var I=Object.defineProperty;var y=Object.getOwnPropertySymbols;var G=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable;var j=(n,s,i)=>s in n?I(n,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[s]=i,N=(n,s)=>{for(var i in s||(s={}))G.call(s,i)&&j(n,i,s[i]);if(y)for(var i of y(s))T.call(s,i)&&j(n,i,s[i]);return n};import{j as e,_ as a,s as R,b as _,k as z,f as B}from"./main.2.8.10.js";import{b as d,u as D,e as F}from"./react-router.DMwpH23k.js";import"./CopyIcn.BnhKHfEP.js";import{S as E}from"./SnackMsg.7BjcJK1j.js";import{S as L}from"./Steps.B84Ui3GU.js";import{I as M,s as q}from"./Integrations.BFhED4ck.js";import{G as H,h as K}from"./GamiPressIntegLayout.BAr3Z-lA.js";import{B as $}from"./BackIcn.BFDZx8No.js";import{y as J,x as O}from"./Note.DalStCGz.js";import{T as Q}from"./TutorialLink.D6K_DiHL.js";import"./react-vendor.P7K3d6op.js";import"./Table.DSsAy4VI.js";import"./index.DpWdl9V1.js";import"./TagifyInput.C4ilRm4k.js";import"./lodash.DCvQBX3r.js";function U({formID:n,gamiPressConf:s,setGamiPressConf:i,step:u,setStep:x,isLoading:h,setIsLoading:b,setSnackbar:v}){const[c,k]=d.useState(!1),[l,p]=d.useState(!1),m=()=>{b("auth"),_({},"gamiPress_authorize").then(o=>{o!=null&&o.success&&(k(!0),v({show:!0,msg:a("Connected with GamiPress Successfully","bit-integrations")})),b(!1),p(!0)})},f=o=>{const r=O(s);r[o.target.name]=o.target.value,i(r)};return e.jsxs("div",{className:"btcd-stp-page",style:{width:u===1&&900,height:u===1&&"auto"},children:[e.jsx(Q,{linkKey:"gamiPress"}),e.jsx("div",{className:"mt-3",children:e.jsx("b",{children:a("Integration Name:","bit-integrations")})}),e.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:f,name:"name",value:s.name,type:"text",placeholder:a("Integration Name...","bit-integrations")}),h==="auth"&&e.jsxs("div",{className:"flx mt-5",children:[e.jsx(J,{size:25,clr:"#022217",className:"mr-2"}),"Checking if GamiPress is active!!!"]}),l&&!c&&!h&&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:"×"}),R(a("%s plugin must be activated to integrate with Bit Integrations","bit-integrations"),"GamiPress")]}),!c&&e.jsx("button",{onClick:m,className:"btn btcd-btn-lg purple sh-sm flx mt-5",type:"button",children:a("Connect","bit-integrations")}),c&&e.jsxs("button",{onClick:()=>x(2),className:"btn btcd-btn-lg purple sh-sm flx mt-5",type:"button",disabled:!c,children:[a("Next","bit-integrations"),e.jsx($,{className:"ml-1 rev-icn"})]})]})}function de({formFields:n,setFlow:s,flow:i,allIntegURL:u,isInfo:x,edit:h}){const b=D(),{formID:v}=F(),c=z(B),{siteURL:k}=c,[l,p]=d.useState(!1),[m,f]=d.useState(1),[o,r]=d.useState({show:!1}),P=[{key:"1",label:a("Award rank to the user","bit-integrations")},{key:"2",label:a("Award an achievement to the user","bit-integrations")},{key:"3",label:a("Award a points to the user","bit-integrations")},{key:"4",label:a("Revoke a rank form the user","bit-integrations")},{key:"5",label:a("Revoke an achievement form the user","bit-integrations")},{key:"6",label:a("Revoke points from the user","bit-integrations")}],A=[{key:"point",label:"Point",required:!0}],[t,g]=d.useState({name:"GamiPress",type:"GamiPress",mainAction:"",field_map:[{formField:"",gamiPressFormField:""}],pointFields:A,allActions:P,actions:{}}),S=()=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),t.mainAction!==""&&f(3)};function w(){switch(t.mainAction){case"1":return t.selectedRank===void 0||t.selectedRank==="";case"2":return t.selectedAchievement===void 0||t.selectedAchievement==="";case"3":return t.selectedPointType===void 0||t.selectedPointType==="";case"4":return t.selectedRank===void 0||t.selectedRank==="";case"5":return t.selectedAchievement===void 0||t.selectedAchievement==="";case"6":return t.selectedPointType===void 0||t.selectedPointType==="";default:return!1}}return e.jsxs("div",{children:[e.jsx(E,{snack:o,setSnackbar:r}),e.jsx("div",{className:"txt-center mt-2",children:e.jsx(L,{step:3,active:m})}),e.jsx(U,{formID:v,gamiPressConf:t,setGamiPressConf:g,step:m,setStep:f,isLoading:l,setIsLoading:p,setSnackbar:r}),e.jsxs("div",{className:"btcd-stp-page",style:N({},m===2&&{width:900,height:"auto",overflow:"visible"}),children:[e.jsx(H,{formFields:n,handleInput:C=>K(C,t,g),gamiPressConf:t,setGamiPressConf:g,isLoading:l,setIsLoading:p,setSnackbar:r,allIntegURL:u,isInfo:x,edit:h}),e.jsxs("button",{onClick:()=>S(),disabled:!t.mainAction||l||w(),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[a("Next","bit-integrations")," ",e.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),e.jsx(M,{step:m,saveConfig:()=>q({flow:i,setFlow:s,allIntegURL:u,navigate:b,conf:t,setIsLoading:p,setSnackbar:r}),isLoading:l,dataConf:t,setDataConf:g,formFields:n})]})}export{de as default};
