import { E as EcwidApiPromise, g as CartData, y as CustomerCookieConsentType, v as JsApiPage, s as CustomerData, T as TrackingConsent, V as VisitorLocation, i as CartGetCallback, a as AddProductParameter, C as CartAddProductCallback, o as CartRemoveProductCallback, f as CartClearCallback, e as CartCalculateTotalCallback, j as CartGoToCheckoutCallback, t as CustomerGetCallback, u as CustomerSignOutCallback } from './ecom-headless.BTXuBMcG.cjs'; declare const EcwidWidgetValues: { /** Minicart widget */ readonly MINICART: "Minicart"; /** Search widget */ readonly SEARCH_PANEL: "SearchPanel"; /** Main storefront widget, contains full Ecwid store */ readonly PRODUCT_BROWSER: "ProductBrowser"; /** Horizontal categories menu widget */ readonly CATEGORIES: "Categories"; /** Widget with an embedded product page */ readonly PRODUCT: "Product"; }; type EcwidWidgetType = typeof EcwidWidgetValues[keyof typeof EcwidWidgetValues]; /** * This event allows tracking any cart changes excluding the payment method selection. * Its callback function with the cart argument contains details about the cart after the change event. * * OnCartChanged event triggers when: * - Cart is initialized, synced, or cleared * - Product has been added, updated (increased quantity, changed selected options), or removed from the cart * - Discount coupon or discount is applied or removed * - Shipping address is added or updated * - Shipping method is selected or changed * * @example * * ```ts * import { OnCartChanged } from '@lightspeed/ecom-headless'; * * OnCartChanged.add((cart) => { * console.log(`Cart ID: ${cart.cartId}`); * console.log(`Items in cart: ${cart.productsQuantity}`); * console.log(`Cart total: ${cart.total}`); * }); * ``` */ declare const OnCartChanged: EcwidApiPromise; /** * This method allows you to catch any changes to the consent value. * * @example * * ```ts * import { OnConsentChanged, CustomerCookieConsent } from '@lightspeed/ecom-headless'; * * OnConsentChanged.add((consent) => { * console.log("consent changed to " + consent); * }); * setTrackingConsent(CustomerCookieConsent.DECLINED); * // "consent changed to DECLINED" * ``` */ declare const OnConsentChanged: EcwidApiPromise; /** * This event triggers instantly when the page DOM is loaded. * * This method doesn't wait for the Ecwid product browser and its contents to fully load * and therefore doesn't return any details about the opened page. * * @example * * ```ts * import { OnPageLoad } from '@lightspeed/ecom-headless'; * * OnPageLoad.add(() => { * console.log("Page DOM has just loaded"); * }); * ``` */ declare const OnPageLoad: EcwidApiPromise; /** * This method allows you to track the full page load – * a moment when both DOM and product browser are loaded and ready for customization. * * It contains a callback function with page argument containing information about a loaded page. * * @example * * ```ts * import { OnPageLoaded, JsApiPageValues } from '@lightspeed/ecom-headless'; * * OnPageLoaded.add((page) => { * if (page.type === JsApiPageValues.PRODUCT) { * console.log(page); * } * }); * // { * // "type":"PRODUCT", * // "categoryId":0, * // "hasPrevious":false, * // "mainCategoryId":0, * // "name":"Desk Black 101x50x76.5 cm Engineered Wood", * // "nameTranslated":{ * // "cs":"", * // "en":"Desk Black 101x50x76.5 cm Engineered Wood" * // }, * // "productId":561386461 * // } * ``` */ declare const OnPageLoaded: EcwidApiPromise; /** * This method allows tracking and preventing page switches on the storefront. * It is triggered when a user is about to switch a page (a new page is not yet loaded). * * The method works synchronously and contains the page argument in its callback function. * Use it to identify the page where users go and prevent page loading by returning a false value. * * @example * * ```ts * import { OnPageSwitch, JsApiPageValues } from '@lightspeed/ecom-headless'; * * OnPageSwitch.add((page) => { * if (page.type === JsApiPageValues.PRODUCT) { * console.log(page); * } * }); * // { * // "type":"PRODUCT", * // "categoryId":0, * // "hasPrevious":false, * // "mainCategoryId":0, * // "name":"Desk Black 101x50x76.5 cm Engineered Wood", * // "nameTranslated":{ * // "cs":"", * // "en":"Desk Black 101x50x76.5 cm Engineered Wood" * // }, * // "productId":561386461 * // } * ``` */ declare const OnPageSwitch: EcwidApiPromise; /** * This method allows you to track a moment when customers log in and out on the storefront. * It contains a callback function with customer argument when a customer logs in, and null if a customer has logged out. * * @example * * ```ts * import { OnSetProfile } from '@lightspeed/ecom-headless'; * * OnSetProfile.add((customer) => { * console.log(customer.email); * // "ec.apps@lightspeedhq.com" * }); * ``` */ declare const OnSetProfile: EcwidApiPromise; /** * This method allows you to get store currency settings on the storefront. * It is useful if you need to add a widget that displays some price to customers. * * It accepts a numeric price as an argument and responds with a formatted price * using store settings: currency symbol, and delimiter symbol and precision. * * @example * * ```ts * import { formatCurrency } from '@lightspeed/ecom-headless'; * * const formattedPrice = await formatCurrency(12.99); * console.log(formattedPrice); * // "$12.99" * ``` */ declare function formatCurrency(amount: number): Promise; /** * This method accepts an app `client_id` as an argument and responds with a * "public config" for the app. This config is the data saved in App Storage * as a public key. * * Read more about setting up App Storage: * {@link https://docs.ecwid.com/launch-apps/native-and-external-apps/build-user-settings-page-for-ecwid-admin/manage-personal-user-settings-storage}. * * @example * ```ts * import { getAppPublicConfig } from '@lightspeed/ecom-headless'; * * const publicConfig = await getAppPublicConfig('client_id'); * console.log(JSON.parse(publicConfig)); * // {"key": "public","value": "{'color':'red','text':'Email button','border-radius':'3px'}"} * ``` */ declare function getAppPublicConfig(clientId: string): Promise; /** * This method accepts app client_id as an argument and responds with a public access token for the app. * Public tokens are safe to use on the storefront, as they won't be able to reveal any private store data. * * @example * * ```ts * import { getAppPublicToken } from '@lightspeed/ecom-headless'; * * const publicToken = await getAppPublicToken('client_id'); * console.log(publicToken); * // "public_qKsUqKkNXzcj9DejwMUqEkY2q2E6BXM9" * ``` */ declare function getAppPublicToken(clientId: string): Promise; /** * This method responds with a list of widgets currently loaded on the website. * * @example * * ```ts * import { getInitializedWidgets } from '@lightspeed/ecom-headless'; * const widgets = await getInitializedWidgets(); * console.log(widgets); * // ["Minicart", "SearchPanel", "ProductBrowser"] * ``` */ declare function getInitializedWidgets(): Promise; declare function getOwnerIdInternal(): Promise; /** * This method allows you to receive the store ID. Works on any opened storefront page. * * @example * * ```ts * import { getStoreId } from '@lightspeed/ecom-headless'; * * const storeId = await getStoreId(); * console.log(storeId); * // 1003 * ``` */ declare const getStoreId: typeof getOwnerIdInternal; /** * This method allows you to receive the store ID. Works on any opened storefront page. * * @example * * ```ts * import { getOwnerId } from '@lightspeed/ecom-headless'; * * const storeId = await getOwnerId(); * console.log(storeId); * // 1003 * ``` */ declare const getOwnerId: typeof getOwnerIdInternal; /** * This method responds with the current storefront language in ISO 639-1 language code. * Use it to dynamically translate custom content on the page. * * @example * * ```ts * import { getStorefrontLang } from '@lightspeed/ecom-headless'; * * const lang = await getStorefrontLang(); * console.log(lang); * // "en" * ``` */ declare function getStorefrontLang(): Promise; /** * This method receives the customer's answer to the cookie consent banner. * Use it to define what cookies your application can collect. * * If the cookie consent value is overridden by the JS method or config, * getTrackingConsent() returns the new value added by JS method/config. * * @example * * ```ts * import { getTrackingConsent } from '@lightspeed/ecom-headless'; * * const trackingConsent = await getTrackingConsent(); * console.log(trackingConsent); * // { userResponse: "ACCEPTED", askConsent: true } * ``` */ declare function getTrackingConsent(): Promise; /** * This method gets the visitor's location based on their shipping or billing address (when entered), or IP. * The call works even for signed-out customers. * * @example * * ```ts * import { getVisitorLocation } from '@lightspeed/ecom-headless'; * * const location = await getVisitorLocation(); * console.log(location); * // { countryCode: "US", stateCode: "NE", source: "IP_ADDRESS" } * ``` */ declare function getVisitorLocation(): Promise; /** * This method is useful for public applications developed before 2024. * It helps apps to adapt their design by detecting the old storefront version. * * All stores created in 2024 and later are using the latest storefront without the ability to switch the version. * * @example * * ```ts * import { isStorefrontV3 } from '@lightspeed/ecom-headless'; * * const isStorefrontV3 = await isStorefrontV3(); * console.log(isStorefrontV3); * // true * ``` */ declare function isStorefrontV3(): Promise; /** * This method allows you to open a specific page on the storefront. The function accepts page slugs and additional parameters in its arguments. * * For example, you can use these redirects in different promo activities: * - Create a popup with a sale product and redirect customers to this product on click. * - Offer customers to log in to receive some bonus. * - Redirect customers to the search page with pre-configured terms showing promo products. * * @example * * ```ts * import { openPage } from '@lightspeed/ecom-headless'; * * // Redirect customers to the cart page * openPage('cart'); * * // Open search page with shoes of one brand * openPage('search', { * keyword: 'shoes', * attribute_Brand: 'Nike', * inventory: 'instock' * }); * ``` * * @see Full list of available pages: https://docs.ecwid.com/storefronts/open-page-on-the-storefront/overview-of-open-page-options#full-list-of-available-pages * * Learn more about pages that can be opened with additional params: * * {@link https://docs.ecwid.com/storefronts/open-page-on-the-storefront/open-product-pages-with-params Open product pages with params} | * {@link https://docs.ecwid.com/storefronts/open-page-on-the-storefront/open-category-pages-with-params Open category pages with params} | * {@link https://docs.ecwid.com/storefronts/open-page-on-the-storefront/open-search-page-with-params Open search page with params} | * {@link https://docs.ecwid.com/storefronts/open-page-on-the-storefront/open-account-pages-with-params Open account pages with params} */ declare function openPage(page: string, options?: Record): Promise; /** * This method accepts an argument matching one of the following values: * * "UNDEFINED": Customer hasn't given their consent yet. * * "ACCEPTED": Collect all types of cookies. * * "DECLINED": Collect only essential cookies. * * "ANALYTICS_ONLY": Collect essential and analytics cookies only. * * "PERSONALIZATION_ONLY": Collect essential and personalization cookies. * * @example * * ```ts * import { setTrackingConsent, getTrackingConsent, CustomerCookieConsentValues } from '@lightspeed/ecom-headless'; * * await setTrackingConsent(CustomerCookieConsentValues.DECLINED); * const trackingConsent = await getTrackingConsent(); * console.log(trackingConsent); * // { userResponse: "DECLINED", askConsent: false } * ``` */ declare function setTrackingConsent(cookieConsent: CustomerCookieConsentType): Promise; /** * This method allows you to receive full information about the current shopping cart. * The response is available in the cart callback. * * @example * * ```ts * import { Cart } from '@lightspeed/ecom-headless'; * * Cart.get((cart) => { * console.log(`Cart has ${cart.productsQuantity} products`); * console.log(`Cart ID: ${cart.cartId}`); * cart.items.forEach(item => { * console.log(`${item.product.name} - Quantity: ${item.quantity}`); * }); * }); * ``` */ declare function get$1(callback?: CartGetCallback): Promise; /** * This method allows you to add a new product position to the shopping cart. * It accepts either a product ID or a product object with extended details including * product ID, quantity, selected options, or subscription product settings. * * When you use this method, it first checks the product by specified ID for stock and variations. * If the selected options match one of the variations, Ecwid will check its stock first. * If you don't have enough stock to add a product, Ecwid adds the available quantity. * If the product is out of stock, nothing is added to the shopping cart. * * @example * * ```ts * import { Cart } from '@lightspeed/ecom-headless'; * * // Add product by ID with default quantity * Cart.addProduct(10, (success, product, cart) => { * if (success) { * console.log('Product added successfully'); * } * }); * * // Add product with specific options and quantity * Cart.addProduct({ * id: 10, * quantity: 3, * options: { * "Size": "L" * } * }, (success, product, cart, error) => { * if (success) { * console.log(`Added ${product.quantity} items to cart`); * } else { * console.error('Failed to add product:', error); * } * }); * * // Add subscription product * Cart.addProduct({ * id: 15, * quantity: 1, * recurringChargeSettings: { * recurringInterval: "MONTH", * recurringIntervalCount: 1, * } * }); * ``` */ declare function addProduct(product: AddProductParameter, callback?: CartAddProductCallback): Promise; /** * This method removes product position from the shopping cart entirely. * The specified product will be removed completely even if its quantity is greater than zero. * * This method completely removes the product from the cart. If you want to decrease its quantity, * use Cart.get() to save product details, then remove the product with Cart.removeProduct() * and add it back with all the same details except for the decreased quantity with Cart.addProduct(). * * To remove a product position from the cart, first, you need to get an index with the Cart.get() method. * Position of the product in the items array is the index. For example, if you have two different * products added to the cart, the first product has an index of 0, and the second has an index of 1. * * @example * * ```ts * import { Cart } from '@lightspeed/ecom-headless'; * * // Remove the first product from cart * Cart.removeProduct(0, (success, itemsRemovedQuantity, product, cart, error) => { * if (success) { * console.log(`Removed ${itemsRemovedQuantity} items from cart`); * console.log(`Product removed: ${product.name}`); * } else { * console.error('Failed to remove product:', error); * } * }); * * // Remove product without callback * Cart.removeProduct(1); * ``` */ declare function removeProduct(index: number, callback?: CartRemoveProductCallback): Promise; /** * This method works in the same way as Cart.removeProduct(), but allows you to remove * multiple items from the cart at once by passing an array of indices. * * Each index represents the position of a product in the cart's items array. * All specified products will be removed completely even if their quantity is greater than zero. * * @example * * ```ts * import { Cart } from '@lightspeed/ecom-headless'; * * // Remove first and second products from cart * Cart.removeProducts([0, 1], (success, itemsRemovedQuantity, product, cart, error) => { * if (success) { * console.log(`Removed ${itemsRemovedQuantity} total items from cart`); * } else { * console.error('Failed to remove products:', error); * } * }); * * // Remove multiple products without callback * Cart.removeProducts([0, 2, 3]); * ``` */ declare function removeProducts(indices: number[], callback?: CartRemoveProductCallback): Promise; /** * This method allows you to clear all details from the shopping cart. * If the method clears the cart successfully, you receive true in the success argument. * * @example * * ```ts * import { Cart } from '@lightspeed/ecom-headless'; * * Cart.clear((success, error) => { * if (success) { * console.log("Cart was cleared"); * } else { * console.log("Cart clear failed. Error message: " + error); * } * }); * * // Clear without callback * Cart.clear(); * ``` */ declare function clear(callback?: CartClearCallback): Promise; /** * This method calculates the current cart asynchronously and passes the result as an order * callback argument with a snapshot of the generated order with essential details. * * The order object includes subtotals, taxes, discounts, shipping costs, and a full cart snapshot. * * @example * * ```ts * import { Cart } from '@lightspeed/ecom-headless'; * * Cart.calculateTotal((order) => { * console.log(`Order total: ${order.total}`); * console.log(`Subtotal: ${order.subtotal}`); * console.log(`Tax: ${order.tax}`); * console.log(`Shipping: ${order.shipping}`); * console.log(`Items in cart: ${order.cart.productsQuantity}`); * * // Access individual cart items * order.cart.items.forEach(item => { * console.log(`${item.product.name} - Qty: ${item.quantity}`); * }); * }); * ``` */ declare function calculateTotal(callback?: CartCalculateTotalCallback): Promise; /** * This method checks whether you can send customers to the first step of the checkout called the shopping cart. * * @example * * ```ts * import { Cart } from '@lightspeed/ecom-headless'; * * const canGoToCheckout = await Cart.canGotoCheckout(); * * if (canGoToCheckout) { * Cart.gotoCheckout(); * } * ``` */ declare function canGotoCheckout(): Promise; /** * This method sends a customer to the first or second checkout step. * * This method works differently depending on the Ecwid admin > Settings > Legal > Terms & Conditions toggle * and whether the customer has already left an email in the shopping cart: * * - No email: the customer is sent to the shopping cart page. * - Email + toggle disabled: the customer is sent to the second checkout page (address details) * - Email + toggle disabled + no shipping: the customer is sent to the payment page. * * @example * * ```ts * import { Cart } from '@lightspeed/ecom-headless'; * * Cart.gotoCheckout(() => { * console.log("Checkout process started"); * }); * ``` */ declare function gotoCheckout(callback?: CartGoToCheckoutCallback): Promise; declare const index$1_addProduct: typeof addProduct; declare const index$1_calculateTotal: typeof calculateTotal; declare const index$1_canGotoCheckout: typeof canGotoCheckout; declare const index$1_clear: typeof clear; declare const index$1_gotoCheckout: typeof gotoCheckout; declare const index$1_removeProduct: typeof removeProduct; declare const index$1_removeProducts: typeof removeProducts; declare namespace index$1 { export { index$1_addProduct as addProduct, index$1_calculateTotal as calculateTotal, index$1_canGotoCheckout as canGotoCheckout, index$1_clear as clear, get$1 as get, index$1_gotoCheckout as gotoCheckout, index$1_removeProduct as removeProduct, index$1_removeProducts as removeProducts, }; } /** * This method receives all data on the customer currently logged in to the store. * If no customer is logged in, the method returns null. * * @example * * ```ts * import { Customer } from '@lightspeed/ecom-headless'; * * Customer.get((customer) => { * if (customer === null) { * console.log('No customer is logged in'); * } else { * console.log(customer.email); * } * }); * ``` */ declare function get(callback?: CustomerGetCallback): Promise; /** * This method signs out customer from their account. * * Error message has value only if success is false. * * @example * * ```ts * import { Customer } from '@lightspeed/ecom-headless'; * * Customer.signOut((success, error) => { * if (success === true) { * console.log('Customer signed out'); * } else { * console.log('Signout failed. Error message: ' + error); * } * }); * ``` */ declare function signOut(callback?: CustomerSignOutCallback): Promise; declare const index_get: typeof get; declare const index_signOut: typeof signOut; declare namespace index { export { index_get as get, index_signOut as signOut, }; } export { EcwidWidgetValues as E, OnCartChanged as O, index as a, OnConsentChanged as b, OnPageLoad as c, OnPageLoaded as d, OnPageSwitch as e, OnSetProfile as f, formatCurrency as g, getAppPublicConfig as h, index$1 as i, getAppPublicToken as j, getInitializedWidgets as k, getOwnerId as l, getStoreId as m, getStorefrontLang as n, getTrackingConsent as o, getVisitorLocation as p, isStorefrontV3 as q, openPage as r, setTrackingConsent as s };