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