1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[974],{446:(e,t,a)=>{"use strict";a.d(t,{SettingsProvider:()=>i,t:()=>n});var r=a(5155),s=a(2115);let l=(0,s.createContext)({timePreference:"chip",setTimePreference:()=>{},roundingEnabled:!1,setRoundingEnabled:()=>{},customMessage:"",setCustomMessage:()=>{},certificateTimeout:30,setCertificateTimeout:()=>{},timerLogoUrl:null,setTimerLogoUrl:()=>{},timerMessage:"",setTimerMessage:()=>{},backgroundColorPreference:"default",setBackgroundColorPreference:()=>{},customBackgroundColor:"#ffffff",setCustomBackgroundColor:()=>{},primaryColorPreference:"default",setPrimaryColorPreference:()=>{},customPrimaryColor:"#f54a87",setCustomPrimaryColor:()=>{}}),n=()=>(0,s.useContext)(l);function i(e){let{children:t}=e,[a,n]=(0,s.useState)("chip"),[i,o]=(0,s.useState)(!1),[c,d]=(0,s.useState)(""),[u,m]=(0,s.useState)(30),[f,h]=(0,s.useState)(null),[x,g]=(0,s.useState)(""),[p,b]=(0,s.useState)("default"),[y,j]=(0,s.useState)("#ffffff"),[N,w]=(0,s.useState)("default"),[v,C]=(0,s.useState)("#f54a87");return(0,r.jsx)(l.Provider,{value:{timePreference:a,setTimePreference:n,roundingEnabled:i,setRoundingEnabled:o,customMessage:c,setCustomMessage:d,certificateTimeout:u,setCertificateTimeout:m,timerLogoUrl:f,setTimerLogoUrl:h,timerMessage:x,setTimerMessage:g,backgroundColorPreference:p,setBackgroundColorPreference:b,customBackgroundColor:y,setCustomBackgroundColor:j,primaryColorPreference:N,setPrimaryColorPreference:w,customPrimaryColor:v,setCustomPrimaryColor:C},children:t})}},3150:(e,t,a)=>{"use strict";a.d(t,{RaceThemeProvider:()=>o,y:()=>i});var r=a(5155),s=a(2115);let l={logoUrl:null,primaryColor:"#f54a87",backgroundColor:"rgba(245, 74, 135, 0.1)",raceName:null,isLoading:!1},n=(0,s.createContext)({...l,setRaceTheme:async()=>{},isLoading:!1}),i=()=>(0,s.useContext)(n);function o(e){let{children:t}=e,[a,i]=(0,s.useState)(l),[o,c]=(0,s.useState)(!1),d=(0,s.useRef)({}),u=async(e,t)=>{if(!e){i(l);return}let a=e.toString();if(d.current[a]){i(d.current[a]);return}c(!0);try{let e=new AbortController,r=setTimeout(()=>e.abort(),5e3),s=await fetch("/api/race-theme?race_id=".concat(a),{signal:e.signal});if(clearTimeout(r),!s.ok)throw Error("API returned status ".concat(s.status));let l=await s.json();if(!l.primaryColor)throw Error("Invalid response: missing primaryColor");let n={logoUrl:l.logoUrl||null,primaryColor:l.primaryColor,backgroundColor:l.backgroundColor||"".concat(l.primaryColor,"10"),raceName:t||l.raceName||"Race ".concat(a)};d.current[a]=n,i(n)}catch(l){console.error("Error setting race theme:",l);let r="#f54a87";if(15721===e)r="#EC8110";else{let e=0;for(let t=0;t<a.length;t++)e=a.charCodeAt(t)+((e<<5)-e);r="#";for(let t=0;t<3;t++)r+=("00"+(e>>8*t&255).toString(16)).substr(-2)}let s={logoUrl:"/placeholder.svg?height=48&width=200&text=Race+".concat(a),primaryColor:r,backgroundColor:function(e,t){if(e.startsWith("#")){let t,a,r,s=e.substring(1);return 3===s.length?(t=Number.parseInt(s[0]+s[0],16),a=Number.parseInt(s[1]+s[1],16),r=Number.parseInt(s[2]+s[2],16)):(t=Number.parseInt(s.substring(0,2),16),a=Number.parseInt(s.substring(2,4),16),r=Number.parseInt(s.substring(4,6),16)),"rgba(".concat(t,", ").concat(a,", ").concat(r,", ").concat(.1,")")}return e.startsWith("rgba")?e.replace(/rgba$$(.+?),\s*[\d.]+$$/,"rgba($1, ".concat(t,")")):e.startsWith("rgb")?e.replace(/rgb$$(.+?)$$/,"rgba($1, ".concat(t,")")):"rgba(245, 74, 135, ".concat(t,")")}(r,.1),raceName:t||"Race ".concat(a)};d.current[a]=s,i(s)}finally{c(!1)}};return(0,r.jsx)(n.Provider,{value:{...a,setRaceTheme:u,isLoading:o},children:t})}},4176:(e,t,a)=>{Promise.resolve().then(a.bind(a,8443))},8443:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>es});var r=a(5155),s=a(2115),l=a(3150),n=a(446),i=a(6766),o=a(1482),c=a(7924),d=a(9708),u=a(2085),m=a(2596),f=a(9688);function h(){for(var e=arguments.length,t=Array(e),a=0;a<e;a++)t[a]=arguments[a];return(0,f.QP)((0,m.$)(t))}let x=(0,u.F)("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-gradient-to-r from-brand to-brand-dark text-white hover:bg-gradient-to-r hover:from-brand-dark hover:to-brand",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-brand-light text-gray-200 hover:bg-gray-800",secondary:"bg-gray-700 text-gray-200 hover:bg-gray-600",ghost:"hover:bg-gray-800 hover:text-white",link:"text-brand-light underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),g=s.forwardRef((e,t)=>
1{let{className:a,variant:s,size:l,asChild:n=!1,...i}=e,o=n?d.DX:"button";return(0,r.jsx)(o,{className:h(x({variant:s,size:l,className:a})),ref:t,...i})});g.displayName="Button";let p=s.forwardRef((e,t)=>{let{className:a,type:s,...l}=e;return(0,r.jsx)("input",{type:s,className:h("flex h-10 w-full rounded-md border bg-gray-700/70 border-gray-600 px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-gray-400 focus-visible:outline-none focus-visible:border-brand-light focus-visible:ring-1 focus-visible:ring-brand-light disabled:cursor-not-allowed disabled:opacity-50",a),ref:t,...l})});p.displayName="Input";let b=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.jsx)("div",{ref:t,className:h("rounded-lg border border-gray-700 shadow-sm card-gradient",a),...s})});b.displayName="Card";let y=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.jsx)("div",{ref:t,className:h("flex flex-col space-y-1.5 p-6",a),...s})});y.displayName="CardHeader";let j=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.jsx)("h3",{ref:t,className:h("text-2xl font-semibold leading-none tracking-tight text-white",a),...s})});j.displayName="CardTitle";let N=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.jsx)("p",{ref:t,className:h("text-sm text-gray-400",a),...s})});N.displayName="CardDescription";let w=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.jsx)("div",{ref:t,className:h("p-6 pt-0",a),...s})});w.displayName="CardContent";let v=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.jsx)("div",{ref:t,className:h("flex items-center p-6 pt-0",a),...s})});v.displayName="CardFooter";let C=(0,u.F)("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-brand text-white hover:bg-brand-dark",secondary:"border-transparent bg-gray-700 text-gray-200 hover:bg-gray-600",destructive:"border-transparent bg-red-900/30 text-red-300 border-red-800",outline:"text-gray-300 border-gray-700"}},defaultVariants:{variant:"default"}});function S(e){let{className:t,variant:a,...s}=e;return(0,r.jsx)("div",{className:h(C({variant:a}),t),...s})}var R=a(3786);function k(e){let{races:t,onSelectRace:a}=e,s=e=>!!e&&new Date(e)>new Date,l=e=>{console.log("Checking draft status for race: ".concat(e.name," (ID: ").concat(e.race_id,")"),e);let t=e.name&&["draft","test","copy","duplicate","template","demo"].some(t=>e.name.toLowerCase().includes(t)),a="draft"===e.status||"draft"===e.race_status||!0===e.is_draft||!1===e.published,r=!0===e.is_private||!0===e.hidden;return(t||a||r)&&console.log('Race "'.concat(e.name,'" (ID: ').concat(e.race_id,") is a draft:"),{nameCheck:t,statusCheck:a,privateCheck:r,status:e.status,race_status:e.race_status,is_draft:e.is_draft,published:e.published,is_private:e.is_private,hidden:e.hidden}),t||a||r};return(0,r.jsxs)(b,{children:[(0,r.jsx)(y,{children:(0,r.jsxs)(j,{children:["Search Results (",t.length," races found)"]})}),(0,r.jsx)(w,{children:(0,r.jsx)("div",{className:"space-y-4",children:t.map(e=>{var t,a,n;let i=e.race||e,o=s(i.next_date||i.last_date),c=l(i);return(0,r.jsxs)("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center p-4 border border-gray-700 rounded-md race-card-gradient hover:border-brand-light transition-colors",children:[(0,r.jsxs)("div",{className:"mb-3 sm:mb-0 w-full sm:w-auto",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)("h3",{className:"font-medium text-white",children:i.name}),o&&(0,r.jsx)(S,{variant:"outline",className:"bg-brand-dark/20 text-brand-light border-brand-light",children:"Upcoming"}),c&&(0,r.jsx)(S,{variant:"destructive",className:"bg-amber-900/20 text-amber-300 border-amber-700",children:"Draft"})]}),(0,r.jsxs)("div",{className:"text-sm text-gray-400 mt-1",children:[(0,r.jsx)("span",{children:(n=i.next_date||i.last_date)?new Date(n).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"Date not available"}),(null===(t=i.address)||void 0===t?void 0:t.city)&&(null===(a=i.address)||void 0===a?void 0:a.state)&&(0,r.jsxs)("span",{children:[" ","⢠",i.address.city,", ",i.address.state]})]})]}),(0,r.jsx)("div",{className:"flex w-full sm:w-auto",children:(0,r.jsx)("a",{href:"https://runsignup.com/Race/Results/".concat(i.race_id),target:"_blank",rel:"noopener noreferrer",className:"w-full sm:w-auto",children:(0,r.jsxs)(g,{variant:"default",className:"w-full flex items-center justify-center gap-1",children:["Overall Results",(0,r.jsx)(R.A,{className:"h-3.5 w-3.5 ml-1"})]})})})]},i.race_id)})})})]})}var _=a(6671),A=a(6981),P=a(5196);let I=s.forwardRef((e,t)=>
1{let{className:a,...s}=e;return(0,r.jsx)(A.bL,{ref:t,className:h("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",a),...s,children:(0,r.jsx)(A.C1,{className:h("flex items-center justify-center text-current"),children:(0,r.jsx)(P.A,{className:"h-4 w-4"})})})});I.displayName=A.bL.displayName;var D=a(2797);let E=(0,u.F)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),U=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.jsx)(D.b,{ref:t,className:h(E(),a),...s})});U.displayName=D.b.displayName;var F=a(8176);let L=F.bL,T=F.l9,z=s.forwardRef((e,t)=>{let{className:a,align:s="center",sideOffset:l=4,...n}=e;return(0,r.jsx)(F.ZL,{children:(0,r.jsx)(F.UC,{ref:t,align:s,sideOffset:l,className:h("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...n})})});z.displayName=F.UC.displayName;var $=a(9074);function Y(e){let{onViewOrganizationRaces:t}=e;return(0,r.jsx)("div",{className:"flex flex-col sm:flex-row gap-2 mt-4",children:(0,r.jsxs)(g,{type:"button",variant:"outline",onClick:t,className:"w-full sm:w-auto flex items-center justify-center gap-2",children:[(0,r.jsx)($.A,{className:"h-4 w-4 text-brand-light"}),"View IRUNCT Races"]})})}function O(e){let{onSelectRace:t,onViewOrganizationRaces:a,inDialog:n=!1}=e,[i,d]=(0,s.useState)(""),[u,m]=(0,s.useState)(!1),[f,h]=(0,s.useState)([]),[x,y]=(0,s.useState)(""),{setRaceTheme:j,isLoading:N}=(0,l.y)(),[v,C]=(0,s.useState)(!1),[S,R]=(0,s.useState)(!1),A=async e=>{if(e.preventDefault(),i.trim()){m(!0),h([]),y(""),n||await j(null);try{let e=new Date,t=new Date(e);t.setFullYear(e.getFullYear()-1);let a=new Date(e);a.setDate(e.getDate()+60);let r=e=>e.toISOString().split("T")[0],s=r(t),l=r(a),n=new AbortController,o=setTimeout(()=>n.abort(),1e4),c="/api/search-races";S&&/^\d+$/.test(i.trim())?c+="?race_id=".concat(i.trim()):c+="?term=".concat(encodeURIComponent(i),"&start_date=").concat(s,"&end_date=").concat(l,"&include_without_results=").concat(v);let d=await fetch(c,{signal:n.signal});if(clearTimeout(o),!d.ok)throw Error("API returned status ".concat(d.status));let u=await d.json();u.races&&Array.isArray(u.races)?(h(u.races),0===u.races.length&&y("No races found matching your search criteria")):y("Invalid response from API")}catch(e){y("AbortError"===e.name?"Search timed out. Please try again.":"Error searching for races. Please try again."),console.error(e)}finally{m(!1)}}},P=async e=>{if(!n){let t=e.race_id,a=e.name||e.race&&e.race.name;if(t)try{await j(t,a)}catch(e){console.error("Error setting race theme:",e),_.oR.error("Could not load race theme, using default instead")}}t(e)};return(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsx)(b,{className:n?"shadow-none border-0":"",children:(0,r.jsxs)(w,{className:n?"p-0":"pt-6",children:[(0,r.jsxs)("form",{onSubmit:A,className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(p,{type:"text",placeholder:S?"Enter race ID (e.g., 163949)":"Search for races (e.g., Miles for Files)",value:i,onChange:e=>d(e.target.value),className:"flex-1"}),(0,r.jsxs)(L,{children:[(0,r.jsx)(T,{asChild:!0,children:(0,r.jsxs)(g,{variant:"outline",size:"icon",type:"button",children:[(0,r.jsx)(o.A,{className:"h-4 w-4 text-brand-light"}),(0,r.jsx)("span",{className:"sr-only",children:"Filter options"})]})}),(0,r.jsx)(z,{className:"w-80 bg-gray-800 border-gray-700",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("h4",{className:"font-medium text-white",children:"Search Options"}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)(I,{id:"include-without-results",checked:v,onCheckedChange:e=>C(!0===e),className:"data-[state=checked]:bg-brand data-[state=checked]:border-brand-light"}),(0,r.jsx)(U,{htmlFor:"include-without-results",className:"text-gray-300",children:"Include races without results"})]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)(I,{id:"search-by-race-id",checked:S,onCheckedChange:e=>R(!0===e),className:"data-[state=checked]:bg-brand data-[state=checked]:border-brand-light"}),(0,r.jsx)(U,{htmlFor:"search-by-race-id",className:"text-gray-300",children:"Search by race ID"})]})]})})]}),(0,r.jsx)(g,{type:"submit",disabled:u,children:u?(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Searching..."]}):(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[(0,r.jsx)(c.A,{className:"h-4 w-4"}),"Search"]})})]}),(0,r.jsx)("div",{className:"text-sm text-gray-400",children:S?"Enter a race ID to find a specific race":(0,r.jsxs)(r.Fragment,{children:["Searching for races from ",function(){let e=new Date,t=new Date(e);t.setFullYear(e.getFullYear()-1);let a=new Date(e);a.setDate(e.getDate()+60);let r=e=>e.toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});return"".concat(r(t)," to ").concat(r(a))}()," ",!v&&"with results available",". Only showing events for the current year."]})})]}),!n&&a&&(0,r.jsx)(Y,{onViewOrganizationRaces:a})]})}),x&&(0,r.jsx)("div",{className:"bg-red-900/30 text-red-300 p-4 rounded-md border border-red-800",children:x}),N&&!n&&(0,r.jsxs)("div",{className:"bg-brand-dark/20 text-brand-light p-4 rounded-md flex items-center gap-2 border border-brand-light",children:[(0,r.jsx)("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),(0,r.jsx)("span",{children:"Loading race theme..."})]}),f.length>0&&(0,r.jsx)(k,{races:f,onSelectRace:P})]})}var M=a(3904),V=a(7550),B=a(2138);function W(e){let{className:t,...a}=e;return(0,r.jsx)("div",{className:h("animate-pulse rounded-md bg-muted",t),...a})}var G=a(1610),J=a(6474),q=a(7863);let H=G.bL;G.YJ;let Z=G.WT,K=s.forwardRef((e,t)=>
1{let{className:a,children:s,...l}=e;return(0,r.jsxs)(G.l9,{ref:t,className:h("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",a),...l,children:[s,(0,r.jsx)(G.In,{asChild:!0,children:(0,r.jsx)(J.A,{className:"h-4 w-4 opacity-50"})})]})});K.displayName=G.l9.displayName;let Q=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.jsx)(G.PP,{ref:t,className:h("flex cursor-default items-center justify-center py-1",a),...s,children:(0,r.jsx)(q.A,{className:"h-4 w-4"})})});Q.displayName=G.PP.displayName;let X=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.jsx)(G.wn,{ref:t,className:h("flex cursor-default items-center justify-center py-1",a),...s,children:(0,r.jsx)(J.A,{className:"h-4 w-4"})})});X.displayName=G.wn.displayName;let ee=s.forwardRef((e,t)=>{let{className:a,children:s,position:l="popper",...n}=e;return(0,r.jsx)(G.ZL,{children:(0,r.jsxs)(G.UC,{ref:t,className:h("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2","popper"===l&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",a),position:l,...n,children:[(0,r.jsx)(Q,{}),(0,r.jsx)(G.LM,{className:h("p-1","popper"===l&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),(0,r.jsx)(X,{})]})})});ee.displayName=G.UC.displayName,s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.jsx)(G.JU,{ref:t,className:h("py-1.5 pl-8 pr-2 text-sm font-semibold",a),...s})}).displayName=G.JU.displayName;let et=s.forwardRef((e,t)=>{let{className:a,children:s,...l}=e;return(0,r.jsxs)(G.q7,{ref:t,className:h("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),...l,children:[(0,r.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,r.jsx)(G.VF,{children:(0,r.jsx)(P.A,{className:"h-4 w-4"})})}),(0,r.jsx)(G.p4,{children:s})]})});function ea(e){let{onSelectRace:t,onBack:a}=e,[n,i]=(0,s.useState)([]),[o,d]=(0,s.useState)(!0),[u,m]=(0,s.useState)(""),[f,h]=(0,s.useState)(1),[x,p]=(0,s.use
1State)(0),[C,R]=(0,s.useState)(0),[_,A]=(0,s.useState)(0),[P,I]=(0,s.useState)(50),{setRaceTheme:D}=(0,l.y)(),[E,F]=(0,s.useState)(!0),L=new Date().getFullYear(),[T,z]=(0,s.useState)(L.toString()),[Y,O]=(0,s.useState)(!0),G=(()=>{let e=[];for(let t=L;t>=2016;t--)e.push(t.toString());return e})(),J=e=>{let t=0;return e.forEach(e=>{let a=e.race||e,r=a.name&&["draft","test","copy","duplicate","template","demo"].some(e=>a.name.toLowerCase().includes(e));("draft"===a.status||"draft"===a.race_status||!0===a.is_draft||!1===a.published||r||!0===a.is_private||!0===a.hidden)&&t++}),t},q=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;d(!0),m("");try{await D(null);let t=await fetch("/api/organization-races?page=".concat(e,"&results_per_page=").concat(P,"&include_drafts=true&year=").concat(T));if(!t.ok)throw Error("API returned status ".concat(t.status));let a=await t.json();if(a.error&&"API credentials not configured"===a.error){F(!1),m("RunSignup API credentials are not configured. Please add them to your environment variables."),i([]);return}let r=a.races||[],s=r.filter(e=>{let t=e.race||e,a=t.next_date||t.last_date;if(!a)return!0;let r=new Date(a);return 2025!==r.getFullYear()||3!==r.getMonth()||6!==r.getDate()});console.log("Filtered out ".concat(r.length-s.length," races scheduled for April 6, 2025"));let l=J(s);A(l),i(s),p(s.length),R(a.yearFiltered||0),h(a.page||e),0===r.length&&m("No races found for your organization in ".concat(T,"."))}catch(e){m("Error loading races: ".concat(e.message)),console.error(e)}finally{d(!1)}};(0,s.useEffect)(()=>{q(f)},[f,T]);let Q=e=>{h(e)},X=Math.ceil(x/P);return(0,r.jsx)("div",{className:"space-y-6",children:(0,r.jsxs)(b,{children:[(0,r.jsxs)(y,{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(j,{children:"IRUNCT Race Results"}),(0,r.jsxs)(S,{variant:"outline",className:"ml-2 border-brand-light text-gray-300",children:[(0,r.jsx)($.A,{className:"h-3 w-3 mr-1 text-brand-light"}),T]})]}),(0,r.jsx)(N,{children:!o&&!u&&n.length>0&&(0,r.jsxs)(r.Fragment,{children:["Showing ",n.length," races from ",T,_>0&&(0,r.jsxs)("span",{className:"ml-1 text-amber-400",children:["(including ",_," draft ",1===_?"race":"races",")"]})]})})]}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,r.jsx)(g,{variant:"outline",onClick:()=>q(f),disabled:o,className:"w-full sm:w-auto",children:o?(0,r.jsxs)("span",{className:"flex items-center justify-center gap-2",children:[(0,r.jsx)("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Loading..."]}):(0,r.jsxs)("span",{className:"flex items-center justify-center gap-2",children:[(0,r.jsx)(M.A,{className:"h-4 w-4 text-brand-light"}),"Refresh"]})}),(0,r.jsxs)(g,{variant:"outline",onClick:a,className:"w-full sm:w-auto",children:[(0,r.jsx)(c.A,{className:"h-4 w-4 mr-2 text-brand-light"}),(0,r.jsx)("span",{className:"whitespace-nowrap",children:"Search All Races In The USA"})]})]})]}),(0,r.jsxs)(w,{children:[(0,r.jsx)("div",{className:"mb-4 flex flex-col sm:flex-row sm:items-center gap-4",children:(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)(U,{htmlFor:"year-select",className:"text-gray-300 whitespace-nowrap",children:"Year:"}),(0,r.jsxs)(H,{value:T,onValueChange:e=>{z(e),h(1)},children:[(0,r.jsx)(K,{id:"year-select",className:"w-28 bg-gray-700 border-gray-600",children:(0,r.jsx)(Z,{placeholder:"Year"})}),(0,r.jsx)(ee,{className:"bg-gray-800 border-gray-700 max-h-60 overflow-y-auto",children:G.map(e=>(0,r.jsx)(et,{value:e,className:"text-gray-300 focus:bg-gray-700 focus:text-white",children:e},e))})]})]})}),o?(0,r.jsx)("div",{className:"space-y-4",children:Array.from({length:5}).map((e,t)=>(0,r.jsx)(b,{children:(0,r.jsxs)(w,{className:"p-4",children:[(0,r.jsx)(W,{className:"h-6 w-3/4 mb-2 bg-gray-700"}),(0,r.jsx)(W,{className:"h-4 w-1/2 bg-gray-700"})]})},t))}):u?(0,r.jsxs)("div",{className:"bg-red-900/30 text-red-300 p-4 rounded-md border border-red-800",children:[u,!E&&(0,r.jsxs)("div",{className:"mt-4",children:[(0,r.jsx)("p",{className:"font-medium",children:"How to configure API credentials:"}),(0,r.jsxs)("ol",{className:"list-decimal ml-5 mt-2 space-y-1",children:[(0,r.jsx)("li",{children:"Add RUNSIGNUP_API_KEY and RUNSIGNUP_API_SECRET to your environment variables"}),(0,r.jsx)("li",{children:"Restart your application"}),(0,r.jsx)("li",{children:"Return to this page to view your organization races"})]})]})]}):n.length>0?(0,r.jsx)(k,{races:n,onSelectRace:t}):(0,r.jsx)("div",{className:"text-center py-8",children:(0,r.jsxs)("p",{className:"text-gray-400",children:["No races found for your organization in ",T,"."]})})]}),X>1&&(0,r.jsx)(v,{className:"flex justify-center pt-4",children:(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[(0,r.jsx)(g,{variant:"outline",size:"sm",onClick:()=>Q(f-1),disabled:f<=1||o,children:(0,r.jsx)(V.A,{className:"h-4 w-4"})}),(0,r.jsxs)("span",{className:"text-sm text-gray-300 px-2",children:["Page ",f," of ",X]}),(0,r.jsx)(g,{variant:"outline",size:"sm",onClick:()=>Q(f+1),disabled:f>=X||o,children:(0,r.jsx)(B.A,{className:"h-4 w-4"})})]})})]})})}et.displayName=G.q7.displayName,s.forwardRef((e,t)=>
1{let{className:a,...s}=e;return(0,r.jsx)(G.wv,{ref:t,className:h("-mx-1 my-1 h-px bg-muted",a),...s})}).displayName=G.wv.displayName;var er=a(5695);function es(){let e=(0,er.useRouter)(),{logoUrl:t,primaryColor:a,backgroundColor:o,raceName:c,setRaceTheme:d}=(0,l.y)(),{primaryColorPreference:u,customPrimaryColor:m}=(0,n.t)(),[f,h]=(0,s.useState)(!1),[x,p]=(0,s.useState)(null),[b,y]=(0,s.useState)(!0),[j,N]=(0,s.useState)(!1),w=async e=>{try{await d(e.race_id,e.name||e.race&&e.race.name)}catch(e){console.error("Error setting race theme:",e)}p(e)},v=()=>{y(!1),N(!0)};return(0,r.jsxs)("div",{className:"min-h-screen",children:[(0,r.jsx)("header",{className:"py-4 px-4 sm:px-6 shadow-md logo-area-gradient",style:{background:"linear-gradient(to bottom, #111827, #1F2937)"},children:(0,r.jsxs)("div",{className:"container mx-auto flex flex-wrap items-center justify-between gap-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-4",children:[(0,r.jsxs)(g,{variant:"ghost",size:"icon",onClick:()=>{e.back()},className:"text-white hover:bg-gray-800",title:"Go back to previous page",children:[(0,r.jsx)(V.A,{className:"h-5 w-5"}),(0,r.jsx)("span",{className:"sr-only",children:"Go back"})]}),(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)(i.default,{src:"/iRunCT-Logo-White.png",alt:"iRunCT Logo",width:100,height:40,className:"h-10 sm:h-12 w-auto",priority:!0}),t?f?(0,r.jsx)("h1",{className:"text-lg sm:text-xl font-bold text-white",children:c||"Results Search"}):(0,r.jsxs)("div",{className:"h-10 sm:h-12 relative flex items-center",children:[(0,r.jsx)(i.default,{src:t||"/placeholder.svg",alt:c||"Race Logo",width:200,height:48,className:"h-full w-auto object-contain",onError:()=>h(!0),priority:!0,unoptimized:!0}),(0,r.jsx)("span",{className:"sr-only",children:c||"Race Search"})]}):(0,r.jsx)("h1",{className:"text-xl sm:text-2xl font-bold text-white",children:"Results Search"})]})]}),x&&c&&(0,r.jsx)("div",{className:"text-white font-bold text-lg sm:text-xl",children:c})]})}),(0,r.jsx)("main",{className:"container mx-auto py-4 sm:py-8 px-3 sm:px-4",children:b?(0,r.jsx)(ea,{onSelectRace:w,onBack:v}):j?(0,r.jsx)(O,{onSelectRace:w,onViewOrganizationRaces:()=>y(!0)}):(0,r.jsx)(ea,{onSelectRace:w,onBack:v})})]})}}},e=>{var t=t=>e(e.s=t);e.O(0,[34,441,684,358],()=>t(4176)),_N_E=e.O()}]);
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.