@sparkvault/sdk-js 18.0.3 → 18.0.5
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 +1 -1
- package/dist/index.cjs +646 -135
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +646 -135
- package/dist/index.mjs.map +1 -1
- package/dist/products/help-desk/form.d.ts +4 -4
- package/dist/products/help-desk/support-view.d.ts +4 -0
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -14953,6 +14953,21 @@ const HELP_DESK_WIDGET_IDENTITY_MESSAGES = Object.freeze({
|
|
|
14953
14953
|
result: 'sparkvault:help-desk:identity'
|
|
14954
14954
|
});
|
|
14955
14955
|
|
|
14956
|
+
/**
|
|
14957
|
+
* The one rule labelling a requester on a ticket's timeline, for every
|
|
14958
|
+
* audience, and in the console's inbox: the name they gave the desk, else
|
|
14959
|
+
* their address; null when it holds neither (an erased requester). An empty
|
|
14960
|
+
* name is no name, so their address stands in for it. Core's timeline
|
|
14961
|
+
* labels (help-desk/events.js) and the console's inbox (inbox/labels.js)
|
|
14962
|
+
* both read it.
|
|
14963
|
+
*
|
|
14964
|
+
* @param {{ display_name?: string|null, email?: string|null }|null|undefined} requester
|
|
14965
|
+
* @returns {string|null}
|
|
14966
|
+
*/
|
|
14967
|
+
function requesterNameOrAddress(requester) {
|
|
14968
|
+
return requester?.display_name || requester?.email || null;
|
|
14969
|
+
}
|
|
14970
|
+
|
|
14956
14971
|
/**
|
|
14957
14972
|
* Mail local parts no queue may take as its alias: the role mailboxes RFC 2142
|
|
14958
14973
|
* names, the addresses mail systems and their operators keep for themselves,
|
|
@@ -19562,6 +19577,8 @@ const HELP_DESK_COLORS = Object.freeze({
|
|
|
19562
19577
|
fillStrong: `var(--hd-fill-strong,${LIGHT['--color-slate-200']})`,
|
|
19563
19578
|
/** A field's and a secondary action's edge. */
|
|
19564
19579
|
lineStrong: `var(--hd-line-strong,${LIGHT['--color-slate-300']})`,
|
|
19580
|
+
/** A modal's scrim stays dark in either scheme; the alpha belongs to the surface. */
|
|
19581
|
+
modalBackdrop: `var(--hd-modal-backdrop,${LIGHT['--ink']})`,
|
|
19565
19582
|
ink: `var(--hd-ink,${LIGHT['--ink']})`,
|
|
19566
19583
|
body: `var(--hd-text-body,${LIGHT['--text-body']})`,
|
|
19567
19584
|
muted: `var(--hd-text-muted,${LIGHT['--text-muted']})`,
|
|
@@ -19701,7 +19718,6 @@ function injectHelpDeskFormStyles() {
|
|
|
19701
19718
|
.svhd-hint{font-size:13px;color:${HELP_DESK_COLORS.body};margin:0}
|
|
19702
19719
|
.svhd-step{display:grid;gap:16px;min-width:0}
|
|
19703
19720
|
.svhd-step-head{display:grid;gap:4px;margin-bottom:4px}
|
|
19704
|
-
.svhd-step-label{margin:0;font-size:13px;font-weight:600;line-height:1.4;color:${HELP_DESK_COLORS.body}}
|
|
19705
19721
|
.svhd-text-button{display:inline-flex;align-items:center;min-height:44px;padding:0 4px;border:0;border-radius:6px;background:transparent;color:${HELP_DESK_ACCENT.ink};font:inherit;font-size:14px;font-weight:600;text-decoration:underline;text-underline-offset:2px;cursor:pointer}
|
|
19706
19722
|
.svhd-text-button:not(:disabled):hover{text-decoration-thickness:2px}
|
|
19707
19723
|
.svhd-text-button:focus-visible{outline:3px solid ${HELP_DESK_FOCUS};outline-offset:2px}
|
|
@@ -20250,7 +20266,7 @@ function acceptedKindsCopy(kinds) {
|
|
|
20250
20266
|
/**
|
|
20251
20267
|
* The files a ticket accepts, in the one phrase every surface names them by,
|
|
20252
20268
|
* built from the policy's own list (ACCEPTED_ATTACHMENT_KINDS): the help desk
|
|
20253
|
-
* composer's
|
|
20269
|
+
* composer's refusal dialog reads it, and so do the API reference
|
|
20254
20270
|
* (apps/api/openapi/overlay.mjs) and the help desk's page on the site
|
|
20255
20271
|
* (apps/www/_data/helpDeskAttachments.js). A refused file's sentence names
|
|
20256
20272
|
* only that its type can't be attached.
|
|
@@ -20258,10 +20274,9 @@ function acceptedKindsCopy(kinds) {
|
|
|
20258
20274
|
const ACCEPTED_ATTACHMENTS_COPY = acceptedKindsCopy(ACCEPTED_ATTACHMENT_KINDS);
|
|
20259
20275
|
|
|
20260
20276
|
/**
|
|
20261
|
-
*
|
|
20262
|
-
*
|
|
20263
|
-
*
|
|
20264
|
-
* Attach.
|
|
20277
|
+
* The attachment rules shown after a refusal: what to add, how many files a
|
|
20278
|
+
* message takes and how large each may be. The help desk composer's
|
|
20279
|
+
* validation dialog reads this without adding prose to accepted uploads.
|
|
20265
20280
|
*/
|
|
20266
20281
|
const CUSTOMER_ATTACHMENTS_HINT =
|
|
20267
20282
|
`Add screenshots, documents or recordings. Up to ${MAX_ATTACHMENTS_PER_MESSAGE} files, ${formatBytes(CUSTOMER_ATTACHMENT_MAX_BYTES)} each.`;
|
|
@@ -20335,6 +20350,386 @@ function refusalCopy(refusal, maxBytes) {
|
|
|
20335
20350
|
return REFUSAL_COPY[refusal] ?? "This file can't be attached.";
|
|
20336
20351
|
}
|
|
20337
20352
|
|
|
20353
|
+
/**
|
|
20354
|
+
* Strict single-value media type (MIME) parsing.
|
|
20355
|
+
*
|
|
20356
|
+
* The one parser for a stored ingot or spark `content_type`: Core validates
|
|
20357
|
+
* every ingested value with it, Forge derives both the served Content-Type and
|
|
20358
|
+
* the inline-render decision from it, the display rules the web console and
|
|
20359
|
+
* the x.sv pages share (display-content-type.js), the Spark payload rule
|
|
20360
|
+
* (`isTextMediaType`) and the server's registry readings (media-type-node.js)
|
|
20361
|
+
* read the essence through it, so no two readers can disagree about what a
|
|
20362
|
+
* value means. A page that cannot import an ES module runs this module's own
|
|
20363
|
+
* source (MEDIA_TYPE_SCRIPT).
|
|
20364
|
+
*
|
|
20365
|
+
* Grammar (RFC 9110 §8.3.1): `type "/" subtype *( OWS ";" OWS [ parameter ] )`
|
|
20366
|
+
* where type, subtype and parameter names are tokens and parameter values are
|
|
20367
|
+
* tokens or quoted-strings, ASCII only. One deliberate tightening: a comma
|
|
20368
|
+
* anywhere rejects the value. Browsers read Content-Type as a comma-separated
|
|
20369
|
+
* list and keep the LAST valid type (WHATWG Fetch "extract a MIME type"), so a
|
|
20370
|
+
* value that this parser would classify by its first type can render in a
|
|
20371
|
+
* browser as another: `image/png, text/html` executes as HTML.
|
|
20372
|
+
*
|
|
20373
|
+
* BROWSER-SAFE: pure string handling, no Node built-ins.
|
|
20374
|
+
*/
|
|
20375
|
+
|
|
20376
|
+
/** Longest accepted value; RFC 6838 caps type and subtype at 127 chars each. */
|
|
20377
|
+
const MAX_MEDIA_TYPE_LENGTH = 255;
|
|
20378
|
+
const TOKEN_CHAR = /[!#$%&'*+.^_`|~0-9A-Za-z-]/;
|
|
20379
|
+
/** qdtext: HTAB, SP and visible ASCII except `"` and backslash. */
|
|
20380
|
+
const QUOTED_TEXT_CHAR = /[\t\x20\x21\x23-\x5b\x5d-\x7e]/;
|
|
20381
|
+
/** The character after the backslash of a quoted-pair: HTAB, SP or visible ASCII. */
|
|
20382
|
+
const QUOTED_PAIR_CHAR = /[\t\x20-\x7e]/;
|
|
20383
|
+
|
|
20384
|
+
/** Index just past the token starting at `start` (=== start when there is none). */
|
|
20385
|
+
function tokenEnd(value, start) {
|
|
20386
|
+
let end = start;
|
|
20387
|
+
while (end < value.length && TOKEN_CHAR.test(value[end])) end += 1;
|
|
20388
|
+
return end;
|
|
20389
|
+
}
|
|
20390
|
+
|
|
20391
|
+
/** Index just past the optional whitespace (SP / HTAB) starting at `start`. */
|
|
20392
|
+
function owsEnd(value, start) {
|
|
20393
|
+
let end = start;
|
|
20394
|
+
while (value[end] === ' ' || value[end] === '\t') end += 1;
|
|
20395
|
+
return end;
|
|
20396
|
+
}
|
|
20397
|
+
|
|
20398
|
+
/**
|
|
20399
|
+
* Read the quoted-string whose opening quote is at `start`.
|
|
20400
|
+
* @returns {{end: number, text: string} | null} The index past the closing
|
|
20401
|
+
* quote and the unescaped content; null when malformed or unterminated.
|
|
20402
|
+
*/
|
|
20403
|
+
function readQuotedString(value, start) {
|
|
20404
|
+
let text = '';
|
|
20405
|
+
let index = start + 1;
|
|
20406
|
+
while (index < value.length) {
|
|
20407
|
+
const char = value[index];
|
|
20408
|
+
if (char === '"') return { end: index + 1, text };
|
|
20409
|
+
if (char === '\\') {
|
|
20410
|
+
const escaped = value[index + 1];
|
|
20411
|
+
if (escaped === undefined || !QUOTED_PAIR_CHAR.test(escaped)) return null;
|
|
20412
|
+
text += escaped;
|
|
20413
|
+
index += 2;
|
|
20414
|
+
} else if (QUOTED_TEXT_CHAR.test(char)) {
|
|
20415
|
+
text += char;
|
|
20416
|
+
index += 1;
|
|
20417
|
+
} else {
|
|
20418
|
+
return null;
|
|
20419
|
+
}
|
|
20420
|
+
}
|
|
20421
|
+
return null;
|
|
20422
|
+
}
|
|
20423
|
+
|
|
20424
|
+
/**
|
|
20425
|
+
* Parse one media type value.
|
|
20426
|
+
*
|
|
20427
|
+
* A single left-to-right scan: every character is examined a bounded number
|
|
20428
|
+
* of times, so the cost is linear in the (already length-capped) input. Core
|
|
20429
|
+
* runs this on untrusted request bodies, where a backtracking grammar would
|
|
20430
|
+
* let one crafted value stall the process.
|
|
20431
|
+
*
|
|
20432
|
+
* @param {unknown} value - A stored or submitted content type
|
|
20433
|
+
* @returns {{
|
|
20434
|
+
* type: string,
|
|
20435
|
+
* subtype: string,
|
|
20436
|
+
* essence: string,
|
|
20437
|
+
* parameters: Map<string, string>
|
|
20438
|
+
* } | null} Lowercased type/subtype/essence and parameter names, unquoted
|
|
20439
|
+
* parameter values (the first occurrence of a name wins); null when the
|
|
20440
|
+
* value is not exactly one well-formed media type.
|
|
20441
|
+
*/
|
|
20442
|
+
function parseMediaType(value) {
|
|
20443
|
+
if (typeof value !== 'string' || value.length > MAX_MEDIA_TYPE_LENGTH || value.includes(',')) {
|
|
20444
|
+
return null;
|
|
20445
|
+
}
|
|
20446
|
+
|
|
20447
|
+
const typeEnd = tokenEnd(value, 0);
|
|
20448
|
+
if (typeEnd === 0 || value[typeEnd] !== '/') return null;
|
|
20449
|
+
const subtypeEnd = tokenEnd(value, typeEnd + 1);
|
|
20450
|
+
if (subtypeEnd === typeEnd + 1) return null;
|
|
20451
|
+
|
|
20452
|
+
const type = value.slice(0, typeEnd).toLowerCase();
|
|
20453
|
+
const subtype = value.slice(typeEnd + 1, subtypeEnd).toLowerCase();
|
|
20454
|
+
const parameters = new Map();
|
|
20455
|
+
|
|
20456
|
+
// parameters = *( OWS ";" OWS [ parameter ] )
|
|
20457
|
+
let index = subtypeEnd;
|
|
20458
|
+
while (index < value.length) {
|
|
20459
|
+
index = owsEnd(value, index);
|
|
20460
|
+
if (value[index] !== ';') return null;
|
|
20461
|
+
index = owsEnd(value, index + 1);
|
|
20462
|
+
if (index === value.length || value[index] === ';') continue; // empty slot
|
|
20463
|
+
|
|
20464
|
+
const nameEnd = tokenEnd(value, index);
|
|
20465
|
+
if (nameEnd === index || value[nameEnd] !== '=') return null;
|
|
20466
|
+
const name = value.slice(index, nameEnd).toLowerCase();
|
|
20467
|
+
|
|
20468
|
+
let parameterValue;
|
|
20469
|
+
if (value[nameEnd + 1] === '"') {
|
|
20470
|
+
const quoted = readQuotedString(value, nameEnd + 1);
|
|
20471
|
+
if (!quoted) return null;
|
|
20472
|
+
parameterValue = quoted.text;
|
|
20473
|
+
index = quoted.end;
|
|
20474
|
+
} else {
|
|
20475
|
+
const valueEnd = tokenEnd(value, nameEnd + 1);
|
|
20476
|
+
if (valueEnd === nameEnd + 1) return null;
|
|
20477
|
+
parameterValue = value.slice(nameEnd + 1, valueEnd);
|
|
20478
|
+
index = valueEnd;
|
|
20479
|
+
}
|
|
20480
|
+
|
|
20481
|
+
if (!parameters.has(name)) parameters.set(name, parameterValue);
|
|
20482
|
+
}
|
|
20483
|
+
|
|
20484
|
+
return { type, subtype, essence: `${type}/${subtype}`, parameters };
|
|
20485
|
+
}
|
|
20486
|
+
|
|
20487
|
+
/**
|
|
20488
|
+
* The essence of a content type: its lowercased `type/subtype`, parameters
|
|
20489
|
+
* dropped (`application/json` of `Application/JSON; charset=utf-8`). An exact
|
|
20490
|
+
* type filter matches an ingot on it.
|
|
20491
|
+
*
|
|
20492
|
+
* The x.sv page runs this function's source (MEDIA_TYPE_SCRIPT), so it keeps
|
|
20493
|
+
* to the ECMAScript 2018 the page parses as (docs/GOTCHAS.md).
|
|
20494
|
+
*
|
|
20495
|
+
* @param {unknown} value
|
|
20496
|
+
* @returns {string|null} null when the value is not exactly one well-formed
|
|
20497
|
+
* media type
|
|
20498
|
+
*/
|
|
20499
|
+
function mediaTypeEssence(value) {
|
|
20500
|
+
const mediaType = parseMediaType(value);
|
|
20501
|
+
return mediaType === null ? null : mediaType.essence;
|
|
20502
|
+
}
|
|
20503
|
+
|
|
20504
|
+
/**
|
|
20505
|
+
* Sound formats platforms type outside the audio tree, each an essence: the
|
|
20506
|
+
* Ogg container, as Firefox types every `.ogg` file (any other platform's
|
|
20507
|
+
* audio/ogg), and WMA as Chrome on macOS types a `.wma` file (Firefox's
|
|
20508
|
+
* audio/x-ms-wma). Each is filed with the audio (mediaTypeFamily), and is
|
|
20509
|
+
* the audio kind's (./ingot-kind.js), so a file's icon and the type filter
|
|
20510
|
+
* that lists it agree.
|
|
20511
|
+
*/
|
|
20512
|
+
const SOUND_TYPES_OUTSIDE_AUDIO = Object.freeze(['application/ogg', 'video/x-ms-wma']);
|
|
20513
|
+
|
|
20514
|
+
new Set(SOUND_TYPES_OUTSIDE_AUDIO);
|
|
20515
|
+
|
|
20516
|
+
/**
|
|
20517
|
+
* Content-type policy for vault and spark bytes a browser page displays or
|
|
20518
|
+
* saves.
|
|
20519
|
+
*
|
|
20520
|
+
* Every display blob becomes a blob: URL in the displaying page's own origin,
|
|
20521
|
+
* and a viewer can open one as a top-level document ("Open image in new tab",
|
|
20522
|
+
* dragging a thumbnail to the tab bar). A stored content_type is caller-supplied
|
|
20523
|
+
* (the public upload portal and any spark creator included), so a blob typed
|
|
20524
|
+
* image/svg+xml, text/html or any XML type would run that caller's script as
|
|
20525
|
+
* the page. Only types every browser renders inertly may therefore reach one,
|
|
20526
|
+
* decided by allowlist so an unknown or malformed type fails closed: the
|
|
20527
|
+
* essence is read by the platform's one media-type parser, and a declared value
|
|
20528
|
+
* that is not exactly one well-formed media type matches no entry.
|
|
20529
|
+
*
|
|
20530
|
+
* A save hands the browser a blob too, and a browser renames a saved copy by
|
|
20531
|
+
* the blob's type, by its own MIME table, refused extensions included:
|
|
20532
|
+
* Firefox saves `Invoice` handed as `application/x-javascript` as
|
|
20533
|
+
* `Invoice.js`, and `Invoice.pdf` handed as `image/svg+xml` as `Invoice.svg`,
|
|
20534
|
+
* and Chromium completes a name that has no extension from a blob's type
|
|
20535
|
+
* alike. Neither completes or replaces an extension by the type of a name
|
|
20536
|
+
* handed as application/octet-stream (docs/GOTCHAS.md). The name a file
|
|
20537
|
+
* saves under is completed by the MIME registry, which only the server
|
|
20538
|
+
* carries (Core answers it as `download_filename`, by ./media-type-node.js
|
|
20539
|
+
* downloadFilename), so a save hands the browser the display-safe type as
|
|
20540
|
+
* well: an inert type keeps its own, from which a browser completes a name
|
|
20541
|
+
* the registry left bare (`Recording` under `audio/flac` saves as
|
|
20542
|
+
* `Recording.flac`), and every other type goes as opaque bytes.
|
|
20543
|
+
*
|
|
20544
|
+
* The one rule for every surface that does this: the web console consumes these
|
|
20545
|
+
* functions directly (its file display path retypes through withDisplaySafeType,
|
|
20546
|
+
* as the one blob save does, saveBlob in ./browser-download.js), the x.sv pages
|
|
20547
|
+
* run this module's own source (DISPLAY_CONTENT_TYPE_SCRIPT), and Forge serves a
|
|
20548
|
+
* response inline on its own origin only when isInertDocumentType says so
|
|
20549
|
+
* (apps/forge/src/routes/decrypt.js). Forge and every client save hand an
|
|
20550
|
+
* inert type to the browser under its own type whatever the file's name, since
|
|
20551
|
+
* a browser renames a download by the type it is handed: an inert type is an
|
|
20552
|
+
* image, audio, video or PDF format, so whatever extension a browser gives its
|
|
20553
|
+
* copy opens it as what it is.
|
|
20554
|
+
*
|
|
20555
|
+
* BROWSER-SAFE: string handling and the platform's Blob, no Node built-ins.
|
|
20556
|
+
*/
|
|
20557
|
+
|
|
20558
|
+
/**
|
|
20559
|
+
* Raster formats: decoded as pixels by <img>, never parsed as a document that
|
|
20560
|
+
* could carry script. HEIC/HEIF stay listed for the case where on-the-fly JPEG
|
|
20561
|
+
* conversion fails and the original bytes are shown as-is.
|
|
20562
|
+
*/
|
|
20563
|
+
const INERT_IMAGE_TYPES = Object.freeze([
|
|
20564
|
+
'image/jpeg',
|
|
20565
|
+
'image/jpg',
|
|
20566
|
+
'image/pjpeg',
|
|
20567
|
+
'image/png',
|
|
20568
|
+
'image/x-png',
|
|
20569
|
+
'image/apng',
|
|
20570
|
+
'image/gif',
|
|
20571
|
+
'image/webp',
|
|
20572
|
+
'image/avif',
|
|
20573
|
+
'image/jxl',
|
|
20574
|
+
'image/bmp',
|
|
20575
|
+
'image/x-ms-bmp',
|
|
20576
|
+
'image/x-icon',
|
|
20577
|
+
'image/vnd.microsoft.icon',
|
|
20578
|
+
'image/tiff',
|
|
20579
|
+
'image/heic',
|
|
20580
|
+
'image/heif'
|
|
20581
|
+
]);
|
|
20582
|
+
|
|
20583
|
+
new Set(INERT_IMAGE_TYPES);
|
|
20584
|
+
|
|
20585
|
+
/**
|
|
20586
|
+
* The platform's one essence reader (./media-type.js), bound in this module's
|
|
20587
|
+
* own scope. The functions DISPLAY_CONTENT_TYPE_SCRIPT carries read it by this
|
|
20588
|
+
* name, which the page binds to the reader MEDIA_TYPE_SCRIPT declares, never
|
|
20589
|
+
* by its imported name: a module transform rewrites an imported name inside a
|
|
20590
|
+
* function's source (vitest's, which every suite runs this module under, turns
|
|
20591
|
+
* `mediaTypeEssence` into `__vite_ssr_import_0__.mediaTypeEssence`), a name no
|
|
20592
|
+
* page declares.
|
|
20593
|
+
*/
|
|
20594
|
+
const essenceOf = mediaTypeEssence;
|
|
20595
|
+
|
|
20596
|
+
/*
|
|
20597
|
+
* Audio and video formats, each under the types the MIME registry files it
|
|
20598
|
+
* under and the ones browsers and Apple's platforms report for it
|
|
20599
|
+
* (`audio/flac`, `audio/vnd.wave`, `audio/aiff`, Chromium's `video/matroska`
|
|
20600
|
+
* and `audio/matroska`, Firefox's `application/ogg` for a `.ogg` file, and,
|
|
20601
|
+
* where Chromium asks the platform: on macOS `video/avi` for a `.avi` file,
|
|
20602
|
+
* `video/x-ms-wma` for a `.wma` one and `audio/x-m4r` for an iPhone ringtone,
|
|
20603
|
+
* and on Windows `audio/vnd.dlna.adts` for a `.aac` one):
|
|
20604
|
+
* encoded sound and pictures, which a browser plays in its own player, never
|
|
20605
|
+
* as a scriptable document, or downloads under the extension its table names
|
|
20606
|
+
* for the type (`.mp3`, `.mov`, `.avi`, `.ogg`), which a desktop opens in a
|
|
20607
|
+
* media player.
|
|
20608
|
+
*
|
|
20609
|
+
* Never a playlist or a stream redirector (`audio/x-mpegurl`,
|
|
20610
|
+
* `audio/x-scpls`, `video/x-ms-asx`, `audio/x-pn-realaudio`): it names media
|
|
20611
|
+
* a player then fetches, and a browser downloads it whatever name it is
|
|
20612
|
+
* handed, saving it as `.m3u`, `.pls`, `.asx` (which Outlook blocks) or
|
|
20613
|
+
* `.ram`; nor `video/x-ms-asf`, under which the registry files the `.asx`
|
|
20614
|
+
* redirector too. An allowlist, so an audio or video type no entry names
|
|
20615
|
+
* fails closed, one with a structured-syntax suffix among them (`video/x+xml`,
|
|
20616
|
+
* which a navigated browser renders as an XML document, script included).
|
|
20617
|
+
*/
|
|
20618
|
+
|
|
20619
|
+
/** The audio formats: sound, which a browser plays in its player. */
|
|
20620
|
+
const INERT_AUDIO_TYPES = Object.freeze([
|
|
20621
|
+
'audio/3gpp',
|
|
20622
|
+
'audio/aac',
|
|
20623
|
+
'audio/x-aac',
|
|
20624
|
+
'audio/vnd.dlna.adts',
|
|
20625
|
+
'audio/aiff',
|
|
20626
|
+
'audio/x-aiff',
|
|
20627
|
+
'audio/amr',
|
|
20628
|
+
'audio/basic',
|
|
20629
|
+
'audio/flac',
|
|
20630
|
+
'audio/x-flac',
|
|
20631
|
+
'audio/matroska',
|
|
20632
|
+
'audio/x-matroska',
|
|
20633
|
+
'audio/midi',
|
|
20634
|
+
'audio/mp3',
|
|
20635
|
+
'audio/mpeg',
|
|
20636
|
+
'audio/mp4',
|
|
20637
|
+
'audio/x-m4a',
|
|
20638
|
+
'audio/x-m4r',
|
|
20639
|
+
'audio/ogg',
|
|
20640
|
+
'audio/wav',
|
|
20641
|
+
'audio/wave',
|
|
20642
|
+
'audio/vnd.wave',
|
|
20643
|
+
'audio/x-wav',
|
|
20644
|
+
'audio/webm',
|
|
20645
|
+
'audio/x-caf',
|
|
20646
|
+
'audio/x-ms-wma',
|
|
20647
|
+
'video/x-ms-wma'
|
|
20648
|
+
]);
|
|
20649
|
+
|
|
20650
|
+
/**
|
|
20651
|
+
* The Ogg container, as Firefox types a `.ogg` file: the one inert type that
|
|
20652
|
+
* does not say whether its files hold sound alone or pictures too. It renders
|
|
20653
|
+
* as a video, whose player plays either.
|
|
20654
|
+
*/
|
|
20655
|
+
const OGG_CONTAINER_TYPE = 'application/ogg';
|
|
20656
|
+
|
|
20657
|
+
/**
|
|
20658
|
+
* The video formats: pictures and sound, which a browser plays in its player,
|
|
20659
|
+
* the Ogg container among them (OGG_CONTAINER_TYPE).
|
|
20660
|
+
*/
|
|
20661
|
+
const INERT_VIDEO_TYPES = Object.freeze([
|
|
20662
|
+
'video/3gpp',
|
|
20663
|
+
'video/3gpp2',
|
|
20664
|
+
'video/matroska',
|
|
20665
|
+
'video/x-matroska',
|
|
20666
|
+
'video/mp2t',
|
|
20667
|
+
'video/mp4',
|
|
20668
|
+
'video/x-m4v',
|
|
20669
|
+
'video/mpeg',
|
|
20670
|
+
'video/ogg',
|
|
20671
|
+
OGG_CONTAINER_TYPE,
|
|
20672
|
+
'video/quicktime',
|
|
20673
|
+
'video/webm',
|
|
20674
|
+
'video/x-flv',
|
|
20675
|
+
'video/x-msvideo',
|
|
20676
|
+
'video/avi',
|
|
20677
|
+
'video/x-ms-wmv'
|
|
20678
|
+
]);
|
|
20679
|
+
|
|
20680
|
+
const PDF_TYPE = 'application/pdf';
|
|
20681
|
+
|
|
20682
|
+
/**
|
|
20683
|
+
* How each inert type renders as a top-level document, by essence
|
|
20684
|
+
* (inertRendering). The x.sv pages read it through
|
|
20685
|
+
* DISPLAY_CONTENT_TYPE_SCRIPT, which serializes it.
|
|
20686
|
+
*/
|
|
20687
|
+
const INERT_RENDERING = new Map([
|
|
20688
|
+
...INERT_IMAGE_TYPES.map((type) => [type, 'image']),
|
|
20689
|
+
...INERT_AUDIO_TYPES.map((type) => [type, 'audio']),
|
|
20690
|
+
...INERT_VIDEO_TYPES.map((type) => [type, 'video']),
|
|
20691
|
+
[PDF_TYPE, 'pdf']
|
|
20692
|
+
]);
|
|
20693
|
+
|
|
20694
|
+
/**
|
|
20695
|
+
* Every type a browser renders inertly as a top-level document, as an essence:
|
|
20696
|
+
* a raster image (INERT_IMAGE_TYPES), an audio or video format, or a PDF,
|
|
20697
|
+
* which the browser's own PDF viewer renders.
|
|
20698
|
+
*/
|
|
20699
|
+
Object.freeze([...INERT_RENDERING.keys()]);
|
|
20700
|
+
|
|
20701
|
+
const OPAQUE_CONTENT_TYPE = 'application/octet-stream';
|
|
20702
|
+
|
|
20703
|
+
/** isInertDocumentType over an essence already read (essenceOf), null for a value that is no media type. */
|
|
20704
|
+
function isInertDocumentEssence(type) {
|
|
20705
|
+
return INERT_RENDERING.has(type);
|
|
20706
|
+
}
|
|
20707
|
+
|
|
20708
|
+
/**
|
|
20709
|
+
* The type a blob a page hands the browser, to display or to save, may carry:
|
|
20710
|
+
* its own essence when the browser renders it inertly, otherwise
|
|
20711
|
+
* application/octet-stream, which a navigated blob URL downloads instead of
|
|
20712
|
+
* rendering and which no browser completes a saved name from.
|
|
20713
|
+
* @param {string|null|undefined} contentType
|
|
20714
|
+
* @returns {string}
|
|
20715
|
+
*/
|
|
20716
|
+
function displaySafeContentType(contentType) {
|
|
20717
|
+
const type = essenceOf(contentType);
|
|
20718
|
+
return isInertDocumentEssence(type) ? type : OPAQUE_CONTENT_TYPE;
|
|
20719
|
+
}
|
|
20720
|
+
|
|
20721
|
+
/**
|
|
20722
|
+
* A blob as a page hands it to the browser, to display or to save: retyped to
|
|
20723
|
+
* displaySafeContentType of its own type, or the blob itself when it already
|
|
20724
|
+
* carries that type. slice() retypes without copying the bytes.
|
|
20725
|
+
* @param {Blob} blob
|
|
20726
|
+
* @returns {Blob}
|
|
20727
|
+
*/
|
|
20728
|
+
function withDisplaySafeType(blob) {
|
|
20729
|
+
const safeType = displaySafeContentType(blob.type);
|
|
20730
|
+
return blob.type === safeType ? blob : blob.slice(0, blob.size, safeType);
|
|
20731
|
+
}
|
|
20732
|
+
|
|
20338
20733
|
/**
|
|
20339
20734
|
* Files brought to a message's composer by drag, drop and paste, handled
|
|
20340
20735
|
* alike by every composer that takes them: the console's reply composer and
|
|
@@ -20536,6 +20931,7 @@ const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
|
|
|
20536
20931
|
|
|
20537
20932
|
const PATHS = Object.freeze({
|
|
20538
20933
|
back: 'm14.5 6-6 6 6 6',
|
|
20934
|
+
arrowRight: 'M4 12h16m-6-6 6 6-6 6',
|
|
20539
20935
|
close: 'm6 6 12 12M18 6 6 18',
|
|
20540
20936
|
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',
|
|
20541
20937
|
check: 'm5 12 4 4L19 6',
|
|
@@ -20592,10 +20988,10 @@ function helpDeskIcon(name) {
|
|
|
20592
20988
|
* takes no files from its customers is refused in words
|
|
20593
20989
|
* (NO_CUSTOMER_FILES_COPY), and one brought while files cannot join is
|
|
20594
20990
|
* never the browser's to open in place of the unsent message.
|
|
20595
|
-
* - **
|
|
20596
|
-
*
|
|
20597
|
-
*
|
|
20598
|
-
*
|
|
20991
|
+
* - **Requirements.** A rejected file opens one modal with its reason and
|
|
20992
|
+
* the attachment rules. A selection shares that modal, and dismissing it
|
|
20993
|
+
* leaves later refusals from the same selection in their chips. Accepted
|
|
20994
|
+
* images have local previews, including while waiting for sign-in.
|
|
20599
20995
|
* - **Uploading.** The browser's check (attachmentRefusal) first, then the
|
|
20600
20996
|
* host's transport: its target (the request a reply belongs to, or the
|
|
20601
20997
|
* draft a new request uploads to, which may not exist yet: the file then
|
|
@@ -20660,21 +21056,27 @@ const COMPOSER_CSS = `
|
|
|
20660
21056
|
.svhd-composer .svhd-composer-drop{position:absolute;inset:0;z-index:1;display:flex;align-items:center;justify-content:center;margin:0;padding:12px;border-radius:5px;background:${HELP_DESK_COLORS.selection};color:${HELP_DESK_ACCENT.ink};font-size:15px;font-weight:600;line-height:1.4;text-align:center;pointer-events:none}
|
|
20661
21057
|
.svhd-composer .svhd-composer-toolbar{display:flex;align-items:center;flex-wrap:wrap;gap:0 4px;padding:0 4px;border-top:1px solid ${HELP_DESK_COLORS.fillStrong}}
|
|
20662
21058
|
.svhd-composer .svhd-composer-attach{display:inline-flex;align-items:center;gap:6px;min-height:44px;margin:0;padding:0 8px;border:0;border-radius:6px;background:transparent;color:${HELP_DESK_COLORS.body};font-family:inherit;font-size:14px;font-weight:600;line-height:1.4;cursor:pointer}
|
|
20663
|
-
.svhd-composer .svhd-composer-attach:hover
|
|
21059
|
+
.svhd-composer .svhd-composer-attach:hover{background:${HELP_DESK_COLORS.fill};color:${HELP_DESK_COLORS.ink}}
|
|
20664
21060
|
.svhd-composer .svhd-composer-attach:disabled{opacity:.6;cursor:default}
|
|
20665
21061
|
.svhd-composer .svhd-composer-attach svg{display:block;width:18px;height:18px}
|
|
20666
|
-
.svhd-composer .svhd-composer-
|
|
20667
|
-
.svhd-composer .svhd-composer-
|
|
20668
|
-
.svhd-composer .svhd-composer-
|
|
20669
|
-
.svhd-composer .svhd-composer-
|
|
20670
|
-
.svhd-composer .svhd-composer-
|
|
20671
|
-
.svhd-composer .svhd-composer-
|
|
20672
|
-
.svhd-composer .svhd-composer-
|
|
20673
|
-
.svhd-composer .svhd-composer-
|
|
20674
|
-
.svhd-composer .svhd-composer-
|
|
21062
|
+
.svhd-composer .svhd-composer-validation-dialog{position:fixed;inset:0;width:min(480px,calc(100vw - 32px));max-height:calc(100dvh - 32px);margin:auto;padding:0;overflow:auto;border:1px solid ${HELP_DESK_COLORS.lineStrong};border-radius:12px;background:${HELP_DESK_COLORS.surface};color:${HELP_DESK_COLORS.ink};font:400 15px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;text-align:left;overscroll-behavior:contain}
|
|
21063
|
+
.svhd-composer .svhd-composer-validation-dialog::backdrop{background:color-mix(in srgb,${HELP_DESK_COLORS.modalBackdrop} 60%,transparent)}
|
|
21064
|
+
.svhd-composer .svhd-composer-validation-header{display:flex;align-items:center;gap:12px;padding:16px 16px 8px 24px}
|
|
21065
|
+
.svhd-composer .svhd-composer-validation-title{flex:1;min-width:0;margin:0;font-family:inherit;font-size:20px;font-weight:600;line-height:1.3;overflow-wrap:anywhere}
|
|
21066
|
+
.svhd-composer .svhd-composer-validation-close{display:grid;place-items:center;flex:none;width:44px;height:44px;margin:0;padding:0;border:0;border-radius:6px;background:transparent;color:${HELP_DESK_COLORS.body};cursor:pointer}
|
|
21067
|
+
.svhd-composer .svhd-composer-validation-close:hover,.svhd-composer .svhd-attachment-remove:hover{background:${HELP_DESK_COLORS.fillStrong};color:${HELP_DESK_COLORS.ink}}
|
|
21068
|
+
.svhd-composer .svhd-composer-validation-close svg,.svhd-composer .svhd-attachment-remove svg{display:block;width:16px;height:16px}
|
|
21069
|
+
.svhd-composer .svhd-composer-refusals{display:grid;gap:12px;margin:0;padding:0 24px 24px;list-style:none;color:${HELP_DESK_COLORS.body};overflow-wrap:anywhere}
|
|
21070
|
+
.svhd-composer .svhd-composer-refusals strong{display:block;margin-bottom:2px;color:${HELP_DESK_COLORS.ink};font-weight:600}
|
|
21071
|
+
.svhd-composer .svhd-composer-requirements{padding:20px 24px;border-top:1px solid ${HELP_DESK_COLORS.fillStrong};background:${HELP_DESK_COLORS.canvas};color:${HELP_DESK_COLORS.body};font-size:13px;line-height:1.5}
|
|
21072
|
+
.svhd-composer .svhd-composer-requirements h3{margin:0 0 8px;color:${HELP_DESK_COLORS.ink};font-family:inherit;font-size:14px;font-weight:600}
|
|
21073
|
+
.svhd-composer .svhd-composer-requirements p{margin:0}
|
|
21074
|
+
.svhd-composer .svhd-composer-requirements p+p{margin-top:8px}
|
|
20675
21075
|
.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}}
|
|
20676
21076
|
.svhd-composer .svhd-attachment-chips:empty{display:none}
|
|
20677
21077
|
.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}
|
|
21078
|
+
.svhd-composer .svhd-attachment-thumbnail{grid-column:1/-1;display:block;width:100%;height:96px;object-fit:contain;margin:8px 0;background:${HELP_DESK_COLORS.field};border-radius:4px}
|
|
21079
|
+
.svhd-composer .svhd-attachment-preview-unavailable{grid-column:1/-1;margin:8px 8px 0 0;color:${HELP_DESK_COLORS.muted};font-size:12px}
|
|
20678
21080
|
.svhd-composer .svhd-attachment-name{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:600;color:${HELP_DESK_COLORS.ink}}
|
|
20679
21081
|
.svhd-composer .svhd-attachment-status{grid-column:1;padding-right:8px;color:${HELP_DESK_COLORS.body};font-size:12px;overflow-wrap:anywhere}
|
|
20680
21082
|
.svhd-composer .svhd-attachment-status.svhd-composer-problem{color:${HELP_DESK_COLORS.error}}
|
|
@@ -20682,7 +21084,7 @@ const COMPOSER_CSS = `
|
|
|
20682
21084
|
.svhd-composer .svhd-attachment-remove{display:grid;place-items:center;width:44px;height:44px;min-height:44px;margin:0;padding:0;border:0;border-radius:6px;background:transparent;color:${HELP_DESK_COLORS.body};cursor:pointer}
|
|
20683
21085
|
.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}
|
|
20684
21086
|
.svhd-composer .svhd-attachment-remove:disabled,.svhd-composer .svhd-attachment-retry:disabled{opacity:.6;cursor:default}
|
|
20685
|
-
.svhd-composer .svhd-composer-attach:focus-visible,.svhd-composer .svhd-composer-
|
|
21087
|
+
.svhd-composer .svhd-composer-attach:focus-visible,.svhd-composer .svhd-composer-validation-close:focus-visible,.svhd-composer .svhd-attachment-remove:focus-visible,.svhd-composer .svhd-attachment-retry:focus-visible{${INSET_RING}}
|
|
20686
21088
|
.svhd-composer-notice{margin:0;color:${HELP_DESK_COLORS.error};font-size:14px;line-height:1.5}
|
|
20687
21089
|
.svhd-composer [hidden],.svhd-composer-notice[hidden]{display:none!important}
|
|
20688
21090
|
`;
|
|
@@ -20719,8 +21121,8 @@ const RECEIVED_COPY = 'File received. Waiting for storage confirmation.';
|
|
|
20719
21121
|
const UPLOAD_FAILED_COPY = "This file couldn't be uploaded. Try again or remove it.";
|
|
20720
21122
|
const UPLOADING_COPY = 'Uploading';
|
|
20721
21123
|
const VERIFYING_COPY = 'Verifying stored file';
|
|
20722
|
-
/**
|
|
20723
|
-
const
|
|
21124
|
+
/** Requirements appear only after a file is refused. */
|
|
21125
|
+
const VALIDATION_TITLE = 'Unable to attach files';
|
|
20724
21126
|
const ACCEPTED_KINDS_COPY = `You can attach ${ACCEPTED_ATTACHMENTS_COPY}.`;
|
|
20725
21127
|
|
|
20726
21128
|
/** What a message's files still need before it can be sent, from the most pressing. */
|
|
@@ -20859,9 +21261,7 @@ function createHelpDeskComposer(options) {
|
|
|
20859
21261
|
const zone = dropZone ?? frame;
|
|
20860
21262
|
const fields = [textarea, ...pasteFields];
|
|
20861
21263
|
|
|
20862
|
-
// The
|
|
20863
|
-
// extensions a request takes first, never the check), and its (?) tip,
|
|
20864
|
-
// whose limits also describe Attach.
|
|
21264
|
+
// The chooser filters names; the canonical attachment check decides.
|
|
20865
21265
|
const input = document.createElement('input');
|
|
20866
21266
|
input.type = 'file';
|
|
20867
21267
|
input.name = 'attachments';
|
|
@@ -20869,40 +21269,13 @@ function createHelpDeskComposer(options) {
|
|
|
20869
21269
|
input.accept = ATTACHMENT_INPUT_ACCEPT;
|
|
20870
21270
|
input.hidden = true;
|
|
20871
21271
|
input.tabIndex = -1;
|
|
20872
|
-
const hint = document.createElement('p');
|
|
20873
|
-
hint.id = `${textarea.id}-attachment-hint`;
|
|
20874
|
-
hint.textContent = CUSTOMER_ATTACHMENTS_HINT;
|
|
20875
|
-
const kinds = document.createElement('p');
|
|
20876
|
-
kinds.textContent = ACCEPTED_KINDS_COPY;
|
|
20877
21272
|
const attach = button$1('svhd-composer-attach', 'Attach files');
|
|
20878
|
-
attach.setAttribute('aria-describedby', hint.id);
|
|
20879
21273
|
const attachText = document.createElement('span');
|
|
20880
21274
|
attachText.textContent = 'Attach';
|
|
20881
21275
|
attach.append(helpDeskIcon('paperclip'), attachText);
|
|
20882
|
-
const helpPanel = document.createElement('div');
|
|
20883
|
-
helpPanel.id = `${textarea.id}-attachment-help`;
|
|
20884
|
-
helpPanel.className = 'svhd-composer-help-panel';
|
|
20885
|
-
helpPanel.setAttribute('role', 'region');
|
|
20886
|
-
helpPanel.setAttribute('aria-label', HELP_TITLE);
|
|
20887
|
-
helpPanel.hidden = true;
|
|
20888
|
-
const helpCopy = document.createElement('div');
|
|
20889
|
-
helpCopy.className = 'svhd-composer-help-copy';
|
|
20890
|
-
helpCopy.append(hint, kinds);
|
|
20891
|
-
const helpClose = button$1('svhd-composer-help-close', 'Close');
|
|
20892
|
-
helpClose.title = 'Close';
|
|
20893
|
-
helpClose.append(helpDeskIcon('close'));
|
|
20894
|
-
helpPanel.append(helpCopy, helpClose);
|
|
20895
|
-
const helpTrigger = button$1('svhd-composer-help', `Help: ${HELP_TITLE}`);
|
|
20896
|
-
helpTrigger.setAttribute('aria-expanded', 'false');
|
|
20897
|
-
helpTrigger.setAttribute('aria-controls', helpPanel.id);
|
|
20898
|
-
const glyph = document.createElement('span');
|
|
20899
|
-
glyph.className = 'svhd-composer-help-glyph';
|
|
20900
|
-
glyph.setAttribute('aria-hidden', 'true');
|
|
20901
|
-
glyph.textContent = '?';
|
|
20902
|
-
helpTrigger.append(glyph);
|
|
20903
21276
|
const toolbar = document.createElement('div');
|
|
20904
21277
|
toolbar.className = 'svhd-composer-toolbar';
|
|
20905
|
-
toolbar.append(attach,
|
|
21278
|
+
toolbar.append(attach, input);
|
|
20906
21279
|
const list = document.createElement('ul');
|
|
20907
21280
|
list.className = 'svhd-attachment-chips';
|
|
20908
21281
|
list.setAttribute('aria-label', 'Attached files');
|
|
@@ -20914,10 +21287,151 @@ function createHelpDeskComposer(options) {
|
|
|
20914
21287
|
let locked = false;
|
|
20915
21288
|
let pickingDisabled = false;
|
|
20916
21289
|
let destroyed = false;
|
|
21290
|
+
let validation = null;
|
|
20917
21291
|
const accepting = () => transport !== null && !locked && !pickingDisabled && !destroyed;
|
|
20918
21292
|
const current = (entry, ownRevision) =>
|
|
20919
21293
|
!destroyed && revision === ownRevision && entries.includes(entry) && !entry.controller?.signal.aborted;
|
|
20920
21294
|
|
|
21295
|
+
/** A selection keeps its refusal lifecycle even when its files settle at different times. */
|
|
21296
|
+
const selection = () => ({
|
|
21297
|
+
dismissed: false,
|
|
21298
|
+
returnFocus: document.activeElement instanceof HTMLElement && document.activeElement !== document.body
|
|
21299
|
+
? document.activeElement : textarea
|
|
21300
|
+
});
|
|
21301
|
+
|
|
21302
|
+
function dismissValidation() {
|
|
21303
|
+
const shown = validation;
|
|
21304
|
+
if (!shown) return;
|
|
21305
|
+
validation = null;
|
|
21306
|
+
for (const batch of shown.batches) batch.dismissed = true;
|
|
21307
|
+
if (shown.dialog.open) shown.dialog.close();
|
|
21308
|
+
shown.dialog.remove();
|
|
21309
|
+
document.documentElement.style.overflow = shown.overflow;
|
|
21310
|
+
if (!destroyed) {
|
|
21311
|
+
const target = shown.returnFocus.isConnected && !shown.returnFocus.disabled ? shown.returnFocus : textarea;
|
|
21312
|
+
target.focus();
|
|
21313
|
+
}
|
|
21314
|
+
}
|
|
21315
|
+
|
|
21316
|
+
/** Exact refusals share one top-layer dialog; later files never steal focus from its reader. */
|
|
21317
|
+
function reportRefusal(batch, key, filename, copy) {
|
|
21318
|
+
if (destroyed || batch.dismissed) return;
|
|
21319
|
+
let shown = validation;
|
|
21320
|
+
if (!shown) {
|
|
21321
|
+
const dialog = document.createElement('dialog');
|
|
21322
|
+
dialog.className = 'svhd-composer-validation-dialog';
|
|
21323
|
+
const title = document.createElement('h2');
|
|
21324
|
+
title.id = `${textarea.id}-attachment-validation-title`;
|
|
21325
|
+
title.className = 'svhd-composer-validation-title';
|
|
21326
|
+
title.textContent = VALIDATION_TITLE;
|
|
21327
|
+
dialog.setAttribute('aria-labelledby', title.id);
|
|
21328
|
+
const close = button$1('svhd-composer-validation-close', 'Close');
|
|
21329
|
+
close.title = 'Close';
|
|
21330
|
+
close.append(helpDeskIcon('close'));
|
|
21331
|
+
const header = document.createElement('div');
|
|
21332
|
+
header.className = 'svhd-composer-validation-header';
|
|
21333
|
+
header.append(title, close);
|
|
21334
|
+
const reasons = document.createElement('ul');
|
|
21335
|
+
reasons.className = 'svhd-composer-refusals';
|
|
21336
|
+
reasons.id = `${textarea.id}-attachment-refusals`;
|
|
21337
|
+
dialog.setAttribute('aria-describedby', reasons.id);
|
|
21338
|
+
reasons.setAttribute('aria-live', 'polite');
|
|
21339
|
+
const requirements = document.createElement('div');
|
|
21340
|
+
requirements.className = 'svhd-composer-requirements';
|
|
21341
|
+
const heading = document.createElement('h3');
|
|
21342
|
+
heading.textContent = 'What you can attach';
|
|
21343
|
+
const limits = document.createElement('p');
|
|
21344
|
+
limits.textContent = deskRefusesFiles ? NO_CUSTOMER_FILES_COPY : CUSTOMER_ATTACHMENTS_HINT;
|
|
21345
|
+
requirements.append(heading, limits);
|
|
21346
|
+
if (!deskRefusesFiles) {
|
|
21347
|
+
const kinds = document.createElement('p');
|
|
21348
|
+
kinds.textContent = ACCEPTED_KINDS_COPY;
|
|
21349
|
+
requirements.append(kinds);
|
|
21350
|
+
}
|
|
21351
|
+
dialog.append(header, reasons, requirements);
|
|
21352
|
+
shown = { dialog, reasons, close, issues: new Map(), batches: new Set(), returnFocus: batch.returnFocus, overflow: document.documentElement.style.overflow };
|
|
21353
|
+
validation = shown;
|
|
21354
|
+
close.addEventListener('click', () => dismissValidation());
|
|
21355
|
+
dialog.addEventListener('cancel', (event) => { event.preventDefault(); event.stopPropagation(); dismissValidation(); });
|
|
21356
|
+
dialog.addEventListener('close', () => { if (validation === shown) dismissValidation(); });
|
|
21357
|
+
dialog.addEventListener('keydown', (event) => {
|
|
21358
|
+
if (event.key === 'Escape') {
|
|
21359
|
+
event.preventDefault();
|
|
21360
|
+
event.stopPropagation();
|
|
21361
|
+
dismissValidation();
|
|
21362
|
+
} else if (event.key === 'Tab') {
|
|
21363
|
+
// Close is this dialog's one focusable control; keep keyboard focus with it.
|
|
21364
|
+
event.preventDefault();
|
|
21365
|
+
close.focus();
|
|
21366
|
+
}
|
|
21367
|
+
});
|
|
21368
|
+
const outside = (event) => {
|
|
21369
|
+
if (event.target !== dialog) return false;
|
|
21370
|
+
const bounds = dialog.getBoundingClientRect();
|
|
21371
|
+
return event.clientX < bounds.left || event.clientX > bounds.right || event.clientY < bounds.top || event.clientY > bounds.bottom;
|
|
21372
|
+
};
|
|
21373
|
+
let backdropPress = false;
|
|
21374
|
+
dialog.addEventListener('pointerdown', (event) => { backdropPress = outside(event); });
|
|
21375
|
+
dialog.addEventListener('click', (event) => { if (backdropPress && outside(event)) dismissValidation(); backdropPress = false; });
|
|
21376
|
+
frame.append(dialog);
|
|
21377
|
+
}
|
|
21378
|
+
shown.batches.add(batch);
|
|
21379
|
+
let reason = shown.issues.get(key);
|
|
21380
|
+
if (!reason) {
|
|
21381
|
+
reason = document.createElement('li');
|
|
21382
|
+
shown.issues.set(key, reason);
|
|
21383
|
+
shown.reasons.append(reason);
|
|
21384
|
+
}
|
|
21385
|
+
const text = document.createElement('span');
|
|
21386
|
+
text.textContent = copy;
|
|
21387
|
+
reason.replaceChildren();
|
|
21388
|
+
if (filename) {
|
|
21389
|
+
const name = document.createElement('strong');
|
|
21390
|
+
name.textContent = filename;
|
|
21391
|
+
reason.append(name);
|
|
21392
|
+
}
|
|
21393
|
+
reason.append(text);
|
|
21394
|
+
if (!shown.dialog.open) {
|
|
21395
|
+
shown.dialog.showModal();
|
|
21396
|
+
document.documentElement.style.overflow = 'hidden';
|
|
21397
|
+
shown.close.focus();
|
|
21398
|
+
}
|
|
21399
|
+
}
|
|
21400
|
+
|
|
21401
|
+
function releasePreview(entry) {
|
|
21402
|
+
if (!entry.previewUrl) return;
|
|
21403
|
+
URL.revokeObjectURL(entry.previewUrl);
|
|
21404
|
+
entry.previewUrl = null;
|
|
21405
|
+
}
|
|
21406
|
+
|
|
21407
|
+
/** Local validated images need no transfer; every blob is inert even if its declared MIME is hostile. */
|
|
21408
|
+
function preview(entry) {
|
|
21409
|
+
if (entry.previewAttempted || !ACCEPTED_ATTACHMENT_KINDS.images.includes(lastExtension(entry.file.name))) return;
|
|
21410
|
+
entry.previewAttempted = true;
|
|
21411
|
+
const image = document.createElement('img');
|
|
21412
|
+
image.className = 'svhd-attachment-thumbnail';
|
|
21413
|
+
image.alt = `Preview of ${entry.file.name}`;
|
|
21414
|
+
image.decoding = 'async';
|
|
21415
|
+
const unavailable = () => {
|
|
21416
|
+
releasePreview(entry);
|
|
21417
|
+
image.remove();
|
|
21418
|
+
if (destroyed || !entries.includes(entry)) return;
|
|
21419
|
+
const fallback = document.createElement('span');
|
|
21420
|
+
fallback.className = 'svhd-attachment-preview-unavailable';
|
|
21421
|
+
fallback.textContent = 'Preview unavailable';
|
|
21422
|
+
entry.row.prepend(fallback);
|
|
21423
|
+
};
|
|
21424
|
+
image.addEventListener('error', unavailable, { once: true });
|
|
21425
|
+
try {
|
|
21426
|
+
entry.previewUrl = URL.createObjectURL(withDisplaySafeType(entry.file));
|
|
21427
|
+
image.src = entry.previewUrl;
|
|
21428
|
+
entry.row.prepend(image);
|
|
21429
|
+
} catch {
|
|
21430
|
+
// A browser that cannot create a preview still uploads the original file.
|
|
21431
|
+
unavailable();
|
|
21432
|
+
}
|
|
21433
|
+
}
|
|
21434
|
+
|
|
20921
21435
|
// A refusal of files is an alert only while it shows, as a field's error is.
|
|
20922
21436
|
function setNotice(text) {
|
|
20923
21437
|
notice.textContent = text ?? '';
|
|
@@ -20978,9 +21492,12 @@ function createHelpDeskComposer(options) {
|
|
|
20978
21492
|
if (!stillCurrent()) return;
|
|
20979
21493
|
if (refusal) {
|
|
20980
21494
|
entry.retryable = false;
|
|
20981
|
-
|
|
21495
|
+
const copy = refusalCopy(refusal, CUSTOMER_ATTACHMENT_MAX_BYTES);
|
|
21496
|
+
show(entry, FILE_STATE.REFUSED, copy);
|
|
21497
|
+
reportRefusal(entry.batch, entry, entry.file.name, copy);
|
|
20982
21498
|
return;
|
|
20983
21499
|
}
|
|
21500
|
+
preview(entry);
|
|
20984
21501
|
request = 'host';
|
|
20985
21502
|
const target = await transport.target();
|
|
20986
21503
|
if (!stillCurrent()) return;
|
|
@@ -21026,7 +21543,9 @@ function createHelpDeskComposer(options) {
|
|
|
21026
21543
|
entry.attachmentId = upload.attachment_id;
|
|
21027
21544
|
if (Number.isSafeInteger(upload.max_bytes) && upload.max_bytes > 0 && entry.file.size > upload.max_bytes) {
|
|
21028
21545
|
entry.retryable = false;
|
|
21029
|
-
|
|
21546
|
+
const copy = tooLargeCopy(upload.max_bytes);
|
|
21547
|
+
show(entry, FILE_STATE.FAILED, copy);
|
|
21548
|
+
reportRefusal(entry.batch, entry, entry.file.name, copy);
|
|
21030
21549
|
return;
|
|
21031
21550
|
}
|
|
21032
21551
|
entry.progress.value = 0;
|
|
@@ -21059,6 +21578,7 @@ function createHelpDeskComposer(options) {
|
|
|
21059
21578
|
const problem = uploadProblem(refusalOf(request, error), organization);
|
|
21060
21579
|
entry.retryable = problem.retryable;
|
|
21061
21580
|
show(entry, FILE_STATE.FAILED, problem.copy);
|
|
21581
|
+
if (!problem.retryable) reportRefusal(entry.batch, entry, entry.file.name, problem.copy);
|
|
21062
21582
|
} finally {
|
|
21063
21583
|
if (entry.controller === controller) entry.controller = null;
|
|
21064
21584
|
if (entry.operation === operation) entry.operation = null;
|
|
@@ -21091,6 +21611,7 @@ function createHelpDeskComposer(options) {
|
|
|
21091
21611
|
const refocus = document.activeElement === entry.remove;
|
|
21092
21612
|
const index = entries.indexOf(entry);
|
|
21093
21613
|
entry.controller?.abort();
|
|
21614
|
+
releasePreview(entry);
|
|
21094
21615
|
entries = entries.filter((candidate) => candidate !== entry);
|
|
21095
21616
|
entry.row.remove();
|
|
21096
21617
|
setNotice(null);
|
|
@@ -21100,13 +21621,14 @@ function createHelpDeskComposer(options) {
|
|
|
21100
21621
|
if (refocus) (entries[Math.min(index, entries.length - 1)]?.remove ?? attach).focus();
|
|
21101
21622
|
}
|
|
21102
21623
|
|
|
21103
|
-
function add(files) {
|
|
21624
|
+
function add(files, batch = selection()) {
|
|
21104
21625
|
if (!accepting()) return;
|
|
21105
21626
|
const incoming = Array.from(files);
|
|
21106
21627
|
if (incoming.length === 0) return;
|
|
21107
21628
|
const counted = entries.filter((entry) => entry.state !== FILE_STATE.REFUSED).length;
|
|
21108
21629
|
const room = Math.max(0, MAX_ATTACHMENTS_PER_MESSAGE - counted);
|
|
21109
21630
|
setNotice(incoming.length > room ? LIMIT_COPY : null);
|
|
21631
|
+
if (incoming.length > room) reportRefusal(batch, batch, null, LIMIT_COPY);
|
|
21110
21632
|
for (const file of incoming.slice(0, room)) {
|
|
21111
21633
|
const row = document.createElement('li');
|
|
21112
21634
|
row.className = 'svhd-attachment-chip';
|
|
@@ -21133,11 +21655,14 @@ function createHelpDeskComposer(options) {
|
|
|
21133
21655
|
const entry = {
|
|
21134
21656
|
file, row, status, progress, remove: removeButton, retry,
|
|
21135
21657
|
state: FILE_STATE.QUEUED, retryable: false, controller: null, operation: null,
|
|
21136
|
-
target: null, attachmentId: null, sessionUrl: null
|
|
21658
|
+
target: null, attachmentId: null, sessionUrl: null, batch, previewUrl: null, previewAttempted: false
|
|
21137
21659
|
};
|
|
21138
21660
|
removeButton.addEventListener('click', () => remove(entry));
|
|
21139
21661
|
retry.addEventListener('click', () => {
|
|
21140
|
-
if (!locked && entry.retryable)
|
|
21662
|
+
if (!locked && entry.retryable) {
|
|
21663
|
+
entry.batch = selection();
|
|
21664
|
+
void run(entry);
|
|
21665
|
+
}
|
|
21141
21666
|
});
|
|
21142
21667
|
row.append(name, removeButton, status, retry, progress);
|
|
21143
21668
|
list.append(row);
|
|
@@ -21161,13 +21686,18 @@ function createHelpDeskComposer(options) {
|
|
|
21161
21686
|
drop.hidden = !value;
|
|
21162
21687
|
}
|
|
21163
21688
|
function refuseFiles() {
|
|
21164
|
-
if (!notice.hidden && notice.textContent === NO_CUSTOMER_FILES_COPY) return;
|
|
21165
21689
|
setNotice(NO_CUSTOMER_FILES_COPY);
|
|
21690
|
+
const batch = selection();
|
|
21691
|
+
reportRefusal(batch, batch, null, NO_CUSTOMER_FILES_COPY);
|
|
21166
21692
|
}
|
|
21167
21693
|
// A dropped folder is left out, and said so beside any refusal the files with it met.
|
|
21168
21694
|
function attachBrought(files, folders) {
|
|
21169
|
-
|
|
21170
|
-
if (
|
|
21695
|
+
const batch = selection();
|
|
21696
|
+
if (files.length > 0) add(files, batch);
|
|
21697
|
+
if (folders > 0) {
|
|
21698
|
+
setNotice(files.length > 0 && !notice.hidden ? `${FOLDER_REFUSAL_COPY} ${notice.textContent}` : FOLDER_REFUSAL_COPY);
|
|
21699
|
+
reportRefusal(batch, 'folders', null, FOLDER_REFUSAL_COPY);
|
|
21700
|
+
}
|
|
21171
21701
|
}
|
|
21172
21702
|
const fileEvents = composerFileEvents({
|
|
21173
21703
|
action: fileAction,
|
|
@@ -21178,33 +21708,6 @@ function createHelpDeskComposer(options) {
|
|
|
21178
21708
|
refuse: refuseFiles
|
|
21179
21709
|
});
|
|
21180
21710
|
|
|
21181
|
-
// The (?) tip: a disclosure that closes by its trigger, Escape, its close
|
|
21182
|
-
// button (focus back on the trigger), a press outside it, or focus leaving it.
|
|
21183
|
-
const inTip = (node) => node instanceof Node && (helpTrigger.contains(node) || helpPanel.contains(node));
|
|
21184
|
-
function setHelpOpen(open) {
|
|
21185
|
-
helpPanel.hidden = !open;
|
|
21186
|
-
helpTrigger.setAttribute('aria-expanded', String(open));
|
|
21187
|
-
if (open) document.addEventListener('pointerdown', onPressOutsideHelp);
|
|
21188
|
-
else document.removeEventListener('pointerdown', onPressOutsideHelp);
|
|
21189
|
-
}
|
|
21190
|
-
function onPressOutsideHelp(event) {
|
|
21191
|
-
if (!inTip(event.target)) setHelpOpen(false);
|
|
21192
|
-
}
|
|
21193
|
-
const onHelpToggle = () => setHelpOpen(helpPanel.hidden);
|
|
21194
|
-
const onHelpClose = () => {
|
|
21195
|
-
setHelpOpen(false);
|
|
21196
|
-
helpTrigger.focus();
|
|
21197
|
-
};
|
|
21198
|
-
// Escape is the tip's alone while it is open: a dialog the form sits in leaves a handled key alone.
|
|
21199
|
-
const onHelpKey = (event) => {
|
|
21200
|
-
if (event.key !== 'Escape' || helpPanel.hidden) return;
|
|
21201
|
-
event.preventDefault();
|
|
21202
|
-
onHelpClose();
|
|
21203
|
-
};
|
|
21204
|
-
const onHelpFocusOut = (event) => {
|
|
21205
|
-
if (!helpPanel.hidden && event.relatedTarget && !inTip(event.relatedTarget)) setHelpOpen(false);
|
|
21206
|
-
};
|
|
21207
|
-
|
|
21208
21711
|
// A desk's refusal of files gives way once the customer writes on.
|
|
21209
21712
|
const onInput = () => {
|
|
21210
21713
|
if (!transport) setNotice(null);
|
|
@@ -21228,19 +21731,15 @@ function createHelpDeskComposer(options) {
|
|
|
21228
21731
|
}
|
|
21229
21732
|
input.addEventListener('change', onChoose);
|
|
21230
21733
|
attach.addEventListener('click', onAttach);
|
|
21231
|
-
helpTrigger.addEventListener('click', onHelpToggle);
|
|
21232
|
-
helpClose.addEventListener('click', onHelpClose);
|
|
21233
|
-
for (const part of [helpTrigger, helpPanel]) {
|
|
21234
|
-
part.addEventListener('keydown', onHelpKey);
|
|
21235
|
-
part.addEventListener('focusout', onHelpFocusOut);
|
|
21236
|
-
}
|
|
21237
21734
|
|
|
21238
21735
|
function clear(keepAttached = false) {
|
|
21239
21736
|
revision += 1;
|
|
21737
|
+
dismissValidation();
|
|
21240
21738
|
const previous = entries;
|
|
21241
21739
|
entries = [];
|
|
21242
21740
|
for (const entry of previous) {
|
|
21243
21741
|
entry.controller?.abort();
|
|
21742
|
+
releasePreview(entry);
|
|
21244
21743
|
if (!keepAttached || entry.state !== FILE_STATE.COMPLETE) void cancel(entry.target, entry.attachmentId);
|
|
21245
21744
|
}
|
|
21246
21745
|
list.replaceChildren();
|
|
@@ -21288,7 +21787,6 @@ function createHelpDeskComposer(options) {
|
|
|
21288
21787
|
destroy(keepAttached = false) {
|
|
21289
21788
|
destroyed = true;
|
|
21290
21789
|
clear(keepAttached);
|
|
21291
|
-
setHelpOpen(false);
|
|
21292
21790
|
zone.removeEventListener('dragenter', fileEvents.dragOver);
|
|
21293
21791
|
zone.removeEventListener('dragover', fileEvents.dragOver);
|
|
21294
21792
|
zone.removeEventListener('dragleave', fileEvents.dragLeave);
|
|
@@ -21299,12 +21797,6 @@ function createHelpDeskComposer(options) {
|
|
|
21299
21797
|
}
|
|
21300
21798
|
input.removeEventListener('change', onChoose);
|
|
21301
21799
|
attach.removeEventListener('click', onAttach);
|
|
21302
|
-
helpTrigger.removeEventListener('click', onHelpToggle);
|
|
21303
|
-
helpClose.removeEventListener('click', onHelpClose);
|
|
21304
|
-
for (const part of [helpTrigger, helpPanel]) {
|
|
21305
|
-
part.removeEventListener('keydown', onHelpKey);
|
|
21306
|
-
part.removeEventListener('focusout', onHelpFocusOut);
|
|
21307
|
-
}
|
|
21308
21800
|
}
|
|
21309
21801
|
};
|
|
21310
21802
|
}
|
|
@@ -21452,6 +21944,7 @@ function saveFormDraft(deskId, requesterId, value) {
|
|
|
21452
21944
|
catch { /* Storage is optional; the live form keeps its composition. */ }
|
|
21453
21945
|
}
|
|
21454
21946
|
|
|
21947
|
+
const HELP_DESK_FORM_TITLE = 'Open a Support Ticket';
|
|
21455
21948
|
let formSequence = 0;
|
|
21456
21949
|
/**
|
|
21457
21950
|
* The desk API's refusal of a file's draft or upload, as the composer reads
|
|
@@ -21590,10 +22083,9 @@ function companySignInUrl(value) {
|
|
|
21590
22083
|
* A confirmed send replaces the form with its confirmation.
|
|
21591
22084
|
*
|
|
21592
22085
|
* The request is a summary and optional details, in a composer that also
|
|
21593
|
-
* takes files. A signed-out widget customer writes it
|
|
21594
|
-
*
|
|
21595
|
-
*
|
|
21596
|
-
* beside the request.
|
|
22086
|
+
* takes files. A signed-out widget customer writes it before continuing to
|
|
22087
|
+
* sign-in, where one button opens the native sign-in window and sends it. A
|
|
22088
|
+
* signed-in customer can switch account or sign out beside the request.
|
|
21597
22089
|
*/
|
|
21598
22090
|
function mountHelpDeskForm(client, options) {
|
|
21599
22091
|
const target = resolveTarget(options.target);
|
|
@@ -21611,22 +22103,16 @@ function mountHelpDeskForm(client, options) {
|
|
|
21611
22103
|
form.className = 'svhd-form';
|
|
21612
22104
|
form.noValidate = true;
|
|
21613
22105
|
shell.body.append(form);
|
|
21614
|
-
/** A step's heading
|
|
21615
|
-
function stepHead(id, title
|
|
22106
|
+
/** A step's heading takes focus when the customer enters it. */
|
|
22107
|
+
function stepHead(id, title) {
|
|
21616
22108
|
const head = document.createElement('div');
|
|
21617
22109
|
head.className = 'svhd-step-head';
|
|
21618
|
-
const stepLabel = label === null ? null : document.createElement('p');
|
|
21619
|
-
if (stepLabel) {
|
|
21620
|
-
stepLabel.className = 'svhd-step-label';
|
|
21621
|
-
stepLabel.textContent = label;
|
|
21622
|
-
head.append(stepLabel);
|
|
21623
|
-
}
|
|
21624
22110
|
const stepHeading = document.createElement('h2');
|
|
21625
22111
|
stepHeading.id = id;
|
|
21626
22112
|
stepHeading.tabIndex = -1;
|
|
21627
22113
|
stepHeading.textContent = title;
|
|
21628
22114
|
head.append(stepHeading);
|
|
21629
|
-
return { head, heading: stepHeading
|
|
22115
|
+
return { head, heading: stepHeading };
|
|
21630
22116
|
}
|
|
21631
22117
|
function stepContainer(step) {
|
|
21632
22118
|
const container = document.createElement('div');
|
|
@@ -21634,7 +22120,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
21634
22120
|
container.dataset.contactStep = step;
|
|
21635
22121
|
return container;
|
|
21636
22122
|
}
|
|
21637
|
-
const request = stepHead(`${prefix}-heading`,
|
|
22123
|
+
const request = stepHead(`${prefix}-heading`, HELP_DESK_FORM_TITLE);
|
|
21638
22124
|
const heading = request.heading;
|
|
21639
22125
|
form.setAttribute('aria-labelledby', heading.id);
|
|
21640
22126
|
const details = stepContainer('details');
|
|
@@ -21781,7 +22267,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
21781
22267
|
const widgetAccount = document.createElement('div');
|
|
21782
22268
|
widgetAccount.className = 'svhd-widget-account';
|
|
21783
22269
|
let widgetCustomer = widget?.customer ?? null;
|
|
21784
|
-
const signInStep = widget ? stepHead(`${prefix}-signin-heading`, 'Sign in to send your request'
|
|
22270
|
+
const signInStep = widget ? stepHead(`${prefix}-signin-heading`, 'Sign in to send your request') : null;
|
|
21785
22271
|
const identity = widget ? stepContainer('identity') : null;
|
|
21786
22272
|
const recap = document.createElement('div');
|
|
21787
22273
|
recap.className = 'svhd-recap';
|
|
@@ -21995,13 +22481,12 @@ function mountHelpDeskForm(client, options) {
|
|
|
21995
22481
|
* The signed-in widget customer writes and sends in one step, posting as
|
|
21996
22482
|
* the account named under it, beside Switch account and, but for a website
|
|
21997
22483
|
* account's session, which the website ends, Sign out; a signed-out one
|
|
21998
|
-
* writes the request
|
|
22484
|
+
* writes the request before continuing to sign-in. Either way the form
|
|
22485
|
+
* shows the request.
|
|
21999
22486
|
*/
|
|
22000
22487
|
function renderWidgetIdentity() {
|
|
22001
22488
|
if (!widget)
|
|
22002
22489
|
return;
|
|
22003
|
-
if (request.label)
|
|
22004
|
-
request.label.hidden = widgetCustomer !== null;
|
|
22005
22490
|
auth.hidden = true;
|
|
22006
22491
|
code.wrapper.hidden = true;
|
|
22007
22492
|
name.wrapper.hidden = true;
|
|
@@ -23208,7 +23693,7 @@ function openHelpDeskForm(client, options = {}) {
|
|
|
23208
23693
|
header.className = 'svhd-modal-header';
|
|
23209
23694
|
const title = document.createElement('span');
|
|
23210
23695
|
title.id = `${prefix}-title`;
|
|
23211
|
-
title.textContent =
|
|
23696
|
+
title.textContent = HELP_DESK_FORM_TITLE;
|
|
23212
23697
|
title.hidden = true;
|
|
23213
23698
|
const close = document.createElement('button');
|
|
23214
23699
|
close.type = 'button';
|
|
@@ -25556,6 +26041,10 @@ function injectHelpDeskSupportStyles() {
|
|
|
25556
26041
|
.svhs-page .svhs-bottom{padding:20px 32px 24px}
|
|
25557
26042
|
.svhs-page .svhs-start-bottom{padding-top:0;align-items:flex-start}
|
|
25558
26043
|
.svhs-page .svhs-start-bottom .svhs-primary{width:auto;min-width:160px}
|
|
26044
|
+
.svhs-page .svhs-start-bottom:has(>.svhs-requester-identity:not([hidden])){flex-direction:row;align-items:center;gap:16px}
|
|
26045
|
+
.svhs-page .svhs-start-bottom:has(>.svhs-requester-identity:not([hidden])) .svhs-primary{flex:none;width:auto}
|
|
26046
|
+
.svhs-requester-identity{flex:1;min-width:0;margin:0;color:${HELP_DESK_COLORS.body};font-size:13px;line-height:1.5;overflow-wrap:anywhere}
|
|
26047
|
+
.svhs-requester-name{font-weight:600}
|
|
25559
26048
|
.svhs-page[data-stage=issue] .svhs-heading{font-size:28px}
|
|
25560
26049
|
.svhs-page .svhs-results-bottom .svhs-secondary{width:auto;flex:none}
|
|
25561
26050
|
.svhs-page .svhs-contact-target,.svhs-page .svhs-contact-target>.svhd-container{min-height:0}
|
|
@@ -25568,6 +26057,7 @@ function injectHelpDeskSupportStyles() {
|
|
|
25568
26057
|
.svhs-page .svhs-bottom{padding:20px}
|
|
25569
26058
|
.svhs-page .svhs-start-bottom{padding-top:0}
|
|
25570
26059
|
.svhs-page .svhs-start-bottom .svhs-primary{width:100%}
|
|
26060
|
+
.svhs-page .svhs-start-bottom:has(>.svhs-requester-identity:not([hidden])) .svhs-primary{min-width:0}
|
|
25571
26061
|
.svhs-page[data-stage=issue] .svhs-heading{font-size:26px}
|
|
25572
26062
|
.svhs-page .svhs-results-bottom .svhs-secondary{width:100%}
|
|
25573
26063
|
.svhs-page .svhs-contact-scroll{padding:0}
|
|
@@ -25792,6 +26282,8 @@ class SupportView {
|
|
|
25792
26282
|
this.deskName = element('span', 'svhs-desk-name');
|
|
25793
26283
|
this.external = element('a', 'svhs-icon-button');
|
|
25794
26284
|
this.issue = element('textarea', 'svhs-issue');
|
|
26285
|
+
this.requesterIdentity = element('p', 'svhs-requester-identity');
|
|
26286
|
+
this.requesterName = element('span', 'svhs-requester-name');
|
|
25795
26287
|
this.issueError = element('p', 'svhs-error');
|
|
25796
26288
|
this.query = element('p', 'svhs-query-text');
|
|
25797
26289
|
this.resultList = element('ul', 'svhs-results');
|
|
@@ -25885,11 +26377,8 @@ class SupportView {
|
|
|
25885
26377
|
// The heading asks the question once, so it names the field too.
|
|
25886
26378
|
const issueHeading = this.headings.get('issue');
|
|
25887
26379
|
issueHeading.id = `${this.prefix}-issue-title`;
|
|
25888
|
-
const helper = element('p', 'svhs-copy', 'What is your question? Tell us what is going on.');
|
|
25889
|
-
helper.id = `${this.prefix}-issue-help`;
|
|
25890
26380
|
this.issue.id = `${this.prefix}-issue`;
|
|
25891
26381
|
this.issue.setAttribute('aria-labelledby', issueHeading.id);
|
|
25892
|
-
this.issue.setAttribute('aria-describedby', helper.id);
|
|
25893
26382
|
this.issue.name = 'support_issue';
|
|
25894
26383
|
this.issue.placeholder = 'Describe your question or issue';
|
|
25895
26384
|
this.issue.autocomplete = 'off';
|
|
@@ -25909,9 +26398,14 @@ class SupportView {
|
|
|
25909
26398
|
this.search();
|
|
25910
26399
|
}
|
|
25911
26400
|
});
|
|
25912
|
-
intro.append(
|
|
26401
|
+
intro.append(this.issue, this.issueError);
|
|
25913
26402
|
this.find = button('svhs-primary', 'Continue', () => this.search());
|
|
25914
|
-
this.footer('issue', 'svhs-start-bottom')
|
|
26403
|
+
const issueFooter = this.footer('issue', 'svhs-start-bottom');
|
|
26404
|
+
issueFooter.append(this.find);
|
|
26405
|
+
this.requesterIdentity.append(document.createTextNode('Signed in as '), this.requesterName);
|
|
26406
|
+
this.requesterIdentity.hidden = true;
|
|
26407
|
+
if (target)
|
|
26408
|
+
issueFooter.append(this.requesterIdentity);
|
|
25915
26409
|
const results = this.screen('results', 'These articles may help');
|
|
25916
26410
|
const queryLine = element('div', 'svhs-query');
|
|
25917
26411
|
const question = element('div', 'svhs-question');
|
|
@@ -25922,11 +26416,12 @@ class SupportView {
|
|
|
25922
26416
|
results.prepend(queryLine);
|
|
25923
26417
|
results.append(this.resultList, this.resultStatus, this.resultError);
|
|
25924
26418
|
this.resultError.setAttribute('role', 'alert');
|
|
25925
|
-
this.contactResults = button('svhs-secondary svhs-full', 'Still need help? Open a ticket', () => {
|
|
26419
|
+
this.contactResults = button('svhs-secondary svhs-full', 'Still need help? Open a support ticket', () => {
|
|
25926
26420
|
if (this.state?.busy)
|
|
25927
26421
|
return;
|
|
25928
26422
|
this.actions.onContact(['locked', 'unavailable'].includes(this.state?.kbState || '') ? 'direct' : this.state?.results?.length ? 'none_match' : 'no_results');
|
|
25929
26423
|
});
|
|
26424
|
+
this.contactResults.append(helpDeskIcon('arrowRight'));
|
|
25930
26425
|
this.contactNote.id = `${this.prefix}-contact-note`;
|
|
25931
26426
|
this.contactNote.hidden = true;
|
|
25932
26427
|
this.resultsFooter = this.footer('results');
|
|
@@ -26057,6 +26552,8 @@ class SupportView {
|
|
|
26057
26552
|
if (next.busy)
|
|
26058
26553
|
this.find.append(element('span', 'svhs-spinner'));
|
|
26059
26554
|
this.find.append(document.createTextNode(next.busy ? 'Continuing...' : 'Continue'));
|
|
26555
|
+
this.requesterName.textContent = next.requesterLabel || '';
|
|
26556
|
+
this.requesterIdentity.hidden = !next.requesterLabel;
|
|
26060
26557
|
this.issueError.textContent = next.stage === 'issue' ? next.error || '' : '';
|
|
26061
26558
|
this.issueError.hidden = !this.issueError.textContent;
|
|
26062
26559
|
this.query.textContent = next.issue;
|
|
@@ -26734,7 +27231,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
26734
27231
|
// launcher included. Any other desk's brand arrives with connect, which the
|
|
26735
27232
|
// first open, search or contact makes, never creation: connecting here would
|
|
26736
27233
|
// add a desk lookup to every page load of a website that shows the launcher.
|
|
26737
|
-
let state = { visible: false, stage: 'issue', deskName: 'Support', issue: '', brand: supportBrand(options.desk?.branding?.color) };
|
|
27234
|
+
let state = { visible: false, stage: 'issue', deskName: 'Support', issue: '', requesterLabel: null, brand: supportBrand(options.desk?.branding?.color) };
|
|
26738
27235
|
if (typeof options.launcher === 'object') {
|
|
26739
27236
|
const offset = (value, fallback) => typeof value === 'number' && Number.isFinite(value) ? Math.min(240, Math.max(12, value)) : fallback;
|
|
26740
27237
|
state.position = { right: offset(options.launcher.right, 24), bottom: offset(options.launcher.bottom, 24) + 72 };
|
|
@@ -26827,6 +27324,11 @@ function createHelpDeskSupport(config, options) {
|
|
|
26827
27324
|
launcher?.setBrand(state.brand);
|
|
26828
27325
|
notify(options.onStateChange, snapshot());
|
|
26829
27326
|
}
|
|
27327
|
+
function identifyRequester(customer) {
|
|
27328
|
+
const requesterLabel = requesterNameOrAddress(customer);
|
|
27329
|
+
if (requesterLabel !== state.requesterLabel)
|
|
27330
|
+
update({ requesterLabel });
|
|
27331
|
+
}
|
|
26830
27332
|
async function connect() {
|
|
26831
27333
|
if (!connected)
|
|
26832
27334
|
connected = HelpDeskClient.connect(config, { ...options, onDiscardError: reportLostRevocation }).then((answer) => {
|
|
@@ -26834,10 +27336,12 @@ function createHelpDeskSupport(config, options) {
|
|
|
26834
27336
|
throw new Error('Support is closed.');
|
|
26835
27337
|
client = answer;
|
|
26836
27338
|
stopSession = answer.subscribeSession((change) => {
|
|
27339
|
+
if (change.source !== 'renew')
|
|
27340
|
+
identifyRequester(null);
|
|
26837
27341
|
if (change.source !== 'clear' || replacingSession)
|
|
26838
27342
|
return;
|
|
26839
27343
|
if (lookupsInFlight === 0)
|
|
26840
|
-
|
|
27344
|
+
tellHost(null);
|
|
26841
27345
|
else
|
|
26842
27346
|
heldClear = true;
|
|
26843
27347
|
});
|
|
@@ -26877,6 +27381,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
26877
27381
|
return;
|
|
26878
27382
|
anonymous = !token;
|
|
26879
27383
|
if (!token) {
|
|
27384
|
+
identifyRequester(null);
|
|
26880
27385
|
if (!state.issue)
|
|
26881
27386
|
update({ issue: readSupportIssue(active.desk.desk_id) ?? '' });
|
|
26882
27387
|
if (state.issue)
|
|
@@ -26886,7 +27391,10 @@ function createHelpDeskSupport(config, options) {
|
|
|
26886
27391
|
}
|
|
26887
27392
|
else if (active.hasTicketAccess) {
|
|
26888
27393
|
const customer = await active.getMe();
|
|
26889
|
-
if (destroyed
|
|
27394
|
+
if (destroyed)
|
|
27395
|
+
return;
|
|
27396
|
+
identifyRequester(customer);
|
|
27397
|
+
if (state.stage !== 'issue')
|
|
26890
27398
|
return;
|
|
26891
27399
|
const saved = readFormDraft(active.desk.desk_id, customer.requester_id);
|
|
26892
27400
|
const composition = readAnonymousFormDraft(active.desk.desk_id);
|
|
@@ -27029,8 +27537,10 @@ function createHelpDeskSupport(config, options) {
|
|
|
27029
27537
|
tellHost(session);
|
|
27030
27538
|
}
|
|
27031
27539
|
function tellHost(session) {
|
|
27032
|
-
if (
|
|
27033
|
-
|
|
27540
|
+
if (destroyed)
|
|
27541
|
+
return;
|
|
27542
|
+
identifyRequester(session?.customer ?? null);
|
|
27543
|
+
notify(options.onSession, session);
|
|
27034
27544
|
}
|
|
27035
27545
|
/**
|
|
27036
27546
|
* Support's session lookup, with where support arrived (`arrival`) when the
|
|
@@ -27221,6 +27731,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
27221
27731
|
return;
|
|
27222
27732
|
contactCustomer = customer;
|
|
27223
27733
|
anonymous = !customer;
|
|
27734
|
+
identifyRequester(customer);
|
|
27224
27735
|
// A customer the website gave back sees their own saved request; none keeps it hidden.
|
|
27225
27736
|
const recovering = customer ? null : pendingRecovery;
|
|
27226
27737
|
pendingRecovery = null;
|
|
@@ -27247,7 +27758,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
27247
27758
|
anonymous = false;
|
|
27248
27759
|
if (options.persist)
|
|
27249
27760
|
clearSupportIssue(client.desk.desk_id);
|
|
27250
|
-
|
|
27761
|
+
tellHost(session);
|
|
27251
27762
|
},
|
|
27252
27763
|
widgetIdentity: {
|
|
27253
27764
|
customer,
|
|
@@ -27527,7 +28038,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
27527
28038
|
// A refused or lost revocation leaves the chosen account in place.
|
|
27528
28039
|
void released.catch(reportLostRevocation);
|
|
27529
28040
|
active.setSession(session);
|
|
27530
|
-
|
|
28041
|
+
tellHost(session);
|
|
27531
28042
|
let refusal;
|
|
27532
28043
|
if (active.ticketAccessPolicy?.mode === 'identity') {
|
|
27533
28044
|
// Without this grant, contact's access check shows the employee gate
|
|
@@ -32445,7 +32956,7 @@ class SparkVault {
|
|
|
32445
32956
|
}
|
|
32446
32957
|
/** Get the SDK version */
|
|
32447
32958
|
static get version() {
|
|
32448
|
-
return '18.0.
|
|
32959
|
+
return '18.0.5';
|
|
32449
32960
|
}
|
|
32450
32961
|
}
|
|
32451
32962
|
if (typeof window !== 'undefined') {
|