PageSourceSearch

https://startuplive.ngo/assets/AdminDashboard-D5-B5Lx7.js

js startuplive.ngo collected 2026-10-09 18:10:48 UTC 802,396 bytes, 192 lines download raw bytes

1import{h as Br,u as gt,k as ed,j as e,R as L,r as _,s as k,B as Qe,C as Kr,J as W,l as td,c as rs,g as pt,m as Le,d as Qr,a as dn,t as we,e as Zr,X as Pr,f as On,T as Jo,n as vv,o as Fe}from"./index-EuY_-FAY.js";import{a as Hn,b as Xn,c as Yn,d as gv,e as yv,f as Ut,D as jv}from"./DashboardHeader-qK3Qmy-e.js";import{B as R}from"./button-DwzNqib_.js";import{S as Sl,N as bv}from"./NotificationCenter-DHgRHZeL.js";import{S as wv}from"./shield-nL0KFzur.js";import{S as Ls,C as lo,F as rd}from"./settings-DbY5cOJ-.js";import{C as nd}from"./chevron-down-D0i5abe3.js";import{H as Nv,L as Id}from"./list-checks-XjZkVVNc.js";import{U as Ge}from"./users-B7Eh8ycR.js";import{C as Cn,B as ns,S as tr}from"./search-BN9ssjqw.js";import{G as _r}from"./gift-D-4Z7Plk.js";import{H as Nn}from"./heart-t6FbOm2Z.js";import{B as It}from"./building-2-AqdBhrS9.js";import{B as Rs,F as _v,C as Sv,P as Ov,S as Gm,a as Hm,b as Xm,c as Ym,A as Cv,d as Av,H as Qm}from"./sheet-DMupNUYN.js";import{I as Nr}from"./image-rU_ppTuS.js";import{G as An}from"./graduation-cap-C2DPgq5_.js";import{M as sn}from"./message-square-CX4ymtRO.js";import{S as on}from"./star-DLxjevVK.js";import{C as qt}from"./calendar-TeXraZ6Q.js";import{M as St}from"./mail-BVVKtkzs.js";import{L as rn,T as Ol}from"./target-Cm-J7PgS.js";import{L as mi}from"./layers-BwsmrnUU.js";import{F as ln,L as Pv}from"./layout-dashboard-a4gKtYLw.js";import{A as kv,F as Ev}from"./Footer-DLYBYlrH.js";import{C as Y,c as Z,a as ce,b as le,d as ct}from"./card-CIFW0qNz.js";import{B as re}from"./badge-BiGl0epm.js";import{K as Gs,l as Cl,t as Tv,a as $v,c as Pn,b as Dv,d as Mv,L as Ld,A as Rd,m as Hs,e as Fd}from"./KPISparkline-BhhDeoeA.js";import{T as Jr}from"./trending-up-DfxLE4nH.js";import{C as Iv,P as Ve}from"./plus-DP6EyEDe.js";import{C as $r}from"./clock-C9pzXbgT.js";import{U as Fs}from"./user-plus-tyTYVH-R.js";import{R as _n,i as Bs,m as Lv,d as Rv,b as Al,a as Fv,c as Bv,e as zv,f as Uv,g as qv,h as Vv,j as Wv,l as Kv,o as Gv,p as Ia,k as Hv,q as Xv,n as Yv,r as Qv,s as Zv,t as Jv,u as eg,v as tg,w as rg,x as ng,y as ag,z as sg,A as ig,B as og,C as lg,D as cg,F as Bd,E as dg,G as Zm,H as co,L as Jm,T as ef,I as ug,P as Pl,J as tf,K as rf,_ as hg,M as mg}from"./Line-DKWHPcEV.js";import fg from"./Users-YDTXGjyT.js";import{S as Tt}from"./switch-C1fACMOm.js";import{I as de}from"./input-CwLsOgdz.js";import{S as xe,a as ve,b as ge,c as ye,d as J}from"./select-Zkugu-mn.js";import{E as Zt}from"./external-link-SoEG5yvx.js";import{C as pr}from"./check-BFBMQrmy.js";import{u as fi}from"./useQuery-DeYV4IS5.js";import{u as as}from"./useMutation-_L21eS81.js";import{L as B}from"./label-DHjRMKAW.js";import{C as pg,E as xg,R as vg}from"./cityCoordinates-BF9Pw5Lr.js";import{T as zr,a as Ur,b as Be,c as ze}from"./tabs-BkjaH3fl.js";import{M as kn}from"./map-pin-CiJS0zpt.js";import{i as Or,_ as nf,a as uo,b as ho,c as ba,d as $e,e as gg,f as af,g as ad,k as sd,h as sf,j as of,l as yg,m as jg,n as lf,o as bg,p as wg,q as Ng,r as mo,s as _g,t as Sg,u as Og,v as zs,w as Cg,x as Ag,R as La}from"./quill.snow-Dj63gIbu.js";import{P as Me}from"./index-CCnnvLwg.js";import{L as pi,G as Pg}from"./list-DRGo6gHo.js";import{E as dr}from"./eye-DWMmm-eV.js";import{T as Pt}from"./textarea-D6vuaKhs.js";import{C as fo}from"./checkbox-D-yVHPM-.js";import{A as Bt}from"./arrow-left-lIwOt_N5.js";import{S as cf}from"./send-CxotHqOi.js";import{D as ut,f as cn,a as ht,b as mt,c as ft,d as $t,e as Vt}from"./dialog-BshpMbXa.js";import{T as We,C as Ra,a as Fa,b as Ba,c as za,d as Ua,e as yn,V as df}from"./command-CJk2AU3Y.js";import{P as qa,a as Va,b as Wa}from"./popover-C1CUfueU.js";import{g as zd,T as kg}from"./timezones-CsxV_3Uh.js";import{C as uf}from"./CityCountryInput-DzjN59o-.js";import{a as Eg,f as Tg}from"./venueAddress-DVUbw9NQ.js";import{S as En}from"./square-pen-DgtJmqsG.js";import{C as ui}from"./chevrons-up-down-CWJDjV6L.js";import{f as Xs}from"./index-Cb8UU1H3.js";import{t as $g}from"./index-DwFUDgNw.js";import{f as Et}from"./format-BJatCrh1.js";import{A as Dg,a as Mg,b as Ig,c as Lg}from"./accordion-DayEqlAl.js";import{A as rr,h as ss,a as nr,b as ar,c as sr,d as ir,e as or,f as lr,g as cr}from"./alert-dialog-Dzo3XCPR.js";import{S as wa}from"./save-B2VAfAIz.js";import{T as nt,a as at,b as pe,c as te,d as st,e as X}from"./table-B7IdTOLn.js";import{E as xi,T as kl,C as hf}from"./thumbs-up-Bz_utueh.js";import{u as el,w as Rg}from"./xlsx-DjuO7_Ju.js";import{A as Dr,a as Mr,b as Ir}from"./avatar-DmtcMqZM.js";import{D as id}from"./download-Gq_d9FhN.js";import{D as mf}from"./dollar-sign-Lxv_EYwt.js";import{G as Da}from"./globe-DmqLM4zl.js";import{L as El}from"./linkedin-CHWP1gWB.js";import{T as Tl}from"./twitter-7bv0L9_e.js";import{U as Fg}from"./user-minus-UfNbG_DV.js";import{A as Bg,a as zg,F as Ug}from"./filter-BX-yFJmx.js";import{P as Tn}from"./pencil-DIhapAap.js";import{U as ff,b as pf,A as qg,g as Vg,a as Wg,B as Ud,C as Kg}from"./ChatSystem-4zb8rVWu.js";import{a as Gg,C as Hg}from"./circle-user-C6EVL7I0.js";import{G as Xg}from"./gavel-MZkOC5Ei.js";import{M as Yg}from"./mic-B2yxq-CM.js";import{A as tl,a as rl}from"./alert-DR-0QDfO.js";import{C as Ka}from"./credit-card-JQAZ1OdP.js";import{L as At}from"./loader-circle-Caxve_ph.js";import{S as xf}from"./sparkles-CDimFECD.js";import{P as Qg}from"./presentation-1PlbYjJw.js";import{A as Zg}from"./award-CK-g5_KF.js";import{M as vi}from"./message-circle-CRCqvEFj.js";import{C as Jg}from"./chevron-up-BGLh5JIr.js";import{f as po}from"./formatDistanceToNow-D9Nv8Mq4.js";import{L as ey}from"./lock-BAVbJQ92.js";import{U as ty}from"./user-DuBvhp_O.js";import{C as ry}from"./circle-check-DZuRMJvy.js";import{P as qd}from"./phone-DpYTnNq-.js";import{R as vf}from"./rocket-D93ZlqmD.js";import{S as ny}from"./separator-CP7aABc2.js";import"./index-BMKRCHpo.js";import"./index-BJKYc_OV.js";import"./index-BccXDNaF.js";import"./index-BSIHs9Yh.js";
1import"./index-C40cg7B2.js";import"./index-BONWbLIr.js";import"./index-BXTDk0Ug.js";import"./index-DKmrCAge.js";import"./chevron-right-R-JJXQF-.js";import"./index-BdQq_4o_.js";import"./index-Byc0C5HR.js";import"./eye-off-Cp1ZERv1.js";import"./CustomLinksManager-CYGJDcW7.js";import"./FileUpload-D5YsiDk4.js";import"./index-90AI2Mcq.js";import"./index-wQwPqDfP.js";import"./differenceInMilliseconds-ycH2onZd.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 $l=Br("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);/**
7 * @license lucide-react v0.462.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const Vd=Br("Euro",[["path",{d:"M4 10h12",key:"1y6xl8"}],["path",{d:"M4 14h9",key:"1loblj"}],["path",{d:"M19 6a7.7 7.7 0 0 0-5.2-2A7.9 7.9 0 0 0 6 12c0 4.4 3.5 8 7.8 8 2 0 3.8-.8 5.2-2",key:"1j6lzo"}]]);/**
12 * @license lucide-react v0.462.0 - ISC
13 *
14 * This source code is licensed under the ISC license.
15 * See the LICENSE file in the root directory of this source tree.
16 */const ay=Br("FolderPlus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/**
17 * @license lucide-react v0.462.0 - ISC
18 *
19 * This source code is licensed under the ISC license.
20 * See the LICENSE file in the root directory of this source tree.
21 */const gf=Br("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);/**
22 * @license lucide-react v0.462.0 - ISC
23 *
24 * This source code is licensed under the ISC license.
25 * See the LICENSE file in the root directory of this source tree.
26 */const Ys=Br("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/**
27 * @license lucide-react v0.462.0 - ISC
28 *
29 * This source code is licensed under the ISC license.
30 * See the LICENSE file in the root directory of this source tree.
31 */const sy=Br("LockOpen",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);/**
32 * @license lucide-react v0.462.0 - ISC
33 *
34 * This source code is licensed under the ISC license.
35 * See the LICENSE file in the root directory of this source tree.
36 */const yf=Br("PenTool",[["path",{d:"M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z",key:"nt11vn"}],["path",{d:"m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18",key:"15qc1e"}],["path",{d:"m2.3 2.3 7.286 7.286",key:"1wuzzi"}],["circle",{cx:"11",cy:"11",r:"2",key:"xmgehs"}]]);/**
37 * @license lucide-react v0.462.0 - ISC
38 *
39 * This source code is licensed under the ISC license.
40 * See the LICENSE file in the root directory of this source tree.
41 */const iy=Br("ToggleLeft",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"8",cy:"12",r:"2",key:"1nvbw3"}]]);/**
42 * @license lucide-react v0.462.0 - ISC
43 *
44 * This source code is licensed under the ISC license.
45 * See the LICENSE file in the root directory of this source tree.
46 */const Wd=Br("Unlink",[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]]);/**
47 * @license lucide-react v0.462.0 - ISC
48 *
49 * This source code is licensed under the ISC license.
50 * See the LICENSE file in the root directory of this source tree.
51 */const oy=Br("UserX",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]]),Kd=[{label:"Dashboard",items:[{path:"/dashboard/admin",label:"Overview",icon:Nv}]},{label:"People & Organizations",items:[{path:"/dashboard/admin/users",label:"Users",icon:Ge},{path:"/dashboard/admin/memberships",label:"Memberships",icon:Cn},{path:"/dashboard/admin/benefits",label:"Benefits",icon:_r},{path:"/dashboard/admin/buddies",label:"Buddy Program",icon:Nn},{path:"/dashboard/admin/companies",label:"Companies",icon:It}
51,{path:"/dashboard/admin/chapters",label:"Chapters",icon:Rs}]},{label:"Content",items:[{path:"/dashboard/admin/blog",label:"Blog",icon:yf},{path:"/dashboard/admin/media",label:"Media Library",icon:Nr},{path:"/dashboard/admin/knowledge",label:"Knowledge Hub",icon:An},{path:"/dashboard/admin/discussions",label:"Discussions",icon:sn},{path:"/dashboard/admin/faq",label:"FAQ",icon:on},{path:"/dashboard/admin/reviews",label:"Reviews",icon:on}]},{label:"Events & Communication",items:[{path:"/dashboard/admin/events",label:"Events",icon:qt},{path:"/dashboard/admin/founders-track",label:"Founders Track",icon:An},{path:"/dashboard/admin/newsletter",label:"Newsletter",icon:St}]},{label:"System",items:[{path:"/dashboard/admin/feedback",label:"Feedback",icon:rn},{path:"/dashboard/admin/templates",label:"Email Templates",icon:St},{path:"/dashboard/admin/registration-emails",label:"Registration Emails",icon:St},{path:"/dashboard/admin/program-templates",label:"Program Templates",icon:mi},{path:"/dashboard/admin/pagesettings",label:"Page Settings",icon:ln},{path:"/dashboard/admin/settings",label:"System Settings",icon:Ls},{path:"/dashboard/admin/analytics",label:"Analytics",icon:lo}]}],ly=()=>{const t=gt(),r=ed(),n=()=>{for(const a of Kd){const s=a.items.find(i=>r.pathname===i.path||i.path!=="/dashboard/admin"&&r.pathname.startsWith(i.path));if(s)return s.label}return"Overview"};return e.jsx("div",{className:"bg-orange-50 border-b border-orange-200 px-4 sm:px-6 lg:px-8 py-2 sm:py-0",children:e.jsxs("div",{className:"flex justify-between items-center gap-3 min-h-[3rem] sm:h-12",children:[e.jsx("div",{className:"flex items-center space-x-3 sm:space-x-4",children:e.jsxs("div",{className:"flex items-center space-x-2 text-gray-900 p-2",children:[e.jsx(wv,{className:"w-5 h-5 text-orange-600 shrink-0"}),e.jsxs("div",{className:"flex flex-col items-start",children:[e.jsx("span",{className:"text-sm font-semibold text-gray-900",children:"Administration"}),e.jsx("span",{className:"text-xs text-gray-600 hidden sm:block",children:"System Management"})]})]})}),e.jsxs(Hn,{children:[e.jsx(Xn,{asChild:!0,children:e.jsxs(R,{variant:"ghost",className:"flex items-center gap-2 hover:bg-orange-100 transition-colors rounded px-3 py-2 h-auto",children:[e.jsx(Ls,{className:"w-4 h-4 text-orange-600"}),e.jsx("span",{className:"text-sm font-medium text-gray-900 max-w-[120px] truncate sm:max-w-none",children:n()}),e.jsx(nd,{className:"w-4 h-4 text-gray-500 shrink-0"})]})}),e.jsx(Yn,{align:"end",className:"w-64 bg-card border shadow-lg z-50 p-0",children:e.jsx(Sl,{className:"h-[min(400px,70vh)]",children:e.jsx("div",{className:"p-1",children:Kd.map((a,s)=>e.jsxs(L.Fragment,{children:[s>0&&e.jsx(gv,{className:"my-1"}),e.jsx(yv,{className:"text-xs text-muted-foreground font-medium px-2 py-1.5",children:a.label}),a.items.map(i=>{const o=i.icon,l=r.pathname===i.path||i.path!=="/dashboard/admin"&&r.pathname.startsWith(i.path);return e.jsxs(Ut,{onClick:()=>t(i.path),className:`cursor-pointer transition-all duration-150 rounded-md mx-1 ${l?"bg-orange-100 text-orange-900 font-medium":"hover:bg-orange-50 focus:bg-orange-50"}`,children:[e.jsx(o,{className:`mr-2 h-4 w-4 shrink-0 ${l?"text-orange-600":"text-muted-foreground"}`}),e.jsx("span",{className:"truncate",children:i.label})]},i.path)})]},a.label))})})})]})]})})},cy=()=>{const t=gt(),[r,n]=_.useState({totalUsers:0,activeEvents:0,totalCompanies:0,totalMentors:0,pendingMentors:0,pendingReviews:0,draftPosts:0,recentUsers:0}),[a,s]=_.useState({users:[],events:[],companies:[],mentors:[]}),[i,o]=_.useState([]),[l,c]=_.useState(!0);_.useEffect(()=>{u()},[]);const u=async()=>{var x,v,y,f;try{c(!0);const b=new Date;b.setDate(b.getDate()-84);const[p,g,N,S,O,C,P,$,A,I,D,q,F,K]=await Promise.all([k.from("profiles").select("*",{count:"exact",head:!0}),k.from("events").select("*",{count:"exact",head:!0}).eq("status","Live"),k.from("companies").select("*",{count:"exact",head:!0}),k.from("role_extensions").select("*",{count:"exact",head:!0}).eq("role_type","mentor").eq("status","Live"),k.from("role_extensions").select("*",{count:"exact",head:!0}).eq("role_type","mentor").eq("status","Pending"),k.from("reviews").select("*",{count:"exact",head:!0}
51).eq("status","pending"),k.from("posts").select("*",{count:"exact",head:!0}).eq("status","draft"),k.from("profiles").select("id, name, created_at").order("created_at",{ascending:!1}).limit(5),k.from("role_extensions").select("id, role_data, status, created_at").eq("role_type","mentor").order("created_at",{ascending:!1}).limit(3),k.from("companies").select("id, name, status, created_at").order("created_at",{ascending:!1}).limit(3),k.from("profiles").select("created_at").gte("created_at",b.toISOString()),k.from("companies").select("created_at").gte("created_at",b.toISOString()),k.from("role_extensions").select("created_at").eq("role_type","mentor").gte("created_at",b.toISOString()),k.from("events").select("created_at").gte("created_at",b.toISOString())]),M=new Date;M.setDate(M.getDate()-7);const E=((x=$.data)==null?void 0:x.filter(V=>new Date(V.created_at)>M).length)||0;n({totalUsers:p.count||0,activeEvents:g.count||0,totalCompanies:N.count||0,totalMentors:S.count||0,pendingMentors:O.count||0,pendingReviews:C.count||0,draftPosts:P.count||0,recentUsers:E});const Q=(V,se)=>{if(!V)return[];const ue=[],z=new Date;for(let he=11;he>=0;he--){const ne=new Date(z);ne.setDate(ne.getDate()-he*7),ne.setHours(23,59,59,999);const fe=V.filter(Ce=>new Date(Ce.created_at)<=ne).length,De=se-(V.length-fe);ue.push({date:new Date(ne),value:Math.max(0,De)})}return ue};s({users:Q(D.data,p.count||0),companies:Q(q.data,N.count||0),mentors:Q(F.data,S.count||0),events:Q(K.data,g.count||0)});const H=[];(v=$.data)==null||v.slice(0,3).forEach(V=>{H.push({id:`user-${V.id}`,type:"user",title:V.name||"New User",subtitle:"User registered",time:d(V.created_at)})}),(y=A.data)==null||y.forEach(V=>{const se=V.role_data||{};H.push({id:`mentor-${V.id}`,type:"mentor",title:se.first_name&&se.last_name?`${se.first_name} ${se.last_name}`.trim():"Mentor",subtitle:V.status==="Pending"?"Awaiting approval":"Mentor profile",time:d(V.created_at),status:V.status})}),(f=I.data)==null||f.forEach(V=>{H.push({id:`company-${V.id}`,type:"company",title:V.name,subtitle:"Company profile",time:d(V.created_at),status:V.status})}),H.sort((V,se)=>{const ue=h(V.time),z=h(se.time);return ue-z}),o(H.slice(0,8))}catch(b){console.error("Error fetching stats:",b)}finally{c(!1)}},d=x=>{const v=new Date(x),f=new Date().getTime()-v.getTime(),b=Math.floor(f/6e4),p=Math.floor(f/36e5),g=Math.floor(f/864e5);return b<60?`${b}m ago`:p<24?`${p}h ago`:g<7?`${g}d ago`:v.toLocaleDateString()},h=x=>x.includes("m ago")?parseInt(x):x.includes("h ago")?parseInt(x)*60:x.includes("d ago")?parseInt(x)*1440:99999,m=x=>{const v={user:{icon:Fs,bg:"bg-blue-100 dark:bg-blue-900/30",color:"text-blue-600"},company:{icon:It,bg:"bg-purple-100 dark:bg-purple-900/30",color:"text-purple-600"},mentor:{icon:An,bg:"bg-green-100 dark:bg-green-900/30",color:"text-green-600"},event:{icon:qt,bg:"bg-orange-100 dark:bg-orange-900/30",color:"text-orange-600"},review:{icon:on,bg:"bg-yellow-100 dark:bg-yellow-900/30",color:"text-yellow-600"},post:{icon:ln,bg:"bg-indigo-100 dark:bg-indigo-900/30",color:"text-indigo-600"}};return v[x]||v.user},j=[{label:"People & Organizations",items:[{label:"Users",icon:Ge,path:"/dashboard/admin/users",color:"text-blue-600",bg:"bg-blue-100 dark:bg-blue-900/30"},{label:"Memberships",icon:Cn,path:"/dashboard/admin/memberships",color:"text-amber-600",bg:"bg-amber-100 dark:bg-amber-900/30"},{label:"Buddy Program",icon:Nn,path:"/dashboard/admin/buddies",color:"text-pink-600",bg:"bg-pink-100 dark:bg-pink-900/30"},{label:"Companies",icon:It,path:"/dashboard/admin/companies",color:"text-purple-600",bg:"bg-purple-100 dark:bg-purple-900/30"},{label:"Chapters",icon:Rs,path:"/dashboard/admin/chapters",color:"text-cyan-600",bg:"bg-cyan-100 dark:bg-cyan-900/30"}]},{label:"Content",items:[{label:"Blog",icon:yf,path:"/dashboard/admin/blog",color:"text-indigo-600",bg:"bg-indigo-100 dark:bg-indigo-900/30"},{label:"Media",icon:Nr,path:"/dashboard/admin/media",color:"text-pink-600",bg:"bg-pink-100 dark:bg-pink-900/30"},{label:"FAQ",icon:on,path:"/dashboard/admin/faq",color:"text-yellow-600",bg:"bg-yellow-100 dark:bg-yellow-900/30"},{label:"Reviews",icon:sn,path:"/dashboard/admin/reviews",color:"text-amber-600",bg:"bg-amber-100 dar
51k:bg-amber-900/30"}]},{label:"Events & Communication",items:[{label:"Events",icon:qt,path:"/dashboard/admin/events",color:"text-orange-600",bg:"bg-orange-100 dark:bg-orange-900/30"},{label:"Newsletter",icon:St,path:"/dashboard/admin/newsletter",color:"text-teal-600",bg:"bg-teal-100 dark:bg-teal-900/30"}]},{label:"System",items:[{label:"Templates",icon:St,path:"/dashboard/admin/templates",color:"text-emerald-600",bg:"bg-emerald-100 dark:bg-emerald-900/30"},{label:"Settings",icon:Ls,path:"/dashboard/admin/pagesettings",color:"text-gray-600",bg:"bg-gray-100 dark:bg-gray-800/30"},{label:"Analytics",icon:lo,path:"/dashboard/admin/analytics",color:"text-rose-600",bg:"bg-rose-100 dark:bg-rose-900/30"}]}];if(l)return e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Qe,{size:48})});const w=r.pendingMentors>0||r.pendingReviews>0||r.draftPosts>0;return e.jsxs("div",{className:"p-4 md:p-6 space-y-4 md:space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsxs(Y,{className:"bg-gradient-to-br from-blue-50 to-blue-100/50 dark:from-blue-950/30 dark:to-blue-900/20 border-blue-200/50 overflow-hidden relative animate-fade-in transition-all duration-300 hover:scale-[1.02] hover:shadow-lg hover:border-blue-300 cursor-pointer group",style:{animationDelay:"0ms"},children:[e.jsx(Z,{className:"p-4 pb-12 relative z-10",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Users"}),e.jsx("p",{className:"text-2xl font-bold text-foreground",children:r.totalUsers.toLocaleString()}),r.recentUsers>0&&e.jsxs("p",{className:"text-xs text-green-600 flex items-center gap-1",children:[e.jsx(Jr,{className:"w-3 h-3"}),"+",r.recentUsers," this week"]})]}),e.jsx(Ge,{className:"w-6 h-6 text-blue-600/50 transition-transform duration-300 group-hover:scale-110"})]})}),e.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-12 transition-all duration-300 group-hover:h-14",children:e.jsx(Gs,{data:a.users,color:"#2563eb",gradientId:"users-gradient"})})]}),e.jsxs(Y,{className:"bg-gradient-to-br from-orange-50 to-orange-100/50 dark:from-orange-950/30 dark:to-orange-900/20 border-orange-200/50 overflow-hidden relative animate-fade-in transition-all duration-300 hover:scale-[1.02] hover:shadow-lg hover:border-orange-300 cursor-pointer group",style:{animationDelay:"50ms"},children:[e.jsx(Z,{className:"p-4 pb-12 relative z-10",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Active Events"}),e.jsx("p",{className:"text-2xl font-bold text-foreground",children:r.activeEvents})]}),e.jsx(qt,{className:"w-6 h-6 text-orange-600/50 transition-transform duration-300 group-hover:scale-110"})]})}),e.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-12 transition-all duration-300 group-hover:h-14",children:e.jsx(Gs,{data:a.events,color:"#ea580c",gradientId:"events-gradient"})})]}),e.jsxs(Y,{className:"bg-gradient-to-br from-purple-50 to-purple-100/50 dark:from-purple-950/30 dark:to-purple-900/20 border-purple-200/50 overflow-hidden relative animate-fade-in transition-all duration-300 hover:scale-[1.02] hover:shadow-lg hover:border-purple-300 cursor-pointer group",style:{animationDelay:"100ms"},children:[e.jsx(Z,{className:"p-4 pb-12 relative z-10",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Companies"}),e.jsx("p",{className:"text-2xl font-bold text-foreground",children:r.totalCompanies.toLocaleString()})]}),e.jsx(It,{className:"w-6 h-6 text-purple-600/50 transition-transform duration-300 group-hover:scale-110"})]})}),e.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-12 transition-all duration-300 group-hover:h-14",children:e.jsx(Gs,{data:a.companies,color:"#9333ea",gradientId:"companies-gradient"})})]}),e.jsxs(Y,{className:"bg-gradient-to-br from-green-50 to-green-100/50 dark:from-green-950/30 dark:to-green-900/20 border-green-200/50 overflow-hidden relative animate-fade-in transition-all duration-300 hover:scale-[1.02] hover:shadow-lg hover:border-green-300 cursor-pointer group",style:{animationDelay:"150ms"},children:[e.jsx(Z,{className:"p-4 pb-12 relative z-10",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Mentors"}),e.jsx("p",{className:"text-2xl font-bold text-foreground",children:r.totalMentors})]}),e.jsx(An,{className:"w-6 h-6 text-green-600/50 transition-transform duration-300 group-hover:scale-110"})]})}),e.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-12 transition-all duration-300 group-hover:h-14",children:e.jsx(Gs,{data:a.mentors,color:"#16a34a",gradientId:"mentors-gradient"})})]})]}),w&&e.jsxs(Y,{className:"border-amber-200 dark:border-amber-800 bg-amber-50/50 dark:bg-amber-950/20",children:[e.jsx(ce,{className:"pb-2 pt-4 px-4",children:e.jsxs(le,{className:"text-sm font-medium flex items-center gap-2 text-amber-800 dark:text-amber-400",children:[e.jsx(Iv,{className:"w-4 h-4"}),"Needs Attention"]})}),e.jsx(Z,{className:"px-4 pb-4",children:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.pendingMentors>0&&e.jsxs(R,{variant:"outline",size:"sm",className:"h-8 text-xs border-amber-300 hover:bg-amber-100 dar
51k:border-amber-700 dark:hover:bg-amber-900/30",onClick:()=>t("/dashboard/admin/mentors"),children:[e.jsx($r,{className:"w-3 h-3 mr-1.5"}),r.pendingMentors," Pending Mentors"]}),r.pendingReviews>0&&e.jsxs(R,{variant:"outline",size:"sm",className:"h-8 text-xs border-amber-300 hover:bg-amber-100 dark:border-amber-700 dark:hover:bg-amber-900/30",onClick:()=>t("/dashboard/admin/reviews"),children:[e.jsx($r,{className:"w-3 h-3 mr-1.5"}),r.pendingReviews," Pending Reviews"]}),r.draftPosts>0&&e.jsxs(R,{variant:"outline",size:"sm",className:"h-8 text-xs border-amber-300 hover:bg-amber-100 dark:border-amber-700 dark:hover:bg-amber-900/30",onClick:()=>t("/dashboard/admin/blog"),children:[e.jsx(ln,{className:"w-3 h-3 mr-1.5"}),r.draftPosts," Draft Posts"]})]})})]}),e.jsxs(Y,{className:"animate-fade-in",style:{animationDelay:"200ms"},children:[e.jsx(ce,{className:"pb-2 pt-4 px-4",children:e.jsx(le,{className:"text-sm font-medium",children:"Quick Access"})}),e.jsx(Z,{className:"px-4 pb-4",children:e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:j.map((x,v)=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-medium text-muted-foreground px-1",children:x.label}),e.jsx("div",{className:"space-y-1",children:x.items.map(y=>{const f=y.icon;return e.jsxs("button",{onClick:()=>t(y.path),className:"flex items-center gap-2 w-full p-2 rounded-lg hover:bg-muted transition-all duration-200 group hover:translate-x-1",children:[e.jsx("div",{className:`p-1.5 rounded-md ${y.bg} transition-colors`,children:e.jsx(f,{className:`w-3.5 h-3.5 ${y.color}`})}),e.jsx("span",{className:"text-xs text-muted-foreground group-hover:text-foreground transition-colors",children:y.label})]},y.path)})})]},x.label))})})]}),e.jsxs(Y,{children:[e.jsxs(ce,{className:"pb-2 pt-4 px-4 flex flex-row items-center justify-between",children:[e.jsx(le,{className:"text-sm font-medium",children:"Recent Activity"}),e.jsxs(R,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>t("/dashboard/admin/users"),children:["View all ",e.jsx(kv,{className:"w-3 h-3 ml-1"})]})]}),e.jsx(Z,{className:"px-4 pb-4",children:i.length>0?e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2",children:i.map(x=>{const{icon:v,bg:y,color:f}=m(x.type);return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border border-border hover:bg-muted/50 transition-colors cursor-pointer",onClick:()=>{x.type==="user"&&t("/dashboard/admin/users"),x.type==="mentor"&&t("/dashboard/admin/mentors"),x.type==="company"&&t("/dashboard/admin/companies")},children:[e.jsx("div",{className:`p-2 rounded-lg ${y} shrink-0`,children:e.jsx(v,{className:`w-4 h-4 ${f}`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:x.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:x.subtitle}),x.status==="Pending"&&e.jsx(re,{variant:"outline",className:"text-[10px] bg-amber-50 text-amber-700 border-amber-200 shrink-0",children:"Pending"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:x.time})]})]},x.id)})}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground text-sm",children:[e.jsx(Kr,{className:"w-8 h-8 mx-auto mb-2 text-green-500"}),"No recent activity"]})})]})]})},dy=()=>{const[t,r]=_.useState([]),[n,a]=_.useState(null),[s,i]=_.useState(""),[o,l]=_.useState(!1),[c,u]=_.useState(!1),[d,h]=_.useState(null),[m,j]=_.useState(""),[w,x]=_.useState(!1),[v,y]=_.useState(!1),[f,b]=_.useState(null),[p,g]=_.useState(!1),[N,S]=_.useState("Startup Live – Events"),[O,C]=_.useState(""),[P,$]=_.useState("writer"),[A,I]=_.useState(!1),[D,q]=_.useState(!1),[F,K]=_.useState(null),[M,E]=_.useState(!1),Q=async()=>{E(!0);try{const{data:T,error:ie}=await k.functions.invoke("google-drive",{body:{action:"status"}});if(ie)throw ie;K({connected:!!(T!=null&&T.connected),outcome:T==null?void 0:T.outcome})}catch{K({connected:!1,outcome:"failed"})}finally{E(!1)}},H=async T=>{const{data:ie,error:Se}=await k.functions.invoke("google-drive",{body:T});if(Se){let Ae=Se.message;const Pe=Se==null?void 0:Se.context;if(Pe!=null&&Pe.text)try{const Ue=await Pe.text(),be=JSON.parse(Ue);Ae=(be==null?void 0:be.error)||Ue}catch{}throw new Error(Ae)}return ie},V=async()=>{x(!0),b(null);try{const T=await H({action:"get_config"});T!=null&&T.root?(h(T.root),j("")):h(null)}catch(T){b(T.message||"Could not load Google Drive configuration")}finally{x(!1)}},se=async()=>{const T=m.trim(),ie=T.match(/\/folders\/([^/?#]+)/)||T.match(/[?&]id=([^&]+)/),Se=ie?ie[1]:T;y(!0),b(null);try{const Ae=await H({action:"set_config",folderId:Se});h(Ae.root),j(""),W.success("Shared Drive folder saved")}catch(Ae){b(Ae.message||"Could not save the folder"),W.error("Could not save the folder")}finally{y(!1)}},ue=async()=>{g(!0),b(null);try{const T=await H({action:"create_root_folder",name:N.trim()||void 0,emails:O.trim()||void 0,role:P,anyoneWithLink:A});h(T.root),j(""),he(T==null?void 0:T.sharing),W.success("Shared Drive folder created")}catch(T){b(T.message||"Could not create the folder"),W.error("Could not create the folder")}finally{g(!1)}},z=async()=>{g(!0),b(null);try{const T=await H({action:"create_shared_drive",name:N.trim()||void 0,emails:O.trim()||void 0,role:P});h(T.root),j(""),he(T==null?void 0:T.sharing),W.success("Shared drive created")}catch(T){b(T.message||"Could not create the shared drive"),W.error("Could not create the shared drive")}finally{g(!1)}},he=T=>{var ie,Se;T&&((ie=T.shared)!=null&&ie.length&&W.success(`Shared with ${T.shared.join(", ")}`),(Se=T.failed)!=null&&Se.length&&(b(T.failed.map(Ae=>`${Ae.target}: ${Ae.error}`).join(" · ")),W.error("Some people could not be added")))},ne=async()=>{q(!0),b(null);try{const T=await H({action:"share_root_folder",emails:O.trim()||void 0,role:P,anyoneWithLink:A});he(T==null?void 0:T.sharing),C("")}catch(T){b(T.message||"Could not share the folder"),W.error("Could not share the folder")}finally{q(!1)}},fe=()=>{d!=null&&d.url&&window.open(d.url,"_blank","noopener,noreferrer")},De=async()=>
51{l(!0);try{const{data:T,error:ie}=await k.functions.invoke("eventbrite-sync",{body:{action:"get-organizations"}});if(ie)throw ie;if(T.success)r(T.organizations||[]),a(T.currentOrganizationId),i(T.currentOrganizationId||"");else throw new Error(T.error||"Failed to fetch organizations")}catch(T){console.error("Error fetching Eventbrite organizations:",T),W.error("Failed to fetch Eventbrite organizations. Check if API key is configured.")}finally{l(!1)}};_.useEffect(()=>{De(),V(),Q()},[]);const Ce=async()=>{if(!s){W.error("Please select an organization");return}u(!0);try{const T=t.find(Ae=>Ae.id===s),{data:ie,error:Se}=await k.functions.invoke("eventbrite-sync",{body:{action:"set-organization",organizationId:s,organizationName:(T==null?void 0:T.name)||""}});if(Se)throw Se;if(ie.success)a(s),W.success("Eventbrite organization saved successfully");else throw new Error(ie.error||"Failed to save organization")}catch(T){console.error("Error saving organization:",T),W.error("Failed to save organization")}finally{u(!1)}},Re=t.find(T=>T.id===n);return e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ls,{className:"w-6 h-6 text-primary"}),e.jsx("h1",{className:"text-2xl font-bold",children:"System Settings"})]}),e.jsxs(Y,{children:[e.jsxs(ce,{children:[e.jsxs(le,{className:"flex items-center gap-2",children:[e.jsx(Zt,{className:"w-5 h-5"}),"Eventbrite Integration"]}),e.jsx(ct,{children:"Configure which Eventbrite organization to use for event synchronization."})]}),e.jsxs(Z,{className:"space-y-4",children:[Re&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted rounded-lg",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Current organization:"}),e.jsx(re,{variant:"secondary",className:"font-medium",children:Re.name})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(xe,{value:s,onValueChange:i,disabled:o,children:[e.jsx(ve,{className:"w-[300px]",children:e.jsx(ge,{placeholder:o?"Loading...":"Select organization"})}),e.jsx(ye,{children:t.map(T=>e.jsx(J,{value:T.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[T.name,T.id===n&&e.jsx(pr,{className:"w-4 h-4 text-green-500"})]})},T.id))})]}),e.jsx(R,{variant:"outline",size:"icon",onClick:De,disabled:o,children:e.jsx(_n,{className:`w-4 h-4 ${o?"animate-spin":""}`})}),e.jsx(R,{onClick:Ce,disabled:c||!s||s===n,children:c?"Saving...":"Save"})]}),t.length===0&&!o&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"No organizations found. Make sure your Eventbrite API key is configured correctly."}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"All new events will be created under the selected organization. Existing events are not affected."})]})]}),e.jsxs(Y,{children:[e.jsxs(ce,{children:[e.jsxs(le,{className:"flex items-center gap-2",children:[e.jsx(rd,{className:"w-5 h-5"}),"Google Drive"]}),e.jsx(ct,{children:"Set the shared Drive folder. Every event gets its own subfolder inside it, which program managers can browse and upload to from their event dashboard."})]}),e.jsxs(Z,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 p-3 bg-muted rounded-lg",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Connection:"}),F===null?e.jsx(re,{variant:"secondary",children:"Checking…"}):F.connected?e.jsxs(re,{className:"bg-green-600 hover:bg-green-600",children:[e.jsx(pr,{className:"w-3 h-3 mr-1"})," Connected"]}):e.jsx(re,{variant:"destructive",children:"Not connected"}),e.jsxs(R,{variant:"ghost",size:"sm",onClick:Q,disabled:M,children:[e.jsx(_n,{className:`w-3 h-3 mr-1 ${M?"animate-spin":""}`}),"Test connection"]}),F&&!F.connected&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Ask your Lovable admin to link the Google Drive connector for this project."})]}),d&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted rounded-lg",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Current folder:"}),e.jsx(re,{variant:"secondary",className:"font-medium",children:d.name}),d.url&&e.jsxs(R,{variant:"link",size:"sm",className:"h-auto p-0",onClick:fe,children:["Open in new tab ",e.jsx(Zt,{className:"w-3 h-3 ml-1"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Create the shared drive"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx(de,{value:N,onChange:T=>S(T.target.value),placeholder:"Shared drive name",className:"max-w-[420px]",disabled:p}),e.jsxs(R,{onClick:z,disabled:p,children:[e.jsx(ay,{className:"w-4 h-4 mr-2"}),p?"Creating...":"Create shared drive"]}),e.jsx(R,{variant:"outline",onClick:ue,disabled:p,children:"Create folder in My Drive"}),e.jsx(R,{variant:"outline",size:"icon",onClick:V,disabled:w,children:e.jsx(_n,{className:`w-4 h-4 ${w?"animate-spin":""}`})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Creates a real Google Shared drive owned by the team (requires a Google Worksp
51ace account) and adds the people below as members. The app manages one subfolder per event inside it."})]}),e.jsxs("div",{className:"space-y-2 pt-2 border-t",children:[e.jsx("p",{className:"text-sm font-medium",children:"Share the folder"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx(de,{value:O,onChange:T=>C(T.target.value),placeholder:"[email protected], [email protected]",className:"max-w-[420px]",disabled:D}),e.jsxs(xe,{value:P,onValueChange:T=>$(T),children:[e.jsx(ve,{className:"w-[160px]",children:e.jsx(ge,{})}),e.jsxs(ye,{children:[e.jsx(J,{value:"writer",children:"Can edit"}),e.jsx(J,{value:"reader",children:"Can view"})]})]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Tt,{checked:A,onCheckedChange:I}),"Anyone with the link"]}),e.jsxs(R,{variant:"outline",onClick:ne,disabled:D||!d||!O.trim()&&!A,children:[e.jsx(Ge,{className:"w-4 h-4 mr-2"}),D?"Sharing...":"Share"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Adds people to the current shared folder (they get a Drive notification email). Everything inside, including every event subfolder, inherits this access."})]}),e.jsxs("div",{className:"space-y-2 pt-2 border-t",children:[e.jsx("p",{className:"text-sm font-medium",children:"Or point at an existing folder"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{value:m,onChange:T=>j(T.target.value),placeholder:"Drive folder link or folder ID",className:"max-w-[420px]",disabled:w}),e.jsx(R,{variant:"outline",onClick:se,disabled:v||!m.trim(),children:v?"Saving...":"Save"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Only works for folders the app created itself. Existing folders and Shared Drives need broader Google access — ask your Lovable admin to re-grant the Drive connector with the full scope."})]}),f&&e.jsx("p",{className:"text-sm text-destructive",children:f})]})]})]})})},uy=()=>{const t=td(),[r,n]=_.useState({attendees_base:25e3,companies_base:7e3,mentors_base:300,corporates_base:500,participants_base:0,pitches_base:0,cities:60,countries:30,c_level_percentage:">60%"}),{data:a,isLoading:s}=fi({queryKey:["page-settings","homepage_stats"],queryFn:async()=>{const{data:c,error:u}=await k.from("page_settings").select("*").eq("setting_key","homepage_stats").maybeSingle();if(u)throw u;if(c!=null&&c.setting_value&&typeof c.setting_value=="object"){const d=c.setting_value;n({attendees_base:d.attendees_base||25e3,companies_base:d.companies_base||7e3,mentors_base:d.mentors_base||300,corporates_base:d.corporates_base||500,participants_base:d.participants_base||0,pitches_base:d.pitches_base||0,cities:d.cities||60,countries:d.countries||30,c_level_percentage:d.c_level_percentage||">60%"})}return c}}),i=as({mutationFn:async c=>{const{error:u}=await k.from("page_settings").update({setting_value:c,updated_at:new Date().toISOString()}).eq("setting_key","homepage_stats");if(u)throw u},onSuccess:()=>{t.invalidateQueries({queryKey:["page-settings"]}),W.success("Homepage statistics have been updated successfully.")},onError:c=>{W.error(`Failed to update settings: ${c.message}`)}}),o=c=>{c.preventDefault(),i.mutate(r)},l=(c,u)=>{n(d=>({...d,[c]:u}))};return s?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx(Qe,{size:64})}):e.jsxs("div",{className:"container mx-auto p-6 max-w-4xl",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"text-3xl font-bold",children:"Page Settings"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"Manage global page settings and configuration"})]}),e.jsxs(Y,{children:[e.jsxs(ce,{children:[e.jsx(le,{children:"Homepage Statistics"}),e.jsx(ct,{children:"Set the base values for homepage statistics. The actual displayed values will be these base values plus real-time data from the database."})]}),e.jsx(Z,{children:e.jsxs("form",{onSubmit:o,className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"attendees",children:"Attendees Base Value"}),e.jsx(de,{id:"attendees",type:"number",value:r.attendees_base,onChange:c=>l("attendees_base",parseInt(c.target.value)||0),placeholder:"25000"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Plus all people with user roles in events"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"companies",children:"Companies Base Value"}),e.jsx(de,{id:"companies",type:"number",value:r.companies_base,onChange:c=>l("companies_base",parseInt(c.target.value)||0),placeholder:"7000"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Plus all startups/scaleups at events"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"mentors",children:"Mentors Base Value"}),e.jsx(de,{id:"mentors",type:"number",value:r.mentors_base,onChange:c=>l("mentors_base",parseInt(c.target.value)||0),placeholder:"300"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Plus all mentors in the system"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"corporates",children:"Corporates Base Value"}),e.jsx(de,{id:"corporates",type:"number",value:r.corporates_base,onChange:c=>l("corporates_base",parseInt(c.target.value)||0),placeholder:"500"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Plus all corporates at events"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"c_level",children:"C-Level Percentage"}),e.jsx(de,{id:"c_level",type:"text",value:r.c_level_percentage,onChange:c=>l("c_level_percentage",c.target.value),placeholder:">60%"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Display format for C-level percentage"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"participants",children:"Participants Base Value"}),e.jsx(de,{id:"participants",type:"number",value:r.participants_base,onChange:c=>l("participants_base",parseInt(c.target.value)||0),placeholder:"0"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Plus all users with event roles"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"pitches",children:"Pitches Base Value"}),e.jsx(de,{id:"pitches",type:"number",value:r.pitches_base,onChange:c=>l("pitches_base",parseInt(c.target.value)||0),placeholder:"0"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Plus all startups in the system"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"cities",children:"Cities"}),e.jsx(de,{id:"cities",type:"number",value:r.cities,onChange:c=>l("cities",parseInt(c.target.value)||0),placeholder:"60"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Number of cities where events are held"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"countries",children:"Countries"}),e.jsx(de,{id:"countries",type:"number",value:r.countries,onChange:c=>l("countries",parseInt(c.target.value)||0),placeholder:"30"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Number of countries where events are held"})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(R,{type:"submit",disabled:i.isPending,children:[i.isPending&&e.jsx(Qe,{size:16,className:"mr-2"}),"Save Settings"]})})]})})]})]})},hy=[{title:"Dashboard",items:[{id:"overview",label:"Overview",icon:Pv,path:"/dashboard/admin"}]},{title:"Users & Content",items:[{id:"users",label:"Users",icon:Ge,path:"/dashboard/admin/users"},{id:"memberships",label:"Memberships",icon:Cn,path:"/dashboard/admin/memberships"}
51,{id:"benefits",label:"Benefits",icon:_r,path:"/dashboard/admin/benefits"},{id:"buddies",label:"Buddy Program",icon:Nn,path:"/dashboard/admin/buddies"},{id:"companies",label:"Companies",icon:It,path:"/dashboard/admin/companies"},{id:"chapters",label:"Chapters",icon:Rs,path:"/dashboard/admin/chapters"}]},{title:"Content",items:[{id:"blog",label:"Blog",icon:ln,path:"/dashboard/admin/blog"},{id:"media",label:"Media Library",icon:Nr,path:"/dashboard/admin/media"},{id:"knowledge",label:"Knowledge Hub",icon:An,path:"/dashboard/admin/knowledge"},{id:"discussions",label:"Discussions",icon:sn,path:"/dashboard/admin/discussions"},{id:"faq",label:"FAQ",icon:on,path:"/dashboard/admin/faq"},{id:"reviews",label:"Reviews",icon:on,path:"/dashboard/admin/reviews"}]},{title:"System",items:[{id:"feedback",label:"Feedback",icon:rn,path:"/dashboard/admin/feedback"},{id:"templates",label:"Email Templates",icon:St,path:"/dashboard/admin/templates"},{id:"program-templates",label:"Program Templates",icon:mi,path:"/dashboard/admin/program-templates"},{id:"analytics",label:"Analytics",icon:lo,path:"/dashboard/admin/analytics"},{id:"pagesettings",label:"Page Settings",icon:ln,path:"/dashboard/admin/pagesettings"},{id:"settings",label:"System Settings",icon:Ls,path:"/dashboard/admin/settings"}]}],jf=({currentSection:t})=>{const r=gt(),n=ed(),a=(s,i)=>s==="overview"?n.pathname==="/dashboard/admin":t===s||n.pathname.startsWith(i);return e.jsx("div",{className:"w-56 bg-card border-r border-border h-full",children:e.jsx("nav",{className:"px-3 py-4 space-y-6",children:hy.map((s,i)=>e.jsxs("div",{children:[e.jsx("h3",{className:"px-3 mb-2 text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:s.title}),e.jsx("div",{className:"space-y-0.5",children:s.items.map(o=>{const l=o.icon,c=a(o.id,o.path);return e.jsxs("button",{className:rs("w-full flex items-center gap-3 px-3 py-2 text-sm font-medium rounded-md transition-all duration-150","active:scale-[0.98]",c?"bg-primary/10 text-primary border-l-2 border-primary":"text-muted-foreground hover:bg-muted hover:text-foreground"),onClick:()=>r(o.path),children:[e.jsx(l,{className:rs("w-4 h-4 flex-shrink-0",c?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:"truncate",children:o.label})]},o.id)})})]},s.title))})})};var my=Or,fy=Bs,py=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,xy=/^\w*$/;function vy(t,r){if(my(t))return!1;var n=typeof t;return n=="number"||n=="symbol"||n=="boolean"||t==null||fy(t)?!0:xy.test(t)||!py.test(t)||r!=null&&t in Object(r)}var od=vy,gy=Lv,yy=500;function jy(t){var r=gy(t,function(a){return n.size===yy&&n.clear(),a}),n=r.cache;return r}var by=jy,wy=by,Ny=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,_y=/\\(\\)?/g,Sy=wy(function(t){var r=[];return t.charCodeAt(0)===46&&r.push(""),t.replace(Ny,function(n,a,s,i){r.push(s?i.replace(_y,"$1"):a||n)}),r}),Oy=Sy;function Cy(t,r){for(var n=-1,a=t==null?0:t.length,s=Array(a);++n<a;)s[n]=r(t[n],n,t);return s}var ld=Cy,Gd=nf,Ay=ld,Py=Or,ky=Bs,Ey=1/0,Hd=Gd?Gd.prototype:void 0,Xd=Hd?Hd.toString:void 0;function bf(t){if(typeof t=="string")return t;if(Py(t))return Ay(t,bf)+"";if(ky(t))return Xd?Xd.call(t):"";var r=t+"";return r=="0"&&1/t==-Ey?"-0":r}var Ty=bf,$y=Ty;function Dy(t){return t==null?"":$y(t)}var wf=Dy,My=Or,Iy=od,Ly=Oy,Ry=wf;function Fy(t,r){return My(t)?t:Iy(t,r)?[t]:Ly(Ry(t))}var Nf=Fy,By=Bs,zy=1/0;function Uy(t){if(typeof t=="string"||By(t))return t;var r=t+"";return r=="0"&&1/t==-zy?"-0":r}var xo=Uy,qy=Nf,Vy=xo;function Wy(t,r){r=qy(r,t);for(var n=0,a=r.length;t!=null&&n<a;)t=t[Vy(r[n++])];return n&&n==a?t:void 0}var cd=Wy,Ky=cd;function Gy(t,r,n){var a=t==null?void 0:Ky(t,r);return a===void 0?n:a}var _f=Gy;const Jt=pt(_f);function Hy(t){return t==null}var Xy=Hy;const Ie=pt(Xy);var Yy=uo,Qy=Or,Zy=ho,Jy="[object String]";function ej(t){return typeof t=="string"||!Qy(t)&&Zy(t)&&Yy(t)==Jy}var tj=ej;const Us=pt(tj);var Sf={exports:{}},He={};/**
52 * @license React
53 * react-is.production.min.js
54 *
55 * Copyright (c) Facebook, Inc. and its affiliates.
56 *
57 * This source code is licensed under the MIT license found in the
58 * LICENSE file in the root directory of this source tree.
59 */var dd=Symbol.for("react.element"),ud=Symbol.for("react.portal"),vo=Symbol.for("react.fragment"),go=Symbol.for("react.strict_mode"),yo=Symbol.for("react.profiler"),jo=Symbol.for("react.provider"),bo=Symbol.for("react.context"),rj=Symbol.for("react.server_context"),wo=Symbol.for("react.forward_ref"),No=Symbol.for("react.suspense"),_o=Symbol.for("react.suspense_list"),So=Symbol.for("react.memo"),Oo=Symbol.for("react.lazy"),nj=Symbol.for("react.offscreen"),Of;Of=Symbol.for("react.module.reference");function gr(t){if(typeof t=="object"&&t!==null){var r=t.$$typeof;switch(r){case dd:switch(t=t.type,t){case vo:case yo:case go:case No:case _o:return t;default:switch(t=t&&t.$$typeof,t){case rj:case bo:case wo:case Oo:case So:case jo:return t;default:return r}}case ud:return r}}}He.ContextConsumer=bo;He.ContextProvider=jo;He.Element=dd;He.ForwardRef=wo;He.Fragment=vo;He.Lazy=Oo;He.Memo=So;He.Portal=ud;He.Profiler=yo;He.StrictMode=go;He.Suspense=No;He.SuspenseList=_o;He.isAsyncMode=function(){return!1};He.isConcurrentMode=function(){return!1};He.isContextConsumer=function(t){return gr(t)===bo};He.isContextProvider=function(t){return gr(t)===jo};He.isElement=function(t){return typeof t=="object"&&t!==null&&t.$$typeof===dd};He.isForwardRef=function(t){return gr(t)===wo};He.isFragment=function(t){return gr(t)===vo};He.isLazy=function(t){return gr(t)===Oo};He.isMemo=function(t){return gr(t)===So};He.isPortal=function(t){return gr(t)===ud};He.isProfiler=function(t){return gr(t)===yo};He.isStrictMode=function(t){return gr(t)===go};He.isSuspense=function(t){return gr(t)===No};He.isSuspenseList=function(t){return gr(t)===_o};He.isValidElementType=function(t){return typeof t=="string"||typeof t=="function"||t===vo||t===yo||t===go||t===No||t===_o||t===nj||typeof t=="object"&&t!==null&&(t.$$typeof===Oo||t.$$typeof===So||t.$$typeof===jo||t.$$typeof===bo||t.$$typeof===wo||t.$$typeof===Of||t.getModuleId!==void 0)};He.typeOf=gr;Sf.exports=He;var Cf=Sf.exports,aj=uo,sj=ho,ij="[object Number]";function oj(t){return typeof t=="number"||sj(t)&&aj(t)==ij}var Af=oj;const lj=pt(Af);var cj=Af;function dj(t){return cj(t)&&t!=+t}var uj=dj;const qs=pt(uj);var Rt=function(r){return r===0?0:r>0?1:-1},bn=function(r){return Us(r)&&r.indexOf("%")===r.length-1},me=function(r){return lj(r)&&!qs(r)},_t=function(r){return me(r)||Us(r)},hj=0,Na=function(r){var n=++hj;return"".concat(r||"").concat(n)},Ft=function(r,n){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!me(r)&&!Us(r))return a;var i;if(bn(r)){var o=r.indexOf("%");i=n*parseFloat(r.slice(0,o))/100}else i=+r;return qs(i)&&(i=a),s&&i>n&&(i=n),i},tn=function(r){if(!r)return null;var n=Object.keys(r);return n&&n.length?r[n[0]]:null},mj=function(r){if(!Array.isArray(r))return!1;for(var n=r.length,a={},s=0;s<n;
vendor: 9,102 bytes, line 59
59s++)if(!a[r[s]])a[r[s]]=!0;else return!0;return!1},Xt=function(r,n){return me(r)&&me(n)?function(a){return r+a*(n-r)}:function(){return n}};function gi(t,r,n){return!t||!t.length?null:t.find(function(a){return a&&(typeof r=="function"?r(a):Jt(a,r))===n})}function Kn(t,r){for(var n in t)if({}.hasOwnProperty.call(t,n)&&(!{}.hasOwnProperty.call(r,n)||t[n]!==r[n]))return!1;for(var a in r)if({}.hasOwnProperty.call(r,a)&&!{}.hasOwnProperty.call(t,a))return!1;return!0}function Dl(t){"@babel/helpers - typeof";return Dl=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Dl(t)}var fj=["viewBox","children"],pj=["aria-activedescendant","aria-atomic","aria-autocomplete","aria-busy","aria-checked","aria-colcount","aria-colindex","aria-colspan","aria-controls","aria-current","aria-describedby","aria-details","aria-disabled","aria-errormessage","aria-expanded","aria-flowto","aria-haspopup","aria-hidden","aria-invalid","aria-keyshortcuts","aria-label","aria-labelledby","aria-level","aria-live","aria-modal","aria-multiline","aria-multiselectable","aria-orientation","aria-owns","aria-placeholder","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-roledescription","aria-rowcount","aria-rowindex","aria-rowspan","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext","className","color","height","id","lang","max","media","method","min","name","style","target","width","role","tabIndex","accentHeight","accumulate","additive","alignmentBaseline","allowReorder","alphabetic","amplitude","arabicForm","ascent","attributeName","attributeType","autoReverse","azimuth","baseFrequency","baselineShift","baseProfile","bbox","begin","bias","by","calcMode","capHeight","clip","clipPath","clipPathUnits","clipRule","colorInterpolation","colorInterpolationFilters","colorProfile","colorRendering","contentScriptType","contentStyleType","cursor","cx","cy","d","decelerate","descent","diffuseConstant","direction","display","divisor","dominantBaseline","dur","dx","dy","edgeMode","elevation","enableBackground","end","exponent","externalResourcesRequired","fill","fillOpacity","fillRule","filter","filterRes","filterUnits","floodColor","floodOpacity","focusable","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontStyle","fontVariant","fontWeight","format","from","fx","fy","g1","g2","glyphName","glyphOrientationHorizontal","glyphOrientationVertical","glyphRef","gradientTransform","gradientUnits","hanging","horizAdvX","horizOriginX","href","ideographic","imageRendering","in2","in","intercept","k1","k2","k3","k4","k","kernelMatrix","kernelUnitLength","kerning","keyPoints","keySplines","keyTimes","lengthAdjust","letterSpacing","lightingColor","limitingConeAngle","local","markerEnd","markerHeight","markerMid","markerStart","markerUnits","markerWidth","mask","maskContentUnits","maskUnits","mathematical","mode","numOctaves","offset","opacity","operator","order","orient","orientation","origin","overflow","overlinePosition","overlineThickness","paintOrder","panose1","pathLength","patternContentUnits","patternTransform","patternUnits","pointerEvents","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","r","radius","refX","refY","renderingIntent","repeatCount","repeatDur","requiredExtensions","requiredFeatures","restart","result","rotate","rx","ry","seed","shapeRendering","slope","spacing","specularConstant","specularExponent","speed","spreadMethod","startOffset","stdDeviation","stemh","stemv","stitchTiles","stopColor","stopOpacity","strikethroughPosition","strikethroughThickness","string","stroke","strokeDasharray","strokeDashoffset","strokeLinecap","strokeLinejoin","strokeMiterlimit","strokeOpacity","strokeWidth","surfaceScale","systemLanguage","tableValues","targetX","targetY","textAnchor","textDecoration","textLength","textRendering","to","transform","u1","u2","underlinePosition","underlineThickness","unicode","unicodeBidi","unicodeRange","unitsPerEm","vAlphabetic","values","vectorEffect","version","vertAdvY","vertOriginX","vertOriginY","vHanging","vIdeographic","viewTarget","visibility","vMathematical","widths","wordSpacing","writingMode","x1","x2","x","xChannelSelector","xHeight","xlinkActuate","xlinkArcrole","xlinkHref","xlinkRole","xlinkShow","xlinkTitle","xlinkType","xmlBase","xmlLang","xmlns","xmlnsXlink","xmlSpace","y1","y2","y","yChannelSelector","z","zoomAndPan","ref","key","angle"],Yd=["points","pathLength"],nl={svg:fj,polygon:Yd,polyline:Yd},hd=["dangerouslySetInnerHTML","onCopy","onCopyCapture","onCut","onCutCapture","onPaste","onPasteCapture","onCompositionEnd","onCompositionEndCapture","onCompositionStart","onCompositionStartCapture","onCompositionUpdate","onCompositionUpdateCapture","onFocus","onFocusCapture","onBlur","onBlurCapture","onChange","onChangeCapture","onBeforeInput","onBeforeInputCapture","onInput","onInputCapture","onReset","onResetCapture","onSubmit","onSubmitCapture","onInvalid","onInvalidCapture","onLoad","onLoadCapture","onError","onErrorCapture","onKeyDown","onKeyDownCapture","onKeyPress","onKeyPressCapture","onKeyUp","onKeyUpCapture","onAbort","onAbortCapture","onCanPlay","onCanPlayCapture","onCanPlayThrough","onCanPlayThroughCapture","onDurationChange","onDurationChangeCapture","onEmptied","onEmptiedCapture","onEncrypted","onEncryptedCapture","onEnded","onEndedCapture","onLoadedData","onLoadedDataCapture","onLoadedMetadata","onLoadedMetadataCapture","onLoadStart","onLoadStartCapture","onPause","onPauseCapture","onPlay","onPlayCapture","onPlaying","onPlayingCapture","onProgress","onProgressCapture","onRateChange","onRateChangeCapture","onSeeked","onSeekedCapture","onSeeking","onSeekingCapture","onStalled","onStalledCapture","onSuspend","onSuspendCapture","onTimeUpdate","onTimeUpdateCapture","onVolumeChange","onVolumeChangeCapture","onWaiting","onWaitingCapture","onAuxClick","onAuxClickCapture","onClick","onClickCapture","onContextMenu","onContextMenuCapture","onDoubleClick","onDoubleClickCapture","onDrag","onDragCapture","onDragEnd","onDragEndCapture","onDragEnter","onDragEnterCapture","onDragExit","onDragExitCapture","onDragLeave","onDragLeaveCapture","onDragOver","onDragOverCapture","onDragStart","onDragStartCapture","onDrop","onDropCapture","onMouseDown","onMouseDownCapture","onMouseEnter","onMouseLeave","onMouseMove","onMouseMoveCapture","onMouseOut","onMouseOutCapture","onMouseOver","onMouseOverCapture","onMouseUp","onMouseUpCapture","onSelect","onSelectCapture","onTouchCancel","onTouchCancelCapture","onTouchEnd","onTouchEndCapture","onTouchMove","onTouchMoveCapture","onTouchStart","onTouchStartCapture","onPointerDown","onPointerDownCapture","onPointerMove","onPointerMoveCapture","onPointerUp","onPointerUpCapture","onPointerCancel","onPointerCancelCapture","onPointerEnter","onPointerEnterCapture","onPointerLeave","onPointerLeaveCapture","onPointerOver","onPointerOverCapture","onPointerOut","onPointerOutCapture","onGotPointerCapture","onGotPointerCaptureCapture","onLostPointerCapture","onLostPointerCaptureCapture","onScroll","onScrollCapture","onWheel","onWheelCapture","onAnimationStart","onAnimationStartCapture","onAnimationEnd","onAnimationEndCapture","onAnimationIteration","onAnimationIterationCapture","onTransitionEnd","onTransitionEndCapture"],yi=function(r,n){if(!r||typeof r=="function"||typeof r=="boolean")return null;var a=r;if(_.isValidElement(r)&&(a=r.props),!ba(a))return null;var s={};return Object.keys(a).forEach(function(i){hd.includes(i)&&(s[i]=n||function(o){return a[i](a,o)})}),s},xj=function(r,n,a){return function(s){return r(n,a,s),null}},$n=function(r,n,a){if(!ba(r)||Dl(r)!=="object")return null;var s=null;return Object.keys(r).forEach(function(i){var o=r[i];hd.includes(i)&&typeof o=="function"&&(s||(s={}),s[i]=xj(o,n,a))}),s},vj=["children"],gj=["children"];function Qd(t,r){if(t==null)return{};var n=yj(t,r),a,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)a=i[s],!(r.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(t,a)&&(n[a]=t[a])}return n}function yj(t,r){if(t==null)return{};var n={};for(var a in t)if(Object.prototype.hasOwnProperty.call(t,a)){if(r.indexOf(a)>=0)continue;n[a]=t[a]}return n}function Ml(t){"@babel/helpers - typeof";return Ml=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Ml(t)}var Zd={click:"onClick",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseover:"onMouseOver",mousemove:"onMouseMove",mouseout:"onMouseOut",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",touchcancel:"onTouchCancel",touchend:"onTouchEnd",touchmove:"onTouchMove",touchstart:"onTouchStart"},Hr=function(r){return typeof r=="string"?r:r?r.displayName||r.name||"Component":""},Jd=null,al=null,md=function t(r){if(r===Jd&&Array.isArray(al))return al;var n=[];
59return _.Children.forEach(r,function(a){Ie(a)||(Cf.isFragment(a)?n=n.concat(t(a.props.children)):n.push(a))}),al=n,Jd=r,n};function er(t,r){var n=[],a=[];return Array.isArray(r)?a=r.map(function(s){return Hr(s)}):a=[Hr(r)],md(t).forEach(function(s){var i=Jt(s,"type.displayName")||Jt(s,"type.name");a.indexOf(i)!==-1&&n.push(s)}),n}function Gt(t,r){var n=er(t,r);return n&&n[0]}var eu=function(r){if(!r||!r.props)return!1;var n=r.props,a=n.width,s=n.height;return!(!me(a)||a<=0||!me(s)||s<=0)},jj=["a","altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColormatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-url","foreignObject","g","glyph","glyphRef","hkern","image","line","lineGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","stop","style","svg","switch","symbol","text","textPath","title","tref","tspan","use","view","vkern"],bj=function(r){return r&&r.type&&Us(r.type)&&jj.indexOf(r.type)>=0},wj=function(r){return r&&Ml(r)==="object"&&"clipDot"in r},Nj=function(r,n,a,s){var i,o=(i=nl==null?void 0:nl[s])!==null&&i!==void 0?i:[];return!$e(r)&&(s&&o.includes(n)||pj.includes(n))||a&&hd.includes(n)},Oe=function(r,n,a){if(!r||typeof r=="function"||typeof r=="boolean")return null;var s=r;if(_.isValidElement(r)&&(s=r.props),!ba(s))return null;var i={};return Object.keys(s).forEach(function(o){var l;Nj((l=s)===null||l===void 0?void 0:l[o],o,n,a)&&(i[o]=s[o])}),i},Il=function t(r,n){if(r===n)return!0;var a=_.Children.count(r);if(a!==_.Children.count(n))return!1;if(a===0)return!0;if(a===1)return tu(Array.isArray(r)?r[0]:r,Array.isArray(n)?n[0]:n);for(var s=0;s<a;s++){var i=r[s],o=n[s];if(Array.isArray(i)||Array.isArray(o)){if(!t(i,o))return!1}else if(!tu(i,o))return!1}return!0},tu=function(r,n){if(Ie(r)&&Ie(n))return!0;if(!Ie(r)&&!Ie(n)){var a=r.props||{},s=a.children,i=Qd(a,vj),o=n.props||{},l=o.children,c=Qd(o,gj);return s&&l?Kn(i,c)&&Il(s,l):!s&&!l?Kn(i,c):!1}return!1},ru=function(r,n){var a=[],s={};return md(r).forEach(function(i,o){if(bj(i))a.push(i);else if(i){var l=Hr(i.type),c=n[l]||{},u=c.handler,d=c.once;if(u&&(!d||!s[l])){var h=u(i,l,o);a.push(h),s[l]=!0}}}),a},_j=function(r){var n=r&&r.type;return n&&Zd[n]?Zd[n]:null},Sj=function(r,n){return md(n).indexOf(r)},Oj=["children","width","height","viewBox","className","style","title","desc"];function Ll(){return Ll=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},Ll.apply(this,arguments)}function Cj(t,r){if(t==null)return{};var n=Aj(t,r),a,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)a=i[s],!(r.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(t,a)&&(n[a]=t[a])}return n}function Aj(t,r){if(t==null)return{};var n={};for(var a in t)if(Object.prototype.hasOwnProperty.call(t,a)){if(r.indexOf(a)>=0)continue;n[a]=t[a]}return n}function Rl(t){var r=t.children,n=t.width,a=t.height,s=t.viewBox,i=t.className,o=t.style,l=t.title,c=t.desc,u=Cj(t,Oj),d=s||{width:n,height:a,x:0,y:0},h=Le("recharts-surface",i);return L.createElement("svg",Ll({},Oe(u,!0,"svg"),{className:h,width:n,height:a,style:o,viewBox:"".concat(d.x," ").concat(d.y," ").concat(d.width," ").concat(d.height)}),L.createElement("title",null,l),L.createElement("desc",null,c),r)}var Pj=["children","className"];function Fl(){return Fl=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},Fl.apply(this,arguments)}function kj(t,r){if(t==null)return{};var n=Ej(t,r),a,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)a=i[s],!(r.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(t,a)&&(n[a]=t[a])}return n}function Ej(t,r){if(t==null)return{};var n={};for(var a in t)if(Object.prototype.hasOwnProperty.call(t,a)){if(r.indexOf(a)>=0)continue;n[a]=t[a]}return n}var Ke=L.forwardRef(function(t,r){var n=t.children,a=t.className,s=kj(t,Pj),i=Le("recharts-layer",a);return L.createElement("g",Fl({className:i},Oe(s,!0),{ref:r}),n)}),Sr=function(r,n){for(var a=arguments.length,s=new Array(a>2?a-2:0),i=2;i<a;i++)s[i-2]=arguments[i]};function Tj(t,r,n){var a=-1,s=t.length;r<0&&(r=-r>s?0:s+r),n=n>s?s:n,n<0&&(n+=s),s=r>n?0:n-r>>>0,r>>>=0;for(var i=Array(s);++a<s;)i[a]=t[a+r];return i}var $j=Tj,Dj=$j;function Mj(t,r,n){var a=t.length;return n=n===void 0?a:n,!r&&n>=a?t:Dj(t,r,n)}var Ij=Mj,Lj="\\ud800-\\udfff",Rj="\\u0300-\\u036f",Fj="\\ufe20-\\ufe2f",Bj="\\u20d0-\\u20ff",zj=Rj+Fj+Bj,Uj="\\ufe0e\\ufe0f",qj="\\u200d",Vj=RegExp("["+qj+Lj+zj+Uj+"]");function Wj(t){return Vj.test(t)}var Pf=Wj;function Kj(t){return t.split("")}var Gj=Kj,kf="\\ud800-\\udfff",Hj="\\u0300-\\u036f",Xj="\\ufe20-\\ufe2f",Yj="\\u20d0-\\u20ff",Qj=Hj+Xj+Yj,Zj="\\ufe0e\\ufe0f",Jj="["+kf+"]",Bl="["+Qj+"]",zl="\\ud83c[\\udffb-\\udfff]",eb="(?:"+Bl+"|"+zl+")",Ef="[^"+kf+"]",Tf="(?:\\ud83c[\\udde6-\\uddff]){2}",$f="[\\ud800-\\udbff][\\udc00-\\udfff]",tb="\\u200d",Df=eb+"?",Mf="["+Zj+"]?",rb="(?:"+tb+"(?:"+[Ef,Tf,$f].join("|")+")"+Mf+Df+")*",nb=Mf+Df+rb,ab="(?:"+[Ef+Bl+"?",Bl,Tf,$f,Jj].join("|")+")",sb=RegExp(zl+"(?="+zl+")|"+ab+nb,"g");function ib(t){return t.match(sb)||[]}var ob=ib,lb=Gj,cb=Pf,db=ob;function ub(t){return cb(t)?db(t):lb(t)}var hb=ub,mb=Ij,fb=Pf,pb=hb,xb=wf;function vb(t){return function(r){r=xb(r);var n=fb(r)?pb(r):void 0,a=n?n[0]:r.charAt(0),s=n?mb(n,1).join(""):r.slice(1);return a[t]()+s}}var gb=vb,yb=gb,jb=yb("toUpperCase"),bb=jb;const Co=pt(bb);function tt(t){return function(){return t}}const If=Math.cos,ji=Math.sin,Cr=Math.sqrt,bi=Math.PI,Ao=2*bi,Ul=Math.PI,ql=2*Ul,vn=1e-6,wb=ql-vn;function Lf(t){this._+=t[0];for(let r=1,n=t.length;r<n;++r)this._+=arguments[r]+t[r]}function Nb(t){let r=Math.floor(t);if(!(r>=0))throw new Error(`invalid digits: ${t}`);if(r>15)return Lf;const n=10**r;return function(a){this._+=a[0];for(let s=1,i=a.length;s<i;++s)this._+=Math.round(arguments[s]*n)/n+a[s]}}class _b{constructor(r){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=r==null?Lf:Nb(r)}moveTo(r,n){this._append`M${this._x0=this._x1=+r},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(r,n){this._append`L${this._x1=+r},${this._y1=+n}`}quadraticCurveTo(r,n,a,s){this._append`Q${+r},${+n}
59,${this._x1=+a},${this._y1=+s}`}bezierCurveTo(r,n,a,s,i,o){this._append`C${+r},${+n},${+a},${+s},${this._x1=+i},${this._y1=+o}`}arcTo(r,n,a,s,i){if(r=+r,n=+n,a=+a,s=+s,i=+i,i<0)throw new Error(`negative radius: ${i}`);let o=this._x1,l=this._y1,c=a-r,u=s-n,d=o-r,h=l-n,m=d*d+h*h;if(this._x1===null)this._append`M${this._x1=r},${this._y1=n}`;else if(m>vn)if(!(Math.abs(h*c-u*d)>vn)||!i)this._append`L${this._x1=r},${this._y1=n}`;else{let j=a-o,w=s-l,x=c*c+u*u,v=j*j+w*w,y=Math.sqrt(x),f=Math.sqrt(m),b=i*Math.tan((Ul-Math.acos((x+m-v)/(2*y*f)))/2),p=b/f,g=b/y;Math.abs(p-1)>vn&&this._append`L${r+p*d},${n+p*h}`,this._append`A${i},${i},0,0,${+(h*j>d*w)},${this._x1=r+g*c},${this._y1=n+g*u}`}}arc(r,n,a,s,i,o){if(r=+r,n=+n,a=+a,o=!!o,a<0)throw new Error(`negative radius: ${a}`);let l=a*Math.cos(s),c=a*Math.sin(s),u=r+l,d=n+c,h=1^o,m=o?s-i:i-s;this._x1===null?this._append`M${u},${d}`:(Math.abs(this._x1-u)>vn||Math.abs(this._y1-d)>vn)&&this._append`L${u},${d}`,a&&(m<0&&(m=m%ql+ql),m>wb?this._append`A${a},${a},0,1,${h},${r-l},${n-c}A${a},${a},0,1,${h},${this._x1=u},${this._y1=d}`:m>vn&&this._append`A${a},${a},0,${+(m>=Ul)},${h},${this._x1=r+a*Math.cos(i)},${this._y1=n+a*Math.sin(i)}`)}rect(r,n,a,s){this._append`M${this._x0=this._x1=+r},${this._y0=this._y1=+n}h${a=+a}v${+s}h${-a}Z`}toString(){return this._}}function fd(t){let r=3;return t.digits=function(n){if(!arguments.length)return r;if(n==null)r=null;else{const a=Math.floor(n);if(!(a>=0))throw new RangeError(`invalid digits: ${n}`);r=a}return t},()=>new _b(r)}function pd(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function Rf(t){this._context=t}Rf.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,r){switch(t=+t,r=+r,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,r):this._context.moveTo(t,r);break;case 1:this._point=2;default:this._context.lineTo(t,r);break}}};function Po(t){return new Rf(t)}function Ff(t){return t[0]}function Bf(t){return t[1]}function zf(t,r){var n=tt(!0),a=null,s=Po,i=null,o=fd(l);t=typeof t=="function"?t:t===void 0?Ff:tt(t),r=typeof r=="function"?r:r===void 0?Bf:tt(r);function l(c){var u,d=(c=pd(c)).length,h,m=!1,j;for(a==null&&(i=s(j=o())),u=0;u<=d;++u)!(u<d&&n(h=c[u],u,c))===m&&((m=!m)?i.lineStart():i.lineEnd()),m&&i.point(+t(h,u,c),+r(h,u,c));if(j)return i=null,j+""||null}return l.x=function(c){return arguments.length?(t=typeof c=="function"?c:tt(+c),l):t},l.y=function(c){return arguments.length?(r=typeof c=="function"?c:tt(+c),l):r},l.defined=function(c){return arguments.length?(n=typeof c=="function"?c:tt(!!c),l):n},l.curve=function(c){return arguments.length?(s=c,a!=null&&(i=s(a)),l):s},l.context=function(c){return arguments.length?(c==null?a=i=null:i=s(a=c),l):a},l}function Qs(t,r,n){var a=null,s=tt(!0),i=null,o=Po,l=null,c=fd(u);t=typeof t=="function"?t:t===void 0?Ff:tt(+t),r=typeof r=="function"?r:tt(r===void 0?0:+r),n=typeof n=="function"?n:n===void 0?Bf:tt(+n);function u(h){var m,j,w,x=(h=pd(h)).length,v,y=!1,f,b=new Array(x),p=new Array(x);for(i==null&&(l=o(f=c())),m=0;m<=x;++m){if(!(m<x&&s(v=h[m],m,h))===y)if(y=!y)j=m,l.areaStart(),l.lineStart();else{for(l.lineEnd(),l.lineStart(),w=m-1;w>=j;--w)l.point(b[w],p[w]);l.lineEnd(),l.areaEnd()}y&&(b[m]=+t(v,m,h),p[m]=+r(v,m,h),l.point(a?+a(v,m,h):b[m],n?+n(v,m,h):p[m]))}if(f)return l=null,f+""||null}function d(){return zf().defined(s).curve(o).context(i)}return u.x=function(h){return arguments.length?(t=typeof h=="function"?h:tt(+h),a=null,u):t},u.x0=function(h){return arguments.length?(t=typeof h=="function"?h:tt(+h),u):t},u.x1=function(h){return arguments.length?(a=h==null?null:typeof h=="function"?h:tt(+h),u):a},u.y=function(h){return arguments.length?(r=typeof h=="function"?h:tt(+h),n=null,u):r},u.y0=function(h){return arguments.length?(r=typeof h=="function"?h:tt(+h),u):r},u.y1=function(h){return arguments.length?(n=h==null?null:typeof h=="function"?h:tt(+h),u):n},u.lineX0=u.lineY0=function(){return d().x(t).y(r)},u.lineY1=function(){return d().x(t).y(n)},u.lineX1=function(){return d().x(a).y(r)},u.defined=function(h){return arguments.length?(s=typeof h=="function"?h:tt(!!h),u):s},u.curve=function(h){return arguments.length?(o=h,i!=null&&(l=o(i)),u):o},u.context=function(h){return arguments.length?(h==null?i=l=null:l=o(i=h),u):i},u}class Uf{constructor(r,n){this._context=r,this._x=n}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(r,n){switch(r=+r,n=+n,this._point){case 0:{this._point=1,this._line?this._context.lineTo(r,n):this._context.moveTo(r,n);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+r)/2,this._y0,this._x0,n,r,n):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+n)/2,r,this._y0,r,n);break}}this._x0=r,this._y0=n}}function Sb(t){return new Uf(t,!0)}function Ob(t){return new Uf(t,!1)}const xd={draw(t,r){const n=Cr(r/bi);t.moveTo(n,0),t.arc(0,0,n,0,Ao)}},Cb={draw(t,r){const n=Cr(r/5)/2;t.moveTo(-3*n,-n),t.lineTo(-n,-n),t.lineTo(-n,-3*n),t.lineTo(n,-3*n),t.lineTo(n,-n),t.lineTo(3*n,-n),t.lineTo(3*n,n),t.lineTo(n,n),t.lineTo(n,3*n),t.lineTo(-n,3*n),t.lineTo(-n,n),t.lineTo(-3*n,n),t.closePath()}},qf=Cr(1/3),Ab=qf*2,Pb={draw(t,r){const n=Cr(r/Ab),a=n*qf;t.moveTo(0,-n),t.lineTo(a,0),t.lineTo(0,n),t.lineTo(-a,0),t.closePath()}},kb={draw(t,r){const n=Cr(r),a=-n/2;t.rect(a,a,n,n)}},Eb=.8908130915292852,Vf=ji(bi/10)/ji(7*bi/10),Tb=ji(Ao/10)*Vf,$b=-If(Ao/10)*Vf,Db={draw(t,r){const n=Cr(r*Eb),a=Tb*n,s=$b*n;t.moveTo(0,-n),t.lineTo(a,s);for(let i=1;i<5;++i){const o=Ao*i/5,l=If(o),c=ji(o);t.lineTo(c*n,-l*n),t.lineTo(l*a-c*s,c*a+l*s)}t.closePath()}}
59,sl=Cr(3),Mb={draw(t,r){const n=-Cr(r/(sl*3));t.moveTo(0,n*2),t.lineTo(-sl*n,-n),t.lineTo(sl*n,-n),t.closePath()}},hr=-.5,mr=Cr(3)/2,Vl=1/Cr(12),Ib=(Vl/2+1)*3,Lb={draw(t,r){const n=Cr(r/Ib),a=n/2,s=n*Vl,i=a,o=n*Vl+n,l=-i,c=o;t.moveTo(a,s),t.lineTo(i,o),t.lineTo(l,c),t.lineTo(hr*a-mr*s,mr*a+hr*s),t.lineTo(hr*i-mr*o,mr*i+hr*o),t.lineTo(hr*l-mr*c,mr*l+hr*c),t.lineTo(hr*a+mr*s,hr*s-mr*a),t.lineTo(hr*i+mr*o,hr*o-mr*i),t.lineTo(hr*l+mr*c,hr*c-mr*l),t.closePath()}};function Rb(t,r){let n=null,a=fd(s);t=typeof t=="function"?t:tt(t||xd),r=typeof r=="function"?r:tt(r===void 0?64:+r);function s(){let i;if(n||(n=i=a()),t.apply(this,arguments).draw(n,+r.apply(this,arguments)),i)return n=null,i+""||null}return s.type=function(i){return arguments.length?(t=typeof i=="function"?i:tt(i),s):t},s.size=function(i){return arguments.length?(r=typeof i=="function"?i:tt(+i),s):r},s.context=function(i){return arguments.length?(n=i??null,s):n},s}function wi(){}function Ni(t,r,n){t._context.bezierCurveTo((2*t._x0+t._x1)/3,(2*t._y0+t._y1)/3,(t._x0+2*t._x1)/3,(t._y0+2*t._y1)/3,(t._x0+4*t._x1+r)/6,(t._y0+4*t._y1+n)/6)}function Wf(t){this._context=t}Wf.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:Ni(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,r){switch(t=+t,r=+r,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,r):this._context.moveTo(t,r);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:Ni(this,t,r);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=r}};function Fb(t){return new Wf(t)}function Kf(t){this._context=t}Kf.prototype={areaStart:wi,areaEnd:wi,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(t,r){switch(t=+t,r=+r,this._point){case 0:this._point=1,this._x2=t,this._y2=r;break;case 1:this._point=2,this._x3=t,this._y3=r;break;case 2:this._point=3,this._x4=t,this._y4=r,this._context.moveTo((this._x0+4*this._x1+t)/6,(this._y0+4*this._y1+r)/6);break;default:Ni(this,t,r);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=r}};function Bb(t){return new Kf(t)}function Gf(t){this._context=t}Gf.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(t,r){switch(t=+t,r=+r,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+t)/6,a=(this._y0+4*this._y1+r)/6;this._line?this._context.lineTo(n,a):this._context.moveTo(n,a);break;case 3:this._point=4;default:Ni(this,t,r);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=r}};function zb(t){return new Gf(t)}function Hf(t){this._context=t}Hf.prototype={areaStart:wi,areaEnd:wi,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(t,r){t=+t,r=+r,this._point?this._context.lineTo(t,r):(this._point=1,this._context.moveTo(t,r))}};function Ub(t){return new Hf(t)}function nu(t){return t<0?-1:1}function au(t,r,n){var a=t._x1-t._x0,s=r-t._x1,i=(t._y1-t._y0)/(a||s<0&&-0),o=(n-t._y1)/(s||a<0&&-0),l=(i*s+o*a)/(a+s);return(nu(i)+nu(o))*Math.min(Math.abs(i),Math.abs(o),.5*Math.abs(l))||0}function su(t,r){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-r)/2:r}function il(t,r,n){var a=t._x0,s=t._y0,i=t._x1,o=t._y1,l=(i-a)/3;
59t._context.bezierCurveTo(a+l,s+l*r,i-l,o-l*n,i,o)}function _i(t){this._context=t}_i.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:il(this,this._t0,su(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,r){var n=NaN;if(t=+t,r=+r,!(t===this._x1&&r===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(t,r):this._context.moveTo(t,r);break;case 1:this._point=2;break;case 2:this._point=3,il(this,su(this,n=au(this,t,r)),n);break;default:il(this,this._t0,n=au(this,t,r));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=r,this._t0=n}}};function Xf(t){this._context=new Yf(t)}(Xf.prototype=Object.create(_i.prototype)).point=function(t,r){_i.prototype.point.call(this,r,t)};function Yf(t){this._context=t}Yf.prototype={moveTo:function(t,r){this._context.moveTo(r,t)},closePath:function(){this._context.closePath()},lineTo:function(t,r){this._context.lineTo(r,t)},bezierCurveTo:function(t,r,n,a,s,i){this._context.bezierCurveTo(r,t,a,n,i,s)}};function qb(t){return new _i(t)}function Vb(t){return new Xf(t)}function Qf(t){this._context=t}Qf.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var t=this._x,r=this._y,n=t.length;if(n)if(this._line?this._context.lineTo(t[0],r[0]):this._context.moveTo(t[0],r[0]),n===2)this._context.lineTo(t[1],r[1]);else for(var a=iu(t),s=iu(r),i=0,o=1;o<n;++i,++o)this._context.bezierCurveTo(a[0][i],s[0][i],a[1][i],s[1][i],t[o],r[o]);(this._line||this._line!==0&&n===1)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null},point:function(t,r){this._x.push(+t),this._y.push(+r)}};function iu(t){var r,n=t.length-1,a,s=new Array(n),i=new Array(n),o=new Array(n);for(s[0]=0,i[0]=2,o[0]=t[0]+2*t[1],r=1;r<n-1;++r)s[r]=1,i[r]=4,o[r]=4*t[r]+2*t[r+1];for(s[n-1]=2,i[n-1]=7,o[n-1]=8*t[n-1]+t[n],r=1;r<n;++r)a=s[r]/i[r-1],i[r]-=a,o[r]-=a*o[r-1];for(s[n-1]=o[n-1]/i[n-1],r=n-2;r>=0;--r)s[r]=(o[r]-s[r+1])/i[r];for(i[n-1]=(t[n]+s[n-1])/2,r=0;r<n-1;++r)i[r]=2*t[r+1]-s[r+1];return[s,i]}function Wb(t){return new Qf(t)}function ko(t,r){this._context=t,this._t=r}ko.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=this._y=NaN,this._point=0},lineEnd:function(){0<this._t&&this._t<1&&this._point===2&&this._context.lineTo(this._x,this._y),(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line>=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(t,r){switch(t=+t,r=+r,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,r):this._context.moveTo(t,r);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,r),this._context.lineTo(t,r);else{var n=this._x*(1-this._t)+t*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,r)}break}}this._x=t,this._y=r}};function Kb(t){return new ko(t,.5)}function Gb(t){return new ko(t,0)}function Hb(t){return new ko(t,1)}function Qn(t,r){if((o=t.length)>1)for(var n=1,a,s,i=t[r[0]],o,l=i.length;n<o;++n)for(s=i,i=t[r[n]],a=0;a<l;++a)i[a][1]+=i[a][0]=isNaN(s[a][1])?s[a][0]:s[a][1]}function Wl(t){for(var r=t.length,n=new Array(r);--r>=0;)n[r]=r;return n}function Xb(t,r){return t[r]}function Yb(t){const r=[];return r.key=t,r}function Qb(){var t=tt([]),r=Wl,n=Qn,a=Xb;function s(i){var o=Array.from(t.apply(this,arguments),Yb),l,c=o.length,u=-1,d;for(const h of i)for(l=0,++u;l<c;++l)(o[l][u]=[0,+a(h,o[l].key,u,i)]).data=h;for(l=0,d=pd(r(o));l<c;++l)o[d[l]].index=l;return n(o,d),o}return s.keys=function(i){return arguments.length?(t=typeof i=="function"?i:tt(Array.from(i)),s):t},s.value=function(i){return arguments.length?(a=typeof i=="function"?i:tt(+i),s):a},s.order=function(i){return arguments.length?(r=i==null?Wl:typeof i=="function"?i:tt(Array.from(i)),s):r},s.offset=function(i){return arguments.length?(n=i??Qn,s):n},s}function Zb(t,r){if((a=t.length)>0){for(var n,a,s=0,i=t[0].length,o;s<i;++s){for(o=n=0;n<a;++n)o+=t[n][s][1]||0;if(o)for(n=0;n<a;++n)t[n][s][1]/=o}Qn(t,r)}}function Jb(t,r){if((s=t.length)>0){for(var n=0,a=t[r[0]],s,i=a.length;n<i;++n){for(var o=0,l=0;o<s;++o)l+=t[o][n][1]||0;a[n][1]+=a[n][0]=-l/2}Qn(t,r)}}function e0(t,r){if(!(!((o=t.length)>0)||!((i=(s=t[r[0]]).length)>0))){for(var n=0,a=1,s,i,o;a<i;++a){for(var l=0,c=0,u=0;l<o;
vendor: 7,473 bytes, lines 59-62
59++l){for(var d=t[r[l]],h=d[a][1]||0,m=d[a-1][1]||0,j=(h-m)/2,w=0;w<l;++w){var x=t[r[w]],v=x[a][1]||0,y=x[a-1][1]||0;j+=v-y}c+=h,u+=j*h}s[a-1][1]+=s[a-1][0]=n,c&&(n-=u/c)}s[a-1][1]+=s[a-1][0]=n,Qn(t,r)}}function is(t){"@babel/helpers - typeof";return is=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},is(t)}var t0=["type","size","sizeType"];function Kl(){return Kl=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},Kl.apply(this,arguments)}function ou(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function lu(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?ou(Object(n),!0).forEach(function(a){r0(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ou(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function r0(t,r,n){return r=n0(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function n0(t){var r=a0(t,"string");return is(r)=="symbol"?r:r+""}function a0(t,r){if(is(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(is(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function s0(t,r){if(t==null)return{};var n=i0(t,r),a,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)a=i[s],!(r.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(t,a)&&(n[a]=t[a])}return n}function i0(t,r){if(t==null)return{};var n={};for(var a in t)if(Object.prototype.hasOwnProperty.call(t,a)){if(r.indexOf(a)>=0)continue;n[a]=t[a]}return n}var Zf={symbolCircle:xd,symbolCross:Cb,symbolDiamond:Pb,symbolSquare:kb,symbolStar:Db,symbolTriangle:Mb,symbolWye:Lb},o0=Math.PI/180,l0=function(r){var n="symbol".concat(Co(r));return Zf[n]||xd},c0=function(r,n,a){if(n==="area")return r;switch(a){case"cross":return 5*r*r/9;case"diamond":return .5*r*r/Math.sqrt(3);case"square":return r*r;case"star":{var s=18*o0;return 1.25*r*r*(Math.tan(s)-Math.tan(s*2)*Math.pow(Math.tan(s),2))}case"triangle":return Math.sqrt(3)*r*r/4;case"wye":return(21-10*Math.sqrt(3))*r*r/8;default:return Math.PI*r*r/4}},d0=function(r,n){Zf["symbol".concat(Co(r))]=n},vd=function(r){var n=r.type,a=n===void 0?"circle":n,s=r.size,i=s===void 0?64:s,o=r.sizeType,l=o===void 0?"area":o,c=s0(r,t0),u=lu(lu({},c),{},{type:a,size:i,sizeType:l}),d=function(){var v=l0(a),y=Rb().type(v).size(c0(i,l,a));return y()},h=u.className,m=u.cx,j=u.cy,w=Oe(u,!0);return m===+m&&j===+j&&i===+i?L.createElement("path",Kl({},w,{className:Le("recharts-symbols",h),transform:"translate(".concat(m,", ").concat(j,")"),d:d()})):null};vd.registerSymbol=d0;function Zn(t){"@babel/helpers - typeof";return Zn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Zn(t)}function Gl(){return Gl=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},Gl.apply(this,arguments)}function cu(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function u0(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?cu(Object(n),!0).forEach(function(a){os(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):cu(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function h0(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function m0(t,r){for(var n=0;n<r.length;n++){var a=r[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,ep(a.key),a)}}function f0(t,r,n){return r&&m0(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function p0(t,r,n){return r=Si(r),x0(t,Jf()?Reflect.construct(r,n||[],Si(t).constructor):r.apply(t,n))}function x0(t,r){if(r&&(Zn(r)==="object"||typeof r=="function"))return r;if(r!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return v0(t)}function v0(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Jf(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Jf=function(){return!!t})()}function Si(t){return Si=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Si(t)}function g0(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&Hl(t,r)}function Hl(t,r){return Hl=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,s){return a.__proto__=s,a},Hl(t,r)}function os(t,r,n){return r=ep(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function ep(t){var r=y0(t,"string");return Zn(r)=="symbol"?r:r+""}function y0(t,r){if(Zn(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(Zn(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}var fr=32,gd=function(t){function r(){return h0(this,r),p0(this,r,arguments)}return g0(r,t),f0(r,[{key:"renderIcon",value:function(a){var s=this.props.inactiveColor,i=fr/2,o=fr/6,l=fr/3,c=a.inactive?s:a.color;if(a.type==="plainline")return L.createElement("line",{strokeWidth:4,fill:"none",stroke:c,strokeDasharray:a.payload.strokeDasharray,x1:0,y1:i,x2:fr,y2:i,className:"recharts-legend-icon"});if(a.type==="line")return L.createElement("path",{strokeWidth:4,fill:"none",stroke:c,d:"M0,".concat(i,"h").concat(l,`
60            A`).concat(o,",").concat(o,",0,1,1,").concat(2*l,",").concat(i,`
61            H`).concat(fr,"M").concat(2*l,",").concat(i,`
62            A`).concat(o,",").concat(o,",0,1,1,").concat(l,",").concat(i),className:"recharts-legend-icon"});if(a.type==="rect")return L.createElement("path",{stroke:"none",fill:c,d:"M0,".concat(fr/8,"h").concat(fr,"v").concat(fr*3/4,"h").concat(-fr,"z"),className:"recharts-legend-icon"});if(L.isValidElement(a.legendIcon)){var u=u0({},a);return delete u.legendIcon,L.cloneElement(a.legendIcon,u)}return L.createElement(vd,{fill:c,cx:i,cy:i,size:fr,sizeType:"diameter",type:a.type})}},{key:"renderItems",value:function(){var a=this,s=this.props,i=s.payload,o=s.iconSize,l=s.layout,c=s.formatter,u=s.inactiveColor,d={x:0,y:0,width:fr,height:fr}
62,h={display:l==="horizontal"?"inline-block":"block",marginRight:10},m={display:"inline-block",verticalAlign:"middle",marginRight:4};return i.map(function(j,w){var x=j.formatter||c,v=Le(os(os({"recharts-legend-item":!0},"legend-item-".concat(w),!0),"inactive",j.inactive));if(j.type==="none")return null;var y=$e(j.value)?null:j.value;Sr(!$e(j.value),`The name property is also required when using a function for the dataKey of a chart's cartesian components. Ex: <Bar name="Name of my Data"/>`);var f=j.inactive?u:j.color;return L.createElement("li",Gl({className:v,style:h,key:"legend-item-".concat(w)},$n(a.props,j,w)),L.createElement(Rl,{width:o,height:o,viewBox:d,style:m},a.renderIcon(j)),L.createElement("span",{className:"recharts-legend-item-text",style:{color:f}},x?x(y,j,w):y))})}},{key:"render",value:function(){var a=this.props,s=a.payload,i=a.layout,o=a.align;if(!s||!s.length)return null;var l={padding:0,margin:0,textAlign:i==="horizontal"?o:"left"};return L.createElement("ul",{className:"recharts-default-legend",style:l},this.renderItems())}}])}(_.PureComponent);os(gd,"displayName","Legend");os(gd,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"middle",inactiveColor:"#ccc"});var j0=gg,b0=af,w0=1,N0=2;function _0(t,r,n,a){var s=n.length,i=s,o=!a;if(t==null)return!i;for(t=Object(t);s--;){var l=n[s];if(o&&l[2]?l[1]!==t[l[0]]:!(l[0]in t))return!1}for(;++s<i;){l=n[s];var c=l[0],u=t[c],d=l[1];if(o&&l[2]){if(u===void 0&&!(c in t))return!1}else{var h=new j0;if(a)var m=a(u,d,c,t,r,h);if(!(m===void 0?b0(d,u,w0|N0,a,h):m))return!1}}return!0}var S0=_0,O0=ad;function C0(t){return t===t&&!O0(t)}var tp=C0,A0=tp,P0=sd;function k0(t){for(var r=P0(t),n=r.length;n--;){var a=r[n],s=t[a];r[n]=[a,s,A0(s)]}return r}var E0=k0;function T0(t,r){return function(n){return n==null?!1:n[t]===r&&(r!==void 0||t in Object(n))}}var rp=T0,$0=S0,D0=E0,M0=rp;function I0(t){var r=D0(t);return r.length==1&&r[0][2]?M0(r[0][0],r[0][1]):function(n){return n===t||$0(n,t,r)}}var L0=I0;function R0(t,r){return t!=null&&r in Object(t)}var F0=R0,B0=Nf,z0=sf,U0=Or,q0=of,V0=yg,W0=xo;function K0(t,r,n){r=B0(r,t);for(var a=-1,s=r.length,i=!1;++a<s;){var o=W0(r[a]);if(!(i=t!=null&&n(t,o)))break;t=t[o]}return i||++a!=s?i:(s=t==null?0:t.length,!!s&&V0(s)&&q0(o,s)&&(U0(t)||z0(t)))}var G0=K0,H0=F0,X0=G0;function Y0(t,r){return t!=null&&X0(t,r,H0)}var Q0=Y0,Z0=af,J0=_f,ew=Q0,tw=od,rw=tp,nw=rp,aw=xo,sw=1,iw=2;function ow(t,r){return tw(t)&&rw(r)?nw(aw(t),r):function(n){var a=J0(n,t);return a===void 0&&a===r?ew(n,t):Z0(r,a,sw|iw)}}var lw=ow;function cw(t){return t}var _a=cw;function dw(t){return function(r){return r==null?void 0:r[t]}}var uw=dw,hw=cd;function mw(t){return function(r){return hw(r,t)}}var fw=mw,pw=uw,xw=fw,vw=od,gw=xo;function yw(t){return vw(t)?pw(gw(t)):xw(t)}var jw=yw,bw=L0,ww=lw,Nw=_a,_w=Or,Sw=jw;function Ow(t){return typeof t=="function"?t:t==null?Nw:typeof t=="object"?_w(t)?ww(t[0],t[1]):bw(t):Sw(t)}var qr=Ow;function Cw(t,r,n,a){for(var s=t.length,i=n+(a?1:-1);a?i--:++i<s;)if(r(t[i],i,t))return i;return-1}var np=Cw;function Aw(t){return t!==t}var Pw=Aw;function kw(t,r,n){for(var a=n-1,s=t.length;++a<s;)if(t[a]===r)return a;return-1}var Ew=kw,Tw=np,$w=Pw,Dw=Ew;function Mw(t,r,n){return r===r?Dw(t,r,n):Tw(t,$w,n)}var Iw=Mw,Lw=Iw;function Rw(t,r){var n=t==null?0:t.length;return!!n&&Lw(t,r,0)>-1}var Fw=Rw;function Bw(t,r,n){for(var a=-1,s=t==null?0:t.length;++a<s;)if(n(r,t[a]))return!0;return!1}var zw=Bw;function Uw(){}var qw=Uw,ol=jg,Vw=qw,Ww=lf,Kw=1/0,Gw=ol&&1/Ww(new ol([,-0]))[1]==Kw?function(t){return new ol(t)}:Vw,Hw=Gw,Xw=bg,Yw=Fw,Qw=zw,Zw=wg,Jw=Hw,eN=lf,tN=200;function rN(t,r,n){var a=-1,s=Yw,i=t.length,o=!0,l=[],c=l;if(n)o=!1,s=Qw;else if(i>=tN){var u=r?null:Jw(t);if(u)return eN(u);o=!1,s=Zw,c=new Xw}else c=r?[]:l;e:for(;++a<i;){var d=t[a],h=r?r(d):d;if(d=n||d!==0?d:0,o&&h===h){for(var m=c.length;m--;)if(c[m]===h)continue e;r&&c.push(h),l.push(d)}else s(c,h,n)||(c!==l&&c.push(h),l.push(d))}return l}var nN=rN,aN=qr,sN=nN;function iN(t,r){return t&&t.length?sN(t,aN(r)):[]}var oN=iN;const du=pt(oN);function ap(t,r,n){return r===!0?du(t,n):$e(r)?du(t,r):t}function Jn(t){"@babel/helpers - typeof";return Jn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Jn(t)}var lN=["ref"];function uu(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function Vr(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};
62r%2?uu(Object(n),!0).forEach(function(a){Eo(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):uu(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function cN(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function hu(t,r){for(var n=0;n<r.length;n++){var a=r[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,ip(a.key),a)}}function dN(t,r,n){return r&&hu(t.prototype,r),n&&hu(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function uN(t,r,n){return r=Oi(r),hN(t,sp()?Reflect.construct(r,n||[],Oi(t).constructor):r.apply(t,n))}function hN(t,r){if(r&&(Jn(r)==="object"||typeof r=="function"))return r;if(r!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return mN(t)}function mN(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function sp(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}
62return(sp=function(){return!!t})()}function Oi(t){return Oi=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Oi(t)}function fN(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&Xl(t,r)}function Xl(t,r){return Xl=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,s){return a.__proto__=s,a},Xl(t,r)}function Eo(t,r,n){return r=ip(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function ip(t){var r=pN(t,"string");return Jn(r)=="symbol"?r:r+""}function pN(t,r){if(Jn(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(Jn(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function xN(t,r){if(t==null)return{};var n=vN(t,r),a,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)a=i[s],!(r.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(t,a)&&(n[a]=t[a])}return n}function vN(t,r){if(t==null)return{};var n={};for(var a in t)if(Object.prototype.hasOwnProperty.call(t,a)){if(r.indexOf(a)>=0)continue;n[a]=t[a]}return n}function gN(t){return t.value}function yN(t,r){if(L.isValidElement(t))return L.cloneElement(t,r);if(typeof t=="function")return L.createElement(t,r);r.ref;var n=xN(r,lN);return L.createElement(gd,n)}var mu=1,an=function(t){function r(){var n;cN(this,r);for(var a=arguments.length,s=new Array(a),i=0;i<a;i++)s[i]=arguments[i];return n=uN(this,r,[].concat(s)),Eo(n,"lastBoundingBox",{width:-1,height:-1}),n}return fN(r,t),dN(r,[{key:"componentDidMount",value:function(){this.updateBBox()}},{key:"componentDidUpdate",value:function(){this.updateBBox()}},{key:"getBBox",value:function(){if(this.wrapperNode&&this.wrapperNode.getBoundingClientRect){var a=this.wrapperNode.getBoundingClientRect();return a.height=this.wrapperNode.offsetHeight,a.width=this.wrapperNode.offsetWidth,a}return null}},{key:"updateBBox",value:function(){var a=this.props.onBBoxUpdate,s=this.getBBox();s?(Math.abs(s.width-this.lastBoundingBox.width)>mu||Math.abs(s.height-this.lastBoundingBox.height)>mu)&&(this.lastBoundingBox.width=s.width,this.lastBoundingBox.height=s.height,a&&a(s)):(this.lastBoundingBox.width!==-1||this.lastBoundingBox.height!==-1)&&(this.lastBoundingBox.width=-1,this.lastBoundingBox.height=-1,a&&a(null))}},{key:"getBBoxSnapshot",value:function(){return this.lastBoundingBox.width>=0&&this.lastBoundingBox.height>=0?Vr({},this.lastBoundingBox):{width:0,height:0}}},{key:"getDefaultPosition",value:function(a){var s=this.props,i=s.layout,o=s.align,l=s.verticalAlign,c=s.margin,u=s.chartWidth,d=s.chartHeight,h,m;if(!a||(a.left===void 0||a.left===null)&&(a.right===void 0||a.right===null))if(o==="center"&&i==="vertical"){var j=this.getBBoxSnapshot();h={left:((u||0)-j.width)/2}}else h=o==="right"?{right:c&&c.right||0}:{left:c&&c.left||0};if(!a||(a.top===void 0||a.top===null)&&(a.bottom===void 0||a.bottom===null))if(l==="middle"){var w=this.getBBoxSnapshot();m={top:((d||0)-w.height)/2}}else m=l==="bottom"?{bottom:c&&c.bottom||0}:{top:c&&c.top||0};return Vr(Vr({},h),m)}},{key:"render",value:function(){var a=this,s=this.props,i=s.content,o=s.width,l=s.height,c=s.wrapperStyle,u=s.payloadUniqBy,d=s.payload,h=Vr(Vr({position:"absolute",width:o||"auto",height:l||"auto"},this.getDefaultPosition(c)),c);return L.createElement("div",{className:"recharts-legend-wrapper",style:h,ref:function(j){a.wrapperNode=j}},yN(i,Vr(Vr({},this.props),{},{payload:ap(d,u,gN)})))}}],[{key:"getWithHeight",value:function(a,s){var i=Vr(Vr({},this.defaultProps),a.props),o=i.layout;return o==="vertical"&&me(a.props.height)?{height:a.props.height}:o==="horizontal"?{width:a.props.width||s}:null}}])}(_.PureComponent);Eo(an,"displayName","Legend");Eo(an,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"bottom"});var fu=nf,jN=sf,bN=Or,pu=fu?fu.isConcatSpreadable:void 0;function wN(t){return bN(t)||jN(t)||!!(pu&&t&&t[pu])}var NN=wN,_N=Ng,SN=NN;function op(t,r,n,a,s){var i=-1,o=t.length;for(n||(n=SN),s||(s=[]);++i<o;){var l=t[i];r>0&&n(l)?r>1?op(l,r-1,n,a,s):_N(s,l):a||(s[s.length]=l)}return s}var lp=op;function ON(t){return function(r,n,a){for(var s=-1,i=Object(r),o=a(r),l=o.length;l--;){var c=o[t?l:++s];if(n(i[c],c,i)===!1)break}return r}}var CN=ON,AN=CN,PN=AN(),kN=PN,EN=kN,TN=sd;function $N(t,r){return t&&EN(t,r,TN)}var cp=$N,DN=mo;function MN(t,r){return function(n,a){if(n==null)return n;if(!DN(n))return t(n,a);for(var s=n.length,i=r?s:-1,o=Object(n);(r?i--:++i<s)&&a(o[i],i,o)!==!1;);return n}}var IN=MN,LN=cp,RN=IN,FN=RN(LN),yd=FN,BN=yd,zN=mo;function UN(t,r){var n=-1,a=zN(t)?Array(t.length):[];return BN(t,function(s,i,o){a[++n]=r(s,i,o)}),a}var dp=UN;function qN(t,r){var n=t.length;for(t.sort(r);n--;)t[n]=t[n].value;return t}var VN=qN,xu=Bs;function WN(t,r){if(t!==r){var n=t!==void 0,a=t===null,s=t===t,i=xu(t),o=r!==void 0,l=r===null,c=r===r,u=xu(r);if(!l&&!u&&!i&&t>r||i&&o&&c&&!l&&!u||a&&o&&c||!n&&c||!s)return 1;if(!a&&!i&&!u&&t<r||u&&n&&s&&!a&&!i||l&&n&&s||!o&&s||!c)return-1}return 0}var KN=WN,GN=KN;function HN(t,r,n){for(var a=-1,s=t.criteria,i=r.criteria,o=s.length,l=n.length;++a<o;){var c=GN(s[a],i[a]);if(c){if(a>=l)return c;var u=n[a];return c*(u=="desc"?-1:1)}}return t.index-r.index}var XN=HN,ll=ld,YN=cd,QN=qr,ZN=dp,JN=VN,e_=_g,t_=XN,r_=_a,n_=Or;function a_(t,r,n){r.length?r=ll(r,function(i){return n_(i)?function(o){return YN(o,i.length===1?i[0]:i)}:i}):r=[r_];var a=-1;r=ll(r,e_(QN));var s=ZN(t,function(i,o,l){var c=ll(r,function(u){return u(i)});return{criteria:c,index:++a,value:i}});return JN(s,function(i,o){return t_(i,o,n)})}var s_=a_;function i_(t,r,n){switch(n.length){case 0:return t.call(r);case 1:return t.call(r,n[0]);case 2:return t.call(r,n[0],n[1]);case 3:return t.call(r,n[0],n[1],n[2])}return t.apply(r,n)}var o_=i_,l_=o_,vu=Math.max;function c_(t,r,n){return r=vu(r===void 0?t.length-1:r,0),function(){for(var a=arguments,s=-1,i=vu(a.length-r,0),o=Array(i);++s<i;)o[s]=a[r+s];s=-1;for(var l=Array(r+1);++s<r;)l[s]=a[s];return l[r]=n(o),l_(t,this,l)}}var d_=c_;function u_(t){return function(){return t}}var h_=u_,m_=Sg,f_=function(){try{var t=m_(Object,"defineProperty");return t({},"",{}),t}catch{}}(),up=f_,p_=h_,gu=up,x_=_a,v_=gu?function(t,r){return gu(t,"toString",{configurable:!0,enumerable:!1,value:p_(r),writable:!0})}:x_,g_=v_,y_=800,j_=16,b_=Date.now;function w_(t){var r=0,n=0;return function(){var a=b_(),s=j_-(a-n);if(n=a,s>0){if(++r>=y_)return arguments[0]}else r=0;return t.apply(void 0,arguments)}}var N_=w_,__=g_,S_=N_,O_=S_(__),C_=O_,A_=_a,P_=d_,k_=C_;function E_(t,r){return k_(P_(t,r,A_),t+"")}var T_=E_,$_=Og,D_=mo,M_=of,I_=ad;function L_(t,r,n){if(!I_(n))return!1;var a=typeof r;return(a=="number"?D_(n)&&M_(r,n.length):a=="string"&&r in n)?$_(n[r],t):!1}var To=L_,R_=lp,F_=s_,B_=T_,yu=To,z_=B_(function(t,r){if(t==null)return[];var n=r.length;return n>1&&yu(t,r[0],r[1])?r=[]:n>2&&yu(r[0],r[1],r[2])&&(r=[r[0]]),F_(t,R_(r,1),[])}),U_=z_;const jd=pt(U_);function ls(t){"@babel/helpers - typeof";return ls=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},ls(t)}function Yl(){return Yl=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},Yl.apply(this,arguments)}function q_(t,r){return G_(t)||K_(t,r)||W_(t,r)||V_()}
vendor: 10,698 bytes, lines 62-63
62function V_(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
63In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function W_(t,r){if(t){if(typeof t=="string")return ju(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ju(t,r)}}function ju(t,r){(r==null||r>t.length)&&(r=t.length);for(var n=0,a=new Array(r);n<r;n++)a[n]=t[n];return a}function K_(t,r){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var a,s,i,o,l=[],c=!0,u=!1;try{if(i=(n=n.call(t)).next,r!==0)for(;!(c=(a=i.call(n)).done)&&(l.push(a.value),l.length!==r);c=!0);}catch(d){u=!0,s=d}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw s}}return l}}function G_(t){if(Array.isArray(t))return t}function bu(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function cl(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?bu(Object(n),!0).forEach(function(a){H_(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):bu(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function H_(t,r,n){return r=X_(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function X_(t){var r=Y_(t,"string");return ls(r)=="symbol"?r:r+""}function Y_(t,r){if(ls(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(ls(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function Q_(t){return Array.isArray(t)&&_t(t[0])&&_t(t[1])?t.join(" ~ "):t}var Z_=function(r){var n=r.separator,a=n===void 0?" : ":n,s=r.contentStyle,i=s===void 0?{}:s,o=r.itemStyle,l=o===void 0?{}:o,c=r.labelStyle,u=c===void 0?{}:c,d=r.payload,h=r.formatter,m=r.itemSorter,j=r.wrapperClassName,w=r.labelClassName,x=r.label,v=r.labelFormatter,y=r.accessibilityLayer,f=y===void 0?!1:y,b=function(){if(d&&d.length){var A={padding:0,margin:0},I=(m?jd(d,m):d).map(function(D,q){if(D.type==="none")return null;var F=cl({display:"block",paddingTop:4,paddingBottom:4,color:D.color||"#000"},l),K=D.formatter||h||Q_,M=D.value,E=D.name,Q=M,H=E;if(K&&Q!=null&&H!=null){var V=K(M,E,D,q,d);if(Array.isArray(V)){var se=q_(V,2);Q=se[0],H=se[1]}else Q=V}return L.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(q),style:F},_t(H)?L.createElement("span",{className:"recharts-tooltip-item-name"},H):null,_t(H)?L.createElement("span",{className:"recharts-tooltip-item-separator"},a):null,L.createElement("span",{className:"recharts-tooltip-item-value"},Q),L.createElement("span",{className:"recharts-tooltip-item-unit"},D.unit||""))});return L.createElement("ul",{className:"recharts-tooltip-item-list",style:A},I)}return null},p=cl({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},i),g=cl({margin:0},u),N=!Ie(x),S=N?x:"",O=Le("recharts-default-tooltip",j),C=Le("recharts-tooltip-label",w);N&&v&&d!==void 0&&d!==null&&(S=v(x,d));var P=f?{role:"status","aria-live":"assertive"}:{};return L.createElement("div",Yl({className:O,style:p},P),L.createElement("p",{className:C,style:g},L.isValidElement(S)?S:"".concat(S)),b())};function cs(t){"@babel/helpers - typeof";return cs=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},cs(t)}function Zs(t,r,n){return r=J_(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function J_(t){var r=eS(t,"string");return cs(r)=="symbol"?r:r+""}function eS(t,r){if(cs(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(cs(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}var Pa="recharts-tooltip-wrapper",tS={visibility:"hidden"};function rS(t){var r=t.coordinate,n=t.translateX,a=t.translateY;return Le(Pa,Zs(Zs(Zs(Zs({},"".concat(Pa,"-right"),me(n)&&r&&me(r.x)&&n>=r.x),"".concat(Pa,"-left"),me(n)&&r&&me(r.x)&&n<r.x),"".concat(Pa,"-bottom"),me(a)&&r&&me(r.y)&&a>=r.y),"".concat(Pa,"-top"),me(a)&&r&&me(r.y)&&a<r.y))}function wu(t){var r=t.allowEscapeViewBox,n=t.coordinate,a=t.key,s=t.offsetTopLeft,i=t.position,o=t.reverseDirection,l=t.tooltipDimension,c=t.viewBox,u=t.viewBoxDimension;if(i&&me(i[a]))return i[a];var d=n[a]-l-s,h=n[a]+s;if(r[a])return o[a]?d:h;if(o[a]){var m=d,j=c[a];return m<j?Math.max(h,c[a]):Math.max(d,c[a])}var w=h+l,x=c[a]+u;return w>x?Math.max(d,c[a]):Math.max(h,c[a])}function nS(t){var r=t.translateX,n=t.translateY,a=t.useTranslate3d;return{transform:a?"translate3d(".concat(r,"px, ").concat(n,"px, 0)"):"translate(".concat(r,"px, ").concat(n,"px)")}}function aS(t){var r=t.allowEscapeViewBox,n=t.coordinate,a=t.offsetTopLeft,s=t.position,i=t.reverseDirection,o=t.tooltipBox,l=t.useTranslate3d,c=t.viewBox,u,d,h;return o.height>0&&o.width>0&&n?(d=wu({allowEscapeViewBox:r,coordinate:n,key:"x",offsetTopLeft:a,position:s,reverseDirection:i,tooltipDimension:o.width,viewBox:c,viewBoxDimension:c.width}),h=wu({allowEscapeViewBox:r,coordinate:n,key:"y",offsetTopLeft:a,position:s,reverseDirection:i,tooltipDimension:o.height,viewBox:c,viewBoxDimension:c.height}),u=nS({translateX:d,translateY:h,useTranslate3d:l})):u=tS,{cssProperties:u,cssClasses:rS({translateX:d,translateY:h,coordinate:n})}}function ea(t){"@babel/helpers - typeof";return ea=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},ea(t)}function Nu(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function _u(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?Nu(Object(n),!0).forEach(function(a){Zl(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Nu(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function sS(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function iS(t,r){for(var n=0;n<r.length;n++){var a=r[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,mp(a.key),a)}}function oS(t,r,n){return r&&iS(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function lS(t,r,n){return r=Ci(r),cS(t,hp()?Reflect.construct(r,n||[],Ci(t).constructor):r.apply(t,n))}function cS(t,r){if(r&&(ea(r)==="object"||typeof r=="function"))return r;if(r!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return dS(t)}function dS(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function hp(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(hp=function(){return!!t})()}function Ci(t){return Ci=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Ci(t)}function uS(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&Ql(t,r)}function Ql(t,r){return Ql=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,s){return a.__proto__=s,a},Ql(t,r)}function Zl(t,r,n){return r=mp(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function mp(t){var r=hS(t,"string");return ea(r)=="symbol"?r:r+""}function hS(t,r){if(ea(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(ea(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}var Su=1,mS=function(t){function r(){var n;sS(this,r);for(var a=arguments.length,s=new Array(a),i=0;i<a;i++)s[i]=arguments[i];return n=lS(this,r,[].concat(s)),Zl(n,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0},lastBoundingBox:{width:-1,height:-1}}),Zl(n,"handleKeyDown",function(o){if(o.key==="Escape"){var l,c,u,d;n.setState({dismissed:!0,dismissedAtCoordinate:{x:(l=(c=n.props.coordinate)===null||c===void 0?void 0:c.x)!==null&&l!==void 0?l:0,y:(u=(d=n.props.coordinate)===null||d===void 0?void 0:d.y)!==null&&u!==void 0?u:0}})}}),n}return uS(r,t),oS(r,[{key:"updateBBox",value:function(){if(this.wrapperNode&&this.wrapperNode.getBoundingClientRect){var a=this.wrapperNode.getBoundingClientRect();(Math.abs(a.width-this.state.lastBoundingBox.width)>Su||Math.abs(a.height-this.state.lastBoundingBox.height)>Su)&&this.setState({lastBoundingBox:{width:a.width,height:a.height}})}else(this.state.lastBoundingBox.width!==-1||this.state.lastBoundingBox.height!==-1)&&this.setState({lastBoundingBox:{width:-1,height:-1}})}},{key:"componentDidMount",value:function(){document.addEventListener("keydown",this.handleKeyDown),this.updateBBox()}},{key:"componentWillUnmount",value:function(){document.removeEventListener("keydown",this.handleKeyDown)}},{key:"componentDidUpdate",value:function(){var a,s;this.props.active&&this.updateBBox(),this.state.dismissed&&(((a=this.props.coordinate)===null||a===void 0?void 0:a.x)!==this.state.dismissedAtCoordinate.x||((s=this.props.coordinate)===null||s===void 0?void 0:s.y)!==this.state.dismissedAtCoordinate.y)&&(this.state.dismissed=!1)}},{key:"render",value:function(){var a=this,s=this.props,i=s.active,o=s.allowEscapeViewBox,l=s.animationDuration,c=s.animationEasing,u=s.children,d=s.coordinate,h=s.hasPayload,m=s.isAnimationActive,j=s.offset,w=s.position,x=s.reverseDirection,v=s.useTranslate3d,y=s.viewBox,f=s.wrapperStyle,b=aS({allowEscapeViewBox:o,coordinate:d,offsetTopLeft:j,position:w,reverseDirection:x,tooltipBox:this.state.lastBoundingBox,useTranslate3d:v,viewBox:y}
63),p=b.cssClasses,g=b.cssProperties,N=_u(_u({transition:m&&i?"transform ".concat(l,"ms ").concat(c):void 0},g),{},{pointerEvents:"none",visibility:!this.state.dismissed&&i&&h?"visible":"hidden",position:"absolute",top:0,left:0},f);return L.createElement("div",{tabIndex:-1,className:p,style:N,ref:function(O){a.wrapperNode=O}},u)}}])}(_.PureComponent),fS=function(){return!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout)},Er={isSsr:fS(),get:function(r){return Er[r]},set:function(r,n){if(typeof r=="string")Er[r]=n;else{var a=Object.keys(r);a&&a.length&&a.forEach(function(s){Er[s]=r[s]})}}};function ta(t){"@babel/helpers - typeof";return ta=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},ta(t)}function Ou(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function Cu(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?Ou(Object(n),!0).forEach(function(a){bd(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Ou(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function pS(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function xS(t,r){for(var n=0;n<r.length;n++){var a=r[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,pp(a.key),a)}}function vS(t,r,n){return r&&xS(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function gS(t,r,n){return r=Ai(r),yS(t,fp()?Reflect.construct(r,n||[],Ai(t).constructor):r.apply(t,n))}function yS(t,r){if(r&&(ta(r)==="object"||typeof r=="function"))return r;if(r!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return jS(t)}function jS(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function fp(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(fp=function(){return!!t})()}function Ai(t){return Ai=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Ai(t)}function bS(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&Jl(t,r)}function Jl(t,r){return Jl=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,s){return a.__proto__=s,a},Jl(t,r)}function bd(t,r,n){return r=pp(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function pp(t){var r=wS(t,"string");return ta(r)=="symbol"?r:r+""}function wS(t,r){if(ta(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(ta(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function NS(t){return t.dataKey}function _S(t,r){return L.isValidElement(t)?L.cloneElement(t,r):typeof t=="function"?L.createElement(t,r):L.createElement(Z_,r)}var Ht=function(t){function r(){return pS(this,r),gS(this,r,arguments)}return bS(r,t),vS(r,[{key:"render",value:function(){var a=this,s=this.props,i=s.active,o=s.allowEscapeViewBox,l=s.animationDuration,c=s.animationEasing,u=s.content,d=s.coordinate,h=s.filterNull,m=s.isAnimationActive,j=s.offset,w=s.payload,x=s.payloadUniqBy,v=s.position,y=s.reverseDirection,f=s.useTranslate3d,b=s.viewBox,p=s.wrapperStyle,g=w??[];h&&g.length&&(g=ap(w.filter(function(S){return S.value!=null&&(S.hide!==!0||a.props.includeHidden)}),x,NS));var N=g.length>0;return L.createElement(mS,{allowEscapeViewBox:o,animationDuration:l,animationEasing:c,isAnimationActive:m,active:i,coordinate:d,hasPayload:N,offset:j,position:v,reverseDirection:y,useTranslate3d:f,viewBox:b,wrapperStyle:p},_S(u,Cu(Cu({},this.props),{},{payload:g})))}}])}(_.PureComponent);bd(Ht,"displayName","Tooltip");bd(Ht,"defaultProps",{accessibilityLayer:!1,allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:"ease",contentStyle:{},coordinate:{x:0,y:0},cursor:!0,cursorStyle:{},filterNull:!0,isAnimationActive:!Er.isSsr,itemStyle:{},labelStyle:{},offset:10,reverseDirection:{x:!1,y:!1},separator:" : ",trigger:"hover",useTranslate3d:!1,viewBox:{x:0,y:0,height:0,width:0},wrapperStyle:{}});var SS=Rv,OS=ad,CS="Expected a function";function AS(t,r,n){var a=!0,s=!0;if(typeof t!="function")throw new TypeError(CS);return OS(n)&&(a="leading"in n?!!n.leading:a,s="trailing"in n?!!n.trailing:s),SS(t,r,{leading:a,maxWait:r,trailing:s})}var PS=AS;const xp=pt(PS);function ds(t){"@babel/helpers - typeof";return ds=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},ds(t)}function Au(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function Js(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};
vendor: 78,994 bytes, lines 63-97
63r%2?Au(Object(n),!0).forEach(function(a){kS(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Au(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function kS(t,r,n){return r=ES(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function ES(t){var r=TS(t,"string");return ds(r)=="symbol"?r:r+""}function TS(t,r){if(ds(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(ds(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function $S(t,r){return LS(t)||IS(t,r)||MS(t,r)||DS()}function DS(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
64In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function MS(t,r){if(t){if(typeof t=="string")return Pu(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Pu(t,r)}}function Pu(t,r){(r==null||r>t.length)&&(r=t.length);for(var n=0,a=new Array(r);n<r;n++)a[n]=t[n];return a}function IS(t,r){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var a,s,i,o,l=[],c=!0,u=!1;try{if(i=(n=n.call(t)).next,r!==0)for(;!(c=(a=i.call(n)).done)&&(l.push(a.value),l.length!==r);c=!0);}catch(d){u=!0,s=d}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw s}}return l}}function LS(t){if(Array.isArray(t))return t}var ei=_.forwardRef(function(t,r){var n=t.aspect,a=t.initialDimension,s=a===void 0?{width:-1,height:-1}:a,i=t.width,o=i===void 0?"100%":i,l=t.height,c=l===void 0?"100%":l,u=t.minWidth,d=u===void 0?0:u,h=t.minHeight,m=t.maxHeight,j=t.children,w=t.debounce,x=w===void 0?0:w,v=t.id,y=t.className,f=t.onResize,b=t.style,p=b===void 0?{}:b,g=_.useRef(null),N=_.useRef();N.current=f,_.useImperativeHandle(r,function(){return Object.defineProperty(g.current,"current",{get:function(){return console.warn("The usage of ref.current.current is deprecated and will no longer be supported."),g.current},configurable:!0})});var S=_.useState({containerWidth:s.width,containerHeight:s.height}),O=$S(S,2),C=O[0],P=O[1],$=_.useCallback(function(I,D){P(function(q){var F=Math.round(I),K=Math.round(D);return q.containerWidth===F&&q.containerHeight===K?q:{containerWidth:F,containerHeight:K}})},[]);_.useEffect(function(){var I=function(E){var Q,H=E[0].contentRect,V=H.width,se=H.height;$(V,se),(Q=N.current)===null||Q===void 0||Q.call(N,V,se)};x>0&&(I=xp(I,x,{trailing:!0,leading:!1}));var D=new ResizeObserver(I),q=g.current.getBoundingClientRect(),F=q.width,K=q.height;return $(F,K),D.observe(g.current),function(){D.disconnect()}},[$,x]);var A=_.useMemo(function(){var I=C.containerWidth,D=C.containerHeight;if(I<0||D<0)return null;Sr(bn(o)||bn(c),`The width(%s) and height(%s) are both fixed numbers,
65       maybe you don't need to use a ResponsiveContainer.`,o,c),Sr(!n||n>0,"The aspect(%s) must be greater than zero.",n);var q=bn(o)?I:o,F=bn(c)?D:c;n&&n>0&&(q?F=q/n:F&&(q=F*n),m&&F>m&&(F=m)),Sr(q>0||F>0,`The width(%s) and height(%s) of chart should be greater than 0,
66       please check the style of container, or the props width(%s) and height(%s),
67       or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the
68       height and width.`,q,F,o,c,d,h,n);var K=!Array.isArray(j)&&Hr(j.type).endsWith("Chart");return L.Children.map(j,function(M){return Cf.isElement(M)?_.cloneElement(M,Js({width:q,height:F},K?{style:Js({height:"100%",width:"100%",maxHeight:F,maxWidth:q},M.props.style)}:{})):M})},[n,j,c,m,h,d,C,o]);return L.createElement("div",{id:v?"".concat(v):void 0,className:Le("recharts-responsive-container",y),style:Js(Js({},p),{},{width:o,height:c,minWidth:d,minHeight:h,maxHeight:m}),ref:g},A)}),us=function(r){return null};us.displayName="Cell";function hs(t){"@babel/helpers - typeof";return hs=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},hs(t)}function ku(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function ec(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?ku(Object(n),!0).forEach(function(a){RS(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ku(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function RS(t,r,n){return r=FS(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function FS(t){var r=BS(t,"string");return hs(r)=="symbol"?r:r+""}function BS(t,r){if(hs(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(hs(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}var Fn={widthCache:{},cacheCount:0},zS=2e3,US={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},Eu="recharts_measurement_span";function qS(t){var r=ec({},t);return Object.keys(r).forEach(function(n){r[n]||delete r[n]}),r}var Ga=function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(r==null||Er.isSsr)return{width:0,height:0};var a=qS(n),s=JSON.stringify({text:r,copyStyle:a});if(Fn.widthCache[s])return Fn.widthCache[s];try{var i=document.getElementById(Eu);i||(i=document.createElement("span"),i.setAttribute("id",Eu),i.setAttribute("aria-hidden","true"),document.body.appendChild(i));var o=ec(ec({},US),a);Object.assign(i.style,o),i.textContent="".concat(r);var l=i.getBoundingClientRect(),c={width:l.width,height:l.height};return Fn.widthCache[s]=c,++Fn.cacheCount>zS&&(Fn.cacheCount=0,Fn.widthCache={}),c}catch{return{width:0,height:0}}},VS=function(r){return{top:r.top+window.scrollY-document.documentElement.clientTop,left:r.left+window.scrollX-document.documentElement.clientLeft}};function ms(t){"@babel/helpers - typeof";return ms=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},ms(t)}function Pi(t,r){return HS(t)||GS(t,r)||KS(t,r)||WS()}function WS(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
69In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function KS(t,r){if(t){if(typeof t=="string")return Tu(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Tu(t,r)}}function Tu(t,r){(r==null||r>t.length)&&(r=t.length);for(var n=0,a=new Array(r);n<r;n++)a[n]=t[n];return a}function GS(t,r){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var a,s,i,o,l=[],c=!0,u=!1;try{if(i=(n=n.call(t)).next,r===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(a=i.call(n)).done)&&(l.push(a.value),l.length!==r);c=!0);}catch(d){u=!0,s=d}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw s}}return l}}function HS(t){if(Array.isArray(t))return t}function XS(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function $u(t,r){for(var n=0;n<r.length;n++){var a=r[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,QS(a.key),a)}}function YS(t,r,n){return r&&$u(t.prototype,r),n&&$u(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function QS(t){var r=ZS(t,"string");return ms(r)=="symbol"?r:r+""}function ZS(t,r){if(ms(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r);if(ms(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}var Du=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,Mu=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,JS=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,e1=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,vp={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},t1=Object.keys(vp),Un="NaN";function r1(t,r){return t*vp[r]}var ti=function(){function t(r,n){XS(this,t),this.num=r,this.unit=n,this.num=r,this.unit=n,Number.isNaN(r)&&(this.unit=""),n!==""&&!JS.test(n)&&(this.num=NaN,this.unit=""),t1.includes(n)&&(this.num=r1(r,n),this.unit="px")}return YS(t,[{key:"add",value:function(n){return this.unit!==n.unit?new t(NaN,""):new t(this.num+n.num,this.unit)}},{key:"subtract",value:function(n){return this.unit!==n.unit?new t(NaN,""):new t(this.num-n.num,this.unit)}},{key:"multiply",value:function(n){return this.unit!==""&&n.unit!==""&&this.unit!==n.unit?new t(NaN,""):new t(this.num*n.num,this.unit||n.unit)}},{key:"divide",value:function(n){return this.unit!==""&&n.unit!==""&&this.unit!==n.unit?new t(NaN,""):new t(this.num/n.num,this.unit||n.unit)}},{key:"toString",value:function(){return"".concat(this.num).concat(this.unit)}},{key:"isNaN",value:function(){return Number.isNaN(this.num)}}],[{key:"parse",value:function(n){var a,s=(a=e1.exec(n))!==null&&a!==void 0?a:[],i=Pi(s,3),o=i[1],l=i[2];return new t(parseFloat(o),l??"")}}])}();function gp(t){if(t.includes(Un))return Un;for(var r=t;r.includes("*")||r.includes("/");){var n,a=(n=Du.exec(r))!==null&&n!==void 0?n:[],s=Pi(a,4),i=s[1],o=s[2],l=s[3],c=ti.parse(i??""),u=ti.parse(l??""),d=o==="*"?c.multiply(u):c.divide(u);if(d.isNaN())return Un;r=r.replace(Du,d.toString())}for(;r.includes("+")||/.-\d+(?:\.\d+)?/.test(r);){var h,m=(h=Mu.exec(r))!==null&&h!==void 0?h:[],j=Pi(m,4),w=j[1],x=j[2],v=j[3],y=ti.parse(w??""),f=ti.parse(v??""),b=x==="+"?y.add(f):y.subtract(f);if(b.isNaN())return Un;r=r.replace(Mu,b.toString())}return r}var Iu=/\(([^()]*)\)/;function n1(t){for(var r=t;r.includes("(");){var n=Iu.exec(r),a=Pi(n,2),s=a[1];r=r.replace(Iu,gp(s))}return r}function a1(t){var r=t.replace(/\s+/g,"");return r=n1(r),r=gp(r),r}function s1(t){try{return a1(t)}catch{return Un}}function dl(t){var r=s1(t.slice(5,-1));return r===Un?"":r}var i1=["x","y","lineHeight","capHeight","scaleToFit","textAnchor","verticalAnchor","fill"],o1=["dx","dy","angle","className","breakAll"];function tc(){return tc=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},tc.apply(this,arguments)}function Lu(t,r){if(t==null)return{};var n=l1(t,r),a,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)a=i[s],!(r.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(t,a)&&(n[a]=t[a])}return n}function l1(t,r){if(t==null)return{};var n={};for(var a in t)if(Object.prototype.hasOwnProperty.call(t,a)){if(r.indexOf(a)>=0)continue;n[a]=t[a]}return n}function Ru(t,r){return h1(t)||u1(t,r)||d1(t,r)||c1()}function c1(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
70In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function d1(t,r){if(t){if(typeof t=="string")return Fu(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Fu(t,r)}}function Fu(t,r){(r==null||r>t.length)&&(r=t.length);for(var n=0,a=new Array(r);n<r;n++)a[n]=t[n];return a}function u1(t,r){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var a,s,i,o,l=[],c=!0,u=!1;try{if(i=(n=n.call(t)).next,r===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(a=i.call(n)).done)&&(l.push(a.value),l.length!==r);c=!0);}catch(d){u=!0,s=d}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw s}}return l}}function h1(t){if(Array.isArray(t))return t}var yp=/[ \f\n\r\t\v\u2028\u2029]+/,jp=function(r){var n=r.children,a=r.breakAll,s=r.style;try{var i=[];Ie(n)||(a?i=n.toString().split(""):i=n.toString().split(yp));var o=i.map(function(c){return{word:c,width:Ga(c,s).width}}),l=a?0:Ga(" ",s).width;return{wordsWithComputedWidth:o,spaceWidth:l}}catch{return null}},m1=function(r,n,a,s,i){var o=r.maxLines,l=r.children,c=r.style,u=r.breakAll,d=me(o),h=l,m=function(){var q=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return q.reduce(function(F,K){var M=K.word,E=K.width,Q=F[F.length-1];if(Q&&(s==null||i||Q.width+E+a<Number(s)))Q.words.push(M),Q.width+=E+a;else{var H={words:[M],width:E};F.push(H)}return F},[])},j=m(n),w=function(q){return q.reduce(function(F,K){return F.width>K.width?F:K})};if(!d)return j;for(var x="…",v=function(q){var F=h.slice(0,q),K=jp({breakAll:u,style:c,children:F+x}).wordsWithComputedWidth,M=m(K),E=M.length>o||w(M).width>Number(s);return[E,M]},y=0,f=h.length-1,b=0,p;y<=f&&b<=h.length-1;){var g=Math.floor((y+f)/2),N=g-1,S=v(N),O=Ru(S,2),C=O[0],P=O[1],$=v(g),A=Ru($,1),I=A[0];if(!C&&!I&&(y=g+1),C&&I&&(f=g-1),!C&&I){p=P;break}b++}return p||j},Bu=function(r){var n=Ie(r)?[]:r.toString().split(yp);return[{words:n}]},f1=function(r){var n=r.width,a=r.scaleToFit,s=r.children,i=r.style,o=r.breakAll,l=r.maxLines;if((n||a)&&!Er.isSsr){var c,u,d=jp({breakAll:o,children:s,style:i});if(d){var h=d.wordsWithComputedWidth,m=d.spaceWidth;c=h,u=m}else return Bu(s);return m1({breakAll:o,children:s,maxLines:l,style:i},c,u,n,a)}return Bu(s)},zu="#808080",Dn=function(r){var n=r.x,a=n===void 0?0:n,s=r.y,i=s===void 0?0:s,o=r.lineHeight,l=o===void 0?"1em":o,c=r.capHeight,u=c===void 0?"0.71em":c,d=r.scaleToFit,h=d===void 0?!1:d,m=r.textAnchor,j=m===void 0?"start":m,w=r.verticalAnchor,x=w===void 0?"end":w,v=r.fill,y=v===void 0?zu:v,f=Lu(r,i1),b=_.useMemo(function(){return f1({breakAll:f.breakAll,children:f.children,maxLines:f.maxLines,scaleToFit:h,style:f.style,width:f.width})},[f.breakAll,f.children,f.maxLines,h,f.style,f.width]),p=f.dx,g=f.dy,N=f.angle,S=f.className,O=f.breakAll,C=Lu(f,o1);if(!_t(a)||!_t(i))return null;var P=a+(me(p)?p:0),$=i+(me(g)?g:0),A;switch(x){case"start":A=dl("calc(".concat(u,")"));break;case"middle":A=dl("calc(".concat((b.length-1)/2," * -").concat(l," + (").concat(u," / 2))"));break;default:A=dl("calc(".concat(b.length-1," * -").concat(l,")"));break}var I=[];if(h){var D=b[0].width,q=f.width;I.push("scale(".concat((me(q)?q/D:1)/D,")"))}return N&&I.push("rotate(".concat(N,", ").concat(P,", ").concat($,")")),I.length&&(C.transform=I.join(" ")),L.createElement("text",tc({},Oe(C,!0),{x:P,y:$,className:Le("recharts-text",S),textAnchor:j,fill:y.includes("url")?zu:y}),b.map(function(F,K){var M=F.words.join(O?"":" ");return L.createElement("tspan",{x:P,dy:K===0?A:l,key:"".concat(M,"-").concat(K)},M)}))};const Uu=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:Al,scaleDiverging:Fv,scaleDivergingLog:Bv,scaleDivergingPow:zv,scaleDivergingSqrt:Uv,scaleDivergingSymlog:qv,scaleIdentity:Vv,scaleImplicit:Wv,scaleLinear:Cl,scaleLog:Kv,scaleOrdinal:Gv,scalePoint:Ia,scalePow:Hv,scaleQuantile:Xv,scaleQuantize:Yv,scaleRadial:Qv,scaleSequential:Zv,scaleSequentialLog:Jv,scaleSequentialPow:eg,scaleSequentialQuantile:tg,scaleSequentialSqrt:rg,scaleSequentialSymlog:ng,scaleSqrt:ag,scaleSymlog:sg,scaleThreshold:ig,scaleTime:Tv,scaleUtc:og,tickFormat:$v},Symbol.toStringTag,{value:"Module"}));var p1=Bs;function x1(t,r,n){for(var a=-1,s=t.length;++a<s;){var i=t[a],o=r(i);if(o!=null&&(l===void 0?o===o&&!p1(o):n(o,l)))var l=o,c=i}return c}var $o=x1;function v1(t,r){return t>r}var bp=v1,g1=$o,y1=bp,j1=_a;function b1(t){return t&&t.length?g1(t,j1,y1):void 0}var w1=b1;const Do=pt(w1);function N1(t,r){return t<r}var wp=N1,_1=$o,S1=wp,O1=_a;function C1(t){return t&&t.length?_1(t,O1,S1):void 0}var A1=C1;const Mo=pt(A1);var P1=ld,k1=qr,E1=dp,T1=Or;function $1(t,r){var n=T1(t)?P1:E1;return n(t,k1(r))}var D1=$1,M1=lp,I1=D1;function L1(t,r){return M1(I1(t,r),1)}var R1=L1;const F1=pt(R1);var Sa=1e9,B1={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},Nd,dt=!0,vr="[DecimalError] ",Sn=vr+"Invalid argument: ",wd=vr+"Exponent out of range: ",Oa=Math.floor,gn=Math.pow,z1=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Yt,Ot=1e7,it=7,Np=9007199254740991,ki=Oa(Np/it),je={};je.absoluteValue=je.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t};je.comparedTo=je.cmp=function(t){var r,n,a,s,i=this;if(t=new i.constructor(t),i.s!==t.s)return i.s||-t.s;if(i.e!==t.e)return i.e>t.e^i.s<0?1:-1;for(a=i.d.length,s=t.d.length,r=0,n=a<s?a:s;r<n;++r)if(i.d[r]!==t.d[r])return i.d[r]>t.d[r]^i.s<0?1:-1;return a===s?0:a>s^i.s<0?1:-1};je.decimalPlaces=je.dp=function(){var t=this,r=t.d.length-1,n=(r-t.e)*it;if(r=t.d[r],r)for(;r%10==0;r/=10)n--;return n<0?0:n};je.dividedBy=je.div=function(t){return Xr(this,new this.constructor(t))};je.dividedToIntegerBy=je.idiv=function(t){var r=this,n=r.constructor;return Je(Xr(r,new n(t),0,1),n.precision)};je.equals=je.eq=function(t){return!this.cmp(t)};je.exponent=function(){return bt(this)};je.greaterThan=je.gt=function(t){return this.cmp(t)>0};je.greaterThanOrEqualTo=je.gte=function(t){return this.cmp(t)>=0};je.isInteger=je.isint=function(){return this.e>this.d.length-2};je.isNegative=je.isneg=function(){return this.s<0};je.isPositive=je.ispos=function(){return this.s>0};je.isZero=function(){return this.s===0};je.lessThan=je.lt=function(t){return this.cmp(t)<0};je.lessThanOrEqualTo=je.lte=function(t){return this.cmp(t)<1};je.logarithm=je.log=function(t){var r,n=this,a=n.constructor,s=a.precision,i=s+5;if(t===void 0)t=new a(10);else if(t=new a(t),t.s<1||t.eq(Yt))throw Error(vr+"NaN");if(n.s<1)throw Error(vr+(n.s?"NaN":"-Infinity"));return n.eq(Yt)?new a(0):(dt=!1,r=Xr(fs(n,i),fs(t,i),i),dt=!0,Je(r,s))};je.minus=je.sub=function(t){var r=this;return t=new r.constructor(t),r.s==t.s?Op(r,t):_p(r,(t.s=-t.s,t))};je.modulo=je.mod=function(t){var r,n=this,a=n.constructor,s=a.precision;if(t=new a(t),!t.s)throw Error(vr+"NaN");return n.s?(dt=!1,r=Xr(n,t,0,1).times(t),dt=!0,n.minus(r)):Je(new a(n),s)};je.naturalExponential=je.exp=function(){return Sp(this)};je.naturalLogarithm=je.ln=function(){return fs(this)};je.negated=je.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};je.plus=je.add=function(t){var r=this;return t=new r.constructor(t),r.s==t.s?_p(r,t):Op(r,(t.s=-t.s,t))};je.precision=je.sd=function(t){var r,n,a,s=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(Sn+t);if(r=bt(s)+1,a=s.d.length-1,n=a*it+1,a=s.d[a],a){for(;a%10==0;a/=10)n--;for(a=s.d[0];a>=10;a/=10)n++}return t&&r>n?r:n};je.squareRoot=je.sqrt=function(){var t,r,n,a,s,i,o,l=this,c=l.constructor;if(l.s<1){if(!l.s)return new c(0);throw Error(vr+"NaN")}for(t=bt(l),dt=!1,s=Math.sqrt(+l),s==0||s==1/0?(r=kr(l.d),(r.length+t)%2==0&&(r+="0"),s=Math.sqrt(r),t=Oa((t+1)/2)-(t<0||t%2),s==1/0?r="5e"+t:(r=s.toExponential(),r=r.slice(0,r.indexOf("e")+1)+t),a=new c(r)):a=new c(s.toString()),n=c.precision,s=o=n+3;;)if(i=a,a=i.plus(Xr(l,i,o+2)).times(.5),kr(i.d).slice(0,o)===(r=kr(a.d)).slice(0,o)){if(r=r.slice(o-3,o+1),s==o&&r=="4999"){if(Je(i,n+1,0),i.times(i).eq(l)){a=i;break}}else if(r!="9999")break;o+=4}return dt=!0,Je(a,n)};je.times=je.mul=function(t){var r,n,a,s,i,o,l,c,u,d=this,h=d.constructor,m=d.d,j=(t=new h(t)).d;if(!d.s||!t.s)return new h(0);for(t.s*=d.s,n=d.e+t.e,c=m.length,u=j.length,c<u&&(i=m,m=j,j=i,o=c,c=u,u=o),i=[],o=c+u,a=o;a--;)i.push(0);for(a=u;--a>=0;){for(r=0,s=c+a;s>a;)l=i[s]+j[a]*m[s-a-1]+r,i[s--]=l%Ot|0,r=l/Ot|0;i[s]=(i[s]+r)%Ot|0}for(;!i[--o];)i.pop();return r?++n:i.shift(),t.d=i,t.e=n,dt?Je(t,h.precision):t};je.toDecimalPlaces=je.todp=function(t,r){var n=this,a=n.constructor;return n=new a(n),t===void 0?n:(Lr(t,0,Sa),r===void 0?r=a.rounding:Lr(r,0,8),Je(n,t+bt(n)+1,r))};je.toExponential=function(t,r){var n,a=this,s=a.constructor;return t===void 0?n=Mn(a,!0):(Lr(t,0,Sa),r===void 0?r=s.rounding:Lr(r,0,8),a=Je(new s(a),t+1,r),n=Mn(a,!0,t+1)),n};je.toFixed=function(t,r){var n,a,s=this,i=s.constructor;return t===void 0?Mn(s):(Lr(t,0,Sa),r===void 0?r=i.rounding:Lr(r,0,8),a=Je(new i(s),t+bt(s)+1,r),n=Mn(a.abs(),!1,t+bt(a)+1),s.isneg()&&!s.isZero()?"-"+n:n)};je.toInteger=je.toint=function(){var t=this,r=t.constructor;return Je(new r(t),bt(t)+1,r.rounding)};je.toNumber=function(){return+this};je.toPower=je.pow=function(t){var r,n,a,s,i,o,l=this,c=l.constructor,u=12,d=+(t=new c(t));if(!t.s)return new c(Yt);if(l=new c(l),!l.s){if(t.s<1)throw Error(vr+"Infinity");return l}if(l.eq(Yt))return l;if(a=c.precision,t.eq(Yt))return Je(l,a);if(r=t.e,n=t.d.length-1,o=r>=n,i=l.s,o){if((n=d<0?-d:d)<=Np){for(s=new c(Yt),r=Math.ceil(a/it+4),dt=!1;n%2&&(s=s.times(l),Vu(s.d,r)),n=Oa(n/2),n!==0;)l=l.times(l),Vu(l.d,r);return dt=!0,t.s<0?new c(Yt).div(s):Je(s,a)}}else if(i<0)throw Error(vr+"NaN");return i=i<0&&t.d[Math.max(r,n)]&1?-1:1,l.s=1,dt=!1,s=t.times(fs(l,a+u)),dt=!0,s=Sp(s),s.s=i,s};je.toPrecision=function(t,r){var n,a,s=this,i=s.constructor;return t===void 0?(n=bt(s),a=Mn(s,n<=i.toExpNeg||n>=i.toExpPos)):(Lr(t,1,Sa),r===void 0?r=i.rounding:Lr(r,0,8),s=Je(new i(s),t,r),n=bt(s),a=Mn(s,t<=n||n<=i.toExpNeg,t)),a};je.toSignificantDigits=je.tosd=function(t,r){var n=this,a=n.constructor;return t===void 0?(t=a.precision,r=a.rounding):(Lr(t,1,Sa),r===void 0?r=a.rounding:Lr(r,0,8)),Je(new a(n),t,r)};je.toString=je.valueOf=je.val=je.toJSON=je[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,r=bt(t),n=t.constructor;return Mn(t,r<=n.toExpNeg||r>=n.toExpPos)};function _p(t,r){var n,a,s,i,o,l,c,u,d=t.constructor,h=d.precision;if(!t.s||!r.s)return r.s||(r=new d(t)),dt?Je(r,h):r;if(c=t.d,u=r.d,o=t.e,s=r.e,c=c.slice(),i=o-s,i){for(i<0?(a=c,i=-i,l=u.length):(a=u,s=o,l=c.length),o=Math.ceil(h/it),l=o>l?o+1:l+1,i>l&&(i=l,a.length=1),a.reverse();i--;)a.push(0);a.reverse()}for(l=c.length,i=u.length,l-i<0&&(i=l,a=u,u=c,c=a),n=0;i;)n=(c[--i]=c[i]+u[i]+n)/Ot|0,c[i]%=Ot;for(n&&(c.unshift(n),++s),l=c.length;c[--l]==0;)c.pop();return r.d=c,r.e=s,dt?Je(r,h):r}function Lr(t,r,n){if(t!==~~t||t<r||t>n)throw Error(Sn+t)}function kr(t){var r,n,a,s=t.length-1,i="",o=t[0];if(s>0){for(i+=o,r=1;r<s;r++)a=t[r]+"",n=it-a.length,n&&(i+=en(n)),i+=a;o=t[r],a=o+"",n=it-a.length,n&&(i+=en(n))}else if(o===0)return"0";for(;o%10===0;)o/=10;return i+o}var Xr=function(){function t(a,s){var i,o=0,l=a.length;for(a=a.slice();l--;)i=a[l]*s+o,a[l]=i%Ot|0,o=i/Ot|0;return o&&a.unshift(o),a}function r(a,s,i,o){var l,c;if(i!=o)c=i>o?1:-1;else for(l=c=0;l<i;l++)if(a[l]!=s[l]){c=a[l]>s[l]?1:-1;break}return c}function n(a,s,i){for(var o=0;i--;)a[i]-=o,o=a[i]<s[i]?1:0,a[i]=o*Ot+a[i]-s[i];for(;!a[0]&&a.length>1;)a.shift()}return function(a,s,i,o){var l,c,u,d,h,m,j,w,x,v,y,f,b,p,g,N,S,O,C=a.constructor,P=a.s==s.s?1:-1,$=a.d,A=s.d;if(!a.s)return new C(a);if(!s.s)throw Error(vr+"Division by zero");for(c=a.e-s.e,S=A.length,g=$.length,j=new C(P),w=j.d=[],u=0;A[u]==($[u]||0);)++u;if(A[u]>($[u]||0)&&--c,i==null?f=i=C.precision:o?f=i+(bt(a)-bt(s))+1:f=i,f<0)return new C(0);if(f=f/it+2|0,u=0,S==1)for(d=0,A=A[0],f++;(u<g||d)&&f--;u++)b=d*Ot+($[u]||0),w[u]=b/A|0,d=b%A|0;else{for(d=Ot/(A[0]+1)|0,d>1&&(A=t(A,d),$=t($,d),S=A.length,g=$.length),p=S,x=$.slice(0,S),v=x.length;v<S;)x[v++]=0;O=A.slice(),O.unshift(0),N=A[0],A[1]>=Ot/2&&++N;do d=0,l=r(A,x,S,v),l<0?(y=x[0],S!=v&&(y=y*Ot+(x[1]||0)),d=y/N|0,d>1?(d>=Ot&&(d=Ot-1),h=t(A,d),m=h.length,v=x.length,l=r(h,x,m,v),l==1&&(d--,n(h,S<m?O:A,m))):(d==0&&(l=d=1),h=A.slice()),m=h.length,m<v&&h.unshift(0),n(x,h,v),l==-1&&(v=x.length,l=r(A,x,S,v),l<1&&(d++,n(x,S<v?O:A,v))),v=x.length):l===0&&(d++,x=[0]),w[u++]=d,l&&x[0]?x[v++]=$[p]||0:(x=[$[p]],v=1);while((p++<g||x[0]!==void 0)&&f--)}return w[0]||w.shift(),j.e=c,Je(j,o?i+bt(j)+1:i)}}();function Sp(t,r){var n,a,s,i,o,l,c=0,u=0,d=t.constructor,h=d.precision;if(bt(t)>16)throw Error(wd+bt(t));if(!t.s)return new d(Yt);for(r==null?(dt=!1,l=h):l=r,o=new d(.03125);t.abs().gte(.1);)t=t.times(o),u+=5;for(a=Math.log(gn(2,u))/Math.LN10*2+5|0,l+=a,n=s=i=new d(Yt),d.precision=l;;){if(s=Je(s.times(t),l),n=n.times(++c),o=i.plus(Xr(s,n,l)),kr(o.d).slice(0,l)===kr(i.d).slice(0,l)){for(;u--;)i=Je(i.times(i),l);return d.precision=h,r==null?(dt=!0,Je(i,h)):i}i=o}}function bt(t){for(var r=t.e*it,n=t.d[0];n>=10;n/=10)r++;return r}function ul(t,r,n){if(r>t.LN10.sd())throw dt=!0,n&&(t.precision=n),Error(vr+"LN10 precision limit exceeded");return Je(new t(t.LN10),r)}function en(t){for(var r="";t--;)r+="0";return r}function fs(t,r){var n,a,s,i,o,l,c,u,d,h=1,m=10,j=t,w=j.d,x=j.constructor,v=x.precision;if(j.s<1)throw Error(vr+(j.s?"NaN":"-Infinity"));if(j.eq(Yt))return new x(0);if(r==null?(dt=!1,u=v):u=r,j.eq(10))return r==null&&(dt=!0),ul(x,u);if(u+=m,x.precision=u,n=kr(w),a=n.charAt(0),i=bt(j),Math.abs(i)<15e14){for(;a<7&&a!=1||a==1&&n.charAt(1)>3;)j=j.times(t),n=kr(j.d),a=n.charAt(0),h++;i=bt(j),a>1?(j=new x("0."+n),i++):j=new x(a+"."+n.slice(1))}else return c=ul(x,u+2,v).times(i+""),j=fs(new x(a+"."+n.slice(1)),u-m).plus(c),x.precision=v,r==null?(dt=!0,Je(j,v)):j;for(l=o=j=Xr(j.minus(Yt),j.plus(Yt),u),d=Je(j.times(j),u),s=3;;){if(o=Je(o.times(d),u),c=l.plus(Xr(o,new x(s),u)),kr(c.d).slice(0,u)===kr(l.d).slice(0,u))return l=l.times(2),i!==0&&(l=l.plus(ul(x,u+2,v).times(i+""))),l=Xr(l,new x(h),u),x.precision=v,r==null?(dt=!0,Je(l,v)):l;l=c,s+=2}}function qu(t,r){var n,a,s;for((n=r.indexOf("."))>-1&&(r=r.replace(".","")),(a=r.search(/e/i))>0?(n<0&&(n=a),n+=+r.slice(a+1),r=r.substring(0,a)):n<0&&(n=r.length),a=0;r.charCodeAt(a)===48;)++a;for(s=r.length;r.charCodeAt(s-1)===48;)--s;if(r=r.slice(a,s),r){if(s-=a,n=n-a-1,t.e=Oa(n/it),t.d=[],a=(n+1)%it,n<0&&(a+=it),a<s){for(a&&t.d.push(+r.slice(0,a)),s-=it;a<s;)t.d.push(+r.slice(a,a+=it));r=r.slice(a),a=it-r.length}else a-=s;for(;a--;)r+="0";if(t.d.push(+r),dt&&(t.e>ki||t.e<-ki))throw Error(wd+n)}else t.s=0,t.e=0,t.d=[0];return t}function Je(t,r,n){var a,s,i,o,l,c,u,d,h=t.d;for(o=1,i=h[0];i>=10;i/=10)o++;if(a=r-o,a<0)a+=it,s=r,u=h[d=0];else{if(d=Math.ceil((a+1)/it),i=h.length,d>=i)return t;for(u=i=h[d],o=1;i>=10;i/=10)o++;a%=it,s=a-it+o}if(n!==void 0&&(i=gn(10,o-s-1),l=u/i%10|0,c=r<0||h[d+1]!==void 0||u%i,c=n<4?(l||c)&&(n==0||n==(t.s<0?3:2)):l>5||l==5&&(n==4||c||n==6&&(a>0?s>0?u/gn(10,o-s):0:h[d-1])%10&1||n==(t.s<0?8:7))),r<1||!h[0])return c?(i=bt(t),h.length=1,r=r-i-1,h[0]=gn(10,(it-r%it)%it),t.e=Oa(-r/it)||0):(h.length=1,h[0]=t.e=t.s=0),t;if(a==0?(h.length=d,i=1,d--):(h.length=d+1,i=gn(10,it-a),h[d]=s>0?(u/gn(10,o-s)%gn(10,s)|0)*i:0),c)for(;;)if(d==0){(h[0]+=i)==Ot&&(h[0]=1,++t.e);break}else{if(h[d]+=i,h[d]!=Ot)break;h[d--]=0,i=1}for(a=h.length;h[--a]===0;)h.pop();if(dt&&(t.e>ki||t.e<-ki))throw Error(wd+bt(t));return t}function Op(t,r){var n,a,s,i,o,l,c,u,d,h,m=t.constructor,j=m.precision;if(!t.s||!r.s)return r.s?r.s=-r.s:r=new m(t),dt?Je(r,j):r;if(c=t.d,h=r.d,a=r.e,u=t.e,c=c.slice(),o=u-a,o){for(d=o<0,d?(n=c,o=-o,l=h.length):(n=h,a=u,l=c.length),s=Math.max(Math.ceil(j/it),l)+2,o>s&&(o=s,n.length=1),n.reverse(),s=o;s--;)n.push(0);n.reverse()}else{for(s=c.length,l=h.length,d=s<l,d&&(l=s),s=0;s<l;s++)if(c[s]!=h[s]){d=c[s]<h[s];break}o=0}for(d&&(n=c,c=h,h=n,r.s=-r.s),l=c.length,s=h.length-l;s>0;--s)c[l++]=0;for(s=h.length;s>o;){if(c[--s]<h[s]){for(i=s;i&&c[--i]===0;)c[i]=Ot-1;--c[i],c[s]+=Ot}c[s]-=h[s]}for(;c[--l]===0;)c.pop();for(;c[0]===0;c.shift())--a;return c[0]?(r.d=c,r.e=a,dt?Je(r,j):r):new m(0)}function Mn(t,r,n){var a,s=bt(t),i=kr(t.d),o=i.length;return r?(n&&(a=n-o)>0?i=i.charAt(0)+"."+i.slice(1)+en(a):o>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(s<0?"e":"e+")+s):s<0?(i="0."+en(-s-1)+i,n&&(a=n-o)>0&&(i+=en(a))):s>=o?(i+=en(s+1-o),n&&(a=n-s-1)>0&&(i=i+"."+en(a))):((a=s+1)<o&&(i=i.slice(0,a)+"."+i.slice(a)),n&&(a=n-o)>0&&(s+1===o&&(i+="."),i+=en(a))),t.s<0?"-"+i:i}function Vu(t,r){if(t.length>r)return t.length=r,!0}function Cp(t){var r,n,a;function s(i){var o=this;if(!(o instanceof s))return new s(i);if(o.constructor=s,i instanceof s){o.s=i.s,o.e=i.e,o.d=(i=i.d)?i.slice():i;return}if(typeof i=="number"){if(i*0!==0)throw Error(Sn+i);if(i>0)o.s=1;else if(i<0)i=-i,o.s=-1;else{o.s=0,o.e=0,o.d=[0];return}if(i===~~i&&i<1e7){o.e=0,o.d=[i];return}return qu(o,i.toString())}else if(typeof i!="string")throw Error(Sn+i);if(i.charCodeAt(0)===45?(i=i.slice(1),o.s=-1):o.s=1,z1.test(i))qu(o,i);else throw Error(Sn+i)}if(s.prototype=je,s.ROUND_UP=0,s.ROUND_DOWN=1,s.ROUND_CEIL=2,s.ROUND_FLOOR=3,s.ROUND_HALF_UP=4,s.ROUND_HALF_DOWN=5,s.ROUND_HALF_EVEN=6,s.ROUND_HALF_CEIL=7,s.ROUND_HALF_FLOOR=8,s.clone=Cp,s.config=s.set=U1,t===void 0&&(t={}),t)for(a=["precision","rounding","toExpNeg","toExpPos","LN10"],r=0;r<a.length;)t.hasOwnProperty(n=a[r++])||(t[n]=this[n]);return s.config(t),s}function U1(t){if(!t||typeof t!="object")throw Error(vr+"Object expected");var r,n,a,s=["precision",1,Sa,"rounding",0,8,"toExpNeg",-1/0,0,"toExpPos",0,1/0];for(r=0;r<s.length;r+=3)if((a=t[n=s[r]])!==void 0)if(Oa(a)===a&&a>=s[r+1]&&a<=s[r+2])this[n]=a;else throw Error(Sn+n+": "+a);if((a=t[n="LN10"])!==void 0)if(a==Math.LN10)this[n]=new this(a);else throw Error(Sn+n+": "+a);return this}var Nd=Cp(B1);Yt=new Nd(1);const Ye=Nd;function q1(t){return G1(t)||K1(t)||W1(t)||V1()}function V1(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
71In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function W1(t,r){if(t){if(typeof t=="string")return rc(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return rc(t,r)}}function K1(t){if(typeof Symbol<"u"&&Symbol.iterator in Object(t))return Array.from(t)}function G1(t){if(Array.isArray(t))return rc(t)}function rc(t,r){(r==null||r>t.length)&&(r=t.length);for(var n=0,a=new Array(r);n<r;n++)a[n]=t[n];return a}var H1=function(r){return r},Ap={"@@functional/placeholder":!0},Pp=function(r){return r===Ap},Wu=function(r){return function n(){return arguments.length===0||arguments.length===1&&Pp(arguments.length<=0?void 0:arguments[0])?n:r.apply(void 0,arguments)}},X1=function t(r,n){return r===1?n:Wu(function(){for(var a=arguments.length,s=new Array(a),i=0;i<a;i++)s[i]=arguments[i];var o=s.filter(function(l){return l!==Ap}).length;return o>=r?n.apply(void 0,s):t(r-o,Wu(function(){for(var l=arguments.length,c=new Array(l),u=0;u<l;u++)c[u]=arguments[u];var d=s.map(function(h){return Pp(h)?c.shift():h});return n.apply(void 0,q1(d).concat(c))}))})},Io=function(r){return X1(r.length,r)},nc=function(r,n){for(var a=[],s=r;s<n;++s)a[s-r]=s;return a},Y1=Io(function(t,r){return Array.isArray(r)?r.map(t):Object.keys(r).map(function(n){return r[n]}).map(t)}),Q1=function(){for(var r=arguments.length,n=new Array(r),a=0;a<r;a++)n[a]=arguments[a];if(!n.length)return H1;var s=n.reverse(),i=s[0],o=s.slice(1);return function(){return o.reduce(function(l,c){return c(l)},i.apply(void 0,arguments))}},ac=function(r){return Array.isArray(r)?r.reverse():r.split("").reverse.join("")},kp=function(r){var n=null,a=null;return function(){for(var s=arguments.length,i=new Array(s),o=0;o<s;o++)i[o]=arguments[o];return n&&i.every(function(l,c){return l===n[c]})||(n=i,a=r.apply(void 0,i)),a}};function Z1(t){var r;return t===0?r=1:r=Math.floor(new Ye(t).abs().log(10).toNumber())+1,r}function J1(t,r,n){for(var a=new Ye(t),s=0,i=[];a.lt(r)&&s<1e5;)i.push(a.toNumber()),a=a.add(n),s++;return i}var eO=Io(function(t,r,n){var a=+t,s=+r;return a+n*(s-a)}),tO=Io(function(t,r,n){var a=r-+t;return a=a||1/0,(n-t)/a}),rO=Io(function(t,r,n){var a=r-+t;return a=a||1/0,Math.max(0,Math.min(1,(n-t)/a))});const Lo={rangeStep:J1,getDigitCount:Z1,interpolateNumber:eO,uninterpolateNumber:tO,uninterpolateTruncation:rO};function sc(t){return sO(t)||aO(t)||Ep(t)||nO()}function nO(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
72In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function aO(t){if(typeof Symbol<"u"&&Symbol.iterator in Object(t))return Array.from(t)}function sO(t){if(Array.isArray(t))return ic(t)}function ps(t,r){return lO(t)||oO(t,r)||Ep(t,r)||iO()}function iO(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
73In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ep(t,r){if(t){if(typeof t=="string")return ic(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ic(t,r)}}function ic(t,r){(r==null||r>t.length)&&(r=t.length);for(var n=0,a=new Array(r);n<r;n++)a[n]=t[n];return a}function oO(t,r){if(!(typeof Symbol>"u"||!(Symbol.iterator in Object(t)))){var n=[],a=!0,s=!1,i=void 0;try{for(var o=t[Symbol.iterator](),l;!(a=(l=o.next()).done)&&(n.push(l.value),!(r&&n.length===r));a=!0);}catch(c){s=!0,i=c}finally{try{!a&&o.return!=null&&o.return()}finally{if(s)throw i}}return n}}function lO(t){if(Array.isArray(t))return t}function Tp(t){var r=ps(t,2),n=r[0],a=r[1],s=n,i=a;return n>a&&(s=a,i=n),[s,i]}function $p(t,r,n){if(t.lte(0))return new Ye(0);var a=Lo.getDigitCount(t.toNumber()),s=new Ye(10).pow(a),i=t.div(s),o=a!==1?.05:.1,l=new Ye(Math.ceil(i.div(o).toNumber())).add(n).mul(o),c=l.mul(s);return r?c:new Ye(Math.ceil(c))}function cO(t,r,n){var a=1,s=new Ye(t);if(!s.isint()&&n){var i=Math.abs(t);i<1?(a=new Ye(10).pow(Lo.getDigitCount(t)-1),s=new Ye(Math.floor(s.div(a).toNumber())).mul(a)):i>1&&(s=new Ye(Math.floor(t)))}else t===0?s=new Ye(Math.floor((r-1)/2)):n||(s=new Ye(Math.floor(t)));var o=Math.floor((r-1)/2),l=Q1(Y1(function(c){return s.add(new Ye(c-o).mul(a)).toNumber()}),nc);return l(0,r)}function Dp(t,r,n,a){var s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((r-t)/(n-1)))return{step:new Ye(0),tickMin:new Ye(0),tickMax:new Ye(0)};var i=$p(new Ye(r).sub(t).div(n-1),a,s),o;t<=0&&r>=0?o=new Ye(0):(o=new Ye(t).add(r).div(2),o=o.sub(new Ye(o).mod(i)));var l=Math.ceil(o.sub(t).div(i).toNumber()),c=Math.ceil(new Ye(r).sub(o).div(i).toNumber()),u=l+c+1;return u>n?Dp(t,r,n,a,s+1):(u<n&&(c=r>0?c+(n-u):c,l=r>0?l:l+(n-u)),{step:i,tickMin:o.sub(new Ye(l).mul(i)),tickMax:o.add(new Ye(c).mul(i))})}function dO(t){var r=ps(t,2),n=r[0],a=r[1],s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=Math.max(s,2),l=Tp([n,a]),c=ps(l,2),u=c[0],d=c[1];if(u===-1/0||d===1/0){var h=d===1/0?[u].concat(sc(nc(0,s-1).map(function(){return 1/0}))):[].concat(sc(nc(0,s-1).map(function(){return-1/0})),[d]);return n>a?ac(h):h}if(u===d)return cO(u,s,i);var m=Dp(u,d,o,i),j=m.step,w=m.tickMin,x=m.tickMax,v=Lo.rangeStep(w,x.add(new Ye(.1).mul(j)),j);return n>a?ac(v):v}function uO(t,r){var n=ps(t,2),a=n[0],s=n[1],i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=Tp([a,s]),l=ps(o,2),c=l[0],u=l[1];if(c===-1/0||u===1/0)return[a,s];if(c===u)return[c];var d=Math.max(r,2),h=$p(new Ye(u).sub(c).div(d-1),i,0),m=[].concat(sc(Lo.rangeStep(new Ye(c),new Ye(u).sub(new Ye(.99).mul(h)),h)),[u]);return a>s?ac(m):m}var hO=kp(dO),mO=kp(uO),fO="Invariant failed";function In(t,r){throw new Error(fO)}var pO=["offset","layout","width","dataKey","data","dataPointFormatter","xAxis","yAxis"];function ra(t){"@babel/helpers - typeof";return ra=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},ra(t)}function Ei(){return Ei=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},Ei.apply(this,arguments)}function xO(t,r){return jO(t)||yO(t,r)||gO(t,r)||vO()}function vO(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
74In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function gO(t,r){if(t){if(typeof t=="string")return Ku(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ku(t,r)}}function Ku(t,r){(r==null||r>t.length)&&(r=t.length);for(var n=0,a=new Array(r);n<r;n++)a[n]=t[n];return a}function yO(t,r){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var a,s,i,o,l=[],c=!0,u=!1;try{if(i=(n=n.call(t)).next,r!==0)for(;!(c=(a=i.call(n)).done)&&(l.push(a.value),l.length!==r);c=!0);}catch(d){u=!0,s=d}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw s}}return l}}function jO(t){if(Array.isArray(t))return t}function bO(t,r){if(t==null)return{};var n=wO(t,r),a,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)a=i[s],!(r.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(t,a)&&(n[a]=t[a])}return n}function wO(t,r){if(t==null)return{};var n={};for(var a in t)if(Object.prototype.hasOwnProperty.call(t,a)){if(r.indexOf(a)>=0)continue;n[a]=t[a]}return n}function NO(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function _O(t,r){for(var n=0;n<r.length;n++){var a=r[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,Lp(a.key),a)}}function SO(t,r,n){return r&&_O(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function OO(t,r,n){return r=Ti(r),CO(t,Mp()?Reflect.construct(r,n||[],Ti(t).constructor):r.apply(t,n))}function CO(t,r){if(r&&(ra(r)==="object"||typeof r=="function"))return r;if(r!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return AO(t)}function AO(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Mp(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Mp=function(){return!!t})()}function Ti(t){return Ti=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Ti(t)}function PO(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&oc(t,r)}function oc(t,r){return oc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,s){return a.__proto__=s,a},oc(t,r)}function Ip(t,r,n){return r=Lp(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function Lp(t){var r=kO(t,"string");return ra(r)=="symbol"?r:r+""}function kO(t,r){if(ra(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(ra(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}var Vs=function(t){function r(){return NO(this,r),OO(this,r,arguments)}return PO(r,t),SO(r,[{key:"render",value:function(){var a=this.props,s=a.offset,i=a.layout,o=a.width,l=a.dataKey,c=a.data,u=a.dataPointFormatter,d=a.xAxis,h=a.yAxis,m=bO(a,pO),j=Oe(m,!1);this.props.direction==="x"&&d.type!=="number"&&In();var w=c.map(function(x){var v=u(x,l),y=v.x,f=v.y,b=v.value,p=v.errorVal;if(!p)return null;var g=[],N,S;if(Array.isArray(p)){var O=xO(p,2);N=O[0],S=O[1]}else N=S=p;if(i==="vertical"){var C=d.scale,P=f+s,$=P+o,A=P-o,I=C(b-N),D=C(b+S);g.push({x1:D,y1:$,x2:D,y2:A}),g.push({x1:I,y1:P,x2:D,y2:P}),g.push({x1:I,y1:$,x2:I,y2:A})}else if(i==="horizontal"){var q=h.scale,F=y+s,K=F-o,M=F+o,E=q(b-N),Q=q(b+S);g.push({x1:K,y1:Q,x2:M,y2:Q}),g.push({x1:F,y1:E,x2:F,y2:Q}),g.push({x1:K,y1:E,x2:M,y2:E})}return L.createElement(Ke,Ei({className:"recharts-errorBar",key:"bar-".concat(g.map(function(H){return"".concat(H.x1,"-").concat(H.x2,"-").concat(H.y1,"-").concat(H.y2)}))},j),g.map(function(H){return L.createElement("line",Ei({},H,{key:"line-".concat(H.x1,"-").concat(H.x2,"-").concat(H.y1,"-").concat(H.y2)}))}))});return L.createElement(Ke,{className:"recharts-errorBars"},w)}}])}(L.Component);Ip(Vs,"defaultProps",{stroke:"black",strokeWidth:1.5,width:5,offset:0,layout:"horizontal"});Ip(Vs,"displayName","ErrorBar");function xs(t){"@babel/helpers - typeof";return xs=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},xs(t)}function Gu(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function mn(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?Gu(Object(n),!0).forEach(function(a){EO(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Gu(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function EO(t,r,n){return r=TO(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function TO(t){var r=$O(t,"string");return xs(r)=="symbol"?r:r+""}function $O(t,r){if(xs(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(xs(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}var Rp=function(r){var n=r.children,a=r.formattedGraphicalItems,s=r.legendWidth,i=r.legendContent,o=Gt(n,an);if(!o)return null;var l=an.defaultProps,c=l!==void 0?mn(mn({},l),o.props):{},u;return o.props&&o.props.payload?u=o.props&&o.props.payload:i==="children"?u=(a||[]).reduce(function(d,h){var m=h.item,j=h.props,w=j.sectors||j.data||[];return d.concat(w.map(function(x){return{type:o.props.iconType||m.props.legendType,value:x.name,color:x.fill,payload:x}}))},[]):u=(a||[]).map(function(d){var h=d.item,m=h.type.defaultProps,j=m!==void 0?mn(mn({},m),h.props):{},w=j.dataKey,x=j.name,v=j.legendType,y=j.hide;return{inactive:y,dataKey:w,type:c.iconType||v||"square",color:_d(h),value:x||w,payload:j}}),mn(mn(mn({},c),an.getWithHeight(o,s)),{},{payload:u,item:o})};function vs(t){"@babel/helpers - typeof";return vs=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},vs(t)}function Hu(t){return LO(t)||IO(t)||MO(t)||DO()}function DO(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
75In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function MO(t,r){if(t){if(typeof t=="string")return lc(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return lc(t,r)}}function IO(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function LO(t){if(Array.isArray(t))return lc(t)}function lc(t,r){(r==null||r>t.length)&&(r=t.length);for(var n=0,a=new Array(r);n<r;n++)a[n]=t[n];return a}function Xu(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function vt(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?Xu(Object(n),!0).forEach(function(a){Gn(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Xu(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function Gn(t,r,n){return r=RO(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function RO(t){var r=FO(t,"string");return vs(r)=="symbol"?r:r+""}function FO(t,r){if(vs(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(vs(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function Nt(t,r,n){return Ie(t)||Ie(r)?n:_t(r)?Jt(t,r,n):$e(r)?r(t):n}function Ha(t,r,n,a){var s=F1(t,function(l){return Nt(l,r)});if(n==="number"){var i=s.filter(function(l){return me(l)||parseFloat(l)});return i.length?[Mo(i),Do(i)]:[1/0,-1/0]}var o=a?s.filter(function(l){return!Ie(l)}):s;return o.map(function(l){return _t(l)||l instanceof Date?l:""})}var BO=function(r){var n,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],s=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0,o=-1,l=(n=a==null?void 0:a.length)!==null&&n!==void 0?n:0;if(l<=1)return 0;if(i&&i.axisType==="angleAxis"&&Math.abs(Math.abs(i.range[1]-i.range[0])-360)<=1e-6)for(var c=i.range,u=0;u<l;u++){var d=u>0?s[u-1].coordinate:s[l-1].coordinate,h=s[u].coordinate,m=u>=l-1?s[0].coordinate:s[u+1].coordinate,j=void 0;if(Rt(h-d)!==Rt(m-h)){var w=[];if(Rt(m-h)===Rt(c[1]-c[0])){j=m;var x=h+c[1]-c[0];w[0]=Math.min(x,(x+d)/2),w[1]=Math.max(x,(x+d)/2)}else{j=d;var v=m+c[1]-c[0];w[0]=Math.min(h,(v+h)/2),w[1]=Math.max(h,(v+h)/2)}var y=[Math.min(h,(j+h)/2),Math.max(h,(j+h)/2)];if(r>y[0]&&r<=y[1]||r>=w[0]&&r<=w[1]){o=s[u].index;break}}else{var f=Math.min(d,m),b=Math.max(d,m);if(r>(f+h)/2&&r<=(b+h)/2){o=s[u].index;break}}}else for(var p=0;p<l;p++)if(p===0&&r<=(a[p].coordinate+a[p+1].coordinate)/2||p>0&&p<l-1&&r>(a[p].coordinate+a[p-1].coordinate)/2&&r<=(a[p].coordinate+a[p+1].coordinate)/2||p===l-1&&r>(a[p].coordinate+a[p-1].coordinate)/2){o=a[p].index;break}return o},_d=function(r){var n,a=r,s=a.type.displayName,i=(n=r.type)!==null&&n!==void 0&&n.defaultProps?vt(vt({},r.type.defaultProps),r.props):r.props,o=i.stroke,l=i.fill,c;switch(s){case"Line":c=o;break;case"Area":case"Radar":c=o&&o!=="none"?o:l;break;default:c=l;break}return c},zO=function(r){var n=r.barSize,a=r.totalSize,s=r.stackGroups,i=s===void 0?{}:s;if(!i)return{};for(var o={},l=Object.keys(i),c=0,u=l.length;c<u;c++)for(var d=i[l[c]].stackGroups,h=Object.keys(d),m=0,j=h.length;m<j;m++){var w=d[h[m]],x=w.items,v=w.cateAxisId,y=x.filter(function(S){return Hr(S.type).indexOf("Bar")>=0});if(y&&y.length){var f=y[0].type.defaultProps,b=f!==void 0?vt(vt({},f),y[0].props):y[0].props,p=b.barSize,g=b[v];o[g]||(o[g]=[]);var N=Ie(p)?n:p;o[g].push({item:y[0],stackList:y.slice(1),barSize:Ie(N)?void 0:Ft(N,a,0)})}}return o},UO=function(r){var n=r.barGap,a=r.barCategoryGap,s=r.bandSize,i=r.sizeList,o=i===void 0?[]:i,l=r.maxBarSize,c=o.length;if(c<1)return null;var u=Ft(n,s,0,!0),d,h=[];if(o[0].barSize===+o[0].barSize){var m=!1,j=s/c,w=o.reduce(function(p,g){return p+g.barSize||0},0);w+=(c-1)*u,w>=s&&(w-=(c-1)*u,u=0),w>=s&&j>0&&(m=!0,j*=.9,w=c*j);var x=(s-w)/2>>0,v={offset:x-u,size:0};d=o.reduce(function(p,g){var N={item:g.item,position:{offset:v.offset+v.size+u,size:m?j:g.barSize}},S=[].concat(Hu(p),[N]);return v=S[S.length-1].position,g.stackList&&g.stackList.length&&g.stackList.forEach(function(O){S.push({item:O,position:v})}),S},h)}else{var y=Ft(a,s,0,!0);s-2*y-(c-1)*u<=0&&(u=0);var f=(s-2*y-(c-1)*u)/c;f>1&&(f>>=0);var b=l===+l?Math.min(f,l):f;d=o.reduce(function(p,g,N){var S=[].concat(Hu(p),[{item:g.item,position:{offset:y+(f+u)*N+(f-b)/2,size:b}}]);return g.stackList&&g.stackList.length&&g.stackList.forEach(function(O){S.push({item:O,position:S[S.length-1].position})}),S},h)}return d},qO=function(r,n,a,s){var i=a.children,o=a.width,l=a.margin,c=o-(l.left||0)-(l.right||0),u=Rp({children:i,legendWidth:c});if(u){var d=s||{},h=d.width,m=d.height,j=u.align,w=u.verticalAlign,x=u.layout;if((x==="vertical"||x==="horizontal"&&w==="middle")&&j!=="center"&&me(r[j]))return vt(vt({},r),{},Gn({},j,r[j]+(h||0)));if((x==="horizontal"||x==="vertical"&&j==="center")&&w!=="middle"&&me(r[w]))return vt(vt({},r),{},Gn({},w,r[w]+(m||0)))}return r},VO=function(r,n,a){return Ie(n)?!0:r==="horizontal"?n==="yAxis":r==="vertical"||a==="x"?n==="xAxis":a==="y"?n==="yAxis":!0},Fp=function(r,n,a,s,i){var o=n.props.children,l=er(o,Vs).filter(function(u){return VO(s,i,u.props.direction)});if(l&&l.length){var c=l.map(function(u){return u.props.dataKey});return r.reduce(function(u,d){var h=Nt(d,a);if(Ie(h))return u;var m=Array.isArray(h)?[Mo(h),Do(h)]:[h,h],j=c.reduce(function(w,x){var v=Nt(d,x,0),y=m[0]-Math.abs(Array.isArray(v)?v[0]:v),f=m[1]+Math.abs(Array.isArray(v)?v[1]:v);return[Math.min(y,w[0]),Math.max(f,w[1])]},[1/0,-1/0]);return[Math.min(j[0],u[0]),Math.max(j[1],u[1])]},[1/0,-1/0])}return null},WO=function(r,n,a,s,i){var o=n.map(function(l){return Fp(r,l,a,i,s)}).filter(function(l){return!Ie(l)});return o&&o.length?o.reduce(function(l,c){return[Math.min(l[0],c[0]),Math.max(l[1],c[1])]},[1/0,-1/0]):null},Bp=function(r,n,a,s,i){var o=n.map(function(c){var u=c.props.dataKey;return a==="number"&&u&&Fp(r,c,u,s)||Ha(r,u,a,i)});if(a==="number")return o.reduce(function(c,u){return[Math.min(c[0],u[0]),Math.max(c[1],u[1])]},[1/0,-1/0]);var l={};return o.reduce(function(c,u){for(var d=0,h=u.length;d<h;d++)l[u[d]]||(l[u[d]]=!0,c.push(u[d]));return c},[])},zp=function(r,n){return r==="horizontal"&&n==="xAxis"||r==="vertical"&&n==="yAxis"||r==="centric"&&n==="angleAxis"||r==="radial"&&n==="radiusAxis"},Up=function(r,n,a,s){if(s)return r.map(function(c){return c.coordinate});var i,o,l=r.map(function(c){return c.coordinate===n&&(i=!0),c.coordinate===a&&(o=!0),c.coordinate});return i||l.push(n),o||l.push(a),l},Gr=function(r,n,a){if(!r)return null;var s=r.scale,i=r.duplicateDomain,o=r.type,l=r.range,c=r.realScaleType==="scaleBand"?s.bandwidth()/2:2,u=(n||a)&&o==="category"&&s.bandwidth?s.bandwidth()/c:0;if(u=r.axisType==="angleAxis"&&(l==null?void 0:l.length)>=2?Rt(l[0]-l[1])*2*u:u,n&&(r.ticks||r.niceTicks)){var d=(r.ticks||r.niceTicks).map(function(h){var m=i?i.indexOf(h):h;return{coordinate:s(m)+u,value:h,offset:u}});return d.filter(function(h){return!qs(h.coordinate)})}return r.isCategorical&&r.categoricalDomain?r.categoricalDomain.map(function(h,m){return{coordinate:s(h)+u,value:h,index:m,offset:u}}):s.ticks&&!a?s.ticks(r.tickCount).map(function(h){return{coordinate:s(h)+u,value:h,offset:u}}):s.domain().map(function(h,m){return{coordinate:s(h)+u,value:i?i[h]:h,index:m,offset:u}})},hl=new WeakMap,ri=function(r,n){if(typeof n!="function")return r;hl.has(r)||hl.set(r,new WeakMap);var a=hl.get(r);if(a.has(n))return a.get(n);var s=function(){r.apply(void 0,arguments),n.apply(void 0,arguments)};return a.set(n,s),s},qp=function(r,n,a){var s=r.scale,i=r.type,o=r.layout,l=r.axisType;if(s==="auto")return o==="radial"&&l==="radiusAxis"?{scale:Al(),realScaleType:"band"}:o==="radial"&&l==="angleAxis"?{scale:Cl(),realScaleType:"linear"}:i==="category"&&n&&(n.indexOf("LineChart")>=0||n.indexOf("AreaChart")>=0||n.indexOf("ComposedChart")>=0&&!a)?{scale:Ia(),realScaleType:"point"}:i==="category"?{scale:Al(),realScaleType:"band"}:{scale:Cl(),realScaleType:"linear"};if(Us(s)){var c="scale".concat(Co(s));return{scale:(Uu[c]||Ia)(),realScaleType:Uu[c]?c:"point"}}return $e(s)?{scale:s}:{scale:Ia(),realScaleType:"point"}},Yu=1e-4,Vp=function(r){var n=r.domain();if(!(!n||n.length<=2)){var a=n.length,s=r.range(),i=Math.min(s[0],s[1])-Yu,o=Math.max(s[0],s[1])+Yu,l=r(n[0]),c=r(n[a-1]);(l<i||l>o||c<i||c>o)&&r.domain([n[0],n[a-1]])}},KO=function(r,n){if(!r)return null;for(var a=0,s=r.length;a<s;a++)if(r[a].item===n)return r[a].position;return null},GO=function(r,n){if(!n||n.length!==2||!me(n[0])||!me(n[1]))return r;var a=Math.min(n[0],n[1]),s=Math.max(n[0],n[1]),i=[r[0],r[1]];return(!me(r[0])||r[0]<a)&&(i[0]=a),(!me(r[1])||r[1]>s)&&(i[1]=s),i[0]>s&&(i[0]=s),i[1]<a&&(i[1]=a),i},HO=function(r){var n=r.length;if(!(n<=0))for(var a=0,s=r[0].length;a<s;++a)for(var i=0,o=0,l=0;l<n;++l){var c=qs(r[l][a][1])?r[l][a][0]:r[l][a][1];c>=0?(r[l][a][0]=i,r[l][a][1]=i+c,i=r[l][a][1]):(r[l][a][0]=o,r[l][a][1]=o+c,o=r[l][a][1])}},XO=function(r){var n=r.length;if(!(n<=0))for(var a=0,s=r[0].length;a<s;++a)for(var i=0,o=0;o<n;++o){var l=qs(r[o][a][1])?r[o][a][0]:r[o][a][1];l>=0?(r[o][a][0]=i,r[o][a][1]=i+l,i=r[o][a][1]):(r[o][a][0]=0,r[o][a][1]=0)}},YO={sign:HO,expand:Zb,none:Qn,silhouette:Jb,wiggle:e0,positive:XO},QO=function(r,n,a){var s=n.map(function(l){return l.props.dataKey}),i=YO[a],o=Qb().keys(s).value(function(l,c){return+Nt(l,c,0)}).order(Wl).offset(i);return o(r)},ZO=function(r,n,a,s,i,o){if(!r)return null;var l=o?n.reverse():n,c={},u=l.reduce(function(h,m){var j,w=(j=m.type)!==null&&j!==void 0&&j.defaultProps?vt(vt({},m.type.defaultProps),m.props):m.props,x=w.stackId,v=w.hide;if(v)return h;var y=w[a],f=h[y]||{hasStack:!1,stackGroups:{}};if(_t(x)){var b=f.stackGroups[x]||{numericAxisId:a,cateAxisId:s,items:[]};b.items.push(m),f.hasStack=!0,f.stackGroups[x]=b}else f.stackGroups[Na("_stackId_")]={numericAxisId:a,cateAxisId:s,items:[m]};return vt(vt({},h),{},Gn({},y,f))},c),d={};return Object.keys(u).reduce(function(h,m){var j=u[m];if(j.hasStack){var w={};j.stackGroups=Object.keys(j.stackGroups).reduce(function(x,v){var y=j.stackGroups[v];return vt(vt({},x),{},Gn({},v,{numericAxisId:a,cateAxisId:s,items:y.items,stackedData:QO(r,y.items,i)}))},w)}return vt(vt({},h),{},Gn({},m,j))},d)},Wp=function(r,n){var a=n.realScaleType,s=n.type,i=n.tickCount,o=n.originalDomain,l=n.allowDecimals,c=a||n.scale;if(c!=="auto"&&c!=="linear")return null;if(i&&s==="number"&&o&&(o[0]==="auto"||o[1]==="auto")){var u=r.domain();if(!u.length)return null;var d=hO(u,i,l);return r.domain([Mo(d),Do(d)]),{niceTicks:d}}if(i&&s==="number"){var h=r.domain(),m=mO(h,i,l);return{niceTicks:m}}return null};function Qu(t){var r=t.axis,n=t.ticks,a=t.bandSize,s=t.entry,i=t.index,o=t.dataKey;if(r.type==="category"){if(!r.allowDuplicatedCategory&&r.dataKey&&!Ie(s[r.dataKey])){var l=gi(n,"value",s[r.dataKey]);if(l)return l.coordinate+a/2}return n[i]?n[i].coordinate+a/2:null}var c=Nt(s,Ie(o)?r.dataKey:o);return Ie(c)?null:r.scale(c)}var Zu=function(r){var n=r.axis,a=r.ticks,s=r.offset,i=r.bandSize,o=r.entry,l=r.index;if(n.type==="category")return a[l]?a[l].coordinate+s:null;var c=Nt(o,n.dataKey,n.domain[l]);return Ie(c)?null:n.scale(c)-i/2+s},JO=function(r){var n=r.numericAxis,a=n.scale.domain();if(n.type==="number"){var s=Math.min(a[0],a[1]),i=Math.max(a[0],a[1]);return s<=0&&i>=0?0:i<0?i:s}return a[0]},eC=function(r,n){var a,s=(a=r.type)!==null&&a!==void 0&&a.defaultProps?vt(vt({},r.type.defaultProps),r.props):r.props,i=s.stackId;if(_t(i)){var o=n[i];if(o){var l=o.items.indexOf(r);return l>=0?o.stackedData[l]:null}}return null},tC=function(r){return r.reduce(function(n,a){return[Mo(a.concat([n[0]]).filter(me)),Do(a.concat([n[1]]).filter(me))]},[1/0,-1/0])},Kp=function(r,n,a){return Object.keys(r).reduce(function(s,i){var o=r[i],l=o.stackedData,c=l.reduce(function(u,d){var h=tC(d.slice(n,a+1));return[Math.min(u[0],h[0]),Math.max(u[1],h[1])]},[1/0,-1/0]);return[Math.min(c[0],s[0]),Math.max(c[1],s[1])]},[1/0,-1/0]).map(function(s){return s===1/0||s===-1/0?0:s})},Ju=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,eh=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,cc=function(r,n,a){if($e(r))return r(n,a);if(!Array.isArray(r))return n;var s=[];if(me(r[0]))s[0]=a?r[0]:Math.min(r[0],n[0]);else if(Ju.test(r[0])){var i=+Ju.exec(r[0])[1];s[0]=n[0]-i}else $e(r[0])?s[0]=r[0](n[0]):s[0]=n[0];if(me(r[1]))s[1]=a?r[1]:Math.max(r[1],n[1]);else if(eh.test(r[1])){var o=+eh.exec(r[1])[1];s[1]=n[1]+o}else $e(r[1])?s[1]=r[1](n[1]):s[1]=n[1];return s},$i=function(r,n,a){if(r&&r.scale&&r.scale.bandwidth){var s=r.scale.bandwidth();if(!a||s>0)return s}if(r&&n&&n.length>=2){for(var i=jd(n,function(h){return h.coordinate}),o=1/0,l=1,c=i.length;l<c;l++){var u=i[l],d=i[l-1];o=Math.min((u.coordinate||0)-(d.coordinate||0),o)}return o===1/0?0:o}return a?void 0:0},th=function(r,n,a){return!r||!r.length||zs(r,Jt(a,"type.defaultProps.domain"))?n:r},Gp=function(r,n){var a=r.type.defaultProps?vt(vt({},r.type.defaultProps),r.props):r.props,s=a.dataKey,i=a.name,o=a.unit,l=a.formatter,c=a.tooltipType,u=a.chartType,d=a.hide;return vt(vt({},Oe(r,!1)),{},{dataKey:s,unit:o,formatter:l,name:i||s,color:_d(r),value:Nt(n,s),type:c,payload:n,chartType:u,hide:d})};function gs(t){"@babel/helpers - typeof";return gs=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},gs(t)}function rh(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function Wr(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?rh(Object(n),!0).forEach(function(a){Hp(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):rh(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function Hp(t,r,n){return r=rC(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function rC(t){var r=nC(t,"string");return gs(r)=="symbol"?r:r+""}function nC(t,r){if(gs(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(gs(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function aC(t,r){return lC(t)||oC(t,r)||iC(t,r)||sC()}function sC(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
76In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function iC(t,r){if(t){if(typeof t=="string")return nh(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return nh(t,r)}}function nh(t,r){(r==null||r>t.length)&&(r=t.length);for(var n=0,a=new Array(r);n<r;n++)a[n]=t[n];return a}function oC(t,r){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var a,s,i,o,l=[],c=!0,u=!1;try{if(i=(n=n.call(t)).next,r!==0)for(;!(c=(a=i.call(n)).done)&&(l.push(a.value),l.length!==r);c=!0);}catch(d){u=!0,s=d}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw s}}return l}}function lC(t){if(Array.isArray(t))return t}var Di=Math.PI/180,cC=function(r){return r*180/Math.PI},rt=function(r,n,a,s){return{x:r+Math.cos(-Di*s)*a,y:n+Math.sin(-Di*s)*a}},Xp=function(r,n){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{top:0,right:0,bottom:0,left:0};return Math.min(Math.abs(r-(a.left||0)-(a.right||0)),Math.abs(n-(a.top||0)-(a.bottom||0)))/2},dC=function(r,n,a,s,i){var o=r.width,l=r.height,c=r.startAngle,u=r.endAngle,d=Ft(r.cx,o,o/2),h=Ft(r.cy,l,l/2),m=Xp(o,l,a),j=Ft(r.innerRadius,m,0),w=Ft(r.outerRadius,m,m*.8),x=Object.keys(n);return x.reduce(function(v,y){var f=n[y],b=f.domain,p=f.reversed,g;if(Ie(f.range))s==="angleAxis"?g=[c,u]:s==="radiusAxis"&&(g=[j,w]),p&&(g=[g[1],g[0]]);else{g=f.range;var N=g,S=aC(N,2);c=S[0],u=S[1]}var O=qp(f,i),C=O.realScaleType,P=O.scale;P.domain(b).range(g),Vp(P);var $=Wp(P,Wr(Wr({},f),{},{realScaleType:C})),A=Wr(Wr(Wr({},f),$),{},{range:g,radius:w,realScaleType:C,scale:P,cx:d,cy:h,innerRadius:j,outerRadius:w,startAngle:c,endAngle:u});return Wr(Wr({},v),{},Hp({},y,A))},{})},uC=function(r,n){var a=r.x,s=r.y,i=n.x,o=n.y;return Math.sqrt(Math.pow(a-i,2)+Math.pow(s-o,2))},hC=function(r,n){var a=r.x,s=r.y,i=n.cx,o=n.cy,l=uC({x:a,y:s},{x:i,y:o});if(l<=0)return{radius:l};var c=(a-i)/l,u=Math.acos(c);return s>o&&(u=2*Math.PI-u),{radius:l,angle:cC(u),angleInRadian:u}},mC=function(r){var n=r.startAngle,a=r.endAngle,s=Math.floor(n/360),i=Math.floor(a/360),o=Math.min(s,i);return{startAngle:n-o*360,endAngle:a-o*360}},fC=function(r,n){var a=n.startAngle,s=n.endAngle,i=Math.floor(a/360),o=Math.floor(s/360),l=Math.min(i,o);return r+l*360},ah=function(r,n){var a=r.x,s=r.y,i=hC({x:a,y:s},n),o=i.radius,l=i.angle,c=n.innerRadius,u=n.outerRadius;if(o<c||o>u)return!1;if(o===0)return!0;var d=mC(n),h=d.startAngle,m=d.endAngle,j=l,w;if(h<=m){for(;j>m;)j-=360;for(;j<h;)j+=360;w=j>=h&&j<=m}else{for(;j>h;)j-=360;for(;j<m;)j+=360;w=j>=m&&j<=h}return w?Wr(Wr({},n),{},{radius:o,angle:fC(j,n)}):null},Yp=function(r){return!_.isValidElement(r)&&!$e(r)&&typeof r!="boolean"?r.className:""};function ys(t){"@babel/helpers - typeof";return ys=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},ys(t)}var pC=["offset"];function xC(t){return jC(t)||yC(t)||gC(t)||vC()}function vC(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
77In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function gC(t,r){if(t){if(typeof t=="string")return dc(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return dc(t,r)}}function yC(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function jC(t){if(Array.isArray(t))return dc(t)}function dc(t,r){(r==null||r>t.length)&&(r=t.length);for(var n=0,a=new Array(r);n<r;n++)a[n]=t[n];return a}function bC(t,r){if(t==null)return{};var n=wC(t,r),a,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)a=i[s],!(r.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(t,a)&&(n[a]=t[a])}return n}function wC(t,r){if(t==null)return{};var n={};for(var a in t)if(Object.prototype.hasOwnProperty.call(t,a)){if(r.indexOf(a)>=0)continue;n[a]=t[a]}return n}function sh(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function wt(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?sh(Object(n),!0).forEach(function(a){NC(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):sh(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function NC(t,r,n){return r=_C(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function _C(t){var r=SC(t,"string");return ys(r)=="symbol"?r:r+""}function SC(t,r){if(ys(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(ys(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function js(){return js=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},js.apply(this,arguments)}var OC=function(r){var n=r.value,a=r.formatter,s=Ie(r.children)?n:r.children;return $e(a)?a(s):s},CC=function(r,n){var a=Rt(n-r),s=Math.min(Math.abs(n-r),360);return a*s},AC=function(r,n,a){var s=r.position,i=r.viewBox,o=r.offset,l=r.className,c=i,u=c.cx,d=c.cy,h=c.innerRadius,m=c.outerRadius,j=c.startAngle,w=c.endAngle,x=c.clockWise,v=(h+m)/2,y=CC(j,w),f=y>=0?1:-1,b,p;s==="insideStart"?(b=j+f*o,p=x):s==="insideEnd"?(b=w-f*o,p=!x):s==="end"&&(b=w+f*o,p=x),p=y<=0?p:!p;var g=rt(u,d,v,b),N=rt(u,d,v,b+(p?1:-1)*359),S="M".concat(g.x,",").concat(g.y,`
78    A`).concat(v,",").concat(v,",0,1,").concat(p?0:1,`,
79    `).concat(N.x,",").concat(N.y),O=Ie(r.id)?Na("recharts-radial-line-"):r.id;return L.createElement("text",js({},a,{dominantBaseline:"central",className:Le("recharts-radial-bar-label",l)}),L.createElement("defs",null,L.createElement("path",{id:O,d:S})),L.createElement("textPath",{xlinkHref:"#".concat(O)},n))},PC=function(r){var n=r.viewBox,a=r.offset,s=r.position,i=n,o=i.cx,l=i.cy,c=i.innerRadius,u=i.outerRadius,d=i.startAngle,h=i.endAngle,m=(d+h)/2;if(s==="outside"){var j=rt(o,l,u+a,m),w=j.x,x=j.y;return{x:w,y:x,textAnchor:w>=o?"start":"end",verticalAnchor:"middle"}}if(s==="center")return{x:o,y:l,textAnchor:"middle",verticalAnchor:"middle"};if(s==="centerTop")return{x:o,y:l,textAnchor:"middle",verticalAnchor:"start"};if(s==="centerBottom")return{x:o,y:l,textAnchor:"middle",verticalAnchor:"end"};var v=(c+u)/2,y=rt(o,l,v,m),f=y.x,b=y.y;return{x:f,y:b,textAnchor:"middle",verticalAnchor:"middle"}},kC=function(r){var n=r.viewBox,a=r.parentViewBox,s=r.offset,i=r.position,o=n,l=o.x,c=o.y,u=o.width,d=o.height,h=d>=0?1:-1,m=h*s,j=h>0?"end":"start",w=h>0?"start":"end",x=u>=0?1:-1,v=x*s,y=x>0?"end":"start",f=x>0?"start":"end";if(i==="top"){var b={x:l+u/2,y:c-h*s,textAnchor:"middle",verticalAnchor:j};return wt(wt({},b),a?{height:Math.max(c-a.y,0),width:u}:{})}if(i==="bottom"){var p={x:l+u/2,y:c+d+m,textAnchor:"middle",verticalAnchor:w};return wt(wt({},p),a?{height:Math.max(a.y+a.height-(c+d),0),width:u}:{})}if(i==="left"){var g={x:l-v,y:c+d/2,textAnchor:y,verticalAnchor:"middle"};return wt(wt({},g),a?{width:Math.max(g.x-a.x,0),height:d}:{})}if(i==="right"){var N={x:l+u+v,y:c+d/2,textAnchor:f,verticalAnchor:"middle"};return wt(wt({},N),a?{width:Math.max(a.x+a.width-N.x,0),height:d}:{})}var S=a?{width:u,height:d}:{};return i==="insideLeft"?wt({x:l+v,y:c+d/2,textAnchor:f,verticalAnchor:"middle"},S):i==="insideRight"?wt({x:l+u-v,y:c+d/2,textAnchor:y,verticalAnchor:"middle"},S):i==="insideTop"?wt({x:l+u/2,y:c+m,textAnchor:"middle",verticalAnchor:w},S):i==="insideBottom"?wt({x:l+u/2,y:c+d-m,textAnchor:"middle",verticalAnchor:j},S):i==="insideTopLeft"?wt({x:l+v,y:c+m,textAnchor:f,verticalAnchor:w},S):i==="insideTopRight"?wt({x:l+u-v,y:c+m,textAnchor:y,verticalAnchor:w},S):i==="insideBottomLeft"?wt({x:l+v,y:c+d-m,textAnchor:f,verticalAnchor:j},S):i==="insideBottomRight"?wt({x:l+u-v,y:c+d-m,textAnchor:y,verticalAnchor:j},S):ba(i)&&(me(i.x)||bn(i.x))&&(me(i.y)||bn(i.y))?wt({x:l+Ft(i.x,u),y:c+Ft(i.y,d),textAnchor:"end",verticalAnchor:"end"},S):wt({x:l+u/2,y:c+d/2,textAnchor:"middle",verticalAnchor:"middle"},S)},EC=function(r){return"cx"in r&&me(r.cx)};function Ct(t){var r=t.offset,n=r===void 0?5:r,a=bC(t,pC),s=wt({offset:n},a),i=s.viewBox,o=s.position,l=s.value,c=s.children,u=s.content,d=s.className,h=d===void 0?"":d,m=s.textBreakAll;if(!i||Ie(l)&&Ie(c)&&!_.isValidElement(u)&&!$e(u))return null;if(_.isValidElement(u))return _.cloneElement(u,s);var j;if($e(u)){if(j=_.createElement(u,s),_.isValidElement(j))return j}else j=OC(s);var w=EC(i),x=Oe(s,!0);if(w&&(o==="insideStart"||o==="insideEnd"||o==="end"))return AC(s,j,x);var v=w?PC(s):kC(s);return L.createElement(Dn,js({className:Le("recharts-label",h)},x,v,{breakAll:m}),j)}Ct.displayName="Label";var Qp=function(r){var n=r.cx,a=r.cy,s=r.angle,i=r.startAngle,o=r.endAngle,l=r.r,c=r.radius,u=r.innerRadius,d=r.outerRadius,h=r.x,m=r.y,j=r.top,w=r.left,x=r.width,v=r.height,y=r.clockWise,f=r.labelViewBox;if(f)return f;if(me(x)&&me(v)){if(me(h)&&me(m))return{x:h,y:m,width:x,height:v};if(me(j)&&me(w))return{x:j,y:w,width:x,height:v}}return me(h)&&me(m)?{x:h,y:m,width:0,height:0}:me(n)&&me(a)?{cx:n,cy:a,startAngle:i||s||0,endAngle:o||s||0,innerRadius:u||0,outerRadius:d||c||l||0,clockWise:y}:r.viewBox?r.viewBox:{}},TC=function(r,n){return r?r===!0?L.createElement(Ct,{key:"label-implicit",viewBox:n}):_t(r)?L.createElement(Ct,{key:"label-implicit",viewBox:n,value:r}):_.isValidElement(r)?r.type===Ct?_.cloneElement(r,{key:"label-implicit",viewBox:n}):L.createElement(Ct,{key:"label-implicit",content:r,viewBox:n}):$e(r)?L.createElement(Ct,{key:"label-implicit",content:r,viewBox:n}):ba(r)?L.createElement(Ct,js({viewBox:n},r,{key:"label-implicit"})):null:null},$C=function(r,n){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!r||!r.children&&a&&!r.label)return null;var s=r.children,i=Qp(r),o=er(s,Ct).map(function(c,u){return _.cloneElement(c,{viewBox:n||i,key:"label-".concat(u)})});if(!a)return o;var l=TC(r.label,n||i);return[l].concat(xC(o))};Ct.parseViewBox=Qp;Ct.renderCallByParent=$C;function DC(t){var r=t==null?0:t.length;return r?t[r-1]:void 0}var MC=DC;const IC=pt(MC);function bs(t){"@babel/helpers - typeof";return bs=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},bs(t)}var LC=["valueAccessor"],RC=["data","dataKey","clockWise","id","textBreakAll"];function FC(t){return qC(t)||UC(t)||zC(t)||BC()}function BC(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
80In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function zC(t,r){if(t){if(typeof t=="string")return uc(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return uc(t,r)}}function UC(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function qC(t){if(Array.isArray(t))return uc(t)}function uc(t,r){(r==null||r>t.length)&&(r=t.length);for(var n=0,a=new Array(r);n<r;n++)a[n]=t[n];return a}function Mi(){return Mi=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},Mi.apply(this,arguments)}function ih(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function oh(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?ih(Object(n),!0).forEach(function(a){VC(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ih(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function VC(t,r,n){return r=WC(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function WC(t){var r=KC(t,"string");return bs(r)=="symbol"?r:r+""}function KC(t,r){if(bs(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(bs(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function lh(t,r){if(t==null)return{};var n=GC(t,r),a,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)a=i[s],!(r.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(t,a)&&(n[a]=t[a])}return n}function GC(t,r){if(t==null)return{};var n={};for(var a in t)if(Object.prototype.hasOwnProperty.call(t,a)){if(r.indexOf(a)>=0)continue;n[a]=t[a]}return n}var HC=function(r){return Array.isArray(r.value)?IC(r.value):r.value};function Yr(t){var r=t.valueAccessor,n=r===void 0?HC:r,a=lh(t,LC),s=a.data,i=a.dataKey,o=a.clockWise,l=a.id,c=a.textBreakAll,u=lh(a,RC);return!s||!s.length?null:L.createElement(Ke,{className:"recharts-label-list"},s.map(function(d,h){var m=Ie(i)?n(d,h):Nt(d&&d.payload,i),j=Ie(l)?{}:{id:"".concat(l,"-").concat(h)};return L.createElement(Ct,Mi({},Oe(d,!0),u,j,{parentViewBox:d.parentViewBox,value:m,textBreakAll:c,viewBox:Ct.parseViewBox(Ie(o)?d:oh(oh({},d),{},{clockWise:o})),key:"label-".concat(h),index:h}))}))}Yr.displayName="LabelList";function XC(t,r){return t?t===!0?L.createElement(Yr,{key:"labelList-implicit",data:r}):L.isValidElement(t)||$e(t)?L.createElement(Yr,{key:"labelList-implicit",data:r,content:t}):ba(t)?L.createElement(Yr,Mi({data:r},t,{key:"labelList-implicit"})):null:null}function YC(t,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!t||!t.children&&n&&!t.label)return null;var a=t.children,s=er(a,Yr).map(function(o,l){return _.cloneElement(o,{data:r,key:"labelList-".concat(l)})});if(!n)return s;var i=XC(t.label,r);return[i].concat(FC(s))}Yr.renderCallByParent=YC;function ws(t){"@babel/helpers - typeof";return ws=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},ws(t)}function hc(){return hc=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},hc.apply(this,arguments)}function ch(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function dh(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?ch(Object(n),!0).forEach(function(a){QC(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ch(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function QC(t,r,n){return r=ZC(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function ZC(t){var r=JC(t,"string");return ws(r)=="symbol"?r:r+""}function JC(t,r){if(ws(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(ws(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}var eA=function(r,n){var a=Rt(n-r),s=Math.min(Math.abs(n-r),359.999);return a*s},ni=function(r){var n=r.cx,a=r.cy,s=r.radius,i=r.angle,o=r.sign,l=r.isExternal,c=r.cornerRadius,u=r.cornerIsExternal,d=c*(l?1:-1)+s,h=Math.asin(c/d)/Di,m=u?i:i+o*h,j=rt(n,a,d,m),w=rt(n,a,s,m),x=u?i-o*h:i,v=rt(n,a,d*Math.cos(h*Di),x);return{center:j,circleTangency:w,lineTangency:v,theta:h}},Zp=function(r){var n=r.cx,a=r.cy,s=r.innerRadius,i=r.outerRadius,o=r.startAngle,l=r.endAngle,c=eA(o,l),u=o+c,d=rt(n,a,i,o),h=rt(n,a,i,u),m="M ".concat(d.x,",").concat(d.y,`
81    A `).concat(i,",").concat(i,`,0,
82    `).concat(+(Math.abs(c)>180),",").concat(+(o>u),`,
83    `).concat(h.x,",").concat(h.y,`
84  `);if(s>0){var j=rt(n,a,s,o),w=rt(n,a,s,u);m+="L ".concat(w.x,",").concat(w.y,`
85            A `).concat(s,",").concat(s,`,0,
86            `).concat(+(Math.abs(c)>180),",").concat(+(o<=u),`,
87            `).concat(j.x,",").concat(j.y," Z")}else m+="L ".concat(n,",").concat(a," Z");return m},tA=function(r){var n=r.cx,a=r.cy,s=r.innerRadius,i=r.outerRadius,o=r.cornerRadius,l=r.forceCornerRadius,c=r.cornerIsExternal,u=r.startAngle,d=r.endAngle,h=Rt(d-u),m=ni({cx:n,cy:a,radius:i,angle:u,sign:h,cornerRadius:o,cornerIsExternal:c}),j=m.circleTangency,w=m.lineTangency,x=m.theta,v=ni({cx:n,cy:a,radius:i,angle:d,sign:-h,cornerRadius:o,cornerIsExternal:c}),y=v.circleTangency,f=v.lineTangency,b=v.theta,p=c?Math.abs(u-d):Math.abs(u-d)-x-b;if(p<0)return l?"M ".concat(w.x,",").concat(w.y,`
88        a`).concat(o,",").concat(o,",0,0,1,").concat(o*2,`,0
89        a`).concat(o,",").concat(o,",0,0,1,").concat(-o*2,`,0
90      `):Zp({cx:n,cy:a,innerRadius:s,outerRadius:i,startAngle:u,endAngle:d});var g="M ".concat(w.x,",").concat(w.y,`
91    A`).concat(o,",").concat(o,",0,0,").concat(+(h<0),",").concat(j.x,",").concat(j.y,`
92    A`).concat(i,",").concat(i,",0,").concat(+(p>180),",").concat(+(h<0),",").concat(y.x,",").concat(y.y,`
93    A`).concat(o,",").concat(o,",0,0,").concat(+(h<0),",").concat(f.x,",").concat(f.y,`
94  `);if(s>0){var N=ni({cx:n,cy:a,radius:s,angle:u,sign:h,isExternal:!0,cornerRadius:o,cornerIsExternal:c}),S=N.circleTangency,O=N.lineTangency,C=N.theta,P=ni({cx:n,cy:a,radius:s,angle:d,sign:-h,isExternal:!0,cornerRadius:o,cornerIsExternal:c}),$=P.circleTangency,A=P.lineTangency,I=P.theta,D=c?Math.abs(u-d):Math.abs(u-d)-C-I;if(D<0&&o===0)return"".concat(g,"L").concat(n,",").concat(a,"Z");g+="L".concat(A.x,",").concat(A.y,`
95      A`).concat(o,",").concat(o,",0,0,").concat(+(h<0),",").concat($.x,",").concat($.y,`
96      A`).concat(s,",").concat(s,",0,").concat(+(D>180),",").concat(+(h>0),",").concat(S.x,",").concat(S.y,`
97      A`).concat(o,",").concat(o,",0,0,").concat(+(h<0),",").concat(O.x,",").concat(O.y,"Z")}else g+="L".concat(n,",").concat(a,"Z");return g},rA={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},Jp=function(r){var n=dh(dh({},rA),r),a=n.cx,s=n.cy,i=n.innerRadius,o=n.outerRadius,l=n.cornerRadius,c=n.forceCornerRadius,u=n.cornerIsExternal,d=n.startAngle,h=n.endAngle,m=n.className;if(o<i||d===h)return null;var j=Le("recharts-sector",m),w=o-i,x=Ft(l,w,0,!0),v;return x>0&&Math.abs(d-h)<360?v=tA({cx:a,cy:s,innerRadius:i,outerRadius:o,cornerRadius:Math.min(x,w/2),forceCornerRadius:c,cornerIsExternal:u,startAngle:d,endAngle:h}):v=Zp({cx:a,cy:s,innerRadius:i,outerRadius:o,startAngle:d,endAngle:h}),L.createElement("path",hc({},Oe(n,!0),{className:j,d:v,role:"img"}))};function Ns(t){"@babel/helpers - typeof";return Ns=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Ns(t)}function mc(){return mc=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},mc.apply(this,arguments)}function uh(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function hh(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};
97r%2?uh(Object(n),!0).forEach(function(a){nA(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):uh(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function nA(t,r,n){return r=aA(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function aA(t){var r=sA(t,"string");return Ns(r)=="symbol"?r:r+""}function sA(t,r){if(Ns(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(Ns(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}var mh={curveBasisClosed:Bb,curveBasisOpen:zb,curveBasis:Fb,curveBumpX:Sb,curveBumpY:Ob,curveLinearClosed:Ub,curveLinear:Po,curveMonotoneX:qb,curveMonotoneY:Vb,curveNatural:Wb,curveStep:Kb,curveStepAfter:Hb,curveStepBefore:Gb},ai=function(r){return r.x===+r.x&&r.y===+r.y},ka=function(r){return r.x},Ea=function(r){return r.y},iA=function(r,n){if($e(r))return r;var a="curve".concat(Co(r));return(a==="curveMonotone"||a==="curveBump")&&n?mh["".concat(a).concat(n==="vertical"?"Y":"X")]:mh[a]||Po},oA=function(r){var n=r.type,a=n===void 0?"linear":n,s=r.points,i=s===void 0?[]:s,o=r.baseLine,l=r.layout,c=r.connectNulls,u=c===void 0?!1:c,d=iA(a,l),h=u?i.filter(function(x){return ai(x)}):i,m;if(Array.isArray(o)){var j=u?o.filter(function(x){return ai(x)}):o,w=h.map(function(x,v){return hh(hh({},x),{},{base:j[v]})});return l==="vertical"?m=Qs().y(Ea).x1(ka).x0(function(x){return x.base.x}):m=Qs().x(ka).y1(Ea).y0(function(x){return x.base.y}),m.defined(ai).curve(d),m(w)}return l==="vertical"&&me(o)?m=Qs().y(Ea).x1(ka).x0(o):me(o)?m=Qs().x(ka).y1(Ea).y0(o):m=zf().x(ka).y(Ea),m.defined(ai).curve(d),m(h)},Ii=function(r){var n=r.className,a=r.points,s=r.path,i=r.pathRef;if((!a||!a.length)&&!s)return null;var o=a&&a.length?oA(r):s;return L.createElement("path",mc({},Oe(r,!1),yi(r),{className:Le("recharts-curve",n),d:o,ref:i}))},lA=Object.getOwnPropertyNames,cA=Object.getOwnPropertySymbols,dA=Object.prototype.hasOwnProperty;function fh(t,r){return function(a,s,i){return t(a,s,i)&&r(a,s,i)}}function si(t){return function(n,a,s){if(!n||!a||typeof n!="object"||typeof a!="object")return t(n,a,s);var i=s.cache,o=i.get(n),l=i.get(a);if(o&&l)return o===a&&l===n;i.set(n,a),i.set(a,n);var c=t(n,a,s);return i.delete(n),i.delete(a),c}}function ph(t){return lA(t).concat(cA(t))}var ex=Object.hasOwn||function(t,r){return dA.call(t,r)};function Ca(t,r){return t||r?t===r:t===r||t!==t&&r!==r}var tx="_owner",xh=Object.getOwnPropertyDescriptor,vh=Object.keys;function uA(t,r,n){var a=t.length;if(r.length!==a)return!1;for(;a-- >0;)if(!n.equals(t[a],r[a],a,a,t,r,n))return!1;return!0}function hA(t,r){return Ca(t.getTime(),r.getTime())}function gh(t,r,n){if(t.size!==r.size)return!1;for(var a={},s=t.entries(),i=0,o,l;(o=s.next())&&!o.done;){for(var c=r.entries(),u=!1,d=0;(l=c.next())&&!l.done;){var h=o.value,m=h[0],j=h[1],w=l.value,x=w[0],v=w[1];!u&&!a[d]&&(u=n.equals(m,x,i,d,t,r,n)&&n.equals(j,v,m,x,t,r,n))&&(a[d]=!0),d++}if(!u)return!1;i++}return!0}function mA(t,r,n){var a=vh(t),s=a.length;if(vh(r).length!==s)return!1;for(var i;s-- >0;)if(i=a[s],i===tx&&(t.$$typeof||r.$$typeof)&&t.$$typeof!==r.$$typeof||!ex(r,i)||!n.equals(t[i],r[i],i,i,t,r,n))return!1;return!0}function Ta(t,r,n){var a=ph(t),s=a.length;if(ph(r).length!==s)return!1;for(var i,o,l;s-- >0;)if(i=a[s],i===tx&&(t.$$typeof||r.$$typeof)&&t.$$typeof!==r.$$typeof||!ex(r,i)||!n.equals(t[i],r[i],i,i,t,r,n)||(o=xh(t,i),l=xh(r,i),(o||l)&&(!o||!l||o.configurable!==l.configurable||o.enumerable!==l.enumerable||o.writable!==l.writable)))return!1;return!0}function fA(t,r){return Ca(t.valueOf(),r.valueOf())}function pA(t,r){return t.source===r.source&&t.flags===r.flags}function yh(t,r,n){if(t.size!==r.size)return!1;for(var a={},s=t.values(),i,o;(i=s.next())&&!i.done;){for(var l=r.values(),c=!1,u=0;(o=l.next())&&!o.done;)!c&&!a[u]&&(c=n.equals(i.value,o.value,i.value,o.value,t,r,n))&&(a[u]=!0),u++;if(!c)return!1}return!0}function xA(t,r){var n=t.length;if(r.length!==n)return!1;for(;n-- >0;)if(t[n]!==r[n])return!1;return!0}var vA="[object Arguments]",gA="[object Boolean]",yA="[object Date]",jA="[object Map]",bA="[object Number]",wA="[object Object]",NA="[object RegExp]",_A="[object Set]",SA="[object String]",OA=Array.isArray,jh=typeof ArrayBuffer=="function"&&ArrayBuffer.isView?ArrayBuffer.isView:null,bh=Object.assign,CA=Object.prototype.toString.call.bind(Object.prototype.toString);function AA(t){var r=t.areArraysEqual,n=t.areDatesEqual,a=t.areMapsEqual,s=t.areObjectsEqual,i=t.arePrimitiveWrappersEqual,o=t.areRegExpsEqual,l=t.areSetsEqual,c=t.areTypedArraysEqual;return function(d,h,m){if(d===h)return!0;
97if(d==null||h==null||typeof d!="object"||typeof h!="object")return d!==d&&h!==h;var j=d.constructor;if(j!==h.constructor)return!1;if(j===Object)return s(d,h,m);if(OA(d))return r(d,h,m);if(jh!=null&&jh(d))return c(d,h,m);if(j===Date)return n(d,h,m);if(j===RegExp)return o(d,h,m);if(j===Map)return a(d,h,m);if(j===Set)return l(d,h,m);var w=CA(d);return w===yA?n(d,h,m):w===NA?o(d,h,m):w===jA?a(d,h,m):w===_A?l(d,h,m):w===wA?typeof d.then!="function"&&typeof h.then!="function"&&s(d,h,m):w===vA?s(d,h,m):w===gA||w===bA||w===SA?i(d,h,m):!1}}function PA(t){var r=t.circular,n=t.createCustomConfig,a=t.strict,s={areArraysEqual:a?Ta:uA,areDatesEqual:hA,areMapsEqual:a?fh(gh,Ta):gh,areObjectsEqual:a?Ta:mA,arePrimitiveWrappersEqual:fA,areRegExpsEqual:pA,areSetsEqual:a?fh(yh,Ta):yh,areTypedArraysEqual:a?Ta:xA};if(n&&(s=bh({},s,n(s))),r){var i=si(s.areArraysEqual),o=si(s.areMapsEqual),l=si(s.areObjectsEqual),c=si(s.areSetsEqual);s=bh({},s,{areArraysEqual:i,areMapsEqual:o,areObjectsEqual:l,areSetsEqual:c})}return s}function kA(t){return function(r,n,a,s,i,o,l){return t(r,n,l)}}function EA(t){var r=t.circular,n=t.comparator,a=t.createState,s=t.equals,i=t.strict;if(a)return function(c,u){var d=a(),h=d.cache,m=h===void 0?r?new WeakMap:void 0:h,j=d.meta;return n(c,u,{cache:m,equals:s,meta:j,strict:i})};if(r)return function(c,u){return n(c,u,{cache:new WeakMap,equals:s,meta:void 0,strict:i})};var o={cache:void 0,equals:s,meta:void 0,strict:i};return function(c,u){return n(c,u,o)}}var TA=un();un({strict:!0});un({circular:!0});un({circular:!0,strict:!0});un({createInternalComparator:function(){return Ca}});un({strict:!0,createInternalComparator:function(){return Ca}});un({circular:!0,createInternalComparator:function(){return Ca}});un({circular:!0,createInternalComparator:function(){return Ca},strict:!0});function un(t){t===void 0&&(t={});var r=t.circular,n=r===void 0?!1:r,a=t.createInternalComparator,s=t.createState,i=t.strict,o=i===void 0?!1:i,l=PA(t),c=AA(l),u=a?a(c):kA(c);return EA({circular:n,comparator:c,createState:s,equals:u,strict:o})}function $A(t){typeof requestAnimationFrame<"u"&&requestAnimationFrame(t)}function wh(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=-1,a=function s(i){n<0&&(n=i),i-n>r?(t(i),n=-1):$A(s)};requestAnimationFrame(a)}function fc(t){"@babel/helpers - typeof";return fc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},fc(t)}function DA(t){return RA(t)||LA(t)||IA(t)||MA()}function MA(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
98In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function IA(t,r){if(t){if(typeof t=="string")return Nh(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Nh(t,r)}}function Nh(t,r){(r==null||r>t.length)&&(r=t.length);for(var n=0,a=new Array(r);n<r;n++)a[n]=t[n];return a}function LA(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function RA(t){if(Array.isArray(t))return t}function FA(){var t={},r=function(){return null},n=!1,a=function s(i){if(!n){if(Array.isArray(i)){if(!i.length)return;var o=i,l=DA(o),c=l[0],u=l.slice(1);if(typeof c=="number"){wh(s.bind(null,u),c);return}s(c),wh(s.bind(null,u));return}fc(i)==="object"&&(t=i,r(t)),typeof i=="function"&&i()}};return{stop:function(){n=!0},start:function(i){n=!1,a(i)},subscribe:function(i){return r=i,function(){r=function(){return null}}}}}function _s(t){"@babel/helpers - typeof";return _s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},_s(t)}function _h(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function Sh(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};
vendor: 26,667 bytes, lines 98-115
98r%2?_h(Object(n),!0).forEach(function(a){rx(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):_h(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function rx(t,r,n){return r=BA(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function BA(t){var r=zA(t,"string");return _s(r)==="symbol"?r:String(r)}function zA(t,r){if(_s(t)!=="object"||t===null)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(_s(a)!=="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}var UA=function(r,n){return[Object.keys(r),Object.keys(n)].reduce(function(a,s){return a.filter(function(i){return s.includes(i)})})},qA=function(r){return r},VA=function(r){return r.replace(/([A-Z])/g,function(n){return"-".concat(n.toLowerCase())})},Xa=function(r,n){return Object.keys(n).reduce(function(a,s){return Sh(Sh({},a),{},rx({},s,r(s,n[s])))},{})},Oh=function(r,n,a){return r.map(function(s){return"".concat(VA(s)," ").concat(n,"ms ").concat(a)}).join(",")};function WA(t,r){return HA(t)||GA(t,r)||nx(t,r)||KA()}function KA(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
99In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function GA(t,r){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var a,s,i,o,l=[],c=!0,u=!1;try{if(i=(n=n.call(t)).next,r!==0)for(;!(c=(a=i.call(n)).done)&&(l.push(a.value),l.length!==r);c=!0);}catch(d){u=!0,s=d}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw s}}return l}}function HA(t){if(Array.isArray(t))return t}function XA(t){return ZA(t)||QA(t)||nx(t)||YA()}function YA(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
100In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function nx(t,r){if(t){if(typeof t=="string")return pc(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return pc(t,r)}}function QA(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function ZA(t){if(Array.isArray(t))return pc(t)}function pc(t,r){(r==null||r>t.length)&&(r=t.length);for(var n=0,a=new Array(r);n<r;n++)a[n]=t[n];return a}var Li=1e-4,ax=function(r,n){return[0,3*r,3*n-6*r,3*r-3*n+1]},sx=function(r,n){return r.map(function(a,s){return a*Math.pow(n,s)}).reduce(function(a,s){return a+s})},Ch=function(r,n){return function(a){var s=ax(r,n);return sx(s,a)}},JA=function(r,n){return function(a){var s=ax(r,n),i=[].concat(XA(s.map(function(o,l){return o*l}).slice(1)),[0]);return sx(i,a)}},Ah=function(){for(var r=arguments.length,n=new Array(r),a=0;a<r;a++)n[a]=arguments[a];var s=n[0],i=n[1],o=n[2],l=n[3];if(n.length===1)switch(n[0]){case"linear":s=0,i=0,o=1,l=1;break;case"ease":s=.25,i=.1,o=.25,l=1;break;case"ease-in":s=.42,i=0,o=1,l=1;break;case"ease-out":s=.42,i=0,o=.58,l=1;break;case"ease-in-out":s=0,i=0,o=.58,l=1;break;default:{var c=n[0].split("(");if(c[0]==="cubic-bezier"&&c[1].split(")")[0].split(",").length===4){var u=c[1].split(")")[0].split(",").map(function(v){return parseFloat(v)}),d=WA(u,4);s=d[0],i=d[1],o=d[2],l=d[3]}}}var h=Ch(s,o),m=Ch(i,l),j=JA(s,o),w=function(y){return y>1?1:y<0?0:y},x=function(y){for(var f=y>1?1:y,b=f,p=0;p<8;++p){var g=h(b)-f,N=j(b);if(Math.abs(g-f)<Li||N<Li)return m(b);b=w(b-g/N)}return m(b)};return x.isStepper=!1,x},eP=function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=r.stiff,a=n===void 0?100:n,s=r.damping,i=s===void 0?8:s,o=r.dt,l=o===void 0?17:o,c=function(d,h,m){var j=-(d-h)*a,w=m*i,x=m+(j-w)*l/1e3,v=m*l/1e3+d;return Math.abs(v-h)<Li&&Math.abs(x)<Li?[h,0]:[v,x]};return c.isStepper=!0,c.dt=l,c},tP=function(){for(var r=arguments.length,n=new Array(r),a=0;a<r;a++)n[a]=arguments[a];var s=n[0];if(typeof s=="string")switch(s){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return Ah(s);case"spring":return eP();default:if(s.split("(")[0]==="cubic-bezier")return Ah(s)}return typeof s=="function"?s:null};function Ss(t){"@babel/helpers - typeof";return Ss=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Ss(t)}function Ph(t){return aP(t)||nP(t)||ix(t)||rP()}function rP(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
101In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function nP(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function aP(t){if(Array.isArray(t))return vc(t)}function kh(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function kt(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?kh(Object(n),!0).forEach(function(a){xc(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):kh(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function xc(t,r,n){return r=sP(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function sP(t){var r=iP(t,"string");return Ss(r)==="symbol"?r:String(r)}function iP(t,r){if(Ss(t)!=="object"||t===null)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(Ss(a)!=="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function oP(t,r){return dP(t)||cP(t,r)||ix(t,r)||lP()}function lP(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
102In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ix(t,r){if(t){if(typeof t=="string")return vc(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return vc(t,r)}}function vc(t,r){(r==null||r>t.length)&&(r=t.length);for(var n=0,a=new Array(r);n<r;n++)a[n]=t[n];return a}function cP(t,r){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var a,s,i,o,l=[],c=!0,u=!1;try{if(i=(n=n.call(t)).next,r!==0)for(;!(c=(a=i.call(n)).done)&&(l.push(a.value),l.length!==r);c=!0);}catch(d){u=!0,s=d}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw s}}return l}}function dP(t){if(Array.isArray(t))return t}var Ri=function(r,n,a){return r+(n-r)*a},gc=function(r){var n=r.from,a=r.to;return n!==a},uP=function t(r,n,a){var s=Xa(function(i,o){if(gc(o)){var l=r(o.from,o.to,o.velocity),c=oP(l,2),u=c[0],d=c[1];return kt(kt({},o),{},{from:u,velocity:d})}return o},n);return a<1?Xa(function(i,o){return gc(o)?kt(kt({},o),{},{velocity:Ri(o.velocity,s[i].velocity,a),from:Ri(o.from,s[i].from,a)}):o},n):t(r,s,a-1)};const hP=function(t,r,n,a,s){var i=UA(t,r),o=i.reduce(function(v,y){return kt(kt({},v),{},xc({},y,[t[y],r[y]]))},{}),l=i.reduce(function(v,y){return kt(kt({},v),{},xc({},y,{from:t[y],velocity:0,to:r[y]}))},{}),c=-1,u,d,h=function(){return null},m=function(){return Xa(function(y,f){return f.from},l)},j=function(){return!Object.values(l).filter(gc).length},w=function(y){u||(u=y);var f=y-u,b=f/n.dt;l=uP(n,l,b),s(kt(kt(kt({},t),r),m())),u=y,j()||(c=requestAnimationFrame(h))},x=function(y){d||(d=y);var f=(y-d)/a,b=Xa(function(g,N){return Ri.apply(void 0,Ph(N).concat([n(f)]))},o);if(s(kt(kt(kt({},t),r),b)),f<1)c=requestAnimationFrame(h);else{var p=Xa(function(g,N){return Ri.apply(void 0,Ph(N).concat([n(1)]))},o);s(kt(kt(kt({},t),r),p))}};return h=n.isStepper?w:x,function(){return requestAnimationFrame(h),function(){cancelAnimationFrame(c)}}};function na(t){"@babel/helpers - typeof";return na=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},na(t)}var mP=["children","begin","duration","attributeName","easing","isActive","steps","from","to","canBegin","onAnimationEnd","shouldReAnimate","onAnimationReStart"];function fP(t,r){if(t==null)return{};var n=pP(t,r),a,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)a=i[s],!(r.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(t,a)&&(n[a]=t[a])}return n}function pP(t,r){if(t==null)return{};var n={},a=Object.keys(t),s,i;for(i=0;i<a.length;i++)s=a[i],!(r.indexOf(s)>=0)&&(n[s]=t[s]);return n}function ml(t){return yP(t)||gP(t)||vP(t)||xP()}function xP(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
103In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function vP(t,r){if(t){if(typeof t=="string")return yc(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return yc(t,r)}}function gP(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function yP(t){if(Array.isArray(t))return yc(t)}function yc(t,r){(r==null||r>t.length)&&(r=t.length);for(var n=0,a=new Array(r);n<r;n++)a[n]=t[n];return a}function Eh(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function jr(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?Eh(Object(n),!0).forEach(function(a){Ma(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Eh(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function Ma(t,r,n){return r=ox(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function jP(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function bP(t,r){for(var n=0;n<r.length;n++){var a=r[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,ox(a.key),a)}}function wP(t,r,n){return r&&bP(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function ox(t){var r=NP(t,"string");return na(r)==="symbol"?r:String(r)}function NP(t,r){if(na(t)!=="object"||t===null)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(na(a)!=="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function _P(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&jc(t,r)}function jc(t,r){return jc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,s){return a.__proto__=s,a},jc(t,r)}function SP(t){var r=OP();return function(){var a=Fi(t),s;if(r){var i=Fi(this).constructor;s=Reflect.construct(a,arguments,i)}else s=a.apply(this,arguments);return bc(this,s)}}function bc(t,r){if(r&&(na(r)==="object"||typeof r=="function"))return r;if(r!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return wc(t)}function wc(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function OP(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Fi(t){return Fi=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Fi(t)}var Rr=function(t){_P(n,t);var r=SP(n);function n(a,s){var i;jP(this,n),i=r.call(this,a,s);var o=i.props,l=o.isActive,c=o.attributeName,u=o.from,d=o.to,h=o.steps,m=o.children,j=o.duration;if(i.handleStyleChange=i.handleStyleChange.bind(wc(i)),i.changeStyle=i.changeStyle.bind(wc(i)),!l||j<=0)return i.state={style:{}},typeof m=="function"&&(i.state={style:d}),bc(i);if(h&&h.length)i.state={style:h[0].style};else if(u){if(typeof m=="function")return i.state={style:u},bc(i);i.state={style:c?Ma({},c,u):u}}else i.state={style:{}};return i}return wP(n,[{key:"componentDidMount",value:function(){var s=this.props,i=s.isActive,o=s.canBegin;this.mounted=!0,!(!i||!o)&&this.runAnimation(this.props)}},{key:"componentDidUpdate",value:function(s){var i=this.props,o=i.isActive,l=i.canBegin,c=i.attributeName,u=i.shouldReAnimate,d=i.to,h=i.from,m=this.state.style;if(l){if(!o){var j={style:c?Ma({},c,d):d};this.state&&m&&(c&&m[c]!==d||!c&&m!==d)&&this.setState(j);return}if(!(TA(s.to,d)&&s.canBegin&&s.isActive)){var w=!s.canBegin||!s.isActive;this.manager&&this.manager.stop(),this.stopJSAnimation&&this.stopJSAnimation();var x=w||u?h:s.to;if(this.state&&m){var v={style:c?Ma({},c,x):x};(c&&m[c]!==x||!c&&m!==x)&&this.setState(v)}this.runAnimation(jr(jr({},this.props),{},{from:x,begin:0}))}}}},{key:"componentWillUnmount",value:function(){this.mounted=!1;var s=this.props.onAnimationEnd;this.unSubscribe&&this.unSubscribe(),this.manager&&(this.manager.stop(),this.manager=null),this.stopJSAnimation&&this.stopJSAnimation(),s&&s()}},{key:"handleStyleChange",value:function(s){this.changeStyle(s)}},{key:"changeStyle",value:function(s){this.mounted&&this.setState({style:s})}},{key:"runJSAnimation",value:function(s){var i=this,o=s.from,l=s.to,c=s.duration,u=s.easing,d=s.begin,h=s.onAnimationEnd,m=s.onAnimationStart,j=hP(o,l,tP(u),c,this.changeStyle),w=function(){i.stopJSAnimation=j()};this.manager.start([m,d,w,c,h])}},{key:"runStepAnimation",value:function(s){var i=this,o=s.steps,l=s.begin,c=s.onAnimationStart,u=o[0],d=u.style,h=u.duration,m=h===void 0?0:h,j=function(x,v,y){if(y===0)return x;var f=v.duration,b=v.easing,p=b===void 0?"ease":b,g=v.style,N=v.properties,S=v.onAnimationEnd,O=y>0?o[y-1]:v,C=N||Object.keys(g);if(typeof p=="function"||p==="spring")return[].concat(ml(x),[i.runJSAnimation.bind(i,{from:O.style,to:g,duration:f,easing:p}),f]);var P=Oh(C,f,p),$=jr(jr(jr({},O.style),g),{},{transition:P});return[].concat(ml(x),[$,f,S]).filter(qA)};return this.manager.start([c].concat(ml(o.reduce(j,[d,Math.max(m,l)])),[s.onAnimationEnd]))}},{key:"runAnimation",value:function(s){this.manager||(this.manager=FA());var i=s.begin,o=s.duration,l=s.attributeName,c=s.to,u=s.easing,d=s.onAnimationStart,h=s.onAnimationEnd,m=s.steps,j=s.children,w=this.manager;if(this.unSubscribe=w.subscribe(this.handleStyleChange),typeof u=="function"||typeof j=="function"||u==="spring"){this.runJSAnimation(s);return}if(m.length>1){this.runStepAnimation(s);return}var x=l?Ma({},l,c):c,v=Oh(Object.keys(x),o,u);w.start([d,i,jr(jr({},x),{},{transition:v}),o,h])}},{key:"render",value:function(){var s=this.props,i=s.children;s.begin;var o=s.duration;s.attributeName,s.easing;var l=s.isActive;s.steps,s.from,s.to,s.canBegin,s.onAnimationEnd,s.shouldReAnimate,s.onAnimationReStart;var c=fP(s,mP),u=_.Children.count(i),d=this.state.style;if(typeof i=="function")return i(d);if(!l||u===0||o<=0)return i;var h=function(j){var w=j.props,x=w.style,v=x===void 0?{}:x,y=w.className,f=_.cloneElement(j,jr(jr({},c),{},{style:jr(jr({},v),d),className:y}));return f};return u===1?h(_.Children.only(i)):L.createElement("div",null,_.Children.map(i,function(m){return h(m)}))}}]),n}(_.PureComponent);Rr.displayName="Animate";Rr.defaultProps={begin:0,duration:1e3,from:"",to:"",attributeName:"",easing:"ease",isActive:!0,canBegin:!0,steps:[],onAnimationEnd:function(){},onAnimationStart:function(){}};Rr.propTypes={from:Me.oneOfType([Me.object,Me.string]),to:Me.oneOfType([Me.object,Me.string]),attributeName:Me.string,duration:Me.number,begin:Me.number,easing:Me.oneOfType([Me.string,Me.func]),steps:Me.arrayOf(Me.shape({duration:Me.number.isRequired,style:Me.object.isRequired,easing:Me.oneOfType([Me.oneOf(["ease","ease-in","ease-out","ease-in-out","linear"]),Me.func]),properties:Me.arrayOf("string"),onAnimationEnd:Me.func})),children:Me.oneOfType([Me.node,Me.func]),isActive:Me.bool,canBegin:Me.bool,onAnimationEnd:Me.func,shouldReAnimate:Me.bool,onAnimationStart:Me.func,onAnimationReStart:Me.func};Me.object,Me.object,Me.object,Me.element;Me.object,Me.object,Me.object,Me.oneOfType([Me.array,Me.element]),Me.any;function Os(t){"@babel/helpers - typeof";return Os=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Os(t)}function Bi(){return Bi=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},Bi.apply(this,arguments)}function CP(t,r){return EP(t)||kP(t,r)||PP(t,r)||AP()}function AP(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
104In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function PP(t,r){if(t){if(typeof t=="string")return Th(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Th(t,r)}}function Th(t,r){(r==null||r>t.length)&&(r=t.length);for(var n=0,a=new Array(r);n<r;n++)a[n]=t[n];return a}function kP(t,r){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var a,s,i,o,l=[],c=!0,u=!1;try{if(i=(n=n.call(t)).next,r!==0)for(;!(c=(a=i.call(n)).done)&&(l.push(a.value),l.length!==r);c=!0);}catch(d){u=!0,s=d}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw s}}return l}}function EP(t){if(Array.isArray(t))return t}function $h(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function Dh(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?$h(Object(n),!0).forEach(function(a){TP(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):$h(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function TP(t,r,n){return r=$P(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function $P(t){var r=DP(t,"string");return Os(r)=="symbol"?r:r+""}function DP(t,r){if(Os(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(Os(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}var Mh=function(r,n,a,s,i){var o=Math.min(Math.abs(a)/2,Math.abs(s)/2),l=s>=0?1:-1,c=a>=0?1:-1,u=s>=0&&a>=0||s<0&&a<0?1:0,d;if(o>0&&i instanceof Array){for(var h=[0,0,0,0],m=0,j=4;m<j;m++)h[m]=i[m]>o?o:i[m];d="M".concat(r,",").concat(n+l*h[0]),h[0]>0&&(d+="A ".concat(h[0],",").concat(h[0],",0,0,").concat(u,",").concat(r+c*h[0],",").concat(n)),d+="L ".concat(r+a-c*h[1],",").concat(n),h[1]>0&&(d+="A ".concat(h[1],",").concat(h[1],",0,0,").concat(u,`,
105        `).concat(r+a,",").concat(n+l*h[1])),d+="L ".concat(r+a,",").concat(n+s-l*h[2]),h[2]>0&&(d+="A ".concat(h[2],",").concat(h[2],",0,0,").concat(u,`,
106        `).concat(r+a-c*h[2],",").concat(n+s)),d+="L ".concat(r+c*h[3],",").concat(n+s),h[3]>0&&(d+="A ".concat(h[3],",").concat(h[3],",0,0,").concat(u,`,
107        `).concat(r,",").concat(n+s-l*h[3])),d+="Z"}else if(o>0&&i===+i&&i>0){var w=Math.min(o,i);d="M ".concat(r,",").concat(n+l*w,`
108            A `).concat(w,",").concat(w,",0,0,").concat(u,",").concat(r+c*w,",").concat(n,`
109            L `).concat(r+a-c*w,",").concat(n,`
110            A `).concat(w,",").concat(w,",0,0,").concat(u,",").concat(r+a,",").concat(n+l*w,`
111            L `).concat(r+a,",").concat(n+s-l*w,`
112            A `).concat(w,",").concat(w,",0,0,").concat(u,",").concat(r+a-c*w,",").concat(n+s,`
113            L `).concat(r+c*w,",").concat(n+s,`
114            A `).concat(w,",").concat(w,",0,0,").concat(u,",").concat(r,",").concat(n+s-l*w," Z")}else d="M ".concat(r,",").concat(n," h ").concat(a," v ").concat(s," h ").concat(-a," Z");return d},MP=function(r,n){if(!r||!n)return!1;var a=r.x,s=r.y,i=n.x,o=n.y,l=n.width,c=n.height;if(Math.abs(l)>0&&Math.abs(c)>0){var u=Math.min(i,i+l),d=Math.max(i,i+l),h=Math.min(o,o+c),m=Math.max(o,o+c);return a>=u&&a<=d&&s>=h&&s<=m}return!1},IP={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},Sd=function(r){var n=Dh(Dh({},IP),r),a=_.useRef(),s=_.useState(-1),i=CP(s,2),o=i[0],l=i[1];_.useEffect(function(){if(a.current&&a.current.getTotalLength)try{var p=a.current.getTotalLength();p&&l(p)}catch{}},[]);var c=n.x,u=n.y,d=n.width,h=n.height,m=n.radius,j=n.className,w=n.animationEasing,x=n.animationDuration,v=n.animationBegin,y=n.isAnimationActive,f=n.isUpdateAnimationActive;if(c!==+c||u!==+u||d!==+d||h!==+h||d===0||h===0)return null;var b=Le("recharts-rectangle",j);return f?L.createElement(Rr,{canBegin:o>0,from:{width:d,height:h,x:c,y:u},to:{width:d,height:h,x:c,y:u},duration:x,animationEasing:w,isActive:f},function(p){var g=p.width,N=p.height,S=p.x,O=p.y;return L.createElement(Rr,{canBegin:o>0,from:"0px ".concat(o===-1?1:o,"px"),to:"".concat(o,"px 0px"),attributeName:"strokeDasharray",begin:v,duration:x,isActive:y,easing:w},L.createElement("path",Bi({},Oe(n,!0),{className:b,d:Mh(S,O,g,N,m),ref:a})))}):L.createElement("path",Bi({},Oe(n,!0),{className:b,d:Mh(c,u,d,h,m)}))},LP=["points","className","baseLinePoints","connectNulls"];function qn(){return qn=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},qn.apply(this,arguments)}function RP(t,r){if(t==null)return{};var n=FP(t,r),a,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)a=i[s],!(r.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(t,a)&&(n[a]=t[a])}return n}function FP(t,r){if(t==null)return{};var n={};for(var a in t)if(Object.prototype.hasOwnProperty.call(t,a)){if(r.indexOf(a)>=0)continue;n[a]=t[a]}return n}function Ih(t){return qP(t)||UP(t)||zP(t)||BP()}function BP(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
115In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function zP(t,r){if(t){if(typeof t=="string")return Nc(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Nc(t,r)}}function UP(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function qP(t){if(Array.isArray(t))return Nc(t)}function Nc(t,r){(r==null||r>t.length)&&(r=t.length);for(var n=0,a=new Array(r);n<r;n++)a[n]=t[n];return a}var Lh=function(r){return r&&r.x===+r.x&&r.y===+r.y},VP=function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],n=[[]];return r.forEach(function(a){Lh(a)?n[n.length-1].push(a):n[n.length-1].length>0&&n.push([])}),Lh(r[0])&&n[n.length-1].push(r[0]),n[n.length-1].length<=0&&(n=n.slice(0,-1)),n},Ya=function(r,n){var a=VP(r);n&&(a=[a.reduce(function(i,o){return[].concat(Ih(i),Ih(o))},[])]);var s=a.map(function(i){return i.reduce(function(o,l,c){return"".concat(o).concat(c===0?"M":"L").concat(l.x,",").concat(l.y)},"")}).join("");return a.length===1?"".concat(s,"Z"):s},WP=function(r,n,a){var s=Ya(r,a);return"".concat(s.slice(-1)==="Z"?s.slice(0,-1):s,"L").concat(Ya(n.reverse(),a).slice(1))},KP=function(r){var n=r.points,a=r.className,s=r.baseLinePoints,i=r.connectNulls,o=RP(r,LP);if(!n||!n.length)return null;var l=Le("recharts-polygon",a);if(s&&s.length){var c=o.stroke&&o.stroke!=="none",u=WP(n,s,i);return L.createElement("g",{className:l},L.createElement("path",qn({},Oe(o,!0),{fill:u.slice(-1)==="Z"?o.fill:"none",stroke:"none",d:u})),c?L.createElement("path",qn({},Oe(o,!0),{fill:"none",d:Ya(n,i)})):null,c?L.createElement("path",qn({},Oe(o,!0),{fill:"none",d:Ya(s,i)})):null)}var d=Ya(n,i);return L.createElement("path",qn({},Oe(o,!0),{fill:d.slice(-1)==="Z"?o.fill:"none",className:l,d}))};function _c(){return _c=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},_c.apply(this,arguments)}var Ro=function(r){var n=r.cx,a=r.cy,s=r.r,i=r.className,o=Le("recharts-dot",i);return n===+n&&a===+a&&s===+s?L.createElement("circle",_c({},Oe(r,!1),yi(r),{className:o,cx:n,cy:a,r:s})):null};function Cs(t){"@babel/helpers - typeof";return Cs=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Cs(t)}var GP=["x","y","top","left","width","height","className"];function Sc(){return Sc=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},Sc.apply(this,arguments)}function Rh(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function HP(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};
115r%2?Rh(Object(n),!0).forEach(function(a){XP(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Rh(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function XP(t,r,n){return r=YP(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function YP(t){var r=QP(t,"string");return Cs(r)=="symbol"?r:r+""}function QP(t,r){if(Cs(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(Cs(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function ZP(t,r){if(t==null)return{};var n=JP(t,r),a,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)a=i[s],!(r.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(t,a)&&(n[a]=t[a])}return n}function JP(t,r){if(t==null)return{};var n={};for(var a in t)if(Object.prototype.hasOwnProperty.call(t,a)){if(r.indexOf(a)>=0)continue;n[a]=t[a]}return n}var ek=function(r,n,a,s,i,o){return"M".concat(r,",").concat(i,"v").concat(s,"M").concat(o,",").concat(n,"h").concat(a)},tk=function(r){var n=r.x,a=n===void 0?0:n,s=r.y,i=s===void 0?0:s,o=r.top,l=o===void 0?0:o,c=r.left,u=c===void 0?0:c,d=r.width,h=d===void 0?0:d,m=r.height,j=m===void 0?0:m,w=r.className,x=ZP(r,GP),v=HP({x:a,y:i,top:l,left:u,width:h,height:j},x);return!me(a)||!me(i)||!me(h)||!me(j)||!me(l)||!me(u)?null:L.createElement("path",Sc({},Oe(v,!0),{className:Le("recharts-cross",w),d:ek(a,i,h,j,l,u)}))},rk=$o,nk=bp,ak=qr;function sk(t,r){return t&&t.length?rk(t,ak(r),nk):void 0}var ik=sk;const ok=pt(ik);var lk=$o,ck=qr,dk=wp;function uk(t,r){return t&&t.length?lk(t,ck(r),dk):void 0}var hk=uk;const mk=pt(hk);var fk=["cx","cy","angle","ticks","axisLine"],pk=["ticks","tick","angle","tickFormatter","stroke"];function aa(t){"@babel/helpers - typeof";return aa=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},aa(t)}function Qa(){return Qa=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},Qa.apply(this,arguments)}function Fh(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function fn(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?Fh(Object(n),!0).forEach(function(a){Fo(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Fh(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function Bh(t,r){if(t==null)return{};var n=xk(t,r),a,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)a=i[s],!(r.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(t,a)&&(n[a]=t[a])}return n}function xk(t,r){if(t==null)return{};var n={};for(var a in t)if(Object.prototype.hasOwnProperty.call(t,a)){if(r.indexOf(a)>=0)continue;n[a]=t[a]}return n}function vk(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function zh(t,r){for(var n=0;n<r.length;n++){var a=r[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,cx(a.key),a)}}function gk(t,r,n){return r&&zh(t.prototype,r),n&&zh(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function yk(t,r,n){return r=zi(r),jk(t,lx()?Reflect.construct(r,n||[],zi(t).constructor):r.apply(t,n))}function jk(t,r){if(r&&(aa(r)==="object"||typeof r=="function"))return r;if(r!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return bk(t)}function bk(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function lx(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(lx=function(){return!!t})()}
vendor: 7,657 bytes, line 115
115function zi(t){return zi=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},zi(t)}function wk(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&Oc(t,r)}function Oc(t,r){return Oc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,s){return a.__proto__=s,a},Oc(t,r)}function Fo(t,r,n){return r=cx(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function cx(t){var r=Nk(t,"string");return aa(r)=="symbol"?r:r+""}function Nk(t,r){if(aa(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(aa(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}var Bo=function(t){function r(){return vk(this,r),yk(this,r,arguments)}return wk(r,t),gk(r,[{key:"getTickValueCoord",value:function(a){var s=a.coordinate,i=this.props,o=i.angle,l=i.cx,c=i.cy;return rt(l,c,s,o)}},{key:"getTickTextAnchor",value:function(){var a=this.props.orientation,s;switch(a){case"left":s="end";break;case"right":s="start";break;default:s="middle";break}return s}},{key:"getViewBox",value:function(){var a=this.props,s=a.cx,i=a.cy,o=a.angle,l=a.ticks,c=ok(l,function(d){return d.coordinate||0}),u=mk(l,function(d){return d.coordinate||0});return{cx:s,cy:i,startAngle:o,endAngle:o,innerRadius:u.coordinate||0,outerRadius:c.coordinate||0}}},{key:"renderAxisLine",value:function(){var a=this.props,s=a.cx,i=a.cy,o=a.angle,l=a.ticks,c=a.axisLine,u=Bh(a,fk),d=l.reduce(function(w,x){return[Math.min(w[0],x.coordinate),Math.max(w[1],x.coordinate)]},[1/0,-1/0]),h=rt(s,i,d[0],o),m=rt(s,i,d[1],o),j=fn(fn(fn({},Oe(u,!1)),{},{fill:"none"},Oe(c,!1)),{},{x1:h.x,y1:h.y,x2:m.x,y2:m.y});return L.createElement("line",Qa({className:"recharts-polar-radius-axis-line"},j))}},{key:"renderTicks",value:function(){var a=this,s=this.props,i=s.ticks,o=s.tick,l=s.angle,c=s.tickFormatter,u=s.stroke,d=Bh(s,pk),h=this.getTickTextAnchor(),m=Oe(d,!1),j=Oe(o,!1),w=i.map(function(x,v){var y=a.getTickValueCoord(x),f=fn(fn(fn(fn({textAnchor:h,transform:"rotate(".concat(90-l,", ").concat(y.x,", ").concat(y.y,")")},m),{},{stroke:"none",fill:u},j),{},{index:v},y),{},{payload:x});return L.createElement(Ke,Qa({className:Le("recharts-polar-radius-axis-tick",Yp(o)),key:"tick-".concat(x.coordinate)},$n(a.props,x,v)),r.renderTickItem(o,f,c?c(x.value,v):x.value))});return L.createElement(Ke,{className:"recharts-polar-radius-axis-ticks"},w)}},{key:"render",value:function(){var a=this.props,s=a.ticks,i=a.axisLine,o=a.tick;return!s||!s.length?null:L.createElement(Ke,{className:Le("recharts-polar-radius-axis",this.props.className)},i&&this.renderAxisLine(),o&&this.renderTicks(),Ct.renderCallByParent(this.props,this.getViewBox()))}}],[{key:"renderTickItem",value:function(a,s,i){var o;return L.isValidElement(a)?o=L.cloneElement(a,s):$e(a)?o=a(s):o=L.createElement(Dn,Qa({},s,{className:"recharts-polar-radius-axis-tick-value"}),i),o}}])}(_.PureComponent);Fo(Bo,"displayName","PolarRadiusAxis");Fo(Bo,"axisType","radiusAxis");Fo(Bo,"defaultProps",{type:"number",radiusAxisId:0,cx:0,cy:0,angle:0,orientation:"right",stroke:"#ccc",axisLine:!0,tick:!0,tickCount:5,allowDataOverflow:!1,scale:"auto",allowDuplicatedCategory:!0});function sa(t){"@babel/helpers - typeof";return sa=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},sa(t)}function jn(){return jn=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},jn.apply(this,arguments)}function Uh(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function pn(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?Uh(Object(n),!0).forEach(function(a){zo(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Uh(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function _k(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function qh(t,r){for(var n=0;n<r.length;n++){var a=r[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,ux(a.key),a)}}function Sk(t,r,n){return r&&qh(t.prototype,r),n&&qh(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function Ok(t,r,n){return r=Ui(r),Ck(t,dx()?Reflect.construct(r,n||[],Ui(t).constructor):r.apply(t,n))}function Ck(t,r){if(r&&(sa(r)==="object"||typeof r=="function"))return r;if(r!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ak(t)}function Ak(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function dx(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(dx=function(){return!!t})()}function Ui(t){return Ui=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Ui(t)}function Pk(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&Cc(t,r)}function Cc(t,r){return Cc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,s){return a.__proto__=s,a},Cc(t,r)}function zo(t,r,n){return r=ux(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function ux(t){var r=kk(t,"string");return sa(r)=="symbol"?r:r+""}function kk(t,r){if(sa(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(sa(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}var Ek=Math.PI/180,Vh=1e-5,Uo=function(t){function r(){return _k(this,r),Ok(this,r,arguments)}return Pk(r,t),Sk(r,[{key:"getTickLineCoord",value:function(a){var s=this.props,i=s.cx,o=s.cy,l=s.radius,c=s.orientation,u=s.tickSize,d=u||8,h=rt(i,o,l,a.coordinate),m=rt(i,o,l+(c==="inner"?-1:1)*d,a.coordinate);return{x1:h.x,y1:h.y,x2:m.x,y2:m.y}}},{key:"getTickTextAnchor",value:function(a){var s=this.props.orientation,i=Math.cos(-a.coordinate*Ek),o;return i>Vh?o=s==="outer"?"start":"end":i<-Vh?o=s==="outer"?"end":"start":o="middle",o}},{key:"renderAxisLine",value:function(){var a=this.props,s=a.cx,i=a.cy,o=a.radius,l=a.axisLine,c=a.axisLineType,u=pn(pn({},Oe(this.props,!1)),{},{fill:"none"},Oe(l,!1));if(c==="circle")return L.createElement(Ro,jn({className:"recharts-polar-angle-axis-line"},u,{cx:s,cy:i,r:o}));var d=this.props.ticks,h=d.map(function(m){return rt(s,i,o,m.coordinate)});return L.createElement(KP,jn({className:"recharts-polar-angle-axis-line"},u,{points:h}))}},{key:"renderTicks",value:function(){var a=this,s=this.props,i=s.ticks,o=s.tick,l=s.tickLine,c=s.tickFormatter,u=s.stroke,d=Oe(this.props,!1),h=Oe(o,!1),m=pn(pn({},d),{},{fill:"none"}
115,Oe(l,!1)),j=i.map(function(w,x){var v=a.getTickLineCoord(w),y=a.getTickTextAnchor(w),f=pn(pn(pn({textAnchor:y},d),{},{stroke:"none",fill:u},h),{},{index:x,payload:w,x:v.x2,y:v.y2});return L.createElement(Ke,jn({className:Le("recharts-polar-angle-axis-tick",Yp(o)),key:"tick-".concat(w.coordinate)},$n(a.props,w,x)),l&&L.createElement("line",jn({className:"recharts-polar-angle-axis-tick-line"},m,v)),o&&r.renderTickItem(o,f,c?c(w.value,x):w.value))});return L.createElement(Ke,{className:"recharts-polar-angle-axis-ticks"},j)}},{key:"render",value:function(){var a=this.props,s=a.ticks,i=a.radius,o=a.axisLine;return i<=0||!s||!s.length?null:L.createElement(Ke,{className:Le("recharts-polar-angle-axis",this.props.className)},o&&this.renderAxisLine(),this.renderTicks())}}],[{key:"renderTickItem",value:function(a,s,i){var o;return L.isValidElement(a)?o=L.cloneElement(a,s):$e(a)?o=a(s):o=L.createElement(Dn,jn({},s,{className:"recharts-polar-angle-axis-tick-value"}),i),o}}])}(_.PureComponent);zo(Uo,"displayName","PolarAngleAxis");zo(Uo,"axisType","angleAxis");zo(Uo,"defaultProps",{type:"category",angleAxisId:0,scale:"auto",cx:0,cy:0,orientation:"outer",axisLine:!0,tickLine:!0,tickSize:8,tick:!0,hide:!1,allowDuplicatedCategory:!0});var Tk=Cg,$k=Tk(Object.getPrototypeOf,Object),Dk=$k,Mk=uo,Ik=Dk,Lk=ho,Rk="[object Object]",Fk=Function.prototype,Bk=Object.prototype,hx=Fk.toString,zk=Bk.hasOwnProperty,Uk=hx.call(Object);function qk(t){if(!Lk(t)||Mk(t)!=Rk)return!1;var r=Ik(t);if(r===null)return!0;var n=zk.call(r,"constructor")&&r.constructor;return typeof n=="function"&&n instanceof n&&hx.call(n)==Uk}var Vk=qk;const Wk=pt(Vk);var Kk=uo,Gk=ho,Hk="[object Boolean]";function Xk(t){return t===!0||t===!1||Gk(t)&&Kk(t)==Hk}var Yk=Xk;const Qk=pt(Yk);function As(t){"@babel/helpers - typeof";return As=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},As(t)}function qi(){return qi=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},qi.apply(this,arguments)}function Zk(t,r){return rE(t)||tE(t,r)||eE(t,r)||Jk()}function Jk(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
116In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function eE(t,r){if(t){if(typeof t=="string")return Wh(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Wh(t,r)}}function Wh(t,r){(r==null||r>t.length)&&(r=t.length);for(var n=0,a=new Array(r);n<r;n++)a[n]=t[n];return a}function tE(t,r){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var a,s,i,o,l=[],c=!0,u=!1;try{if(i=(n=n.call(t)).next,r!==0)for(;!(c=(a=i.call(n)).done)&&(l.push(a.value),l.length!==r);c=!0);}catch(d){u=!0,s=d}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw s}}return l}}function rE(t){if(Array.isArray(t))return t}function Kh(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function Gh(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?Kh(Object(n),!0).forEach(function(a){nE(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Kh(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function nE(t,r,n){return r=aE(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function aE(t){var r=sE(t,"string");return As(r)=="symbol"?r:r+""}function sE(t,r){if(As(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(As(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}var Hh=function(r,n,a,s,i){var o=a-s,l;
vendor: 15,526 bytes, line 116
116return l="M ".concat(r,",").concat(n),l+="L ".concat(r+a,",").concat(n),l+="L ".concat(r+a-o/2,",").concat(n+i),l+="L ".concat(r+a-o/2-s,",").concat(n+i),l+="L ".concat(r,",").concat(n," Z"),l},iE={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},oE=function(r){var n=Gh(Gh({},iE),r),a=_.useRef(),s=_.useState(-1),i=Zk(s,2),o=i[0],l=i[1];_.useEffect(function(){if(a.current&&a.current.getTotalLength)try{var b=a.current.getTotalLength();b&&l(b)}catch{}},[]);var c=n.x,u=n.y,d=n.upperWidth,h=n.lowerWidth,m=n.height,j=n.className,w=n.animationEasing,x=n.animationDuration,v=n.animationBegin,y=n.isUpdateAnimationActive;if(c!==+c||u!==+u||d!==+d||h!==+h||m!==+m||d===0&&h===0||m===0)return null;var f=Le("recharts-trapezoid",j);return y?L.createElement(Rr,{canBegin:o>0,from:{upperWidth:0,lowerWidth:0,height:m,x:c,y:u},to:{upperWidth:d,lowerWidth:h,height:m,x:c,y:u},duration:x,animationEasing:w,isActive:y},function(b){var p=b.upperWidth,g=b.lowerWidth,N=b.height,S=b.x,O=b.y;return L.createElement(Rr,{canBegin:o>0,from:"0px ".concat(o===-1?1:o,"px"),to:"".concat(o,"px 0px"),attributeName:"strokeDasharray",begin:v,duration:x,easing:w},L.createElement("path",qi({},Oe(n,!0),{className:f,d:Hh(S,O,p,g,N),ref:a})))}):L.createElement("g",null,L.createElement("path",qi({},Oe(n,!0),{className:f,d:Hh(c,u,d,h,m)})))},lE=["option","shapeType","propTransformer","activeClassName","isActive"];function Ps(t){"@babel/helpers - typeof";return Ps=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Ps(t)}function cE(t,r){if(t==null)return{};var n=dE(t,r),a,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)a=i[s],!(r.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(t,a)&&(n[a]=t[a])}return n}function dE(t,r){if(t==null)return{};var n={};for(var a in t)if(Object.prototype.hasOwnProperty.call(t,a)){if(r.indexOf(a)>=0)continue;n[a]=t[a]}return n}function Xh(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function Vi(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?Xh(Object(n),!0).forEach(function(a){uE(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Xh(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function uE(t,r,n){return r=hE(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function hE(t){var r=mE(t,"string");return Ps(r)=="symbol"?r:r+""}function mE(t,r){if(Ps(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(Ps(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function fE(t,r){return Vi(Vi({},r),t)}function pE(t,r){return t==="symbols"}function Yh(t){var r=t.shapeType,n=t.elementProps;switch(r){case"rectangle":return L.createElement(Sd,n);case"trapezoid":return L.createElement(oE,n);case"sector":return L.createElement(Jp,n);case"symbols":if(pE(r))return L.createElement(vd,n);break;default:return null}}function xE(t){return _.isValidElement(t)?t.props:t}function mx(t){var r=t.option,n=t.shapeType,a=t.propTransformer,s=a===void 0?fE:a,i=t.activeClassName,o=i===void 0?"recharts-active-shape":i,l=t.isActive,c=cE(t,lE),u;if(_.isValidElement(r))u=_.cloneElement(r,Vi(Vi({},c),xE(r)));else if($e(r))u=r(c);else if(Wk(r)&&!Qk(r)){var d=s(r,c);u=L.createElement(Yh,{shapeType:n,elementProps:d})}else{var h=c;u=L.createElement(Yh,{shapeType:n,elementProps:h})}return l?L.createElement(Ke,{className:o},u):u}function qo(t,r){return r!=null&&"trapezoids"in t.props}function Vo(t,r){return r!=null&&"sectors"in t.props}function ks(t,r){return r!=null&&"points"in t.props}function vE(t,r){var n,a,s=t.x===(r==null||(n=r.labelViewBox)===null||n===void 0?void 0:n.x)||t.x===r.x,i=t.y===(r==null||(a=r.labelViewBox)===null||a===void 0?void 0:a.y)||t.y===r.y;return s&&i}function gE(t,r){var n=t.endAngle===r.endAngle,a=t.startAngle===r.startAngle;return n&&a}function yE(t,r){var n=t.x===r.x,a=t.y===r.y,s=t.z===r.z;return n&&a&&s}function jE(t,r){var n;return qo(t,r)?n=vE:Vo(t,r)?n=gE:ks(t,r)&&(n=yE),n}function bE(t,r){var n;return qo(t,r)?n="trapezoids":Vo(t,r)?n="sectors":ks(t,r)&&(n="points"),n}function wE(t,r){if(qo(t,r)){var n;return(n=r.tooltipPayload)===null||n===void 0||(n=n[0])===null||n===void 0||(n=n.payload)===null||n===void 0?void 0:n.payload}if(Vo(t,r)){var a;return(a=r.tooltipPayload)===null||a===void 0||(a=a[0])===null||a===void 0||(a=a.payload)===null||a===void 0?void 0:a.payload}return ks(t,r)?r.payload:{}}function NE(t){var r=t.activeTooltipItem,n=t.graphicalItem,a=t.itemData,s=bE(n,r),i=wE(n,r),o=a.filter(function(c,u){var d=zs(i,c),h=n.props[s].filter(function(w){var x=jE(n,r);return x(w,r)}),m=n.props[s].indexOf(h[h.length-1]),j=u===m;return d&&j}),l=a.indexOf(o[o.length-1]);return l}var hi;function ia(t){"@babel/helpers - typeof";return ia=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},ia(t)}function Vn(){return Vn=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},Vn.apply(this,arguments)}function Qh(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function et(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?Qh(Object(n),!0).forEach(function(a){xr(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Qh(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function _E(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function Zh(t,r){for(var n=0;n<r.length;n++){var a=r[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,px(a.key),a)}}function SE(t,r,n){return r&&Zh(t.prototype,r),n&&Zh(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function OE(t,r,n){return r=Wi(r),CE(t,fx()?Reflect.construct(r,n||[],Wi(t).constructor):r.apply(t,n))}function CE(t,r){if(r&&(ia(r)==="object"||typeof r=="function"))return r;if(r!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return AE(t)}function AE(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function fx(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(fx=function(){return!!t})()}function Wi(t){return Wi=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Wi(t)}function PE(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&Ac(t,r)}function Ac(t,r){return Ac=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,s){return a.__proto__=s,a},Ac(t,r)}function xr(t,r,n){return r=px(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function px(t){var r=kE(t,"string");return ia(r)=="symbol"?r:r+""}function kE(t,r){if(ia(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(ia(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}var Fr=function(t){function r(n){var a;return _E(this,r),a=OE(this,r,[n]),xr(a,"pieRef",null),xr(a,"sectorRefs",[]),xr(a,"id",Na("recharts-pie-")),xr(a,"handleAnimationEnd",function(){var s=a.props.onAnimationEnd;a.setState({isAnimationFinished:!0}),$e(s)&&s()}),xr(a,"handleAnimationStart",function(){var s=a.props.onAnimationStart;a.setState({isAnimationFinished:!1}),$e(s)&&s()}),a.state={isAnimationFinished:!n.isAnimationActive,prevIsAnimationActive:n.isAnimationActive,prevAnimationId:n.animationId,sectorToFocus:0},a}return PE(r,t),SE(r,[{key:"isActiveIndex",value:function(a){var s=this.props.activeIndex;return Array.isArray(s)?s.indexOf(a)!==-1:a===s}},{key:"hasActiveIndex",value:function(){var a=this.props.activeIndex;return Array.isArray(a)?a.length!==0:a||a===0}},{key:"renderLabels",value:function(a){var s=this.props.isAnimationActive;if(s&&!this.state.isAnimationFinished)return null;var i=this.props,o=i.label,l=i.labelLine,c=i.dataKey,u=i.valueKey,d=Oe(this.props,!1),h=Oe(o,!1),m=Oe(l,!1),j=o&&o.offsetRadius||20,w=a.map(function(x,v){var y=(x.startAngle+x.endAngle)/2,f=rt(x.cx,x.cy,x.outerRadius+j,y),b=et(et(et(et({},d),x),{},{stroke:"none"},h),{},{index:v,textAnchor:r.getTextAnchor(f.x,x.cx)},f),p=et(et(et(et({},d),x),{},{fill:"none",stroke:x.fill},m),{},{index:v,points:[rt(x.cx,x.cy,x.outerRadius,y),f]}),g=c;return Ie(c)&&Ie(u)?g="value":Ie(c)&&(g=u),L.createElement(Ke,{key:"label-".concat(x.startAngle,"-").concat(x.endAngle,"-").concat(x.midAngle,"-").concat(v)},l&&r.renderLabelLineItem(l,p,"line"),r.renderLabelItem(o,b,Nt(x,g)))});return L.createElement(Ke,{className:"recharts-pie-labels"},w)}},{key:"renderSectorsStatically",value:function(a){var s=this,i=this.props,o=i.activeShape,l=i.blendStroke,c=i.inactiveShape;return a.map(function(u,d){if((u==null?void 0:u.startAngle)===0&&(u==null?void 0:u.endAngle)===0&&a.length!==1)return null;var h=s.isActiveIndex(d),m=c&&s.hasActiveIndex()?c:null,j=h?o:m,w=et(et({},u),{},{stroke:l?u.fill:u.stroke,tabIndex:-1});return L.createElement(Ke,Vn({ref:function(v){v&&!s.sectorRefs.includes(v)&&s.sectorRefs.push(v)},tabIndex:-1,className:"recharts-pie-sector"},$n(s.props,u,d),{key:"sector-".concat(u==null?void 0:u.startAngle,"-").concat(u==null?void 0:u.endAngle,"-").concat(u.midAngle,"-").concat(d)}),L.createElement(mx,Vn({option:j,isActive:h,shapeType:"sector"},w)))})}},{key:"renderSectorsWithAnimation",value:function(){var a=this,s=this.props,i=s.sectors,o=s.isAnimationActive,l=s.animationBegin,c=s.animationDuration,u=s.animationEasing,d=s.animationId,h=this.state,m=h.prevSectors,j=h.prevIsAnimationActive;return L.createElement(Rr,{begin:l,duration:c,isActive:o,easing:u,from:{t:0},to:{t:1},key:"pie-".concat(d,"-").concat(j),onAnimationStart:this.handleAnimationStart,onAnimationEnd:this.handleAnimationEnd},function(w){var x=w.t,v=[],y=i&&i[0],f=y.startAngle;return i.forEach(function(b,p){var g=m&&m[p],N=p>0?Jt(b,"paddingAngle",0):0;if(g){var S=Xt(g.endAngle-g.startAngle,b.endAngle-b.startAngle),O=et(et({},b),{},{startAngle:f+N,endAngle:f+S(x)+N});v.push(O),f=O.endAngle}else{var C=b.endAngle,P=b.startAngle,$=Xt(0,C-P),A=$(x),I=et(et({},b),{},{startAngle:f+N,endAngle:f+A+N});v.push(I),f=I.endAngle}}),L.createElement(Ke,null,a.renderSectorsStatically(v))})}},{key:"attachKeyboardHandlers",value:function(a){var s=this;a.onkeydown=function(i){if(!i.altKey)switch(i.key){case"ArrowLeft":{var o=++s.state.sectorToFocus%s.sectorRefs.length;s.sectorRefs[o].focus(),s.setState({sectorToFocus:o});break}case"ArrowRight":{var l=--s.state.sectorToFocus<0?s.sectorRefs.length-1:s.state.sectorToFocus%s.sectorRefs.length;s.sectorRefs[l].focus(),s.setState({sectorToFocus:l});break}case"Escape":{s.sectorRefs[s.state.sectorToFocus].blur(),s.setState({sectorToFocus:0});break}}}}},{key:"renderSectors",value:function(){var a=this.props,s=a.sectors,i=a.isAnimationActive,o=this.state.prevSectors;return i&&s&&s.length&&(!o||!zs(o,s))?this.renderSectorsWithAnimation():this.renderSectorsStatically(s)}},{key:"componentDidMount",value:function(){this.pieRef&&this.attachKeyboardHandlers(this.pieRef)}},{key:"render",value:function(){var a=this,s=this.props,i=s.hide,o=s.sectors,l=s.className,c=s.label,u=s.cx,d=s.cy,h=s.innerRadius,m=s.outerRadius,j=s.isAnimationActive,w=this.state.isAnimationFinished;if(i||!o||!o.length||!me(u)||!me(d)||!me(h)||!me(m))return null;var x=Le("recharts-pie",l);return L.createElement(Ke,{tabIndex:this.props.rootTabIndex,className:x,ref:function(y){a.pieRef=y}},this.renderSectors(),c&&this.renderLabels(o),Ct.renderCallByParent(this.props,null,!1),(!j||w)&&Yr.renderCallByParent(this.props,o,!1))}}],[{key:"getDerivedStateFromProps",value:function(a,s){return s.prevIsAnimationActive!==a.isAnimationActive?{prevIsAnimationActive:a.isAnimationActive,prevAnimationId:a.animationId,curSectors:a.sectors,prevSectors:[],isAnimationFinished:!0}:a.isAnimationActive&&a.animationId!==s.prevAnimationId?{prevAnimationId:a.animationId,curSectors:a.sectors,prevSectors:s.curSectors,isAnimationFinished:!0}:a.sectors!==s.curSectors?{curSectors:a.sectors,isAnimationFinished:!0}:null}},{key:"getTextAnchor",value:function(a,s){return a>s?"start":a<s?"end":"middle"}},{key:"renderLabelLineItem",value:function(a,s,i){if(L.isValidElement(a))return L.cloneElement(a,s);if($e(a))return a(s);var o=Le("recharts-pie-label-line",typeof a!="boolean"?a.className:"");return L.createElement(Ii,Vn({},s,{key:i,type:"linear",className:o}))}},{key:"renderLabelItem",value:function(a,s,i){if(L.isValidElement(a))return L.cloneElement(a,s);var o=i;if($e(a)&&(o=a(s),L.isValidElement(o)))return o;var l=Le("recharts-pie-label-text",typeof a!="boolean"&&!$e(a)?a.className:"");return L.createElement(Dn,Vn({},s,{alignmentBaseline:"middle",className:l}),o)}}])}(_.PureComponent);hi=Fr;xr(Fr,"displayName","Pie");xr(Fr,"defaultProps",{stroke:"#fff",fill:"#808080",legendType:"rect",cx:"50%",cy:"50%",startAngle:0,endAngle:360,innerRadius:0,outerRadius:"80%",paddingAngle:0,labelLine:!0,hide:!1,minAngle:0,isAnimationActive:!Er.isSsr,animationBegin:400,animationDuration:1500,animationEasing:"ease",nameKey:"name",blendStroke:!1,rootTabIndex:0});xr(Fr,"parseDeltaAngle",function(t,r){var n=Rt(r-t),a=Math.min(Math.abs(r-t),360);return n*a});xr(Fr,"getRealPieData",function(t){var r=t.data,n=t.children,a=Oe(t,!1),s=er(n,us);return r&&r.length?r.map(function(i,o){return et(et(et({payload:i},a),i),s&&s[o]&&s[o].props)}):s&&s.length?s.map(function(i){return et(et({},a),i.props)}):[]});xr(Fr,"parseCoordinateOfPie",function(t,r){var n=r.top,a=r.left,s=r.width,i=r.height,o=Xp(s,i),l=a+Ft(t.cx,s,s/2),c=n+Ft(t.cy,i,i/2),u=Ft(t.innerRadius,o,0),d=Ft(t.outerRadius,o,o*.8),h=t.maxRadius||Math.sqrt(s*s+i*i)/2;return{cx:l,cy:c,innerRadius:u,outerRadius:d,maxRadius:h}});xr(Fr,"getComposedData",function(t){var r=t.item,n=t.offset,a=r.type.defaultProps!==void 0?et(et({},r.type.defaultProps),r.props):r.props,s=hi.getRealPieData(a);if(!s||!s.length)return null;var i=a.cornerRadius,o=a.startAngle,l=a.endAngle,c=a.paddingAngle,u=a.dataKey,d=a.nameKey,h=a.valueKey,m=a.tooltipType,j=Math.abs(a.minAngle),w=hi.parseCoordinateOfPie(a,n),x=hi.parseDeltaAngle(o,l),v=Math.abs(x),y=u;Ie(u)&&Ie(h)?(Sr(!1,`Use "dataKey" to specify the value of pie,
117      the props "valueKey" will be deprecated in 1.1.0`),y="value"):Ie(u)&&(Sr(!1,`Use "dataKey" to specify the value of pie,
118      the props "valueKey" will be deprecated in 1.1.0`),y=h);var f=s.filter(function(O){return Nt(O,y,0)!==0}).length,b=(v>=360?f:f-1)*c,p=v-f*j-b,g=s.reduce(function(O,C){var P=Nt(C,y,0);return O+(me(P)?P:0)},0),N;if(g>0){var S;N=s.map(function(O,C){var P=Nt(O,y,0),$=Nt(O,d,C),A=(me(P)?P:0)/g,I;C?I=S.endAngle+Rt(x)*c*(P!==0?1:0):I=o;var D=I+Rt(x)*((P!==0?j:0)+A*p),q=(I+D)/2,F=(w.innerRadius+w.outerRadius)/2,K=[{name:$,value:P,payload:O,dataKey:y,type:m}],M=rt(w.cx,w.cy,F,q);return S=et(et(et({percent:A,cornerRadius:i,name:$,tooltipPayload:K,midAngle:q,middleRadius:F,tooltipPosition:M},O),w),{},{value:Nt(O,y),startAngle:I,endAngle:D,payload:O,paddingAngle:Rt(x)*c}),S})}return et(et({},w),{},{sectors:N,data:s})});var EE=Math.ceil,TE=Math.max;function $E(t,r,n,a){for(var s=-1,i=TE(EE((r-t)/(n||1)),0),o=Array(i);i--;)o[a?i:++s]=t,t+=n;return o}var DE=$E,ME=lg,Jh=1/0,IE=17976931348623157e292;function LE(t){if(!t)return t===0?t:0;if(t=ME(t),t===Jh||t===-Jh){var r=t<0?-1:1;return r*IE}return t===t?t:0}var xx=LE,RE=DE,FE=To,fl=xx;function BE(t){return function(r,n,a){return a&&typeof a!="number"&&FE(r,n,a)&&(n=a=void 0),r=fl(r),n===void 0?(n=r,r=0):n=fl(n),a=a===void 0?r<n?1:-1:fl(a),RE(r,n,a,t)}}var zE=BE,UE=zE,qE=UE(),VE=qE;const Ki=pt(VE);function Es(t){"@babel/helpers - typeof";return Es=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Es(t)}function em(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function tm(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?em(Object(n),!0).forEach(function(a){vx(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):em(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function vx(t,r,n){return r=WE(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function WE(t){var r=KE(t,"string");return Es(r)=="symbol"?r:r+""}function KE(t,r){if(Es(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(Es(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}var GE=["Webkit","Moz","O","ms"],HE=function(r,n){var a=r.replace(/(\w)/,function(i){return i.toUpperCase()}),s=GE.reduce(function(i,o){return tm(tm({},i),{},vx({},o+a,n))},{});return s[r]=n,s};function oa(t){"@babel/helpers - typeof";return oa=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},oa(t)}function Gi(){return Gi=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},Gi.apply(this,arguments)}function rm(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function pl(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?rm(Object(n),!0).forEach(function(a){Kt(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):rm(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function XE(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function nm(t,r){for(var n=0;n<r.length;n++){var a=r[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,yx(a.key),a)}}function YE(t,r,n){return r&&nm(t.prototype,r),n&&nm(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function QE(t,r,n){return r=Hi(r),ZE(t,gx()?Reflect.construct(r,n||[],Hi(t).constructor):r.apply(t,n))}function ZE(t,r){if(r&&(oa(r)==="object"||typeof r=="function"))return r;if(r!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return JE(t)}function JE(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function gx(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(gx=function(){return!!t})()}
vendor: 9,759 bytes, line 118
118function Hi(t){return Hi=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Hi(t)}function e2(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&Pc(t,r)}function Pc(t,r){return Pc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,s){return a.__proto__=s,a},Pc(t,r)}function Kt(t,r,n){return r=yx(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function yx(t){var r=t2(t,"string");return oa(r)=="symbol"?r:r+""}function t2(t,r){if(oa(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(oa(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}var r2=function(r){var n=r.data,a=r.startIndex,s=r.endIndex,i=r.x,o=r.width,l=r.travellerWidth;if(!n||!n.length)return{};var c=n.length,u=Ia().domain(Ki(0,c)).range([i,i+o-l]),d=u.domain().map(function(h){return u(h)});return{isTextActive:!1,isSlideMoving:!1,isTravellerMoving:!1,isTravellerFocused:!1,startX:u(a),endX:u(s),scale:u,scaleValues:d}},am=function(r){return r.changedTouches&&!!r.changedTouches.length},la=function(t){function r(n){var a;return XE(this,r),a=QE(this,r,[n]),Kt(a,"handleDrag",function(s){a.leaveTimer&&(clearTimeout(a.leaveTimer),a.leaveTimer=null),a.state.isTravellerMoving?a.handleTravellerMove(s):a.state.isSlideMoving&&a.handleSlideDrag(s)}),Kt(a,"handleTouchMove",function(s){s.changedTouches!=null&&s.changedTouches.length>0&&a.handleDrag(s.changedTouches[0])}),Kt(a,"handleDragEnd",function(){a.setState({isTravellerMoving:!1,isSlideMoving:!1},function(){var s=a.props,i=s.endIndex,o=s.onDragEnd,l=s.startIndex;o==null||o({endIndex:i,startIndex:l})}),a.detachDragEndListener()}),Kt(a,"handleLeaveWrapper",function(){(a.state.isTravellerMoving||a.state.isSlideMoving)&&(a.leaveTimer=window.setTimeout(a.handleDragEnd,a.props.leaveTimeOut))}),Kt(a,"handleEnterSlideOrTraveller",function(){a.setState({isTextActive:!0})}),Kt(a,"handleLeaveSlideOrTraveller",function(){a.setState({isTextActive:!1})}),Kt(a,"handleSlideDragStart",function(s){var i=am(s)?s.changedTouches[0]:s;a.setState({isTravellerMoving:!1,isSlideMoving:!0,slideMoveStartX:i.pageX}),a.attachDragEndListener()}),a.travellerDragStartHandlers={startX:a.handleTravellerDragStart.bind(a,"startX"),endX:a.handleTravellerDragStart.bind(a,"endX")},a.state={},a}return e2(r,t),YE(r,[{key:"componentWillUnmount",value:function(){this.leaveTimer&&(clearTimeout(this.leaveTimer),this.leaveTimer=null),this.detachDragEndListener()}},{key:"getIndex",value:function(a){var s=a.startX,i=a.endX,o=this.state.scaleValues,l=this.props,c=l.gap,u=l.data,d=u.length-1,h=Math.min(s,i),m=Math.max(s,i),j=r.getIndexInRange(o,h),w=r.getIndexInRange(o,m);return{startIndex:j-j%c,endIndex:w===d?d:w-w%c}}},{key:"getTextOfTick",value:function(a){var s=this.props,i=s.data,o=s.tickFormatter,l=s.dataKey,c=Nt(i[a],l,a);return $e(o)?o(c,a):c}},{key:"attachDragEndListener",value:function(){window.addEventListener("mouseup",this.handleDragEnd,!0),window.addEventListener("touchend",this.handleDragEnd,!0),window.addEventListener("mousemove",this.handleDrag,!0)}},{key:"detachDragEndListener",value:function(){window.removeEventListener("mouseup",this.handleDragEnd,!0),window.removeEventListener("touchend",this.handleDragEnd,!0),window.removeEventListener("mousemove",this.handleDrag,!0)}},{key:"handleSlideDrag",value:function(a){var s=this.state,i=s.slideMoveStartX,o=s.startX,l=s.endX,c=this.props,u=c.x,d=c.width,h=c.travellerWidth,m=c.startIndex,j=c.endIndex,w=c.onChange,x=a.pageX-i;x>0?x=Math.min(x,u+d-h-l,u+d-h-o):x<0&&(x=Math.max(x,u-o,u-l));var v=this.getIndex({startX:o+x,endX:l+x});(v.startIndex!==m||v.endIndex!==j)&&w&&w(v),this.setState({startX:o+x,endX:l+x,slideMoveStartX:a.pageX})}},{key:"handleTravellerDragStart",value:function(a,s){var i=am(s)?s.changedTouches[0]:s;this.setState({isSlideMoving:!1,isTravellerMoving:!0,movingTravellerId:a,brushMoveStartX:i.pageX}),this.attachDragEndListener()}},{key:"handleTravellerMove",value:function(a){var s=this.state,i=s.brushMoveStartX,o=s.movingTravellerId,l=s.endX,c=s.startX,u=this.state[o],d=this.props,h=d.x,m=d.width,j=d.travellerWidth,w=d.onChange,x=d.gap,v=d.data,y={startX:this.state.startX,endX:this.state.endX},f=a.pageX-i;f>0?f=Math.min(f,h+m-j-u):f<0&&(f=Math.max(f,h-u)),y[o]=u+f;var b=this.getIndex(y),p=b.startIndex,g=b.endIndex,N=function(){var O=v.length-1;return o==="startX"&&(l>c?p%x===0:g%x===0)||l<c&&g===O||o==="endX"&&(l>c?g%x===0:p%x===0)||l>c&&g===O};this.setState(Kt(Kt({},o,u+f),"brushMoveStartX",a.pageX),function(){w&&N()&&w(b)})}},{key:"handleTravellerMoveKeyboard",value:function(a,s){var i=this,o=this.state,l=o.scaleValues,c=o.startX,u=o.endX,d=this.state[s],h=l.indexOf(d);if(h!==-1){var m=h+a;if(!(m===-1||m>=l.length)){var j=l[m];s==="startX"&&j>=u||s==="endX"&&j<=c||this.setState(Kt({},s,j),function(){i.props.onChange(i.getIndex({startX:i.state.startX,endX:i.state.endX}))})}}}},{key:"renderBackground",value:function(){var a=this.props,s=a.x,i=a.y,o=a.width,l=a.height,c=a.fill,u=a.stroke;return L.createElement("rect",{stroke:u,fill:c,x:s,y:i,width:o,height:l})}},{key:"renderPanorama",value:function(){var a=this.props,s=a.x,i=a.y,o=a.width,l=a.height,c=a.data,u=a.children,d=a.padding,h=_.Children.only(u);return h?L.cloneElement(h,{x:s,y:i,width:o,height:l,margin:d,compact:!0,data:c}):null}},{key:"renderTravellerLayer",value:function(a,s){var i,o,l=this,c=this.props,u=c.y,d=c.travellerWidth,h=c.height,m=c.traveller,j=c.ariaLabel,w=c.data,x=c.startIndex,v=c.endIndex,y=Math.max(a,this.props.x),f=pl(pl({},Oe(this.props,!1)),{},{x:y,y:u,width:d,height:h}),b=j||"Min value: ".concat((i=w[x])===null||i===void 0?void 0:i.name,", Max value: ").concat((o=w[v])===null||o===void 0?void 0:o.name);return L.createElement(Ke,{tabIndex:0,role:"slider","aria-label":b,"aria-valuenow":a,className:"recharts-brush-traveller",onMouseEnter:this.handleEnterSlideOrTraveller,onMouseLeave:this.handleLeaveSlideOrTraveller,onMouseDown:this.travellerDragStartHandlers[s],onTouchStart:this.travellerDragStartHandlers[s],onKeyDown:function(g){["ArrowLeft","ArrowRight"].includes(g.key)&&(g.preventDefault(),g.stopPropagation(),l.handleTravellerMoveKeyboard(g.key==="ArrowRight"?1:-1,s))},onFocus:function(){l.setState({isTravellerFocused:!0})},onBlur:function(){l.setState({isTravellerFocused:!1})},style:{cursor:"col-resize"}},r.renderTraveller(m,f))}},{key:"renderSlide",value:function(a,s){var i=this.props,o=i.y,l=i.height,c=i.stroke,u=i.travellerWidth,d=Math.min(a,s)+u,h=Math.max(Math.abs(s-a)-u,0);return L.createElement("rect",{className:"recharts-brush-slide",onMouseEnter:this.handleEnterSlideOrTraveller,onMouseLeave:this.handleLeaveSlideOrTraveller,onMouseDown:this.handleSlideDragStart,onTouchStart:this.handleSlideDragStart,style:{cursor:"move"},stroke:"none",fill:c,fillOpacity:.2,x:d,y:o,width:h,height:l})}},{key:"renderText",value:function(){var a=this.props,s=a.startIndex,i=a.endIndex,o=a.y,l=a.height,c=a.travellerWidth,u=a.stroke,d=this.state,h=d.startX,m=d.endX,j=5,w={pointerEvents:"none",fill:u};return L.createElement(Ke,{className:"recharts-brush-texts"},L.createElement(Dn,Gi({textAnchor:"end",verticalAnchor:"middle",x:Math.min(h,m)-j,y:o+l/2},w),this.getTextOfTick(s)),L.createElement(Dn,Gi({textAnchor:"start",verticalAnchor:"middle",x:Math.max(h,m)+c+j,y:o+l/2},w),this.getTextOfTick(i)))}},{key:"render",value:function(){var a=this.props,s=a.data,i=a.className,o=a.children,l=a.x,c=a.y,u=a.width,d=a.height,h=a.alwaysShowText,m=this.state,j=m.startX,w=m.endX,x=m.isTextActive,v=m.isSlideMoving,y=m.isTravellerMoving,f=m.isTravellerFocused;if(!s||!s.length||!me(l)||!me(c)||!me(u)||!me(d)||u<=0||d<=0)return null;var b=Le("recharts-brush",i),p=L.Children.count(o)===1,g=HE("userSelect","none");return L.createElement(Ke,{className:b,onMouseLeave:this.handleLeaveWrapper,onTouchMove:this.handleTouchMove,style:g},this.renderBackground(),p&&this.renderPanorama(),this.renderSlide(j,w),this.renderTravellerLayer(j,"startX"),this.renderTravellerLayer(w,"endX"),(x||v||y||f||h)&&this.renderText())}}],[{key:"renderDefaultTraveller",value:function(a){var s=a.x,i=a.y,o=a.width,l=a.height,c=a.stroke,u=Math.floor(i+l/2)-1;return L.createElement(L.Fragment,null,L.createElement("rect",{x:s,y:i,width:o,height:l,fill:c,stroke:"none"}),L.createElement("line",{x1:s+1,y1:u,x2:s+o-1,y2:u,fill:"none",stroke:"#fff"}),L.createElement("line",{x1:s+1,y1:u+2,x2:s+o-1,y2:u+2,fill:"none",stroke:"#fff"}))}},{key:"renderTraveller",value:function(a,s){var i;return L.isValidElement(a)?i=L.cloneElement(a,s):$e(a)?i=a(s):i=r.renderDefaultTraveller(s),i}},{key:"getDerivedStateFromProps",value:function(a,s){var i=a.data,o=a.width,l=a.x,c=a.travellerWidth,u=a.updateId,d=a.startIndex,h=a.endIndex;if(i!==s.prevData||u!==s.prevUpdateId)return pl({prevData:i,prevTravellerWidth:c,prevUpdateId:u,prevX:l,prevWidth:o},i&&i.length?r2({data:i,width:o,x:l,travellerWidth:c,startIndex:d,endIndex:h}):{scale:null,scaleValues:null});if(s.scale&&(o!==s.prevWidth||l!==s.prevX||c!==s.prevTravellerWidth)){s.scale.range([l,l+o-c]);var m=s.scale.domain().map(function(j){return s.scale(j)});return{prevData:i,prevTravellerWidth:c,prevUpdateId:u,prevX:l,prevWidth:o,startX:s.scale(a.startIndex),endX:s.scale(a.endIndex),scaleValues:m}}return null}},{key:"getIndexInRange",value:function(a,s){for(var i=a.length,o=0,l=i-1;l-o>1;){var c=Math.floor((o+l)/2);a[c]>s?l=c:o=c}return s>=a[l]?l:o}}])}(_.PureComponent);
118Kt(la,"displayName","Brush");Kt(la,"defaultProps",{height:40,travellerWidth:5,gap:1,fill:"#fff",stroke:"#666",padding:{top:1,right:1,bottom:1,left:1},leaveTimeOut:1e3,alwaysShowText:!1});var n2=yd;function a2(t,r){var n;return n2(t,function(a,s,i){return n=r(a,s,i),!n}),!!n}var s2=a2,i2=Ag,o2=qr,l2=s2,c2=Or,d2=To;function u2(t,r,n){var a=c2(t)?i2:l2;return n&&d2(t,r,n)&&(r=void 0),a(t,o2(r))}var h2=u2;const m2=pt(h2);var Tr=function(r,n){var a=r.alwaysShow,s=r.ifOverflow;return a&&(s="extendDomain"),s===n},sm=up;function f2(t,r,n){r=="__proto__"&&sm?sm(t,r,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[r]=n}var p2=f2,x2=p2,v2=cp,g2=qr;function y2(t,r){var n={};return r=g2(r),v2(t,function(a,s,i){x2(n,s,r(a,s,i))}),n}var j2=y2;const b2=pt(j2);function w2(t,r){for(var n=-1,a=t==null?0:t.length;++n<a;)if(!r(t[n],n,t))return!1;return!0}var N2=w2,_2=yd;function S2(t,r){var n=!0;return _2(t,function(a,s,i){return n=!!r(a,s,i),n}),n}var O2=S2,C2=N2,A2=O2,P2=qr,k2=Or,E2=To;function T2(t,r,n){var a=k2(t)?C2:A2;return n&&E2(t,r,n)&&(r=void 0),a(t,P2(r))}var $2=T2;const jx=pt($2);var D2=["x","y"];function Ts(t){"@babel/helpers - typeof";return Ts=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Ts(t)}function kc(){return kc=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},kc.apply(this,arguments)}function im(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function $a(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?im(Object(n),!0).forEach(function(a){M2(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):im(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function M2(t,r,n){return r=I2(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function I2(t){var r=L2(t,"string");return Ts(r)=="symbol"?r:r+""}function L2(t,r){if(Ts(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(Ts(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function R2(t,r){if(t==null)return{};var n=F2(t,r),a,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)a=i[s],!(r.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(t,a)&&(n[a]=t[a])}return n}function F2(t,r){if(t==null)return{};var n={};for(var a in t)if(Object.prototype.hasOwnProperty.call(t,a)){if(r.indexOf(a)>=0)continue;n[a]=t[a]}return n}function B2(t,r){var n=t.x,a=t.y,s=R2(t,D2),i="".concat(n),o=parseInt(i,10),l="".concat(a),c=parseInt(l,10),u="".concat(r.height||s.height),d=parseInt(u,10),h="".concat(r.width||s.width),m=parseInt(h,10);return $a($a($a($a($a({},r),s),o?{x:o}:{}),c?{y:c}:{}),{},{height:d,width:m,name:r.name,radius:r.radius})}function om(t){return L.createElement(mx,kc({shapeType:"rectangle",propTransformer:B2,activeClassName:"recharts-active-bar"},t))}var z2=function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return function(a,s){if(typeof r=="number")return r;var i=typeof a=="number";return i?r(a,s):(i||In(),n)}},U2=["value","background"],bx;function ca(t){"@babel/helpers - typeof";return ca=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},ca(t)}function q2(t,r){if(t==null)return{};var n=V2(t,r),a,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)a=i[s],!(r.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(t,a)&&(n[a]=t[a])}return n}function V2(t,r){if(t==null)return{};var n={};for(var a in t)if(Object.prototype.hasOwnProperty.call(t,a)){if(r.indexOf(a)>=0)continue;n[a]=t[a]}return n}function Xi(){return Xi=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},Xi.apply(this,arguments)}function lm(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function jt(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};
vendor: 13,212 bytes, line 118
118r%2?lm(Object(n),!0).forEach(function(a){nn(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):lm(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function W2(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function cm(t,r){for(var n=0;n<r.length;n++){var a=r[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,Nx(a.key),a)}}function K2(t,r,n){return r&&cm(t.prototype,r),n&&cm(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function G2(t,r,n){return r=Yi(r),H2(t,wx()?Reflect.construct(r,n||[],Yi(t).constructor):r.apply(t,n))}function H2(t,r){if(r&&(ca(r)==="object"||typeof r=="function"))return r;if(r!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return X2(t)}function X2(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function wx(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(wx=function(){return!!t})()}function Yi(t){return Yi=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Yi(t)}function Y2(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&Ec(t,r)}function Ec(t,r){return Ec=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,s){return a.__proto__=s,a},Ec(t,r)}function nn(t,r,n){return r=Nx(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function Nx(t){var r=Q2(t,"string");return ca(r)=="symbol"?r:r+""}function Q2(t,r){if(ca(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(ca(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}var Rn=function(t){function r(){var n;W2(this,r);for(var a=arguments.length,s=new Array(a),i=0;i<a;i++)s[i]=arguments[i];return n=G2(this,r,[].concat(s)),nn(n,"state",{isAnimationFinished:!1}),nn(n,"id",Na("recharts-bar-")),nn(n,"handleAnimationEnd",function(){var o=n.props.onAnimationEnd;n.setState({isAnimationFinished:!0}),o&&o()}),nn(n,"handleAnimationStart",function(){var o=n.props.onAnimationStart;n.setState({isAnimationFinished:!1}),o&&o()}),n}return Y2(r,t),K2(r,[{key:"renderRectanglesStatically",value:function(a){var s=this,i=this.props,o=i.shape,l=i.dataKey,c=i.activeIndex,u=i.activeBar,d=Oe(this.props,!1);return a&&a.map(function(h,m){var j=m===c,w=j?u:o,x=jt(jt(jt({},d),h),{},{isActive:j,option:w,index:m,dataKey:l,onAnimationStart:s.handleAnimationStart,onAnimationEnd:s.handleAnimationEnd});return L.createElement(Ke,Xi({className:"recharts-bar-rectangle"},$n(s.props,h,m),{key:"rectangle-".concat(h==null?void 0:h.x,"-").concat(h==null?void 0:h.y,"-").concat(h==null?void 0:h.value)}),L.createElement(om,x))})}},{key:"renderRectanglesWithAnimation",value:function(){var a=this,s=this.props,i=s.data,o=s.layout,l=s.isAnimationActive,c=s.animationBegin,u=s.animationDuration,d=s.animationEasing,h=s.animationId,m=this.state.prevData;return L.createElement(Rr,{begin:c,duration:u,isActive:l,easing:d,from:{t:0},to:{t:1},key:"bar-".concat(h),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(j){var w=j.t,x=i.map(function(v,y){var f=m&&m[y];if(f){var b=Xt(f.x,v.x),p=Xt(f.y,v.y),g=Xt(f.width,v.width),N=Xt(f.height,v.height);return jt(jt({},v),{},{x:b(w),y:p(w),width:g(w),height:N(w)})}if(o==="horizontal"){var S=Xt(0,v.height),O=S(w);return jt(jt({},v),{},{y:v.y+v.height-O,height:O})}var C=Xt(0,v.width),P=C(w);return jt(jt({},v),{},{width:P})});return L.createElement(Ke,null,a.renderRectanglesStatically(x))})}},{key:"renderRectangles",value:function(){var a=this.props,s=a.data,i=a.isAnimationActive,o=this.state.prevData;return i&&s&&s.length&&(!o||!zs(o,s))?this.renderRectanglesWithAnimation():this.renderRectanglesStatically(s)}},{key:"renderBackground",value:function(){var a=this,s=this.props,i=s.data,o=s.dataKey,l=s.activeIndex,c=Oe(this.props.background,!1);return i.map(function(u,d){u.value;var h=u.background,m=q2(u,U2);if(!h)return null;var j=jt(jt(jt(jt(jt({},m),{},{fill:"#eee"},h),c),$n(a.props,u,d)),{},{onAnimationStart:a.handleAnimationStart,onAnimationEnd:a.handleAnimationEnd,dataKey:o,index:d,className:"recharts-bar-background-rectangle"});return L.createElement(om,Xi({key:"background-bar-".concat(d),option:a.props.background,isActive:d===l},j))})}},{key:"renderErrorBar",value:function(a,s){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var i=this.props,o=i.data,l=i.xAxis,c=i.yAxis,u=i.layout,d=i.children,h=er(d,Vs);if(!h)return null;var m=u==="vertical"?o[0].height/2:o[0].width/2,j=function(v,y){var f=Array.isArray(v.value)?v.value[1]:v.value;return{x:v.x,y:v.y,value:f,errorVal:Nt(v,y)}},w={clipPath:a?"url(#clipPath-".concat(s,")"):null};return L.createElement(Ke,w,h.map(function(x){return L.cloneElement(x,{key:"error-bar-".concat(s,"-").concat(x.props.dataKey),data:o,xAxis:l,yAxis:c,layout:u,offset:m,dataPointFormatter:j})}))}},{key:"render",value:function(){var a=this.props,s=a.hide,i=a.data,o=a.className,l=a.xAxis,c=a.yAxis,u=a.left,d=a.top,h=a.width,m=a.height,j=a.isAnimationActive,w=a.background,x=a.id;if(s||!i||!i.length)return null;var v=this.state.isAnimationFinished,y=Le("recharts-bar",o),f=l&&l.allowDataOverflow,b=c&&c.allowDataOverflow,p=f||b,g=Ie(x)?this.id:x;return L.createElement(Ke,{className:y},f||b?L.createElement("defs",null,L.createElement("clipPath",{id:"clipPath-".concat(g)},L.createElement("rect",{x:f?u:u-h/2,y:b?d:d-m/2,width:f?h:h*2,height:b?m:m*2}))):null,L.createElement(Ke,{className:"recharts-bar-rectangles",clipPath:p?"url(#clipPath-".concat(g,")"):null},w?this.renderBackground():null,this.renderRectangles()),this.renderErrorBar(p,g),(!j||v)&&Yr.renderCallByParent(this.props,i))}}],[{key:"getDerivedStateFromProps",value:function(a,s){return a.animationId!==s.prevAnimationId?{prevAnimationId:a.animationId,curData:a.data,prevData:s.curData}:a.data!==s.curData?{curData:a.data}:null}}])}(_.PureComponent);bx=Rn;nn(Rn,"displayName","Bar");nn(Rn,"defaultProps",{xAxisId:0,yAxisId:0,legendType:"rect",minPointSize:0,hide:!1,data:[],layout:"vertical",activeBar:!1,isAnimationActive:!Er.isSsr,animationBegin:0,animationDuration:400,animationEasing:"ease"});nn(Rn,"getComposedData",function(t){var r=t.props,n=t.item,a=t.barPosition,s=t.bandSize,i=t.xAxis,o=t.yAxis,l=t.xAxisTicks,c=t.yAxisTicks,u=t.stackedData,d=t.dataStartIndex,h=t.displayedData,m=t.offset,j=KO(a,n);if(!j)return null;var w=r.layout,x=n.type.defaultProps,v=x!==void 0?jt(jt({},x),n.props):n.props,y=v.dataKey,f=v.children,b=v.minPointSize,p=w==="horizontal"?o:i,g=u?p.scale.domain():null,N=JO({numericAxis:p}),S=er(f,us),O=h.map(function(C,P){var $,A,I,D,q,F;u?$=GO(u[d+P],g):($=Nt(C,y),Array.isArray($)||($=[N,$]));var K=z2(b,bx.defaultProps.minPointSize)($[1],P);if(w==="horizontal"){var M,E=[o.scale($[0]),o.scale($[1])],Q=E[0],H=E[1];A=Zu({axis:i,ticks:l,bandSize:s,offset:j.offset,entry:C,index:P}),I=(M=H??Q)!==null&&M!==void 0?M:void 0,D=j.size;var V=Q-H;if(q=Number.isNaN(V)?0:V,F={x:A,y:o.y,width:D,height:o.height},Math.abs(K)>0&&Math.abs(q)<Math.abs(K)){var se=Rt(q||K)*(Math.abs(K)-Math.abs(q));I-=se,q+=se}}else{var ue=[i.scale($[0]),i.scale($[1])],z=ue[0],he=ue[1];if(A=z,I=Zu({axis:o,ticks:c,bandSize:s,offset:j.offset,entry:C,index:P}),D=he-z,q=j.size,F={x:i.x,y:I,width:i.width,height:q},Math.abs(K)>0&&Math.abs(D)<Math.abs(K)){var ne=Rt(D||K)*(Math.abs(K)-Math.abs(D));D+=ne}}return jt(jt(jt({},C),{},{x:A,y:I,width:D,height:q,value:u?$:$[1],payload:C,background:F},S&&S[P]&&S[P].props),{},{tooltipPayload:[Gp(n,C)],tooltipPosition:{x:A+D/2,y:I+q/2}})});return jt({data:O,layout:w},m)});function $s(t){"@babel/helpers - typeof";return $s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},$s(t)}function Z2(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function dm(t,r){for(var n=0;n<r.length;n++){var a=r[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,_x(a.key),a)}}function J2(t,r,n){return r&&dm(t.prototype,r),n&&dm(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function um(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function br(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?um(Object(n),!0).forEach(function(a){Wo(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):um(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function Wo(t,r,n){return r=_x(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function _x(t){var r=eT(t,"string");return $s(r)=="symbol"?r:r+""}function eT(t,r){if($s(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if($s(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}var Sx=function(r,n,a,s,i){var o=r.width,l=r.height,c=r.layout,u=r.children,d=Object.keys(n),h={left:a.left,leftMirror:a.left,right:o-a.right,rightMirror:o-a.right,top:a.top,topMirror:a.top,bottom:l-a.bottom,bottomMirror:l-a.bottom},m=!!Gt(u,Rn);return d.reduce(function(j,w){var x=n[w],v=x.orientation,y=x.domain,f=x.padding,b=f===void 0?{}:f,p=x.mirror,g=x.reversed,N="".concat(v).concat(p?"Mirror":""),S,O,C,P,$;if(x.type==="number"&&(x.padding==="gap"||x.padding==="no-gap")){var A=y[1]-y[0],I=1/0,D=x.categoricalDomain.sort();if(D.forEach(function(ue,z){z>0&&(I=Math.min((ue||0)-(D[z-1]||0),I))}),Number.isFinite(I)){var q=I/A,F=x.layout==="vertical"?a.height:a.width;if(x.padding==="gap"&&(S=q*F/2),x.padding==="no-gap"){var K=Ft(r.barCategoryGap,q*F),M=q*F/2;S=M-K-(M-K)/F*K}}}s==="xAxis"?O=[a.left+(b.left||0)+(S||0),a.left+a.width-(b.right||0)-(S||0)]:s==="yAxis"?O=c==="horizontal"?[a.top+a.height-(b.bottom||0),a.top+(b.top||0)]:[a.top+(b.top||0)+(S||0),a.top+a.height-(b.bottom||0)-(S||0)]:O=x.range,g&&(O=[O[1],O[0]]);var E=qp(x,i,m),Q=E.scale,H=E.realScaleType;Q.domain(y).range(O),Vp(Q);var V=Wp(Q,br(br({},x),{},{realScaleType:H}));s==="xAxis"?($=v==="top"&&!p||v==="bottom"&&p,C=a.left,P=h[N]-$*x.height):s==="yAxis"&&($=v==="left"&&!p||v==="right"&&p,C=h[N]-$*x.width,P=a.top);var se=br(br(br({},x),V),{},{realScaleType:H,x:C,y:P,scale:Q,width:s==="xAxis"?a.width:x.width,height:s==="yAxis"?a.height:x.height});return se.bandSize=$i(se,V),!x.hide&&s==="xAxis"?h[N]+=($?-1:1)*se.height:x.hide||(h[N]+=($?-1:1)*se.width),br(br({},j),{},Wo({},w,se))},{})},Ox=function(r,n){var a=r.x,s=r.y,i=n.x,o=n.y;return{x:Math.min(a,i),y:Math.min(s,o),width:Math.abs(i-a),height:Math.abs(o-s)}},tT=function(r){var n=r.x1,a=r.y1,s=r.x2,i=r.y2;return Ox({x:n,y:a},{x:s,y:i})},Cx=function(){function t(r){Z2(this,t),this.scale=r}return J2(t,[{key:"domain",get:function(){return this.scale.domain}},{key:"range",get:function(){return this.scale.range}},{key:"rangeMin",get:function(){return this.range()[0]}},{key:"rangeMax",get:function(){return this.range()[1]}},{key:"bandwidth",get:function(){return this.scale.bandwidth}},{key:"apply",value:function(n){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=a.bandAware,i=a.position;if(n!==void 0){if(i)switch(i){case"start":return this.scale(n);case"middle":{var o=this.bandwidth?this.bandwidth()/2:0;return this.scale(n)+o}case"end":{var l=this.bandwidth?this.bandwidth():0;return this.scale(n)+l}default:return this.scale(n)}if(s){var c=this.bandwidth?this.bandwidth()/2:0;return this.scale(n)+c}return this.scale(n)}}},{key:"isInRange",value:function(n){var a=this.range(),s=a[0],i=a[a.length-1];return s<=i?n>=s&&n<=i:n>=i&&n<=s}}],[{key:"create",value:function(n){return new t(n)}}])}();Wo(Cx,"EPS",1e-4);var Od=function(r){var n=Object.keys(r).reduce(function(a,s){return br(br({},a),{},Wo({},s,Cx.create(r[s])))},{});return br(br({},n),{},{apply:function(s){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=i.bandAware,l=i.position;return b2(s,function(c,u){return n[u].apply(c,{bandAware:o,position:l})})},isInRange:function(s){return jx(s,function(i,o){return n[o].isInRange(i)})}})};function rT(t){return(t%180+180)%180}var nT=function(r){var n=r.width,a=r.height,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,i=rT(s),o=i*Math.PI/180,l=Math.atan(a/n),c=o>l&&o<Math.PI-l?a/Math.sin(o):n/Math.cos(o);return Math.abs(c)}
118,aT=qr,sT=mo,iT=sd;function oT(t){return function(r,n,a){var s=Object(r);if(!sT(r)){var i=aT(n);r=iT(r),n=function(l){return i(s[l],l,s)}}var o=t(r,n,a);return o>-1?s[i?r[o]:o]:void 0}}var lT=oT,cT=xx;function dT(t){var r=cT(t),n=r%1;return r===r?n?r-n:r:0}var uT=dT,hT=np,mT=qr,fT=uT,pT=Math.max;function xT(t,r,n){var a=t==null?0:t.length;if(!a)return-1;var s=n==null?0:fT(n);return s<0&&(s=pT(a+s,0)),hT(t,mT(r),s)}var vT=xT,gT=lT,yT=vT,jT=gT(yT),bT=jT;const wT=pt(bT);var NT=cg(function(t){return{x:t.left,y:t.top,width:t.width,height:t.height}},function(t){return["l",t.left,"t",t.top,"w",t.width,"h",t.height].join("")}),Cd=_.createContext(void 0),Ad=_.createContext(void 0),Ax=_.createContext(void 0),Px=_.createContext({}),kx=_.createContext(void 0),Ex=_.createContext(0),Tx=_.createContext(0),hm=function(r){var n=r.state,a=n.xAxisMap,s=n.yAxisMap,i=n.offset,o=r.clipPathId,l=r.children,c=r.width,u=r.height,d=NT(i);return L.createElement(Cd.Provider,{value:a},L.createElement(Ad.Provider,{value:s},L.createElement(Px.Provider,{value:i},L.createElement(Ax.Provider,{value:d},L.createElement(kx.Provider,{value:o},L.createElement(Ex.Provider,{value:u},L.createElement(Tx.Provider,{value:c},l)))))))},_T=function(){return _.useContext(kx)},$x=function(r){var n=_.useContext(Cd);n==null&&In();var a=n[r];return a==null&&In(),a},ST=function(){var r=_.useContext(Cd);return tn(r)},OT=function(){var r=_.useContext(Ad),n=wT(r,function(a){return jx(a.domain,Number.isFinite)});return n||tn(r)},Dx=function(r){var n=_.useContext(Ad);n==null&&In();var a=n[r];return a==null&&In(),a}
vendor: 90,697 bytes, lines 118-123
118,CT=function(){var r=_.useContext(Ax);return r},AT=function(){return _.useContext(Px)},Pd=function(){return _.useContext(Tx)},kd=function(){return _.useContext(Ex)};function da(t){"@babel/helpers - typeof";return da=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},da(t)}function PT(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function kT(t,r){for(var n=0;n<r.length;n++){var a=r[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,Ix(a.key),a)}}function ET(t,r,n){return r&&kT(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function TT(t,r,n){return r=Qi(r),$T(t,Mx()?Reflect.construct(r,n||[],Qi(t).constructor):r.apply(t,n))}function $T(t,r){if(r&&(da(r)==="object"||typeof r=="function"))return r;if(r!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return DT(t)}function DT(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Mx(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Mx=function(){return!!t})()}function Qi(t){return Qi=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Qi(t)}function MT(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&Tc(t,r)}function Tc(t,r){return Tc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,s){return a.__proto__=s,a},Tc(t,r)}function mm(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function fm(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?mm(Object(n),!0).forEach(function(a){Ed(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):mm(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function Ed(t,r,n){return r=Ix(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function Ix(t){var r=IT(t,"string");return da(r)=="symbol"?r:r+""}function IT(t,r){if(da(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(da(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function LT(t,r){return zT(t)||BT(t,r)||FT(t,r)||RT()}function RT(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
119In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function FT(t,r){if(t){if(typeof t=="string")return pm(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return pm(t,r)}}function pm(t,r){(r==null||r>t.length)&&(r=t.length);for(var n=0,a=new Array(r);n<r;n++)a[n]=t[n];return a}function BT(t,r){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var a,s,i,o,l=[],c=!0,u=!1;try{if(i=(n=n.call(t)).next,r!==0)for(;!(c=(a=i.call(n)).done)&&(l.push(a.value),l.length!==r);c=!0);}catch(d){u=!0,s=d}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw s}}return l}}function zT(t){if(Array.isArray(t))return t}function $c(){return $c=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},$c.apply(this,arguments)}var UT=function(r,n){var a;return L.isValidElement(r)?a=L.cloneElement(r,n):$e(r)?a=r(n):a=L.createElement("line",$c({},n,{className:"recharts-reference-line-line"})),a},qT=function(r,n,a,s,i,o,l,c,u){var d=i.x,h=i.y,m=i.width,j=i.height;if(a){var w=u.y,x=r.y.apply(w,{position:o});if(Tr(u,"discard")&&!r.y.isInRange(x))return null;var v=[{x:d+m,y:x},{x:d,y:x}];return c==="left"?v.reverse():v}if(n){var y=u.x,f=r.x.apply(y,{position:o});if(Tr(u,"discard")&&!r.x.isInRange(f))return null;var b=[{x:f,y:h+j},{x:f,y:h}];return l==="top"?b.reverse():b}if(s){var p=u.segment,g=p.map(function(N){return r.apply(N,{position:o})});return Tr(u,"discard")&&m2(g,function(N){return!r.isInRange(N)})?null:g}return null};function VT(t){var r=t.x,n=t.y,a=t.segment,s=t.xAxisId,i=t.yAxisId,o=t.shape,l=t.className,c=t.alwaysShow,u=_T(),d=$x(s),h=Dx(i),m=CT();if(!u||!m)return null;Sr(c===void 0,'The alwaysShow prop is deprecated. Please use ifOverflow="extendDomain" instead.');var j=Od({x:d.scale,y:h.scale}),w=_t(r),x=_t(n),v=a&&a.length===2,y=qT(j,w,x,v,m,t.position,d.orientation,h.orientation,t);if(!y)return null;var f=LT(y,2),b=f[0],p=b.x,g=b.y,N=f[1],S=N.x,O=N.y,C=Tr(t,"hidden")?"url(#".concat(u,")"):void 0,P=fm(fm({clipPath:C},Oe(t,!0)),{},{x1:p,y1:g,x2:S,y2:O});return L.createElement(Ke,{className:Le("recharts-reference-line",l)},UT(o,P),Ct.renderCallByParent(t,tT({x1:p,y1:g,x2:S,y2:O})))}var Td=function(t){function r(){return PT(this,r),TT(this,r,arguments)}return MT(r,t),ET(r,[{key:"render",value:function(){return L.createElement(VT,this.props)}}])}(L.Component);Ed(Td,"displayName","ReferenceLine");Ed(Td,"defaultProps",{isFront:!1,ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle"});function Dc(){return Dc=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},Dc.apply(this,arguments)}function ua(t){"@babel/helpers - typeof";return ua=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},ua(t)}function xm(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function vm(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?xm(Object(n),!0).forEach(function(a){Ko(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):xm(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function WT(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function KT(t,r){for(var n=0;n<r.length;n++){var a=r[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,Rx(a.key),a)}}function GT(t,r,n){return r&&KT(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function HT(t,r,n){return r=Zi(r),XT(t,Lx()?Reflect.construct(r,n||[],Zi(t).constructor):r.apply(t,n))}function XT(t,r){if(r&&(ua(r)==="object"||typeof r=="function"))return r;if(r!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return YT(t)}function YT(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Lx(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Lx=function(){return!!t})()}function Zi(t){return Zi=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Zi(t)}function QT(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&Mc(t,r)}function Mc(t,r){return Mc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,s){return a.__proto__=s,a},Mc(t,r)}function Ko(t,r,n){return r=Rx(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function Rx(t){var r=ZT(t,"string");return ua(r)=="symbol"?r:r+""}function ZT(t,r){if(ua(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(ua(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}var JT=function(r){var n=r.x,a=r.y,s=r.xAxis,i=r.yAxis,o=Od({x:s.scale,y:i.scale}),l=o.apply({x:n,y:a},{bandAware:!0});return Tr(r,"discard")&&!o.isInRange(l)?null:l},Go=function(t){function r(){return WT(this,r),HT(this,r,arguments)}return QT(r,t),GT(r,[{key:"render",value:function(){var a=this.props,s=a.x,i=a.y,o=a.r,l=a.alwaysShow,c=a.clipPathId,u=_t(s),d=_t(i);if(Sr(l===void 0,'The alwaysShow prop is deprecated. Please use ifOverflow="extendDomain" instead.'),!u||!d)return null;var h=JT(this.props);if(!h)return null;var m=h.x,j=h.y,w=this.props,x=w.shape,v=w.className,y=Tr(this.props,"hidden")?"url(#".concat(c,")"):void 0,f=vm(vm({clipPath:y},Oe(this.props,!0)),{},{cx:m,cy:j});return L.createElement(Ke,{className:Le("recharts-reference-dot",v)},r.renderDot(x,f),Ct.renderCallByParent(this.props,{x:m-o,y:j-o,width:2*o,height:2*o}))}}])}(L.Component);Ko(Go,"displayName","ReferenceDot");Ko(Go,"defaultProps",{isFront:!1,ifOverflow:"discard",xAxisId:0,yAxisId:0,r:10,fill:"#fff",stroke:"#ccc",fillOpacity:1,strokeWidth:1});Ko(Go,"renderDot",function(t,r){var n;return L.isValidElement(t)?n=L.cloneElement(t,r):$e(t)?n=t(r):n=L.createElement(Ro,Dc({},r,{cx:r.cx,cy:r.cy,className:"recharts-reference-dot-dot"})),n});function Ic(){return Ic=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},Ic.apply(this,arguments)}function ha(t){"@babel/helpers - typeof";return ha=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},ha(t)}function gm(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function ym(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?gm(Object(n),!0).forEach(function(a){Ho(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):gm(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function e$(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function t$(t,r){for(var n=0;n<r.length;n++){var a=r[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,Bx(a.key),a)}}function r$(t,r,n){return r&&t$(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function n$(t,r,n){return r=Ji(r),a$(t,Fx()?Reflect.construct(r,n||[],Ji(t).constructor):r.apply(t,n))}function a$(t,r){if(r&&(ha(r)==="object"||typeof r=="function"))return r;if(r!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return s$(t)}function s$(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Fx(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Fx=function(){return!!t})()}function Ji(t){return Ji=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Ji(t)}function i$(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&Lc(t,r)}function Lc(t,r){return Lc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,s){return a.__proto__=s,a},Lc(t,r)}function Ho(t,r,n){return r=Bx(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function Bx(t){var r=o$(t,"string");return ha(r)=="symbol"?r:r+""}function o$(t,r){if(ha(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(ha(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}var l$=function(r,n,a,s,i){var o=i.x1,l=i.x2,c=i.y1,u=i.y2,d=i.xAxis,h=i.yAxis;if(!d||!h)return null;var m=Od({x:d.scale,y:h.scale}),j={x:r?m.x.apply(o,{position:"start"}):m.x.rangeMin,y:a?m.y.apply(c,{position:"start"}):m.y.rangeMin},w={x:n?m.x.apply(l,{position:"end"}):m.x.rangeMax,y:s?m.y.apply(u,{position:"end"}):m.y.rangeMax};return Tr(i,"discard")&&(!m.isInRange(j)||!m.isInRange(w))?null:Ox(j,w)},Xo=function(t){function r(){return e$(this,r),n$(this,r,arguments)}return i$(r,t),r$(r,[{key:"render",value:function(){var a=this.props,s=a.x1,i=a.x2,o=a.y1,l=a.y2,c=a.className,u=a.alwaysShow,d=a.clipPathId;Sr(u===void 0,'The alwaysShow prop is deprecated. Please use ifOverflow="extendDomain" instead.');var h=_t(s),m=_t(i),j=_t(o),w=_t(l),x=this.props.shape;if(!h&&!m&&!j&&!w&&!x)return null;var v=l$(h,m,j,w,this.props);if(!v&&!x)return null;var y=Tr(this.props,"hidden")?"url(#".concat(d,")"):void 0;return L.createElement(Ke,{className:Le("recharts-reference-area",c)},r.renderRect(x,ym(ym({clipPath:y},Oe(this.props,!0)),v)),Ct.renderCallByParent(this.props,v))}}])}(L.Component);Ho(Xo,"displayName","ReferenceArea");Ho(Xo,"defaultProps",{isFront:!1,ifOverflow:"discard",xAxisId:0,yAxisId:0,r:10,fill:"#ccc",fillOpacity:.5,stroke:"none",strokeWidth:1});Ho(Xo,"renderRect",function(t,r){var n;return L.isValidElement(t)?n=L.cloneElement(t,r):$e(t)?n=t(r):n=L.createElement(Sd,Ic({},r,{className:"recharts-reference-area-rect"})),n});function zx(t,r,n){if(r<1)return[];if(r===1&&n===void 0)return t;for(var a=[],s=0;s<t.length;s+=r)a.push(t[s]);return a}function c$(t,r,n){var a={width:t.width+r.width,height:t.height+r.height};return nT(a,n)}function d$(t,r,n){var a=n==="width",s=t.x,i=t.y,o=t.width,l=t.height;return r===1?{start:a?s:i,end:a?s+o:i+l}:{start:a?s+o:i+l,end:a?s:i}}function eo(t,r,n,a,s){if(t*r<t*a||t*r>t*s)return!1;var i=n();return t*(r-t*i/2-a)>=0&&t*(r+t*i/2-s)<=0}function u$(t,r){return zx(t,r+1)}function h$(t,r,n,a,s){for(var i=(a||[]).slice(),o=r.start,l=r.end,c=0,u=1,d=o,h=function(){var w=a==null?void 0:a[c];if(w===void 0)return{v:zx(a,u)};var x=c,v,y=function(){return v===void 0&&(v=n(w,x)),v},f=w.coordinate,b=c===0||eo(t,f,y,d,l);b||(c=0,d=o,u+=1),b&&(d=f+t*(y()/2+s),c+=u)},m;u<=i.length;)if(m=h(),m)return m.v;return[]}function Ds(t){"@babel/helpers - typeof";return Ds=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Ds(t)}function jm(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function Dt(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?jm(Object(n),!0).forEach(function(a){m$(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):jm(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function m$(t,r,n){return r=f$(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function f$(t){var r=p$(t,"string");return Ds(r)=="symbol"?r:r+""}function p$(t,r){if(Ds(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(Ds(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function x$(t,r,n,a,s){for(var i=(a||[]).slice(),o=i.length,l=r.start,c=r.end,u=function(m){var j=i[m],w,x=function(){return w===void 0&&(w=n(j,m)),w};if(m===o-1){var v=t*(j.coordinate+t*x()/2-c);i[m]=j=Dt(Dt({},j),{},{tickCoord:v>0?j.coordinate-v*t:j.coordinate})}else i[m]=j=Dt(Dt({},j),{},{tickCoord:j.coordinate});var y=eo(t,j.tickCoord,x,l,c);y&&(c=j.tickCoord-t*(x()/2+s),i[m]=Dt(Dt({},j),{},{isShow:!0}))},d=o-1;d>=0;d--)u(d);return i}function v$(t,r,n,a,s,i){var o=(a||[]).slice(),l=o.length,c=r.start,u=r.end;if(i){var d=a[l-1],h=n(d,l-1),m=t*(d.coordinate+t*h/2-u);o[l-1]=d=Dt(Dt({},d),{},{tickCoord:m>0?d.coordinate-m*t:d.coordinate});var j=eo(t,d.tickCoord,function(){return h},c,u);j&&(u=d.tickCoord-t*(h/2+s),o[l-1]=Dt(Dt({},d),{},{isShow:!0}))}for(var w=i?l-1:l,x=function(f){var b=o[f],p,g=function(){return p===void 0&&(p=n(b,f)),p};if(f===0){var N=t*(b.coordinate-t*g()/2-c);o[f]=b=Dt(Dt({},b),{},{tickCoord:N<0?b.coordinate-N*t:b.coordinate})}else o[f]=b=Dt(Dt({},b),{},{tickCoord:b.coordinate});var S=eo(t,b.tickCoord,g,c,u);S&&(c=b.tickCoord+t*(g()/2+s),o[f]=Dt(Dt({},b),{},{isShow:!0}))},v=0;v<w;v++)x(v);return o}function $d(t,r,n){var a=t.tick,s=t.ticks,i=t.viewBox,o=t.minTickGap,l=t.orientation,c=t.interval,u=t.tickFormatter,d=t.unit,h=t.angle;if(!s||!s.length||!a)return[];if(me(c)||Er.isSsr)return u$(s,typeof c=="number"&&me(c)?c:0);var m=[],j=l==="top"||l==="bottom"?"width":"height",w=d&&j==="width"?Ga(d,{fontSize:r,letterSpacing:n}):{width:0,height:0},x=function(b,p){var g=$e(u)?u(b.value,p):b.value;return j==="width"?c$(Ga(g,{fontSize:r,letterSpacing:n}),w,h):Ga(g,{fontSize:r,letterSpacing:n})[j]},v=s.length>=2?Rt(s[1].coordinate-s[0].coordinate):1,y=d$(i,v,j);return c==="equidistantPreserveStart"?h$(v,y,x,s,o):(c==="preserveStart"||c==="preserveStartEnd"?m=v$(v,y,x,s,o,c==="preserveStartEnd"):m=x$(v,y,x,s,o),m.filter(function(f){return f.isShow}))}var g$=["viewBox"],y$=["viewBox"],j$=["ticks"];function ma(t){"@babel/helpers - typeof";return ma=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},ma(t)}function Wn(){return Wn=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},Wn.apply(this,arguments)}function bm(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function Lt(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?bm(Object(n),!0).forEach(function(a){Dd(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):bm(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function xl(t,r){if(t==null)return{};var n=b$(t,r),a,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)a=i[s],!(r.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(t,a)&&(n[a]=t[a])}return n}function b$(t,r){if(t==null)return{};var n={};for(var a in t)if(Object.prototype.hasOwnProperty.call(t,a)){if(r.indexOf(a)>=0)continue;n[a]=t[a]}return n}function w$(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function wm(t,r){for(var n=0;n<r.length;n++){var a=r[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,qx(a.key),a)}}function N$(t,r,n){return r&&wm(t.prototype,r),n&&wm(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function _$(t,r,n){return r=to(r),S$(t,Ux()?Reflect.construct(r,n||[],to(t).constructor):r.apply(t,n))}function S$(t,r){if(r&&(ma(r)==="object"||typeof r=="function"))return r;if(r!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return O$(t)}function O$(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Ux(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Ux=function(){return!!t})()}function to(t){return to=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},to(t)}function C$(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&Rc(t,r)}function Rc(t,r){return Rc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,s){return a.__proto__=s,a},Rc(t,r)}function Dd(t,r,n){return r=qx(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function qx(t){var r=A$(t,"string");return ma(r)=="symbol"?r:r+""}function A$(t,r){if(ma(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(ma(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}var Aa=function(t){function r(n){var a;return w$(this,r),a=_$(this,r,[n]),a.state={fontSize:"",letterSpacing:""},a}return C$(r,t),N$(r,[{key:"shouldComponentUpdate",value:function(a,s){var i=a.viewBox,o=xl(a,g$),l=this.props,c=l.viewBox,u=xl(l,y$);return!Kn(i,c)||!Kn(o,u)||!Kn(s,this.state)}},{key:"componentDidMount",value:function(){var a=this.layerReference;if(a){var s=a.getElementsByClassName("recharts-cartesian-axis-tick-value")[0];s&&this.setState({fontSize:window.getComputedStyle(s).fontSize,letterSpacing:window.getComputedStyle(s).letterSpacing})}}},{key:"getTickLineCoord",value:function(a){var s=this.props,i=s.x,o=s.y,l=s.width,c=s.height,u=s.orientation,d=s.tickSize,h=s.mirror,m=s.tickMargin,j,w,x,v,y,f,b=h?-1:1,p=a.tickSize||d,g=me(a.tickCoord)?a.tickCoord:a.coordinate;switch(u){case"top":j=w=a.coordinate,v=o+ +!h*c,x=v-b*p,f=x-b*m,y=g;break;case"left":x=v=a.coordinate,w=i+ +!h*l,j=w-b*p,y=j-b*m,f=g;break;case"right":x=v=a.coordinate,w=i+ +h*l,j=w+b*p,y=j+b*m,f=g;break;default:j=w=a.coordinate,v=o+ +h*c,x=v+b*p,f=x+b*m,y=g;break}return{line:{x1:j,y1:x,x2:w,y2:v},tick:{x:y,y:f}}}},{key:"getTickTextAnchor",value:function(){var a=this.props,s=a.orientation,i=a.mirror,o;switch(s){case"left":o=i?"start":"end";break;case"right":o=i?"end":"start";break;default:o="middle";break}return o}},{key:"getTickVerticalAnchor",value:function(){var a=this.props,s=a.orientation,i=a.mirror,o="end";switch(s){case"left":case"right":o="middle";break;case"top":o=i?"start":"end";break;default:o=i?"end":"start";break}return o}},{key:"renderAxisLine",value:function(){var a=this.props,s=a.x,i=a.y,o=a.width,l=a.height,c=a.orientation,u=a.mirror,d=a.axisLine,h=Lt(Lt(Lt({},Oe(this.props,!1)),Oe(d,!1)),{},{fill:"none"});if(c==="top"||c==="bottom"){var m=+(c==="top"&&!u||c==="bottom"&&u);h=Lt(Lt({},h),{},{x1:s,y1:i+m*l,x2:s+o,y2:i+m*l})}else{var j=+(c==="left"&&!u||c==="right"&&u);h=Lt(Lt({},h),{},{x1:s+j*o,y1:i,x2:s+j*o,y2:i+l})}return L.createElement("line",Wn({},h,{className:Le("recharts-cartesian-axis-line",Jt(d,"className"))}))}},{key:"renderTicks",value:function(a,s,i){var o=this,l=this.props,c=l.tickLine,u=l.stroke,d=l.tick,h=l.tickFormatter,m=l.unit,j=$d(Lt(Lt({},this.props),{},{ticks:a}),s,i),w=this.getTickTextAnchor(),x=this.getTickVerticalAnchor(),v=Oe(this.props,!1),y=Oe(d,!1),f=Lt(Lt({},v),{},{fill:"none"},Oe(c,!1)),b=j.map(function(p,g){var N=o.getTickLineCoord(p),S=N.line,O=N.tick,C=Lt(Lt(Lt(Lt({textAnchor:w,verticalAnchor:x},v),{},{stroke:"none",fill:u},y),O),{},{index:g,payload:p,visibleTicksCount:j.length,tickFormatter:h});return L.createElement(Ke,Wn({className:"recharts-cartesian-axis-tick",key:"tick-".concat(p.value,"-").concat(p.coordinate,"-").concat(p.tickCoord)},$n(o.props,p,g)),c&&L.createElement("line",Wn({},f,S,{className:Le("recharts-cartesian-axis-tick-line",Jt(c,"className"))})),d&&r.renderTickItem(d,C,"".concat($e(h)?h(p.value,g):p.value).concat(m||"")))});return L.createElement("g",{className:"recharts-cartesian-axis-ticks"},b)}},{key:"render",value:function(){var a=this,s=this.props,i=s.axisLine,o=s.width,l=s.height,c=s.ticksGenerator,u=s.className,d=s.hide;if(d)return null;var h=this.props,m=h.ticks,j=xl(h,j$),w=m;return $e(c)&&(w=m&&m.length>0?c(this.props):c(j)),o<=0||l<=0||!w||!w.length?null:L.createElement(Ke,{className:Le("recharts-cartesian-axis",u),ref:function(v){a.layerReference=v}},i&&this.renderAxisLine(),this.renderTicks(w,this.state.fontSize,this.state.letterSpacing),Ct.renderCallByParent(this.props))}}],[{key:"renderTickItem",value:function(a,s,i){var o;return L.isValidElement(a)?o=L.cloneElement(a,s):$e(a)?o=a(s):o=L.createElement(Dn,Wn({},s,{className:"recharts-cartesian-axis-tick-value"}),i),o}}])}(_.Component);Dd(Aa,"displayName","CartesianAxis");Dd(Aa,"defaultProps",{x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:"bottom",ticks:[],stroke:"#666",tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:"preserveEnd"});var P$=["x1","y1","x2","y2","key"],k$=["offset"];function Ln(t){"@babel/helpers - typeof";return Ln=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Ln(t)}function Nm(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function Mt(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?Nm(Object(n),!0).forEach(function(a){E$(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Nm(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function E$(t,r,n){return r=T$(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function T$(t){var r=$$(t,"string");return Ln(r)=="symbol"?r:r+""}function $$(t,r){if(Ln(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(Ln(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function wn(){return wn=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},wn.apply(this,arguments)}function _m(t,r){if(t==null)return{};var n=D$(t,r),a,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)a=i[s],!(r.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(t,a)&&(n[a]=t[a])}return n}function D$(t,r){if(t==null)return{};var n={};for(var a in t)if(Object.prototype.hasOwnProperty.call(t,a)){if(r.indexOf(a)>=0)continue;n[a]=t[a]}return n}var M$=function(r){var n=r.fill;if(!n||n==="none")return null;var a=r.fillOpacity,s=r.x,i=r.y,o=r.width,l=r.height,c=r.ry;return L.createElement("rect",{x:s,y:i,ry:c,width:o,height:l,stroke:"none",fill:n,fillOpacity:a,className:"recharts-cartesian-grid-bg"})};function Vx(t,r){var n;if(L.isValidElement(t))n=L.cloneElement(t,r);else if($e(t))n=t(r);else{var a=r.x1,s=r.y1,i=r.x2,o=r.y2,l=r.key,c=_m(r,P$),u=Oe(c,!1);u.offset;var d=_m(u,k$);n=L.createElement("line",wn({},d,{x1:a,y1:s,x2:i,y2:o,fill:"none",key:l}))}return n}function I$(t){var r=t.x,n=t.width,a=t.horizontal,s=a===void 0?!0:a,i=t.horizontalPoints;if(!s||!i||!i.length)return null;var o=i.map(function(l,c){var u=Mt(Mt({},t),{},{x1:r,y1:l,x2:r+n,y2:l,key:"line-".concat(c),index:c});return Vx(s,u)});return L.createElement("g",{className:"recharts-cartesian-grid-horizontal"},o)}function L$(t){var r=t.y,n=t.height,a=t.vertical,s=a===void 0?!0:a,i=t.verticalPoints;if(!s||!i||!i.length)return null;var o=i.map(function(l,c){var u=Mt(Mt({},t),{},{x1:l,y1:r,x2:l,y2:r+n,key:"line-".concat(c),index:c});return Vx(s,u)});return L.createElement("g",{className:"recharts-cartesian-grid-vertical"},o)}function R$(t){var r=t.horizontalFill,n=t.fillOpacity,a=t.x,s=t.y,i=t.width,o=t.height,l=t.horizontalPoints,c=t.horizontal,u=c===void 0?!0:c;if(!u||!r||!r.length)return null;var d=l.map(function(m){return Math.round(m+s-s)}).sort(function(m,j){return m-j});s!==d[0]&&d.unshift(0);var h=d.map(function(m,j){var w=!d[j+1],x=w?s+o-m:d[j+1]-m;if(x<=0)return null;var v=j%r.length;return L.createElement("rect",{key:"react-".concat(j),y:m,x:a,height:x,width:i,stroke:"none",fill:r[v],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return L.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},h)}function F$(t){var r=t.vertical,n=r===void 0?!0:r,a=t.verticalFill,s=t.fillOpacity,i=t.x,o=t.y,l=t.width,c=t.height,u=t.verticalPoints;if(!n||!a||!a.length)return null;var d=u.map(function(m){return Math.round(m+i-i)}).sort(function(m,j){return m-j});i!==d[0]&&d.unshift(0);var h=d.map(function(m,j){var w=!d[j+1],x=w?i+l-m:d[j+1]-m;if(x<=0)return null;var v=j%a.length;return L.createElement("rect",{key:"react-".concat(j),x:m,y:o,width:x,height:c,stroke:"none",fill:a[v],fillOpacity:s,className:"recharts-cartesian-grid-bg"})});return L.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},h)}var B$=function(r,n){var a=r.xAxis,s=r.width,i=r.height,o=r.offset;return Up($d(Mt(Mt(Mt({},Aa.defaultProps),a),{},{ticks:Gr(a,!0),viewBox:{x:0,y:0,width:s,height:i}})),o.left,o.left+o.width,n)},z$=function(r,n){var a=r.yAxis,s=r.width,i=r.height,o=r.offset;return Up($d(Mt(Mt(Mt({},Aa.defaultProps),a),{},{ticks:Gr(a,!0),viewBox:{x:0,y:0,width:s,height:i}})),o.top,o.top+o.height,n)},Bn={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[]};function Fc(t){var r,n,a,s,i,o,l=Pd(),c=kd(),u=AT(),d=Mt(Mt({},t),{},{stroke:(r=t.stroke)!==null&&r!==void 0?r:Bn.stroke,fill:(n=t.fill)!==null&&n!==void 0?n:Bn.fill,horizontal:(a=t.horizontal)!==null&&a!==void 0?a:Bn.horizontal,horizontalFill:(s=t.horizontalFill)!==null&&s!==void 0?s:Bn.horizontalFill,vertical:(i=t.vertical)!==null&&i!==void 0?i:Bn.vertical,verticalFill:(o=t.verticalFill)!==null&&o!==void 0?o:Bn.verticalFill,x:me(t.x)?t.x:u.left,y:me(t.y)?t.y:u.top,width:me(t.width)?t.width:u.width,height:me(t.height)?t.height:u.height}),h=d.x,m=d.y,j=d.width,w=d.height,x=d.syncWithTicks,v=d.horizontalValues,y=d.verticalValues,f=ST(),b=OT();if(!me(j)||j<=0||!me(w)||w<=0||!me(h)||h!==+h||!me(m)||m!==+m)return null;var p=d.verticalCoordinatesGenerator||B$,g=d.horizontalCoordinatesGenerator||z$,N=d.horizontalPoints,S=d.verticalPoints;if((!N||!N.length)&&$e(g)){var O=v&&v.length,C=g({yAxis:b?Mt(Mt({},b),{},{ticks:O?v:b.ticks}):void 0,width:l,height:c,offset:u},O?!0:x);Sr(Array.isArray(C),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(Ln(C),"]")),Array.isArray(C)&&(N=C)}if((!S||!S.length)&&$e(p)){var P=y&&y.length,$=p({xAxis:f?Mt(Mt({},f),{},{ticks:P?y:f.ticks}):void 0,width:l,height:c,offset:u},P?!0:x);Sr(Array.isArray($),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(Ln($),"]")),Array.isArray($)&&(S=$)}return L.createElement("g",{className:"recharts-cartesian-grid"},L.createElement(M$,{fill:d.fill,fillOpacity:d.fillOpacity,x:d.x,y:d.y,width:d.width,height:d.height,ry:d.ry}),L.createElement(I$,wn({},d,{offset:u,horizontalPoints:N,xAxis:f,yAxis:b})),L.createElement(L$,wn({},d,{offset:u,verticalPoints:S,xAxis:f,yAxis:b})),L.createElement(R$,wn({},d,{horizontalPoints:N})),L.createElement(F$,wn({},d,{verticalPoints:S})))}Fc.displayName="CartesianGrid";var U$=["type","layout","connectNulls","ref"],q$=["key"];function fa(t){"@babel/helpers - typeof";return fa=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},fa(t)}function Sm(t,r){if(t==null)return{};var n=V$(t,r),a,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)a=i[s],!(r.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(t,a)&&(n[a]=t[a])}return n}function V$(t,r){if(t==null)return{};var n={};for(var a in t)if(Object.prototype.hasOwnProperty.call(t,a)){if(r.indexOf(a)>=0)continue;n[a]=t[a]}return n}function Za(){return Za=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},Za.apply(this,arguments)}function Om(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function Wt(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?Om(Object(n),!0).forEach(function(a){wr(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Om(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function zn(t){return H$(t)||G$(t)||K$(t)||W$()}function W$(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
120In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function K$(t,r){if(t){if(typeof t=="string")return Bc(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Bc(t,r)}}function G$(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function H$(t){if(Array.isArray(t))return Bc(t)}function Bc(t,r){(r==null||r>t.length)&&(r=t.length);for(var n=0,a=new Array(r);n<r;n++)a[n]=t[n];return a}function X$(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function Cm(t,r){for(var n=0;n<r.length;n++){var a=r[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,Kx(a.key),a)}}function Y$(t,r,n){return r&&Cm(t.prototype,r),n&&Cm(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function Q$(t,r,n){return r=ro(r),Z$(t,Wx()?Reflect.construct(r,n||[],ro(t).constructor):r.apply(t,n))}function Z$(t,r){if(r&&(fa(r)==="object"||typeof r=="function"))return r;if(r!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return J$(t)}function J$(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Wx(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Wx=function(){return!!t})()}function ro(t){return ro=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},ro(t)}function e4(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&zc(t,r)}function zc(t,r){return zc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,s){return a.__proto__=s,a},zc(t,r)}function wr(t,r,n){return r=Kx(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function Kx(t){var r=t4(t,"string");return fa(r)=="symbol"?r:r+""}function t4(t,r){if(fa(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(fa(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}var Ws=function(t){function r(){var n;X$(this,r);for(var a=arguments.length,s=new Array(a),i=0;i<a;i++)s[i]=arguments[i];return n=Q$(this,r,[].concat(s)),wr(n,"state",{isAnimationFinished:!0,totalLength:0}),wr(n,"generateSimpleStrokeDasharray",function(o,l){return"".concat(l,"px ").concat(o-l,"px")}),wr(n,"getStrokeDasharray",function(o,l,c){var u=c.reduce(function(y,f){return y+f});if(!u)return n.generateSimpleStrokeDasharray(l,o);for(var d=Math.floor(o/u),h=o%u,m=l-o,j=[],w=0,x=0;w<c.length;x+=c[w],++w)if(x+c[w]>h){j=[].concat(zn(c.slice(0,w)),[h-x]);break}var v=j.length%2===0?[0,m]:[m];return[].concat(zn(r.repeat(c,d)),zn(j),v).map(function(y){return"".concat(y,"px")}).join(", ")}),wr(n,"id",Na("recharts-line-")),wr(n,"pathRef",function(o){n.mainCurve=o}),wr(n,"handleAnimationEnd",function(){n.setState({isAnimationFinished:!0}),n.props.onAnimationEnd&&n.props.onAnimationEnd()}),wr(n,"handleAnimationStart",function(){n.setState({isAnimationFinished:!1}),n.props.onAnimationStart&&n.props.onAnimationStart()}),n}return e4(r,t),Y$(r,[{key:"componentDidMount",value:function(){if(this.props.isAnimationActive){var a=this.getTotalLength();this.setState({totalLength:a})}}},{key:"componentDidUpdate",value:function(){if(this.props.isAnimationActive){var a=this.getTotalLength();a!==this.state.totalLength&&this.setState({totalLength:a})}}},{key:"getTotalLength",value:function(){var a=this.mainCurve;try{return a&&a.getTotalLength&&a.getTotalLength()||0}catch{return 0}}},{key:"renderErrorBar",value:function(a,s){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var i=this.props,o=i.points,l=i.xAxis,c=i.yAxis,u=i.layout,d=i.children,h=er(d,Vs);if(!h)return null;var m=function(x,v){return{x:x.x,y:x.y,value:x.value,errorVal:Nt(x.payload,v)}},j={clipPath:a?"url(#clipPath-".concat(s,")"):null};return L.createElement(Ke,j,h.map(function(w){return L.cloneElement(w,{key:"bar-".concat(w.props.dataKey),data:o,xAxis:l,yAxis:c,layout:u,dataPointFormatter:m})}))}},{key:"renderDots",value:function(a,s,i){var o=this.props.isAnimationActive;if(o&&!this.state.isAnimationFinished)return null;var l=this.props,c=l.dot,u=l.points,d=l.dataKey,h=Oe(this.props,!1),m=Oe(c,!0),j=u.map(function(x,v){var y=Wt(Wt(Wt({key:"dot-".concat(v),r:3},h),m),{},{value:x.value,dataKey:d,cx:x.x,cy:x.y,index:v,payload:x.payload});return r.renderDotItem(c,y)}),w={clipPath:a?"url(#clipPath-".concat(s?"":"dots-").concat(i,")"):null};return L.createElement(Ke,Za({className:"recharts-line-dots",key:"dots"},w),j)}},{key:"renderCurveStatically",value:function(a,s,i,o){var l=this.props,c=l.type,u=l.layout,d=l.connectNulls;l.ref;var h=Sm(l,U$),m=Wt(Wt(Wt({},Oe(h,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:s?"url(#clipPath-".concat(i,")"):null,points:a},o),{},{type:c,layout:u,connectNulls:d});return L.createElement(Ii,Za({},m,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(a,s){var i=this,o=this.props,l=o.points,c=o.strokeDasharray,u=o.isAnimationActive,d=o.animationBegin,h=o.animationDuration,m=o.animationEasing,j=o.animationId,w=o.animateNewValues,x=o.width,v=o.height,y=this.state,f=y.prevPoints,b=y.totalLength;return L.createElement(Rr,{begin:d,duration:h,isActive:u,easing:m,from:{t:0},to:{t:1},key:"line-".concat(j),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(p){var g=p.t;if(f){var N=f.length/l.length,S=l.map(function(A,I){var D=Math.floor(I*N);if(f[D]){var q=f[D],F=Xt(q.x,A.x),K=Xt(q.y,A.y);return Wt(Wt({},A),{},{x:F(g),y:K(g)})}if(w){var M=Xt(x*2,A.x),E=Xt(v/2,A.y);return Wt(Wt({},A),{},{x:M(g),y:E(g)})}return Wt(Wt({},A),{},{x:A.x,y:A.y})});return i.renderCurveStatically(S,a,s)}var O=Xt(0,b),C=O(g),P;if(c){var $="".concat(c).split(/[,\s]+/gim).map(function(A){return parseFloat(A)});P=i.getStrokeDasharray(C,b,$)}else P=i.generateSimpleStrokeDasharray(b,C);return i.renderCurveStatically(l,a,s,{strokeDasharray:P})})}},{key:"renderCurve",value:function(a,s){var i=this.props,o=i.points,l=i.isAnimationActive,c=this.state,u=c.prevPoints,d=c.totalLength;return l&&o&&o.length&&(!u&&d>0||!zs(u,o))?this.renderCurveWithAnimation(a,s):this.renderCurveStatically(o,a,s)}},{key:"render",value:function(){var a,s=this.props,i=s.hide,o=s.dot,l=s.points,c=s.className,u=s.xAxis,d=s.yAxis,h=s.top,m=s.left,j=s.width,w=s.height,x=s.isAnimationActive,v=s.id;if(i||!l||!l.length)return null;var y=this.state.isAnimationFinished,f=l.length===1,b=Le("recharts-line",c),p=u&&u.allowDataOverflow,g=d&&d.allowDataOverflow,N=p||g,S=Ie(v)?this.id:v,O=(a=Oe(o,!1))!==null&&a!==void 0?a:{r:3,strokeWidth:2},C=O.r,P=C===void 0?3:C,$=O.strokeWidth,A=$===void 0?2:$,I=wj(o)?o:{},D=I.clipDot,q=D===void 0?!0:D,F=P*2+A;return L.createElement(Ke,{className:b},p||g?L.createElement("defs",null,L.createElement("clipPath",{id:"clipPath-".concat(S)},L.createElement("rect",{x:p?m:m-j/2,y:g?h:h-w/2,width:p?j:j*2,height:g?w:w*2})),!q&&L.createElement("clipPath",{id:"clipPath-dots-".concat(S)},L.createElement("rect",{x:m-F/2,y:h-F/2,width:j+F,height:w+F}))):null,!f&&this.renderCurve(N,S),this.renderErrorBar(N,S),(f||o)&&this.renderDots(N,q,S),(!x||y)&&Yr.renderCallByParent(this.props,l))}}],[{key:"getDerivedStateFromProps",value:function(a,s){return a.animationId!==s.prevAnimationId?{prevAnimationId:a.animationId,curPoints:a.points,prevPoints:s.curPoints}:a.points!==s.curPoints?{curPoints:a.points}:null}},{key:"repeat",value:function(a,s){for(var i=a.length%2!==0?[].concat(zn(a),[0]):a,o=[],l=0;l<s;++l)o=[].concat(zn(o),zn(i));return o}},{key:"renderDotItem",value:function(a,s){var i;if(L.isValidElement(a))i=L.cloneElement(a,s);else if($e(a))i=a(s);else{var o=s.key,l=Sm(s,q$),c=Le("recharts-line-dot",typeof a!="boolean"?a.className:"");i=L.createElement(Ro,Za({key:o},l,{className:c}))}return i}}])}(_.PureComponent);wr(Ws,"displayName","Line");wr(Ws,"defaultProps",{xAxisId:0,yAxisId:0,connectNulls:!1,activeDot:!0,dot:!0,legendType:"line",stroke:"#3182bd",strokeWidth:1,fill:"#fff",points:[],isAnimationActive:!Er.isSsr,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",hide:!1,label:!1});wr(Ws,"getComposedData",function(t){var r=t.props,n=t.xAxis,a=t.yAxis,s=t.xAxisTicks,i=t.yAxisTicks,o=t.dataKey,l=t.bandSize,c=t.displayedData,u=t.offset,d=r.layout,h=c.map(function(m,j){var w=Nt(m,o);return d==="horizontal"?{x:Qu({axis:n,ticks:s,bandSize:l,entry:m,index:j}),y:Ie(w)?null:a.scale(w),value:w,payload:m}:{x:Ie(w)?null:n.scale(w),y:Qu({axis:a,ticks:i,bandSize:l,entry:m,index:j}),value:w,payload:m}});return Wt({points:h,layout:d},u)});function pa(t){"@babel/helpers - typeof";return pa=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},pa(t)}function r4(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function n4(t,r){for(var n=0;n<r.length;n++){var a=r[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,Xx(a.key),a)}}function a4(t,r,n){return r&&n4(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function s4(t,r,n){return r=no(r),i4(t,Gx()?Reflect.construct(r,n||[],no(t).constructor):r.apply(t,n))}function i4(t,r){if(r&&(pa(r)==="object"||typeof r=="function"))return r;if(r!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return o4(t)}function o4(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Gx(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Gx=function(){return!!t})()}function no(t){return no=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},no(t)}function l4(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&Uc(t,r)}function Uc(t,r){return Uc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,s){return a.__proto__=s,a},Uc(t,r)}function Hx(t,r,n){return r=Xx(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function Xx(t){var r=c4(t,"string");return pa(r)=="symbol"?r:r+""}function c4(t,r){if(pa(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(pa(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function qc(){return qc=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},qc.apply(this,arguments)}function d4(t){var r=t.xAxisId,n=Pd(),a=kd(),s=$x(r);return s==null?null:L.createElement(Aa,qc({},s,{className:Le("recharts-".concat(s.axisType," ").concat(s.axisType),s.className),viewBox:{x:0,y:0,width:n,height:a},ticksGenerator:function(o){return Gr(o,!0)}}))}var xa=function(t){function r(){return r4(this,r),s4(this,r,arguments)}return l4(r,t),a4(r,[{key:"render",value:function(){return L.createElement(d4,this.props)}}])}(L.Component);Hx(xa,"displayName","XAxis");Hx(xa,"defaultProps",{allowDecimals:!0,hide:!1,orientation:"bottom",width:0,height:30,mirror:!1,xAxisId:0,tickCount:5,type:"category",padding:{left:0,right:0},allowDataOverflow:!1,scale:"auto",reversed:!1,allowDuplicatedCategory:!0});function va(t){"@babel/helpers - typeof";return va=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},va(t)}function u4(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function h4(t,r){for(var n=0;n<r.length;n++){var a=r[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,Zx(a.key),a)}}function m4(t,r,n){return r&&h4(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function f4(t,r,n){return r=ao(r),p4(t,Yx()?Reflect.construct(r,n||[],ao(t).constructor):r.apply(t,n))}function p4(t,r){if(r&&(va(r)==="object"||typeof r=="function"))return r;if(r!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return x4(t)}function x4(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Yx(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Yx=function(){return!!t})()}function ao(t){return ao=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},ao(t)}function v4(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&Vc(t,r)}function Vc(t,r){return Vc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,s){return a.__proto__=s,a},Vc(t,r)}function Qx(t,r,n){return r=Zx(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function Zx(t){var r=g4(t,"string");return va(r)=="symbol"?r:r+""}function g4(t,r){if(va(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(va(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function Wc(){return Wc=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},Wc.apply(this,arguments)}var y4=function(r){var n=r.yAxisId,a=Pd(),s=kd(),i=Dx(n);return i==null?null:L.createElement(Aa,Wc({},i,{className:Le("recharts-".concat(i.axisType," ").concat(i.axisType),i.className),viewBox:{x:0,y:0,width:a,height:s},ticksGenerator:function(l){return Gr(l,!0)}}))},ga=function(t){function r(){return u4(this,r),f4(this,r,arguments)}return v4(r,t),m4(r,[{key:"render",value:function(){return L.createElement(y4,this.props)}}])}(L.Component);Qx(ga,"displayName","YAxis");Qx(ga,"defaultProps",{allowDuplicatedCategory:!0,allowDecimals:!0,hide:!1,orientation:"left",width:60,height:0,mirror:!1,yAxisId:0,tickCount:5,type:"number",padding:{top:0,bottom:0},allowDataOverflow:!1,scale:"auto",reversed:!1});function Am(t){return N4(t)||w4(t)||b4(t)||j4()}function j4(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
121In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function b4(t,r){if(t){if(typeof t=="string")return Kc(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Kc(t,r)}}function w4(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function N4(t){if(Array.isArray(t))return Kc(t)}function Kc(t,r){(r==null||r>t.length)&&(r=t.length);for(var n=0,a=new Array(r);n<r;n++)a[n]=t[n];return a}var Gc=function(r,n,a,s,i){var o=er(r,Td),l=er(r,Go),c=[].concat(Am(o),Am(l)),u=er(r,Xo),d="".concat(s,"Id"),h=s[0],m=n;if(c.length&&(m=c.reduce(function(x,v){if(v.props[d]===a&&Tr(v.props,"extendDomain")&&me(v.props[h])){var y=v.props[h];return[Math.min(x[0],y),Math.max(x[1],y)]}return x},m)),u.length){var j="".concat(h,"1"),w="".concat(h,"2");m=u.reduce(function(x,v){if(v.props[d]===a&&Tr(v.props,"extendDomain")&&me(v.props[j])&&me(v.props[w])){var y=v.props[j],f=v.props[w];return[Math.min(x[0],y,f),Math.max(x[1],y,f)]}return x},m)}return i&&i.length&&(m=i.reduce(function(x,v){return me(v)?[Math.min(x[0],v),Math.max(x[1],v)]:x},m)),m},Jx={exports:{}};(function(t){var r=Object.prototype.hasOwnProperty,n="~";function a(){}Object.create&&(a.prototype=Object.create(null),new a().__proto__||(n=!1));function s(c,u,d){this.fn=c,this.context=u,this.once=d||!1}function i(c,u,d,h,m){if(typeof d!="function")throw new TypeError("The listener must be a function");var j=new s(d,h||c,m),w=n?n+u:u;return c._events[w]?c._events[w].fn?c._events[w]=[c._events[w],j]:c._events[w].push(j):(c._events[w]=j,c._eventsCount++),c}function o(c,u){--c._eventsCount===0?c._events=new a:delete c._events[u]}function l(){this._events=new a,this._eventsCount=0}l.prototype.eventNames=function(){var u=[],d,h;if(this._eventsCount===0)return u;for(h in d=this._events)r.call(d,h)&&u.push(n?h.slice(1):h);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(d)):u},l.prototype.listeners=function(u){var d=n?n+u:u,h=this._events[d];if(!h)return[];if(h.fn)return[h.fn];for(var m=0,j=h.length,w=new Array(j);m<j;m++)w[m]=h[m].fn;return w},l.prototype.listenerCount=function(u){var d=n?n+u:u,h=this._events[d];return h?h.fn?1:h.length:0},l.prototype.emit=function(u,d,h,m,j,w){var x=n?n+u:u;if(!this._events[x])return!1;var v=this._events[x],y=arguments.length,f,b;if(v.fn){switch(v.once&&this.removeListener(u,v.fn,void 0,!0),y){case 1:return v.fn.call(v.context),!0;case 2:return v.fn.call(v.context,d),!0;case 3:return v.fn.call(v.context,d,h),!0;case 4:return v.fn.call(v.context,d,h,m),!0;case 5:return v.fn.call(v.context,d,h,m,j),!0;case 6:return v.fn.call(v.context,d,h,m,j,w),!0}for(b=1,f=new Array(y-1);b<y;b++)f[b-1]=arguments[b];v.fn.apply(v.context,f)}else{var p=v.length,g;for(b=0;b<p;b++)switch(v[b].once&&this.removeListener(u,v[b].fn,void 0,!0),y){case 1:v[b].fn.call(v[b].context);break;case 2:v[b].fn.call(v[b].context,d);break;case 3:v[b].fn.call(v[b].context,d,h);break;case 4:v[b].fn.call(v[b].context,d,h,m);break;default:if(!f)for(g=1,f=new Array(y-1);g<y;g++)f[g-1]=arguments[g];v[b].fn.apply(v[b].context,f)}}return!0},l.prototype.on=function(u,d,h){return i(this,u,d,h,!1)},l.prototype.once=function(u,d,h){return i(this,u,d,h,!0)},l.prototype.removeListener=function(u,d,h,m){var j=n?n+u:u;if(!this._events[j])return this;if(!d)return o(this,j),this;var w=this._events[j];if(w.fn)w.fn===d&&(!m||w.once)&&(!h||w.context===h)&&o(this,j);else{for(var x=0,v=[],y=w.length;x<y;x++)(w[x].fn!==d||m&&!w[x].once||h&&w[x].context!==h)&&v.push(w[x]);v.length?this._events[j]=v.length===1?v[0]:v:o(this,j)}return this},l.prototype.removeAllListeners=function(u){var d;return u?(d=n?n+u:u,this._events[d]&&o(this,d)):(this._events=new a,this._eventsCount=0),this},l.prototype.off=l.prototype.removeListener,l.prototype.addListener=l.prototype.on,l.prefixed=n,l.EventEmitter=l,t.exports=l})(Jx);var _4=Jx.exports;const S4=pt(_4);var vl=new S4,gl="recharts.syncMouseEvents";function Ms(t){"@babel/helpers - typeof";return Ms=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Ms(t)}function O4(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function C4(t,r){for(var n=0;n<r.length;n++){var a=r[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,ev(a.key),a)}}function A4(t,r,n){return r&&C4(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function yl(t,r,n){return r=ev(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function ev(t){var r=P4(t,"string");return Ms(r)=="symbol"?r:r+""}function P4(t,r){if(Ms(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r);if(Ms(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}var k4=function(){function t(){O4(this,t),yl(this,"activeIndex",0),yl(this,"coordinateList",[]),yl(this,"layout","horizontal")}return A4(t,[{key:"setDetails",value:function(n){var a,s=n.coordinateList,i=s===void 0?null:s,o=n.container,l=o===void 0?null:o,c=n.layout,u=c===void 0?null:c,d=n.offset,h=d===void 0?null:d,m=n.mouseHandlerCallback,j=m===void 0?null:m;this.coordinateList=(a=i??this.coordinateList)!==null&&a!==void 0?a:[],this.container=l??this.container,this.layout=u??this.layout,this.offset=h??this.offset,this.mouseHandlerCallback=j??this.mouseHandlerCallback,this.activeIndex=Math.min(Math.max(this.activeIndex,0),this.coordinateList.length-1)}},{key:"focus",value:function(){this.spoofMouse()}},{key:"keyboardEvent",value:function(n){if(this.coordinateList.length!==0)switch(n.key){case"ArrowRight":{if(this.layout!=="horizontal")return;this.activeIndex=Math.min(this.activeIndex+1,this.coordinateList.length-1),this.spoofMouse();break}case"ArrowLeft":{if(this.layout!=="horizontal")return;this.activeIndex=Math.max(this.activeIndex-1,0),this.spoofMouse();break}}}},{key:"setIndex",value:function(n){this.activeIndex=n}},{key:"spoofMouse",value:function(){var n,a;if(this.layout==="horizontal"&&this.coordinateList.length!==0){var s=this.container.getBoundingClientRect(),i=s.x,o=s.y,l=s.height,c=this.coordinateList[this.activeIndex].coordinate,u=((n=window)===null||n===void 0?void 0:n.scrollX)||0,d=((a=window)===null||a===void 0?void 0:a.scrollY)||0,h=i+c+u,m=o+this.offset.top+l/2+d;this.mouseHandlerCallback({pageX:h,pageY:m})}}}])}();function E4(t,r,n){if(n==="number"&&r===!0&&Array.isArray(t)){var a=t==null?void 0:t[0],s=t==null?void 0:t[1];if(a&&s&&me(a)&&me(s))return!0}return!1}function T4(t,r,n,a){var s=a/2;return{stroke:"none",fill:"#ccc",x:t==="horizontal"?r.x-s:n.left+.5,y:t==="horizontal"?n.top+.5:r.y-s,width:t==="horizontal"?a:n.width-1,height:t==="horizontal"?n.height-1:a}}function tv(t){var r=t.cx,n=t.cy,a=t.radius,s=t.startAngle,i=t.endAngle,o=rt(r,n,a,s),l=rt(r,n,a,i);return{points:[o,l],cx:r,cy:n,radius:a,startAngle:s,endAngle:i}}function $4(t,r,n){var a,s,i,o;if(t==="horizontal")a=r.x,i=a,s=n.top,o=n.top+n.height;else if(t==="vertical")s=r.y,o=s,a=n.left,i=n.left+n.width;else if(r.cx!=null&&r.cy!=null)if(t==="centric"){var l=r.cx,c=r.cy,u=r.innerRadius,d=r.outerRadius,h=r.angle,m=rt(l,c,u,h),j=rt(l,c,d,h);a=m.x,s=m.y,i=j.x,o=j.y}else return tv(r);return[{x:a,y:s},{x:i,y:o}]}function Is(t){"@babel/helpers - typeof";return Is=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Is(t)}function Pm(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function ii(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?Pm(Object(n),!0).forEach(function(a){D4(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Pm(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function D4(t,r,n){return r=M4(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function M4(t){var r=I4(t,"string");return Is(r)=="symbol"?r:r+""}function I4(t,r){if(Is(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(Is(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function L4(t){var r,n,a=t.element,s=t.tooltipEventType,i=t.isActive,o=t.activeCoordinate,l=t.activePayload,c=t.offset,u=t.activeTooltipIndex,d=t.tooltipAxisBandSize,h=t.layout,m=t.chartName,j=(r=a.props.cursor)!==null&&r!==void 0?r:(n=a.type.defaultProps)===null||n===void 0?void 0:n.cursor;if(!a||!j||!i||!o||m!=="ScatterChart"&&s!=="axis")return null;var w,x=Ii;if(m==="ScatterChart")w=o,x=tk;else if(m==="BarChart")w=T4(h,o,c,d),x=Sd;else if(h==="radial"){var v=tv(o),y=v.cx,f=v.cy,b=v.radius,p=v.startAngle,g=v.endAngle;w={cx:y,cy:f,startAngle:p,endAngle:g,innerRadius:b,outerRadius:b},x=Jp}else w={points:$4(h,o,c)},x=Ii;var N=ii(ii(ii(ii({stroke:"#ccc",pointerEvents:"none"},c),w),Oe(j,!1)),{},{payload:l,payloadIndex:u,className:Le("recharts-tooltip-cursor",j.className)});return _.isValidElement(j)?_.cloneElement(j,N):_.createElement(x,N)}var R4=["item"],F4=["children","className","width","height","style","compact","title","desc"];function ya(t){"@babel/helpers - typeof";return ya=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},ya(t)}function Ja(){return Ja=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},Ja.apply(this,arguments)}function km(t,r){return U4(t)||z4(t,r)||nv(t,r)||B4()}function B4(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
122In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function z4(t,r){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var a,s,i,o,l=[],c=!0,u=!1;try{if(i=(n=n.call(t)).next,r!==0)for(;!(c=(a=i.call(n)).done)&&(l.push(a.value),l.length!==r);c=!0);}catch(d){u=!0,s=d}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw s}}return l}}function U4(t){if(Array.isArray(t))return t}function Em(t,r){if(t==null)return{};var n=q4(t,r),a,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)a=i[s],!(r.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(t,a)&&(n[a]=t[a])}return n}function q4(t,r){if(t==null)return{};var n={};for(var a in t)if(Object.prototype.hasOwnProperty.call(t,a)){if(r.indexOf(a)>=0)continue;n[a]=t[a]}return n}function V4(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function W4(t,r){for(var n=0;n<r.length;n++){var a=r[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,av(a.key),a)}}function K4(t,r,n){return r&&W4(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function G4(t,r,n){return r=so(r),H4(t,rv()?Reflect.construct(r,n||[],so(t).constructor):r.apply(t,n))}function H4(t,r){if(r&&(ya(r)==="object"||typeof r=="function"))return r;if(r!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return X4(t)}function X4(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function rv(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(rv=function(){return!!t})()}function so(t){return so=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},so(t)}function Y4(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&Hc(t,r)}function Hc(t,r){return Hc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,s){return a.__proto__=s,a},Hc(t,r)}function ja(t){return J4(t)||Z4(t)||nv(t)||Q4()}function Q4(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
123In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function nv(t,r){if(t){if(typeof t=="string")return Xc(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Xc(t,r)}}function Z4(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function J4(t){if(Array.isArray(t))return Xc(t)}function Xc(t,r){(r==null||r>t.length)&&(r=t.length);for(var n=0,a=new Array(r);n<r;n++)a[n]=t[n];return a}function Tm(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,a)}return n}function ae(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?Tm(Object(n),!0).forEach(function(a){Ee(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Tm(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function Ee(t,r,n){return r=av(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function av(t){var r=eD(t,"string");return ya(r)=="symbol"?r:r+""}function eD(t,r){if(ya(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,r||"default");if(ya(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}var tD={xAxis:["bottom","top"],yAxis:["left","right"]},rD={width:"100%",height:"100%"},sv={x:0,y:0};function oi(t){return t}var nD=function(r,n){return n==="horizontal"?r.x:n==="vertical"?r.y:n==="centric"?r.angle:r.radius},aD=function(r,n,a,s){var i=n.find(function(d){return d&&d.index===a});if(i){if(r==="horizontal")return{x:i.coordinate,y:s.y};if(r==="vertical")return{x:s.x,y:i.coordinate};if(r==="centric"){var o=i.coordinate,l=s.radius;return ae(ae(ae({},s),rt(s.cx,s.cy,l,o)),{},{angle:o,radius:l})}var c=i.coordinate,u=s.angle;return ae(ae(ae({},s),rt(s.cx,s.cy,c,u)),{},{angle:u,radius:c})}return sv},Yo=function(r,n){var a=n.graphicalItems,s=n.dataStartIndex,i=n.dataEndIndex,o=(a??[]).reduce(function(l,c){var u=c.props.data;return u&&u.length?[].concat(ja(l),ja(u)):l},[]);return o.length>0?o:r&&r.length&&me(s)&&me(i)?r.slice(s,i+1):[]};function iv(t){return t==="number"?[0,"auto"]:void 0}var Yc=function(r,n,a,s){var i=r.graphicalItems,o=r.tooltipAxis,l=Yo(n,r);return a<0||!i||!i.length||a>=l.length?null:i.reduce(function(c,u){var d,h=(d=u.props.data)!==null&&d!==void 0?d:n;h&&r.dataStartIndex+r.dataEndIndex!==0&&r.dataEndIndex-r.dataStartIndex>=a&&(h=h.slice(r.dataStartIndex,r.dataEndIndex+1));var m;if(o.dataKey&&!o.allowDuplicatedCategory){var j=h===void 0?l:h;m=gi(j,o.dataKey,s)}else m=h&&h[a]||l[a];return m?[].concat(ja(c),[Gp(u,m)]):c},[])},$m=function(r,n,a,s){var i=s||{x:r.chartX,y:r.chartY},o=nD(i,a),l=r.orderedTooltipTicks,c=r.tooltipAxis,u=r.tooltipTicks,d=BO(o,l,u,c);if(d>=0&&u){var h=u[d]&&u[d].value,m=Yc(r,n,d,h),j=aD(a,l,d,i);return{activeTooltipIndex:d,activeLabel:h,activePayload:m,activeCoordinate:j}}return null},sD=function(r,n){var a=n.axes,s=n.graphicalItems,i=n.axisType,o=n.axisIdKey,l=n.stackGroups,c=n.dataStartIndex,u=n.dataEndIndex,d=r.layout,h=r.children,m=r.stackOffset,j=zp(d,i);return a.reduce(function(w,x){var v,y=x.type.defaultProps!==void 0?ae(ae({},x.type.defaultProps),x.props):x.props,f=y.type,b=y.dataKey,p=y.allowDataOverflow,g=y.allowDuplicatedCategory,N=y.scale,S=y.ticks,O=y.includeHidden,C=y[o];if(w[C])return w;var P=Yo(r.data,{graphicalItems:s.filter(function(V){var se,ue=o in V.props?V.props[o]:(se=V.type.defaultProps)===null||se===void 0?void 0:se[o];return ue===C}),dataStartIndex:c,dataEndIndex:u}),$=P.length,A,I,D;E4(y.domain,p,f)&&(A=cc(y.domain,null,p),j&&(f==="number"||N!=="auto")&&(D=Ha(P,b,"category")));var q=iv(f);if(!A||A.length===0){var F,K=(F=y.domain)!==null&&F!==void 0?F:q;if(b){if(A=Ha(P,b,f),f==="category"&&j){var M=mj(A);g&&M?(I=A,A=Ki(0,$)):g||(A=th(K,A,x).reduce(function(V,se){return V.indexOf(se)>=0?V:[].concat(ja(V),[se])},[]))}else if(f==="category")g?A=A.filter(function(V){return V!==""&&!Ie(V)}):A=th(K,A,x).reduce(function(V,se){return V.indexOf(se)>=0||se===""||Ie(se)?V:[].concat(ja(V),[se])},[]);else if(f==="number"){var E=WO(P,s.filter(function(V){var se,ue,z=o in V.props?V.props[o]:(se=V.type.defaultProps)===null||se===void 0?void 0:se[o],he="hide"in V.props?V.props.hide:(ue=V.type.defaultProps)===null||ue===void 0?void 0:ue.hide;return z===C&&(O||!he)}),b,i,d);E&&(A=E)}j&&(f==="number"||N!=="auto")&&(D=Ha(P,b,"category"))}else j?A=Ki(0,$):l&&l[C]&&l[C].hasStack&&f==="number"?A=m==="expand"?[0,1]:Kp(l[C].stackGroups,c,u):A=Bp(P,s.filter(function(V){var se=o in V.props?V.props[o]:V.type.defaultProps[o],ue="hide"in V.props?V.props.hide:V.type.defaultProps.hide;return se===C&&(O||!ue)}),f,d,!0);if(f==="number")A=Gc(h,A,C,i,S),K&&(A=cc(K,A,p));else if(f==="category"&&K){var Q=K,H=A.every(function(V){return Q.indexOf(V)>=0});H&&(A=Q)}}return ae(ae({},w),{},Ee({},C,ae(ae({},y),{},{axisType:i,domain:A,categoricalDomain:D,duplicateDomain:I,originalDomain:(v=y.domain)!==null&&v!==void 0?v:q,isCategorical:j,layout:d})))},{})},iD=function(r,n){var a=n.graphicalItems,s=n.Axis,i=n.axisType,o=n.axisIdKey,l=n.stackGroups,c=n.dataStartIndex,u=n.dataEndIndex,d=r.layout,h=r.children,m=Yo(r.data,{graphicalItems:a,dataStartIndex:c,dataEndIndex:u}),j=m.length,w=zp(d,i),x=-1;return a.reduce(function(v,y){var f=y.type.defaultProps!==void 0?ae(ae({},y.type.defaultProps),y.props):y.props,b=f[o],p=iv("number");if(!v[b]){x++;var g;return w?g=Ki(0,j):l&&l[b]&&l[b].hasStack?(g=Kp(l[b].stackGroups,c,u),g=Gc(h,g,b,i)):(g=cc(p,Bp(m,a.filter(function(N){var S,O,C=o in N.props?N.props[o]:(S=N.type.defaultProps)===null||S===void 0?void 0:S[o],P="hide"in N.props?N.props.hide:(O=N.type.defaultProps)===null||O===void 0?void 0:O.hide;return C===b&&!P}),"number",d),s.defaultProps.allowDataOverflow),g=Gc(h,g,b,i)),ae(ae({},v),{},Ee({},b,ae(ae({axisType:i},s.defaultProps),{},{hide:!0,orientation:Jt(tD,"".concat(i,".").concat(x%2),null),domain:g,originalDomain:p,isCategorical:w,layout:d})))}return v},{})},oD=function(r,n){var a=n.axisType,s=a===void 0?"xAxis":a,i=n.AxisComp,o=n.graphicalItems,l=n.stackGroups,c=n.dataStartIndex,u=n.dataEndIndex,d=r.children,h="".concat(s,"Id"),m=er(d,i),j={};return m&&m.length?j=sD(r,{axes:m,graphicalItems:o,axisType:s,axisIdKey:h,stackGroups:l,dataStartIndex:c,dataEndIndex:u}):o&&o.length&&(j=iD(r,{Axis:i,graphicalItems:o,axisType:s,axisIdKey:h,stackGroups:l,dataStartIndex:c,dataEndIndex:u})),j},lD=function(r){var n=tn(r),a=Gr(n,!1,!0);return{tooltipTicks:a,orderedTooltipTicks:jd(a,function(s){return s.coordinate}),tooltipAxis:n,tooltipAxisBandSize:$i(n,a)}},Dm=function(r){var n=r.children,a=r.defaultShowTooltip,s=Gt(n,la),i=0,o=0;return r.data&&r.data.length!==0&&(o=r.data.length-1),s&&s.props&&(s.props.startIndex>=0&&(i=s.props.startIndex),s.props.endIndex>=0&&(o=s.props.endIndex)),{chartX:0,chartY:0,dataStartIndex:i,dataEndIndex:o,activeTooltipIndex:-1,isTooltipActive:!!a}},cD=function(r){return!r||!r.length?!1:r.some(function(n){var a=Hr(n&&n.type);return a&&a.indexOf("Bar")>=0})},Mm=function(r){return r==="horizontal"?{numericAxisName:"yAxis",cateAxisName:"xAxis"}:r==="vertical"?{numericAxisName:"xAxis",cateAxisName:"yAxis"}:r==="centric"?{numericAxisName:"radiusAxis",cateAxisName:"angleAxis"}:{numericAxisName:"angleAxis",cateAxisName:"radiusAxis"}},dD=function(r,n){var a=r.props,s=r.graphicalItems,i=r.xAxisMap,o=i===void 0?{}:i,l=r.yAxisMap,c=l===void 0?{}:l,u=a.width,d=a.height,h=a.children,m=a.margin||{},j=Gt(h,la),w=Gt(h,an),x=Object.keys(c).reduce(function(g,N){var S=c[N],O=S.orientation;return!S.mirror&&!S.hide?ae(ae({},g),{},Ee({},O,g[O]+S.width)):g},{left:m.left||0,right:m.right||0}),v=Object.keys(o).reduce(function(g,N){var S=o[N],O=S.orientation;return!S.mirror&&!S.hide?ae(ae({},g),{},Ee({},O,Jt(g,"".concat(O))+S.height)):g},{top:m.top||0,bottom:m.bottom||0}),y=ae(ae({},v),x),f=y.bottom;j&&(y.bottom+=j.props.height||la.defaultProps.height),w&&n&&(y=qO(y,s,a,n));var b=u-y.left-y.right,p=d-y.top-y.bottom;return ae(ae({brushBottom:f},y),{},{width:Math.max(b,0),height:Math.max(p,0)})},uD=function(r,n){if(n==="xAxis")return r[n].width;if(n==="yAxis")return r[n].height},Md=function(r){var n=r.chartName,a=r.GraphicalChild,s=r.defaultTooltipEventType,i=s===void 0?"axis":s,o=r.validateTooltipEventTypes,l=o===void 0?["axis"]:o,c=r.axisComponents,u=r.legendContent,d=r.formatAxisMap,h=r.defaultProps,m=function(v,y){var f=y.graphicalItems,b=y.stackGroups,p=y.offset,g=y.updateId,N=y.dataStartIndex,S=y.dataEndIndex,O=v.barSize,C=v.layout,P=v.barGap,$=v.barCategoryGap,A=v.maxBarSize,I=Mm(C),D=I.numericAxisName,q=I.cateAxisName,F=cD(f),K=[];return f.forEach(function(M,E){var Q=Yo(v.data,{graphicalItems:[M],dataStartIndex:N,dataEndIndex:S}),H=M.type.defaultProps!==void 0?ae(ae({},M.type.defaultProps),M.props):M.props,V=H.dataKey,se=H.maxBarSize,ue=H["".concat(D,"Id")],z=H["".concat(q,"Id")],he={},ne=c.reduce(function(yt,zt){var Ar=y["".concat(zt.axisType,"Map")],ur=H["".concat(zt.axisType,"Id")];Ar&&Ar[ur]||zt.axisType==="zAxis"||In();var ee=Ar[ur];return ae(ae({},yt),{},Ee(Ee({},zt.axisType,ee),"".concat(zt.axisType,"Ticks"),Gr(ee)))},he),fe=ne[q],De=ne["".concat(q,"Ticks")],Ce=b&&b[ue]&&b[ue].hasStack&&eC(M,b[ue].stackGroups),Re=Hr(M.type).indexOf("Bar")>=0,T=$i(fe,De),ie=[],Se=F&&zO({barSize:O,stackGroups:b,totalSize:uD(ne,q)});if(Re){var Ae,Pe,Ue=Ie(se)?A:se,be=(Ae=(Pe=$i(fe,De,!0))!==null&&Pe!==void 0?Pe:Ue)!==null&&Ae!==void 0?Ae:0;ie=UO({barGap:P,barCategoryGap:$,bandSize:be!==T?be:T,sizeList:Se[z],maxBarSize:Ue}),be!==T&&(ie=ie.map(function(yt){return ae(ae({},yt),{},{position:ae(ae({},yt.position),{},{offset:yt.position.offset-be/2})})}))}var ot=M&&M.type&&M.type.getComposedData;ot&&K.push({props:ae(ae({},ot(ae(ae({},ne),{},{displayedData:Q,props:v,dataKey:V,item:M,bandSize:T,barPosition:ie,offset:p,stackedData:Ce,layout:C,dataStartIndex:N,dataEndIndex:S}))),{},Ee(Ee(Ee({key:M.key||"item-".concat(E)},D,ne[D]),q,ne[q]),"animationId",g)),childIndex:Sj(M,v.children),item:M})}),K},j=function(v,y){var f=v.props,b=v.dataStartIndex,p=v.dataEndIndex,g=v.updateId;if(!eu({props:f}))return null;var N=f.children,S=f.layout,O=f.stackOffset,C=f.data,P=f.reverseStackOrder,$=Mm(S),A=$.numericAxisName,I=$.cateAxisName,D=er(N,a),q=ZO(C,D,"".concat(A,"Id"),"".concat(I,"Id"),O,P),F=c.reduce(function(H,V){var se="".concat(V.axisType,"Map");return ae(ae({},H),{},Ee({},se,oD(f,ae(ae({},V),{},{graphicalItems:D,stackGroups:V.axisType===A&&q,dataStartIndex:b,dataEndIndex:p}))))},{}),K=dD(ae(ae({},F),{},{props:f,graphicalItems:D}),y==null?void 0:y.legendBBox);Object.keys(F).forEach(function(H){F[H]=d(f,F[H],K,H.replace("Map",""),n)});var M=F["".concat(I,"Map")],E=lD(M),Q=m(f,ae(ae({},F),{},{dataStartIndex:b,dataEndIndex:p,updateId:g,graphicalItems:D,stackGroups:q,offset:K}));return ae(ae({formattedGraphicalItems:Q,graphicalItems:D,offset:K,stackGroups:q},E),F)},w=function(x){function v(y){var f,b,p;return V4(this,v),p=G4(this,v,[y]),Ee(p,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),Ee(p,"accessibilityManager",new k4),Ee(p,"handleLegendBBoxUpdate",function(g){if(g){var N=p.state,S=N.dataStartIndex,O=N.dataEndIndex,C=N.updateId;p.setState(ae({legendBBox:g},j({props:p.props,dataStartIndex:S,dataEndIndex:O,updateId:C},ae(ae({},p.state),{},{legendBBox:g}))))}}),Ee(p,"handleReceiveSyncEvent",function(g,N,S){if(p.props.syncId===g){if(S===p.eventEmitterSymbol&&typeof p.props.syncMethod!="function")return;p.applySyncEvent(N)}}),Ee(p,"handleBrushChange",function(g){var N=g.startIndex,S=g.endIndex;if(N!==p.state.dataStartIndex||S!==p.state.dataEndIndex){var O=p.state.updateId;p.setState(function(){return ae({dataStartIndex:N,dataEndIndex:S},j({props:p.props,dataStartIndex:N,dataEndIndex:S,updateId:O},p.state))}),p.triggerSyncEvent({dataStartIndex:N,dataEndIndex:S})}}),Ee(p,"handleMouseEnter",function(g){var N=p.getMouseInfo(g);if(N){var S=ae(ae({},N),{},{isTooltipActive:!0});p.setState(S),p.triggerSyncEvent(S);var O=p.props.onMouseEnter;$e(O)&&O(S,g)}}),Ee(p,"triggeredAfterMouseMove",function(g){var N=p.getMouseInfo(g),S=N?ae(ae({},N),{},{isTooltipActive:!0}):{isTooltipActive:!1};p.setState(S),p.triggerSyncEvent(S);var O=p.props.onMouseMove;$e(O)&&O(S,g)}),Ee(p,"handleItemMouseEnter",function(g){p.setState(function(){return{isTooltipActive:!0,activeItem:g,activePayload:g.tooltipPayload,activeCoordinate:g.tooltipPosition||{x:g.cx,y:g.cy}}})}),Ee(p,"handleItemMouseLeave",function(){p.setState(function(){return{isTooltipActive:!1}})}),Ee(p,"handleMouseMove",function(g){g.persist(),p.throttleTriggeredAfterMouseMove(g)}),Ee(p,"handleMouseLeave",function(g){p.throttleTriggeredAfterMouseMove.cancel();var N={isTooltipActive:!1};p.setState(N),p.triggerSyncEvent(N);var S=p.props.onMouseLeave;$e(S)&&S(N,g)}),Ee(p,"handleOuterEvent",function(g){var N=_j(g),S=Jt(p.props,"".concat(N));if(N&&$e(S)){var O,C;/.*touch.*/i.test(N)?C=p.getMouseInfo(g.changedTouches[0]):C=p.getMouseInfo(g),S((O=C)!==null&&O!==void 0?O:{},g)}}),Ee(p,"handleClick",function(g){var N=p.getMouseInfo(g);if(N){var S=ae(ae({},N),{},{isTooltipActive:!0});p.setState(S),p.triggerSyncEvent(S);var O=p.props.onClick;$e(O)&&O(S,g)}}),Ee(p,"handleMouseDown",function(g){var N=p.props.onMouseDown;if($e(N)){var S=p.getMouseInfo(g);N(S,g)}}),Ee(p,"handleMouseUp",function(g){var N=p.props.onMouseUp;if($e(N)){var S=p.getMouseInfo(g);N(S,g)}}),Ee(p,"handleTouchMove",function(g){g.changedTouches!=null&&g.changedTouches.length>0&&p.throttleTriggeredAfterMouseMove(g.changedTouches[0])}),Ee(p,"handleTouchStart",function(g){g.changedTouches!=null&&g.changedTouches.length>0&&p.handleMouseDown(g.changedTouches[0])}),Ee(p,"handleTouchEnd",function(g){g.changedTouches!=null&&g.changedTouches.length>0&&p.handleMouseUp(g.changedTouches[0])}),Ee(p,"triggerSyncEvent",function(g){p.props.syncId!==void 0&&vl.emit(gl,p.props.syncId,g,p.eventEmitterSymbol)}),Ee(p,"applySyncEvent",function(g){var N=p.props,S=N.layout,O=N.syncMethod,C=p.state.updateId,P=g.dataStartIndex,$=g.dataEndIndex;if(g.dataStartIndex!==void 0||g.dataEndIndex!==void 0)p.setState(ae({dataStartIndex:P,dataEndIndex:$},j({props:p.props,dataStartIndex:P,dataEndIndex:$,updateId:C},p.state)));else if(g.activeTooltipIndex!==void 0){var A=g.chartX,I=g.chartY,D=g.activeTooltipIndex,q=p.state,F=q.offset,K=q.tooltipTicks;if(!F)return;if(typeof O=="function")D=O(K,g);else if(O==="value"){D=-1;for(var M=0;M<K.length;M++)if(K[M].value===g.activeLabel){D=M;break}}var E=ae(ae({},F),{},{x:F.left,y:F.top}),Q=Math.min(A,E.x+E.width),H=Math.min(I,E.y+E.height),V=K[D]&&K[D].value,se=Yc(p.state,p.props.data,D),ue=K[D]?{x:S==="horizontal"?K[D].coordinate:Q,y:S==="horizontal"?H:K[D].coordinate}:sv;p.setState(ae(ae({},g),{},{activeLabel:V,activeCoordinate:ue,activePayload:se,activeTooltipIndex:D}))}else p.setState(g)}),Ee(p,"renderCursor",function(g){var N,S=p.state,O=S.isTooltipActive,C=S.activeCoordinate,P=S.activePayload,$=S.offset,A=S.activeTooltipIndex,I=S.tooltipAxisBandSize,D=p.getTooltipEventType(),q=(N=g.props.active)!==null&&N!==void 0?N:O,F=p.props.layout,K=g.key||"_recharts-cursor";return L.createElement(L4,{key:K,activeCoordinate:C,activePayload:P,activeTooltipIndex:A,chartName:n,element:g,isActive:q,layout:F,offset:$,tooltipAxisBandSize:I,tooltipEventType:D})}),Ee(p,"renderPolarAxis",function(g,N,S){var O=Jt(g,"type.axisType"),C=Jt(p.state,"".concat(O,"Map")),P=g.type.defaultProps,$=P!==void 0?ae(ae({},P),g.props):g.props,A=C&&C[$["".concat(O,"Id")]];return _.cloneElement(g,ae(ae({},A),{},{className:Le(O,A.className),key:g.key||"".concat(N,"-").concat(S),ticks:Gr(A,!0)}))}),Ee(p,"renderPolarGrid",function(g){var N=g.props,S=N.radialLines,O=N.polarAngles,C=N.polarRadius,P=p.state,$=P.radiusAxisMap,A=P.angleAxisMap,I=tn($),D=tn(A),q=D.cx,F=D.cy,K=D.innerRadius,M=D.outerRadius;return _.cloneElement(g,{polarAngles:Array.isArray(O)?O:Gr(D,!0).map(function(E){return E.coordinate}),polarRadius:Array.isArray(C)?C:Gr(I,!0).map(function(E){return E.coordinate}),cx:q,cy:F,innerRadius:K,outerRadius:M,key:g.key||"polar-grid",radialLines:S})}),Ee(p,"renderLegend",function(){var g=p.state.formattedGraphicalItems,N=p.props,S=N.children,O=N.width,C=N.height,P=p.props.margin||{},$=O-(P.left||0)-(P.right||0),A=Rp({children:S,formattedGraphicalItems:g,legendWidth:$,legendContent:u});if(!A)return null;var I=A.item,D=Em(A,R4);return _.cloneElement(I,ae(ae({},D),{},{chartWidth:O,chartHeight:C,margin:P,onBBoxUpdate:p.handleLegendBBoxUpdate}))}),Ee(p,"renderTooltip",function(){var g,N=p.props,S=N.children,O=N.accessibilityLayer,C=Gt(S,Ht);if(!C)return null;var P=p.state,$=P.isTooltipActive,A=P.activeCoordinate,I=P.activePayload,D=P.activeLabel,q=P.offset,F=(g=C.props.active)!==null&&g!==void 0?g:$;return _.cloneElement(C,{viewBox:ae(ae({},q),{},{x:q.left,y:q.top}),active:F,label:D,payload:F?I:[],coordinate:A,accessibilityLayer:O})}),Ee(p,"renderBrush",function(g){var N=p.props,S=N.margin,O=N.data,C=p.state,P=C.offset,$=C.dataStartIndex,A=C.dataEndIndex,I=C.updateId;return _.cloneElement(g,{key:g.key||"_recharts-brush",onChange:ri(p.handleBrushChange,g.props.onChange),data:O,x:me(g.props.x)?g.props.x:P.left,y:me(g.props.y)?g.props.y:P.top+P.height+P.brushBottom-(S.bottom||0),width:me(g.props.width)?g.props.width:P.width,startIndex:$,endIndex:A,updateId:"brush-".concat(I)})}),Ee(p,"renderReferenceElement",function(g,N,S){if(!g)return null;var O=p,C=O.clipPathId,P=p.state,$=P.xAxisMap,A=P.yAxisMap,I=P.offset,D=g.type.defaultProps||{},q=g.props,F=q.xAxisId,K=F===void 0?D.xAxisId:F,M=q.yAxisId,E=M===void 0?D.yAxisId:M;return _.cloneElement(g,{key:g.key||"".concat(N,"-").concat(S),xAxis:$[K],yAxis:A[E],viewBox:{x:I.left,y:I.top,width:I.width,height:I.height},clipPathId:C})}),Ee(p,"renderActivePoints",function(g){var N=g.item,S=g.activePoint,O=g.basePoint,C=g.childIndex,P=g.isRange,$=[],A=N.props.key,I=N.item.type.defaultProps!==void 0?ae(ae({},N.item.type.defaultProps),N.item.props):N.item.props,D=I.activeDot,q=I.dataKey,F=ae(ae({index:C,dataKey:q,cx:S.x,cy:S.y,r:4,fill:_d(N.item),strokeWidth:2,stroke:"#fff",payload:S.payload,value:S.value},Oe(D,!1)),yi(D));return $.push(v.renderActiveDot(D,F,"".concat(A,"-activePoint-").concat(C))),O?$.push(v.renderActiveDot(D,ae(ae({},F),{},{cx:O.x,cy:O.y}),"".concat(A,"-basePoint-").concat(C))):P&&$.push(null),$}),Ee(p,"renderGraphicChild",function(g,N,S){var O=p.filterFormatItem(g,N,S);if(!O)return null;var C=p.getTooltipEventType(),P=p.state,$=P.isTooltipActive,A=P.tooltipAxis,I=P.activeTooltipIndex,D=P.activeLabel,q=p.props.children,F=Gt(q,Ht),K=O.props,M=K.points,E=K.isRange,Q=K.baseLine,H=O.item.type.defaultProps!==void 0?ae(ae({},O.item.type.defaultProps),O.item.props):O.item.props,V=H.activeDot,se=H.hide,ue=H.activeBar,z=H.activeShape,he=!!(!se&&$&&F&&(V||ue||z)),ne={};C!=="axis"&&F&&F.props.trigger==="click"?ne={onClick:ri(p.handleItemMouseEnter,g.props.onClick)}:C!=="axis"&&(ne={onMouseLeave:ri(p.handleItemMouseLeave,g.props.onMouseLeave),onMouseEnter:ri(p.handleItemMouseEnter,g.props.onMouseEnter)});var fe=_.cloneElement(g,ae(ae({},O.props),ne));function De(zt){return typeof A.dataKey=="function"?A.dataKey(zt.payload):null}if(he)if(I>=0){var Ce,Re;if(A.dataKey&&!A.allowDuplicatedCategory){var T=typeof A.dataKey=="function"?De:"payload.".concat(A.dataKey.toString());Ce=gi(M,T,D),Re=E&&Q&&gi(Q,T,D)}else Ce=M==null?void 0:M[I],Re=E&&Q&&Q[I];if(z||ue){var ie=g.props.activeIndex!==void 0?g.props.activeIndex:I;return[_.cloneElement(g,ae(ae(ae({},O.props),ne),{},{activeIndex:ie})),null,null]}if(!Ie(Ce))return[fe].concat(ja(p.renderActivePoints({item:O,activePoint:Ce,basePoint:Re,childIndex:I,isRange:E})))}else{var Se,Ae=(Se=p.getItemByXY(p.state.activeCoordinate))!==null&&Se!==void 0?Se:{graphicalItem:fe},Pe=Ae.graphicalItem,Ue=Pe.item,be=Ue===void 0?g:Ue,ot=Pe.childIndex,yt=ae(ae(ae({},O.props),ne),{},{activeIndex:ot});return[_.cloneElement(be,yt),null,null]}return E?[fe,null,null]:[fe,null]}),Ee(p,"renderCustomized",function(g,N,S){return _.cloneElement(g,ae(ae({key:"recharts-customized-".concat(S)},p.props),p.state))}),Ee(p,"renderMap",{CartesianGrid:{handler:oi,once:!0},ReferenceArea:{handler:p.renderReferenceElement},ReferenceLine:{handler:oi},ReferenceDot:{handler:p.renderReferenceElement},XAxis:{handler:oi},YAxis:{handler:oi},Brush:{handler:p.renderBrush,once:!0},Bar:{handler:p.renderGraphicChild},Line:{handler:p.renderGraphicChild},Area:{handler:p.renderGraphicChild},Radar:{handler:p.renderGraphicChild},RadialBar:{handler:p.renderGraphicChild},Scatter:{handler:p.renderGraphicChild},Pie:{handler:p.renderGraphicChild},Funnel:{handler:p.renderGraphicChild},Tooltip:{handler:p.renderCursor,once:!0},PolarGrid:{handler:p.renderPolarGrid,once:!0},PolarAngleAxis:{handler:p.renderPolarAxis},PolarRadiusAxis:{handler:p.renderPolarAxis},Customized:{handler:p.renderCustomized}}),p.clipPathId="".concat((f=y.id)!==null&&f!==void 0?f:Na("recharts"),"-clip"),p.throttleTriggeredAfterMouseMove=xp(p.triggeredAfterMouseMove,(b=y.throttleDelay)!==null&&b!==void 0?b:1e3/60),p.state={},p}return Y4(v,x),K4(v,[{key:"componentDidMount",value:function(){var f,b;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(f=this.props.margin.left)!==null&&f!==void 0?f:0,top:(b=this.props.margin.top)!==null&&b!==void 0?b:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var f=this.props,b=f.children,p=f.data,g=f.height,N=f.layout,S=Gt(b,Ht);if(S){var O=S.props.defaultIndex;if(!(typeof O!="number"||O<0||O>this.state.tooltipTicks.length-1)){var C=this.state.tooltipTicks[O]&&this.state.tooltipTicks[O].value,P=Yc(this.state,p,O,C),$=this.state.tooltipTicks[O].coordinate,A=(this.state.offset.top+g)/2,I=N==="horizontal",D=I?{x:$,y:A}:{y:$,x:A},q=this.state.formattedGraphicalItems.find(function(K){var M=K.item;return M.type.name==="Scatter"});q&&(D=ae(ae({},D),q.props.points[O].tooltipPosition),P=q.props.points[O].tooltipPayload);var F={activeTooltipIndex:O,isTooltipActive:!0,activeLabel:C,activePayload:P,activeCoordinate:D};this.setState(F),this.renderCursor(S),this.accessibilityManager.setIndex(O)}}}},{key:"getSnapshotBeforeUpdate",value:function(f,b){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==b.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==f.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==f.margin){var p,g;this.accessibilityManager.setDetails({offset:{left:(p=this.props.margin.left)!==null&&p!==void 0?p:0,top:(g=this.props.margin.top)!==null&&g!==void 0?g:0}})}return null}},{key:"componentDidUpdate",value:function(f){Il([Gt(f.children,Ht)],[Gt(this.props.children,Ht)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var f=Gt(this.props.children,Ht);if(f&&typeof f.props.shared=="boolean"){var b=f.props.shared?"axis":"item";return l.indexOf(b)>=0?b:i}return i}},{key:"getMouseInfo",value:function(f){if(!this.container)return null;var b=this.container,p=b.getBoundingClientRect(),g=VS(p),N={chartX:Math.round(f.pageX-g.left),chartY:Math.round(f.pageY-g.top)},S=p.width/b.offsetWidth||1,O=this.inRange(N.chartX,N.chartY,S);if(!O)return null;var C=this.state,P=C.xAxisMap,$=C.yAxisMap,A=this.getTooltipEventType();if(A!=="axis"&&P&&$){var I=tn(P).scale,D=tn($).scale,q=I&&I.invert?I.invert(N.chartX):null,F=D&&D.invert?D.invert(N.chartY):null;return ae(ae({},N),{},{xValue:q,yValue:F})}var K=$m(this.state,this.props.data,this.props.layout,O);return K?ae(ae({},N),K):null}},{key:"inRange",value:function(f,b){var p=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,g=this.props.layout,N=f/p,S=b/p;if(g==="horizontal"||g==="vertical"){var O=this.state.offset,C=N>=O.left&&N<=O.left+O.width&&S>=O.top&&S<=O.top+O.height;return C?{x:N,y:S}:null}var P=this.state,$=P.angleAxisMap,A=P.radiusAxisMap;if($&&A){var I=tn($);return ah({x:N,y:S},I)}return null}},{key:"parseEventsOfWrapper",value:function(){var f=this.props.children,b=this.getTooltipEventType(),p=Gt(f,Ht),g={};p&&b==="axis"&&(p.props.trigger==="click"?g={onClick:this.handleClick}:g={onMouseEnter:this.handleMouseEnter,onMouseMove:this.handleMouseMove,onMouseLeave:this.handleMouseLeave,onTouchMove:this.handleTouchMove,onTouchStart:this.handleTouchStart,onTouchEnd:this.handleTouchEnd});var N=yi(this.props,this.handleOuterEvent);return ae(ae({},N),g)}},{key:"addListener",value:function(){vl.on(gl,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){vl.removeListener(gl,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(f,b,p){for(var g=this.state.formattedGraphicalItems,N=0,S=g.length;N<S;N++){var O=g[N];if(O.item===f||O.props.key===f.key||b===Hr(O.item.type)&&p===O.childIndex)return O}return null}},{key:"renderClipPath",value:function(){var f=this.clipPathId,b=this.state.offset,p=b.left,g=b.top,N=b.height,S=b.width;return L.createElement("defs",null,L.createElement("clipPath",{id:f},L.createElement("rect",{x:p,y:g,height:N,width:S})))}},{key:"getXScales",value:function(){var f=this.state.xAxisMap;return f?Object.entries(f).reduce(function(b,p){var g=km(p,2),N=g[0],S=g[1];return ae(ae({},b),{},Ee({},N,S.scale))},{}):null}},{key:"getYScales",value:function(){var f=this.state.yAxisMap;return f?Object.entries(f).reduce(function(b,p){var g=km(p,2),N=g[0],S=g[1];return ae(ae({},b),{},Ee({},N,S.scale))},{}):null}},{key:"getXScaleByAxisId",value:function(f){var b;return(b=this.state.xAxisMap)===null||b===void 0||(b=b[f])===null||b===void 0?void 0:b.scale}},{key:"getYScaleByAxisId",value:function(f){var b;return(b=this.state.yAxisMap)===null||b===void 0||(b=b[f])===null||b===void 0?void 0:b.scale}},{key:"getItemByXY",value:function(f){var b=this.state,p=b.formattedGraphicalItems,g=b.activeItem;if(p&&p.length)for(var N=0,S=p.length;N<S;N++){var O=p[N],C=O.props,P=O.item,$=P.type.defaultProps!==void 0?ae(ae({},P.type.defaultProps),P.props):P.props,A=Hr(P.type);if(A==="Bar"){var I=(C.data||[]).find(function(K){return MP(f,K)});if(I)return{graphicalItem:O,payload:I}}else if(A==="RadialBar"){var D=(C.data||[]).find(function(K){return ah(f,K)});if(D)return{graphicalItem:O,payload:D}}else if(qo(O,g)||Vo(O,g)||ks(O,g)){var q=NE({graphicalItem:O,activeTooltipItem:g,itemData:$.data}),F=$.activeIndex===void 0?q:$.activeIndex;return{graphicalItem:ae(ae({},O),{},{childIndex:F}),payload:ks(O,g)?$.data[q]:O.props.data[q]}}}return null}},{key:"render",value:function(){var f=this;if(!eu(this))return null;var b=this.props,p=b.children,g=b.className,N=b.width,S=b.height,O=b.style,C=b.compact,P=b.title,$=b.desc,A=Em(b,F4),I=Oe(A,!1);if(C)return L.createElement(hm,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},L.createElement(Rl,Ja({},I,{width:N,height:S,title:P,desc:$}),this.renderClipPath(),ru(p,this.renderMap)));if(this.props.accessibilityLayer){var D,q;I.tabIndex=(D=this.props.tabIndex)!==null&&D!==void 0?D:0,I.role=(q=this.props.role)!==null&&q!==void 0?q:"application",I.onKeyDown=function(K){f.accessibilityManager.keyboardEvent(K)},I.onFocus=function(){f.accessibilityManager.focus()}}var F=this.parseEventsOfWrapper();return L.createElement(hm,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},L.createElement("div",Ja({className:Le("recharts-wrapper",g),style:ae({position:"relative",curs
123or:"default",width:N,height:S},O)},F,{ref:function(M){f.container=M}}),L.createElement(Rl,Ja({},I,{width:N,height:S,title:P,desc:$,style:rD}),this.renderClipPath(),ru(p,this.renderMap)),this.renderLegend(),this.renderTooltip()))}}])}(_.Component);return Ee(w,"displayName",n),Ee(w,"defaultProps",ae({layout:"horizontal",stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:{top:5,right:5,bottom:5,left:5},reverseStackOrder:!1,syncMethod:"index"},h)),Ee(w,"getDerivedStateFromProps",function(x,v){var y=x.dataKey,f=x.data,b=x.children,p=x.width,g=x.height,N=x.layout,S=x.stackOffset,O=x.margin,C=v.dataStartIndex,P=v.dataEndIndex;if(v.updateId===void 0){var $=Dm(x);return ae(ae(ae({},$),{},{updateId:0},j(ae(ae({props:x},$),{},{updateId:0}),v)),{},{prevDataKey:y,prevData:f,prevWidth:p,prevHeight:g,prevLayout:N,prevStackOffset:S,prevMargin:O,prevChildren:b})}if(y!==v.prevDataKey||f!==v.prevData||p!==v.prevWidth||g!==v.prevHeight||N!==v.prevLayout||S!==v.prevStackOffset||!Kn(O,v.prevMargin)){var A=Dm(x),I={chartX:v.chartX,chartY:v.chartY,isTooltipActive:v.isTooltipActive},D=ae(ae({},$m(v,f,N)),{},{updateId:v.updateId+1}),q=ae(ae(ae({},A),I),D);return ae(ae(ae({},q),j(ae({props:x},q),v)),{},{prevDataKey:y,prevData:f,prevWidth:p,prevHeight:g,prevLayout:N,prevStackOffset:S,prevMargin:O,prevChildren:b})}if(!Il(b,v.prevChildren)){var F,K,M,E,Q=Gt(b,la),H=Q&&(F=(K=Q.props)===null||K===void 0?void 0:K.startIndex)!==null&&F!==void 0?F:C,V=Q&&(M=(E=Q.props)===null||E===void 0?void 0:E.endIndex)!==null&&M!==void 0?M:P,se=H!==C||V!==P,ue=!Ie(f),z=ue&&!se?v.updateId:v.updateId+1;return ae(ae({updateId:z},j(ae(ae({props:x},v),{},{updateId:z,dataStartIndex:H,dataEndIndex:V}),v)),{},{prevChildren:b,dataStartIndex:H,dataEndIndex:V})}return null}),Ee(w,"renderActiveDot",function(x,v,y){var f;return _.isValidElement(x)?f=_.cloneElement(x,v):$e(x)?f=x(v):f=L.createElement(Ro,v),L.createElement(Ke,{className:"recharts-active-dot",key:y},f)}),function(v){return L.createElement(w,v)}},hD=Md({chartName:"LineChart",GraphicalChild:Ws,axisComponents:[{axisType:"xAxis",AxisComp:xa},{axisType:"yAxis",AxisComp:ga}],formatAxisMap:Sx}),mD=Md({chartName:"BarChart",GraphicalChild:Rn,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:xa},{axisType:"yAxis",AxisComp:ga}],formatAxisMap:Sx}),Im=Md({chartName:"PieChart",GraphicalChild:Fr,validateTooltipEventTypes:["item"],defaultTooltipEventType:"item",legendContent:"children",axisComponents:[{axisType:"angleAxis",AxisComp:Uo},{axisType:"radiusAxis",AxisComp:Bo}],formatAxisMap:dC,defaultProps:{layout:"centric",startAngle:0,endAngle:360,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"}});const li=["hsl(var(--primary))","hsl(var(--secondary))","hsl(var(--accent))","hsl(var(--muted))"],fD=()=>{const[t,r]=_.useState({totalUsers:0,totalMembers:0,activeLastWeek:0,activeLastMonth:0,activeLastYear:0,registeredLastWeek:0,registeredLastMonth:0,registeredLastYear:0,totalEvents:0,liveEvents:0,completedEvents:0,totalStartups:0,totalCorporate:0,totalMentors:0,totalInvestors:0,liveCompanies:0,draftCompanies:0}),[n,a]=_.useState([]),[s,i]=_.useState(!0);_.useEffect(()=>{o()},[]);const o=async()=>{try{const h=new Date,m=new Date(h.getTime()-7*24*60*60*1e3),j=new Date(h.getTime()-30*24*60*60*1e3),w=new Date(h.getTime()-365*24*60*60*1e3),{data:x,error:v}=await k.from("profiles").select("*");if(v)throw v;const{data:y,error:f}=await k.from("events").select("*");if(f)throw f;const{data:b,error:p}=await k.from("companies").select("*");if(p)throw p;const{data:g,error:N}=await k.from("role_extensions").select("*").eq("role_type","mentor").eq("status","Live");if(N)throw N;const{data:S,error:O}=await k.from("role_extensions").select("*").eq("role_type","investor").eq("status","Live");if(O)throw O;const C=(y||[]).map(z=>{var Ce,Re;const he=z.location||"Vienna",ne=he.includes(",")?he.split(","):[he,""],fe=((Ce=ne[0])==null?void 0:Ce.trim())||"Vienna",De=((Re=ne[1])==null?void 0:Re.trim())||"Austria";return{id:z.id,title:z.title,city:fe,country:De,coordinates:pg[fe]||[16.3738,48.2082],startDate:z.start_date,endD
123ate:z.end_date,status:z.status==="Live"?"Live":z.status==="Draft"?"Draft":"Completed",participants:0,maxParticipants:z.max_participants||0}});a(C);const P=(x==null?void 0:x.length)||0,$=(x==null?void 0:x.filter(z=>z.membership_level==="member"||z.membership_level==="admin").length)||0,A=(x==null?void 0:x.filter(z=>new Date(z.created_at)>=m).length)||0,I=(x==null?void 0:x.filter(z=>new Date(z.created_at)>=j).length)||0,D=(x==null?void 0:x.filter(z=>new Date(z.created_at)>=w).length)||0,q=(x==null?void 0:x.filter(z=>new Date(z.updated_at)>=m).length)||0,F=(x==null?void 0:x.filter(z=>new Date(z.updated_at)>=j).length)||0,K=(x==null?void 0:x.filter(z=>new Date(z.updated_at)>=w).length)||0,M=(y==null?void 0:y.length)||0,E=(y==null?void 0:y.filter(z=>z.status==="Live").length)||0,Q=0,H=(b==null?void 0:b.filter(z=>z.company_type==="startup").length)||0,V=(b==null?void 0:b.filter(z=>z.company_type==="corporate").length)||0,se=(b==null?void 0:b.filter(z=>z.status==="Live").length)||0,ue=(b==null?void 0:b.filter(z=>z.status==="Draft").length)||0;r({totalUsers:P,totalMembers:$,activeLastWeek:q,activeLastMonth:F,activeLastYear:K,registeredLastWeek:A,registeredLastMonth:I,registeredLastYear:D,totalEvents:M,liveEvents:E,completedEvents:Q,totalStartups:H,totalCorporate:V,totalMentors:(g==null?void 0:g.length)||0,totalInvestors:(S==null?void 0:S.length)||0,liveCompanies:se,draftCompanies:ue})}catch(h){console.error("Error fetching analytics:",h)}finally{i(!1)}},l=[{period:"Last Week",value:t.registeredLastWeek},{period:"Last Month",value:t.registeredLastMonth},{period:"Last Year",value:t.registeredLastYear}],c=[{period:"Last Week",value:t.activeLastWeek},{period:"Last Month",value:t.activeLastMonth},{period:"Last Year",value:t.activeLastYear}],u=[{name:"Startups",value:t.totalStartups},{name:"Corporate",value:t.totalCorporate},{name:"Mentors",value:t.totalMentors},{name:"Investors",value:t.totalInvestors},{name:"Other",value:Math.max(0,t.totalUsers-t.totalStartups-t.totalCorporate-t.totalMentors-t.totalInvestors)}],d=[{name:"Live",value:t.liveEvents},{name:"Completed",value:t.completedEvents},{name:"Draft",value:Math.max(0,t.totalEvents-t.liveEvents-t.completedEvents)}];return e.jsxs("div",{className:"flex min-h-screen bg-background",children:[e.jsx(jf,{currentSection:"analytics"}),e.jsx("div",{className:"flex-1 p-6 overflow-auto",children:e.jsxs("div",{className:"space-y-6 max-w-[1600px]",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(lo,{className:"w-6 h-6 text-primary"}),e.jsx("h1",{className:"text-2xl font-bold",children:"Analytics & Reports"})]}),e.jsx(re,{variant:"secondary",children:"Real-time Data"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsxs(Y,{children:[e.jsx(ce,{className:"pb-2",children:e.jsxs(le,{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(Ge,{className:"w-4 h-4"}),"Total Users"]})}),e.jsxs(Z,{children:[e.jsx("div",{className:"text-3xl font-bold",children:t.totalUsers}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[t.totalMembers," members"]})]})]}),e.jsxs(Y,{children:[e.jsx(ce,{className:"pb-2",children:e.jsxs(le,{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx($l,{className:"w-4 h-4"}),"Active This Month"]})}),e.jsxs(Z,{children:[e.jsx("div",{className:"text-3xl font-bold",children:t.activeLastMonth}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[t.activeLastWeek," this week"]})]})]}),e.jsxs(Y,{children:[e.jsx(ce,{className:"pb-2",children:e.jsxs(le,{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(qt,{className:"w-4 h-4"}),"Total Events"]})}),e.jsxs(Z,{children:[e.jsx("div",{className:"text-3xl font-bold",children:t.totalEvents}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[t.liveEvents," currently live"]})]})]}),e.jsxs(Y,{children:[e.jsx(ce,{className:"pb-2",children:e.jsxs(le,{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(It,{className:"w-4 h-4"}),"Ecosystem"]})}),e.jsxs(Z,{children:[e.jsx("div",{className:"text-3xl font-bold",children:t.totalStartups+t.totalCorporate}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[t.totalMentors," mentors · ",t.totalInvestors," investors"]})]})]})]}),e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsxs(le,{className:"flex items-center gap-2",children:[e.jsx(kn,{className:"w-5 h-5"}),"Global Event Network"]})}),e.jsx(Z,{className:"h-[500px]",children:e.jsx(xg,{events:n,onEventSelect:h=>console.log("Selected event:",h),showPastEvents:!0})})]}),e.jsxs(zr,{defaultValue:"registrations",className:"w-full",children:[e.jsxs(Ur,{className:"grid w-full grid-cols-6",children:[e.jsx(Be,{value:"registrations",children:"Registrations"}),e.jsx(Be,{value:"activity",children:"Activity"}),e.jsx(Be,{value:"users",children:"User Types"}),e.jsx(Be,{value:"events",children:"Events"}),e.jsx(Be,{value:"mentors",children:"Mentors"}),e.jsx(Be,{value:"companies",children:"Companies"})]}),e.jsx(ze,{value:"registrations",className:"space-y-4",children:e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsxs(le,{className:"flex items-center gap-2",children:[e.jsx(Fs,{className:"w-5 h-5"}),"New User Registrations"]})}),e.jsx(Z,{children:e.jsx(ei,{width:"100%",height:300,children:e.jsxs(mD,{data:l,children:[e.jsx(Fc,{strokeDasharray:"3 3"}),e.jsx(xa,{dataKey:"period"}),e.jsx(ga,{}),e.jsx(Ht,{}),e.jsx(an,{}),e.jsx(Rn,{dataKey:"value",fill:"hsl(var(--primary))",name:"Registrations"})]})})})]})}),e.jsx(ze,{value:"activity",className:"space-y-4",children:e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsxs(le,{className:"flex items-center gap-2",children:[e.jsx(Jr,{className:"w-5 h-5"}),"User Activity Over Time"]})}),e.jsx(Z,{children:e.jsx(ei,{width:"100%",height:300,children:e.jsxs(hD,{data:c,children:[e.jsx(Fc,{strokeDasharray:"3 3"}),e.jsx(xa,{dataKey:"period"}),e.jsx(ga,{}),e.jsx(Ht,{}),e.jsx(an,{}),e.jsx(Ws,{type:"monotone",dataKey:"value",stroke:"hsl(var(--primary))",name:"Active Users",strokeWidth:2})]})})})]})}),e.jsx(ze,{value:"users",className:"space-y-4",children:e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsxs(le,{className:"flex items-center gap-2",children:[e.jsx(Ge,{className:"w-5 h-5"}),"User Type Distribution"]})}),e.jsx(Z,{children:e.jsx(ei,{width:"100%",height:300,children:e.jsxs(Im,{children:[e.jsx(Fr,{data:u,cx:"50%",cy:"50%",labelLine:!1,label:({name:h,percent:m})=>`${h}: ${(m*100).toFixed(0)}%`,outerRadius:80,fill:"#8884d8",dataKey:"value",children:u.map((h,m)=>e.jsx(us,{fill:li[m%li.length]},`cell-${m}`))}),e.jsx(Ht,{})]})})})]})}),e.jsx(ze,{value:"events",className:"space-y-4",children:e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsxs(le,{className:"flex items-center gap-2",children:[e.jsx(qt,{className:"w-5 h-5"}),"Event Status Overview"]})}),e.jsx(Z,{children:e.jsx(ei,{width:"100%",height:300,children:e.jsxs(Im,{children:[e.jsx(Fr,{data:d,cx:"50%",cy:"50%",labelLine:!1,label:({name:h,percent:m})=>`${h}: ${(m*100).toFixed(0)}%`,outerRadius:80,fill:"#8884d8",dataKey:"value",children:d.map((h,m)=>e.jsx(us,{fill:li[m%li.length]},`cell-${m}`))}),e.jsx(Ht,{})]})})})]})}),e.jsxs(ze,{value:"mentors",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-4",children:[e.jsxs(Y,{children:[e.jsx(ce,{className:"pb-2",children:e.jsx(le,{className:"text-sm font-medium text-muted-foreground",children:"Total Mentors"})}),e.jsx(Z,{children:e.jsx("div",{className:"text-2xl font-bold",children:t.totalMentors})})]}),e.jsxs(Y,{children:[e.jsx(ce,{className:"pb-2",children:e.jsx(le,{className:"text-sm font-medium text-muted-foreground",children:"Active Mentors"})}),e.jsxs(Z,{children:[e.jsx("div",{className:"text-2xl font-bold",children:Math.floor(t.totalMentors
123*.75)}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"75% of total"})]})]}),e.jsxs(Y,{children:[e.jsx(ce,{className:"pb-2",children:e.jsx(le,{className:"text-sm font-medium text-muted-foreground",children:"Avg. Sessions/Mentor"})}),e.jsxs(Z,{children:[e.jsx("div",{className:"text-2xl font-bold",children:"3.2"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Per month"})]})]})]}),e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsxs(le,{className:"flex items-center gap-2",children:[e.jsx(An,{className:"w-5 h-5"}),"Mentor Statistics"]})}),e.jsx(Z,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm font-medium",children:"Public Profiles"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Math.floor(t.totalMentors*.8)})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm font-medium",children:"Protected Profiles"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Math.floor(t.totalMentors*.15)})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm font-medium",children:"Private Profiles"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Math.floor(t.totalMentors*.05)})]}),e.jsx("div",{className:"pt-4 border-t",children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm font-medium",children:"Most Common Expertise"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Marketing, Sales, Product"})]})})]})})]})]}),e.jsxs(ze,{value:"companies",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-4",children:[e.jsxs(Y,{children:[e.jsx(ce,{className:"pb-2",children:e.jsx(le,{className:"text-sm font-medium text-muted-foreground",children:"Total Companies"})}),e.jsx(Z,{children:e.jsx("div",{className:"text-2xl font-bold",children:t.totalStartups+t.totalCorporate})})]}),e.jsxs(Y,{children:[e.jsx(ce,{className:"pb-2",children:e.jsx(le,{className:"text-sm font-medium text-muted-foreground",children:"Live Profiles"})}),e.jsxs(Z,{children:[e.jsx("div",{className:"text-2xl font-bold",children:t.liveCompanies}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[(t.liveCompanies/(t.totalStartups+t.totalCorporate||1)*100).toFixed(0),"% of total"]})]})]}),e.jsxs(Y,{children:[e.jsx(ce,{className:"pb-2",children:e.jsx(le,{className:"text-sm font-medium text-muted-foreground",children:"Avg. Team Size"})}),e.jsxs(Z,{children:[e.jsx("div",{className:"text-2xl font-bold",children:"5.8"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Members"})]})]})]}),e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsxs(le,{className:"flex items-center gap-2",children:[e.jsx(It,{className:"w-5 h-5"}),"Company Statistics"]})}),e.jsx(Z,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm font-medium",children:"Startups"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:t.totalStartups})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm font-medium",children:"Corporate Partners"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:t.totalCorporate})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm font-medium",children:"Draft Profiles"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:t.draftCompanies})]}),e.jsxs("div",{className:"pt-4 border-t",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm font-medium",children:"Most Common Industries"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"SaaS, FinTech, HealthTech"})]}),e.jsxs("div",{className:"flex justify-between items-center mt-2",children:[e.jsx("span",{className:"text-sm font-medium",children:"Most Common Stage"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Seed, Series A"})]})]})]})})]})]})]}),e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsxs(le,{className:"flex items-center gap-2",children:[e.jsx(ns,{className:"w-5 h-5"}),"Membership Overview"]})}),e.jsx(Z,{children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Members"}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:t.totalMembers})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Guest Users"}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:t.totalUsers-t.totalMembers})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Conversion Rate"}),e.jsxs("p",{className:"text-2xl font-bold mt-1",children:[t.totalUsers>0?(t.totalMembers/t.totalUsers*100).toFixed(1):0,"%"]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Admin Users"}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:Math.floor(t.totalMembers*.05)})]})]})})]})]})})]})},pD=()=>{const[t,r]=_.useState([]),[n,a]=_.useState([]),[s,i]=_.useState(!0),{user:o}=Qr(),l=dn(),c=gt();_.useEffect(()=>{if(!o){c("/login");return}u(),d(),h()},[o]);const u=async()=>
123{if(!(o!=null&&o.id))return;const{data:j}=await k.from("admin_users").select("user_id").eq("user_id",o.id).maybeSingle(),{data:w}=await k.from("profiles").select("membership_level").eq("user_id",o.id).single();(j==null?void 0:j.user_id)||(w==null?void 0:w.membership_level)==="admin"||(l.toast.error({title:"Access denied. Admin privileges required."}),c("/dashboard"))},d=async()=>{try{i(!0);const{data:j,error:w}=await k.from("newsletter_campaigns").select("*").order("created_at",{ascending:!1});if(w)throw w;const x=await Promise.all((j||[]).map(async v=>{const{count:y}=await k.from("newsletter_registrations").select("*",{count:"exact",head:!0}).eq("campaign_id",v.id);return{...v,registration_count:y||0}}));r(x)}catch(j){console.error("Error fetching campaigns:",j),l.toast.error({title:"Failed to fetch campaigns"})}finally{i(!1)}},h=async()=>{try{const{data:j,error:w}=await k.from("newsletter_lists").select("*").order("name");if(w)throw w;const x=await Promise.all((j||[]).map(async v=>{const{count:y}=await k.from("newsletter_user_lists").select("*",{count:"exact",head:!0}).eq("list_id",v.id);return{...v,user_count:y||0}}));a(x)}catch(j){console.error("Error fetching lists:",j),l.toast.error({title:"Failed to fetch lists"})}},m=j=>{switch(j){case"draft":return"bg-gray-100 text-gray-800";case"scheduled":return"bg-blue-100 text-blue-800";case"sent":return"bg-green-100 text-green-800";default:return"bg-gray-100 text-gray-800"}};return s?e.jsx("div",{className:"min-h-screen bg-background",children:e.jsx("div",{className:"flex items-center justify-center min-h-[60vh]",children:e.jsx(Qe,{size:64})})}):e.jsx("div",{className:"min-h-screen bg-background",children:e.jsx("main",{className:"py-8",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[e.jsx("div",{className:"bg-gradient-to-r from-muted/50 to-muted rounded-lg p-4 mb-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx(St,{className:"w-6 h-6 text-primary"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-foreground",children:"Newsletter Dashboard"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage newsletter campaigns and track registrations"})]})]}),e.jsxs("div",{className:"flex items-center space-x-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-lg font-bold text-primary",children:t.length}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Total Campaigns"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-lg font-bold text-primary",children:n.reduce((j,w)=>j+(w.user_count||0),0)}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"List Members"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-lg font-bold text-primary",children:t.filter(j=>j.status==="sent").length}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Sent"})]})]})]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"Newsletter Management"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(R,{variant:"outline",onClick:()=>c("/dashboard/admin/newsletter/lists"),className:"bg-background border-border",children:[e.jsx(pi,{className:"w-4 h-4 mr-2"}),"Manage Lists (",n.length,")"]}),e.jsxs(R,{onClick:()=>c("/dashboard/admin/newsletter/create"),className:"bg-primary hover:bg-primary-hover text-primary-foreground",children:[e.jsx(Ve,{className:"w-4 h-4 mr-2"}),"Create Campaign"]})]})]}),e.jsx("div",{className:"space-y-3",children:t.map(j=>e.jsx(Y,{className:"hover:shadow-sm transition-shadow border",children:e.jsx(Z,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(St,{className:"w-4 h-4 text-primary"}),e.jsx("h3",{className:"text-base font-semibold text-foreground",children:j.title}),e.jsx(re,{className:m(j.status),children:j.status})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:j.subject}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Created"}),e.jsx("p",{className:"text-sm text-foreground",children:new Date(j.created_at).toLocaleDateString()})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Status"}),e.jsx("p",{className:"text-sm text-foreground capitalize",children:j.status})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Recipients"}),e.jsx("p",{className:"text-sm text-foreground",children:j.registration_count||0})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Sent"}),e.jsx("p",{className:"text-sm text-foreground",children:j.sent_at?new Date(j.sent_at).toLocaleDateString():"Not sent"})]})]})]}),e.jsx("div",{className:"flex items-center gap-2 ml-4",children:e.jsxs(R,{size:"sm",variant:"outline",className:"h-8 px-3 text-xs",onClick:()=>c(`/dashboard/admin/newsletter/campaign/${j.id}`),children:[e.jsx(dr,{className:"w-3 h-3 mr-1"}),"View Details"]}
123)})]})})},j.id))}),t.length===0&&e.jsx(Y,{children:e.jsxs(Z,{className:"py-12 text-center",children:[e.jsx(St,{className:"w-12 h-12 text-muted-foreground mx-auto mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-foreground mb-2",children:"No campaigns yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Create your first newsletter campaign to get started"}),e.jsxs(R,{onClick:()=>c("/dashboard/admin/newsletter/create"),className:"bg-primary hover:bg-primary-hover text-primary-foreground",children:[e.jsx(Ve,{className:"w-4 h-4 mr-2"}),"Create First Campaign"]})]})})]})]})})})},xD=()=>{const[t,r]=_.useState([]),[n,a]=_.useState(!0),[s,i]=_.useState(!1),[o,l]=_.useState({title:"",subject:"",content:"",status:"draft",selectedLists:[]}),{user:c}=Qr(),u=dn(),d=gt();_.useEffect(()=>{if(!c){d("/login");return}h(),m()},[c]);const h=async()=>{if(!(c!=null&&c.id))return;const{data:y}=await k.from("admin_users").select("user_id").eq("user_id",c.id).maybeSingle(),{data:f}=await k.from("profiles").select("membership_level").eq("user_id",c.id).single();(y==null?void 0:y.user_id)||(f==null?void 0:f.membership_level)==="admin"||(u.toast.error({title:"Access denied. Admin privileges required."}),d("/dashboard"))},m=async()=>{try{a(!0);const{data:y,error:f}=await k.from("newsletter_lists").select("*").order("name");if(f)throw f;const b=await Promise.all((y||[]).map(async p=>{const{count:g}=await k.from("newsletter_user_lists").select("*",{count:"exact",head:!0}).eq("list_id",p.id);return{...p,list_type:p.list_type,user_count:g||0}}));r(b)}catch(y){console.error("Error fetching lists:",y),u.toast.error({title:"Failed to fetch lists"})}finally{a(!1)}},j=async()=>{try{if(!o.title.trim()||!o.subject.trim()){u.toast.error({title:"Title and subject are required"});return}if(o.selectedLists.length===0){u.toast.error({title:"Please select at least one list"});return}i(!0);const{data:y,error:f}=await k.from("newsletter_campaigns").insert({title:o.title,subject:o.subject,content:o.content,status:o.status,created_by:c==null?void 0:c.id}).select().single();if(f)throw f;const b=o.selectedLists.map(g=>({campaign_id:y.id,list_id:g})),{error:p}=await k.from("newsletter_campaign_lists").insert(b);if(p)throw p;u.toast.success({title:"Campaign created successfully"}),d("/dashboard/admin/newsletter")}catch(y){console.error("Error creating campaign:",y),u.toast.error({title:"Failed to create campaign"})}finally{i(!1)}},w=y=>{switch(y){case"public":return"bg-green-100 text-green-800";case"member":return"bg-blue-100 text-blue-800";case"private":return"bg-gray-100 text-gray-800";default:return"bg-gray-100 text-gray-800"}},x=y=>{switch(y){case"public":return"Public";case"member":return"Members Only";case"private":return"Private";default:return"Private"}},v=y=>{l(f=>({...f,selectedLists:f.selectedLists.includes(y)?f.selectedLists.filter(b=>b!==y):[...f.selectedLists,y]}))};return n?e.jsx("div",{className:"min-h-screen bg-background",children:e.jsx("div",{className:"flex items-center justify-center min-h-[60vh]",children:e.jsx(Qe,{size:64})})}):e.jsx("div",{className:"min-h-screen bg-background",children:e.jsx("main",{className:"py-8",children:e.jsxs("div",{className:"max-w-4xl mx-auto px-4 sm:px-6 lg:px-8",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[e.jsxs(R,{variant:"outline",onClick:()=>d("/dashboard/admin/newsletter"),className:"bg-background border-border",children:[e.jsx(Bt,{className:"w-4 h-4 mr-2"}),"Back to Newsletter"]}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Create New Campaign"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Design and send newsletter campaigns to your lists"})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsxs(le,{className:"flex items-center gap-2",children:[e.jsx(St,{className:"w-5 h-5"}),"Campaign Information"]})}),e.jsxs(Z,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(B,{children:"Campaign Title"}),e.jsx(de,{value:o.title,onChange:y=>l(f=>({...f,title:y.target.value})),placeholder:"Enter campaign title"})]}),e.jsxs("div",{children:[e.jsx(B,{children:"Status"}),e.jsxs(xe,{value:o.status,onValueChange:y=>l(f=>({...f,status:y})),children:[e.jsx(ve,{children:e.jsx(ge,{})}),e.jsxs(ye,{children:[e.jsx(J,{value:"draft",children:"Draft"}),e.jsx(J,{value:"scheduled",children:"Scheduled"}),e.jsx(J,{value:"sent",children:"Sent"})]})]})]})]}),e.jsxs("div",{children:[e.jsx(B,{children:"Email Subject"}),e.jsx(de,{value:o.subject,onChange:y=>l(f=>({...f,subject:y.target.value})),placeholder:"Enter email subject line"})]}),e.jsxs("div",{children:[e.jsx(B,{children:"Email Content"}),e.jsx(Pt,{value:o.content,onChange:y=>l(f=>({...f,content:y.target.value})),placeholder:"Enter your email content here...",rows:8,className:"resize-none"})]})]})]}),e.jsxs(Y,{children:[e.jsxs(ce,{children:[e.jsx(le,{children:"Target Lists"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Select which lists should receive this campaign"})]}),e.jsx(Z,{children:e.jsx("div",{className:"space-y-3",children:t.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"No lists available. Create a list first."}),e.jsx(R,{variant:"outline",onClick:()=>d("/dashboard/admin/newsletter/lists"),children:"Manage Lists"})]}):t.map(y=>e.jsxs("div",{className:"flex items-center space-x-3 p-3 border border-border rounded-lg",children:[e.jsx(fo,{id:y.id,checked:o.selectedLists.includes(y.id),onCheckedChange:()=>v(y.id)}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{htmlFor:y.id,className:"text-sm font-medium text-foreground cursor-pointer",children:y.name}),e.jsx(re,{className:w(y.list_type),children:x(y.list_type)})]}),y.description&&e.jsx("p",{className:"text-xs text-muted-foreground",children:y.description}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[y.user_count||0," members"]})]})]},y.id))})})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(R,{variant:"outline",onClick:()=>d("/dashboard/admin/newsletter"),children:"Cancel"}),e.jsx(R,{onClick:j,disabled:s,className:"bg-primary hover:bg-primary-hover text-primary-foreground",children:s?e.jsx(e.Fragment,{children:"Creating..."}):e.jsxs(e.Fragment,{children:[e.jsx(cf,{className:"w-4 h-4 mr-2"}),"Create Campaign"]})})]})]})]})})})},vD=()=>{var fe,De,Ce,Re;const[t,r]=_.useState([]),[n,a]=_.useState([]),[s,i]=_.useState([]),[o,l]=_.useState(!0),[c,u]=_.useState(""),[d,h]=_.useState(""),[m,j]=_.useState(""),[w,x]=_.useState(!0),[v,y]=_.useState("list"),[f,b]=_.useState(!1),[p,g]=_.useState(null),[N,S]=_.useState({title:"",description:"",event_type:"Pre Acceleration",location:"",location_id:"",chapter_id:"",max_participants:"",status:"Draft",visibility:"Private",timezone:"",start_date:"",end_date:""}),{user:O}=Qr(),C=dn(),P=gt();_.useEffect(()=>{if(!O){P("/login");return}$(),A(),I(),D()},[O]);const $=async()=>
123{if(!(O!=null&&O.id))return;const{data:T}=await k.from("admin_users").select("user_id").eq("user_id",O.id).maybeSingle(),{data:ie}=await k.from("profiles").select("membership_level").eq("user_id",O.id).single();(T==null?void 0:T.user_id)||(ie==null?void 0:ie.membership_level)==="admin"||(C.toast.error({title:"Access denied. Admin privileges required."}),P("/dashboard"))},A=async()=>{try{l(!0);const{data:{user:T}}=await k.auth.getUser();if(!T)return;const{data:ie,error:Se}=await k.from("events").select("id, title, description, event_type, location, location_id, max_participants, status, visibility, created_at, updated_at, timezone, start_date, end_date, eventbrite_event_id, eventbrite_enabled, eventbrite_synced_at");if(Se)throw Se;const Ae=await Promise.all((ie||[]).map(async Pe=>{var ot;const{count:Ue}=await k.from("user_roles").select("*",{count:"exact",head:!0}).eq("event_id",Pe.id).eq("status","accepted"),{data:be}=await k.from("chapter_events").select("chapter_id, chapters(name)").eq("event_id",Pe.id).maybeSingle();return{...Pe,participant_count:Ue||0,chapter_name:((ot=be==null?void 0:be.chapters)==null?void 0:ot.name)||null}}));r(Ae)}catch(T){console.error("Error fetching events:",T),C.toast.error({title:"Failed to fetch events"})}finally{l(!1)}},I=async()=>{try{const{data:T,error:ie}=await k.from("locations").select("id, name, address, street_address, address_line_2, city, state_region, postal_code, country_code").order("name");if(ie)throw ie;a(T||[])}catch(T){console.error("Error fetching locations:",T)}},D=async()=>{try{const{data:T,error:ie}=await k.from("chapters").select("id, name, description").order("name");if(ie)throw ie;i(T||[])}catch(T){console.error("Error fetching chapters:",T)}},q=async()=>{try{if(!N.title.trim()){C.toast.error({title:"Title is required"});return}const T=N.start_date?Xs(new Date(N.start_date),N.timezone||"Europe/Vienna"):null,ie=N.end_date?Xs(new Date(N.end_date),N.timezone||"Europe/Vienna"):null,Se={title:N.title,description:N.description||null,event_type:N.event_type,location:N.location||null,timezone:N.timezone||"Europe/Vienna",start_date:T?T.toISOString():null,end_date:ie?ie.toISOString():null,location_id:N.location_id&&N.location_id!=="none"?N.location_id:null,max_participants:N.max_participants?parseInt(N.max_participants):null,status:N.status,visibility:N.visibility},{data:Ae,error:Pe}=await k.from("events").insert(Se).select().single();if(Pe)throw Pe;if(N.chapter_id&&N.chapter_id!=="none"&&Ae){const{error:Ue}=await k.from("chapter_events").insert({chapter_id:N.chapter_id,event_id:Ae.id});Ue&&console.error("Error linking chapter:",Ue)}Ae&&k.functions.invoke("google-drive",{body:{action:"ensure_folder",eventId:Ae.id}}).catch(Ue=>console.warn("Drive folder not created:",Ue)),C.toast.success({title:"Event created successfully"}),b(!1),se(),A()}catch(T){console.error("Error creating event:",T),C.toast.error({title:"Failed to create event"})}},F=async()=>{if(p)try{console.log("Updating event with data:",{start_date:N.start_date,end_date:N.end_date,timezone:N.timezone});let T=null,ie=null;N.start_date&&N.timezone&&(T=Xs(N.start_date,N.timezone),console.log("Start date conversion:",{input:N.start_date,timezone:N.timezone,output:T.toISOString()})),N.end_date&&N.timezone&&(ie=Xs(N.end_date,N.timezone),console.log("End date conversion:",{input:N.end_date,timezone:N.timezone,output:ie.toISOString()}));const Se={title:N.title,description:N.description||null,event_type:N.event_type,location:N.location||null,timezone:N.timezone||"Europe/Vienna",start_date:T?T.toISOString():null,end_date:ie?ie.toISOString():null,location_id:N.location_id&&N.location_id!=="none"?N.location_id:null,max_participants:N.max_participants?parseInt(N.max_participants):null,status:N.status,visibility:N.visibility},{error:Ae}=await k.from("events").update(Se).eq("id",p.id);if(Ae)throw Ae;if(p.eventbrite_enabled&&p.eventbrite_event_id){const{data:Pe,error:Ue}=await k.functions.invoke("eventbrite-sync",{body:{action:"sync",eventId:p.id}});(Ue||!(Pe!=null&&Pe.success))&&C.toast.warning({title:"Event saved, but the Eventbrite update failed"})}if(await k.from("chapter_events").delete().eq("event_id",p.id),N.chapter_id&&N.chapter_id!=="none"){const{error:Pe}=await k.from("chapter_events").insert({chapter_id:N.chapter_id,event_id:p.id});Pe&&console.error("Error linking chapter:",Pe)}C.toast.success({title:"Event updated successfully"}),g(null),se(),A()}catch(T){console.error("Error updating event:",T),C.toast.error({title:"Failed to update event"})}},K=async T=>
123{if(confirm("Are you sure you want to delete this event? This action cannot be undone."))try{const{error:ie}=await k.from("events").delete().eq("id",T);if(ie)throw ie;C.toast.success({title:"Event deleted successfully"}),A()}catch(ie){console.error("Error deleting event:",ie),C.toast.error({title:"Failed to delete event"})}},[M,E]=_.useState(null),Q=async T=>{E(T);try{const ie=await k.functions.invoke("eventbrite-sync",{body:{action:"enable",eventId:T}});if(ie.error)throw ie.error;if(!ie.data.success)throw new Error(ie.data.error||"Failed to enable Eventbrite");C.toast.success({title:"Eventbrite integration enabled"}),A()}catch(ie){console.error("Error enabling Eventbrite:",ie),C.toast.error({title:ie.message||"Failed to enable Eventbrite"})}finally{E(null)}},H=async T=>{E(T);try{const ie=await k.functions.invoke("eventbrite-sync",{body:{action:"sync",eventId:T}});if(ie.error)throw ie.error;if(!ie.data.success)throw new Error(ie.data.error||"Failed to sync with Eventbrite");C.toast.success({title:"Event synced to Eventbrite"}),A()}catch(ie){console.error("Error syncing Eventbrite:",ie),C.toast.error({title:ie.message||"Failed to sync with Eventbrite"})}finally{E(null)}},V=async T=>{E(T);try{const ie=await k.functions.invoke("eventbrite-sync",{body:{action:"disable",eventId:T}});if(ie.error)throw ie.error;if(!ie.data.success)throw new Error(ie.data.error||"Failed to disable Eventbrite");C.toast.success({title:"Eventbrite integration disabled"}),A()}catch(ie){console.error("Error disabling Eventbrite:",ie),C.toast.error({title:ie.message||"Failed to disable Eventbrite"})}finally{E(null)}},se=()=>{S({title:"",description:"",event_type:"Pre Acceleration",location:"",location_id:"none",chapter_id:"",max_participants:"",status:"Draft",visibility:"Private",timezone:"",start_date:"",end_date:""})},ue=T=>{var Ae;g(T);const ie=(Pe,Ue)=>{if(!Pe)return"";try{console.log("Converting UTC to local:",{utcDateString:Pe,tz:Ue});const be=new Date(Pe),ot=$g(be,Ue),yt=Et(ot,"yyyy-MM-dd'T'HH:mm");return console.log("Converted result:",{utcDate:be.toISOString(),zonedDate:ot,formatted:yt}),yt}catch(be){return console.error("Error converting date:",be),""}},Se=T.timezone||"Europe/Vienna";console.log("Opening edit dialog for event:",{eventId:T.id,title:T.title,timezone:Se,start_date:T.start_date,end_date:T.end_date}),S({title:T.title,description:T.description||"",event_type:T.event_type||"Pre Acceleration",location:T.location||"",location_id:T.location_id||"none",chapter_id:T.chapter_id||"",max_participants:((Ae=T.max_participants)==null?void 0:Ae.toString())||"",status:T.status,visibility:T.visibility,timezone:Se,start_date:ie(T.start_date,Se),end_date:ie(T.end_date,Se)})},z=t.filter(T=>{var Pe,Ue;const ie=T.title.toLowerCase().includes(c.toLowerCase())||((Pe=T.description)==null?void 0:Pe.toLowerCase().includes(c.toLowerCase()))||((Ue=T.location)==null?void 0:Ue.toLowerCase().includes(c.toLowerCase())),Se=!d||d==="all"||T.status===d,Ae=!m||m==="all"||T.visibility===m;return ie&&Se&&Ae}).sort((T,ie)=>{const Se=T.created_at?new Date(T.created_at).getTime():0;return(ie.created_at?new Date(ie.created_at).getTime():0)-Se}),he=T=>{switch(T){case"Draft":return"bg-gray-100 text-gray-800";case"Live":return"bg-green-100 text-green-800";case"Cancelled":return"bg-red-100 text-red-800";case"Completed":return"bg-blue-100 text-blue-800";default:return"bg-gray-100 text-gray-800"}},ne=T=>{switch(T){case"Public":return"bg-green-100 text-green-800";case"Protected":return"bg-yellow-100 text-yellow-800";case"Private":return"bg-red-100 text-red-800";default:return"bg-gray-100 text-gray-800"}};return o?e.jsx("div",{className:"min-h-screen bg-background",children:e.jsx("div",{className:"flex items-center justify-center min-h-[60vh]",children:e.jsx(Qe,{size:64})})}):e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-background via-background to-muted/20",children:[e.jsx("main",{className:"py-8",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-3xl font-bold text-foreground mb-2 flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(qt,{className:"w-5 h-5 text-primary"})}),"Event Management"]}),e.jsx("p",{className:"text-muted-foreground",children:"Create, manage, and monitor all your events"})]}),e.jsx(ut,{open:f,onOpenChange:b,children:e.jsx(cn,{asChild:!0,children:e.jsxs(R,{size:"lg",className:"gap-2",children:[e.jsx(Ve,{className:"w-5 h-5"}),"Create Event"]})})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsx(Y,{className:"border-l-4 border-l-primary",children:e.jsx(Z,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Total Events"}),e.jsx("p",{className:"text-3xl font-bold text-foreground",children:t.length})]}),e.jsx(qt,{className:"w-8 h-8 text-primary opacity-50"})]})})}),e.jsx(Y,{className:"border-l-4 border-l-green-500",children:e.jsx(Z,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Live Events"}),e.jsx("p",{className:"text-3xl font-bold text-foreground",children:t.filter(T=>T.status==="Live").length})]}),e.jsx(dr,{className:"w-8 h-8 text-green-500 opacity-50"})]})})}),e.jsx(Y,{className:"border-l-4 border-l-blue-500",children:e.jsx(Z,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Total Participants"}),e.jsx("p",{className:"text-3xl font-bold text-foreground",children:t.reduce((T,ie)=>T+(ie.participant_count||0),0)})]}),e.jsx(Ge,{className:"w-8 h-8 text-blue-500 opacity-50"})]})})}),e.jsx(Y,{className:"border-l-4 border-l-orange-500",children:e.jsx(Z,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Chapters"}),e.jsx("p",{className:"text-3xl font-bold text-foreground",children:t.filter(T=>T.chapter_name).length})]}),e.jsx(It,{className:"w-8 h-8 text-orange-500 opacity-50"})]})})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsx(Y,{children:e.jsx(Z,{className:"p-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsxs("div",{children:[e.jsx(B,{className:"text-sm font-medium",children:"Search Events"}),e.jsx(de,{placeholder:"Search by title, location...",value:c,onChange:T=>u(T.target.value),className:"mt-1.5"})]}),e.jsxs("div",{children:[e.jsx(B,{className:"text-sm font-medium",children:"Status"}),e.jsxs(xe,{value:d,onValueChange:h,children:[e.jsx(ve,{className:"mt-1.5",children:e.jsx(ge,{placeholder:"All statuses"})}),e.jsxs(ye,{children:[e.jsx(J,{value:"all",children:"All statuses"}),e.jsx(J,{value:"Draft",children:"Draft"}),e.jsx(J,{value:"Live",children:"Live"}),e.jsx(J,{value:"Cancelled",children:"Cancelled"}),e.jsx(J,{value:"Completed",children:"Completed"})]})]})]}),e.jsxs("div",{children:[e.jsx(B,{className:"text-sm font-medium",children:"Visibility"}),e.jsxs(xe,{value:m,onValueChange:j,children:[e.jsx(ve,{className:"mt-1.5",children:e.jsx(ge,{placeholder:"All visibility"})}),e.jsxs(ye,{children:[e.jsx(J,{value:"all",children:"All visibility"}),e.jsx(J,{value:"Public",children:"Public"}),e.jsx(J,{value:"Protected",children:"Protected"}),e.jsx(J,{value:"Private",children:"Private"})]})]})]}),e.jsxs("div",{children:[e.jsx(B,{className:"text-sm font-medium",children:"View Mode"}),e.jsxs("div",{className:"flex gap-2 mt-1.5",children:[e.jsxs(R,{variant:v==="list"?"default":"outline",size:"sm",onClick:()=>y("list"),className:"flex-1",children:[e.jsx(pi,{className:"w-4 h-4 mr-2"}),"List"]}),e.jsxs(R,{variant:v==="grid"?"default":"outline",size:"sm",onClick:()=>y("grid"),className:"flex-1",children:[e.jsx(Pg,{className:"w-4 h-4 mr-2"}),"Grid"]})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2 pt-2 border-t",children:[e.jsx(Tt,{id:"upcoming-only",checked:w,onCheckedChange:x}),e.jsx(B,{htmlFor:"upcoming-only",className:"text-sm cursor-pointer font-normal",children:"Show upcoming events only"})]})]})})}),v==="grid"?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:z.map(T=>e.jsxs(Y,{className:"bg-card text-card-foreground shadow-md transition-colors hover:shadow-lg",children:[e.jsxs(ce,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(le,{className:"text-sm font-medium",children:T.title}),e.jsxs("div",{className:"flex space-x-1",children:[T.eventbrite_enabled?e.jsxs(e.Fragment,{children:[e.jsx(R,{variant:"ghost",size:"icon",onClick:()=>H(T.id),disabled:M===T.id,title:"Sync to Eventbrite",children:e.jsx(_n,{className:`h-4 w-4 text-orange-500 ${M===T.id?"animate-spin":""}`})}),e.jsx(R,{variant:"ghost",size:"icon",onClick:()=>V(T.id),disabled:M===T.id,title:"Disable Eventbrite",children:e.jsx(Wd,{className:"h-4 w-4 text-red-500"})})]}):e.jsx(R,{variant:"ghost",size:"icon",onClick:()=>Q(T.id),disabled:M===T.id,title:"Enable Eventbrite Integration",children:e.jsx(Ys,{className:`h-4 w-4 text-blue-500 ${M===T.id?"animate-pulse":""}`})}),e.jsx(R,{variant:"ghost",size:"icon",onClick:()=>ue(T),children:e.jsx(En,{className:"h-4 w-4"})}),e.jsx(R,{variant:"ghost",size:"icon",onClick:()=>K(T.id),children:e.jsx(We,{className:"h-4 w-4 text-red-500"})})]})]}),e.jsxs(Z,{children:[e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:T.description||"No description"}),e.jsxs("div",{className:"flex items-center space-x-1 text-xs mt-2",children:[e.jsx(kn,{className:"h-4 w-4"}),e.jsx("span",{children:T.location||"No location"})]}),T.start_date&&e.jsxs("div",{className:"flex items-center space-x-1 text-xs mt-1",children:[e.jsx($r,{className:"h-4 w-4"}),e.jsx("span",{children:new Date(T.start_date).toLocaleDateString()})]}),e.jsxs("div",{className:"flex justify-between items-center mt-3",children:[e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsx(re,{className:he(T.status),children:T.status}),e.jsx(re,{className:ne(T.visibility),children:T.visibility}),T.eventbrite_enabled&&e.jsxs(re,{className:"bg-orange-100 text-orange-800",children:[e.jsx(Ys,{className:"h-3 w-3 mr-1"}),"EB"]})]}),T.participant_count!==void 0&&e.jsxs("div",{className:"flex items-center space-x-1 text-xs",children:[e.jsx(Ge,{className:"h-4 w-4"}),e.jsx("span",{children:T.participant_count})]})]})]})]},T.id))}):e.jsx("div",{className:"grid grid-cols-1 gap-4",children:z.map(T=>e.jsx(Y,{className:"bg-card text-card-foreground shadow-sm",children:e.jsxs(Z,{className:"grid grid-cols-1 md:grid-cols-4 gap-4 p-6",children:[e.jsxs("div",{className:"md:col-span-1 flex flex-col justify-between",children:[e.jsxs("div",{children:[e.jsx(le,{className:"text-sm font-medium",children:T.title}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:T.description||"No description"})]}),e.jsxs("div",{className:"flex space-x-1 mt-2",children:[T.eventbrite_enabled?e.jsxs(e.Fragment,{children:[e.jsx(R,{variant:"ghost",size:"icon",onClick:()=>H(T.id),disabled:M===T.id,title:"Sync to Eventbrite",children:e.jsx(_n,{className:`h-4 w-4 text-orange-500 ${M===T.id?"animate-spin":""}`})}),e.jsx(R,{variant:"ghost",size:"icon",onClick:()=>V(T.id),disabled:M===T.id,title:"Disable Eventbrite",children:e.jsx(Wd,{className:"h-4 w-4 text-red-500"})})]}):e.jsx(R,{variant:"ghost",size:"icon",onClick:()=>Q(T.id),disabled:M===T.id,title:"Enable Eventbrite Integration",children:e.jsx(Ys,{className:`h-4 w-4 text-blue-500 ${M===T.id?"animate-pulse":""}`})}),e.jsx(R,{variant:"ghost",size:"icon",onClick:()=>ue(T),children:e.jsx(En,{className:"h-4 w-4"})}),e.jsx(R,{variant:"ghost",size:"icon",onClick:()=>K(T.id),children:e.jsx(We,{className:"h-4 w-4 text-red-500"})})]})]}),e.jsxs("div",{className:"md:col-span-3 grid grid-cols-1 md:grid-cols-3 gap-2",children:[e.jsxs("div",{className:"flex items-center space-x-1 text-xs",children:[e.jsx(kn,{className:"h-4 w-4"}),e.jsx("span",{children:T.location||"No location"})]}),T.start_date&&e.jsxs("div",{className:"flex items-center space-x-1 text-xs",children:[e.jsx($r,{className:"h-4 w-4"}),e.jsx("span",{children:new Date(T.start_date).toLocaleDateString()})]}),T.participant_count!==void 0&&e.jsxs("div",{className:"flex items-center space-x-1 text-xs",children:[e.jsx(Ge,{className:"h-4 w-4"}),e.jsxs("span",{children:[T.participant_count," Participants"]})]}),e.jsxs("div",{className:"md:col-span-3 flex items-center space-x-2",children:[e.jsx(re,{className:he(T.status),children:T.status}),e.jsx(re,{className:ne(T.visibility),children:T.visibility}),T.eventbrite_enabled&&e.jsxs(re,{className:"bg-orange-100 text-orange-800",children:[e.jsx(Ys,{className:"h-3 w-3 mr-1"}),"Eventbrite"]})]})]})]})},T.id))})]})]})}),e.jsx(ut,{open:p!==null||f,onOpenChange:T=>{T||(b(!1),g(null),se())},children:e.jsxs(ht,{className:"max-w-2xl",children:[e.jsx(mt,{children:e.jsx(ft,{children:p?"Edit Event":"Create New Event"})}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"title",children:"Title"}),e.jsx(de,{id:"title",value:N.title,onChange:T=>S({...N,title:T.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"event_type",children:"Event Type"}),e.jsxs(xe,{value:N.event_type,onValueChange:T=>S({...N,event_type:T}),children:[e.jsx(ve,{children:e.jsx(ge,{placeholder:"Select event type"})}),e.jsxs(ye,{children:[e.jsx(J,{value:"Pre Acceleration",children:"Pre Acceleration"}),e.jsx(J,{value:"Workshop",children:"Workshop"}),e.jsx(J,{value:"Networking",children:"Networking"})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(uf,{city:((De=(fe=N.location)==null?void 0:fe.split(",")[0])==null?void 0:De.trim())||"",country:((Re=(Ce=N.location)==null?void 0:Ce.split(",").slice(1).join(","))==null?void 0:Re.trim())||"",onCityChange:T=>{S(ie=>{var Ae,Pe;const Se=((Pe=(Ae=ie.location)==null?void 0:Ae.split(",").slice(1).join(","))==null?void 0:Pe.trim())||"";return{...ie,location:Se?`${T}, ${Se}`:T}})},onCountryChange:T=>{S(ie=>{var Ae,Pe;const Se=((Pe=(Ae=ie.location)==null?void 0:Ae.split(",")[0])==null?void 0:Pe.trim())||"";return{...ie,location:`${Se}, ${T}`}})},onTimezoneChange:T=>{S(ie=>({...ie,timezone:T}))}}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"timezone",children:"Timezone"}),e.jsxs(qa,{children:[e.jsx(Va,{asChild:!0,children:e.jsxs(R,{variant:"outline",role:"combobox",className:"w-full justify-between",children:[N.timezone?zd(N.timezone):"Select timezone...",e.jsx(ui,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Wa,{className:"w-[400px] p-0",children:e.jsxs(Ra,{children:[e.jsx(Fa,{placeholder:"Search timezone..."}),e.jsxs(Ba,{children:[e.jsx(za,{children:"No timezone found."}),e.jsx(Ua,{children:kg.map(T=>e.jsxs(yn,{value:T,onSelect:()=>{S({...N,timezone:T})},children:[e.jsx(pr,{className:rs("mr-2 h-4 w-4",N.timezone===T?"opacity-100":"opacity-0")}),zd(T)]},T))})]})]})})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"chapter_id",children:"Chapter (Optional)"}),e.jsxs(xe,{value:N.chapter_id,onValueChange:T=>S({...N,chapter_id:T}),children:[e.jsx(ve,{children:e.jsx(ge,{placeholder:"Select a chapter"})}),e.jsxs(ye,{children:[e.jsx(J,{value:"none",children:"None"}),s.map(T=>e.jsx(J,{value:T.id,children:T.name},T.id))]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"start_date",children:"Start Date & Time"}),e.jsx(de,{id:"start_date",type:"datetime-local",value:N.start_date,onChange:T=>S({...N,start_date:T.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"end_date",children
123:"End Date & Time"}),e.jsx(de,{id:"end_date",type:"datetime-local",value:N.end_date,onChange:T=>S({...N,end_date:T.target.value})})]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"location_id",children:"Registered Venue"}),e.jsxs(xe,{value:N.location_id,onValueChange:T=>{const ie=n.find(Se=>Se.id===T);S({...N,location_id:T,location:ie&&Eg(ie)||N.location})},children:[e.jsx(ve,{children:e.jsx(ge,{placeholder:"Select a venue"})}),e.jsxs(ye,{children:[e.jsx(J,{value:"none",children:"None"}),n.map(T=>e.jsxs(J,{value:T.id,children:[T.name," - ",Tg(T)]},T.id))]})]})]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"max_participants",children:"Max Participants"}),e.jsx(de,{type:"number",id:"max_participants",value:N.max_participants,onChange:T=>S({...N,max_participants:T.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"status",children:"Status"}),e.jsxs(xe,{value:N.status,onValueChange:T=>S({...N,status:T}),children:[e.jsx(ve,{children:e.jsx(ge,{placeholder:"Select status"})}),e.jsxs(ye,{children:[e.jsx(J,{value:"Draft",children:"Draft"}),e.jsx(J,{value:"Live",children:"Live"}),e.jsx(J,{value:"Cancelled",children:"Cancelled"}),e.jsx(J,{value:"Completed",children:"Completed"})]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"visibility",children:"Visibility"}),e.jsxs(xe,{value:N.visibility,onValueChange:T=>S({...N,visibility:T}),children:[e.jsx(ve,{children:e.jsx(ge,{placeholder:"Select visibility"})}),e.jsxs(ye,{children:[e.jsx(J,{value:"Public",children:"Public"}),e.jsx(J,{value:"Protected",children:"Protected"}),e.jsx(J,{value:"Private",children:"Private"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"description",children:"Description"}),e.jsx(Pt,{id:"description",placeholder:"Event description",value:N.description,onChange:T=>S({...N,description:T.target.value})})]})]}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(R,{variant:"secondary",onClick:()=>{b(!1),g(null),se()},children:"Cancel"}),e.jsx(R,{onClick:p?F:q,children:p?"Update Event":"Create Event"})]})]})})]})},gD={toolbar:[[{header:[1,2,3,!1]}],["bold","italic","underline","strike"],[{list:"ordered"},{list:"bullet"}],[{color:[]},{background:[]}],[{align:[]}],["link","image"],["clean"]]},yD=()=>{const[t,r]=_.useState([]),[n,a]=_.useState(!0),[s,i]=_.useState(!1),[o,l]=_.useState(!1),[c,u]=_.useState(null),[d,h]=_.useState({name:"",type:"EMAIL",subject:"",content:"",description:"",variables:[],is_active:!0}),[m,j]=_.useState("");_.useEffect(()=>{w()},[]);const w=async()=>{try{const{data:S,error:O}=await k.from("templates").select("*").eq("type","EMAIL").order("created_at",{ascending:!1});if(O)throw O;const C=(S||[]).map(P=>({...P,variables:Array.isArray(P.variables)?P.variables:typeof P.variables=="string"?[P.variables]:[]}));r(C)}catch(S){we.error({title:"Error loading templates",description:S.message})}finally{a(!1)}},x=()=>{u(null),h({name:"",type:"EMAIL",subject:"",content:"",description:"",variables:[],is_active:!0}),i(!0)},v=S=>{u(S),h({name:S.name,type:S.type,subject:S.subject,content:S.content,description:S.description,variables:S.variables||[],is_active:S.is_active}),i(!0)},y=S=>{u(S),l(!0)},f=async()=>{try{if(!d.name||!d.content){we.error({title:"Missing required fields",description:"Please fill in name and content"});return}
123const S={name:d.name,type:d.type,subject:d.subject,content:d.content,description:d.description,variables:d.variables,is_active:d.is_active,updated_at:new Date().toISOString()};if(c){const{error:O}=await k.from("templates").update(S).eq("id",c.id);if(O)throw O;we.success({title:"Template updated",description:"Email template has been updated successfully"})}else{const{error:O}=await k.from("templates").insert({...S,created_at:new Date().toISOString()});if(O)throw O;we.success({title:"Template created",description:"Email template has been created successfully"})}i(!1),w()}catch(S){we.error({title:"Error saving template",description:S.message})}},b=async S=>{if(confirm(`Are you sure you want to delete the template "${S.name}"?`))try{const{error:O}=await k.from("templates").delete().eq("id",S.id);if(O)throw O;we.success({title:"Template deleted",description:"Email template has been deleted successfully"}),w()}catch(O){we.error({title:"Error deleting template",description:O.message})}},p=()=>{m.trim()&&!d.variables.includes(m.trim())&&(h(S=>({...S,variables:[...S.variables,m.trim()]})),j(""))},g=S=>{h(O=>({...O,variables:O.variables.filter(C=>C!==S)}))},N=()=>{if(!c)return"";let S=c.content;
123return c.variables.forEach(O=>{const C=O==="verification_url"?"https://example.com/verify":O==="unsubscribe_url"?"https://example.com/unsubscribe":O==="email"?"[email protected]":`[${O}]`;S=S.replace(new RegExp(`{{${O}}}`,"g"),C)}),S};return n?e.jsx("div",{className:"flex items-center justify-center p-12",children:e.jsx(Qe,{size:48})}):e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Email Template Management"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage email templates for newsletters and notifications"})]}),e.jsxs(R,{onClick:x,children:[e.jsx(Ve,{className:"w-4 h-4 mr-2"}),"Create Template"]})]}),e.jsx("div",{className:"grid gap-4",children:t.map(S=>e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(le,{className:"text-lg",children:S.name}),e.jsx(re,{variant:S.is_active?"default":"secondary",children:S.is_active?"Active":"Inactive"}),e.jsxs(re,{variant:"outline",children:[e.jsx(St,{className:"w-3 h-3 mr-1"}),S.type]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:S.description}),S.subject&&e.jsxs("p",{className:"text-sm font-medium",children:["Subject: ",S.subject]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(R,{variant:"outline",size:"sm",onClick:()=>y(S),children:e.jsx(dr,{className:"w-4 h-4"})}),e.jsx(R,{variant:"outline",size:"sm",onClick:()=>v(S),children:e.jsx(En,{className:"w-4 h-4"})}),e.jsx(R,{variant:"outline",size:"sm",onClick:()=>b(S),children:e.jsx(We,{className:"w-4 h-4"})})]})]})}),e.jsxs(Z,{children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:S.variables.map(O=>e.jsx(re,{variant:"secondary",className:"text-xs",children:O},O))}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["Last updated: ",new Date(S.updated_at).toLocaleDateString()]})]})]},S.id))}),e.jsx(ut,{open:s,onOpenChange:i,children:e.jsxs(ht,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(mt,{children:[e.jsx(ft,{children:c?"Edit Template":"Create Template"}),e.jsx($t,{children:c?"Update the email template":"Create a new email template"})]}),e.jsxs(zr,{defaultValue:"basic",className:"space-y-4",children:[e.jsxs(Ur,{children:[e.jsx(Be,{value:"basic",children:"Basic Info"}),e.jsx(Be,{value:"content",children:"Content"}),e.jsx(Be,{value:"variables",children:"Variables"})]}),e.jsxs(ze,{value:"basic",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"name",children:"Template Name"}),e.jsx(de,{id:"name",value:d.name,onChange:S=>h(O=>({...O,name:S.target.value})),placeholder:"Enter template name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"type",children:"Type"}),e.jsxs(xe,{value:d.type,onValueChange:S=>h(O=>({...O,type:S})),children:[e.jsx(ve,{children:e.jsx(ge,{})}),e.jsx(ye,{children:e.jsx(J,{value:"EMAIL",children:"EMAIL"})})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"subject",children:"Email Subject"}),e.jsx(de,{id:"subject",value:d.subject,onChange:S=>h(O=>({...O,subject:S.target.value})),placeholder:"Enter email subject"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"description",children:"Description"}),e.jsx(Pt,{id:"description",value:d.description,onChange:S=>h(O=>({...O,description:S.target.value})),placeholder:"Enter template description",rows:3})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Tt,{checked:d.is_active,onCheckedChange:S=>h(O=>({...O,is_active:S}))}),e.jsx(B,{children:"Active Template"})]})]}),e.jsx(ze,{value:"content",className:"space-y-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"content",children:"Email Content"}),e.jsx(La,{theme:"snow",value:d.content,onChange:S=>h(O=>({...O,content:S})),modules:gD,className:"bg-background min-h-[400px]",placeholder:"Enter email content..."}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Use ","{{variable_name}}"," syntax for dynamic content"]})]})}),e.jsxs(ze,{value:"variables",className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Template Variables"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(de,{value:m,onChange:S=>j(S.target.value),placeholder:"Enter variable name",onKeyPress:S=>S.key==="Enter"&&p()}),e.jsx(R,{onClick:p,variant:"outline",children:"Add"})]})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:d.variables.map(S=>e.jsxs(re,{variant:"secondary",className:"cursor-pointer",onClick:()=>g(S),children:[S," ×"]},S))}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Click on a variable to remove it. Variables can be used in content as ","{{variable_name}}"]})]})]}),e.jsxs(Vt,{children:[e.jsx(R,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(R,{onClick:f,children:[c?"Update":"Create"," Template"]})]})]})}),e.jsx(ut,{open:o,onOpenChange:l,children:e.jsxs(ht,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(mt,{children:[e.jsxs(ft,{children:["Template Preview: ",c==null?void 0:c.name]}),e.jsx($t,{children:"Preview of the email template with sample data"})]}),c&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"p-4 bg-gray-50 rounded-lg",children:e.jsxs("p",{className:"font-semibold",children:["Subject: ",c.subject]})}),e.jsx("div",{className:"border rounded-lg p-4 bg-white",dangerouslySetInnerHTML:{__html:N()}})]}),e.jsx(Vt,{children:e.jsx(R,{onClick:()=>l(!1),children:"Close"})})]})})]})},jD=()=>{const{toast:t}=dn(),[r,n]=_.useState(!0),[a,s]=_.useState([]),[i,o]=_.useState(""),[l,c]=_.useState([]),[u,d]=_.useState([]),[h,m]=_.useState([]),[j,w]=_.useState(""),[x,v]=_.useState(""),[y,f]=_.useState({}),[b,p]=_.useState({}),g=_.useMemo(()=>a.find(E=>E.id===i)||null,[a,i]),N=async()=>{const{data:E,error:Q}=await k.from("program_template_sets").select("id, name, description, is_default").order("is_default",{ascending:!1}).order("name");if(Q){t.error({title:"Could not load templates",description:Q.message});return}s(E||[]),o(H=>{var V;return H||((V=E==null?void 0:E[0])==null?void 0:V.id)||""})},S=async E=>{const[Q,H,V]=await Promise.all([k.from("program_template_phases").select("*").eq("set_id",E).order("order_index"),k.from("program_template_milestones").select("*").eq("set_id",E).order("order_index"),k.from("program_template_tasks").select("*").eq("set_id",E).order("order_index")]
123);c(Q.data||[]),d(H.data||[]),m(V.data||[])};_.useEffect(()=>{(async()=>(n(!0),await N(),n(!1)))()},[]),_.useEffect(()=>{i&&S(i)},[i]);const O=async()=>{if(!j.trim())return;const{data:E,error:Q}=await k.from("program_template_sets").insert({name:j.trim(),is_default:a.length===0}).select("id, name, description, is_default").single();if(Q)return t.error({title:"Create failed",description:Q.message});w(""),s(H=>[...H,E]),o(E.id),t.success({title:"Template created"})},C=async()=>{if(!g)return;await k.from("program_template_sets").update({is_default:!1}).neq("id",g.id);const{error:E}=await k.from("program_template_sets").update({is_default:!0}).eq("id",g.id);if(E)return t.error({title:"Update failed",description:E.message});await N(),t.success({title:"Default template set"})},P=async()=>{if(!g)return;const{error:E}=await k.from("program_template_sets").delete().eq("id",g.id);if(E)return t.error({title:"Delete failed",description:E.message});o(""),await N(),t.success({title:"Template deleted"})},$=async E=>{g&&(s(Q=>Q.map(H=>H.id===g.id?{...H,name:E}:H)),await k.from("program_template_sets").update({name:E}).eq("id",g.id))},A=async()=>{var V;if(!i||!x.trim())return;const E=(((V=l[l.length-1])==null?void 0:V.order_index)||0)+1,{data:Q,error:H}=await k.from("program_template_phases").insert({set_id:i,name:x.trim(),order_index:E}).select("*").single();if(H)return t.error({title:"Add phase failed",description:H.message});v(""),c(se=>[...se,Q])},I=async E=>{const{error:Q}=await k.from("program_template_phases").delete().eq("id",E);if(Q)return t.error({title:"Delete failed",description:Q.message});c(H=>H.filter(V=>V.id!==E)),d(H=>H.filter(V=>V.phase_id!==E)),m(H=>H.filter(V=>V.phase_id!==E))},D=async E=>{const Q=(y[E]||"").trim();if(!Q)return;const H=u.length+1,{data:V,error:se}=await k.from("program_template_milestones").insert({set_id:i,phase_id:E,name:Q,order_index:H}).select("*").single();if(se)return t.error({title:"Add milestone failed",description:se.message});f(ue=>({...ue,[E]:""})),d(ue=>[...ue,V])},q=async E=>{const{error:Q}=await k.from("program_template_milestones").delete().eq("id",E);if(Q)return t.error({title:"Delete failed",description:Q.message});d(H=>H.filter(V=>V.id!==E)),m(H=>H.filter(V=>V.milestone_id!==E))},F=async(E,Q)=>{const H=Q||`phase:${E}`,V=(b[H]||"").trim();if(!V)return;const se=h.length+1,{data:ue,error:z}=await k.from("program_template_tasks").insert({set_id:i,phase_id:E,milestone_id:Q,title:V,order_index:se}).select("*").single();if(z)return t.error({title:"Add task failed",description:z.message});p(he=>({...he,[H]:""})),m(he=>[...he,ue])},K=async E=>{const{error:Q}=await k.from("program_template_tasks").delete().eq("id",E);if(Q)return t.error({title:"Delete failed",description:Q.message});m(H=>H.filter(V=>V.id!==E))},M=async(E,Q)=>{m(H=>H.map(V=>V.id===E?{...V,title:Q}:V)),await k.from("program_template_tasks").update({title:Q}).eq("id",E)};return r?e.jsx("div",{className:"flex justify-center py-16",children:e.jsx(Qe,{})}):e.jsxs("div",{className:"p-4 md:p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[e.jsx(mi,{className:"h-6 w-6 text-primary"})," Program Templates"]}),e.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:"These templates are what program managers load with “Load template” in the Program Management workspace."})]}),e.jsxs(Y,{children:[e.jsx(ce,{className:"pb-3",children:e.jsx(le,{className:"text-base",children:"Template"})}),e.jsxs(Z,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col md:flex-row gap-3 md:items-end",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx(B,{children:"Select template"}),e.jsxs(xe,{value:i,onValueChange:o,children:[e.jsx(ve,{children:e.jsx(ge,{placeholder:"Choose a template"})}),e.jsx(ye,{children:a.map(E=>e.jsxs(J,{value:E.id,children:[E.name,E.is_default?" • default":""]},E.id))})]})]}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx(B,{children:"New template"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(de,{value:j,onChange:E=>w(E.target.value),placeholder:"e.g. 2-day hackathon"}),e.jsx(R,{onClick:O,disabled:!j.trim(),children:e.jsx(Ve,{className:"h-4 w-4"})})]})]})]}),g&&e.jsxs("div",{className:"flex flex-col md:flex-row gap-3 md:items-end border-t pt-4",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx(B,{children:"Name"}),e.jsx(de,{value:g.name,onChange:E=>$(E.target.value)})]}),e.jsxs("div",{className:"flex gap-2",children:[g.is_default?e.jsxs(re,{className:"h-10 flex items-center gap-1",children:[e.jsx(on,{className:"h-3 w-3"})," Default"]}):e.jsxs(R,{variant:"outline",onClick:C,children:[e.jsx(on,{className:"h-4 w-4 mr-2"})," Set as default"]}),e.jsxs(rr,{children:[e.jsx(ss,{asChild:!0,children:e.jsxs(R,{variant:"destructive",children:[e.jsx(We,{className:"h-4 w-4 mr-2"})," Delete"]})}),e.jsxs(nr,{children:[e.jsxs(ar,{children:[e.jsx(sr,{children:"Delete this template?"}),e.jsxs(ir,{children:["All phases, milestones and tasks of “",g.name,"” will be removed. Events already using it are not affected."]})]}),e.jsxs(or,{children:[e.jsx(lr,{children:"Cancel"}),e.jsx(cr,{onClick:P,children:"Delete"})]})]})]})]})]})]})]}),i&&e.jsxs(Y,{children:[e.jsx(ce,{className:"pb-3",children:e.jsxs(le,{className:"text-base flex items-center justify-between",children:[e.jsx("span",{children:"Phases, milestones & tasks"}),e.jsxs("span",{className:"text-xs font-normal text-muted-foreground",children:[l.length," phases · ",u.length," milestones · ",h.length," tasks"]})]})}),e.jsxs(Z,{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(de,{value:x,onChange:E=>v(E.target.value),placeholder:"New phase name (e.g. 3 Months)"}),e.jsxs(R,{onClick:A,disabled:!x.trim(),children:[e.jsx(Ve,{className:"h-4 w-4 mr-2"})," Phase"]})]}),e.jsx(Dg,{type:"multiple",className:"w-full",children:l.map(E=>
123{const Q=u.filter(V=>V.phase_id===E.id),H=h.filter(V=>V.phase_id===E.id&&!V.milestone_id);return e.jsxs(Mg,{value:E.id,children:[e.jsx(Ig,{className:"hover:no-underline",children:e.jsxs("div",{className:"flex items-center gap-2 text-left",children:[e.jsx(mi,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium",children:E.name}),e.jsxs(re,{variant:"secondary",className:"ml-2",children:[Q.length," milestones"]}),e.jsxs(re,{variant:"outline",children:[h.filter(V=>V.phase_id===E.id).length," tasks"]})]})}),e.jsxs(Lg,{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(de,{value:y[E.id]||"",onChange:V=>f(se=>({...se,[E.id]:V.target.value})),placeholder:"New milestone"}),e.jsxs(R,{variant:"outline",onClick:()=>D(E.id),children:[e.jsx(Bd,{className:"h-4 w-4 mr-2"})," Add"]}),e.jsx(R,{variant:"ghost",onClick:()=>I(E.id),className:"text-destructive",children:e.jsx(We,{className:"h-4 w-4"})})]}),Q.map(V=>{const se=h.filter(ue=>ue.milestone_id===V.id);return e.jsxs("div",{className:"rounded-lg border p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Bd,{className:"h-4 w-4 text-primary"})," ",V.name]}),e.jsx(R,{size:"sm",variant:"ghost",className:"text-destructive",onClick:()=>q(V.id),children:e.jsx(We,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"space-y-1",children:se.map(ue=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Id,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx(de,{className:"h-8",value:ue.title,onChange:z=>M(ue.id,z.target.value)}),e.jsx(R,{size:"sm",variant:"ghost",className:"text-destructive",onClick:()=>K(ue.id),children:e.jsx(We,{className:"h-4 w-4"})})]},ue.id))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(de,{className:"h-8",value:b[V.id]||"",onChange:ue=>p(z=>({...z,[V.id]:ue.target.value})),placeholder:"New task"}),e.jsx(R,{size:"sm",variant:"outline",onClick:()=>F(E.id,V.id),children:e.jsx(Ve,{className:"h-4 w-4"})})]})]},V.id)}),e.jsxs("div",{className:"rounded-lg border border-dashed p-3 space-y-2",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Tasks without milestone"}),H.map(V=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Id,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx(de,{className:"h-8",value:V.title,onChange:se=>M(V.id,se.target.value)}),e.jsx(R,{size:"sm",variant:"ghost",className:"text-destructive",onClick:()=>K(V.id),children:e.jsx(We,{className:"h-4 w-4"})})]},V.id)),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(de,{className:"h-8",value:b[`phase:${E.id}`]||"",onChange:V=>p(se=>({...se,[`phase:${E.id}`]:V.target.value})),placeholder:"New task"}),e.jsx(R,{size:"sm",variant:"outline",onClick:()=>F(E.id,null),children:e.jsx(Ve,{className:"h-4 w-4"})})]})]})]})]},E.id)})})]})]})]})},ci=[{value:"visitor",label:"Visitor"},{value:"attendee",label:"Attendee"},{value:"startup",label:"Startup Founder"},{value:"mentor",label:"Mentor"},{value:"investor",label:"Investor"}],jl={toolbar:[[{header:[1,2,3,!1]}],["bold","italic","underline"],[{list:"ordered"},{list:"bullet"}],["link"],["clean"]]},bD=()=>{var x,v,y;const[t,r]=_.useState([]),[n,a]=_.useState(!0),[s,i]=_.useState(!1),[o,l]=_.useState("visitor");_.useEffect(()=>{c()},[]);const c=async()=>{try{const{data:f,error:b}=await k.from("event_registration_email_defaults").select("*").order("role",{ascending:!0});if(b)throw b;r(f||[])}catch(f){we.error({title:"Error loading templates",description:f.message})}finally{a(!1)}},u=(f,b)=>t.find(g=>g.role===f&&g.email_type===b)||{role:f,email_type:b,subject:"",content:"",is_active:!0},d=(f,b,p)=>{r(g=>g.find(S=>S.role===f&&S.email_type===b)?g.map(S=>S.role===f&&S.email_type===b?{...S,...p}:S):[...g,{role:f,email_type:b,subject:"",content:"",is_active:!0,...p}])},h=async()=>{try{i(!0);for(const f of t){const{error:b}=await k.from("event_registration_email_defaults").upsert({role:f.role,email_type:f.email_type,subject:f.subject,content:f.content,is_active:f.is_active,updated_at:new Date().toISOString()},{onConflict:"role,email_type"});if(b)throw b}we.success({title:"Templates saved",description:"Default email templates have been updated successfully"})}catch(f){we.error({title:"Error saving templates",description:f.message})}finally{i(!1)}};if(n)return e.jsx("div",{className:"flex items-center justify-center p-12",children:e.jsx(Qe,{size:48})});const m=u(o,"pending"),j=u(o,"approved"),w=u(o,"rejected");return e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Registration Email Templates"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage default email templates for event registrations. These are copied to new events."})]}),e.jsxs(R,{onClick:h,disabled:s,children:[e.jsx(wa,{className:"w-4 h-4 mr-2"}),s?"Saving...":"Save All Templates"]})]}),e.jsx("div",{className:"p-4 bg-muted/50 rounded-lg",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx("strong",{children:"Available placeholders:"})," ",e.jsx("code",{className:"bg-background px-1 rounded",children:"{{first_name}}"}),", ",e.jsx("code",{className:"bg-background px-1 rounded",children:"{{last_name}}"}),", ",e.jsx("code",{className:"bg-background px-1 rounded",children:"{{event_title}}"})]})}),e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsxs(le,{className:"flex items-center gap-2",children:[e.jsx(Ge,{className:"w-5 h-5"}),"Select Registration Type"]})}),e.jsx(Z,{children:e.jsxs(xe,{value:o,onValueChange:l,children:[e.jsx(ve,{className:"w-full max-w-xs",children:e.jsx(ge,{placeholder:"Select registration type"})}),e.jsx(ye,{children:ci.map(f=>e.jsx(J,{value:f.value,children:f.label},f.value))})]})})]}),e.jsxs("div",{className:"grid gap-6",children:[e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(St,{className:"w-5 h-5 text-orange-500"}),e.jsx(le,{children:"Registration Pending Email"}),e.jsx(re,{variant:"outline",children:(x=ci.find(f=>f.value===o))==null?void 0:x.label})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{htmlFor:"pending-active",className:"text-sm",children:"Active"}),e.jsx(Tt,{id:"pending-active",checked:m.is_active,onCheckedChange:f=>d(o,"pending",{is_active:f})})]})]})}),e.jsxs(Z,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"pending-subject",children:"Subject"}),e.jsx(de,{id:"pending-subject",value:m.subject,onChange:f=>d(o,"pending",{subject:f.target.value}),placeholder:"Email subject"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Content"}),e.jsx("div",{className:"min-h-[200px]",children:e.jsx(La,{value:m.content,onChange:f=>d(o,"pending",{content:f}),modules:jl,style:{height:"150px"}})})]})]})]}),e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(St,{className:"w-5 h-5 text-green-500"}),e.jsx(le,{children:"Registration Approved Email"}),e.jsx(re,{variant:"outline",children:(v=ci.find(f=>f.value===o))==null?void 0:v.label})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{htmlFor:"approved-active",className:"text-sm",children:"Active"}),e.jsx(Tt,{id:"approved-active",checked:j.is_active,onCheckedChange:f=>d(o,"approved",{is_active:f})})]})]})}),e.jsxs(Z,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"approved-subject",children:"Subject"}),e.jsx(de,{id:"approved-subject",value:j.subject,onChange:f=>d(o,"approved",{subject:f.target.value}),placeholder:"Email subject"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Content"}),e.jsx("div",{className:"min-h-[200px]",children:e.jsx(La,{value:j.content,onChange:f=>d(o,"approved",{content:f}),modules:jl,style:{height:"150px"}})})]})]})]}),e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(St,{className:"w-5 h-5 text-red-500"}
123),e.jsx(le,{children:"Registration Rejected Email"}),e.jsx(re,{variant:"outline",children:(y=ci.find(f=>f.value===o))==null?void 0:y.label})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{htmlFor:"rejected-active",className:"text-sm",children:"Active"}),e.jsx(Tt,{id:"rejected-active",checked:w.is_active,onCheckedChange:f=>d(o,"rejected",{is_active:f})})]})]})}),e.jsxs(Z,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"rejected-subject",children:"Subject"}),e.jsx(de,{id:"rejected-subject",value:w.subject,onChange:f=>d(o,"rejected",{subject:f.target.value}),placeholder:"Email subject"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Content"}),e.jsx("div",{className:"min-h-[200px]",children:e.jsx(La,{value:w.content,onChange:f=>d(o,"rejected",{content:f}),modules:jl,style:{height:"150px"}})})]})]})]})]})]})},wD=()=>{const[t,r]=_.useState([]),[n,a]=_.useState([]),[s,i]=_.useState([]),[o,l]=_.useState([]),[c,u]=_.useState(!0),[d,h]=_.useState(""),[m,j]=_.useState("all");_.useState(null);const w=gt();_.useEffect(()=>{x(),v(),y()},[]),_.useEffect(()=>{f()},[t,d,m]);const x=async()=>{try{const{data:C,error:P}=await k.from("posts").select("*").order("created_at",{ascending:!1});if(P)throw P;r(C||[])}catch(C){we.error({title:"Error loading posts",description:C.message})}finally{u(!1)}},v=async()=>{try{const{data:C,error:P}=await k.from("events").select("id, title").order("title");if(P)throw P;a(C||[])}catch(C){console.error("Error fetching events:",C)}},y=async()=>{try{const{data:C,error:P}=await k.from("companies").select("id, name").order("name");if(P)throw P;i(C||[])}catch(C){console.error("Error fetching companies:",C)}},f=()=>{let C=t;d&&(C=C.filter(P=>P.title.toLowerCase().includes(d.toLowerCase())||P.author.toLowerCase().includes(d.toLowerCase())||P.category.toLowerCase().includes(d.toLowerCase()))),m!=="all"&&(C=C.filter(P=>P.status===m)),l(C)},b=async C=>{if(confirm("Are you sure you want to delete this post? This action cannot be undone."))try{const{error:P}=await k.from("posts").delete().eq("id",C);if(P)throw P;r(t.filter($=>$.id!==C)),we.success({title:"Post deleted",description:"The blog post has been successfully deleted"})}catch(P){we.error({title:"Error deleting post",description:P.message})}},p=async(C,P)=>{try{const{error:$}=await k.from("posts").update({status:P}).eq("id",C);if($)throw $;r(t.map(A=>A.id===C?{...A,status:P}:A)),we.success({title:"Status updated",description:`Post status changed to ${P}`})}catch($){we.error({title:"Error updating status",description:$.message})}},g=C=>{switch(C){case"live":return"default";case"draft":return"secondary";default:return"outline"}},N=C=>{switch(C){case"public":return"default";case"protected":return"secondary";case"private":return"destructive";default:return"outline"}},S=C=>{if(!C)return null;const P=n.find($=>$.id===C);return(P==null?void 0:P.title)||"Unknown Event"},O=C=>{if(!C)return null;const P=s.find($=>$.id===C);return(P==null?void 0:P.name)||"Unknown Company"};return c?e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"h-8 bg-gray-200 rounded animate-pulse"}),e.jsx("div",{className:"h-64 bg-gray-200 rounded animate-pulse"})]}):e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Blog Management"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage blog posts, events, and company associations"})]}),e.jsxs(R,{onClick:()=>w("/dashboard/admin/blog/edit/new"),children:[e.jsx(Ve,{className:"w-4 h-4 mr-2"}),"Create Post"]})]}),e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsx(le,{children:"Blog Posts"})}),e.jsxs(Z,{children:[e.jsxs("div",{className:"flex gap-4 mb-6",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(tr,{className:"w-4 h-4 absolute left-3 top-3 text-muted-foreground"}),e.jsx(de,{placeholder:"Search posts...",className:"pl-10",value:d,onChange:C=>h(C.target.value)})]}),e.jsxs("select",{className:"px-3 py-2 border rounded-md",value:m,onChange:C=>j(C.target.value),children:[e.jsx("option",{value:"all",children:"All Status"}),e.jsx("option",{value:"draft",children:"Draft"}),e.jsx("option",{value:"live",children:"Live"})]})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(nt,{children:[e.jsx(at,{children:e.jsxs(pe,{children:[e.jsx(te,{children:"Title"}),e.jsx(te,{children:"Author"}),e.jsx(te,{children:"Category"}),e.jsx(te,{children:"Status"}),e.jsx(te,{children:"Visibility"}),e.jsx(te,{children:"Associations"}),e.jsx(te,{children:"Created"}),e.jsx(te,{className:"w-[50px]"})]})}),e.jsx(st,{children:o.length===0?e.jsx(pe,{children:e.jsx(X,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:"No blog posts found"})}):o.map(C=>e.jsxs(pe,{children:[e.jsx(X,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:C.title}),C.excerpt&&e.jsx("div",{className:"text-sm text-muted-foreground truncate max-w-xs",children:C.excerpt})]})}),e.jsx(X,{children:C.author}),e.jsx(X,{children:C.category}),e.jsx(X,{children:e.jsx(re,{variant:g(C.status),children:C.status})}),e.jsx(X,{children:e.jsx(re,{variant:N(C.visibility),children:C.visibility})}),e.jsx(X,{children:e.jsxs("div",{className:"space-y-1",children:[C.event_id&&e.jsxs("div",{className:"flex items-center text-xs text-muted-foreground",children:[e.jsx(qt,{className:"w-3 h-3 mr-1"}),S(C.event_id)]}),C.company_id&&e.jsxs("div",{className:"flex items-center text-xs text-muted-foreground",children:[e.jsx(It,{className:"w-3 h-3 mr-1"}),O(C.company_id)]}),!C.event_id&&!C.company_id&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"None"})]})}),e.jsx(X,{className:"text-sm text-muted-foreground",children:new Date(C.created_at).toLocaleDateString()}),e.jsx(X,{children:e.jsxs(Hn,{children:[e.jsx(Xn,{asChild:!0,children:e.jsx(R,{variant:"ghost",size:"sm",children:e.jsx(xi,{className:"w-4 h-4"})})}),e.jsxs(Yn,{align:"end",children:[e.jsxs(Ut,{onClick:()=>w(`/dashboard/admin/blog/edit/${C.id}`),children:[e.jsx(En,{className:"w-4 h-4 mr-2"}),"Edit"]}),e.jsxs(Ut,{onClick:()=>window.open(`/blog/${C.slug}`,"_blank"),children:[e.jsx(dr,{className:"w-4 h-4 mr-2"}),"View"]}
123),e.jsx(Ut,{onClick:()=>p(C.id,C.status==="live"?"draft":"live"),children:C.status==="live"?"Mark as Draft":"Publish"}),e.jsxs(Ut,{onClick:()=>b(C.id),className:"text-destructive",children:[e.jsx(We,{className:"w-4 h-4 mr-2"}),"Delete"]})]})]})})]},C.id))})]})})]})]})]})},ND=()=>{const[t,r]=_.useState([]),[n,a]=_.useState([]),[s,i]=_.useState(!0),[o,l]=_.useState(""),[c,u]=_.useState("all"),[d,h]=_.useState("all"),[m,j]=_.useState("all"),[w,x]=_.useState(!1),[v,y]=_.useState(null),f=gt();_.useEffect(()=>{b()},[]),_.useEffect(()=>{p()},[t,o,c,d,m]);const b=async()=>{try{i(!0);const{data:C,error:P}=await k.from("companies").select("*").order("created_at",{ascending:!1});if(P)throw P;const $=(C==null?void 0:C.map(F=>F.city_id).filter(Boolean))||[];let A=new Map;if($.length>0){const{data:F}=await k.from("cities_with_countries").select("id, name, country").in("id",$);F==null||F.forEach(K=>A.set(K.id,K))}const I=(C==null?void 0:C.map(F=>F.id))||[];let D=new Map;if(I.length>0){const{data:F}=await k.from("company_members").select(`
124            id,
125            profile_id,
126            role,
127            position,
128            company_id,
129            profiles!inner(id, name, email, avatar_url)
130          `).in("company_id",I);F==null||F.forEach(K=>{const M=K.company_id;D.has(M)||D.set(M,[]),D.get(M).push({id:K.id,profile_id:K.profile_id,role:K.role,position:K.position,profile:K.profiles})})}const q=(C==null?void 0:C.map(F=>{const K=F.city_id?A.get(F.city_id):null;return{...F,city_display:K?`${K.name}, ${K.country}`:void 0,members:D.get(F.id)||[]}}))||[];r(q)}catch(C){console.error("Error fetching companies:",C),we.error({title:"Error",description:"Failed to fetch companies"})}finally{i(!1)}},p=()=>{let C=[...t];o&&(C=C.filter(P=>{var $,A,I;return(($=P.name)==null?void 0:$.toLowerCase().includes(o.toLowerCase()))||((A=P.tagline)==null?void 0:A.toLowerCase().includes(o.toLowerCase()))||((I=P.city_display)==null?void 0:I.toLowerCase().includes(o.toLowerCase()))})),c!=="all"&&(C=C.filter(P=>P.status===c)),d!=="all"&&(C=C.filter(P=>P.company_type===d)),m!=="all"&&(C=C.filter(P=>(P.city_display||"__none__")===m)),a(C)},g=async()=>{if(v)try{const{error:C}=await k.from("companies").delete().eq("id",v.id);if(C)throw C;we.success({title:"Success",description:"Company deleted successfully"}),x(!1),y(null),b()}catch(C){console.error("Error deleting company:",C),we.error({title:"Error",description:"Failed to delete company"})}},N=async(C,P)=>{try{const{error:$}=await k.from("companies").update({status:P}).eq("id",C);if($)throw $;we.success({title:"Success",description:"Company status updated"}),b()}catch($){console.error("Error updating status:",$),we.error({title:"Error",description:"Failed to update status"})}},S=C=>{const $={Public:{variant:"default",label:"Public"},Protected:{variant:"secondary",label:"Protected"},Private:{variant:"outline",label:"Private"}}[C||"Private"]||{variant:"outline",label:"Private"};return e.jsx(re,{variant:$.variant,children:$.label})},O=()=>{const C=n.map(I=>({Name:I.name,Tagline:I.tagline||"",Type:I.company_type||"",Status:I.status||"",Visibility:I.visibility||"",Website:I.website||"",Location:I.city_display||"","Founded Year":I.founded_year||"","Team Size":I.team_size||"","Funding Stage":I.funding_stage||"",Industry:(I.industry||[]).join(", "),Technologies:(I.technologies||[]).join(", "),Members:(I.members||[]).map(D=>`${D.profile.name}${D.position?` (${D.position})`:""}`).join("; "),"Member Emails":(I.members||[]).map(D=>D.profile.email).filter(Boolean).join("; "),Description:I.description||"","Created At":I.created_at,"Updated At":I.updated_at})),P=el.json_to_sheet(C),$=el.book_new();el.book_append_sheet($,P,"Companies");const A=new Date().toISOString().slice(0,10);Rg($,`companies-${A}.xlsx`)};return e.jsxs("div",{className:"min-h-screen bg-background p-6",children:[e.jsxs("div",{className:"space-y-6 max-w-[1600px] mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(It,{className:"w-6 h-6 text-primary"}),e.jsx("h1",{className:"text-2xl font-bold",children:"Company Management"})]}),e.jsxs(R,{onClick:O,variant:"outline",disabled:s||n.length===0,children:[e.jsx(id,{className:"w-4 h-4 mr-2"}),"Export XLSX"]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsxs(Y,{children:[e.jsx(ce,{className:"pb-2",children:e.jsx(le,{className:"text-sm font-medium text-muted-foreground",children:"Total Companies"})}),e.jsx(Z,{children:e.jsx("div",{className:"text-3xl font-bold",children:t.length})})]}),e.jsxs(Y,{children:[e.jsx(ce,{className:"pb-2",children:e.jsx(le,{className:"text-sm font-medium text-muted-foreground",children:"Live Companies"})}),e.jsx(Z,{children:e.jsx("div",{className:"text-3xl font-bold",children:t.filter(C=>C.status==="Live").length})})]}),e.jsxs(Y,{children:[e.jsx(ce,{className:"pb-2",children:e.jsx(le,{className:"text-sm font-medium text-muted-foreground",children:"Startups"})}),e.jsx(Z,{children:e.jsx("div",{className:"text-3xl font-bold",children:t.filter(C=>C.company_type==="startup").length})})]}),e.jsxs(Y,{children:[e.jsx(ce,{className:"pb-2",children:e.jsx(le,{className:"text-sm font-medium text-muted-foreground",children:"Corporates"})}),e.jsx(Z,{children:e.jsx("div",{className:"text-3xl font-bold",children:t.filter(C=>C.company_type==="corporate").length})})]})]}),e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsx(le,{children:"Filter Companies"})}),e.jsx(Z,{children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(tr,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),e.jsx(de,{placeholder:"Search companies...",value:o,onChange:C=>l(C.target.value),className:"pl-10"})]}),e.jsxs(xe,{value:c,onValueChange:u,children:[e.jsx(ve,{children:e.jsx(ge,{placeholder:"Filter by status"})}),e.jsxs(ye,{children:[e.jsx(J,{value:"all",children:"All Statuses"}),e.jsx(J,{value:"Live",children:"Live"}),e.jsx(J,{value:"Draft",children:"Draft"})]})]}),e.jsxs(xe,{value:d,onValueChange:h,children:[e.jsx(ve,{children:e.jsx(ge,{placeholder:"Filter by type"})}),e.jsxs(ye,{children:[e.jsx(J,{value:"all",children:"All Types"}),e.jsx(J,{value:"startup",children:"Startup"}),e.jsx(J,{value:"corporate",children:"Corporate"})]})]}),e.jsxs(xe,{value:m,onValueChange:j,children:[e.jsx(ve,{children:e.jsx(ge,{placeholder:"Filter by city"})}),e.jsxs(ye,{children:[e.jsx(J,{value:"all",children:"All Cities"}),Array.from(new Set(t.map(C=>
130C.city_display).filter(Boolean))).sort((C,P)=>C.localeCompare(P)).map(C=>e.jsx(J,{value:C,children:C},C))]})]})]})})]}),e.jsxs(Y,{children:[e.jsxs(ce,{children:[e.jsxs(le,{children:["Companies (",n.length,")"]}),e.jsx(ct,{children:"Manage all companies in the system"})]}),e.jsx(Z,{children:s?e.jsx("div",{className:"text-center py-8",children:"Loading companies..."}):n.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No companies found"}):e.jsxs(nt,{children:[e.jsx(at,{children:e.jsxs(pe,{children:[e.jsx(te,{children:"Company"}),e.jsx(te,{children:"Type"}),e.jsx(te,{children:"Location"}),e.jsx(te,{children:"Status"}),e.jsx(te,{children:"Visibility"}),e.jsx(te,{children:"Team"}),e.jsx(te,{children:"Founded"}),e.jsx(te,{className:"text-right",children:"Actions"})]})}),e.jsx(st,{children:n.map(C=>e.jsxs(pe,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>f(`/dashboard/admin/companies/${C.id}`),children:[e.jsx(X,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[C.logo&&e.jsx("img",{src:C.logo,alt:`${C.name} logo`,className:"w-10 h-10 rounded-md object-cover flex-shrink-0"}),e.jsxs("div",{className:"flex flex-col min-w-0",children:[e.jsx("span",{className:"font-medium truncate",children:C.name}),C.tagline&&e.jsx("span",{className:"text-sm text-muted-foreground truncate",children:C.tagline}),C.members&&C.members.length>0&&e.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[e.jsx("div",{className:"flex -space-x-2",children:C.members.slice(0,3).map(P=>{var $;return e.jsxs(Dr,{className:"h-5 w-5 border-2 border-background",children:[e.jsx(Mr,{src:P.profile.avatar_url||void 0}),e.jsx(Ir,{className:"text-[10px]",children:($=P.profile.name)==null?void 0:$.split(" ").map(A=>A[0]).join("").slice(0,2)})]},P.id)})}),e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:C.members.length===1?C.members[0].profile.name:`${C.members.length} members`})]})]})]})}),e.jsx(X,{children:e.jsx(re,{variant:"outline",children:C.company_type||"N/A"})}),e.jsx(X,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(kn,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-sm",children:C.city_display||"N/A"})]})}),e.jsx(X,{children:e.jsxs(xe,{value:C.status||"Draft",onValueChange:P=>N(C.id,P),children:[e.jsx(ve,{className:"w-[100px]",children:e.jsx(ge,{})}),e.jsxs(ye,{children:[e.jsx(J,{value:"Live",children:"Live"}),e.jsx(J,{value:"Draft",children:"Draft"})]})]})}),e.jsx(X,{children:S(C.visibility)}),e.jsx(X,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Ge,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-sm",children:C.team_size||"N/A"})]})}),e.jsx(X,{children:C.founded_year||"N/A"}),e.jsx(X,{className:"text-right",onClick:P=>P.stopPropagation(),children:e.jsxs("div",{className:"flex justify-end gap-2",children:[C.website&&e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>window.open(C.website,"_blank"),children:e.jsx(Zt,{className:"w-4 h-4"})}),e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>f(`/dashboard/admin/companies/${C.id}`),children:e.jsx(dr,{className:"w-4 h-4"})}),e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>f(`/dashboard/admin/companies/${C.id}/edit`),children:e.jsx(En,{className:"w-4 h-4"})}),e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>{y(C),x(!0)},children:e.jsx(We,{className:"w-4 h-4 text-destructive"})})]})})]},C.id))})]})})]})]}),e.jsx(ut,{open:w,onOpenChange:x,children:e.jsxs(ht,{children:[e.jsxs(mt,{children:[e.jsx(ft,{children:"Delete Company"}),e.jsxs($t,{children:['Are you sure you want to delete "',v==null?void 0:v.name,'"? This action cannot be undone.']})]}),e.jsxs(Vt,{children:[e.jsx(R,{variant:"outline",onClick:()=>x(!1),children:"Cancel"}),e.jsx(R,{variant:"destructive",onClick:g,children:"Delete"})]})]})})]})},_D=()=>{const{companyId:t}=Zr(),r=gt(),[n,a]=_.useState(null),[s,i]=_.useState([]),[o,l]=_.useState(!0),[c,u]=_.useState(null);_.useEffect(()=>{t&&(d(),h())},[t]);const d=async()=>{try{l(!0);const{data:x,error:v}=await k.from("companies").select("*").eq("id",t).single();if(v)throw v;let y;if(x.city_id){const{data:f}=await k.from("cities_with_countries").select("name, country").eq("id",x.city_id).single();f&&(y=`${f.name}, ${f.country}`)}a({...x,city_display:y})}catch(x){console.error("Error fetching company:",x),we.error({title:"Error",description:"Failed to fetch company details"}),r("/dashboard/admin/companies")}finally{l(!1)}},h=async()=>{try{const{data:x,error:v}=await k.from("company_members").select(`
131          id,
132          profile_id,
133          role,
134          position,
135          profiles!inner(id, user_id, name, email, avatar_url)
136        `).eq("company_id",t);if(v)throw v;const y=(x==null?void 0:x.map(f=>({id:f.id,profile_id:f.profile_id,role:f.role,position:f.position,profile:f.profiles})))||[];i(y)}catch(x){console.error("Error fetching members:",x)}},m=async()=>
136{if(c)try{const{error:x}=await k.from("company_members").delete().eq("id",c.id);if(x)throw x;we.success({title:"Member Removed",description:`${c.profile.name} has been removed from this company`}),u(null),h()}catch(x){console.error("Error removing member:",x),we.error({title:"Error",description:"Failed to remove member"})}},j=x=>{const y={Live:{variant:"default",label:"Live"},Draft:{variant:"secondary",label:"Draft"}}[x||"Draft"]||{variant:"secondary",label:"Draft"};return e.jsx(re,{variant:y.variant,children:y.label})},w=x=>{const y={Public:{variant:"default",label:"Public"},Protected:{variant:"secondary",label:"Protected"},Private:{variant:"outline",label:"Private"}}[x||"Private"]||{variant:"outline",label:"Private"};return e.jsx(re,{variant:y.variant,children:y.label})};return o?e.jsx("div",{className:"min-h-screen bg-background p-6",children:e.jsx("div",{className:"text-center py-8",children:"Loading company details..."})}):n?e.jsxs("div",{className:"min-h-screen bg-background p-6",children:[e.jsxs("div",{className:"space-y-6 max-w-[1200px] mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsxs(R,{variant:"ghost",size:"sm",onClick:()=>r("/dashboard/admin/companies"),children:[e.jsx(Bt,{className:"w-4 h-4 mr-2"}),"Back to Companies"]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(It,{className:"w-6 h-6 text-primary"}),e.jsx("h1",{className:"text-2xl font-bold",children:n.name})]})]}),e.jsxs(R,{onClick:()=>r(`/dashboard/admin/companies/${t}/edit`),children:[e.jsx(En,{className:"w-4 h-4 mr-2"}),"Edit Company"]})]}),e.jsxs("div",{className:"flex gap-2",children:[j(n.status),w(n.visibility),n.company_type&&e.jsx(re,{variant:"outline",children:n.company_type})]}),n.tagline&&e.jsx("p",{className:"text-lg text-muted-foreground",children:n.tagline}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[n.city_display&&e.jsx(Y,{children:e.jsx(Z,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(kn,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Location"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n.city_display})]})]})})}),n.founded_year&&e.jsx(Y,{children:e.jsx(Z,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qt,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Founded"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n.founded_year})]})]})})}),n.team_size&&e.jsx(Y,{children:e.jsx(Z,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ge,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Team Size"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n.team_size})]})]})})}),n.funding_stage&&e.jsx(Y,{children:e.jsx(Z,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(mf,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Funding Stage"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n.funding_stage})]})]})})})]}),n.description&&e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsx(le,{children:"About"})}),e.jsx(Z,{children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:n.description})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[n.problem&&e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsxs(le,{className:"flex items-center gap-2",children:[e.jsx(Ol,{className:"w-5 h-5"}),"Problem"]})}),e.jsx(Z,{children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:n.problem})})]}),n.solution&&e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsxs(le,{className:"flex items-center gap-2",children:[e.jsx(rn,{className:"w-5 h-5"}),"Solution"]})}),e.jsx(Z,{children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:n.solution})})]})]}),(n.business_model||n.target_market||n.traction)&&e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsxs(le,{className:"flex items-center gap-2",children:[e.jsx(ns,{className:"w-5 h-5"}),"Business Details"]}
136)}),e.jsxs(Z,{className:"space-y-4",children:[n.business_model&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-1",children:"Business Model"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n.business_model})]}),n.target_market&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-1",children:"Target Market"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n.target_market})]}),n.traction&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-1",children:"Traction"}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:n.traction})]})]})]}),(n.industry&&n.industry.length>0||n.technologies&&n.technologies.length>0)&&e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsx(le,{children:"Industry & Technologies"})}),e.jsxs(Z,{className:"space-y-4",children:[n.industry&&n.industry.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"Industry"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:n.industry.map((x,v)=>e.jsx(re,{variant:"secondary",children:x},v))})]}),n.technologies&&n.technologies.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"Technologies"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:n.technologies.map((x,v)=>e.jsx(re,{variant:"outline",children:x},v))})]})]})]}),(n.website||n.linkedin||n.twitter)&&e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsx(le,{children:"Links"})}),e.jsx(Z,{children:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[n.website&&e.jsxs(R,{variant:"outline",size:"sm",onClick:()=>window.open(n.website,"_blank"),children:[e.jsx(Da,{className:"w-4 h-4 mr-2"}),"Website",e.jsx(Zt,{className:"w-3 h-3 ml-2"})]}),n.linkedin&&e.jsxs(R,{variant:"outline",size:"sm",onClick:()=>window.open(n.linkedin,"_blank"),children:[e.jsx(El,{className:"w-4 h-4 mr-2"}),"LinkedIn",e.jsx(Zt,{className:"w-3 h-3 ml-2"})]}),n.twitter&&e.jsxs(R,{variant:"outline",size:"sm",onClick:()=>window.open(n.twitter,"_blank"),children:[e.jsx(Tl,{className:"w-4 h-4 mr-2"}),"Twitter",e.jsx(Zt,{className:"w-3 h-3 ml-2"})]})]})})]}),e.jsxs(Y,{children:[e.jsxs(ce,{children:[e.jsxs(le,{className:"flex items-center gap-2",children:[e.jsx(Ge,{className:"w-5 h-5"}),"Team Members (",s.length,")"]}),e.jsx(ct,{children:"People associated with this company"})]}),e.jsx(Z,{children:s.length===0?e.jsx("p",{className:"text-muted-foreground text-sm",children:"No team members found"}):e.jsx("div",{className:"space-y-3",children:s.map(x=>{var v;return e.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(Dr,{className:"h-10 w-10",children:[e.jsx(Mr,{src:x.profile.avatar_url||void 0}),e.jsx(Ir,{children:(v=x.profile.name)==null?void 0:v.split(" ").map(y=>y[0]).join("").slice(0,2)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:x.profile.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:x.profile.email}),e.jsxs("div",{className:"flex gap-2 mt-1",children:[e.jsx(re,{variant:"secondary",className:"text-xs",children:x.role}),x.position&&e.jsx(re,{variant:"outline",className:"text-xs",children:x.position})]})]})]}),e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>u(x),className:"text-destructive hover:text-destructive hover:bg-destructive/10",children:e.jsx(Fg,{className:"w-4 h-4"})})]},x.id)})})})]}),e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsx(le,{children:"Metadata"})}),e.jsxs(Z,{className:"space-y-2",children:[e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:"Created:"})," ",e.jsx("span",{className:"text-muted-foreground",children:new Date(n.created_at).toLocaleDateString()})]}),e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:"Last Updated:"})," ",e.jsx("span",{className:"text-muted-foreground",children:new Date(n.updated_at).toLocaleDateString()})]}),e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:"Company ID:"})," ",e.jsx("span",{className:"text-muted-foreground font-mono text-xs",children:n.id})]})]})]})]}),e.jsx(rr,{open:!!c,onOpenChange:x=>!x&&u(null),children:e.jsxs(nr,{children:[e.jsxs(ar,{children:[e.jsx(sr,{children:"Remove Team Member"}),e.jsxs(ir,{children:["Are you sure you want to remove ",c==null?void 0:c.profile.name," from ",n.name,"? This will remove their association with this company."]})]}),e.jsxs(or,{children:[e.jsx(lr,{children:"Cancel"}),e.jsx(cr,{onClick:m,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]})})]}):e.jsx("div",{className:"min-h-screen bg-background p-6",children:e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Company not found"})})},Lm=["founder","member","advisor","investor"],SD=({companyId:t})=>{const[r,n]=_.useState([]),[a,s]=_.useState(!0),[i,o]=_.useState(!1),[l,c]=_.useState(""),[u,d]=_.useState([]),[h,m]=_.useState(!1),[j,w]=_.useState("founder"),[x,v]=_.useState(""),y=async()=>{s(!0);const{data:O,error:C}=await k.from("company_members").select("id, role, position, is_primary, profile:profiles(id, user_id, name, first_name, last_name, email, avatar_url)").eq("company_id",t).order("is_primary",{ascending:!1});C?we.error({title:"Failed to load members",description:C.message}):n(O||[]),s(!1)};_.useEffect(()=>{t&&y()},[t]);const f=_.useMemo(()=>new Set(r.map(O=>{var C;return(C=O.profile)==null?void 0:C.id}
136).filter(Boolean)),[r]);_.useEffect(()=>{if(!i)return;const O=l.trim();if(O.length<2){d([]);return}const C=setTimeout(async()=>{m(!0);const{data:P,error:$}=await k.from("profiles").select("id, user_id, name, first_name, last_name, email").or(`name.ilike.%${O}%,first_name.ilike.%${O}%,last_name.ilike.%${O}%,email.ilike.%${O}%`).limit(20);m(!1),$||d(P||[])},250);return()=>clearTimeout(C)},[l,i]);const b=async O=>{if(f.has(O.id)){we.info({title:"Already a member"});return}const C=x.trim()||(j==="founder"?"Founder":j.charAt(0).toUpperCase()+j.slice(1)),{error:P}=await k.from("company_members").insert({company_id:t,profile_id:O.id,role:j,position:C,is_primary:!1});if(P){we.error({title:"Could not add member",description:P.message});return}we.success({title:"Member added"}),o(!1),c(""),v(""),y()},p=async O=>{if(!confirm("Remove this user from the company?"))return;const{error:C}=await k.from("company_members").delete().eq("id",O);if(C){we.error({title:"Could not remove member",description:C.message});return}we.success({title:"Member removed"}),y()},g=async(O,C)=>{const{error:P}=await k.from("company_members").update({role:C}).eq("id",O);if(P){we.error({title:"Could not update role",description:P.message});return}y()},N=async O=>{await k.from("company_members").update({is_primary:!1}).eq("company_id",t);const{error:C}=await k.from("company_members").update({is_primary:!0}).eq("id",O);if(C){we.error({title:"Could not set primary",description:C.message});return}we.success({title:"Primary contact updated"}),y()},S=O=>O&&([O.first_name,O.last_name].filter(Boolean).join(" ").trim()||O.name||O.email)||"Unknown";return e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs(le,{className:"flex items-center gap-2",children:[e.jsx(Ge,{className:"w-5 h-5 text-primary"}),"Company Members"]}),e.jsxs(qa,{open:i,onOpenChange:o,children:[e.jsx(Va,{asChild:!0,children:e.jsxs(R,{children:[e.jsx(Ve,{className:"w-4 h-4 mr-2"}),"Add user"]})}),e.jsxs(Wa,{className:"w-96 p-3 space-y-3",align:"end",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx(B,{className:"text-xs",children:"Role"}),e.jsxs(xe,{value:j,onValueChange:w,children:[e.jsx(ve,{children:e.jsx(ge,{})}),e.jsx(ye,{children:Lm.map(O=>e.jsx(J,{value:O,children:O.charAt(0).toUpperCase()+O.slice(1)},O))})]})]}),e.jsxs("div",{children:[e.jsx(B,{className:"text-xs",children:"Position (optional)"}),e.jsx(de,{value:x,onChange:O=>v(O.target.value),placeholder:"e.g. CEO"})]})]}),e.jsxs(Ra,{shouldFilter:!1,children:[e.jsx(Fa,{placeholder:"Search users by name or email…",value:l,onValueChange:c}),e.jsx(Ba,{children:h?e.jsx("div",{className:"py-4 text-sm text-center text-muted-foreground",children:"Searching…"}):e.jsxs(e.Fragment,{children:[e.jsx(za,{children:l.length<2?"Type at least 2 characters…":"No users found."}),e.jsx(Ua,{children:u.filter(O=>!f.has(O.id)).map(O=>e.jsxs(yn,{value:O.id,onSelect:()=>b(O),className:"flex flex-col items-start cursor-pointer",children:[e.jsx("span",{className:"font-medium",children:S(O)}),O.email&&e.jsx("span",{className:"text-xs text-muted-foreground",children:O.email})]},O.id))})]})})]})]})]})]})}),e.jsx(Z,{children:a?e.jsx("div",{className:"text-center py-6 text-muted-foreground",children:"Loading…"}):r.length===0?e.jsxs("div",{className:"text-center py-10 border border-dashed rounded-lg",children:[e.jsx(Ge,{className:"w-8 h-8 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:'No members yet. Add a user to make this company appear under their "My Companies".'})]}):e.jsx("div",{className:"divide-y border rounded-lg",children:r.map(O=>{var C;return e.jsxs("div",{className:"flex items-center gap-3 p-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium truncate",children:S(O.profile)}),O.is_primary&&e.jsxs(re,{variant:"secondary",className:"text-xs",children:[e.jsx(Cn,{className:"w-3 h-3 mr-1"}),"Primary"]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground truncate",children:[(C=O.profile)==null?void 0:C.email,O.position?` · ${O.position}`:""]})]}),e.jsxs(xe,{value:O.role,onValueChange:P=>g(O.id,P),children:[e.jsx(ve,{className:"w-32",children:e.jsx(ge,{})}),e.jsx(ye,{children:Lm.map(P=>e.jsx(J,{value:P,children:P.charAt(0).toUpperCase()+P.slice(1)},P))})]}),!O.is_primary&&e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>N(O.id),title:"Set as primary",children:e.jsx(Cn,{className:"w-4 h-4"})}),e.jsx(R,{variant:"ghost",size:"icon",onClick:()=>p(O.id),title:"Remove",children:e.jsx(We,{className:"w-4 h-4 text-destructive"})})]},O.id)})})})]})},OD=()=>{const{companyId:t}=Zr(),r=gt(),[n,a]=_.useState(null),[s,i]=_.useState(!0),[o,l]=_.useState(!1);_.useEffect(()=>{t&&c()},[t]);const c=async()=>{try{i(!0);const{data:d,error:h}=await k.from("companies").select("*").eq("id",t).single();if(h)throw h;const m={...d,custom_links:Array.isArray(d.custom_links)?d.custom_links:[]};a(m)}catch(d){console.error("Error fetching company:",d),we.error({title:"Error",description:"Failed to fetch company details"}),r("/dashboard/admin/companies")}finally{i(!1)}},u=async()=>
136{if(n){l(!0);try{const{error:d}=await k.from("companies").update({name:n.name,tagline:n.tagline,description:n.description,logo:n.logo,hero_image:n.hero_image,city_id:n.city_id,founded_year:n.founded_year,industry:n.industry,website:n.website,linkedin:n.linkedin,twitter:n.twitter,facebook:n.facebook,instagram:n.instagram,business_model:n.business_model,target_market:n.target_market,solution:n.solution,problem:n.problem,team_size:n.team_size,funding_stage:n.funding_stage,traction:n.traction,technologies:n.technologies,demo_video:n.demo_video,pitch_deck:n.pitch_deck,custom_links:n.custom_links||[],visibility:n.visibility,status:n.status,company_type:n.company_type,show_on_homepage:n.show_on_homepage,show_on_about_us:n.show_on_about_us}).eq("id",n.id);if(d)throw d;we.success({title:"Success",description:"Company updated successfully"}),r(`/dashboard/admin/companies/${n.id}`)}catch(d){console.error("Error updating company:",d),we.error({title:"Error",description:"Failed to update company"})}finally{l(!1)}}};return s?e.jsx("div",{className:"min-h-screen bg-background p-6",children:e.jsx("div",{className:"text-center py-8",children:"Loading company..."})}):n?e.jsx("div",{className:"min-h-screen bg-background p-6",children:e.jsxs("div",{className:"space-y-6 max-w-[1200px] mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsxs(R,{variant:"ghost",size:"sm",onClick:()=>r(`/dashboard/admin/companies/${t}`),children:[e.jsx(Bt,{className:"w-4 h-4 mr-2"}),"Back to Details"]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(It,{className:"w-6 h-6 text-primary"}),e.jsxs("h1",{className:"text-2xl font-bold",children:["Edit ",n.name]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(R,{variant:"outline",onClick:()=>r(`/dashboard/admin/companies/${t}`),children:"Cancel"}),e.jsxs(R,{onClick:u,disabled:o,children:[e.jsx(wa,{className:"w-4 h-4 mr-2"}),o?"Saving...":"Save Changes"]})]})]}),e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsx(le,{children:"Admin Controls"})}),e.jsx(Z,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(B,{htmlFor:"status",children:"Status"}),e.jsxs(xe,{value:n.status||"Draft",onValueChange:d=>a({...n,status:d}),children:[e.jsx(ve,{id:"status",children:e.jsx(ge,{})}),e.jsxs(ye,{children:[e.jsx(J,{value:"Live",children:"Live"}),e.jsx(J,{value:"Draft",children:"Draft"})]})]})]}),e.jsxs("div",{children:[e.jsx(B,{htmlFor:"visibility",children:"Visibility"}),e.jsxs(xe,{value:n.visibility||"Private",onValueChange:d=>a({...n,visibility:d}),children:[e.jsx(ve,{id:"visibility",children:e.jsx(ge,{})}),e.jsxs(ye,{children:[e.jsx(J,{value:"Public",children:"Public"}),e.jsx(J,{value:"Protected",children:"Protected"}),e.jsx(J,{value:"Private",children:"Private"})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{htmlFor:"show_on_homepage",children:"Show on Homepage"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:'Display company logo under "Trusted by leading partners"'})]}),e.jsx(Tt,{id:"show_on_homepage",checked:n.show_on_homepage,onCheckedChange:d=>a({...n,show_on_homepage:d})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{htmlFor:"show_on_about_us",children:"Show on About Us"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:'Display company logo under "Check our partners"'})]}),e.jsx(Tt,{id:"show_on_about_us",checked:n.show_on_about_us,onCheckedChange:d=>a({...n,show_on_about_us:d})})]})]})]})})]}),e.jsx(SD,{companyId:n.id}),e.jsx(dg,{company:n,onChange:a,isAdmin:!0})]})}):e.jsx("div",{className:"min-h-screen bg-background p-6",children:e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Company not found"})})},CD=()=>{const[t,r]=_.useState([]),[n,a]=_.useState(!0),[s,i]=_.useState(null),[o,l]=_.useState(null),[c,u]=_.useState(!1),[d,h]=_.useState({question:"",answer:"",display_on_home:!1,display_on_faq_page:!0,highlighted:!1,status:"live"});_.useEffect(()=>{m()},[]);const m=async()=>{try{const{data:b,error:p}=await k.from("faqs").select("*").order("sort_order",{ascending:!0});if(p)throw p;r(b||[])}catch(b){console.error("Error fetching FAQs:",b),W.error("Failed to fetch FAQs")}finally{a(!1)}},j=async b=>{b.preventDefault();try{if(s){const{error:p}=await k.from("faqs").update({question:d.question,answer:d.answer,display_on_home:d.display_on_home,display_on_faq_page:d.display_on_faq_page,highlighted:d.highlighted,status:d.status}).eq("id",s.id);if(p)throw p;W.success("FAQ updated successfully")}else{const{error:p}=await k.from("faqs").insert({question:d.question,answer:d.answer,display_on_home:d.display_on_home,display_on_faq_page:d.display_on_faq_page,highlighted:d.highlighted,status:d.status,sort_order:t.length});if(p)throw p;W.success("FAQ created successfully")}u(!1),v(),m()}catch(p){console.error("Error saving FAQ:",p),W.error("Failed to save FAQ")}},w=async b=>{try{const{error:p}=await k.from("faqs").delete().eq("id",b);if(p)throw p;W.success("FAQ deleted successfully"),m()}catch(p){console.error("Error deleting FAQ:",p),W.error("Failed to delete FAQ")}finally{l(null)}},x=async(b,p)=>{const g=t.findIndex(O=>O.id===b);if(p==="up"&&g===0||p==="down"&&g===t.length-1)return;const N=p==="up"?g-1:g+1,S=[...t];[S[g],S[N]]=[S[N],S[g]];try{const O=S.map((C,P)=>({id:C.id,sort_order:P}));for(const C of O)await k.from("faqs").update({sort_order:C.sort_order}).eq("id",C.id);m()}catch(O){console.error("Error reordering FAQs:",O),W.error("Failed to reorder FAQs")}},v=()=>{h({question:"",answer:"",display_on_home:!1,display_on_faq_page:!0,highlighted:!1,status:"live"}),i(null)},y=b=>{i(b),h({question:b.question,answer:b.answer,display_on_home:b.display_on_home,display_on_faq_page:b.display_on_faq_page,highlighted:b.highlighted,status:b.status}),u(!0)},f=()=>
136{v(),u(!0)};return n?e.jsx("div",{className:"p-6",children:"Loading FAQs..."}):e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:"FAQ Management"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Manage frequently asked questions for your website"})]}),e.jsxs(ut,{open:c,onOpenChange:u,children:[e.jsx(cn,{asChild:!0,children:e.jsxs(R,{onClick:f,children:[e.jsx(Ve,{className:"w-4 h-4 mr-2"}),"Add FAQ"]})}),e.jsxs(ht,{className:"max-w-2xl",children:[e.jsxs(mt,{children:[e.jsx(ft,{children:s?"Edit FAQ":"Create FAQ"}),e.jsx($t,{children:s?"Update the FAQ details":"Add a new frequently asked question"})]}),e.jsxs("form",{onSubmit:j,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"question",children:"Question"}),e.jsx(de,{id:"question",value:d.question,onChange:b=>h({...d,question:b.target.value}),required:!0,placeholder:"Enter the question"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"answer",children:"Answer"}),e.jsx(Pt,{id:"answer",value:d.answer,onChange:b=>h({...d,answer:b.target.value}),required:!0,placeholder:"Enter the answer",rows:4})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Tt,{id:"display_on_home",checked:d.display_on_home,onCheckedChange:b=>h({...d,display_on_home:b})}),e.jsx(B,{htmlFor:"display_on_home",children:"Display on Home Page"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Tt,{id:"display_on_faq_page",checked:d.display_on_faq_page,onCheckedChange:b=>h({...d,display_on_faq_page:b})}),e.jsx(B,{htmlFor:"display_on_faq_page",children:"Display on FAQ Page"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Tt,{id:"highlighted",checked:d.highlighted,onCheckedChange:b=>h({...d,highlighted:b})}),e.jsx(B,{htmlFor:"highlighted",children:"⭐ Highlight (Show at top of FAQ page)"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Tt,{id:"status",checked:d.status==="live",onCheckedChange:b=>h({...d,status:b?"live":"draft"})}),e.jsx(B,{htmlFor:"status",children:"Published"})]}),e.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[e.jsx(R,{type:"button",variant:"outline",onClick:()=>{u(!1),v()},children:"Cancel"}),e.jsx(R,{type:"submit",children:s?"Update":"Create"})]})]})]})]})]}),e.jsx("div",{className:"space-y-4",children:t.map((b,p)=>e.jsx(Y,{children:e.jsx(ce,{children:e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(le,{className:"text-lg",children:b.question}),e.jsx(ct,{className:"mt-2",children:b.answer}),e.jsxs("div",{className:"flex gap-2 mt-3",children:[b.display_on_home&&e.jsx(re,{variant:"secondary",children:"Home Page"}),b.display_on_faq_page&&e.jsx(re,{variant:"secondary",children:"FAQ Page"}),b.highlighted&&e.jsx(re,{variant:"default",children:"⭐ Highlighted"}),e.jsx(re,{variant:b.status==="live"?"default":"outline",children:b.status})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(R,{size:"sm",variant:"ghost",onClick:()=>x(b.id,"up"),disabled:p===0,children:e.jsx(Bg,{className:"w-4 h-4"})}),e.jsx(R,{size:"sm",variant:"ghost",onClick:()=>x(b.id,"down"),disabled:p===t.length-1,children:e.jsx(zg,{className:"w-4 h-4"})})]}),e.jsx(R,{size:"sm",variant:"ghost",onClick:()=>y(b),children:e.jsx(Tn,{className:"w-4 h-4"})}),e.jsx(R,{size:"sm",variant:"ghost",onClick:()=>l(b.id),children:e.jsx(We,{className:"w-4 h-4"})})]})]})})},b.id))}),e.jsx(rr,{open:!!o,onOpenChange:()=>l(null),children:e.jsxs(nr,{children:[e.jsxs(ar,{children:[e.jsx(sr,{children:"Are you sure?"}),e.jsx(ir,{children:"This action cannot be undone. This will permanently delete the FAQ."})]}),e.jsxs(or,{children:[e.jsx(lr,{children:"Cancel"}),e.jsx(cr,{onClick:()=>o&&w(o),children:"Delete"})]})]})})]})},AD=()=>{const[t,r]=_.useState([]),[n,a]=_.useState(!1),[s,i]=_.useState(""),[o,l]=_.useState(null),[c,u]=_.useState(null);_.useEffect(()=>{d()},[]);const d=async()=>{try{const{data:y,error:f}=await k.storage.from("event-images").list("media",{limit:100,offset:0,sortBy:{column:"created_at",order:"desc"}});if(f)throw f;const b=y.map(p=>{var N,S;const{data:g}=k.storage.from("event-images").getPublicUrl(`media/${p.name}`);return{name:p.name,url:g.publicUrl,size:((N=p.metadata)==null?void 0:N.size)||0,type:((S=p.metadata)==null?void 0:S.mimetype)||"unknown",created_at:p.created_at||new Date().toISOString()}});r(b)}
136catch(y){we.error({title:"Error loading files",description:y.message})}},h=async y=>{const f=y.target.files;if(!(!f||f.length===0)){a(!0);try{const b=Array.from(f).map(async p=>{if(!["image/","video/","application/pdf"].some(P=>p.type.startsWith(P)))throw new Error(`File ${p.name} is not an allowed type`);if(p.size>10485760)throw new Error(`File ${p.name} is too large (max 10MB)`);const N=p.name.split(".").pop(),O=`media/${`${Date.now()}-${Math.random().toString(36).substring(2)}.${N}`}`,{error:C}=await k.storage.from("event-images").upload(O,p);if(C)throw C});await Promise.all(b),we.success({title:"Upload successful",description:`${f.length} file(s) uploaded successfully`}),d()}catch(b){we.error({title:"Upload failed",description:b.message})}finally{a(!1),y.target.value=""}}},m=y=>{navigator.clipboard.writeText(y),u(y),we.success({title:"URL copied",description:"Image URL has been copied to clipboard"}),setTimeout(()=>u(null),2e3)},j=async()=>{if(o)try{const y=`media/${o.name}`,{error:f}=await k.storage.from("event-images").remove([y]);if(f)throw f;we.success({title:"File deleted",description:"Media file has been deleted successfully"}),d()}catch(y){we.error({title:"Delete failed",description:y.message})}finally{l(null)}},w=y=>y.startsWith("image/")?e.jsx(Nr,{className:"w-4 h-4"}):y.startsWith("video/")?e.jsx(_v,{className:"w-4 h-4"}):e.jsx(ln,{className:"w-4 h-4"}),x=y=>{if(y===0)return"0 Bytes";const f=1024,b=["Bytes","KB","MB","GB"],p=Math.floor(Math.log(y)/Math.log(f));return Math.round(y/Math.pow(f,p)*100)/100+" "+b[p]},v=t.filter(y=>y.name.toLowerCase().includes(s.toLowerCase()));return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("main",{className:"py-8",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[e.jsx("div",{className:"bg-gradient-to-r from-muted/50 to-muted rounded-lg p-4 mb-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx(Nr,{className:"w-6 h-6 text-primary"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-foreground",children:"Media Library"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Upload and manage images, videos, and documents for your blog posts"})]})]}),e.jsx("div",{className:"flex items-center space-x-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-lg font-bold text-primary",children:t.length}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Total Files"})]})})]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsx(le,{children:"Upload Files"})}),e.jsx(Z,{className:"space-y-4",children:e.jsxs("div",{className:"border-2 border-dashed border-border rounded-lg p-8 text-center",children:[e.jsx(ff,{className:"w-12 h-12 mx-auto mb-4 text-muted-foreground"}),e.jsxs(B,{htmlFor:"file-upload",className:"cursor-pointer",children:[e.jsx("span",{className:"text-lg font-medium",children:n?"Uploading...":"Click to upload files"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"Images, videos, or PDFs (Max 10MB per file)"})]}),e.jsx(de,{id:"file-upload",type:"file",multiple:!0,accept:"image/*,video/*,application/pdf",onChange:h,disabled:n,className:"hidden"})]})})]}),e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(le,{children:["Media Files (",v.length,")"]}),e.jsxs("div",{className:"relative w-64",children:[e.jsx(tr,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(de,{placeholder:"Search files...",value:s,onChange:y=>i(y.target.value),className:"pl-10"})]})]})}),e.jsx(Z,{children:v.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(Nr,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No media files found"})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:v.map(y=>e.jsxs("div",{className:"border rounded-lg overflow-hidden hover:shadow-md transition-shadow",children:[e.jsx("div",{className:"aspect-video bg-muted flex items-center justify-center",children:y.type.startsWith("image/")?e.jsx("img",{src:y.url,alt:y.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"text-muted-foreground",children:w(y.type)})}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm truncate",title:y.name,children:y.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[x(y.size)," • ",new Date(y.created_at).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(R,{variant:"outline",size:"sm",onClick:()=>m(y.url),className:"flex-1",children:c===y.url?e.jsxs(e.Fragment,{children:[e.jsx(pr,{className:"w-4 h-4 mr-1"}),"Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(Zm,{className:"w-4 h-4 mr-1"}),"Copy URL"]})}),e.jsx(R,{variant:"outline",size:"sm",onClick:()=>l(y),children:e.jsx(We,{className:"w-4 h-4"})})]})]})]},y.name))})})]})]})]})}),e.jsx(rr,{open:!!o,onOpenChange:()=>l(null),children:e.jsxs(nr,{children:[e.jsxs(ar,{children:[e.jsx(sr,{children:"Delete Media File"}),e.jsxs(ir,{children:['Are you sure you want to delete "',o==null?void 0:o.name,'"? This action cannot be undone.']})]}),e.jsxs(or,{children:[e.jsx(lr,{children:"Cancel"}),e.jsx(cr,{onClick:j,children:"Delete"})]})]})})]})},PD=()=>{const t=gt(),[r,n]=_.useState([]),[a,s]=_.useState(!0),[i,o]=_.useState(!1),[l,c]=_.useState(null),[u,d]=_.useState({name:"",description:""});_.useEffect(()=>{h()},[]);const h=async()=>{try{const{data:v,error:y}=await k.from("chapters").select("*").order("name");if(y)throw y;n(v||[])}catch(v){console.error("Error fetching chapters:",v),W.error("Failed to load chapters")}finally{s(!1)}},m=v=>{v?(c(v),d({name:v.name,description:v.description||""})):(c(null),d({name:"",description:""})),o(!0)},j=()=>{o(!1),c(null),d({name:"",description:""})},w=async v=>{v.preventDefault();try{if(l){const{error:y}=await k.from("chapters").update({name:u.name,description:u.description||null}).eq("id",l.id);if(y)throw y;W.success("Chapter updated successfully")}else{const{error:y}=await k.from("chapters").insert({name:u.name,description:u.description||null});if(y)throw y;W.success("Chapter created successfully")}j(),h()}catch(y){console.error("Error saving chapter:",y),W.error("Failed to save chapter")}},x=async v=>{if(confirm("Are you sure you want to delete this chapter?"))try{const{error:y}=await k.from("chapters").delete().eq("id",v);if(y)throw y;W.success("Chapter deleted successfully"),h()}catch(y){console.error("Error deleting chapter:",y),W.error("Failed to delete chapter")}};return a?e.jsx("div",{className:"flex items-center justify-center p-12",children:e.jsx(Qe,{size:48})}):e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:"Chapter Management"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"Manage chapters and their details"})]}),e.jsxs(R,{onClick:()=>m(),children:[e.jsx(Ve,{className:"h-4 w-4 mr-2"}),"Add Chapter"]})]}),e.jsxs(nt,{children:[e.jsx(at,{children:e.jsxs(pe,{children:[e.jsx(te,{children:"Name"}),e.jsx(te,{children:"Description"}),e.jsx(te,{children:"Created"}),e.jsx(te,{className:"text-right",children:"Actions"})]})}),e.jsxs(st,{children:[r.map(v=>e.jsxs(pe,{children:[e.jsx(X,{className:"font-medium",children:v.name}),e.jsx(X,{children:v.description||"-"}),e.jsx(X,{children:new Date(v.created_at).toLocaleDateString()}),e.jsxs(X,{className:"text-right space-x-2",children:[e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>
136t(`/dashboard/admin/chapters/${v.id}`),children:e.jsx(dr,{className:"h-4 w-4"})}),e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>m(v),children:e.jsx(Tn,{className:"h-4 w-4"})}),e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>x(v.id),children:e.jsx(We,{className:"h-4 w-4"})})]})]},v.id)),r.length===0&&e.jsx(pe,{children:e.jsx(X,{colSpan:4,className:"text-center text-muted-foreground",children:"No chapters found. Create your first chapter to get started."})})]})]}),e.jsx(ut,{open:i,onOpenChange:o,children:e.jsx(ht,{children:e.jsxs("form",{onSubmit:w,children:[e.jsxs(mt,{children:[e.jsx(ft,{children:l?"Edit Chapter":"Add New Chapter"}),e.jsx($t,{children:l?"Update chapter details":"Create a new chapter"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"name",children:"Name *"}),e.jsx(de,{id:"name",value:u.name,onChange:v=>d({...u,name:v.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"description",children:"Description"}),e.jsx(Pt,{id:"description",value:u.description,onChange:v=>d({...u,description:v.target.value}),rows:3})]})]}),e.jsxs(Vt,{children:[e.jsx(R,{type:"button",variant:"outline",onClick:j,children:"Cancel"}),e.jsx(R,{type:"submit",children:l?"Update":"Create"})]})]})})})]})},Rm=[{value:"event_crew",label:"Event Crew"},{value:"team_coordinator",label:"Team Coordinator"},{value:"chapter_lead",label:"Chapter Lead"},{value:"regional_lead",label:"Regional Lead"},{value:"global_team",label:"Global Team"}],kD=()=>{const{chapterId:t}=Zr(),r=gt(),[n,a]=_.useState(null),[s,i]=_.useState([]),[o,l]=_.useState([]),[c,u]=_.useState([]),[d,h]=_.useState(!0),[m,j]=_.useState(!1),[w,x]=_.useState(!1),[v,y]=_.useState(""),[f,b]=_.useState(""),[p,g]=_.useState(""),[N,S]=_.useState(""),[O,C]=_.useState(""),[P,$]=_.useState([]),[A,I]=_.useState([]);_.useEffect(()=>{t&&(D(),q(),F(),M())},[t]);const D=async()=>{try{const{data:z,error:he}=await k.from("chapters").select("*").eq("id",t).single();if(he)throw he;a(z)}catch(z){console.error("Error fetching chapter:",z),W.error("Failed to load chapter")}finally{h(!1)}},q=async()=>{try{const{data:z,error:he}=await k.from("chapter_members").select("id, user_id, role, created_at").eq("chapter_id",t).order("created_at",{ascending:!1});if(he)throw he;if(!z||z.length===0){i([]);return}const ne=z.map(T=>T.user_id),{data:fe,error:De}=await k.from("profiles").select("user_id, name, email").in("user_id",ne);if(De)throw De;const Ce=new Map((fe==null?void 0:fe.map(T=>[T.user_id,T]))||[]),Re=z.map(T=>({...T,profiles:Ce.get(T.user_id)||{name:"Unknown",email:"Unknown"}}));i(Re)}catch(z){console.error("Error fetching members:",z),W.error("Failed to load members")}},F=async()=>{try{const{data:z,error:he}=await k.from("chapter_events").select("id, event_id, created_at").eq("chapter_id",t).order("created_at",{ascending:!1});if(he)throw he;if(!z||z.length===0){l([]);return}const ne=z.map(T=>T.event_id),{data:fe,error:De}=await k.from("events").select("id, title, start_date, end_date, event_type").in("id",ne);if(De)throw De;const Ce=new Map((fe==null?void 0:fe.map(T=>[T.id,T]))||[]),Re=z.map(T=>({...T,events:Ce.get(T.event_id)||{title:"Unknown Event",start_date:"",end_date:"",event_type:""}}));l(Re)}catch(z){console.error("Error fetching chapter events:",z),W.error("Failed to load chapter events")}},K=async z=>{if(!z||z.length<2){I([]);return}try{const{data:he,error:ne}=await k.from("events").select("id, title, start_date, event_type").or(`title.ilike.%${z}%,event_type.ilike.%${z}%`).order("start_date",{ascending:!1}).limit(10);if(ne)throw ne;I(he||[])}catch(he){console.error("Error searching events:",he)}},M=async()=>{try{const{data:z,error:he}=await k.from("events").select("id, title, start_date, event_type").order("start_date",{ascending:!1});if(he)throw he;u(z||[])}catch(z){console.error("Error fetching events:",z)}},E=async z=>{if(!z||z.length<2){$([]);return}try{const{data:he,error:ne}=await k.from("profiles").select("user_id, name, email").or(`name.ilike.%${z}%,email.ilike.%${z}%`).limit(10);if(ne)throw ne;$(he||[])}catch(he){console.error("Error searching users:",he)}},Q=async()=>
136{if(!v||!f){W.error("Please select a user and role");return}try{const{error:z}=await k.from("chapter_members").insert([{chapter_id:t,user_id:v,role:f}]);if(z)throw z;W.success("Member added successfully"),j(!1),y(""),b(""),S(""),$([]),q()}catch(z){console.error("Error adding member:",z),(z==null?void 0:z.code)==="23505"?W.error("User already has this role in this chapter"):W.error("Failed to add member")}},H=async z=>{if(confirm("Are you sure you want to remove this member?"))try{const{error:he}=await k.from("chapter_members").delete().eq("id",z);if(he)throw he;W.success("Member removed successfully"),q()}catch(he){console.error("Error removing member:",he),W.error("Failed to remove member")}},V=async()=>{if(!p){W.error("Please select an event");return}try{const{error:z}=await k.from("chapter_events").insert([{chapter_id:t,event_id:p}]);if(z)throw z;W.success("Event added to chapter successfully"),x(!1),g(""),C(""),I([]),F()}catch(z){console.error("Error adding event:",z),(z==null?void 0:z.code)==="23505"?W.error("Event already linked to this chapter"):W.error("Failed to add event")}},se=async z=>{if(confirm("Are you sure you want to remove this event from the chapter?"))try{const{error:he}=await k.from("chapter_events").delete().eq("id",z);if(he)throw he;W.success("Event removed from chapter successfully"),F()}catch(he){console.error("Error removing event:",he),W.error("Failed to remove event")}},ue=z=>{var he;return((he=Rm.find(ne=>ne.value===z))==null?void 0:he.label)||z};return d?e.jsx("div",{className:"flex items-center justify-center p-12",children:e.jsx(Qe,{size:48})}):n?e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs(R,{variant:"ghost",onClick:()=>r("/dashboard/admin/chapters"),children:[e.jsx(Bt,{className:"h-4 w-4 mr-2"}),"Back"]})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:n.name}),n.description&&e.jsx("p",{className:"text-muted-foreground mt-2",children:n.description})]}),e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(le,{children:"Chapter Members"}),e.jsxs(R,{onClick:()=>j(!0),children:[e.jsx(Ve,{className:"h-4 w-4 mr-2"}),"Add Member"]})]})}),e.jsx(Z,{children:e.jsxs(nt,{children:[e.jsx(at,{children:e.jsxs(pe,{children:[e.jsx(te,{children:"Name"}),e.jsx(te,{children:"Email"}),e.jsx(te,{children:"Role"}),e.jsx(te,{children:"Added"}),e.jsx(te,{className:"text-right",children:"Actions"})]})}),e.jsxs(st,{children:[s.map(z=>e.jsxs(pe,{children:[e.jsx(X,{className:"font-medium",children:z.profiles.name}),e.jsx(X,{children:z.profiles.email}),e.jsx(X,{children:ue(z.role)}),e.jsx(X,{children:new Date(z.created_at).toLocaleDateString()}),e.jsx(X,{className:"text-right",children:e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>H(z.id),children:e.jsx(We,{className:"h-4 w-4"})})})]},z.id)),s.length===0&&e.jsx(pe,{children:e.jsx(X,{colSpan:5,className:"text-center text-muted-foreground",children:"No members assigned to this chapter yet."})})]})]})})]}),e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(le,{children:"Linked Events"}),e.jsxs(R,{onClick:()=>x(!0),children:[e.jsx(Ve,{className:"h-4 w-4 mr-2"}),"Add Event"]})]})}),e.jsx(Z,{children:e.jsxs(nt,{children:[e.jsx(at,{children:e.jsxs(pe,{children:[e.jsx(te,{children:"Event Title"}),e.jsx(te,{children:"Type"}),e.jsx(te,{children:"Start Date"}),e.jsx(te,{children:"Linked"}),e.jsx(te,{className:"text-right",children:"Actions"})]})}),e.jsxs(st,{children:[o.map(z=>e.jsxs(pe,{children:[e.jsx(X,{className:"font-medium",children:z.events.title}),e.jsx(X,{children:z.events.event_type}),e.jsx(X,{children:z.events.start_date?new Date(z.events.start_date).toLocaleDateString():"-"}),e.jsx(X,{children:new Date(z.created_at).toLocaleDateString()}),e.jsx(X,{className:"text-right",children:e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>se(z.id),children:e.jsx(We,{className:"h-4 w-4"})})})]},z.id)),o.length===0&&e.jsx(pe,{children:e.jsx(X,{colSpan:5,className:"text-center text-muted-foreground",children:"No events linked to this chapter yet."})})]})]})})]}),e.jsx(ut,{open:m,onOpenChange:j,children:e.jsxs(ht,{className:"max-w-md",children:[e.jsxs(mt,{children:[e.jsx(ft,{children:"Add Member to Chapter"}),e.jsx($t,{children:"Search for a user and assign them a role in this chapter"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"user-search",children:"Search User"}),e.jsx(de,{id:"user-search",placeholder:"Search by name or email...",value:N,onChange:z=>{S(z.target.value),E(z.target.value)}}),P.length>0&&e.jsx("div",{className:"border rounded-md max-h-48 overflow-y-auto",children:P.map(z=>e.jsxs("div",{className:`p-2 cursor-pointer hover:bg-muted ${v===z.user_id?"bg-muted":""}`,onClick:()=>{y(z.user_id),S(z.name||z.email),$([])},children:[e.jsx("div",{className:"font-medium",children:z.name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:z.email})]},z.user_id))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"role",children:"Role"}),e.jsxs(xe,{value:f,onValueChange:b,children:[e.jsx(ve,{children:e.jsx(ge,{placeholder:"Select a role"})}),e.jsx(ye,{children:Rm.map(z=>e.jsx(J,{value:z.value,children:z.label},z.value))})]})]})]}),e.jsxs(Vt,{children:[e.jsx(R,{type:"button",variant:"outline",onClick:()=>{j(!1),y(""),b(""),S(""),$([])},children:"Cancel"}),e.jsx(R,{onClick:Q,children:"Add Member"})]})]})}),e.jsx(ut,{open:w,onOpenChange:x,children:e.jsxs(ht,{className:"max-w-md",children:[e.jsxs(mt,{children:[e.jsx(ft,{children:"Add Event to Chapter"}),e.jsx($t,{children:"Search for an event to link to this chapter"})]}),e.jsx("div",{className:"space-y-4 py-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"event-search",children:"Search Event"}),e.jsx(de,{id:"event-search",placeholder:"Search by event name or type...",value:O,onChange:z=>{C(z.target.value),K(z.target.value)}}),A.length>0&&e.jsx("div",{className:"border rounded-md max-h-48 overflow-y-auto",children:A.map(z=>e.jsxs("div",{className:`p-3 cursor-pointer hover:bg-muted transition-colors ${p===z.id?"bg-muted":""}`,onClick:()=>{g(z.id),C(`${z.title} (${z.event_type})`),I([])},children:[e.jsx("div",{className:"font-medium",children:z.title}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[z.event_type," - ",new Date(z.start_date).toLocaleDateString()]})]},z.id))})]})}),e.jsxs(Vt,{children:[e.jsx(R,{type:"button",variant:"outline",onClick:()=>{x(!1),g(""),C(""),I([])},children:"Cancel"}),e.jsx(R,{onClick:V,disabled:!p,children:"Add Event"})]})]})})]}):e.jsx("div",{className:"p-6",children:"Chapter not found"})},Fm=[{value:"MARKETING",label:"Marketing",icon:"📣"},{value:"TECH",label:"Tech",icon:"💻"},{value:"BUSINESS",label:"Business",icon:"💼"},{value:"LEGAL",label:"Legal",icon:"⚖️"}],Bm=[{value:"junior",label:"Junior (0-2 years)"},{value:"mid",label:"Mid-level (3-5 years)"},{value:"senior",label:"Senior (6-10 years)"},{value:"executive",label:"Executive (10+ years)"}],bl=[{value:"mentor",label:"Mentor",icon:Ge,color:"bg-blue-500/10 text-blue-600",borderColor:"border-blue-200"},{value:"investor",label:"Investor",icon:Jr,color:"bg-green-500/10 text-green-600",borderColor:"border-green-200"},{value:"jury",label:"Jury",icon:Xg,color:"bg-purple-500/10 text-purple-600",borderColor:"border-purple-200"},{value:"speaker",label:"Speaker",icon:Yg,color:"bg-orange-500/10 text-orange-600",borderColor:"border-orange-200"}],ED={mentor:[{key:"experience",label:"Years of Experience",type:"text"},{key:"expertise",label:"Expertise",type:"array"},{key:"mentorship_areas",label:"Mentorship Areas",type:"array"},{key:"achievements",label:"Achievements",type:"array"}],investor:[{key:"investment_focus",label:"Investment Focus",type:"array"},{key:"investment_stage",label:"Investment Stage",type:"array"},{key:"ticket_size_min",label:"Min Ticket Size ($)",type:"text"},{key:"ticket_size_max",label:"Max Ticket Size ($)",type:"text"},{key:"geographic_focus",label:"Geographic Focus",type:"text"},{key:"portfolio_companies",label:"Portfolio Companies",type:"array"}],jury:[{key:"judging_criteria",label:"Judging Criteria",type:"array"}
136,{key:"industry_focus",label:"Industry Focus",type:"array"},{key:"past_events",label:"Past Judging Events",type:"array"}],speaker:[{key:"speaking_experience",label:"Speaking Experience",type:"text"},{key:"topics",label:"Topics",type:"array"},{key:"past_events",label:"Past Speaking Events",type:"array"}]},TD=({user:t,onUpdate:r})=>{var be,ot,yt,zt,Ar,ur,ee,Ne,ke,G,_e;const[n,a]=_.useState(!1),[s,i]=_.useState(!1),[o,l]=_.useState(null),[c,u]=_.useState(null),[d,h]=_.useState(""),[m,j]=_.useState(""),[w,x]=_.useState(""),[v,y]=_.useState([]),[f,b]=_.useState(!0),[p,g]=_.useState(null),[N,S]=_.useState({}),[O,C]=_.useState("Draft"),[P,$]=_.useState("Public"),[A,I]=_.useState({}),[D,q]=_.useState(!1),[F,K]=_.useState("");_.useEffect(()=>{M(),E()},[t.id]);const M=async()=>{const{data:U}=await k.from("profiles").select("*").eq("user_id",t.user_id).single();U&&(l(U),u(U))},E=async()=>{try{const{data:U,error:oe}=await k.from("role_extensions").select("*").eq("profile_id",t.id);if(oe)throw oe;const Te=(U||[]).map(Xe=>({...Xe,role_data:typeof Xe.role_data=="object"&&Xe.role_data!==null?Xe.role_data:{}}));y(Te)}catch(U){console.error("Error fetching role extensions:",U)}finally{b(!1)}},Q=()=>{u({...o}),a(!0)},H=()=>{l(c),a(!1)},V=async()=>{i(!0);try{const U=`${o.first_name||""} ${o.last_name||""}`.trim(),oe=[o.city,o.country].filter(Boolean).join(", "),{error:Te}=await k.from("profiles").update({first_name:o.first_name,last_name:o.last_name,name:U,email:o.email,bio:o.bio,company:o.company,position:o.position,experience_level:o.experience_level,main_badge:o.main_badge,city:o.city,country:o.country,location:oe,skills:o.skills,interests:o.interests,looking_for:o.looking_for,linkedin:o.linkedin,twitter:o.twitter,website:o.website,languages:o.languages}).eq("user_id",t.user_id);if(Te)throw Te;W.success("Profile updated"),a(!1),r()}catch(U){console.error("Error:",U),W.error("Failed to update profile")}finally{i(!1)}},se=(U,oe,Te)=>{if(!oe.trim())return;const Xe=o[U]||[];Xe.includes(oe.trim())||l(lt=>({...lt,[U]:[...Xe,oe.trim()]})),Te("")},ue=(U,oe)=>{const Te=o[U]||[];l(Xe=>({...Xe,[U]:Te.filter(lt=>lt!==oe)}))},z=U=>{var oe;return((oe=Bm.find(Te=>Te.value===U))==null?void 0:oe.label)||U}
136,he=U=>Fm.find(oe=>oe.value===U),ne=async()=>{if(F){if(v.some(U=>U.role_type===F)){W.error("This role extension already exists");return}try{const U=`${F}-${t.id.substring(0,8)}`,{data:oe,error:Te}=await k.from("role_extensions").insert({profile_id:t.id,role_type:F,slug:U,role_data:{},status:"Draft",visibility:"Public"}).select().single();if(Te)throw Te;y([...v,{...oe,role_data:{}}]),q(!1),K(""),W.success("Role profile created")}catch(U){console.error("Error creating role extension:",U),W.error("Failed to create role profile")}}},fe=U=>{g(U.id),S({...U.role_data}),C(U.status),$(U.visibility),I({})},De=async U=>{try{const{error:oe}=await k.from("role_extensions").update({role_data:N,status:O,visibility:P}).eq("id",U);if(oe)throw oe;y(v.map(Te=>Te.id===U?{...Te,role_data:N,status:O,visibility:P}:Te)),g(null),W.success("Role profile updated")}catch(oe){console.error("Error updating role extension:",oe),W.error("Failed to update role profile")}},Ce=async U=>{try{const{error:oe}=await k.from("role_extensions").update({status:"Live"}).eq("id",U);if(oe)throw oe;y(v.map(Te=>Te.id===U?{...Te,status:"Live"}:Te)),W.success("Role profile approved and now live")}catch(oe){console.error("Error approving role:",oe),W.error("Failed to approve role profile")}},Re=async U=>{if(confirm("Are you sure you want to reject this role profile? It will be set back to Draft status."))try{const{error:oe}=await k.from("role_extensions").update({status:"Draft"}).eq("id",U);if(oe)throw oe;y(v.map(Te=>Te.id===U?{...Te,status:"Draft"}:Te)),W.success("Role profile rejected and set to Draft")}catch(oe){console.error("Error rejecting role:",oe),W.error("Failed to reject role profile")}},T=async U=>{if(confirm("Delete this role profile?"))try{const{error:oe}=await k.from("role_extensions").delete().eq("id",U);if(oe)throw oe;y(v.filter(Te=>Te.id!==U)),W.success("Role profile deleted")}catch(oe){console.error("Error deleting role extension:",oe),W.error("Failed to delete role profile")}},ie=U=>{var Xe;const oe=(Xe=A[U])==null?void 0:Xe.trim();if(!oe)return;const Te=N[U]||[];Te.includes(oe)||S({...N,[U]:[...Te,oe]}),I({...A,[U]:""})},Se=(U,oe)=>{const Te=N[U]||[];S({...N,[U]:Te.filter(Xe=>Xe!==oe)})},Ae=U=>bl.find(oe=>oe.value===U)||bl[0],Pe=({items:U})=>!U||U.length===0?e.jsx("span",{className:"text-muted-foreground text-sm italic",children:"Not set"}):e.jsx("div",{className:"flex flex-wrap gap-1",children:U.map((oe,Te)=>e.jsx(re,{variant:"secondary",className:"text-xs",children:oe},Te))}),Ue=[o==null?void 0:o.city,o==null?void 0:o.country].filter(Boolean).join(", ");return o?e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Y,{children:[e.jsx(ce,{className:"pb-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-primary/10",children:e.jsx(Gg,{className:"h-5 w-5 text-primary"})}),e.jsx(le,{className:"text-lg",children:"Basic Information"})]}),n?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(R,{variant:"ghost",size:"sm",onClick:H,disabled:s,children:[e.jsx(Pr,{className:"mr-1 h-4 w-4"}),"Cancel"]}),e.jsxs(R,{size:"sm",onClick:V,disabled:s,children:[s?e.jsx(Qe,{size:16,className:"mr-2"}):e.jsx(pr,{className:"mr-1 h-4 w-4"}),"Save"]})]}):e.jsxs(R,{variant:"outline",size:"sm",onClick:Q,children:[e.jsx(Tn,{className:"mr-2 h-4 w-4"}),"Edit"]})]})}),e.jsx(Z,{className:"space-y-6",children:n?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"First Name"}),e.jsx(de,{value:o.first_name||"",onChange:U=>l(oe=>({...oe,first_name:U.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Last Name"}),e.jsx(de,{value:o.last_name||"",onChange:U=>l(oe=>({...oe,last_name:U.target.value}))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Email"}),e.jsx(de,{type:"email",value:o.email||"",onChange:U=>l(oe=>({...oe,email:U.target.value}))})]}),e.jsx(uf,{city:o.city||"",country:o.country||"",onCityChange:U=>l(oe=>({...oe,city:U})),onCountryChange:U=>l(oe=>({...oe,country:U}))}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Bio"}),e.jsx(Pt,{value:o.bio||"",onChange:U=>l(oe=>({...oe,bio:U.target.value})),rows:3,placeholder:"Tell us about this user..."})]}),e.jsxs("div",{className:"pt-4 border-t",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(ns,{className:"h-4 w-4 text-blue-500"}),e.jsx("span",{className:"text-sm font-medium",children:"Professional"})]}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Company"}),e.jsx(de,{value:o.company||"",onChange:U=>l(oe=>({...oe,company:U.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Position"}),e.jsx(de,{value:o.position||"",onChange:U=>l(oe=>({...oe,position:U.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Experience Level"}),e.jsxs(xe,{value:o.experience_level||"",onValueChange:U=>l(oe=>({...oe,experience_level:U})),children:[e.jsx(ve,{children:e.jsx(ge,{placeholder:"Select level"})}),e.jsx(ye,{children:Bm.map(U=>e.jsx(J,{value:U.value,children:U.label},U.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Main Badge"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:Fm.map(U=>e.jsxs("button",{type:"button",onClick:()=>l(oe=>({...oe,main_badge:U.value})),className:rs("relative p-3 rounded-xl border-2 transition-all hover:shadow-md",o.main_badge===U.value?"border-primary bg-primary/5 shadow-sm":"border-border/50 hover:border-primary/30"),children:[e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("span",{className:"text-2xl",children:U.icon}),e.jsx("span",{className:"text-sm font-medium",children:U.label})]}),o.main_badge===U.value&&e.jsx("div",{className:"absolute -top-1 -right-1 w-5 h-5 rounded-full bg-primary flex items-center justify-center",children:e.jsx(pr,{className:"w-3 h-3 text-primary-foreground"})})]},U.value))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Skills"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(de,{value:d,onChange:U=>h(U.target.value),placeholder:"Add skill",onKeyPress:U=>U.key==="Enter"&&(U.preventDefault(),se("skills",d,h))}),e.jsx(R,{type:"button",variant:"outline",size:"icon",onClick:()=>se("skills",d,h),children:e.jsx(Ve,{className:"h-4 w-4"})})]}),((ke=o.skills)==null?void 0:ke.length)>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:o.skills.map((U,oe)=>e.jsxs(re,{variant:"secondary",className:"text-xs gap-1",children:[U,e.jsx(Pr,{className:"h-3 w-3 cursor-pointer",onClick:()=>ue("skills",U)})]},oe))})]}),e.jsxs("div",{className:"pt-4 border-t",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(Da,{className:"h-4 w-4 text-green-500"}),e.jsx("span",{className:"text-sm font-medium",children:"Social Links"})]}),e.jsxs("div",{className:"grid sm:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(B,{className:"flex items-center gap-2",children:[e.jsx(El,{className:"h-4 w-4 text-blue-600"}),"LinkedIn"]}),e.jsx(de,{value:o.linkedin||"",onChange:U=>l(oe=>({...oe,linkedin:U.target.value})),placeholder:"https://linkedin.com/in/..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(B,{className:"flex items-center gap-2",children:[e.jsx(Tl,{className:"h-4 w-4 text-blue-400"}),"Twitter"]}),e.jsx(de,{value:o.twitter||"",onChange:U=>l(oe=>({...oe,twitter:U.target.value})),placeholder:"@username"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(B,{className:"flex items-center gap-2",children:[e.jsx(Da,{className:"h-4 w-4 text-primary"}),"Website"]}),e.jsx(de,{value:o.website||"",onChange:U=>l(oe=>({...oe,website:U.target.value})),placeholder:"https://..."})]})]})]}),e.jsxs("div",{className:"pt-4 border-t",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(Ol,{className:"h-4 w-4 text-purple-500"}),e.jsx("span",{className:"text-sm font-medium",children:"Interests & Goals"})]}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Interests"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(de,{value:m,onChange:U=>j(U.target.value),placeholder:"Add interest",onKeyPress:U=>U.key==="Enter"&&(U.preventDefault(),se("interests",m,j))}),e.jsx(R,{type:"button",variant:"outline",size:"icon",onClick:()=>se("interests",m,j),children:e.jsx(Ve,{className:"h-4 w-4"})})]}),((G=o.interests)==null?void 0:G.length)>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:o.interests.map((U,oe)=>e.jsxs(re,{variant:"secondary",className:"text-xs gap-1",children:[U,e.jsx(Pr,{className:"h-3 w-3 cursor-pointer",onClick:()=>ue("interests",U)})]},oe))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Looking For"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(de,{value:w,onChange:U=>x(U.target.value),placeholder:"Add item",onKeyPress:U=>U.key==="Enter"&&(U.preventDefault(),se("looking_for",w,x))}),e.jsx(R,{type:"button",variant:"outline",size:"icon",onClick:()=>se("looking_for",w,x),children:e.jsx(Ve,{className:"h-4 w-4"})})]}),((_e=o.looking_for)==null?void 0:_e.length)>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:o.looking_for.map((U,oe)=>e.jsxs(re,{variant:"outline",className:"text-xs gap-1 border-green-500/30 text-green-700",children:[U,e.jsx(Pr,{className:"h-3 w-3 cursor-pointer",onClick:()=>ue("looking_for",U)})]},oe))})]})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Full Name"}),e.jsxs("p",{className:"text-sm font-medium",children:[o.first_name," ",o.last_name]})]}),e.jsxs("div",{children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Email"}),e.jsx("p",{className:"text-sm",children:o.email})]}),Ue&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(kn,{className:"h-4 w-4 text-muted-foreground mt-0.5"}),e.jsxs("div",{children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Location"}),e.jsx("p",{className:"text-sm",children:Ue})]})]})]}),o.bio&&e.jsxs("div",{children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Bio"}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:o.bio})]}),e.jsxs("div",{className:"pt-2 border-t",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(ns,{className:"h-4 w-4 text-blue-500"}),e.jsx("span",{className:"text-sm font-medium",children:"Professional"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[o.company&&e.jsxs("div",{children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Company"}),e.jsx("p",{className:"text-sm",children:o.company})]}),o.position&&e.jsxs("div",{children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Position"}),e.jsx("p",{className:"text-sm",children:o.position})]}),o.experience_level&&e.jsxs("div",{children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Experience"}),e.jsx("p",{className:"text-sm",children:z(o.experience_level)})]}),o.main_badge&&e.jsxs("div",{children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Main Badge"}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[e.jsx("span",{children:(be=he(o.main_badge))==null?void 0:be.icon}),e.jsx(re,{variant:"secondary",className:"text-xs",children:(ot=he(o.main_badge))==null?void 0:ot.label})]})]})]})]}),((yt=o.skills)==null?void 0:yt.length)>0&&e.jsxs("div",{children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Skills"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1",children:o.skills.map((U,oe)=>e.jsx(re,{className:"text-xs bg-primary/10 text-primary border-0",children:U},oe))})]}),((zt=o.languages)==null?void 0:zt.length)>0&&e.jsxs("div",{children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Languages"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1",children:o.languages.map((U,oe)=>e.jsx(re,{variant:"outline",className:"text-xs",children:U},oe))})]}),(o.linkedin||o.twitter||o.website)&&e.jsxs("div",{className:"pt-2 border-t",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Da,{className:"h-4 w-4 text-green-500"}),e.jsx("span",{className:"text-sm font-medium",children:"Social Links"})]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[o.linkedin&&e.jsxs("a",{href:o.linkedin.startsWith("http")?o.linkedin:`https://${o.linkedin}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-sm text-blue-600 hover:underline",children:[e.jsx(El,{className:"h-4 w-4"}),"LinkedIn"]}),o.twitter&&e.jsxs("a",{href:o.twitter.startsWith("http")?o.twitter:`https://twitter.com/${o.twitter.replace("@","")}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-sm text-blue-400 hover:underline",children:[e.jsx(Tl,{className:"h-4 w-4"}),o.twitter]}),o.website&&e.jsxs("a",{href:o.website.startsWith("http")?o.website:`https://${o.website}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-sm text-primary hover:underline",children:[e.jsx(Da,{className:"h-4 w-4"}),"Website"]})]})]}),(((Ar=o.interests)==null?void 0:Ar.length)>0||((ur=o.looking_for)==null?void 0:ur.length)>0)&&e.jsxs("div",{className:"pt-2 border-t",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Ol,{className:"h-4 w-4 text-purple-500"}),e.jsx("span",{className:"text-sm font-medium",children:"Interests & Goals"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[((ee=o.interests)==null?void 0:ee.length)>0&&e.jsxs("div",{children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Interests"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1",children:o.interests.map((U,oe)=>e.jsx(re,{variant:"secondary",className:"text-xs",children:U},oe))})]}),((Ne=o.looking_for)==null?void 0:Ne.length)>0&&e.jsxs("div",{children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Looking For"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1",children:o.looking_for.map((U,oe)=>e.jsx(re,{variant:"outline",className:"text-xs border-green-500/30 text-green-700",children:U},oe))})]})]})]})]})})]}),e.jsxs(Y,{children:[e.jsxs(ce,{className:"p-4 md:p-6 flex flex-row items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-rose-500/10",children:e.jsx(Ge,{className:"h-5 w-5 text-rose-500"})}),e.jsxs("div",{children:[e.jsx(le,{className:"text-lg",children:"Role Profiles"}),e.jsx(ct,{children:"Mentor, Investor, Jury, Speaker profiles"})]})]}),e.jsxs(ut,{open:D,onOpenChange:q,children:[e.jsx(cn,{asChild:!0,children:e.jsxs(R,{size:"sm",variant:"outline",children:[e.jsx(Ve,{className:"h-4 w-4 mr-2"}),"Add Role"]})}),e.jsxs(ht,{children:[e.jsx(mt,{children:e.jsx(ft,{children:"Create Role Profile"})}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs(xe,{value:F,onValueChange:K,children:[e.jsx(ve,{children:e.jsx(ge,{placeholder:"Select role type"})}),e.jsx(ye,{children:bl.filter(U=>!v.some(oe=>oe.role_type===U.value)).map(U=>e.jsx(J,{value:U.value,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(U.icon,{className:"h-4 w-4"}),U.label]})},U.value))})]}),e.jsxs(R,{onClick:ne,disabled:!F,className:"w-full",children:[e.jsx(Ve,{className:"h-4 w-4 mr-2"}),"Create Profile"]})]})]})]})]}),e.jsx(Z,{className:"p-4 md:p-6 pt-0",children:f?e.jsx("div",{className:"flex justify-center py-6",children:e.jsx(Qe,{size:24})}):v.length===0?e.jsxs("div",{className:"text-center py-6 text-muted-foreground",children:[e.jsx(Ge,{className:"h-10 w-10 mx-auto mb-3 opacity-30"}),e.jsx("p",{className:"text-sm",children:"No role profiles yet"})]}):e.jsx("div",{className:"space-y-4",children:v.map(U=>{const oe=Ae(U.role_type),Te=oe.icon,Xe=ED[U.role_type]||[],lt=p===U.id;return e
136.jsxs("div",{className:`border rounded-lg overflow-hidden ${oe.borderColor} ${U.status==="Pending"?"ring-2 ring-amber-400/50":""}`,children:[U.status==="Pending"&&!lt&&e.jsx("div",{className:"bg-gradient-to-r from-amber-50 to-orange-50 dark:from-amber-950/30 dark:to-orange-950/30 border-b border-amber-200 dark:border-amber-800 p-4",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"p-2 rounded-full bg-amber-100 dark:bg-amber-900/50",children:e.jsx($r,{className:"h-5 w-5 text-amber-600 dark:text-amber-400"})}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-amber-900 dark:text-amber-100",children:"Pending Approval"}),e.jsxs("p",{className:"text-sm text-amber-700 dark:text-amber-300",children:["This ",oe.label.toLowerCase()," profile is waiting for admin review"]})]})]}),e.jsxs("div",{className:"flex gap-2 w-full sm:w-auto",children:[e.jsxs(R,{size:"sm",variant:"outline",className:"flex-1 sm:flex-none border-red-200 text-red-700 hover:bg-red-50 hover:text-red-800 dark:border-red-800 dark:text-red-400 dark:hover:bg-red-950",onClick:()=>Re(U.id),children:[e.jsx(On,{className:"h-4 w-4 mr-1.5"}),"Reject"]}),e.jsxs(R,{size:"sm",className:"flex-1 sm:flex-none bg-green-600 hover:bg-green-700 text-white",onClick:()=>Ce(U.id),children:[e.jsx(Kr,{className:"h-4 w-4 mr-1.5"}),"Approve"]})]})]})}),e.jsxs("div",{className:`p-3 flex items-center justify-between ${oe.color}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Te,{className:"h-5 w-5"}),e.jsx("span",{className:"font-medium",children:oe.label}),e.jsxs(re,{variant:"outline",className:rs("text-xs",U.status==="Pending"&&"bg-amber-100 text-amber-800 border-amber-300 dark:bg-amber-900/50 dark:text-amber-300 dark:border-amber-700",U.status==="Live"&&"bg-green-100 text-green-800 border-green-300 dark:bg-green-900/50 dark:text-green-300 dark:border-green-700",U.status==="Draft"&&"bg-gray-100 text-gray-800 border-gray-300 dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600"),children:[U.status==="Pending"&&e.jsx($r,{className:"h-3 w-3 mr-1"}),U.status==="Live"&&e.jsx(Kr,{className:"h-3 w-3 mr-1"}),U.status]}),e.jsx(re,{variant:"outline",className:"text-xs bg-background/50",children:U.visibility})]}),e.jsx("div",{className:"flex gap-1",children:lt?e.jsxs(e.Fragment,{children:[e.jsx(R,{size:"sm",variant:"ghost",className:"h-7 px-2",onClick:()=>g(null),children:e.jsx(Pr,{className:"h-3 w-3"})}),e.jsx(R,{size:"sm",variant:"ghost",className:"h-7 px-2",onClick:()=>De(U.id),children:e.jsx(wa,{className:"h-3 w-3"})})]}):e.jsxs(e.Fragment,{children:[e.jsx(R,{size:"sm",variant:"ghost",className:"h-7 px-2",onClick:()=>fe(U),children:e.jsx(Tn,{className:"h-3 w-3"})}),e.jsx(R,{size:"sm",variant:"ghost",className:"h-7 px-2 text-destructive",onClick:()=>T(U.id),children:e.jsx(We,{className:"h-3 w-3"})})]})})]}),e.jsx("div",{className:"p-4",children:lt?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs",children:"Status"}),e.jsxs(xe,{value:O,onValueChange:Ze=>C(Ze),children:[e.jsx(ve,{className:"h-9",children:e.jsx(ge,{})}),e.jsxs(ye,{children:[e.jsx(J,{value:"Draft",children:"Draft"}),e.jsx(J,{value:"Pending",children:"Pending"}),e.jsx(J,{value:"Live",children:"Live"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs",children:"Visibility"}),e.jsxs(xe,{value:P,onValueChange:Ze=>$(Ze),children:[e.jsx(ve,{className:"h-9",children:e.jsx(ge,{})}),e.jsxs(ye,{children:[e.jsx(J,{value:"Private",children:"Private"}),e.jsx(J,{value:"Protected",children:"Protected"}),e.jsx(J,{value:"Public",children:"Public"})]})]})]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:Xe.map(Ze=>{var Ks;return e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs",children:Ze.label}),Ze.type==="array"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(de,{value:A[Ze.key]||"",onChange:yr=>I({...A,[Ze.key]:yr.target.value}),placeholder:`Add ${Ze.label.toLowerCase()}`,className:"h-9",onKeyPress:yr=>yr.key==="Enter"&&(yr.preventDefault(),ie(Ze.key))}),e.jsx(R,{type:"button",size:"sm",variant:"outline",onClick:()=>ie(Ze.key),children:e.jsx(Ve,{className:"h-3 w-3"})})]}),((Ks=N[Ze.key])==null?void 0:Ks.length)>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:N[Ze.key].map((yr,Qo)=>e.jsxs(re,{variant:"secondary",className:"text-xs gap-1",children:[yr,e.jsx(Pr,{className:"h-3 w-3 cursor-pointer",onClick:()=>Se(Ze.key,yr)})]},Qo))})]}
136):e.jsx(de,{value:N[Ze.key]||"",onChange:yr=>S({...N,[Ze.key]:yr.target.value}),className:"h-9"})]},Ze.key)})})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:Xe.map(Ze=>e.jsxs("div",{children:[e.jsx("span",{className:"text-xs text-muted-foreground block mb-1",children:Ze.label}),Ze.type==="array"?e.jsx(Pe,{items:U.role_data[Ze.key]}):e.jsx("span",{className:"text-sm",children:U.role_data[Ze.key]||"—"})]},Ze.key))})})]},U.id)})})})]})]}):e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx(Qe,{size:32})})},$D=["visitor","attendee","startup","mentor","corporate","investor","speaker","program_manager","jury_member","location"],DD=["pending","accepted","rejected"],MD=({userId:t})=>{const[r,n]=_.useState([]),[a,s]=_.useState([]),[i,o]=_.useState(!1),[l,c]=_.useState(""),[u,d]=_.useState(""),[h,m]=_.useState("accepted");_.useEffect(()=>{j(),w()},[t]);const j=async()=>{try{const{data:f,error:b}=await k.from("user_roles").select(`
137          id,
138          role,
139          status,
140          event_id,
141          events (title)
142        `).eq("user_id",t).order("created_at",{ascending:!1});if(b)throw b;n(f||[])}catch(f){console.error("Error fetching roles:",f),W.error("Failed to load event roles")}},w=async()=>{try{const{data:f,error:b}=await k.from("events").select("id, title").order("title");if(b)throw b;s(f||[])}catch(f){console.error("Error fetching events:",f)}},x=async()=>{if(!l||!u){W.error("Please select an event and role");return}try{const{error:f}=await k.from("user_roles").insert([{user_id:t,event_id:l,role:u,status:h}]);if(f)throw f;W.success("Role added successfully"),o(!1),c(""),d(""),m("accepted"),j()}catch(f){console.error("Error adding role:",f),(f==null?void 0:f.code)==="23505"?W.error("User already has this role for this event"):W.error("Failed to add role")}},v=async f=>{if(confirm("Are you sure you want to remove this role?"))try{const{error:b}=await k.from("user_roles").delete().eq("id",f);if(b)throw b;W.success("Role removed successfully"),j()}catch(b){console.error("Error removing role:",b),W.error("Failed to remove role")}},y=f=>({pending:"bg-yellow-100 text-yellow-800 border-yellow-200",accepted:"bg-green-100 text-green-800 border-green-200",rejected:"bg-red-100 text-red-800 border-red-200"})[f]||"bg-gray-100 text-gray-800 border-gray-200";return e.jsxs(Y,{children:[e.jsx(ce,{className:"p-4 md:p-6",children:e.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-center gap-3",children:[e.jsxs("div",{children:[e.jsx(le,{className:"text-lg md:text-xl",children:"Event Roles"}),e.jsx(ct,{className:"text-sm",children:"Manage user roles for specific events"})]}),e.jsxs(R,{onClick:()=>o(!0),size:"sm",className:"w-full md:w-auto",children:[e.jsx(Ve,{className:"h-3 w-3 md:h-4 md:w-4 mr-2"}),e.jsx("span",{className:"text-sm",children:"Add Role"})]})]})}),e.jsx(Z,{className:"p-4 md:p-6",children:e.jsx("div",{className:"overflow-x-auto -mx-4 md:mx-0",children:e.jsxs(nt,{children:[e.jsx(at,{children:e.jsxs(pe,{children:[e.jsx(te,{className:"text-xs md:text-sm",children:"Event"}),e.jsx(te,{className:"text-xs md:text-sm",children:"Role"}),e.jsx(te,{className:"text-xs md:text-sm",children:"Status"}),e.jsx(te,{className:"text-right text-xs md:text-sm",children:"Actions"})]})}),e.jsxs(st,{children:[r.map(f=>{var b;return e.jsxs(pe,{children:[e.jsx(X,{className:"font-medium text-xs md:text-sm",children:((b=f.events)==null?void 0:b.title)||"Unknown Event"}),e.jsx(X,{children:e.jsx(re,{variant:"outline",className:"text-xs",children:f.role.replace("_"," ")})}),e.jsx(X,{children:e.jsx(re,{className:y(f.status)+" text-xs",children:f.status})}),e.jsx(X,{className:"text-right",children:e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>v(f.id),children:e.jsx(We,{className:"h-3 w-3 md:h-4 md:w-4"})})})]},f.id)}),r.length===0&&e.jsx(pe,{children:e.jsx(X,{colSpan:4,className:"text-center text-muted-foreground text-xs md:text-sm py-8",children:"No event roles assigned yet."})})]})]})})}),e.jsx(ut,{open:i,onOpenChange:o,children:e.jsxs(ht,{children:[e.jsxs(mt,{children:[e.jsx(ft,{children:"Add Event Role"}),e.jsx($t,{children:"Assign a role to this user for a specific event"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"event",children:"Event"}),e.jsxs(xe,{value:l,onValueChange:c,children:[e.jsx(ve,{children:e.jsx(ge,{placeholder:"Select an event"})}),e.jsx(ye,{children:a.map(f=>e.jsx(J,{value:f.id,children:f.title},f.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"role",children:"Role"}),e.jsxs(xe,{value:u,onValueChange:d,children:[e.jsx(ve,{children:e.jsx(ge,{placeholder:"Select a role"})}),e.jsx(ye,{children:$D.map(f=>e.jsx(J,{value:f,children:f.replace("_"," ")},f))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"status",children:"Status"}),e.jsxs(xe,{value:h,onValueChange:m,children:[e.jsx(ve,{children:e.jsx(ge,{})}),e.jsx(ye,{children:DD.map(f=>e.jsx(J,{value:f,children:f},f))})]})]})]}),e.jsxs(Vt,{children:[e.jsx(R,{type:"button",variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(R,{onClick:x,children:"Add Role"})]})]})})]})},zm=[{value:"event_crew",label:"Event Crew"},{value:"team_coordinator",label:"Team Coordinator"},{value:"chapter_lead",label:"Chapter Lead"},{value:"regional_lead",label:"Regional Lead"},{value:"global_team",label:"Global Team"}],ID=({userId:t})=>{const[r,n]=_.useState([]),[a,s]=_.useState([]),[i,o]=_.useState(!1),[l,c]=_.useState(""),[u,d]=_.useState("");_.useEffect(()=>{h(),m()},[t]);const h=async()=>{try{const{data:v,error:y}=await k.from("chapter_members").select(`
143          id,
144          role,
145          created_at,
146          chapters (id, name)
147        `).eq("user_id",t).order("created_at",{ascending:!1});if(y)throw y;n(v||[])}catch(v){console.error("Error fetching chapter memberships:",v),W.error("Failed to load chapters")}},m=async()=>{try{const{data:v,error:y}=await k.from("chapters").select("id, name").order("name");if(y)throw y;s(v||[])}catch(v){console.error("Error fetching chapters:",v)}},j=async()=>
147{if(!l||!u){W.error("Please select a chapter and role");return}try{const{error:v}=await k.from("chapter_members").insert([{user_id:t,chapter_id:l,role:u}]);if(v)throw v;W.success("Chapter membership added successfully"),o(!1),c(""),d(""),h()}catch(v){console.error("Error adding membership:",v),(v==null?void 0:v.code)==="23505"?W.error("User already has this role in this chapter"):W.error("Failed to add chapter membership")}},w=async v=>{if(confirm("Are you sure you want to remove this chapter membership?"))try{const{error:y}=await k.from("chapter_members").delete().eq("id",v);if(y)throw y;W.success("Chapter membership removed successfully"),h()}catch(y){console.error("Error removing membership:",y),W.error("Failed to remove chapter membership")}},x=v=>{var y;return((y=zm.find(f=>f.value===v))==null?void 0:y.label)||v};return e.jsxs(Y,{children:[e.jsx(ce,{className:"p-4 md:p-6",children:e.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-center gap-3",children:[e.jsxs("div",{children:[e.jsx(le,{className:"text-lg md:text-xl",children:"Chapter Memberships"}),e.jsx(ct,{className:"text-sm",children:"Manage user's chapter assignments and roles"})]}),e.jsxs(R,{onClick:()=>o(!0),size:"sm",className:"w-full md:w-auto",children:[e.jsx(Ve,{className:"h-3 w-3 md:h-4 md:w-4 mr-2"}),e.jsx("span",{className:"text-sm",children:"Add Chapter"})]})]})}),e.jsx(Z,{className:"p-4 md:p-6",children:e.jsx("div",{className:"overflow-x-auto -mx-4 md:mx-0",children:e.jsxs(nt,{children:[e.jsx(at,{children:e.jsxs(pe,{children:[e.jsx(te,{className:"text-xs md:text-sm",children:"Chapter"}),e.jsx(te,{className:"text-xs md:text-sm",children:"Role"}),e.jsx(te,{className:"text-xs md:text-sm",children:"Added"}),e.jsx(te,{className:"text-right text-xs md:text-sm",children:"Actions"})]})}),e.jsxs(st,{children:[r.map(v=>{var y;return e.jsxs(pe,{children:[e.jsx(X,{className:"font-medium text-xs md:text-sm",children:((y=v.chapters)==null?void 0:y.name)||"Unknown Chapter"}),e.jsx(X,{children:e.jsx(re,{variant:"outline",className:"text-xs",children:x(v.role)})}),e.jsx(X,{className:"text-xs md:text-sm",children:new Date(v.created_at).toLocaleDateString()}),e.jsx(X,{className:"text-right",children:e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>w(v.id),children:e.jsx(We,{className:"h-3 w-3 md:h-4 md:w-4"})})})]},v.id)}),r.length===0&&e.jsx(pe,{children:e.jsx(X,{colSpan:4,className:"text-center text-muted-foreground text-xs md:text-sm py-8",children:"No chapter memberships yet."})})]})]})})}),e.jsx(ut,{open:i,onOpenChange:o,children:e.jsxs(ht,{children:[e.jsxs(mt,{children:[e.jsx(ft,{children:"Add Chapter Membership"}),e.jsx($t,{children:"Assign this user to a chapter with a specific role"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"chapter",children:"Chapter"}),e.jsxs(xe,{value:l,onValueChange:c,children:[e.jsx(ve,{children:e.jsx(ge,{placeholder:"Select a chapter"})}),e.jsx(ye,{children:a.map(v=>e.jsx(J,{value:v.id,children:v.name},v.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"role",children:"Role"}),e.jsxs(xe,{value:u,onValueChange:d,children:[e.jsx(ve,{children:e.jsx(ge,{placeholder:"Select a role"})}),e.jsx(ye,{children:zm.map(v=>e.jsx(J,{value:v.value,children:v.label},v.value))})]})]})]}),e.jsxs(Vt,{children:[e.jsx(R,{type:"button",variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(R,{onClick:j,children:"Add Membership"})]})]})})]})},Um=[{value:"guest",label:"Guest",description:"Limited access to public content"},{value:"member",label:"Member",description:"Access to member-only content and events"},{value:"admin",label:"Admin",description:"Full system access and management capabilities"}],qm=t=>{switch(t){case"active":return"default";case"trialing":return"secondary";case"cancelled":return"outline";case"past_due":return"destructive";case"expired":return"outline";default:return"outline"}},LD=({user:t,onUpdate:r})=>{var N,S;const[n,a]=_.useState(t.membership_level),[s,i]=_.useState(t.is_active??!0),[o,l]=_.useState(!1),[c,u]=_.useState(!1),[d,h]=_.useState([]),[m,j]=_.useState([]),[w,x]=_.useState(!0);_.useEffect(()=>
147{v()},[t.user_id]);const v=async()=>{try{x(!0);const{data:O,error:C}=await k.from("user_subscriptions").select(`
148          id,
149          status,
150          current_period_start,
151          current_period_end,
152          cancel_at_period_end,
153          trial_code_id,
154          plan_id
155        `).eq("user_id",t.user_id).order("created_at",{ascending:!1});if(C)throw C;let P={};if(O&&O.length>0){const F=[...new Set(O.map(K=>K.plan_id).filter(Boolean))];if(F.length>0){const{data:K}=await k.from("membership_plans").select("id, name, price_cents, currency, interval").in("id",F);K&&(P=Object.fromEntries(K.map(M=>[M.id,M])))}}let $={};if(O&&O.length>0){const F=[...new Set(O.map(K=>K.trial_code_id).filter(Boolean))];if(F.length>0){const{data:K}=await k.from("trial_codes").select("id, code, trial_days").in("id",F);K&&($=Object.fromEntries(K.map(M=>[M.id,M])))}}if(C)throw C;const A=(O==null?void 0:O.map(F=>({id:F.id,status:F.status,current_period_start:F.current_period_start,current_period_end:F.current_period_end,cancel_at_period_end:F.cancel_at_period_end,plan:F.plan_id?P[F.plan_id]:null,trial_code:F.trial_code_id?$[F.trial_code_id]:null})))||[];h(A);const{data:I,error:D}=await k.from("trial_code_redemptions").select(`
156          id,
157          redeemed_at,
158          trial_codes (
159            code,
160            trial_days,
161            membership_plans (
162              name
163            )
164          )
165        `).eq("user_id",t.user_id).order("redeemed_at",{ascending:!1});if(D)throw D;const q=(I==null?void 0:I.map(F=>{var K,M,E;return{id:F.id,redeemed_at:F.redeemed_at,trial_code:{code:(K=F.trial_codes)==null?void 0:K.code,trial_days:(M=F.trial_codes)==null?void 0:M.trial_days,plan:(E=F.trial_codes)==null?void 0:E.membership_plans}}}))||[];j(q)}catch(O){console.error("Error fetching subscription data:",O)}finally{x(!1)}},y=async()=>{if(n===t.membership_level){W.info("No changes to save");return}l(!0);try{const{error:O}=await k.from("profiles").update({membership_level:n}).eq("user_id",t.user_id);if(O)throw O;W.success("Membership level updated successfully"),r()}catch(O){console.error("Error updating membership:",O),W.error("Failed to update membership level")}finally{l(!1)}},f=async()=>{u(!0);const O=!s;try{const{error:C}=await k.from("profiles").update({is_active:O}).eq("user_id",t.user_id);if(C)throw C;i(O),W.success(O?"User activated successfully":"User deactivated successfully"),r()}catch(C){console.error("Error toggling user status:",C),W.error("Failed to update user status")}finally{u(!1)}},b=Um.find(O=>O.value===n),p=d.find(O=>O.status==="active"||O.status==="trialing"),g=(O,C)=>new Intl.NumberFormat("en-US",{style:"currency",currency:C.toUpperCase()}).format(O/100);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Y,{className:p?"border-emerald-500/50 bg-emerald-50/50 dark:bg-emerald-950/20":"border-muted",children:[e.jsxs(ce,{className:"p-4 md:p-6",children:[e.jsx(le,{className:"text-lg md:text-xl flex items-center gap-2",children:p?e.jsxs(e.Fragment,{children:[e.jsx(Cn,{className:"h-5 w-5 text-emerald-600"}),e.jsx("span",{className:"text-emerald-700 dark:text-emerald-400",children:"Subscribed"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ka,{className:"h-5 w-5 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"No Active Subscription"})]})}),e.jsx(ct,{className:"text-sm",children:p?"User has an active paid membership subscription":"This user does not have an active subscription"})]}),e.jsx(Z,{className:"space-y-4 p-4 md:p-6",children:p?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Plan"}),e.jsx("p",{className:"font-semibold",children:((N=p.plan)==null?void 0:N.name)||"Unknown"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Status"}),e.jsx(re,{variant:qm(p.status),children:p.status})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Price"}),e.jsxs("p",{className:"font-semibold",children:[p.plan?g(p.plan.price_cents,p.plan.currency):"-",((S=p.plan)==null?void 0:S.interval)&&`/${p.plan.interval}`]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Paid Until"}),e.jsx("p",{className:"font-semibold text-emerald-700 dark:text-emerald-400",children:Et(new Date(p.current_period_end),"MMM d, yyyy")})]})]}),p.trial_code&&e.jsxs("div",{className:"flex items-center gap-2 text-sm bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800 p-3 rounded-lg",children:[e.jsx(_r,{className:"h-4 w-4 text-amber-600"}),e.jsxs("span",{children:["Started with trial code: ",e.jsx("code",{className:"font-mono bg-background px-1.5 py-0.5 rounded text-amber-700 dark:text-amber-400",children:p.trial_code.code}),e.jsxs("span",{className:"text-muted-foreground ml-2",children:["(",p.tri
165al_code.trial_days," days trial)"]})]})]}),p.cancel_at_period_end&&e.jsxs(tl,{variant:"destructive",children:[e.jsx(Jo,{className:"h-4 w-4"}),e.jsxs(rl,{children:["Subscription will cancel at period end (",Et(new Date(p.current_period_end),"MMM d, yyyy"),")"]})]})]}):e.jsx("div",{className:"text-center py-4",children:e.jsx("p",{className:"text-muted-foreground",children:d.length>0?"User had previous subscriptions but none are currently active.":"User has never subscribed to a paid plan."})})})]}),d.length>0&&e.jsxs(Y,{children:[e.jsxs(ce,{className:"p-4 md:p-6",children:[e.jsxs(le,{className:"text-lg md:text-xl flex items-center gap-2",children:[e.jsx(Ka,{className:"h-5 w-5"}),"Subscription History"]}),e.jsx(ct,{className:"text-sm",children:"All past and current subscriptions for this user"})]}),e.jsx(Z,{className:"p-4 md:p-6",children:e.jsxs(nt,{children:[e.jsx(at,{children:e.jsxs(pe,{children:[e.jsx(te,{children:"Plan"}),e.jsx(te,{children:"Status"}),e.jsx(te,{children:"Period"}),e.jsx(te,{children:"Trial Code"})]})}),e.jsx(st,{children:d.map(O=>{var C;return e.jsxs(pe,{children:[e.jsx(X,{className:"font-medium",children:((C=O.plan)==null?void 0:C.name)||"Unknown"}),e.jsx(X,{children:e.jsx(re,{variant:qm(O.status),children:O.status})}),e.jsxs(X,{className:"text-sm text-muted-foreground",children:[Et(new Date(O.current_period_start),"MMM d")," - ",Et(new Date(O.current_period_end),"MMM d, yyyy")]}),e.jsx(X,{children:O.trial_code?e.jsx("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:O.trial_code.code}):e.jsx("span",{className:"text-muted-foreground",children:"-"})})]},O.id)})})]})})]}),m.length>0&&e.jsxs(Y,{children:[e.jsxs(ce,{className:"p-4 md:p-6",children:[e.jsxs(le,{className:"text-lg md:text-xl flex items-center gap-2",children:[e.jsx(_r,{className:"h-5 w-5"}),"Trial Code Redemptions"]}),e.jsx(ct,{className:"text-sm",children:"Trial codes this user has redeemed"})]}),e.jsx(Z,{className:"p-4 md:p-6",children:e.jsxs(nt,{children:[e.jsx(at,{children:e.jsxs(pe,{children:[e.jsx(te,{children:"Code"}),e.jsx(te,{children:"Plan"}),e.jsx(te,{children:"Trial Days"}),e.jsx(te,{children:"Redeemed"})]})}),e.jsx(st,{children:m.map(O=>{var C;return e.jsxs(pe,{children:[e.jsx(X,{children:e.jsx("code",{className:"font-mono bg-muted px-1 py-0.5 rounded",children:O.trial_code.code})}),e.jsx(X,{children:((C=O.trial_code.plan)==null?void 0:C.name)||"Unknown"}),e.jsxs(X,{children:[O.trial_code.trial_days," days"]}),e.jsx(X,{className:"text-sm text-muted-foreground",children:Et(new Date(O.redeemed_at),"MMM d, yyyy")})]},O.id)})})]})})]}),e.jsxs(Y,{children:[e.jsxs(ce,{className:"p-4 md:p-6",children:[e.jsxs(le,{className:"text-lg md:text-xl flex items-center gap-2",children:[s?e.jsx(pf,{className:"h-5 w-5 text-green-500"}):e.jsx(oy,{className:"h-5 w-5 text-destructive"}),"Account Status"]}),e.jsx(ct,{className:"text-sm",children:"Control whether this user can access the system"})]}),e.jsxs(Z,{className:"space-y-4 p-4 md:p-6",children:[e.jsxs(tl,{variant:s?"default":"destructive",children:[e.jsx(Jo,{className:"h-4 w-4 flex-shrink-0"}),e.jsx(rl,{className:"text-xs md:text-sm",children:s?"This user account is active and can access the system normally.":"This user account is deactivated. They cannot access the system until reactivated."})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-muted rounded-lg",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{htmlFor:"user-status",className:"text-sm font-medium",children:s?"Account Active":"Account Deactivated"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s?"Toggle to deactivate this user":"Toggle to reactivate this user"})]}),e.jsx(Tt,{id:"user-status",checked:s,onCheckedChange:f,disabled:c})]})]})]}),e.jsxs(Y,{children:[e.jsxs(ce,{className:"p-4 md:p-6",children:[e.jsx(le,{className:"text-lg md:text-xl",children:"System Access Level"}),e.jsx(ct,{className:"text-sm",children:"Manage user's system access permissions (separate from paid subscription)"})]}),e.jsxs(Z,{className:"space-y-4 md:space-y-6 p-4 md:p-6",children:[e.jsxs(tl,{children:[e.jsx(Jo,{className:"h-4 w-4 flex-shrink-0"}),e.jsx(rl,{className:"text-xs md:text-sm",children:"Changing access level affects the user's access to system features. Admin level grants full access to all administrative functions."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"membership",className:"text-sm",children:"Access Level"}),e.jsxs(xe,{value:n,onValueChange:a,children:[e.jsx(ve,{className:"text-sm md:text-base",children:e.jsx(ge,{})}),e.jsx(ye,{children:Um.map(O=>e.jsx(J,{value:O.value,children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:O.label}),e.jsx("div",{className:"text-xs text-muted-foreground",children:O.description})]})},O.value))})]})]}),b&&e.jsxs("div",{className:"p-3 md:p-4 bg-muted rounded-lg",children:[e.jsx("h4",{className:"font-medium mb-1 md:mb-2 text-sm md:text-base",children:b.label}),e.jsx("p",{className:"text-xs md:text-sm text-muted-foreground",children:b.description})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(R,{onClick:y,disabled:o||n===t.membership_level,size:"sm",className:"w-full md:w-auto",children:[e.jsx(wa,{className:"h-3 w-3 md:h-4 md:w-4 mr-2"}),e.jsx("span",{className:"text-sm",children:"Save Changes"})]})})]})]})]})},RD=({userId:t,userEmail:r})=>{const[n,a]=_.useState([]),[s,i]=_.useState([]),[o,l]=_.useState(!0),[c,u]=_.useState(!1),[d,h]=_.useState([]);_.useEffect(()=>{m()},[t]);const m=async()=>{try{l(!0);const{data:f,error:b}=await k.from("newsletter_user_lists").select(`
166          id,
167          list_id,
168          subscribed_at,
169          newsletter_lists (
170            id,
171            name,
172            description,
173            list_type
174          )
175        `).eq("user_id",t);if(b)throw b;const{data:p,error:g}=await k.from("newsletter_lists").select("id, name, description, list_type").order("name");if(g)throw g;a(f||[]),i(p||[])}catch(f){console.error("Error fetching newsletter data:",f),W.error("Failed to load newsletter subscriptions")}finally{l(!1)}},j=async()=>
175{if(d.length===0){W.error("Please select at least one list");return}try{const f=d.map(p=>({user_id:t,list_id:p})),{error:b}=await k.from("newsletter_user_lists").insert(f);if(b)throw b;W.success(`Added to ${d.length} list(s)`),u(!1),h([]),m()}catch(f){console.error("Error adding subscriptions:",f),W.error("Failed to add subscriptions")}},w=async(f,b)=>{try{const{error:p}=await k.from("newsletter_user_lists").delete().eq("id",f);if(p)throw p;W.success(`Removed from ${b}`),m()}catch(p){console.error("Error removing subscription:",p),W.error("Failed to remove subscription")}},x=f=>{h(b=>b.includes(f)?b.filter(p=>p!==f):[...b,f])},v=f=>{const b={public:"bg-green-100 text-green-800",member:"bg-blue-100 text-blue-800",private:"bg-gray-100 text-gray-800"};return b[f]||b.public},y=s.filter(f=>!n.some(b=>b.list_id===f.id));return o?e.jsx(Y,{children:e.jsx(Z,{className:"p-6",children:e.jsx("p",{className:"text-muted-foreground",children:"Loading newsletter subscriptions..."})})}):e.jsx("div",{className:"space-y-6",children:e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(le,{className:"flex items-center gap-2",children:[e.jsx(St,{className:"h-5 w-5"}),"Newsletter Subscriptions"]}),e.jsxs(ct,{className:"mt-2",children:["Manage user's newsletter list subscriptions for ",r]})]}),e.jsxs(ut,{open:c,onOpenChange:u,children:[e.jsx(cn,{asChild:!0,children:e.jsxs(R,{children:[e.jsx(Ve,{className:"h-4 w-4 mr-2"}),"Add to Lists"]})}),e.jsxs(ht,{className:"max-w-2xl",children:[e.jsxs(mt,{children:[e.jsx(ft,{children:"Add to Newsletter Lists"}),e.jsx($t,{children:"Select newsletter lists to subscribe this user to"})]}),e.jsx("div",{className:"max-h-96 overflow-y-auto",children:y.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No available lists to add"}):e.jsx("div",{className:"space-y-3",children:y.map(f=>e.jsxs("div",{className:"flex items-start space-x-3 p-3 border rounded-lg hover:bg-muted/50 cursor-pointer",onClick:()=>x(f.id),children:[e.jsx(fo,{checked:d.includes(f.id),onCheckedChange:()=>x(f.id)}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium",children:f.name}),e.jsx(re,{className:v(f.list_type),children:f.list_type})]}),f.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:f.description})]})]},f.id))})}),e.jsxs(Vt,{children:[e.jsx(R,{variant:"outline",onClick:()=>u(!1),children:"Cancel"}),e.jsxs(R,{onClick:j,disabled:d.length===0,children:["Add to ",d.length," List",d.length!==1?"s":""]})]})]})]})]})}),e.jsx(Z,{children:n.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(St,{className:"h-12 w-12 text-muted-foreground mx-auto mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"This user is not subscribed to any newsletter lists"}),e.jsxs(R,{variant:"outline",className:"mt-4",onClick:()=>u(!0),children:[e.jsx(Ve,{className:"h-4 w-4 mr-2"}),"Add to Lists"]})]}):e.jsxs(nt,{children:[e.jsx(at,{children:e.jsxs(pe,{children:[e.jsx(te,{children:"List Name"}),e.jsx(te,{children:"Type"}),e.jsx(te,{children:"Description"}),e.jsx(te,{children:"Subscribed"}),e.jsx(te,{className:"text-right",children:"Actions"})]})}),e.jsx(st,{children:n.map(f=>e.jsxs(pe,{children:[e.jsx(X,{className:"font-medium",children:f.newsletter_lists.name}),e.jsx(X,{children:e.jsx(re,{className:v(f.newsletter_lists.list_type),children:f.newsletter_lists.list_type})}),e.jsx(X,{className:"text-muted-foreground",children:f.newsletter_lists.description||"—"}),e.jsx(X,{children:new Date(f.subscribed_at).toLocaleDateString()}),e.jsx(X,{className:"text-right",children:e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>w(f.id,f.newsletter_lists.name),children:e.jsx(We,{className:"h-4 w-4"})})})]},f.id))})]})})]})})},FD=({userId:t})=>{const[r,n]=_.useState([]),[a,s]=_.useState(!0),i=gt();_.useEffect(()=>{o()},[t]);const o=async()=>{try{const{data:l}=await k.from("profiles").select("id").eq("user_id",t).single();if(!l){n([]);return}const{data:c,error:u}=await k.from("company_members").select(`
176          id, role, position, is_primary, start_date, end_date,
177          companies:company_id (id, name, slug, logo, company_type, industry, status)
178        `).eq("profile_id",l.id);if(u)throw u;const d=(c||[]).filter(h=>h.companies!=null).map(h=>({id:h.id,role:h.role,position:h.position,is_primary:h.is_primary,start_date:h.start_date,end_date:h.end_date,company:h.companies}));n(d)}catch(l){console.error("Error fetching company memberships:",l)}finally{s(!1)}};return a?e.jsx("div",{className:"flex justify-center p-8",children:e.jsx(Qe,{size:32})}):r.length===0?e.jsxs(Y,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(It,{className:"h-10 w-10 mx-auto mb-3 opacity-40"}
178),e.jsx("p",{children:"No company associations found for this user."})]}):e.jsx("div",{className:"space-y-3",children:r.map(l=>e.jsx(Y,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-4",children:[l.company.logo?e.jsx("img",{src:l.company.logo,alt:l.company.name,className:"h-12 w-12 rounded-lg object-contain border bg-background"}):e.jsx("div",{className:"h-12 w-12 rounded-lg bg-muted flex items-center justify-center",children:e.jsx(It,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h3",{className:"font-semibold truncate",children:l.company.name}),l.is_primary&&e.jsx(re,{variant:"default",className:"text-[10px]",children:"Primary"}),e.jsx(re,{variant:"outline",className:"capitalize text-[10px]",children:l.role}),l.company.status==="Draft"&&e.jsx(re,{variant:"destructive",className:"text-[10px]",children:"Draft"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l.position}),e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground",children:[l.company.company_type&&e.jsx("span",{className:"capitalize",children:l.company.company_type}),l.company.industry&&l.company.industry.length>0&&e.jsx("span",{children:l.company.industry.slice(0,3).join(", ")}),l.start_date&&e.jsxs("span",{children:["Since ",new Date(l.start_date).toLocaleDateString()]})]})]}),e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>i(`/dashboard/admin/companies/${l.company.id}`),children:e.jsx(Zt,{className:"h-4 w-4"})})]})},l.id))})},BD=()=>{const{userId:t}=Zr(),r=gt(),[n,a]=_.useState(null),[s,i]=_.useState(!0),[o,l]=_.useState("profile"),[c,u]=_.useState(!1),d=_.useRef(null);_.useEffect(()=>{t&&h()},[t]);const h=async()=>{try{const{data:x,error:v}=await k.from("profiles").select("*").eq("user_id",t).single();if(v)throw v;a(x)}catch(x){console.error("Error fetching user:",x),W.error("Failed to load user data")}finally{i(!1)}},m=async x=>{var b;const v=(b=x.target.files)==null?void 0:b[0];if(!v||!n)return;const y=Vg(v);if(y){W.error(y);return}const f=Wg(v,5);if(f){W.error(f);return}u(!0);try{const p=v.name.split(".").pop(),g=`${Date.now()}.${p}`,N=`${n.user_id}/${g}`;if(n.avatar_url&&n.avatar_url.includes(n.user_id)){const P=n.avatar_url.split("/"),$=P.findIndex(A=>A==="avatars");if($!==-1){const A=P.slice($+1).join("/");await k.storage.from("avatars").remove([A])}}const{error:S}=await k.storage.from("avatars").upload(N,v,{upsert:!0});if(S)throw S;const{data:{publicUrl:O}}=k.storage.from("avatars").getPublicUrl(N),{error:C}=await k.from("profiles").update({avatar_url:O}
178).eq("user_id",n.user_id);if(C)throw C;a(P=>P&&{...P,avatar_url:O}),W.success("Profile picture updated")}catch(p){console.error("Avatar upload error:",p),W.error("Failed to upload profile picture")}finally{u(!1),d.current&&(d.current.value="")}},j=x=>x.split(" ").map(v=>v[0]).join("").toUpperCase().slice(0,2),w=x=>{const v={admin:"bg-red-100 text-red-800 border-red-200",member:"bg-blue-100 text-blue-800 border-blue-200",guest:"bg-gray-100 text-gray-800 border-gray-200"};return v[x]||v.guest};return s?e.jsx("div",{className:"flex items-center justify-center p-12",children:e.jsx(Qe,{size:48})}):n?e.jsxs("div",{className:"p-3 md:p-6 space-y-4 md:space-y-6",children:[e.jsx("div",{className:"flex items-center gap-2 md:gap-4",children:e.jsxs(R,{variant:"ghost",size:"sm",onClick:()=>r("/dashboard/admin/users"),className:"h-9 md:h-10",children:[e.jsx(Bt,{className:"h-4 w-4 md:mr-2"}),e.jsx("span",{className:"hidden md:inline",children:"Back to Users"})]})}),e.jsx(Y,{className:"overflow-hidden",children:e.jsx("div",{className:"bg-gradient-to-r from-primary/10 via-primary/5 to-transparent p-4 md:p-6",children:e.jsxs("div",{className:"flex flex-col md:flex-row items-start gap-4 md:gap-6",children:[e.jsxs("div",{className:"relative group cursor-pointer",onClick:()=>{var x;return(x=d.current)==null?void 0:x.click()},title:"Click to change profile picture",children:[e.jsxs(Dr,{className:"h-20 w-20 md:h-24 md:w-24 ring-4 ring-background shadow-lg",children:[e.jsx(Mr,{src:n.avatar_url,alt:n.name}),e.jsx(Ir,{className:"text-xl md:text-2xl bg-primary text-primary-foreground",children:j(n.name)})]}),e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center rounded-full opacity-0 group-hover:opacity-100 transition-opacity",children:c?e.jsx(At,{className:"h-6 w-6 text-white animate-spin"}):e.jsx(Hg,{className:"h-6 w-6 text-white"})}),e.jsx("input",{ref:d,type:"file",accept:qg,onChange:m,className:"hidden",disabled:c})]}),e.jsxs("div",{className:"flex-1 text-center md:text-left w-full",children:[e.jsxs("div",{className:"flex flex-col md:flex-row items-center md:items-start gap-2 md:gap-3 mb-2",children:[e.jsx("h1",{className:"text-2xl md:text-3xl font-bold",children:n.name}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(re,{className:w(n.membership_level),children:n.membership_level.charAt(0).toUpperCase()+n.membership_level.slice(1)}),n.is_active?e.jsxs(re,{variant:"outline",className:"bg-green-50 text-green-700 border-green-200",children:[e.jsx(Kr,{className:"h-3 w-3 mr-1"}),"Active"]}):e.jsxs(re,{variant:"outline",className:"bg-red-50 text-red-700 border-red-200",children:[e.jsx(On,{className:"h-3 w-3 mr-1"}),"Inactive"]})]})]}),e.jsx("p",{className:"text-sm md:text-base text-muted-foreground mb-3",children:n.email}),e.jsxs("div",{className:"flex flex-wrap justify-center md:justify-start gap-4 text-xs md:text-sm text-muted-foreground mb-4",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-foreground",children:"Joined:"})," ",new Date(n.created_at).toLocaleDateString()]}),e.jsxs("div",{className:"font-mono text-[10px] md:text-xs opacity-60",children:["ID: ",n.user_id.slice(0,8),"..."]})]}),e.jsxs(R,{size:"sm",className:"gap-2 w-full md:w-auto",onClick:()=>{window.openConversationWithUser&&window.openConversationWithUser(n.user_id)},children:[e.jsx(sn,{className:"h-4 w-4"}),e.jsx("span",{children:"Message User"})]})]})]})})}),e.jsxs(zr,{value:o,onValueChange:l,className:"space-y-4 md:space-y-6",children:[e.jsx("div",{className:"w-full overflow-x-auto",children:e.jsxs(Ur,{className:"inline-flex w-auto min-w-full md:grid md:w-full md:grid-cols-6 gap-1 h-auto",children:[e.jsxs(Be,{value:"profile",className:"flex items-center gap-1 md:gap-2 text-xs md:text-sm px-3 md:px-4 whitespace-nowrap",children:[e.jsx(ln,{className:"h-3 w-3 md:h-4 md:w-4 flex-shrink-0"}),e.jsx("span",{children:"Profile"})]}),e.jsxs(Be,{value:"event-roles",className:"flex items-center gap-1 md:gap-2 text-xs md:text-sm px-3 md:px-4 whitespace-nowrap",children:[e.jsx(ns,{className:"h-3 w-3 md:h-4 md:w-4 flex-shrink-0"}),e.jsx("span",{children:"Roles"})]}),e.jsxs(Be,{value:"chapters",className:"flex items-center gap-1 md:gap-2 text-xs md:text-sm px-3 md:px-4 whitespace-nowrap",children:[e.jsx(It,{className:"h-3 w-3 md:h-4 md:w-4 flex-shrink-0"}),e.jsx("span",{children:"Chapters"})]}),e.jsxs(Be,{value:"newsletter",className:"flex items-center gap-1 md:gap-2 text-xs md:text-sm px-3 md:px-4 whitespace-nowrap",children:[e.jsx(St,{className:"h-3 w-3 md:h-4 md:w-4 flex-shrink-0"}),e.jsx("span",{children:"Newsletter"})]}),e.jsxs(Be,{value:"companies",className:"flex items-center gap-1 md:gap-2 text-xs md:text-sm px-3 md:px-4 whitespace-nowrap",children:[e.jsx(It,{className:"h-3 w-3 md:h-4 md:w-4 flex-shrink-0"}),e.jsx("span",{children:"Companies"})]}),e.jsxs(Be,{value:"membership",className:"flex items-center gap-1 md:gap-2 text-xs md:text-sm px-3 md:px-4 whitespace-nowrap",children:[e.jsx(Cn,{className:"h-3 w-3 md:h-4 md:w-4 flex-shrink-0"}),e.jsx("span",{children:"Membership"})]})]})}),e.jsx(ze,{value:"profile",children:e.jsx(TD,{user:n,onUpdate:h})}),e.jsx(ze,{value:"event-roles",children:e.jsx(MD,{userId:n.user_id})}),e.jsx(ze,{value:"chapters",children:e.jsx(ID,{userId:n.user_id})}),e.jsx(ze,{value:"newsletter",children:e.jsx(RD,{userId:n.user_id,userEmail:n.email})}),e.jsx(ze,{value:"companies",children:e.jsx(FD,{userId:n.user_id})}),e.jsx(ze,{value:"membership",children:e.jsx(LD,{user:n,onUpdate:h})})]})]}):e.jsx("div",{className:"p-6",children:"User not found"})},ov=[{value:"BookOpen",label:"Book",icon:Rs},{value:"DollarSign",label:"Dollar",icon:mf},{value:"TrendingUp",label:"Trending",icon:Jr},{value:"Lightbulb",label:"Lightbulb",icon:rn},{value:"Users",label:"Users",icon:Ge},{value:"Presentation",label:"Presentation",icon:Qg},{value:"Award",label:"Award",icon:Zg},{value:"Code",label:"Code",icon:Sv},{value:"Video",label:"Video",icon:df},{value:"Sparkles",label:"Sparkles",icon:xf}],lv=[{value:"blue",label:"Blue",class:"bg-blue-100 text-blue-700"},{value:"green",label:"Green",class:"bg-green-100 text-green-700"},{value:"purple",label:"Purple",class:"bg-purple-100 text-purple-700"},{value:"orange",label:"Orange",class:"bg-orange-100 text-orange-700"},{value:"indigo",label:"Indigo",class:"bg-indigo-100 text-indigo-700"},{value:"red",label:"Red",class:"bg-red-100 text-red-700"},{value:"yellow",label:"Yellow",class:"bg-yellow-100 text-yellow-700"},{value:"gray",label:"Gray",class:"bg-gray-100 text-gray-700"}],wl=t=>{const r=ov.find(n=>n.value===t);if(r){const n=r.icon;return e.jsx(n,{className:"h-4 w-4"})}return e.jsx(Rs,{className:"h-4 w-4"})},Nl=t=>{const r=lv.find(n=>n.value===t);return(r==null?void 0:r.class)||"bg-gray-100 text-gray-700"},zD=()=>{const[t,r]=_.useState([]),[n,a]=_.useState(!0),[s,i]=_.useState(!1),[o,l]=_.useState(null),[c,u]=_.useState({}),[d,h]=_.useState("categories"),[m,j]=_.useState([]),[w,x]=_.useState(!1),[v,y]=_.useState(""),[f,b]=_.useState("all");_.useState(null);const[p,g]=_.useState({name:"",slug:"",description:"",icon:"BookOpen",color:"blue",sort_order:0});_.useEffect(()=>{N(),S()},[]),_.useEffect(()=>{d==="videos"&&O()},[d]);const N=async()=>{a(!0);const{data:M,error:E}=await k.from("member_video_categories").select("*").order("sort_order");E?W.error("Failed to load categories"):r(M||[]),a(!1)},S=async()=>{const{data:M}=await k.from("member_videos").select("category");if(M){const E={};M.forEach(Q=>{E[Q.category]=(E[Q.category]||0)+1}),u(E)}},O=async()=>{x(!0);const{data:M,error:E}=await k.from("member_videos").select("*").order("created_at",{ascending:!1});if(E){W.error("Failed to load videos"),x(!1);return}const Q=[...new Set((M||[]).map(ue=>ue.user_id))],{data:H}=await k.from("profiles").select("id, first_name, last_name, avatar_url").in("id",Q),V=new Map((H||[]).map(ue=>[ue.id,ue])),se=(M||[]).map(ue=>({...ue,uploader:V.get(ue.user_id)||null}));j(se),x(!1)},C=async M=>{const{error:E}=await k.from("member_videos").delete().eq("id",M);E?W.error("Failed to delete video",{description:E.message}):(W.success("Video deleted"),j(Q=>Q.filter(H=>H.id!==M)),S())},P=m.filter(M=>{var H;const E=!v||M.title.toLowerCase().includes(v.toLowerCase())||((H=M.description)==null?void 0:H.toLowerCase().includes(v.toLowerCase())),Q=f==="all"||M.category===f;return E&&Q}),$=M=>M.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""),A=M=>{g(E=>({...E,name:M,slug:o?E.slug:$(M)}))},I=()=>{g({name:"",slug:"",description:"",icon:"BookOpen",color:"blue",sort_order:t.length}),l(null)},D=M=>
178{l(M),g({name:M.name,slug:M.slug,description:M.description||"",icon:M.icon||"BookOpen",color:M.color||"blue",sort_order:M.sort_order}),i(!0)},q=async()=>{if(!p.name.trim()||!p.slug.trim()){W.error("Name and slug are required");return}const M={name:p.name.trim(),slug:p.slug.trim(),description:p.description.trim()||null,icon:p.icon,color:p.color,sort_order:p.sort_order};if(o){const{error:E}=await k.from("member_video_categories").update(M).eq("id",o.id);E?W.error("Failed to update category",{description:E.message}):(W.success("Category updated"),i(!1),I(),N())}else{const{error:E}=await k.from("member_video_categories").insert(M);E?W.error("Failed to create category",{description:E.message}):(W.success("Category created"),i(!1),I(),N())}},F=async M=>{const E=c[M.slug]||0;if(E>0){W.error("Cannot delete category with videos",{description:`This category has ${E} video(s). Reassign them first.`});return}const{error:Q}=await k.from("member_video_categories").delete().eq("id",M.id);Q?W.error("Failed to delete category"):(W.success("Category deleted"),N())},K=async(M,E)=>{const Q=t.findIndex(se=>se.id===M.id),H=E==="up"?Q-1:Q+1;if(H<0||H>=t.length)return;const V=t[H];await Promise.all([k.from("member_video_categories").update({sort_order:V.sort_order}).eq("id",M.id),k.from("member_video_categories").update({sort_order:M.sort_order}).eq("id",V.id)]),N()};return e.jsxs("div",{className:"flex min-h-screen bg-background",children:[e.jsx(jf,{currentSection:"knowledge"}),e.jsx("div",{className:"flex-1 p-6 overflow-auto",children:e.jsxs("div",{className:"space-y-6 max-w-[1200px]",children:[e.jsx("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(An,{className:"w-6 h-6 text-primary"}),e.jsx("h1",{className:"text-2xl font-bold",children:"Knowledge Hub Management"})]})}),e.jsxs(zr,{value:d,onValueChange:h,children:[e.jsxs(Ur,{children:[e.jsxs(Be,{value:"categories",className:"gap-2",children:[e.jsx(rd,{className:"h-4 w-4"}),"Categories"]}),e.jsxs(Be,{value:"videos",className:"gap-2",children:[e.jsx(df,{className:"h-4 w-4"}),"Videos (",Object.values(c).reduce((M,E)=>M+E,0),")"]})]}),e.jsxs(ze,{value:"categories",className:"space-y-6 mt-6",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(ut,{open:s,onOpenChange:M=>{i(M),M||I()},children:[e.jsx(cn,{asChild:!0,children:e.jsxs(R,{className:"gap-2",children:[e.jsx(Ve,{className:"h-4 w-4"}),"Add Category"]})}),e.jsxs(ht,{className:"sm:max-w-md",children:[e.jsx(mt,{children:e.jsx(ft,{children:o?"Edit Category":"Add New Category"})}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"name",children:"Name"}),e.jsx(de,{id:"name",value:p.name,onChange:M=>A(M.target.value),placeholder:"e.g., Fundraising"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"slug",children:"Slug"}),e.jsx(de,{id:"slug",value:p.slug,onChange:M=>g(E=>({...E,slug:M.target.value})),placeholder:"e.g., fundraising"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used for filtering. Only lowercase letters, numbers, and hyphens."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"description",children:"Description"}),e.jsx(Pt,{id:"description",value:p.description,onChange:M=>g(E=>({...E,description:M.target.value})),placeholder:"Brief description of this category",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Icon"}),e.jsxs(xe,{value:p.icon,onValueChange:M=>g(E=>({...E,icon:M})),children:[e.jsx(ve,{children:e.jsx(ge,{})}),e.jsx(ye,{children:ov.map(M=>e.jsx(J,{value:M.value,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(M.icon,{className:"h-4 w-4"}),M.label]})},M.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Color"}),e.jsxs(xe,{value:p.color,onValueChange:M=>g(E=>({...E,color:M})),children:[e.jsx(ve,{children:e.jsx(ge,{})}),e.jsx(ye,{children:lv.map(M=>e.jsx(J,{value:M.value,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-4 h-4 rounded ${M.class}`}),M.label]})},M.value))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"sort_order",children:"Sort Order"}),e.jsx(de,{id:"sort_order",type:"number",value:p.sort_order,onChange:M=>g(E=>({...E,sort_order:parseInt(M.target.value)||0}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Preview"}),e.jsx("div",{className:"p-3 border rounded-lg bg-muted/50",children:e.jsxs(re,{className:`${Nl(p.color)} border gap-1.5`,children:[wl(p.icon),p.name||"Category Name"]})})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(R,{variant:"outline",className:"flex-1",onClick:()=>{i(!1),I()},children:"Cancel"}),e.jsx(R,{className:"flex-1",onClick:q,children:o?"Update":"Create"})]})]})]})]})}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs(Y,{children:[e.jsx(ce,{className:"pb-2",children:e.jsx(le,{className:"text-sm font-medium text-muted-foreground",children:"Total Categories"})}),e.jsx(Z,{children:e.jsx("div",{className:"text-2xl font-bold",children:t.length})})]}),e.jsxs(Y,{children:[e.jsx(ce,{className:"pb-2",children:e.jsx(le,{className:"text-sm font-medium text-muted-foreground",children:"Total Videos"})}),e.jsx(Z,{children:e.jsx("div",{className:"text-2xl font-bold",children:Object.values(c).reduce((M,E)=>M+E,0)})})]}),e.jsxs(Y,{children:[e.jsx(ce,{className:"pb-2",children:e.jsx(le,{className:"text-sm font-medium text-muted-foreground",children:"Empty Categories"})}),e.jsx(Z,{children:e.jsx("div",{className:"text-2xl font-bold",children:t.filter(M=>!c[M.slug]).length})})]})]}),e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsx(le,{children:"Categories"})}),e.jsx(Z,{children:n?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading..."}):t.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No categories yet. Create your first one!"}):e.jsxs(nt,{children:[e.jsx(at,{children:e.jsxs(pe,{children:[e.jsx(te,{className:"w-12",children:"Order"}),e.jsx(te,{children:"Category"}),e.jsx(te,{children:"Slug"}),e.jsx(te,{className:"text-center",children:"Videos"}),e.jsx(te,{className:"text-right",children:"Actions"})]})}),e.jsx(st,{children:t.map((M,E)=>e.jsxs(pe,{children:[e.jsx(X,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(gf,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx(R,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>K(M,"up"),disabled:E===0,children:"▲"}),e.jsx(R,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>K(M,"down"),disabled:E===t.length-1,children:"▼"})]})]})}),e.jsxs(X,{children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(re,{className:`${Nl(M.color)} border gap-1.5`,children:[wl(M.icon),M.name]})}),M.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 max-w-xs truncate",children:M.description})]}),e.jsx(X,{children:e.jsx("code",{className:"text-xs bg-muted px-1.5 py-0.5 rounded",children:M.slug})}),e.jsx(X,{className:"text-center",children:e.jsx(re,{variant:"secondary",children:c[M.slug]||0})}),e.jsx(X,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(R,{variant:"ghost",size:"icon",onClick:()=>D(M),children:e.jsx(Tn,{className:"h-4 w-4"})}),e.jsxs(rr,{children:[e.jsx(ss,{asChild:!0,children:e.jsx(R,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(We,{className:"h-4 w-4"})})}),e.jsxs(nr,{children:[e.jsxs(ar,{children:[e.jsx(sr,{children:"Delete Category"}),e.jsxs(ir,{children:['Are you sure you want to delete "',M.name,'"?',(c[M.slug]||0)>0&&e.jsxs("span",{className:"block mt-2 text-destructive font-medium",children:["This category has ",c[M.slug]," video(s). You must reassign them before deleting."]})]})]}),e.jsxs(or,{children:[e.jsx(lr,{children:"Cancel"}),e.jsx(cr,{onClick:()=>F(M),className:"bg-destructive hover:bg-destructive/90",children:"Delete"})]})]})]})]})})]},M.id))})]})})]})]}),e.jsxs(ze,{value:"videos",className:"space-y-6 mt-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(tr,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}
178),e.jsx(de,{placeholder:"Search videos...",value:v,onChange:M=>y(M.target.value),className:"pl-10"})]}),e.jsxs(xe,{value:f,onValueChange:b,children:[e.jsx(ve,{className:"w-[180px]",children:e.jsx(ge,{placeholder:"All Categories"})}),e.jsxs(ye,{children:[e.jsx(J,{value:"all",children:"All Categories"}),t.map(M=>e.jsx(J,{value:M.slug,children:M.name},M.slug))]})]})]}),e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsxs(le,{children:["All Videos (",P.length,")"]})}),e.jsx(Z,{children:w?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading videos..."}):P.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No videos found"}):e.jsxs(nt,{children:[e.jsx(at,{children:e.jsxs(pe,{children:[e.jsx(te,{children:"Video"}),e.jsx(te,{children:"Category"}),e.jsx(te,{children:"Uploaded By"}),e.jsx(te,{className:"text-center",children:"Stats"}),e.jsx(te,{className:"text-right",children:"Actions"})]})}),e.jsx(st,{children:P.map(M=>{var Q,H;const E=t.find(V=>V.slug===M.category);return e.jsxs(pe,{children:[e.jsx(X,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative w-24 h-14 roun
178ded overflow-hidden shrink-0",children:[e.jsx("img",{src:`https://img.youtube.com/vi/${M.youtube_video_id}/mqdefault.jpg`,alt:M.title,className:"w-full h-full object-cover"}),M.is_featured&&e.jsxs(re,{className:"absolute top-1 left-1 bg-yellow-500 text-yellow-900 text-[10px] px-1 py-0",children:[e.jsx(xf,{className:"h-2 w-2 mr-0.5"}),"Featured"]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium line-clamp-1",children:M.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Et(new Date(M.created_at),"MMM d, yyyy")})]})]})}),e.jsx(X,{children:E?e.jsxs(re,{className:`${Nl(E.color)} border gap-1`,children:[wl(E.icon),E.name]}):e.jsx(re,{variant:"secondary",children:M.category})}),e.jsx(X,{children:M.uploader?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Dr,{className:"h-6 w-6",children:[e.jsx(Mr,{src:M.uploader.avatar_url||void 0}),e.jsx(Ir,{className:"text-xs",children:(((Q=M.uploader.first_name)==null?void 0:Q[0])||"")+(((H=M.uploader.last_name)==null?void 0:H[0])||"")})]}),e.jsxs("span",{className:"text-sm",children:[M.uploader.first_name," ",M.uploader.last_name]})]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"Unknown"})}),e.jsx(X,{children:e.jsxs("div",{className:"flex items-center justify-center gap-3 text-muted-foreground text-sm",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(dr,{className:"h-3.5 w-3.5"}),M.views_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Nn,{className:"h-3.5 w-3.5"}),M.likes_count]})]})}),e.jsx(X,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(R,{variant:"ghost",size:"icon",onClick:()=>window.open(M.youtube_url,"_blank"),children:e.jsx(Zt,{className:"h-4 w-4"})}),e.jsxs(rr,{children:[e.jsx(ss,{asChild:!0,children:e.jsx(R,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(We,{className:"h-4 w-4"})})}),e.jsxs(nr,{children:[e.jsxs(ar,{children:[e.jsx(sr,{children:"Delete Video"}),e.jsxs(ir,{children:['Are you sure you want to delete "',M.title,'"? This action cannot be undone.']})]}),e.jsxs(or,{children:[e.jsx(lr,{children:"Cancel"}),e.jsx(cr,{onClick:()=>C(M.id),className:"bg-destructive hover:bg-destructive/90",children:"Delete"})]})]})]})]})})]},M.id)})})]})})]})]})]})]})})]})},UD=["message-circle","lightbulb","rocket","users","briefcase","code","heart","star","zap","trophy","target","compass","book","globe","shield","flag","bell","coffee"],qD=()=>{const[t,r]=_.useState("categories");return e.jsxs("div",{className:"container mx-auto px-4 py-6 max-w-7xl",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Discussions Management"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage discussion categories, topics, and replies"})]}),e.jsxs(zr,{value:t,onValueChange:r,children:[e.jsxs(Ur,{className:"mb-6",children:[e.jsxs(Be,{value:"categories",className:"gap-2",children:[e.jsx(rd,{className:"h-4 w-4"}),"Categories"]}),e.jsxs(Be,{value:"discussions",className:"gap-2",children:[e.jsx(sn,{className:"h-4 w-4"}),"Topics"]}),e.jsxs(Be,{value:"replies",className:"gap-2",children:[e.jsx(vi,{className:"h-4 w-4"}),"Replies"]})]}),e.jsx(ze,{value:"categories",children:e.jsx(VD,{})}),e.jsx(ze,{value:"discussions",children:e.jsx(WD,{})}),e.jsx(ze,{value:"replies",children:e.jsx(GD,{})})]})]})},VD=()=>{const[t,r]=_.useState([]),[n,a]=_.useState(!0),[s,i]=_.useState(!1),[o,l]=_.useState(null),[c,u]=_.useState(null),[d,h]=_.useState({name:"",slug:"",description:"",icon:"message-circle",display_order:0,member_only:!0});_.useEffect(()=>{m()},[]);const m=async()=>{a(!0);try{const{data:f,error:b}=await k.from("discussion_categories").select("*").order("display_order",{ascending:!0});if(b)throw b;const{data:p}=await k.from("discussions").select("category_id"),g=(p||[]).reduce((N,S)=>(S.category_id&&(N[S.category_id]=(N[S.category_id]||0)+1),N),{});r((f||[]).map(N=>({...N,discussion_count:g[N.id]||0})))}catch(f){console.error("Error:",f),W.error("Failed to load categories")}finally{a(!1)}},j=()=>
178{l(null),h({name:"",slug:"",description:"",icon:"message-circle",display_order:t.length,member_only:!0}),i(!0)},w=f=>{l(f),h({name:f.name,slug:f.slug,description:f.description||"",icon:f.icon||"message-circle",display_order:f.display_order||0,member_only:f.member_only??!0}),i(!0)},x=async()=>{if(!d.name.trim()||!d.slug.trim()){W.error("Name and slug are required");return}try{if(o){const{error:f}=await k.from("discussion_categories").update({name:d.name,slug:d.slug,description:d.description||null,icon:d.icon,display_order:d.display_order,member_only:d.member_only}).eq("id",o.id);if(f)throw f;W.success("Category updated")}else{const{error:f}=await k.from("discussion_categories").insert({name:d.name,slug:d.slug,description:d.description||null,icon:d.icon,display_order:d.display_order,member_only:d.member_only});if(f)throw f;W.success("Category created")}i(!1),m()}catch(f){console.error("Error:",f),W.error(f.message||"Failed to save category")}},v=async()=>{if(!c)return;const f=t.find(b=>b.id===c);if(f&&(f.discussion_count||0)>
1780){W.error("Cannot delete category with discussions"),u(null);return}try{const{error:b}=await k.from("discussion_categories").delete().eq("id",c);if(b)throw b;W.success("Category deleted"),m()}catch(b){console.error("Error:",b),W.error("Failed to delete category")}finally{u(null)}},y=async(f,b)=>{const p=t.findIndex(S=>S.id===f);if(b==="up"&&p===0||b==="down"&&p===t.length-1)return;const g=b==="up"?p-1:p+1,N=[{id:t[p].id,display_order:t[g].display_order},{id:t[g].id,display_order:t[p].display_order}];try{for(const S of N)await k.from("discussion_categories").update({display_order:S.display_order}).eq("id",S.id);m()}catch(S){console.error("Error:",S),W.error("Failed to reorder")}};return n?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(Qe,{size:32})}):e.jsxs(e.Fragment,{children:[e.jsxs(Y,{children:[e.jsxs(ce,{className:"flex flex-row items-center justify-between",children:[e.jsx(le,{className:"text-lg",children:"Discussion Categories"}),e.jsxs(R,{onClick:j,size:"sm",children:[e.jsx(Ve,{className:"h-4 w-4 mr-2"}),"Add Category"]})]}),e.jsx(Z,{children:e.jsxs(nt,{children:[e.jsx(at,{children:e.jsxs(pe,{children:[e.jsx(te,{className:"w-12",children:"Order"}),e.jsx(te,{children:"Name"}),e.jsx(te,{children:"Slug"}),e.jsx(te,{children:"Discussions"}),e.jsx(te,{children:"Access"}),e.jsx(te,{className:"text-right",children:"Actions"})]})}),e.jsxs(st,{children:[t.map((f,b)=>e.jsxs(pe,{children:[e.jsx(X,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(R,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:b===0,onClick:()=>y(f.id,"up"),children:e.jsx(Jg,{className:"h-3 w-3"})}),e.jsx(R,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:b===t.length-1,onClick:()=>y(f.id,"down"),children:e.jsx(nd,{className:"h-3 w-3"})})]})}),e.jsx(X,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-lg",children:f.icon||"💬"}),e.jsx("span",{className:"font-medium",children:f.name})]})}),e.jsx(X,{className:"text-muted-foreground",children:f.slug}),e.jsx(X,{children:e.jsx(re,{variant:"secondary",children:f.discussion_count||0})}),e.jsx(X,{children:e.jsx(re,{variant:f.member_only?"default":"outline",children:f.member_only?"Members Only":"Public"})}),e.jsx(X,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(R,{variant:"ghost",size:"icon",onClick:()=>w(f),children:e.jsx(Tn,{className:"h-4 w-4"})}),e.jsx(R,{variant:"ghost",size:"icon",onClick:()=>u(f.id),disabled:(f.discussion_count||0)>0,children:e.jsx(We,{className:"h-4 w-4"})})]})})]},f.id)),t.length===0&&e.jsx(pe,{children:e.jsx(X,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No categories yet"})})]})]})})]}),e.jsx(ut,{open:s,onOpenChange:i,children:e.jsxs(ht,{children:[e.jsx(mt,{children:e.jsx(ft,{children:o?"Edit Category":"New Category"})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Name"}),e.jsx(de,{value:d.name,onChange:f=>h({...d,name:f.target.value}),placeholder:"e.g., General Discussion"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Slug"}),e.jsx(de,{value:d.slug,onChange:f=>h({...d,slug:f.target.value.toLowerCase().replace(/\s+/g,"-")}),placeholder:"e.g., general"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Description"}),e.jsx(Pt,{value:d.description,onChange:f=>h({...d,description:f.target.value}),placeholder:"Brief description...",rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Icon"}),e.jsxs(xe,{value:d.icon,onValueChange:f=>h({...d,icon:f}),children:[e.jsx(ve,{children:e.jsx(ge,{})}),e.jsx(ye,{children:UD.map(f=>e.jsx(J,{value:f,children:f},f))})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{children:"Members Only"}),e.jsx(Tt,{checked:d.member_only,onCheckedChange:f=>h({...d,member_only:f})})]})]}),e.jsxs(Vt,{children:[e.jsx(R,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(R,{onClick:x,children:"Save"})]})]})}),e.jsx(rr,{open:!!c,onOpenChange:()=>u(null),children:e.jsxs(nr,{children:[e.jsxs(ar,{children:[e.jsx(sr,{children:"Delete Category?"}),e.jsx(ir,{children:"This action cannot be undone."})]}),e.jsxs(or,{children:[e.jsx(lr,{children:"Cancel"}),e.jsx(cr,{onClick:v,className:"bg-destructive text-destructive-foreground",children:"Delete"})]})]})})]})},WD=()=>{const[t,r]=_.useState([]),[n,a]=_.useState([]),[s,i]=_.useState(!0),[o,l]=_.useState(""),[c,u]=_.useState("all"),[d,h]=_.useState(null),[m,j]=_.useState(null);_.useEffect(()=>{w()},[]);const w=async()=>{i(!0);try{const[{data:p},{data:g}]=await Promise.all([k.from("discussions").select("*").order("created_at",{ascending:!1}),k.from("discussion_categories").select("*").order("display_order")]);if(a(g||[]),p){const N=[...new Set(p.map(P=>P.author_id))],{data:S}=await k.from("profiles").select("user_id, name, avatar_url").in("user_id",N),O=new Map((S==null?void 0:S.map(P=>[P.user_id,P]))||[]),C=new Map((g||[]).map(P=>[P.id,P]));r(p.map(P=>({...P,author:O.get(P.author_id),category:P.category_id?C.get(P.category_id):void 0})))}}catch(p){console.error("Error:",p),W.error("Failed to load discussions")}finally{i(!1)}},x=async(p,g)=>{try{await k.from("discussions").update({is_pinned:!g}).eq("id",p),W.success(g?"Unpinned":"Pinned"),w()}catch{W.error("Failed to update")}},v=async(p,g)=>{try{await k.from("discussions").update({is_locked:!g}).eq("id",p),W.success(g?"Unlocked":"Locked"),w()}catch{W.error("Failed to update")}},y=async()=>
178{if(m)try{await k.from("discussions").delete().eq("id",m),W.success("Discussion deleted"),w()}catch{W.error("Failed to delete")}finally{j(null)}},f=t.filter(p=>{const g=!o||p.title.toLowerCase().includes(o.toLowerCase())||p.content.toLowerCase().includes(o.toLowerCase()),N=c==="all"||p.category_id===c;return g&&N}),b=p=>(p==null?void 0:p.split(" ").map(g=>g[0]).join("").toUpperCase().slice(0,2))||"?";return s?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(Qe,{size:32})}):d?e.jsx(KD,{discussion:d,onBack:()=>{h(null),w()}}):e.jsxs(e.Fragment,{children:[e.jsxs(Y,{children:[e.jsxs(ce,{children:[e.jsx(le,{className:"text-lg",children:"Discussion Topics"}),e.jsxs("div",{className:"flex gap-4 mt-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(tr,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(de,{placeholder:"Search discussions...",value:o,onChange:p=>l(p.target.value),className:"pl-10"})]}),e.jsxs(xe,{value:c,onValueChange:u,children:[e.jsx(ve,{className:"w-48",children:e.jsx(ge,{placeholder:"All Categories"})}),e.jsxs(ye,{children:[e.jsx(J,{value:"all",children:"All Categories"}),n.map(p=>e.jsx(J,{value:p.id,children:p.name},p.id))]})]})]})]}),e.jsx(Z,{children:e.jsxs(nt,{children:[e.jsx(at,{children:e.jsxs(pe,{children:[e.jsx(te,{children:"Title"}),e.jsx(te,{children:"Author"}),e.jsx(te,{children:"Category"}),e.jsx(te,{children:"Stats"}),e.jsx(te,{children:"Status"}),e.jsx(te,{children:"Created"}),e.jsx(te,{className:"text-right",children:"Actions"})]})}),e.jsxs(st,{children:[f.map(p=>{var g,N,S;return e.jsxs(pe,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>h(p),children:[e.jsx(X,{children:e.jsx("div",{className:"font-medium max-w-xs truncate",children:p.title})}),e.jsx(X,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Dr,{className:"h-6 w-6",children:[e.jsx(Mr,{src:((g=p.author)==null?void 0:g.avatar_url)||""}),e.jsx(Ir,{className:"text-xs",children:b((N=p.author)==null?void 0:N.name)})]}),e.jsx("span",{className:"text-sm",children:((S=p.author)==null?void 0:S.name)||"Unknown"})]})}),e.jsx(X,{children:p.category?e.jsx(re,{variant:"outline",children:p.category.name}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(X,{children:e.jsxs("div",{className:"flex items-center gap-3 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(vi,{className:"h-3 w-3"})," ",p.reply_count||0]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(dr,{className:"h-3 w-3"})," ",p.view_count||0]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(kl,{className:"h-3 w-3"})," ",p.vote_count||0]})]})}),e.jsx(X,{children:e.jsxs("div",{className:"flex gap-1",children:[p.is_pinned&&e.jsx(re,{variant:"default",className:"text-xs",children:"Pinned"}),p.is_locked&&e.jsx(re,{variant:"secondary",className:"text-xs",children:"Locked"})]})}),e.jsx(X,{className:"text-sm text-muted-foreground",children:po(new Date(p.created_at),{addSuffix:!0})}),e.jsx(X,{className:"text-right",onClick:O=>O.stopPropagation(),children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(R,{variant:"ghost",size:"icon",onClick:()=>x(p.id,p.is_pinned),title:p.is_pinned?"Unpin":"Pin",children:e.jsx(Ov,{className:`h-4 w-4 ${p.is_pinned?"text-primary":""}`})}),e.jsx(R,{variant:"ghost",size:"icon",onClick:()=>v(p.id,p.is_locked),title:p.is_locked?"Unlock":"Lock",children:p.is_locked?e.jsx(ey,{className:"h-4 w-4"}):e.jsx(sy,{className:"h-4 w-4"})}),e.jsx(R,{variant:"ghost",size:"icon",onClick:()=>j(p.id),children:e.jsx(We,{className:"h-4 w-4"})})]})})]},p.id)}),f.length===0&&e.jsx(pe,{children:e.jsx(X,{colSpan:7,className:"text-center text-muted-foreground py-8",children:"No discussions found"})})]})]})})]}),e.jsx(rr,{open:!!m,onOpenChange:()=>j(null),children:e.jsxs(nr,{children:[e.jsxs(ar,{children:[e.jsx(sr,{children:"Delete Discussion?"}),e.jsx(ir,{children:"This will delete the discussion and all its replies. This action cannot be undone."})]}),e.jsxs(or,{children:[e.jsx(lr,{children:"Cancel"}),e.jsx(cr,{onClick:y,className:"bg-destructive text-destructive-foreground",children:"Delete"})]})]})})]})},KD=({discussion:t,onBack:r})=>{var h,m,j;const[n,a]=_.useState([]),[s,i]=_.useState(!0),[o,l]=_.useState(null);_.useEffect(()=>{c()},[t.id]);const c=async()=>{i(!0);try{const{data:w}=await k.from("discussion_replies").select("*").eq("discussion_id",t.id).order("created_at",{ascending:!0});if(w){const x=[...new Set(w.map(f=>f.author_id))],{data:v}=await k.from("profiles").select("user_id, name, avatar_url").in("user_id",x),y=new Map((v==null?void 0:v.map(f=>[f.user_id,f]))||[]);a(w.map(f=>({...f,author:y.get(f.author_id)})))}}catch(w){console.error("Error:",w)}finally{i(!1)}},u=async()=>
178{if(o)try{await k.from("discussion_replies").delete().eq("id",o),W.success("Reply deleted"),c()}catch{W.error("Failed to delete")}finally{l(null)}},d=w=>(w==null?void 0:w.split(" ").map(x=>x[0]).join("").toUpperCase().slice(0,2))||"?";return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(R,{variant:"ghost",onClick:r,className:"gap-2",children:[e.jsx(Bt,{className:"h-4 w-4"}),"Back to Topics"]}),e.jsxs(Y,{children:[e.jsxs(ce,{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.is_pinned&&e.jsx(re,{children:"Pinned"}),t.is_locked&&e.jsx(re,{variant:"secondary",children:"Locked"}),t.category&&e.jsx(re,{variant:"outline",children:t.category.name})]}),e.jsx(le,{children:t.title}),e.jsxs("div",{className:"flex items-center gap-3 text-sm text-muted-foreground mt-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Dr,{className:"h-6 w-6",children:[e.jsx(Mr,{src:((h=t.author)==null?void 0:h.avatar_url)||""}),e.jsx(Ir,{className:"text-xs",children:d((m=t.author)==null?void 0:m.name)})]}),((j=t.author)==null?void 0:j.name)||"Unknown"]}),e.jsx("span",{children:"•"}),e.jsx("span",{children:Et(new Date(t.created_at),"PPp")})]})]}),e.jsxs(Z,{children:[e.jsx("p",{className:"whitespace-pre-wrap text-foreground",children:t.content}),e.jsxs("div",{className:"flex gap-4 mt-4 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(dr,{className:"h-4 w-4"})," ",t.view_count||0," views"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(kl,{className:"h-4 w-4"})," ",t.vote_count||0," votes"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(vi,{className:"h-4 w-4"})," ",n.length," replies"]})]})]})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold mb-4 flex items-center gap-2",children:[e.jsx(vi,{className:"h-5 w-5"}),"Replies (",n.length,")"]}),s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(Qe,{size:32})}):n.length===0?e.jsx(Y,{children:e.jsx(Z,{className:"py-8 text-center text-muted-foreground",children:"No replies yet"})}):e.jsx("div",{className:"space-y-3",children:n.map(w=>{var x,v,y;return e.jsx(Y,{children:e.jsx(Z,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs(Dr,{className:"h-8 w-8",children:[e.jsx(Mr,{src:((x=w.author)==null?void 0:x.avatar_url)||""}),e.jsx(Ir,{className:"text-xs",children:d((v=w.author)==null?void 0:v.name)})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm",children:((y=w.author)==null?void 0:y.name)||"Unknown"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:po(new Date(w.created_at),{addSuffix:!0})}),w.vote_count!==null&&w.vote_count!==0&&e.jsxs(re,{variant:"outline",className:"text-xs",children:[e.jsx(kl,{className:"h-3 w-3 mr-1"})," ",w.vote_count]})]}),e.jsx("p",{className:"text-sm mt-1 whitespace-pre-wrap",children:w.content})]})]}),e.jsx(R,{variant:"ghost",size:"icon",onClick:()=>l(w.id),children:e.jsx(We,{className:"h-4 w-4"})})]})})},w.id)})})]}),e.jsx(rr,{open:!!o,onOpenChange:()=>l(null),children:e.jsxs(nr,{children:[e.jsxs(ar,{children:[e.jsx(sr,{children:"Delete Reply?"}),e.jsx(ir,{children:"This action cannot be undone."})]}),e.jsxs(or,{children:[e.jsx(lr,{children:"Cancel"}),e.jsx(cr,{onClick:u,className:"bg-destructive text-destructive-foreground",children:"Delete"})]})]})})]})},GD=()=>{const[t,r]=_.useState([]),[n,a]=_.useState(!0),[s,i]=_.useState(""),[o,l]=_.useState(null);_.useEffect(()=>{c()},[]);const c=async()=>{a(!0);try{const{data:m}=await k.from("discussion_replies").select("*").order("created_at",{ascending:!1}).limit(100);if(m){const j=[...new Set(m.map(b=>b.author_id))],w=[...new Set(m.map(b=>b.discussion_id))],[{data:x},{data:v}]=await Promise.all([k.from("profiles").select("user_id, name, avatar_url").in("user_id",j),k.from("discussions").select("id, title").in("id",w)]),y=new Map((x==null?void 0:x.map(b=>[b.user_id,b]))||[]),f=new Map((v==null?void 0:v.map(b=>[b.id,b]))||[]);r(m.map(b=>
178({...b,author:y.get(b.author_id),discussion:f.get(b.discussion_id)})))}}catch(m){console.error("Error:",m),W.error("Failed to load replies")}finally{a(!1)}},u=async()=>{if(o)try{await k.from("discussion_replies").delete().eq("id",o),W.success("Reply deleted"),c()}catch{W.error("Failed to delete")}finally{l(null)}},d=t.filter(m=>!s||m.content.toLowerCase().includes(s.toLowerCase())),h=m=>(m==null?void 0:m.split(" ").map(j=>j[0]).join("").toUpperCase().slice(0,2))||"?";return n?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(Qe,{size:32})}):e.jsxs(e.Fragment,{children:[e.jsxs(Y,{children:[e.jsxs(ce,{children:[e.jsx(le,{className:"text-lg",children:"Recent Replies"}),e.jsxs("div",{className:"relative mt-4",children:[e.jsx(tr,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(de,{placeholder:"Search replies...",value:s,onChange:m=>i(m.target.value),className:"pl-10"})]})]}),e.jsx(Z,{children:e.jsxs(nt,{children:[e.jsx(at,{children:e.jsxs(pe,{children:[e.jsx(te,{children:"Author"}),e.jsx(te,{children:"Content"}),e.jsx(te,{children:"Discussion"}),e.jsx(te,{children:"Votes"}),e.jsx(te,{children:"Created"}),e.jsx(te,{className:"text-right",children:"Actions"})]})}),e.jsxs(st,{children:[d.map(m=>{var j,w,x,v;return e.jsxs(pe,{children:[e.jsx(X,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Dr,{className:"h-6 w-6",children:[e.jsx(Mr,{src:((j=m.author)==null?void 0:j.avatar_url)||""}),e.jsx(Ir,{className:"text-xs",children:h((w=m.author)==null?void 0:w.name)})]}),e.jsx("span",{className:"text-sm",children:((x=m.author)==null?void 0:x.name)||"Unknown"})]})}),e.jsx(X,{children:e.jsx("p",{className:"max-w-md truncate text-sm",children:m.content})}),e.jsx(X,{children:e.jsx("span",{className:"text-sm text-muted-foreground max-w-xs truncate block",children:((v=m.discussion)==null?void 0:v.title)||"Unknown"})}),e.jsx(X,{children:e.jsx(re,{variant:"outline",children:m.vote_count||0})}),e.jsx(X,{className:"text-sm text-muted-foreground",children:po(new Date(m.created_at),{addSuffix:!0})}),e.jsx(X,{className:"text-right",children:e.jsx(R,{variant:"ghost",size:"icon",onClick:()=>l(m.id),children:e.jsx(We,{className:"h-4 w-4"})})})]},m.id)}),d.length===0&&e.jsx(pe,{children:e.jsx(X,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No replies found"})})]})]})})]}),e.jsx(rr,{open:!!o,onOpenChange:()=>l(null),children:e.jsxs(nr,{children:[e.jsxs(ar,{children:[e.jsx(sr,{children:"Delete Reply?"}),e.jsx(ir,{children:"This action cannot be undone."})]}),e.jsxs(or,{children:[e.jsx(lr,{children:"Cancel"}),e.jsx(cr,{onClick:u,className:"bg-destructive text-destructive-foreground",children:"Delete"})]})]})})]})},xn={new:{label:"New",color:"bg-blue-100 text-blue-800",icon:$r},in_review:{label:"In Review",color:"bg-amber-100 text-amber-800",icon:dr},planned:{label:"Planned",color:"bg-purple-100 text-purple-800",icon:qt},resolved:{label:"Resolved",color:"bg-green-100 text-green-800",icon:ry},closed:{label:"Closed",color:"bg-gray-100 text-gray-800",icon:On}},HD=()=>{var q,F,K,M;const[t,r]=_.useState([]),[n,a]=_.useState(!0),[s,i]=_.useState(""),[o,l]=_.useState("all"),[c,u]=_.useState("all"),[d,h]=_.useState(null),[m,j]=_.useState(""),[w,x]=_.useState(!1),[v,y]=_.useState([]),[f,b]=_.useState(""),[p,g]=_.useState(!1);_.useEffect(()=>{N()},[]);const N=async()=>{try{const{data:E,error:Q}=await k.from("feedback_requests").select("*").order("created_at",{ascending:!1});if(Q)throw Q;if(!E||E.length===0){r([]);return}const H=[...new Set(E.map(he=>he.user_id))],{data:V,error:se}=await k.from("profiles").select("user_id, name, email, avatar_url").in("user_id",H);se&&console.error("Error fetching profiles:",se);const ue=new Map((V||[]).map(he=>[he.user_id,he])),z=E.map(he=>({...he,profiles:ue.get(he.user_id)||null}));r(z)}catch(E){console.error("Error fetching feedback:",E),W.error("Failed to load feedback")}finally{a(!1)}},S=async(E,Q)=>{try{const{error:H}=await k.from("feedback_requests").update({status:Q}).eq("id",E);if(H)throw H;r(V=>V.map(se=>se.id===E?{...se,status:Q}:se)),W.success("Status updated")}catch(H){console.error("Error updating status:",H),W.error("Failed to update status")}},O=async()=>
178{if(d)try{const{error:E}=await k.from("feedback_requests").update({admin_notes:m}).eq("id",d.id);if(E)throw E;r(Q=>Q.map(H=>H.id===d.id?{...H,admin_notes:m}:H)),W.success("Notes saved")}catch(E){console.error("Error updating notes:",E),W.error("Failed to save notes")}},C=async E=>{try{const{error:Q}=await k.from("feedback_requests").delete().eq("id",E);if(Q)throw Q;r(H=>H.filter(V=>V.id!==E)),x(!1),W.success("Feedback deleted")}catch(Q){console.error("Error deleting feedback:",Q),W.error("Failed to delete feedback")}},P=async E=>{g(!0);try{const{data:Q,error:H}=await k.from("feedback_replies").select("*").eq("feedback_id",E).order("created_at",{ascending:!0});if(H)throw H;y(Q||[])}catch(Q){console.error("Error fetching replies:",Q)}finally{g(!1)}},$=async()=>{if(!(!d||!f.trim()))try{const{data:{user:E}}=await k.auth.getUser();if(!E)throw new Error("Not authenticated");const{data:Q,error:H}=await k.from("feedback_replies").insert({feedback_id:d.id,user_id:E.id,message:f.trim(),is_admin_reply:!0}).select().single();if(H)throw H;y(V=>[...V,Q]),b(""),W.success("Reply sent");try{await k.functions.invoke("send-feedback-notification",{body:{notificationType:"reply",feedbackId:d.id,replyMessage:f.trim(),isAdminReply:!0}})}catch(V){console.error("Failed to send reply notification:",V)}}catch(E){console.error("Error adding reply:",E),W.error("Failed to send reply")}},A=E=>{h(E),j(E.admin_notes||""),y([]),b(""),x(!0),P(E.id)},I=t.filter(E=>{var se,ue,z,he;const Q=E.title.toLowerCase().includes(s.toLowerCase())||E.description.toLowerCase().includes(s.toLowerCase())||((ue=(se=E.profiles)==null?void 0:se.name)==null?void 0:ue.toLowerCase().includes(s.toLowerCase()))||((he=(z=E.profiles)==null?void 0:z.email)==null?void 0:he.toLowerCase().includes(s.toLowerCase())),H=o==="all"||E.status===o,V=c==="all"||E.type===c;return Q&&H&&V}),D={total:t.length,new:t.filter(E=>E.status==="new").length,inReview:t.filter(E=>E.status==="in_review").length,features:t.filter(E=>E.type==="feature").length,bugs:t.filter(E=>E.type==="bug").length};return n?e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:e.jsxs("div",{className:"text-center",children:[e.jsx(rn,{className:"w-12 h-12 text-muted-foreground mx-auto mb-4 animate-pulse"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading feedback..."})]})}):e.jsx("div",{className:"min-h-screen bg-background",children:e.jsxs("main",{className:"container mx-auto px-4 py-8 max-w-7xl",children:[e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(rn,{className:"w-8 h-8 text-primary"}),e.jsx("h1",{className:"text-4xl font-bold text-foreground",children:"Feedback Management"})]}),e.jsx("p",{className:"text-muted-foreground",children:"Review and manage user feedback and bug reports"})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3 md:gap-4 mb-6",children:[e.jsx(Y,{children:e.jsx(Z,{className:"pt-4 md:pt-6 pb-4 md:pb-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-2xl md:text-3xl font-bold text-foreground",children:D.total}),e.jsx("p",{className:"text-xs md:text-sm text-muted-foreground",children:"Total Requests"})]})})}),e.jsx(Y,{className:"bg-gradient-to-br from-blue-50 to-blue-100/50 dark:from-blue-950/30 dark:to-blue-900/20 border-blue-200/50",children:e.jsx(Z,{className:"pt-4 md:pt-6 pb-4 md:pb-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-2xl md:text-3xl font-bold text-blue-600",children:D.new}),e.jsx("p",{className:"text-xs md:text-sm text-blue-600/80",children:"New"})]})})}),e.jsx(Y,{className:"bg-gradient-to-br from-amber-50 to-amber-100/50 dark:from-amber-950/30 dark:to-amber-900/20 border-amber-200/50",children:e.jsx(Z,{className:"pt-4 md:pt-6 pb-4 md:pb-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-2xl md:text-3xl font-bold text-amber-600",children:D.inReview}),e.jsx("p",{className:"text-xs md:text-sm text-amber-600/80",children:"In Review"})]})})}),e.jsx(Y,{className:"bg-gradient-to-br from-purple-50 to-purple-100/50 dark:from-purple-950/30 dark:to-purple-900/20 border-purple-200/50",children:e.jsx(Z,{className:"pt-4 md:pt-6 pb-4 md:pb-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-2xl md:text-3xl font-bold text-purple-600",children:D.features}),e.jsx("p",{className:"text-xs md:text-sm text-purple-600/80",children:"Feature Requests"})]})})}),e.jsx(Y,{className:"bg-gradient-to-br from-red-50 to-red-100/50 dark:from-red-950/30 dark:to-red-900/20 border-red-200/50",children:e.jsx(Z,{className:"pt-4 md:pt-6 pb-4 md:pb-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-2xl md:text-3xl font-bold text-red-600",children:D.bugs}),e.jsx("p",{className:"text-xs md:text-sm text-red-600/80",children:"Bug Reports"})]})})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(tr,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(de,{placeholder:"Search by title, description, or user...",value:s,onChange:E=>i(E.target.value),className:"pl-10"})]}),e.jsxs(xe,{value:o,onValueChange:l,children:[e.jsxs(ve,{className:"w-[160px]",children:[e.jsx(Ug,{className:"h-4 w-4 mr-2"}),e.jsx(ge,{placeholder:"Status"})]}),e.jsxs(ye,{children:[e.jsx(J,{value:"all",children:"All Status"}),Object.entries(xn).map(([E,Q])=>e.jsx(J,{value:E,children:Q.label},E))]})]}),e.jsxs(xe,{value:c,onValueChange:u,children:[e.jsx(ve,{className:"w-[160px]",children:e.jsx(ge,{placeholder:"Type"})}),e.jsxs(ye,{children:[e.jsx(J,{value:"all",children:"All Types"}),e.jsx(J,{value:"feature",children:"Feature Requests"}),e.jsx(J,{value:"bug",children:"Bug Reports"})]})]})]}),e.jsx(Y,{children:e.jsxs(nt,{children:[e.jsx(at,{children:e.jsxs(pe,{children:[e.jsx(te,{children:"Type"}),e.jsx(te,{children:"Title"}),e.jsx(te,{children:"User"}),e.jsx(te,{children:"Status"}),e.jsx(te,{children:"Date"}),e.jsx(te,{className:"text-right",children:"Actions"})]})}),e.jsx(st,{children:I.length===0?e.jsx(pe,{children:e.jsx(X,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No feedback found"})}):I.map(E=>{var V,se;const Q=xn[E.status]||xn.new,H=Q.icon;return e.jsxs(pe,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>A(E),children:[e.jsx(X,{children:e.jsxs(re,{variant:"outline",className:E.type==="feature"?"border-purple-300 text-purple-700":"border-red-300 text-red-700",children:[E.type==="feature"?e.jsx(rn,{className:"h-3 w-3 mr-1"}):e.jsx(Ud,{className:"h-3 w-3 mr-1"}),E.type==="feature"?"Feature":"Bug"]})}),e.jsx(X,{className:"font-medium max-w-[200px] truncate",children:E.title}),e.jsx(X,{children:e.jsxs("div",{className:"text-sm",children:[e.jsx("div",{children:((V=E.profiles)==null?void 0:V.name)||"Unknown"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:(se=E.profiles)==null?void 0:se.email})]})}),e.jsx(X,{children:e.jsxs(re,{className:Q.color,children:[e.jsx(H,{className:"h-3 w-3 mr-1"}),Q.label]})}),e.jsx(X,{className:"text-sm text-muted-foreground",children:Et(new Date(E.created_at),"MMM d, yyyy")}),e.jsx(X,{className:"text-right",children:e.jsxs(xe,{value:E.status,onValueChange:ue=>{S(E.id,ue)},children:[e.jsx(ve,{className:"w-[120px] h-8",onClick:ue=>ue.stopPropagation(),children:e.jsx(ge,{})}),e.jsx(ye,{children:Object.entries(xn).map(([ue,z])=>e.jsx(J,{value:ue,children:z.label},ue))})]})})]},E.id)})})]})}),e.jsx(ut,{open:w,onOpenChange:x,children:e.jsx(ht,{className:"sm:max-w-2xl max-h-[90vh] overflow-y-auto",children:d&&e.jsxs(e.Fragment,{children:[e.jsxs(mt,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(re,{variant:"outline",className:d.type==="feature"?"border-purple-300 text-purple-700":"border-red-300 text-red-700",children:[d.type==="feature"?e.jsx(rn,{className:"h-3 w-3 mr-1"}):e.jsx(Ud,{className:"h-3 w-3 mr-1"}),d.type==="feature"?"Feature Request":"Bug Report"]}),e.jsx(re,{className:((q=xn[d.status])==null?void 0:q.color)||"",children:((F=xn[d.status])==null?void 0:F.label)||d.status})]}),e.jsx(ft,{className:"text-xl",children:d.title}),e.jsxs($t,{children:["Submitted by ",((K=d.profiles)==null?void 0:K.name)||"Unknown"," (",(M=d.profiles)==null?void 0:M.email,") on ",Et(new Date(d.created_at),"MMMM d, yyyy h:mm a")]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Description"}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap bg-muted p-3 rounded-md",children:d.description})]}),d.page_url&&e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Page"}),e.jsxs("a",{href:d.page_url,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline flex items-center gap-1",children:[d.page_url,e.jsx(Zt,{className:"h-3 w-3"})]})]}),d.screenshot_url&&e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Screenshot"}),e.jsx("a",{href:d.screenshot_url,target:"_blank",rel:"noopener noreferrer",children:e.jsx("img",{src:d.screenshot_url,alt:"Screenshot",className:"max-w-full max-h-64 roun
178ded-md border cursor-pointer hover:opacity-90 transition-opacity"})})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Update Status"}),e.jsxs(xe,{value:d.status,onValueChange:E=>{S(d.id,E),h({...d,status:E})},children:[e.jsx(ve,{className:"w-full",children:e.jsx(ge,{})}),e.jsx(ye,{children:Object.entries(xn).map(([E,Q])=>e.jsx(J,{value:E,children:Q.label},E))})]})]}),e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-3 flex items-center gap-2",children:[e.jsx(sn,{className:"h-4 w-4"}),"Conversation"]}),p?e.jsx("div",{className:"text-center py-4 text-muted-foreground text-sm",children:"Loading replies..."}):v.length===0?e.jsx("div",{className:"text-center py-4 text-muted-foreground text-sm bg-muted/50 rounded-md",children:"No replies yet. Start the conversation below."}):e.jsx("div",{className:"space-y-3 max-h-48 overflow-y-auto",children:v.map(E=>e.jsxs("div",{className:`p-3 rounded-lg ${E.is_admin_reply?"bg-primary/10 border border-primary/20 ml-4":"bg-muted mr-4"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(ty,{className:"h-3 w-3"}),e.jsx("span",{className:"text-xs font-medium",children:E.is_admin_reply?"Admin":"User"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Et(new Date(E.created_at),"MMM d, h:mm a")})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:E.message})]},E.id))}),e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsx(Pt,{value:f,onChange:E=>b(E.target.value),placeholder:"Type your reply to the user...",rows:2,className:"flex-1"}),e.jsx(R,{onClick:$,disabled:!f.trim(),className:"self-end",children:e.jsx(cf,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"pt-4 border-t",children:[e.jsx("h4",{className:"font-medium mb-2 text-muted-foreground text-sm",children:"Internal Notes (not visible to user)"}),e.jsx(Pt,{value:m,onChange:E=>j(E.target.value),placeholder:"Add internal notes about this feedback...",rows:2,className:"bg-muted/50"}),e.jsx(R,{size:"sm",variant:"outline",className:"mt-2",onClick:O,children:"Save Notes"})]}),e.jsx("div",{className:"pt-4 border-t",children:e.jsxs(rr,{children:[e.jsx(ss,{asChild:!0,children:e.jsxs(R,{variant:"destructive",size:"sm",children:[e.jsx(We,{className:"h-4 w-4 mr-2"}),"Delete Feedback"]})}),e.jsxs(nr,{children:[e.jsxs(ar,{children:[e.jsx(sr,{children:"Delete Feedback"}),e.jsx(ir,{children:"Are you sure you want to delete this feedback? This action cannot be undone."})]}),e.jsxs(or,{children:[e.jsx(lr,{children:"Cancel"}),e.jsx(cr,{onClick:()=>C(d.id),children:"Delete"})]})]})]})})]})]})})})]})})},cv={submitted:"bg-blue-100 text-blue-800",in_review:"bg-yellow-100 text-yellow-800",accepted:"bg-green-100 text-green-800",rejected:"bg-red-100 text-red-800",withdrawn:"bg-gray-100 text-gray-800"},XD=()=>e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Founders Track"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage cohorts and applications for the Founders Track program"})]}),e.jsxs(zr,{defaultValue:"applications",className:"space-y-6",children:[e.jsxs(Ur,{children:[e.jsx(Be,{value:"applications",children:"Student Applications"}),e.jsx(Be,{value:"startups",children:"Startup Applications"}),e.jsx(Be,{value:"cohorts",children:"Cohorts"}),e.jsx(Be,{value:"settings",children:"Settings"})]}),e.jsx(ze,{value:"applications",children:e.jsx(ZD,{})}),e.jsx(ze,{value:"startups",children:e.jsx(eM,{})}),e.jsx(ze,{value:"cohorts",children:e.jsx(YD,{})}),e.jsx(ze,{value:"settings",children:e.jsx(rM,{})})]})]}),YD=()=>{const[t,r]=_.useState([]),[n,a]=_.useState({}),[s,i]=_.useState(!0),[o,l]=_.useState(null),[c,u]=_.useState(!1),d=async()=>{i(!0);const{data:j}=await k.from("founders_track_cohorts").select("*").order("created_at",{ascending:!1});r(j||[]);const{data:w}=await k.from("founders_track_applications").select("cohort_id"),x={};w==null||w.forEach(v=>{x[v.cohort_id]=(x[v.cohort_id]||0)+1}),a(x),i(!1)};_.useEffect(()=>{d()},[]);const h=()=>{l({id:"",name:"",bootcamp_start:null,application_deadline:null,status:"draft",description:null,created_at:""}),u(!0)},m=j=>{l(j),u(!0)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h2",{className:"text-xl font-semibold",children:"Cohorts"}),e.jsxs(R,{onClick:h,children:[e.jsx(Ve,{className:"w-4 h-4 mr-2"}),"New cohort"]})]}),e.jsx(Y,{children:e.jsx(Z,{className:"p-0",children:s?e.jsx("div",{className:"p-6",children:e.jsx(At,{className:"animate-spin"})}):e.jsxs(nt,{children:[e.jsx(at,{children:e.jsxs(pe,{children:[e.jsx(te,{children:"Name"}),e.jsx(te,{children:"Bootcamp start"}),e.jsx(te,{children:"Deadline"}),e.jsx(te,{children:"Status"}),e.jsx(te,{children:"Applications"}),e.jsx(te,{})]})}),e.jsxs(st,{children:[t.map(j=>e.jsxs(pe,{children:[e.jsx(X,{className:"font-medium",children:j.name}),e.jsx(X,{children:j.bootcamp_start||"—"}),e.jsx(X,{children:j.application_deadline?new Date(j.application_deadline).toLocaleStr
178ing():"—"}),e.jsx(X,{children:e.jsx(re,{children:j.status})}),e.jsx(X,{children:n[j.id]||0}),e.jsx(X,{children:e.jsx(R,{size:"sm",variant:"outline",onClick:()=>m(j),children:"Edit"})})]},j.id)),t.length===0&&e.jsx(pe,{children:e.jsx(X,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No cohorts yet"})})]})]})})}),e.jsx(QD,{open:c,onOpenChange:u,cohort:o,onSaved:()=>{u(!1),d()}})]})},QD=({open:t,onOpenChange:r,cohort:n,onSaved:a})=>{const[s,i]=_.useState({}),[o,l]=_.useState(!1);_.useEffect(()=>{i(n||{})},[n]);const c=async()=>{if(!s.name){W.error("Name required");return}l(!0);const d={name:s.name,bootcamp_start:s.bootcamp_start||null,application_deadline:s.application_deadline||null,status:s.status||"draft",description:s.description||null},{error:h}=n!=null&&n.id?await k.from("founders_track_cohorts").update(d).eq("id",n.id):await k.from("founders_track_cohorts").insert(d);if(l(!1),h){W.error(h.message);return}W.success("Saved"),a()},u=async()=>{if(!(n!=null&&n.id)||!confirm("Delete this cohort and all its applications?"))return;const{error:d}=await k.from("founders_track_cohorts").delete().eq("id",n.id);if(d){W.error(d.message);return}W.success("Deleted"),a()};return e.jsx(ut,{open:t,onOpenChange:r,children:e.jsxs(ht,{children:[e.jsx(mt,{children:e.jsx(ft,{children:n!=null&&n.id?"Edit cohort":"New cohort"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(B,{children:"Name"}),e.jsx(de,{value:s.name||"",onChange:d=>i({...s,name:d.target.value})})]}),e.jsxs("div",{children:[e.jsx(B,{children:"Description"}),e.jsx(Pt,{value:s.description||"",onChange:d=>i({...s,description:d.target.value})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(B,{children:"Bootcamp start"}),e.jsx(de,{type:"date",value:s.bootcamp_start||"",onChange:d=>i({...s,bootcamp_start:d.target.value})})]}),e.jsxs("div",{children:[e.jsx(B,{children:"Application deadline"}),e.jsx(de,{type:"datetime-local",value:s.application_deadline?s.application_deadline.slice(0,16):"",onChange:d=>i({...s,application_deadline:d.target.value})})]})]}),e.jsxs("div",{children:[e.jsx(B,{children:"Status"}),e.jsxs(xe,{value:s.status||"draft",onValueChange:d=>i({...s,status:d}),children:[e.jsx(ve,{children:e.jsx(ge,{})}),e.jsxs(ye,{children:[e.jsx(J,{value:"draft",children:"Draft"}),e.jsx(J,{value:"open",children:"Open"}),e.jsx(J,{value:"closed",children:"Closed"})]})]})]})]}),e.jsxs(Vt,{className:"flex justify-between sm:justify-between",children:[n!=null&&n.id?e.jsx(R,{variant:"destructive",onClick:u,children:"Delete"}):e.jsx("span",{}),e.jsx(R,{onClick:c,disabled:o,children:o?"Saving…":"Save"})]})]})})},ZD=()=>{const[t,r]=_.useState([]),[n,a]=_.useState([]),[s,i]=_.useState(!0),[o,l]=_.useState("all"),[c,u]=_.useState("all"),[d,h]=_.useState(""),[m,j]=_.useState(null),w=async()=>{i(!0);const[{data:y},{data:f}]=await Promise.all([k.from("founders_track_applications").select("*").order("created_at",{ascending:!1}),k.from("founders_track_cohorts").select("*").order("created_at",{ascending:!1})]);r(y||[]),a(f||[]),i(!1)};_.useEffect(()=>{w()},[]);const x=t.filter(y=>{if(o!=="all"&&y.cohort_id!==o||c!=="all"&&y.status!==c)return!1;if(d){const f=d.toLowerCase();if(!`${y.first_name} ${y.last_name} ${y.email} ${y.university}`.toLowerCase().includes(f))return!1}return!0}),v=()=>{const f=[["Created","Cohort","Status","First name","Last name","Email","Phone","LinkedIn","University","Field","Year","Expected grad","Video","Referral","Domains","Problem"],...x.map(N=>{var S;return[new Date(N.created_at).toISOString(),((S=n.find(O=>O.id===N.cohort_id))==null?void 0:S.name)||"",N.status,N.first_name,N.last_name,N.email,N.phone||"",N.linkedin_url,N.university,N.field_of_study,N.year_of_studies,N.expected_graduation,N.video_url,N.referral_source,(N.preferred_domains||[]).join("|"),N.problem_statement.replace(/\n/g," ")]})].map(N=>N.map(S=>`"${String(S).replace(/"/g,'""')}"`).join(",")).join(`
179`),b=new Blob([f],{type:"text/csv"}),p=URL.createObjectURL(b),g=document.createElement("a");g.href=p,g.download="founders-track-applications.csv",g.click(),URL.revokeObjectURL(p)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-3 items-end justify-between",children:[e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx(de,{placeholder:"Search name / email / university…",value:d,onChange:y=>h(y.target.value),className:"w-64"}),e.jsxs(xe,{value:o,onValueChange:l,children:[e.jsx(ve,{className:"w-48",children:e.jsx(ge,{placeholder:"Cohort"})}),e.jsxs(ye,{children:[e.jsx(J,{value:"all",children:"All cohorts"}),n.map(y=>e.jsx(J,{value:y.id,children:y.name},y.id))]})]}),e.jsxs(xe,{value:c,onValueChange:u,children:[e.jsx(ve,{className:"w-44",children:e.jsx(ge,{placeholder:"Status"})}),e.jsxs(ye,{children:[e.jsx(J,{value:"all",children:"All statuses"}),e.jsx(J,{value:"submitted",children:"Submitted"}),e.jsx(J,{value:"in_review",children:"In review"}),e.jsx(J,{value:"accepted",children:"Accepted"}),e.jsx(J,{value:"rejected",children:"Rejected"}),e.jsx(J,{value:"withdrawn",children:"Withdrawn"})]})]})]}),e.jsxs(R,{onClick:v,variant:"outline",children:[e.jsx(id,{className:"w-4 h-4 mr-2"}),"Export CSV"]})]}),e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsxs(le,{children:[x.length," application",x.length!==1?"s":""]})}),e.jsx(Z,{children:s?e.jsx(At,{className:"animate-spin"}):e.jsxs(nt,{children:[e.jsx(at,{children:e.jsxs(pe,{children:[e.jsx(te,{children:"Name"}),e.jsx(te,{children:"Email"}),e.jsx(te,{children:"University"}),e.jsx(te,{children:"Year"}),e.jsx(te,{children:"Status"}),e.jsx(te,{children:"Submitted"})]})}),e.jsxs(st,{children:[x.map(y=>e.jsxs(pe,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>j(y),children:[e.jsxs(X,{className:"font-medium",children:[y.first_name," ",y.last_name]}),e.jsx(X,{children:y.email}),e.jsx(X,{children:y.university}),e.jsx(X,{children:y.year_of_studies}),e.jsx(X,{children:e.jsx("span",{className:`px-2 py-1 rounded text-xs ${cv[y.status]}`,children:y.status})}),e.jsx(X,{children:new Date(y.created_at).toLocaleDateString()})]},y.id)),x.length===0&&e.jsx(pe,{children:e.jsx(X,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No applications"})})]})]})})]}),e.jsx(JD,{app:m,onClose:()=>j(null),onChanged:w})]})},JD=({app:t,onClose:r,onChanged:n})=>{const[a,s]=_.useState(""),[i,o]=_.useState("submitted"),[l,c]=_.useState(null);_.useEffect(()=>{t&&(s(t.admin_notes||""),o(t.status),c(null),t.cv_file_path&&k.storage.from("founders-track-cvs").createSignedUrl(t.cv_file_path,3600).then(({data:d})=>{d!=null&&d.signedUrl&&c(d.signedUrl)}))},[t]);const u=async()=>
179{if(!t)return;if(i==="accepted"&&t.status!=="accepted"){const{data:h,error:m}=await k.functions.invoke("accept-founders-track-application",{body:{application_id:t.id,admin_notes:a}});if(m){W.error(m.message);return}if(h!=null&&h.error){W.error(h.error);return}W.success(h!=null&&h.created_new_user?"Accepted — invite email sent":"Accepted — student linked"),n();return}const{error:d}=await k.from("founders_track_applications").update({status:i,admin_notes:a}).eq("id",t.id);if(d){W.error(d.message);return}W.success("Updated"),n()};return e.jsx(Gm,{open:!!t,onOpenChange:d=>!d&&r(),children:e.jsx(Hm,{className:"sm:max-w-2xl overflow-y-auto",children:t&&e.jsxs(e.Fragment,{children:[e.jsx(Xm,{children:e.jsxs(Ym,{children:[t.first_name," ",t.last_name]})}),e.jsxs("div",{className:"mt-6 space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[e.jsx(xt,{label:"Email",value:t.email}),e.jsx(xt,{label:"Phone",value:t.phone||"—"}),e.jsx(xt,{label:"LinkedIn",value:e.jsxs("a",{href:t.linkedin_url,target:"_blank",rel:"noreferrer",className:"underline inline-flex items-center gap-1",children:["Open ",e.jsx(Zt,{className:"w-3 h-3"})]})}),e.jsx(xt,{label:"University",value:t.university}),e.jsx(xt,{label:"Field",value:t.field_of_study}),e.jsx(xt,{label:"Year",value:t.year_of_studies}),e.jsx(xt,{label:"Expected graduation",value:t.expected_graduation}),e.jsx(xt,{label:"Referral",value:t.referral_source}),e.jsx(xt,{label:"Newsletter",value:t.newsletter_optin?"Yes":"No"}),e.jsx(xt,{label:"Domains",value:(t.preferred_domains||[]).join(", ")||"—"})]}),e.jsxs("div",{children:[e.jsx(B,{className:"text-xs uppercase text-muted-foreground",children:"Problem statement"}),e.jsx("p",{className:"text-sm mt-1 whitespace-pre-wrap",children:t.problem_statement})]}),e.jsxs("div",{className:"flex gap-3",children:[l?e.jsx(R,{asChild:!0,variant:"outline",size:"sm",children:e.jsxs("a",{href:l,target:"_blank",rel:"noreferrer",children:[e.jsx(ln,{className:"w-4 h-4 mr-2"}),"Download CV"]})}):t.cv_file_path?e.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading CV link…"}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"No CV"}),e.jsx(R,{asChild:!0,variant:"outline",size:"sm",children:e.jsxs("a",{href:t.video_url,target:"_blank",rel:"noreferrer",children:[e.jsx(Zt,{className:"w-4 h-4 mr-2"}),"Watch video"]})})]}),e.jsxs("div",{children:[e.jsx(B,{children:"Status"}),e.jsxs(xe,{value:i,onValueChange:d=>o(d),children:[e.jsx(ve,{children:e.jsx(ge,{})}),e.jsxs(ye,{children:[e.jsx(J,{value:"submitted",children:"Submitted"}),e.jsx(J,{value:"in_review",children:"In review"}),e.jsx(J,{value:"accepted",children:"Accepted"}),e.jsx(J,{value:"rejected",children:"Rejected"}),e.jsx(J,{value:"withdrawn",children:"Withdrawn"})]})]})]}),e.jsxs("div",{children:[e.jsx(B,{children:"Admin notes"}),e.jsx(Pt,{rows:4,value:a,onChange:d=>s(d.target.value)})]}),e.jsx(R,{onClick:u,className:"w-full",children:"Save changes"})]})]})})})},xt=({label:t,value:r})=>e.jsxs("div",{children:[e.jsx("div",{className:"text-xs uppercase text-muted-foreground",children:t}),e.jsx("div",{className:"text-sm",children:r})]}),eM=()=>{const[t,r]=_.useState([]),[n,a]=_.useState([]),[s,i]=_.useState(!0),[o,l]=_.useState("all"),[c,u]=_.useState("all"),[d,h]=_.useState(""),[m,j]=_.useState(null),w=async()=>{i(!0);const[{data:y},{data:f}]=await Promise.all([k.from("founders_track_startup_applications").select("*").order("created_at",{ascending:!1}),k.from("founders_track_cohorts").select("*").order("created_at",{ascending:!1})]);r(y||[]),a(f||[]),i(!1)};_.useEffect(()=>{w()},[]);const x=t.filter(y=>{if(o!=="all"&&y.cohort_id!==o||c!=="all"&&y.status!==c)return!1;if(d){const f=d.toLowerCase();if(!`${y.company_name} ${y.contact_first_name} ${y.contact_last_name} ${y.contact_email}`.toLowerCase().includes(f))return!1}return!0}),v=()=>{const f=[["Created","Cohort","Status","Plan","Company","Website","Contact","Email","Role","Phone","Stage","Team size","Founded","Industry","Description"],...x.map(N=>{var S;return[new Date(N.created_at).toISOString(),((S=n.find(O=>O.id===N.cohort_id))==null?void 0:S.name)||"",N.status,N.plan_type,N.company_name,N.website||"",`${N.contact_first_name} ${N.contact_last_name}`,N.contact_email,N.contact_role,N.contact_phone||"",N.funding_stage||"",N.team_size??"",N.founded_year??"",(N.industry||[]).join("|"),N.description.replace(/\n/g," ")]})].map(N=>N.map(S=>`"${String(S).replace(/"/g,'""')}"`).join(",")).join(`
180`),b=new Blob([f],{type:"text/csv"}),p=URL.createObjectURL(b),g=document.createElement("a");g.href=p,g.download="founders-track-startup-applications.csv",g.click(),URL.revokeObjectURL(p)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-3 items-end justify-between",children:[e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx(de,{placeholder:"Search company / contact / email…",value:d,onChange:y=>h(y.target.value),className:"w-64"}),e.jsxs(xe,{value:o,onValueChange:l,children:[e.jsx(ve,{className:"w-48",children:e.jsx(ge,{placeholder:"Cohort"})}),e.jsxs(ye,{children:[e.jsx(J,{value:"all",children:"All cohorts"}),n.map(y=>e.jsx(J,{value:y.id,children:y.name},y.id))]})]}),e.jsxs(xe,{value:c,onValueChange:u,children:[e.jsx(ve,{className:"w-44",children:e.jsx(ge,{placeholder:"Status"})}),e.jsxs(ye,{children:[e.jsx(J,{value:"all",children:"All statuses"}),e.jsx(J,{value:"submitted",children:"Submitted"}),e.jsx(J,{value:"in_review",children:"In review"}),e.jsx(J,{value:"accepted",children:"Accepted"}),e.jsx(J,{value:"rejected",children:"Rejected"}),e.jsx(J,{value:"withdrawn",children:"Withdrawn"})]})]})]}),e.jsxs(R,{onClick:v,variant:"outline",children:[e.jsx(id,{className:"w-4 h-4 mr-2"}),"Export CSV"]})]}),e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsxs(le,{children:[x.length," startup application",x.length!==1?"s":""]})}),e.jsx(Z,{children:s?e.jsx(At,{className:"animate-spin"}):e.jsxs(nt,{children:[e.jsx(at,{children:e.jsxs(pe,{children:[e.jsx(te,{children:"Company"}),e.jsx(te,{children:"Contact"}),e.jsx(te,{children:"Plan"}),e.jsx(te,{children:"Stage"}),e.jsx(te,{children:"Status"}),e.jsx(te,{children:"Submitted"})]})}),e.jsxs(st,{children:[x.map(y=>e.jsxs(pe,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>j(y),children:[e.jsx(X,{className:"font-medium",children:y.company_name}),e.jsxs(X,{children:[y.contact_first_name," ",y.contact_last_name,e.jsx("div",{className:"text-xs text-muted-foreground",children:y.contact_email})]}),e.jsx(X,{children:e.jsx(re,{variant:y.plan_type==="with_cofounder"?"default":"secondary",children:y.plan_type==="with_cofounder"?"€10k + salary":"€5k"})}),e.jsx(X,{children:y.funding_stage||"—"}),e.jsx(X,{children:e.jsx("span",{className:`px-2 py-1 rounded text-xs ${cv[y.status]}`,children:y.status})}),e.jsx(X,{children:new Date(y.created_at).toLocaleDateString()})]},y.id)),x.length===0&&e.jsx(pe,{children:e.jsx(X,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No startup applications"})})]})]})})]}),e.jsx(tM,{app:m,onClose:()=>j(null),onChanged:w})]})},tM=({app:t,onClose:r,onChanged:n})=>{const[a,s]=_.useState(""),[i,o]=_.useState("submitted");_.useEffect(()=>{t&&(s(t.admin_notes||""),o(t.status))},[t]);const l=async()=>
180{if(!t)return;const{error:c}=await k.from("founders_track_startup_applications").update({status:i,admin_notes:a}).eq("id",t.id);if(c){W.error(c.message);return}W.success("Updated"),n()};return e.jsx(Gm,{open:!!t,onOpenChange:c=>!c&&r(),children:e.jsx(Hm,{className:"sm:max-w-2xl overflow-y-auto",children:t&&e.jsxs(e.Fragment,{children:[e.jsx(Xm,{children:e.jsx(Ym,{children:t.company_name})}),e.jsxs("div",{className:"mt-6 space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[e.jsx(xt,{label:"Contact",value:`${t.contact_first_name} ${t.contact_last_name}`}),e.jsx(xt,{label:"Role",value:t.contact_role}),e.jsx(xt,{label:"Email",value:t.contact_email}),e.jsx(xt,{label:"Phone",value:t.contact_phone||"—"}),e.jsx(xt,{label:"Website",value:t.website?e.jsxs("a",{href:t.website,target:"_blank",rel:"noreferrer",className:"underline inline-flex items-center gap-1",children:["Open ",e.jsx(Zt,{className:"w-3 h-3"})]}):"—"}),e.jsx(xt,{label:"LinkedIn",value:t.linkedin?e.jsxs("a",{href:t.linkedin,target:"_blank",rel:"noreferrer",className:"underline inline-flex items-center gap-1",children:["Open ",e.jsx(Zt,{className:"w-3 h-3"})]}):"—"}),e.jsx(xt,{label:"Funding stage",value:t.funding_stage||"—"}),e.jsx(xt,{label:"Team size",value:t.team_size??"—"}),e.jsx(xt,{label:"Founded",value:t.founded_year??"—"}),e.jsx(xt,{label:"Industry",value:(t.industry||[]).join(", ")||"—"}),e.jsx(xt,{label:"Plan",value:e.jsx(re,{variant:t.plan_type==="with_cofounder"?"default":"secondary",children:t.plan_type==="with_cofounder"?"€10k + founder salary":"€5k participation"})}),e.jsx(xt,{label:"Agreed to fees",value:t.agreed_to_fees?"Yes":"No"})]}),t.tagline&&e.jsxs("div",{children:[e.jsx(B,{className:"text-xs uppercase text-muted-foreground",children:"Tagline"}),e.jsx("p",{className:"text-sm mt-1",children:t.tagline})]}),e.jsxs("div",{children:[e.jsx(B,{className:"text-xs uppercase text-muted-foreground",children:"Description"}),e.jsx("p",{className:"text-sm mt-1 whitespace-pre-wrap",children:t.description})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(B,{className:"text-xs uppercase text-muted-foreground",children:"Problem"}),e.jsx("p",{className:"text-sm mt-1 whitespace-pre-wrap",children:t.problem})]}),e.jsxs("div",{children:[e.jsx(B,{className:"text-xs uppercase text-muted-foreground",children:"Solution"}),e.jsx("p",{className:"text-sm mt-1 whitespace-pre-wrap",children:t.solution})]}),t.target_market&&e.jsxs("div",{children:[e.jsx(B,{className:"text-xs uppercase text-muted-foreground",children:"Target market"}),e.jsx("p",{className:"text-sm mt-1 whitespace-pre-wrap",children:t.target_market})]}),t.business_model&&e.jsxs("div",{children:[e.jsx(B,{className:"text-xs uppercase text-muted-foreground",children:"Business model"}),e.jsx("p",{className:"text-sm mt-1 whitespace-pre-wrap",children:t.business_model})]}),t.traction&&e.jsxs("div",{className:"md:col-span-2",children:[e.jsx(B,{className:"text-xs uppercase text-muted-foreground",children:"Traction"}),e.jsx("p",{className:"text-sm mt-1 whitespace-pre-wrap",children:t.traction})]})]}),t.desired_profile&&e.jsxs("div",{children:[e.jsx(B,{className:"text-xs uppercase text-muted-foreground",children:"Desired candidate profile"}),e.jsx("p",{className:"text-sm mt-1 whitespace-pre-wrap",children:t.desired_profile})]}),t.additional_notes&&e.jsxs("div",{children:[e.jsx(B,{className:"text-xs uppercase text-muted-foreground",children:"Additional notes"}),e.jsx("p",{className:"text-sm mt-1 whitespace-pre-wrap",children:t.additional_notes})]}),e.jsxs("div",{children:[e.jsx(B,{children:"Status"}),e.jsxs(xe,{value:i,onValueChange:c=>o(c),children:[e.jsx(ve,{children:e.jsx(ge,{})}),e.jsxs(ye,{children:[e.jsx(J,{value:"submitted",children:"Submitted"}),e.jsx(J,{value:"in_review",children:"In review"}),e.jsx(J,{value:"accepted",children:"Accepted"}),e.jsx(J,{value:"rejected",children:"Rejected"}),e.jsx(J,{value:"withdrawn",children:"Withdrawn"})]})]})]}),e.jsxs("div",{children:[e.jsx(B,{children:"Admin notes"}),e.jsx(Pt,{rows:4,value:a,onChange:c=>s(c.target.value)})]}),e.jsx(R,{onClick:l,className:"w-full",children:"Save changes"})]})]})})})},rM=()=>{const[t,r]=_.useState([]),[n,a]=_.useState([]),[s,i]=_.useState(""),[o,l]=_.useState(!0),[c,u]=_.useState(!1),[d,h]=_.useState(null);_.useEffect(()=>{(async()=>
180{l(!0);const[{data:w},{data:x}]=await Promise.all([k.rpc("get_platform_admin_recipients"),k.from("founders_track_settings").select("id, notification_emails").limit(1).maybeSingle()]),v=(w||[]).map(b=>({user_id:b.user_id,email:b.email??"",name:b.name||b.email||b.user_id})).filter(b=>b.email);r(v);const y=(x==null?void 0:x.notification_emails)||[];h((x==null?void 0:x.id)||null);const f=new Set(v.map(b=>b.email.toLowerCase()));a(y.filter(b=>f.has(b.toLowerCase()))),i(y.filter(b=>!f.has(b.toLowerCase())).join(", ")),l(!1)})()},[]);const m=w=>{a(x=>x.includes(w)?x.filter(v=>v!==w):[...x,w])},j=async()=>{const w=s.split(/[,;\s]+/).map(f=>f.trim()).filter(Boolean),x=Array.from(new Set([...n,...w]));if(x.length===0){W.error("Add at least one recipient");return}u(!0);const v={notification_emails:x},{error:y}=d?await k.from("founders_track_settings").update(v).eq("id",d):await k.from("founders_track_settings").insert(v);if(u(!1),y){W.error(y.message);return}W.success("Settings saved")};return e.jsxs(Y,{children:[e.jsxs(ce,{children:[e.jsx(le,{children:"Application notifications"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose who receives an email when a new Founders Track application is submitted."})]}),e.jsx(Z,{className:"space-y-6",children:o?e.jsx(At,{className:"animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Platform administrators"}),t.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"No administrators with email found."}),e.jsx("div",{className:"space-y-2",children:t.map(w=>e.jsxs("label",{className:"flex items-center gap-3 p-3 border rounded-md cursor-pointer hover:bg-muted/50",children:[e.jsx("input",{type:"checkbox",className:"h-4 w-4",checked:n.includes(w.email),onChange:()=>m(w.email)}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-sm",children:w.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:w.email})]})]},w.user_id))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Additional recipients (optional)"}),e.jsx(de,{placeholder:"[email protected], [email protected]",value:s,onChange:w=>i(w.target.value)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Comma-separated email addresses for non-admin recipients."})]}),e.jsx(R,{onClick:j,disabled:c,children:c?"Saving…":"Save settings"})]})})]})},nM=()=>{var ur;const{id:t}=Zr(),r=gt(),n=t!=="new",[a,s]=_.useState({title:"",content:"",excerpt:"",author:"",author_avatar:"",author_role:"",category:"",status:"draft",visibility:"public",slug:"",image:"",tags:[],read_time:5,event_id:"",company_id:""}),[i,o]=_.useState([]),[l,c]=_.useState([]),[u,d]=_.useState([]),[h,m]=_.useState(null),[j,w]=_.useState(null),[x,v]=_.useState(null),[y,f]=_.useState(!1),[b,p]=_.useState(!1),[g,N]=_.useState(!1),[S,O]=_.useState(""),[C,P]=_.useState(!1),[$,A]=_.useState([]),[I,D]=_.useState(!1),[q,F]=_.useState(!1),[K,M]=_.useState(!1),E=_.useRef(null),[Q,H]=_.useState(null),[V,se]=_.useState(!1);_.useEffect(()=>{De(),Ce(),Re(),n&&fe()},[t,n]);const ue=async()=>{F(!0);try{const{data:ee,error:Ne}=await k.storage.from("event-images").list("media",{limit:100,offset:0,sortBy:{column:"created_at",order:"desc"}});if(Ne)throw Ne;const ke=ee.map(G=>{const{data:_e}=k.storage.from("event-images").getPublicUrl(`media/${G.name}`);return{name:G.name,url:_e.publicUrl,created_at:G.created_at}});A(ke)}catch(ee){we.error({title:"Error loading media",description:ee.message})}finally{F(!1)}},z=()=>{var ke;const ee=(ke=E.current)==null?void 0:ke.getEditor(),Ne=ee==null?void 0:ee.getSelection();Ne&&H(Ne.index),D(!0),ue()},he=ee=>{var ke;const Ne=(ke=E.current)==null?void 0:ke.getEditor();if(Ne){const G=typeof Q=="number"?Q:Ne.getLength();Ne.insertEmbed(G,"image",ee,"user"),Ne.setSelection(G+1,0,"silent"),D(!1)}else{const G=`<img src="${ee}" alt="Blog image" />`;ie("content",(a.content||"")+G),D(!1)}we.success({title:"Image inserted",description:"Image has been inserted into the content"})},ne=ee=>{ie("image",ee),M(!1),we.success({title:"Hero image selected",description:"Hero image has been updated"})},fe=async()=>
180{if(t)try{const{data:ee,error:Ne}=await k.from("posts").select("*").eq("id",t).single();if(Ne)throw Ne;if(s(ee),ee.author){const ke=i.find(G=>G.name===ee.author);ke&&m(ke)}if(ee.event_id){const ke=l.find(G=>G.id===ee.event_id);ke&&w(ke)}if(ee.company_id){const ke=u.find(G=>G.id===ee.company_id);ke&&v(ke)}}catch(ee){we.error({title:"Error loading post",description:ee.message})}},De=async()=>{try{const{data:ee,error:Ne}=await k.from("profiles").select("user_id, name, email, avatar_url").order("name");if(Ne)throw Ne;o((ee==null?void 0:ee.map(ke=>({id:ke.user_id,name:ke.name,email:ke.email,avatar_url:ke.avatar_url})))||[])}catch(ee){console.error("Error fetching users:",ee)}},Ce=async()=>{try{const{data:ee,error:Ne}=await k.from("events").select("id, title").order("title");if(Ne)throw Ne;c(ee||[])}catch(ee){console.error("Error fetching events:",ee)}},Re=async()=>{try{const{data:ee,error:Ne}=await k.from("companies").select("id, name").order("name");if(Ne)throw Ne;d(ee||[])}catch(ee){console.error("Error fetching companies:",ee)}},T=ee=>ee.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""),ie=(ee,Ne)=>{s(ke=>({...ke,[ee]:Ne})),ee==="title"&&typeof Ne=="string"&&s(ke=>({...ke,slug:T(Ne)}))},Se=ee=>{m(ee),s(Ne=>({...Ne,author:ee.name,author_avatar:ee.avatar_url||""})),f(!1)},Ae=ee=>{w(ee),s(Ne=>({...Ne,event_id:(ee==null?void 0:ee.id)||""})),p(!1)},Pe=ee=>{v(ee),s(Ne=>({...Ne,company_id:(ee==null?void 0:ee.id)||""})),N(!1)},Ue=()=>{var ee;S.trim()&&!((ee=a.tags)!=null&&ee.includes(S.trim()))&&(s(Ne=>({...Ne,tags:[...Ne.tags||[],S.trim()]})),O(""))},be=ee=>{s(Ne=>{var ke;return{...Ne,tags:((ke=Ne.tags)==null?void 0:ke.filter(G=>G!==ee))||[]}})},ot=async()=>{var ee,Ne;try{se(!0);const{data:ke,error:G}=await k.functions.invoke("generate-blog-content",{body:{title:a.title,excerpt:a.excerpt,content:a.content}});if(G){(ee=G.message)!=null&&ee.includes("Rate limits exceeded")?we.error({title:"Rate limit exceeded",description:"Please try again in a moment."}):(Ne=G.message)!=null&&Ne.includes("Payment required")?we.error({title:"AI credits required",description:"Please add credits to your workspace."}):we.error({title:"Error generating content",description:G.message||"Please try again."}),console.error("Error generating content:",G);return}ke&&ke.title&&ke.excerpt&&ke.content?(s({...a,title:ke.title,excerpt:ke.excerpt,content:ke.content}),we.success({title:"Content generated",description:"AI has enhanced your blog post!"})):we.error({title:"Invalid response",description:"Please try again."})}catch(ke){console.error("Error generating content:",ke),we.error({title:"Error generating content",description:ke.message||"Please try again."})}finally{se(!1)}},yt=async()=>{if(!a.title||!a.content||!a.author||!a.category){we.error({title:"Missing required fields",description:"Please fill in title, content, author, and category"});return}P(!0);try{const ee={title:a.title,content:a.content,excerpt:a.excerpt||"",author:a.author,author_avatar:a.author_avatar||"",author_role:a.author_role||"",category:a.category,status:a.status,visibility:a.visibility,slug:a.slug,image:a.image||"",tags:a.tags||[],read_time:a.read_time||5,event_id:a.event_id||null,company_id:a.company_id||null,updated_at:new Date().toISOString()};let Ne;if(n&&t){const{data:ke,error:G}=await k.from("posts").update(ee).eq("id",t).select().single();Ne={data:ke,error:G}}else{const ke={...ee,created_at:new Date().toISOString()},{data:G,error:_e}=await k.from("posts").insert(ke).select().single();Ne={data:G,error:_e}}if(Ne.error)throw Ne.error;we.success({title:n?"Post updated":"Post created",description:`Blog post has been successfully ${n?"updated":"created"}`}),r("/dashboard/admin/blog")}catch(ee){we.error({title:"Error saving post",description:ee.message})}finally{P(!1)}},zt=["Technology","Startup News","Events","Funding","Product Updates","Community","Mentorship","Industry Insights"],Ar={toolbar:[[{header:[1,2,3,4,5,6,!1]}],["bold","italic","underline","strike"],[{list:"ordered"},{list:"bullet"}],[{script:"sub"},{script:"super"}],[{indent:"-1"},{indent:"+1"}],[{direction:"rtl"}],[{color:[]},{background:[]}],[{align:[]}],["link","image","video"],["clean"]]};return e.jsx("div",{className:"min-h-screen bg-background p-6",children:e.jsxs("div",{className:"max-w-6xl mx-auto 
180space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsxs(R,{variant:"ghost",onClick:()=>r("/dashboard/admin/blog"),className:"flex items-center space-x-2",children:[e.jsx(Bt,{className:"w-4 h-4"}),e.jsx("span",{children:"Back to Blog Management"})]}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:n?"Edit Blog Post":"Create New Blog Post"}),e.jsx("p",{className:"text-muted-foreground",children:n?"Update your blog post details":"Create a new blog post for your audience"})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(R,{type:"button",variant:"secondary",onClick:ot,disabled:V||!a.title,children:V?"Generating...":"Generate Content with AI"}),e.jsxs(R,{onClick:yt,disabled:C,children:[e.jsx(wa,{className:"w-4 h-4 mr-2"}),C?"Saving...":n?"Update Post":"Create Post"]})]})]}),e.jsxs(zr,{defaultValue:"content",className:"space-y-4",children:[e.jsxs(Ur,{children:[e.jsx(Be,{value:"content",children:"Content"}),e.jsx(Be,{value:"settings",children:"Settings"}),e.jsx(Be,{value:"associations",children:"Associations"})]}),e.jsx(ze,{value:"content",children:e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsx(le,{children:"Content"})}),e.jsxs(Z,{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"title",children:"Title *"}),e.jsx(de,{id:"title",value:a.title,onChange:ee=>ie("title",ee.target.value),placeholder:"Enter post title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"slug",children:"Slug"}),e.jsx(de,{id:"slug",value:a.slug,onChange:ee=>ie("slug",ee.target.value),placeholder:"post-url-slug"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"excerpt",children:"Excerpt"}),e.jsx(de,{id:"excerpt",value:a.excerpt,onChange:ee=>ie("excerpt",ee.target.value),placeholder:"Brief description of the post"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{children:"Content *"}),e.jsxs(ut,{open:I,onOpenChange:D,children:[e.jsx(cn,{asChild:!0,children:e.jsxs(R,{type:"button",variant:"outline",size:"sm",onClick:z,children:[e.jsx(Nr,{className:"w-4 h-4 mr-2"}),"Insert from Media Library"]})}),e.jsxs(ht,{className:"max-w-4xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(mt,{children:[e.jsx(ft,{children:"Select Image from Media Library"}),e.jsx($t,{children:"Click on an image to insert it into your blog content"})]}),e.jsx("div",{className:"space-y-4",children:q?e.jsx("div",{className:"text-center py-8",children:"Loading media..."}):$.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Nr,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No media files found"}),e.jsx(R,{variant:"outline",className:"mt-4",onClick:()=>{D(!1),r("/dashboard/admin/media")},children:"Go to Media Library"})]}):e.jsx("div",{className:"grid grid-cols-3 gap-4",children:$.map(ee=>e.jsxs("div",{className:"border rounded-lg overflow-hidden cursor-pointer hover:shadow-lg transition-shadow",onClick:()=>he(ee.url),children:[e.jsx("div",{className:"aspect-video bg-muted",children:e.jsx("img",{src:ee.url,alt:ee.name,className:"w-full h-full object-cover"})}),e.jsx("div",{className:"p-2",children:e.jsx("p",{className:"text-xs truncate",title:ee.name,children:ee.name})})]},ee.name))})})]})]})]}),e.jsx(La,{ref:E,value:a.content,onChange:ee=>ie("content",ee),onChangeSelection:(ee,Ne,ke)=>{H(ee?ee.index:null)},modules:Ar,theme:"snow",className:"blog-content",style:{height:"400px",marginBottom:"50px"}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"image",children:"Hero Image"}),e.jsx("div",{className:"flex gap-2",children:e.jsxs(ut,{open:K,onOpenChange:M,children:[e.jsx(cn,{asChild:!0,children:e.jsxs(R,{type:"button",variant:"outline",onClick:ue,children:[e.jsx(Nr,{className:"w-4 h-4 mr-2"}),"Select from Library"]})}),e.jsxs(ht,{className:"max-w-4xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(mt,{children:[e.jsx(ft,{children:"Select Hero Image from Media Library"}),e.jsx($t,{children:"Click on an image to set it as the hero image"})]}),e.jsx("div",{className:"space-y-4",children:q?e.jsx("div",{className:"text-center py-8",children:"Loading media..."}):$.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Nr,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No media files found"}),e.jsx(R,{variant:"outline",className:"mt-4",onClick:()=>{M(!1),r("/dashboard/admin/media")}
180,children:"Go to Media Library"})]}):e.jsx("div",{className:"grid grid-cols-3 gap-4",children:$.map(ee=>e.jsxs("div",{className:"border rounded-lg overflow-hidden cursor-pointer hover:shadow-lg transition-shadow",onClick:()=>ne(ee.url),children:[e.jsx("div",{className:"aspect-video bg-muted",children:e.jsx("img",{src:ee.url,alt:ee.name,className:"w-full h-full object-cover"})}),e.jsx("div",{className:"p-2",children:e.jsx("p",{className:"text-xs truncate",title:ee.name,children:ee.name})})]},ee.name))})})]})]})}),a.image&&e.jsx("div",{className:"mt-2",children:e.jsx("img",{src:a.image,alt:"Preview",className:"max-w-xs h-32 object-cover rounded border"})})]})]})]})}),e.jsx(ze,{value:"settings",children:e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsx(le,{children:"Settings"})}),e.jsxs(Z,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Author *"}),e.jsxs(qa,{open:y,onOpenChange:f,children:[e.jsx(Va,{asChild:!0,children:e.jsxs(R,{variant:"outline",role:"combobox","aria-expanded":y,className:"w-full justify-between",children:[h?h.name:"Select author...",e.jsx(ui,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Wa,{className:"w-full p-0 bg-popover border shadow-md z-50",children:e.jsxs(Ra,{children:[e.jsx(Fa,{placeholder:"Search users..."}),e.jsxs(Ba,{children:[e.jsx(za,{children:"No user found."}),e.jsx(Ua,{children:i.map(ee=>e.jsxs(yn,{value:ee.name,onSelect:()=>Se(ee),className:"cursor-pointer",children:[e.jsx(pr,{className:`mr-2 h-4 w-4 ${(h==null?void 0:h.id)===ee.id?"opacity-100":"opacity-0"}`}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:ee.name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:ee.email})]})]},ee.id))})]})]})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"author_role",children:"Author Role"}),e.jsx(de,{id:"author_role",value:a.author_role,onChange:ee=>ie("author_role",ee.target.value),placeholder:"CEO, CTO, Founder, etc."})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"category",children:"Category *"}),e.jsxs(xe,{value:a.category,onValueChange:ee=>ie("category",ee),children:[e.jsx(ve,{className:"bg-background",children:e.jsx(ge,{placeholder:"Select category"})}),e.jsx(ye,{className:"bg-popover border shadow-md z-50",children:zt.map(ee=>e.jsx(J,{value:ee,children:ee},ee))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"status",children:"Status"}),e.jsxs(xe,{value:a.status,onValueChange:ee=>ie("status",ee),children:[e.jsx(ve,{className:"bg-background",children:e.jsx(ge,{})}),e.jsxs(ye,{className:"bg-popover border shadow-md z-50",children:[e.jsx(J,{value:"draft",children:"Draft"}),e.jsx(J,{value:"live",children:"Live"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"visibility",children:"Visibility"}),e.jsxs(xe,{value:a.visibility,onValueChange:ee=>ie("visibility",ee),children:[e.jsx(ve,{className:"bg-background",children:e.jsx(ge,{})}),e.jsxs(ye,{className:"bg-popover border shadow-md z-50",children:[e.jsx(J,{value:"public",children:"Public"}),e.jsx(J,{value:"protected",children:"Protected"}),e.jsx(J,{value:"private",children:"Private"})]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"read_time",children:"Estimated Read Time (minutes)"}),e.jsx(de,{id:"read_time",type:"number",min:"1",max:"60",value:a.read_time,onChange:ee=>ie("read_time",parseInt(ee.target.value)||5)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Tags"}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx(de,{value:S,onChange:ee=>O(ee.target.value),placeholder:"Add a tag",onKeyPress:ee=>ee.key==="Enter"&&(ee.preventDefault(),Ue())}),e.jsx(R,{type:"button",onClick:Ue,size:"sm",children:e.jsx(Ve,{className:"w-4 h-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:(ur=a.tags)==null?void 0:ur.map(ee=>e.jsxs(re,{variant:"secondary",className:"flex items-center gap-1",children:[ee,e.jsx("button",{type:"button",onClick:()=>be(ee),className:"ml-1 hover:text-destructive",children:e.jsx(Pr,{className:"w-3 h-3"})})]},ee))})]})]})]})}),e.jsx(ze,{value:"associations",children:e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsx(le,{children:"Associations"})}),e.jsxs(Z,{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Associated Event"}),e.jsxs(qa,{open:b,onOpenChange:p,children:[e.jsx(Va,{asChild:!0,children:e.jsxs(R,{variant:"outline",role:"combobox","aria-expanded":b,className:"w-full justify-between",children:[j?j.title:"Select an event (optional)",e.
180jsx(ui,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Wa,{className:"w-full p-0 bg-popover border shadow-md z-50",children:e.jsxs(Ra,{children:[e.jsx(Fa,{placeholder:"Search events..."}),e.jsxs(Ba,{children:[e.jsx(za,{children:"No event found."}),e.jsxs(Ua,{children:[e.jsxs(yn,{value:"no-event",onSelect:()=>Ae(null),className:"cursor-pointer",children:[e.jsx(pr,{className:`mr-2 h-4 w-4 ${j?"opacity-0":"opacity-100"}`}),"No event"]}),l.map(ee=>e.jsxs(yn,{value:ee.title,onSelect:()=>Ae(ee),className:"cursor-pointer",children:[e.jsx(pr,{className:`mr-2 h-4 w-4 ${(j==null?void 0:j.id)===ee.id?"opacity-100":"opacity-0"}`}),ee.title]},ee.id))]})]})]})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Associated Company"}),e.jsxs(qa,{open:g,onOpenChange:N,children:[e.jsx(Va,{asChild:!0,children:e.jsxs(R,{variant:"outline",role:"combobox","aria-expanded":g,className:"w-full justify-between",children:[x?x.name:"Select a company (optional)",e.jsx(ui,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Wa,{className:"w-full p-0 bg-popover border shadow-md z-50",children:e.jsxs(Ra,{children:[e.jsx(Fa,{placeholder:"Search companies..."}),e.jsxs(Ba,{children:[e.jsx(za,{children:"No company found."}),e.jsxs(Ua,{children:[e.jsxs(yn,{value:"no-company",onSelect:()=>Pe(null),className:"cursor-pointer",children:[e.jsx(pr,{className:`mr-2 h-4 w-4 ${x?"opacity-0":"opacity-100"}`}),"No company"]}),u.map(ee=>e.jsxs(yn,{value:ee.name,onSelect:()=>Pe(ee),className:"cursor-pointer",children:[e.jsx(pr,{className:`mr-2 h-4 w-4 ${(x==null?void 0:x.id)===ee.id?"opacity-100":"opacity-0"}`}),ee.name]},ee.id))]})]})]})})]})]})]}),e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsx(le,{className:"text-sm",children:"Association Benefits"})}),e.jsx(Z,{className:"text-sm text-muted-foreground",children:e.jsxs("ul",{className:"space-y-1",children:[e.jsxs("li",{children:["• ",e.jsx("strong",{children:"Event Association:"})," Links the blog post to an event, showing it in event-related content"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"Company Association:"})," Links the blog post to a company profile for better organization"]}),e.jsx("li",{children:"• Both associations are optional and can be used independently"})]})})]})]})]})})]})]})})},aM=()=>{var b;const[t,r]=_.useState(null),[n,a]=_.useState([]),[s,i]=_.useState([]),[o,l]=_.useState(!0),[c,u]=_.useState(""),[d,h]=_.useState(""),{campaignId:m}=Zr();Qr();const j=dn(),w=gt();_.useEffect(()=>{m&&(x(),v())},[m]),_.useEffect(()=>{const p=n.filter(g=>{const N=g.name.toLowerCase().includes(c.toLowerCase())||g.email.toLowerCase().includes(c.toLowerCase()),S=!d||g.sent_status===d;return N&&S});i(p)},[n,c,d]);const x=async()=>{try{const{data:p,error:g}=await k.from("newsletter_campaigns").select("*").eq("id",m).single();if(g)throw g;const{data:N,error:S}=await k.from("newsletter_campaign_lists").select(`
181          list_id,
182          newsletter_lists!inner(id, name, description)
183        `).eq("campaign_id",m);if(S)throw S;r({...p,target_lists:(N==null?void 0:N.map(O=>O.newsletter_lists))||[]})}catch(p){console.error("Error fetching campaign details:",p),j.toast.error({title:"Failed to fetch campaign details"})}},v=async()=>{try{l(!0);const{data:p,error:g}=await k.from("newsletter_campaign_lists").select("list_id").eq("campaign_id",m);if(g)throw g;if(!p||p.length===0){a([]);return}const N=p.map(I=>I.list_id),{data:S,error:O}=await k.from("newsletter_user_lists").select("user_id").in("list_id",N);if(O)throw O;if(!S||S.length===0){a([]);return}const C=[...new Set(S.map(I=>I.user_id))],{data:P,error:$}=await k.from("profiles").select("id, user_id, name, email, membership_level").in("user_id",C);if($)throw $;const A=(P||[]).map(I=>({id:I.id,user_id:I.user_id,name:I.name,email:I.email,membership_level:I.membership_level,sent_status:"pending",sent_at:null}));a(A)}catch(p){console.error("Error fetching campaign users:",p),j.toast.error({title:"Failed to fetch campaign users"})}finally{l(!1)}},y=p=>{switch(p){case"draft":return"bg-gray-100 text-gray-800";case"scheduled":return"bg-blue-100 text-blue-800";case"sent":return"bg-green-100 text-green-800";default:return"bg-gray-100 text-gray-800"}},f=p=>{switch(p){case"sent":return"bg-green-100 text-green-800";
183case"pending":return"bg-yellow-100 text-yellow-800";case"failed":return"bg-red-100 text-red-800";default:return"bg-gray-100 text-gray-800"}};return o?e.jsx("div",{className:"min-h-screen bg-background",children:e.jsx("div",{className:"flex items-center justify-center min-h-[60vh]",children:e.jsx(Qe,{size:128})})}):t?e.jsx("div",{className:"min-h-screen bg-background",children:e.jsx("main",{className:"py-8",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[e.jsxs("div",{className:"mb-6",children:[e.jsxs(R,{variant:"outline",onClick:()=>w("/dashboard/admin/newsletter"),className:"mb-4",children:[e.jsx(Bt,{className:"w-4 h-4 mr-2"}),"Back to Newsletter"]}),e.jsx("div",{className:"bg-gradient-to-r from-muted/50 to-muted rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx(St,{className:"w-6 h-6 text-primary"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-foreground",children:t.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Campaign Details & Recipients"})]})]}),e.jsxs("div",{className:"flex items-center space-x-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-lg font-bold text-primary",children:s.length}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Recipients"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-lg font-bold text-primary",children:s.filter(p=>p.sent_status==="sent").length}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Sent"})]}),e.jsx(re,{className:y(t.status),children:t.status.toUpperCase()})]})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsx("div",{className:"lg:col-span-1",children:e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsxs(le,{className:"flex items-center gap-2",children:[e.jsx(dr,{className:"w-5 h-5 text-primary"}),"Campaign Details"]})}),e.jsxs(Z,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(B,{className:"text-sm font-medium",children:"Subject"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:t.subject})]}),e.jsxs("div",{children:[e.jsx(B,{className:"text-sm font-medium",children:"Target Lists"}),e.jsx("div",{className:"mt-1 space-y-1",children:((b=t.target_lists)==null?void 0:b.map(p=>e.jsx(re,{variant:"outline",className:"text-xs",children:p.name},p.id)))||e.jsx("p",{className:"text-sm text-muted-foreground",children:"No lists selected"})})]}),e.jsxs("div",{children:[e.jsx(B,{className:"text-sm font-medium",children:"Created"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:new Date(t.created_at).toLocaleDateString()})]}),t.sent_at&&e.jsxs("div",{children:[e.jsx(B,{className:"text-sm font-medium",children:"Sent"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:new Date(t.sent_at).toLocaleDateString()})]}),t.content&&e.jsxs("div",{children:[e.jsx(B,{className:"text-sm font-medium",children:"Content Preview"}),e.jsx("div",{className:"mt-1 p-3 bg-muted/30 rounded-lg text-sm max-h-40 overflow-y-auto",children:t.content})]})]})]})}),e.jsx("div",{className:"lg:col-span-2",children:e.jsxs(Y,{children:[e.jsxs(ce,{children:[e.jsxs(le,{className:"flex items-center gap-2",children:[e.jsx(Ge,{className:"w-5 h-5 text-primary"}),"Recipients (",s.length,")"]}),e.jsxs("div",{className:"flex gap-4 mt-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(B,{className:"text-sm",children:"Search Recipients"}),e.jsx(de,{placeholder:"Search by name or email...",value:c,onChange:p=>u(p.target.value),className:"mt-1"})]}),e.jsxs("div",{className:"w-48",children:[e.jsx(B,{className:"text-sm",children:"Status"}),e.jsxs("select",{value:d,onChange:p=>h(p.target.value),className:"mt-1 w-full px-3 py-2 border border-border rounded-md text-sm bg-background",children:[e.jsx("option",{value:"",children:"All statuses"}),e.jsx("option",{value:"pending",children:"Pending"}),e.jsx("option",{value:"sent",children:"Sent"}),e.jsx("option",{value:"failed",children:"Failed"})]})]})]})]}),e.jsx(Z,{children:e.jsxs("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:[s.map(p=>e.jsxs("div",{className:"flex items-center justify-between bg-muted/30 p-3 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(pf,{className:"w-4 h-4 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:p.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:p.email})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(re,{variant:"outline",className:"text-xs",children:p.membership_level}),e.jsx(re,{className:`text-xs ${f(p.sent_status||"pending")}`,children:p.sent_status||"pending"}),p.sent_at&&e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(p.sent_at).toLocaleDateString()})]})]}
183,p.id)),s.length===0&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx(Ge,{className:"w-12 h-12 text-muted-foreground mx-auto mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-foreground mb-2",children:"No recipients found"}),e.jsx("p",{className:"text-muted-foreground",children:c||d?"Try adjusting your search criteria":"No users in selected lists"})]})]})})]})})]})]})})}):e.jsx("div",{className:"min-h-screen bg-background",children:e.jsx("div",{className:"flex items-center justify-center min-h-[60vh]",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mb-2",children:"Campaign not found"}),e.jsxs(R,{onClick:()=>w("/dashboard/admin/newsletter"),children:[e.jsx(Bt,{className:"w-4 h-4 mr-2"}),"Back to Newsletter"]})]})})})},sM=()=>{const[t,r]=_.useState([]),[n,a]=_.useState([]),[s,i]=_.useState([]),[o,l]=_.useState(!0),[c,u]=_.useState(""),[d,h]=_.useState("all"),[m,j]=_.useState(null),[w,x]=_.useState({name:"",description:"",list_type:"private"}),{user:v}=Qr(),y=dn(),f=gt();_.useEffect(()=>{if(!v){f("/login");return}b(),p(),g()},[v]),_.useEffect(()=>{let $=t;c&&($=$.filter(A=>{var I;return A.name.toLowerCase().includes(c.toLowerCase())||((I=A.description)==null?void 0:I.toLowerCase().includes(c.toLowerCase()))})),d!=="all"&&($=$.filter(A=>A.list_type===d)),a($)},[t,c,d]);const b=async()=>{if(!(v!=null&&v.id))return;const{data:$}=await k.from("admin_users").select("user_id").eq("user_id",v.id).maybeSingle(),{data:A}=await k.from("profiles").select("membership_level").eq("user_id",v.id).single();($==null?void 0:$.user_id)||(A==null?void 0:A.membership_level)==="admin"||(y.toast.error({title:"Access denied. Admin privileges required."}),f("/dashboard"))},p=async()=>{try{l(!0);const{data:$,error:A}=await k.from("newsletter_lists").select("*").order("name");if(A)throw A;const I=await Promise.all(($||[]).map(async D=>{const{count:q}=await k.from("newsletter_user_lists").select("*",{count:"exact",head:!0}).eq("list_id",D.id);return{...D,list_type:D.list_type,user_count:q||0}}));r(I)}catch($){console.error("Error fetching lists:",$),y.toast.error({title:"Failed to fetch lists"})}finally{l(!1)}},g=async()=>{try{const{data:{user:$}}=await k.auth.getUser();if(!$)return;const{data:A,error:I}=await k.rpc("get_all_profiles_for_admin",{requesting_user_id:$.id});if(I)throw I;i(A||[])}catch($){console.error("Error fetching users:",$),y.toast.error({title:"Failed to fetch users"})}},N=async()=>{try{if(!w.name.trim()){y.toast.error({title:"List name is required"});return}const{error:$}=await k.from("newsletter_lists").insert({name:w.name,description:w.description,list_type:w.list_type,created_by:v==null?void 0:v.id});if($)throw $;y.toast.success({title:"List created successfully"}),x({name:"",description:"",list_type:"private"}),p()}catch($){console.error("Error creating list:",$),y.toast.error({title:"Failed to create list"})}},S=async $=>{if(confirm("Are you sure you want to delete this list? This action cannot be undone."))try{const{error:A}=await k.from("newsletter_lists").delete().eq("id",$);if(A)throw A;y.toast.success({title:"List deleted successfully"}),p()}catch(A){console.error("Error deleting list:",A),y.toast.error({title:"Failed to delete list"})}},O=async($,A,I)=>{try{if(I){const{error:D}=await k.from("newsletter_user_lists").delete().eq("user_id",$).eq("list_id",A);if(D)throw D}else{const{error:D}=await k.from("newsletter_user_lists").insert({user_id:$,list_id:A});if(D)throw D}i(D=>D.map(q=>q.user_id===$?{...q,is_subscribed:!I}:q)),y.toast.success({title:I?"User removed from list":"User added to list"})}catch(D){console.error("Error updating user list subscription:",D),y.toast.error({title:"Failed to update subscription"})}},C=$=>{switch($){case"public":return"bg-green-100 text-green-800";case"member":return"bg-blue-100 text-blue-800";case"private":return"bg-gray-100 text-gray-800";default:return"bg-gray-100 text-gray-800"}},P=$=>{switch($){case"public":return"Public";case"member":return"Members Only";case"private":return"Private";default:return"Private"}};return o?e.jsx("div",{className:"min-h-screen bg-background",children:e.jsx("div",{className:"flex items-center justify-center min-h-[60vh]",children:e.jsx(Qe,{size:128})})}):e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("main",{className:"py-8",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[e.jsxs(R,{variant:"outline",onClick:()=>f("/dashboard/admin/newsletter"),className:"bg-background border-border",children:[e.jsx(Bt,{className:"w-4 h-4 mr-2"}),"Back to Newsletter"]}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Lists Management"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Create and manage newsletter lists with different access levels"})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"bg-card rounded-lg border p-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(B,{className:"text-sm",children:"Search Lists"}),e.jsx(de,{placeholder:"Search by name or description...",value:c,onChange:$=>u($.target.value),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(B,{className:"text-sm",children:"List Type"}),e.jsxs(xe,{value:d,onValueChange:h,children:[e.jsx(ve,{className:"mt-1",children:e.jsx(ge,{placeholder:"All types"})}),e.jsxs(ye,{children:[e.jsx(J,{value:"all",children:"All Types"}),e.jsx(J,{value:"public",children:"Public"}),e.jsx(J,{value:"member",children:"Members Only"}),e.jsx(J,{value:"private",children:"Private"})]})]})]})]})}),e.jsxs(Y,{children:[e.jsxs(ce,{children:[e.jsx(le,{children:"Create New List"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Create different types of newsletter lists for targeted campaigns"})]}),e.jsxs(Z,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(B,{children:"List Name"}),e.jsx(de,{value:w.name,onChange:$=>x(A=>({...A,name:$.target.value})),placeholder:"Enter list name"})]}),e.jsxs("div",{children:[e.jsx(B,{children:"List Type"}),e.jsxs(xe,{value:w.list_type,onValueChange:$=>x(A=>({...A,list_type:$})),children:[e.jsx(ve,{children:e.jsx(ge,{})}),e.jsxs(ye,{children:[e.jsx(J,{value:"private",children:"Private - Admin access only"}),e.jsx(J,{value:"member",children:"Members Only - For paid members"}),e.jsx(J,{value:"public",children:"Public - Open to everyone"})]})]})]})]}),e.jsxs("div",{children:[e.jsx(B,{children:"Description"}),e.jsx(Pt,{value:w.description,onChange:$=>x(A=>({...A,description:$.target.value})),placeholder:"Enter list description (optional)",rows:3})]}),e.jsxs(R,{onClick:N,className:"bg-primary hover:bg-primary-hover text-primary-foreground",children:[e.jsx(Ve,{className:"w-4 h-4 mr-2"}),"Create List"]})]})]}),e.jsx("div",{className:"space-y-3",children:n.map($=>e.jsx(Y,{className:"hover:shadow-sm transition-shadow border",children:e.jsx(Z,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h4",{className:"font-medium text-foreground",children:$.name}),e.jsx(re,{className:C($.list_type),children:P($.list_type)})]}),$.description&&e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:$.description}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[$.user_count||0," members • Created ",new Date($.created_at).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(R,{variant:"outline",size:"sm",onClick:()=>f(`/dashboard/admin/newsletter/lists/${$.id}`),children:[e.jsx(Fs,{className:"w-4 h-4 mr-1"}),"Manage Users"]}),e.jsxs(R,{variant:"outline",size:"sm",onClick:()=>S($.id),className:"text-destructive hover:bg-destructive hover:text-destructive-foreground",children:[e.jsx(We,{className:"w-4 h-4 mr-1"}),"Delete"]})]})]})})},$.id))}),n.length===0&&t.length>0&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx(pi,{className:"w-12 h-12 text-muted-foreground mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No lists match your search criteria"})]}),t.length===0&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx(pi,{className:"w-12 h-12 text-muted-foreground mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No lists created yet"})]})]})]})}),m&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-background border border-border rounded-lg w-full max-w-3xl max-h-[80vh] overflow-hidden",children:[e.jsx("div",{className:"p-6 border-b border-border",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-lg font-semibold text-foreground",children:["Manage Users - ",m.name]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(re,{className:C(m.list_type),children:P(m.list_type)}),m.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:m.description})]})]}),e.jsx(R,{variant:"outline",onClick:()=>j(null),children:"Close"})]})}),e.jsx("div",{className:"p-6 overflow-y-auto max-h-[60vh]",children:e.jsx("div",{className:"space-y-2",children:s.map($=>e.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted rounded-lg",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:$.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:$.email})]}),e.jsx(fo,{checked:$.is_subscribed||!1,onCheckedChange:A=>{O($.user_id,m.id,$.is_subscribed||!1)}})]},$.user_id))})})]})})]})},iM=()=>{const{listId:t}=Zr(),r=gt(),[n,a]=_.useState(null),[s,i]=_.useState([]),[o,l]=_.useState([]),[c,u]=_.useState(""),[d,h]=_.useState(!0),[m,j]=_.useState({totalSubscribers:0,newThisWeek:0,newThisMonth:0,growthRate:"+0%"});Qr();const w=dn();_.useEffect(()=>{t&&(x(),v())},[t]),_.useEffect(()=>{if(c){const g=s.filter(N=>N.name.toLowerCase().includes(c.toLowerCase())||N.email.toLowerCase().includes(c.toLowerCase()));l(g)}else l(s)},[c,s]);const x=async()=>{try{const{data:g,error:N}=await k.from("newsletter_lists").select("*").eq("id",t).single();if(N)throw N;a(g)}catch(g){console.error("Error fetching list:",g),w.toast.error({title:"Failed to load list details"})}},v=async()=>{try{h(!0);const{data:g,error:N}=await k.from("profiles").select("id, user_id, name, email, membership_level");if(N)throw N;const{data:S,error:O}=await k.from("newsletter_user_lists").select("user_id, subscribed_at").eq("list_id",t);if(O)throw O;const C=new Set((S==null?void 0:S.map(A=>A.user_id))||[]),P=new Map((S==null?void 0:S.map(A=>[A.user_id,A.subscribed_at]))||[]),$=(g==null?void 0:g.map(A=>({...A,is_subscribed:C.has(A.user_id),subscribed_at:P.get(A.user_id)})))||[];i($),y($,S||[])}catch(g){console.error("Error fetching users:",g),w.toast.error({title:"Failed to load users"})}finally{h(!1)}},y=(g,N)=>{const S=g.filter(D=>D.is_subscribed),O=new Date,C=new Date(O.getTime()-7*24*60*60*1e3),P=new Date(O.getTime()-30*24*60*60*1e3),$=N.filter(D=>new Date(D.subscribed_at)>=C).length,A=N.filter(D=>new Date(D.subscribed_at)>=P).length,I=S.length>0?`+${Math.round(A/S.length*100)}%`:"+0%";j({totalSubscribers:S.length,newThisWeek:$,newThisMonth:A,growthRate:
183I})},f=async(g,N)=>{try{if(N){const{error:S}=await k.from("newsletter_user_lists").delete().eq("list_id",t).eq("user_id",g);if(S)throw S;w.toast.success({title:"User removed from list"})}else{const{error:S}=await k.from("newsletter_user_lists").insert([{list_id:t,user_id:g}]);if(S)throw S;w.toast.success({title:"User added to list"})}await v()}catch(S){console.error("Error toggling subscription:",S),w.toast.error({title:"Failed to update subscription"})}},b=g=>{switch(g){case"public":return"bg-green-100 text-green-800";case"member":return"bg-blue-100 text-blue-800";case"private":return"bg-red-100 text-red-800";default:return"bg-gray-100 text-gray-800"}},p=g=>{switch(g){case"public":return"Public";case"member":return"Member Only";case"private":return"Private";default:return g}};return d&&!n?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Qe,{size:32}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:"Loading list details..."})]})}):n?e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsxs(R,{variant:"outline",onClick:()=>r("/dashboard/admin/newsletter/lists"),children:[e.jsx(Bt,{className:"w-4 h-4 mr-2"}),"Back to Lists"]}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:n.name}),e.jsxs("div",{className:"flex items-center space-x-2 mt-1",children:[e.jsx(re,{className:b(n.list_type),children:p(n.list_type)}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Created ",new Date(n.created_at).toLocaleDateString()]})]})]})]})}),n.description&&e.jsx(Y,{children:e.jsx(Z,{className:"pt-6",children:e.jsx("p",{className:"text-muted-foreground",children:n.description})})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsxs(Y,{children:[e.jsxs(ce,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(le,{className:"text-sm font-medium",children:"Total Subscribers"}),e.jsx(Ge,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Z,{children:e.jsx("div",{className:"text-2xl font-bold text-primary",children:m.totalSubscribers})})]}),e.jsxs(Y,{children:[e.jsxs(ce,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(le,{className:"text-sm font-medium",children:"New This Week"}),e.jsx(qt,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Z,{children:e.jsx("div",{className:"text-2xl font-bold text-green-600",children:m.newThisWeek})})]}),e.jsxs(Y,{children:[e.jsxs(ce,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(le,{className:"text-sm font-medium",children:"New This Month"}),e.jsx(St,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Z,{children:e.jsx("div",{className:"text-2xl font-bold text-blue-600",children:m.newThisMonth})})]}),e.jsxs(Y,{children:[e.jsxs(ce,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(le,{className:"text-sm font-medium",children:"Growth Rate"}),e.jsx(Jr,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Z,{children:e.jsx("div",{className:"text-2xl font-bold text-green-600",children:m.growthRate})})]})]}),e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(le,{className:"flex items-center gap-2",children:[e.jsx(Ge,{className:"w-5 h-5"}),"Manage Subscribers"]}
183),e.jsx("div",{className:"flex items-center space-x-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(tr,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground w-4 h-4"}),e.jsx(de,{placeholder:"Search users...",value:c,onChange:g=>u(g.target.value),className:"pl-10 w-64"})]})})]})}),e.jsx(Z,{children:d?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(Qe,{size:32}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:"Loading users..."})]}):e.jsxs(nt,{children:[e.jsx(at,{children:e.jsxs(pe,{children:[e.jsx(te,{children:"Subscribed"}),e.jsx(te,{children:"Name"}),e.jsx(te,{children:"Email"}),e.jsx(te,{children:"Membership Level"}),e.jsx(te,{children:"Subscribed Date"})]})}),e.jsx(st,{children:o.map(g=>e.jsxs(pe,{children:[e.jsx(X,{children:e.jsx(fo,{checked:g.is_subscribed,onCheckedChange:()=>f(g.user_id,g.is_subscribed||!1)})}),e.jsx(X,{className:"font-medium",children:g.name}),e.jsx(X,{children:g.email}),e.jsx(X,{children:e.jsx(re,{variant:"outline",className:"capitalize",children:g.membership_level})}),e.jsx(X,{children:g.is_subscribed&&g.subscribed_at?new Date(g.subscribed_at).toLocaleDateString():"-"})]},g.user_id))})]})})]})]}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-muted-foreground",children:"List not found"}),e.jsxs(R,{onClick:()=>r("/dashboard/admin/newsletter/lists"),className:"mt-4",children:[e.jsx(Bt,{className:"w-4 h-4 mr-2"}),"Back to Lists"]})]})},oM=[{value:"month",label:"Monthly"},{value:"year",label:"Yearly"}],lM=[{value:"eur",label:"EUR (€)"},{value:"usd",label:"USD ($)"},{value:"gbp",label:"GBP (£)"}],cM=()=>{const[t,r]=_.useState([]),[n,a]=_.useState(!0),[s,i]=_.useState(!1),[o,l]=_.useState(null),[c,u]=_.useState(!1),[d,h]=_.useState(null),[m,j]=_.useState(null),[w,x]=_.useState({name:"",description:"",price_cents:0,currency:"eur",interval:"year",features:[],is_active:!0,stripe_product_id:"",stripe_price_id:""}),[v,y]=_.useState("");_.useEffect(()=>{f()},[]);const f=async()=>{try{a(!0);const{data:A,error:I}=await k.from("membership_plans").select("*").order("display_order");if(I)throw I;const D=(A||[]).map(q=>({...q,features:Array.isArray(q.features)?q.features:null}));r(D)}catch(A){console.error("Error fetching plans:",A),W.error("Failed to load membership plans")}finally{a(!1)}},b=()=>{l(null),x({name:"",description:"",price_cents:0,currency:"eur",interval:"year",features:[],is_active:!0,stripe_product_id:"",stripe_price_id:""}),i(!0)},p=A=>{l(A),x({name:A.name,description:A.description||"",price_cents:A.price_cents,currency:A.currency,interval:A.interval,features:A.features||[],is_active:A.is_active,stripe_product_id:A.stripe_product_id||"",stripe_price_id:A.stripe_price_id||""}),i(!0)},g=async()=>{if(!w.name){W.error("Please enter a plan name");return}u(!0);try{const A={name:w.name,description:w.description||null,price_cents:w.price_cents,currency:w.currency,interval:w.interval,features:w.features.length>0?w.features:null,is_active:w.is_active,stripe_product_id:w.stripe_product_id||null,stripe_price_id:w.stripe_price_id||null};if(o){const{error:I}=await k.from("membership_plans").update(A).eq("id",o.id);if(I)throw I;W.success("Plan updated successfully")}else{const I=Math.max(...t.map(q=>q.display_order),0),{error:D}=await k.from("membership_plans").insert({...A,display_order:I+1});if(D)throw D;W.success("Plan created successfully")}i(!1),f()}catch(A){console.error("Error saving plan:",A),W.error(A.message||"Failed to save plan")}finally{u(!1)}},N=async A=>{if(confirm("Are you sure you want to delete this plan? This cannot be undone.")){h(A);try{const{error:I}=await k.from("membership_plans").delete().eq("id",A);if(I)throw I;W.success("Plan deleted successfully"),f()}catch(I){console.error("Error deleting plan:",I),W.error(I.message||"Failed to delete plan")}finally{h(null)}}},S=async A=>{try{const{error:I}=await k.from("membership_plans").update({is_active:!A.is_active}).eq("id",A.id);if(I)throw I;W.success(`Plan ${A.is_active?"deactivated":"activated"}`),f()}catch(I){console.error("Error toggling plan:",I),W.error("Failed to update plan")}},O=()=>{v.trim()&&(x(A=>({...A,features:[...A.features,v.trim()]})),y(""))},C=A=>{x(I=>({...I,features:I.features.filter((D,q)=>q!==A)}))},P=(A,I)=>new Intl.NumberFormat("de-DE",{style:"currency",currency:I.toUpperCase()}).format(A/100),$=async A=>{j(A);try{const{data:I,error:D}=await k.functions.invoke("sync-plan-to-stripe",{body:{planId:A}});if(D)throw D;
183if(I!=null&&I.error)throw new Error(I.error);W.success(I.message||"Plan synced to Stripe successfully"),f()}catch(I){console.error("Error syncing to Stripe:",I),W.error(I.message||"Failed to sync plan to Stripe")}finally{j(null)}};return n?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(At,{className:"h-8 w-8 animate-spin text-primary"})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(le,{children:"Membership Plans"}),e.jsx(ct,{children:"Configure your subscription plans and pricing"})]}),e.jsxs(R,{onClick:b,className:"gap-2",children:[e.jsx(Ve,{className:"h-4 w-4"}),"Add Plan"]})]})}),e.jsx(Z,{children:e.jsxs(nt,{children:[e.jsx(at,{children:e.jsxs(pe,{children:[e.jsx(te,{className:"w-12",children:"#"}),e.jsx(te,{children:"Plan Name"}),e.jsx(te,{children:"Price"}),e.jsx(te,{children:"Features"}),e.jsx(te,{children:"Stripe"}),e.jsx(te,{children:"Status"}),e.jsx(te,{className:"text-right",children:"Actions"})]})}),e.jsx(st,{children:t.length===0?e.jsx(pe,{children:e.jsx(X,{colSpan:7,className:"text-center text-muted-foreground py-8",children:"No membership plans configured"})}):t.map(A=>{var I;return e.jsxs(pe,{children:[e.jsx(X,{className:"text-muted-foreground",children:A.display_order}),e.jsx(X,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:A.name}),A.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:A.description})]})}),e.jsxs(X,{children:[e.jsx("div",{className:"font-medium",children:P(A.price_cents,A.currency)}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["per ",A.interval]})]}),e.jsx(X,{children:e.jsxs("div",{className:"text-sm text-muted-foreground",children:[((I=A.features)==null?void 0:I.length)||0," features"]})}),e.jsx(X,{children:A.stripe_price_id?e.jsx(re,{variant:"outline",className:"bg-primary/10 text-primary border-primary/30",children:"Connected"}):e.jsxs(R,{variant:"outline",size:"sm",onClick:()=>$(A.id),disabled:m===A.id,className:"gap-1.5",children:[m===A.id?e.jsx(At,{className:"h-3 w-3 animate-spin"}):e.jsx(_n,{className:"h-3 w-3"}),"Sync to Stripe"]})}),e.jsx(X,{children:e.jsx(Tt,{checked:A.is_active,onCheckedChange:()=>S(A)})}),e.jsx(X,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(R,{variant:"ghost",size:"icon",onClick:()=>p(A),children:e.jsx(Tn,{className:"h-4 w-4"})}),e.jsx(R,{variant:"ghost",size:"icon",onClick:()=>N(A.id),disabled:d===A.id,className:"text-destructive hover:text-destructive",children:d===A.id?e.jsx(At,{className:"h-4 w-4 animate-spin"}):e.jsx(We,{className:"h-4 w-4"})})]})})]},A.id)})})]})})]}),e.jsx(ut,{open:s,onOpenChange:i,children:e.jsxs(ht,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(mt,{children:[e.jsx(ft,{children:o?"Edit Plan":"Create New Plan"}),e.jsx($t,{children:o?"Update the membership plan details":"Add a new membership plan to your offerings"})]}),e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"name",children:"Plan Name *"}),e.jsx(de,{id:"name",value:w.name,onChange:A=>x({...w,name:A.target.value}),placeholder:"e.g., Startup, Business Angel"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"interval",children:"Billing Interval"}),e.jsxs(xe,{value:w.interval,onValueChange:A=>x({...w,interval:A}),children:[e.jsx(ve,{children:e.jsx(ge,{})}),e.jsx(ye,{children:oM.map(A=>e.jsx(J,{value:A.value,children:A.label},A.value))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"description",children:"Description"}),e.jsx(Pt,{id:"description",value:w.description,onChange:A=>x({...w,description:A.target.value}),placeholder:"Brief description of this plan",rows:2})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"price",children:"Price (in cents)"}),e.jsx(de,{id:"price",type:"number",value:w.price_cents,onChange:A=>x({...w,price_cents:parseInt(A.target.value)||0}),placeholder:"50000 = €500.00"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Display: ",P(w.price_cents,w.currency)]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"currency",children:"Currency"}),e.jsxs(xe,{value:w.currency,onValueChange:A=>x({...w,currency:A}),children:[e.jsx(ve,{children:e.jsx(ge,{})}),e.jsx(ye,{children:lM.map(A=>e.jsx(J,{value:A.value,children:A.label},A.value))})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(B,{children:"Features"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(de,{value:v,onCh
183ange:A=>y(A.target.value),placeholder:"Add a feature...",onKeyDown:A=>A.key==="Enter"&&(A.preventDefault(),O())}),e.jsx(R,{type:"button",variant:"outline",onClick:O,children:e.jsx(Ve,{className:"h-4 w-4"})})]}),w.features.length>0&&e.jsx("div",{className:"space-y-2 mt-2",children:w.features.map((A,I)=>e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted rounded-md",children:[e.jsx(gf,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"flex-1 text-sm",children:A}),e.jsx(R,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>C(I),children:e.jsx(Pr,{className:"h-3 w-3"})})]},I))})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:"Stripe Integration (Optional)"}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"stripe_product_id",children:"Stripe Product ID"}),e.jsx(de,{id:"stripe_product_id",value:w.stripe_product_id,onChange:A=>x({...w,stripe_product_id:A.target.value}),placeholder:"prod_..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"stripe_price_id",children:"Stripe Price ID"}),e.jsx(de,{id:"stripe_price_id",value:w.stripe_price_id,onChange:A=>x({...w,stripe_price_id:A.target.value}),placeholder:"price_..."})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted rounded-lg",children:[e.jsx(Tt,{id:"is_active",checked:w.is_active,onCheckedChange:A=>x({...w,is_active:A})}),e.jsx(B,{htmlFor:"is_active",className:"cursor-pointer",children:"Plan is active and available for purchase"})]})]}),e.jsxs(Vt,{children:[e.jsx(R,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(R,{onClick:g,disabled:c,children:[c&&e.jsx(At,{className:"h-4 w-4 mr-2 animate-spin"}),o?"Save Changes":"Create Plan"]})]})]})})]})},dM=()=>{var Ne,ke;const[t,r]=_.useState("subscriptions"),[n,a]=_.useState([]),[s,i]=_.useState([]),[o,l]=_.useState([]),[c,u]=_.useState(!0),[d,h]=_.useState(""),[m,j]=_.useState("all"),[w,x]=_.useState({totalActive:0,totalTrialing:0,monthlyRevenue:0,activeTrialCodes:0}),[v,y]=_.useState(!1),[f,b]=_.useState(!1),[p,g]=_.useState({code:"",plan_id:"",trial_days:14,max_redemptions:"",valid_until:"",notes:""}),[N,S]=_.useState(null),[O,C]=_.useState([]),[P,$]=_.useState(!1),[A,I]=_.useState(!1),[D,q]=_.useState(null),[F,K]=_.useState(!1),[M,E]=_.useState(!1),[Q,H]=_.useState(!1),[V,se]=_.useState(!1),[ue,z]=_.useState(""),[he,ne]=_.useState([]),[fe,De]=_.useState(!1),[Ce,Re]=_.useState({user_id:"",user_name:"",plan_id:"",period_end:""});_.useEffect(()=>{T()},[]);const T=async()=>{u(!0);try{const{data:G,error:_e}=await k.from("user_subscriptions").select(`
184          *,
185          membership_plans(id, name, price_cents, currency, interval)
186        `).order("created_at",{ascending:!1});console.log("Admin subscriptions fetch:",{subsData:G,subsError:_e});const U=[...new Set((G||[]).map(qe=>qe.user_id))];let oe=new Map;if(U.length>0){const{data:qe}=await k.from("profiles").select("user_id, name, email").in("user_id",U);oe=new Map((qe||[]).map(hn=>[hn.user_id,hn]))}const Te=[...new Set((G||[]).map(qe=>qe.trial_code_id).filter(Boolean))];let Xe=new Map;if(Te.length>0){const{data:qe}=await k.from("trial_codes").select("id, code").in("id",Te);Xe=new Map((qe||[]).map(hn=>[hn.id,hn]))}const lt=(G||[]).map(qe=>({...qe,profiles:oe.get(qe.user_id)||{name:"Unknown",email:""},trial_codes:qe.trial_code_id?Xe.get(qe.trial_code_id):null}));a(lt);const{data:Ze}=await k.from("trial_codes").select(`
187          *,
188          membership_plans(id, name)
189        `).order("created_at",{ascending:!1}),Ks=[...new Set((Ze||[]).map(qe=>qe.created_by).filter(Boolean))],{data:yr}=await k.from("profiles").select("user_id, name").in("user_id",Ks),Qo=new Map((yr||[]).map(qe=>[qe.user_id,qe])),hv=(Ze||[]).map(qe=>({...qe,profiles:qe.created_by?Qo.get(qe.created_by):void 0}));i(hv);const{data:mv}=await k.from("membership_plans").select("id, name, price_cents, currency, interval").eq("is_active",!0).order("display_order");l(mv||[]);const fv=(G||[]).filter(qe=>qe.status==="active").length,pv=(G||[]).filter(qe=>qe.status==="trialing").length,xv=(G||[]).filter(qe=>qe.status==="active"&&qe.stripe_subscription_id).reduce((qe,hn)=>{const Zo=hn.membership_plans;return Zo.interval==="year"?qe+Zo.price_cents/12:qe+Zo.price_cents},0);x({totalActive:fv,totalTrialing:pv,monthlyRevenue:xv,activeTrialCodes:(Ze||[]).filter(qe=>qe.is_active).length})}catch(G){console.error("Error fetching data:",G),W.error("Failed to load membership data")}finally{u(!1)}},ie=()=>{const G="ABCDEFGHJKMNPQRSTUVWXYZ23456789";let _e="";for(let U=0;U<8;U++)_e+=G.charAt(Math.floor(Math.random()*G.length));g({...p,code:_e})},Se=async()=>
189{if(!p.code||!p.plan_id){W.error("Please fill in required fields");return}b(!0);try{const{data:{user:G}}=await k.auth.getUser(),{error:_e}=await k.from("trial_codes").insert({code:p.code.toUpperCase(),plan_id:p.plan_id,trial_days:p.trial_days,max_redemptions:p.max_redemptions?parseInt(p.max_redemptions):null,valid_until:p.valid_until||null,notes:p.notes||null,created_by:G==null?void 0:G.id});if(_e)throw _e;W.success("Trial code created successfully"),y(!1),g({code:"",plan_id:"",trial_days:14,max_redemptions:"",valid_until:"",notes:""}),T()}catch(G){console.error("Error creating trial code:",G),W.error(G.message||"Failed to create trial code")}finally{b(!1)}},Ae=async(G,_e)=>{try{const{error:U}=await k.from("trial_codes").update({is_active:!_e}).eq("id",G);if(U)throw U;W.success(`Trial code ${_e?"deactivated":"activated"}`),T()}catch(U){console.error("Error toggling code:",U),W.error("Failed to update trial code")}},Pe=G=>{navigator.clipboard.writeText(G),W.success("Code copied to clipboard")},Ue=async G=>{S(G),$(!0);try{const{data:_e}=await k.from("trial_code_redemptions").select("id, redeemed_at, user_id").eq("trial_code_id",G).order("redeemed_at",{ascending:!1}),U=[...new Set((_e||[]).map(lt=>lt.user_id))],{data:oe}=await k.from("profiles").select("user_id, name, email").in("user_id",U),Te=new Map((oe||[]).map(lt=>[lt.user_id,lt])),Xe=(_e||[]).map(lt=>({id:lt.id,redeemed_at:lt.redeemed_at,profiles:Te.get(lt.user_id)||{name:"Unknown",email:""}}));C(Xe)}catch(_e){console.error("Error fetching redemptions:",_e)}finally{$(!1)}},be=async()=>{if(D){E(!0);try{const{data:G,error:_e}=await k.functions.invoke("manage-subscription",{body:{action:"cancel",subscriptionId:D.id,adminAction:!0,cancelImmediately:F}});if(_e)throw _e;if(G!=null&&G.error)throw new Error(G.error);W.success(F?"Subscription cancelled immediately":"Subscription will be cancelled at period end"),I(!1),q(null),K(!1),T()}catch(G){console.error("Error cancelling subscription:",G),W.error(G.message||"Failed to cancel subscription")}finally{E(!1)}}},ot=async G=>{try{const{data:_e,error:U}=await k.functions.invoke("manage-subscription",{body:{action:"reactivate",subscriptionId:G.id,adminAction:!0}});if(U)throw U;if(_e!=null&&_e.error)throw new Error(_e.error);W.success("Subscription reactivated"),T()}catch(_e){console.error("Error reactivating subscription:",_e),W.error(_e.message||"Failed to reactivate subscription")}},yt=async G=>{if(!G||G.length<2){ne([]);return}De(!0);try{const{data:_e,error:U}=await k.from("profiles").select("user_id, name, email").or(`name.ilike.%${G}%,email.ilike.%${G}%`).limit(10);if(U)throw U;ne(_e||[])}catch(_e){console.error("Error searching users:",_e),ne([])}finally{De(!1)}},zt=async()=>{if(!Ce.user_id||!Ce.plan_id||!Ce.period_end){W.error("Please fill in all required fields");return}se(!0);try{const G=new Date(Ce.period_end),_e=new Date;if(G<=_e){W.error("Period end must be in the future");return}const{data:U}=await k.from("user_subscriptions").select("id, status").eq("user_id",Ce.user_id).in("status",["active","trialing"]).single();if(U){W.error("User already has an active subscription");return}const{error:oe}=await k.from("user_subscriptions").insert({user_id:Ce.user_id,plan_id:Ce.plan_id,status:"active",current_period_start:_e.toISOString(),current_period_end:G.toISOString(),cancel_at_period_end:!1});if(oe)throw oe;W.success("Membership added successfully"),H(!1),Re({user_id:"",user_name:"",plan_id:"",period_end:""}),z(""),ne([]),T()}catch(G){console.error("Error adding membership:",G),W.error(G.message||"Failed to add membership")}finally{se(!1)}},Ar=(G,_e)=>{if(_e)return e.jsx(re,{variant:"outline",className:"text-orange-600 border-orange-600",children:"Cancelling"});switch(G){case"active":return e.jsx(re,{className:"bg-primary",children:"Active"});case"trialing":return e.jsx(re,{variant:"secondary",children:"Trial"});case"past_due":return e.jsx(re,{variant:"destructive",children:"Past Due"});case"cancelled":case"expired":return e.jsx(re,{variant:"secondary",children:"Expired"});default:return e.jsx(re,{variant:"secondary",children:G})}},ur=G=>new Intl.NumberFormat("de-DE",{style:"currency",currency:"EUR"}).format(G/100),ee=n.filter(G=>{var oe,Te,Xe,lt;const _e=!d||((Te=(oe=G.profiles)==null?void 0:oe.name)==null?void 0:Te.toLowerCase().includes(d.toLowerCase()))||((lt=(Xe=G.profiles)==null?void 0:Xe.email)==null?void 0:lt.toLowerCase().includes(d.toLowerCase())),U=m==="all"||G.status===m;return _e&&U});return c?e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Ka,{className:"w-12 h-12 text-muted-foreground mx-auto mb-4 animate-pulse"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading memberships..."})]})}):e.jsx("div",{className:"min-h-screen bg-background",children:e.jsxs("main",{className:"container mx-auto px-4 py-8 max-w-7xl",children:[e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(Ka,{className:"w-8 h-8 text-primary"}),e.jsx("h1",{className:"text-4xl font-bold text-foreground",children:"Memberships"})]}),e.jsx("p",{className:"text-muted-foreground",children:"Manage subscriptions, plans, and trial codes"})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 md:gap-4 mb-6",children:[e.jsx(Y,{children:e.jsx(Z,{className:"pt-4 md:pt-6 pb-4 md:pb-6",children:e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1 mb-1",children:[e.jsx(Ge,{className:"w-4 h-4 md:w-5 md:h-5 text-emerald-600"}),e.jsx("p",{className:"text-2xl md:text-3xl font-bold text-emerald-600",children:w.totalActive})]}),e.jsx("p",{className:"text-xs md:text-sm text-muted-foreground",children:"Active Members"})]})})}),e.jsx(Y,{children:e.jsx(Z,{className:"pt-4 md:pt-6 pb-4 md:pb-6",children:e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1 mb-1",children:[e.jsx(_r,{className:"w-4 h-4 md:w-5 md:h-5 text-amber-600"}),e.jsx("p",{className:"text-2xl md:text-3xl font-bold text-amber-600",children:w.totalTrialing})]}),e.jsx("p",{className:"text-xs md:text-sm text-muted-foreground",children:"Trial Users"})]})})}),e.jsx(Y,{className:"bg-gradient-to-br from-emerald-50 to-emerald-100/50 dark:from-emerald-950/30 dark:to-emerald-900/20 border-emerald-200/50",children:e.jsx(Z,{className:"pt-4 md:pt-6 pb-4 md:pb-6",children:e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1 mb-1",children:[e.jsx(Jr,{className:"w-4 h-4 md:w-5 md:h-5 text-emerald-600"}),e.jsx("p",{className:"text-2xl md:text-3xl font-bold text-emerald-600",children:ur(w.monthlyRevenue)})]}),e.jsx("p",{className:"text-xs md:text-sm text-muted-foreground",children:"Monthly Revenue"})]})})}),e.jsx(Y,{children:e.jsx(Z,{className:"pt-4 md:pt-6 pb-4 md:pb-6",children:e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1 mb-1",children:[e.jsx(Ka,{className:"w-4 h-4 md:w-5 md:h-5 text-blue-600"}),e.jsx("p",{className:"text-2xl md:text-3xl font-bold text-blue-600",children:w.activeTrialCodes})]}),e.jsx("p",{className:"text-xs md:text-sm text-muted-foreground",children:"Active Trial Codes"})]})})})]}),e.jsxs(zr,{value:t,onValueChange:r,children:[e.jsxs(Ur,{children:[e.jsx(Be,{value:"subscriptions",children:"Subscriptions"}),e.jsx(Be,{value:"plans",children:"Plans"}),e.jsx(Be,{value:"trial-codes",children:"Trial Codes"})]}),e.jsxs(ze,{value:"subscriptions",className:"space-y-4",children:[e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsx(le,{children:"All Subscriptions"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(tr,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(de,{placeholder:"Search by name or email...",value:d,onChange:G=>h(G.target.value),className:"pl-9 w-64"})]}),e.jsxs(xe,{value:m,onValueChange:j,children:[e.jsx(ve,{className:"w-32",children:e.jsx(ge,{})}),e.jsxs(ye,{children:[e.jsx(J,{value:"all",children:"All Status"}),e.jsx(J,{value:"active",children:"Active"}),e.jsx(J,{value:"trialing",children:"Trialing"}),e.jsx(J,{value:"past_due",children:"Past Due"}),e.jsx(J,{value:"cancelled",children:"Cancelled"})]})]}),e.jsxs(R,{onClick:()=>H(!0),children:[e.jsx(Fs,{className:"h-4 w-4 mr-2"}),"Add Membership"]})]})]})}),e.jsx(Z,{children:e.jsxs(nt,{children:[e.jsx(at,{children:e.jsxs(pe,{children:[e.jsx(te,{children:"User"}),e.jsx(te,{children:"Plan"}),e.jsx(te,{children:"Status"}),e.jsx(te,{children:"Price"}),e.jsx(te,{children:"Period End"}),e.jsx(te,{children:"Trial Code"}),e.jsx(te,{className:"text-right",children:"Actions"})]})}),e.jsx(st,{children:ee.length===0?e.jsx(pe,{children:e.jsx(X,{colSpan:7,className:"text-center text-muted-foreground py-8",children:"No subscriptions foun
189d"})}):ee.map(G=>{var _e,U,oe,Te,Xe,lt;return e.jsxs(pe,{children:[e.jsx(X,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:((_e=G.profiles)==null?void 0:_e.name)||"Unknown"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:(U=G.profiles)==null?void 0:U.email})]})}),e.jsx(X,{children:(oe=G.membership_plans)==null?void 0:oe.name}),e.jsx(X,{children:Ar(G.status,G.cancel_at_period_end)}),e.jsxs(X,{children:[ur(((Te=G.membership_plans)==null?void 0:Te.price_cents)||0),e.jsxs("span",{className:"text-muted-foreground text-xs",children:["/",(Xe=G.membership_plans)==null?void 0:Xe.interval]})]}),e.jsx(X,{children:Et(new Date(G.current_period_end),"MMM d, yyyy")}),e.jsx(X,{children:(lt=G.trial_codes)!=null&&lt.code?e.jsx(re,{variant:"outline",children:G.trial_codes.code}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsxs(X,{className:"text-right",children:[(G.status==="active"||G.status==="trialing")&&e.jsxs(Hn,{children:[e.jsx(Xn,{asChild:!0,children:e.jsx(R,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",children:e.jsx(xi,{className:"h-4 w-4"})})}),e.jsx(Yn,{align:"end",className:"bg-background border",children:G.cancel_at_period_end?e.jsxs(Ut,{onClick:()=>ot(G),className:"cursor-pointer",children:[e.jsx(vg,{className:"mr-2 h-4 w-4"}),"Reactivate Subscription"]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ut,{onClick:()=>{q(G),K(!1),I(!0)},className:"cursor-pointer",children:[e.jsx(qt,{className:"mr-2 h-4 w-4"}),"Cancel at Period End"]}),e.jsxs(Ut,{onClick:()=>{q(G),K(!0),I(!0)},className:"cursor-pointer text-destructive focus:text-destructive",children:[e.jsx(On,{className:"mr-2 h-4 w-4"}),"Cancel Immediately"]})]})})]}),G.status==="cancelled"&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Cancelled"})]})]},G.id)})})]})})]}),e.jsx(rr,{open:A,onOpenChange:I,children:e.jsxs(nr,{children:[e.jsxs(ar,{children:[e.jsx(sr,{children:F?"Cancel Subscription Immediately?":"Cancel at Period End?"}),e.jsx(ir,{children:F?e.jsxs(e.Fragment,{children:["This will immediately cancel ",e.jsx("strong",{children:(Ne=D==null?void 0:D.profiles)==null?void 0:Ne.name}),"'s subscription. They will lose access right away. This action cannot be undone."]}):e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:(ke=D==null?void 0:D.profiles)==null?void 0:ke.name}),"'s subscription will be cancelled at the end of the current billing period (",D&&Et(new Date(D.current_period_end),"MMM d, yyyy"),"). They will retain access until then."]})})]}),e.jsxs(or,{children:[e.jsx(lr,{disabled:M,children:"Cancel"}),e.jsxs(cr,{onClick:be,disabled:M,className:F?"bg-destructive hover:bg-destructive/90":"",children:[M&&e.jsx(At,{className:"mr-2 h-4 w-4 animate-spin"}),F?"Cancel Now":"Cancel at Period End"]})]})]})})]}),e.jsx(ze,{value:"plans",className:"space-y-4",children:e.jsx(cM,{})}),e.jsxs(ze,{value:"trial-codes",className:"space-y-4",children:[e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(le,{children:"Trial Codes"}),e.jsxs(ut,{open:v,onOpenChange:y,children:[e.jsx(cn,{asChild:!0,children:e.jsxs(R,{children:[e.jsx(Ve,{className:"h-4 w-4 mr-2"}),"Create Trial Code"]})}),e.jsxs(ht,{children:[e.jsxs(mt,{children:[e.jsx(ft,{children:"Create Trial Code"}),e.jsx($t,{children:"Create a new trial code for users to get free access"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Code *"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(de,{value:p.code,onChange:G=>g({...p,code:G.target.value.toUpperCase()}),placeholder:"TRIAL2024"}),e.jsx(R,{variant:"outline",onClick:ie,type:"button",children:"Generate"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Plan *"}),e.jsxs(xe,{value:p.plan_id,onValueChange:G=>g({...p,plan_id:G}),children:[e.jsx(ve,{children:e.jsx(ge,{placeholder:"Select plan"})}),e.jsx(ye,{children:o.map(G=>e.jsx(J,{value:G.id,children:G.name},G.id))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Trial Days"}),e.jsx(de,{type:"number",min:1,max:365,value:p.trial_days,onChange:G=>g({...p,trial_days:parseInt(G.target.value)||14})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Max Redemptions"}),e.jsx(de,{type:"number",min:1,placeholder:"Unlimited",value:p.max_redemptions,onChange:G=>g({...p,max_redemptions:G.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Valid Until"}
189),e.jsx(de,{type:"date",value:p.valid_until,onChange:G=>g({...p,valid_until:G.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Notes"}),e.jsx(Pt,{placeholder:"Internal notes about this code...",value:p.notes,onChange:G=>g({...p,notes:G.target.value})})]})]}),e.jsxs(Vt,{children:[e.jsx(R,{variant:"outline",onClick:()=>y(!1),children:"Cancel"}),e.jsxs(R,{onClick:Se,disabled:f,children:[f&&e.jsx(At,{className:"h-4 w-4 mr-2 animate-spin"}),"Create Code"]})]})]})]})]})}),e.jsx(Z,{children:e.jsxs(nt,{children:[e.jsx(at,{children:e.jsxs(pe,{children:[e.jsx(te,{children:"Code"}),e.jsx(te,{children:"Plan"}),e.jsx(te,{children:"Trial Days"}),e.jsx(te,{children:"Redemptions"}),e.jsx(te,{children:"Valid Until"}),e.jsx(te,{children:"Status"}),e.jsx(te,{children:"Actions"})]})}),e.jsx(st,{children:s.length===0?e.jsx(pe,{children:e.jsx(X,{colSpan:7,className:"text-center text-muted-foreground py-8",children:"No trial codes created yet"})}):s.map(G=>{var _e;return e.jsxs(pe,{children:[e.jsx(X,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"bg-muted px-2 py-1 rounded text-sm font-mono",children:G.code}),e.jsx(R,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>Pe(G.code),children:e.jsx(Zm,{className:"h-3 w-3"})})]})}),e.jsx(X,{children:(_e=G.membership_plans)==null?void 0:_e.name}),e.jsxs(X,{children:[G.trial_days," days"]}),e.jsx(X,{children:e.jsxs("span",{className:G.max_redemptions&&G.redemption_count>=G.max_redemptions?"text-destructive":"",children:[G.redemption_count,G.max_redemptions?` / ${G.max_redemptions}`:""]})}),e.jsx(X,{children:G.valid_until?Et(new Date(G.valid_until),"MMM d, yyyy"):"No expiry"}),e.jsx(X,{children:G.is_active?e.jsx(re,{className:"bg-green-500",children:"Active"}):e.jsx(re,{variant:"secondary",children:"Inactive"})}),e.jsx(X,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(R,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>Ue(G.id),children:e.jsx(dr,{className:"h-4 w-4"})}),e.jsx(R,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>Ae(G.id,G.is_active),children:e.jsx(iy,{className:"h-4 w-4"})})]})})]},G.id)})})]})})]}),e.jsx(ut,{open:!!N,onOpenChange:()=>S(null),children:e.jsxs(ht,{children:[e.jsxs(mt,{children:[e.jsx(ft,{children:"Code Redemptions"}),e.jsx($t,{children:"Users who have redeemed this trial code"})]}),P?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(At,{className:"h-6 w-6 animate-spin"})}):O.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No redemptions yet"}):e.jsxs(nt,{children:[e.jsx(at,{children:e.jsxs(pe,{children:[e.jsx(te,{children:"User"}),e.jsx(te,{children:"Redeemed At"})]})}),e.jsx(st,{children:O.map(G=>{var _e,U;return e.jsxs(pe,{children:[e.jsx(X,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:(_e=G.profiles)==null?void 0:_e.name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:(U=G.profiles)==null?void 0:U.email})]})}),e.jsx(X,{children:Et(new Date(G.redeemed_at),"MMM d, yyyy h:mm a")})]},G.id)})})]})]})})]})]}),e.jsx(ut,{open:Q,onOpenChange:H,children:e.jsxs(ht,{className:"sm:max-w-md",children:[e.jsxs(mt,{children:[e.jsx(ft,{children:"Add Manual Membership"}),e.jsx($t,{children:"Assign a membership to a user with a custom period end date."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"User *"}),Ce.user_id?e.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted rounded-lg",children:[e.jsx("div",{children:e.jsx("p",{className:"font-medium",children:Ce.user_name})}),e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>{Re({...Ce,user_id:"",user_name:""}),z("")},children:e.jsx(On,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(tr,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(de,{placeholder:"Search by name or email...",value:ue,onChange:G=>{z(G.target.value),yt(G.target.value)},className:"pl-9"})]}),fe&&e.jsx("div",{className:"flex items-center justify-center py-2",children:e.jsx(At,{className:"h-4 w-4 animate-spin"})}),he.length>0&&e.jsx("div",{className:"border rounded-lg max-h-40 overflow-y-auto",children:he.map(G=>e.jsxs("button",{className:"w-full text-left px-3 py-2 hover:bg-muted transition-colors border-b last:border-b-0",onClick:()=>{Re({...Ce,user_id:G.user_id,user_name:`${G.name} (${G.email})`}),ne([]),z("")},children:[e.jsx("p",{className:"font-medium text-sm",children:G.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:G.email})]},G.user_id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Membership Plan *"}),e.jsxs(xe,{value:Ce.plan_id,onValueChange:G=>Re({...Ce,plan_id:G}),children:[e.jsx(ve,{children:e.jsx(ge,{placeholder:"Select a plan"})}),e.jsx(ye,{children:o.map(G=>e.jsxs(J,{value:G.id,children:[G.name," (",ur(G.price_cents),"/",G.interval,")"]},G.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Period End Date *"}),e.jsx(de,{type:"date",value:Ce.period_end,onChange:G=>Re({...Ce,period_end:G.target.value}),min:new Date().toISOString().split("T")[0]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"The membership will be active until this date."})]})]}),e.jsxs(Vt,{children:[e.jsx(R,{variant:"outline",onClick:()=>{H(!1),Re({user_id:"",user_name:"",plan_id:"",period_end:""}),z(""),ne([])},children:"Cancel"}),e.jsx(R,{onClick:zt,disabled:V||!Ce.user_id||!Ce.plan_id||!Ce.period_end,children:V?e.jsxs(e.Fragment,{children:[e.jsx(At,{className:"mr-2 h-4 w-4 animate-spin"}),"Adding..."]}):"Add Membership"})]})]})})]})})},uM=()=>{const[t,r]=_.useState(!0),[n,a]=_.useState(""),[s,i]=_.useState({totalPairings:0,activePairings:0,completedPairings:0,totalCalls:0,totalCheckIns:0,seekingBuddies:0}),[o,l]=_.useState([]),[c,u]=_.useState([]),[d,h]=_.useState("overview");_.useEffect(()=>{m()},[]);const m=async()=>{r(!0);try{await Promise.all([j(),w(),x()])}catch(g){console.error("Error loading buddy program data:",g)}finally{r(!1)}},j=async()=>{const{data:g}=await k.from("buddy_pairings").select("status"),N=(g==null?void 0:g.filter($=>$.status==="active").length)||0,S=(g==null?void 0:g.filter($=>$.status==="completed").length)||0,{count:O}=await k.from("buddy_scheduled_calls").select("*",{count:"exact",head:!0}),{count:C}=await k.from("buddy_check_ins").select("*",{count:"exact",head:!0}),{count:P}=await k.from("buddy_preferences").select("*",{count:"exact",head:!0}).eq("status","seeking");i({totalPairings:(g==null?void 0:g.length)||0,activePairings:N,completedPairings:S,totalCalls:O||0,totalCheckIns:C||0,seekingBuddies:P||0})},w=async()=>{const{data:g}=await k.from("buddy_pairings").select("*").order("updated_at",{ascending:!1});if(!g){l([]);return}const N=[...new Set(g.flatMap(P=>[P.user_a_id,P.user_b_id]))],{data:S}=await k.from("profiles").select("user_id, name, first_name, last_name, avatar_url, email").in("user_id",N),O=new Map((S==null?void 0:S.map(P=>[P.user_id,P]))||[]),C=g.map(P=>({...P,user_a_profile:O.get(P.user_a_id),user_b_profile:O.get(P.user_b_id)}));l(C)},x=async()=>{const g=[],{data:N}=await k.from("buddy_scheduled_calls").select("id, pairing_id, scheduled_at, status, topic").order("created_at",{ascending:!1}).limit(20),{data:S}=await k.from("buddy_check_ins").select("id, pairing_id, created_at, mood, wins").order("created_at",{ascending:!1}).limit(20),O=[...new Set([...(N==null?void 0:N.map(D=>D.pairing_id))||[],...(S==null?void 0:S.map(D=>D.pairing_id))||[]])],{data:C}=await k.from("buddy_pairings").select("id, user_a_id, user_b_id").in("id",O),P=[...new Set((C==null?void 0:C.flatMap(D=>[D.user_a_id,D.user_b_id]))||[])],{data:$}=await k.from("profiles").select("user_id, name, first_name").in("user_id",P),A=new Map(($==null?void 0:$.map(D=>[D.user_id,D]))||[]),I=new Map((C==null?void 0:C.map(D=>[D.id,D]))||[]);
189N==null||N.forEach(D=>{const q=I.get(D.pairing_id),F=q?A.get(q.user_a_id):null,K=q?A.get(q.user_b_id):null;g.push({id:D.id,type:"call",created_at:D.scheduled_at,pairing_id:D.pairing_id,user_a_name:(F==null?void 0:F.first_name)||(F==null?void 0:F.name)||"Unknown",user_b_name:(K==null?void 0:K.first_name)||(K==null?void 0:K.name)||"Unknown",details:D.topic||"Buddy Call",status:D.status})}),S==null||S.forEach(D=>{var M;const q=I.get(D.pairing_id),F=q?A.get(q.user_a_id):null,K=q?A.get(q.user_b_id):null;g.push({id:D.id,type:"checkin",created_at:D.created_at,pairing_id:D.pairing_id,user_a_name:(F==null?void 0:F.first_name)||(F==null?void 0:F.name)||"Unknown",user_b_name:(K==null?void 0:K.first_name)||(K==null?void 0:K.name)||"Unknown",details:(M=D.wins)!=null&&M.length?`${D.wins.length} wins logged`:"Check-in"})}),g.sort((D,q)=>new Date(q.created_at).getTime()-new Date(D.created_at).getTime()),u(g.slice(0,30))},v=g=>g?g.first_name?g.last_name?`${g.first_name} ${g.last_name}`:g.first_name:g.name||"Unknown":"Unknown",y=g=>{var N,S;return g?g.first_name?`${g.first_name[0]}${((N=g.last_name)==null?void 0:N[0])||""}`:((S=g.name)==null?void 0:S.split(" ").map(O=>O[0]).join("").slice(0,2))||"?":"?"},f=o.filter(g=>{if(!n)return!0;const N=n.toLowerCase(),S=v(g.user_a_profile).toLowerCase(),O=v(g.user_b_profile).toLowerCase();return S.includes(N)||O.includes(N)}),b=g=>{switch(g){case"active":return e.jsx(re,{className:"bg-green-500/10 text-green-600 border-green-500/20",children:"Active"});case"completed":return e.jsx(re,{variant:"secondary",children:"Completed"});case"pending":return e.jsx(re,{variant:"outline",children:"Pending"});default:return e.jsx(re,{variant:"outline",children:g})}},p=g=>{switch(g){case"completed":return e.jsx(re,{className:"bg-green-500/10 text-green-600 border-green-500/20",children:"Completed"});case"confirmed":return e.jsx(re,{className:"bg-blue-500/10 text-blue-600 border-blue-500/20",children:"Confirmed"});case"pending":return e.jsx(re,{variant:"outline",children:"Pending"});case"cancelled":return e.jsx(re,{variant:"destructive",children:"Cancelled"});default:return null}};return t?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(At,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Buddy Program"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage and monitor buddy connections and activities"})]}),e.jsxs(R,{variant:"outline",onClick:m,children:[e.jsx(_n,{className:"h-4 w-4 mr-2"}),"Refresh"]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4",children:[e.jsx(Y,{children:e.jsx(Z,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-primary/10",children:e.jsx(Ge,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:s.totalPairings}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Pairings"})]})]})})}),e.jsx(Y,{children:e.jsx(Z,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-green-500/10",children:e.jsx(Nn,{className:"h-5 w-5 text-green-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:s.activePairings}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Active"})]})]})})}),e.jsx(Y,{children:e.jsx(Z,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-muted",children:e.jsx(Cv,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:s.completedPairings}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Completed"})]})]})})}),e.jsx(Y,{children:e.jsx(Z,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-blue-500/10",children:e.jsx(qd,{className:"h-5 w-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:s.totalCalls}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Calls"})]})]})})}),e.jsx(Y,{children:e.jsx(Z,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-purple-500/10",children:e.jsx(sn,{className:"h-5 w-5 text-purple-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:s.totalCheckIns}
189),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Check-ins"})]})]})})}),e.jsx(Y,{children:e.jsx(Z,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-amber-500/10",children:e.jsx(tr,{className:"h-5 w-5 text-amber-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:s.seekingBuddies}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Seeking"})]})]})})})]}),e.jsxs(zr,{value:d,onValueChange:h,children:[e.jsxs(Ur,{children:[e.jsxs(Be,{value:"overview",className:"gap-2",children:[e.jsx($l,{className:"h-4 w-4"}),"Activity Feed"]}),e.jsxs(Be,{value:"pairings",className:"gap-2",children:[e.jsx(Nn,{className:"h-4 w-4"}),"All Pairings"]})]}),e.jsx(ze,{value:"overview",className:"mt-4",children:e.jsxs(Y,{children:[e.jsxs(ce,{children:[e.jsxs(le,{className:"flex items-center gap-2",children:[e.jsx(Jr,{className:"h-5 w-5"}),"Recent Activity"]}),e.jsx(ct,{children:"Latest calls, check-ins and pairing updates"})]}),e.jsx(Z,{children:c.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx($l,{className:"h-12 w-12 mx-auto mb-3 opacity-30"}),e.jsx("p",{children:"No recent activity"})]}):e.jsx(Sl,{className:"h-[500px]",children:e.jsx("div",{className:"space-y-3",children:c.map(g=>e.jsxs("div",{className:"flex items-start gap-4 p-3 rounded-lg border bg-card hover:bg-muted/50 transition-colors",children:[e.jsx("div",{className:`p-2 rounded-lg ${g.type==="call"?"bg-blue-500/10":"bg-purple-500/10"}`,children:g.type==="call"?e.jsx(qd,{className:`h-4 w-4 ${g.type==="call"?"text-blue-600":"text-purple-600"}`}):e.jsx(sn,{className:"h-4 w-4 text-purple-600"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:"font-medium text-sm",children:[g.user_a_name," & ",g.user_b_name]}),g.type==="call"&&p(g.status)]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[g.type==="call"?"📞 ":"📝 ",g.details]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[e.jsx($r,{className:"h-3 w-3 inline mr-1"}),po(new Date(g.created_at),{addSuffix:!0})]})]})]},`${g.type}-${g.id}`))})})})]})}),e.jsx(ze,{value:"pairings",className:"mt-4",children:e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(le,{children:"All Buddy Pairings"}),e.jsx(ct,{children:"View and manage all buddy connections"})]}),e.jsxs("div",{className:"relative w-64",children:[e.jsx(tr,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(de,{placeholder:"Search by name...",value:n,onChange:g=>a(g.target.value),className:"pl-9"})]})]})}),e.jsx(Z,{children:f.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Ge,{className:"h-12 w-12 mx-auto mb-3 opacity-30"}),e.jsx("p",{children:"No pairings found"})]}):e.jsx(Sl,{className:"h-[500px]",children:e.jsx("div",{className:"space-y-3",children:f.map(g=>{var N,S,O,C;return e.jsxs("div",{className:"flex items-center gap-4 p-4 rounded-xl border bg-card hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsxs(Dr,{className:"h-10 w-10",children:[e.jsx(Mr,{src:((N=g.user_a_profile)==null?void 0:N.avatar_url)||void 0}),e.jsx(Ir,{children:y(g.user_a_profile)})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:v(g.user_a_profile)}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:(S=g.user_a_profile)==null?void 0:S.email})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(Nn,{className:"h-4 w-4 text-rose-500"})}),e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsxs(Dr,{className:"h-10 w-10",children:[e.jsx(Mr,{src:((O=g.user_b_profile)==null?void 0:O.avatar_url)||void 0}),e.jsx(Ir,{children:y(g.user_b_profile)})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:v(g.user_b_profile)}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:(C=g.user_b_profile)==null?void 0:C.email})]})]}),e.jsxs("div",{className:"flex items-center gap-4 shrink-0",children:[b(g.status),e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Matched ",Et(new Date(g.matched_at),"MMM d, yyyy")]}),g.match_score&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Score: ",g.match_score,"%"]})]})]})]},g.id)})})})})]})})]})]})},hM={Hotel:Qm,Rocket:vf,CalendarDays:hf,Users:Ge,Gift:_r},mM=()=>{const{user:t}=Qr(),r=gt(),n=td(),[a,s]=_.useState("all"),[i,o]=_.useState(""),{data:l=[],isLoading:c}=fi({queryKey:["admin-benefits"],queryFn:async()=>{const{data:b,error:p}=await k.from("member_benefits").select("*").order("display_order");if(p)throw p;return b}}),{data:u=[],isLoading:d}=fi({queryKey:["admin-benefit-orders"],queryFn:async()=>{const{data:b,error:p}=await k.from("benefit_orders").select(`
190          *,
191          member_benefits (*)
192        `).order("created_at",{ascending:!1});if(p)throw p;const g=[...new Set(b.map(O=>O.user_id))],{data:N}=await k.from("profiles").select("id, first_name, last_name, avatar_url").in("id",g),S=new Map((N==null?void 0:N.map(O=>[O.id,O]))||[]);return b.map(O=>({...O,profiles:S.get(O.user_id)||null}))}}),h=as({mutationFn:async b=>{const{error:p}=await k.from("member_benefits").delete().eq("id",b);if(p)throw p},onSuccess:()=>{n.invalidateQueries({queryKey:["admin-benefits"]}),W.success("Benefit deleted!")},onError:b=>{console.error("Error deleting benefit:",b),W.error("Failed to delete benef
192it")}}),m=as({mutationFn:async({orderId:b,status:p,adminNotes:g})=>{const N={status:p};p==="confirmed"?(N.confirmed_by=t.id,N.confirmed_at=new Date().toISOString()):p==="completed"&&(N.completed_at=new Date().toISOString()),g&&(N.admin_notes=g);const{error:S}=await k.from("benefit_orders").update(N).eq("id",b);if(S)throw S},onSuccess:()=>{n.invalidateQueries({queryKey:["admin-benefit-orders"]}),W.success("Order updated!"),o("")},onError:b=>{console.error("Error updating order:",b),W.error("Failed to update order")}}),j=b=>{r(`/dashboard/admin/benefits/${b.id}/edit`)},w=()=>{r("/dashboard/admin/benefits/new/edit")},x=b=>{switch(b){case"pending":return e.jsxs(re,{variant:"outline",className:"bg-yellow-50 text-yellow-700 border-yellow-200",children:[e.jsx($r,{className:"h-3 w-3 mr-1"}),"Pending"]});case"confirmed":return e.jsxs(re,{variant:"outline",className:"bg-blue-50 text-blue-700 border-blue-200",children:[e.jsx(Kr,{className:"h-3 w-3 mr-1"}),"Confirmed"]});case"completed":return e.jsxs(re,{variant:"outline",className:"bg-green-50 text-green-700 border-green-200",children:[e.jsx(Kr,{className:"h-3 w-3 mr-1"}),"Completed"]});case"cancelled":return e.jsxs(re,{variant:"outline",className:"bg-red-50 text-red-700 border-red-200",children:[e.jsx(On,{className:"h-3 w-3 mr-1"}),"Cancelled"]});default:return e.jsx(re,{variant:"outline",children:b})}},v=b=>(b?hM[b]:_r)||_r,y={totalOrders:u.length,pendingOrders:u.filter(b=>b.status==="pending").length,confirmedOrders:u.filter(b=>b.status==="confirmed").length,completedOrders:u.filter(b=>b.status==="completed").length,activeBenefits:l.filter(b=>b.is_active).length},f=a==="all"?u:u.filter(b=>b.status===a);return c||d?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx(At,{className:"h-8 w-8 animate-spin text-primary"})}):e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Benefits Management"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage member benefits and process orders"})]}),e.jsxs(R,{onClick:w,children:[e.jsx(Ve,{className:"h-4 w-4 mr-2"}),"Add Benefit"]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[e.jsx(Y,{children:e.jsx(Z,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(Av,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:y.totalOrders}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Orders"})]})]})})}),e.jsx(Y,{children:e.jsx(Z,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-yellow-100 flex items-center justify-center",children:e.jsx($r,{className:"h-5 w-5 text-yellow-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:y.pendingOrders}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Pending"})]})]})})}),e.jsx(Y,{children:e.jsx(Z,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-blue-100 flex items-center justify-center",children:e.jsx(Kr,{className:"h-5 w-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:y.confirmedOrders}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Confirmed"})]})]})})}),e.jsx(Y,{children:e.jsx(Z,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-green-100 flex items-center justify-center",children:e.jsx(Jr,{className:"h-5 w-5 text-green-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:y.completedOrders}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Completed"})]})]})})}),e.jsx(Y,{children:e.jsx(Z,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-purple-100 flex items-center justify-center",children:e.jsx(_r,{className:"h-5 w-5 text-purple-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:y.activeBenefits}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Active Benefits"})]})]})})})]}),e.jsxs(zr,{defaultValue:"orders",className:"space-y-6",children:[e.jsxs(Ur,{children:[e.jsxs(Be,{value:"orders",children:["Orders (",u.length,")"]}),e.jsxs(Be,{value:"catalog",children:["Benefits Catalog (",l.length,")"]})]}),e.jsxs(ze,{value:"orders",className:"space-y-4",children:[e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs(xe,{value:a,onValueChange:s,children:[e.jsx(ve,{className:"w-40",children:e.jsx(ge,{placeholder:"Filter by status"})}),e.jsxs(ye,{children:[e.jsx(J,{value:"all",children:"All Status"}),e.jsx(J,{value:"pending",children:"Pending"}),e.jsx(J,{value:"confirmed",children:"Confirmed"}),e.jsx(J,{value:"completed",children:"Completed"}),e.jsx(J,{value:"cancelled",children:"Cancelled"})]})]})}),e.jsx(Y,{children:e.jsxs(nt,{children:[e.jsx(at,{children:e.jsxs(pe,{children:[e.jsx(te,{children:"Member"}),e.jsx(te,{children:"Benefit"}),e.jsx(te,{children:"Requested"}),e.jsx(te,{children:"Status"}),e.jsx(te,{children:"Notes"}),e.jsx(te,{className:"text-right",children:"Actions"})]})}),e.jsx(st,{children:f.length===0?e.jsx(pe,{children:e.jsx(X,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No orders found"})}):f.map(b=>{var N;const p=b.profiles,g=p&&`${p.first_name||""} ${p.last_name||""}`.trim()||"Unknown";return e.jsxs(pe,{children:[e.jsx(X,{children:e.jsx("div",{className:"font-medium",children:g})}),e.jsx(X,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[(()=>{var O;const S=v(((O=b.member_benefits)==null?void 0:O.icon)||null);return e.jsx(S,{className:"h-4 w-4 text-muted-foreground"})})(),e.jsx("span",{children:((N=b.member_benefits)==null?void 0:N.name)||"Unknown"})]})}),e.jsx(X,{children:Et(new Date(b.created_at),"MMM d, yyyy")}),e.jsx(X,{children:x(b.status)}),e.jsx(X,{className:"max-w-[200px] truncate",children:b.notes||"-"}),e.jsx(X,{className:"text-right",children:e.jsxs(Hn,{children:[e.jsx(Xn,{asChild:!0,children:e.jsx(R,{variant:"ghost",size:"icon",children:e.jsx(xi,{className:"h-4 w-4"})})}),e.jsxs(Yn,{align:"end",children:[b.status==="pending"&&e.jsxs(Ut,{onClick:()=>m.mutate({orderId:b.id,status:"confirmed"}),children:[e.jsx(Kr,{className:"h-4 w-4 mr-2"}),"Confirm"]}),b.status==="confirmed"&&e.jsxs(Ut,{onClick:()=>m.mutate({orderId:b.id,status:"completed"}),children:[e.jsx(Kr,{className:"h-4 w-4 mr-2"}),"Mark Complete"]}
192),b.status!=="cancelled"&&b.status!=="completed"&&e.jsxs(Ut,{onClick:()=>m.mutate({orderId:b.id,status:"cancelled"}),className:"text-destructive",children:[e.jsx(On,{className:"h-4 w-4 mr-2"}),"Cancel"]})]})]})})]},b.id)})})]})})]}),e.jsx(ze,{value:"catalog",className:"space-y-4",children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:l.map(b=>{const p=v(b.icon),g=u.filter(N=>N.benefit_id===b.id).length;return e.jsxs(Y,{className:b.is_active?"":"opacity-60",children:[e.jsx(ce,{className:"pb-2",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(p,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(le,{className:"text-base",children:b.name}),e.jsxs(ct,{className:"text-xs",children:[g," orders"]})]})]}),e.jsxs(Hn,{children:[e.jsx(Xn,{asChild:!0,children:e.jsx(R,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(xi,{className:"h-4 w-4"})})}),e.jsxs(Yn,{align:"end",children:[e.jsxs(Ut,{onClick:()=>j(b),children:[e.jsx(En,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(Ut,{onClick:()=>h.mutate(b.id),className:"text-destructive",children:[e.jsx(We,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})]})}),e.jsxs(Z,{children:[e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:b.short_description||b.description}),e.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[e.jsx(re,{variant:b.is_active?"default":"secondary",children:b.is_active?"Active":"Inactive"}),e.jsx(re,{variant:"outline",children:b.category})]})]})]},b.id)})})})]})]})},Vm=[{value:"Hotel",label:"Hotel",icon:Qm},{value:"Rocket",label:"Rocket",icon:vf},{value:"CalendarDays",label:"Calendar",icon:hf},{value:"Users",label:"Users",icon:Ge},{value:"Gift",label:"Gift",icon:_r}],fM=[{value:"accommodation",label:"Accommodation"},{value:"event",label:"Event Access"},{value:"networking",label:"Networking"}],pM={name:"",description:"",short_description:"",category:"event",icon:"Gift",terms:"",max_orders_per_user:"",total_available:"",available_slots:"",price:"0",price_label:"",is_active:!0,display_order:0,image_url:""},xM=()=>{var g;const{benefitId:t}=Zr(),r=gt(),n=td(),a=t==="new",[s,i]=_.useState(pM),[o,l]=_.useState(null),[c,u]=_.useState(null),[d,h]=_.useState(!1),{data:m,isLoading:j}=fi({queryKey:["admin-benefit",t],queryFn:async()=>{if(a)return null;const{data:N,error:S}=await k.from("member_benefits").select("*").eq("id",t).single();if(S)throw S;return N},enabled:!a});_.useEffect(()=>{var N,S,O,C;m&&(i({name:m.name||"",description:m.description||"",short_description:m.short_description||"",category:m.category||"event",icon:m.icon||"Gift",terms:m.terms||"",max_orders_per_user:((N=m.max_orders_per_user)==null?void 0:N.toString())||"",total_available:((S=m.total_available)==null?void 0:S.toString())||"",available_slots:((O=m.available_slots)==null?void 0:O.toString())||"",price:((C=m.price)==null?void 0:C.toString())||"0",price_label:m.price_label||"",is_active:m.is_active??!0,display_order:m.display_order||0,image_url:m.image_url||""}),m.image_url&&u(m.image_url))},[m]);const w=async N=>{const S=N.name.split(".").pop(),C=`benefit-images/${`${crypto.randomUUID()}.${S}`}`,{error:P}=await k.storage.from("event-images").upload(C,N);if(P)throw P;const{data:$}=k.storage.from("event-images").getPublicUrl(C);return $.publicUrl},x=as({mutationFn:async()=>{h(!0);let N=s.image_url;o&&(N=await w(o));const S={name:s.name,description:s.description||null,short_description:s.short_description||null,category:s.category,icon:s.icon,terms:s.terms||null,max_orders_per_user:s.max_orders_per_user?parseInt(s.max_orders_per_user):null,total_available:s.total_available?parseInt(s.total_available):null,available_slots:s.available_slots?parseInt(s.available_slots):null,price:s.price?parseFloat(s.price):0,price_label:s.price_label||null,is_active:s.is_active,display_order:s.display_order,image_url:N||null};if(a){const{error:O}=await k.from("member_benefits").insert(S);if(O)throw O}else{const{error:O}=await k.from("member_benefits").update(S).eq("id",t);if(O)throw O}},onSuccess:()=>{n.invalidateQueries({queryKey:["admin-benefits"]}),n.invalidateQueries({queryKey:["member-benefits"]}),W.success(a?"Benefit created!":"Benefit updated!"),r("/dashboard/admin/benefits")},onError:N=>{console.error("Error saving benefit:",N),W.error("Failed to save benef
192it")},onSettled:()=>{h(!1)}}),v=as({mutationFn:async()=>{const{error:N}=await k.from("member_benefits").delete().eq("id",t);if(N)throw N},onSuccess:()=>{n.invalidateQueries({queryKey:["admin-benefits"]}),W.success("Benefit deleted!"),r("/dashboard/admin/benefits")},onError:N=>{console.error("Error deleting benefit:",N),W.error("Failed to delete benefit")}}),y=N=>{var O;const S=(O=N.target.files)==null?void 0:O[0];if(S){if(S.size>5*1024*1024){W.error("Image must be less than 5MB");return}l(S),u(URL.createObjectURL(S))}},f=()=>{l(null),u(null),i({...s,image_url:""})},b=N=>{if(N.preventDefault(),!s.name){W.error("Name is required");return}x.mutate()};if(j)return e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx(At,{className:"h-8 w-8 animate-spin text-primary"})});const p=((g=Vm.find(N=>N.value===s.icon))==null?void 0:g.icon)||_r;return e.jsxs("div",{className:"p-6 max-w-4xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(R,{variant:"ghost",size:"icon",onClick:()=>r("/dashboard/admin/benefits"),children:e.jsx(Bt,{className:"h-5 w-5"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"text-2xl font-bold",children:a?"Create Benefit":"Edit Benefit"}),e.jsx("p",{className:"text-muted-foreground",children:a?"Add a new member benefit":`Editing: ${m==null?void 0:m.name}`})]}),!a&&e.jsxs(rr,{children:[e.jsx(ss,{asChild:!0,children:e.jsxs(R,{variant:"destructive",size:"sm",children:[e.jsx(We,{className:"h-4 w-4 mr-2"}),"Delete"]})}),e.jsxs(nr,{children:[e.jsxs(ar,{children:[e.jsx(sr,{children:"Delete Benefit?"}),e.jsx(ir,{children:"This will permanently delete this benefit. Existing orders will be preserved but the benefit will no longer be available."})]}),e.jsxs(or,{children:[e.jsx(lr,{children:"Cancel"}),e.jsx(cr,{onClick:()=>v.mutate(),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]}),e.jsxs("form",{onSubmit:b,className:"space-y-6",children:[e.jsxs(Y,{children:[e.jsxs(ce,{children:[e.jsxs(le,{className:"flex items-center gap-2",children:[e.jsx(Nr,{className:"h-5 w-5"}),"Benefit Image"]}),e.jsx(ct,{children:"Upload a high-quality image for this benefit (recommended: 1200x600px)"})]}),e.jsx(Z,{children:e.jsxs("div",{className:"space-y-4",children:[c?e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:c,alt:"Benefit preview",className:"w-full h-64 object-cover rounded-lg border"}),e.jsx(R,{type:"button",variant:"destructive",size:"icon",className:"absolute top-2 right-2",onClick:f,children:e.jsx(Pr,{className:"h-4 w-4"})})]}):e.jsxs("label",{className:"flex flex-col items-center justify-center w-full h-64 border-2 border-dashed rounded-lg cursor-pointer bg-muted/50 hover:bg-muted transition-colors",children:[e.jsxs("div",{className:"flex flex-col items-center justify-center pt-5 pb-6",children:[e.jsx(ff,{className:"h-10 w-10 text-muted-foreground mb-3"}),e.jsxs("p",{className:"mb-2 text-sm text-muted-foreground",children:[e.jsx("span",{className:"font-semibold",children:"Click to upload"})," or drag and drop"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"PNG, JPG or WebP (max 5MB)"})]}),e.jsx("input",{type:"file",className:"hidden",accept:"image/*",onChange:y})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"image_url",children:"Or enter image URL"}),e.jsx(de,{id:"image_url",value:s.image_url,onChange:N=>{i({...s,image_url:N.target.value}),N.target.value&&!o&&u(N.target.value)},placeholder:"https://example.com/image.jpg"})]})]})})]}),e.jsxs(Y,{children:[e.jsxs(ce,{children:[e.jsx(le,{children:"Basic Information"}),e.jsx(ct,{children:"Essential details about the benefit"})]}),e.jsxs(Z,{className:"space-y-4",children:[e.jsxs("div",{className:"grid md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"name",children:"Name *"}),e.jsx(de,{id:"name",value:s.name,onChange:N=>i({...s,name:N.target.value}),placeholder:"e.g., Accommodation",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"category",children:"Category"}),e.jsxs(xe,{value:s.category,onValueChange:N=>i({...s,category:N}),children:[e.jsx(ve,{children:e.jsx(ge,{})}),e.jsx(ye,{children:fM.map(N=>e.jsx(J,{value:N.value,children:N.label},N.value))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"short_description",children:"Short Description"}),e.jsx(de,{id:"short_description",value:s.short_description,onChange:N=>i({...s,short_description:N.target.value}),placeholder:"Brief summary shown on benefit cards"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"description",children:"Full Description"}),e.jsx(Pt,{id:"description",value:s.description,onChange:N=>i({...s,description:N.target.value}),placeholder:"Detailed description of what's included in this benefit",rows:4})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"icon",children:"Icon"}),e.jsxs(xe,{value:s.icon,onValueChange:N=>i({...s,icon:N}),children:[e.jsx(ve,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{className:"h-4 w-4"}),e.jsx(ge,{})]})}),e.jsx(ye,{children:Vm.map(N=>e.jsx(J,{value:N.value,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N.icon,{className:"h-4 w-4"}),N.label]})},N.value))})]})]})]})]}),e.jsxs(Y,{children:[e.jsxs(ce,{children:[e.jsxs(le,{className:"flex items-center gap-2",children:[e.jsx(Vd,{className:"h-5 w-5"}),"Pricing"]}),e.jsx(ct,{children:"Set the price for this benefit"})]}),e.jsx(Z,{className:"space-y-4",children:e.jsxs("div",{className:"grid md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"price",children:"Price (€)"}),e.jsxs("div",{className:"relative",children:[e.jsx(Vd,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(de,{id:"price",type:"number",step:"0.01",min:"0",value:s.price,onChange:N=>i({...s,price:N.target.value}),className:"pl-9",placeholder:"0.00"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Set to 0 for benef
192its included in membership"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"price_label",children:"Price Label (optional)"}),e.jsx(de,{id:"price_label",value:s.price_label,onChange:N=>i({...s,price_label:N.target.value}),placeholder:"e.g., €150 per night, Included in membership"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Custom label shown instead of raw price"})]})]})})]}),e.jsxs(Y,{children:[e.jsxs(ce,{children:[e.jsx(le,{children:"Availability & Limits"}),e.jsx(ct,{children:"Control inventory and order limits"})]}),e.jsxs(Z,{className:"space-y-4",children:[e.jsxs("div",{className:"grid md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"total_available",children:"Total Capacity"}),e.jsx(de,{id:"total_available",type:"number",min:"0",value:s.total_available,onChange:N=>i({...s,total_available:N.target.value}),placeholder:"Unlimited"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Maximum total orders ever"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"available_slots",children:"Available Slots"}),e.jsx(de,{id:"available_slots",type:"number",min:"0",value:s.available_slots,onChange:N=>i({...s,available_slots:N.target.value}),placeholder:"Unlimited"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Current available inventory"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"max_orders_per_user",children:"Max per User"}),e.jsx(de,{id:"max_orders_per_user",type:"number",min:"0",value:s.max_orders_per_user,onChange:N=>i({...s,max_orders_per_user:N.target.value}),placeholder:"Unlimited"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Leave empty for unlimited"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"display_order",children:"Display Order"}),e.jsx(de,{id:"display_order",type:"number",value:s.display_order,onChange:N=>i({...s,display_order:parseInt(N.target.value)||0}),placeholder:"0"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Lower numbers appear first. First item is featured."})]})]})]}),e.jsxs(Y,{children:[e.jsxs(ce,{children:[e.jsx(le,{children:"Terms & Status"}),e.jsx(ct,{children:"Terms of use and visibility settings"})]}),e.jsxs(Z,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"terms",children:"Terms & Conditions"}),e.jsx(Pt,{id:"terms",value:s.terms,onChange:N=>i({...s,terms:N.target.value}),placeholder:"Terms and conditions for this benefit (shown to members before ordering)",rows:3})]}),e.jsx(ny,{}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{htmlFor:"is_active",children:"Active"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"When enabled, this benefit is visible to members"})]}),e.jsx(Tt,{id:"is_active",checked:s.is_active,onCheckedChange:N=>i({...s,is_active:N})})]})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-4 sticky bottom-4 bg-background p-4 rounded-lg border shadow-lg",children:[e.jsx(R,{type:"button",variant:"outline",onClick:()=>r("/dashboard/admin/benefits"),children:"Cancel"}),e.jsx(R,{type:"submit",disabled:x.isPending||d,children:x.isPending||d?e.jsxs(e.Fragment,{children:[e.jsx(At,{className:"h-4 w-4 mr-2 animate-spin"}),d?"Uploading...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(wa,{className:"h-4 w-4 mr-2"}),a?"Create Benefit":"Save Changes"]})})]})]})]})};var Qt={top:"top",left:"left",right:"right",bottom:"bottom"};function vM(t){var r=t.labelOffset,n=t.labelProps,a=t.orientation,s=t.range,i=t.tickLabelFontSize,o=t.tickLength,l=a===Qt.left||a===Qt.top?-1:1,c,u,d;if(a===Qt.top||a===Qt.bottom){var h=a===Qt.bottom&&typeof n.fontSize=="number"?n.fontSize:0;c=(Number(s[0])+Number(s[s.length-1]))/2,u=l*(o+r+i+h)}else c=l*((Number(s[0])+Number(s[s.length-1]))/2),u=-(o+r),d="rotate("+l*90+")";return{x:c,y:u,transform:d}}function es(){return es=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},es.apply(this,arguments)}function gM(t){var r=t.hideTicks,n=t.horizontal,a=t.orientation,s=t.tickClassName,i=t.tickComponent,o=t.tickLabelProps,l=t.tickStroke,c=l===void 0?"#222":l,u=t.tickTransform,d=t.ticks,h=t.strokeWidth,m=t.tickLineProps;return d.map(function(j){var w,x=j.value,v=j.index,y=j.from,f=j.to,b=j.formattedValue,p=(w=o[v])!=null?w:{},g=Math.max(10,typeof p.fontSize=="number"&&p.fontSize||0),N=f.y+(n&&a!==Qt.top?g:0);return L.createElement(co,{key:"visx-tick-"+x+"-"+v,className:Pn("visx-axis-tick",s),transform:u},!r&&L.createElement(Jm,es({from:y,to:f,stroke:c,strokeWidth:h,strokeLinecap:"square"},m)),i?i(es({},p,{x:f.x,y:N,formattedValue:b})):L.createElement(ef,es({x:f.x,y:N},p),b))})}function ts(){return ts=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},ts.apply(this,arguments)}var Wm={textAnchor:"middle",fontFamily:"Arial",fontSize:10,fill:"#222"};function yM(t){var r=t.axisFromPoint,n=t.axisLineClassName,a=t.axisToPoint,s=t.hideAxisLine,i=t.hideTicks,o=t.horizontal,l=t.label,c=l===void 0?"":l,u=t.labelClassName,d=t.labelOffset,h=d===void 0?14:d,m=t.labelProps,j=t.orientation,w=j===void 0?Qt.bottom:j,x=t.scale,v=t.stroke,y=v===void 0?"#222":v,f=t.strokeDasharray,b=t.strokeWidth,p=b===void 0?1:b,g=t.tickClassName,N=t.tickComponent,S=t.tickLineProps,O=t.tickLabelProps,C=t.tickLength,P=C===void 0?8:C,$=t.tickStroke,A=$===void 0?"#222":$,I=t.tickTransform,D=t.ticks,q=t.ticksComponent,F=q===void 0?gM:q,K=ts({},Wm,m),M=ts({},Wm,typeof O=="object"?O:null),E=D.map(function(H){var V=H.value,se=H.index;return typeof O=="function"?O(V,se,D):M}),Q=Math.max.apply(Math,[10].concat(E.map(function(H){return typeof H.fontSize=="number"?H.fontSize:0})));return L.createElement(L.Fragment,null,F({hideTicks:i,horizontal:o,orientation:w,scale:x,tickClassName:g,tickComponent:N,tickLabelProps:E,tickStroke:A,tickTransform:I,ticks:D,strokeWidth:p,tickLineProps:S}),!s&&L.createElement(Jm,{className:Pn("visx-axis-line",n),from:r,to:a,stroke:y,strokeWidth:p,strokeDasharray:f}),c&&L.createElement(ef,ts({className:Pn("visx-axis-label",u)}
192,vM({labelOffset:h,labelProps:K,orientation:w,range:x.range(),tickLabelFontSize:Q,tickLength:P}),K),c))}function jM(t,r){r===void 0&&(r="center");var n=t;if(r!=="start"&&"bandwidth"in n){var a=n.bandwidth();return r==="center"&&(a/=2),n.round()&&(a=Math.round(a)),function(s){var i=n(s);return typeof i=="number"?i+a:i}}return t}function bM(t){var r=t;return"tickFormat"in r?r.tickFormat():ug}function di(t,r){var n=t.x,a=t.y;return new Pl(r?{x:n,y:a}:{x:a,y:n})}function Qc(){return Qc=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},Qc.apply(this,arguments)}var _l=0;function wM(t){return t===void 0&&(t=_l),typeof t=="number"?{start:t,end:t}:Qc({start:_l,end:_l},t)}var NM=["children","axisClassName","hideAxisLine","hideTicks","hideZero","innerRef","left","numTicks","orientation","rangePadding","scale","tickFormat","tickLength","tickValues","top"];function Zc(){return Zc=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},Zc.apply(this,arguments)}function _M(t,r){if(t==null)return{};var n={},a=Object.keys(t),s,i;for(i=0;i<a.length;i++)s=a[i],!(r.indexOf(s)>=0)&&(n[s]=t[s]);return n}function dv(t){var r=t.children,n=r===void 0?yM:r,a=t.axisClassName,s=t.hideAxisLine,i=s===void 0?!1:s,o=t.hideTicks,l=o===void 0?!1:o,c=t.hideZero,u=c===void 0?!1:c,d=t.innerRef,h=t.left,m=h===void 0?0:h,j=t.numTicks,w=j===void 0?10:j,x=t.orientation,v=x===void 0?Qt.bottom:x,y=t.rangePadding,f=y===void 0?0:y,b=t.scale,p=t.tickFormat,g=t.tickLength,N=g===void 0?8:g,S=t.tickValues,O=t.top,C=O===void 0?0:O,P=_M(t,NM),$=p??bM(b),A=v===Qt.left,I=v===Qt.top,D=I||v===Qt.bottom,q=jM(b),F=A||I?-1:1,K=b.range(),M=wM(f),E=di({x:Number(K[0])+.5-M.start,y:0},D),Q=di({x:Number(K[K.length-1])+.5+M.end,y:0},D),H=(S??tf(b,w)).filter(function(se){return!u||se!==0&&se!=="0"}).map(function(se,ue){return{value:se,index:ue}}),V=H.map(function(se){var ue=se.value,z=se.index,he=rf(q(ue));return{value:ue,index:z,from:di({x:he,y:0},D),to:di({x:he,y:N*F},D),formattedValue:$(ue,z,H)}});return L.createElement(co,{className:Pn("visx-axis",a),innerRef:d,top:C,left:m},n(Zc({},P,{axisFromPoint:E,axisToPoint:Q,hideAxisLine:i,hideTicks:l,hideZero:u,horizontal:D,numTicks:w,orientation:v,rangePadding:f,scale:b,tickFormat:$,tickLength:N,tickPosition:q,tickSign:F,ticks:V})))}var SM=["axisClassName","labelOffset","tickLength","tickLabelProps"];function io(){return io=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},io.apply(this,arguments)}function OM(t,r){if(t==null)return{};var n={},a=Object.keys(t),s,i;for(i=0;i<a.length;i++)s=a[i],!(r.indexOf(s)>=0)&&(n[s]=t[s]);return n}var CM={dx:"-0.25em",dy:"0.25em",fill:"#222",fontFamily:"Arial",fontSize:10,textAnchor:"end"};function AM(t){var r=t.axisClassName,n=t.labelOffset,a=n===void 0?36:n,s=t.tickLength,i=s===void 0?8:s,o=t.tickLabelProps,l=OM(t,SM),c=typeof o=="function"?o:io({},CM,o);return L.createElement(dv,io({axisClassName:Pn("visx-axis-left",r),labelOffset:a,orientation:Qt.left,tickLabelProps:c,tickLength:i},l))}var PM=["axisClassName","labelOffset","tickLength","tickLabelProps"];function oo(){return oo=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},oo.apply(this,arguments)}function kM(t,r){if(t==null)return{};var n={},a=Object.keys(t),s,i;for(i=0;i<a.length;i++)s=a[i],!(r.indexOf(s)>=0)&&(n[s]=t[s]);return n}var EM={dy:"0.25em",fill:"#222",fontFamily:"Arial",fontSize:10,textAnchor:"middle"};function TM(t){var r=t.axisClassName,n=t.labelOffset,a=n===void 0?8:n,s=t.tickLength,i=s===void 0?8:s,o=t.tickLabelProps,l=kM(t,PM),c=typeof o=="function"?o:oo({},EM,o);return L.createElement(dv,oo({axisClassName:Pn("visx-axis-bottom",r),labelOffset:a,orientation:Qt.bottom,tickLabelProps:c,tickLength:i},l))}function $M(t){return"bandwidth"in t?t.bandwidth():0}var DM=["top","left","scale","width","stroke","strokeWidth","strokeDasharray","className","children","numTicks","lineStyle","offset","tickValues"];
192function Jc(){return Jc=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},Jc.apply(this,arguments)}function MM(t,r){if(t==null)return{};var n={},a=Object.keys(t),s,i;for(i=0;i<a.length;i++)s=a[i],!(r.indexOf(s)>=0)&&(n[s]=t[s]);return n}function uv(t){var r=t.top,n=r===void 0?0:r,a=t.left,s=a===void 0?0:a,i=t.scale,o=t.width,l=t.stroke,c=l===void 0?"#eaf0f6":l,u=t.strokeWidth,d=u===void 0?1:u,h=t.strokeDasharray,m=t.className,j=t.children,w=t.numTicks,x=w===void 0?10:w,v=t.lineStyle,y=t.offset,f=t.tickValues,b=MM(t,DM),p=f??tf(i,x),g=(y??0)+$M(i)/2,N=p.map(function(S,O){var C,P=((C=rf(i(S)))!=null?C:0)+g;return{index:O,from:new Pl({x:0,y:P}),to:new Pl({x:o,y:P})}});return L.createElement(co,{className:Pn("visx-rows",m),top:n,left:s},j?j({lines:N}):N.map(function(S){var O=S.from,C=S.to,P=S.index;return L.createElement(hg,Jc({key:"row-line-"+P,from:O,to:C,stroke:c,strokeWidth:d,strokeDasharray:h,style:v},b))}))}uv.propTypes={tickValues:Me.array,width:Me.number.isRequired};const IM=({totalParticipants:t,acceptedParticipants:r,pendingParticipants:n,eventId:a})=>{const[s,i]=_.useState([]),[o,l]=_.useState(!0),c=400,u=200,d={top:20,right:30,bottom:40,left:40},h=c-d.left-d.right,m=u-d.top-d.bottom;_.useEffect(()=>{a&&j()},[a]);const j=async()=>{try{l(!0);const{data:g,error:N}=await k.from("user_roles").select("created_at, status, role, user_id").eq("event_id",a).order("created_at",{ascending:!0});if(N)throw N;i(g||[])}catch(g){console.error("Error fetching user roles for timeline:",g),i([])}finally{l(!1)}},x=(()=>{if(s.length===0){const D=new Date,q=new Date(D.getTime()-30*24*60*60*1e3),F=[];let K=0,M=0;for(let E=0;E<=30;E++){const Q=new Date(q.getTime()+E*24*60*60*1e3);E<20?(K+=Math.floor(Math.random()*3)+1,M+=Math.floor(Math.random()*2)):E<25?(K+=Math.floor(Math.random()*5)+2,M+=Math.floor(Math.random()*3)+1):(K+=Math.floor(Math.random()*2),M+=Math.floor(Math.random()*1)),F.push({date:Q,registrations:Math.min(K,t),accepted:Math.min(M,r)})}return F.length>0&&(F[F.length-1].registrations=t,F[F.length-1].accepted=r),F}const g=[...s].sort((D,q)=>new Date(D.created_at).getTime()-new Date(q.created_at).getTime());if(g.length===0)return[];const N=new Date(g[0].created_at),S=new Date,O=new Map,C=new Date(N);for(;C<=S;){const D=C.toISOString().split("T")[0];O.set(D,{date:new Date(C),registrations:0,accepted:0}),C.setDate(C.getDate()+1)}let P=0,$=0;const A=new Map;return g.forEach(D=>{const q=new Date(D.created_at).toISOString().split("T")[0];A.has(q)||A.set(q,[]),A.get(q).push(D)}),Array.from(O.keys()).sort().forEach(D=>{const q=O.get(D);if(A.has(D)){const F=A.get(D);P+=F.length,$+=F.filter(K=>K.status==="accepted").length}q.registrations=P,q.accepted=$}),Array.from(O.values()).filter(D=>D.registrations>0)})();if(o)return e.jsx("div",{className:"w-full h-[200px] flex items-center justify-center bg-muted/10 rounded-lg",children:e.jsx(Qe,{size:24})});if(x.length===0)return e.jsx("div",{className:"w-full h-[200px] flex items-center justify-center bg-muted/10 rounded-lg",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"No timeline data available"})});const v=Dv({range:[0,h],domain:[Math.min(...x.map(g=>g.date)),Math.max(...x.map(g=>g.date))]}),y=Mv({range:[m,0],domain:[0,Math.max(t,10)],nice:!0}),f=g=>g.date,b=g=>g.registrations,p=g=>g.accepted;return e.jsxs("div",{className:"w-full",children:[e.jsxs("svg",{width:c,height:u,children:[e.jsx(Ld,{id:"registration-gradient",from:"hsl(var(--primary))",to:"hsl(var(--primary))",fromOpacity:.4,toOpacity:.1}),e.jsx(Ld,{id:"accepted-gradient",from:"hsl(120, 60%, 50%)",to:"hsl(120, 60%, 50%)",fromOpacity:.4,toOpacity:.1}),e.jsxs(co,{left:d.left,top:d.top,children:[e.jsx(uv,{scale:y,width:h,stroke:"hsl(var(--muted-foreground))",strokeOpacity:.1}),e.jsx(Rd,{data:x,x:g=>v(f(g))??0,y:g=>y(b(g))??0,yScale:y,fill:"url(#registration-gradient)",curve:Hs}),e.jsx(Rd,{data:x,x:g=>v(f(g))??0,y:g=>y(p(g))??0,yScale:y,fill:"url(#accepted-gradient)",curve:Hs}),e.jsx(Fd,{data:x,x:g=>v(f(g))??0,y:g=>y(b(g))??0,stroke:"hsl(var(--primary))",strokeWidth:2,curve:Hs}),e.jsx(Fd,{data:x,x:g=>v(f(g))??0,y:g=>
192y(p(g))??0,stroke:"hsl(120, 60%, 50%)",strokeWidth:2,curve:Hs}),e.jsx(TM,{top:m,scale:v,numTicks:5,stroke:"hsl(var(--muted-foreground))",tickStroke:"hsl(var(--muted-foreground))",tickLabelProps:{fill:"hsl(var(--muted-foreground))",fontSize:10,textAnchor:"middle"}}),e.jsx(AM,{scale:y,numTicks:4,stroke:"hsl(var(--muted-foreground))",tickStroke:"hsl(var(--muted-foreground))",tickLabelProps:{fill:"hsl(var(--muted-foreground))",fontSize:10,textAnchor:"end",dx:-4}})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-4 mt-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-full bg-primary"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Total Registrations"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:"hsl(120, 60%, 50%)"}}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Accepted"})]})]})]})},LM=({roles:t,onRemoveRole:r,className:n})=>{const a=o=>o.split("_").map(l=>l.charAt(0).toUpperCase()+l.slice(1)).join(" "),s=o=>{switch(o){case"startup":return"bg-blue-100 text-blue-800 dark:bg-blue-900/20 dark:text-blue-400";case"mentor":return"bg-purple-100 text-purple-800 dark:bg-purple-900/20 dark:text-purple-400";case"investor":return"bg-green-100 text-green-800 dark:bg-green-900/20 dark:text-green-400";case"jury":return"bg-orange-100 text-orange-800 dark:bg-orange-900/20 dark:text-orange-400";case"program_manager":return"bg-red-100 text-red-800 dark:bg-red-900/20 dark:text-red-400";case"corporate":return"bg-indigo-100 text-indigo-800 dark:bg-indigo-900/20 dark:text-indigo-400";case"speaker":return"bg-pink-100 text-pink-800 dark:bg-pink-900/20 dark:text-pink-400";case"attendant":return"bg-cyan-100 text-cyan-800 dark:bg-cyan-900/20 dark:text-cyan-400";case"location":return"bg-amber-100 text-amber-800 dark:bg-amber-900/20 dark:text-amber-400";default:return"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-300"}},i=t.map(o=>o.substring(0,2).toUpperCase()).join(" ");return t.length===0?null:e.jsxs(Hn,{children:[e.jsx(Xn,{asChild:!0,children:e.jsxs(R,{variant:"outline",size:"sm",className:`h-8 px-2 text-xs bg-background hover:bg-muted border border-border/50 ${n}`,children:[e.jsx("span",{className:"font-mono font-medium",children:i}),e.jsx(nd,{className:"h-3 w-3 ml-1"})]})}),e.jsx(Yn,{align:"start",className:"w-48 bg-background border border-border shadow-lg z-50",children:t.map((o,l)=>e.jsxs(Ut,{className:"flex items-center justify-between p-2 hover:bg-muted cursor-pointer",onSelect:c=>c.preventDefault(),children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(re,{variant:"secondary",className:`${s(o)} text-xs px-2 py-1`,children:a(o)})}),e.jsx(R,{variant:"ghost",size:"sm",onClick:c=>{c.stopPropagation(),r(o)},className:"h-6 w-6 p-0 hover:bg-destructive/20 hover:text-destructive",children:e.jsx(Pr,{className:"h-3 w-3"})})]},l))})]})},RM=()=>{var ue,z,he;const{eventId:t}=Zr(),r=gt(),[n,a]=_.useState(null),[s,i]=_.useState([]),[o,l]=_.useState([]),[c,u]=_.useState([]),[d,h]=_.useState(""),[m,j]=_.useState("all"),[w,x]=_.useState("all"),[v,y]=_.useState(!0),[f,b]=_.useState(!1),[p,g]=_.useState(""),[N,S]=_.useState("startup"),[O,C]=_.useState({totalParticipants:0,acceptedParticipants:0,pendingParticipants:0,roleBreakdown:{}});Qr();const P=dn(),$=["startup","mentor","investor","jury","speaker","attendant","program_manager","corporate","location"];_.useEffect(()=>{t&&(A(),I(),D())},[t]),_.useEffect(()=>{q()},[s,d,m,w]),_.useEffect(()=>{F()},[s]);const A=async()=>{try{const{data:ne,error:fe}=await k.from("events").select("*").eq("id",t).single();if(fe)throw fe;a(ne)}catch(ne){console.error("Error fetching event:",ne),P.toast.error({title:"Failed to load event details"})}},I=async()=>{try{y(!0);const{data:ne,error:fe}=await k.from("user_roles").select("id, user_id, role, status, created_at, checkin_code, company_id").eq("event_id",t).order("created_at",{ascending:!1});if(fe)throw fe;if(!ne||ne.length===0){i([]);return}const De=[...new Set(ne.map(be=>be.user_id))],{data:Ce,error:Re}=await k.from("profiles").select("user_id, name, email, membership_level").in("user_id",De);if(Re)throw Re;const T=[...new Set(ne.filter(be=>(be.role==="startup"||be.role==="corporate")&&be.company_id).map(be=>
192be.company_id).filter(Boolean))];let ie=[];if(T.length>0){const{data:be,error:ot}=await k.from("companies").select("id, name").in("id",T);if(ot)throw ot;ie=be||[]}const Se=new Map;Ce==null||Ce.forEach(be=>{Se.set(be.user_id,be)});const Ae=new Map;ie.forEach(be=>{Ae.set(be.id,be)});const Pe=new Map;ne.forEach(be=>{const ot=be.user_id;if(!Pe.has(ot))Pe.set(ot,{...be,roles:[be.role],profiles:Se.get(be.user_id)||{name:"Unknown User",email:"[email protected]",membership_level:"guest"},companies:be.company_id&&(be.role==="startup"||be.role==="corporate")&&Ae.get(be.company_id)||null});else{const yt=Pe.get(ot);yt.roles.push(be.role),be.company_id&&(be.role==="startup"||be.role==="corporate")&&(yt.companies=Ae.get(be.company_id)||null)}});const Ue=Array.from(Pe.values());i(Ue)}catch(ne){console.error("Error fetching user roles:",ne),P.toast.error({title:"Failed to load participants"})}finally{y(!1)}},D=async()=>{try{const{data:ne,error:fe}=await k.from("profiles").select("id, user_id, name, email, membership_level").order("name");if(fe)throw fe;u(ne||[])}catch(ne){console.error("Error fetching users:",ne)}},q=()=>{let ne=s;d&&(ne=ne.filter(fe=>fe.profiles.name.toLowerCase().includes(d.toLowerCase())||fe.profiles.email.toLowerCase().includes(d.toLowerCase()))),m!=="all"&&(ne=ne.filter(fe=>fe.role===m)),w!=="all"&&(ne=ne.filter(fe=>fe.status===w)),l(ne)},F=()=>{const ne=s.length,fe=s.filter(Re=>Re.status==="accepted").length,De=s.filter(Re=>Re.status==="pending").length,Ce={};s.forEach(Re=>{Ce[Re.role]=(Ce[Re.role]||0)+1}),C({totalParticipants:ne,acceptedParticipants:fe,pendingParticipants:De,roleBreakdown:Ce})},K=async()=>{if(!(!p||!N))try{if(s.find(De=>De.user_id===p)){P.toast.error({title:"User already has a role in this event"});return}const{error:fe}=await k.from("user_roles").insert({user_id:p,event_id:t,role:N,status:"pending"});if(fe)throw fe;P.toast.success({title:"User added to event successfully"}),b(!1),g(""),S("startup"),await I()}catch(ne){console.error("Error adding user:",ne),P.toast.error({title:"Failed to add user to event"})}},M=async(ne,fe)=>{try{const{error:De}=await k.from("user_roles").update({status:fe}).eq("id",ne);if(De)throw De;P.toast.success({title:"Status updated successfully"}),await I()}catch(De){console.error("Error updating status:",De),P.toast.error({title:"Failed to update status"})}},E=async ne=>{try{const{error:fe}=await k.from("user_roles").delete().eq("id",ne);if(fe)throw fe;P.toast.success({title:"User removed from event"}),await I()}catch(fe){console.error("Error removing user:",fe),P.toast.error({title:"Failed to remove user"})}},Q=async(ne,fe)=>{try{const{error:De}=await k.from("user_roles").delete().eq("user_id",ne).eq("event_id",t).eq("role",fe);if(De)throw De;P.toast.success({title:"Role removed successfully"}),await I()}catch(De){console.error("Error removing role:",De),P.toast.error({title:"Failed to remove role"})}},H=ne=>{switch(ne){case"accepted":return"bg-green-100 text-green-800";
192case"pending":return"bg-yellow-100 text-yellow-800";case"rejected":return"bg-red-100 text-red-800";default:return"bg-gray-100 text-gray-800"}},V=ne=>ne.split("_").map(fe=>fe.charAt(0).toUpperCase()+fe.slice(1)).join(" "),se=ne=>ne.charAt(0).toUpperCase()+ne.slice(1);return v&&!n?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Qe,{size:32}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:"Loading event details..."})]})}):n?e.jsxs("div",{className:"container mx-auto px-4 py-6 space-y-6 max-w-7xl",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsxs(R,{variant:"outline",onClick:()=>r("/dashboard/admin/events"),children:[e.jsx(Bt,{className:"w-4 h-4 mr-2"}),"Back to Events"]}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:n.title}),e.jsxs("div",{className:"flex items-center space-x-2 mt-1",children:[e.jsx(re,{className:H(n.status.toLowerCase()),children:se(n.status)}),e.jsx(re,{variant:"outline",children:n.event_type}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[new Date(n.start_date).toLocaleDateString()," - ",new Date(n.end_date).toLocaleDateString()]})]})]})]}),e.jsxs(R,{onClick:()=>b(!0),children:[e.jsx(Fs,{className:"w-4 h-4 mr-2"}),"Add Participant"]})]}),e.jsx(Y,{children:e.jsxs(Z,{className:"pt-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qt,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium",children:"Duration"})]}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[new Date(n.start_date).toLocaleDateString()," - ",new Date(n.end_date).toLocaleDateString()]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(kn,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium",children:"Location"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:n.location||"Not specified"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ge,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium",children:"Max Participants"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:n.max_participants||"Unlimited"})]})]}),n.description&&e.jsx("div",{className:"mt-4 pt-4 border-t",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:n.description})})]})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs(Y,{className:"lg:col-span-2 bg-gradient-to-br from-primary/5 to-primary-glow/10 border-primary/20",children:[e.jsx(ce,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(le,{className:"text-lg font-semibold text-primary flex items-center gap-2",children:[e.jsx(Jr,{className:"h-5 w-5"}),"Participants Overview"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Real-time participation metrics"})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-3xl font-bold text-primary",children:O.totalParticipants}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Total Registered"})]})]})}),e.jsxs(Z,{children:[e.jsx(IM,{totalParticipants:O.totalParticipants,acceptedParticipants:O.acceptedParticipants,pendingParticipants:O.pendingParticipants,eventId:t}),e.jsxs("div",{className:"grid grid-cols-3 gap-4 mt-4 pt-4 border-t border-primary/20",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-lg font-semibold text-green-600",children:O.acceptedParticipants}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Accepted"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-lg font-semibold text-yellow-600",children:O.pen
192dingParticipants}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Pending"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-lg font-semibold text-red-600",children:O.totalParticipants-O.acceptedParticipants-O.pendingParticipants}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Rejected"})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Y,{className:"bg-gradient-to-br from-green-50 to-emerald-50 border-green-200 dark:from-green-950/20 dark:to-emerald-950/20 dark:border-green-800",children:[e.jsxs(ce,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(le,{className:"text-sm font-medium text-green-700 dark:text-green-300",children:"Acceptance Rate"}),e.jsx(pr,{className:"h-4 w-4 text-green-600"})]}),e.jsxs(Z,{children:[e.jsxs("div",{className:"text-2xl font-bold text-green-700 dark:text-green-300",children:[O.totalParticipants>0?Math.round(O.acceptedParticipants/O.totalParticipants*100):0,"%"]}),e.jsxs("p",{className:"text-xs text-green-600 dark:text-green-400",children:[O.acceptedParticipants," of ",O.totalParticipants," accepted"]})]})]}),e.jsxs(Y,{className:"bg-gradient-to-br from-blue-50 to-indigo-50 border-blue-200 dark:from-blue-950/20 dark:to-indigo-950/20 dark:border-blue-800",children:[e.jsxs(ce,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(le,{className:"text-sm font-medium text-blue-700 dark:text-blue-300",children:"Top Role"}),e.jsx(Ge,{className:"h-4 w-4 text-blue-600"})]}),e.jsxs(Z,{children:[e.jsx("div",{className:"text-lg font-bold text-blue-700 dark:text-blue-300 capitalize",children:((z=(ue=Object.entries(O.roleBreakdown).sort(([,ne],[,fe])=>fe-ne)[0])==null?void 0:ue[0])==null?void 0:z.replace("_"," "))||"None"}),e.jsxs("p",{className:"text-xs text-blue-600 dark:text-blue-400",children:[((he=Object.entries(O.roleBreakdown).sort(([,ne],[,fe])=>fe-ne)[0])==null?void 0:he[1])||0," participants"]})]})]}),e.jsxs(Y,{className:"bg-gradient-to-br from-purple-50 to-violet-50 border-purple-200 dark:from-purple-950/20 dark:to-violet-950/20 dark:border-purple-800",children:[e.jsxs(ce,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(le,{className:"text-sm font-medium text-purple-700 dark:text-purple-300",children:"Capacity"}),e.jsx(dr,{className:"h-4 w-4 text-purple-600"})]}),e.jsxs(Z,{children:[e.jsx("div",{className:"text-lg font-bold text-purple-700 dark:text-purple-300",children:n.max_participants?`${Math.round(O.totalParticipants/n.max_participants*100)}%`:"Unlimited"}),e.jsx("p",{className:"text-xs text-purple-600 dark:text-purple-400",children:n.max_participants?`${O.totalParticipants} / ${n.max_participants} slots`:"No capacity limit"})]})]})]})]}),e.jsxs(Y,{children:[e.jsx(ce,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(le,{className:"flex items-center gap-2",children:[e.jsx(Ge,{className:"w-5 h-5"}),"Event Participants"]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(tr,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground w-4 h-4"}),e.jsx(de,{placeholder:"Search participants...",value:d,onChange:ne=>h(ne.target.value),className:"pl-10 w-64"})]}),e.jsxs(xe,{value:m,onValueChange:j,children:[e.jsx(ve,{className:"w-32",children:e.jsx(ge,{placeholder:"Role"})}),e.jsxs(ye,{children:[e.jsx(J,{value:"all",children:"All Roles"}),$.map(ne=>e.jsx(J,{value:ne,children:V(ne)},ne))]})]}),e.jsxs(xe,{value:w,onValueChange:x,children:[e.jsx(ve,{className:"w-32",children:e.jsx(ge,{placeholder:"Status"})}),e.jsxs(ye,{children:[e.jsx(J,{value:"all",children:"All Status"}),e.jsx(J,{value:"pending",children:"Pending"}),e.jsx(J,{value:"accepted",children:"Accepted"}),e.jsx(J,{value:"rejected",children:"Rejected"})]})]})]})]})}),e.jsx(Z,{children:v?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(Qe,{size:32}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:"Loading participants..."})]}):e.jsxs(nt,{children:[e.jsx(at,{children:e.jsxs(pe,{children:[e.jsx(te,{children:"Name"}),e.jsx(te,{children:"Roles"}),e.jsx(te,{children:"Company"}),e.jsx(te,{children:"Status"}),e.jsx(te,{children:"Membership"}),e.jsx(te,{children:"Actions"})]})}),e.jsx(st,{children:o.map(ne=>e.jsxs(pe,{children:[e.jsx(X,{className:"font-medium",children:ne.profiles.name}),e.jsx(X,{children:e.jsx(LM,{roles:ne.roles||[ne.role],onRemoveRole:fe=>Q(ne.user_id,fe)})}),e.jsx(X,{children:ne.companies?e.jsx("span",{className:"text-sm text-muted-foreground",children:ne.companies.name}):e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"-"})}),e.jsx(X,{children:e.jsxs(xe,{value:ne.status,onValueChange:fe=>M(ne.id,fe),children:[e.jsx(ve,{className:"w-24",children:e.jsx(ge,{})}),e.jsxs(ye,{children:[e.jsx(J,{value:"pending",children:"Pending"}),e.jsx(J,{value:"accepted",children:"Accepted"}),e.jsx(J,{value:"rejected",children:"Rejected"})]})]})}),e.jsx(X,{children:e.jsx(re,{variant:"outline",className:"capitalize",children:ne.profiles.membership_level})}),e.jsx(X,{children:e.jsx(R,{variant:"outline",size:"sm",onClick:()=>E(ne.id),className:"text-destructive hover:bg-destructive hover:text-destructive-foreground",children:e.jsx(We,{className:"w-4 h-4"})})})]},ne.id))})]})})]}),e.jsx(ut,{open:f,onOpenChange:b,children:e.jsxs(ht,{className:"max-w-md",children:[e.jsx(mt,{children:e.jsx(ft,{children:"Add Participant to Event"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Select User"}),e.jsxs(xe,{value:p,onValueChange:g,children:[e.jsx(ve,{className:"mt-1",children:e.jsx(ge,{placeholder:"Choose a user"})}),e.jsx(ye,{children:c.filter(ne=>!s.some(fe=>fe.user_id===ne.user_id)).map(ne=>e.jsxs(J,{value:ne.user_id,children:[ne.name," (",ne.email,")"]},ne.user_id))})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Select Role"}),e.jsxs(xe,{value:N,onValueChange:S,children:[e.jsx(ve,{className:"mt-1",children:e.jsx(ge,{})}),e.jsx(ye,{children:$.map(ne=>e.jsx(J,{value:ne,children:V(ne)},ne))})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(R,{variant:"outline",onClick:()=>b(!1),children:"Cancel"}
192),e.jsx(R,{onClick:K,disabled:!p||!N,children:"Add Participant"})]})]})]})})]}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-muted-foreground",children:"Event not found"}),e.jsxs(R,{onClick:()=>r("/dashboard/admin/events"),className:"mt-4",children:[e.jsx(Bt,{className:"w-4 h-4 mr-2"}),"Back to Events"]})]})},Km=t=>({visitor:"visitor",attendee:"attendant",mentor:"mentor",startup:"startup_founder",corporate:"corporate",investor:"investor",speaker:"attendant",program_manager:"program_manager",jury_member:"jury_member",location:"location"})[t]||"visitor",WL=()=>{var m;const{user:t,isLoading:r}=Qr(),[n,a]=_.useState(!1),[s,i]=_.useState(!1),[o,l]=_.useState(0);if(gt(),ed(),r)return e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx(Qe,{size:64})});if(!t)return null;const c=[...t.globalRoles],u=t.globalRoles.length>0?t.globalRoles[0]:"visitor",d={id:t.id,name:t.name,email:t.email,avatar:(m=t.profileData)==null?void 0:m.avatar_url,roles:c.map(Km),primaryRole:Km(u)},h=()=>{a(!n)};return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(jv,{user:d,onMenuClick:h,onNotificationClick:()=>i(!s),unreadCount:o,sticky:!1}),e.jsx(ly,{}),e.jsx("main",{className:"flex-1",children:e.jsxs(vv,{children:[e.jsx(Fe,{path:"/",element:e.jsx(cy,{})}),e.jsx(Fe,{path:"/users",element:e.jsx(fg,{})}),e.jsx(Fe,{path:"/users/:userId",element:e.jsx(BD,{})}),e.jsx(Fe,{path:"/memberships",element:e.jsx(dM,{})}),e.jsx(Fe,{path:"/benefits",element:e.jsx(mM,{})}),e.jsx(Fe,{path:"/benefits/:benefitId/edit",element:e.jsx(xM,{})}),e.jsx(Fe,{path:"/buddies",element:e.jsx(uM,{})}),e.jsx(Fe,{path:"/companies",element:e.jsx(ND,{})}),e.jsx(Fe,{path:"/companies/:companyId",element:e.jsx(_D,{})}),e.jsx(Fe,{path:"/companies/:companyId/edit",element:e.jsx(OD,{})}),e.jsx(Fe,{path:"/blog",element:e.jsx(wD,{})}),e.jsx(Fe,{path:"/blog/edit/:id",element:e.jsx(nM,{})}),e.jsx(Fe,{path:"/media",element:e.jsx(AD,{})}),e.jsx(Fe,{path:"/faq",element:e.jsx(CD,{})}),e.jsx(Fe,{path:"/templates",element:e.jsx(yD,{})}),e.jsx(Fe,{path:"/program-templates",element:e.jsx(jD,{})}),e.jsx(Fe,{path:"/registration-emails",element:e.jsx(bD,{})}),e.jsx(Fe,{path:"/events",element:e.jsx(vD,{})}),e.jsx(Fe,{path:"/events/:eventId",element:e.jsx(RM,{})}),e.jsx(Fe,{path:"/newsletter",element:e.jsx(pD,{})}),e.jsx(Fe,{path:"/newsletter/create",element:e.jsx(xD,{})}),e.jsx(Fe,{path:"/newsletter/campaign/:campaignId",element:e.jsx(aM,{})}),e.jsx(Fe,{path:"/newsletter/lists",element:e.jsx(sM,{})}),e.jsx(Fe,{path:"/newsletter/lists/:listId",element:e.jsx(iM,{})}),e.jsx(Fe,{path:"/pagesettings",element:e.jsx(uy,{})}),e.jsx(Fe,{path:"/settings",element:e.jsx(dy,{})}),e.jsx(Fe,{path:"/analytics",element:e.jsx(fD,{})}),e.jsx(Fe,{path:"/reviews",element:e.jsx(mg,{})}),e.jsx(Fe,{path:"/chapters",element:e.jsx(PD,{})}),e.jsx(Fe,{path:"/chapters/:chapterId",element:e.jsx(kD,{})}),e.jsx(Fe,{path:"/knowledge",element:e.jsx(zD,{})}),e.jsx(Fe,{path:"/discussions",element:e.jsx(qD,{})}),e.jsx(Fe,{path:"/feedback",element:e.jsx(HD,{})}),e.jsx(Fe,{path:"/founders-track",element:e.jsx(XD,{})})]})}),e.jsx(Ev,{}),e.jsx(bv,{isOpen:s,onClose:()=>i(!1),onUnreadCountChange:l}),e.jsx(Kg,{user:d})]})};export{WL 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.