'use strict';
import { c } from 'react/compiler-runtime';
import { jsx } from 'react/jsx-runtime';
import { useState, useEffect } from 'react';
import { TitleContext } from '../../../../meta/page/title-context.js';

var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", {
  value,
  configurable: true
});
function TitleProvider(t0) {
  const $ = c(4);
  const {
    children,
    appTitle
  } = t0;
  const [title, setTitle] = useState("");
  const contextValue = {
    title,
    setTitle
  };
  let t1;
  let t2;
  if ($[0] !== appTitle || $[1] !== title) {
    t1 = () => {
      document.title = appTitle + (title && ` - ${title}`);
    };
    t2 = [title, appTitle];
    $[0] = appTitle;
    $[1] = title;
    $[2] = t1;
    $[3] = t2;
  } else {
    t1 = $[2];
    t2 = $[3];
  }
  useEffect(t1, t2);
  return jsx(TitleContext.Provider, {
    value: contextValue,
    children
  });
}
__name(TitleProvider, "TitleProvider");

export { TitleProvider as default };
