var A=Object.defineProperty;var k=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable;var v=(n,s,a)=>s in n?A(n,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):n[s]=a,y=(n,s)=>{for(var a in s||(s={}))I.call(s,a)&&v(n,a,s[a]);if(k)for(var a of k(s))L.call(s,a)&&v(n,a,s[a]);return n};import{r as d,j as t,u as T,k as _}from"./main-406.js";import{_ as l,L as z,b as F,A as B,d as M,I as q,s as D}from"./bi.394.85.js";import{S as E}from"./bi.68.941.js";import{S as P,h as H,c as R}from"./bi.674.709.js";import{B as G}from"./bi.46.744.js";import{T as N,t as J}from"./bi.150.760.js";import"./bi.704.707.js";import"./bi.701.708.js";function K({formID:n,sliceWpConf:s,setSliceWpConf:a,step:u,setStep:x,isLoading:p,setIsLoading:h,setSnackbar:S}){const[o,f]=d.useState(!1),[m,b]=d.useState(!1),{sliceWp:e}=J,r=()=>{h("auth"),F({},"slicewp_authorize").then(c=>{c!=null&&c.success&&(f(!0),S({show:!0,msg:l("Connected with SliceWp affiliate Successfully","bit-integrations")})),h(!1),b(!0)})},j=c=>{const i=B(s);i[c.target.name]=c.target.value,a(i)};return t.jsxs("div",{className:"btcd-stp-page",style:{width:u===1&&900,height:u===1&&"auto"},children:[(e==null?void 0:e.youTubeLink)&&t.jsx(N,{title:e==null?void 0:e.title,youTubeLink:e==null?void 0:e.youTubeLink}),(e==null?void 0:e.docLink)&&t.jsx(N,{title:e==null?void 0:e.title,docLink:e==null?void 0:e.docLink}),t.jsx("div",{className:"mt-3",children:t.jsx("b",{children:l("Integration Name:","bit-integrations")})}),t.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:j,name:"name",value:s.name,type:"text",placeholder:l("Integration Name...","bit-integrations")}),p==="auth"&&t.jsxs("div",{className:"flx mt-5",children:[t.jsx(z,{size:25,clr:"#022217",className:"mr-2"}),"Checking if SliceWp affiliate is active!!!"]}),m&&!o&&!p&&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:"×"}),"SliceWp affiliate plugin must be activated to integrate with Bit Integrations."]}),!o&&t.jsx("button",{onClick:r,className:"btn btcd-btn-lg purple sh-sm flx mt-5",type:"button",children:l("Connect","bit-integrations")}),o&&t.jsxs("button",{onClick:()=>x(2),className:"btn btcd-btn-lg purple sh-sm flx mt-5",type:"button",disabled:!o,children:[l("Next","bit-integrations"),t.jsx(G,{className:"ml-1 rev-icn"})]})]})}function tt({formFields:n,setFlow:s,flow:a,allIntegURL:u,isInfo:x,edit:p}){const h=T(),{formID:S}=_(),[o,f]=d.useState(!1),[m,b]=d.useState(1),[e,r]=d.useState({show:!1}),j=[{key:"1",label:"Add commission to user's affiliate"}],c=[{key:"commission_date",label:"commission_date",required:!0},{key:"reference",label:"Reference",required:!1},{key:"amount",label:"Amount",required:!1}],[i,g]=d.useState({name:"SliceWp",type:"SliceWp",mainAction:"",field_map:[{formField:"",slicewpFormField:""}],allActions:j,sliceWpFields:c,actions:{}}),w=()=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!R(i)){r({show:!0,msg:l("Please map mandatory fields","bit-integrations")});return}i.mainAction!==""&&b(3)};return t.jsxs("div",{children:[t.jsx(M,{snack:e,setSnackbar:r}),t.jsx("div",{className:"txt-center mt-2",children:t.jsx(E,{step:3,active:m})}),t.jsx(K,{formID:S,sliceWpConf:i,setSliceWpConf:g,step:m,setStep:b,isLoading:o,setIsLoading:f,setSnackbar:r}),t.jsxs("div",{className:"btcd-stp-page",style:y({},m===2&&{width:900,height:"auto",overflow:"visible"}),children:[t.jsx(P,{formFields:n,handleInput:C=>H(C,i,g),sliceWpConf:i,setSliceWpConf:g,isLoading:o,setIsLoading:f,setSnackbar:r,allIntegURL:u,isInfo:x,edit:p}),t.jsxs("button",{onClick:()=>w(),disabled:!i.mainAction||o||i.statusId===void 0,className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[l("Next","bit-integrations")," ",t.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),t.jsx(q,{step:m,saveConfig:()=>D({flow:a,setFlow:s,allIntegURL:u,navigate:h,conf:i,setIsLoading:f,setSnackbar:r}),isLoading:o,dataConf:i,setDataConf:g,formFields:n})]})}export{tt as default};
