var C=Object.defineProperty;var y=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable;var N=(r,i,s)=>i in r?C(r,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[i]=s,h=(r,i)=>{for(var s in i||(i={}))I.call(i,s)&&N(r,s,i[s]);if(y)for(var s of y(i))T.call(i,s)&&N(r,s,i[s]);return r};import{_ as t,j as e,b as K}from"./main.2.9.0.js";import{b as x}from"./react-router.DMwpH23k.js";import{B as D}from"./BackIcn._8Wofmn2.js";import{y as _,a9 as E}from"./Note.NSUdvR3c.js";import{r as P}from"./DirectIqCommonFunc.D1AObw2G.js";import{T as B}from"./TutorialLink.CFG7bS5c.js";import"./react-vendor.P7K3d6op.js";import"./CopyIcn.CEA_lFLo.js";function J({formID:r,directIqConf:i,setDirectIqConf:s,step:u,setstep:f,setSnackbar:g,isInfo:c,isLoading:l,setIsLoading:b}){const[o,A]=x.useState(!1),[d,j]=x.useState({name:"",client_secret:""}),[v,S]=x.useState(!1),k=()=>{const n=h({},i);if(!n.name||!n.client_secret){j({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}b("auth");const m={client_id:n.client_id,client_secret:n.client_secret};K(m,"directIq_authorize").then(a=>{a!=null&&a.success&&(A(!0),g({show:!0,msg:t("Authorized Successfully","bit-integrations")})),S(!0),b(!1)})},p=n=>{const m=h({},i),a=h({},d);a[n.target.name]="",m[n.target.name]=n.target.value,j(a),s(m)},z=()=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),P(i,s,b,g),f(2)},w=`
            <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:u===1&&900,height:u===1&&"auto"},children:[e.jsx(B,{linkKey:"directIq"}),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:p,name:"name",value:i.name,type:"text",placeholder:t("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:t("Access Client id:","bit-integrations")})}),e.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:p,name:"client_id",value:i.client_id,type:"text",placeholder:t("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:t("Access Client Secret Key:","bit-integrations")})}),e.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:p,name:"client_secret",value:i.client_secret,type:"text",placeholder:t("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:[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",{}),l==="auth"&&e.jsxs("div",{className:"flx mt-5",children:[e.jsx(_,{size:25,clr:"#022217",className:"mr-2"}),"Checking Client Secret Key!!!"]}),v&&!o&&!l&&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:k,className:"btn btcd-btn-lg purple sh-sm flx",type:"button",disabled:o||l,children:[o?t("Authorized ✔","bit-integrations"):t("Authorize","bit-integrations"),l&&e.jsx(_,{size:20,clr:"#022217",className:"ml-2"})]}),e.jsx("br",{}),e.jsxs("button",{onClick:()=>z(),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",disabled:!o,children:[t("Next","bit-integrations"),e.jsx(D,{className:"ml-1 rev-icn"})]})]}),e.jsx(E,{note:w})]})}export{J as default};
