var C=Object.defineProperty;var f=Object.getOwnPropertySymbols;var K=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable;var A=(a,s,i)=>s in a?C(a,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):a[s]=i,d=(a,s)=>{for(var i in s||(s={}))K.call(s,i)&&A(a,i,s[i]);if(f)for(var i of f(s))E.call(s,i)&&A(a,i,s[i]);return a};import{_ as e,s as N,j as t,d as F}from"./main.2.8.1.js";import{d as u}from"./react-router-dom.9mCuUg3q.js";import{B}from"./BackIcn._kGL_vVw.js";import{z as k,a9 as $}from"./Note.BeM7sN-p.js";import{r as G}from"./ConvertKitCommonFunc.CHf5MZxu.js";import{t as L}from"./tutorialLinks.kMkIDzcD.js";import{T as S}from"./TutorialLink.BAFX--T3.js";import"./CopyIcn.3gZpHton.js";function U({formID:a,convertKitConf:s,setConvertKitConf:i,step:x,setstep:_,setSnackbar:g,isInfo:p,isLoading:o,setIsLoading:h}){const{convertKit:n}=L,[l,v]=u.useState(!1),[b,j]=u.useState({name:"",api_secret:""}),[z,w]=u.useState(!1),I=()=>{const r=d({},s);if(!r.name||!r.api_secret){j({name:r.name?"":e("Integration name can't be empty","bit-integrations"),api_secret:r.api_secret?"":e("Access API Secret Key can't be empty","bit-integrations")});return}h("auth");const m={api_secret:r.api_secret};F(m,"convertKit_authorize").then(c=>{c!=null&&c.success&&(v(!0),g({show:!0,msg:e("Authorized Successfully","bit-integrations")})),w(!0),h(!1)})},y=r=>{const m=d({},s),c=d({},b);c[r.target.name]="",m[r.target.name]=r.target.value,j(c),i(m)},T=()=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),G(s,i,h,g),_(2)},P=`
            <h4>${e("Get api secret key","bit-integrations")}</h4>
            <ul>
                <li>${N(e("First go to your %s dashboard.","bit-integrations"),"Kit(ConvertKit)")}</li>
                <li>${e('Click "Settings", Then click "Advanced"',"bit-integrations")}</li>
            </ul>`;return t.jsxs("div",{className:"btcd-stp-page",style:{width:x===1&&900,height:x===1&&"auto"},children:[t.jsx(S,{title:"ConvertKit",youTubeLink:n==null?void 0:n.youTubeLink}),t.jsx(S,{title:"ConvertKit",docLink:n==null?void 0:n.docLink}),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:y,name:"name",value:s.name,type:"text",placeholder:e("Integration Name...","bit-integrations"),disabled:p}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:b.name}),t.jsx("div",{className:"mt-3 wdt-200",children:t.jsx("b",{children:e("Access API Secret Key:","bit-integrations")})}),t.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:y,name:"api_secret",value:s.api_secret,type:"text",placeholder:e("Access API Secret Key...","bit-integrations"),disabled:p}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:b.api_secret}),t.jsxs("small",{className:"d-blk mt-3",children:[e("To Get API Secret Key, Please Visit","bit-integrations")," ",t.jsx("a",{className:"btcd-link",href:"https://app.convertkit.com/account_settings/advanced_settings",target:"_blank",rel:"noreferrer",children:N(e("%s API Token","bit-integrations"),"Kit(ConvertKit)")})]}),t.jsx("br",{}),t.jsx("br",{}),o==="auth"&&t.jsxs("div",{className:"flx mt-5",children:[t.jsx(k,{size:25,clr:"#022217",className:"mr-2"}),e("Checking API Secret Key","bit-integrations"),"!!!"]}),z&&!l&&!o&&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 Secret key is invalid","bit-integrations")]}),!p&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:I,className:"btn btcd-btn-lg purple sh-sm flx",type:"button",disabled:l||o,children:[l?e("Authorized ✔","bit-integrations"):e("Authorize","bit-integrations"),o&&t.jsx(k,{size:20,clr:"#022217",className:"ml-2"})]}),t.jsx("br",{}),t.jsxs("button",{onClick:()=>T(),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",disabled:!l,children:[e("Next","bit-integrations"),t.jsx(B,{className:"ml-1 rev-icn"})]})]}),t.jsx($,{note:P})]})}export{U as default};
