1import{i as ls,m as ms,l as _,r as c,g as ds,j as e,N as us,s as h}from"./index-Cqd0JOc_.js";import{T as R,a as B,b as f,c as l,d as K,e as o}from"./table-nARFq4H9.js";import{D as ps}from"./DashboardLayout-BinGEAd0.js";import{F as hs}from"./FancyPageHeader-_KfKDVZk.js";import{C as b,a as v}from"./card-BcVuNMRk.js";import{B as N}from"./button-BF8JIYbj.js";import{B as T}from"./badge-BHUfJ5H9.js";import{A as fs,a as xs,b as gs,c as ys,d as js,e as bs,f as vs,g as Ns}from"./alert-dialog-CpS25gTn.js";import{I as _s}from"./input-J4lF_ZPD.js";import{L as Y}from"./label-yK3TlKaU.js";import{T as Ne}from"./textarea-BJl_ZXoV.js";import{u as d}from"./index-B-GB_aZ6.js";import{useOrganizationContext as ws}from"./OrganizationContext-CQoJsQ29.js";import{u as Cs}from"./currency-CECdeNGG.js";import{o as ks}from"./useCreditCosts-BcRtE5PW.js";import{D as J,a as G,b as Q,c as Z,d as X}from"./dialog-iEhwrC3O.js";import{C as Ss}from"./checkbox-BWcXKwjU.js";import{A as As}from"./AffiliateTermsContent-DZn-r3ve.js";import{C as ee}from"./crown-gKsGUkXj.js";import{S as qs}from"./shield-check-v-xp2Ixk.js";import{L}from"./loader-circle-BS6OsW3x.js";import{S as Ds}from"./send-9-SUNmbP.js";import{C as Ts}from"./check-BRRfmCJJ.js";import{C as Ls}from"./copy-BHUDp6u9.js";import{U as Fs}from"./skeleton-B6LPOF7D.js";import{c as Ps}from"./createLucideIcon-BUgdZWmp.js";import{C as $s}from"./calendar-clock-AGuoH_Mu.js";import{W as _e}from"./wallet-DvVwzrjI.js";import{C as we}from"./coins-JNu2WCpw.js";import{U as zs}from"./users-DRrtC0T5.js";import{C as Rs}from"./log-out-B2OGXzKC.js";import{M as Bs}from"./mouse-pointer-click-BgYRlr5w.js";import{R as Ks,X as Ms,Y as Us,T as Is,L as Os}from"./generateCategoricalChart-CpBdzV30.js";import{L as Hs,C as Vs,a as Ce}from"./LineChart-Dj3ZEaLq.js";import{H as Es}from"./history-CTH0x5n6.js";import"./index-DEqiOm32.js";import"./use-mobile-Cc7N6gKM.js";import"./index-RVQqwujB.js";import"./index-BS3rh8m8.js";import"./useProjects-D_-Uw0MY.js";import"./x-CI-zb7NX.js";import"./dropdown-menu-B50cqF0J.js";import"./index-_h1cipRK.js";import"./index-BQdIuXMc.js";import"./index-Cv1VlRNV.js";import"./radio-group-wqp0Ln5l.js";import"./index-QGGOdO5c.js";import"./use-toast-B9tLpTqp.js";import"./ContactDialog-DtR5fo-M.js";import"./select-BwYIxdh_.js";import"./chevron-up-BM3YnvV8.js";import"./sparkles-y60jKWHf.js";import"./building-2-CgqKxnVV.js";import"./zap-C6BjTcY5.js";import"./laure-avatar-wH1i9WzZ.js";import"./share-2-CNqDtR-b.js";import"./gift-EIldoFoh.js";
1import"./user-wbwqibtj.js";import"./globe-C9_lmDAP.js";import"./banknote-D5tBcXRh.js";import"./credit-card-BuMO8ibT.js";import"./settings-C2YpJ7nr.js";import"./circle-help-QREzNaV4.js";import"./party-popper-hfHhLT72.js";import"./book-open-C13MO25X.js";import"./graduation-cap-OS2P0j5w.js";import"./kbFileTypes-CK7dhHB6.js";import"./rotate-ccw-C__7SGaS.js";import"./arrow-up-Cbmnt9CZ.js";import"./mail-DQ_txK33.js";import"./index-CtKlTlVt.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const Ws=Ps("Percent",[["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}],["circle",{cx:"6.5",cy:"6.5",r:"2.5",key:"4mh3h7"}],["circle",{cx:"17.5",cy:"17.5",r:"2.5",key:"1mdrzq"}]]),dr=()=>{const{i18n:ke}=ls(),t=(ke.language||"fr").toLowerCase().startsWith("fr"),{profile:x}=ms(),{isOrgContext:Se,isOrgAdmin:Ae,isLoading:qe,currentOrganization:m}=ws(),g=(m==null?void 0:m.id)??null,{data:i,refetch:De}=_({queryKey:["org-affiliate-settings",g],enabled:!!g,queryFn:async()=>{const{data:s,error:r}=await h.from("organizations").select("affiliate_commission_pct, affiliate_commission_months, affiliate_status, affiliate_approved_at, affiliate_requested_at, affiliate_promo_channels, affiliate_website, affiliate_audience, subscription_status, name, country").eq("id",g).maybeSingle();if(r)throw r;return{pct:Number((s==null?void 0:s.affiliate_commission_pct)??10),months:Number((s==null?void 0:s.affiliate_commission_months)??6),status:String((s==null?void 0:s.affiliate_status)??"none"),approvedAt:s==null?void 0:s.affiliate_approved_at,requestedAt:s==null?void 0:s.affiliate_requested_at,channels:s==null?void 0:s.affiliate_promo_channels,website:s==null?void 0:s.affiliate_website,audience:s==null?void 0:s.affiliate_audience,subscriptionStatus:String((s==null?void 0:s.subscription_status)??"inactive"),orgName:String((s==null?void 0:s.name)??""),country:String((s==null?void 0:s.country)??"")}}}),Te=(i==null?void 0:i.pct)??10,M=(i==null?void 0:i.months)??6,se=(i==null?void 0:i.status)??"none",y=se==="approved",U=se==="pending",{data:F=[],isLoading:te}=_({queryKey:["my-affiliates"],queryFn:async()=>{const{data:s,error:r}=await h.rpc("get_my_affiliates");if(r)throw r;return s??[]}}),{data:Le=[]}=_({queryKey:["my-affiliate-purchases"],queryFn:async()=>{const{data:s,error:r}=await h.rpc("get_my_affiliate_purchases");if(r)throw r;return(s??[]).map(a=>({referred_user_id:a.referred_user_id,purchase_id:a.purchase_id,purchased_at:a.purchased_at,currency:a.currency||"eur",amount_cents:Number(a.amount_cents??0),commission_cents:Number(a.commission_cents??0),type:a.type||"",credits_purchased:Number(a.credits_purchased??0),plan:a.plan||"",is_promo:!!a.is_promo}))}}),{data:Fe=[]}=_({queryKey:["my-affiliate-clicks",x==null?void 0:x.id],enabled:y&&!!(x!=null&&x.id),queryFn:async()=>{const s=new Date;s.setDate(s.getDate()-89);const{data:r,error:a}=await h.from("affiliate_clicks").select("created_at").gte("created_at",s.toISOString());if(a)throw a;return(r??[]).map(n=>({created_at:String(n.created_at)}))}}),Pe=Le.reduce((s,r)=>{var a;return(s[a=r.referred_user_id]||(s[a]=[])).push(r),s},{}),[$e,ze]=c.useState(null),Re=s=>{switch(s.plan){case"starter":return t?"Abonnement Starter":"Starter subscription";case"pro":return t?"Abonnement Pro":"Pro subscription";case"business":return t?"Abonnement Business":"Business subscription";case"credits_60":return t?"Pack 60 crédits":"60 credits pack";case"pro_topup":return t?"Recharge Pro (30 crédits)":"Pro top-up (30 credits)";case"org_credits_500":return t?"Pack 500 crédits (org.)":"500 credits pack (org.)";case"org_credits_2000":return t?"Pack 2000 crédits (org.)":"2000 credits pack (org.)";case"subscription":return t?"Abonnement":"Subscription";default:return s.credits_purchased?t?`${s.credits_purchased} crédits`:`${s.credits_purchased} credits`:s.type||"â"}},{data:I=[],isLoading:Be}=_({queryKey:["my-affiliate-revenue"],queryFn:async()=>{const{data:s,error:r}=await h.rpc("get_my_affiliate_revenue");if(r)throw r;return(s??[]).map(a=>({month_start:a.month_start,currency:a.currency||"eur",gross_cents:Number(a.gross_cents??0),commission_cents:Number(a.commission_cents??0),purchases_count:Number(a.purchases_count??0)}))}}),{data:re=[],refetch:Ke}=_({queryKey:["my-affiliate-balance"],queryFn:async()=>{const{data:s,error:r}=await h.rpc("get_my_affiliate_balance");if(r)throw r;return(s??[]).map(a=>({currency:a.currency||"eur",earned_cents:Number(a.earned_cents??0),paid_cents:Number(a.paid_cents??0),available_cents:Number(a.available_cents??0)}))}}),{data:ae=[],refetch:Me}=_({queryKey:["my-affiliate-payouts",g],enabled:!!g,queryFn:async()=>{const{data:s,error:r}=await h.from("affiliate_payouts").select("id, created_at, amount_cents, currency, method, credits_granted, status, note").eq("organization_id",g).order("created_at",{ascending:!1});if(r)throw r;return s??[]}}),w=re.find(s=>
6s.currency==="eur")||re[0]||null,C=(w==null?void 0:w.available_cents)??0,q=(w==null?void 0:w.currency)??"eur",Ue=q==="usd"?3.3333:4,P=Math.floor(C/100*Ue),ie=(i==null?void 0:i.subscriptionStatus)==="business"||(m==null?void 0:m.subscription_status)==="business",j=(i==null?void 0:i.orgName)||(m==null?void 0:m.name)||"",[D,ne]=c.useState(!1),[Ie,O]=c.useState(!1),[Oe,H]=c.useState(!1),[oe,ce]=c.useState(!1),le=Cs(),me=((i==null?void 0:i.country)||(m==null?void 0:m.country)||"").trim(),k=!me||/^(fr|france)$/i.test(me),He=String(le||"eur").toLowerCase()==="eur",de=!!i&&(!k||!He),[Ve,V]=c.useState(!1),Ee=ds();c.useEffect(()=>{de&&V(!0)},[de]);const We=async()=>{if(!m)return;ce(!0);const s=ks();try{const{data:r,error:a}=await h.functions.invoke("create-checkout",{body:{type:"business",currency:le,organization_id:m.id}});if(a)throw a;r!=null&&r.url&&s?s.location.href=r.url:r!=null&&r.url?window.location.href=r.url:s==null||s.close()}catch(r){s==null||s.close(),d.error((r==null?void 0:r.message)||(t?"Impossible de démarrer le paiement":"Unable to start checkout"))}finally{ce(!1)}},Ye=async()=>{ne(!0);try{const{data:s,error:r}=await h.rpc("convert_affiliate_earnings_to_credits",{p_currency:q});if(r)throw r;const a=s;if((a==null?void 0:a.error)==="business_required"){d.error(t?"Un abonnement Business est requis.":"A Business subscription is required.");return}if((a==null?void 0:a.error)==="below_minimum"){d.error(t?"Minimum de 50 ⬠HT requis.":"A minimum of â¬50 excl. VAT is required.");return}if(a!=null&&a.error)throw new Error(a.error);d.success(t?`${a.credits} crédits ajoutés à votre organisation !`:`${a.credits} credits added to your organization!`),await Promise.all([Ke(),Me()]),O(!1)}catch(s){d.error((s==null?void 0:s.message)||(t?"Conversion impossible":"Conversion failed"))}finally{ne(!1)}},Je=Object.values(I.reduce((s,r)=>{const a=s[r.currency]||{currency:r.currency,gross_cents:0,commission_cents:0,purchases_count:0};return a.gross_cents+=r.gross_cents,a.commission_cents+=r.commission_cents,a.purchases_count+=r.purchases_count,s[r.currency]=a,s},{})),u=(s,r)=>new Intl.NumberFormat(t?"fr-FR":"en-US",{style:"currency",currency:(r||"eur").toUpperCase()}).format(s/100),Ge=s=>new Date(`${s}T00:00:00`).toLocaleDateString(t?"fr-FR":"en-US",{month:"long",year:"numeric"}),S=`${Number(Te).toString().replace(".",t?",":".")} %`,[ue,pe]=c.useState(!1),[$,Qe]=c.useState(""),[he,Ze]=c.useState(""),[fe,Xe]=c.useState(""),[xe,ge]=c.useState(!1),[es,E]=c.useState(!1),[z,ss]=c.useState(!1),[W,ye]=c.useState(!1),je=c.useRef(null),ts=()=>{const s=je.current;s&&s.scrollTop+s.clientHeight>=s.scrollHeight-40&&ss(!0)},rs=async()=>{if(!W){d.error(t?"Merci dâaccepter les conditions générales du programme dâaffiliation.":"Please accept the affiliate program terms and conditions.");return}if(!g||!$.trim()){d.error(t?"Merci dâindiquer où vous ferez la promotion.":"Please tell us where you will promote.");return}ge(!0);try{const{data:s,error:r}=await h.functions.invoke("request-affiliation",{body:{organization_id:g,promo_channels:$.trim(),website:he.trim()||null,audience:fe.trim()||null}});if(r)throw r;if(s!=null&&s.error)throw new Error(s.error);d.success(t?"Demande envoyée ! Vous serez notifié après validation.":"Request sent! You will be notified once approved."),await De()}catch(s){d.error((s==null?void 0:s.message)||(t?"Envoi impossible":"Could not submit"))}finally{ge(!1)}},be=(x==null?void 0:x.referral_code)||"",A=be?`https://skillka.ai/invite/${be}`:"",ve=A?`${A}?utm_source=referral&utm_medium=whatsapp&utm_campaign=affiliation`:"https://skillka.ai",as=t?`Je crée mes formations complètes (programme, supports, quiz, Qualiopi) en quelques minutes avec SkillKa.ai. Essayez avec mon lien : 7${ve}`:`I build complete training courses (program, materials, quizzes) in minutes with SkillKa.ai. Try it with my link: 8${ve}`,is=`https://api.whatsapp.com/send?text=${encodeURIComponent(as)}`,ns=(()=>{const s=[],r=t?"fr-FR":"en-US";for(let n=29;n>=0;n--){const p=new Date;p.setDate(p.getDate()-n);const cs=p.toISOString().slice(0,10);s.push({key:cs,label:p.toLocaleDateString(r,{day:"numeric",month:"short"}),clicks:0,signups:0})}const a=new Map(s.map(n=>[n.key,n]));for(const n of Fe){const p=a.get(String(n.created_at).slice(0,10));p&&(p.clicks+=1)}for(const n of F){const p=a.get(String(n.signed_up_at).slice(0,10));p&&(p.signups+=1)}return s})();if(!qe&&(!Se||!Ae))return e.jsx(us,{to:"/dashboard",replace:!0});const os=async()=>{try{await navigator.clipboard.writeText(A),pe(!0),d.success(t?"Lien copié !":"Link copied!"),setTimeout(()=>pe(!1),2e3)}catch{d.error(t?"Impossible de copier":"Could not copy")}};return e.jsx(ps,{children:e.jsxs("div",{className:"w-full",children:[e.jsx(hs,{icon:ee,title:t?"Affiliation":"Affiliate program",subtitle:t?`Recommandez SkillKa.ai et percevez ${S} des achats de vos affiliés.`:`Recommend SkillKa.ai and earn ${S} of your affiliatesâ purchases.`,actions:e.jsx(T,{className:"hidden sm:inline-flex",children:"VIP"})}),!y&&e.jsx(b,{className:"mb-5 border-primary/30",children:e.jsxs(v,{className:"space-y-4 p-4 sm:p-5",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-primary/10",children:e.jsx(qs,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold",children:U?t?"Demande en cours dâexamen":"Request under review":t?"Activez votre affiliation":"Activate your affiliate program"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:U?t?"Votre demande a bien été envoyée. Aucune commission nâest comptabilisée tant quâelle nâest pas acceptée : les revenus démarrent à la date dâacceptation.":"Your request has been sent. No commission is counted until it is approved: earnings start at the approval date.":t?"Pour devenir affilié, soumettez une demande en précisant où vou
8s souhaitez faire la promotion de SkillKa.ai. Aucune commission nâest comptabilisée avant lâacceptation.":"To become an affiliate, submit a request describing where you plan to promote SkillKa.ai. No commission is counted before approval."})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"promo-channels",children:t?"Où souhaitez-vous faire la promotion de SkillKa.ai ? *":"Where do you plan to promote SkillKa.ai? *"}),e.jsx(Ne,{id:"promo-channels",rows:4,maxLength:4e3,value:$,onChange:s=>Qe(s.target.value),placeholder:t?"Ex. : LinkedIn, newsletter (5 000 abonnés), blog formation, salons, bouche-à -oreille clients...":"E.g. LinkedIn, newsletter (5,000 subscribers), training blog, trade shows, client referrals..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"promo-website",children:t?"Site web / profil (optionnel)":"Website / profile (optional)"}),e.jsx(_s,{id:"promo-website",value:he,onChange:s=>Ze(s.target.value),placeholder:"https://...",maxLength:500})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"promo-audience",children:t?"Votre audience (optionnel)":"Your audience (optional)"}),e.jsx(Ne,{id:"promo-audience",rows:3,maxLength:2e3,value:fe,onChange:s=>Xe(s.target.value),placeholder:t?"Qui sont vos contacts ? (organismes de formation, RH, indépendants...)":"Who is your audience? (training providers, HR, freelancers...)"})]}),e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-primary/30 bg-primary/5 p-3",children:[e.jsx(Ss,{id:"affiliate-terms",checked:W,onCheckedChange:s=>ye(s===!0),disabled:!z,className:"mt-0.5 h-5 w-5 border-2"}),e.jsxs("label",{htmlFor:"affiliate-terms",className:"text-sm leading-relaxed",children:[t?"Jâai lu et jâaccepte les ":"I have read and accept the ",e.jsx("button",{type:"button",onClick:()=>E(!0),className:"text-primary underline underline-offset-2 hover:text-primary/80",children:t?"conditions générales du programme dâaffiliation":"affiliate program terms and conditions"}),".",!z&&e.jsx("span",{className:"mt-1 block text-xs text-muted-foreground",children:t?"Ouvrez et faites défiler les conditions jusquâen bas pour pouvoir cocher cette case.":"Open and scroll the terms to the bottom to enable this checkbox."})]})]}),e.jsx(J,{open:es,onOpenChange:E,children:e.jsxs(G,{className:"max-w-3xl w-[95vw] max-h-[85vh] p-0",children:[e.jsxs(Q,{className:"px-4 pt-4 sm:px-6 sm:pt-6",children:[e.jsx(Z,{className:"text-lg font-heading font-bold sm:text-xl",children:t?"Conditions générales du programme dâaffiliation":"Affiliate program terms and conditions"}),e.jsx(X,{children:t?"Faites défiler jusquâen bas pour pouvoir accepter les conditions.":"Scroll to the bottom to be able to accept the terms."})]}),e.jsx("div",{ref:je,onScroll:ts,className:"max-h-[55vh] overflow-y-auto px-4 pb-2 sm:px-6",children:e.jsx(As,{})}),e.jsxs("div",{className:"flex flex-col gap-2 border-t border-border px-4 py-3 sm:flex-row sm:items-center sm:justify-between sm:px-6",children:[e.jsx("a",{href:"/affiliation-cgu",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground underline underline-offset-2 hover:text-foreground",children:t?"Ouvrir dans un nouvel onglet":"Open in a new tab"}),e.jsx(N,{disabled:!z,onClick:()=>{ye(!0),E(!1)},children:z?t?"Jâaccepte les conditions":"I accept the terms":t?"Faites défiler jusquâen bas":"Scroll to the bottom"})]})]})}),e.jsxs(N,{onClick:rs,disabled:xe||!$.trim()||!W,children:[xe?e.jsx(L,{className:"mr-1.5 h-4 w-4 animate-spin"}):e.jsx(Ds,{className:"mr-1.5 h-4 w-4"}),U?t?"Mettre à jour ma demande":"Update my request":t?"Demander lâaffiliation":"Request affiliation"]})]})}),y&&e.jsx(b,{className:"mb-5",children:e.jsxs(v,{className:"space-y-3 p-4 sm:p-5",children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:t?"Votre lien dâaffiliation":"Your affiliate link"}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsx("div",{className:"min-w-0 flex-1 rounded-lg border border-border bg-muted/40 px-3 py-2",children:e.jsx("p",{className:"truncate font-mono text-xs sm:text-sm",children:A||"..."})}),e.jsxs(N,{onClick:os,disabled:!A,className:"sm:w-auto",children:[ue?e.jsx(Ts,{className:"mr-1.5 h-4 w-4"}):e.jsx(Ls,{className:"mr-1.5 h-4 w-4"}),ue?t?"Copié":"Copied":t?"Copier le lien":"Copy link"]}),e.jsxs("a",{href:is,target:"_blank",rel:"noopener noreferrer","aria-disabled":!A,className:"inline-flex h-10 items-center justify-center gap-2 whitespace-nowrap rounded-xl bg-[#25D366] bg-none px-4 py-2 text-sm font-semibold tracking-tight text-white shadow-[0_4px_14px_-4px_rgba(37,211,102,0.5)] ring-1 ring-inset ring-white/15 transition-all duration-200 hover:-translate-y-0.5 hover:bg-[#20BA5A] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#25D366] active:scale-[0.97] sm:w-auto",children:[e.jsx("svg",{viewBox:"0 0 32 32","aria-hidden":"true",className:"h-4 w-4 shrink-0 fill-current",children:e.jsx("path",{d:"M16.003 3.2c-7.06 0-12.79 5.73-12.79 12.79 0 2.253.59 4.454 1.71 6.394L3.2 28.8l6.58-1.72a12.74 12.74 0 0 0 6.223 1.585h.005c7.06 0 12.79-5.73 12.79-12.79 0-3.417-1.33-6.63-3.746-9.046A12.71 12.71 0 0 0 16.003 3.2Zm0 23.31h-.004a10.6 10.6 0 0 1-5.4-1.48l-.388-.23-4.005 1.05 1.07-3.905-.253-.4a10.57 10.57 0 0 1-1.62-5.655c0-5.867 4.774-10.64 10.645-10.64 2.843 0 5.514 1.108 7.524 3.12a10.57 10.57 0 0 1 3.117 7.527c-.002 5.868-4.775 10.613-10.686 10.613Zm5.84-7.957c-.32-.16-1.893-.934-2.186-1.04-.293-.107-.507-.16-.72.16-.213.32-.826 1.04-1.013 1.253-.187.213-.373.24-.693.08-.32-.16-1.35-.498-2.57-1.586-.95-.847-1.592-1.894-1.779-2.214-.186-.32-.02-.493.14-.652.144-.144.32-.373.48-.56.16-.187.213-.32.32-.533.107-.214.053-.4-.027-.56-.08-.16-.72-1.735-.986-2.375-.26-.624-.524-.54-.72-.55l-.613-.01c-.213 0-.56.08-.853.4-.293.32-1.12 1.094-1.12 2.667 0 1.574 1.146 3.094 1.306 3.307.16.213 2.253 3.44 5.46 4.826.763.33 1.36.527 1.824.674.767.244 1.464.21 2.016.128.615-.092 1.893-.774 2.16-1.522.267-.747.267-1.387.187-1.52-.08-.133-.293-.213-.613-.373Z"})}),t?"Partager sur WhatsApp":"Share on WhatsApp"]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t?"Câest le même lien que votre lien dâinvitation.":"This is the same as your invitation link.",i!=null&&i.approvedAt?t?` Aff
8iliation active depuis le ${new Date(i.approvedAt).toLocaleDateString("fr-FR")}.`:` Affiliation active since ${new Date(i.approvedAt).toLocaleDateString("en-US")}.`:""]})]})}),e.jsx(b,{children:e.jsxs(v,{className:"space-y-4 p-4 sm:p-5",children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:t?"Comment ça marche":"How it works"}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-primary/10",children:e.jsx(Fs,{className:"h-4 w-4 text-primary"})}),e.jsx("p",{className:"pt-1 text-sm",children:t?"Partagez votre lien : chaque personne qui sâinscrit via ce lien devient votre filleul.":"Share your link: anyone who signs up through it becomes your referral."})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-primary/10",children:e.jsx(Ws,{className:"h-4 w-4 text-primary"})}),e.jsx("p",{className:"pt-1 text-sm",children:t?e.jsxs(e.Fragment,{children:["Vous recevez ",e.jsxs("strong",{children:[S," des achats HT"]})," réalisés par vos filleuls sur SkillKa.ai.",!y&&e.jsxs(e.Fragment,{children:[" Si vous n'êtes pas abonné le taux est de 10 %. Si vous êtes abonné Pro et/ou Business vous recevrez ",e.jsx("strong",{children:"15 % des achats HT"})," de vos filleuls."]})]}):e.jsxs(e.Fragment,{children:["You receive ",e.jsxs("strong",{children:[S," of the purchases (excl. VAT)"]})," made by your referrals on SkillKa.ai.",!y&&e.jsxs(e.Fragment,{children:[" If you are not subscribed the rate is 10%. If you are a Pro and/or Business subscriber you will receive ",e.jsx("strong",{children:"15% of the purchases (excl. VAT)"})," from your referrals."]})]})})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-primary/10",children:e.jsx($s,{className:"h-4 w-4 text-primary"})}),e.jsx("p",{className:"pt-1 text-sm",children:t?e.jsxs(e.Fragment,{children:["Cette commission sâapplique pendant ",e.jsxs("strong",{children:[M," mois"]})," à compter de la date dâinscription de chaque filleul sur SkillKa.ai."]}):e.jsxs(e.Fragment,{children:["This commission applies for ",e.jsxs("strong",{children:[M," month",M>1?"s":""]})," from each referralâs sign-up date on SkillKa.ai."]})})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-primary/10",children:e.jsx(_e,{className:"h-4 w-4 text-primary"})}),e.jsx("p",{className:"pt-1 text-sm",children:t?e.jsxs(e.Fragment,{children:["Un paiement peut être demandé à partir de ",e.jsx("strong",{children:"50 ⬠HT"})," de revenus générés."]}):e.jsxs(e.Fragment,{children:["A payout can only be requested from ",e.jsx("strong",{children:"â¬50 excl. VAT"})," of generated earnings."]})})]})]})}),y&&e.jsx(b,{className:"mt-5",children:e.jsxs(v,{className:"space-y-4 p-4 sm:p-5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"h-4 w-4 text-primary"}),e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:t?"Solde disponible":"Available balance"})]}),e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold text-primary",children:u(C,q)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t?`Convertible en ${P} crédits pour votre organisation.`:`Convertible into ${P} credits for your organization.`})]}),e.jsxs(N,{disabled:D||C<=0,onClick:()=>ie?O(!0):H(!0),children:[e.jsx(we,{className:"mr-1.5 h-4 w-4"}),t?"Convertir en crédits":"Convert into credits"]}),e.jsx(J,{open:Oe,onOpenChange:H,children:e.jsxs(G,{className:"sm:max-w-md",children:[e.jsxs(Q,{children:[e.jsxs(Z,{className:"flex items-center gap-2",children:[e.jsx(ee,{className:"h-5 w-5 text-primary"}),t?"Offre Business requise":"Business plan required"]}),e.jsx(X,{children:t?`Pour convertir instantanément vos revenus d'affiliation en crédits, votre organisation${j?` « ${j} »`:""} doit être abonnée à l'offre Entreprise & Ãquipes (Business). Sans cet abonnement, vous pouvez uniquement demander un paiement à partir de 50 ⬠HT.`:`To instantly convert your affiliate earnings into credits, your organization${j?` â${j}â`:""} must be subscribed to the Business plan. Without it, you can only request a payout from â¬50 excl. VAT.`})]}),e.jsxs("div",{className:"flex flex-col gap-2 pt-2",children:[e.jsxs(N,{onClick:We,disabled:oe,className:"w-full",children:[oe?e.jsx(L,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(ee,{className:"mr-2 h-4 w-4"}),t?"Souscrire à l'offre Business":"Subscribe to the Business plan"]}),e.jsx(N,{variant:"ghost",onClick:()=>H(!1),className:"w-full",children:t?"Plus tard":"Later"})]})]})}),e.jsx(fs,{open:Ie,onOpenChange:s=>!D&&O(s),children:e.jsxs(xs,{children:[e.jsxs(gs,{children:[e.jsx(ys,{children:t?"Convert
8ir vos gains en crédits ?":"Convert your earnings into credits?"}),e.jsx(js,{asChild:!0,children:e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsx("p",{children:t?`Vous allez convertir ${u(C,q)} en ${P} crédits.`:`You are about to convert ${u(C,q)} into ${P} credits.`}),e.jsx("p",{className:"font-medium text-foreground",children:t?`Ces crédits seront directement crédités sur le compte de votre organisation${j?` « ${j} »`:""}, et non sur votre compte personnel.`:`These credits will be credited directly to your organization${j?` â${j}â`:""} account, not to your personal account.`}),e.jsx("p",{children:t?"Les crédits sont valables 1 an. Cette opération est définitive : les gains convertis ne pourront plus faire lâobjet dâun paiement.":"Credits are valid for 1 year. This action is final: converted earnings can no longer be paid out."})]})})]}),e.jsxs(bs,{children:[e.jsx(vs,{disabled:D,children:t?"Annuler":"Cancel"}),e.jsxs(Ns,{onClick:s=>{s.preventDefault(),Ye()},disabled:D,children:[D&&e.jsx(L,{className:"mr-1.5 h-4 w-4 animate-spin"}),t?"Confirmer la conversion":"Confirm conversion"]})]})]})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:ie?C<=0?t?"Aucun gain disponible à convertir pour le moment.":"No earnings available to convert yet.":t?"Conversion immédiate sans minimum, crédits valables 1 an. Vous pourrez demander un paiement et émettre une facture à partir de 50 ⬠HT de revenus générés.":"Immediate conversion with no minimum, credits valid for 1 year. You will be able to request a payout and issue an invoice from â¬50 excl. VAT of generated earnings.":t?"La conversion instantanée en crédits nécessite un abonnement Business actif sur votre organisation.":"Instant conversion into credits requires an active Business subscription on your organization."})]})}),e.jsx(b,{className:"mt-5",children:e.jsxs(v,{className:"space-y-4 p-4 sm:p-5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(zs,{className:"h-4 w-4 text-primary"}),e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:t?"Mes affiliés":"My affiliates"}),!te&&e.jsx(T,{variant:"secondary",children:F.length})]}),te?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(L,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):F.length===0?e.jsx("p",{className:"py-6 text-center text-sm text-muted-foreground",children:t?"Aucun affilié pour le moment. Partagez votre lien pour commencer.":"No affiliates yet. Share your link to get started."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(R,{children:[e.jsx(B,{children:e.jsxs(f,{children:[e.jsx(l,{className:"w-10"}),e.jsx(l,{children:t?"Prénom":"First name"}),e.jsx(l,{children:t?"Date dâinscription":"Sign-up date"}),e.jsx(l,{className:"text-right",children:t?"Achats":"Purchases"})]})}),e.jsx(K,{children:F.map(s=>{const r=Pe[s.user_id]??[],a=$e===s.user_id;return e.jsxs(c.Fragment,{children:[e.jsxs(f,{className:r.length>0?"cursor-pointer":void 0,onClick:()=>r.length>0&&ze(a?null:s.user_id),children:[e.jsx(o,{className:"pr-0",children:r.length>0&&e.jsx(Rs,{className:`h-4 w-4 text-muted-foreground transition-transform ${a?"rotate-90":""}`})}),e.jsx(o,{className:"font-medium",children:s.first_name||"â"}),e.jsx(o,{className:"text-sm text-muted-foreground",children:new Date(s.signed_up_at).toLocaleDateString(t?"fr-FR":"en-US",{day:"2-digit",month:"2-digit",year:"numeric"})}),e.jsx(o,{className:"text-right",children:e.jsx(T,{variant:r.length>0?"default":"secondary",children:r.length})})]}),a&&e.jsx(f,{className:"bg-muted/40 hover:bg-muted/40",children:e.jsx(o,{colSpan:4,className:"p-0",children:e.jsx("div",{className:"px-4 py-3",children:e.jsxs(R,{children:[e.jsx(B,{children:e.jsxs(f,{children:[e.jsx(l,{className:"h-8 text-xs",children:"Date"}),e.jsx(l,{className:"h-8 text-xs",children:t?"Offre":"Plan"}),e.jsx(l,{className:"h-8 text-right text-xs",children:t?"Montant HT":"Amount excl. VAT"}),e.jsx(l,{className:"h-8 text-right text-xs",children:"Commission"})]})}),e.jsx(K,{children:r.map(n=>e.jsxs(f,{children:[e.jsx(o,{className:"py-2 text-xs text-muted-foreground",children:new Date(n.purchased_at).toLocaleDateString(t?"fr-FR":"en-US",{day:"2-digit",month:"2-digit",year:"numeric"})}),e.jsx(o,{className:"py-2 text-xs",children:e.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{children:Re(n)}),n.is_promo&&e.jsx(T,{variant:"secondary",className:"h-5 px-1.5 text-[10px]",children:"Promo"})]})}),e.jsx(o,{className:"py-2 text-right text-xs",children:u(n.amount_cents,n.currency)}),e.jsx(o,{className:"py-2 text-right text-xs font-medium text-primary",children:u(n.commission_cents,n.currency)})]},n.purchase_id))})]})})})})]}
8,s.user_id)})})]})})]})}),y&&e.jsx(b,{className:"mt-5",children:e.jsxs(v,{className:"space-y-4 p-4 sm:p-5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Bs,{className:"h-4 w-4 text-primary"}),e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:t?"Activité de mon lien dâaffiliation (30 derniers jours)":"My affiliate link activity (last 30 days)"})]}),e.jsx("div",{className:"h-64 w-full",children:e.jsx(Ks,{width:"100%",height:"100%",children:e.jsxs(Hs,{data:ns,margin:{top:5,right:10,left:-18,bottom:0},children:[e.jsx(Vs,{strokeDasharray:"3 3",className:"stroke-border"}),e.jsx(Ms,{dataKey:"label",tick:{fontSize:11},interval:"preserveStartEnd",minTickGap:28,className:"text-muted-foreground"}),e.jsx(Us,{allowDecimals:!1,tick:{fontSize:11},className:"text-muted-foreground"}),e.jsx(Is,{contentStyle:{backgroundColor:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"0.5rem",fontSize:"0.8rem"}}),e.jsx(Os,{wrapperStyle:{fontSize:"0.8rem"}}),e.jsx(Ce,{type:"monotone",dataKey:"clicks",name:t?"Clics sur le lien":"Link clicks",stroke:"hsl(var(--primary))",strokeWidth:2,dot:!1}),e.jsx(Ce,{type:"monotone",dataKey:"signups",name:t?"Filleuls inscrits":"Referral signups",stroke:"hsl(142 70% 45%)",strokeWidth:2,dot:!1})]})})})]})}),e.jsx(b,{className:"mt-5",children:e.jsxs(v,{className:"space-y-4 p-4 sm:p-5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_e,{className:"h-4 w-4 text-primary"}),e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:t?"Mes revenus dâaffiliation":"My affiliate earnings"})]}),Be?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(L,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):I.length===0?e.jsx("p",{className:"py-6 text-center text-sm text-muted-foreground",children:t?"Aucun revenu pour le moment.":"No earnings yet."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(R,{children:[e.jsx(B,{children:e.jsxs(f,{children:[e.jsx(l,{children:t?"Mois":"Month"}),e.jsx(l,{className:"text-right",children:t?"Achats":"Purchases"}),e.jsx(l,{className:"text-right",children:"Volume"}),e.jsx(l,{className:"text-right",children:t?`Commission (${S})`:`Commission (${S})`})]})}),e.jsxs(K,{children:[I.map(s=>e.jsxs(f,{children:[e.jsx(o,{className:"font-medium capitalize",children:Ge(s.month_start)}),e.jsx(o,{className:"text-right text-sm text-muted-foreground",children:s.purchases_count}),e.jsx(o,{className:"text-right text-sm text-muted-foreground",children:u(s.gross_cents,s.currency)}),e.jsx(o,{className:"text-right font-semibold",children:u(s.commission_cents,s.currency)})]},`${s.month_start}-${s.currency}`)),Je.map(s=>e.jsxs(f,{className:"border-t-2 bg-muted/40",children:[e.jsx(o,{className:"font-semibold",children:t?"Total depuis le début":"Total since the beginning"}),e.jsx(o,{className:"text-right font-semibold",children:s.purchases_count}),e.jsx(o,{className:"text-right font-semibold",children:u(s.gross_cents,s.currency)}),e.jsx(o,{className:"text-right font-bold text-primary",children:u(s.commission_cents,s.currency)})]},`total-${s.currency}`))]})]})})]})}),y&&e.jsx(b,{className:"mt-5",children:e.jsxs(v,{className:"space-y-4 p-4 sm:p-5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Es,{className:"h-4 w-4 text-primary"}),e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:t?"Historique des paiements":"Payout history"})]}),ae.length===0?e.jsx("p",{className:"py-6 text-center text-sm text-muted-foreground",children:t?"Aucun paiement effectué pour le moment.":"No payout yet."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(R,{children:[e.jsx(B,{children:e.jsxs(f,{children:[e.jsx(l,{children:"Date"}),e.jsx(l,{children:"Type"}),e.jsx(l,{className:"text-right",children:t?"Montant":"Amount"}),e.jsx(l,{className:"text-right",children:t?"Statut":"Status"})]})}),e.jsx(K,{children:ae.map(s=>e.jsxs(f,{children:[e.jsx(o,{className:"text-sm",children:new Date(s.created_at).toLocaleDateString(t?"fr-FR":"en-US",{day:"2-digit",month:"2-digit",year:"numeric"})}),e.jsx(o,{className:"text-sm",children:s.method==="credits"?t?`Crédits (+${s.credits_granted})`:`Credits (+${s.credits_granted})`:t?"Virement":"Bank transfer"}),e.jsx(o,{className:"text-right font-semibold",children:u(Number(s.amount_cents||0),s.currency)}),e.jsx(o,{className:"text-right",children:e.jsx(T,{variant:s.status==="paid"?"default":"secondary",children:s.status==="paid"?s.method==="credits"?t?"Convert
8i en crédits":"Converted to credits":t?"Payé":"Paid":t?"En attente":"Pending"})})]},s.id))})]})})]})}),e.jsx(J,{open:Ve,onOpenChange:s=>{k&&V(s)},children:e.jsxs(G,{className:"sm:max-w-md",onEscapeKeyDown:s=>{k||s.preventDefault()},onInteractOutside:s=>{k||s.preventDefault()},children:[e.jsxs(Q,{children:[e.jsx(Z,{children:t?"Programme disponible en France uniquement":"Program available in France only"}),e.jsx(X,{children:k?t?"Le programme d'affiliation est actuellement disponible uniquement en euros (â¬). Vous pouvez déjà consulter et partager votre lien, mais les commissions ne pourront pas encore être versées.":"The affiliate program is currently available only in euros (â¬). You can already view and share your link, but commissions cannot be paid out yet.":t?"Le programme d'affiliation est pour l'instant ouvert uniquement aux entreprises situées en France. Votre entreprise étant enregistrée hors de France, vous ne pouvez pas encore y participer.":"The affiliate program is currently open only to companies based in France. As your company is registered outside France, you cannot join it yet."})]}),e.jsx("div",{className:"flex justify-end",children:k?e.jsx(N,{onClick:()=>V(!1),children:t?"J'ai compris":"Got it"}):e.jsx(N,{onClick:()=>Ee("/dashboard"),children:t?"Retour au tableau de bord":"Back to dashboard"})})]})})]})})};export{dr as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.