@sparkvault/sdk-js 15.14.0 → 15.14.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/dist/index.cjs +551 -118
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.mjs +551 -118
- package/dist/index.mjs.map +1 -1
- package/dist/products/help-desk/form-draft.d.ts +1 -0
- package/dist/products/help-desk/form-types.d.ts +2 -0
- package/dist/products/help-desk/kb-client.d.ts +11 -2
- package/dist/products/help-desk/kb-types.d.ts +6 -0
- package/dist/products/help-desk/support-brand.d.ts +2 -0
- package/dist/products/help-desk/support-types.d.ts +3 -1
- package/dist/products/help-desk/support-view.d.ts +17 -1
- package/dist/products/help-desk/types.d.ts +2 -0
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/dist/vaults/upload/modal.d.ts +3 -3
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -16834,6 +16834,7 @@ class HelpDeskClient {
|
|
|
16834
16834
|
ticket_id: ticket, subject: options.subject, body: options.body, attachments: options.attachments ?? [],
|
|
16835
16835
|
...(options.assistance_attempt_id && { assistance_attempt_id: options.assistance_attempt_id }),
|
|
16836
16836
|
...(options.assistance_visitor_id && { assistance_visitor_id: options.assistance_visitor_id }),
|
|
16837
|
+
...(options.source_article_id && { source_article_id: options.source_article_id }),
|
|
16837
16838
|
}, undefined, true, context);
|
|
16838
16839
|
}
|
|
16839
16840
|
listTickets(options = {}) {
|
|
@@ -17788,6 +17789,8 @@ const TTL_MS = 30 * 60 * 1000;
|
|
|
17788
17789
|
const storageKey = (deskId, requesterId) => isHelpDeskId(deskId) && isResourceIdOf('requester', requesterId) ? `sv-hd-draft:${deskId}:${requesterId}:new` : null;
|
|
17789
17790
|
const validBody = (value) => typeof value === 'string' && value.length <= MAX_BODY_BYTES && new TextEncoder().encode(value).length <= MAX_BODY_BYTES;
|
|
17790
17791
|
const validSubject = (value) => typeof value === 'string' && value.length <= MAX_SUBJECT_LEN;
|
|
17792
|
+
const validArticleId = (value) => typeof value === 'string' && value.length > 0 && value.length <= 256 &&
|
|
17793
|
+
!Array.from(value).some(character => character.charCodeAt(0) <= 32 || character === '\\');
|
|
17791
17794
|
/** The question before sign-in is tab-local and contains no customer identity. */
|
|
17792
17795
|
function clearSupportIssue(deskId) {
|
|
17793
17796
|
try {
|
|
@@ -17870,10 +17873,12 @@ function readFormDraft(deskId, requesterId) {
|
|
|
17870
17873
|
!Number.isFinite(row.expires_at) || row.expires_at <= Date.now() || row.expires_at > Date.now() + TTL_MS ||
|
|
17871
17874
|
!validSubject(row.subject) || !validBody(row.body) || (row.ticket_id !== null && !isResourceIdOf('ticket', row.ticket_id)) ||
|
|
17872
17875
|
(sent !== null && (!isResourceIdOf('ticket', sent?.ticket_id) || !validSubject(sent.subject) || !validBody(sent.body) ||
|
|
17876
|
+
(sent.source_article_id !== undefined && !validArticleId(sent.source_article_id)) ||
|
|
17873
17877
|
!Array.isArray(sent.attachments) || sent.attachments.length > MAX_ATTACHMENTS_PER_MESSAGE || sent.attachments.some((id) => !isResourceIdOf('attachment', id)))))
|
|
17874
17878
|
throw new Error('Invalid draft');
|
|
17875
17879
|
return { subject: row.subject, body: row.body, ticketId: row.ticket_id, hadFiles: row.had_files === true,
|
|
17876
|
-
uncertain: sent ? { ticketId: sent.ticket_id, subject: sent.subject, body: sent.body, attachments: [...sent.attachments]
|
|
17880
|
+
uncertain: sent ? { ticketId: sent.ticket_id, subject: sent.subject, body: sent.body, attachments: [...sent.attachments],
|
|
17881
|
+
...(sent.source_article_id !== undefined && { source_article_id: sent.source_article_id }) } : null };
|
|
17877
17882
|
}
|
|
17878
17883
|
catch {
|
|
17879
17884
|
removeFormDraft(deskId, requesterId);
|
|
@@ -17892,7 +17897,8 @@ function saveFormDraft(deskId, requesterId, value) {
|
|
|
17892
17897
|
const sent = value.uncertain;
|
|
17893
17898
|
sessionStorage.setItem(key, JSON.stringify({ version: 1, desk_id: deskId, requester_id: requesterId, kind: 'new',
|
|
17894
17899
|
expires_at: Date.now() + TTL_MS, subject: value.subject, body: value.body, ticket_id: value.ticketId,
|
|
17895
|
-
uncertain: sent ? { ticket_id: sent.ticketId, subject: sent.subject, body: sent.body, attachments: sent.attachments
|
|
17900
|
+
uncertain: sent ? { ticket_id: sent.ticketId, subject: sent.subject, body: sent.body, attachments: sent.attachments,
|
|
17901
|
+
...(validArticleId(sent.source_article_id) && { source_article_id: sent.source_article_id }) } : null,
|
|
17896
17902
|
had_files: value.hadFiles }));
|
|
17897
17903
|
}
|
|
17898
17904
|
catch { /* Storage is optional; the live form keeps its composition. */ }
|
|
@@ -18826,7 +18832,14 @@ function mountHelpDeskForm(client, options) {
|
|
|
18826
18832
|
const id = await ensureDraft(ownGeneration, token);
|
|
18827
18833
|
if (!alive(ownGeneration) || !(await tokenFor(ownGeneration)))
|
|
18828
18834
|
return;
|
|
18829
|
-
|
|
18835
|
+
let sourceArticleId;
|
|
18836
|
+
try {
|
|
18837
|
+
sourceArticleId = options.sourceArticleId?.();
|
|
18838
|
+
}
|
|
18839
|
+
catch { /* Optional context cannot prevent sending. */ }
|
|
18840
|
+
uncertainSubmission = { ticketId: id, subject: subjectText, body, attachments: attachments?.attachmentIds ?? [],
|
|
18841
|
+
...(typeof sourceArticleId === 'string' && sourceArticleId.length > 0 && sourceArticleId.length <= 256 &&
|
|
18842
|
+
!Array.from(sourceArticleId).some(character => character.charCodeAt(0) <= 32 || character === '\\') && { source_article_id: sourceArticleId }) };
|
|
18830
18843
|
}
|
|
18831
18844
|
persistDraft();
|
|
18832
18845
|
attachments?.lock(true);
|
|
@@ -19502,6 +19515,10 @@ function recommendKnowledgeBase(prepared, issue, { limit = 5, categoryId = null
|
|
|
19502
19515
|
].map(value => typeof value === 'function' ? value.toString() : value).join('\n') + '\nexport { prepareSearchIndex, searchKnowledgeBase, recommendKnowledgeBase };\n';
|
|
19503
19516
|
|
|
19504
19517
|
/** One published-KB transport and shared local search engine for support entry points. */
|
|
19518
|
+
const currentVisitor = (value) => value !== null && typeof value === 'object' &&
|
|
19519
|
+
'visitor_id' in value && typeof value.visitor_id === 'string' && /^[a-f0-9]{64}$/.test(value.visitor_id) &&
|
|
19520
|
+
'expires_at' in value && typeof value.expires_at === 'number' && Number.isSafeInteger(value.expires_at) &&
|
|
19521
|
+
value.expires_at * 1000 > Date.now() + 60000 && value.expires_at * 1000 <= Date.now() + 31 * 86400000;
|
|
19505
19522
|
const invalid = () => new SparkVaultError('The help center returned an invalid answer. Try again.', 'KB_INVALID_RESPONSE');
|
|
19506
19523
|
const changed = () => new SparkVaultError('The help center changed. Search again to see current answers.', 'KB_PUBLICATION_CHANGED', 409);
|
|
19507
19524
|
const validPath = (value) => typeof value === 'string' && value.startsWith('/') && !value.startsWith('//') &&
|
|
@@ -19517,6 +19534,9 @@ class HelpDeskKnowledgeBaseClient {
|
|
|
19517
19534
|
this.config = null;
|
|
19518
19535
|
this.index = null;
|
|
19519
19536
|
this.indexPending = null;
|
|
19537
|
+
this.visitorSession = null;
|
|
19538
|
+
this.visitorPending = null;
|
|
19539
|
+
this.voteQueues = new Map();
|
|
19520
19540
|
this.objectUrls = new Set();
|
|
19521
19541
|
this.generation = 0;
|
|
19522
19542
|
this.readerRevision = 0;
|
|
@@ -19536,7 +19556,8 @@ class HelpDeskKnowledgeBaseClient {
|
|
|
19536
19556
|
if (this.destroyed)
|
|
19537
19557
|
throw new SparkVaultError('This support session has closed.', 'KB_CLOSED');
|
|
19538
19558
|
const route = typeof suffix === 'object'
|
|
19539
|
-
? apiPath `/v1/hd/desks/${this.deskId}/kb/widget/
|
|
19559
|
+
? 'helpful' in suffix ? apiPath `/v1/hd/desks/${this.deskId}/kb/widget/articles/${suffix.helpful}/helpful`
|
|
19560
|
+
: apiPath `/v1/hd/desks/${this.deskId}/kb/widget/documents/${suffix.document}`
|
|
19540
19561
|
: apiPath `/v1/hd/desks/${this.deskId}/kb/widget/${suffix}`;
|
|
19541
19562
|
const url = new URL(`${this.sdkConfig.apiBaseUrl}${route}`);
|
|
19542
19563
|
if (options.release)
|
|
@@ -19678,6 +19699,87 @@ class HelpDeskKnowledgeBaseClient {
|
|
|
19678
19699
|
const row = index.articles.find(article => article.path === path || (!url.hash && article.path === url.pathname));
|
|
19679
19700
|
return row ? this.result(row, index) : null;
|
|
19680
19701
|
}
|
|
19702
|
+
/** Resolve a ticket's article reference only against the current authorized publication. */
|
|
19703
|
+
async resolveArticle(id) {
|
|
19704
|
+
if (typeof id !== 'string' || !id || id.length > 256)
|
|
19705
|
+
return null;
|
|
19706
|
+
const index = await this.currentIndex();
|
|
19707
|
+
const row = index.articles.find(article => article.id === id);
|
|
19708
|
+
return row ? this.result(row, index) : null;
|
|
19709
|
+
}
|
|
19710
|
+
async visitor(config) {
|
|
19711
|
+
const key = `kb-visitor:${new URL(config.canonical_origin).host}:${this.deskId}`;
|
|
19712
|
+
try {
|
|
19713
|
+
const saved = JSON.parse(globalThis.localStorage.getItem(key) ?? 'null');
|
|
19714
|
+
if (currentVisitor(saved))
|
|
19715
|
+
return saved;
|
|
19716
|
+
}
|
|
19717
|
+
catch { /* Storage can be unavailable in an embedded support surface. */ }
|
|
19718
|
+
if (this.visitorSession?.key === key && currentVisitor(this.visitorSession.value))
|
|
19719
|
+
return this.visitorSession.value;
|
|
19720
|
+
if (this.visitorPending?.key === key)
|
|
19721
|
+
return this.visitorPending.pending;
|
|
19722
|
+
const pending = (async () => {
|
|
19723
|
+
const value = await this.request('visitor', { body: { release_id: config.release_id } });
|
|
19724
|
+
if (!currentVisitor(value))
|
|
19725
|
+
throw invalid();
|
|
19726
|
+
this.visitorSession = { key, value };
|
|
19727
|
+
try {
|
|
19728
|
+
globalThis.localStorage.setItem(key, JSON.stringify(value));
|
|
19729
|
+
}
|
|
19730
|
+
catch { /* Keep the visitor in memory when persistence is blocked. */ }
|
|
19731
|
+
return value;
|
|
19732
|
+
})();
|
|
19733
|
+
this.visitorPending = { key, pending };
|
|
19734
|
+
try {
|
|
19735
|
+
return await pending;
|
|
19736
|
+
}
|
|
19737
|
+
finally {
|
|
19738
|
+
if (this.visitorPending?.pending === pending)
|
|
19739
|
+
this.visitorPending = null;
|
|
19740
|
+
}
|
|
19741
|
+
}
|
|
19742
|
+
/** Use the help center's browser visitor and vote receipt; ticket identity is never sent. */
|
|
19743
|
+
async vote(article, vote) {
|
|
19744
|
+
if (article?.kind !== 'article' || typeof article.id !== 'string' || !article.id || article.id.length > 256 || !['yes', 'no'].includes(vote)) {
|
|
19745
|
+
throw new ValidationError('Choose yes or no for a published article.');
|
|
19746
|
+
}
|
|
19747
|
+
const reference = { id: article.id, release_id: article.release_id };
|
|
19748
|
+
const previous = this.voteQueues.get(reference.id) ?? Promise.resolve();
|
|
19749
|
+
const pending = previous.then(() => this.saveVote(reference, vote));
|
|
19750
|
+
// Keep user choices in order even when an earlier vote is slow or fails.
|
|
19751
|
+
// The caller still receives its own failure; the next choice can proceed.
|
|
19752
|
+
const settled = pending.then(() => undefined, () => undefined);
|
|
19753
|
+
this.voteQueues.set(reference.id, settled);
|
|
19754
|
+
void settled.then(() => { if (this.voteQueues.get(reference.id) === settled)
|
|
19755
|
+
this.voteQueues.delete(reference.id); });
|
|
19756
|
+
return pending;
|
|
19757
|
+
}
|
|
19758
|
+
async saveVote(article, vote) {
|
|
19759
|
+
const config = await this.load();
|
|
19760
|
+
if (!config.available)
|
|
19761
|
+
throw new SparkVaultError('This help center is unavailable. Contact support to continue.', 'KB_UNAVAILABLE', 404);
|
|
19762
|
+
if (!config.authorized)
|
|
19763
|
+
throw new SparkVaultError('Sign in to this help center to send feedback.', config.access.mode === 'ip_allowlist' ? 'KB_IP_RESTRICTED' : 'KB_ACCESS_REQUIRED', config.access.mode === 'ip_allowlist' ? 403 : 401);
|
|
19764
|
+
if (config.release_id !== article.release_id)
|
|
19765
|
+
throw changed();
|
|
19766
|
+
const visitor = await this.visitor(config);
|
|
19767
|
+
const value = await this.request({ helpful: article.id }, {
|
|
19768
|
+
body: { visitor_id: visitor.visitor_id, release_id: article.release_id, vote }
|
|
19769
|
+
});
|
|
19770
|
+
if (value?.vote !== vote || !Number.isSafeInteger(value.version) || value.version < 1)
|
|
19771
|
+
throw invalid();
|
|
19772
|
+
let review;
|
|
19773
|
+
try {
|
|
19774
|
+
if (vote === 'yes' && typeof value.review_url === 'string' && value.review_url.length <= 2048) {
|
|
19775
|
+
const url = new URL(value.review_url);
|
|
19776
|
+
if (url.protocol === 'https:' && !url.username && !url.password)
|
|
19777
|
+
review = url;
|
|
19778
|
+
}
|
|
19779
|
+
}
|
|
19780
|
+
catch { /* A malformed review destination must not invalidate an acknowledged vote. */ }
|
|
19781
|
+
return { vote, version: value.version, ...(review && { review_url: review.href }) };
|
|
19782
|
+
}
|
|
19681
19783
|
async read(result) {
|
|
19682
19784
|
const config = await this.load();
|
|
19683
19785
|
if (config.release_id !== result.release_id)
|
|
@@ -20045,20 +20147,20 @@ function injectHelpDeskSupportStyles() {
|
|
|
20045
20147
|
style.id = 'sparkvault-help-desk-support-styles';
|
|
20046
20148
|
style.textContent = `
|
|
20047
20149
|
.svhs-panel,.svhs-panel *{box-sizing:border-box}
|
|
20048
|
-
.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:
|
|
20150
|
+
.svhs-panel{position:fixed;right:calc(var(--svhs-right,24px) + env(safe-area-inset-right,0px));bottom:calc(var(--svhs-bottom,96px) + env(safe-area-inset-bottom,0px));z-index:2147482900;width:408px;height:422px;max-width:calc(100vw - 32px);max-height:calc(100dvh - var(--svhs-bottom,96px) - 24px);display:flex;flex-direction:column;overflow:hidden;border:1px solid ${DS.slate200};border-radius:12px;background:${DS.white};color:${DS.slate900};font:400 15px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue',sans-serif;text-align:left;box-shadow:${DS.shadowPopover};transform-origin:bottom right;transition:width 180ms cubic-bezier(.2,0,0,1),height 180ms cubic-bezier(.2,0,0,1)}
|
|
20049
20151
|
.svhs-panel[hidden],.svhs-panel [hidden]{display:none!important}
|
|
20050
20152
|
.svhs-panel[data-stage=results]{height:680px}
|
|
20051
20153
|
.svhs-panel[data-stage=article]{width:704px;height:700px}
|
|
20052
|
-
.svhs-panel[data-stage=feedback]{height:358px}
|
|
20154
|
+
.svhs-panel[data-stage=feedback],.svhs-panel[data-stage=resolved]{height:358px}
|
|
20053
20155
|
.svhs-panel[data-stage=contact]{height:720px}
|
|
20054
20156
|
.svhs-panel[data-stage=receipt]{height:430px}
|
|
20055
20157
|
.svhs-panel button,.svhs-panel input,.svhs-panel textarea{font:inherit;letter-spacing:normal;text-transform:none}
|
|
20056
20158
|
.svhs-panel button,.svhs-panel a{touch-action:manipulation;-webkit-tap-highlight-color:transparent}
|
|
20057
20159
|
.svhs-panel button{appearance:none;cursor:pointer;margin:0}
|
|
20058
20160
|
.svhs-panel button:active{transform:translateY(1px)}
|
|
20059
|
-
.svhs-panel button:focus-visible,.svhs-panel a:focus-visible,.svhs-panel input:focus-visible,.svhs-panel textarea:focus-visible{outline:2px solid
|
|
20161
|
+
.svhs-panel button:focus-visible,.svhs-panel a:focus-visible,.svhs-panel input:focus-visible,.svhs-panel textarea:focus-visible{outline:2px solid var(--hd-focus,var(--hd-accent-ink,${DS.action}));outline-offset:3px;box-shadow:none}
|
|
20060
20162
|
.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}
|
|
20061
|
-
.svhs-toolbar{display:flex;align-items:center;justify-content:space-between;gap:
|
|
20163
|
+
.svhs-toolbar{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:60px;flex:none;padding:8px 14px 8px 24px;border-bottom:1px solid ${DS.slate200}}
|
|
20062
20164
|
.svhs-desk-name{font-size:14px;font-weight:600;line-height:1.35;color:${DS.slate600};overflow-wrap:anywhere;min-width:0}
|
|
20063
20165
|
.svhs-toolbar-actions{display:flex;align-items:center;gap:4px;margin-left:auto;flex:none}
|
|
20064
20166
|
.svhs-identity-notice{display:flex;align-items:center;justify-content:space-between;gap:8px;flex:none;padding:8px 24px;border-bottom:1px solid ${DS.slate200};background:${DS.slate50}}
|
|
@@ -20071,36 +20173,45 @@ function injectHelpDeskSupportStyles() {
|
|
|
20071
20173
|
.svhs-back:disabled{background:transparent;color:${DS.slate500};cursor:default;transform:none}
|
|
20072
20174
|
.svhs-screen{display:flex;flex-direction:column;min-height:0;flex:1}
|
|
20073
20175
|
.svhs-scroll{padding:26px 24px;overflow:auto;overscroll-behavior:contain;min-height:0;flex:1;scrollbar-gutter:stable}
|
|
20074
|
-
.svhs-heading{margin:0 0
|
|
20075
|
-
.svhs-heading:focus,.svhs-article-title:focus{outline:none}
|
|
20076
|
-
.svhs-copy{margin:0 0
|
|
20176
|
+
.svhs-heading{margin:0 0 8px;padding:0;color:${DS.slate900};font-size:24px;font-weight:600;line-height:1.3;letter-spacing:-.6px;overflow-wrap:anywhere}
|
|
20177
|
+
.svhs-heading:focus,.svhs-article-title:focus{outline:none;box-shadow:none}
|
|
20178
|
+
.svhs-copy{margin:0 0 24px;color:${DS.slate600};font-size:14px;line-height:1.55}
|
|
20077
20179
|
.svhs-label{display:block;margin:0 0 7px;font-size:13px;font-weight:600;color:${DS.slate600}}
|
|
20078
|
-
.svhs-issue{display:block;width:100%;min-height:
|
|
20180
|
+
.svhs-issue{display:block;width:100%;min-height:120px;max-height:200px;resize:none;overflow-y:auto;border:1px solid ${DS.slate300};border-radius:8px;padding:12px 14px;background:${DS.white};color:${DS.slate900};font-size:16px!important;line-height:1.5!important;box-shadow:none}
|
|
20079
20181
|
.svhs-issue::placeholder{color:${DS.slate500};opacity:1}
|
|
20080
|
-
.svhs-issue:focus{border-color
|
|
20182
|
+
.svhs-issue:focus{border-color:var(--hd-focus,var(--hd-accent-ink,${DS.action}))}
|
|
20081
20183
|
.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)}
|
|
20082
|
-
.svhs-primary{background
|
|
20083
|
-
.svhs-primary:hover{background
|
|
20184
|
+
.svhs-primary{background:var(--hd-accent,${DS.action});color:var(--hd-on-accent,${DS.white})}
|
|
20185
|
+
.svhs-primary:hover{background:var(--hd-accent-hover,${DS.actionHover})}
|
|
20084
20186
|
.svhs-primary[aria-disabled=true]{cursor:progress}
|
|
20085
20187
|
.svhs-secondary{border-color:${DS.slate300};background:${DS.white};color:${DS.slate600}}
|
|
20086
20188
|
.svhs-secondary:hover{background:${DS.slate50}}
|
|
20087
|
-
.svhs-text-button{display:inline-flex;align-items:center;justify-content:center;min-height:44px;padding:9px 4px;border:0;border-radius:6px;background:transparent;color
|
|
20189
|
+
.svhs-text-button{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:44px;padding:9px 4px;border:0;border-radius:6px;background:transparent;color:var(--hd-accent-ink,${DS.action});font-size:14px!important;line-height:1.4!important;text-decoration:none}
|
|
20088
20190
|
.svhs-text-button:hover{text-decoration:underline}
|
|
20089
20191
|
.svhs-full{width:100%}
|
|
20090
20192
|
.svhs-bottom{padding:16px 24px 18px;flex:none;border-top:1px solid ${DS.slate100}}
|
|
20091
20193
|
.svhs-start-bottom{display:flex;flex-direction:column;align-items:center;gap:6px;padding-top:0;border-top:0}
|
|
20092
20194
|
.svhs-start-bottom .svhs-primary{width:100%}
|
|
20093
|
-
.svhs-query{display:flex;align-items:
|
|
20094
|
-
.svhs-
|
|
20095
|
-
.svhs-
|
|
20195
|
+
.svhs-query{display:flex;align-items:center;gap:12px;margin:0 0 24px;padding:12px 14px;border:1px solid ${DS.slate200};border-radius:8px;background:${DS.slate50}}
|
|
20196
|
+
.svhs-question{flex:1;min-width:0}
|
|
20197
|
+
.svhs-question-label{display:block;margin-bottom:3px;color:${DS.slate500};font-size:12px;font-weight:500;line-height:1.4}
|
|
20198
|
+
.svhs-query-text{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;margin:0;color:${DS.slate900};font-size:14px;line-height:1.5;overflow-wrap:anywhere;white-space:pre-wrap}
|
|
20199
|
+
.svhs-query .svhs-text-button{flex:none;min-width:44px;padding:8px 0}
|
|
20096
20200
|
.svhs-results{display:flex;flex-direction:column;margin:0;padding:0;list-style:none}
|
|
20097
|
-
.svhs-result{display:
|
|
20201
|
+
.svhs-result{display:grid;grid-template-columns:24px minmax(0,1fr) 16px;align-items:start;gap:12px;width:100%;padding:18px 0;border:0;border-bottom:1px solid ${DS.slate200};border-radius:0;background:${DS.white};color:${DS.slate900};text-align:left}
|
|
20202
|
+
.svhs-results li:first-child .svhs-result{border-top:1px solid ${DS.slate200}}
|
|
20098
20203
|
.svhs-results li:last-child .svhs-result{border-bottom:0}
|
|
20099
|
-
.svhs-result-
|
|
20100
|
-
.svhs-result
|
|
20101
|
-
.svhs-result-
|
|
20102
|
-
.svhs-result-
|
|
20103
|
-
.svhs-
|
|
20204
|
+
.svhs-result-copy{display:block;min-width:0}
|
|
20205
|
+
.svhs-result-icon{margin-top:2px;color:${DS.slate500}}
|
|
20206
|
+
.svhs-result-chevron{width:16px!important;height:16px!important;margin-top:4px;color:${DS.slate500}}
|
|
20207
|
+
.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}
|
|
20208
|
+
.svhs-result:hover{background:${DS.slate50}}
|
|
20209
|
+
.svhs-result:hover .svhs-result-title{color:var(--hd-accent-ink,${DS.action});text-decoration:underline}
|
|
20210
|
+
.svhs-result-excerpt{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;margin:0;color:${DS.slate600};font-size:14px;line-height:1.5;overflow-wrap:anywhere}
|
|
20211
|
+
.svhs-result-category{display:block;margin-top:6px;color:${DS.slate500};font-size:12px;line-height:1.4}
|
|
20212
|
+
.svhs-results-bottom{background:${DS.slate50};border-top-color:${DS.slate200}}
|
|
20213
|
+
.svhs-footer-title{margin:0 0 3px;color:${DS.slate900};font-size:14px;font-weight:600;line-height:1.5}
|
|
20214
|
+
.svhs-footer-copy{margin:0 0 14px;color:${DS.slate600};font-size:13px;line-height:1.5}
|
|
20104
20215
|
.svhs-error{margin:12px 0 0;color:${DS.error};font-size:14px;line-height:1.5;overflow-wrap:anywhere}
|
|
20105
20216
|
.svhs-status{margin:16px 0;color:${DS.slate600};font-size:14px;line-height:1.5}
|
|
20106
20217
|
.svhs-empty{padding:12px 0 4px}
|
|
@@ -20118,7 +20229,7 @@ function injectHelpDeskSupportStyles() {
|
|
|
20118
20229
|
.svhs-article-content ul,.svhs-article-content ol{margin:0 0 22px;padding-left:22px}
|
|
20119
20230
|
.svhs-article-content li{margin:8px 0;padding-left:5px}
|
|
20120
20231
|
.svhs-article-content strong{font-weight:600;color:${DS.slate900}}
|
|
20121
|
-
.svhs-article-content a{color
|
|
20232
|
+
.svhs-article-content a{color:var(--hd-accent-ink,${DS.action});text-decoration:underline;text-underline-offset:2px}
|
|
20122
20233
|
.svhs-article-content img,.svhs-article-content video{display:block;max-width:100%;height:auto;margin:20px 0}
|
|
20123
20234
|
.svhs-reader-asset{display:block;max-width:100%;margin:20px 0}
|
|
20124
20235
|
.svhs-reader-asset img{margin:0}
|
|
@@ -20138,6 +20249,8 @@ function injectHelpDeskSupportStyles() {
|
|
|
20138
20249
|
.svhs-feedback-scroll{padding-top:30px}
|
|
20139
20250
|
.svhs-feedback-actions{display:flex;flex-direction:column;gap:9px;margin-top:24px}
|
|
20140
20251
|
.svhs-feedback-actions .svhs-text-button{align-self:center;color:${DS.slate500}}
|
|
20252
|
+
.svhs-review{margin-top:24px}
|
|
20253
|
+
.svhs-review .svhs-primary{width:fit-content}
|
|
20141
20254
|
.svhs-contact-scroll{padding:0;scrollbar-gutter:auto}
|
|
20142
20255
|
.svhs-contact-target{display:flex;flex-direction:column;min-height:100%}
|
|
20143
20256
|
.svhs-contact-target:empty{display:none;min-height:0}
|
|
@@ -20145,7 +20258,7 @@ function injectHelpDeskSupportStyles() {
|
|
|
20145
20258
|
.svhs-contact-prelude .svhs-secondary{margin-top:16px}
|
|
20146
20259
|
.svhs-ticket-gate{padding:0 24px 24px}
|
|
20147
20260
|
.svhs-unlock-input{display:block;box-sizing:border-box;width:100%;min-height:46px;margin:0 0 16px;border:1px solid ${DS.slate300};border-radius:6px;padding:11px 12px;background:${DS.white};color:${DS.slate900};font-size:16px!important;line-height:1.5!important}
|
|
20148
|
-
.svhs-unlock-input:focus{border-color
|
|
20261
|
+
.svhs-unlock-input:focus{border-color:var(--hd-focus,var(--hd-accent-ink,${DS.action}))}
|
|
20149
20262
|
.svhs-unlock-form{margin:0}
|
|
20150
20263
|
.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}
|
|
20151
20264
|
.svhs-contact-target .svhd-body{display:flex;flex:1;flex-direction:column;min-height:0}
|
|
@@ -20155,6 +20268,9 @@ function injectHelpDeskSupportStyles() {
|
|
|
20155
20268
|
.svhs-contact-target .svhd-input{font-size:16px;line-height:1.5}
|
|
20156
20269
|
.svhs-contact-target .svhd-description{min-height:138px}
|
|
20157
20270
|
.svhs-contact-target .svhd-actions{gap:10px}
|
|
20271
|
+
.svhs-contact-target .svhd-button:not(.svhd-secondary){background:var(--hd-accent,${DS.action});color:var(--hd-on-accent,${DS.white})}
|
|
20272
|
+
.svhs-contact-target .svhd-button:not(.svhd-secondary):hover{background:var(--hd-accent-hover,${DS.actionHover})}
|
|
20273
|
+
.svhs-contact-target .svhd-link{color:var(--hd-accent-ink,${DS.action})}
|
|
20158
20274
|
.svhs-contact-target .svhd-actions>.svhd-button:first-child{flex:1}
|
|
20159
20275
|
.svhs-contact-target .svhd-status{font-size:14px}
|
|
20160
20276
|
.svhs-contact-target .svhd-auth{gap:14px}
|
|
@@ -20162,9 +20278,9 @@ function injectHelpDeskSupportStyles() {
|
|
|
20162
20278
|
.svhs-contact-target .svhd-widget-identity{display:flex;flex:1;min-width:0;flex-direction:column;gap:2px;margin:0;line-height:1.4;overflow-wrap:anywhere}
|
|
20163
20279
|
.svhs-contact-target .svhd-widget-identity strong{color:${DS.slate900};font-size:14px;font-weight:600}
|
|
20164
20280
|
.svhs-contact-target .svhd-widget-identity span{color:${DS.slate500};font-size:13px}
|
|
20165
|
-
.svhs-contact-target .svhd-widget-account-link{display:inline-flex;align-items:center;justify-content:center;min-height:44px;max-width:100%;padding:8px 0;border:0;border-radius:6px;background:transparent;color
|
|
20281
|
+
.svhs-contact-target .svhd-widget-account-link{display:inline-flex;align-items:center;justify-content:center;min-height:44px;max-width:100%;padding:8px 0;border:0;border-radius:6px;background:transparent;color:var(--hd-accent-ink,${DS.action});font-size:13px;line-height:1.4}
|
|
20166
20282
|
.svhs-contact-target .svhd-widget-account-link:hover{text-decoration:underline}
|
|
20167
|
-
.svhs-contact-target .svhd-widget-account-link:focus-visible{outline:2px solid
|
|
20283
|
+
.svhs-contact-target .svhd-widget-account-link:focus-visible{outline:2px solid var(--hd-focus,var(--hd-accent-ink,${DS.action}));outline-offset:3px}
|
|
20168
20284
|
.svhs-contact-target .svhd-widget-account-link:disabled{cursor:progress;color:${DS.slate500}}
|
|
20169
20285
|
.svhs-contact-target .svhd-widget-names{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:12px}
|
|
20170
20286
|
.svhs-contact-target .svhd-widget-form{display:flex;flex:1;flex-direction:column;gap:16px}
|
|
@@ -20178,8 +20294,8 @@ function injectHelpDeskSupportStyles() {
|
|
|
20178
20294
|
.svhs-contact-target .svhd-widget-form>.svhd-confirm .svhd-button{flex:1}
|
|
20179
20295
|
.svhs-contact-target .svhd-footer{margin-top:16px;text-align:center;font-size:11px}
|
|
20180
20296
|
.svhs-receipt-scroll{padding-top:36px}
|
|
20181
|
-
.svhs-receipt-mark{width:30px!important;height:30px!important;margin-bottom:20px;color
|
|
20182
|
-
.svhs-ticket-link{display:inline-flex;align-items:center;min-height:44px;margin:0 0 10px;color
|
|
20297
|
+
.svhs-receipt-mark{width:30px!important;height:30px!important;margin-bottom:20px;color:var(--hd-accent-ink,${DS.action})}
|
|
20298
|
+
.svhs-ticket-link{display:inline-flex;align-items:center;min-height:44px;margin:0 0 10px;color:var(--hd-accent-ink,${DS.action});font-size:14px;font-weight:600;text-decoration:underline}
|
|
20183
20299
|
.svhs-receipt-note{white-space:pre-wrap;overflow-wrap:anywhere}
|
|
20184
20300
|
.svhs-receipt-actions{display:flex;flex-direction:column;align-items:center;gap:4px}
|
|
20185
20301
|
.svhs-live{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
|
|
@@ -20191,30 +20307,28 @@ function injectHelpDeskSupportStyles() {
|
|
|
20191
20307
|
.sv-support-launcher{touch-action:manipulation;-webkit-tap-highlight-color:transparent;transition:background 120ms cubic-bezier(.2,0,0,1)}
|
|
20192
20308
|
.sv-support-launcher:hover{filter:brightness(1.12)}
|
|
20193
20309
|
.sv-support-launcher:active{transform:translateY(1px)}
|
|
20194
|
-
.sv-support-launcher:focus-visible{outline:3px solid
|
|
20310
|
+
.sv-support-launcher:focus-visible{outline:3px solid var(--hd-accent-ink,${DS.action});outline-offset:3px}
|
|
20195
20311
|
@media(max-width:640px){
|
|
20196
20312
|
.svhs-panel{right:0;bottom:0;width:100%;height:100dvh;max-width:none;max-height:none;border:0;border-radius:0}
|
|
20197
|
-
.svhs-toolbar{min-height:
|
|
20313
|
+
.svhs-toolbar{min-height:60px;padding:8px 16px 8px 24px;border-bottom-color:${DS.slate200}}
|
|
20198
20314
|
.svhs-icon-button{width:44px;height:44px}
|
|
20199
20315
|
.svhs-back{min-height:44px;max-width:42%}
|
|
20200
|
-
.svhs-scroll{padding:
|
|
20201
|
-
.svhs-heading{font-size:
|
|
20202
|
-
.svhs-issue{min-height:
|
|
20316
|
+
.svhs-scroll{padding:24px}
|
|
20317
|
+
.svhs-heading{font-size:24px}
|
|
20318
|
+
.svhs-issue{min-height:140px;max-height:260px}
|
|
20203
20319
|
.svhs-bottom{padding-bottom:calc(20px + env(safe-area-inset-bottom))}
|
|
20204
20320
|
.svhs-start-bottom{margin-top:0}
|
|
20205
20321
|
.svhs-panel[data-stage=issue] .svhs-scroll{flex:0}
|
|
20206
20322
|
.svhs-query .svhs-text-button{min-height:44px;min-width:44px}
|
|
20207
|
-
.svhs-query-text{font-size:
|
|
20208
|
-
.svhs-result{padding:
|
|
20209
|
-
.svhs-result-title{font-size:17px}
|
|
20210
|
-
.svhs-result-excerpt{font-size:14px}
|
|
20323
|
+
.svhs-query-text{font-size:14px}
|
|
20324
|
+
.svhs-result{padding:16px 0;gap:10px}
|
|
20211
20325
|
.svhs-article-scroll{padding:32px 25px}
|
|
20212
20326
|
.svhs-article-title{font-size:28px}
|
|
20213
20327
|
.svhs-article-content{font-size:16px}
|
|
20214
|
-
.svhs-article-footer{align-items:stretch;padding:
|
|
20215
|
-
.svhs-article-question{display:
|
|
20216
|
-
.svhs-reader-actions{
|
|
20217
|
-
.svhs-article-footer .svhs-primary,.svhs-article-footer .svhs-text-button{
|
|
20328
|
+
.svhs-article-footer{flex-direction:column;align-items:stretch;gap:10px;padding:16px 24px calc(12px + env(safe-area-inset-bottom))}
|
|
20329
|
+
.svhs-article-question{display:block}
|
|
20330
|
+
.svhs-reader-actions{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.3fr);gap:12px;width:100%}
|
|
20331
|
+
.svhs-article-footer .svhs-primary,.svhs-article-footer .svhs-text-button{min-width:0;min-height:48px;font-size:14px!important;white-space:normal}
|
|
20218
20332
|
.svhs-feedback-scroll{padding-top:50px}
|
|
20219
20333
|
.svhs-feedback-actions{margin-top:30px}
|
|
20220
20334
|
.svhs-feedback-actions .svhs-primary,.svhs-feedback-actions .svhs-secondary{min-height:48px}
|
|
@@ -20229,12 +20343,37 @@ function injectHelpDeskSupportStyles() {
|
|
|
20229
20343
|
@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}}
|
|
20230
20344
|
@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}}
|
|
20231
20345
|
@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}}
|
|
20232
|
-
.svhs-panel.svhs-page{position:static;inset:auto;z-index:auto;width:100%;height:auto;max-width:
|
|
20346
|
+
.svhs-panel.svhs-page{position:static;inset:auto;z-index:auto;width:100%;height:auto;max-width:720px;max-height:none;margin:0 auto;border:1px solid ${DS.slate200};border-radius:12px;box-shadow:none;transition:none}
|
|
20347
|
+
.svhs-page .svhs-toolbar{min-height:52px;padding:4px 24px}
|
|
20348
|
+
.svhs-page .svhs-back{max-width:none;white-space:nowrap}
|
|
20349
|
+
.svhs-page .svhs-desk-name{display:none}
|
|
20350
|
+
.svhs-page[data-stage=issue] .svhs-toolbar,.svhs-page[data-stage=resolved] .svhs-toolbar,.svhs-page[data-stage=receipt] .svhs-toolbar{display:none}
|
|
20233
20351
|
.svhs-page .svhs-screen{flex:none}
|
|
20234
|
-
.svhs-page .svhs-scroll{flex:none;overflow:visible;overscroll-behavior:auto;scrollbar-gutter:auto}
|
|
20352
|
+
.svhs-page .svhs-scroll{flex:none;padding:28px 32px;overflow:visible;overscroll-behavior:auto;scrollbar-gutter:auto}
|
|
20353
|
+
.svhs-page .svhs-bottom{padding:20px 32px 24px}
|
|
20354
|
+
.svhs-page .svhs-start-bottom{padding-top:0;align-items:flex-start}
|
|
20355
|
+
.svhs-page .svhs-start-bottom .svhs-primary{width:auto;min-width:160px}
|
|
20356
|
+
.svhs-page[data-stage=issue] .svhs-heading{font-size:28px}
|
|
20357
|
+
.svhs-page .svhs-results-bottom{display:flex;align-items:center;gap:24px}
|
|
20358
|
+
.svhs-page .svhs-results-bottom[hidden]{display:none}
|
|
20359
|
+
.svhs-page .svhs-escalation{flex:1;min-width:0}
|
|
20360
|
+
.svhs-page .svhs-footer-copy{margin:0}
|
|
20361
|
+
.svhs-page .svhs-results-bottom .svhs-secondary{width:auto;flex:none}
|
|
20235
20362
|
.svhs-page .svhs-contact-target,.svhs-page .svhs-contact-target>.svhd-container{min-height:0}
|
|
20363
|
+
.svhs-page .svhs-contact-scroll{padding:0}
|
|
20236
20364
|
.svhs-page .svhd-widget-form>.svhd-actions{position:static;margin:0;padding:16px 0 0}
|
|
20237
20365
|
.svhs-page .svhd-widget-form>.svhd-actions>.svhd-secondary{display:inline-flex}
|
|
20366
|
+
@media(max-width:640px){
|
|
20367
|
+
.svhs-page .svhs-toolbar{padding:4px 20px}
|
|
20368
|
+
.svhs-page .svhs-scroll{padding:24px 20px}
|
|
20369
|
+
.svhs-page .svhs-bottom{padding:20px}
|
|
20370
|
+
.svhs-page .svhs-start-bottom{padding-top:0}
|
|
20371
|
+
.svhs-page .svhs-start-bottom .svhs-primary{width:100%}
|
|
20372
|
+
.svhs-page[data-stage=issue] .svhs-heading{font-size:26px}
|
|
20373
|
+
.svhs-page .svhs-results-bottom{display:block}
|
|
20374
|
+
.svhs-page .svhs-results-bottom .svhs-secondary{width:100%;margin-top:14px}
|
|
20375
|
+
.svhs-page .svhs-contact-scroll{padding:0}
|
|
20376
|
+
}
|
|
20238
20377
|
`;
|
|
20239
20378
|
document.head.appendChild(style);
|
|
20240
20379
|
}
|
|
@@ -20406,6 +20545,149 @@ class SupportPhoneHistory {
|
|
|
20406
20545
|
}
|
|
20407
20546
|
}
|
|
20408
20547
|
|
|
20548
|
+
/**
|
|
20549
|
+
* A tenant's brand color and the WCAG contrast rules that decide how it may be
|
|
20550
|
+
* used: the one hex rule the server stores, the console checks and the portal
|
|
20551
|
+
* paints, the one contrast reading the console's readouts and the portal's
|
|
20552
|
+
* accent share, and the one way a readout writes that reading.
|
|
20553
|
+
*
|
|
20554
|
+
* A brand color is tenant-controlled, so it is used only when it is a
|
|
20555
|
+
* six-digit hex color, read case-insensitively and held in lowercase; anything
|
|
20556
|
+
* else (a color name, a CSS function, a value that runs on into more CSS) is
|
|
20557
|
+
* no color at all.
|
|
20558
|
+
*
|
|
20559
|
+
* A brand color can be any lightness, so whatever shows it picks what goes
|
|
20560
|
+
* with it: white or ink as the text on its fill, whichever reads more
|
|
20561
|
+
* strongly (at least 4.2:1 on any fill, as far as two inks reach on a
|
|
20562
|
+
* mid-tone), and the color itself as text only where it reaches 4.5:1 on
|
|
20563
|
+
* both grounds accent text stands on, the white surface and the canvas
|
|
20564
|
+
* tone, ink otherwise. accentProperties says that as the accent
|
|
20565
|
+
* custom properties the customer portal paints with and the console's sample
|
|
20566
|
+
* of it shows, in the design system's own tokens.
|
|
20567
|
+
*
|
|
20568
|
+
* BROWSER-SAFE: data only, no imports.
|
|
20569
|
+
*/
|
|
20570
|
+
|
|
20571
|
+
const HEX_COLOR = /^#[0-9a-f]{6}$/;
|
|
20572
|
+
|
|
20573
|
+
/** WCAG AA's floor for normal-size text. */
|
|
20574
|
+
const AA_TEXT_CONTRAST = 4.5;
|
|
20575
|
+
|
|
20576
|
+
/**
|
|
20577
|
+
* The canvas tone, the design system's `--canvas` (`--color-slate-50`): the
|
|
20578
|
+
* page ground the customer portal (its pages and a customer's own messages)
|
|
20579
|
+
* and the knowledge base's default theme set accent text on, beside the white
|
|
20580
|
+
* surface. The design system publishes its tokens only as CSS, which this
|
|
20581
|
+
* import-free module cannot read, so the value is mirrored here once, and
|
|
20582
|
+
* tests/brand-color.test.js holds it to packages/design-system/tokens/colors.css.
|
|
20583
|
+
*/
|
|
20584
|
+
const CANVAS_COLOR = '#f7fafb';
|
|
20585
|
+
|
|
20586
|
+
/**
|
|
20587
|
+
* The ink, the design system's `--ink` (`--color-slate-900`): the dark text a
|
|
20588
|
+
* pairing paints on a fill and in place of a color too light to stand as
|
|
20589
|
+
* text. Mirrored here once for the same reason as CANVAS_COLOR, and held to
|
|
20590
|
+
* packages/design-system/tokens/colors.css by tests/brand-color.test.js.
|
|
20591
|
+
*/
|
|
20592
|
+
const INK_COLOR = '#0d1a20';
|
|
20593
|
+
|
|
20594
|
+
/** Relative luminance (WCAG 2) of a validated `#rrggbb` color. */
|
|
20595
|
+
function relativeLuminance(color) {
|
|
20596
|
+
const [red, green, blue] = [1, 3, 5].map((offset) => {
|
|
20597
|
+
const channel = Number.parseInt(color.slice(offset, offset + 2), 16) / 255;
|
|
20598
|
+
return channel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4;
|
|
20599
|
+
});
|
|
20600
|
+
return 0.2126 * red + 0.7152 * green + 0.0722 * blue;
|
|
20601
|
+
}
|
|
20602
|
+
|
|
20603
|
+
/** The contrast ratio of two relative luminances. */
|
|
20604
|
+
function contrastRatio(first, second) {
|
|
20605
|
+
return (Math.max(first, second) + 0.05) / (Math.min(first, second) + 0.05);
|
|
20606
|
+
}
|
|
20607
|
+
|
|
20608
|
+
/** The relative luminance of the ink a fill's text is weighed in, the real ink rather than pure black. */
|
|
20609
|
+
const INK_LUMINANCE = relativeLuminance(INK_COLOR);
|
|
20610
|
+
|
|
20611
|
+
/** The relative luminances of the grounds accent text stands on: the white surface and the canvas tone. */
|
|
20612
|
+
const TEXT_GROUNDS = Object.freeze([1, relativeLuminance(CANVAS_COLOR)]);
|
|
20613
|
+
|
|
20614
|
+
/** How strongly a color of this luminance reads as text on the ground it reads least on. */
|
|
20615
|
+
function textContrast(luminance) {
|
|
20616
|
+
return Math.min(...TEXT_GROUNDS.map((ground) => contrastRatio(luminance, ground)));
|
|
20617
|
+
}
|
|
20618
|
+
|
|
20619
|
+
/**
|
|
20620
|
+
* A brand color as it may be stored and shown, or null when the value is not
|
|
20621
|
+
* one: a `#rrggbb` hex value, read case-insensitively.
|
|
20622
|
+
*
|
|
20623
|
+
* @param {unknown} value
|
|
20624
|
+
* @returns {string|null} The color in lowercase
|
|
20625
|
+
*/
|
|
20626
|
+
function brandColor(value) {
|
|
20627
|
+
if (typeof value !== 'string') return null;
|
|
20628
|
+
const color = value.toLowerCase();
|
|
20629
|
+
return HEX_COLOR.test(color) ? color : null;
|
|
20630
|
+
}
|
|
20631
|
+
|
|
20632
|
+
/**
|
|
20633
|
+
* What goes with a brand color: the text on its fill (white or ink,
|
|
20634
|
+
* whichever reads more strongly, at least 4.2:1 on any fill) and the ink for
|
|
20635
|
+
* it as text
|
|
20636
|
+
* (the color itself where it reaches AA_TEXT_CONTRAST on both the white
|
|
20637
|
+
* surface and the canvas tone, ink otherwise).
|
|
20638
|
+
*
|
|
20639
|
+
* @param {unknown} value
|
|
20640
|
+
* @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)
|
|
20641
|
+
*/
|
|
20642
|
+
function accentPairing(value) {
|
|
20643
|
+
const color = brandColor(value);
|
|
20644
|
+
if (!color) return null;
|
|
20645
|
+
const luminance = relativeLuminance(color);
|
|
20646
|
+
const ratio = textContrast(luminance);
|
|
20647
|
+
return {
|
|
20648
|
+
onAccent: contrastRatio(luminance, 1) >= contrastRatio(luminance, INK_LUMINANCE) ? 'white' : 'ink',
|
|
20649
|
+
accentInk: ratio >= AA_TEXT_CONTRAST ? 'accent' : 'ink',
|
|
20650
|
+
ratio
|
|
20651
|
+
};
|
|
20652
|
+
}
|
|
20653
|
+
|
|
20654
|
+
/** Contrast between a brand fill and the label selected by accentPairing. */
|
|
20655
|
+
function accentFillContrast(value) {
|
|
20656
|
+
const color = brandColor(value);
|
|
20657
|
+
if (!color) return null;
|
|
20658
|
+
const pairing = accentPairing(color);
|
|
20659
|
+
return contrastRatio(relativeLuminance(color), pairing.onAccent === 'white' ? 1 : INK_LUMINANCE);
|
|
20660
|
+
}
|
|
20661
|
+
|
|
20662
|
+
/** Darken only the narrow range where neither white nor the product ink reaches AA. */
|
|
20663
|
+
function accessibleFill(color) {
|
|
20664
|
+
let fill = color;
|
|
20665
|
+
while ((accentFillContrast(fill) ?? 0) < AA_TEXT_CONTRAST) {
|
|
20666
|
+
fill = `#${[1, 3, 5].map(offset => Math.floor(Number.parseInt(fill.slice(offset, offset + 2), 16) * 0.98).toString(16).padStart(2, '0')).join('')}`;
|
|
20667
|
+
}
|
|
20668
|
+
return fill;
|
|
20669
|
+
}
|
|
20670
|
+
/** Scoped brand properties work in both a hosted page and an unrelated widget host. */
|
|
20671
|
+
function applySupportBrand(target, value) {
|
|
20672
|
+
const color = brandColor(value);
|
|
20673
|
+
if (!color) {
|
|
20674
|
+
for (const name of ['--hd-accent', '--hd-on-accent', '--hd-accent-ink', '--hd-accent-hover', '--hd-focus'])
|
|
20675
|
+
target.style.removeProperty(name);
|
|
20676
|
+
return;
|
|
20677
|
+
}
|
|
20678
|
+
const fill = accessibleFill(color);
|
|
20679
|
+
const pairing = accentPairing(fill);
|
|
20680
|
+
const ink = pairing.accentInk === 'accent' ? fill : DS.slate900;
|
|
20681
|
+
const label = pairing.onAccent === 'white' ? DS.white : DS.slate900;
|
|
20682
|
+
// Dark fills deepen on hover; light fills stay unchanged to preserve label contrast.
|
|
20683
|
+
const hover = pairing.onAccent === 'white'
|
|
20684
|
+
? `#${[1, 3, 5].map(offset => Math.floor(Number.parseInt(fill.slice(offset, offset + 2), 16) * 0.9).toString(16).padStart(2, '0')).join('')}`
|
|
20685
|
+
: fill;
|
|
20686
|
+
const properties = { '--hd-accent': fill, '--hd-on-accent': label, '--hd-accent-ink': ink, '--hd-accent-hover': hover, '--hd-focus': ink };
|
|
20687
|
+
for (const [name, content] of Object.entries(properties))
|
|
20688
|
+
target.style.setProperty(name, content);
|
|
20689
|
+
}
|
|
20690
|
+
|
|
20409
20691
|
/* global MediaQueryList, HTMLImageElement, HTMLAnchorElement, Element */
|
|
20410
20692
|
let sequence = 0;
|
|
20411
20693
|
function element(tag, className, text) {
|
|
@@ -20432,6 +20714,10 @@ function icon(name) {
|
|
|
20432
20714
|
close: 'm6 6 12 12M18 6 6 18',
|
|
20433
20715
|
external: 'M14 4h6v6m0-6L10 14M11 5H5a1 1 0 0 0-1 1v13a1 1 0 0 0 1 1h13a1 1 0 0 0 1-1v-6',
|
|
20434
20716
|
check: 'm5 12 4 4L19 6',
|
|
20717
|
+
article: 'M14 3H6a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V8Zm0 0v5h5M8 12h8M8 16h6',
|
|
20718
|
+
chevron: 'm9 6 6 6-6 6',
|
|
20719
|
+
thumbUp: 'M7 10v11H3V10Zm0 1 5-8c2 0 3 1 2 4l-1 3h6a2 2 0 0 1 2 2l-2 7a2 2 0 0 1-2 2H7',
|
|
20720
|
+
thumbDown: 'M7 14V3H3v11Zm0-1 5 8c2 0 3-1 2-4l-1-3h6a2 2 0 0 0 2-2l-2-7a2 2 0 0 0-2-2H7',
|
|
20435
20721
|
}[name]);
|
|
20436
20722
|
svg.append(path);
|
|
20437
20723
|
return svg;
|
|
@@ -20481,6 +20767,11 @@ class SupportView {
|
|
|
20481
20767
|
this.articleStatus = element('p', 'svhs-status');
|
|
20482
20768
|
this.articleError = element('p', 'svhs-error');
|
|
20483
20769
|
this.articleFooter = element('div', 'svhs-article-footer');
|
|
20770
|
+
this.feedbackStatus = element('p', 'svhs-status');
|
|
20771
|
+
this.feedbackError = element('p', 'svhs-error');
|
|
20772
|
+
this.reviewPrompt = element('div', 'svhs-review');
|
|
20773
|
+
this.reviewLink = element('a', 'svhs-primary');
|
|
20774
|
+
this.sourceArticle = element('p', 'svhs-copy');
|
|
20484
20775
|
this.contactTitle = element('h2', 'svhs-heading');
|
|
20485
20776
|
this.contactStatus = element('p', 'svhs-status');
|
|
20486
20777
|
this.contactError = element('p', 'svhs-error');
|
|
@@ -20536,12 +20827,12 @@ class SupportView {
|
|
|
20536
20827
|
this.identityNotice.hidden = true;
|
|
20537
20828
|
this.panel.append(this.identityNotice);
|
|
20538
20829
|
const intro = this.screen('issue', 'How can we help?');
|
|
20539
|
-
intro.append(element('p', 'svhs-copy', '
|
|
20540
|
-
const issueLabel = element('label', 'svhs-
|
|
20830
|
+
intro.append(element('p', 'svhs-copy', 'Describe your question or issue.'));
|
|
20831
|
+
const issueLabel = element('label', 'svhs-label', 'What’s your question?');
|
|
20541
20832
|
issueLabel.htmlFor = `${this.prefix}-issue`;
|
|
20542
20833
|
this.issue.id = issueLabel.htmlFor;
|
|
20543
20834
|
this.issue.name = 'support_issue';
|
|
20544
|
-
this.issue.placeholder = 'Describe
|
|
20835
|
+
this.issue.placeholder = 'Describe what you need help with…';
|
|
20545
20836
|
this.issue.autocomplete = 'off';
|
|
20546
20837
|
this.issue.setAttribute('aria-describedby', `${this.prefix}-issue-error`);
|
|
20547
20838
|
this.issueError.id = `${this.prefix}-issue-error`;
|
|
@@ -20560,17 +20851,28 @@ class SupportView {
|
|
|
20560
20851
|
}
|
|
20561
20852
|
});
|
|
20562
20853
|
intro.append(issueLabel, this.issue, this.issueError);
|
|
20563
|
-
this.find = button('svhs-primary', '
|
|
20564
|
-
this.footer('issue', 'svhs-start-bottom').append(this.find
|
|
20565
|
-
const results = this.screen('results', 'These may help');
|
|
20854
|
+
this.find = button('svhs-primary', 'Continue', () => this.search());
|
|
20855
|
+
this.footer('issue', 'svhs-start-bottom').append(this.find);
|
|
20856
|
+
const results = this.screen('results', 'These articles may help');
|
|
20566
20857
|
const queryLine = element('div', 'svhs-query');
|
|
20567
|
-
|
|
20568
|
-
|
|
20858
|
+
const question = element('div', 'svhs-question');
|
|
20859
|
+
question.append(element('span', 'svhs-question-label', 'Your question'), this.query);
|
|
20860
|
+
const editQuestion = button('svhs-text-button', 'Edit', () => this.actions.onBack());
|
|
20861
|
+
editQuestion.setAttribute('aria-label', 'Edit your question');
|
|
20862
|
+
queryLine.append(question, editQuestion);
|
|
20863
|
+
results.prepend(queryLine);
|
|
20864
|
+
results.append(this.resultCopy, this.resultList, this.resultStatus, this.resultError);
|
|
20569
20865
|
this.resultError.setAttribute('role', 'alert');
|
|
20570
|
-
this.contactResults = button('svhs-secondary svhs-full', '
|
|
20571
|
-
|
|
20866
|
+
this.contactResults = button('svhs-secondary svhs-full', 'Create a support ticket', () => {
|
|
20867
|
+
if (this.state?.busy)
|
|
20868
|
+
return;
|
|
20869
|
+
this.actions.onContact(['locked', 'unavailable'].includes(this.state?.kbState || '') ? 'direct' : this.state?.results?.length ? 'none_match' : 'no_results');
|
|
20572
20870
|
});
|
|
20573
|
-
this.footer('results')
|
|
20871
|
+
this.resultsFooter = this.footer('results');
|
|
20872
|
+
this.resultsFooter.classList.add('svhs-results-bottom');
|
|
20873
|
+
const escalation = element('div', 'svhs-escalation');
|
|
20874
|
+
escalation.append(element('p', 'svhs-footer-title', 'Still need help?'), element('p', 'svhs-footer-copy', 'Send your question to our support team.'));
|
|
20875
|
+
this.resultsFooter.append(escalation, this.contactResults);
|
|
20574
20876
|
const article = this.screen('article');
|
|
20575
20877
|
article.classList.add('svhs-article-scroll');
|
|
20576
20878
|
this.articleTitle.tabIndex = -1;
|
|
@@ -20582,18 +20884,37 @@ class SupportView {
|
|
|
20582
20884
|
article.append(this.articleCategory, this.articleTitle, this.articleStatus, this.articleContent, this.articleError, this.articleRetry);
|
|
20583
20885
|
this.articleContent.addEventListener('click', (event) => this.articleLink(event));
|
|
20584
20886
|
const readerActions = element('div', 'svhs-reader-actions');
|
|
20585
|
-
|
|
20586
|
-
this.actions.onAnswered(); })
|
|
20587
|
-
|
|
20887
|
+
const yes = button('svhs-primary', 'Yes', () => { if (this.state?.article && !this.state.busy && !this.state.error)
|
|
20888
|
+
this.actions.onAnswered(); });
|
|
20889
|
+
yes.prepend(icon('thumbUp'));
|
|
20890
|
+
const no = button('svhs-text-button', 'No, create a ticket', () => this.actions.onContact('article_not_answered'));
|
|
20891
|
+
no.prepend(icon('thumbDown'));
|
|
20892
|
+
readerActions.append(yes, no);
|
|
20893
|
+
this.articleFooter.append(element('span', 'svhs-article-question', 'Did this resolve your question?'), readerActions);
|
|
20588
20894
|
this.screens.get('article').append(this.articleFooter);
|
|
20589
|
-
const feedback = this.screen('feedback', 'Did this
|
|
20895
|
+
const feedback = this.screen('feedback', 'Did this resolve your question?');
|
|
20590
20896
|
feedback.classList.add('svhs-feedback-scroll');
|
|
20591
20897
|
feedback.append(element('p', 'svhs-copy', 'Your feedback helps us improve our help articles.'));
|
|
20592
20898
|
const feedbackActions = element('div', 'svhs-feedback-actions');
|
|
20593
|
-
feedbackActions.append(button('svhs-primary', 'Yes
|
|
20899
|
+
feedbackActions.append(button('svhs-primary', 'Yes', () => this.actions.onAnswered()), button('svhs-secondary', 'No, create a ticket', () => this.actions.onContact('article_not_answered')));
|
|
20594
20900
|
if (!target)
|
|
20595
20901
|
feedbackActions.append(button('svhs-text-button', 'Not now', () => this.actions.onClose()));
|
|
20596
20902
|
feedback.append(feedbackActions);
|
|
20903
|
+
const resolved = this.screen('resolved', 'Thanks for letting us know');
|
|
20904
|
+
resolved.classList.add('svhs-feedback-scroll');
|
|
20905
|
+
this.feedbackStatus.setAttribute('role', 'status');
|
|
20906
|
+
this.feedbackError.setAttribute('role', 'alert');
|
|
20907
|
+
this.retryFeedback = button('svhs-secondary', 'Try saving feedback again', () => this.actions.onRetryFeedback?.());
|
|
20908
|
+
this.reviewLink.textContent = 'Leave a review';
|
|
20909
|
+
this.reviewLink.target = '_blank';
|
|
20910
|
+
this.reviewLink.rel = 'noopener noreferrer';
|
|
20911
|
+
this.reviewPrompt.append(element('p', 'svhs-copy', 'Would you like to share your experience in a review?'), this.reviewLink);
|
|
20912
|
+
resolved.append(this.feedbackStatus, this.feedbackError, this.retryFeedback, this.reviewPrompt);
|
|
20913
|
+
const resolvedActions = element('div', 'svhs-feedback-actions');
|
|
20914
|
+
resolvedActions.append(button('svhs-text-button', 'Ask another question', () => this.actions.onRestart?.()));
|
|
20915
|
+
if (!target)
|
|
20916
|
+
resolvedActions.append(button('svhs-secondary', 'Done', () => this.actions.onClose()));
|
|
20917
|
+
resolved.append(resolvedActions);
|
|
20597
20918
|
const contact = this.screen('contact');
|
|
20598
20919
|
contact.classList.add('svhs-contact-scroll');
|
|
20599
20920
|
const contactPrelude = element('div', 'svhs-contact-prelude');
|
|
@@ -20603,6 +20924,7 @@ class SupportView {
|
|
|
20603
20924
|
this.contactError.id = `${this.prefix}-contact-error`;
|
|
20604
20925
|
this.contactRetry = button('svhs-secondary', 'Try again', () => this.actions.onRetry?.());
|
|
20605
20926
|
contactPrelude.append(this.contactTitle, this.contactStatus, this.contactError, this.contactRetry);
|
|
20927
|
+
contactPrelude.append(this.sourceArticle);
|
|
20606
20928
|
contact.append(contactPrelude);
|
|
20607
20929
|
contact.append(this.ticketGate);
|
|
20608
20930
|
contact.append(this.contactTarget);
|
|
@@ -20648,6 +20970,7 @@ class SupportView {
|
|
|
20648
20970
|
if (previous)
|
|
20649
20971
|
this.saveScroll(previous);
|
|
20650
20972
|
this.state = next;
|
|
20973
|
+
applySupportBrand(this.panel, next.brandColor);
|
|
20651
20974
|
this.panel.dataset.stage = next.stage;
|
|
20652
20975
|
const inset = (value, fallback) => typeof value === 'number' && Number.isFinite(value) ? Math.min(480, Math.max(0, value)) : fallback;
|
|
20653
20976
|
this.panel.style.setProperty('--svhs-right', `${inset(next.position?.right, 24)}px`);
|
|
@@ -20659,7 +20982,10 @@ class SupportView {
|
|
|
20659
20982
|
this.back.disabled = Boolean(next.navigationLocked || next.identityPending);
|
|
20660
20983
|
this.back.lastChild.textContent = next.stage === 'article' ? 'All answers' : next.stage === 'feedback' ? 'Keep reading' : 'Back';
|
|
20661
20984
|
this.deskName.hidden = next.stage === 'article';
|
|
20662
|
-
this.
|
|
20985
|
+
const heading = this.headings.get(next.stage);
|
|
20986
|
+
if (heading && !heading.id)
|
|
20987
|
+
heading.id = `${this.prefix}-${next.stage}-title`;
|
|
20988
|
+
this.panel.setAttribute('aria-labelledby', this.target && heading ? heading.id : next.stage === 'article' ? this.articleTitle.id : this.deskName.id);
|
|
20663
20989
|
for (const [stage, screen] of this.screens)
|
|
20664
20990
|
screen.hidden = stage !== next.stage;
|
|
20665
20991
|
if (this.issue.value !== next.issue)
|
|
@@ -20670,7 +20996,7 @@ class SupportView {
|
|
|
20670
20996
|
this.find.replaceChildren();
|
|
20671
20997
|
if (next.busy)
|
|
20672
20998
|
this.find.append(element('span', 'svhs-spinner'));
|
|
20673
|
-
this.find.append(document.createTextNode(next.busy ? '
|
|
20999
|
+
this.find.append(document.createTextNode(next.busy ? 'Continuing…' : 'Continue'));
|
|
20674
21000
|
this.issueError.textContent = next.stage === 'issue' ? next.error || '' : '';
|
|
20675
21001
|
this.issueError.hidden = !this.issueError.textContent;
|
|
20676
21002
|
this.query.textContent = next.issue;
|
|
@@ -20683,7 +21009,20 @@ class SupportView {
|
|
|
20683
21009
|
this.contactError.textContent = next.stage === 'contact' ? next.error || '' : '';
|
|
20684
21010
|
this.contactError.hidden = !this.contactError.textContent;
|
|
20685
21011
|
this.contactRetry.hidden = Boolean(next.ticketAccessRequired) || !this.contactError.textContent || !this.actions.onRetry || Boolean(next.busy);
|
|
20686
|
-
this.
|
|
21012
|
+
this.sourceArticle.textContent = next.sourceArticle ? `Article you read: ${next.sourceArticle.title}` : '';
|
|
21013
|
+
this.sourceArticle.hidden = !next.sourceArticle;
|
|
21014
|
+
this.contactTitle.parentElement.hidden = this.contactTitle.hidden && this.contactStatus.hidden && this.contactError.hidden && this.sourceArticle.hidden;
|
|
21015
|
+
this.feedbackStatus.textContent = next.feedbackBusy ? 'Saving your feedback...' : next.feedbackError ? '' : next.article?.kind === 'faq' ? 'We are glad that helped.' : 'Your feedback has been saved.';
|
|
21016
|
+
this.feedbackError.textContent = next.feedbackError || '';
|
|
21017
|
+
this.feedbackError.hidden = !next.feedbackError;
|
|
21018
|
+
this.retryFeedback.hidden = !next.feedbackError || !this.actions.onRetryFeedback;
|
|
21019
|
+
const review = httpUrl(next.reviewUrl);
|
|
21020
|
+
const safeReview = review?.protocol === 'https:' ? review : null;
|
|
21021
|
+
this.reviewPrompt.hidden = !safeReview;
|
|
21022
|
+
if (safeReview)
|
|
21023
|
+
this.reviewLink.href = safeReview.href;
|
|
21024
|
+
else
|
|
21025
|
+
this.reviewLink.removeAttribute('href');
|
|
20687
21026
|
this.renderTicketGate(next);
|
|
20688
21027
|
this.renderReceipt(next);
|
|
20689
21028
|
this.syncPresentation();
|
|
@@ -20704,7 +21043,7 @@ class SupportView {
|
|
|
20704
21043
|
return;
|
|
20705
21044
|
const heading = this.contactTarget.querySelector('h1,h2,h3');
|
|
20706
21045
|
this.contactTitle.hidden = Boolean(heading);
|
|
20707
|
-
this.contactTitle.parentElement.hidden = this.contactTitle.hidden && this.contactStatus.hidden && this.contactError.hidden;
|
|
21046
|
+
this.contactTitle.parentElement.hidden = this.contactTitle.hidden && this.contactStatus.hidden && this.contactError.hidden && this.sourceArticle.hidden;
|
|
20708
21047
|
const target = heading ?? this.contactTarget;
|
|
20709
21048
|
target.tabIndex = -1;
|
|
20710
21049
|
target.focus({ preventScroll: !this.target });
|
|
@@ -20862,6 +21201,10 @@ class SupportView {
|
|
|
20862
21201
|
}
|
|
20863
21202
|
renderResults(state) {
|
|
20864
21203
|
const results = state.results ?? [];
|
|
21204
|
+
this.headings.get('results').textContent = state.busy ? 'Checking for helpful articles…'
|
|
21205
|
+
: state.kbState === 'locked' ? 'View helpful articles'
|
|
21206
|
+
: results.length && state.kbState !== 'unavailable' ? 'These articles may help'
|
|
21207
|
+
: 'Let’s get you some help';
|
|
20865
21208
|
const signature = JSON.stringify(results);
|
|
20866
21209
|
if (signature !== this.resultSignature) {
|
|
20867
21210
|
this.resultSignature = signature;
|
|
@@ -20869,16 +21212,22 @@ class SupportView {
|
|
|
20869
21212
|
for (const result of results) {
|
|
20870
21213
|
const item = element('li');
|
|
20871
21214
|
const open = button('svhs-result', '', () => this.actions.onOpenArticle(result.id));
|
|
20872
|
-
|
|
21215
|
+
const copy = element('span', 'svhs-result-copy');
|
|
21216
|
+
copy.append(element('span', 'svhs-result-title', result.title));
|
|
20873
21217
|
if (result.summary)
|
|
20874
|
-
|
|
21218
|
+
copy.append(element('span', 'svhs-result-excerpt', result.summary));
|
|
20875
21219
|
if (result.category)
|
|
20876
|
-
|
|
21220
|
+
copy.append(element('span', 'svhs-result-category', result.category));
|
|
21221
|
+
const documentIcon = icon('article');
|
|
21222
|
+
documentIcon.classList.add('svhs-result-icon');
|
|
21223
|
+
const chevron = icon('chevron');
|
|
21224
|
+
chevron.classList.add('svhs-result-chevron');
|
|
21225
|
+
open.append(documentIcon, copy, chevron);
|
|
20877
21226
|
item.append(open);
|
|
20878
21227
|
this.resultList.append(item);
|
|
20879
21228
|
}
|
|
20880
21229
|
}
|
|
20881
|
-
this.resultCopy.textContent =
|
|
21230
|
+
this.resultCopy.textContent = 'Choose an article to read the full answer.';
|
|
20882
21231
|
this.resultList.hidden = Boolean(state.busy) || state.kbState === 'locked' || state.kbState === 'unavailable';
|
|
20883
21232
|
this.resultCopy.hidden = this.resultList.hidden || results.length === 0;
|
|
20884
21233
|
this.resultError.textContent = state.stage === 'results' ? state.error || '' : '';
|
|
@@ -20888,7 +21237,8 @@ class SupportView {
|
|
|
20888
21237
|
control.setAttribute('aria-disabled', String(Boolean(state.busy)));
|
|
20889
21238
|
control.setAttribute('aria-busy', String(Boolean(state.busy)));
|
|
20890
21239
|
}
|
|
20891
|
-
this.
|
|
21240
|
+
this.resultsFooter.hidden = Boolean(state.busy);
|
|
21241
|
+
this.contactResults.disabled = Boolean(state.busy);
|
|
20892
21242
|
}
|
|
20893
21243
|
renderResultStatus(state, results) {
|
|
20894
21244
|
const signature = state.kbState === 'locked' ? `locked:${state.kbAccessMode}` : state.busy ? 'busy' : state.kbState === 'unavailable' ? 'unavailable' : results.length ? 'matches' : 'empty';
|
|
@@ -21276,6 +21626,8 @@ function createHelpDeskSupport(config, options) {
|
|
|
21276
21626
|
let cancelArticleAssets = null;
|
|
21277
21627
|
let stopSession = null;
|
|
21278
21628
|
let anonymous = false;
|
|
21629
|
+
let feedbackSequence = 0;
|
|
21630
|
+
let sourceArticleId;
|
|
21279
21631
|
const lifetime = new AbortController();
|
|
21280
21632
|
const bindings = new Set();
|
|
21281
21633
|
let state = { visible: false, stage: 'issue', deskName: 'Support', issue: '' };
|
|
@@ -21315,7 +21667,9 @@ function createHelpDeskSupport(config, options) {
|
|
|
21315
21667
|
update({ stage: 'issue', error: undefined });
|
|
21316
21668
|
},
|
|
21317
21669
|
onClose: () => {
|
|
21318
|
-
if (state.stage === '
|
|
21670
|
+
if (state.stage === 'resolved')
|
|
21671
|
+
resetJourney(false);
|
|
21672
|
+
else if (state.stage === 'article' && state.article)
|
|
21319
21673
|
update({ stage: 'feedback', error: undefined });
|
|
21320
21674
|
else {
|
|
21321
21675
|
if (state.stage === 'feedback')
|
|
@@ -21323,13 +21677,8 @@ function createHelpDeskSupport(config, options) {
|
|
|
21323
21677
|
minimize();
|
|
21324
21678
|
}
|
|
21325
21679
|
},
|
|
21326
|
-
onAnswered: () => {
|
|
21327
|
-
|
|
21328
|
-
return;
|
|
21329
|
-
void attempt?.then((active) => active?.solved());
|
|
21330
|
-
resetJourney(options.target !== undefined);
|
|
21331
|
-
view.showToast('We’re happy we could help.');
|
|
21332
|
-
},
|
|
21680
|
+
onAnswered: () => { void answerArticle(); },
|
|
21681
|
+
onRetryFeedback: () => { void answerArticle(); },
|
|
21333
21682
|
onRestart: () => {
|
|
21334
21683
|
resetJourney(state.visible);
|
|
21335
21684
|
},
|
|
@@ -21387,7 +21736,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
21387
21736
|
return (await http.request(path, { method: 'POST', body, credentials: 'omit', headers: { 'X-SV-Client': 'help-desk-portal', ...headers } })).data;
|
|
21388
21737
|
},
|
|
21389
21738
|
});
|
|
21390
|
-
update({ deskName: answer.desk.organization_name || 'Support' });
|
|
21739
|
+
update({ deskName: answer.desk.organization_name || 'Support', brandColor: answer.desk.branding?.color });
|
|
21391
21740
|
return answer;
|
|
21392
21741
|
}).catch((error) => { connected = null; throw error; });
|
|
21393
21742
|
return connected;
|
|
@@ -21400,6 +21749,10 @@ function createHelpDeskSupport(config, options) {
|
|
|
21400
21749
|
update({ visible: true });
|
|
21401
21750
|
try {
|
|
21402
21751
|
const active = await connect();
|
|
21752
|
+
if (input.articleId && state.stage === 'issue' && !contact) {
|
|
21753
|
+
await contactFromArticle(input.articleId);
|
|
21754
|
+
return;
|
|
21755
|
+
}
|
|
21403
21756
|
if (!options.persist || destroyed || state.stage !== 'issue')
|
|
21404
21757
|
return;
|
|
21405
21758
|
const token = await active.getSessionToken();
|
|
@@ -21437,6 +21790,57 @@ function createHelpDeskSupport(config, options) {
|
|
|
21437
21790
|
}
|
|
21438
21791
|
}
|
|
21439
21792
|
function minimize() { update({ visible: false }); }
|
|
21793
|
+
async function answerArticle() {
|
|
21794
|
+
const article = state.article;
|
|
21795
|
+
if (destroyed || !article || state.feedbackBusy)
|
|
21796
|
+
return;
|
|
21797
|
+
const ownFeedback = ++feedbackSequence;
|
|
21798
|
+
void attempt?.then((active) => active?.solved());
|
|
21799
|
+
update({ stage: 'resolved', feedbackBusy: article.kind === 'article', feedbackError: undefined, reviewUrl: undefined, error: undefined });
|
|
21800
|
+
if (article.kind !== 'article' || !kb)
|
|
21801
|
+
return;
|
|
21802
|
+
try {
|
|
21803
|
+
const saved = await kb.vote(article, 'yes');
|
|
21804
|
+
if (destroyed || ownFeedback !== feedbackSequence || state.stage !== 'resolved')
|
|
21805
|
+
return;
|
|
21806
|
+
update({ feedbackBusy: false, reviewUrl: saved.review_url || undefined });
|
|
21807
|
+
}
|
|
21808
|
+
catch (value) {
|
|
21809
|
+
if (destroyed || ownFeedback !== feedbackSequence || state.stage !== 'resolved')
|
|
21810
|
+
return;
|
|
21811
|
+
update({ feedbackBusy: false, feedbackError: failure(value).message });
|
|
21812
|
+
}
|
|
21813
|
+
}
|
|
21814
|
+
/** Article feedback has already happened in the help center; skip suggestions and preserve its trusted reference. */
|
|
21815
|
+
async function contactFromArticle(id) {
|
|
21816
|
+
const ownSequence = ++sequence;
|
|
21817
|
+
update({ busy: true, error: undefined });
|
|
21818
|
+
try {
|
|
21819
|
+
if (!kb || typeof id !== 'string' || !id || id.length > 256)
|
|
21820
|
+
throw new ValidationError('Choose a published article.');
|
|
21821
|
+
sourceArticleId = id;
|
|
21822
|
+
const result = await kb.resolveArticle(id);
|
|
21823
|
+
if (!result)
|
|
21824
|
+
throw new ValidationError('This article is no longer available.');
|
|
21825
|
+
const article = await kb.read(result);
|
|
21826
|
+
if (destroyed || ownSequence !== sequence)
|
|
21827
|
+
return;
|
|
21828
|
+
requestedArticle = result;
|
|
21829
|
+
kbConfig = await kb.load();
|
|
21830
|
+
if (destroyed || ownSequence !== sequence)
|
|
21831
|
+
return;
|
|
21832
|
+
update({ article, sourceArticle: { title: article.title, url: article.canonical_url }, busy: false });
|
|
21833
|
+
void startAttempt(true, article.release_id, 1).then((active) => active?.articleOpened(article.id, article.release_id));
|
|
21834
|
+
await showContact('article_not_answered');
|
|
21835
|
+
}
|
|
21836
|
+
catch {
|
|
21837
|
+
if (destroyed || ownSequence !== sequence)
|
|
21838
|
+
return;
|
|
21839
|
+
// A stale or protected article must not stop someone asking for help.
|
|
21840
|
+
update({ busy: false, article: undefined, sourceArticle: undefined });
|
|
21841
|
+
await showContact('direct');
|
|
21842
|
+
}
|
|
21843
|
+
}
|
|
21440
21844
|
/** Forget a finished journey: its form and the files it authorized, any composition held for it, its suggestions and article. */
|
|
21441
21845
|
function resetJourney(visible) {
|
|
21442
21846
|
contact?.destroy();
|
|
@@ -21449,10 +21853,13 @@ function createHelpDeskSupport(config, options) {
|
|
|
21449
21853
|
results = [];
|
|
21450
21854
|
requestedArticle = null;
|
|
21451
21855
|
pendingComposition = null;
|
|
21856
|
+
feedbackSequence += 1;
|
|
21857
|
+
sourceArticleId = undefined;
|
|
21452
21858
|
if (options.persist && client)
|
|
21453
21859
|
clearSupportIssue(client.desk.desk_id);
|
|
21454
21860
|
update({ visible, stage: 'issue', issue: '', results: [], article: undefined, articleUrl: undefined,
|
|
21455
|
-
receipt: undefined, error: undefined, busy: false, navigationLocked: false
|
|
21861
|
+
receipt: undefined, error: undefined, busy: false, navigationLocked: false, sourceArticle: undefined,
|
|
21862
|
+
feedbackBusy: false, feedbackError: undefined, reviewUrl: undefined });
|
|
21456
21863
|
}
|
|
21457
21864
|
function signIn(input = {}) {
|
|
21458
21865
|
if (!client)
|
|
@@ -21485,8 +21892,9 @@ function createHelpDeskSupport(config, options) {
|
|
|
21485
21892
|
async function search(issue) {
|
|
21486
21893
|
if (destroyed || !issue.trim())
|
|
21487
21894
|
return;
|
|
21895
|
+
sourceArticleId = undefined;
|
|
21488
21896
|
const ownSequence = ++sequence;
|
|
21489
|
-
update({ stage: 'results', issue, busy: true, error: undefined, results: [], article: undefined, kbState: undefined });
|
|
21897
|
+
update({ stage: 'results', issue, busy: true, error: undefined, results: [], article: undefined, kbState: undefined, sourceArticle: undefined });
|
|
21490
21898
|
results = [];
|
|
21491
21899
|
try {
|
|
21492
21900
|
const active = await connect();
|
|
@@ -21630,6 +22038,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
21630
22038
|
...(switchedAccount && (options.getSessionToken || options.getIdentityAssertion || options.identityEndpoint) ? { useWebsiteAccount: (safe) => { void useWebsiteAccount(safe); } } : {}),
|
|
21631
22039
|
},
|
|
21632
22040
|
assistanceContext: () => activeAttempt?.ticketContext(),
|
|
22041
|
+
sourceArticleId: () => sourceArticleId,
|
|
21633
22042
|
onError: (error) => {
|
|
21634
22043
|
notify(options.onError, error);
|
|
21635
22044
|
if (['HELP_DESK_ACCESS_REQUIRED', 'HELP_DESK_IP_DENIED'].includes(errorCode(error) ?? ''))
|
|
@@ -21675,6 +22084,14 @@ function createHelpDeskSupport(config, options) {
|
|
|
21675
22084
|
async function showContact(reason) {
|
|
21676
22085
|
if (destroyed || contactOpening === sequence)
|
|
21677
22086
|
return;
|
|
22087
|
+
if (reason === 'article_not_answered' && state.article) {
|
|
22088
|
+
const article = state.article;
|
|
22089
|
+
sourceArticleId = article.id;
|
|
22090
|
+
update({ sourceArticle: { title: article.title, url: article.canonical_url } });
|
|
22091
|
+
// The article vote and assistance outcome serve different reports. Neither may block contacting the team.
|
|
22092
|
+
if (article.kind === 'article' && kb)
|
|
22093
|
+
void kb.vote(article, 'no').catch(() => undefined);
|
|
22094
|
+
}
|
|
21678
22095
|
followIssue();
|
|
21679
22096
|
cancelArticleAssets?.();
|
|
21680
22097
|
cancelArticleAssets = null;
|
|
@@ -21783,6 +22200,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
21783
22200
|
results = [];
|
|
21784
22201
|
requestedArticle = null;
|
|
21785
22202
|
attempt = null;
|
|
22203
|
+
sourceArticleId = undefined;
|
|
21786
22204
|
update({ results: [], article: undefined, articleUrl: undefined, kbState: undefined });
|
|
21787
22205
|
switchedAccount = true;
|
|
21788
22206
|
const logout = active.switchSupportAccount();
|
|
@@ -21830,6 +22248,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
21830
22248
|
results = [];
|
|
21831
22249
|
requestedArticle = null;
|
|
21832
22250
|
attempt = null;
|
|
22251
|
+
sourceArticleId = undefined;
|
|
21833
22252
|
update({ busy: true, error: undefined, results: [], article: undefined, articleUrl: undefined, kbState: undefined });
|
|
21834
22253
|
try {
|
|
21835
22254
|
await client.useWebsiteAccount();
|
|
@@ -23013,11 +23432,6 @@ function getUploadStyles() {
|
|
|
23013
23432
|
overflow: hidden;
|
|
23014
23433
|
}
|
|
23015
23434
|
|
|
23016
|
-
.svu-modal.svu-with-sidebar {
|
|
23017
|
-
max-width: 900px;
|
|
23018
|
-
flex-direction: row;
|
|
23019
|
-
}
|
|
23020
|
-
|
|
23021
23435
|
.svu-modal-main {
|
|
23022
23436
|
flex: 1;
|
|
23023
23437
|
display: flex;
|
|
@@ -23781,13 +24195,38 @@ function getUploadStyles() {
|
|
|
23781
24195
|
}
|
|
23782
24196
|
|
|
23783
24197
|
/* ========================================
|
|
23784
|
-
SECURITY
|
|
24198
|
+
ON-DEMAND SECURITY HELP
|
|
23785
24199
|
======================================== */
|
|
23786
24200
|
|
|
24201
|
+
.svu-security-help {
|
|
24202
|
+
flex-shrink: 0;
|
|
24203
|
+
border-top: 1px solid ${tokens.borderDark};
|
|
24204
|
+
}
|
|
24205
|
+
|
|
24206
|
+
.svu-security-help summary {
|
|
24207
|
+
display: flex;
|
|
24208
|
+
align-items: center;
|
|
24209
|
+
justify-content: center;
|
|
24210
|
+
width: 44px;
|
|
24211
|
+
min-height: 44px;
|
|
24212
|
+
margin-left: auto;
|
|
24213
|
+
cursor: pointer;
|
|
24214
|
+
color: ${tokens.textMutedOnDark};
|
|
24215
|
+
font-size: 16px;
|
|
24216
|
+
list-style: none;
|
|
24217
|
+
}
|
|
24218
|
+
|
|
24219
|
+
.svu-security-help summary::-webkit-details-marker { display: none; }
|
|
24220
|
+
.svu-security-help summary:focus-visible {
|
|
24221
|
+
outline: 2px solid ${tokens.textOnDark};
|
|
24222
|
+
outline-offset: -4px;
|
|
24223
|
+
}
|
|
24224
|
+
|
|
23787
24225
|
.svu-sidebar {
|
|
23788
|
-
|
|
24226
|
+
box-sizing: border-box;
|
|
24227
|
+
width: 100%;
|
|
24228
|
+
max-height: 240px;
|
|
23789
24229
|
background: ${tokens.bgDark};
|
|
23790
|
-
border-left: 1px solid ${tokens.borderDark};
|
|
23791
24230
|
color: ${tokens.textOnDark};
|
|
23792
24231
|
padding: 20px;
|
|
23793
24232
|
overflow-y: auto;
|
|
@@ -23957,20 +24396,6 @@ function getUploadStyles() {
|
|
|
23957
24396
|
RESPONSIVE
|
|
23958
24397
|
======================================== */
|
|
23959
24398
|
|
|
23960
|
-
@media (max-width: 768px) {
|
|
23961
|
-
.svu-modal.svu-with-sidebar {
|
|
23962
|
-
flex-direction: column;
|
|
23963
|
-
max-width: 480px;
|
|
23964
|
-
}
|
|
23965
|
-
|
|
23966
|
-
.svu-sidebar {
|
|
23967
|
-
width: 100%;
|
|
23968
|
-
border-left: none;
|
|
23969
|
-
border-top: 1px solid ${tokens.borderDark};
|
|
23970
|
-
max-height: 300px;
|
|
23971
|
-
}
|
|
23972
|
-
}
|
|
23973
|
-
|
|
23974
24399
|
@media (max-width: 480px) {
|
|
23975
24400
|
.svu-modal {
|
|
23976
24401
|
max-width: 100%;
|
|
@@ -24038,7 +24463,7 @@ function getUploadStyles() {
|
|
|
24038
24463
|
* Upload Modal Container
|
|
24039
24464
|
*
|
|
24040
24465
|
* Single responsibility: the upload dialog's chrome (branded header, body,
|
|
24041
|
-
* footer, and
|
|
24466
|
+
* footer, and optional security help) inside the SDK's shared
|
|
24042
24467
|
* modal shell, which owns the dialog behaviour (dismissal, scroll lock,
|
|
24043
24468
|
* focus). Does NOT handle content rendering - that's the Renderer's job.
|
|
24044
24469
|
*/
|
|
@@ -24127,25 +24552,33 @@ class UploadModalContainer {
|
|
|
24127
24552
|
this.refreshHeader();
|
|
24128
24553
|
}
|
|
24129
24554
|
/**
|
|
24130
|
-
*
|
|
24131
|
-
* the
|
|
24555
|
+
* Offer security education on demand during a transfer. Never expand it
|
|
24556
|
+
* automatically or widen the working view to accommodate explanatory copy.
|
|
24132
24557
|
*/
|
|
24133
24558
|
toggleSidebar(show) {
|
|
24134
24559
|
if (!this.shell)
|
|
24135
24560
|
return;
|
|
24136
24561
|
if (show && !this.sidebar) {
|
|
24137
|
-
this.sidebar =
|
|
24138
|
-
this.
|
|
24139
|
-
|
|
24140
|
-
|
|
24141
|
-
|
|
24562
|
+
this.sidebar = document.createElement('details');
|
|
24563
|
+
this.sidebar.className = 'svu-security-help';
|
|
24564
|
+
const summary = document.createElement('summary');
|
|
24565
|
+
summary.textContent = '?';
|
|
24566
|
+
summary.setAttribute('aria-label', 'About upload security');
|
|
24567
|
+
summary.title = 'About upload security';
|
|
24568
|
+
this.sidebar.append(summary, createSecuritySidebar(this.branding));
|
|
24569
|
+
this.sidebar.addEventListener('keydown', (event) => {
|
|
24570
|
+
if (event.key !== 'Escape' || !this.sidebar?.open)
|
|
24571
|
+
return;
|
|
24572
|
+
event.preventDefault();
|
|
24573
|
+
event.stopPropagation();
|
|
24574
|
+
this.sidebar.open = false;
|
|
24575
|
+
summary.focus();
|
|
24576
|
+
});
|
|
24577
|
+
this.body?.after(this.sidebar);
|
|
24142
24578
|
}
|
|
24143
24579
|
else if (!show && this.sidebar) {
|
|
24144
|
-
this.shell.modal.classList.remove('svu-with-sidebar');
|
|
24145
24580
|
this.sidebar.remove();
|
|
24146
24581
|
this.sidebar = null;
|
|
24147
|
-
if (this.header)
|
|
24148
|
-
this.header.style.display = '';
|
|
24149
24582
|
}
|
|
24150
24583
|
}
|
|
24151
24584
|
handleClose() {
|
|
@@ -24543,7 +24976,7 @@ class UploadRenderer {
|
|
|
24543
24976
|
return;
|
|
24544
24977
|
// Clear body
|
|
24545
24978
|
body.innerHTML = '';
|
|
24546
|
-
// The dialog darkens and
|
|
24979
|
+
// The dialog darkens and offers optional security help in the dark states;
|
|
24547
24980
|
// inline mode runs those states in its own dialog (renderInModal).
|
|
24548
24981
|
if (this.container instanceof UploadModalContainer) {
|
|
24549
24982
|
this.container.setDarkMode(isDarkState);
|
|
@@ -24629,7 +25062,7 @@ class UploadRenderer {
|
|
|
24629
25062
|
if (inlineBody?.parentElement) {
|
|
24630
25063
|
inlineBody.parentElement.style.display = 'none';
|
|
24631
25064
|
}
|
|
24632
|
-
// Set dark mode and
|
|
25065
|
+
// Set dark mode and offer security help once, closed until requested.
|
|
24633
25066
|
this.uploadModal.setDarkMode(true);
|
|
24634
25067
|
this.uploadModal.toggleSidebar(true);
|
|
24635
25068
|
this.hybridModalInitialized = true;
|
|
@@ -26644,7 +27077,7 @@ class SparkVault {
|
|
|
26644
27077
|
}
|
|
26645
27078
|
/** Get the SDK version */
|
|
26646
27079
|
static get version() {
|
|
26647
|
-
return '15.14.
|
|
27080
|
+
return '15.14.2';
|
|
26648
27081
|
}
|
|
26649
27082
|
}
|
|
26650
27083
|
if (typeof window !== 'undefined') {
|