import{C as S,r as g,aE as M,d as v,x as O,g as R,o as C,u as T,a as y,c as b,q as w,b as k}from"./index-D6Xt1sgO.js";function W(e){return R()?(C(e),!0):!1}function m(e){return typeof e=="function"?e():T(e)}const h=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const _=e=>e!=null,B=()=>{};function D(e){return e||y()}function E(...e){if(e.length!==1)return S(...e);const t=e[0];return typeof t=="function"?g(M(()=>({get:t,set:B}))):v(t)}function U(e,t){D(t)&&O(e,t)}function q(e){var t;const i=m(e);return(t=i==null?void 0:i.$el)!=null?t:i}const x=h?window:void 0,A=h?window.document:void 0;function G(){const e=v(!1),t=y();return t&&k(()=>{e.value=!0},t),e}function L(e){const t=G();return w(()=>(t.value,!!e()))}function $(e,t,i={}){const{window:s=x,...c}=i;let n;const l=L(()=>s&&"MutationObserver"in s),a=()=>{n&&(n.disconnect(),n=void 0)},r=w(()=>{const u=m(e),p=(Array.isArray(u)?u:[u]).map(q).filter(_);return new Set(p)}),d=b(()=>r.value,u=>{a(),l.value&&s&&u.size&&(n=new MutationObserver(t),u.forEach(p=>n.observe(p,c)))},{immediate:!0,flush:"post"}),f=()=>n==null?void 0:n.takeRecords(),o=()=>{a(),d()};return W(o),{isSupported:l,stop:o,takeRecords:f}}function I(e=null,t={}){var i,s,c;const{document:n=A,restoreOnUnmount:l=o=>o}=t,a=(i=n==null?void 0:n.title)!=null?i:"",r=E((s=e??(n==null?void 0:n.title))!=null?s:null),d=e&&typeof e=="function";function f(o){if(!("titleTemplate"in t))return o;const u=t.titleTemplate||"%s";return typeof u=="function"?u(o):m(u).replace(/%s/g,o)}return b(r,(o,u)=>{o!==u&&n&&(n.title=f(typeof o=="string"?o:""))},{immediate:!0}),t.observe&&!t.titleTemplate&&n&&!d&&$((c=n.head)==null?void 0:c.querySelector("title"),()=>{n&&n.title!==r.value&&(r.value=f(n.title))},{childList:!0}),U(()=>{if(l){const o=l(a,r.value||"");o!=null&&n&&(n.title=o)}}),r}export{I as u};
