(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,46063,e=>{"use strict";var t=e.i(43476),a=e.i(71645),l=e.i(11795);e.s(["default",0,function({value:e,onChange:s,folder:n="misc",label:i="Image"}){let r=(0,l.createClient)(),d=(0,a.useRef)(null),[u,c]=(0,a.useState)(!1),[o,m]=(0,a.useState)(null);async function g(e){let t=e.target.files?.[0];if(!t)return;c(!0),m(null);let a=(t.name.split(".").pop()||"jpg").toLowerCase(),l=`${n}/${Date.now()}-${Math.random().toString(36).slice(2,8)}.${a}`,{error:i}=await r.storage.from("media").upload(l,t,{cacheControl:"3600",upsert:!1});if(i){m(i.message),c(!1);return}let{data:d}=r.storage.from("media").getPublicUrl(l);s(d.publicUrl),c(!1)}return(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm font-medium mb-1",children:i}),(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("div",{className:"h-20 w-20 shrink-0 overflow-hidden rounded-md border border-neutral-200 bg-neutral-100",children:e?(0,t.jsx)("img",{src:e,alt:"",className:"h-full w-full object-cover"}):(0,t.jsx)("div",{className:"flex h-full w-full items-center justify-center text-[11px] text-neutral-400",children:"No image"})}),(0,t.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("button",{type:"button",onClick:()=>d.current?.click(),disabled:u,className:"rounded-md bg-neutral-900 px-3 py-1.5 text-sm font-medium text-white hover:bg-neutral-700 disabled:opacity-50",children:u?"Uploading…":"Upload"}),e&&(0,t.jsx)("button",{type:"button",onClick:()=>s(""),className:"rounded-md border border-neutral-200 px-3 py-1.5 text-sm text-neutral-600 hover:bg-neutral-50",children:"Remove"})]}),(0,t.jsx)("input",{ref:d,type:"file",accept:"image/*",onChange:g,className:"hidden"}),(0,t.jsx)("input",{value:e,onChange:e=>s(e.target.value),placeholder:"…or paste an image URL",className:"input"}),o&&(0,t.jsx)("p",{className:"text-sm text-red-600",children:o})]})]})]})}])},56995,e=>{"use strict";var t=e.i(43476),a=e.i(71645),l=e.i(18566),s=e.i(11795),n=e.i(46063);function i({label:e,children:a}){return(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm font-medium mb-1",children:e}),a]})}e.s(["default",0,function({categories:e}){let r=(0,l.useRouter)(),d=(0,s.createClient)(),[u,c]=(0,a.useState)({title:"",description:"",venue:"",starts_at:"",ends_at:"",cover_image_url:"",category_id:""}),[o,m]=(0,a.useState)(null),[g,p]=(0,a.useState)(!1);async function x(e){e.preventDefault(),p(!0),m(null);let{data:t}=await d.auth.getUser();if(!t.user){m("Not signed in"),p(!1);return}let{data:a,error:l}=await d.from("events").insert({organizer_id:t.user.id,title:u.title,description:u.description||null,venue:u.venue||null,starts_at:new Date(u.starts_at).toISOString(),ends_at:u.ends_at?new Date(u.ends_at).toISOString():null,cover_image_url:u.cover_image_url||null,category_id:u.category_id||null,status:"draft"}).select().single();if(l){m(l.message),p(!1);return}r.push(`/dashboard/events/${a.id}`)}return(0,t.jsxs)("form",{onSubmit:x,className:"space-y-4",children:[(0,t.jsx)(i,{label:"Title",children:(0,t.jsx)("input",{required:!0,value:u.title,onChange:e=>c({...u,title:e.target.value}),className:"input"})}),(0,t.jsx)(i,{label:"Description",children:(0,t.jsx)("textarea",{value:u.description,onChange:e=>c({...u,description:e.target.value}),className:"input",rows:3})}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,t.jsx)(i,{label:"Venue",children:(0,t.jsx)("input",{value:u.venue,onChange:e=>c({...u,venue:e.target.value}),className:"input"})}),(0,t.jsx)(i,{label:"Category",children:(0,t.jsxs)("select",{value:u.category_id,onChange:e=>c({...u,category_id:e.target.value}),className:"input",children:[(0,t.jsx)("option",{value:"",children:"— None —"}),e.map(e=>(0,t.jsx)("option",{value:e.id,children:e.name},e.id))]})})]}),(0,t.jsx)(n.default,{value:u.cover_image_url,onChange:e=>c({...u,cover_image_url:e}),folder:"events",label:"Cover image"}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,t.jsx)(i,{label:"Starts at",children:(0,t.jsx)("input",{required:!0,type:"datetime-local",value:u.starts_at,onChange:e=>c({...u,starts_at:e.target.value}),className:"input"})}),(0,t.jsx)(i,{label:"Ends at",children:(0,t.jsx)("input",{type:"datetime-local",value:u.ends_at,onChange:e=>c({...u,ends_at:e.target.value}),className:"input"})})]}),o&&(0,t.jsx)("p",{className:"text-sm text-red-600",children:o}),(0,t.jsx)("button",{type:"submit",disabled:g,className:"rounded-md bg-brand-green text-white px-4 py-2 text-sm font-medium hover:bg-brand-green-deep disabled:opacity-50",children:g?"Creating…":"Create event"})]})}])}]);