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