var C=Object.defineProperty;var j=Object.getOwnPropertySymbols;var P=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable;var k=(i,s,a)=>s in i?C(i,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):i[s]=a,l=(i,s)=>{for(var a in s||(s={}))P.call(s,a)&&k(i,a,s[a]);if(j)for(var a of j(s))$.call(s,a)&&k(i,a,s[a]);return i};import{_ as e,j as t,b as K,q as g}from"./main.2.9.0.js";import{b as u}from"./react-router.DMwpH23k.js";import{B as T}from"./BackIcn._8Wofmn2.js";import{y as A,a9 as E}from"./Note.NSUdvR3c.js";import{r as B}from"./CampaignMonitorCommonFunc.DqevWaHC.js";import{T as F}from"./TutorialLink.CFG7bS5c.js";import"./react-vendor.P7K3d6op.js";import"./CopyIcn.CEA_lFLo.js";function O({campaignMonitorConf:i,setCampaignMonitorConf:s,step:a,setstep:f,setSnackbar:_,isInfo:o,isLoading:c,setIsLoading:b}){const[d,N]=u.useState(!1),[m,x]=u.useState({name:"",api_key:""}),[v,z]=u.useState(!1),w=()=>{const n=l({},i);if(!n.name||!n.client_id||!n.api_key){x({name:n.name?"":e("Integration name can't be empty","bit-integrations"),client_id:n.client_id?"":e("Client Id can't be empty","bit-integrations"),api_key:n.api_key?"":e("Access Api Key can't be empty","bit-integrations")});return}b("auth");const p={api_key:n.api_key,client_id:n.client_id};K(p,"campaign_monitor_authorize").then(r=>{if(r&&r.success){const y=l({},i);y.tokenDetails=r.data,s(y),N(!0),g.success(e("Authorized Successfully","bit-integrations"))}else r&&r.data||!r.success&&typeof r.data.Message=="string"?g.error(`${e("Authorization failed Cause:","bit-integrations")}${r.data.Message}. ${e("please try again","bit-integrations")}`):g.error(e("Authorization failed. please try again","bit-integrations"));z(!0),b(!1)})},h=n=>{const p=l({},i),r=l({},m);r[n.target.name]="",p[n.target.name]=n.target.value,x(r),s(p)},I=()=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),B(i,s,b,_),f(2)},S=`
            <h4>${e("Get Client Id & Api key","bit-integrations")}</h4>
            <ul>
                <li>${e("First go to your CampaignMonitor dashboard.","bit-integrations")}</li>
                <li>${e('Click on Your "Profile Image" at the top right',"bit-integrations")}</li>
                <li>${e('Click on the "Account Settings"',"bit-integrations")}</li>
                <li>${e('Then Click "API keys"',"bit-integrations")}</li>
            </ul>`;return t.jsxs("div",{className:"btcd-stp-page",style:{width:a===1&&900,height:a===1&&"auto"},children:[t.jsx(F,{linkKey:"campaignMonitor"}),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:h,name:"name",value:i.name,type:"text",placeholder:e("Integration Name...","bit-integrations"),disabled:o}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:m.name}),t.jsx("div",{className:"mt-3 wdt-250",children:t.jsx("b",{children:e("Client id:","bit-integrations")})}),t.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:h,name:"client_id",value:i.client_id,type:"text",placeholder:e("client ID...","bit-integrations"),disabled:o}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:m.client_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:h,name:"api_key",value:i.api_key,type:"text",placeholder:e("Access API Key...","bit-integrations"),disabled:o}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:m.api_key}),t.jsxs("small",{className:"d-blk mt-3",children:[e("To Get Client Id & Api Key, Please Visit","bit-integrations")," ",t.jsx("a",{className:"btcd-link",href:"https://bitcode2.createsend.com/account/apikeys",target:"_blank",rel:"noreferrer",children:e("Campaign Monitor API Key","bit-integrations")})]}),t.jsx("br",{}),t.jsx("br",{}),c==="auth"&&t.jsxs("div",{className:"flx mt-5",children:[t.jsx(A,{size:25,clr:"#022217",className:"mr-2"}),e("Checking API Key!!!","bit-integrations")]}),v&&!d&&!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:"×"}),e("Sorry, Api key is invalid","bit-integrations")]}),!o&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:w,className:"btn btcd-btn-lg purple sh-sm flx",type:"button",disabled:d||c,children:[d?e("Authorized ✔","bit-integrations"):e("Authorize","bit-integrations"),c&&t.jsx(A,{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:!d,children:[e("Next","bit-integrations"),t.jsx(T,{className:"ml-1 rev-icn"})]})]}),t.jsx(E,{note:S})]})}export{O as default};
