@esolve/ng-esolve-connect 0.143.0 → 0.145.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.
@@ -304,7 +304,7 @@ class EsolveCategoryTreeItem {
304
304
  get tiny_image_src() {
305
305
  return this.getImagePath('tiny');
306
306
  }
307
- constructor(type, esolve_id, parent_id, description, sef_description, short_description, sort_priority, active, display_only, image_name, seo_title, seo_keywords, seo_description, children) {
307
+ constructor(type, esolve_id, parent_id, description, sef_description, short_description, sort_priority, active, display_only, image_name, seo_title, seo_keywords, seo_description, children, cart_sort, stock_sort) {
308
308
  this.type = type;
309
309
  this.esolve_id = esolve_id;
310
310
  this.parent_id = parent_id;
@@ -316,6 +316,8 @@ class EsolveCategoryTreeItem {
316
316
  this.display_only = display_only;
317
317
  this.image_name = image_name;
318
318
  this.id = '';
319
+ this.cart_sort = null;
320
+ this.stock_sort = null;
319
321
  this.image_path = '';
320
322
  if (this.type === 'category') {
321
323
  this.id = `<<CAT>>${this.esolve_id}`;
@@ -332,6 +334,18 @@ class EsolveCategoryTreeItem {
332
334
  seo_title = this.description;
333
335
  }
334
336
  this.seo_details = new EsolveSeoInfo(seo_title, seo_description, seo_keywords);
337
+ if (cart_sort) {
338
+ this.cart_sort = {
339
+ field: cart_sort.sort,
340
+ order: cart_sort.order,
341
+ };
342
+ }
343
+ if (stock_sort) {
344
+ this.stock_sort = {
345
+ field: stock_sort.sort,
346
+ order: stock_sort.order,
347
+ };
348
+ }
335
349
  }
336
350
  getImagePath(image_size) {
337
351
  if (this.image_name !== '') {
@@ -473,13 +487,13 @@ class EsolveCategoryTreeService {
473
487
  esolve_id = tree_record.id;
474
488
  parent_id = tree_record.menu_id;
475
489
  }
476
- tree_items.push(new EsolveCategoryTreeItem(tree_record.type, esolve_id, parent_id, tree_record.description, tree_record.sef_description, tree_record.seo_description, tree_record.sort_priority, tree_record.active, tree_record.display_only, tree_record.image, tree_record.seo_page_title, tree_record.seo_keywords, tree_record.short_description, children));
490
+ tree_items.push(new EsolveCategoryTreeItem(tree_record.type, esolve_id, parent_id, tree_record.description, tree_record.sef_description, tree_record.seo_description, tree_record.sort_priority, tree_record.active, tree_record.display_only, tree_record.image, tree_record.seo_page_title, tree_record.seo_keywords, tree_record.short_description, children, tree_record.cart_sort, tree_record.stock_sort));
477
491
  }
478
492
  }
479
493
  return tree_items;
480
494
  }
481
495
  processTreeItem(record) {
482
- return new EsolveCategoryTreeItem(record.type, record.id, record.parent_id, record.description, record.sef_description, record.short_description, record.sort_priority, record.active, record.display_only, record.image, record.seo_page_title, record.seo_keywords, record.seo_description);
496
+ return new EsolveCategoryTreeItem(record.type, record.id, record.parent_id, record.description, record.sef_description, record.short_description, record.sort_priority, record.active, record.display_only, record.image, record.seo_page_title, record.seo_keywords, record.seo_description, undefined, record.cart_sort, record.stock_sort);
483
497
  }
484
498
  processID(id) {
485
499
  let type;
@@ -2284,12 +2298,7 @@ class EsolveStockService {
2284
2298
  if (options.is_active) {
2285
2299
  params = params.set('is_active', options.is_active);
2286
2300
  }
2287
- if (options.override_fields_set) {
2288
- params = params.set('override_fields_set', options.override_fields_set);
2289
- }
2290
- if (options.custom_field_config_names) {
2291
- params = params.set('custom_field_config_names', options.custom_field_config_names.join(','));
2292
- }
2301
+ params = this.applyFieldSetOptions(params, options);
2293
2302
  if (options.category_id) {
2294
2303
  params = params.set('category_id', options.category_id);
2295
2304
  }
@@ -2362,10 +2371,14 @@ class EsolveStockService {
2362
2371
  *
2363
2372
  * @param code Stock item code
2364
2373
  */
2365
- getLinkedItems(code) {
2374
+ getLinkedItems(code, options) {
2375
+ let params = new HttpParams().set('code', code);
2376
+ if (options) {
2377
+ params = this.applyFieldSetOptions(params, options);
2378
+ }
2366
2379
  return this.http
2367
2380
  .get(`${this.config.api_url}/get-linked-items.php`, {
2368
- params: { code },
2381
+ params,
2369
2382
  })
2370
2383
  .pipe(map((response) => {
2371
2384
  if (response.records === undefined ||
@@ -2398,6 +2411,7 @@ class EsolveStockService {
2398
2411
  params = params.set('order', sort.order);
2399
2412
  }
2400
2413
  }
2414
+ params = this.applyFieldSetOptions(params, options);
2401
2415
  }
2402
2416
  return this.http
2403
2417
  .get(`${this.config.api_url}/get-recipe-items.php`, {
@@ -2442,6 +2456,7 @@ class EsolveStockService {
2442
2456
  if (options.media_id) {
2443
2457
  params = params.append('media_id', options.media_id);
2444
2458
  }
2459
+ params = this.applyFieldSetOptions(params, options);
2445
2460
  return this.http
2446
2461
  .get(`${this.config.api_url}/get-media-linked-items.php`, {
2447
2462
  params,
@@ -2460,10 +2475,14 @@ class EsolveStockService {
2460
2475
  *
2461
2476
  * @param code Stock item code
2462
2477
  */
2463
- getSuggestedItems(code) {
2478
+ getSuggestedItems(code, options) {
2479
+ let params = new HttpParams().set('code', code);
2480
+ if (options) {
2481
+ params = this.applyFieldSetOptions(params, options);
2482
+ }
2464
2483
  return this.http
2465
2484
  .get(`${this.config.api_url}/get-suggested-items.php`, {
2466
- params: { code },
2485
+ params,
2467
2486
  })
2468
2487
  .pipe(map((response) => {
2469
2488
  if (response.records === undefined ||
@@ -2588,6 +2607,22 @@ class EsolveStockService {
2588
2607
  }
2589
2608
  return params;
2590
2609
  }
2610
+ /**
2611
+ * Applies the shared field-set options (`override_fields_set` and
2612
+ * `custom_field_config_names`) to the given HTTP params.
2613
+ *
2614
+ * @param params HTTP client parameters
2615
+ * @param options Field set options
2616
+ */
2617
+ applyFieldSetOptions(params, options) {
2618
+ if (options.override_fields_set) {
2619
+ params = params.set('override_fields_set', options.override_fields_set);
2620
+ }
2621
+ if (options.custom_field_config_names) {
2622
+ params = params.set('custom_field_config_names', options.custom_field_config_names.join(','));
2623
+ }
2624
+ return params;
2625
+ }
2591
2626
  /**
2592
2627
  * Processes the eSolve stock item record and converts it to an object.
2593
2628
  *
@@ -6207,6 +6242,7 @@ class EsolveLocation {
6207
6242
  this.website_url = record.website_url;
6208
6243
  this.image_name = record.image_name ?? '';
6209
6244
  this.image_last_modified = record.image_last_modified ?? '';
6245
+ this.sef_name = record.sef_name ?? '';
6210
6246
  this.address = new EsolveLocationAddress(record.street, record.suburb, record.city, record.province, record.country, record.postal_code, +record.latitude, +record.longitude);
6211
6247
  this.pobox_address = new EsolveLocationPOBoxAddress(record.pobox, record.pobox_city, record.pobox_postal_code);
6212
6248
  const telnumbers = [];
@@ -8941,6 +8977,88 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImpo
8941
8977
  }]
8942
8978
  }] });
8943
8979
 
8980
+ class EsolveEnquiryFormField {
8981
+ constructor(record) {
8982
+ this.id = 0;
8983
+ this.identifier = '';
8984
+ this.type = '';
8985
+ this.label = '';
8986
+ this.description = '';
8987
+ this.required = false;
8988
+ this.placeholder = '';
8989
+ this.character_length = 255;
8990
+ this.options = [];
8991
+ this.accept = '';
8992
+ this.layout_row = 0;
8993
+ this.presentational = false;
8994
+ if (record) {
8995
+ this.id = +(record.id ?? 0);
8996
+ this.identifier = record.identifier ?? '';
8997
+ this.type = record.type ?? '';
8998
+ this.label = record.label ?? '';
8999
+ this.description = record.description ?? '';
9000
+ this.required = !!record.required;
9001
+ this.layout_row = +(record.layout_row ?? 0);
9002
+ this.presentational = !!record.presentational;
9003
+ if ('placeholder' in record) {
9004
+ this.placeholder = record.placeholder ?? '';
9005
+ }
9006
+ if ('character_length' in record) {
9007
+ this.character_length = +(record.character_length ?? 255);
9008
+ }
9009
+ if ('options' in record) {
9010
+ this.options = record.options ?? [];
9011
+ }
9012
+ if ('accept' in record) {
9013
+ this.accept = record.accept ?? '';
9014
+ }
9015
+ }
9016
+ }
9017
+ /**
9018
+ * Presentational fields (e.g. section headings) carry no answer and should
9019
+ * be rendered as layout/grouping markers rather than inputs.
9020
+ */
9021
+ isPresentational() {
9022
+ return this.presentational || this.type === 'heading';
9023
+ }
9024
+ }
9025
+
9026
+ class EsolveEnquiryFormSubmissionResult {
9027
+ constructor(result) {
9028
+ this.success = false;
9029
+ this.message = '';
9030
+ this.invalid_field_identifiers = [];
9031
+ this.success = result.success;
9032
+ this.message = result.message;
9033
+ this.invalid_field_identifiers =
9034
+ result.invalid_field_identifiers ?? [];
9035
+ }
9036
+ }
9037
+
9038
+ class EsolveEnquiryForm {
9039
+ constructor(record) {
9040
+ this.id = 0;
9041
+ this.identifier = '';
9042
+ this.title = '';
9043
+ this.description = '';
9044
+ this.success_message = '';
9045
+ this.fields = [];
9046
+ if (record) {
9047
+ this.id = +(record.id ?? 0);
9048
+ this.identifier = record.identifier ?? '';
9049
+ this.title = record.title ?? '';
9050
+ this.description = record.description ?? '';
9051
+ this.success_message = record.success_message ?? '';
9052
+ this.fields = this.processFields(record.fields ?? []);
9053
+ }
9054
+ }
9055
+ processFields(fields) {
9056
+ return fields.map((field) => {
9057
+ return new EsolveEnquiryFormField(field);
9058
+ });
9059
+ }
9060
+ }
9061
+
8944
9062
  class EsolveEnquiryResult extends EsolveResponseResult {
8945
9063
  constructor(response) {
8946
9064
  super(response);
@@ -8949,6 +9067,80 @@ class EsolveEnquiryResult extends EsolveResponseResult {
8949
9067
  }
8950
9068
  }
8951
9069
 
9070
+ class EsolveEnquiryFormsService {
9071
+ constructor() {
9072
+ this.http = inject(HttpClient);
9073
+ this.config = inject(EsolveConfigService);
9074
+ this.errorHandler = inject(EsolveErrorHandlerService);
9075
+ }
9076
+ /**
9077
+ * Fetch an enquiry form definition by its id or string identifier.
9078
+ *
9079
+ * @param params - Either `{ id: number }` or `{ identifier: string }`
9080
+ *
9081
+ * @returns an Observable of type EsolveEnquiryForm
9082
+ */
9083
+ getEnquiryForm(params) {
9084
+ let httpParams = new HttpParams();
9085
+ if ('id' in params) {
9086
+ httpParams = httpParams.set('enquiry_forms_id', params.id);
9087
+ }
9088
+ else {
9089
+ httpParams = httpParams.set('identifier', params.identifier);
9090
+ }
9091
+ return this.http
9092
+ .get(`${this.config.api_url}/get-enquiry-form.php`, { params: httpParams })
9093
+ .pipe(map((response) => {
9094
+ const record = response.records;
9095
+ if (!record || Array.isArray(record)) {
9096
+ throw response;
9097
+ }
9098
+ return new EsolveEnquiryForm(record);
9099
+ }));
9100
+ }
9101
+ /**
9102
+ * Submit a completed enquiry form.
9103
+ *
9104
+ * Resolves with the submit result — does not reject on validation failure.
9105
+ * Check `result.success` and `result.invalid_field_identifiers` to handle
9106
+ * field-level validation errors without clearing the form.
9107
+ *
9108
+ * Captcha fields (`captcha_key`, `captcha_code`) should be appended to
9109
+ * `form_data` by the caller when captcha is enabled.
9110
+ *
9111
+ * @param params - Either `{ id: number }` or `{ identifier: string }`
9112
+ * @param form_data - Completed form data; file fields appended as `File` objects
9113
+ *
9114
+ * @returns an Observable of type EsolveEnquiryFormSubmissionResult
9115
+ */
9116
+ submitEnquiryForm(params, form_data) {
9117
+ let http_params = new HttpParams();
9118
+ if ('id' in params) {
9119
+ http_params = http_params.set('enquiry_forms_id', params.id);
9120
+ }
9121
+ else {
9122
+ http_params = http_params.set('identifier', params.identifier);
9123
+ }
9124
+ return this.http
9125
+ .post(`${this.config.api_url}/set-enquiry-form-submission.php`, form_data, {
9126
+ responseType: 'json',
9127
+ observe: 'body',
9128
+ params: http_params,
9129
+ })
9130
+ .pipe(map((http_response) => new EsolveEnquiryFormSubmissionResult(http_response.additional_data)), catchError((errorRes) => {
9131
+ return this.errorHandler.handleHttpPostError('set-enquiry-form-submission', errorRes);
9132
+ }));
9133
+ }
9134
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: EsolveEnquiryFormsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
9135
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: EsolveEnquiryFormsService, providedIn: 'root' }); }
9136
+ }
9137
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: EsolveEnquiryFormsService, decorators: [{
9138
+ type: Injectable,
9139
+ args: [{
9140
+ providedIn: 'root',
9141
+ }]
9142
+ }] });
9143
+
8952
9144
  class EsolveEnquiryService {
8953
9145
  constructor() {
8954
9146
  this.config = inject(EsolveConfigService);
@@ -9006,10 +9198,22 @@ class EsolveWishlistService {
9006
9198
  /**
9007
9199
  * Retrieves the current wishlist
9008
9200
  *
9201
+ * @param options Optional field-set options controlling which stock
9202
+ * fields are returned for each wishlist item
9203
+ *
9009
9204
  * @returns An `Observable` with an array of cart items
9010
9205
  */
9011
- getWishlist() {
9012
- return this.getWishlistRecords().pipe(map((response) => {
9206
+ getWishlist(options) {
9207
+ let params = new HttpParams();
9208
+ if (options) {
9209
+ if (options.override_fields_set) {
9210
+ params = params.set('override_fields_set', options.override_fields_set);
9211
+ }
9212
+ if (options.custom_field_config_names) {
9213
+ params = params.set('custom_field_config_names', options.custom_field_config_names.join(','));
9214
+ }
9215
+ }
9216
+ return this.getWishlistRecords(params).pipe(map((response) => {
9013
9217
  if (response.records === undefined) {
9014
9218
  throw response;
9015
9219
  }
@@ -9652,6 +9856,76 @@ class EsolveCompetitionEntryResult extends EsolveResponseResult {
9652
9856
  }
9653
9857
  }
9654
9858
 
9859
+ class EsolveCompetitionEntry {
9860
+ constructor(record) {
9861
+ this.id = '';
9862
+ this.code = '';
9863
+ this.title = '';
9864
+ this.submitted_by = '';
9865
+ this.file_type = 'image';
9866
+ this.file_url = '';
9867
+ this.preview_url = '';
9868
+ this.date_submitted = '';
9869
+ this.status = 'pending';
9870
+ this.up_votes = 0;
9871
+ this.down_votes = 0;
9872
+ this.has_voted = false;
9873
+ if (record) {
9874
+ this.id = record.id ?? '';
9875
+ this.code = record.code ?? '';
9876
+ this.title = record.title ?? '';
9877
+ this.submitted_by = record.submitted_by ?? '';
9878
+ this.file_type = record.file_type ?? 'image';
9879
+ this.file_url = record.file_url ?? '';
9880
+ this.preview_url = record.preview_url ?? '';
9881
+ this.date_submitted = record.date_submitted ?? '';
9882
+ this.status = record.status ?? 'pending';
9883
+ this.up_votes = +(record.up_votes ?? 0);
9884
+ this.down_votes = +(record.down_votes ?? 0);
9885
+ this.has_voted = !!record.has_voted;
9886
+ this.text_content = record.text_content;
9887
+ }
9888
+ }
9889
+ }
9890
+
9891
+ /**
9892
+ * Public competition statistics returned by the `get-competitions.php` service.
9893
+ */
9894
+ class EsolveCompetitionStats {
9895
+ constructor(record) {
9896
+ /**
9897
+ * Total approved entries submitted to the competition.
9898
+ */
9899
+ this.total_entries = 0;
9900
+ /**
9901
+ * Total up + down votes cast across all competition entries.
9902
+ */
9903
+ this.total_votes = 0;
9904
+ if (record) {
9905
+ this.total_entries = +(record.total_entries ?? 0);
9906
+ this.total_votes = +(record.total_votes ?? 0);
9907
+ }
9908
+ }
9909
+ }
9910
+
9911
+ class EsolveCompetitionVoteResult extends EsolveResponseResult {
9912
+ constructor(record) {
9913
+ super(record);
9914
+ this.success = false;
9915
+ this.entry_id = '';
9916
+ this.dowhat = 'up';
9917
+ this.up_votes = 0;
9918
+ this.down_votes = 0;
9919
+ this.has_voted = false;
9920
+ this.success = true;
9921
+ this.entry_id = record.entry_id ?? '';
9922
+ this.dowhat = record.dowhat ?? 'up';
9923
+ this.up_votes = +(record.up_votes ?? 0);
9924
+ this.down_votes = +(record.down_votes ?? 0);
9925
+ this.has_voted = !!record.has_voted;
9926
+ }
9927
+ }
9928
+
9655
9929
  class EsolveCompetitionWinner {
9656
9930
  constructor(record) {
9657
9931
  /**
@@ -9732,6 +10006,18 @@ class EsolveCompetition {
9732
10006
  * Competition requires text submission
9733
10007
  */
9734
10008
  this.require_text = false;
10009
+ /**
10010
+ * Allow document (PDF/PPTX/DOCX) submissions
10011
+ */
10012
+ this.require_document = false;
10013
+ /**
10014
+ * Whether public voting on entries is enabled for this competition
10015
+ */
10016
+ this.enable_voting = true;
10017
+ /**
10018
+ * Whether new entries require moderator approval before they appear
10019
+ */
10020
+ this.require_approval = false;
9735
10021
  /**
9736
10022
  * List of competition winners
9737
10023
  */
@@ -9740,6 +10026,10 @@ class EsolveCompetition {
9740
10026
  * Display a count down timer
9741
10027
  */
9742
10028
  this.display_timer = false;
10029
+ /**
10030
+ * Public competition statistics (entries and votes)
10031
+ */
10032
+ this.stats = new EsolveCompetitionStats();
9743
10033
  if (record) {
9744
10034
  this.id = +(record.id ?? 0);
9745
10035
  this.identifier = record.identifier ?? '';
@@ -9762,8 +10052,14 @@ class EsolveCompetition {
9762
10052
  this.require_audio = !!+(record.audio_attachment ?? false);
9763
10053
  this.require_video = !!+(record.video_attachment ?? false);
9764
10054
  this.require_image = !!+(record.image_attachment ?? false);
10055
+ this.require_document = !!+(record.document_attachment ?? false);
9765
10056
  this.require_text = !!+(record.text ?? false);
10057
+ this.enable_voting = !!+(record.enable_voting ?? true);
10058
+ this.require_approval = !!+(record.require_approval ?? false);
9766
10059
  this.display_timer = !!+(record.display_timer ?? false);
10060
+ if (record.stats) {
10061
+ this.stats = new EsolveCompetitionStats(record.stats);
10062
+ }
9767
10063
  const winners = record.winners;
9768
10064
  if (winners && winners.length > 0) {
9769
10065
  for (const winner of winners) {
@@ -9859,6 +10155,49 @@ class EsolveCompetitionsService {
9859
10155
  return this.errorHandler.handleHttpPostError('set-competition-entry', errorRes);
9860
10156
  }));
9861
10157
  }
10158
+ /**
10159
+ * Retrieve a paginated list of approved entries for a competition.
10160
+ *
10161
+ * @param competitions_id - eSolve ID of the competition.
10162
+ * @param page - 1-based page number (optional).
10163
+ * @param rows - entries per page (optional).
10164
+ *
10165
+ * @returns an Observable of EsolveCompetitionEntry[].
10166
+ */
10167
+ getCompetitionEntries(competitions_id, page, rows) {
10168
+ let params = new HttpParams({
10169
+ fromObject: { competitions_id },
10170
+ });
10171
+ if (page != null) {
10172
+ params = params.set('page', page);
10173
+ }
10174
+ if (rows != null) {
10175
+ params = params.set('rows', rows);
10176
+ }
10177
+ return this.http
10178
+ .get(`${this.config.api_url}/get-competition-entries.php`, { params })
10179
+ .pipe(map$1((response) => (response.records ?? []).map((record) => new EsolveCompetitionEntry(record))), catchError$1(() => of([])));
10180
+ }
10181
+ /**
10182
+ * Cast or retract a vote on a competition entry.
10183
+ *
10184
+ * @param competition_entry_id - UUID of the entry to vote on.
10185
+ * @param dowhat - `'up'` to upvote (default) or `'down'` to downvote.
10186
+ *
10187
+ * @returns an Observable of EsolveCompetitionVoteResult.
10188
+ */
10189
+ setCompetitionVote(competition_entry_id, dowhat = 'up') {
10190
+ const body = { competition_entry_id, dowhat };
10191
+ return this.http
10192
+ .post(`${this.config.api_url}/set-competition-vote.php`, body, {
10193
+ headers: {
10194
+ 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;',
10195
+ },
10196
+ responseType: 'json',
10197
+ observe: 'body',
10198
+ })
10199
+ .pipe(map$1((http_response) => this.responseHandler.validateSingleHttpResponse(http_response, (response) => new EsolveCompetitionVoteResult(response))), catchError$1((errorRes) => this.errorHandler.handleHttpPostError('set-competition-vote', errorRes)));
10200
+ }
9862
10201
  getCompetitionSingle(params) {
9863
10202
  return this.getCompetitionRecords(params).pipe(map$1((records) => {
9864
10203
  const record = records[0];
@@ -11047,6 +11386,142 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImpo
11047
11386
  }]
11048
11387
  }] });
11049
11388
 
11389
+ /**
11390
+ * One labelled product grid within a `product_catalog` (`multi_grid`) chat
11391
+ * result — e.g. "Under R500", "Best sellers". `items` are built the same way
11392
+ * `EsolveChatIntentResult.items` builds `product_search` results, just
11393
+ * grouped under a label instead of a single flat list. `link` is an optional
11394
+ * "View more" target the consumer can build a route from — `null` when the
11395
+ * server couldn't resolve any of this group's filters to a real
11396
+ * category/subcategory/brand/tag.
11397
+ */
11398
+ class EsolveChatProductGroup {
11399
+ constructor(record) {
11400
+ this.label = record.label ?? '';
11401
+ this.items = (record.items ?? []).map((r) => new EsolveStockItemBase(r));
11402
+ this.link = record.link ?? null;
11403
+ }
11404
+ }
11405
+
11406
+ class EsolveChatIntentResult {
11407
+ constructor(response) {
11408
+ this.intent = response.intent;
11409
+ this.parameters = response.parameters;
11410
+ this.reply = response.reply;
11411
+ this.history = response.history;
11412
+ this.context = response.context ?? '';
11413
+ this.display_hint = response.display_hint ?? 'text';
11414
+ this.suggestions = response.suggestions ?? [];
11415
+ const data = response.data;
11416
+ if ((this.intent === 'product_search' || this.intent === 'add_to_basket') &&
11417
+ Array.isArray(data)) {
11418
+ // For `add_to_basket`, `items` holds the single item that was added
11419
+ // to the cart (empty when no match was found or the add failed).
11420
+ this.items = data.map((r) => new EsolveStockItemBase(r));
11421
+ this.groups = [];
11422
+ this.locations = [];
11423
+ this.brands = [];
11424
+ }
11425
+ else if (this.intent === 'product_catalog' && Array.isArray(data)) {
11426
+ this.items = [];
11427
+ this.groups = data.map((g) => new EsolveChatProductGroup(g));
11428
+ this.locations = [];
11429
+ this.brands = [];
11430
+ }
11431
+ else if (this.intent === 'directions' && Array.isArray(data)) {
11432
+ this.items = [];
11433
+ this.groups = [];
11434
+ this.locations = data.map((r) => new EsolveLocation(r));
11435
+ this.brands = [];
11436
+ }
11437
+ else if (this.intent === 'list_brands' && Array.isArray(data)) {
11438
+ this.items = [];
11439
+ this.groups = [];
11440
+ this.locations = [];
11441
+ this.brands = data.map((r) => new EsolveManufacturer(r));
11442
+ }
11443
+ else {
11444
+ this.items = [];
11445
+ this.groups = [];
11446
+ this.locations = [];
11447
+ this.brands = [];
11448
+ }
11449
+ }
11450
+ }
11451
+
11452
+ class EsolveChatService {
11453
+ constructor() {
11454
+ this.http = inject(HttpClient);
11455
+ this.config = inject(EsolveConfigService);
11456
+ this.errorHandler = inject(EsolveErrorHandlerService);
11457
+ }
11458
+ /**
11459
+ * Send a free-text message to the chat assistant (AI classification).
11460
+ *
11461
+ * The caller is responsible for persisting `result.history` and
11462
+ * `result.context` between turns and passing them back on the next call.
11463
+ * The server caps history at 50 messages and summarises automatically.
11464
+ *
11465
+ * @param message The user's message (max 1024 chars; truncated server-side).
11466
+ * @param history History from the previous `EsolveChatIntentResult.history`.
11467
+ * Pass an empty array to start a new conversation.
11468
+ * @param context Pass back `EsolveChatIntentResult.context` from the previous
11469
+ * turn so the AI can answer follow-up questions about results
11470
+ * currently shown on screen. Omit or pass `null` / `''` when
11471
+ * there are no current results. Never stored in history.
11472
+ */
11473
+ sendMessage(message, history = [], context) {
11474
+ const body = { message, history };
11475
+ if (context) {
11476
+ body.context = context;
11477
+ }
11478
+ return this.post(body);
11479
+ }
11480
+ /**
11481
+ * Dispatch a structured suggestion-chip tap directly — no AI round trip.
11482
+ *
11483
+ * Use this when the consumer taps a chip whose `intent` is a server intent
11484
+ * (`product_search`, `product_catalog`, `add_to_basket`, `directions`,
11485
+ * `list_brands`). Client-action intents (`view_cart`, `checkout`) are handled
11486
+ * locally by the consumer and never reach this method.
11487
+ *
11488
+ * @param intent One of the 5 server intents.
11489
+ * @param parameters The chip's `parameters` (sent back verbatim).
11490
+ * @param history History from the previous `EsolveChatIntentResult.history`.
11491
+ * @param phrase The chip's phrase, recorded as the user turn in history.
11492
+ * Omit to let the server fall back to `parameters.query`.
11493
+ */
11494
+ dispatchIntent(intent, parameters, history = [], phrase) {
11495
+ const body = { intent, parameters, history };
11496
+ if (phrase) {
11497
+ body.phrase = phrase;
11498
+ }
11499
+ return this.post(body);
11500
+ }
11501
+ post(body) {
11502
+ return this.http
11503
+ .post(`${this.config.api_url}/set-chat-intent.php`, body)
11504
+ .pipe(map$1((response) => {
11505
+ if (response.type === 'error') {
11506
+ throw response;
11507
+ }
11508
+ const data = response.additional_data;
11509
+ if (Array.isArray(data) || !data) {
11510
+ throw response;
11511
+ }
11512
+ return new EsolveChatIntentResult(data);
11513
+ }), catchError$1((errorRes) => this.errorHandler.handleHttpPostError('set-chat-intent', errorRes)));
11514
+ }
11515
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: EsolveChatService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
11516
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: EsolveChatService, providedIn: 'root' }); }
11517
+ }
11518
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: EsolveChatService, decorators: [{
11519
+ type: Injectable,
11520
+ args: [{
11521
+ providedIn: 'root',
11522
+ }]
11523
+ }] });
11524
+
11050
11525
  /*
11051
11526
  * Public API Surface of ng-esolve-connect
11052
11527
  */
@@ -11055,5 +11530,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImpo
11055
11530
  * Generated bundle index. Do not edit.
11056
11531
  */
11057
11532
 
11058
- export { ESOLVE_CONNECT_CONFIG, ESOLVE_EURUS_AUTO_LOGIN, EsolveAccountConfirmationResult, EsolveAccountPayment, EsolveAccountService, EsolveAdditionalStockImage, EsolveAddress, EsolveAddressResult, EsolveAffiliate, EsolveAffiliateCheckResult, EsolveAffiliateLinkResult, EsolveAffiliateService, EsolveAlbum, EsolveAlbumImage, EsolveAlbumImageList, EsolveAlbumList, EsolveAlbumsService, EsolveAsset, EsolveAssetsService, EsolveAuthService, EsolveBankingDetails, EsolveBanner, EsolveBannerImage, EsolveBannerImageHotspot, EsolveBannerService, EsolveBannerVideo, EsolveCaptcha, EsolveCaptchaService, EsolveCareer, EsolveCareersService, EsolveCartAlternative, EsolveCartErrorHandlerService, EsolveCartItem, EsolveCartItemError, EsolveCartPromotionProgressItem, EsolveCartPromotionProgressQualifyingItem, EsolveCartService, EsolveCartStockItem, EsolveCartTaxBreakdown, EsolveCartTotals, EsolveCategoryTreeItem, EsolveCategoryTreeService, EsolveCdnSrcDirective, EsolveChangePasswordResult, EsolveCheckoutResult, EsolveClientAsset, EsolveClientAssetList, EsolveColour, EsolveColoursService, EsolveCompetition, EsolveCompetitionDates, EsolveCompetitionEntryResult, EsolveCompetitionWinner, EsolveCompetitionsService, EsolveConfigService, EsolveCookieService, EsolveCountry, EsolveCountryService, EsolveCoupon, EsolveCouponsService, EsolveDeliveriesService, EsolveDelivery, EsolveDeliveryCategoryTotals, EsolveDeliveryList, EsolveDeliveryStatus, EsolveDependantItem, EsolveDeviceService, EsolveEmptyCartResult, EsolveEmptyWishlistResult, EsolveEnquiryResult, EsolveEnquiryService, EsolveErpDocumentRequest, EsolveErpDocumentsRequestResult, EsolveErrorHandlerService, EsolveEvent, EsolveEventTargetService, EsolveEventType, EsolveFilterFactory, EsolveGenericFilter, EsolveGeocodeAddressResult, EsolveGeocodeCoordsResult, EsolveGeocodeResult, EsolveGeocoderService, EsolveHttpError, EsolveLinkedAsset, EsolveLinkedStockItem, EsolveList, EsolveLocation, EsolveLocationAddress, EsolveLocationContactInfo, EsolveLocationGEO, EsolveLocationList, EsolveLocationPOBoxAddress, EsolveLocationTradingDay, EsolveLocationTradingTimes, EsolveLocationUpdateResult, EsolveLocationsService, EsolveManufacturer, EsolveManufacturersService, EsolveMaterial, EsolveMaterialsService, EsolveMediaStockItem, EsolveMenuItem, EsolveMenuService, EsolveMultipleSelectFilter, EsolveNewsArticle, EsolveNewsArticleAuthor, EsolveNewsArticleList, EsolveNewsGroup, EsolveNewsService, EsolveNewsletterResult, EsolveNotificationButtonAction, EsolveNotificationDates, EsolveNotificationsService, EsolveOtp, EsolveOtpService, EsolveOtpValidation, EsolvePaymentMethod, EsolvePaymentResult, EsolvePaymentService, EsolveRange, EsolveRangeFilter, EsolveRangesService, EsolveRecipeStockItem, EsolveRegistrationResult, EsolveResetPasswordResult, EsolveResponseHandlerService, EsolveResponseResult, EsolveResult, EsolveReview, EsolveReviewList, EsolveReviewResult, EsolveReviewsService, EsolveSearchCleanResult, EsolveSearchResult, EsolveSearchResultItem, EsolveSearchService, EsolveSearchVectorizeResult, EsolveSeoInfo, EsolveSeoService, EsolveSessionAddressUpdateResult, EsolveSessionClientUpdateResult, EsolveSessionMetadataService, EsolveSessionService, EsolveSessionShippingUpdateResult, EsolveSetDeviceResult, EsolveSetNotifyResult, EsolveSettings, EsolveSettingsService, EsolveShippingCost, EsolveShippingCostItem, EsolveShippingMethod, EsolveShippingService, EsolveShippingTotals, EsolveSingleSelectFilter, EsolveSpecial, EsolveSpecialDates, EsolveSpecialImage, EsolveSpecialImageCollection, EsolveSpecialsService, EsolveStatement, EsolveStatementAgeing, EsolveStatementBalances, EsolveStatementTransaction, EsolveStockBadge, EsolveStockBarcode, EsolveStockGroup, EsolveStockGroupItem, EsolveStockImage, EsolveStockImageCollection, EsolveStockItem, EsolveStockItemBase, EsolveStockItemList, EsolveStockItemLocationLevel, EsolveStockLeadTimes, EsolveStockLinkedCategory, EsolveStockPrice, EsolveStockReviewsReport, EsolveStockService, EsolveStockTransactionSales, EsolveSuggestedStockItem, EsolveSupplier, EsolveSuppliersService, EsolveSystemNotification, EsolveSystemNotificationType, EsolveTag, EsolveTagsService, EsolveTimeSlot, EsolveTimeSlotConfig, EsolveTimeSlotDate, EsolveTimeSlotDays, EsolveTimeSlotTimes, EsolveToggleFilter, EsolveTopic, EsolveTopicService, EsolveTransaction, EsolveTransactionAddress, EsolveTransactionAnalyticsData, EsolveTransactionApprovalResult, EsolveTransactionClient, EsolveTransactionDelivery, EsolveTransactionItem, EsolveTransactionItemPrice, EsolveTransactionList, EsolveTransactionLocation, EsolveTransactionPaymentMethod, EsolveTransactionPick, EsolveTransactionShippingMethod, EsolveTransactionTimeSlot, EsolveTransactionUser, EsolveTransactionsService, EsolveUserAccount, EsolveUserAccountBusiness, EsolveUserAccountContact, EsolveUserAccountResult, EsolveUserClientAccount, EsolveUserClientAccountBalances, EsolveUserDevice, EsolveVaultItem, EsolveVaultItemResult, EsolveVoucher, EsolveVouchersService, EsolveWalletBalances, EsolveWalletService, EsolveWalletTransaction, EsolveWalletTransactionsList, EsolveWishlistItem, EsolveWishlistService, NgEsolveConnectModule, esolveAuthInterceptor, esolveHexHash, esolveUnauthorizedErrorInterceptor, isEsolveCdnPath, isFtgCdnPath, isLegacyEsolveCdnPath, processEsolveImageSrc, provideEsolveImageLoader, provideNgEsolveConnect };
11533
+ export { ESOLVE_CONNECT_CONFIG, ESOLVE_EURUS_AUTO_LOGIN, EsolveAccountConfirmationResult, EsolveAccountPayment, EsolveAccountService, EsolveAdditionalStockImage, EsolveAddress, EsolveAddressResult, EsolveAffiliate, EsolveAffiliateCheckResult, EsolveAffiliateLinkResult, EsolveAffiliateService, EsolveAlbum, EsolveAlbumImage, EsolveAlbumImageList, EsolveAlbumList, EsolveAlbumsService, EsolveAsset, EsolveAssetsService, EsolveAuthService, EsolveBankingDetails, EsolveBanner, EsolveBannerImage, EsolveBannerImageHotspot, EsolveBannerService, EsolveBannerVideo, EsolveCaptcha, EsolveCaptchaService, EsolveCareer, EsolveCareersService, EsolveCartAlternative, EsolveCartErrorHandlerService, EsolveCartItem, EsolveCartItemError, EsolveCartPromotionProgressItem, EsolveCartPromotionProgressQualifyingItem, EsolveCartService, EsolveCartStockItem, EsolveCartTaxBreakdown, EsolveCartTotals, EsolveCategoryTreeItem, EsolveCategoryTreeService, EsolveCdnSrcDirective, EsolveChangePasswordResult, EsolveChatIntentResult, EsolveChatProductGroup, EsolveChatService, EsolveCheckoutResult, EsolveClientAsset, EsolveClientAssetList, EsolveColour, EsolveColoursService, EsolveCompetition, EsolveCompetitionDates, EsolveCompetitionEntry, EsolveCompetitionEntryResult, EsolveCompetitionStats, EsolveCompetitionVoteResult, EsolveCompetitionWinner, EsolveCompetitionsService, EsolveConfigService, EsolveCookieService, EsolveCountry, EsolveCountryService, EsolveCoupon, EsolveCouponsService, EsolveDeliveriesService, EsolveDelivery, EsolveDeliveryCategoryTotals, EsolveDeliveryList, EsolveDeliveryStatus, EsolveDependantItem, EsolveDeviceService, EsolveEmptyCartResult, EsolveEmptyWishlistResult, EsolveEnquiryForm, EsolveEnquiryFormField, EsolveEnquiryFormSubmissionResult, EsolveEnquiryFormsService, EsolveEnquiryResult, EsolveEnquiryService, EsolveErpDocumentRequest, EsolveErpDocumentsRequestResult, EsolveErrorHandlerService, EsolveEvent, EsolveEventTargetService, EsolveEventType, EsolveFilterFactory, EsolveGenericFilter, EsolveGeocodeAddressResult, EsolveGeocodeCoordsResult, EsolveGeocodeResult, EsolveGeocoderService, EsolveHttpError, EsolveLinkedAsset, EsolveLinkedStockItem, EsolveList, EsolveLocation, EsolveLocationAddress, EsolveLocationContactInfo, EsolveLocationGEO, EsolveLocationList, EsolveLocationPOBoxAddress, EsolveLocationTradingDay, EsolveLocationTradingTimes, EsolveLocationUpdateResult, EsolveLocationsService, EsolveManufacturer, EsolveManufacturersService, EsolveMaterial, EsolveMaterialsService, EsolveMediaStockItem, EsolveMenuItem, EsolveMenuService, EsolveMultipleSelectFilter, EsolveNewsArticle, EsolveNewsArticleAuthor, EsolveNewsArticleList, EsolveNewsGroup, EsolveNewsService, EsolveNewsletterResult, EsolveNotificationButtonAction, EsolveNotificationDates, EsolveNotificationsService, EsolveOtp, EsolveOtpService, EsolveOtpValidation, EsolvePaymentMethod, EsolvePaymentResult, EsolvePaymentService, EsolveRange, EsolveRangeFilter, EsolveRangesService, EsolveRecipeStockItem, EsolveRegistrationResult, EsolveResetPasswordResult, EsolveResponseHandlerService, EsolveResponseResult, EsolveResult, EsolveReview, EsolveReviewList, EsolveReviewResult, EsolveReviewsService, EsolveSearchCleanResult, EsolveSearchResult, EsolveSearchResultItem, EsolveSearchService, EsolveSearchVectorizeResult, EsolveSeoInfo, EsolveSeoService, EsolveSessionAddressUpdateResult, EsolveSessionClientUpdateResult, EsolveSessionMetadataService, EsolveSessionService, EsolveSessionShippingUpdateResult, EsolveSetDeviceResult, EsolveSetNotifyResult, EsolveSettings, EsolveSettingsService, EsolveShippingCost, EsolveShippingCostItem, EsolveShippingMethod, EsolveShippingService, EsolveShippingTotals, EsolveSingleSelectFilter, EsolveSpecial, EsolveSpecialDates, EsolveSpecialImage, EsolveSpecialImageCollection, EsolveSpecialsService, EsolveStatement, EsolveStatementAgeing, EsolveStatementBalances, EsolveStatementTransaction, EsolveStockBadge, EsolveStockBarcode, EsolveStockGroup, EsolveStockGroupItem, EsolveStockImage, EsolveStockImageCollection, EsolveStockItem, EsolveStockItemBase, EsolveStockItemList, EsolveStockItemLocationLevel, EsolveStockLeadTimes, EsolveStockLinkedCategory, EsolveStockPrice, EsolveStockReviewsReport, EsolveStockService, EsolveStockTransactionSales, EsolveSuggestedStockItem, EsolveSupplier, EsolveSuppliersService, EsolveSystemNotification, EsolveSystemNotificationType, EsolveTag, EsolveTagsService, EsolveTimeSlot, EsolveTimeSlotConfig, EsolveTimeSlotDate, EsolveTimeSlotDays, EsolveTimeSlotTimes, EsolveToggleFilter, EsolveTopic, EsolveTopicService, EsolveTransaction, EsolveTransactionAddress, EsolveTransactionAnalyticsData, EsolveTransactionApprovalResult, EsolveTransactionClient, EsolveTransactionDelivery, EsolveTransactionItem, EsolveTransactionItemPrice, EsolveTransactionList, EsolveTransactionLocation, EsolveTransactionPaymentMethod, EsolveTransactionPick, EsolveTransactionShippingMethod, EsolveTransactionTimeSlot, EsolveTransactionUser, EsolveTransactionsService, EsolveUserAccount, EsolveUserAccountBusiness, EsolveUserAccountContact, EsolveUserAccountResult, EsolveUserClientAccount, EsolveUserClientAccountBalances, EsolveUserDevice, EsolveVaultItem, EsolveVaultItemResult, EsolveVoucher, EsolveVouchersService, EsolveWalletBalances, EsolveWalletService, EsolveWalletTransaction, EsolveWalletTransactionsList, EsolveWishlistItem, EsolveWishlistService, NgEsolveConnectModule, esolveAuthInterceptor, esolveHexHash, esolveUnauthorizedErrorInterceptor, isEsolveCdnPath, isFtgCdnPath, isLegacyEsolveCdnPath, processEsolveImageSrc, provideEsolveImageLoader, provideNgEsolveConnect };
11059
11534
  //# sourceMappingURL=esolve-ng-esolve-connect.mjs.map