1import{O as l}from"./index-DXi0I5ak.js";import"./vendor-ahVw9cdH.js";import"./radix--pSzM2y8.js";import"./supabase-DYrB2Yg5.js";import"./charts-CSweoJhv.js";import"./query-CeIq2NOR.js";import"./forms-Cc1FL3tT.js";const _={junior_development:"junior_development",elite_amateur:"high_performance_tour",professional:"high_performance_tour",mental_coaching:"mental_performance",technical:"technical_full_swing",mental_performance:"mental_performance",physical_on_course:"physical_on_course",technical_full_swing:"technical_full_swing",short_game:"short_game",putting:"putting",strategy_course_management:"strategy_course_management",physical_fitness:"physical_fitness",high_performance_tour:"high_performance_tour",general_instruction:"general_instruction"},y={recreational:"beginner",club_competition:"intermediate",national:"advanced",professional:"pro",beginner:"beginner",intermediate:"intermediate",advanced:"advanced",scratch:"scratch",pro:"pro",tour:"tour"},u={pga:"PGA",pgta:"PGTA",lpga:"LPGA",r_and_a:"R&A",trackman:"Trackman",titleist_tpi:"Titleist TPI"},s=e=>e==null||e===""||Array.isArray(e)&&e.length===0;function g(e){var r,a;const i=[];return e.certType==="other"&&((r=e.certOtherTitle)!=null&&r.trim())?i.push(e.certOtherTitle.trim()):e.certType&&u[e.certType]?i.push(u[e.certType]):e.certType&&i.push(e.certType),i.length===0?void 0:[(a=e.certId)!=null&&a.trim()?`${i[0]} (${e.certId.trim()})`:i[0]]}function f(e,i){if(!(e!=null&&e.length))return;const t=Array.from(new Set(e.map(r=>i[r]).filter(Boolean)));return t.length>0?t:void 0}async function h(e){const i=e==null?void 0:e.trim();if(!i)return;const{data:t}=await l.from("countries").select("id").ilike("name",i).maybeSingle();return t==null?void 0:t.id}async function d(e,i){const t=e==null?void 0:e.trim();if(!t||!i)return;const{data:r}=await l.from("towns").select("id").eq("country_id",i).ilike("name",t).maybeSingle();return r==null?void 0:r.id}async function j(e,i){var p,o;const t={},r={};s(i.name)&&((p=e.fullName)!=null&&p.trim())&&(t.name=e.fullName.trim()),s(i.website)&&((o=e.website)!=null&&o.trim())&&(t.website=e.website.trim());let a;if(s(i.country_id)&&(a=await h(e.country),a&&(t.country_id=a)),s(i.town_id)){const n=a??i.country_id??void 0,m=await d(e.city,n??void 0);m&&(t.town_id=m)}if(s(i.years_experience)){const n=typeof e.yearsExperience=="number"?e.yearsExperience:parseInt(String(e.yearsExperience??""),10);Number.isFinite(n)&&n>0&&(r.years_experience=n)}if(s(i.certifications)){const n=g(e);n&&(r.certifications=n)}if(s(i.specialties)){const n=f(e.specializations,_);n&&(r.specialties=n)}if(s(i.player_levels)){const n=f(e.competitiveLevels,y);n&&(r.player_levels=n)}const c=Object.keys(t).length+Object.keys(r).length;return{org:t,marketplace:r,fieldCount:c}}async function x(e,i){if(i.fieldCount!==0){if(Object.keys(i.org).length>0){const{error:t}=await l.from("organizations").update(i.org).eq("id",e);t&&console.warn("[coach-prefill] organizations update failed:",t)}if(Object.keys(i.marketplace).length>0){const{error:t}=await l.from("organization_marketplace_profile").upsert({organization_id:e,...i.marketplace},{onConflict:"organization_id"});t&&console.warn("[coach-prefill] marketplace upsert failed:",t)}}}async function S(e){const{data:i,error:t}=await l.from("organization_applications").select("id, application_details, status, contact_email, organization_name, country").eq("contact_email",e).order("created_at",{ascending:!1}).limit(1).maybeSingle();return t?(console.warn("[coach-prefill] fetch application failed:",t),null):i}function w(e){return g(e)??[]}function v(e){return f(e.specializations,_)??[]}function b(e){return f(e.competitiveLevels,y)??[]}function T(e){const i=typeof e.yearsExperience=="number"?e.yearsExperience:parseInt(String(e.yearsExperience??""),10);return Number.isFinite(i)&&i>0?i:null}function z(e,i){const t=(i==null?void 0:i.topicLabel)??(o=>o),r=(i==null?void 0:i.playerLevelLabel)??(o=>o),a=[],c=(o,n)=>{n&&n.trim()&&a.push({label:o,value:n.trim()})};c("Name",e.fullName),c("Location",[e.city,e.country].filter(o=>o&&String(o).trim()).join(", ")||void 0),c("Website",e.website),c("Certification",w(e).join(", ")||void 0);const p=T(e);return c("Years coaching",p===null?void 0:String(p)),c("Focus areas",v
1(e).map(t).join(", ")||void 0),c("Player levels",b(e).map(r).join(", ")||void 0),a}export{w as applicationCertifications,b as applicationPlayerLevels,v as applicationSpecialties,T as applicationYearsExperience,x as applyPrefillPatch,j as buildPrefillPatch,S as fetchLatestApplicationForEmail,z as summarizeApplication};
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.