var K=Object.defineProperty;var j=Object.getOwnPropertySymbols;var $=Object.prototype.hasOwnProperty,D=Object.prototype.propertyIsEnumerable;var k=(r,i,a)=>i in r?K(r,i,{enumerable:!0,configurable:!0,writable:!0,value:a}):r[i]=a,c=(r,i)=>{for(var a in i||(i={}))$.call(i,a)&&k(r,a,i[a]);if(j)for(var a of j(i))D.call(i,a)&&k(r,a,i[a]);return r};import{_ as e,j as t,b as P,q as u}from"./main.2.8.10.js";import{b as g}from"./react-router.DMwpH23k.js";import{B as E}from"./BackIcn.BFDZx8No.js";import{y as f,a9 as C}from"./Note.DalStCGz.js";import{r as M}from"./MailifyCommonFunc.f8BlnkEU.js";import{T as B}from"./TutorialLink.D6K_DiHL.js";import"./react-vendor.P7K3d6op.js";import"./CopyIcn.BnhKHfEP.js";function U({formID:r,mailifyConf:i,setMailifyConf:a,step:x,setstep:N,setSnackbar:_,isInfo:o,isLoading:l,setIsLoading:h}){const[d,v]=g.useState(!1),[m,y]=g.useState({name:"",api_key:""}),[z,w]=g.useState(!1),I=()=>{const n=c({},i);if(!n.name||!n.api_key){y({name:n.name?"":e("Integration name can't be empty","bit-integrations"),account_id:n.account_id?"":e("Access Account ID can't be empty","bit-integrations"),api_key:n.api_key?"":e("Access Api Key can't be empty","bit-integrations")});return}h("auth");const p={account_id:n.account_id,api_key:n.api_key};P(p,"mailify_authorize").then(s=>{if(s&&s.success){const A=c({},i);A.tokenDetails=s.data,a(A),v(!0),u.success(e("Authorized Successfully","bit-integrations"))}else s&&s.data&&s.data.data||!s.success&&typeof s.data=="string"?u.error(`${e("Authorization failed Cause:","bit-integrations")}${s.data.data||s.data}. ${e("please try again","bit-integrations")}`):u.error(e("Authorization failed. please try again","bit-integrations"));w(!0),h(!1)})},b=n=>{const p=c({},i),s=c({},m);s[n.target.name]="",p[n.target.name]=n.target.value,y(s),a(p)},S=()=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),M(i,a,h,_),N(2)},T=`
            <h4>${e("Get Account Id and Api key","bit-integrations")}</h4>
            <ul>
                <li>${e("First go to your Mailify dashboard.","bit-integrations")}</li>
                <li>${e('Click on the "Settings" from Top-Right corner dropdown',"bit-integrations")}</li>
                <li>${e('Then Click "Developers", Then click "Add an Api Key"',"bit-integrations")}</li>
            </ul>`;return t.jsxs("div",{className:"btcd-stp-page",style:{width:x===1&&900,height:x===1&&"auto"},children:[t.jsx(B,{linkKey:"mailify"}),t.jsx("div",{className:"mt-3 wdt-200",children:t.jsx("b",{children:e("Integration Name:","bit-integrations")})}),t.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:b,name:"name",value:i.name,type:"text",placeholder:e("Integration Name...","bit-integrations"),disabled:o}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:m.name}),t.jsx("div",{className:"mt-3 wdt-200",children:t.jsx("b",{children:e("Access Account ID:","bit-integrations")})}),t.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:b,name:"account_id",value:i.account_id,type:"text",placeholder:e("Access Account ID...","bit-integrations"),disabled:o}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:m.account_id}),t.jsx("div",{className:"mt-3 wdt-250",children:t.jsx("b",{children:e("Access API Key:","bit-integrations")})}),t.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:b,name:"api_key",value:i.api_key,type:"text",placeholder:e("Access API Key...","bit-integrations"),disabled:o}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:m.api_key}),t.jsxs("small",{className:"d-blk mt-3",children:[e("To Get Account Id and Api Key, Please Visit","bit-integrations")," ",t.jsx("a",{className:"btcd-link",href:"https://app.mailify.com/#!/p/home",target:"_blank",rel:"noreferrer",children:e("Mailify API Token","bit-integrations")})]}),t.jsx("br",{}),t.jsx("br",{}),l==="auth"&&t.jsxs("div",{className:"flx mt-5",children:[t.jsx(f,{size:25,clr:"#022217",className:"mr-2"}),e("Checking API Key!!!","bit-integrations")]}),z&&!d&&!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:"×"}),e("Sorry, Api key is invalid","bit-integrations")]}),!o&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:I,className:"btn btcd-btn-lg purple sh-sm flx",type:"button",disabled:d||l,children:[d?e("Authorized ✔","bit-integrations"):e("Authorize","bit-integrations"),l&&t.jsx(f,{size:20,clr:"#022217",className:"ml-2"})]}),t.jsx("br",{}),t.jsxs("button",{onClick:()=>S(),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",disabled:!d,children:[e("Next","bit-integrations"),t.jsx(E,{className:"ml-1 rev-icn"})]})]}),t.jsx(C,{note:T})]})}export{U as default};
