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