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