var E=Object.defineProperty;var f=Object.getOwnPropertySymbols;var L=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable;var k=(n,e,i)=>e in n?E(n,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[e]=i,d=(n,e)=>{for(var i in e||(e={}))L.call(e,i)&&k(n,i,e[i]);if(f)for(var i of f(e))P.call(e,i)&&k(n,i,e[i]);return n};import{j as t,_ as s,d as T}from"./main.2.8.1.js";import{d as p}from"./react-router-dom.9mCuUg3q.js";import{B}from"./BackIcn._kGL_vVw.js";import{z as N}from"./Note.BeM7sN-p.js";import{r as C}from"./EnchargeCommonFunc.1cTg0e70.js";import{t as K}from"./tutorialLinks.kMkIDzcD.js";import{T as A}from"./TutorialLink.BAFX--T3.js";import"./CopyIcn.3gZpHton.js";function O({formID:n,enchargeConf:e,setEnchargeConf:i,step:g,setstep:z,setSnackbar:x,isInfo:h}){const[l,_]=p.useState(!1),[u,y]=p.useState({name:"",api_key:""}),[v,I]=p.useState(!1),[c,b]=p.useState(!1),{encharge:r}=K,S=()=>{const a=d({},e);if(!a.name||!a.api_key){y({name:a.name?"":s("Integration name can't be empty","bit-integrations"),api_key:a.api_key?"":s("API Key can't be empty","bit-integrations")});return}b("auth");const m={api_key:a.api_key};T(m,"encharge_authorize").then(o=>{o!=null&&o.success&&(_(!0),x({show:!0,msg:s("Authorized Successfully","bit-integrations")})),I(!0),b(!1)})},j=a=>{const m=d({},e),o=d({},u);o[a.target.name]="",m[a.target.name]=a.target.value,y(o),i(m)},w=()=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),z(2),C(e,i,b,x)};return t.jsxs("div",{className:"btcd-stp-page",style:{width:g===1&&900,height:g===1&&"auto"},children:[t.jsx(A,{title:"Encharge",youTubeLink:r==null?void 0:r.youTubeLink}),t.jsx(A,{title:"Encharge",docLink:r==null?void 0:r.docLink}),t.jsx("div",{className:"mt-3",children:t.jsx("b",{children:s("Integration Name:","bit-integrations")})}),t.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:j,name:"name",value:e.name,type:"text",placeholder:s("Integration Name...","bit-integrations"),disabled:h}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:u.name}),t.jsx("div",{className:"mt-3",children:t.jsx("b",{children:s("API Key:","bit-integrations")})}),t.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:j,name:"api_key",value:e.api_key,type:"text",placeholder:s("API key","bit-integrations"),disabled:h}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:u.api_key}),t.jsxs("small",{className:"d-blk mt-5",children:[s("To get API , Please Visit","bit-integrations")," ",t.jsx("a",{className:"btcd-link",href:"https://app.encharge.io/account/info",target:"_blank",rel:"noreferrer",children:s("Encharge API Console","bit-integrations")})]}),c==="auth"&&t.jsxs("div",{className:"flx mt-5",children:[t.jsx(N,{size:25,clr:"#022217",className:"mr-2"}),s("Checking API Key!!!","bit-integrations")]}),v&&!l&&!c&&t.jsxs("div",{className:"flx mt-5",style:{color:"red"},children:[t.jsx("span",{className:"btcd-icn mr-2",style:{fontSize:30,marginTop:-5},children:"×"}),s("Sorry, Api key is invalid","bit-integrations")]}),!h&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:S,className:"btn btcd-btn-lg purple sh-sm flx",type:"button",disabled:l||c,children:[l?s("Authorized ✔","bit-integrations"):s("Authorize","bit-integrations"),c&&t.jsx(N,{size:20,clr:"#022217",className:"ml-2"})]}),t.jsx("br",{}),t.jsxs("button",{onClick:()=>w(),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",disabled:!l,children:[s("Next","bit-integrations"),t.jsx(B,{className:"ml-1 rev-icn"})]})]})]})}export{O as default};
