@sparkvault/sdk-js 16.7.1 → 16.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -14337,7 +14337,7 @@ Array.from({ length: 1 << BRAND_BITS.size }, (_, mask) =>
14337
14337
  * theirs. Every timeline event type declares whether a customer may see it;
14338
14338
  * a customer-facing projection keeps only `public` types (an allowlist, so a
14339
14339
  * new type is hidden until it says otherwise). The portal's client name and
14340
- * API prefix, team mail aliases, the attachment ceremony's steps, the
14340
+ * API prefix, queue mail aliases, the attachment ceremony's steps, the
14341
14341
  * question a customer's new request asks before it is discarded, session,
14342
14342
  * sign-in code (its length, lifetime, sender, resend wait, countdown and
14343
14343
  * the code step's words), merge and pending-attachment timings, hold
@@ -14355,7 +14355,7 @@ Array.from({ length: 1 << BRAND_BITS.size }, (_, mask) =>
14355
14355
  *
14356
14356
  * BROWSER-SAFE: data and pure functions, and newMessageId's count of the ids
14357
14357
  * its page named; its imports are the mail products whose fixed From local
14358
- * parts no team alias may take (./mail-products.js), the brand rule no team
14358
+ * parts no queue alias may take (./mail-products.js), the brand rule no queue
14359
14359
  * alias may read as (./organization-name.js) and the resource id rule a desk
14360
14360
  * id is read by (./ids.js).
14361
14361
  */
@@ -14389,10 +14389,10 @@ const HELP_DESK_WIDGET_IDENTITY_MESSAGES = Object.freeze({
14389
14389
  });
14390
14390
 
14391
14391
  /**
14392
- * Mail local parts no team may take as its alias: the role mailboxes RFC 2142
14392
+ * Mail local parts no queue may take as its alias: the role mailboxes RFC 2142
14393
14393
  * names, the addresses mail systems and their operators keep for themselves,
14394
14394
  * the platform's own host labels, and the fixed local part every other mail
14395
- * product writes from (MAIL_PRODUCTS fromLocalPart), so no team writes from
14395
+ * product writes from (MAIL_PRODUCTS fromLocalPart), so no queue writes from
14396
14396
  * the address Notify writes from on a domain both products use.
14397
14397
  */
14398
14398
  Object.freeze([
@@ -14403,16 +14403,17 @@ Object.freeze([
14403
14403
  ...MAIL_PRODUCT_KEYS.map((key) => MAIL_PRODUCTS[key].fromLocalPart).filter((localPart) => localPart !== null)
14404
14404
  ]);
14405
14405
 
14406
- /** The alias a team's mail goes out under until its admin chooses another. */
14407
- const DEFAULT_TEAM_ALIAS = 'support';
14406
+ /** The alias a desk without a mailbox of its own receives and writes from, wherever a queue claims none. */
14407
+ const DEFAULT_QUEUE_ALIAS = 'support';
14408
14408
 
14409
14409
  /**
14410
14410
  * What a customer's new request asks before Cancel throws away what they
14411
- * wrote and the files they added: the portal's New request page and the SDK's
14412
- * support form ask it in place of their actions row, with Keep editing first,
14413
- * as the primary button, focused as the question appears, and Discard after
14414
- * it as the quieter one. Discard sends nothing, forgets the text and cancels
14415
- * each file's upload, so `note` promises no more than both forms do.
14411
+ * wrote and the files they added: the SDK's support form, wherever it is
14412
+ * drawn (the portal's New request page among them), asks it in place of its
14413
+ * actions row, with Keep editing first, as the primary button, focused as the
14414
+ * question appears, and Discard after it as the quieter one. Discard sends
14415
+ * nothing, forgets the text and cancels each file's upload, so `note`
14416
+ * promises no more than the form does.
14416
14417
  */
14417
14418
  const DISCARD_REQUEST_COPY = Object.freeze({
14418
14419
  question: 'Discard this request?',
@@ -14457,14 +14458,14 @@ function helpDeskPinDigits(value) {
14457
14458
  }
14458
14459
 
14459
14460
  /**
14460
- * The address a desk's emailed sign-in codes come from: its default team
14461
+ * The address a desk's emailed sign-in codes come from: its default queue
14461
14462
  * alias on the host the desk sends from (the desk lookup's `sending_host`).
14462
14463
  *
14463
14464
  * @param {string} sendingHost
14464
14465
  * @returns {string}
14465
14466
  */
14466
14467
  function helpDeskCodeSender(sendingHost) {
14467
- return `${DEFAULT_TEAM_ALIAS}@${sendingHost}`;
14468
+ return `${DEFAULT_QUEUE_ALIAS}@${sendingHost}`;
14468
14469
  }
14469
14470
 
14470
14471
  /**
@@ -18287,7 +18288,7 @@ function injectHelpDeskFormStyles() {
18287
18288
  .svhd-input:focus-visible,.svhd-button:focus-visible,.svhd-link:focus-visible{outline:3px solid ${DS.action};outline-offset:2px}
18288
18289
  .svhd-input:disabled{background:${DS.slate50}}
18289
18290
  .svhd-auth{display:grid;gap:16px;border:0;padding:0;margin:0}
18290
- .svhd-form[hidden],.svhd-step[hidden],.svhd-auth[hidden],.svhd-field[hidden],.svhd-field-error[hidden],.svhd-status[hidden],.svhd-link[hidden],.svhd-actions[hidden],.svhd-confirm[hidden],.svhd-widget-account[hidden],.svhd-text-button[hidden],.svhd-composer-drop[hidden],.svhd-attachment-chips[hidden]{display:none}
18291
+ .svhd-form[hidden],.svhd-step[hidden],.svhd-auth[hidden],.svhd-field[hidden],.svhd-field-error[hidden],.svhd-status[hidden],.svhd-link[hidden],.svhd-actions[hidden],.svhd-confirm[hidden],.svhd-widget-account[hidden],.svhd-text-button[hidden]{display:none}
18291
18292
  .svhd-actions{display:flex;align-items:center;gap:12px;flex-wrap:wrap}
18292
18293
  .svhd-button{border:0;border-radius:6px;padding:10px 16px;min-height:44px;font:600 15px/1.5 system-ui,sans-serif;background:${DS.action};color:${DS.white};cursor:pointer}
18293
18294
  .svhd-button:hover{background:${DS.actionHover}}
@@ -18322,41 +18323,54 @@ function injectHelpDeskFormStyles() {
18322
18323
  .svhd-recap-label{display:block;color:${DS.slate600};font-size:12px;font-weight:600;line-height:1.4}
18323
18324
  .svhd-recap-text{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;margin:0;color:${DS.slate900};font-size:14px;line-height:1.5;overflow-wrap:anywhere}
18324
18325
  .svhd-recap .svhd-text-button{flex:none}
18325
- /* The frame is the field: its ring shows wherever focus is inside it, and the text inside draws none of its own. */
18326
- .svhd-composer{position:relative;display:flex;flex-direction:column;min-width:0;border:1px solid ${DS.slate300};border-radius:6px;background:${DS.white}}
18327
- .svhd-composer:has(.svhd-composer-input:focus-visible){outline:3px solid ${DS.action};outline-offset:2px}
18328
- @supports not selector(:has(*)){.svhd-composer:focus-within{outline:3px solid ${DS.action};outline-offset:2px}}
18329
- .svhd-composer-dragging{border-style:dashed;border-color:${DS.action}}
18330
- .svhd-composer-input{display:block;width:100%;min-height:140px;resize:vertical;border:0;border-radius:6px 6px 0 0;padding:10px 12px;background:transparent;color:${DS.slate900};font:inherit;font-size:16px}
18331
- .svhd-composer-input:focus,.svhd-composer-input:focus-visible{outline:none}
18332
- .svhd-composer-input:disabled{background:${DS.slate50}}
18333
- .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:${DS.actionBg};color:${DS.action};font-weight:600;text-align:center;pointer-events:none}
18334
- .svhd-composer-toolbar{display:flex;align-items:center;flex-wrap:wrap;gap:0 12px;padding:0 8px 0 4px;border-top:1px solid ${DS.slate200}}
18335
- .svhd-composer-attach{display:inline-flex;align-items:center;gap:6px;min-height:44px;padding:0 8px;border:0;border-radius:6px;background:transparent;color:${DS.slate600};font:600 14px/1.4 system-ui,sans-serif;cursor:pointer}
18336
- .svhd-composer-attach:hover{background:${DS.slate100};color:${DS.slate900}}
18337
- .svhd-composer-attach:disabled{opacity:.6;cursor:default}
18338
- .svhd-composer .svhd-composer-attach svg{display:block;width:18px;height:18px}
18339
- .svhd-composer-hint{flex:1 1 160px;min-width:0;margin:0;padding:6px 0;font-size:12px;line-height:1.4;color:${DS.slate600}}
18340
- .svhd-composer-notice{margin:0;font-size:14px}
18341
- .svhd-attachment-chips{display:flex;flex-wrap:wrap;gap:8px;list-style:none;margin:0;padding:8px;border-top:1px solid ${DS.slate200}}
18342
- .svhd-attachment-chips:empty{display:none}
18343
- .svhd-attachment-chip{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;flex:0 1 280px;min-width:0;max-width:100%;padding:0 0 8px 10px;border:1px solid ${DS.slate200};border-radius:6px;background:${DS.slate50};font-size:13px;line-height:1.4}
18344
- .svhd-attachment-name{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:600;color:${DS.slate900}}
18345
- .svhd-attachment-status{grid-column:1;padding-right:8px;color:${DS.slate600};font-size:12px;overflow-wrap:anywhere}
18346
- .svhd-attachment-status.svhd-error{color:${DS.error}}
18347
- .svhd-attachment-progress{grid-column:1/-1;width:calc(100% - 10px);height:6px;margin-top:6px;accent-color:${DS.action}}
18348
- .svhd-attachment-chip .svhd-attachment-remove{display:grid;place-items:center;width:44px;height:44px;min-height:44px;padding:0;border:0;border-radius:6px;background:transparent;color:${DS.slate600};cursor:pointer}
18349
- .svhd-attachment-remove:hover{background:${DS.slate200};color:${DS.slate900}}
18350
- .svhd-attachment-chip .svhd-attachment-remove svg{display:block;width:16px;height:16px}
18351
- .svhd-attachment-chip .svhd-attachment-retry{grid-column:2;min-height:44px;padding:0 10px;border:0;border-radius:6px;background:transparent;color:${DS.action};font:600 13px/1.4 system-ui,sans-serif;text-decoration:underline;cursor:pointer}
18352
- .svhd-composer button:focus-visible{outline:3px solid ${DS.action};outline-offset:-3px}
18353
- .svhd-attachment-remove:disabled,.svhd-attachment-retry:disabled{opacity:.6;cursor:default}
18354
18326
  .svhd-live{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
18355
18327
  .svhd-footer{margin-top:20px;font-size:12px;color:${DS.slate500}}
18356
18328
  `;
18357
18329
  document.head.appendChild(style);
18358
18330
  }
18359
18331
 
18332
+ /**
18333
+ * The steps an attachment's upload shows (ATTACHMENT_CEREMONY_STEPS, the help
18334
+ * desk's one wording), each in the state the transfer has actually reached:
18335
+ * the one reading the console's composer and the portal's editor draw.
18336
+ * Nothing here runs on a clock: a step completes only when the transfer
18337
+ * reports what it names, so the same report always shows the same steps.
18338
+ *
18339
+ * - "Sending" runs while the upload starts and its bytes go out, and
18340
+ * completes once every byte has been accepted.
18341
+ * - "Encrypted as it arrives" runs while bytes flow: the vault encrypts each
18342
+ * one on arrival, so it completes with the last of them.
18343
+ * - "Stored" runs from the last byte until the server confirms the file is
18344
+ * stored, which also completes "Integrity verified": the server confirms a
18345
+ * file only once it holds every byte of the size the upload declared, each
18346
+ * chunk under an authentication tag, and the transfer has checked the
18347
+ * offsets it reported along the way. A transfer whose bytes all arrived
18348
+ * while the vault was still saving (`received`: the SDK throws
18349
+ * RECEIVED_STILL_SAVING from ./transfer-retry.js for it) shows the file
18350
+ * stored and the check still to come. Both clients attach such a file as it
18351
+ * is, and the server, which alone learns when the file is stored, refuses a
18352
+ * message sent before then in its own words.
18353
+ *
18354
+ * BROWSER-SAFE: pure data, no Node built-ins.
18355
+ */
18356
+
18357
+
18358
+ /** A step's state. */
18359
+ const CEREMONY_STEP_STATUS = Object.freeze({ PENDING: 'pending', ACTIVE: 'active', COMPLETE: 'complete' });
18360
+
18361
+ const { PENDING, ACTIVE, COMPLETE } = CEREMONY_STEP_STATUS;
18362
+
18363
+ /**
18364
+ * How much of the file has gone out, as a whole percentage.
18365
+ *
18366
+ * @param {{ bytesSent: number, bytesTotal: number }} transfer
18367
+ * @returns {number}
18368
+ */
18369
+ function sentPercent({ bytesSent, bytesTotal }) {
18370
+ if (!(bytesTotal > 0)) return 0;
18371
+ return Math.min(100, Math.floor((bytesSent / bytesTotal) * 100));
18372
+ }
18373
+
18360
18374
  /**
18361
18375
  * The one rule for which characters a file name may hold, shared by every
18362
18376
  * runtime that stores a name (Core refuses them at ingest, and clients check
@@ -18765,8 +18779,9 @@ function formatBytes(bytes, decimals = 1) {
18765
18779
 
18766
18780
  /**
18767
18781
  * What stops a file from joining a message, decided in the browser before any
18768
- * upload starts: the one check the portal's editor and the console's
18769
- * composer run. The server never reads an uploaded file's plaintext, so the
18782
+ * upload starts: the one check the help desk composer (./help-desk-composer.js,
18783
+ * the SDK's ticket form and the portal's reply) and the console's composer
18784
+ * run. The server never reads an uploaded file's plaintext, so the
18770
18785
  * check on a file's first bytes can only run here, over the file itself; the
18771
18786
  * name rule runs here and again on the server when the upload is initiated.
18772
18787
  * Both are the platform's one attachment policy (./attachment-policy.js);
@@ -18838,17 +18853,19 @@ function acceptedKindsCopy(kinds) {
18838
18853
 
18839
18854
  /**
18840
18855
  * The files a ticket accepts, in the one phrase every surface names them by,
18841
- * built from the policy's own list (ACCEPTED_ATTACHMENT_KINDS): the sentence
18842
- * refusing any other file reads it, and so do the API reference
18856
+ * built from the policy's own list (ACCEPTED_ATTACHMENT_KINDS): the help desk
18857
+ * composer's (?) tip reads it, and so do the API reference
18843
18858
  * (apps/api/openapi/overlay.mjs) and the help desk's page on the site
18844
- * (apps/www/_data/helpDeskAttachments.js).
18859
+ * (apps/www/_data/helpDeskAttachments.js). A refused file's sentence names
18860
+ * only that its type can't be attached.
18845
18861
  */
18846
18862
  const ACCEPTED_ATTACHMENTS_COPY = acceptedKindsCopy(ACCEPTED_ATTACHMENT_KINDS);
18847
18863
 
18848
18864
  /**
18849
18865
  * What a customer's file picker says before any file is chosen: what to add,
18850
- * how many files a message takes and how large each may be. The portal's
18851
- * editor and the SDK's support form show it under their pickers.
18866
+ * how many files a message takes and how large each may be. The help desk
18867
+ * composer's (?) tip after its Attach button says it, and it describes
18868
+ * Attach.
18852
18869
  */
18853
18870
  const CUSTOMER_ATTACHMENTS_HINT =
18854
18871
  `Add screenshots, documents or recordings. Up to ${MAX_ATTACHMENTS_PER_MESSAGE} files, ${formatBytes(CUSTOMER_ATTACHMENT_MAX_BYTES)} each.`;
@@ -18856,12 +18873,25 @@ const CUSTOMER_ATTACHMENTS_HINT =
18856
18873
  /**
18857
18874
  * What a customer reads at a desk that takes no files from its customers
18858
18875
  * (the desk lookup's `customer_can_attach_files` is false, the upload refusal
18859
- * CUSTOMER_UPLOAD_REFUSALS.UPLOADS_OFF): the portal's refusal and its note on
18860
- * the files an email left out, and the SDK's support form refusing a file
18861
- * dropped, pasted or uploaded there.
18876
+ * CUSTOMER_UPLOAD_REFUSALS.UPLOADS_OFF): the help desk composer refusing a
18877
+ * file dropped, pasted or uploaded there, and the portal's note on the files
18878
+ * an email left out.
18862
18879
  */
18863
18880
  const NO_CUSTOMER_FILES_COPY = "This help desk doesn't take files from customers.";
18864
18881
 
18882
+ /**
18883
+ * What a customer reads of a file their upload allowance refuses, one
18884
+ * sentence for each reason (CUSTOMER_UPLOAD_REFUSALS) wherever it is said:
18885
+ * the help desk composer's refusal of a file they upload
18886
+ * (./help-desk-composer.js), and the portal's note on the files an email
18887
+ * carried that a request left out. An allowance of 0 turns customer uploads
18888
+ * off, which reads as NO_CUSTOMER_FILES_COPY.
18889
+ */
18890
+ const CUSTOMER_UPLOAD_REFUSAL_COPY = Object.freeze({
18891
+ [CUSTOMER_UPLOAD_REFUSALS.ALLOWANCE_REACHED]: "You've reached this help desk's upload allowance, so this file can't be added.",
18892
+ [CUSTOMER_UPLOAD_REFUSALS.UPLOADS_OFF]: NO_CUSTOMER_FILES_COPY
18893
+ });
18894
+
18865
18895
  /**
18866
18896
  * A file input's `accept`: every extension a ticket accepts
18867
18897
  * (ACCEPTED_ATTACHMENT_EXTENSIONS), each with its dot, so the system's file
@@ -18874,7 +18904,7 @@ const REFUSAL_COPY = Object.freeze({
18874
18904
  [ATTACHMENT_REFUSALS.EMPTY]: 'This file has no name.',
18875
18905
  [ATTACHMENT_REFUSALS.TOO_LONG]: "This file's name is too long. Rename it and try again.",
18876
18906
  [ATTACHMENT_REFUSALS.UNSAFE_NAME]: "This file's name can't be used. Rename it and try again.",
18877
- [ATTACHMENT_REFUSALS.REFUSED_EXTENSION]: `Files of this type can't be attached. You can attach ${ACCEPTED_ATTACHMENTS_COPY}.`,
18907
+ [ATTACHMENT_REFUSALS.REFUSED_EXTENSION]: "Files of this type can't be attached.",
18878
18908
  [ATTACHMENT_REFUSALS.EXECUTABLE]: "This file is a program, and programs can't be attached.",
18879
18909
  [ATTACHMENT_REFUSALS.SCRIPT]: "This file is a script, and scripts can't be attached.",
18880
18910
  [ATTACHMENT_REFUSALS.MARKUP]: "This file holds web page markup, which can't be attached.",
@@ -18910,354 +18940,117 @@ function refusalCopy(refusal, maxBytes) {
18910
18940
  }
18911
18941
 
18912
18942
  /**
18913
- * The help desk's bare outline glyphs, shared by the support wizard and the
18914
- * ticket form: stroked in `currentColor`, so the stylesheet that sizes them
18915
- * also colors them, and hidden from assistive technology, since the control
18916
- * that holds one names it.
18943
+ * A tenant's brand color and the WCAG contrast rules that decide how it may be
18944
+ * used: the one hex rule the server stores, the console checks and the portal
18945
+ * paints, the one contrast reading the console's readouts and the portal's
18946
+ * accent share, and the one way a readout writes that reading.
18947
+ *
18948
+ * A brand color is tenant-controlled, so it is used only when it is a
18949
+ * six-digit hex color, read case-insensitively and held in lowercase; anything
18950
+ * else (a color name, a CSS function, a value that runs on into more CSS) is
18951
+ * no color at all.
18952
+ *
18953
+ * A brand color can be any lightness, so whatever shows it picks what goes
18954
+ * with it: white or ink as the text on its fill, whichever reads more
18955
+ * strongly (at least 4.2:1 on any fill, as far as two inks reach on a
18956
+ * mid-tone), and the color itself as text only where it reaches 4.5:1 on
18957
+ * both grounds accent text stands on, the white surface and the canvas
18958
+ * tone, ink otherwise. accentProperties says that as the accent
18959
+ * custom properties the customer portal paints with and the console's sample
18960
+ * of it shows, in the design system's own tokens.
18961
+ *
18962
+ * BROWSER-SAFE: data only, no imports.
18917
18963
  */
18918
- const PATHS = {
18919
- back: 'm14.5 6-6 6 6 6',
18920
- close: 'm6 6 12 12M18 6 6 18',
18921
- 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',
18922
- check: 'm5 12 4 4L19 6',
18923
- article: 'M14 3H6a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V8Zm0 0v5h5M8 12h8M8 16h6',
18924
- chevron: 'm9 6 6 6-6 6',
18925
- thumbUp: 'M7 10v11H3V10Zm0 1 5-8c2 0 3 1 2 4l-1 3h6a2 2 0 0 1 2 2l-2 7a2 2 0 0 1-2 2H7',
18926
- thumbDown: 'M7 14V3H3v11Zm0-1 5 8c2 0 3-1 2-4l-1-3h6a2 2 0 0 0 2-2l-2-7a2 2 0 0 0-2-2H7',
18927
- paperclip: 'm21 11-8.6 8.6a5.5 5.5 0 0 1-7.8-7.8l8.6-8.6a3.7 3.7 0 0 1 5.2 5.2l-8.6 8.6a1.8 1.8 0 0 1-2.6-2.6L15 6.6',
18928
- info: 'M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18Zm0-10v5m0-8h.01',
18929
- };
18930
- function helpDeskIcon(name) {
18931
- const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
18932
- svg.setAttribute('viewBox', '0 0 24 24');
18933
- svg.setAttribute('aria-hidden', 'true');
18934
- svg.setAttribute('focusable', 'false');
18935
- svg.setAttribute('fill', 'none');
18936
- svg.setAttribute('stroke', 'currentColor');
18937
- svg.setAttribute('stroke-width', '1.7');
18938
- svg.setAttribute('stroke-linecap', 'round');
18939
- svg.setAttribute('stroke-linejoin', 'round');
18940
- const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
18941
- path.setAttribute('d', PATHS[name]);
18942
- svg.append(path);
18943
- return svg;
18964
+
18965
+ const HEX_COLOR = /^#[0-9a-f]{6}$/;
18966
+
18967
+ /** WCAG AA's floor for normal-size text. */
18968
+ const AA_TEXT_CONTRAST = 4.5;
18969
+
18970
+ /**
18971
+ * The canvas tone, the design system's `--canvas` (`--color-slate-50`): the
18972
+ * page ground the customer portal (its pages and a customer's own messages)
18973
+ * and the knowledge base's default theme set accent text on, beside the white
18974
+ * surface. The design system publishes its tokens only as CSS, which this
18975
+ * import-free module cannot read, so the value is mirrored here once, and
18976
+ * tests/brand-color.test.js holds it to packages/design-system/tokens/colors.css.
18977
+ */
18978
+ const CANVAS_COLOR = '#f7fafb';
18979
+
18980
+ /**
18981
+ * The ink, the design system's `--ink` (`--color-slate-900`): the dark text a
18982
+ * pairing paints on a fill and in place of a color too light to stand as
18983
+ * text. Mirrored here once for the same reason as CANVAS_COLOR, and held to
18984
+ * packages/design-system/tokens/colors.css by tests/brand-color.test.js.
18985
+ */
18986
+ const INK_COLOR = '#0d1a20';
18987
+
18988
+ /** Relative luminance (WCAG 2) of a validated `#rrggbb` color. */
18989
+ function relativeLuminance(color) {
18990
+ const [red, green, blue] = [1, 3, 5].map((offset) => {
18991
+ const channel = Number.parseInt(color.slice(offset, offset + 2), 16) / 255;
18992
+ return channel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4;
18993
+ });
18994
+ return 0.2126 * red + 0.7152 * green + 0.0722 * blue;
18944
18995
  }
18945
18996
 
18946
- /** A refusal of files read under the composer, hidden until there is one. */
18947
- function createNotice() {
18948
- const notice = document.createElement('p');
18949
- notice.className = 'svhd-composer-notice svhd-error';
18950
- notice.hidden = true;
18951
- return notice;
18997
+ /** The contrast ratio of two relative luminances. */
18998
+ function contrastRatio(first, second) {
18999
+ return (Math.max(first, second) + 0.05) / (Math.min(first, second) + 0.05);
18952
19000
  }
18953
- /** Show a notice's refusal, or hide it with null. It is an alert only while it shows, as a field's error is. */
18954
- function setNotice(notice, text) {
18955
- notice.textContent = text ?? '';
18956
- notice.hidden = text === null;
18957
- if (text === null)
18958
- notice.removeAttribute('role');
18959
- else
18960
- notice.setAttribute('role', 'alert');
18961
- }
18962
- /** A failed mint's quota/size refusal remains a visible file error, never a silently omitted file. */
18963
- function problem(error) {
18964
- if (error instanceof SparkVaultError) {
18965
- if (error.code === 'upload_refused')
18966
- return { copy: 'This help desk cannot store this file right now. Remove it before sending your request.', retryable: false };
18967
- if (error.statusCode === 413) {
18968
- const max = error.details?.max_bytes;
18969
- return { copy: typeof max === 'number' && Number.isSafeInteger(max) && max > 0 ? tooLargeCopy(max) : 'This file is larger than this help desk accepts.', retryable: false };
18970
- }
18971
- if (error.statusCode === 402) {
18972
- const reason = error.details?.reason;
18973
- return { copy: reason === CUSTOMER_UPLOAD_REFUSALS.UPLOADS_OFF ? NO_CUSTOMER_FILES_COPY
18974
- : reason === CUSTOMER_UPLOAD_REFUSALS.ALLOWANCE_REACHED ? 'You have reached this help desk’s upload allowance.'
18975
- : 'This help desk cannot store more files right now.', retryable: false };
18976
- }
18977
- if (error.statusCode && error.statusCode >= 400 && error.statusCode < 500 && ![408, 409, 429].includes(error.statusCode)) {
18978
- return { copy: 'This file cannot be attached. Remove it before sending your request.', retryable: false };
18979
- }
18980
- }
18981
- return { copy: 'This file could not be uploaded. Try again or remove it.', retryable: true };
18982
- }
18983
- /**
18984
- * The picker owns each file's transfer; it publishes only IDs whose Forge
18985
- * receipt has confirmed storage. `onEntriesChange` hears each file the
18986
- * customer adds or removes.
18987
- */
18988
- function createFormAttachments(client, prefix, context, onEntriesChange) {
18989
- const input = document.createElement('input');
18990
- input.type = 'file';
18991
- input.name = 'attachments';
18992
- input.multiple = true;
18993
- input.accept = ATTACHMENT_INPUT_ACCEPT;
18994
- input.hidden = true;
18995
- input.tabIndex = -1;
18996
- const hint = document.createElement('p');
18997
- hint.id = `${prefix}-attachment-hint`;
18998
- hint.className = 'svhd-composer-hint';
18999
- hint.textContent = CUSTOMER_ATTACHMENTS_HINT;
19000
- const attach = document.createElement('button');
19001
- attach.type = 'button';
19002
- attach.className = 'svhd-composer-attach';
19003
- attach.setAttribute('aria-label', 'Attach files');
19004
- attach.setAttribute('aria-describedby', hint.id);
19005
- const attachText = document.createElement('span');
19006
- attachText.textContent = 'Attach';
19007
- attach.append(helpDeskIcon('paperclip'), attachText);
19008
- const toolbar = document.createElement('div');
19009
- toolbar.className = 'svhd-composer-toolbar';
19010
- toolbar.append(attach, hint, input);
19011
- const notice = createNotice();
19012
- const list = document.createElement('ul');
19013
- list.className = 'svhd-attachment-chips';
19014
- list.setAttribute('aria-label', 'Attached files');
19015
- let entries = [];
19016
- let revision = 0;
19017
- let locked = false;
19018
- let pickingDisabled = false;
19019
- let destroyed = false;
19020
- const current = (entry, ownRevision) => !destroyed && revision === ownRevision && entries.includes(entry) && !entry.controller?.signal.aborted;
19021
- function syncPicking() {
19022
- attach.disabled = locked || pickingDisabled;
19023
- input.disabled = locked || pickingDisabled;
19024
- }
19025
- function controls(entry) {
19026
- entry.remove.disabled = locked;
19027
- entry.retry.disabled = locked || !!entry.operation;
19028
- }
19029
- function update(entry, state, text) {
19030
- entry.state = state;
19031
- entry.row.dataset.state = state;
19032
- entry.status.textContent = text;
19033
- entry.status.classList.toggle('svhd-error', state === 'failed');
19034
- entry.progress.hidden = state !== 'uploading';
19035
- entry.retry.hidden = !(entry.retryable && (state === 'failed' || state === 'received'));
19036
- entry.retry.textContent = state === 'received' ? 'Check upload' : 'Retry';
19037
- entry.retry.setAttribute('aria-label', `${state === 'received' ? 'Check upload' : 'Retry'} ${entry.file.name}`);
19038
- controls(entry);
19039
- }
19040
- async function cancel(entry, id = entry.attachmentId, owner = entry.context) {
19041
- if (!id || !owner)
19042
- return;
19043
- try {
19044
- await client.cancelDraftAttachment(owner.draftId, id, { expectedSessionToken: owner.expectedSessionToken });
19045
- }
19046
- catch {
19047
- // A switched/signed-out customer cannot cancel as the new account.
19048
- // Failed cleanup is left to the server's pending-upload reaper.
19049
- }
19050
- }
19051
- function run(entry) {
19052
- if (entry.operation)
19053
- return entry.operation;
19054
- const ownRevision = revision;
19055
- const controller = new AbortController();
19056
- entry.controller = controller;
19057
- const stillCurrent = () => current(entry, ownRevision) && entry.controller === controller;
19058
- let operation;
19059
- operation = (async () => {
19060
- try {
19061
- update(entry, 'checking', 'Checking file');
19062
- const refusal = await attachmentRefusal(entry.file, CUSTOMER_ATTACHMENT_MAX_BYTES);
19063
- if (!stillCurrent())
19064
- return;
19065
- if (refusal) {
19066
- entry.retryable = false;
19067
- update(entry, 'failed', refusalCopy(refusal, CUSTOMER_ATTACHMENT_MAX_BYTES));
19068
- return;
19069
- }
19070
- const owner = await context();
19071
- if (!stillCurrent())
19072
- return;
19073
- if (!owner) {
19074
- update(entry, 'queued', 'Uploads when you send your request.');
19075
- return;
19076
- }
19077
- const options = {
19078
- signal: controller.signal,
19079
- onProgress: (sent, total) => {
19080
- if (!stillCurrent())
19081
- return;
19082
- const percentage = total > 0 ? Math.max(0, Math.min(100, Math.round(sent / total * 100))) : 0;
19083
- entry.progress.value = percentage;
19084
- entry.status.textContent = percentage === 100 ? 'Verifying stored file' : `Uploading ${percentage}%`;
19085
- },
19086
- };
19087
- // Resume the same receipt/session after a lost answer or delayed
19088
- // publication; never mint another upload for received bytes.
19089
- if (entry.sessionUrl && entry.attachmentId) {
19090
- entry.context = owner;
19091
- update(entry, 'uploading', 'Checking upload');
19092
- await client.resumeAttachment({ sessionUrl: entry.sessionUrl }, entry.file, options);
19093
- }
19094
- else {
19095
- if (entry.attachmentId)
19096
- await cancel(entry);
19097
- if (!stillCurrent())
19098
- return;
19099
- entry.attachmentId = undefined;
19100
- entry.context = owner;
19101
- update(entry, 'starting', 'Starting upload');
19102
- const upload = await client.initiateDraftAttachment(owner.draftId, { name: entry.file.name, size: entry.file.size }, { expectedSessionToken: owner.expectedSessionToken });
19103
- if (!stillCurrent()) {
19104
- await cancel(entry, upload.attachment_id, owner);
19105
- return;
19106
- }
19107
- if (!isResourceIdOf('attachment', upload.attachment_id))
19108
- throw new SparkVaultError('Invalid attachment answer.', 'HELP_DESK_INVALID_RESPONSE');
19109
- entry.attachmentId = upload.attachment_id;
19110
- if (Number.isSafeInteger(upload.max_bytes) && upload.max_bytes > 0 && entry.file.size > upload.max_bytes) {
19111
- throw new SparkVaultError('The file is too large.', 'HELP_DESK_ATTACHMENT_TOO_LARGE', 413, { max_bytes: upload.max_bytes });
19112
- }
19113
- update(entry, 'uploading', 'Uploading 0%');
19114
- await client.sendAttachment(upload.forge_url, entry.file, {
19115
- ...options,
19116
- onSessionCreated: (session) => { if (stillCurrent())
19117
- entry.sessionUrl = session.sessionUrl; },
19118
- });
19119
- }
19120
- if (!stillCurrent())
19121
- return;
19122
- entry.progress.value = 100;
19123
- entry.retryable = false;
19124
- update(entry, 'complete', 'Attached');
19125
- }
19126
- catch (error) {
19127
- if (!stillCurrent())
19128
- return;
19129
- const code = error instanceof SparkVaultError ? error.code : error?.code;
19130
- if (code === RECEIVED_STILL_SAVING) {
19131
- entry.retryable = !!entry.sessionUrl;
19132
- update(entry, 'received', 'File received. Waiting for storage confirmation.');
19133
- return;
19134
- }
19135
- if (code === 'session_gone')
19136
- entry.sessionUrl = undefined;
19137
- const failure = problem(error);
19138
- entry.retryable = failure.retryable;
19139
- update(entry, 'failed', failure.copy);
19140
- }
19141
- finally {
19142
- if (entry.controller === controller)
19143
- entry.controller = undefined;
19144
- if (entry.operation === operation)
19145
- entry.operation = undefined;
19146
- if (entries.includes(entry))
19147
- controls(entry);
19148
- }
19149
- })();
19150
- entry.operation = operation;
19151
- controls(entry);
19152
- return operation;
19153
- }
19154
- function remove(entry) {
19155
- if (locked)
19156
- return;
19157
- // A keyboard removal keeps focus among the files, else on Attach.
19158
- const refocus = document.activeElement === entry.remove;
19159
- const index = entries.indexOf(entry);
19160
- entry.controller?.abort();
19161
- entries = entries.filter(candidate => candidate !== entry);
19162
- entry.row.remove();
19163
- setNotice(notice, null);
19164
- void cancel(entry);
19165
- onEntriesChange();
19166
- if (refocus)
19167
- (entries[Math.min(index, entries.length - 1)]?.remove ?? attach).focus();
19168
- }
19169
- function add(files) {
19170
- if (locked || pickingDisabled || destroyed)
19171
- return;
19172
- const incoming = Array.from(files);
19173
- if (incoming.length === 0)
19174
- return;
19175
- const room = Math.max(0, MAX_ATTACHMENTS_PER_MESSAGE - entries.length);
19176
- setNotice(notice, incoming.length > room ? `You can attach up to ${MAX_ATTACHMENTS_PER_MESSAGE} files. Remove a file before adding another.` : null);
19177
- for (const file of incoming.slice(0, room)) {
19178
- const row = document.createElement('li');
19179
- row.className = 'svhd-attachment-chip';
19180
- const filename = document.createElement('span');
19181
- filename.className = 'svhd-attachment-name';
19182
- filename.textContent = file.name;
19183
- filename.title = file.name;
19184
- const status = document.createElement('span');
19185
- status.className = 'svhd-attachment-status';
19186
- status.setAttribute('role', 'status');
19187
- status.setAttribute('aria-live', 'polite');
19188
- const progress = document.createElement('progress');
19189
- progress.className = 'svhd-attachment-progress';
19190
- progress.max = 100;
19191
- progress.value = 0;
19192
- progress.hidden = true;
19193
- progress.setAttribute('aria-label', `Upload progress for ${file.name}`);
19194
- const removeButton = document.createElement('button');
19195
- removeButton.type = 'button';
19196
- removeButton.className = 'svhd-attachment-remove';
19197
- removeButton.setAttribute('aria-label', `Remove ${file.name}`);
19198
- removeButton.append(helpDeskIcon('close'));
19199
- const retry = document.createElement('button');
19200
- retry.type = 'button';
19201
- retry.className = 'svhd-attachment-retry';
19202
- retry.hidden = true;
19203
- const entry = { file, row, status, progress, remove: removeButton, retry, state: 'queued', retryable: false };
19204
- removeButton.onclick = () => remove(entry);
19205
- retry.onclick = () => { if (!locked && entry.retryable)
19206
- void run(entry); };
19207
- row.append(filename, removeButton, status, retry, progress);
19208
- list.append(row);
19209
- entries.push(entry);
19210
- void run(entry);
19211
- }
19212
- if (room > 0)
19213
- onEntriesChange();
19214
- }
19215
- const onChange = () => { if (input.files)
19216
- add(input.files); input.value = ''; };
19217
- const onAttach = () => { if (!attach.disabled)
19218
- input.click(); };
19219
- input.addEventListener('change', onChange);
19220
- attach.addEventListener('click', onAttach);
19221
- function clear(preserveComplete = false) {
19222
- revision += 1;
19223
- const previous = entries;
19224
- entries = [];
19225
- for (const entry of previous) {
19226
- entry.controller?.abort();
19227
- if (!preserveComplete || entry.state !== 'complete')
19228
- void cancel(entry);
19229
- }
19230
- list.replaceChildren();
19231
- input.value = '';
19232
- setNotice(notice, null);
19233
- }
19234
- return {
19235
- toolbar,
19236
- list,
19237
- notice,
19238
- get accepting() { return !locked && !pickingDisabled && !destroyed; },
19239
- get attachmentIds() { return entries.filter(entry => entry.state === 'complete' && entry.attachmentId).map(entry => entry.attachmentId); },
19240
- get unresolved() { return entries.some(entry => entry.state !== 'complete'); },
19241
- get hasEntries() { return entries.length > 0; },
19242
- get names() { return entries.map(entry => entry.file.name); },
19243
- add,
19244
- async start() { await Promise.all(entries.map(entry => entry.operation ?? (entry.state === 'queued' ? run(entry) : Promise.resolve()))); },
19245
- lock(value) { locked = value; syncPicking(); entries.forEach(controls); },
19246
- disablePicking(value) { pickingDisabled = value; syncPicking(); },
19247
- renewSession(previousToken, nextToken) {
19248
- for (const entry of entries) {
19249
- if (entry.context?.expectedSessionToken === previousToken)
19250
- entry.context = { ...entry.context, expectedSessionToken: nextToken };
19251
- }
19252
- },
19253
- clear,
19254
- destroy(preserveComplete = false) {
19255
- destroyed = true;
19256
- clear(preserveComplete);
19257
- input.removeEventListener('change', onChange);
19258
- attach.removeEventListener('click', onAttach);
19259
- },
19260
- };
19001
+
19002
+ /** The relative luminance of the ink a fill's text is weighed in, the real ink rather than pure black. */
19003
+ const INK_LUMINANCE = relativeLuminance(INK_COLOR);
19004
+
19005
+ /** The relative luminances of the grounds accent text stands on: the white surface and the canvas tone. */
19006
+ const TEXT_GROUNDS = Object.freeze([1, relativeLuminance(CANVAS_COLOR)]);
19007
+
19008
+ /** How strongly a color of this luminance reads as text on the ground it reads least on. */
19009
+ function textContrast(luminance) {
19010
+ return Math.min(...TEXT_GROUNDS.map((ground) => contrastRatio(luminance, ground)));
19011
+ }
19012
+
19013
+ /**
19014
+ * A brand color as it may be stored and shown, or null when the value is not
19015
+ * one: a `#rrggbb` hex value, read case-insensitively.
19016
+ *
19017
+ * @param {unknown} value
19018
+ * @returns {string|null} The color in lowercase
19019
+ */
19020
+ function brandColor(value) {
19021
+ if (typeof value !== 'string') return null;
19022
+ const color = value.toLowerCase();
19023
+ return HEX_COLOR.test(color) ? color : null;
19024
+ }
19025
+
19026
+ /**
19027
+ * What goes with a brand color: the text on its fill (white or ink,
19028
+ * whichever reads more strongly, at least 4.2:1 on any fill) and the ink for
19029
+ * it as text
19030
+ * (the color itself where it reaches AA_TEXT_CONTRAST on both the white
19031
+ * surface and the canvas tone, ink otherwise).
19032
+ *
19033
+ * @param {unknown} value
19034
+ * @returns {{ onAccent: 'white'|'ink', accentInk: 'accent'|'ink', ratio: number }|null} Null when the value is not a brand color; `ratio` is its contrast as text (accentTextContrast)
19035
+ */
19036
+ function accentPairing(value) {
19037
+ const color = brandColor(value);
19038
+ if (!color) return null;
19039
+ const luminance = relativeLuminance(color);
19040
+ const ratio = textContrast(luminance);
19041
+ return {
19042
+ onAccent: contrastRatio(luminance, 1) >= contrastRatio(luminance, INK_LUMINANCE) ? 'white' : 'ink',
19043
+ accentInk: ratio >= AA_TEXT_CONTRAST ? 'accent' : 'ink',
19044
+ ratio
19045
+ };
19046
+ }
19047
+
19048
+ /** Contrast between a brand fill and the label selected by accentPairing. */
19049
+ function accentFillContrast(value) {
19050
+ const color = brandColor(value);
19051
+ if (!color) return null;
19052
+ const pairing = accentPairing(color);
19053
+ return contrastRatio(relativeLuminance(color), pairing.onAccent === 'white' ? 1 : INK_LUMINANCE);
19261
19054
  }
19262
19055
 
19263
19056
  /**
@@ -19295,7 +19088,7 @@ function createFormAttachments(client, prefix, context, onEntriesChange) {
19295
19088
  const DROP_FILES_COPY = 'Drop the files to attach them.';
19296
19089
 
19297
19090
  /** What a person reads when a drop held a folder, which is never attached. */
19298
- const FOLDER_REFUSAL_COPY = 'Folders can’t be attached. Add the files inside them instead.';
19091
+ const FOLDER_REFUSAL_COPY = "Folders can't be attached. Add the files inside them instead.";
19299
19092
 
19300
19093
  /** The name the clipboard gives every pasted picture, with its extension. */
19301
19094
  const CLIPBOARD_IMAGE_NAME = /^image\.(\w+)$/;
@@ -19420,90 +19213,838 @@ function composerFileEvents({ action, frameHolds, heldNames, dragging, attach, r
19420
19213
  }
19421
19214
 
19422
19215
  /**
19423
- * The details field as a composer. A file pasted into the summary or the
19424
- * details, or dropped anywhere on the request step, joins the form's one
19425
- * attachment pipeline (`attachments.add`), under the same limits and
19426
- * refusals as a picked one; the drop target shows only over the composer.
19427
- * How a drag, a drop and a paste are answered (which files they carry, the
19428
- * folders a drop leaves out, the names of pasted pictures, when the drop
19429
- * target shows) is @sparkvault/app-sdk/composer-files' to decide; this says
19430
- * what a file brought now does. A paste or drag of text alone stays the
19431
- * browser's. A file brought over the form is never the browser's to open in
19432
- * place of the unsent request: on the sign-in step, or while the form takes
19433
- * no files, it is refused outright, and a desk that takes no files says so
19434
- * when the file is dropped.
19435
- */
19436
- function createComposer(options) {
19437
- const { form, summary, textarea, attachments, deskRefusesFiles, onRequestStep } = options;
19438
- const frame = document.createElement('div');
19439
- frame.className = 'svhd-composer';
19440
- textarea.classList.add('svhd-composer-input');
19441
- const drop = document.createElement('p');
19442
- drop.className = 'svhd-composer-drop';
19443
- drop.textContent = DROP_FILES_COPY;
19444
- drop.hidden = true;
19445
- frame.append(textarea, drop);
19446
- if (attachments)
19447
- frame.append(attachments.toolbar, attachments.list);
19448
- const notice = attachments?.notice ?? createNotice();
19449
- const fields = [summary, textarea];
19450
- function fileAction() {
19451
- if (!onRequestStep())
19452
- return 'none';
19453
- if (attachments)
19454
- return attachments.accepting ? 'attach' : 'none';
19455
- return deskRefusesFiles ? 'refuse' : 'none';
19456
- }
19457
- function dragging(value) {
19458
- frame.classList.toggle('svhd-composer-dragging', value);
19459
- drop.hidden = !value;
19460
- }
19461
- function refuseFiles() {
19462
- if (!notice.hidden && notice.textContent === NO_CUSTOMER_FILES_COPY)
19463
- return;
19464
- setNotice(notice, NO_CUSTOMER_FILES_COPY);
19465
- }
19466
- // A dropped folder is left out, and said so beside any refusal the files
19467
- // with it met.
19468
- function attach(files, folders) {
19469
- if (files.length > 0)
19470
- attachments?.add(files);
19471
- if (folders > 0)
19472
- setNotice(notice, files.length > 0 && !notice.hidden ? `${FOLDER_REFUSAL_COPY} ${notice.textContent}` : FOLDER_REFUSAL_COPY);
19473
- }
19474
- const fileEvents = composerFileEvents({
19475
- action: fileAction,
19476
- frameHolds: (node) => node instanceof Node && frame.contains(node),
19477
- heldNames: () => attachments?.names ?? [],
19478
- dragging,
19479
- attach,
19480
- refuse: refuseFiles,
19481
- });
19482
- const onInput = () => { if (!attachments)
19483
- setNotice(notice, null); };
19484
- form.addEventListener('dragenter', fileEvents.dragOver);
19485
- form.addEventListener('dragover', fileEvents.dragOver);
19486
- form.addEventListener('dragleave', fileEvents.dragLeave);
19487
- form.addEventListener('drop', fileEvents.drop);
19488
- for (const field of fields) {
19489
- field.addEventListener('paste', fileEvents.paste);
19490
- field.addEventListener('input', onInput);
19491
- }
19216
+ * When an unread Spark expires, as a person reads it on their own clock: the
19217
+ * marketing site's anonymous sender states it on its ready card, and the
19218
+ * console's Create Spark dialog states it before the Spark is made. One
19219
+ * implementation, so both surfaces say the same time the same way.
19220
+ *
19221
+ * BROWSER-SAFE: no imports. It reads the runtime's own locale and time zone.
19222
+ */
19223
+
19224
+
19225
+ /**
19226
+ * A time of day on the reader's own clock, in the house style where the
19227
+ * reader's locale reads a 12-hour clock with its period last ("4:36pm", on
19228
+ * the hour "5pm"), and as the locale writes it otherwise ("16:36").
19229
+ *
19230
+ * @param {Date} date
19231
+ * @returns {string}
19232
+ */
19233
+ function clockTime(date) {
19234
+ const clock = new Intl.DateTimeFormat(undefined, { hour: 'numeric', minute: '2-digit' });
19235
+ const parts = clock.formatToParts(date);
19236
+ const last = parts[parts.length - 1];
19237
+ if (last.type !== 'dayPeriod') return clock.format(date);
19238
+ const part = (type) => parts.find((candidate) => candidate.type === type).value;
19239
+ const minute = part('minute');
19240
+ return `${part('hour')}${minute === '00' ? '' : `:${minute}`}${last.value.replace(/[^\p{L}]/gu, '').toLowerCase()}`;
19241
+ }
19242
+
19243
+ /**
19244
+ * The help desk's bare outline glyphs, drawn by the SDK's support wizard and
19245
+ * ticket form and by the one message composer (./help-desk-composer.js) the
19246
+ * portal's reply shares with them: stroked in `currentColor`, so the
19247
+ * stylesheet that sizes one also colors it, and hidden from assistive
19248
+ * technology, since the control that holds one names it.
19249
+ *
19250
+ * BROWSER-SAFE: builds each glyph through the page's `document`.
19251
+ */
19252
+
19253
+ const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
19254
+
19255
+ const PATHS = Object.freeze({
19256
+ back: 'm14.5 6-6 6 6 6',
19257
+ close: 'm6 6 12 12M18 6 6 18',
19258
+ 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',
19259
+ check: 'm5 12 4 4L19 6',
19260
+ article: 'M14 3H6a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V8Zm0 0v5h5M8 12h8M8 16h6',
19261
+ chevron: 'm9 6 6 6-6 6',
19262
+ thumbUp: 'M7 10v11H3V10Zm0 1 5-8c2 0 3 1 2 4l-1 3h6a2 2 0 0 1 2 2l-2 7a2 2 0 0 1-2 2H7',
19263
+ thumbDown: 'M7 14V3H3v11Zm0-1 5 8c2 0 3-1 2-4l-1-3h6a2 2 0 0 0 2-2l-2-7a2 2 0 0 0-2-2H7',
19264
+ paperclip: 'm21 11-8.6 8.6a5.5 5.5 0 0 1-7.8-7.8l8.6-8.6a3.7 3.7 0 0 1 5.2 5.2l-8.6 8.6a1.8 1.8 0 0 1-2.6-2.6L15 6.6',
19265
+ info: 'M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18Zm0-10v5m0-8h.01'
19266
+ });
19267
+
19268
+ /**
19269
+ * One glyph as an SVG element.
19270
+ *
19271
+ * @param {string} name - One of the glyphs' names (help-desk-icons.d.ts HelpDeskIconName)
19272
+ * @returns {SVGSVGElement}
19273
+ * @throws {TypeError} For a name no glyph has
19274
+ */
19275
+ function helpDeskIcon(name) {
19276
+ if (!Object.hasOwn(PATHS, name)) throw new TypeError('No help desk icon has this name.');
19277
+ const svg = document.createElementNS(SVG_NAMESPACE, 'svg');
19278
+ svg.setAttribute('viewBox', '0 0 24 24');
19279
+ svg.setAttribute('aria-hidden', 'true');
19280
+ svg.setAttribute('focusable', 'false');
19281
+ svg.setAttribute('fill', 'none');
19282
+ svg.setAttribute('stroke', 'currentColor');
19283
+ svg.setAttribute('stroke-width', '1.7');
19284
+ svg.setAttribute('stroke-linecap', 'round');
19285
+ svg.setAttribute('stroke-linejoin', 'round');
19286
+ const path = document.createElementNS(SVG_NAMESPACE, 'path');
19287
+ path.setAttribute('d', PATHS[name]);
19288
+ svg.append(path);
19289
+ return svg;
19290
+ }
19291
+
19292
+ /**
19293
+ * The help desk's one message composer, for a customer writing to a help
19294
+ * desk: the SDK's ticket form (the support wizard's request step, and the
19295
+ * inline form) writes a new request in it, and the portal writes a reply on
19296
+ * a request in it. The text sits in one bordered frame with the Attach
19297
+ * button and the attached files inside it, and every file the customer adds
19298
+ * (picked, pasted or dropped) runs through the one attachment pipeline here,
19299
+ * so both surfaces check, upload, resume, refuse and report a file in the
19300
+ * same steps and the same words.
19301
+ *
19302
+ * - **Adding.** A file picked with Attach, pasted into the text (or into a
19303
+ * field the host names, the SDK's summary), or dropped anywhere on the
19304
+ * host's drop zone joins the same list, under the per-message count
19305
+ * (MAX_ATTACHMENTS_PER_MESSAGE; a file the browser's check refused is no
19306
+ * part of it). How a drag, a drop and a paste are answered (a paste or drag
19307
+ * of text stays the browser's, a dropped folder is left out and said so, a
19308
+ * pasted picture is numbered) is @sparkvault/app-sdk/composer-files'
19309
+ * policy, shared with the console's composer. A file brought to a desk that
19310
+ * takes no files from its customers is refused in words
19311
+ * (NO_CUSTOMER_FILES_COPY), and one brought while files cannot join is
19312
+ * never the browser's to open in place of the unsent message.
19313
+ * - **Help.** What a message takes (how many files, how large, which kinds)
19314
+ * waits behind a (?) tip after Attach, a disclosure that closes by its
19315
+ * trigger, by Escape, by its close button, by a press outside it or by
19316
+ * focus leaving it; a refused file's chip names only why it was refused.
19317
+ * - **Uploading.** The browser's check (attachmentRefusal) first, then the
19318
+ * host's transport: its target (the request a reply belongs to, or the
19319
+ * draft a new request uploads to, which may not exist yet: the file then
19320
+ * waits for `start`), the upload's initiation, and the SDK's resumable
19321
+ * transfer. A transfer that failed after its session opened, or whose
19322
+ * bytes all arrived while the vault was still storing them, resumes that
19323
+ * session rather than uploading the file again. A chip's status line, a
19324
+ * polite live region, changes only with the file's step (Checking file,
19325
+ * Starting upload, Uploading, Verifying stored file, Attached, a failure);
19326
+ * the share of bytes sent (sentPercent, floored, so verifying never shows
19327
+ * before the last byte) is its progress bar's, outside that region.
19328
+ * - **Attached.** Only a file the server confirmed stored joins the message
19329
+ * (`attachmentIds`). A file received but still being stored holds the
19330
+ * message back, as Core refuses a message carrying one
19331
+ * (apps/api/src/help-desk/attachments.js validateAttachmentsBelong), until
19332
+ * its Check upload confirms it.
19333
+ * - **Refused.** One sentence for each refusal (uploadProblem), read from the
19334
+ * host's refusal of the upload's initiation (`transport.refusal`, a refusal
19335
+ * it cannot read a fault anyone may try again) or the transfer's own error,
19336
+ * and whether trying again can mend it.
19337
+ *
19338
+ * The composer draws its own stylesheet (one unlayered `<style>` per
19339
+ * document), in the design system's colors with the help desk's accent
19340
+ * (`--hd-accent-ink`) where the host sets one. Its focus ring is the one the
19341
+ * host's fields wear: its color, width and offset are the host's
19342
+ * `--hd-focus`, `--hd-focus-width` and `--hd-focus-offset`, else the SDK's
19343
+ * field ring (Action Blue, 3px, 2px out).
19344
+ *
19345
+ * BROWSER-SAFE: builds its DOM through the page's `document`, and imports
19346
+ * only app-sdk's browser-safe modules.
19347
+ */
19348
+
19349
+
19350
+ /** The id of the composer's one `<style>` element in a document. */
19351
+ const HELP_DESK_COMPOSER_STYLE_ID = 'sparkvault-help-desk-composer-styles';
19352
+
19353
+ /**
19354
+ * The design-system colors the composer is drawn in, each the value of the
19355
+ * token it names (tests/help-desk-composer.test.js holds them to
19356
+ * packages/design-system/tokens). The canvas tone and the ink are
19357
+ * brand-color.js' mirrors of those tokens.
19358
+ */
19359
+ const COMPOSER_COLORS = Object.freeze({
19360
+ '--color-white': '#ffffff',
19361
+ '--canvas': CANVAS_COLOR,
19362
+ '--color-slate-100': '#f0f5f7',
19363
+ '--color-slate-200': '#e0e9ed',
19364
+ '--color-slate-300': '#c9d6dc',
19365
+ '--color-slate-600': '#425761',
19366
+ '--ink': INK_COLOR,
19367
+ '--color-action': '#216bde',
19368
+ '--color-action-bg': '#eef4fe',
19369
+ '--color-error': '#b02b27'
19370
+ });
19371
+
19372
+ const C = COMPOSER_COLORS;
19373
+ /** The help desk's accent ink where the host sets one, Action Blue where none does. */
19374
+ const ACCENT_INK = `var(--hd-accent-ink,${C['--color-action']})`;
19375
+ /** The focus ring of the host's fields: the SDK's field ring (`.svhd-input`) where the host sets none. */
19376
+ const FOCUS = `var(--hd-focus,${C['--color-action']})`;
19377
+ const FOCUS_WIDTH = 'var(--hd-focus-width,3px)';
19378
+ const FOCUS_OFFSET = 'var(--hd-focus-offset,2px)';
19379
+ /** A control inside the frame wears the ring within its own hit area. */
19380
+ const INSET_RING = `outline:${FOCUS_WIDTH} solid ${FOCUS};outline-offset:calc(-1 * ${FOCUS_WIDTH});box-shadow:none`;
19381
+
19382
+ /**
19383
+ * The composer's stylesheet. Every rule but the notice's sits under
19384
+ * `.svhd-composer`, a class deep, so a host's own element and focus rules
19385
+ * never reach into the frame; the notice, which sits under the frame, is
19386
+ * one class of its own.
19387
+ */
19388
+ const COMPOSER_CSS = `
19389
+ .svhd-composer,.svhd-composer *{box-sizing:border-box}
19390
+ .svhd-composer{position:relative;display:flex;flex-direction:column;min-width:0;border:1px solid ${C['--color-slate-300']};border-radius:6px;background:${C['--color-white']};color:${C['--ink']}}
19391
+ .svhd-composer:has(.svhd-composer-input:focus-visible){outline:${FOCUS_WIDTH} solid ${FOCUS};outline-offset:${FOCUS_OFFSET}}
19392
+ @supports not selector(:has(*)){.svhd-composer:focus-within{outline:${FOCUS_WIDTH} solid ${FOCUS};outline-offset:${FOCUS_OFFSET}}}
19393
+ .svhd-composer:has(.svhd-composer-input[aria-invalid=true]){border-color:${C['--color-error']}}
19394
+ .svhd-composer.svhd-composer-dragging{border-style:dashed;border-color:${ACCENT_INK}}
19395
+ .svhd-composer .svhd-composer-input{display:block;width:100%;min-height:140px;margin:0;resize:vertical;border:0;border-radius:6px 6px 0 0;padding:10px 12px;background:transparent;color:${C['--ink']};font-family:inherit;font-size:16px;line-height:1.5}
19396
+ .svhd-composer .svhd-composer-input:focus,.svhd-composer .svhd-composer-input:focus-visible{outline:none;box-shadow:none}
19397
+ .svhd-composer .svhd-composer-input:disabled{background:${C['--canvas']}}
19398
+ .svhd-composer .svhd-composer-drop{position:absolute;inset:0;z-index:1;display:flex;align-items:center;justify-content:center;margin:0;padding:12px;border-radius:5px;background:${C['--color-action-bg']};color:${ACCENT_INK};font-size:15px;font-weight:600;line-height:1.4;text-align:center;pointer-events:none}
19399
+ .svhd-composer .svhd-composer-toolbar{display:flex;align-items:center;flex-wrap:wrap;gap:0 4px;padding:0 4px;border-top:1px solid ${C['--color-slate-200']}}
19400
+ .svhd-composer .svhd-composer-attach{display:inline-flex;align-items:center;gap:6px;min-height:44px;margin:0;padding:0 8px;border:0;border-radius:6px;background:transparent;color:${C['--color-slate-600']};font-family:inherit;font-size:14px;font-weight:600;line-height:1.4;cursor:pointer}
19401
+ .svhd-composer .svhd-composer-attach:hover,.svhd-composer .svhd-composer-help:hover{background:${C['--color-slate-100']};color:${C['--ink']}}
19402
+ .svhd-composer .svhd-composer-attach:disabled{opacity:.6;cursor:default}
19403
+ .svhd-composer .svhd-composer-attach svg{display:block;width:18px;height:18px}
19404
+ .svhd-composer .svhd-composer-help{display:inline-grid;place-items:center;width:44px;height:44px;margin:0;padding:0;border:0;border-radius:6px;background:transparent;color:${C['--color-slate-600']};font-family:inherit;cursor:pointer}
19405
+ .svhd-composer .svhd-composer-help-glyph{display:inline-grid;place-items:center;width:20px;height:20px;border:1px solid currentColor;border-radius:50%;font-size:13px;font-weight:600;line-height:1}
19406
+ .svhd-composer .svhd-composer-help-panel{display:grid;grid-template-columns:minmax(0,1fr) auto;column-gap:8px;align-items:start;flex:1 1 100%;min-width:0;margin:0 0 8px;padding:10px 12px;border:1px solid ${C['--color-slate-200']};border-radius:6px;background:${C['--canvas']};color:${C['--color-slate-600']};font-size:13px;line-height:1.5}
19407
+ .svhd-composer .svhd-composer-help-copy{grid-column:1;min-width:0;overflow-wrap:anywhere}
19408
+ .svhd-composer .svhd-composer-help-copy p{margin:0}
19409
+ .svhd-composer .svhd-composer-help-copy p+p{margin-top:6px}
19410
+ .svhd-composer .svhd-composer-help-close{grid-row:1;grid-column:2;display:grid;place-items:center;width:44px;height:44px;margin:-10px -12px 0 0;padding:0;border:0;border-radius:6px;background:transparent;color:${C['--color-slate-600']};cursor:pointer}
19411
+ .svhd-composer .svhd-composer-help-close:hover,.svhd-composer .svhd-attachment-remove:hover{background:${C['--color-slate-200']};color:${C['--ink']}}
19412
+ .svhd-composer .svhd-composer-help-close svg,.svhd-composer .svhd-attachment-remove svg{display:block;width:16px;height:16px}
19413
+ .svhd-composer .svhd-attachment-chips{display:flex;flex-wrap:wrap;gap:8px;list-style:none;margin:0;padding:8px;border-top:1px solid ${C['--color-slate-200']}}
19414
+ .svhd-composer .svhd-attachment-chips:empty{display:none}
19415
+ .svhd-composer .svhd-attachment-chip{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;align-content:start;flex:0 1 280px;min-width:0;max-width:100%;margin:0;padding:0 0 8px 10px;border:1px solid ${C['--color-slate-200']};border-radius:6px;background:${C['--canvas']};font-size:13px;line-height:1.4}
19416
+ .svhd-composer .svhd-attachment-name{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:600;color:${C['--ink']}}
19417
+ .svhd-composer .svhd-attachment-status{grid-column:1;padding-right:8px;color:${C['--color-slate-600']};font-size:12px;overflow-wrap:anywhere}
19418
+ .svhd-composer .svhd-attachment-status.svhd-composer-problem{color:${C['--color-error']}}
19419
+ .svhd-composer .svhd-attachment-progress{grid-column:1/-1;width:calc(100% - 10px);height:6px;margin-top:6px;accent-color:${ACCENT_INK}}
19420
+ .svhd-composer .svhd-attachment-remove{display:grid;place-items:center;width:44px;height:44px;min-height:44px;margin:0;padding:0;border:0;border-radius:6px;background:transparent;color:${C['--color-slate-600']};cursor:pointer}
19421
+ .svhd-composer .svhd-attachment-retry{grid-column:2;min-height:44px;margin:0;padding:0 10px;border:0;border-radius:6px;background:transparent;color:${ACCENT_INK};font-family:inherit;font-size:13px;font-weight:600;line-height:1.4;text-decoration:underline;cursor:pointer}
19422
+ .svhd-composer .svhd-attachment-remove:disabled,.svhd-composer .svhd-attachment-retry:disabled{opacity:.6;cursor:default}
19423
+ .svhd-composer .svhd-composer-attach:focus-visible,.svhd-composer .svhd-composer-help:focus-visible,.svhd-composer .svhd-composer-help-close:focus-visible,.svhd-composer .svhd-attachment-remove:focus-visible,.svhd-composer .svhd-attachment-retry:focus-visible{${INSET_RING}}
19424
+ .svhd-composer-notice{margin:0;color:${C['--color-error']};font-size:14px;line-height:1.5}
19425
+ .svhd-composer [hidden],.svhd-composer-notice[hidden]{display:none!important}
19426
+ `;
19427
+
19428
+ /** Draw the composer's stylesheet into the page, once. */
19429
+ function injectComposerStyles() {
19430
+ if (document.getElementById(HELP_DESK_COMPOSER_STYLE_ID)) return;
19431
+ const style = document.createElement('style');
19432
+ style.id = HELP_DESK_COMPOSER_STYLE_ID;
19433
+ style.textContent = COMPOSER_CSS;
19434
+ document.head.append(style);
19435
+ }
19436
+
19437
+ /** Where a file stands, as its chip's `data-state` names it. */
19438
+ const FILE_STATE = Object.freeze({
19439
+ /** Waiting for its target: a new request's draft that does not exist yet. */
19440
+ QUEUED: 'queued',
19441
+ CHECKING: 'checking',
19442
+ /** The browser's check refused it; it never reached the server. */
19443
+ REFUSED: 'refused',
19444
+ STARTING: 'starting',
19445
+ UPLOADING: 'uploading',
19446
+ /** Every byte arrived and the vault is still storing it. */
19447
+ RECEIVED: 'received',
19448
+ COMPLETE: 'complete',
19449
+ FAILED: 'failed'
19450
+ });
19451
+
19452
+ const IN_FLIGHT = new Set([FILE_STATE.QUEUED, FILE_STATE.CHECKING, FILE_STATE.STARTING, FILE_STATE.UPLOADING]);
19453
+
19454
+ const QUEUED_COPY = 'Uploads when you send your request.';
19455
+ const LIMIT_COPY = `You can attach up to ${MAX_ATTACHMENTS_PER_MESSAGE} files. Remove a file before adding another.`;
19456
+ const RECEIVED_COPY = 'File received. Waiting for storage confirmation.';
19457
+ const UPLOAD_FAILED_COPY = "This file couldn't be uploaded. Try again or remove it.";
19458
+ const UPLOADING_COPY = 'Uploading';
19459
+ const VERIFYING_COPY = 'Verifying stored file';
19460
+ /** The (?) tip's name, and what it says a message takes. */
19461
+ const HELP_TITLE = 'Attachment limits';
19462
+ const ACCEPTED_KINDS_COPY = `You can attach ${ACCEPTED_ATTACHMENTS_COPY}.`;
19463
+
19464
+ /** What a message's files still need before it can be sent, from the most pressing. */
19465
+ const HOLD_COPY = Object.freeze({
19466
+ uploading: 'Your files are still uploading.',
19467
+ storing: 'A file is still being stored. Check its upload in a moment, or remove it.',
19468
+ retryable: "Remove the files that couldn't be attached, or try them again.",
19469
+ refused: "Remove the files that can't be attached."
19470
+ });
19471
+
19472
+ /** Core's 402s for a company that cannot pay for a transfer now, which funding can mend. */
19473
+ const FUNDING_CODES = new Set(['USAGE_CREDITS_EXHAUSTED', 'USAGE_CREDIT_FUNDING_REVIEW', 'USAGE_CREDITS_REQUIRED']);
19474
+
19475
+ /**
19476
+ * The 409s a next try can get past: a write the server could not settle now
19477
+ * (CONFLICT), and the SDK's own answer for a customer session that changed
19478
+ * under the upload (HELP_DESK_SESSION_CHANGED), which the next try makes
19479
+ * under the session that stands.
19480
+ */
19481
+ const PASSING_CONFLICTS = new Set(['CONFLICT', 'HELP_DESK_SESSION_CHANGED']);
19482
+
19483
+ /** The transfer's code for a session the server no longer holds: the next try uploads the file afresh. */
19484
+ const SESSION_GONE = 'session_gone';
19485
+
19486
+ const isRecord = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
19487
+
19488
+ /** A `Retry-After` in milliseconds as the moment it names, in epoch seconds, or null. */
19489
+ const momentAfter = (milliseconds) =>
19490
+ Number.isFinite(milliseconds) && milliseconds >= 0 ? Math.ceil((Date.now() + milliseconds) / 1000) : null;
19491
+
19492
+ /**
19493
+ * The SDK transfer's error as an UploadRefusal: the status and Core code a
19494
+ * refusal it met names (`details.status`, `details.coreCode`), else its own
19495
+ * status (0 for no answer), and its `Retry-After`.
19496
+ *
19497
+ * @param {unknown} error
19498
+ * @returns {import('./help-desk-composer.d.ts').UploadRefusal}
19499
+ */
19500
+ function transferRefusal(error) {
19501
+ const details = isRecord(error?.details) ? error.details : null;
19502
+ const status = Number.isInteger(details?.status) ? details.status : Number.isInteger(error?.statusCode) ? error.statusCode : 0;
19503
+ return {
19504
+ status,
19505
+ code: typeof details?.coreCode === 'string' ? details.coreCode : null,
19506
+ details,
19507
+ resetsAt: momentAfter(error?.retryAfterMs)
19508
+ };
19509
+ }
19510
+
19511
+ /**
19512
+ * What a customer reads of a file's failed upload, and whether trying it
19513
+ * again can succeed: after a company's funding recovers, a rate limit, a lost
19514
+ * connection, a conflict a next try gets past (PASSING_CONFLICTS), or a fault. A
19515
+ * refusal of the file itself (its size, the customer's upload allowance, the
19516
+ * company's storage, any other final 4xx) stands however often it is tried.
19517
+ * Null, an error neither the host nor the transfer could read, is a fault.
19518
+ *
19519
+ * @param {import('./help-desk-composer.d.ts').UploadRefusal | null} refusal
19520
+ * @param {string | null} organization - The help desk's company, as the desk names it, or null where it names none
19521
+ * @returns {{ copy: string, retryable: boolean }}
19522
+ */
19523
+ function uploadProblem(refusal, organization) {
19524
+ if (refusal === null) return { copy: UPLOAD_FAILED_COPY, retryable: true };
19525
+ const company = organization || 'This help desk';
19526
+ const { status, code } = refusal;
19527
+ const details = isRecord(refusal.details) ? refusal.details : {};
19528
+ if (status === 402 && FUNDING_CODES.has(code)) {
19529
+ return { copy: `${company} can't take files right now. Try again later.`, retryable: true };
19530
+ }
19531
+ if (status === 429) {
19532
+ const when = Number.isFinite(refusal.resetsAt) ? `at ${clockTime(new Date(refusal.resetsAt * 1000))}` : 'later';
19533
+ return { copy: `Too many uploads for now. Try again ${when}.`, retryable: true };
19534
+ }
19535
+ if (status === 0) return { copy: "This file couldn't be uploaded. Check your connection and try again.", retryable: true };
19536
+ const storageFull = { copy: `${company}'s storage is full, so this file can't be added.`, retryable: false };
19537
+ if (code === 'UPLOAD_POOL_FULL') return storageFull;
19538
+ if (status === 402) {
19539
+ if (typeof details.reason === 'string' && Object.hasOwn(CUSTOMER_UPLOAD_REFUSAL_COPY, details.reason)) {
19540
+ return { copy: CUSTOMER_UPLOAD_REFUSAL_COPY[details.reason], retryable: false };
19541
+ }
19542
+ if (code === 'QUOTA_EXCEEDED' && details.resource === 'storage') return storageFull;
19543
+ return { copy: `${company} can't take files right now.`, retryable: false };
19544
+ }
19545
+ if (status === 413) {
19546
+ const ceiling = details.max_bytes;
19492
19547
  return {
19493
- frame,
19494
- notice,
19495
- clearNotice: () => setNotice(notice, null),
19496
- destroy() {
19497
- form.removeEventListener('dragenter', fileEvents.dragOver);
19498
- form.removeEventListener('dragover', fileEvents.dragOver);
19499
- form.removeEventListener('dragleave', fileEvents.dragLeave);
19500
- form.removeEventListener('drop', fileEvents.drop);
19501
- for (const field of fields) {
19502
- field.removeEventListener('paste', fileEvents.paste);
19503
- field.removeEventListener('input', onInput);
19504
- }
19505
- },
19548
+ copy: Number.isSafeInteger(ceiling) && ceiling > 0 ? tooLargeCopy(ceiling) : 'This file is larger than this help desk accepts.',
19549
+ retryable: false
19506
19550
  };
19551
+ }
19552
+ if (status === 409 && PASSING_CONFLICTS.has(code)) return { copy: UPLOAD_FAILED_COPY, retryable: true };
19553
+ if (status >= 400 && status < 500 && status !== 408) return { copy: "This file can't be attached.", retryable: false };
19554
+ return { copy: UPLOAD_FAILED_COPY, retryable: true };
19555
+ }
19556
+
19557
+ /** A button of the composer's. */
19558
+ function button$1(className, label) {
19559
+ const element = document.createElement('button');
19560
+ element.type = 'button';
19561
+ element.className = className;
19562
+ element.setAttribute('aria-label', label);
19563
+ return element;
19564
+ }
19565
+
19566
+ /**
19567
+ * Frame `options.textarea` as the help desk's message composer.
19568
+ *
19569
+ * @param {import('./help-desk-composer.d.ts').HelpDeskComposerOptions} options
19570
+ * @returns {import('./help-desk-composer.d.ts').HelpDeskComposer}
19571
+ */
19572
+ function createHelpDeskComposer(options) {
19573
+ const {
19574
+ textarea,
19575
+ transport = null,
19576
+ deskRefusesFiles = false,
19577
+ organization,
19578
+ dropZone = null,
19579
+ pasteFields = [],
19580
+ active = () => true,
19581
+ onFilesChange = () => {},
19582
+ onStateChange = () => {}
19583
+ } = options;
19584
+ injectComposerStyles();
19585
+
19586
+ const frame = document.createElement('div');
19587
+ frame.className = 'svhd-composer';
19588
+ textarea.classList.add('svhd-composer-input');
19589
+ const drop = document.createElement('p');
19590
+ drop.className = 'svhd-composer-drop';
19591
+ drop.textContent = DROP_FILES_COPY;
19592
+ drop.hidden = true;
19593
+ frame.append(textarea, drop);
19594
+ const notice = document.createElement('p');
19595
+ notice.className = 'svhd-composer-notice';
19596
+ notice.hidden = true;
19597
+ const zone = dropZone ?? frame;
19598
+ const fields = [textarea, ...pasteFields];
19599
+
19600
+ // The Attach button, the chooser it opens (a filter that offers the
19601
+ // extensions a request takes first, never the check), and its (?) tip,
19602
+ // whose limits also describe Attach.
19603
+ const input = document.createElement('input');
19604
+ input.type = 'file';
19605
+ input.name = 'attachments';
19606
+ input.multiple = true;
19607
+ input.accept = ATTACHMENT_INPUT_ACCEPT;
19608
+ input.hidden = true;
19609
+ input.tabIndex = -1;
19610
+ const hint = document.createElement('p');
19611
+ hint.id = `${textarea.id}-attachment-hint`;
19612
+ hint.textContent = CUSTOMER_ATTACHMENTS_HINT;
19613
+ const kinds = document.createElement('p');
19614
+ kinds.textContent = ACCEPTED_KINDS_COPY;
19615
+ const attach = button$1('svhd-composer-attach', 'Attach files');
19616
+ attach.setAttribute('aria-describedby', hint.id);
19617
+ const attachText = document.createElement('span');
19618
+ attachText.textContent = 'Attach';
19619
+ attach.append(helpDeskIcon('paperclip'), attachText);
19620
+ const helpPanel = document.createElement('div');
19621
+ helpPanel.id = `${textarea.id}-attachment-help`;
19622
+ helpPanel.className = 'svhd-composer-help-panel';
19623
+ helpPanel.setAttribute('role', 'region');
19624
+ helpPanel.setAttribute('aria-label', HELP_TITLE);
19625
+ helpPanel.hidden = true;
19626
+ const helpCopy = document.createElement('div');
19627
+ helpCopy.className = 'svhd-composer-help-copy';
19628
+ helpCopy.append(hint, kinds);
19629
+ const helpClose = button$1('svhd-composer-help-close', 'Close');
19630
+ helpClose.title = 'Close';
19631
+ helpClose.append(helpDeskIcon('close'));
19632
+ helpPanel.append(helpCopy, helpClose);
19633
+ const helpTrigger = button$1('svhd-composer-help', `Help: ${HELP_TITLE}`);
19634
+ helpTrigger.setAttribute('aria-expanded', 'false');
19635
+ helpTrigger.setAttribute('aria-controls', helpPanel.id);
19636
+ const glyph = document.createElement('span');
19637
+ glyph.className = 'svhd-composer-help-glyph';
19638
+ glyph.setAttribute('aria-hidden', 'true');
19639
+ glyph.textContent = '?';
19640
+ helpTrigger.append(glyph);
19641
+ const toolbar = document.createElement('div');
19642
+ toolbar.className = 'svhd-composer-toolbar';
19643
+ toolbar.append(attach, helpTrigger, helpPanel, input);
19644
+ const list = document.createElement('ul');
19645
+ list.className = 'svhd-attachment-chips';
19646
+ list.setAttribute('aria-label', 'Attached files');
19647
+ if (transport) frame.append(toolbar, list);
19648
+
19649
+ let entries = [];
19650
+ // Every clear starts a new revision: an answer for a file of an earlier one is dropped.
19651
+ let revision = 0;
19652
+ let locked = false;
19653
+ let pickingDisabled = false;
19654
+ let destroyed = false;
19655
+ const accepting = () => transport !== null && !locked && !pickingDisabled && !destroyed;
19656
+ const current = (entry, ownRevision) =>
19657
+ !destroyed && revision === ownRevision && entries.includes(entry) && !entry.controller?.signal.aborted;
19658
+
19659
+ // A refusal of files is an alert only while it shows, as a field's error is.
19660
+ function setNotice(text) {
19661
+ notice.textContent = text ?? '';
19662
+ notice.hidden = text === null;
19663
+ if (text === null) notice.removeAttribute('role');
19664
+ else notice.setAttribute('role', 'alert');
19665
+ }
19666
+ function syncPicking() {
19667
+ attach.disabled = !accepting();
19668
+ input.disabled = !accepting();
19669
+ }
19670
+ function controls(entry) {
19671
+ entry.remove.disabled = locked;
19672
+ entry.retry.disabled = locked || Boolean(entry.operation);
19673
+ }
19674
+ function show(entry, state, text) {
19675
+ entry.state = state;
19676
+ entry.row.dataset.state = state;
19677
+ entry.status.textContent = text;
19678
+ entry.status.classList.toggle('svhd-composer-problem', state === FILE_STATE.FAILED || state === FILE_STATE.REFUSED);
19679
+ entry.progress.hidden = state !== FILE_STATE.UPLOADING;
19680
+ const action = state === FILE_STATE.RECEIVED ? 'Check upload' : 'Retry';
19681
+ entry.retry.hidden = !(entry.retryable && (state === FILE_STATE.FAILED || state === FILE_STATE.RECEIVED));
19682
+ entry.retry.textContent = action;
19683
+ entry.retry.setAttribute('aria-label', `${action} ${entry.file.name}`);
19684
+ controls(entry);
19685
+ if (state === FILE_STATE.COMPLETE) onFilesChange();
19686
+ onStateChange();
19687
+ }
19688
+ /**
19689
+ * Cancel an upload the customer no longer means to send, which gives its
19690
+ * share of their upload allowance back at once. One that does not land (a
19691
+ * signed-out or switched customer cannot cancel as the next one) is the
19692
+ * server's to reap.
19693
+ */
19694
+ async function cancel(target, attachmentId) {
19695
+ if (target === null || target === undefined || !attachmentId) return;
19696
+ try {
19697
+ await transport.cancel(target, attachmentId);
19698
+ } catch {
19699
+ // As above: the server reaps the upload.
19700
+ }
19701
+ }
19702
+
19703
+ /** One attempt at a file: the browser's check, its target, then a new upload or the resumed one. */
19704
+ function run(entry) {
19705
+ if (entry.operation) return entry.operation;
19706
+ const ownRevision = revision;
19707
+ const controller = new AbortController();
19708
+ entry.controller = controller;
19709
+ const stillCurrent = () => current(entry, ownRevision) && entry.controller === controller;
19710
+ // Which request a failure met: the host's (its target, the initiation) or the transfer's.
19711
+ let request = null;
19712
+ const operation = (async () => {
19713
+ try {
19714
+ show(entry, FILE_STATE.CHECKING, 'Checking file');
19715
+ const refusal = await attachmentRefusal(entry.file, CUSTOMER_ATTACHMENT_MAX_BYTES);
19716
+ if (!stillCurrent()) return;
19717
+ if (refusal) {
19718
+ entry.retryable = false;
19719
+ show(entry, FILE_STATE.REFUSED, refusalCopy(refusal, CUSTOMER_ATTACHMENT_MAX_BYTES));
19720
+ return;
19721
+ }
19722
+ request = 'host';
19723
+ const target = await transport.target();
19724
+ if (!stillCurrent()) return;
19725
+ if (target === null) {
19726
+ show(entry, FILE_STATE.QUEUED, QUEUED_COPY);
19727
+ return;
19728
+ }
19729
+ const transfer = {
19730
+ signal: controller.signal,
19731
+ // The bar takes every step; the status line, a live region, only a change of step.
19732
+ onProgress: (sent, total) => {
19733
+ if (!stillCurrent()) return;
19734
+ const percent = sentPercent({ bytesSent: sent, bytesTotal: total });
19735
+ entry.progress.value = percent;
19736
+ const step = percent === 100 ? VERIFYING_COPY : UPLOADING_COPY;
19737
+ if (entry.status.textContent !== step) entry.status.textContent = step;
19738
+ }
19739
+ };
19740
+ if (entry.sessionUrl && entry.attachmentId) {
19741
+ // The session this file's bytes went to stands: resume it, never upload them twice.
19742
+ entry.target = target;
19743
+ show(entry, FILE_STATE.UPLOADING, 'Checking upload');
19744
+ request = 'transfer';
19745
+ await transport.resume({ sessionUrl: entry.sessionUrl }, entry.file, transfer);
19746
+ } else {
19747
+ // An upload an earlier attempt left on the server is cancelled
19748
+ // first, so it holds none of the allowance this one is decided on.
19749
+ await cancel(entry.target, entry.attachmentId);
19750
+ if (!stillCurrent()) return;
19751
+ entry.attachmentId = null;
19752
+ entry.target = target;
19753
+ show(entry, FILE_STATE.STARTING, 'Starting upload');
19754
+ const upload = await transport.initiate(target, { name: entry.file.name, size: entry.file.size });
19755
+ if (!stillCurrent()) {
19756
+ await cancel(target, upload?.attachment_id);
19757
+ return;
19758
+ }
19759
+ if (!isResourceIdOf('attachment', upload?.attachment_id)) {
19760
+ entry.retryable = true;
19761
+ show(entry, FILE_STATE.FAILED, UPLOAD_FAILED_COPY);
19762
+ return;
19763
+ }
19764
+ entry.attachmentId = upload.attachment_id;
19765
+ if (Number.isSafeInteger(upload.max_bytes) && upload.max_bytes > 0 && entry.file.size > upload.max_bytes) {
19766
+ entry.retryable = false;
19767
+ show(entry, FILE_STATE.FAILED, tooLargeCopy(upload.max_bytes));
19768
+ return;
19769
+ }
19770
+ entry.progress.value = 0;
19771
+ show(entry, FILE_STATE.UPLOADING, UPLOADING_COPY);
19772
+ request = 'transfer';
19773
+ await transport.send(upload.forge_url, entry.file, {
19774
+ ...transfer,
19775
+ onSessionCreated: (session) => {
19776
+ if (stillCurrent()) entry.sessionUrl = session.sessionUrl;
19777
+ }
19778
+ });
19779
+ }
19780
+ if (!stillCurrent()) return;
19781
+ entry.progress.value = 100;
19782
+ entry.retryable = false;
19783
+ show(entry, FILE_STATE.COMPLETE, 'Attached');
19784
+ } catch (error) {
19785
+ if (!stillCurrent()) return;
19786
+ if (request === 'transfer' && error?.code === RECEIVED_STILL_SAVING) {
19787
+ entry.retryable = Boolean(entry.sessionUrl);
19788
+ show(entry, FILE_STATE.RECEIVED, RECEIVED_COPY);
19789
+ return;
19790
+ }
19791
+ if (request === 'transfer' && error?.code === SESSION_GONE) {
19792
+ entry.sessionUrl = null;
19793
+ entry.retryable = true;
19794
+ show(entry, FILE_STATE.FAILED, UPLOAD_FAILED_COPY);
19795
+ return;
19796
+ }
19797
+ const problem = uploadProblem(refusalOf(request, error), organization);
19798
+ entry.retryable = problem.retryable;
19799
+ show(entry, FILE_STATE.FAILED, problem.copy);
19800
+ } finally {
19801
+ if (entry.controller === controller) entry.controller = null;
19802
+ if (entry.operation === operation) entry.operation = null;
19803
+ if (entries.includes(entry)) controls(entry);
19804
+ }
19805
+ })();
19806
+ entry.operation = operation;
19807
+ controls(entry);
19808
+ return operation;
19809
+ }
19810
+
19811
+ /**
19812
+ * The refusal a failure names, read by the request it met: the host's
19813
+ * reading of its own refusal, or the transfer's. A host reading that throws
19814
+ * leaves a fault, which the customer may try again, never a stuck chip.
19815
+ */
19816
+ function refusalOf(request, error) {
19817
+ if (request === 'transfer') return transferRefusal(error);
19818
+ if (request !== 'host') return null;
19819
+ try {
19820
+ return transport.refusal(error);
19821
+ } catch {
19822
+ return null;
19823
+ }
19824
+ }
19825
+
19826
+ function remove(entry) {
19827
+ if (locked) return;
19828
+ // A keyboard removal keeps focus among the files, else on Attach.
19829
+ const refocus = document.activeElement === entry.remove;
19830
+ const index = entries.indexOf(entry);
19831
+ entry.controller?.abort();
19832
+ entries = entries.filter((candidate) => candidate !== entry);
19833
+ entry.row.remove();
19834
+ setNotice(null);
19835
+ void cancel(entry.target, entry.attachmentId);
19836
+ onFilesChange();
19837
+ onStateChange();
19838
+ if (refocus) (entries[Math.min(index, entries.length - 1)]?.remove ?? attach).focus();
19839
+ }
19840
+
19841
+ function add(files) {
19842
+ if (!accepting()) return;
19843
+ const incoming = Array.from(files);
19844
+ if (incoming.length === 0) return;
19845
+ const counted = entries.filter((entry) => entry.state !== FILE_STATE.REFUSED).length;
19846
+ const room = Math.max(0, MAX_ATTACHMENTS_PER_MESSAGE - counted);
19847
+ setNotice(incoming.length > room ? LIMIT_COPY : null);
19848
+ for (const file of incoming.slice(0, room)) {
19849
+ const row = document.createElement('li');
19850
+ row.className = 'svhd-attachment-chip';
19851
+ const name = document.createElement('span');
19852
+ name.className = 'svhd-attachment-name';
19853
+ name.textContent = file.name;
19854
+ name.title = file.name;
19855
+ const status = document.createElement('span');
19856
+ status.className = 'svhd-attachment-status';
19857
+ status.setAttribute('role', 'status');
19858
+ status.setAttribute('aria-live', 'polite');
19859
+ const progress = document.createElement('progress');
19860
+ progress.className = 'svhd-attachment-progress';
19861
+ progress.max = 100;
19862
+ progress.value = 0;
19863
+ progress.hidden = true;
19864
+ progress.setAttribute('aria-label', `Upload progress for ${file.name}`);
19865
+ const removeButton = button$1('svhd-attachment-remove', `Remove ${file.name}`);
19866
+ removeButton.append(helpDeskIcon('close'));
19867
+ const retry = document.createElement('button');
19868
+ retry.type = 'button';
19869
+ retry.className = 'svhd-attachment-retry';
19870
+ retry.hidden = true;
19871
+ const entry = {
19872
+ file, row, status, progress, remove: removeButton, retry,
19873
+ state: FILE_STATE.QUEUED, retryable: false, controller: null, operation: null,
19874
+ target: null, attachmentId: null, sessionUrl: null
19875
+ };
19876
+ removeButton.addEventListener('click', () => remove(entry));
19877
+ retry.addEventListener('click', () => {
19878
+ if (!locked && entry.retryable) void run(entry);
19879
+ });
19880
+ row.append(name, removeButton, status, retry, progress);
19881
+ list.append(row);
19882
+ entries.push(entry);
19883
+ void run(entry);
19884
+ }
19885
+ if (room > 0) {
19886
+ onFilesChange();
19887
+ onStateChange();
19888
+ }
19889
+ }
19890
+
19891
+ // What a file brought to the host does: join the message, be refused in words, or nothing.
19892
+ function fileAction() {
19893
+ if (!active()) return 'none';
19894
+ if (transport) return accepting() ? 'attach' : 'none';
19895
+ return deskRefusesFiles ? 'refuse' : 'none';
19896
+ }
19897
+ function dragging(value) {
19898
+ frame.classList.toggle('svhd-composer-dragging', value);
19899
+ drop.hidden = !value;
19900
+ }
19901
+ function refuseFiles() {
19902
+ if (!notice.hidden && notice.textContent === NO_CUSTOMER_FILES_COPY) return;
19903
+ setNotice(NO_CUSTOMER_FILES_COPY);
19904
+ }
19905
+ // A dropped folder is left out, and said so beside any refusal the files with it met.
19906
+ function attachBrought(files, folders) {
19907
+ if (files.length > 0) add(files);
19908
+ if (folders > 0) setNotice(files.length > 0 && !notice.hidden ? `${FOLDER_REFUSAL_COPY} ${notice.textContent}` : FOLDER_REFUSAL_COPY);
19909
+ }
19910
+ const fileEvents = composerFileEvents({
19911
+ action: fileAction,
19912
+ frameHolds: (node) => node instanceof Node && frame.contains(node),
19913
+ heldNames: () => entries.map((entry) => entry.file.name),
19914
+ dragging,
19915
+ attach: attachBrought,
19916
+ refuse: refuseFiles
19917
+ });
19918
+
19919
+ // The (?) tip: a disclosure that closes by its trigger, Escape, its close
19920
+ // button (focus back on the trigger), a press outside it, or focus leaving it.
19921
+ const inTip = (node) => node instanceof Node && (helpTrigger.contains(node) || helpPanel.contains(node));
19922
+ function setHelpOpen(open) {
19923
+ helpPanel.hidden = !open;
19924
+ helpTrigger.setAttribute('aria-expanded', String(open));
19925
+ if (open) document.addEventListener('pointerdown', onPressOutsideHelp);
19926
+ else document.removeEventListener('pointerdown', onPressOutsideHelp);
19927
+ }
19928
+ function onPressOutsideHelp(event) {
19929
+ if (!inTip(event.target)) setHelpOpen(false);
19930
+ }
19931
+ const onHelpToggle = () => setHelpOpen(helpPanel.hidden);
19932
+ const onHelpClose = () => {
19933
+ setHelpOpen(false);
19934
+ helpTrigger.focus();
19935
+ };
19936
+ // Escape is the tip's alone while it is open: a dialog the form sits in leaves a handled key alone.
19937
+ const onHelpKey = (event) => {
19938
+ if (event.key !== 'Escape' || helpPanel.hidden) return;
19939
+ event.preventDefault();
19940
+ onHelpClose();
19941
+ };
19942
+ const onHelpFocusOut = (event) => {
19943
+ if (!helpPanel.hidden && event.relatedTarget && !inTip(event.relatedTarget)) setHelpOpen(false);
19944
+ };
19945
+
19946
+ // A desk's refusal of files gives way once the customer writes on.
19947
+ const onInput = () => {
19948
+ if (!transport) setNotice(null);
19949
+ };
19950
+ const onChoose = () => {
19951
+ if (input.files) add(input.files);
19952
+ // The same file can be chosen again after it is removed.
19953
+ input.value = '';
19954
+ };
19955
+ const onAttach = () => {
19956
+ if (!attach.disabled) input.click();
19957
+ };
19958
+
19959
+ zone.addEventListener('dragenter', fileEvents.dragOver);
19960
+ zone.addEventListener('dragover', fileEvents.dragOver);
19961
+ zone.addEventListener('dragleave', fileEvents.dragLeave);
19962
+ zone.addEventListener('drop', fileEvents.drop);
19963
+ for (const field of fields) {
19964
+ field.addEventListener('paste', fileEvents.paste);
19965
+ field.addEventListener('input', onInput);
19966
+ }
19967
+ input.addEventListener('change', onChoose);
19968
+ attach.addEventListener('click', onAttach);
19969
+ helpTrigger.addEventListener('click', onHelpToggle);
19970
+ helpClose.addEventListener('click', onHelpClose);
19971
+ for (const part of [helpTrigger, helpPanel]) {
19972
+ part.addEventListener('keydown', onHelpKey);
19973
+ part.addEventListener('focusout', onHelpFocusOut);
19974
+ }
19975
+
19976
+ function clear(keepAttached = false) {
19977
+ revision += 1;
19978
+ const previous = entries;
19979
+ entries = [];
19980
+ for (const entry of previous) {
19981
+ entry.controller?.abort();
19982
+ if (!keepAttached || entry.state !== FILE_STATE.COMPLETE) void cancel(entry.target, entry.attachmentId);
19983
+ }
19984
+ list.replaceChildren();
19985
+ input.value = '';
19986
+ setNotice(null);
19987
+ }
19988
+
19989
+ return {
19990
+ frame,
19991
+ notice,
19992
+ get hasFiles() {
19993
+ return entries.length > 0;
19994
+ },
19995
+ get attachmentIds() {
19996
+ return entries.filter((entry) => entry.state === FILE_STATE.COMPLETE).map((entry) => entry.attachmentId);
19997
+ },
19998
+ get holdCopy() {
19999
+ if (entries.some((entry) => IN_FLIGHT.has(entry.state))) return HOLD_COPY.uploading;
20000
+ if (entries.some((entry) => entry.state === FILE_STATE.RECEIVED)) return HOLD_COPY.storing;
20001
+ if (entries.some((entry) => entry.state === FILE_STATE.FAILED && entry.retryable)) return HOLD_COPY.retryable;
20002
+ if (entries.some((entry) => entry.state !== FILE_STATE.COMPLETE)) return HOLD_COPY.refused;
20003
+ return null;
20004
+ },
20005
+ async start() {
20006
+ await Promise.all(entries.map((entry) => entry.operation ?? (entry.state === FILE_STATE.QUEUED ? run(entry) : null)));
20007
+ },
20008
+ lock(value) {
20009
+ locked = value;
20010
+ syncPicking();
20011
+ entries.forEach(controls);
20012
+ },
20013
+ disablePicking(value) {
20014
+ pickingDisabled = value;
20015
+ syncPicking();
20016
+ },
20017
+ hideFiles(value) {
20018
+ list.hidden = value;
20019
+ },
20020
+ rebind(rebound) {
20021
+ for (const entry of entries) {
20022
+ if (entry.target !== null) entry.target = rebound(entry.target);
20023
+ }
20024
+ },
20025
+ clear,
20026
+ destroy(keepAttached = false) {
20027
+ destroyed = true;
20028
+ clear(keepAttached);
20029
+ setHelpOpen(false);
20030
+ zone.removeEventListener('dragenter', fileEvents.dragOver);
20031
+ zone.removeEventListener('dragover', fileEvents.dragOver);
20032
+ zone.removeEventListener('dragleave', fileEvents.dragLeave);
20033
+ zone.removeEventListener('drop', fileEvents.drop);
20034
+ for (const field of fields) {
20035
+ field.removeEventListener('paste', fileEvents.paste);
20036
+ field.removeEventListener('input', onInput);
20037
+ }
20038
+ input.removeEventListener('change', onChoose);
20039
+ attach.removeEventListener('click', onAttach);
20040
+ helpTrigger.removeEventListener('click', onHelpToggle);
20041
+ helpClose.removeEventListener('click', onHelpClose);
20042
+ for (const part of [helpTrigger, helpPanel]) {
20043
+ part.removeEventListener('keydown', onHelpKey);
20044
+ part.removeEventListener('focusout', onHelpFocusOut);
20045
+ }
20046
+ }
20047
+ };
19507
20048
  }
19508
20049
 
19509
20050
  const TTL_MS = 30 * 60 * 1000;
@@ -19650,6 +20191,18 @@ function saveFormDraft(deskId, requesterId, value) {
19650
20191
  }
19651
20192
 
19652
20193
  let formSequence = 0;
20194
+ /**
20195
+ * The desk API's refusal of a file's draft or upload, as the composer reads
20196
+ * it (status 0 for no answer); null for an error the SDK did not build.
20197
+ */
20198
+ function draftUploadRefusal(error) {
20199
+ if (!(error instanceof SparkVaultError))
20200
+ return null;
20201
+ const details = error.details ?? null;
20202
+ const resetsAt = typeof details?.resets_at === 'number' ? details.resets_at
20203
+ : error.retryAfterMs !== null ? Math.ceil((Date.now() + error.retryAfterMs) / 1000) : null;
20204
+ return { status: error.statusCode ?? 0, code: error.serviceCode ?? error.code, details, resetsAt };
20205
+ }
19653
20206
  /** An absent or server-side answer cannot establish that the write was refused. */
19654
20207
  function unknownSubmissionOutcome(error) {
19655
20208
  // The client can suppress a response after the write was accepted. A new
@@ -19700,16 +20253,16 @@ function textButton(text, action) {
19700
20253
  button.addEventListener('click', action);
19701
20254
  return button;
19702
20255
  }
19703
- const UNSENT_NOTE_COPY = 'Your request hasn’t been sent yet. Sign in so we know who to reply to, then we’ll send it.';
19704
- const SIGN_IN_HELP_COPY = 'A secure window opens. Sign in with your email, or continue with an account you’re already signed in to.';
20256
+ const UNSENT_NOTE_COPY = "Your request hasn't been sent yet. Sign in so we know who to reply to, then we'll send it.";
20257
+ const SIGN_IN_HELP_COPY = "A secure window opens. Sign in with your email, or continue with an account you're already signed in to.";
19705
20258
  const SIGNING_IN_COPY = 'Finish signing in using the secure window.';
19706
20259
  const SWITCHING_COPY = 'Choose an account in the secure window.';
19707
- const SIGNED_OUT_COPY = 'You’re signed out of support. What you wrote is still here.';
20260
+ const SIGNED_OUT_COPY = "You're signed out of support. What you wrote is still here.";
19708
20261
  const FILES_AGAIN_COPY = 'Choose your files again before sending.';
19709
- const SIGN_IN_CANCELLED_COPY = 'Sign-in was cancelled. Your request is still here and hasn’t been sent.';
20262
+ const SIGN_IN_CANCELLED_COPY = "Sign-in was cancelled. Your request is still here and hasn't been sent.";
19710
20263
  const RECOVER_STATUS_COPY = 'Sign in again to recover your saved request.';
19711
20264
  const RECOVER_WEBSITE_COPY = 'Sign in to your website account again to recover your saved request.';
19712
- const WEBSITE_SIGNED_OUT_COPY = 'You’re not signed in to the website. Sign in there, then choose Use website account again.';
20265
+ const WEBSITE_SIGNED_OUT_COPY = "You're not signed in to the website. Sign in there, then choose Use website account again.";
19713
20266
  const RECOVER_NOTE_COPY = 'Sign in with the same email as before to recover your saved request.';
19714
20267
  /** Host callback failures do not change a ticket's accepted or failed result. */
19715
20268
  function notify$1(callback, value) {
@@ -19915,26 +20468,42 @@ function mountHelpDeskForm(client, options) {
19915
20468
  event.preventDefault();
19916
20469
  focusAtEnd(description.input);
19917
20470
  });
19918
- const attachments = client.desk.customer_can_attach_files && options.attachments !== false
19919
- ? createFormAttachments(client, prefix, async () => {
19920
- const ownGeneration = generation;
19921
- const token = await tokenFor(ownGeneration);
19922
- if (!token || !alive(ownGeneration))
19923
- return null;
19924
- const id = await ensureDraft(ownGeneration, token);
19925
- if (!alive(ownGeneration))
19926
- return null;
19927
- return { draftId: id, expectedSessionToken: token };
19928
- }, () => {
19929
- if (attachments?.hasEntries)
20471
+ // A file uploads to the request's draft, made once the customer is signed
20472
+ // in; until then it waits for the send.
20473
+ const transport = client.desk.customer_can_attach_files && options.attachments !== false
20474
+ ? {
20475
+ async target() {
20476
+ const ownGeneration = generation;
20477
+ const token = await tokenFor(ownGeneration);
20478
+ if (!token || !alive(ownGeneration))
20479
+ return null;
20480
+ const id = await ensureDraft(ownGeneration, token);
20481
+ if (!alive(ownGeneration))
20482
+ return null;
20483
+ return { draftId: id, expectedSessionToken: token };
20484
+ },
20485
+ initiate: (upload, file) => client.initiateDraftAttachment(upload.draftId, file, { expectedSessionToken: upload.expectedSessionToken }),
20486
+ cancel: (upload, attachmentId) => client.cancelDraftAttachment(upload.draftId, attachmentId, { expectedSessionToken: upload.expectedSessionToken }),
20487
+ send: (url, file, transfer) => client.sendAttachment(url, file, transfer),
20488
+ resume: (session, file, transfer) => client.resumeAttachment(session, file, transfer),
20489
+ refusal: draftUploadRefusal,
20490
+ }
20491
+ : null;
20492
+ const composer = createHelpDeskComposer({
20493
+ textarea: description.input,
20494
+ transport,
20495
+ deskRefusesFiles: !client.desk.customer_can_attach_files,
20496
+ organization: client.desk.organization_name,
20497
+ dropZone: form,
20498
+ pasteFields: [subject.input],
20499
+ active: () => step === 'details',
20500
+ // What the request carries is saved with it; a file's step is not.
20501
+ onFilesChange: () => {
20502
+ if (composer.hasFiles)
19930
20503
  restoredFiles = false;
19931
20504
  persistDraft();
19932
20505
  syncLeaveGuard();
19933
- })
19934
- : undefined;
19935
- const composer = createComposer({
19936
- form, summary: subject.input, textarea: description.input, attachments,
19937
- deskRefusesFiles: !client.desk.customer_can_attach_files, onRequestStep: () => step === 'details',
20506
+ },
19938
20507
  });
19939
20508
  description.wrapper.classList.add('svhd-composer-field');
19940
20509
  description.wrapper.insertBefore(composer.frame, description.error);
@@ -20075,8 +20644,14 @@ function mountHelpDeskForm(client, options) {
20075
20644
  let websiteSignedOut = false;
20076
20645
  // The form is held while the secure window chooses another account: no send is under way.
20077
20646
  let switchingAccount = false;
20647
+ /**
20648
+ * Save the request as the form holds it. Never while a sign-in is under
20649
+ * way: a session notification then blanks the fields until the sign-in's
20650
+ * answer confirms its customer, and nothing may save that blank over the
20651
+ * request.
20652
+ */
20078
20653
  function persistDraft() {
20079
- if (!options.persist || completed || destroyed)
20654
+ if (!options.persist || completed || destroyed || authenticating)
20080
20655
  return;
20081
20656
  if (!draftOwner) {
20082
20657
  // The hidden request is a previous customer's; nothing is saved over it.
@@ -20086,7 +20661,7 @@ function mountHelpDeskForm(client, options) {
20086
20661
  }
20087
20662
  saveFormDraft(client.desk.desk_id, draftOwner.requester_id, {
20088
20663
  subject: subject.input.value, body: description.input.value, ticketId: draftId,
20089
- uncertain: uncertainSubmission, hadFiles: restoredFiles || attachments?.hasEntries === true,
20664
+ uncertain: uncertainSubmission, hadFiles: restoredFiles || composer.hasFiles,
20090
20665
  });
20091
20666
  }
20092
20667
  function forgetDraft() {
@@ -20137,7 +20712,7 @@ function mountHelpDeskForm(client, options) {
20137
20712
  */
20138
20713
  function safeComposition() {
20139
20714
  return pending || uncertainSubmission !== null || completed ? null
20140
- : { subject: subject.input.value, body: description.input.value, hadFiles: attachments?.hasEntries === true };
20715
+ : { subject: subject.input.value, body: description.input.value, hadFiles: composer.hasFiles };
20141
20716
  }
20142
20717
  /** What the send button reads while nothing is in flight. */
20143
20718
  function idleLabel() {
@@ -20321,8 +20896,8 @@ function mountHelpDeskForm(client, options) {
20321
20896
  for (const button of widgetAccount.querySelectorAll('button'))
20322
20897
  button.disabled = disabled || uncertainSubmission !== null || completed;
20323
20898
  renderResend();
20324
- attachments?.disablePicking(disabled || recovery !== null);
20325
- attachments?.lock(completed || uncertainSubmission !== null);
20899
+ composer.disablePicking(disabled || recovery !== null);
20900
+ composer.lock(completed || uncertainSubmission !== null);
20326
20901
  }
20327
20902
  function clearCode() {
20328
20903
  code.input.value = '';
@@ -20401,7 +20976,7 @@ function mountHelpDeskForm(client, options) {
20401
20976
  return false;
20402
20977
  return (pending && state !== 'authenticating') || uncertainSubmission !== null || challenge !== null || step === 'identity'
20403
20978
  || edited(subject.input, filledWith('subject')) || edited(description.input, filledWith('body'))
20404
- || attachments?.hasEntries === true;
20979
+ || composer.hasFiles;
20405
20980
  }
20406
20981
  /**
20407
20982
  * The field a request the ticket write would refuse is refused under, with
@@ -20478,11 +21053,9 @@ function mountHelpDeskForm(client, options) {
20478
21053
  done = null;
20479
21054
  form.hidden = false;
20480
21055
  closeConfirm(false);
20481
- attachments?.clear(completed || uncertainSubmission !== null);
20482
- attachments?.lock(false);
20483
- if (attachments)
20484
- attachments.list.hidden = false;
20485
- composer.clearNotice();
21056
+ composer.clear(completed || uncertainSubmission !== null);
21057
+ composer.lock(false);
21058
+ composer.hideFiles(false);
20486
21059
  subject.input.value = '';
20487
21060
  description.input.value = '';
20488
21061
  email.input.value = '';
@@ -20521,7 +21094,7 @@ function mountHelpDeskForm(client, options) {
20521
21094
  // and never authenticates one as a side effect of cleanup.
20522
21095
  const token = client.verifiedSessionTokenFor(change.requesterId);
20523
21096
  if (token && previousToken) {
20524
- attachments?.renewSession(previousToken, token);
21097
+ composer.rebind((upload) => upload.expectedSessionToken === previousToken ? { ...upload, expectedSessionToken: token } : upload);
20525
21098
  sessionToken = token;
20526
21099
  }
20527
21100
  return;
@@ -20542,8 +21115,7 @@ function mountHelpDeskForm(client, options) {
20542
21115
  name.input.value = '';
20543
21116
  email.input.value = '';
20544
21117
  clearCode();
20545
- if (attachments)
20546
- attachments.list.hidden = true;
21118
+ composer.hideFiles(true);
20547
21119
  return;
20548
21120
  }
20549
21121
  // Preserve the old request before hiding it. The next verified requester
@@ -20739,8 +21311,7 @@ function mountHelpDeskForm(client, options) {
20739
21311
  sessionToken = token;
20740
21312
  sessionKnown = true;
20741
21313
  authenticating = false;
20742
- if (attachments)
20743
- attachments.list.hidden = false;
21314
+ composer.hideFiles(false);
20744
21315
  subject.input.value = subjectText;
20745
21316
  description.input.value = detailsText;
20746
21317
  if (widget && session) {
@@ -20803,8 +21374,7 @@ function mountHelpDeskForm(client, options) {
20803
21374
  sessionToken = token;
20804
21375
  sessionKnown = true;
20805
21376
  authenticating = false;
20806
- if (attachments)
20807
- attachments.list.hidden = false;
21377
+ composer.hideFiles(false);
20808
21378
  dropChallenge();
20809
21379
  subject.input.value = subjectText;
20810
21380
  description.input.value = detailsText;
@@ -20845,12 +21415,13 @@ function mountHelpDeskForm(client, options) {
20845
21415
  if (!alive(ownGeneration) || !(await tokenFor(ownGeneration)))
20846
21416
  return;
20847
21417
  }
20848
- if (!recoveringSubmission && attachments) {
20849
- await attachments.start();
21418
+ if (!recoveringSubmission && transport) {
21419
+ await composer.start();
20850
21420
  if (!alive(ownGeneration) || !(await tokenFor(ownGeneration)))
20851
21421
  return;
20852
- if (attachments.unresolved) {
20853
- message('Finish uploading your files, or remove files that could not be attached.', true);
21422
+ const held = composer.holdCopy;
21423
+ if (held !== null) {
21424
+ message(held, true);
20854
21425
  return;
20855
21426
  }
20856
21427
  }
@@ -20867,12 +21438,12 @@ function mountHelpDeskForm(client, options) {
20867
21438
  sourceArticleId = options.sourceArticleId?.();
20868
21439
  }
20869
21440
  catch { /* Optional context cannot prevent sending. */ }
20870
- uncertainSubmission = { ticketId: id, subject: subjectText, body, attachments: attachments?.attachmentIds ?? [],
21441
+ uncertainSubmission = { ticketId: id, subject: subjectText, body, attachments: composer.attachmentIds,
20871
21442
  ...(typeof sourceArticleId === 'string' && sourceArticleId.length > 0 && sourceArticleId.length <= 256 &&
20872
21443
  !Array.from(sourceArticleId).some(character => character.charCodeAt(0) <= 32 || character === '\\') && { source_article_id: sourceArticleId }) };
20873
21444
  }
20874
21445
  persistDraft();
20875
- attachments?.lock(true);
21446
+ composer.lock(true);
20876
21447
  ticketAttempted = true;
20877
21448
  const ticket = await client.createTicket({ ...uncertainSubmission, attachments: [...uncertainSubmission.attachments], ...options.assistanceContext?.() }, { expectedSessionToken: token });
20878
21449
  if (!alive(ownGeneration) || !(await tokenFor(ownGeneration)))
@@ -20907,7 +21478,7 @@ function mountHelpDeskForm(client, options) {
20907
21478
  if (draftExpired) {
20908
21479
  draftId = null;
20909
21480
  draftPromise = null;
20910
- attachments?.clear();
21481
+ composer.clear();
20911
21482
  }
20912
21483
  if (error instanceof SparkVaultError && error.serviceCode === 'PIN_INVALID') {
20913
21484
  clearCode();
@@ -21086,8 +21657,7 @@ function mountHelpDeskForm(client, options) {
21086
21657
  destroyed = true;
21087
21658
  generation += 1;
21088
21659
  stopResendCountdown();
21089
- attachments?.destroy(completed || uncertainSubmission !== null);
21090
- composer.destroy();
21660
+ composer.destroy(completed || uncertainSubmission !== null);
21091
21661
  live.destroy();
21092
21662
  unsubscribe();
21093
21663
  form.removeEventListener('submit', onSubmit);
@@ -23478,7 +24048,12 @@ function createSupportLauncher(options, open) {
23478
24048
  };
23479
24049
  }
23480
24050
 
23481
- /** The support journey's only skin. Customer content stays in the product register. */
24051
+ /**
24052
+ * The support journey's only skin. Customer content stays in the product register.
24053
+ * The panel's focus ring is 2px, 3px out, in the desk's focus color: its width and
24054
+ * offset are the panel's custom properties, which the help desk composer inside
24055
+ * its request form reads, so the composer rings as the fields beside it do.
24056
+ */
23482
24057
  function injectHelpDeskSupportStyles() {
23483
24058
  if (document.getElementById('sparkvault-help-desk-support-styles'))
23484
24059
  return;
@@ -23486,6 +24061,7 @@ function injectHelpDeskSupportStyles() {
23486
24061
  style.id = 'sparkvault-help-desk-support-styles';
23487
24062
  style.textContent = `
23488
24063
  .svhs-panel,.svhs-panel *{box-sizing:border-box}
24064
+ .svhs-panel{--hd-focus-width:2px;--hd-focus-offset:3px}
23489
24065
  .svhs-panel{position:fixed;right:calc(var(--svhs-right,24px) + env(safe-area-inset-right,0px));bottom:calc(var(--svhs-bottom,96px) + env(safe-area-inset-bottom,0px));z-index:2147482900;width:408px;height:422px;max-width:calc(100vw - 32px);max-height:calc(100dvh - var(--svhs-bottom,96px) - 24px);display:flex;flex-direction:column;overflow:hidden;border:1px solid ${DS.slate200};border-radius:12px;background:${DS.white};color:${DS.slate900};font:400 15px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue',sans-serif;text-align:left;box-shadow:${DS.shadowPopover};transform-origin:bottom right;transition:width 180ms cubic-bezier(.2,0,0,1),height 180ms cubic-bezier(.2,0,0,1)}
23490
24066
  .svhs-panel[hidden],.svhs-panel [hidden]{display:none!important}
23491
24067
  .svhs-panel[data-stage=results]{height:680px}
@@ -23497,7 +24073,7 @@ function injectHelpDeskSupportStyles() {
23497
24073
  .svhs-panel button,.svhs-panel a{touch-action:manipulation;-webkit-tap-highlight-color:transparent}
23498
24074
  .svhs-panel button{appearance:none;cursor:pointer;margin:0}
23499
24075
  .svhs-panel button:active{transform:translateY(1px)}
23500
- .svhs-panel button:focus-visible,.svhs-panel a:focus-visible,.svhs-panel input:focus-visible,.svhs-panel textarea:focus-visible{outline:2px solid var(--hd-focus,var(--hd-accent-ink,${DS.action}));outline-offset:3px;box-shadow:none}
24076
+ .svhs-panel button:focus-visible,.svhs-panel a:focus-visible,.svhs-panel input:focus-visible,.svhs-panel textarea:focus-visible{outline:var(--hd-focus-width) solid var(--hd-focus,var(--hd-accent-ink,${DS.action}));outline-offset:var(--hd-focus-offset);box-shadow:none}
23501
24077
  .svhs-panel svg{display:block;width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round;flex:none;pointer-events:none}
23502
24078
  .svhs-toolbar{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:60px;flex:none;padding:8px 14px 8px 24px;border-bottom:1px solid ${DS.slate200}}
23503
24079
  .svhs-desk-name{font-size:14px;font-weight:600;line-height:1.35;color:${DS.slate600};overflow-wrap:anywhere;min-width:0}
@@ -23616,10 +24192,6 @@ function injectHelpDeskSupportStyles() {
23616
24192
  .svhs-contact-target .svhd-auth{gap:14px}
23617
24193
  .svhs-contact-target .svhd-text-button{color:var(--hd-accent-ink,${DS.action})}
23618
24194
  .svhs-contact-target .svhd-text-button:disabled{color:${DS.slate500}}
23619
- .svhs-contact-target .svhd-composer:has(.svhd-composer-input:focus-visible){outline:2px solid var(--hd-focus,var(--hd-accent-ink,${DS.action}));outline-offset:3px}
23620
- @supports not selector(:has(*)){.svhs-contact-target .svhd-composer:focus-within{outline:2px solid var(--hd-focus,var(--hd-accent-ink,${DS.action}));outline-offset:3px}}
23621
- .svhs-panel .svhd-composer-input:focus-visible{outline:none}
23622
- .svhs-panel .svhd-composer button:focus-visible{outline-offset:-2px}
23623
24195
  .svhs-contact-target .svhd-widget-form{display:flex;flex:1;flex-direction:column;gap:16px}
23624
24196
  /* The request fills the panel: the details step, and in it the composer and its text, take the height the fields leave. */
23625
24197
  .svhs-contact-target .svhd-widget-form>[data-contact-step=details]{display:flex;flex:1;flex-direction:column;gap:16px}
@@ -23878,120 +24450,6 @@ class SupportPhoneHistory {
23878
24450
  }
23879
24451
  }
23880
24452
 
23881
- /**
23882
- * A tenant's brand color and the WCAG contrast rules that decide how it may be
23883
- * used: the one hex rule the server stores, the console checks and the portal
23884
- * paints, the one contrast reading the console's readouts and the portal's
23885
- * accent share, and the one way a readout writes that reading.
23886
- *
23887
- * A brand color is tenant-controlled, so it is used only when it is a
23888
- * six-digit hex color, read case-insensitively and held in lowercase; anything
23889
- * else (a color name, a CSS function, a value that runs on into more CSS) is
23890
- * no color at all.
23891
- *
23892
- * A brand color can be any lightness, so whatever shows it picks what goes
23893
- * with it: white or ink as the text on its fill, whichever reads more
23894
- * strongly (at least 4.2:1 on any fill, as far as two inks reach on a
23895
- * mid-tone), and the color itself as text only where it reaches 4.5:1 on
23896
- * both grounds accent text stands on, the white surface and the canvas
23897
- * tone, ink otherwise. accentProperties says that as the accent
23898
- * custom properties the customer portal paints with and the console's sample
23899
- * of it shows, in the design system's own tokens.
23900
- *
23901
- * BROWSER-SAFE: data only, no imports.
23902
- */
23903
-
23904
- const HEX_COLOR = /^#[0-9a-f]{6}$/;
23905
-
23906
- /** WCAG AA's floor for normal-size text. */
23907
- const AA_TEXT_CONTRAST = 4.5;
23908
-
23909
- /**
23910
- * The canvas tone, the design system's `--canvas` (`--color-slate-50`): the
23911
- * page ground the customer portal (its pages and a customer's own messages)
23912
- * and the knowledge base's default theme set accent text on, beside the white
23913
- * surface. The design system publishes its tokens only as CSS, which this
23914
- * import-free module cannot read, so the value is mirrored here once, and
23915
- * tests/brand-color.test.js holds it to packages/design-system/tokens/colors.css.
23916
- */
23917
- const CANVAS_COLOR = '#f7fafb';
23918
-
23919
- /**
23920
- * The ink, the design system's `--ink` (`--color-slate-900`): the dark text a
23921
- * pairing paints on a fill and in place of a color too light to stand as
23922
- * text. Mirrored here once for the same reason as CANVAS_COLOR, and held to
23923
- * packages/design-system/tokens/colors.css by tests/brand-color.test.js.
23924
- */
23925
- const INK_COLOR = '#0d1a20';
23926
-
23927
- /** Relative luminance (WCAG 2) of a validated `#rrggbb` color. */
23928
- function relativeLuminance(color) {
23929
- const [red, green, blue] = [1, 3, 5].map((offset) => {
23930
- const channel = Number.parseInt(color.slice(offset, offset + 2), 16) / 255;
23931
- return channel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4;
23932
- });
23933
- return 0.2126 * red + 0.7152 * green + 0.0722 * blue;
23934
- }
23935
-
23936
- /** The contrast ratio of two relative luminances. */
23937
- function contrastRatio(first, second) {
23938
- return (Math.max(first, second) + 0.05) / (Math.min(first, second) + 0.05);
23939
- }
23940
-
23941
- /** The relative luminance of the ink a fill's text is weighed in, the real ink rather than pure black. */
23942
- const INK_LUMINANCE = relativeLuminance(INK_COLOR);
23943
-
23944
- /** The relative luminances of the grounds accent text stands on: the white surface and the canvas tone. */
23945
- const TEXT_GROUNDS = Object.freeze([1, relativeLuminance(CANVAS_COLOR)]);
23946
-
23947
- /** How strongly a color of this luminance reads as text on the ground it reads least on. */
23948
- function textContrast(luminance) {
23949
- return Math.min(...TEXT_GROUNDS.map((ground) => contrastRatio(luminance, ground)));
23950
- }
23951
-
23952
- /**
23953
- * A brand color as it may be stored and shown, or null when the value is not
23954
- * one: a `#rrggbb` hex value, read case-insensitively.
23955
- *
23956
- * @param {unknown} value
23957
- * @returns {string|null} The color in lowercase
23958
- */
23959
- function brandColor(value) {
23960
- if (typeof value !== 'string') return null;
23961
- const color = value.toLowerCase();
23962
- return HEX_COLOR.test(color) ? color : null;
23963
- }
23964
-
23965
- /**
23966
- * What goes with a brand color: the text on its fill (white or ink,
23967
- * whichever reads more strongly, at least 4.2:1 on any fill) and the ink for
23968
- * it as text
23969
- * (the color itself where it reaches AA_TEXT_CONTRAST on both the white
23970
- * surface and the canvas tone, ink otherwise).
23971
- *
23972
- * @param {unknown} value
23973
- * @returns {{ onAccent: 'white'|'ink', accentInk: 'accent'|'ink', ratio: number }|null} Null when the value is not a brand color; `ratio` is its contrast as text (accentTextContrast)
23974
- */
23975
- function accentPairing(value) {
23976
- const color = brandColor(value);
23977
- if (!color) return null;
23978
- const luminance = relativeLuminance(color);
23979
- const ratio = textContrast(luminance);
23980
- return {
23981
- onAccent: contrastRatio(luminance, 1) >= contrastRatio(luminance, INK_LUMINANCE) ? 'white' : 'ink',
23982
- accentInk: ratio >= AA_TEXT_CONTRAST ? 'accent' : 'ink',
23983
- ratio
23984
- };
23985
- }
23986
-
23987
- /** Contrast between a brand fill and the label selected by accentPairing. */
23988
- function accentFillContrast(value) {
23989
- const color = brandColor(value);
23990
- if (!color) return null;
23991
- const pairing = accentPairing(color);
23992
- return contrastRatio(relativeLuminance(color), pairing.onAccent === 'white' ? 1 : INK_LUMINANCE);
23993
- }
23994
-
23995
24453
  /** Darken only the narrow range where neither white nor the product ink reaches AA. */
23996
24454
  function accessibleFill(color) {
23997
24455
  let fill = color;
@@ -24426,7 +24884,7 @@ class SupportView {
24426
24884
  continue;
24427
24885
  frame.setAttribute('aria-busy', 'false');
24428
24886
  status.hidden = false;
24429
- status.replaceChildren(document.createTextNode('This image couldn’t be loaded.'));
24887
+ status.replaceChildren(document.createTextNode("This image couldn't be loaded."));
24430
24888
  const canonical = httpUrl(this.state?.article?.canonical_url);
24431
24889
  if (canonical) {
24432
24890
  const link = element('a', '', 'Open the full article');
@@ -24554,7 +25012,7 @@ class SupportView {
24554
25012
  this.headings.get('results').textContent = state.busy ? 'Checking for helpful articles…'
24555
25013
  : state.kbState === 'locked' ? 'View helpful articles'
24556
25014
  : results.length && state.kbState !== 'unavailable' ? 'These articles may help'
24557
- : 'Let’s get you some help';
25015
+ : "Let's get you some help";
24558
25016
  const signature = JSON.stringify(results);
24559
25017
  if (signature !== this.resultSignature) {
24560
25018
  this.resultSignature = signature;
@@ -24633,12 +25091,12 @@ class SupportView {
24633
25091
  this.actions.onUnlock?.(); }));
24634
25092
  }
24635
25093
  else {
24636
- this.resultStatus.append(element('p', 'svhs-copy', 'The help center isn’t available from this network. You can still contact support below.'));
25094
+ this.resultStatus.append(element('p', 'svhs-copy', "The help center isn't available from this network. You can still contact support below."));
24637
25095
  }
24638
25096
  }
24639
25097
  else if (state.kbState === 'unavailable') {
24640
25098
  this.resultStatus.removeAttribute('role');
24641
- this.resultStatus.append(element('h3', 'svhs-heading', 'We couldn’t load the help center'), element('p', 'svhs-copy', 'Try again, or send your question to support. Your message is saved here.'));
25099
+ this.resultStatus.append(element('h3', 'svhs-heading', "We couldn't load the help center"), element('p', 'svhs-copy', 'Try again, or send your question to support. Your message is saved here.'));
24642
25100
  if (this.actions.onRetry)
24643
25101
  this.resultStatus.append(button('svhs-secondary', 'Try again', () => this.actions.onRetry?.()));
24644
25102
  }
@@ -24664,7 +25122,7 @@ class SupportView {
24664
25122
  this.articleError.hidden = !this.articleError.textContent;
24665
25123
  this.articleRetry.hidden = !this.articleError.textContent || Boolean(state.busy) || !this.actions.onRetry;
24666
25124
  this.articleContent.hidden = Boolean(state.busy);
24667
- this.articleTitle.textContent = article?.title || (state.error ? 'We couldn’t load this article' : 'Help article');
25125
+ this.articleTitle.textContent = article?.title || (state.error ? "We couldn't load this article" : 'Help article');
24668
25126
  const category = state.results?.find((result) => result.id === article?.id)?.category;
24669
25127
  this.articleCategory.textContent = category || '';
24670
25128
  this.articleCategory.hidden = !category;
@@ -24773,7 +25231,7 @@ class SupportView {
24773
25231
  }
24774
25232
  renderReceipt(state) {
24775
25233
  const receipt = state.receipt;
24776
- this.receiptCopy.replaceChildren(document.createTextNode(receipt?.email ? 'Your message has been sent. We’ll reply to ' : 'Your message has been sent.'));
25234
+ this.receiptCopy.replaceChildren(document.createTextNode(receipt?.email ? "Your message has been sent. We'll reply to " : 'Your message has been sent.'));
24777
25235
  if (receipt?.email)
24778
25236
  this.receiptCopy.append(element('strong', '', receipt.email), document.createTextNode('.'));
24779
25237
  this.receiptTicket.textContent = receipt?.ticketNumber !== undefined ? `Ticket #${receipt.ticketNumber}` : '';
@@ -30544,7 +31002,7 @@ class SparkVault {
30544
31002
  }
30545
31003
  /** Get the SDK version */
30546
31004
  static get version() {
30547
- return '16.7.1';
31005
+ return '16.9.0';
30548
31006
  }
30549
31007
  }
30550
31008
  if (typeof window !== 'undefined') {