var T=Object.defineProperty;var f=Object.getOwnPropertySymbols;var E=Object.prototype.hasOwnProperty,S=Object.prototype.propertyIsEnumerable;var k=(r,i,s)=>i in r?T(r,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[i]=s,m=(r,i)=>{for(var s in i||(i={}))E.call(i,s)&&k(r,s,i[s]);if(f)for(var s of f(i))S.call(i,s)&&k(r,s,i[s]);return r};import{r as b,j as t}from"./main-406.js";import{B as P}from"./bi.46.744.js";import{_ as n,L as N,b as B}from"./bi.394.85.js";import{r as F}from"./bi.216.745.js";import{T as z,t as K}from"./bi.150.760.js";function U({formID:r,telegramConf:i,setTelegramConf:s,step:g,setstep:A,setSnackbar:h,isInfo:u}){const[c,j]=b.useState(!1),[d,x]=b.useState({name:"",bot_api_key:"",apiError:""}),[L,v]=b.useState(!1),[l,y]=b.useState(!1),{telegram:e}=K,w=()=>{const a=m({},i);if(!a.name||!a.bot_api_key){x({name:a.name?"":n("Integration name cann't be empty","bit-integrations"),bot_api_key:a.bot_api_key?"":n("API Key cann't be empty","bit-integrations")});return}y("auth");const p={bot_api_key:a.bot_api_key};B(p,"telegram_authorize").then(o=>{o!=null&&o.success?(j(!0),h({show:!0,msg:n("Authorized Successfully","bit-integrations")})):(j(!1),x({apiError:o==null?void 0:o.data.description}),h({show:!0,msg:n("Authorized Filled","bit-integrations")})),v(!0),y(!1)})},_=a=>{const p=m({},i),o=m({},d);o[a.target.name]="",p[a.target.name]=a.target.value,x(o),s(p)},I=()=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),F(i,s,y,h),A(2)};return t.jsxs("div",{className:"btcd-stp-page",style:{width:g===1&&900,height:g===1&&"auto"},children:[(e==null?void 0:e.youTubeLink)&&t.jsx(z,{title:e==null?void 0:e.title,youTubeLink:e==null?void 0:e.youTubeLink}),(e==null?void 0:e.docLink)&&t.jsx(z,{title:e==null?void 0:e.title,docLink:e==null?void 0:e.docLink}),t.jsx("div",{className:"mt-3",children:t.jsx("b",{children:n("Integration Name:","bit-integrations")})}),t.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:_,name:"name",value:i.name,type:"text",placeholder:n("Integration Name...","bit-integrations"),disabled:u}),t.jsx("div",{style:{color:"red",fontSize:"15px",marginTop:"5px"},children:d.name}),t.jsx("div",{className:"mt-3",children:t.jsx("b",{children:n("Bot API Key:","bit-integrations")})}),t.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:_,name:"bot_api_key",value:i.bot_api_key,type:"text",placeholder:n("Integration Name...","bit-integrations"),disabled:u}),t.jsx("div",{style:{color:"red",fontSize:"15px",marginTop:"5px"},children:d.bot_api_key}),l==="auth"&&t.jsxs("div",{className:"flx mt-5",children:[t.jsx(N,{size:25,clr:"#022217",className:"mr-2"}),"Checking API Key!!!"]}),L&&!c&&!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:"×"}),d.apiError]}),!u&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:w,className:"btn btcd-btn-lg purple sh-sm flx",type:"button",disabled:c||l,children:[c?n("Authorized ✔","bit-integrations"):n("Authorize","bit-integrations"),l&&t.jsx(N,{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:!c,children:[n("Next","bit-integrations"),t.jsx(P,{className:"ml-1 rev-icn"})]})]})]})}export{U as default};
