1import{u as ce,k as de,e as me,ac as pe,r as l,f as ue,J as ge,l as xe,j as e,g as _,B as b,C as q,a as L,d as G,p as K,s as he,O as je,V as n,W as o,aQ as u,Y as c,F as be,X as ve,$ as d,Q as m,I as N,a9 as O,v as fe,h as ye,i as T,U as Ne,a1 as we,a2 as Ce,D as Q,E as De,a6 as E,aR as Ue}from"./index-CAQ9C6-z.js";import{S as ke,a as Se,b as Ie,c as Fe,d as v}from"./select-C1jcuWaT.js";import{A as Ae,a as Pe}from"./alert-CTONyx1G.js";import{d as Me}from"./directUpload-Dc5aW8FH.js";import{b as _e}from"./schema-mI1ZaGro.js";import{c as z,i as qe}from"./calendarDate-Cy0AuFih.js";import{F as Le}from"./FocalPointSlider-D0YRD_6R.js";import{s as Y}from"./subHours-C8H0UFTR.js";import{A as J}from"./arrow-left-BrnCBqZV.js";import{I as Oe}from"./image-vQO19pbr.js";import{U as Te}from"./upload-BTVigLWl.js";import{f as R}from"./format-DECx0Hkk.js";import{S as Ee}from"./star-QjPncnq2.js";import"./index-BdQq_4o_.js";import"./index-Q3UH4NY9.js";import"./chevron-down--E-1bxpl.js";import"./chevron-up-BOfZRiUg.js";import"./slider-B6J5yanw.js";import"./en-US-K2-Byqu-.js";import"./differenceInCalendarDays-BvXbP6kq.js";const Re=_e.extend({imageUrl:E().optional(),applicationUrl:E().url("Please enter a valid URL").optional().or(Ue("")),releaseDate:E().optional()});function oa(){const{isAuthenticated:H}=ce(),{toast:g}=de(),[,w]=me(),C=pe().id,D=l.useRef(null),[U,F]=l.useState(null),[k,x]=l.useState(null),[S,A]=l.useState(!1),[X,P]=l.useState(!1),[h,M]=l.useState(!0),[B,V]=l.useState(50),[j,W]=l.useState({allAccess:null,premium:null}),{data:s,isLoading:Z}=ue({queryKey:[`/api/opportunities/${C}`],enabled:H&&!!C}),i=ge({resolver:Ce(Re),defaultValues:{title:"",description:"",category:"brand_partnerships_campaign",requirements:"",deliverables:"",budget:void 0,deadline:void 0,imageUrl:"",applicationUrl:"",releaseDate:""}});l.useEffect(()=>{s&&(i.reset({title:s.title,description:s.description,category:s.category,requirements:s.requirements||"",deliverables:s.deliverables||"",budget:s.budget??void 0,deadline:s.deadline?z(s.deadline)??void 0:void 0,imageUrl:s.imageUrl||"",applicationUrl:s.applicationUrl||"",releaseDate:s.releaseDate?new Date(s.releaseDate).toISOString().slice(0,16):""}),s.imageUrl&&x(s.imageUrl),V(s.imageFocalY??50))},[s,i]);const f=i.watch("releaseDate");l.useEffect(()=>{if(f){const a=new Date(f),t=Y(a,48),r=Y(a,24);W({allAccess:t,premium:r})}else W({allAccess:null,premium:null})},[f]);const ee=async a=>{const{imageUrl:t}=await Me("/api/upload/campaign-image",a);return t},I=xe({mutationFn:async a=>{var p,y;let t=(s==null?void 0:s.imageUrl)||"";if(U&&!h){A(!0);try{t=await ee(U)}catch(oe){throw A(!1),oe}A(!1)}const r={...a,imageUrl:h?s==null?void 0:s.imageUrl:t,imageFocalY:B,allAccessDate:(p=j.allAccess)==null?void 0:p.toISOString(),premiumDate:(y=j.premium)==null?void 0:y.toISOString()};await De("PUT",`/api/opportunities/${C}`,r)},onSuccess:()=>{g({title:"Success",description:"Campaign updated successfully!"}),Q.invalidateQueries({queryKey:["/api/my-campaigns"]}),Q.invalidateQueries({queryKey:[`/api/opportunities/${C}`]}),w("/campaigns")},onError:a=>{g({title:"Error",description:a.message||"Failed to update campaign",variant:"destructive"})}}),$=a=>{if(!a){F(null),s!=null&&s.imageUrl?x(s.imageUrl):x(null),M(!0);return}if(!["image/jpeg","image/jpg","image/png","image/webp"].includes(a.type)){g({title:"Invalid file type",description:"Please upload a JPG, PNG, or WebP image",variant:"destructive"});return}if(a.size>5*1024*1024){g({title:"File too large",description:"Please upload an image smaller than 5MB",variant:"destructive"});return}F(a),M(!1);const r=new FileReader;r.onload=p=>{var y;x((y=p.target)==null?void 0:y.result)},r.readAsDataURL(a)},ae=a=>{var r;const t=((r=a.target.files)==null?void 0:r[0])||null;$(t)},se=l.useCallback(a=>{a.preventDefault(),P(!0)},[]),te=l.useCallback(a=>{a.preventDefault(),P(!1)},[]),re=l.useCallback(a=>{var r;a.preventDefault(),P(!1);const t=((r=a.dataTransfer.files)==null?void 0:r[0])||null;t&&t.type.startsWith("image/")?$(t):g({title:"Invalid file",description:"Please drop an image file",variant:"destructive"})},[]),ie=()=>{F(null),s!=null&&s.imageUrl?(x(s.imageUrl),M(!0)):x(null),D.current&&(D.current.value="")},le=a=>{I.mutate(a)},ne=a=>{var p;const t=Object.keys(a)[0],r=t?(p=a[t])==null?void 0:p.message:void 0;g({title:"Please fix the highlighted fields",description:typeof r=="string"&&r?`${t}: ${r}`:"Some fields are invalid or missing.",variant:"destructive"})};return Z?e.jsxs("div",{className:"max-w-4xl space-y-6",children:[e.jsx(_,{className:"h-10 w-48"}),e.jsx(_,{className:"h-64 w-full"}),e.jsx(_,{className:"h-96 w-full"})]}
1):s?e.jsxs("div",{className:"max-w-4xl space-y-6",children:[e.jsxs(b,{variant:"ghost",onClick:()=>w("/campaigns"),className:"gap-2","data-testid":"button-back",children:[e.jsx(J,{className:"w-4 h-4"}),"Back to Campaigns"]}),e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h1",{className:"text-3xl md:text-4xl font-bold font-heading text-foreground",children:"Edit Festival Sponsorship"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"Update your opportunity details"})]}),e.jsxs(q,{className:"border-rose-400/10 shadow-[0_0_30px_rgba(232,165,152,0.1)] bg-gradient-to-br from-card via-card to-rose-400/5",children:[e.jsxs(G,{className:"border-b border-rose-400/10 pb-6",children:[e.jsx(K,{className:"text-2xl",children:"Campaign Details"}),e.jsx(he,{className:"text-muted-foreground",children:"Update information about your opportunity"})]}),e.jsx(L,{className:"mt-6",children:e.jsx(je,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(le,ne),className:"space-y-6",children:[e.jsxs(n,{children:[e.jsx(o,{className:"text-base font-semibold",children:"Campaign Image"}),e.jsx(u,{children:s.imageUrl?"Current image is shown below. Upload a new image to replace it.":"Add an image to your campaign"}),e.jsx(c,{children:e.jsxs("div",{className:"space-y-4",children:[k&&e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"relative aspect-video w-full overflow-hidden rounded-lg border-2 border-primary/20",children:[e.jsx("img",{src:k,alt:"Campaign preview",loading:"lazy",decoding:"async",className:"w-full h-full object-cover"}),h&&s.imageUrl&&e.jsxs("div",{className:"absolute top-2 left-2 bg-green-600 text-white px-3 py-1 rounded-full text-sm font-semibold flex items-center gap-1",children:[e.jsx(be,{className:"w-4 h-4"}),"Current Image"]}),!h&&U&&e.jsx("div",{className:"absolute top-2 left-2 bg-blue-600 text-white px-3 py-1 rounded-full text-sm font-semibold",children:"New Image"})]}),!h&&U&&e.jsxs(b,{type:"button",variant:"destructive",size:"sm",className:"absolute top-2 right-2",onClick:ie,"data-testid":"button-remove-new-image",children:[e.jsx(ve,{className:"w-4 h-4 mr-1"}),"Remove New Image"]})]}),k&&e.jsx(Le,{imageUrl:k,value:B,onChange:V}),e.jsxs("div",{className:`relative border-2 border-dashed rounded-lg p-8 text-center transition-all ${X?"border-primary bg-primary/10":"border-gray-300 hover:border-primary/50"}`,onDragOver:se,onDragLeave:te,onDrop:re,children:[e.jsx("input",{ref:D,type:"file",accept:"image/jpeg,image/jpg,image/png,image/webp",onChange:ae,className:"hidden","data-testid":"input-image-upload"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"mx-auto w-12 h-12 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(Oe,{className:"w-6 h-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:s.imageUrl&&h?"Upload a new image to replace the current one":"Drop an image here or click to browse"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"JPG, PNG or WebP. Max 5MB."})]}),e.jsxs(b,{type:"button",variant:"outline",size:"sm",onClick:()=>{var a;return(a=D.current)==null?void 0:a.click()},className:"gap-2","data-testid":"button-choose-image",children:[e.jsx(Te,{className:"w-4 h-4"}),s.imageUrl?"Change Image":"Choose Image"]})]})]})]})}),e.jsx(d,{})]}),e.jsx(m,{control:i.control,name:"title",render:({field:a})=>e.jsxs(n,{children:[e.jsx(o,{children:"Campaign Title"}),e.jsx(c,{children:e.jsx(N,{placeholder:"e.g., Summer Music Festival Brand Partnership",...a,className:"bg-background/50","data-testid":"input-title"})}),e.jsx(d,{})]})}),e.jsx(m,{control:i.control,name:"description",render:({field:a})=>e.jsxs(n,{children:[e.jsx(o,{children:"Description"}),e.jsx(c,{children:e.jsx(O,{placeholder:"Describe your opportunity and what you're looking for...",className:"min-h-[120px] bg-background/50",...a,"data-testid":"input-description"})}),e.jsx(d,{})]})}),e.jsx(m,{control:i.control,name:"category",render:({field:a})=>e.jsxs(n,{children:[e.jsx(o,{children:"Category"}),e.jsxs(ke,{onValueChange:a.onChange,defaultValue:a.value,children:[e.jsx(c,{children:e.jsx(Se,{className:"bg-background/50","data-testid":"select-category",children:e.jsx(Ie,{placeholder:"Select a category"})})}),e.jsxs(Fe,{children:[e.jsx(v,{value:"festival_campaign","data-testid":"option-festival-campaign",children:"Festival Campaign"}),e.jsx(v,{value:"artist_track_campaign","data-testid":"option-artist-track-campaign",children:"Artist Track Campaign"}),e.jsx(v,{value:"artist_show_campaign","data-testid":"option-artist-show-campaign",children:"Artist Show Campaign"}),e.jsx(v,{value:"brand_partnerships_campaign","data-testid":"option-brand-partnerships-campaign",children:"Brand Partnerships Campaign"}
1),e.jsx(v,{value:"media_coverage_campaign","data-testid":"option-media-coverage-campaign",children:"Media Coverage Campaign"}),e.jsx(v,{value:"discounts_offers_freebies","data-testid":"option-discounts-offers-freebies",children:"Discounts, Offers & Freebies"})]})]}),e.jsx(d,{})]})}),e.jsx(m,{control:i.control,name:"requirements",render:({field:a})=>e.jsxs(n,{children:[e.jsx(o,{children:"Requirements"}),e.jsx(c,{children:e.jsx(O,{placeholder:"What are the requirements for creators?",className:"min-h-[100px] bg-background/50",...a,value:a.value??"","data-testid":"input-requirements"})}),e.jsx(u,{children:"List any specific requirements or qualifications needed"}),e.jsx(d,{})]})}),e.jsx(m,{control:i.control,name:"deliverables",render:({field:a})=>e.jsxs(n,{children:[e.jsx(o,{children:"Deliverables"}),e.jsx(c,{children:e.jsx(O,{placeholder:"What deliverables are expected?",className:"min-h-[100px] bg-background/50",...a,value:a.value??"","data-testid":"input-deliverables"})}),e.jsx(u,{children:"Describe what creators need to deliver"}),e.jsx(d,{})]})}),e.jsx(m,{control:i.control,name:"applicationUrl",render:({field:a})=>e.jsxs(n,{children:[e.jsx(o,{children:"External Application URL (Optional)"}),e.jsx(c,{children:e.jsx(N,{type:"url",placeholder:"https://example.com/apply",...a,value:a.value||"",className:"bg-background/50","data-testid":"input-application-url"})}),e.jsx(u,{children:"Provide an external URL where creators can apply directly (e.g., your website, form, etc.)"}),e.jsx(d,{})]})}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx(m,{control:i.control,name:"budget",render:({field:a})=>e.jsxs(n,{children:[e.jsx(o,{children:"Budget (Optional)"}),e.jsx(c,{children:e.jsx(N,{type:"number",placeholder:"e.g., 5000",...a,value:a.value??"",onChange:t=>a.onChange(t.target.value?Number(t.target.value):void 0),className:"bg-background/50","data-testid":"input-budget"})}),e.jsx(u,{children:"Budget in USD"}),e.jsx(d,{})]})}),e.jsx(m,{control:i.control,name:"deadline",render:({field:a})=>e.jsxs(n,{children:[e.jsx(o,{children:"End date / application deadline (Optional)"}),e.jsx(c,{children:e.jsx(N,{type:"date",value:qe(a.value),onChange:t=>a.onChange(t.target.value?z(t.target.value):""),className:"bg-background/50","data-testid":"input-deadline"})}),e.jsx(u,{children:"Once this date passes, the opportunity automatically shows as Closed and stops accepting applications. Leave blank to keep it open with no end date."}),e.jsx(d,{})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(m,{control:i.control,name:"releaseDate",render:({field:a})=>e.jsxs(n,{children:[e.jsx(o,{children:"Release Date"}),e.jsx(c,{children:e.jsx(N,{type:"datetime-local",...a,value:a.value||"",min:new Date().toISOString().slice(0,16),className:"bg-background/50","data-testid":"input-release-date"})}),e.jsx(u,{children:"When this opportunity will be visible to all creators"}),e.jsx(d,{})]})}),f&&j.allAccess&&j.premium&&e.jsxs(q,{className:"border-rose-400/20 bg-gradient-to-r from-rose-50/50 to-purple-50/50 dark:from-rose-950/20 dark:to-purple-950/20",children:[e.jsx(G,{children:e.jsxs(K,{className:"text-lg flex items-center gap-2",children:[e.jsx(fe,{className:"w-5 h-5"}),"Early Access Timeline"]})}),e.jsxs(L,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-md border border-yellow-500/30 bg-yellow-50/50 dark:bg-yellow-950/20",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ye,{className:"w-5 h-5 text-yellow-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-sm",children:"All Access Members"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"48 hours early access"})]})]}),e.jsx("div",{className:"text-right",children:e.jsx(T,{variant:"outline",className:"bg-yellow-100 dark:bg-yellow-900/30",children:R(j.allAccess,"MMM dd, h:mm a")})})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-md border border-purple-500/30 bg-purple-50/50 dark:bg-purple-950/20",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ee,{className:"w-5 h-5 text-purple-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-sm",children:"VIP Members"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"24 hours early access"})]})]}),e.jsx("div",{className:"text-right",children:e.jsx(T,{variant:"outline",className:"bg-purple-100 dar
1k:bg-purple-900/30",children:R(j.premium,"MMM dd, h:mm a")})})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-md border border-gray-300 dark:border-gray-700 bg-gray-50/50 dark:bg-gray-950/20",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ne,{className:"w-5 h-5 text-gray-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-sm",children:"All Creators"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"General release"})]})]}),e.jsx("div",{className:"text-right",children:e.jsx(T,{variant:"outline",children:R(new Date(f),"MMM dd, h:mm a")})})]})]}),e.jsx(Ae,{className:"border-rose-400/20",children:e.jsxs(Pe,{className:"text-xs",children:[e.jsx("strong",{children:"Note:"})," Early access timing helps create urgency and rewards VIP members with first-look opportunities."]})})]})]})]}),e.jsxs("div",{className:"flex gap-4 pt-4",children:[e.jsx(b,{type:"submit",disabled:I.isPending||S,className:"bg-gradient-to-r from-primary to-accent hover:from-primary hover:to-accent text-primary-foreground festival-glow","data-testid":"button-update-campaign",children:I.isPending||S?e.jsxs(e.Fragment,{children:[e.jsx(we,{className:"mr-2 h-4 w-4 animate-spin"}),S?"Uploading...":"Updating..."]}):"Update Campaign"}),e.jsx(b,{type:"button",variant:"outline",onClick:()=>w("/campaigns"),disabled:I.isPending||S,"data-testid":"button-cancel",children:"Cancel"})]})]})})})]})]}):e.jsxs("div",{className:"max-w-4xl space-y-6",children:[e.jsxs(b,{variant:"ghost",onClick:()=>w("/campaigns"),className:"gap-2","data-testid":"button-back",children:[e.jsx(J,{className:"w-4 h-4"}),"Back to Campaigns"]}),e.jsx(q,{children:e.jsx(L,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"Campaign not found"})})})]})}export{oa 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.