var w=Object.defineProperty;var A=Object.getOwnPropertySymbols;var S=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable;var j=(a,s,i)=>s in a?w(a,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):a[s]=i,p=(a,s)=>{for(var i in s||(s={}))S.call(s,i)&&j(a,i,s[i]);if(A)for(var i of A(s))P.call(s,i)&&j(a,i,s[i]);return a};import{G as L,r as d,j as e,_ as r,L as E,bm as K,c as R}from"./main-343.js";import{t as _}from"./bf-974-82.js";import{a5 as C,a6 as T,a4 as U}from"./bf-659-81.js";function D({activeCampaingConf:a,setActiveCampaingConf:s,step:i,setstep:F,setSnackbar:b,isInfo:c,isLoading:u,setIsLoading:x,allIntegURL:g,authorizedAction:f}){const v=L(),[l,k]=d.useState(!1),[o,y]=d.useState({name:"",api_key:""}),[N,z]=d.useState(!1),I=()=>{const t=p({},a);if(!t.name||!t.api_key||!t.api_url){y({name:t.name?"":r("Integration name cann't be empty"),api_key:t.api_key?"":r("Access API Key cann't be empty"),api_url:t.api_url?"":r("Access API URL cann't be empty")});return}x("auth");const m={api_key:t.api_key,api_url:t.api_url};R(m,"bitforms_aCampaign_authorize").then(n=>{n!=null&&n.success&&(k(!0),b({show:!0,msg:r("Authorized Successfully")}),U(t),setTimeout(()=>{v(g)},1e3)),z(!0),x(!1)})},h=t=>{const m=p({},a),n=p({},o);n[t.target.name]="",m[t.target.name]=t.target.value,y(n),s(m)};return d.useEffect(()=>{l&&f()},[l]),e.jsxs(e.Fragment,{children:[e.jsx(C,{title:_.activeCampaign.title,youTubeLink:_.activeCampaign.link}),e.jsxs("div",{className:"btcd-stp-page",style:{width:900,height:"100%"},children:[e.jsx("div",{className:"mt-3 wdt-200",children:e.jsx("b",{children:r("Integration Name:")})}),e.jsx("input",{"aria-label":"Integration name",className:"btcd-paper-inp w-6 mt-1",onChange:h,name:"name",value:a.name,type:"text",placeholder:r("Integration Name..."),disabled:c}),e.jsx("div",{style:{color:"red",fontSize:"15px"},children:o.name}),e.jsx("div",{className:"mt-3 wdt-200",children:e.jsx("b",{children:r("Access API URL:")})}),e.jsx("input",{"aria-label":"Access API URL",className:"btcd-paper-inp w-6 mt-1",onChange:h,name:"api_url",value:a.api_url,type:"text",placeholder:r("Access API URL..."),disabled:c}),e.jsx("div",{style:{color:"red",fontSize:"15px"},children:o.api_url}),e.jsx("div",{className:"mt-3 wdt-200",children:e.jsx("b",{children:r("Access API Key:")})}),e.jsx("input",{"aria-label":"Access API Key",className:"btcd-paper-inp w-6 mt-1",onChange:h,name:"api_key",value:a.api_key,type:"text",placeholder:r("Access API Key..."),disabled:c}),e.jsx("div",{style:{color:"red",fontSize:"15px"},children:o.api_key}),u==="auth"&&e.jsxs("div",{className:"flx mt-5",children:[e.jsx(E,{size:25,clr:"#022217",className:"mr-2"}),"Checking API Key!!!"]}),N&&!l&&!u&&e.jsxs("div",{className:"flx mt-5",style:{color:"red"},children:[e.jsx("span",{className:"mr-2",style:{fontSize:30,marginTop:-5},children:e.jsx(K,{size:"15"})}),"Sorry, API key is invalid"]}),!c&&e.jsxs(e.Fragment,{children:[e.jsx(T,{isAuthorized:l,handleAuthorize:I,isLoading:u}),e.jsx("br",{})]})]})]})}export{D as default};
