var I=Object.defineProperty;var j=Object.getOwnPropertySymbols;var P=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable;var A=(r,e,s)=>e in r?I(r,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[e]=s,h=(r,e)=>{for(var s in e||(e={}))P.call(e,s)&&A(r,s,e[s]);if(j)for(var s of j(e))T.call(e,s)&&A(r,s,e[s]);return r};import{_ as i,j as t,b as E}from"./main.2.8.10.js";import{b as x}from"./react-router.DMwpH23k.js";import{B as K}from"./BackIcn.BFDZx8No.js";import{y as _,a9 as R}from"./Note.DalStCGz.js";import{c as B,a as F}from"./ActiveCampaignCommonFunc.BGdNEPK9.js";import{T as U}from"./TutorialLink.D6K_DiHL.js";import"./react-vendor.P7K3d6op.js";import"./CopyIcn.BnhKHfEP.js";function Q({formID:r,activeCampaingConf:e,setActiveCampaingConf:s,step:g,setstep:N,setSnackbar:u,isInfo:l,isLoading:o,setIsLoading:c}){const[m,f]=x.useState(!1),[p,y]=x.useState({name:"",api_key:""}),[k,v]=x.useState(!1),z=()=>{const a=h({},e);if(!a.name||!a.api_key||!a.api_url){y({name:a.name?"":i("Integration name can't be empty","bit-integrations"),api_key:a.api_key?"":i("Access Api Key can't be empty","bit-integrations"),api_url:a.api_url?"":i("Access API URL can't be empty","bit-integrations")});return}c("auth");const d={api_key:a.api_key,api_url:a.api_url};E(d,"aCampaign_authorize").then(n=>{n!=null&&n.success&&(f(!0),u({show:!0,msg:i("Authorized Successfully","bit-integrations")})),v(!0),c(!1)})},b=a=>{const d=h({},e),n=h({},p);n[a.target.name]="",d[a.target.name]=a.target.value,y(n),s(d)},w=()=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),B(e,s,c,u),F(e,s,c,u),N(2)},S=`
            <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(U,{linkKey:"activeCampaign"}),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:b,name:"name",value:e.name,type:"text",placeholder:i("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:i("Access API URL:","bit-integrations")})}),t.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:b,name:"api_url",value:e.api_url,type:"text",placeholder:i("Access API URL...","bit-integrations"),disabled:l}),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:b,name:"api_key",value:e.api_key,type:"text",placeholder:i("Access API Key...","bit-integrations"),disabled:l}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:p.api_key}),o==="auth"&&t.jsxs("div",{className:"flx mt-5",children:[t.jsx(_,{size:25,clr:"#022217",className:"mr-2"}),i("Checking API Key!!!","bit-integrations")]}),k&&!m&&!o&&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")]}),!l&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:z,className:"btn btcd-btn-lg purple sh-sm flx",type:"button",disabled:m||o,children:[m?i("Authorized ✔","bit-integrations"):i("Authorize","bit-integrations"),o&&t.jsx(_,{size:20,clr:"#022217",className:"ml-2"})]}),t.jsx("br",{}),t.jsxs("button",{onClick:()=>w(),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",disabled:!m,children:[i("Next","bit-integrations"),t.jsx(K,{className:"ml-1 rev-icn"})]})]}),t.jsx(R,{note:S})]})}export{Q as default};
