var E=Object.defineProperty;var j=Object.getOwnPropertySymbols;var K=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable;var A=(i,s,n)=>s in i?E(i,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[s]=n,c=(i,s)=>{for(var n in s||(s={}))K.call(s,n)&&A(i,n,s[n]);if(j)for(var n of j(s))I.call(s,n)&&A(i,n,s[n]);return i};import{r as u,j as t}from"./main-406.js";import{_ as a,L as f,N as P,b as B,W as g}from"./bi.394.85.js";import{B as F}from"./bi.46.744.js";import{r as G}from"./bi.465.893.js";import{T as N,t as $}from"./bi.150.760.js";function q({lemlistConf:i,setLemlistConf:s,step:n,setstep:z,setSnackbar:_,isInfo:h,isLoading:l,setIsLoading:m}){const[d,T]=u.useState(!1),[b,x]=u.useState({name:"",api_key:""}),[v,w]=u.useState(!1),{lemlist:e}=$,S=()=>{const o=c({},i);if(!o.name||!o.api_key){x({name:o.name?"":a("Integration name cann't be empty","bit-integrations"),api_key:o.api_key?"":a("Access Api Key cann't be empty","bit-integrations")});return}m("auth");const p={api_key:o.api_key};B(p,"lemlist_authorize").then(r=>{if(r&&r.success){const k=c({},i);k.tokenDetails=r.data,s(k),T(!0),g.success(a("Authorized Successfully","bit-integrations"))}else r&&r.data&&r.data.data||!r.success&&typeof r.data=="string"?g.error(`${a("Authorization failed Cause:","bit-integrations")}${r.data.data||r.data}. ${a("please try again","bit-integrations")}`):g.error(a("Authorization failed. please try again","bit-integrations"));w(!0),m(!1)})},y=o=>{const p=c({},i),r=c({},b);r[o.target.name]="",p[o.target.name]=o.target.value,x(r),s(p)},L=()=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),G(i,s,m,_),z(2)},C=`
            <h4>Get Api key</h4>
            <ul>
                <li>First go to your Lemlist dashboard.</li>
                <li>Click on the "Team Setting" from sidebar</li>
                <li>Then Click "Integrations"</li>
                <li>Then click "Api", Then click "Generate Api Key"</li>
            </ul>`;return t.jsxs("div",{className:"btcd-stp-page",style:{width:n===1&&900,height:n===1&&"auto"},children:[(e==null?void 0:e.youTubeLink)&&t.jsx(N,{title:e==null?void 0:e.title,youTubeLink:e==null?void 0:e.youTubeLink}),(e==null?void 0:e.docLink)&&t.jsx(N,{title:e==null?void 0:e.title,docLink:e==null?void 0:e.docLink}),t.jsx("div",{className:"mt-3 wdt-200",children:t.jsx("b",{children:a("Integration Name:","bit-integrations")})}),t.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:y,name:"name",value:i.name,type:"text",placeholder:a("Integration Name...","bit-integrations"),disabled:h}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:b.name}),t.jsx("div",{className:"mt-3 wdt-250",children:t.jsx("b",{children:a("Access Api Key:","bit-integrations")})}),t.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:y,name:"api_key",value:i.api_key,type:"text",placeholder:a("Access Api Key...","bit-integrations"),disabled:h}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:b.api_key}),t.jsxs("small",{className:"d-blk mt-3",children:[a("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:a("Lemlist API Token","bit-integrations")})]}),t.jsx("br",{}),t.jsx("br",{}),l==="auth"&&t.jsxs("div",{className:"flx mt-5",children:[t.jsx(f,{size:25,clr:"#022217",className:"mr-2"}),"Checking Api Key!!!"]}),v&&!d&&!l&&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:"×"}),"Sorry, Api key is invalid"]}),!h&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:S,className:"btn btcd-btn-lg purple sh-sm flx",type:"button",disabled:d||l,children:[d?a("Authorized ✔","bit-integrations"):a("Authorize","bit-integrations"),l&&t.jsx(f,{size:20,clr:"#022217",className:"ml-2"})]}),t.jsx("br",{}),t.jsxs("button",{onClick:()=>L(),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",disabled:!d,children:[a("Next","bit-integrations"),t.jsx(F,{className:"ml-1 rev-icn"})]})]}),t.jsx(P,{note:C})]})}export{q as default};
