import { X as escape_html } from './context-BZ_07CFR.js';
import { s as setAgentsContext } from './agents-context-BFekPmHw.js';
import { p as page, g as goto } from './index3-DWsxdehH.js';
import './state.svelte-Yu4RD6aK.js';
import './utils-KcIDVAAe.js';
import './index-FgxKh3J4.js';

function _layout($$renderer, $$props) {
  $$renderer.component(($$renderer2) => {
    let { children } = $$props;
    let error = "";
    setAgentsContext({
      onAgentSelect: (agentId) => {
        const currentTab = page.url.pathname.split("/")[1];
        if (!currentTab) {
          goto();
        } else if (currentTab === "roleplay") {
          goto();
        } else {
          goto();
        }
      },
      onError: handleError
    });
    function handleError(errorMessage) {
      error = errorMessage;
      setTimeout(
        () => {
          error = "";
        },
        5e3
      );
      console.error(errorMessage);
    }
    $$renderer2.push(`<main class="h-screen overflow-hidden bg-gray-600">`);
    children($$renderer2);
    $$renderer2.push(`<!----> `);
    if (error) {
      $$renderer2.push("<!--[-->");
      $$renderer2.push(`<div class="absolute bottom-0 right-0 m-4 rounded-sm border border-red-500 bg-red-50 px-4 py-2 text-red-800 focus:outline-none focus:ring-0">${escape_html(error)}</div>`);
    } else {
      $$renderer2.push("<!--[!-->");
    }
    $$renderer2.push(`<!--]--></main>`);
  });
}

export { _layout as default };
//# sourceMappingURL=_layout.svelte-BYc7aO6O.js.map
