1import"../chunks/CWj6FrbW.js";import"../chunks/K9bMRwDS.js";import{p as Z,D as ee,i as ae,f as E,h as se,u as re,t as g,g as _,j as te,y as ne,s as d,c as l,C as t,F as n,L as h,o,B as oe,W as ie,z as le,A as P,$ as pe,r as p,n as N,v,q as C}from"../chunks/CrZuSITo.js";import{D as de}from"../chunks/B9UoeqEk.js";import{F as ce}from"../chunks/Dq474R-N.js";import{C as ge}from"../chunks/DcWUAgBk.js";import{g as u,i as he}from"../chunks/BWXuU_zM.js";import{p as ve}from"../chunks/Dk0cxk4R.js";var ue=E('<img class="brand-logo svelte-ghronr"/>'),me=E('<div class="brand-logo-placeholder svelte-ghronr"> </div>'),fe=E('<div class="sponsorships-page svelte-ghronr"><header class="page-header svelte-ghronr"><div class="breadcrumb svelte-ghronr"><a href="/admin/brands" class="svelte-ghronr">Brands</a> <span class="svelte-ghronr">/</span> <a class="svelte-ghronr"> </a> <span class="svelte-ghronr">/</span> <span class="svelte-ghronr">Sponsorships</span></div> <div class="header-row svelte-ghronr"><div class="brand-info svelte-ghronr"><!> <div><h1 class="svelte-ghronr"> </h1> <p class="subtitle svelte-ghronr">Manage sponsorship campaigns for this brand</p></div></div> <a class="btn-primary svelte-ghronr"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" class="svelte-ghronr"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"></path></svg> Create Sponsorship</a></div></header> <!> <!> <!></div>');function De(j,S){Z(S,!1);const[B,M]=ne(),z=()=>le(ve,"$page",B);let s=ee(S,"data",8),r=oe({open:!1,sponsorship:null,loading:!1});function w(e){return{ACTIVE:"#10b981",INACTIVE:"#6b7280",COMPLETED:"#6366f1",CANCELLED:"#ef4444",EXPIRED:"#f59e0b"}[e]||"#6b7280"}function R(e){var T,F;if(!e)return"-";const a=e.currency||"USD",i=((T=e.min)==null?void 0:T.toLocaleString())||"0",c=((F=e.max)==null?void 0:F.toLocaleString())||"0";return`${a} ${i} - ${c}`}const U=[{key:"title",label:"Sponsorship",sortable:!0,render:(e,a)=>{var i;return` 2 <a href="/admin/sponsorships/${a.id}" style="text-decoration: none; color: inherit; display: block;"> 3 <div style="font-weight: 500; color: #4f46e5;">${e}</div> 4 <div style="font-size: 0.75rem; color: #6b7280;"> 5 ${((i=a.categories)==null?void 0:i.slice(0,2).join(", "))||"No categories"} 6 </div> 7 </a> 8 `}},{key:"budget",label:"Budget",render:e=>R(e)},{key:"status",label:"Status",render:(e,a)=>` 9 <div style="display: flex; gap: 0.375rem; flex-wrap: wrap;"> 10 <span style="padding: 0.25rem 0.5rem; background: ${w(e)}20; color: ${w(e)}; font-size: 0.75rem; font-weight: 500; border-radius: 4px;">${e}</span> 11 ${a.isFeatured?'<span style="padding: 0.25rem 0.5rem; background: #fef3c7; color: #f59e0b; font-size: 0.75rem; font-weight: 500; border-radius: 4px;">Featured</span>':""} 12 </div> 13 `},{key:"applications",label:"Applications",render:(e,a)=>` 14 <span style="font-weight: 500;">${e}</span> 15 <span style="color: #9ca3af;">/ ${a.maxApplications}</span> 16 `},{key:"createdAt",label:"Created",sortable:!0,render:e=>new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}],V=[{key:"search",label:"Search",type:"text",placeholder:"Search sponsorships..."},{key:"status",label:"Status",type:"select",options:[{value:"ACTIVE",label:"Active"},{value:"INACTIVE",label:"Inactive"},{value:"COMPLETED",label:"Completed"},{value:"CANCELLED",label:"Cancelled"},{value:"EXPIRED",label:"Expired"}]}];function O(e){const a=new URLSearchParams;Object.entries(e.detail).forEach(([i,c])=>{c!==void 0&&c!==""&&c!==!1&&a.set(i,String(c))}),a.set("page","1"),u(`?${a.toString()}`)}function q(e){const a=new URLSearchParams(z().url.searchParams);a.set("page",e.toString()),u(`?${a.toString()}`)}async function X(){var e;if(o(r).sponsorship){h(r,o(r).loading=!0);try{const i=await(await fetch(`/apis/v1/admin/sponsorships/${o(r).sponsorship.id}`,{method:"DELETE"})).json();i.success?(P(r,{open:!1,sponsorship:null,loading:!1}),await he()):(alert(((e=i.error)==null?void 0:e.message)||"Failed to delete sponsorship"),h(r,o(r).loading=!1))}catch(a){console.error("Delete error:",a),alert("Failed to delete sponsorship"),h(r,o(r).loading=!1)}}}const H=[{label:"Applications",variant:"primary",onClick:e=>u(`/admin/applications?sponsorshipId=${e.id}`)},{label:"Edit",variant:"default",onClick:e=>u(`/admin/sponsorships/${e.id}`)},{label:"Delete",variant:"danger",onClick:e=>{P(r,{open:!0,sponsorship:e,loading:!1})}}];ae();var m=fe();se(e=>{g(()=>pe.title=`Sponsorships - ${n(s()),t(()=>s().brand.name)??""} - Admin`)});var f=l(m),b=l(f),$=d(l(b),4),W=l($,!0);p($),N(4),p(b);var D=d(b,2),y=l(D),k=l(y);{var G=e=>{var a=ue();g(()=>{v(a,"src",(n(s()),t(()=>s().brand.logo))),v(a,"alt",(n(s()),t(()=>s().brand.name)))}),_(e,a)},J=e=>{var a=me(),i=l(a,!0);p(a),g(()=>C(i,(n(s()),t(()=>
16s().brand.name[0])))),_(e,a)};re(k,e=>{n(s()),t(()=>s().brand.logo)?e(G):e(J,!1)})}var x=d(k,2),A=l(x),K=l(A);p(A),N(2),p(x),p(y);var Q=d(y,2);p(D),p(f);var L=d(f,2);ce(L,{get filters(){return V},get values(){return n(s()),t(()=>s().currentFilters)},$$events:{change:O}});var I=d(L,2);de(I,{get columns(){return U},get data(){return n(s()),t(()=>s().sponsorships)},get pagination(){return n(s()),t(()=>s().pagination)},get actions(){return H},emptyMessage:"No sponsorships found for this brand",$$events:{pageChange:e=>q(e.detail)}});var Y=d(I,2);{let e=ie(()=>(o(r),t(()=>{var a;return(a=o(r).sponsorship)==null?void 0:a.title})));ge(Y,{title:"Delete Sponsorship",get message(){return`Are you sure you want to delete '${o(e)??""}'? This action cannot be undone.`},confirmText:"Delete",get loading(){return o(r),t(()=>o(r).loading)},get open(){return o(r).open},set open(a){h(r,o(r).open=a)},$$events:{confirm:X},$$legacy:!0})}p(m),g(()=>{v($,"href",`/admin/brands/${n(s()),t(()=>s().brand.id)??""}`),C(W,(n(s()),t(()=>s().brand.name))),C(K,`${n(s()),t(()=>s().brand.name)??""} Sponsorships`),v(Q,"href",`/admin/brands/${n(s()),t(()=>s().brand.id)??""}/sponsorships/new`)}),_(j,m),te(),M()}export{De as component};
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.