{"version":3,"sources":["../../src/innovation-assistant-v2-statistics-statistics.universal.ts","../../src/innovation-assistant-v2-statistics-statistics.http.ts"],"sourcesContent":["import { transformError as sdkTransformError } from '@wix/sdk-runtime/transform-error';\nimport {\n  renameKeysFromSDKRequestToRESTRequest,\n  renameKeysFromRESTResponseToSDKResponse,\n} from '@wix/sdk-runtime/rename-all-nested-keys';\nimport { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport * as ambassadorWixInnovationAssistantV2Statistics from './innovation-assistant-v2-statistics-statistics.http.js';\n\n/**\n * Aggregated AI Site-Chat statistics for a site.\n *\n * Statistics include daily KPI rows for recent activity and period KPI rows for comparison windows, such as the last 30 days and the previous 30 days.\n */\nexport interface Statistics {\n  /**\n   * Site ID the statistics are scoped to.\n   * @format GUID\n   */\n  _id?: string;\n  /**\n   * Typed daily statistics.\n   *\n   * Deprecated. Use `dailyKpis` instead.\n   * @maxSize 30\n   * @deprecated Typed daily statistics.\n   *\n   * Deprecated. Use `dailyKpis` instead.\n   * @replacedBy daily_kpis\n   * @targetRemovalDate 2026-02-03\n   */\n  dailies?: Daily[];\n  /**\n   * Typed period statistics.\n   *\n   * Deprecated. Use `periodKpis` instead.\n   * @maxSize 10\n   * @deprecated Typed period statistics.\n   *\n   * Deprecated. Use `periodKpis` instead.\n   * @replacedBy period_kpis\n   * @targetRemovalDate 2026-02-03\n   */\n  timespans?: Timespan[];\n  /**\n   * Daily KPI rows for the last 30 days.\n   *\n   * Each row contains the fields requested in `dailyFields`, or all default daily KPI fields if `dailyFields` isn't provided.\n   * @maxSize 30\n   */\n  dailyKpis?: Record<string, any>[] | null;\n  /**\n   * Period KPI rows for comparison windows.\n   *\n   * Each row contains the fields requested in `byPeriodFields`, or all default period KPI fields if `byPeriodFields` isn't provided.\n   * @maxSize 10\n   */\n  periodKpis?: Record<string, any>[] | null;\n}\n\nexport interface Daily {\n  /** Date the daily statistics are for. */\n  date?: Date | null;\n  /** Number of conversations on this date. */\n  conversations?: string | null;\n  /**\n   * Number of messages on this date.\n   *\n   * Deprecated.\n   * @deprecated\n   */\n  messages?: string | null;\n  /** Number of unique visitors on this date. */\n  visitors?: string | null;\n  /** Number of product items shown or recommended in AI Site-Chat on this date. */\n  exposedItems?: string | null;\n  /** Number of orders associated with AI Site-Chat activity on this date. */\n  orders?: string | null;\n  /** Chat handler the daily statistics are grouped by. */\n  chatHandler?: ChatHandlerWithLiterals;\n  /** Number of conversations that received a response on this date. */\n  repliedConversationsCount?: string | null;\n}\n\nexport enum ChatHandler {\n  /** Unknown handler. */\n  UNKNOWN_HANDLER = 'UNKNOWN_HANDLER',\n  /** AI assistant. */\n  AI = 'AI',\n  /** Wix user, such as a site owner or contributor. */\n  WIX_USER = 'WIX_USER',\n}\n\n/** @enumType */\nexport type ChatHandlerWithLiterals =\n  | ChatHandler\n  | 'UNKNOWN_HANDLER'\n  | 'AI'\n  | 'WIX_USER';\n\nexport interface Timespan {\n  /** Comparison period the statistics are aggregated for. */\n  period?: PeriodWithLiterals;\n  /** Number of conversations in this period. */\n  conversations?: string | null;\n  /**\n   * Number of messages in this period.\n   *\n   * Deprecated.\n   * @deprecated\n   */\n  messages?: string | null;\n  /** Number of unique visitors in this period. */\n  visitors?: string | null;\n  /** Number of product items shown or recommended in AI Site-Chat in this period. */\n  exposedItems?: string | null;\n  /** Number of orders associated with AI Site-Chat activity in this period. */\n  orders?: string | null;\n  /** Chat handler the period statistics are grouped by. */\n  chatHandler?: ChatHandlerWithLiterals;\n  /** Number of conversations that received a response in this period. */\n  repliedConversationsCount?: string | null;\n  /** Median response time in seconds. */\n  medianResponseTimeSecondsP50?: string | null;\n  /** Median first response time in seconds. */\n  medianFirstResponseTimeSecondsP50?: string | null;\n}\n\nexport enum Period {\n  /** Unknown period. */\n  UNKNOWN_PERIOD = 'UNKNOWN_PERIOD',\n  /** Rolling 30-day period from the current date. */\n  LAST_30_DAYS = 'LAST_30_DAYS',\n  /** The 30-day period before `LAST_30_DAYS`. */\n  PREVIOUS_30_DAYS = 'PREVIOUS_30_DAYS',\n}\n\n/** @enumType */\nexport type PeriodWithLiterals =\n  | Period\n  | 'UNKNOWN_PERIOD'\n  | 'LAST_30_DAYS'\n  | 'PREVIOUS_30_DAYS';\n\nexport interface GetStatisticsRequest {\n  /**\n   * Daily KPI fields to return in `statistics.dailyKpis`.\n   *\n   * Supported values: `kpi_date`, `mode`, `conversations_count`, `visitors_distinct_count`, `exposed_items_count`, `total_orders_count`, `replied_conversations_count`, `response_time_seconds_p50`, `first_response_time_seconds_p50`.\n   *\n   * Default: All supported daily KPI fields.\n   */\n  dailyFields?: string[];\n  /**\n   * Period KPI fields to return in `statistics.periodKpis`.\n   *\n   * Supported values: `period`, `mode`, `conversations_count`, `visitors_distinct_count`, `exposed_items_count`, `total_orders_count`, `replied_conversations_count`, `response_time_seconds_p50`, `first_response_time_seconds_p50`.\n   *\n   * Default: All supported period KPI fields.\n   */\n  byPeriodFields?: string[];\n}\n\nexport interface GetStatisticsResponse {\n  /** Aggregated AI Site-Chat statistics for the authenticated site. */\n  statistics?: Statistics;\n}\n\n/**\n * Retrieves aggregated AI Site-Chat statistics for the authenticated site.\n * @public\n * @documentationMaturity preview\n * @permissionId innovation:assistant:v2:statistics:get_statistics\n * @applicableIdentity APP\n * @fqn wix.innovation.assistant.stats.v2.WixAssistantStatistics.GetStatistics\n */\nexport async function getStatistics(\n  options?: GetStatisticsOptions\n): Promise<\n  NonNullablePaths<\n    GetStatisticsResponse,\n    | `statistics._id`\n    | `statistics.dailies`\n    | `statistics.dailies.${number}.chatHandler`\n    | `statistics.timespans`\n    | `statistics.timespans.${number}.period`\n    | `statistics.timespans.${number}.chatHandler`\n    | `statistics.dailyKpis`\n    | `statistics.periodKpis`,\n    5\n  >\n> {\n  // @ts-ignore\n  const { httpClient, sideEffects } = arguments[1] as {\n    httpClient: HttpClient;\n    sideEffects?: any;\n  };\n\n  const payload = renameKeysFromSDKRequestToRESTRequest({\n    dailyFields: options?.dailyFields,\n    byPeriodFields: options?.byPeriodFields,\n  });\n\n  const reqOpts =\n    ambassadorWixInnovationAssistantV2Statistics.getStatistics(payload);\n\n  sideEffects?.onSiteCall?.();\n  try {\n    const result = await httpClient.request(reqOpts);\n    sideEffects?.onSuccess?.(result);\n\n    return renameKeysFromRESTResponseToSDKResponse(result.data)!;\n  } catch (err: any) {\n    const transformedError = sdkTransformError(\n      err,\n      {\n        spreadPathsToArguments: {},\n        explicitPathsToArguments: {\n          dailyFields: '$[0].dailyFields',\n          byPeriodFields: '$[0].byPeriodFields',\n        },\n        singleArgumentUnchanged: false,\n      },\n      ['options']\n    );\n    sideEffects?.onError?.(err);\n\n    throw transformedError;\n  }\n}\n\nexport interface GetStatisticsOptions {\n  /**\n   * Daily KPI fields to return in `statistics.dailyKpis`.\n   *\n   * Supported values: `kpi_date`, `mode`, `conversations_count`, `visitors_distinct_count`, `exposed_items_count`, `total_orders_count`, `replied_conversations_count`, `response_time_seconds_p50`, `first_response_time_seconds_p50`.\n   *\n   * Default: All supported daily KPI fields.\n   */\n  dailyFields?: string[];\n  /**\n   * Period KPI fields to return in `statistics.periodKpis`.\n   *\n   * Supported values: `period`, `mode`, `conversations_count`, `visitors_distinct_count`, `exposed_items_count`, `total_orders_count`, `replied_conversations_count`, `response_time_seconds_p50`, `first_response_time_seconds_p50`.\n   *\n   * Default: All supported period KPI fields.\n   */\n  byPeriodFields?: string[];\n}\n","import { toURLSearchParams } from '@wix/sdk-runtime/rest-modules';\nimport { transformRESTTimestampToSDKTimestamp } from '@wix/sdk-runtime/transformations/timestamp';\nimport { transformPaths } from '@wix/sdk-runtime/transformations/transform-paths';\nimport { resolveUrl } from '@wix/sdk-runtime/rest-modules';\nimport { ResolveUrlOpts } from '@wix/sdk-runtime/rest-modules';\nimport { RequestOptionsFactory } from '@wix/sdk-types';\n\nfunction resolveWixInnovationAssistantStatsV2WixAssistantStatisticsUrl(\n  opts: Omit<ResolveUrlOpts, 'domainToMappings'>\n) {\n  const domainToMappings = {\n    'manage._base_domain_': [\n      {\n        srcPath: '/_api/wix-assistant-stats',\n        destPath: '/api',\n      },\n      {\n        srcPath: '/wix-assistant-stats',\n        destPath: '',\n      },\n    ],\n    'www.wixapis.com': [\n      {\n        srcPath: '/innovation/assistant/v2/statistics',\n        destPath: '/v2/statistics',\n      },\n    ],\n    '*.dev.wix-code.com': [\n      {\n        srcPath: '/innovation/assistant/v2/statistics',\n        destPath: '/v2/statistics',\n      },\n    ],\n    _: [\n      {\n        srcPath: '/innovation/assistant/v2/statistics',\n        destPath: '/v2/statistics',\n      },\n    ],\n  };\n\n  return resolveUrl(Object.assign(opts, { domainToMappings }));\n}\n\nconst PACKAGE_NAME = '@wix/auto_sdk_assistant-stats_statistics';\n\n/** Retrieves aggregated AI Site-Chat statistics for the authenticated site. */\nexport function getStatistics(payload: object): RequestOptionsFactory<any> {\n  function __getStatistics({ host }: any) {\n    const metadata = {\n      entityFqdn: 'wix.innovation.assistant.v2.statistics',\n      method: 'GET' as any,\n      methodFqn:\n        'wix.innovation.assistant.stats.v2.WixAssistantStatistics.GetStatistics',\n      packageName: PACKAGE_NAME,\n      migrationOptions: {\n        optInTransformResponse: true,\n      },\n      url: resolveWixInnovationAssistantStatsV2WixAssistantStatisticsUrl({\n        protoPath: '/v2/statistics',\n        data: payload,\n        host,\n      }),\n      params: toURLSearchParams(payload),\n      transformResponse: (payload: any) =>\n        transformPaths(payload, [\n          {\n            transformFn: transformRESTTimestampToSDKTimestamp,\n            paths: [{ path: 'statistics.dailies.date' }],\n          },\n        ]),\n    };\n\n    return metadata;\n  }\n\n  return __getStatistics;\n}\n"],"mappings":";AAAA,SAAS,kBAAkB,yBAAyB;AACpD;AAAA,EACE;AAAA,EACA;AAAA,OACK;;;ACJP,SAAS,yBAAyB;AAClC,SAAS,4CAA4C;AACrD,SAAS,sBAAsB;AAC/B,SAAS,kBAAkB;AAI3B,SAAS,8DACP,MACA;AACA,QAAM,mBAAmB;AAAA,IACvB,wBAAwB;AAAA,MACtB;AAAA,QACE,SAAS;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