PageSourceSearch

https://fantasticforms.com/static/js/376.bfc03394.chunk.js

js fantasticforms.com collected 2026-09-25 22:48:55 UTC 27,951 bytes, 2 lines download raw bytes

1"use strict";(self.webpackChunkfrontend=self.webpackChunkfrontend||[]).push([[376],{30480(e,s,t){t.d(s,{i:()=>l});var a=t(65043),n=t(35016),i=t(1089);function l(){const{user:e}=(0,n.As)(),s=(0,a.useMemo)(()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch(e){return"UTC"}},[]),t=(null===e||void 0===e?void 0:e.timezone)||s;return(0,a.useMemo)(()=>({timezone:t,isUserSet:Boolean(null===e||void 0===e?void 0:e.timezone),formatDate:e=>(0,i.Yq)(e,t),formatDateTime:e=>(0,i.r6)(e,t)}),[t,null===e||void 0===e?void 0:e.timezone])}},70376(e,s,t){t.r(s),t.d(s,{default:()=>U});var a=t(65043),n=t(45685),i=t(4980),l=t(12420),c=t(13390),r=t(91140),d=t(75395),o=t(84370),m=t(56328),x=t(73782),h=t(65469),u=t(5077),p=t(84025),f=t(94805),j=t(28646),b=t(27033),g=t(22024),v=t(55731),N=t(63172),y=t(46963),w=t(28006),z=t(72782),_=t(7118),k=t(51654),A=t(92264),C=t(78615),S=t(65598),F=t(64702),R=t(17494),M=t.n(R),L=t(57856),B=t(40614),E=t(70579);const q=e=>{let{form:s,elementAnalytics:t,onClose:n}=e;const i=(0,a.useRef)(null),l=(0,a.useRef)(null),r=(0,a.useRef)({}),[d,o]=(0,a.useState)(null),m=new Set(["short_text","long_text","email","number","phone","url","single_choice","multiple_choice","dropdown","rating","linear_scale","yes_no","matrix","ranked_list","fill_in_blanks","full_name","address","date","time","date_time","file_upload","signature","voice_recording","payment","clickwrap"]),x=((null===t||void 0===t?void 0:t.elements)||[]).filter(e=>m.has(e.type));if((0,a.useEffect)(()=>{if(!i.current||0===x.length)return;const e=i.current;e.querySelectorAll("canvas.heatmap-canvas").forEach(e=>e.remove());const s=M().create({container:e,radius:110,maxOpacity:.55,minOpacity:0,blur:.85,gradient:{0:"rgba(59, 130, 246, 0)",.25:"rgba(59, 130, 246, 0.6)",.5:"rgba(34, 197, 94, 0.7)",.7:"rgba(250, 204, 21, 0.8)",.9:"rgba(254, 106, 107, 0.9)",1:"rgba(220, 38, 38, 1)"}});l.current=s;e.querySelectorAll("canvas").forEach(e=>e.classList.add("heatmap-canvas"));const t=e.getBoundingClientRect(),a=x.map(e=>{const s=r.current[e.id];if(!s)return null;const a=s.getBoundingClientRect();return{x:Math.round(a.left-t.left+a.width/2),y:Math.round(a.top-t.top+a.height/2),value:Math.max(0,Math.min(100,e.drop_off||0))}}).filter(Boolean);s.setData({max:100,min:0,data:a});const n=()=>{const t=e.getBoundingClientRect(),a=x.map(e=>{const s=r.current[e.id];if(!s)return null;const a=s.getBoundingClientRect();return{x:Math.round(a.left-t.left+a.width/2),y:Math.round(a.top-t.top+a.height/2),value:Math.max(0,Math.min(100,e.drop_off||0))}}).filter(Boolean);s.setData({max:100,min:0,data:a})};return window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[x]),!t)return(0,E.jsx)("div",{className:"flex items-center justify-center py-16","data-testid":"heatmap-loading",children:(0,E.jsx)(g.A,{className:"w-6 h-6 animate-spin text-zinc-400"})});if(0===x.length)return(0,E.jsx)("div",{className:"rounded-xl border border-zinc-200 bg-zinc-50/40 p-8 text-center","data-testid":"heatmap-empty",children:(0,E.jsx)("p",{className:"text-sm text-zinc-500",children:"There is not enough data to display. Check back later."})});const h=t.total_completed||0,u=t.total_abandoned||0;return h+u<10||0===u?(0,E.jsxs)("div",{className:"space-y-4","data-testid":"heatmap-insufficient-data",children:[(0,E.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,E.jsxs)("div",{className:"flex items-start gap-2",children:[(0,E.jsx)(L.A,{className:"w-4 h-4 text-zinc-400 mt-0.5 shrink-0"}),(0,E.jsx)("p",{className:"text-xs text-zinc-500",children:(0,E.jsx)("strong",{className:"text-zinc-700",children:"Field-engagement heatmap"})})]}),n&&(0,E.jsx)(c.$,{variant:"ghost",size:"sm",onClick:n,"data-testid":"heatmap-close-btn","aria-label":"Close heatmap",children:(0,E.jsx)(B.A,{className:"w-4 h-4"})})]}),(0,E.jsxs)("div",{className:"rounded-xl border border-zinc-200 bg-zinc-50/40 p-10 text-center",children:[(0,E.jsx)("p",{className:"text-sm text-zinc-600 font-medium",children:"There is not enough data to display."}),(0,E.jsx)("p",{className:"text-xs text-zinc-500 mt-1",children:"Check back later."})]})]}):(0,E.jsxs)("div",{className:"space-y-4","data-testid":"form-heatmap",children:[(0,E.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,E.jsxs)("div",{className:"flex items-start gap-2",children:[(0,E.jsx)(L.A,{className:"w-4 h-4 text-zinc-400 mt-0.5 shrink-0"}),(0,E.jsxs)("p",{className:"text-xs text-zinc-500 max-w-2xl",children:[(0,E.jsx)("strong",{className:"text-zinc-700",children:"Field-engagement heatmap"})," \u2014 warm areas indicate where respondents drop off (",t.total_completed," completed + ",t.total_abandoned," abandoned). Hover over a field card to see its exact metrics."]})]}),n&&(0,E.jsx)(c.$,{variant:"ghost",size:"sm",onClick:n,"data-testid":"heatmap-close-btn","aria-label":"Close heatmap",children:(0,E.jsx)(B.A,{className:"w-4 h-4"})})]}),(0,E.jsxs)("div",{className:"flex items-center gap-3 text-[11px] text-zinc-500","data-testid":"heatmap-legend",children:[(0,E.jsx)("span",{children:"Smooth flow"}),(0,E.jsx)("div",{className:"flex-1 h-2 rounded-full",style:{background:"linear-gradient(to right, rgba(59,130,246,0.7), rgba(34,197,94,0.7), rgba(250,204,21,0.85), rgba(254,106,107,0.9), rgba(220,38,38,1))"}}),(0,E.jsx)("span",{children:"High friction"})]}),(0,E.jsxs)("div",{ref:i,className:"relative rounded-xl border border-zinc-200 bg-white p-6 space-y-3 overflow-hidden","data-testid":"heatmap-container",children:[(0,E.jsxs)("div",{className:"pb-2 border-b border-zinc-100",children:[(0,E.jsx)("h3",{className:"font-bold text-zinc-900",children:(null===s||void 0===s?void 0:s.title)||"Form Preview"}),(null===s||void 0===s?void 0:s.description)&&(0,E.jsx)("p",{className:"text-xs text-zinc-500 mt-0.5 line-clamp-1",children:s.description})]}),x.map((e,s)=>
1{const t=(e.drop_off||0)>=50,a=(e.drop_off||0)>=20&&(e.drop_off||0)<50;return(0,E.jsxs)("div",{ref:s=>{r.current[e.id]=s},className:"relative z-10 rounded-lg border bg-white/90 backdrop-blur-sm p-3 transition-all cursor-default ".concat(d===e.id?"ring-2 ring-zinc-900 shadow-md":"border-zinc-200"),onMouseEnter:()=>o(e.id),onMouseLeave:()=>o(null),"data-testid":"heatmap-card-".concat(e.id),children:[(0,E.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,E.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,E.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,E.jsxs)("span",{className:"text-[10px] text-zinc-400 font-mono",children:["#",s+1]}),(0,E.jsx)("span",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:e.type}),e.required&&(0,E.jsx)("span",{className:"text-[10px] text-amber-700 bg-amber-50 px-1.5 py-0.5 rounded",children:"required"})]}),(0,E.jsx)("p",{className:"text-sm font-medium text-zinc-900 truncate",title:e.question||"",children:e.question||(0,E.jsx)("span",{className:"italic text-zinc-400",children:"(no label)"})})]}),(0,E.jsxs)("div",{className:"text-right shrink-0",children:[(0,E.jsxs)("div",{className:"text-sm font-bold ".concat(t?"text-red-600":a?"text-amber-600":"text-zinc-700"),children:[(e.drop_off||0).toFixed(0),"%"]}),(0,E.jsx)("div",{className:"text-[10px] text-zinc-400 uppercase tracking-wide",children:"drop-off"})]})]}),d===e.id&&(0,E.jsxs)("div",{className:"mt-2 pt-2 border-t border-zinc-100 flex items-center gap-4 text-[11px] text-zinc-500","data-testid":"heatmap-card-detail-".concat(e.id),children:[(0,E.jsxs)("span",{children:["Reached: ",(0,E.jsx)("strong",{className:"text-zinc-700",children:e.reached||0})]}),(0,E.jsxs)("span",{children:["Answered: ",(0,E.jsx)("strong",{className:"text-zinc-700",children:e.completed_with_answer||0})]}),(0,E.jsxs)("span",{children:["Fill rate: ",(0,E.jsxs)("strong",{className:"text-zinc-700",children:[(e.fill_rate||0).toFixed(1),"%"]})]})]})]},e.id)})]})]})};var D=t(30480),P=t(35016);const T="#FE6A6B",O=e=>{let{title:s,icon:t,data:a}=e;const n=a?Object.entries(a).sort((e,s)=>s[1]-e[1]).slice(0,6):[],i=n.reduce((e,s)=>e+s[1],0);return(0,E.jsxs)(r.Zp,{children:[(0,E.jsx)(r.aR,{className:"pb-3",children:(0,E.jsxs)(r.ZB,{className:"text-sm font-medium flex items-center gap-2",children:[(0,E.jsx)(t,{className:"w-4 h-4",style:{color:T}}),s]})}),(0,E.jsx)(r.Wu,{className:"pt-0",children:0===n.length?(0,E.jsx)("p",{className:"text-xs text-zinc-400 py-2",children:"No data yet"}):(0,E.jsx)("div",{className:"space-y-2.5",children:n.map(e=>{let[s,t]=e;const a=i>0?t/i*100:0;return(0,E.jsxs)("div",{children:[(0,E.jsxs)("div",{className:"flex items-center justify-between text-sm mb-1",children:[(0,E.jsx)("span",{className:"text-zinc-700 truncate mr-2",children:s}),(0,E.jsxs)("span",{className:"text-zinc-400 text-xs whitespace-nowrap",children:[t," (",a.toFixed(0),"%)"]})]}),(0,E.jsx)("div",{className:"h-1.5 bg-zinc-100 rounded-full overflow-hidden",children:(0,E.jsx)("div",{className:"h-full rounded-full",style:{width:"".concat(a,"%"),backgroundColor:T}})})]},s)})})})]})},Z="ff_block_own_activity",V=e=>{let{elementAnalytics:s}=e;const t="#FE6A6B",n="#10B981",i=s.elements,l=i.some(e=>(e.reached||0)>0),c=(0,a.useMemo)(()=>[{key:"reached",label:"Reached",color:t,disabled:!l,get baseline(){return Math.max(1,i[0].reached||0)},valueFor:e=>e.reached||0,format:e=>e.toLocaleString()},{key:"fill_rate",label:"Fill rate",color:n,disabled:!1,baseline:100,valueFor:e=>e.fill_rate||0,format:e=>"".concat((e||0).toFixed(1),"%")}],[i,l]),r=l?"reached":"fill_rate",[d,o]=(0,a.useState)(r),[m,h]=(0,a.useState)(null),u=c.find(e=>e.key===d)||c[0],p="function"===typeof u.baseline?u.baseline():u.baseline;return(0,E.jsxs)("div",{className:"space-y-2","data-testid":"element-funnel",children:[(0,E.jsx)("div",{className:"flex flex-wrap gap-2 mb-3","data-testid":"element-funnel-toggles",children:c.map(e=>{const s=d===e.key;return(0,E.jsxs)("button",{type:"button",onClick:()=>!e.disabled&&o(e.key),disabled:e.disabled,className:"inline-flex items-center gap-2 px-2.5 py-1 rounded-full text-xs font-medium border transition-colors ".concat(s?"bg-white text-zinc-900 border-zinc-300":"bg-zinc-50 text-zinc-400 border-zinc-200 hover:text-zinc-600"," disabled:opacity-40 disabled:cursor-not-allowed"),"data-testid":"element-funnel-toggle-".concat(e.key),"aria-pressed":s,children:[(0,E.jsx)("span",{className:"w-2.5 h-2.5 rounded-full",style:{backgroundColor:s?e.color:"#D4D4D8"}}),e.label]},e.key)})}),(0,E.jsxs)("p",{className:"text-xs text-zinc-500 mb-3",children:["Visual funnel showing where respondents drop off element-by-element (",s.total_completed," completed + ",s.total_abandoned," abandoned)."]}),i.map((e,s)=>{const a=u.valueFor(e),c=p>0?Math.max("reached"===u.key?4:0,a/p*100):0,r=s>0?u.valueFor(i[s-1]):0,d=s>0?Math.max(0,r-a):0,o=s>0&&r>0?Math.round(d/r*100):0,f=m===e.id;return(0,E.jsxs)("div",{"data-testid":"element-analytics-row-".concat(e.id),children:[s>0&&o>0&&(0,E.jsxs)("div",{className:"flex items-center justify-center text-[11px] text-zinc-400 -my-0.5 gap-1","data-testid":"element-funnel-drop-".concat(e.id),children:[(0,E.jsx)(x.A,{className:"w-3 h-3"}),"-",o,"% (",u.format(d),")"]}),(0,E.jsxs)("div",{className:"flex items-stretch gap-3 group relative",onMouseEnter:()=>h(e.id),onMouseLeave:()=>h(null),children:[(0,E.jsxs)("div",{className:"flex-1 relative h-12 flex items-center justify-center",children:[(0,E.jsx)("div",{className:"absolute inset-y-1 rounded-md transition-all",style:{width:"".concat(c,"%"),backgroundColor:u.color,opacity:Math.max(.45,c/100),boxShadow:0===s?"0 1px 0 ".concat(u.color,"40 inset"):void 0}}),(0,E.jsx)("div",{className:"relative z-10 text-xs font-semibold text-white drop-shadow-sm",style:{textShadow:"0 1px 1px rgba(0,0,0,0.18)"},children:u.format(a)})]}),(0,E.jsxs)("div",{className:"w-44 flex flex-col justify-center gap-0.5 py-1",children:[(0,E.jsxs)("p",{className:"text-sm font-medium text-zinc-900 truncate leading-tight",title:e.question||"",children:[(0,E.jsxs)("span",{className:"text-zinc-400 mr-1",children:["#",e.order+1]}),e.question||(0,E.jsx)("span",{className:"italic text-zinc-400",children:"(no label)"})]}),(0,E.jsxs)("div",{className:"flex items-center gap-2 text-[10px] text-zinc-500",children:[(0,E.jsx)("span",{className:"uppercase tracking-wide",children:e.type}),e.required&&(0,E.jsx)("span",{className:"text-amber-700",children:"required"})]})]}),f&&(0,E.jsxs)("div",{className:"absolute -top-2 left-1/2 -translate-x-1/2 -translate-y-full z-20 px-3 py-2 bg-white border border-zinc-200 rounded-md shadow-sm pointer-events-none text-xs min-w-[200px]","data-testid":"element-funnel-tooltip-".concat(e.id),children:[(0,E.jsxs)("div",{className:"font-medium text-zinc-900 mb-1.5 truncate",children:["#",e.order+1," \xb7 ",e.question||(0,E.jsx)("span",{className:"italic text-zinc-400",children:"(no label)"})]}),l&&(0,E.jsxs)("div",{className:"flex items-center justify-between gap-3 text-zinc-700",children:[(0,E.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,E.jsx)("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:t}}),"Reached"]}),(0,E.jsx)("span",{className:"font-medium tabular-nums",children:(e.reached||0).toLocaleStr
1ing()})]}),(0,E.jsxs)("div",{className:"flex items-center justify-between gap-3 text-zinc-700",children:[(0,E.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,E.jsx)("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:n}}),"Fill rate"]}),(0,E.jsxs)("span",{className:"font-medium tabular-nums",children:[(e.fill_rate||0).toFixed(1),"%"]})]}),s>0&&o>0&&(0,E.jsxs)("div",{className:"flex items-center justify-between gap-3 text-zinc-500 mt-1 pt-1 border-t border-zinc-100",children:[(0,E.jsx)("span",{children:"Drop from previous"}),(0,E.jsxs)("span",{className:"font-medium tabular-nums",children:["-",o,"%"]})]})]})]})]},e.id)})]})},U=()=>{var e,s,t;const[x,R]=(0,a.useState)(!0),{formatDate:M}=(0,D.i)(),{isPaid:L}=(0,P.As)(),[B,U]=(0,a.useState)(!1),[W,H]=(0,a.useState)(!1),[I,$]=(0,a.useState)(!1),[Y,G]=(0,a.useState)(null),[X,J]=(0,a.useState)([]),[K,Q]=(0,a.useState)(null),[ee,se]=(0,a.useState)(null),[te,ae]=(0,a.useState)("30"),[ne,ie]=(0,a.useState)(""),[le,ce]=(0,a.useState)(""),[re,de]=(0,a.useState)(()=>"true"===localStorage.getItem(Z)),[oe,me]=(0,a.useState)(null),[xe,he]=(0,a.useState)(null),[ue,pe]=(0,a.useState)(!1);(0,a.useEffect)(()=>{i.LP.getMyIp().then(e=>me(e.ip)).catch(()=>{})},[]),(0,a.useEffect)(()=>{fe(),je()},[re,oe]),(0,a.useEffect)(()=>{K&&be(K)},[K,te,ne,le,re,oe]);const fe=async()=>{try{const e=re&&oe?oe:null,s=await i.LP.getDashboard(e);G(s)}catch(e){G({summary:{total_forms:0,published_forms:0,total_views:0,total_submissions:0,avg_completion_rate:0},chart_data:[],top_forms:[]})}finally{R(!1)}},je=async()=>{try{const e=await i._0.getAll(),s=Array.isArray(e)?e:e.forms||[];J(s),s.length>0&&!K&&Q(s[0].id)}catch(e){console.error("Failed to fetch forms",e),J([])}},be=async e=>{try{const s=re&&oe?oe:null,t="custom"===te,a=await i.LP.getFormAnalytics(e,s,t?void 0:parseInt(te),t?ne:void 0,t?le:void 0);se(a)}catch(s){se(null)}pe(!0);try{const s=await i.LP.getFormElementAnalytics(e);he(s)}catch(t){he(null)}finally{pe(!1)}};return x?(0,E.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-zinc-50",children:(0,E.jsx)(F.A,{size:48})}):(0,E.jsxs)("div",{className:"min-h-screen bg-zinc-50",children:[(0,E.jsx)("header",{className:"bg-white border-b border-zinc-200",children:(0,E.jsx)("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:(0,E.jsxs)("div",{className:"flex items-center justify-between h-16",children:[(0,E.jsxs)("div",{className:"flex items-center gap-4",children:[(0,E.jsx)(n.N_,{to:"/dashboard",className:"p-2 hover:bg-zinc-100 rounded-lg transition-colors",children:(0,E.jsx)(h.A,{className:"w-5 h-5"})}),(0,E.jsx)("h1",{className:"text-xl font-bold text-zinc-900",children:"Analytics"})]}),(0,E.jsxs)("div",{className:"flex items-center gap-3",children:[(0,E.jsxs)("button",{type:"button",onClick:()=>{L?K?U(!0):m.oR.error("Pick a form first to view its heatmap."):m.oR.error("Heatmap is a Pro feature. Upgrade to unlock.")},className:"flex items-center gap-1.5 text-sm text-zinc-500 hover:text-zinc-900 transition-colors group","data-testid":"open-heatmap-btn",title:L?"View field-engagement heatmap":"Heatmap is a Pro feature",children:[(0,E.jsx)(u.A,{className:"w-4 h-4"}),(0,E.jsx)("span",{className:"hidden sm:inline",children:"Heatmap"}),!L&&(0,E.jsx)("span",{className:"text-[10px] bg-[#FF6B6B] text-white px-1.5 py-0.5 rounded font-semibold",children:"PRO"})]}),(0,E.jsx)("span",{className:"hidden sm:inline text-zinc-200",children:"|"}),(0,E.jsxs)("label",{htmlFor:"block-own",className:"flex items-center gap-2 text-sm text-zinc-500 cursor-pointer select-none","data-testid":"block-own-label",children:[(0,E.jsx)(p.A,{className:"w-4 h-4"}),(0,E.jsx)("span",{className:"hidden sm:inline",children:"Block my own activity"})]}),(0,E.jsx)(k.d,{id:"block-own",checked:re,onCheckedChange:e=>{de(e),localStorage.setItem(Z,String(e))},"data-testid":"block-own-toggle"}),(0,E.jsx)("span",{className:"hidden sm:inline text-zinc-200",children:"|"}),(0,E.jsxs)("button",{type:"button",onClick:()=>{K?H(!0):m.oR.error("Pick a form first.")},className:"flex items-center gap-1.5 text-sm text-zinc-500 hover:text-red-600 transition-colors group","data-testid":"reset-stats-btn",title:"Reset all stats for this form",children:[(0,E.jsx)(f.A,{className:"w-4 h-4"}),(0,E.jsx)("span",{className:"hidden sm:inline",children:"Reset Stats"})]})]})]})})}),(0,E.jsx)("main",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8",children:(0,E.jsxs)("div",{className:"space-y-6",children:[(0,E.jsxs)(r.Zp,{children:[(0,E.jsxs)(r.aR,{className:"flex flex-row items-center justify-between",children:[(0,E.jsx)(r.ZB,{children:"Form Analytics"}),(0,E.jsxs)("div",{className:"flex items-center gap-3",children:[(0,E.jsxs)(o.l6,{value:K||"",onValueChange:Q,children:[(0,E.jsx)(o.bq,{className:"w-[260px]",children:(0,E.jsx)(o.yv,{placeholder:"Select a form"})}),(0,E.jsx)(o.gC,{children:X.map(e=>(0,E.jsx)(o.eb,{value:e.id,children:e.title},e.id))})]}),(0,E.jsxs)(o.l6,{value:te,onValueChange:e=>{ae(e),"custom"!==e&&(ie(""),ce(""))},children:[(0,E.jsx)(o.bq,{className:"w-[150px]",children:(0,E.jsx)(o.yv,{})}),(0,E.jsxs)(o.gC,{children:[(0,E.jsx)(o.eb,{value:"1",children:"Last 24 hours"}),(0,E.jsx)(o.eb,{value:"3",children:"Last 3 days"}),(0,E.jsx)(o.eb,{value:"7",children:"Last 7 days"}),(0,E.jsx)(o.eb,{value:"30",children:"Last 30 days"}),(0,E.jsx)(o.eb,{value:"90",children:"Last 90 days"}),(0,E.jsx)(o.eb,{value:"365",children:"Last 12 months"}),(0,E.jsx)(o.eb,{value:"0",children:"All time"})]})]}),"custom"===te&&(0,E.jsxs)(C.AM,{children:[(0,E.jsx)(C.Wv,{asChild:!0,children:(0,E.jsxs)(c.$,{variant:"outline",size:"sm",className:"gap-1.5",children:[(0,E.jsx)(j.A,{className:"w-3.5 h-3.5"}),ne&&le?"".concat(ne," \u2013 ").concat(le):"Pick dates"]})}),(0,E.jsxs)(C.hl,{className:"w-auto p-4 space-y-3",align:"end",children:[(0,E.jsxs)("div",{className:"space-y-1.5",children:[(0,E.jsx)("label",{className:"text-xs font-medium text-zinc-500",children:"Start"}),(0,E.jsx)(A.p,{type:"date",value:ne,onChange:e=>ie(e.target.value),className:"text-sm","data-testid":"custom-start-date"})]}),(0,E.jsxs)("div",{className:"space-y-1.5",children:[(0,E.jsx)("label",{className:"text-xs font-medium text-zinc-500",children:"End"}),(0,E.jsx)(A.p,{type:"date",value:le,onChange:e=>ce(e.target.value),className:"text-sm","data-testid":"custom-end-date"})]})]})]})]})]}),(0,E.jsx)(r.Wu,{children:ee?(0,E.jsxs)("div",{className:"space-y-6",children:[(0,E.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[(0,E.jsxs)("div",{className:"bg-zinc-50 rounded-lg p-4",children:[(0,E.jsx)("p",{className:"text-xs text-zinc-500 uppercase",children:"Views"}),(0,E.jsx)("p",{className:"text-xl font-bold",children:ee.summary.total_views})]}),(0,E.jsxs)("div",{className:"bg-zinc-50 rounded-lg p-4",children:[(0,E.jsx)("p",{className:"text-xs text-zinc-500 uppercase",children:"Submissions"}),(0,E.jsx)("p",{className:"text-xl font-bold",children:ee.summary.total_submissions})]}),(0,E.jsxs)("div",{className:"bg-zinc-50 rounded-lg p-4",children:[(0,E.jsx)("p",{className:"text-xs text-zinc-500 uppercase",children:"Completion Rate"}),(0,E.jsxs)("p",{className:"text-xl font-bold",children:[ee.summary.completion_rate,"%"]})]}),(0,E.jsxs)("div",{className:"bg-zinc-50 rounded-lg p-4",children:[(0,E.jsx)("p",{className:"text-xs text-zinc-500 uppercase",children:"Avg. Time"}),(0,E.jsx)("p",{className:"text-xl font-bold",children:ee.summary.avg_completion_time_seconds?"".concat(Math.round(ee.summary.avg_completion_time_seconds/60),"m"):"-"})]})]}),(0,E.jsx)("div",{"data-testid":"form-activity-chart",children:(()=>{const e=ee.chart_data||[];let s=e,t="day";if(e.length>200){const a=new Map;for(const s of e){const e=(s.date||"").slice(0,7);if(!e)continue;const t=a.get(e)||{date:"".concat(e,"-01"),views:0,submissions:0};t.views+=s.views||0,t.submissions+=s.submissions||0,a.set(e,t)}s=Array.from(a.values()).sort((e,s)=>e.date.localeCompare(s.date)),t="month"}return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("div",{className:"flex items-center justify-between mb-3 pt-2 border-t border-zinc-100",children:(0,E.jsxs)("h4",{className:"text-sm font-semibold text-zinc-800 uppercase tracking-wide pt-3",children:["Activity Over Time","day"!==t&&(0,E.jsxs)("span",{className:"ml-2 text-xs font-normal text-zinc-400 normal-case tracking-normal",children:["(grouped by ",t,")"]})]})}),(0,E.jsx)(l.A,{series:s,height:240,seriesDefs:[{key:"views",label:"Views",color:"#A1A1AA",axis:"left",format:"number"},{key:"submissions",label:"Submissions",color:"#FE6A6B",axis:"left",format:"number"}],defaultVisible:{views:!0,submissions:!0}})]})})()}),K&&(0,E.jsxs)("div",{"data-testid":"element-funnel-section",children:[(0,E.jsx)("div",{className:"flex items-center justify-between mb-3 pt-2 border-t border-zinc-100",children:(0,E.jsxs)("h4",{className:"text-sm font-semibold text-zinc-800 uppercase tracking-wide pt-3 flex items-center gap-2",children:[(0,E.jsx)(b.A,{className:"w-3.5 h-3.5",style:{color:T}}),"Funnel by element"]})}),ue&&(0,E.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,E.jsx)(g.A,{className:"w-5 h-5 animate-spin text-zinc-400"})}),!ue&&xe&&0===xe.elements.length&&(0,E.jsx)("p",{className:"text-sm text-zinc-500 py-6 text-center",children:"This form has no elements yet."}),!ue&&xe&&xe.elements.length>0&&(0,E.jsx)(V,{elementAnalytics:xe})]})]}):(0,E.jsxs)("div",{className:"text-center py-12 text-zinc-500",children:[(0,E.jsx)(b.A,{className:"w-12 h-12 mx-auto mb-4 text-zinc-300"}
1),(0,E.jsx)("p",{children:"Select a form to view analytics"})]})})]}),(null===ee||void 0===ee||null===(e=ee.traffic_sources)||void 0===e?void 0:e.length)>0&&(0,E.jsxs)(r.Zp,{children:[(0,E.jsx)(r.aR,{children:(0,E.jsx)(r.ZB,{className:"text-lg",children:"Traffic Sources"})}),(0,E.jsx)(r.Wu,{children:(0,E.jsx)("div",{className:"space-y-3",children:ee.traffic_sources.map((e,s)=>{const t=ee.traffic_sources.reduce((e,s)=>e+s.count,0),a=(e.count/t*100).toFixed(1);return(0,E.jsx)("div",{className:"flex items-center gap-3",children:(0,E.jsxs)("div",{className:"flex-1",children:[(0,E.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,E.jsx)("span",{className:"text-sm font-medium",children:e.source}),(0,E.jsxs)("span",{className:"text-sm text-zinc-500",children:[e.count," (",a,"%)"]})]}),(0,E.jsx)(d.k,{value:parseFloat(a),className:"h-2"})]})},s)})})})]}),ee&&(0,E.jsxs)("div",{className:"grid grid-cols-2 lg:grid-cols-5 gap-4",children:[(0,E.jsx)(O,{title:"Browser",icon:v.A,data:ee.browsers}),(0,E.jsx)(O,{title:"Device",icon:N.A,data:ee.devices}),(0,E.jsx)(O,{title:"Operating System",icon:y.A,data:ee.operating_systems}),(0,E.jsx)(O,{title:"Country",icon:w.A,data:ee.countries}),(0,E.jsx)(O,{title:"City",icon:z.A,data:ee.cities})]}),(null===ee||void 0===ee||null===(s=ee.recent_submissions)||void 0===s?void 0:s.length)>0&&(0,E.jsxs)(r.Zp,{children:[(0,E.jsx)(r.aR,{children:(0,E.jsx)(r.ZB,{className:"text-lg",children:"Recent Submissions"})}),(0,E.jsx)(r.Wu,{children:(0,E.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:ee.recent_submissions.slice(0,6).map((e,s)=>(0,E.jsxs)("div",{className:"flex items-center gap-3 p-2 bg-zinc-50 rounded-lg",children:[(0,E.jsx)("div",{className:"w-8 h-8 rounded-full flex items-center justify-center",style:{backgroundColor:"#FE6A6B20"},children:(0,E.jsx)(_.A,{className:"w-4 h-4",style:{color:"#FE6A6B"}})}),(0,E.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,E.jsx)("p",{className:"text-sm font-medium",children:"New submission"}),(0,E.jsx)("p",{className:"text-xs text-zinc-500",children:e.completed_at?M(e.completed_at):e.started_at?M(e.started_at):"Recently"})]})]},e.id||s))})})]})]})}),B&&(0,E.jsx)("div",{className:"fixed inset-0 z-50 bg-zinc-900/50 backdrop-blur-sm flex items-start justify-center overflow-y-auto p-4 sm:p-8",onClick:e=>{e.target===e.currentTarget&&U(!1)},"data-testid":"heatmap-modal-overlay",children:(0,E.jsx)("div",{className:"w-full max-w-3xl bg-white rounded-2xl shadow-xl my-8 p-6","data-testid":"heatmap-modal",children:(0,E.jsx)(q,{form:X.find(e=>e.id===K),elementAnalytics:xe,onClose:()=>U(!1)})})}),(0,E.jsx)(S.lG,{open:W,onOpenChange:e=>{I||H(e)},children:(0,E.jsxs)(S.Cf,{"data-testid":"reset-stats-dialog",children:[(0,E.jsxs)(S.c7,{children:[(0,E.jsx)(S.L3,{children:"Are you sure?"}),(0,E.jsxs)(S.rr,{children:["This will permanently delete all views, completed submissions, and abandoned data for",(0,E.jsxs)("strong",{className:"text-zinc-900",children:[" ",(null===(t=X.find(e=>e.id===K))||void 0===t?void 0:t.title)||"this form"]}),". This cannot be undone."]})]}),(0,E.jsxs)(S.Es,{className:"gap-2",children:[(0,E.jsx)(c.$,{variant:"outline",onClick:()=>H(!1),disabled:I,"data-testid":"reset-stats-cancel",children:"Cancel"}),(0,E.jsxs)(c.$,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:async()=>{if(K){$(!0);try{await i.LP.resetFormStats(K),await be(K),m.oR.success("Stats reset."),H(!1)}catch(t){var e,s;m.oR.error((null===t||void 0===t||null===(e=t.response)||void 0===e||null===(s=e.data)||void 0===s?void 0:s.detail)||"Failed to reset stats.")}finally{$(!1)}}},disabled:I,"data-testid":"reset-stats-confirm",children:[I&&(0,E.jsx)(g.A,{className:"w-4 h-4 mr-2 animate-spin"}),"Yes, Reset Stats"]})]})]})})]})}},75395(e,s,t){t.d(s,{k:()=>o});var a=t(89379),n=t(53986),i=t(65043),l=t(7989),c=t(1089),r=t(70579);const d=["className","value"],o=i.forwardRef((e,s)=>{let{className:t,value:i}=e,o=(0,n.A)(e,d);return(0,r.jsx)(l.bL,(0,a.A)((0,a.A)({ref:s,className:(0,c.cn)("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",t)},o),{},{children:(0,r.jsx)(l.C1,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:"translateX(-".concat(100-(i||0),"%)")}})}))});o.displayName=l.bL.displayName},78615(e,s,t){t.d(s,{AM:()=>o,Wv:()=>m,hl:()=>x});var a=t(89379),n=t(53986),i=t(65043),l=t(80942),c=t(1089),r=t(70579);const d=["className","align","sideOffset"],o=l.bL,m=l.l9,x=(l.Mz,i.forwardRef((e,s)=>{let{className:t,align:i="center",sideOffset:o=4}=e,m=(0,n.A)(e,d);return(0,r.jsx)(l.ZL,{children:(0,r.jsx)(l.UC,(0,a.A)({ref:s,align:i,sideOffset:o,className:(0,
1c.cn)("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none 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-popover-content-transform-origin]",t)},m))})}));x.displayName=l.UC.displayName}}]);
2//# sourceMappingURL=376.bfc03394.chunk.js.map

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.