var z=Object.defineProperty;var x=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,S=Object.prototype.propertyIsEnumerable;var y=(e,s,a)=>s in e?z(e,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[s]=a,m=(e,s)=>{for(var a in s||(s={}))I.call(s,a)&&y(e,a,s[a]);if(x)for(var a of x(s))S.call(s,a)&&y(e,a,s[a]);return e};import{j as t,_ as i,b as w}from"./main.2.8.10.js";import{b as d}from"./react-router.DMwpH23k.js";import{B as P}from"./BackIcn.BFDZx8No.js";import{y as j}from"./Note.DalStCGz.js";import{a as T}from"./ElasticEmailCommonFunc.CE20DUPG.js";import{T as L}from"./TutorialLink.D6K_DiHL.js";import"./react-vendor.P7K3d6op.js";import"./CopyIcn.BnhKHfEP.js";function H({elasticEmailConf:e,setElasticEmailConf:s,step:a,setstep:k,isInfo:p}){const[o,N]=d.useState(!1),[h,g]=d.useState({name:"",api_key:""}),[f,A]=d.useState(!1),[l,b]=d.useState(!1),_=()=>{const n=m({},e);if(!n.name||!n.api_key){g({name:n.name?"":i("Integration name can't be empty","bit-integrations"),api_key:n.api_key?"":i("API Key can't be empty","bit-integrations")});return}b("auth");const c={api_key:n.api_key};w(c,"elasticemail_authorize").then(r=>{r!=null&&r.success&&N(!0),A(!0),b(!1)})},u=n=>{const c=m({},e),r=m({},h);r[n.target.name]="",c[n.target.name]=n.target.value,g(r),s(c)},v=()=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!(e!=null&&e.default)&&T(e,s,b),k(2)};return t.jsxs("div",{className:"btcd-stp-page",style:{width:a===1&&900,height:a===1&&"auto"},children:[t.jsx(L,{linkKey:"elasticEmail"}),t.jsx("div",{className:"mt-3",children:t.jsx("b",{children:i("Integration Name:","bit-integrations")})}),t.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:u,name:"name",value:e.name,type:"text",placeholder:i("Integration Name...","bit-integrations"),disabled:p}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:h.name}),t.jsx("div",{className:"mt-3",children:t.jsx("b",{children:i("API Key:","bit-integrations")})}),t.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:u,name:"api_key",value:e.api_key,type:"text",placeholder:i("Integration Name...","bit-integrations"),disabled:p}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:h.api_key}),t.jsxs("small",{className:"d-blk mt-5",children:[i("To get API , Please Visit","bit-integrations")," ",t.jsx("a",{className:"btcd-link",href:"https://elasticemail.com/account#/settings/new/manage-api",target:"_blank",rel:"noreferrer",children:i("Elastic Email API Console","bit-integrations")})]}),l==="auth"&&t.jsxs("div",{className:"flx mt-5",children:[t.jsx(j,{size:25,clr:"#022217",className:"mr-2"}),i("Checking API Key!!!","bit-integrations")]}),f&&!o&&!l&&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:"×"}),i("Sorry, Api key is invalid","bit-integrations")]}),!p&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:_,className:"btn btcd-btn-lg purple sh-sm flx",type:"button",disabled:o||l,children:[o?i("Authorized ✔","bit-integrations"):i("Authorize","bit-integrations"),l&&t.jsx(j,{size:20,clr:"#022217",className:"ml-2"})]}),t.jsx("br",{}),t.jsxs("button",{onClick:()=>v(),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",disabled:!o,children:[i("Next","bit-integrations"),t.jsx(P,{className:"ml-1 rev-icn"})]})]})]})}export{H as default};
