1import{c as H,y as O,r as o,j as e,B as l,q as A,e as h,P as W,Q as M,R as q,V as Q,ad as Y,I as u,ae as $,Y as G}from"./index-CdlRzbIO.js";import{C as r,a as c}from"./card-CM0Okv3Z.js";import{T as J}from"./textarea-DQY33lpu.js";import{S as E}from"./skeleton-CbzUyPBA.js";import{P as K}from"./progress-Bf01UNVF.js";import{S,a as T,b as k,c as P,d}from"./select-Bn2PV-d6.js";import{F as p}from"./flask-conical-C54X-NpF.js";import{R as X}from"./refresh-cw-DjQSYiT5.js";import{P as f}from"./plus-v05U7UbD.js";import{T as Z}from"./trending-up-CE5PUVoR.js";import{P as ee}from"./pause-DbRWmTgP.js";import{T as se}from"./trash-2-Ck4J97G1.js";import"./index-BdQq_4o_.js";import"./index-ClrCEPLH.js";import"./chevron-down-CJ0_mUBc.js";import"./chevron-up-QfggDjgX.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 D=H("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]),ae=[{id:"1",name:"Homepage Hero CTA",description:"Test different call-to-action buttons on the homepage hero section",status:"running",type:"ab_test",variants:[{id:"a",name:"Control (Blue)",allocation:50,conversions:145,views:2340},{id:"b",name:"Variant (Purple)",allocation:50,conversions:178,views:2280}],targetAudience:"all",trafficAllocation:100,startDate:"2025-01-10",endDate:null,metrics:{totalViews:4620,totalConversions:323,conversionRate:6.99,confidence:87,winner:null}},{id:"2",name:"Pricing Display Format",description:"Compare monthly vs per-reading pricing display",status:"completed",type:"ab_test",variants:[{id:"a",name:"Per Reading",allocation:50,conversions:89,views:1200},{id:"b",name:"Monthly Value",allocation:50,conversions:112,views:1180}],targetAudience:"new_users",trafficAllocation:50,startDate:"2025-01-01",endDate:"2025-01-15",metrics:{totalViews:2380,totalConversions:201,conversionRate:8.45,confidence:95,winner:"b"}}],ve=()=>{const{toast:g}
6=O(),[B,v]=o.useState(!0),[m,j]=o.useState([]),[R,x]=o.useState(!1),[N,b]=o.useState(!1),[a,i]=o.useState({name:"",description:"",type:"ab_test",targetAudience:"all",trafficAllocation:100,variantA:"Control",variantB:"Variant"});o.useEffect(()=>{w()},[]);const w=async()=>{v(!0),await new Promise(s=>setTimeout(s,500)),j(ae),v(!1)},V=s=>{switch(s){case"running":return e.jsx(h,{className:"bg-green-100 text-green-700",children:"Running"});case"paused":return e.jsx(h,{className:"bg-amber-100 text-amber-700",children:"Paused"});case"completed":return e.jsx(h,{className:"bg-blue-100 text-blue-700",children:"Completed"});default:return e.jsx(h,{variant:"secondary",children:"Draft"})}},F=s=>{j(n=>n.map(t=>{if(t.id===s){const y=t.status==="running"?"paused":"running";return{...t,status:y}}return t})),g({title:"Experiment status updated"})},_=s=>{j(n=>n.filter(t=>t.id!==s)),g({title:"Experiment deleted"})},I=async()=>{if(!a.name){g({title:"Please enter experiment name",variant:"destructive"});return}b(!0),await new Promise(n=>setTimeout(n,500));const s={id:Date.now().toString(),name:a.name,description:a.description,status:"draft",type:a.type,variants:[{id:"a",name:a.variantA,allocation:50,conversions:0,views:0},{id:"b",name:a.variantB,allocation:50,conversions:0,views:0}],targetAudience:a.targetAudience,trafficAllocation:a.trafficAllocation,startDate:null,endDate:null,metrics:{totalViews:0,totalConversions:0,conversionRate:0,confidence:0,winner:null}};j(n=>[s,...n]),x(!1),i({name:"",description:"",type:"ab_test",targetAudience:"all",trafficAllocation:100,variantA:"Control",variantB:"Variant"}),b(!1),g({title:"Experiment created"})},L=m.filter(s=>s.status==="running").length,z=m.filter(s=>s.status==="completed").length;return e.jsxs("div",{className:"space-y-6 max-w-6xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-900 flex items-center gap-2",children:[e.jsx(p,{className:"h-6 w-6 text-cyan-600"}),"A/B Testing & Experiments"]}),e.jsx("p",{className:"text-gray-500 mt-1",children:"Run experiments to optimize your platform"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(l,{onClick:w,variant:"outline",size:"sm",children:[e.jsx(X,{className:"h-4 w-4 mr-2"}),"Refresh"]}),e.jsxs(l,{onClick:()=>x(!0),children:[e.jsx(f,{className:"h-4 w-4 mr-2"}),"New Experiment"]})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[e.jsx(r,{className:"border-0 shadow-sm",children:e.jsx(c,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-violet-50",children:e.jsx(p,{className:"h-5 w-5 text-violet-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Total Experiments"}),e.jsx("p",{className:"text-xl font-bold",children:m.length})]})]})})}),e.jsx(r,{className:"border-0 shadow-sm",children:e.jsx(c,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-green-50",children:e.jsx(D,{className:"h-5 w-5 text-green-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Running"}),e.jsx("p",{className:"text-xl font-bold",children:L})]})]})})}),e.jsx(r,{className:"border-0 shadow-sm",children:e.jsx(c,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-blue-50",children:e.jsx(A,{className:"h-5 w-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Completed"}),e.jsx("p",{className:"text-xl font-bold",children:z})]})]})})}),e.jsx(r,{className:"border-0 shadow-sm",children:e.jsx(c,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-amber-50",children:e.jsx(Z,{className:"h-5 w-5 text-amber-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Avg Lift"}),e.jsx("p",{className:"text-xl font-bold",children:"+12.3%"})]})]})})})]}),e.jsx("div",{className:"space-y-4",children:B?[1,2].map(s=>e.jsx(r,{children:e.jsxs(c,{className:"p-6",children:[e.jsx(E,{className:"h-6 w-48 mb-2"}),e.jsx(E,{className:"h-4 w-96"})]})},s)):m.length===0?e.jsx(r,{children:e.jsxs(c,{className:"py-12 text-center",children:[e.jsx(p,{className:"h-12 w-12 mx-auto mb-3 text-gray-300"}),e.jsx("p",{className:"font-medium text-gray-600",children:"No experiments yet"}),e.jsx("p",{className:"text-sm text-gray-400 mb-4",children:"Create your first A/B test to start optimizing"}),e.jsxs(l,{onClick:()=>x(!0),children:[e.jsx(f,{className:"h-4 w-4 mr-2"}),"Create Experiment"]})]})}):m.map(s=>{var n;return e.jsx(r,{children:e.jsxs(c,{className:"p-6",children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[e.jsx("h3",{className:"font-semibold text-lg",children:s.name}),V(s.status),s.metrics.winner&&e.jsxs(h,{className:"bg-green-100 text-green-700",children:["Winner: ",(n=s.variants.find(t=>
6t.id===s.metrics.winner))==null?void 0:n.name]})]}),e.jsx("p",{className:"text-gray-500 text-sm",children:s.description})]}),e.jsxs("div",{className:"flex gap-2",children:[s.status!=="completed"&&e.jsx(l,{variant:"outline",size:"sm",onClick:()=>F(s.id),children:s.status==="running"?e.jsxs(e.Fragment,{children:[e.jsx(ee,{className:"h-4 w-4 mr-1"})," Pause"]}):e.jsxs(e.Fragment,{children:[e.jsx(D,{className:"h-4 w-4 mr-1"})," Start"]})}),e.jsx(l,{variant:"ghost",size:"sm",onClick:()=>_(s.id),children:e.jsx(se,{className:"h-4 w-4 text-red-500"})})]})]}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 mt-4",children:s.variants.map((t,y)=>{const U=t.views>0?(t.conversions/t.views*100).toFixed(2):"0.00",C=s.metrics.winner===t.id;return e.jsxs("div",{className:`p-4 rounded-lg border ${C?"border-green-300 bg-green-50":"bg-gray-50"}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("span",{className:"font-medium",children:[t.name,C&&e.jsx(A,{className:"h-4 w-4 inline ml-2 text-green-600"})]}),e.jsxs("span",{className:"text-sm text-gray-500",children:[t.allocation,"% traffic"]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:t.views.toLocaleString()}),e.jsx("p",{className:"text-xs text-gray-500",children:"Views"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:t.conversions}),e.jsx("p",{className:"text-xs text-gray-500",children:"Conversions"})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-2xl font-bold text-violet-600",children:[U,"%"]}),e.jsx("p",{className:"text-xs text-gray-500",children:"Rate"})]})]})]},t.id)})}),s.status!=="draft"&&e.jsxs("div",{className:"mt-4 p-3 bg-gray-50 rounded-lg",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium",children:"Statistical Confidence"}),e.jsxs("span",{className:"text-sm font-bold",children:[s.metrics.confidence,"%"]})]}),e.jsx(K,{value:s.metrics.confidence,className:"h-2"}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:s.metrics.confidence>=95?"â Statistically significant result":"Need more data for significance"})]})]})},s.id)})}),e.jsx(W,{open:R,onOpenChange:x,children:e.jsxs(M,{className:"max-w-lg",children:[e.jsxs(q,{children:[e.jsx(Q,{children:"Create New Experiment"}),e.jsx(Y,{children:"Set up a new A/B test or multivariate experiment"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Experiment Name"}),e.jsx(u,{value:a.name,onChange:s=>i({...a,name:s.target.value}),placeholder:"e.g., Homepage CTA Color Test"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Description"}),e.jsx(J,{value:a.description,onChange:s=>i({...a,description:s.target.value}),placeholder:"What are you testing and why?",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Type"}),e.jsxs(S,{value:a.type,onValueChange:s=>i({...a,type:s}),children:[e.jsx(T,{children:e.jsx(k,{})}),e.jsxs(P,{children:[e.jsx(d,{value:"ab_test",children:"A/B Test"}),e.jsx(d,{value:"multivariate",children:"Multivariate"}),e.jsx(d,{value:"feature_flag",children:"Feature Flag"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Target Audience"}),e.jsxs(S,{value:a.targetAudience,onValueChange:s=>i({...a,targetAudience:s}),children:[e.jsx(T,{children:e.jsx(k,{})}),e.jsxs(P,{children:[e.jsx(d,{value:"all",children:"All Users"}),e.jsx(d,{value:"new_users",children:"New Users Only"}),e.jsx(d,{value:"returning",children:"Returning Users"}),e.jsx(d,{value:"logged_in",children:"Logged In Users"})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Variant A Name"}),e.jsx(u,{value:a.variantA,onChange:s=>i({...a,variantA:s.target.value}),placeholder:"Control"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Variant B Name"}),e.jsx(u,{value:a.variantB,onChange:s=>i({...a,variantB:s.target.value}),placeholder:"Variant"})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-sm font-medium mb-1.5 block",children:["Traffic Allocation: ",a.trafficAllocation,"%"]}),e.jsx("input",{type:"range",min:"10",max:"100",step:"10",value:a.trafficAllocation,onChange:s=>i({...a,trafficAllocation:parseInt(s.target.value)}),className:"w-full"})]})]}),e.jsxs($,{children:[e.jsx(l,{variant:"outline",onClick:()=>x(!1),children:"Cancel"}),e.jsxs(l,{onClick:I,disabled:N,children:[N?e.jsx(G,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(f,{className:"h-4 w-4 mr-2"}),"Create Experiment"]})]})]})})]})};export{ve 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.