var I=Object.defineProperty;var j=Object.getOwnPropertySymbols;var $=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable;var k=(i,a,s)=>a in i?I(i,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[a]=s,o=(i,a)=>{for(var s in a||(a={}))$.call(a,s)&&k(i,s,a[s]);if(j)for(var s of j(a))P.call(a,s)&&k(i,s,a[s]);return i};import{_ as e,j as t,b as C,q as h}from"./main.2.8.10.js";import{b as g}from"./react-router.DMwpH23k.js";import{B as E}from"./BackIcn.BFDZx8No.js";import{y as f,a9 as K}from"./Note.DalStCGz.js";import{r as B}from"./LemlistCommonFunc.CHjvQLct.js";import{T as F}from"./TutorialLink.D6K_DiHL.js";import"./react-vendor.P7K3d6op.js";import"./CopyIcn.BnhKHfEP.js";function U({lemlistConf:i,setLemlistConf:a,step:s,setstep:A,setSnackbar:N,isInfo:d,isLoading:c,setIsLoading:p}){const[l,z]=g.useState(!1),[b,u]=g.useState({name:"",api_key:""}),[_,v]=g.useState(!1),w=()=>{const r=o({},i);if(!r.name||!r.api_key){u({name:r.name?"":e("Integration name can't be empty","bit-integrations"),api_key:r.api_key?"":e("Access Api Key can't be empty","bit-integrations")});return}p("auth");const m={api_key:r.api_key};C(m,"lemlist_authorize").then(n=>{if(n&&n.success){const y=o({},i);y.tokenDetails=n.data,a(y),z(!0),h.success(e("Authorized Successfully","bit-integrations"))}else n&&n.data&&n.data.data||!n.success&&typeof n.data=="string"?h.error(`${e("Authorization failed Cause:","bit-integrations")}${n.data.data||n.data}. ${e("please try again","bit-integrations")}`):h.error(e("Authorization failed. please try again","bit-integrations"));v(!0),p(!1)})},x=r=>{const m=o({},i),n=o({},b);n[r.target.name]="",m[r.target.name]=r.target.value,u(n),a(m)},S=()=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),B(i,a,p,N),A(2)},T=`
            <h4>${e("Get Api key","bit-integrations")}</h4>
            <ul>
                <li>${e("First go to your Lemlist dashboard.","bit-integrations")}</li>
                <li>${e('Click on the "Team Setting" from sidebar',"bit-integrations")}</li>
                <li>${e('Then Click "Integrations"',"bit-integrations")}</li>
                <li>${e('Then click "Api", Then click "Generate Api Key"',"bit-integrations")}</li>
            </ul>`;return t.jsxs("div",{className:"btcd-stp-page",style:{width:s===1&&900,height:s===1&&"auto"},children:[t.jsx(F,{linkKey:"lemlist"}),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:x,name:"name",value:i.name,type:"text",placeholder:e("Integration Name...","bit-integrations"),disabled:d}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:b.name}),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:x,name:"api_key",value:i.api_key,type:"text",placeholder:e("Access API Key...","bit-integrations"),disabled:d}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:b.api_key}),t.jsxs("small",{className:"d-blk mt-3",children:[e("To get API key, please visit","bit-integrations")," ",t.jsx("a",{className:"btcd-link",href:"https://api.lemlist.com/teams/tea_beEpCu2irsJfn3PJr/settings/integrations#api",target:"_blank",rel:"noreferrer",children:e("Lemlist API Token","bit-integrations")})]}),t.jsx("br",{}),t.jsx("br",{}),c==="auth"&&t.jsxs("div",{className:"flx mt-5",children:[t.jsx(f,{size:25,clr:"#022217",className:"mr-2"}),e("Checking API Key!!!","bit-integrations")]}),_&&!l&&!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")]}),!d&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:w,className:"btn btcd-btn-lg purple sh-sm flx",type:"button",disabled:l||c,children:[l?e("Authorized ✔","bit-integrations"):e("Authorize","bit-integrations"),c&&t.jsx(f,{size:20,clr:"#022217",className:"ml-2"})]}),t.jsx("br",{}),t.jsxs("button",{onClick:()=>S(),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",disabled:!l,children:[e("Next","bit-integrations"),t.jsx(E,{className:"ml-1 rev-icn"})]})]}),t.jsx(K,{note:T})]})}export{U as default};
