@rechargeapps/storefront-client 1.6.1 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -186,13 +186,14 @@ function deleteBundleSelection(session, id) {
186
186
  session
187
187
  );
188
188
  }
189
- async function updateBundle(session, purchase_item_id, updateRequest) {
189
+ async function updateBundle(session, purchase_item_id, updateRequest, query) {
190
190
  const { subscription } = await request.rechargeApiRequest(
191
191
  "put",
192
192
  "/bundles",
193
193
  {
194
194
  id: purchase_item_id,
195
- data: updateRequest
195
+ data: updateRequest,
196
+ query
196
197
  },
197
198
  session
198
199
  );
@@ -1 +1 @@
1
- {"version":3,"file":"bundle.js","sources":["../../../src/api/bundle.ts"],"sourcesContent":["import { nanoid } from 'nanoid';\nimport {\n BundleAppProxy,\n DynamicBundleItemAppProxy,\n BundleSelection,\n BundleSelectionListParams,\n BundleSelectionsResponse,\n CreateBundleSelectionRequest,\n Session,\n UpdateBundleSelectionRequest,\n UpdateBundlePurchaseItem,\n BundlePurchaseItem,\n} from '../types';\nimport { rechargeApiRequest, shopifyAppProxyRequest } from '../utils/request';\nimport { getOptions } from '../utils/options';\nimport { getCDNBundleSettings } from './cdn';\nimport { toLineItemProperty } from '../utils/bundle';\n\nconst STORE_FRONT_MANAGER_URL = '/bundling-storefront-manager';\n\nfunction getTimestampSecondsFromClient(): number {\n /**\n * Get the current unix epoch in seconds from the client-side.\n */\n return Math.ceil(Date.now() / 1000);\n}\n\nasync function getTimestampSecondsFromServer(): Promise<number> {\n /**\n * Get the unix epoch from the server instead of using it directly from the\n * client. This must reduce even more the number of invalid Bundles.\n */\n try {\n const { timestamp } = await shopifyAppProxyRequest<{ timestamp: number }>('get', `${STORE_FRONT_MANAGER_URL}/t`, {\n headers: { 'X-Recharge-App': 'storefront-client' },\n });\n return timestamp;\n } catch (ex) {\n console.error(`Fetch failed: ${ex}. Using client-side date.`);\n return getTimestampSecondsFromClient();\n }\n}\n\nexport async function getBundleId(bundle: BundleAppProxy): Promise<string> {\n const opts = getOptions();\n const isValid = await validateBundle(bundle);\n if (isValid !== true) {\n throw new Error(isValid);\n }\n const timestampSeconds = await getTimestampSecondsFromServer();\n const bundleData = toLineItemProperty({\n variantId: bundle.externalVariantId,\n version: timestampSeconds,\n items: bundle.selections.map(item => {\n return {\n collectionId: item.collectionId,\n productId: item.externalProductId,\n variantId: item.externalVariantId,\n quantity: item.quantity,\n sku: '',\n };\n }),\n });\n\n try {\n const payload = await shopifyAppProxyRequest<{ id: string; code: number; message: string }>(\n 'post',\n `${STORE_FRONT_MANAGER_URL}/api/v1/bundles`,\n {\n data: {\n bundle: bundleData,\n },\n headers: {\n Origin: `https://${opts.storeIdentifier}`,\n },\n }\n );\n\n if (!payload.id || payload.code !== 200) {\n throw new Error(`1: failed generating rb_id: ${JSON.stringify(payload)}`);\n }\n\n return payload.id;\n } catch (e) {\n // Handle NetworkError exceptions\n throw new Error(`2: failed generating rb_id ${e}`);\n }\n}\n\nexport function getDynamicBundleItems(bundle: BundleAppProxy, shopifyProductHandle: string) {\n const isValid = validateDynamicBundle(bundle);\n if (isValid !== true) {\n throw new Error(`Dynamic Bundle is invalid. ${isValid}`);\n }\n // generate unique id for dynamic bundle\n const bundleId = `${nanoid(9)}:${bundle.externalProductId}`;\n return bundle.selections.map(item => {\n const itemData: DynamicBundleItemAppProxy = {\n id: item.externalVariantId,\n quantity: item.quantity,\n properties: {\n _rc_bundle: bundleId,\n _rc_bundle_variant: bundle.externalVariantId,\n _rc_bundle_parent: shopifyProductHandle,\n _rc_bundle_collection_id: item.collectionId,\n },\n };\n\n if (item.sellingPlan) {\n // this is used by SCI stores\n itemData.selling_plan = item.sellingPlan;\n } else if (item.shippingIntervalFrequency) {\n // this is used by RCS stores\n itemData.properties.shipping_interval_frequency = item.shippingIntervalFrequency;\n itemData.properties.shipping_interval_unit_type = item.shippingIntervalUnitType;\n itemData.id = `${item.discountedVariantId}`;\n }\n\n return itemData;\n });\n}\n\nexport async function validateBundle(bundle: BundleAppProxy): Promise<true | string> {\n try {\n // once we implement this function, we can make it raise an exception\n // we could also have a local store relative to this function so we don't have to pass bundleProduct\n if (!bundle) {\n return 'Bundle is not defined';\n }\n const bundleSettings = await getCDNBundleSettings(bundle.externalProductId);\n if (!bundleSettings) {\n return 'Bundle settings do not exist for the given product';\n }\n return true;\n } catch (e) {\n return `Error fetching bundle settings: ${e}`;\n }\n}\n\nconst intervalUnitGroups = {\n day: ['day', 'days', 'Days'],\n days: ['day', 'days', 'Days'],\n Days: ['day', 'days', 'Days'],\n week: ['week', 'weeks', 'Weeks'],\n weeks: ['week', 'weeks', 'Weeks'],\n Weeks: ['week', 'weeks', 'Weeks'],\n month: ['month', 'months', 'Months'],\n months: ['month', 'months', 'Months'],\n Months: ['month', 'months', 'Months'],\n};\n\n/**\n * Validates a dynamic bundle\n *\n * @param bundle Dynamic Bundle being validated\n * @returns true or error message\n */\nexport function validateDynamicBundle(bundle: BundleAppProxy): true | string {\n if (!bundle) {\n return 'No bundle defined.';\n }\n if (bundle.selections.length === 0) {\n return 'No selections defined.';\n }\n // validation for RCS onetimes\n const { shippingIntervalFrequency, shippingIntervalUnitType } =\n bundle.selections.find(selection => selection.shippingIntervalFrequency || selection.shippingIntervalUnitType) ||\n {};\n if (shippingIntervalFrequency || shippingIntervalUnitType) {\n // if we have shipping intervals then we should have both defined\n if (!shippingIntervalFrequency || !shippingIntervalUnitType) {\n return 'Shipping intervals do not match on selections.';\n } else {\n // if we have shipping intervals then any that are defined should match\n const shippingIntervalUnitGroup = intervalUnitGroups[shippingIntervalUnitType];\n for (let x = 0; x < bundle.selections.length; x++) {\n const { shippingIntervalFrequency: frequency, shippingIntervalUnitType: unitType } = bundle.selections[x];\n if (\n (frequency && frequency !== shippingIntervalFrequency) ||\n (unitType && !shippingIntervalUnitGroup.includes(unitType))\n ) {\n return 'Shipping intervals do not match on selections.';\n }\n }\n }\n }\n return true;\n}\n\nexport async function getBundleSelection(session: Session, id: string | number): Promise<BundleSelection> {\n const { bundle_selection } = await rechargeApiRequest<{ bundle_selection: BundleSelection }>(\n 'get',\n `/bundle_selections`,\n {\n id,\n },\n session\n );\n return bundle_selection;\n}\n\nexport function listBundleSelections(\n session: Session,\n query?: BundleSelectionListParams\n): Promise<BundleSelectionsResponse> {\n return rechargeApiRequest<BundleSelectionsResponse>('get', `/bundle_selections`, { query }, session);\n}\n\nexport async function createBundleSelection(\n session: Session,\n createRequest: CreateBundleSelectionRequest\n): Promise<BundleSelection> {\n const { bundle_selection } = await rechargeApiRequest<{ bundle_selection: BundleSelection }>(\n 'post',\n `/bundle_selections`,\n {\n data: createRequest,\n },\n session\n );\n return bundle_selection;\n}\n\nexport async function updateBundleSelection(\n session: Session,\n id: string | number,\n updateRequest: UpdateBundleSelectionRequest\n): Promise<BundleSelection> {\n const { bundle_selection } = await rechargeApiRequest<{ bundle_selection: BundleSelection }>(\n 'put',\n `/bundle_selections`,\n {\n id,\n data: updateRequest,\n },\n session\n );\n return bundle_selection;\n}\n\nexport function deleteBundleSelection(session: Session, id: string | number): Promise<void> {\n return rechargeApiRequest<void>(\n 'delete',\n `/bundle_selections`,\n {\n id,\n },\n session\n );\n}\n\nexport async function updateBundle(\n session: Session,\n purchase_item_id: string | number,\n updateRequest: UpdateBundlePurchaseItem\n): Promise<BundlePurchaseItem> {\n const { subscription } = await rechargeApiRequest<{ subscription: BundlePurchaseItem }>(\n 'put',\n '/bundles',\n {\n id: purchase_item_id,\n data: updateRequest,\n },\n session\n );\n\n return subscription;\n}\n"],"names":["shopifyAppProxyRequest","bundle","getOptions","toLineItemProperty","nanoid","getCDNBundleSettings","rechargeApiRequest"],"mappings":";;;;;;;;;;AAKA,MAAM,uBAAuB,GAAG,8BAA8B,CAAC;AAC/D,SAAS,6BAA6B,GAAG;AACzC,EAAE,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC;AACrC,CAAC;AACD,eAAe,6BAA6B,GA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ACL,IAAI,OAAO;AACX,GAAG,CAAC;AACJ,EAAE,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AACM,eAAe,qBAAqB,CAAC,OAAO,EAAE,EAAE,EAAE,aAAa,EAAE;AACxE,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAMA,0BAAkB;AACvD,IAAI,KAAK;AACT,IAAI,CAAC,kBAAkB,CAAC;AACxB,IAAI;AACJ,MAAM,EAAE;AACR,MAAM,IAAI,EAAE,aAAa;AACzB,KAAK;AACL,IAAI,OAAO;AACX,GAAG,CAAC;AACJ,EAAE,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AACM,SAAS,qBAAqB,CAAC,OAAO,EAAE,EAAE,EAAE;AACnD,EAAE,OAAOA,0BAAkB;AAC3B,IAAI,QAAQ;AACZ,IAAI,CAAC,kBAAkB,CAAC;AACxB,IAAI;AACJ,MAAM,EAAE;AACR,KAAK;AACL,IAAI,OAAO;AACX,GAAG,CAAC;AACJ,CAAC;AACM,eAAe,YAAY,CAAC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE;AAC7E,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,MAAMA,0BAAkB;AACnD,IAAI,KAAK;AACT,IAAI,UAAU;AACd,IAAI;AACJ,MAAM,EAAE,EAAE,gBAAgB;AAC1B,MAAM,IAAI,EAAE,aAAa;AACzB,KAAK;AACL,IAAI,OAAO;AACX,GAAG,CAAC;AACJ,EAAE,OAAO,YAAY,CAAC;AACtB;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"bundle.js","sources":["../../../src/api/bundle.ts"],"sourcesContent":["import { nanoid } from 'nanoid';\nimport {\n BundleAppProxy,\n DynamicBundleItemAppProxy,\n BundleSelection,\n BundleSelectionListParams,\n BundleSelectionsResponse,\n CreateBundleSelectionRequest,\n Session,\n UpdateBundleSelectionRequest,\n UpdateBundlePurchaseItem,\n BundlePurchaseItem,\n BundlePurchaseItemParams,\n} from '../types';\nimport { rechargeApiRequest, shopifyAppProxyRequest } from '../utils/request';\nimport { getOptions } from '../utils/options';\nimport { getCDNBundleSettings } from './cdn';\nimport { toLineItemProperty } from '../utils/bundle';\n\nconst STORE_FRONT_MANAGER_URL = '/bundling-storefront-manager';\n\nfunction getTimestampSecondsFromClient(): number {\n /**\n * Get the current unix epoch in seconds from the client-side.\n */\n return Math.ceil(Date.now() / 1000);\n}\n\nasync function getTimestampSecondsFromServer(): Promise<number> {\n /**\n * Get the unix epoch from the server instead of using it directly from the\n * client. This must reduce even more the number of invalid Bundles.\n */\n try {\n const { timestamp } = await shopifyAppProxyRequest<{ timestamp: number }>('get', `${STORE_FRONT_MANAGER_URL}/t`, {\n headers: { 'X-Recharge-App': 'storefront-client' },\n });\n return timestamp;\n } catch (ex) {\n console.error(`Fetch failed: ${ex}. Using client-side date.`);\n return getTimestampSecondsFromClient();\n }\n}\n\nexport async function getBundleId(bundle: BundleAppProxy): Promise<string> {\n const opts = getOptions();\n const isValid = await validateBundle(bundle);\n if (isValid !== true) {\n throw new Error(isValid);\n }\n const timestampSeconds = await getTimestampSecondsFromServer();\n const bundleData = toLineItemProperty({\n variantId: bundle.externalVariantId,\n version: timestampSeconds,\n items: bundle.selections.map(item => {\n return {\n collectionId: item.collectionId,\n productId: item.externalProductId,\n variantId: item.externalVariantId,\n quantity: item.quantity,\n sku: '',\n };\n }),\n });\n\n try {\n const payload = await shopifyAppProxyRequest<{ id: string; code: number; message: string }>(\n 'post',\n `${STORE_FRONT_MANAGER_URL}/api/v1/bundles`,\n {\n data: {\n bundle: bundleData,\n },\n headers: {\n Origin: `https://${opts.storeIdentifier}`,\n },\n }\n );\n\n if (!payload.id || payload.code !== 200) {\n throw new Error(`1: failed generating rb_id: ${JSON.stringify(payload)}`);\n }\n\n return payload.id;\n } catch (e) {\n // Handle NetworkError exceptions\n throw new Error(`2: failed generating rb_id ${e}`);\n }\n}\n\nexport function getDynamicBundleItems(bundle: BundleAppProxy, shopifyProductHandle: string) {\n const isValid = validateDynamicBundle(bundle);\n if (isValid !== true) {\n throw new Error(`Dynamic Bundle is invalid. ${isValid}`);\n }\n // generate unique id for dynamic bundle\n const bundleId = `${nanoid(9)}:${bundle.externalProductId}`;\n return bundle.selections.map(item => {\n const itemData: DynamicBundleItemAppProxy = {\n id: item.externalVariantId,\n quantity: item.quantity,\n properties: {\n _rc_bundle: bundleId,\n _rc_bundle_variant: bundle.externalVariantId,\n _rc_bundle_parent: shopifyProductHandle,\n _rc_bundle_collection_id: item.collectionId,\n },\n };\n\n if (item.sellingPlan) {\n // this is used by SCI stores\n itemData.selling_plan = item.sellingPlan;\n } else if (item.shippingIntervalFrequency) {\n // this is used by RCS stores\n itemData.properties.shipping_interval_frequency = item.shippingIntervalFrequency;\n itemData.properties.shipping_interval_unit_type = item.shippingIntervalUnitType;\n itemData.id = `${item.discountedVariantId}`;\n }\n\n return itemData;\n });\n}\n\nexport async function validateBundle(bundle: BundleAppProxy): Promise<true | string> {\n try {\n // once we implement this function, we can make it raise an exception\n // we could also have a local store relative to this function so we don't have to pass bundleProduct\n if (!bundle) {\n return 'Bundle is not defined';\n }\n const bundleSettings = await getCDNBundleSettings(bundle.externalProductId);\n if (!bundleSettings) {\n return 'Bundle settings do not exist for the given product';\n }\n return true;\n } catch (e) {\n return `Error fetching bundle settings: ${e}`;\n }\n}\n\nconst intervalUnitGroups = {\n day: ['day', 'days', 'Days'],\n days: ['day', 'days', 'Days'],\n Days: ['day', 'days', 'Days'],\n week: ['week', 'weeks', 'Weeks'],\n weeks: ['week', 'weeks', 'Weeks'],\n Weeks: ['week', 'weeks', 'Weeks'],\n month: ['month', 'months', 'Months'],\n months: ['month', 'months', 'Months'],\n Months: ['month', 'months', 'Months'],\n};\n\n/**\n * Validates a dynamic bundle\n *\n * @param bundle Dynamic Bundle being validated\n * @returns true or error message\n */\nexport function validateDynamicBundle(bundle: BundleAppProxy): true | string {\n if (!bundle) {\n return 'No bundle defined.';\n }\n if (bundle.selections.length === 0) {\n return 'No selections defined.';\n }\n // validation for RCS onetimes\n const { shippingIntervalFrequency, shippingIntervalUnitType } =\n bundle.selections.find(selection => selection.shippingIntervalFrequency || selection.shippingIntervalUnitType) ||\n {};\n if (shippingIntervalFrequency || shippingIntervalUnitType) {\n // if we have shipping intervals then we should have both defined\n if (!shippingIntervalFrequency || !shippingIntervalUnitType) {\n return 'Shipping intervals do not match on selections.';\n } else {\n // if we have shipping intervals then any that are defined should match\n const shippingIntervalUnitGroup = intervalUnitGroups[shippingIntervalUnitType];\n for (let x = 0; x < bundle.selections.length; x++) {\n const { shippingIntervalFrequency: frequency, shippingIntervalUnitType: unitType } = bundle.selections[x];\n if (\n (frequency && frequency !== shippingIntervalFrequency) ||\n (unitType && !shippingIntervalUnitGroup.includes(unitType))\n ) {\n return 'Shipping intervals do not match on selections.';\n }\n }\n }\n }\n return true;\n}\n\nexport async function getBundleSelection(session: Session, id: string | number): Promise<BundleSelection> {\n const { bundle_selection } = await rechargeApiRequest<{ bundle_selection: BundleSelection }>(\n 'get',\n `/bundle_selections`,\n {\n id,\n },\n session\n );\n return bundle_selection;\n}\n\nexport function listBundleSelections(\n session: Session,\n query?: BundleSelectionListParams\n): Promise<BundleSelectionsResponse> {\n return rechargeApiRequest<BundleSelectionsResponse>('get', `/bundle_selections`, { query }, session);\n}\n\nexport async function createBundleSelection(\n session: Session,\n createRequest: CreateBundleSelectionRequest\n): Promise<BundleSelection> {\n const { bundle_selection } = await rechargeApiRequest<{ bundle_selection: BundleSelection }>(\n 'post',\n `/bundle_selections`,\n {\n data: createRequest,\n },\n session\n );\n return bundle_selection;\n}\n\nexport async function updateBundleSelection(\n session: Session,\n id: string | number,\n updateRequest: UpdateBundleSelectionRequest\n): Promise<BundleSelection> {\n const { bundle_selection } = await rechargeApiRequest<{ bundle_selection: BundleSelection }>(\n 'put',\n `/bundle_selections`,\n {\n id,\n data: updateRequest,\n },\n session\n );\n return bundle_selection;\n}\n\nexport function deleteBundleSelection(session: Session, id: string | number): Promise<void> {\n return rechargeApiRequest<void>(\n 'delete',\n `/bundle_selections`,\n {\n id,\n },\n session\n );\n}\n\nexport async function updateBundle(\n session: Session,\n purchase_item_id: string | number,\n updateRequest: UpdateBundlePurchaseItem,\n query?: BundlePurchaseItemParams\n): Promise<BundlePurchaseItem> {\n const { subscription } = await rechargeApiRequest<{ subscription: BundlePurchaseItem }>(\n 'put',\n '/bundles',\n {\n id: purchase_item_id,\n data: updateRequest,\n query,\n },\n session\n );\n\n return subscription;\n}\n"],"names":["shopifyAppProxyRequest","bundle","getOptions","toLineItemProperty","nanoid","getCDNBundleSettings","rechargeApiRequest"],"mappings":";;;;;;;;;;AAKA,MAAM,uBAAuB,GAAG,8BAA8B,CAAC;AAC/D,SAAS,6BAA6B,GAAG;AACzC,EAAE,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC;AACrC,CAAC;AACD,eAAe,6BAA6B,GAAG;AAC/C,EAAE,IAAI;AACN,IAAI,MAAM,EAAE,SAAS,EAAE,GAAG,MAAMA,8BAAsB,CAAC,KAAK,EAAE,CAAC,EAAE,uBAAuB,CAAC,EAAE,CAAC,EAAE;AAC9F,MAAM,OAAO,EAAE,EAAE,gBAAgB,EAAE,mBAAmB,EAAE;AACxD,KAAK,CAAC,CAAC;AACP,IAAI,OAAO,SAAS,CAAC;AACrB,GAAG,CAAC,OAAO,EAAE,EAAE;AACf,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,cAAc,EAAE,EAAE,CAAC,yBAAyB,CAAC,CAAC,CAAC;AAClE,IAAI,OAAO,6BAA6B,EAAE,CAAC;AAC3C,GAAG;AACH,CAAC;AACM,eAAe,WAAW,CAACC,QAAM,EAAE;AAC1C,EAAE,MAAM,IAAI,GAAGC,kBAAU,EAAE,CAAC;AAC5B,EAAE,MAAM,OAAO,GAAG,MAAM,cAAc,CAACD,QAAM,CAAC,CAAC;AAC/C,EAAE,IAAI,OAAO,KAAK,IAAI,EAAE;AACxB,IAAI,M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gB,EAAE,aAAa,EAAE,KAAK,EAAE;AACpF,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,MAAMA,0BAAkB;AACnD,IAAI,KAAK;AACT,IAAI,UAAU;AACd,IAAI;AACJ,MAAM,EAAE,EAAE,gBAAgB;AAC1B,MAAM,IAAI,EAAE,aAAa;AACzB,MAAM,KAAK;AACX,KAAK;AACL,IAAI,OAAO;AACX,GAAG,CAAC;AACJ,EAAE,OAAO,YAAY,CAAC;AACtB;;;;;;;;;;;;;"}
@@ -182,13 +182,14 @@ function deleteBundleSelection(session, id) {
182
182
  session
183
183
  );
184
184
  }
185
- async function updateBundle(session, purchase_item_id, updateRequest) {
185
+ async function updateBundle(session, purchase_item_id, updateRequest, query) {
186
186
  const { subscription } = await rechargeApiRequest(
187
187
  "put",
188
188
  "/bundles",
189
189
  {
190
190
  id: purchase_item_id,
191
- data: updateRequest
191
+ data: updateRequest,
192
+ query
192
193
  },
193
194
  session
194
195
  );
@@ -1 +1 @@
1
- {"version":3,"file":"bundle.js","sources":["../../../src/api/bundle.ts"],"sourcesContent":["import { nanoid } from 'nanoid';\nimport {\n BundleAppProxy,\n DynamicBundleItemAppProxy,\n BundleSelection,\n BundleSelectionListParams,\n BundleSelectionsResponse,\n CreateBundleSelectionRequest,\n Session,\n UpdateBundleSelectionRequest,\n UpdateBundlePurchaseItem,\n BundlePurchaseItem,\n} from '../types';\nimport { rechargeApiRequest, shopifyAppProxyRequest } from '../utils/request';\nimport { getOptions } from '../utils/options';\nimport { getCDNBundleSettings } from './cdn';\nimport { toLineItemProperty } from '../utils/bundle';\n\nconst STORE_FRONT_MANAGER_URL = '/bundling-storefront-manager';\n\nfunction getTimestampSecondsFromClient(): number {\n /**\n * Get the current unix epoch in seconds from the client-side.\n */\n return Math.ceil(Date.now() / 1000);\n}\n\nasync function getTimestampSecondsFromServer(): Promise<number> {\n /**\n * Get the unix epoch from the server instead of using it directly from the\n * client. This must reduce even more the number of invalid Bundles.\n */\n try {\n const { timestamp } = await shopifyAppProxyRequest<{ timestamp: number }>('get', `${STORE_FRONT_MANAGER_URL}/t`, {\n headers: { 'X-Recharge-App': 'storefront-client' },\n });\n return timestamp;\n } catch (ex) {\n console.error(`Fetch failed: ${ex}. Using client-side date.`);\n return getTimestampSecondsFromClient();\n }\n}\n\nexport async function getBundleId(bundle: BundleAppProxy): Promise<string> {\n const opts = getOptions();\n const isValid = await validateBundle(bundle);\n if (isValid !== true) {\n throw new Error(isValid);\n }\n const timestampSeconds = await getTimestampSecondsFromServer();\n const bundleData = toLineItemProperty({\n variantId: bundle.externalVariantId,\n version: timestampSeconds,\n items: bundle.selections.map(item => {\n return {\n collectionId: item.collectionId,\n productId: item.externalProductId,\n variantId: item.externalVariantId,\n quantity: item.quantity,\n sku: '',\n };\n }),\n });\n\n try {\n const payload = await shopifyAppProxyRequest<{ id: string; code: number; message: string }>(\n 'post',\n `${STORE_FRONT_MANAGER_URL}/api/v1/bundles`,\n {\n data: {\n bundle: bundleData,\n },\n headers: {\n Origin: `https://${opts.storeIdentifier}`,\n },\n }\n );\n\n if (!payload.id || payload.code !== 200) {\n throw new Error(`1: failed generating rb_id: ${JSON.stringify(payload)}`);\n }\n\n return payload.id;\n } catch (e) {\n // Handle NetworkError exceptions\n throw new Error(`2: failed generating rb_id ${e}`);\n }\n}\n\nexport function getDynamicBundleItems(bundle: BundleAppProxy, shopifyProductHandle: string) {\n const isValid = validateDynamicBundle(bundle);\n if (isValid !== true) {\n throw new Error(`Dynamic Bundle is invalid. ${isValid}`);\n }\n // generate unique id for dynamic bundle\n const bundleId = `${nanoid(9)}:${bundle.externalProductId}`;\n return bundle.selections.map(item => {\n const itemData: DynamicBundleItemAppProxy = {\n id: item.externalVariantId,\n quantity: item.quantity,\n properties: {\n _rc_bundle: bundleId,\n _rc_bundle_variant: bundle.externalVariantId,\n _rc_bundle_parent: shopifyProductHandle,\n _rc_bundle_collection_id: item.collectionId,\n },\n };\n\n if (item.sellingPlan) {\n // this is used by SCI stores\n itemData.selling_plan = item.sellingPlan;\n } else if (item.shippingIntervalFrequency) {\n // this is used by RCS stores\n itemData.properties.shipping_interval_frequency = item.shippingIntervalFrequency;\n itemData.properties.shipping_interval_unit_type = item.shippingIntervalUnitType;\n itemData.id = `${item.discountedVariantId}`;\n }\n\n return itemData;\n });\n}\n\nexport async function validateBundle(bundle: BundleAppProxy): Promise<true | string> {\n try {\n // once we implement this function, we can make it raise an exception\n // we could also have a local store relative to this function so we don't have to pass bundleProduct\n if (!bundle) {\n return 'Bundle is not defined';\n }\n const bundleSettings = await getCDNBundleSettings(bundle.externalProductId);\n if (!bundleSettings) {\n return 'Bundle settings do not exist for the given product';\n }\n return true;\n } catch (e) {\n return `Error fetching bundle settings: ${e}`;\n }\n}\n\nconst intervalUnitGroups = {\n day: ['day', 'days', 'Days'],\n days: ['day', 'days', 'Days'],\n Days: ['day', 'days', 'Days'],\n week: ['week', 'weeks', 'Weeks'],\n weeks: ['week', 'weeks', 'Weeks'],\n Weeks: ['week', 'weeks', 'Weeks'],\n month: ['month', 'months', 'Months'],\n months: ['month', 'months', 'Months'],\n Months: ['month', 'months', 'Months'],\n};\n\n/**\n * Validates a dynamic bundle\n *\n * @param bundle Dynamic Bundle being validated\n * @returns true or error message\n */\nexport function validateDynamicBundle(bundle: BundleAppProxy): true | string {\n if (!bundle) {\n return 'No bundle defined.';\n }\n if (bundle.selections.length === 0) {\n return 'No selections defined.';\n }\n // validation for RCS onetimes\n const { shippingIntervalFrequency, shippingIntervalUnitType } =\n bundle.selections.find(selection => selection.shippingIntervalFrequency || selection.shippingIntervalUnitType) ||\n {};\n if (shippingIntervalFrequency || shippingIntervalUnitType) {\n // if we have shipping intervals then we should have both defined\n if (!shippingIntervalFrequency || !shippingIntervalUnitType) {\n return 'Shipping intervals do not match on selections.';\n } else {\n // if we have shipping intervals then any that are defined should match\n const shippingIntervalUnitGroup = intervalUnitGroups[shippingIntervalUnitType];\n for (let x = 0; x < bundle.selections.length; x++) {\n const { shippingIntervalFrequency: frequency, shippingIntervalUnitType: unitType } = bundle.selections[x];\n if (\n (frequency && frequency !== shippingIntervalFrequency) ||\n (unitType && !shippingIntervalUnitGroup.includes(unitType))\n ) {\n return 'Shipping intervals do not match on selections.';\n }\n }\n }\n }\n return true;\n}\n\nexport async function getBundleSelection(session: Session, id: string | number): Promise<BundleSelection> {\n const { bundle_selection } = await rechargeApiRequest<{ bundle_selection: BundleSelection }>(\n 'get',\n `/bundle_selections`,\n {\n id,\n },\n session\n );\n return bundle_selection;\n}\n\nexport function listBundleSelections(\n session: Session,\n query?: BundleSelectionListParams\n): Promise<BundleSelectionsResponse> {\n return rechargeApiRequest<BundleSelectionsResponse>('get', `/bundle_selections`, { query }, session);\n}\n\nexport async function createBundleSelection(\n session: Session,\n createRequest: CreateBundleSelectionRequest\n): Promise<BundleSelection> {\n const { bundle_selection } = await rechargeApiRequest<{ bundle_selection: BundleSelection }>(\n 'post',\n `/bundle_selections`,\n {\n data: createRequest,\n },\n session\n );\n return bundle_selection;\n}\n\nexport async function updateBundleSelection(\n session: Session,\n id: string | number,\n updateRequest: UpdateBundleSelectionRequest\n): Promise<BundleSelection> {\n const { bundle_selection } = await rechargeApiRequest<{ bundle_selection: BundleSelection }>(\n 'put',\n `/bundle_selections`,\n {\n id,\n data: updateRequest,\n },\n session\n );\n return bundle_selection;\n}\n\nexport function deleteBundleSelection(session: Session, id: string | number): Promise<void> {\n return rechargeApiRequest<void>(\n 'delete',\n `/bundle_selections`,\n {\n id,\n },\n session\n );\n}\n\nexport async function updateBundle(\n session: Session,\n purchase_item_id: string | number,\n updateRequest: UpdateBundlePurchaseItem\n): Promise<BundlePurchaseItem> {\n const { subscription } = await rechargeApiRequest<{ subscription: BundlePurchaseItem }>(\n 'put',\n '/bundles',\n {\n id: purchase_item_id,\n data: updateRequest,\n },\n session\n );\n\n return subscription;\n}\n"],"names":[],"mappings":";;;;;;AAKA,MAAM,uBAAuB,GAAG,8BAA8B,CAAC;AAC/D,SAAS,6BAA6B,GAAG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AAkB;AACvD,IAAI,MAAM;AACV,IAAI,CAAC,kBAAkB,CAAC;AACxB,IAAI;AACJ,MAAM,IAAI,EAAE,aAAa;AACzB,KAAK;AACL,IAAI,OAAO;AACX,GAAG,CAAC;AACJ,EAAE,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AACM,eAAe,qBAAqB,CAAC,OAAO,EAAE,EAAE,EAAE,aAAa,EAAE;AACxE,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAM,kBAAkB;AACvD,IAAI,KAAK;AACT,IAAI,CAAC,kBAAkB,CAAC;AACxB,IAAI;AACJ,MAAM,EAAE;AACR,MAAM,IAAI,EAAE,aAAa;AACzB,KAAK;AACL,IAAI,OAAO;AACX,GAAG,CAAC;AACJ,EAAE,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AACM,SAAS,qBAAqB,CAAC,OAAO,EAAE,EAAE,EAAE;AACnD,EAAE,OAAO,kBAAkB;AAC3B,IAAI,QAAQ;AACZ,IAAI,CAAC,kBAAkB,CAAC;AACxB,IAAI;AACJ,MAAM,EAAE;AACR,KAAK;AACL,IAAI,OAAO;AACX,GAAG,CAAC;AACJ,CAAC;AACM,eAAe,YAAY,CAAC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE;AAC7E,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,kBAAkB;AACnD,IAAI,KAAK;AACT,IAAI,UAAU;AACd,IAAI;AACJ,MAAM,EAAE,EAAE,gBAAgB;AAC1B,MAAM,IAAI,EAAE,aAAa;AACzB,KAAK;AACL,IAAI,OAAO;AACX,GAAG,CAAC;AACJ,EAAE,OAAO,YAAY,CAAC;AACtB;;;;"}
1
+ {"version":3,"file":"bundle.js","sources":["../../../src/api/bundle.ts"],"sourcesContent":["import { nanoid } from 'nanoid';\nimport {\n BundleAppProxy,\n DynamicBundleItemAppProxy,\n BundleSelection,\n BundleSelectionListParams,\n BundleSelectionsResponse,\n CreateBundleSelectionRequest,\n Session,\n UpdateBundleSelectionRequest,\n UpdateBundlePurchaseItem,\n BundlePurchaseItem,\n BundlePurchaseItemParams,\n} from '../types';\nimport { rechargeApiRequest, shopifyAppProxyRequest } from '../utils/request';\nimport { getOptions } from '../utils/options';\nimport { getCDNBundleSettings } from './cdn';\nimport { toLineItemProperty } from '../utils/bundle';\n\nconst STORE_FRONT_MANAGER_URL = '/bundling-storefront-manager';\n\nfunction getTimestampSecondsFromClient(): number {\n /**\n * Get the current unix epoch in seconds from the client-side.\n */\n return Math.ceil(Date.now() / 1000);\n}\n\nasync function getTimestampSecondsFromServer(): Promise<number> {\n /**\n * Get the unix epoch from the server instead of using it directly from the\n * client. This must reduce even more the number of invalid Bundles.\n */\n try {\n const { timestamp } = await shopifyAppProxyRequest<{ timestamp: number }>('get', `${STORE_FRONT_MANAGER_URL}/t`, {\n headers: { 'X-Recharge-App': 'storefront-client' },\n });\n return timestamp;\n } catch (ex) {\n console.error(`Fetch failed: ${ex}. Using client-side date.`);\n return getTimestampSecondsFromClient();\n }\n}\n\nexport async function getBundleId(bundle: BundleAppProxy): Promise<string> {\n const opts = getOptions();\n const isValid = await validateBundle(bundle);\n if (isValid !== true) {\n throw new Error(isValid);\n }\n const timestampSeconds = await getTimestampSecondsFromServer();\n const bundleData = toLineItemProperty({\n variantId: bundle.externalVariantId,\n version: timestampSeconds,\n items: bundle.selections.map(item => {\n return {\n collectionId: item.collectionId,\n productId: item.externalProductId,\n variantId: item.externalVariantId,\n quantity: item.quantity,\n sku: '',\n };\n }),\n });\n\n try {\n const payload = await shopifyAppProxyRequest<{ id: string; code: number; message: string }>(\n 'post',\n `${STORE_FRONT_MANAGER_URL}/api/v1/bundles`,\n {\n data: {\n bundle: bundleData,\n },\n headers: {\n Origin: `https://${opts.storeIdentifier}`,\n },\n }\n );\n\n if (!payload.id || payload.code !== 200) {\n throw new Error(`1: failed generating rb_id: ${JSON.stringify(payload)}`);\n }\n\n return payload.id;\n } catch (e) {\n // Handle NetworkError exceptions\n throw new Error(`2: failed generating rb_id ${e}`);\n }\n}\n\nexport function getDynamicBundleItems(bundle: BundleAppProxy, shopifyProductHandle: string) {\n const isValid = validateDynamicBundle(bundle);\n if (isValid !== true) {\n throw new Error(`Dynamic Bundle is invalid. ${isValid}`);\n }\n // generate unique id for dynamic bundle\n const bundleId = `${nanoid(9)}:${bundle.externalProductId}`;\n return bundle.selections.map(item => {\n const itemData: DynamicBundleItemAppProxy = {\n id: item.externalVariantId,\n quantity: item.quantity,\n properties: {\n _rc_bundle: bundleId,\n _rc_bundle_variant: bundle.externalVariantId,\n _rc_bundle_parent: shopifyProductHandle,\n _rc_bundle_collection_id: item.collectionId,\n },\n };\n\n if (item.sellingPlan) {\n // this is used by SCI stores\n itemData.selling_plan = item.sellingPlan;\n } else if (item.shippingIntervalFrequency) {\n // this is used by RCS stores\n itemData.properties.shipping_interval_frequency = item.shippingIntervalFrequency;\n itemData.properties.shipping_interval_unit_type = item.shippingIntervalUnitType;\n itemData.id = `${item.discountedVariantId}`;\n }\n\n return itemData;\n });\n}\n\nexport async function validateBundle(bundle: BundleAppProxy): Promise<true | string> {\n try {\n // once we implement this function, we can make it raise an exception\n // we could also have a local store relative to this function so we don't have to pass bundleProduct\n if (!bundle) {\n return 'Bundle is not defined';\n }\n const bundleSettings = await getCDNBundleSettings(bundle.externalProductId);\n if (!bundleSettings) {\n return 'Bundle settings do not exist for the given product';\n }\n return true;\n } catch (e) {\n return `Error fetching bundle settings: ${e}`;\n }\n}\n\nconst intervalUnitGroups = {\n day: ['day', 'days', 'Days'],\n days: ['day', 'days', 'Days'],\n Days: ['day', 'days', 'Days'],\n week: ['week', 'weeks', 'Weeks'],\n weeks: ['week', 'weeks', 'Weeks'],\n Weeks: ['week', 'weeks', 'Weeks'],\n month: ['month', 'months', 'Months'],\n months: ['month', 'months', 'Months'],\n Months: ['month', 'months', 'Months'],\n};\n\n/**\n * Validates a dynamic bundle\n *\n * @param bundle Dynamic Bundle being validated\n * @returns true or error message\n */\nexport function validateDynamicBundle(bundle: BundleAppProxy): true | string {\n if (!bundle) {\n return 'No bundle defined.';\n }\n if (bundle.selections.length === 0) {\n return 'No selections defined.';\n }\n // validation for RCS onetimes\n const { shippingIntervalFrequency, shippingIntervalUnitType } =\n bundle.selections.find(selection => selection.shippingIntervalFrequency || selection.shippingIntervalUnitType) ||\n {};\n if (shippingIntervalFrequency || shippingIntervalUnitType) {\n // if we have shipping intervals then we should have both defined\n if (!shippingIntervalFrequency || !shippingIntervalUnitType) {\n return 'Shipping intervals do not match on selections.';\n } else {\n // if we have shipping intervals then any that are defined should match\n const shippingIntervalUnitGroup = intervalUnitGroups[shippingIntervalUnitType];\n for (let x = 0; x < bundle.selections.length; x++) {\n const { shippingIntervalFrequency: frequency, shippingIntervalUnitType: unitType } = bundle.selections[x];\n if (\n (frequency && frequency !== shippingIntervalFrequency) ||\n (unitType && !shippingIntervalUnitGroup.includes(unitType))\n ) {\n return 'Shipping intervals do not match on selections.';\n }\n }\n }\n }\n return true;\n}\n\nexport async function getBundleSelection(session: Session, id: string | number): Promise<BundleSelection> {\n const { bundle_selection } = await rechargeApiRequest<{ bundle_selection: BundleSelection }>(\n 'get',\n `/bundle_selections`,\n {\n id,\n },\n session\n );\n return bundle_selection;\n}\n\nexport function listBundleSelections(\n session: Session,\n query?: BundleSelectionListParams\n): Promise<BundleSelectionsResponse> {\n return rechargeApiRequest<BundleSelectionsResponse>('get', `/bundle_selections`, { query }, session);\n}\n\nexport async function createBundleSelection(\n session: Session,\n createRequest: CreateBundleSelectionRequest\n): Promise<BundleSelection> {\n const { bundle_selection } = await rechargeApiRequest<{ bundle_selection: BundleSelection }>(\n 'post',\n `/bundle_selections`,\n {\n data: createRequest,\n },\n session\n );\n return bundle_selection;\n}\n\nexport async function updateBundleSelection(\n session: Session,\n id: string | number,\n updateRequest: UpdateBundleSelectionRequest\n): Promise<BundleSelection> {\n const { bundle_selection } = await rechargeApiRequest<{ bundle_selection: BundleSelection }>(\n 'put',\n `/bundle_selections`,\n {\n id,\n data: updateRequest,\n },\n session\n );\n return bundle_selection;\n}\n\nexport function deleteBundleSelection(session: Session, id: string | number): Promise<void> {\n return rechargeApiRequest<void>(\n 'delete',\n `/bundle_selections`,\n {\n id,\n },\n session\n );\n}\n\nexport async function updateBundle(\n session: Session,\n purchase_item_id: string | number,\n updateRequest: UpdateBundlePurchaseItem,\n query?: BundlePurchaseItemParams\n): Promise<BundlePurchaseItem> {\n const { subscription } = await rechargeApiRequest<{ subscription: BundlePurchaseItem }>(\n 'put',\n '/bundles',\n {\n id: purchase_item_id,\n data: updateRequest,\n query,\n },\n session\n );\n\n return subscription;\n}\n"],"names":[],"mappings":";;;;;;AAKA,MAAM,uBAAuB,GAAG,8BAA8B,CAAC;AAC/D,SAAS,6BAA6B,GAAG;AACzC,EAAE,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC;AACrC,CAAC;AACD,eAAe,6BAA6B,GAAG;AAC/C,EAAE,IAAI;AACN,IAAI,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,sBAAsB,CAAC,KAAK,EAAE,CAAC,EAAE,uBAAuB,CAAC,EAAE,CAAC,EAAE;AAC9F,MAAM,OAAO,EAAE,EAAE,gBAAgB,EAAE,mBAAmB,EAAE;AACxD,KAAK,CAAC,CAAC;AACP,IAAI,OAAO,SAAS,CAAC;AACrB,GAAG,CAAC,OAAO,EAAE,EAAE;AACf,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,cAAc,EAAE,EAAE,CAAC,yBAAyB,CAAC,CAAC,CAAC;AAClE,IAAI,OAAO,6BAA6B,EAAE,CAAC;AAC3C,GAAG;AACH,CAAC;AACM,eAAe,WAAW,CAAC,MAAM,EAAE;AAC1C,EAAE,MAAM,IAAI,GAAG,UAAU,EAAE,CAAC;AAC5B,EAAE,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,MAAM,CAAC,CAAC;AAC/C,EAAE,IAAI,OAAO,KAAK,IAAI,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,gBAAgB,EAAE,aAAa,EAAE,KAAK,EAAE;AACpF,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,kBAAkB;AACnD,IAAI,KAAK;AACT,IAAI,UAAU;AACd,IAAI;AACJ,MAAM,EAAE,EAAE,gBAAgB;AAC1B,MAAM,IAAI,EAAE,aAAa;AACzB,MAAM,KAAK;AACX,KAAK;AACL,IAAI,OAAO;AACX,GAAG,CAAC;AACJ,EAAE,OAAO,YAAY,CAAC;AACtB;;;;"}
package/dist/index.d.ts CHANGED
@@ -339,6 +339,9 @@ interface UpdateBundlePurchaseItem extends UpdateSubscriptionRequest {
339
339
  interface BundlePurchaseItem extends Subscription {
340
340
  items: BundleSelectionItem[];
341
341
  }
342
+ interface BundlePurchaseItemParams {
343
+ commit?: boolean;
344
+ }
342
345
 
343
346
  interface AddonSettings {
344
347
  collectionId: string;
@@ -2046,7 +2049,7 @@ declare function listBundleSelections(session: Session, query?: BundleSelectionL
2046
2049
  declare function createBundleSelection(session: Session, createRequest: CreateBundleSelectionRequest): Promise<BundleSelection>;
2047
2050
  declare function updateBundleSelection(session: Session, id: string | number, updateRequest: UpdateBundleSelectionRequest): Promise<BundleSelection>;
2048
2051
  declare function deleteBundleSelection(session: Session, id: string | number): Promise<void>;
2049
- declare function updateBundle(session: Session, purchase_item_id: string | number, updateRequest: UpdateBundlePurchaseItem): Promise<BundlePurchaseItem>;
2052
+ declare function updateBundle(session: Session, purchase_item_id: string | number, updateRequest: UpdateBundlePurchaseItem, query?: BundlePurchaseItemParams): Promise<BundlePurchaseItem>;
2050
2053
 
2051
2054
  /** @internal Retrieves membership information for passed in id */
2052
2055
  declare function getMembership(session: Session, id: string | number): Promise<Membership>;
@@ -2155,4 +2158,4 @@ declare const api: {
2155
2158
  };
2156
2159
  declare function initRecharge(opt?: InitOptions): void;
2157
2160
 
2158
- export { ActivateMembershipRequest, Address, AddressIncludes, AddressListParams, AddressListResponse, AddressResponse, AddressSortBy, AnalyticsData, AssociatedAddress, BasicSubscriptionParams, BooleanLike, BooleanNumbers, BooleanString, BooleanStringNumbers, BundleAppProxy, BundleProduct, BundlePurchaseItem, BundleSelection, BundleSelectionAppProxy, BundleSelectionItem, BundleSelectionItemRequiredCreateProps, BundleSelectionListParams, BundleSelectionsResponse, BundleSelectionsSortBy, BundleTranslations, CDNBaseWidgetSettings, CDNBundleLayoutSettings, CDNBundleSettings, CDNBundleStep, CDNBundleStepOption, CDNBundleVariant, CDNBundleVariantOptionSource, CDNBundleVariantSelectionDefault, CDNPrices, CDNProduct, CDNProductAndSettings, CDNProductKeyObject, CDNProductOption, CDNProductOptionValue, CDNProductRaw, CDNProductResource, CDNProductsAndSettings, CDNProductsAndSettingsResource, CDNSellingPlan, CDNSellingPlanAllocations, CDNSellingPlanGroup, CDNStoreSettings, CDNSubscriptionOption, CDNVariant, CDNVariantOptionValue, CDNWidgetSettings, CDNWidgetSettingsRaw, CDNWidgetSettingsResource, CRUDRequestOptions, CancelMembershipRequest, CancelSubscriptionRequest, ChangeMembershipRequest, ChannelSettings, Charge, ChargeIncludes, ChargeListParams, ChargeListResponse, ChargeResponse, ChargeSortBy, ChargeStatus, ColorString, CreateAddressRequest, CreateBundleSelectionRequest, CreateMetafieldRequest, CreateOnetimeRequest, CreateRecipientAddress, CreateSubscriptionRequest, Customer, CustomerDeliveryScheduleParams, CustomerDeliveryScheduleResponse, CustomerIncludes, CustomerPortalAccessResponse, Delivery, DeliveryLineItem, DeliveryOrder, DeliveryPaymentMethod, Discount, DynamicBundleItemAppProxy, DynamicBundlePropertiesAppProxy, ExternalAttributeSchema, ExternalId, ExternalTransactionId, FirstOption, GetAddressOptions, GetChargeOptions, GetCustomerOptions, GetMembershipProgramOptions, GetPaymentMethodOptions, GetRequestOptions, GetSubscriptionOptions, HTMLString, InitOptions, IntervalUnit, IsoDateString, LineItem, ListParams, LoginResponse, Membership, MembershipBenefit, MembershipIncludes, MembershipListParams, MembershipListResponse, MembershipProgram, MembershipProgramIncludes, MembershipProgramListParams, MembershipProgramListResponse, MembershipProgramResponse, MembershipProgramSortBy, MembershipProgramStatus, MembershipResponse, MembershipStatus, MembershipsSortBy, MergeAddressesRequest, Metafield, MetafieldOptionalCreateProps, MetafieldOwnerResource, MetafieldRequiredCreateProps, Method, Onetime, OnetimeListParams, OnetimeOptionalCreateProps, OnetimeRequiredCreateProps, OnetimesResponse, OnetimesSortBy, Order, OrderIncludes, OrderListParams, OrderSortBy, OrderStatus, OrderType, OrdersResponse, PasswordlessCodeResponse, PasswordlessOptions, PasswordlessValidateResponse, PaymentDetails, PaymentMethod, PaymentMethodIncludes, PaymentMethodListParams, PaymentMethodSortBy, PaymentMethodStatus, PaymentMethodsResponse, PaymentType, Plan, PlanListParams, PlanSortBy, PlanType, PlansResponse, PriceAdjustmentsType, ProcessorName, ProductImage, Property, Request, RequestHeaders, RequestOptions, Session, ShippingLine, SkipFutureChargeAddressRequest, SkipFutureChargeAddressResponse, StorefrontEnvironment, StorefrontOptions, StorefrontPurchaseOption, SubType, Subscription, SubscriptionIncludes, SubscriptionListParams, SubscriptionOptionalCreateProps, SubscriptionPreferences, SubscriptionRequiredCreateProps, SubscriptionSortBy, SubscriptionStatus, Subscription_2021_01, SubscriptionsResponse, TaxLine, Translations, UpdateAddressRequest, UpdateBundlePurchaseItem, UpdateBundleSelectionRequest, UpdateCustomerRequest, UpdateMetafieldRequest, UpdateOnetimeRequest, UpdatePaymentMethodRequest, UpdateSubscriptionParams, UpdateSubscriptionRequest, UpdateSubscriptionsParams, UpdateSubscriptionsRequest, WidgetIconColor, WidgetTemplateType, activateMembership, activateSubscription, api, applyDiscountToAddress, applyDiscountToCharge, cancelMembership, cancelSubscription, changeMembership, createAddress, createBundleSelection, createMetafield, createOnetime, createSubscription, createSubscriptions, deleteAddress, deleteBundleSelection, deleteMetafield, deleteOnetime, getAddress, getBundleId, getBundleSelection, getCDNBundleSettings, getCDNProduct, getCDNProductAndSettings, getCDNProducts, getCDNProductsAndSettings, getCDNStoreSettings, getCDNWidgetSettings, getCharge, getCustomer, getCustomerPortalAccess, getDeliverySchedule, getDynamicBundleItems, getMembership, getMembershipProgram, getOnetime, getOrder, getPaymentMethod, getPlan, getSubscription, initRecharge, intervalUnit, listAddresses, listBundleSelections, listCharges, listMembershipPrograms, listMemberships, listOnetimes, listOrders, listPaymentMethods, listPlans, listSubscriptions, loginCustomerPortal, loginShopifyApi, loginShopifyAppProxy, membershipIncludes, mergeAddresses, processCharge, removeDiscountsFromAddress, removeDiscountsFromCharge, resetCDNCache, sendPasswordlessCode, sendPasswordlessCodeAppProxy, skipCharge, skipFutureCharge, skipGiftSubscriptionCharge, skipSubscriptionCharge, unskipCharge, updateAddress, updateBundle, updateBundleSelection, updateCustomer, updateMetafield, updateOnetime, updatePaymentMethod, updateSubscription, updateSubscriptionAddress, updateSubscriptionChargeDate, updateSubscriptions, validateBundle, validateDynamicBundle, validatePasswordlessCode, validatePasswordlessCodeAppProxy };
2161
+ export { ActivateMembershipRequest, Address, AddressIncludes, AddressListParams, AddressListResponse, AddressResponse, AddressSortBy, AnalyticsData, AssociatedAddress, BasicSubscriptionParams, BooleanLike, BooleanNumbers, BooleanString, BooleanStringNumbers, BundleAppProxy, BundleProduct, BundlePurchaseItem, BundlePurchaseItemParams, BundleSelection, BundleSelectionAppProxy, BundleSelectionItem, BundleSelectionItemRequiredCreateProps, BundleSelectionListParams, BundleSelectionsResponse, BundleSelectionsSortBy, BundleTranslations, CDNBaseWidgetSettings, CDNBundleLayoutSettings, CDNBundleSettings, CDNBundleStep, CDNBundleStepOption, CDNBundleVariant, CDNBundleVariantOptionSource, CDNBundleVariantSelectionDefault, CDNPrices, CDNProduct, CDNProductAndSettings, CDNProductKeyObject, CDNProductOption, CDNProductOptionValue, CDNProductRaw, CDNProductResource, CDNProductsAndSettings, CDNProductsAndSettingsResource, CDNSellingPlan, CDNSellingPlanAllocations, CDNSellingPlanGroup, CDNStoreSettings, CDNSubscriptionOption, CDNVariant, CDNVariantOptionValue, CDNWidgetSettings, CDNWidgetSettingsRaw, CDNWidgetSettingsResource, CRUDRequestOptions, CancelMembershipRequest, CancelSubscriptionRequest, ChangeMembershipRequest, ChannelSettings, Charge, ChargeIncludes, ChargeListParams, ChargeListResponse, ChargeResponse, ChargeSortBy, ChargeStatus, ColorString, CreateAddressRequest, CreateBundleSelectionRequest, CreateMetafieldRequest, CreateOnetimeRequest, CreateRecipientAddress, CreateSubscriptionRequest, Customer, CustomerDeliveryScheduleParams, CustomerDeliveryScheduleResponse, CustomerIncludes, CustomerPortalAccessResponse, Delivery, DeliveryLineItem, DeliveryOrder, DeliveryPaymentMethod, Discount, DynamicBundleItemAppProxy, DynamicBundlePropertiesAppProxy, ExternalAttributeSchema, ExternalId, ExternalTransactionId, FirstOption, GetAddressOptions, GetChargeOptions, GetCustomerOptions, GetMembershipProgramOptions, GetPaymentMethodOptions, GetRequestOptions, GetSubscriptionOptions, HTMLString, InitOptions, IntervalUnit, IsoDateString, LineItem, ListParams, LoginResponse, Membership, MembershipBenefit, MembershipIncludes, MembershipListParams, MembershipListResponse, MembershipProgram, MembershipProgramIncludes, MembershipProgramListParams, MembershipProgramListResponse, MembershipProgramResponse, MembershipProgramSortBy, MembershipProgramStatus, MembershipResponse, MembershipStatus, MembershipsSortBy, MergeAddressesRequest, Metafield, MetafieldOptionalCreateProps, MetafieldOwnerResource, MetafieldRequiredCreateProps, Method, Onetime, OnetimeListParams, OnetimeOptionalCreateProps, OnetimeRequiredCreateProps, OnetimesResponse, OnetimesSortBy, Order, OrderIncludes, OrderListParams, OrderSortBy, OrderStatus, OrderType, OrdersResponse, PasswordlessCodeResponse, PasswordlessOptions, PasswordlessValidateResponse, PaymentDetails, PaymentMethod, PaymentMethodIncludes, PaymentMethodListParams, PaymentMethodSortBy, PaymentMethodStatus, PaymentMethodsResponse, PaymentType, Plan, PlanListParams, PlanSortBy, PlanType, PlansResponse, PriceAdjustmentsType, ProcessorName, ProductImage, Property, Request, RequestHeaders, RequestOptions, Session, ShippingLine, SkipFutureChargeAddressRequest, SkipFutureChargeAddressResponse, StorefrontEnvironment, StorefrontOptions, StorefrontPurchaseOption, SubType, Subscription, SubscriptionIncludes, SubscriptionListParams, SubscriptionOptionalCreateProps, SubscriptionPreferences, SubscriptionRequiredCreateProps, SubscriptionSortBy, SubscriptionStatus, Subscription_2021_01, SubscriptionsResponse, TaxLine, Translations, UpdateAddressRequest, UpdateBundlePurchaseItem, UpdateBundleSelectionRequest, UpdateCustomerRequest, UpdateMetafieldRequest, UpdateOnetimeRequest, UpdatePaymentMethodRequest, UpdateSubscriptionParams, UpdateSubscriptionRequest, UpdateSubscriptionsParams, UpdateSubscriptionsRequest, WidgetIconColor, WidgetTemplateType, activateMembership, activateSubscription, api, applyDiscountToAddress, applyDiscountToCharge, cancelMembership, cancelSubscription, changeMembership, createAddress, createBundleSelection, createMetafield, createOnetime, createSubscription, createSubscriptions, deleteAddress, deleteBundleSelection, deleteMetafield, deleteOnetime, getAddress, getBundleId, getBundleSelection, getCDNBundleSettings, getCDNProduct, getCDNProductAndSettings, getCDNProducts, getCDNProductsAndSettings, getCDNStoreSettings, getCDNWidgetSettings, getCharge, getCustomer, getCustomerPortalAccess, getDeliverySchedule, getDynamicBundleItems, getMembership, getMembershipProgram, getOnetime, getOrder, getPaymentMethod, getPlan, getSubscription, initRecharge, intervalUnit, listAddresses, listBundleSelections, listCharges, listMembershipPrograms, listMemberships, listOnetimes, listOrders, listPaymentMethods, listPlans, listSubscriptions, loginCustomerPortal, loginShopifyApi, loginShopifyAppProxy, membershipIncludes, mergeAddresses, processCharge, removeDiscountsFromAddress, removeDiscountsFromCharge, resetCDNCache, sendPasswordlessCode, sendPasswordlessCodeAppProxy, skipCharge, skipFutureCharge, skipGiftSubscriptionCharge, skipSubscriptionCharge, unskipCharge, updateAddress, updateBundle, updateBundleSelection, updateCustomer, updateMetafield, updateOnetime, updatePaymentMethod, updateSubscription, updateSubscriptionAddress, updateSubscriptionChargeDate, updateSubscriptions, validateBundle, validateDynamicBundle, validatePasswordlessCode, validatePasswordlessCodeAppProxy };
@@ -1,4 +1,4 @@
1
- // recharge-client-1.6.1.min.js | MIT License | © Recharge Inc.
1
+ // recharge-client-1.7.0.min.js | MIT License | © Recharge Inc.
2
2
  (function(oe,pt){typeof exports=="object"&&typeof module<"u"?module.exports=pt():typeof define=="function"&&define.amd?define(pt):(oe=typeof globalThis<"u"?globalThis:oe||self,oe.recharge=pt())})(this,function(){"use strict";var oe=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function pt(t){var e=t.default;if(typeof e=="function"){var r=function(){return e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(n){var a=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,a.get?a:{enumerable:!0,get:function(){return t[n]}})}),r}var K=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof K<"u"&&K,te={searchParams:"URLSearchParams"in K,iterable:"Symbol"in K&&"iterator"in Symbol,blob:"FileReader"in K&&"Blob"in K&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in K,arrayBuffer:"ArrayBuffer"in K};function zo(t){return t&&DataView.prototype.isPrototypeOf(t)}if(te.arrayBuffer)var Go=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],Wo=ArrayBuffer.isView||function(t){return t&&Go.indexOf(Object.prototype.toString.call(t))>-1};function ht(t){if(typeof t!="string"&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t)||t==="")throw new TypeError('Invalid character in header field name: "'+t+'"');return t.toLowerCase()}function wr(t){return typeof t!="string"&&(t=String(t)),t}function vr(t){var e={next:function(){var r=t.shift();return{done:r===void 0,value:r}}};return te.iterable&&(e[Symbol.iterator]=function(){return e}),e}function j(t){this.map={},t instanceof j?t.forEach(function(e,r){this.append(r,e)},this):Array.isArray(t)?t.forEach(function(e){this.append(e[0],e[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}j.prototype.append=function(t,e){t=ht(t),e=wr(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},j.prototype.delete=function(t){delete this.map[ht(t)]},j.prototype.get=function(t){return t=ht(t),this.has(t)?this.map[t]:null},j.prototype.has=function(t){return this.map.hasOwnProperty(ht(t))},j.prototype.set=function(t,e){this.map[ht(t)]=wr(e)},j.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},j.prototype.keys=function(){var t=[];return this.forEach(function(e,r){t.push(r)}),vr(t)},j.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),vr(t)},j.prototype.entries=function(){var t=[];return this.forEach(function(e,r){t.push([r,e])}),vr(t)},te.iterable&&(j.prototype[Symbol.iterator]=j.prototype.entries);function _r(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function An(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})}function Ho(t){var e=new FileReader,r=An(e);return e.readAsArrayBuffer(t),r}function Yo(t){var e=new FileReader,r=An(e);return e.readAsText(t),r}function Xo(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n<e.length;n++)r[n]=String.fromCharCode(e[n]);return r.join("")}function xn(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function Sn(){return this.bodyUsed=!1,this._initBody=function(t){this.bodyUsed=this.bodyUsed,this._bodyInit=t,t?typeof t=="string"?this._bodyText=t:te.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:te.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:te.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():te.arrayBuffer&&te.blob&&zo(t)?(this._bodyArrayBuffer=xn(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):te.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||Wo(t))?this._bodyArrayBuffer=xn(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||(typeof t=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):te.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},te.blob&&(this.blob=function(){var t=_r(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var t=_r(this);return t||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else return this.blob().then(Ho)}),this.text=function(){var t=_r(this);if(t)return t;if(this._bodyBlob)return Yo(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(Xo(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},te.formData&&(this.formData=function(){return this.text().then(Qo)}),this.json=function(){return this.text().then(JSON.parse)},this}var Jo=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function Ko(t){var e=t.toUpperCase();return Jo.indexOf(e)>-1?e:t}function Ue(t,e){if(!(this instanceof Ue))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');e=e||{};var r=e.body;if(t instanceof Ue){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new j(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,!r&&t._bodyInit!=null&&(r=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",(e.headers||!this.headers)&&(this.headers=new j(e.headers)),this.method=Ko(e.method||this.method||"GET"),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&r)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(r),(this.method==="GET"||this.method==="HEAD")&&(e.cache==="no-store"||e.cache==="no-cache")){var n=/([?&])_=[^&]*/;if(n.test(this.url))this.url=this.url.replace(n,"$1_="+new Date().getTime());else{var a=/\?/;this.url+=(a.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}Ue.prototype.clone=function(){return new Ue(this,{body:this._bodyInit})};function Qo(t){var e=new FormData;return t.trim().split("&").forEach(function(r){if(r){var n=r.split("="),a=n.shift().replace(/\+/g," "),s=n.join("=").replace(/\+/g," ");e.append(decodeURIComponent(a),decodeURIComponent(s))}}),e}function Zo(t){var e=new j,r=t.replace(/\r?\n[\t ]+/g," ");return r.split("\r").map(function(n){return n.indexOf(`
3
3
  `)===0?n.substr(1,n.length):n}).forEach(function(n){var a=n.split(":"),s=a.shift().trim();if(s){var f=a.join(":").trim();e.append(s,f)}}),e}Sn.call(Ue.prototype);function pe(t,e){if(!(this instanceof pe))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');e||(e={}),this.type="default",this.status=e.status===void 0?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText=e.statusText===void 0?"":""+e.statusText,this.headers=new j(e.headers),this.url=e.url||"",this._initBody(t)}Sn.call(pe.prototype),pe.prototype.clone=function(){return new pe(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new j(this.headers),url:this.url})},pe.error=function(){var t=new pe(null,{status:0,statusText:""});return t.type="error",t};var ea=[301,302,303,307,308];pe.redirect=function(t,e){if(ea.indexOf(e)===-1)throw new RangeError("Invalid status code");return new pe(null,{status:e,headers:{location:t}})};var Ce=K.DOMException;try{new Ce}catch{Ce=function(e,r){this.message=e,this.name=r;var n=Error(e);this.stack=n.stack},Ce.prototype=Object.create(Error.prototype),Ce.prototype.constructor=Ce}function In(t,e){return new Promise(function(r,n){var a=new Ue(t,e);if(a.signal&&a.signal.aborted)return n(new Ce("Aborted","AbortError"));var s=new XMLHttpRequest;function f(){s.abort()}s.onload=function(){var h={status:s.status,statusText:s.statusText,headers:Zo(s.getAllResponseHeaders()||"")};h.url="responseURL"in s?s.responseURL:h.headers.get("X-Request-URL");var m="response"in s?s.response:s.responseText;setTimeout(function(){r(new pe(m,h))},0)},s.onerror=function(){setTimeout(function(){n(new TypeError("Network request failed"))},0)},s.ontimeout=function(){setTimeout(function(){n(new TypeError("Network request failed"))},0)},s.onabort=function(){setTimeout(function(){n(new Ce("Aborted","AbortError"))},0)};function p(h){try{return h===""&&K.location.href?K.location.href:h}catch{return h}}s.open(a.method,p(a.url),!0),a.credentials==="include"?s.withCredentials=!0:a.credentials==="omit"&&(s.withCredentials=!1),"responseType"in s&&(te.blob?s.responseType="blob":te.arrayBuffer&&a.headers.get("Content-Type")&&a.headers.get("Content-Type").indexOf("application/octet-stream")!==-1&&(s.responseType="arraybuffer")),e&&typeof e.headers=="object"&&!(e.headers instanceof j)?Object.getOwnPropertyNames(e.headers).forEach(function(h){s.setRequestHeader(h,wr(e.headers[h]))}):a.headers.forEach(function(h,m){s.setRequestHeader(m,h)}),a.signal&&(a.signal.addEventListener("abort",f),s.onreadystatechange=function(){s.readyState===4&&a.signal.removeEventListener("abort",f)}),s.send(typeof a._bodyInit>"u"?null:a._bodyInit)})}In.polyfill=!0,K.fetch||(K.fetch=In,K.Headers=j,K.Request=Ue,K.Response=pe),self.fetch.bind(self);var ta=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var a=42;e[r]=a;for(r in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var s=Object.getOwnPropertySymbols(e);if(s.length!==1||s[0]!==r||!Object.prototype.propertyIsEnumerable.call(e,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var f=Object.getOwnPropertyDescriptor(e,r);if(f.value!==a||f.enumerable!==!0)return!1}return!0},Bn=typeof Symbol<"u"&&Symbol,ra=ta,na=function(){return typeof Bn!="function"||typeof Symbol!="function"||typeof Bn("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:ra()},On={foo:{}},ia=Object,oa=function(){return{__proto__:On}.foo===On.foo&&!({__proto__:null}instanceof ia)},aa="Function.prototype.bind called on incompatible ",br=Array.prototype.slice,sa=Object.prototype.toString,ua="[object Function]",ca=function(e){var r=this;if(typeof r!="function"||sa.call(r)!==ua)throw new TypeError(aa+r);for(var n=br.call(arguments,1),a,s=function(){if(this instanceof a){var v=r.apply(this,n.concat(br.call(arguments)));return Object(v)===v?v:this}else return r.apply(e,n.concat(br.call(arguments)))},f=Math.max(0,r.length-n.length),p=[],h=0;h<f;h++)p.push("$"+h);if(a=Function("binder","return function ("+p.join(",")+"){ return binder.apply(this,arguments); }")(s),r.prototype){var m=function(){};m.prototype=r.prototype,a.prototype=new m,m.prototype=null}return a},fa=ca,Er=Function.prototype.bind||fa,la=Er,pa=la.call(Function.call,Object.prototype.hasOwnProperty),C,He=SyntaxError,Tn=Function,Ye=TypeError,Ar=function(t){try{return Tn('"use strict"; return ('+t+").constructor;")()}catch{}},De=Object.getOwnPropertyDescriptor;if(De)try{De({},"")}catch{De=null}var xr=function(){throw new Ye},ha=De?function(){try{return arguments.callee,xr}catch{try{return De(arguments,"callee").get}catch{return xr}}}():xr,Xe=na(),da=oa(),W=Object.getPrototypeOf||(da?function(t){return t.__proto__}:null),Je={},ya=typeof Uint8Array>"u"||!W?C:W(Uint8Array),Ne={"%AggregateError%":typeof AggregateError>"u"?C:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?C:ArrayBuffer,"%ArrayIteratorPrototype%":Xe&&W?W([][Symbol.iterator]()):C,"%AsyncFromSyncIteratorPrototype%":C,"%AsyncFunction%":Je,"%AsyncGenerator%":Je,"%AsyncGeneratorFunction%":Je,"%AsyncIteratorPrototype%":Je,"%Atomics%":typeof Atomics>"u"?C:Atomics,"%BigInt%":typeof BigInt>"u"?C:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?C:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?C:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?C:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array>"u"?C:Float32Array,"%Float64Array%":typeof Float64Array>"u"?C:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?C:FinalizationRegistry,"%Function%":Tn,"%GeneratorFunction%":Je,"%Int8Array%":typeof Int8Array>"u"?C:Int8Array,"%Int16Array%":typeof Int16Array>"u"?C:Int16Array,"%Int32Array%":typeof Int32Array>"u"?C:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Xe&&W?W(W([][Symbol.iterator]())):C,"%JSON%":typeof JSON=="object"?JSON:C,"%Map%":typeof Map>"u"?C:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Xe||!W?C:W(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?C:Promise,"%Proxy%":typeof Proxy>"u"?C:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect>"u"?C:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?C:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Xe||!W?C:W(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?C:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Xe&&W?W(""[Symbol.iterator]()):C,"%Symbol%":Xe?Symbol:C,"%SyntaxError%":He,"%ThrowTypeError%":ha,"%TypedArray%":ya,"%TypeError%":Ye,"%Uint8Array%":typeof Uint8Array>"u"?C:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?C:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?C:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?C:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap>"u"?C:WeakMap,"%WeakRef%":typeof WeakRef>"u"?C:WeakRef,"%WeakSet%":typeof WeakSet>"u"?C:WeakSet};if(W)try{null.error}catch(t){var ga=W(W(t));Ne["%Error.prototype%"]=ga}var ma=function t(e){var r;if(e==="%AsyncFunction%")r=Ar("async function () {}");else if(e==="%GeneratorFunction%")r=Ar("function* () {}");else if(e==="%AsyncGeneratorFunction%")r=Ar("async function* () {}");else if(e==="%AsyncGenerator%"){var n=t("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if(e==="%AsyncIteratorPrototype%"){var a=t("%AsyncGenerator%");a&&W&&(r=W(a.prototype))}return Ne[e]=r,r},Rn={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},dt=Er,Dt=pa,wa=dt.call(Function.call,Array.prototype.concat),va=dt.call(Function.apply,Array.prototype.splice),$n=dt.call(Function.call,String.prototype.replace),Nt=dt.call(Function.call,String.prototype.slice),_a=dt.call(Function.call,RegExp.prototype.exec),ba=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Ea=/\\(\\)?/g,Aa=function(e){var r=Nt(e,0,1),n=Nt(e,-1);if(r==="%"&&n!=="%")throw new He("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&r!=="%")throw new He("invalid intrinsic syntax, expected opening `%`");var a=[];return $n(e,ba,function(s,f,p,h){a[a.length]=p?$n(h,Ea,"$1"):f||s}),a},xa=function(e,r){var n=e,a;if(Dt(Rn,n)&&(a=Rn[n],n="%"+a[0]+"%"),Dt(Ne,n)){var s=Ne[n];if(s===Je&&(s=ma(n)),typeof s>"u"&&!r)throw new Ye("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:a,name:n,value:s}}throw new He("intrinsic "+e+" does not exist!")},Sr=function(e,r){if(typeof e!="string"||e.length===0)throw new Ye("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new Ye('"allowMissing" argument must be a boolean');if(_a(/^%?[^%]*%?$/,e)===null)throw new He("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=Aa(e),a=n.length>0?n[0]:"",s=xa("%"+a+"%",r),f=s.name,p=s.value,h=!1,m=s.alias;m&&(a=m[0],va(n,wa([0,1],m)));for(var v=1,_=!0;v<n.length;v+=1){var b=n[v],y=Nt(b,0,1),x=Nt(b,-1);if((y==='"'||y==="'"||y==="`"||x==='"'||x==="'"||x==="`")&&y!==x)throw new He("property names with quotes must have matching quotes");if((b==="constructor"||!_)&&(h=!0),a+="."+b,f="%"+a+"%",Dt(Ne,f))p=Ne[f];else if(p!=null){if(!(b in p)){if(!r)throw new Ye("base intrinsic for "+e+" exists, but the property is not available.");return}if(De&&v+1>=n.length){var I=De(p,b);_=!!I,_&&"get"in I&&!("originalValue"in I.get)?p=I.get:p=p[b]}else _=Dt(p,b),p=p[b];_&&!h&&(Ne[f]=p)}}return p},Pn={exports:{}};(function(t){var e=Er,r=Sr,n=r("%Function.prototype.apply%"),a=r("%Function.prototype.call%"),s=r("%Reflect.apply%",!0)||e.call(a,n),f=r("%Object.getOwnPropertyDescriptor%",!0),p=r("%Object.defineProperty%",!0),h=r("%Math.max%");if(p)try{p({},"a",{value:1})}catch{p=null}t.exports=function(_){var b=s(e,a,arguments);if(f&&p){var y=f(b,"length");y.configurable&&p(b,"length",{value:1+h(0,_.length-(arguments.length-1))})}return b};var m=function(){return s(e,n,arguments)};p?p(t.exports,"apply",{value:m}):t.exports.apply=m})(Pn);var Fn=Sr,Un=Pn.exports,Sa=Un(Fn("String.prototype.indexOf")),Ia=function(e,r){var n=Fn(e,!!r);return typeof n=="function"&&Sa(e,".prototype.")>-1?Un(n):n},Ke=typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{},he=[],ue=[],Ba=typeof Uint8Array<"u"?Uint8Array:Array,Ir=!1;function Cn(){Ir=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0,r=t.length;e<r;++e)he[e]=t[e],ue[t.charCodeAt(e)]=e;ue["-".charCodeAt(0)]=62,ue["_".charCodeAt(0)]=63}function Oa(t){Ir||Cn();var e,r,n,a,s,f,p=t.length;if(p%4>0)throw new Error("Invalid string. Length must be a multiple of 4");s=t[p-2]==="="?2:t[p-1]==="="?1:0,f=new Ba(p*3/4-s),n=s>0?p-4:p;var h=0;for(e=0,r=0;e<n;e+=4,r+=3)a=ue[t.charCodeAt(e)]<<18|ue[t.charCodeAt(e+1)]<<12|ue[t.charCodeAt(e+2)]<<6|ue[t.charCodeAt(e+3)],f[h++]=a>>16&255,f[h++]=a>>8&255,f[h++]=a&255;return s===2?(a=ue[t.charCodeAt(e)]<<2|ue[t.charCodeAt(e+1)]>>4,f[h++]=a&255):s===1&&(a=ue[t.charCodeAt(e)]<<10|ue[t.charCodeAt(e+1)]<<4|ue[t.charCodeAt(e+2)]>>2,f[h++]=a>>8&255,f[h++]=a&255),f}function Ta(t){return he[t>>18&63]+he[t>>12&63]+he[t>>6&63]+he[t&63]}function Ra(t,e,r){for(var n,a=[],s=e;s<r;s+=3)n=(t[s]<<16)+(t[s+1]<<8)+t[s+2],a.push(Ta(n));return a.join("")}function Dn(t){Ir||Cn();for(var e,r=t.length,n=r%3,a="",s=[],f=16383,p=0,h=r-n;p<h;p+=f)s.push(Ra(t,p,p+f>h?h:p+f));return n===1?(e=t[r-1],a+=he[e>>2],a+=he[e<<4&63],a+="=="):n===2&&(e=(t[r-2]<<8)+t[r-1],a+=he[e>>10],a+=he[e>>4&63],a+=he[e<<2&63],a+="="),s.push(a),s.join("")}function Mt(t,e,r,n,a){var s,f,p=a*8-n-1,h=(1<<p)-1,m=h>>1,v=-7,_=r?a-1:0,b=r?-1:1,y=t[e+_];for(_+=b,s=y&(1<<-v)-1,y>>=-v,v+=p;v>0;s=s*256+t[e+_],_+=b,v-=8);for(f=s&(1<<-v)-1,s>>=-v,v+=n;v>0;f=f*256+t[e+_],_+=b,v-=8);if(s===0)s=1-m;else{if(s===h)return f?NaN:(y?-1:1)*(1/0);f=f+Math.pow(2,n),s=s-m}return(y?-1:1)*f*Math.pow(2,s-n)}function Nn(t,e,r,n,a,s){var f,p,h,m=s*8-a-1,v=(1<<m)-1,_=v>>1,b=a===23?Math.pow(2,-24)-Math.pow(2,-77):0,y=n?0:s-1,x=n?1:-1,I=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(p=isNaN(e)?1:0,f=v):(f=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-f))<1&&(f--,h*=2),f+_>=1?e+=b/h:e+=b*Math.pow(2,1-_),e*h>=2&&(f++,h/=2),f+_>=v?(p=0,f=v):f+_>=1?(p=(e*h-1)*Math.pow(2,a),f=f+_):(p=e*Math.pow(2,_-1)*Math.pow(2,a),f=0));a>=8;t[r+y]=p&255,y+=x,p/=256,a-=8);for(f=f<<a|p,m+=a;m>0;t[r+y]=f&255,y+=x,f/=256,m-=8);t[r+y-x]|=I*128}var $a={}.toString,Mn=Array.isArray||function(t){return $a.call(t)=="[object Array]"};/*!
4
4
  * The buffer module from node.js, for the browser.
@@ -17,6 +17,6 @@
17
17
  `)+" "+r[1]:r[0]+e+" "+t.join(", ")+" "+r[1]}function Cr(t){return Array.isArray(t)}function Xt(t){return typeof t=="boolean"}function yt(t){return t===null}function oi(t){return t==null}function Dr(t){return typeof t=="number"}function gt(t){return typeof t=="string"}function ai(t){return typeof t=="symbol"}function ge(t){return t===void 0}function mt(t){return je(t)&&Nr(t)==="[object RegExp]"}function je(t){return typeof t=="object"&&t!==null}function Jt(t){return je(t)&&Nr(t)==="[object Date]"}function wt(t){return je(t)&&(Nr(t)==="[object Error]"||t instanceof Error)}function vt(t){return typeof t=="function"}function si(t){return t===null||typeof t=="boolean"||typeof t=="number"||typeof t=="string"||typeof t=="symbol"||typeof t>"u"}function ui(t){return E.isBuffer(t)}function Nr(t){return Object.prototype.toString.call(t)}function Mr(t){return t<10?"0"+t.toString(10):t.toString(10)}var Ms=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Ls(){var t=new Date,e=[Mr(t.getHours()),Mr(t.getMinutes()),Mr(t.getSeconds())].join(":");return[t.getDate(),Ms[t.getMonth()],e].join(" ")}function ci(){console.log("%s - %s",Ls(),Wt.apply(null,arguments))}function Lr(t,e){if(!e||!je(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t}function fi(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var ks={inherits:ni,_extend:Lr,log:ci,isBuffer:ui,isPrimitive:si,isFunction:vt,isError:wt,isDate:Jt,isObject:je,isRegExp:mt,isUndefined:ge,isSymbol:ai,isString:gt,isNumber:Dr,isNullOrUndefined:oi,isNull:yt,isBoolean:Xt,isArray:Cr,inspect:ye,deprecate:$r,format:Wt,debuglog:ii},js=Object.freeze({__proto__:null,format:Wt,deprecate:$r,debuglog:ii,inspect:ye,isArray:Cr,isBoolean:Xt,isNull:yt,isNullOrUndefined:oi,isNumber:Dr,isString:gt,isSymbol:ai,isUndefined:ge,isRegExp:mt,isObject:je,isDate:Jt,isError:wt,isFunction:vt,isPrimitive:si,isBuffer:ui,log:ci,inherits:ni,_extend:Lr,default:ks}),qs=pt(js),Vs=qs.inspect,kr=typeof Map=="function"&&Map.prototype,jr=Object.getOwnPropertyDescriptor&&kr?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Kt=kr&&jr&&typeof jr.get=="function"?jr.get:null,li=kr&&Map.prototype.forEach,qr=typeof Set=="function"&&Set.prototype,Vr=Object.getOwnPropertyDescriptor&&qr?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Qt=qr&&Vr&&typeof Vr.get=="function"?Vr.get:null,pi=qr&&Set.prototype.forEach,zs=typeof WeakMap=="function"&&WeakMap.prototype,_t=zs?WeakMap.prototype.has:null,Gs=typeof WeakSet=="function"&&WeakSet.prototype,bt=Gs?WeakSet.prototype.has:null,Ws=typeof WeakRef=="function"&&WeakRef.prototype,hi=Ws?WeakRef.prototype.deref:null,Hs=Boolean.prototype.valueOf,Ys=Object.prototype.toString,Xs=Function.prototype.toString,Js=String.prototype.match,zr=String.prototype.slice,Te=String.prototype.replace,Ks=String.prototype.toUpperCase,di=String.prototype.toLowerCase,yi=RegExp.prototype.test,gi=Array.prototype.concat,me=Array.prototype.join,Qs=Array.prototype.slice,mi=Math.floor,Gr=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Wr=Object.getOwnPropertySymbols,Hr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,et=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Q=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===et||"symbol")?Symbol.toStringTag:null,wi=Object.prototype.propertyIsEnumerable,vi=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(t){return t.__proto__}:null);function _i(t,e){if(t===1/0||t===-1/0||t!==t||t&&t>-1e3&&t<1e3||yi.call(/e/,e))return e;var r=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof t=="number"){var n=t<0?-mi(-t):mi(t);if(n!==t){var a=String(n),s=zr.call(e,a.length+1);return Te.call(a,r,"$&_")+"."+Te.call(Te.call(s,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Te.call(e,r,"$&_")}var Yr=Vs,bi=Yr.custom,Ei=Si(bi)?bi:null,Zs=function t(e,r,n,a){var s=r||{};if(Re(s,"quoteStyle")&&s.quoteStyle!=="single"&&s.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Re(s,"maxStringLength")&&(typeof s.maxStringLength=="number"?s.maxStringLength<0&&s.maxStringLength!==1/0:s.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var f=Re(s,"customInspect")?s.customInspect:!0;if(typeof f!="boolean"&&f!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(Re(s,"indent")&&s.indent!==null&&s.indent!==" "&&!(parseInt(s.indent,10)===s.indent&&s.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(Re(s,"numericSeparator")&&typeof s.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var p=s.numericSeparator;if(typeof e>"u")return"undefined";if(e===null)return"null";if(typeof e=="boolean")return e?"true":"false";if(typeof e=="string")return Bi(e,s);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var h=String(e);return p?_i(e,h):h}if(typeof e=="bigint"){var m=String(e)+"n";return p?_i(e,m):m}var v=typeof s.depth>"u"?5:s.depth;if(typeof n>"u"&&(n=0),n>=v&&v>0&&typeof e=="object")return Xr(e)?"[Array]":"[Object]";var _=mu(s,n);if(typeof a>"u")a=[];else if(Ii(a,e)>=0)return"[Circular]";function b(L,Z,N){if(Z&&(a=Qs.call(a),a.push(Z)),N){var se={depth:s.depth};return Re(s,"quoteStyle")&&(se.quoteStyle=s.quoteStyle),t(L,se,n+1,a)}return t(L,s,n+1,a)}if(typeof e=="function"&&!xi(e)){var y=uu(e),x=Zt(e,b);return"[Function"+(y?": "+y:" (anonymous)")+"]"+(x.length>0?" { "+me.call(x,", ")+" }":"")}if(Si(e)){var I=et?Te.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):Hr.call(e);return typeof e=="object"&&!et?Et(I):I}if(du(e)){for(var O="<"+di.call(String(e.nodeName)),S=e.attributes||[],B=0;B<S.length;B++)O+=" "+S[B].name+"="+Ai(eu(S[B].value),"double",s);return O+=">",e.childNodes&&e.childNodes.length&&(O+="..."),O+="</"+di.call(String(e.nodeName))+">",O}if(Xr(e)){if(e.length===0)return"[]";var $=Zt(e,b);return _&&!gu($)?"["+Kr($,_)+"]":"[ "+me.call($,", ")+" ]"}if(ru(e)){var R=Zt(e,b);return!("cause"in Error.prototype)&&"cause"in e&&!wi.call(e,"cause")?"{ ["+String(e)+"] "+me.call(gi.call("[cause]: "+b(e.cause),R),", ")+" }":R.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+me.call(R,", ")+" }"}if(typeof e=="object"&&f){if(Ei&&typeof e[Ei]=="function"&&Yr)return Yr(e,{depth:v-n});if(f!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(cu(e)){var D=[];return li&&li.call(e,function(L,Z){D.push(b(Z,e,!0)+" => "+b(L,e))}),Oi("Map",Kt.call(e),D,_)}if(pu(e)){var M=[];return pi&&pi.call(e,function(L){M.push(b(L,e))}),Oi("Set",Qt.call(e),M,_)}if(fu(e))return Jr("WeakMap");if(hu(e))return Jr("WeakSet");if(lu(e))return Jr("WeakRef");if(iu(e))return Et(b(Number(e)));if(au(e))return Et(b(Gr.call(e)));if(ou(e))return Et(Hs.call(e));if(nu(e))return Et(b(String(e)));if(!tu(e)&&!xi(e)){var q=Zt(e,b),V=vi?vi(e)===Object.prototype:e instanceof Object||e.constructor===Object,Y=e instanceof Object?"":"null prototype",z=!V&&Q&&Object(e)===e&&Q in e?zr.call($e(e),8,-1):Y?"Object":"",ne=V||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",ae=ne+(z||Y?"["+me.call(gi.call([],z||[],Y||[]),": ")+"] ":"");return q.length===0?ae+"{}":_?ae+"{"+Kr(q,_)+"}":ae+"{ "+me.call(q,", ")+" }"}return String(e)};function Ai(t,e,r){var n=(r.quoteStyle||e)==="double"?'"':"'";return n+t+n}function eu(t){return Te.call(String(t),/"/g,"&quot;")}function Xr(t){return $e(t)==="[object Array]"&&(!Q||!(typeof t=="object"&&Q in t))}function tu(t){return $e(t)==="[object Date]"&&(!Q||!(typeof t=="object"&&Q in t))}function xi(t){return $e(t)==="[object RegExp]"&&(!Q||!(typeof t=="object"&&Q in t))}function ru(t){return $e(t)==="[object Error]"&&(!Q||!(typeof t=="object"&&Q in t))}function nu(t){return $e(t)==="[object String]"&&(!Q||!(typeof t=="object"&&Q in t))}function iu(t){return $e(t)==="[object Number]"&&(!Q||!(typeof t=="object"&&Q in t))}function ou(t){return $e(t)==="[object Boolean]"&&(!Q||!(typeof t=="object"&&Q in t))}function Si(t){if(et)return t&&typeof t=="object"&&t instanceof Symbol;if(typeof t=="symbol")return!0;if(!t||typeof t!="object"||!Hr)return!1;try{return Hr.call(t),!0}catch{}return!1}function au(t){if(!t||typeof t!="object"||!Gr)return!1;try{return Gr.call(t),!0}catch{}return!1}var su=Object.prototype.hasOwnProperty||function(t){return t in this};function Re(t,e){return su.call(t,e)}function $e(t){return Ys.call(t)}function uu(t){if(t.name)return t.name;var e=Js.call(Xs.call(t),/^function\s*([\w$]+)/);return e?e[1]:null}function Ii(t,e){if(t.indexOf)return t.indexOf(e);for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return-1}function cu(t){if(!Kt||!t||typeof t!="object")return!1;try{Kt.call(t);try{Qt.call(t)}catch{return!0}return t instanceof Map}catch{}return!1}function fu(t){if(!_t||!t||typeof t!="object")return!1;try{_t.call(t,_t);try{bt.call(t,bt)}catch{return!0}return t instanceof WeakMap}catch{}return!1}function lu(t){if(!hi||!t||typeof t!="object")return!1;try{return hi.call(t),!0}catch{}return!1}function pu(t){if(!Qt||!t||typeof t!="object")return!1;try{Qt.call(t);try{Kt.call(t)}catch{return!0}return t instanceof Set}catch{}return!1}function hu(t){if(!bt||!t||typeof t!="object")return!1;try{bt.call(t,bt);try{_t.call(t,_t)}catch{return!0}return t instanceof WeakSet}catch{}return!1}function du(t){return!t||typeof t!="object"?!1:typeof HTMLElement<"u"&&t instanceof HTMLElement?!0:typeof t.nodeName=="string"&&typeof t.getAttribute=="function"}function Bi(t,e){if(t.length>e.maxStringLength){var r=t.length-e.maxStringLength,n="... "+r+" more character"+(r>1?"s":"");return Bi(zr.call(t,0,e.maxStringLength),e)+n}var a=Te.call(Te.call(t,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,yu);return Ai(a,"single",e)}function yu(t){var e=t.charCodeAt(0),r={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return r?"\\"+r:"\\x"+(e<16?"0":"")+Ks.call(e.toString(16))}function Et(t){return"Object("+t+")"}function Jr(t){return t+" { ? }"}function Oi(t,e,r,n){var a=n?Kr(r,n):me.call(r,", ");return t+" ("+e+") {"+a+"}"}function gu(t){for(var e=0;e<t.length;e++)if(Ii(t[e],`
18
18
  `)>=0)return!1;return!0}function mu(t,e){var r;if(t.indent===" ")r=" ";else if(typeof t.indent=="number"&&t.indent>0)r=me.call(Array(t.indent+1)," ");else return null;return{base:r,prev:me.call(Array(e+1),r)}}function Kr(t,e){if(t.length===0)return"";var r=`
19
19
  `+e.prev+e.base;return r+me.call(t,","+r)+`
20
- `+e.prev}function Zt(t,e){var r=Xr(t),n=[];if(r){n.length=t.length;for(var a=0;a<t.length;a++)n[a]=Re(t,a)?e(t[a],t):""}var s=typeof Wr=="function"?Wr(t):[],f;if(et){f={};for(var p=0;p<s.length;p++)f["$"+s[p]]=s[p]}for(var h in t)Re(t,h)&&(r&&String(Number(h))===h&&h<t.length||et&&f["$"+h]instanceof Symbol||(yi.call(/[^\w$]/,h)?n.push(e(h,t)+": "+e(t[h],t)):n.push(h+": "+e(t[h],t))));if(typeof Wr=="function")for(var m=0;m<s.length;m++)wi.call(t,s[m])&&n.push("["+e(s[m])+"]: "+e(t[s[m]],t));return n}var Qr=Sr,tt=Ia,wu=Zs,vu=Qr("%TypeError%"),er=Qr("%WeakMap%",!0),tr=Qr("%Map%",!0),_u=tt("WeakMap.prototype.get",!0),bu=tt("WeakMap.prototype.set",!0),Eu=tt("WeakMap.prototype.has",!0),Au=tt("Map.prototype.get",!0),xu=tt("Map.prototype.set",!0),Su=tt("Map.prototype.has",!0),Zr=function(t,e){for(var r=t,n;(n=r.next)!==null;r=n)if(n.key===e)return r.next=n.next,n.next=t.next,t.next=n,n},Iu=function(t,e){var r=Zr(t,e);return r&&r.value},Bu=function(t,e,r){var n=Zr(t,e);n?n.value=r:t.next={key:e,next:t.next,value:r}},Ou=function(t,e){return!!Zr(t,e)},Tu=function(){var e,r,n,a={assert:function(s){if(!a.has(s))throw new vu("Side channel does not contain "+wu(s))},get:function(s){if(er&&s&&(typeof s=="object"||typeof s=="function")){if(e)return _u(e,s)}else if(tr){if(r)return Au(r,s)}else if(n)return Iu(n,s)},has:function(s){if(er&&s&&(typeof s=="object"||typeof s=="function")){if(e)return Eu(e,s)}else if(tr){if(r)return Su(r,s)}else if(n)return Ou(n,s);return!1},set:function(s,f){er&&s&&(typeof s=="object"||typeof s=="function")?(e||(e=new er),bu(e,s,f)):tr?(r||(r=new tr),xu(r,s,f)):(n||(n={key:{},next:null}),Bu(n,s,f))}};return a},Ru=String.prototype.replace,$u=/%20/g,en={RFC1738:"RFC1738",RFC3986:"RFC3986"},Ti={default:en.RFC3986,formatters:{RFC1738:function(t){return Ru.call(t,$u,"+")},RFC3986:function(t){return String(t)}},RFC1738:en.RFC1738,RFC3986:en.RFC3986},Pu=Ti,tn=Object.prototype.hasOwnProperty,qe=Array.isArray,we=function(){for(var t=[],e=0;e<256;++e)t.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return t}(),Fu=function(e){for(;e.length>1;){var r=e.pop(),n=r.obj[r.prop];if(qe(n)){for(var a=[],s=0;s<n.length;++s)typeof n[s]<"u"&&a.push(n[s]);r.obj[r.prop]=a}}},Ri=function(e,r){for(var n=r&&r.plainObjects?Object.create(null):{},a=0;a<e.length;++a)typeof e[a]<"u"&&(n[a]=e[a]);return n},Uu=function t(e,r,n){if(!r)return e;if(typeof r!="object"){if(qe(e))e.push(r);else if(e&&typeof e=="object")(n&&(n.plainObjects||n.allowPrototypes)||!tn.call(Object.prototype,r))&&(e[r]=!0);else return[e,r];return e}if(!e||typeof e!="object")return[e].concat(r);var a=e;return qe(e)&&!qe(r)&&(a=Ri(e,n)),qe(e)&&qe(r)?(r.forEach(function(s,f){if(tn.call(e,f)){var p=e[f];p&&typeof p=="object"&&s&&typeof s=="object"?e[f]=t(p,s,n):e.push(s)}else e[f]=s}),e):Object.keys(r).reduce(function(s,f){var p=r[f];return tn.call(s,f)?s[f]=t(s[f],p,n):s[f]=p,s},a)},Cu=function(e,r){return Object.keys(r).reduce(function(n,a){return n[a]=r[a],n},e)},Du=function(t,e,r){var n=t.replace(/\+/g," ");if(r==="iso-8859-1")return n.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(n)}catch{return n}},Nu=function(e,r,n,a,s){if(e.length===0)return e;var f=e;if(typeof e=="symbol"?f=Symbol.prototype.toString.call(e):typeof e!="string"&&(f=String(e)),n==="iso-8859-1")return escape(f).replace(/%u[0-9a-f]{4}/gi,function(v){return"%26%23"+parseInt(v.slice(2),16)+"%3B"});for(var p="",h=0;h<f.length;++h){var m=f.charCodeAt(h);if(m===45||m===46||m===95||m===126||m>=48&&m<=57||m>=65&&m<=90||m>=97&&m<=122||s===Pu.RFC1738&&(m===40||m===41)){p+=f.charAt(h);continue}if(m<128){p=p+we[m];continue}if(m<2048){p=p+(we[192|m>>6]+we[128|m&63]);continue}if(m<55296||m>=57344){p=p+(we[224|m>>12]+we[128|m>>6&63]+we[128|m&63]);continue}h+=1,m=65536+((m&1023)<<10|f.charCodeAt(h)&1023),p+=we[240|m>>18]+we[128|m>>12&63]+we[128|m>>6&63]+we[128|m&63]}return p},Mu=function(e){for(var r=[{obj:{o:e},prop:"o"}],n=[],a=0;a<r.length;++a)for(var s=r[a],f=s.obj[s.prop],p=Object.keys(f),h=0;h<p.length;++h){var m=p[h],v=f[m];typeof v=="object"&&v!==null&&n.indexOf(v)===-1&&(r.push({obj:f,prop:m}),n.push(v))}return Fu(r),e},Lu=function(e){return Object.prototype.toString.call(e)==="[object RegExp]"},ku=function(e){return!e||typeof e!="object"?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},ju=function(e,r){return[].concat(e,r)},qu=function(e,r){if(qe(e)){for(var n=[],a=0;a<e.length;a+=1)n.push(r(e[a]));return n}return r(e)},Vu={arrayToObject:Ri,assign:Cu,combine:ju,compact:Mu,decode:Du,encode:Nu,isBuffer:ku,isRegExp:Lu,maybeMap:qu,merge:Uu},$i=Tu,rn=Vu,At=Ti,zu=Object.prototype.hasOwnProperty,Pi={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,r){return e+"["+r+"]"},repeat:function(e){return e}},Ae=Array.isArray,Gu=String.prototype.split,Wu=Array.prototype.push,Fi=function(t,e){Wu.apply(t,Ae(e)?e:[e])},Hu=Date.prototype.toISOString,Ui=At.default,X={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:rn.encode,encodeValuesOnly:!1,format:Ui,formatter:At.formatters[Ui],indices:!1,serializeDate:function(e){return Hu.call(e)},skipNulls:!1,strictNullHandling:!1},Yu=function(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="symbol"||typeof e=="bigint"},nn={},Xu=function t(e,r,n,a,s,f,p,h,m,v,_,b,y,x,I,O){for(var S=e,B=O,$=0,R=!1;(B=B.get(nn))!==void 0&&!R;){var D=B.get(e);if($+=1,typeof D<"u"){if(D===$)throw new RangeError("Cyclic object value");R=!0}typeof B.get(nn)>"u"&&($=0)}if(typeof h=="function"?S=h(r,S):S instanceof Date?S=_(S):n==="comma"&&Ae(S)&&(S=rn.maybeMap(S,function(Pe){return Pe instanceof Date?_(Pe):Pe})),S===null){if(s)return p&&!x?p(r,X.encoder,I,"key",b):r;S=""}if(Yu(S)||rn.isBuffer(S)){if(p){var M=x?r:p(r,X.encoder,I,"key",b);if(n==="comma"&&x){for(var q=Gu.call(String(S),","),V="",Y=0;Y<q.length;++Y)V+=(Y===0?"":",")+y(p(q[Y],X.encoder,I,"value",b));return[y(M)+(a&&Ae(S)&&q.length===1?"[]":"")+"="+V]}return[y(M)+"="+y(p(S,X.encoder,I,"value",b))]}return[y(r)+"="+y(String(S))]}var z=[];if(typeof S>"u")return z;var ne;if(n==="comma"&&Ae(S))ne=[{value:S.length>0?S.join(",")||null:void 0}];else if(Ae(h))ne=h;else{var ae=Object.keys(S);ne=m?ae.sort(m):ae}for(var L=a&&Ae(S)&&S.length===1?r+"[]":r,Z=0;Z<ne.length;++Z){var N=ne[Z],se=typeof N=="object"&&typeof N.value<"u"?N.value:S[N];if(!(f&&se===null)){var ut=Ae(S)?typeof n=="function"?n(L,N):L:L+(v?"."+N:"["+N+"]");O.set(e,$);var ie=$i();ie.set(nn,O),Fi(z,t(se,ut,n,a,s,f,p,h,m,v,_,b,y,x,I,ie))}}return z},Ju=function(e){if(!e)return X;if(e.encoder!==null&&typeof e.encoder<"u"&&typeof e.encoder!="function")throw new TypeError("Encoder has to be a function.");var r=e.charset||X.charset;if(typeof e.charset<"u"&&e.charset!=="utf-8"&&e.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=At.default;if(typeof e.format<"u"){if(!zu.call(At.formatters,e.format))throw new TypeError("Unknown format option provided.");n=e.format}var a=At.formatters[n],s=X.filter;return(typeof e.filter=="function"||Ae(e.filter))&&(s=e.filter),{addQueryPrefix:typeof e.addQueryPrefix=="boolean"?e.addQueryPrefix:X.addQueryPrefix,allowDots:typeof e.allowDots>"u"?X.allowDots:!!e.allowDots,charset:r,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:X.charsetSentinel,delimiter:typeof e.delimiter>"u"?X.delimiter:e.delimiter,encode:typeof e.encode=="boolean"?e.encode:X.encode,encoder:typeof e.encoder=="function"?e.encoder:X.encoder,encodeValuesOnly:typeof e.encodeValuesOnly=="boolean"?e.encodeValuesOnly:X.encodeValuesOnly,filter:s,format:n,formatter:a,serializeDate:typeof e.serializeDate=="function"?e.serializeDate:X.serializeDate,skipNulls:typeof e.skipNulls=="boolean"?e.skipNulls:X.skipNulls,sort:typeof e.sort=="function"?e.sort:null,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:X.strictNullHandling}},Ku=function(t,e){var r=t,n=Ju(e),a,s;typeof n.filter=="function"?(s=n.filter,r=s("",r)):Ae(n.filter)&&(s=n.filter,a=s);var f=[];if(typeof r!="object"||r===null)return"";var p;e&&e.arrayFormat in Pi?p=e.arrayFormat:e&&"indices"in e?p=e.indices?"indices":"repeat":p="indices";var h=Pi[p];if(e&&"commaRoundTrip"in e&&typeof e.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var m=h==="comma"&&e&&e.commaRoundTrip;a||(a=Object.keys(r)),n.sort&&a.sort(n.sort);for(var v=$i(),_=0;_<a.length;++_){var b=a[_];n.skipNulls&&r[b]===null||Fi(f,Xu(r[b],b,h,m,n.strictNullHandling,n.skipNulls,n.encode?n.encoder:null,n.filter,n.sort,n.allowDots,n.serializeDate,n.format,n.formatter,n.encodeValuesOnly,n.charset,v))}var y=f.join(n.delimiter),x=n.addQueryPrefix===!0?"?":"";return n.charsetSentinel&&(n.charset==="iso-8859-1"?x+="utf8=%26%2310003%3B&":x+="utf8=%E2%9C%93&"),y.length>0?x+y:""};let Ci={storeIdentifier:"",environment:"prod"};function Qu(t){Ci=t}function ve(){return Ci}const Zu=t=>t==="stage"?"https://api.stage.rechargeapps.com":"https://api.rechargeapps.com",rr=t=>t==="stage"?"https://admin.stage.rechargeapps.com":"https://admin.rechargeapps.com",ec=t=>t==="stage"?"https://static.stage.rechargecdn.com":"https://static.rechargecdn.com",tc="/tools/recurring";class nr{constructor(e,r){this.name="RechargeRequestError",this.message=e,this.status=r}}var rc=Object.defineProperty,nc=Object.defineProperties,ic=Object.getOwnPropertyDescriptors,Di=Object.getOwnPropertySymbols,oc=Object.prototype.hasOwnProperty,ac=Object.prototype.propertyIsEnumerable,Ni=(t,e,r)=>e in t?rc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ir=(t,e)=>{for(var r in e||(e={}))oc.call(e,r)&&Ni(t,r,e[r]);if(Di)for(var r of Di(e))ac.call(e,r)&&Ni(t,r,e[r]);return t},sc=(t,e)=>nc(t,ic(e));function uc(t){return Ku(t,{encode:!1,indices:!1,arrayFormat:"comma"})}async function or(t,e,r={}){const n=ve();return ce(t,`${ec(n.environment)}/store/${n.storeIdentifier}${e}`,r)}async function T(t,e,{id:r,query:n,data:a,headers:s}={},f){const{environment:p,storeIdentifier:h,loginRetryFn:m}=ve(),v=f.apiToken,_=Zu(p),b=ir({"X-Recharge-Access-Token":v,"X-Recharge-Version":"2021-11"},s||{}),y=ir({shop_url:h},n);try{return await ce(t,`${_}${e}`,{id:r,query:y,data:a,headers:b})}catch(x){if(m&&x instanceof nr&&x.status===401)return m().then(I=>{if(I)return ce(t,`${_}${e}`,{id:r,query:y,data:a,headers:sc(ir({},b),{"X-Recharge-Access-Token":I.apiToken})});throw x});throw x}}async function xt(t,e,r={}){return ce(t,`${tc}${e}`,r)}async function ce(t,e,{id:r,query:n,data:a,headers:s}={}){let f=e.trim();if(r&&(f=[f,`${r}`.trim()].join("/")),n){let _;[f,_]=f.split("?");const b=[_,uc(n)].join("&").replace(/^&/,"");f=`${f}${b?`?${b}`:""}`}let p;a&&t!=="get"&&(p=JSON.stringify(a));const h=ir({Accept:"application/json","Content-Type":"application/json","X-Recharge-App":"storefront-client"},s||{}),m=await fetch(f,{method:t,headers:h,body:p});let v;try{v=await m.json()}catch{}if(!m.ok)throw v&&v.error?new nr(v.error,m.status):v&&v.errors?new nr(JSON.stringify(v.errors),m.status):new nr("A connection error occurred while making the request");return v}var cc=Object.defineProperty,Mi=Object.getOwnPropertySymbols,fc=Object.prototype.hasOwnProperty,lc=Object.prototype.propertyIsEnumerable,Li=(t,e,r)=>e in t?cc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,pc=(t,e)=>{for(var r in e||(e={}))fc.call(e,r)&&Li(t,r,e[r]);if(Mi)for(var r of Mi(e))lc.call(e,r)&&Li(t,r,e[r]);return t};function hc(t,e){return T("get","/addresses",{query:e},t)}async function dc(t,e,r){const{address:n}=await T("get","/addresses",{id:e,query:{include:r?.include}},t);return n}async function yc(t,e){const{address:r}=await T("post","/addresses",{data:pc({customer_id:t.customerId?Number(t.customerId):void 0},e)},t);return r}async function on(t,e,r){const{address:n}=await T("put","/addresses",{id:e,data:r},t);return n}async function gc(t,e,r){return on(t,e,{discounts:[{code:r}]})}async function mc(t,e){return on(t,e,{discounts:[]})}function wc(t,e){return T("delete","/addresses",{id:e},t)}async function vc(t,e){const{address:r}=await T("post","/addresses/merge",{data:e},t);return r}async function _c(t,e,r){const{charge:n}=await T("post",`/addresses/${e}/charges/skip`,{data:r},t);return n}var bc=Object.freeze({__proto__:null,listAddresses:hc,getAddress:dc,createAddress:yc,updateAddress:on,applyDiscountToAddress:gc,removeDiscountsFromAddress:mc,deleteAddress:wc,mergeAddresses:vc,skipFutureCharge:_c}),Ec=Object.defineProperty,ki=Object.getOwnPropertySymbols,Ac=Object.prototype.hasOwnProperty,xc=Object.prototype.propertyIsEnumerable,ji=(t,e,r)=>e in t?Ec(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,qi=(t,e)=>{for(var r in e||(e={}))Ac.call(e,r)&&ji(t,r,e[r]);if(ki)for(var r of ki(e))xc.call(e,r)&&ji(t,r,e[r]);return t};async function Sc(){const{storefrontAccessToken:t}=ve(),e={};t&&(e["X-Recharge-Storefront-Access-Token"]=t);const r=await xt("get","/access",{headers:e});return{apiToken:r.api_token,customerId:r.customer_id}}async function Ic(t,e){const{environment:r,storefrontAccessToken:n,storeIdentifier:a}=ve(),s=rr(r),f={};n&&(f["X-Recharge-Storefront-Access-Token"]=n);const p=await ce("post",`${s}/shopify_storefront_access`,{data:{customer_token:e,storefront_token:t,shop_url:a},headers:f});return p.api_token?{apiToken:p.api_token,customerId:p.customer_id}:null}async function Bc(t,e={}){const{environment:r,storefrontAccessToken:n,storeIdentifier:a}=ve(),s=rr(r),f={};n&&(f["X-Recharge-Storefront-Access-Token"]=n);const p=await ce("post",`${s}/attempt_login`,{data:qi({email:t,shop:a},e),headers:f});if(p.errors)throw new Error(p.errors);return p.session_token}async function Oc(t,e={}){const{storefrontAccessToken:r}=ve(),n={};r&&(n["X-Recharge-Storefront-Access-Token"]=r);const a=await xt("post","/attempt_login",{data:qi({email:t},e),headers:n});if(a.errors)throw new Error(a.errors);return a.session_token}async function Tc(t,e,r){const{environment:n,storefrontAccessToken:a,storeIdentifier:s}=ve(),f=rr(n),p={};a&&(p["X-Recharge-Storefront-Access-Token"]=a);const h=await ce("post",`${f}/validate_login`,{data:{code:r,email:t,session_token:e,shop:s},headers:p});if(h.errors)throw new Error(h.errors);return{apiToken:h.api_token,customerId:h.customer_id}}async function Rc(t,e,r){const{storefrontAccessToken:n}=ve(),a={};n&&(a["X-Recharge-Storefront-Access-Token"]=n);const s=await xt("post","/validate_login",{data:{code:r,email:t,session_token:e},headers:a});if(s.errors)throw new Error(s.errors);return{apiToken:s.api_token,customerId:s.customer_id}}function $c(){const{pathname:t,search:e}=window.location,r=new URLSearchParams(e).get("token"),n=t.split("/").filter(Boolean),a=n.findIndex(f=>f==="portal"),s=a!==-1?n[a+1]:void 0;if(!r||!s)throw new Error("Not in context of Recharge Customer Portal or URL did not contain correct params");return{customerHash:s,token:r}}async function Pc(){const{customerHash:t,token:e}=$c(),{environment:r,storefrontAccessToken:n,storeIdentifier:a}=ve(),s=rr(r),f={};n&&(f["X-Recharge-Storefront-Access-Token"]=n);const p=await ce("post",`${s}/customers/${t}/access`,{headers:f,data:{token:e,shop:a}});return{apiToken:p.api_token,customerId:p.customer_id}}var Fc=Object.freeze({__proto__:null,loginShopifyAppProxy:Sc,loginShopifyApi:Ic,sendPasswordlessCode:Bc,sendPasswordlessCodeAppProxy:Oc,validatePasswordlessCode:Tc,validatePasswordlessCodeAppProxy:Rc,loginCustomerPortal:Pc});let Uc=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce((e,r)=>(r&=63,r<36?e+=r.toString(36):r<62?e+=(r-26).toString(36).toUpperCase():r>62?e+="-":e+="_",e),"");var Cc=200,an="__lodash_hash_undefined__",Dc=1/0,Vi=9007199254740991,Nc="[object Arguments]",Mc="[object Function]",Lc="[object GeneratorFunction]",kc="[object Symbol]",jc=/[\\^$.*+?()[\]{}|]/g,qc=/^\[object .+?Constructor\]$/,Vc=/^(?:0|[1-9]\d*)$/,zc=typeof oe=="object"&&oe&&oe.Object===Object&&oe,Gc=typeof self=="object"&&self&&self.Object===Object&&self,sn=zc||Gc||Function("return this")();function Wc(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}function Hc(t,e){var r=t?t.length:0;return!!r&&Jc(t,e,0)>-1}function Yc(t,e,r){for(var n=-1,a=t?t.length:0;++n<a;)if(r(e,t[n]))return!0;return!1}function zi(t,e){for(var r=-1,n=t?t.length:0,a=Array(n);++r<n;)a[r]=e(t[r],r,t);return a}function un(t,e){for(var r=-1,n=e.length,a=t.length;++r<n;)t[a+r]=e[r];return t}function Xc(t,e,r,n){for(var a=t.length,s=r+(n?1:-1);n?s--:++s<a;)if(e(t[s],s,t))return s;return-1}function Jc(t,e,r){if(e!==e)return Xc(t,Kc,r);for(var n=r-1,a=t.length;++n<a;)if(t[n]===e)return n;return-1}function Kc(t){return t!==t}function Qc(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}function Zc(t){return function(e){return t(e)}}function ef(t,e){return t.has(e)}function tf(t,e){return t?.[e]}function rf(t){var e=!1;if(t!=null&&typeof t.toString!="function")try{e=!!(t+"")}catch{}return e}function Gi(t,e){return function(r){return t(e(r))}}var nf=Array.prototype,of=Function.prototype,ar=Object.prototype,cn=sn["__core-js_shared__"],Wi=function(){var t=/[^.]+$/.exec(cn&&cn.keys&&cn.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),Hi=of.toString,rt=ar.hasOwnProperty,fn=ar.toString,af=RegExp("^"+Hi.call(rt).replace(jc,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Yi=sn.Symbol,sf=Gi(Object.getPrototypeOf,Object),uf=ar.propertyIsEnumerable,cf=nf.splice,Xi=Yi?Yi.isConcatSpreadable:void 0,ln=Object.getOwnPropertySymbols,Ji=Math.max,ff=Qi(sn,"Map"),St=Qi(Object,"create");function Ve(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function lf(){this.__data__=St?St(null):{}}function pf(t){return this.has(t)&&delete this.__data__[t]}function hf(t){var e=this.__data__;if(St){var r=e[t];return r===an?void 0:r}return rt.call(e,t)?e[t]:void 0}function df(t){var e=this.__data__;return St?e[t]!==void 0:rt.call(e,t)}function yf(t,e){var r=this.__data__;return r[t]=St&&e===void 0?an:e,this}Ve.prototype.clear=lf,Ve.prototype.delete=pf,Ve.prototype.get=hf,Ve.prototype.has=df,Ve.prototype.set=yf;function nt(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function gf(){this.__data__=[]}function mf(t){var e=this.__data__,r=ur(e,t);if(r<0)return!1;var n=e.length-1;return r==n?e.pop():cf.call(e,r,1),!0}function wf(t){var e=this.__data__,r=ur(e,t);return r<0?void 0:e[r][1]}function vf(t){return ur(this.__data__,t)>-1}function _f(t,e){var r=this.__data__,n=ur(r,t);return n<0?r.push([t,e]):r[n][1]=e,this}nt.prototype.clear=gf,nt.prototype.delete=mf,nt.prototype.get=wf,nt.prototype.has=vf,nt.prototype.set=_f;function it(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function bf(){this.__data__={hash:new Ve,map:new(ff||nt),string:new Ve}}function Ef(t){return cr(this,t).delete(t)}function Af(t){return cr(this,t).get(t)}function xf(t){return cr(this,t).has(t)}function Sf(t,e){return cr(this,t).set(t,e),this}it.prototype.clear=bf,it.prototype.delete=Ef,it.prototype.get=Af,it.prototype.has=xf,it.prototype.set=Sf;function sr(t){var e=-1,r=t?t.length:0;for(this.__data__=new it;++e<r;)this.add(t[e])}function If(t){return this.__data__.set(t,an),this}function Bf(t){return this.__data__.has(t)}sr.prototype.add=sr.prototype.push=If,sr.prototype.has=Bf;function Of(t,e){var r=pn(t)||Zi(t)?Qc(t.length,String):[],n=r.length,a=!!n;for(var s in t)(e||rt.call(t,s))&&!(a&&(s=="length"||kf(s,n)))&&r.push(s);return r}function ur(t,e){for(var r=t.length;r--;)if(Hf(t[r][0],e))return r;return-1}function Tf(t,e,r,n){var a=-1,s=Hc,f=!0,p=t.length,h=[],m=e.length;if(!p)return h;r&&(e=zi(e,Zc(r))),n?(s=Yc,f=!1):e.length>=Cc&&(s=ef,f=!1,e=new sr(e));e:for(;++a<p;){var v=t[a],_=r?r(v):v;if(v=n||v!==0?v:0,f&&_===_){for(var b=m;b--;)if(e[b]===_)continue e;h.push(v)}else s(e,_,n)||h.push(v)}return h}function Ki(t,e,r,n,a){var s=-1,f=t.length;for(r||(r=Lf),a||(a=[]);++s<f;){var p=t[s];e>0&&r(p)?e>1?Ki(p,e-1,r,n,a):un(a,p):n||(a[a.length]=p)}return a}function Rf(t,e,r){var n=e(t);return pn(t)?n:un(n,r(t))}function $f(t){if(!hn(t)||qf(t))return!1;var e=to(t)||rf(t)?af:qc;return e.test(Wf(t))}function Pf(t){if(!hn(t))return zf(t);var e=Vf(t),r=[];for(var n in t)n=="constructor"&&(e||!rt.call(t,n))||r.push(n);return r}function Ff(t,e){return t=Object(t),Uf(t,e,function(r,n){return n in t})}function Uf(t,e,r){for(var n=-1,a=e.length,s={};++n<a;){var f=e[n],p=t[f];r(p,f)&&(s[f]=p)}return s}function Cf(t,e){return e=Ji(e===void 0?t.length-1:e,0),function(){for(var r=arguments,n=-1,a=Ji(r.length-e,0),s=Array(a);++n<a;)s[n]=r[e+n];n=-1;for(var f=Array(e+1);++n<e;)f[n]=r[n];return f[e]=s,Wc(t,this,f)}}function Df(t){return Rf(t,Kf,Mf)}function cr(t,e){var r=t.__data__;return jf(e)?r[typeof e=="string"?"string":"hash"]:r.map}function Qi(t,e){var r=tf(t,e);return $f(r)?r:void 0}var Nf=ln?Gi(ln,Object):no,Mf=ln?function(t){for(var e=[];t;)un(e,Nf(t)),t=sf(t);return e}:no;function Lf(t){return pn(t)||Zi(t)||!!(Xi&&t&&t[Xi])}function kf(t,e){return e=e??Vi,!!e&&(typeof t=="number"||Vc.test(t))&&t>-1&&t%1==0&&t<e}function jf(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function qf(t){return!!Wi&&Wi in t}function Vf(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||ar;return t===r}function zf(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}function Gf(t){if(typeof t=="string"||Jf(t))return t;var e=t+"";return e=="0"&&1/t==-Dc?"-0":e}function Wf(t){if(t!=null){try{return Hi.call(t)}catch{}try{return t+""}catch{}}return""}function Hf(t,e){return t===e||t!==t&&e!==e}function Zi(t){return Yf(t)&&rt.call(t,"callee")&&(!uf.call(t,"callee")||fn.call(t)==Nc)}var pn=Array.isArray;function eo(t){return t!=null&&Xf(t.length)&&!to(t)}function Yf(t){return ro(t)&&eo(t)}function to(t){var e=hn(t)?fn.call(t):"";return e==Mc||e==Lc}function Xf(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Vi}function hn(t){var e=typeof t;return!!t&&(e=="object"||e=="function")}function ro(t){return!!t&&typeof t=="object"}function Jf(t){return typeof t=="symbol"||ro(t)&&fn.call(t)==kc}function Kf(t){return eo(t)?Of(t,!0):Pf(t)}var Qf=Cf(function(t,e){return t==null?{}:(e=zi(Ki(e,1),Gf),Ff(t,Tf(Df(t),e)))});function no(){return[]}var dn=Qf,Zf=Object.defineProperty,el=Object.defineProperties,tl=Object.getOwnPropertyDescriptors,io=Object.getOwnPropertySymbols,rl=Object.prototype.hasOwnProperty,nl=Object.prototype.propertyIsEnumerable,oo=(t,e,r)=>e in t?Zf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,il=(t,e)=>{for(var r in e||(e={}))rl.call(e,r)&&oo(t,r,e[r]);if(io)for(var r of io(e))nl.call(e,r)&&oo(t,r,e[r]);return t},ol=(t,e)=>el(t,tl(e));function al(t){try{return JSON.parse(t)}catch{return t}}function sl(t){return Object.entries(t).reduce((e,[r,n])=>ol(il({},e),{[r]:al(n)}),{})}const ao=t=>typeof t=="string"?t!=="0"&&t!=="false":!!t;var ul=Object.defineProperty,cl=Object.defineProperties,fl=Object.getOwnPropertyDescriptors,so=Object.getOwnPropertySymbols,ll=Object.prototype.hasOwnProperty,pl=Object.prototype.propertyIsEnumerable,uo=(t,e,r)=>e in t?ul(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,co=(t,e)=>{for(var r in e||(e={}))ll.call(e,r)&&uo(t,r,e[r]);if(so)for(var r of so(e))pl.call(e,r)&&uo(t,r,e[r]);return t},fo=(t,e)=>cl(t,fl(e));function lo(t){var e;const r=sl(t),n=r.auto_inject===void 0?!0:r.auto_inject,a=(e=r.display_on)!=null?e:[],s=r.first_option==="autodeliver";return fo(co({},dn(r,["display_on","first_option"])),{auto_inject:n,valid_pages:a,is_subscription_first:s,autoInject:n,validPages:a,isSubscriptionFirst:s})}function po(t){var e;const r=((e=t.subscription_options)==null?void 0:e.storefront_purchase_options)==="subscription_only";return fo(co({},t),{is_subscription_only:r,isSubscriptionOnly:r})}function hl(t){return t.map(e=>{const r={};return Object.entries(e).forEach(([n,a])=>{r[n]=po(a)}),r})}const fr="2020-12",dl={store_currency:{currency_code:"USD",currency_symbol:"$",decimal_separator:".",thousands_separator:",",currency_symbol_location:"left"}},It=new Map;function lr(t,e){return It.has(t)||It.set(t,e()),It.get(t)}async function yn(t){const{product:e}=await lr(`product.${t}`,()=>or("get",`/product/${fr}/${t}.json`));return po(e)}async function ho(){return await lr("storeSettings",()=>or("get",`/${fr}/store_settings.json`).catch(()=>dl))}async function yo(){const{widget_settings:t}=await lr("widgetSettings",()=>or("get",`/${fr}/widget_settings.json`));return lo(t)}async function go(){const{products:t,widget_settings:e,store_settings:r,meta:n}=await lr("productsAndSettings",()=>or("get",`/product/${fr}/products.json`));return n?.status==="error"?Promise.reject(n.message):{products:hl(t),widget_settings:lo(e),store_settings:r??{}}}async function yl(){const{products:t}=await go();return t}async function gl(t){const[e,r,n]=await Promise.all([yn(t),ho(),yo()]);return{product:e,store_settings:r,widget_settings:n,storeSettings:r,widgetSettings:n}}async function mo(t){const{bundle_product:e}=await yn(t);return e}async function wo(){return Array.from(It.keys()).forEach(t=>It.delete(t))}var ml=Object.freeze({__proto__:null,getCDNProduct:yn,getCDNStoreSettings:ho,getCDNWidgetSettings:yo,getCDNProductsAndSettings:go,getCDNProducts:yl,getCDNProductAndSettings:gl,getCDNBundleSettings:mo,resetCDNCache:wo}),vo={exports:{}};/*! For license information please see xdr.js.LICENSE.txt */(function(t,e){(function(r,n){t.exports=n()})(oe,()=>(()=>{var r={899:(s,f,p)=>{const h=p(221);s.exports=h},221:(s,f,p)=>{p.r(f),p.d(f,{Array:()=>ft,Bool:()=>G,Double:()=>hr,Enum:()=>_e,Float:()=>Pe,Hyper:()=>L,Int:()=>z,Opaque:()=>Pt,Option:()=>Ut,Quadruple:()=>k,Reference:()=>ee,String:()=>$t,Struct:()=>Fe,Union:()=>Ie,UnsignedHyper:()=>ie,UnsignedInt:()=>N,VarArray:()=>Ft,VarOpaque:()=>Se,Void:()=>J,config:()=>g});class h extends TypeError{constructor(o){super(`XDR Write Error: ${o}`)}}class m extends TypeError{constructor(o){super(`XDR Read Error: ${o}`)}}class v extends TypeError{constructor(o){super(`XDR Type Definition Error: ${o}`)}}class _ extends v{constructor(){super("method not implemented, it should be overloaded in the descendant class.")}}var b=p(764).lW;class y{constructor(o){if(!b.isBuffer(o)){if(!(o instanceof Array))throw new m("source not specified");o=b.from(o)}this._buffer=o,this._length=o.length,this._index=0}_buffer;_length;_index;get eof(){return this._index===this._length}advance(o){const l=this._index;if(this._index+=o,this._length<this._index)throw new m("attempt to read outside the boundary of the buffer");const w=4-(o%4||4);if(w>0){for(let A=0;A<w;A++)if(this._buffer[this._index+A]!==0)throw new m("invalid padding");this._index+=w}return l}rewind(){this._index=0}read(o){const l=this.advance(o);return this._buffer.subarray(l,l+o)}readInt32BE(){return this._buffer.readInt32BE(this.advance(4))}readUInt32BE(){return this._buffer.readUInt32BE(this.advance(4))}readBigInt64BE(){return this._buffer.readBigInt64BE(this.advance(8))}readBigUInt64BE(){return this._buffer.readBigUInt64BE(this.advance(8))}readFloatBE(){return this._buffer.readFloatBE(this.advance(4))}readDoubleBE(){return this._buffer.readDoubleBE(this.advance(8))}ensureInputConsumed(){if(this._index!==this._length)throw new m("invalid XDR contract typecast - source buffer not entirely consumed")}}var x=p(764).lW;const I=8192;class O{constructor(o){typeof o=="number"?o=x.allocUnsafe(o):o instanceof x||(o=x.allocUnsafe(I)),this._buffer=o,this._length=o.length}_buffer;_length;_index=0;alloc(o){const l=this._index;return this._index+=o,this._length<this._index&&this.resize(this._index),l}resize(o){const l=Math.ceil(o/I)*I,w=x.allocUnsafe(l);this._buffer.copy(w,0,0,this._length),this._buffer=w,this._length=l}finalize(){return this._buffer.subarray(0,this._index)}toArray(){return[...this.finalize()]}write(o,l){if(typeof o=="string"){const A=this.alloc(l);this._buffer.write(o,A,"utf8")}else{o instanceof x||(o=x.from(o));const A=this.alloc(l);o.copy(this._buffer,A,0,l)}const w=4-(l%4||4);if(w>0){const A=this.alloc(w);this._buffer.fill(0,A,this._index)}}writeInt32BE(o){const l=this.alloc(4);this._buffer.writeInt32BE(o,l)}writeUInt32BE(o){const l=this.alloc(4);this._buffer.writeUInt32BE(o,l)}writeBigInt64BE(o){const l=this.alloc(8);this._buffer.writeBigInt64BE(o,l)}writeBigUInt64BE(o){const l=this.alloc(8);this._buffer.writeBigUInt64BE(o,l)}writeFloatBE(o){const l=this.alloc(4);this._buffer.writeFloatBE(o,l)}writeDoubleBE(o){const l=this.alloc(8);this._buffer.writeDoubleBE(o,l)}static bufferChunkSize=I}var S=p(764).lW;class B{toXDR(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"raw";if(!this.write)return this.constructor.toXDR(this,o);const l=new O;return this.write(this,l),M(l.finalize(),o)}fromXDR(o){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"raw";if(!this.read)return this.constructor.fromXDR(o,l);const w=new y(q(o,l)),A=this.read(w);return w.ensureInputConsumed(),A}validateXDR(o){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"raw";try{return this.fromXDR(o,l),!0}catch{return!1}}static toXDR(o){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"raw";const w=new O;return this.write(o,w),M(w.finalize(),l)}static fromXDR(o){const l=new y(q(o,arguments.length>1&&arguments[1]!==void 0?arguments[1]:"raw")),w=this.read(l);return l.ensureInputConsumed(),w}static validateXDR(o){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"raw";try{return this.fromXDR(o,l),!0}catch{return!1}}}class $ extends B{static read(o){throw new _}static write(o,l){throw new _}static isValid(o){return!1}}class R extends B{isValid(o){return!1}}class D extends TypeError{constructor(o){super(`Invalid format ${o}, must be one of "raw", "hex", "base64"`)}}function M(d,o){switch(o){case"raw":return d;case"hex":return d.toString("hex");case"base64":return d.toString("base64");default:throw new D(o)}}function q(d,o){switch(o){case"raw":return d;case"hex":return S.from(d,"hex");case"base64":return S.from(d,"base64");default:throw new D(o)}}const V=2147483647,Y=-2147483648;class z extends ${static read(o){return o.readInt32BE()}static write(o,l){if(typeof o!="number")throw new h("not a number");if((0|o)!==o)throw new h("invalid i32 value");l.writeInt32BE(o)}static isValid(o){return typeof o=="number"&&(0|o)===o&&o>=Y&&o<=V}}z.MAX_VALUE=V,z.MIN_VALUE=2147483648;const ne=-9223372036854775808n,ae=9223372036854775807n;class L extends ${constructor(o,l){if(super(),typeof o=="bigint"){if(o<ne||o>ae)throw new TypeError("Invalid i64 value");this._value=o}else{if((0|o)!==o||(0|l)!==l)throw new TypeError("Invalid i64 value");this._value=BigInt(l>>>0)<<32n|BigInt(o>>>0)}}get low(){return Number(0xFFFFFFFFn&this._value)<<0}get high(){return Number(this._value>>32n)>>0}get unsigned(){return!1}toString(){return this._value.toString()}toJSON(){return{_value:this._value.toString()}}static read(o){return new L(o.readBigInt64BE())}static write(o,l){if(!(o instanceof this))throw new h(`${o} is not a Hyper`);l.writeBigInt64BE(o._value)}static fromString(o){if(!/^-?\d{0,19}$/.test(o))throw new TypeError(`Invalid i64 string value: ${o}`);return new L(BigInt(o))}static fromBits(o,l){return new this(o,l)}static isValid(o){return o instanceof this}}L.MAX_VALUE=new L(ae),L.MIN_VALUE=new L(ne);const Z=4294967295;class N extends ${static read(o){return o.readUInt32BE()}static write(o,l){if(typeof o!="number"||!(o>=0&&o<=Z)||o%1!=0)throw new h("invalid u32 value");l.writeUInt32BE(o)}static isValid(o){return typeof o=="number"&&o%1==0&&o>=0&&o<=Z}}N.MAX_VALUE=Z,N.MIN_VALUE=0;const se=0n,ut=0xFFFFFFFFFFFFFFFFn;class ie extends ${constructor(o,l){if(super(),typeof o=="bigint"){if(o<se||o>ut)throw new TypeError("Invalid u64 value");this._value=o}else{if((0|o)!==o||(0|l)!==l)throw new TypeError("Invalid u64 value");this._value=BigInt(l>>>0)<<32n|BigInt(o>>>0)}}get low(){return Number(0xFFFFFFFFn&this._value)<<0}get high(){return Number(this._value>>32n)>>0}get unsigned(){return!0}toString(){return this._value.toString()}toJSON(){return{_value:this._value.toString()}}static read(o){return new ie(o.readBigUInt64BE())}static write(o,l){if(!(o instanceof this))throw new h(`${o} is not an UnsignedHyper`);l.writeBigUInt64BE(o._value)}static fromString(o){if(!/^\d{0,20}$/.test(o))throw new TypeError(`Invalid u64 string value: ${o}`);return new ie(BigInt(o))}static fromBits(o,l){return new this(o,l)}static isValid(o){return o instanceof this}}ie.MAX_VALUE=new ie(ut),ie.MIN_VALUE=new ie(se);class Pe extends ${static read(o){return o.readFloatBE()}static write(o,l){if(typeof o!="number")throw new h("not a number");l.writeFloatBE(o)}static isValid(o){return typeof o=="number"}}class hr extends ${static read(o){return o.readDoubleBE()}static write(o,l){if(typeof o!="number")throw new h("not a number");l.writeDoubleBE(o)}static isValid(o){return typeof o=="number"}}class k extends ${static read(){throw new v("quadruple not supported")}static write(){throw new v("quadruple not supported")}static isValid(){return!1}}class G extends ${static read(o){const l=z.read(o);switch(l){case 0:return!1;case 1:return!0;default:throw new m(`got ${l} when trying to read a bool`)}}static write(o,l){const w=o?1:0;z.write(w,l)}static isValid(o){return typeof o=="boolean"}}var ct=p(764).lW;class $t extends R{constructor(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:N.MAX_VALUE;super(),this._maxLength=o}read(o){const l=N.read(o);if(l>this._maxLength)throw new m(`saw ${l} length String, max allowed is ${this._maxLength}`);return o.read(l)}readString(o){return this.read(o).toString("utf8")}write(o,l){const w=typeof o=="string"?ct.byteLength(o,"utf8"):o.length;if(w>this._maxLength)throw new h(`got ${o.length} bytes, max allowed is ${this._maxLength}`);N.write(w,l),l.write(o,w)}isValid(o){return typeof o=="string"?ct.byteLength(o,"utf8")<=this._maxLength:!!(o instanceof Array||ct.isBuffer(o))&&o.length<=this._maxLength}}var dr=p(764).lW;class Pt extends R{constructor(o){super(),this._length=o}read(o){return o.read(this._length)}write(o,l){const{length:w}=o;if(w!==this._length)throw new h(`got ${o.length} bytes, expected ${this._length}`);l.write(o,w)}isValid(o){return dr.isBuffer(o)&&o.length===this._length}}var yr=p(764).lW;class Se extends R{constructor(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:N.MAX_VALUE;super(),this._maxLength=o}read(o){const l=N.read(o);if(l>this._maxLength)throw new m(`saw ${l} length VarOpaque, max allowed is ${this._maxLength}`);return o.read(l)}write(o,l){const{length:w}=o;if(o.length>this._maxLength)throw new h(`got ${o.length} bytes, max allowed is ${this._maxLength}`);N.write(w,l),l.write(o,w)}isValid(o){return yr.isBuffer(o)&&o.length<=this._maxLength}}class ft extends R{constructor(o,l){super(),this._childType=o,this._length=l}read(o){const l=new p.g.Array(this._length);for(let w=0;w<this._length;w++)l[w]=this._childType.read(o);return l}write(o,l){if(!(o instanceof p.g.Array))throw new h("value is not array");if(o.length!==this._length)throw new h(`got array of size ${o.length}, expected ${this._length}`);for(const w of o)this._childType.write(w,l)}isValid(o){if(!(o instanceof p.g.Array)||o.length!==this._length)return!1;for(const l of o)if(!this._childType.isValid(l))return!1;return!0}}class Ft extends R{constructor(o){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:N.MAX_VALUE;super(),this._childType=o,this._maxLength=l}read(o){const l=N.read(o);if(l>this._maxLength)throw new m(`saw ${l} length VarArray, max allowed is ${this._maxLength}`);const w=new Array(l);for(let A=0;A<l;A++)w[A]=this._childType.read(o);return w}write(o,l){if(!(o instanceof Array))throw new h("value is not array");if(o.length>this._maxLength)throw new h(`got array of size ${o.length}, max allowed is ${this._maxLength}`);N.write(o.length,l);for(const w of o)this._childType.write(w,l)}isValid(o){if(!(o instanceof Array)||o.length>this._maxLength)return!1;for(const l of o)if(!this._childType.isValid(l))return!1;return!0}}class Ut extends ${constructor(o){super(),this._childType=o}read(o){if(G.read(o))return this._childType.read(o)}write(o,l){const w=o!=null;G.write(w,l),w&&this._childType.write(o,l)}isValid(o){return o==null||this._childType.isValid(o)}}class J extends ${static read(){}static write(o){if(o!==void 0)throw new h("trying to write value to a void slot")}static isValid(o){return o===void 0}}class _e extends ${constructor(o,l){super(),this.name=o,this.value=l}static read(o){const l=z.read(o),w=this._byValue[l];if(w===void 0)throw new m(`unknown ${this.enumName} member for value ${l}`);return w}static write(o,l){if(!(o instanceof this))throw new h(`unknown ${o} is not a ${this.enumName}`);z.write(o.value,l)}static isValid(o){return o instanceof this}static members(){return this._members}static values(){return Object.values(this._members)}static fromName(o){const l=this._members[o];if(!l)throw new TypeError(`${o} is not a member of ${this.enumName}`);return l}static fromValue(o){const l=this._byValue[o];if(l===void 0)throw new TypeError(`${o} is not a value of any member of ${this.enumName}`);return l}static create(o,l,w){const A=class extends _e{};A.enumName=l,o.results[l]=A,A._members={},A._byValue={};for(const[F,P]of Object.entries(w)){const U=new A(F,P);A._members[F]=U,A._byValue[P]=U,A[F]=()=>U}return A}}class ee extends ${resolve(){throw new v('"resolve" method should be implemented in the descendant class')}}class Fe extends ${constructor(o){super(),this._attributes=o||{}}static read(o){const l={};for(const[w,A]of this._fields)l[w]=A.read(o);return new this(l)}static write(o,l){if(!(o instanceof this))throw new h(`${o} is not a ${this.structName}`);for(const[w,A]of this._fields){const F=o._attributes[w];A.write(F,l)}}static isValid(o){return o instanceof this}static create(o,l,w){const A=class extends Fe{};A.structName=l,o.results[l]=A;const F=new Array(w.length);for(let P=0;P<w.length;P++){const U=w[P],Ct=U[0];let mr=U[1];mr instanceof ee&&(mr=mr.resolve(o)),F[P]=[Ct,mr],A.prototype[Ct]=gr(Ct)}return A._fields=F,A}}function gr(d){return function(o){return o!==void 0&&(this._attributes[d]=o),this._attributes[d]}}class Ie extends R{constructor(o,l){super(),this.set(o,l)}set(o,l){typeof o=="string"&&(o=this.constructor._switchOn.fromName(o)),this._switch=o;const w=this.constructor.armForSwitch(this._switch);this._arm=w,this._armType=w===J?J:this.constructor._arms[w],this._value=l}get(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this._arm;if(this._arm!==J&&this._arm!==o)throw new TypeError(`${o} not set`);return this._value}switch(){return this._switch}arm(){return this._arm}armType(){return this._armType}value(){return this._value}static armForSwitch(o){const l=this._switches.get(o);if(l!==void 0)return l;if(this._defaultArm)return this._defaultArm;throw new TypeError(`Bad union switch: ${o}`)}static armTypeForArm(o){return o===J?J:this._arms[o]}static read(o){const l=this._switchOn.read(o),w=this.armForSwitch(l),A=w===J?J:this._arms[w];let F;return F=A!==void 0?A.read(o):w.read(o),new this(l,F)}static write(o,l){if(!(o instanceof this))throw new h(`${o} is not a ${this.unionName}`);this._switchOn.write(o.switch(),l),o.armType().write(o.value(),l)}static isValid(o){return o instanceof this}static create(o,l,w){const A=class extends Ie{};A.unionName=l,o.results[l]=A,w.switchOn instanceof ee?A._switchOn=w.switchOn.resolve(o):A._switchOn=w.switchOn,A._switches=new Map,A._arms={};let F=w.defaultArm;F instanceof ee&&(F=F.resolve(o)),A._defaultArm=F;for(const[P,U]of w.switches){const Ct=typeof P=="string"?A._switchOn.fromName(P):P;A._switches.set(Ct,U)}if(A._switchOn.values!==void 0)for(const P of A._switchOn.values())A[P.name]=function(U){return new A(P,U)},A.prototype[P.name]=function(U){return this.set(P,U)};if(w.arms)for(const[P,U]of Object.entries(w.arms))A._arms[P]=U instanceof ee?U.resolve(o):U,U!==J&&(A.prototype[P]=function(){return this.get(P)});return A}}class fe extends ee{constructor(o){super(),this.name=o}resolve(o){return o.definitions[this.name].resolve(o)}}class lt extends ee{constructor(o,l){let w=arguments.length>2&&arguments[2]!==void 0&&arguments[2];super(),this.childReference=o,this.length=l,this.variable=w}resolve(o){let l=this.childReference,w=this.length;return l instanceof ee&&(l=l.resolve(o)),w instanceof ee&&(w=w.resolve(o)),this.variable?new Ft(l,w):new ft(l,w)}}class En extends ee{constructor(o){super(),this.childReference=o,this.name=o.name}resolve(o){let l=this.childReference;return l instanceof ee&&(l=l.resolve(o)),new Ut(l)}}class le extends ee{constructor(o,l){super(),this.sizedType=o,this.length=l}resolve(o){let l=this.length;return l instanceof ee&&(l=l.resolve(o)),new this.sizedType(l)}}class We{constructor(o,l,w){this.constructor=o,this.name=l,this.config=w}resolve(o){return this.name in o.results?o.results[this.name]:this.constructor(o,this.name,this.config)}}function i(d,o,l){return l instanceof ee&&(l=l.resolve(d)),d.results[o]=l,l}function u(d,o,l){return d.results[o]=l,l}class c{constructor(o){this._destination=o,this._definitions={}}enum(o,l){const w=new We(_e.create,o,l);this.define(o,w)}struct(o,l){const w=new We(Fe.create,o,l);this.define(o,w)}union(o,l){const w=new We(Ie.create,o,l);this.define(o,w)}typedef(o,l){const w=new We(i,o,l);this.define(o,w)}const(o,l){const w=new We(u,o,l);this.define(o,w)}void(){return J}bool(){return G}int(){return z}hyper(){return L}uint(){return N}uhyper(){return ie}float(){return Pe}double(){return hr}quadruple(){return k}string(o){return new le($t,o)}opaque(o){return new le(Pt,o)}varOpaque(o){return new le(Se,o)}array(o,l){return new lt(o,l)}varArray(o,l){return new lt(o,l,!0)}option(o){return new En(o)}define(o,l){if(this._destination[o]!==void 0)throw new v(`${o} is already defined`);this._definitions[o]=l}lookup(o){return new fe(o)}resolve(){for(const o of Object.values(this._definitions))o.resolve({definitions:this._definitions,results:this._destination})}}function g(d){let o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(d){const l=new c(o);d(l),l.resolve()}return o}},742:(s,f)=>{f.byteLength=function(x){var I=b(x),O=I[0],S=I[1];return 3*(O+S)/4-S},f.toByteArray=function(x){var I,O,S=b(x),B=S[0],$=S[1],R=new m(function(q,V,Y){return 3*(V+Y)/4-Y}(0,B,$)),D=0,M=$>0?B-4:B;for(O=0;O<M;O+=4)I=h[x.charCodeAt(O)]<<18|h[x.charCodeAt(O+1)]<<12|h[x.charCodeAt(O+2)]<<6|h[x.charCodeAt(O+3)],R[D++]=I>>16&255,R[D++]=I>>8&255,R[D++]=255&I;return $===2&&(I=h[x.charCodeAt(O)]<<2|h[x.charCodeAt(O+1)]>>4,R[D++]=255&I),$===1&&(I=h[x.charCodeAt(O)]<<10|h[x.charCodeAt(O+1)]<<4|h[x.charCodeAt(O+2)]>>2,R[D++]=I>>8&255,R[D++]=255&I),R},f.fromByteArray=function(x){for(var I,O=x.length,S=O%3,B=[],$=16383,R=0,D=O-S;R<D;R+=$)B.push(y(x,R,R+$>D?D:R+$));return S===1?(I=x[O-1],B.push(p[I>>2]+p[I<<4&63]+"==")):S===2&&(I=(x[O-2]<<8)+x[O-1],B.push(p[I>>10]+p[I>>4&63]+p[I<<2&63]+"=")),B.join("")};for(var p=[],h=[],m=typeof Uint8Array<"u"?Uint8Array:Array,v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",_=0;_<64;++_)p[_]=v[_],h[v.charCodeAt(_)]=_;function b(x){var I=x.length;if(I%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var O=x.indexOf("=");return O===-1&&(O=I),[O,O===I?0:4-O%4]}function y(x,I,O){for(var S,B,$=[],R=I;R<O;R+=3)S=(x[R]<<16&16711680)+(x[R+1]<<8&65280)+(255&x[R+2]),$.push(p[(B=S)>>18&63]+p[B>>12&63]+p[B>>6&63]+p[63&B]);return $.join("")}h["-".charCodeAt(0)]=62,h["_".charCodeAt(0)]=63},764:(s,f,p)=>{const h=p(742),m=p(645),v=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;f.lW=y,f.h2=50;const _=2147483647;function b(i){if(i>_)throw new RangeError('The value "'+i+'" is invalid for option "size"');const u=new Uint8Array(i);return Object.setPrototypeOf(u,y.prototype),u}function y(i,u,c){if(typeof i=="number"){if(typeof u=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return O(i)}return x(i,u,c)}function x(i,u,c){if(typeof i=="string")return function(o,l){if(typeof l=="string"&&l!==""||(l="utf8"),!y.isEncoding(l))throw new TypeError("Unknown encoding: "+l);const w=0|R(o,l);let A=b(w);const F=A.write(o,l);return F!==w&&(A=A.slice(0,F)),A}(i,u);if(ArrayBuffer.isView(i))return function(o){if(fe(o,Uint8Array)){const l=new Uint8Array(o);return B(l.buffer,l.byteOffset,l.byteLength)}return S(o)}(i);if(i==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof i);if(fe(i,ArrayBuffer)||i&&fe(i.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(fe(i,SharedArrayBuffer)||i&&fe(i.buffer,SharedArrayBuffer)))return B(i,u,c);if(typeof i=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const g=i.valueOf&&i.valueOf();if(g!=null&&g!==i)return y.from(g,u,c);const d=function(o){if(y.isBuffer(o)){const l=0|$(o.length),w=b(l);return w.length===0||o.copy(w,0,0,l),w}if(o.length!==void 0)return typeof o.length!="number"||lt(o.length)?b(0):S(o);if(o.type==="Buffer"&&Array.isArray(o.data))return S(o.data)}(i);if(d)return d;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof i[Symbol.toPrimitive]=="function")return y.from(i[Symbol.toPrimitive]("string"),u,c);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof i)}function I(i){if(typeof i!="number")throw new TypeError('"size" argument must be of type number');if(i<0)throw new RangeError('The value "'+i+'" is invalid for option "size"')}function O(i){return I(i),b(i<0?0:0|$(i))}function S(i){const u=i.length<0?0:0|$(i.length),c=b(u);for(let g=0;g<u;g+=1)c[g]=255&i[g];return c}function B(i,u,c){if(u<0||i.byteLength<u)throw new RangeError('"offset" is outside of buffer bounds');if(i.byteLength<u+(c||0))throw new RangeError('"length" is outside of buffer bounds');let g;return g=u===void 0&&c===void 0?new Uint8Array(i):c===void 0?new Uint8Array(i,u):new Uint8Array(i,u,c),Object.setPrototypeOf(g,y.prototype),g}function $(i){if(i>=_)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+_.toString(16)+" bytes");return 0|i}function R(i,u){if(y.isBuffer(i))return i.length;if(ArrayBuffer.isView(i)||fe(i,ArrayBuffer))return i.byteLength;if(typeof i!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof i);const c=i.length,g=arguments.length>2&&arguments[2]===!0;if(!g&&c===0)return 0;let d=!1;for(;;)switch(u){case"ascii":case"latin1":case"binary":return c;case"utf8":case"utf-8":return Fe(i).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*c;case"hex":return c>>>1;case"base64":return gr(i).length;default:if(d)return g?-1:Fe(i).length;u=(""+u).toLowerCase(),d=!0}}function D(i,u,c){let g=!1;if((u===void 0||u<0)&&(u=0),u>this.length||((c===void 0||c>this.length)&&(c=this.length),c<=0)||(c>>>=0)<=(u>>>=0))return"";for(i||(i="utf8");;)switch(i){case"hex":return Pe(this,u,c);case"utf8":case"utf-8":return N(this,u,c);case"ascii":return ut(this,u,c);case"latin1":case"binary":return ie(this,u,c);case"base64":return Z(this,u,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return hr(this,u,c);default:if(g)throw new TypeError("Unknown encoding: "+i);i=(i+"").toLowerCase(),g=!0}}function M(i,u,c){const g=i[u];i[u]=i[c],i[c]=g}function q(i,u,c,g,d){if(i.length===0)return-1;if(typeof c=="string"?(g=c,c=0):c>2147483647?c=2147483647:c<-2147483648&&(c=-2147483648),lt(c=+c)&&(c=d?0:i.length-1),c<0&&(c=i.length+c),c>=i.length){if(d)return-1;c=i.length-1}else if(c<0){if(!d)return-1;c=0}if(typeof u=="string"&&(u=y.from(u,g)),y.isBuffer(u))return u.length===0?-1:V(i,u,c,g,d);if(typeof u=="number")return u&=255,typeof Uint8Array.prototype.indexOf=="function"?d?Uint8Array.prototype.indexOf.call(i,u,c):Uint8Array.prototype.lastIndexOf.call(i,u,c):V(i,[u],c,g,d);throw new TypeError("val must be string, number or Buffer")}function V(i,u,c,g,d){let o,l=1,w=i.length,A=u.length;if(g!==void 0&&((g=String(g).toLowerCase())==="ucs2"||g==="ucs-2"||g==="utf16le"||g==="utf-16le")){if(i.length<2||u.length<2)return-1;l=2,w/=2,A/=2,c/=2}function F(P,U){return l===1?P[U]:P.readUInt16BE(U*l)}if(d){let P=-1;for(o=c;o<w;o++)if(F(i,o)===F(u,P===-1?0:o-P)){if(P===-1&&(P=o),o-P+1===A)return P*l}else P!==-1&&(o-=o-P),P=-1}else for(c+A>w&&(c=w-A),o=c;o>=0;o--){let P=!0;for(let U=0;U<A;U++)if(F(i,o+U)!==F(u,U)){P=!1;break}if(P)return o}return-1}function Y(i,u,c,g){c=Number(c)||0;const d=i.length-c;g?(g=Number(g))>d&&(g=d):g=d;const o=u.length;let l;for(g>o/2&&(g=o/2),l=0;l<g;++l){const w=parseInt(u.substr(2*l,2),16);if(lt(w))return l;i[c+l]=w}return l}function z(i,u,c,g){return Ie(Fe(u,i.length-c),i,c,g)}function ne(i,u,c,g){return Ie(function(d){const o=[];for(let l=0;l<d.length;++l)o.push(255&d.charCodeAt(l));return o}(u),i,c,g)}function ae(i,u,c,g){return Ie(gr(u),i,c,g)}function L(i,u,c,g){return Ie(function(d,o){let l,w,A;const F=[];for(let P=0;P<d.length&&!((o-=2)<0);++P)l=d.charCodeAt(P),w=l>>8,A=l%256,F.push(A),F.push(w);return F}(u,i.length-c),i,c,g)}function Z(i,u,c){return u===0&&c===i.length?h.fromByteArray(i):h.fromByteArray(i.slice(u,c))}function N(i,u,c){c=Math.min(i.length,c);const g=[];let d=u;for(;d<c;){const o=i[d];let l=null,w=o>239?4:o>223?3:o>191?2:1;if(d+w<=c){let A,F,P,U;switch(w){case 1:o<128&&(l=o);break;case 2:A=i[d+1],(192&A)==128&&(U=(31&o)<<6|63&A,U>127&&(l=U));break;case 3:A=i[d+1],F=i[d+2],(192&A)==128&&(192&F)==128&&(U=(15&o)<<12|(63&A)<<6|63&F,U>2047&&(U<55296||U>57343)&&(l=U));break;case 4:A=i[d+1],F=i[d+2],P=i[d+3],(192&A)==128&&(192&F)==128&&(192&P)==128&&(U=(15&o)<<18|(63&A)<<12|(63&F)<<6|63&P,U>65535&&U<1114112&&(l=U))}}l===null?(l=65533,w=1):l>65535&&(l-=65536,g.push(l>>>10&1023|55296),l=56320|1023&l),g.push(l),d+=w}return function(o){const l=o.length;if(l<=se)return String.fromCharCode.apply(String,o);let w="",A=0;for(;A<l;)w+=String.fromCharCode.apply(String,o.slice(A,A+=se));return w}(g)}y.TYPED_ARRAY_SUPPORT=function(){try{const i=new Uint8Array(1),u={foo:function(){return 42}};return Object.setPrototypeOf(u,Uint8Array.prototype),Object.setPrototypeOf(i,u),i.foo()===42}catch{return!1}}(),y.TYPED_ARRAY_SUPPORT||typeof console>"u"||typeof console.error!="function"||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(y.prototype,"parent",{enumerable:!0,get:function(){if(y.isBuffer(this))return this.buffer}}),Object.defineProperty(y.prototype,"offset",{enumerable:!0,get:function(){if(y.isBuffer(this))return this.byteOffset}}),y.poolSize=8192,y.from=function(i,u,c){return x(i,u,c)},Object.setPrototypeOf(y.prototype,Uint8Array.prototype),Object.setPrototypeOf(y,Uint8Array),y.alloc=function(i,u,c){return function(g,d,o){return I(g),g<=0?b(g):d!==void 0?typeof o=="string"?b(g).fill(d,o):b(g).fill(d):b(g)}(i,u,c)},y.allocUnsafe=function(i){return O(i)},y.allocUnsafeSlow=function(i){return O(i)},y.isBuffer=function(i){return i!=null&&i._isBuffer===!0&&i!==y.prototype},y.compare=function(i,u){if(fe(i,Uint8Array)&&(i=y.from(i,i.offset,i.byteLength)),fe(u,Uint8Array)&&(u=y.from(u,u.offset,u.byteLength)),!y.isBuffer(i)||!y.isBuffer(u))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(i===u)return 0;let c=i.length,g=u.length;for(let d=0,o=Math.min(c,g);d<o;++d)if(i[d]!==u[d]){c=i[d],g=u[d];break}return c<g?-1:g<c?1:0},y.isEncoding=function(i){switch(String(i).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},y.concat=function(i,u){if(!Array.isArray(i))throw new TypeError('"list" argument must be an Array of Buffers');if(i.length===0)return y.alloc(0);let c;if(u===void 0)for(u=0,c=0;c<i.length;++c)u+=i[c].length;const g=y.allocUnsafe(u);let d=0;for(c=0;c<i.length;++c){let o=i[c];if(fe(o,Uint8Array))d+o.length>g.length?(y.isBuffer(o)||(o=y.from(o)),o.copy(g,d)):Uint8Array.prototype.set.call(g,o,d);else{if(!y.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(g,d)}d+=o.length}return g},y.byteLength=R,y.prototype._isBuffer=!0,y.prototype.swap16=function(){const i=this.length;if(i%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let u=0;u<i;u+=2)M(this,u,u+1);return this},y.prototype.swap32=function(){const i=this.length;if(i%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let u=0;u<i;u+=4)M(this,u,u+3),M(this,u+1,u+2);return this},y.prototype.swap64=function(){const i=this.length;if(i%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let u=0;u<i;u+=8)M(this,u,u+7),M(this,u+1,u+6),M(this,u+2,u+5),M(this,u+3,u+4);return this},y.prototype.toString=function(){const i=this.length;return i===0?"":arguments.length===0?N(this,0,i):D.apply(this,arguments)},y.prototype.toLocaleString=y.prototype.toString,y.prototype.equals=function(i){if(!y.isBuffer(i))throw new TypeError("Argument must be a Buffer");return this===i||y.compare(this,i)===0},y.prototype.inspect=function(){let i="";const u=f.h2;return i=this.toString("hex",0,u).replace(/(.{2})/g,"$1 ").trim(),this.length>u&&(i+=" ... "),"<Buffer "+i+">"},v&&(y.prototype[v]=y.prototype.inspect),y.prototype.compare=function(i,u,c,g,d){if(fe(i,Uint8Array)&&(i=y.from(i,i.offset,i.byteLength)),!y.isBuffer(i))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof i);if(u===void 0&&(u=0),c===void 0&&(c=i?i.length:0),g===void 0&&(g=0),d===void 0&&(d=this.length),u<0||c>i.length||g<0||d>this.length)throw new RangeError("out of range index");if(g>=d&&u>=c)return 0;if(g>=d)return-1;if(u>=c)return 1;if(this===i)return 0;let o=(d>>>=0)-(g>>>=0),l=(c>>>=0)-(u>>>=0);const w=Math.min(o,l),A=this.slice(g,d),F=i.slice(u,c);for(let P=0;P<w;++P)if(A[P]!==F[P]){o=A[P],l=F[P];break}return o<l?-1:l<o?1:0},y.prototype.includes=function(i,u,c){return this.indexOf(i,u,c)!==-1},y.prototype.indexOf=function(i,u,c){return q(this,i,u,c,!0)},y.prototype.lastIndexOf=function(i,u,c){return q(this,i,u,c,!1)},y.prototype.write=function(i,u,c,g){if(u===void 0)g="utf8",c=this.length,u=0;else if(c===void 0&&typeof u=="string")g=u,c=this.length,u=0;else{if(!isFinite(u))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");u>>>=0,isFinite(c)?(c>>>=0,g===void 0&&(g="utf8")):(g=c,c=void 0)}const d=this.length-u;if((c===void 0||c>d)&&(c=d),i.length>0&&(c<0||u<0)||u>this.length)throw new RangeError("Attempt to write outside buffer bounds");g||(g="utf8");let o=!1;for(;;)switch(g){case"hex":return Y(this,i,u,c);case"utf8":case"utf-8":return z(this,i,u,c);case"ascii":case"latin1":case"binary":return ne(this,i,u,c);case"base64":return ae(this,i,u,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,i,u,c);default:if(o)throw new TypeError("Unknown encoding: "+g);g=(""+g).toLowerCase(),o=!0}},y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const se=4096;function ut(i,u,c){let g="";c=Math.min(i.length,c);for(let d=u;d<c;++d)g+=String.fromCharCode(127&i[d]);return g}function ie(i,u,c){let g="";c=Math.min(i.length,c);for(let d=u;d<c;++d)g+=String.fromCharCode(i[d]);return g}function Pe(i,u,c){const g=i.length;(!u||u<0)&&(u=0),(!c||c<0||c>g)&&(c=g);let d="";for(let o=u;o<c;++o)d+=En[i[o]];return d}function hr(i,u,c){const g=i.slice(u,c);let d="";for(let o=0;o<g.length-1;o+=2)d+=String.fromCharCode(g[o]+256*g[o+1]);return d}function k(i,u,c){if(i%1!=0||i<0)throw new RangeError("offset is not uint");if(i+u>c)throw new RangeError("Trying to access beyond buffer length")}function G(i,u,c,g,d,o){if(!y.isBuffer(i))throw new TypeError('"buffer" argument must be a Buffer instance');if(u>d||u<o)throw new RangeError('"value" argument is out of bounds');if(c+g>i.length)throw new RangeError("Index out of range")}function ct(i,u,c,g,d){Ut(u,g,d,i,c,7);let o=Number(u&BigInt(4294967295));i[c++]=o,o>>=8,i[c++]=o,o>>=8,i[c++]=o,o>>=8,i[c++]=o;let l=Number(u>>BigInt(32)&BigInt(4294967295));return i[c++]=l,l>>=8,i[c++]=l,l>>=8,i[c++]=l,l>>=8,i[c++]=l,c}function $t(i,u,c,g,d){Ut(u,g,d,i,c,7);let o=Number(u&BigInt(4294967295));i[c+7]=o,o>>=8,i[c+6]=o,o>>=8,i[c+5]=o,o>>=8,i[c+4]=o;let l=Number(u>>BigInt(32)&BigInt(4294967295));return i[c+3]=l,l>>=8,i[c+2]=l,l>>=8,i[c+1]=l,l>>=8,i[c]=l,c+8}function dr(i,u,c,g,d,o){if(c+g>i.length)throw new RangeError("Index out of range");if(c<0)throw new RangeError("Index out of range")}function Pt(i,u,c,g,d){return u=+u,c>>>=0,d||dr(i,0,c,4),m.write(i,u,c,g,23,4),c+4}function yr(i,u,c,g,d){return u=+u,c>>>=0,d||dr(i,0,c,8),m.write(i,u,c,g,52,8),c+8}y.prototype.slice=function(i,u){const c=this.length;(i=~~i)<0?(i+=c)<0&&(i=0):i>c&&(i=c),(u=u===void 0?c:~~u)<0?(u+=c)<0&&(u=0):u>c&&(u=c),u<i&&(u=i);const g=this.subarray(i,u);return Object.setPrototypeOf(g,y.prototype),g},y.prototype.readUintLE=y.prototype.readUIntLE=function(i,u,c){i>>>=0,u>>>=0,c||k(i,u,this.length);let g=this[i],d=1,o=0;for(;++o<u&&(d*=256);)g+=this[i+o]*d;return g},y.prototype.readUintBE=y.prototype.readUIntBE=function(i,u,c){i>>>=0,u>>>=0,c||k(i,u,this.length);let g=this[i+--u],d=1;for(;u>0&&(d*=256);)g+=this[i+--u]*d;return g},y.prototype.readUint8=y.prototype.readUInt8=function(i,u){return i>>>=0,u||k(i,1,this.length),this[i]},y.prototype.readUint16LE=y.prototype.readUInt16LE=function(i,u){return i>>>=0,u||k(i,2,this.length),this[i]|this[i+1]<<8},y.prototype.readUint16BE=y.prototype.readUInt16BE=function(i,u){return i>>>=0,u||k(i,2,this.length),this[i]<<8|this[i+1]},y.prototype.readUint32LE=y.prototype.readUInt32LE=function(i,u){return i>>>=0,u||k(i,4,this.length),(this[i]|this[i+1]<<8|this[i+2]<<16)+16777216*this[i+3]},y.prototype.readUint32BE=y.prototype.readUInt32BE=function(i,u){return i>>>=0,u||k(i,4,this.length),16777216*this[i]+(this[i+1]<<16|this[i+2]<<8|this[i+3])},y.prototype.readBigUInt64LE=le(function(i){J(i>>>=0,"offset");const u=this[i],c=this[i+7];u!==void 0&&c!==void 0||_e(i,this.length-8);const g=u+256*this[++i]+65536*this[++i]+this[++i]*2**24,d=this[++i]+256*this[++i]+65536*this[++i]+c*2**24;return BigInt(g)+(BigInt(d)<<BigInt(32))}),y.prototype.readBigUInt64BE=le(function(i){J(i>>>=0,"offset");const u=this[i],c=this[i+7];u!==void 0&&c!==void 0||_e(i,this.length-8);const g=u*2**24+65536*this[++i]+256*this[++i]+this[++i],d=this[++i]*2**24+65536*this[++i]+256*this[++i]+c;return(BigInt(g)<<BigInt(32))+BigInt(d)}),y.prototype.readIntLE=function(i,u,c){i>>>=0,u>>>=0,c||k(i,u,this.length);let g=this[i],d=1,o=0;for(;++o<u&&(d*=256);)g+=this[i+o]*d;return d*=128,g>=d&&(g-=Math.pow(2,8*u)),g},y.prototype.readIntBE=function(i,u,c){i>>>=0,u>>>=0,c||k(i,u,this.length);let g=u,d=1,o=this[i+--g];for(;g>0&&(d*=256);)o+=this[i+--g]*d;return d*=128,o>=d&&(o-=Math.pow(2,8*u)),o},y.prototype.readInt8=function(i,u){return i>>>=0,u||k(i,1,this.length),128&this[i]?-1*(255-this[i]+1):this[i]},y.prototype.readInt16LE=function(i,u){i>>>=0,u||k(i,2,this.length);const c=this[i]|this[i+1]<<8;return 32768&c?4294901760|c:c},y.prototype.readInt16BE=function(i,u){i>>>=0,u||k(i,2,this.length);const c=this[i+1]|this[i]<<8;return 32768&c?4294901760|c:c},y.prototype.readInt32LE=function(i,u){return i>>>=0,u||k(i,4,this.length),this[i]|this[i+1]<<8|this[i+2]<<16|this[i+3]<<24},y.prototype.readInt32BE=function(i,u){return i>>>=0,u||k(i,4,this.length),this[i]<<24|this[i+1]<<16|this[i+2]<<8|this[i+3]},y.prototype.readBigInt64LE=le(function(i){J(i>>>=0,"offset");const u=this[i],c=this[i+7];u!==void 0&&c!==void 0||_e(i,this.length-8);const g=this[i+4]+256*this[i+5]+65536*this[i+6]+(c<<24);return(BigInt(g)<<BigInt(32))+BigInt(u+256*this[++i]+65536*this[++i]+this[++i]*16777216)}),y.prototype.readBigInt64BE=le(function(i){J(i>>>=0,"offset");const u=this[i],c=this[i+7];u!==void 0&&c!==void 0||_e(i,this.length-8);const g=(u<<24)+65536*this[++i]+256*this[++i]+this[++i];return(BigInt(g)<<BigInt(32))+BigInt(this[++i]*16777216+65536*this[++i]+256*this[++i]+c)}),y.prototype.readFloatLE=function(i,u){return i>>>=0,u||k(i,4,this.length),m.read(this,i,!0,23,4)},y.prototype.readFloatBE=function(i,u){return i>>>=0,u||k(i,4,this.length),m.read(this,i,!1,23,4)},y.prototype.readDoubleLE=function(i,u){return i>>>=0,u||k(i,8,this.length),m.read(this,i,!0,52,8)},y.prototype.readDoubleBE=function(i,u){return i>>>=0,u||k(i,8,this.length),m.read(this,i,!1,52,8)},y.prototype.writeUintLE=y.prototype.writeUIntLE=function(i,u,c,g){i=+i,u>>>=0,c>>>=0,!g&&G(this,i,u,c,Math.pow(2,8*c)-1,0);let d=1,o=0;for(this[u]=255&i;++o<c&&(d*=256);)this[u+o]=i/d&255;return u+c},y.prototype.writeUintBE=y.prototype.writeUIntBE=function(i,u,c,g){i=+i,u>>>=0,c>>>=0,!g&&G(this,i,u,c,Math.pow(2,8*c)-1,0);let d=c-1,o=1;for(this[u+d]=255&i;--d>=0&&(o*=256);)this[u+d]=i/o&255;return u+c},y.prototype.writeUint8=y.prototype.writeUInt8=function(i,u,c){return i=+i,u>>>=0,c||G(this,i,u,1,255,0),this[u]=255&i,u+1},y.prototype.writeUint16LE=y.prototype.writeUInt16LE=function(i,u,c){return i=+i,u>>>=0,c||G(this,i,u,2,65535,0),this[u]=255&i,this[u+1]=i>>>8,u+2},y.prototype.writeUint16BE=y.prototype.writeUInt16BE=function(i,u,c){return i=+i,u>>>=0,c||G(this,i,u,2,65535,0),this[u]=i>>>8,this[u+1]=255&i,u+2},y.prototype.writeUint32LE=y.prototype.writeUInt32LE=function(i,u,c){return i=+i,u>>>=0,c||G(this,i,u,4,4294967295,0),this[u+3]=i>>>24,this[u+2]=i>>>16,this[u+1]=i>>>8,this[u]=255&i,u+4},y.prototype.writeUint32BE=y.prototype.writeUInt32BE=function(i,u,c){return i=+i,u>>>=0,c||G(this,i,u,4,4294967295,0),this[u]=i>>>24,this[u+1]=i>>>16,this[u+2]=i>>>8,this[u+3]=255&i,u+4},y.prototype.writeBigUInt64LE=le(function(i,u=0){return ct(this,i,u,BigInt(0),BigInt("0xffffffffffffffff"))}),y.prototype.writeBigUInt64BE=le(function(i,u=0){return $t(this,i,u,BigInt(0),BigInt("0xffffffffffffffff"))}),y.prototype.writeIntLE=function(i,u,c,g){if(i=+i,u>>>=0,!g){const w=Math.pow(2,8*c-1);G(this,i,u,c,w-1,-w)}let d=0,o=1,l=0;for(this[u]=255&i;++d<c&&(o*=256);)i<0&&l===0&&this[u+d-1]!==0&&(l=1),this[u+d]=(i/o>>0)-l&255;return u+c},y.prototype.writeIntBE=function(i,u,c,g){if(i=+i,u>>>=0,!g){const w=Math.pow(2,8*c-1);G(this,i,u,c,w-1,-w)}let d=c-1,o=1,l=0;for(this[u+d]=255&i;--d>=0&&(o*=256);)i<0&&l===0&&this[u+d+1]!==0&&(l=1),this[u+d]=(i/o>>0)-l&255;return u+c},y.prototype.writeInt8=function(i,u,c){return i=+i,u>>>=0,c||G(this,i,u,1,127,-128),i<0&&(i=255+i+1),this[u]=255&i,u+1},y.prototype.writeInt16LE=function(i,u,c){return i=+i,u>>>=0,c||G(this,i,u,2,32767,-32768),this[u]=255&i,this[u+1]=i>>>8,u+2},y.prototype.writeInt16BE=function(i,u,c){return i=+i,u>>>=0,c||G(this,i,u,2,32767,-32768),this[u]=i>>>8,this[u+1]=255&i,u+2},y.prototype.writeInt32LE=function(i,u,c){return i=+i,u>>>=0,c||G(this,i,u,4,2147483647,-2147483648),this[u]=255&i,this[u+1]=i>>>8,this[u+2]=i>>>16,this[u+3]=i>>>24,u+4},y.prototype.writeInt32BE=function(i,u,c){return i=+i,u>>>=0,c||G(this,i,u,4,2147483647,-2147483648),i<0&&(i=4294967295+i+1),this[u]=i>>>24,this[u+1]=i>>>16,this[u+2]=i>>>8,this[u+3]=255&i,u+4},y.prototype.writeBigInt64LE=le(function(i,u=0){return ct(this,i,u,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),y.prototype.writeBigInt64BE=le(function(i,u=0){return $t(this,i,u,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),y.prototype.writeFloatLE=function(i,u,c){return Pt(this,i,u,!0,c)},y.prototype.writeFloatBE=function(i,u,c){return Pt(this,i,u,!1,c)},y.prototype.writeDoubleLE=function(i,u,c){return yr(this,i,u,!0,c)},y.prototype.writeDoubleBE=function(i,u,c){return yr(this,i,u,!1,c)},y.prototype.copy=function(i,u,c,g){if(!y.isBuffer(i))throw new TypeError("argument should be a Buffer");if(c||(c=0),g||g===0||(g=this.length),u>=i.length&&(u=i.length),u||(u=0),g>0&&g<c&&(g=c),g===c||i.length===0||this.length===0)return 0;if(u<0)throw new RangeError("targetStart out of bounds");if(c<0||c>=this.length)throw new RangeError("Index out of range");if(g<0)throw new RangeError("sourceEnd out of bounds");g>this.length&&(g=this.length),i.length-u<g-c&&(g=i.length-u+c);const d=g-c;return this===i&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(u,c,g):Uint8Array.prototype.set.call(i,this.subarray(c,g),u),d},y.prototype.fill=function(i,u,c,g){if(typeof i=="string"){if(typeof u=="string"?(g=u,u=0,c=this.length):typeof c=="string"&&(g=c,c=this.length),g!==void 0&&typeof g!="string")throw new TypeError("encoding must be a string");if(typeof g=="string"&&!y.isEncoding(g))throw new TypeError("Unknown encoding: "+g);if(i.length===1){const o=i.charCodeAt(0);(g==="utf8"&&o<128||g==="latin1")&&(i=o)}}else typeof i=="number"?i&=255:typeof i=="boolean"&&(i=Number(i));if(u<0||this.length<u||this.length<c)throw new RangeError("Out of range index");if(c<=u)return this;let d;if(u>>>=0,c=c===void 0?this.length:c>>>0,i||(i=0),typeof i=="number")for(d=u;d<c;++d)this[d]=i;else{const o=y.isBuffer(i)?i:y.from(i,g),l=o.length;if(l===0)throw new TypeError('The value "'+i+'" is invalid for argument "value"');for(d=0;d<c-u;++d)this[d+u]=o[d%l]}return this};const Se={};function ft(i,u,c){Se[i]=class extends c{constructor(){super(),Object.defineProperty(this,"message",{value:u.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${i}]`,this.stack,delete this.name}get code(){return i}set code(g){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:g,writable:!0})}toString(){return`${this.name} [${i}]: ${this.message}`}}}function Ft(i){let u="",c=i.length;const g=i[0]==="-"?1:0;for(;c>=g+4;c-=3)u=`_${i.slice(c-3,c)}${u}`;return`${i.slice(0,c)}${u}`}function Ut(i,u,c,g,d,o){if(i>c||i<u){const l=typeof u=="bigint"?"n":"";let w;throw w=o>3?u===0||u===BigInt(0)?`>= 0${l} and < 2${l} ** ${8*(o+1)}${l}`:`>= -(2${l} ** ${8*(o+1)-1}${l}) and < 2 ** ${8*(o+1)-1}${l}`:`>= ${u}${l} and <= ${c}${l}`,new Se.ERR_OUT_OF_RANGE("value",w,i)}(function(l,w,A){J(w,"offset"),l[w]!==void 0&&l[w+A]!==void 0||_e(w,l.length-(A+1))})(g,d,o)}function J(i,u){if(typeof i!="number")throw new Se.ERR_INVALID_ARG_TYPE(u,"number",i)}function _e(i,u,c){throw Math.floor(i)!==i?(J(i,c),new Se.ERR_OUT_OF_RANGE(c||"offset","an integer",i)):u<0?new Se.ERR_BUFFER_OUT_OF_BOUNDS:new Se.ERR_OUT_OF_RANGE(c||"offset",`>= ${c?1:0} and <= ${u}`,i)}ft("ERR_BUFFER_OUT_OF_BOUNDS",function(i){return i?`${i} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),ft("ERR_INVALID_ARG_TYPE",function(i,u){return`The "${i}" argument must be of type number. Received type ${typeof u}`},TypeError),ft("ERR_OUT_OF_RANGE",function(i,u,c){let g=`The value of "${i}" is out of range.`,d=c;return Number.isInteger(c)&&Math.abs(c)>4294967296?d=Ft(String(c)):typeof c=="bigint"&&(d=String(c),(c>BigInt(2)**BigInt(32)||c<-(BigInt(2)**BigInt(32)))&&(d=Ft(d)),d+="n"),g+=` It must be ${u}. Received ${d}`,g},RangeError);const ee=/[^+/0-9A-Za-z-_]/g;function Fe(i,u){let c;u=u||1/0;const g=i.length;let d=null;const o=[];for(let l=0;l<g;++l){if(c=i.charCodeAt(l),c>55295&&c<57344){if(!d){if(c>56319){(u-=3)>-1&&o.push(239,191,189);continue}if(l+1===g){(u-=3)>-1&&o.push(239,191,189);continue}d=c;continue}if(c<56320){(u-=3)>-1&&o.push(239,191,189),d=c;continue}c=65536+(d-55296<<10|c-56320)}else d&&(u-=3)>-1&&o.push(239,191,189);if(d=null,c<128){if((u-=1)<0)break;o.push(c)}else if(c<2048){if((u-=2)<0)break;o.push(c>>6|192,63&c|128)}else if(c<65536){if((u-=3)<0)break;o.push(c>>12|224,c>>6&63|128,63&c|128)}else{if(!(c<1114112))throw new Error("Invalid code point");if((u-=4)<0)break;o.push(c>>18|240,c>>12&63|128,c>>6&63|128,63&c|128)}}return o}function gr(i){return h.toByteArray(function(u){if((u=(u=u.split("=")[0]).trim().replace(ee,"")).length<2)return"";for(;u.length%4!=0;)u+="=";return u}(i))}function Ie(i,u,c,g){let d;for(d=0;d<g&&!(d+c>=u.length||d>=i.length);++d)u[d+c]=i[d];return d}function fe(i,u){return i instanceof u||i!=null&&i.constructor!=null&&i.constructor.name!=null&&i.constructor.name===u.name}function lt(i){return i!=i}const En=function(){const i="0123456789abcdef",u=new Array(256);for(let c=0;c<16;++c){const g=16*c;for(let d=0;d<16;++d)u[g+d]=i[c]+i[d]}return u}();function le(i){return typeof BigInt>"u"?We:i}function We(){throw new Error("BigInt not supported")}},645:(s,f)=>{f.read=function(p,h,m,v,_){var b,y,x=8*_-v-1,I=(1<<x)-1,O=I>>1,S=-7,B=m?_-1:0,$=m?-1:1,R=p[h+B];for(B+=$,b=R&(1<<-S)-1,R>>=-S,S+=x;S>0;b=256*b+p[h+B],B+=$,S-=8);for(y=b&(1<<-S)-1,b>>=-S,S+=v;S>0;y=256*y+p[h+B],B+=$,S-=8);if(b===0)b=1-O;else{if(b===I)return y?NaN:1/0*(R?-1:1);y+=Math.pow(2,v),b-=O}return(R?-1:1)*y*Math.pow(2,b-v)},f.write=function(p,h,m,v,_,b){var y,x,I,O=8*b-_-1,S=(1<<O)-1,B=S>>1,$=_===23?Math.pow(2,-24)-Math.pow(2,-77):0,R=v?0:b-1,D=v?1:-1,M=h<0||h===0&&1/h<0?1:0;for(h=Math.abs(h),isNaN(h)||h===1/0?(x=isNaN(h)?1:0,y=S):(y=Math.floor(Math.log(h)/Math.LN2),h*(I=Math.pow(2,-y))<1&&(y--,I*=2),(h+=y+B>=1?$/I:$*Math.pow(2,1-B))*I>=2&&(y++,I/=2),y+B>=S?(x=0,y=S):y+B>=1?(x=(h*I-1)*Math.pow(2,_),y+=B):(x=h*Math.pow(2,B-1)*Math.pow(2,_),y=0));_>=8;p[m+R]=255&x,R+=D,x/=256,_-=8);for(y=y<<_|x,O+=_;O>0;p[m+R]=255&y,R+=D,y/=256,O-=8);p[m+R-D]|=128*M}}},n={};function a(s){var f=n[s];if(f!==void 0)return f.exports;var p=n[s]={exports:{}};return r[s](p,p.exports,a),p.exports}return a.d=(s,f)=>{for(var p in f)a.o(f,p)&&!a.o(s,p)&&Object.defineProperty(s,p,{enumerable:!0,get:f[p]})},a.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),a.o=(s,f)=>Object.prototype.hasOwnProperty.call(s,f),a.r=s=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(s,"__esModule",{value:!0})},a(899)})())})(vo);function wl(t){const e={variantId:xe.Uint64.fromString(t.variantId.toString()),version:t.version||Math.floor(Date.now()/1e3),items:t.items.map(n=>new xe.BundleItem({collectionId:xe.Uint64.fromString(n.collectionId.toString()),productId:xe.Uint64.fromString(n.productId.toString()),variantId:xe.Uint64.fromString(n.variantId.toString()),sku:n.sku||"",quantity:n.quantity,ext:new xe.BundleItemExt(0)})),ext:new xe.BundleExt(0)},r=new xe.Bundle(e);return xe.BundleEnvelope.envelopeTypeBundle(r).toXDR("base64")}const xe=vo.exports.config(t=>{t.enum("EnvelopeType",{envelopeTypeBundle:0}),t.typedef("Uint32",t.uint()),t.typedef("Uint64",t.uhyper()),t.union("BundleItemExt",{switchOn:t.int(),switchName:"v",switches:[[0,t.void()]],arms:{}}),t.struct("BundleItem",[["collectionId",t.lookup("Uint64")],["productId",t.lookup("Uint64")],["variantId",t.lookup("Uint64")],["sku",t.string()],["quantity",t.lookup("Uint32")],["ext",t.lookup("BundleItemExt")]]),t.union("BundleExt",{switchOn:t.int(),switchName:"v",switches:[[0,t.void()]],arms:{}}),t.struct("Bundle",[["variantId",t.lookup("Uint64")],["items",t.varArray(t.lookup("BundleItem"),500)],["version",t.lookup("Uint32")],["ext",t.lookup("BundleExt")]]),t.union("BundleEnvelope",{switchOn:t.lookup("EnvelopeType"),switchName:"type",switches:[["envelopeTypeBundle","v1"]],arms:{v1:t.lookup("Bundle")}})}),_o="/bundling-storefront-manager";function vl(){return Math.ceil(Date.now()/1e3)}async function _l(){try{const{timestamp:t}=await xt("get",`${_o}/t`,{headers:{"X-Recharge-App":"storefront-client"}});return t}catch(t){return console.error(`Fetch failed: ${t}. Using client-side date.`),vl()}}async function bl(t){const e=ve(),r=await bo(t);if(r!==!0)throw new Error(r);const n=await _l(),a=wl({variantId:t.externalVariantId,version:n,items:t.selections.map(s=>({collectionId:s.collectionId,productId:s.externalProductId,variantId:s.externalVariantId,quantity:s.quantity,sku:""}))});try{const s=await xt("post",`${_o}/api/v1/bundles`,{data:{bundle:a},headers:{Origin:`https://${e.storeIdentifier}`}});if(!s.id||s.code!==200)throw new Error(`1: failed generating rb_id: ${JSON.stringify(s)}`);return s.id}catch(s){throw new Error(`2: failed generating rb_id ${s}`)}}function El(t,e){const r=Eo(t);if(r!==!0)throw new Error(`Dynamic Bundle is invalid. ${r}`);const n=`${Uc(9)}:${t.externalProductId}`;return t.selections.map(a=>{const s={id:a.externalVariantId,quantity:a.quantity,properties:{_rc_bundle:n,_rc_bundle_variant:t.externalVariantId,_rc_bundle_parent:e,_rc_bundle_collection_id:a.collectionId}};return a.sellingPlan?s.selling_plan=a.sellingPlan:a.shippingIntervalFrequency&&(s.properties.shipping_interval_frequency=a.shippingIntervalFrequency,s.properties.shipping_interval_unit_type=a.shippingIntervalUnitType,s.id=`${a.discountedVariantId}`),s})}async function bo(t){try{return t?await mo(t.externalProductId)?!0:"Bundle settings do not exist for the given product":"Bundle is not defined"}catch(e){return`Error fetching bundle settings: ${e}`}}const Al={day:["day","days","Days"],days:["day","days","Days"],Days:["day","days","Days"],week:["week","weeks","Weeks"],weeks:["week","weeks","Weeks"],Weeks:["week","weeks","Weeks"],month:["month","months","Months"],months:["month","months","Months"],Months:["month","months","Months"]};function Eo(t){if(!t)return"No bundle defined.";if(t.selections.length===0)return"No selections defined.";const{shippingIntervalFrequency:e,shippingIntervalUnitType:r}=t.selections.find(n=>n.shippingIntervalFrequency||n.shippingIntervalUnitType)||{};if(e||r){if(!e||!r)return"Shipping intervals do not match on selections.";{const n=Al[r];for(let a=0;a<t.selections.length;a++){const{shippingIntervalFrequency:s,shippingIntervalUnitType:f}=t.selections[a];if(s&&s!==e||f&&!n.includes(f))return"Shipping intervals do not match on selections."}}}return!0}async function xl(t,e){const{bundle_selection:r}=await T("get","/bundle_selections",{id:e},t);return r}function Sl(t,e){return T("get","/bundle_selections",{query:e},t)}async function Il(t,e){const{bundle_selection:r}=await T("post","/bundle_selections",{data:e},t);return r}async function Bl(t,e,r){const{bundle_selection:n}=await T("put","/bundle_selections",{id:e,data:r},t);return n}function Ol(t,e){return T("delete","/bundle_selections",{id:e},t)}async function Tl(t,e,r){const{subscription:n}=await T("put","/bundles",{id:e,data:r},t);return n}var Rl=Object.freeze({__proto__:null,getBundleId:bl,getDynamicBundleItems:El,validateBundle:bo,validateDynamicBundle:Eo,getBundleSelection:xl,listBundleSelections:Sl,createBundleSelection:Il,updateBundleSelection:Bl,deleteBundleSelection:Ol,updateBundle:Tl});async function $l(t,e,r){const{charge:n}=await T("get","/charges",{id:e,query:{include:r?.include}},t);return n}function Pl(t,e){return T("get","/charges",{query:e},t)}async function Fl(t,e,r){const{charge:n}=await T("post",`/charges/${e}/apply_discount`,{data:{discount_code:r}},t);return n}async function Ul(t,e){const{charge:r}=await T("post",`/charges/${e}/remove_discount`,{},t);return r}async function Cl(t,e,r){const{charge:n}=await T("post",`/charges/${e}/skip`,{data:{purchase_item_ids:r.map(a=>Number(a))}},t);return n}async function Dl(t,e,r){const{charge:n}=await T("post",`/charges/${e}/unskip`,{data:{purchase_item_ids:r.map(a=>Number(a))}},t);return n}async function Nl(t,e){const{charge:r}=await T("post",`/charges/${e}/process`,{},t);return r}var Ml=Object.freeze({__proto__:null,getCharge:$l,listCharges:Pl,applyDiscountToCharge:Fl,removeDiscountsFromCharge:Ul,skipCharge:Cl,unskipCharge:Dl,processCharge:Nl});async function Ll(t,e){const{membership:r}=await T("get","/memberships",{id:e},t);return r}function kl(t,e){return T("get","/memberships",{query:e},t)}async function jl(t,e,r){const{membership:n}=await T("post",`/memberships/${e}/cancel`,{data:r},t);return n}async function ql(t,e,r){const{membership:n}=await T("post",`/memberships/${e}/activate`,{data:r},t);return n}async function Vl(t,e,r){const{membership:n}=await T("post",`/memberships/${e}/change`,{data:r},t);return n}var zl=Object.freeze({__proto__:null,getMembership:Ll,listMemberships:kl,cancelMembership:jl,activateMembership:ql,changeMembership:Vl});async function Gl(t,e,r){const{membership_program:n}=await T("get","/membership_programs",{id:e,query:{include:r?.include}},t);return n}function Wl(t,e){return T("get","/membership_programs",{query:e},t)}var Hl=Object.freeze({__proto__:null,getMembershipProgram:Gl,listMembershipPrograms:Wl});async function Yl(t,e){const{metafield:r}=await T("post","/metafields",{data:{metafield:e}},t);return r}async function Xl(t,e,r){const{metafield:n}=await T("put","/metafields",{id:e,data:{metafield:r}},t);return n}function Jl(t,e){return T("delete","/metafields",{id:e},t)}var Kl=Object.freeze({__proto__:null,createMetafield:Yl,updateMetafield:Xl,deleteMetafield:Jl});async function Ql(t,e){const{onetime:r}=await T("get","/onetimes",{id:e},t);return r}function Zl(t,e){return T("get","/onetimes",{query:e},t)}async function ep(t,e){const{onetime:r}=await T("post","/onetimes",{data:e},t);return r}async function tp(t,e,r){const{onetime:n}=await T("put","/onetimes",{id:e,data:r},t);return n}function rp(t,e){return T("delete","/onetimes",{id:e},t)}var np=Object.freeze({__proto__:null,getOnetime:Ql,listOnetimes:Zl,createOnetime:ep,updateOnetime:tp,deleteOnetime:rp});async function ip(t,e){const{order:r}=await T("get","/orders",{id:e},t);return r}function op(t,e){return T("get","/orders",{query:e},t)}var ap=Object.freeze({__proto__:null,getOrder:ip,listOrders:op});async function sp(t,e,r){const{payment_method:n}=await T("get","/payment_methods",{id:e,query:{include:r?.include}},t);return n}async function up(t,e,r){const{payment_method:n}=await T("put","/payment_methods",{id:e,data:r},t);return n}function cp(t,e){return T("get","/payment_methods",{query:e},t)}var fp=Object.freeze({__proto__:null,getPaymentMethod:sp,updatePaymentMethod:up,listPaymentMethods:cp});async function lp(t,e){const{plan:r}=await T("get","/plans",{id:e},t);return r}function pp(t,e){return T("get","/plans",{query:e},t)}var hp=Object.freeze({__proto__:null,getPlan:lp,listPlans:pp}),dp="Expected a function",Ao="__lodash_placeholder__",ze=1,pr=2,yp=4,ot=8,Bt=16,Ge=32,Ot=64,xo=128,gp=256,So=512,Io=1/0,mp=9007199254740991,wp=17976931348623157e292,Bo=0/0,vp=[["ary",xo],["bind",ze],["bindKey",pr],["curry",ot],["curryRight",Bt],["flip",So],["partial",Ge],["partialRight",Ot],["rearg",gp]],_p="[object Function]",bp="[object GeneratorFunction]",Ep="[object Symbol]",Ap=/[\\^$.*+?()[\]{}|]/g,xp=/^\s+|\s+$/g,Sp=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Ip=/\{\n\/\* \[wrapped with (.+)\] \*/,Bp=/,? & /,Op=/^[-+]0x[0-9a-f]+$/i,Tp=/^0b[01]+$/i,Rp=/^\[object .+?Constructor\]$/,$p=/^0o[0-7]+$/i,Pp=/^(?:0|[1-9]\d*)$/,Fp=parseInt,Up=typeof oe=="object"&&oe&&oe.Object===Object&&oe,Cp=typeof self=="object"&&self&&self.Object===Object&&self,Tt=Up||Cp||Function("return this")();function gn(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}function Dp(t,e){for(var r=-1,n=t?t.length:0;++r<n&&e(t[r],r,t)!==!1;);return t}function Np(t,e){var r=t?t.length:0;return!!r&&Lp(t,e,0)>-1}function Mp(t,e,r,n){for(var a=t.length,s=r+(n?1:-1);n?s--:++s<a;)if(e(t[s],s,t))return s;return-1}function Lp(t,e,r){if(e!==e)return Mp(t,kp,r);for(var n=r-1,a=t.length;++n<a;)if(t[n]===e)return n;return-1}function kp(t){return t!==t}function jp(t,e){for(var r=t.length,n=0;r--;)t[r]===e&&n++;return n}function qp(t,e){return t?.[e]}function Vp(t){var e=!1;if(t!=null&&typeof t.toString!="function")try{e=!!(t+"")}catch{}return e}function mn(t,e){for(var r=-1,n=t.length,a=0,s=[];++r<n;){var f=t[r];(f===e||f===Ao)&&(t[r]=Ao,s[a++]=r)}return s}var zp=Function.prototype,Oo=Object.prototype,wn=Tt["__core-js_shared__"],To=function(){var t=/[^.]+$/.exec(wn&&wn.keys&&wn.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),Ro=zp.toString,Gp=Oo.hasOwnProperty,$o=Oo.toString,Wp=RegExp("^"+Ro.call(Gp).replace(Ap,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Hp=Object.create,at=Math.max,Yp=Math.min,Po=function(){var t=Uo(Object,"defineProperty"),e=Uo.name;return e&&e.length>2?t:void 0}();function Xp(t){return st(t)?Hp(t):{}}function Jp(t){if(!st(t)||uh(t))return!1;var e=ph(t)||Vp(t)?Wp:Rp;return e.test(fh(t))}function Kp(t,e){return e=at(e===void 0?t.length-1:e,0),function(){for(var r=arguments,n=-1,a=at(r.length-e,0),s=Array(a);++n<a;)s[n]=r[e+n];n=-1;for(var f=Array(e+1);++n<e;)f[n]=r[n];return f[e]=s,gn(t,this,f)}}function Qp(t,e,r,n){for(var a=-1,s=t.length,f=r.length,p=-1,h=e.length,m=at(s-f,0),v=Array(h+m),_=!n;++p<h;)v[p]=e[p];for(;++a<f;)(_||a<s)&&(v[r[a]]=t[a]);for(;m--;)v[p++]=t[a++];return v}function Zp(t,e,r,n){for(var a=-1,s=t.length,f=-1,p=r.length,h=-1,m=e.length,v=at(s-p,0),_=Array(v+m),b=!n;++a<v;)_[a]=t[a];for(var y=a;++h<m;)_[y+h]=e[h];for(;++f<p;)(b||a<s)&&(_[y+r[f]]=t[a++]);return _}function eh(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}function th(t,e,r){var n=e&ze,a=Rt(t);function s(){var f=this&&this!==Tt&&this instanceof s?a:t;return f.apply(n?r:this,arguments)}return s}function Rt(t){return function(){var e=arguments;switch(e.length){case 0:return new t;case 1:return new t(e[0]);case 2:return new t(e[0],e[1]);case 3:return new t(e[0],e[1],e[2]);case 4:return new t(e[0],e[1],e[2],e[3]);case 5:return new t(e[0],e[1],e[2],e[3],e[4]);case 6:return new t(e[0],e[1],e[2],e[3],e[4],e[5]);case 7:return new t(e[0],e[1],e[2],e[3],e[4],e[5],e[6])}var r=Xp(t.prototype),n=t.apply(r,e);return st(n)?n:r}}function rh(t,e,r){var n=Rt(t);function a(){for(var s=arguments.length,f=Array(s),p=s,h=_n(a);p--;)f[p]=arguments[p];var m=s<3&&f[0]!==h&&f[s-1]!==h?[]:mn(f,h);if(s-=m.length,s<r)return Fo(t,e,vn,a.placeholder,void 0,f,m,void 0,void 0,r-s);var v=this&&this!==Tt&&this instanceof a?n:t;return gn(v,this,f)}return a}function vn(t,e,r,n,a,s,f,p,h,m){var v=e&xo,_=e&ze,b=e&pr,y=e&(ot|Bt),x=e&So,I=b?void 0:Rt(t);function O(){for(var S=arguments.length,B=Array(S),$=S;$--;)B[$]=arguments[$];if(y)var R=_n(O),D=jp(B,R);if(n&&(B=Qp(B,n,a,y)),s&&(B=Zp(B,s,f,y)),S-=D,y&&S<m){var M=mn(B,R);return Fo(t,e,vn,O.placeholder,r,B,M,p,h,m-S)}var q=_?r:this,V=b?q[t]:t;return S=B.length,p?B=ch(B,p):x&&S>1&&B.reverse(),v&&h<S&&(B.length=h),this&&this!==Tt&&this instanceof O&&(V=I||Rt(V)),V.apply(q,B)}return O}function nh(t,e,r,n){var a=e&ze,s=Rt(t);function f(){for(var p=-1,h=arguments.length,m=-1,v=n.length,_=Array(v+h),b=this&&this!==Tt&&this instanceof f?s:t;++m<v;)_[m]=n[m];for(;h--;)_[m++]=arguments[++p];return gn(b,a?r:this,_)}return f}function Fo(t,e,r,n,a,s,f,p,h,m){var v=e&ot,_=v?f:void 0,b=v?void 0:f,y=v?s:void 0,x=v?void 0:s;e|=v?Ge:Ot,e&=~(v?Ot:Ge),e&yp||(e&=~(ze|pr));var I=r(t,e,a,y,_,x,b,p,h,m);return I.placeholder=n,Co(I,t,e)}function ih(t,e,r,n,a,s,f,p){var h=e&pr;if(!h&&typeof t!="function")throw new TypeError(dp);var m=n?n.length:0;if(m||(e&=~(Ge|Ot),n=a=void 0),f=f===void 0?f:at(Do(f),0),p=p===void 0?p:Do(p),m-=a?a.length:0,e&Ot){var v=n,_=a;n=a=void 0}var b=[t,e,r,n,a,v,_,s,f,p];if(t=b[0],e=b[1],r=b[2],n=b[3],a=b[4],p=b[9]=b[9]==null?h?0:t.length:at(b[9]-m,0),!p&&e&(ot|Bt)&&(e&=~(ot|Bt)),!e||e==ze)var y=th(t,e,r);else e==ot||e==Bt?y=rh(t,e,p):(e==Ge||e==(ze|Ge))&&!a.length?y=nh(t,e,r,n):y=vn.apply(void 0,b);return Co(y,t,e)}function _n(t){var e=t;return e.placeholder}function Uo(t,e){var r=qp(t,e);return Jp(r)?r:void 0}function oh(t){var e=t.match(Ip);return e?e[1].split(Bp):[]}function ah(t,e){var r=e.length,n=r-1;return e[n]=(r>1?"& ":"")+e[n],e=e.join(r>2?", ":" "),t.replace(Sp,`{
20
+ `+e.prev}function Zt(t,e){var r=Xr(t),n=[];if(r){n.length=t.length;for(var a=0;a<t.length;a++)n[a]=Re(t,a)?e(t[a],t):""}var s=typeof Wr=="function"?Wr(t):[],f;if(et){f={};for(var p=0;p<s.length;p++)f["$"+s[p]]=s[p]}for(var h in t)Re(t,h)&&(r&&String(Number(h))===h&&h<t.length||et&&f["$"+h]instanceof Symbol||(yi.call(/[^\w$]/,h)?n.push(e(h,t)+": "+e(t[h],t)):n.push(h+": "+e(t[h],t))));if(typeof Wr=="function")for(var m=0;m<s.length;m++)wi.call(t,s[m])&&n.push("["+e(s[m])+"]: "+e(t[s[m]],t));return n}var Qr=Sr,tt=Ia,wu=Zs,vu=Qr("%TypeError%"),er=Qr("%WeakMap%",!0),tr=Qr("%Map%",!0),_u=tt("WeakMap.prototype.get",!0),bu=tt("WeakMap.prototype.set",!0),Eu=tt("WeakMap.prototype.has",!0),Au=tt("Map.prototype.get",!0),xu=tt("Map.prototype.set",!0),Su=tt("Map.prototype.has",!0),Zr=function(t,e){for(var r=t,n;(n=r.next)!==null;r=n)if(n.key===e)return r.next=n.next,n.next=t.next,t.next=n,n},Iu=function(t,e){var r=Zr(t,e);return r&&r.value},Bu=function(t,e,r){var n=Zr(t,e);n?n.value=r:t.next={key:e,next:t.next,value:r}},Ou=function(t,e){return!!Zr(t,e)},Tu=function(){var e,r,n,a={assert:function(s){if(!a.has(s))throw new vu("Side channel does not contain "+wu(s))},get:function(s){if(er&&s&&(typeof s=="object"||typeof s=="function")){if(e)return _u(e,s)}else if(tr){if(r)return Au(r,s)}else if(n)return Iu(n,s)},has:function(s){if(er&&s&&(typeof s=="object"||typeof s=="function")){if(e)return Eu(e,s)}else if(tr){if(r)return Su(r,s)}else if(n)return Ou(n,s);return!1},set:function(s,f){er&&s&&(typeof s=="object"||typeof s=="function")?(e||(e=new er),bu(e,s,f)):tr?(r||(r=new tr),xu(r,s,f)):(n||(n={key:{},next:null}),Bu(n,s,f))}};return a},Ru=String.prototype.replace,$u=/%20/g,en={RFC1738:"RFC1738",RFC3986:"RFC3986"},Ti={default:en.RFC3986,formatters:{RFC1738:function(t){return Ru.call(t,$u,"+")},RFC3986:function(t){return String(t)}},RFC1738:en.RFC1738,RFC3986:en.RFC3986},Pu=Ti,tn=Object.prototype.hasOwnProperty,qe=Array.isArray,we=function(){for(var t=[],e=0;e<256;++e)t.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return t}(),Fu=function(e){for(;e.length>1;){var r=e.pop(),n=r.obj[r.prop];if(qe(n)){for(var a=[],s=0;s<n.length;++s)typeof n[s]<"u"&&a.push(n[s]);r.obj[r.prop]=a}}},Ri=function(e,r){for(var n=r&&r.plainObjects?Object.create(null):{},a=0;a<e.length;++a)typeof e[a]<"u"&&(n[a]=e[a]);return n},Uu=function t(e,r,n){if(!r)return e;if(typeof r!="object"){if(qe(e))e.push(r);else if(e&&typeof e=="object")(n&&(n.plainObjects||n.allowPrototypes)||!tn.call(Object.prototype,r))&&(e[r]=!0);else return[e,r];return e}if(!e||typeof e!="object")return[e].concat(r);var a=e;return qe(e)&&!qe(r)&&(a=Ri(e,n)),qe(e)&&qe(r)?(r.forEach(function(s,f){if(tn.call(e,f)){var p=e[f];p&&typeof p=="object"&&s&&typeof s=="object"?e[f]=t(p,s,n):e.push(s)}else e[f]=s}),e):Object.keys(r).reduce(function(s,f){var p=r[f];return tn.call(s,f)?s[f]=t(s[f],p,n):s[f]=p,s},a)},Cu=function(e,r){return Object.keys(r).reduce(function(n,a){return n[a]=r[a],n},e)},Du=function(t,e,r){var n=t.replace(/\+/g," ");if(r==="iso-8859-1")return n.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(n)}catch{return n}},Nu=function(e,r,n,a,s){if(e.length===0)return e;var f=e;if(typeof e=="symbol"?f=Symbol.prototype.toString.call(e):typeof e!="string"&&(f=String(e)),n==="iso-8859-1")return escape(f).replace(/%u[0-9a-f]{4}/gi,function(v){return"%26%23"+parseInt(v.slice(2),16)+"%3B"});for(var p="",h=0;h<f.length;++h){var m=f.charCodeAt(h);if(m===45||m===46||m===95||m===126||m>=48&&m<=57||m>=65&&m<=90||m>=97&&m<=122||s===Pu.RFC1738&&(m===40||m===41)){p+=f.charAt(h);continue}if(m<128){p=p+we[m];continue}if(m<2048){p=p+(we[192|m>>6]+we[128|m&63]);continue}if(m<55296||m>=57344){p=p+(we[224|m>>12]+we[128|m>>6&63]+we[128|m&63]);continue}h+=1,m=65536+((m&1023)<<10|f.charCodeAt(h)&1023),p+=we[240|m>>18]+we[128|m>>12&63]+we[128|m>>6&63]+we[128|m&63]}return p},Mu=function(e){for(var r=[{obj:{o:e},prop:"o"}],n=[],a=0;a<r.length;++a)for(var s=r[a],f=s.obj[s.prop],p=Object.keys(f),h=0;h<p.length;++h){var m=p[h],v=f[m];typeof v=="object"&&v!==null&&n.indexOf(v)===-1&&(r.push({obj:f,prop:m}),n.push(v))}return Fu(r),e},Lu=function(e){return Object.prototype.toString.call(e)==="[object RegExp]"},ku=function(e){return!e||typeof e!="object"?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},ju=function(e,r){return[].concat(e,r)},qu=function(e,r){if(qe(e)){for(var n=[],a=0;a<e.length;a+=1)n.push(r(e[a]));return n}return r(e)},Vu={arrayToObject:Ri,assign:Cu,combine:ju,compact:Mu,decode:Du,encode:Nu,isBuffer:ku,isRegExp:Lu,maybeMap:qu,merge:Uu},$i=Tu,rn=Vu,At=Ti,zu=Object.prototype.hasOwnProperty,Pi={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,r){return e+"["+r+"]"},repeat:function(e){return e}},Ae=Array.isArray,Gu=String.prototype.split,Wu=Array.prototype.push,Fi=function(t,e){Wu.apply(t,Ae(e)?e:[e])},Hu=Date.prototype.toISOString,Ui=At.default,X={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:rn.encode,encodeValuesOnly:!1,format:Ui,formatter:At.formatters[Ui],indices:!1,serializeDate:function(e){return Hu.call(e)},skipNulls:!1,strictNullHandling:!1},Yu=function(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="symbol"||typeof e=="bigint"},nn={},Xu=function t(e,r,n,a,s,f,p,h,m,v,_,b,y,x,I,O){for(var S=e,B=O,$=0,R=!1;(B=B.get(nn))!==void 0&&!R;){var D=B.get(e);if($+=1,typeof D<"u"){if(D===$)throw new RangeError("Cyclic object value");R=!0}typeof B.get(nn)>"u"&&($=0)}if(typeof h=="function"?S=h(r,S):S instanceof Date?S=_(S):n==="comma"&&Ae(S)&&(S=rn.maybeMap(S,function(Pe){return Pe instanceof Date?_(Pe):Pe})),S===null){if(s)return p&&!x?p(r,X.encoder,I,"key",b):r;S=""}if(Yu(S)||rn.isBuffer(S)){if(p){var M=x?r:p(r,X.encoder,I,"key",b);if(n==="comma"&&x){for(var q=Gu.call(String(S),","),V="",Y=0;Y<q.length;++Y)V+=(Y===0?"":",")+y(p(q[Y],X.encoder,I,"value",b));return[y(M)+(a&&Ae(S)&&q.length===1?"[]":"")+"="+V]}return[y(M)+"="+y(p(S,X.encoder,I,"value",b))]}return[y(r)+"="+y(String(S))]}var z=[];if(typeof S>"u")return z;var ne;if(n==="comma"&&Ae(S))ne=[{value:S.length>0?S.join(",")||null:void 0}];else if(Ae(h))ne=h;else{var ae=Object.keys(S);ne=m?ae.sort(m):ae}for(var L=a&&Ae(S)&&S.length===1?r+"[]":r,Z=0;Z<ne.length;++Z){var N=ne[Z],se=typeof N=="object"&&typeof N.value<"u"?N.value:S[N];if(!(f&&se===null)){var ut=Ae(S)?typeof n=="function"?n(L,N):L:L+(v?"."+N:"["+N+"]");O.set(e,$);var ie=$i();ie.set(nn,O),Fi(z,t(se,ut,n,a,s,f,p,h,m,v,_,b,y,x,I,ie))}}return z},Ju=function(e){if(!e)return X;if(e.encoder!==null&&typeof e.encoder<"u"&&typeof e.encoder!="function")throw new TypeError("Encoder has to be a function.");var r=e.charset||X.charset;if(typeof e.charset<"u"&&e.charset!=="utf-8"&&e.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=At.default;if(typeof e.format<"u"){if(!zu.call(At.formatters,e.format))throw new TypeError("Unknown format option provided.");n=e.format}var a=At.formatters[n],s=X.filter;return(typeof e.filter=="function"||Ae(e.filter))&&(s=e.filter),{addQueryPrefix:typeof e.addQueryPrefix=="boolean"?e.addQueryPrefix:X.addQueryPrefix,allowDots:typeof e.allowDots>"u"?X.allowDots:!!e.allowDots,charset:r,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:X.charsetSentinel,delimiter:typeof e.delimiter>"u"?X.delimiter:e.delimiter,encode:typeof e.encode=="boolean"?e.encode:X.encode,encoder:typeof e.encoder=="function"?e.encoder:X.encoder,encodeValuesOnly:typeof e.encodeValuesOnly=="boolean"?e.encodeValuesOnly:X.encodeValuesOnly,filter:s,format:n,formatter:a,serializeDate:typeof e.serializeDate=="function"?e.serializeDate:X.serializeDate,skipNulls:typeof e.skipNulls=="boolean"?e.skipNulls:X.skipNulls,sort:typeof e.sort=="function"?e.sort:null,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:X.strictNullHandling}},Ku=function(t,e){var r=t,n=Ju(e),a,s;typeof n.filter=="function"?(s=n.filter,r=s("",r)):Ae(n.filter)&&(s=n.filter,a=s);var f=[];if(typeof r!="object"||r===null)return"";var p;e&&e.arrayFormat in Pi?p=e.arrayFormat:e&&"indices"in e?p=e.indices?"indices":"repeat":p="indices";var h=Pi[p];if(e&&"commaRoundTrip"in e&&typeof e.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var m=h==="comma"&&e&&e.commaRoundTrip;a||(a=Object.keys(r)),n.sort&&a.sort(n.sort);for(var v=$i(),_=0;_<a.length;++_){var b=a[_];n.skipNulls&&r[b]===null||Fi(f,Xu(r[b],b,h,m,n.strictNullHandling,n.skipNulls,n.encode?n.encoder:null,n.filter,n.sort,n.allowDots,n.serializeDate,n.format,n.formatter,n.encodeValuesOnly,n.charset,v))}var y=f.join(n.delimiter),x=n.addQueryPrefix===!0?"?":"";return n.charsetSentinel&&(n.charset==="iso-8859-1"?x+="utf8=%26%2310003%3B&":x+="utf8=%E2%9C%93&"),y.length>0?x+y:""};let Ci={storeIdentifier:"",environment:"prod"};function Qu(t){Ci=t}function ve(){return Ci}const Zu=t=>t==="stage"?"https://api.stage.rechargeapps.com":"https://api.rechargeapps.com",rr=t=>t==="stage"?"https://admin.stage.rechargeapps.com":"https://admin.rechargeapps.com",ec=t=>t==="stage"?"https://static.stage.rechargecdn.com":"https://static.rechargecdn.com",tc="/tools/recurring";class nr{constructor(e,r){this.name="RechargeRequestError",this.message=e,this.status=r}}var rc=Object.defineProperty,nc=Object.defineProperties,ic=Object.getOwnPropertyDescriptors,Di=Object.getOwnPropertySymbols,oc=Object.prototype.hasOwnProperty,ac=Object.prototype.propertyIsEnumerable,Ni=(t,e,r)=>e in t?rc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ir=(t,e)=>{for(var r in e||(e={}))oc.call(e,r)&&Ni(t,r,e[r]);if(Di)for(var r of Di(e))ac.call(e,r)&&Ni(t,r,e[r]);return t},sc=(t,e)=>nc(t,ic(e));function uc(t){return Ku(t,{encode:!1,indices:!1,arrayFormat:"comma"})}async function or(t,e,r={}){const n=ve();return ce(t,`${ec(n.environment)}/store/${n.storeIdentifier}${e}`,r)}async function T(t,e,{id:r,query:n,data:a,headers:s}={},f){const{environment:p,storeIdentifier:h,loginRetryFn:m}=ve(),v=f.apiToken,_=Zu(p),b=ir({"X-Recharge-Access-Token":v,"X-Recharge-Version":"2021-11"},s||{}),y=ir({shop_url:h},n);try{return await ce(t,`${_}${e}`,{id:r,query:y,data:a,headers:b})}catch(x){if(m&&x instanceof nr&&x.status===401)return m().then(I=>{if(I)return ce(t,`${_}${e}`,{id:r,query:y,data:a,headers:sc(ir({},b),{"X-Recharge-Access-Token":I.apiToken})});throw x});throw x}}async function xt(t,e,r={}){return ce(t,`${tc}${e}`,r)}async function ce(t,e,{id:r,query:n,data:a,headers:s}={}){let f=e.trim();if(r&&(f=[f,`${r}`.trim()].join("/")),n){let _;[f,_]=f.split("?");const b=[_,uc(n)].join("&").replace(/^&/,"");f=`${f}${b?`?${b}`:""}`}let p;a&&t!=="get"&&(p=JSON.stringify(a));const h=ir({Accept:"application/json","Content-Type":"application/json","X-Recharge-App":"storefront-client"},s||{}),m=await fetch(f,{method:t,headers:h,body:p});let v;try{v=await m.json()}catch{}if(!m.ok)throw v&&v.error?new nr(v.error,m.status):v&&v.errors?new nr(JSON.stringify(v.errors),m.status):new nr("A connection error occurred while making the request");return v}var cc=Object.defineProperty,Mi=Object.getOwnPropertySymbols,fc=Object.prototype.hasOwnProperty,lc=Object.prototype.propertyIsEnumerable,Li=(t,e,r)=>e in t?cc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,pc=(t,e)=>{for(var r in e||(e={}))fc.call(e,r)&&Li(t,r,e[r]);if(Mi)for(var r of Mi(e))lc.call(e,r)&&Li(t,r,e[r]);return t};function hc(t,e){return T("get","/addresses",{query:e},t)}async function dc(t,e,r){const{address:n}=await T("get","/addresses",{id:e,query:{include:r?.include}},t);return n}async function yc(t,e){const{address:r}=await T("post","/addresses",{data:pc({customer_id:t.customerId?Number(t.customerId):void 0},e)},t);return r}async function on(t,e,r){const{address:n}=await T("put","/addresses",{id:e,data:r},t);return n}async function gc(t,e,r){return on(t,e,{discounts:[{code:r}]})}async function mc(t,e){return on(t,e,{discounts:[]})}function wc(t,e){return T("delete","/addresses",{id:e},t)}async function vc(t,e){const{address:r}=await T("post","/addresses/merge",{data:e},t);return r}async function _c(t,e,r){const{charge:n}=await T("post",`/addresses/${e}/charges/skip`,{data:r},t);return n}var bc=Object.freeze({__proto__:null,listAddresses:hc,getAddress:dc,createAddress:yc,updateAddress:on,applyDiscountToAddress:gc,removeDiscountsFromAddress:mc,deleteAddress:wc,mergeAddresses:vc,skipFutureCharge:_c}),Ec=Object.defineProperty,ki=Object.getOwnPropertySymbols,Ac=Object.prototype.hasOwnProperty,xc=Object.prototype.propertyIsEnumerable,ji=(t,e,r)=>e in t?Ec(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,qi=(t,e)=>{for(var r in e||(e={}))Ac.call(e,r)&&ji(t,r,e[r]);if(ki)for(var r of ki(e))xc.call(e,r)&&ji(t,r,e[r]);return t};async function Sc(){const{storefrontAccessToken:t}=ve(),e={};t&&(e["X-Recharge-Storefront-Access-Token"]=t);const r=await xt("get","/access",{headers:e});return{apiToken:r.api_token,customerId:r.customer_id}}async function Ic(t,e){const{environment:r,storefrontAccessToken:n,storeIdentifier:a}=ve(),s=rr(r),f={};n&&(f["X-Recharge-Storefront-Access-Token"]=n);const p=await ce("post",`${s}/shopify_storefront_access`,{data:{customer_token:e,storefront_token:t,shop_url:a},headers:f});return p.api_token?{apiToken:p.api_token,customerId:p.customer_id}:null}async function Bc(t,e={}){const{environment:r,storefrontAccessToken:n,storeIdentifier:a}=ve(),s=rr(r),f={};n&&(f["X-Recharge-Storefront-Access-Token"]=n);const p=await ce("post",`${s}/attempt_login`,{data:qi({email:t,shop:a},e),headers:f});if(p.errors)throw new Error(p.errors);return p.session_token}async function Oc(t,e={}){const{storefrontAccessToken:r}=ve(),n={};r&&(n["X-Recharge-Storefront-Access-Token"]=r);const a=await xt("post","/attempt_login",{data:qi({email:t},e),headers:n});if(a.errors)throw new Error(a.errors);return a.session_token}async function Tc(t,e,r){const{environment:n,storefrontAccessToken:a,storeIdentifier:s}=ve(),f=rr(n),p={};a&&(p["X-Recharge-Storefront-Access-Token"]=a);const h=await ce("post",`${f}/validate_login`,{data:{code:r,email:t,session_token:e,shop:s},headers:p});if(h.errors)throw new Error(h.errors);return{apiToken:h.api_token,customerId:h.customer_id}}async function Rc(t,e,r){const{storefrontAccessToken:n}=ve(),a={};n&&(a["X-Recharge-Storefront-Access-Token"]=n);const s=await xt("post","/validate_login",{data:{code:r,email:t,session_token:e},headers:a});if(s.errors)throw new Error(s.errors);return{apiToken:s.api_token,customerId:s.customer_id}}function $c(){const{pathname:t,search:e}=window.location,r=new URLSearchParams(e).get("token"),n=t.split("/").filter(Boolean),a=n.findIndex(f=>f==="portal"),s=a!==-1?n[a+1]:void 0;if(!r||!s)throw new Error("Not in context of Recharge Customer Portal or URL did not contain correct params");return{customerHash:s,token:r}}async function Pc(){const{customerHash:t,token:e}=$c(),{environment:r,storefrontAccessToken:n,storeIdentifier:a}=ve(),s=rr(r),f={};n&&(f["X-Recharge-Storefront-Access-Token"]=n);const p=await ce("post",`${s}/customers/${t}/access`,{headers:f,data:{token:e,shop:a}});return{apiToken:p.api_token,customerId:p.customer_id}}var Fc=Object.freeze({__proto__:null,loginShopifyAppProxy:Sc,loginShopifyApi:Ic,sendPasswordlessCode:Bc,sendPasswordlessCodeAppProxy:Oc,validatePasswordlessCode:Tc,validatePasswordlessCodeAppProxy:Rc,loginCustomerPortal:Pc});let Uc=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce((e,r)=>(r&=63,r<36?e+=r.toString(36):r<62?e+=(r-26).toString(36).toUpperCase():r>62?e+="-":e+="_",e),"");var Cc=200,an="__lodash_hash_undefined__",Dc=1/0,Vi=9007199254740991,Nc="[object Arguments]",Mc="[object Function]",Lc="[object GeneratorFunction]",kc="[object Symbol]",jc=/[\\^$.*+?()[\]{}|]/g,qc=/^\[object .+?Constructor\]$/,Vc=/^(?:0|[1-9]\d*)$/,zc=typeof oe=="object"&&oe&&oe.Object===Object&&oe,Gc=typeof self=="object"&&self&&self.Object===Object&&self,sn=zc||Gc||Function("return this")();function Wc(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}function Hc(t,e){var r=t?t.length:0;return!!r&&Jc(t,e,0)>-1}function Yc(t,e,r){for(var n=-1,a=t?t.length:0;++n<a;)if(r(e,t[n]))return!0;return!1}function zi(t,e){for(var r=-1,n=t?t.length:0,a=Array(n);++r<n;)a[r]=e(t[r],r,t);return a}function un(t,e){for(var r=-1,n=e.length,a=t.length;++r<n;)t[a+r]=e[r];return t}function Xc(t,e,r,n){for(var a=t.length,s=r+(n?1:-1);n?s--:++s<a;)if(e(t[s],s,t))return s;return-1}function Jc(t,e,r){if(e!==e)return Xc(t,Kc,r);for(var n=r-1,a=t.length;++n<a;)if(t[n]===e)return n;return-1}function Kc(t){return t!==t}function Qc(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}function Zc(t){return function(e){return t(e)}}function ef(t,e){return t.has(e)}function tf(t,e){return t?.[e]}function rf(t){var e=!1;if(t!=null&&typeof t.toString!="function")try{e=!!(t+"")}catch{}return e}function Gi(t,e){return function(r){return t(e(r))}}var nf=Array.prototype,of=Function.prototype,ar=Object.prototype,cn=sn["__core-js_shared__"],Wi=function(){var t=/[^.]+$/.exec(cn&&cn.keys&&cn.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),Hi=of.toString,rt=ar.hasOwnProperty,fn=ar.toString,af=RegExp("^"+Hi.call(rt).replace(jc,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Yi=sn.Symbol,sf=Gi(Object.getPrototypeOf,Object),uf=ar.propertyIsEnumerable,cf=nf.splice,Xi=Yi?Yi.isConcatSpreadable:void 0,ln=Object.getOwnPropertySymbols,Ji=Math.max,ff=Qi(sn,"Map"),St=Qi(Object,"create");function Ve(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function lf(){this.__data__=St?St(null):{}}function pf(t){return this.has(t)&&delete this.__data__[t]}function hf(t){var e=this.__data__;if(St){var r=e[t];return r===an?void 0:r}return rt.call(e,t)?e[t]:void 0}function df(t){var e=this.__data__;return St?e[t]!==void 0:rt.call(e,t)}function yf(t,e){var r=this.__data__;return r[t]=St&&e===void 0?an:e,this}Ve.prototype.clear=lf,Ve.prototype.delete=pf,Ve.prototype.get=hf,Ve.prototype.has=df,Ve.prototype.set=yf;function nt(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function gf(){this.__data__=[]}function mf(t){var e=this.__data__,r=ur(e,t);if(r<0)return!1;var n=e.length-1;return r==n?e.pop():cf.call(e,r,1),!0}function wf(t){var e=this.__data__,r=ur(e,t);return r<0?void 0:e[r][1]}function vf(t){return ur(this.__data__,t)>-1}function _f(t,e){var r=this.__data__,n=ur(r,t);return n<0?r.push([t,e]):r[n][1]=e,this}nt.prototype.clear=gf,nt.prototype.delete=mf,nt.prototype.get=wf,nt.prototype.has=vf,nt.prototype.set=_f;function it(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function bf(){this.__data__={hash:new Ve,map:new(ff||nt),string:new Ve}}function Ef(t){return cr(this,t).delete(t)}function Af(t){return cr(this,t).get(t)}function xf(t){return cr(this,t).has(t)}function Sf(t,e){return cr(this,t).set(t,e),this}it.prototype.clear=bf,it.prototype.delete=Ef,it.prototype.get=Af,it.prototype.has=xf,it.prototype.set=Sf;function sr(t){var e=-1,r=t?t.length:0;for(this.__data__=new it;++e<r;)this.add(t[e])}function If(t){return this.__data__.set(t,an),this}function Bf(t){return this.__data__.has(t)}sr.prototype.add=sr.prototype.push=If,sr.prototype.has=Bf;function Of(t,e){var r=pn(t)||Zi(t)?Qc(t.length,String):[],n=r.length,a=!!n;for(var s in t)(e||rt.call(t,s))&&!(a&&(s=="length"||kf(s,n)))&&r.push(s);return r}function ur(t,e){for(var r=t.length;r--;)if(Hf(t[r][0],e))return r;return-1}function Tf(t,e,r,n){var a=-1,s=Hc,f=!0,p=t.length,h=[],m=e.length;if(!p)return h;r&&(e=zi(e,Zc(r))),n?(s=Yc,f=!1):e.length>=Cc&&(s=ef,f=!1,e=new sr(e));e:for(;++a<p;){var v=t[a],_=r?r(v):v;if(v=n||v!==0?v:0,f&&_===_){for(var b=m;b--;)if(e[b]===_)continue e;h.push(v)}else s(e,_,n)||h.push(v)}return h}function Ki(t,e,r,n,a){var s=-1,f=t.length;for(r||(r=Lf),a||(a=[]);++s<f;){var p=t[s];e>0&&r(p)?e>1?Ki(p,e-1,r,n,a):un(a,p):n||(a[a.length]=p)}return a}function Rf(t,e,r){var n=e(t);return pn(t)?n:un(n,r(t))}function $f(t){if(!hn(t)||qf(t))return!1;var e=to(t)||rf(t)?af:qc;return e.test(Wf(t))}function Pf(t){if(!hn(t))return zf(t);var e=Vf(t),r=[];for(var n in t)n=="constructor"&&(e||!rt.call(t,n))||r.push(n);return r}function Ff(t,e){return t=Object(t),Uf(t,e,function(r,n){return n in t})}function Uf(t,e,r){for(var n=-1,a=e.length,s={};++n<a;){var f=e[n],p=t[f];r(p,f)&&(s[f]=p)}return s}function Cf(t,e){return e=Ji(e===void 0?t.length-1:e,0),function(){for(var r=arguments,n=-1,a=Ji(r.length-e,0),s=Array(a);++n<a;)s[n]=r[e+n];n=-1;for(var f=Array(e+1);++n<e;)f[n]=r[n];return f[e]=s,Wc(t,this,f)}}function Df(t){return Rf(t,Kf,Mf)}function cr(t,e){var r=t.__data__;return jf(e)?r[typeof e=="string"?"string":"hash"]:r.map}function Qi(t,e){var r=tf(t,e);return $f(r)?r:void 0}var Nf=ln?Gi(ln,Object):no,Mf=ln?function(t){for(var e=[];t;)un(e,Nf(t)),t=sf(t);return e}:no;function Lf(t){return pn(t)||Zi(t)||!!(Xi&&t&&t[Xi])}function kf(t,e){return e=e??Vi,!!e&&(typeof t=="number"||Vc.test(t))&&t>-1&&t%1==0&&t<e}function jf(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function qf(t){return!!Wi&&Wi in t}function Vf(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||ar;return t===r}function zf(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}function Gf(t){if(typeof t=="string"||Jf(t))return t;var e=t+"";return e=="0"&&1/t==-Dc?"-0":e}function Wf(t){if(t!=null){try{return Hi.call(t)}catch{}try{return t+""}catch{}}return""}function Hf(t,e){return t===e||t!==t&&e!==e}function Zi(t){return Yf(t)&&rt.call(t,"callee")&&(!uf.call(t,"callee")||fn.call(t)==Nc)}var pn=Array.isArray;function eo(t){return t!=null&&Xf(t.length)&&!to(t)}function Yf(t){return ro(t)&&eo(t)}function to(t){var e=hn(t)?fn.call(t):"";return e==Mc||e==Lc}function Xf(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Vi}function hn(t){var e=typeof t;return!!t&&(e=="object"||e=="function")}function ro(t){return!!t&&typeof t=="object"}function Jf(t){return typeof t=="symbol"||ro(t)&&fn.call(t)==kc}function Kf(t){return eo(t)?Of(t,!0):Pf(t)}var Qf=Cf(function(t,e){return t==null?{}:(e=zi(Ki(e,1),Gf),Ff(t,Tf(Df(t),e)))});function no(){return[]}var dn=Qf,Zf=Object.defineProperty,el=Object.defineProperties,tl=Object.getOwnPropertyDescriptors,io=Object.getOwnPropertySymbols,rl=Object.prototype.hasOwnProperty,nl=Object.prototype.propertyIsEnumerable,oo=(t,e,r)=>e in t?Zf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,il=(t,e)=>{for(var r in e||(e={}))rl.call(e,r)&&oo(t,r,e[r]);if(io)for(var r of io(e))nl.call(e,r)&&oo(t,r,e[r]);return t},ol=(t,e)=>el(t,tl(e));function al(t){try{return JSON.parse(t)}catch{return t}}function sl(t){return Object.entries(t).reduce((e,[r,n])=>ol(il({},e),{[r]:al(n)}),{})}const ao=t=>typeof t=="string"?t!=="0"&&t!=="false":!!t;var ul=Object.defineProperty,cl=Object.defineProperties,fl=Object.getOwnPropertyDescriptors,so=Object.getOwnPropertySymbols,ll=Object.prototype.hasOwnProperty,pl=Object.prototype.propertyIsEnumerable,uo=(t,e,r)=>e in t?ul(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,co=(t,e)=>{for(var r in e||(e={}))ll.call(e,r)&&uo(t,r,e[r]);if(so)for(var r of so(e))pl.call(e,r)&&uo(t,r,e[r]);return t},fo=(t,e)=>cl(t,fl(e));function lo(t){var e;const r=sl(t),n=r.auto_inject===void 0?!0:r.auto_inject,a=(e=r.display_on)!=null?e:[],s=r.first_option==="autodeliver";return fo(co({},dn(r,["display_on","first_option"])),{auto_inject:n,valid_pages:a,is_subscription_first:s,autoInject:n,validPages:a,isSubscriptionFirst:s})}function po(t){var e;const r=((e=t.subscription_options)==null?void 0:e.storefront_purchase_options)==="subscription_only";return fo(co({},t),{is_subscription_only:r,isSubscriptionOnly:r})}function hl(t){return t.map(e=>{const r={};return Object.entries(e).forEach(([n,a])=>{r[n]=po(a)}),r})}const fr="2020-12",dl={store_currency:{currency_code:"USD",currency_symbol:"$",decimal_separator:".",thousands_separator:",",currency_symbol_location:"left"}},It=new Map;function lr(t,e){return It.has(t)||It.set(t,e()),It.get(t)}async function yn(t){const{product:e}=await lr(`product.${t}`,()=>or("get",`/product/${fr}/${t}.json`));return po(e)}async function ho(){return await lr("storeSettings",()=>or("get",`/${fr}/store_settings.json`).catch(()=>dl))}async function yo(){const{widget_settings:t}=await lr("widgetSettings",()=>or("get",`/${fr}/widget_settings.json`));return lo(t)}async function go(){const{products:t,widget_settings:e,store_settings:r,meta:n}=await lr("productsAndSettings",()=>or("get",`/product/${fr}/products.json`));return n?.status==="error"?Promise.reject(n.message):{products:hl(t),widget_settings:lo(e),store_settings:r??{}}}async function yl(){const{products:t}=await go();return t}async function gl(t){const[e,r,n]=await Promise.all([yn(t),ho(),yo()]);return{product:e,store_settings:r,widget_settings:n,storeSettings:r,widgetSettings:n}}async function mo(t){const{bundle_product:e}=await yn(t);return e}async function wo(){return Array.from(It.keys()).forEach(t=>It.delete(t))}var ml=Object.freeze({__proto__:null,getCDNProduct:yn,getCDNStoreSettings:ho,getCDNWidgetSettings:yo,getCDNProductsAndSettings:go,getCDNProducts:yl,getCDNProductAndSettings:gl,getCDNBundleSettings:mo,resetCDNCache:wo}),vo={exports:{}};/*! For license information please see xdr.js.LICENSE.txt */(function(t,e){(function(r,n){t.exports=n()})(oe,()=>(()=>{var r={899:(s,f,p)=>{const h=p(221);s.exports=h},221:(s,f,p)=>{p.r(f),p.d(f,{Array:()=>ft,Bool:()=>G,Double:()=>hr,Enum:()=>_e,Float:()=>Pe,Hyper:()=>L,Int:()=>z,Opaque:()=>Pt,Option:()=>Ut,Quadruple:()=>k,Reference:()=>ee,String:()=>$t,Struct:()=>Fe,Union:()=>Ie,UnsignedHyper:()=>ie,UnsignedInt:()=>N,VarArray:()=>Ft,VarOpaque:()=>Se,Void:()=>J,config:()=>g});class h extends TypeError{constructor(o){super(`XDR Write Error: ${o}`)}}class m extends TypeError{constructor(o){super(`XDR Read Error: ${o}`)}}class v extends TypeError{constructor(o){super(`XDR Type Definition Error: ${o}`)}}class _ extends v{constructor(){super("method not implemented, it should be overloaded in the descendant class.")}}var b=p(764).lW;class y{constructor(o){if(!b.isBuffer(o)){if(!(o instanceof Array))throw new m("source not specified");o=b.from(o)}this._buffer=o,this._length=o.length,this._index=0}_buffer;_length;_index;get eof(){return this._index===this._length}advance(o){const l=this._index;if(this._index+=o,this._length<this._index)throw new m("attempt to read outside the boundary of the buffer");const w=4-(o%4||4);if(w>0){for(let A=0;A<w;A++)if(this._buffer[this._index+A]!==0)throw new m("invalid padding");this._index+=w}return l}rewind(){this._index=0}read(o){const l=this.advance(o);return this._buffer.subarray(l,l+o)}readInt32BE(){return this._buffer.readInt32BE(this.advance(4))}readUInt32BE(){return this._buffer.readUInt32BE(this.advance(4))}readBigInt64BE(){return this._buffer.readBigInt64BE(this.advance(8))}readBigUInt64BE(){return this._buffer.readBigUInt64BE(this.advance(8))}readFloatBE(){return this._buffer.readFloatBE(this.advance(4))}readDoubleBE(){return this._buffer.readDoubleBE(this.advance(8))}ensureInputConsumed(){if(this._index!==this._length)throw new m("invalid XDR contract typecast - source buffer not entirely consumed")}}var x=p(764).lW;const I=8192;class O{constructor(o){typeof o=="number"?o=x.allocUnsafe(o):o instanceof x||(o=x.allocUnsafe(I)),this._buffer=o,this._length=o.length}_buffer;_length;_index=0;alloc(o){const l=this._index;return this._index+=o,this._length<this._index&&this.resize(this._index),l}resize(o){const l=Math.ceil(o/I)*I,w=x.allocUnsafe(l);this._buffer.copy(w,0,0,this._length),this._buffer=w,this._length=l}finalize(){return this._buffer.subarray(0,this._index)}toArray(){return[...this.finalize()]}write(o,l){if(typeof o=="string"){const A=this.alloc(l);this._buffer.write(o,A,"utf8")}else{o instanceof x||(o=x.from(o));const A=this.alloc(l);o.copy(this._buffer,A,0,l)}const w=4-(l%4||4);if(w>0){const A=this.alloc(w);this._buffer.fill(0,A,this._index)}}writeInt32BE(o){const l=this.alloc(4);this._buffer.writeInt32BE(o,l)}writeUInt32BE(o){const l=this.alloc(4);this._buffer.writeUInt32BE(o,l)}writeBigInt64BE(o){const l=this.alloc(8);this._buffer.writeBigInt64BE(o,l)}writeBigUInt64BE(o){const l=this.alloc(8);this._buffer.writeBigUInt64BE(o,l)}writeFloatBE(o){const l=this.alloc(4);this._buffer.writeFloatBE(o,l)}writeDoubleBE(o){const l=this.alloc(8);this._buffer.writeDoubleBE(o,l)}static bufferChunkSize=I}var S=p(764).lW;class B{toXDR(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"raw";if(!this.write)return this.constructor.toXDR(this,o);const l=new O;return this.write(this,l),M(l.finalize(),o)}fromXDR(o){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"raw";if(!this.read)return this.constructor.fromXDR(o,l);const w=new y(q(o,l)),A=this.read(w);return w.ensureInputConsumed(),A}validateXDR(o){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"raw";try{return this.fromXDR(o,l),!0}catch{return!1}}static toXDR(o){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"raw";const w=new O;return this.write(o,w),M(w.finalize(),l)}static fromXDR(o){const l=new y(q(o,arguments.length>1&&arguments[1]!==void 0?arguments[1]:"raw")),w=this.read(l);return l.ensureInputConsumed(),w}static validateXDR(o){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"raw";try{return this.fromXDR(o,l),!0}catch{return!1}}}class $ extends B{static read(o){throw new _}static write(o,l){throw new _}static isValid(o){return!1}}class R extends B{isValid(o){return!1}}class D extends TypeError{constructor(o){super(`Invalid format ${o}, must be one of "raw", "hex", "base64"`)}}function M(d,o){switch(o){case"raw":return d;case"hex":return d.toString("hex");case"base64":return d.toString("base64");default:throw new D(o)}}function q(d,o){switch(o){case"raw":return d;case"hex":return S.from(d,"hex");case"base64":return S.from(d,"base64");default:throw new D(o)}}const V=2147483647,Y=-2147483648;class z extends ${static read(o){return o.readInt32BE()}static write(o,l){if(typeof o!="number")throw new h("not a number");if((0|o)!==o)throw new h("invalid i32 value");l.writeInt32BE(o)}static isValid(o){return typeof o=="number"&&(0|o)===o&&o>=Y&&o<=V}}z.MAX_VALUE=V,z.MIN_VALUE=2147483648;const ne=-9223372036854775808n,ae=9223372036854775807n;class L extends ${constructor(o,l){if(super(),typeof o=="bigint"){if(o<ne||o>ae)throw new TypeError("Invalid i64 value");this._value=o}else{if((0|o)!==o||(0|l)!==l)throw new TypeError("Invalid i64 value");this._value=BigInt(l>>>0)<<32n|BigInt(o>>>0)}}get low(){return Number(0xFFFFFFFFn&this._value)<<0}get high(){return Number(this._value>>32n)>>0}get unsigned(){return!1}toString(){return this._value.toString()}toJSON(){return{_value:this._value.toString()}}static read(o){return new L(o.readBigInt64BE())}static write(o,l){if(!(o instanceof this))throw new h(`${o} is not a Hyper`);l.writeBigInt64BE(o._value)}static fromString(o){if(!/^-?\d{0,19}$/.test(o))throw new TypeError(`Invalid i64 string value: ${o}`);return new L(BigInt(o))}static fromBits(o,l){return new this(o,l)}static isValid(o){return o instanceof this}}L.MAX_VALUE=new L(ae),L.MIN_VALUE=new L(ne);const Z=4294967295;class N extends ${static read(o){return o.readUInt32BE()}static write(o,l){if(typeof o!="number"||!(o>=0&&o<=Z)||o%1!=0)throw new h("invalid u32 value");l.writeUInt32BE(o)}static isValid(o){return typeof o=="number"&&o%1==0&&o>=0&&o<=Z}}N.MAX_VALUE=Z,N.MIN_VALUE=0;const se=0n,ut=0xFFFFFFFFFFFFFFFFn;class ie extends ${constructor(o,l){if(super(),typeof o=="bigint"){if(o<se||o>ut)throw new TypeError("Invalid u64 value");this._value=o}else{if((0|o)!==o||(0|l)!==l)throw new TypeError("Invalid u64 value");this._value=BigInt(l>>>0)<<32n|BigInt(o>>>0)}}get low(){return Number(0xFFFFFFFFn&this._value)<<0}get high(){return Number(this._value>>32n)>>0}get unsigned(){return!0}toString(){return this._value.toString()}toJSON(){return{_value:this._value.toString()}}static read(o){return new ie(o.readBigUInt64BE())}static write(o,l){if(!(o instanceof this))throw new h(`${o} is not an UnsignedHyper`);l.writeBigUInt64BE(o._value)}static fromString(o){if(!/^\d{0,20}$/.test(o))throw new TypeError(`Invalid u64 string value: ${o}`);return new ie(BigInt(o))}static fromBits(o,l){return new this(o,l)}static isValid(o){return o instanceof this}}ie.MAX_VALUE=new ie(ut),ie.MIN_VALUE=new ie(se);class Pe extends ${static read(o){return o.readFloatBE()}static write(o,l){if(typeof o!="number")throw new h("not a number");l.writeFloatBE(o)}static isValid(o){return typeof o=="number"}}class hr extends ${static read(o){return o.readDoubleBE()}static write(o,l){if(typeof o!="number")throw new h("not a number");l.writeDoubleBE(o)}static isValid(o){return typeof o=="number"}}class k extends ${static read(){throw new v("quadruple not supported")}static write(){throw new v("quadruple not supported")}static isValid(){return!1}}class G extends ${static read(o){const l=z.read(o);switch(l){case 0:return!1;case 1:return!0;default:throw new m(`got ${l} when trying to read a bool`)}}static write(o,l){const w=o?1:0;z.write(w,l)}static isValid(o){return typeof o=="boolean"}}var ct=p(764).lW;class $t extends R{constructor(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:N.MAX_VALUE;super(),this._maxLength=o}read(o){const l=N.read(o);if(l>this._maxLength)throw new m(`saw ${l} length String, max allowed is ${this._maxLength}`);return o.read(l)}readString(o){return this.read(o).toString("utf8")}write(o,l){const w=typeof o=="string"?ct.byteLength(o,"utf8"):o.length;if(w>this._maxLength)throw new h(`got ${o.length} bytes, max allowed is ${this._maxLength}`);N.write(w,l),l.write(o,w)}isValid(o){return typeof o=="string"?ct.byteLength(o,"utf8")<=this._maxLength:!!(o instanceof Array||ct.isBuffer(o))&&o.length<=this._maxLength}}var dr=p(764).lW;class Pt extends R{constructor(o){super(),this._length=o}read(o){return o.read(this._length)}write(o,l){const{length:w}=o;if(w!==this._length)throw new h(`got ${o.length} bytes, expected ${this._length}`);l.write(o,w)}isValid(o){return dr.isBuffer(o)&&o.length===this._length}}var yr=p(764).lW;class Se extends R{constructor(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:N.MAX_VALUE;super(),this._maxLength=o}read(o){const l=N.read(o);if(l>this._maxLength)throw new m(`saw ${l} length VarOpaque, max allowed is ${this._maxLength}`);return o.read(l)}write(o,l){const{length:w}=o;if(o.length>this._maxLength)throw new h(`got ${o.length} bytes, max allowed is ${this._maxLength}`);N.write(w,l),l.write(o,w)}isValid(o){return yr.isBuffer(o)&&o.length<=this._maxLength}}class ft extends R{constructor(o,l){super(),this._childType=o,this._length=l}read(o){const l=new p.g.Array(this._length);for(let w=0;w<this._length;w++)l[w]=this._childType.read(o);return l}write(o,l){if(!(o instanceof p.g.Array))throw new h("value is not array");if(o.length!==this._length)throw new h(`got array of size ${o.length}, expected ${this._length}`);for(const w of o)this._childType.write(w,l)}isValid(o){if(!(o instanceof p.g.Array)||o.length!==this._length)return!1;for(const l of o)if(!this._childType.isValid(l))return!1;return!0}}class Ft extends R{constructor(o){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:N.MAX_VALUE;super(),this._childType=o,this._maxLength=l}read(o){const l=N.read(o);if(l>this._maxLength)throw new m(`saw ${l} length VarArray, max allowed is ${this._maxLength}`);const w=new Array(l);for(let A=0;A<l;A++)w[A]=this._childType.read(o);return w}write(o,l){if(!(o instanceof Array))throw new h("value is not array");if(o.length>this._maxLength)throw new h(`got array of size ${o.length}, max allowed is ${this._maxLength}`);N.write(o.length,l);for(const w of o)this._childType.write(w,l)}isValid(o){if(!(o instanceof Array)||o.length>this._maxLength)return!1;for(const l of o)if(!this._childType.isValid(l))return!1;return!0}}class Ut extends ${constructor(o){super(),this._childType=o}read(o){if(G.read(o))return this._childType.read(o)}write(o,l){const w=o!=null;G.write(w,l),w&&this._childType.write(o,l)}isValid(o){return o==null||this._childType.isValid(o)}}class J extends ${static read(){}static write(o){if(o!==void 0)throw new h("trying to write value to a void slot")}static isValid(o){return o===void 0}}class _e extends ${constructor(o,l){super(),this.name=o,this.value=l}static read(o){const l=z.read(o),w=this._byValue[l];if(w===void 0)throw new m(`unknown ${this.enumName} member for value ${l}`);return w}static write(o,l){if(!(o instanceof this))throw new h(`unknown ${o} is not a ${this.enumName}`);z.write(o.value,l)}static isValid(o){return o instanceof this}static members(){return this._members}static values(){return Object.values(this._members)}static fromName(o){const l=this._members[o];if(!l)throw new TypeError(`${o} is not a member of ${this.enumName}`);return l}static fromValue(o){const l=this._byValue[o];if(l===void 0)throw new TypeError(`${o} is not a value of any member of ${this.enumName}`);return l}static create(o,l,w){const A=class extends _e{};A.enumName=l,o.results[l]=A,A._members={},A._byValue={};for(const[F,P]of Object.entries(w)){const U=new A(F,P);A._members[F]=U,A._byValue[P]=U,A[F]=()=>U}return A}}class ee extends ${resolve(){throw new v('"resolve" method should be implemented in the descendant class')}}class Fe extends ${constructor(o){super(),this._attributes=o||{}}static read(o){const l={};for(const[w,A]of this._fields)l[w]=A.read(o);return new this(l)}static write(o,l){if(!(o instanceof this))throw new h(`${o} is not a ${this.structName}`);for(const[w,A]of this._fields){const F=o._attributes[w];A.write(F,l)}}static isValid(o){return o instanceof this}static create(o,l,w){const A=class extends Fe{};A.structName=l,o.results[l]=A;const F=new Array(w.length);for(let P=0;P<w.length;P++){const U=w[P],Ct=U[0];let mr=U[1];mr instanceof ee&&(mr=mr.resolve(o)),F[P]=[Ct,mr],A.prototype[Ct]=gr(Ct)}return A._fields=F,A}}function gr(d){return function(o){return o!==void 0&&(this._attributes[d]=o),this._attributes[d]}}class Ie extends R{constructor(o,l){super(),this.set(o,l)}set(o,l){typeof o=="string"&&(o=this.constructor._switchOn.fromName(o)),this._switch=o;const w=this.constructor.armForSwitch(this._switch);this._arm=w,this._armType=w===J?J:this.constructor._arms[w],this._value=l}get(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this._arm;if(this._arm!==J&&this._arm!==o)throw new TypeError(`${o} not set`);return this._value}switch(){return this._switch}arm(){return this._arm}armType(){return this._armType}value(){return this._value}static armForSwitch(o){const l=this._switches.get(o);if(l!==void 0)return l;if(this._defaultArm)return this._defaultArm;throw new TypeError(`Bad union switch: ${o}`)}static armTypeForArm(o){return o===J?J:this._arms[o]}static read(o){const l=this._switchOn.read(o),w=this.armForSwitch(l),A=w===J?J:this._arms[w];let F;return F=A!==void 0?A.read(o):w.read(o),new this(l,F)}static write(o,l){if(!(o instanceof this))throw new h(`${o} is not a ${this.unionName}`);this._switchOn.write(o.switch(),l),o.armType().write(o.value(),l)}static isValid(o){return o instanceof this}static create(o,l,w){const A=class extends Ie{};A.unionName=l,o.results[l]=A,w.switchOn instanceof ee?A._switchOn=w.switchOn.resolve(o):A._switchOn=w.switchOn,A._switches=new Map,A._arms={};let F=w.defaultArm;F instanceof ee&&(F=F.resolve(o)),A._defaultArm=F;for(const[P,U]of w.switches){const Ct=typeof P=="string"?A._switchOn.fromName(P):P;A._switches.set(Ct,U)}if(A._switchOn.values!==void 0)for(const P of A._switchOn.values())A[P.name]=function(U){return new A(P,U)},A.prototype[P.name]=function(U){return this.set(P,U)};if(w.arms)for(const[P,U]of Object.entries(w.arms))A._arms[P]=U instanceof ee?U.resolve(o):U,U!==J&&(A.prototype[P]=function(){return this.get(P)});return A}}class fe extends ee{constructor(o){super(),this.name=o}resolve(o){return o.definitions[this.name].resolve(o)}}class lt extends ee{constructor(o,l){let w=arguments.length>2&&arguments[2]!==void 0&&arguments[2];super(),this.childReference=o,this.length=l,this.variable=w}resolve(o){let l=this.childReference,w=this.length;return l instanceof ee&&(l=l.resolve(o)),w instanceof ee&&(w=w.resolve(o)),this.variable?new Ft(l,w):new ft(l,w)}}class En extends ee{constructor(o){super(),this.childReference=o,this.name=o.name}resolve(o){let l=this.childReference;return l instanceof ee&&(l=l.resolve(o)),new Ut(l)}}class le extends ee{constructor(o,l){super(),this.sizedType=o,this.length=l}resolve(o){let l=this.length;return l instanceof ee&&(l=l.resolve(o)),new this.sizedType(l)}}class We{constructor(o,l,w){this.constructor=o,this.name=l,this.config=w}resolve(o){return this.name in o.results?o.results[this.name]:this.constructor(o,this.name,this.config)}}function i(d,o,l){return l instanceof ee&&(l=l.resolve(d)),d.results[o]=l,l}function u(d,o,l){return d.results[o]=l,l}class c{constructor(o){this._destination=o,this._definitions={}}enum(o,l){const w=new We(_e.create,o,l);this.define(o,w)}struct(o,l){const w=new We(Fe.create,o,l);this.define(o,w)}union(o,l){const w=new We(Ie.create,o,l);this.define(o,w)}typedef(o,l){const w=new We(i,o,l);this.define(o,w)}const(o,l){const w=new We(u,o,l);this.define(o,w)}void(){return J}bool(){return G}int(){return z}hyper(){return L}uint(){return N}uhyper(){return ie}float(){return Pe}double(){return hr}quadruple(){return k}string(o){return new le($t,o)}opaque(o){return new le(Pt,o)}varOpaque(o){return new le(Se,o)}array(o,l){return new lt(o,l)}varArray(o,l){return new lt(o,l,!0)}option(o){return new En(o)}define(o,l){if(this._destination[o]!==void 0)throw new v(`${o} is already defined`);this._definitions[o]=l}lookup(o){return new fe(o)}resolve(){for(const o of Object.values(this._definitions))o.resolve({definitions:this._definitions,results:this._destination})}}function g(d){let o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(d){const l=new c(o);d(l),l.resolve()}return o}},742:(s,f)=>{f.byteLength=function(x){var I=b(x),O=I[0],S=I[1];return 3*(O+S)/4-S},f.toByteArray=function(x){var I,O,S=b(x),B=S[0],$=S[1],R=new m(function(q,V,Y){return 3*(V+Y)/4-Y}(0,B,$)),D=0,M=$>0?B-4:B;for(O=0;O<M;O+=4)I=h[x.charCodeAt(O)]<<18|h[x.charCodeAt(O+1)]<<12|h[x.charCodeAt(O+2)]<<6|h[x.charCodeAt(O+3)],R[D++]=I>>16&255,R[D++]=I>>8&255,R[D++]=255&I;return $===2&&(I=h[x.charCodeAt(O)]<<2|h[x.charCodeAt(O+1)]>>4,R[D++]=255&I),$===1&&(I=h[x.charCodeAt(O)]<<10|h[x.charCodeAt(O+1)]<<4|h[x.charCodeAt(O+2)]>>2,R[D++]=I>>8&255,R[D++]=255&I),R},f.fromByteArray=function(x){for(var I,O=x.length,S=O%3,B=[],$=16383,R=0,D=O-S;R<D;R+=$)B.push(y(x,R,R+$>D?D:R+$));return S===1?(I=x[O-1],B.push(p[I>>2]+p[I<<4&63]+"==")):S===2&&(I=(x[O-2]<<8)+x[O-1],B.push(p[I>>10]+p[I>>4&63]+p[I<<2&63]+"=")),B.join("")};for(var p=[],h=[],m=typeof Uint8Array<"u"?Uint8Array:Array,v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",_=0;_<64;++_)p[_]=v[_],h[v.charCodeAt(_)]=_;function b(x){var I=x.length;if(I%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var O=x.indexOf("=");return O===-1&&(O=I),[O,O===I?0:4-O%4]}function y(x,I,O){for(var S,B,$=[],R=I;R<O;R+=3)S=(x[R]<<16&16711680)+(x[R+1]<<8&65280)+(255&x[R+2]),$.push(p[(B=S)>>18&63]+p[B>>12&63]+p[B>>6&63]+p[63&B]);return $.join("")}h["-".charCodeAt(0)]=62,h["_".charCodeAt(0)]=63},764:(s,f,p)=>{const h=p(742),m=p(645),v=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;f.lW=y,f.h2=50;const _=2147483647;function b(i){if(i>_)throw new RangeError('The value "'+i+'" is invalid for option "size"');const u=new Uint8Array(i);return Object.setPrototypeOf(u,y.prototype),u}function y(i,u,c){if(typeof i=="number"){if(typeof u=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return O(i)}return x(i,u,c)}function x(i,u,c){if(typeof i=="string")return function(o,l){if(typeof l=="string"&&l!==""||(l="utf8"),!y.isEncoding(l))throw new TypeError("Unknown encoding: "+l);const w=0|R(o,l);let A=b(w);const F=A.write(o,l);return F!==w&&(A=A.slice(0,F)),A}(i,u);if(ArrayBuffer.isView(i))return function(o){if(fe(o,Uint8Array)){const l=new Uint8Array(o);return B(l.buffer,l.byteOffset,l.byteLength)}return S(o)}(i);if(i==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof i);if(fe(i,ArrayBuffer)||i&&fe(i.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(fe(i,SharedArrayBuffer)||i&&fe(i.buffer,SharedArrayBuffer)))return B(i,u,c);if(typeof i=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const g=i.valueOf&&i.valueOf();if(g!=null&&g!==i)return y.from(g,u,c);const d=function(o){if(y.isBuffer(o)){const l=0|$(o.length),w=b(l);return w.length===0||o.copy(w,0,0,l),w}if(o.length!==void 0)return typeof o.length!="number"||lt(o.length)?b(0):S(o);if(o.type==="Buffer"&&Array.isArray(o.data))return S(o.data)}(i);if(d)return d;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof i[Symbol.toPrimitive]=="function")return y.from(i[Symbol.toPrimitive]("string"),u,c);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof i)}function I(i){if(typeof i!="number")throw new TypeError('"size" argument must be of type number');if(i<0)throw new RangeError('The value "'+i+'" is invalid for option "size"')}function O(i){return I(i),b(i<0?0:0|$(i))}function S(i){const u=i.length<0?0:0|$(i.length),c=b(u);for(let g=0;g<u;g+=1)c[g]=255&i[g];return c}function B(i,u,c){if(u<0||i.byteLength<u)throw new RangeError('"offset" is outside of buffer bounds');if(i.byteLength<u+(c||0))throw new RangeError('"length" is outside of buffer bounds');let g;return g=u===void 0&&c===void 0?new Uint8Array(i):c===void 0?new Uint8Array(i,u):new Uint8Array(i,u,c),Object.setPrototypeOf(g,y.prototype),g}function $(i){if(i>=_)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+_.toString(16)+" bytes");return 0|i}function R(i,u){if(y.isBuffer(i))return i.length;if(ArrayBuffer.isView(i)||fe(i,ArrayBuffer))return i.byteLength;if(typeof i!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof i);const c=i.length,g=arguments.length>2&&arguments[2]===!0;if(!g&&c===0)return 0;let d=!1;for(;;)switch(u){case"ascii":case"latin1":case"binary":return c;case"utf8":case"utf-8":return Fe(i).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*c;case"hex":return c>>>1;case"base64":return gr(i).length;default:if(d)return g?-1:Fe(i).length;u=(""+u).toLowerCase(),d=!0}}function D(i,u,c){let g=!1;if((u===void 0||u<0)&&(u=0),u>this.length||((c===void 0||c>this.length)&&(c=this.length),c<=0)||(c>>>=0)<=(u>>>=0))return"";for(i||(i="utf8");;)switch(i){case"hex":return Pe(this,u,c);case"utf8":case"utf-8":return N(this,u,c);case"ascii":return ut(this,u,c);case"latin1":case"binary":return ie(this,u,c);case"base64":return Z(this,u,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return hr(this,u,c);default:if(g)throw new TypeError("Unknown encoding: "+i);i=(i+"").toLowerCase(),g=!0}}function M(i,u,c){const g=i[u];i[u]=i[c],i[c]=g}function q(i,u,c,g,d){if(i.length===0)return-1;if(typeof c=="string"?(g=c,c=0):c>2147483647?c=2147483647:c<-2147483648&&(c=-2147483648),lt(c=+c)&&(c=d?0:i.length-1),c<0&&(c=i.length+c),c>=i.length){if(d)return-1;c=i.length-1}else if(c<0){if(!d)return-1;c=0}if(typeof u=="string"&&(u=y.from(u,g)),y.isBuffer(u))return u.length===0?-1:V(i,u,c,g,d);if(typeof u=="number")return u&=255,typeof Uint8Array.prototype.indexOf=="function"?d?Uint8Array.prototype.indexOf.call(i,u,c):Uint8Array.prototype.lastIndexOf.call(i,u,c):V(i,[u],c,g,d);throw new TypeError("val must be string, number or Buffer")}function V(i,u,c,g,d){let o,l=1,w=i.length,A=u.length;if(g!==void 0&&((g=String(g).toLowerCase())==="ucs2"||g==="ucs-2"||g==="utf16le"||g==="utf-16le")){if(i.length<2||u.length<2)return-1;l=2,w/=2,A/=2,c/=2}function F(P,U){return l===1?P[U]:P.readUInt16BE(U*l)}if(d){let P=-1;for(o=c;o<w;o++)if(F(i,o)===F(u,P===-1?0:o-P)){if(P===-1&&(P=o),o-P+1===A)return P*l}else P!==-1&&(o-=o-P),P=-1}else for(c+A>w&&(c=w-A),o=c;o>=0;o--){let P=!0;for(let U=0;U<A;U++)if(F(i,o+U)!==F(u,U)){P=!1;break}if(P)return o}return-1}function Y(i,u,c,g){c=Number(c)||0;const d=i.length-c;g?(g=Number(g))>d&&(g=d):g=d;const o=u.length;let l;for(g>o/2&&(g=o/2),l=0;l<g;++l){const w=parseInt(u.substr(2*l,2),16);if(lt(w))return l;i[c+l]=w}return l}function z(i,u,c,g){return Ie(Fe(u,i.length-c),i,c,g)}function ne(i,u,c,g){return Ie(function(d){const o=[];for(let l=0;l<d.length;++l)o.push(255&d.charCodeAt(l));return o}(u),i,c,g)}function ae(i,u,c,g){return Ie(gr(u),i,c,g)}function L(i,u,c,g){return Ie(function(d,o){let l,w,A;const F=[];for(let P=0;P<d.length&&!((o-=2)<0);++P)l=d.charCodeAt(P),w=l>>8,A=l%256,F.push(A),F.push(w);return F}(u,i.length-c),i,c,g)}function Z(i,u,c){return u===0&&c===i.length?h.fromByteArray(i):h.fromByteArray(i.slice(u,c))}function N(i,u,c){c=Math.min(i.length,c);const g=[];let d=u;for(;d<c;){const o=i[d];let l=null,w=o>239?4:o>223?3:o>191?2:1;if(d+w<=c){let A,F,P,U;switch(w){case 1:o<128&&(l=o);break;case 2:A=i[d+1],(192&A)==128&&(U=(31&o)<<6|63&A,U>127&&(l=U));break;case 3:A=i[d+1],F=i[d+2],(192&A)==128&&(192&F)==128&&(U=(15&o)<<12|(63&A)<<6|63&F,U>2047&&(U<55296||U>57343)&&(l=U));break;case 4:A=i[d+1],F=i[d+2],P=i[d+3],(192&A)==128&&(192&F)==128&&(192&P)==128&&(U=(15&o)<<18|(63&A)<<12|(63&F)<<6|63&P,U>65535&&U<1114112&&(l=U))}}l===null?(l=65533,w=1):l>65535&&(l-=65536,g.push(l>>>10&1023|55296),l=56320|1023&l),g.push(l),d+=w}return function(o){const l=o.length;if(l<=se)return String.fromCharCode.apply(String,o);let w="",A=0;for(;A<l;)w+=String.fromCharCode.apply(String,o.slice(A,A+=se));return w}(g)}y.TYPED_ARRAY_SUPPORT=function(){try{const i=new Uint8Array(1),u={foo:function(){return 42}};return Object.setPrototypeOf(u,Uint8Array.prototype),Object.setPrototypeOf(i,u),i.foo()===42}catch{return!1}}(),y.TYPED_ARRAY_SUPPORT||typeof console>"u"||typeof console.error!="function"||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(y.prototype,"parent",{enumerable:!0,get:function(){if(y.isBuffer(this))return this.buffer}}),Object.defineProperty(y.prototype,"offset",{enumerable:!0,get:function(){if(y.isBuffer(this))return this.byteOffset}}),y.poolSize=8192,y.from=function(i,u,c){return x(i,u,c)},Object.setPrototypeOf(y.prototype,Uint8Array.prototype),Object.setPrototypeOf(y,Uint8Array),y.alloc=function(i,u,c){return function(g,d,o){return I(g),g<=0?b(g):d!==void 0?typeof o=="string"?b(g).fill(d,o):b(g).fill(d):b(g)}(i,u,c)},y.allocUnsafe=function(i){return O(i)},y.allocUnsafeSlow=function(i){return O(i)},y.isBuffer=function(i){return i!=null&&i._isBuffer===!0&&i!==y.prototype},y.compare=function(i,u){if(fe(i,Uint8Array)&&(i=y.from(i,i.offset,i.byteLength)),fe(u,Uint8Array)&&(u=y.from(u,u.offset,u.byteLength)),!y.isBuffer(i)||!y.isBuffer(u))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(i===u)return 0;let c=i.length,g=u.length;for(let d=0,o=Math.min(c,g);d<o;++d)if(i[d]!==u[d]){c=i[d],g=u[d];break}return c<g?-1:g<c?1:0},y.isEncoding=function(i){switch(String(i).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},y.concat=function(i,u){if(!Array.isArray(i))throw new TypeError('"list" argument must be an Array of Buffers');if(i.length===0)return y.alloc(0);let c;if(u===void 0)for(u=0,c=0;c<i.length;++c)u+=i[c].length;const g=y.allocUnsafe(u);let d=0;for(c=0;c<i.length;++c){let o=i[c];if(fe(o,Uint8Array))d+o.length>g.length?(y.isBuffer(o)||(o=y.from(o)),o.copy(g,d)):Uint8Array.prototype.set.call(g,o,d);else{if(!y.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(g,d)}d+=o.length}return g},y.byteLength=R,y.prototype._isBuffer=!0,y.prototype.swap16=function(){const i=this.length;if(i%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let u=0;u<i;u+=2)M(this,u,u+1);return this},y.prototype.swap32=function(){const i=this.length;if(i%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let u=0;u<i;u+=4)M(this,u,u+3),M(this,u+1,u+2);return this},y.prototype.swap64=function(){const i=this.length;if(i%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let u=0;u<i;u+=8)M(this,u,u+7),M(this,u+1,u+6),M(this,u+2,u+5),M(this,u+3,u+4);return this},y.prototype.toString=function(){const i=this.length;return i===0?"":arguments.length===0?N(this,0,i):D.apply(this,arguments)},y.prototype.toLocaleString=y.prototype.toString,y.prototype.equals=function(i){if(!y.isBuffer(i))throw new TypeError("Argument must be a Buffer");return this===i||y.compare(this,i)===0},y.prototype.inspect=function(){let i="";const u=f.h2;return i=this.toString("hex",0,u).replace(/(.{2})/g,"$1 ").trim(),this.length>u&&(i+=" ... "),"<Buffer "+i+">"},v&&(y.prototype[v]=y.prototype.inspect),y.prototype.compare=function(i,u,c,g,d){if(fe(i,Uint8Array)&&(i=y.from(i,i.offset,i.byteLength)),!y.isBuffer(i))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof i);if(u===void 0&&(u=0),c===void 0&&(c=i?i.length:0),g===void 0&&(g=0),d===void 0&&(d=this.length),u<0||c>i.length||g<0||d>this.length)throw new RangeError("out of range index");if(g>=d&&u>=c)return 0;if(g>=d)return-1;if(u>=c)return 1;if(this===i)return 0;let o=(d>>>=0)-(g>>>=0),l=(c>>>=0)-(u>>>=0);const w=Math.min(o,l),A=this.slice(g,d),F=i.slice(u,c);for(let P=0;P<w;++P)if(A[P]!==F[P]){o=A[P],l=F[P];break}return o<l?-1:l<o?1:0},y.prototype.includes=function(i,u,c){return this.indexOf(i,u,c)!==-1},y.prototype.indexOf=function(i,u,c){return q(this,i,u,c,!0)},y.prototype.lastIndexOf=function(i,u,c){return q(this,i,u,c,!1)},y.prototype.write=function(i,u,c,g){if(u===void 0)g="utf8",c=this.length,u=0;else if(c===void 0&&typeof u=="string")g=u,c=this.length,u=0;else{if(!isFinite(u))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");u>>>=0,isFinite(c)?(c>>>=0,g===void 0&&(g="utf8")):(g=c,c=void 0)}const d=this.length-u;if((c===void 0||c>d)&&(c=d),i.length>0&&(c<0||u<0)||u>this.length)throw new RangeError("Attempt to write outside buffer bounds");g||(g="utf8");let o=!1;for(;;)switch(g){case"hex":return Y(this,i,u,c);case"utf8":case"utf-8":return z(this,i,u,c);case"ascii":case"latin1":case"binary":return ne(this,i,u,c);case"base64":return ae(this,i,u,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,i,u,c);default:if(o)throw new TypeError("Unknown encoding: "+g);g=(""+g).toLowerCase(),o=!0}},y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const se=4096;function ut(i,u,c){let g="";c=Math.min(i.length,c);for(let d=u;d<c;++d)g+=String.fromCharCode(127&i[d]);return g}function ie(i,u,c){let g="";c=Math.min(i.length,c);for(let d=u;d<c;++d)g+=String.fromCharCode(i[d]);return g}function Pe(i,u,c){const g=i.length;(!u||u<0)&&(u=0),(!c||c<0||c>g)&&(c=g);let d="";for(let o=u;o<c;++o)d+=En[i[o]];return d}function hr(i,u,c){const g=i.slice(u,c);let d="";for(let o=0;o<g.length-1;o+=2)d+=String.fromCharCode(g[o]+256*g[o+1]);return d}function k(i,u,c){if(i%1!=0||i<0)throw new RangeError("offset is not uint");if(i+u>c)throw new RangeError("Trying to access beyond buffer length")}function G(i,u,c,g,d,o){if(!y.isBuffer(i))throw new TypeError('"buffer" argument must be a Buffer instance');if(u>d||u<o)throw new RangeError('"value" argument is out of bounds');if(c+g>i.length)throw new RangeError("Index out of range")}function ct(i,u,c,g,d){Ut(u,g,d,i,c,7);let o=Number(u&BigInt(4294967295));i[c++]=o,o>>=8,i[c++]=o,o>>=8,i[c++]=o,o>>=8,i[c++]=o;let l=Number(u>>BigInt(32)&BigInt(4294967295));return i[c++]=l,l>>=8,i[c++]=l,l>>=8,i[c++]=l,l>>=8,i[c++]=l,c}function $t(i,u,c,g,d){Ut(u,g,d,i,c,7);let o=Number(u&BigInt(4294967295));i[c+7]=o,o>>=8,i[c+6]=o,o>>=8,i[c+5]=o,o>>=8,i[c+4]=o;let l=Number(u>>BigInt(32)&BigInt(4294967295));return i[c+3]=l,l>>=8,i[c+2]=l,l>>=8,i[c+1]=l,l>>=8,i[c]=l,c+8}function dr(i,u,c,g,d,o){if(c+g>i.length)throw new RangeError("Index out of range");if(c<0)throw new RangeError("Index out of range")}function Pt(i,u,c,g,d){return u=+u,c>>>=0,d||dr(i,0,c,4),m.write(i,u,c,g,23,4),c+4}function yr(i,u,c,g,d){return u=+u,c>>>=0,d||dr(i,0,c,8),m.write(i,u,c,g,52,8),c+8}y.prototype.slice=function(i,u){const c=this.length;(i=~~i)<0?(i+=c)<0&&(i=0):i>c&&(i=c),(u=u===void 0?c:~~u)<0?(u+=c)<0&&(u=0):u>c&&(u=c),u<i&&(u=i);const g=this.subarray(i,u);return Object.setPrototypeOf(g,y.prototype),g},y.prototype.readUintLE=y.prototype.readUIntLE=function(i,u,c){i>>>=0,u>>>=0,c||k(i,u,this.length);let g=this[i],d=1,o=0;for(;++o<u&&(d*=256);)g+=this[i+o]*d;return g},y.prototype.readUintBE=y.prototype.readUIntBE=function(i,u,c){i>>>=0,u>>>=0,c||k(i,u,this.length);let g=this[i+--u],d=1;for(;u>0&&(d*=256);)g+=this[i+--u]*d;return g},y.prototype.readUint8=y.prototype.readUInt8=function(i,u){return i>>>=0,u||k(i,1,this.length),this[i]},y.prototype.readUint16LE=y.prototype.readUInt16LE=function(i,u){return i>>>=0,u||k(i,2,this.length),this[i]|this[i+1]<<8},y.prototype.readUint16BE=y.prototype.readUInt16BE=function(i,u){return i>>>=0,u||k(i,2,this.length),this[i]<<8|this[i+1]},y.prototype.readUint32LE=y.prototype.readUInt32LE=function(i,u){return i>>>=0,u||k(i,4,this.length),(this[i]|this[i+1]<<8|this[i+2]<<16)+16777216*this[i+3]},y.prototype.readUint32BE=y.prototype.readUInt32BE=function(i,u){return i>>>=0,u||k(i,4,this.length),16777216*this[i]+(this[i+1]<<16|this[i+2]<<8|this[i+3])},y.prototype.readBigUInt64LE=le(function(i){J(i>>>=0,"offset");const u=this[i],c=this[i+7];u!==void 0&&c!==void 0||_e(i,this.length-8);const g=u+256*this[++i]+65536*this[++i]+this[++i]*2**24,d=this[++i]+256*this[++i]+65536*this[++i]+c*2**24;return BigInt(g)+(BigInt(d)<<BigInt(32))}),y.prototype.readBigUInt64BE=le(function(i){J(i>>>=0,"offset");const u=this[i],c=this[i+7];u!==void 0&&c!==void 0||_e(i,this.length-8);const g=u*2**24+65536*this[++i]+256*this[++i]+this[++i],d=this[++i]*2**24+65536*this[++i]+256*this[++i]+c;return(BigInt(g)<<BigInt(32))+BigInt(d)}),y.prototype.readIntLE=function(i,u,c){i>>>=0,u>>>=0,c||k(i,u,this.length);let g=this[i],d=1,o=0;for(;++o<u&&(d*=256);)g+=this[i+o]*d;return d*=128,g>=d&&(g-=Math.pow(2,8*u)),g},y.prototype.readIntBE=function(i,u,c){i>>>=0,u>>>=0,c||k(i,u,this.length);let g=u,d=1,o=this[i+--g];for(;g>0&&(d*=256);)o+=this[i+--g]*d;return d*=128,o>=d&&(o-=Math.pow(2,8*u)),o},y.prototype.readInt8=function(i,u){return i>>>=0,u||k(i,1,this.length),128&this[i]?-1*(255-this[i]+1):this[i]},y.prototype.readInt16LE=function(i,u){i>>>=0,u||k(i,2,this.length);const c=this[i]|this[i+1]<<8;return 32768&c?4294901760|c:c},y.prototype.readInt16BE=function(i,u){i>>>=0,u||k(i,2,this.length);const c=this[i+1]|this[i]<<8;return 32768&c?4294901760|c:c},y.prototype.readInt32LE=function(i,u){return i>>>=0,u||k(i,4,this.length),this[i]|this[i+1]<<8|this[i+2]<<16|this[i+3]<<24},y.prototype.readInt32BE=function(i,u){return i>>>=0,u||k(i,4,this.length),this[i]<<24|this[i+1]<<16|this[i+2]<<8|this[i+3]},y.prototype.readBigInt64LE=le(function(i){J(i>>>=0,"offset");const u=this[i],c=this[i+7];u!==void 0&&c!==void 0||_e(i,this.length-8);const g=this[i+4]+256*this[i+5]+65536*this[i+6]+(c<<24);return(BigInt(g)<<BigInt(32))+BigInt(u+256*this[++i]+65536*this[++i]+this[++i]*16777216)}),y.prototype.readBigInt64BE=le(function(i){J(i>>>=0,"offset");const u=this[i],c=this[i+7];u!==void 0&&c!==void 0||_e(i,this.length-8);const g=(u<<24)+65536*this[++i]+256*this[++i]+this[++i];return(BigInt(g)<<BigInt(32))+BigInt(this[++i]*16777216+65536*this[++i]+256*this[++i]+c)}),y.prototype.readFloatLE=function(i,u){return i>>>=0,u||k(i,4,this.length),m.read(this,i,!0,23,4)},y.prototype.readFloatBE=function(i,u){return i>>>=0,u||k(i,4,this.length),m.read(this,i,!1,23,4)},y.prototype.readDoubleLE=function(i,u){return i>>>=0,u||k(i,8,this.length),m.read(this,i,!0,52,8)},y.prototype.readDoubleBE=function(i,u){return i>>>=0,u||k(i,8,this.length),m.read(this,i,!1,52,8)},y.prototype.writeUintLE=y.prototype.writeUIntLE=function(i,u,c,g){i=+i,u>>>=0,c>>>=0,!g&&G(this,i,u,c,Math.pow(2,8*c)-1,0);let d=1,o=0;for(this[u]=255&i;++o<c&&(d*=256);)this[u+o]=i/d&255;return u+c},y.prototype.writeUintBE=y.prototype.writeUIntBE=function(i,u,c,g){i=+i,u>>>=0,c>>>=0,!g&&G(this,i,u,c,Math.pow(2,8*c)-1,0);let d=c-1,o=1;for(this[u+d]=255&i;--d>=0&&(o*=256);)this[u+d]=i/o&255;return u+c},y.prototype.writeUint8=y.prototype.writeUInt8=function(i,u,c){return i=+i,u>>>=0,c||G(this,i,u,1,255,0),this[u]=255&i,u+1},y.prototype.writeUint16LE=y.prototype.writeUInt16LE=function(i,u,c){return i=+i,u>>>=0,c||G(this,i,u,2,65535,0),this[u]=255&i,this[u+1]=i>>>8,u+2},y.prototype.writeUint16BE=y.prototype.writeUInt16BE=function(i,u,c){return i=+i,u>>>=0,c||G(this,i,u,2,65535,0),this[u]=i>>>8,this[u+1]=255&i,u+2},y.prototype.writeUint32LE=y.prototype.writeUInt32LE=function(i,u,c){return i=+i,u>>>=0,c||G(this,i,u,4,4294967295,0),this[u+3]=i>>>24,this[u+2]=i>>>16,this[u+1]=i>>>8,this[u]=255&i,u+4},y.prototype.writeUint32BE=y.prototype.writeUInt32BE=function(i,u,c){return i=+i,u>>>=0,c||G(this,i,u,4,4294967295,0),this[u]=i>>>24,this[u+1]=i>>>16,this[u+2]=i>>>8,this[u+3]=255&i,u+4},y.prototype.writeBigUInt64LE=le(function(i,u=0){return ct(this,i,u,BigInt(0),BigInt("0xffffffffffffffff"))}),y.prototype.writeBigUInt64BE=le(function(i,u=0){return $t(this,i,u,BigInt(0),BigInt("0xffffffffffffffff"))}),y.prototype.writeIntLE=function(i,u,c,g){if(i=+i,u>>>=0,!g){const w=Math.pow(2,8*c-1);G(this,i,u,c,w-1,-w)}let d=0,o=1,l=0;for(this[u]=255&i;++d<c&&(o*=256);)i<0&&l===0&&this[u+d-1]!==0&&(l=1),this[u+d]=(i/o>>0)-l&255;return u+c},y.prototype.writeIntBE=function(i,u,c,g){if(i=+i,u>>>=0,!g){const w=Math.pow(2,8*c-1);G(this,i,u,c,w-1,-w)}let d=c-1,o=1,l=0;for(this[u+d]=255&i;--d>=0&&(o*=256);)i<0&&l===0&&this[u+d+1]!==0&&(l=1),this[u+d]=(i/o>>0)-l&255;return u+c},y.prototype.writeInt8=function(i,u,c){return i=+i,u>>>=0,c||G(this,i,u,1,127,-128),i<0&&(i=255+i+1),this[u]=255&i,u+1},y.prototype.writeInt16LE=function(i,u,c){return i=+i,u>>>=0,c||G(this,i,u,2,32767,-32768),this[u]=255&i,this[u+1]=i>>>8,u+2},y.prototype.writeInt16BE=function(i,u,c){return i=+i,u>>>=0,c||G(this,i,u,2,32767,-32768),this[u]=i>>>8,this[u+1]=255&i,u+2},y.prototype.writeInt32LE=function(i,u,c){return i=+i,u>>>=0,c||G(this,i,u,4,2147483647,-2147483648),this[u]=255&i,this[u+1]=i>>>8,this[u+2]=i>>>16,this[u+3]=i>>>24,u+4},y.prototype.writeInt32BE=function(i,u,c){return i=+i,u>>>=0,c||G(this,i,u,4,2147483647,-2147483648),i<0&&(i=4294967295+i+1),this[u]=i>>>24,this[u+1]=i>>>16,this[u+2]=i>>>8,this[u+3]=255&i,u+4},y.prototype.writeBigInt64LE=le(function(i,u=0){return ct(this,i,u,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),y.prototype.writeBigInt64BE=le(function(i,u=0){return $t(this,i,u,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),y.prototype.writeFloatLE=function(i,u,c){return Pt(this,i,u,!0,c)},y.prototype.writeFloatBE=function(i,u,c){return Pt(this,i,u,!1,c)},y.prototype.writeDoubleLE=function(i,u,c){return yr(this,i,u,!0,c)},y.prototype.writeDoubleBE=function(i,u,c){return yr(this,i,u,!1,c)},y.prototype.copy=function(i,u,c,g){if(!y.isBuffer(i))throw new TypeError("argument should be a Buffer");if(c||(c=0),g||g===0||(g=this.length),u>=i.length&&(u=i.length),u||(u=0),g>0&&g<c&&(g=c),g===c||i.length===0||this.length===0)return 0;if(u<0)throw new RangeError("targetStart out of bounds");if(c<0||c>=this.length)throw new RangeError("Index out of range");if(g<0)throw new RangeError("sourceEnd out of bounds");g>this.length&&(g=this.length),i.length-u<g-c&&(g=i.length-u+c);const d=g-c;return this===i&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(u,c,g):Uint8Array.prototype.set.call(i,this.subarray(c,g),u),d},y.prototype.fill=function(i,u,c,g){if(typeof i=="string"){if(typeof u=="string"?(g=u,u=0,c=this.length):typeof c=="string"&&(g=c,c=this.length),g!==void 0&&typeof g!="string")throw new TypeError("encoding must be a string");if(typeof g=="string"&&!y.isEncoding(g))throw new TypeError("Unknown encoding: "+g);if(i.length===1){const o=i.charCodeAt(0);(g==="utf8"&&o<128||g==="latin1")&&(i=o)}}else typeof i=="number"?i&=255:typeof i=="boolean"&&(i=Number(i));if(u<0||this.length<u||this.length<c)throw new RangeError("Out of range index");if(c<=u)return this;let d;if(u>>>=0,c=c===void 0?this.length:c>>>0,i||(i=0),typeof i=="number")for(d=u;d<c;++d)this[d]=i;else{const o=y.isBuffer(i)?i:y.from(i,g),l=o.length;if(l===0)throw new TypeError('The value "'+i+'" is invalid for argument "value"');for(d=0;d<c-u;++d)this[d+u]=o[d%l]}return this};const Se={};function ft(i,u,c){Se[i]=class extends c{constructor(){super(),Object.defineProperty(this,"message",{value:u.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${i}]`,this.stack,delete this.name}get code(){return i}set code(g){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:g,writable:!0})}toString(){return`${this.name} [${i}]: ${this.message}`}}}function Ft(i){let u="",c=i.length;const g=i[0]==="-"?1:0;for(;c>=g+4;c-=3)u=`_${i.slice(c-3,c)}${u}`;return`${i.slice(0,c)}${u}`}function Ut(i,u,c,g,d,o){if(i>c||i<u){const l=typeof u=="bigint"?"n":"";let w;throw w=o>3?u===0||u===BigInt(0)?`>= 0${l} and < 2${l} ** ${8*(o+1)}${l}`:`>= -(2${l} ** ${8*(o+1)-1}${l}) and < 2 ** ${8*(o+1)-1}${l}`:`>= ${u}${l} and <= ${c}${l}`,new Se.ERR_OUT_OF_RANGE("value",w,i)}(function(l,w,A){J(w,"offset"),l[w]!==void 0&&l[w+A]!==void 0||_e(w,l.length-(A+1))})(g,d,o)}function J(i,u){if(typeof i!="number")throw new Se.ERR_INVALID_ARG_TYPE(u,"number",i)}function _e(i,u,c){throw Math.floor(i)!==i?(J(i,c),new Se.ERR_OUT_OF_RANGE(c||"offset","an integer",i)):u<0?new Se.ERR_BUFFER_OUT_OF_BOUNDS:new Se.ERR_OUT_OF_RANGE(c||"offset",`>= ${c?1:0} and <= ${u}`,i)}ft("ERR_BUFFER_OUT_OF_BOUNDS",function(i){return i?`${i} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),ft("ERR_INVALID_ARG_TYPE",function(i,u){return`The "${i}" argument must be of type number. Received type ${typeof u}`},TypeError),ft("ERR_OUT_OF_RANGE",function(i,u,c){let g=`The value of "${i}" is out of range.`,d=c;return Number.isInteger(c)&&Math.abs(c)>4294967296?d=Ft(String(c)):typeof c=="bigint"&&(d=String(c),(c>BigInt(2)**BigInt(32)||c<-(BigInt(2)**BigInt(32)))&&(d=Ft(d)),d+="n"),g+=` It must be ${u}. Received ${d}`,g},RangeError);const ee=/[^+/0-9A-Za-z-_]/g;function Fe(i,u){let c;u=u||1/0;const g=i.length;let d=null;const o=[];for(let l=0;l<g;++l){if(c=i.charCodeAt(l),c>55295&&c<57344){if(!d){if(c>56319){(u-=3)>-1&&o.push(239,191,189);continue}if(l+1===g){(u-=3)>-1&&o.push(239,191,189);continue}d=c;continue}if(c<56320){(u-=3)>-1&&o.push(239,191,189),d=c;continue}c=65536+(d-55296<<10|c-56320)}else d&&(u-=3)>-1&&o.push(239,191,189);if(d=null,c<128){if((u-=1)<0)break;o.push(c)}else if(c<2048){if((u-=2)<0)break;o.push(c>>6|192,63&c|128)}else if(c<65536){if((u-=3)<0)break;o.push(c>>12|224,c>>6&63|128,63&c|128)}else{if(!(c<1114112))throw new Error("Invalid code point");if((u-=4)<0)break;o.push(c>>18|240,c>>12&63|128,c>>6&63|128,63&c|128)}}return o}function gr(i){return h.toByteArray(function(u){if((u=(u=u.split("=")[0]).trim().replace(ee,"")).length<2)return"";for(;u.length%4!=0;)u+="=";return u}(i))}function Ie(i,u,c,g){let d;for(d=0;d<g&&!(d+c>=u.length||d>=i.length);++d)u[d+c]=i[d];return d}function fe(i,u){return i instanceof u||i!=null&&i.constructor!=null&&i.constructor.name!=null&&i.constructor.name===u.name}function lt(i){return i!=i}const En=function(){const i="0123456789abcdef",u=new Array(256);for(let c=0;c<16;++c){const g=16*c;for(let d=0;d<16;++d)u[g+d]=i[c]+i[d]}return u}();function le(i){return typeof BigInt>"u"?We:i}function We(){throw new Error("BigInt not supported")}},645:(s,f)=>{f.read=function(p,h,m,v,_){var b,y,x=8*_-v-1,I=(1<<x)-1,O=I>>1,S=-7,B=m?_-1:0,$=m?-1:1,R=p[h+B];for(B+=$,b=R&(1<<-S)-1,R>>=-S,S+=x;S>0;b=256*b+p[h+B],B+=$,S-=8);for(y=b&(1<<-S)-1,b>>=-S,S+=v;S>0;y=256*y+p[h+B],B+=$,S-=8);if(b===0)b=1-O;else{if(b===I)return y?NaN:1/0*(R?-1:1);y+=Math.pow(2,v),b-=O}return(R?-1:1)*y*Math.pow(2,b-v)},f.write=function(p,h,m,v,_,b){var y,x,I,O=8*b-_-1,S=(1<<O)-1,B=S>>1,$=_===23?Math.pow(2,-24)-Math.pow(2,-77):0,R=v?0:b-1,D=v?1:-1,M=h<0||h===0&&1/h<0?1:0;for(h=Math.abs(h),isNaN(h)||h===1/0?(x=isNaN(h)?1:0,y=S):(y=Math.floor(Math.log(h)/Math.LN2),h*(I=Math.pow(2,-y))<1&&(y--,I*=2),(h+=y+B>=1?$/I:$*Math.pow(2,1-B))*I>=2&&(y++,I/=2),y+B>=S?(x=0,y=S):y+B>=1?(x=(h*I-1)*Math.pow(2,_),y+=B):(x=h*Math.pow(2,B-1)*Math.pow(2,_),y=0));_>=8;p[m+R]=255&x,R+=D,x/=256,_-=8);for(y=y<<_|x,O+=_;O>0;p[m+R]=255&y,R+=D,y/=256,O-=8);p[m+R-D]|=128*M}}},n={};function a(s){var f=n[s];if(f!==void 0)return f.exports;var p=n[s]={exports:{}};return r[s](p,p.exports,a),p.exports}return a.d=(s,f)=>{for(var p in f)a.o(f,p)&&!a.o(s,p)&&Object.defineProperty(s,p,{enumerable:!0,get:f[p]})},a.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),a.o=(s,f)=>Object.prototype.hasOwnProperty.call(s,f),a.r=s=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(s,"__esModule",{value:!0})},a(899)})())})(vo);function wl(t){const e={variantId:xe.Uint64.fromString(t.variantId.toString()),version:t.version||Math.floor(Date.now()/1e3),items:t.items.map(n=>new xe.BundleItem({collectionId:xe.Uint64.fromString(n.collectionId.toString()),productId:xe.Uint64.fromString(n.productId.toString()),variantId:xe.Uint64.fromString(n.variantId.toString()),sku:n.sku||"",quantity:n.quantity,ext:new xe.BundleItemExt(0)})),ext:new xe.BundleExt(0)},r=new xe.Bundle(e);return xe.BundleEnvelope.envelopeTypeBundle(r).toXDR("base64")}const xe=vo.exports.config(t=>{t.enum("EnvelopeType",{envelopeTypeBundle:0}),t.typedef("Uint32",t.uint()),t.typedef("Uint64",t.uhyper()),t.union("BundleItemExt",{switchOn:t.int(),switchName:"v",switches:[[0,t.void()]],arms:{}}),t.struct("BundleItem",[["collectionId",t.lookup("Uint64")],["productId",t.lookup("Uint64")],["variantId",t.lookup("Uint64")],["sku",t.string()],["quantity",t.lookup("Uint32")],["ext",t.lookup("BundleItemExt")]]),t.union("BundleExt",{switchOn:t.int(),switchName:"v",switches:[[0,t.void()]],arms:{}}),t.struct("Bundle",[["variantId",t.lookup("Uint64")],["items",t.varArray(t.lookup("BundleItem"),500)],["version",t.lookup("Uint32")],["ext",t.lookup("BundleExt")]]),t.union("BundleEnvelope",{switchOn:t.lookup("EnvelopeType"),switchName:"type",switches:[["envelopeTypeBundle","v1"]],arms:{v1:t.lookup("Bundle")}})}),_o="/bundling-storefront-manager";function vl(){return Math.ceil(Date.now()/1e3)}async function _l(){try{const{timestamp:t}=await xt("get",`${_o}/t`,{headers:{"X-Recharge-App":"storefront-client"}});return t}catch(t){return console.error(`Fetch failed: ${t}. Using client-side date.`),vl()}}async function bl(t){const e=ve(),r=await bo(t);if(r!==!0)throw new Error(r);const n=await _l(),a=wl({variantId:t.externalVariantId,version:n,items:t.selections.map(s=>({collectionId:s.collectionId,productId:s.externalProductId,variantId:s.externalVariantId,quantity:s.quantity,sku:""}))});try{const s=await xt("post",`${_o}/api/v1/bundles`,{data:{bundle:a},headers:{Origin:`https://${e.storeIdentifier}`}});if(!s.id||s.code!==200)throw new Error(`1: failed generating rb_id: ${JSON.stringify(s)}`);return s.id}catch(s){throw new Error(`2: failed generating rb_id ${s}`)}}function El(t,e){const r=Eo(t);if(r!==!0)throw new Error(`Dynamic Bundle is invalid. ${r}`);const n=`${Uc(9)}:${t.externalProductId}`;return t.selections.map(a=>{const s={id:a.externalVariantId,quantity:a.quantity,properties:{_rc_bundle:n,_rc_bundle_variant:t.externalVariantId,_rc_bundle_parent:e,_rc_bundle_collection_id:a.collectionId}};return a.sellingPlan?s.selling_plan=a.sellingPlan:a.shippingIntervalFrequency&&(s.properties.shipping_interval_frequency=a.shippingIntervalFrequency,s.properties.shipping_interval_unit_type=a.shippingIntervalUnitType,s.id=`${a.discountedVariantId}`),s})}async function bo(t){try{return t?await mo(t.externalProductId)?!0:"Bundle settings do not exist for the given product":"Bundle is not defined"}catch(e){return`Error fetching bundle settings: ${e}`}}const Al={day:["day","days","Days"],days:["day","days","Days"],Days:["day","days","Days"],week:["week","weeks","Weeks"],weeks:["week","weeks","Weeks"],Weeks:["week","weeks","Weeks"],month:["month","months","Months"],months:["month","months","Months"],Months:["month","months","Months"]};function Eo(t){if(!t)return"No bundle defined.";if(t.selections.length===0)return"No selections defined.";const{shippingIntervalFrequency:e,shippingIntervalUnitType:r}=t.selections.find(n=>n.shippingIntervalFrequency||n.shippingIntervalUnitType)||{};if(e||r){if(!e||!r)return"Shipping intervals do not match on selections.";{const n=Al[r];for(let a=0;a<t.selections.length;a++){const{shippingIntervalFrequency:s,shippingIntervalUnitType:f}=t.selections[a];if(s&&s!==e||f&&!n.includes(f))return"Shipping intervals do not match on selections."}}}return!0}async function xl(t,e){const{bundle_selection:r}=await T("get","/bundle_selections",{id:e},t);return r}function Sl(t,e){return T("get","/bundle_selections",{query:e},t)}async function Il(t,e){const{bundle_selection:r}=await T("post","/bundle_selections",{data:e},t);return r}async function Bl(t,e,r){const{bundle_selection:n}=await T("put","/bundle_selections",{id:e,data:r},t);return n}function Ol(t,e){return T("delete","/bundle_selections",{id:e},t)}async function Tl(t,e,r,n){const{subscription:a}=await T("put","/bundles",{id:e,data:r,query:n},t);return a}var Rl=Object.freeze({__proto__:null,getBundleId:bl,getDynamicBundleItems:El,validateBundle:bo,validateDynamicBundle:Eo,getBundleSelection:xl,listBundleSelections:Sl,createBundleSelection:Il,updateBundleSelection:Bl,deleteBundleSelection:Ol,updateBundle:Tl});async function $l(t,e,r){const{charge:n}=await T("get","/charges",{id:e,query:{include:r?.include}},t);return n}function Pl(t,e){return T("get","/charges",{query:e},t)}async function Fl(t,e,r){const{charge:n}=await T("post",`/charges/${e}/apply_discount`,{data:{discount_code:r}},t);return n}async function Ul(t,e){const{charge:r}=await T("post",`/charges/${e}/remove_discount`,{},t);return r}async function Cl(t,e,r){const{charge:n}=await T("post",`/charges/${e}/skip`,{data:{purchase_item_ids:r.map(a=>Number(a))}},t);return n}async function Dl(t,e,r){const{charge:n}=await T("post",`/charges/${e}/unskip`,{data:{purchase_item_ids:r.map(a=>Number(a))}},t);return n}async function Nl(t,e){const{charge:r}=await T("post",`/charges/${e}/process`,{},t);return r}var Ml=Object.freeze({__proto__:null,getCharge:$l,listCharges:Pl,applyDiscountToCharge:Fl,removeDiscountsFromCharge:Ul,skipCharge:Cl,unskipCharge:Dl,processCharge:Nl});async function Ll(t,e){const{membership:r}=await T("get","/memberships",{id:e},t);return r}function kl(t,e){return T("get","/memberships",{query:e},t)}async function jl(t,e,r){const{membership:n}=await T("post",`/memberships/${e}/cancel`,{data:r},t);return n}async function ql(t,e,r){const{membership:n}=await T("post",`/memberships/${e}/activate`,{data:r},t);return n}async function Vl(t,e,r){const{membership:n}=await T("post",`/memberships/${e}/change`,{data:r},t);return n}var zl=Object.freeze({__proto__:null,getMembership:Ll,listMemberships:kl,cancelMembership:jl,activateMembership:ql,changeMembership:Vl});async function Gl(t,e,r){const{membership_program:n}=await T("get","/membership_programs",{id:e,query:{include:r?.include}},t);return n}function Wl(t,e){return T("get","/membership_programs",{query:e},t)}var Hl=Object.freeze({__proto__:null,getMembershipProgram:Gl,listMembershipPrograms:Wl});async function Yl(t,e){const{metafield:r}=await T("post","/metafields",{data:{metafield:e}},t);return r}async function Xl(t,e,r){const{metafield:n}=await T("put","/metafields",{id:e,data:{metafield:r}},t);return n}function Jl(t,e){return T("delete","/metafields",{id:e},t)}var Kl=Object.freeze({__proto__:null,createMetafield:Yl,updateMetafield:Xl,deleteMetafield:Jl});async function Ql(t,e){const{onetime:r}=await T("get","/onetimes",{id:e},t);return r}function Zl(t,e){return T("get","/onetimes",{query:e},t)}async function ep(t,e){const{onetime:r}=await T("post","/onetimes",{data:e},t);return r}async function tp(t,e,r){const{onetime:n}=await T("put","/onetimes",{id:e,data:r},t);return n}function rp(t,e){return T("delete","/onetimes",{id:e},t)}var np=Object.freeze({__proto__:null,getOnetime:Ql,listOnetimes:Zl,createOnetime:ep,updateOnetime:tp,deleteOnetime:rp});async function ip(t,e){const{order:r}=await T("get","/orders",{id:e},t);return r}function op(t,e){return T("get","/orders",{query:e},t)}var ap=Object.freeze({__proto__:null,getOrder:ip,listOrders:op});async function sp(t,e,r){const{payment_method:n}=await T("get","/payment_methods",{id:e,query:{include:r?.include}},t);return n}async function up(t,e,r){const{payment_method:n}=await T("put","/payment_methods",{id:e,data:r},t);return n}function cp(t,e){return T("get","/payment_methods",{query:e},t)}var fp=Object.freeze({__proto__:null,getPaymentMethod:sp,updatePaymentMethod:up,listPaymentMethods:cp});async function lp(t,e){const{plan:r}=await T("get","/plans",{id:e},t);return r}function pp(t,e){return T("get","/plans",{query:e},t)}var hp=Object.freeze({__proto__:null,getPlan:lp,listPlans:pp}),dp="Expected a function",Ao="__lodash_placeholder__",ze=1,pr=2,yp=4,ot=8,Bt=16,Ge=32,Ot=64,xo=128,gp=256,So=512,Io=1/0,mp=9007199254740991,wp=17976931348623157e292,Bo=0/0,vp=[["ary",xo],["bind",ze],["bindKey",pr],["curry",ot],["curryRight",Bt],["flip",So],["partial",Ge],["partialRight",Ot],["rearg",gp]],_p="[object Function]",bp="[object GeneratorFunction]",Ep="[object Symbol]",Ap=/[\\^$.*+?()[\]{}|]/g,xp=/^\s+|\s+$/g,Sp=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Ip=/\{\n\/\* \[wrapped with (.+)\] \*/,Bp=/,? & /,Op=/^[-+]0x[0-9a-f]+$/i,Tp=/^0b[01]+$/i,Rp=/^\[object .+?Constructor\]$/,$p=/^0o[0-7]+$/i,Pp=/^(?:0|[1-9]\d*)$/,Fp=parseInt,Up=typeof oe=="object"&&oe&&oe.Object===Object&&oe,Cp=typeof self=="object"&&self&&self.Object===Object&&self,Tt=Up||Cp||Function("return this")();function gn(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}function Dp(t,e){for(var r=-1,n=t?t.length:0;++r<n&&e(t[r],r,t)!==!1;);return t}function Np(t,e){var r=t?t.length:0;return!!r&&Lp(t,e,0)>-1}function Mp(t,e,r,n){for(var a=t.length,s=r+(n?1:-1);n?s--:++s<a;)if(e(t[s],s,t))return s;return-1}function Lp(t,e,r){if(e!==e)return Mp(t,kp,r);for(var n=r-1,a=t.length;++n<a;)if(t[n]===e)return n;return-1}function kp(t){return t!==t}function jp(t,e){for(var r=t.length,n=0;r--;)t[r]===e&&n++;return n}function qp(t,e){return t?.[e]}function Vp(t){var e=!1;if(t!=null&&typeof t.toString!="function")try{e=!!(t+"")}catch{}return e}function mn(t,e){for(var r=-1,n=t.length,a=0,s=[];++r<n;){var f=t[r];(f===e||f===Ao)&&(t[r]=Ao,s[a++]=r)}return s}var zp=Function.prototype,Oo=Object.prototype,wn=Tt["__core-js_shared__"],To=function(){var t=/[^.]+$/.exec(wn&&wn.keys&&wn.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),Ro=zp.toString,Gp=Oo.hasOwnProperty,$o=Oo.toString,Wp=RegExp("^"+Ro.call(Gp).replace(Ap,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Hp=Object.create,at=Math.max,Yp=Math.min,Po=function(){var t=Uo(Object,"defineProperty"),e=Uo.name;return e&&e.length>2?t:void 0}();function Xp(t){return st(t)?Hp(t):{}}function Jp(t){if(!st(t)||uh(t))return!1;var e=ph(t)||Vp(t)?Wp:Rp;return e.test(fh(t))}function Kp(t,e){return e=at(e===void 0?t.length-1:e,0),function(){for(var r=arguments,n=-1,a=at(r.length-e,0),s=Array(a);++n<a;)s[n]=r[e+n];n=-1;for(var f=Array(e+1);++n<e;)f[n]=r[n];return f[e]=s,gn(t,this,f)}}function Qp(t,e,r,n){for(var a=-1,s=t.length,f=r.length,p=-1,h=e.length,m=at(s-f,0),v=Array(h+m),_=!n;++p<h;)v[p]=e[p];for(;++a<f;)(_||a<s)&&(v[r[a]]=t[a]);for(;m--;)v[p++]=t[a++];return v}function Zp(t,e,r,n){for(var a=-1,s=t.length,f=-1,p=r.length,h=-1,m=e.length,v=at(s-p,0),_=Array(v+m),b=!n;++a<v;)_[a]=t[a];for(var y=a;++h<m;)_[y+h]=e[h];for(;++f<p;)(b||a<s)&&(_[y+r[f]]=t[a++]);return _}function eh(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}function th(t,e,r){var n=e&ze,a=Rt(t);function s(){var f=this&&this!==Tt&&this instanceof s?a:t;return f.apply(n?r:this,arguments)}return s}function Rt(t){return function(){var e=arguments;switch(e.length){case 0:return new t;case 1:return new t(e[0]);case 2:return new t(e[0],e[1]);case 3:return new t(e[0],e[1],e[2]);case 4:return new t(e[0],e[1],e[2],e[3]);case 5:return new t(e[0],e[1],e[2],e[3],e[4]);case 6:return new t(e[0],e[1],e[2],e[3],e[4],e[5]);case 7:return new t(e[0],e[1],e[2],e[3],e[4],e[5],e[6])}var r=Xp(t.prototype),n=t.apply(r,e);return st(n)?n:r}}function rh(t,e,r){var n=Rt(t);function a(){for(var s=arguments.length,f=Array(s),p=s,h=_n(a);p--;)f[p]=arguments[p];var m=s<3&&f[0]!==h&&f[s-1]!==h?[]:mn(f,h);if(s-=m.length,s<r)return Fo(t,e,vn,a.placeholder,void 0,f,m,void 0,void 0,r-s);var v=this&&this!==Tt&&this instanceof a?n:t;return gn(v,this,f)}return a}function vn(t,e,r,n,a,s,f,p,h,m){var v=e&xo,_=e&ze,b=e&pr,y=e&(ot|Bt),x=e&So,I=b?void 0:Rt(t);function O(){for(var S=arguments.length,B=Array(S),$=S;$--;)B[$]=arguments[$];if(y)var R=_n(O),D=jp(B,R);if(n&&(B=Qp(B,n,a,y)),s&&(B=Zp(B,s,f,y)),S-=D,y&&S<m){var M=mn(B,R);return Fo(t,e,vn,O.placeholder,r,B,M,p,h,m-S)}var q=_?r:this,V=b?q[t]:t;return S=B.length,p?B=ch(B,p):x&&S>1&&B.reverse(),v&&h<S&&(B.length=h),this&&this!==Tt&&this instanceof O&&(V=I||Rt(V)),V.apply(q,B)}return O}function nh(t,e,r,n){var a=e&ze,s=Rt(t);function f(){for(var p=-1,h=arguments.length,m=-1,v=n.length,_=Array(v+h),b=this&&this!==Tt&&this instanceof f?s:t;++m<v;)_[m]=n[m];for(;h--;)_[m++]=arguments[++p];return gn(b,a?r:this,_)}return f}function Fo(t,e,r,n,a,s,f,p,h,m){var v=e&ot,_=v?f:void 0,b=v?void 0:f,y=v?s:void 0,x=v?void 0:s;e|=v?Ge:Ot,e&=~(v?Ot:Ge),e&yp||(e&=~(ze|pr));var I=r(t,e,a,y,_,x,b,p,h,m);return I.placeholder=n,Co(I,t,e)}function ih(t,e,r,n,a,s,f,p){var h=e&pr;if(!h&&typeof t!="function")throw new TypeError(dp);var m=n?n.length:0;if(m||(e&=~(Ge|Ot),n=a=void 0),f=f===void 0?f:at(Do(f),0),p=p===void 0?p:Do(p),m-=a?a.length:0,e&Ot){var v=n,_=a;n=a=void 0}var b=[t,e,r,n,a,v,_,s,f,p];if(t=b[0],e=b[1],r=b[2],n=b[3],a=b[4],p=b[9]=b[9]==null?h?0:t.length:at(b[9]-m,0),!p&&e&(ot|Bt)&&(e&=~(ot|Bt)),!e||e==ze)var y=th(t,e,r);else e==ot||e==Bt?y=rh(t,e,p):(e==Ge||e==(ze|Ge))&&!a.length?y=nh(t,e,r,n):y=vn.apply(void 0,b);return Co(y,t,e)}function _n(t){var e=t;return e.placeholder}function Uo(t,e){var r=qp(t,e);return Jp(r)?r:void 0}function oh(t){var e=t.match(Ip);return e?e[1].split(Bp):[]}function ah(t,e){var r=e.length,n=r-1;return e[n]=(r>1?"& ":"")+e[n],e=e.join(r>2?", ":" "),t.replace(Sp,`{
21
21
  /* [wrapped with `+e+`] */
22
22
  `)}function sh(t,e){return e=e??mp,!!e&&(typeof t=="number"||Pp.test(t))&&t>-1&&t%1==0&&t<e}function uh(t){return!!To&&To in t}function ch(t,e){for(var r=t.length,n=Yp(e.length,r),a=eh(t);n--;){var s=e[n];t[n]=sh(s,r)?a[s]:void 0}return t}var Co=Po?function(t,e,r){var n=e+"";return Po(t,"toString",{configurable:!0,enumerable:!1,value:mh(ah(n,lh(oh(n),r)))})}:wh;function fh(t){if(t!=null){try{return Ro.call(t)}catch{}try{return t+""}catch{}}return""}function lh(t,e){return Dp(vp,function(r){var n="_."+r[0];e&r[1]&&!Np(t,n)&&t.push(n)}),t.sort()}var bn=Kp(function(t,e){var r=mn(e,_n(bn));return ih(t,Ge,void 0,e,r)});function ph(t){var e=st(t)?$o.call(t):"";return e==_p||e==bp}function st(t){var e=typeof t;return!!t&&(e=="object"||e=="function")}function hh(t){return!!t&&typeof t=="object"}function dh(t){return typeof t=="symbol"||hh(t)&&$o.call(t)==Ep}function yh(t){if(!t)return t===0?t:0;if(t=gh(t),t===Io||t===-Io){var e=t<0?-1:1;return e*wp}return t===t?t:0}function Do(t){var e=yh(t),r=e%1;return e===e?r?e-r:e:0}function gh(t){if(typeof t=="number")return t;if(dh(t))return Bo;if(st(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=st(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=t.replace(xp,"");var r=Tp.test(t);return r||$p.test(t)?Fp(t.slice(2),r?2:8):Op.test(t)?Bo:+t}function mh(t){return function(){return t}}function wh(t){return t}bn.placeholder={};var No=bn,vh=Object.defineProperty,_h=Object.defineProperties,bh=Object.getOwnPropertyDescriptors,Mo=Object.getOwnPropertySymbols,Eh=Object.prototype.hasOwnProperty,Ah=Object.prototype.propertyIsEnumerable,Lo=(t,e,r)=>e in t?vh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ko=(t,e)=>{for(var r in e||(e={}))Eh.call(e,r)&&Lo(t,r,e[r]);if(Mo)for(var r of Mo(e))Ah.call(e,r)&&Lo(t,r,e[r]);return t},jo=(t,e)=>_h(t,bh(e));function xh(t,e){return jo(ko({},dn(e,["address_id","external_variant_id","external_product_id","charge_interval_frequency","order_interval_frequency","price","status"])),{customer_id:parseInt(t,10),shopify_variant_id:e.external_variant_id.ecommerce?parseInt(e.external_variant_id.ecommerce,10):void 0,charge_interval_frequency:`${e.charge_interval_frequency}`,order_interval_frequency:`${e.order_interval_frequency}`,status:e.status?e.status.toUpperCase():void 0})}function Sh(t,e){var r;return jo(ko({},dn(e,["external_variant_id","external_product_id","charge_interval_frequency","order_interval_frequency","price","use_external_variant_defaults"])),{shopify_variant_id:(r=e.external_variant_id)!=null&&r.ecommerce?parseInt(e.external_variant_id.ecommerce,10):void 0,charge_interval_frequency:e.charge_interval_frequency?`${e.charge_interval_frequency}`:void 0,order_interval_frequency:e.order_interval_frequency?`${e.order_interval_frequency}`:void 0,force_update:t})}function qo(t){const{id:e,address_id:r,customer_id:n,analytics_data:a,cancellation_reason:s,cancellation_reason_comments:f,cancelled_at:p,charge_interval_frequency:h,created_at:m,expire_after_specific_number_of_charges:v,shopify_product_id:_,shopify_variant_id:b,has_queued_charges:y,is_prepaid:x,is_skippable:I,is_swappable:O,max_retries_reached:S,next_charge_scheduled_at:B,order_day_of_month:$,order_day_of_week:R,order_interval_frequency:D,order_interval_unit:M,presentment_currency:q,price:V,product_title:Y,properties:z,quantity:ne,sku:ae,sku_override:L,status:Z,updated_at:N,variant_title:se}=t;return{id:e,address_id:r,customer_id:n,analytics_data:a,cancellation_reason:s,cancellation_reason_comments:f,cancelled_at:p,charge_interval_frequency:parseInt(h,10),created_at:m,expire_after_specific_number_of_charges:v,external_product_id:{ecommerce:`${_}`},external_variant_id:{ecommerce:`${b}`},has_queued_charges:ao(y),is_prepaid:x,is_skippable:I,is_swappable:O,max_retries_reached:ao(S),next_charge_scheduled_at:B,order_day_of_month:$,order_day_of_week:R,order_interval_frequency:parseInt(D,10),order_interval_unit:M,presentment_currency:q,price:`${V}`,product_title:Y??"",properties:z,quantity:ne,sku:ae,sku_override:L,status:Z.toLowerCase(),updated_at:N,variant_title:se}}async function Ih(t,e,r){const{subscription:n}=await T("get","/subscriptions",{id:e,query:{include:r?.include}},t);return n}function Bh(t,e){return T("get","/subscriptions",{query:e},t)}async function Oh(t,e,r){const{subscription:n}=await T("post","/subscriptions",{data:e,query:r},t);return n}async function Th(t,e,r,n){const{subscription:a}=await T("put","/subscriptions",{id:e,data:r,query:n},t);return a}async function Rh(t,e,r,n){const{subscription:a}=await T("post",`/subscriptions/${e}/set_next_charge_date`,{data:{date:r},query:n},t);return a}async function $h(t,e,r){const{subscription:n}=await T("post",`/subscriptions/${e}/change_address`,{data:{address_id:r}},t);return n}async function Ph(t,e,r,n){const{subscription:a}=await T("post",`/subscriptions/${e}/cancel`,{data:r,query:n},t);return a}async function Fh(t,e,r){const{subscription:n}=await T("post",`/subscriptions/${e}/activate`,{query:r},t);return n}async function Uh(t,e,r){const{charge:n}=await T("post",`/subscriptions/${e}/charges/skip`,{data:{date:r,subscription_id:`${e}`}},t);return n}async function Ch(t,e,r){const{onetimes:n}=await T("post","/purchase_items/skip_gift",{data:{purchase_item_ids:e.map(Number),recipient_address:r}},t);return n}async function Dh(t,e){const r=e.length;if(r<1||r>21)throw new Error("Number of subscriptions must be between 1 and 20.");const{customerId:n}=t;if(!n)throw new Error("No customerId in session.");const a=e[0].address_id;if(!e.every(h=>h.address_id===a))throw new Error("All subscriptions must have the same address_id.");const s=No(xh,n),f=e.map(s),{subscriptions:p}=await T("post",`/addresses/${a}/subscriptions-bulk`,{data:{subscriptions:f},headers:{"X-Recharge-Version":"2021-01"}},t);return p.map(qo)}async function Nh(t,e,r,n){const a=r.length;if(a<1||a>21)throw new Error("Number of subscriptions must be between 1 and 20.");const{customerId:s}=t;if(!s)throw new Error("No customerId in session.");const f=No(Sh,!!(n!=null&&n.force_update)),p=r.map(f),{subscriptions:h}=await T("put",`/addresses/${e}/subscriptions-bulk`,{data:{subscriptions:p},headers:{"X-Recharge-Version":"2021-01"}},t);return h.map(qo)}var Mh=Object.freeze({__proto__:null,getSubscription:Ih,listSubscriptions:Bh,createSubscription:Oh,updateSubscription:Th,updateSubscriptionChargeDate:Rh,updateSubscriptionAddress:$h,cancelSubscription:Ph,activateSubscription:Fh,skipSubscriptionCharge:Uh,skipGiftSubscriptionCharge:Ch,createSubscriptions:Dh,updateSubscriptions:Nh});async function Lh(t,e){const r=t.customerId;if(!r)throw new Error("Not logged in.");const{customer:n}=await T("get","/customers",{id:r,query:{include:e?.include}},t);return n}async function kh(t,e){const r=t.customerId;if(!r)throw new Error("Not logged in.");const{customer:n}=await T("put","/customers",{id:r,data:e},t);return n}async function jh(t,e){const r=t.customerId;if(!r)throw new Error("Not logged in.");const{deliveries:n}=await T("get",`/customers/${r}/delivery_schedule`,{query:e},t);return n}async function qh(t){return await T("get","/portal_access",{},t)}var Vh=Object.freeze({__proto__:null,getCustomer:Lh,updateCustomer:kh,getDeliverySchedule:jh,getCustomerPortalAccess:qh});const zh={get(t,e){return ce("get",t,e)},post(t,e){return ce("post",t,e)},put(t,e){return ce("put",t,e)},delete(t,e){return ce("delete",t,e)}};function Gh(t){var e,r;if(t)return t;if((e=window?.Shopify)!=null&&e.shop)return window.Shopify.shop;let n=window?.domain;if(!n){const a=(r=location?.href.match(/(?:http[s]*:\/\/)*(.*?)\.(?=admin\.rechargeapps\.com)/i))==null?void 0:r[1].replace(/-sp$/,"");a&&(n=`${a}.myshopify.com`)}if(n)return n;throw new Error("No storeIdentifier was passed into init.")}function Wh(t={}){const e=t,{storefrontAccessToken:r}=t;if(r&&!r.startsWith("strfnt"))throw new Error("Incorrect storefront access token used. See https://storefront.rechargepayments.com/client/docs/getting_started/package_setup/#initialization-- for more information.");Qu({storeIdentifier:Gh(t.storeIdentifier),loginRetryFn:t.loginRetryFn,storefrontAccessToken:r,environment:e.environment?e.environment:"prod"}),wo()}const Vo={init:Wh,api:zh,address:bc,auth:Fc,bundle:Rl,charge:Ml,cdn:ml,customer:Vh,membership:zl,membershipProgram:Hl,metafield:Kl,onetime:np,order:ap,paymentMethod:fp,plan:hp,subscription:Mh};try{Vo.init()}catch{}return Vo});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rechargeapps/storefront-client",
3
3
  "description": "Storefront client for Recharge",
4
- "version": "1.6.1",
4
+ "version": "1.7.0",
5
5
  "author": "Recharge Inc.",
6
6
  "license": "MIT",
7
7
  "main": "dist/cjs/index.js",