var I=Object.defineProperty;var j=Object.getOwnPropertySymbols;var w=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable;var k=(e,r,s)=>r in e?I(e,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[r]=s,u=(e,r)=>{for(var s in r||(r={}))w.call(r,s)&&k(e,s,r[s]);if(j)for(var s of j(r))T.call(r,s)&&k(e,s,r[s]);return e};import{r as b,j as t}from"./main-406.js";import{B as P}from"./bi.46.744.js";import{_ as a,L as y,b as f}from"./bi.394.85.js";import{T as _,t as E}from"./bi.150.760.js";function M({sendyConf:e,setSendyConf:r,step:s,setstep:N,isInfo:l}){const[c,v]=b.useState(!1),[o,x]=b.useState({name:"",api_key:""}),[S,L]=b.useState(!1),[m,g]=b.useState(!1),{sendy:i}=E,A=()=>{const n=u({},e);if(!n.name||!n.api_key){x({name:n.name?"":a("Integration name cann't be empty","bit-integrations"),api_key:n.api_key?"":a("API Key cann't be empty","bit-integrations"),sendy_url:n.sendy_url?"":a("Sendy URL cann't be empty","bit-integrations")});return}g("auth");const d={api_key:n.api_key,sendy_url:n.sendy_url};f(d,"sendy_authorize").then(p=>{p.success&&v(!0),L(!0),g(!1)})},h=n=>{const d=u({},e),p=u({},o);p[n.target.name]="",d[n.target.name]=n.target.value,x(p),r(d)},z=()=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),N(2)};return t.jsxs("div",{className:"btcd-stp-page",style:{width:s===1&&900,height:s===1&&"auto"},children:[(i==null?void 0:i.youTubeLink)&&t.jsx(_,{title:i==null?void 0:i.title,youTubeLink:i==null?void 0:i.youTubeLink}),(i==null?void 0:i.docLink)&&t.jsx(_,{title:i==null?void 0:i.title,docLink:i==null?void 0:i.docLink}),t.jsx("div",{className:"mt-3",children:t.jsx("b",{children:a("Integration Name:","bit-integrations")})}),t.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:h,name:"name",value:e==null?void 0:e.name,type:"text",placeholder:a("Integration Name...","bit-integrations"),disabled:l}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:o.name}),t.jsx("div",{className:"mt-3",children:t.jsx("b",{children:a("API Key:","bit-integrations")})}),t.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:h,name:"api_key",value:e==null?void 0:e.api_key,type:"text",placeholder:a("api Key...","bit-integrations"),disabled:l}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:o.api_key}),t.jsxs("small",{className:"d-blk mt-5",children:[a("To get API , Please Visit","bit-integrations")," ",t.jsx("a",{className:"btcd-link",href:"https://app.sendy.com/api-key",target:"_blank",rel:"noreferrer",children:a("Sendy API Console","bit-integrations")})]}),t.jsx("div",{className:"mt-3",children:t.jsx("b",{children:a("Sendy URL:","bit-integrations")})}),t.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:h,name:"sendy_url",value:e==null?void 0:e.sendy_url,type:"text",placeholder:a("Sendy URL...","bit-integrations"),disabled:l}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:o.sendy_url}),m==="auth"&&t.jsxs("div",{className:"flx mt-5",children:[t.jsx(y,{size:25,clr:"#022217",className:"mr-2"}),"Checking API Key!!!"]}),S&&!c&&!m&&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"]}),!l&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:A,className:"btn btcd-btn-lg purple sh-sm flx",type:"button",disabled:c||m,children:[c?a("Authorized ✔","bit-integrations"):a("Authorize","bit-integrations"),m&&t.jsx(y,{size:20,clr:"#022217",className:"ml-2"})]}),t.jsx("br",{}),t.jsxs("button",{onClick:()=>z(),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",disabled:!c,children:[a("Next","bit-integrations"),t.jsx(P,{className:"ml-1 rev-icn"})]})]})]})}export{M as default};
