{"version":3,"sources":["../../src/atlas-v2-prediction-autocomplete.universal.ts","../../src/atlas-v2-prediction-autocomplete.http.ts","../../src/atlas-v2-prediction-autocomplete.public.ts","../../src/atlas-v2-prediction-autocomplete.context.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 ambassadorWixAtlasV2Prediction from './atlas-v2-prediction-autocomplete.http.js';\n\nexport interface Prediction {\n  /** The human-readable name of the prediction */\n  description?: string;\n  /** The id of the prediction that can be use in place api. Available for short time. */\n  searchId?: string;\n  /** Contains an array with offset value and length. These describe the location of the entered term in the prediction result text, so that the term can be highlighted if desired */\n  matchedSubstrings?: MatchedSubstrings[];\n  /** Provides pre-formatted text that can be shown in your autocomplete results */\n  textStructure?: TextStructure;\n  /** Contains an integer indicating the straight-line distance between the predicted place, and the specified origin point, in meters. */\n  distanceInMeters?: number | null;\n  /**\n   * The place types. For example: route, locality etc...\n   * @maxSize 100\n   * @maxLength 128\n   */\n  types?: string[];\n}\n\nexport interface MatchedSubstrings {\n  length?: number;\n  offset?: number;\n}\n\nexport interface TextStructure {\n  /** Contains the main text of a prediction, usually the name of the place */\n  mainText?: string;\n  /** Contains the secondary text of a prediction, usually the location of the place */\n  secondaryText?: string;\n  /** Contains an array with offset value and length. These describe the location of the entered term in the prediction result text, so that the term can be highlighted if desired */\n  mainTextMatchedSubstrings?: MatchedSubstrings[];\n}\n\nexport interface ListPredictionsRequest {\n  /** The text the predictions will be based on. */\n  input?: string;\n  /** The origin point from which to calculate straight-line distance to the destination */\n  origin?: AddressLocation;\n  /** The point around which you wish to retrieve place information */\n  location?: AddressLocation;\n  /** The acceptable distance from that location (in meters) */\n  radius?: string | null;\n  /** Filters the user can add in order to get more accurate results */\n  filterBy?: FilterBy[];\n}\n\nexport interface AddressLocation {\n  /** Address latitude. */\n  latitude?: number | null;\n  /** Address longitude. */\n  longitude?: number | null;\n}\n\nexport interface FilterBy {\n  /** One of the filter types enum */\n  filterType?: FilterTypeWithLiterals;\n  /** Free text like \"us\" */\n  filterValue?: string;\n}\n\nexport enum FilterType {\n  /** Filter by zip code */\n  zip_code = 'zip_code',\n  /** Filter by 2-letters or 3-letters country code */\n  country_code = 'country_code',\n}\n\n/** @enumType */\nexport type FilterTypeWithLiterals = FilterType | 'zip_code' | 'country_code';\n\nexport interface ListPredictionsResponse {\n  predictions?: Prediction[];\n}\n\nexport interface PredictRequest {\n  /**\n   * The text the predictions will be based on.\n   * @minLength 1\n   */\n  input: string;\n  /** The origin point from which to calculate straight-line distance to the destination */\n  origin?: AddressLocation;\n  /** The point around which you wish to retrieve place information */\n  location?: AddressLocation;\n  /** The acceptable distance from that location (in meters) */\n  radius?: string | null;\n  /** alpha-2 or alpha-3 ISO-3166 country codes to filter by */\n  countryCodes?: string[];\n  /**\n   * A random string which identifies an autocomplete session for billing purposes. The session begins when the user starts typing a query, and concludes when they select a place and a call to Get Place is made. Once a session has concluded, the token is no longer valid. your app must generate a fresh token for each session.\n   * @format GUID\n   */\n  sessionToken?: string | null;\n}\n\nexport interface PredictResponse {\n  predictions?: Prediction[];\n}\n\n/**\n * A Predict end-point take an input and returns an list of Prediction object.\n * @param input - The text the predictions will be based on.\n * @public\n * @documentationMaturity preview\n * @requiredField input\n * @permissionId WIX_ATLAS.LIST_PREDICTIONS\n * @applicableIdentity APP\n * @fqn com.wixpress.vi.atlas.service.v2.AutocompleteServiceV2.Predict\n */\nexport async function predict(\n  input: string,\n  options?: PredictOptions\n): Promise<\n  NonNullablePaths<\n    PredictResponse,\n    | `predictions`\n    | `predictions.${number}.description`\n    | `predictions.${number}.searchId`\n    | `predictions.${number}.textStructure.mainText`\n    | `predictions.${number}.textStructure.secondaryText`,\n    3\n  >\n> {\n  // @ts-ignore\n  const { httpClient, sideEffects } = arguments[2] as {\n    httpClient: HttpClient;\n    sideEffects?: any;\n  };\n\n  const payload = renameKeysFromSDKRequestToRESTRequest({\n    input: input,\n    origin: options?.origin,\n    location: options?.location,\n    radius: options?.radius,\n    countryCodes: options?.countryCodes,\n    sessionToken: options?.sessionToken,\n  });\n\n  const reqOpts = ambassadorWixAtlasV2Prediction.predict(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          input: '$[0]',\n          origin: '$[1].origin',\n          location: '$[1].location',\n          radius: '$[1].radius',\n          countryCodes: '$[1].countryCodes',\n          sessionToken: '$[1].sessionToken',\n        },\n        singleArgumentUnchanged: false,\n      },\n      ['input', 'options']\n    );\n    sideEffects?.onError?.(err);\n\n    throw transformedError;\n  }\n}\n\nexport interface PredictOptions {\n  /** The origin point from which to calculate straight-line distance to the destination */\n  origin?: AddressLocation;\n  /** The point around which you wish to retrieve place information */\n  location?: AddressLocation;\n  /** The acceptable distance from that location (in meters) */\n  radius?: string | null;\n  /** alpha-2 or alpha-3 ISO-3166 country codes to filter by */\n  countryCodes?: string[];\n  /**\n   * A random string which identifies an autocomplete session for billing purposes. The session begins when the user starts typing a query, and concludes when they select a place and a call to Get Place is made. Once a session has concluded, the token is no longer valid. your app must generate a fresh token for each session.\n   * @format GUID\n   */\n  sessionToken?: string | null;\n}\n","import { transformSDKFloatToRESTFloat } from '@wix/sdk-runtime/transformations/float';\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\nconst TRANSFORM_PATHS_0 = [\n  { path: 'origin.latitude' },\n  { path: 'origin.longitude' },\n  { path: 'location.latitude' },\n  { path: 'location.longitude' },\n];\n\nfunction resolveComWixpressViAtlasServiceV2AutocompleteServiceV2Url(\n  opts: Omit<ResolveUrlOpts, 'domainToMappings'>\n) {\n  const domainToMappings = {\n    'api._api_base_domain_': [\n      {\n        srcPath: '/wix-atlas-service-web',\n        destPath: '',\n      },\n    ],\n    'bo._base_domain_': [\n      {\n        srcPath: '/wix-atlas-service-web',\n        destPath: '',\n      },\n    ],\n    'wixbo.ai': [\n      {\n        srcPath: '/wix-atlas-service-web',\n        destPath: '',\n      },\n    ],\n    'wix-bo.com': [\n      {\n        srcPath: '/wix-atlas-service-web',\n        destPath: '',\n      },\n    ],\n    _: [\n      {\n        srcPath: '/api/wix-atlas-service-web',\n        destPath: '',\n      },\n      {\n        srcPath: '/_api/wix-atlas-service-web',\n        destPath: '',\n      },\n    ],\n    'www._base_domain_': [\n      {\n        srcPath: '/wix-atlas-service-web',\n        destPath: '',\n      },\n      {\n        srcPath: '/_api/wix-atlas-service-web',\n        destPath: '',\n      },\n      {\n        srcPath: '/api/wix-atlas-service-web',\n        destPath: '',\n      },\n    ],\n    'manage._base_domain_': [\n      {\n        srcPath: '/wix-atlas-service-web',\n        destPath: '',\n      },\n    ],\n    'editor._base_domain_': [\n      {\n        srcPath: '/wix-atlas-service-web',\n        destPath: '',\n      },\n      {\n        srcPath: '/api/wix-atlas-service-web',\n        destPath: '',\n      },\n    ],\n    'blocks._base_domain_': [\n      {\n        srcPath: '/wix-atlas-service-web',\n        destPath: '',\n      },\n      {\n        srcPath: '/api/wix-atlas-service-web',\n        destPath: '',\n      },\n    ],\n    'create.editorx': [\n      {\n        srcPath: '/wix-atlas-service-web',\n        destPath: '',\n      },\n      {\n        srcPath: '/api/wix-atlas-service-web',\n        destPath: '',\n      },\n    ],\n    'editor.wixapps.net': [\n      {\n        srcPath: '/api/wix-atlas-service-web',\n        destPath: '',\n      },\n    ],\n    '*.wixforms.com': [\n      {\n        srcPath: '/_api/wix-atlas-service-web',\n        destPath: '',\n      },\n    ],\n    'platform.rise.ai': [\n      {\n        srcPath: '/_api/wix-atlas-service-web',\n        destPath: '',\n      },\n      {\n        srcPath: '/wix-atlas-service-web',\n        destPath: '',\n      },\n    ],\n    'www.wixapis.com': [\n      {\n        srcPath: '/api/wix-atlas-service-web',\n        destPath: '',\n      },\n    ],\n  };\n\n  return resolveUrl(Object.assign(opts, { domainToMappings }));\n}\n\nconst PACKAGE_NAME = '@wix/auto_sdk_atlas_autocomplete';\n\n/** A Predict end-point take an input and returns an list of Prediction object. */\nexport function predict(payload: object): RequestOptionsFactory<any> {\n  function __predict({ host }: any) {\n    const serializedData = transformPaths(payload, [\n      {\n        transformFn: transformSDKFloatToRESTFloat,\n        paths: TRANSFORM_PATHS_0,\n      },\n    ]);\n    const metadata = {\n      entityFqdn: 'wix.atlas.v2.prediction',\n      method: 'POST' as any,\n      methodFqn:\n        'com.wixpress.vi.atlas.service.v2.AutocompleteServiceV2.Predict',\n      packageName: PACKAGE_NAME,\n      migrationOptions: {\n        optInTransformResponse: true,\n      },\n      url: resolveComWixpressViAtlasServiceV2AutocompleteServiceV2Url({\n        protoPath: '/v2/predict',\n        data: serializedData,\n        host,\n      }),\n      data: serializedData,\n    };\n\n    return metadata;\n  }\n\n  return __predict;\n}\n","import { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport {\n  PredictOptions,\n  PredictResponse,\n  predict as universalPredict,\n} from './atlas-v2-prediction-autocomplete.universal.js';\n\nexport const __metadata = { PACKAGE_NAME: '@wix/atlas' };\n\nexport function predict(httpClient: HttpClient): PredictSignature {\n  return (input: string, options?: PredictOptions) =>\n    universalPredict(\n      input,\n      options,\n      // @ts-ignore\n      { httpClient }\n    );\n}\n\ninterface PredictSignature {\n  /**\n   * A Predict end-point take an input and returns an list of Prediction object.\n   * @param - The text the predictions will be based on.\n   */\n  (input: string, options?: PredictOptions): Promise<\n    NonNullablePaths<\n      PredictResponse,\n      | `predictions`\n      | `predictions.${number}.description`\n      | `predictions.${number}.searchId`\n      | `predictions.${number}.textStructure.mainText`\n      | `predictions.${number}.textStructure.secondaryText`,\n      3\n    >\n  >;\n}\n\nexport {\n  AddressLocation,\n  FilterBy,\n  FilterType,\n  ListPredictionsRequest,\n  ListPredictionsResponse,\n  MatchedSubstrings,\n  PredictOptions,\n  PredictRequest,\n  PredictResponse,\n  Prediction,\n  TextStructure,\n} from './atlas-v2-prediction-autocomplete.universal.js';\n","import { predict as publicPredict } from './atlas-v2-prediction-autocomplete.public.js';\nimport { createRESTModule } from '@wix/sdk-runtime/rest-modules';\nimport { BuildRESTFunction, MaybeContext } from '@wix/sdk-types';\n\nexport const predict: MaybeContext<\n  BuildRESTFunction<typeof publicPredict> & typeof publicPredict\n> = /*#__PURE__*/ createRESTModule(publicPredict);\n\nexport { FilterType } from './atlas-v2-prediction-autocomplete.universal.js';\nexport {\n  Prediction,\n  MatchedSubstrings,\n  TextStructure,\n  ListPredictionsRequest,\n  AddressLocation,\n  FilterBy,\n  ListPredictionsResponse,\n  PredictRequest,\n  PredictResponse,\n  PredictOptions,\n} from './atlas-v2-prediction-autocomplete.universal.js';\nexport { FilterTypeWithLiterals } from './atlas-v2-prediction-autocomplete.universal.js';\n"],"mappings":";AAAA,SAAS,kBAAkB,yBAAyB;AACpD;AAAA,EACE;AAAA,EACA;AAAA,OACK;;;ACJP,SAAS,oCAAoC;AAC7C,SAAS,sBAAsB;AAC/B,SAAS,kBAAkB;AAI3B,IAAM,oBAAoB;AAAA,EACxB,EAAE,MAAM,kBAAkB;AAAA,EAC1B,EAAE,MAAM,mBAAmB;AAAA,EAC3B,EAAE,MAAM,oBAAoB;AAAA,EAC5B,EAAE,MAAM,qBAAqB;AAC/B;AAEA,SAAS,2DACP,MACA;AACA,QAAM,mBAAmB;AAAA,IACvB,yBAAyB;AAAA,MACvB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,oBAAoB;AAAA,MAClB;AA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