var P=Object.defineProperty;var A=Object.getOwnPropertySymbols;var E=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable;var k=(a,e,s)=>e in a?P(a,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[e]=s,h=(a,e)=>{for(var s in e||(e={}))E.call(e,s)&&k(a,s,e[s]);if(A)for(var s of A(e))L.call(e,s)&&k(a,s,e[s]);return a};import{_ as i,j as t,d as K}from"./main.2.8.1.js";import{d as y}from"./react-router-dom.9mCuUg3q.js";import{B as R}from"./BackIcn._kGL_vVw.js";import{z as _,a9 as B}from"./Note.BeM7sN-p.js";import{c as F,a as U}from"./ActiveCampaignCommonFunc.COwV6A41.js";import{T as N}from"./TutorialLink.BAFX--T3.js";import{t as $}from"./tutorialLinks.kMkIDzcD.js";import"./CopyIcn.3gZpHton.js";function W({formID:a,activeCampaingConf:e,setActiveCampaingConf:s,step:g,setstep:f,setSnackbar:b,isInfo:o,isLoading:c,setIsLoading:d}){const{activeCampaign:n}=$,[m,z]=y.useState(!1),[p,j]=y.useState({name:"",api_key:""}),[w,v]=y.useState(!1),S=()=>{const r=h({},e);if(!r.name||!r.api_key||!r.api_url){j({name:r.name?"":i("Integration name can't be empty","bit-integrations"),api_key:r.api_key?"":i("Access Api Key can't be empty","bit-integrations"),api_url:r.api_url?"":i("Access API URL can't be empty","bit-integrations")});return}d("auth");const u={api_key:r.api_key,api_url:r.api_url};K(u,"aCampaign_authorize").then(l=>{l!=null&&l.success&&(z(!0),b({show:!0,msg:i("Authorized Successfully","bit-integrations")})),v(!0),d(!1)})},x=r=>{const u=h({},e),l=h({},p);l[r.target.name]="",u[r.target.name]=r.target.value,j(l),s(u)},I=()=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),F(e,s,d,b),U(e,s,d,b),f(2)},T=`
            <h4>${i("Get api url and api key","bit-integrations")}</h4>
            <ul>
                <li>${i("First go to activeCampaign your dashboard.","bit-integrations")}</li>
                <li>${i("Click Settings, Then click Developer","bit-integrations")}"</li>
            </ul>`;return t.jsxs("div",{className:"btcd-stp-page",style:{width:g===1&&900,height:g===1&&"auto"},children:[t.jsx(N,{title:"ActiveCampaign",youTubeLink:n==null?void 0:n.youTubeLink}),t.jsx(N,{title:"ActiveCampaign",docLink:n==null?void 0:n.docLink}),t.jsx("div",{className:"mt-3 wdt-200",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:e.name,type:"text",placeholder:i("Integration Name...","bit-integrations"),disabled:o}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:p.name}),t.jsx("div",{className:"mt-3 wdt-200",children:t.jsx("b",{children:i("Access API URL:","bit-integrations")})}),t.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:x,name:"api_url",value:e.api_url,type:"text",placeholder:i("Access API URL...","bit-integrations"),disabled:o}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:p.api_url}),t.jsx("div",{className:"mt-3 wdt-200",children:t.jsx("b",{children:i("Access 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:i("Access API Key...","bit-integrations"),disabled:o}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:p.api_key}),c==="auth"&&t.jsxs("div",{className:"flx mt-5",children:[t.jsx(_,{size:25,clr:"#022217",className:"mr-2"}),i("Checking API Key!!!","bit-integrations")]}),w&&!m&&!c&&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:"×"}),i("Sorry, Api key is invalid","bit-integrations")]}),!o&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:S,className:"btn btcd-btn-lg purple sh-sm flx",type:"button",disabled:m||c,children:[m?i("Authorized ✔","bit-integrations"):i("Authorize","bit-integrations"),c&&t.jsx(_,{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:!m,children:[i("Next","bit-integrations"),t.jsx(R,{className:"ml-1 rev-icn"})]})]}),t.jsx(B,{note:T})]})}export{W as default};
