1import{aC as k,r as h,aD as j,aE as G,aF as M,aG as T,aH as V,aI as z,s as D,j as n,L as v,ak as I,p as L,d as H}from"./index-BuNt6ydv.js";import{A as S}from"./arrow-left-Bq3zN7V1.js";import{C as P}from"./clock-BWJy3j_F.js";import{E as q}from"./eye-CJ3uPfn6.js";function O(e){if(Array.isArray(e))return e.flatMap(d=>O(d));if(typeof e!="string")return[];const r=[];let t=0,a,u,s,l,i;const o=()=>{for(;t<e.length&&/\s/.test(e.charAt(t));)t+=1;return t<e.length},c=()=>(u=e.charAt(t),u!=="="&&u!==";"&&u!==",");for(;t<e.length;){for(a=t,i=!1;o();)if(u=e.charAt(t),u===","){for(s=t,t+=1,o(),l=t;t<e.length&&c();)t+=1;t<e.length&&e.charAt(t)==="="?(i=!0,t=l,r.push(e.slice(a,s)),a=t):t=s+1}else t+=1;(!i||t>=e.length)&&r.push(e.slice(a))}return r}function B(e){return e instanceof Headers?e:Array.isArray(e)?new Headers(e):typeof e=="object"?new Headers(e):null}function U(...e){return e.reduce((r,t)=>{const a=B(t);if(!a)return r;for(const[u,s]of a.entries())u==="set-cookie"?O(s).forEach(l=>r.append("set-cookie",l)):r.set(u,s);return r},new Headers)}function Y(e){const r=k();return h.useCallback(async(...t)=>{try{const a=await e(...t);if(j(a))throw a;return a}catch(a){if(j(a))return a.options._fromLocation=r.stores.location.get(),r.navigate(r.resolveRedirect(a).options);throw a}},[r,e])}function F(e){return e!=="__proto__"&&e!=="constructor"&&e!=="prototype"}function N(e,r){const t=Object.create(null);if(e)for(const a of Object.keys(e))F(a)&&(t[a]=e[a]);if(r&&typeof r=="object")for(const a of Object.keys(r))F(a)&&(t[a]=r[a]);return t}function R(e){return Object.create(null)}var A=()=>{throw new Error("createServerOnlyFn() functions can only be called on the server!")},b=(e,r)=>{const t=r||e||{};return typeof t.method>"u"&&(t.method="GET"),Object.assign(s=>b(void 0,{...t,...s}),{options:t,middleware:s=>{const l=[...t.middleware||[]];s.map(o=>{M in o?o.options.middleware&&l.push(...o.options.middleware):l.push(o)});const i=b(void 0,{...t,middleware:l});return i[M]=!0,i},inputValidator:s=>b(void 0,{...t,inputValidator:s}),handler:(...s)=>{const[l,i]=s,o={...t,extractedFn:l,serverFn:i},c=[...o.middleware||[],W(o)];return l.method=t.method,Object.assign(async d=>{const p=await $(c,"client",{...l,...o,data:d?.data,headers:d?.headers,signal:d?.signal,fetch:d?.fetch,context:R()}),x=G(p.error);if(x)throw x;if(p.error)throw p.error;return p.result},{...l,method:t.method,__executeServer:async d=>{const p=A(),x=p.contextAfterGlobalMiddlewares;return await $(c,"server",{...l,...d,serverFnMeta:l.serverFnMeta,context:N(d.context,x),request:p.request}).then(g=>({result:g.result,error:g.error,context:g.sendContext}))}})}})};async function $(e,r,t){let a=J([...T()?.functionMiddleware||[],...e]);if(r==="server"){const s=A();s?.executedRequestMiddlewares&&(a=a.filter(l=>!s.executedRequestMiddlewares.has(l)))}const u=async s=>{const l=a.shift();if(!l)return s;try{"inputValidator"in l.options&&l.options.inputValidator&&r==="server"&&(s.data=await K(l.options.inputValidator,s.data));let i;if(r==="client"?"client"in l.options&&(i=l.options.client):"server"in l.options&&(i=l.options.server),i){const c=await i({...s,next:async(d={})=>{const p=await u({...s,...d,context:N(s.context,d.context),sendContext:N(s.sendContext,d.sendContext),headers:U(s.headers,d.headers),_callSiteFetch:s._callSiteFetch,fetch:s._callSiteFetch??d.fetch??s.fetch,result:d.result!==void 0?d.result:d instanceof Response?d:s.result,error:d.error??s.error});if(p.error)throw p.error;return p}});if(j(c))return{...s,error:c};if(c instanceof Response)return{...s,result:c};if(!c)throw new Error("User middleware returned undefined. You must call next() or return a result in your middlewares.");return c}return u(s)}catch(i){return{...s,error:i}}};return u({...t,headers:t.headers||{},sendContext:t.sendContext||{},context:t.context||R(),_callSiteFetch:t.fetch})}function J(e,r=100){const t=new Set,a=[],u=(s,l)=>{if(l>r)throw new Error(`Middleware nesting depth exceeded maximum of ${r}. Check for circular references.`);s.forEach(i=>{i.options.middleware&&u(i.options.middleware,l+1),t.has(i)||(t.add(i),a.push(i))})};return u(e,0),a}async function K(e,r){if(e==null)return{};if("~standard"in e){const t=await e["~standard"].validate(r);if(t.issues)throw new Error(JSON.stringify(t.issues,void 0,2));return t.value}if("parse"in e)return e.parse(r);if(typeof e=="function")return e(r);throw new Error("Invalid validator type!")}function W(e){return{"~types":void 0,options:{inputValidator:e.inputValidator,client:async({next:r,sendContext:t,fetch:a,...u})=>{const s={...u,context:t,fetch:a};return r(await e.extractedFn?.(s))},server:async({next:r,...t})=>{const a=await e.serverFn?.(t);return r({...t,result:a})}}}}const Z=b({method:"POST"}
1).handler(V("62520be76403d0318e8d59dc46eccd9d98f8fc8c968e22019d5d362033b48b60")),Q=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),X=[{label:"la recette complète du poulet DG maison avec la Marinade Poulet Mamiza",to:"/recette/$slug",params:{slug:"recette-poulet-dg-maison-marinade-poulet-mamiza"}},{label:"la recette complète du poulet DG maison",to:"/recette/$slug",params:{slug:"recette-poulet-dg-maison-marinade-poulet-mamiza"}},{label:"la recette complète du poulet DG",to:"/recette/$slug",params:{slug:"recette-poulet-dg-maison-marinade-poulet-mamiza"}},{label:"recette complète du poulet DG",to:"/recette/$slug",params:{slug:"recette-poulet-dg-maison-marinade-poulet-mamiza"}},{label:"recette du poulet DG",to:"/recette/$slug",params:{slug:"recette-poulet-dg-maison-marinade-poulet-mamiza"}},{label:"poulet DG maison",to:"/recette/$slug",params:{slug:"recette-poulet-dg-maison-marinade-poulet-mamiza"}}],E=[...X,...L.map(e=>({label:e.name,to:"/produit/$slug",params:{slug:e.slug}})),...H.map(e=>({label:e.title,to:"/recette/$slug",params:{slug:e.slug}}))].sort((e,r)=>r.label.length-e.label.length);function ee(e,r){if(!e)return[e];const t=new RegExp(`(${E.map(s=>Q(s.label)).join("|")})`,"g"),a=e.split(t),u=new Set;return a.map((s,l)=>{const i=E.find(c=>c.label===s);if(!i)return n.jsx(h.Fragment,{children:s},l);const o=`${i.to}:${i.params.slug}`;return i.params.slug===r||u.has(o)?n.jsx(h.Fragment,{children:s},l):(u.add(o),n.jsx(v,{to:i.to,params:i.params,className:"text-terroir underline decoration-terroir/40 underline-offset-4 hover:decoration-terroir",children:s},l))})}function ae(){const{slug:e}=z({from:"/blog/$slug"}),[r,t]=h.useState(null),[a,u]=h.useState(!0),s=Y(Z);h.useEffect(()=>{D.from("posts").select("id,title,slug,excerpt,content,cover_image_url,published_at,category,tags,view_count").eq("slug",e).eq("published",!0).maybeSingle().then(({data:o})=>{const c=o??null;t(c),u(!1),c?.id&&s({data:{postId:c.id}}).catch(()=>{})})},[e,s]);const{sections:l,readingTime:i}=h.useMemo(()=>{if(!r?.content)return{sections:[],readingTime:0};const o=r.content.split(/\r?\n/),c=[];let d={id:"intro",title:"Introduction",body:[]};c.push(d);const p=m=>m.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,60),x=(m,w,y)=>{const f=m.trim();return!f||f.length>90||/^[â¢\-\*\d]/.test(f)||/[.:,;]$/.test(f)||w.trim()!==""||y.trim()!==""?!1:/^[A-ZÃ-ÃÃ-Ã]/.test(f)};for(let m=0;m<o.length;m++){const w=o[m],y=o[m-1]??"",f=o[m+1]??"";if(x(w,y,f)){const _=w.trim();d={id:p(_)||`section-${c.length}`,title:_,body:[]},c.push(d)}else d.body.push(w)}const g=c.map(m=>({...m,body:m.body.join(` 2`).trim()})).filter(m=>m.body.length>0||m.title!=="Introduction").map(m=>({...m,body:m.body.split(` 3`)})),C=r.content.split(/\s+/).filter(Boolean).length;return{sections:g,readingTime:Math.max(1,Math.round(C/220))}},[r?.content]);return a?n.jsx("div",{className:"mx-auto max-w-3xl px-4 py-20 text-sm text-muted-foreground",children:"Chargementâ¦"}):r?n.jsxs("div",{className:"mx-auto max-w-6xl px-4 py-12 sm:px-6 lg:py-20",children:[n.jsxs(v,{to:"/blog",className:"inline-flex items-center gap-2 text-xs uppercase tracking-[0.2em] text-terroir hover:underline",children:[n.jsx(S,{className:"h-3.5 w-3.5"})," Le carnet"]}),n.jsxs("header",{className:"mt-8 max-w-3xl",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-[11px] uppercase tracking-[0.3em]",children:[r.category&&n.jsx("span",{className:"text-terroir",children:r.category}),r.category&&r.published_at&&n.jsx("span",{className:"text-muted-foreground",children:"·"}),r.published_at&&n.jsx("span",{className:"text-muted-foreground",children:new Date(r.published_at).toLocaleDateString("fr-FR",{day:"numeric",month:"long",year:"numeric"})})]}),n.jsx("h1",{className:"mt-4 font-display text-4xl leading-tight sm:text-5xl",children:r.title}),r.excerpt&&n.jsx("p",{className:"mt-5 text-lg text-muted-foreground",children:r.excerpt}),n.jsxs("div",{className:"mt-6 flex flex-wrap items-center gap-5 border-t border-border/60 pt-5 text-xs text-muted-foreground",children:[n.jsxs("span",{className:"inline-flex items-center gap-2",children:[n.jsx(I,{className:"h-3.5 w-3.5"})," Terre & Saveurs"]}),n.jsxs("span",{className:"inline-flex items-center gap-2",children:[n.jsx(P,{className:"h-3.5 w-3.5"})," ",i," min de lecture"]}),n.jsxs("span",{className:"inline-flex items-center gap-2",children:[n.jsx(q,{className:"h-3.5 w-3.5"})," ",r.view_count??0," vues"]})]})]}),r.cover_image_url&&n.jsx("img",{src:r.cover_image_url,alt:r.title,className:"mt-10 aspect-[16/9] w-full rounded-sm object-cover"}),n.jsxs("div",{className:"mt-12 grid gap-12 lg:grid-cols-[1fr_240px]",children:[n.jsxs("article",{className:"min-w-0 max-w-3xl",children:[l.length>1&&n.jsxs("nav",{"aria-label":"Sommaire",className:"mb-10 rounded-sm border border-border/60 bg-secondary/30 p-6 lg:hidden",children:[n.jsx("p",{className:"text-[11px] uppercase tracking-[0.3em] text-terroir",children:"Sommaire"}),n.jsx("ol",{className:"mt-3 space-y-2 text-sm",children:l.map((o,c)=>n.jsx("li",{children:n.jsxs("a",{href:`#${o.id}
3`,className:"text-foreground/80 hover:text-terroir",children:[String(c+1).padStart(2,"0"),". ",o.title]})},o.id))})]}),l.map(o=>n.jsxs("section",{id:o.id,className:"mb-10 scroll-mt-24",children:[o.title!=="Introduction"&&n.jsx("h2",{className:"mb-4 font-display text-2xl leading-tight sm:text-3xl",children:o.title}),n.jsx("div",{className:"whitespace-pre-wrap font-body text-base leading-relaxed text-foreground/90",children:ee(o.body.join(` 4`),e)})]},o.id))]}),l.length>1&&n.jsx("aside",{className:"hidden lg:block",children:n.jsxs("div",{className:"sticky top-24",children:[n.jsx("p",{className:"text-[11px] uppercase tracking-[0.3em] text-terroir",children:"Sommaire"}),n.jsx("ol",{className:"mt-4 space-y-3 border-l border-border/60 pl-4 text-sm",children:l.map((o,c)=>n.jsx("li",{children:n.jsxs("a",{href:`#${o.id}`,className:"block text-foreground/70 transition hover:text-terroir",children:[n.jsx("span",{className:"mr-2 text-[11px] text-muted-foreground",children:String(c+1).padStart(2,"0")}),o.title]})},o.id))})]})})]})]}):n.jsxs("div",{className:"mx-auto max-w-3xl px-4 py-20 text-center",children:[n.jsx("h1",{className:"font-display text-3xl",children:"Article introuvable"}),n.jsxs(v,{to:"/blog",className:"mt-6 inline-flex items-center gap-2 text-sm text-terroir hover:underline",children:[n.jsx(S,{className:"h-4 w-4"})," Retour au carnet"]})]})}export{ae 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.