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