import{e as k,h as P,A as R,B as l,C as N,D as j,E as x,P as c,L as S}from"./DzNUFzst.js";import{l as d,i as L,m as _,u as h,k as w,n as y,an as A,v as O,S as T,p as v,s as B}from"./BX5Qd5jQ.js";const E=d({name:"LayoutLoader",inheritAttrs:!1,props:{name:String,layoutProps:Object},setup(t,n){return()=>y(l[t.name],t.layoutProps,n.slots)}}),C={name:{type:[String,Boolean,Object],default:null},fallback:{type:[String,Object],default:null}},q=d({name:"NuxtLayout",inheritAttrs:!1,props:C,setup(t,n){const a=k(),u=L(c),e=!u||u===P()?R():u,o=_(()=>{let s=h(t.name)??(e==null?void 0:e.meta.layout)??"default";return s&&!(s in l)&&t.fallback&&(s=h(t.fallback)),s}),i=w();n.expose({layoutRef:i});const r=a.deferHydration();if(a.isHydrating){const s=a.hooks.hookOnce("app:error",r);N().beforeEach(s)}let f;return()=>{const s=o.value&&o.value in l,p=(e==null?void 0:e.meta.layoutTransition)??j,b=f;return f=o.value,x(s&&p,{default:()=>y(T,{suspensible:!0,onResolve:()=>{O(r)}},{default:()=>y(H,{layoutProps:A(n.attrs,{ref:i}),key:o.value||void 0,name:o.value,shouldProvide:!t.name,isRenderingNewLayout:m=>m!==b&&m===o.value,hasTransition:!!p},n.slots)})}).default()}}}),H=d({name:"NuxtLayoutProvider",inheritAttrs:!1,props:{name:{type:[String,Boolean]},layoutProps:{type:Object},hasTransition:{type:Boolean},shouldProvide:{type:Boolean},isRenderingNewLayout:{type:Function,required:!0}},setup(t,n){const a=t.name;t.shouldProvide&&v(S,{isCurrent:e=>a===(e.meta.layout??"default")});const u=L(c);if(u&&u===P()){const e=R(),o={};for(const i in e){const r=i;Object.defineProperty(o,r,{enumerable:!0,get:()=>t.isRenderingNewLayout(t.name)?e[r]:u[r]})}v(c,B(o))}return()=>{var e,o;return!a||typeof a=="string"&&!(a in l)?(o=(e=n.slots).default)==null?void 0:o.call(e):y(E,{key:a,layoutProps:t.layoutProps,name:a},n.slots)}}});export{q as _};
