1import{g as R,r as x,s as j,ah as I,u as T,j as e,Y as M,ax as A,n as E,L,aq as G}from"./index-Coh6kqMH.js";import{a as q}from"./score-badge-D4rSP-Of.js";import{G as H}from"./PageSkeletons-D62f-lZz.js";import{S as F}from"./SkeletonCrossfade-CkcOrCOq.js";import{u as U,E as W}from"./use-shop-data-D2UN0Ucg.js";import{A as C}from"./AiReportCta-9saihaVi.js";import{u as O}from"./ShopReportContext-DoARYpab.js";import{l as Z}from"./shop-stats-BEm1Z1hc.js";import{Z as z}from"./zap-8ZdMyzw0.js";import{T as B}from"./target-BBUQCZK1.js";import{C as S}from"./circle-x-D5Txr_in.js";import{C as K}from"./circle-check-D-LwKIWQ.js";import"./skeleton-D7aDfLY4.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const $=R("Lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]);function V(){const[a,r]=x.useState(new Set),[h,l]=x.useState(!0),[s,g]=x.useState(null);x.useEffect(()=>{let o=!1;return(async()=>{var p;const{data:m}=await j.auth.getUser(),c=((p=m.user)==null?void 0:p.id)??null;if(o)return;if(g(c),!c){l(!1);return}const{data:d,error:i}=await j.from("growth_plan_task_completions").select("task_key").eq("user_id",c);o||(!i&&d&&r(new Set(d.map(f=>f.task_key))),l(!1))})(),()=>{o=!0}},[]);const u=x.useCallback(async o=>{if(!s)return;const m=a.has(o);r(d=>{const i=new Set(d);return m?i.delete(o):i.add(o),i});const{error:c}=m?await j.from("growth_plan_task_completions").delete().eq("user_id",s).eq("task_key",o):await j.from("growth_plan_task_completions").upsert({user_id:s,task_key:o},{onConflict:"user_id,task_key"});c&&(r(d=>{const i=new Set(d);return m?i.add(o):i.delete(o),i}),I({title:"Couldn't save progress",description:c.message,variant:"destructive"}))},[s,a]);return{completed:a,toggleTask:u,loading:h}}function N({done:a,total:r}){const{t:h}=T();if(r===0)return null;const l=Math.round(a/r*100);return e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx(A,{value:l,className:"h-1.5 flex-1"}),e.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:h("growthPage.sectionProgress.completed",{done:a,total:r})})]})}function X(a){return a==="Very High"||a==="high"?"urgent":a==="High"||a==="medium"?"high":"medium"}function k({id:a,title:r,impact:h,effort:l,done:s,onToggle:g,href:u}){return e.jsxs("div",{className:`flex items-center gap-3 p-3 rounded-lg bg-muted/30 hover:bg-muted/50 transition-colors group ${s?"opacity-60":""}`,children:[e.jsx("button",{onClick:()=>g(a),className:"flex-shrink-0",children:s?e.jsx(K,{className:"w-5 h-5 text-success"}):e.jsx(E,{className:"w-5 h-5 text-muted-foreground hover:text-primary transition-colors"})}),u?e.jsx(L,{to:u,className:`text-sm flex-1 hover:text-primary transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded ${s?"line-through text-muted-foreground":""}`,children:r}):e.jsx("span",{className:`text-sm flex-1 ${s?"line-through text-muted-foreground":""}`,children:r}),u&&e.jsx(G,{className:"w-4 h-4 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity"}),e.jsx(q,{status:X(h)}),l&&e.jsx("span",{className:"text-xs text-muted-foreground hidden sm:inline",children:l})]})}function de(){const{t:a}=T(),{stats:r,loading:h}=U(),{row:l,report:s,generating:g,regenerate:u,startedAt:o,cancel:m}=O(r),{completed:c,toggleTask:d}=V(),i=x.useMemo(()=>r.detectedIssues.map(t=>`qw-${t.key}`),[r.detectedIssues]),p=x.useMemo(()=>((s==null?void 0:s.highROI)??[]).map((t,n)=>`hr-${n}`),[s]),f=x.useMemo(()=>((s==null?void 0:s.strategic)??[]).map((t,n)=>`st-${n}`),[s]),w=t=>t.filter(n=>c.has(n)).length,v=w(i),y=w(p),b=w(f),_=i.length+p.length+f.length,D=v+y+b,P=async()=>{const t=await u();t!=null&&t.error&&I({title:a("growthPage.toast.generateReportErrorTitle"),description:t.error,variant:"destructive"})};return e.jsx(F,{loading:h,skeleton:e.jsx(H,{}),children:r.hasData?e.jsxs("div",{className:"p-4 md:p-6 max-w-4xl mx-auto
6space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 flex-wrap",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:a("growthPage.heading.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a("growthPage.heading.description")}),_>0&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[e.jsx("span",{className:"font-medium text-foreground",children:D})," ",a("growthPage.heading.tasksCompletedSuffix",{totalTasks:_})]})]}),s&&e.jsx(C,{hasReport:!0,generating:g,onGenerate:P,generatedAt:l==null?void 0:l.generated_at,compact:!0,startedAt:o,onCancel:m})]}),e.jsxs("div",{className:"glass-card p-5",children:[e.jsxs("h3",{className:"font-semibold text-sm flex items-center gap-2 mb-4",children:[e.jsx(z,{className:"w-4 h-4 text-warning"})," ",a("growthPage.quickWins.title")]}),e.jsx(N,{done:v,total:i.length}),r.detectedIssues.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:a("growthPage.quickWins.noIssues")}):e.jsx("div",{className:"space-y-2",children:r.detectedIssues.map(t=>e.jsx(k,{id:`qw-${t.key}`,title:t.title,impact:t.impact,done:c.has(`qw-${t.key}`),onToggle:d,href:Z(t.key)},t.key))})]}),!s&&e.jsx(C,{hasReport:!1,generating:g,onGenerate:P,startedAt:o,onCancel:m}),s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"glass-card p-5",children:[e.jsxs("h3",{className:"font-semibold text-sm flex items-center gap-2 mb-4",children:[e.jsx(M,{className:"w-4 h-4 text-success"})," ",a("growthPage.roiFixes.title")]}),e.jsx(N,{done:y,total:p.length}),e.jsx("div",{className:"space-y-2",children:s.highROI.map((t,n)=>e.jsx(k,{id:`hr-${n}`,title:t.title,impact:t.impact,effort:t.effort,done:c.has(`hr-${n}`),onToggle:d},`hr-${n}`))})]}),e.jsxs("div",{className:"glass-card p-5",children:[e.jsxs("h3",{className:"font-semibold text-sm flex items-center gap-2 mb-4",children:[e.jsx(B,{className:"w-4 h-4 text-primary"})," ",a("growthPage.strategicImprovements.title")]}),e.jsx(N,{done:b,total:f.length}),e.jsx("div",{className:"space-y-2",children:s.strategic.map((t,n)=>e.jsx(k,{id:`st-${n}`,title:t.title,impact:t.impact,effort:t.effort,done:c.has(`st-${n}`),onToggle:d},`st-${n}`))})]}),e.jsxs("div",{className:"glass-card p-5",children:[e.jsxs("h3",{className:"font-semibold text-sm flex items-center gap-2 mb-4",children:[e.jsx($,{className:"w-4 h-4 text-accent"})," ",a("growthPage.newProductIdeas.title")]}),e.jsx("div",{className:"space-y-3",children:s.newProducts.map((t,n)=>e.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-lg bg-muted/30",children:[e.jsx($,{className:"w-4 h-4 text-accent flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-sm font-medium",children:t.title}),e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:t.rationale})]}),e.jsx(q,{status:t.confidence==="High"?"above":"medium"})]},n))})]}),e.jsxs("div",{className:"glass-card p-5",children:[e.jsxs("h3",{className:"font-semibold text-sm flex items-center gap-2 mb-4",children:[e.jsx(S,{className:"w-4 h-4 text-destructive"})," ",a("growthPage.stopDoing.title")]}),e.jsx("ul",{className:"space-y-2",children:s.stopDoing.map(t=>e.jsxs("li",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(S,{className:"w-4 h-4 text-destructive flex-shrink-0 mt-0.5"})," ",t]},t))})]})]})]}):e.jsx(W,{})})}export{de 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.