import * as react5 from "react";
import "@tanstack/react-start";

//#region src/pwa.d.ts

/**
 * The tags that make the app installable: its manifest, its home screen icon,
 * and, while the app is installable, the name and launch screens iOS shows.
 * Render it once, in `<head>` in the root route's `RootDocument`.
 *
 * @example
 * function RootDocument({ children }: { children: React.ReactNode }) {
 *   return (
 *     <html lang="en">
 *       <head>
 *         <HeadContent />
 *         <SoftrPwaHead />
 *       </head>
 *       <body>
 *         {children}
 *         <Scripts />
 *       </body>
 *     </html>
 *   )
 * }
 */
declare function SoftrPwaHead(): react5.FunctionComponentElement<react5.FragmentProps>;
type PwaPlatform = "ios" | "android" | "desktop";
type InstallChoice = "accepted" | "dismissed";
type PwaInstall = {
  available: false;
} | {
  available: true;
  /** Which steps install the app on this device. */
  platform: PwaPlatform;
  /** The name the home screen will show. */
  name: string;
  /** The icon the home screen will show. */
  iconUrl: string;
  /**
   * Opens the browser's own install dialog. Only there while the browser offers one: never in
   * iOS, Safari, Firefox or the Studio preview, and not again once the visitor has closed it.
   * Call it from a click, and show the steps for `platform` while it is missing or rejects.
   */
  install?: () => Promise<InstallChoice>;
};
/**
 * Whether to offer installing the app, and on which platform. Render an
 * install button only while this says `available`: it is unavailable while
 * loading, when the builder has not turned the PWA on, when Softr has switched
 * it off, and when the app already runs installed.
 *
 * @example
 * function InstallButton() {
 *   const install = usePwaInstall()
 *   if (!install.available) return null
 *   return (
 *     <button
 *       onClick={() =>
 *         install.install
 *           ? install.install().catch(() => openSteps(install.platform))
 *           : openSteps(install.platform)
 *       }
 *     >
 *       Install {install.name}
 *     </button>
 *   )
 * }
 */
declare function usePwaInstall(): PwaInstall;
//#endregion
export { PwaInstall, PwaPlatform, SoftrPwaHead, usePwaInstall };