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