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