1import{r,j as e}from"./radix-ui-DPh7-E6u.js";import{B as p}from"./button-DT89iARz.js";import{C as f,T as _}from"./card-Bu07PzW5.js";import{L as U,E as $,a as q}from"./lock-BTGOntni.js";import{c as w,X as T}from"./main-m2eyXYtA.js";import{C as D}from"./check-B8ZUhUf4.js";import{C as A,M as z}from"./map-pin-WkQe9eip.js";import{C as G}from"./clock-2yGuA3x5.js";import"./react-vendor-DfSJUp79.js";import"./query-Dj0kKX4W.js";import"./index-CqmyKYSU.js";/** 2 * @license lucide-react v0.454.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=w("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);/** 7 * @license lucide-react v0.454.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const H=w("Pencil",[["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"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/** 12 * @license lucide-react v0.454.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const J=w("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);function Y({onUnlock:c}){const[i,g]=r.useState(""),[m,b]=r.useState(!1),[u,o]=r.useState(""),[x,a]=r.useState(!1),n=async l=>{l.preventDefault(),a(!0),o("");try{(await(await fetch("/api/admin/verify-password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:i})})).json()).success?(sessionStorage.setItem("admin_auth","1"),c()):o("Incorrect password. Please try again.")}catch{o("Something went wrong. Please try again.")}finally{a(!1)}};return e.jsx("div",{className:"min-h-screen bg-[#f0f3f4] flex items-center justify-center px-4",children:e.jsxs(f,{className:"w-full max-w-sm p-8 shadow-lg border-2",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-[#b14987]/10 flex items-center justify-center mx-auto mb-4",children:e.jsx(U,{className:"w-7 h-7 text-[#b14987]"})}),e.jsx("h1",{className:"text-2xl font-bold text-[#2e1f87] font-heading",children:"Admin Access"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Enter your password to manage speaking events"})]}),e.jsxs("form",{onSubmit:n,className:"space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:m?"text":"password",value:i,onChange:l=>g(l.target.value),placeholder:"Password",autoFocus:!0,className:"w-full border border-border rounded-lg px-4 py-2.5 pr-10 text-sm focus:outline-none focus:ring-2 focus:ring-[#b14987]"}),e.jsx("button",{type:"button",onClick:()=>b(l=>!l),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:m?e.jsx($,{className:"w-4 h-4"}):e.jsx(q,{className:"w-4 h-4"})})]}),u&&e.jsx("p",{className:"text-red-600 text-sm",children:u}),e.jsx(p,{type:"submit",disabled:x||!i,className:"w-full bg-[#b14987] hover:bg-[#b14987]/90 text-white",children:x?"Checking...":"Enter"})]})]})})}const L=()=>({title:"",eventType:"booked",date:"",endDate:"",time:"",location:"",city:"",stateCountry:"",description:"",url:"",isPublic:!0}),K={booked:"Booked",available:"Available",tentative:"Tentative"},V={booked:"bg-[#b14987] text-white",available:"bg-[#5ce1e6] text-[#2e1f87]",tentative:"bg-[#2e1f87]/20 text-[#2e1f87]"};function ie(){const[c,i]=r.useState(()=>sessionStorage.getItem("admin_auth")==="1");return c?e.jsx(W,{}):e.jsx(Y,{onUnlock:()=>i(!0)})}function W(){const[c,i]=r.useState([]),[g,m]=r.useState(!0),[b,u]=r.useState(!1),[o,x]=r.useState(null),[a,n]=r.useState(L()),[l,j]=r.useState(!1),[k,N]=r.useState(null),[C,d]=r.useState(""),[S,h]=r.useState(""),y=()=>{m(!0),fetch("/api/speaking-events?all=true").then(t=>t.json()).then(t=>{i(Array.isArray(t)?t:[]),m(!1)}).catch(()=>m(!1))};r.useEffect(()=>{y()},[]);const M=()=>{n(L()),x(null),u(!0),d("")},F=t=>
16{n({title:t.title,eventType:t.eventType,date:t.date,endDate:t.endDate||"",time:t.time||"",location:t.location||"",city:t.city||"",stateCountry:t.stateCountry||"",description:t.description||"",url:t.url||"",isPublic:t.isPublic}),x(t.id),u(!0),d("")},v=()=>{u(!1),x(null),d("")},B=async()=>{if(!a.title.trim()||!a.date){d("Title and date are required.");return}j(!0),d("");try{const t=o?`/api/speaking-events/${o}`:"/api/speaking-events";if(!(await fetch(t,{method:o?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})).ok)throw new Error("Save failed");h(o?"Event updated!":"Event added!"),setTimeout(()=>h(""),3e3),v(),y()}catch{d("Something went wrong. Please try again.")}finally{j(!1)}},O=async t=>{try{await fetch(`/api/speaking-events/${t}`,{method:"DELETE"}),N(null),h("Event deleted."),setTimeout(()=>h(""),3e3),y()}catch{d("Delete failed.")}},E=t=>{const[s,P,I]=t.split("-").map(Number);return new Date(s,P-1,I).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})};return e.jsx("div",{className:"min-h-screen bg-[#f0f3f4] py-10 px-4",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-[#2e1f87] font-heading",children:"Speaking Events"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Manage your calendar - changes appear live on the Speaking page."})]}),e.jsxs(p,{onClick:M,className:"bg-[#b14987] hover:bg-[#b14987]/90 text-white gap-2",children:[e.jsx(J,{className:"w-4 h-4"})," Add Event"]})]}),S&&e.jsxs("div",{className:"flex items-center gap-2 bg-green-50 border border-green-200 text-green-800 rounded-lg px-4 py-3 text-sm",children:[e.jsx(D,{className:"w-4 h-4"})," ",S]}),b&&e.jsxs(f,{className:"p-6 border-2 border-[#b14987]/30 shadow-lg",children:[e.jsxs("div",{className:"flex items-center justify-between mb-5",children:[e.jsx("h2",{className:"text-xl font-bold text-[#2e1f87] font-heading",children:o?"Edit Event":"Add New Event"}),e.jsx("button",{onClick:v,className:"text-muted-foreground hover:text-foreground",children:e.jsx(T,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-1",children:"Event Title *"}),e.jsx("input",{type:"text",value:a.title,onChange:t=>n(s=>({...s,title:t.target.value})),placeholder:"e.g. Women's Conference Keynote",className:"w-full border border-border rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-[#b14987]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-1",children:"Event Type *"}),e.jsxs("select",{value:a.eventType,onChange:t=>n(s=>({...s,eventType:t.target.value})),className:"w-full border border-border rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-[#b14987]",children:[e.jsx("option",{value:"booked",children:"Booked"}),e.jsx("option",{value:"available",children:"Available"}),e.jsx("option",{value:"tentative",children:"Tentative"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 pt-6",children:[e.jsx("input",{type:"checkbox",id:"isPublic",checked:a.isPublic,onChange:t=>n(s=>({...s,isPublic:t.target.checked})),className:"w-4 h-4 accent-[#b14987]"}),e.jsx("label",{htmlFor:"isPublic",className:"text-sm font-medium text-foreground",children:"Show on website"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-1",children:"Start Date *"}),e.jsx("input",{type:"date",value:a.date,onChange:t=>n(s=>({...s,date:t.target.value})),className:"w-full border border-border rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-[#b14987]"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-1",children:["End Date ",e.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),e.jsx("input",{type:"date",value:a.endDate||"",onChange:t=>n(s=>({...s,endDate:t.target.value})),className:"w-full border border-border rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-[#b14987]"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-1",children:["Time ",e.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),e.jsx("input",{type:"text",value:a.time||"",onChange:t=>n(s=>({...s,time:t.target.value})),placeholder:"e.g. 7:00 PM",className:"w-full border border-border rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-[#b14987]"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-1",children:["Venue ",e.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),e.jsx("input",{type:"text",value:a.location||"",onChange:t=>n(s=>({...s,location:t.target.value})),placeholder:"e.g. Grand Ballroom",className:"w-full border border-border rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-[#b14987]"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-1",children:["City ",e.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),e.jsx("input",{type:"text",value:a.city||"",onChange:t=>n(s=>({...s,city:t.target.value})),placeholder:"e.g. Grand Rapids",className:"w-full border border-border rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-[#b14987]"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-1",children:["State / Country ",e.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),e.jsx("input",{type:"text",value:a.stateCountry||"",onChange:t=>n(s=>({...s,stateCountry:t.target.value})),placeholder:"e.g. Michigan",className:"w-full border border-border rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-[#b14987]"})]}),e.jsxs("div",{className:"sm:col-span-2",children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-1",children:["Event Link ",e.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),e.jsx("input",{type:"url",value:a.url||"",onChange:t=>n(s=>({...s,url:t.target.value})),placeholder:"https://...",className:"w-full border border-border rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-[#b14987]"})]}),e.jsxs("div",{className:"sm:col-span-2",children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-1",children:["Description ",e.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),e.jsx("textarea",{value:a.description||"",onChange:t=>n(s=>({...s,description:t.target.value})),rows:3,placeholder:"Brief description of the event...",className:"w-full border border-border rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-[#b14987] resize-none"})]})]}),C&&e.jsx("p",{className:"text-red-600 text-sm mt-3",children:C}),e.jsxs("div",{className:"flex gap-3 mt-5",children:[e.jsx(p,{onClick:B,disabled:l,className:"bg-[#b14987] hover:bg-[#b14987]/90 text-white",children:l?"Saving...":o?"Save Changes":"Add Event"}),e.jsx(p,{variant:"outline",onClick:v,children:"Cancel"})]})]}),g?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(t=>e.jsx("div",{className:"h-20 bg-white rounded-xl animate-pulse"},t))}):c.length===0?e.jsxs(f,{className:"p-12 text-center",children:[e.jsx(A,{className:"w-12 h-12 mx-auto mb-3 text-muted-foreground
16/40"}),e.jsx("p",{className:"text-muted-foreground",children:"No events yet. Add your first event above."})]}):e.jsx("div",{className:"space-y-3",children:c.map(t=>e.jsx(f,{className:"p-4 bg-white hover:shadow-md transition-shadow",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap mb-1",children:[e.jsx("h3",{className:"font-semibold text-foreground truncate",children:t.title}),e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full font-medium ${V[t.eventType]}`,children:K[t.eventType]}),!t.isPublic&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-muted text-muted-foreground",children:"Hidden"})]}),e.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(A,{className:"w-3 h-3"}),E(t.date),t.endDate&&t.endDate!==t.date?` â ${E(t.endDate)}`:""]}),t.time&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(G,{className:"w-3 h-3"}),t.time]}),(t.city||t.location)&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(z,{className:"w-3 h-3"}),[t.location,t.city,t.stateCountry].filter(Boolean).join(", ")]}),t.url&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(R,{className:"w-3 h-3"}),"Has link"]})]}),t.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-1",children:t.description})]}),e.jsx("div",{className:"flex items-center gap-2 shrink-0",children:k===t.id?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-xs text-red-600 font-medium",children:"Delete?"}),e.jsx("button",{onClick:()=>O(t.id),className:"text-red-600 hover:text-red-700 p-1",children:e.jsx(D,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>N(null),className:"text-muted-foreground hover:text-foreground p-1",children:e.jsx(T,{className:"w-4 h-4"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>F(t),className:"text-muted-foreground hover:text-[#2e1f87] p-1.5 rounded-lg hover:bg-muted transition-colors",children:e.jsx(H,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>N(t.id),className:"text-muted-foreground hover:text-red-600 p-1.5 rounded-lg hover:bg-red-50 transition-colors",children:e.jsx(_,{className:"w-4 h-4"})})]})})]})},t.id))}),e.jsxs("p",{className:"text-center text-xs text-muted-foreground pt-4",children:["Changes are reflected immediately on the"," ",e.jsx("a",{href:"/speaking",className:"text-[#b14987] hover:underline",target:"_blank",children:"Speaking page"}),"."]})]})})}export{ie 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.