var v=Object.defineProperty;var j=Object.getOwnPropertySymbols;var P=Object.prototype.hasOwnProperty,S=Object.prototype.propertyIsEnumerable;var f=(t,a,s)=>a in t?v(t,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[a]=s,l=(t,a)=>{for(var s in a||(a={}))P.call(a,s)&&f(t,s,a[s]);if(j)for(var s of j(a))S.call(a,s)&&f(t,s,a[s]);return t};import{r as c,j as e,_ as n,L as w,bm as E,c as L}from"./main-343.js";import{t as b}from"./bf-974-82.js";import{a5 as T,a6 as B}from"./bf-659-81.js";import{N as F}from"./bf-713-109.js";import{r as K}from"./bf-66-176.js";import"./bf-649-79.js";function D({enchargeConf:t,setEnchargeConf:a,step:s,setstep:k,setSnackbar:x,isInfo:m}){const[d,A]=c.useState(!1),[h,g]=c.useState({name:"",api_key:""}),[N,_]=c.useState(!1),[p,u]=c.useState(!1),z=()=>{const r=l({},t);if(!r.name||!r.api_key){g({name:r.name?"":n("Integration name cann't be empty"),api_key:r.api_key?"":n("API Key cann't be empty")});return}u("auth");const o={api_key:r.api_key};L(o,"bitforms_encharge_authorize").then(i=>{i!=null&&i.success&&(A(!0),x({show:!0,msg:n("Authorized Successfully")})),_(!0),u(!1)})},y=r=>{const o=l({},t),i=l({},h);i[r.target.name]="",o[r.target.name]=r.target.value,g(i),a(o)},I=()=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),k(2),K(t,a,u,x)};return e.jsxs(e.Fragment,{children:[e.jsx(T,{title:b.encharge.title,youTubeLink:b.encharge.link}),e.jsxs("div",{className:"btcd-stp-page",style:{width:s===1&&900,height:s===1&&"100%"},children:[e.jsx("div",{className:"mt-3",children:e.jsx("b",{children:n("Integration Name:")})}),e.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:y,name:"name",value:t.name,type:"text",placeholder:n("Integration Name..."),disabled:m}),e.jsx("div",{style:{color:"red",fontSize:"15px"},children:h.name}),e.jsx("div",{className:"mt-3",children:e.jsx("b",{children:n("API Key:")})}),e.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:y,name:"api_key",value:t.api_key,type:"text",placeholder:n("API key"),disabled:m}),e.jsx("div",{style:{color:"red",fontSize:"15px"},children:h.api_key}),e.jsxs("small",{className:"d-blk mt-5",children:[n("To get API , Please Visit")," ",e.jsx("a",{className:"btcd-link",href:"https://app.encharge.io/account/info",target:"_blank",rel:"noreferrer",children:n("Encharge API Console")})]}),p==="auth"&&e.jsxs("div",{className:"flx mt-5",children:[e.jsx(w,{size:25,clr:"#022217",className:"mr-2"}),"Checking API Key!!!"]}),N&&!d&&!p&&e.jsxs("div",{className:"flx mt-5",style:{color:"red"},children:[e.jsx("span",{className:" mr-2",style:{fontSize:30,marginTop:-5},children:e.jsx(E,{size:"15"})}),"Sorry, API key is invalid"]}),!m&&e.jsxs(e.Fragment,{children:[e.jsx(B,{isAuthorized:d,isLoading:p,handleAuthorize:()=>z()}),e.jsx("br",{}),e.jsx(F,{nextPageHandler:()=>I(),disabled:!d})]})]})]})}export{D as default};
