@sparkvault/sdk-js 18.0.4 → 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 +594 -123
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +594 -123
- package/dist/index.mjs.map +1 -1
- package/dist/products/help-desk/form.d.ts +4 -4
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -19577,6 +19577,8 @@ const HELP_DESK_COLORS = Object.freeze({
|
|
|
19577
19577
|
fillStrong: `var(--hd-fill-strong,${LIGHT['--color-slate-200']})`,
|
|
19578
19578
|
/** A field's and a secondary action's edge. */
|
|
19579
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']})`,
|
|
19580
19582
|
ink: `var(--hd-ink,${LIGHT['--ink']})`,
|
|
19581
19583
|
body: `var(--hd-text-body,${LIGHT['--text-body']})`,
|
|
19582
19584
|
muted: `var(--hd-text-muted,${LIGHT['--text-muted']})`,
|
|
@@ -19716,7 +19718,6 @@ function injectHelpDeskFormStyles() {
|
|
|
19716
19718
|
.svhd-hint{font-size:13px;color:${HELP_DESK_COLORS.body};margin:0}
|
|
19717
19719
|
.svhd-step{display:grid;gap:16px;min-width:0}
|
|
19718
19720
|
.svhd-step-head{display:grid;gap:4px;margin-bottom:4px}
|
|
19719
|
-
.svhd-step-label{margin:0;font-size:13px;font-weight:600;line-height:1.4;color:${HELP_DESK_COLORS.body}}
|
|
19720
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}
|
|
19721
19722
|
.svhd-text-button:not(:disabled):hover{text-decoration-thickness:2px}
|
|
19722
19723
|
.svhd-text-button:focus-visible{outline:3px solid ${HELP_DESK_FOCUS};outline-offset:2px}
|
|
@@ -20265,7 +20266,7 @@ function acceptedKindsCopy(kinds) {
|
|
|
20265
20266
|
/**
|
|
20266
20267
|
* The files a ticket accepts, in the one phrase every surface names them by,
|
|
20267
20268
|
* built from the policy's own list (ACCEPTED_ATTACHMENT_KINDS): the help desk
|
|
20268
|
-
* composer's
|
|
20269
|
+
* composer's refusal dialog reads it, and so do the API reference
|
|
20269
20270
|
* (apps/api/openapi/overlay.mjs) and the help desk's page on the site
|
|
20270
20271
|
* (apps/www/_data/helpDeskAttachments.js). A refused file's sentence names
|
|
20271
20272
|
* only that its type can't be attached.
|
|
@@ -20273,10 +20274,9 @@ function acceptedKindsCopy(kinds) {
|
|
|
20273
20274
|
const ACCEPTED_ATTACHMENTS_COPY = acceptedKindsCopy(ACCEPTED_ATTACHMENT_KINDS);
|
|
20274
20275
|
|
|
20275
20276
|
/**
|
|
20276
|
-
*
|
|
20277
|
-
*
|
|
20278
|
-
*
|
|
20279
|
-
* 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.
|
|
20280
20280
|
*/
|
|
20281
20281
|
const CUSTOMER_ATTACHMENTS_HINT =
|
|
20282
20282
|
`Add screenshots, documents or recordings. Up to ${MAX_ATTACHMENTS_PER_MESSAGE} files, ${formatBytes(CUSTOMER_ATTACHMENT_MAX_BYTES)} each.`;
|
|
@@ -20350,6 +20350,386 @@ function refusalCopy(refusal, maxBytes) {
|
|
|
20350
20350
|
return REFUSAL_COPY[refusal] ?? "This file can't be attached.";
|
|
20351
20351
|
}
|
|
20352
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
|
+
|
|
20353
20733
|
/**
|
|
20354
20734
|
* Files brought to a message's composer by drag, drop and paste, handled
|
|
20355
20735
|
* alike by every composer that takes them: the console's reply composer and
|
|
@@ -20551,6 +20931,7 @@ const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
|
|
|
20551
20931
|
|
|
20552
20932
|
const PATHS = Object.freeze({
|
|
20553
20933
|
back: 'm14.5 6-6 6 6 6',
|
|
20934
|
+
arrowRight: 'M4 12h16m-6-6 6 6-6 6',
|
|
20554
20935
|
close: 'm6 6 12 12M18 6 6 18',
|
|
20555
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',
|
|
20556
20937
|
check: 'm5 12 4 4L19 6',
|
|
@@ -20607,10 +20988,10 @@ function helpDeskIcon(name) {
|
|
|
20607
20988
|
* takes no files from its customers is refused in words
|
|
20608
20989
|
* (NO_CUSTOMER_FILES_COPY), and one brought while files cannot join is
|
|
20609
20990
|
* never the browser's to open in place of the unsent message.
|
|
20610
|
-
* - **
|
|
20611
|
-
*
|
|
20612
|
-
*
|
|
20613
|
-
*
|
|
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.
|
|
20614
20995
|
* - **Uploading.** The browser's check (attachmentRefusal) first, then the
|
|
20615
20996
|
* host's transport: its target (the request a reply belongs to, or the
|
|
20616
20997
|
* draft a new request uploads to, which may not exist yet: the file then
|
|
@@ -20675,21 +21056,27 @@ const COMPOSER_CSS = `
|
|
|
20675
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}
|
|
20676
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}}
|
|
20677
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}
|
|
20678
|
-
.svhd-composer .svhd-composer-attach:hover
|
|
21059
|
+
.svhd-composer .svhd-composer-attach:hover{background:${HELP_DESK_COLORS.fill};color:${HELP_DESK_COLORS.ink}}
|
|
20679
21060
|
.svhd-composer .svhd-composer-attach:disabled{opacity:.6;cursor:default}
|
|
20680
21061
|
.svhd-composer .svhd-composer-attach svg{display:block;width:18px;height:18px}
|
|
20681
|
-
.svhd-composer .svhd-composer-
|
|
20682
|
-
.svhd-composer .svhd-composer-
|
|
20683
|
-
.svhd-composer .svhd-composer-
|
|
20684
|
-
.svhd-composer .svhd-composer-
|
|
20685
|
-
.svhd-composer .svhd-composer-
|
|
20686
|
-
.svhd-composer .svhd-composer-
|
|
20687
|
-
.svhd-composer .svhd-composer-
|
|
20688
|
-
.svhd-composer .svhd-composer-
|
|
20689
|
-
.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}
|
|
20690
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}}
|
|
20691
21076
|
.svhd-composer .svhd-attachment-chips:empty{display:none}
|
|
20692
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}
|
|
20693
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}}
|
|
20694
21081
|
.svhd-composer .svhd-attachment-status{grid-column:1;padding-right:8px;color:${HELP_DESK_COLORS.body};font-size:12px;overflow-wrap:anywhere}
|
|
20695
21082
|
.svhd-composer .svhd-attachment-status.svhd-composer-problem{color:${HELP_DESK_COLORS.error}}
|
|
@@ -20697,7 +21084,7 @@ const COMPOSER_CSS = `
|
|
|
20697
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}
|
|
20698
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}
|
|
20699
21086
|
.svhd-composer .svhd-attachment-remove:disabled,.svhd-composer .svhd-attachment-retry:disabled{opacity:.6;cursor:default}
|
|
20700
|
-
.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}}
|
|
20701
21088
|
.svhd-composer-notice{margin:0;color:${HELP_DESK_COLORS.error};font-size:14px;line-height:1.5}
|
|
20702
21089
|
.svhd-composer [hidden],.svhd-composer-notice[hidden]{display:none!important}
|
|
20703
21090
|
`;
|
|
@@ -20734,8 +21121,8 @@ const RECEIVED_COPY = 'File received. Waiting for storage confirmation.';
|
|
|
20734
21121
|
const UPLOAD_FAILED_COPY = "This file couldn't be uploaded. Try again or remove it.";
|
|
20735
21122
|
const UPLOADING_COPY = 'Uploading';
|
|
20736
21123
|
const VERIFYING_COPY = 'Verifying stored file';
|
|
20737
|
-
/**
|
|
20738
|
-
const
|
|
21124
|
+
/** Requirements appear only after a file is refused. */
|
|
21125
|
+
const VALIDATION_TITLE = 'Unable to attach files';
|
|
20739
21126
|
const ACCEPTED_KINDS_COPY = `You can attach ${ACCEPTED_ATTACHMENTS_COPY}.`;
|
|
20740
21127
|
|
|
20741
21128
|
/** What a message's files still need before it can be sent, from the most pressing. */
|
|
@@ -20874,9 +21261,7 @@ function createHelpDeskComposer(options) {
|
|
|
20874
21261
|
const zone = dropZone ?? frame;
|
|
20875
21262
|
const fields = [textarea, ...pasteFields];
|
|
20876
21263
|
|
|
20877
|
-
// The
|
|
20878
|
-
// extensions a request takes first, never the check), and its (?) tip,
|
|
20879
|
-
// whose limits also describe Attach.
|
|
21264
|
+
// The chooser filters names; the canonical attachment check decides.
|
|
20880
21265
|
const input = document.createElement('input');
|
|
20881
21266
|
input.type = 'file';
|
|
20882
21267
|
input.name = 'attachments';
|
|
@@ -20884,40 +21269,13 @@ function createHelpDeskComposer(options) {
|
|
|
20884
21269
|
input.accept = ATTACHMENT_INPUT_ACCEPT;
|
|
20885
21270
|
input.hidden = true;
|
|
20886
21271
|
input.tabIndex = -1;
|
|
20887
|
-
const hint = document.createElement('p');
|
|
20888
|
-
hint.id = `${textarea.id}-attachment-hint`;
|
|
20889
|
-
hint.textContent = CUSTOMER_ATTACHMENTS_HINT;
|
|
20890
|
-
const kinds = document.createElement('p');
|
|
20891
|
-
kinds.textContent = ACCEPTED_KINDS_COPY;
|
|
20892
21272
|
const attach = button$1('svhd-composer-attach', 'Attach files');
|
|
20893
|
-
attach.setAttribute('aria-describedby', hint.id);
|
|
20894
21273
|
const attachText = document.createElement('span');
|
|
20895
21274
|
attachText.textContent = 'Attach';
|
|
20896
21275
|
attach.append(helpDeskIcon('paperclip'), attachText);
|
|
20897
|
-
const helpPanel = document.createElement('div');
|
|
20898
|
-
helpPanel.id = `${textarea.id}-attachment-help`;
|
|
20899
|
-
helpPanel.className = 'svhd-composer-help-panel';
|
|
20900
|
-
helpPanel.setAttribute('role', 'region');
|
|
20901
|
-
helpPanel.setAttribute('aria-label', HELP_TITLE);
|
|
20902
|
-
helpPanel.hidden = true;
|
|
20903
|
-
const helpCopy = document.createElement('div');
|
|
20904
|
-
helpCopy.className = 'svhd-composer-help-copy';
|
|
20905
|
-
helpCopy.append(hint, kinds);
|
|
20906
|
-
const helpClose = button$1('svhd-composer-help-close', 'Close');
|
|
20907
|
-
helpClose.title = 'Close';
|
|
20908
|
-
helpClose.append(helpDeskIcon('close'));
|
|
20909
|
-
helpPanel.append(helpCopy, helpClose);
|
|
20910
|
-
const helpTrigger = button$1('svhd-composer-help', `Help: ${HELP_TITLE}`);
|
|
20911
|
-
helpTrigger.setAttribute('aria-expanded', 'false');
|
|
20912
|
-
helpTrigger.setAttribute('aria-controls', helpPanel.id);
|
|
20913
|
-
const glyph = document.createElement('span');
|
|
20914
|
-
glyph.className = 'svhd-composer-help-glyph';
|
|
20915
|
-
glyph.setAttribute('aria-hidden', 'true');
|
|
20916
|
-
glyph.textContent = '?';
|
|
20917
|
-
helpTrigger.append(glyph);
|
|
20918
21276
|
const toolbar = document.createElement('div');
|
|
20919
21277
|
toolbar.className = 'svhd-composer-toolbar';
|
|
20920
|
-
toolbar.append(attach,
|
|
21278
|
+
toolbar.append(attach, input);
|
|
20921
21279
|
const list = document.createElement('ul');
|
|
20922
21280
|
list.className = 'svhd-attachment-chips';
|
|
20923
21281
|
list.setAttribute('aria-label', 'Attached files');
|
|
@@ -20929,10 +21287,151 @@ function createHelpDeskComposer(options) {
|
|
|
20929
21287
|
let locked = false;
|
|
20930
21288
|
let pickingDisabled = false;
|
|
20931
21289
|
let destroyed = false;
|
|
21290
|
+
let validation = null;
|
|
20932
21291
|
const accepting = () => transport !== null && !locked && !pickingDisabled && !destroyed;
|
|
20933
21292
|
const current = (entry, ownRevision) =>
|
|
20934
21293
|
!destroyed && revision === ownRevision && entries.includes(entry) && !entry.controller?.signal.aborted;
|
|
20935
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
|
+
|
|
20936
21435
|
// A refusal of files is an alert only while it shows, as a field's error is.
|
|
20937
21436
|
function setNotice(text) {
|
|
20938
21437
|
notice.textContent = text ?? '';
|
|
@@ -20993,9 +21492,12 @@ function createHelpDeskComposer(options) {
|
|
|
20993
21492
|
if (!stillCurrent()) return;
|
|
20994
21493
|
if (refusal) {
|
|
20995
21494
|
entry.retryable = false;
|
|
20996
|
-
|
|
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);
|
|
20997
21498
|
return;
|
|
20998
21499
|
}
|
|
21500
|
+
preview(entry);
|
|
20999
21501
|
request = 'host';
|
|
21000
21502
|
const target = await transport.target();
|
|
21001
21503
|
if (!stillCurrent()) return;
|
|
@@ -21041,7 +21543,9 @@ function createHelpDeskComposer(options) {
|
|
|
21041
21543
|
entry.attachmentId = upload.attachment_id;
|
|
21042
21544
|
if (Number.isSafeInteger(upload.max_bytes) && upload.max_bytes > 0 && entry.file.size > upload.max_bytes) {
|
|
21043
21545
|
entry.retryable = false;
|
|
21044
|
-
|
|
21546
|
+
const copy = tooLargeCopy(upload.max_bytes);
|
|
21547
|
+
show(entry, FILE_STATE.FAILED, copy);
|
|
21548
|
+
reportRefusal(entry.batch, entry, entry.file.name, copy);
|
|
21045
21549
|
return;
|
|
21046
21550
|
}
|
|
21047
21551
|
entry.progress.value = 0;
|
|
@@ -21074,6 +21578,7 @@ function createHelpDeskComposer(options) {
|
|
|
21074
21578
|
const problem = uploadProblem(refusalOf(request, error), organization);
|
|
21075
21579
|
entry.retryable = problem.retryable;
|
|
21076
21580
|
show(entry, FILE_STATE.FAILED, problem.copy);
|
|
21581
|
+
if (!problem.retryable) reportRefusal(entry.batch, entry, entry.file.name, problem.copy);
|
|
21077
21582
|
} finally {
|
|
21078
21583
|
if (entry.controller === controller) entry.controller = null;
|
|
21079
21584
|
if (entry.operation === operation) entry.operation = null;
|
|
@@ -21106,6 +21611,7 @@ function createHelpDeskComposer(options) {
|
|
|
21106
21611
|
const refocus = document.activeElement === entry.remove;
|
|
21107
21612
|
const index = entries.indexOf(entry);
|
|
21108
21613
|
entry.controller?.abort();
|
|
21614
|
+
releasePreview(entry);
|
|
21109
21615
|
entries = entries.filter((candidate) => candidate !== entry);
|
|
21110
21616
|
entry.row.remove();
|
|
21111
21617
|
setNotice(null);
|
|
@@ -21115,13 +21621,14 @@ function createHelpDeskComposer(options) {
|
|
|
21115
21621
|
if (refocus) (entries[Math.min(index, entries.length - 1)]?.remove ?? attach).focus();
|
|
21116
21622
|
}
|
|
21117
21623
|
|
|
21118
|
-
function add(files) {
|
|
21624
|
+
function add(files, batch = selection()) {
|
|
21119
21625
|
if (!accepting()) return;
|
|
21120
21626
|
const incoming = Array.from(files);
|
|
21121
21627
|
if (incoming.length === 0) return;
|
|
21122
21628
|
const counted = entries.filter((entry) => entry.state !== FILE_STATE.REFUSED).length;
|
|
21123
21629
|
const room = Math.max(0, MAX_ATTACHMENTS_PER_MESSAGE - counted);
|
|
21124
21630
|
setNotice(incoming.length > room ? LIMIT_COPY : null);
|
|
21631
|
+
if (incoming.length > room) reportRefusal(batch, batch, null, LIMIT_COPY);
|
|
21125
21632
|
for (const file of incoming.slice(0, room)) {
|
|
21126
21633
|
const row = document.createElement('li');
|
|
21127
21634
|
row.className = 'svhd-attachment-chip';
|
|
@@ -21148,11 +21655,14 @@ function createHelpDeskComposer(options) {
|
|
|
21148
21655
|
const entry = {
|
|
21149
21656
|
file, row, status, progress, remove: removeButton, retry,
|
|
21150
21657
|
state: FILE_STATE.QUEUED, retryable: false, controller: null, operation: null,
|
|
21151
|
-
target: null, attachmentId: null, sessionUrl: null
|
|
21658
|
+
target: null, attachmentId: null, sessionUrl: null, batch, previewUrl: null, previewAttempted: false
|
|
21152
21659
|
};
|
|
21153
21660
|
removeButton.addEventListener('click', () => remove(entry));
|
|
21154
21661
|
retry.addEventListener('click', () => {
|
|
21155
|
-
if (!locked && entry.retryable)
|
|
21662
|
+
if (!locked && entry.retryable) {
|
|
21663
|
+
entry.batch = selection();
|
|
21664
|
+
void run(entry);
|
|
21665
|
+
}
|
|
21156
21666
|
});
|
|
21157
21667
|
row.append(name, removeButton, status, retry, progress);
|
|
21158
21668
|
list.append(row);
|
|
@@ -21176,13 +21686,18 @@ function createHelpDeskComposer(options) {
|
|
|
21176
21686
|
drop.hidden = !value;
|
|
21177
21687
|
}
|
|
21178
21688
|
function refuseFiles() {
|
|
21179
|
-
if (!notice.hidden && notice.textContent === NO_CUSTOMER_FILES_COPY) return;
|
|
21180
21689
|
setNotice(NO_CUSTOMER_FILES_COPY);
|
|
21690
|
+
const batch = selection();
|
|
21691
|
+
reportRefusal(batch, batch, null, NO_CUSTOMER_FILES_COPY);
|
|
21181
21692
|
}
|
|
21182
21693
|
// A dropped folder is left out, and said so beside any refusal the files with it met.
|
|
21183
21694
|
function attachBrought(files, folders) {
|
|
21184
|
-
|
|
21185
|
-
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
|
+
}
|
|
21186
21701
|
}
|
|
21187
21702
|
const fileEvents = composerFileEvents({
|
|
21188
21703
|
action: fileAction,
|
|
@@ -21193,33 +21708,6 @@ function createHelpDeskComposer(options) {
|
|
|
21193
21708
|
refuse: refuseFiles
|
|
21194
21709
|
});
|
|
21195
21710
|
|
|
21196
|
-
// The (?) tip: a disclosure that closes by its trigger, Escape, its close
|
|
21197
|
-
// button (focus back on the trigger), a press outside it, or focus leaving it.
|
|
21198
|
-
const inTip = (node) => node instanceof Node && (helpTrigger.contains(node) || helpPanel.contains(node));
|
|
21199
|
-
function setHelpOpen(open) {
|
|
21200
|
-
helpPanel.hidden = !open;
|
|
21201
|
-
helpTrigger.setAttribute('aria-expanded', String(open));
|
|
21202
|
-
if (open) document.addEventListener('pointerdown', onPressOutsideHelp);
|
|
21203
|
-
else document.removeEventListener('pointerdown', onPressOutsideHelp);
|
|
21204
|
-
}
|
|
21205
|
-
function onPressOutsideHelp(event) {
|
|
21206
|
-
if (!inTip(event.target)) setHelpOpen(false);
|
|
21207
|
-
}
|
|
21208
|
-
const onHelpToggle = () => setHelpOpen(helpPanel.hidden);
|
|
21209
|
-
const onHelpClose = () => {
|
|
21210
|
-
setHelpOpen(false);
|
|
21211
|
-
helpTrigger.focus();
|
|
21212
|
-
};
|
|
21213
|
-
// Escape is the tip's alone while it is open: a dialog the form sits in leaves a handled key alone.
|
|
21214
|
-
const onHelpKey = (event) => {
|
|
21215
|
-
if (event.key !== 'Escape' || helpPanel.hidden) return;
|
|
21216
|
-
event.preventDefault();
|
|
21217
|
-
onHelpClose();
|
|
21218
|
-
};
|
|
21219
|
-
const onHelpFocusOut = (event) => {
|
|
21220
|
-
if (!helpPanel.hidden && event.relatedTarget && !inTip(event.relatedTarget)) setHelpOpen(false);
|
|
21221
|
-
};
|
|
21222
|
-
|
|
21223
21711
|
// A desk's refusal of files gives way once the customer writes on.
|
|
21224
21712
|
const onInput = () => {
|
|
21225
21713
|
if (!transport) setNotice(null);
|
|
@@ -21243,19 +21731,15 @@ function createHelpDeskComposer(options) {
|
|
|
21243
21731
|
}
|
|
21244
21732
|
input.addEventListener('change', onChoose);
|
|
21245
21733
|
attach.addEventListener('click', onAttach);
|
|
21246
|
-
helpTrigger.addEventListener('click', onHelpToggle);
|
|
21247
|
-
helpClose.addEventListener('click', onHelpClose);
|
|
21248
|
-
for (const part of [helpTrigger, helpPanel]) {
|
|
21249
|
-
part.addEventListener('keydown', onHelpKey);
|
|
21250
|
-
part.addEventListener('focusout', onHelpFocusOut);
|
|
21251
|
-
}
|
|
21252
21734
|
|
|
21253
21735
|
function clear(keepAttached = false) {
|
|
21254
21736
|
revision += 1;
|
|
21737
|
+
dismissValidation();
|
|
21255
21738
|
const previous = entries;
|
|
21256
21739
|
entries = [];
|
|
21257
21740
|
for (const entry of previous) {
|
|
21258
21741
|
entry.controller?.abort();
|
|
21742
|
+
releasePreview(entry);
|
|
21259
21743
|
if (!keepAttached || entry.state !== FILE_STATE.COMPLETE) void cancel(entry.target, entry.attachmentId);
|
|
21260
21744
|
}
|
|
21261
21745
|
list.replaceChildren();
|
|
@@ -21303,7 +21787,6 @@ function createHelpDeskComposer(options) {
|
|
|
21303
21787
|
destroy(keepAttached = false) {
|
|
21304
21788
|
destroyed = true;
|
|
21305
21789
|
clear(keepAttached);
|
|
21306
|
-
setHelpOpen(false);
|
|
21307
21790
|
zone.removeEventListener('dragenter', fileEvents.dragOver);
|
|
21308
21791
|
zone.removeEventListener('dragover', fileEvents.dragOver);
|
|
21309
21792
|
zone.removeEventListener('dragleave', fileEvents.dragLeave);
|
|
@@ -21314,12 +21797,6 @@ function createHelpDeskComposer(options) {
|
|
|
21314
21797
|
}
|
|
21315
21798
|
input.removeEventListener('change', onChoose);
|
|
21316
21799
|
attach.removeEventListener('click', onAttach);
|
|
21317
|
-
helpTrigger.removeEventListener('click', onHelpToggle);
|
|
21318
|
-
helpClose.removeEventListener('click', onHelpClose);
|
|
21319
|
-
for (const part of [helpTrigger, helpPanel]) {
|
|
21320
|
-
part.removeEventListener('keydown', onHelpKey);
|
|
21321
|
-
part.removeEventListener('focusout', onHelpFocusOut);
|
|
21322
|
-
}
|
|
21323
21800
|
}
|
|
21324
21801
|
};
|
|
21325
21802
|
}
|
|
@@ -21467,6 +21944,7 @@ function saveFormDraft(deskId, requesterId, value) {
|
|
|
21467
21944
|
catch { /* Storage is optional; the live form keeps its composition. */ }
|
|
21468
21945
|
}
|
|
21469
21946
|
|
|
21947
|
+
const HELP_DESK_FORM_TITLE = 'Open a Support Ticket';
|
|
21470
21948
|
let formSequence = 0;
|
|
21471
21949
|
/**
|
|
21472
21950
|
* The desk API's refusal of a file's draft or upload, as the composer reads
|
|
@@ -21605,10 +22083,9 @@ function companySignInUrl(value) {
|
|
|
21605
22083
|
* A confirmed send replaces the form with its confirmation.
|
|
21606
22084
|
*
|
|
21607
22085
|
* The request is a summary and optional details, in a composer that also
|
|
21608
|
-
* takes files. A signed-out widget customer writes it
|
|
21609
|
-
*
|
|
21610
|
-
*
|
|
21611
|
-
* 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.
|
|
21612
22089
|
*/
|
|
21613
22090
|
function mountHelpDeskForm(client, options) {
|
|
21614
22091
|
const target = resolveTarget(options.target);
|
|
@@ -21626,22 +22103,16 @@ function mountHelpDeskForm(client, options) {
|
|
|
21626
22103
|
form.className = 'svhd-form';
|
|
21627
22104
|
form.noValidate = true;
|
|
21628
22105
|
shell.body.append(form);
|
|
21629
|
-
/** A step's heading
|
|
21630
|
-
function stepHead(id, title
|
|
22106
|
+
/** A step's heading takes focus when the customer enters it. */
|
|
22107
|
+
function stepHead(id, title) {
|
|
21631
22108
|
const head = document.createElement('div');
|
|
21632
22109
|
head.className = 'svhd-step-head';
|
|
21633
|
-
const stepLabel = label === null ? null : document.createElement('p');
|
|
21634
|
-
if (stepLabel) {
|
|
21635
|
-
stepLabel.className = 'svhd-step-label';
|
|
21636
|
-
stepLabel.textContent = label;
|
|
21637
|
-
head.append(stepLabel);
|
|
21638
|
-
}
|
|
21639
22110
|
const stepHeading = document.createElement('h2');
|
|
21640
22111
|
stepHeading.id = id;
|
|
21641
22112
|
stepHeading.tabIndex = -1;
|
|
21642
22113
|
stepHeading.textContent = title;
|
|
21643
22114
|
head.append(stepHeading);
|
|
21644
|
-
return { head, heading: stepHeading
|
|
22115
|
+
return { head, heading: stepHeading };
|
|
21645
22116
|
}
|
|
21646
22117
|
function stepContainer(step) {
|
|
21647
22118
|
const container = document.createElement('div');
|
|
@@ -21649,7 +22120,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
21649
22120
|
container.dataset.contactStep = step;
|
|
21650
22121
|
return container;
|
|
21651
22122
|
}
|
|
21652
|
-
const request = stepHead(`${prefix}-heading`,
|
|
22123
|
+
const request = stepHead(`${prefix}-heading`, HELP_DESK_FORM_TITLE);
|
|
21653
22124
|
const heading = request.heading;
|
|
21654
22125
|
form.setAttribute('aria-labelledby', heading.id);
|
|
21655
22126
|
const details = stepContainer('details');
|
|
@@ -21796,7 +22267,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
21796
22267
|
const widgetAccount = document.createElement('div');
|
|
21797
22268
|
widgetAccount.className = 'svhd-widget-account';
|
|
21798
22269
|
let widgetCustomer = widget?.customer ?? null;
|
|
21799
|
-
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;
|
|
21800
22271
|
const identity = widget ? stepContainer('identity') : null;
|
|
21801
22272
|
const recap = document.createElement('div');
|
|
21802
22273
|
recap.className = 'svhd-recap';
|
|
@@ -22010,13 +22481,12 @@ function mountHelpDeskForm(client, options) {
|
|
|
22010
22481
|
* The signed-in widget customer writes and sends in one step, posting as
|
|
22011
22482
|
* the account named under it, beside Switch account and, but for a website
|
|
22012
22483
|
* account's session, which the website ends, Sign out; a signed-out one
|
|
22013
|
-
* writes the request
|
|
22484
|
+
* writes the request before continuing to sign-in. Either way the form
|
|
22485
|
+
* shows the request.
|
|
22014
22486
|
*/
|
|
22015
22487
|
function renderWidgetIdentity() {
|
|
22016
22488
|
if (!widget)
|
|
22017
22489
|
return;
|
|
22018
|
-
if (request.label)
|
|
22019
|
-
request.label.hidden = widgetCustomer !== null;
|
|
22020
22490
|
auth.hidden = true;
|
|
22021
22491
|
code.wrapper.hidden = true;
|
|
22022
22492
|
name.wrapper.hidden = true;
|
|
@@ -23223,7 +23693,7 @@ function openHelpDeskForm(client, options = {}) {
|
|
|
23223
23693
|
header.className = 'svhd-modal-header';
|
|
23224
23694
|
const title = document.createElement('span');
|
|
23225
23695
|
title.id = `${prefix}-title`;
|
|
23226
|
-
title.textContent =
|
|
23696
|
+
title.textContent = HELP_DESK_FORM_TITLE;
|
|
23227
23697
|
title.hidden = true;
|
|
23228
23698
|
const close = document.createElement('button');
|
|
23229
23699
|
close.type = 'button';
|
|
@@ -25946,11 +26416,12 @@ class SupportView {
|
|
|
25946
26416
|
results.prepend(queryLine);
|
|
25947
26417
|
results.append(this.resultList, this.resultStatus, this.resultError);
|
|
25948
26418
|
this.resultError.setAttribute('role', 'alert');
|
|
25949
|
-
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', () => {
|
|
25950
26420
|
if (this.state?.busy)
|
|
25951
26421
|
return;
|
|
25952
26422
|
this.actions.onContact(['locked', 'unavailable'].includes(this.state?.kbState || '') ? 'direct' : this.state?.results?.length ? 'none_match' : 'no_results');
|
|
25953
26423
|
});
|
|
26424
|
+
this.contactResults.append(helpDeskIcon('arrowRight'));
|
|
25954
26425
|
this.contactNote.id = `${this.prefix}-contact-note`;
|
|
25955
26426
|
this.contactNote.hidden = true;
|
|
25956
26427
|
this.resultsFooter = this.footer('results');
|
|
@@ -32485,7 +32956,7 @@ class SparkVault {
|
|
|
32485
32956
|
}
|
|
32486
32957
|
/** Get the SDK version */
|
|
32487
32958
|
static get version() {
|
|
32488
|
-
return '18.0.
|
|
32959
|
+
return '18.0.5';
|
|
32489
32960
|
}
|
|
32490
32961
|
}
|
|
32491
32962
|
if (typeof window !== 'undefined') {
|