1import{t as w,u as k,r,s as c,e as d,j as e,d as g,w as J,B as O}from"./index-NwEFhPA0.js";import{D as y}from"./DashboardLayout-CvdIkXwW.js";import{U as D}from"./UnlockBanner-CsTmIaMC.js";import{T as v}from"./TopUpDialog-DsYWGLcG.js";import"./panel-left-DQjPX9y2.js";import"./zap-CyU0R1qD.js";import"./plus-BNPajLMA.js";import"./coins-CRu_Omx9.js";import"./log-out-CkU8Vx_b.js";import"./usePlanLanguageSync-CeQLvXKv.js";import"./lock-Ad9P-h7W.js";import"./lock-open-n_zaxqhm.js";import"./dialog-CR40autX.js";import"./index-KFRh6O9B.js";const G=()=>{var f;const{planId:t}=w(),{t:o}=k(),[s,b]=r.useState(null),[N,I]=r.useState(!0),[S,p]=r.useState(!1),[m,u]=r.useState(!1),[l,x]=r.useState(null);r.useEffect(()=>{t&&_()},[t]);const _=async()=>{var n,a;try{const[i,j]=await Promise.all([c.from("business_plans").select("business_name, industry, is_unlocked").eq("id",t).single(),c.from("plan_sections").select("content").eq("business_plan_id",t).eq("section_type","suggested_next_steps").single()]);i.data&&b(i.data),(n=j.data)!=null&&n.content?x(JSON.parse(j.data.content)):(a=i.data)!=null&&a.is_unlocked&&h()}catch(i){console.error("Error:",i)}finally{I(!1)}},h=async()=>{var n;if(!(s!=null&&s.is_unlocked)){d.error(o("sections.purchaseRequired"));return}u(!0);try{const a=await fetch("https://jjpinfflozrxxhpzumky.supabase.co/functions/v1/generate-insights",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${((n=(await c.auth.getSession()).data.session)==null?void 0:n.access_token)??"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImpqcGluZmZsb3pyeHhocHp1bWt5Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3Njg5Njc4MTYsImV4cCI6MjA4NDU0MzgxNn0.S_61DN4qjnKDOAJa8j_aa_5jLdgANJZibdjuoIBllWE"}`},body:JSON.stringify({planId:t,type:"next_steps"})});if(!a.ok)throw new Error("Failed to generate");const i=await a.json();i.next_steps&&(x(i.next_steps),d.success(o("sections.nextSteps.generated")))}catch{d.error(o("sections.nextSteps.generateFailed"))}finally{u(!1)}};return N?e.jsx(y,{planId:t||"",children:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(g,{className:"w-8 h-8 animate-spin text-primary"})})}):e.jsxs(y,{planId:t||"",children:[e.jsx("div",{className:"mb-8",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold font-display",children:o("sections.nextSteps.title")}),e.jsx("p",{className:"text-muted-foreground",children:o("sections.nextSteps.subtitle",{name:s==null?void 0:s.business_name})})]})})}),!(s!=null&&s.is_unlocked)&&e.jsx(D,{onUnlock:()=>p(!0)}),e.jsx(v,{open:S,onOpenChange:p,planId:t}),l&&((f=l.steps)==null?void 0:f.length)>0?e.jsx("div",{className:"space-y-4",children:l.steps.map((n,a)=>e.jsxs("div",{className:"bg-yellow-50 border border-yellow-200 rounded-xl p-6",children:[e.jsx("h3",{className:"font-semibold text-lg mb-2 text-yellow-900",children:n.title}),e.jsx("p",{className:"text-yellow-800",children:n.description})]},a))}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(J,{className:"w-12 h-12 text-muted-foreground/30 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:o("sections.nextSteps.noData")}),e.jsxs(O,{onClick:h,disabled:m,children:[m?e.jsx(g,{className:"w-4 h-4 mr-2 animate-spin"}):null,o("sections.nextSteps.generate")]})]})]})};export{G 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.