@iheartjane/dm-sdk 2.24.1 → 2.26.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.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as Placement, A as AdMode, F as FilterContext, a as PageContextEnum, S as SearchSortEnum, C as Click, I as Impression, b as CustomImageData, c as SmartSortProductProps, d as SmartSortClickIntent, e as SmartSortProps, f as ConversionExternalProduct, g as SessionEvent, R as RequiredConfig, J as JaneDMPublicConfig, h as JaneDMInternalConfig, i as FetchCartTopperRowProps, j as FetchCustomImageRowProps, k as Facets, l as FetchMenuRowProps, m as FetchMenuTopRowProps, n as FetchProductReviewsProps, o as ProductReviewsResponse, p as FetchRecommendedPDPRowProps, q as FetchRecommendedRowProps, r as FetchRecommendedSortProps, V as VirtualBudtenderQuery, s as IterateProductReviewsProps, t as ProductReviewsIterable } from './smartSort-DJFM0D_n.js';
2
- export { u as AppMode, D as DEFAULT_PAGE_SIZE, v as FetchCartTopperRowByPosProductId, w as FetchCartTopperRowByProductProps, x as FetchRecommendedPDPRowByPosProductId, y as FetchRecommendedPDPRowByProductId, z as IntendedDisplay, B as JaneDMConfig, E as JaneDMIdentifiers, G as JaneDeviceIdSentinel, H as PaginationInfo, K as ProductKindEnum, L as ProductReview, M as ProductReviewsAggregate, N as ReviewSortEnum, O as SearchSort, Q as SmartSortNextPageProps, T as VirtualBudtenderSearchResponse, U as bestSellerRank, W as categoryAndNameAsc, X as defaultOrder, Y as priceAsc, Z as priceDesc, _ as priceEighthOunceAsc, $ as priceEighthOunceDesc, a0 as priceGramAsc, a1 as priceGramDesc, a2 as priceHalfGramAsc, a3 as priceHalfGramDesc, a4 as priceHalfOunceAsc, a5 as priceHalfOunceDesc, a6 as priceOunceAsc, a7 as priceOunceDesc, a8 as priceQuarterOunceAsc, a9 as priceQuarterOunceDesc, aa as priceTwoGramAsc, ab as priceTwoGramDesc, ac as rating, ad as recommendation, ae as searchSorts, af as thcPotencyAsc, ag as thcPotencyDesc } from './smartSort-DJFM0D_n.js';
1
+ import { P as Placement, A as AdMode, F as FilterContext, a as PageContextEnum, S as SearchSortEnum, C as CustomImageData, b as SmartSortProductProps, c as SmartSortClickIntent, d as SmartSortProps, e as ConversionExternalProduct, f as SessionEvent, R as RequiredConfig, J as JaneDMPublicConfig, g as JaneDMInternalConfig, h as FetchCartTopperRowProps, i as FetchCustomImageRowProps, j as Facets, k as FetchMenuRowProps, l as FetchMenuTopRowProps, m as FetchProductReviewsProps, n as ProductReviewsResponse, o as FetchRecommendedPDPRowProps, p as FetchRecommendedRowProps, q as FetchRecommendedSortProps, I as IterateProductReviewsProps, r as ProductReviewsIterable } from './smartSort-C7l2wPes.js';
2
+ export { s as AppMode, D as DEFAULT_PAGE_SIZE, t as FetchCartTopperRowByPosProductId, u as FetchCartTopperRowByProductProps, v as FetchRecommendedPDPRowByPosProductId, w as FetchRecommendedPDPRowByProductId, x as IntendedDisplay, y as JaneDMConfig, z as JaneDMIdentifiers, B as JaneDeviceIdSentinel, E as PaginationInfo, G as ProductKindEnum, H as ProductReview, K as ProductReviewsAggregate, L as ReviewSortEnum, M as SearchSort, N as SmartSortNextPageProps, O as bestSellerRank, Q as categoryAndNameAsc, T as defaultOrder, U as priceAsc, V as priceDesc, W as priceEighthOunceAsc, X as priceEighthOunceDesc, Y as priceGramAsc, Z as priceGramDesc, _ as priceHalfGramAsc, $ as priceHalfGramDesc, a0 as priceHalfOunceAsc, a1 as priceHalfOunceDesc, a2 as priceOunceAsc, a3 as priceOunceDesc, a4 as priceQuarterOunceAsc, a5 as priceQuarterOunceDesc, a6 as priceTwoGramAsc, a7 as priceTwoGramDesc, a8 as rating, a9 as recommendation, aa as searchSorts, ab as thcPotencyAsc, ac as thcPotencyDesc } from './smartSort-C7l2wPes.js';
3
3
 
4
4
  interface CustomBestSellingProps {
5
5
  placement: Placement.BestSelling;
@@ -98,92 +98,6 @@ interface ProductByPosProductId {
98
98
  productId?: never;
99
99
  }
100
100
 
101
- /**
102
- * The VirtualBudtenderClickIntent is used to determine if the click
103
- * event should be treated as an "add to cart" event.
104
- */
105
- interface VirtualBudtenderClickIntent {
106
- /**
107
- * When set to true, the click event will be treated as an "add to cart" event.
108
- * @default false
109
- */
110
- isAddToCart?: boolean;
111
- }
112
- /**
113
- * Properties to create a `VirtualBudtenderProduct` instance.
114
- * @internal
115
- */
116
- interface VirtualBudtenderProductProps<ProductAttributes extends object = Record<string, unknown>> {
117
- /**
118
- * The raw Virtual Budtender product data
119
- */
120
- attributes: ProductAttributes;
121
- /**
122
- * Click tracking payload
123
- */
124
- clickPayload: Click;
125
- /**
126
- * Click tracking URL
127
- */
128
- clickUrl: string;
129
- /**
130
- * Whether this product has been impressed yet
131
- */
132
- hasBeenImpressed?: boolean;
133
- /**
134
- * Impression tracking payload
135
- */
136
- impressPayload: Impression;
137
- /**
138
- * Impression tracking URL
139
- */
140
- impressUrl: string;
141
- /**
142
- * Boolean that indicates if a product is sponsored or not
143
- */
144
- isSponsored: boolean;
145
- /**
146
- * The primary identifier for this product
147
- */
148
- objectId: string;
149
- /**
150
- * The reasoning for the product
151
- */
152
- reasoning?: string;
153
- /**
154
- * The score of the product
155
- */
156
- score?: number;
157
- }
158
- /**
159
- * Parameters for fetching virtual budtender query suggestions.
160
- * @internal
161
- */
162
- interface VirtualBudtenderQueriesParams {
163
- /**
164
- * The store ID to get queries for
165
- */
166
- storeId: number;
167
- }
168
- /**
169
- * Parameters for virtual budtender search.
170
- * @internal
171
- */
172
- interface VirtualBudtenderSearchParams {
173
- /**
174
- * Natural language query for product search
175
- */
176
- query: string;
177
- /**
178
- * Optional search attributes to include in the results
179
- */
180
- searchAttributes?: string[];
181
- /**
182
- * Store ID to search products in
183
- */
184
- storeId: number;
185
- }
186
-
187
101
  /**
188
102
  * Parameters for fetching facets.
189
103
  */
@@ -514,112 +428,6 @@ interface SessionEventParams {
514
428
  events: SessionEvent[];
515
429
  }
516
430
 
517
- interface VirtualBudtenderSearchWithProductsResponse<ProductShape extends object = Record<string, unknown>> {
518
- htmlResponse: string;
519
- markdownResponse: string;
520
- products: VirtualBudtenderProduct<ProductShape>[];
521
- query: string;
522
- totalResults: number;
523
- unformattedResponse: string;
524
- }
525
- /**
526
- * Represents a product returned from Virtual Budtender search.
527
- * Provides tracking methods for click and impression events.
528
- *
529
- * @internal
530
- */
531
- declare class VirtualBudtenderProduct<ProductShape extends object = Record<string, unknown>> {
532
- /**
533
- * The raw Virtual Budtender product data including search attributes and reasoning.
534
- */
535
- attributes: ProductShape;
536
- /**
537
- * Boolean that indicates if a product is sponsored or not
538
- */
539
- isSponsored: boolean;
540
- /**
541
- * The primary identifier for this product.
542
- */
543
- objectId: string;
544
- /**
545
- * The reasoning for the product
546
- */
547
- reasoning?: string;
548
- /**
549
- * The score of the product
550
- */
551
- score?: number;
552
- private clickPayload;
553
- private clickUrl;
554
- private hasBeenImpressed;
555
- private impressPayload;
556
- private impressPromise?;
557
- private impressUrl;
558
- /**
559
- * Builds a new VirtualBudtenderProduct instance based on the provided properties.
560
- * This method should be used in conjunction with `serialize()` to recreate the instance.
561
- */
562
- constructor(props: VirtualBudtenderProductProps<ProductShape>);
563
- /**
564
- * Converts the previously-serialized object back to an instance of this class.
565
- * This method should be used in conjunction with `toJSON()` to recreate the instance.
566
- */
567
- static fromJSON<ProductShape extends object = Record<string, unknown>>(serialized: string): VirtualBudtenderProduct<ProductShape>;
568
- /**
569
- * Records attribution data for this product. This method
570
- * should be called when the product is clicked by the user.
571
- * If the click is associated with an add to cart action,
572
- * that intent should be passed to the click method.
573
- * @example
574
- * ```jsx
575
- * results.products.map((product) => {
576
- * return (<ProductCard
577
- * product={product}
578
- * onClick={() => product.click()}
579
- * key={product.objectId}
580
- * >
581
- * <Button
582
- * title="Add to Cart"
583
- * onClick={() => product.click({isAddToCart: true})}
584
- * />
585
- * </ProductCard>);
586
- * });
587
- * ```
588
- */
589
- click(props?: VirtualBudtenderClickIntent): Promise<void>;
590
- /**
591
- * Records attribution data for this product. This method
592
- * should be called when the product is visible by the user in
593
- * the viewport, as a visible DOM element.
594
- * See {@link https://www.npmjs.com/package/react-intersection-observer react-intersection-observer} for a React component that can be used to detect when an element is in the viewport.
595
- * @example
596
- * ```jsx
597
- * import { InView } from "react-intersection-observer";
598
- *
599
- * const Component = () => (
600
- * <InView onChange={(inView) => {
601
- * if(inView) {
602
- * product.impress();
603
- * }
604
- * }}>
605
- * <ProductCard />
606
- * </InView>
607
- * );
608
- * ```
609
- */
610
- impress(): Promise<void>;
611
- /**
612
- * Serializes the instance to a plain object for storage or transport.
613
- * This method should be used in conjunction with `fromJSON()` to recreate the instance.
614
- */
615
- serialize(): VirtualBudtenderProductProps<ProductShape>;
616
- /**
617
- * Converts the instance to a JSON string for storage or transport.
618
- * This method should be used in conjunction with `fromJSON()` to recreate the instance.
619
- */
620
- toJSON(): string;
621
- }
622
-
623
431
  type Func<T> = () => Promise<T>;
624
432
  /**
625
433
  * Generic Cell Rate Algorithm (GCRA) rate limiter implementation.
@@ -1035,43 +843,6 @@ declare class JaneDM {
1035
843
  * ```
1036
844
  */
1037
845
  fetchRecommendedSort<ProductShape extends object = Record<string, unknown>>(props: FetchRecommendedSortProps): Promise<SmartSort<ProductShape>>;
1038
- /**
1039
- * Fetches virtual budtender query suggestions from the Jane DM API.
1040
- * Returns curated queries optimized for natural language product search.
1041
- * @internal
1042
- * @example
1043
- * ```jsx
1044
- * const queries = await client.fetchVirtualBudtenderQueries({
1045
- * storeId: 420,
1046
- * });
1047
- *
1048
- * console.log(queries); // [{ query: "help me sleep", displayText: "Help me sleep" }, ...]
1049
- * ```
1050
- */
1051
- fetchVirtualBudtenderQueries(props: VirtualBudtenderQueriesParams): Promise<VirtualBudtenderQuery[]>;
1052
- /**
1053
- * Performs natural language product search using Virtual Budtender AI.
1054
- * Returns personalized product recommendations with AI-generated explanations
1055
- * and integrates sponsored products when relevant to the query.
1056
- * @internal
1057
- * @example
1058
- * ```jsx
1059
- * const result = await client.fetchVirtualBudtenderSearch({
1060
- * query: "help me sleep",
1061
- * storeId: 420,
1062
- * });
1063
- *
1064
- * console.log(result.markdownResponse); // AI-generated response
1065
- * console.log(result.products); // Array of VirtualBudtenderProduct instances
1066
- *
1067
- * // Each product has click and impression tracking
1068
- * result.products.forEach(product => {
1069
- * console.log(product.attributes.reasoning); // AI reasoning
1070
- * console.log(product.isSponsored); // Sponsored status
1071
- * });
1072
- * ```
1073
- */
1074
- fetchVirtualBudtenderSearch<ProductShape extends object = Record<string, unknown>>(props: VirtualBudtenderSearchParams): Promise<VirtualBudtenderSearchWithProductsResponse<ProductShape>>;
1075
846
  /**
1076
847
  * Retrieves the configured JDID for the client.
1077
848
  */
@@ -1178,4 +949,4 @@ declare class JaneDM {
1178
949
  private initializeClientSideJdid;
1179
950
  }
1180
951
 
1181
- export { AdMode, BrandSpecials, ConversionExternalProduct, CustomImageData, Facets, FetchCartTopperRowProps, FetchCustomImageRowProps, type FetchCustomPlacementsProps, type FetchFacetsParams, type FetchFeaturedPlacementProps, FetchMenuRowProps, FetchMenuTopRowProps, FetchProductReviewsProps, FetchRecommendedPDPRowProps, FetchRecommendedRowProps, FetchRecommendedSortProps, IterateProductReviewsProps, JaneDM, type MultiPlacementResponse, PageContextEnum, Placement, type PosCheckoutParams, ProductReviewsIterable, ProductReviewsResponse, SearchSortEnum, type SessionEventParams, SmartSort, SmartSortClickIntent, SmartSortProduct, SmartSortProductProps, SmartSortProps, Specials, type VirtualBudtenderClickIntent, VirtualBudtenderProduct, VirtualBudtenderQuery };
952
+ export { AdMode, BrandSpecials, ConversionExternalProduct, CustomImageData, Facets, FetchCartTopperRowProps, FetchCustomImageRowProps, type FetchCustomPlacementsProps, type FetchFacetsParams, type FetchFeaturedPlacementProps, FetchMenuRowProps, FetchMenuTopRowProps, FetchProductReviewsProps, FetchRecommendedPDPRowProps, FetchRecommendedRowProps, FetchRecommendedSortProps, IterateProductReviewsProps, JaneDM, type MultiPlacementResponse, PageContextEnum, Placement, type PosCheckoutParams, ProductReviewsIterable, ProductReviewsResponse, SearchSortEnum, type SessionEventParams, SmartSort, SmartSortClickIntent, SmartSortProduct, SmartSortProductProps, SmartSortProps, Specials };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{A as ne,B as ae,C as ce,D as de,E as ue,F as pe,G as le,H as me,I as he,J as Le,a as S,b as l,c as J,d as be,e as Ge,f as we,g as Je,h as A,i as Qe,j as Ke,k as ve,l as Q,m as K,n as L,o as H,p as $,q as W,r as Z,s as X,t as Y,u as ee,v as te,w as re,x as se,y as ie,z as oe}from"./chunk-VEW5EGZ2.js";var ke="2.24.1";var Pe=(r,e)=>{let{apiKey:t,source:s}=e,i=new URL(r);return i.searchParams.set("jdm_source",s),i.searchParams.set("jdm_version",ke),t&&i.searchParams.set("jdm_api_key",t),i.searchParams.sort(),i.toString()},h=(r,e,t)=>{let s=new URL(r+e);return Pe(s.toString(),t)},w=(r,e)=>{let t=new URL(r+l.click),s=new URL(r+l.impression);return{clickEndpoint:Pe(t.toString(),e),impressionEndpoint:Pe(s.toString(),e)}},ge=class extends Error{response;constructor(e,t){super(e),this.response=t}},_e=async r=>{if(r.ok){if(r.status===204)return null}else throw new ge("Api Request Failed",r);try{return await r.json()}catch{}},He=async(r,e)=>{let t=await fetch(r,{body:JSON.stringify(e),headers:{Accept:"application/json","Content-Type":"text/plain"},method:"POST"});return _e(t)},$e=async(r,e={})=>{let{headers:t,...s}=e,i=await fetch(r,{...s,headers:{Accept:"application/json",...t},method:"GET"});return _e(i)},m={get:$e,post:He};import{nanoid as xe}from"nanoid";var v=()=>typeof window<"u"&&typeof document<"u";var We=(...r)=>{console.error("[JaneDmSDK]",...r)},Ze=(...r)=>{console.info("[JaneDmSDK]",...r)},Xe=(...r)=>{console.log("[JaneDmSDK]",...r)},k={error:We,info:Ze,log:Xe};var Ye=r=>{let e=localStorage.getItem(r);return e!==null?rt(e):e},et=(r,e)=>localStorage.setItem(r,st(e)),tt=r=>localStorage.removeItem(r),F={get:Ye,remove:tt,set:et},rt=r=>Ce(r)?r.substring(1,r.length-1):r,st=r=>Ce(r)?r:`"${r}"`,Ce=r=>{let t=r.length-1;return r[0]==='"'&&r[t]==='"'};var Se="j_fp_last_run",it=1440*60*1e3,ot=20,fe=new Set,nt=(r,e)=>`${r}:${e.apiKey}:${e.source}`;var at=r=>typeof r=="object"&&r!==null&&typeof r.token=="string"&&typeof r.endpoint=="string"&&typeof r.scriptUrlPattern=="string",ct=async(r,e)=>{try{let t=h(r,l.fingerprint,e),s=await m.get(t);return at(s)?s:null}catch(t){return k.error("Failed to fetch fingerprint token:",t),null}},dt=async(r,e,t,s)=>{try{let i=await import("@fingerprintjs/fingerprintjs-pro"),n=await i.load({apiKey:r,endpoint:[e,i.defaultEndpoint],region:"us",scriptUrlPattern:[t,i.defaultScriptUrlPattern],storageKey:"eyeD"}),o={tag:{isDmSdk:!0}};s?.linkedId&&(o.linkedId=s.linkedId);let c=await n.get(o);return!c||!c.visitorId?(k.error("Fingerprint JS did not return a valid visitorId"),null):{visitorId:c.visitorId}}catch(i){return k.error("Failed to run Fingerprint JS:",i),null}},Fe=async(r,e,t)=>{if(!v())return xe();let s=F.get("jdid");if(!s)return await Ee(r,e,t)??xe();if(s.length!==ot)return await Re(r,e,{linkedId:s}),s;let i=await Te(r,e,t);if(i)return i;if(De()==="error")try{F.set(Se,Date.now().toString())}catch{}return s},De=()=>{try{let r=F.get(Se);if(!r)return"missing";let e=parseInt(r,10);return Number.isNaN(e)?"missing":Date.now()-e>=it?"expired":"valid"}catch{return"error"}},Te=async(r,e,t)=>{let s=De();return s==="valid"||s==="error"?null:Ee(r,e,t)},Ee=async(r,e,t)=>{let s=nt(r,e);if(fe.has(s))return null;fe.add(s);try{let i=await ct(r,e);if(!i)return null;let a=await dt(i.token,i.endpoint,i.scriptUrlPattern,t);if(!a)return null;try{F.set(Se,Date.now().toString())}catch{}return a.visitorId}catch(i){return k.error("Failed to run fingerprint:",i),null}finally{fe.delete(s)}},Re=async(r,e,t)=>{if(v()&&t?.linkedId!=="user-opt-out")try{await Te(r,e,t)}catch(s){k.error("Failed to run SSR fingerprint:",s)}};var b=class r extends Error{constructor(e){super(`[Jane DM SDK]: ${e}`),this.name="SdkError",Object.setPrototypeOf(this,r.prototype)}};var ye=r=>{switch(r){case K:return"best-seller-rank";case L:return"category-and-name-asc";case $:return"price-asc";case W:return"price-desc";case Z:return"price-eighth-ounce-asc";case X:return"price-eighth-ounce-desc";case Y:return"price-gram-asc";case ee:return"price-gram-desc";case te:return"price-half-gram-asc";case re:return"price-half-gram-desc";case se:return"price-half-ounce-asc";case ie:return"price-half-ounce-desc";case oe:return"price-ounce-asc";case ne:return"price-ounce-desc";case ae:return"price-quarter-ounce-asc";case ce:return"price-quarter-ounce-desc";case de:return"price-two-gram-asc";case ue:return"price-two-gram-desc";case pe:return"rating";case le:return"recommendation";case me:return"thc-potency-asc";case he:return"thc-potency-desc";case H:default:return"default"}};var T=r=>JSON.parse(r);var Ie=class r{isSponsored;objectId;clickPayload;clickUrl;impressPayload;impressUrl;constructor(e){this.objectId=e.objectId,this.impressUrl=e.impressUrl,this.impressPayload=e.impressPayload,this.clickPayload=e.clickPayload,this.clickUrl=e.clickUrl,this.isSponsored=e.isSponsored}static fromJSON(e){return new r(T(e))}serialize(){return{clickPayload:this.clickPayload,clickUrl:this.clickUrl,impressPayload:this.impressPayload,impressUrl:this.impressUrl,isSponsored:this.isSponsored,objectId:this.objectId}}toJSON(){return JSON.stringify(this.serialize())}},D=class r{attributes;isSponsored;objectId;clickPayload;clickUrl;hasBeenImpressed;impressPayload;impressPromise;impressUrl;constructor(e){this.objectId=e.objectId,this.attributes=e.attributes,this.impressUrl=e.impressUrl,this.impressPayload=e.impressPayload,this.clickPayload=e.clickPayload,this.clickUrl=e.clickUrl,this.isSponsored=e.isSponsored,this.hasBeenImpressed=e.hasBeenImpressed??!1}static fromJSON(e){return new r(T(e))}click(e={isAddToCart:!1}){let{isAddToCart:t=!1}=e,s={...this.clickPayload,isAddToCart:t};return m.post(this.clickUrl,s)}impress(){return this.hasBeenImpressed?Promise.resolve():(this.impressPromise??=m.post(this.impressUrl,this.impressPayload).then(()=>{this.hasBeenImpressed=!0}).finally(()=>{this.impressPromise=void 0}),this.impressPromise)}serialize(){return{attributes:this.attributes,clickPayload:this.clickPayload,clickUrl:this.clickUrl,hasBeenImpressed:this.hasBeenImpressed,impressPayload:this.impressPayload,impressUrl:this.impressUrl,isSponsored:this.isSponsored,objectId:this.objectId}}toJSON(){return JSON.stringify(this.serialize())}},E=class r{customImages;placement;products;rowId;searchFacets;title;totalProducts;creativeIds;cachedProducts;config;loadPromise;nextPageProps;nextPageUrl;constructor(e){this.rowId=e.rowId,this.searchFacets=e.searchFacets,this.nextPageUrl=e.nextPageUrl,this.nextPageProps=e.nextPageProps,this.products=e.products.map(t=>new D(t)),this.cachedProducts=e.cachedProducts.map(t=>new Ie(t)),this.totalProducts=e.totalProducts,this.title=e.title,this.creativeIds=e.creativeIds,this.config=e.config,this.customImages=e.customImages??[],this.placement=e.placement,v()&&!this.config.skipAutoSmartSortOnLoad&&this.onLoad().catch(t=>k.error("Failed to run onLoad:",t))}static fromJSON(e){return new r(T(e))}hasNextPage(){return this.cachedProducts.length>0}async nextPage(){if(!this.hasNextPage())return;let e=this.cachedProducts.slice(0,this.nextPageProps.pageSize),t={app_mode:this.config.appMode,jane_device_id:this.config.identifier.jdid,object_ids:e.map(a=>a.objectId),search_attributes:this.nextPageProps.searchAttributes},s=await m.post(this.nextPageUrl,t),i=new Map(s.products?.map(a=>[a.object_id,a.search_attributes]));e.forEach(a=>{let n=i.get(a.objectId);n!==void 0&&this.products.push(new D({...a.serialize(),attributes:n}))}),this.cachedProducts=this.cachedProducts.slice(this.nextPageProps.pageSize)}async onLoad(){return this.loadPromise?this.loadPromise:(this.loadPromise=(async()=>{if(!v())return;let e={apiKey:this.config.apiKey,source:this.config.source};await Re(this.config.eventsEndpoint,e,{linkedId:this.config.identifier.jdid})})(),this.loadPromise)}serialize(){return{cachedProducts:this.cachedProducts.map(e=>e.serialize()),config:this.config,creativeIds:this.creativeIds,customImages:this.customImages,nextPageProps:this.nextPageProps,nextPageUrl:this.nextPageUrl,placement:this.placement,products:this.products.map(e=>e.serialize()),rowId:this.rowId,searchFacets:this.searchFacets,title:this.title,totalProducts:this.totalProducts}}toJSON(){return JSON.stringify(this.serialize())}},j=class{async createSmartSort(e){let t={apiKey:e.config.apiKey,source:e.config.source},s=h(e.config.endpoint,l.smart,t),i=h(e.config.pageEndpoint,l.page,t),a=this.buildSmartRequest(e),n=await m.post(s,a),{clickEndpoint:o,impressionEndpoint:c}=w(e.config.eventsEndpoint,t),{creative_ids:u,custom_images:P,products:p,row_id:d,search_facets:I,title:f}=n,{cachedProducts:_,products:C}=this.generateProducts({clickUrl:o,identifier:e.config.identifier,impressUrl:c,products:p}),x=(P??[]).map(U=>this.massageCustomImageData(U)).filter(U=>U!==void 0);return new E({cachedProducts:_,config:e.config,creativeIds:u,customImages:x,nextPageProps:{pageSize:"page_size"in a?a.page_size??60:60,searchAttributes:a.search_attributes??e.searchAttributes},nextPageUrl:i,placement:e.placement,products:C,rowId:d,searchFacets:I,title:f,totalProducts:n.nb_hits??0})}generateProducts(e){let{clickUrl:t,identifier:s,impressUrl:i,products:a}=e,n={cachedProducts:[],products:[]};return a?.forEach(o=>{let c={clickPayload:{adToken:o.ad_token,distinctId:s.mixpanelDistinctId??s.jdid,isAddToCart:!1,janeDeviceId:s.jdid,kevelToken:o.kevel_token,myHighD:o.my_high_d,productId:o.product_id,storeId:o.store_id},clickUrl:t,impressPayload:{distinctId:s.mixpanelDistinctId??s.jdid,engagements:[{adToken:o.ad_token,kevelToken:o.kevel_token,myHighD:o.my_high_d,productId:o.product_id}],janeDeviceId:s.jdid},impressUrl:i,isSponsored:!!o.flight_id,objectId:o.object_id};o.search_attributes!==void 0?n.products.push({...c,attributes:o.search_attributes}):n.cachedProducts.push(c)}),n}massageCustomImageData(e){if(e)return{headline:e.headline,imageUrl:e.image_url,intendedDisplay:e.intended_display,logoUrl:e.logo_url,overlayColor:e.overlay_color,positionX:e.position_x,positionY:e.position_y,scaleNumber:e.scale_number,textColor:e.text_color}}buildSmartRequest(e){let{config:t,searchAttributes:s,...i}=e,a={app_mode:t.appMode,distinct_id:t.identifier.mixpanelDistinctId,jane_device_id:t.identifier.jdid,pos_user_id:t.identifier.posUserId,search_attributes:s,user_id:t.identifier.userId};switch(i.placement){case"cart_toppers":{let{cartProductIds:n,posCartProductIds:o,storeId:c}=i;return{...a,cart_pos_product_ids:o,cart_product_ids:n,placement:"cart_toppers",store_id:c}}case"custom_image_row":{let{searchFilter:n,storeId:o}=i;return{...a,placement:"custom_image_row",search_filter:n,store_id:o}}case"menu_dynamic_row":{let{adMode:n,filterContext:o,pageContext:c,storeId:u}=i;return{...a,ad_mode:n??"default",filter_context:o,page_context:c,placement:"menu_dynamic_row",store_id:u}}case"menu_inline":{let{adMode:n,distinctByProduct:o,metadata:c,numColumns:u,searchFilter:P,searchQuery:p,searchSort:d,storeId:I,storeIds:f}=i;return{...a,ad_mode:n??"default",distinct_by_product:o,metadata:c,num_columns:u,placement:"menu_inline",search_filter:P,search_query:p,search_sort:ye(d),store_ids:f||[I]}}case"menu_inline_table":{let{disableAds:n,distinctByProduct:o,maxProducts:c,metadata:u,numColumns:P,pageSize:p,searchFacets:d,searchFilter:I,searchQuery:f,searchSort:_,storeId:C,storeIds:x}=i;return{...a,disable_ads:n,distinct_by_product:o,max_products:c,metadata:u,num_columns:P,page_size:p,placement:"menu_inline_table",search_attributes:s,search_facets:d,search_filter:I,search_query:f,search_sort:ye(_),store_ids:x||[C]}}case"menu_top_row":{let{searchFilter:n,storeId:o}=i,c=this.extractValidCreativeIds(e);return{...a,exclude_creative_ids:c,placement:"menu_top_row",search_filter:n,store_id:o}}case"pdp_row":{let{posProductId:n,productId:o,storeId:c}=i;return{...a,placement:"pdp_row",pos_product_id:n,product_id:o,store_id:c}}default:throw new b(`Invalid Smart Sort Placement: ${i.placement}`)}}extractValidCreativeIds(e){if(e.placement==="menu_top_row"&&"excludeCreativeIds"in e&&Array.isArray(e.excludeCreativeIds))return e.excludeCreativeIds.filter(t=>typeof t=="number")}};var pt=r=>r.placement==="specials",lt=r=>r.placement==="brand_specials",M=class{placement;title;constructor(e){this.title=e,this.placement="brand_specials"}},B=class{placement;title;constructor(e){this.title=e,this.placement="specials"}},O=class extends j{async createMultiPlacement(e){let t={apiKey:e.config.apiKey,source:e.config.source},s=h(e.config.endpoint,l.multi,t),i=h(e.config.pageEndpoint,l.page,t),a=this.buildMultiRequest(e),n=await m.post(s,a),{clickEndpoint:o,impressionEndpoint:c}=w(e.config.eventsEndpoint,t),u=[];for(let[P,p]of(n.placements||[]).entries())if(pt(p))u.push(new B(p.title));else if(lt(p))u.push(new M(p.title));else{let{creative_ids:d,custom_images:I,placement:f,products:_,row_id:C,search_facets:x,title:U}=p,{cachedProducts:Ne,products:Ve}=this.generateProducts({clickUrl:o,identifier:e.config.identifier,impressUrl:c,products:_}),ze=(I??[]).map(G=>this.massageCustomImageData(G)).filter(G=>G!==void 0);u.push(new E({cachedProducts:Ne,config:{...e.config,skipAutoSmartSortOnLoad:P===0?e.config.skipAutoSmartSortOnLoad:!0},creativeIds:d,customImages:ze,nextPageProps:{pageSize:60,searchAttributes:a.search_attributes||[]},nextPageUrl:i,placement:f,products:Ve,rowId:C,searchFacets:x,title:U,totalProducts:p.nb_hits??0}))}return u}buildMultiRequest(e){let{config:t,numColumns:s,searchAttributes:i,storeId:a,...n}=e,o={app_mode:t.appMode,distinct_id:t.identifier.mixpanelDistinctId,jane_device_id:t.identifier.jdid,num_columns:s,pos_user_id:t.identifier.posUserId,search_attributes:i,store_id:a,user_id:t.identifier.userId};switch(n.multiRequestType){case"custom":return{...o,placements:this.massageCustomPlacements(n.placements),type:"custom"};case"featured":return{...o,exclude_menu_top_row:n.excludeMenuTopRow??!1,type:"featured"};default:throw new b(`Invalid Multi Type: ${n.multiRequestType}`)}}massageCustomPlacements(e){let t=[];for(let s of e)switch(s.placement){case"best_selling":t.push({placement:"best_selling",title:s.title});break;case"brand_specials":t.push({placement:"brand_specials",title:s.title});break;case"buy_again_row":t.push({placement:"buy_again_row",title:s.title});break;case"custom_image_row":t.push({placement:"custom_image_row",search_filter:s.searchFilter});break;case"featured_row":t.push({placement:"featured_row",row_id:s.rowId});break;case"menu_dynamic_row":t.push({ad_mode:s.adMode??"default",filter_context:s.filterContext,page_context:s.pageContext,placement:"menu_dynamic_row"});break;case"menu_inline":t.push({ad_mode:s.adMode??"default",metadata:s.metadata,placement:"menu_inline",search_filter:s.searchFilter,search_query:s.searchQuery,search_sort:s.searchSort,title:s.title});break;case"menu_inline_table":t.push({disable_ads:s.disableAds,max_products:s.maxProducts,metadata:s.metadata,page_size:s.pageSize,placement:"menu_inline_table",search_facets:s.searchFacets,search_filter:s.searchFilter,search_query:s.searchQuery,search_sort:s.searchSort,title:s.title});break;case"menu_top_row":t.push({placement:"menu_top_row",search_filter:s.searchFilter});break;case"sale":t.push({placement:"sale",title:s.title});break;case"specials":t.push({placement:"specials",title:s.title});break;default:throw new b(`Invalid Custom Placement: ${s.placement}`)}return t}};import{nanoid as Rt}from"nanoid";var je=async r=>{let{apiKey:e,appMode:t,endpoint:s,identifier:i,searchFacets:a,searchFilter:n,searchQuery:o,source:c,storeId:u}=r,{jdid:P}=i||{},p=h(s,l.facets,{apiKey:e,source:c}),d={appMode:t,janeDeviceId:P,searchFacets:a,searchFilter:n,searchQuery:o,storeId:u};return(await m.post(p,d)).searchFacets??{}};var Ue=async r=>{let{apiKey:e,endpoint:t,identifier:s,source:i,storeId:a,...n}=r,o=h(t,l.externalCheckout,{apiKey:e,source:i}),c={janeDeviceId:s.jdid,posOrderId:n.posOrderId,posUserId:n.posUserId||s.posUserId,products:n.products,storeId:a};return await m.post(o,c)};var q=class{async create(e){let{config:t,searchAttributes:s,storeId:i,...a}=e,n={apiKey:t.apiKey,source:t.source},o=h(t.endpoint,l.product,n),{clickEndpoint:c,impressionEndpoint:u}=w(t.eventsEndpoint,n),P={app_mode:t.appMode,distinct_id:t.identifier.mixpanelDistinctId,jane_device_id:t.identifier.jdid,pos_user_id:t.identifier.posUserId,search_attributes:s,store_id:i,user_id:t.identifier.userId},p=a.productId!==void 0?{...P,product_id:a.productId}:{...P,pos_product_id:a.posProductId},d=await m.post(o,p);return new D({attributes:d.search_attributes,clickPayload:{adToken:d.ad_token,distinctId:t.identifier.mixpanelDistinctId,isAddToCart:!1,janeDeviceId:t.identifier.jdid,kevelToken:d.kevel_token,myHighD:d.my_high_d,productId:d.product_id,storeId:i},clickUrl:c,impressPayload:{distinctId:t.identifier.mixpanelDistinctId??t.identifier.jdid,engagements:[{adToken:d.ad_token,kevelToken:d.kevel_token,myHighD:d.my_high_d,productId:d.product_id}],janeDeviceId:t.identifier.jdid},impressUrl:u,isSponsored:!!d.flight_id,objectId:d.object_id})}};var mt=r=>({activities:r.activities,avatar:r.avatar,comment:r.comment,createdAt:r.created_at,feelings:r.feelings,hasComment:r.has_comment,id:r.id,nickname:r.nickname,productId:r.product_id,rating:r.rating,storeId:r.store_id,storeName:r.store_name,updatedAt:r.updated_at,upvoteCount:r.upvote_count}),ht=r=>({activitiesDistribution:r.activities_distribution,averageRating:r.average_rating,distribution:r.distribution,feelingsDistribution:r.feelings_distribution,reviewCount:r.review_count}),Pt=(r,e,t)=>{let s=r.total_count,i=Math.max(1,Math.ceil(s/t));return{aggregate:ht(r.aggregate),items:r.reviews.map(mt),pagination:{currentPage:e,hasNextPage:e<i,hasPreviousPage:e>1,pageSize:t,totalCount:s,totalPages:i},productId:r.product_id}},Ae=async r=>{let{activities:e,config:t,feelings:s,hasComment:i,page:a,pageSize:n,productId:o,ratings:c,sort:u}=r,P=a??1,p=n??50,d=h(t.endpoint,l.productReviews,{apiKey:t.apiKey,source:t.source}),I={activities:e,feelings:s,has_comment:i||void 0,page:a,page_size:n,product_id:o,ratings:c,sort:u},f=await m.post(d,I);return Pt(f,P,p)},Me=r=>{let e={[Symbol.asyncIterator]:async function*(){let t=1;for(;;){let s=await r(t);if(yield s,!s.pagination.hasNextPage)return;t+=1}}};return{pages:e,[Symbol.asyncIterator]:async function*(){for await(let t of e)yield*t.items}}};var Be=async r=>{let{apiKey:e,eventsEndpoint:t,identifier:s,source:i,...a}=r,n=h(t,l.sessionEvent,{apiKey:e,source:i}),o={distinctId:s.mixpanelDistinctId,events:a.events,janeDeviceId:s.jdid};return await m.post(n,o)};function R(r,e,t){let s=t.value;if(!s)throw new Error("Decorator applied to invalid method descriptor");return t.value=async function(...i){return await this.init(),s.apply(this,i)},t}function y(r,e,t){let s=t.value;if(!s)throw new Error("Decorator applied to invalid method descriptor");return t.value=async function(...i){if(!this.rateLimiter)throw new Error("throttle decorator can only be used on JaneDM class methods");return this.rateLimiter.schedule(async()=>s.apply(this,i))},t}var N=class{burst;intervalMs;rate;tat=0;toleranceMs;constructor(e,t=1){if(e<=0)throw new b("rate must be > 0");if(t<1)throw new b("burst must be >= 1");this.rate=e,this.burst=Math.floor(t),this.intervalMs=1e3/this.rate,this.toleranceMs=(this.burst-1)*this.intervalMs}async schedule(e){let t=Date.now(),s=Math.max(0,this.tat-this.toleranceMs-t);this.tat=Math.max(this.tat,t)+this.intervalMs;let i=async()=>e();return s>0?new Promise((a,n)=>setTimeout(()=>i().then(a).catch(n),s)):i()}};var gt=/^https?:\/\//,ft=/^(https?:\/\/)?(([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}|localhost)(:\d+)?(\/.*)?$/,V=(r,e)=>{let s=gt.test(r??e)?r??e:`https://${r}`,i=new URL(s);return ft.test(i.toString())?i.protocol+"//"+i.host:e};var Oe=async r=>{let{apiKey:e,appMode:t,endpoint:s,identifier:i,source:a,storeId:n}=r,{jdid:o}=i;if(!o)throw new b("Jane Device ID (jdid) is required to fetch virtual budtender queries");let c=h(s,l.virtualBudtenderQueries,{apiKey:e,source:a}),u={appMode:t,janeDeviceId:o,storeId:n};return(await m.post(c,u)).queries??[]},qe=async r=>{let{apiKey:e,appMode:t,endpoint:s,eventsEndpoint:i,identifier:a,query:n,searchAttributes:o,source:c,storeId:u}=r,{jdid:P}=a;if(!P)throw new b("Jane Device ID (jdid) is required to perform virtual budtender search");let p={apiKey:e,source:c},d=h(s,l.virtualBudtenderSearch,p),I={app_mode:t,jane_device_id:P,placement:"virtual_budtender_search",query:n,search_attributes:o,store_id:u},f=await m.post(d,I),{clickEndpoint:_,impressionEndpoint:C}=w(i,p),x=St({clickUrl:_,identifier:a,impressUrl:C,products:f.products??[],storeId:u});return{htmlResponse:f.htmlResponse,markdownResponse:f.markdownResponse,products:x,query:f.query,totalResults:f.totalResults??0,unformattedResponse:f.unformattedResponse}},z=class r{attributes;isSponsored;objectId;reasoning;score;clickPayload;clickUrl;hasBeenImpressed;impressPayload;impressPromise;impressUrl;constructor(e){this.objectId=e.objectId,this.attributes=e.attributes,this.impressUrl=e.impressUrl,this.impressPayload=e.impressPayload,this.clickPayload=e.clickPayload,this.clickUrl=e.clickUrl,this.isSponsored=e.isSponsored,this.hasBeenImpressed=e.hasBeenImpressed??!1,this.score=e.score,this.reasoning=e.reasoning}static fromJSON(e){return new r(T(e))}click(e={isAddToCart:!1}){let{isAddToCart:t=!1}=e,s={...this.clickPayload,isAddToCart:t};return m.post(this.clickUrl,s)}impress(){return this.hasBeenImpressed?Promise.resolve():(this.impressPromise??=m.post(this.impressUrl,this.impressPayload).then(()=>{this.hasBeenImpressed=!0}).finally(()=>{this.impressPromise=void 0}),this.impressPromise)}serialize(){return{attributes:this.attributes,clickPayload:this.clickPayload,clickUrl:this.clickUrl,hasBeenImpressed:this.hasBeenImpressed,impressPayload:this.impressPayload,impressUrl:this.impressUrl,isSponsored:this.isSponsored,objectId:this.objectId,reasoning:this.reasoning,score:this.score}}toJSON(){return JSON.stringify(this.serialize())}},St=r=>{let{clickUrl:e,identifier:t,impressUrl:s,products:i,storeId:a}=r,n=[];return i?.forEach(o=>{let c={attributes:o.search_attributes,clickPayload:{adToken:o.ad_token,distinctId:t.mixpanelDistinctId??t.jdid,isAddToCart:!1,janeDeviceId:t.jdid,kevelToken:o.kevel_token,myHighD:o.my_high_d,productId:o.product_id,storeId:a},clickUrl:e,impressPayload:{distinctId:t.mixpanelDistinctId??t.jdid,engagements:[{adToken:o.ad_token,kevelToken:o.kevel_token,myHighD:o.my_high_d,productId:o.product_id}],janeDeviceId:t.jdid},impressUrl:s,isSponsored:!!o.flight_id,objectId:o.object_id,reasoning:o.reasoning,score:o.score};n.push(new z(c))}),n};var g=class{config;rateLimiter;initialized=!1;multiClient;productClient;smartSortClient;userProvidedJdid=!1;constructor(e,t){let{apiKey:s,endpoint:i,identifier:a}=e,{appMode:n="headless",eventsEndpoint:o,pageEndpoint:c,skipAutoSmartSortOnLoad:u=!1,source:P="sdk"}=t??{},p=V(i,"https://dmerch.iheartjane.com"),d=V(o,p),I=V(c,p);this.userProvidedJdid=!!a?.jdid,this.config={apiKey:s,appMode:n,endpoint:p,eventsEndpoint:d,identifier:a??{jdid:""},pageEndpoint:I,skipAutoSmartSortOnLoad:u,source:P},this.smartSortClient=new j,this.multiClient=new O,this.productClient=new q,this.rateLimiter=new N(10,20)}static generateJaneDeviceId(){return Rt()}async fetchCartTopperRow(e){return await this.smartSortClient.createSmartSort({...e,config:this.config,placement:"cart_toppers"})}async fetchCustomImageRow(e){return this.smartSortClient.createSmartSort({...e,config:this.config,placement:"custom_image_row"})}async fetchCustomPlacements(e){return await this.multiClient.createMultiPlacement({config:this.config,multiRequestType:"custom",...e})}async fetchFacets(e){return je({...e,...this.config})}async fetchFeaturedPlacements(e){return await this.multiClient.createMultiPlacement({config:this.config,multiRequestType:"featured",...e})}async fetchMenuRow(e){return this.smartSortClient.createSmartSort({...e,config:this.config,placement:"menu_inline"})}async fetchMenuTopRow(e){return this.smartSortClient.createSmartSort({...e,config:this.config,placement:"menu_top_row"})}async fetchProduct(e){return this.productClient.create({config:this.config,...e})}async fetchProductReviews(e){return Ae({config:this.config,...e})}async fetchRecommendedPDPRow(e){return await this.smartSortClient.createSmartSort({...e,config:this.config,placement:"pdp_row"})}async fetchRecommendedRow(e){return await this.smartSortClient.createSmartSort({...e,config:this.config,placement:"menu_dynamic_row"})}async fetchRecommendedSort(e){return await this.smartSortClient.createSmartSort({...e,config:this.config,placement:"menu_inline_table"})}async fetchVirtualBudtenderQueries(e){return Oe({...e,...this.config})}async fetchVirtualBudtenderSearch(e){return qe({...e,...this.config})}getJaneDeviceId(){return this.config.identifier.jdid}async init(){this.initialized||(v()&&!this.userProvidedJdid&&await this.initializeClientSideJdid(),this.initialized=!0)}iterateProductReviews(e){return Me(t=>this.fetchProductReviews({...e,page:t}))}async sendPosCheckout(e){return Ue({...e,...this.config})}async sendSessionEvent(e){return Be({...e,...this.config})}async initializeClientSideJdid(){let e={apiKey:this.config.apiKey,source:this.config.source},t=await Fe(this.config.eventsEndpoint,e);F.set("jdid",t),this.config.identifier.jdid=t}};S([R,y],g.prototype,"fetchCartTopperRow",1),S([R,y],g.prototype,"fetchCustomImageRow",1),S([R,y],g.prototype,"fetchCustomPlacements",1),S([R,y],g.prototype,"fetchFacets",1),S([R,y],g.prototype,"fetchFeaturedPlacements",1),S([R,y],g.prototype,"fetchMenuRow",1),S([R,y],g.prototype,"fetchMenuTopRow",1),S([R,y],g.prototype,"fetchProduct",1),S([R,y],g.prototype,"fetchProductReviews",1),S([R,y],g.prototype,"fetchRecommendedPDPRow",1),S([R,y],g.prototype,"fetchRecommendedRow",1),S([R,y],g.prototype,"fetchRecommendedSort",1),S([R,y],g.prototype,"fetchVirtualBudtenderQueries",1),S([R,y],g.prototype,"fetchVirtualBudtenderSearch",1);export{J as AdMode,be as AppMode,M as BrandSpecials,Q as DEFAULT_PAGE_SIZE,Ge as IntendedDisplay,g as JaneDM,we as JaneDeviceIdSentinel,Je as PageContextEnum,A as Placement,Qe as ProductKindEnum,Ke as ReviewSortEnum,ve as SearchSortEnum,E as SmartSort,D as SmartSortProduct,B as Specials,z as VirtualBudtenderProduct,K as bestSellerRank,L as categoryAndNameAsc,H as defaultOrder,$ as priceAsc,W as priceDesc,Z as priceEighthOunceAsc,X as priceEighthOunceDesc,Y as priceGramAsc,ee as priceGramDesc,te as priceHalfGramAsc,re as priceHalfGramDesc,se as priceHalfOunceAsc,ie as priceHalfOunceDesc,oe as priceOunceAsc,ne as priceOunceDesc,ae as priceQuarterOunceAsc,ce as priceQuarterOunceDesc,de as priceTwoGramAsc,ue as priceTwoGramDesc,pe as rating,le as recommendation,Le as searchSorts,me as thcPotencyAsc,he as thcPotencyDesc};
1
+ import{A as ne,B as ae,C as ce,D as de,E as ue,F as pe,G as me,H as le,I as he,J as Je,a as f,b as p,c as L,d as we,e as ze,f as be,g as Ge,h as A,i as Ke,j as Le,k as J,l as B,m as H,n as Q,o as V,p as $,q as Z,r as X,s as Y,t as W,u as ee,v as te,w as re,x as se,y as ie,z as oe}from"./chunk-HXMWTQAO.js";var ve="2.26.0";var Pe=(t,e)=>{let{apiKey:r,source:s}=e,i=new URL(t);return i.searchParams.set("jdm_source",s),i.searchParams.set("jdm_version",ve),r&&i.searchParams.set("jdm_api_key",r),i.searchParams.sort(),i.toString()},h=(t,e,r)=>{let s=new URL(t+e);return Pe(s.toString(),r)},k=(t,e)=>{let r=new URL(t+p.click),s=new URL(t+p.impression);return{clickEndpoint:Pe(r.toString(),e),impressionEndpoint:Pe(s.toString(),e)}},ge=class extends Error{response;constructor(e,r){super(e),this.response=r}},_e=async t=>{if(t.ok){if(t.status===204)return null}else throw new ge("Api Request Failed",t);try{return await t.json()}catch{}},Be=async(t,e)=>{let r=await fetch(t,{body:JSON.stringify(e),headers:{Accept:"application/json","Content-Type":"text/plain"},method:"POST"});return _e(r)},He=async(t,e={})=>{let{headers:r,...s}=e,i=await fetch(t,{...s,headers:{Accept:"application/json",...r},method:"GET"});return _e(i)},l={get:He,post:Be};import{nanoid as ke}from"nanoid";var b=()=>typeof window<"u"&&typeof document<"u";var Qe=(...t)=>{console.error("[JaneDmSDK]",...t)},Ve=(...t)=>{console.info("[JaneDmSDK]",...t)},$e=(...t)=>{console.log("[JaneDmSDK]",...t)},v={error:Qe,info:Ve,log:$e};var Ze=t=>{let e=localStorage.getItem(t);return e!==null?We(e):e},Xe=(t,e)=>localStorage.setItem(t,et(e)),Ye=t=>localStorage.removeItem(t),_={get:Ze,remove:Ye,set:Xe},We=t=>Ce(t)?t.substring(1,t.length-1):t,et=t=>Ce(t)?t:`"${t}"`,Ce=t=>{let r=t.length-1;return t[0]==='"'&&t[r]==='"'};var Se="j_fp_last_run",tt=1440*60*1e3,rt=20,fe=new Set,st=(t,e)=>`${t}:${e.apiKey}:${e.source}`;var it=t=>typeof t=="object"&&t!==null&&typeof t.token=="string"&&typeof t.endpoint=="string"&&typeof t.scriptUrlPattern=="string",ot=async(t,e)=>{try{let r=h(t,p.fingerprint,e),s=await l.get(r);return it(s)?s:null}catch(r){return v.error("Failed to fetch fingerprint token:",r),null}},nt=async(t,e,r,s)=>{try{let i=await import("@fingerprintjs/fingerprintjs-pro"),o=await i.load({apiKey:t,endpoint:[e,i.defaultEndpoint],region:"us",scriptUrlPattern:[r,i.defaultScriptUrlPattern],storageKey:"eyeD"}),a={tag:{isDmSdk:!0}};s?.linkedId&&(a.linkedId=s.linkedId);let c=await o.get(a);return!c||!c.visitorId?(v.error("Fingerprint JS did not return a valid visitorId"),null):{visitorId:c.visitorId}}catch(i){return v.error("Failed to run Fingerprint JS:",i),null}},xe=async(t,e,r)=>{if(!b())return ke();let s=_.get("jdid");if(!s)return await Ee(t,e,r)??ke();if(s.length!==rt)return await Re(t,e,{linkedId:s}),s;let i=await De(t,e,r);if(i)return i;if(Fe()==="error")try{_.set(Se,Date.now().toString())}catch{}return s},Fe=()=>{try{let t=_.get(Se);if(!t)return"missing";let e=parseInt(t,10);return Number.isNaN(e)?"missing":Date.now()-e>=tt?"expired":"valid"}catch{return"error"}},De=async(t,e,r)=>{let s=Fe();return s==="valid"||s==="error"?null:Ee(t,e,r)},Ee=async(t,e,r)=>{let s=st(t,e);if(fe.has(s))return null;fe.add(s);try{let i=await ot(t,e);if(!i)return null;let n=await nt(i.token,i.endpoint,i.scriptUrlPattern,r);if(!n)return null;try{_.set(Se,Date.now().toString())}catch{}return n.visitorId}catch(i){return v.error("Failed to run fingerprint:",i),null}finally{fe.delete(s)}},Re=async(t,e,r)=>{if(b()&&r?.linkedId!=="user-opt-out")try{await De(t,e,r)}catch(s){v.error("Failed to run SSR fingerprint:",s)}};var I=class t extends Error{constructor(e){super(`[Jane DM SDK]: ${e}`),this.name="SdkError",Object.setPrototypeOf(this,t.prototype)}};var at=new Set(Object.values(J)),ye=t=>{switch(t){case H:return"best-seller-rank";case Q:return"category-and-name-asc";case V:return"default";case $:return"price-asc";case Z:return"price-desc";case X:return"price-eighth-ounce-asc";case Y:return"price-eighth-ounce-desc";case W:return"price-gram-asc";case ee:return"price-gram-desc";case te:return"price-half-gram-asc";case re:return"price-half-gram-desc";case se:return"price-half-ounce-asc";case ie:return"price-half-ounce-desc";case oe:return"price-ounce-asc";case ne:return"price-ounce-desc";case ae:return"price-quarter-ounce-asc";case ce:return"price-quarter-ounce-desc";case de:return"price-two-gram-asc";case ue:return"price-two-gram-desc";case pe:return"rating";case me:return"recommendation";case le:return"thc-potency-asc";case he:return"thc-potency-desc";default:return at.has(t)?t:"default"}};var O=t=>JSON.parse(t);var Ie=class t{isSponsored;objectId;clickPayload;clickUrl;impressPayload;impressUrl;constructor(e){this.objectId=e.objectId,this.impressUrl=e.impressUrl,this.impressPayload=e.impressPayload,this.clickPayload=e.clickPayload,this.clickUrl=e.clickUrl,this.isSponsored=e.isSponsored}static fromJSON(e){return new t(O(e))}serialize(){return{clickPayload:this.clickPayload,clickUrl:this.clickUrl,impressPayload:this.impressPayload,impressUrl:this.impressUrl,isSponsored:this.isSponsored,objectId:this.objectId}}toJSON(){return JSON.stringify(this.serialize())}},C=class t{attributes;isSponsored;objectId;clickPayload;clickUrl;hasBeenImpressed;impressPayload;impressPromise;impressUrl;constructor(e){this.objectId=e.objectId,this.attributes=e.attributes,this.impressUrl=e.impressUrl,this.impressPayload=e.impressPayload,this.clickPayload=e.clickPayload,this.clickUrl=e.clickUrl,this.isSponsored=e.isSponsored,this.hasBeenImpressed=e.hasBeenImpressed??!1}static fromJSON(e){return new t(O(e))}click(e={isAddToCart:!1}){let{isAddToCart:r=!1}=e,s={...this.clickPayload,isAddToCart:r};return l.post(this.clickUrl,s)}impress(){return this.hasBeenImpressed?Promise.resolve():(this.impressPromise??=l.post(this.impressUrl,this.impressPayload).then(()=>{this.hasBeenImpressed=!0}).finally(()=>{this.impressPromise=void 0}),this.impressPromise)}serialize(){return{attributes:this.attributes,clickPayload:this.clickPayload,clickUrl:this.clickUrl,hasBeenImpressed:this.hasBeenImpressed,impressPayload:this.impressPayload,impressUrl:this.impressUrl,isSponsored:this.isSponsored,objectId:this.objectId}}toJSON(){return JSON.stringify(this.serialize())}},x=class t{customImages;placement;products;rowId;searchFacets;title;totalProducts;creativeIds;cachedProducts;config;loadPromise;nextPageProps;nextPageUrl;constructor(e){this.rowId=e.rowId,this.searchFacets=e.searchFacets,this.nextPageUrl=e.nextPageUrl,this.nextPageProps=e.nextPageProps,this.products=e.products.map(r=>new C(r)),this.cachedProducts=e.cachedProducts.map(r=>new Ie(r)),this.totalProducts=e.totalProducts,this.title=e.title,this.creativeIds=e.creativeIds,this.config=e.config,this.customImages=e.customImages??[],this.placement=e.placement,b()&&!this.config.skipAutoSmartSortOnLoad&&this.onLoad().catch(r=>v.error("Failed to run onLoad:",r))}static fromJSON(e){return new t(O(e))}hasNextPage(){return this.cachedProducts.length>0}async nextPage(){if(!this.hasNextPage())return;let e=this.cachedProducts.slice(0,this.nextPageProps.pageSize),r={app_mode:this.config.appMode,jane_device_id:this.config.identifier.jdid,object_ids:e.map(n=>n.objectId),search_attributes:this.nextPageProps.searchAttributes},s=await l.post(this.nextPageUrl,r),i=new Map(s.products?.map(n=>[n.object_id,n.search_attributes]));e.forEach(n=>{let o=i.get(n.objectId);o!==void 0&&this.products.push(new C({...n.serialize(),attributes:o}))}),this.cachedProducts=this.cachedProducts.slice(this.nextPageProps.pageSize)}async onLoad(){return this.loadPromise?this.loadPromise:(this.loadPromise=(async()=>{if(!b())return;let e={apiKey:this.config.apiKey,source:this.config.source};await Re(this.config.eventsEndpoint,e,{linkedId:this.config.identifier.jdid})})(),this.loadPromise)}serialize(){return{cachedProducts:this.cachedProducts.map(e=>e.serialize()),config:this.config,creativeIds:this.creativeIds,customImages:this.customImages,nextPageProps:this.nextPageProps,nextPageUrl:this.nextPageUrl,placement:this.placement,products:this.products.map(e=>e.serialize()),rowId:this.rowId,searchFacets:this.searchFacets,title:this.title,totalProducts:this.totalProducts}}toJSON(){return JSON.stringify(this.serialize())}},F=class{async createSmartSort(e){let r={apiKey:e.config.apiKey,source:e.config.source},s=h(e.config.endpoint,p.smart,r),i=h(e.config.pageEndpoint,p.page,r),n=this.buildSmartRequest(e),o=await l.post(s,n),{clickEndpoint:a,impressionEndpoint:c}=k(e.config.eventsEndpoint,r),{creative_ids:m,custom_images:P,products:u,row_id:d,search_facets:y,title:w}=o,{cachedProducts:D,products:E}=this.generateProducts({clickUrl:a,identifier:e.config.identifier,impressUrl:c,products:u}),T=(P??[]).map(M=>this.massageCustomImageData(M)).filter(M=>M!==void 0);return new x({cachedProducts:D,config:e.config,creativeIds:m,customImages:T,nextPageProps:{pageSize:"page_size"in n?n.page_size??60:60,searchAttributes:n.search_attributes??e.searchAttributes},nextPageUrl:i,placement:e.placement,products:E,rowId:d,searchFacets:y,title:w,totalProducts:o.nb_hits??0})}generateProducts(e){let{clickUrl:r,identifier:s,impressUrl:i,products:n}=e,o={cachedProducts:[],products:[]};return n?.forEach(a=>{let c={clickPayload:{adToken:a.ad_token,distinctId:s.mixpanelDistinctId??s.jdid,isAddToCart:!1,janeDeviceId:s.jdid,kevelToken:a.kevel_token,myHighD:a.my_high_d,productId:a.product_id,storeId:a.store_id},clickUrl:r,impressPayload:{distinctId:s.mixpanelDistinctId??s.jdid,engagements:[{adToken:a.ad_token,kevelToken:a.kevel_token,myHighD:a.my_high_d,productId:a.product_id}],janeDeviceId:s.jdid},impressUrl:i,isSponsored:!!a.flight_id,objectId:a.object_id};a.search_attributes!==void 0?o.products.push({...c,attributes:a.search_attributes}):o.cachedProducts.push(c)}),o}massageCustomImageData(e){if(e)return{headline:e.headline,imageUrl:e.image_url,intendedDisplay:e.intended_display,logoUrl:e.logo_url,overlayColor:e.overlay_color,positionX:e.position_x,positionY:e.position_y,scaleNumber:e.scale_number,textColor:e.text_color}}buildSmartRequest(e){let{config:r,searchAttributes:s,...i}=e,n={app_mode:r.appMode,distinct_id:r.identifier.mixpanelDistinctId,jane_device_id:r.identifier.jdid,pos_user_id:r.identifier.posUserId,search_attributes:s,user_id:r.identifier.userId};switch(i.placement){case"cart_toppers":{let{cartProductIds:o,posCartProductIds:a,storeId:c}=i;return{...n,cart_pos_product_ids:a,cart_product_ids:o,placement:"cart_toppers",store_id:c}}case"custom_image_row":{let{searchFilter:o,storeId:a}=i;return{...n,placement:"custom_image_row",search_filter:o,store_id:a}}case"menu_dynamic_row":{let{adMode:o,filterContext:a,pageContext:c,storeId:m}=i;return{...n,ad_mode:o??"default",filter_context:a,page_context:c,placement:"menu_dynamic_row",store_id:m}}case"menu_inline":{let{adMode:o,distinctByProduct:a,metadata:c,numColumns:m,searchFilter:P,searchQuery:u,searchSort:d,storeId:y,storeIds:w}=i;return{...n,ad_mode:o??"default",distinct_by_product:a,metadata:c,num_columns:m,placement:"menu_inline",search_filter:P,search_query:u,search_sort:ye(d),store_ids:w||[y]}}case"menu_inline_table":{let{disableAds:o,distinctByProduct:a,maxProducts:c,metadata:m,numColumns:P,pageSize:u,searchFacets:d,searchFilter:y,searchQuery:w,searchSort:D,storeId:E,storeIds:T}=i;return{...n,disable_ads:o,distinct_by_product:a,max_products:c,metadata:m,num_columns:P,page_size:u,placement:"menu_inline_table",search_attributes:s,search_facets:d,search_filter:y,search_query:w,search_sort:ye(D),store_ids:T||[E]}}case"menu_top_row":{let{searchFilter:o,storeId:a}=i,c=this.extractValidCreativeIds(e);return{...n,exclude_creative_ids:c,placement:"menu_top_row",search_filter:o,store_id:a}}case"pdp_row":{let{posProductId:o,productId:a,storeId:c}=i;return{...n,placement:"pdp_row",pos_product_id:o,product_id:a,store_id:c}}default:throw new I(`Invalid Smart Sort Placement: ${i.placement}`)}}extractValidCreativeIds(e){if(e.placement==="menu_top_row"&&"excludeCreativeIds"in e&&Array.isArray(e.excludeCreativeIds))return e.excludeCreativeIds.filter(r=>typeof r=="number")}};var dt=t=>t.placement==="specials",ut=t=>t.placement==="brand_specials",j=class{placement;title;constructor(e){this.title=e,this.placement="brand_specials"}},U=class{placement;title;constructor(e){this.title=e,this.placement="specials"}},q=class extends F{async createMultiPlacement(e){let r={apiKey:e.config.apiKey,source:e.config.source},s=h(e.config.endpoint,p.multi,r),i=h(e.config.pageEndpoint,p.page,r),n=this.buildMultiRequest(e),o=await l.post(s,n),{clickEndpoint:a,impressionEndpoint:c}=k(e.config.eventsEndpoint,r),m=[];for(let[P,u]of(o.placements||[]).entries())if(dt(u))m.push(new U(u.title));else if(ut(u))m.push(new j(u.title));else{let{creative_ids:d,custom_images:y,placement:w,products:D,row_id:E,search_facets:T,title:M}=u,{cachedProducts:Ue,products:qe}=this.generateProducts({clickUrl:a,identifier:e.config.identifier,impressUrl:c,products:D}),Ne=(y??[]).map(K=>this.massageCustomImageData(K)).filter(K=>K!==void 0);m.push(new x({cachedProducts:Ue,config:{...e.config,skipAutoSmartSortOnLoad:P===0?e.config.skipAutoSmartSortOnLoad:!0},creativeIds:d,customImages:Ne,nextPageProps:{pageSize:60,searchAttributes:n.search_attributes||[]},nextPageUrl:i,placement:w,products:qe,rowId:E,searchFacets:T,title:M,totalProducts:u.nb_hits??0}))}return m}buildMultiRequest(e){let{config:r,numColumns:s,searchAttributes:i,storeId:n,...o}=e,a={app_mode:r.appMode,distinct_id:r.identifier.mixpanelDistinctId,jane_device_id:r.identifier.jdid,num_columns:s,pos_user_id:r.identifier.posUserId,search_attributes:i,store_id:n,user_id:r.identifier.userId};switch(o.multiRequestType){case"custom":return{...a,placements:this.massageCustomPlacements(o.placements),type:"custom"};case"featured":return{...a,exclude_menu_top_row:o.excludeMenuTopRow??!1,type:"featured"};default:throw new I(`Invalid Multi Type: ${o.multiRequestType}`)}}massageCustomPlacements(e){let r=[];for(let s of e)switch(s.placement){case"best_selling":r.push({placement:"best_selling",title:s.title});break;case"brand_specials":r.push({placement:"brand_specials",title:s.title});break;case"buy_again_row":r.push({placement:"buy_again_row",title:s.title});break;case"custom_image_row":r.push({placement:"custom_image_row",search_filter:s.searchFilter});break;case"featured_row":r.push({placement:"featured_row",row_id:s.rowId});break;case"menu_dynamic_row":r.push({ad_mode:s.adMode??"default",filter_context:s.filterContext,page_context:s.pageContext,placement:"menu_dynamic_row"});break;case"menu_inline":r.push({ad_mode:s.adMode??"default",metadata:s.metadata,placement:"menu_inline",search_filter:s.searchFilter,search_query:s.searchQuery,search_sort:s.searchSort,title:s.title});break;case"menu_inline_table":r.push({disable_ads:s.disableAds,max_products:s.maxProducts,metadata:s.metadata,page_size:s.pageSize,placement:"menu_inline_table",search_facets:s.searchFacets,search_filter:s.searchFilter,search_query:s.searchQuery,search_sort:s.searchSort,title:s.title});break;case"menu_top_row":r.push({placement:"menu_top_row",search_filter:s.searchFilter});break;case"sale":r.push({placement:"sale",title:s.title});break;case"specials":r.push({placement:"specials",title:s.title});break;default:throw new I(`Invalid Custom Placement: ${s.placement}`)}return r}};import{nanoid as gt}from"nanoid";var Te=async t=>{let{apiKey:e,appMode:r,endpoint:s,identifier:i,searchFacets:n,searchFilter:o,searchQuery:a,source:c,storeId:m}=t,{jdid:P}=i||{},u=h(s,p.facets,{apiKey:e,source:c}),d={appMode:r,janeDeviceId:P,searchFacets:n,searchFilter:o,searchQuery:a,storeId:m};return(await l.post(u,d)).searchFacets??{}};var Me=async t=>{let{apiKey:e,endpoint:r,identifier:s,source:i,storeId:n,...o}=t,a=h(r,p.externalCheckout,{apiKey:e,source:i}),c={janeDeviceId:s.jdid,posOrderId:o.posOrderId,posUserId:o.posUserId||s.posUserId,products:o.products,storeId:n};return await l.post(a,c)};var N=class{async create(e){let{config:r,searchAttributes:s,storeId:i,...n}=e,o={apiKey:r.apiKey,source:r.source},a=h(r.endpoint,p.product,o),{clickEndpoint:c,impressionEndpoint:m}=k(r.eventsEndpoint,o),P={app_mode:r.appMode,distinct_id:r.identifier.mixpanelDistinctId,jane_device_id:r.identifier.jdid,pos_user_id:r.identifier.posUserId,search_attributes:s,store_id:i,user_id:r.identifier.userId},u=n.productId!==void 0?{...P,product_id:n.productId}:{...P,pos_product_id:n.posProductId},d=await l.post(a,u);return new C({attributes:d.search_attributes,clickPayload:{adToken:d.ad_token,distinctId:r.identifier.mixpanelDistinctId,isAddToCart:!1,janeDeviceId:r.identifier.jdid,kevelToken:d.kevel_token,myHighD:d.my_high_d,productId:d.product_id,storeId:i},clickUrl:c,impressPayload:{distinctId:r.identifier.mixpanelDistinctId??r.identifier.jdid,engagements:[{adToken:d.ad_token,kevelToken:d.kevel_token,myHighD:d.my_high_d,productId:d.product_id}],janeDeviceId:r.identifier.jdid},impressUrl:m,isSponsored:!!d.flight_id,objectId:d.object_id})}};var pt=t=>({activities:t.activities,avatar:t.avatar,comment:t.comment,createdAt:t.created_at,feelings:t.feelings,hasComment:t.has_comment,id:t.id,nickname:t.nickname,productId:t.product_id,rating:t.rating,storeId:t.store_id,storeName:t.store_name,updatedAt:t.updated_at,upvoteCount:t.upvote_count}),mt=t=>({activitiesDistribution:t.activities_distribution,averageRating:t.average_rating,distribution:t.distribution,feelingsDistribution:t.feelings_distribution,reviewCount:t.review_count}),lt=(t,e,r)=>{let s=t.total_count,i=Math.max(1,Math.ceil(s/r));return{aggregate:mt(t.aggregate),aiSummary:t.ai_summary,items:t.reviews.map(pt),pagination:{currentPage:e,hasNextPage:e<i,hasPreviousPage:e>1,pageSize:r,totalCount:s,totalPages:i},productId:t.product_id}},Ae=async t=>{let{activities:e,config:r,feelings:s,hasComment:i,page:n,pageSize:o,productId:a,ratings:c,sort:m}=t,P=n??1,u=o??50,d=h(r.endpoint,p.productReviews,{apiKey:r.apiKey,source:r.source}),y={activities:e,feelings:s,has_comment:i||void 0,page:n,page_size:o,product_id:a,ratings:c,sort:m},w=await l.post(d,y);return lt(w,P,u)},Oe=t=>{let e={[Symbol.asyncIterator]:async function*(){let r=1;for(;;){let s=await t(r);if(yield s,!s.pagination.hasNextPage)return;r+=1}}};return{pages:e,[Symbol.asyncIterator]:async function*(){for await(let r of e)yield*r.items}}};var je=async t=>{let{apiKey:e,eventsEndpoint:r,identifier:s,source:i,...n}=t,o=h(r,p.sessionEvent,{apiKey:e,source:i}),a={distinctId:s.mixpanelDistinctId,events:n.events,janeDeviceId:s.jdid};return await l.post(o,a)};function S(t,e,r){let s=r.value;if(!s)throw new Error("Decorator applied to invalid method descriptor");return r.value=async function(...i){return await this.init(),s.apply(this,i)},r}function R(t,e,r){let s=r.value;if(!s)throw new Error("Decorator applied to invalid method descriptor");return r.value=async function(...i){if(!this.rateLimiter)throw new Error("throttle decorator can only be used on JaneDM class methods");return this.rateLimiter.schedule(async()=>s.apply(this,i))},r}var z=class{burst;intervalMs;rate;tat=0;toleranceMs;constructor(e,r=1){if(e<=0)throw new I("rate must be > 0");if(r<1)throw new I("burst must be >= 1");this.rate=e,this.burst=Math.floor(r),this.intervalMs=1e3/this.rate,this.toleranceMs=(this.burst-1)*this.intervalMs}async schedule(e){let r=Date.now(),s=Math.max(0,this.tat-this.toleranceMs-r);this.tat=Math.max(this.tat,r)+this.intervalMs;let i=async()=>e();return s>0?new Promise((n,o)=>setTimeout(()=>i().then(n).catch(o),s)):i()}};var ht=/^https?:\/\//,Pt=/^(https?:\/\/)?(([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}|localhost)(:\d+)?(\/.*)?$/,G=(t,e)=>{let s=ht.test(t??e)?t??e:`https://${t}`,i=new URL(s);return Pt.test(i.toString())?i.protocol+"//"+i.host:e};var g=class{config;rateLimiter;initialized=!1;multiClient;productClient;smartSortClient;userProvidedJdid=!1;constructor(e,r){let{apiKey:s,endpoint:i,identifier:n}=e,{appMode:o="headless",eventsEndpoint:a,pageEndpoint:c,skipAutoSmartSortOnLoad:m=!1,source:P="sdk"}=r??{},u=G(i,"https://dmerch.iheartjane.com"),d=G(a,u),y=G(c,u);this.userProvidedJdid=!!n?.jdid,this.config={apiKey:s,appMode:o,endpoint:u,eventsEndpoint:d,identifier:n??{jdid:""},pageEndpoint:y,skipAutoSmartSortOnLoad:m,source:P},this.smartSortClient=new F,this.multiClient=new q,this.productClient=new N,this.rateLimiter=new z(10,20)}static generateJaneDeviceId(){return gt()}async fetchCartTopperRow(e){return await this.smartSortClient.createSmartSort({...e,config:this.config,placement:"cart_toppers"})}async fetchCustomImageRow(e){return this.smartSortClient.createSmartSort({...e,config:this.config,placement:"custom_image_row"})}async fetchCustomPlacements(e){return await this.multiClient.createMultiPlacement({config:this.config,multiRequestType:"custom",...e})}async fetchFacets(e){return Te({...e,...this.config})}async fetchFeaturedPlacements(e){return await this.multiClient.createMultiPlacement({config:this.config,multiRequestType:"featured",...e})}async fetchMenuRow(e){return this.smartSortClient.createSmartSort({...e,config:this.config,placement:"menu_inline"})}async fetchMenuTopRow(e){return this.smartSortClient.createSmartSort({...e,config:this.config,placement:"menu_top_row"})}async fetchProduct(e){return this.productClient.create({config:this.config,...e})}async fetchProductReviews(e){return Ae({config:this.config,...e})}async fetchRecommendedPDPRow(e){return await this.smartSortClient.createSmartSort({...e,config:this.config,placement:"pdp_row"})}async fetchRecommendedRow(e){return await this.smartSortClient.createSmartSort({...e,config:this.config,placement:"menu_dynamic_row"})}async fetchRecommendedSort(e){return await this.smartSortClient.createSmartSort({...e,config:this.config,placement:"menu_inline_table"})}getJaneDeviceId(){return this.config.identifier.jdid}async init(){this.initialized||(b()&&!this.userProvidedJdid&&await this.initializeClientSideJdid(),this.initialized=!0)}iterateProductReviews(e){return Oe(r=>this.fetchProductReviews({...e,page:r}))}async sendPosCheckout(e){return Me({...e,...this.config})}async sendSessionEvent(e){return je({...e,...this.config})}async initializeClientSideJdid(){let e={apiKey:this.config.apiKey,source:this.config.source},r=await xe(this.config.eventsEndpoint,e);_.set("jdid",r),this.config.identifier.jdid=r}};f([S,R],g.prototype,"fetchCartTopperRow",1),f([S,R],g.prototype,"fetchCustomImageRow",1),f([S,R],g.prototype,"fetchCustomPlacements",1),f([S,R],g.prototype,"fetchFacets",1),f([S,R],g.prototype,"fetchFeaturedPlacements",1),f([S,R],g.prototype,"fetchMenuRow",1),f([S,R],g.prototype,"fetchMenuTopRow",1),f([S,R],g.prototype,"fetchProduct",1),f([S,R],g.prototype,"fetchProductReviews",1),f([S,R],g.prototype,"fetchRecommendedPDPRow",1),f([S,R],g.prototype,"fetchRecommendedRow",1),f([S,R],g.prototype,"fetchRecommendedSort",1);export{L as AdMode,we as AppMode,j as BrandSpecials,B as DEFAULT_PAGE_SIZE,ze as IntendedDisplay,g as JaneDM,be as JaneDeviceIdSentinel,Ge as PageContextEnum,A as Placement,Ke as ProductKindEnum,Le as ReviewSortEnum,J as SearchSortEnum,x as SmartSort,C as SmartSortProduct,U as Specials,H as bestSellerRank,Q as categoryAndNameAsc,V as defaultOrder,$ as priceAsc,Z as priceDesc,X as priceEighthOunceAsc,Y as priceEighthOunceDesc,W as priceGramAsc,ee as priceGramDesc,te as priceHalfGramAsc,re as priceHalfGramDesc,se as priceHalfOunceAsc,ie as priceHalfOunceDesc,oe as priceOunceAsc,ne as priceOunceDesc,ae as priceQuarterOunceAsc,ce as priceQuarterOunceDesc,de as priceTwoGramAsc,ue as priceTwoGramDesc,pe as rating,me as recommendation,Je as searchSorts,le as thcPotencyAsc,he as thcPotencyDesc};
@@ -38,8 +38,7 @@ declare enum Placement {
38
38
  MenuTopRow = "menu_top_row",
39
39
  PdpRow = "pdp_row",
40
40
  Sale = "sale",
41
- Specials = "specials",
42
- VirtualBudtenderSearch = "virtual_budtender_search"
41
+ Specials = "specials"
43
42
  }
44
43
  declare enum ProductKindEnum {
45
44
  Edible = "edible",
@@ -61,6 +60,8 @@ declare enum ReviewSortEnum {
61
60
  declare enum SearchSortEnum {
62
61
  BestSellerRank = "best-seller-rank",
63
62
  CategoryAndNameAsc = "category-and-name-asc",
63
+ CbdDosageAsc = "cbd-dosage-asc",
64
+ CbdDosageDesc = "cbd-dosage-desc",
64
65
  Default = "default",
65
66
  PriceAsc = "price-asc",
66
67
  PriceDesc = "price-desc",
@@ -80,6 +81,8 @@ declare enum SearchSortEnum {
80
81
  PriceTwoGramDesc = "price-two-gram-desc",
81
82
  Rating = "rating",
82
83
  Recommendation = "recommendation",
84
+ ThcDosageAsc = "thc-dosage-asc",
85
+ ThcDosageDesc = "thc-dosage-desc",
83
86
  ThcPotencyAsc = "thc-potency-asc",
84
87
  ThcPotencyDesc = "thc-potency-desc"
85
88
  }
@@ -108,7 +111,7 @@ type Click = {
108
111
  */
109
112
  distinctId?: string;
110
113
  /**
111
- * Should be true if the click ads the product to the cart
114
+ * Should be true if the click adds the product to the cart
112
115
  */
113
116
  isAddToCart?: boolean;
114
117
  /**
@@ -193,16 +196,13 @@ interface Product {
193
196
  }
194
197
  interface ProductReviewsResponse$1 {
195
198
  aggregate: ReviewAggregate;
199
+ ai_summary?: string;
196
200
  product_id: number;
197
201
  reviews: Review[];
198
202
  total_count: number;
199
203
  }
200
204
  interface ProductsPlacementResponse {
201
205
  creative_ids?: number[];
202
- /**
203
- * @deprecated true
204
- */
205
- custom_image_data?: CustomImageData$1;
206
206
  custom_images?: CustomImageData$1[];
207
207
  nb_hits?: number;
208
208
  placement?: Placement;
@@ -284,74 +284,6 @@ interface SpecialsPlacementResponse {
284
284
  specials?: SpecialResponse[];
285
285
  title?: string;
286
286
  }
287
- type VirtualBudtenderProduct = {
288
- /**
289
- * AI-generated explanation for why this product matches the query
290
- *
291
- * @example This product contains CBD which is known for its calming effects and may help with sleep
292
- */
293
- reasoning?: string;
294
- /**
295
- * Relevance score for this product (0 to 10)
296
- *
297
- * @example 8.5
298
- * @format float
299
- * @maximum 10
300
- * @minimum 0
301
- */
302
- score?: number;
303
- } & Product;
304
- interface VirtualBudtenderQuery {
305
- /**
306
- * Human-readable display text for the query
307
- *
308
- * @example Help me sleep
309
- */
310
- displayText: string;
311
- /**
312
- * The natural language query string
313
- *
314
- * @example help me sleep
315
- */
316
- query: string;
317
- }
318
- interface VirtualBudtenderSearchResponse {
319
- /**
320
- * AI-generated response in HTML format
321
- *
322
- * @example <p>Based on your request for sleep help, I recommend these products...</p>
323
- */
324
- htmlResponse: string;
325
- /**
326
- * AI-generated response in markdown format
327
- *
328
- * @example Based on your request for sleep help, I recommend these products that contain CBD and indica strains...
329
- */
330
- markdownResponse: string;
331
- /**
332
- * List of products matching the query
333
- */
334
- products: VirtualBudtenderProduct[];
335
- /**
336
- * The original query that was searched
337
- *
338
- * @example help me sleep
339
- */
340
- query: string;
341
- /**
342
- * Total number of products found
343
- *
344
- * @example 15
345
- * @minimum 0
346
- */
347
- totalResults: number;
348
- /**
349
- * Raw AI-generated response without formatting
350
- *
351
- * @example Based on your request for sleep help, I recommend these products that contain CBD and indica strains...
352
- */
353
- unformattedResponse: string;
354
- }
355
287
 
356
288
  /**
357
289
  * Configuration options for the Jane DM SDK client.
@@ -597,6 +529,12 @@ type ProductReviewsIterable = PaginatedIterable<ProductReview, ProductReviewsRes
597
529
  */
598
530
  interface ProductReviewsResponse extends PaginatedResponse<ProductReview> {
599
531
  aggregate: ProductReviewsAggregate;
532
+ /**
533
+ * AI-generated summary of the product's reviews. Absent when no
534
+ * summary has been generated for the product. Whole-product: does not
535
+ * vary with the request's filters or pagination.
536
+ */
537
+ aiSummary?: string;
600
538
  productId: number;
601
539
  }
602
540
 
@@ -1072,4 +1010,4 @@ interface SmartSortProps<ProductShape extends object = Record<string, unknown>>
1072
1010
  totalProducts: number;
1073
1011
  }
1074
1012
 
1075
- export { priceEighthOunceDesc as $, AdMode as A, type JaneDMConfig as B, type Click as C, DEFAULT_PAGE_SIZE as D, type JaneDMIdentifiers as E, type FilterContext as F, JaneDeviceIdSentinel as G, type PaginationInfo as H, type Impression as I, type JaneDMPublicConfig as J, ProductKindEnum as K, type ProductReview as L, type ProductReviewsAggregate as M, ReviewSortEnum as N, type SearchSort as O, Placement as P, type SmartSortNextPageProps as Q, type RequiredConfig as R, SearchSortEnum as S, type VirtualBudtenderSearchResponse as T, bestSellerRank as U, type VirtualBudtenderQuery as V, categoryAndNameAsc as W, defaultOrder as X, priceAsc as Y, priceDesc as Z, priceEighthOunceAsc as _, PageContextEnum as a, priceGramAsc as a0, priceGramDesc as a1, priceHalfGramAsc as a2, priceHalfGramDesc as a3, priceHalfOunceAsc as a4, priceHalfOunceDesc as a5, priceOunceAsc as a6, priceOunceDesc as a7, priceQuarterOunceAsc as a8, priceQuarterOunceDesc as a9, priceTwoGramAsc as aa, priceTwoGramDesc as ab, rating as ac, recommendation as ad, searchSorts as ae, thcPotencyAsc as af, thcPotencyDesc as ag, type PlacementResponse as ah, type Product as ai, type ProductReviewsResponse$1 as aj, type ProductsPlacementResponse as ak, type PageResponse as al, type CustomImageData$1 as am, type CustomImageData as b, type SmartSortProductProps as c, type SmartSortClickIntent as d, type SmartSortProps as e, type ConversionExternalProduct as f, type SessionEvent as g, type JaneDMInternalConfig as h, type FetchCartTopperRowProps as i, type FetchCustomImageRowProps as j, type Facets as k, type FetchMenuRowProps as l, type FetchMenuTopRowProps as m, type FetchProductReviewsProps as n, type ProductReviewsResponse as o, type FetchRecommendedPDPRowProps as p, type FetchRecommendedRowProps as q, type FetchRecommendedSortProps as r, type IterateProductReviewsProps as s, type ProductReviewsIterable as t, AppMode as u, type FetchCartTopperRowByPosProductId as v, type FetchCartTopperRowByProductProps as w, type FetchRecommendedPDPRowByPosProductId as x, type FetchRecommendedPDPRowByProductId as y, IntendedDisplay as z };
1013
+ export { priceHalfGramDesc as $, AdMode as A, JaneDeviceIdSentinel as B, type CustomImageData as C, DEFAULT_PAGE_SIZE as D, type PaginationInfo as E, type FilterContext as F, ProductKindEnum as G, type ProductReview as H, type IterateProductReviewsProps as I, type JaneDMPublicConfig as J, type ProductReviewsAggregate as K, ReviewSortEnum as L, type SearchSort as M, type SmartSortNextPageProps as N, bestSellerRank as O, Placement as P, categoryAndNameAsc as Q, type RequiredConfig as R, SearchSortEnum as S, defaultOrder as T, priceAsc as U, priceDesc as V, priceEighthOunceAsc as W, priceEighthOunceDesc as X, priceGramAsc as Y, priceGramDesc as Z, priceHalfGramAsc as _, PageContextEnum as a, priceHalfOunceAsc as a0, priceHalfOunceDesc as a1, priceOunceAsc as a2, priceOunceDesc as a3, priceQuarterOunceAsc as a4, priceQuarterOunceDesc as a5, priceTwoGramAsc as a6, priceTwoGramDesc as a7, rating as a8, recommendation as a9, searchSorts as aa, thcPotencyAsc as ab, thcPotencyDesc as ac, type PlacementResponse as ad, type Product as ae, type ProductReviewsResponse$1 as af, type ProductsPlacementResponse as ag, type PageResponse as ah, type CustomImageData$1 as ai, type SmartSortProductProps as b, type SmartSortClickIntent as c, type SmartSortProps as d, type ConversionExternalProduct as e, type SessionEvent as f, type JaneDMInternalConfig as g, type FetchCartTopperRowProps as h, type FetchCustomImageRowProps as i, type Facets as j, type FetchMenuRowProps as k, type FetchMenuTopRowProps as l, type FetchProductReviewsProps as m, type ProductReviewsResponse as n, type FetchRecommendedPDPRowProps as o, type FetchRecommendedRowProps as p, type FetchRecommendedSortProps as q, type ProductReviewsIterable as r, AppMode as s, type FetchCartTopperRowByPosProductId as t, type FetchCartTopperRowByProductProps as u, type FetchRecommendedPDPRowByPosProductId as v, type FetchRecommendedPDPRowByProductId as w, IntendedDisplay as x, type JaneDMConfig as y, type JaneDMIdentifiers as z };