import{u as i}from"./useQuery-BPBYh37X.js";import{s as t}from"./client-DO0WN1kq.js";const _=e=>i({queryKey:["cidades",e],queryFn:async()=>{const{data:s,error:a}=await t.from("cidades").select("*").eq("estado_id",e).eq("is_active",!0).order("population",{ascending:!1});if(a)throw a;return s},enabled:!!e}),y=(e,s)=>i({queryKey:["cidade",e,s],queryFn:async()=>{const{data:a,error:o}=await t.from("estados").select("*").eq("slug",e).eq("is_active",!0).single();if(o)throw o;const{data:c,error:d}=await t.from("cidades").select("*").eq("slug",s).eq("estado_id",a.id).eq("is_active",!0).single();if(d)throw d;let n=null;try{const{data:r}=await t.from("city_demographics").select("population_60plus, elderly_ratio, median_household_income_brl, dominant_economic_sector, is_capital, is_metro_region_seat, ibge_sync_status").eq("cidade_id",c.id).maybeSingle();r&&r.ibge_sync_status==="success"&&(n=r)}catch{}return{...c,estado:{id:a.id,nome:a.nome,sigla:a.sigla,slug:a.slug},demographics:n}},enabled:!!e&&!!s}),m=()=>i({queryKey:["cidades-count"],queryFn:async()=>{const{count:e,error:s}=await t.from("cidades").select("*",{count:"exact",head:!0}).eq("is_active",!0);if(s)throw s;return e||0}});export{_ as a,y as b,m as u};