@brandlab-digital/site-next 3.17.1 → 3.19.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.
Files changed (40) hide show
  1. package/dist/contact/client-entry.d.ts +2 -1
  2. package/dist/contact/client-entry.d.ts.map +1 -1
  3. package/dist/contact/client-entry.js +1 -0
  4. package/dist/contact/client-entry.js.map +1 -1
  5. package/dist/contact/form-client.d.ts +12 -3
  6. package/dist/contact/form-client.d.ts.map +1 -1
  7. package/dist/contact/form-client.js +18 -2
  8. package/dist/contact/form-client.js.map +1 -1
  9. package/dist/contact/google-tag-navigate.d.ts +32 -0
  10. package/dist/contact/google-tag-navigate.d.ts.map +1 -0
  11. package/dist/contact/google-tag-navigate.js +72 -0
  12. package/dist/contact/google-tag-navigate.js.map +1 -0
  13. package/dist/next-config.d.ts +5 -0
  14. package/dist/next-config.d.ts.map +1 -1
  15. package/dist/next-config.js +6 -1
  16. package/dist/next-config.js.map +1 -1
  17. package/dist/ui-kit/form/quote-form.d.ts +6 -2
  18. package/dist/ui-kit/form/quote-form.d.ts.map +1 -1
  19. package/dist/ui-kit/form/quote-form.js +6 -3
  20. package/dist/ui-kit/form/quote-form.js.map +1 -1
  21. package/dist/ui-kit/primitives/media-frame.d.ts +5 -0
  22. package/dist/ui-kit/primitives/media-frame.d.ts.map +1 -1
  23. package/dist/ui-kit/primitives/media-frame.js +5 -2
  24. package/dist/ui-kit/primitives/media-frame.js.map +1 -1
  25. package/dist/ui-kit/primitives/media.d.ts +2 -0
  26. package/dist/ui-kit/primitives/media.d.ts.map +1 -1
  27. package/dist/ui-kit/primitives/media.js +1 -1
  28. package/dist/ui-kit/primitives/media.js.map +1 -1
  29. package/dist/ui-kit/repeated-slots.d.ts +1 -1
  30. package/dist/ui-kit/repeated-slots.js +1 -1
  31. package/dist/ui-kit/repeated-slots.js.map +1 -1
  32. package/dist/ui-kit/sections/hero.d.ts +5 -0
  33. package/dist/ui-kit/sections/hero.d.ts.map +1 -1
  34. package/dist/ui-kit/sections/hero.js +1 -1
  35. package/dist/ui-kit/sections/hero.js.map +1 -1
  36. package/dist/ui-kit/sections/licences.d.ts +23 -0
  37. package/dist/ui-kit/sections/licences.d.ts.map +1 -1
  38. package/dist/ui-kit/sections/licences.js +29 -3
  39. package/dist/ui-kit/sections/licences.js.map +1 -1
  40. package/package.json +2 -2
@@ -1,4 +1,5 @@
1
1
  export { compressBrandlabContactImage, useBrandlabContactAttachments, type BrandlabContactAttachmentErrorReason, type BrandlabContactAttachmentPreview, type UseBrandlabContactAttachmentsOptions, type UseBrandlabContactAttachmentsResult, } from './attachments-client.js';
2
- export { contactFieldProps, useBrandlabContactForm, type BrandlabContactAcceptedResult, type BrandlabContactFailedResult, type BrandlabContactFormProps, type BrandlabContactSubmitProps, type BrandlabContactSubmitStart, type ContactFieldPropsOptions, type UseBrandlabContactFormOptions, type UseBrandlabContactFormResult, } from './form-client.js';
2
+ export { contactFieldProps, useBrandlabContactForm, type BrandlabContactAcceptedResult, type BrandlabContactClientInvalid, type BrandlabContactFailedResult, type BrandlabContactFormProps, type BrandlabContactSubmitProps, type BrandlabContactSubmitStart, type ContactFieldPropsOptions, type UseBrandlabContactFormOptions, type UseBrandlabContactFormResult, } from './form-client.js';
3
+ export { GOOGLE_TAG_SETTLE_MS, GOOGLE_TAG_WAIT_MS, googleTagSettled, navigateAfterGoogleTag, type NavigateAfterGoogleTagOptions, } from './google-tag-navigate.js';
3
4
  export type { ContactSubmissionPhase } from './client.js';
4
5
  //# sourceMappingURL=client-entry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client-entry.d.ts","sourceRoot":"","sources":["../../src/contact/client-entry.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,4BAA4B,EAC5B,6BAA6B,EAC7B,KAAK,oCAAoC,EACzC,KAAK,gCAAgC,EACrC,KAAK,oCAAoC,EACzC,KAAK,mCAAmC,GACzC,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,KAAK,6BAA6B,EAClC,KAAK,2BAA2B,EAChC,KAAK,wBAAwB,EAC7B,KAAK,0BAA0B,EAC/B,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,EAC7B,KAAK,6BAA6B,EAClC,KAAK,4BAA4B,GAClC,MAAM,kBAAkB,CAAA;AACzB,YAAY,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"client-entry.d.ts","sourceRoot":"","sources":["../../src/contact/client-entry.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,4BAA4B,EAC5B,6BAA6B,EAC7B,KAAK,oCAAoC,EACzC,KAAK,gCAAgC,EACrC,KAAK,oCAAoC,EACzC,KAAK,mCAAmC,GACzC,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,KAAK,6BAA6B,EAClC,KAAK,4BAA4B,EACjC,KAAK,2BAA2B,EAChC,KAAK,wBAAwB,EAC7B,KAAK,0BAA0B,EAC/B,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,EAC7B,KAAK,6BAA6B,EAClC,KAAK,4BAA4B,GAClC,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,KAAK,6BAA6B,GACnC,MAAM,0BAA0B,CAAA;AACjC,YAAY,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA"}
@@ -1,4 +1,5 @@
1
1
  'use client';
2
2
  export { compressBrandlabContactImage, useBrandlabContactAttachments, } from './attachments-client.js';
3
3
  export { contactFieldProps, useBrandlabContactForm, } from './form-client.js';
4
+ export { GOOGLE_TAG_SETTLE_MS, GOOGLE_TAG_WAIT_MS, googleTagSettled, navigateAfterGoogleTag, } from './google-tag-navigate.js';
4
5
  //# sourceMappingURL=client-entry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"client-entry.js","sourceRoot":"","sources":["../../src/contact/client-entry.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,EACL,4BAA4B,EAC5B,6BAA6B,GAK9B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACL,iBAAiB,EACjB,sBAAsB,GASvB,MAAM,kBAAkB,CAAA","sourcesContent":["'use client'\n\nexport {\n compressBrandlabContactImage,\n useBrandlabContactAttachments,\n type BrandlabContactAttachmentErrorReason,\n type BrandlabContactAttachmentPreview,\n type UseBrandlabContactAttachmentsOptions,\n type UseBrandlabContactAttachmentsResult,\n} from './attachments-client.js'\nexport {\n contactFieldProps,\n useBrandlabContactForm,\n type BrandlabContactAcceptedResult,\n type BrandlabContactFailedResult,\n type BrandlabContactFormProps,\n type BrandlabContactSubmitProps,\n type BrandlabContactSubmitStart,\n type ContactFieldPropsOptions,\n type UseBrandlabContactFormOptions,\n type UseBrandlabContactFormResult,\n} from './form-client.js'\nexport type { ContactSubmissionPhase } from './client.js'\n"]}
1
+ {"version":3,"file":"client-entry.js","sourceRoot":"","sources":["../../src/contact/client-entry.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,EACL,4BAA4B,EAC5B,6BAA6B,GAK9B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACL,iBAAiB,EACjB,sBAAsB,GAUvB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,GAEvB,MAAM,0BAA0B,CAAA","sourcesContent":["'use client'\n\nexport {\n compressBrandlabContactImage,\n useBrandlabContactAttachments,\n type BrandlabContactAttachmentErrorReason,\n type BrandlabContactAttachmentPreview,\n type UseBrandlabContactAttachmentsOptions,\n type UseBrandlabContactAttachmentsResult,\n} from './attachments-client.js'\nexport {\n contactFieldProps,\n useBrandlabContactForm,\n type BrandlabContactAcceptedResult,\n type BrandlabContactClientInvalid,\n type BrandlabContactFailedResult,\n type BrandlabContactFormProps,\n type BrandlabContactSubmitProps,\n type BrandlabContactSubmitStart,\n type ContactFieldPropsOptions,\n type UseBrandlabContactFormOptions,\n type UseBrandlabContactFormResult,\n} from './form-client.js'\nexport {\n GOOGLE_TAG_SETTLE_MS,\n GOOGLE_TAG_WAIT_MS,\n googleTagSettled,\n navigateAfterGoogleTag,\n type NavigateAfterGoogleTagOptions,\n} from './google-tag-navigate.js'\nexport type { ContactSubmissionPhase } from './client.js'\n"]}
@@ -18,6 +18,14 @@ export interface BrandlabContactSubmitStart {
18
18
  */
19
19
  formData: FormData;
20
20
  }
21
+ /**
22
+ * Returned by onSubmitStart to cancel because the form's own checks failed (3.18.0): the failing keys in the order
23
+ * the visitor sees them. Nothing is sent, and lead_form_error goes out with stage `validation` and reason `field`
24
+ * naming the first contract field; a key that isn't a contract field (the photos) gives reason `attachment`.
25
+ */
26
+ export interface BrandlabContactClientInvalid {
27
+ invalidFields: readonly string[];
28
+ }
21
29
  export interface UseBrandlabContactFormOptions {
22
30
  /** The contact contract from src/config/contact.ts. */
23
31
  contract: BrandlabContactContract;
@@ -44,10 +52,11 @@ export interface UseBrandlabContactFormOptions {
44
52
  /**
45
53
  * Runs when the visitor submits, before anything is sent: clear the form's
46
54
  * own notices, adjust `formData`, or return `false` to cancel (for example
47
- * after `form.reportValidity()`). An unchanged resubmission runs it too;
48
- * `retry()` does not.
55
+ * after `form.reportValidity()`). Return `{ invalidFields }` instead to
56
+ * cancel and report the failed checks as lead_form_error. An unchanged
57
+ * resubmission runs it too; `retry()` does not.
49
58
  */
50
- onSubmitStart?: (submission: BrandlabContactSubmitStart) => void | false;
59
+ onSubmitStart?: (submission: BrandlabContactSubmitStart) => void | false | BrandlabContactClientInvalid;
51
60
  /**
52
61
  * Runs after every attempt, before onAccepted or onFailed: an accepted
53
62
  * enquiry, a silently accepted submission (even when ignored) or a failure.
@@ -1 +1 @@
1
- {"version":3,"file":"form-client.d.ts","sourceRoot":"","sources":["../../src/contact/form-client.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,u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
245
  return;
246
246
  const form = event.currentTarget;
247
247
  const formData = new FormData(form);
248
- if (latest.current.onSubmitStart?.({ form, formData }) === false)
248
+ const started = latest.current.onSubmitStart?.({ form, formData });
249
+ if (started === false)
249
250
  return;
251
+ if (started && typeof started === 'object') {
252
+ trackStart();
253
+ const keys = started.invalidFields;
254
+ const field = keys.find((key) => fieldOrder.includes(key));
255
+ if (!brandlabTestVisit())
256
+ latest.current.analytics?.trackLeadFormError({
257
+ pagePath: rawPagePath,
258
+ formId: diagnosticsFormId,
259
+ stage: 'validation',
260
+ errorCount: Math.min(50, Math.max(1, keys.length)),
261
+ reason: field ? 'field' : 'attachment',
262
+ ...(field ? { field } : {}),
263
+ });
264
+ return;
265
+ }
250
266
  if (brandlabTestVisit())
251
267
  formData.set(CONTACT_FORM_FIELDS.testMarker, BRANDLAB_CONTACT_TEST_MARKER);
252
268
  trackStart();
@@ -256,7 +272,7 @@ export function useBrandlabContactForm(options) {
256
272
  });
257
273
  // The controller reports every failure as a result; nothing is left to handle here.
258
274
  send(() => controller.submit(formData)).catch(() => undefined);
259
- }, [attachmentPrefix, attachments, controller, send, trackStart]);
275
+ }, [attachmentPrefix, attachments, controller, diagnosticsFormId, fieldOrder, rawPagePath, send, trackStart]);
260
276
  const retry = useCallback(async () => {
261
277
  if (lockRef.current || !controller.getState().canRetry)
262
278
  return undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"form-client.js","sourceRoot":"","sources":["../../src/contact/form-client.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,EACL,iCAAiC,EACjC,kCAAkC,EAClC,qBAAqB,GAGtB,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAA;AAC/E,OAAO,EACL,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,EACR,oBAAoB,GAGrB,MAAM,OAAO,CAAA;AAEd,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,M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K,CAAC,QAAQ;QACxB,WAAW;QACX,UAAU,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QACpD,OAAO,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,GAAG,MAAM,IAAI,IAAI,QAAQ;QACpD,SAAS;QACT,KAAK;QACL,WAAW;QACX,UAAU;KACX,CAAA;AACH,CAAC;AASD;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC/B,IAAkC,EAClC,IAAY,EACZ,UAAoC,EAAE;IAEtC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,IAAI,IAAI,2CAA2C,CAAC,CAAA;IACtE,CAAC;IACD,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;IACnC,MAAM,WAAW,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;SAC9E,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,GAAG,CAAC,CAAA;IACZ,OAAO;QACL,IAAI;QACJ,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO;QAC1C,cAAc,EAAE,KAAK,CAAC,CAAC,CAAE,IAAc,CAAC,CAAC,CAAC,SAAS;QACnD,kBAAkB,EAAE,WAAW,IAAI,SAAS;KAC7C,CAAA;AACH,CAAC","sourcesContent":["'use client'\n\nimport {\n DEFAULT_CONTACT_ATTACHMENT_POLICY,\n DOCUMENT_CONTACT_ATTACHMENT_POLICY,\n defineContactContract,\n type BrandlabContactContract,\n type ContactActionResult,\n} from '@brandlab-digital/site-core/contact'\nimport { normalizeBrandlabRoutePath } from '@brandlab-digital/site-core/routes'\nimport {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n type FormEvent,\n type RefObject,\n} from 'react'\nimport type { BrandlabAnalytics, LeadFormErrorReason, LeadFormErrorStage } from '../analytics.js'\nimport { leadBindingFor, safeSlug } from '../lead-registry.js'\nimport { contactFormDataHasPhotos, reportAcceptedLead } from '../lead-reporting.js'\nimport {\n useBrandlabContactAttachments,\n type UseBrandlabContactAttachmentsOptions,\n type UseBrandlabContactAttachmentsResult,\n} from './attachments-client.js'\nimport {\n createContactHttpSubmissionController,\n isContactClientFailure,\n type ContactSubmissionPhase,\n type ContactSubmissionState,\n} from './client.js'\nimport { BRANDLAB_CONTACT_TEST_MARKER, CONTACT_FORM_FIELDS } from './shared.js'\n\n/** An accepted enquiry, or a silently accepted spam-protected submission (`accepted: false`). */\nexport type BrandlabContactAcceptedResult = Extract<ContactActionResult, { ok: true }>\nexport type BrandlabContactFailedResult = Extract<ContactActionResult, { ok: false }>\n\nexport interface BrandlabContactSubmitStart {\n form: HTMLFormElement\n /**\n * The fields about to be sent, read from the form. Add or replace entries\n * here (for example `service_interest`); prepared photos are appended after.\n */\n formData: FormData\n}\n\nexport interface UseBrandlabContactFormOptions {\n /** The contact contract from src/config/contact.ts. */\n contract: BrandlabContactContract\n /** The site's defineBrandlabAnalytics binding: the declared lead after each accepted enquiry, plus lead diagnostics. */\n analytics?: BrandlabAnalytics\n /** The current pathname, for example `usePathname()`. */\n pagePath: string\n /** Reviewed label for the enquiry email's page row. */\n pageLabel?: string\n /**\n * The form element's id and the lead diagnostics' form_id. Without it the form\n * gets no id (the hook never takes a React id, so the form's own ids are\n * unchanged), diagnostics use `contact-form` and error ids start `contact-form-`.\n * The element keeps the id exactly as given; diagnostics report it as a slug\n * (React `useId()` parts removed, see `contactFormSlug`).\n */\n formId?: string\n /** Page to open after an accepted enquiry; `null` or omitted keeps the visitor on the page. */\n redirectTo?: string | null\n /** Client navigation such as `router.push`; defaults to `window.location.assign`. */\n navigate?: (href: string) => void\n /** Delay before the redirect, in milliseconds (default 1500); 0 navigates at once. */\n redirectDelayMs?: number\n /**\n * Runs when the visitor submits, before anything is sent: clear the form's\n * own notices, adjust `formData`, or return `false` to cancel (for example\n * after `form.reportValidity()`). An unchanged resubmission runs it too;\n * `retry()` does not.\n */\n onSubmitStart?: (submission: BrandlabContactSubmitStart) => void | false\n /**\n * Runs after every attempt, before onAccepted or onFailed: an accepted\n * enquiry, a silently accepted submission (even when ignored) or a failure.\n */\n onSettled?: (result: ContactActionResult) => void\n /** Runs after an accepted enquiry, once the form has been reset and before any redirect. */\n onAccepted?: (result: BrandlabContactAcceptedResult) => void\n /** Runs after a failed attempt; typed values and prepared photos are kept. */\n onFailed?: (result: BrandlabContactFailedResult) => void\n /**\n * A silently accepted submission (spam protection): `complete` (default)\n * resets, runs onAccepted and redirects like an accepted enquiry; `ignore`\n * leaves the form as it is and runs only onSettled.\n */\n silentAcceptance?: 'complete' | 'ignore'\n /** Photo preparation options; the policy follows the contract's attachment mode by default. */\n attachments?: UseBrandlabContactAttachmentsOptions\n /** Multipart field prefix for prepared files (default `attachments`, sent as `attachments[0]` …). */\n attachmentFieldPrefix?: string\n /** Live Consent Mode decision for ad_user_data; without it Enhanced Conversions stay off, unless the analytics contract's mode is `disclosed`. */\n adUserDataConsent?: boolean\n contactEndpoint?: string\n fetcher?: typeof fetch\n}\n\n/**\n * Spread onto the `<form>`: `method=\"post\"` with no `action` or `encType`, so a\n * submission before hydration posts back to the page and never puts fields in\n * a URL; the hook submits through fetch. `id` only when `formId` is given.\n */\nexport interface BrandlabContactFormProps {\n id?: string\n ref: RefObject<HTMLFormElement | null>\n method: 'post'\n 'aria-busy': boolean\n onSubmit: (event: FormEvent<HTMLFormElement>) => void\n onFocusCapture: () => void\n}\n\n/** Spread onto the submit button: disabled until hydration, while sending or preparing photos. */\nexport interface BrandlabContactSubmitProps {\n type: 'submit'\n disabled: boolean\n}\n\nexport interface UseBrandlabContactFormResult {\n /** The `formId` option, or `contact-form` when none was given. */\n formId: string\n formProps: BrandlabContactFormProps\n submitProps: BrandlabContactSubmitProps\n /** False during server rendering and hydration. */\n hydrated: boolean\n /** The submit button's `disabled` (also in submitProps): until hydration, while sending or preparing photos. */\n submitDisabled: boolean\n pending: boolean\n phase: ContactSubmissionPhase\n result: ContactActionResult | undefined\n /** An accepted enquiry (a silently accepted spam-protected submission looks the same). */\n succeeded: boolean\n /** A retryable failure: retry(), or submitting the same fields again, reuses its submission ID. */\n canRetry: boolean\n fieldErrors: Readonly<Record<string, readonly string[]>>\n fieldError(name: string): string | undefined\n /** Id for a field's error message element: `${formId}-${name}-error`. */\n errorId(name: string): string\n /** Attach to the status element; it receives focus when an error has no invalid field. */\n statusRef: RefObject<HTMLElement | null>\n /** Resends the failed enquiry with the same submission ID. */\n retry(): Promise<ContactActionResult | undefined>\n attachments: UseBrandlabContactAttachmentsResult\n /** Contract field keys accepted by contactFieldProps. */\n fieldNames: ReadonlySet<string>\n}\n\nconst INITIAL_STATE: ContactSubmissionState = {\n phase: 'idle',\n pending: false,\n canRetry: false,\n}\nconst DEFAULT_REDIRECT_DELAY_MS = 1_500\nconst FOCUSABLE_INVALID_FIELD = [\n 'input[aria-invalid=\"true\"]:not([disabled]):not([type=\"hidden\"])',\n 'select[aria-invalid=\"true\"]:not([disabled])',\n 'textarea[aria-invalid=\"true\"]:not([disabled])',\n 'button[aria-invalid=\"true\"]:not([disabled])',\n '[aria-invalid=\"true\"][tabindex]:not([aria-disabled=\"true\"])',\n].join(',')\n\nconst subscribeToNothing = () => () => undefined\nconst getClientSnapshot = () => true\nconst getServerSnapshot = () => false\n\n/** React `useId()` values: `_R_1a_`/`_r_1a_` (19.2), `«r1a»` (19.0 and 19.1), `:r1a:` (18). */\nconst REACT_ID = /_[rR]_[0-9A-Za-z]*_|«[rR][0-9A-Za-z]*»|:[rR][0-9A-Za-z]*:/g\n\n/**\n * The lead diagnostics' form_id for any formId. A valid slug is kept (trimmed and\n * lowercased). Otherwise React `useId()` parts are removed, so an id made unique for\n * the page still reports as one stable form, every run of other characters becomes\n * one hyphen, and the result is at most 80 characters; `contact-form` when nothing\n * is left. Without this, a formId such as `contact-form-_R_5e35f9db_` silently\n * dropped lead_form_start and lead_form_error.\n */\nexport function contactFormSlug(formId: string): string {\n const slug = safeSlug(String(formId))\n if (slug) return slug\n const derived = String(formId)\n .replace(REACT_ID, '-')\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+/, '')\n .slice(0, 80)\n .replace(/-+$/, '')\n return derived || 'contact-form'\n}\n\n/**\n * A Brandlab test visit: a page opened with `?bl_test=1` (a launch proof or canary), remembered for the tab so the\n * marker survives moving to the quote form; `?bl_test=0` ends it. Its enquiries carry the `bl_test` marker.\n */\nfunction brandlabTestVisit() {\n if (typeof window === 'undefined') return false\n try {\n const flag = new URLSearchParams(window.location.search).get(CONTACT_FORM_FIELDS.testMarker)\n if (flag === BRANDLAB_CONTACT_TEST_MARKER) window.sessionStorage.setItem(CONTACT_FORM_FIELDS.testMarker, flag)\n if (flag === '0') window.sessionStorage.removeItem(CONTACT_FORM_FIELDS.testMarker)\n return window.sessionStorage.getItem(CONTACT_FORM_FIELDS.testMarker) === BRANDLAB_CONTACT_TEST_MARKER ||\n flag === BRANDLAB_CONTACT_TEST_MARKER\n } catch {\n return false\n }\n}\n\nfunction isTestSubmission(formData: FormData) {\n return formData.get(CONTACT_FORM_FIELDS.testMarker) === BRANDLAB_CONTACT_TEST_MARKER\n}\n\nfunction safePagePath(pagePath: string) {\n try {\n return normalizeBrandlabRoutePath(pagePath.split(/[?#]/, 1)[0] || '/')\n } catch {\n return '/'\n }\n}\n\nfunction errorStage(result: BrandlabContactFailedResult): LeadFormErrorStage {\n return result.code === 'validation' ? 'validation' : 'delivery'\n}\n\n/**\n * Separates a field the visitor can correct from a request the server refused,\n * rejected photos, a server delivery failure and a browser-side failure, which\n * error_stage alone reports as only `validation` or `delivery`.\n */\nfunction errorReason(result: BrandlabContactFailedResult): LeadFormErrorReason {\n if (result.code === 'validation') {\n return Object.keys(result.fieldErrors ?? {}).length > 0 ? 'field' : 'request'\n }\n if (result.code === 'attachment_rejected') return 'attachment'\n return isContactClientFailure(result) ? 'network' : 'delivery'\n}\n\n/** The first rejected field in contract order: a contract key, never a value. */\nfunction firstErrorField(result: BrandlabContactFailedResult, fieldOrder: readonly string[]) {\n const fieldErrors = result.fieldErrors ?? {}\n return fieldOrder.find((key) => fieldErrors[key]?.length) ?? Object.keys(fieldErrors)[0]\n}\n\nfunction assertLifecycleOptions(options: UseBrandlabContactFormOptions) {\n const delay = options.redirectDelayMs\n if (delay !== undefined && (!Number.isInteger(delay) || delay < 0 || delay > 60_000)) {\n throw new TypeError('redirectDelayMs must be a whole number of milliseconds from 0 to 60000.')\n }\n if (options.silentAcceptance !== undefined && !['complete', 'ignore'].includes(options.silentAcceptance)) {\n throw new TypeError('silentAcceptance must be \"complete\" or \"ignore\".')\n }\n if (options.analytics !== undefined && !leadBindingFor(options.analytics)) {\n throw new TypeError('analytics must be the binding returned by defineBrandlabAnalytics.')\n }\n}\n\n/**\n * Contact form behaviour for project-owned markup and copy. The form posts\n * through fetch with FormData; before hydration the submit button stays\n * disabled. Typed values (uncontrolled fields) and prepared photos are kept\n * after any failure, retry() and an unchanged resubmission reuse the same\n * submission ID (so a resend cannot duplicate the email), the first invalid\n * field is focused, and an accepted enquiry resets the form and redirects.\n * The lead is reported exactly as the site's defineBrandlabAnalytics binding\n * declares, once per accepted enquiry, with contact_form's `has_photos`. On a\n * Brandlab test visit (`?bl_test=1`) each enquiry carries the `bl_test` marker\n * and is never reported (no lead diagnostics either). Browser validation is left exactly as the form's own\n * markup declares it.\n */\nexport function useBrandlabContactForm(options: UseBrandlabContactFormOptions): UseBrandlabContactFormResult {\n const contract = useMemo(() => defineContactContract(options.contract), [options.contract])\n assertLifecycleOptions(options)\n const hydrated = useSyncExternalStore(subscribeToNothing, getClientSnapshot, getServerSnapshot)\n const formId = options.formId ?? 'contact-form'\n const diagnosticsFormId = contactFormSlug(formId)\n const rawPagePath = options.pagePath\n const pagePath = safePagePath(rawPagePath)\n const formRef = useRef<HTMLFormElement>(null)\n const statusRef = useRef<HTMLElement>(null)\n const [state, setState] = useState<ContactSubmissionState>(INITIAL_STATE)\n const lockRef = useRef(false)\n const startedRef = useRef(false)\n const redirectTimerRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)\n const latest = useRef(options)\n latest.current = options\n\n const policy = options.attachments?.policy ??\n (contract.attachments.mode === 'images-and-pdfs-optional'\n ? DOCUMENT_CONTACT_ATTACHMENT_POLICY\n : DEFAULT_CONTACT_ATTACHMENT_POLICY)\n const attachments = useBrandlabContactAttachments({ ...options.attachments, policy })\n const attachmentPrefix = options.attachmentFieldPrefix ?? 'attachments'\n\n const fieldOrder = useMemo(() => contract.fields.map((field) => field.key), [contract])\n const fieldNames = useMemo(() => new Set(fieldOrder), [fieldOrder])\n const roles = useMemo(\n () => ({ fields: contract.fields.map((field) => ({ name: field.key, role: field.role })) }),\n [contract],\n )\n const { analytics, pageLabel, contactEndpoint, fetcher, adUserDataConsent } = options\n const controller = useMemo(() => {\n const lead = leadBindingFor(analytics)\n return createContactHttpSubmissionController({\n pagePath,\n ...(pageLabel ? { pageLabel } : {}),\n ...(contactEndpoint ? { contactEndpoint } : {}),\n ...(fetcher ? { fetcher } : {}),\n ...(lead\n ? {\n reportAccepted: (result, formData) => {\n // The server answers a test enquiry without a confirmation; this only guards that rule.\n if (isTestSubmission(formData)) return\n reportAcceptedLead(lead, result, {\n pagePath: rawPagePath,\n formData,\n fieldRoles: roles,\n hasPhotos: contactFormDataHasPhotos(formData),\n ...(adUserDataConsent !== undefined ? { adUserDataConsent } : {}),\n })\n },\n }\n : {}),\n onStateChange: setState,\n })\n }, [adUserDataConsent, analytics, contactEndpoint, fetcher, pageLabel, pagePath, rawPagePath, roles])\n\n useEffect(() => () => clearTimeout(redirectTimerRef.current), [])\n\n useEffect(() => {\n if (state.phase !== 'error') return\n const invalid = formRef.current?.querySelector<HTMLElement>(FOCUSABLE_INVALID_FIELD)\n ;(invalid ?? statusRef.current)?.focus()\n }, [state])\n\n const trackStart = useCallback(() => {\n if (startedRef.current) return\n startedRef.current = true\n // A Brandlab test visit is never a starter: no diagnostics.\n if (brandlabTestVisit()) return\n latest.current.analytics?.trackLeadFormStart({ pagePath: rawPagePath, formId: diagnosticsFormId })\n }, [diagnosticsFormId, rawPagePath])\n\n const handleResult = useCallback(\n (result: ContactActionResult) => {\n const current = latest.current\n current.onSettled?.(result)\n if (!result.ok) {\n const reason = errorReason(result)\n const field = reason === 'field' ? firstErrorField(result, fieldOrder) : undefined\n if (!brandlabTestVisit()) current.analytics?.trackLeadFormError({\n pagePath: rawPagePath,\n formId: diagnosticsFormId,\n stage: errorStage(result),\n errorCount: result.code === 'validation'\n ? Math.min(50, Math.max(1, Object.keys(result.fieldErrors ?? {}).length))\n : 1,\n reason,\n ...(field ? { field } : {}),\n })\n current.onFailed?.(result)\n return\n }\n if (!result.accepted && current.silentAcceptance === 'ignore') return\n formRef.current?.reset()\n attachments.clearImages()\n current.onAccepted?.(result)\n const redirectTo = current.redirectTo\n if (!redirectTo) return\n const navigate = current.navigate ?? ((href: string) => window.location.assign(href))\n const delay = current.redirectDelayMs ?? DEFAULT_REDIRECT_DELAY_MS\n clearTimeout(redirectTimerRef.current)\n if (delay === 0) {\n navigate(redirectTo)\n return\n }\n redirectTimerRef.current = setTimeout(() => navigate(redirectTo), delay)\n },\n [attachments, diagnosticsFormId, fieldOrder, rawPagePath],\n )\n\n const send = useCallback(\n async (attempt: () => Promise<ContactActionResult>) => {\n lockRef.current = true\n try {\n const result = await attempt()\n handleResult(result)\n return result\n } finally {\n lockRef.current = false\n }\n },\n [handleResult],\n )\n\n const onSubmit = useCallback(\n (event: FormEvent<HTMLFormElement>) => {\n event.preventDefault()\n if (lockRef.current || attachments.isProcessing) return\n const form = event.currentTarget\n const formData = new FormData(form)\n if (latest.current.onSubmitStart?.({ form, formData }) === false) return\n if (brandlabTestVisit()) formData.set(CONTACT_FORM_FIELDS.testMarker, BRANDLAB_CONTACT_TEST_MARKER)\n trackStart()\n attachments.clearErrorMessage()\n attachments.images.forEach((image, index) => {\n formData.append(`${attachmentPrefix}[${index}]`, image.file)\n })\n // The controller reports every failure as a result; nothing is left to handle here.\n send(() => controller.submit(formData)).catch(() => undefined)\n },\n [attachmentPrefix, attachments, controller, send, trackStart],\n )\n\n const retry = useCallback(async () => {\n if (lockRef.current || !controller.getState().canRetry) return undefined\n return send(() => controller.retry())\n }, [controller, send])\n\n const fieldErrors = state.result && !state.result.ok && state.result.code === 'validation'\n ? state.result.fieldErrors ?? {}\n : {}\n\n const submitDisabled = !hydrated || state.pending || attachments.isProcessing\n return {\n formId,\n formProps: {\n ...(options.formId ? { id: options.formId } : {}),\n ref: formRef,\n method: 'post',\n 'aria-busy': state.pending || attachments.isProcessing,\n onSubmit,\n onFocusCapture: trackStart,\n },\n submitProps: { type: 'submit', disabled: submitDisabled },\n hydrated,\n submitDisabled,\n pending: state.pending,\n phase: state.phase,\n result: state.result,\n succeeded: state.result?.ok === true,\n canRetry: state.canRetry,\n fieldErrors,\n fieldError: (name: string) => fieldErrors[name]?.[0],\n errorId: (name: string) => `${formId}-${name}-error`,\n statusRef,\n retry,\n attachments,\n fieldNames,\n }\n}\n\nexport interface ContactFieldPropsOptions {\n /** Ids of help text already describing the field; the error id is appended. */\n describedBy?: string\n /** Defaults to disabled while an enquiry is sending. */\n disabled?: boolean\n}\n\n/**\n * Props for one uncontrolled contract field: name, disabled while sending and\n * the error relationship. It never adds value, required or length attributes,\n * so the form's existing validation is unchanged.\n */\nexport function contactFieldProps(\n form: UseBrandlabContactFormResult,\n name: string,\n options: ContactFieldPropsOptions = {},\n) {\n if (!form.fieldNames.has(name)) {\n throw new Error(`\"${name}\" is not a field in the contact contract.`)\n }\n const error = form.fieldError(name)\n const describedBy = [options.describedBy, error ? form.errorId(name) : undefined]\n .filter(Boolean)\n .join(' ')\n return {\n name,\n disabled: options.disabled ?? form.pending,\n 'aria-invalid': error ? (true as const) : undefined,\n 'aria-describedby': describedBy || undefined,\n }\n}\n"]}
1
+ {"version":3,"file":"form-client.js","sourceRoot":"","sources":["../../src/contact/form-client.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,EACL,iCAAiC,EACjC,kCAAkC,EAClC,qBAAqB,GAGtB,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAA;AAC/E,OAAO,EACL,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,EACR,oBAAoB,GAGrB,MAAM,OAAO,CAAA;AAEd,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACnF,OAAO,EACL,6BAA6B,GAG9B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACL,qCAAqC,EACrC,sBAAsB,GAGvB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,4BAA4B,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAiI/E,MAAM,aAAa,GAA2B;IAC5C,KAAK,EAAE,MAAM;IACb,OAAO,EAAE,KAAK;IACd,QAAQ,EAAE,KAAK;CAChB,CAAA;AACD,MAAM,yBAAyB,GAAG,KAAK,CAAA;AACvC,MAAM,uBAAuB,GAAG;IAC9B,iEAAiE;IACjE,6CAA6C;IAC7C,+CAA+C;IAC/C,6CAA6C;IAC7C,6DAA6D;CAC9D,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAEX,MAAM,kBAAkB,GAAG,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,SAAS,CAAA;AAChD,MAAM,iBAAiB,GAAG,GAAG,EAAE,CAAC,IAAI,CAAA;AACpC,MAAM,iBAAiB,GAAG,GAAG,EAAE,CAAC,KAAK,CAAA;AAErC,+FAA+F;AAC/F,MA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AAC,MAAM,EAAE,EAAE,KAAK,IAAI;QACpC,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,WAAW;QACX,UAAU,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QACpD,OAAO,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,GAAG,MAAM,IAAI,IAAI,QAAQ;QACpD,SAAS;QACT,KAAK;QACL,WAAW;QACX,UAAU;KACX,CAAA;AACH,CAAC;AASD;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC/B,IAAkC,EAClC,IAAY,EACZ,UAAoC,EAAE;IAEtC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,IAAI,IAAI,2CAA2C,CAAC,CAAA;IACtE,CAAC;IACD,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;IACnC,MAAM,WAAW,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;SAC9E,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,GAAG,CAAC,CAAA;IACZ,OAAO;QACL,IAAI;QACJ,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO;QAC1C,cAAc,EAAE,KAAK,CAAC,CAAC,CAAE,IAAc,CAAC,CAAC,CAAC,SAAS;QACnD,kBAAkB,EAAE,WAAW,IAAI,SAAS;KAC7C,CAAA;AACH,CAAC","sourcesContent":["'use client'\n\nimport {\n DEFAULT_CONTACT_ATTACHMENT_POLICY,\n DOCUMENT_CONTACT_ATTACHMENT_POLICY,\n defineContactContract,\n type BrandlabContactContract,\n type ContactActionResult,\n} from '@brandlab-digital/site-core/contact'\nimport { normalizeBrandlabRoutePath } from '@brandlab-digital/site-core/routes'\nimport {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n type FormEvent,\n type RefObject,\n} from 'react'\nimport type { BrandlabAnalytics, LeadFormErrorReason, LeadFormErrorStage } from '../analytics.js'\nimport { leadBindingFor, safeSlug } from '../lead-registry.js'\nimport { contactFormDataHasPhotos, reportAcceptedLead } from '../lead-reporting.js'\nimport {\n useBrandlabContactAttachments,\n type UseBrandlabContactAttachmentsOptions,\n type UseBrandlabContactAttachmentsResult,\n} from './attachments-client.js'\nimport {\n createContactHttpSubmissionController,\n isContactClientFailure,\n type ContactSubmissionPhase,\n type ContactSubmissionState,\n} from './client.js'\nimport { BRANDLAB_CONTACT_TEST_MARKER, CONTACT_FORM_FIELDS } from './shared.js'\n\n/** An accepted enquiry, or a silently accepted spam-protected submission (`accepted: false`). */\nexport type BrandlabContactAcceptedResult = Extract<ContactActionResult, { ok: true }>\nexport type BrandlabContactFailedResult = Extract<ContactActionResult, { ok: false }>\n\nexport interface BrandlabContactSubmitStart {\n form: HTMLFormElement\n /**\n * The fields about to be sent, read from the form. Add or replace entries\n * here (for example `service_interest`); prepared photos are appended after.\n */\n formData: FormData\n}\n\n/**\n * Returned by onSubmitStart to cancel because the form's own checks failed (3.18.0): the failing keys in the order\n * the visitor sees them. Nothing is sent, and lead_form_error goes out with stage `validation` and reason `field`\n * naming the first contract field; a key that isn't a contract field (the photos) gives reason `attachment`.\n */\nexport interface BrandlabContactClientInvalid {\n invalidFields: readonly string[]\n}\n\nexport interface UseBrandlabContactFormOptions {\n /** The contact contract from src/config/contact.ts. */\n contract: BrandlabContactContract\n /** The site's defineBrandlabAnalytics binding: the declared lead after each accepted enquiry, plus lead diagnostics. */\n analytics?: BrandlabAnalytics\n /** The current pathname, for example `usePathname()`. */\n pagePath: string\n /** Reviewed label for the enquiry email's page row. */\n pageLabel?: string\n /**\n * The form element's id and the lead diagnostics' form_id. Without it the form\n * gets no id (the hook never takes a React id, so the form's own ids are\n * unchanged), diagnostics use `contact-form` and error ids start `contact-form-`.\n * The element keeps the id exactly as given; diagnostics report it as a slug\n * (React `useId()` parts removed, see `contactFormSlug`).\n */\n formId?: string\n /** Page to open after an accepted enquiry; `null` or omitted keeps the visitor on the page. */\n redirectTo?: string | null\n /** Client navigation such as `router.push`; defaults to `window.location.assign`. */\n navigate?: (href: string) => void\n /** Delay before the redirect, in milliseconds (default 1500); 0 navigates at once. */\n redirectDelayMs?: number\n /**\n * Runs when the visitor submits, before anything is sent: clear the form's\n * own notices, adjust `formData`, or return `false` to cancel (for example\n * after `form.reportValidity()`). Return `{ invalidFields }` instead to\n * cancel and report the failed checks as lead_form_error. An unchanged\n * resubmission runs it too; `retry()` does not.\n */\n onSubmitStart?: (submission: BrandlabContactSubmitStart) => void | false | BrandlabContactClientInvalid\n /**\n * Runs after every attempt, before onAccepted or onFailed: an accepted\n * enquiry, a silently accepted submission (even when ignored) or a failure.\n */\n onSettled?: (result: ContactActionResult) => void\n /** Runs after an accepted enquiry, once the form has been reset and before any redirect. */\n onAccepted?: (result: BrandlabContactAcceptedResult) => void\n /** Runs after a failed attempt; typed values and prepared photos are kept. */\n onFailed?: (result: BrandlabContactFailedResult) => void\n /**\n * A silently accepted submission (spam protection): `complete` (default)\n * resets, runs onAccepted and redirects like an accepted enquiry; `ignore`\n * leaves the form as it is and runs only onSettled.\n */\n silentAcceptance?: 'complete' | 'ignore'\n /** Photo preparation options; the policy follows the contract's attachment mode by default. */\n attachments?: UseBrandlabContactAttachmentsOptions\n /** Multipart field prefix for prepared files (default `attachments`, sent as `attachments[0]` …). */\n attachmentFieldPrefix?: string\n /** Live Consent Mode decision for ad_user_data; without it Enhanced Conversions stay off, unless the analytics contract's mode is `disclosed`. */\n adUserDataConsent?: boolean\n contactEndpoint?: string\n fetcher?: typeof fetch\n}\n\n/**\n * Spread onto the `<form>`: `method=\"post\"` with no `action` or `encType`, so a\n * submission before hydration posts back to the page and never puts fields in\n * a URL; the hook submits through fetch. `id` only when `formId` is given.\n */\nexport interface BrandlabContactFormProps {\n id?: string\n ref: RefObject<HTMLFormElement | null>\n method: 'post'\n 'aria-busy': boolean\n onSubmit: (event: FormEvent<HTMLFormElement>) => void\n onFocusCapture: () => void\n}\n\n/** Spread onto the submit button: disabled until hydration, while sending or preparing photos. */\nexport interface BrandlabContactSubmitProps {\n type: 'submit'\n disabled: boolean\n}\n\nexport interface UseBrandlabContactFormResult {\n /** The `formId` option, or `contact-form` when none was given. */\n formId: string\n formProps: BrandlabContactFormProps\n submitProps: BrandlabContactSubmitProps\n /** False during server rendering and hydration. */\n hydrated: boolean\n /** The submit button's `disabled` (also in submitProps): until hydration, while sending or preparing photos. */\n submitDisabled: boolean\n pending: boolean\n phase: ContactSubmissionPhase\n result: ContactActionResult | undefined\n /** An accepted enquiry (a silently accepted spam-protected submission looks the same). */\n succeeded: boolean\n /** A retryable failure: retry(), or submitting the same fields again, reuses its submission ID. */\n canRetry: boolean\n fieldErrors: Readonly<Record<string, readonly string[]>>\n fieldError(name: string): string | undefined\n /** Id for a field's error message element: `${formId}-${name}-error`. */\n errorId(name: string): string\n /** Attach to the status element; it receives focus when an error has no invalid field. */\n statusRef: RefObject<HTMLElement | null>\n /** Resends the failed enquiry with the same submission ID. */\n retry(): Promise<ContactActionResult | undefined>\n attachments: UseBrandlabContactAttachmentsResult\n /** Contract field keys accepted by contactFieldProps. */\n fieldNames: ReadonlySet<string>\n}\n\nconst INITIAL_STATE: ContactSubmissionState = {\n phase: 'idle',\n pending: false,\n canRetry: false,\n}\nconst DEFAULT_REDIRECT_DELAY_MS = 1_500\nconst FOCUSABLE_INVALID_FIELD = [\n 'input[aria-invalid=\"true\"]:not([disabled]):not([type=\"hidden\"])',\n 'select[aria-invalid=\"true\"]:not([disabled])',\n 'textarea[aria-invalid=\"true\"]:not([disabled])',\n 'button[aria-invalid=\"true\"]:not([disabled])',\n '[aria-invalid=\"true\"][tabindex]:not([aria-disabled=\"true\"])',\n].join(',')\n\nconst subscribeToNothing = () => () => undefined\nconst getClientSnapshot = () => true\nconst getServerSnapshot = () => false\n\n/** React `useId()` values: `_R_1a_`/`_r_1a_` (19.2), `«r1a»` (19.0 and 19.1), `:r1a:` (18). */\nconst REACT_ID = /_[rR]_[0-9A-Za-z]*_|«[rR][0-9A-Za-z]*»|:[rR][0-9A-Za-z]*:/g\n\n/**\n * The lead diagnostics' form_id for any formId. A valid slug is kept (trimmed and\n * lowercased). Otherwise React `useId()` parts are removed, so an id made unique for\n * the page still reports as one stable form, every run of other characters becomes\n * one hyphen, and the result is at most 80 characters; `contact-form` when nothing\n * is left. Without this, a formId such as `contact-form-_R_5e35f9db_` silently\n * dropped lead_form_start and lead_form_error.\n */\nexport function contactFormSlug(formId: string): string {\n const slug = safeSlug(String(formId))\n if (slug) return slug\n const derived = String(formId)\n .replace(REACT_ID, '-')\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+/, '')\n .slice(0, 80)\n .replace(/-+$/, '')\n return derived || 'contact-form'\n}\n\n/**\n * A Brandlab test visit: a page opened with `?bl_test=1` (a launch proof or canary), remembered for the tab so the\n * marker survives moving to the quote form; `?bl_test=0` ends it. Its enquiries carry the `bl_test` marker.\n */\nfunction brandlabTestVisit() {\n if (typeof window === 'undefined') return false\n try {\n const flag = new URLSearchParams(window.location.search).get(CONTACT_FORM_FIELDS.testMarker)\n if (flag === BRANDLAB_CONTACT_TEST_MARKER) window.sessionStorage.setItem(CONTACT_FORM_FIELDS.testMarker, flag)\n if (flag === '0') window.sessionStorage.removeItem(CONTACT_FORM_FIELDS.testMarker)\n return window.sessionStorage.getItem(CONTACT_FORM_FIELDS.testMarker) === BRANDLAB_CONTACT_TEST_MARKER ||\n flag === BRANDLAB_CONTACT_TEST_MARKER\n } catch {\n return false\n }\n}\n\nfunction isTestSubmission(formData: FormData) {\n return formData.get(CONTACT_FORM_FIELDS.testMarker) === BRANDLAB_CONTACT_TEST_MARKER\n}\n\nfunction safePagePath(pagePath: string) {\n try {\n return normalizeBrandlabRoutePath(pagePath.split(/[?#]/, 1)[0] || '/')\n } catch {\n return '/'\n }\n}\n\nfunction errorStage(result: BrandlabContactFailedResult): LeadFormErrorStage {\n return result.code === 'validation' ? 'validation' : 'delivery'\n}\n\n/**\n * Separates a field the visitor can correct from a request the server refused,\n * rejected photos, a server delivery failure and a browser-side failure, which\n * error_stage alone reports as only `validation` or `delivery`.\n */\nfunction errorReason(result: BrandlabContactFailedResult): LeadFormErrorReason {\n if (result.code === 'validation') {\n return Object.keys(result.fieldErrors ?? {}).length > 0 ? 'field' : 'request'\n }\n if (result.code === 'attachment_rejected') return 'attachment'\n return isContactClientFailure(result) ? 'network' : 'delivery'\n}\n\n/** The first rejected field in contract order: a contract key, never a value. */\nfunction firstErrorField(result: BrandlabContactFailedResult, fieldOrder: readonly string[]) {\n const fieldErrors = result.fieldErrors ?? {}\n return fieldOrder.find((key) => fieldErrors[key]?.length) ?? Object.keys(fieldErrors)[0]\n}\n\nfunction assertLifecycleOptions(options: UseBrandlabContactFormOptions) {\n const delay = options.redirectDelayMs\n if (delay !== undefined && (!Number.isInteger(delay) || delay < 0 || delay > 60_000)) {\n throw new TypeError('redirectDelayMs must be a whole number of milliseconds from 0 to 60000.')\n }\n if (options.silentAcceptance !== undefined && !['complete', 'ignore'].includes(options.silentAcceptance)) {\n throw new TypeError('silentAcceptance must be \"complete\" or \"ignore\".')\n }\n if (options.analytics !== undefined && !leadBindingFor(options.analytics)) {\n throw new TypeError('analytics must be the binding returned by defineBrandlabAnalytics.')\n }\n}\n\n/**\n * Contact form behaviour for project-owned markup and copy. The form posts\n * through fetch with FormData; before hydration the submit button stays\n * disabled. Typed values (uncontrolled fields) and prepared photos are kept\n * after any failure, retry() and an unchanged resubmission reuse the same\n * submission ID (so a resend cannot duplicate the email), the first invalid\n * field is focused, and an accepted enquiry resets the form and redirects.\n * The lead is reported exactly as the site's defineBrandlabAnalytics binding\n * declares, once per accepted enquiry, with contact_form's `has_photos`. On a\n * Brandlab test visit (`?bl_test=1`) each enquiry carries the `bl_test` marker\n * and is never reported (no lead diagnostics either). Browser validation is left exactly as the form's own\n * markup declares it.\n */\nexport function useBrandlabContactForm(options: UseBrandlabContactFormOptions): UseBrandlabContactFormResult {\n const contract = useMemo(() => defineContactContract(options.contract), [options.contract])\n assertLifecycleOptions(options)\n const hydrated = useSyncExternalStore(subscribeToNothing, getClientSnapshot, getServerSnapshot)\n const formId = options.formId ?? 'contact-form'\n const diagnosticsFormId = contactFormSlug(formId)\n const rawPagePath = options.pagePath\n const pagePath = safePagePath(rawPagePath)\n const formRef = useRef<HTMLFormElement>(null)\n const statusRef = useRef<HTMLElement>(null)\n const [state, setState] = useState<ContactSubmissionState>(INITIAL_STATE)\n const lockRef = useRef(false)\n const startedRef = useRef(false)\n const redirectTimerRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)\n const latest = useRef(options)\n latest.current = options\n\n const policy = options.attachments?.policy ??\n (contract.attachments.mode === 'images-and-pdfs-optional'\n ? DOCUMENT_CONTACT_ATTACHMENT_POLICY\n : DEFAULT_CONTACT_ATTACHMENT_POLICY)\n const attachments = useBrandlabContactAttachments({ ...options.attachments, policy })\n const attachmentPrefix = options.attachmentFieldPrefix ?? 'attachments'\n\n const fieldOrder = useMemo(() => contract.fields.map((field) => field.key), [contract])\n const fieldNames = useMemo(() => new Set(fieldOrder), [fieldOrder])\n const roles = useMemo(\n () => ({ fields: contract.fields.map((field) => ({ name: field.key, role: field.role })) }),\n [contract],\n )\n const { analytics, pageLabel, contactEndpoint, fetcher, adUserDataConsent } = options\n const controller = useMemo(() => {\n const lead = leadBindingFor(analytics)\n return createContactHttpSubmissionController({\n pagePath,\n ...(pageLabel ? { pageLabel } : {}),\n ...(contactEndpoint ? { contactEndpoint } : {}),\n ...(fetcher ? { fetcher } : {}),\n ...(lead\n ? {\n reportAccepted: (result, formData) => {\n // The server answers a test enquiry without a confirmation; this only guards that rule.\n if (isTestSubmission(formData)) return\n reportAcceptedLead(lead, result, {\n pagePath: rawPagePath,\n formData,\n fieldRoles: roles,\n hasPhotos: contactFormDataHasPhotos(formData),\n ...(adUserDataConsent !== undefined ? { adUserDataConsent } : {}),\n })\n },\n }\n : {}),\n onStateChange: setState,\n })\n }, [adUserDataConsent, analytics, contactEndpoint, fetcher, pageLabel, pagePath, rawPagePath, roles])\n\n useEffect(() => () => clearTimeout(redirectTimerRef.current), [])\n\n useEffect(() => {\n if (state.phase !== 'error') return\n const invalid = formRef.current?.querySelector<HTMLElement>(FOCUSABLE_INVALID_FIELD)\n ;(invalid ?? statusRef.current)?.focus()\n }, [state])\n\n const trackStart = useCallback(() => {\n if (startedRef.current) return\n startedRef.current = true\n // A Brandlab test visit is never a starter: no diagnostics.\n if (brandlabTestVisit()) return\n latest.current.analytics?.trackLeadFormStart({ pagePath: rawPagePath, formId: diagnosticsFormId })\n }, [diagnosticsFormId, rawPagePath])\n\n const handleResult = useCallback(\n (result: ContactActionResult) => {\n const current = latest.current\n current.onSettled?.(result)\n if (!result.ok) {\n const reason = errorReason(result)\n const field = reason === 'field' ? firstErrorField(result, fieldOrder) : undefined\n if (!brandlabTestVisit()) current.analytics?.trackLeadFormError({\n pagePath: rawPagePath,\n formId: diagnosticsFormId,\n stage: errorStage(result),\n errorCount: result.code === 'validation'\n ? Math.min(50, Math.max(1, Object.keys(result.fieldErrors ?? {}).length))\n : 1,\n reason,\n ...(field ? { field } : {}),\n })\n current.onFailed?.(result)\n return\n }\n if (!result.accepted && current.silentAcceptance === 'ignore') return\n formRef.current?.reset()\n attachments.clearImages()\n current.onAccepted?.(result)\n const redirectTo = current.redirectTo\n if (!redirectTo) return\n const navigate = current.navigate ?? ((href: string) => window.location.assign(href))\n const delay = current.redirectDelayMs ?? DEFAULT_REDIRECT_DELAY_MS\n clearTimeout(redirectTimerRef.current)\n if (delay === 0) {\n navigate(redirectTo)\n return\n }\n redirectTimerRef.current = setTimeout(() => navigate(redirectTo), delay)\n },\n [attachments, diagnosticsFormId, fieldOrder, rawPagePath],\n )\n\n const send = useCallback(\n async (attempt: () => Promise<ContactActionResult>) => {\n lockRef.current = true\n try {\n const result = await attempt()\n handleResult(result)\n return result\n } finally {\n lockRef.current = false\n }\n },\n [handleResult],\n )\n\n const onSubmit = useCallback(\n (event: FormEvent<HTMLFormElement>) => {\n event.preventDefault()\n if (lockRef.current || attachments.isProcessing) return\n const form = event.currentTarget\n const formData = new FormData(form)\n const started = latest.current.onSubmitStart?.({ form, formData })\n if (started === false) return\n if (started && typeof started === 'object') {\n trackStart()\n const keys = started.invalidFields\n const field = keys.find((key) => fieldOrder.includes(key))\n if (!brandlabTestVisit()) latest.current.analytics?.trackLeadFormError({\n pagePath: rawPagePath,\n formId: diagnosticsFormId,\n stage: 'validation',\n errorCount: Math.min(50, Math.max(1, keys.length)),\n reason: field ? 'field' : 'attachment',\n ...(field ? { field } : {}),\n })\n return\n }\n if (brandlabTestVisit()) formData.set(CONTACT_FORM_FIELDS.testMarker, BRANDLAB_CONTACT_TEST_MARKER)\n trackStart()\n attachments.clearErrorMessage()\n attachments.images.forEach((image, index) => {\n formData.append(`${attachmentPrefix}[${index}]`, image.file)\n })\n // The controller reports every failure as a result; nothing is left to handle here.\n send(() => controller.submit(formData)).catch(() => undefined)\n },\n [attachmentPrefix, attachments, controller, diagnosticsFormId, fieldOrder, rawPagePath, send, trackStart],\n )\n\n const retry = useCallback(async () => {\n if (lockRef.current || !controller.getState().canRetry) return undefined\n return send(() => controller.retry())\n }, [controller, send])\n\n const fieldErrors = state.result && !state.result.ok && state.result.code === 'validation'\n ? state.result.fieldErrors ?? {}\n : {}\n\n const submitDisabled = !hydrated || state.pending || attachments.isProcessing\n return {\n formId,\n formProps: {\n ...(options.formId ? { id: options.formId } : {}),\n ref: formRef,\n method: 'post',\n 'aria-busy': state.pending || attachments.isProcessing,\n onSubmit,\n onFocusCapture: trackStart,\n },\n submitProps: { type: 'submit', disabled: submitDisabled },\n hydrated,\n submitDisabled,\n pending: state.pending,\n phase: state.phase,\n result: state.result,\n succeeded: state.result?.ok === true,\n canRetry: state.canRetry,\n fieldErrors,\n fieldError: (name: string) => fieldErrors[name]?.[0],\n errorId: (name: string) => `${formId}-${name}-error`,\n statusRef,\n retry,\n attachments,\n fieldNames,\n }\n}\n\nexport interface ContactFieldPropsOptions {\n /** Ids of help text already describing the field; the error id is appended. */\n describedBy?: string\n /** Defaults to disabled while an enquiry is sending. */\n disabled?: boolean\n}\n\n/**\n * Props for one uncontrolled contract field: name, disabled while sending and\n * the error relationship. It never adds value, required or length attributes,\n * so the form's existing validation is unchanged.\n */\nexport function contactFieldProps(\n form: UseBrandlabContactFormResult,\n name: string,\n options: ContactFieldPropsOptions = {},\n) {\n if (!form.fieldNames.has(name)) {\n throw new Error(`\"${name}\" is not a field in the contact contract.`)\n }\n const error = form.fieldError(name)\n const describedBy = [options.describedBy, error ? form.errorId(name) : undefined]\n .filter(Boolean)\n .join(' ')\n return {\n name,\n disabled: options.disabled ?? form.pending,\n 'aria-invalid': error ? (true as const) : undefined,\n 'aria-describedby': describedBy || undefined,\n }\n}\n"]}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * A thank-you redirect that keeps the enquiry's analytics (3.18.0). The contact_form event and the Google Ads
3
+ * conversion go to `gtag()` the moment an enquiry is accepted. Until Google's tag script (`BrandlabGoogleTag`'s
4
+ * `data-brandlab-google-tag="loader"`) has loaded, `gtag()` only queues them in `dataLayer`, and a full page load
5
+ * straight away throws the queue away (Codex reproduced the loss on AA with a slow tag, 28 Oct 2026). Once the tag has
6
+ * loaded its hits leave by beacon, so a short pause before the page load keeps them. A slow tag gets up to
7
+ * `maxWaitMs`; a blocked or absent one (ad blocker, network error, a preview without the tag) sends the visitor on at
8
+ * once.
9
+ */
10
+ /** The longest the redirect waits for Google's tag to load before going anyway. */
11
+ export declare const GOOGLE_TAG_WAIT_MS = 8000;
12
+ /** The pause after the tag has loaded, for it to send what was queued. */
13
+ export declare const GOOGLE_TAG_SETTLE_MS = 150;
14
+ /** Whether there is nothing left to wait for: the tag has loaded or failed, or the page has no tag at all. */
15
+ export declare function googleTagSettled(win?: Window): boolean;
16
+ export interface NavigateAfterGoogleTagOptions {
17
+ /** The longest wait for the tag (default 8000 ms). */
18
+ readonly maxWaitMs?: number;
19
+ /** The pause once the tag has loaded (default 150 ms). */
20
+ readonly settleMs?: number;
21
+ /** The page load; `window.location.assign` by default. */
22
+ readonly assign?: (href: string) => void;
23
+ readonly win?: Window;
24
+ }
25
+ /**
26
+ * Opens `href` once Google's tag has had the chance to send the enquiry's hits. `QuoteForm`'s default; any site on
27
+ * `useBrandlabContactForm` can pass it as `navigate`.
28
+ */
29
+ export declare function navigateAfterGoogleTag(href: string, options?: NavigateAfterGoogleTagOptions): void;
30
+ /** Test seam: forget a settled loader between tests. */
31
+ export declare function resetGoogleTagWaitForTests(): void;
32
+ //# sourceMappingURL=google-tag-navigate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"google-tag-navigate.d.ts","sourceRoot":"","sources":["../../src/contact/google-tag-navigate.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,mFAAmF;AACnF,eAAO,MAAM,kBAAkB,OAAO,CAAA;AACtC,0EAA0E;AAC1E,eAAO,MAAM,oBAAoB,MAAM,CAAA;AAqBvC,8GAA8G;AAC9G,wBAAgB,gBAAgB,CAAC,GAAG,GAAE,MAAe,GAAG,OAAO,CAO9D;AAED,MAAM,WAAW,6BAA6B;IAC5C,sDAAsD;IACtD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC3B,0DAA0D;IAC1D,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC1B,0DAA0D;IAC1D,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IACxC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CACtB;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,6BAAkC,GAAG,IAAI,CAmBtG;AAED,wDAAwD;AACxD,wBAAgB,0BAA0B,IAAI,IAAI,CAEjD"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * A thank-you redirect that keeps the enquiry's analytics (3.18.0). The contact_form event and the Google Ads
3
+ * conversion go to `gtag()` the moment an enquiry is accepted. Until Google's tag script (`BrandlabGoogleTag`'s
4
+ * `data-brandlab-google-tag="loader"`) has loaded, `gtag()` only queues them in `dataLayer`, and a full page load
5
+ * straight away throws the queue away (Codex reproduced the loss on AA with a slow tag, 28 Oct 2026). Once the tag has
6
+ * loaded its hits leave by beacon, so a short pause before the page load keeps them. A slow tag gets up to
7
+ * `maxWaitMs`; a blocked or absent one (ad blocker, network error, a preview without the tag) sends the visitor on at
8
+ * once.
9
+ */
10
+ /** The longest the redirect waits for Google's tag to load before going anyway. */
11
+ export const GOOGLE_TAG_WAIT_MS = 8000;
12
+ /** The pause after the tag has loaded, for it to send what was queued. */
13
+ export const GOOGLE_TAG_SETTLE_MS = 150;
14
+ const POLL_MS = 50;
15
+ const LOADER_SELECTOR = 'script[data-brandlab-google-tag="loader"]';
16
+ let loaderSettled = false;
17
+ let listening = false;
18
+ /** Listens once for the loader's load or error; resource events don't bubble but reach a capturing listener. */
19
+ function listen(win) {
20
+ if (listening)
21
+ return;
22
+ listening = true;
23
+ const settle = (event) => {
24
+ const target = event.target;
25
+ if (target?.tagName === 'SCRIPT' && target.dataset?.brandlabGoogleTag === 'loader')
26
+ loaderSettled = true;
27
+ };
28
+ win.addEventListener('load', settle, true);
29
+ win.addEventListener('error', settle, true);
30
+ }
31
+ if (typeof window !== 'undefined')
32
+ listen(window);
33
+ /** Whether there is nothing left to wait for: the tag has loaded or failed, or the page has no tag at all. */
34
+ export function googleTagSettled(win = window) {
35
+ if (loaderSettled || 'google_tag_manager' in win)
36
+ return true;
37
+ const loader = win.document.querySelector(LOADER_SELECTOR);
38
+ if (!loader)
39
+ return true;
40
+ // Finished before this module was evaluated: the resource timing entry is there.
41
+ return loader.src !== '' && typeof win.performance?.getEntriesByName === 'function'
42
+ && win.performance.getEntriesByName(loader.src).length > 0;
43
+ }
44
+ /**
45
+ * Opens `href` once Google's tag has had the chance to send the enquiry's hits. `QuoteForm`'s default; any site on
46
+ * `useBrandlabContactForm` can pass it as `navigate`.
47
+ */
48
+ export function navigateAfterGoogleTag(href, options = {}) {
49
+ const win = options.win ?? window;
50
+ listen(win);
51
+ const maxWaitMs = options.maxWaitMs ?? GOOGLE_TAG_WAIT_MS;
52
+ const settleMs = options.settleMs ?? GOOGLE_TAG_SETTLE_MS;
53
+ const assign = options.assign ?? ((target) => win.location.assign(target));
54
+ if (googleTagSettled(win) && !win.document.querySelector(LOADER_SELECTOR)) {
55
+ assign(href);
56
+ return;
57
+ }
58
+ const start = Date.now();
59
+ const wait = () => {
60
+ if (googleTagSettled(win) || Date.now() - start >= maxWaitMs) {
61
+ win.setTimeout(() => assign(href), settleMs);
62
+ return;
63
+ }
64
+ win.setTimeout(wait, POLL_MS);
65
+ };
66
+ wait();
67
+ }
68
+ /** Test seam: forget a settled loader between tests. */
69
+ export function resetGoogleTagWaitForTests() {
70
+ loaderSettled = false;
71
+ }
72
+ //# sourceMappingURL=google-tag-navigate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"google-tag-navigate.js","sourceRoot":"","sources":["../../src/contact/google-tag-navigate.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,mFAAmF;AACnF,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAA;AACtC,0EAA0E;AAC1E,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAA;AACvC,MAAM,OAAO,GAAG,EAAE,CAAA;AAClB,MAAM,eAAe,GAAG,2CAA2C,CAAA;AAEnE,IAAI,aAAa,GAAG,KAAK,CAAA;AACzB,IAAI,SAAS,GAAG,KAAK,CAAA;AAErB,gHAAgH;AAChH,SAAS,MAAM,CAAC,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,SAAS,IAAI,kBAAkB,CAAA;IACzD,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,oBAAoB,CAAA;IACzD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC,MAAc,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAA;IAClF,IAAI,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,aAAa,CAAC,eAAe,CAAC,EAAE,CAAC;QAC1E,MAAM,CAAC,IAAI,CAAC,CAAA;QACZ,OAAM;IACR,CAAC;IACD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;IACxB,MAAM,IAAI,GAAG,GAAG,EAAE;QAChB,IAAI,gBAAgB,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,SAAS,EAAE,CAAC;YAC7D,GAAG,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAA;YAC5C,OAAM;QACR,CAAC;QACD,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IAC/B,CAAC,CAAA;IACD,IAAI,EAAE,CAAA;AACR,CAAC;AAED,wDAAwD;AACxD,MAAM,UAAU,0BAA0B;IACxC,aAAa,GAAG,KAAK,CAAA;AACvB,CAAC","sourcesContent":["/**\n * A thank-you redirect that keeps the enquiry's analytics (3.18.0). The contact_form event and the Google Ads\n * conversion go to `gtag()` the moment an enquiry is accepted. Until Google's tag script (`BrandlabGoogleTag`'s\n * `data-brandlab-google-tag=\"loader\"`) has loaded, `gtag()` only queues them in `dataLayer`, and a full page load\n * straight away throws the queue away (Codex reproduced the loss on AA with a slow tag, 28 Oct 2026). Once the tag has\n * loaded its hits leave by beacon, so a short pause before the page load keeps them. A slow tag gets up to\n * `maxWaitMs`; a blocked or absent one (ad blocker, network error, a preview without the tag) sends the visitor on at\n * once.\n */\n\n/** The longest the redirect waits for Google's tag to load before going anyway. */\nexport const GOOGLE_TAG_WAIT_MS = 8000\n/** The pause after the tag has loaded, for it to send what was queued. */\nexport const GOOGLE_TAG_SETTLE_MS = 150\nconst POLL_MS = 50\nconst LOADER_SELECTOR = 'script[data-brandlab-google-tag=\"loader\"]'\n\nlet loaderSettled = false\nlet listening = false\n\n/** Listens once for the loader's load or error; resource events don't bubble but reach a capturing listener. */\nfunction listen(win: Window) {\n if (listening) return\n listening = true\n const settle = (event: Event) => {\n const target = event.target as { tagName?: string; dataset?: DOMStringMap } | null\n if (target?.tagName === 'SCRIPT' && target.dataset?.brandlabGoogleTag === 'loader') loaderSettled = true\n }\n win.addEventListener('load', settle, true)\n win.addEventListener('error', settle, true)\n}\n\nif (typeof window !== 'undefined') listen(window)\n\n/** Whether there is nothing left to wait for: the tag has loaded or failed, or the page has no tag at all. */\nexport function googleTagSettled(win: Window = window): boolean {\n if (loaderSettled || 'google_tag_manager' in win) return true\n const loader = win.document.querySelector<HTMLScriptElement>(LOADER_SELECTOR)\n if (!loader) return true\n // Finished before this module was evaluated: the resource timing entry is there.\n return loader.src !== '' && typeof win.performance?.getEntriesByName === 'function'\n && win.performance.getEntriesByName(loader.src).length > 0\n}\n\nexport interface NavigateAfterGoogleTagOptions {\n /** The longest wait for the tag (default 8000 ms). */\n readonly maxWaitMs?: number\n /** The pause once the tag has loaded (default 150 ms). */\n readonly settleMs?: number\n /** The page load; `window.location.assign` by default. */\n readonly assign?: (href: string) => void\n readonly win?: Window\n}\n\n/**\n * Opens `href` once Google's tag has had the chance to send the enquiry's hits. `QuoteForm`'s default; any site on\n * `useBrandlabContactForm` can pass it as `navigate`.\n */\nexport function navigateAfterGoogleTag(href: string, options: NavigateAfterGoogleTagOptions = {}): void {\n const win = options.win ?? window\n listen(win)\n const maxWaitMs = options.maxWaitMs ?? GOOGLE_TAG_WAIT_MS\n const settleMs = options.settleMs ?? GOOGLE_TAG_SETTLE_MS\n const assign = options.assign ?? ((target: string) => win.location.assign(target))\n if (googleTagSettled(win) && !win.document.querySelector(LOADER_SELECTOR)) {\n assign(href)\n return\n }\n const start = Date.now()\n const wait = () => {\n if (googleTagSettled(win) || Date.now() - start >= maxWaitMs) {\n win.setTimeout(() => assign(href), settleMs)\n return\n }\n win.setTimeout(wait, POLL_MS)\n }\n wait()\n}\n\n/** Test seam: forget a settled loader between tests. */\nexport function resetGoogleTagWaitForTests(): void {\n loaderSettled = false\n}\n"]}
@@ -116,6 +116,11 @@ export declare const BRANDLAB_ICON_SPRITE_SOURCE = "/_bl/:file(icons\\.[0-9a-f]+
116
116
  export declare const BRANDLAB_CONTACT_OUTPUT_FILE_TRACING: Readonly<{
117
117
  '/api/contact': readonly string[];
118
118
  }>;
119
+ /**
120
+ * Next's own device widths plus 1440 (3.18.0): a hero on a 1440 px screen gets a 1440 px file instead of a 1920 px one,
121
+ * about 40% fewer bytes (B1). A site's own `images.deviceSizes` replaces the list.
122
+ */
123
+ export declare const BRANDLAB_DEFAULT_DEVICE_SIZES: readonly [640, 750, 828, 1080, 1200, 1440, 1920, 2048, 3840];
119
124
  /**
120
125
  * Converts the redirect table to Next redirects: each entry keeps its 301 or
121
126
  * 308 status (Next forwards the query string), gains a single-hop
@@ -1 +1 @@
1
- {"version":3,"file":"next-config.d.ts","sourceRoot":"","sources":["../src/next-config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmB,KAAK,qBAAqB,EAAE,MAAM,uCAAuC,CAAA;AACnG,OAAO,EAGL,KAAK,6BAA6B,EAClC,KAAK,mBAAmB,EACxB,KAAK,YAAY,EAClB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAIL,KAAK,uCAAuC,EAC5C,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAE3B,MAAM,cAAc,CAAA;AACrB,OAAO,EAAoC,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAA;A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M,2BAA2B,wCAAwC,CAAA;AAEhF,mFAAmF;AACnF,eAAO,MAAM,oCAAoC;;EAM/C,CAAA;AAkBF;;;GAGG;AACH,eAAO,MAAM,6BAA6B,8DAA+D,CAAA;AAsOzG;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE;IAC9C,IAAI,EAAE,YAAY,CAAA;IAClB,SAAS,EAAE,qBAAqB,CAAA;IAChC,wEAAwE;IACxE,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAC/B,GAAG,oBAAoB,EAAE,CA4BzB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,GAAG,SAAS,MAAM,EAAE,CAOnH;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,yBAAyB,GAAG;IAAE,GAAG,CAAC,EAAE,SAAS,CAAA;CAAE,GACvD,kBAAkB,CAAA;AACrB,wBAAgB,wBAAwB,CAAC,OAAO,EAC9C,OAAO,EAAE,yBAAyB,GAAG;IACnC,wFAAwF;IACxF,GAAG,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,OAAO,CAAA;CAC7C,GACA,OAAO,CAAA"}
@@ -31,6 +31,11 @@ const OPTION_KEYS = new Set([
31
31
  'environment',
32
32
  'projectRoot',
33
33
  ]);
34
+ /**
35
+ * Next's own device widths plus 1440 (3.18.0): a hero on a 1440 px screen gets a 1440 px file instead of a 1920 px one,
36
+ * about 40% fewer bytes (B1). A site's own `images.deviceSizes` replaces the list.
37
+ */
38
+ export const BRANDLAB_DEFAULT_DEVICE_SIZES = [640, 750, 828, 1080, 1200, 1440, 1920, 2048, 3840];
34
39
  const IMAGE_KEYS = new Set(['deviceSizes', 'imageSizes', 'qualities', 'minimumCacheTTL', 'remotePatterns', 'developmentRemotePatterns']);
35
40
  const REMOTE_PATTERN_KEYS = new Set(['protocol', 'hostname', 'port', 'pathname', 'search']);
36
41
  function assertKnownKeys(value, allowed, field, hint = '') {
@@ -174,7 +179,7 @@ function buildImagesConfig(images, productionBuild) {
174
179
  : [...(remotePatterns ?? []), ...developmentRemotePatterns];
175
180
  return {
176
181
  formats: ['image/webp'],
177
- ...(deviceSizes ? { deviceSizes } : {}),
182
+ deviceSizes: deviceSizes ?? [...BRANDLAB_DEFAULT_DEVICE_SIZES],
178
183
  ...(imageSizes ? { imageSizes } : {}),
179
184
  ...(qualities ? { qualities } : {}),
180
185
  ...(images.minimumCacheTTL !== undefined ? { minimumCacheTTL: images.minimumCacheTTL } : {}),