@sparkvault/sdk-js 17.0.2 → 18.0.1
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/README.md +89 -12
- package/dist/index.cjs +881 -349
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +16 -11
- package/dist/index.mjs +881 -349
- package/dist/index.mjs.map +1 -1
- package/dist/products/help-desk/client.d.ts +0 -4
- package/dist/products/help-desk/form-types.d.ts +3 -0
- package/dist/products/help-desk/kb-types.d.ts +1 -2
- package/dist/products/help-desk/styles.d.ts +8 -1
- package/dist/products/help-desk/support-brand.d.ts +49 -2
- package/dist/products/help-desk/support-launcher.d.ts +8 -2
- package/dist/products/help-desk/support-styles.d.ts +8 -1
- package/dist/products/help-desk/support-view.d.ts +3 -1
- package/dist/products/help-desk/types.d.ts +1 -5
- package/dist/products/help-desk/widget-identity.d.ts +2 -2
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1155,6 +1155,18 @@ const SPARKVAULT_FILES_HOST = 'files.sv';
|
|
|
1155
1155
|
*/
|
|
1156
1156
|
const SPARKVAULT_HELP_DESK_DOMAIN = 'help.sv';
|
|
1157
1157
|
|
|
1158
|
+
/**
|
|
1159
|
+
* The Help Desk sign-in host (`https://signin.help.sv`): the one fixed host of
|
|
1160
|
+
* the window Help Desk's own sign-in opens (`/{desk_id}/{challenge_id}`) and
|
|
1161
|
+
* of the one redirect URI its Identity client registers (`/callback`). Its
|
|
1162
|
+
* label is a reserved organization handle (organization-handle.js), so no desk
|
|
1163
|
+
* can hold it, and the help.sv Worker serves the portal's shell on it as on
|
|
1164
|
+
* every host of the domain. Like every host under the help-desk domain it is
|
|
1165
|
+
* reserved and not owned (isSparkVaultOwnedHostname). Core takes the window's
|
|
1166
|
+
* steps only from exactly this origin.
|
|
1167
|
+
*/
|
|
1168
|
+
const SPARKVAULT_HELP_DESK_SIGN_IN_HOST = `signin.${SPARKVAULT_HELP_DESK_DOMAIN}`;
|
|
1169
|
+
|
|
1158
1170
|
/**
|
|
1159
1171
|
* Notify's mail domain: each organization's Notify mail goes from a host under
|
|
1160
1172
|
* it, as its help desk's goes from one under the help-desk domain. On the web
|
|
@@ -14737,8 +14749,8 @@ Array.from({ length: 1 << BRAND_BITS.size }, (_, mask) =>
|
|
|
14737
14749
|
* presets, size limits, the operator display and desk mode choices, the
|
|
14738
14750
|
* operator queue's views and orders, the reply review list's views and
|
|
14739
14751
|
* states, the response-time histogram's bucket edges, the sections of a
|
|
14740
|
-
* desk's settings an address names, and the messages
|
|
14741
|
-
* sign-in posts between the website and its
|
|
14752
|
+
* desk's settings an address names, and the messages Help Desk's own
|
|
14753
|
+
* sign-in posts between the website and its sign-in window live here for
|
|
14742
14754
|
* the same reason. So does the one rule a typed or pasted sign-in code is
|
|
14743
14755
|
* read by (helpDeskPinDigits), which every sign-in form applies. So does the
|
|
14744
14756
|
* one way a client names a message it sends (newMessageId), which the
|
|
@@ -14766,14 +14778,15 @@ const HELP_DESK_CLOSE_REASONS = Object.freeze(['resolved', 'duplicate', 'spam'])
|
|
|
14766
14778
|
Object.freeze(HELP_DESK_CLOSE_REASONS.filter((reason) => reason !== 'duplicate'));
|
|
14767
14779
|
|
|
14768
14780
|
/**
|
|
14769
|
-
* The messages
|
|
14770
|
-
* window (the JS SDK's openWidgetIdentity) and the
|
|
14771
|
-
*
|
|
14772
|
-
*
|
|
14773
|
-
*
|
|
14774
|
-
* sign-in's code
|
|
14775
|
-
*
|
|
14776
|
-
*
|
|
14781
|
+
* The messages Help Desk's own sign-in exchanges between the website's
|
|
14782
|
+
* window (the JS SDK's openWidgetIdentity) and the sign-in window it opens on
|
|
14783
|
+
* the Help Desk sign-in host (the portal's sign-in window page): the window
|
|
14784
|
+
* asks its opener for the challenge's state (`ready`), the opener answers its
|
|
14785
|
+
* own popup alone, at the sign-in origin (`state`), and the window reports
|
|
14786
|
+
* the sign-in's code, only once the person confirms it, or its cancellation
|
|
14787
|
+
* (`result`) to the website's origin alone. Every message names its
|
|
14788
|
+
* challenge, and the state is never in the window's URL, so only the window
|
|
14789
|
+
* that started a challenge can complete it.
|
|
14777
14790
|
*/
|
|
14778
14791
|
const HELP_DESK_WIDGET_IDENTITY_MESSAGES = Object.freeze({
|
|
14779
14792
|
ready: 'sparkvault:help-desk:identity-ready',
|
|
@@ -17949,22 +17962,24 @@ function mapInvitation(wire) {
|
|
|
17949
17962
|
};
|
|
17950
17963
|
}
|
|
17951
17964
|
|
|
17952
|
-
/** The native support ceremony. Identity
|
|
17965
|
+
/** The native support ceremony. Identity's answer stays inside the Help Desk sign-in window. */
|
|
17953
17966
|
const VALUE = /^[A-Za-z0-9_-]{43}$/;
|
|
17967
|
+
/** The one origin the sign-in window runs on. Never read from the challenge's sign-in URL, which is checked against it. */
|
|
17968
|
+
const SIGN_IN_ORIGIN = `https://${SPARKVAULT_HELP_DESK_SIGN_IN_HOST}`;
|
|
17954
17969
|
/** The website's own opener policy cut the window off: no retry on this page can work, only its owner can fix it. */
|
|
17955
17970
|
const SEVERED_MESSAGE = 'This website stops the support sign-in window from reporting back, so sign-in cannot finish here. Let the website\'s owner know.';
|
|
17956
|
-
/** How often the sign-in window's handle is checked once it leaves for
|
|
17971
|
+
/** How often the sign-in window's handle is checked once it leaves for its start page. */
|
|
17957
17972
|
const HANDLE_CHECK_MS = 500;
|
|
17958
17973
|
/**
|
|
17959
17974
|
* What a sign-in window's handle reading `closed` before its page's ready
|
|
17960
17975
|
* message means. A website serving `Cross-Origin-Opener-Policy: same-origin`
|
|
17961
|
-
* severs the window the moment its
|
|
17976
|
+
* severs the window the moment its start page loads: the handle reads
|
|
17962
17977
|
* `closed` while the window stays open in front of the person, showing that
|
|
17963
17978
|
* page's own "not connected" notice. So:
|
|
17964
17979
|
* - the website's page holding focus again means the person closed the
|
|
17965
17980
|
* window and is back on it: a cancellation;
|
|
17966
17981
|
* - a handle that reads `closed` at the first check after the window left
|
|
17967
|
-
* for
|
|
17982
|
+
* for its start page, while the website's page still lacks focus, is a
|
|
17968
17983
|
* severance: the window is still in front of the person, for no person
|
|
17969
17984
|
* closes it that fast and then leaves the website;
|
|
17970
17985
|
* - anything else cannot be told apart (a severance on a slow load, or a
|
|
@@ -17981,6 +17996,19 @@ function closedBeforeReady(firstCheck) {
|
|
|
17981
17996
|
return new PopupSeveredError(SEVERED_MESSAGE);
|
|
17982
17997
|
return new SparkVaultError('Support sign-in did not start. Try again.', 'HELP_DESK_WIDGET_SIGN_IN_INTERRUPTED');
|
|
17983
17998
|
}
|
|
17999
|
+
/**
|
|
18000
|
+
* The challenge's start page, `https://signin.help.sv/{desk_id}/{challenge_id}`:
|
|
18001
|
+
* its sign-in URL when that is exactly the sign-in window's page for this
|
|
18002
|
+
* desk and this challenge, and the challenge's other values have their
|
|
18003
|
+
* shapes; else null.
|
|
18004
|
+
*/
|
|
18005
|
+
function startPage(value, deskId) {
|
|
18006
|
+
if (!value || ![value.challenge_id, value.verifier, value.state].every((part) => typeof part === 'string' && VALUE.test(part)) ||
|
|
18007
|
+
!Number.isSafeInteger(value.expires_at))
|
|
18008
|
+
return null;
|
|
18009
|
+
const expected = `${SIGN_IN_ORIGIN}/${deskId}/${value.challenge_id}`;
|
|
18010
|
+
return value.sign_in_url === expected ? expected : null;
|
|
18011
|
+
}
|
|
17984
18012
|
/**
|
|
17985
18013
|
* Open synchronously inside the user's gesture, before preparing the server
|
|
17986
18014
|
* challenge. A session redeemed after the sign-in already ended (cancelled,
|
|
@@ -18003,7 +18031,6 @@ function openWidgetIdentity(options, prepare, ready, redeem, discard, deskId) {
|
|
|
18003
18031
|
catch { /* The popup may already have navigated. */ }
|
|
18004
18032
|
return new Promise((resolve, reject) => {
|
|
18005
18033
|
let challenge = null;
|
|
18006
|
-
let firstPartyOrigin = null;
|
|
18007
18034
|
let settled = false;
|
|
18008
18035
|
let checking = false;
|
|
18009
18036
|
let interval;
|
|
@@ -18048,19 +18075,19 @@ function openWidgetIdentity(options, prepare, ready, redeem, discard, deskId) {
|
|
|
18048
18075
|
finish(null, session);
|
|
18049
18076
|
};
|
|
18050
18077
|
const receive = (event) => {
|
|
18051
|
-
if (!challenge || event.source !== popup || event.origin !==
|
|
18078
|
+
if (!challenge || event.source !== popup || event.origin !== SIGN_IN_ORIGIN)
|
|
18052
18079
|
return;
|
|
18053
18080
|
const data = event.data;
|
|
18054
18081
|
if (!data || data.challenge_id !== challenge.challenge_id)
|
|
18055
18082
|
return;
|
|
18056
|
-
// The
|
|
18057
|
-
//
|
|
18058
|
-
//
|
|
18059
|
-
//
|
|
18083
|
+
// The sign-in window this page opened asks for the challenge's state,
|
|
18084
|
+
// without which Core takes none of its steps: only this popup, at the
|
|
18085
|
+
// sign-in origin, is ever answered, so a sign-in link opened in any
|
|
18086
|
+
// other window or browser completes nothing.
|
|
18060
18087
|
if (data.type === HELP_DESK_WIDGET_IDENTITY_MESSAGES.ready) {
|
|
18061
18088
|
if (watch)
|
|
18062
18089
|
clearInterval(watch);
|
|
18063
|
-
popup.postMessage({ type: HELP_DESK_WIDGET_IDENTITY_MESSAGES.state, challenge_id: challenge.challenge_id, state: challenge.state },
|
|
18090
|
+
popup.postMessage({ type: HELP_DESK_WIDGET_IDENTITY_MESSAGES.state, challenge_id: challenge.challenge_id, state: challenge.state }, SIGN_IN_ORIGIN);
|
|
18064
18091
|
return;
|
|
18065
18092
|
}
|
|
18066
18093
|
if (data.type !== HELP_DESK_WIDGET_IDENTITY_MESSAGES.result || data.state !== challenge.state)
|
|
@@ -18077,10 +18104,8 @@ function openWidgetIdentity(options, prepare, ready, redeem, discard, deskId) {
|
|
|
18077
18104
|
void prepare().then((value) => {
|
|
18078
18105
|
if (settled)
|
|
18079
18106
|
return;
|
|
18080
|
-
const url =
|
|
18081
|
-
if (!
|
|
18082
|
-
url.protocol !== 'https:' || url.origin !== 'https://auth.sv' || url.username || url.password || url.search || url.hash ||
|
|
18083
|
-
url.pathname !== `/help-desk/${deskId}/${value.challenge_id}`)
|
|
18107
|
+
const url = startPage(value, deskId);
|
|
18108
|
+
if (!url)
|
|
18084
18109
|
throw new SparkVaultError('The support sign-in address is invalid.', 'HELP_DESK_INVALID_RESPONSE');
|
|
18085
18110
|
// The window still holds this page's own placeholder, which no opener
|
|
18086
18111
|
// policy severs: closed now, the person closed it.
|
|
@@ -18089,8 +18114,7 @@ function openWidgetIdentity(options, prepare, ready, redeem, discard, deskId) {
|
|
|
18089
18114
|
return;
|
|
18090
18115
|
}
|
|
18091
18116
|
challenge = value;
|
|
18092
|
-
|
|
18093
|
-
popup.location.replace(url.href);
|
|
18117
|
+
popup.location.replace(url);
|
|
18094
18118
|
// A window whose handle dies before its page asks for the state can
|
|
18095
18119
|
// never be handed it, so the sign-in ends at once (closedBeforeReady)
|
|
18096
18120
|
// rather than polling until the challenge expires.
|
|
@@ -18101,8 +18125,8 @@ function openWidgetIdentity(options, prepare, ready, redeem, discard, deskId) {
|
|
|
18101
18125
|
finish(closedBeforeReady(checks === 1));
|
|
18102
18126
|
}, HANDLE_CHECK_MS);
|
|
18103
18127
|
// Code delivery must survive a browser severing window.opener during
|
|
18104
|
-
// the
|
|
18105
|
-
// challenge and verifier; no Identity
|
|
18128
|
+
// the window's Identity round trip. Polling knows only the original
|
|
18129
|
+
// challenge and verifier; no Identity token ever reaches this page.
|
|
18106
18130
|
interval = setInterval(() => {
|
|
18107
18131
|
if (settled || checking || !challenge)
|
|
18108
18132
|
return;
|
|
@@ -18244,7 +18268,7 @@ class HelpDeskClient {
|
|
|
18244
18268
|
this.releasedTokens = new Map();
|
|
18245
18269
|
this.ownsSession = false;
|
|
18246
18270
|
// Frozen copies of the records this client reads, so a page changing the desk it handed in (`HelpDeskConnectOptions.desk`) changes nothing here.
|
|
18247
|
-
this.desk = Object.freeze({ ...desk, branding: Object.freeze({ ...desk.branding }),
|
|
18271
|
+
this.desk = Object.freeze({ ...desk, branding: Object.freeze({ ...desk.branding }),
|
|
18248
18272
|
external_identity: desk.external_identity ? Object.freeze({ ...desk.external_identity }) : undefined,
|
|
18249
18273
|
ticket_access_control: desk.ticket_access_control ? Object.freeze({ ...desk.ticket_access_control }) : undefined });
|
|
18250
18274
|
this.http = http;
|
|
@@ -18626,10 +18650,6 @@ class HelpDeskClient {
|
|
|
18626
18650
|
challenge_id: options.challengeId, binding_secret: options.bindingSecret, code: options.code,
|
|
18627
18651
|
});
|
|
18628
18652
|
}
|
|
18629
|
-
/** Identity completion still requires a server-approved desk portal origin. */
|
|
18630
|
-
completeIdentity(options) {
|
|
18631
|
-
return this.establish(apiPath `/v1/hd/desks/${this.desk.desk_id}/auth/identity/complete`, { token: options.token });
|
|
18632
|
-
}
|
|
18633
18653
|
/** Uninstalled result: the owning form/controller decides when the new requester becomes current. */
|
|
18634
18654
|
signInWidgetIdentity(options = {}) {
|
|
18635
18655
|
const revision = this.revision;
|
|
@@ -18648,8 +18668,8 @@ class HelpDeskClient {
|
|
|
18648
18668
|
const result = await this.send('POST', apiPath `/v1/hd/desks/${this.desk.desk_id}/auth/widget/redeem`, {
|
|
18649
18669
|
challenge_id: challenge.challenge_id, verifier: challenge.verifier, ...(code && { code }),
|
|
18650
18670
|
}, undefined, false);
|
|
18651
|
-
// A native sign-in opens a session at
|
|
18652
|
-
//
|
|
18671
|
+
// A native sign-in opens a session at SparkVault's Identity: an email sign-in's customer carries
|
|
18672
|
+
// the `identity` assurance; a sign-in by the organization's own identity provider carries
|
|
18653
18673
|
// the `federated` mark and the `federated` assurance together, never one without the other.
|
|
18654
18674
|
const customer = result?.customer;
|
|
18655
18675
|
const nativeIdentity = customer?.federated === true ? customer.assurance === 'federated' : customer?.assurance === 'identity';
|
|
@@ -18825,7 +18845,657 @@ class HelpDeskClient {
|
|
|
18825
18845
|
}
|
|
18826
18846
|
}
|
|
18827
18847
|
|
|
18828
|
-
/**
|
|
18848
|
+
/**
|
|
18849
|
+
* A tenant's brand color and the WCAG contrast rules that decide how it may be
|
|
18850
|
+
* used: the one hex rule the server stores, the console checks and the portal
|
|
18851
|
+
* paints, the one contrast reading the console's readouts, the portal's
|
|
18852
|
+
* accent and the portal's reading of a help center's ground share, and the
|
|
18853
|
+
* one way a readout writes that reading.
|
|
18854
|
+
*
|
|
18855
|
+
* A brand color is tenant-controlled, so it is used only when it is a
|
|
18856
|
+
* six-digit hex color, read case-insensitively and held in lowercase; anything
|
|
18857
|
+
* else (a color name, a CSS function, a value that runs on into more CSS) is
|
|
18858
|
+
* no color at all.
|
|
18859
|
+
*
|
|
18860
|
+
* A brand color can be any lightness, so whatever shows it picks what goes
|
|
18861
|
+
* with it, in one pairing per scheme that every surface painting the color
|
|
18862
|
+
* shares (the customer portal, the SDK's support journey, the desk's email,
|
|
18863
|
+
* the console's sample):
|
|
18864
|
+
*
|
|
18865
|
+
* light (lightAccent) the fill, moved in lightness away from its label
|
|
18866
|
+
* only where neither white nor ink reads on it at
|
|
18867
|
+
* 4.5:1; white or ink on it, whichever reads more
|
|
18868
|
+
* strongly; the color itself as text only where it
|
|
18869
|
+
* reaches 4.5:1 on both grounds accent text stands on,
|
|
18870
|
+
* the white surface and the canvas tone, ink otherwise
|
|
18871
|
+
* dark (darkAccent) a color with a hue a reader sees, lifted in
|
|
18872
|
+
* lightness at its own hue and the saturation it shows
|
|
18873
|
+
* where it would not read: as text until it reads at
|
|
18874
|
+
* 4.5:1 on every dark ground accent text stands on
|
|
18875
|
+
* (darkAccentInk), as a fill until it stands at 3:1 on
|
|
18876
|
+
* the dark page and its cards under a label at 4.5:1,
|
|
18877
|
+
* its hover too (darkAccentFill); a grey or black, the
|
|
18878
|
+
* dark scheme's ink, as fill and as text, under ink
|
|
18879
|
+
*
|
|
18880
|
+
* A hue is the one a reader sees (shownChroma): a black whose OKLCH chroma
|
|
18881
|
+
* names a hue no reader sees there, such as #000001, pairs as black in both
|
|
18882
|
+
* schemes. Under the pointer each fill moves a step a reader sees, away from
|
|
18883
|
+
* its label wherever there is room, and on dark grounds wherever that step
|
|
18884
|
+
* still stands there (hoverOf). schemePairings gives both pairings at once,
|
|
18885
|
+
* DEFAULT_PAIRINGS the ones a desk with no brand color paints, and
|
|
18886
|
+
* accentProperties says either as the accent custom properties the customer
|
|
18887
|
+
* portal paints with.
|
|
18888
|
+
*
|
|
18889
|
+
* BROWSER-SAFE: data only, no imports.
|
|
18890
|
+
*/
|
|
18891
|
+
|
|
18892
|
+
const HEX_COLOR = /^#[0-9a-f]{6}$/;
|
|
18893
|
+
|
|
18894
|
+
/** WCAG AA's floor for normal-size text. */
|
|
18895
|
+
const AA_TEXT_CONTRAST = 4.5;
|
|
18896
|
+
|
|
18897
|
+
/**
|
|
18898
|
+
* The canvas tone, the design system's `--canvas` (`--color-slate-50`): the
|
|
18899
|
+
* page ground the customer portal (its pages and a customer's own messages)
|
|
18900
|
+
* and the knowledge base's default theme set accent text on, beside the white
|
|
18901
|
+
* surface. The design system publishes its tokens only as CSS, which this
|
|
18902
|
+
* import-free module cannot read, so the value is mirrored here once, and
|
|
18903
|
+
* tests/brand-color.test.js holds it to packages/design-system/tokens/colors.css.
|
|
18904
|
+
*/
|
|
18905
|
+
const CANVAS_COLOR = '#f7fafb';
|
|
18906
|
+
|
|
18907
|
+
/**
|
|
18908
|
+
* The ink, the design system's `--ink` (`--color-slate-900`): the dark text a
|
|
18909
|
+
* pairing paints on a fill and in place of a color too light to stand as
|
|
18910
|
+
* text. Mirrored here once for the same reason as CANVAS_COLOR, and held to
|
|
18911
|
+
* packages/design-system/tokens/colors.css by tests/brand-color.test.js.
|
|
18912
|
+
*/
|
|
18913
|
+
const INK_COLOR = '#0d1a20';
|
|
18914
|
+
|
|
18915
|
+
/**
|
|
18916
|
+
* The design system's dark app grounds accent colors stand on, mirrored for
|
|
18917
|
+
* the same reason as CANVAS_COLOR and held to the tokens the same way: the
|
|
18918
|
+
* page (`--dark-app-canvas`), its cards (`--dark-app-surface`) and the
|
|
18919
|
+
* ground of selected text and of the composer's drop prompt
|
|
18920
|
+
* (`--dark-app-selection`), the lightest ground accent text stands on there.
|
|
18921
|
+
*/
|
|
18922
|
+
const DARK_CANVAS_COLOR = '#071217';
|
|
18923
|
+
const DARK_SURFACE_COLOR = '#0d1a20';
|
|
18924
|
+
const DARK_SELECTION_COLOR = '#1b2e4c';
|
|
18925
|
+
|
|
18926
|
+
/**
|
|
18927
|
+
* The dark app ramp's ink, `--dark-app-ink`: the text on its grounds, and the
|
|
18928
|
+
* accent a grey or black brand color takes there. Mirrored and held to the
|
|
18929
|
+
* tokens as CANVAS_COLOR is.
|
|
18930
|
+
*/
|
|
18931
|
+
const DARK_INK_COLOR = '#f0f5f7';
|
|
18932
|
+
|
|
18933
|
+
/**
|
|
18934
|
+
* The pairings a desk with no brand color paints, in the shape a brand
|
|
18935
|
+
* color's take (schemePairings), so every surface that paints a desk's accent
|
|
18936
|
+
* (the customer portal, the SDK's support journey, the desk's email, the
|
|
18937
|
+
* console's sample) paints this one default: on light grounds the design
|
|
18938
|
+
* system's primary button (`--color-btn-primary`, under the pointer
|
|
18939
|
+
* `--color-btn-primary-hover`) under white, with `--color-action` as text; on
|
|
18940
|
+
* the dark app grounds its action fill (`--dark-app-action`, under the
|
|
18941
|
+
* pointer `--dark-app-action-hover`) under white, with
|
|
18942
|
+
* `--color-action-on-dark` as text. Each color is its token's value,
|
|
18943
|
+
* mirrored and held to the tokens as CANVAS_COLOR is.
|
|
18944
|
+
*/
|
|
18945
|
+
const DEFAULT_PAIRINGS = Object.freeze({
|
|
18946
|
+
light: Object.freeze({ fill: '#0a4eb1', onAccent: 'white', ink: '#216bde', hover: '#03439f' }),
|
|
18947
|
+
dark: Object.freeze({ fill: '#226ee3', onAccent: 'white', ink: '#72a8ff', hover: '#1d60c8' })
|
|
18948
|
+
});
|
|
18949
|
+
|
|
18950
|
+
/**
|
|
18951
|
+
* The chroma a reader sees (shownChroma) under which a color is a grey rather
|
|
18952
|
+
* than a hue: the neutral greys a brand picks (a pure, warm or cool grey,
|
|
18953
|
+
* stone, zinc) sit at 0 to 0.019, and the least saturated colors still named
|
|
18954
|
+
* by their hue (a desaturated olive, a charcoal navy, a taupe, a brown) at
|
|
18955
|
+
* 0.028 to 0.035.
|
|
18956
|
+
*/
|
|
18957
|
+
const CHROMA_FLOOR = 0.02;
|
|
18958
|
+
|
|
18959
|
+
/**
|
|
18960
|
+
* The OKLCH lightness under which OKLCH's chroma names a hue a reader does
|
|
18961
|
+
* not see: CIE L*a*b*'s 6/29, under which L*a*b* weighs light linearly where
|
|
18962
|
+
* OKLab keeps its cube root to black. Near black that cube root finds a hue
|
|
18963
|
+
* in what little light there is (a chroma of 0.021 in #000001, 0.045 in
|
|
18964
|
+
* #00000a) in a color a reader sees as black.
|
|
18965
|
+
*/
|
|
18966
|
+
const LINEAR_LIGHTNESS = 6 / 29;
|
|
18967
|
+
|
|
18968
|
+
/** WCAG AA's floor for a control's parts and a state's mark (1.4.11). */
|
|
18969
|
+
const AA_NON_TEXT_CONTRAST = 3;
|
|
18970
|
+
|
|
18971
|
+
/** sRGB's transfer function: an encoded channel, from 0 to 1, as linear light, and back. */
|
|
18972
|
+
const toLinear = (channel) => (channel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4);
|
|
18973
|
+
const toGamma = (channel) => (channel <= 0.0031308 ? 12.92 * channel : 1.055 * channel ** (1 / 2.4) - 0.055);
|
|
18974
|
+
|
|
18975
|
+
/** A validated `#rrggbb` color's red, green and blue channels, each from 0 to 1. */
|
|
18976
|
+
const channelsOf = (color) => [1, 3, 5].map((offset) => Number.parseInt(color.slice(offset, offset + 2), 16) / 255);
|
|
18977
|
+
|
|
18978
|
+
/** Relative luminance (WCAG 2) of an sRGB color's red, green and blue channels, each from 0 to 1. */
|
|
18979
|
+
function channelLuminance(channels) {
|
|
18980
|
+
const [red, green, blue] = channels.map(toLinear);
|
|
18981
|
+
return 0.2126 * red + 0.7152 * green + 0.0722 * blue;
|
|
18982
|
+
}
|
|
18983
|
+
|
|
18984
|
+
/** Relative luminance (WCAG 2) of a validated `#rrggbb` color. */
|
|
18985
|
+
function relativeLuminance(color) {
|
|
18986
|
+
return channelLuminance(channelsOf(color));
|
|
18987
|
+
}
|
|
18988
|
+
|
|
18989
|
+
/** The contrast ratio of two relative luminances. */
|
|
18990
|
+
function contrastRatio(first, second) {
|
|
18991
|
+
return (Math.max(first, second) + 0.05) / (Math.min(first, second) + 0.05);
|
|
18992
|
+
}
|
|
18993
|
+
|
|
18994
|
+
/** The relative luminance of the ink a fill's text is weighed in, the real ink rather than pure black. */
|
|
18995
|
+
const INK_LUMINANCE = relativeLuminance(INK_COLOR);
|
|
18996
|
+
|
|
18997
|
+
/** The relative luminances of the grounds accent text stands on: the white surface and the canvas tone. */
|
|
18998
|
+
const TEXT_GROUNDS = Object.freeze([1, relativeLuminance(CANVAS_COLOR)]);
|
|
18999
|
+
|
|
19000
|
+
/** The dark app ramp's grounds accent text stands on, as sRGB channels: the dark page, its cards and the selection. */
|
|
19001
|
+
const DARK_TEXT_GROUNDS = Object.freeze([DARK_CANVAS_COLOR, DARK_SURFACE_COLOR, DARK_SELECTION_COLOR].map((color) => Object.freeze(channelsOf(color))));
|
|
19002
|
+
|
|
19003
|
+
/** The dark app ramp's grounds an accent fill stands on, as sRGB channels: the dark page and its cards. */
|
|
19004
|
+
const DARK_FILL_GROUNDS = Object.freeze([DARK_CANVAS_COLOR, DARK_SURFACE_COLOR].map((color) => Object.freeze(channelsOf(color))));
|
|
19005
|
+
|
|
19006
|
+
/** How strongly a color of this luminance reads on the one of `grounds` it reads least on. */
|
|
19007
|
+
function lowestContrast(luminance, grounds) {
|
|
19008
|
+
return Math.min(...grounds.map((ground) => contrastRatio(luminance, ground)));
|
|
19009
|
+
}
|
|
19010
|
+
|
|
19011
|
+
/** The text a fill of this luminance takes: white or ink, whichever reads more strongly on it. */
|
|
19012
|
+
function labelOf(luminance) {
|
|
19013
|
+
return contrastRatio(luminance, 1) >= contrastRatio(luminance, INK_LUMINANCE) ? 'white' : 'ink';
|
|
19014
|
+
}
|
|
19015
|
+
|
|
19016
|
+
/** How strongly that text reads on a fill of this luminance. */
|
|
19017
|
+
function labelContrast(luminance) {
|
|
19018
|
+
return contrastRatio(luminance, labelOf(luminance) === 'white' ? 1 : INK_LUMINANCE);
|
|
19019
|
+
}
|
|
19020
|
+
|
|
19021
|
+
/** How strongly a color of this luminance reads as text on the light ground it reads least on. */
|
|
19022
|
+
function textContrast(luminance) {
|
|
19023
|
+
return lowestContrast(luminance, TEXT_GROUNDS);
|
|
19024
|
+
}
|
|
19025
|
+
|
|
19026
|
+
/**
|
|
19027
|
+
* A validated `#rrggbb` color in OKLCH (lightness from 0 to 1, chroma, hue in
|
|
19028
|
+
* radians), by the same transform the design system derives its palette with
|
|
19029
|
+
* (packages/design-system/scripts/token-css.mjs oklchOfRgb, by which
|
|
19030
|
+
* tests/brand-color.test.js measures every lift).
|
|
19031
|
+
*/
|
|
19032
|
+
function oklchOf(color) {
|
|
19033
|
+
const [r, g, b] = channelsOf(color).map(toLinear);
|
|
19034
|
+
const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
|
|
19035
|
+
const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
|
|
19036
|
+
const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
|
|
19037
|
+
const a = 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s;
|
|
19038
|
+
const bAxis = 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s;
|
|
19039
|
+
return { L: 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s, C: Math.hypot(a, bAxis), H: Math.atan2(bAxis, a) };
|
|
19040
|
+
}
|
|
19041
|
+
|
|
19042
|
+
/** An OKLCH color's linear red, green and blue; a channel outside 0 to 1 is one sRGB cannot draw. */
|
|
19043
|
+
function linearOfOklch(L, C, H) {
|
|
19044
|
+
const [a, b] = [C * Math.cos(H), C * Math.sin(H)];
|
|
19045
|
+
const l = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3;
|
|
19046
|
+
const m = (L - 0.1055613458 * a - 0.0638541728 * b) ** 3;
|
|
19047
|
+
const s = (L - 0.0894841775 * a - 1.291485548 * b) ** 3;
|
|
19048
|
+
return [
|
|
19049
|
+
4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,
|
|
19050
|
+
-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,
|
|
19051
|
+
-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s
|
|
19052
|
+
];
|
|
19053
|
+
}
|
|
19054
|
+
|
|
19055
|
+
/**
|
|
19056
|
+
* The chroma a reader sees in a color (its OKLCH lightness and chroma): its
|
|
19057
|
+
* OKLCH chroma, under LINEAR_LIGHTNESS faded by the square of the color's
|
|
19058
|
+
* share of that lightness, as L*a*b*'s linear weighing scales chroma against
|
|
19059
|
+
* the cube root there.
|
|
19060
|
+
*/
|
|
19061
|
+
const shownChroma = ({ L, C }) => C * Math.min(1, (L / LINEAR_LIGHTNESS) ** 2);
|
|
19062
|
+
|
|
19063
|
+
/** Whether a color (its OKLCH lightness and chroma) has a hue a reader sees: its shown chroma at CHROMA_FLOOR or more. */
|
|
19064
|
+
const hasHue = (oklch) => shownChroma(oklch) >= CHROMA_FLOOR;
|
|
19065
|
+
|
|
19066
|
+
/**
|
|
19067
|
+
* The saturation a walk from a color keeps (shiftedUntil): its shown chroma
|
|
19068
|
+
* for its lightness. A color darker than LINEAR_LIGHTNESS with no hue a
|
|
19069
|
+
* reader sees keeps none, so it walks as a grey: a walk toward the light
|
|
19070
|
+
* would grow its trace into a hue. A lighter grey keeps its faint tint, which
|
|
19071
|
+
* its short walks barely move.
|
|
19072
|
+
*/
|
|
19073
|
+
function saturationOf(oklch) {
|
|
19074
|
+
if (oklch.L <= 0 || (oklch.L < LINEAR_LIGHTNESS && !hasHue(oklch))) return 0;
|
|
19075
|
+
return shownChroma(oklch) / oklch.L;
|
|
19076
|
+
}
|
|
19077
|
+
|
|
19078
|
+
const drawable = (channels) => channels.every((channel) => channel >= 0 && channel <= 1);
|
|
19079
|
+
|
|
19080
|
+
/** The `#rrggbb` color at OKLCH lightness L and hue H, with as much of chroma C as sRGB holds there. */
|
|
19081
|
+
function colorAt(L, C, H) {
|
|
19082
|
+
let chroma = C;
|
|
19083
|
+
if (!drawable(linearOfOklch(L, chroma, H))) {
|
|
19084
|
+
let [low, high] = [0, C];
|
|
19085
|
+
for (let halving = 0; halving < 24; halving += 1) {
|
|
19086
|
+
const middle = (low + high) / 2;
|
|
19087
|
+
if (drawable(linearOfOklch(L, middle, H))) low = middle;
|
|
19088
|
+
else high = middle;
|
|
19089
|
+
}
|
|
19090
|
+
chroma = low;
|
|
19091
|
+
}
|
|
19092
|
+
return `#${linearOfOklch(L, chroma, H).map((channel) => Math.round(toGamma(Math.min(1, Math.max(0, channel))) * 255).toString(16).padStart(2, '0')).join('')}`;
|
|
19093
|
+
}
|
|
19094
|
+
|
|
19095
|
+
/** How far each step of a shift moves a color's OKLCH lightness. */
|
|
19096
|
+
const SHIFT_STEP = 0.005;
|
|
19097
|
+
|
|
19098
|
+
/**
|
|
19099
|
+
* A color as it stands where `reads` asks more of it: itself where it reads,
|
|
19100
|
+
* else moved in OKLCH lightness (up for `direction` 1, down for -1) at its
|
|
19101
|
+
* own hue, one step at a time, to the first step that reads, white or black
|
|
19102
|
+
* at the end. Its saturation (saturationOf), the chroma a reader sees for its
|
|
19103
|
+
* lightness, stays as it is, so a navy lifts to a clear blue of its own
|
|
19104
|
+
* family rather than greying out, with as much of that chroma as sRGB holds
|
|
19105
|
+
* at each step. Null where not even the end reads.
|
|
19106
|
+
*
|
|
19107
|
+
* @param {string} color - A validated brand color
|
|
19108
|
+
* @param {1|-1} direction
|
|
19109
|
+
* @param {(candidate: string) => boolean} reads
|
|
19110
|
+
* @returns {string|null}
|
|
19111
|
+
*/
|
|
19112
|
+
function shiftedUntil(color, direction, reads) {
|
|
19113
|
+
if (reads(color)) return color;
|
|
19114
|
+
const oklch = oklchOf(color);
|
|
19115
|
+
const { L, H } = oklch;
|
|
19116
|
+
const saturation = saturationOf(oklch);
|
|
19117
|
+
for (let lightness = L + direction * SHIFT_STEP; lightness > 0 && lightness < 1; lightness += direction * SHIFT_STEP) {
|
|
19118
|
+
const shifted = colorAt(lightness, saturation * lightness, H);
|
|
19119
|
+
if (reads(shifted)) return shifted;
|
|
19120
|
+
}
|
|
19121
|
+
const end = direction > 0 ? '#ffffff' : '#000000';
|
|
19122
|
+
return reads(end) ? end : null;
|
|
19123
|
+
}
|
|
19124
|
+
|
|
19125
|
+
/**
|
|
19126
|
+
* A brand color as it may be stored and shown, or null when the value is not
|
|
19127
|
+
* one: a `#rrggbb` hex value, read case-insensitively.
|
|
19128
|
+
*
|
|
19129
|
+
* @param {unknown} value
|
|
19130
|
+
* @returns {string|null} The color in lowercase
|
|
19131
|
+
*/
|
|
19132
|
+
function brandColor(value) {
|
|
19133
|
+
if (typeof value !== 'string') return null;
|
|
19134
|
+
const color = value.toLowerCase();
|
|
19135
|
+
return HEX_COLOR.test(color) ? color : null;
|
|
19136
|
+
}
|
|
19137
|
+
|
|
19138
|
+
/** How far a fill under the pointer moves at least, in OKLCH lightness. */
|
|
19139
|
+
const HOVER_SHIFT = 0.05;
|
|
19140
|
+
|
|
19141
|
+
/**
|
|
19142
|
+
* How far a fill under the pointer stands from the fill at least, as a
|
|
19143
|
+
* contrast ratio: where HOVER_SHIFT moves a very dark fill too little for a
|
|
19144
|
+
* reader to see (black's step is a 1.0:1 change), the hover moves on until
|
|
19145
|
+
* it stands this far apart.
|
|
19146
|
+
*/
|
|
19147
|
+
const HOVER_CONTRAST = 1.1;
|
|
19148
|
+
|
|
19149
|
+
/**
|
|
19150
|
+
* A fill under the pointer: the first step in OKLCH lightness at its own hue
|
|
19151
|
+
* (shiftedUntil) at least HOVER_SHIFT from the fill that stands
|
|
19152
|
+
* HOVER_CONTRAST from it, away from its label (darker under white, lighter
|
|
19153
|
+
* under ink), so the label reads more strongly on it still, where that step
|
|
19154
|
+
* `stands` (for a dark fill, standsWhere: on the grounds it stands on, under
|
|
19155
|
+
* its label). Where it does not (a fill too near that end of the range, black
|
|
19156
|
+
* and its nearest neighbors under white or white under ink, or a dark fill
|
|
19157
|
+
* whose step away sinks into its grounds), the first such step toward its
|
|
19158
|
+
* label, where that one stands; a step further either way only moves further
|
|
19159
|
+
* from the fill. Null where neither stands.
|
|
19160
|
+
*
|
|
19161
|
+
* @param {string} fill - A `#rrggbb` color
|
|
19162
|
+
* @param {'white'|'ink'} onAccent - Its label
|
|
19163
|
+
* @param {(candidate: string) => boolean} [stands]
|
|
19164
|
+
* @returns {string|null}
|
|
19165
|
+
*/
|
|
19166
|
+
function hoverOf(fill, onAccent, stands = () => true) {
|
|
19167
|
+
const { L } = oklchOf(fill);
|
|
19168
|
+
const luminance = relativeLuminance(fill);
|
|
19169
|
+
const apart = (candidate) => Math.abs(oklchOf(candidate).L - L) >= HOVER_SHIFT - Number.EPSILON
|
|
19170
|
+
&& contrastRatio(relativeLuminance(candidate), luminance) >= HOVER_CONTRAST;
|
|
19171
|
+
const away = onAccent === 'white' ? -1 : 1;
|
|
19172
|
+
return [away, -away].map((direction) => shiftedUntil(fill, direction, apart)).find((step) => step !== null && stands(step)) ?? null;
|
|
19173
|
+
}
|
|
19174
|
+
|
|
19175
|
+
/**
|
|
19176
|
+
* Whether a dark fill's hover stands where the fill does: at
|
|
19177
|
+
* AA_NON_TEXT_CONTRAST on each of the grounds (their relative luminances),
|
|
19178
|
+
* under the fill's label at AA_TEXT_CONTRAST.
|
|
19179
|
+
*
|
|
19180
|
+
* @param {number[]} luminances
|
|
19181
|
+
* @param {'white'|'ink'} onAccent
|
|
19182
|
+
* @returns {(candidate: string) => boolean}
|
|
19183
|
+
*/
|
|
19184
|
+
const standsWhere = (luminances, onAccent) => (candidate) => {
|
|
19185
|
+
const luminance = relativeLuminance(candidate);
|
|
19186
|
+
return lowestContrast(luminance, luminances) >= AA_NON_TEXT_CONTRAST
|
|
19187
|
+
&& contrastRatio(luminance, onAccent === 'white' ? 1 : INK_LUMINANCE) >= AA_TEXT_CONTRAST;
|
|
19188
|
+
};
|
|
19189
|
+
|
|
19190
|
+
/**
|
|
19191
|
+
* @typedef {Object} AccentPairing
|
|
19192
|
+
* @property {string} fill - The fill of a primary action, `#rrggbb`
|
|
19193
|
+
* @property {'white'|'ink'} onAccent - The text on it: white, or the light ink (INK_COLOR)
|
|
19194
|
+
* @property {string} ink - The accent as text on the scheme's grounds, `#rrggbb`
|
|
19195
|
+
* @property {string} hover - The fill under the pointer, `#rrggbb`
|
|
19196
|
+
*/
|
|
19197
|
+
|
|
19198
|
+
/**
|
|
19199
|
+
* What a brand color becomes on the light grounds (the white surface and the
|
|
19200
|
+
* canvas tone): its label, white or ink, whichever reads more strongly on
|
|
19201
|
+
* it; its fill, itself where that label reads on it at AA_TEXT_CONTRAST,
|
|
19202
|
+
* else moved in lightness away from the label (shiftedUntil) to the first
|
|
19203
|
+
* step where it does; the color itself as text where it reads at
|
|
19204
|
+
* AA_TEXT_CONTRAST on both grounds (accentTextContrast), INK_COLOR otherwise;
|
|
19205
|
+
* and its fill under the pointer (hoverOf).
|
|
19206
|
+
*
|
|
19207
|
+
* @param {unknown} value
|
|
19208
|
+
* @returns {AccentPairing|null} Null when the value is not a brand color
|
|
19209
|
+
*/
|
|
19210
|
+
function lightAccent(value) {
|
|
19211
|
+
const color = brandColor(value);
|
|
19212
|
+
if (!color) return null;
|
|
19213
|
+
const luminance = relativeLuminance(color);
|
|
19214
|
+
const onAccent = labelOf(luminance);
|
|
19215
|
+
const fill = shiftedUntil(color, onAccent === 'white' ? -1 : 1, (candidate) => labelContrast(relativeLuminance(candidate)) >= AA_TEXT_CONTRAST);
|
|
19216
|
+
return { fill, onAccent, ink: textContrast(luminance) >= AA_TEXT_CONTRAST ? color : INK_COLOR, hover: hoverOf(fill, onAccent) };
|
|
19217
|
+
}
|
|
19218
|
+
|
|
19219
|
+
/**
|
|
19220
|
+
* The color a brand color starts its dark lift from: itself where it has a
|
|
19221
|
+
* hue a reader sees (hasHue), kept as it lifts; the dark scheme's ink
|
|
19222
|
+
* (DARK_INK_COLOR) for a grey or black, which has no hue to keep and lifted
|
|
19223
|
+
* would read as a disabled control.
|
|
19224
|
+
*/
|
|
19225
|
+
const darkSource = (color) => (hasHue(oklchOf(color)) ? color : DARK_INK_COLOR);
|
|
19226
|
+
|
|
19227
|
+
/** The relative luminances of grounds given as sRGB channels. */
|
|
19228
|
+
const luminancesOf = (grounds) => grounds.map(channelLuminance);
|
|
19229
|
+
|
|
19230
|
+
/**
|
|
19231
|
+
* A brand color's fill on dark grounds: the color (darkSource) lifted
|
|
19232
|
+
* (shiftedUntil) until it stands at AA_NON_TEXT_CONTRAST on each of `grounds`,
|
|
19233
|
+
* white or ink, whichever reads more strongly on it, reads at
|
|
19234
|
+
* AA_TEXT_CONTRAST, and it has a fill under the pointer that stands there
|
|
19235
|
+
* too (hoverOf, standsWhere); that label; and that hover. A color that
|
|
19236
|
+
* already stands there is itself.
|
|
19237
|
+
*
|
|
19238
|
+
* @param {unknown} value
|
|
19239
|
+
* @param {number[][]} [grounds] - sRGB channels from 0 to 1; the dark app ramp's page and cards unless given
|
|
19240
|
+
* @returns {{ fill: string, onAccent: 'white'|'ink', hover: string }|null} Null when the value is not a brand color, or no lift stands on `grounds`
|
|
19241
|
+
*/
|
|
19242
|
+
function darkAccentFill(value, grounds = DARK_FILL_GROUNDS) {
|
|
19243
|
+
const color = brandColor(value);
|
|
19244
|
+
if (!color) return null;
|
|
19245
|
+
const luminances = luminancesOf(grounds);
|
|
19246
|
+
// The step that stands, with its label and hover, kept from the walk that found it.
|
|
19247
|
+
let found = null;
|
|
19248
|
+
shiftedUntil(darkSource(color), 1, (candidate) => {
|
|
19249
|
+
const luminance = relativeLuminance(candidate);
|
|
19250
|
+
if (lowestContrast(luminance, luminances) < AA_NON_TEXT_CONTRAST || labelContrast(luminance) < AA_TEXT_CONTRAST) return false;
|
|
19251
|
+
const onAccent = labelOf(luminance);
|
|
19252
|
+
const hover = hoverOf(candidate, onAccent, standsWhere(luminances, onAccent));
|
|
19253
|
+
found = hover && { fill: candidate, onAccent, hover };
|
|
19254
|
+
return found !== null;
|
|
19255
|
+
});
|
|
19256
|
+
return found;
|
|
19257
|
+
}
|
|
19258
|
+
|
|
19259
|
+
/**
|
|
19260
|
+
* A brand color as text on dark grounds: the color (darkSource) lifted
|
|
19261
|
+
* (shiftedUntil) until it reads at AA_TEXT_CONTRAST on each of `grounds`. A
|
|
19262
|
+
* color that already reads there is itself.
|
|
19263
|
+
*
|
|
19264
|
+
* @param {unknown} value
|
|
19265
|
+
* @param {number[][]} [grounds] - sRGB channels from 0 to 1; the dark app ramp's page, cards and selection unless given
|
|
19266
|
+
* @returns {string|null} Null when the value is not a brand color, or no lift reads on `grounds`
|
|
19267
|
+
*/
|
|
19268
|
+
function darkAccentInk(value, grounds = DARK_TEXT_GROUNDS) {
|
|
19269
|
+
const color = brandColor(value);
|
|
19270
|
+
if (!color) return null;
|
|
19271
|
+
const luminances = luminancesOf(grounds);
|
|
19272
|
+
return shiftedUntil(darkSource(color), 1, (candidate) => lowestContrast(relativeLuminance(candidate), luminances) >= AA_TEXT_CONTRAST);
|
|
19273
|
+
}
|
|
19274
|
+
|
|
19275
|
+
/**
|
|
19276
|
+
* What a brand color becomes on the design system's dark app grounds: its
|
|
19277
|
+
* fill and label (darkAccentFill) and its text (darkAccentInk), each lifted
|
|
19278
|
+
* at the color's own hue until it reads there. On a help center's own dark
|
|
19279
|
+
* ground the customer portal lifts this pairing again, with the same two,
|
|
19280
|
+
* against that ground and the grounds it draws from it.
|
|
19281
|
+
*
|
|
19282
|
+
* @param {unknown} value
|
|
19283
|
+
* @returns {AccentPairing|null} Null when the value is not a brand color
|
|
19284
|
+
*/
|
|
19285
|
+
function darkAccent(value) {
|
|
19286
|
+
const fill = darkAccentFill(value);
|
|
19287
|
+
return fill && { ...fill, ink: darkAccentInk(value) };
|
|
19288
|
+
}
|
|
19289
|
+
|
|
19290
|
+
/**
|
|
19291
|
+
* A brand color's pairing in each scheme, derived once for whatever writes
|
|
19292
|
+
* them and weighs them together: on the light grounds (lightAccent) and on
|
|
19293
|
+
* the dark app grounds (darkAccent).
|
|
19294
|
+
*
|
|
19295
|
+
* @param {unknown} value
|
|
19296
|
+
* @returns {Readonly<{ light: AccentPairing, dark: AccentPairing }>|null} Null when the value is not a brand color
|
|
19297
|
+
*/
|
|
19298
|
+
function schemePairings(value) {
|
|
19299
|
+
const light = lightAccent(value);
|
|
19300
|
+
return light && Object.freeze({ light, dark: darkAccent(value) });
|
|
19301
|
+
}
|
|
19302
|
+
|
|
19303
|
+
/**
|
|
19304
|
+
* How accentProperties writes white and each scheme's ink, the colors a
|
|
19305
|
+
* design-system token names: as those tokens (`tokens`), for a page whose
|
|
19306
|
+
* stylesheet declares them (the customer portal, the console's sample), or as
|
|
19307
|
+
* the colors themselves (`colors`), for a page that declares none (the SDK's
|
|
19308
|
+
* widget on a customer's website). Each token holds the color beside it.
|
|
19309
|
+
*/
|
|
19310
|
+
const WRITINGS = Object.freeze({
|
|
19311
|
+
tokens: Object.freeze({ white: 'var(--color-white)', ink: 'var(--ink)', darkInk: 'var(--dark-app-ink)' }),
|
|
19312
|
+
colors: Object.freeze({ white: '#ffffff', ink: INK_COLOR, darkInk: DARK_INK_COLOR })
|
|
19313
|
+
});
|
|
19314
|
+
|
|
19315
|
+
/**
|
|
19316
|
+
* The accent custom properties for a desk's pairings (a brand color's,
|
|
19317
|
+
* schemePairings, or DEFAULT_PAIRINGS), for each scheme a help desk surface
|
|
19318
|
+
* paints in: on light grounds the fill (`--hd-light-accent`), the text on it
|
|
19319
|
+
* (`--hd-light-on-accent`), the accent as text (`--hd-light-accent-ink`) and
|
|
19320
|
+
* the fill under the pointer (`--hd-light-accent-hover`); on the dark app
|
|
19321
|
+
* grounds the same four (`--hd-dark-*`). The one place these names are
|
|
19322
|
+
* spelled: the customer portal's root, the console's sample and every element
|
|
19323
|
+
* of the SDK's widget carry what it returns.
|
|
19324
|
+
*
|
|
19325
|
+
* @param {{ light: AccentPairing, dark: AccentPairing }} pairings
|
|
19326
|
+
* @param {'tokens'|'colors'} [writing] - How white and each scheme's ink are written (WRITINGS)
|
|
19327
|
+
* @returns {Record<`--hd-${'light'|'dark'}-${'accent'|'on-accent'|'accent-ink'|'accent-hover'}`, string>}
|
|
19328
|
+
*/
|
|
19329
|
+
function accentProperties(pairings, writing = 'tokens') {
|
|
19330
|
+
const { white, ink, darkInk } = WRITINGS[writing];
|
|
19331
|
+
const label = { white, ink };
|
|
19332
|
+
const { light, dark } = pairings;
|
|
19333
|
+
return {
|
|
19334
|
+
'--hd-light-accent': light.fill,
|
|
19335
|
+
'--hd-light-on-accent': label[light.onAccent],
|
|
19336
|
+
'--hd-light-accent-ink': light.ink === INK_COLOR ? ink : light.ink,
|
|
19337
|
+
'--hd-light-accent-hover': light.hover,
|
|
19338
|
+
'--hd-dark-accent': dark.fill === DARK_INK_COLOR ? darkInk : dark.fill,
|
|
19339
|
+
'--hd-dark-on-accent': label[dark.onAccent],
|
|
19340
|
+
'--hd-dark-accent-ink': dark.ink === DARK_INK_COLOR ? darkInk : dark.ink,
|
|
19341
|
+
'--hd-dark-accent-hover': dark.hover
|
|
19342
|
+
};
|
|
19343
|
+
}
|
|
19344
|
+
|
|
19345
|
+
/**
|
|
19346
|
+
* The help desk's color roles as every customer-facing piece of its UI reads
|
|
19347
|
+
* them, written once: the SDK's support launcher, its panel, the request
|
|
19348
|
+
* form and its modal (sdk-js products/help-desk) and the composer both share
|
|
19349
|
+
* (help-desk-composer.js). Each reads the customer portal's color role of the
|
|
19350
|
+
* same meaning (`--hd-*`, which the portal's root maps to its scheme's color
|
|
19351
|
+
* set), else the design system's light value, the one the portal's own light
|
|
19352
|
+
* set maps the role to, so on a page that sets none, a customer's own website
|
|
19353
|
+
* among them, the UI stays light.
|
|
19354
|
+
*
|
|
19355
|
+
* The accent reads the page's accent roles (`--hd-accent*`, which the portal's
|
|
19356
|
+
* root sets to the pairing its scheme paints), else the light pairing the
|
|
19357
|
+
* element it paints in carries (`--hd-light-accent*`: the SDK's launcher,
|
|
19358
|
+
* panel, form container and modal each carry the desk's), else the light
|
|
19359
|
+
* half of brand-color.js' DEFAULT_PAIRINGS, the pairing a desk without a
|
|
19360
|
+
* brand color takes.
|
|
19361
|
+
*
|
|
19362
|
+
* BROWSER-SAFE: data only; imports only brand-color.js.
|
|
19363
|
+
*/
|
|
19364
|
+
|
|
19365
|
+
|
|
19366
|
+
/**
|
|
19367
|
+
* The light value of each design-system token a role falls back to, keyed by
|
|
19368
|
+
* that token (tests/help-desk-colors.test.js holds each to
|
|
19369
|
+
* packages/design-system/tokens). The canvas tone and the ink are
|
|
19370
|
+
* brand-color.js' mirrors of those tokens.
|
|
19371
|
+
*/
|
|
19372
|
+
const HELP_DESK_LIGHT_COLORS = Object.freeze({
|
|
19373
|
+
'--surface': '#ffffff',
|
|
19374
|
+
'--canvas': CANVAS_COLOR,
|
|
19375
|
+
'--color-slate-100': '#f0f5f7',
|
|
19376
|
+
'--color-slate-200': '#e0e9ed',
|
|
19377
|
+
'--color-slate-300': '#c9d6dc',
|
|
19378
|
+
'--ink': INK_COLOR,
|
|
19379
|
+
'--text-body': '#425761',
|
|
19380
|
+
'--text-muted': '#5e757f',
|
|
19381
|
+
'--color-action-bg': '#eef4fe',
|
|
19382
|
+
'--color-error': '#b02b27'
|
|
19383
|
+
});
|
|
19384
|
+
|
|
19385
|
+
const LIGHT = HELP_DESK_LIGHT_COLORS;
|
|
19386
|
+
|
|
19387
|
+
/** 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. */
|
|
19388
|
+
const DEFAULT = accentProperties(DEFAULT_PAIRINGS, 'colors');
|
|
19389
|
+
|
|
19390
|
+
/** The neutral and error roles, each the page's `--hd-*` role, else its light value. */
|
|
19391
|
+
const HELP_DESK_COLORS = Object.freeze({
|
|
19392
|
+
/** A panel and its cards. */
|
|
19393
|
+
surface: `var(--hd-surface,${LIGHT['--surface']})`,
|
|
19394
|
+
/** A field's ground. */
|
|
19395
|
+
field: `var(--hd-field,${LIGHT['--surface']})`,
|
|
19396
|
+
/** A quiet ground: a question's recap, a note, code, a disabled field. */
|
|
19397
|
+
canvas: `var(--hd-canvas,${LIGHT['--canvas']})`,
|
|
19398
|
+
/** A raised row or control under the pointer. */
|
|
19399
|
+
hover: `var(--hd-hover,${LIGHT['--canvas']})`,
|
|
19400
|
+
/** An icon control under the pointer, and the quietest rules. */
|
|
19401
|
+
fill: `var(--hd-fill,${LIGHT['--color-slate-100']})`,
|
|
19402
|
+
/** Rules and edges. */
|
|
19403
|
+
fillStrong: `var(--hd-fill-strong,${LIGHT['--color-slate-200']})`,
|
|
19404
|
+
/** A field's and a secondary action's edge. */
|
|
19405
|
+
lineStrong: `var(--hd-line-strong,${LIGHT['--color-slate-300']})`,
|
|
19406
|
+
ink: `var(--hd-ink,${LIGHT['--ink']})`,
|
|
19407
|
+
body: `var(--hd-text-body,${LIGHT['--text-body']})`,
|
|
19408
|
+
muted: `var(--hd-text-muted,${LIGHT['--text-muted']})`,
|
|
19409
|
+
/** Selected text, and the composer's drop prompt. */
|
|
19410
|
+
selection: `var(--hd-selection,${LIGHT['--color-action-bg']})`,
|
|
19411
|
+
error: `var(--hd-error,${LIGHT['--color-error']})`
|
|
19412
|
+
});
|
|
19413
|
+
|
|
19414
|
+
/** The accent roles: the fill of a primary action, the text on it, the accent as text, and the fill under the pointer. */
|
|
19415
|
+
const HELP_DESK_ACCENT = Object.freeze({
|
|
19416
|
+
fill: `var(--hd-accent,var(--hd-light-accent,${DEFAULT['--hd-light-accent']}))`,
|
|
19417
|
+
onAccent: `var(--hd-on-accent,var(--hd-light-on-accent,${DEFAULT['--hd-light-on-accent']}))`,
|
|
19418
|
+
ink: `var(--hd-accent-ink,var(--hd-light-accent-ink,${DEFAULT['--hd-light-accent-ink']}))`,
|
|
19419
|
+
hover: `var(--hd-accent-hover,var(--hd-light-accent-hover,${DEFAULT['--hd-light-accent-hover']}))`
|
|
19420
|
+
});
|
|
19421
|
+
|
|
19422
|
+
/** The focus ring's color: the page's `--hd-focus` where it sets one, else the accent as text. */
|
|
19423
|
+
const HELP_DESK_FOCUS = `var(--hd-focus,${HELP_DESK_ACCENT.ink})`;
|
|
19424
|
+
|
|
19425
|
+
/**
|
|
19426
|
+
* Both schemes' pairings as the custom properties an element carries them
|
|
19427
|
+
* under (@sparkvault/app-sdk/brand-color accentProperties: `--hd-light-accent*`,
|
|
19428
|
+
* `--hd-dark-accent*`), written as colors, since a customer's website declares
|
|
19429
|
+
* none of the design system's tokens.
|
|
19430
|
+
*/
|
|
19431
|
+
function pairingProperties(pairings) {
|
|
19432
|
+
return Object.freeze(accentProperties(pairings, 'colors'));
|
|
19433
|
+
}
|
|
19434
|
+
/** The default pairings (@sparkvault/app-sdk/brand-color DEFAULT_PAIRINGS) as the custom properties, every one an element can carry. */
|
|
19435
|
+
const DEFAULT_PROPERTIES = pairingProperties(DEFAULT_PAIRINGS);
|
|
19436
|
+
/**
|
|
19437
|
+
* The default pairings (@sparkvault/app-sdk/brand-color DEFAULT_PAIRINGS, the
|
|
19438
|
+
* ones the customer portal, the console's sample and the desk's email paint
|
|
19439
|
+
* for a desk without a brand color) as stylesheet declarations, which a
|
|
19440
|
+
* desk's brand color replaces (applySupportBrand). The launcher, the support
|
|
19441
|
+
* panel, the request form's container and its modal each carry them, so the
|
|
19442
|
+
* accent roles (@sparkvault/app-sdk/help-desk-colors HELP_DESK_ACCENT) read
|
|
19443
|
+
* the light pairing the element carries, and a website may point those roles
|
|
19444
|
+
* at the dark one.
|
|
19445
|
+
*/
|
|
19446
|
+
const DEFAULT_PAIRING_DECLARATIONS = Object.entries(DEFAULT_PROPERTIES).map(([name, value]) => `${name}:${value}`).join(';');
|
|
19447
|
+
const NO_BRAND = Object.freeze({ color: null, properties: null });
|
|
19448
|
+
/**
|
|
19449
|
+
* Pairs a desk's brand color for every carrier, once: both of its pairings
|
|
19450
|
+
* (@sparkvault/app-sdk/brand-color schemePairings, the ones the customer
|
|
19451
|
+
* portal and the desk's email paint too), under each scheme's names: the
|
|
19452
|
+
* fill, white or the ink on it, the accent as text, and the fill under the
|
|
19453
|
+
* pointer. Whoever learns the desk's color derives it and hands the one brand
|
|
19454
|
+
* to each element it paints (applySupportBrand), so a desk's color is paired
|
|
19455
|
+
* once however often its elements render. A value that is no brand color is
|
|
19456
|
+
* none.
|
|
19457
|
+
*/
|
|
19458
|
+
function supportBrand(value) {
|
|
19459
|
+
const color = brandColor(value);
|
|
19460
|
+
const pairings = color === null ? null : schemePairings(color);
|
|
19461
|
+
return pairings ? Object.freeze({ color, properties: pairingProperties(pairings) }) : NO_BRAND;
|
|
19462
|
+
}
|
|
19463
|
+
/**
|
|
19464
|
+
* The brand for a desk's color: `held` where it pairs that same color, so a
|
|
19465
|
+
* color learned again (a held desk's, then connect's answer for it) is paired
|
|
19466
|
+
* once and stays the one object every element compares.
|
|
19467
|
+
*/
|
|
19468
|
+
function brandFor(value, held) {
|
|
19469
|
+
return brandColor(value) === held.color ? held : supportBrand(value);
|
|
19470
|
+
}
|
|
19471
|
+
/**
|
|
19472
|
+
* Sets a desk's brand (supportBrand) on the launcher, the support panel, the
|
|
19473
|
+
* request form's container or the form's modal. The stylesheet paints the
|
|
19474
|
+
* light pairing wherever the accent roles (`--hd-accent*`) are not set, so on
|
|
19475
|
+
* a website the widget's accent is the pairing the portal paints on light
|
|
19476
|
+
* pages until the page points the roles at the dark pairing, and inside the
|
|
19477
|
+
* customer portal each takes the portal's roles. Scoped to the element, so it
|
|
19478
|
+
* works on a hosted page and on any website the widget stands on; a brand
|
|
19479
|
+
* with no color clears them, and the stylesheet's default pairings return.
|
|
19480
|
+
*/
|
|
19481
|
+
function applySupportBrand(target, brand) {
|
|
19482
|
+
for (const name of Object.keys(DEFAULT_PROPERTIES)) {
|
|
19483
|
+
const value = brand.properties?.[name];
|
|
19484
|
+
if (value)
|
|
19485
|
+
target.style.setProperty(name, value);
|
|
19486
|
+
else
|
|
19487
|
+
target.style.removeProperty(name);
|
|
19488
|
+
}
|
|
19489
|
+
}
|
|
19490
|
+
|
|
19491
|
+
/**
|
|
19492
|
+
* Scoped styles for the optional inline help desk form and its modal, in the
|
|
19493
|
+
* help desk's color roles (@sparkvault/app-sdk/help-desk-colors): their
|
|
19494
|
+
* neutrals the page's roles where it sets them (HOST), their accent the
|
|
19495
|
+
* page's accent roles, else the desk's light pairing, which the form's
|
|
19496
|
+
* container and the modal each carry (ACCENT, DEFAULT_PAIRING_DECLARATIONS),
|
|
19497
|
+
* as the support panel does.
|
|
19498
|
+
*/
|
|
18829
19499
|
function injectHelpDeskFormStyles() {
|
|
18830
19500
|
if (document.getElementById('sparkvault-help-desk-styles'))
|
|
18831
19501
|
return;
|
|
@@ -18834,33 +19504,33 @@ function injectHelpDeskFormStyles() {
|
|
|
18834
19504
|
style.textContent = `
|
|
18835
19505
|
.svhd-overlay{position:fixed;inset:0;z-index:2147483000;display:flex;align-items:center;justify-content:center;padding:16px;background:${DS.modalOverlay};overflow:auto}
|
|
18836
19506
|
.svhd-blur{backdrop-filter:blur(5px)}
|
|
18837
|
-
.svhd-modal{width:100%;max-width:36rem;max-height:calc(100dvh - 32px);overflow:auto;border-radius:12px;background:${
|
|
19507
|
+
.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}}
|
|
18838
19508
|
.svhd-modal-header{display:flex;justify-content:flex-end;padding:12px 16px 0}
|
|
18839
|
-
.svhd-modal-close{border:0;border-radius:4px;background:transparent;color:${
|
|
18840
|
-
.svhd-modal-close:hover{color:${
|
|
18841
|
-
.svhd-modal-close:focus-visible{outline:3px solid ${
|
|
19509
|
+
.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}
|
|
19510
|
+
.svhd-modal-close:hover{color:${HELP_DESK_COLORS.ink}}
|
|
19511
|
+
.svhd-modal-close:focus-visible{outline:3px solid ${HELP_DESK_FOCUS};outline-offset:2px}
|
|
18842
19512
|
.svhd-modal .svhd-container{max-width:none;border:0;border-radius:0;padding-top:8px}
|
|
18843
|
-
.svhd-container{box-sizing:border-box;max-width:36rem;border:1px solid ${
|
|
19513
|
+
.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}}
|
|
18844
19514
|
.svhd-container *{box-sizing:border-box}
|
|
18845
19515
|
.svhd-container h2{font-size:22px;line-height:1.25;margin:0}
|
|
18846
19516
|
.svhd-step-head h2:focus{outline:none}
|
|
18847
19517
|
.svhd-form{display:grid;gap:16px}
|
|
18848
19518
|
.svhd-field{display:grid;gap:6px}
|
|
18849
19519
|
.svhd-label{font-weight:600}
|
|
18850
|
-
.svhd-input{width:100%;border:1px solid ${
|
|
18851
|
-
.svhd-input:focus-visible,.svhd-button:focus-visible,.svhd-link:focus-visible{outline:3px solid ${
|
|
18852
|
-
.svhd-input:disabled{background:${
|
|
19520
|
+
.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}
|
|
19521
|
+
.svhd-input:focus-visible,.svhd-button:focus-visible,.svhd-link:focus-visible{outline:3px solid ${HELP_DESK_FOCUS};outline-offset:2px}
|
|
19522
|
+
.svhd-input:disabled{background:${HELP_DESK_COLORS.canvas}}
|
|
18853
19523
|
.svhd-auth{display:grid;gap:16px;border:0;padding:0;margin:0}
|
|
18854
19524
|
.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}
|
|
18855
19525
|
.svhd-actions{display:flex;align-items:center;gap:12px;flex-wrap:wrap}
|
|
18856
|
-
.svhd-button{border:0;border-radius:6px;padding:10px 16px;min-height:44px;font:600 15px/1.5 system-ui,sans-serif;background:${
|
|
18857
|
-
.svhd-button:hover{background:${
|
|
19526
|
+
.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}
|
|
19527
|
+
.svhd-button:hover{background:${HELP_DESK_ACCENT.hover}}
|
|
18858
19528
|
.svhd-button:disabled{opacity:.6;cursor:default}
|
|
18859
|
-
.svhd-secondary{background:transparent;color:${
|
|
18860
|
-
.svhd-secondary:hover{background:transparent;color:${
|
|
18861
|
-
.svhd-status{margin:0;color:${
|
|
18862
|
-
.svhd-error{color:${
|
|
18863
|
-
.svhd-field-error{margin:0;font-size:14px;color:${
|
|
19529
|
+
.svhd-secondary{background:transparent;color:${HELP_DESK_COLORS.body};padding:10px 4px}
|
|
19530
|
+
.svhd-secondary:hover{background:transparent;color:${HELP_DESK_COLORS.ink}}
|
|
19531
|
+
.svhd-status{margin:0;color:${HELP_DESK_COLORS.body}}
|
|
19532
|
+
.svhd-error{color:${HELP_DESK_COLORS.error}}
|
|
19533
|
+
.svhd-field-error{margin:0;font-size:14px;color:${HELP_DESK_COLORS.error}}
|
|
18864
19534
|
.svhd-code-links{display:flex;flex-wrap:wrap;gap:4px 16px}
|
|
18865
19535
|
.svhd-confirm{display:grid;gap:8px}
|
|
18866
19536
|
.svhd-confirm-title{font-weight:600;margin:0}
|
|
@@ -18868,26 +19538,26 @@ function injectHelpDeskFormStyles() {
|
|
|
18868
19538
|
.svhd-done-title{font-size:18px;line-height:1.3;margin:0}
|
|
18869
19539
|
.svhd-done-title:focus{outline:none}
|
|
18870
19540
|
.svhd-confirmation-message{white-space:pre-wrap;overflow-wrap:anywhere}
|
|
18871
|
-
.svhd-link{display:inline-flex;align-items:center;justify-self:start;min-height:44px;color:${
|
|
18872
|
-
.svhd-hint{font-size:13px;color:${
|
|
19541
|
+
.svhd-link{display:inline-flex;align-items:center;justify-self:start;min-height:44px;color:${HELP_DESK_ACCENT.ink};text-decoration:underline}
|
|
19542
|
+
.svhd-hint{font-size:13px;color:${HELP_DESK_COLORS.body};margin:0}
|
|
18873
19543
|
.svhd-step{display:grid;gap:16px;min-width:0}
|
|
18874
19544
|
.svhd-step-head{display:grid;gap:4px;margin-bottom:4px}
|
|
18875
|
-
.svhd-step-label{margin:0;font-size:13px;font-weight:600;line-height:1.4;color:${
|
|
18876
|
-
.svhd-text-button{display:inline-flex;align-items:center;min-height:44px;padding:0 4px;border:0;border-radius:6px;background:transparent;color:${
|
|
18877
|
-
.svhd-text-button:hover{
|
|
18878
|
-
.svhd-text-button:focus-visible{outline:3px solid ${
|
|
18879
|
-
.svhd-text-button:disabled{color:${
|
|
19545
|
+
.svhd-step-label{margin:0;font-size:13px;font-weight:600;line-height:1.4;color:${HELP_DESK_COLORS.body}}
|
|
19546
|
+
.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}
|
|
19547
|
+
.svhd-text-button:not(:disabled):hover{text-decoration-thickness:2px}
|
|
19548
|
+
.svhd-text-button:focus-visible{outline:3px solid ${HELP_DESK_FOCUS};outline-offset:2px}
|
|
19549
|
+
.svhd-text-button:disabled{color:${HELP_DESK_COLORS.muted};cursor:default}
|
|
18880
19550
|
.svhd-widget-account{display:flex;align-items:center;flex-wrap:wrap;gap:0 16px;min-width:0}
|
|
18881
|
-
.svhd-posting-as{margin:0;color:${
|
|
18882
|
-
.svhd-note{display:flex;align-items:flex-start;gap:10px;margin:0;padding:12px 14px;border:1px solid ${
|
|
18883
|
-
.svhd-step .svhd-note svg{display:block;width:18px;height:18px;flex:none;margin-top:2px;color:${
|
|
18884
|
-
.svhd-recap{display:flex;align-items:center;gap:12px;padding:6px 6px 6px 14px;border:1px solid ${
|
|
19551
|
+
.svhd-posting-as{margin:0;color:${HELP_DESK_COLORS.body};font-size:14px;line-height:1.5;overflow-wrap:anywhere}
|
|
19552
|
+
.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}
|
|
19553
|
+
.svhd-step .svhd-note svg{display:block;width:18px;height:18px;flex:none;margin-top:2px;color:${HELP_DESK_ACCENT.ink}}
|
|
19554
|
+
.svhd-recap{display:flex;align-items:center;gap:12px;padding:6px 6px 6px 14px;border:1px solid ${HELP_DESK_COLORS.fillStrong};border-radius:8px}
|
|
18885
19555
|
.svhd-recap-request{flex:1;min-width:0}
|
|
18886
|
-
.svhd-recap-label{display:block;color:${
|
|
18887
|
-
.svhd-recap-text{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;margin:0;color:${
|
|
19556
|
+
.svhd-recap-label{display:block;color:${HELP_DESK_COLORS.body};font-size:12px;font-weight:600;line-height:1.4}
|
|
19557
|
+
.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}
|
|
18888
19558
|
.svhd-recap .svhd-text-button{flex:none}
|
|
18889
19559
|
.svhd-live{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
|
|
18890
|
-
.svhd-footer{margin-top:20px;font-size:12px;color:${
|
|
19560
|
+
.svhd-footer{margin-top:20px;font-size:12px;color:${HELP_DESK_COLORS.muted}}
|
|
18891
19561
|
`;
|
|
18892
19562
|
document.head.appendChild(style);
|
|
18893
19563
|
}
|
|
@@ -19506,123 +20176,6 @@ function refusalCopy(refusal, maxBytes) {
|
|
|
19506
20176
|
return REFUSAL_COPY[refusal] ?? "This file can't be attached.";
|
|
19507
20177
|
}
|
|
19508
20178
|
|
|
19509
|
-
/**
|
|
19510
|
-
* A tenant's brand color and the WCAG contrast rules that decide how it may be
|
|
19511
|
-
* used: the one hex rule the server stores, the console checks and the portal
|
|
19512
|
-
* paints, the one contrast reading the console's readouts, the portal's
|
|
19513
|
-
* accent and the portal's reading of a help center's ground share, and the
|
|
19514
|
-
* one way a readout writes that reading.
|
|
19515
|
-
*
|
|
19516
|
-
* A brand color is tenant-controlled, so it is used only when it is a
|
|
19517
|
-
* six-digit hex color, read case-insensitively and held in lowercase; anything
|
|
19518
|
-
* else (a color name, a CSS function, a value that runs on into more CSS) is
|
|
19519
|
-
* no color at all.
|
|
19520
|
-
*
|
|
19521
|
-
* A brand color can be any lightness, so whatever shows it picks what goes
|
|
19522
|
-
* with it: white or ink as the text on its fill, whichever reads more
|
|
19523
|
-
* strongly (at least 4.2:1 on any fill, as far as two inks reach on a
|
|
19524
|
-
* mid-tone), and the color itself as text only where it reaches 4.5:1 on
|
|
19525
|
-
* both grounds accent text stands on, the white surface and the canvas
|
|
19526
|
-
* tone, ink otherwise. accentProperties says that as the accent
|
|
19527
|
-
* custom properties the customer portal paints with and the console's sample
|
|
19528
|
-
* of it shows, in the design system's own tokens.
|
|
19529
|
-
*
|
|
19530
|
-
* BROWSER-SAFE: data only, no imports.
|
|
19531
|
-
*/
|
|
19532
|
-
|
|
19533
|
-
const HEX_COLOR = /^#[0-9a-f]{6}$/;
|
|
19534
|
-
|
|
19535
|
-
/** WCAG AA's floor for normal-size text. */
|
|
19536
|
-
const AA_TEXT_CONTRAST = 4.5;
|
|
19537
|
-
|
|
19538
|
-
/**
|
|
19539
|
-
* The canvas tone, the design system's `--canvas` (`--color-slate-50`): the
|
|
19540
|
-
* page ground the customer portal (its pages and a customer's own messages)
|
|
19541
|
-
* and the knowledge base's default theme set accent text on, beside the white
|
|
19542
|
-
* surface. The design system publishes its tokens only as CSS, which this
|
|
19543
|
-
* import-free module cannot read, so the value is mirrored here once, and
|
|
19544
|
-
* tests/brand-color.test.js holds it to packages/design-system/tokens/colors.css.
|
|
19545
|
-
*/
|
|
19546
|
-
const CANVAS_COLOR = '#f7fafb';
|
|
19547
|
-
|
|
19548
|
-
/**
|
|
19549
|
-
* The ink, the design system's `--ink` (`--color-slate-900`): the dark text a
|
|
19550
|
-
* pairing paints on a fill and in place of a color too light to stand as
|
|
19551
|
-
* text. Mirrored here once for the same reason as CANVAS_COLOR, and held to
|
|
19552
|
-
* packages/design-system/tokens/colors.css by tests/brand-color.test.js.
|
|
19553
|
-
*/
|
|
19554
|
-
const INK_COLOR = '#0d1a20';
|
|
19555
|
-
|
|
19556
|
-
/** Relative luminance (WCAG 2) of an sRGB color's red, green and blue channels, each from 0 to 1. */
|
|
19557
|
-
function channelLuminance(channels) {
|
|
19558
|
-
const [red, green, blue] = channels.map((channel) => (channel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4));
|
|
19559
|
-
return 0.2126 * red + 0.7152 * green + 0.0722 * blue;
|
|
19560
|
-
}
|
|
19561
|
-
|
|
19562
|
-
/** Relative luminance (WCAG 2) of a validated `#rrggbb` color. */
|
|
19563
|
-
function relativeLuminance(color) {
|
|
19564
|
-
return channelLuminance([1, 3, 5].map((offset) => Number.parseInt(color.slice(offset, offset + 2), 16) / 255));
|
|
19565
|
-
}
|
|
19566
|
-
|
|
19567
|
-
/** The contrast ratio of two relative luminances. */
|
|
19568
|
-
function contrastRatio(first, second) {
|
|
19569
|
-
return (Math.max(first, second) + 0.05) / (Math.min(first, second) + 0.05);
|
|
19570
|
-
}
|
|
19571
|
-
|
|
19572
|
-
/** The relative luminance of the ink a fill's text is weighed in, the real ink rather than pure black. */
|
|
19573
|
-
const INK_LUMINANCE = relativeLuminance(INK_COLOR);
|
|
19574
|
-
|
|
19575
|
-
/** The relative luminances of the grounds accent text stands on: the white surface and the canvas tone. */
|
|
19576
|
-
const TEXT_GROUNDS = Object.freeze([1, relativeLuminance(CANVAS_COLOR)]);
|
|
19577
|
-
|
|
19578
|
-
/** How strongly a color of this luminance reads as text on the ground it reads least on. */
|
|
19579
|
-
function textContrast(luminance) {
|
|
19580
|
-
return Math.min(...TEXT_GROUNDS.map((ground) => contrastRatio(luminance, ground)));
|
|
19581
|
-
}
|
|
19582
|
-
|
|
19583
|
-
/**
|
|
19584
|
-
* A brand color as it may be stored and shown, or null when the value is not
|
|
19585
|
-
* one: a `#rrggbb` hex value, read case-insensitively.
|
|
19586
|
-
*
|
|
19587
|
-
* @param {unknown} value
|
|
19588
|
-
* @returns {string|null} The color in lowercase
|
|
19589
|
-
*/
|
|
19590
|
-
function brandColor(value) {
|
|
19591
|
-
if (typeof value !== 'string') return null;
|
|
19592
|
-
const color = value.toLowerCase();
|
|
19593
|
-
return HEX_COLOR.test(color) ? color : null;
|
|
19594
|
-
}
|
|
19595
|
-
|
|
19596
|
-
/**
|
|
19597
|
-
* What goes with a brand color: the text on its fill (white or ink,
|
|
19598
|
-
* whichever reads more strongly, at least 4.2:1 on any fill) and the ink for
|
|
19599
|
-
* it as text
|
|
19600
|
-
* (the color itself where it reaches AA_TEXT_CONTRAST on both the white
|
|
19601
|
-
* surface and the canvas tone, ink otherwise).
|
|
19602
|
-
*
|
|
19603
|
-
* @param {unknown} value
|
|
19604
|
-
* @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)
|
|
19605
|
-
*/
|
|
19606
|
-
function accentPairing(value) {
|
|
19607
|
-
const color = brandColor(value);
|
|
19608
|
-
if (!color) return null;
|
|
19609
|
-
const luminance = relativeLuminance(color);
|
|
19610
|
-
const ratio = textContrast(luminance);
|
|
19611
|
-
return {
|
|
19612
|
-
onAccent: contrastRatio(luminance, 1) >= contrastRatio(luminance, INK_LUMINANCE) ? 'white' : 'ink',
|
|
19613
|
-
accentInk: ratio >= AA_TEXT_CONTRAST ? 'accent' : 'ink',
|
|
19614
|
-
ratio
|
|
19615
|
-
};
|
|
19616
|
-
}
|
|
19617
|
-
|
|
19618
|
-
/** Contrast between a brand fill and the label selected by accentPairing. */
|
|
19619
|
-
function accentFillContrast(value) {
|
|
19620
|
-
const color = brandColor(value);
|
|
19621
|
-
if (!color) return null;
|
|
19622
|
-
const pairing = accentPairing(color);
|
|
19623
|
-
return contrastRatio(relativeLuminance(color), pairing.onAccent === 'white' ? 1 : INK_LUMINANCE);
|
|
19624
|
-
}
|
|
19625
|
-
|
|
19626
20179
|
/**
|
|
19627
20180
|
* Files brought to a message's composer by drag, drop and paste, handled
|
|
19628
20181
|
* alike by every composer that takes them: the console's reply composer and
|
|
@@ -19906,11 +20459,14 @@ function helpDeskIcon(name) {
|
|
|
19906
20459
|
* and whether trying again can mend it.
|
|
19907
20460
|
*
|
|
19908
20461
|
* The composer draws its own stylesheet (one unlayered `<style>` per
|
|
19909
|
-
* document), in the
|
|
19910
|
-
*
|
|
19911
|
-
*
|
|
19912
|
-
*
|
|
19913
|
-
*
|
|
20462
|
+
* document), in the help desk's color roles (help-desk-colors.js): the
|
|
20463
|
+
* host's where it sets them, else the design system's light values, with the
|
|
20464
|
+
* help desk's accent as text, the light pairing of the SDK's panel, form
|
|
20465
|
+
* container or modal it stands in where the host sets no accent role. Its
|
|
20466
|
+
* focus ring is the one the host's fields wear: its color, width and offset
|
|
20467
|
+
* are the host's `--hd-focus`, `--hd-focus-width` and `--hd-focus-offset`,
|
|
20468
|
+
* the color else that accent, the width and offset else the SDK's field
|
|
20469
|
+
* ring's (3px, 2px out).
|
|
19914
20470
|
*
|
|
19915
20471
|
* BROWSER-SAFE: builds its DOM through the page's `document`, and imports
|
|
19916
20472
|
* only app-sdk's browser-safe modules.
|
|
@@ -19920,34 +20476,11 @@ function helpDeskIcon(name) {
|
|
|
19920
20476
|
/** The id of the composer's one `<style>` element in a document. */
|
|
19921
20477
|
const HELP_DESK_COMPOSER_STYLE_ID = 'sparkvault-help-desk-composer-styles';
|
|
19922
20478
|
|
|
19923
|
-
/**
|
|
19924
|
-
* The design-system colors the composer is drawn in, each the value of the
|
|
19925
|
-
* token it names (tests/help-desk-composer.test.js holds them to
|
|
19926
|
-
* packages/design-system/tokens). The canvas tone and the ink are
|
|
19927
|
-
* brand-color.js' mirrors of those tokens.
|
|
19928
|
-
*/
|
|
19929
|
-
const COMPOSER_COLORS = Object.freeze({
|
|
19930
|
-
'--color-white': '#ffffff',
|
|
19931
|
-
'--canvas': CANVAS_COLOR,
|
|
19932
|
-
'--color-slate-100': '#f0f5f7',
|
|
19933
|
-
'--color-slate-200': '#e0e9ed',
|
|
19934
|
-
'--color-slate-300': '#c9d6dc',
|
|
19935
|
-
'--color-slate-600': '#425761',
|
|
19936
|
-
'--ink': INK_COLOR,
|
|
19937
|
-
'--color-action': '#216bde',
|
|
19938
|
-
'--color-action-bg': '#eef4fe',
|
|
19939
|
-
'--color-error': '#b02b27'
|
|
19940
|
-
});
|
|
19941
|
-
|
|
19942
|
-
const C = COMPOSER_COLORS;
|
|
19943
|
-
/** The help desk's accent ink where the host sets one, Action Blue where none does. */
|
|
19944
|
-
const ACCENT_INK = `var(--hd-accent-ink,${C['--color-action']})`;
|
|
19945
|
-
/** The focus ring of the host's fields: the SDK's field ring (`.svhd-input`) where the host sets none. */
|
|
19946
|
-
const FOCUS = `var(--hd-focus,${C['--color-action']})`;
|
|
20479
|
+
/** The focus ring's width and offset: the host's where it sets them, else the SDK's field ring (`.svhd-input`). */
|
|
19947
20480
|
const FOCUS_WIDTH = 'var(--hd-focus-width,3px)';
|
|
19948
20481
|
const FOCUS_OFFSET = 'var(--hd-focus-offset,2px)';
|
|
19949
20482
|
/** A control inside the frame wears the ring within its own hit area. */
|
|
19950
|
-
const INSET_RING = `outline:${FOCUS_WIDTH} solid ${
|
|
20483
|
+
const INSET_RING = `outline:${FOCUS_WIDTH} solid ${HELP_DESK_FOCUS};outline-offset:calc(-1 * ${FOCUS_WIDTH});box-shadow:none`;
|
|
19951
20484
|
|
|
19952
20485
|
/**
|
|
19953
20486
|
* The composer's stylesheet. Every rule but the notice's sits under
|
|
@@ -19957,41 +20490,41 @@ const INSET_RING = `outline:${FOCUS_WIDTH} solid ${FOCUS};outline-offset:calc(-1
|
|
|
19957
20490
|
*/
|
|
19958
20491
|
const COMPOSER_CSS = `
|
|
19959
20492
|
.svhd-composer,.svhd-composer *{box-sizing:border-box}
|
|
19960
|
-
.svhd-composer{position:relative;display:flex;flex-direction:column;min-width:0;border:1px solid ${
|
|
19961
|
-
.svhd-composer:has(.svhd-composer-input:focus-visible){outline:${FOCUS_WIDTH} solid ${
|
|
19962
|
-
@supports not selector(:has(*)){.svhd-composer:focus-within{outline:${FOCUS_WIDTH} solid ${
|
|
19963
|
-
.svhd-composer:has(.svhd-composer-input[aria-invalid=true]){border-color:${
|
|
19964
|
-
.svhd-composer.svhd-composer-dragging{border-style:dashed;border-color:${
|
|
19965
|
-
.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:${
|
|
20493
|
+
.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}}
|
|
20494
|
+
.svhd-composer:has(.svhd-composer-input:focus-visible){outline:${FOCUS_WIDTH} solid ${HELP_DESK_FOCUS};outline-offset:${FOCUS_OFFSET}}
|
|
20495
|
+
@supports not selector(:has(*)){.svhd-composer:focus-within{outline:${FOCUS_WIDTH} solid ${HELP_DESK_FOCUS};outline-offset:${FOCUS_OFFSET}}}
|
|
20496
|
+
.svhd-composer:has(.svhd-composer-input[aria-invalid=true]){border-color:${HELP_DESK_COLORS.error}}
|
|
20497
|
+
.svhd-composer.svhd-composer-dragging{border-style:dashed;border-color:${HELP_DESK_ACCENT.ink}}
|
|
20498
|
+
.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}
|
|
19966
20499
|
.svhd-composer .svhd-composer-input:focus,.svhd-composer .svhd-composer-input:focus-visible{outline:none;box-shadow:none}
|
|
19967
|
-
.svhd-composer .svhd-composer-input:disabled{background:${
|
|
19968
|
-
.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:${
|
|
19969
|
-
.svhd-composer .svhd-composer-toolbar{display:flex;align-items:center;flex-wrap:wrap;gap:0 4px;padding:0 4px;border-top:1px solid ${
|
|
19970
|
-
.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:${
|
|
19971
|
-
.svhd-composer .svhd-composer-attach:hover,.svhd-composer .svhd-composer-help:hover{background:${
|
|
20500
|
+
.svhd-composer .svhd-composer-input:disabled{background:${HELP_DESK_COLORS.canvas}}
|
|
20501
|
+
.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}
|
|
20502
|
+
.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}}
|
|
20503
|
+
.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}
|
|
20504
|
+
.svhd-composer .svhd-composer-attach:hover,.svhd-composer .svhd-composer-help:hover{background:${HELP_DESK_COLORS.fill};color:${HELP_DESK_COLORS.ink}}
|
|
19972
20505
|
.svhd-composer .svhd-composer-attach:disabled{opacity:.6;cursor:default}
|
|
19973
20506
|
.svhd-composer .svhd-composer-attach svg{display:block;width:18px;height:18px}
|
|
19974
|
-
.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:${
|
|
20507
|
+
.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}
|
|
19975
20508
|
.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}
|
|
19976
|
-
.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 ${
|
|
20509
|
+
.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}
|
|
19977
20510
|
.svhd-composer .svhd-composer-help-copy{grid-column:1;min-width:0;overflow-wrap:anywhere}
|
|
19978
20511
|
.svhd-composer .svhd-composer-help-copy p{margin:0}
|
|
19979
20512
|
.svhd-composer .svhd-composer-help-copy p+p{margin-top:6px}
|
|
19980
|
-
.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:${
|
|
19981
|
-
.svhd-composer .svhd-composer-help-close:hover,.svhd-composer .svhd-attachment-remove:hover{background:${
|
|
20513
|
+
.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}
|
|
20514
|
+
.svhd-composer .svhd-composer-help-close:hover,.svhd-composer .svhd-attachment-remove:hover{background:${HELP_DESK_COLORS.fillStrong};color:${HELP_DESK_COLORS.ink}}
|
|
19982
20515
|
.svhd-composer .svhd-composer-help-close svg,.svhd-composer .svhd-attachment-remove svg{display:block;width:16px;height:16px}
|
|
19983
|
-
.svhd-composer .svhd-attachment-chips{display:flex;flex-wrap:wrap;gap:8px;list-style:none;margin:0;padding:8px;border-top:1px solid ${
|
|
20516
|
+
.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}}
|
|
19984
20517
|
.svhd-composer .svhd-attachment-chips:empty{display:none}
|
|
19985
|
-
.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 ${
|
|
19986
|
-
.svhd-composer .svhd-attachment-name{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:600;color:${
|
|
19987
|
-
.svhd-composer .svhd-attachment-status{grid-column:1;padding-right:8px;color:${
|
|
19988
|
-
.svhd-composer .svhd-attachment-status.svhd-composer-problem{color:${
|
|
19989
|
-
.svhd-composer .svhd-attachment-progress{grid-column:1/-1;width:calc(100% - 10px);height:6px;margin-top:6px;accent-color:${
|
|
19990
|
-
.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:${
|
|
19991
|
-
.svhd-composer .svhd-attachment-retry{grid-column:2;min-height:44px;margin:0;padding:0 10px;border:0;border-radius:6px;background:transparent;color:${
|
|
20518
|
+
.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}
|
|
20519
|
+
.svhd-composer .svhd-attachment-name{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:600;color:${HELP_DESK_COLORS.ink}}
|
|
20520
|
+
.svhd-composer .svhd-attachment-status{grid-column:1;padding-right:8px;color:${HELP_DESK_COLORS.body};font-size:12px;overflow-wrap:anywhere}
|
|
20521
|
+
.svhd-composer .svhd-attachment-status.svhd-composer-problem{color:${HELP_DESK_COLORS.error}}
|
|
20522
|
+
.svhd-composer .svhd-attachment-progress{grid-column:1/-1;width:calc(100% - 10px);height:6px;margin-top:6px;accent-color:${HELP_DESK_ACCENT.ink}}
|
|
20523
|
+
.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}
|
|
20524
|
+
.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}
|
|
19992
20525
|
.svhd-composer .svhd-attachment-remove:disabled,.svhd-composer .svhd-attachment-retry:disabled{opacity:.6;cursor:default}
|
|
19993
20526
|
.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}}
|
|
19994
|
-
.svhd-composer-notice{margin:0;color:${
|
|
20527
|
+
.svhd-composer-notice{margin:0;color:${HELP_DESK_COLORS.error};font-size:14px;line-height:1.5}
|
|
19995
20528
|
.svhd-composer [hidden],.svhd-composer-notice[hidden]{display:none!important}
|
|
19996
20529
|
`;
|
|
19997
20530
|
|
|
@@ -20913,6 +21446,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20913
21446
|
// The page that lays the support wizard out carries the attribution itself.
|
|
20914
21447
|
footer: options.hostShowsAttribution ? null : createSecuredByFooter('svhd'),
|
|
20915
21448
|
});
|
|
21449
|
+
applySupportBrand(shell.container, options.brand ?? supportBrand(client.desk.branding?.color));
|
|
20916
21450
|
const prefix = `svhd-${++formSequence}`;
|
|
20917
21451
|
const form = document.createElement('form');
|
|
20918
21452
|
form.className = 'svhd-form';
|
|
@@ -21784,9 +22318,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
21784
22318
|
return;
|
|
21785
22319
|
}
|
|
21786
22320
|
hosted.hidden = newRequestUrl === null;
|
|
21787
|
-
message(
|
|
21788
|
-
? 'This help desk cannot sign you in right now. Try again later.'
|
|
21789
|
-
: 'This help desk requires sign-in. Open it in a new tab to sign in and submit your request there.');
|
|
22321
|
+
message('This help desk requires sign-in. Open it in a new tab to sign in and submit your request there.');
|
|
21790
22322
|
}
|
|
21791
22323
|
async function submit() {
|
|
21792
22324
|
if (pending || completed || destroyed)
|
|
@@ -22527,9 +23059,12 @@ function openHelpDeskForm(client, options = {}) {
|
|
|
22527
23059
|
close.addEventListener('click', requestDismiss);
|
|
22528
23060
|
header.append(title, close);
|
|
22529
23061
|
const body = document.createElement('div');
|
|
23062
|
+
// Paired once for the modal and the form inside it.
|
|
23063
|
+
const brand = options.brand ?? supportBrand(client.desk.branding?.color);
|
|
23064
|
+
applySupportBrand(shell.modal, brand);
|
|
22530
23065
|
shell.modal.append(header, body);
|
|
22531
23066
|
try {
|
|
22532
|
-
inner = mountHelpDeskForm(client, { ...options, target: body, onCancel: cancel });
|
|
23067
|
+
inner = mountHelpDeskForm(client, { ...options, brand, target: body, onCancel: cancel });
|
|
22533
23068
|
// State observers run while the inner form mounts. They can dismiss the
|
|
22534
23069
|
// shell before mountHelpDeskForm hands us its cleanup handle.
|
|
22535
23070
|
if (destroyed)
|
|
@@ -24586,8 +25121,12 @@ function createSupportAnalytics({ deskId, post }) {
|
|
|
24586
25121
|
}
|
|
24587
25122
|
|
|
24588
25123
|
let launcherSequence = 0;
|
|
24589
|
-
/**
|
|
24590
|
-
|
|
25124
|
+
/**
|
|
25125
|
+
* A convenience path only: it never owns a second support flow. It carries
|
|
25126
|
+
* the desk's brand (`brand`, then setBrand), so its focus ring is the desk's,
|
|
25127
|
+
* as the panel's are.
|
|
25128
|
+
*/
|
|
25129
|
+
function createSupportLauncher(options, brand, open) {
|
|
24591
25130
|
const button = document.createElement('button');
|
|
24592
25131
|
button.type = 'button';
|
|
24593
25132
|
button.className = 'sv-support-launcher';
|
|
@@ -24596,7 +25135,7 @@ function createSupportLauncher(options, open) {
|
|
|
24596
25135
|
button.setAttribute('aria-haspopup', 'dialog');
|
|
24597
25136
|
button.setAttribute('aria-expanded', 'false');
|
|
24598
25137
|
const offset = (value, fallback) => typeof value === 'number' && Number.isFinite(value) ? Math.min(240, Math.max(12, value)) : fallback;
|
|
24599
|
-
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};
|
|
25138
|
+
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;`;
|
|
24600
25139
|
if (options.imageUrl) {
|
|
24601
25140
|
let url;
|
|
24602
25141
|
try {
|
|
@@ -24622,19 +25161,37 @@ function createSupportLauncher(options, open) {
|
|
|
24622
25161
|
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';
|
|
24623
25162
|
button.append(mark);
|
|
24624
25163
|
}
|
|
25164
|
+
applySupportBrand(button, brand);
|
|
24625
25165
|
button.addEventListener('click', open);
|
|
24626
25166
|
document.body.append(button);
|
|
24627
25167
|
return {
|
|
24628
25168
|
setExpanded(expanded) { button.setAttribute('aria-expanded', String(expanded)); },
|
|
25169
|
+
setBrand(next) { applySupportBrand(button, next); },
|
|
24629
25170
|
destroy() { button.removeEventListener('click', open); button.remove(); },
|
|
24630
25171
|
};
|
|
24631
25172
|
}
|
|
24632
25173
|
|
|
25174
|
+
/**
|
|
25175
|
+
* The launcher's focus ring. The launcher floats over whatever the website
|
|
25176
|
+
* draws beneath it, so its ring opens with two bands no page color hides
|
|
25177
|
+
* (WCAG technique C40): white, then slate-950, which stand over 9:1 apart, so
|
|
25178
|
+
* one of them stands at 3:1 or more on any ground. It is the design system's
|
|
25179
|
+
* focus ring (`--focus-ring`: a surface gap, then the ring) with the darkest
|
|
25180
|
+
* slate as its ring, and the desk's focus color rings outside both.
|
|
25181
|
+
*/
|
|
25182
|
+
const LAUNCHER_RING = `0 0 0 2px ${DS.white},0 0 0 4px ${DS.slate950}`;
|
|
24633
25183
|
/**
|
|
24634
25184
|
* The support journey's only skin. Customer content stays in the product register.
|
|
24635
25185
|
* The panel's focus ring is 2px, 3px out, in the desk's focus color: its width and
|
|
24636
25186
|
* offset are the panel's custom properties, which the help desk composer inside
|
|
24637
|
-
* its request form reads, so the composer rings as the fields beside it do.
|
|
25187
|
+
* its request form reads, so the composer rings as the fields beside it do. It
|
|
25188
|
+
* paints in the help desk's color roles (@sparkvault/app-sdk/help-desk-colors):
|
|
25189
|
+
* its neutrals read the page's roles (HOST), so in the customer portal they
|
|
25190
|
+
* follow the portal's scheme, and stay light anywhere else; its accent reads
|
|
25191
|
+
* the page's accent roles, else the desk's light pairing (ACCENT), which the
|
|
25192
|
+
* panel and the launcher each carry (DEFAULT_PAIRING_DECLARATIONS), so the
|
|
25193
|
+
* launcher rings in the desk's color, as every control in the panel does,
|
|
25194
|
+
* outside a ring of its own that reads on any page (LAUNCHER_RING).
|
|
24638
25195
|
*/
|
|
24639
25196
|
function injectHelpDeskSupportStyles() {
|
|
24640
25197
|
if (document.getElementById('sparkvault-help-desk-support-styles'))
|
|
@@ -24643,8 +25200,8 @@ function injectHelpDeskSupportStyles() {
|
|
|
24643
25200
|
style.id = 'sparkvault-help-desk-support-styles';
|
|
24644
25201
|
style.textContent = `
|
|
24645
25202
|
.svhs-panel,.svhs-panel *{box-sizing:border-box}
|
|
24646
|
-
.svhs-panel{--hd-focus-width:2px;--hd-focus-offset:3px}
|
|
24647
|
-
.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 ${
|
|
25203
|
+
.svhs-panel{--hd-focus-width:2px;--hd-focus-offset:3px;${DEFAULT_PAIRING_DECLARATIONS}}
|
|
25204
|
+
.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)}
|
|
24648
25205
|
.svhs-panel[hidden],.svhs-panel [hidden]{display:none!important}
|
|
24649
25206
|
.svhs-panel[data-stage=results]{height:680px}
|
|
24650
25207
|
.svhs-panel[data-stage=article]{width:704px;height:700px}
|
|
@@ -24655,99 +25212,99 @@ function injectHelpDeskSupportStyles() {
|
|
|
24655
25212
|
.svhs-panel button,.svhs-panel a{touch-action:manipulation;-webkit-tap-highlight-color:transparent}
|
|
24656
25213
|
.svhs-panel button{appearance:none;cursor:pointer;margin:0}
|
|
24657
25214
|
.svhs-panel button:active{transform:translateY(1px)}
|
|
24658
|
-
.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
|
|
25215
|
+
.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}
|
|
24659
25216
|
.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}
|
|
24660
|
-
.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 ${
|
|
24661
|
-
.svhs-desk-name{font-size:14px;font-weight:600;line-height:1.35;color:${
|
|
25217
|
+
.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}}
|
|
25218
|
+
.svhs-desk-name{font-size:14px;font-weight:600;line-height:1.35;color:${HELP_DESK_COLORS.body};overflow-wrap:anywhere;min-width:0}
|
|
24662
25219
|
.svhs-toolbar-actions{display:flex;align-items:center;gap:4px;margin-left:auto;flex:none}
|
|
24663
|
-
.svhs-identity-notice{display:flex;align-items:center;justify-content:space-between;gap:8px;flex:none;padding:8px 24px;border-bottom:1px solid ${
|
|
25220
|
+
.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}}
|
|
24664
25221
|
.svhs-identity-notice .svhs-status{margin:0;font-size:13px}
|
|
24665
25222
|
.svhs-identity-notice .svhs-text-button{flex:none;font-size:13px!important}
|
|
24666
|
-
.svhs-icon-button{display:grid;place-items:center;width:40px;height:40px;flex:none;padding:0;border:0;border-radius:6px;background:transparent;color:${
|
|
24667
|
-
.svhs-icon-button:hover{background:${
|
|
24668
|
-
.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:${
|
|
24669
|
-
.svhs-back:hover{background:${
|
|
24670
|
-
.svhs-back:disabled{background:transparent;color:${
|
|
25223
|
+
.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}
|
|
25224
|
+
.svhs-icon-button:hover{background:${HELP_DESK_COLORS.fill};color:${HELP_DESK_COLORS.ink}}
|
|
25225
|
+
.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}
|
|
25226
|
+
.svhs-back:hover{background:${HELP_DESK_COLORS.hover}}
|
|
25227
|
+
.svhs-back:disabled{background:transparent;color:${HELP_DESK_COLORS.muted};cursor:default;transform:none}
|
|
24671
25228
|
.svhs-screen{display:flex;flex-direction:column;min-height:0;flex:1}
|
|
24672
25229
|
.svhs-scroll{padding:26px 24px;overflow:auto;overscroll-behavior:contain;min-height:0;flex:1;scrollbar-gutter:stable}
|
|
24673
|
-
.svhs-heading{margin:0 0 8px;padding:0;color:${
|
|
25230
|
+
.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}
|
|
24674
25231
|
.svhs-heading:focus,.svhs-article-title:focus{outline:none;box-shadow:none}
|
|
24675
|
-
.svhs-copy{margin:0 0 24px;color:${
|
|
24676
|
-
.svhs-label{display:block;margin:0 0 7px;font-size:13px;font-weight:600;color:${
|
|
24677
|
-
.svhs-issue{display:block;width:100%;min-height:120px;max-height:200px;resize:none;overflow-y:auto;border:1px solid ${
|
|
25232
|
+
.svhs-copy{margin:0 0 24px;color:${HELP_DESK_COLORS.body};font-size:14px;line-height:1.55}
|
|
25233
|
+
.svhs-label{display:block;margin:0 0 7px;font-size:13px;font-weight:600;color:${HELP_DESK_COLORS.body}}
|
|
25234
|
+
.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}
|
|
24678
25235
|
/* The heading is the field's label, so the field follows it at a label's distance from a question this large. */
|
|
24679
25236
|
.svhs-heading+.svhs-issue{margin-top:16px}
|
|
24680
|
-
.svhs-issue::placeholder{color:${
|
|
24681
|
-
.svhs-issue:focus{border-color
|
|
25237
|
+
.svhs-issue::placeholder{color:${HELP_DESK_COLORS.muted};opacity:1}
|
|
25238
|
+
.svhs-issue:focus{border-color:${HELP_DESK_FOCUS}}
|
|
24682
25239
|
.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)}
|
|
24683
|
-
.svhs-primary{background
|
|
24684
|
-
.svhs-primary:hover{background
|
|
25240
|
+
.svhs-primary{background:${HELP_DESK_ACCENT.fill};color:${HELP_DESK_ACCENT.onAccent}}
|
|
25241
|
+
.svhs-primary:hover{background:${HELP_DESK_ACCENT.hover}}
|
|
24685
25242
|
.svhs-primary[aria-disabled=true]{cursor:progress}
|
|
24686
|
-
.svhs-secondary{border-color:${
|
|
24687
|
-
.svhs-secondary:hover{background:${
|
|
24688
|
-
.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
|
|
25243
|
+
.svhs-secondary{border-color:${HELP_DESK_COLORS.lineStrong};background:${HELP_DESK_COLORS.surface};color:${HELP_DESK_COLORS.body}}
|
|
25244
|
+
.svhs-secondary:hover{background:${HELP_DESK_COLORS.hover}}
|
|
25245
|
+
.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}
|
|
24689
25246
|
.svhs-text-button:hover{text-decoration:underline}
|
|
24690
25247
|
.svhs-full{width:100%}
|
|
24691
|
-
.svhs-bottom{padding:16px 24px 18px;flex:none;border-top:1px solid ${
|
|
25248
|
+
.svhs-bottom{padding:16px 24px 18px;flex:none;border-top:1px solid ${HELP_DESK_COLORS.fill}}
|
|
24692
25249
|
.svhs-start-bottom{display:flex;flex-direction:column;align-items:center;gap:6px;padding-top:0;border-top:0}
|
|
24693
25250
|
.svhs-start-bottom .svhs-primary{width:100%}
|
|
24694
|
-
.svhs-query{display:flex;align-items:center;gap:12px;margin:0 0 24px;padding:12px 14px;border:1px solid ${
|
|
25251
|
+
.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}}
|
|
24695
25252
|
.svhs-question{flex:1;min-width:0}
|
|
24696
|
-
.svhs-question-label{display:block;margin-bottom:3px;color:${
|
|
24697
|
-
.svhs-query-text{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;margin:0;color:${
|
|
25253
|
+
.svhs-question-label{display:block;margin-bottom:3px;color:${HELP_DESK_COLORS.muted};font-size:12px;font-weight:500;line-height:1.4}
|
|
25254
|
+
.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}
|
|
24698
25255
|
.svhs-query .svhs-text-button{flex:none;min-width:44px;padding:8px 0}
|
|
24699
25256
|
.svhs-results{display:flex;flex-direction:column;margin:0;padding:0;list-style:none}
|
|
24700
|
-
.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 ${
|
|
24701
|
-
.svhs-results li:first-child .svhs-result{border-top:1px solid ${
|
|
25257
|
+
.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}
|
|
25258
|
+
.svhs-results li:first-child .svhs-result{border-top:1px solid ${HELP_DESK_COLORS.fillStrong}}
|
|
24702
25259
|
.svhs-results li:last-child .svhs-result{border-bottom:0}
|
|
24703
25260
|
.svhs-result-copy{display:block;min-width:0}
|
|
24704
|
-
.svhs-result-icon{margin-top:2px;color:${
|
|
24705
|
-
.svhs-result-chevron{width:16px!important;height:16px!important;margin-top:4px;color:${
|
|
25261
|
+
.svhs-result-icon{margin-top:2px;color:${HELP_DESK_COLORS.muted}}
|
|
25262
|
+
.svhs-result-chevron{width:16px!important;height:16px!important;margin-top:4px;color:${HELP_DESK_COLORS.muted}}
|
|
24706
25263
|
.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}
|
|
24707
|
-
.svhs-result:hover{background:${
|
|
24708
|
-
.svhs-result:hover .svhs-result-title{color
|
|
24709
|
-
.svhs-result-excerpt{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;margin:0;color:${
|
|
24710
|
-
.svhs-result-category{display:block;margin-top:6px;color:${
|
|
24711
|
-
.svhs-results-bottom{display:flex;flex-wrap:wrap;align-items:center;gap:8px 16px;background:${
|
|
25264
|
+
.svhs-result:hover{background:${HELP_DESK_COLORS.hover}}
|
|
25265
|
+
.svhs-result:hover .svhs-result-title{color:${HELP_DESK_ACCENT.ink};text-decoration:underline}
|
|
25266
|
+
.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}
|
|
25267
|
+
.svhs-result-category{display:block;margin-top:6px;color:${HELP_DESK_COLORS.muted};font-size:12px;line-height:1.4}
|
|
25268
|
+
.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}}
|
|
24712
25269
|
/* Wraps below the ticket button when less than 200px remain beside it, as under the panel's full-width button. */
|
|
24713
|
-
.svhs-contact-note{flex:1 1 200px;min-width:0;margin:0;color:${
|
|
24714
|
-
.svhs-error{margin:12px 0 0;color:${
|
|
24715
|
-
.svhs-status{margin:16px 0;color:${
|
|
25270
|
+
.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}
|
|
25271
|
+
.svhs-error{margin:12px 0 0;color:${HELP_DESK_COLORS.error};font-size:14px;line-height:1.5;overflow-wrap:anywhere}
|
|
25272
|
+
.svhs-status{margin:16px 0;color:${HELP_DESK_COLORS.body};font-size:14px;line-height:1.5}
|
|
24716
25273
|
.svhs-empty{padding:12px 0 4px}
|
|
24717
25274
|
.svhs-empty .svhs-heading{font-size:18px;letter-spacing:-.3px}
|
|
24718
25275
|
.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}
|
|
24719
25276
|
@keyframes svhs-spin{to{transform:rotate(360deg)}}
|
|
24720
25277
|
.svhs-article-scroll{padding:34px 48px 28px}
|
|
24721
|
-
.svhs-category{margin:0 0 12px;color:${
|
|
24722
|
-
.svhs-article-title{margin:0 0 18px;color:${
|
|
24723
|
-
.svhs-article-content{color:${
|
|
25278
|
+
.svhs-category{margin:0 0 12px;color:${HELP_DESK_COLORS.muted};font-size:13px;line-height:1.5;overflow-wrap:anywhere}
|
|
25279
|
+
.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}
|
|
25280
|
+
.svhs-article-content{color:${HELP_DESK_COLORS.body};font-size:15px;line-height:1.65;overflow-wrap:anywhere}
|
|
24724
25281
|
.svhs-article-content>*:first-child{margin-top:0}
|
|
24725
25282
|
.svhs-article-content p{margin:0 0 18px;font:inherit;color:inherit}
|
|
24726
|
-
.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:${
|
|
25283
|
+
.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}
|
|
24727
25284
|
.svhs-article-content h3,.svhs-article-content h4,.svhs-article-content h5,.svhs-article-content h6{font-size:16px}
|
|
24728
25285
|
.svhs-article-content ul,.svhs-article-content ol{margin:0 0 22px;padding-left:22px}
|
|
24729
25286
|
.svhs-article-content li{margin:8px 0;padding-left:5px}
|
|
24730
|
-
.svhs-article-content strong{font-weight:600;color:${
|
|
24731
|
-
.svhs-article-content a{color
|
|
25287
|
+
.svhs-article-content strong{font-weight:600;color:${HELP_DESK_COLORS.ink}}
|
|
25288
|
+
.svhs-article-content a{color:${HELP_DESK_ACCENT.ink};text-decoration:underline;text-underline-offset:2px}
|
|
24732
25289
|
.svhs-article-content img,.svhs-article-content video{display:block;max-width:100%;height:auto;margin:20px 0}
|
|
24733
25290
|
.svhs-reader-asset{display:block;max-width:100%;margin:20px 0}
|
|
24734
25291
|
.svhs-reader-asset img{margin:0}
|
|
24735
|
-
.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 ${
|
|
25292
|
+
.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}
|
|
24736
25293
|
.svhs-reader-asset-status[style]{min-height:0}
|
|
24737
|
-
.svhs-article-content blockquote{margin:22px 0;padding:0 0 0 16px;border-left:2px solid ${
|
|
24738
|
-
.svhs-article-content pre{margin:20px 0;padding:14px;border:1px solid ${
|
|
25294
|
+
.svhs-article-content blockquote{margin:22px 0;padding:0 0 0 16px;border-left:2px solid ${HELP_DESK_COLORS.lineStrong};font-size:14px}
|
|
25295
|
+
.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}
|
|
24739
25296
|
.svhs-article-content code{font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:.9em}
|
|
24740
25297
|
.svhs-article-content table{display:block;max-width:100%;border-collapse:collapse;overflow:auto;overscroll-behavior:contain;margin:20px 0;font-size:14px}
|
|
24741
|
-
.svhs-article-content th,.svhs-article-content td{padding:10px 12px;border:1px solid ${
|
|
24742
|
-
.svhs-article-content hr{margin:24px 0;border:0;border-top:1px solid ${
|
|
24743
|
-
.svhs-article-footer{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:14px 24px;border-top:1px solid ${
|
|
25298
|
+
.svhs-article-content th,.svhs-article-content td{padding:10px 12px;border:1px solid ${HELP_DESK_COLORS.fillStrong};text-align:left}
|
|
25299
|
+
.svhs-article-content hr{margin:24px 0;border:0;border-top:1px solid ${HELP_DESK_COLORS.fillStrong}}
|
|
25300
|
+
.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}
|
|
24744
25301
|
.svhs-article-footer .svhs-primary{min-width:110px}
|
|
24745
25302
|
.svhs-article-footer .svhs-text-button{white-space:nowrap;font-size:13px!important}
|
|
24746
|
-
.svhs-article-question{color:${
|
|
25303
|
+
.svhs-article-question{color:${HELP_DESK_COLORS.muted};font-size:13px;line-height:1.5}
|
|
24747
25304
|
.svhs-reader-actions{display:flex;align-items:stretch;gap:12px;flex:none}
|
|
24748
25305
|
.svhs-feedback-scroll{padding-top:30px}
|
|
24749
25306
|
.svhs-feedback-actions{display:flex;flex-direction:column;gap:9px;margin-top:24px}
|
|
24750
|
-
.svhs-feedback-actions .svhs-text-button{align-self:center;color:${
|
|
25307
|
+
.svhs-feedback-actions .svhs-text-button{align-self:center;color:${HELP_DESK_COLORS.muted}}
|
|
24751
25308
|
.svhs-review{margin-top:24px}
|
|
24752
25309
|
.svhs-review .svhs-primary{width:fit-content}
|
|
24753
25310
|
.svhs-contact-scroll{padding:0;scrollbar-gutter:auto}
|
|
@@ -24756,8 +25313,8 @@ function injectHelpDeskSupportStyles() {
|
|
|
24756
25313
|
.svhs-contact-prelude{padding:24px}
|
|
24757
25314
|
.svhs-contact-prelude .svhs-secondary{margin-top:16px}
|
|
24758
25315
|
.svhs-ticket-gate{padding:0 24px 24px}
|
|
24759
|
-
.svhs-unlock-input{display:block;box-sizing:border-box;width:100%;min-height:46px;margin:0 0 16px;border:1px solid ${
|
|
24760
|
-
.svhs-unlock-input:focus{border-color
|
|
25316
|
+
.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}
|
|
25317
|
+
.svhs-unlock-input:focus{border-color:${HELP_DESK_FOCUS}}
|
|
24761
25318
|
.svhs-unlock-form{margin:0}
|
|
24762
25319
|
.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}
|
|
24763
25320
|
.svhs-contact-target .svhd-body{display:flex;flex:1;flex-direction:column;min-height:0}
|
|
@@ -24766,44 +25323,39 @@ function injectHelpDeskSupportStyles() {
|
|
|
24766
25323
|
.svhs-contact-target .svhd-label{font-size:13px;line-height:1.5}
|
|
24767
25324
|
.svhs-contact-target .svhd-input{font-size:16px;line-height:1.5}
|
|
24768
25325
|
.svhs-contact-target .svhd-actions{gap:10px}
|
|
24769
|
-
.svhs-contact-target .svhd-button:not(.svhd-secondary){background:var(--hd-accent,${DS.action});color:var(--hd-on-accent,${DS.white})}
|
|
24770
|
-
.svhs-contact-target .svhd-button:not(.svhd-secondary):hover{background:var(--hd-accent-hover,${DS.actionHover})}
|
|
24771
|
-
.svhs-contact-target .svhd-link{color:var(--hd-accent-ink,${DS.action})}
|
|
24772
25326
|
.svhs-contact-target .svhd-actions>.svhd-button:first-child{flex:1}
|
|
24773
25327
|
.svhs-contact-target .svhd-status{font-size:14px}
|
|
24774
25328
|
.svhs-contact-target .svhd-auth{gap:14px}
|
|
24775
|
-
.svhs-contact-target .svhd-text-button{color:var(--hd-accent-ink,${DS.action})}
|
|
24776
|
-
.svhs-contact-target .svhd-text-button:disabled{color:${DS.slate500}}
|
|
24777
25329
|
.svhs-contact-target .svhd-widget-form{display:flex;flex:1;flex-direction:column;gap:16px}
|
|
24778
25330
|
/* The request fills the panel: the details step, and in it the composer and its text, take the height the fields leave. */
|
|
24779
25331
|
.svhs-contact-target .svhd-widget-form>[data-contact-step=details]{display:flex;flex:1;flex-direction:column;gap:16px}
|
|
24780
25332
|
.svhs-contact-target .svhd-widget-form .svhd-composer-field{display:flex;flex:1;flex-direction:column;gap:6px;min-height:164px}
|
|
24781
25333
|
.svhs-contact-target .svhd-widget-form .svhd-composer{flex:1}
|
|
24782
25334
|
.svhs-contact-target .svhd-widget-form .svhd-composer-input{flex:1;min-height:120px}
|
|
24783
|
-
.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 ${
|
|
25335
|
+
.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}}
|
|
24784
25336
|
.svhs-contact-target .svhd-widget-form>.svhd-actions>.svhd-secondary{display:none}
|
|
24785
25337
|
.svhs-contact-target .svhd-widget-form .svhd-actions>.svhd-button{font-size:14px}
|
|
24786
|
-
.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 ${
|
|
25338
|
+
.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}}
|
|
24787
25339
|
.svhs-contact-target .svhd-widget-form>.svhd-confirm .svhd-actions{flex-wrap:nowrap}
|
|
24788
25340
|
.svhs-contact-target .svhd-widget-form>.svhd-confirm .svhd-button{flex:1}
|
|
24789
25341
|
.svhs-contact-target .svhd-footer{margin-top:16px;text-align:center;font-size:11px}
|
|
24790
25342
|
.svhs-receipt-scroll{padding-top:36px}
|
|
24791
|
-
.svhs-receipt-mark{width:30px!important;height:30px!important;margin-bottom:20px;color
|
|
24792
|
-
.svhs-ticket-link{display:inline-flex;align-items:center;min-height:44px;margin:0 0 10px;color
|
|
25343
|
+
.svhs-receipt-mark{width:30px!important;height:30px!important;margin-bottom:20px;color:${HELP_DESK_ACCENT.ink}}
|
|
25344
|
+
.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}
|
|
24793
25345
|
.svhs-receipt-note{white-space:pre-wrap;overflow-wrap:anywhere}
|
|
24794
25346
|
.svhs-receipt-actions{display:flex;flex-direction:column;align-items:center;gap:4px}
|
|
24795
25347
|
.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}
|
|
24796
25348
|
.svhs-toast svg{width:18px;height:18px;flex:none;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
|
|
24797
|
-
.svhs-overlay{position:fixed;inset:0;z-index:2147482900;display:flex;background:${
|
|
25349
|
+
.svhs-overlay{position:fixed;inset:0;z-index:2147482900;display:flex;background:${HELP_DESK_COLORS.surface};padding:0;overflow:hidden}
|
|
24798
25350
|
.svhs-modal{width:100%;height:100%;min-width:0;outline:none}
|
|
24799
25351
|
.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}
|
|
24800
|
-
.sv-support-launcher{touch-action:manipulation;-webkit-tap-highlight-color:transparent;transition:background 120ms cubic-bezier(.2,0,0,1)}
|
|
25352
|
+
.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}}
|
|
24801
25353
|
.sv-support-launcher:hover{filter:brightness(1.12)}
|
|
24802
25354
|
.sv-support-launcher:active{transform:translateY(1px)}
|
|
24803
|
-
.sv-support-launcher:focus-visible{outline:3px solid
|
|
25355
|
+
.sv-support-launcher:focus-visible{outline:3px solid ${HELP_DESK_FOCUS};outline-offset:4px;box-shadow:${LAUNCHER_RING},${DS.shadowPopover}}
|
|
24804
25356
|
@media(max-width:640px){
|
|
24805
25357
|
.svhs-panel{right:0;bottom:0;width:100%;height:100dvh;max-width:none;max-height:none;border:0;border-radius:0}
|
|
24806
|
-
.svhs-toolbar{min-height:60px;padding:8px 16px 8px 24px;border-bottom-color:${
|
|
25358
|
+
.svhs-toolbar{min-height:60px;padding:8px 16px 8px 24px;border-bottom-color:${HELP_DESK_COLORS.fillStrong}}
|
|
24807
25359
|
.svhs-icon-button{width:44px;height:44px}
|
|
24808
25360
|
.svhs-back{min-height:44px;max-width:42%}
|
|
24809
25361
|
.svhs-scroll{padding:24px}
|
|
@@ -24835,7 +25387,7 @@ function injectHelpDeskSupportStyles() {
|
|
|
24835
25387
|
@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}}
|
|
24836
25388
|
@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}}
|
|
24837
25389
|
@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}}
|
|
24838
|
-
.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 ${
|
|
25390
|
+
.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}
|
|
24839
25391
|
.svhs-page .svhs-toolbar{min-height:52px;padding:4px 24px}
|
|
24840
25392
|
.svhs-page .svhs-back{max-width:none;white-space:nowrap}
|
|
24841
25393
|
.svhs-page .svhs-desk-name{display:none}
|
|
@@ -25032,35 +25584,6 @@ class SupportPhoneHistory {
|
|
|
25032
25584
|
}
|
|
25033
25585
|
}
|
|
25034
25586
|
|
|
25035
|
-
/** Darken only the narrow range where neither white nor the product ink reaches AA. */
|
|
25036
|
-
function accessibleFill(color) {
|
|
25037
|
-
let fill = color;
|
|
25038
|
-
while ((accentFillContrast(fill) ?? 0) < AA_TEXT_CONTRAST) {
|
|
25039
|
-
fill = `#${[1, 3, 5].map(offset => Math.floor(Number.parseInt(fill.slice(offset, offset + 2), 16) * 0.98).toString(16).padStart(2, '0')).join('')}`;
|
|
25040
|
-
}
|
|
25041
|
-
return fill;
|
|
25042
|
-
}
|
|
25043
|
-
/** Scoped brand properties work in both a hosted page and an unrelated widget host. */
|
|
25044
|
-
function applySupportBrand(target, value) {
|
|
25045
|
-
const color = brandColor(value);
|
|
25046
|
-
if (!color) {
|
|
25047
|
-
for (const name of ['--hd-accent', '--hd-on-accent', '--hd-accent-ink', '--hd-accent-hover', '--hd-focus'])
|
|
25048
|
-
target.style.removeProperty(name);
|
|
25049
|
-
return;
|
|
25050
|
-
}
|
|
25051
|
-
const fill = accessibleFill(color);
|
|
25052
|
-
const pairing = accentPairing(fill);
|
|
25053
|
-
const ink = pairing.accentInk === 'accent' ? fill : DS.slate900;
|
|
25054
|
-
const label = pairing.onAccent === 'white' ? DS.white : DS.slate900;
|
|
25055
|
-
// Dark fills deepen on hover; light fills stay unchanged to preserve label contrast.
|
|
25056
|
-
const hover = pairing.onAccent === 'white'
|
|
25057
|
-
? `#${[1, 3, 5].map(offset => Math.floor(Number.parseInt(fill.slice(offset, offset + 2), 16) * 0.9).toString(16).padStart(2, '0')).join('')}`
|
|
25058
|
-
: fill;
|
|
25059
|
-
const properties = { '--hd-accent': fill, '--hd-on-accent': label, '--hd-accent-ink': ink, '--hd-accent-hover': hover, '--hd-focus': ink };
|
|
25060
|
-
for (const [name, content] of Object.entries(properties))
|
|
25061
|
-
target.style.setProperty(name, content);
|
|
25062
|
-
}
|
|
25063
|
-
|
|
25064
25587
|
/* global MediaQueryList, HTMLImageElement, HTMLAnchorElement, Element */
|
|
25065
25588
|
let sequence = 0;
|
|
25066
25589
|
function element(tag, className, text) {
|
|
@@ -25347,7 +25870,8 @@ class SupportView {
|
|
|
25347
25870
|
if (previous)
|
|
25348
25871
|
this.saveScroll(previous);
|
|
25349
25872
|
this.state = next;
|
|
25350
|
-
|
|
25873
|
+
if (next.brand !== previous?.brand)
|
|
25874
|
+
applySupportBrand(this.panel, next.brand);
|
|
25351
25875
|
this.panel.dataset.stage = next.stage;
|
|
25352
25876
|
const inset = (value, fallback) => typeof value === 'number' && Number.isFinite(value) ? Math.min(480, Math.max(0, value)) : fallback;
|
|
25353
25877
|
this.panel.style.setProperty('--svhs-right', `${inset(next.position?.right, 24)}px`);
|
|
@@ -26050,7 +26574,11 @@ function createHelpDeskSupport(config, options) {
|
|
|
26050
26574
|
let sourceArticleId;
|
|
26051
26575
|
const lifetime = new AbortController();
|
|
26052
26576
|
const bindings = new Set();
|
|
26053
|
-
|
|
26577
|
+
// A desk the page already holds brands the journey from the start, the
|
|
26578
|
+
// launcher included. Any other desk's brand arrives with connect, which the
|
|
26579
|
+
// first open, search or contact makes, never creation: connecting here would
|
|
26580
|
+
// add a desk lookup to every page load of a website that shows the launcher.
|
|
26581
|
+
let state = { visible: false, stage: 'issue', deskName: 'Support', issue: '', brand: supportBrand(options.desk?.branding?.color) };
|
|
26054
26582
|
if (typeof options.launcher === 'object') {
|
|
26055
26583
|
const offset = (value, fallback) => typeof value === 'number' && Number.isFinite(value) ? Math.min(240, Math.max(12, value)) : fallback;
|
|
26056
26584
|
state.position = { right: offset(options.launcher.right, 24), bottom: offset(options.launcher.bottom, 24) + 72 };
|
|
@@ -26124,7 +26652,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
26124
26652
|
}, options.target === undefined ? undefined : resolveTarget(options.target));
|
|
26125
26653
|
const launcher = (() => {
|
|
26126
26654
|
try {
|
|
26127
|
-
return options.launcher ? createSupportLauncher(typeof options.launcher === 'object' ? options.launcher : {}, () => { void open(); }) : null;
|
|
26655
|
+
return options.launcher ? createSupportLauncher(typeof options.launcher === 'object' ? options.launcher : {}, state.brand, () => { void open(); }) : null;
|
|
26128
26656
|
}
|
|
26129
26657
|
catch (error) {
|
|
26130
26658
|
view.destroy();
|
|
@@ -26135,9 +26663,12 @@ function createHelpDeskSupport(config, options) {
|
|
|
26135
26663
|
function update(change) {
|
|
26136
26664
|
if (destroyed)
|
|
26137
26665
|
return;
|
|
26666
|
+
const rebranded = change.brand !== undefined && change.brand !== state.brand;
|
|
26138
26667
|
state = { ...state, ...change };
|
|
26139
26668
|
view.render(state);
|
|
26140
26669
|
launcher?.setExpanded(state.visible);
|
|
26670
|
+
if (rebranded)
|
|
26671
|
+
launcher?.setBrand(state.brand);
|
|
26141
26672
|
notify(options.onStateChange, snapshot());
|
|
26142
26673
|
}
|
|
26143
26674
|
async function connect() {
|
|
@@ -26164,7 +26695,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
26164
26695
|
return (await http.request(path, { method: 'POST', body, credentials: 'omit', headers: { 'X-SV-Client': 'help-desk-portal', ...headers } })).data;
|
|
26165
26696
|
},
|
|
26166
26697
|
});
|
|
26167
|
-
update({ deskName: answer.desk.organization_name || 'Support',
|
|
26698
|
+
update({ deskName: answer.desk.organization_name || 'Support', brand: brandFor(answer.desk.branding?.color, state.brand), contactNote: answer.desk.ticket_contact_note ?? undefined });
|
|
26168
26699
|
return answer;
|
|
26169
26700
|
}).catch((error) => { connected = null; throw error; });
|
|
26170
26701
|
return connected;
|
|
@@ -26555,6 +27086,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
26555
27086
|
persist: options.persist,
|
|
26556
27087
|
pageLayout: options.target !== undefined,
|
|
26557
27088
|
hostShowsAttribution: options.hostShowsAttribution === true,
|
|
27089
|
+
brand: state.brand,
|
|
26558
27090
|
onSession: (session) => {
|
|
26559
27091
|
anonymous = false;
|
|
26560
27092
|
if (options.persist)
|
|
@@ -26797,7 +27329,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
26797
27329
|
sourceArticleId = undefined;
|
|
26798
27330
|
}
|
|
26799
27331
|
/**
|
|
26800
|
-
* Switch account from the contact form:
|
|
27332
|
+
* Switch account from the contact form: the window's chooser opens in this
|
|
26801
27333
|
* gesture, the current session staying current until another account's is
|
|
26802
27334
|
* redeemed. A window that closes or fails rejects, nothing changed, for the
|
|
26803
27335
|
* form to say so; a redeemed session takes the old one's place.
|
|
@@ -26987,7 +27519,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
26987
27519
|
client?.clearTicketAccess();
|
|
26988
27520
|
client?.setSession(null);
|
|
26989
27521
|
client = null;
|
|
26990
|
-
state = { visible: false, stage: 'issue', deskName: 'Support', issue: '' };
|
|
27522
|
+
state = { visible: false, stage: 'issue', deskName: 'Support', issue: '', brand: state.brand };
|
|
26991
27523
|
},
|
|
26992
27524
|
};
|
|
26993
27525
|
}
|
|
@@ -31756,7 +32288,7 @@ class SparkVault {
|
|
|
31756
32288
|
}
|
|
31757
32289
|
/** Get the SDK version */
|
|
31758
32290
|
static get version() {
|
|
31759
|
-
return '
|
|
32291
|
+
return '18.0.1';
|
|
31760
32292
|
}
|
|
31761
32293
|
}
|
|
31762
32294
|
if (typeof window !== 'undefined') {
|