1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[65274],{65274:function(e,s,a){a.r(s),a.d(s,{default:function(){return eO}});var t=a(57437),r=a(2265),l=a(27648),i=a(99376),n=a(79820),d=a(12381),o=a(69174),c=a(15291),m=a(90641),x=a(74291),h=a(17168),u=a(32060),g=a(10407),v=a(99897),p=a(33388),b=a(28553),j=a(68919),f=a(29202),N=a(83774),w=a(42208),y=a(95805),k=a(37806),D=a(82023),C=a(46221),_=a(29985),Z=a(31047),F=a(82431),S=a(15863),E=a(92735),U=a(91879),R=a(37533),T=a(11239),A=a(58896),z=a(95252),P=a(73247),O=a(13781),B=a(16275),K=a(40476),V=a(52048),L=a(70525),M=a(42488),I=a(3085),Y=a(91723),G=a(71637),$=a(49663),q=a(43745),H=a(28124),W=a(96362),Q=a(84881),X=a(9310),J=a(46574),ee=a(32482),es=a(47559),ea=a(29789),et=a(88997),er=a(63639),el=a(37760),ei=a(29374),en=a(53113),ed=a(31810),eo=a(82718),ec=a(56439),em=a(48736),ex=a(61178),eh=a(47625),eu=a(5481),eg=a(56940),ev=a(97059),ep=a(62994),eb=a(8147),ej=a(23263),ef=a(75169),eN=a(3574),ew=a(20407),ey=a(22190),ek=a(77031),eD=a(31699),eC=a(71837),e_=a(69064);let eZ=e=>{let{className:s}=e;return(0,t.jsx)("svg",{className:s,viewBox:"0 0 24 24",fill:"currentColor",children:(0,t.jsx)("path",{d:"M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"})})},eF={reach:{label:"Reach",color:"#3B82F6",icon:w.Z},impressions:{label:"Impressions",color:"#8B5CF6",icon:C.Z},engagement:{label:"Engagement",color:"#EC4899",icon:et.Z},followers:{label:"Followers",color:"#10B981",icon:y.Z}},eS=e=>{var s,a,l,i,x,u,g,v;let{externalPeriod:p,externalSelectedPageId:b,externalRefreshing:N,onRefreshComplete:D,hideHeader:Z=!1}=e,{user:E}=(0,Q.a)(),U=(null==E?void 0:E.workspace_id)||"",[A,z]=(0,r.useState)(!0),[P,O]=(0,r.useState)(!1),[B,K]=(0,r.useState)(null),[V,M]=(0,r.useState)(null),[Y,G]=(0,r.useState)(null),[$,q]=(0,r.useState)(null),[H,X]=(0,r.useState)("28d"),[J,ee]=(0,r.useState)("overview"),[es,ea]=(0,r.useState)("reach"),[eS,eE]=(0,r.useState)([]),[eU,eR]=(0,r.useState)("all"),eT=p||H,eA=p?()=>{}:X,ez=b||eU,eP=b?()=>{}:eR,eO=void 0!==N?N:P,eB=e=>{let s=Number(e)||0;return s>=1e6?"".concat((s/1e6).toFixed(1),"M"):s>=1e3?"".concat((s/1e3).toFixed(1),"K"):s.toLocaleString()},[eK,eV]=(0,r.useState)(null),eL=(0,r.useCallback)(async()=>{if(!U)return;let e="7d"===eT?7:"14d"===eT?14:"90d"===eT?90:28;try{let s=await eC.api.get("/meta/analytics/time-series?workspace_id=".concat(U,"&days=").concat(e));s.data.success&&s.data.data&&eV(s.data.data)}catch(e){console.error("Error fetching time series data:",e)}},[U,eT]),eM=(0,r.useCallback)(e=>{if(!eK||!eK.dates||0===eK.dates.length)return[];let{dates:s,facebook:a,instagram:t}=eK;return s.map((s,r)=>{let l=new Date(s),i=0,n=0,d=0;return("facebook"===e||"combined"===e)&&(i+=a.reach[r]||0,n+=a.impressions[r]||0,d+=a.engagement[r]||0),("instagram"===e||"combined"===e)&&(i+=t.reach[r]||0,n+=t.impressions[r]||0,d+=t.profile_views[r]||0),{date:s,displayDate:l.toLocaleDateString("en-US",{month:"short",day:"numeric"}),reach:i,impressions:n,engagement:d,followers:0}})},[eK]),[eI,eY]=(0,r.useState)([]),[eG,e$]=(0,r.useState)([]),[eq,eH]=(0,r.useState)([]);(0,r.useRef)(!1);let eW=(0,r.useRef)(""),eQ=(0,r.useCallback)(async()=>{if(U)try{let e=await eC.api.get("/meta/analytics/pages?workspace_id=".concat(U));e.data.success&&eE(e.data.facebook_pages||[])}catch(e){console.error("Error fetching connected pages:",e)}},[U]),eX=(0,r.useCallback)(async()=>{if(U)try{K(null);let e=ez&&"all"!==ez?"&page_id=".concat(ez):"",s=await eC.api.get("/meta/analytics/dashboard?workspace_id=".concat(U,"&period=").concat(eT).concat(e));M(s.data),s.data.success||s.data.connected||K(null)}catch(r){var e,s,a;console.error("Error fetching Meta analytics:",r);let t=null==r?void 0:null===(e=r.response)||void 0===e?void 0:e.status;if(401===t||403===t||404===t)K(null),M({success:!1,connected:!1,error:"Not authenticated or endpoint not available"});else{let e=(null==r?void 0:null===(a=r.response)||void 0===a?void 0:null===(s=a.data)||void 0===s?void 0:s.detail)||(null==r?void 0:r.message)||"Unable to connect to Meta Analytics";K(e),M({success:!1,connected:!1,error:e})}}},[U,eT,ez]),eJ=(0,r.useCallback)(async()=>
1{if(U)try{let e=ez&&"all"!==ez?"&page_id=".concat(ez):"",s=await eC.api.get("/meta/analytics/top-posts?workspace_id=".concat(U,"&limit=5").concat(e));s.data.success&&G(s.data.data)}catch(e){console.error("Error fetching top posts:",e)}},[U,ez]),e0=(0,r.useCallback)(async()=>{if(U)try{let e=ez&&"all"!==ez?"&page_id=".concat(ez):"",s=await eC.api.get("/meta/analytics/geographic?workspace_id=".concat(U).concat(e));s.data.success&&q(s.data.data)}catch(e){console.error("Error fetching geo data:",e)}},[U,ez]),e5=(0,r.useCallback)(()=>{let e=eM("combined"),s=eM("facebook"),a=eM("instagram");eY(e),e$(s),eH(a)},[eM]),e3=(0,r.useCallback)(async()=>{z(!0),await Promise.all([eX(),eJ(),e0(),eL()]),z(!1)},[eX,eJ,e0,eL]),e1=async()=>{O(!0),eW.current="",await e3(),O(!1),e_.default.success("Meta analytics refreshed")};(0,r.useEffect)(()=>{U&&eQ()},[U,eQ]),(0,r.useEffect)(()=>{if(!U)return;let e="".concat(U,"-").concat(eT,"-").concat(ez);eW.current!==e&&(eW.current=e,(async()=>{z(!0),await Promise.all([eX(),eJ(),e0(),eL()]),z(!1)})())},[U,eT,ez,eX,eJ,e0,eL]),(0,r.useEffect)(()=>{eK&&e5()},[eK,e5]),(0,r.useEffect)(()=>{N&&(async()=>{eW.current="",await e3(),null==D||D()})()},[N,D,e3]);let e2=()=>{window.location.href="/dashboard/ads-assets"};if(!A&&B&&!(null==V?void 0:V.connected))return(0,t.jsx)(n.Zb,{className:"border-dashed border-orange-200 dark:border-orange-800",children:(0,t.jsxs)(n.aY,{className:"flex flex-col items-center justify-center py-12",children:[(0,t.jsx)("div",{className:"p-3 rounded-full bg-orange-100 dark:bg-orange-900/30 mb-4",children:(0,t.jsx)(er.Z,{className:"w-8 h-8 text-orange-500"})}),(0,t.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Unable to Load Meta Analytics"}),(0,t.jsx)("p",{className:"text-muted-foreground text-center mb-4 max-w-sm text-sm",children:B||"There was an issue connecting to the Meta Analytics service."}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsxs)(d.z,{variant:"outline",onClick:()=>e3(),children:[(0,t.jsx)(F.Z,{className:"w-4 h-4 mr-2"}),"Retry"]}),(0,t.jsxs)(d.z,{onClick:e2,children:[(0,t.jsx)(_.Z,{className:"w-4 h-4 mr-2"}),"Connect Accounts"]})]})]})});if(!A&&V&&!V.connected&&!B)return(0,t.jsx)(n.Zb,{className:"border-dashed",children:(0,t.jsxs)(n.aY,{className:"flex flex-col items-center justify-center py-12",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,t.jsx)("div",{className:"p-3 rounded-full bg-blue-100",children:(0,t.jsx)(eZ,{className:"w-8 h-8 text-[#1877F2]"})}),(0,t.jsx)("div",{className:"p-3 rounded-full bg-gradient-to-br from-purple-500 to-pink-500",children:(0,t.jsx)(el.Z,{className:"w-8 h-8 text-white"})})]}),(0,t.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connect Meta Accounts"}),(0,t.jsx)("p",{className:"text-muted-foreground text-center mb-4 max-w-sm",children:"Connect your Facebook Page and Instagram Business account to view analytics."}),(0,t.jsxs)(d.z,{onClick:e2,children:[(0,t.jsx)(_.Z,{className:"w-4 h-4 mr-2"}),"Connect Accounts"]})]})});if(A)return(0,t.jsx)(n.Zb,{children:(0,t.jsx)(n.aY,{className:"flex items-center justify-center py-12",children:(0,t.jsx)(S.Z,{className:"w-8 h-8 animate-spin text-muted-foreground"})})});let e4=null==V?void 0:null===(s=V.data)||void 0===s?void 0:s.summary,e8=null==V?void 0:null===(a=V.data)||void 0===a?void 0:a.connection_status,e6=[{name:"Reactions",value:Number(null==e4?void 0:e4.total_reactions)||0,color:"#1877F2"},{name:"Comments",value:Number(null==e4?void 0:e4.total_comments)||0,color:"#E1306C"},{name:"Shares",value:Number(null==e4?void 0:e4.total_shares)||0,color:"#25D366"},{name:"Saves",value:Number(null==e4?void 0:e4.total_saves)||0,color:"#F58529"}].filter(e=>e.value>0),e9=[{platform:"Facebook",reach:Number(null==e4?void 0:e4.page_reach)||0,impressions:Number(null==e4?void 0:e4.page_impressions)||0,engagement:Number(null==e4?void 0:e4.page_post_engagements)||0},{platform:"Instagram",reach:Number(null==e4?void 0:e4.instagram_reach
1)||0,impressions:Number(null==e4?void 0:e4.instagram_impressions)||0,engagement:Number(null==e4?void 0:e4.total_reactions)||0}],e7=(Number(null==e4?void 0:e4.page_fans)||0)+(Number(null==e4?void 0:e4.instagram_followers)||0),se=(Number(null==e4?void 0:e4.page_post_engagements)||0)+(Number(null==e4?void 0:e4.total_reactions)||0),ss=[{name:"Reactions",value:Number(null==e4?void 0:e4.total_reactions)||0,color:"#1877F2"},{name:"Comments",value:Number(null==e4?void 0:e4.total_comments)||0,color:"#42B72A"},{name:"Shares",value:Number(null==e4?void 0:e4.total_shares)||0,color:"#F7B928"}].filter(e=>e.value>0),sa=[{name:"Likes",value:Number(null==e4?void 0:e4.total_reactions)||0,color:"#E1306C"},{name:"Comments",value:Number(null==e4?void 0:e4.total_comments)||0,color:"#833AB4"},{name:"Saves",value:Number(null==e4?void 0:e4.total_saves)||0,color:"#F58529"}].filter(e=>e.value>0),st=(e,s,a,r,l,i)=>(0,t.jsxs)(n.Zb,{className:"relative overflow-hidden border-0 shadow-md hover:shadow-lg transition-shadow",children:[(0,t.jsx)("div",{className:"absolute inset-0 bg-gradient-to-br ".concat(r," opacity-0 group-hover:opacity-5 transition-opacity")}),(0,t.jsx)(n.aY,{className:"p-4",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground font-medium",children:e}),(0,t.jsxs)("p",{className:"text-2xl font-bold mt-1",children:["number"==typeof s?eB(s):s,i&&(0,t.jsx)("span",{className:"text-sm font-normal text-muted-foreground ml-1",children:i})]}),void 0!==l&&(0,t.jsxs)("div",{className:"flex items-center gap-1 mt-1 text-xs ".concat(l>=0?"text-green-600":"text-red-600"),children:[l>=0?(0,t.jsx)(L.Z,{className:"w-3 h-3"}):(0,t.jsx)(I.Z,{className:"w-3 h-3"}),(0,t.jsxs)("span",{children:[l>=0?"+":"",eB(l)]})]})]}),(0,t.jsx)("div",{className:"p-2.5 rounded-xl bg-gradient-to-br ".concat(r," shadow-lg"),children:a})]})})]}),sr=(e,s,a,r)=>(0,t.jsxs)(n.Zb,{className:"border-0 shadow-lg",children:[(0,t.jsx)(n.Ol,{className:"pb-2",children:(0,t.jsx)(n.ll,{className:"text-lg",children:a})}),(0,t.jsx)(n.aY,{children:e.length>0?(0,t.jsx)("div",{className:"h-[250px]",children:(0,t.jsx)(eh.h,{width:"100%",height:"100%",children:(0,t.jsxs)(eu.T,{data:e,margin:{top:10,right:10,left:0,bottom:0},children:[(0,t.jsx)("defs",{children:(0,t.jsxs)("linearGradient",{id:"gradient-".concat(r),x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,t.jsx)("stop",{offset:"5%",stopColor:s,stopOpacity:.3}),(0,t.jsx)("stop",{offset:"95%",stopColor:s,stopOpacity:0})]})}),(0,t.jsx)(eg.q,{strokeDasharray:"3 3",stroke:"hsl(var(--border))",vertical:!1}),(0,t.jsx)(ev.K,{dataKey:"displayDate",tick:{fontSize:11,fill:"hsl(var(--muted-foreground))"},tickLine:!1,axisLine:!1,interval:"preserveStartEnd"}),(0,t.jsx)(ep.B,{tick:{fontSize:11,fill:"hsl(var(--muted-foreground))"},tickLine:!1,axisLine:!1,tickFormatter:e=>eB(e),width:45}),(0,t.jsx)(eb.u,{contentStyle:{backgroundColor:"hsl(var(--background))",border:"1px solid hsl(var(--border))",borderRadius:"8px"},formatter:e=>[eB(e),r]}),(0,t.jsx)(ej.u,{type:"monotone",dataKey:r.toLowerCase(),stroke:s,strokeWidth:2,fill:"url(#gradient-".concat(r,")"),dot:!1})]})})}):(0,t.jsxs)("div",{className:"h-[250px] flex flex-col items-center justify-center text-muted-foreground text-center",children:[(0,t.jsx)(er.Z,{className:"w-8 h-8 text-amber-500 mb-2 opacity-60"}),(0,t.jsx)("p",{className:"text-sm",children:"Insights data requires additional permissions"})]})})]}),sl=(e,s)=>(0,t.jsx)(m.x,{className:"h-[350px] pr-4",children:e&&e.length>0?(0,t.jsx)("div",{className:"space-y-3",children:e.map((e,a)=>(0,t.jsxs)("div",{className:"flex items-start gap-3 p-3 rounded-lg bg-muted/30 hover:bg-muted/50 transition-colors",children:[(0,t.jsx)("div",{className:"flex items-center justify-center w-8 h-8 rounded-full text-white text-sm font-bold ".concat("facebook"===s?"bg-[#1877F2]":"bg-gradient-to-br from-purple-500 to-pink-500"),children:a+1}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:["facebook"===s?(0,t.jsx)(eZ,{className:"w-4 h-4 text-[#1877F2]"}):(0,t.jsx)(el.Z,{className:"w-4 h-4 text-[#E1306C]"}),e.media_type&&(0,t.jsx)(o.C,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:"VIDEO"===e.media_type?(0,t.jsx)(ei.Z,{className:"w-3 h-3"}):(0,t.jsx)(en.Z,{className:"w-3 h-3"})}),(e.created_time||e.timestamp)&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:new Date(e.created_time||e.timestamp||"").toLocaleDateString()})]}),(0,t.jsx)("p",{className:"text-sm truncate mb-2",children:e.message||e.caption||"No caption"}),(0,t.jsx)("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:"facebook"===s?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[(0,t.jsx)(ed.Z,{className:"w-3 h-3"})," ",eB(e.reactions||0)]}),(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[(0,t.jsx)(eo.Z,{className:"w-3 h-3"})," ",eB(e.comments)]}),(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[(0,t.jsx)(j.Z,{className:"w-3 h-3"})," ",eB(e.shares||0)]})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[(0,t.jsx)(et.Z,{className:"w-3 h-3"})," ",eB(e.likes||0)]}),(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[(0,t.jsx)(eo.Z,{className:"w-3 h-3"})," ",eB(e.comments)]})]})})]}),(0,t.jsx)(o.C,{className:"facebook"===s?"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400":"bg-pink-100 text-pink-700 dark:bg-pink-900/30 dark:text-pink-400",children:eB(e.engagement)})]},e.id))}):(0,t.jsxs)("div",{className:"h-full flex flex-col items-center justify-center text-muted-foreground py-12",children:[(0,t.jsx)(en.Z,{className:"w-12 h-12 mb-3 opacity-30"}),(0,t.jsx)("p",{children:"No posts data available"})]})}),si=e=>{let s="facebook"===e?null==$?void 0:$.facebook:null==$?void 0:$.instagram,a=(null==s?void 0:s.countries)||[],r="facebook"===e?"fans":"followers",l="facebook"===e?"from-blue-500 to-blue-600":"from-pink-500 to-rose-600";return(0,t.jsx)(m.x,{className:"h-[300px] pr-4",children:a.length>0?(0,t.jsx)("div",{className:"space-y-4",children:a.slice(0,8).map((e,s)=>{var i;let n=Number(null===(i=a[0])||void 0===i?void 0:i[r])||1,d=Number(e[r])||0,o=d/n*100;return(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,t.jsx)("span",{className:"font-medium",children:e.country}),(0,t.jsx)("span",{className:"text-muted-foreground",children:eB(d)})]}),(0,t.jsx)("div",{className:"h-2 bg-muted rounded-full overflow-hidden",children:(0,t.jsx)("div",{className:"h-full bg-gradient-to-r ".concat(l," rounded-full transition-all duration-500"),style:{width:"".concat(o,"%")}})})]},e.country||s)})}):(0,t.jsxs)("div",{className:"h-full flex flex-col items-center justify-center text-muted-foreground py-12",children:[(0,t.jsx)(f.Z,{className:"w-12 h-12 mb-3 opacity-30"}),(0,t.jsx)("p",{children:"No location data available"})]})})};return(0,t.jsxs)("div",{className:"space-y-6",children:[!Z&&(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"p-2.5 rounded-xl bg-gradient-to-br from-blue-600 to-purple-600 shadow-lg shadow-blue-500/25",children:(0,t.jsx)(ec.Z,{className:"w-5 h-5 text-white"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-xl font-semibold",children:"Meta Analytics"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Facebook & Instagram performance"})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[eS.length>1&&(0,t.jsxs)(c.Ph,{value:ez,onValueChange:eP,children:[(0,t.jsx)(c.i4,{className:"w-[180px] h-8 text-xs",children:(0,t.jsx)(c.ki,{placeholder:"Select page"})}),(0,t.jsxs)(c.Bw,{children:[(0,t.jsx)(c.Ql,{value:"all",children:"All Pages (Combined)"}),eS.map(e=>(0,t.jsx)(c.Ql,{value:e.page_id,children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(eZ,{className:"w-3 h-3 text-[#1877F2]"}),(0,t.jsx)("span",{className:"truncate max-w-[140px]",children:e.page_name})]})},e.page_id))]})]}),(0,t.jsx)(h.Tabs,{value:eT,onValueChange:eA,children:(0,t.jsxs)(h.TabsList,{className:"h-8",children:[(0,t.jsx)(h.TabsTrigger,{value:"7d",className:"text-xs px-2",children:"7D"}),(0,t.jsx)(h.TabsTrigger,{value:"14d",className:"text-xs px-2",children:"14D"}),(0,t.jsx)(h.TabsTrigger,{value:"28d",className:"text-xs px-2",children:"28D"}),(0,t.jsx)(h.TabsTrigger,{value:"90d",className:"text-xs px-2",children:"90D"})]})}),(0,t.jsx)(d.z,{variant:"outline",size:"sm",onClick:e1,disabled:eO,children:(0,t.jsx)(F.Z,{className:"w-4 h-4 ".concat(eO?"animate-spin":"")})})]})]}),(0,t.jsxs)(h.Tabs,{value:J,onValueChange:e=>ee(e),className:"space-y-6",children:[(0,t.jsxs)(h.TabsList,{className:"bg-muted/50 p-1 h-auto",children:[(0,t.jsxs)(h.TabsTrigger,{value:"overview",className:"flex items-center gap-2 px-4 py-2",children:[(0,t.jsx)(C.Z,{className:"w-4 h-4"}),(0,t.jsx)("span",{children:"Overview"})]}),(0,t.jsxs)(h.TabsTrigger,{value:"facebook",className:"flex items-center gap-2 px-4 py-2",children:[(0,t.jsx)(eZ,{className:"w-4 h-4"}),(0,t.jsx)("span",{children:"Facebook"}),(null==e8?void 0:e8.facebook)&&(0,t.jsx)("span",{className:"w-2 h-2 rounded-full bg-green-500"})]}),(0,t.jsxs)(h.TabsTrigger,{value:"instagram",className:"flex items-center gap-2 px-4 py-2",children:[(0,t.jsx)(el.Z,{className:"w-4 h-4"}),(0,t.jsx)("span",{children:"Instagram"}),(null==e8?void 0:e8.instagram)&&(0,t.jsx)("span",{className:"w-2 h-2 rounded-full bg-green-500"})]})]}),(0,t.jsxs)(h.TabsContent,{value:"overview",className:"space-y-6 mt-6",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,t.jsxs)(o.C,{variant:(null==e8?void 0:e8.facebook)?"default":"outline",className:"gap-1",children:[(0,t.jsx)(eZ,{className:"w-3 h-3"}),"Facebook ",(null==e8?void 0:e8.facebook)?"Connected":"Not Connected"]}),(0,t.jsxs)(o.C,{variant:(null==e8?void 0:e8.instagram)?"default":"outline",className:"gap-1",children:[(0,t.jsx)(el.Z,{className:"w-3 h-3"}),"Instagram ",(null==e8?void 0:e8.instagram)?"Connected":"Not Connected"]})]}),(0,t.jsxs)("div",{className:"flex flex-col lg:flex-row gap-4 lg:items-stretch",children:[(0,t.jsxs)(n.Zb,{className:"border-0 shadow-lg lg:w-[70%] flex flex-col",children:[(0,t.jsxs)(n.Ol,{className:"pb-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-gradient-to-br from-indigo-500 to-purple-600",children:(0,t.jsx)(L.Z,{className:"w-5 h-5 text-white"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)(n.ll,{className:"text-lg",children:"Trend Analysis"}),(0,t.jsxs)("p",{className:"text-sm text-muted-foreground",children:[eF[es].label," over time"]})]})]}),(0,t.jsx)(h.Tabs,{value:es,onValueChange:e=>ea(e),className:"mt-4",children:(0,t.jsx)(h.TabsList,{className:"bg-muted/50 p-1 h-auto flex-wrap",children:Object.keys(eF).map(e=>{let s=eF[e],a=s.icon;return(0,t.jsxs)(h.TabsTrigger,{value:e,className:"flex items-center gap-1.5 data-[state=active]:bg-background px-3 py-1.5",children:[(0,t.jsx)(a,{className:"w-4 h-4"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:s.label})]},e)})})})]}),(0,t.jsx)(n.aY,{className:"flex-1",children:eI.length>0?(0,t.jsx)("div",{className:"h-[280px]",children:(0,t.jsx)(eh.h,{width:"100%",height:"100%",children:(0,t.jsxs)(eu.T,{data:eI,margin:{top:10,right:10,left:0,bottom:0},children:[(0,t.jsx)("defs",{children:(0,t.jsxs)("linearGradient",{id:"gradient-meta-".concat(es),x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,t.jsx)("stop",{offset:"5%",
1stopColor:eF[es].color,stopOpacity:.3}),(0,t.jsx)("stop",{offset:"95%",stopColor:eF[es].color,stopOpacity:0})]})}),(0,t.jsx)(eg.q,{strokeDasharray:"3 3",stroke:"hsl(var(--border))",vertical:!1}),(0,t.jsx)(ev.K,{dataKey:"displayDate",tick:{fontSize:12,fill:"hsl(var(--muted-foreground))"},tickLine:!1,axisLine:!1,interval:"preserveStartEnd"}),(0,t.jsx)(ep.B,{tick:{fontSize:12,fill:"hsl(var(--muted-foreground))"},tickLine:!1,axisLine:!1,tickFormatter:e=>eB(e),width:50}),(0,t.jsx)(eb.u,{contentStyle:{backgroundColor:"hsl(var(--background))",border:"1px solid hsl(var(--border))",borderRadius:"8px"},formatter:e=>[eB(e),eF[es].label]}),(0,t.jsx)(ej.u,{type:"monotone",dataKey:es,stroke:eF[es].color,strokeWidth:2,fill:"url(#gradient-meta-".concat(es,")"),dot:!1})]})})}):(0,t.jsxs)("div",{className:"h-[280px] flex flex-col items-center justify-center text-muted-foreground text-center px-4",children:[(0,t.jsx)("div",{className:"p-3 rounded-full bg-amber-100 dark:bg-amber-900/30 mb-3",children:(0,t.jsx)(er.Z,{className:"w-8 h-8 text-amber-500"})}),(0,t.jsx)("p",{className:"font-medium mb-1",children:"Trend Data Unavailable"}),(0,t.jsxs)("p",{className:"text-sm max-w-md",children:["Daily insights require the ",(0,t.jsx)("code",{className:"bg-muted px-1 rounded",children:"read_insights"})," permission. Please reconnect your Facebook Page with full permissions to view trend data."]}),(0,t.jsxs)(d.z,{variant:"outline",size:"sm",className:"mt-3",onClick:e2,children:[(0,t.jsx)(_.Z,{className:"w-4 h-4 mr-2"}),"Reconnect Account"]})]})})]}),(0,t.jsx)(n.Zb,{className:"overflow-hidden border-0 shadow-xl lg:w-[30%] flex flex-col",children:(0,t.jsx)("div",{className:"bg-gradient-to-b from-pink-500 via-purple-500 to-indigo-500 p-1 flex-1",children:(0,t.jsxs)(n.aY,{className:"p-4 bg-gradient-to-b from-pink-500/95 via-purple-500/95 to-indigo-500/95 text-white rounded-lg h-full flex flex-col justify-center",children:[(0,t.jsx)("div",{className:"flex items-center justify-between mb-4",children:(0,t.jsxs)(o.C,{className:"bg-white/20 text-white border-white/30 backdrop-blur-sm px-3 py-1 text-xs font-semibold",children:[(0,t.jsx)(T.Z,{className:"w-3 h-3 mr-1"})," SOCIAL"]})}),(0,t.jsxs)("div",{className:"flex flex-col items-center text-center",children:[(0,t.jsxs)("div",{className:"relative mb-3",children:[(0,t.jsx)("div",{className:"w-20 h-20 rounded-2xl bg-white/20 backdrop-blur-sm flex items-center justify-center shadow-lg",children:(0,t.jsx)(y.Z,{className:"w-10 h-10"})}),(0,t.jsxs)("span",{className:"absolute -top-1 -right-1 flex h-4 w-4",children:[(0,t.jsx)("span",{className:"animate-ping absolute h-full w-full rounded-full bg-white opacity-75"}),(0,t.jsx)("span",{className:"relative rounded-full h-4 w-4 bg-white shadow-lg"})]})]}),(0,t.jsx)("p",{className:"text-white/70 text-sm font-medium mb-1",children:"Total Followers"}),(0,t.jsx)("p",{className:"text-4xl font-bold tracking-tight mb-4",children:eB(e7)}),(0,t.jsxs)("div",{className:"w-full space-y-3 pt-3 border-t border-white/20",children:[(0,t.jsxs)("div",{className:"flex justify-between items-center",children:[(0,t.jsx)("span",{className:"text-white/70 text-xs font-medium uppercase tracking-wider",children:"Engagement"}),(0,t.jsx)("span",{className:"text-lg font-bold",children:eB(se)})]}),(0,t.jsxs)("div",{className:"flex justify-between items-center",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(eZ,{className:"w-4 h-4"}),(0,t.jsx)("span",{className:"text-sm",children:eB((null==e4?void 0:e4.page_fans)||0)})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(el.Z,{className:"w-4 h-4"}),(0,t.jsx)("span",{className:"text-sm",children:eB((null==e4?void 0:e4.instagram_followers)||0)})]})]})]})]})]})})})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3 md:gap-4",children:[st("Followers",e7,(0,t.jsx)(y.Z,{className:"w-5 h-5 text-white"}),"from-blue-500 to-indigo-600",(Number(null==e4?void 0:e4.page_fans_change)||0)+(Number(null==e4?void 0:e4.instagram_followers_change)||0)),st("Engagement",se,(0,t.jsx)(et.Z,{className:"w-5 h-5 text-white"}),"from-pink-500 to-rose-600"),st("Reactions",(null==e4?void 0:e4.total_reactions)||0,(0,t.jsx)(ed.Z,{className:"w-5 h-5 text-white"}),"from-amber-500 to-orange-600"),st("Comments",(null==e4?void 0:e4.total_comments)||0,(0,t.jsx)(eo.Z,{className:"w-5 h-5 text-white"}),"from-green-500 to-emerald-600"),st("Shares",(null==e4?void 0:e4.total_shares)||0,(0,t.jsx)(j.Z,{className:"w-5 h-5 text-white"}),"from-purple-500 to-indigo-600")]}),(((null==e4?void 0:e4.page_reach)||0)>
10||((null==e4?void 0:e4.instagram_reach)||0)>0||((null==e4?void 0:e4.page_impressions)||0)>0)&&(0,t.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 md:gap-4",children:[st("Total Reach",(Number(null==e4?void 0:e4.page_reach)||0)+(Number(null==e4?void 0:e4.instagram_reach)||0),(0,t.jsx)(w.Z,{className:"w-5 h-5 text-white"}),"from-blue-600 to-cyan-600"),st("Impressions",(Number(null==e4?void 0:e4.page_impressions)||0)+(Number(null==e4?void 0:e4.instagram_impressions)||0),(0,t.jsx)(C.Z,{className:"w-5 h-5 text-white"}),"from-violet-500 to-purple-600"),st("Profile Views",(Number(null==e4?void 0:e4.page_views)||0)+(Number(null==e4?void 0:e4.instagram_profile_views)||0),(0,t.jsx)(R.Z,{className:"w-5 h-5 text-white"}),"from-orange-500 to-red-500"),st("Website Clicks",(null==e4?void 0:e4.instagram_website_clicks)||0,(0,t.jsx)(W.Z,{className:"w-5 h-5 text-white"}),"from-teal-500 to-emerald-600")]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[(0,t.jsxs)(n.Zb,{className:"border-0 shadow-lg",children:[(0,t.jsx)(n.Ol,{children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-gradient-to-br from-pink-500 to-rose-600",children:(0,t.jsx)(et.Z,{className:"w-5 h-5 text-white"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)(n.ll,{className:"text-lg",children:"Engagement Breakdown"}),(0,t.jsx)(n.SZ,{children:"How your audience interacts"})]})]})}),(0,t.jsx)(n.aY,{children:e6.length>0?(0,t.jsx)("div",{className:"h-[250px]",children:(0,t.jsx)(eh.h,{width:"100%",height:"100%",children:(0,t.jsxs)(ef.u,{children:[(0,t.jsx)(eN.b,{data:e6,cx:"50%",cy:"50%",innerRadius:60,outerRadius:90,paddingAngle:3,dataKey:"value",children:e6.map((e,s)=>(0,t.jsx)(ew.b,{fill:e.color},"cell-".concat(s)))}),(0,t.jsx)(eb.u,{formatter:e=>[eB(e),""]}),(0,t.jsx)(ey.D,{verticalAlign:"bottom",height:36})]})})}):(0,t.jsx)("div",{className:"h-[250px] flex items-center justify-center text-muted-foreground",children:(0,t.jsx)("p",{children:"No engagement data available"})})})]}),(0,t.jsxs)(n.Zb,{className:"border-0 shadow-lg",children:[(0,t.jsx)(n.Ol,{children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-gradient-to-br from-blue-500 to-purple-600",children:(0,t.jsx)(C.Z,{className:"w-5 h-5 text-white"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)(n.ll,{className:"text-lg",children:"Platform Comparison"}),(0,t.jsx)(n.SZ,{children:"Facebook vs Instagram"})]})]})}),(0,t.jsx)(n.aY,{children:(0,t.jsx)("div",{className:"h-[250px]",children:(0,t.jsx)(eh.h,{width:"100%",height:"100%",children:(0,t.jsxs)(ek.v,{data:e9,layout:"vertical",margin:{left:20},children:[(0,t.jsx)(eg.q,{strokeDasharray:"3 3",horizontal:!0,vertical:!1}),(0,t.jsx)(ev.K,{type:"number",tickFormatter:e=>eB(e)}),(0,t.jsx)(ep.B,{dataKey:"platform",type:"category",width:80}),(0,t.jsx)(eb.u,{formatter:e=>[eB(e),""]}),(0,t.jsx)(eD.$,{dataKey:"reach",name:"Reach",fill:"#3B82F6",radius:[0,4,4,0]}),(0,t.jsx)(eD.$,{dataKey:"impressions",name:"Impressions",fill:"#8B5CF6",radius:[0,4,4,0]}),(0,t.jsx)(eD.$,{dataKey:"engagement",name:"Engagement",fill:"#EC4899",radius:[0,4,4,0]}),(0,t.jsx)(ey.D,{})]})})})})]})]})]}),(0,t.jsx)(h.TabsContent,{value:"facebook",className:"space-y-6 mt-6",children:(null==e8?void 0:e8.facebook)||((null==e4?void 0:e4.page_fans)||0)>0?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[st("Page Fans",(null==e4?void 0:e4.page_fans)||0,(0,t.jsx)(y.Z,{className:"w-5 h-5 text-white"}),"from-blue-500 to-blue-600",null==e4?void 0:e4.page_fans_change),st("Page Reach",(null==e4?void 0:e4.page_reach)||0,(0,t.jsx)(w.Z,{className:"w-5 h-5 text-white"}),"from-blue-600 to-indigo-600"),st("Page Impressions",(null==e4?void 0:e4.page_impressions)||0,(0,t.jsx)(C.Z,{className:"w-5 h-5 text-white"}),"from-indigo-500 to-purple-600"),st("Post Engagements",(null==e4?void 0:e4.page_post_engagements)||0,(0,t.jsx)(et.Z,{className:"w-5 h-5 text-white"}),"from-purple-500 to-pink-600")]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[st("Page Views",(null==e4?void 0:e4.page_views)||0,(0,t.jsx)(R.Z,{className:"w-5 h-5 text-white"}),"from-orange-500 to-red-500"),st("Engaged Users",(null==e4?void 0:e4.page_engaged_users)||0,(0,t.jsx)(k.Z,{className:"w-5 h-5 text-white"}),"from-green-500 to-emerald-600"),st("Reactions",(null==e4?void 0:e4.total_reactions)||0,(0,t.jsx)(ed.Z,{className:"w-5 h-5 text-white"}),"from-amber-500 to-orange-600"),st("Shares",(null==e4?void 0:e4.total_shares)||0,(0,t.jsx)(j.Z,{className:"w-5 h-5 text-white"}),"from-teal-500 to-cyan-600")]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[sr(eG,"#1877F2","Reach Over Time","Reach"),sr(eG,"#42B72A","Engagement Over Time","Engagement")]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[(0,t.jsxs)(n.Zb,{className:"border-0 shadow-lg",children:[(0,t.jsx)(n.Ol,{children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-[#1877F2]",children:(0,t.jsx)(em.Z,{className:"w-5 h-5 text-white"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)(n.ll,{className:"text-lg",children:"Top Facebook Posts"}),(0,t.jsx)(n.SZ,{children:"Best performing content"})]})]})}),(0,t.jsx)(n.aY,{children:sl((null==Y?void 0:Y.facebook)||[],"facebook")})]}),(0,t.jsxs)(n.Zb,{className:"border-0 shadow-lg",children:[(0,t.jsx)(n.Ol,{children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-gradient-to-br from-blue-500 to-blue-600",children:(0,t.jsx)(f.Z,{className:"w-5 h-5 text-white"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)(n.ll,{className:"text-lg",children:"Fan Demographics"}),(0,t.jsx)(n.SZ,{children:"Where your fans are located"})]})]})}),(0,t.jsx)(n.aY,{children:si("facebook")})]})]}),(null==$?void 0:null===(l=$.facebook)||void 0===l?void 0:l.gender_age)&&Object.keys($.facebook.gender_age.male||{}).length>0?(0,t.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[(0,t.jsxs)(n.Zb,{className:"border-0 shadow-lg",children:[(0,t.jsx)(n.Ol,{children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-gradient-to-br from-blue-500 to-purple-600",children:(0,t.jsx)(y.Z,{className:"w-5 h-5 text-white"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)(n.ll,{className:"text-lg",children:"Gender Distribution"}),(0,t.jsx)(n.SZ,{children:"Audience breakdown by gender"})]})]})}),(0,t.jsx)(n.aY,{children:(0,t.jsx)("div",{className:"h-[250px]",children:(0,t.jsx)(eh.h,{width:"100%",height:"100%",children:(0,t.jsxs)(ef.u,{children:[(0,t.jsxs)(eN.b,{data:[{name:"Male",value:(null===(i=$.facebook.gender_age.totals)||void 0===i?void 0:i.male)||0,color:"#3B82F6"},{name:"Female",value:(null===(x=$.facebook.gender_age.totals)||void 0===x?void 0:x.female)||0,color:"#EC4899"}],cx:"50%",cy:"50%",innerRadius:60,outerRadius:90,paddingAngle:3,dataKey:"value",children:[(0,t.jsx)(ew.b,{fill:"#3B82F6"}),(0,t.jsx)(ew.b,{fill:"#EC4899"})]}),(0,t.jsx)(eb.u,{formatter:e=>[eB(e),""]}),(0,t.jsx)(ey.D,{verticalAlign:"bottom",height:36})]})})})})]}),(0,t.jsxs)(n.Zb,{className:"border-0 shadow-lg",children:[(0,t.jsx)(n.Ol,{children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-gradient-to-br from-purple-500 to-pink-600",children:(0,t.jsx)(C.Z,{className:"w-5 h-5 text-white"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)(n.ll,{className:"text-lg",children:"Age Distribution"}),(0,t.jsx)(n.SZ,{children:"Audience breakdown by age group"})]})]})}),(0,t.jsx)(n.aY,{children:(0,t.jsx)("div",{className:"h-[250px]",children:(0,t.jsx)(eh.h,{width:"100%",height:"100%",children:(0,t.jsxs)(ek.v,{data:Object.keys($.facebook.gender_age.male||{}).map(e=>{var s,a,t,r;return{age:e,male:(null===(a=$.facebook.gender_age)||void 0===a?void 0:null===(s=a.male)||void 0===s?void 0:s[e])||0,female:(null===(r=$.facebook.gender_age)||void 0===r?void 0:null===(t=r.female)||void 0===t?void 0:t[e])||0}}).sort((e,s)=>{let a=["13-17","18-24","25-34","35-44","45-54","55-64","65+"];return a.indexOf(e.age)-a.indexOf(s.age)}),margin:{left:10},children:[(0,t.jsx)(eg.q,{strokeDasharray:"3 3",vertical:!1}),(0,t.jsx)(ev.K,{dataKey:"age",tick:{fontSize:11}}),(0,t.jsx)(ep.B,{tickFormatter:e=>eB(e)}),(0,t.jsx)(eb.u,{formatter:e=>[eB(e),""]}),(0,t.jsx)(eD.$,{dataKey:"male",name:"Male",fill:"#3B82F6",radius:[4,4,0,0]}),(0,t.jsx)(eD.$,{dataKey:"female",name:"Female",fill:"#EC4899",radius:[4,4,0,0]}),(0,t.jsx)(ey.D,{})]})})})})]})]}):(0,t.jsxs)(n.Zb,{className:"border-0 shadow-lg",children:[(0,t.jsx)(n.Ol,{children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-gradient-to-br from-blue-500 to-purple-600",children:(0,t.jsx)(y.Z,{className:"w-5 h-5 text-white"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)(n.ll,{className:"text-lg",children:"Gender & Age Demographics"}),(0,t.jsx)(n.SZ,{children:"Audience breakdown by gender and age"})]})]})}),(0,t.jsx)(n.aY,{children:(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[(0,t.jsx)("div",{className:"p-3 rounded-full bg-amber-100 dar
1k:bg-amber-900/30 mb-4",children:(0,t.jsx)(er.Z,{className:"w-8 h-8 text-amber-500"})}),(0,t.jsx)("h4",{className:"font-medium mb-2",children:"Demographics Data Unavailable"}),(0,t.jsxs)("p",{className:"text-sm text-muted-foreground max-w-md mb-4",children:["Gender and age demographics require the ",(0,t.jsx)("code",{className:"bg-muted px-1 rounded",children:"read_insights"})," permission from Meta. Please reconnect your Facebook Page with full permissions enabled."]}),(0,t.jsxs)(d.z,{variant:"outline",size:"sm",onClick:e2,children:[(0,t.jsx)(_.Z,{className:"w-4 h-4 mr-2"}),"Reconnect Account"]})]})})]}),(0,t.jsxs)(n.Zb,{className:"border-0 shadow-lg",children:[(0,t.jsx)(n.Ol,{children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-gradient-to-br from-blue-500 to-indigo-600",children:(0,t.jsx)(et.Z,{className:"w-5 h-5 text-white"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)(n.ll,{className:"text-lg",children:"Engagement Breakdown"}),(0,t.jsx)(n.SZ,{children:"How users interact with your content"})]})]})}),(0,t.jsx)(n.aY,{children:ss.length>0?(0,t.jsx)("div",{className:"h-[300px]",children:(0,t.jsx)(eh.h,{width:"100%",height:"100%",children:(0,t.jsxs)(ek.v,{data:ss,margin:{left:20},children:[(0,t.jsx)(eg.q,{strokeDasharray:"3 3",vertical:!1}),(0,t.jsx)(ev.K,{dataKey:"name"}),(0,t.jsx)(ep.B,{tickFormatter:e=>eB(e)}),(0,t.jsx)(eb.u,{formatter:e=>[eB(e),""]}),(0,t.jsx)(eD.$,{dataKey:"value",radius:[4,4,0,0],children:ss.map((e,s)=>(0,t.jsx)(ew.b,{fill:e.color},"cell-".concat(s)))})]})})}):(0,t.jsx)("div",{className:"h-[300px] flex items-center justify-center text-muted-foreground",children:(0,t.jsx)("p",{children:"No engagement data available"})})})]})]}):(0,t.jsx)(n.Zb,{className:"border-dashed",children:(0,t.jsxs)(n.aY,{className:"flex flex-col items-center justify-center py-12",children:[(0,t.jsx)("div",{className:"p-3 rounded-full bg-blue-100 mb-4",children:(0,t.jsx)(eZ,{className:"w-8 h-8 text-[#1877F2]"})}),(0,t.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connect Facebook Page"}),(0,t.jsx)("p",{className:"text-muted-foreground text-center mb-4 max-w-sm",children:"Connect your Facebook Page to view detailed analytics."}),(0,t.jsxs)(d.z,{onClick:e2,children:[(0,t.jsx)(_.Z,{className:"w-4 h-4 mr-2"}),"Connect Facebook"]})]})})}),(0,t.jsx)(h.TabsContent,{value:"instagram",className:"space-y-6 mt-6",children:(null==e8?void 0:e8.instagram)||((null==e4?void 0:e4.instagram_followers)||0)>0?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[st("Followers",(null==e4?void 0:e4.instagram_followers)||0,(0,t.jsx)(y.Z,{className:"w-5 h-5 text-white"}),"from-purple-500 to-pink-500",null==e4?void 0:e4.instagram_followers_change),st("Reach",(null==e4?void 0:e4.instagram_reach
1)||0,(0,t.jsx)(w.Z,{className:"w-5 h-5 text-white"}),"from-pink-500 to-rose-500"),st("Impressions",(null==e4?void 0:e4.instagram_impressions)||0,(0,t.jsx)(C.Z,{className:"w-5 h-5 text-white"}),"from-rose-500 to-orange-500"),st("Profile Views",(null==e4?void 0:e4.instagram_profile_views)||0,(0,t.jsx)(R.Z,{className:"w-5 h-5 text-white"}),"from-orange-500 to-amber-500")]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[st("Website Clicks",(null==e4?void 0:e4.instagram_website_clicks)||0,(0,t.jsx)(W.Z,{className:"w-5 h-5 text-white"}),"from-green-500 to-emerald-600"),st("Total Likes",(null==e4?void 0:e4.total_reactions)||0,(0,t.jsx)(et.Z,{className:"w-5 h-5 text-white"}),"from-red-500 to-pink-600"),st("Comments",(null==e4?void 0:e4.total_comments)||0,(0,t.jsx)(eo.Z,{className:"w-5 h-5 text-white"}),"from-blue-500 to-indigo-600"),st("Saves",(null==e4?void 0:e4.total_saves)||0,(0,t.jsx)(ex.Z,{className:"w-5 h-5 text-white"}),"from-amber-500 to-yellow-500")]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[sr(eq,"#E1306C","Reach Over Time","Reach"),sr(eq,"#833AB4","Engagement Over Time","Engagement")]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[(0,t.jsxs)(n.Zb,{className:"border-0 shadow-lg",children:[(0,t.jsx)(n.Ol,{children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-gradient-to-br from-purple-500 to-pink-500",children:(0,t.jsx)(en.Z,{className:"w-5 h-5 text-white"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)(n.ll,{className:"text-lg",children:"Top Instagram Posts"}),(0,t.jsx)(n.SZ,{children:"Best performing content"})]})]})}),(0,t.jsx)(n.aY,{children:sl((null==Y?void 0:Y.instagram)||[],"instagram")})]}),(0,t.jsxs)(n.Zb,{className:"border-0 shadow-lg",children:[(0,t.jsx)(n.Ol,{children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-gradient-to-br from-pink-500 to-rose-600",children:(0,t.jsx)(f.Z,{className:"w-5 h-5 text-white"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)(n.ll,{className:"text-lg",children:"Follower Demographics"}),(0,t.jsx)(n.SZ,{children:"Where your followers are located"})]})]})}),(0,t.jsx)(n.aY,{children:si("instagram")})]})]}),(null==$?void 0:null===(u=$.instagram)||void 0===u?void 0:u.gender_age)&&Object.keys($.instagram.gender_age.male||{}).length>0?(0,t.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[(0,t.jsxs)(n.Zb,{className:"border-0 shadow-lg",children:[(0,t.jsx)(n.Ol,{children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-gradient-to-br from-pink-500 to-purple-600",children:(0,t.jsx)(y.Z,{className:"w-5 h-5 text-white"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)(n.ll,{className:"text-lg",children:"Gender Distribution"}),(0,t.jsx)(n.SZ,{children:"Audience breakdown by gender"})]})]})}),(0,t.jsx)(n.aY,{children:(0,t.jsx)("div",{className:"h-[250px]",children:(0,t.jsx)(eh.h,{width:"100%",height:"100%",children:(0,t.jsxs)(ef.u,{children:[(0,t.jsxs)(eN.b,{data:[{name:"Male",value:(null===(g=$.instagram.gender_age.totals)||void 0===g?void 0:g.male)||0,color:"#3B82F6"},{name:"Female",value:(null===(v=$.instagram.gender_age.totals)||void 0===v?void 0:v.female)||0,color:"#EC4899"}],cx:"50%",cy:"50%",innerRadius:60,outerRadius:90,paddingAngle:3,dataKey:"value",children:[(0,t.jsx)(ew.b,{fill:"#3B82F6"}),(0,t.jsx)(ew.b,{fill:"#EC4899"})]}),(0,t.jsx)(eb.u,{formatter:e=>[eB(e),""]}),(0,t.jsx)(ey.D,{verticalAlign:"bottom",height:36})]})})})})]}),(0,t.jsxs)(n.Zb,{className:"border-0 shadow-lg",children:[(0,t.jsx)(n.Ol,{children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-gradient-to-br from-rose-500 to-orange-500",children:(0,t.jsx)(C.Z,{className:"w-5 h-5 text-white"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)(n.ll,{className:"text-lg",children:"Age Distribution"}),(0,t.jsx)(n.SZ,{children:"Audience breakdown by age group"})]})]})}),(0,t.jsx)(n.aY,{children:(0,t.jsx)("div",{className:"h-[250px]",children:(0,t.jsx)(eh.h,{width:"100%",height:"100%",children:(0,t.jsxs)(ek.v,{data:Object.keys($.
1instagram.gender_age.male||{}).map(e=>{var s,a,t,r;return{age:e,male:(null===(a=$.instagram.gender_age)||void 0===a?void 0:null===(s=a.male)||void 0===s?void 0:s[e])||0,female:(null===(r=$.instagram.gender_age)||void 0===r?void 0:null===(t=r.female)||void 0===t?void 0:t[e])||0}}).sort((e,s)=>{let a=["13-17","18-24","25-34","35-44","45-54","55-64","65+"];return a.indexOf(e.age)-a.indexOf(s.age)}),margin:{left:10},children:[(0,t.jsx)(eg.q,{strokeDasharray:"3 3",vertical:!1}),(0,t.jsx)(ev.K,{dataKey:"age",tick:{fontSize:11}}),(0,t.jsx)(ep.B,{tickFormatter:e=>eB(e)}),(0,t.jsx)(eb.u,{formatter:e=>[eB(e),""]}),(0,t.jsx)(eD.$,{dataKey:"male",name:"Male",fill:"#3B82F6",radius:[4,4,0,0]}),(0,t.jsx)(eD.$,{dataKey:"female",name:"Female",fill:"#EC4899",radius:[4,4,0,0]}),(0,t.jsx)(ey.D,{})]})})})})]})]}):(0,t.jsxs)(n.Zb,{className:"border-0 shadow-lg",children:[(0,t.jsx)(n.Ol,{children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-gradient-to-br from-pink-500 to-purple-600",children:(0,t.jsx)(y.Z,{className:"w-5 h-5 text-white"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)(n.ll,{className:"text-lg",children:"Gender & Age Demographics"}),(0,t.jsx)(n.SZ,{children:"Audience breakdown by gender and age"})]})]})}),(0,t.jsx)(n.aY,{children:(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[(0,t.jsx)("div",{className:"p-3 rounded-full bg-amber-100 dark:bg-amber-900/30 mb-4",children:(0,t.jsx)(er.Z,{className:"w-8 h-8 text-amber-500"})}),(0,t.jsx)("h4",{className:"font-medium mb-2",children:"Demographics Data Unavailable"}),(0,t.jsxs)("p",{className:"text-sm text-muted-foreground max-w-md mb-4",children:["Gender and age demographics require the ",(0,t.jsx)("code",{className:"bg-muted px-1 rounded",children:"instagram_manage_insights"})," permission from Meta. Please reconnect your Instagram account with full permissions enabled."]}),(0,t.jsxs)(d.z,{variant:"outline",size:"sm",onClick:e2,children:[(0,t.jsx)(_.Z,{className:"w-4 h-4 mr-2"}),"Reconnect Account"]})]})})]}),(0,t.jsxs)(n.Zb,{className:"border-0 shadow-lg",children:[(0,t.jsx)(n.Ol,{children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-gradient-to-br from-purple-500 to-pink-600",children:(0,t.jsx)(et.Z,{className:"w-5 h-5 text-white"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)(n.ll,{className:"text-lg",children:"Engagement Breakdown"}),(0,t.jsx)(n.SZ,{children:"How users interact with your content"})]})]})}),(0,t.jsx)(n.aY,{children:sa.length>0?(0,t.jsx)("div",{className:"h-[300px]",children:(0,t.jsx)(eh.h,{width:"100%",height:"100%",children:(0,t.jsxs)(ek.v,{data:sa,margin:{left:20},children:[(0,t.jsx)(eg.q,{strokeDasharray:"3 3",vertical:!1}),(0,t.jsx)(ev.K,{dataKey:"name"}),(0,t.jsx)(ep.B,{tickFormatter:e=>eB(e)}),(0,t.jsx)(eb.u,{formatter:e=>[eB(e),""]}),(0,t.jsx)(eD.$,{dataKey:"value",radius:[4,4,0,0],children:sa.map((e,s)=>(0,t.jsx)(ew.b,{fill:e.color},"cell-".concat(s)))})]})})}):(0,t.jsx)("div",{className:"h-[300px] flex items-center justify-center text-muted-foreground",children:(0,t.jsx)("p",{children:"No engagement data available"})})})]})]}):(0,t.jsx)(n.Zb,{className:"border-dashed",children:(0,t.jsxs)(n.aY,{className:"flex flex-col items-center justify-center py-12",children:[(0,t.jsx)("div",{className:"p-3 rounded-full bg-gradient-to-br from-purple-500 to-pink-500 mb-4",children:(0,t.jsx)(el.Z,{className:"w-8 h-8 text-white"})}),(0,t.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connect Instagram Business"}),(0,t.jsx)("p",{className:"text-muted-foreground text-center mb-4 max-w-sm",children:"Connect your Instagram Business account to view detailed analytics."}),(0,t.jsxs)(d.z,{onClick:e2,className:"bg-gradient-to-r from-purple-500 to-pink-500 hover:from-purple-600 hover:to-pink-600",children:[(0,t.jsx)(_.Z,{className:"w-4 h-4 mr-2"}),"Connect Instagram"]})]})})})]})]})},eE=e=>{let{className:s}=e;return(0,t.jsx)("svg",{className:s,viewBox:"0 0 24 24",fill:"currentColor",children:(0,t.jsx)("path",{d:"M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"})})},eU=e=>
1({"United States":"\uD83C\uDDFA\uD83C\uDDF8",USA:"\uD83C\uDDFA\uD83C\uDDF8","United Kingdom":"\uD83C\uDDEC\uD83C\uDDE7",UK:"\uD83C\uDDEC\uD83C\uDDE7",Canada:"\uD83C\uDDE8\uD83C\uDDE6",Australia:"\uD83C\uDDE6\uD83C\uDDFA",Germany:"\uD83C\uDDE9\uD83C\uDDEA",France:"\uD83C\uDDEB\uD83C\uDDF7",India:"\uD83C\uDDEE\uD83C\uDDF3",Japan:"\uD83C\uDDEF\uD83C\uDDF5",China:"\uD83C\uDDE8\uD83C\uDDF3",Brazil:"\uD83C\uDDE7\uD83C\uDDF7",Mexico:"\uD83C\uDDF2\uD83C\uDDFD",Spain:"\uD83C\uDDEA\uD83C\uDDF8",Italy:"\uD83C\uDDEE\uD83C\uDDF9",Netherlands:"\uD83C\uDDF3\uD83C\uDDF1",Russia:"\uD83C\uDDF7\uD83C\uDDFA","South Korea":"\uD83C\uDDF0\uD83C\uDDF7",Singapore:"\uD83C\uDDF8\uD83C\uDDEC",Indonesia:"\uD83C\uDDEE\uD83C\uDDE9",Thailand:"\uD83C\uDDF9\uD83C\uDDED",Vietnam:"\uD83C\uDDFB\uD83C\uDDF3",Philippines:"\uD83C\uDDF5\uD83C\uDDED",Malaysia:"\uD83C\uDDF2\uD83C\uDDFE",UAE:"\uD83C\uDDE6\uD83C\uDDEA","United Arab Emirates":"\uD83C\uDDE6\uD83C\uDDEA","Saudi Arabia":"\uD83C\uDDF8\uD83C\uDDE6","South Africa":"\uD83C\uDDFF\uD83C\uDDE6",Nigeria:"\uD83C\uDDF3\uD83C\uDDEC",Egypt:"\uD83C\uDDEA\uD83C\uDDEC",Turkey:"\uD83C\uDDF9\uD83C\uDDF7",Poland:"\uD83C\uDDF5\uD83C\uDDF1",Sweden:"\uD83C\uDDF8\uD83C\uDDEA",Norway:"\uD83C\uDDF3\uD83C\uDDF4",Denmark:"\uD83C\uDDE9\uD83C\uDDF0",Finland:"\uD83C\uDDEB\uD83C\uDDEE",Switzerland:"\uD83C\uDDE8\uD83C\uDDED",Austria:"\uD83C\uDDE6\uD83C\uDDF9",Belgium:"\uD83C\uDDE7\uD83C\uDDEA",Portugal:"\uD83C\uDDF5\uD83C\uDDF9",Ireland:"\uD83C\uDDEE\uD83C\uDDEA","New Zealand":"\uD83C\uDDF3\uD83C\uDDFF",Argentina:"\uD83C\uDDE6\uD83C\uDDF7",Chile:"\uD83C\uDDE8\uD83C\uDDF1",Colombia:"\uD83C\uDDE8\uD83C\uDDF4",Peru:"\uD83C\uDDF5\uD83C\uDDEA",Israel:"\uD83C\uDDEE\uD83C\uDDF1",Pakistan:"\uD83C\uDDF5\uD83C\uDDF0",Bangladesh:"\uD83C\uDDE7\uD83C\uDDE9","Sri Lanka":"\uD83C\uDDF1\uD83C\uDDF0",Nepal:"\uD83C\uDDF3\uD83C\uDDF5",Kenya:"\uD83C\uDDF0\uD83C\uDDEA",Ghana:"\uD83C\uDDEC\uD83C\uDDED",Morocco:"\uD83C\uDDF2\uD83C\uDDE6","Czech Republic":"\uD83C\uDDE8\uD83C\uDDFF",Romania:"\uD83C\uDDF7\uD83C\uDDF4",Hungary:"\uD83C\uDDED\uD83C\uDDFA",Greece:"\uD83C\uDDEC\uD83C\uDDF7",Ukraine:"\uD83C\uDDFA\uD83C\uDDE6",Taiwan:"\uD83C\uDDF9\uD83C\uDDFC","Hong Kong":"\uD83C\uDDED\uD83C\uDDF0","(not set)":"\uD83C\uDF0D"})[e]||"\uD83C\uDF0D",eR=["#6366f1","#8b5cf6","#ec4899","#f59e0b","#22c55e","#06b6d4"];function eT(e){let{pages:s,dateRange:a}=e,r=(0,i.useRouter)(),l=e=>e>=1e6?"".concat((e/1e6).toFixed(1),"M"):e>=1e3?"".concat((e/1e3).toFixed(1),"K"):e.toLocaleString(),n=e=>{let s="page:".concat(encodeURIComponent(e.pagePath));r.push("/dashboard/analytics/drill?path=".concat(s,"&dateRange=").concat(a))};return(0,t.jsx)("div",{className:"space-y-3",children:s.slice(0,8).map((e,a)=>{var r;let i=(null===(r=s[0])||void 0===r?void 0:r.screenPageViews)||1,d=e.screenPageViews/i*100;return(0,t.jsxs)("div",{className:"group cursor-pointer",onClick:()=>n(e),children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[(0,t.jsx)("span",{className:"flex items-center justify-center w-6 h-6 rounded-full bg-muted text-xs font-medium text-muted-foreground",children:a+1}),(0,t.jsx)("span",{className:"text-sm font-medium truncate",title:e.pagePath,children:e.pagePath.length>40?e.pagePath.substring(0,40)+"...":e.pagePath})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3 text-sm flex-shrink-0",children:[(0,t.jsxs)("span",{className:"text-muted-foreground text-xs",children:[e.activeUsers," users"]}),(0,t.jsx)(o.C,{variant:"secondary",className:"font-semibold",children:l(e.screenPageViews)}),(0,t.jsx)(g.Z,{className:"w-4 h-4 text-muted-foreground/50 group-hover:text-primary group-hover:translate-x-0.5 transition-all"})]})]}),(0,t.jsx)("div",{className:"relative h-1.5 bg-muted rounded-full overflow-hidden",children:(0,t.jsx)("div",{className:"absolute inset-y-0 left-0 bg-gradient-to-r from-pink-500 to-rose-500 rounded-full transition-all duration-500",style:{width:"".concat(d,"%")}})})]},a)})})}function eA(e){let{deviceData:s,dateRange:a}=e,r=(0,i.useRouter)(),l=e=>"Desktop"===e||"desktop"===e?v.Z:"Mobile"===e||"mobile"===e?p.Z:"Tablet"===e||"tablet"===e?b.Z:v.Z,n=e=>{let s="device:".concat(encodeURIComponent(e.name.toLowerCase()));r.push("/dashboard/analytics/drill?path=".concat(s,"&dateRange=").concat(a))},d=s.reduce((e,s)=>e+s.value,0)||1;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"h-[180px]",children:(0,t.jsx)(eh.h,{width:"100%",height:"100%",children:(0,t.jsxs)(ef.u,{children:[(0,t.jsx)(eN.b,{data:s,cx:"50%",cy:"50%",innerRadius:50,outerRadius:75,paddingAngle:4,dataKey:"value",children:s.map((e,s)=>(0,t.jsx)(ew.b,{fill:eR[s%eR.length],strokeWidth:0},s))}),(0,t.jsx)(eb.u,{contentStyle:{backgroundColor:"rgba(0,0,0,0.8)",border:"none",borderRadius:"8px",color:"white"}})]})})}),(0,t.jsx)("div",{className:"space-y-2 mt-3",children:s.map((e,s)=>{let a=(e.value/d*100).toFixed(1),r=l(e.name);return(0,t.jsxs)("div",{className:"flex items-center justify-between text-sm p-2 rounded-lg hover:bg-muted/50 transition-colors cursor-pointer group",onClick:()=>n(e),children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"w-3 h-3 rounded-full shadow-sm",style:{backgroundColor:eR[s]}}),(0,t.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground",children:[(0,t.jsx)(r,{className:"w-4 h-4"}),(0,t.jsx)("span",{className:"font-medium text-foreground",children:e.name})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:e.value}),(0,t.jsxs)(o.C,{variant:"outline",className:"font-semibold",children:[a,"%"]}
1),(0,t.jsx)(g.Z,{className:"w-4 h-4 text-muted-foreground/50 group-hover:text-primary group-hover:translate-x-0.5 transition-all"})]})]},e.name)})})]})}function ez(e){let{trafficSources:s,firstUserSources:a,dateRange:n}=e,c=(0,i.useRouter)(),[m,x]=(0,r.useState)("sessions"),u=e=>e>=1e6?"".concat((e/1e6).toFixed(1),"M"):e>=1e3?"".concat((e/1e3).toFixed(1),"K"):e.toLocaleString(),v=(e,s)=>{let a="sessions"===s?e.sessionSource:e.firstUserSource,t="source:".concat(encodeURIComponent(a));c.push("/dashboard/analytics/drill?path=".concat(t,"&dateRange=").concat(n))},p=["from-blue-500 to-cyan-500","from-indigo-500 to-blue-500","from-violet-500 to-indigo-500","from-purple-500 to-violet-500","from-fuchsia-500 to-purple-500","from-pink-500 to-fuchsia-500"],b=["from-green-500 to-emerald-500","from-teal-500 to-green-500","from-cyan-500 to-teal-500","from-sky-500 to-cyan-500","from-blue-500 to-sky-500","from-indigo-500 to-blue-500"];return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"p-2.5 rounded-xl bg-gradient-to-br from-blue-500 to-cyan-600 shadow-lg shadow-blue-500/25",children:(0,t.jsx)(j.Z,{className:"w-5 h-5 text-white"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-lg font-semibold",children:"Traffic Sources"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"sessions"===m?"Session acquisition":"First-time visitors"})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("div",{className:"bg-muted/50 rounded-lg p-0.5",children:(0,t.jsx)(h.Tabs,{value:m,onValueChange:e=>x(e),children:(0,t.jsxs)(h.TabsList,{className:"grid grid-cols-2 h-7 bg-transparent",children:[(0,t.jsx)(h.TabsTrigger,{value:"sessions",className:"text-[10px] px-2 data-[state=active]:bg-background data-[state=active]:shadow-sm rounded-md",children:"Sessions"}),(0,t.jsx)(h.TabsTrigger,{value:"first_user",className:"text-[10px] px-2 data-[state=active]:bg-background data-[state=active]:shadow-sm rounded-md",children:"New Users"})]})})}),(0,t.jsx)(l.default,{href:"/dashboard/analytics/sources",children:(0,t.jsx)(d.z,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",children:(0,t.jsx)(g.Z,{className:"w-4 h-4"})})})]})]}),(0,t.jsx)("div",{className:"space-y-2.5",children:"sessions"===m?s.slice(0,6).map((e,a)=>{var r;let l=(null===(r=s[0])||void 0===r?void 0:r.sessions)||1,i=e.sessions/l*100;return(0,t.jsxs)("div",{className:"group p-2.5 rounded-xl hover:bg-muted/50 transition-all duration-200 -mx-1 cursor-pointer",onClick:()=>v(e,"sessions"),children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("div",{className:"w-2 h-2 rounded-full bg-gradient-to-r ".concat(p[a%p.length])}),(0,t.jsx)("span",{className:"text-sm font-medium truncate max-w-[180px] group-hover:text-primary transition-colors",children:e.sessionSource}),(0,t.jsxs)("span",{className:"text-xs text-muted-foreground",children:["/ ",e.sessionMedium]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(o.C,{variant:"secondary",className:"h-5 text-xs font-semibold",children:u(e.sessions)}),(0,t.jsx)(g.Z,{className:"w-4 h-4 text-muted-foreground/50 group-hover:text-primary group-hover:translate-x-0.5 transition-all"})]})]}),(0,t.jsx)("div",{className:"relative h-1.5 bg-muted/70 rounded-full overflow-hidden",children:(0,t.jsx)("div",{className:"absolute inset-y-0 left-0 bg-gradient-to-r ".concat(p[a%p.length]," rounded-full transition-all duration-700 ease-out"),style:{width:"".concat(i,"%")}})})]},a)}):a.slice(0,6).map((e,s)=>{var r;let l=(null===(r=a[0])||void 0===r?void 0:r.newUsers)||1,i=e.newUsers/l*100;return(0,t.jsxs)("div",{className:"group p-2.5 rounded-xl hover:bg-muted/50 transition-all duration-200 -mx-1 cursor-pointer",onClick:()=>v(e,"first_user"),children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("div",{className:"w-2 h-2 rounded-full bg-gradient-to-r ".concat(b[s%b.length])}),(0,t.jsx)("span",{className:"text-sm font-medium truncate max-w-[180px] group-hover:text-primary transition-colors",children:e.firstUserSource}),(0,t.jsxs)("span",{className:"text-xs text-muted-foreground",children:["/ ",e.firstUserMedium]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(o.C,{className:"h-5 text-xs font-semibold bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400 border-0",children:u(e.newUsers)}
1),(0,t.jsx)(g.Z,{className:"w-4 h-4 text-muted-foreground/50 group-hover:text-primary group-hover:translate-x-0.5 transition-all"})]})]}),(0,t.jsx)("div",{className:"relative h-1.5 bg-muted/70 rounded-full overflow-hidden",children:(0,t.jsx)("div",{className:"absolute inset-y-0 left-0 bg-gradient-to-r ".concat(b[s%b.length]," rounded-full transition-all duration-700 ease-out"),style:{width:"".concat(i,"%")}})})]},s)})})]})}function eP(e){let{countries:s,cities:a,totalUsers:n,dateRange:o}=e,c=(0,i.useRouter)(),[m,x]=(0,r.useState)("country"),u=e=>e>=1e6?"".concat((e/1e6).toFixed(1),"M"):e>=1e3?"".concat((e/1e3).toFixed(1),"K"):e.toLocaleString(),v=(e,s)=>{let a="country"===s?e.country:e.city,t="".concat("country"===s?"country":"city",":").concat(encodeURIComponent(a));c.push("/dashboard/analytics/drill?path=".concat(t,"&dateRange=").concat(o))};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"p-2.5 rounded-xl bg-gradient-to-br from-amber-500 to-orange-600 shadow-lg shadow-amber-500/25",children:(0,t.jsx)(f.Z,{className:"w-5 h-5 text-white"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-lg font-semibold",children:"Users by Location"}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:[s.length," countries • ",u(n)," users"]})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("div",{className:"bg-muted/50 rounded-lg p-0.5",children:(0,t.jsx)(h.Tabs,{value:m,onValueChange:e=>x(e),children:(0,t.jsxs)(h.TabsList,{className:"grid grid-cols-2 h-7 bg-transparent",children:[(0,t.jsx)(h.TabsTrigger,{value:"country",className:"text-[10px] px-2 data-[state=active]:bg-background data-[state=active]:shadow-sm rounded-md",children:"Countries"}),(0,t.jsx)(h.TabsTrigger,{value:"city",className:"text-[10px] px-2 data-[state=active]:bg-background data-[state=active]:shadow-sm rounded-md",children:"Cities"})]})})}),(0,t.jsx)(l.default,{href:"/dashboard/analytics/geographic",children:(0,t.jsx)(d.z,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",children:(0,t.jsx)(g.Z,{className:"w-4 h-4"})})})]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:["country"===m?s.slice(0,5).map((e,a)=>{var r;let l=n>0?e.activeUsers/n*100:0,i=((null===(r=s[0])||void 0===r?void 0:r.activeUsers)||1)/(n||1)*100;return(0,t.jsxs)("div",{className:"group flex items-center gap-3 p-2 rounded-lg hover:bg-muted/50 transition-colors cursor-pointer",onClick:()=>v(e,"country"),children:[(0,t.jsx)("span",{className:"text-lg",children:eU(e.country)}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,t.jsx)("span",{className:"text-sm font-medium truncate group-hover:text-primary transition-colors",children:e.country}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-sm font-bold text-primary",children:u(e.activeUsers)}),(0,t.jsx)(g.Z,{className:"w-4 h-4 text-muted-foreground/50 group-hover:text-primary group-hover:translate-x-0.5 transition-all"})]})]}),(0,t.jsx)("div",{className:"h-1 bg-muted/70 rounded-full overflow-hidden",children:(0,t.jsx)("div",{className:"h-full bg-gradient-to-r from-amber-500 to-orange-500 rounded-full",style:{width:"".concat(i>0?l/i*100:0,"%")}})})]})]},a)}):a.slice(0,5).map((e,s)=>{var r;let l=(null===(r=a[0])||void 0===r?void 0:r.activeUsers)||1,i=e.activeUsers/l*100;return(0,t.jsxs)("div",{className:"group flex items-center gap-3 p-2 rounded-lg hover:bg-muted/50 transition-colors cursor-pointer",onClick:()=>v(e,"city"),children:[(0,t.jsx)("span",{className:"text-lg",children:eU(e.country)}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-sm font-medium group-hover:text-primary transition-colors",children:e.city||"(not set)"}),(0,t.jsxs)("span",{className:"text-xs text-muted-foreground ml-1",children:["• ",e.country]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-sm font-bold text-primary",children:u(e.activeUsers)}
1),(0,t.jsx)(g.Z,{className:"w-4 h-4 text-muted-foreground/50 group-hover:text-primary group-hover:translate-x-0.5 transition-all"})]})]}),(0,t.jsx)("div",{className:"h-1 bg-muted/70 rounded-full overflow-hidden",children:(0,t.jsx)("div",{className:"h-full bg-gradient-to-r from-amber-500 to-orange-500 rounded-full",style:{width:"".concat(i,"%")}})})]})]},s)}),"country"===m&&0===s.length&&(0,t.jsxs)("div",{className:"text-center py-4 text-muted-foreground text-sm",children:[(0,t.jsx)(f.Z,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),(0,t.jsx)("p",{children:"No location data yet"})]}),"city"===m&&0===a.length&&(0,t.jsxs)("div",{className:"text-center py-4 text-muted-foreground text-sm",children:[(0,t.jsx)(N.Z,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),(0,t.jsx)("p",{children:"No city data yet"})]})]})]})}function eO(){return(0,t.jsxs)(J.zJ,{children:[(0,t.jsx)(eB,{}),(0,t.jsx)(ee.x,{})]})}function eB(){var e,s,a,i,J,ee,et,er,el,ei,en,ed,eo,ec,em,ex,ey,ek,eD,eZ,eF,eO,eB,eK,eV,eL,eM,eI,eY,eG,e$,eq,eH,eW,eQ,eX,eJ,e0,e5,e3,e1,e2,e4,e8,e6,e9,e7,se,ss,sa,st,sr,sl,si,sn,sd,so,sc,sm;let{user:sx}=(0,Q.a)(),{endNavigation:sh}=(0,X.H)(),su=(null==sx?void 0:sx.workspace_id)||"",[sg,sv]=(0,r.useState)(null),[sp,sb]=(0,r.useState)(null),[sj,sf]=(0,r.useState)(null),[sN,sw]=(0,r.useState)([]),[sy,sk]=(0,r.useState)(!0),[sD,sC]=(0,r.useState)(!1),[s_,sZ]=(0,r.useState)(!1),[sF,sS]=(0,r.useState)("28daysAgo"),[sE,sU]=(0,r.useState)(null),[sR,sT]=(0,r.useState)(!1),[sA,sz]=(0,r.useState)(!1),[sP,sO]=(0,r.useState)(!1),[sB,sK]=(0,r.useState)(!1),[sV,sL]=(0,r.useState)(!1),[sM,sI]=(0,r.useState)(!1),[sY,sG]=(0,r.useState)(!1),[s$,sq]=(0,r.useState)(!1),[sH,sW]=(0,r.useState)(!1),[sQ,sX]=(0,r.useState)("google"),[sJ,s0]=(0,r.useState)("28d"),[s5,s3]=(0,r.useState)("all"),[s1,s2]=(0,r.useState)([]),[s4,s8]=(0,r.useState)(!1),[s6,s9]=(0,r.useState)("sessions"),[s7,ae]=(0,r.useState)("summary"),[as,aa]=(0,r.useState)("country"),[at,ar]=(0,r.useState)("organic"),[al,ai]=(0,r.useState)([]),[an,ad]=(0,r.useState)(!1),[ao,ac]=(0,r.useState)("screenPageViews"),am={screenPageViews:{label:"Page Views",color:"#6366f1",icon:w.Z},activeUsers:{label:"Active Users",color:"#22c55e",icon:y.Z},newUsers:{label:"New Users",color:"#f59e0b",icon:k.Z},totalUsers:{label:"Total Users",color:"#ec4899",icon:y.Z}},ax=(0,r.useCallback)(async()=>{if(!su){sk(!1),sh(),sv({connected:!1});return}try{let e=await eC.api.get("/oauth/analytics/google/status?workspace_id=".concat(su));sv(e.data)}catch(e){console.error("Error fetching GA status:",e),sv({connected:!1})}finally{sk(!1),sh()}},[su,sh]),ah=(0,r.useCallback)(async()=>{if(su&&(null==sg?void 0:sg.connected))try{sC(!0);let e=await eC.api.get("/oauth/analytics/google/comprehensive?workspace_id=".concat(su,"&date_range=").concat(sF));sb(e.data)}catch(e){console.error("Error fetching GA data:",e)}finally{sC(!1)}},[su,null==sg?void 0:sg.connected,sF]),au=(0,r.useCallback)(async()=>{if(su&&(null==sg?void 0:sg.connected))try{let e=await eC.api.get("/oauth/analytics/google/realtime?workspace_id=".concat(su));e.data.success&&e.data.connected&&sf(e.data.data)}catch(e){console.error("Error fetching live data:",e)}},[su,null==sg?void 0:sg.connected]),ag=(0,r.useCallback)(async()=>{if(su)try{let e=await eC.api.get("/oauth/analytics/google/properties?workspace_id=".concat(su));sw(e.data.available_properties||[])}catch(e){console.error("Error fetching properties:",e)}},[su]),av=(0,r.useCallback)(async()=>{if(su)try{sT(!0);let e=await eC.api.get("/oauth/searchconsole/keywords?workspace_id=".concat(su,"&days=28&limit=20"));sU(e.data)}catch(e){console.error("Error fetching Search Console data:",e),sU({connected:!1})}finally{sT(!1)}},[su]),ap=(0,r.useCallback)(async()=>{if(su&&(null==sg?void 0:sg.connected)){ad(!0);try{var e;let s=await eC.api.get("/oauth/analytics/google/time-series?workspace_id=".concat(su,"&date_range=").concat(sF));if(null===(e=s.data)||void 0===e?void 0:e.data){let e=s.data.data.map(e=>({date:e.date||"",displayDate:ab(e.date||""),screenPageViews:e.screenPageViews||0,activeUsers:e.activeUsers||0,newUsers:e.newUsers||0,totalUsers:e.totalUsers||e.activeUsers||0})).sort((e,s)=>e.date.localeCompare(s.date));ai(e)}}catch(e){console.error("Error fetching time series data:",e),ai([])}finally{ad(!1)}}},[su,null==sg?void 0:sg.connected,sF]),ab=e=>{if(!e||8!==e.length)return e;let s=e.substring(0,4),a=e.substring(4,6),t=e.substring(6,8);return new Date("".concat(s,"-").concat(a,"-").concat(t)).toLocaleDateString("en-US",{month:"short",day:"numeric"})};(0,r.useEffect)(()=>{ax()},[su,ax]),(0,r.useEffect)(()=>
1{if((null==sg?void 0:sg.connected)&&su){ah(),au(),ag(),av(),ap();let e=setInterval(au,3e4);return()=>clearInterval(e)}},[null==sg?void 0:sg.connected,su,sF,ah,au,ag,av,ap]),(0,r.useEffect)(()=>{(async()=>{if(su&&"meta"===sQ)try{let e=await eC.api.get("/meta/analytics/pages?workspace_id=".concat(su));e.data.success&&s2(e.data.facebook_pages||[])}catch(e){console.error("Error fetching Meta connected pages:",e)}})()},[su,sQ]);let aj=async()=>{if(confirm("Disconnect Google Analytics?"))try{await eC.api.post("/oauth/analytics/google/disconnect?workspace_id=".concat(su)),e_.default.success("Disconnected"),sv({connected:!1}),sb(null)}catch(e){e_.default.error("Failed to disconnect")}},af=async e=>{try{await eC.api.post("/oauth/analytics/google/select-property?workspace_id=".concat(su,"&property_id=").concat(e)),e_.default.success("Property changed"),ax(),ah(),ap()}catch(e){e_.default.error("Failed to change property")}},aN=e=>e>=1e6?"".concat((e/1e6).toFixed(1),"M"):e>=1e3?"".concat((e/1e3).toFixed(1),"K"):e.toLocaleString(),aw=e=>"".concat(Math.floor(e/60),"m ").concat(Math.round(e%60),"s"),ay=(e,s)=>{let a=new Blob([e],{type:"text/csv;charset=utf-8;"}),t=window.document.createElement("a");t.href=URL.createObjectURL(a),t.download=s,t.click()},ak=e=>{if(sp){sZ(!0);try{let i="",n=new Date().toISOString().split("T")[0];switch(e){case"metrics":var s,a,t,r,l;i="Metric,Value\n"+"Users,".concat((null===(s=sp.metrics)||void 0===s?void 0:s.users)||0,"\n")+"Sessions,".concat((null===(a=sp.metrics)||void 0===a?void 0:a.sessions)||0,"\n")+"Page Views,".concat((null===(t=sp.metrics)||void 0===t?void 0:t.pageViews)||0,"\n")+"Bounce Rate,".concat((null===(r=sp.metrics)||void 0===r?void 0:r.bounceRate)||0,"%\n")+"Avg Duration,".concat(aw((null===(l=sp.metrics)||void 0===l?void 0:l.avgSessionDuration)||0));break;case"pages":i="Page Path,Page Title,Views,Users,Sessions,Bounce Rate\n"+(sp.pages||[]).map(e=>'"'.concat(e.pagePath,'","').concat(e.pageTitle,'",').concat(e.screenPageViews,",").concat(e.activeUsers,",").concat(e.sessions,",").concat(e.bounceRate,"%")).join("\n");break;case"countries":i="Country,Users,Sessions,New Users,Bounce Rate\n"+(sp.countries||[]).map(e=>'"'.concat(e.country,'",').concat(e.activeUsers,",").concat(e.sessions,",").concat(e.newUsers,",").concat(e.bounceRate,"%")).join("\n");break;case"sources":i="Source,Medium,Sessions,Users,New Users,Bounce Rate\n"+(sp.traffic_sources||[]).map(e=>'"'.concat(e.sessionSource,'","').concat(e.sessionMedium,'",').concat(e.sessions,",").concat(e.activeUsers,",").concat(e.newUsers,",").concat(e.bounceRate,"%")).join("\n")}ay(i,"ga_".concat(e,"_").concat(n,".csv")),e_.default.success("Exported successfully")}catch(e){e_.default.error("Export failed")}finally{sZ(!1)}}};if(sy)return(0,t.jsx)("div",{className:"flex items-center justify-center h-[60vh]",children:(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("div",{className:"w-16 h-16 rounded-full border-4 border-primary/20 border-t-primary animate-spin mx-auto"}),(0,t.jsx)(D.Z,{className:"w-6 h-6 text-primary absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2"})]}),(0,t.jsx)("p",{className:"mt-4 text-muted-foreground",children:"Loading analytics..."})]})});if(!su)return(0,t.jsx)("div",{className:"container mx-auto p-3 sm:p-4 md:p-6",children:(0,t.jsxs)("div",{className:"max-w-2xl mx-auto text-center py-16",children:[(0,t.jsxs)("div",{className:"relative mx-auto w-32 h-32 mb-8",children:[(0,t.jsx)("div",{className:"absolute inset-0 bg-gradient-to-br from-amber-400 to-orange-500 rounded-3xl rotate-6 opacity-20"}),(0,t.jsx)("div",{className:"absolute inset-0 bg-gradient-to-br from-amber-100 to-orange-100 dark:from-amber-900/30 dark:to-orange-900/30 rounded-3xl flex items-center justify-center",children:(0,t.jsx)(C.Z,{className:"w-14 h-14 text-amber-500"})})]}),(0,t.jsx)("h1",{className:"text-4xl font-bold mb-4 bg-gradient-to-r from-amber-500 to-orange-500 bg-clip-text text-transparent",children:"Workspace Required"}),(0,t.jsx)("p",{className:"text-lg text-muted-foreground mb-8 max-w-md mx-auto",children:"Please ensure you are logged in with a valid workspace to view anal
1ytics."})]})});if(!(null==sg?void 0:sg.connected))return(0,t.jsx)("div",{className:"container mx-auto p-3 sm:p-4 md:p-6",children:(0,t.jsxs)("div",{className:"max-w-2xl mx-auto text-center py-16",children:[(0,t.jsxs)("div",{className:"relative mx-auto w-32 h-32 mb-8",children:[(0,t.jsx)("div",{className:"absolute inset-0 bg-gradient-to-br from-orange-400 to-red-500 rounded-3xl rotate-6 opacity-20"}),(0,t.jsx)("div",{className:"absolute inset-0 bg-gradient-to-br from-orange-100 to-red-100 dark:from-orange-900/30 dark:to-red-900/30 rounded-3xl flex items-center justify-center",children:(0,t.jsx)(C.Z,{className:"w-14 h-14 text-orange-500"})})]}),(0,t.jsx)("h1",{className:"text-4xl font-bold mb-4 bg-gradient-to-r from-orange-500 to-red-500 bg-clip-text text-transparent",children:"Connect Google Analytics"}),(0,t.jsx)("p",{className:"text-lg text-muted-foreground mb-8 max-w-md mx-auto",children:"Get powerful insights into your website traffic, user behavior, and conversion metrics."}),(0,t.jsxs)(d.z,{size:"lg",onClick:()=>{window.location.href="/api/oauth/analytics/google/connect?workspace_id=".concat(su)},className:"gap-2 bg-gradient-to-r from-orange-500 to-red-500 hover:from-orange-600 hover:to-red-600 shadow-lg shadow-orange-500/25",children:[(0,t.jsx)(_.Z,{className:"w-5 h-5"}),"Connect Google Analytics"]})]})});let aD=(()=>{var e,s,a;if(null==sp?void 0:null===(s=sp.tech_details)||void 0===s?void 0:null===(e=s.device_categories)||void 0===e?void 0:e.length)return sp.tech_details.device_categories.map(e=>({name:(e.deviceCategory||"Unknown").charAt(0).toUpperCase()+(e.deviceCategory||"unknown").slice(1),value:e.activeUsers||0}));if(null==sj?void 0:null===(a=sj.visitors)||void 0===a?void 0:a.length){let e={desktop:0,mobile:0,tablet:0};return sj.visitors.forEach(s=>{let a=(s.device_type||"desktop").toLowerCase();e[a]=(e[a]||0)+(s.active_users||1)}),[{name:"Desktop",value:e.desktop||0},{name:"Mobile",value:e.mobile||0},{name:"Tablet",value:e.tablet||0}]}return[{name:"Desktop",value:50},{name:"Mobile",value:35},{name:"Tablet",value:15}]})(),aC=(null==sp?void 0:null===(e=sp.metrics)||void 0===e?void 0:e.users)||0;return(0,t.jsxs)("div",{className:"w-full px-4 md:px-6 space-y-4",children:["google"===sQ&&(0,t.jsxs)("div",{className:"relative animate-fade-in-up",children:[(0,t.jsx)("div",{className:"absolute inset-0 -z-10 bg-gradient-to-r from-indigo-500/10 via-purple-500/10 to-pink-500/10 rounded-2xl blur-2xl"}),(0,t.jsxs)("div",{className:"flex flex-col lg:flex-row lg:items-center lg:justify-between gap-3 p-4 rounded-xl bg-white/60 dark:bg-gray-900/60 backdrop-blur-xl border border-white/20 dark:border-white/10 shadow-lg",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsxs)("div",{className:"relative group",children:[(0,t.jsx)("div",{className:"absolute inset-0 bg-gradient-to-br from-indigo-500 to-purple-600 rounded-xl blur-md opacity-60 group-hover:opacity-80 transition-opacity"}),(0,t.jsx)("div",{className:"relative p-2 rounded-xl bg-gradient-to-br from-indigo-500 to-purple-600 shadow-lg shadow-indigo-500/25",children:(0,t.jsx)(C.Z,{className:"w-5 h-5 text-white"})})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{className:"text-2xl font-bold tracking-tight bg-gradient-to-r from-gray-900 to-gray-700 dark:from-white dark:to-gray-300 bg-clip-text text-transparent",children:"Analytics Dashboard"}),(0,t.jsxs)("p",{className:"text-sm text-muted-foreground flex items-center gap-1.5",children:[(0,t.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,t.jsx)("span",{className:"animate-ping absolute h-full w-full rounded-full bg-green-400 opacity-75"}),(0,t.jsx)("span",{className:"relative rounded-full h-2 w-2 bg-green-500"})]}),(null==sp?void 0:sp.property_name)||sg.property_name]})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,t.jsxs)(c.Ph,{value:sF,onValueChange:sS,children:[(0,t.jsxs)(c.i4,{"data-tour":"analytics-date-range",className:"w-[140px] bg-white/70 dark:bg-gray-800/70 backdrop-blur-xl border-white/30 dark:border-white/10 hover:bg-white/90 dark:hover:bg-gray-800/90 transition-colors",children:[(0,t.jsx)(Z.Z,{className:"w-4 h-4 mr-2 text-indigo-500"}),(0,t.jsx)(c.ki,{})]}),(0,t.jsxs)(c.Bw,{children:[(0,t.jsx)(c.Ql,{value:"2daysAgo",children:"Last 2 days"}),(0,t.jsx)(c.Ql,{value:"7daysAgo",children:"Last 7 days"}),(0,t.jsx)(c.Ql,{value:"28daysAgo",children:"Last 28 days"}),(0,t.jsx)(c.Ql,{value:"90daysAgo",children:"Last 90 days"})]})]}),sN.length>1&&(0,t.jsxs)(c.Ph,{value:sg.property_id,onValueChange:af,children:[(0,t.jsx)(c.i4,{className:"w-[180px] bg-white/70 dark:bg-gray-800/70 backdrop-blur-xl border-white/30 dark:border-white/10 hover:bg-white/90 dark:hover:bg-gray-800/90 transition-colors",children:(0,t.jsx)(c.ki,{placeholder:"Select property"})}),(0,t.jsx)(c.Bw,{children:sN.map(e=>(0,t.jsx)(c.Ql,{value:e.property_id,children:e.property_name},e.property_id))})]}),(0,t.jsx)(d.z,{variant:"outline",size:"icon",onClick:()=>{ah(),au(),ap()},disabled:sD,className:"bg-white/70 dark:bg-gray-800/70 backdrop-blur-xl border-white/30 dark:border-white/10 hover:bg-white/90 dark:hover:bg-gray-800/90 transition-colors",children:(0,t.jsx)(F.Z,{className:"w-4 h-4 ".concat(sD?"animate-spin":"")})}),(0,t.jsxs)(u.h_,{children:[(0,t.jsx)(u.$F,{asChild:!0,children:(0,t.jsxs)(d.z,{"data-tour":"analytics-export",variant:"outline",size:"sm",disabled:s_,className:"bg-white/70 dark:bg-gray-800/70 backdrop-blur-xl border-white/30 dark:border-white/10 hover:bg-white/90 dark:hover:bg-gray-800/90 transition-colors",children:[s_?(0,t.jsx)(S.Z,{className:"h-4 w-4 mr-2 animate-spin"}):(0,t.jsx)(E.Z,{className:"h-4 w-4 mr-2"}),"Export"]})}),(0,t.jsxs)(u.AW,{align:"end",className:"bg-white/90 dark:bg-gray-900/90 backdrop-blur-xl border-white/20",children:[(0,t.jsx)(u.Xi,{onClick:()=>ak("metrics"),children:"Metrics Summary"}),(0,t.jsx)(u.Xi,{onClick:()=>ak("pages"),children:"All Pages"}),(0,t.jsx)(u.Xi,{onClick:()=>ak("countries"),children:"Countries"}),(0,t.jsx)(u.Xi,{onClick:()=>ak("sources"),children:"Traffic Sources"})]})]}),(0,t.jsx)(l.default,{href:"/dashboard/analytics/reports",children:(0,t.jsxs)(d.z,{"data-tour":"analytics-reports",variant:"default",size:"sm",className:"bg-gradient-to-r from-rose-500 to-pink-500 hover:from-rose-600 hover:to-pink-600 text-white shadow-lg shadow-rose-500/25 hover:shadow-xl hover:shadow-rose-500/30 transition-all",children:[(0,t.jsx)(C.Z,{className:"h-4 w-4 mr-2"}),"View Reports"]})}),(0,t.jsxs)(d.z,{variant:"ghost",size:"sm",className:"text-red-500 hover:text-red-600 hover:bg-red-50 dark:hover:bg-red-950/30",onClick:aj,children:[(0,t.jsx)(U.Z,{className:"w-4 h-4 mr-1"})," Disconnect"]})]})]})]}),"meta"===sQ&&(0,t.jsxs)("div",{className:"relative animate-fade-in-up",children:[(0,t.jsx)("div",{className:"absolute inset-0 -z-10 bg-gradient-to-r from-blue-500/10 via-purple-500/10 to-pink-500/10 rounded-2xl blur-2xl"}),(0,t.jsxs)("div",{className:"flex flex-col lg:flex-row lg:items-center lg:justify-between gap-3 p-4 rounded-xl bg-white/60 dark:bg-gray-900/60 backdrop-blur-xl border border-white/20 dark:border-white/10 shadow-lg",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsxs)("div",{className:"relative group",children:[(0,t.jsx)("div",{className:"absolute inset-0 bg-gradient-to-br from-indigo-500 to-purple-600 rounded-xl blur-md opacity-60 group-hover:opacity-80 transition-opacity"}),(0,t.jsx)("div",{className:"relative p-2 rounded-xl bg-gradient-to-br from-indigo-500 to-purple-600 shadow-lg shadow-indigo-500/25",children:(0,t.jsx)(C.Z,{className:"w-5 h-5 text-white"})})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{className:"text-2xl font-bold tracking-tight bg-gradient-to-r from-gray-900 to-gray-700 dark:from-white dark:to-gray-300 bg-clip-text text-transparent",children:"Analytics Dashboard"}),(0,t.jsxs)("p",{className:"text-sm text-muted-foreground flex items-center gap-1.5",children:[(0,t.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,t.jsx)("span",{className:"animate-ping absolute h-full w-full rounded-full bg-green-400 opacity-75"}),(0,t.jsx)("span",{className:"relative rounded-full h-2 w-2 bg-green-500"})]}),"all"===s5?"All Pages (Combined)":(null===(s=s1.find(e=>e.page_id===s5))||void 0===s?void 0:s.page_name)||"Meta Analytics"]})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,t.jsxs)(c.Ph,{value:s5,onValueChange:s3,children:[(0,t.jsxs)(c.i4,{className:"w-[200px] bg-white/70 dark:bg-gray-800/70 backdrop-blur-xl border-white/30 dark:border-white/10 hover:bg-white/90 dark:hover:bg-gray-800/90 transition-colors",children:[(0,t.jsx)(eE,{className:"w-4 h-4 mr-2 text-[#1877F2]"}),(0,t.jsx)(c.ki,{placeholder:"Select page"})]}),(0,t.jsxs)(c.Bw,{children:[(0,t.jsx)(c.Ql,{value:"all",children:"All Pages (Combined)"}),s1.map(e=>(0,t.jsx)(c.Ql,{value:e.page_id,children:e.page_name},e.page_id))]})]}),(0,t.jsx)(h.Tabs,{value:sJ,onValueChange:s0,children:(0,t.jsxs)(h.TabsList,{className:"bg-white/70 dark:bg-gray-800/70 backdrop-blur-xl border border-white/30 dark:border-white/10",children:[(0,t.jsx)(h.TabsTrigger,{value:"7d",className:"text-xs px-3 data-[state=active]:bg-blue-500 data-[state=active]:text-white",children:"7D"}),(0,t.jsx)(h.TabsTrigger,{value:"14d",className:"text-xs px-3 data-[state=active]:bg-blue-500 data-[state=active]:text-white",children:"14D"}),(0,t.jsx)(h.TabsTrigger,{value:"28d",className:"text-xs px-3 data-[state=active]:bg-blue-500 data-[state=active]:text-white",children:"28D"}),(0,t.jsx)(h.TabsTrigger,{value:"90d",className:"text-xs px-3 data-[state=active]:bg-blue-500 data-[state=active]:text-white",children:"90D"})]})}),(0,t.jsx)(d.z,{variant:"outline",size:"icon",onClick:()=>s8(!0),disabled:s4,className:"bg-white/70 dark:bg-gray-800/70 backdrop-blur-xl border-white/30 dark:border-white/10 hover:bg-white/90 dark:hover:bg-gray-800/90 transition-colors",children:(0,t.jsx)(F.Z,{className:"w-4 h-4 ".concat(s4?"animate-spin":"")})})]})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1 p-1 bg-white/50 dark:bg-gray-900/50 backdrop-blur-xl rounded-xl w-fit border border-white/20 dark:border-white/10 shadow-lg animate-fade-in-up delay-100",children:[(0,t.jsxs)("button",{"data-tour":"analytics-google",onClick:()=>sX("google"),className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm font-medium transition-all duration-300 ".concat("google"===sQ?"bg-white dark:bg-gray-800 shadow-md text-foreground":"text-muted-foreground hover:text-foreground hover:bg-white/50 dark:hover:bg-gray-800/50"),children:[(0,t.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",children:[(0,t.jsx)("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z",fill:"#4285F4"}),(0,t.jsx)("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z",fill:"#34A853"}),(0,t.jsx)("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z",fill:"#FBBC05"}),(0,t.jsx)("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z",fill:"#EA4335"})]}),"Google Analytics"]}),(0,t.jsxs)("button",{"data-tour":"analytics-meta",onClick:()=>sX("meta"),className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm font-medium transition-all duration-300 ".concat("meta"===sQ?"bg-white dark:bg-gray-800 shadow-md text-foreground":"text-muted-foreground hover:text-foreground hover:bg-white/50 dark:hover:bg-gray-800/50"),children:[(0,t.jsx)(eE,{className:"w-4 h-4 text-[#1877F2]"}),"Meta Analytics"]})]}),"google"===sQ&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{"data-tour":"analytics-quick-access",className:"flex items-center gap-2 flex-wrap p-2.5 rounded-xl bg-white/40 dark:bg-gray-900/40 backdrop-blur-lg border border-white/20 dark:border-white/10 animate-fade-in-up delay-200",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground mr-2 font-medium",children:"Qu
1ick Access:"}),(0,t.jsx)(l.default,{href:"/dashboard/analytics/pages",children:(0,t.jsxs)(o.C,{variant:"outline",className:"cursor-pointer bg-white/60 dark:bg-gray-800/60 backdrop-blur-sm border-white/30 hover:bg-white/90 dark:hover:bg-gray-800/90 hover:shadow-md transition-all",children:[(0,t.jsx)(R.Z,{className:"w-3 h-3 mr-1"})," Pages"]})}),(0,t.jsx)(l.default,{href:"/dashboard/analytics/sources",children:(0,t.jsxs)(o.C,{variant:"outline",className:"cursor-pointer bg-white/60 dark:bg-gray-800/60 backdrop-blur-sm border-white/30 hover:bg-white/90 dark:hover:bg-gray-800/90 hover:shadow-md transition-all",children:[(0,t.jsx)(j.Z,{className:"w-3 h-3 mr-1"})," Sources"]})}),(0,t.jsx)(l.default,{href:"/dashboard/analytics/events",children:(0,t.jsxs)(o.C,{variant:"outline",className:"cursor-pointer bg-white/60 dark:bg-gray-800/60 backdrop-blur-sm border-white/30 hover:bg-white/90 dark:hover:bg-gray-800/90 hover:shadow-md transition-all",children:[(0,t.jsx)(T.Z,{className:"w-3 h-3 mr-1"})," Events"]})}),(0,t.jsx)(l.default,{href:"/dashboard/analytics/funnel",children:(0,t.jsxs)(o.C,{variant:"outline",className:"cursor-pointer bg-white/60 dark:bg-gray-800/60 backdrop-blur-sm border-white/30 hover:bg-white/90 dark:hover:bg-gray-800/90 hover:shadow-md transition-all",children:[(0,t.jsx)(A.Z,{className:"w-3 h-3 mr-1"})," Funnel"]})}),(0,t.jsx)(l.default,{href:"/dashboard/analytics/conversions",children:(0,t.jsxs)(o.C,{variant:"outline",className:"cursor-pointer bg-white/60 dark:bg-gray-800/60 backdrop-blur-sm border-white/30 hover:bg-white/90 dark:hover:bg-gray-800/90 hover:shadow-md transition-all",children:[(0,t.jsx)(z.Z,{className:"w-3 h-3 mr-1"})," Conversions"]})}),(0,t.jsx)(l.default,{href:"/dashboard/analytics/demographics",children:(0,t.jsxs)(o.C,{variant:"outline",className:"cursor-pointer bg-white/60 dark:bg-gray-800/60 backdrop-blur-sm border-white/30 hover:bg-white/90 dark:hover:bg-gray-800/90 hover:shadow-md transition-all",children:[(0,t.jsx)(f.Z,{className:"w-3 h-3 mr-1"})," Demographics"]})}),(0,t.jsx)(l.default,{href:"/dashboard/analytics/search-console",children:(0,t.jsxs)(o.C,{variant:"outline",className:"cursor-pointer bg-white/60 dark:bg-gray-800/60 backdrop-blur-sm border-white/30 hover:bg-white/90 dark:hover:bg-gray-800/90 hover:shadow-md transition-all",children:[(0,t.jsx)(P.Z,{className:"w-3 h-3 mr-1"})," Search Console"]})}),(0,t.jsx)(l.default,{href:"/dashboard/analytics/attribution",children:(0,t.jsxs)(o.C,{variant:"outline",className:"cursor-pointer bg-white/60 dark:bg-gray-800/60 backdrop-blur-sm border-white/30 hover:bg-white/90 dark:hover:bg-gray-800/90 hover:shadow-md transition-all",children:[(0,t.jsx)(O.Z,{className:"w-3 h-3 mr-1"})," Attribution"]})}),(0,t.jsx)(l.default,{href:"/dashboard/analytics/cohorts",children:(0,t.jsxs)(o.C,{variant:"outline",className:"cursor-pointer bg-white/60 dark:bg-gray-800/60 backdrop-blur-sm border-white/30 hover:bg-white/90 dark:hover:bg-gray-800/90 hover:shadow-md transition-all",children:[(0,t.jsx)(y.Z,{className:"w-3 h-3 mr-1"})," Cohorts"]})}),(0,t.jsx)(l.default,{href:"/dashboard/analytics/ecommerce",children:(0,t.jsxs)(o.C,{variant:"outline",className:"cursor-pointer bg-white/60 dark:bg-gray-800/60 backdrop-blur-sm border-white/30 hover:bg-white/90 dark:hover:bg-gray-800/90 hover:shadow-md transition-all",children:[(0,t.jsx)(B.Z,{className:"w-3 h-3 mr-1"})," E-commerce"]})}),(0,t.jsx)(l.default,{href:"/dashboard/analytics/web-vitals",children:(0,t.jsxs)(o.C,{variant:"outline",className:"cursor-pointer bg-white/60 dark:bg-gray-800/60 backdrop-blur-sm border-white/30 hover:bg-white/90 dark:hover:bg-gray-800/90 hover:shadow-md transition-all",children:[(0,t.jsx)(K.Z,{className:"w-3 h-3 mr-1"})," Web Vitals"]})}),(0,t.jsx)(l.default,{href:"/dashboard/analytics/geographic",children:(0,t.jsxs)(o.C,{variant:"outline",className:"cursor-pointer bg-white/60 dark:bg-gray-800/60 backdrop-blur-sm border-white/30 hover:bg-white/90 dark:hover:bg-gray-800/90 hover:shadow-md transition-all",children:[(0,t.jsx)(V.Z,{className:"w-3 h-3 mr-1"})," Geographic"]})})]}),(0,t.jsxs)("div",{className:"flex flex-col lg:flex-row gap-4 lg:items-stretch",children:[(0,t.jsxs)(n.Zb,{"data-tour":"analytics-trend-chart",className:"border-0 shadow-lg bg-white/70 dark:bg-gray-900/70 backdrop-blur-xl border border-white/20 dark:border-white/10 hover:shadow-2xl hover:border-white/40 dark:hover:border-white/20 transition-all duration-300 lg:w-[70%] flex flex-col",children:[(0,t.jsxs)(n.Ol,{className:"pb-2",children:[(0,t.jsx)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("div",{className:"absolute inset-0 bg-gradient-to-br from-indigo-500 to-purple-600 rounded-lg blur-md opacity-60"}),(0,t.jsx)("div",{className:"relative p-2 rounded-lg bg-gradient-to-br from-indigo-500 to-purple-600",children:(0,t.jsx)(L.Z,{className:"w-4 h-4 text-white"})})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(n.ll,{className:"text-base",children:"Trend Analysis"}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:[am[ao].label," over time"]})]})]})}),(0,t.jsx)(h.Tabs,{value:ao,onValueChange:e=>ac(e),className:"mt-3",children:(0,t.jsx)(h.TabsList,{className:"bg-muted/50 p-1 h-auto flex-wrap",children:Object.keys(am).map(e=>{let s=am[e],a=s.icon;return(0,t.jsxs)(h.TabsTrigger,{value:e,className:"flex items-center gap-1.5 data-[state=active]:bg-background px-2.5 py-1",children:[(0,t.jsx)(a,{className:"w-3.5 h-3.5"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:s.label})]},e)})})})]}),(0,t.jsx)(n.aY,{className:"flex-1 pt-0",children:an?(0,t.jsx)("div",{className:"h-[250px] flex items-center justify-center",children:(0,t.jsx)(S.Z,{className:"w-8 h-8 animate-spin text-primary"})}):al.length>0?(0,t.jsx)("div",{className:"h-[250px]",children:(0,t.jsx)(eh.h,{width:"100%",height:"100%",children:(0,t.jsxs)(eu.T,{data:al,margin:{top:10,right:10,left:0,bottom:0},children:[(0,t.jsx)("defs",{children:(0,t.jsxs)("linearGradient",{id:"gradient-main-".concat(ao),x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,t.jsx)("stop",{offset:"5%",
1stopColor:am[ao].color,stopOpacity:.3}),(0,t.jsx)("stop",{offset:"95%",stopColor:am[ao].color,stopOpacity:0})]})}),(0,t.jsx)(eg.q,{strokeDasharray:"3 3",stroke:"hsl(var(--border))",vertical:!1}),(0,t.jsx)(ev.K,{dataKey:"displayDate",tick:{fontSize:12,fill:"hsl(var(--muted-foreground))"},tickLine:!1,axisLine:!1,interval:"preserveStartEnd"}),(0,t.jsx)(ep.B,{tick:{fontSize:12,fill:"hsl(var(--muted-foreground))"},tickLine:!1,axisLine:!1,tickFormatter:e=>e>=1e6?"".concat((e/1e6).toFixed(1),"M"):e>=1e3?"".concat((e/1e3).toFixed(1),"K"):e.toString(),width:50}),(0,t.jsx)(eb.u,{contentStyle:{backgroundColor:"hsl(var(--background))",border:"1px solid hsl(var(--border))",borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.1)"},formatter:e=>[e>=1e3?"".concat((e/1e3).toFixed(1),"K"):e.toLocaleString(),am[ao].label],labelFormatter:e=>"Date: ".concat(e)}),(0,t.jsx)(ej.u,{type:"monotone",dataKey:ao,stroke:am[ao].color,strokeWidth:2,fill:"url(#gradient-main-".concat(ao,")"),dot:!1,activeDot:{r:6,strokeWidth:2,fill:"hsl(var(--background))"}})]})})}):(0,t.jsxs)("div",{className:"h-[250px] flex flex-col items-center justify-center text-muted-foreground",children:[(0,t.jsx)(C.Z,{className:"w-12 h-12 mb-3 opacity-30"}),(0,t.jsx)("p",{children:"No trend data available"}),(0,t.jsx)("p",{className:"text-sm",children:"Data will appear once analytics are collected"})]})})]}),sj&&(0,t.jsx)(n.Zb,{className:"overflow-hidden border-0 shadow-xl bg-white/70 dark:bg-gray-900/70 backdrop-blur-xl border border-white/20 dark:border-white/10 hover:shadow-2xl hover:border-white/40 dark:hover:border-white/20 transition-all duration-300 lg:w-[30%] flex flex-col",children:(0,t.jsx)("div",{className:"bg-gradient-to-b from-emerald-500 via-green-500 to-teal-500 p-1 flex-1",children:(0,t.jsxs)(n.aY,{className:"p-4 bg-gradient-to-b from-emerald-500/95 via-green-500/95 to-teal-500/95 text-white rounded-lg h-full flex flex-col justify-center",children:[(0,t.jsx)("div",{className:"flex items-center justify-between mb-4",children:(0,t.jsxs)(o.C,{className:"bg-white/20 text-white border-white/30 backdrop-blur-sm px-3 py-1 text-xs font-semibold",children:[(0,t.jsx)(T.Z,{className:"w-3 h-3 mr-1"})," LIVE"]})}),(0,t.jsxs)("div",{className:"flex flex-col items-center text-center",children:[(0,t.jsxs)("div",{className:"relative mb-3",children:[(0,t.jsx)("div",{className:"w-20 h-20 rounded-2xl bg-white/20 backdrop-blur-sm flex items-center justify-center shadow-lg",children:(0,t.jsx)(M.Z,{className:"w-10 h-10"})}),(0,t.jsxs)("span",{className:"absolute -top-1 -right-1 flex h-4 w-4",children:[(0,t.jsx)("span",{className:"animate-ping absolute h-full w-full rounded-full bg-white opacity-75"}),(0,t.jsx)("span",{className:"relative rounded-full h-4 w-4 bg-white shadow-lg"})]})]}),(0,t.jsx)("p",{className:"text-white/70 text-sm font-medium mb-1",children:"Active Right Now"}),(0,t.jsx)("p",{className:"text-5xl font-bold tracking-tight mb-4",children:sj.summary.active_now}),(0,t.jsxs)("div",{className:"w-full space-y-3 pt-3 border-t border-white/20",children:[(0,t.jsxs)("div",{className:"flex justify-between items-center",children:[(0,t.jsx)("span",{className:"text-white/70 text-xs font-medium uppercase tracking-wider",children:"Page Views (30m)"}),(0,t.jsx)("span",{className:"text-lg font-bold",children:sj.summary.total_pageviews})]}),(0,t.jsxs)("div",{className:"text-left",children:[(0,t.jsx)("p",{className:"text-white/70 text-xs font-medium uppercase tracking-wider mb-1",children:"Top Page"}),(0,t.jsx)("p",{className:"text-xs font-medium truncate bg-white/10 rounded-full px-3 py-1.5",children:(null===(a=sj.summary.popular_pages[0])||void 0===a?void 0:a.page)||"N/A"})]})]})]})]})})})]}),(null==sp?void 0:sp.metrics)&&(0,t.jsxs)("div",{"data-tour":"analytics-metrics",className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-5 gap-2 sm:gap-3 md:gap-4",children:[(0,t.jsx)(es.O$,{label:"Users",value:sp.metrics.users,icon:y.Z,dimension:"source",breakdownOptions:["source","country","device","page"],gradient:"from-blue-500 to-indigo-600",dateRange:sF,propertyId:null==sg?void 0:sg.property_id}),(0,t.jsx)(es.O$,{label:"Sessions",value:sp.metrics.sessions,icon:L.Z,dimension:"source",breakdownOptions:["source","page","device","country"],gradient:"from-purple-500 to-pink-600",dateRange:sF,propertyId:null==sg?void 0:sg.property_id}),(0,t.jsx)(es.O$,{label:"Page Views",value:sp.metrics.pageViews,icon:w.Z,dimension:"page",breakdownOptions:["page","source","device","country"],gradient:"from-indigo-500 to-purple-600",dateRange:sF,propertyId:null==sg?void 0:sg.property_id}),(0,t.jsx)(es.O$,{label:"Bounce Rate",value:sp.metrics.bounceRate,icon:I.Z,format:"percent",dimension:"page",breakdownOptions:["page","source","device"],gradient:"from-orange-500 to-red-500",dateRange:sF,propertyId:null==sg?void 0:sg.property_id,hint:"Click for page breakdown"}),(0,t.jsx)(es.O$,{label:"Avg. Duration",value:sp.metrics.avgSessionDuration,icon:Y.Z,format:"duration",dimension:"page",breakdownOptions:["page","source","device"],gradient:"from-cyan-500 to-teal-500",dateRange:sF,propertyId:null==sg?void 0:sg.property_id})]}),(null==sp?void 0:null===(i=sp.new_vs_returning)||void 0===i?void 0:i.summary)&&sp.new_vs_returning.summary.length>0&&(0,t.jsxs)(n.Zb,{className:"border-0 shadow-lg bg-white/70 dark:bg-gray-900/70 backdrop-blur-xl border border-white/20 dark:border-white/10 hover:shadow-2xl hover:border-white/40 dark:hover:border-white/20 transition-all duration-300 overflow-hidden",children:[(0,t.jsx)(n.Ol,{className:"flex flex-row items-center justify-between pb-2",children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("div",{className:"absolute inset-0 bg-gradient-to-br from-violet-500 to-fuchsia-600 rounded-lg blur-md opacity-60"}),(0,t.jsx)("div",{className:"relative p-2 rounded-lg bg-gradient-to-br from-violet-500 to-fuchsia-600 shadow-md",children:(0,t.jsx)(G.Z,{className:"w-4 h-4 text-white"})})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(n.ll,{className:"text-lg",children:"New vs Returning Users"}),(0,t.jsx)(n.SZ,{children:"Click on a card to drill down into user behavior"})]})]})}),(0,t.jsx)(n.aY,{children:(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[(0,t.jsxs)("div",{className:"flex flex-col items-center",children:[(0,t.jsx)("div",{className:"h-[180px] w-full",children:(0,t.jsx)(eh.h,{width:"100%",height:"100%",children:(0,t.jsxs)(ef.u,{children:[(0,t.jsx)(eN.b,{data:sp.new_vs_returning.summary.map(e=>({name:"new"===e.userType?"New Users":"Returning Users",value:e.activeUsers})),cx:"50%",cy:"50%",innerRadius:55,outerRadius:80,paddingAngle:4,dataKey:"value",children:sp.new_vs_returning.summary.map((e,s)=>(0,t.jsx)(ew.b,{fill:"new"===e.userType?"#22c55e":"#6366f1",strokeWidth:0},s))}),(0,t.jsx)(eb.u,{formatter:e=>aN(e),contentStyle:{backgroundColor:"rgba(0,0,0,0.8)",border:"none",borderRadius:"8px",color:"white"}})]})})}),(0,t.jsx)("div",{className:"flex gap-6 mt-3",children:sp.new_vs_returning.summary.map((e,s)=>{let a=sp.new_vs_returning.summary.reduce((e,s)=>e+s.activeUsers,0)||1,r=(e.activeUsers/a*100).toFixed(1);return(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("div",{className:"w-3 h-3 rounded-full shadow-sm",style:{backgroundColor:"new"===e.userType?"#22c55e":"#6366f1"}}),(0,t.jsxs)("span",{className:"text-sm font-medium",children:["new"===e.userType?"New":"Returning",": ",r,"%"]})]},s)})})]}),(()=>{var e;let s=null===(e=sp.new_vs_returning)||void 0===e?void 0:e.summary.find(e=>"new"===e.userType);return(0,t.jsx)(l.default,{href:"/dashboard/analytics/drill?path=user_type:new&dateRange=".concat(sF),children:(0,t.jsxs)("div",{className:"p-5 rounded-2xl bg-gradient-to-br from-green-50 to-emerald-50 dark:from-green-950/40 dark:to-emerald-950/40 border border-green-100 dark:border-green-800/50 cursor-pointer hover:shadow-lg hover:scale-[1.02] transition-all group",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("div",{className:"p-1.5 rounded-lg bg-green-100 dark:bg-green-900/50",children:(0,t.jsx)($.Z,{className:"w-4 h-4 text-green-600"})}),(0,t.jsx)("h4",{className:"font-semibold text-green-700 dark:text-green-400",children:"New Users"})]}),(0,t.jsx)(g.Z,{className:"w-4 h-4 text-green-600 opacity-0 group-hover:opacity-100 transition-opacity"})]}),(0,t.jsx)("div",{className:"space-y-2.5",children:[{label:"Users",value:aN((null==s?void 0:s.activeUsers)||0)},{label:"Sessions",value:aN((null==s?void 0:s.sessions)||0)},{label:"Engagement",value:"".concat(((null==s?void 0:s.engagementRate)||0).toFixed(1),"%")},{label:"Bounce Rate",value:"".concat(((null==s?void 0:s.bounceRate)||0).toFixed(1),"%")},{label:"Avg Duration",value:"".concat(Math.round((null==s?void 0:s.averageSessionDuration)||0),"s")}].map((e,s)=>(0,t.jsxs)("div",{className:"flex justify-between text-sm",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:e.label}),(0,t.jsx)("span",{className:"font-semibold",children:e.value})]},s))})]})})})(),(()=>{var e;let s=null===(e=sp.new_vs_returning)||void 0===e?void 0:e.summary.find(e=>"returning"===e.userType);return(0,t.jsx)(l.default,{href:"/dashboard/analytics/drill?path=user_type:returning&dateRange=".concat(sF),children:(0,t.jsxs)("div",{className:"p-5 rounded-2xl bg-gradient-to-br from-indigo-50 to-purple-50 dark:from-indigo-950/40 dark:to-purple-950/40 border border-indigo-100 dark:border-indigo-800/50 cursor-pointer hover:shadow-lg hover:scale-[1.02] transition-all group",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("div",{className:"p-1.5 rounded-lg bg-indigo-100 dark:bg-indigo-900/50",children:(0,t.jsx)(q.Z,{className:"w-4 h-4 text-indigo-600"})}),(0,t.jsx)("h4",{className:"font-semibold text-indigo-700 dark:text-indigo-400",children:"Returning Users"})]}),(0,t.jsx)(g.Z,{className:"w-4 h-4 text-indigo-600 opacity-0 group-hover:opacity-100 transition-opacity"})]}),(0,t.jsx)("div",{className:"space-y-2.5",children:[{label:"Users",value:aN((null==s?void 0:s.activeUsers)||0)},{label:"Sessions",value:aN((null==s?void 0:s.sessions)||0)},{label:"Engagement",value:"".concat(((null==s?void 0:s.engagementRate)||0).toFixed(1),"%")},{label:"Bounce Rate",value:"".concat(((null==s?void 0:s.bounceRate)||0).toFixed(1),"%")},{label:"Avg Duration",value:"".concat(Math.round((null==s?void 0:s.averageSessionDuration)||0),"s")}].map((e,s)=>(0,t.jsxs)("div",{className:"flex justify-between text-sm",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:e.label}),(0,t.jsx)("span",{className:"font-semibold",children:e.value})]},s))})]})})})()]})})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[(0,t.jsxs)(n.Zb,{className:"lg:col-span-2 border-0 shadow-lg",children:[(0,t.jsxs)(n.Ol,{className:"flex flex-row items-center justify-between pb-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-gradient-to-br from-pink-500 to-rose-600 shadow-md",children:(0,t.jsx)(R.Z,{className:"w-4 h-4 text-white"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)(n.ll,{className:"text-lg",children:"Top Pages"}),(0,t.jsxs)(n.SZ,{children:[(null==sp?void 0:null===(J=sp.pages)||void 0===J?void 0:J.length)||0," pages tracked"]})]})]}),(0,t.jsx)(l.default,{href:"/dashboard/analytics/pages",children:(0,t.jsxs)(d.z,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground",children:["View All ",(0,t.jsx)(g.Z,{className:"w-4 h-4 ml-1"})]})})]}),(0,t.jsx)(n.aY,{children:(0,t.jsx)(eT,{pages:(null==sp?void 0:sp.pages)||[],dateRange:sF})})]}),(0,t.jsxs)(n.Zb,{className:"border-0 shadow-lg bg-white/70 dark:bg-gray-900/70 backdrop-blur-xl border border-white/20 dark:border-white/10 hover:shadow-2xl hover:border-white/40 dark:hover:border-white/20 transition-all duration-300",children:[(0,t.jsx)(n.Ol,{className:"pb-2",children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-gradient-to-br from-violet-500 to-purple-600 shadow-md",children:(0,t.jsx)(v.Z,{className:"w-4 h-4 text-white"})}),(0,t.jsx)(n.ll,{className:"text-lg",children:"Devices"})]})}),(0,t.jsx)(n.aY,{children:(0,t.jsx)(eA,{deviceData:aD,dateRange:sF})})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[(0,t.jsxs)(n.Zb,{className:"border-0 shadow-lg bg-white/70 dark:bg-gray-900/70 backdrop-blur-xl border border-white/20 dark:border-white/10 hover:shadow-2xl hover:border-white/40 dark:hover:border-white/20 transition-all duration-300 overflow-hidden",children:[(0,t.jsx)("div",{className:"h-1 bg-gradient-to-r from-blue-500 via-cyan-500 to-teal-500"}),(0,t.jsx)(n.aY,{className:"pt-4",children:(0,t.jsx)(ez,{trafficSources:(null==sp?void 0:sp.traffic_sources)||[],firstUserSources:(null==sp?void 0:sp.first_user_sources)||[],dateRange:sF})})]}),(0,t.jsxs)(n.Zb,{className:"border-0 shadow-lg bg-white/70 dark:bg-gray-900/70 backdrop-blur-xl border border-white/20 dark:border-white/10 hover:shadow-2xl hover:border-white/40 dark:hover:border-white/20 transition-all duration-300 overflow-hidden",children:[(0,t.jsx)("div",{className:"h-1 bg-gradient-to-r from-amber-500 via-orange-500 to-red-500"}),(0,t.jsx)(n.aY,{className:"pt-4",children:(0,t.jsx)(eP,{countries:(null==sp?void 0:sp.countries)||[],cities:(null==sp?void 0:sp.cities)||[],totalUsers:aC,dateRange:sF})})]})]}
1),(null==sp?void 0:null===(ee=sp.key_events_by_platform)||void 0===ee?void 0:ee.length)||(null==sp?void 0:null===(et=sp.events_by_name)||void 0===et?void 0:et.length)?(0,t.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[(0,t.jsxs)(n.Zb,{className:"cursor-pointer hover:shadow-xl transition-all duration-300 border-0 shadow-lg group",onClick:()=>sq(!0),children:[(0,t.jsx)(n.Ol,{className:"pb-2",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-gradient-to-br from-amber-500 to-orange-600 shadow-md",children:(0,t.jsx)(A.Z,{className:"w-4 h-4 text-white"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)(n.ll,{className:"text-lg",children:"Key Events by Platform"}),(0,t.jsx)(n.SZ,{children:"Click for tech details"})]})]}),(0,t.jsx)(g.Z,{className:"w-5 h-5 text-muted-foreground group-hover:translate-x-1 transition-transform"})]})}),(0,t.jsx)(n.aY,{children:(null==sp?void 0:sp.key_events_by_platform)&&sp.key_events_by_platform.length>0?(0,t.jsxs)("div",{className:"flex items-center gap-6",children:[(0,t.jsx)("div",{className:"h-[200px] w-[200px] flex-shrink-0",children:(0,t.jsx)(eh.h,{width:"100%",height:"100%",children:(0,t.jsxs)(ef.u,{children:[(0,t.jsx)(eN.b,{data:sp.key_events_by_platform.map(e=>({name:e.platform||"Unknown",value:e.keyEvents})),cx:"50%",cy:"50%",innerRadius:55,outerRadius:85,paddingAngle:4,dataKey:"value",children:sp.key_events_by_platform.map((e,s)=>(0,t.jsx)(ew.b,{fill:eR[s%eR.length],strokeWidth:0},s))}),(0,t.jsx)(eb.u,{contentStyle:{backgroundColor:"rgba(0,0,0,0.8)",border:"none",borderRadius:"8px",color:"white"}})]})})}),(0,t.jsx)("div",{className:"flex-1 space-y-3",children:sp.key_events_by_platform.map((e,s)=>{let a=sp.key_events_by_platform.reduce((e,s)=>e+s.keyEvents,0)||1;return(0,t.jsxs)("div",{className:"flex items-center justify-between text-sm p-2 rounded-lg hover:bg-muted/50",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:eR[s%eR.length]}}),(0,t.jsx)("span",{className:"capitalize font-medium",children:e.platform||"Unknown"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:aN(e.keyEvents)}),(0,t.jsxs)(o.C,{variant:"outline",children:[(e.keyEvents/a*100).toFixed(1),"%"]})]})]},e.platform)})})]}):(0,t.jsx)("div",{className:"h-[200px] flex items-center justify-center text-muted-foreground",children:(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsx)(A.Z,{className:"w-10 h-10 mx-auto mb-2 opacity-30"}),(0,t.jsx)("p",{children:"No key events data"})]})})})]}),(0,t.jsxs)(n.Zb,{className:"border-0 shadow-lg bg-white/70 dark:bg-gray-900/70 backdrop-blur-xl border border-white/20 dark:border-white/10 hover:shadow-2xl hover:border-white/40 dark:hover:border-white/20 transition-all duration-300",children:[(0,t.jsxs)(n.Ol,{className:"flex flex-row items-center justify-between pb-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg shadow-md ".concat("summary"===s7?"bg-gradient-to-br from-indigo-500 to-purple-600":"bg-gradient-to-br from-teal-500 to-cyan-600"),children:"summary"===s7?(0,t.jsx)(H.Z,{className:"w-4 h-4 text-white"}):(0,t.jsx)(M.Z,{className:"w-4 h-4 text-white"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)(n.ll,{className:"text-lg",children:"Events"}),(0,t.jsx)(n.SZ,{children:"summary"===s7?"Key metrics overview":"".concat((null==sp?void 0:null===(er=sp.events_by_name)||void 0===er?void 0:er.length)||0," events tracked")})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(h.Tabs,{value:s7,onValueChange:e=>ae(e),children:(0,t.jsxs)(h.TabsList,{className:"grid grid-cols-2 h-8",children:[(0,t.jsx)(h.TabsTrigger,{value:"summary",className:"text-xs px-3",children:"Summary"}),(0,t.jsx)(h.TabsTrigger,{value:"top_events",className:"text-xs px-3",children:"Top Events"})]})}),"top_events"===s7&&(0,t.jsx)(l.default,{href:"/dashboard/analytics/events",children:(0,t.jsx)(d.z,{variant:"ghost",size:"sm",className:"text-muted-foreground",children:(0,t.jsx)(g.Z,{className:"w-4 h-4"})})})]})]}),(0,t.jsx)(n.aY,{children:"summary"===s7?(0,t.jsxs)("div",{className:"grid grid-cols-3 gap-3",children:[(0,t.jsx)("div",{className:"p-4 rounded-xl bg-gradient-to-br from-indigo-50 to-purple-50 dark:from-indigo-950/50 dark:to-purple-950/50 border border-indigo-100 dark:border-indigo-800/50",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground font-medium",children:"Key Events"}),(0,t.jsx)("p",{className:"text-2xl font-bold text-indigo-600 dark:text-indigo-400 mt-1",children:aN((null==sp?void 0:null===(el=sp.
1key_events_summary)||void 0===el?void 0:el.total_key_events)||0)})]}),(0,t.jsx)("div",{className:"p-2 rounded-lg bg-indigo-100 dark:bg-indigo-900/50",children:(0,t.jsx)(A.Z,{className:"w-5 h-5 text-indigo-500"})})]})}),(0,t.jsx)("div",{className:"p-4 rounded-xl bg-gradient-to-br from-green-50 to-emerald-50 dark:from-green-950/50 dark:to-emerald-950/50 border border-green-100 dark:border-green-800/50",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground font-medium",children:"Revenue"}),(0,t.jsxs)("p",{className:"text-2xl font-bold text-green-600 dark:text-green-400 mt-1",children:["$",aN((null==sp?void 0:null===(ei=sp.key_events_summary)||void 0===ei?void 0:ei.total_revenue)||0)]})]}),(0,t.jsx)("div",{className:"p-2 rounded-lg bg-green-100 dark:bg-green-900/50",children:(0,t.jsx)(z.Z,{className:"w-5 h-5 text-green-500"})})]})}),(0,t.jsx)("div",{className:"p-4 rounded-xl bg-gradient-to-br from-blue-50 to-cyan-50 dark:from-blue-950/50 dark:to-cyan-950/50 border border-blue-100 dark:border-blue-800/50",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground font-medium",children:"Event Count"}),(0,t.jsx)("p",{className:"text-2xl font-bold text-blue-600 dark:text-blue-400 mt-1",children:aN((null==sp?void 0:null===(en=sp.key_events_summary)||void 0===en?void 0:en.total_event_count)||0)})]}),(0,t.jsx)("div",{className:"p-2 rounded-lg bg-blue-100 dark:bg-blue-900/50",children:(0,t.jsx)(H.Z,{className:"w-5 h-5 text-blue-500"})})]})})]}):(0,t.jsx)(m.x,{className:"h-[200px]",children:(0,t.jsxs)("div",{className:"space-y-2",children:[((null==sp?void 0:sp.events_by_name)||[]).slice(0,8).map((e,s)=>{var a,r;let l=(null==sp?void 0:null===(r=sp.events_by_name)||void 0===r?void 0:null===(a=r[0])||void 0===a?void 0:a.eventCount)||1,i=e.eventCount/l*100;return(0,t.jsxs)("div",{className:"group",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,t.jsx)("span",{className:"text-sm font-medium truncate max-w-[180px] group-hover:text-primary transition-colors",title:e.eventName,children:e.eventName}),(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,t.jsxs)("span",{className:"text-muted-foreground text-xs",children:[e.totalUsers," users"]}),(0,t.jsx)(o.C,{variant:"secondary",children:aN(e.eventCount)}
1)]})]}),(0,t.jsx)("div",{className:"relative h-1 bg-muted rounded-full overflow-hidden",children:(0,t.jsx)("div",{className:"absolute inset-y-0 left-0 bg-gradient-to-r from-teal-500 to-cyan-500 rounded-full",style:{width:"".concat(i,"%")}})})]},s)}),(!(null==sp?void 0:sp.events_by_name)||0===sp.events_by_name.length)&&(0,t.jsxs)("div",{className:"text-center py-8 text-muted-foreground",children:[(0,t.jsx)(M.Z,{className:"w-8 h-8 mx-auto mb-2 opacity-30"}),(0,t.jsx)("p",{children:"No events data"})]})]})})})]})]}):null,(0,t.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[(0,t.jsxs)(n.Zb,{className:"border-0 shadow-lg bg-white/70 dark:bg-gray-900/70 backdrop-blur-xl border border-white/20 dark:border-white/10 hover:shadow-2xl hover:border-white/40 dark:hover:border-white/20 transition-all duration-300 bg-gradient-to-br from-rose-50/50 via-background to-pink-50/30 dark:from-rose-950/20 dark:via-background dark:to-pink-950/10",children:[(0,t.jsxs)(n.Ol,{className:"flex flex-row items-center justify-between pb-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-gradient-to-br from-rose-500 to-pink-600 shadow-md",children:(0,t.jsx)(P.Z,{className:"w-4 h-4 text-white"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)(n.ll,{className:"text-lg",children:"Keywords"}),(0,t.jsx)(n.SZ,{children:(()=>{var e,s,a,t;if("organic"===at)return(null==sE?void 0:null===(t=sE.keywords)||void 0===t?void 0:t.length)?"".concat(sE.keywords.length," organic keywords"):"Google Search Console keywords";let r="utm_terms"===at?null==sp?void 0:null===(e=sp.keywords)||void 0===e?void 0:e.utm_terms:"google_ads"===at?null==sp?void 0:null===(s=sp.keywords)||void 0===s?void 0:s.google_ads_keywords:null==sp?void 0:null===(a=sp.keywords)||void 0===a?void 0:a.search_terms;return(null==r?void 0:r.length)?"".concat(r.length," keywords found"):"Track campaign keywords"})()})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("select",{value:at,onChange:e=>ar(e.target.value),className:"text-xs px-3 py-1.5 rounded-lg border bg-background/80 backdrop-blur-sm hover:bg-muted/50 transition-colors focus:outline-none focus:ring-2 focus:ring-rose-500/20",children:[(0,t.jsx)("option",{value:"organic",children:"Organic Search"}),(0,t.jsx)("option",{value:"utm_terms",children:"Campaign Terms"}),(0,t.jsx)("option",{value:"google_ads",children:"Google Ads"}),(0,t.jsx)("option",{value:"search_terms",children:"Site Search"})]}),(0,t.jsx)(d.z,{variant:"ghost",size:"sm",onClick:()=>sW(!0),className:"text-muted-foreground",children:(0,t.jsx)(g.Z,{className:"w-4 h-4"})})]})]}),(0,t.jsx)(n.aY,{children:(0,t.jsxs)("div",{className:"space-y-3",children:["organic"===at&&(0,t.jsx)(t.Fragment,{children:sR?(0,t.jsxs)("div",{className:"text-center py-8",children:[(0,t.jsx)(S.Z,{className:"w-6 h-6 mx-auto animate-spin text-muted-foreground"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-2",children:"Checking connection..."})]}):(null==sE?void 0:sE.connected)?(0,t.jsxs)("div",{className:"text-center py-6 text-muted-foreground rounded-xl border border-dashed bg-muted/20",children:[(0,t.jsx)(P.Z,{className:"w-8 h-8 mx-auto mb-2 text-emerald-500 opacity-70"}),(0,t.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Search Console Connected"}),(0,t.jsx)("p",{className:"text-xs opacity-70 mt-1 mb-3",children:(null==sE?void 0:null===(ed=sE.site_url)||void 0===ed?void 0:ed.replace("sc-domain:",""))||"View organic search data"}),(0,t.jsx)(l.default,{href:"/dashboard/analytics/search-console",children:(0,t.jsxs)(d.z,{size:"sm",className:"text-xs",children:[(0,t.jsx)(W.Z,{className:"w-3 h-3 mr-1"}),"View"]}
1)})]}):(0,t.jsxs)("div",{className:"text-center py-6 text-muted-foreground rounded-xl border border-dashed bg-muted/20",children:[(0,t.jsx)(P.Z,{className:"w-8 h-8 mx-auto mb-2 opacity-30"}),(0,t.jsx)("p",{className:"text-sm font-medium",children:"Connect Search Console"}),(0,t.jsx)("p",{className:"text-xs opacity-70 mt-1 mb-3",children:"Get organic search keywords from Google"}),(0,t.jsxs)(d.z,{size:"sm",variant:"outline",className:"text-xs",onClick:()=>window.location.href="/api/oauth/searchconsole/connect?workspace_id=".concat(su),children:[(0,t.jsx)(_.Z,{className:"w-3 h-3 mr-1"}),"Connect"]})]})}),"utm_terms"===at&&(0,t.jsxs)(t.Fragment,{children:[((null==sp?void 0:null===(eo=sp.keywords)||void 0===eo?void 0:eo.utm_terms)||[]).slice(0,6).map((e,s)=>{var a,r,l;let i=(null==sp?void 0:null===(l=sp.keywords)||void 0===l?void 0:null===(r=l.utm_terms)||void 0===r?void 0:null===(a=r[0])||void 0===a?void 0:a.sessions)||1,n=e.sessions/i*100;return(0,t.jsxs)("div",{className:"group",children:[(0,t.jsxs)("div",{className:"flex justify-between text-sm mb-1",children:[(0,t.jsx)("span",{className:"truncate max-w-[200px] group-hover:text-rose-500 transition-colors font-medium",title:e.keyword,children:e.keyword}),(0,t.jsx)("span",{className:"text-muted-foreground font-semibold",children:aN(e.sessions)})]}),(0,t.jsx)("div",{className:"relative h-2 bg-muted rounded-full overflow-hidden",children:(0,t.jsx)("div",{className:"absolute inset-y-0 left-0 bg-gradient-to-r from-rose-400 to-pink-500 rounded-full transition-all duration-500",style:{width:"".concat(n,"%")}})})]},s)}),!(null==sp?void 0:null===(em=sp.keywords)||void 0===em?void 0:null===(ec=em.utm_terms)||void 0===ec?void 0:ec.length)&&(0,t.jsxs)("div",{className:"text-center py-8 text-muted-foreground rounded-xl border border-dashed bg-muted/20",children:[(0,t.jsx)(A.Z,{className:"w-8 h-8 mx-auto mb-2 opacity-30"}),(0,t.jsx)("p",{className:"text-sm font-medium",children:"No Campaign Terms"}),(0,t.jsx)("p",{className:"text-xs opacity-70 mt-1",children:"Use ?utm_term=keyword in URLs"})]})]}),"google_ads"===at&&(0,t.jsxs)(t.Fragment,{children:[((null==sp?void 0:null===(ex=sp.keywords)||void 0===ex?void 0:ex.google_ads_keywords)||[]).slice(0,6).map((e,s)=>{var a,r,l;let i=(null==sp?void 0:null===(l=sp.keywords)||void 0===l?void 0:null===(r=l.google_ads_keywords)||void 0===r?void 0:null===(a=r[0])||void 0===a?void 0:a.sessions)||1,n=e.sessions/i*100;return(0,t.jsxs)("div",{className:"group",children:[(0,t.jsxs)("div",{className:"flex justify-between text-sm mb-1",children:[(0,t.jsx)("span",{className:"truncate max-w-[200px] group-hover:text-blue-500 transition-colors font-medium",title:e.keyword,children:e.keyword}),(0,t.jsx)("span",{className:"text-muted-foreground font-semibold",children:aN(e.sessions)})]}),(0,t.jsx)("div",{className:"relative h-2 bg-muted rounded-full overflow-hidden",children:(0,t.jsx)("div",{className:"absolute inset-y-0 left-0 bg-gradient-to-r from-blue-400 to-blue-600 rounded-full transition-all duration-500",style:{width:"".concat(n,"%")}})})]},s)}),!(null==sp?void 0:null===(ek=sp.keywords)||void 0===ek?void 0:null===(ey=ek.google_ads_keywords)||void 0===ey?void 0:ey.length)&&(0,t.jsxs)("div",{className:"text-center py-8 text-muted-foreground rounded-xl border border-dashed bg-muted/20",children:[(0,t.jsx)(z.Z,{className:"w-8 h-8 mx-auto mb-2 opacity-30"}),(0,t.jsx)("p",{className:"text-sm font-medium",children:"No Google Ads Keywords"}),(0,t.jsx)("p",{className:"text-xs opacity-70 mt-1",children:"Link Google Ads to GA4"})]})]}),"search_terms"===at&&(0,t.jsxs)(t.Fragment,{children:[((null==sp?void 0:null===(eD=sp.keywords)||void 0===eD?void 0:eD.search_terms)||[]).slice(0,6).map((e,s)=>{var a,r,l;let i=(null==sp?void 0:null===(l=sp.keywords)||void 0===l?void 0:null===(r=l.search_terms)||void 0===r?void 0:null===(a=r[0])||void 0===a?void 0:a.sessions)||1,n=e.sessions/i*100;return(0,t.jsxs)("div",{className:"group",children:[(0,t.jsxs)("div",{className:"flex justify-between text-sm mb-1",children:[(0,t.jsx)("span",{className:"truncate max-w-[200px] group-hover:text-green-500 transition-colors font-medium",title:e.keyword,
1children:e.keyword}),(0,t.jsx)("span",{className:"text-muted-foreground font-semibold",children:aN(e.sessions)})]}),(0,t.jsx)("div",{className:"relative h-2 bg-muted rounded-full overflow-hidden",children:(0,t.jsx)("div",{className:"absolute inset-y-0 left-0 bg-gradient-to-r from-green-400 to-emerald-500 rounded-full transition-all duration-500",style:{width:"".concat(n,"%")}})})]},s)}),!(null==sp?void 0:null===(eF=sp.keywords)||void 0===eF?void 0:null===(eZ=eF.search_terms)||void 0===eZ?void 0:eZ.length)&&(0,t.jsxs)("div",{className:"text-center py-8 text-muted-foreground rounded-xl border border-dashed bg-muted/20",children:[(0,t.jsx)(P.Z,{className:"w-8 h-8 mx-auto mb-2 opacity-30"}),(0,t.jsx)("p",{className:"text-sm font-medium",children:"No Site Search Terms"}),(0,t.jsx)("p",{className:"text-xs opacity-70 mt-1",children:"Enable site search tracking"})]})]})]})})]}),(0,t.jsxs)(n.Zb,{className:"border-0 shadow-lg bg-white/70 dark:bg-gray-900/70 backdrop-blur-xl border border-white/20 dark:border-white/10 hover:shadow-2xl hover:border-white/40 dark:hover:border-white/20 transition-all duration-300 bg-gradient-to-br from-violet-50/50 via-background to-purple-50/30 dark:from-violet-950/20 dark:via-background dark:to-purple-950/10",children:[(0,t.jsxs)(n.Ol,{className:"flex flex-row items-center justify-between pb-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-gradient-to-br from-violet-500 to-purple-600 shadow-md",children:(0,t.jsx)(y.Z,{className:"w-4 h-4 text-white"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)(n.ll,{className:"text-lg",children:"Demographics"}),(0,t.jsx)(n.SZ,{children:"Device & browser insights"})]})]}),(0,t.jsx)(l.default,{href:"/dashboard/analytics/demographics",children:(0,t.jsxs)(d.z,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-violet-500 transition-colors",children:["View Details ",(0,t.jsx)(g.Z,{className:"w-4 h-4 ml-1"})]})})]}),(0,t.jsxs)(n.aY,{children:[(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,t.jsx)(p.Z,{className:"w-4 h-4 text-violet-500"}),(0,t.jsx)("span",{className:"text-sm font-semibold",children:"Devices"})]}),((null==sp?void 0:null===(eO=sp.tech_details)||void 0===eO?void 0:eO.device_categories)||[]).slice(0,3).map((e,s)=>{var a,r;let l=(null==sp?void 0:null===(r=sp.tech_details)||void 0===r?void 0:null===(a=r.device_categories)||void 0===a?void 0:a.reduce((e,s)=>e+s.activeUsers,0))||1,i=(e.activeUsers/l*100).toFixed(1),n={desktop:(0,t.jsx)(v.Z,{className:"w-3.5 h-3.5"}),mobile:(0,t.jsx)(p.Z,{className:"w-3.5 h-3.5"}),tablet:(0,t.jsx)(b.Z,{className:"w-3.5 h-3.5"})},d=e.deviceCategory||"unknown";return(0,t.jsxs)("div",{className:"flex items-center justify-between p-2 rounded-lg bg-muted/40 hover:bg-muted/60 transition-colors",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-violet-500",children:n[d.toLowerCase()]||(0,t.jsx)(f.Z,{className:"w-3.5 h-3.5"})}),(0,t.jsx)("span",{className:"text-sm capitalize font-medium",children:d})]}),(0,t.jsxs)(o.C,{variant:"secondary",className:"bg-violet-100 text-violet-700 dark:bg-violet-900 dark:text-violet-300",children:[i,"%"]})]},s)}),!(null==sp?void 0:null===(eK=sp.tech_details)||void 0===eK?void 0:null===(eB=eK.device_categories)||void 0===eB?void 0:eB.length)&&(0,t.jsx)("div",{className:"text-center py-4 text-muted-foreground text-xs",children:"No device data"})]}),(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,t.jsx)(f.Z,{className:"w-4 h-4 text-purple-500"}),(0,t.jsx)("span",{className:"text-sm font-semibold",children:"Browsers"})]}),((null==sp?void 0:null===(eV=sp.tech_details)||void 0===eV?void 0:eV.browsers)||[]).slice(0,3).map((e,s)=>{var a,r,l;let i=(null==sp?void 0:null===(l=sp.tech_details)||void 0===l?void 0:null===(r=l.browsers)||void 0===r?void 0:null===(a=r[0])||void 0===a?void 0:a.activeUsers)||1,n=(e.activeUsers/i*100).toFixed(0),d=e.browser||"Unknown";return(0,t.jsxs)("div",{className:"flex items-center justify-between p-2 rounded-lg bg-muted/40 hover:bg-muted/60 transition-colors",children:[(0,t.jsx)("span",{className:"text-sm font-medium truncate max-w-[100px]",title:d,children:d}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("div",{className:"w-12 h-1.5 bg-muted rounded-full overflow-hidden",children:(0,t.jsx)("div",{className:"h-full bg-gradient-to-r from-purple-400 to-purple-600 rounded-full",style:{width:"".concat(n,"%")}})}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground font-medium w-8",children:aN(e.activeUsers)})]})]},s)}),!(null==sp?void 0:null===(eM=sp.tech_details)||void 0===eM?void 0:null===(eL=eM.browsers)||void 0===eL?void 0:eL.length)&&(0,t.jsx)("div",{className:"text-center py-4 text-muted-foreground text-xs",children:"No browser data"})]})]}),(null==sp?void 0:null===(eI=sp.new_vs_returning)||void 0===eI?void 0:eI.summary)&&sp.new_vs_returning.summary.length>0&&(0,t.jsx)("div",{className:"mt-4 pt-4 border-t",children:(()=>{var e,s;let a=(null===(e=sp.new_vs_returning.summary.find(e=>{var s;return(null===(s=e.userType)||void 0===s?void 0:s.toLowerCase())==="new"}))||void 0===e?void 0:e.activeUsers)||0,r=(null===(s=sp.new_vs_returning.summary.find(e=>{var s;return(null===(s=e.userType)||void 0===s?void 0:s.toLowerCase())==="returning"}))||void 0===s?void 0:s.activeUsers)||0,l=a+r;return 0===l?null:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(k.Z,{className:"w-4 h-4 text-emerald-500"}),(0,t.jsx)("span",{className:"text-sm",children:"New Users"}),(0,t.jsxs)(o.C,{className:"bg-emerald-100 text-emerald-700 dark:bg-emerald-900 dark:text-emerald-300",children:[(a/l*100).toFixed(1),"%"]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)($.Z,{className:"w-4 h-4 text-blue-500"}),(0,t.jsx)("span",{className:"text-sm",children:"Returning"}),(0,t.jsxs)(o.C,{className:"bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-300",children:[(r/l*100).toFixed(1),"%"]})]})]})})()})]})]})]}),(null==sp?void 0:sp.last_updated)&&(0,t.jsx)("div",{className:"text-center pt-2",children:(0,t.jsxs)("p",{className:"text-xs text-muted-foreground inline-flex items-center gap-1.5 bg-muted/50 px-3 py-1.5 rounded-full",children:[(0,t.jsx)(Y.Z,{className:"w-3 h-3"}
1),"Last updated: ",new Date(sp.last_updated).toLocaleString()]})})]}),"meta"===sQ&&(0,t.jsx)("div",{id:"meta-analytics",className:"mt-2",children:(0,t.jsx)(eS,{externalPeriod:sJ,externalSelectedPageId:s5,externalRefreshing:s4,onRefreshComplete:()=>s8(!1),hideHeader:!0})}),(0,t.jsx)(x.Vq,{open:sA,onOpenChange:sz,children:(0,t.jsxs)(x.cZ,{className:"max-w-[95vw] sm:max-w-4xl max-h-[85vh]",children:[(0,t.jsx)(x.fK,{children:(0,t.jsxs)(x.$N,{className:"flex items-center gap-2",children:[(0,t.jsx)(R.Z,{className:"w-5 h-5 text-primary"}),"All Pages (",(null==sp?void 0:null===(eY=sp.pages)||void 0===eY?void 0:eY.length)||0,")"]})}),(0,t.jsx)(m.x,{className:"h-[65vh]",children:(0,t.jsxs)("table",{className:"w-full text-sm",children:[(0,t.jsx)("thead",{className:"sticky top-0 bg-background border-b",children:(0,t.jsxs)("tr",{className:"text-left",children:[(0,t.jsx)("th",{className:"p-3 font-semibold",children:"#"}),(0,t.jsx)("th",{className:"p-3 font-semibold",children:"Page Path"}),(0,t.jsx)("th",{className:"p-3 text-right font-semibold",children:"Views"}),(0,t.jsx)("th",{className:"p-3 text-right font-semibold",children:"Users"}),(0,t.jsx)("th",{className:"p-3 text-right font-semibold",children:"Bounce"}),(0,t.jsx)("th",{className:"p-3 text-right font-semibold",children:"Avg Time"})]})}),(0,t.jsx)("tbody",{children:((null==sp?void 0:sp.pages)||[]).map((e,s)=>(0,t.jsxs)("tr",{className:"border-b hover:bg-muted/50 transition-colors",children:[(0,t.jsx)("td",{className:"p-3 text-muted-foreground",children:s+1}),(0,t.jsx)("td",{className:"p-3 max-w-[300px]",children:(0,t.jsx)(ea.H,{pagePath:e.pagePath,websiteUrl:null==sg?void 0:sg.website_url,maxLength:45})}),(0,t.jsx)("td",{className:"p-3 text-right font-semibold text-primary",children:aN(e.screenPageViews)}),(0,t.jsx)("td",{className:"p-3 text-right",children:aN(e.activeUsers)}),(0,t.jsxs)("td",{className:"p-3 text-right",children:[e.bounceRate.toFixed(1),"%"]}),(0,t.jsx)("td",{className:"p-3 text-right",children:aw(e.averageSessionDuration)})]},s))})]})})]})}),(0,t.jsx)(x.Vq,{open:sP,onOpenChange:sO,children:(0,t.jsxs)(x.cZ,{className:"max-w-[95vw] sm:max-w-3xl max-h-[85vh]",children:[(0,t.jsx)(x.fK,{children:(0,t.jsxs)(x.$N,{className:"flex items-center gap-2",children:[(0,t.jsx)(f.Z,{className:"w-5 h-5 text-primary"}),"All Countries (",(null==sp?void 0:null===(eG=sp.countries)||void 0===eG?void 0:eG.length)||0,")"]})}),(0,t.jsx)(m.x,{className:"h-[65vh]",children:(0,t.jsxs)("table",{className:"w-full text-sm",children:[(0,t.jsx)("thead",{className:"sticky top-0 bg-background border-b",children:(0,t.jsxs)("tr",{className:"text-left",children:[(0,t.jsx)("th",{className:"p-3 font-semibold",children:"#"}),(0,t.jsx)("th",{className:"p-3 font-semibold",children:"Country"}),(0,t.jsx)("th",{className:"p-3 text-right font-semibold",children:"Users"}),(0,t.jsx)("th",{className:"p-3 text-right font-semibold",children:"Sessions"}),(0,t.jsx)("th",{className:"p-3 text-right font-semibold",children:"New Users"}),(0,t.jsx)("th",{className:"p-3 text-right font-semibold",children:"Bounce"})]})}),(0,t.jsx)("tbody",{children:((null==sp?void 0:sp.countries)||[]).map((e,s)=>(0,t.jsxs)("tr",{className:"border-b hover:bg-muted/50 transition-colors",children:[(0,t.jsx)("td",{className:"p-3 text-muted-foreground",children:s+1}),(0,t.jsxs)("td",{className:"p-3",children:[(0,t.jsx)("span",{className:"mr-2 text-lg",children:eU(e.country)}),(0,t.jsx)("span",{className:"font-medium",children:e.country})]}),(0,t.jsx)("td",{className:"p-3 text-right font-semibold text-primary",children:aN(e.activeUsers)}),(0,t.jsx)("td",{className:"p-3 text-right",children:aN(e.sessions)}),(0,t.jsx)("td",{className:"p-3 text-right",children:aN(e.newUsers)}),(0,t.jsxs)("td",{className:"p-3 text-right",children:[e.bounceRate.toFixed(1),"%"]})]},s))})]})})]})}),(0,t.jsx)(x.Vq,{open:sB,onOpenChange:sK,children:(0,t.jsxs)(x.cZ,{className:"max-w-[95vw] sm:max-w-3xl max-h-[85vh]",children:[(0,t.jsx)(x.fK,{children:(0,t.jsxs)(x.$N,{className:"flex items-center gap-2",children:[(0,t.jsx)(N.Z,{className:"w-5 h-5 text-primary"}),"All Cities (",(null==sp?void 0:null===(e$=sp.cities)||void 0===e$?void 0:e$.length)||0,")"]})}),(0,t.jsx)(m.x,{className:"h-[65vh]",children:(0,t.jsxs)("table",{className:"w-full text-sm",children:[(0,t.jsx)("thead",{className:"sticky top-0 bg-background border-b",children:(0,t.jsxs)("tr",{className:"text-left",children:[(0,t.jsx)("th",{className:"p-3 font-semibold",children:"#"}),(0,t.jsx)("th",{className:"p-3 font-semibold",children:"City"}),(0,t.jsx)("th",{className:"p-3 font-semibold",children:"Country"}),(0,t.jsx)("th",{className:"p-3 text-right font-semibold",children:"Users"}),(0,t.jsx)("th",{className:"p-3 text-right font-semibold",children:"Sessions"}),(0,t.jsx)("th",{className:"p-3 text-right font-semibold",children:"Bounce"})]})}),(0,t.jsx)("tbody",{children:((null==sp?void 0:sp.cities)||[]).map((e,s)=>(0,t.jsxs)("tr",{className:"border-b hover:bg-muted/50 transition-colors",children:[(0,t.jsx)("td",{className:"p-3 text-muted-foreground",children:s+1}),(0,t.jsx)("td",{className:"p-3 font-medium",children:e.city||"(not set)"}),(0,t.jsxs)("td",{className:"p-3",children:[(0,t.jsx)("span",{className:"mr-2",children:eU(e.country)}),e.country]}),(0,t.jsx)("td",{className:"p-3 text-right font-semibold text-primary",children:aN(e.activeUsers)}),(0,t.jsx)("td",{className:"p-3 text-right",children:aN(e.sessions)}),(0,t.jsxs)("td",{className:"p-3 text-right",children:[e.bounceRate.toFixed(1),"%"]})]},s))})]})})]})}),(0,t.jsx)(x.Vq,{open:sV,onOpenChange:sL,children:(0,t.jsxs)(x.cZ,{className:"max-w-[95vw] sm:max-w-4xl max-h-[85vh]",children:[(0,t.jsx)(x.fK,{children:(0,t.jsxs)(x.$
1N,{className:"flex items-center gap-2",children:[(0,t.jsx)(j.Z,{className:"w-5 h-5 text-primary"}),"All Traffic Sources"]})}),(0,t.jsx)(m.x,{className:"h-[65vh]",children:(0,t.jsxs)("table",{className:"w-full text-sm",children:[(0,t.jsx)("thead",{className:"sticky top-0 bg-background border-b",children:(0,t.jsxs)("tr",{className:"text-left",children:[(0,t.jsx)("th",{className:"p-3 font-semibold",children:"Source"}),(0,t.jsx)("th",{className:"p-3 font-semibold",children:"Medium"}),(0,t.jsx)("th",{className:"p-3 text-right font-semibold",children:"Sessions"}),(0,t.jsx)("th",{className:"p-3 text-right font-semibold",children:"Users"}),(0,t.jsx)("th",{className:"p-3 text-right font-semibold",children:"New Users"}),(0,t.jsx)("th",{className:"p-3 text-right font-semibold",children:"Bounce"})]})}),(0,t.jsx)("tbody",{children:((null==sp?void 0:sp.traffic_sources)||[]).map((e,s)=>(0,t.jsxs)("tr",{className:"border-b hover:bg-muted/50 transition-colors",children:[(0,t.jsx)("td",{className:"p-3 font-semibold",children:e.sessionSource}),(0,t.jsx)("td",{className:"p-3 text-muted-foreground",children:e.sessionMedium}),(0,t.jsx)("td",{className:"p-3 text-right font-semibold text-primary",children:aN(e.sessions)}),(0,t.jsx)("td",{className:"p-3 text-right",children:aN(e.activeUsers)}),(0,t.jsx)("td",{className:"p-3 text-right",children:aN(e.newUsers)}),(0,t.jsxs)("td",{className:"p-3 text-right",children:[e.bounceRate.toFixed(1),"%"]})]},s))})]})})]})}),(0,t.jsx)(x.Vq,{open:sM,onOpenChange:sI,children:(0,t.jsxs)(x.cZ,{className:"max-w-[95vw] sm:max-w-3xl max-h-[85vh]",children:[(0,t.jsx)(x.fK,{children:(0,t.jsxs)(x.$N,{className:"flex items-center gap-2",children:[(0,t.jsx)(I.Z,{className:"w-5 h-5 text-orange-500"}),"Bounce Rate by Page"]})}),(0,t.jsx)(m.x,{className:"h-[65vh]",children:(0,t.jsxs)("table",{className:"w-full text-sm",children:[(0,t.jsx)("thead",{className:"sticky top-0 bg-background border-b",children:(0,t.jsxs)("tr",{className:"text-left",children:[(0,t.jsx)("th",{className:"p-3 font-semibold",children:"Page"}),(0,t.jsx)("th",{className:"p-3 text-right font-semibold",children:"Sessions"}),(0,t.jsx)("th",{className:"p-3 text-right font-semibold",children:"Bounce Rate"})]})}),(0,t.jsx)("tbody",{children:((null==sp?void 0:sp.bounce_rate_pages)||(null==sp?void 0:sp.pages)||[]).map((e,s)=>(0,t.jsxs)("tr",{className:"border-b hover:bg-muted/50 transition-colors",children:[(0,t.jsx)("td",{className:"p-3 max-w-[300px]",children:(0,t.jsx)(ea.H,{pagePath:e.pagePath,websiteUrl:null==sg?void 0:sg.website_url,maxLength:45})}),(0,t.jsx)("td",{className:"p-3 text-right",children:aN(e.sessions)}),(0,t.jsx)("td",{className:"p-3 text-right",children:(0,t.jsxs)(o.C,{variant:e.bounceRate>70?"destructive":e.bounceRate<40?"default":"secondary",children:[e.bounceRate.toFixed(1),"%"]})})]},s))})]})})]})}),(0,t.jsx)(x.Vq,{open:sY,onOpenChange:sG,children:(0,t.jsxs)(x.cZ,{className:"max-w-[95vw] sm:max-w-4xl max-h-[85vh]",children:[(0,t.jsx)(x.fK,{children:(0,t.jsxs)(x.$N,{className:"flex items-center gap-2",children:[(0,t.jsx)(M.Z,{className:"w-5 h-5 text-primary"}),"All Events (",(null==sp?void 0:null===(eq=sp.events_by_name)||void 0===eq?void 0:eq.length)||0,")"]})}),(0,t.jsx)(m.x,{className:"h-[65vh]",children:(0,t.jsxs)("table",{className:"w-full text-sm",children:[(0,t.jsx)("thead",{className:"sticky top-0 bg-background border-b",children:(0,t.jsxs)("tr",{className:"text-left",children:[(0,t.jsx)("th",{className:"p-3 font-semibold",children:"#"}),(0,t.jsx)("th",{className:"p-3 font-semibold",children:"Event Name"}),(0,t.jsx)("th",{className:"p-3 text-right font-semibold",children:"Event Count"}),(0,t.jsx)("th",{className:"p-3 text-right font-semibold",children:"Users"}),(0,t.jsx)("th",{className:"p-3 text-right font-semibold",children:"Per User"}),(0,t.jsx)("th",{className:"p-3 text-right font-semibold",children:"Revenue"})]})}),(0,t.jsx)("tbody",{children:((null==sp?void 0:sp.events_by_name)||[]).map((e,s)=>(0,t.jsxs)("tr",{className:"border-b hover:bg-muted/50 transition-colors",children:[(0,t.jsx)("td",{className:"p-3 text-muted-foreground",children:s+1}),(0,t.jsx)("td",{className:"p-3 font-semibold",children:e.eventName}),(0,t.jsx)("td",{className:"p-3 text-right font-semibold text-primary",children:aN(e.eventCount)}
1),(0,t.jsx)("td",{className:"p-3 text-right",children:aN(e.totalUsers)}),(0,t.jsx)("td",{className:"p-3 text-right",children:e.eventCountPerUser.toFixed(2)}),(0,t.jsxs)("td",{className:"p-3 text-right text-green-600 font-medium",children:["$",e.totalRevenue.toFixed(2)]})]},s))})]})})]})}),(0,t.jsx)(x.Vq,{open:s$,onOpenChange:sq,children:(0,t.jsxs)(x.cZ,{className:"max-w-[95vw] sm:max-w-5xl max-h-[90vh]",children:[(0,t.jsx)(x.fK,{children:(0,t.jsxs)(x.$N,{className:"flex items-center gap-2",children:[(0,t.jsx)(v.Z,{className:"w-5 h-5 text-primary"}),"Tech Details"]})}),(0,t.jsx)(m.x,{className:"h-[75vh]",children:(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 p-1",children:[(0,t.jsxs)("div",{className:"p-4 rounded-xl border bg-muted/30",children:[(0,t.jsxs)("h3",{className:"font-semibold mb-4 flex items-center gap-2",children:[(0,t.jsx)(f.Z,{className:"w-4 h-4 text-primary"})," Browsers"]}),(0,t.jsxs)("div",{className:"space-y-3",children:[((null==sp?void 0:null===(eH=sp.tech_details)||void 0===eH?void 0:eH.browsers)||[]).map((e,s)=>{var a,r,l;let i=(null==sp?void 0:null===(l=sp.tech_details)||void 0===l?void 0:null===(r=l.browsers)||void 0===r?void 0:null===(a=r[0])||void 0===a?void 0:a.activeUsers)||1,n=e.activeUsers/i*100;return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex justify-between text-sm mb-1",children:[(0,t.jsx)("span",{className:"font-medium",children:e.browser}),(0,t.jsxs)("span",{className:"text-muted-foreground",children:[aN(e.activeUsers)," users"]})]}),(0,t.jsx)("div",{className:"relative h-2 bg-muted rounded-full overflow-hidden",children:(0,t.jsx)("div",{className:"absolute inset-y-0 left-0 bg-gradient-to-r from-indigo-500 to-purple-500 rounded-full",style:{width:"".concat(n,"%")}})})]},s)}),!(null==sp?void 0:null===(eQ=sp.tech_details)||void 0===eQ?void 0:null===(eW=eQ.browsers)||void 0===eW?void 0:eW.length)&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"No browser data"})]})]}),(0,t.jsxs)("div",{className:"p-4 rounded-xl border bg-muted/30",children:[(0,t.jsxs)("h3",{className:"font-semibold mb-4 flex items-center gap-2",children:[(0,t.jsx)(v.Z,{className:"w-4 h-4 text-primary"})," Operating Systems"]}),(0,t.jsxs)("div",{className:"space-y-3",children:[((null==sp?void 0:null===(eX=sp.tech_details)||void 0===eX?void 0:eX.operating_systems)||[]).map((e,s)=>{var a,r,l;let i=(null==sp?void 0:null===(l=sp.tech_details)||void 0===l?void 0:null===(r=l.operating_systems)||void 0===r?void 0:null===(a=r[0])||void 0===a?void 0:a.activeUsers)||1,n=e.activeUsers/i*100;return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex justify-between text-sm mb-1",children:[(0,t.jsx)("span",{className:"font-medium",children:e.operatingSystem}),(0,t.jsxs)("span",{className:"text-muted-foreground",children:[aN(e.activeUsers)," users"]})]}),(0,t.jsx)("div",{className:"relative h-2 bg-muted rounded-full overflow-hidden",children:(0,t.jsx)("div",{className:"absolute inset-y-0 left-0 bg-gradient-to-r from-blue-500 to-cyan-500 rounded-full",style:{width:"".concat(n,"%")}})})]},s)}),!(null==sp?void 0:null===(e0=sp.tech_details)||void 0===e0?void 0:null===(eJ=e0.operating_systems)||void 0===eJ?void 0:eJ.length)&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"No OS data"})]})]}),(0,t.jsxs)("div",{className:"p-4 rounded-xl border bg-muted/30",children:[(0,t.jsxs)("h3",{className:"font-semibold mb-4 flex items-center gap-2",children:[(0,t.jsx)(b.Z,{className:"w-4 h-4 text-primary"})," Screen Resolutions"]}),(0,t.jsxs)("div",{className:"space-y-3",children:[((null==sp?void 0:null===(e5=sp.tech_details)||void 0===e5?void 0:e5.screen_resolutions)||[]).map((e,s)=>{var a,r,l;let i=(null==sp?void 0:null===(l=sp.tech_details)||void 0===l?void 0:null===(r=l.screen_resolutions)||void 0===r?void 0:null===(a=r[0])||void 0===a?void 0:a.activeUsers)||1,n=e.activeUsers/i*100;return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex justify-between text-sm mb-1",children:[(0,t.jsx)("span",{className:"font-mono font-medium",children:e.screenResolution}),(0,t.jsxs)("span",{className:"text-muted-foreground",children:[aN(e.activeUsers)," users"]})]}),(0,t.jsx)("div",{className:"relative h-2 bg-muted rounded-full overflow-hidden",children:(0,t.jsx)("div",{className:"absolute inset-y-0 left-0 bg-gradient-to-r from-pink-500 to-rose-500 rounded-full",style:{width:"".concat(n,"%")}})})]},s)}),!(null==sp?void 0:null===(e1=sp.tech_details)||void 0===e1?void 0:null===(e3=e1.screen_resolutions)||void 0===e3?void 0:e3.length)&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"No screen resolution data"})]})]}),(0,t.jsxs)("div",{className:"p-4 rounded-xl border bg-muted/30",children:[(0,t.jsxs)("h3",{className:"font-semibold mb-4 flex items-center gap-2",children:[(0,t.jsx)(p.Z,{className:"w-4 h-4 text-primary"})," Device Categories"]}),(0,t.jsxs)("div",{className:"space-y-3",children:[((null==sp?void 0:null===(e2=sp.tech_details)||void 0===e2?void 0:e2.device_categories)||[]).map((e,s)=>{var a,r,l;let i=(null==sp?void 0:null===(r=sp.tech_details)||void 0===r?void 0:null===(a=r.device_categories)||void 0===a?void 0:a.reduce((e,s)=>e+s.activeUsers,0))||1,n=e.activeUsers/i*100;return(0,t.jsxs)("div",{className:"p-3 rounded-lg bg-background border",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,t.jsxs)("span",{className:"font-semibold capitalize flex items-center gap-2",children:["desktop"===e.deviceCategory&&(0,t.jsx)(v.Z,{className:"w-4 h-4"}),"mobile"===e.deviceCategory&&(0,t.jsx)(p.Z,{className:"w-4 h-4"}),"tablet"===e.deviceCategory&&(0,t.jsx)(b.Z,{className:"w-4 h-4"}),e.deviceCategory]}),(0,t.jsxs)(o.C,{className:"bg-primary/10 text-primary",children:[n.toFixed(1),"%"]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-3 gap-2 text-xs text-muted-foreground",children:[(0,t.jsxs)("div",{children:["Users: ",(0,t.jsx)("span",{className:"text-foreground font-semibold",children:aN(e.activeUsers)})]}),(0,t.jsxs)("div",{children:["Sessions: ",(0,t.jsx)("span",{className:"text-foreground font-semibold",children:aN(e.sessions)})]}),(0,t.jsxs)("div",{children:["Bounce: ",(0,t.jsxs)("span",{className:"text-foreground font-semibold",children:[(null===(l=e.bounceRate)||void 0===l?void 0:l.toFixed(1))||0,"%"]})]})]})]},s)}),!(null==sp?void 0:null===(e8=sp.tech_details)||void 0===e8?void 0:null===(e4=e8.device_categories)||void 0===e4?void 0:e4.length)&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"No device data"})]})]})]})})]})}),(0,t.jsx)(x.Vq,{open:sH,onOpenChange:sW,children:(0,t.jsxs)(x.cZ,{className:"max-w-[95vw] sm:max-w-5xl max-h-[90vh]",children:[(0,t.jsx)(x.fK,{children:(0,t.jsxs)(x.$
1N,{className:"flex items-center gap-2",children:[(0,t.jsx)(P.Z,{className:"w-5 h-5 text-primary"}),"All Keywords"]})}),(0,t.jsx)(m.x,{className:"h-[75vh]",children:(0,t.jsxs)("div",{className:"space-y-8 p-1",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("h3",{className:"font-semibold mb-4 flex items-center gap-2",children:[(0,t.jsx)(o.C,{variant:"outline",children:"UTM"}),"Campaign Terms (",(null==sp?void 0:null===(e9=sp.keywords)||void 0===e9?void 0:null===(e6=e9.utm_terms)||void 0===e6?void 0:e6.length)||0,")"]}),((null==sp?void 0:null===(se=sp.keywords)||void 0===se?void 0:null===(e7=se.utm_terms)||void 0===e7?void 0:e7.length)||0)>0?(0,t.jsxs)("div",{className:"rounded-xl border overflow-hidden",children:[(0,t.jsxs)("div",{className:"grid grid-cols-6 gap-2 p-3 bg-muted/50 text-xs font-semibold",children:[(0,t.jsx)("div",{className:"col-span-2",children:"Keyword"}),(0,t.jsx)("div",{className:"text-right",children:"Sessions"}),(0,t.jsx)("div",{className:"text-right",children:"Users"}),(0,t.jsx)("div",{className:"text-right",children:"New Users"}),(0,t.jsx)("div",{className:"text-right",children:"Bounce"})]}),(0,t.jsx)("div",{className:"divide-y max-h-[200px] overflow-auto",children:((null==sp?void 0:null===(ss=sp.keywords)||void 0===ss?void 0:ss.utm_terms)||[]).map((e,s)=>{var a;return(0,t.jsxs)("div",{className:"grid grid-cols-6 gap-2 p-3 text-sm hover:bg-muted/30",children:[(0,t.jsx)("div",{className:"col-span-2 truncate font-medium",title:e.keyword,children:e.keyword}),(0,t.jsx)("div",{className:"text-right font-semibold text-primary",children:aN(e.sessions)}),(0,t.jsx)("div",{className:"text-right",children:aN(e.activeUsers)}),(0,t.jsx)("div",{className:"text-right",children:aN(e.newUsers||0)}),(0,t.jsxs)("div",{className:"text-right",children:[(null===(a=e.bounceRate)||void 0===a?void 0:a.toFixed(1))||0,"%"]})]},s)})})]}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground p-4 border rounded-xl bg-muted/30",children:"No UTM terms captured. Use utm_term parameter in your campaigns to track keywords."})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("h3",{className:"font-semibold mb-4 flex items-center gap-2",children:[(0,t.jsx)(o.C,{variant:"outline",className:"bg-blue-50 text-blue-600 border-blue-200",children:"Ads"}),"Google Ads Keywords (",(null==sp?void 0:null===(st=sp.keywords)||void 0===st?void 0:null===(sa=st.google_ads_keywords)||void 0===sa?void 0:sa.length)||0,")"]}),((null==sp?void 0:null===(sl=sp.keywords)||void 0===sl?void 0:null===(sr=sl.google_ads_keywords)||void 0===sr?void 0:sr.length)||0)>0?(0,t.jsxs)("div",{className:"rounded-xl border overflow-hidden",children:[(0,t.jsxs)("div",{className:"grid grid-cols-6 gap-2 p-3 bg-muted/50 text-xs font-semibold",children:[(0,t.jsx)("div",{className:"col-span-2",children:"Keyword"}),(0,t.jsx)("div",{className:"text-right",children:"Sessions"}),(0,t.jsx)("div",{className:"text-right",children:"Users"}),(0,t.jsx)("div",{className:"text-right",children:"Conversions"}),(0,t.jsx)("div",{className:"text-right",children:"Revenue"})]}),(0,t.jsx)("div",{className:"divide-y max-h-[200px] overflow-auto",children:((null==sp?void 0:null===(si=sp.keywords)||void 0===si?void 0:si.google_ads_keywords)||[]).map((e,s)=>(0,t.jsxs)("div",{className:"grid grid-cols-6 gap-2 p-3 text-sm hover:bg-muted/30",children:[(0,t.jsx)("div",{className:"col-span-2 truncate font-medium",title:e.keyword,children:e.keyword}),(0,t.jsx)("div",{className:"text-right font-semibold text-primary",children:aN(e.sessions)}),(0,t.jsx)("div",{className:"text-right",children:aN(e.activeUsers)}),(0,t.jsx)("div",{className:"text-right",children:aN(e.conversions||0)}),(0,t.jsxs)("div",{className:"text-right text-green-600 font-medium",children:["$",(e.totalRevenue||0).toFixed(2)]})]},s))})]}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground p-4 border rounded-xl bg-muted/30",children:"No Google Ads keywords. Link your Google Ads account to see keyword data."})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("h3",{className:"font-semibold mb-4 flex items-center gap-2",children:[(0,t.jsx)(o.C,{variant:"outline",className:"bg-green-50 text-green-600 border-green-200",children:"Search"}),"Search Terms (",(null==sp?void 0:null===(sd=sp.keywords)||void 0===sd?void 0:null===(sn=sd.search_terms)||void 0===sn?void 0:sn.length)||0,")"]}),((null==sp?void 0:null===(sc=sp.keywords)||void 0===sc?void 0:null===(so=sc.search_terms)||void 0===so?void 0:so.length)||0)>0?(0,t.jsxs)("div",{className:"rounded-xl border overflow-hidden",children:[(0,t.jsxs)("div",{className:"grid grid-cols-4 gap-2 p-3 bg-muted/50 text-xs font-semibold",children:[(0,t.jsx)("div",{className:"col-span-2",children:"Search Term"}),(0,t.jsx)("div",{className:"text-right",children:"Sessions"}),(0,t.jsx)("div",{className:"text-right",children:"Users"})]}),(0,t.jsx)("div",{className:"divide-y max-h-[200px] overflow-auto",children:((null==sp?void 0:null===(sm=sp.keywords)||void 0===sm?void 0:sm.search_terms)||[]).map((e,s)=>(0,t.jsxs)("div",{className:"grid grid-cols-4 gap-2 p-3 text-sm hover:bg-muted/30",children:[(0,t.jsx)("div",{className:"col-span-2 truncate font-medium",title:e.keyword,
1children:e.keyword}),(0,t.jsx)("div",{className:"text-right font-semibold text-primary",children:aN(e.sessions)}),(0,t.jsx)("div",{className:"text-right",children:aN(e.activeUsers)})]},s))})]}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground p-4 border rounded-xl bg-muted/30",children:'Search term data is limited due to Google\'s privacy policy. Most organic search terms appear as "(not provided)".'})]})]})})]})})]})}},29789:function(e,s,a){a.d(s,{H:function(){return i}});var t=a(57437),r=a(96362),l=a(93448);function i(e){let{pagePath:s,websiteUrl:a,className:i,showIcon:n=!0,truncate:d=!0,maxLength:o=50}=e,c=(()=>{if(!a)return null;let e=a.replace(/\/$/,""),t=s.startsWith("/")?s:"/".concat(s);return"".concat(e).concat(t)})(),m=d&&s.length>o?"".concat(s.substring(0,o),"..."):s;return c?(0,t.jsxs)("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:(0,l.cn)("font-medium text-primary hover:underline inline-flex items-center gap-1 group",i),title:"Open ".concat(c," in new tab"),onClick:e=>e.stopPropagation(),children:[(0,t.jsx)("span",{className:"truncate",children:c}),n&&(0,t.jsx)(r.Z,{className:"w-3 h-3 opacity-50 group-hover:opacity-100 flex-shrink-0"})]}):(0,t.jsx)("span",{className:(0,l.cn)("font-medium",i),title:s,children:m})}},32060:function(e,s,a){a.d(s,{$F:function(){return o},AW:function(){return c},Ju:function(){return h},VD:function(){return u},Xi:function(){return m},bO:function(){return x},h_:function(){return d}});var t=a(57437),r=a(2265),l=a(70085),i=a(93448),n=a(20653);let d=l.fC,o=l.xz;l.ZA,l.Uv,l.Tr,l.Ee,r.forwardRef((e,s)=>{let{className:a,inset:r,children:d,...o}=e;return(0,t.jsxs)(l.fF,{ref:s,className:(0,i.cn)("flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",r&&"pl-8",a),...o,children:[d,(0,t.jsx)(n.XCv,{className:"ml-auto"})]})}).displayName=l.fF.displayName,r.forwardRef((e,s)=>{let{className:a,...r}=e;return(0,t.jsx)(l.tu,{ref:s,className:(0,i.cn)("z-50 min-w-[8rem] overflow-hidden rounded-[4px] border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",a),...r})}).displayName=l.tu.displayName;let c=r.forwardRef((e,s)=>{let{className:a,sideOffset:r=4,...n}=e;return(0,t.jsx)(l.Uv,{children:(0,t.jsx)(l.VY,{ref:s,sideOffset:r,className:(0,i.cn)("z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-[4px] border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",a),...n})})});c.displayName=l.VY.displayName;let m=r.forwardRef((e,s)=>{let{className:a,inset:r,...n}=e;return(0,t.jsx)(l.ck,{ref:s,className:(0,i.cn)("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0",r&&"pl-8",a),...n})});m.displayName=l.ck.displayName;let x=r.forwardRef((e,s)=>{let{className:a,children:r,checked:d,...o}=e;return(0,t.jsxs)(l.oC,{ref:s,className:(0,i.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),checked:d,...o,children:[(0,t.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,t.jsx)(l.wU,{children:(0,t.jsx)(n.nQG,{className:"h-4 w-4"})})}),r]})});x.displayName=l.oC.displayName,r.forwardRef((e,s)=>{let{className:a,children:r,...d}=e;return(0,t.jsxs)(l.Rk,{ref:s,className:(0,i.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),...d,children:[(0,t.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,t.jsx)(l.wU,{children:(0,t.jsx)(n.jXb,{className:"h-2 w-2 fill-current"})})}),r]})}).displayName=l.Rk.displayName;let h=r.forwardRef((e,s)=>{let{className:a,inset:r,...n}=e;return(0,t.jsx)(l.__,{ref:s,className:(0,i.cn)("px-2 py-1.5 text-sm font-semibold",r&&"pl-8",a),...n})});h.displayName=l.__.displayName;let u=r.forwardRef((e,s)=>{let{className:a,...r}=e;return(0,t.jsx)(l.Z0,{ref:s,className:(0,i.cn)("-mx-1 my-1 h-px bg-muted",a),...r})});u.displayName=l.Z0.displayName},15291:function(e,s,a){a.d(s,{Bw:function(){return h},DI:function(){return c},Ph:function(){return o},Ql:function(){return g},i4:function(){return x},ki:function(){return m},n5:function(){return u}});var t=a(57437),r=a(2265),l=a(56873),i=a(40875),n=a(30401),d=a(93448);let o=l.fC,c=l.ZA,m=l.B4,x=r.forwardRef((e,s)=>{let{className:a,children:r,...n}=e;return(0,t.jsxs)(l.xz,{ref:s,className:(0,d.cn)("flex h-10 w-full items-center justify-between rounded-[4px] border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 dark:text-gray-100 px-3 py-2 text-sm r
1ing-offset-white dark:ring-offset-gray-950 placeholder:text-gray-500 dark:placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-gray-950 dark:focus:ring-gray-300 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",a),...n,children:[r,(0,t.jsx)(l.JO,{asChild:!0,children:(0,t.jsx)(i.Z,{className:"h-4 w-4 opacity-50"})})]})});x.displayName=l.xz.displayName;let h=r.forwardRef((e,s)=>{let{className:a,children:r,position:i="popper",...n}=e;return(0,t.jsx)(l.h_,{children:(0,t.jsx)(l.VY,{ref:s,className:(0,d.cn)("relative z-50 min-w-[8rem] overflow-hidden rounded-[4px] border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 text-gray-950 dark:text-gray-100 shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2","popper"===i&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",a),position:i,...n,children:(0,t.jsx)(l.l_,{className:(0,d.cn)("p-1 max-h-[300px] overflow-y-auto","popper"===i&&"w-full min-w-[var(--radix-select-trigger-width)]"),children:r})})})});h.displayName=l.VY.displayName;let u=r.forwardRef((e,s)=>{let{className:a,...r}=e;return(0,t.jsx)(l.__,{ref:s,className:(0,d.cn)("py-1.5 pl-8 pr-2 text-sm font-semibold",a),...r})});u.displayName=l.__.displayName;let g=r.forwardRef((e,s)=>{let{className:a,children:r,...i}=e;return(0,t.jsxs)(l.ck,{ref:s,className:(0,d.cn)("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-gray-100 dark:focus:bg-gray-700 focus:text-gray-900 dark:focus:text-gray-100 data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),...i,children:[(0,t.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,t.jsx)(l.wU,{children:(0,t.jsx)(n.Z,{className:"h-4 w-4"})})}),(0,t.jsx)(l.eT,{children:r})]})});g.displayName=l.ck.displayName,r.forwardRef((e,s)=>{let{className:a,...r}=e;return(0,t.jsx)(l.Z0,{ref:s,className:(0,d.cn)("-mx-1 my-1 h-px bg-gray-100 dark:bg-gray-700",a),...r})}).displayName=l.Z0.displayName},9310:function(e,s,a){a.d(s,{H:function(){return d},K:function(){return n}});var t=a(57437),r=a(2265),l=a(99376);let i=(0,r.createContext)(void 0);function n(e){let{children:s}=e,[a,n]=(0,r.useState)(!1),d=(0,l.useRouter)(),o=(0,l.usePathname)(),c=(0,r.useRef)(o),m=(0,r.useRef)(null),x=(0,r.useCallback)(()=>{m.current&&(clearTimeout(m.current),m.current=null)},[]),h=(0,r.useCallback)(()=>{x(),n(!0),m.current=setTimeout(()=>{n(!1)},4e3)},[x]),u=(0,r.useCallback)(()=>{x(),n(!1)},[x]),g=(0,r.useCallback)(e=>{e!==o&&(h(),d.push(e))},[d,o,h]);return(0,r.useEffect)(()=>(o!==c.current&&(c.current=o),()=>x()),[o,x]),(0,t.jsx)(i.Provider,{value:{isNavigating:a,startNavigation:h,endNavigation:u,navigateTo:g},children:s})}function d(){let e=(0,r.useContext)(i);if(!e)throw Error("useNavigation must be used within a NavigationProvider");return e}}}]);
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.