{"version":3,"file":"selfHostShell.cjs","names":[],"sources":["../../../src/web/lib/selfHostShell.ts"],"sourcesContent":["/** The `window.poDesktop.platform` a self-hosted Worker's shell sets (po-web `selfHostRuntime`). */\nconst SELF_HOST_PLATFORM = 'self-host';\n/** The meta tag a hosted Po's gateway adds to its shell, naming its Team pages. */\nconst TEAM_META = 'meta[name=\"po-team\"]';\n\ninterface ShellBridge {\n  platform?: string;\n  cloud?: { signOut?: () => Promise<unknown> };\n}\n\nconst bridge = (): ShellBridge | undefined =>\n  typeof window === 'undefined' ? undefined : (window as { poDesktop?: ShellBridge }).poDesktop;\n\n/** Whether this page is a self-hosted or hosted Po Worker's shell rather than a local cockpit. */\nexport function isSelfHostShell(): boolean {\n  return bridge()?.platform === SELF_HOST_PLATFORM;\n}\n\n/** The host's Team pages, when its shell names a same-origin path for them. */\nexport function teamPageUrl(\n  doc: Pick<Document, 'querySelector'> | undefined = globalThis.document,\n): string | undefined {\n  const content = doc?.querySelector(TEAM_META)?.getAttribute('content') ?? '';\n  return content.startsWith('/') && !content.startsWith('//') ? content : undefined;\n}\n\n/** The self-host bridge's sign-out, which ends the owner cookie and returns to the host's sign-in page. */\nexport function selfHostSignOut(): (() => Promise<unknown>) | undefined {\n  const cloud = isSelfHostShell() ? bridge()?.cloud : undefined;\n  const signOut = cloud?.signOut;\n  return signOut ? () => signOut.call(cloud) : undefined;\n}\n"],"mappings":";;AACA,MAAM,qBAAqB;;AAE3B,MAAM,YAAY;AAOlB,MAAM,eACJ,OAAO,WAAW,cAAc,KAAA,IAAa,OAAuC;;AAGtF,SAAgB,kBAA2B;CACzC,OAAO,OAAO,CAAC,EAAE,aAAa;AAChC;;AAGA,SAAgB,YACd,MAAmD,WAAW,UAC1C;CACpB,MAAM,UAAU,KAAK,cAAc,SAAS,CAAC,EAAE,aAAa,SAAS,KAAK;CAC1E,OAAO,QAAQ,WAAW,GAAG,KAAK,CAAC,QAAQ,WAAW,IAAI,IAAI,UAAU,KAAA;AAC1E;;AAGA,SAAgB,kBAAwD;CACtE,MAAM,QAAQ,gBAAgB,IAAI,OAAO,CAAC,EAAE,QAAQ,KAAA;CACpD,MAAM,UAAU,OAAO;CACvB,OAAO,gBAAgB,QAAQ,KAAK,KAAK,IAAI,KAAA;AAC/C"}