1import{j as e}from"./vendor-flow-B04FTXmM.js";import{r as u}from"./vendor-charts-CNq_tRbU.js";import{p as Ue,c as He,x as Qe,s as j,au as je,C as J,e as Y,B as F,k as X,q as L,d as Ne,U as ve,V as ye,af as P,aa as ne,l as V,D as W,F as Ge,S as Se,f as Pe,g as Re,h as Fe,j as G,H as le,J as ce,K as de,N as oe,O as me,L as S,I as N,Q as Me,R as xe,a0 as Ke,ao as Ze,ab as ae,ac as Je,as as Ae,av as Ye,Z as ie,_ as Xe,aw as et}from"./index-CF-BktP0.js";import{T as tt,a as st,b as be,c as _e}from"./tabs-D6X0pIi6.js";import{T as U,a as H,b as k,c,d as Q,e as l}from"./table-DbsTj3lw.js";import{P as Ce}from"./plus-D4YFjws1.js";import{L as rt}from"./lock-DUuD2A7j.js";import{C as at}from"./crown-TyCFoszz.js";import{T as it}from"./trash-2-DpENJZW2.js";import{D as re}from"./dollar-sign-DAfOVds8.js";import{P as Te}from"./percent-BSQwT80M.js";import{S as Ie}from"./save-DMkHmkpv.js";import{L as nt}from"./layout-dashboard-BD8kre7B.js";import{W as lt}from"./wand-sparkles-Cr3BBst4.js";import"./vendor-radix-OQMYyGRC.js";import"./vendor-supabase-HpAwllmY.js";import"./vendor-framer-CsgcxaOh.js";import"./vendor-date-CyRfVvI6.js";import"./vendor-markdown-F-WMOARd.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 we=Ue("Pen",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]);function ke(i){return{id:i.id,name:i.name,platformFee:Number(i.platform_fee),billingCycle:i.billing_cycle,voiceRate:Number(i.voice_rate),workflowRate:Number(i.workflow_rate),aiScoringRate:Number(i.ai_scoring_rate),reportRate:Number(i.report_rate),markupPercent:Number(i.markup_percent),includedVoiceMinutes:i.included_voice_minutes,includedWorkflowRuns:i.included_workflow_runs,includedAiQueries:i.included_ai_queries,isDefault:i.is_default,firmSizeCategory:i.firm_size_category??"small",overageRate:Number(i.overage_rate??.25),includedMinutes:i.included_minutes??0,description:i.description,creditsIncluded:i.credits_included??0}}function ct({plan:i,open:w,onOpenChange:v,onSave:b}){const M=!i,$={id:crypto.randomUUID(),name:"",platformFee:1440,billingCycle:"monthly",voiceRate:.12,workflowRate:.02,aiScoringRate:.05,reportRate:.08,markupPercent:0,includedVoiceMinutes:1e3,includedWorkflowRuns:0,includedAiQueries:0,isDefault:!1,firmSizeCategory:"small",overageRate:.25,includedMinutes:1e3,description:"",creditsIncluded:500},[m,I]=u.useState(i??$);u.useEffect(()=>{I(i??{...$,id:crypto.randomUUID()})},[i,w]);const _=(h,A)=>I(f=>({...f,[h]:A}));return e.jsx(le,{open:w,onOpenChange:v,children:e.jsxs(ce,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[e.jsxs(de,{children:[e.jsx(oe,{children:M?"Create Plan":`Edit "${m.name}"`}),e.jsx(me,{children:"Configure pricing and rebilling rates for this plan"})]}),e.jsxs("div",{className:"space-y-5 py-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{className:"text-xs",children:"Plan Name"}),e.jsx(N,{value:m.name,onChange:h=>_("name",h.target.value),placeholder:"e.g. Starter"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(S,{className:"text-xs flex items-center gap-1.5",children:[e.jsx(re,{className:"h-3.5 w-3.5 text-primary"}),"Monthly Retainer"]}),e.jsxs("div",{className:"relative",children:[e.jsx(re,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(N,{type:"number",step:"1",min:"0",value:m.platformFee,onChange:h=>_("platformFee",+h.target.value),className:"pl-8"})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Monthly retainer including platform access and included minutes"})]}),e.jsx(P,{}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(S,{className:"text-xs flex items-center gap-1.5",children:[e.jsx(Ke,{className:"h-3.5 w-3.5 text-primary"}),"Credits Included"]}),e.jsx(N,{type:"number",min:"0",value:m.creditsIncluded,onChange:h=>_("creditsIncluded",+h.target.value)}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Credits for Workflows, AI Actions & Reports â recharged monthly"})]}),e.jsx(P,{}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{className:"text-xs",children:"Description"}),e.jsx(N,{value:m.description??"",onChange:h=>_("description",h.target.value),placeholder:"Brief plan description"})]}),e.jsx(P,{}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-xs font-semibold text-foreground mb-1 flex items-center gap-1.5",children:[e.jsx(Ze,{className:"h-3.5 w-3.5 text-primary"}),"Credit Consumption per Action"]}),e.jsx("p",{className:"text-[11px] text-muted-foreground mb-3",children:"Each action deducts credits from the sub-account balance."}),e.jsx("div",{className:"rounded-md border border-border overflow-hidden",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-muted/50",children:[e.jsx("th",{className:"text-left px-3 py-1.5 font-medium text-muted-foreground",children:"Action"}),e.jsx("th",{className:"text-right px-3 py-1.5 font-medium text-muted-foreground",children:"Credits"})]})}),e.jsxs("tbody",{className:"divide-y divide-border",children:[e.jsxs("tr",{children:[e.jsxs("td",{className:"px-3 py-1.5 flex items-center gap-1.5",children:[e.jsx(ae,{className:"h-3 w-3 text-muted-foreground"}),"Workflow Execution"]}),e.jsx("td",{className:"px-3 py-1.5 text-right font-medium",children:"1"})]}),e.jsxs("tr",{children:[e.jsxs("td",{className:"px-3 py-1.5 flex items-center gap-1.5",children:[e.jsx(Je,{className:"h-3 w-3 text-muted-foreground"}),"AI Scoring"]}),e.jsx("td",{className:"px-3 py-1.5 text-right font-medium",children:"1"})]}),e.jsxs("tr",{children:[e.jsxs("td",{className:"px-3 py-1.5 flex items-center gap-1.5",children:[e.jsx(Ae,{className:"h-3 w-3 text-muted-foreground"}),"Report Sent"]}),e.jsx("td",{className:"px-3 py-1.5 text-right font-medium",children:"1"})]}),e.jsxs("tr",{children:[e.jsxs("td",{className:"px-3 py-1.5 flex items-center gap-1.5",children:[e.jsx(Ye,{className:"h-3 w-3 text-muted-foreground"}),"SMS Sent"]}),e.jsx("td",{className:"px-3 py-1.5 text-right font-medium",children:"1"})]}),e.jsxs("tr",{children:[e.jsxs("td",{className:"px-3 py-1.5 flex items-center gap-1.5",children:[e.jsx(ne,{className:"h-3 w-3 text-muted-foreground"}),"Voice AI (per minute)"]}),e.jsx("td",{className:"px-3 py-1.5 text-right font-medium",children:"1"})]}),e.jsx("tr",{className:"bg-muted/30",children:e.jsxs("td",{className:"px-3 py-1.5",colSpan:2,children:[e.jsxs("p",{className:"flex items-center gap-1.5 font-medium mb-1",children:[e.jsx(ie,{className:"h-3 w-3 text-muted-foreground"}),"AI Scoring (by transcript length)"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-0.5 text-[10px] text-muted-foreground ml-4",children:[e.jsx("span",{children:"0â4,500 chars (~0â5 min)"}),e.jsx("span",{className:"text-right font-medium text-foreground",children:"1 credit"}),e.jsx("span",{children:"4,501â18,000 chars (~5â20 min)"}),e.jsx("span",{className:"text-right font-medium text-foreground",children:"2 credits"}),e.jsx("span",{children:"18,001â27,000 chars (~20â30 min)"}),e.jsx("span",{className:"text-right font-medium text-foreground",children:"3 credits"}),e.jsx("span",{children:"27,001+ chars (~30+ min)"}),e.jsx("span",{className:"text-right font-medium text-foreground",children:"4 credits"})]})]})})]})]})})]}),e.jsx(P,{}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(S,{className:"text-xs flex items-center gap-1.5",children:[e.jsx(Te,{className:"h-3.5 w-3.5 text-primary"}),"Credit Price Override (per credit)"]}),e.jsxs("div",{className:"relative",children:[e.jsx(re,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3 w-3 text-muted-foreground"}),e.jsx(N,{type:"number",step:"0.01",min:"0",value:m.markupPercent>0?(.25*(1+m.markupPercent/100)).toFixed(3):"0.25",onChange:h=>{const A=+h.target.value,f=A>0?Math.round((A/.25-1)*100):0;_("markupPercent",Math.max(0,f))},className:"pl-7"})]}),e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Base cost: $0.25/credit. Current markup: ",m.markupPercent,"% â billed at $",(.25*(1+m.markupPercent/100)).toFixed(3),"/credit."]})]}),e.jsxs("div",{className:"flex items-center justify-between py-1",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Default Plan"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Auto-assign to new sub-accounts"})]}),e.jsx(Me,{checked:m.isDefault,onCheckedChange:h=>_("isDefault",h)})]})]}),e.jsxs(xe,{children:[e.jsx(F,{variant:"outline",onClick:()=>v(!1),children:"Cancel"}),e.jsxs(F,{onClick:()=>{b(m),v(!1)},disabled:!m.name.trim(),className:"gap-1.5",children:[e.jsx(Ie,{className:"h-3.5 w-3.5"}),M?"Create Plan":"Save Changes"]})]})]})})}function Mt(){var ge,fe;const{toast:i}=He(),{assignedFirms:w,isSuperAdmin:v}=Qe(),[b,M]=u.useState([]),[$,m]=u.useState(!0),[I,_]=u.useState(null),[h,A]=u.useState(!1),[f,r]=u.useState(null);u.useState(200),u.useState(!1);const[o,g]=u.useState([]),[y,T]=u.useState(!1),[D,K]=u.useState(!1),[O,ee]=u.useState(null),[ue,pe]=u.useState(null),te={name:"",ke
6y:"",monthly_price:"",minutes_included:"",overage_rate:"",minutes_rollover:!1,description:""},[E,R]=u.useState(te),se=async()=>{const{data:t}=await j.from("minute_plans").select("*").eq("is_active",!0).order("sort_order",{ascending:!0});t&&g(t)},De=async()=>{var n;const t=E;if(!t.name.trim()){i({title:"Name required",variant:"destructive"});return}const s=parseFloat(t.monthly_price||"0");if(!s||s<=0){i({title:"Monthly price required",variant:"destructive"});return}const a=parseInt(t.minutes_included||"0",10);if(!a||a<=0){i({title:"Minutes included required",variant:"destructive"});return}K(!0);try{const d={name:t.name.trim(),price_monthly_usd:s,minutes_included:a,overage_rate_usd:parseFloat(t.overage_rate||"0"),minutes_rollover:t.minutes_rollover,description:t.description.trim()||null};let p;if(O)p=await j.functions.invoke("manage-custom-minute-plan",{body:{plan_id:O,action:"update",...d}});else{const x=(t.key||t.name).trim().toLowerCase().replace(/[^a-z0-9-]+/g,"-");p=await j.functions.invoke("manage-custom-minute-plan",{body:{action:"create",key:x,...d}})}if(p.error)throw p.error;if((n=p.data)!=null&&n.error)throw new Error(p.data.error);i({title:O?"Plan updated":"Custom plan created",description:`${t.name} is synced with Stripe.`}),T(!1),ee(null),R(te),await se()}catch(d){i({title:O?"Failed to update plan":"Failed to create plan",description:d.message,variant:"destructive"})}finally{K(!1)}},Oe=t=>{ee(t.id),R({name:t.name??"",key:t.key??"",monthly_price:(t.price_monthly_usd??0).toString(),minutes_included:String(t.minutes_included??0),overage_rate:(t.overage_rate_usd??0).toString(),minutes_rollover:!!t.minutes_rollover,description:t.description??""}),T(!0)},Ee=async t=>{if(confirm("Delete this custom plan? It will be archived in Stripe and hidden from sub-accounts.")){pe(t);try{const{data:s,error:a}=await j.functions.invoke("manage-custom-minute-plan",{body:{plan_id:t,action:"delete"}});if(a)throw a;if(s!=null&&s.error)throw new Error(s.error);i({title:"Custom plan deleted"}),await se()}catch(s){i({title:"Failed to delete",description:s.message,variant:"destructive"})}finally{pe(null)}}};u.useEffect(()=>{(async()=>await se())()},[]),u.useEffect(()=>{(async()=>{const{data:t}=await j.from("plan_templates").select("*").order("platform_fee",{ascending:!0});t&&M(t.map(ke)),m(!1)})()},[]);const[z,Z]=u.useState([]);u.useEffect(()=>{(async()=>{const{data:t}=await j.from("plan_assignments").select("*");t&&Z(t)})()},[]);const B=u.useMemo(()=>w.map(t=>{const s=z.find(a=>a.firm_id===t.id);return{firmId:t.id,firmName:t.name,planId:(s==null?void 0:s.plan_template_id)??null,customOverrides:{platformFee:(s==null?void 0:s.custom_platform_fee)??void 0,voiceRate:(s==null?void 0:s.custom_voice_rate)??void 0,workflowRate:(s==null?void 0:s.custom_workflow_rate)??void 0,aiScoringRate:(s==null?void 0:s.custom_ai_scoring_rate)??void 0,reportRate:(s==null?void 0:s.custom_report_rate)??void 0,markupPercent:(s==null?void 0:s.custom_markup_percent)??void 0,voiceTier1Credits:(s==null?void 0:s.custom_voice_tier1_credits)??void 0,voiceTier2Credits:(s==null?void 0:s.custom_voice_tier2_credits)??void 0,voiceTier3Credits:(s==null?void 0:s.custom_voice_tier3_credits)??void 0,voiceTier4Credits:(s==null?void 0:s.custom_voice_tier4_credits)??void 0,agentPerMinuteCredits:(s==null?void 0:s.custom_agent_per_minute_credits)??void 0}}}),[w,z]),$e=async t=>{const s={name:t.name,platform_fee:t.platformFee,billing_cycle:t.billingCycle,voice_rate:t.voiceRate,workflow_rate:t.workflowRate,ai_scoring_rate:t.aiScoringRate,report_rate:t.reportRate,markup_percent:t.markupPercent,included_voice_minutes:t.includedVoiceMinutes,included_workflow_runs:t.includedWorkflowRuns,included_ai_queries:t.includedAiQueries,is_default:t.isDefault,firm_size_category:t.firmSizeCategory,overage_rate:t.overageRate,included_minutes:t.includedMinutes,description:t.description,credits_included:t.creditsIncluded};if(b.find(d=>d.id===t.id)){const{error:d}=await j.from("plan_templates").update(s).eq("id",t.id);if(d){i({title:"Error saving",description:d.message,variant:"destructive"});return}}else{s.id=t.id;const{error:d}=await j.from("plan_templates").insert(s);if(d){i({title:"Error creating",description:d.message,variant:"destructive"});return}}const{data:n}=await j.from("plan_templates").select("*").order("platform_fee",{ascending:!0});n&&M(n.map(ke)),i({title:"Plan saved",description:`"${t.name}" has been updated.`})},[Le,he]=u.useState(null),ze=async(t,s)=>{var a;if(!s||s==="none"){z.find(p=>p.firm_id===t)&&await j.from("plan_assignments").update({plan_template_id:null}).eq("firm_id",t);const{data:d}=await j.from("plan_assignments").select("*");d&&Z(d),i({title:"Plan removed"});return}he(t);try{const{data:n,error:d}=await j.functions.invoke("manage-subscription",{body:{action:"assign",firm_id:t,plan_template_id:s}});if(d)throw d;if(n!=null&&n.error)throw new Error(n.error);const{data:p}=await j.from("plan_assignments").select("*");p&&Z(p),i({title:"Plan assigned & Stripe subscription "+(n.action==="updated"?"updated":"created"),description:`Subscription ID: ${(a=n.subscription_id)==null?void 0:a.slice(0,20)}...`})}catch(n){i({title:"Failed to assign plan",description:n.message,variant:"destructive"}),console.error("Stripe assignment error:",n)}finally{he(null)}},Be=async(t,s)=>{const a={custom_platform_fee:s.platformFee??null,custom_voice_rate:s.voiceRate??null,custom_workflow_rate:s.workflowRate??null,custom_ai_scoring_rate:s.aiScoringRate??null,custom_report_rate:s.reportRate??null,custom_markup_percent:s.markupPercent??null,custom_voice_tier1_credits:s.voiceTier1Credits??null,custom_voice_tier2_credits:s.voiceTier2Credits??null,custom_voice_tier3_credits:s.voiceTier3Credits??null,custom_voice_tier4_credits:s.voiceTier4Credits??null,custom_agent_per_minute_credits:s.agentPerMinuteCredits??null};try{if(z.find(x=>x.firm_id===t)){const{error:x}=await j.from("plan_assignments").update(a).eq("firm_id",t);if(x)throw x}else{const{error:x}=await j.from("plan_assignments").insert({firm_id:t,...a});if(x)throw x}const{data:d,error:p}=await j.from("plan_assignments").select("*");if(p)throw p;d&&Z(d),r(null),i({title:"Custom pricing saved",description:"Overrides are now active for this sub-account."})}catch(n){console.error("Override save error:",n),i({title:"Failed to save overrides",description:n.message,variant:"destructive"})}},Ve=t=>{const s=B.find(p=>p.firmId===t),a=b.find(p=>p.id===(s==null?void 0:s.planId)),n=(s==null?void 0:s.customOverrides)??{},d=1+(n.markupPercent??(a==null?void 0:a.markupPercent)??0)/100;return{platformFee:n.platformFee??(a==null?void 0:a.platformFee)??0,voiceRate:(n.voiceRate??(a==null?void 0:a.voiceRate)??0)*d,workflowRate:(n.workflowRate??(a==null?void 0:a.workflowRate)??0)*d,aiScoringRate:(n.aiScoringRate??(a==null?void 0:a.aiScoringRate)??0)*d,reportRate:(n.reportRate??(a==null?void 0:a.reportRate)??0)*d,includedMinutes:(a==null?void 0:a.includedMinutes)??0,markupPercent:n.markupPercent??(a==null?void 0:a.markupPercent)??0,rawVoiceRate:n.voiceRate??(a==null?void 0:a.voiceRate)??0,rawWorkflowRate:n.workflowRate??(a==null?void 0:a.workflowRate)??0,rawAiScoringRate:n.aiScoringRate??(a==null?void 0:a.aiScoringRate)??0,rawReportRate:n.reportRate??(a==null?void 0:a.reportRate)??0}};return $?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):e.jsxs("div",{className:"space-y-6 max-w-6xl mx-auto",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(je,{className:"h-6 w-6 text-primary"}),e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Plans & Pricing"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Minute-based subscription plans for all sub-accounts"})]})}),e.jsxs(tt,{defaultValue:"plans",children:[e.jsxs(st,{children:[e.jsx(be,{value:"plans",children:"Plans"}),e.jsx(be,{value:"assignments",children:"Sub-Account Plans"})]}),e.jsxs(_e,{value:"plans",className:"mt-4 space-y-4",children:[e.jsx(J,{className:"border-primary/20 bg-primary/5",children:e.jsx(Y,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"These are the minute-based subscription plans available to all sub-accounts. Each plan includes a monthly allotment of voice minutes; usage beyond the allotment is billed at the plan's overage rate per minute."}),e.jsxs(F,{size:"sm",className:"gap-1.5 shrink-0",onClick:()=>T(!0),children:[e.jsx(Ce,{className:"h-3.5 w-3.5"})," Create custom plan"]})]})})}),o.length===0?e.jsx(J,{children:e.jsxs(Y,{className:"py-12 text-center text-sm text-muted-foreground",children:[e.jsx(X,{className:"h-5 w-5 animate-spin mx-auto mb-2"}),"Loading plansâ¦"]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5 ga
6p-4",children:o.map(t=>{const s=!!t.is_custom,a=t.key==="growth";return e.jsxs(J,{className:L("relative overflow-hidden transition-shadow hover:shadow-md flex flex-col",a&&"ring-2 ring-primary"),children:[a&&e.jsx("div",{className:"absolute top-0 right-0 bg-primary text-primary-foreground text-[10px] font-semibold px-2 py-0.5 rounded-bl-lg",children:"Most Popular"}),s&&e.jsxs("div",{className:"absolute top-0 left-0 bg-amber-500/15 text-amber-600 text-[10px] font-semibold px-2 py-0.5 rounded-br-lg flex items-center gap-1",children:[e.jsx(rt,{className:"h-2.5 w-2.5"})," Agency only"]}),e.jsxs(Ne,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[s?e.jsx(at,{className:"h-4 w-4 text-primary"}):e.jsx(je,{className:"h-4 w-4 text-primary"}),e.jsx(ve,{className:"text-lg",children:t.name})]}),e.jsx(ye,{className:"text-xs",children:t.key})]}),e.jsxs(Y,{className:"space-y-4 flex-1 flex flex-col",children:[e.jsxs("div",{className:"flex items-baseline gap-1",children:[e.jsxs("span",{className:"text-3xl font-bold text-foreground",children:["$",Number(t.price_monthly_usd).toFixed(0)]}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"/mo"})]}),e.jsx(P,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm text-muted-foreground flex items-center gap-1.5",children:[e.jsx(ne,{className:"h-3.5 w-3.5"})," Minutes"]}),e.jsxs("span",{className:"text-sm font-semibold",children:[Number(t.minutes_included).toLocaleString()," / mo"]})]}),e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Overage"}),e.jsxs("span",{className:"text-sm font-bold text-foreground",children:["$",Number(t.overage_rate_usd).toFixed(2),e.jsx("span",{className:"text-[10px] text-muted-foreground font-normal",children:" /min"})]})]}),t.minutes_rollover&&e.jsx("p",{className:"text-[10px] text-muted-foreground/80 leading-snug",children:"Unused minutes roll over to the next cycle."})]}),e.jsx(P,{}),e.jsx("div",{className:"space-y-1 flex-1",children:[`${Number(t.minutes_included).toLocaleString()} voice minutes / month`,"All platform features unlocked","Cancel anytime","Monthly billing via Stripe"].map(n=>e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(V,{className:"h-3 w-3 text-primary shrink-0"}),n]},n))}),e.jsx("div",{className:"pt-2 border-t border-border",children:t.stripe_price_id?e.jsxs(W,{className:"text-[10px] bg-green-500/10 text-green-600 border-green-500/30 hover:bg-green-500/20",children:[e.jsx(V,{className:"h-2.5 w-2.5 mr-1"})," Stripe connected"]}):e.jsx("span",{className:"text-[10px] text-amber-600",children:"Stripe price not set"})}),s&&e.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[e.jsxs(F,{size:"sm",variant:"outline",className:"h-7 gap-1 text-xs flex-1",onClick:()=>Oe(t),children:[e.jsx(we,{className:"h-3 w-3"})," Edit"]}),e.jsx(F,{size:"sm",variant:"outline",className:"h-7 gap-1 text-xs text-destructive hover:text-destructive",disabled:ue===t.id,onClick:()=>Ee(t.id),children:ue===t.id?e.jsx(X,{className:"h-3 w-3 animate-spin"}):e.jsx(it,{className:"h-3 w-3"})})]})]})]},t.id)})})]}),e.jsx(_e,{value:"assignments",className:"mt-4",children:e.jsxs(J,{children:[e.jsxs(Ne,{children:[e.jsx(ve,{className:"text-base",children:"Sub-Account Plan Assignments"}),e.jsx(ye,{children:"Assign plans and set custom rebilling overrides per sub-account"})]}),e.jsx(Y,{className:"p-0",children:e.jsxs(U,{children:[e.jsx(H,{children:e.jsxs(k,{children:[e.jsx(c,{children:"Sub-Account"}),e.jsx(c,{children:"Assigned Plan"}),e.jsx(c,{children:"Monthly Fee"}),e.jsx(c,{children:"Credits"}),e.jsx(c,{className:"text-center",children:"Stripe Status"}),e.jsx(c,{className:"text-center",children:"Overrides"}),e.jsx(c,{className:"text-right",children:"Actions"})]})}),e.jsx(Q,{children:B.length===0?e.jsx(k,{children:e.jsx(l,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"No sub-accounts found"})}):B.map(t=>{var p;const s=b.find(x=>x.id===t.planId),a=Ve(t.firmId),n=Object.keys(t.customOverrides).length>0,d=w.find(x=>x.id===t.firmId);return e.jsxs(k,{children:[e.jsx(l,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-8 w-8 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(Ge,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:(d==null?void 0:d.name)??t.firmName}),n&&e.jsxs(W,{variant:"outline",className:"text-[10px] gap-1 text-primary border-primary/30 mt-0.5",children:[e.jsx(V,{className:"h-2.5 w-2.5"})," Custom Rates"]})]})]})}),e.jsx(l,{children:e.jsxs(Se,{value:t.planId??"none",onValueChange:x=>ze(t.firmId,x==="none"?"":x),children:[e.jsx(Pe,{className:"w-[160px] h-8 text-sm",children:e.jsx(Re,{placeholder:"No plan"})}),e.jsxs(Fe,{children:[e.jsx(G,{value:"none",children:"No Plan"}),b.map(x=>
6e.jsxs(G,{value:x.id,children:[x.name," (",x.firmSizeCategory==="small"?"SM":x.firmSizeCategory==="medium"?"MD":"ENT",")"]},x.id))]})]})}),e.jsx(l,{children:e.jsxs("span",{className:"text-sm font-semibold",children:["$",a.platformFee.toLocaleString(),"/mo"]})}),e.jsx(l,{children:e.jsx("span",{className:"text-sm",children:((p=s==null?void 0:s.creditsIncluded)==null?void 0:p.toLocaleString())??"0"})}),e.jsx(l,{className:"text-center",children:(()=>{const x=z.find(We=>We.firm_id===t.firmId),qe=x==null?void 0:x.stripe_subscription_id;return Le===t.firmId?e.jsx(X,{className:"h-4 w-4 animate-spin mx-auto text-muted-foreground"}):qe?e.jsxs(W,{className:"text-[10px] bg-green-500/10 text-green-600 border-green-500/30 hover:bg-green-500/20",children:[e.jsx(V,{className:"h-2.5 w-2.5 mr-1"})," Active"]}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"Not billed"})})()}),e.jsx(l,{className:"text-center",children:n?e.jsxs(W,{variant:"outline",className:"text-[11px] gap-1 text-primary border-primary/30",children:[e.jsx(V,{className:"h-3 w-3"})," Active"]}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"â"})}),e.jsx(l,{className:"text-right",children:e.jsxs(F,{variant:"ghost",size:"sm",className:"gap-1 text-xs",onClick:()=>r(t.firmId),children:[e.jsx(we,{className:"h-3 w-3"})," Override"]})})]},t.firmId)})})]})})]})})]}),e.jsx(ct,{plan:I,open:h,onOpenChange:A,onSave:$e}),f&&e.jsx(ot,{firmId:f,firmName:((ge=w.find(t=>t.id===f))==null?void 0:ge.name)??"",basePlan:b.find(t=>{var s;return t.id===((s=B.find(a=>a.firmId===f))==null?void 0:s.planId)})??null,currentOverrides:((fe=B.find(t=>t.firmId===f))==null?void 0:fe.customOverrides)??{},onSave:t=>Be(f,t),onClose:()=>r(null)}),e.jsx(le,{open:y,onOpenChange:t=>{T(t),t||(ee(null),R(te))},children:e.jsxs(ce,{className:"max-w-md",children:[e.jsxs(de,{children:[e.jsx(oe,{children:O?"Edit custom plan":"Create custom plan"}),e.jsx(me,{children:O?"Updates the minute plan and syncs changes to Stripe (price changes create a new Stripe price).":"Creates a Stripe product + price and a hidden minute plan visible only inside the agency view."})]}),e.jsxs("div",{className:"space-y-3 py-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{className:"text-xs",children:"Plan name"}),e.jsx(N,{value:E.name,onChange:t=>R(s=>({...s,name:t.target.value})),placeholder:"e.g. Acme Custom"})]}),!O&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{className:"text-xs",children:"Key (optional)"}),e.jsx(N,{value:E.key,onChange:t=>R(s=>({...s,key:t.target.value})),placeholder:"auto-generated from name"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{className:"text-xs",children:"Monthly price ($)"}),e.jsx(N,{type:"number",min:"0",step:"0.01",value:E.monthly_price,onChange:t=>R(s=>({...s,monthly_price:t.target.value})),placeholder:"299"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{className:"text-xs",children:"Minutes included / mo"}),e.jsx(N,{type:"number",min:"0",value:E.minutes_included,onChange:t=>R(s=>({...s,minutes_included:t.target.value})),placeholder:"1000"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{className:"text-xs",children:"Overage rate ($ / minute)"}),e.jsx(N,{type:"number",min:"0",step:"0.01",value:E.overage_rate,onChange:t=>R(s=>({...s,overage_rate:t.target.value})),placeholder:"0.25"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{className:"text-xs",children:"Description (optional)"}),e.jsx(N,{value:E.description,onChange:t=>R(s=>({...s,description:t.target.value})),placeholder:"Brief plan description"})]}),e.jsxs("div",{className:"flex items-center justify-between py-1",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Minutes rollover"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Unused minutes carry into the next cycle"})]}),e.jsx(Me,{checked:E.minutes_rollover,onCheckedChange:t=>R(s=>({...s,minutes_rollover:t}))})]})]}),e.jsxs(xe,{children:[e.jsx(F,{variant:"outline",onClick:()=>T(!1),disabled:D,children:"Cancel"}),e.jsxs(F,{onClick:De,disabled:D,className:"gap-1.5",children:[D?e.jsx(X,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Ce,{className:"h-3.5 w-3.5"}),O?"Save changes":"Create plan"]})]})]})})]})}const C={voiceTier1:{label:"⤠4,500 chars (~0â5 min)",internalCost:.011,defaultCredits:1}
6,voiceTier2:{label:"4,501â18,000 chars (~5â20 min)",internalCost:.016,defaultCredits:2},voiceTier3:{label:"18,001â27,000 chars (~20â30 min)",internalCost:.019,defaultCredits:3},voiceTier4:{label:"27,001+ chars (~30+ min)",internalCost:.021,defaultCredits:4},agentPerMinute:{label:"Agent Per Minute",internalCost:.14,defaultCredits:1},workflow:{label:"Workflow Execution",internalCost:.001,defaultCredits:.5},aiScoring:{label:"AI Scoring",internalCost:.005,defaultCredits:1},report:{label:"Report Generation",internalCost:.003,defaultCredits:1},promptFix:{label:"Prompt Fix (single)",internalCost:.015,defaultCredits:1},promptOptimize:{label:"A/B Prompt Optimization",internalCost:.045,defaultCredits:2},promptSimulation:{label:"Prompt Simulation (per run)",internalCost:.04,defaultCredits:1}},dt=.25;function q(i,w){const v=w*dt;if(v<=0)return{revenue:v,profit:-i,marginPct:-100};const b=v-i,M=b/v*100;return{revenue:v,profit:b,marginPct:M}}function ot({firmId:i,firmName:w,basePlan:v,currentOverrides:b,onSave:M,onClose:$}){const[m,I]=u.useState(b),_=(r,o)=>{I(g=>{if(o===""){const y={...g};return delete y[r],y}return{...g,[r]:+o}})},h=[{key:"voiceTier1Credits",cost:C.voiceTier1},{key:"voiceTier2Credits",cost:C.voiceTier2},{key:"voiceTier3Credits",cost:C.voiceTier3},{key:"voiceTier4Credits",cost:C.voiceTier4}],A=[{key:"workflowRate",cost:C.workflow,icon:ae,label:"Workflow"},{key:"reportRate",cost:C.report,icon:Ae,label:"Report"}],f=({marginPct:r})=>e.jsxs(W,{variant:"outline",className:L("text-[10px] font-mono px-1.5 py-0",r>=90?"border-emerald-500/40 text-emerald-600 bg-emerald-50 dark:bg-emerald-950/30 dark:text-emerald-400":r>=70?"border-green-500/40 text-green-600 bg-green-50 dark:bg-green-950/30 dark:text-green-400":r>=50?"border-yellow-500/40 text-yellow-600 bg-yellow-50 dark:bg-yellow-950/30 dark:text-yellow-400":r>=0?"border-orange-500/40 text-orange-600 bg-orange-50 dark:bg-orange-950/30 dark:text-orange-400":"border-red-500/40 text-red-600 bg-red-50 dark:bg-red-950/30 dark:text-red-400"),children:[r>=0?"+":"",r.toFixed(0),"%"]});return e.jsx(le,{open:!0,onOpenChange:()=>$(),children:e.jsxs(ce,{className:"max-w-2xl max-h-[90vh]",children:[e.jsxs(de,{children:[e.jsxs(oe,{className:"flex items-center gap-2",children:[e.jsx(Xe,{className:"h-5 w-5 text-primary"}),"Credit Rates & Margins: ",w]}),e.jsx(me,{children:"Override credit costs per action. Internal costs, revenue, and profit margins are shown for each line."})]}),e.jsxs("div",{className:"space-y-5 py-2 max-h-[60vh] overflow-y-auto pr-1",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(nt,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:"Monthly Plan"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Select a Pro tier credit allocation"})]}),e.jsxs(Se,{value:m.platformFee!=null?String(m.platformFee):"default",onValueChange:r=>{I(r==="default"?o=>{const g={...o};return delete g.platformFee,g}:o=>({...o,platformFee:+r}))},children:[e.jsx(Pe,{className:"h-8 w-[180px] text-sm",children:e.jsx(Re,{placeholder:"Plan default"})}),e.jsxs(Fe,{children:[e.jsx(G,{value:"default",className:"text-sm",children:"Plan default"}),e.jsx(G,{value:"0",className:"text-sm",children:"PAYG â 0 credits"}),et.map(r=>e.jsxs(G,{value:String(r.credits),className:"text-sm",children:[r.label," â $",r.pricePerMonth,"/mo"]},r.credits))]})]})]}),e.jsx(P,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ne,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"AI Scoring (Transcript)"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Gemini AI analysis of call transcripts â charged per
6call by character count"})]})]}),e.jsx("div",{className:"rounded-lg border overflow-hidden",children:e.jsxs(U,{children:[e.jsx(H,{children:e.jsxs(k,{className:"text-[11px]",children:[e.jsx(c,{className:"py-1.5 text-[11px]",children:"Tier"}),e.jsx(c,{className:"py-1.5 text-[11px] text-right",children:"Internal $"}),e.jsx(c,{className:"py-1.5 text-[11px] text-right w-[90px]",children:"Credits"}),e.jsx(c,{className:"py-1.5 text-[11px] text-right",children:"Revenue"}),e.jsx(c,{className:"py-1.5 text-[11px] text-right",children:"Profit"}),e.jsx(c,{className:"py-1.5 text-[11px] text-right",children:"Margin"})]})}),e.jsx(Q,{children:h.map(({key:r,cost:o})=>{const g=m[r]??o.defaultCredits,y=q(o.internalCost,g);return e.jsxs(k,{className:"text-xs",children:[e.jsx(l,{className:"py-1.5 text-[11px] text-muted-foreground max-w-[180px]",children:o.label}),e.jsxs(l,{className:"py-1.5 text-right font-mono text-[11px] text-muted-foreground",children:["$",o.internalCost.toFixed(3)]}),e.jsx(l,{className:"py-1.5 text-right",children:e.jsx(N,{type:"number",step:"0.1",min:"0",placeholder:String(o.defaultCredits),value:m[r]??"",onChange:T=>_(r,T.target.value),className:"h-6 w-[70px] text-[11px] text-right ml-auto"})}),e.jsxs(l,{className:"py-1.5 text-right font-mono text-[11px]",children:["$",y.revenue.toFixed(3)]}),e.jsxs(l,{className:L("py-1.5 text-right font-mono text-[11px]",y.profit>=0?"text-emerald-600 dark:text-emerald-400":"text-red-500"),children:["$",y.profit.toFixed(3)]}),e.jsx(l,{className:"py-1.5 text-right",children:e.jsx(f,{marginPct:y.marginPct})})]},r)})})]})})]}),e.jsx(P,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ie,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Agent Per Minute"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Visionair telephony cost for follow-up agent calls â separate from transcript analysis"})]})]}),e.jsx("div",{className:"rounded-lg border overflow-hidden",children:e.jsxs(U,{children:[e.jsx(H,{children:e.jsxs(k,{className:"text-[11px]",children:[e.jsx(c,{className:"py-1.5 text-[11px]",children:"Action"}),e.jsx(c,{className:"py-1.5 text-[11px] text-right",children:"Internal $"}),e.jsx(c,{className:"py-1.5 text-[11px] text-right w-[90px]",children:"Credits/min"}),e.jsx(c,{className:"py-1.5 text-[11px] text-right",children:"Revenue/min"}),e.jsx(c,{className:"py-1.5 text-[11px] text-right",children:"Profit/min"}),e.jsx(c,{className:"py-1.5 text-[11px] text-right",children:"Margin"})]})}),e.jsx(Q,{children:(()=>{const r=C.agentPerMinute,o=m.agentPerMinuteCredits??r.defaultCredits,g=q(r.internalCost,o);return e.jsxs(k,{className:"text-xs",children:[e.jsx(l,{className:"py-1.5",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(ie,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-[11px]",children:r.label})]})}),e.jsxs(l,{className:"py-1.5 text-right font-mono text-[11px] text-muted-foreground",children:["$",r.internalCost.toFixed(3)]}),e.jsx(l,{className:"py-1.5 text-right",children:e.jsx(N,{type:"number",step:"0.1",min:"0",placeholder:String(r.defaultCredits),value:m.agentPerMinuteCredits??"",onChange:y=>_("agentPerMinuteCredits",y.target.value),className:"h-6 w-[70px] text-[11px] text-right ml-auto"})}),e.jsxs(l,{className:"py-1.5 text-right font-mono text-[11px]",children:["$",g.revenue.toFixed(3)]}),e.jsxs(l,{className:L("py-1.5 text-right font-mono text-[11px]",g.profit>=0?"text-emerald-600 dark:text-emerald-400":"text-red-500"),children:["$",g.profit.toFixed(3)]}),e.jsx(l,{className:"py-1.5 text-right",children:e.jsx(f,{marginPct:g.marginPct})})]})})()})]})})]}),e.jsx(P,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ae,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("p",{className:"text-sm font-medium",children:"Action Costs"})]}),e.jsx("div",{className:"rounded-lg border overflow-hidden",children:e.jsxs(U,{children:[e.jsx(H,{children:e.jsxs(k,{className:"text-[11px]",children:[e.jsx(c,{className:"py-1.5 text-[11px]",children:"Action"}),e.jsx(c,{className:"py-1.5 text-[11px] text-right",children:"Internal $"}),e.jsx(c,{className:"py-1.5 text-[11px] text-right w-[90px]",children:"Credits"}),e.jsx(c,{className:"py-1.5 text-[11px] text-right",children:"Revenue"}),e.jsx(c,{className:"py-1.5 text-[11px] text-right",children:"Profit"}),e.jsx(c,{className:"py-1.5 text-[11px] text-right",children:"Margin"})]})}),e.jsx(Q,{children:A.map(({key:r,cost:o,icon:g,label:y})=>{const T=m[r]??o.defaultCredits,D=q(o.internalCost,T);return e.jsxs(k,{className:"text-xs",children:[e.jsx(l,{className:"py-1.5",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(g,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-[11px]",children:y})]})}),e.jsxs(l,{className:"py-1.5 text-right font-mono text-[11px] text-muted-foreground",children:["$",o.internalCost.toFixed(3)]}),e.jsx(l,{className:"py-1.5 text-right",children:e.jsx(N,{type:"number",step:"0.01",min:"0",placeholder:String(o.defaultCredits),value:m[r]??"",onChange:K=>_(r,K.target.value),className:"h-6 w-[70px] text-[11px] text-right ml-auto"})}),e.jsxs(l,{className:"py-1.5 text-right font-mono text-[11px]",children:["$",D.revenue.toFixed(3)]}),e.jsxs(l,{className:L("py-1.5 text-right font-mono text-[11px]",D.profit>=0?"text-emerald-600 dark:text-emerald-400":"text-red-500"),children:["$",D.profit.toFixed(3)]}),e.jsx(l,{className:"py-1.5 text-right",children:e.jsx(f,{marginPct:D.marginPct})})]},r)})})]})})]}),e.jsx(P,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(lt,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"AI Optimization"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Flag-driven prompt fixes & A/B testing â fixed credit costs, charged each invocation (incl. re-runs)"})]})]}),e.jsx("div",{className:"rounded-lg border overflow-hidden",children:e.jsxs(U,{children:[e.jsx(H,{children:e.jsxs(k,{className:"text-[11px]",children:[e.jsx(c,{className:"py-1.5 text-[11px]",children:"Action"}),e.jsx(c,{className:"py-1.5 text-[11px] text-right",children:"Internal $"}),e.jsx(c,{className:"py-1.5 text-[11px] text-right w-[90px]",children:"Credits"}),e.jsx(c,{className:"py-1.5 text-[11px] text-right",children:"Revenue"}),e.jsx(c,{className:"py-1.5 text-[11px] text-right",children:"Profit"}),e.jsx(c,{className:"py-1.5 text-[11px] text-right",children:"Margin"})]})}),e.jsx(Q,{children:[C.promptFix,C.promptOptimize,C.promptSimulation].map(r=>{const o=q(r.internalCost,r.defaultCredits);return e.jsxs(k,{className:"text-xs",children:[e.jsx(l,{className:"py-1.5 text-[11px]",children:r.label}),e.jsxs(l,{className:"py-1.5 text-right font-mono text-[11px] text-muted-foreground",children:["$",r.internalCost.toFixed(3)]}),e.jsx(l,{className:"py-1.5 text-right font-mono text-[11px]",children:r.defaultCredits}),e.jsxs(l,{className:"py-1.5 text-right font-mono text-[11px]",children:["$",o.revenue.toFixed(3)]}),e.jsxs(l,{className:L("py-1.5 text-right font-mono text-[11px]",o.profit>=0?"text-emerald-600 dark:text-emerald-400":"text-red-500"),children:["$",o.profit.toFixed(3)]}),e.jsx(l,{className:"py-1.5 text-right",children:e.jsx(f,{marginPct:o.marginPct})})]},r.label)})})]})})]}),e.jsx(P,{}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Te,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:"Additional Markup"}),e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Applied on top of all credit charges. Default: ",(v==null?void 0:v.markupPercent)??0,"%"]})]}),e.jsxs("div",{className:"relative w-[90px]",children:[e.jsx(N,{type:"number",step:"0.5",min:"0",placeholder:"â",value:m.markupPercent??"",onChange:r=>_("markupPercent",r.target.value),className:"h-8 text-sm pr-8 text-right"}),e.jsx("span",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-[11px] text-muted-foreground",children:"%"})]})]}),e.jsxs("div",{className:"rounded-lg bg-muted/50 border p-3 space-y-1.5",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Margin Summary (at $0.25/credit)"}),e.jsx("div",{className:"grid grid-cols-3 gap-2 text-[11px]",children:[...h.map(r=>({label:r.cost.label.split("(")[0].trim(),credits:m[r.key]??r.cost.defaultCredits,internalCost:r.cost.internalCost})),{label:"Agent/min",credits:m.agentPerMinuteCredits??C.agentPerMinute.defaultCredits,internalCost:C.agentPerMinute.internalCost},...A.map(r=>({label:r.label,credits:m[r.key]??r.cost.defaultCredits,internalCost:r.cost.internalCost}))].map((r,o)=>{const g=q(r.internalCost,r.credits);return e.jsxs("div",{className:"flex items-center justify-between gap-1 px-2 py-1 rounded bg-background border",children:[e.jsx("span",{className:"text-muted-foreground truncate",children:r.label}),e.jsx(f,{marginPct:g.marginPct})]},o)})})]})]}),e.jsxs(xe,{children:[e.jsx(F,{variant:"outline",onClick:$,children:"Cancel"}),e.jsxs(F,{onClick:()=>M(m),className:"gap-1.5",children:[e.jsx(Ie,{className:"h-3.5 w-3.5"})," Save Overrides"]})]})]})})}export{Mt 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.