{"version":3,"file":"types/tabs.mjs","sources":["webpack://@agent-infra/browser/./src/types/tabs.ts"],"sourcesContent":["/*\n * Copyright (c) 2025 Bytedance, Inc. and its affiliates.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type {\n  Viewport,\n  Protocol,\n  PuppeteerLifeCycleEvent,\n  ScreenshotOptions,\n} from 'puppeteer-core';\n\nimport type { EnvInfo } from './env';\nimport type { UserAgentInfo } from './browser';\n\nexport interface TabsOptions {\n  viewport: Viewport;\n  envInfo: EnvInfo;\n  userAgentInfo?: UserAgentInfo;\n}\n\nexport interface TabOptions extends TabsOptions {\n  tabId: string;\n  injectVisibilityScript?: boolean;\n}\n\nexport const enum TabEvents {\n  TabLoadingStateChanged = 'tabLoadingStateChanged',\n  TabUrlChanged = 'tabUrlChanged',\n  TabVisibilityChanged = 'TabVisibilityChanged',\n  TabDialogChanged = 'TabDialogChanged',\n}\n\nexport interface TabEventsMap {\n  [TabEvents.TabLoadingStateChanged]: {\n    tabId: string;\n    isLoading: boolean;\n  };\n  [TabEvents.TabUrlChanged]: {\n    tabId: string;\n    oldUrl: string;\n    newUrl: string;\n  };\n  [TabEvents.TabVisibilityChanged]: {\n    tabId: string;\n    isVisible: boolean;\n  };\n  [TabEvents.TabDialogChanged]: {\n    tabId: string;\n    isOpen: boolean;\n    type?: Protocol.Page.DialogType;\n    message?: string;\n    defaultValue?: string;\n  };\n}\n\nexport interface DialogMeta {\n  type: Protocol.Page.DialogType;\n  message: string;\n  defaultValue: string;\n}\n\nexport interface TabMeta {\n  id: string;\n  title: string;\n  url: string;\n  favicon: string | null;\n  isLoading: boolean;\n  isActive: boolean;\n  canGoBack: boolean;\n  canGoForward: boolean;\n  dialog?: DialogMeta;\n}\n\nexport interface TabsState {\n  tabs: Map<string, TabMeta>;\n  activeTabId: string | null;\n}\n\nexport interface TabsOperationTracker {\n  creatingTargetIds: Set<string>;\n  switchingTargetIds: Set<string>;\n  closingTargetIds: Set<string>;\n}\n\nexport interface NavigationOptions {\n  waitUntil?: PuppeteerLifeCycleEvent[];\n  timeout?: number;\n}\n\nexport interface NavigationSuccessResult {\n  success: true;\n  url: string;\n}\nexport interface NavigationErrorResult {\n  success: false;\n  url: string;\n  message: string;\n}\n\nexport type NavigationResult = NavigationSuccessResult | NavigationErrorResult;\n\nexport type TabScreenshotOptions = Pick<\n  ScreenshotOptions,\n  'type' | 'quality' | 'fullPage' | 'path'\n>;\n\nexport interface BaseScreenshotResult {\n  type: string;\n  width: number;\n  height: number;\n}\n\nexport interface ScreenshotResultWithPath extends BaseScreenshotResult {\n  data: Uint8Array;\n}\n\nexport interface ScreenshotResultWithoutPath extends BaseScreenshotResult {\n  data: string;\n}\n\nexport type TabScreenshotResult<T extends TabScreenshotOptions> = T extends {\n  path: string;\n}\n  ? ScreenshotResultWithPath\n  : ScreenshotResultWithoutPath;\n"],"names":["TabEvents"],"mappings":";;;;AAyBO,IAAWA,iBAASA,WAAAA,GAAAA,SAATA,SAAS;;;;;WAATA"}