@sparkvault/sdk-js 18.0.0 → 18.0.2

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.cjs CHANGED
@@ -4620,6 +4620,220 @@ class LoadingView {
4620
4620
  }
4621
4621
  }
4622
4622
 
4623
+ /**
4624
+ * Shared browser email-or-phone field. Entered text is held separately from
4625
+ * phone presentation, so a numeric email prefix never inherits punctuation
4626
+ * inserted by the formatter. Callers validate `value`, never the presentation.
4627
+ */
4628
+
4629
+ const PHONE_CHARACTER = /[+\d]/;
4630
+
4631
+ /** Map each displayed phone digit to the entered character it represents. */
4632
+ function phonePositions(value, display) {
4633
+ const entered = [...value.matchAll(/[+\d]/g)].map((match) => match.index);
4634
+ const shown = [...display.matchAll(/[+\d]/g)].map((match) => match.index);
4635
+ // NANP presentation omits its declared country code; it stays in the value.
4636
+ return shown.map((position, index) => ({ display: position, value: entered[index + entered.length - shown.length] }));
4637
+ }
4638
+
4639
+ /**
4640
+ * @param {HTMLInputElement} input - A text or tel input owned by the caller
4641
+ * @param {{allowedTypes?: ('email'|'phone')[], onChange?: (value: string, type: 'email'|'phone') => void}} options
4642
+ * @returns {{readonly value: string, readonly type: 'email'|'phone', setValue: (value: string) => void, destroy: () => void}}
4643
+ */
4644
+ function attachIdentityInput(input, { allowedTypes = ['email', 'phone'], onChange } = {}) {
4645
+ let value = input.value;
4646
+ let display = value;
4647
+ let positions = [];
4648
+ let composing = false;
4649
+ let beforeEdit = null;
4650
+ let history = [{ value, start: value.length, end: value.length }];
4651
+ let historyIndex = 0;
4652
+ const phoneOnly = allowedTypes.length === 1 && allowedTypes[0] === 'phone';
4653
+ const allowsPhone = allowedTypes.includes('phone');
4654
+ const identityType = () => phoneOnly ? 'phone' : allowsPhone ? inferIdentityType(value) : 'email';
4655
+
4656
+ function valuePosition(position) {
4657
+ if (display === value || position === 0) return position;
4658
+ if (position >= display.length) return value.length;
4659
+ return positions.find((entry) => entry.display >= position)?.value ?? value.length;
4660
+ }
4661
+
4662
+ function displayPosition(position) {
4663
+ if (display === value) return position;
4664
+ if (position >= value.length) return display.length;
4665
+ for (let index = positions.length - 1; index >= 0; index -= 1) {
4666
+ if (positions[index].value < position) return positions[index].display + 1;
4667
+ }
4668
+ return positions[0]?.display ?? 0;
4669
+ }
4670
+
4671
+ function present(start = null, end = start) {
4672
+ display = identityType() === 'phone' ? formatPhoneDisplay(value) : value;
4673
+ positions = display === value ? [] : phonePositions(value, display);
4674
+ input.value = display;
4675
+ // Mixed fields keep a text keyboard: an initial digit can begin an email.
4676
+ input.inputMode = phoneOnly ? 'tel' : 'text';
4677
+ input.autocapitalize = 'none';
4678
+ input.spellcheck = false;
4679
+ if (start !== null) input.setSelectionRange(displayPosition(start), displayPosition(end));
4680
+ }
4681
+
4682
+ // Formatting writes the DOM value, which changes native undo bookkeeping.
4683
+ // History therefore owns entered values and selections, never DOM diffs.
4684
+ function restoreHistory(direction) {
4685
+ beforeEdit = null;
4686
+ const nextIndex = Math.max(0, Math.min(history.length - 1, historyIndex + direction));
4687
+ const changed = nextIndex !== historyIndex;
4688
+ historyIndex = nextIndex;
4689
+ const state = history[historyIndex];
4690
+ value = state.value;
4691
+ present();
4692
+ input.setSelectionRange(state.start, state.end);
4693
+ if (changed) onChange?.(value, identityType());
4694
+ }
4695
+
4696
+ function historyDirection(event) {
4697
+ return event.inputType === 'historyUndo' ? -1 : event.inputType === 'historyRedo' ? 1 : 0;
4698
+ }
4699
+
4700
+ function handleHistoryKey(event) {
4701
+ if (composing || event.isComposing || event.altKey || !(event.metaKey || event.ctrlKey)) return;
4702
+ const key = event.key.toLowerCase();
4703
+ const direction = key === 'z' ? (event.shiftKey ? 1 : -1) : key === 'y' && event.ctrlKey ? 1 : 0;
4704
+ if (!direction) return;
4705
+ event.preventDefault();
4706
+ restoreHistory(direction);
4707
+ }
4708
+
4709
+ function rememberSelection() {
4710
+ const start = input.selectionStart ?? display.length;
4711
+ const end = input.selectionEnd ?? start;
4712
+ history[historyIndex] = { value, start, end };
4713
+ }
4714
+
4715
+ function captureEdit(event) {
4716
+ if (composing || event.isComposing) return;
4717
+ const direction = historyDirection(event);
4718
+ if (direction) {
4719
+ if (event.cancelable) {
4720
+ event.preventDefault();
4721
+ restoreHistory(direction);
4722
+ }
4723
+ return;
4724
+ }
4725
+ rememberSelection();
4726
+ let start = input.selectionStart ?? display.length;
4727
+ let end = input.selectionEnd ?? start;
4728
+ if (start === end && event.inputType === 'deleteContentBackward') start = Math.max(0, start - 1);
4729
+ if (start === end && event.inputType === 'deleteContentForward') end = Math.min(display.length, end + 1);
4730
+ beforeEdit = { start, end, inputType: event.inputType, display };
4731
+ }
4732
+
4733
+ function acceptEdit(event) {
4734
+ if (composing || event.isComposing) return;
4735
+ const direction = historyDirection(event);
4736
+ if (direction) {
4737
+ restoreHistory(direction);
4738
+ return;
4739
+ }
4740
+ const next = input.value;
4741
+ if (next === display) {
4742
+ beforeEdit = null;
4743
+ return;
4744
+ }
4745
+ const cursor = input.selectionStart ?? next.length;
4746
+ const selectionEnd = input.selectionEnd ?? cursor;
4747
+ let start = 0;
4748
+ let end = display.length;
4749
+ let nextEnd = next.length;
4750
+ const edit = beforeEdit;
4751
+ beforeEdit = null;
4752
+ if (edit?.display === display && next.startsWith(display.slice(0, edit.start))
4753
+ && next.endsWith(display.slice(edit.end))) {
4754
+ start = edit.start;
4755
+ end = edit.end;
4756
+ nextEnd = next.length - (display.length - end);
4757
+ } else {
4758
+ while (start < display.length && start < next.length && display[start] === next[start]) start += 1;
4759
+ while (end > start && nextEnd > start && display[end - 1] === next[nextEnd - 1]) {
4760
+ end -= 1;
4761
+ nextEnd -= 1;
4762
+ }
4763
+ }
4764
+ let rawStart = valuePosition(start);
4765
+ let rawEnd = valuePosition(end);
4766
+ const inserted = next.slice(start, nextEnd);
4767
+ // Backspace/Delete on presentation punctuation must make progress instead
4768
+ // of immediately restoring the separator and trapping the caret.
4769
+ if (!inserted && end > start && rawStart === rawEnd) {
4770
+ const forward = (edit?.inputType || event.inputType) === 'deleteContentForward';
4771
+ if (forward) {
4772
+ while (rawEnd < value.length && !PHONE_CHARACTER.test(value[rawEnd])) rawEnd += 1;
4773
+ rawEnd = Math.min(value.length, rawEnd + 1);
4774
+ } else {
4775
+ while (rawStart > 0 && !PHONE_CHARACTER.test(value[rawStart - 1])) rawStart -= 1;
4776
+ rawStart = Math.max(0, rawStart - 1);
4777
+ }
4778
+ }
4779
+ const toValuePosition = (position) => position < start
4780
+ ? valuePosition(position)
4781
+ : position <= nextEnd
4782
+ ? rawStart + position - start
4783
+ : valuePosition(position - nextEnd + end) + inserted.length - (rawEnd - rawStart);
4784
+ const rawCursor = toValuePosition(cursor);
4785
+ const rawSelectionEnd = toValuePosition(selectionEnd);
4786
+ value = value.slice(0, rawStart) + inserted + value.slice(rawEnd);
4787
+ present(rawCursor, rawSelectionEnd);
4788
+ history.splice(historyIndex + 1);
4789
+ history.push({ value, start: input.selectionStart, end: input.selectionEnd });
4790
+ historyIndex = history.length - 1;
4791
+ onChange?.(value, identityType());
4792
+ }
4793
+
4794
+ function startComposition() {
4795
+ rememberSelection();
4796
+ composing = true;
4797
+ beforeEdit = null;
4798
+ }
4799
+
4800
+ function endComposition(event) {
4801
+ composing = false;
4802
+ acceptEdit(event);
4803
+ }
4804
+
4805
+ input.addEventListener('keydown', handleHistoryKey);
4806
+ input.addEventListener('beforeinput', captureEdit);
4807
+ input.addEventListener('input', acceptEdit);
4808
+ input.addEventListener('change', acceptEdit);
4809
+ input.addEventListener('compositionstart', startComposition);
4810
+ input.addEventListener('compositionend', endComposition);
4811
+ present();
4812
+ rememberSelection();
4813
+
4814
+ return {
4815
+ get value() { return value; },
4816
+ get type() { return identityType(); },
4817
+ setValue(next) {
4818
+ if (next === value) return;
4819
+ value = next;
4820
+ history = [{ value, start: value.length, end: value.length }];
4821
+ historyIndex = 0;
4822
+ beforeEdit = null;
4823
+ present();
4824
+ rememberSelection();
4825
+ },
4826
+ destroy() {
4827
+ input.removeEventListener('keydown', handleHistoryKey);
4828
+ input.removeEventListener('beforeinput', captureEdit);
4829
+ input.removeEventListener('input', acceptEdit);
4830
+ input.removeEventListener('change', acceptEdit);
4831
+ input.removeEventListener('compositionstart', startComposition);
4832
+ input.removeEventListener('compositionend', endComposition);
4833
+ }
4834
+ };
4835
+ }
4836
+
4623
4837
  /**
4624
4838
  * The sign-in providers' marks and the social networks' marks, each stated
4625
4839
  * once: the identity dialog (the browser SDK, which bundles this module) and
@@ -5115,7 +5329,7 @@ function smsConsent(id) {
5115
5329
  *
5116
5330
  * Collects and validates the user's email or phone number: reads the input as
5117
5331
  * one or the other by the platform's rules (`@sparkvault/app-sdk/phone` and
5118
- * `@sparkvault/app-sdk/email-address`), and formats a phone-only field as the
5332
+ * `@sparkvault/app-sdk/email-address`), and formats phone numbers as the
5119
5333
  * number is typed. A field that takes a phone number carries the SMS and voice
5120
5334
  * consent beneath it.
5121
5335
  */
@@ -5130,12 +5344,8 @@ class IdentityInputView {
5130
5344
  this.leadingHandler = null;
5131
5345
  this.errorContainer = null;
5132
5346
  this.focusTimeoutId = null;
5133
- this.detectedType = 'email';
5347
+ this.identityInput = null;
5134
5348
  this.props = props;
5135
- this.boundHandleInput = () => {
5136
- this.handleInput();
5137
- this.props.onType?.();
5138
- };
5139
5349
  this.boundHandleKeyDown = (e) => {
5140
5350
  if (e.key === 'Enter') {
5141
5351
  e.preventDefault();
@@ -5190,9 +5400,17 @@ class IdentityInputView {
5190
5400
  this.inputElement.maxLength = EMAIL_ADDRESS_LIMITS.ADDRESS;
5191
5401
  if (this.props.initialValue) {
5192
5402
  this.inputElement.value = this.props.initialValue;
5193
- this.detectAndUpdateType(this.props.initialValue);
5194
5403
  }
5195
- this.inputElement.addEventListener('input', this.boundHandleInput);
5404
+ this.identityInput = attachIdentityInput(this.inputElement, {
5405
+ allowedTypes: this.props.allowedTypes,
5406
+ onChange: () => {
5407
+ this.clearError();
5408
+ if (this.labelElement)
5409
+ this.labelElement.textContent = this.getLabelText();
5410
+ this.props.onType?.();
5411
+ }
5412
+ });
5413
+ this.labelElement.textContent = this.getLabelText();
5196
5414
  this.inputElement.addEventListener('keydown', this.boundHandleKeyDown);
5197
5415
  inputWrapper.appendChild(this.labelElement);
5198
5416
  inputWrapper.appendChild(this.inputElement);
@@ -5245,7 +5463,7 @@ class IdentityInputView {
5245
5463
  }
5246
5464
  getLabelText() {
5247
5465
  if (this.allowsBoth) {
5248
- return this.detectedType === 'phone' ? 'Phone number' : 'Email address';
5466
+ return this.identityInput?.type === 'phone' ? 'Phone number' : 'Email address';
5249
5467
  }
5250
5468
  if (this.allowsPhone)
5251
5469
  return 'Phone number';
@@ -5258,36 +5476,6 @@ class IdentityInputView {
5258
5476
  return '(555) 123-4567';
5259
5477
  return 'you@example.com';
5260
5478
  }
5261
- handleInput() {
5262
- this.clearError();
5263
- if (!this.inputElement)
5264
- return;
5265
- const value = this.inputElement.value;
5266
- if (this.allowsBoth) {
5267
- // The label follows what the input reads as, but the text is never
5268
- // rewritten: digits typed so far can still begin an email address
5269
- // ("2024user@gmail.com", "12345678@qq.com"), and phone formatting would
5270
- // corrupt it. Submit normalizes a phone number whatever its separators.
5271
- const wasPhone = this.detectedType === 'phone';
5272
- this.detectAndUpdateType(value);
5273
- if (wasPhone !== (this.detectedType === 'phone') && this.labelElement) {
5274
- this.labelElement.textContent = this.getLabelText();
5275
- }
5276
- }
5277
- else if (this.allowsPhone) {
5278
- // Phone-only mode: always format
5279
- const cursorPos = this.inputElement.selectionStart ?? value.length;
5280
- const formatted = formatPhoneDisplay(value);
5281
- if (formatted !== value) {
5282
- this.inputElement.value = formatted;
5283
- const newPos = Math.min(cursorPos + (formatted.length - value.length), formatted.length);
5284
- this.inputElement.setSelectionRange(newPos, newPos);
5285
- }
5286
- }
5287
- }
5288
- detectAndUpdateType(value) {
5289
- this.detectedType = inferIdentityType(value);
5290
- }
5291
5479
  clearError() {
5292
5480
  if (this.errorContainer) {
5293
5481
  clearChildren(this.errorContainer);
@@ -5303,60 +5491,27 @@ class IdentityInputView {
5303
5491
  this.inputElement?.focus();
5304
5492
  }
5305
5493
  handleSubmit() {
5306
- if (!this.inputElement || !this.submitButton)
5494
+ if (!this.identityInput || !this.submitButton)
5495
+ return;
5496
+ const type = this.identityInput.type;
5497
+ const value = type === 'phone'
5498
+ ? parsePhone(this.identityInput.value)
5499
+ : validateEmail(this.identityInput.value);
5500
+ if (!value) {
5501
+ this.showError(type === 'phone' ? 'Please enter a valid phone number' : 'Please enter a valid email address');
5307
5502
  return;
5308
- const rawValue = this.inputElement.value;
5309
- // Validate based on detected type
5310
- if (this.allowsBoth) {
5311
- if (this.detectedType === 'phone') {
5312
- const validPhone = parsePhone(rawValue);
5313
- if (!validPhone) {
5314
- this.showError('Please enter a valid phone number');
5315
- return;
5316
- }
5317
- this.submitButton.disabled = true;
5318
- this.submitButton.textContent = 'Please wait...';
5319
- this.props.onSubmit({ value: validPhone, type: 'phone' });
5320
- }
5321
- else {
5322
- const validEmail = validateEmail(rawValue);
5323
- if (!validEmail) {
5324
- this.showError('Please enter a valid email address');
5325
- return;
5326
- }
5327
- this.submitButton.disabled = true;
5328
- this.submitButton.textContent = 'Please wait...';
5329
- this.props.onSubmit({ value: validEmail, type: 'email' });
5330
- }
5331
- }
5332
- else if (this.allowsPhone) {
5333
- const validPhone = parsePhone(rawValue);
5334
- if (!validPhone) {
5335
- this.showError('Please enter a valid phone number');
5336
- return;
5337
- }
5338
- this.submitButton.disabled = true;
5339
- this.submitButton.textContent = 'Please wait...';
5340
- this.props.onSubmit({ value: validPhone, type: 'phone' });
5341
- }
5342
- else {
5343
- const validEmail = validateEmail(rawValue);
5344
- if (!validEmail) {
5345
- this.showError('Please enter a valid email address');
5346
- return;
5347
- }
5348
- this.submitButton.disabled = true;
5349
- this.submitButton.textContent = 'Please wait...';
5350
- this.props.onSubmit({ value: validEmail, type: 'email' });
5351
5503
  }
5504
+ this.submitButton.disabled = true;
5505
+ this.submitButton.textContent = 'Please wait...';
5506
+ this.props.onSubmit({ value, type });
5352
5507
  }
5353
5508
  destroy() {
5509
+ this.identityInput?.destroy();
5354
5510
  if (this.focusTimeoutId !== null) {
5355
5511
  clearTimeout(this.focusTimeoutId);
5356
5512
  this.focusTimeoutId = null;
5357
5513
  }
5358
5514
  if (this.inputElement) {
5359
- this.inputElement.removeEventListener('input', this.boundHandleInput);
5360
5515
  this.inputElement.removeEventListener('keydown', this.boundHandleKeyDown);
5361
5516
  }
5362
5517
  if (this.submitButton) {
@@ -18849,7 +19004,657 @@ class HelpDeskClient {
18849
19004
  }
18850
19005
  }
18851
19006
 
18852
- /** Scoped styles for the optional inline help desk form. */
19007
+ /**
19008
+ * A tenant's brand color and the WCAG contrast rules that decide how it may be
19009
+ * used: the one hex rule the server stores, the console checks and the portal
19010
+ * paints, the one contrast reading the console's readouts, the portal's
19011
+ * accent and the portal's reading of a help center's ground share, and the
19012
+ * one way a readout writes that reading.
19013
+ *
19014
+ * A brand color is tenant-controlled, so it is used only when it is a
19015
+ * six-digit hex color, read case-insensitively and held in lowercase; anything
19016
+ * else (a color name, a CSS function, a value that runs on into more CSS) is
19017
+ * no color at all.
19018
+ *
19019
+ * A brand color can be any lightness, so whatever shows it picks what goes
19020
+ * with it, in one pairing per scheme that every surface painting the color
19021
+ * shares (the customer portal, the SDK's support journey, the desk's email,
19022
+ * the console's sample):
19023
+ *
19024
+ * light (lightAccent) the fill, moved in lightness away from its label
19025
+ * only where neither white nor ink reads on it at
19026
+ * 4.5:1; white or ink on it, whichever reads more
19027
+ * strongly; the color itself as text only where it
19028
+ * reaches 4.5:1 on both grounds accent text stands on,
19029
+ * the white surface and the canvas tone, ink otherwise
19030
+ * dark (darkAccent) a color with a hue a reader sees, lifted in
19031
+ * lightness at its own hue and the saturation it shows
19032
+ * where it would not read: as text until it reads at
19033
+ * 4.5:1 on every dark ground accent text stands on
19034
+ * (darkAccentInk), as a fill until it stands at 3:1 on
19035
+ * the dark page and its cards under a label at 4.5:1,
19036
+ * its hover too (darkAccentFill); a grey or black, the
19037
+ * dark scheme's ink, as fill and as text, under ink
19038
+ *
19039
+ * A hue is the one a reader sees (shownChroma): a black whose OKLCH chroma
19040
+ * names a hue no reader sees there, such as #000001, pairs as black in both
19041
+ * schemes. Under the pointer each fill moves a step a reader sees, away from
19042
+ * its label wherever there is room, and on dark grounds wherever that step
19043
+ * still stands there (hoverOf). schemePairings gives both pairings at once,
19044
+ * DEFAULT_PAIRINGS the ones a desk with no brand color paints, and
19045
+ * accentProperties says either as the accent custom properties the customer
19046
+ * portal paints with.
19047
+ *
19048
+ * BROWSER-SAFE: data only, no imports.
19049
+ */
19050
+
19051
+ const HEX_COLOR = /^#[0-9a-f]{6}$/;
19052
+
19053
+ /** WCAG AA's floor for normal-size text. */
19054
+ const AA_TEXT_CONTRAST = 4.5;
19055
+
19056
+ /**
19057
+ * The canvas tone, the design system's `--canvas` (`--color-slate-50`): the
19058
+ * page ground the customer portal (its pages and a customer's own messages)
19059
+ * and the knowledge base's default theme set accent text on, beside the white
19060
+ * surface. The design system publishes its tokens only as CSS, which this
19061
+ * import-free module cannot read, so the value is mirrored here once, and
19062
+ * tests/brand-color.test.js holds it to packages/design-system/tokens/colors.css.
19063
+ */
19064
+ const CANVAS_COLOR = '#f7fafb';
19065
+
19066
+ /**
19067
+ * The ink, the design system's `--ink` (`--color-slate-900`): the dark text a
19068
+ * pairing paints on a fill and in place of a color too light to stand as
19069
+ * text. Mirrored here once for the same reason as CANVAS_COLOR, and held to
19070
+ * packages/design-system/tokens/colors.css by tests/brand-color.test.js.
19071
+ */
19072
+ const INK_COLOR = '#0d1a20';
19073
+
19074
+ /**
19075
+ * The design system's dark app grounds accent colors stand on, mirrored for
19076
+ * the same reason as CANVAS_COLOR and held to the tokens the same way: the
19077
+ * page (`--dark-app-canvas`), its cards (`--dark-app-surface`) and the
19078
+ * ground of selected text and of the composer's drop prompt
19079
+ * (`--dark-app-selection`), the lightest ground accent text stands on there.
19080
+ */
19081
+ const DARK_CANVAS_COLOR = '#071217';
19082
+ const DARK_SURFACE_COLOR = '#0d1a20';
19083
+ const DARK_SELECTION_COLOR = '#1b2e4c';
19084
+
19085
+ /**
19086
+ * The dark app ramp's ink, `--dark-app-ink`: the text on its grounds, and the
19087
+ * accent a grey or black brand color takes there. Mirrored and held to the
19088
+ * tokens as CANVAS_COLOR is.
19089
+ */
19090
+ const DARK_INK_COLOR = '#f0f5f7';
19091
+
19092
+ /**
19093
+ * The pairings a desk with no brand color paints, in the shape a brand
19094
+ * color's take (schemePairings), so every surface that paints a desk's accent
19095
+ * (the customer portal, the SDK's support journey, the desk's email, the
19096
+ * console's sample) paints this one default: on light grounds the design
19097
+ * system's primary button (`--color-btn-primary`, under the pointer
19098
+ * `--color-btn-primary-hover`) under white, with `--color-action` as text; on
19099
+ * the dark app grounds its action fill (`--dark-app-action`, under the
19100
+ * pointer `--dark-app-action-hover`) under white, with
19101
+ * `--color-action-on-dark` as text. Each color is its token's value,
19102
+ * mirrored and held to the tokens as CANVAS_COLOR is.
19103
+ */
19104
+ const DEFAULT_PAIRINGS = Object.freeze({
19105
+ light: Object.freeze({ fill: '#0a4eb1', onAccent: 'white', ink: '#216bde', hover: '#03439f' }),
19106
+ dark: Object.freeze({ fill: '#226ee3', onAccent: 'white', ink: '#72a8ff', hover: '#1d60c8' })
19107
+ });
19108
+
19109
+ /**
19110
+ * The chroma a reader sees (shownChroma) under which a color is a grey rather
19111
+ * than a hue: the neutral greys a brand picks (a pure, warm or cool grey,
19112
+ * stone, zinc) sit at 0 to 0.019, and the least saturated colors still named
19113
+ * by their hue (a desaturated olive, a charcoal navy, a taupe, a brown) at
19114
+ * 0.028 to 0.035.
19115
+ */
19116
+ const CHROMA_FLOOR = 0.02;
19117
+
19118
+ /**
19119
+ * The OKLCH lightness under which OKLCH's chroma names a hue a reader does
19120
+ * not see: CIE L*a*b*'s 6/29, under which L*a*b* weighs light linearly where
19121
+ * OKLab keeps its cube root to black. Near black that cube root finds a hue
19122
+ * in what little light there is (a chroma of 0.021 in #000001, 0.045 in
19123
+ * #00000a) in a color a reader sees as black.
19124
+ */
19125
+ const LINEAR_LIGHTNESS = 6 / 29;
19126
+
19127
+ /** WCAG AA's floor for a control's parts and a state's mark (1.4.11). */
19128
+ const AA_NON_TEXT_CONTRAST = 3;
19129
+
19130
+ /** sRGB's transfer function: an encoded channel, from 0 to 1, as linear light, and back. */
19131
+ const toLinear = (channel) => (channel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4);
19132
+ const toGamma = (channel) => (channel <= 0.0031308 ? 12.92 * channel : 1.055 * channel ** (1 / 2.4) - 0.055);
19133
+
19134
+ /** A validated `#rrggbb` color's red, green and blue channels, each from 0 to 1. */
19135
+ const channelsOf = (color) => [1, 3, 5].map((offset) => Number.parseInt(color.slice(offset, offset + 2), 16) / 255);
19136
+
19137
+ /** Relative luminance (WCAG 2) of an sRGB color's red, green and blue channels, each from 0 to 1. */
19138
+ function channelLuminance(channels) {
19139
+ const [red, green, blue] = channels.map(toLinear);
19140
+ return 0.2126 * red + 0.7152 * green + 0.0722 * blue;
19141
+ }
19142
+
19143
+ /** Relative luminance (WCAG 2) of a validated `#rrggbb` color. */
19144
+ function relativeLuminance(color) {
19145
+ return channelLuminance(channelsOf(color));
19146
+ }
19147
+
19148
+ /** The contrast ratio of two relative luminances. */
19149
+ function contrastRatio(first, second) {
19150
+ return (Math.max(first, second) + 0.05) / (Math.min(first, second) + 0.05);
19151
+ }
19152
+
19153
+ /** The relative luminance of the ink a fill's text is weighed in, the real ink rather than pure black. */
19154
+ const INK_LUMINANCE = relativeLuminance(INK_COLOR);
19155
+
19156
+ /** The relative luminances of the grounds accent text stands on: the white surface and the canvas tone. */
19157
+ const TEXT_GROUNDS = Object.freeze([1, relativeLuminance(CANVAS_COLOR)]);
19158
+
19159
+ /** The dark app ramp's grounds accent text stands on, as sRGB channels: the dark page, its cards and the selection. */
19160
+ const DARK_TEXT_GROUNDS = Object.freeze([DARK_CANVAS_COLOR, DARK_SURFACE_COLOR, DARK_SELECTION_COLOR].map((color) => Object.freeze(channelsOf(color))));
19161
+
19162
+ /** The dark app ramp's grounds an accent fill stands on, as sRGB channels: the dark page and its cards. */
19163
+ const DARK_FILL_GROUNDS = Object.freeze([DARK_CANVAS_COLOR, DARK_SURFACE_COLOR].map((color) => Object.freeze(channelsOf(color))));
19164
+
19165
+ /** How strongly a color of this luminance reads on the one of `grounds` it reads least on. */
19166
+ function lowestContrast(luminance, grounds) {
19167
+ return Math.min(...grounds.map((ground) => contrastRatio(luminance, ground)));
19168
+ }
19169
+
19170
+ /** The text a fill of this luminance takes: white or ink, whichever reads more strongly on it. */
19171
+ function labelOf(luminance) {
19172
+ return contrastRatio(luminance, 1) >= contrastRatio(luminance, INK_LUMINANCE) ? 'white' : 'ink';
19173
+ }
19174
+
19175
+ /** How strongly that text reads on a fill of this luminance. */
19176
+ function labelContrast(luminance) {
19177
+ return contrastRatio(luminance, labelOf(luminance) === 'white' ? 1 : INK_LUMINANCE);
19178
+ }
19179
+
19180
+ /** How strongly a color of this luminance reads as text on the light ground it reads least on. */
19181
+ function textContrast(luminance) {
19182
+ return lowestContrast(luminance, TEXT_GROUNDS);
19183
+ }
19184
+
19185
+ /**
19186
+ * A validated `#rrggbb` color in OKLCH (lightness from 0 to 1, chroma, hue in
19187
+ * radians), by the same transform the design system derives its palette with
19188
+ * (packages/design-system/scripts/token-css.mjs oklchOfRgb, by which
19189
+ * tests/brand-color.test.js measures every lift).
19190
+ */
19191
+ function oklchOf(color) {
19192
+ const [r, g, b] = channelsOf(color).map(toLinear);
19193
+ const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
19194
+ const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
19195
+ const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
19196
+ const a = 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s;
19197
+ const bAxis = 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s;
19198
+ return { L: 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s, C: Math.hypot(a, bAxis), H: Math.atan2(bAxis, a) };
19199
+ }
19200
+
19201
+ /** An OKLCH color's linear red, green and blue; a channel outside 0 to 1 is one sRGB cannot draw. */
19202
+ function linearOfOklch(L, C, H) {
19203
+ const [a, b] = [C * Math.cos(H), C * Math.sin(H)];
19204
+ const l = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3;
19205
+ const m = (L - 0.1055613458 * a - 0.0638541728 * b) ** 3;
19206
+ const s = (L - 0.0894841775 * a - 1.291485548 * b) ** 3;
19207
+ return [
19208
+ 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,
19209
+ -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,
19210
+ -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s
19211
+ ];
19212
+ }
19213
+
19214
+ /**
19215
+ * The chroma a reader sees in a color (its OKLCH lightness and chroma): its
19216
+ * OKLCH chroma, under LINEAR_LIGHTNESS faded by the square of the color's
19217
+ * share of that lightness, as L*a*b*'s linear weighing scales chroma against
19218
+ * the cube root there.
19219
+ */
19220
+ const shownChroma = ({ L, C }) => C * Math.min(1, (L / LINEAR_LIGHTNESS) ** 2);
19221
+
19222
+ /** Whether a color (its OKLCH lightness and chroma) has a hue a reader sees: its shown chroma at CHROMA_FLOOR or more. */
19223
+ const hasHue = (oklch) => shownChroma(oklch) >= CHROMA_FLOOR;
19224
+
19225
+ /**
19226
+ * The saturation a walk from a color keeps (shiftedUntil): its shown chroma
19227
+ * for its lightness. A color darker than LINEAR_LIGHTNESS with no hue a
19228
+ * reader sees keeps none, so it walks as a grey: a walk toward the light
19229
+ * would grow its trace into a hue. A lighter grey keeps its faint tint, which
19230
+ * its short walks barely move.
19231
+ */
19232
+ function saturationOf(oklch) {
19233
+ if (oklch.L <= 0 || (oklch.L < LINEAR_LIGHTNESS && !hasHue(oklch))) return 0;
19234
+ return shownChroma(oklch) / oklch.L;
19235
+ }
19236
+
19237
+ const drawable = (channels) => channels.every((channel) => channel >= 0 && channel <= 1);
19238
+
19239
+ /** The `#rrggbb` color at OKLCH lightness L and hue H, with as much of chroma C as sRGB holds there. */
19240
+ function colorAt(L, C, H) {
19241
+ let chroma = C;
19242
+ if (!drawable(linearOfOklch(L, chroma, H))) {
19243
+ let [low, high] = [0, C];
19244
+ for (let halving = 0; halving < 24; halving += 1) {
19245
+ const middle = (low + high) / 2;
19246
+ if (drawable(linearOfOklch(L, middle, H))) low = middle;
19247
+ else high = middle;
19248
+ }
19249
+ chroma = low;
19250
+ }
19251
+ return `#${linearOfOklch(L, chroma, H).map((channel) => Math.round(toGamma(Math.min(1, Math.max(0, channel))) * 255).toString(16).padStart(2, '0')).join('')}`;
19252
+ }
19253
+
19254
+ /** How far each step of a shift moves a color's OKLCH lightness. */
19255
+ const SHIFT_STEP = 0.005;
19256
+
19257
+ /**
19258
+ * A color as it stands where `reads` asks more of it: itself where it reads,
19259
+ * else moved in OKLCH lightness (up for `direction` 1, down for -1) at its
19260
+ * own hue, one step at a time, to the first step that reads, white or black
19261
+ * at the end. Its saturation (saturationOf), the chroma a reader sees for its
19262
+ * lightness, stays as it is, so a navy lifts to a clear blue of its own
19263
+ * family rather than greying out, with as much of that chroma as sRGB holds
19264
+ * at each step. Null where not even the end reads.
19265
+ *
19266
+ * @param {string} color - A validated brand color
19267
+ * @param {1|-1} direction
19268
+ * @param {(candidate: string) => boolean} reads
19269
+ * @returns {string|null}
19270
+ */
19271
+ function shiftedUntil(color, direction, reads) {
19272
+ if (reads(color)) return color;
19273
+ const oklch = oklchOf(color);
19274
+ const { L, H } = oklch;
19275
+ const saturation = saturationOf(oklch);
19276
+ for (let lightness = L + direction * SHIFT_STEP; lightness > 0 && lightness < 1; lightness += direction * SHIFT_STEP) {
19277
+ const shifted = colorAt(lightness, saturation * lightness, H);
19278
+ if (reads(shifted)) return shifted;
19279
+ }
19280
+ const end = direction > 0 ? '#ffffff' : '#000000';
19281
+ return reads(end) ? end : null;
19282
+ }
19283
+
19284
+ /**
19285
+ * A brand color as it may be stored and shown, or null when the value is not
19286
+ * one: a `#rrggbb` hex value, read case-insensitively.
19287
+ *
19288
+ * @param {unknown} value
19289
+ * @returns {string|null} The color in lowercase
19290
+ */
19291
+ function brandColor(value) {
19292
+ if (typeof value !== 'string') return null;
19293
+ const color = value.toLowerCase();
19294
+ return HEX_COLOR.test(color) ? color : null;
19295
+ }
19296
+
19297
+ /** How far a fill under the pointer moves at least, in OKLCH lightness. */
19298
+ const HOVER_SHIFT = 0.05;
19299
+
19300
+ /**
19301
+ * How far a fill under the pointer stands from the fill at least, as a
19302
+ * contrast ratio: where HOVER_SHIFT moves a very dark fill too little for a
19303
+ * reader to see (black's step is a 1.0:1 change), the hover moves on until
19304
+ * it stands this far apart.
19305
+ */
19306
+ const HOVER_CONTRAST = 1.1;
19307
+
19308
+ /**
19309
+ * A fill under the pointer: the first step in OKLCH lightness at its own hue
19310
+ * (shiftedUntil) at least HOVER_SHIFT from the fill that stands
19311
+ * HOVER_CONTRAST from it, away from its label (darker under white, lighter
19312
+ * under ink), so the label reads more strongly on it still, where that step
19313
+ * `stands` (for a dark fill, standsWhere: on the grounds it stands on, under
19314
+ * its label). Where it does not (a fill too near that end of the range, black
19315
+ * and its nearest neighbors under white or white under ink, or a dark fill
19316
+ * whose step away sinks into its grounds), the first such step toward its
19317
+ * label, where that one stands; a step further either way only moves further
19318
+ * from the fill. Null where neither stands.
19319
+ *
19320
+ * @param {string} fill - A `#rrggbb` color
19321
+ * @param {'white'|'ink'} onAccent - Its label
19322
+ * @param {(candidate: string) => boolean} [stands]
19323
+ * @returns {string|null}
19324
+ */
19325
+ function hoverOf(fill, onAccent, stands = () => true) {
19326
+ const { L } = oklchOf(fill);
19327
+ const luminance = relativeLuminance(fill);
19328
+ const apart = (candidate) => Math.abs(oklchOf(candidate).L - L) >= HOVER_SHIFT - Number.EPSILON
19329
+ && contrastRatio(relativeLuminance(candidate), luminance) >= HOVER_CONTRAST;
19330
+ const away = onAccent === 'white' ? -1 : 1;
19331
+ return [away, -away].map((direction) => shiftedUntil(fill, direction, apart)).find((step) => step !== null && stands(step)) ?? null;
19332
+ }
19333
+
19334
+ /**
19335
+ * Whether a dark fill's hover stands where the fill does: at
19336
+ * AA_NON_TEXT_CONTRAST on each of the grounds (their relative luminances),
19337
+ * under the fill's label at AA_TEXT_CONTRAST.
19338
+ *
19339
+ * @param {number[]} luminances
19340
+ * @param {'white'|'ink'} onAccent
19341
+ * @returns {(candidate: string) => boolean}
19342
+ */
19343
+ const standsWhere = (luminances, onAccent) => (candidate) => {
19344
+ const luminance = relativeLuminance(candidate);
19345
+ return lowestContrast(luminance, luminances) >= AA_NON_TEXT_CONTRAST
19346
+ && contrastRatio(luminance, onAccent === 'white' ? 1 : INK_LUMINANCE) >= AA_TEXT_CONTRAST;
19347
+ };
19348
+
19349
+ /**
19350
+ * @typedef {Object} AccentPairing
19351
+ * @property {string} fill - The fill of a primary action, `#rrggbb`
19352
+ * @property {'white'|'ink'} onAccent - The text on it: white, or the light ink (INK_COLOR)
19353
+ * @property {string} ink - The accent as text on the scheme's grounds, `#rrggbb`
19354
+ * @property {string} hover - The fill under the pointer, `#rrggbb`
19355
+ */
19356
+
19357
+ /**
19358
+ * What a brand color becomes on the light grounds (the white surface and the
19359
+ * canvas tone): its label, white or ink, whichever reads more strongly on
19360
+ * it; its fill, itself where that label reads on it at AA_TEXT_CONTRAST,
19361
+ * else moved in lightness away from the label (shiftedUntil) to the first
19362
+ * step where it does; the color itself as text where it reads at
19363
+ * AA_TEXT_CONTRAST on both grounds (accentTextContrast), INK_COLOR otherwise;
19364
+ * and its fill under the pointer (hoverOf).
19365
+ *
19366
+ * @param {unknown} value
19367
+ * @returns {AccentPairing|null} Null when the value is not a brand color
19368
+ */
19369
+ function lightAccent(value) {
19370
+ const color = brandColor(value);
19371
+ if (!color) return null;
19372
+ const luminance = relativeLuminance(color);
19373
+ const onAccent = labelOf(luminance);
19374
+ const fill = shiftedUntil(color, onAccent === 'white' ? -1 : 1, (candidate) => labelContrast(relativeLuminance(candidate)) >= AA_TEXT_CONTRAST);
19375
+ return { fill, onAccent, ink: textContrast(luminance) >= AA_TEXT_CONTRAST ? color : INK_COLOR, hover: hoverOf(fill, onAccent) };
19376
+ }
19377
+
19378
+ /**
19379
+ * The color a brand color starts its dark lift from: itself where it has a
19380
+ * hue a reader sees (hasHue), kept as it lifts; the dark scheme's ink
19381
+ * (DARK_INK_COLOR) for a grey or black, which has no hue to keep and lifted
19382
+ * would read as a disabled control.
19383
+ */
19384
+ const darkSource = (color) => (hasHue(oklchOf(color)) ? color : DARK_INK_COLOR);
19385
+
19386
+ /** The relative luminances of grounds given as sRGB channels. */
19387
+ const luminancesOf = (grounds) => grounds.map(channelLuminance);
19388
+
19389
+ /**
19390
+ * A brand color's fill on dark grounds: the color (darkSource) lifted
19391
+ * (shiftedUntil) until it stands at AA_NON_TEXT_CONTRAST on each of `grounds`,
19392
+ * white or ink, whichever reads more strongly on it, reads at
19393
+ * AA_TEXT_CONTRAST, and it has a fill under the pointer that stands there
19394
+ * too (hoverOf, standsWhere); that label; and that hover. A color that
19395
+ * already stands there is itself.
19396
+ *
19397
+ * @param {unknown} value
19398
+ * @param {number[][]} [grounds] - sRGB channels from 0 to 1; the dark app ramp's page and cards unless given
19399
+ * @returns {{ fill: string, onAccent: 'white'|'ink', hover: string }|null} Null when the value is not a brand color, or no lift stands on `grounds`
19400
+ */
19401
+ function darkAccentFill(value, grounds = DARK_FILL_GROUNDS) {
19402
+ const color = brandColor(value);
19403
+ if (!color) return null;
19404
+ const luminances = luminancesOf(grounds);
19405
+ // The step that stands, with its label and hover, kept from the walk that found it.
19406
+ let found = null;
19407
+ shiftedUntil(darkSource(color), 1, (candidate) => {
19408
+ const luminance = relativeLuminance(candidate);
19409
+ if (lowestContrast(luminance, luminances) < AA_NON_TEXT_CONTRAST || labelContrast(luminance) < AA_TEXT_CONTRAST) return false;
19410
+ const onAccent = labelOf(luminance);
19411
+ const hover = hoverOf(candidate, onAccent, standsWhere(luminances, onAccent));
19412
+ found = hover && { fill: candidate, onAccent, hover };
19413
+ return found !== null;
19414
+ });
19415
+ return found;
19416
+ }
19417
+
19418
+ /**
19419
+ * A brand color as text on dark grounds: the color (darkSource) lifted
19420
+ * (shiftedUntil) until it reads at AA_TEXT_CONTRAST on each of `grounds`. A
19421
+ * color that already reads there is itself.
19422
+ *
19423
+ * @param {unknown} value
19424
+ * @param {number[][]} [grounds] - sRGB channels from 0 to 1; the dark app ramp's page, cards and selection unless given
19425
+ * @returns {string|null} Null when the value is not a brand color, or no lift reads on `grounds`
19426
+ */
19427
+ function darkAccentInk(value, grounds = DARK_TEXT_GROUNDS) {
19428
+ const color = brandColor(value);
19429
+ if (!color) return null;
19430
+ const luminances = luminancesOf(grounds);
19431
+ return shiftedUntil(darkSource(color), 1, (candidate) => lowestContrast(relativeLuminance(candidate), luminances) >= AA_TEXT_CONTRAST);
19432
+ }
19433
+
19434
+ /**
19435
+ * What a brand color becomes on the design system's dark app grounds: its
19436
+ * fill and label (darkAccentFill) and its text (darkAccentInk), each lifted
19437
+ * at the color's own hue until it reads there. On a help center's own dark
19438
+ * ground the customer portal lifts this pairing again, with the same two,
19439
+ * against that ground and the grounds it draws from it.
19440
+ *
19441
+ * @param {unknown} value
19442
+ * @returns {AccentPairing|null} Null when the value is not a brand color
19443
+ */
19444
+ function darkAccent(value) {
19445
+ const fill = darkAccentFill(value);
19446
+ return fill && { ...fill, ink: darkAccentInk(value) };
19447
+ }
19448
+
19449
+ /**
19450
+ * A brand color's pairing in each scheme, derived once for whatever writes
19451
+ * them and weighs them together: on the light grounds (lightAccent) and on
19452
+ * the dark app grounds (darkAccent).
19453
+ *
19454
+ * @param {unknown} value
19455
+ * @returns {Readonly<{ light: AccentPairing, dark: AccentPairing }>|null} Null when the value is not a brand color
19456
+ */
19457
+ function schemePairings(value) {
19458
+ const light = lightAccent(value);
19459
+ return light && Object.freeze({ light, dark: darkAccent(value) });
19460
+ }
19461
+
19462
+ /**
19463
+ * How accentProperties writes white and each scheme's ink, the colors a
19464
+ * design-system token names: as those tokens (`tokens`), for a page whose
19465
+ * stylesheet declares them (the customer portal, the console's sample), or as
19466
+ * the colors themselves (`colors`), for a page that declares none (the SDK's
19467
+ * widget on a customer's website). Each token holds the color beside it.
19468
+ */
19469
+ const WRITINGS = Object.freeze({
19470
+ tokens: Object.freeze({ white: 'var(--color-white)', ink: 'var(--ink)', darkInk: 'var(--dark-app-ink)' }),
19471
+ colors: Object.freeze({ white: '#ffffff', ink: INK_COLOR, darkInk: DARK_INK_COLOR })
19472
+ });
19473
+
19474
+ /**
19475
+ * The accent custom properties for a desk's pairings (a brand color's,
19476
+ * schemePairings, or DEFAULT_PAIRINGS), for each scheme a help desk surface
19477
+ * paints in: on light grounds the fill (`--hd-light-accent`), the text on it
19478
+ * (`--hd-light-on-accent`), the accent as text (`--hd-light-accent-ink`) and
19479
+ * the fill under the pointer (`--hd-light-accent-hover`); on the dark app
19480
+ * grounds the same four (`--hd-dark-*`). The one place these names are
19481
+ * spelled: the customer portal's root, the console's sample and every element
19482
+ * of the SDK's widget carry what it returns.
19483
+ *
19484
+ * @param {{ light: AccentPairing, dark: AccentPairing }} pairings
19485
+ * @param {'tokens'|'colors'} [writing] - How white and each scheme's ink are written (WRITINGS)
19486
+ * @returns {Record<`--hd-${'light'|'dark'}-${'accent'|'on-accent'|'accent-ink'|'accent-hover'}`, string>}
19487
+ */
19488
+ function accentProperties(pairings, writing = 'tokens') {
19489
+ const { white, ink, darkInk } = WRITINGS[writing];
19490
+ const label = { white, ink };
19491
+ const { light, dark } = pairings;
19492
+ return {
19493
+ '--hd-light-accent': light.fill,
19494
+ '--hd-light-on-accent': label[light.onAccent],
19495
+ '--hd-light-accent-ink': light.ink === INK_COLOR ? ink : light.ink,
19496
+ '--hd-light-accent-hover': light.hover,
19497
+ '--hd-dark-accent': dark.fill === DARK_INK_COLOR ? darkInk : dark.fill,
19498
+ '--hd-dark-on-accent': label[dark.onAccent],
19499
+ '--hd-dark-accent-ink': dark.ink === DARK_INK_COLOR ? darkInk : dark.ink,
19500
+ '--hd-dark-accent-hover': dark.hover
19501
+ };
19502
+ }
19503
+
19504
+ /**
19505
+ * The help desk's color roles as every customer-facing piece of its UI reads
19506
+ * them, written once: the SDK's support launcher, its panel, the request
19507
+ * form and its modal (sdk-js products/help-desk) and the composer both share
19508
+ * (help-desk-composer.js). Each reads the customer portal's color role of the
19509
+ * same meaning (`--hd-*`, which the portal's root maps to its scheme's color
19510
+ * set), else the design system's light value, the one the portal's own light
19511
+ * set maps the role to, so on a page that sets none, a customer's own website
19512
+ * among them, the UI stays light.
19513
+ *
19514
+ * The accent reads the page's accent roles (`--hd-accent*`, which the portal's
19515
+ * root sets to the pairing its scheme paints), else the light pairing the
19516
+ * element it paints in carries (`--hd-light-accent*`: the SDK's launcher,
19517
+ * panel, form container and modal each carry the desk's), else the light
19518
+ * half of brand-color.js' DEFAULT_PAIRINGS, the pairing a desk without a
19519
+ * brand color takes.
19520
+ *
19521
+ * BROWSER-SAFE: data only; imports only brand-color.js.
19522
+ */
19523
+
19524
+
19525
+ /**
19526
+ * The light value of each design-system token a role falls back to, keyed by
19527
+ * that token (tests/help-desk-colors.test.js holds each to
19528
+ * packages/design-system/tokens). The canvas tone and the ink are
19529
+ * brand-color.js' mirrors of those tokens.
19530
+ */
19531
+ const HELP_DESK_LIGHT_COLORS = Object.freeze({
19532
+ '--surface': '#ffffff',
19533
+ '--canvas': CANVAS_COLOR,
19534
+ '--color-slate-100': '#f0f5f7',
19535
+ '--color-slate-200': '#e0e9ed',
19536
+ '--color-slate-300': '#c9d6dc',
19537
+ '--ink': INK_COLOR,
19538
+ '--text-body': '#425761',
19539
+ '--text-muted': '#5e757f',
19540
+ '--color-action-bg': '#eef4fe',
19541
+ '--color-error': '#b02b27'
19542
+ });
19543
+
19544
+ const LIGHT = HELP_DESK_LIGHT_COLORS;
19545
+
19546
+ /** The default pairings (DEFAULT_PAIRINGS) as the properties an element carries, written as colors: a page that declares none of the design system's tokens reads them. */
19547
+ const DEFAULT = accentProperties(DEFAULT_PAIRINGS, 'colors');
19548
+
19549
+ /** The neutral and error roles, each the page's `--hd-*` role, else its light value. */
19550
+ const HELP_DESK_COLORS = Object.freeze({
19551
+ /** A panel and its cards. */
19552
+ surface: `var(--hd-surface,${LIGHT['--surface']})`,
19553
+ /** A field's ground. */
19554
+ field: `var(--hd-field,${LIGHT['--surface']})`,
19555
+ /** A quiet ground: a question's recap, a note, code, a disabled field. */
19556
+ canvas: `var(--hd-canvas,${LIGHT['--canvas']})`,
19557
+ /** A raised row or control under the pointer. */
19558
+ hover: `var(--hd-hover,${LIGHT['--canvas']})`,
19559
+ /** An icon control under the pointer, and the quietest rules. */
19560
+ fill: `var(--hd-fill,${LIGHT['--color-slate-100']})`,
19561
+ /** Rules and edges. */
19562
+ fillStrong: `var(--hd-fill-strong,${LIGHT['--color-slate-200']})`,
19563
+ /** A field's and a secondary action's edge. */
19564
+ lineStrong: `var(--hd-line-strong,${LIGHT['--color-slate-300']})`,
19565
+ ink: `var(--hd-ink,${LIGHT['--ink']})`,
19566
+ body: `var(--hd-text-body,${LIGHT['--text-body']})`,
19567
+ muted: `var(--hd-text-muted,${LIGHT['--text-muted']})`,
19568
+ /** Selected text, and the composer's drop prompt. */
19569
+ selection: `var(--hd-selection,${LIGHT['--color-action-bg']})`,
19570
+ error: `var(--hd-error,${LIGHT['--color-error']})`
19571
+ });
19572
+
19573
+ /** The accent roles: the fill of a primary action, the text on it, the accent as text, and the fill under the pointer. */
19574
+ const HELP_DESK_ACCENT = Object.freeze({
19575
+ fill: `var(--hd-accent,var(--hd-light-accent,${DEFAULT['--hd-light-accent']}))`,
19576
+ onAccent: `var(--hd-on-accent,var(--hd-light-on-accent,${DEFAULT['--hd-light-on-accent']}))`,
19577
+ ink: `var(--hd-accent-ink,var(--hd-light-accent-ink,${DEFAULT['--hd-light-accent-ink']}))`,
19578
+ hover: `var(--hd-accent-hover,var(--hd-light-accent-hover,${DEFAULT['--hd-light-accent-hover']}))`
19579
+ });
19580
+
19581
+ /** The focus ring's color: the page's `--hd-focus` where it sets one, else the accent as text. */
19582
+ const HELP_DESK_FOCUS = `var(--hd-focus,${HELP_DESK_ACCENT.ink})`;
19583
+
19584
+ /**
19585
+ * Both schemes' pairings as the custom properties an element carries them
19586
+ * under (@sparkvault/app-sdk/brand-color accentProperties: `--hd-light-accent*`,
19587
+ * `--hd-dark-accent*`), written as colors, since a customer's website declares
19588
+ * none of the design system's tokens.
19589
+ */
19590
+ function pairingProperties(pairings) {
19591
+ return Object.freeze(accentProperties(pairings, 'colors'));
19592
+ }
19593
+ /** The default pairings (@sparkvault/app-sdk/brand-color DEFAULT_PAIRINGS) as the custom properties, every one an element can carry. */
19594
+ const DEFAULT_PROPERTIES = pairingProperties(DEFAULT_PAIRINGS);
19595
+ /**
19596
+ * The default pairings (@sparkvault/app-sdk/brand-color DEFAULT_PAIRINGS, the
19597
+ * ones the customer portal, the console's sample and the desk's email paint
19598
+ * for a desk without a brand color) as stylesheet declarations, which a
19599
+ * desk's brand color replaces (applySupportBrand). The launcher, the support
19600
+ * panel, the request form's container and its modal each carry them, so the
19601
+ * accent roles (@sparkvault/app-sdk/help-desk-colors HELP_DESK_ACCENT) read
19602
+ * the light pairing the element carries, and a website may point those roles
19603
+ * at the dark one.
19604
+ */
19605
+ const DEFAULT_PAIRING_DECLARATIONS = Object.entries(DEFAULT_PROPERTIES).map(([name, value]) => `${name}:${value}`).join(';');
19606
+ const NO_BRAND = Object.freeze({ color: null, properties: null });
19607
+ /**
19608
+ * Pairs a desk's brand color for every carrier, once: both of its pairings
19609
+ * (@sparkvault/app-sdk/brand-color schemePairings, the ones the customer
19610
+ * portal and the desk's email paint too), under each scheme's names: the
19611
+ * fill, white or the ink on it, the accent as text, and the fill under the
19612
+ * pointer. Whoever learns the desk's color derives it and hands the one brand
19613
+ * to each element it paints (applySupportBrand), so a desk's color is paired
19614
+ * once however often its elements render. A value that is no brand color is
19615
+ * none.
19616
+ */
19617
+ function supportBrand(value) {
19618
+ const color = brandColor(value);
19619
+ const pairings = color === null ? null : schemePairings(color);
19620
+ return pairings ? Object.freeze({ color, properties: pairingProperties(pairings) }) : NO_BRAND;
19621
+ }
19622
+ /**
19623
+ * The brand for a desk's color: `held` where it pairs that same color, so a
19624
+ * color learned again (a held desk's, then connect's answer for it) is paired
19625
+ * once and stays the one object every element compares.
19626
+ */
19627
+ function brandFor(value, held) {
19628
+ return brandColor(value) === held.color ? held : supportBrand(value);
19629
+ }
19630
+ /**
19631
+ * Sets a desk's brand (supportBrand) on the launcher, the support panel, the
19632
+ * request form's container or the form's modal. The stylesheet paints the
19633
+ * light pairing wherever the accent roles (`--hd-accent*`) are not set, so on
19634
+ * a website the widget's accent is the pairing the portal paints on light
19635
+ * pages until the page points the roles at the dark pairing, and inside the
19636
+ * customer portal each takes the portal's roles. Scoped to the element, so it
19637
+ * works on a hosted page and on any website the widget stands on; a brand
19638
+ * with no color clears them, and the stylesheet's default pairings return.
19639
+ */
19640
+ function applySupportBrand(target, brand) {
19641
+ for (const name of Object.keys(DEFAULT_PROPERTIES)) {
19642
+ const value = brand.properties?.[name];
19643
+ if (value)
19644
+ target.style.setProperty(name, value);
19645
+ else
19646
+ target.style.removeProperty(name);
19647
+ }
19648
+ }
19649
+
19650
+ /**
19651
+ * Scoped styles for the optional inline help desk form and its modal, in the
19652
+ * help desk's color roles (@sparkvault/app-sdk/help-desk-colors): their
19653
+ * neutrals the page's roles where it sets them (HOST), their accent the
19654
+ * page's accent roles, else the desk's light pairing, which the form's
19655
+ * container and the modal each carry (ACCENT, DEFAULT_PAIRING_DECLARATIONS),
19656
+ * as the support panel does.
19657
+ */
18853
19658
  function injectHelpDeskFormStyles() {
18854
19659
  if (document.getElementById('sparkvault-help-desk-styles'))
18855
19660
  return;
@@ -18858,33 +19663,33 @@ function injectHelpDeskFormStyles() {
18858
19663
  style.textContent = `
18859
19664
  .svhd-overlay{position:fixed;inset:0;z-index:2147483000;display:flex;align-items:center;justify-content:center;padding:16px;background:${DS.modalOverlay};overflow:auto}
18860
19665
  .svhd-blur{backdrop-filter:blur(5px)}
18861
- .svhd-modal{width:100%;max-width:36rem;max-height:calc(100dvh - 32px);overflow:auto;border-radius:12px;background:${DS.white};box-shadow:${DS.shadowPopover}}
19666
+ .svhd-modal{width:100%;max-width:36rem;max-height:calc(100dvh - 32px);overflow:auto;border-radius:12px;background:${HELP_DESK_COLORS.surface};box-shadow:${DS.shadowPopover};${DEFAULT_PAIRING_DECLARATIONS}}
18862
19667
  .svhd-modal-header{display:flex;justify-content:flex-end;padding:12px 16px 0}
18863
- .svhd-modal-close{border:0;border-radius:4px;background:transparent;color:${DS.slate600};cursor:pointer;font:600 14px/1.5 system-ui,sans-serif;padding:6px 8px;min-height:44px}
18864
- .svhd-modal-close:hover{color:${DS.slate900}}
18865
- .svhd-modal-close:focus-visible{outline:3px solid ${DS.action};outline-offset:2px}
19668
+ .svhd-modal-close{border:0;border-radius:4px;background:transparent;color:${HELP_DESK_COLORS.body};cursor:pointer;font:600 14px/1.5 system-ui,sans-serif;padding:6px 8px;min-height:44px}
19669
+ .svhd-modal-close:hover{color:${HELP_DESK_COLORS.ink}}
19670
+ .svhd-modal-close:focus-visible{outline:3px solid ${HELP_DESK_FOCUS};outline-offset:2px}
18866
19671
  .svhd-modal .svhd-container{max-width:none;border:0;border-radius:0;padding-top:8px}
18867
- .svhd-container{box-sizing:border-box;max-width:36rem;border:1px solid ${DS.slate200};border-radius:12px;background:${DS.white};color:${DS.slate900};font:400 15px/1.5 system-ui,sans-serif;padding:24px}
19672
+ .svhd-container{box-sizing:border-box;max-width:36rem;border:1px solid ${HELP_DESK_COLORS.fillStrong};border-radius:12px;background:${HELP_DESK_COLORS.surface};color:${HELP_DESK_COLORS.ink};font:400 15px/1.5 system-ui,sans-serif;padding:24px;${DEFAULT_PAIRING_DECLARATIONS}}
18868
19673
  .svhd-container *{box-sizing:border-box}
18869
19674
  .svhd-container h2{font-size:22px;line-height:1.25;margin:0}
18870
19675
  .svhd-step-head h2:focus{outline:none}
18871
19676
  .svhd-form{display:grid;gap:16px}
18872
19677
  .svhd-field{display:grid;gap:6px}
18873
19678
  .svhd-label{font-weight:600}
18874
- .svhd-input{width:100%;border:1px solid ${DS.slate300};border-radius:6px;padding:10px 12px;color:${DS.slate900};background:${DS.white};font:inherit;font-size:16px}
18875
- .svhd-input:focus-visible,.svhd-button:focus-visible,.svhd-link:focus-visible{outline:3px solid ${DS.action};outline-offset:2px}
18876
- .svhd-input:disabled{background:${DS.slate50}}
19679
+ .svhd-input{width:100%;border:1px solid ${HELP_DESK_COLORS.lineStrong};border-radius:6px;padding:10px 12px;color:${HELP_DESK_COLORS.ink};background:${HELP_DESK_COLORS.field};font:inherit;font-size:16px}
19680
+ .svhd-input:focus-visible,.svhd-button:focus-visible,.svhd-link:focus-visible{outline:3px solid ${HELP_DESK_FOCUS};outline-offset:2px}
19681
+ .svhd-input:disabled{background:${HELP_DESK_COLORS.canvas}}
18877
19682
  .svhd-auth{display:grid;gap:16px;border:0;padding:0;margin:0}
18878
19683
  .svhd-form[hidden],.svhd-step[hidden],.svhd-auth[hidden],.svhd-field[hidden],.svhd-field-error[hidden],.svhd-status[hidden],.svhd-link[hidden],.svhd-actions[hidden],.svhd-confirm[hidden],.svhd-widget-account[hidden],.svhd-text-button[hidden]{display:none}
18879
19684
  .svhd-actions{display:flex;align-items:center;gap:12px;flex-wrap:wrap}
18880
- .svhd-button{border:0;border-radius:6px;padding:10px 16px;min-height:44px;font:600 15px/1.5 system-ui,sans-serif;background:${DS.action};color:${DS.white};cursor:pointer}
18881
- .svhd-button:hover{background:${DS.actionHover}}
19685
+ .svhd-button{border:0;border-radius:6px;padding:10px 16px;min-height:44px;font:600 15px/1.5 system-ui,sans-serif;background:${HELP_DESK_ACCENT.fill};color:${HELP_DESK_ACCENT.onAccent};cursor:pointer}
19686
+ .svhd-button:hover{background:${HELP_DESK_ACCENT.hover}}
18882
19687
  .svhd-button:disabled{opacity:.6;cursor:default}
18883
- .svhd-secondary{background:transparent;color:${DS.slate600};padding:10px 4px}
18884
- .svhd-secondary:hover{background:transparent;color:${DS.slate900}}
18885
- .svhd-status{margin:0;color:${DS.slate600}}
18886
- .svhd-error{color:${DS.error}}
18887
- .svhd-field-error{margin:0;font-size:14px;color:${DS.error}}
19688
+ .svhd-secondary{background:transparent;color:${HELP_DESK_COLORS.body};padding:10px 4px}
19689
+ .svhd-secondary:hover{background:transparent;color:${HELP_DESK_COLORS.ink}}
19690
+ .svhd-status{margin:0;color:${HELP_DESK_COLORS.body}}
19691
+ .svhd-error{color:${HELP_DESK_COLORS.error}}
19692
+ .svhd-field-error{margin:0;font-size:14px;color:${HELP_DESK_COLORS.error}}
18888
19693
  .svhd-code-links{display:flex;flex-wrap:wrap;gap:4px 16px}
18889
19694
  .svhd-confirm{display:grid;gap:8px}
18890
19695
  .svhd-confirm-title{font-weight:600;margin:0}
@@ -18892,26 +19697,26 @@ function injectHelpDeskFormStyles() {
18892
19697
  .svhd-done-title{font-size:18px;line-height:1.3;margin:0}
18893
19698
  .svhd-done-title:focus{outline:none}
18894
19699
  .svhd-confirmation-message{white-space:pre-wrap;overflow-wrap:anywhere}
18895
- .svhd-link{display:inline-flex;align-items:center;justify-self:start;min-height:44px;color:${DS.action};text-decoration:underline}
18896
- .svhd-hint{font-size:13px;color:${DS.slate600};margin:0}
19700
+ .svhd-link{display:inline-flex;align-items:center;justify-self:start;min-height:44px;color:${HELP_DESK_ACCENT.ink};text-decoration:underline}
19701
+ .svhd-hint{font-size:13px;color:${HELP_DESK_COLORS.body};margin:0}
18897
19702
  .svhd-step{display:grid;gap:16px;min-width:0}
18898
19703
  .svhd-step-head{display:grid;gap:4px;margin-bottom:4px}
18899
- .svhd-step-label{margin:0;font-size:13px;font-weight:600;line-height:1.4;color:${DS.slate600}}
18900
- .svhd-text-button{display:inline-flex;align-items:center;min-height:44px;padding:0 4px;border:0;border-radius:6px;background:transparent;color:${DS.action};font:inherit;font-size:14px;font-weight:600;text-decoration:underline;text-underline-offset:2px;cursor:pointer}
18901
- .svhd-text-button:hover{color:${DS.actionHover}}
18902
- .svhd-text-button:focus-visible{outline:3px solid ${DS.action};outline-offset:2px}
18903
- .svhd-text-button:disabled{color:${DS.slate500};cursor:default}
19704
+ .svhd-step-label{margin:0;font-size:13px;font-weight:600;line-height:1.4;color:${HELP_DESK_COLORS.body}}
19705
+ .svhd-text-button{display:inline-flex;align-items:center;min-height:44px;padding:0 4px;border:0;border-radius:6px;background:transparent;color:${HELP_DESK_ACCENT.ink};font:inherit;font-size:14px;font-weight:600;text-decoration:underline;text-underline-offset:2px;cursor:pointer}
19706
+ .svhd-text-button:not(:disabled):hover{text-decoration-thickness:2px}
19707
+ .svhd-text-button:focus-visible{outline:3px solid ${HELP_DESK_FOCUS};outline-offset:2px}
19708
+ .svhd-text-button:disabled{color:${HELP_DESK_COLORS.muted};cursor:default}
18904
19709
  .svhd-widget-account{display:flex;align-items:center;flex-wrap:wrap;gap:0 16px;min-width:0}
18905
- .svhd-posting-as{margin:0;color:${DS.slate600};font-size:14px;line-height:1.5;overflow-wrap:anywhere}
18906
- .svhd-note{display:flex;align-items:flex-start;gap:10px;margin:0;padding:12px 14px;border:1px solid ${DS.slate200};border-radius:8px;background:${DS.slate50};color:${DS.slate900};font-size:14px;line-height:1.5}
18907
- .svhd-step .svhd-note svg{display:block;width:18px;height:18px;flex:none;margin-top:2px;color:${DS.action}}
18908
- .svhd-recap{display:flex;align-items:center;gap:12px;padding:6px 6px 6px 14px;border:1px solid ${DS.slate200};border-radius:8px}
19710
+ .svhd-posting-as{margin:0;color:${HELP_DESK_COLORS.body};font-size:14px;line-height:1.5;overflow-wrap:anywhere}
19711
+ .svhd-note{display:flex;align-items:flex-start;gap:10px;margin:0;padding:12px 14px;border:1px solid ${HELP_DESK_COLORS.fillStrong};border-radius:8px;background:${HELP_DESK_COLORS.canvas};color:${HELP_DESK_COLORS.ink};font-size:14px;line-height:1.5}
19712
+ .svhd-step .svhd-note svg{display:block;width:18px;height:18px;flex:none;margin-top:2px;color:${HELP_DESK_ACCENT.ink}}
19713
+ .svhd-recap{display:flex;align-items:center;gap:12px;padding:6px 6px 6px 14px;border:1px solid ${HELP_DESK_COLORS.fillStrong};border-radius:8px}
18909
19714
  .svhd-recap-request{flex:1;min-width:0}
18910
- .svhd-recap-label{display:block;color:${DS.slate600};font-size:12px;font-weight:600;line-height:1.4}
18911
- .svhd-recap-text{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;margin:0;color:${DS.slate900};font-size:14px;line-height:1.5;overflow-wrap:anywhere}
19715
+ .svhd-recap-label{display:block;color:${HELP_DESK_COLORS.body};font-size:12px;font-weight:600;line-height:1.4}
19716
+ .svhd-recap-text{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;margin:0;color:${HELP_DESK_COLORS.ink};font-size:14px;line-height:1.5;overflow-wrap:anywhere}
18912
19717
  .svhd-recap .svhd-text-button{flex:none}
18913
19718
  .svhd-live{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
18914
- .svhd-footer{margin-top:20px;font-size:12px;color:${DS.slate500}}
19719
+ .svhd-footer{margin-top:20px;font-size:12px;color:${HELP_DESK_COLORS.muted}}
18915
19720
  `;
18916
19721
  document.head.appendChild(style);
18917
19722
  }
@@ -19530,123 +20335,6 @@ function refusalCopy(refusal, maxBytes) {
19530
20335
  return REFUSAL_COPY[refusal] ?? "This file can't be attached.";
19531
20336
  }
19532
20337
 
19533
- /**
19534
- * A tenant's brand color and the WCAG contrast rules that decide how it may be
19535
- * used: the one hex rule the server stores, the console checks and the portal
19536
- * paints, the one contrast reading the console's readouts, the portal's
19537
- * accent and the portal's reading of a help center's ground share, and the
19538
- * one way a readout writes that reading.
19539
- *
19540
- * A brand color is tenant-controlled, so it is used only when it is a
19541
- * six-digit hex color, read case-insensitively and held in lowercase; anything
19542
- * else (a color name, a CSS function, a value that runs on into more CSS) is
19543
- * no color at all.
19544
- *
19545
- * A brand color can be any lightness, so whatever shows it picks what goes
19546
- * with it: white or ink as the text on its fill, whichever reads more
19547
- * strongly (at least 4.2:1 on any fill, as far as two inks reach on a
19548
- * mid-tone), and the color itself as text only where it reaches 4.5:1 on
19549
- * both grounds accent text stands on, the white surface and the canvas
19550
- * tone, ink otherwise. accentProperties says that as the accent
19551
- * custom properties the customer portal paints with and the console's sample
19552
- * of it shows, in the design system's own tokens.
19553
- *
19554
- * BROWSER-SAFE: data only, no imports.
19555
- */
19556
-
19557
- const HEX_COLOR = /^#[0-9a-f]{6}$/;
19558
-
19559
- /** WCAG AA's floor for normal-size text. */
19560
- const AA_TEXT_CONTRAST = 4.5;
19561
-
19562
- /**
19563
- * The canvas tone, the design system's `--canvas` (`--color-slate-50`): the
19564
- * page ground the customer portal (its pages and a customer's own messages)
19565
- * and the knowledge base's default theme set accent text on, beside the white
19566
- * surface. The design system publishes its tokens only as CSS, which this
19567
- * import-free module cannot read, so the value is mirrored here once, and
19568
- * tests/brand-color.test.js holds it to packages/design-system/tokens/colors.css.
19569
- */
19570
- const CANVAS_COLOR = '#f7fafb';
19571
-
19572
- /**
19573
- * The ink, the design system's `--ink` (`--color-slate-900`): the dark text a
19574
- * pairing paints on a fill and in place of a color too light to stand as
19575
- * text. Mirrored here once for the same reason as CANVAS_COLOR, and held to
19576
- * packages/design-system/tokens/colors.css by tests/brand-color.test.js.
19577
- */
19578
- const INK_COLOR = '#0d1a20';
19579
-
19580
- /** Relative luminance (WCAG 2) of an sRGB color's red, green and blue channels, each from 0 to 1. */
19581
- function channelLuminance(channels) {
19582
- const [red, green, blue] = channels.map((channel) => (channel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4));
19583
- return 0.2126 * red + 0.7152 * green + 0.0722 * blue;
19584
- }
19585
-
19586
- /** Relative luminance (WCAG 2) of a validated `#rrggbb` color. */
19587
- function relativeLuminance(color) {
19588
- return channelLuminance([1, 3, 5].map((offset) => Number.parseInt(color.slice(offset, offset + 2), 16) / 255));
19589
- }
19590
-
19591
- /** The contrast ratio of two relative luminances. */
19592
- function contrastRatio(first, second) {
19593
- return (Math.max(first, second) + 0.05) / (Math.min(first, second) + 0.05);
19594
- }
19595
-
19596
- /** The relative luminance of the ink a fill's text is weighed in, the real ink rather than pure black. */
19597
- const INK_LUMINANCE = relativeLuminance(INK_COLOR);
19598
-
19599
- /** The relative luminances of the grounds accent text stands on: the white surface and the canvas tone. */
19600
- const TEXT_GROUNDS = Object.freeze([1, relativeLuminance(CANVAS_COLOR)]);
19601
-
19602
- /** How strongly a color of this luminance reads as text on the ground it reads least on. */
19603
- function textContrast(luminance) {
19604
- return Math.min(...TEXT_GROUNDS.map((ground) => contrastRatio(luminance, ground)));
19605
- }
19606
-
19607
- /**
19608
- * A brand color as it may be stored and shown, or null when the value is not
19609
- * one: a `#rrggbb` hex value, read case-insensitively.
19610
- *
19611
- * @param {unknown} value
19612
- * @returns {string|null} The color in lowercase
19613
- */
19614
- function brandColor(value) {
19615
- if (typeof value !== 'string') return null;
19616
- const color = value.toLowerCase();
19617
- return HEX_COLOR.test(color) ? color : null;
19618
- }
19619
-
19620
- /**
19621
- * What goes with a brand color: the text on its fill (white or ink,
19622
- * whichever reads more strongly, at least 4.2:1 on any fill) and the ink for
19623
- * it as text
19624
- * (the color itself where it reaches AA_TEXT_CONTRAST on both the white
19625
- * surface and the canvas tone, ink otherwise).
19626
- *
19627
- * @param {unknown} value
19628
- * @returns {{ onAccent: 'white'|'ink', accentInk: 'accent'|'ink', ratio: number }|null} Null when the value is not a brand color; `ratio` is its contrast as text (accentTextContrast)
19629
- */
19630
- function accentPairing(value) {
19631
- const color = brandColor(value);
19632
- if (!color) return null;
19633
- const luminance = relativeLuminance(color);
19634
- const ratio = textContrast(luminance);
19635
- return {
19636
- onAccent: contrastRatio(luminance, 1) >= contrastRatio(luminance, INK_LUMINANCE) ? 'white' : 'ink',
19637
- accentInk: ratio >= AA_TEXT_CONTRAST ? 'accent' : 'ink',
19638
- ratio
19639
- };
19640
- }
19641
-
19642
- /** Contrast between a brand fill and the label selected by accentPairing. */
19643
- function accentFillContrast(value) {
19644
- const color = brandColor(value);
19645
- if (!color) return null;
19646
- const pairing = accentPairing(color);
19647
- return contrastRatio(relativeLuminance(color), pairing.onAccent === 'white' ? 1 : INK_LUMINANCE);
19648
- }
19649
-
19650
20338
  /**
19651
20339
  * Files brought to a message's composer by drag, drop and paste, handled
19652
20340
  * alike by every composer that takes them: the console's reply composer and
@@ -19930,11 +20618,14 @@ function helpDeskIcon(name) {
19930
20618
  * and whether trying again can mend it.
19931
20619
  *
19932
20620
  * The composer draws its own stylesheet (one unlayered `<style>` per
19933
- * document), in the design system's colors with the help desk's accent
19934
- * (`--hd-accent-ink`) where the host sets one. Its focus ring is the one the
19935
- * host's fields wear: its color, width and offset are the host's
19936
- * `--hd-focus`, `--hd-focus-width` and `--hd-focus-offset`, else the SDK's
19937
- * field ring (Action Blue, 3px, 2px out).
20621
+ * document), in the help desk's color roles (help-desk-colors.js): the
20622
+ * host's where it sets them, else the design system's light values, with the
20623
+ * help desk's accent as text, the light pairing of the SDK's panel, form
20624
+ * container or modal it stands in where the host sets no accent role. Its
20625
+ * focus ring is the one the host's fields wear: its color, width and offset
20626
+ * are the host's `--hd-focus`, `--hd-focus-width` and `--hd-focus-offset`,
20627
+ * the color else that accent, the width and offset else the SDK's field
20628
+ * ring's (3px, 2px out).
19938
20629
  *
19939
20630
  * BROWSER-SAFE: builds its DOM through the page's `document`, and imports
19940
20631
  * only app-sdk's browser-safe modules.
@@ -19944,34 +20635,11 @@ function helpDeskIcon(name) {
19944
20635
  /** The id of the composer's one `<style>` element in a document. */
19945
20636
  const HELP_DESK_COMPOSER_STYLE_ID = 'sparkvault-help-desk-composer-styles';
19946
20637
 
19947
- /**
19948
- * The design-system colors the composer is drawn in, each the value of the
19949
- * token it names (tests/help-desk-composer.test.js holds them to
19950
- * packages/design-system/tokens). The canvas tone and the ink are
19951
- * brand-color.js' mirrors of those tokens.
19952
- */
19953
- const COMPOSER_COLORS = Object.freeze({
19954
- '--color-white': '#ffffff',
19955
- '--canvas': CANVAS_COLOR,
19956
- '--color-slate-100': '#f0f5f7',
19957
- '--color-slate-200': '#e0e9ed',
19958
- '--color-slate-300': '#c9d6dc',
19959
- '--color-slate-600': '#425761',
19960
- '--ink': INK_COLOR,
19961
- '--color-action': '#216bde',
19962
- '--color-action-bg': '#eef4fe',
19963
- '--color-error': '#b02b27'
19964
- });
19965
-
19966
- const C = COMPOSER_COLORS;
19967
- /** The help desk's accent ink where the host sets one, Action Blue where none does. */
19968
- const ACCENT_INK = `var(--hd-accent-ink,${C['--color-action']})`;
19969
- /** The focus ring of the host's fields: the SDK's field ring (`.svhd-input`) where the host sets none. */
19970
- const FOCUS = `var(--hd-focus,${C['--color-action']})`;
20638
+ /** The focus ring's width and offset: the host's where it sets them, else the SDK's field ring (`.svhd-input`). */
19971
20639
  const FOCUS_WIDTH = 'var(--hd-focus-width,3px)';
19972
20640
  const FOCUS_OFFSET = 'var(--hd-focus-offset,2px)';
19973
20641
  /** A control inside the frame wears the ring within its own hit area. */
19974
- const INSET_RING = `outline:${FOCUS_WIDTH} solid ${FOCUS};outline-offset:calc(-1 * ${FOCUS_WIDTH});box-shadow:none`;
20642
+ const INSET_RING = `outline:${FOCUS_WIDTH} solid ${HELP_DESK_FOCUS};outline-offset:calc(-1 * ${FOCUS_WIDTH});box-shadow:none`;
19975
20643
 
19976
20644
  /**
19977
20645
  * The composer's stylesheet. Every rule but the notice's sits under
@@ -19981,41 +20649,41 @@ const INSET_RING = `outline:${FOCUS_WIDTH} solid ${FOCUS};outline-offset:calc(-1
19981
20649
  */
19982
20650
  const COMPOSER_CSS = `
19983
20651
  .svhd-composer,.svhd-composer *{box-sizing:border-box}
19984
- .svhd-composer{position:relative;display:flex;flex-direction:column;min-width:0;border:1px solid ${C['--color-slate-300']};border-radius:6px;background:${C['--color-white']};color:${C['--ink']}}
19985
- .svhd-composer:has(.svhd-composer-input:focus-visible){outline:${FOCUS_WIDTH} solid ${FOCUS};outline-offset:${FOCUS_OFFSET}}
19986
- @supports not selector(:has(*)){.svhd-composer:focus-within{outline:${FOCUS_WIDTH} solid ${FOCUS};outline-offset:${FOCUS_OFFSET}}}
19987
- .svhd-composer:has(.svhd-composer-input[aria-invalid=true]){border-color:${C['--color-error']}}
19988
- .svhd-composer.svhd-composer-dragging{border-style:dashed;border-color:${ACCENT_INK}}
19989
- .svhd-composer .svhd-composer-input{display:block;width:100%;min-height:140px;margin:0;resize:vertical;border:0;border-radius:6px 6px 0 0;padding:10px 12px;background:transparent;color:${C['--ink']};font-family:inherit;font-size:16px;line-height:1.5}
20652
+ .svhd-composer{position:relative;display:flex;flex-direction:column;min-width:0;border:1px solid ${HELP_DESK_COLORS.lineStrong};border-radius:6px;background:${HELP_DESK_COLORS.field};color:${HELP_DESK_COLORS.ink}}
20653
+ .svhd-composer:has(.svhd-composer-input:focus-visible){outline:${FOCUS_WIDTH} solid ${HELP_DESK_FOCUS};outline-offset:${FOCUS_OFFSET}}
20654
+ @supports not selector(:has(*)){.svhd-composer:focus-within{outline:${FOCUS_WIDTH} solid ${HELP_DESK_FOCUS};outline-offset:${FOCUS_OFFSET}}}
20655
+ .svhd-composer:has(.svhd-composer-input[aria-invalid=true]){border-color:${HELP_DESK_COLORS.error}}
20656
+ .svhd-composer.svhd-composer-dragging{border-style:dashed;border-color:${HELP_DESK_ACCENT.ink}}
20657
+ .svhd-composer .svhd-composer-input{display:block;width:100%;min-height:140px;margin:0;resize:vertical;border:0;border-radius:6px 6px 0 0;padding:10px 12px;background:transparent;color:${HELP_DESK_COLORS.ink};font-family:inherit;font-size:16px;line-height:1.5}
19990
20658
  .svhd-composer .svhd-composer-input:focus,.svhd-composer .svhd-composer-input:focus-visible{outline:none;box-shadow:none}
19991
- .svhd-composer .svhd-composer-input:disabled{background:${C['--canvas']}}
19992
- .svhd-composer .svhd-composer-drop{position:absolute;inset:0;z-index:1;display:flex;align-items:center;justify-content:center;margin:0;padding:12px;border-radius:5px;background:${C['--color-action-bg']};color:${ACCENT_INK};font-size:15px;font-weight:600;line-height:1.4;text-align:center;pointer-events:none}
19993
- .svhd-composer .svhd-composer-toolbar{display:flex;align-items:center;flex-wrap:wrap;gap:0 4px;padding:0 4px;border-top:1px solid ${C['--color-slate-200']}}
19994
- .svhd-composer .svhd-composer-attach{display:inline-flex;align-items:center;gap:6px;min-height:44px;margin:0;padding:0 8px;border:0;border-radius:6px;background:transparent;color:${C['--color-slate-600']};font-family:inherit;font-size:14px;font-weight:600;line-height:1.4;cursor:pointer}
19995
- .svhd-composer .svhd-composer-attach:hover,.svhd-composer .svhd-composer-help:hover{background:${C['--color-slate-100']};color:${C['--ink']}}
20659
+ .svhd-composer .svhd-composer-input:disabled{background:${HELP_DESK_COLORS.canvas}}
20660
+ .svhd-composer .svhd-composer-drop{position:absolute;inset:0;z-index:1;display:flex;align-items:center;justify-content:center;margin:0;padding:12px;border-radius:5px;background:${HELP_DESK_COLORS.selection};color:${HELP_DESK_ACCENT.ink};font-size:15px;font-weight:600;line-height:1.4;text-align:center;pointer-events:none}
20661
+ .svhd-composer .svhd-composer-toolbar{display:flex;align-items:center;flex-wrap:wrap;gap:0 4px;padding:0 4px;border-top:1px solid ${HELP_DESK_COLORS.fillStrong}}
20662
+ .svhd-composer .svhd-composer-attach{display:inline-flex;align-items:center;gap:6px;min-height:44px;margin:0;padding:0 8px;border:0;border-radius:6px;background:transparent;color:${HELP_DESK_COLORS.body};font-family:inherit;font-size:14px;font-weight:600;line-height:1.4;cursor:pointer}
20663
+ .svhd-composer .svhd-composer-attach:hover,.svhd-composer .svhd-composer-help:hover{background:${HELP_DESK_COLORS.fill};color:${HELP_DESK_COLORS.ink}}
19996
20664
  .svhd-composer .svhd-composer-attach:disabled{opacity:.6;cursor:default}
19997
20665
  .svhd-composer .svhd-composer-attach svg{display:block;width:18px;height:18px}
19998
- .svhd-composer .svhd-composer-help{display:inline-grid;place-items:center;width:44px;height:44px;margin:0;padding:0;border:0;border-radius:6px;background:transparent;color:${C['--color-slate-600']};font-family:inherit;cursor:pointer}
20666
+ .svhd-composer .svhd-composer-help{display:inline-grid;place-items:center;width:44px;height:44px;margin:0;padding:0;border:0;border-radius:6px;background:transparent;color:${HELP_DESK_COLORS.body};font-family:inherit;cursor:pointer}
19999
20667
  .svhd-composer .svhd-composer-help-glyph{display:inline-grid;place-items:center;width:20px;height:20px;border:1px solid currentColor;border-radius:50%;font-size:13px;font-weight:600;line-height:1}
20000
- .svhd-composer .svhd-composer-help-panel{display:grid;grid-template-columns:minmax(0,1fr) auto;column-gap:8px;align-items:start;flex:1 1 100%;min-width:0;margin:0 0 8px;padding:10px 12px;border:1px solid ${C['--color-slate-200']};border-radius:6px;background:${C['--canvas']};color:${C['--color-slate-600']};font-size:13px;line-height:1.5}
20668
+ .svhd-composer .svhd-composer-help-panel{display:grid;grid-template-columns:minmax(0,1fr) auto;column-gap:8px;align-items:start;flex:1 1 100%;min-width:0;margin:0 0 8px;padding:10px 12px;border:1px solid ${HELP_DESK_COLORS.fillStrong};border-radius:6px;background:${HELP_DESK_COLORS.canvas};color:${HELP_DESK_COLORS.body};font-size:13px;line-height:1.5}
20001
20669
  .svhd-composer .svhd-composer-help-copy{grid-column:1;min-width:0;overflow-wrap:anywhere}
20002
20670
  .svhd-composer .svhd-composer-help-copy p{margin:0}
20003
20671
  .svhd-composer .svhd-composer-help-copy p+p{margin-top:6px}
20004
- .svhd-composer .svhd-composer-help-close{grid-row:1;grid-column:2;display:grid;place-items:center;width:44px;height:44px;margin:-10px -12px 0 0;padding:0;border:0;border-radius:6px;background:transparent;color:${C['--color-slate-600']};cursor:pointer}
20005
- .svhd-composer .svhd-composer-help-close:hover,.svhd-composer .svhd-attachment-remove:hover{background:${C['--color-slate-200']};color:${C['--ink']}}
20672
+ .svhd-composer .svhd-composer-help-close{grid-row:1;grid-column:2;display:grid;place-items:center;width:44px;height:44px;margin:-10px -12px 0 0;padding:0;border:0;border-radius:6px;background:transparent;color:${HELP_DESK_COLORS.body};cursor:pointer}
20673
+ .svhd-composer .svhd-composer-help-close:hover,.svhd-composer .svhd-attachment-remove:hover{background:${HELP_DESK_COLORS.fillStrong};color:${HELP_DESK_COLORS.ink}}
20006
20674
  .svhd-composer .svhd-composer-help-close svg,.svhd-composer .svhd-attachment-remove svg{display:block;width:16px;height:16px}
20007
- .svhd-composer .svhd-attachment-chips{display:flex;flex-wrap:wrap;gap:8px;list-style:none;margin:0;padding:8px;border-top:1px solid ${C['--color-slate-200']}}
20675
+ .svhd-composer .svhd-attachment-chips{display:flex;flex-wrap:wrap;gap:8px;list-style:none;margin:0;padding:8px;border-top:1px solid ${HELP_DESK_COLORS.fillStrong}}
20008
20676
  .svhd-composer .svhd-attachment-chips:empty{display:none}
20009
- .svhd-composer .svhd-attachment-chip{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;align-content:start;flex:0 1 280px;min-width:0;max-width:100%;margin:0;padding:0 0 8px 10px;border:1px solid ${C['--color-slate-200']};border-radius:6px;background:${C['--canvas']};font-size:13px;line-height:1.4}
20010
- .svhd-composer .svhd-attachment-name{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:600;color:${C['--ink']}}
20011
- .svhd-composer .svhd-attachment-status{grid-column:1;padding-right:8px;color:${C['--color-slate-600']};font-size:12px;overflow-wrap:anywhere}
20012
- .svhd-composer .svhd-attachment-status.svhd-composer-problem{color:${C['--color-error']}}
20013
- .svhd-composer .svhd-attachment-progress{grid-column:1/-1;width:calc(100% - 10px);height:6px;margin-top:6px;accent-color:${ACCENT_INK}}
20014
- .svhd-composer .svhd-attachment-remove{display:grid;place-items:center;width:44px;height:44px;min-height:44px;margin:0;padding:0;border:0;border-radius:6px;background:transparent;color:${C['--color-slate-600']};cursor:pointer}
20015
- .svhd-composer .svhd-attachment-retry{grid-column:2;min-height:44px;margin:0;padding:0 10px;border:0;border-radius:6px;background:transparent;color:${ACCENT_INK};font-family:inherit;font-size:13px;font-weight:600;line-height:1.4;text-decoration:underline;cursor:pointer}
20677
+ .svhd-composer .svhd-attachment-chip{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;align-content:start;flex:0 1 280px;min-width:0;max-width:100%;margin:0;padding:0 0 8px 10px;border:1px solid ${HELP_DESK_COLORS.fillStrong};border-radius:6px;background:${HELP_DESK_COLORS.canvas};font-size:13px;line-height:1.4}
20678
+ .svhd-composer .svhd-attachment-name{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:600;color:${HELP_DESK_COLORS.ink}}
20679
+ .svhd-composer .svhd-attachment-status{grid-column:1;padding-right:8px;color:${HELP_DESK_COLORS.body};font-size:12px;overflow-wrap:anywhere}
20680
+ .svhd-composer .svhd-attachment-status.svhd-composer-problem{color:${HELP_DESK_COLORS.error}}
20681
+ .svhd-composer .svhd-attachment-progress{grid-column:1/-1;width:calc(100% - 10px);height:6px;margin-top:6px;accent-color:${HELP_DESK_ACCENT.ink}}
20682
+ .svhd-composer .svhd-attachment-remove{display:grid;place-items:center;width:44px;height:44px;min-height:44px;margin:0;padding:0;border:0;border-radius:6px;background:transparent;color:${HELP_DESK_COLORS.body};cursor:pointer}
20683
+ .svhd-composer .svhd-attachment-retry{grid-column:2;min-height:44px;margin:0;padding:0 10px;border:0;border-radius:6px;background:transparent;color:${HELP_DESK_ACCENT.ink};font-family:inherit;font-size:13px;font-weight:600;line-height:1.4;text-decoration:underline;cursor:pointer}
20016
20684
  .svhd-composer .svhd-attachment-remove:disabled,.svhd-composer .svhd-attachment-retry:disabled{opacity:.6;cursor:default}
20017
20685
  .svhd-composer .svhd-composer-attach:focus-visible,.svhd-composer .svhd-composer-help:focus-visible,.svhd-composer .svhd-composer-help-close:focus-visible,.svhd-composer .svhd-attachment-remove:focus-visible,.svhd-composer .svhd-attachment-retry:focus-visible{${INSET_RING}}
20018
- .svhd-composer-notice{margin:0;color:${C['--color-error']};font-size:14px;line-height:1.5}
20686
+ .svhd-composer-notice{margin:0;color:${HELP_DESK_COLORS.error};font-size:14px;line-height:1.5}
20019
20687
  .svhd-composer [hidden],.svhd-composer-notice[hidden]{display:none!important}
20020
20688
  `;
20021
20689
 
@@ -20937,6 +21605,7 @@ function mountHelpDeskForm(client, options) {
20937
21605
  // The page that lays the support wizard out carries the attribution itself.
20938
21606
  footer: options.hostShowsAttribution ? null : createSecuredByFooter('svhd'),
20939
21607
  });
21608
+ applySupportBrand(shell.container, options.brand ?? supportBrand(client.desk.branding?.color));
20940
21609
  const prefix = `svhd-${++formSequence}`;
20941
21610
  const form = document.createElement('form');
20942
21611
  form.className = 'svhd-form';
@@ -22549,9 +23218,12 @@ function openHelpDeskForm(client, options = {}) {
22549
23218
  close.addEventListener('click', requestDismiss);
22550
23219
  header.append(title, close);
22551
23220
  const body = document.createElement('div');
23221
+ // Paired once for the modal and the form inside it.
23222
+ const brand = options.brand ?? supportBrand(client.desk.branding?.color);
23223
+ applySupportBrand(shell.modal, brand);
22552
23224
  shell.modal.append(header, body);
22553
23225
  try {
22554
- inner = mountHelpDeskForm(client, { ...options, target: body, onCancel: cancel });
23226
+ inner = mountHelpDeskForm(client, { ...options, brand, target: body, onCancel: cancel });
22555
23227
  // State observers run while the inner form mounts. They can dismiss the
22556
23228
  // shell before mountHelpDeskForm hands us its cleanup handle.
22557
23229
  if (destroyed)
@@ -24608,8 +25280,12 @@ function createSupportAnalytics({ deskId, post }) {
24608
25280
  }
24609
25281
 
24610
25282
  let launcherSequence = 0;
24611
- /** A convenience path only: it never owns a second support flow. */
24612
- function createSupportLauncher(options, open) {
25283
+ /**
25284
+ * A convenience path only: it never owns a second support flow. It carries
25285
+ * the desk's brand (`brand`, then setBrand), so its focus ring is the desk's,
25286
+ * as the panel's are.
25287
+ */
25288
+ function createSupportLauncher(options, brand, open) {
24613
25289
  const button = document.createElement('button');
24614
25290
  button.type = 'button';
24615
25291
  button.className = 'sv-support-launcher';
@@ -24618,7 +25294,7 @@ function createSupportLauncher(options, open) {
24618
25294
  button.setAttribute('aria-haspopup', 'dialog');
24619
25295
  button.setAttribute('aria-expanded', 'false');
24620
25296
  const offset = (value, fallback) => typeof value === 'number' && Number.isFinite(value) ? Math.min(240, Math.max(12, value)) : fallback;
24621
- button.style.cssText = `position:fixed;right:calc(${offset(options.right, 24)}px + env(safe-area-inset-right,0px));bottom:calc(${offset(options.bottom, 24)}px + env(safe-area-inset-bottom,0px));z-index:2147482800;width:56px;height:56px;border-radius:50%;border:1px solid ${withAlpha(DS.white, .22)};background:${DS.slate900};color:${DS.white};box-shadow:${DS.shadowPopover};display:grid;place-items:center;cursor:pointer;padding:0;overflow:hidden;`;
25297
+ button.style.cssText = `position:fixed;right:calc(${offset(options.right, 24)}px + env(safe-area-inset-right,0px));bottom:calc(${offset(options.bottom, 24)}px + env(safe-area-inset-bottom,0px));z-index:2147482800;width:56px;height:56px;border-radius:50%;border:1px solid ${withAlpha(DS.white, .22)};background:${DS.slate900};color:${DS.white};display:grid;place-items:center;cursor:pointer;padding:0;overflow:hidden;`;
24622
25298
  if (options.imageUrl) {
24623
25299
  let url;
24624
25300
  try {
@@ -24644,19 +25320,37 @@ function createSupportLauncher(options, open) {
24644
25320
  mark.style.cssText = 'display:grid;place-items:center;width:26px;height:26px;border:1.8px solid currentColor;border-radius:50%;font:600 20px/1 system-ui,sans-serif';
24645
25321
  button.append(mark);
24646
25322
  }
25323
+ applySupportBrand(button, brand);
24647
25324
  button.addEventListener('click', open);
24648
25325
  document.body.append(button);
24649
25326
  return {
24650
25327
  setExpanded(expanded) { button.setAttribute('aria-expanded', String(expanded)); },
25328
+ setBrand(next) { applySupportBrand(button, next); },
24651
25329
  destroy() { button.removeEventListener('click', open); button.remove(); },
24652
25330
  };
24653
25331
  }
24654
25332
 
25333
+ /**
25334
+ * The launcher's focus ring. The launcher floats over whatever the website
25335
+ * draws beneath it, so its ring opens with two bands no page color hides
25336
+ * (WCAG technique C40): white, then slate-950, which stand over 9:1 apart, so
25337
+ * one of them stands at 3:1 or more on any ground. It is the design system's
25338
+ * focus ring (`--focus-ring`: a surface gap, then the ring) with the darkest
25339
+ * slate as its ring, and the desk's focus color rings outside both.
25340
+ */
25341
+ const LAUNCHER_RING = `0 0 0 2px ${DS.white},0 0 0 4px ${DS.slate950}`;
24655
25342
  /**
24656
25343
  * The support journey's only skin. Customer content stays in the product register.
24657
25344
  * The panel's focus ring is 2px, 3px out, in the desk's focus color: its width and
24658
25345
  * offset are the panel's custom properties, which the help desk composer inside
24659
- * its request form reads, so the composer rings as the fields beside it do.
25346
+ * its request form reads, so the composer rings as the fields beside it do. It
25347
+ * paints in the help desk's color roles (@sparkvault/app-sdk/help-desk-colors):
25348
+ * its neutrals read the page's roles (HOST), so in the customer portal they
25349
+ * follow the portal's scheme, and stay light anywhere else; its accent reads
25350
+ * the page's accent roles, else the desk's light pairing (ACCENT), which the
25351
+ * panel and the launcher each carry (DEFAULT_PAIRING_DECLARATIONS), so the
25352
+ * launcher rings in the desk's color, as every control in the panel does,
25353
+ * outside a ring of its own that reads on any page (LAUNCHER_RING).
24660
25354
  */
24661
25355
  function injectHelpDeskSupportStyles() {
24662
25356
  if (document.getElementById('sparkvault-help-desk-support-styles'))
@@ -24665,8 +25359,8 @@ function injectHelpDeskSupportStyles() {
24665
25359
  style.id = 'sparkvault-help-desk-support-styles';
24666
25360
  style.textContent = `
24667
25361
  .svhs-panel,.svhs-panel *{box-sizing:border-box}
24668
- .svhs-panel{--hd-focus-width:2px;--hd-focus-offset:3px}
24669
- .svhs-panel{position:fixed;right:calc(var(--svhs-right,24px) + env(safe-area-inset-right,0px));bottom:calc(var(--svhs-bottom,96px) + env(safe-area-inset-bottom,0px));z-index:2147482900;width:408px;height:422px;max-width:calc(100vw - 32px);max-height:calc(100dvh - var(--svhs-bottom,96px) - 24px);display:flex;flex-direction:column;overflow:hidden;border:1px solid ${DS.slate200};border-radius:12px;background:${DS.white};color:${DS.slate900};font:400 15px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue',sans-serif;text-align:left;box-shadow:${DS.shadowPopover};transform-origin:bottom right;transition:width 180ms cubic-bezier(.2,0,0,1),height 180ms cubic-bezier(.2,0,0,1)}
25362
+ .svhs-panel{--hd-focus-width:2px;--hd-focus-offset:3px;${DEFAULT_PAIRING_DECLARATIONS}}
25363
+ .svhs-panel{position:fixed;right:calc(var(--svhs-right,24px) + env(safe-area-inset-right,0px));bottom:calc(var(--svhs-bottom,96px) + env(safe-area-inset-bottom,0px));z-index:2147482900;width:408px;height:422px;max-width:calc(100vw - 32px);max-height:calc(100dvh - var(--svhs-bottom,96px) - 24px);display:flex;flex-direction:column;overflow:hidden;border:1px solid ${HELP_DESK_COLORS.fillStrong};border-radius:12px;background:${HELP_DESK_COLORS.surface};color:${HELP_DESK_COLORS.ink};font:400 15px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue',sans-serif;text-align:left;box-shadow:${DS.shadowPopover};transform-origin:bottom right;transition:width 180ms cubic-bezier(.2,0,0,1),height 180ms cubic-bezier(.2,0,0,1)}
24670
25364
  .svhs-panel[hidden],.svhs-panel [hidden]{display:none!important}
24671
25365
  .svhs-panel[data-stage=results]{height:680px}
24672
25366
  .svhs-panel[data-stage=article]{width:704px;height:700px}
@@ -24677,99 +25371,99 @@ function injectHelpDeskSupportStyles() {
24677
25371
  .svhs-panel button,.svhs-panel a{touch-action:manipulation;-webkit-tap-highlight-color:transparent}
24678
25372
  .svhs-panel button{appearance:none;cursor:pointer;margin:0}
24679
25373
  .svhs-panel button:active{transform:translateY(1px)}
24680
- .svhs-panel button:focus-visible,.svhs-panel a:focus-visible,.svhs-panel input:focus-visible,.svhs-panel textarea:focus-visible{outline:var(--hd-focus-width) solid var(--hd-focus,var(--hd-accent-ink,${DS.action}));outline-offset:var(--hd-focus-offset);box-shadow:none}
25374
+ .svhs-panel button:focus-visible,.svhs-panel a:focus-visible,.svhs-panel input:focus-visible,.svhs-panel textarea:focus-visible{outline:var(--hd-focus-width) solid ${HELP_DESK_FOCUS};outline-offset:var(--hd-focus-offset);box-shadow:none}
24681
25375
  .svhs-panel svg{display:block;width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round;flex:none;pointer-events:none}
24682
- .svhs-toolbar{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:60px;flex:none;padding:8px 14px 8px 24px;border-bottom:1px solid ${DS.slate200}}
24683
- .svhs-desk-name{font-size:14px;font-weight:600;line-height:1.35;color:${DS.slate600};overflow-wrap:anywhere;min-width:0}
25376
+ .svhs-toolbar{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:60px;flex:none;padding:8px 14px 8px 24px;border-bottom:1px solid ${HELP_DESK_COLORS.fillStrong}}
25377
+ .svhs-desk-name{font-size:14px;font-weight:600;line-height:1.35;color:${HELP_DESK_COLORS.body};overflow-wrap:anywhere;min-width:0}
24684
25378
  .svhs-toolbar-actions{display:flex;align-items:center;gap:4px;margin-left:auto;flex:none}
24685
- .svhs-identity-notice{display:flex;align-items:center;justify-content:space-between;gap:8px;flex:none;padding:8px 24px;border-bottom:1px solid ${DS.slate200};background:${DS.slate50}}
25379
+ .svhs-identity-notice{display:flex;align-items:center;justify-content:space-between;gap:8px;flex:none;padding:8px 24px;border-bottom:1px solid ${HELP_DESK_COLORS.fillStrong};background:${HELP_DESK_COLORS.canvas}}
24686
25380
  .svhs-identity-notice .svhs-status{margin:0;font-size:13px}
24687
25381
  .svhs-identity-notice .svhs-text-button{flex:none;font-size:13px!important}
24688
- .svhs-icon-button{display:grid;place-items:center;width:40px;height:40px;flex:none;padding:0;border:0;border-radius:6px;background:transparent;color:${DS.slate500};text-decoration:none}
24689
- .svhs-icon-button:hover{background:${DS.slate100};color:${DS.slate900}}
24690
- .svhs-back{display:flex;align-items:center;gap:4px;flex:none;min-height:40px;margin-left:-10px!important;padding:8px;border:0;border-radius:6px;background:transparent;color:${DS.slate600};font-size:14px!important;font-weight:500!important;line-height:1.4}
24691
- .svhs-back:hover{background:${DS.slate50}}
24692
- .svhs-back:disabled{background:transparent;color:${DS.slate500};cursor:default;transform:none}
25382
+ .svhs-icon-button{display:grid;place-items:center;width:40px;height:40px;flex:none;padding:0;border:0;border-radius:6px;background:transparent;color:${HELP_DESK_COLORS.muted};text-decoration:none}
25383
+ .svhs-icon-button:hover{background:${HELP_DESK_COLORS.fill};color:${HELP_DESK_COLORS.ink}}
25384
+ .svhs-back{display:flex;align-items:center;gap:4px;flex:none;min-height:40px;margin-left:-10px!important;padding:8px;border:0;border-radius:6px;background:transparent;color:${HELP_DESK_COLORS.body};font-size:14px!important;font-weight:500!important;line-height:1.4}
25385
+ .svhs-back:hover{background:${HELP_DESK_COLORS.hover}}
25386
+ .svhs-back:disabled{background:transparent;color:${HELP_DESK_COLORS.muted};cursor:default;transform:none}
24693
25387
  .svhs-screen{display:flex;flex-direction:column;min-height:0;flex:1}
24694
25388
  .svhs-scroll{padding:26px 24px;overflow:auto;overscroll-behavior:contain;min-height:0;flex:1;scrollbar-gutter:stable}
24695
- .svhs-heading{margin:0 0 8px;padding:0;color:${DS.slate900};font-size:24px;font-weight:600;line-height:1.3;letter-spacing:-.6px;overflow-wrap:anywhere}
25389
+ .svhs-heading{margin:0 0 8px;padding:0;color:${HELP_DESK_COLORS.ink};font-size:24px;font-weight:600;line-height:1.3;letter-spacing:-.6px;overflow-wrap:anywhere}
24696
25390
  .svhs-heading:focus,.svhs-article-title:focus{outline:none;box-shadow:none}
24697
- .svhs-copy{margin:0 0 24px;color:${DS.slate600};font-size:14px;line-height:1.55}
24698
- .svhs-label{display:block;margin:0 0 7px;font-size:13px;font-weight:600;color:${DS.slate600}}
24699
- .svhs-issue{display:block;width:100%;min-height:120px;max-height:200px;resize:none;overflow-y:auto;border:1px solid ${DS.slate300};border-radius:8px;padding:12px 14px;background:${DS.white};color:${DS.slate900};font-size:16px!important;line-height:1.5!important;box-shadow:none}
25391
+ .svhs-copy{margin:0 0 24px;color:${HELP_DESK_COLORS.body};font-size:14px;line-height:1.55}
25392
+ .svhs-label{display:block;margin:0 0 7px;font-size:13px;font-weight:600;color:${HELP_DESK_COLORS.body}}
25393
+ .svhs-issue{display:block;width:100%;min-height:120px;max-height:200px;resize:none;overflow-y:auto;border:1px solid ${HELP_DESK_COLORS.lineStrong};border-radius:8px;padding:12px 14px;background:${HELP_DESK_COLORS.field};color:${HELP_DESK_COLORS.ink};font-size:16px!important;line-height:1.5!important;box-shadow:none}
24700
25394
  /* The heading is the field's label, so the field follows it at a label's distance from a question this large. */
24701
25395
  .svhs-heading+.svhs-issue{margin-top:16px}
24702
- .svhs-issue::placeholder{color:${DS.slate500};opacity:1}
24703
- .svhs-issue:focus{border-color:var(--hd-focus,var(--hd-accent-ink,${DS.action}))}
25396
+ .svhs-issue::placeholder{color:${HELP_DESK_COLORS.muted};opacity:1}
25397
+ .svhs-issue:focus{border-color:${HELP_DESK_FOCUS}}
24704
25398
  .svhs-primary,.svhs-secondary{display:flex;align-items:center;justify-content:center;gap:8px;min-height:44px;padding:10px 16px;border:1px solid transparent;border-radius:6px;font-size:14px!important;font-weight:600!important;line-height:1.4!important;text-decoration:none;transition:background 120ms cubic-bezier(.2,0,0,1)}
24705
- .svhs-primary{background:var(--hd-accent,${DS.action});color:var(--hd-on-accent,${DS.white})}
24706
- .svhs-primary:hover{background:var(--hd-accent-hover,${DS.actionHover})}
25399
+ .svhs-primary{background:${HELP_DESK_ACCENT.fill};color:${HELP_DESK_ACCENT.onAccent}}
25400
+ .svhs-primary:hover{background:${HELP_DESK_ACCENT.hover}}
24707
25401
  .svhs-primary[aria-disabled=true]{cursor:progress}
24708
- .svhs-secondary{border-color:${DS.slate300};background:${DS.white};color:${DS.slate600}}
24709
- .svhs-secondary:hover{background:${DS.slate50}}
24710
- .svhs-text-button{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:44px;padding:9px 4px;border:0;border-radius:6px;background:transparent;color:var(--hd-accent-ink,${DS.action});font-size:14px!important;line-height:1.4!important;text-decoration:none}
25402
+ .svhs-secondary{border-color:${HELP_DESK_COLORS.lineStrong};background:${HELP_DESK_COLORS.surface};color:${HELP_DESK_COLORS.body}}
25403
+ .svhs-secondary:hover{background:${HELP_DESK_COLORS.hover}}
25404
+ .svhs-text-button{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:44px;padding:9px 4px;border:0;border-radius:6px;background:transparent;color:${HELP_DESK_ACCENT.ink};font-size:14px!important;line-height:1.4!important;text-decoration:none}
24711
25405
  .svhs-text-button:hover{text-decoration:underline}
24712
25406
  .svhs-full{width:100%}
24713
- .svhs-bottom{padding:16px 24px 18px;flex:none;border-top:1px solid ${DS.slate100}}
25407
+ .svhs-bottom{padding:16px 24px 18px;flex:none;border-top:1px solid ${HELP_DESK_COLORS.fill}}
24714
25408
  .svhs-start-bottom{display:flex;flex-direction:column;align-items:center;gap:6px;padding-top:0;border-top:0}
24715
25409
  .svhs-start-bottom .svhs-primary{width:100%}
24716
- .svhs-query{display:flex;align-items:center;gap:12px;margin:0 0 24px;padding:12px 14px;border:1px solid ${DS.slate200};border-radius:8px;background:${DS.slate50}}
25410
+ .svhs-query{display:flex;align-items:center;gap:12px;margin:0 0 24px;padding:12px 14px;border:1px solid ${HELP_DESK_COLORS.fillStrong};border-radius:8px;background:${HELP_DESK_COLORS.canvas}}
24717
25411
  .svhs-question{flex:1;min-width:0}
24718
- .svhs-question-label{display:block;margin-bottom:3px;color:${DS.slate500};font-size:12px;font-weight:500;line-height:1.4}
24719
- .svhs-query-text{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;margin:0;color:${DS.slate900};font-size:14px;line-height:1.5;overflow-wrap:anywhere;white-space:pre-wrap}
25412
+ .svhs-question-label{display:block;margin-bottom:3px;color:${HELP_DESK_COLORS.muted};font-size:12px;font-weight:500;line-height:1.4}
25413
+ .svhs-query-text{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;margin:0;color:${HELP_DESK_COLORS.ink};font-size:14px;line-height:1.5;overflow-wrap:anywhere;white-space:pre-wrap}
24720
25414
  .svhs-query .svhs-text-button{flex:none;min-width:44px;padding:8px 0}
24721
25415
  .svhs-results{display:flex;flex-direction:column;margin:0;padding:0;list-style:none}
24722
- .svhs-result{display:grid;grid-template-columns:24px minmax(0,1fr) 16px;align-items:start;gap:12px;width:100%;padding:18px 0;border:0;border-bottom:1px solid ${DS.slate200};border-radius:0;background:${DS.white};color:${DS.slate900};text-align:left}
24723
- .svhs-results li:first-child .svhs-result{border-top:1px solid ${DS.slate200}}
25416
+ .svhs-result{display:grid;grid-template-columns:24px minmax(0,1fr) 16px;align-items:start;gap:12px;width:100%;padding:18px 0;border:0;border-bottom:1px solid ${HELP_DESK_COLORS.fillStrong};border-radius:0;background:${HELP_DESK_COLORS.surface};color:${HELP_DESK_COLORS.ink};text-align:left}
25417
+ .svhs-results li:first-child .svhs-result{border-top:1px solid ${HELP_DESK_COLORS.fillStrong}}
24724
25418
  .svhs-results li:last-child .svhs-result{border-bottom:0}
24725
25419
  .svhs-result-copy{display:block;min-width:0}
24726
- .svhs-result-icon{margin-top:2px;color:${DS.slate500}}
24727
- .svhs-result-chevron{width:16px!important;height:16px!important;margin-top:4px;color:${DS.slate500}}
25420
+ .svhs-result-icon{margin-top:2px;color:${HELP_DESK_COLORS.muted}}
25421
+ .svhs-result-chevron{width:16px!important;height:16px!important;margin-top:4px;color:${HELP_DESK_COLORS.muted}}
24728
25422
  .svhs-result-title{display:block;margin:0 0 4px;color:inherit;font-size:16px;font-weight:600;line-height:1.4;letter-spacing:-.15px;overflow-wrap:anywhere}
24729
- .svhs-result:hover{background:${DS.slate50}}
24730
- .svhs-result:hover .svhs-result-title{color:var(--hd-accent-ink,${DS.action});text-decoration:underline}
24731
- .svhs-result-excerpt{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;margin:0;color:${DS.slate600};font-size:14px;line-height:1.5;overflow-wrap:anywhere}
24732
- .svhs-result-category{display:block;margin-top:6px;color:${DS.slate500};font-size:12px;line-height:1.4}
24733
- .svhs-results-bottom{display:flex;flex-wrap:wrap;align-items:center;gap:8px 16px;background:${DS.slate50};border-top-color:${DS.slate200}}
25423
+ .svhs-result:hover{background:${HELP_DESK_COLORS.hover}}
25424
+ .svhs-result:hover .svhs-result-title{color:${HELP_DESK_ACCENT.ink};text-decoration:underline}
25425
+ .svhs-result-excerpt{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;margin:0;color:${HELP_DESK_COLORS.body};font-size:14px;line-height:1.5;overflow-wrap:anywhere}
25426
+ .svhs-result-category{display:block;margin-top:6px;color:${HELP_DESK_COLORS.muted};font-size:12px;line-height:1.4}
25427
+ .svhs-results-bottom{display:flex;flex-wrap:wrap;align-items:center;gap:8px 16px;background:${HELP_DESK_COLORS.canvas};border-top-color:${HELP_DESK_COLORS.fillStrong}}
24734
25428
  /* Wraps below the ticket button when less than 200px remain beside it, as under the panel's full-width button. */
24735
- .svhs-contact-note{flex:1 1 200px;min-width:0;margin:0;color:${DS.slate500};font-size:13px;line-height:1.5;overflow-wrap:anywhere}
24736
- .svhs-error{margin:12px 0 0;color:${DS.error};font-size:14px;line-height:1.5;overflow-wrap:anywhere}
24737
- .svhs-status{margin:16px 0;color:${DS.slate600};font-size:14px;line-height:1.5}
25429
+ .svhs-contact-note{flex:1 1 200px;min-width:0;margin:0;color:${HELP_DESK_COLORS.muted};font-size:13px;line-height:1.5;overflow-wrap:anywhere}
25430
+ .svhs-error{margin:12px 0 0;color:${HELP_DESK_COLORS.error};font-size:14px;line-height:1.5;overflow-wrap:anywhere}
25431
+ .svhs-status{margin:16px 0;color:${HELP_DESK_COLORS.body};font-size:14px;line-height:1.5}
24738
25432
  .svhs-empty{padding:12px 0 4px}
24739
25433
  .svhs-empty .svhs-heading{font-size:18px;letter-spacing:-.3px}
24740
25434
  .svhs-spinner{width:15px;height:15px;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;animation:svhs-spin .7s linear infinite;flex:none}
24741
25435
  @keyframes svhs-spin{to{transform:rotate(360deg)}}
24742
25436
  .svhs-article-scroll{padding:34px 48px 28px}
24743
- .svhs-category{margin:0 0 12px;color:${DS.slate500};font-size:13px;line-height:1.5;overflow-wrap:anywhere}
24744
- .svhs-article-title{margin:0 0 18px;color:${DS.slate900};font-size:28px;font-weight:600;line-height:1.2;letter-spacing:-.8px;overflow-wrap:anywhere}
24745
- .svhs-article-content{color:${DS.slate600};font-size:15px;line-height:1.65;overflow-wrap:anywhere}
25437
+ .svhs-category{margin:0 0 12px;color:${HELP_DESK_COLORS.muted};font-size:13px;line-height:1.5;overflow-wrap:anywhere}
25438
+ .svhs-article-title{margin:0 0 18px;color:${HELP_DESK_COLORS.ink};font-size:28px;font-weight:600;line-height:1.2;letter-spacing:-.8px;overflow-wrap:anywhere}
25439
+ .svhs-article-content{color:${HELP_DESK_COLORS.body};font-size:15px;line-height:1.65;overflow-wrap:anywhere}
24746
25440
  .svhs-article-content>*:first-child{margin-top:0}
24747
25441
  .svhs-article-content p{margin:0 0 18px;font:inherit;color:inherit}
24748
- .svhs-article-content h1,.svhs-article-content h2,.svhs-article-content h3,.svhs-article-content h4,.svhs-article-content h5,.svhs-article-content h6{margin:28px 0 12px;color:${DS.slate900};font-size:18px;font-weight:600;line-height:1.35;letter-spacing:-.3px;scroll-margin-top:24px}
25442
+ .svhs-article-content h1,.svhs-article-content h2,.svhs-article-content h3,.svhs-article-content h4,.svhs-article-content h5,.svhs-article-content h6{margin:28px 0 12px;color:${HELP_DESK_COLORS.ink};font-size:18px;font-weight:600;line-height:1.35;letter-spacing:-.3px;scroll-margin-top:24px}
24749
25443
  .svhs-article-content h3,.svhs-article-content h4,.svhs-article-content h5,.svhs-article-content h6{font-size:16px}
24750
25444
  .svhs-article-content ul,.svhs-article-content ol{margin:0 0 22px;padding-left:22px}
24751
25445
  .svhs-article-content li{margin:8px 0;padding-left:5px}
24752
- .svhs-article-content strong{font-weight:600;color:${DS.slate900}}
24753
- .svhs-article-content a{color:var(--hd-accent-ink,${DS.action});text-decoration:underline;text-underline-offset:2px}
25446
+ .svhs-article-content strong{font-weight:600;color:${HELP_DESK_COLORS.ink}}
25447
+ .svhs-article-content a{color:${HELP_DESK_ACCENT.ink};text-decoration:underline;text-underline-offset:2px}
24754
25448
  .svhs-article-content img,.svhs-article-content video{display:block;max-width:100%;height:auto;margin:20px 0}
24755
25449
  .svhs-reader-asset{display:block;max-width:100%;margin:20px 0}
24756
25450
  .svhs-reader-asset img{margin:0}
24757
- .svhs-reader-asset-status{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:4px;min-height:140px;padding:20px;border:1px solid ${DS.slate200};border-radius:6px;background:${DS.slate50};color:${DS.slate500};font-size:13px;text-align:center}
25451
+ .svhs-reader-asset-status{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:4px;min-height:140px;padding:20px;border:1px solid ${HELP_DESK_COLORS.fillStrong};border-radius:6px;background:${HELP_DESK_COLORS.canvas};color:${HELP_DESK_COLORS.muted};font-size:13px;text-align:center}
24758
25452
  .svhs-reader-asset-status[style]{min-height:0}
24759
- .svhs-article-content blockquote{margin:22px 0;padding:0 0 0 16px;border-left:2px solid ${DS.slate300};font-size:14px}
24760
- .svhs-article-content pre{margin:20px 0;padding:14px;border:1px solid ${DS.slate200};border-radius:6px;background:${DS.slate50};overflow:auto;overscroll-behavior:contain;font:13px/1.6 ui-monospace,SFMono-Regular,Consolas,monospace}
25453
+ .svhs-article-content blockquote{margin:22px 0;padding:0 0 0 16px;border-left:2px solid ${HELP_DESK_COLORS.lineStrong};font-size:14px}
25454
+ .svhs-article-content pre{margin:20px 0;padding:14px;border:1px solid ${HELP_DESK_COLORS.fillStrong};border-radius:6px;background:${HELP_DESK_COLORS.canvas};overflow:auto;overscroll-behavior:contain;font:13px/1.6 ui-monospace,SFMono-Regular,Consolas,monospace}
24761
25455
  .svhs-article-content code{font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:.9em}
24762
25456
  .svhs-article-content table{display:block;max-width:100%;border-collapse:collapse;overflow:auto;overscroll-behavior:contain;margin:20px 0;font-size:14px}
24763
- .svhs-article-content th,.svhs-article-content td{padding:10px 12px;border:1px solid ${DS.slate200};text-align:left}
24764
- .svhs-article-content hr{margin:24px 0;border:0;border-top:1px solid ${DS.slate200}}
24765
- .svhs-article-footer{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:14px 24px;border-top:1px solid ${DS.slate100};flex:none}
25457
+ .svhs-article-content th,.svhs-article-content td{padding:10px 12px;border:1px solid ${HELP_DESK_COLORS.fillStrong};text-align:left}
25458
+ .svhs-article-content hr{margin:24px 0;border:0;border-top:1px solid ${HELP_DESK_COLORS.fillStrong}}
25459
+ .svhs-article-footer{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:14px 24px;border-top:1px solid ${HELP_DESK_COLORS.fill};flex:none}
24766
25460
  .svhs-article-footer .svhs-primary{min-width:110px}
24767
25461
  .svhs-article-footer .svhs-text-button{white-space:nowrap;font-size:13px!important}
24768
- .svhs-article-question{color:${DS.slate500};font-size:13px;line-height:1.5}
25462
+ .svhs-article-question{color:${HELP_DESK_COLORS.muted};font-size:13px;line-height:1.5}
24769
25463
  .svhs-reader-actions{display:flex;align-items:stretch;gap:12px;flex:none}
24770
25464
  .svhs-feedback-scroll{padding-top:30px}
24771
25465
  .svhs-feedback-actions{display:flex;flex-direction:column;gap:9px;margin-top:24px}
24772
- .svhs-feedback-actions .svhs-text-button{align-self:center;color:${DS.slate500}}
25466
+ .svhs-feedback-actions .svhs-text-button{align-self:center;color:${HELP_DESK_COLORS.muted}}
24773
25467
  .svhs-review{margin-top:24px}
24774
25468
  .svhs-review .svhs-primary{width:fit-content}
24775
25469
  .svhs-contact-scroll{padding:0;scrollbar-gutter:auto}
@@ -24778,8 +25472,8 @@ function injectHelpDeskSupportStyles() {
24778
25472
  .svhs-contact-prelude{padding:24px}
24779
25473
  .svhs-contact-prelude .svhs-secondary{margin-top:16px}
24780
25474
  .svhs-ticket-gate{padding:0 24px 24px}
24781
- .svhs-unlock-input{display:block;box-sizing:border-box;width:100%;min-height:46px;margin:0 0 16px;border:1px solid ${DS.slate300};border-radius:6px;padding:11px 12px;background:${DS.white};color:${DS.slate900};font-size:16px!important;line-height:1.5!important}
24782
- .svhs-unlock-input:focus{border-color:var(--hd-focus,var(--hd-accent-ink,${DS.action}))}
25475
+ .svhs-unlock-input{display:block;box-sizing:border-box;width:100%;min-height:46px;margin:0 0 16px;border:1px solid ${HELP_DESK_COLORS.lineStrong};border-radius:6px;padding:11px 12px;background:${HELP_DESK_COLORS.field};color:${HELP_DESK_COLORS.ink};font-size:16px!important;line-height:1.5!important}
25476
+ .svhs-unlock-input:focus{border-color:${HELP_DESK_FOCUS}}
24783
25477
  .svhs-unlock-form{margin:0}
24784
25478
  .svhs-contact-target>.svhd-container{display:flex;flex:1;flex-direction:column;min-height:100%;max-width:none;padding:24px;border:0;border-radius:0;box-shadow:none;background:transparent}
24785
25479
  .svhs-contact-target .svhd-body{display:flex;flex:1;flex-direction:column;min-height:0}
@@ -24788,44 +25482,39 @@ function injectHelpDeskSupportStyles() {
24788
25482
  .svhs-contact-target .svhd-label{font-size:13px;line-height:1.5}
24789
25483
  .svhs-contact-target .svhd-input{font-size:16px;line-height:1.5}
24790
25484
  .svhs-contact-target .svhd-actions{gap:10px}
24791
- .svhs-contact-target .svhd-button:not(.svhd-secondary){background:var(--hd-accent,${DS.action});color:var(--hd-on-accent,${DS.white})}
24792
- .svhs-contact-target .svhd-button:not(.svhd-secondary):hover{background:var(--hd-accent-hover,${DS.actionHover})}
24793
- .svhs-contact-target .svhd-link{color:var(--hd-accent-ink,${DS.action})}
24794
25485
  .svhs-contact-target .svhd-actions>.svhd-button:first-child{flex:1}
24795
25486
  .svhs-contact-target .svhd-status{font-size:14px}
24796
25487
  .svhs-contact-target .svhd-auth{gap:14px}
24797
- .svhs-contact-target .svhd-text-button{color:var(--hd-accent-ink,${DS.action})}
24798
- .svhs-contact-target .svhd-text-button:disabled{color:${DS.slate500}}
24799
25488
  .svhs-contact-target .svhd-widget-form{display:flex;flex:1;flex-direction:column;gap:16px}
24800
25489
  /* The request fills the panel: the details step, and in it the composer and its text, take the height the fields leave. */
24801
25490
  .svhs-contact-target .svhd-widget-form>[data-contact-step=details]{display:flex;flex:1;flex-direction:column;gap:16px}
24802
25491
  .svhs-contact-target .svhd-widget-form .svhd-composer-field{display:flex;flex:1;flex-direction:column;gap:6px;min-height:164px}
24803
25492
  .svhs-contact-target .svhd-widget-form .svhd-composer{flex:1}
24804
25493
  .svhs-contact-target .svhd-widget-form .svhd-composer-input{flex:1;min-height:120px}
24805
- .svhs-contact-target .svhd-widget-form>.svhd-actions{position:sticky;bottom:0;z-index:1;margin:auto -24px 0;padding:16px 24px 0;border-top:1px solid ${DS.slate100};background:${DS.white}}
25494
+ .svhs-contact-target .svhd-widget-form>.svhd-actions{position:sticky;bottom:0;z-index:1;margin:auto -24px 0;padding:16px 24px 0;border-top:1px solid ${HELP_DESK_COLORS.fill};background:${HELP_DESK_COLORS.surface}}
24806
25495
  .svhs-contact-target .svhd-widget-form>.svhd-actions>.svhd-secondary{display:none}
24807
25496
  .svhs-contact-target .svhd-widget-form .svhd-actions>.svhd-button{font-size:14px}
24808
- .svhs-contact-target .svhd-widget-form>.svhd-confirm{position:sticky;bottom:-24px;z-index:2;margin:0 -24px -24px;padding:16px 24px 24px;border-top:1px solid ${DS.slate200};background:${DS.white}}
25497
+ .svhs-contact-target .svhd-widget-form>.svhd-confirm{position:sticky;bottom:-24px;z-index:2;margin:0 -24px -24px;padding:16px 24px 24px;border-top:1px solid ${HELP_DESK_COLORS.fillStrong};background:${HELP_DESK_COLORS.surface}}
24809
25498
  .svhs-contact-target .svhd-widget-form>.svhd-confirm .svhd-actions{flex-wrap:nowrap}
24810
25499
  .svhs-contact-target .svhd-widget-form>.svhd-confirm .svhd-button{flex:1}
24811
25500
  .svhs-contact-target .svhd-footer{margin-top:16px;text-align:center;font-size:11px}
24812
25501
  .svhs-receipt-scroll{padding-top:36px}
24813
- .svhs-receipt-mark{width:30px!important;height:30px!important;margin-bottom:20px;color:var(--hd-accent-ink,${DS.action})}
24814
- .svhs-ticket-link{display:inline-flex;align-items:center;min-height:44px;margin:0 0 10px;color:var(--hd-accent-ink,${DS.action});font-size:14px;font-weight:600;text-decoration:underline}
25502
+ .svhs-receipt-mark{width:30px!important;height:30px!important;margin-bottom:20px;color:${HELP_DESK_ACCENT.ink}}
25503
+ .svhs-ticket-link{display:inline-flex;align-items:center;min-height:44px;margin:0 0 10px;color:${HELP_DESK_ACCENT.ink};font-size:14px;font-weight:600;text-decoration:underline}
24815
25504
  .svhs-receipt-note{white-space:pre-wrap;overflow-wrap:anywhere}
24816
25505
  .svhs-receipt-actions{display:flex;flex-direction:column;align-items:center;gap:4px}
24817
25506
  .svhs-toast{box-sizing:border-box;position:fixed;right:24px;bottom:calc(96px + var(--svhs-toast-offset,0px) + env(safe-area-inset-bottom));z-index:2147482901;display:flex;align-items:center;gap:10px;max-width:calc(100vw - 36px);padding:14px 18px;border:1px solid transparent;border-radius:8px;background:${DS.slate900};color:${DS.white};box-shadow:${DS.shadowPopover};font:400 14px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue',sans-serif;overflow-wrap:anywhere}
24818
25507
  .svhs-toast svg{width:18px;height:18px;flex:none;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
24819
- .svhs-overlay{position:fixed;inset:0;z-index:2147482900;display:flex;background:${DS.white};padding:0;overflow:hidden}
25508
+ .svhs-overlay{position:fixed;inset:0;z-index:2147482900;display:flex;background:${HELP_DESK_COLORS.surface};padding:0;overflow:hidden}
24820
25509
  .svhs-modal{width:100%;height:100%;min-width:0;outline:none}
24821
25510
  .svhs-overlay .svhs-panel{position:relative;inset:auto;width:100%;height:100%;max-width:none;max-height:none;border:0;border-radius:0;box-shadow:none;padding-top:env(safe-area-inset-top);transition:none}
24822
- .sv-support-launcher{touch-action:manipulation;-webkit-tap-highlight-color:transparent;transition:background 120ms cubic-bezier(.2,0,0,1)}
25511
+ .sv-support-launcher{touch-action:manipulation;-webkit-tap-highlight-color:transparent;transition:background 120ms cubic-bezier(.2,0,0,1);box-shadow:${DS.shadowPopover};${DEFAULT_PAIRING_DECLARATIONS}}
24823
25512
  .sv-support-launcher:hover{filter:brightness(1.12)}
24824
25513
  .sv-support-launcher:active{transform:translateY(1px)}
24825
- .sv-support-launcher:focus-visible{outline:3px solid var(--hd-accent-ink,${DS.action});outline-offset:3px}
25514
+ .sv-support-launcher:focus-visible{outline:3px solid ${HELP_DESK_FOCUS};outline-offset:4px;box-shadow:${LAUNCHER_RING},${DS.shadowPopover}}
24826
25515
  @media(max-width:640px){
24827
25516
  .svhs-panel{right:0;bottom:0;width:100%;height:100dvh;max-width:none;max-height:none;border:0;border-radius:0}
24828
- .svhs-toolbar{min-height:60px;padding:8px 16px 8px 24px;border-bottom-color:${DS.slate200}}
25517
+ .svhs-toolbar{min-height:60px;padding:8px 16px 8px 24px;border-bottom-color:${HELP_DESK_COLORS.fillStrong}}
24829
25518
  .svhs-icon-button{width:44px;height:44px}
24830
25519
  .svhs-back{min-height:44px;max-width:42%}
24831
25520
  .svhs-scroll{padding:24px}
@@ -24857,7 +25546,7 @@ function injectHelpDeskSupportStyles() {
24857
25546
  @media(pointer:coarse){.svhs-icon-button{width:44px;height:44px}.svhs-back{min-height:44px}.svhs-query .svhs-text-button{min-height:44px;min-width:44px}}
24858
25547
  @media(prefers-reduced-motion:reduce){.svhs-panel,.svhs-panel *,.sv-support-launcher{transition-duration:0s!important;animation-duration:.01ms!important;animation-iteration-count:1!important;scroll-behavior:auto!important}}
24859
25548
  @media(forced-colors:active){.svhs-panel button:focus-visible,.svhs-panel a:focus-visible,.svhs-panel input:focus-visible,.svhs-panel textarea:focus-visible{outline:2px solid Highlight}.svhs-panel,.svhs-primary,.svhs-secondary{border:1px solid ButtonText}}
24860
- .svhs-panel.svhs-page{position:static;inset:auto;z-index:auto;width:100%;height:auto;max-width:720px;max-height:none;margin:0 auto;border:1px solid ${DS.slate200};border-radius:12px;box-shadow:none;transition:none}
25549
+ .svhs-panel.svhs-page{position:static;inset:auto;z-index:auto;width:100%;height:auto;max-width:720px;max-height:none;margin:0 auto;border:1px solid ${HELP_DESK_COLORS.fillStrong};border-radius:12px;box-shadow:none;transition:none}
24861
25550
  .svhs-page .svhs-toolbar{min-height:52px;padding:4px 24px}
24862
25551
  .svhs-page .svhs-back{max-width:none;white-space:nowrap}
24863
25552
  .svhs-page .svhs-desk-name{display:none}
@@ -25054,35 +25743,6 @@ class SupportPhoneHistory {
25054
25743
  }
25055
25744
  }
25056
25745
 
25057
- /** Darken only the narrow range where neither white nor the product ink reaches AA. */
25058
- function accessibleFill(color) {
25059
- let fill = color;
25060
- while ((accentFillContrast(fill) ?? 0) < AA_TEXT_CONTRAST) {
25061
- fill = `#${[1, 3, 5].map(offset => Math.floor(Number.parseInt(fill.slice(offset, offset + 2), 16) * 0.98).toString(16).padStart(2, '0')).join('')}`;
25062
- }
25063
- return fill;
25064
- }
25065
- /** Scoped brand properties work in both a hosted page and an unrelated widget host. */
25066
- function applySupportBrand(target, value) {
25067
- const color = brandColor(value);
25068
- if (!color) {
25069
- for (const name of ['--hd-accent', '--hd-on-accent', '--hd-accent-ink', '--hd-accent-hover', '--hd-focus'])
25070
- target.style.removeProperty(name);
25071
- return;
25072
- }
25073
- const fill = accessibleFill(color);
25074
- const pairing = accentPairing(fill);
25075
- const ink = pairing.accentInk === 'accent' ? fill : DS.slate900;
25076
- const label = pairing.onAccent === 'white' ? DS.white : DS.slate900;
25077
- // Dark fills deepen on hover; light fills stay unchanged to preserve label contrast.
25078
- const hover = pairing.onAccent === 'white'
25079
- ? `#${[1, 3, 5].map(offset => Math.floor(Number.parseInt(fill.slice(offset, offset + 2), 16) * 0.9).toString(16).padStart(2, '0')).join('')}`
25080
- : fill;
25081
- const properties = { '--hd-accent': fill, '--hd-on-accent': label, '--hd-accent-ink': ink, '--hd-accent-hover': hover, '--hd-focus': ink };
25082
- for (const [name, content] of Object.entries(properties))
25083
- target.style.setProperty(name, content);
25084
- }
25085
-
25086
25746
  /* global MediaQueryList, HTMLImageElement, HTMLAnchorElement, Element */
25087
25747
  let sequence = 0;
25088
25748
  function element(tag, className, text) {
@@ -25369,7 +26029,8 @@ class SupportView {
25369
26029
  if (previous)
25370
26030
  this.saveScroll(previous);
25371
26031
  this.state = next;
25372
- applySupportBrand(this.panel, next.brandColor);
26032
+ if (next.brand !== previous?.brand)
26033
+ applySupportBrand(this.panel, next.brand);
25373
26034
  this.panel.dataset.stage = next.stage;
25374
26035
  const inset = (value, fallback) => typeof value === 'number' && Number.isFinite(value) ? Math.min(480, Math.max(0, value)) : fallback;
25375
26036
  this.panel.style.setProperty('--svhs-right', `${inset(next.position?.right, 24)}px`);
@@ -26072,7 +26733,11 @@ function createHelpDeskSupport(config, options) {
26072
26733
  let sourceArticleId;
26073
26734
  const lifetime = new AbortController();
26074
26735
  const bindings = new Set();
26075
- let state = { visible: false, stage: 'issue', deskName: 'Support', issue: '' };
26736
+ // A desk the page already holds brands the journey from the start, the
26737
+ // launcher included. Any other desk's brand arrives with connect, which the
26738
+ // first open, search or contact makes, never creation: connecting here would
26739
+ // add a desk lookup to every page load of a website that shows the launcher.
26740
+ let state = { visible: false, stage: 'issue', deskName: 'Support', issue: '', brand: supportBrand(options.desk?.branding?.color) };
26076
26741
  if (typeof options.launcher === 'object') {
26077
26742
  const offset = (value, fallback) => typeof value === 'number' && Number.isFinite(value) ? Math.min(240, Math.max(12, value)) : fallback;
26078
26743
  state.position = { right: offset(options.launcher.right, 24), bottom: offset(options.launcher.bottom, 24) + 72 };
@@ -26146,7 +26811,7 @@ function createHelpDeskSupport(config, options) {
26146
26811
  }, options.target === undefined ? undefined : resolveTarget(options.target));
26147
26812
  const launcher = (() => {
26148
26813
  try {
26149
- return options.launcher ? createSupportLauncher(typeof options.launcher === 'object' ? options.launcher : {}, () => { void open(); }) : null;
26814
+ return options.launcher ? createSupportLauncher(typeof options.launcher === 'object' ? options.launcher : {}, state.brand, () => { void open(); }) : null;
26150
26815
  }
26151
26816
  catch (error) {
26152
26817
  view.destroy();
@@ -26157,9 +26822,12 @@ function createHelpDeskSupport(config, options) {
26157
26822
  function update(change) {
26158
26823
  if (destroyed)
26159
26824
  return;
26825
+ const rebranded = change.brand !== undefined && change.brand !== state.brand;
26160
26826
  state = { ...state, ...change };
26161
26827
  view.render(state);
26162
26828
  launcher?.setExpanded(state.visible);
26829
+ if (rebranded)
26830
+ launcher?.setBrand(state.brand);
26163
26831
  notify(options.onStateChange, snapshot());
26164
26832
  }
26165
26833
  async function connect() {
@@ -26186,7 +26854,7 @@ function createHelpDeskSupport(config, options) {
26186
26854
  return (await http.request(path, { method: 'POST', body, credentials: 'omit', headers: { 'X-SV-Client': 'help-desk-portal', ...headers } })).data;
26187
26855
  },
26188
26856
  });
26189
- update({ deskName: answer.desk.organization_name || 'Support', brandColor: answer.desk.branding?.color, contactNote: answer.desk.ticket_contact_note ?? undefined });
26857
+ update({ deskName: answer.desk.organization_name || 'Support', brand: brandFor(answer.desk.branding?.color, state.brand), contactNote: answer.desk.ticket_contact_note ?? undefined });
26190
26858
  return answer;
26191
26859
  }).catch((error) => { connected = null; throw error; });
26192
26860
  return connected;
@@ -26577,6 +27245,7 @@ function createHelpDeskSupport(config, options) {
26577
27245
  persist: options.persist,
26578
27246
  pageLayout: options.target !== undefined,
26579
27247
  hostShowsAttribution: options.hostShowsAttribution === true,
27248
+ brand: state.brand,
26580
27249
  onSession: (session) => {
26581
27250
  anonymous = false;
26582
27251
  if (options.persist)
@@ -27009,7 +27678,7 @@ function createHelpDeskSupport(config, options) {
27009
27678
  client?.clearTicketAccess();
27010
27679
  client?.setSession(null);
27011
27680
  client = null;
27012
- state = { visible: false, stage: 'issue', deskName: 'Support', issue: '' };
27681
+ state = { visible: false, stage: 'issue', deskName: 'Support', issue: '', brand: state.brand };
27013
27682
  },
27014
27683
  };
27015
27684
  }
@@ -31150,7 +31819,8 @@ class SparksModule {
31150
31819
  /**
31151
31820
  * Deliver an invite-only spark's link to its invitee again, changing
31152
31821
  * nothing about the link: the way on from an invitation that could not be
31153
- * delivered (a share rejected with INVITATION_DELIVERY_FAILED leaves its
31822
+ * delivered (a share rejected with INVITATION_DELIVERY_FAILED or a 402
31823
+ * usage-credit funding refusal leaves its
31154
31824
  * link in place, and the same share again delivers nothing), or one the
31155
31825
  * invitee never received. `linkCode` names the link the resend was asked
31156
31826
  * of: a link replaced since is never delivered in its place (409 CONFLICT).
@@ -31778,7 +32448,7 @@ class SparkVault {
31778
32448
  }
31779
32449
  /** Get the SDK version */
31780
32450
  static get version() {
31781
- return '18.0.0';
32451
+ return '18.0.2';
31782
32452
  }
31783
32453
  }
31784
32454
  if (typeof window !== 'undefined') {