PageSourceSearch

https://www.focora.ai/assets/AnalyticsPage-D5KMDqbA.js

js focora.ai collected 2026-09-24 14:30:46 UTC 11,360 bytes, 14 lines download raw bytes

1import{t as s,b as se,w as y,H as re,G as ne,O as ae}from"./chunk-4N6VE7H7-DCXb7SYf.js";import{C as Q}from"./chevron-left-DlG8RhzE.js";import{c as oe}from"./createLucideIcon-5ma6jv8o.js";import{C as X}from"./chevron-right-iU340f0p.js";import{b as G}from"./logger-DuBIU0n2.js";import{r as R,w as I}from"./storage-ChT9lsEs.js";/**
2 * @license lucide-react v0.479.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const ie=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]],le=oe("CalendarDays",ie);function ce({activeTab:e,setActiveTab:t,tab:r,toPath:a}){const n=e===r.toLowerCase();return s.jsx(se,{to:a,children:s.jsx("button",{className:`border-[1.5px] px-4 py-2 rounded-lg text-sm font-medium transition-colors cursor-pointer
7          ${n?"bg-purple-100 text-purple-600 border-purple-200":"bg-white text-gray-600 border-gray-200/60 hover:bg-gray-50"}`,onClick:()=>t(r.toLowerCase()),children:r})})}const Z=1,O=["January","February","March","April","May","June","July","August","September","October","November","December"],S=O.map(e=>e.slice(0,3)),ue=["S","M","T","W","T","F","S"],de=Array.from({length:7},(e,t)=>ue[(t+Z)%7]),z=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},F=(e,t)=>{const r=new Date(e);return r.setDate(r.getDate()+t),r},Y=e=>{const t=z(e);return F(t,-((t.getDay()-Z+7)%7))},N=e=>new Date(e.getFullYear(),e.getMonth(),1),me=e=>new Date(e.getFullYear(),0,1),ge=(e,t)=>new Date(e,t+1,0).getDate(),A=(e,t)=>{const r=new Date(e.getFullYear(),e.getMonth()+t,1);return new Date(r.getFullYear(),r.getMonth(),Math.min(e.getDate(),ge(r.getFullYear(),r.getMonth())))},pe=(e,t)=>A(e,t*12),P=(e,t)=>e==="week"?Y(t):e==="month"?N(t):me(t),E=(e,t,r)=>P(e,t).getTime()===P(e,r).getTime(),he=(e,t,r)=>P(e,t).getTime()>P(e,r).getTime(),W=(e,t,r)=>e==="week"?F(t,7*r):e==="month"?A(t,r):pe(t,r);function xe(e,t,r){if(e==="year")return String(t.getFullYear());if(e==="month")return`${(r?S:O)[t.getMonth()]} ${t.getFullYear()}`;const a=Y(t),n=F(a,6),l=S[a.getMonth()],i=S[n.getMonth()];return r?a.getMonth()===n.getMonth()?`${l} ${a.getDate()} – ${n.getDate()}`:`${l} ${a.getDate()} – ${i} ${n.getDate()}`:a.getFullYear()!==n.getFullYear()?`${l} ${a.getDate()}, ${a.getFullYear()} – ${i} ${n.getDate()}, ${n.getFullYear()}`:a.getMonth()!==n.getMonth()?`${l} ${a.getDate()} – ${i} ${n.getDate()}, ${n.getFullYear()}`:`${l} ${a.getDate()} – ${n.getDate()}, ${n.getFullYear()}`}const u=z(new Date),B=e=>String(e).padStart(2,"0"),H=e=>`${e.getFullYear()}-${B(e.getMonth()+1)}-${B(e.getDate())}`,J=e=>{const t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e||"");if(!t)return u;const[,r,a,n]=t,l=new Date(Number(r),Number(a)-1,Number(n));return Number.isNaN(l.getTime())?u:z(l)},v="focus:outline-none focus-visible:ring-2 focus-visible:ring-purple-300",_=(e,t)=>`flex ${t} shrink-0 items-center justify-center rounded-md transition-colors ${v} `+(e?"cursor-default text-gray-300":"text-gray-500 hover:bg-gray-100 hover:text-gray-700"),K=()=>s.jsx("div",{"aria-hidden":!0,className:"mx-1 h-5 w-px shrink-0 bg-gray-200"});function fe({value:e,onChange:t,compact:r}){return s.jsx("div",{role:"group","aria-label":"Period granularity",className:"flex shrink-0 rounded-lg bg-gray-100 p-0.5",children:["week","month","year"].map(a=>s.jsx("button",{type:"button","aria-pressed":e===a,onClick:()=>t(a),className:`${r?"px-1.5 text-xs":"px-3 text-sm"} py-1 font-medium rounded-md transition-colors ${v} `+(e===a?"bg-white text-gray-900 shadow-sm":"text-gray-500 hover:text-gray-700"),children:a[0].toUpperCase()+a.slice(1)},a))})}function ye({granularity:e,anchor:t,onPick:r,onToday:a,compact:n}){const[l,i]=y.useState(()=>N(t)),[x,d]=y.useState(()=>t.getFullYear()),[b,w]=y.useState(()=>Math.floor(t.getFullYear()/12)*12),f=u.getFullYear();let g,j,$,k,c;e==="week"?(g=`${O[l.getMonth()]} ${l.getFullYear()}`,j=!0,$=l.getTime()<N(u).getTime(),k=()=>i(o=>A(o,-1)),c=()=>i(o=>A(o,1))):e==="month"?(g=String(x),j=!0,$=x<f,k=()=>d(o=>o-1),c=()=>d(o=>o+1)):(g=`${b} – ${b+11}`,j=!0,$=b+12<=f,k=()=>w(o=>o-12),c=()=>w(o=>o+12));const T=E(e,t,u),D=()=>{i(N(u)),d(f),w(Math.floor(f/12)*12),a()},ee=n?"pp-in absolute inset-x-0 top-full z-30 mt-1.5":"pp-in absolute right-0 top-full z-30 mt-1.5 w-72";return s.jsxs("div",{role:"dialog","aria-label":"Jump to a date",className:`${ee} rounded-xl border border-gray-200 bg-white p-3 shadow-lg`,children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between px-1",children:[s.jsx("button",{type:"button","aria-label":"Previous",disabled:!j,onClick:k,className:_(!j,"h-7 w-7"),children:s.jsx(Q,{size:16})}),s.jsx("span",{className:"text-sm font-semibold text-gray-900 tabular-nums",children:g}),s.jsx("button",{type:"button","aria-label":"Next",disabled:!$,onClick:c,className:_(!$,"h-7 w-7"),children:s.jsx(X,{size:16})})]}),e==="week"&&s.jsxs("div",{children:[s.jsx("div",{className:"grid grid-cols-7 pb-1",children:de.map((o,m)=>s.jsx("span",{className:"flex h-6 items-center justify-center text-xs font-medium text-gray-400",children:o},m))}),s.jsx("div",{className:"flex flex-col gap-0.5",children:Array.from({length:6},(o,m)=>F(Y(N(l)),m*7)).map(o=>{const m=o.getTime()>Y(u).getTime(),p=o.getTime()===Y(t).getTime();return s.jsx("button",{type:"button",disabled:m,onClick:()=>r(o),className:`grid w-full grid-cols-7 rounded-lg transition-colors ${v} `+(m?"cursor-default":p?"bg-purple-100":"hover:bg-gray-50"),children:Array.from({length:7},(h,M)=>F(o,M)).map(h=>{const M=h.getTime()===u.getTime(),L=h.getTime()>u.getTime(),te=h.getMonth()===l.getMonth();let C="text-gray-700";return m||L?C="text-gray-300":te?p&&(C="text-purple-700"):C=p?"text-purple-400":"text-gray-400",M&&(C=`font-semibold ${p?"text-purple-700":"text-purple-600"}`),s.jsx("span",{className:`flex h-7 items-center justify-center text-xs tabular-nums ${C}`,children:h.getDate()},h.getTime())})},o.getTime())})})]}),e==="month"&&s.jsx("div",{className:"grid grid-cols-3 gap-1",children:S.map((o,m)=>{const p=new Date(x,m,1),h=p.getTime()>N(u).getTime(),M=E("month",p,t),L=E("month",p,u);return s.jsx("button",{type:"button",disabled:h,onClick:()=>r(p),className:`rounded-md py-2 text-sm transition-colors ${v} `+(h?"cursor-default text-gray-300":M?"bg-purple-100 font-medium text-purple-700":L?"font-medium text-purple-600 hover:bg-gray-50":"text-gray-700 hover:bg-gray-50"),children:o},o)})}),e==="year"&&s.jsx("div",{className:"grid grid-cols-3 gap-1",children:Array.from({length:12},(o,m)=>b+m).map(o=>{const m=o>f,p=t.getFullYear()===o,h=o===f;return s.jsx("button",{type:"button",disabled:m,onClick:()=>r(new Date(o,0,1)),className:`rounded-md py-2 text-sm tabular-nums transition-colors ${v} `+(m?"cursor-default text-gray-300":p?"bg-purple-100 font-medium text-purple-700":h?"font-medium text-purple-600 hover:bg-gray-50":"text-gray-700 hover:bg-gray-50"),children:o},o)})}),s.jsx("div",{className:"mt-2 border-t border-gray-100 pt-2",children:s.jsx("button",{type:"button",disabled:T,onClick:D,className:`w-full rounded-md py-1.5 text-xs font-medium transition-colors ${v} `+(T?"cursor-default text-gray-300":"text-purple-600 hover:bg-purple-50 hover:text-purple-700"),
7children:"Go to today"})})]})}function be({granularity:e,anchor:t,onGranularityChange:r,onAnchorChange:a,compact:n=!1}){const[l,i]=y.useState(!1),x=y.useRef(null),d=E(e,t,u),b=c=>{r(c),i(!1)},w=()=>a(W(e,t,-1)),f=()=>{if(d)return;const c=W(e,t,1);a(he(e,c,u)?u:c)},g=()=>{a(u),i(!1)},j=c=>{a(c),i(!1)};y.useEffect(()=>{if(!l)return;const c=D=>{x.current&&!x.current.contains(D.target)&&i(!1)},T=D=>{D.key==="Escape"&&i(!1)};return document.addEventListener("mousedown",c),document.addEventListener("keydown",T),()=>{document.removeEventListener("mousedown",c),document.removeEventListener("keydown",T)}},[l]);const $={week:n?112:158,month:n?86:118,year:60},k=n?"h-8 w-8":"h-7 w-7";return s.jsxs("div",{ref:x,className:n?"relative w-full":"relative inline-block",children:[s.jsx("style",{children:`
8        .pp-in { animation: ppIn .12s ease-out; transform-origin: top right; }
9        @keyframes ppIn {
10          from { opacity: 0; transform: translateY(-2px) scale(.98); }
11          to   { opacity: 1; transform: none; }
12        }
13        @media (prefers-reduced-motion: reduce) { .pp-in { animation: none; } }
14      `}),s.jsxs("div",{className:"flex select-none items-center gap-0.5 rounded-lg border border-gray-200 bg-white p-1 shadow-sm "+(n?"w-full":""),children:[s.jsx(fe,{value:e,onChange:b,compact:n}),s.jsx(K,{}),s.jsxs("div",{className:"flex items-center gap-0.5 "+(n?"min-w-0 flex-1":""),children:[s.jsx("button",{type:"button","aria-label":`Previous ${e}`,onClick:w,className:_(!1,k),children:s.jsx(Q,{size:16})}),s.jsxs("button",{type:"button","aria-haspopup":"dialog","aria-expanded":l,title:"Jump to a specific date",onClick:()=>i(c=>!c),style:n?void 0:{minWidth:$[e]},className:`flex items-center justify-center gap-1.5 rounded-md px-2 py-1 text-sm font-medium text-gray-900 transition-colors hover:bg-gray-50 ${v} `+(n?"min-w-0 flex-1":""),children:[s.jsx(le,{size:14,className:"shrink-0 text-gray-400"}),s.jsx("span",{className:"truncate tabular-nums",children:xe(e,t,n)})]}),s.jsx("button",{type:"button","aria-label":`Next ${e}`,disabled:d,onClick:f,className:_(d,k),children:s.jsx(X,{size:16})})]}),!n&&s.jsxs(s.Fragment,{children:[s.jsx(K,{}),s.jsx("button",{type:"button",disabled:d,onClick:g,className:`rounded-md px-2 py-1 text-xs font-medium transition-colors ${v} `+(d?"cursor-default text-gray-300":"text-gray-500 hover:bg-gray-50 hover:text-gray-900"),children:"Today"})]})]}),l&&s.jsx(ye,{granularity:e,anchor:t,onPick:j,onToday:g,compact:n},e)]})}function ve({setActiveTab:e,activeTab:t,granularity:r,anchor:a,onGranularityChange:n,onAnchorChange:l}){return s.jsxs("div",{className:"col-span-14 flex justify-between items-center mb-6",children:[s.jsx("div",{className:"flex gap-1",children:["Overview","Tasks","Focus","Website Activity"].map(i=>(G.info("Current tab:",i,"development"),i?s.jsx(ce,{setActiveTab:e,activeTab:t,tab:i,toPath:`/analytics/${i==null?void 0:i.toLowerCase().split(" ")[0]}`},i):(G.error("Tab is undefined:",i,"development"),null)))}),s.jsx(be,{granularity:r,anchor:a,onGranularityChange:n,onAnchorChange:l})]})}const V=["week","month","year"],U="analytics_active_tab",q="analytics_date_range";function we(){const[e,t]=y.useState(()=>R(U,"overview")),[r,a]=ne(),n=R(q,null),l=r.get("granularity"),i=V.includes(l)?l:V.includes(n==null?void 0:n.granularity)?n.granularity:"week",x=r.has("date")?J(r.get("date")):n!=null&&n.date?J(n.date):u,d=H(x);y.useEffect(()=>{I(U,e)},[e]),y.useEffect(()=>{I(q,{granularity:i,date:d})},[i,d]);const b=g=>{r.set("granularity",g),a(r)},w=g=>{r.set("granularity",i),r.set("date",H(g)),a(r)},f={dateRange:{granularity:i,date:d}};return s.jsxs(s.Fragment,{children:[s.jsx(ve,{setActiveTab:t,activeTab:e,granularity:i,anchor:x,onGranularityChange:b,onAnchorChange:w}),s.jsx(ae,{context:f},`${i}|${d}`)]})}const Me=re(we);export{Me as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.