PageSourceSearch

https://www.chargehound.com/static/build/752.4983749f93540e85b140.js

js chargehound.com collected 2026-10-03 21:01:27 UTC 272,212 bytes, 2 lines download raw bytes

1/*! For license information please see 752.4983749f93540e85b140.js.LICENSE.txt */
2"use strict";(self.webpackChunkchargehound_api=self.webpackChunkchargehound_api||[]).push([[752],{1167:(e,t,a)=>{a.r(t),a.d(t,{default:()=>qa});var s=a(1882),n=a.n(s),i=a(6924),r=a.n(i),l=a(55364),o=a.n(l),c=a(42203),d=a(96540),m=a(79608),p=a(95011),u=a(18831),h=a(46942),g=a.n(h),v=a(45114),E=a(54625),f=a(64846),y=a.n(f),b=a(8812),N=a(59399),A=a.n(N),w=a(96628),k=a.n(w),S=a(22994),C=a(59006),I=a(26819),P=a(50405),x=a(96515),D=a(20312),T=a.n(D);function L(){return L=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var s in a)({}).hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},L.apply(null,arguments)}function O(e,t,a){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var a=e[Symbol.toPrimitive];if(void 0!==a){var s=a.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class R extends d.Component{constructor(e){super(e),O(this,"onCopy",(()=>{I.A.hide(this.tooltip),this.setState({copy:"Copied!"},(()=>{this.timeout=setTimeout(this.showTooltip)}))})),O(this,"onSelect",(()=>{this.text.select(),this.text.focus()})),O(this,"showTooltip",(()=>{this.tooltip&&I.A.show(this.tooltip),this.timeout=setTimeout(this.resetCopy,1e3)})),O(this,"resetCopy",(()=>{this.setState({copy:"Copy to clipboard"})})),this.state={copy:"Copy to clipboard"}}componentWillUnmount(){this.timeout&&clearTimeout(this.timeout)}render(){return d.createElement("span",{className:"input-group"},d.createElement("input",{spellCheck:!1,onChange:()=>{},ref:e=>{this.text=e},onClick:this.onSelect,className:"emphasis form-control",value:this.props.apiKey}),d.createElement(A(),{text:this.props.apiKey,onCopy:this.onCopy},d.createElement("span",{ref:e=>{this.tooltip=e},"data-for":"copy","data-tip":this.state.copy,className:"input-group-addon"},d.createElement("i",{className:"fa fa-clipboard","aria-hidden":"true"}))))}}class j extends d.Component{constructor(e){super(e),O(this,"toggleAPIKeys",(()=>{this.state.hasKeys?this.setState({showAPIKeys:!this.state.showAPIKeys},(()=>I.A.rebuild())):(0,P.A)({config:this.props.config,identityProvider:this.props.settings.organization.identityProvider,lastLogin:this.props.lastLogin,reauthenticationInterval:this.props.settings.reauthenticationInterval,updateLastLoginTime:this.props.updateLastLoginTime}).then((()=>{this.setState({loading:!0});const e=(0,m.A)({config:this.props.config,name:"settingsApiKeysJson"});return(0,c.Ay)(e)})).then((e=>{this.setState({liveKey:e.live,testKey:e.test,loading:!1,hasKeys:!0,showAPIKeys:!0},(()=>I.A.rebuild()))})).catch((e=>{this.setState({loading:!1,showAPIKeys:!1}),e&&this.props.errorAlert("There was an error loading your keys. Please try again.")}))})),O(this,"rotateAPIKeys",(()=>{this.setState({loading:!0});const e=(0,m.A)({config:this.props.config,name:"settingsApiKeysJson"});(0,c.bE)(e,{mode:this.state.mode}).then((e=>{const t="live"===this.state.mode?"Live":"Test";this.props.successAlert(`${t} API key successfully rotated. Please store your new API key.`),this.setState({liveKey:e.live,testKey:e.test,loading:!1,hasKeys:!0,showAPIKeys:!0,mode:"test",rotateModalOpen:!1},(()=>I.A.rebuild()))})).catch((e=>{this.setState({loading:!1,showAPIKeys:!1}),this.props.errorAlert(e.json.error.message||"There was an error rotating your keys. Please try again.")}))})),O(this,"updateMode",(e=>{const t="on"===e.currentTarget.value?e.currentTarget.name:this.state.endpoint.mode;this.setState({mode:t})})),O(this,"beginRotate",(()=>{(0,P.A)({config:this.props.config,identityProvider:this.props.settings.organization.identityProvider,lastLogin:this.props.lastLogin,reauthenticationInterval:this.props.settings.reauthenticationInterval,updateLastLoginTime:this.props.updateLastLoginTime}).then((()=>{this.setState({rotateModalOpen:!0})}))})),O(this,"cancelRotate",(()=>{this.setState({rotateModalOpen:!1})})),this.state={showAPIKeys:!1,liveKey:null,testKey:null,hasKeys:!1,loading:!1,mode:"test",rotateModalOpen:!1}}render(){let e;this.state.showAPIKeys&&(e=d.createElement("ul",{className:"list-unstyled"},d.createElement("li",{className:"clearfix"},d.createElement("span",{className:"pull-left"},d.createElement(R,{apiKey:this.state.liveKey})),d.createElement("span",{className:"pull-right"},d.createElement("span",{className:"mode-label live"},"live"))),d.createElement("li",{className:"clearfix"},d.createElement("span",{className:"pull-left"},d.createElement(R,{apiKey:this.state.testKey})),d.createElement("span",{className:"pull-right"},d.createElement("span",{className:"mode-label test"},"test")))));let t;Boolean("owner"===this.props.user.state||this.props.user.siteAdmin)&&(t=d.createElement("button",{disabled:this.state.loading,onClick:this.beginRotate,className:"btn btn-primary pull-right"},"Rotate key"));const a="live"===this.state.mode?"Live":"Test";return d.createElement("div",{id:"api-keys",ref:C.A,className:"app-block no-padding tight api-keys-block"},d.createElement(I.A,{id:"copy",effect:"solid",place:"bottom"}),d.createElement("div",{className:"header"}
2,d.createElement("h4",null,"View API Keys")),d.createElement("div",{className:"content"},"These are your API keys and they will allow you to access Chargehound programmatically. Keep them safe."),e,t||e?d.createElement("hr",null):null,d.createElement("div",{className:"btn-section clearfix"},d.createElement("button",{disabled:this.state.loading,onClick:this.toggleAPIKeys,className:"btn btn-secondary pull-left"},this.state.loading&&d.createElement("i",{className:"fa fa-spinner fa-spin fa-fw"}),d.createElement("span",null,!this.state.loading&&this.state.showAPIKeys?"Hide keys":"Show keys")),t),d.createElement(T(),{isOpen:this.state.rotateModalOpen,onRequestClose:this.cancelRotate,contentLabel:"Rotate Keys Modal",className:"dialog-modal-content",overlayClassName:"dialog-modal-overlay"},d.createElement("div",{className:"rotate-modal"},d.createElement("button",{onClick:this.cancelRotate,type:"button",className:"close","data-dismiss":"modal","aria-label":"Close"},d.createElement("span",{"aria-hidden":"true"},"×")),d.createElement("h4",null,"Rotate API Key"),d.createElement("div",null,"A key rotation will generate a new API key for your account."),d.createElement("br",null),d.createElement("div",null,"Once you rotate your key, ",d.createElement("strong",null,"your current key will work for 12 hours and then it will be invalid.")),d.createElement("div",null,d.createElement("hr",null),d.createElement("div",{className:"row-heading emphasis"},"Account Key to Rotate"),d.createElement("div",{className:"mode-select"},d.createElement("input",{type:"radio",name:"live",checked:"live"===this.state.mode,onChange:this.updateMode}),d.createElement("label",{htmlFor:"live"},"Live"),d.createElement("input",{type:"radio",name:"test",checked:"test"===this.state.mode,onChange:this.updateMode}),d.createElement("label",{htmlFor:"test"},"Test")),d.createElement("hr",null)),d.createElement("div",{className:"alert alert-warning"},d.createElement("div",null,"Clicking confirm will rotate your ",d.createElement("strong",null,a," API key."))),d.createElement("div",{className:"btns"},d.createElement("button",{className:"btn btn-primary",onClick:this.rotateAPIKeys},"Confirm key rotation")))))}}class M extends d.Component{constructor(e){super(e),O(this,"saveChanges",(()=>{const e=(0,m.A)({config:this.props.config,name:"settingsApiIpAllowlistJson"});this.setState({saving:!0}),y()(this.props.index)?(0,c.yJ)(e,{update:this.state.ip,ip:this.props.ip,mode:this.state.mode}).then((e=>{this.props.updateSettings({accounts:e.accounts}),this.cancelEditing(),this.props.successAlert("Your IP restrictions were updated.")})).catch((e=>{this.setState({saving:!1}),this.props.errorAlert(e.json.error.message)})):(0,c.bE)(e,{ip:this.state.ip,mode:this.state.mode}).then((e=>{this.props.updateSettings({accounts:e.accounts}),this.cancelEditing(),this.props.successAlert("Your IP restrictions were updated.")})).catch((e=>{this.setState({saving:!1}),this.props.errorAlert(e.json.error.message)}))})),O(this,"updateMode",(e=>{const t="on"===e.currentTarget.value?e.currentTarget.name:this.state.mode;this.setState({mode:t})})),O(this,"updateIp",(e=>{this.setState({ip:e.currentTarget.value})})),O(this,"clearState",(()=>{this.setState({saving:!1,ip:"",mode:"test"})})),O(this,"cancelEditing",(()=>{this.clearState(),this.props.cancelEditing()})),this.state={saving:!1,ip:e.ip||"",mode:e.mode||"test"}}render(){let e,t,a;return y()(this.props.index)?t=d.createElement("span",{className:g()({"mode-label":!0,[this.state.mode]:!0})},"live"===this.state.mode?"Live":"Test"):e=d.createElement("div",null,d.createElement("hr",null),d.createElement("div",{className:"row-heading emphasis"},"Mode"),d.createElement("div",{className:"mode-select"},d.createElement("input",{type:"radio",name:"live",checked:"live"===this.state.mode,onChange:this.updateMode}),d.createElement("label",{htmlFor:"live"},"Live"),d.createElement("input",{type:"radio",name:"test",checked:"test"===this.state.mode,onChange:this.updateMode}),d.createElement("label",{htmlFor:"test"},"Test")),d.createElement("div",{className:"explain"},"Allow this IP address for live or test API requests.")),this.props.accounts[this.state.mode].ipAllowlist&&this.props.accounts[this.state.mode].ipAllowlist.length||(a=d.createElement("div",{className:"alert alert-warning"},"Once you've added a allowed IP address for ",this.state.mode," API requests,"," ","all ",this.state.mode," requests that are not in the allowed IPs will be rejected.")),d.createElement(T(),{isOpen:this.props.isOpen,onRequestClose:this.cancelEditing,contentLabel:"IP Modal",className:"dialog-modal-content",overlayClassName:"dialog-modal-overlay"},d.createElement("div",{className:"ip-modal"},d.createElement("button",{onClick:this.cancelEditing,type:"button",className:"close","data-dismiss":"modal","aria-label":"Close"},d.createElement("span",{"aria-hidden":"true"},"×")),d.createElement("h4",null,y()(this.props.index)?"Update":"Add an"," IP"),t,d.createElement("div",null,d.createElement("div",{className:"row-heading emphasis"},"IP address"),d.createElement("input",{className:"form-control",onChange:this.updateIp,type:"text",name:"ip",value:this.state.ip,placeholder:"127.0.0.1"}),d.createElement("div",{className:"explain"},"IP address to allow for API requests. CIDR notation is supported. Examples: 127.0.0.1, 192.168.0.0/24")),e,a,d.createElement("div",{className:"btns clearfix"},d.createElement("span",{className:"pull-right"},d.createElement("button",{onClick:this.cancelEditing,disabled:this.state.saving,className:"btn btn-default"},"Cancel"),d.createElement("button",{onClick:this.saveChanges,disabled:this.state.saving,className:"btn btn-margin-left btn-primary"}
2,"Save")))))}}class U extends d.Component{constructor(e){super(e),O(this,"addNewIp",(()=>{(0,P.A)({config:this.props.config,identityProvider:this.props.settings.organization.identityProvider,lastLogin:this.props.lastLogin,reauthenticationInterval:this.props.settings.reauthenticationInterval,updateLastLoginTime:this.props.updateLastLoginTime}).then((()=>{this.setState({ipModalOpen:!0,editingIp:null,editingIpMode:"test",editingIpIndex:null})}))})),O(this,"cancelEditing",(()=>{this.setState({ipModalOpen:!1,editingIp:null,editingIpMode:"test",editingIpIndex:null})})),this.state={ipModalOpen:!1,editingIp:null,editingIpMode:"test",editingIpIndex:null}}editIp(e,t,a){(0,P.A)({config:this.props.config,identityProvider:this.props.settings.organization.identityProvider,lastLogin:this.props.lastLogin,reauthenticationInterval:this.props.settings.reauthenticationInterval,updateLastLoginTime:this.props.updateLastLoginTime}).then((()=>{this.setState({ipModalOpen:!0,editingIp:e,editingIpMode:t,editingIpIndex:a})}))}deleteIp(e,t){(0,P.A)({config:this.props.config,identityProvider:this.props.settings.organization.identityProvider,lastLogin:this.props.lastLogin,reauthenticationInterval:this.props.settings.reauthenticationInterval,updateLastLoginTime:this.props.updateLastLoginTime}).then((()=>(0,b.A)({title:"Remove IP",message:d.createElement("span",null,"Are you sure you want to remove ",d.createElement("strong",null,e)," from the allowed IPs?")}))).then((()=>{this.props.setSaving(!0);const a=(0,m.A)({config:this.props.config,name:"settingsApiIpAllowlistJson"});return(0,c.yH)(a,{ip:e,mode:t})})).then((t=>{this.props.updateSettings({accounts:t.accounts}),this.props.setSaving(!1),this.props.successAlert(`${e} was successfully removed from the allowed IPs.`)})).catch((e=>{e&&(this.props.setSaving(!1),this.props.errorAlert(e.json.error.message))}))}render(){const{live:e,test:t}=this.props.settings.accounts,a=Boolean("owner"===this.props.user.state||this.props.user.siteAdmin);let s=[];return e.ipAllowlist&&e.ipAllowlist.length&&(s=s.concat(e.ipAllowlist.map(((e,t)=>{let s;return a&&(s=d.createElement("span",{className:"actions"},d.createElement("a",{onClick:this.editIp.bind(this,e,"live",t),className:"edit"},"edit"),d.createElement("a",{onClick:this.deleteIp.bind(this,e,"live"),className:"edit"},"remove"))),d.createElement("li",{className:"clearfix ip",key:t},d.createElement("span",null,d.createElement("span",{className:"pull-left"},d.createElement("span",{className:""},d.createElement("code",null,e)," ",s)),d.createElement("span",{className:"pull-right"},d.createElement("span",{className:g()({"mode-label":!0,live:!0})},"live"))))})))),t.ipAllowlist&&t.ipAllowlist.length&&(s=s.concat(t.ipAllowlist.map(((e,t)=>{let s;return a&&(s=d.createElement("span",{className:"actions"},d.createElement("a",{onClick:this.editIp.bind(this,e,"test",t),className:"edit"},"edit"),d.createElement("a",{onClick:this.deleteIp.bind(this,e,"test"),className:"edit"},"remove"))),d.createElement("li",{className:"clearfix ip",key:t},d.createElement("span",null,d.createElement("span",{className:"pull-left"},d.createElement("span",{className:""},d.createElement("code",null,e)," ",s)),d.createElement("span",{className:"pull-right"},d.createElement("span",{className:g()({"mode-label":!0,test:!0})},"test"))))})))),s.length||a?s.length?a?d.createElement("div",{id:"ip-allowlist",ref:C.A,className:"app-block no-padding tight ip-allowlist-block"},d.createElement("div",{className:"header"},d.createElement("h4",null,"IP Restrictions")),d.createElement("div",{className:"content"},"Your API access is restricted by IP address. The IPs that can access the API are listed below. You can add up to 10 allowed IP addresses per mode."),d.createElement("hr",null),d.createElement("div",{className:"restrictions-container"},d.createElement("ul",{className:"list-unstyled"},s)),d.createElement("hr",null),d.createElement("div",{className:"item-add text-right"},d.createElement("span",{className:"explainer"},"Add an IP"),d.createElement("button",{onClick:this.addNewIp,className:"btn btn-primary"},d.createElement("span",{className:"fa fa-plus"}))),d.createElement(M,{key:`${this.state.editingIp}-${this.state.editingIpIndex}`,isOpen:this.state.ipModalOpen,cancelEditing:this.cancelEditing,ip:this.state.editingIp,mode:this.state.editingIpMode,index:this.state.editingIpIndex,config:this.props.config,accounts:this.props.settings.accounts,updateSettings:this.props.updateSettings,successAlert:this.props.successAlert,errorAlert:this.props.errorAlert})):d.createElement("div",{id:"ip-allowlist",ref:C.A,className:"app-block no-padding tight ip-allowlist-block"},d.createElement("div",{className:"header"},d.createElement("h4",null,"IP Restrictions")),d.createElement("div",{className:"content"},"Your API access is restricted by IP address. The IPs that can access the dashboard are listed below."),d.createElement("hr",null),d.createElement("div",{className:"restrictions-container"},d.createElement("ul",{className:"list-unstyled"},s))):d.createElement("div",{id:"ip-allowlist",ref:C.A,className:"app-block no-padding tight ip-allowlist-block"},d.createElement("div",{className:"header"},d.createElement("h4",null,"IP Restrictions")),d.createElement("div",{className:"content"},"You can restrict API access by IP address."),d.createElement("hr",null),d.createElement("div",{className:"item-add text-right"},d.createElement("span",{className:"explainer"},"Add an IP"),d.createElement("button",{onClick:this.addNewIp,className:"btn btn-primary"},d.createElement("span",{className:"fa fa-plus"}))),d.createElement(M,{key:`${this.state.editingIp}-${this.state.editingIpIndex}`,isOpen:this.state.ipModalOpen,cancelEditing:this.cancelEditing,ip:this.state.editingIp,mode:this.state.editingIpMode,index:this.state.editingIpIndex,config:this.props.config,accounts:this.props.settings.accounts,updateSettings:this.props.updateSettings,successAlert:this.props.successAlert,errorAlert:this.props.errorAlert})):null}}class K extends d.Component{constructor(e){super(e),O(this,"beginUpgrade",(()=>{this.setState({upgradeModalOpen:!0})})),O(this,"cancelUpgrade",(()=>{this.setState({upgradeModalOpen:!1})})),O(this,"setOrgVersion",(e=>{const t=(0,m.A)({config:this.props.config,name:"settingsVersioningJson"});return this.cancelUpgrade(),this.props.setSaving(!0),(0,c.bE)(t,{version:e}).then((e=>{this.props.updateSettings(e),this.props.setSaving(!1),this.props.successAlert("API version updated.")})).catch((e=>{e&&(this.props.setSaving(!1),this.props.errorAlert(e.json.error.message))}))})),this.state={upgradeModalOpen:!1}}
2render(){const e=this.props.settings.versioning.versions[0];let t,a,s;return this.props.settings.versioning.upToDate?t=d.createElement("span",{className:"label label-success"},"Up to date"):(t=d.createElement("span",{className:"label label-primary"},"Upgrade available"),s=d.createElement("div",null,"Check the ",d.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:`${this.props.config.webHost}/docs/api/${e}/#changelog`},d.createElement("span",null,"changelog"))," to see if your integration will be affected. Read more about ",d.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:`${this.props.config.webHost}/docs/api/${e}/#versioning`},d.createElement("span",null,"versioning")),"."),a=d.createElement("div",{className:"btn-section"},d.createElement("button",{onClick:this.beginUpgrade,className:"btn btn-primary"},"Upgrade API version"))),d.createElement("div",{id:"api-version",ref:C.A,className:"app-block no-padding tight api-version-block"},d.createElement(I.A,{id:"copy",effect:"solid",place:"bottom"}),d.createElement("div",{className:"header"},d.createElement("h4",null,"API Version")),d.createElement("div",{className:"content"},d.createElement("div",{className:g()({"section-upper":Boolean(s)})},"You're using API version ",d.createElement("strong",null,this.props.settings.versioning.currentVersion)," ",t),s),a,d.createElement(T(),{isOpen:this.state.upgradeModalOpen,onRequestClose:this.cancelUpgrade,contentLabel:"Upgrade Modal",className:"dialog-modal-content",overlayClassName:"dialog-modal-overlay"},d.createElement("div",{className:"upgrade-modal"},d.createElement("button",{onClick:this.cancelUpgrade,type:"button",className:"close","data-dismiss":"modal","aria-label":"Close"},d.createElement("span",{"aria-hidden":"true"},"×")),d.createElement("h4",null,"Upgrade API Version"),d.createElement("div",{className:"alert alert-warning"},d.createElement("div",null,d.createElement("strong",null,"You will not be able to roll back after upgrading."))),d.createElement("div",null,"Check the ",d.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:`${this.props.config.webHost}
2/docs/api/${e}/#changelog`},"changelog")," to see if your integration will be affected by any of the breaking changes."),d.createElement("br",null),d.createElement("div",null,"Before upgrading your API version, you should ",d.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:`${this.props.config.webHost}/docs/api/${e}/#testing`},"test")," your integration by setting the ",d.createElement("code",null,"Chargehound-Version")," header to the new version, ",d.createElement("strong",null,e),", for individual API requests."),d.createElement("br",null),d.createElement("div",null,"Clicking confirm will set your API version to the latest version, ",d.createElement("strong",null,e),"."),d.createElement("div",{className:"btns"},d.createElement("button",{className:"btn btn-primary",onClick:()=>this.setOrgVersion(e)},"Confirm upgrade")))))}}const _={isNew:!0,id:"new",processors:[],accounts:[],url:"",mode:"test",events:{"dispute.created":!1,"dispute.updated":!1,"dispute.submitted":!1,"dispute.closed":!1,"dispute.response.generated":!1,"dispute.ce3_ineligible":!1,"pre_dispute.refunded":!1}},z=["dispute.created","dispute.updated","dispute.submitted","dispute.closed","dispute.response.generated","dispute.ce3_ineligible","pre_dispute.refunded"];class F extends d.Component{constructor(e){super(e),O(this,"saveChanges",(()=>{const e=(0,m.A)({config:this.props.config,name:"organizationSettingsJson",params:["webhook-urls"]}),t=this.state.prefix+this.state.url;let a=this.state.endpoint.processors;if(!a.length&&!this.state.endpoint.accounts.length&&"live"===this.state.endpoint.mode){Object.keys(this.props.settings.credentials).map((e=>!!this.props.settings.credentials[e].filter((e=>"stripe"===e.processor||e.mode===this.state.endpoint.mode)).length)).filter((e=>!!e)).length||(a=["all"])}this.setState({saving:!0}),(0,c.bE)(e,{endpoint:{url:t,events:this.state.endpoint.events,mode:this.state.endpoint.mode,processors:a,accounts:this.state.endpoint.accounts,id:this.state.endpoint.id,isNew:this.state.endpoint.isNew,version:this.state.endpoint.version},action:"update"}).then((e=>{this.props.updateSettings({webhookUrls:e.webhookUrls}),this.props.cancelEditing(),I.A.rebuild(),this.props.successAlert("Your Webhook URL was saved.")})).catch((e=>{this.setState({saving:!1}),this.props.errorAlert(e.json.error.message)}))})),O(this,"pollForWebhookResult",(()=>{const e=(0,m.A)({config:this.props.config,name:"organizationSettingsJson",params:["webhook-urls"]});return(0,c.Ay)(e,!0)})),O(this,"sendTestWebhook",(()=>{const e=(0,m.A)({config:this.props.config,name:"organizationSettingsJson",params:["webhook-urls"]}),t=this.state.prefix+this.state.url;this.setState({testing:!0}),(0,c.bE)(e,{url:t,action:"test",mode:this.state.endpoint.mode}).then((()=>(this.props.infoAlert(`Sending a test event to '${t}'.`),this.pollForWebhookResult()))).then((e=>{e.success?(this.setState({testing:!1}),this.props.successAlert(e.message)):(this.setState({testing:!1}),e.sslError?this.props.errorAlert(d.createElement("span",null,"Webhook delivery failed, encountered SSL error."," ","You can test your SSL integration"," ",d.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:"https://www.ssllabs.com/ssltest/index.html"},"here"),".")):this.props.errorAlert(e.message))})).catch((e=>{this.setState({testing:!1}),this.props.errorAlert(e.json.error.message)}))})),O(this,"updateMode",(e=>{const t="on"===e.currentTarget.value?e.currentTarget.name:this.state.endpoint.mode;this.setState((e=>({endpoint:o()(e.endpoint,{mode:t}),prefix:"live"===t?"https://":e.prefix})))})),O(this,"updatePrefix",(e=>{this.setState({prefix:e})})),O(this,"protoRe",/^(https?:\/\/)/i),O(this,"updateUrl",(e=>{let t,a,s=e.currentTarget.value;if(s){const e=s.match(this.protoRe);e&&(t="live"===this.state.endpoint.mode?"https://":e[1],s=s.replace(this.protoRe,""))}a=t||this.state.prefix,this.setState({url:s,prefix:a})})),O(this,"updateVersion",(e=>{this.setState((t=>({endpoint:o()(t.endpoint,{version:e})})))})),O(this,"updateSelectedProcessors",((e,t)=>{this.setState((e=>(e.endpoint.processors=t.filter((e=>{let{type:t}=e;return"processor"===t})).map((e=>{let{value:t}=e;return t})),e.endpoint.accounts=t.filter((e=>{let{type:t}=e;return"account"===t})).map((e=>{let{value:t}=e;return t})),{endpoint:e.endpoint})))})),O(this,"onNodeToggle",(e=>{"processor"===e.type&&this.setState((t=>{t.toggledNodes[e.value]=e.expanded}))}));const{endpoint:t}=e;let a="https://";t.url&&0===t.url.toLowerCase().indexOf("http://")&&(a="http://");const s=t.url.replace(a,"");t.events=(0,u.decamelizeKeys)(t.events),this.state={testing:!1,saving:!1,prefix:a,url:s,endpoint:t,toggledNodes:{}}}updateEvent(e){this.setState((t=>({endpoint:o()(t.endpoint,{events:{[e]:!t.endpoint.events[e]}})})))}
2render(){const e=this.props.settings.versioning.versions[0];let t,a,s;this.state.endpoint.isNew?t=d.createElement("div",null,d.createElement("hr",null),d.createElement("div",{className:"row-heading emphasis"},"Mode"),d.createElement("div",{className:"mode-select"},d.createElement("input",{type:"radio",name:"live",checked:"live"===this.state.endpoint.mode,onChange:this.updateMode}),d.createElement("label",{htmlFor:"live"},"Live"),d.createElement("input",{type:"radio",name:"test",checked:"test"===this.state.endpoint.mode,onChange:this.updateMode}),d.createElement("label",{htmlFor:"test"},"Test")),d.createElement("div",{className:"explain"},"Send live mode events or test mode events.")):a=d.createElement("span",{className:g()({"mode-label":!0,[this.state.endpoint.mode]:!0})},"live"===this.state.endpoint.mode?"Live":"Test"),s="live"===this.state.endpoint.mode?d.createElement("span",{className:"input-group-addon emphasis"},this.state.prefix):d.createElement(x._,{value:this.state.prefix,values:["http://","https://"],setPrefix:this.updatePrefix});const n=this.state.endpoint.processors,i=this.state.endpoint.accounts,r=n.some((e=>"all"===e)),l=Object.keys(this.props.settings.credentials).sort().map((e=>{const t=this.props.settings.credentials[e].filter((e=>"stripe"===e.processor||e.mode===this.state.endpoint.mode)).map((t=>({label:t.title||(0,S.A)(t),type:"account",value:t.slug,checked:r||n.some((t=>t===e))||i.some((e=>e===t.slug))})));return t.length?{label:`${S.y[e]} (all accounts)`,type:"processor",value:e,children:t,checked:r||n.some((t=>t===e)),expanded:this.state.toggledNodes[e]}:null})).filter((e=>!!e));let o;return"test"===this.state.endpoint.mode&&"test"===this.state.endpoint.mode&&l.push({label:"Test Disputes",type:"processor",value:"mocks",checked:r||n.some((e=>"mocks"===e))}),o=l.length?d.createElement("div",null,d.createElement("hr",null),d.createElement("div",null,d.createElement("div",{className:"row-heading emphasis"},"Processors"),d.createElement(k(),{data:{label:"All",type:"processor",value:"all",checked:r,children:l,expanded:!0},texts:{placeholder:"Choose a processor..."},onFocus:()=>this.setState({processorFocus:!0}),onBlur:()=>this.setState({processorFocus:!1}),onNodeToggle:this.onNodeToggle,className:g()({"processor-dropdown":!0,focus:this.state.processorFocus}),showPartiallySelected:!0,onChange:this.updateSelectedProcessors}),d.createElement("div",{className:"explain"},"Send webhooks for specific processors, specific accounts, or all connected accounts."))):d.createElement("div",null,d.createElement("hr",null),d.createElement("div",null,d.createElement("div",{className:"row-heading emphasis"},"Processors"),d.createElement("div",null,d.createElement("code",null,"All")),d.createElement("div",{className:"explain"},"Once you've connected an account you can edit the webhook to send events for specific accounts or processors."))),d.createElement(T(),{isOpen:!0,onRequestClose:this.props.cancelEditing,contentLabel:"Webhook Modal",className:"dialog-modal-content",overlayClassName:"dialog-modal-overlay"},d.createElement("div",{className:"webhook-modal"},d.createElement("button",{onClick:this.props.cancelEditing,type:"button",className:"close","data-dismiss":"modal","aria-label":"Close"},d.createElement("span",{"aria-hidden":"true"},"×")),d.createElement("h4",null,this.state.endpoint.isNew?"Add":"Update"," Webhook"),a,d.createElement("div",null,d.createElement("div",{className:"row-heading emphasis"},"URL"),d.createElement("div",{className:"input-group url"},s,d.createElement("input",{className:"form-control",onChange:this.updateUrl,type:"text",name:"url",value:this.state.url,placeholder:"www.example.com/webhook-handler"})),d.createElement("div",{className:"explain"},"URL to be called with the event data.")),t,o,d.createElement("hr",null),d.createElement("div",null,d.createElement("div",{className:"row-heading emphasis"},"API Version"),d.createElement("select",{className:"version-select",onChange:e=>this.updateVersion(e.currentTarget.value),value:this.state.endpoint.version,name:"template"}
2,this.props.settings.versioning.versions.map((e=>d.createElement("option",{key:e,value:e},e)))),this.state.endpoint.version===e?d.createElement("span",{className:"label label-success"},"Up to date"):d.createElement("span",{className:"label label-primary"},"Upgrade available"),d.createElement("div",{className:"explain"},"API version for the event. The event object may differ between versions. Check the ",d.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:`${this.props.config.webHost}/docs/api/${e}/#changelog`},"changelog")," to see if your integration will be affected.")),d.createElement("hr",null),d.createElement("div",{className:"row-heading emphasis"},"Events"),d.createElement("ul",{className:"list-unstyled"},z.filter((e=>!("dispute.ce3_ineligible"===e&&(!this.state.endpoint.version||this.state.endpoint.version<"2026-02-03"))&&!("pre_dispute.refunded"===e&&(!this.state.endpoint.version||this.state.endpoint.version<"2026-08-13")))).map((e=>d.createElement("li",{className:"event",key:e},d.createElement("input",{type:"checkbox",name:e,checked:this.state.endpoint.events[e],onChange:this.updateEvent.bind(this,e)}),d.createElement("code",null,e))))),d.createElement("div",{className:"explain"},"Which event types to send."),d.createElement("div",{className:"btns clearfix"},d.createElement("span",{className:"pull-left"},d.createElement("button",{onClick:this.sendTestWebhook,disabled:this.state.testing,className:"btn btn-default test"},"Send test event")),d.createElement("span",{className:"pull-right"},d.createElement("button",{onClick:this.props.cancelEditing,disabled:this.state.saving,className:"btn btn-default"},"Cancel"),d.createElement("button",{onClick:this.saveChanges,disabled:this.state.saving,className:"btn btn-margin-left btn-primary"},"Save")))))}}class $ extends d.Component{constructor(e){super(e),O(this,"getDefaultEndpoint",(()=>{const e=this.props.settings.versioning.currentVersion||this.props.settings.versioning.versions[0];return o()({version:e},_)})),O(this,"addEndpoint",(()=>{(0,P.A)({config:this.props.config,identityProvider:this.props.settings.organization.identityProvider,lastLogin:this.props.lastLogin,reauthenticationInterval:this.props.settings.reauthenticationInterval,updateLastLoginTime:this.props.updateLastLoginTime}).then((()=>{this.setState({modalOpen:!0,editingEndpoint:this.getDefaultEndpoint()})}))})),O(this,"cancelEditing",(()=>{this.setState({modalOpen:!1,editingEndpoint:this.getDefaultEndpoint()})})),O(this,"censorRe",/(http:\/\/|https:\/\/)([^\s",\'"]*:[^\s",\'"]*)@(.+)/),O(this,"toggleUseProxy",(e=>{const t=e.currentTarget.checked;this.props.setSaving(!0);const a=(0,m.A)({config:this.props.config,name:"organizationSettingsJson",params:["webhook-proxy"]});(0,c.bE)(a,{useProxy:t}).then((()=>{this.setState({useProxy:t}),this.props.setSaving(!1)})).catch((e=>{e&&(this.props.setSaving(!1),this.props.errorAlert(e.json.error.message))}))})),this.state={modalOpen:!1,editingEndpoint:this.getDefaultEndpoint(),useProxy:this.props.settings.useWebhookProxy}}censorUrl(e){const t=this.censorRe.exec(e);return t&&(e=t[1]+"****:****@"+t[3]),e}deleteEndpoint(e){(0,P.A)({config:this.props.config,identityProvider:this.props.settings.organization.identityProvider,lastLogin:this.props.lastLogin,reauthenticationInterval:this.props.settings.reauthenticationInterval,updateLastLoginTime:this.props.updateLastLoginTime,respectGracePeriod:!1}).then((()=>(0,b.A)({title:"Remove URL",message:d.createElement("span",null,"Are you sure you want to delete ",d.createElement("strong",null,this.censorUrl(e.url)),"? Webhooks will no longer be sent to this url.")}))).then((()=>{this.props.setSaving(!0);const t=(0,m.A)({config:this.props.config,name:"organizationSettingsJson",params:["webhook-urls"]});return(0,c.bE)(t,{endpoint:e,action:"delete"})})).then((t=>{this.props.updateSettings({webhookUrls:t.webhookUrls}),this.props.setSaving(!1),this.props.successAlert(`${e.url} was successfully deleted.`)})).catch((e=>{e&&(this.props.setSaving(!1),this.props.errorAlert(e.json.error.message))}))}
2editEndpoint(e){(0,P.A)({config:this.props.config,identityProvider:this.props.settings.organization.identityProvider,lastLogin:this.props.lastLogin,reauthenticationInterval:this.props.settings.reauthenticationInterval,updateLastLoginTime:this.props.updateLastLoginTime}).then((()=>{this.setState({modalOpen:!0,editingEndpoint:o()({},e),useProxy:this.props.settings.useWebhookProxy})}))}render(){const e=this.props.settings.versioning.currentVersion;let t,a,s;return this.props.settings.webhookUrls.length&&(t=d.createElement("div",null,d.createElement(I.A,{id:"url",effect:"solid",multiline:!0}),d.createElement("hr",{className:"margin-none"}),d.createElement("ul",{className:"list-unstyled"},this.props.settings.webhookUrls.map((e=>{let t=this.censorUrl(e.url);return t.length>=50&&(t=d.createElement("span",{className:"inline-block","data-for":"url","data-tip":t.replace(/(.{40})/g,"$1<br/>")},t.slice(0,40)+"...")),d.createElement("li",{className:"endpoint clearfix",key:e.id},d.createElement("span",null,d.createElement("span",{className:"pull-left"},d.createElement("span",{className:"url emphasis"},t),d.createElement("span",{className:"actions"},d.createElement("a",{onClick:this.editEndpoint.bind(this,e),className:"edit"},"edit"),d.createElement("a",{onClick:this.deleteEndpoint.bind(this,e),className:"edit"},"remove"))),d.createElement("span",{className:"pull-right"},d.createElement("span",{className:g()({"mode-label":!0,[e.mode]:!0})},e.mode))))})))),a=d.createElement("div",{className:"webhook-proxy"},d.createElement("div",{className:"use-proxy"},d.createElement("strong",null,"Use a static IP",d.createElement("div",{className:"pull-right"},d.createElement("input",{type:"checkbox",checked:this.state.useProxy,onChange:this.toggleUseProxy,disabled:this.state.saving}))),d.createElement("div",null,"Send webhooks from a set of fixed IP addresses to allow for firewall allowlisting.")))),this.state.modalOpen&&(s=d.createElement(F,L({cancelEditing:this.cancelEditing,endpoint:this.state.editingEndpoint},this.props))),d.createElement("div",{id:"webhooks",ref:C.A,className:"app-block no-padding tight webhook-settings"},d.createElement("div",{className:"header"},d.createElement("h4",null,"Webhook Settings")),d.createElement("div",{className:"content"},"Chargehound can send you a webhook notification when a dispute is created, updated, submitted, closed, or when a dispute response is generated."),a,d.createElement("div",{className:"content webhook-doc"},d.createElement("a",{target:"_blank",className:"doc-link",rel:"noopener noreferrer",href:`${this.props.config.webHost}
2/docs/api/${e}/#webhooks`},"View webhook documentation")),d.createElement("div",{className:"webhook-urls"},t,d.createElement("hr",null),d.createElement("div",{className:"item-add text-right"},d.createElement("span",{className:"explainer"},"Add webhook URL"),d.createElement("button",{onClick:this.addEndpoint,className:"btn btn-primary"},d.createElement("span",{className:"fa fa-plus"})))),s)}}function B(e){return d.createElement("div",null,d.createElement(j,e),d.createElement(U,e),d.createElement(K,e),d.createElement($,e))}var V=a(12225),q=a(46005);function Y(){return Y=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var s in a)({}).hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},Y.apply(null,arguments)}function J(e,t,a){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var a=e[Symbol.toPrimitive];if(void 0!==a){var s=a.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class W extends d.Component{constructor(e){super(e),J(this,"updateOrgName",(e=>{this.setState({editedOrgName:e.currentTarget.value})})),J(this,"onOrgNameSave",(()=>{(0,P.A)({config:this.props.config,identityProvider:this.props.settings.organization.identityProvider,lastLogin:this.props.lastLogin,reauthenticationInterval:this.props.settings.reauthenticationInterval,updateLastLoginTime:this.props.updateLastLoginTime,respectGracePeriod:!1}).then((()=>{const e=(0,m.A)({config:this.props.config,name:"settingsOrganizationNameJson"}),t=this.state.editedOrgName;(0,b.A)({title:"Change Organization Name",message:d.createElement("span",null,"Are you sure you want to change your organization name to ",d.createElement("b",null,t),"?")}).then((()=>(this.props.setSaving(!0),(0,c.bE)(e,{name:t})))).then((e=>{this.props.setSaving(!1);const{organization:a}=this.props.settings;a.name=e.name,this.props.updateSettings({organization:a}),this.props.updateUserOrganization(e),this.props.successAlert(`Organization name updated to ${t}.`)})).catch((e=>{e&&(this.props.setSaving(!1),this.props.errorAlert(e.json.error.message))}))}))})),this.state={editedOrgName:e.user.organization.name}}render(){return d.createElement("div",{id:"organization-name",ref:C.A,className:"app-block no-padding tight"},d.createElement("div",{className:"header"},d.createElement("h4",null,"Organization Name")),d.createElement("div",{className:"padding-15"},d.createElement("div",{className:"section-upper"},d.createElement("strong",null,"Change the name of your organization")),d.createElement("div",null,d.createElement("input",{onChange:this.updateOrgName,value:this.state.editedOrgName,type:"text",maxLength:"100",placeholder:"Your organization's name",className:"form-control"}))),d.createElement("hr",null),d.createElement("div",{className:"btn-section clearfix pull-right"},d.createElement("button",{disabled:this.state.editedOrgName===this.props.user.organization.name||!this.state.editedOrgName,onClick:this.onOrgNameSave,className:"btn btn-primary"},"Save changes")))}}class H extends d.Component{constructor(e){super(e),J(this,"onCopy",(()=>{I.A.hide(this.tooltip),this.setState({copy:"Copied!"},(()=>{this.timeout=setTimeout(this.showTooltip)}))})),J(this,"onSelect",(()=>{this.text.select(),this.text.focus()})),J(this,"showTooltip",(()=>{this.tooltip&&I.A.show(this.tooltip),this.timeout=setTimeout(this.resetCopy,1e3)})),J(this,"resetCopy",(()=>{this.setState({copy:"Copy to clipboard"})})),this.state={copy:"Copy to clipboard"}}componentWillUnmount(){this.timeout&&clearTimeout(this.timeout)}render(){return d.createElement("span",{className:"input-group"},d.createElement(I.A,{id:this.props.id,effect:"solid",place:"bottom"}),d.createElement("input",{type:"text",spellCheck:!1,onChange:()=>{},ref:e=>{this.text=e},onClick:this.onSelect,className:"form-control",value:this.props.link,autoComplete:"one-time-code"}),d.createElement(A(),{text:this.props.link,onCopy:this.onCopy},d.createElement("span",{ref:e=>{this.tooltip=e},"data-for":this.props.id,"data-tip":this.state.copy,className:"input-group-addon"},d.createElement("i",{className:"fa fa-clipboard","aria-hidden":"true"}))))}}class G extends d.Component{constructor(){super(...arguments),J(this,"handleSelect",(e=>{this.props.updatePasswordExpire(e.value)})),J(this,"expireOptions",[{label:"never",value:0},{label:"after 90 days",value:90},{label:"after 180 days",value:180},{label:"after 360 days",value:360}])}
2render(){return d.createElement("div",{className:"inner-content"},d.createElement("div",{className:"row-heading"},d.createElement("strong",null,"Expire passwords")),d.createElement(q.Ay,{styles:V.A,onChange:this.handleSelect,options:this.expireOptions,value:this.expireOptions.filter((e=>{let{value:t}=e;return t===this.props.passwordExpire})),isClearable:!1,isSearchable:!1}),d.createElement("div",{className:"setting-notice"},"Require your users to update their passwords regularly."))}}class X extends d.Component{constructor(e){super(e),J(this,"updateIdentityProvider",(e=>{const t="on"===e.currentTarget.value?e.currentTarget.name:this.state.identityProvider;this.setState({identityProvider:t,edited:!0})})),J(this,"updateSamlMetadataUrl",(e=>{const t=e.currentTarget.value;this.setState({samlMetadataUrl:t,edited:!0,samlIsValid:!1})})),J(this,"updateSamlEntityId",(e=>{const t=e.currentTarget.value;this.setState({samlEntityId:t,edited:!0})})),J(this,"updatePasswordExpire",(e=>{this.setState({passwordExpire:e,edited:!0})})),J(this,"toggleMfa",(()=>{const e=!this.state.mfaRequired;this.setState({mfaRequired:e,edited:!0})})),J(this,"validateSamlMetadataUrl",(()=>{this.setState({samlIsValid:!1,samlIsValidating:!0});const e=(0,m.A)({config:this.props.config,name:"settingsSamlMetadataValidationJson"});(0,c.bE)(e,{url:this.state.samlMetadataUrl}).then((e=>{e.success?(this.setState({samlMetadataUrl:e.url,samlEntityId:e.entityId,samlIsValidating:!1,samlIsValid:!0}),this.props.successAlert(e.message)):(this.setState({samlIsValidating:!1,samlIsValid:!1}),this.props.errorAlert(e.message))})).catch((e=>{this.setState({samlIsValidating:!1,samlIsValid:!1}),this.props.errorAlert(e.json.error.message)}))})),J(this,"onSave",(()=>{if("saml"===this.state.identityProvider){if(!this.state.samlMetadataUrl)return void this.props.errorAlert("Please supply a valid metadata URL");if(!this.state.samlEntityId)return void this.props.errorAlert("Please specify the entity ID")}(0,P.A)({config:this.props.config,identityProvider:this.props.settings.organization.identityProvider,lastLogin:this.props.lastLogin,reauthenticationInterval:this.props.settings.reauthenticationInterval,updateLastLoginTime:this.props.updateLastLoginTime,respectGracePeriod:!1}).then((()=>(0,b.A)({title:"Confirm Change of Authentication Settings",messageElement:d.createElement("div",null,"Are you sure you want to change your authentication settings? This action will affect all users in your organization.")}).then((()=>{this.props.setSaving(!0);const e=(0,m.A)({config:this.props.config,name:"settingsAuthProviderJson"});(0,c.bE)(e,{identityProvider:this.state.identityProvider,samlMetadataUrl:this.state.samlMetadataUrl,samlEntityId:this.state.samlEntityId,mfaRequired:this.state.mfaRequired,passwordExpire:this.state.passwordExpire}).then((e=>{if(e.success){this.props.setSaving(!1);const{organization:t}=this.props.settings;t.identityProvider=e.identityProvider,t.samlMetadataUrl=e.samlMetadataUrl,t.samlEntityId=e.samlEntityId,t.mfaRequired=e.mfaRequired,t.passwordExpire=e.passwordExpire,this.props.updateSettings({organization:t}),this.props.updateUserOrganization(e),this.props.successAlert(e.message)}else this.props.errorAlert(e.message)})).catch((e=>{this.props.errorAlert(e.json.error.message)}))}))))})),J(this,"onDeleteCredentials",(()=>{(0,b.A)({title:"Confirm Deletion of Credentials",messageElement:d.createElement("div",null,"Are you sure you want to delete credentials for your team? This action will affect all users in your organization.")}).then((()=>{this.props.setSaving(!0);const e=(0,m.A)({config:this.props.config,name:"settingsClearCredentialsJson"});(0,c.yH)(e).then((e=>{this.props.updateSettings(e),this.props.setSaving(!1),this.props.successAlert("Credentials deleted successfully.")})).catch((e=>{this.props.errorAlert(e.json.error.message)}))}))})),J(this,"onSendInvites",(()=>{(0,b.A)({title:"Confirm Send Invites",messageElement:d.createElement("div",null,"Are you sure you want to send email invites to team members who haven't set a password yet?")}).then((()=>{this.props.setSaving(!0);const e=(0,m.A)({config:this.props.config,name:"organizationSettingsJson",params:["invite"]});(0,c.bE)(e,{action:"invite_missing_users"}).then((e=>{this.props.updateSettings(e),this.props.setSaving(!1),this.props.successAlert("Invites sent successfully.")})).catch((e=>{this.props.errorAlert(e.json.error.message)}))}))}
2)),this.state={identityProvider:this.props.settings.organization.identityProvider,edited:!1,samlIsValid:!1,samlIsValidating:!1,samlMetadataUrl:this.props.settings.organization.samlMetadataUrl||"",samlEntityId:this.props.settings.organization.samlEntityId||"",mfaRequired:this.props.settings.organization.mfaRequired,passwordExpire:this.props.settings.organization.passwordExpire||0}}render(){let e,t,a,s,n,i;if("chargehound"===this.state.identityProvider){let s;const n=(0,m.A)({config:this.props.config,name:"profileTab"}),i=(0,m.A)({config:this.props.config,name:"profileTab",params:["two-factor-auth"]});s=this.props.settings.user.mfaEnabled?d.createElement("div",{className:"mfa-notice"},"Require your users to use an authenticator app such as"," ",d.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:"https://guide.duo.com/third-party-accounts"},"Duo"),","," ",d.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:"https://support.google.com/accounts/answer/1066447?hl=en"},"Google Authenticator"),", or"," ",d.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:"https://support.authy.com/hc/en-us/articles/115001945848"},"Authy")," ","for extra security."):d.createElement("div",{className:"mfa-notice"},"Before requiring 2FA for your team, enable 2FA for your own user profile. You can do so ",d.createElement(E.N_,{to:i},"here"),"."),e=d.createElement("div",{className:"inner-content"},d.createElement("input",{type:"checkbox",name:"mfaEnabled",checked:this.state.mfaRequired,disabled:!this.props.settings.user.mfaEnabled,onChange:this.toggleMfa}),d.createElement("label",{id:"mfa",htmlFor:"mfa"},"Require multi-factor authentication"),s),t=d.createElement(G,Y({updatePasswordExpire:this.updatePasswordExpire,passwordExpire:this.state.passwordExpire},this.props)),"chargehound"===this.props.settings.organization.identityProvider&&(this.props.settings.team.some((e=>!e.hasLogin&&e.hash===this.props.user.id))?a=d.createElement("div",{className:"app-item clearfix warning"},"You haven't chosen a password yet!  ",d.createElement(E.N_,{to:n},"Set your password now"),"."):this.props.settings.team.some((e=>!e.hasLogin&&!e.hasInvite))&&(a=d.createElement("div",{className:"app-item clearfix warning"},"Some of your users don't have credentials set up yet. You can invite them to choose a password so they can log into Chargehound.",d.createElement("button",{className:"btn btn-primary",onClick:this.onSendInvites},"Send Invites"))))}if("google"===this.state.identityProvider){const e=this.props.config.webHost+(0,m.A)({config:this.props.config,name:"googleOauthLogin"});s=d.createElement("div",{className:"inner-content"},d.createElement("div",{className:"row-heading"},"Google Login Page"),d.createElement(H,{id:"google-sso-url",link:e}),d.createElement("div",{className:"auth-notice"},"Please instruct your team to use this link when signing in."))}if("saml"===this.state.identityProvider){let e;e=this.state.samlIsValidating?d.createElement("span",{disabled:!0,className:"btn btn-secondary input-group-addon"},d.createElement("i",{className:"fa fa-spinner fa-pulse"}),"Validating"):this.state.samlIsValid?d.createElement("span",{onClick:this.validateSamlMetadataUrl,className:"btn btn-default input-group-addon"},d.createElement("i",{className:"fa fa-check"}),"Valid"):d.createElement("span",{onClick:this.validateSamlMetadataUrl,disabled:!this.state.samlMetadataUrl,className:"btn btn-secondary input-group-addon"},"Validate");const t=this.props.config.webHost+(0,m.A)({config:this.props.config,name:"samlAcs"});n=d.createElement("div",{className:"inner-content saml-options"},d.createElement("div",{className:"row-heading"},"Metadata URL"),d.createElement("div",null,d.createElement("span",{className:"input-group"},d.createElement("input",{className:"form-control",onChange:this.updateSamlMetadataUrl,type:"text",autoCapitalize:"false",autoCorrect:"false",autoComplete:"one-time-code",name:"samlMetadataUrl",placeholder:"Metadata URL",value:this.state.samlMetadataUrl}),e),d.createElement("div",{className:"auth-notice"},'Enter your the SAML metadata URL of your identity provider to complete the integration. It may be described as the "Issuer URL" in y
2our identity provider.')),d.createElement("div",null,d.createElement("div",{className:"row-heading"},"Entity ID"),d.createElement("input",{className:"form-control",onChange:this.updateSamlEntityId,type:"text",autoCapitalize:"false",autoCorrect:"false",autoComplete:"one-time-code",name:"samlEntityId",placeholder:"Entity ID",value:this.state.samlEntityId}),d.createElement("div",{className:"auth-notice"},'This may be referred to as the "Identity Provider Issuer" in your identity provider.')),d.createElement("div",null,d.createElement("div",{className:"row-heading"},"Assertion Control Service URL"),d.createElement(H,{id:"saml-acs-url",link:t}),d.createElement("div",{className:"auth-notice"},"Please configure your identity provider to send SAML assertions to this endpoint."))),this.props.settings.team.some((e=>e.hasLogin))&&"saml"===this.props.settings.organization.identityProvider&&(i=d.createElement("div",{className:"app-item clearfix warning"},"Some of your users are still able to login with a password they previously set with Chargehound. You can delete these credentials to enforce use of single sign-on.",d.createElement("button",{className:"btn btn-danger",onClick:this.onDeleteCredentials},"Delete Credentials")))}return d.createElement("div",{className:"app-block no-padding tight auth-provider"},d.createElement("div",{className:"header"},d.createElement("h4",null,"Authentication")),a,i,d.createElement("div",{className:"content"},"Choose how your users log into Chargehound."),d.createElement("div",{className:"content"},d.createElement("input",{type:"radio",name:"chargehound",checked:"chargehound"===this.state.identityProvider,onChange:this.updateIdentityProvider}),d.createElement("label",{htmlFor:"chargehound"},"Email and Password"),d.createElement("div",{className:"auth-provider-description"},"Users login with their email and password. Passwords must be"," ","8 or more characters and contain at least one uppercase letter,"," ","one lowercase letter, and one digit."),e,t,d.createElement("input",{type:"radio",name:"google",checked:"google"===this.state.identityProvider,onChange:this.updateIdentityProvider}),d.createElement("label",{htmlFor:"chargehound"},"Login with Google"),d.createElement("div",{className:"auth-provider-description"},"Users must log in with their Google account."),s,d.createElement("input",{type:"radio",name:"saml",checked:"saml"===this.state.identityProvider,onChange:this.updateIdentityProvider}),d.createElement("label",{htmlFor:"chargehound"},"SAML Single Sign-On"),d.createElement("div",{className:"auth-provider-description"},"Authentication is provided by an Identity Provider of your choosing, such as OneLogin or Okta."),n),d.createElement("hr",null),d.createElement("div",{className:"btn-section clearfix"},d.createElement("button",{disabled:!this.state.edited,onClick:this.onSave,className:"btn btn-primary pull-right"},"Save changes")))}}class Q extends d.Component{constructor(e){super(e),J(this,"clearState",(()=>{this.setState({saving:!1,domain:""})})),J(this,"saveChanges",(()=>{const e=(0,m.A)({config:this.props.config,name:"settingsEmailDomainAllowlistJson"});this.setState({saving:!0}),y()(this.props.index)?(0,c.yJ)(e,{update:this.state.domain,domain:this.props.domain}).then((e=>{this.props.updateSettings({emailDomainAllowlist:e.emailDomainAllowlist}),this.cancelEditing(),this.props.successAlert("Your email domain restrictions were updated.")})).catch((e=>{this.setState({saving:!1}),this.props.errorAlert(e.json.error.message)})):(0,c.bE)(e,{domain:this.state.domain}).then((e=>{this.props.updateSettings({emailDomainAllowlist:e.emailDomainAllowlist}),this.cancelEditing(),this.props.successAlert("Your email domain restrictions were updated.")})).catch((e=>{this.setState({saving:!1}),this.props.errorAlert(e.json.error.message)}))})),J(this,"updateDomain",(e=>{this.setState({domain:e.currentTarget.value})})),J(this,"cancelEditing",(()=>{this.clearState(),this.props.cancelEditing()})),this.state={saving:!1,domain:e.domain||""}}render(){let e;return this.props.emailDomainAllowlist&&this.props.emailDomainAllowlist.length||(e=d.createElement("div",{className:"alert alert-warning"},"Once you've added a allowed email domain for team member accounts,"," ","all invites and email changes will need to comply with the domain restrictions moving forward.")),d.createElement(T(),{isOpen:this.props.isOpen,onRequestClose:this.cancelEditing,contentLabel:"IP Modal",className:"dialog-modal-content",overlayClassName:"dialog-modal-overlay"},d.createElement("div",{className:"ip-modal"},d.createElement("button",{onClick:this.cancelEditing,type:"button",className:"close","data-dismiss":"modal","aria-label":"Close"},d.createElement("span",{"aria-hidden":"true"},"×")),d.createElement("h4",null,y()(this.props.index)?"Update":"Add a"," Domain"),d.createElement("div",null,d.createElement("div",{className:"row-heading emphasis"},"Email domain"),d.createElement("input",{className:"form-control",onChange:this.updateDomain,type:"text",autoCapitalize:"false",autoCorrect:"false",name:"domain",value:this.state.domain,placeholder:"example.com"}),d.createElement("div",{className:"explain"},"Domain to allow for team member email addresses. An email domain is the part of the email address after the ",d.createElement("code",null,"@")," sign, e.g. ",d.createElement("code",null,this.props.currentUserEmailDomain),".")),e,d.createElement("div",{className:"btns clearfix"},d.createElement("span",{className:"pull-right"},d.createElement("button",{onClick:this.cancelEditing,disabled:this.state.saving,className:"btn btn-default"},"Cancel"),d.createElement("button",{onClick:this.saveChanges,disabled:this.state.saving,className:"btn btn-margin-left btn-primary"}
2,"Save")))))}}class Z extends d.Component{constructor(e){super(e),J(this,"addNewDomain",(()=>{(0,P.A)({config:this.props.config,identityProvider:this.props.settings.organization.identityProvider,lastLogin:this.props.lastLogin,reauthenticationInterval:this.props.settings.reauthenticationInterval,updateLastLoginTime:this.props.updateLastLoginTime}).then((()=>{this.setState({modalOpen:!0,editingDomain:null,editingDomainIndex:null})}))})),J(this,"cancelEditing",(()=>{this.setState({modalOpen:!1,editingDomain:null,editingDomainIndex:null})})),this.state={modalOpen:!1,editingDomain:null,editingDomainIndex:null}}editDomain(e,t){(0,P.A)({config:this.props.config,identityProvider:this.props.settings.organization.identityProvider,lastLogin:this.props.lastLogin,reauthenticationInterval:this.props.settings.reauthenticationInterval,updateLastLoginTime:this.props.updateLastLoginTime}).then((()=>{this.setState({modalOpen:!0,editingDomain:e,editingDomainIndex:t})}))}deleteDomain(e){(0,P.A)({config:this.props.config,identityProvider:this.props.settings.organization.identityProvider,lastLogin:this.props.lastLogin,reauthenticationInterval:this.props.settings.reauthenticationInterval,updateLastLoginTime:this.props.updateLastLoginTime,respectGracePeriod:!1}).then((()=>{(0,b.A)({title:"Remove Domain",message:d.createElement("span",null,"Are you sure you want to remove ",d.createElement("strong",null,e)," from the allowed domains?")}).then((()=>{this.props.setSaving(!0);const t=(0,m.A)({config:this.props.config,name:"settingsEmailDomainAllowlistJson"});return(0,c.yH)(t,{domain:e})})).then((t=>{this.props.updateSettings({emailDomainAllowlist:t.emailDomainAllowlist}),this.props.setSaving(!1),this.props.successAlert(`${e} was successfully removed from the allowed domains.`)})).catch((e=>{e&&(this.props.setSaving(!1),this.props.errorAlert(e.json.error.message))}))}))}render(){const{emailDomainAllowlist:e}=this.props.settings,t=Boolean("owner"===this.props.user.state||this.props.user.siteAdmin),a=this.props.settings.user.emailDomain;let s=[];return e&&(s=e.map(((e,a)=>{let s;return t&&(s=d.createElement("span",{className:"actions"},d.createElement("a",{onClick:this.editDomain.bind(this,e,a),className:"edit"},"edit"),d.createElement("a",{onClick:this.deleteDomain.bind(this,e),className:"edit"},"remove"))),d.createElement("li",{className:"clearfix domain",key:a},d.createElement("span",null,d.createElement("span",{className:"pull-left"},d.createElement("span",{className:""},d.createElement("code",null,e)," ",s))))}))),s.length||t?s.length?t?d.createElement("div",{id:"domain-allowlist",ref:C.A,className:"app-block no-padding tight domain-allowlist-block"},d.createElement("div",{className:"header"},d.createElement("h4",null,"Email Domain Restrictions")),d.createElement("div",{className:"content"},"Your team member email addresses are restricted by domain. Invites and email changes must match the domains in the list below. You can add up to 10 allowed domains."),d.createElement("hr",null),d.createElement("div",{className:"restrictions-container"},d.createElement("ul",{className:"list-unstyled"},s)),d.createElement("hr",null),d.createElement("div",{className:"item-add text-right"},d.createElement("span",{className:"explainer"},"Add a domain"),d.createElement("button",{onClick:this.addNewDomain,className:"btn btn-primary"},d.createElement("span",{className:"fa fa-plus"}))),d.createElement(Q,{key:`${this.state.editingDomain}-${this.state.editingDomainIndex}`,isOpen:this.state.modalOpen,cancelEditing:this.cancelEditing,domain:this.state.editingDomain,index:this.state.editingDomainIndex,config:this.props.config,emailDomainAllowlist:e,currentUserEmailDomain:a,updateSettings:this.props.updateSettings,successAlert:this.props.successAlert,errorAlert:this.props.errorAlert})):d.createElement("div",{id:"domain-allowlist",ref:C.A,className:"app-block no-padding tight domain-allowlist-block"},d.createElement("div",{className:"header"},d.createElement("h4",null,"Email Domain Restrictions")),d.createElement("div",{className:"content"},"Your team member email addresses are restricted by domain. Email changes must match the domains in the list below."),d.createElement("hr",null),d.createElement("div",{className:"restrictions-container"},d.createElement("ul",{className:"list-unstyled"},s))):d.createElement("div",{id:"domain-allowlist",ref:C.A,className:"app-block no-padding tight domain-allowlist-block"},d.createElement("div",{className:"header"},d.createElement("h4",null,"Email Domain Restrictions")),d.createElement("div",{className:"content"},"You can restrict team member email addresses by domain."," ","For example, you can ensure that all team member invites and email changes have ",d.createElement("code",null,"@",a)," in the email address."),d.createElement("hr",null),d.createElement("div",{className:"item-add text-right"},d.createElement("span",{className:"explainer"},"Add a domain"),d.createElement("button",{onClick:this.addNewDomain,className:"btn btn-primary"},d.createElement("span",{className:"fa fa-plus"}))),d.createElement(Q,{key:`${this.state.editingDomain}-${this.state.editingDomainIndex}`,isOpen:this.state.modalOpen,cancelEditing:this.cancelEditing,domain:this.state.editingDomain,index:this.state.editingDomainIndex,config:this.props.config,emailDomainAllowlist:e,currentUserEmailDomain:a,updateSettings:this.props.updateSettings,successAlert:this.props.successAlert,errorAlert:this.props.errorAlert})):null}}class ee extends d.Component{constructor(e){super(e),J(this,"clearState",(()=>{let e="";this.props.ipAllowlist&&this.props.ipAllowlist.length||(e=this.props.currentIp),this.setState({saving:!1,ip:e})})),J(this,"saveChanges",(()=>{const e=(0,m.A)({config:this.props.config,name:"settingsDashboardIpAllowlistJson"});this.setState({saving:!0}),y()(this.props.index)?(0,c.yJ)(e,{update:this.state.ip,ip:this.props.ip}).then((e=>{this.props.updateSettings({ipAllowlist:e.ipAllowlist}),this.cancelEditing(),this.props.successAlert("Your IP restrictions were updated.")})).catch((e=>{this.setState({saving:!1}),this.props.errorAlert(e.json.error.message)})):(0,c.bE)(e,{ip:this.state.ip}).then((e=>{this.props.updateSettings({ipAllowlist:e.ipAllowlist}),this.cancelEditing(),this.props.successAlert("Your IP restrictions were updated.")})).catch((e=>{this.setState({saving:!1}),this.props.errorAlert(e.json.error.message)}))})),J(this,"updateIp",(e=>{this.setState({ip:e.currentTarget.value})})),J(this,"cancelEditing",(()=>{this.clearState(),this.props.cancelEditing()}));let t=e.ip||"";t||e.ipAllowlist&&e.ipAllowlist.length||(t=e.currentIp),this.state={saving:!1,ip:t}}render(){let e;return this.props.ipAllowlist&&this.props.ipAllowlist.length?y()(this.props.index)&&(e=d.createElement("div",{className:"alert alert-warning"},"You will need to keep your current IP address,"," ",this.props.currentIp,", in the allowed IPs.")):e=d.createElement("div",{className:"alert alert-warning"},"Once you've added a allowed IP address for dashboard access,"," ","all dashboard access that is not from the allowed IPs will be rejected.",d.createElement("br",null),d.createElement("br",null),"You will need to include your current IP address,"," ",this.props.currentIp,", in the initial IP address or CIDR range."),d.createElement(T(),{isOpen:this.props.isOpen,onRequestClose:this.cancelEditing,contentLabel:"IP Modal",className:"dialog-modal-content",overlayClassName:"dialog-modal-overlay"},d.createElement("div",{className:"ip-modal"},d.createElement("button",{onClick:this.cancelEditing,type:"button",className:"close","data-dismiss":"modal","aria-label":"Close"},d.createElement("span",{"aria-hidden":"true"},"×")),d.createElement("h4",null,y()(this.props.index)?"Update":"Add an"," IP"),d.createElement("div",null,d.createElement("div",{className:"row-heading emphasis"},"IP address"),d.createElement("input",{className:"form-control",onChange:this.updateIp,type:"text",name:"ip",value:this.state.ip,placeholder:"127.0.0.1"}),d.createElement("div",{className:"explain"},"IP address to allow for dashboard access. CIDR notation is supported. Examples: 127.0.0.1, 192.168.0.0/24")),e,d.createElement("div",{className:"btns clearfix"},d.createElement("span",{className:"pull-right"},d.createElement("button",{onClick:this.cancelEditing,disabled:this.state.saving,className:"btn btn-default"},"Cancel"),d.createElement("button",{onClick:this.saveChanges,disabled:this.state.saving,className:"btn btn-margin-left btn-primary"}
2,"Save")))))}}class te extends d.Component{constructor(e){super(e),J(this,"addNewIp",(()=>{(0,P.A)({config:this.props.config,identityProvider:this.props.settings.organization.identityProvider,lastLogin:this.props.lastLogin,reauthenticationInterval:this.props.settings.reauthenticationInterval,updateLastLoginTime:this.props.updateLastLoginTime}).then((()=>{this.setState({ipModalOpen:!0,editingIp:null,editingIpIndex:null})}))})),J(this,"cancelEditing",(()=>{this.setState({ipModalOpen:!1,editingIp:null,editingIpIndex:null})})),this.state={ipModalOpen:!1,editingIp:null,editingIpIndex:null}}editIp(e,t){(0,P.A)({config:this.props.config,identityProvider:this.props.settings.organization.identityProvider,lastLogin:this.props.lastLogin,reauthenticationInterval:this.props.settings.reauthenticationInterval,updateLastLoginTime:this.props.updateLastLoginTime}).then((()=>{this.setState({ipModalOpen:!0,editingIp:e,editingIpIndex:t})}))}deleteIp(e){(0,P.A)({config:this.props.config,identityProvider:this.props.settings.organization.identityProvider,lastLogin:this.props.lastLogin,reauthenticationInterval:this.props.settings.reauthenticationInterval,updateLastLoginTime:this.props.updateLastLoginTime,respectGracePeriod:!1}).then((()=>{(0,b.A)({title:"Remove IP",message:d.createElement("span",null,"Are you sure you want to remove ",d.createElement("strong",null,e)," from the allowed IPs?")}).then((()=>{this.props.setSaving(!0);const t=(0,m.A)({config:this.props.config,name:"settingsDashboardIpAllowlistJson"});return(0,c.yH)(t,{ip:e})})).then((t=>{this.props.updateSettings({ipAllowlist:t.ipAllowlist}),this.props.setSaving(!1),this.props.successAlert(`${e} was successfully removed from the allowed IPs.`)})).catch((e=>{e&&(this.props.setSaving(!1),this.props.errorAlert(e.json.error.message))}))}))}render(){const{ipAllowlist:e}=this.props.settings,t=Boolean("owner"===this.props.user.state||this.props.user.siteAdmin);let a=[];return e&&(a=e.map(((e,a)=>{let s;return t&&(s=d.createElement("span",{className:"actions"},d.createElement("a",{onClick:this.editIp.bind(this,e,a),className:"edit"},"edit"),d.createElement("a",{onClick:this.deleteIp.bind(this,e),className:"edit"},"remove"))),d.createElement("li",{className:"clearfix ip",key:a},d.createElement("span",null,d.createElement("span",{className:"pull-left"},d.createElement("span",{className:""},d.createElement("code",null,e)," ",s))))}))),a.length||t?a.length?t?d.createElement("div",{id:"ip-allowlist",ref:C.A,className:"app-block no-padding tight ip-allowlist-block"},d.createElement("div",{className:"header"},d.createElement("h4",null,"IP Restrictions")),d.createElement("div",{className:"content"},"Your dashboard access is restricted by IP address. The IPs that can access the dashboard are listed below. You can add up to 10 allowed IP addresses."),d.createElement("hr",null),d.createElement("div",{className:"restrictions-container"},d.createElement("ul",{className:"list-unstyled"},a)),d.createElement("hr",null),d.createElement("div",{className:"item-add text-right"},d.createElement("span",{className:"explainer"},"Add an IP"),d.createElement("button",{onClick:this.addNewIp,className:"btn btn-primary"},d.createElement("span",{className:"fa fa-plus"}))),d.createElement(ee,{key:`${this.state.editingIp}-${this.state.editingIpIndex}`,isOpen:this.state.ipModalOpen,cancelEditing:this.cancelEditing,ip:this.state.editingIp,index:this.state.editingIpIndex,config:this.props.config,ipAllowlist:e,currentIp:this.props.settings.currentIp,updateSettings:this.props.updateSettings,successAlert:this.props.successAlert,errorAlert:this.props.errorAlert})):d.createElement("div",{id:"ip-allowlist",ref:C.A,className:"app-block no-padding tight ip-allowlist-block"},d.createElement("div",{className:"header"},d.createElement("h4",null,"IP Restrictions")),d.createElement("div",{className:"content"},"Your dashboard access is restricted by IP address. The IPs that can access the dashboard are listed below."),d.createElement("hr",null),d.createElement("div",{className:"restrictions-container"},d.createElement("ul",{className:"list-unstyled"},a))):d.createElement("div",{id:"ip-allowlist",ref:C.A,className:"app-block no-padding tight ip-allowlist-block"},d.createElement("div",{className:"header"},d.createElement("h4",null,"IP Restrictions")),d.createElement("div",{className:"content"},"You can restrict dashboard access by IP address."),d.createElement("hr",null),d.createElement("div",{className:"item-add text-right"},d.createElement("span",{className:"explainer"},"Add an IP"),d.createElement("button",{onClick:this.addNewIp,className:"btn btn-primary"},d.createElement("span",{className:"fa fa-plus"}))),d.createElement(ee,{key:`${this.state.editingIp}-${this.state.editingIpIndex}`,isOpen:this.state.ipModalOpen,cancelEditing:this.cancelEditing,ip:this.state.editingIp,index:this.state.editingIpIndex,config:this.props.config,ipAllowlist:e,currentIp:this.props.settings.currentIp,updateSettings:this.props.updateSettings,successAlert:this.props.successAlert,errorAlert:this.props.errorAlert})):null}}class ae extends d.Component{constructor(e){super(e),J(this,"closeModal",(()=>{this.setState({editedOrgName:"",editedDelete:""}),this.props.closeModal()})),J(this,"onConfirm",(()=>{const e=this.state.editedOrgName,t=this.state.editedDelete;this.closeModal(),this.props.onOrgDelete({organizationName:e,typedDelete:t})})),J(this,"updateOrgName",(e=>{this.setState({editedOrgName:e.currentTarget.value})})),J(this,"updateDelete",(e=>{this.setState({editedDelete:e.currentTarget.value})})),this.state={editedOrgName:"",editedDelete:""}}render(){const e=Boolean(this.state.editedOrgName.toUpperCase()===this.props.organization.name.toUpperCase()&&"DELETE"===this.state.editedDelete.toUpperCase());return d.createElement(T(),{isOpen:this.props.modalIsOpen,onRequestClose:this.closeModal,contentLabel:"Modal",className:"dialog-modal-content",overlayClassName:"dialog-modal-overlay"},d.createElement("div",{className:"delete-org-modal"},d.createElement("button",{className:"close",onClick:this.closeModal},"×"),d.createElement("h4",{className:"modal-title"},"Delete organization"),d.createElement("div",{className:"section-upper"},"Your organization will immediately by suspended and you will no longer be able to submit disputes. Chargehound will fulfill your deletion request, after which all of your disputes will be deleted permanently. You will be notified when your request has been fulfilled."),d.createElement("div",{className:"alert alert-danger"},"Organization delete is irreversable."),d.createElement("hr",null),d.createElement("div",{className:"section-upper"},d.createElement("div",{className:"form-group"},d.createElement("label",null,"Type your organization's name:"),d.createElement("input",{className:"form-control",onChange:this.updateOrgName,value:this.state.editedOrgName,type:"text",autoComplete:"off",maxLength:"100"})),d.createElement("div",{className:"form-group"},d.createElement("label",null,"Type ",d.createElement("i",null,"delete"),":"),d.createElement("input",{className:"form-control",onChange:this.updateDelete,value:this.state.editedDelete,type:"text",autoComplete:"off",maxLength:"25"}))),d.createElement("div",{className:"pull-right"},d.createElement("button",{onClick:this.closeModal,className:"btn btn-default"},"Cancel"),d.createElement("button",{disabled:!e,onClick:this.onConfirm,className:"btn btn-margin-left btn-danger"}
2,"Delete"))))}}class se extends d.Component{constructor(e){super(e),J(this,"openConfirmModal",(()=>{(0,P.A)({config:this.props.config,identityProvider:this.props.settings.organization.identityProvider,lastLogin:this.props.lastLogin,reauthenticationInterval:this.props.settings.reauthenticationInterval,updateLastLoginTime:this.props.updateLastLoginTime,respectGracePeriod:!1}).then((()=>{this.setState({confirmModalOpen:!0})}))})),J(this,"closeConfirmModal",(()=>{this.setState({confirmModalOpen:!1})})),J(this,"onOrgDelete",(e=>{this.props.setSaving(!0);const t=(0,m.A)({config:this.props.config,name:"settingsOrganizationDeleteJson"});(0,c.bE)(t,e).then((()=>{this.props.setSaving(!1),this.props.successAlert("Organization delete request successfully submitted.")})).catch((e=>{e&&(this.props.setSaving(!1),this.props.errorAlert(e.json.error.message))}))})),this.state={confirmModalOpen:!1}}render(){return d.createElement("div",{id:"organization-delete",ref:C.A,className:"app-block no-padding tight"},d.createElement("div",{className:"header"},d.createElement("h4",null,"Delete Organization")),d.createElement("div",{className:"content"},d.createElement("div",null,d.createElement("strong",null,"Submit a request to delete your organization"))),d.createElement("hr",null),d.createElement("div",{className:"btn-section clearfix"},d.createElement("button",{className:"btn btn-danger pull-right",onClick:this.openConfirmModal},"Delete organization")),d.createElement(ae,{modalIsOpen:this.state.confirmModalOpen,closeModal:this.closeConfirmModal,onOrgDelete:this.onOrgDelete,organization:this.props.user.organization}))}}function ne(e){return d.createElement("div",null,d.createElement(W,Y({key:e.user.organization.name},e)),d.createElement(X,e),d.createElement(Z,e),d.createElement(te,e),d.createElement(se,e))}var ie,re=a(39335),le=a(8714),oe=a(8435),ce=a(74716),de="https://js.stripe.com/v3",me=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,pe="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used",ue=function(e){var t=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",a=document.createElement("script");a.src="".concat(de).concat(t);var s=document.head||document.body;if(!s)throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");return s.appendChild(a),a},he=null,ge=null,ve=null,Ee=function(e){return null!==he?he:(he=new Promise((function(t,a){if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(pe),window.Stripe)t(window.Stripe);else try{var s=function(){for(var e=document.querySelectorAll('script[src^="'.concat(de,'"]')),t=0;t<e.length;t++){var a=e[t];if(me.test(a.src))return a}return null}();if(s&&e)console.warn(pe);else if(s){if(s&&null!==ve&&null!==ge){var n;s.removeEventListener("load",ve),s.removeEventListener("error",ge),null===(n=s.parentNode)||void 0===n||n.removeChild(s),s=ue(e)}}else s=ue(e);ve=function(e,t){return function(){window.Stripe?e(window.Stripe):t(new Error("Stripe.js not available"))}}(t,a),ge=function(e){return function(){e(new Error("Failed to load Stripe.js"))}}(a),s.addEventListener("load",ve),s.addEventListener("error",ge)}catch(e){return void a(e)}else t(null)}))).catch((function(e){return he=null,Promise.reject(e)}))},fe=!1,ye=function(){return ie||(ie=Ee(null).catch((function(e){return ie=null,Promise.reject(e)})))};Promise.resolve().then((function(){return ye()})).catch((function(e){fe||console.warn(e)}));function be(e,t,a){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var a=e[Symbol.toPrimitive];if(void 0!==a){var s=a.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class Ne extends d.Component{render(){return d.cloneElement(this.props.children,{StripeCheckout:this.props.StripeCheckout})}}const Ae=(0,re.A)("https://checkout.stripe.com/checkout.js",{globalName:"StripeCheckout"})(Ne);function we(e){return d.createElement("div",null,d.createElement(Ae,null,d.createElement(Se,e)),d.createElement(Ce,e))}function ke(e){const t=[];if(e.receivedFee&&t.push(d.createElement("span",{key:"received"},"$",e.receivedFee," for every dispute received that needs a response")),e.submittedFee&&t.push(d.createElement("span",{key:"submitted"},"$",e.submittedFee," for every response submitted")),e.feePercent&&t.push(d.createElement("span",{key:"win"},e.feePercent,"% of the total dollar value of chargebacks settled in your favor")),t.length){let e;if(t.length>1){const a=t.pop();e=t.reduce((function(e,a,s){return s!==t.length-1?e.concat(a,d.createElement("span",{key:s},", ")):e.concat(a)}),[]),e=e.concat(d.createElement("span",{key:"and"}," and "),a)}else e=t;return d.createElement("div",{className:"payment-note"},"At the end of each billing cycle you will be billed ",e,".")}return null}class Se extends d.Component{constructor(e){super(e),be(this,"onEmailSave",(()=>{const e=(0,m.A)({config:this.props.config,name:"organizationSettingsJson",params:["cus-email"]});this.props.setSaving(!0),(0,c.bE)(e,{email:this.state.editedCustomerEmail}).then((e=>{this.props.updateSettings(e),this.props.setSaving(!1),this.props.settings.chargeAutomatically?this.props.successAlert("Receipts email updated."):this.props.successAlert("Invoices email updated.")})).catch((e=>{this.props.setSaving(!1),this.props.errorAlert(e.json.error.message||"Something went wrong, and we could not add your receipts email. Please try again.")}))})),be(this,"onLinkClick",(()=>{const e=this.state.stripeInstance;if(!e)return void this.props.errorAlert("Unable to load payment provider. Please refresh the page and try again.");this.props.setSaving(!0);const t=(0,m.A)({config:this.props.config,name:"settingsBankSetupJson"});(0,c.bE)(t,{}).then((t=>{const a=t.clientSecret,s=this.props.settings.organization.name,n=this.state.editedCustomerEmail||this.props.settings.customerEmail;return e.collectBankAccountForSetup({clientSecret:a,params:{payment_method_type:"us_bank_account",payment_method_data:{billing_details:{name:s,email:n}}}})})).then((t=>{let{setupIntent:a,error:s}=t;if(s)return this.props.setSaving(!1),void this.props.errorAlert(s.message);if(a){if("requires_confirmation"===a.status)return e.confirmUsBankAccountSetup(a.client_secret);
2if("succeeded"===a.status)return{setupIntent:a,error:null};this.props.setSaving(!1),this.props.errorAlert("Unexpected setup status. Please try again.")}else this.props.setSaving(!1)})).then((e=>{if(!e)return;const{setupIntent:t,error:a}=e;if(a)return this.props.setSaving(!1),void this.props.errorAlert(a.message);if("succeeded"!==t.status)return this.props.setSaving(!1),void this.props.errorAlert("Bank account verification did not complete. Please try again.");const s=(0,m.A)({config:this.props.config,name:"settingsBankConfirmJson"}),n=t.id;return(0,c.bE)(s,{setup_intent_id:n})})).then((e=>{e&&(this.props.updateSettings(e),this.setState({editedCustomerEmail:e.customerEmail}),this.props.setSaving(!1),this.props.successAlert("Your bank account was successfully added."))})).catch((e=>{this.props.setSaving(!1),this.props.errorAlert(e.json&&e.json.error&&e.json.error.message||"Something went wrong. Please try again.")}))})),be(this,"onStripeClick",(()=>{this.state.stripeHandler&&this.state.stripeHandler.open({name:"Chargehound",description:"Fight disputes automatically",billingAddress:!0,panelLabel:"Add card"})})),be(this,"onStripeToken",(e=>{const t=(0,m.A)({config:this.props.config,name:"organizationSettingsJson",params:["payment"]});this.props.setSaving(!0),(0,c.bE)(t,{card_token:e.id,email:e.email}).then((e=>{this.props.updateSettings(e),this.setState({editedCustomerEmail:e.customerEmail}),this.props.setSaving(!1),this.props.successAlert("Your payment details were successfully added to your account.")})).catch((e=>{this.props.setSaving(!1),this.props.errorAlert(e.json.error.message||"Something went wrong, and we could not add your payment details. Please try again.")}))})),be(this,"updateEmail",(e=>{this.setState({editedCustomerEmail:e.currentTarget.value})})),this.state={editedCustomerEmail:e.settings.customerEmail||""}}componentDidMount(){this.props.settings.stripePublishableKey&&(this._stripePromise=function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];fe=!0;var s=Date.now();return ye().then((function(e){return function(e,t,a){if(null===e)return null;var s=e.apply(void 0,t);return function(e,t){e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",version:"2.4.0",startTime:t})}(s,a),s}(e,t,s)}))}(this.props.settings.stripePublishableKey),this._stripePromise.then((e=>{this._unmounted||this.setState({stripeInstance:e})})).catch((()=>{this._unmounted||this.setState({stripeLoadError:!0})}
2)))}componentDidUpdate(){if(!this.state.stripeHandler&&this.props.StripeCheckout){const e=this.props.StripeCheckout.configure({key:this.props.settings.stripePublishableKey,image:"",locale:"auto",token:this.onStripeToken});this.setState({stripeHandler:e})}}componentWillUnmount(){this._unmounted=!0}render(){let e,t,a,s;return this.props.settings.customerDelinquent&&(e=d.createElement("div",{className:"alert alert-danger section-upper"},"We were unable to charge your account. Please update your payment information.")),this.props.settings.chargeAutomatically?this.props.settings.paymentSource?(a=d.createElement("div",null,d.createElement("hr",{className:"margin-none"}),d.createElement("div",{className:"content"},d.createElement("div",{className:"section-upper"},"Send receipts to:"),d.createElement("input",{className:"form-control",onChange:this.updateEmail,type:"email",name:"email",value:this.state.editedCustomerEmail,placeholder:"[email protected]"}),d.createElement("button",{onClick:this.onEmailSave,className:"btn btn-secondary"},"Update"))),this.props.settings.paymentSource.bankName?t=d.createElement("div",null,d.createElement("div",{className:"payment-source section-upper"},d.createElement("p",null,d.createElement("strong",null,this.props.settings.paymentSource.bankName)," account ending in ",d.createElement("strong",null,this.props.settings.paymentSource.last4))),d.createElement("div",null,d.createElement("button",{onClick:this.onLinkClick,className:"margin-ri-5 add-plaid btn btn-secondary"},"Update your bank account"),d.createElement("button",{onClick:this.onStripeClick,className:"add-stripe btn btn-default"},"Use a credit card")),d.createElement(ke,{feePercent:this.props.settings.organization.feePercent,receivedFee:this.props.settings.organization.receivedFee,submittedFee:this.props.settings.organization.submittedFee})):this.props.settings.paymentSource.brand&&(t=d.createElement("div",null,d.createElement("div",{className:"payment-source section-upper"},d.createElement("p",null,d.createElement("strong",null,this.props.settings.paymentSource.brand)," ending in ",d.createElement("strong",null,this.props.settings.paymentSource.last4))),d.createElement("div",null,d.createElement("button",{onClick:this.onStripeClick,className:"margin-ri-5 add-stripe btn btn-secondary"},"Update your card"),d.createElement("button",{onClick:this.onLinkClick,className:"add-plaid btn btn-default"},"Pay with ACH")),d.createElement(ke,{feePercent:this.props.settings.organization.feePercent,receivedFee:this.props.settings.organization.receivedFee,submittedFee:this.props.settings.organization.submittedFee})))):t=d.createElement("div",null,d.createElement("div",{className:"section-upper"},"You haven't added your payment information yet. You'll need to do that before you can continue submitting disputes."),d.createElement("div",null,d.createElement("button",{onClick:this.onStripeClick,className:"margin-ri-5 add-stripe btn btn-primary"},"Add your card"),d.createElement("button",{onClick:this.onLinkClick,className:"add-plaid btn btn-default"},"Pay with ACH")),d.createElement(ke,{feePercent:this.props.settings.organization.feePercent,receivedFee:this.props.settings.organization.receivedFee,submittedFee:this.props.settings.organization.submittedFee})):(t=d.createElement("div",null,d.createElement("div",{className:"payment-source section-upper"},d.createElement("p",null,"Chargehound will email you an invoice at the end of each billing cycle."," ","In the email you will be provided with a link to a payment page where you can find the bank details required to make an ACH payment,"," ","or pay your invoice with a credit card."," ","The payment page is hosted by Stripe, a PCI-DSS Level 1 certified payment processor.")),d.createElement(ke,{feePercent:this.props.settings.organization.feePercent,receivedFee:this.props.settings.organization.receivedFee,submittedFee:this.props.settings.organization.submittedFee})),a=d.createElement("div",null,d.createElement("hr",{className:"margin-none"}),d.createElement("div",{className:"content"},d.createElement("div",{className:"section-upper"},"Send invoices to:"),d.createElement("div",{className:"form-group"},d.createElement("input",{className:"form-control",onChange:this.updateEmail,type:"email",name:"email",value:this.state.editedCustomerEmail,placeholder:"[email protected]"})),d.createElement("button",{onClick:this.onEmailSave,className:"btn btn-secondary"},"Update")))),this.props.settings.customerCredit<0&&(s=d.createElement("div",null,d.createElement("hr",{className:"margin-none"}),d.createElement("div",{className:"content"},d.createElement("div",null,"Credit balance:"," ",d.createElement("span",{className:"emphasis"},d.createElement(oe.oP,{total:-1*this.props.settings.customerCredit,currency:"usd"}))),d.createElement("div",{className:"payment-note credit"},"Credit will decrease the amount due on your next invoice.")))),d.createElement("div",{id:"payment-method",ref:C.A,className:"app-block no-padding tight"},d.createElement("div",{className:"header"},d.createElement("h4",null,"Payment Information")),d.createElement("div",{className:"content"},e,t),s,a)}}function Ce(e){if(!e.settings.invoices)return null;const{invoices:t}=e.settings;let a,s;if(t.upcoming&&(a=d.createElement("div",{id:"payment-upcoming-invoice",ref:C.A,className:"app-block no-padding tight"},d.createElement("div",{className:"header"},d.createElement("h4",null,"Upcoming Invoice")),d.createElement("div",{className:"upcoming-invoice"},d.createElement("ul",{className:"list-unstyled invoice-summary"},d.createElement("li",{className:"summary"},d.createElement("strong",{className:"desc"},"Date:"),d.createElement("span",{className:"emphasis amount"},t.upcoming.formattedDate)),d.createElement("li",{className:"summary"},d.createElement("strong",{className:"desc"},"Total:"),d.createElement("span",{className:"emphasis amount"},d.createElement(oe.oP,{total:t.upcoming.total,currency:t.upcoming.currency}))),d.createElement("li",{className:"summary"},d.createElement("strong",{className:"desc"},"Items:"),d.createElement("span",{className:"emphasis amount"},(0,le.LN)(t.upcoming.totalItems)))),d.createElement("div",{className:"view-details clearfix"},d.createElement("div",{className:"pull-right"},d.createElement(E.N_,{className:"btn btn-default",to:t.upcoming.url},"View details")))))),t.data.length){let a;if(t.hasMore){const t=(0,m.A)({config:e.config,name:"invoices"});a=d.createElement("div",{className:"view-all clearfix"},d.createElement("div",{className:"pull-right"},d.createElement(E.N_,{className:"btn btn-default",to:t},"View all")))}s=d.createElement("div",{id:"payment-invoices",ref:C.A,className:"app-block no-padding tight payment-invoices"},d.createElement("div",{className:"header"},d.createElement("h4",null,"Recent Invoices")),d.createElement("div",{className:"invoice-history"},d.createElement(ce.p,{invoices:t.data}),a))}return d.createElement("div",null,a,s)}var Ie=a(79859),Pe=a.n(Ie),xe=a(88055),De=a.n(xe),Te=a(37007),Le=a(22819),Oe=a(56347),Re=a(32732);function je(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,s)}return a}function Me(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};
2t%2?je(Object(a),!0).forEach((function(t){Ue(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):je(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}function Ue(e,t,a){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var a=e[Symbol.toPrimitive];if(void 0!==a){var s=a.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}const Ke=function(e){const[t,a]=d.useState([]),[s,n]=d.useState(!0),[i,r]=d.useState(!1),[l,o]=d.useState({acquirerBin:"",caid:"",processor:"",descriptor:"",isCustomProcessor:!1}),[p,u]=d.useState(!1),[h,v]=d.useState(null),[E,f]=d.useState(""),[y,b]=d.useState(null),[N,A]=d.useState(""),w=(e=>{const t=Object.entries(Le.k0).map((e=>{let[t,a]=e;return{value:t,label:a}}));return e&&t.push({value:Le.zf,label:"PayPal Branded"}),t.sort(((e,t)=>e.label.localeCompare(t.label))),t.push({value:"other",label:"Other"}),t})(e.config&&e.config.paypalSharedMid&&e.config.paypalSharedMid.enabled),k=l.processor===Le.zf;d.useEffect((()=>{S()}),[e.credential.hash]);const S=()=>{n(!0);const t=(0,m.A)({config:e.config,name:"settingsVisaCredentialsJson"});(0,c.Ay)(`${t}?account_credential_id=${e.credential.hash}`).then((t=>{"success"===t.status?a(t.data||[]):e.errorAlert("Failed to load Visa additional information.")})).catch((()=>{e.errorAlert("Error loading Visa additional information.")})).finally((()=>{n(!1)}))},C=(e,t)=>{o((a=>Me(Me({},a),{},{[e]:t})))},I=(t,a,s)=>{const n=N.trim();if(!n)return void e.errorAlert("Please enter a descriptor.");if(n===s)return b(null),void A("");const i=(0,m.A)({config:e.config,name:"settingsVisaDescriptorsJson"});let r=!1;(0,c.bE)(i,{credentialId:t,descriptor:n}).then((e=>{if(!e||"success"!==e.status)throw new Error("Descriptor update did not complete.");return r=!0,(0,c.yH)(`${i}?id=${a}`)})).then((t=>{if(!t||"success"!==t.status)throw new Error("Descriptor update did not complete.");S(),b(null),A(""),e.successAlert("Descriptor updated successfully.")})).catch((t=>{let a=r?`New descriptor registered, but couldn't remove the old one. Please remove '${s}' manually.`:"Error updating descriptor.";!r&&t.json&&t.json.reason?a=t.json.reason:r||409!==t.status||(a=`Descriptor '${n}' is already registered (matching is case-insensitive).`),b(null),A(""),e.errorAlert(a),S()}))};return d.createElement("div",{className:"account-details-section"},d.createElement("span",{className:g()({"status fa-stack fa-lg":!0,complete:!e.credential.revoked,incomplete:e.credential.revoked})},d.createElement("i",{className:"fa fa-circle fa-stack-2x"}),d.createElement("i",{className:g()({"fa fa-stack-1x fa-inverse":!0,"fa-check":!e.credential.revoked,"fa-times":e.credential.revoked})})),d.createElement("div",{className:"title"},"Visa Merchant ID: ",d.createElement("code",null,e.credential.account)),d.createElement("div",{className:"instructions"},"Contact support if you need to change your Merchant ID."),d.createElement("div",{className:"visa-additional-info"},d.createElement("div",{className:"section-header"},d.createElement("div",{className:"title"},"Add your credentials"),!i&&d.createElement("button",{className:"btn btn-primary btn-sm",onClick:()=>r(!0)},d.createElement("i",{className:"fa fa-plus"})," Add")),s?d.createElement("div",{className:"visa-info-list"},d.createElement("div",{className:"visa-info-row"},d.createElement("div",{className:"info-item"},d.createElement("i",{className:"fa fa-spinner fa-pulse"})," Loading Visa additional information..."))):t.length>0&&d.createElement("div",{className:"visa-info-list"},t.map((t=>t.shared?d.createElement("div",{key:t.id,className:"visa-info-row branded-row"},d.createElement("div",{className:"branded-field"},d.createElement("div",{className:"label"},"Type:"),d.createElement("div",{className:"value"},d.createElement("code",null,"PayPal Branded"))),d.createElement("div",{className:"branded-field"},d.createElement("div",{className:"label"},"Credentials:"),d.createElement("div",{className:"value"},"Managed by Chargehound")),d.createElement("div",{className:"branded-field"},d.createElement("div",{className:"label"},"Descriptors:"),d.createElement("div",{className:"value"},t.descriptors&&t.descriptors.map((a=>a.active&&y===a.id?d.createElement("span",{key:a.id,className:"descriptor-add-inline"},d.createElement("input",{type:"text",className:"form-control input-sm",value:N,maxLength:25,onChange:e=>A(e.target.value),onKeyDown:e=>{"Enter"===e.key&&I(t.id,a.id,a.descriptor)},autoFocus:!0}),d.createElement("button",{className:"btn btn-xs btn-primary",onClick:()=>I(t.id,a.id,a.descriptor)},"Save"),d.createElement("button",{className:"btn btn-xs btn-default",onClick:()=>{b(null),A("")}},"Cancel")):d.createElement("span",{key:a.id,className:g()("descriptor-tag",{"descriptor-tag-inactive":!a.active})},d.createElement("code",null,a.descriptor),!a.active&&d.createElement("span",{className:"descriptor-status"},"Inactive"),a.active?d.createElement(d.Fragment,null,d.createElement("button",{className:"btn btn-xs btn-link",onClick:()=>{b(a.id),A(a.descriptor)},title:"Edit descriptor"},d.createElement("i",{className:"fa fa-pencil"})),d.createElement("button",{className:"btn btn-xs btn-link",onClick:()=>(t=>{const a=(0,m.A)({config:e.config,name:"settingsVisaDescriptorsJson"});(0,c.yH)(`${a}?id=${t}`).then((t=>{"success"===t.status&&(S(),e.successAlert("Descriptor removed."))})).catch((t=>{let a="Error removing descriptor.";t.json&&t.json.reason&&(a=t.json.reason),e.errorAlert(a)}))})(a.id),title:"Delete descriptor"},d.createElement("i",{className:"fa fa-times"}))):d.createElement("button",{className:"btn btn-xs btn-link",onClick:()=>(t=>{const a=(0,m.A)({config:e.config,name:"settingsVisaDescriptorsJson"});(0,c.yJ)(a,{descriptorId:t}).then((t=>{"success"===t.status&&(S(),e.successAlert("Descriptor reactivated."))})).catch((t=>{let a="Error reactivating descriptor.";t.json&&t.json.reason&&(a=t.json.reason),e.errorAlert(a)}))})(a.id),title:"Reactivate descriptor"},d.createElement("i",{className:"fa fa-undo"})," Reactivate")))),h===t.id?d.createElement("span",{className:"descriptor-add-inline"},d.createElement("input",{type:"text",className:"form-control input-sm",placeholder:"e.g. PP*STORENAME",maxLength:25,value:E,onChange:e=>f(e.target.value)}),d.createElement("button",{className:"btn btn-xs btn-primary",onClick:()=>(t=>{if(!E.trim())return void e.errorAlert("Please enter a descriptor.");const a=(0,m.A)({config:e.config,name:"settingsVisaDescriptorsJson"});(0,c.bE)(a,{credentialId:t,descriptor:E.trim()}).then((t=>{"success"===t.status&&(S(),f(""),v(null),e.successAlert("Descriptor added successfully."))})).catch((t=>{let a="Error adding descriptor.";t.json&&t.json.reason?a=t.json.reason:t.json&&t.json.message?a=t.json.message:t.json&&t.json.error?a="string"==typeof t.json.error?t.json.error:t.json.error.message||a:409===t.status?a=`Descriptor '${E.trim()}' is already registered (matching is case-insensitive).`:t.statusText&&(a=t.statusText),e.errorAlert(a)}))})(t.id)},"Add"),d.createElement("button",{className:"btn btn-xs btn-default",onClick:()=>{v(null),f("")}},"Cancel")):d.createElement("button",{className:"btn btn-xs btn-link",onClick:()=>v(t.id)},d.createElement("i",{className:"fa fa-plus"})," Add descriptor")))):d.createElement("div",{key:t.id,className:"visa-info-row"},d.createElement("div",{className:"label"},"AcquirerBIN:"),d.createElement("div",{className:"value"},d.createElement("code",null,t.acquirerBin)),d.createElement("div",{className:"label"},"CAID:"),d.createElement("div",{className:"value"},d.createElement("code",null,t.caid)),d.createElement("div",{className:"label"},"Processor:"),d.createElement("div",{className:"value"},d.createElement("code",null,t.processor)))))),i&&d.createElement("div",{className:"add-info-form"},d.createElement("form",{className:"form-horizontal"},d.createElement("div",{className:"form-group"},d.createElement("label",{className:"col-sm-3 control-label"},"Processor"),d.createElement("div",{className:"col-sm-9"},d.createElement(Re.A,{condition:!l.isCustomProcessor,whenTrue:d.createElement(d.Fragment,null,d.createElement(q.Ay,{styles:V.A,placeholder:"Select a processor...",value:w.find((e=>e.value===l.processor)),onChange:e=>{"other"===e.value?o((e=>Me(Me({},e),{},{processor:"",isCustomProcessor:!0,descriptor:""}))):o((t=>Me(Me({},t),{},{processor:e.value,isCustomProcessor:!1,descriptor:""})))},options:w,isSearchable:!0,menuPortalTarget:document.body,menuPosition:"fixed"}),d.createElement("small",{className:"help-block"},"Select your processor from the list")),whenFalse:d.createElement(d.Fragment,null,d.createElement("input",{type:"text",className:"form-control",placeholder:"Enter processor name",value:l.processor,onChange:e=>C("processor",e.target.value)}),d.createElement("button",{type:"button",className:"btn btn-link btn-xs",onClick:()=>o((e=>Me(Me({},e),{},{processor:"",isCustomProcessor:!1})))}
2,"← Back to dropdown"))}))),l.processor&&!k&&d.createElement(d.Fragment,null,d.createElement("div",{className:"form-group"},d.createElement("label",{className:"col-sm-3 control-label"},"Acquirer BIN",d.createElement("span",{className:"required-star"},"*")),d.createElement("div",{className:"col-sm-9"},d.createElement("input",{type:"text",className:"form-control",placeholder:"Enter 6-digit Acquirer BIN",value:l.acquirerBin,onChange:e=>C("acquirerBin",e.target.value)}),d.createElement("small",null,"Must be exactly 6 digits"))),d.createElement("div",{className:"form-group"},d.createElement("label",{className:"col-sm-3 control-label"},"CAID",d.createElement("span",{className:"required-star"},"*")),d.createElement("div",{className:"col-sm-9"},d.createElement("input",{type:"text",className:"form-control",placeholder:"Enter Card Acceptor ID",value:l.caid,onChange:e=>C("caid",e.target.value)}),d.createElement("small",null,"1-15 alphanumeric characters")))),k&&d.createElement("div",{className:"form-group"},d.createElement("label",{className:"col-sm-3 control-label"},"Descriptor",d.createElement("span",{className:"required-star"},"*")),d.createElement("div",{className:"col-sm-9"},d.createElement("input",{type:"text",className:"form-control",placeholder:"e.g. PayPal*YourStoreName",maxLength:25,value:l.descriptor,onChange:e=>C("descriptor",e.target.value)}),d.createElement("small",null,"Enter the exact payment descriptor as registered with Verifi. This must match exactly for routing to work. Max 25 characters.")))),d.createElement("div",{className:"form-actions"},d.createElement("button",{className:"btn btn-default",onClick:()=>{o({acquirerBin:"",caid:"",processor:"",descriptor:"",isCustomProcessor:!1}),r(!1)},disabled:p},"Cancel"),d.createElement("button",{className:g()("btn btn-primary",{disabled:p}),onClick:()=>{if(k){if(!l.descriptor)return void e.errorAlert("Please enter a payment descriptor.")}else if(!l.acquirerBin||!l.caid||!l.processor)return void e.errorAlert("Please fill in all fields.");const t=k?Le.zf:(a=l.processor)?a.trim().toLowerCase().replace(/\s+/g,"_"):"";var a;if(!t.match(/^[a-z0-9_]+$/))return void e.errorAlert("Processor name must contain only lowercase letters, numbers, and underscores.");u(!0);const s=(0,m.A)({config:e.config,name:"settingsVisaCredentialsJson"}),n={accountCredentialId:e.credential.hash,processor:t};k?n.descriptor=l.descriptor.trim():(n.acquirerBin=l.acquirerBin,n.caid=l.caid),(0,c.bE)(s,n).then((t=>{"success"===t.status?(S(),o({acquirerBin:"",caid:"",processor:"",descriptor:"",isCustomProcessor:!1}),r(!1),e.successAlert("Visa additional information added successfully.")):e.errorAlert(t.message||"Failed to save Visa additional information.")})).catch((t=>{let a="Error saving Visa additional information.";t.json&&t.json.reason?a=t.json.reason:t.json&&t.json.message?a=t.json.message:t.json&&t.json.error&&("string"==typeof t.json.error?a=t.json.error:t.json.error.message&&(a=t.json.error.message)),e.errorAlert(a)})).finally((()=>{u(!1)}))},disabled:p},p?d.createElement("span",null,d.createElement("i",{className:"fa fa-spinner fa-pulse"})," Saving"):"Save")))))};var _e=a(18194),ze=a(3638);function Fe(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,s)}return a}function $e(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?Fe(Object(a),!0).forEach((function(t){Be(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):Fe(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}function Be(e,t,a){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var a=e[Symbol.toPrimitive];if(void 0!==a){var s=a.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}const Ve=function(e){const[t,a]=d.useState((0,_e.z$)()),[s,n]=d.use
2State([(0,_e.yl)()]),[i,r]=d.useState([(0,_e.Lz)()]),[l,o]=d.useState(!1),[p,u]=d.useState(null),[h,v]=d.useState(1),E=e.credential&&e.credential.hash,[f,y]=d.useState(null),[b,N]=d.useState(!e.inWizard&&!!E);d.useEffect((()=>{if(e.inWizard||!E)return;let t=!1;const a=(0,m.A)({config:e.config,name:"settingsEthocaEnrollment"});return(0,_e.vs)(a,E).then((e=>{t||y(e.enrollment||null)})).catch((()=>{t||(y(null),e.errorAlert("Failed to load Mastercard Consumer Clarity status."))})).finally((()=>{t||N(!1)})),()=>{t=!0}}),[e.inWizard,E]);const A=!(!f||!f.subMerchantGuid),w=!e.inWizard&&!!E&&!b&&A,k=!(e.inWizard||!E||b||A);d.useEffect((()=>{k&&a((0,_e.HB)(f,e.credential&&e.credential.merchantId))}),[k]);const S=(e,t)=>{a((a=>$e($e({},a),{},{[e]:t})))},C=(e,t,a)=>{n((s=>s.map((s=>s.id===e?$e($e({},s),{},{[t]:a}):s))))};return b?d.createElement("div",{className:"account-details-section help-block"},"Loading Mastercard Consumer Clarity status..."):w?d.createElement(ze.A,{config:e.config,credential:e.credential,errorAlert:e.errorAlert,successAlert:e.successAlert}):d.createElement("div",{className:"account-details-section"},d.createElement("div",{className:"title"},k?"Resume Mastercard Consumer Clarity onboarding":"Mastercard Consumer Clarity onboarding"),d.createElement("div",{className:"instructions"},k?`A previous onboarding attempt didn't complete${f&&f.onboardingStatus?` (status: ${f.onboardingStatus})`:""}. Review the details below, update anything that needs fixing, and resubmit.`:"Register your business with Mastercard Consumer Clarity. Enter the BIN / Card Acceptor ID pair(s) for the accounts you want enrolled."),d.createElement("div",{className:"wizard-step-indicator",style:{margin:"8px 0 16px",fontWeight:600}},"Step ",h," of ",_e.Td),p&&d.createElement("div",{className:"visa-info-list"},d.createElement("div",{className:"visa-info-row"},d.createElement("div",{className:"label"},"Status:"),d.createElement("div",{className:"value"},d.createElement("code",null,p.status)),d.createElement("div",{className:"label"},"Sub-merchant GUID:"),d.createElement("div",{className:"value"},d.createElement("code",null,p.subMerchantGuid)),d.createElement("div",{className:"label"},"Location ID:"),d.createElement("div",{className:"value"},d.createElement("code",null,p.locationId))),p.warnings&&p.warnings.length>0&&d.createElement("div",{className:"visa-info-row",style:{color:"#a94442"}},d.createElement("div",{className:"label"},"Warnings:"),d.createElement("div",{className:"value"},d.createElement("ul",{style:{margin:0,paddingLeft:"1.2em"}},p.warnings.map(((e,t)=>d.createElement("li",{key:t},e))))))),d.createElement("div",{className:"add-info-form"},d.createElement("form",{className:"form-horizontal"},1===h&&d.createElement(d.Fragment,null,d.createElement("div",{className:"form-group"},d.createElement("label",{className:"col-sm-3 control-label"},"Merchant ID",d.createElement("span",{className:"required-star"},"*")),d.createElement("div",{className:"col-sm-9"},d.createElement("input",{type:"text",className:"form-control",placeholder:"Enter merchant ID",value:t.merchantId,onChange:e=>S("merchantId",e.target.value),disabled:k}),k&&d.createElement("p",{className:"help-block"},"Merchant ID can't be changed while resuming an existing enrollment."))),d.createElement("div",{className:"form-group"},d.createElement("label",{className:"col-sm-3 control-label"},"Business name"),d.createElement("div",{className:"col-sm-9"},d.createElement("input",{type:"text",className:"form-control",placeholder:"Defaults to your organization name if left blank",value:t.businessName,onChange:e=>S("businessName",e.target.value)}))),d.createElement("div",{className:"form-group"},d.createElement("label",{className:"col-sm-3 control-label"},"Industry code",d.createElement("span",{className:"required-star"},"*")),d.createElement("div",{className:"col-sm-9"},d.createElement("input",{type:"text",className:"form-control",placeholder:"Enter industry code",maxLength:3,value:t.industryCode,onChange:e=>S("industryCode",e.target.value)}))),d.createElement("div",{className:"form-group"},d.createElement("label",{className:"col-sm-3 control-label"},"Business type",d.createElement("span",{className:"required-star"},"*")),d.createElement("div",{className:"col-sm-9"},d.createElement("select",{className:"form-control",value:t.businessType,onCh
2ange:e=>S("businessType",e.target.value)},d.createElement("option",{value:""},"Select a business type"),_e.xw.map((e=>d.createElement("option",{key:e,value:e},e)))))),d.createElement("div",{className:"form-group"},d.createElement("label",{className:"col-sm-3 control-label"},"Locale",d.createElement("span",{className:"required-star"},"*")),d.createElement("div",{className:"col-sm-9"},d.createElement("select",{className:"form-control",value:t.localeCode,onChange:e=>S("localeCode",e.target.value)},_e.Yy.map((e=>d.createElement("option",{key:e,value:e},e)))))),d.createElement("div",{className:"form-group"},d.createElement("label",{className:"col-sm-3 control-label"},"Merchant description",d.createElement("span",{className:"required-star"},"*")),d.createElement("div",{className:"col-sm-9"},d.createElement("textarea",{className:"form-control",placeholder:"Enter merchant description",value:t.merchantDescription,onChange:e=>S("merchantDescription",e.target.value)}))),d.createElement("div",{className:"form-group"},d.createElement("div",{className:"col-sm-offset-3 col-sm-9"},d.createElement("label",{className:"checkbox-inline"},d.createElement("input",{type:"checkbox",checked:t.defaultLocale,onChange:e=>S("defaultLocale",e.target.checked)})," ","Mark this as the default locale")))),2===h&&d.createElement(d.Fragment,null,d.createElement("div",{className:"form-group"},d.createElement("label",{className:"col-sm-3 control-label"},"Country code",d.createElement("span",{className:"required-star"},"*")),d.createElement("div",{className:"col-sm-9"},d.createElement("input",{type:"text",className:"form-control",placeholder:"e.g. US",value:t.countryCode,onChange:e=>S("countryCode",e.target.value)}))),d.createElement("div",{className:"form-group"},d.createElement("div",{className:"col-sm-offset-3 col-sm-9"},d.createElement("label",{className:"checkbox-inline"},d.createElement("input",{type:"checkbox",checked:t.defaultLocation,onChange:e=>S("defaultLocation",e.target.checked)})," ","Mark this as the default location"))),d.createElement("div",{className:"form-group"},d.createElement("label",{className:"col-sm-3 control-label"},"Legal address line 1",d.createElement("span",{className:"required-star"},"*")),d.createElement("div",{className:"col-sm-9"},d.createElement("input",{type:"text",className:"form-control",placeholder:"Street address",value:t.legalAddressLine1,onChange:e=>S("legalAddressLine1",e.target.value)}))),d.createElement("div",{className:"form-group"},d.createElement("label",{className:"col-sm-3 control-label"},"Legal city",d.createElement("span",{className:"required-star"},"*")),d.createElement("div",{className:"col-sm-9"},d.createElement("input",{type:"text",className:"form-control",placeholder:"City",value:t.legalCity,onChange:e=>S("legalCity",e.target.value)}))),d.createElement("div",{className:"form-group"},d.createElement("label",{className:"col-sm-3 control-label"},"Legal region code",d.createElement("span",{className:"required-star"},"*")),d.createElement("div",{className:"col-sm-9"},d.createElement("input",{type:"text",className:"form-control",placeholder:"e.g. CA",value:t.legalRegionCode,onChange:e=>S("legalRegionCode",e.target.value)}))),d.createElement("div",{className:"form-group"},d.createElement("label",{className:"col-sm-3 control-label"},"Legal postal code",d.createElement("span",{className:"required-star"},"*")),d.createElement("div",{className:"col-sm-9"},d.createElement("input",{type:"text",className:"form-control",placeholder:"Postal / ZIP code",value:t.legalPostalCode,onChange:e=>S("legalPostalCode",e.target.value)}))),d.createElement("div",{className:"form-group"},d.createElement("label",{className:"col-sm-3 control-label"},"Legal country code",d.createElement("span",{className:"required-star"},"*")),d.createElement("div",{className:"col-sm-9"},d.createElement("input",{type:"text",className:"form-control",placeholder:"e.g. US",value:t.legalCountryCode,onChange:e=>S("legalCountryCode",e.target.value)}))),d.createElement("div",{className:"form-group"},d.createElement("label",{className:"col-sm-3 control-label"},"Legal phone",d.createElement("span",{className:"required-star"},"*")),d.createElement("div",{className:"col-sm-9"},d.createElement("input",{type:"text",className:"form-control",placeholder:"Contact phone number",value:t.legalPhone,onChange:e=>S("legalPhone",e.target.value)})))),3===h&&d.createElement(d.Fragment,null,d.createElement("div",{className:"form-group"},d.createElement("label",{className:"col-sm-3 control-label"},"BIN / Card Acceptor ID",d.createElement("span",{className:"required-star"},"*")),d.createElement("div",{className:"col-sm-9"},s.map((e=>d.createElement("div",{className:"bin-caid-row",key:e.id,style:{display:"flex",gap:"8px",marginBottom:"8px"}},d.createElement("input",{type:"text",className:"form-control",placeholder:"Acquirer BIN",value:e.acquirerBin,onChange:t=>C(e.id,"acquirerBin",t.target.value)}),d.createElement("input",{type:"text",className:"form-control",placeholder:"Card Acceptor ID",value:e.cardAcceptorId,onChange:t=>C(e.id,"cardAcceptorId",t.target.value)}),d.createElement("button",{type:"button",className:"btn btn-default",onClick:()=>{return t=e.id,n((e=>e.length>1?e.filter((e=>e.id!==t)):e));var t},disabled:1===s.length,"aria-label":"Remove BIN/CAID pair"},"×")))),d.createElement("button",{type:"button",className:"btn btn-link",onClick:()=>n((e=>[...e,(0,_e.yl)()]))},"+ Add another BIN / Card Acceptor ID"))),d.createElement("div",{className:"form-group"},d.createElement("label",{className:"col-sm-3 control-label"},"Statement descriptors"),d.createElement("div",{className:"col-sm-9"},i.map((e=>d.createElement("div",{className:"descriptor-row",key:e.id,style:{display:"flex",gap:"8px",marginBottom:"8px"}},d.createElement("input",{type:"text",className:"form-control",placeholder:"e.g. ETHOCA HOTEL GROUP",value:e.value,onChange:t=>{return a=e.id,s=t.target.value,void r((e=>e.map((e=>e.id===a?$e($e({},e),{},{value:s}):e))));var a,s}}),d.createElement("button",{type:"button",className:"btn btn-default",onClick:()=>{return t=e.id,r((e=>e.length>1?e.filter((e=>e.id!==t)):e));var t},disabled:1===i.length,"aria-label":"Remove descriptor"},"×")))),d.createElement("button",{type:"button",className:"btn btn-link",onClick:()=>r((e=>[...e,(0,_e.Lz)()]))},"+ Add another descriptor"),d.createElement("p",{className:"help-block"},"Optional. Statement descriptors help Mastercard match transactions to your business. You can add more later."))))),d.createElement("div",{className:"form-actions"},h>1&&d.createElement("button",{type:"button",className:"btn btn-default",onClick:()=>v((e=>Math.max(e-1,1))),style:{marginRight:"8px"}},"Back"),h<_e.Td?d.createElement("button",{type:"button",className:"btn btn-primary",onClick:()=>{(0,_e.bG)(t,h)?v((e=>Math.min(e+1,_e.Td))):e.errorAlert("Please fill in all required fields.")}},"Next"):d.createElement("button",{className:g()("btn btn-primary",{disabled:l}),onClick:()=>{const a=s.filter((e=>e.acquirerBin.trim()&&e.cardAcceptorId.trim()));if(!(0,_e.bG)(t,1)||!(0,_e.bG)(t,2))return void e.errorAlert("Please fill in all required fields.");if(!a.length)return void e.errorAlert("Please add at least one BIN / Card Acceptor ID pair.");o(!0);const n=(0,m.A)({config:e.config,name:"settingsEthocaOnboarding"});(0,c.bE)(n,(0,_e.mg)({formData:t,filledPairs:a,descriptorRows:i,mode:e.credential&&e.credential.mode})).then((t=>{if(t.success){const a=t.data&&t.data.status?t.data.status:"submitted",s=t.data&&t.data.warnings||[];s.length?e.errorAlert(`Mastercard Consumer Clarity onboarding ${a} with warnings: ${s.join("; ")}`):e.successAlert(`Mastercard Consumer Clarity onboarding ${a}.`),e.inWizard?(t.account&&e.addCredential(t.account),e.cancelAddingAccount()):(u(t.data||{}),t.data&&t.data.subMerchantGuid&&y((e=>$e($e({},e||{}),{},{subMerchantGuid:t.data.subMerchantGuid}))))}else e.errorAlert("Failed to submit Mastercard Consumer Clarity onboarding.")})).catch((t=>{e.errorAlert(t.json&&t.json.error&&t.json.error.message?t.json.error.message:"Error submitting Mastercard Consumer Clarity onboarding.")})).finally((()=>{o(!1)}))},disabled:l},l?d.createElement("span",null,d.createElement("i",{className:"fa fa-spinner fa-pulse"})," Saving"):"Submit"))))};function qe(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,s)}return a}function Ye(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};
2t%2?qe(Object(a),!0).forEach((function(t){We(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):qe(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}function Je(){return Je=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var s in a)({}).hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},Je.apply(null,arguments)}function We(e,t,a){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var a=e[Symbol.toPrimitive];if(void 0!==a){var s=a.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function He(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return e?.config?.rapidDisputeResolution?.enabled||!1}function Ge(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return e.filter((e=>!(e.name===Le.Ge&&!He(t))&&(!(e.name===Le.el&&!t?.config?.dlocal?.enabled)&&(!(e.name===Le.Al&&!t?.config?.klarna?.enabled)&&!(e.name===Le.rD&&!t?.config?.mastercardClarity?.enabled)))))}function Xe(e){return e.title?e.title:`your ${S.y[e.processor]} account`}class Qe extends d.Component{constructor(e){super(e),We(this,"onChange",(e=>{this.setState({newField:e.currentTarget.value})})),We(this,"addField",(e=>{e.preventDefault(),this.setState((e=>{let t=!1;return new Set(e.metadataFields).has(this.state.newField)||(e.metadataFields.push(this.state.newField),t=!0),{metadataFields:e.metadataFields,newField:"",dirty:t}}),(()=>{this.state.dirty&&this.props.saveMetadataFields(this.state.metadataFields).then((()=>{this.setState({dirty:!1})}))}))})),We(this,"removeField",(e=>{this.setState((t=>(t.metadataFields.splice(e,1),{metadataFields:t.metadataFields,dirty:!0})),(()=>{this.props.saveMetadataFields(this.state.metadataFields).then((()=>{this.setState({dirty:!1})}))}))})),this.state={newField:"",metadataFields:[],dirty:!1}}static getDerivedStateFromProps(e,t){if(t.dirty)return null;return{metadataFields:e.settings.metadataFields}}render(){if(!this.props.settings.organization.stripeConnected&&!this.props.settings.organization.braintreeConnected)return null;let e,t,a,s,n;return this.props.settings.organization.stripeConnected&&this.props.settings.organization.braintreeConnected?(e=d.createElement("span",null,"If you store any ",d.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:"https://stripe.com/docs/api#metadata"},"metadata fields")," on your Stripe ",d.createElement("code",null,"Charge"),", ",d.createElement("code",null,"Customer"),", or ",d.createElement("code",null,"Subscription")," objects, or any ",d.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:"https://articles.braintreepayments.com/control-panel/custom-fields"},"custom fields")," on your Braintree ",d.createElement("code",null,"Transaction")," or ",d.createElement("code",null,"Customer")," objects, then you can enter the field names here and Chargehound will automatically collect that information as well."),t="metadata or custom",a="Metadata and Custom Fields"):this.props.settings.organization.stripeConnected?(e=d.createElement("span",null,"If you store any ",d.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:"https://stripe.com/docs/api#metadata"},"metadata fields")," on your Stripe ",d.createElement("code",null,"Charge"),", ",d.createElement("code",null,"Customer"),", or ",d.createElement("code",null,"Subscription")," objects, then you can enter the field names here and Chargehound will automatically collect that information as well."),t="metadata",a="Metadata"):this.props.settings.organization.braintreeConnected&&(e=d.createElement("span",null,"If you store any ",d.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:"https://articles.braintreepayments.com/control-panel/custom-fields"},"custom fields")," on your Braintree ",d.createElement("code",null,"Transaction")," or ",d.createElement("code",null,"Customer")," objects, then you can enter the field names here and Chargehound will automatically collect that information as well."),t="custom",a="Custom Fields"),this.props.settings.organization.braintreeConnected&&(s=d.createElement("p",null,d.createElement("span",null,'Your Braintree custom fields should be "Store-and-pass-back" fields, and the field name given to Chargehound should be the API name.'))),this.state.metadataFields.length&&(n=d.createElement("div",{className:"fields"},d.createElement("ul",{className:"list-unstyled clearfix"},this.state.metadataFields.map(((e,t)=>d.createElement("li",{key:t},d.createElement("div",{className:"field"},d.createElement("span",{className:"name"},e),d.createElement("button",{key:"delete",className:"delete",onClick:()=>this.removeField(t)},d.createElement("i",{className:"fa fa-times-circle"}))))))))),d.createElement("div",{id:"metadata-settings",ref:C.A,className:"app-block no-padding tight metadata-settings"},d.createElement(Oe.XG,{when:!!this.state.dirty,message:"You have unsaved changes, if you leave the page they will be lost."}),d.createElement("div",{className:"header"},d.createElement("h4",null,a)),d.createElement("div",{className:"content"},d.createElement("p",null,"Chargehound tries to automatically collect standard information from your payment processor when a dispute is created."),d.createElement("p",null,e),s,d.createElement("div",{className:"section-upper emphasis"},"Add the name of a ",t," field:"),d.createElement("form",{className:"form clearfix"},d.createElement("div",{className:"form-group"},d.createElement("input",{className:"form-control order-id",type:"text",value:this.state.newField,onChange:this.onChange,placeholder:"E.g. order_id"})),d.createElement("button",{disabled:!this.state.newField,onClick:this.addField,className:"pull-right btn btn-default"},"Add field"))),n&&d.createElement("hr",null),n)}}class Ze extends d.Component{constructor(e){super(e),We(this,"addAccount",(()=>{this.setState({adding:!0,preselectedProcessor:null})})),We(this,"addAccountForProcessor",(e=>{this.setState({adding:!0,preselectedProcessor:e})})),We(this,"cancelAddingAccount",(()=>{this.setState({adding:!1,preselectedProcessor:null})})),We(this,"editAccount",(e=>{this.setState({editing:e})})),We(this,"finishEditingAccount",(()=>{this.setState({editing:!1})}
2)),We(this,"generateSlug",(e=>{const t=Object.keys(this.props.settings.credentials),a=[];t.forEach((e=>{const t=this.props.settings.credentials[e];Array.prototype.push.apply(a,t)}));if(!a.some((e=>"default"===e.slug)))return"default";let s=e.title.toLowerCase().replace(/[^a-z0-9]+/g,"-");if(a.some((e=>e.slug===s))){const e=s;let t=2;for(;a.some((e=>e.slug===s));)t++,s=e+"-"+t}return s})),this.state={adding:!1,editing:!1,saving:!1,preselectedProcessor:null}}render(){let e,t;const a=Object.keys(this.props.settings.credentials).sort().filter((e=>!("visa"===e&&!He(this.props))));return this.state.adding&&(e=d.createElement(st,Je({cancelAddingAccount:this.cancelAddingAccount,generateSlug:this.generateSlug,preselectedProcessor:this.state.preselectedProcessor},this.props))),t=a.length>0?d.createElement("div",{className:"app-block no-padding tight"},d.createElement("div",{className:"header"},d.createElement("h4",null,"Connected Accounts")),a.map((e=>{const t=this.props.settings.credentials[e];return d.createElement(et,Je({key:e,processor:e,credentials:t},this.props,{adding:this.state.adding,editing:this.state.editing,editAccount:this.editAccount,finishEditingAccount:this.finishEditingAccount}))})),d.createElement(at,{addAccount:this.addAccount,editing:this.state.editing})):d.createElement(tt,Je({addAccountForProcessor:this.addAccountForProcessor},this.props)),d.createElement("div",{className:"processors-tab"},t,e,d.createElement(Qe,this.props),d.createElement(_t,this.props))}}function et(e){const[t,a]=(0,d.useState)(!1);if(e.credentials.length<3)return d.createElement("div",{className:"processor-group"},e.credentials.filter((t=>!("visa"===t.processor&&!He(e)))).map((t=>d.createElement(bt,Je({key:t.hash,credential:t},e,{adding:e.adding,editing:e.editing,editAccount:e.editAccount,finishEditingAccount:e.finishEditingAccount})))));{let s,n;return t?(s=d.createElement("span",null,"Hide ",d.createElement("i",{className:"fa fa-chevron-down toggler"})),n=d.createElement("div",{className:"processor-list"},e.credentials.filter((t=>!("visa"===t.processor&&!He(e)))).map((t=>d.createElement(bt,Je({key:t.hash,credential:t,nestedVersion:!0},e,{adding:e.adding,editing:e.editing,editAccount:e.editAccount,finishEditingAccount:e.finishEditingAccount})))))):s=d.createElement("span",null,"View ",d.createElement("i",{className:"fa fa-chevron-right toggler"})),s=d.createElement("div",{className:"toggle",onClick:()=>a(!t)},s),d.createElement("div",{className:"processor-group"},d.createElement("div",{className:"account-item"},d.createElement("div",{className:"clearfix account-summary"},d.createElement("div",{className:"pull-left"},d.createElement("div",{className:"account-name"},S.y[e.processor]),d.createElement(rt,{processor:e.processor})),d.createElement("div",{className:"pull-right"},d.createElement("div",{className:"processor-count"},e.credentials.length," accounts"),s))),n)}}function tt(e){const t=Ge(Le.ZD,e);return d.createElement("div",{className:"app-block no-padding tight unconnected"},d.createElement("div",{className:"header"},d.createElement("h4",null,"Connect Your Payment Processor")),t.map((t=>d.createElement("a",{key:t.name,className:`app-item text-center provider ${t.name}-provider`,onClick:()=>e.addAccountForProcessor(t.name),style:{cursor:"pointer"}},d.createElement("img",{alt:`Connect with ${t.name}`,src:t.logo})))))}function at(e){return e.editing?d.createElement("div",{className:"item-add text-right"},d.createElement("span",{className:"explainer"}," ")):d.createElement("div",{className:"item-add text-right"},d.createElement("span",{className:"explainer"},"Add a new account"),d.createElement("div",{className:"btn btn-primary add-rule",onClick:e.addAccount},d.createElement("span",{className:"fa fa-plus"})))}class st extends d.Component{constructor(e){super(e),We(this,"choose",(e=>{this.setState({choosing:e})})),We(this,"selectMode",(e=>{const t=De()(this.state.account);t.mode=e.currentTarget.value,t.title=(0,S.A)(t),t.slug=this.props.generateSlug(t),t.suggestedTitle=`e.g. ${t.title}`,t.suggestedSlug=`e.g. ${t.slug}`,this.setState({account:t})})),We(this,"selectConnectionType",(e=>{const t=De()(this.state.account);t.connectionType=e.currentTarget.value,this.setState({account:t})})),We(this,"selectProcessor",(e=>{const t=De()(this.state.account);t.processor=e;const a=He(this.props)?[Le.Hv,Le.MU,Le.XP,Le.Ge]:[Le.Hv,Le.MU,Le.XP],s=a.includes(e);s&&(t.mode="live"),t.title=(0,S.A)(t),t.slug=this.props.generateSlug(t),t.suggestedTitle=`e.g. ${t.title}`,t.suggestedSlug=`e.g. ${t.slug}`;let n="mode";a.includes(e)?n="multi_merchant_id":s?n="title":e===Le.kN&&(n="type"),this.setState({account:t,choosing:n})}
2)),We(this,"validateTitle",(()=>{this.setState({validating:!0});const e=(0,m.A)({config:this.props.config,name:"settingsAccountTitleJson"});(0,c.yJ)(e,{title:this.state.account.title}).then((()=>{this.setState({validating:!1}),this.titleChosen()})).catch((e=>{this.setState({validating:!1}),this.props.errorAlert(e.json.error.message||"An unexpected error occurred.")}))})),We(this,"titleChosen",(()=>{"default"!==this.props.generateSlug(this.state.account)?this.choose("slug"):this.validateAccountDetails()})),We(this,"updateProperty",(e=>{const t=De()(this.state.account);t[e.currentTarget.name]=e.currentTarget.value,this.setState({account:t})})),We(this,"updatePropertyByKey",((e,t)=>{const a=De()(this.state.account);a[e]=t,this.setState({account:a})})),We(this,"clearError",((e,t)=>{this.state.error&&e===this.state.error.index&&this.state.error.fieldType===t&&this.setState({error:null})})),We(this,"updateSlug",(e=>{const t=De()(this.state.account);t.slug=e.currentTarget.value.toLowerCase().replace(/[^a-zA-Z0-9]/,"-"),this.setState({account:t})})),We(this,"updateTitle",(e=>{const t=De()(this.state.account);t.title=e.currentTarget.value,t.slug=this.props.generateSlug(t),t.suggestedSlug=`e.g. ${t.slug}`,this.setState({account:t})})),We(this,"validateAccountDetails",(()=>{this.setState({validating:!0});const e=(0,m.A)({config:this.props.config,name:"settingsAccountSlugJson"});(0,c.bE)(e,{slug:this.state.account.slug,title:this.state.account.title,processor:this.state.account.processor,mode:this.state.account.mode}).then((e=>{if(this.setState({validating:!1}),"mastercard"!==this.state.account.processor)if("adyen"===this.state.account.processor||"worldpay"===this.state.account.processor||"checkout"===this.state.account.processor||"klarna"===this.state.account.processor||"dlocal"===this.state.account.processor||"restricted"===this.state.account.connectionType){const e=De()(this.state.account);e.account="",e.key="","klarna"===this.state.account.processor&&(e.region="eu"),"dlocal"===this.state.account.processor&&(e.secretKey="",e.xAccountId=""),this.setState({choosing:"api_keys",account:e})}else this.setState({choosing:"token",connectData:e});else this.setState({choosing:"ethoca"})})).catch((e=>{this.setState({validating:!1}),this.props.errorAlert(e.json.error.message||"An unexpected error occurred.")}))})),We(this,"verifyCredentials",(()=>{this.setState({verifying:!0});const e=(0,m.A)({config:this.props.config,name:"settingsAdyenConnectVerifyJson"});(0,c.bE)(e,{slug:this.state.account.slug,title:this.state.account.title,account:this.state.account.account,username:this.state.account.username,password:this.state.account.password,mode:this.state.account.mode}).then((e=>{e.success?(this.props.addCredential(e.account),this.props.cancelAddingAccount()):(this.props.errorAlert(e.message||"Unable to verify credentials."),this.setState({verifying:!1}))})).catch((e=>{this.props.errorAlert(e.json.error.message||"Unable to verify credentials."),this.setState({verifying:!1})}))})),We(this,"verifyKlarnaCredentials",(()=>{this.setState({verifying:!0});const e=(0,m.A)({config:this.props.config,name:"settingsKlarnaConnectVerifyJson"});(0,c.bE)(e,{slug:this.state.account.slug,title:this.state.account.title,merchant_id:this.state.account.account,api_key:this.state.account.key,region:this.state.account.region||"eu",mode:this.state.account.mode}).then((e=>{e.success?(this.props.addCredential(e.account),this.props.cancelAddingAccount(),this.props.successAlert("Klarna account connected successfully!")):(this.props.errorAlert(e.message||"Unable to verify Klarna credentials."),this.setState({verifying:!1}))})).catch((e=>{this.props.errorAlert(e.json.error.message||"Unable to verify Klarna credentials."),this.setState({verifying:!1})}))})),We(this,"verifyMerchantId",(()=>{this.setState({verifying:!0});const e=(0,m.A)({config:this.props.config,name:"settingsMerchantIdVerifyJson"});(0,c.bE)(e,{slug:this.state.account.slug,title:this.state.account.title,account:this.state.account.account,accounts:this.state.account.accounts,processor:this.state.account.processor}).then((e=>{e.account.accounts?this.setState({account:Ye(Ye({},this.state.account),{},{accounts:e.account.accounts}),choosing:"multi_title",verifying:!1}):(this.props.addCredential(e.account),this.props.cancelAddingAccount(),this.state.account.processor===Le.Hv?this.props.successAlert("Vantiv merchant ID added."):this.state.account.processor===Le.MU?this.props.successAlert("American Express Service Establishment Number added."):this.state.account.processor===Le.XP?this.props.successAlert("Chase merchant ID added."):this.state.account.processor===Le.Ge&&this.props.successAlert("Visa merchant ID added."))})).catch((e=>{e.json?(this.props.errorAlert(e.json.error.message),null!==e.json.error.index&&void 0!==e.json.error.index&&this.setState({error:{index:e.json.error.index,fieldType:e.json.error.fieldType}})):this.props.errorAlert(e.json.error.message||"Unable to verify merchant ID."),this.setState({verifying:!1})}
2))})),We(this,"verifyMultiTitle",(()=>{this.setState({verifying:!0});const e=(0,m.A)({config:this.props.config,name:"settingsMultiTitleVerifyJson"}),{titles:t,slugs:a}=Et(this.state.account,this.props.settings);(0,c.bE)(e,{slugs:a,titles:t,accounts:this.state.account.accounts,processor:this.state.account.processor}).then((e=>{e.credentials.forEach((e=>{this.props.addCredential(e)})),this.props.cancelAddingAccount();const t=e.credentials.length>1?"s":"";this.state.account.processor===Le.Hv?this.props.successAlert(`Vantiv merchant ID${t} added.`):this.state.account.processor===Le.MU?this.props.successAlert(`American Express Service Establishment Number${t} added.`):this.state.account.processor===Le.XP?this.props.successAlert(`Chase merchant ID${t} added.`):this.state.account.processor===Le.Ge&&this.props.successAlert(`Visa merchant ID${t} added.`)})).catch((e=>{e.json?(this.props.errorAlert(e.json.error.message),null!==e.json.error.index&&void 0!==e.json.error.index&&this.setState({error:{index:e.json.error.index,fieldType:e.json.error.fieldType}})):this.props.errorAlert(e.json.error.message||"Unable to add new accounts."),this.setState({verifying:!1})}))})),We(this,"verifyApiKey",(()=>{this.setState({verifying:!0});const e=(0,m.A)({config:this.props.config,name:"settingsApiKeyVerifyJson"}),t={slug:this.state.account.slug,title:this.state.account.title,account:this.state.account.account,key:this.state.account.key,mode:this.state.account.mode,processor:this.state.account.processor};"dlocal"===this.state.account.processor&&(t.secretKey=this.state.account.secretKey,this.state.account.xAccountId&&(t.xAccountId=this.state.account.xAccountId)),(0,c.bE)(e,t).then((e=>{this.props.addCredential(e.account),this.props.cancelAddingAccount(),"worldpay"===this.state.account.processor?this.props.successAlert("Worldpay account added."):"checkout"===this.state.account.processor?this.props.successAlert("Checkout account added."):"stripe"===this.state.account.processor?this.props.successAlert("Stripe account added."):"adyen"===this.state.account.processor?this.props.successAlert("Adyen account added."):"dlocal"===this.state.account.processor&&this.props.successAlert("dLocal account added.")})).catch((e=>{this.props.errorAlert(e.json.error.message||"Unable to verify API key."),this.setState({verifying:!1})}))})),this.state={account:{processor:null,title:null,slug:null,account:null,username:null,password:null,suggestedTitle:null,suggestedSlug:null},choosing:"processor",validating:!1,verifying:!1,error:null}}componentDidMount(){this.props.preselectedProcessor&&this.selectProcessor(this.props.preselectedProcessor)}render(){const e={choose:this.choose,selectProcessor:this.selectProcessor,selectMode:this.selectMode,selectConnectionType:this.selectConnectionType,updateTitle:this.updateTitle,updateSlug:this.updateSlug,updateProperty:this.updateProperty,updatePropertyByKey:this.updatePropertyByKey,clearError:this.clearError,verifyCredentials:this.verifyCredentials,verifyKlarnaCredentials:this.verifyKlarnaCredentials,verifyMultiTitle:this.verifyMultiTitle,verifyMerchantId:this.verifyMerchantId,verifyApiKey:this.verifyApiKey,validateAccountDetails:this.validateAccountDetails,validateTitle:this.validateTitle},t={credential:this.state.account,choosing:this.state.choosing,connectData:this.state.connectData,verifying:this.state.verifying,validating:this.state.validating,error:this.state.error},a=`account-modal choosing-${this.state.choosing}`;return d.createElement(T(),{isOpen:!0,shouldCloseOnOverlayClick:!1,onRequestClose:this.props.cancelAddingAccount,contentLabel:"Account Modal",className:"dialog-modal-content",overlayClassName:"dialog-modal-overlay"},d.createElement("div",{className:a},d.createElement("button",{onClick:this.props.cancelAddingAccount,type:"button",className:"close","data-dismiss":"modal","aria-label":"Close"},d.createElement("span",{"aria-hidden":"true"},"×")),d.createElement("div",{className:"content-section"},d.createElement(nt,Je({},this.props,t,e)),d.createElement(it,Je({},this.props,t,e)))))}}function nt(e){return"processor"===e.choosing?d.createElement(ot,e):"type"===e.choosing?d.createElement(ct,e):"mode"===e.choosing?d.createElement(dt,e):"title"===e.choosing?d.createElement(mt,e):"slug"===e.choosing?d.createElement(pt,e):"token"===e.choosing?d.createElement(ht,e):"ethoca"===e.choosing?d.createElement(Ve,Je({},e,{inWizard:!0})):"credentials"===e.choosing?d.createElement(gt,e):"multi_merchant_id"===e.choosing?d.createElement(vt,e):"multi_title"===e.choosing?d.createElement(ft,e):"api_keys"===e.choosing?d.createElement(yt,e):null}function it(e){let t="Next",a=!0;let s,n,i=!0,r=!0,l=null,o=null;if("processor"===e.choosing)a=!1,i=!1;else if("type"===e.choosing)r=e.credential.connectionType,l=()=>{"connect"===e.credential.connectionType?e.choose("title"):e.choose("mode")},o=()=>e.choose("processor");else if("mode"===e.choosing)r=e.credential.mode,l=()=>e.choose("title"),o=()=>{"restricted"===e.credential.connectionType?e.choose("type"):e.choose("processor")};else if("title"===e.choosing){r=e.credential.title,l=e.validateTitle;const t=He(e)?[Le.kN,Le.Hv,Le.MU,Le.XP,Le.Ge]:[Le.kN,Le.Hv,Le.MU,Le.XP];o=()=>e.choose(Pe()(t,e.credential.processor)?"processor":"mode")}else"slug"===e.choosing?(r=e.credential.slug,l=e.validateAccountDetails,o=()=>e.choose("title")):"credentials"===e.choosing?(r=e.credential.account&&e.credential.username&&e.credential.password,l=e.verifyCredentials,t="Verify",o=()=>e.choose("title")):"token"===e.choosing||"ethoca"===e.choosing?(a=!1,o=()=>e.choose("title")):"multi_merchant_id"===e.choosing?(r=e.credential.accounts&&e.credential.accounts.some((e=>!!e)),l=e.verifyMerchantId,t="Next",o=()=>e.choose("processor")):"multi_title"===e.choosing?(r=!0,l=e.verifyMultiTitle,t="Save",o=()=>e.choose("multi_merchant_id")):"api_keys"===e.choosing&&("dlocal"===e.credential.processor?(r=e.credential.account&&e.credential.key&&e.credential.secretKey,l=e.verifyApiKey):"klarna"===e.credential.processor?(r=e.credential.account&&e.credential.key,l=e.verifyKlarnaCredentials):(r=e.credential.account&&e.credential.key,l=e.verifyApiKey),t="Save",o=()=>e.choose("title"));if(r=r&&!e.verifying&&!e.validating,a){let a="btn btn-primary btn-margin-left pull-right ";r||(a+=" disabled");const n=e.verifying||e.validating?d.createElement("i",{className:"fa fa-spinner fa-pulse"}):null;s=d.createElement("div",{className:a,onClick:r?l:null},n," ",t)}return i&&(n=d.createElement("a",{className:"back",onClick:o},"← ","Back")),d.createElement("div",{className:"account-edit-footer"},n,s)}function rt(e){let t=e.processor||e.credential.processor;if(!t)return null;const a=S.y[t],s=`logo ${t}`;return"worldpay_portal"===t&&(t="worldpay"),d.createElement("img",{className:s,alt:a,title:a,src:`https://www.paypalobjects.com/chargehound/logos/${t}.png`})}function lt(e){let{processor:t,onClick:a}=e;return d.createElement("a",{key:t.name,className:`provider ${t.name}-provider`,onClick:a},d.createElement("img",{alt:`Connect with ${t.name}`,src:t.logo}))}function ot(e){return d.createElement("div",{className:"content"},d.createElement("div",{className:"prompt"},"Add a payment processor"),d.createElement("div",{className:"provider-prompt"},"One click connection"),d.createElement("div",{className:"providers lrg"},Ge(Le.ZD,e).filter((e=>e.oneClickConnect)).map((t=>d.createElement(lt,{key:t.name,processor:t,onClick:()=>e.selectProcessor(t.name)})))),d.createElement("hr",null),d.createElement("div",{className:"provider-prompt"},"Enter account details to connect"),d.createElement("div",{className:"providers list"},Ge(Le.ZD,e).filter((e=>!e.oneClickConnect)).map((t=>d.createElement(lt,{key:t.name,processor:t,onClick:()=>e.selectProcessor(t.name)})))))}function ct(e){return d.createElement("div",{className:"content"},d.createElement("div",{className:"prompt"},"How do you want to connect your account?"),d.createElement("input",{type:"radio",name:"connection",value:"connect",checked:"connect"===e.credential.connectionType,onCh
2ange:e.selectConnectionType}),d.createElement("label",null,"Stripe Connect"),d.createElement("input",{type:"radio",name:"connection",value:"restricted",checked:"restricted"===e.credential.connectionType,onChange:e.selectConnectionType}),d.createElement("label",null,"Restricted API key"))}function dt(e){let t,a;return"braintree"===e.credential.processor||"paypal"===e.credential.processor?(t="Production",a="Sandbox"):(t="Live",a="Test"),d.createElement("div",{className:"content"},d.createElement("div",{className:"prompt"},"What type of account do you want to add?"),d.createElement("input",{type:"radio",name:"mode",value:"live",checked:"live"===e.credential.mode,onChange:e.selectMode}),d.createElement("label",null,t),d.createElement("input",{type:"radio",name:"mode",value:"test",checked:"test"===e.credential.mode,onChange:e.selectMode}),d.createElement("label",null,a))}function mt(e){return d.createElement("div",{className:"content"},d.createElement("div",{className:"prompt"},"Pick a display name for your new account"),d.createElement("input",{type:"text",className:"form-control",placeholder:e.credential.suggestedTitle,value:e.credential.title,onChange:e.updateTitle}),d.createElement("div",{className:"description"},"The display name is how your new account will be displayed in the Chargehound dashboard."))}function pt(e){return d.createElement("div",{className:"content"},d.createElement("div",{className:"prompt"},"Pick a unique ID for your new account"),d.createElement("input",{type:"text",className:"form-control",placeholder:e.credential.suggestedSlug,value:e.credential.slug,onChange:e.updateSlug}),d.createElement("div",{className:"description"},"The unique ID is how your new account will be identified in the Chargehound API."))}class ut extends d.Component{constructor(e){super(e),this.state={isMounted:!1,connectInstance:!1}}componentDidMount(){this.setState({isMounted:!0}),this.timeout=setTimeout((()=>{"braintree"!==this.props.credential.processor&&"paypal"!==this.props.credential.processor||this.state.connectInstance||(this.props.cancelAddingAccount(),"braintree"===this.props.credential.processor?this.props.errorAlert("The Braintree Connect button failed to load. Please refresh the page and try again."):"paypal"===this.props.credential.processor?this.props.errorAlert("The PayPal Connect button failed to load. Please refresh the page and try again."):this.props.errorAlert("Failed to load connect data, please refresh the page and try again."))}),2e4)}componentDidUpdate(){this.props.connectData&&this.state.isMounted&&!this.state.connectInstance&&("braintree"===this.props.credential.processor?this.props.braintreeConnectLoaded&&n()(BraintreeOAuthConnect)&&this.setState({connectInstance:!0},(()=>{new BraintreeOAuthConnect({connectUrl:this.props.connectData.connectUrl,environment:this.props.connectData.connectEnv,container:"bt-oauth-connect-container"})})):"paypal"===this.props.credential.processor&&this.props.paypalConnectLoaded&&n()(paypal.use)&&paypal.use(["login"],(e=>{e?this.setState({connectInstance:!0},(()=>{e.render({appid:this.props.connectData.appId,authend:this.props.connectData.connectEnv,scopes:this.props.connectData.scopes,containerid:"cwppButton",responseType:"code",locale:"en-us",buttonType:"CWP",buttonShape:"pill",buttonSize:"lg",fullPage:"true",returnurl:this.props.connectData.callbackUrl})})):(this.props.cancelAddingAccount(),this.props.errorAlert("The PayPal Connect button failed to load. Please refresh the page and try again."))})))}componentWillUnmount(){clearTimeout(this.timeout)}render(){let e,t,a;"stripe"===this.props.credential.processor?e=d.createElement("a",{href:this.props.connectData.connectUrl,className:"stripe-connect connect-stripe-btn"},d.createElement("span",null,"Connect with Stripe")):"braintree"===this.props.credential.processor?(e=d.createElement("div",{id:"bt-oauth-connect-container",className:"connect-braintree-btn"}),t=d.createElement("div",{className:"account-mode"},"This is a ","live"===this.props.credential.mode?"Production":"Sandbox"," account")):"paypal"===this.props.credential.processor&&(e=d.createElement("span",{id:"cwppButton"}),t=d.createElement("div",{className:"account-mode"},"This is a ","live"===this.props.credential.mode?"Production":"Sandbox"," account")),"braintree"!==this.props.credential.processor&&"paypal"!==this.props.credential.processor||this.state.connectInstance||(a=d.createElement("i",{className:"fa fa-spinner fa-pulse"}));const s=`connect ${this.props.credential.processor}`;let n;return n=this.props.isReconnect?"Reconnect account":"Review and connect",d.createElement("div",{className:"content"},d.createElement("div",{className:"prompt"},n),d.createElement("div",{className:s},d.createElement("div",{className:"account-name"},d.createElement("label",null,"Account"),d.createElement("div",{className:"value"},this.props.credential.title||(0,S.A)(this.props.credential))),d.createElement("div",{className:"account-id"},d.createElement("label",null,"Unique ID"),d.createElement("div",{className:"value"},this.props.credential.slug)),t,e,a))}}function ht(e){const[t]=(0,Te.A)("https://assets.braintreegateway.com/v1/braintree-oauth-connect.
2js",!1),[a]=(0,Te.A)("https://www.paypalobjects.com/js/external/connect/api.js",!1);return d.createElement(ut,Je({paypalConnectLoaded:a,braintreeConnectLoaded:t},e))}function gt(e){const t="live"===e.credential.mode?"https://ca-live.adyen.com/ca/ca/config/human_users_new.shtml":"https://ca-test.adyen.com/ca/ca/config/human_users_new.shtml",a="live"===e.credential.mode?"":"Test",s=d.createElement("span",{className:"instructions"},"In order to sync disputes automatically to Chargehound from Adyen, you need to supply login details for an Adyen ",a," user with the Merchant Dispute Management role in the"," ",d.createElement("a",{href:t,target:"_blank",rel:"noopener noreferrer"},"Adyen Customer Area"),".");return d.createElement("div",{className:"content"},d.createElement("div",{className:"clearfix"},d.createElement("div",{className:"prompt"},"Please verify credentials for your new Adyen account."),d.createElement("div",{className:"verify-credentials"},d.createElement("div",{className:"form-row clearfix"},d.createElement("input",{type:"text",name:"account",className:"form-control",placeholder:"Account",value:e.credential.account,onChange:e.updateProperty})),d.createElement("div",{className:"form-row clearfix"},d.createElement("input",{type:"text",name:"username",className:"form-control",placeholder:"User Name",value:e.credential.username,onChange:e.updateProperty})),d.createElement("div",{className:"form-row clearfix"},d.createElement("input",{type:"password",name:"password",className:"form-control",placeholder:"Password",value:e.credential.password,autoComplete:"new-password",onChange:e.updateProperty})),s)))}function vt(e){const t=e.credential.accounts||[""];let a,s;e.credential.processor===Le.Hv?a="Please tell us your Vantiv merchant ID":e.credential.processor===Le.MU?a="Please tell us your American Express Service Establishment Number":e.credential.processor===Le.XP?a="Please tell us your Chase merchant ID":e.credential.processor===Le.Ge&&(a="Please tell us your Visa client ID"),e.credential.processor===Le.Hv?s=d.createElement(d.Fragment,null,"To get started with your Vantiv integration, please enter your Vantiv merchant ID. If you are unsure what your merchant ID is, get in touch with"," ",d.createElement("a",{href:"https://developer.vantiv.com/community/help-and-getting-started/main-contact-us"},"Vantiv technical support.")):e.credential.processor===Le.MU?s=d.createElement(d.Fragment,null,"To get started with your American Express integration, please enter your American Express Service Establishment Number. The Service Establishment Number (SE#) is located on your American Express statements and web portal reports. If you are unsure what your Service Establishment Number is, get in touch with American Express."):e.credential.processor===Le.XP?s=d.createElement(d.Fragment,null,"To get started with your Chase integration, please enter your Chase merchant ID. If you are unsure what your merchant ID is, get in touch with"," ",d.createElement("a",{href:"https://secure.paymentech.com/devcenter/secure/support/contactus"},"Chase technical support.")):e.credential.processor===Le.Ge&&(s=d.createElement(d.Fragment,null,"To get started with your Visa integration, please enter your Visa merchant ID. If you are unsure what your merchant ID is, get in touch with Visa support."));const n=e.credential.processor===Le.Ge?"Client ID":"Merchant ID";return d.createElement("div",{className:"content"},d.createElement("div",{className:"clearfix"},d.createElement("div",{className:"prompt"},a),d.createElement("div",{className:"verify-credentials"},d.createElement("div",{className:"merchant-ids"},t.map(((a,s)=>d.createElement("div",{className:g()({"input-group":!0,"has-error":e.error&&"mid"===e.error.fieldType&&s===e.error.index}),key:s},d.createElement("input",{type:"text",name:"account",className:"form-control",placeholder:n,value:a,onChange:a=>{const n=t.slice(0);n[s]=a.currentTarget.value,e.updatePropertyByKey("accounts",n),e.clearError(s,"mid")}}),d.createElement("span",{className:"input-group-btn"},d.createElement("button",{disabled:1===t.length,className:"btn btn-default",type:"button",onClick:()=>{const a=t.slice(0);a.splice(s,1),e.updatePropertyByKey("accounts",a),e.clearError(s,"mid")}},d.createElement("span",{className:"fa fa-minus"}))))))),d.createElement("div",{className:"clearfix"},d.createElement("a",{className:"link-btn pull-right",onClick:()=>{const a=t.slice(0);a.push(""),e.updatePropertyByKey("accounts",a)}},"Add another ",d.createElement("span",{className:"fa fa-plus"}))),d.createElement("div",{className:"instructions"},s))))}function Et(e,t){const a=Object.keys(t.credentials),s=[];a.forEach((e=>{const a=t.credentials[e];Array.prototype.push.apply(s,a)}));let n=(0,S.A)(e);const i=n,r=i.toLowerCase().replace(/[^a-z0-9]+/g,"-");let l=1;if(s.some((e=>e.title===n)))for(;s.some((e=>e.title===n));)l++,n=i+" "+l;const o=e.titles||[],c=e.slugs||[];
2return e.accounts.forEach(((e,t)=>{void 0===o[t]&&(o[t]=0===t?n:i+" "+(l+t)),void 0===c[t]&&(c[t]=o[t].toLowerCase().replace(/[^a-z0-9]+/g,"-"))})),{titles:o,slugs:c,baseTitle:i,baseSlug:r}}function ft(e){const{titles:t,slugs:a,baseTitle:s,baseSlug:n}=Et(e.credential,e.settings);let i,r;return e.credential.accounts.length>1?(i="Pick titles and IDs for your new accounts",r=d.createElement(d.Fragment,null,"The titles are how your new accounts will be displayed in the Chargehound dashboard. The unique IDs  how your new accounts will be identified in the Chargehound API.")):(i="Pick a title and ID for your new account",r=d.createElement(d.Fragment,null,"The title is how your new account will be displayed in the Chargehound dashboard. The unique ID is how your new account will be identified in the Chargehound API.")),d.createElement("div",{className:"content container-fluid"},d.createElement("div",{className:"prompt"},i),d.createElement("div",{className:"description"},r),d.createElement("div",{className:"merchant-ids titles"},e.credential.accounts.map(((i,r)=>d.createElement("div",{key:r},0===r?null:d.createElement("hr",null),d.createElement("div",{className:"row-heading mid emphasis"},d.createElement("strong",null,"Account: "),d.createElement("code",null,i)),d.createElement("div",{className:"row-heading emphasis"},"Title"),d.createElement("div",{className:g()({"has-error":e.error&&"title"===e.error.fieldType&&e.error.index===r})},d.createElement("input",{type:"text",className:"form-control",placeholder:`e.g. ${s}`,value:t[r],onChange:t=>{let a;a=e.credential.titles?e.credential.titles.slice(0):[],a[r]=t.currentTarget.value,e.updatePropertyByKey("titles",a),e.clearError(r,"title")}})),d.createElement("div",{className:"row-heading emphasis"},"ID"),d.createElement("div",{className:g()({"has-error":e.error&&"slug"===e.error.fieldType&&e.error.index===r})},d.createElement("input",{type:"text",className:"form-control",placeholder:`e.g. ${n}`,value:a[r],onChange:t=>{let a;a=e.credential.slugs?e.credential.slugs.slice(0):[],a[r]=t.currentTarget.value,e.updatePropertyByKey("slugs",a),e.clearError(r,"slug")}})))))))}function yt(e){let t,a,s,n;if("adyen"===e.credential.processor){s="Adyen Account Name",n="Adyen API Key",t="Please enter your Adyen account name and API key";const i="live"===e.credential.mode?"https://ca-live.adyen.com/ca/ca/config/human_users_new.shtml":"https://ca-test.adyen.com/ca/ca/config/human_users_new.shtml",r="live"===e.credential.mode?"":"Test";a=d.createElement("div",{className:"instructions"},"In order to submit disputes automatically, you need to supply the API key for a ",r," ",d.createElement("a",{href:i,target:"_blank",rel:"noopener noreferrer"},"API credential")," ","with the Dispute Management role. You should create an API credential unique to Chargehound, following Adyen's instructions. You will need to contact Adyen to set up the"," "," Dispute Management role.")}else if("worldpay"===e.credential.processor)s="Merchant ID",n="Service Key",t="Please enter your Worldpay merchant ID and service key",a=d.createElement("span",{className:"instructions"},"You can find your Worldpay merchant ID and service key on the ",d.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:"https://online.worldpay.com/settings/keys"},"API keys tab")," of your settings page.");else if("checkout"===e.credential.processor)s="Channel name",n="API Key",t="Please enter your Checkout channel name and API key",a=d.createElement("span",{className:"instructions"},"You can find your Checkout channel name and API key on the ",d.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:`https://${"live"===e.credential.mode?"hub":"sandbox"}.checkout.com/settings/channels`},"Channels tab")," of your settings page.");else if("klarna"===e.credential.processor){s="Klarna Merchant ID",n="Klarna API Key",t="Please enter your Klarna merchant ID and API key";const i="live"===e.credential.mode?"Production":"Playground",r="https://docs.klarna.com/api/disputes-api/";a=d.createElement("div",{className:"instructions"},"Enter your Klarna ",i," merchant ID and API key. You can find these in your"," ",d.createElement("a",{href:r,target:"_blank",rel:"noopener noreferrer"},"Klarna Merchant Portal"),". The API key must have Disputes API access.")}else{if("dlocal"===e.credential.processor)return s="X-Login",n="X-Trans-Key",t="Please enter your dLocal credentials",a=d.createElement("div",{className:"instructions"},"You can find how to get your dLocal API credentials in the ",d.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:"https://docs.dlocal.com/docs/get-api-credentials"},"dLocal documentation"),"."),d.createElement("div",{className:"content"},d.createElement("div",{className:"clearfix"},d.createElement("div",{className:"prompt"},t),d.createElement("div",{className:"verify-credentials"},d.createElement("div",{className:"form-row clearfix"},d.createElement("input",{type:"text",name:"account",className:"form-control",placeholder:"X-Login",autoComplete:"off",value:e.credential.account,onChange:e.updateProperty}),d.createElement("input",{type:"text",name:"key",className:"form-control",placeholder:"X-Trans-Key",autoComplete:"off",value:e.credential.key,onChange:e.updateProperty}),d.createElement("input",{type:"password",name:"secretKey",className:"form-control",placeholder:"Secret Key",autoComplete:"off",value:e.credential.secretKey,onChange:e.updateProperty}),d.createElement("input",{type:"text",name:"xAccountId",className:"form-control",placeholder:"X-Account-Id (optional)",autoComplete:"off",maxLength:"255",value:e.credential.xAccountId||"",onChange:e.updateProperty}),d.createElement("p",{className:"help-block"},"Only include X-Account-Id if your dLocal contract requires it. Most merchants should leave this blank.")),a)));if("stripe"===e.credential.processor){s="Stripe account ID (e.g. acct_123)",
2n="Stripe restricted key (e.g. rk_123)",t="Please enter your Stripe account ID and and restricted API key";let i="/";"test"===e.credential.mode&&(i+="test/");const r=`https://dashboard.stripe.com${i}apikeys`;let l="/";"test"===e.credential.mode&&(l+="test/");const o=`https://dashboard.stripe.com${l}account`;a=d.createElement(d.Fragment,null,d.createElement("div",{className:"instructions"},"You can view your Stripe account ID in the Stripe dashboard ",d.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:o},"here"),". You can create and edit restricted API keys in the Stripe dashboard ",d.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:r},"here"),". The restricted API key needs the following permissions:",d.createElement(wt,null)))}}return d.createElement("div",{className:"content"},d.createElement("div",{className:"clearfix"},d.createElement("div",{className:"prompt"},t),d.createElement("div",{className:"verify-credentials"},d.createElement("div",{className:"form-row clearfix"},d.createElement("input",{type:"text",name:"account",className:"form-control",placeholder:s,value:e.credential.account,onChange:e.updateProperty}),d.createElement("input",{type:"text",name:"key",className:"form-control",placeholder:n,value:e.credential.key,onChange:e.updateProperty}),"klarna"===e.credential.processor&&d.createElement("select",{name:"region",className:"form-control",value:e.credential.region||"eu",onChange:e.updateProperty},d.createElement("option",{value:"eu"},"Europe (EU)"),d.createElement("option",{value:"na"},"North America (NA)"),d.createElement("option",{value:"oc"},"Oceania (OC)"))),a)))}ht.defaultProps={isReconnect:!1};class bt extends d.Component{constructor(e){super(e),We(this,"cancelEditingTitle",(()=>{this.setState({editingTitle:!1,title:null})})),We(this,"editTitle",(()=>{const e=this.props.credential.title||(0,S.A)(this.props.credential);this.setState({editingTitle:!0,title:e})})),We(this,"saveTitle",(()=>{this.setState({saving:!0});const e=(0,m.A)({config:this.props.config,name:"settingsAccountTitleJson",params:["title"]});(0,c.bE)(e,{hash:this.props.credential.hash,title:this.state.title,slug:this.props.credential.title}).then((e=>{this.setState({saving:!1}),e.success?(this.props.updateCredentials(this.props.credential.hash,{title:this.state.title}),this.setState({editingTitle:!1})):this.props.errorAlert(e.message||"An unexpected error occurred.")})).catch((e=>{this.setState({saving:!1}),this.props.errorAlert(e.json.error.message||"An unexpected error occurred.")}))})),We(this,"toggleExpanded",(()=>{this.state.expanded&&this.props.editing===this.props.credential&&this.props.finishEditingAccount(),this.setState({expanded:!this.state.expanded})})),We(this,"updateTitle",(e=>{this.setState({title:e.currentTarget.value})})),this.state={expanded:!!this.props.credential.revoked,editingTitle:!1,saving:!1,reconnectIsOpen:!1,connectData:null}}render(){const e=this.props.credential,t=(0,S.A)(e);let a,s;a="stripe"!==e.processor||"restricted"===e.secretKeyType?e.mode:"Live + Test",e.revoked||(s=this.state.expanded?d.createElement("span",null,"Hide ",d.createElement("i",{className:"fa fa-chevron-down toggler"})):d.createElement("span",null,"View ",d.createElement("i",{className:"fa fa-chevron-right toggler"}))),s=d.createElement("div",{className:"toggle",onClick:this.toggleExpanded},s),"worldpay_portal"===e.processor&&(s=null);const n=d.createElement("div",{className:g()({"mode-label":!0,live:"live"===e.mode,test:"test"===e.mode,inactive:e.revoked})},a);let i;e.revoked&&(i=d.createElement("div",{className:"mode-label disconnected"},"DISCONNECTED"));const r=d.createElement("div",{className:"account-slug"},d.createElement("strong",null,"ID:"),d.createElement("code",null,e.slug)),l=this.state.expanded&&!this.props.adding&&(!this.props.editing||this.props.editing===e);let o,c;return this.state.editingTitle&&(o=d.createElement(Nt,{title:this.state.title,saving:this.state.saving,originalTitle:e.title||(0,S.A)(e),editTitle:this.editTitle,updateTitle:this.updateTitle,saveTitle:this.saveTitle,cancelEditingTitle:this.cancelEditingTitle})),this.props.nestedVersion||(c=d.createElement(rt,{credential:e})),d.createElement("div",{className:g()({"account-item":!0,"account-credential":!0,nested:this.props.nestedVersion})},o,d.createElement("div",{className:"clearfix account-summary"},d.createElement("div",{className:"pull-left"},d.createElement("div",{className:"account-name"},e.title||t,d.createElement("a",{onClick:this.editTitle,className:"edit-link"},"edit"),r),c),d.createElement("div",{className:"pull-right"},n,i,s)),l&&d.createElement("div",{className:"account-details"},d.createElement(St,this.props)))}}function Nt(e){let t="btn btn-primary pull-right",a="Save";return e.saving&&(t+=" disabled",a=d.createElement("span",null,d.createElement("i",{className:"fa fa-spinner fa-pulse"}),"   Saving")),d.createElement(T(),{isOpen:!0,shouldCloseOnOverlayClick:!1,onRequestClose:e.cancelEditingTitle,className:"dialog-modal-content",overlayClassName:"dialog-modal-overlay",contentLabel:"Account Modal"},d.createElement("div",{className:"account-modal editing-title-modal"},d.createElement("button",{onClick:e.cancelEditingTitle,type:"button",className:"modal close","data-dismiss":"modal","aria-label":"Close"},d.createElement("span",{"aria-hidden":"true"},"×")),d.createElement("div",null,d.createElement("div",{className:"prompt"},"Pick a new display name for this account"),d.createElement("div",{className:"content-section"},d.createElement("input",{type:"text",value:e.title,onChange:e.updateTitle,placeholder:"e.g. "+e.originalTitle,className:"form-control"})),d.createElement("div",{className:"account-edit-footer"},d.createElement("div",{onClick:e.saving?null:e.saveTitle,className:t},a)))))}bt.defaultProps={nestedVersion:!1};class At extends d.Component{constructor(e){super(e),We(this,"reconnect",(()=>{this.setState({validating:!0});const e=(0,m.A)({config:this.props.config,name:"settingsAccountReconnectJson"});(0,c.bE)(e,{slug:this.props.credential.slug,title:this.props.credential.title,processor:this.props.credential.processor,mode:this.props.credential.mode}).then((e=>{this.setState({validating:!1}),this.setState({isOpen:!0,connectData:e})})).catch((e=>{this.setState({validating:!1}),this.props.errorAlert(e.json.error.message||"An unexpected error occurred.")}))})),We(this,"cancel",(()=>{this.setState({isOpen:!1})})),this.state={isOpen:!1,connectData:null}}render(){return d.createElement("div",null,d.createElement("div",{className:"account-details-section"},d.createElement("div",null,d.createElement("div",{className:"title"},"Reconnect your Braintree account"),d.createElement("span",{className:"status incomplete fa-stack fa-lg"},d.createElement("i",{className:"fa fa-circle fa-stack-2x"}),d.createElement("i",{className:"fa fa-ellipsis-h fa-stack-1x fa-inverse"})),d.createElement("div",{className:"instructions"},"Braintree has added a new Disputes API. This means that Chargehound can submit disputes on your behalf without the need to set up website credentials."),d.createElement("div",{className:"instructions"},"However, you'll need to authorize Chargehound to use the new API by reconnecting your account."),d.createElement("div",{className:"actions"},d.createElement("button",{className:"btn btn-default",onClick:this.reconnect},"Reconnect")))),d.createElement(T(),{isOpen:this.state.isOpen,shouldCloseOnOverlayClick:!1,onRequestClose:this.cancel,contentLabel:"Reconnect Modal",className:"dialog-modal-content",overlayClassName:"dialog-modal-overlay"},d.createElement("div",{className:"account-modal"},d.createElement("button",{onClick:this.cancel,type:"button",className:"close","data-dismiss":"modal","aria-label":"Close"},d.createElement("span",{"aria-hidden":"true"},"×")),d.createElement("div",{className:"content-section"},d.createElement(ht,Je({},this.props,{isReconnect:!0,connectData:this.state.connectData}))))))}}function wt(){return d.createElement("ul",{className:"rk-permissions"},d.createElement("li",null,"Disputes (read and write)"),d.createElement("li",null,"Files (read and write)"),d.createElement("li",null,"Charges (read)"),d.createElement("li",null,"Customers (read)"),d.createElement("li",null,"Events (read)"),d.createElement("li",null,"Coupons (read)"),d.createElement("li",null,"Credit notes (read)"),d.createElement("li",null,"Invoices (read)"),d.createElement("li",null,"Sources (read)"),d.createElement("li",null,"Products (read)"),d.createElement("li",null,"SKUs (read)"),d.createElement("li",null,"Plans (read)"),d.createElement("li",null,"Subscriptions (read)"))}class kt extends d.Component{constructor(e){super(e),We(this,"editKey",(()=>{this.state.editing?this.props.finishEditingAccount():this.props.editAccount(this.props.credential),this.setState({editing:!this.state.editing})})),We(this,"saveKey",(()=>{const e=(0,m.A)({config:this.props.config,name:"settingsApiKeyVerifyJson"});this.props.setSaving(!0),(0,c.bE)(e,{hash:this.props.credential.hash,key:this.state.rk}).then((()=>{this.setState({rk:"",editing:!1}),this.props.setSaving(!1),this.props.successAlert(`Restricted key was updated for ${Xe(this.props.credential)}.`),this.props.finishEditingAccount()}
2)).catch((e=>{this.props.setSaving(!1),this.props.errorAlert(e.json.error.message)}))})),We(this,"updateKey",(e=>{this.setState({rk:e.currentTarget.value})})),this.state={rk:"",editing:!1}}render(){let e,t,a;if(this.props.credential.webhookReceived)t=d.createElement("span",{className:"status complete fa-stack fa-lg"},d.createElement("i",{className:"fa fa-circle fa-stack-2x"}),d.createElement("i",{className:"fa fa-check fa-stack-1x fa-inverse"}));else{let a="/";"test"===this.props.credential.mode&&(a+="test/");const s=`https://dashboard.stripe.com${a}webhooks`;e=d.createElement("div",{className:"instructions"},"You'll need to add an endpoint to your Stripe webhooks. You can add an endpoint in the Stripe dashboard ",d.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:s},"here"),". Select the ",d.createElement("code",null,"charge.dispute.created"),", ",d.createElement("code",null,"charge.dispute.updated"),", and ",d.createElement("code",null,"charge.dispute.closed")," events. This allows Chargehound to automatically sync disputes as they come in. Use the following URL as the endpoint URL:"),t=d.createElement("span",{className:"status incomplete fa-stack fa-lg"},d.createElement("i",{className:"fa fa-circle fa-stack-2x"}),d.createElement("i",{className:"fa fa-ellipsis-h fa-stack-1x fa-inverse"}))}if(this.state.editing){let e="/";"test"===this.props.credential.mode&&(e+="test/");const t=`https://dashboard.stripe.com${e}apikeys`;a=d.createElement("div",{className:"account-details-section"},d.createElement("span",{className:"status incomplete fa-stack fa-lg"},d.createElement("i",{className:"fa fa-circle fa-stack-2x"}),d.createElement("i",{className:"fa fa-ellipsis-h fa-stack-1x fa-inverse"})),d.createElement("div",{className:"title"},"Update your restricted API key"),d.createElement("div",{className:"instructions"},"You can create and edit restricted API keys in the Stripe dashboard ",d.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:t},"here"),". The restricted API key needs the following permissions:",d.createElement(wt,null)),d.createElement("div",null,d.createElement("div",{className:"form-group"},d.createElement("input",{className:"form-control",onChange:this.updateKey,value:this.state.rk,autoComplete:"off",type:"text",placeholder:"Stripe restricted key (e.g. rk_123)"})),d.createElement("div",{className:"actions"},d.createElement("div",{onClick:this.editKey,className:"btn btn-default"},"Cancel"),d.createElement("div",{onClick:this.saveKey,className:"btn btn-primary"},"Update"))))}else a=d.createElement("div",{className:"account-details-section"},d.createElement("span",{className:"status complete fa-stack fa-lg"},d.createElement("i",{className:"fa fa-circle fa-stack-2x"}),d.createElement("i",{className:"fa fa-check fa-stack-1x fa-inverse"})),d.createElement("div",{className:"title"},"API key supplied"),d.createElement("div",{className:"instructions"},"Your Stripe account has been successfully connected."),d.createElement("div",{className:"actions top-right"},d.createElement("div",{onClick:this.editKey,className:"btn btn-default"},"Edit")));return d.createElement(d.Fragment,null,d.createElement("div",{className:"account-details-section account-id"},d.createElement("span",{className:g()({"status fa-stack fa-lg":!0,complete:!0})},d.createElement("i",{className:"fa fa-circle fa-stack-2x"}),d.createElement("i",{className:g()({"fa fa-stack-1x fa-inverse":!0,"fa-check":!0})})),d.createElement("div",{className:"title"},"Stripe Account ID: ",d.createElement("code",null,this.props.credential.account))),d.createElement("hr",null),a,d.createElement("hr",null),d.createElement("div",{className:"account-details-section"},t,d.createElement("div",{className:"title"},"Set up webhooks to automatically fight chargebacks"),e,d.createElement("div",{className:"instructions"},d.createElement("code",null,this.props.settings.apiHost,"/webhooks/stripe-connect/",this.props.settings.organization.hash,"default"!==this.props.credential.slug&&`/${this.props.credential.slug}`))))}}function St(e){if("braintree"===e.credential.processor){let t,a,s,n;return e.credential.revoked||("live"===e.credential.mode&&(t=d.createElement(jt,e)),-1===e.credential.scopes.indexOf("read_only")&&-1===e.credential.scopes.indexOf("manage_disputes")&&(a=d.createElement(At,e),s=d.createElement(Ct,e)),-1===e.credential.scopes.indexOf("oauth_app_receive_dispute_webhooks")&&(n=d.createElement(It,e))),d.createElement("div",null,d.createElement(Mt,e),a?d.createElement("hr",null):null,a,s?d.createElement("hr",null):null,s,n?d.createElement("hr",null):null,n,t?d.createElement("hr",null):null,t)}if("paypal"===e.credential.processor)return d.createElement("div",null,d.createElement(Mt,e));if("adyen"===e.credential.processor)return d.createElement("div",null,d.createElement(Rt,e),d.createElement("hr",null),d.createElement(It,e));if("stripe"===e.credential.processor){let t,a,s;return e.credential.revoked||e.settings.organization.stripePlatformSettings&&(t=d.createElement(xt,e)),"restricted"===e.credential.secretKeyType&&(a=d.createElement(kt,e)),"restricted"!==e.credential.secretKeyType&&(s=d.createElement(Mt,e)),d.createElement("div",null,s,t?d.createElement("hr",null):null,t,a)}return"vantiv"===e.credential.processor?d.createElement("div",null,d.createElement(Dt,e)):"amex"===e.credential.processor?d.createElement("div",null,d.createElement(Tt,e)):"chase"===e.credential.processor?d.createElement("div",null,d.createElement(Lt,e)):"visa"===e.credential.processor&&He(e)?d.createElement("div",null,d.createElement(Ke,e)):"mastercard"===e.credential.processor?d.createElement("div",null,d.createElement(Ve,e)):"worldpay"===e.credential.processor||"checkout"===e.credential.processor?d.createElement("div",null,d.createElement(Rt,e),d.createElement("hr",null),d.createElement(It,e)):"klarna"===e.credential.processor?d.createElement("div",null,d.createElement(Mt,e),d.createElement("hr",null),d.createElement(Pt,e),d.createElement("hr",null),d.createElement(It,e)):"dlocal"===e.credential.processor?d.createElement("div",null,d.createElement(It,e)):(e.credential.processor,null)}class Ct extends d.Component{constructor(e){super(e),We(this,"cancelEditing",(()=>{this.props.finishEditingAccount(),this.setState({editing:!1,account:this.props.credential.account,username:this.props.credential.username,password:this.props.credential.password})}
2)),We(this,"editCredentials",(()=>{this.setState({editing:!0,password:""}),this.props.editAccount(this.props.credential)})),We(this,"updateAccount",(e=>{this.state.editing&&this.setState({account:e.currentTarget.value})})),We(this,"updatePassword",(e=>{this.state.editing&&this.setState({password:e.currentTarget.value})})),We(this,"updateUsername",(e=>{this.state.editing&&this.setState({username:e.currentTarget.value})})),We(this,"verifyAdyenCredentials",(()=>{const e=(0,m.A)({config:this.props.config,name:"settingsAdyenConnectVerifyJson"});(0,c.bE)(e,{hash:this.props.credential.hash,account:this.state.account,username:this.state.username,password:this.state.password}).then((e=>{e.success?(this.props.finishEditingAccount(),this.props.updateCredentials(this.props.credential.hash,{hasBot:!0,account:this.state.account,username:this.state.username}),this.setState({editing:!1,verifying:!1})):this.setState({error:e.message||"Unable to verify credentials.",verifying:!1})})).catch((e=>{this.setState({error:e.json.error.message||"Unable to verify credentials.",verifying:!1})}))})),We(this,"verifyBraintreeCredentials",(()=>{const e=(0,m.A)({config:this.props.config,name:"organizationSettingsJson",params:["braintree_bot"]});(0,c.bE)(e,{hash:this.props.credential.hash,merchant_id:this.state.account,"braintree-bot-login":this.state.username,"braintree-bot-pw":this.state.password}).then((()=>{(0,c.Ay)(e).then((e=>{e.success?(this.props.finishEditingAccount(),this.props.updateCredentials(this.props.credential.hash,{hasBot:!0,username:this.state.username,password:this.state.password}),this.setState({editing:!1,verifying:!1})):this.setState({error:e.message||"Unable to verify credentials.",verifying:!1})}))})).catch((e=>{this.setState({error:e.json.error.message||"Unable to verify credentials.",verifying:!1})}))})),We(this,"verifyCredentials",(()=>{this.setState({verifying:!0}),"braintree"===this.props.credential.processor&&this.verifyBraintreeCredentials(),"adyen"===this.props.credential.processor&&this.verifyAdyenCredentials()})),this.state={editing:!e.credential.hasBot,verifying:!1,account:e.credential.account||"",username:e.credential.username||"",password:e.credential.password||""}}render(){let e,t;const a={};let s;this.state.editing&&!this.state.verifying||(a.disabled=!0);const n=this.props.credential,i=S.y[n.processor];let r="You are all set up to submit disputes.";if("braintree"===n.processor&&(e=d.createElement("div",{className:"input-group edit"},d.createElement("div",{className:"clearfix"},d.createElement("div",{className:"line-item"},"Username"),d.createElement("input",Je({className:"form-control",onChange:this.updateUsername,type:"text"},a,{autoComplete:"false",value:this.state.username,placeholder:"Username"}))),d.createElement("div",{className:"clearfix"},d.createElement("div",{className:"line-item"},"Password"),d.createElement("input",Je({className:"form-control",onChange:this.updatePassword,type:"password"},a,{autoComplete:"new-password",value:this.state.password,placeholder:"Password"})))),s="live"===n.mode?"":"Sandbox",t=d.createElement("div",{className:"instructions"},"In order to submit disputes, you need to supply login details for a Braintree ",s," user with Dispute Management permissions.")),"adyen"===n.processor){e=d.createElement("div",{className:"input-group edit"},d.createElement("div",{className:"clearfix"},d.createElement("div",{className:"line-item"},"Account"),d.createElement("input",Je({className:"form-control",onChange:this.updateAccount,type:"text"},a,{autoComplete:"false",value:this.state.account,placeholder:"Account"}))),d.createElement("div",{className:"clearfix"},d.createElement("div",{className:"line-item"},"Username"),d.createElement("input",Je({className:"form-control",onChange:this.updateUsername,type:"text"},a,{autoComplete:"false",value:this.state.username,placeholder:"Username"}))),d.createElement("div",{className:"clearfix"},d.createElement("div",{className:"line-item"},"Password"),d.createElement("input",Je({className:"form-control",onChange:this.updatePassword,type:"password"},a,{autoComplete:"new-password",value:this.state.password,placeholder:"Password"}))));const i="live"===n.mode?"https://ca-live.adyen.com/ca/ca/config/human_users_new.shtml":"https://ca-test.adyen.com/ca/ca/config/human_users_new.shtml";s="live"===n.mode?"":"Test",r="You are all set up to sync disputes to Chargehound from Adyen.",t=d.createElement("div",{className:"instructions"},"In order to sync disputes automatically to Chargehound from Adyen, you need to supply login details for an Adye
2n ",s," user with the Merchant Dispute Management role in the"," ",d.createElement("a",{href:i,target:"_blank",rel:"noopener noreferrer"},"Adyen Customer Area"),".")}const l=this.state.verifying?d.createElement("div",{className:"btn btn-primary disabled"},d.createElement("i",{className:"fa fa-spinner fa-pulse"})," Verify"):d.createElement("div",{onClick:this.verifyCredentials,className:"btn btn-primary"},"Verify");if(this.state.editing){const a=this.state.error?d.createElement("div",{className:"error"},this.state.error):null,r=n.hasBot?d.createElement("div",{onClick:this.cancelEditing,className:this.state.verifying?"btn btn-default disabled":"btn btn-default"},"Cancel"):null;return d.createElement("div",{className:"account-details-section"},d.createElement("span",{className:"status incomplete fa-stack fa-lg"},d.createElement("i",{className:"fa fa-circle fa-stack-2x"}),d.createElement("i",{className:"fa fa-pencil fa-stack-1x fa-inverse"})),d.createElement("div",{className:"title"},"Edit credentials for your ",i," ",s," website user"),t,e,d.createElement("div",{className:"actions"},a,r,l))}return n.hasBot?d.createElement("div",{className:"account-details-section"},d.createElement("span",{className:"status complete fa-stack fa-lg"},d.createElement("i",{className:"fa fa-circle fa-stack-2x"}),d.createElement("i",{className:"fa fa-check fa-stack-1x fa-inverse"})),d.createElement("div",{className:"title"},"Website credentials have successfully been supplied"),d.createElement("div",{className:"instructions"},r),d.createElement("div",{className:"actions top-right"},d.createElement("div",{onClick:this.editCredentials,className:"btn btn-default"},"Edit"))):d.createElement("div",{className:"account-details-section"},d.createElement("span",{className:"status incomplete fa-stack fa-lg"},d.createElement("i",{className:"fa fa-circle fa-stack-2x"}),d.createElement("i",{className:"fa fa-pencil fa-stack-1x fa-inverse"})),d.createElement("div",{className:"title"},"Please enter credentials for a ",i," ",s," website user"),t,e,d.createElement("div",{className:"actions"},l))}}class It extends d.Component{constructor(e){super(e)}render(){const e=this.props.credential;let t,a,s,n,i,r,l,o;const c=e.processor;let m=`${this.props.settings.apiHost}/webhooks/${c}`;"live"===e.mode?m+=`/live/${this.props.settings.accounts.live.hash}`:m+=`/test/${this.props.settings.accounts.test.hash}`,"default"!==e.slug&&(m+=`/${e.slug}`),i=e.webhookReceived?d.createElement("span",{className:"status complete fa-stack fa-lg"},d.createElement("i",{className:"fa fa-circle fa-stack-2x"}),d.createElement("i",{className:"fa fa-check fa-stack-1x fa-inverse"})):d.createElement("span",{className:"status incomplete fa-stack fa-lg"},d.createElement("i",{className:"fa fa-circle fa-stack-2x"}),d.createElement("i",{className:"fa fa-ellipsis-h fa-stack-1x fa-inverse"})),"braintree"===e.processor?(t="https://developers.braintreepayments.com/guides/webhooks/create",a=`https://${"live"===e.mode?"www":"sandbox"}.braintreegateway.com/merchants/${e.account}/webhooks/new`,s=d.createElement("span",null,"Select notifications for the ",d.createElement("code",null,"Dispute Opened"),", ",d.createElement("code",null,"Won")," and ",d.createElement("code",null,"Lost")," events."),n="Braintree dashboard"):"worldpay"===e.processor?(t="https://developer.worldpay.com/jsonapi/docs/webhooks-settings",a="https://online.worldpay.com/settings/webhooks",n="Worldpay dashboard",m=`${this.props.settings.apiHost}/webhooks/${e.processor}`,s=d.createElement("span",null,"You can test the webhook by sending a Test Webhook with the Order Status Change Event"," ","set to ",d.createElement("code",null,"INFORMATION_REQUESTED"),".")):"checkout"===e.processor?(t="https://docs.checkout.com/reporting-and-insights/webhooks",a=`https://${"live"===e.mode?"hub":"sandbox"}.checkout.com/settings/channels`,n="Checkout dashboard",s=d.createElement("span",null,'Create the webhook for the "',e.account,'" channel. Select notifications for all dispute events (',d.createElement("code",null,"Dispute evidence required"),", ",d.createElement("code",null,"Dispute won"),", ",d.createElement("code",null,"Dispute lost"),", ",d.createElement("code",null,"Dispute resolved"),", ",d.createElement("code",null,"Dispute expired"),", ",d.createElement("code",null,"Dispute canceled"),").")):"adyen"===e.processor?(t="https://docs.adyen.com/development-resources/webhooks#set-up-notifications-in-your-customer-area",a=`https://ca-${"live"===e.mode?"live":"test"}.adyen.com`,n="Adyen dashboard",r=d.createElement("div",{className:"instructions"},"For the ",d.createElement("strong",null,"Communication Method"),', set "JSON". For ',d.createElement("strong",null,"Authentication"),', set "',this.props.settings.adyenWhAuth.user,'" as the username and "',this.props.settings.adyenWhAuth.pw,'" as the password. Once the webhook is created, contact Adyen to restrict notifications to dispute events.')):"klarna"===e.processor?(m=`${this.props.settings.apiH
2ost}/webhooks/klarna`,l=d.createElement("div",{className:"instructions"},"Please contact Klarna support to configure a webhook using the Chargehound callback URL below."),r=e.hasSecretKey?d.createElement("div",{className:"instructions"},"Configure Klarna with the webhook signing key saved above for this Merchant ID."):d.createElement("div",{className:"instructions"},"Add the webhook signing key above before enabling webhook delivery."),o=d.createElement("div",{className:"instructions"},"Request notifications for dispute state change events (",d.createElement("code",null,"payment.dispute.state-change.*"),").")):"dlocal"===e.processor&&(t="https://docs.dlocal.com/reference/webhooks",a="https://merchant.dlocal.com",n="dLocal dashboard",s=d.createElement("span",null,"Configure the webhook URL in your dLocal merchant settings to receive dispute notifications."));const p=S.y[e.processor];return d.createElement("div",{className:"account-details-section"},i,d.createElement("div",{className:"title"},"Set up webhooks to automatically fight chargebacks"),!l&&d.createElement("div",{className:"instructions"},"You need to create a"," ",t?d.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:t},"webhook"):"webhook"," ","in the ",p," system to notify Chargehound when new disputes are created."," ",s),!l&&a&&d.createElement("div",{className:"instructions"},"Configure your webhook in the ",d.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:a},n)," ","to call back to:"),l,d.createElement("div",{className:"instructions"},d.createElement("code",null,m)),r,o)}}class Pt extends d.Component{constructor(e){super(e),We(this,"startEditing",(()=>{this.setState({editing:!0,webhookSigningKey:""})})),We(this,"cancelEditing",(()=>{this.setState({editing:!1,webhookSigningKey:"",saving:!1})})),We(this,"updateWebhookSigningKey",(e=>{this.setState({webhookSigningKey:e.currentTarget.value})})),We(this,"saveWebhookSigningKey",(()=>{const e=this.state.webhookSigningKey.trim();if(!e)return void this.props.errorAlert("Please enter a webhook signing key.");this.setState({saving:!0});const t=(0,m.A)({config:this.props.config,name:"settingsKlarnaWebhookSigningKeyJson"});(0,c.bE)(t,{hash:this.props.credential.hash,webhookSigningKey:e}).then((e=>{e.success?(this.props.updateCredentials(this.props.credential.hash,{hasSecretKey:!0}),this.setState({editing:!1,saving:!1,webhookSigningKey:""}),this.props.successAlert("Klarna webhook signing key saved.")):(this.props.errorAlert(e.message||"Unable to save Klarna webhook signing key."),this.setState({saving:!1}))})).catch((e=>{const t=e.json?.error?.message||e.json?.message||"Unable to save Klarna webhook signing key.";this.props.errorAlert(t),this.setState({saving:!1})}))})),this.state={editing:!e.credential.hasSecretKey,saving:!1,webhookSigningKey:""}}render(){const e=this.props.credential.hasSecretKey;let t,a;return this.state.editing?(a=d.createElement("input",{className:"form-control",type:"password",autoComplete:"off",onChange:this.updateWebhookSigningKey,value:this.state.webhookSigningKey,placeholder:"Webhook Signing Key"}),t=d.createElement("div",{className:"actions"},d.createElement("button",{onClick:this.cancelEditing,className:"btn btn-secondary",disabled:this.state.saving},"Cancel")," ",d.createElement("button",{onClick:this.saveWebhookSigningKey,className:"btn btn-primary",disabled:!this.state.webhookSigningKey.trim()||this.state.saving},this.state.saving?d.createElement("span",null,d.createElement("i",{className:"fa fa-spinner fa-pulse"})," Saving"):"Save"))):t=d.createElement("div",{className:"actions"},d.createElement("button",{onClick:this.startEditing,className:"btn btn-secondary"},e?"Update":"Add"," webhook signing key")),d.createElement("div",{className:"account-details-section"},d.createElement("span",{className:g()({"fa-stack status fa-lg":!0,complete:e,incomplete:!e})},d.createElement("i",{className:"fa fa-circle fa-stack-2x"}),d.createElement("i",{className:g()({"fa fa-stack-1x fa-inverse":!0,"fa-check":e,"fa-times":!e})})),d.createElement("div",{className:"title"},"Configure Webhook Signing Key"),d.createElement("div",{className:"instructions"},"Save the webhook signing key Klarna provides for this Merchant ID. Chargehound uses it to authenticate Klarna webhook payloads."),d.createElement("div",{className:"section"},a,t))}}class xt extends d.Component{constructor(e){super(e),We(this,"editKeys",(()=>{this.state.editing?this.props.finishEditingAccount():this.props.editAccount(this.props.credential),this.setState({editing:!this.state.editing})})),We(this,"saveKeys",(()=>{const e=(0,m.A)({config:this.props.config,name:"organizationSettingsJson",params:["stripe-secret-keys"]});this.props.setSaving(!0),(0,c.bE)(e,{"test-stripe-secret-key":this.state.testStripeSecret,"live-stripe-secret-key":this.state.liveStripeSecret,merchant_id:this.props.credential.merchantId}).then((()=>{this.props.updateCredentials(this.props.credential.hash,{hasSecretKey:!0}),this.setState({testStripeSecret:"",liveStripeSecret:"",showStripePlatformKeys:!1}),this.props.setSaving(!1),this.props.successAlert(`Keys were updated for ${Xe(this.props.credential)}.`),this.props.finishEditingAccount()}
2)).catch((e=>{this.props.setSaving(!1),this.props.errorAlert(e.json.error.message)}))})),We(this,"updateLiveSecret",(e=>{this.setState({liveStripeSecret:e.currentTarget.value})})),We(this,"updateTestSecret",(e=>{this.setState({testStripeSecret:e.currentTarget.value})})),this.state={testStripeSecret:"",liveStripeSecret:"",editing:!e.credential.hasSecretKey}}render(){let e,t,a;return this.props.settings.organization.stripeAccountWebhook?(e=d.createElement("div",{className:"instructions"},"You'll need to add the following URL to your Stripe Connect webhooks. Select the ",d.createElement("code",null,"charge.dispute.created"),", ",d.createElement("code",null,"charge.dispute.updated"),", and ",d.createElement("code",null,"charge.dispute.closed")," events. This allows Chargehound to automatically sync disputes as they come in."),t=d.createElement("span",{className:"status complete fa-stack fa-lg"},d.createElement("i",{className:"fa fa-circle fa-stack-2x"}),d.createElement("i",{className:"fa fa-check fa-stack-1x fa-inverse"}))):t=d.createElement("span",{className:"status incomplete fa-stack fa-lg"},d.createElement("i",{className:"fa fa-circle fa-stack-2x"}),d.createElement("i",{className:"fa fa-ellipsis-h fa-stack-1x fa-inverse"})),a=this.state.editing?d.createElement("div",{className:"account-details-section"},d.createElement("span",{className:"status incomplete fa-stack fa-lg"},d.createElement("i",{className:"fa fa-circle fa-stack-2x"}),d.createElement("i",{className:"fa fa-ellipsis-h fa-stack-1x fa-inverse"})),d.createElement("div",{className:"title"},"Please ",this.props.credential.hasSecretKey?"update":"provide"," your Stripe API keys"),d.createElement("div",{className:"instructions"},"In order to work with managed or connected account integrations that charge directly, we require an API key. The API key will be encrypted and will never be revealed to the end user or to Chargehound personnel. Read more about ",d.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:"https://stripe.com/docs/connect/payments-fees#charging-directly"},"charging directly"),"."),d.createElement("div",{className:"instructions"},"The API keys are available in the Stripe dashboard ",d.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:"https://dashboard.stripe.com/account/apikeys"},"here"),"."),d.createElement("div",null,d.createElement("div",{className:"input-group"},d.createElement("div",{className:"line-item"},d.createElement("div",{className:"line-item"},"Test"),d.createElement("input",{type:"text",onChange:this.updateTestSecret,value:this.state.testStripeSecret,autoComplete:"off",placeholder:"Test API key"})),d.createElement("div",{className:"line-item"},d.createElement("div",{className:"line-item"},"Live"),d.createElement("input",{type:"text",onChange:this.updateLiveSecret,value:this.state.liveStripeSecret,autoComplete:"off",placeholder:"Live API key"}))),d.createElement("div",{className:"actions"},d.createElement("div",{onClick:this.editKeys,className:"btn btn-default"},"Cancel"),d.createElement("div",{onClick:this.saveKeys,className:"btn btn-primary"},this.props.credential.hasSecretKey?"Update":"Save")))):d.createElement("div",{className:"account-details-section"},d.createElement("span",{className:"status complete fa-stack fa-lg"},d.createElement("i",{className:"fa fa-circle fa-stack-2x"}),d.createElement("i",{className:"fa fa-check fa-stack-1x fa-inverse"})),d.createElement("div",{className:"title"},"API keys supplied"),d.createElement("div",{className:"instructions"},"Your Stripe account has been successfully connected."),d.createElement("div",{className:"actions top-right"},d.createElement("div",{onClick:this.editKeys,className:"btn btn-default"},"Edit"))),d.createElement("div",null,a,d.createElement("hr",null),d.createElement("div",{className:"account-details-section"},t,d.createElement("div",{className:"title"},"Set up webhooks to automatically fight chargebacks"),e,d.createElement("div",{className:"instructions"},"The webhooks can be configured in the Stripe dashboard"," ",d.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:"https://dashboard.stripe.com/account/webhooks"},"here"),"."),d.createElement("div",{className:"instructions"}
2,d.createElement("code",null,this.props.settings.apiHost,"/webhooks/stripe-connect/",this.props.settings.organization.hash,"default"!==this.props.credential.slug&&`/${this.props.credential.slug}`))))}}class Dt extends d.Component{constructor(e){super(e),We(this,"deleteAlias",(()=>{const e=(0,m.A)({config:this.props.config,name:"settingsVantivMerchantIdAlias"});this.setState({newAlias:""}),(0,c.yH)(e,{hash:this.props.credential.hash,alias:this.state.newAlias}).then((()=>{this.props.updateCredentials(this.props.credential.hash,{alias:null}),this.props.successAlert("Merchant ID alias removed.")})).catch((e=>{this.props.errorAlert(e.json.error.message||"Unable to remove Merchant ID alias.")}))})),We(this,"beginAddingAlias",(()=>{this.setState({addingAlias:!0,savingAlias:!1})})),We(this,"cancelAddingAlias",(()=>{this.setState({addingAlias:!1,newAlias:""})})),We(this,"updateAlias",(e=>{this.setState({newAlias:e.currentTarget.value})})),We(this,"saveAlias",(()=>{this.setState({savingAlias:!0});const e=(0,m.A)({config:this.props.config,name:"settingsVantivMerchantIdAlias"}),t=this.state.newAlias;(0,c.bE)(e,{hash:this.props.credential.hash,alias:this.state.newAlias}).then((()=>{this.setState({addingAlias:!1,savingAlias:!1,alias:""}),this.props.updateCredentials(this.props.credential.hash,{alias:t}),this.props.successAlert("Merchant ID alias added.")})).catch((e=>{this.props.errorAlert(e.json.error.message||"Unable to add Merchant ID alias."),this.setState({savingAlias:!1})}))})),this.state={addingAlias:!1,savingAlias:!1,newAlias:""}}render(){let e;e=this.props.credential.alias?d.createElement("span",{className:"alias"},"Alias: ",this.props.credential.alias,d.createElement("a",{className:"edit-alias",onClick:this.deleteAlias},"remove alias")):d.createElement("a",{className:"edit-alias",onClick:this.beginAddingAlias},"add an alias");const t=d.createElement(Ot,{alias:this.state.newAlias,adding:this.state.addingAlias,saving:this.state.savingAlias,cancelAddingAlias:this.cancelAddingAlias,updateAlias:this.updateAlias,saveAlias:this.saveAlias});return d.createElement("div",{className:"account-details-section"},d.createElement("span",{className:"status complete fa-stack fa-lg"},d.createElement("i",{className:"fa fa-circle fa-stack-2x"}),d.createElement("i",{className:"fa fa-check fa-stack-1x fa-inverse"})),d.createElement("div",{className:"title"},"Vantiv Merchant ID: ",d.createElement("code",null,this.props.credential.account)," ",e),d.createElement("div",{className:"instructions"},"Contact support if you need to change your merchant ID."),t)}}function Tt(e){return d.createElement("div",{className:"account-details-section"},d.createElement("span",{className:g()({"status fa-stack fa-lg":!0,complete:!e.credential.revoked,incomplete:e.credential.revoked})},d.createElement("i",{className:"fa fa-circle fa-stack-2x"}),d.createElement("i",{className:g()({"fa fa-stack-1x fa-inverse":!0,"fa-check":!e.credential.revoked,"fa-times":e.credential.revoked})})),d.createElement("div",{className:"title"},"American Express Service Establishment Number: ",d.createElement("code",null,e.credential.account)),d.createElement("div",{className:"instructions"},"Contact support if you need to change your Service Establishment Number."))}function Lt(e){return d.createElement("div",{className:"account-details-section"},d.createElement("span",{className:g()({"status fa-stack fa-lg":!0,complete:!e.credential.revoked,incomplete:e.credential.revoked})},d.createElement("i",{className:"fa fa-circle fa-stack-2x"}),d.createElement("i",{className:g()({"fa fa-stack-1x fa-inverse":!0,"fa-check":!e.credential.revoked,"fa-times":e.credential.revoked})})),d.createElement("div",{className:"title"},"Chase Merchant ID: ",d.createElement("code",null,e.credential.account)),d.createElement("div",{className:"instructions"},"Contact support if you need to change your Merchant ID."))}function Ot(e){let t="btn btn-primary pull-right",a="Save";return e.saving&&(t+=" disabled",a=d.createElement("span",null,d.createElement("i",{className:"fa fa-spinner fa-pulse"}),"   Saving")),d.createElement(T(),{isOpen:e.adding,shouldCloseOnOverlayClick:!1,onRequestClose:e.cancelAddingAlias,className:"dialog-modal-content",overlayClassName:"dialog-modal-overlay",contentLabel:"Account Modal"},d.createElement("div",{className:"account-modal editing-title-modal"}
2,d.createElement("button",{onClick:e.cancelAddingAlias,type:"button",className:"modal close","data-dismiss":"modal","aria-label":"Close"},d.createElement("span",{"aria-hidden":"true"},"×")),d.createElement("div",null,d.createElement("div",{className:"prompt"},"Please add an alias for this Merchant ID"),d.createElement("div",{className:"content content-section"},d.createElement("input",{type:"text",value:e.alias,onChange:e.updateAlias,placeholder:"e.g. 123456",className:"form-control"}),d.createElement("div",{className:"description"},"Add an alias if you have old-style Vantiv Merchant ID, which will be a 6-digit number.")),d.createElement("div",{className:"account-edit-footer"},d.createElement("div",{onClick:e.saving?null:e.saveAlias,className:t},a)))))}class Rt extends d.Component{constructor(e){super(e),We(this,"startUpdate",(()=>{this.setState({updating:!0,newKey:""})})),We(this,"cancelUpdate",(()=>{this.setState({updating:!1,newKey:""})})),We(this,"updateKey",(e=>{this.setState({newKey:e.currentTarget.value})})),We(this,"saveUpdate",(()=>{this.setState({saving:!0});const e=(0,m.A)({config:this.props.config,name:"settingsApiKeyVerifyJson"});(0,c.bE)(e,{hash:this.props.credential.hash,key:this.state.newKey}).then((e=>{if(this.setState({saving:!1,updating:!1,newKey:""}),"worldpay"===this.props.credential.processor)this.props.successAlert("Worldpay API key updated.");else if("checkout"===this.props.credential.processor)this.props.successAlert("Checkout API key updated.");else if("adyen"===this.props.credential.processor){const t=e.account;this.props.updateCredentials(this.props.credential.hash,{hasSecretKey:t.hasSecretKey,hasApiLogin:t.hasApiLogin}),this.props.successAlert("Adyen API key updated.")}})).catch((e=>{this.props.errorAlert(e.json.error.message||"Unable to verify API key."),this.setState({saving:!1})}))})),this.state={updating:!1,saving:!1,newKey:""}}render(){let e,t,a,s,n,i,r=!0,l=!0;if("worldpay"===this.props.credential.processor)s="Worldpay API key",n="Worldpay Merchant ID";else if("checkout"===this.props.credential.processor)s="Checkout API key",n="Checkout channel";else if("adyen"===this.props.credential.processor){s="Adyen API key",n="Adyen webservice API key",r=!1,l=this.props.credential.hasSecretKey;const e="https://docs.adyen.com/development-resources/api-credentials#new-credential",t="live"===this.props.credential.mode?"Live":"Test";l?a=d.createElement("div",{className:"instructions"},"Webservice credentials have successfully been supplied. You are all set up to submit disputes."):this.props.credential.hasApiLogin?(l=!0,a=d.createElement("div",{className:"instructions"},"You supplied a webservice user with basic authentication details. If you want to update your credentials, you only need to supply the API key.")):a=d.createElement("div",{className:"instructions"},"In order to submit disputes automatically, you need to supply the API key for a ",t," ",d.createElement("a",{href:e,target:"_blank",rel:"noopener noreferrer"},"API credential")," ","with the Dispute Management role. You should create an API credential unique to Chargehound, following Adyen's instructions. You will need to contact Adyen to set up the"," "," Dispute Management role.")}return this.state.updating?(e=this.state.saving?d.createElement("div",{className:"actions"},d.createElement("button",{className:"btn btn-secondary disabled"},"Cancel"),d.createElement("button",{className:"btn btn-primary disabled"},d.createElement("i",{className:"fa fa-spinner fa-pulse"})," Saving")):d.createElement("div",{className:"actions"},d.createElement("button",{onClick:this.cancelUpdate,className:"btn btn-secondary"},"Cancel"),d.createElement("button",{onClick:this.saveUpdate,className:"btn btn-primary"},"Save API key")),t=d.createElement("input",{className:"form-control",type:"text",onChange:this.updateKey,value:this.state.newKey,placeholder:s})):e=d.createElement("div",{className:"actions"},d.createElement("button",{onClick:this.startUpdate,className:"btn btn-secondary"},l?"Update":"Add"," API key")),r&&(i=d.createElement("span",null,": ",d.createElement("code",null,this.props.credential.account))),d.createElement("div",{className:"account-details-section"},d.createElement("span",{className:g()({"fa-stack status fa-lg":!0,complete:l,incomplete:!l})},d.createElement("i",{className:"fa fa-circle fa-stack-2x"}),d.createElement("i",{className:g()({"fa fa-stack-1x fa-inverse":!0,"fa-check":l,"fa-times":!l})})),d.createElement("div",{className:"title"},n,i),a,d.createElement("div",{className:"section"},t,e))}}class jt extends d.Component{constructor(e){super(e),We(this,"onRevoke",(()=>{const e=(0,m.A)({config:this.props.config,name:"organizationSettingsJson",params:["revoke-magento"]});(0,b.A)({message:"This will remove the integration from Chargehound. Are you sure?"}).then((()=>(this.props.setSaving(!0),(0,c.bE)(e,{hash:this.props.credential.hash})))).then((e=>{this.props.setSaving(!1),this.props.updateCredentials(this.props.credential.hash,{storeUrl:null,hasMagentoIntegration:!1}),this.props.successAlert(e.message)})).catch((e=>{this.props.setSaving(!1),this.props.errorAlert(e.message)}))})),We(this,"toggleSteps",(()=>{this.setState((e=>({showSteps:!e.showSteps})))}
2)),this.state={showSteps:!1}}render(){if(this.props.credential.hasMagentoIntegration)return d.createElement("div",{className:"account-details-section"},d.createElement("div",{className:"status magento-logo"},d.createElement("img",{src:"https://www.paypalobjects.com/chargehound/logos/magento-icon.svg"})),d.createElement("p",{className:"title"},"Magento account integrated"),d.createElement("div",{className:"instructions"},"You have activated a Magento integration for:"),d.createElement("div",{className:"instructions"},d.createElement("code",null,this.props.credential.storeUrl)),d.createElement("div",{className:"actions top-right"},d.createElement("button",{onClick:this.onRevoke,className:"btn btn-secondary"},"Revoke")));let e;return e=this.state.showSteps?d.createElement("div",null,d.createElement("div",{className:"instructions pad-bottom"},"To integrate Chargehound with your Magento store, log in to Magento as an admin and navigate to ",d.createElement("code",null,"System ",">"," Extensions ",">"," Integrations"),". Create a new integration with:"),d.createElement("div",{className:"line-item"},"Callback URL:"),d.createElement("div",{className:"instructions"},d.createElement("code",null,this.props.config.webHost,"/connect/magento/activate")),d.createElement("div",{className:"line-item"},"Identity link URL:"),d.createElement("div",{className:"instructions"},d.createElement("code",null,this.props.config.webHost,"/connect/magento/link","default"===this.props.credential?"":`/${this.props.credential.slug}`)),d.createElement("div",{className:"instructions pad-top"},"Be sure to add API resource access for ",d.createElement("code",null,"Sales Orders"),",",d.createElement("code",null,"Sales Shipments"),", ",d.createElement("code",null,"Customers")," and",d.createElement("code",null,"Products"),"."),d.createElement("div",{className:"instructions"},d.createElement("em",null,"(Note: Chargehound only works with Magento version 2 and above.)"))):d.createElement("div",null,d.createElement("div",{className:"instructions"},"Integrate Chargehound with your Magento store to simplify dispute processing.")),d.createElement("div",{className:"account-details-section"},d.createElement("div",{className:"status magento-logo"},d.createElement("img",{src:"https://www.paypalobjects.com/chargehound/logos/magento-icon.svg"})),d.createElement("p",{className:"title"},"Integrate with Magento"),e,d.createElement("div",{className:"actions top-right"},d.createElement("button",{onClick:this.toggleSteps,className:"btn btn-default"},this.state.showSteps?"Hide":"Show Me How")))}}class Mt extends d.Component{constructor(e){super(e),We(this,"openKlarnaReconnect",(()=>{this.setState({klarnaReconnect:!0})})),We(this,"cancelKlarnaReconnect",(()=>{this.setState({klarnaReconnect:!1,klarnaMerchantId:"",klarnaApiKey:"",klarnaRegion:"eu",klarnaSaving:!1})})),We(this,"submitKlarnaReconnect",(()=>{this.setState({klarnaSaving:!0});const e=(0,m.A)({config:this.props.config,name:"settingsKlarnaConnectVerifyJson"});(0,c.bE)(e,{title:this.props.credential.title,merchant_id:this.state.klarnaMerchantId,api_key:this.state.klarnaApiKey,region:this.state.klarnaRegion,mode:this.props.credential.mode}).then((e=>{e.success?(this.cancelKlarnaReconnect(),this.props.successAlert("Klarna account reconnected successfully!"),window.location.reload()):(this.props.errorAlert(e.message||"Unable to verify Klarna credentials."),this.setState({klarnaSaving:!1}))})).catch((e=>{const t=e?.json?.error?.message||"Unable to verify Klarna credentials.";this.props.errorAlert(t),this.setState({klarnaSaving:!1})}))})),We(this,"reconnect",(()=>{this.setState({validating:!0});const e=(0,m.A)({config:this.props.config,name:"settingsAccountReconnectJson"});(0,c.bE)(e,{slug:this.props.credential.slug,title:this.props.credential.title,processor:this.props.credential.processor,mode:this.props.credential.mode,scope:this.props.credential.scopes.join(",")}).then((e=>{this.setState({validating:!1}),this.setState({isOpen:!0,connectData:e})})).catch((e=>{this.setState({validating:!1}),this.props.errorAlert(e.json.error.message||"An unexpected error occurred.")}))})),We(this,"cancel",(()=>{this.setState({isOpen:!1})})),this.state={isOpen:!1,connectData:null,klarnaReconnect:!1,klarnaMerchantId:"",klarnaApiKey:"",klarnaRegion:"eu",klarnaSaving:!1}}render(){let e,t,a,s;if("stripe"===this.props.credential.processor?e=d.createElement("div",{className:"title"}
2,"Stripe Account ID: ",d.createElement("code",null,this.props.credential.account)):"braintree"===this.props.credential.processor?e=d.createElement("div",{className:"title"},"Braintree Merchant ID: ",d.createElement("code",null,this.props.credential.account)):"checkout"===this.props.credential.processor?e=d.createElement("div",{className:"title"},"Checkout Channel: ",d.createElement("code",null,this.props.credential.account)):"paypal"===this.props.credential.processor?this.props.credential.account.startsWith("https://")?(e=d.createElement("div",{className:"title"},"Paypal Account"),t=d.createElement("div",{className:"instructions"},"The Paypal merchant ID will be shown here once Chargehound syncs a dispute.")):e=d.createElement("div",{className:"title"},"Paypal Merchant ID: ",d.createElement("code",null,this.props.credential.account)):"klarna"===this.props.credential.processor&&(e=d.createElement("div",{className:"title"},"Klarna Merchant ID: ",d.createElement("code",null,this.props.credential.account))),this.props.credential.revoked)"klarna"===this.props.credential.processor?(a=d.createElement(d.Fragment,null,d.createElement("div",{className:"instructions"},"Your Klarna API credentials have been revoked. Chargehound can no longer sync disputes or submit evidence on your behalf."),d.createElement("div",{className:"instructions"},"You can re-enable Chargehound at any time by reconnecting with new API credentials."),d.createElement("div",{className:"actions"},d.createElement("button",{className:"btn btn-default",onClick:this.openKlarnaReconnect},"Reconnect"))),s=d.createElement(T(),{isOpen:this.state.klarnaReconnect,shouldCloseOnOverlayClick:!1,onRequestClose:this.cancelKlarnaReconnect,contentLabel:"Reconnect Klarna",className:"dialog-modal-content",overlayClassName:"dialog-modal-overlay"},d.createElement("div",{className:"account-modal"},d.createElement("button",{onClick:this.cancelKlarnaReconnect,type:"button",className:"close","data-dismiss":"modal","aria-label":"Close"},d.createElement("span",{"aria-hidden":"true"},"×")),d.createElement("div",{className:"content-section"},d.createElement("h4",null,"Reconnect Klarna"),d.createElement("div",{className:"form-group"},d.createElement("label",null,"Klarna Merchant ID"),d.createElement("input",{className:"form-control",type:"text",placeholder:"Klarna Merchant ID",value:this.state.klarnaMerchantId,onChange:e=>this.setState({klarnaMerchantId:e.target.value})})),d.createElement("div",{className:"form-group"},d.createElement("label",null,"Klarna API Key"),d.createElement("input",{className:"form-control",type:"password",placeholder:"Klarna API Key",value:this.state.klarnaApiKey,onChange:e=>this.setState({klarnaApiKey:e.target.value})})),d.createElement("div",{className:"form-group"},d.createElement("label",null,"Region"),d.createElement("select",{className:"form-control",value:this.state.klarnaRegion,onChange:e=>this.setState({klarnaRegion:e.target.value})},d.createElement("option",{value:"eu"},"Europe (EU)"),d.createElement("option",{value:"na"},"North America (NA)"),d.createElement("option",{value:"oc"},"Oceania (OC)"))),d.createElement("div",{className:"actions"},d.createElement("button",{className:"btn btn-secondary",onClick:this.cancelKlarnaReconnect},"Cancel")," ",d.createElement("button",{className:"btn btn-primary",disabled:!this.state.klarnaMerchantId||!this.state.klarnaApiKey||this.state.klarnaSaving,onClick:this.submitKlarnaReconnect},this.state.klarnaSaving?d.createElement("span",null,d.createElement("i",{className:"fa fa-spinner fa-pulse"})," Saving"):"Reconnect")))))):(a=d.createElement(d.Fragment,null,d.createElement("div",{className:"instructions"},"You've revoked access for this ",S.y[this.props.credential.processor]," account. Chargehound can no longer sync disputes or submit evidence on your behalf."),d.createElement("div",{className:"instructions"},"You can re-enable Chargehound at any time by reconnecting your ",S.y[this.props.credential.processor]," account."),d.createElement("div",{className:"actions"},d.createElement("button",{className:"btn btn-default",onClick:this.reconnect},"Reconnect"))),s=d.createElement(T(),{isOpen:this.state.isOpen,shouldCloseOnOverlayClick:!1,onRequestClose:this.cancel,contentLabel:"Reconnect Modal",className:"dialog-modal-content",overlayClassName:"dialog-modal-overlay"},d.createElement("div",{className:"account-modal"},d.createElement("button",{onClick:this.cancel,type:"button",className:"close","data-dismiss":"modal","aria-label":"Close"},d.createElement("span",{"aria-hidden":"true"},"×")),d.createElement("div",{className:"content-section"},d.createElement(ht,Je({},this.props,{isReconnect:!0,connectData:this.state.connectData}))))));else if("stripe"===this.props.credential.processor)a=d.createElement("div",{className:"instructions"}
2,"You can revoke Chargehound's access to your Stripe account at any time from the ",d.createElement("a",{href:"https://dashboard.stripe.com/account/applications",target:"_blank",rel:"noopener noreferrer"},"Connect")," section of your Stripe dashboard. If you do this, Chargehound will no longer be able to sync disputes or submit evidence on your behalf.");else if("braintree"===this.props.credential.processor){let e;e="live"===this.props.credential.mode?`https://www.braintreegateway.com/merchants/${this.props.credential.merchantId}/connected_oauth_applications`:`https://sandbox.braintreegateway.com/merchants/${this.props.credential.merchantId}/connected_oauth_applications`,a=d.createElement("div",{className:"instructions"},"You can revoke Chargehound's access to your Braintree account at any time from the ",d.createElement("a",{href:e,target:"_blank",rel:"noopener noreferrer"},"Oauth")," section of your Braintree dashboard. If you do this, Chargehound will no longer be able to sync disputes or submit evidence on your behalf.")}else if("paypal"===this.props.credential.processor){let e;e="live"===this.props.credential.mode?"https://www.paypal.com/businessprofile/mysettings/loginwithpaypal":"https://www.sandbox.paypal.com/businessprofile/mysettings/loginwithpaypal",a=d.createElement("div",{className:"instructions"},"You can revoke Chargehound's access to your PayPal account at any time from the ",d.createElement("a",{href:e,target:"_blank",rel:"noopener noreferrer"},"Log In with PayPal")," section of your PayPal dashboard. If you do this, Chargehound will no longer be able to sync disputes or submit evidence on your behalf.")}else"klarna"===this.props.credential.processor&&(a=d.createElement("div",{className:"instructions"},"You can revoke Chargehound's access to your Klarna account at any time by updating your API credentials in the ",d.createElement("a",{href:"https://portal.klarna.com",target:"_blank",rel:"noopener noreferrer"},"Klarna Merchant Portal"),". If you do this, Chargehound will no longer be able to sync disputes or submit evidence on your behalf."));return d.createElement("div",{className:"account-details-section account-id"},d.createElement("span",{className:g()({"status fa-stack fa-lg":!0,complete:!this.props.credential.revoked,incomplete:this.props.credential.revoked})},d.createElement("i",{className:"fa fa-circle fa-stack-2x"}),d.createElement("i",{className:g()({"fa fa-stack-1x fa-inverse":!0,"fa-check":!this.props.credential.revoked,"fa-times":this.props.credential.revoked})})),e,t,a,s)}}function Ut(e){let t,a=e.credential||null;a||1!==e.credentialOptions.length||(a=e.credentialAccounts.find((t=>t.slug===e.credentialOptions[0].value))),t=a&&a.linkedAmex||[];const[s,n]=(0,d.useState)(a?a.slug:null),[i,r]=(0,d.useState)(t);let l,o;l=a?d.createElement("div",{className:"selected-processor"},a.title||(0,S.A)(a)):d.createElement(q.Ay,{styles:V.A,placeholder:"Select Braintree account...",onChange:e=>n(e.value),options:e.credentialOptions,value:e.credentialOptions.filter((e=>{let{value:t}=e;return t===s}))}),o=e.credential?"Edit linked accounts":"Link accounts";const c=!i.length||!s;return d.createElement("div",null,d.createElement("h4",null,o),d.createElement("div",{className:"row-heading emphasis"},"Transaction processor"),l,d.createElement("div",{className:"explain"},"The account that processes the American Express transactions."),d.createElement("hr",null),d.createElement("div",{className:"row-heading emphasis"},"Linked American Express accounts"),d.createElement(q.Ay,{styles:V.A,placeholder:"Select American Express account...",onChange:e=>r(e.map((e=>e.value))),options:e.amexOptions,value:e.amexOptions.filter((e=>-1!==i.indexOf(e.value))),isMulti:!0}),d.createElement("div",{className:"explain"},"The American Express account or accounts that are linked to the above account."),d.createElement("div",{className:"actions clearfix"},d.createElement("button",{className:"btn btn-default",onClick:e.cancelEditing},"Cancel"),d.createElement("button",{disabled:c,className:"btn btn-primary btn-margin-left",onClick:()=>{e.linkAmexAccounts(e.credentialAccounts.find((e=>e.slug===s)),i),e.cancelEditing()}},"Save")))}function Kt(e){return d.createElement(T(),{isOpen:e.isOpen,shouldCloseOnOverlayClick:!1,onRequestClose:e.cancelEditing,contentLabel:"Account Link Modal",className:"dialog-modal-content account-link-modal",overlayClassName:"dialog-modal-overlay"},d.createElement("div",null,d.createElement("button",{onClick:e.cancelEditing,type:"button",className:"close","data-dismiss":"modal","aria-label":"Close"},d.createElement("span",{"aria-hidden":"true"},"×")),d.createElement("div",{className:"content-section"},d.createElement(Ut,Je({key:e.credential?e.credential.slug:1},e)))))}function _t(e){const[t,a]=(0,d.useState)({open:!1,credential:null});if(!e.settings.credentials.amex||!e.settings.credentials.braintree)return null;const s=e.settings.credentials.amex.filter((e=>"live"===e.mode));if(!s.length)return null;const n=e.settings.credentials.braintree.filter((e=>"live"===e.mode));if(!n.length)return null;const i=n.filter((e=>
2e.linkedAmex)),r=[],l={};s.forEach((e=>{r.push({label:`${e.title||(0,S.A)(e)} (${e.merchantId})`,value:e.slug}),l[e.slug]=e}));const o=n.filter((e=>!e.linkedAmex)).map((e=>({label:e.title||(0,S.A)(e),value:e.slug})));let c,m;return o.length&&(c=d.createElement("div",{className:"item-add text-right"},d.createElement("span",{className:"explainer"},"Add link"),d.createElement("div",{className:"btn btn-primary add-rule",onClick:()=>a({open:!0,credential:null})},d.createElement("span",{className:"fa fa-plus"})))),i.length&&(m=i.map((t=>d.createElement("div",{key:t.slug,className:"app-item"},d.createElement("div",{className:"clearfix"},d.createElement("span",{className:"status success"},d.createElement("i",{className:"fa fa-sm fa-link"})),d.createElement("span",null,t.title||(0,S.A)(t)),d.createElement("span",{className:"actions pull-right"},d.createElement("a",{onClick:()=>{a({open:!0,credential:t})},className:"edit"},"edit"),d.createElement("a",{onClick:()=>{(0,b.A)({title:"Unlink accounts",message:"This will unlink the accounts. Are you sure?"}).then((()=>{e.linkAmexAccounts(t,[])})).catch((()=>{}))},className:"edit"},"remove"))),d.createElement("div",{className:"clearfix links"},d.createElement("div",{className:"line-separator"}),d.createElement("div",{className:"linked"},d.createElement("span",{className:"status"},d.createElement("i",{className:"fa fa-sm fa-link"})),d.createElement("span",null,t.linkedAmex.map((e=>l[e].title)).join(", ")))))))),d.createElement("div",{id:"link-amex",ref:C.A,className:"app-block no-padding tight link-amex"},d.createElement("div",{className:"header"},d.createElement("h4",null,"Link American Express Accounts")),d.createElement("div",{className:"content"},"If you process American Express transactions through a Braintree account, you can link the American Express account or accounts. When the accounts are linked, Chargehound can automatically collect more data and make your API integration easier."),d.createElement("hr",null),m,c,d.createElement(Kt,{credential:t.credential,amexOptions:r,credentialOptions:o,credentialAccounts:n,linkAmexAccounts:e.linkAmexAccounts,isOpen:t.open,cancelEditing:()=>a({open:!1,credential:null})}))}var zt=a(43811),Ft=a(37487),$t=a(98835);function Bt(e,t,a){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var a=e[Symbol.toPrimitive];if(void 0!==a){var s=a.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class Vt extends d.Component{constructor(e){super(e),Bt(this,"onEmailSave",(()=>{const e=(0,m.A)({config:this.props.config,name:"organizationSettingsJson",params:["invite"]}),t=this.state.editedEmail;this.props.setSaving(!0),(0,c.bE)(e,{email:t,action:"send_invite"}).then((e=>{this.props.updateSettings(e),this.props.setSaving(!1),this.setState({editedEmail:""}),this.props.successAlert(`We sent an invite for ${t} to join ${this.props.settings.organization.name}.`)})).catch((e=>{this.props.setSaving(!1),this.props.errorAlert(e.json.error.message||`We could not send an invite for ${t} to join ${this.props.settings.organization.name}. Please try again.`)}))})),Bt(this,"updateEmail",(e=>{this.setState({editedEmail:e.currentTarget.value})})),Bt(this,"exportUsers",(()=>{if(this.state.exportUsers)return!1;this.setState({exportingUsers:!0}),this.props.exportUsers().then((()=>{this.setState({exportingUsers:!1})}))})),this.state={editedEmail:""}}onDeleteInvite(e){(0,b.A)({title:"Delete Invite",message:`Are you sure you want to revoke the invitation for ${e.email}?`}).then((()=>{const t=(0,m.A)({config:this.props.config,name:"organizationSettingsJson",params:["invite"]});return this.props.setSaving(!0),(0,c.bE)(t,{invite_id:e.id,action:"delete_invite"})})).then((t=>{this.props.updateSettings(t),this.props.setSaving(!1),this.props.successAlert(`We revoked the invite for ${e.email}.`)})).catch((e=>{e&&(this.props.setSaving(!1),this.props.errorAlert(e.json.error.message))}))}onDeleteUser(e){(0,b.A)({title:"Delete User",message:`Are you sure you want to delete ${e.fullName}'s account? Any pending invites they have sent will be deleted as well.`}).then((()=>{const t=(0,m.A)({config:this.props.config,name:"organizationSettingsJson",params:["user"]});return this.props.setSaving(!0),(0,c.bE)(t,{user_id:e.hash,action:"delete"})})).then((t=>{this.props.updateSettings(t),this.props.setSaving(!1),this.props.successAlert(`${e.fullName} was successfully deleted.`)})).catch((e=>{e&&(this.props.setSaving(!1),this.props.errorAlert(e.json.error.message))}))}onMakeUserAdmin(e){(0,b.A)({title:"Create Admin",message:`Are you sure you want to make ${e.fullName} an admin?`}).then((()=>{const t=(0,m.A)({config:this.props.config,name:"organizationSettingsJson",params:["user"]});return this.props.setSaving(!0),(0,c.bE)(t,{user_id:e.hash,action:"make_admin"})})).then((t=>{this.props.updateSettings(t),this.props.setSaving(!1),this.props.successAlert(`${e.fullName} is now an admin.`)})).catch((e=>{e&&(this.props.setSaving(!1),this.props.errorAlert(e.json.error.message))}))}onResendInvite(e){(0,b.A)({title:"Resend Invite",message:`Are you sure you want to resend an invitation to ${e.email}?`}).then((()=>{const t=(0,m.A)({config:this.props.config,name:"organizationSettingsJson",params:["invite"]});return this.props.setSaving(!0),(0,c.bE)(t,{invite_id:e.id,action:"resend_invite"})})).then((()=>{this.props.setSaving(!1),this.props.successAlert(`We sent an invite for ${e.email} to join ${this.props.settings.organization.name}.`)})).catch((e=>{e&&(this.props.setSaving(!1),this.props.errorAlert(e.json.error.message))}))}onRevokeUserAdmin(e){(0,b.A)({title:"Revoke Admin",message:`Are you sure you want to revoke admin privileges for ${e.fullName}?`}).then((()=>{const t=(0,m.A)({config:this.props.config,name:"organizationSettingsJson",params:["user"]});return this.props.setSaving(!0),(0,c.bE)(t,{user_id:e.hash,action:"revoke_admin"})})).then((t=>{this.props.updateSettings(t),this.props.setSaving(!1),this.props.successAlert(`${e.fullName} is no longer an admin.`)})).catch((e=>{e&&(this.props.setSaving(!1),this.props.errorAlert(e.json.error.message))}))}render(){let e;const t="owner"===this.props.user.state||this.props.user.siteAdmin;let a,s;if(this.props.settings.pendingInvites.length&&(e=d.createElement("div",null,d.createElement("hr",{className:"margin-none"}),d.createElement("div",{className:"padding-15"},d.createElement("div",{className:"section-upper"},d.createElement("strong",null,"Pending invites")),d.createElement("table",{className:"table"},d.createElement("tbody",null,this.props.settings.pendingInvites.map(((e,a)=>{let s;return t&&(s=d.createElement("td",{className:"team-actions"},d.createElement("span",{className:"invite-resend",onClick:this.onResendInvite.bind(this,e)},"Resend Invite"),d.createElement("button",{className:"delete",onClick:this.onDeleteInvite.bind(this,e)},"×"))),d.createElement("tr",{key:a,className:"team-member"},d.createElement("td",null,d.createElement("span",{className:"pending-email"},e.email)),s)}))))))),t){const e="#invite"===window.location.hash;a=d.createElement("div",null,d.createElement("hr",{className:"margin-none"}),d.createElement("div",{className:"padding-15"},d.createElement("div",{className:"section-upper"},d.createElement("strong",null,"Invite someone new to your team")),d.createElement("div",null,d.createElement("input",{className:"form-control",autoFocus:e,onChange:this.updateEmail,value:this.state.editedEmail,type:"email",placeholder:"Work email address"}),d.createElement("button",{onClick:this.onEmailSave,className:"btn"},"Invite"))));
2const t=this.state.exportingUsers?d.createElement("i",{className:"fa fa-spinner fa-pulse"}):null,n=this.state.exportingUsers?"Exporting...":"Export";s=d.createElement("div",{className:"pull-right"},d.createElement("a",{disabled:this.state.exportingUsers,className:"link-btn",onClick:this.exportUsers},t," ",n))}else{const e=this.props.settings.team.filter((e=>"owner"===e.state)),t=e.map((e=>e.fullName));let s;s=1===e.length?`Your team admin can invite new members. Please ask your team admin (${t.join(", ")}) if you need to invite someone new.`:`Only team admins can invite new members. Please ask one of your team admins (${t.join(", ")}) if you need to invite someone new.`,a=d.createElement("div",null,d.createElement("hr",{className:"margin-none"}),d.createElement("div",{className:"padding-15"},d.createElement("div",{className:"section-upper"},d.createElement("strong",null,"Invite someone new to your team")),d.createElement("div",null,s)))}return d.createElement("div",{id:"team-members",ref:C.A,className:"app-block no-padding tight"},d.createElement("div",{className:"header"},d.createElement("h4",null,d.createElement("span",null,"Team Members"),s)),d.createElement("div",{className:"content"},d.createElement("table",{className:"table"},d.createElement("tbody",null,this.props.settings.team.map(((e,a)=>{if(e.isDeleted)return null;let s,n;return t&&this.props.user.id!==e.hash&&(s=d.createElement("td",{className:"team-actions"},d.createElement("span",{className:"admin-toggle",onClick:"owner"===e.state?this.onRevokeUserAdmin.bind(this,e):this.onMakeUserAdmin.bind(this,e)},"owner"===e.state?"Revoke Admin":"Make Admin"),d.createElement("button",{className:"delete",onClick:this.onDeleteUser.bind(this,e)},"×"))),e.mfaEnabled&&(n=d.createElement("span",{className:"mfa-enabled"},d.createElement("i",{className:"fa fa-check"})," 2FA")),d.createElement("tr",{key:a,className:"team-member"},d.createElement("td",null,d.createElement("span",null,e.fullName)," ",d.createElement("span",{className:"email"},e.email),n),s)}))))),e,a)}}const qt=(0,$t.wr)((function(e){let t,a;if(e.loading)a=d.createElement(Ft.Rh,{includeContainer:!1});else{if(e.hasMore){const a=(0,m.A)({config:e.config,name:"activityLogs"});t=d.createElement("div",{className:"view-all clearfix"},d.createElement("div",{className:"pull-right"},d.createElement(E.N_,{className:"btn btn-default",to:a},"View all")))}a=e.activities.length?e.activities.map((t=>d.createElement(zt.hc,{key:t.id,activity:t,config:e.config}))):d.createElement("div",{className:"empty text-center"},"There has been no dashboard activity in the past 30 days.")}return d.createElement("div",null,d.createElement("div",{className:"app-block no-padding tight"},d.createElement("div",{className:"header"},d.createElement("h4",null,"Recent Dashboard Activities")),a,t))}),{limit:5});function Yt(e){const t=Boolean("owner"===e.user.state||e.user.siteAdmin);return d.createElement("div",null,d.createElement(Vt,e),t&&d.createElement(qt,e))}var Jt=a(14809),Wt=a(91657),Ht=a(74352),Gt=a(69198),Xt=a(41973);function Qt(){return Qt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var s in a)({}).hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},Qt.apply(null,arguments)}function Zt(e){return d.createElement(d.Fragment,null,d.createElement("button",Qt({},e,{className:"btn btn-default btn-block add-rule-btn-narrow",onClick:e.onClick}),d.createElement("span",{className:"explainer"},"Add a rule")))}function ea(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,s)}return a}function ta(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?ea(Object(a),!0).forEach((function(t){aa(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):ea(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}function aa(e,t,a){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var a=e[Symbol.toPrimitive];if(void 0!==a){var s=a.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}const sa=e=>({editing:!1,isDirty:!1,preDisputeAcceptLogic:De()(e.preDisputeAcceptLogic),index:null,rule:null}),na=(e,t)=>{switch(t.type){case"ADD_RULE":{const t={left:"",right:"",op:"=",isNew:!0},a=[...e.preDisputeAcceptLogic,t];return ta(ta({},e),{},{preDisputeAcceptLogic:a,editing:!0,index:a.length-1,rule:t})}
2case"CANCEL_EDITING":{const t=e.rule&&e.rule.isNew?e.preDisputeAcceptLogic.slice(0,-1):e.preDisputeAcceptLogic;return ta(ta({},e),{},{preDisputeAcceptLogic:t,editing:!1,index:null,rule:null,isDirty:!1})}case"EDIT_RULE":{const a=e.preDisputeAcceptLogic[t.payload];return ta(ta({},e),{},{editing:!0,index:t.payload,rule:{left:De()(a.left),op:De()(a.op),right:De()(a.right),isNew:a.isNew}})}case"SET_DIRTY":return ta(ta({},e),{},{isDirty:!0});case"UPDATE_LOGIC":return ta(ta({},e),{},{preDisputeAcceptLogic:t.payload});case"UPDATE_RULE":return ta(ta({},e),{},{rule:t.payload});default:return e}};function ia(e){const[t,a]=(0,d.useReducer)(na,e.settings,sa),s=()=>a({type:"ADD_RULE"}),n=()=>a({type:"CANCEL_EDITING"}),i=function(){let a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return e.setSaving(!0),(()=>{const a=(0,m.A)({config:e.config,name:"settingsManualReviewJson",params:["preDisputeAcceptLogic"]});return(0,c.bE)(a,{"pre-dispute-accept-logic":t.preDisputeAcceptLogic})})().then((()=>(e.updateSettings({preDisputeAcceptLogic:t.preDisputeAcceptLogic}),e.setSaving(!1),e.successAlert(a||"Accept settings saved."),r(),!0))).catch((t=>{const a=t.json&&t.json.error?t.json.error.message:null;return e.setSaving(!1),e.errorAlert(a||"Something went wrong, and we could not save your settings. Please try again."),r(),!1}))},r=()=>{n()},l=!!e.settings.preDisputeAcceptLogic.length,o=(s,n)=>({rule:s,context:t.preDisputeAcceptLogic,deleteRule:()=>function(e){let s=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=t.preDisputeAcceptLogic,l=De()(n);l.splice(e,1),a({type:"UPDATE_LOGIC",payload:l}),s?r():i("Rule deleted successfully.").then((e=>{e||a({type:"UPDATE_LOGIC",payload:n})}))}(n,!1),editRule:()=>(e=>a({type:"EDIT_RULE",payload:e}))(n),viewOnly:e.viewOnly,idx:n}),p=()=>l?d.createElement("ul",{className:"rules list-unstyled"},t.preDisputeAcceptLogic.map(((e,t)=>e.isNew?null:d.createElement("li",{className:"rule",key:e.id||t},d.createElement(Gt.bd,o(e,t)))))):null,u=()=>!l&&e.viewOnly?d.createElement("div",{className:"section_pre_dispute_intro"},d.createElement("p",null,d.createElement("strong",null,"Organization have not configured rules to automatically accept disputes."))):d.createElement("div",{className:"section_pre_dispute_intro"},"Automatically refund pre-disputes before they escalate to chargebacks."),h=()=>e.viewOnly?null:d.createElement(d.Fragment,null,d.createElement("hr",null),d.createElement("div",{className:"actions clearfix"},d.createElement(Zt,{onClick:s,"aria-label":"Add Accept Rule"})));return d.createElement("div",{id:"accept",ref:C.A,className:"app-block no-padding tight template-select-block"},d.createElement("div",{className:"header"},d.createElement("h4",null,"Pre-Dispute Rules")),d.createElement(u,null),d.createElement(p,null),d.createElement(h,null),d.createElement(Oe.XG,{when:!!t.isDirty,message:"You have unsaved changes, if you leave the page they will be lost."}),d.createElement(Gt.Ay,{content:"Automatically refund a pre-dispute when:",isOpen:t.editing,rule:t.rule,saveRule:t.rule?()=>((e,s)=>{const n=t.preDisputeAcceptLogic,r=De()(n);r[e]&&r[e].isNew&&r.splice(e,1);const l=De()(s);(0,Xt.Jb)(l),r[e]=l,a({type:"UPDATE_LOGIC",payload:r}),a({type:"UPDATE_RULE",payload:l}),i(s.isNew?"The new rule was successfully added.":"Rule successfully updated.").then((e=>{e||(a({type:"UPDATE_LOGIC",payload:n}),a({type:"UPDATE_RULE",payload:s}))}))})(t.index,t.rule):void 0,cancelEditing:n,edited:()=>a({type:"SET_DIRTY"}),isDirty:t.isDirty,errorAlert:e.errorAlert,templateFields:e.settings.preDisputeRulesFields,onChangeRule:e=>{a({type:"UPDATE_RULE",payload:e})},fieldPickerPlaceholder:"Select Pre-Dispute field",fieldPickerDataTip:"Choose a Pre-Dispute field"}))}var ra=a(25131);function la(e){let{isEnabled:t,disabled:a,onClick:s,featureName:n,className:i="",enabledText:r="Enabled",disabledText:l="Disabled"}=e;const o=g()("btn",{"btn-success":t,"btn-default":!t},"pull-right",i);return d.createElement("button",{onClick:s,"aria-label":`${t?"Disable":"Enable"} ${n}`,disabled:a,className:o},t?r:l)}var oa=a(99225);const ca=e=>{let{url:t}=e;return d.createElement("div",{className:"disclaimer"},d.createElement("p",null,'By clicking "Accept", you confirm that you have read, understood, and agree to our'," ",d.createElement("a",{rel:"noopener noreferrer",target:"_blank",href:t},"terms & conditions"),"."))},da=e=>{let{featureName:t}=e;return d.createElement("p",null,"Confirm Disable ",t)},ma={DCDA:{enableTitle:"Terms & Conditions",disableTitle:"Dispute Automation",termsUrl:oa.Uo,featureName:"Dispute Automation"},DE:{enableTitle:"Terms & Conditions",disableTitle:"Dispute Evaluator",termsUrl:oa.d0,featureName:"Dispute Evaluator"},RDR:{enableTitle:"Terms & Conditions",disableTitle:"Rapid Dispute Resolution",termsUrl:oa.Wj,featureName:"Rapid Dispute Resolution"},CE:{enableTitle:"Enable Compelling Evidence",disableTitle:"Disable Compelling Evidence",featureName:"Compelling Evidence"}};function pa(e){let{isEnabled:t,disableBtn:a,saveRapidDisputeResolutionSettings:s=()=>{}}=e;const n=d.useCallback((()=>{const e=ma.RDR,a=t?e.disableTitle:e.enableTitle,n=t?d.createElement(da,{featureName:e.featureName}):d.createElement(ca,{url:e.termsUrl});(0,b.A)({title:a,messageElement:n,confirmLabel:t?"Ok":"Accept"}).then(s).catch((()=>{}))}),[t,s]);return d.createElement("div",{id:"toggler-de"},d.createElement("div",{className:"app-block no-padding tight toggler-block"},d.createElement("div",{className:"header"},d.createElement("h4",null,"Rapid Dispute Resolution (RDR) by Verifi")),d.createElement("hr",null),d.createElement("div",{className:"toggler-switch-container rdr-switch-container"},d.createElement("div",{className:"toggler-explainer"},d.createElement("span",null,"Automatically resolve Visa pre-disputes by setting rules to refund them before they escalate to chargebacks")),d.createElement("div",{className:"toggler-switch"},d.createElement(la,{isEnabled:t,onClick:n,disabled:a,featureName:"Rapid Dispute Resolution"})))))}var ua=a(85442),ha=a(85440);function ga(e){let{isEnabled:t,disableBtn:a,saveCompellingEvidenceSettings:s,customRulesCeEditor:n}=e;return d.createElement("div",{className:"app-block no-padding clearfix"},d.createElement("div",{className:"header"},d.createElement("h4",{style:{display:"inline-block",marginRight:16}},"Visa Compelling Evidence"),d.createElement("div",{className:"pull-right",style:{display:"inline-block"}},d.createElement("button",{onClick:()=>{let e="Enable Visa Compelling Evidence",a=d.createElement("p",{role:"alertdialog"},"Confirm Enable Visa Compelling Evidence");t&&(e="Disable Visa Compelling Evidence",a=d.createElement("p",{role:"alertdialog"},"Confirm Disable Visa Compelling Evidence")),(0,b.A)({title:e,messageElement:a,confirmLabel:t?"Disable":"Enable"}).then((()=>{s()})).catch((()=>{}))},"aria-label":(t?"Disable":"Enable")+" Visa Compelling Evidence",disabled:a,className:`btn ${t?"btn-success":"btn-default"} pull-right`},t?"Enabled":"Disabled"))),d.createElement("div",null,n))}var va=a(8419);function Ea(e,t,a){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var a=e[Symbol.toPrimitive];if(void 0!==a){var s=a.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class fa extends d.Component{constructor(e){var t;super(e),t=this,Ea(this,"addRule",(()=>{this.setState((e=>({customRules:[...e.customRules,{left:"",right:"",op:"=",isNew:!0}]})),(()=>{this.editRule(this.state.customRules.length-1)}))})),Ea(this,"cancelEditing",(()=>{const e=()=>{this.setState({editing:!1,index:null,rule:null,isDirty:!1})};this.state.rule&&this.state.rule.isNew?this.setState((e=>({customRules:(0,Xt.or)(e.customRules)})),e):e()})),Ea(this,"editRule",(e=>{const t=this.state.customRules[e];this.setState({editing:!0,index:e,rule:{left:De()(t.left),op:De()(t.op),right:De()(t.right),isNew:t.isNew}})})),Ea(this,"edited",(()=>{this.setState({isDirty:!0})})),Ea(this,"postSettings",(e=>{if("function"==typeof this.props.onSave)return this.props.onSave(e);const t=(0,m.A)({config:this.props.config,name:"settingsManualReviewJson",params:["customRulesCE"]});return(0,c.bE)(t,{"custom-rule-ce-logic":e})})),Ea(this,"save",(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;t.props.setSaving(!0);const a=t.state.customRules;return t.postSettings(a).then((()=>(t.props.updateSettings({customRuleCeLogic:a}),t.props.setSaving(!1),t.props.successAlert(e||"Dispute Automation Custom rule settings saved."),t.saved(),!0))).catch((e=>{const a=e.json&&e.json.error?e.json.error.message:null;return t.props.setSaving(!1),t.props.errorAlert(a||"Something went wrong, and we could not save your settings. Please try again."),t.saved(),!1}))})),Ea(this,"saved",(()=>{this.cancelEditing()})),this.state={editing:!1,isDirty:!1,customRules:De()(e.settings.customRuleCeLogic)}}deleteRule(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const a=this.state.customRules,s=(0,Xt.wi)(a,e);this.setState({customRules:s},(()=>{t?this.saved():this.save("Custom Rule deleted successfully.").then((e=>{e||this.setState({customRules:a})}))}))}saveRule(e,t){const a=this.state.customRules,s=(0,Xt.Fk)(t),n=(0,Xt.sl)(a,e,s);this.setState({customRules:n,rule:s},(()=>{this.save(t.isNew?"The new rule was successfully added.":"Rule successfully updated.").then((e=>{e||this.setState({customRules:a,rule:t})}))}))}render(){const e=this.state.customRules.some((e=>!e.isNew));let t,a;return e&&(t=d.createElement("ul",{className:"rules list-unstyled"},this.state.customRules.map(((e,t)=>{if(e.isNew)return null;const a={rule:e,context:this.state.customRules,deleteRule:this.deleteRule.bind(this,t,!1),editRule:this.editRule.bind(this,t),viewOnly:this.props.viewOnly,idx:t};return d.createElement("li",{className:"rule",key:t},d.createElement(Gt.bd,a))})))),a=e?d.createElement("div",{className:"intro"},"Disputes matching the following rules will be automatically contested:"):d.createElement("div",null,d.createElement("div",{id:"empty",className:"intro"},"You can define the rules to automatically contest disputes using Visa Compelling Evidence"),d.createElement("hr",null)),d.createElement("div",{id:"custom-rules",ref:C.A,className:"no-padding tight template-select-block"},a,t,this.props.viewOnly?null:d.createElement("div",{className:"actions clearfix"},d.createElement("div",{className:"pull-right"},d.createElement("div",{className:"text-right"},d.createElement(va.A,{onClick:this.addRule,"aria-label":"Add Custom Rule"})))),d.createElement(Oe.XG,{when:!!this.state.isDirty,message:"You have unsaved changes, if you leave the page they will be lost."}),d.createElement(Gt.Ay,{content:"Auto Submit disputes evidence via Visa Compelling Evidence when:",isOpen:this.state.editing,rule:this.state.rule,saveRule:this.saveRule.bind(this,this.state.index),cancelEditing:this.cancelEditing,edited:this.edited,isDirty:this.state.isDirty,errorAlert:this.props.errorAlert,templateFields:this.props.settings.customRulesCeFields,editorContext:"customRules"}))}}function ya(e){let{isEnabled:t}=e;return d.createElement("div",{id:"toggler-evidence-map"},d.createElement("div",{className:"app-block no-padding tight toggler-block"},d.createElement("div",{className:"header"},d.createElement("h4",null,"AI Dynamic Template Settings")),d.createElement("hr",null),d.createElement("div",{className:"toggler-switch-container"},d.createElement("div",{className:"toggler-explainer"},d.createElement("span",null,"AI Dynamic Template (Evidence Map)")),d.createElement("div",{className:"toggler-switch"},d.createElement("span",{style:{cursor:"default"},className:`btn ${t?"btn-success":"btn-default"} pull-right`},t?"Enabled":"Disabled")))))}var ba=a(66245),Na=a.n(ba);function Aa(e,t,a){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var a=e[Symbol.toPrimitive];if(void 0!==a){var s=a.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class wa extends d.Component{constructor(e){super(e),Aa(this,"setDefault",(()=>{const e=this.props.currentDefault;this.state.selected.value&&this.props.setDefaultTemplate(this.state.selected.value,(()=>{this.props.saveTemplateLogic("Default template successfully enabled.",(t=>{t||this.props.setDefaultTemplate(e),this.cancel()}))}))})),Aa(this,"cancel",(()=>{this.onChange(null),this.props.cancel()})),Aa(this,"onChange",(e=>{this.setState({selected:e})})),this.state={selected:null}}render(){const e=Na()(Object.keys(this.props.templatesBySlug),[this.props.currentDefault]).filter((e=>!this.props.templatesBySlug[e].archived));return d.createElement(T(),{isOpen:this.props.isOpen,contentLabel:"Modal",onRequestClose:this.cancel,className:"dialog-modal-content default-template-modal",overlayClassName:"dialog-modal-overlay edit-overlay"},d.createElement("div",null,d.createElement("button",{onClick:this.cancel,type:"button",className:"close","data-dismiss":"modal","aria-label":"Close"},d.createElement("span",{"aria-hidden":"true"},"×")),d.createElement("h4",null,"Set a Default Template"),d.createElement("div",{className:"content"},"Choose a template that will be used if none of your other template select rules are matched"),d.createElement("div",{className:"templates"},d.createElement(q.Ay,{styles:V.A,placeholder:"Select a template...",value:this.state.selected,options:e.map((e=>({value:e,label:this.props.templatesBySlug[e].title}))),onChange:this.onChange})),d.createElement("div",{className:"actions"},d.createElement("button",{className:"btn btn-default cancel",onClick:this.cancel},"Cancel"),d.createElement("button",{id:"select-default-template",className:g()({"btn btn-primary save":!0,disabled:!this.state.selected}),onClick:this.setDefault},"Save"))),d.createElement(I.A,{effect:"solid",offset:{top:-5}}))}}class ka extends d.Component{constructor(e){super(e),Aa(this,"componentDidMount",(()=>{I.A.rebuild()})),Aa(this,"save",(()=>{if(!this.state.rule.template)return void this.props.errorAlert("Please set a template for the rule.");const e=(0,Xt.J6)(this.state.rule.rule,this.props.templateFields);if(!e[0])return this.props.errorAlert(e[1]||"Please supply valid values for all rules."),void this.setState({highlightErrors:!0});this.props.saveRule(this.state.rule,(()=>{this.setState({step:"template",highlightErrors:!1})}))})),Aa(this,"updateTemplate",(e=>{this.setState((t=>({rule:{template:e,rule:t.rule.rule,isNew:t.rule.isNew}})))})),Aa(this,"updateRule",(e=>{this.setState((t=>({rule:{rule:e,template:t.rule.template,isNew:t.rule.isNew},highlightErrors:!1})))})),Aa(this,"onTemplateChange",(e=>{e&&e.value?this.updateTemplate(e.value):this.updateTemplate(null)})),Aa(this,"cancel",(()=>{this.setState({step:"template",highlightErrors:!1}),this.props.cancelEditing()})),Aa(this,"next",(()=>{this.state.rule.template&&this.setState({step:"rule"})})),this.state={step:"template",rule:e.rule}}componentDidUpdate(e){e.isOpen!==this.props.isOpen&&this.setState({rule:De()(this.props.rule),highlightErrors:!1})}render(){const{rule:e}=this.state;let t,a,s;if(e)if(e.isNew)if(t="Create a new rule","template"===this.state.step){const t=Object.keys(this.props.templatesBySlug).filter((e=>!this.props.templatesBySlug[e].archived)).map((e=>({value:e,label:this.props.templatesBySlug[e].title})));a=d.createElement("div",null,d.createElement("div",{className:"content"},"First, choose the template that will be selected"),d.createElement("div",{className:"templates"},d.createElement(q.Ay,{styles:V.A,placeholder:"Select a template...",value:t.filter((t=>t.value===e.template)),options:t,onChange:this.onTemplateChange}
2))),s=d.createElement("div",{className:"actions"},d.createElement("button",{className:"btn btn-default cancel",onClick:this.cancel},"Cancel"),d.createElement("button",{className:g()({"btn btn-primary next":!0,disabled:!e.template}),onClick:this.next},"Next"))}else a=d.createElement("div",null,d.createElement("div",{className:"content"},"Select the template ",d.createElement("strong",null,this.props.templatesBySlug[e.template].title)," when:"),d.createElement(Gt.H_,{rule:e.rule,templateFields:this.props.templateFields,edited:this.props.edited,updateRule:this.updateRule,highlightErrors:this.state.highlightErrors})),s=d.createElement("div",{className:"actions"},d.createElement("button",{className:"btn btn-default cancel",onClick:this.cancel},"Cancel"),d.createElement("button",{className:"btn btn-primary save",onClick:this.save},"Save"));else t="Edit rule",a=d.createElement("div",null,d.createElement("div",{className:"content"},"Select the template ",d.createElement("strong",null,this.props.templatesBySlug[e.template].title)," when:"),d.createElement(Gt.H_,{rule:e.rule,templateFields:this.props.templateFields,edited:this.props.edited,updateRule:this.updateRule,highlightErrors:this.state.highlightErrors})),s=d.createElement("div",{className:"actions"},d.createElement("button",{className:"btn btn-default cancel",onClick:this.cancel},"Cancel"),d.createElement("button",{className:"btn btn-primary save",onClick:this.save},"Save"));return d.createElement(T(),{isOpen:this.props.isOpen,contentLabel:"Modal",onRequestClose:this.cancel,className:"dialog-modal-content review-modal",overlayClassName:"dialog-modal-overlay edit-overlay"},d.createElement("div",{className:"manual-review-editor-modal"},d.createElement("button",{onClick:this.cancel,type:"button",className:"close","data-dismiss":"modal","aria-label":"Close"},d.createElement("span",{"aria-hidden":"true"},"×")),d.createElement("h4",null,t),a,s),d.createElement(I.A,{effect:"solid",offset:{top:-5}}))}}function Sa(e){const t=e.templatesBySlug[e.template].title,a=e.templatesBySlug[e.template].archived;return d.createElement("div",{className:"template-group"},d.createElement("div",{className:"template"},"Select ",d.createElement("strong",null,t,a?" (archived)":null)," when:"),d.createElement("div",{className:"rules"},d.createElement("div",{className:"rule"},d.createElement(Gt.bd,{idx:e.index,rule:e.rule,deleteRule:()=>e.deleteRule(e.index,!1),editRule:()=>e.editRule(e.index)}))))}class Ca extends d.Component{constructor(){super(...arguments),Aa(this,"remove",(()=>{const e=this.props.template;(0,b.A)().then((()=>{this.props.setDefaultTemplate(null,(()=>{this.props.saveTemplateLogic("Default template successfully disabled",(t=>{t||this.props.setDefaultTemplate(e)}))}))}))}))}render(){const e=this.props.templatesBySlug[this.props.template].title,t=this.props.templatesBySlug[this.props.template].archived;return d.createElement("div",{className:"template-group default"},d.createElement("div",{className:"details"},d.createElement("div",{className:"template"},"Default: ",d.createElement("strong",null,e,t?" (archived)":null)),d.createElement("a",{onClick:this.remove},d.createElement("span",{className:"fa fa-times"}))))}}class Ia extends d.Component{constructor(e){var t;super(e),t=this,Aa(this,"editRule",(e=>{const t=this.props.settings.templateSelectLogic.rules[e];this.setState({editing:!0,index:e,rule:{template:t.template,isNew:t.isNew,rule:{left:De()(t.rule.left),op:De()(t.rule.op),right:De()(t.rule.right)}}})})),Aa(this,"addRule",(()=>{this.props.addTemplateLogic((e=>{this.editRule(e)}))})),Aa(this,"deleteRule",(function(e){let a=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const s=()=>{const s=t.props.settings.templateSelectLogic.rules[e];t.props.deleteTemplateLogic(e,(()=>{a?t.saved():t.props.saveTemplateLogic("Rule deleted successfully.",(a=>{a||t.props.updateTemplateLogic(e,s)}))}))};a?s():(0,b.A)().then(s).catch((()=>{}))})),Aa(this,"edited",(()=>{this.setState({isDirty:!0})})),Aa(this,"saveRule",((e,t)=>{const a=e,s=this.state.index,n=e.isNew;e={template:e.template,rule:e.rule},this.setState({rule:e},(()=>{this.props.updateTemplateLogic(s,e,(()=>{this.props.saveTemplateLogic(n?"The new rule was successfully added.":"Rule successfully updated.",(e=>{e||this.setState({rule:a},(()=>{this.props.updateTemplateLogic(s,a)})),this.saved(t)}))}))}))})),Aa(this,"saved",(e=>{this.cancelEditing(e)})),Aa(this,"cancelEditing",(e=>{const t=()=>{this.setState({editing:!1,isDirty:!1,index:null,rule:null},e)};this.state.rule&&this.state.rule.isNew?this.props.deleteTemplateLogic(this.state.index,t):t()})),Aa(this,"toggleSetDefault",(()=>{this.setState((e=>({settingDefault:!e.settingDefault})))})),this.state={editing:!1,settingDefault:!1,isDirty:!1,index:null,rule:null}}render(){const e=!!this.props.settings.templateSelectLogic.rules.length,t=!!this.props.settings.templateSelectLogic.default;let a,s;e&&(a=this.props.settings.templateSelectLogic.rules.map(((e,t)=>e.isNew?null:d.createElement(Sa,{deleteRule:this.deleteRule,edited:this.edited,editRule:this.editRule,index:t,key:t,rule:e.rule,template:e.template,templatesBySlug:this.props.settings.templatesBySlug})))),t&&(s=d.createElement(Ca,{template:this.props.settings.templateSelectLogic.default,saveTemplateLogic:this.props.saveTemplateLogic,templatesBySlug:this.props.settings.templatesBySlug,setDefaultTemplate:this.props.setDefaultTemplate}));let n;return n=!(t||e&&a.filter((e=>!!e)).length)?d.createElement("div",null,d.createElement("div",{id:"empty",className:"intro"},d.createElement("p",null,d.createElement("strong",null,"Match templates to disputes when using the API to submit.")),d.createElement("p",null,"Chargehound can automatically choose a template for a dispute using simple rules that you create. You can also set a default template, which will be used for disputes that do not match any of your other template rules."),d.createElement("p",null,"For example, you might use a ",d.createElement("code",null,"subscription")," template for disputes on subscription charges, and a default ",d.createElement("code",null,"ecommerce")," template for all other disputes."),d.createElement("p",null,"Creating template select rules can cut down on your API integration time because you will not need to specify templates as a part of the integration. It also makes it easier to make changes to your templates and workflow in the future. You can always override the template rules by specifying a template in the API call.")),d.createElement("hr",null)):d.createElement("div",{className:"intro"},"When a template is not specified in API calls, Chargehound will automatically select what template to use."),d.createElement("div",{id:"template-select",ref:C.A,className:"app-block no-padding tight template-select-block"},d.createElement("div",{className:"header"},d.createElement("h4",null,"Template Select")),n,s,a,d.createElement("div",{className:"actions clearfix"},d.createElement("div",{className:"pull-left"},d.createElement("button",{id:"default-template",onClick:this.toggleSetDefault,className:"btn btn-default"},"Set default")),d.createElement("div",{className:"pull-right"},d.createElement("div",{className:"text-right"},d.createElement("span",{className:"explainer"},"Add a rule"),d.createElement("div",{id:"add-template",className:"btn btn-primary add-rule",onClick:this.addRule},d.createElement("span",{className:"fa fa-plus"}))))),d.createElement(Oe.XG,{when:!!this.state.isDirty,message:"You have unsaved changes, if you leave the page they will be lost."}),d.createElement(ka,{isOpen:this.state.editing,rule:this.state.rule,templatesBySlug:this.props.settings.templatesBySlug,templateFields:this.props.settings.templateFields,saveRule:this.saveRule,cancelEditing:this.cancelEditing,errorAlert:this.props.errorAlert,currentDefault:this.props.settings.templateSelectLogic.default,edited:this.edited}),d.createElement(wa,{isOpen:this.state.settingDefault,templatesBySlug:this.props.settings.templatesBySlug,currentDefault:this.props.settings.templateSelectLogic.default,saveTemplateLogic:this.props.saveTemplateLogic,setDefaultTemplate:this.props.setDefaultTemplate,cancel:this.toggleSetDefault}))}}function Pa(e,t,a){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var a=e[Symbol.toPrimitive];if(void 0!==a){var s=a.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function xa(e){const t=e.warningLogic[e.action];let a,s;return t&&t.length?(a=d.createElement("ul",{className:"rules list-unstyled"},t.map(((t,a)=>{if(t.isNew)return null;const s={rule:t,deleteRule:e.deleteRule.bind(e.this,e.action,a,!1),editRule:e.editRule.bind(e.this,e.action,a),idx:a};return d.createElement("li",{className:"rule",key:a},d.createElement(Gt.bd,s))}))),s=d.createElement("div",{className:"actions clearfix"},d.createElement("div",{className:"pull-right"},d.createElement("div",{className:"text-right"},d.createElement("span",{className:"explainer"},"Add a rule"),d.createElement("div",{id:"add-template",className:"btn btn-primary add-rule",onClick:e.addRule.bind(e.this,e.action)},d.createElement("span",{className:"fa fa-plus"})))))):s=d.createElement("div",{className:"actions"},d.createElement("div",{className:"btn btn-default first-rule-btn",onClick:e.addRule.bind(e.this,e.action)},"Add a rule")),d.createElement(d.Fragment,null,d.createElement("div",{className:"intro"},e.actionVerb," dispute warnings when:"),a,s)}class Da extends d.Component{constructor(e){var t;super(e),t=this,Pa(this,"cancelEditing",(()=>{const e=()=>{this.setState({editing:!1,index:null,rule:null,isDirty:!1,action:null})};this.state.action&&this.state.rule&&this.state.rule.isNew?this.setState((e=>{const t=e.warningLogic[this.state.action];return t.pop(),{warningLogic:o()({},e.warningLogic,{[this.state.action]:t}),action:null}}),e):e()})),Pa(this,"edited",(()=>{this.setState({isDirty:!0})})),Pa(this,"save",(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;const a=(0,m.A)({config:t.props.config,name:"settingsManualReviewJson",params:["warningLogic"]});t.props.setSaving(!0);const s=t.state.warningLogic;return(0,c.bE)(a,{"warning-logic":s}).then((()=>(t.props.updateSettings({warningLogic:s}),t.props.setSaving(!1),t.props.successAlert(e||"Warning settings saved."),t.saved(),!0))).catch((e=>{const a=e.json&&e.json.error?e.json.error.message:null;return t.props.setSaving(!1),t.props.errorAlert(a||"Something went wrong, and we not could save your settings. Please try again."),t.saved(),!1}))})),Pa(this,"saved",(()=>{this.cancelEditing()})),this.state={editing:!1,isDirty:!1,action:null,index:null,rule:null,warningLogic:De()(e.settings.warningLogic)}}addRule(e){this.setState((t=>{let a=t.warningLogic[e];return a||(a=[]),a.push({left:"",right:"",op:"=",isNew:!0}),{warningLogic:o()({},t.warningLogic,{[e]:a}),action:e}}),(()=>{this.editRule(e,this.state.warningLogic[e].length-1)}))}deleteRule(e,t){let a=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const s=()=>{const s=this.state.warningLogic,n=De()(s);n[e].splice(t,1),this.setState({warningLogic:n},(()=>{a?this.saved():this.save("Rule deleted successfully.").then((e=>{e||this.setState({warningLogic:s})}))}))};a?s():(0,b.A)().then(s)}editRule(e,t){const a=this.state.warningLogic[e][t];this.setState({editing:!0,index:t,action:e,rule:{left:De()(a.left),op:De()(a.op),right:De()(a.right),isNew:a.isNew}})}saveRule(e,t,a){const s=this.state.warningLogic;s[e][t].isNew&&s[e].splice(t,1);const n=De()(s),i=De()(a);(0,Xt.Jb)(i),n[e][t]=i,this.setState({warningLogic:n,rule:i},(()=>{this.save(a.isNew?"The new rule was successfully added.":"Rule successfully updated.").then((e=>{e||this.setState({warningLogic:s,rule:a})}))}))}render(){let e;return this.state.warningLogic.review&&this.state.warningLogic.review.filter((e=>!e.isNew)).length&&(e=d.createElement(xa,{action:"review-bypass",actionVerb:
2d.createElement("span",null,d.createElement("strong",null,"Bypass manual review")," for"),warningLogic:this.props.settings.warningLogic,this:this,addRule:this.addRule,editRule:this.editRule,deleteRule:this.deleteRule})),d.createElement("div",{id:"warning-rules",ref:C.A,className:"app-block no-padding tight template-select-block"},d.createElement("div",{className:"header"},d.createElement("h4",null,"Dispute Warnings")),d.createElement("div",{className:"intro"},d.createElement("p",null,"A dispute warning indicates that the card issuer has notified the payment processor that a charge may be fraudulent. Refunding the charge can stop the warning from escalating to a dispute."),d.createElement("p",null,"You can automatically refund, dismiss, or review dispute warnings.")),e,d.createElement(xa,{action:"review",actionVerb:d.createElement("strong",null,"Manually review"),warningLogic:this.props.settings.warningLogic,this:this,addRule:this.addRule,editRule:this.editRule,deleteRule:this.deleteRule}),d.createElement(xa,{action:"dismiss",actionVerb:
2d.createElement("strong",null,"Dismiss"),warningLogic:this.props.settings.warningLogic,this:this,addRule:this.addRule,editRule:this.editRule,deleteRule:this.deleteRule}),d.createElement(xa,{action:"refund",actionVerb:d.createElement("strong",null,"Refund"),warningLogic:this.props.settings.warningLogic,this:this,addRule:this.addRule,editRule:this.editRule,deleteRule:this.deleteRule}),d.createElement(Oe.XG,{when:!!this.state.isDirty,message:"You have unsaved changes, if you leave the page they will be lost."}),d.createElement(Gt.Ay,{content:`Automatically ${this.state.action} a dispute warning when:`,isOpen:this.state.editing,rule:this.state.rule,saveRule:this.saveRule.bind(this,this.state.action,this.state.index),cancelEditing:this.cancelEditing,edited:this.edited,errorAlert:this.props.errorAlert,templateFields:this.props.settings.warningFields}))}}function Ta(){return Ta=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var s in a)({}).hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},Ta.apply(null,arguments)}function La(e,t,a){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var a=e[Symbol.toPrimitive];if(void 0!==a){var s=a.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}Pa(Da,"ACTIONS",["review","dismiss","refund","review-bypass"]);class Oa extends d.Component{constructor(e){super(e),La(this,"hourOptions",[{label:"12 hours",value:12},{label:"24 hours",value:24},{label:"48 hours",value:48},{label:"1 week",value:168}]),La(this,"modeOptions",[{label:"before due date",value:"before-due"},{label:"after being queued",value:"after-queue"}]),La(this,"updateHours",(e=>{this.setState({hours:e.value,dirty:!0})})),La(this,"updateMode",(e=>{this.setState({mode:e.value,dirty:!0})})),La(this,"onSave",(()=>{this.props.saveQueueSettings({hours:this.state.hours,mode:this.state.mode}).then((()=>{this.setState({dirty:!1})}))})),this.state={mode:e.settings.queue.mode,hours:e.settings.queue.hours,dirty:!1}}render(){return d.createElement("div",{id:"queue-settings",ref:C.A,className:"app-block no-padding tight queue-settings"},d.createElement(Oe.XG,{when:!!this.state.dirty,message:"You have unsaved changes, if you leave the page they will be lost."}),d.createElement("div",{className:"header"},d.createElement("h4",null,"Queue Settings")),d.createElement("div",{className:"content"},d.createElement("p",null,"Queuing a dispute for submission allows you to stage evidence that will be automatically submitted later. This can give you time to check the data or attach additional evidence to a dispute."),d.createElement("p",null,"You can queue individual disputes from the dashboard, or automatically queue disputes with the API. View the API documentation ",d.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:`${this.props.config.webHost}
2/docs/api/${this.props.settings.versioning.currentVersion}/#queuing-for-submission`},"here"),"."),d.createElement("div",{className:"section-upper emphasis"},"Submit queued disputes"),d.createElement(q.Ay,{styles:V.A,className:"select timeframe",placeholder:"Choose timeframe...",isSearchable:!1,isClearable:!1,value:this.hourOptions.filter((e=>{let{value:t}=e;return t===this.state.hours})),options:this.hourOptions,onChange:this.updateHours}),d.createElement(q.Ay,{styles:V.A,className:"select mode",placeholder:"Choose mode...",isSearchable:!1,isClearable:!1,value:this.modeOptions.filter((e=>{let{value:t}=e;return t===this.state.mode})),options:this.modeOptions,onChange:this.updateMode})),d.createElement("hr",null),d.createElement("div",{className:"btn-section clearfix"},d.createElement("button",{disabled:!this.state.dirty,onClick:this.onSave,className:"btn btn-primary pull-right"},"Save changes")))}}class Ra extends d.Component{constructor(e){super(e),La(this,"hourOptions",[{label:"never",value:0},{label:"after 1 day",value:24},{label:"after 2 days",value:48},{label:"after 3 days",value:72},{label:"after 1 week",value:168}]),La(this,"updateHours",(e=>{this.setState({hours:e.value,dirty:!0})})),La(this,"onSave",(()=>{this.props.saveAcceptOverdueSettings({hours:this.state.hours}).then((()=>{this.setState({dirty:!1})}))})),this.state={hours:e.settings.acceptOverdue.hours,dirty:!1}}render(){return d.createElement("div",{id:"accept-overdue-settings",ref:C.A,className:"app-block no-padding tight accept-overdue-settings"},d.createElement(Oe.XG,{when:!!this.state.dirty,message:"You have unsaved changes, if you leave the page they will be lost."}),d.createElement("div",{className:"header"},d.createElement("h4",null,"Accept Overdue")),d.createElement("div",{className:"content"},d.createElement("p",null,"You can automatically accept overdue disputes. Automatically accepting overdue disputes will keep your Chargehound dashboard focused on actionable disputes."),d.createElement("div",{className:"section-upper emphasis"},"Accept overdue disputes"),d.createElement(q.Ay,{styles:V.A,className:"select timeframe",placeholder:"Choose timeframe...",isSearchable:!1,isClearable:!1,value:this.hourOptions.filter((e=>{let{value:t}=e;return t===this.state.hours})),options:this.hourOptions,onChange:this.updateHours})),d.createElement("hr",null),d.createElement("div",{className:"btn-section clearfix"},d.createElement("button",{disabled:!this.state.dirty,onClick:this.onSave,className:"btn btn-primary pull-right"},"Save changes")))}}function ja(e){const t=e.config.rapidDisputeResolution?.enabled??!1;let a,s,n,i,r,l,o,c,m,p;return e.settings.showWarningLogic&&(a=d.createElement(Da,e)),t&&e.settings.rdr?.isAvailableForOrg&&(i=d.createElement(pa,{isEnabled:e.settings.rdr?.isEnabled,saveRapidDisputeResolutionSettings:e.saveRapidDisputeResolutionSettings,disableBtn:!e.settings.user.canUserToggleRdr}),n=d.createElement(ia,e)),e.settings.disputeEvaluator?.isAvailableForOrg&&(l=d.createElement(ha.A,{isEnabled:e.settings.disputeEvaluator?.isEnabled,saveDisputeEvaluatorSettings:e.saveDisputeEvaluatorSettings,disableBtn:!e.settings.user.canUserToggleDe}),e.settings.user.canUserSeeDeRules&&(o=d.createElement(Ht.A,Ta({},e,{viewOnly:!e.settings.user.canUserModifyDeRules})))),e.settings.dcda?.isAvailableForOrg&&(r=d.createElement(ua.A,{isEnabled:e.settings.dcda.isEnabled,saveDisputeAutomationSettings:e.saveDisputeAutomationSettings,disableBtn:!e.settings.user.canUserToggleDcda}),e.settings.user.canUserSeeCustomRules&&(s=d.createElement(Wt.A,Ta({},e,{viewOnly:!e.settings.user.canUserModifyCustomRules})))),e.user.siteAdmin&&null!==e.settings.evidenceMapEnabled&&void 0!==e.settings.evidenceMapEnabled&&(p=d.createElement(ya,{isEnabled:e.settings.evidenceMapEnabled})),e.settings.compellingEvidence?.isAvailableForOrg&&(e.settings.compellingEvidence.isEnabled&&(m=d.createElement(fa,e)),c=d.createElement(ga,{isEnabled:e.settings.compellingEvidence.isEnabled,saveCompellingEvidenceSettings:e.saveCompellingEvidenceSettings,customRulesCeEditor:m})),d.createElement("div",null,i,n,l,r,c,p,d.createElement(ra.A,e),d.createElement(Jt.A,e),o,s,d.createElement(Ra,e),d.createElement(Ia,e),d.createElement(Oa,e),a)}function Ma(e){const t=Ka[e.match.params.tab]?`${Ka[e.match.params.tab]} Settings`:"Settings";return d.createElement(v.d,{loading:e.loading,error:e.error,saving:e.saving,alerts:e.alerts,clearAlerts:e.clearAlerts,title:t,containerName:"team-sett
2ings",config:e.config,user:e.user},d.createElement(_a,e))}const Ua=["processors","payment","workflow","team","api","organization"],Ka={processors:"Processors",payment:"Payment",workflow:"Workflow",team:"Team",api:"Webhooks & API",organization:"Organization"};function _a(e){const t=e.match.params.tab||Ua[0],a=Boolean("owner"===e.user.state||e.user.siteAdmin),s=Ua.map((s=>{if("organization"===s&&!a)return null;const n=(0,m.A)({config:e.config,name:"organizationSettingsTab",params:[s]});return d.createElement("li",{key:s,className:g()({active:t===s})},d.createElement(E.N_,{to:n},Ka[s]))}));let n;return n="processors"===t?d.createElement(Ze,e):"payment"===t?d.createElement(we,e):"workflow"===t?d.createElement(ja,e):"team"===t?d.createElement(Yt,e):"api"===t?d.createElement(B,e):a&&"organization"===t?d.createElement(ne,e):d.createElement("div",{className:"app-block tight"},d.createElement("div",{className:"text-center loading-error"},d.createElement("div",null,d.createElement("h1",null,d.createElement("i",{className:"fa fa-frown-o fa-4x"})),d.createElement("h2",null,"Not found"),d.createElement("h3",null,"Looks like these settings don't exist."),d.createElement("br",null)))),d.createElement("div",null,d.createElement("hgroup",{className:"heading"},d.createElement("h3",{className:"text-center"},e.user.organization.name," Settings"),d.createElement("h4",{className:"text-center"},"Manage the settings for your team")),d.createElement("ul",{className:g()({"page-nav nav nav-pills":!0,owner:a})},s),n)}var za=a(95093),Fa=a.n(za),$a=a(10832);function Ba(){return Ba=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var s in a)({}).hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},Ba.apply(null,arguments)}function Va(e,t,a){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var a=e[Symbol.toPrimitive];if(void 0!==a){var s=a.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class qa extends d.Component{constructor(e){var t;super(e),t=this,Va(this,"setSaving",(e=>{this.setState({saving:e})})),Va(this,"addCredential",(e=>{this.setState((t=>{const a=t.settings,s=a.credentials;return s[e.processor]||(s[e.processor]=[]),s[e.processor].push(e),{settings:o()({},a,{credentials:s})}}))})),Va(this,"updateCredentials",((e,t)=>{this.setState((a=>{const s=a.settings,n=s.credentials;return Object.keys(n).some((a=>n[a].some((a=>a.hash===e&&(o()(a,t),!0))))),{settings:o()({},s,{credentials:n})}}))})),Va(this,"updateSettings",(e=>{this.setState({settings:r()({},this.state.settings,e,(function(e,t){if(Array.isArray(t))return t}))})})),Va(this,"updateSettingsKey",((e,t,a)=>{this.setState((a=>{n()(t)&&(t=t(a.settings[e]));const s=o()({},a.settings[e],t),i=o()({},a.settings,{[e]:s});return o()({},{settings:i})}),a)})),Va(this,"updateLastLoginTime",(()=>{this.setState({lastLogin:Fa().now()})})),Va(this,"addTemplateLogic",(e=>{let t=0;this.updateSettingsKey("templateSelectLogic",(e=>(e.rules.push({template:null,isNew:!0,rule:{left:"",right:"",op:"="}}),t=e.rules.length-1,e)),(()=>{n()(e)&&e(t)}))})),Va(this,"deleteTemplateLogic",((e,t)=>
2{this.updateSettingsKey("templateSelectLogic",(t=>(t.rules.splice(e,1),t)),(()=>{n()(t)&&t()}))})),Va(this,"updateTemplateLogic",((e,t,a)=>{this.updateSettingsKey("templateSelectLogic",(a=>(a.rules[e]=t,a)),(()=>{n()(a)&&a()}))})),Va(this,"setDefaultTemplate",((e,t)=>{this.updateSettingsKey("templateSelectLogic",(t=>(t.default=e,t)),(()=>{n()(t)&&t()}))})),Va(this,"saveTemplateLogic",(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const s=(0,m.A)({config:t.props.config,name:"settingsManualReviewJson"});t.setSaving(!0),(0,c.bE)(s,{"template-select-logic":t.state.settings.templateSelectLogic}).then((()=>{t.setSaving(!1),t.props.successAlert(e||"Template select rule saved."),n()(a)&&a(!0)})).catch((e=>{const s=e.json&&e.json.error?e.json.error.message:null;t.setSaving(!1),t.props.errorAlert(s||"Something went wrong, and we not could save your settings. Please try again."),n()(a)&&a(!1)}))})),Va(this,"saveQueueSettings",(e=>{const t=(0,m.A)({config:this.props.config,name:"settingsQueueJson"});return this.setSaving(!0),(0,c.bE)(t,e).then((()=>{this.setSaving(!1),this.props.successAlert("Queue settings saved."),this.updateSettingsKey("queue",e)})).catch((e=>{const t=e.json&&e.json.error?e.json.error.message:null;this.setSaving(!1),this.props.errorAlert(t||"Something went wrong, and we not could save your settings. Please try again.")}))})),Va(this,"saveAcceptOverdueSettings",(e=>{const t=(0,m.A)({config:this.props.config,name:"settingsAcceptOverdueJson"});return this.setSaving(!0),(0,c.bE)(t,e).then((()=>{this.setSaving(!1),this.props.successAlert("Accept overdue settings saved."),this.updateSettingsKey("acceptOverdue",e)})).catch((e=>{const t=e.json&&e.json.error?e.json.error.message:null;this.setSaving(!1),this.props.errorAlert(t||"Something went wrong, and we not could save your settings. Please try again.")}))})),Va(this,"saveDisputeAutomationSettings",(async()=>{const e=$a.v.DISPUTE_AUTOMATION;return await(0,$a.O)({config:this.props.config,routeName:e.routeName,currentState:this.state.settings.dcda.isEnabled,onStart:()=>this.setSaving(!0),onSuccess:(t,a)=>{this.props.successAlert(t),this.updateSettingsKey(e.settingsKey,{isEnabled:a})},onError:e=>this.props.errorAlert(e),onComplete:()=>this.setSaving(!1)})})),Va(this,"saveDisputeEvaluatorSettings",(async()=>{const e=$a.v.DISPUTE_EVALUATOR;return await(0,$a.O)({config:this.props.config,routeName:e.routeName,currentState:this.state.settings.disputeEvaluator.isEnabled,onStart:()=>this.setSaving(!0),onSuccess:(t,a)=>{this.props.successAlert(t),this.updateSettingsKey(e.settingsKey,{isEnabled:a})},onError:e=>this.props.errorAlert(e),onComplete:()=>this.setSaving(!1)})})),Va(this,"saveRapidDisputeResolutionSettings",(async()=>{const e=$a.v.RAPID_DISPUTE_RESOLUTION;return await(0,$a.O)({config:this.props.config,routeName:e.routeName,currentState:this.state.settings.rdr.isEnabled,onStart:()=>this.setSaving(!0),onSuccess:(t,a)=>{this.props.successAlert(t),this.updateSettingsKey(e.settingsKey,{isEnabled:a})},onError:e=>this.props.errorAlert(e),onComplete:()=>this.setSaving(!1)})})),Va(this,"saveCompellingEvidenceSettings",(async()=>{const e=$a.v.COMPELLING_EVIDENCE;return await(0,$a.O)({config:this.props.config,routeName:e.routeName,currentState:this.state.settings.compellingEvidence.isEnabled,onStart:()=>this.setSaving(!0),onSuccess:(t,a)=>{this.props.successAlert(t),this.updateSettingsKey(e.settingsKey,{isEnabled:a})},onError:e=>this.props.errorAlert(e),onComplete:()=>this.setSaving(!1)})})),Va(this,"saveMetadataFields",(e=>{const t=(0,m.A)({config:this.props.config,name:"settingsMetadataJson"});return this.setSaving(!0),(0,c.bE)(t,{metadata_fields:e}).then((()=>{this.setSaving(!1),this.props.successAlert("Metadata fields updated."),this.updateSettingsKey("metadataFields",e)})).catch((e=>{const t=e.json&&e.json.error?e.json.error.message:null;this.setSaving(!1),this.props.errorAlert(t||"Something went wrong, and we not could save your settings. Please try again.")}))})),Va(this,"linkAmexAccounts",((e,t)=>
2{this.setState({saving:!0});const a=(0,m.A)({config:this.props.config,name:"settingsLinkAmexAccountsJson"});(0,c.bE)(a,{hash:e.hash,selected:t}).then((e=>{this.setState({saving:!1}),e.success?(this.setState((t=>{const a=t.settings,s=a.credentials,n=e.credentials.reduce(((e,t)=>(e[t.hash]=t.linkedAmex,e)),{});return s.braintree.forEach((e=>{"live"===e.mode&&(e.linkedAmex=n[e.hash])})),{settings:o()({},a,{credentials:s})}})),this.props.successAlert("Successfully updated linked American Express accounts.")):this.props.errorAlert(e.message||"An unexpected error occurred.")})).catch((e=>{this.setState({saving:!1}),this.props.errorAlert(e.json.error.message||"An unexpected error occurred.")}))})),Va(this,"exportUsers",(()=>{const e=(0,m.A)({config:this.props.config,name:"exportUsersJson"});return(0,c.bE)(e).then((e=>{if(e.success)return this.props.infoAlert("Your CSV is being generated, please wait one moment..."),this.fetchUsersExport()})).catch((e=>{this.props.errorAlert(e.json.error.message||"An unexpected error occurred.")}))})),Va(this,"fetchUsersExport",(()=>{const e=(0,m.A)({config:this.props.config,name:"exportUsersJson"});return(0,c.Ay)(e,!0).then((e=>{if(e.success){window.open(e.url)||this.props.infoAlert(d.createElement("strong",null,d.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:e.url},"Your download is ready! Click here to view it.")))}}))})),this.state={settings:null,loading:!0,saving:!1,lastLogin:Fa().utc(e.user.lastLogin)}}componentDidMount(){this.load(this.props)}componentDidUpdate(e){e.location.key!==this.props.location.key&&(this.state.settings||this.load(this.props))}load(e){this.setState({loading:!0});const t=(0,m.A)({config:e.config,name:"organizationSettingsJson",params:[e.match.params.tab||"processors"]});(0,c.Ay)(t,!1,!1).then((e=>{const t=e.template_select_logic,a=e.templates_by_slug,s=e.custom_rules_dcda_fields,n=e.custom_rule_dcda_logic,i=e.custom_rule_de_logic,r=e.custom_rules_de_fields;(e=(0,u.camelizeKeys)(e)).invoices&&(e.invoices.upcoming&&(e.invoices.upcoming=(0,p.Sn)(e.invoices.upcoming,this.props.config)),e.invoices.data=(0,p.DS)(e.invoices.data,this.props.config)),e.templateSelectLogic=t,e.templatesBySlug=a,e.customRulesDcdaFields=s,e.customRuleDcdaLogic=n,e.customRuleDeLogic=i,e.customRulesDeFields=r,this.setState({settings:e,loading:!1})})).catch((e=>this.props.handleError(e)))}render(){return d.createElement(Ma,Ba({updateSettings:this.updateSettings,updateCredentials:this.updateCredentials,addCredential:this.addCredential,setS
2aving:this.setSaving,saveDisputeAutomationSettings:this.saveDisputeAutomationSettings,saveDisputeEvaluatorSettings:this.saveDisputeEvaluatorSettings,saveCompellingEvidenceSettings:this.saveCompellingEvidenceSettings,saveRapidDisputeResolutionSettings:this.saveRapidDisputeResolutionSettings,addTemplateLogic:this.addTemplateLogic,updateTemplateLogic:this.updateTemplateLogic,deleteTemplateLogic:this.deleteTemplateLogic,saveTemplateLogic:this.saveTemplateLogic,setDefaultTemplate:this.setDefaultTemplate,saveQueueSettings:this.saveQueueSettings,saveAcceptOverdueSettings:this.saveAcceptOverdueSettings,saveMetadataFields:this.saveMetadataFields,linkAmexAccounts:this.linkAmexAccounts,exportUsers:this.exportUsers,updateLastLoginTime:this.updateLastLoginTime},this.props,this.state))}}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.