var K=Object.defineProperty;var k=Object.getOwnPropertySymbols;var M=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable;var f=(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={}))M.call(i,a)&&f(r,a,i[a]);if(k)for(var a of k(i))P.call(i,a)&&f(r,a,i[a]);return r};import{_ as e,j as t,d as E,q as g}from"./main.2.8.1.js";import{d as x}from"./react-router-dom.9mCuUg3q.js";import{B as C}from"./BackIcn._kGL_vVw.js";import{z as N,a9 as B}from"./Note.BeM7sN-p.js";import{r as F}from"./MailifyCommonFunc.CudAWY6J.js";import{t as L}from"./tutorialLinks.kMkIDzcD.js";import{T as _}from"./TutorialLink.BAFX--T3.js";import"./CopyIcn.3gZpHton.js";function W({formID:r,mailifyConf:i,setMailifyConf:a,step:y,setstep:v,setSnackbar:z,isInfo:l,isLoading:d,setIsLoading:h}){const{mailify:o}=L,[m,w]=x.useState(!1),[p,A]=x.useState({name:"",api_key:""}),[S,I]=x.useState(!1),T=()=>{const n=c({},i);if(!n.name||!n.api_key){A({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 b={account_id:n.account_id,api_key:n.api_key};E(b,"mailify_authorize").then(s=>{if(s&&s.success){const j=c({},i);j.tokenDetails=s.data,a(j),w(!0),g.success(e("Authorized Successfully","bit-integrations"))}else s&&s.data&&s.data.data||!s.success&&typeof s.data=="string"?g.error(`${e("Authorization failed Cause:","bit-integrations")}${s.data.data||s.data}. ${e("please try again","bit-integrations")}`):g.error(e("Authorization failed. please try again","bit-integrations"));I(!0),h(!1)})},u=n=>{const b=c({},i),s=c({},p);s[n.target.name]="",b[n.target.name]=n.target.value,A(s),a(b)},$=()=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),F(i,a,h,z),v(2)},D=`
            <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:y===1&&900,height:y===1&&"auto"},children:[t.jsx(_,{title:"Mailify (Sarbacane)",youTubeLink:o==null?void 0:o.youTubeLink}),t.jsx(_,{title:"Mailify (Sarbacane)",docLink:o==null?void 0:o.docLink}),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:u,name:"name",value:i.name,type:"text",placeholder:e("Integration Name...","bit-integrations"),disabled:l}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:p.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:u,name:"account_id",value:i.account_id,type:"text",placeholder:e("Access Account ID...","bit-integrations"),disabled:l}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:p.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:u,name:"api_key",value:i.api_key,type:"text",placeholder:e("Access API Key...","bit-integrations"),disabled:l}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:p.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",{}),d==="auth"&&t.jsxs("div",{className:"flx mt-5",children:[t.jsx(N,{size:25,clr:"#022217",className:"mr-2"}),e("Checking API Key!!!","bit-integrations")]}),S&&!m&&!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:"×"}),e("Sorry, Api key is invalid","bit-integrations")]}),!l&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:T,className:"btn btcd-btn-lg purple sh-sm flx",type:"button",disabled:m||d,children:[m?e("Authorized ✔","bit-integrations"):e("Authorize","bit-integrations"),d&&t.jsx(N,{size:20,clr:"#022217",className:"ml-2"})]}),t.jsx("br",{}),t.jsxs("button",{onClick:()=>$(),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",disabled:!m,children:[e("Next","bit-integrations"),t.jsx(C,{className:"ml-1 rev-icn"})]})]}),t.jsx(B,{note:D})]})}export{W as default};
