var P=Object.defineProperty;var j=Object.getOwnPropertySymbols;var v=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable;var z=(t,a,s)=>a in t?P(t,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[a]=s,d=(t,a)=>{for(var s in a||(a={}))v.call(a,s)&&z(t,s,a[s]);if(j)for(var s of j(a))w.call(a,s)&&z(t,s,a[s]);return t};import{r as l,a as L,j as e,_ as n,L as S,aL as K,c as M}from"./main-40.js";import{t as b}from"./bf-892-199.js";import{T}from"./bf-679-136.js";import{A as B}from"./bf-541-403.js";import{N as F}from"./bf-504-404.js";import{a as H}from"./bf-683-372.js";/* empty css          */import"./bf-860-126.js";import"./bf-132-75.js";import"./bf-141-80.js";import"./bf-586-70.js";function Z({elasticEmailConf:t,setElasticEmailConf:a,step:s,setstep:k,isInfo:m}){const[o,x]=l.useState({authorized:!1,errorMsg:""}),[h,g]=l.useState({name:"",api_key:""}),[A,N]=l.useState(!1),[p,u]=l.useState(!1),{css:_}=L(),f=()=>{const r=d({},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 c={api_key:r.api_key};M(c,"bitforms_elasticemail_authorize").then(i=>{i!=null&&i.success?x({authorized:!0,errorMsg:""}):x({authorized:!1,errorMsg:(i==null?void 0:i.data)||""}),N(!0),u(!1)})},y=r=>{const c=d({},t),i=d({},h);i[r.target.name]="",c[r.target.name]=r.target.value,g(i),a(c)},I=()=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!(t!=null&&t.default)&&H(t,a,u),k(2)};return e.jsxs("div",{className:"btcd-stp-page",style:{width:s===1&&900,height:s===1&&"auto"},children:[e.jsx(T,{title:b.elasticemail.title,youTubeLink:b.elasticemail.link}),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 Key, Please Visit")," ",e.jsx("a",{className:"btcd-link",href:"https://elasticemail.com/account#/settings/new/manage-api",target:"_blank",rel:"noreferrer",children:n("Elastic Email API Console")})]}),p==="auth"&&e.jsxs("div",{className:"flx mt-5",children:[e.jsx(S,{size:25,clr:"#022217",className:"mr-2"}),"Checking API Key!!!"]}),A&&!o.authorized&&!p&&e.jsxs("div",{className:"flx mt-5",style:{color:"red"},children:[e.jsx(K,{size:"15",className:_({mr:10})})," ",o.errorMsg||"Couldn't authorize, Please check API Key"]}),!m&&e.jsxs(e.Fragment,{children:[e.jsx(B,{isAuthorized:o.authorized,isLoading:p,handleAuthorize:()=>f()}),e.jsx("br",{}),e.jsx(F,{nextPageHandler:()=>I(),disabled:!o.authorized})]})]})}export{Z as default};
