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