1import{b as A,r as c,j as e,B as o,p as w,a9 as E,af as L,a3 as f,a4 as v,C as S,ac as _,a6 as N,aA as B,aK as m,V as I,ao as P}from"./index-ByYYWl6V.js";import{u as M,a as O,b as $}from"./useEventTypes-92m5yosm.js";import{u as z}from"./booking-domain-DHUoi_Ea.js";import{B as H}from"./badge-DuSeH5ON.js";import{S as U}from"./skeleton-Dgkec9Dl.js";import{D as V,a as K,b as q,c as x,d as F}from"./dropdown-menu-BZRKspBv.js";import{A as Q,a as R,b as W,c as G,d as J,e as X,f as Y,g as Z}from"./alert-dialog-Cm0yc26w.js";import{P as b}from"./plus-CwyWY8pM.js";import{C as ee}from"./clock-CUm8QZGC.js";import{E as se}from"./external-link-CECnRthk.js";import{E as te}from"./ellipsis-CAg5Wdfa.js";import{T as ae}from"./trash-2-250o4KTP.js";import{P as ie,B as re}from"./phone-DRfvr5iu.js";import{M as ne}from"./map-pin-54GgpTKZ.js";import"./useQuery-yGeh6Hp2.js";import"./useMutation-BJQUmqJw.js";import"./booking-api-DEe9SXlv.js";import"./supabase-functions-CBdNz-q5.js";import"./index-CnBNeFET.js";import"./chevron-right-X_hlXzqd.js";import"./circle-DcpkfI2n.js";const oe={virtual:I,phone:ie,in_person:re,custom:ne},le={virtual:"Web",phone:"Phone",in_person:"In person",custom:"Custom"};function Se(){const i=A(),{data:l,isLoading:C}=M(),{data:p}=z(),y=O(),k=$(),[n,D]=c.useState(""),[r,d]=c.useState(null),[T,u]=c.useState(null),h=c.useMemo(()=>{const s=l??[];if(!n.trim())return s;const a=n.trim().toLowerCase();return s.filter(t=>t.title.toLowerCase().includes(a)||t.slug.toLowerCase().includes(a)||(t.description??"").toLowerCase().includes(a))},[l,n]),g=async s=>{const t=`${p??window.location.origin}/b/${s.slug}`;try{await navigator.clipboard.writeText(t),u(s.id),setTimeout(()=>u(j=>j===s.id?null:j),1500),m.success("Link copied")}catch{m.error("Could not copy link")}};return e.jsxs("div",{className:"p-4 sm:p-6 lg:p-8 max-w-6xl mx-auto space-y-6",children:[e.jsxs("header",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Event types"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:"Each event type is a public page where people can pick a time on your calendar."})]}),e.jsxs(o,{onClick:()=>i("/booking/event-types/new"),children:[e.jsx(b,{className:"h-4 w-4 mr-2"})," New event type"]})]}),e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(w,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(E,{value:n,onChange:s=>D(s.target.value),placeholder:"Search event typesâ¦",className:"pl-9"})]}),C?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:Array.from({length:4}).map((s,a)=>e.jsx(U,{className:"h-32 w-full rounded-lg"},a))}):h.length===0?e.jsx(ce,{query:n,onCreate:()=>i("/booking/event-types/new")}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:h.map(s=>{const a=oe[s.location_kind];return e.jsxs("article",{className:"group relative border rounded-lg bg-card overflow-hidden hover:border-foreground
1/20 transition-colors",children:[e.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1",style:{background:s.color??"hsl(var(--primary))"}}),e.jsxs("div",{className:"p-4 pl-5 flex items-start gap-3",children:[e.jsxs("button",{onClick:()=>i(`/booking/event-types/${s.id}`),className:"flex-1 min-w-0 text-left space-y-2",children:[e.jsx("div",{className:"flex items-start justify-between gap-2",children:e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold truncate",children:s.title}),s.is_active?null:e.jsx(H,{variant:"secondary",className:"text-[10px] uppercase tracking-wider",children:"Hidden"})]}),e.jsxs("div",{className:"text-xs text-muted-foreground font-mono mt-0.5 truncate",children:["/b/",s.slug]})]})}),s.description?e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:s.description}):null,e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(ee,{className:"h-3 w-3"})," ",s.duration_minutes,"m"]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(a,{className:"h-3 w-3"})," ",le[s.location_kind]]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsxs(L,{children:[e.jsxs(f,{children:[e.jsx(v,{asChild:!0,children:e.jsx(o,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>g(s),children:T===s.id?e.jsx(S,{className:"h-3.5 w-3.5 text-emerald-500"}):e.jsx(_,{className:"h-3.5 w-3.5"})})}),e.jsx(N,{children:"Copy link"})]}),e.jsxs(f,{children:[e.jsx(v,{asChild:!0,children:e.jsx(o,{asChild:!0,variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx("a",{href:`${p??""}/b/${s.slug}`,target:"_blank",rel:"noreferrer",children:e.jsx(se,{className:"h-3.5 w-3.5"})})})}),e.jsx(N,{children:"Open public page"})]})]}),e.jsx(B,{checked:s.is_active,onCheckedChange:t=>k.mutate({id:s.id,patch:{is_active:t}},{onSuccess:()=>m.success(t?"Visible":"Hidden")}),onClick:t=>t.stopPropagation(),className:"ml-1"}),e.jsxs(V,{children:[e.jsx(K,{asChild:!0,children:e.jsx(o,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(te,{className:"h-4 w-4"})})}),e.jsxs(q,{align:"end",children:[e.jsx(x,{onClick:()=>i(`/booking/event-types/${s.id}`),children:"Edit"}),e.jsx(x,{onClick:()=>g(s),children:"Copy link"}),e.jsx(F,{}),e.jsxs(x,{className:"text-destructive focus:text-destructive",onClick:()=>d(s),children:[e.jsx(ae,{className:"h-3.5 w-3.5 mr-2"}),"Delete"]})]})]})]})]})]},s.id)})}),e.jsx(Q,{open:!!r,onOpenChange:s=>!s&&d(null),children:e.jsxs(R,{children:[e.jsxs(W,{children:[e.jsx(G,{children:"Delete this event type?"}),e.jsxs(J,{children:['"',r==null?void 0:r.title,'" will be removed and its public link will stop working. Existing bookings stay intact.']})]}),e.jsxs(X,{children:[e.jsx(Y,{children:"Keep"}),e.jsx(Z,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{r&&y.mutate(r.id),d(null)},children:"Delete"})]})]})})]})}function ce({query:i,onCreate:l}){return i.trim()?e.jsxs("div",{className:"border border-dashed rounded-lg p-12 text-center",children:[e.jsx(w,{className:"h-8 w-8 text-muted-foreground mx-auto mb-3"}),e.jsxs("div",{className:"text-sm font-medium",children:['No results for "',i,'"']}),e.jsx("div",{className:"text-xs text-muted-foreground mt-1",children:"Try a different search."})]}):e.jsxs("div",{className:"border border-dashed rounded-lg p-12 text-center space-y-3 bg-muted/10",children:[e.jsx(P,{className:"h-10 w-10 text-muted-foreground mx-auto"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-base font-semibold",children:"Create your first event type"}),e.jsx("div",{className:"text-sm text-muted-foreground mt-1 max-w-sm mx-auto",children:"An event type defines how people can book time with you â duration, availability, location."})]}),e.jsxs(o,{onClick:l,children:[e.jsx(b,{className:"h-4 w-4 mr-2"})," New event type"]})]})}export{Se 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.