import{ax as I,M as f,ay as T,a0 as v,az as O,j as C,B as w,K as L,aA as P,aB as M,d as A,A as W,aC as k}from"./entry.022.8a67e790.js";function R(){let e=[];return{cleanup:()=>{e=e.filter(n=>(n(),!1))},onCleanup:n=>{e.push(n)}}}function _(e){let t=()=>{};const r=new Promise(o=>{t=()=>{e(),o()}});return{promise:r,resolvePromise:t,onResolvedPromise:o=>{r.then(o)}}}function z(e){const t=e.effect.fn,r=e.render;e.render=(...n)=>{e.effect.fn=()=>r(...n);const o=e.effect.run();return e.effect.fn=t,e.render=r,o}}const B=e=>typeof e=="function",S=e=>e!==null&&typeof e=="object";function d(e,t){if(I(e)&&(t(e),e.children!==null)){if(Array.isArray(e.children)){e.children.forEach(r=>d(r,t));return}S(e.children)&&Object.keys(e.children).forEach(r=>{if(!B(e.children[r]))return;const n=e.children[r]();if(Array.isArray(n)){n.forEach(o=>d(o,t));return}d(n,t)})}}function N(e){var t,r;return((t=e.type)==null?void 0:t.__asyncLoader)&&((r=e.type)==null?void 0:r.name)==="AsyncComponentWrapper"}function V({subTree:e},t){const r=[];if(d(e,n=>{N(n)&&r.push(n.type.__asyncLoader())}),r.length>0){Promise.all(r).then(t);return}t()}function j(e){if(!e||!e.subTree)return;const t=e.subTree.el,r=e.u;e.u===null&&(e.u=[]),e.u.push(()=>{e.subTree.el===null&&(e.subTree.el=t),e.u=r})}function x(){const e=f();if(!e||e.isMounted)throw new Error("useLazyHydration must be called from the setup method.");const t=e.vnode.el!==null;if(e.vnode.type.__isLazilyHydrated=!0,!t)return{willPerformHydration:t,onHydrated:()=>{}};const{cleanup:r,onCleanup:n}=R(),{promise:o,resolvePromise:i,onResolvedPromise:s}=_(r),u=a=>s(()=>O(()=>V(e,a)));return e.type.__asyncLoader=()=>o,j(e.parent),T(()=>{e.asyncDep=new Promise(a=>{a(!0)})}),s(()=>{z(e),e.asyncDep=null}),v(r),{willPerformHydration:t,hydrate:i,onHydrated:u,onCleanup:n}}function F({willPerformHydration:e,hydrate:t,onCleanup:r},n=2e3){if(!e)return;if(!f())throw new Error("useHydrateWhenIdle must be called from the setup or lifecycle hook methods.");if(!("requestIdleCallback"in window)){t();return}const o=requestIdleCallback(()=>{t()},{timeout:n});r(()=>{cancelIdleCallback(o)})}const E={ELEMENT:1,TEXT:3,COMMENT:8},p=e=>e&&e.nodeType===E.ELEMENT,g=e=>e&&e.nodeType===E.COMMENT,D=e=>g(e)&&(e==null?void 0:e.data)==="[",U=e=>g(e)&&(e==null?void 0:e.data)==="]";function H({vnode:e,subTree:t}){if(!e||e.el===null)return[];if(p(e.el))return[e.el];const r=[];if(t&&D(t.el)&&U(t.anchor)){let n=e.el.nextSibling;for(;n;){if(n&&p(n)&&r.push(n),n===t.anchor)return r;n=n.nextSibling}}return r}function q({willPerformHydration:e,hydrate:t,onCleanup:r},n=["focus"]){if(!e)return;const o=f();if(!o||o.isMounted)throw new Error("useHydrateOnInteraction must be called from the setup method.");const i=C(n);w(()=>{const s=H(o),u=s.length>1?s[0].parentElement||document:s[0],a={capture:!0,once:!1,passive:!0},y=c=>{c.stopPropagation();const m=c.composedPath&&c.composedPath()||c.path;if(!m){let l=c.target;for(;l;){if(s.includes(l)){t();return}if(l===u)return;l=l.parentElement}return}s.forEach(l=>{m.includes(l)&&t()})};i.forEach(c=>{u.addEventListener(c,y,a)}),r(()=>{i.forEach(c=>{u.removeEventListener(c,y,a)})})})}function K({willPerformHydration:e,hydrate:t,onCleanup:r},n){if(!e)return;if(!f())throw new Error("useHydrateWhenTriggered must be called from the setup or lifecycle hook methods.");const o=L(P(n)?n:()=>n,i=>{i&&t()},{immediate:!0});r(o)}const h=new Map;function J(e){const t=typeof IntersectionObserver<"u";if(!t)return{supported:t};const r=JSON.stringify(e);if(h.has(r))return{supported:t,observer:h.get(r)};const n=new IntersectionObserver(o=>{o.forEach(i=>{!(i.isIntersecting||i.intersectionRatio>0)||!i.target.hydrate||i.target.hydrate()})},e);return h.set(r,n),{supported:t,observer:n}}function X({willPerformHydration:e,hydrate:t,onCleanup:r},n){if(!e)return;const o=f();if(!o||o.isMounted)throw new Error("useHydrateWhenVisible must be called from the setup method.");const{supported:i,observer:s}=J(n);if(!i){t();return}w(()=>{const u=H(o);u.forEach(a=>{a.hydrate=t,s.observe(a)}),r(()=>{u.forEach(a=>{delete a.hydrate,s.unobserve(a)})})})}const b=e=>e.length===1?e[0]:e,$=A({name:"LazyHydrationWrapper",inheritAttrs:!1,suspensible:!1,props:{whenIdle:{default:!1,type:[Boolean,Number]},whenVisible:{default:!1,type:[Boolean,Object]},onInteraction:{default:!1,type:[Array,Boolean,String]},whenTriggered:{default:void 0,type:[Boolean,Object]}},emits:["hydrated"],setup(e,{slots:t,emit:r}){const n=x();if(!n.willPerformHydration)return()=>b(t.default());if(n.onHydrated(()=>r("hydrated")),e.whenIdle&&F(n,e.whenIdle!==!0?e.whenIdle:void 0),e.whenVisible&&X(n,e.whenVisible!==!0?e.whenVisible:void 0),e.onInteraction){let o;e.onInteraction!==!0&&(o=W(()=>Array.isArray(e.onInteraction)?e.onInteraction:[e.onInteraction]).value),q(n,o)}return e.whenTriggered!==void 0&&K(n,k(e,"whenTriggered")),()=>b(t.default())}}),Q=M($);export{Q as L};