@enhance-eng/sdk 0.1.161 → 0.1.166

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.
@@ -37,8 +37,10 @@ var __enhance_capture_kernel__ = (function(exports) {
37
37
  };
38
38
  //#endregion
39
39
  //#region ../canvas-format/src/canvas-edit-support.lib.ts
40
- /** Why the API refused an operation, as a fixed value. Never the words of the refusal. */
40
+ /** Why the API refused a request or one of its operations, as a fixed value. Never its words. */
41
41
  const CANVAS_REFUSAL_CODES = [
42
+ "input-invalid",
43
+ "request-too-large",
42
44
  "appearance-unsupported-component",
43
45
  "styles-unsupported-component",
44
46
  "text-shadow-blend-unsupported",
@@ -347,6 +349,16 @@ var __enhance_capture_kernel__ = (function(exports) {
347
349
  if (document["version"] === LEGACY_CANVAS_FORMATS.v13 || document["version"] === LEGACY_CANVAS_FORMATS.v14) return adapted;
348
350
  return withoutTextShadowBlends(document["version"] === LEGACY_CANVAS_FORMATS.v12 ? adapted : adaptCanvasCss(adapted));
349
351
  };
352
+ const isSafeInteger = (value) => Number.isSafeInteger(value);
353
+ /** A format below 1 names no adaptation, so the walk below refuses it. */
354
+ const canvasWriterFormat = (version) => {
355
+ if (!isSafeInteger(version)) return "refused";
356
+ if (version > 15) return "ahead";
357
+ if (version === 15) return "current";
358
+ const adaptations = new Map(Object.entries(LEGACY_CANVAS_ADAPTATIONS).map(([format, kind]) => [Number(format), kind]));
359
+ for (let format = version; format < 15; format += 1) if (adaptations.get(format) !== "format-number") return "refused";
360
+ return "number-only";
361
+ };
350
362
  //#endregion
351
363
  //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/core.js
352
364
  var _a$1;
@@ -483,7 +495,7 @@ var __enhance_capture_kernel__ = (function(exports) {
483
495
  return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
484
496
  }
485
497
  const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
486
- function isObject$3(data) {
498
+ function isObject$6(data) {
487
499
  return typeof data === "object" && data !== null && !Array.isArray(data);
488
500
  }
489
501
  const allowsEval = /* @__PURE__*/ cached(() => {
@@ -497,12 +509,12 @@ var __enhance_capture_kernel__ = (function(exports) {
497
509
  }
498
510
  });
499
511
  function isPlainObject(o) {
500
- if (isObject$3(o) === false) return false;
512
+ if (isObject$6(o) === false) return false;
501
513
  const ctor = o.constructor;
502
514
  if (ctor === void 0) return true;
503
515
  if (typeof ctor !== "function") return true;
504
516
  const prot = ctor.prototype;
505
- if (isObject$3(prot) === false) return false;
517
+ if (isObject$6(prot) === false) return false;
506
518
  if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) return false;
507
519
  return true;
508
520
  }
@@ -1940,7 +1952,7 @@ var __enhance_capture_kernel__ = (function(exports) {
1940
1952
  }
1941
1953
  return propValues;
1942
1954
  });
1943
- const isObject = isObject$3;
1955
+ const isObject = isObject$6;
1944
1956
  const catchall = def.catchall;
1945
1957
  let value;
1946
1958
  inst._zod.parse = (payload, ctx) => {
@@ -2069,7 +2081,7 @@ var __enhance_capture_kernel__ = (function(exports) {
2069
2081
  return (payload, ctx) => fn(shape, payload, ctx);
2070
2082
  };
2071
2083
  let fastpass;
2072
- const isObject = isObject$3;
2084
+ const isObject = isObject$6;
2073
2085
  const jit = !globalConfig.jitless;
2074
2086
  const fastEnabled = jit && allowsEval.value;
2075
2087
  const catchall = def.catchall;
@@ -2181,7 +2193,7 @@ var __enhance_capture_kernel__ = (function(exports) {
2181
2193
  });
2182
2194
  inst._zod.parse = (payload, ctx) => {
2183
2195
  const input = payload.value;
2184
- if (!isObject$3(input)) {
2196
+ if (!isObject$6(input)) {
2185
2197
  payload.issues.push({
2186
2198
  code: "invalid_type",
2187
2199
  expected: "object",
@@ -4920,6 +4932,86 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4920
4932
  function number$1(params) {
4921
4933
  return /* @__PURE__ */ _coercedNumber(ZodNumber, params);
4922
4934
  }
4935
+ const objectPictureSizeSchema = _enum$1(["quarter", "sixteenth"]);
4936
+ /** One stored picture of one top layer. */
4937
+ const canvasObjectPictureSchema = strictObject({
4938
+ objectId: string$1().min(1),
4939
+ size: objectPictureSizeSchema,
4940
+ /** Where the picture's bytes are; what it answers with never changes. */
4941
+ url: string$1().min(1),
4942
+ width: number$2().int().positive(),
4943
+ height: number$2().int().positive(),
4944
+ /** The canvas version the picture was drawn at. */
4945
+ drawnVersion: number$2().int().nonnegative(),
4946
+ /** Whether the top layer is unchanged since the picture was drawn. */
4947
+ isCurrent: boolean$1(),
4948
+ /**
4949
+ * The font size, in pixels, that set the most characters of the top layer's texts when it was
4950
+ * drawn; left out where it held no text, or for a picture drawn before sizes were kept.
4951
+ */
4952
+ textSize: number$2().positive().optional()
4953
+ });
4954
+ strictObject({
4955
+ canvasId: uuid$1(),
4956
+ /** Only pictures drawn after this version; every picture when left out. */
4957
+ sinceVersion: number$2().int().nonnegative().optional()
4958
+ });
4959
+ object$1({ pictures: array$1(canvasObjectPictureSchema) });
4960
+ strictObject({
4961
+ canvasId: uuid$1(),
4962
+ objectIds: array$1(string$1().min(1)).min(1).max(200)
4963
+ });
4964
+ object$1({ scheduled: number$2().int().nonnegative() });
4965
+ const MAX_PICTURE_STORAGE_KEY_LENGTH = 500;
4966
+ const MAX_PICTURE_FAILURE_LENGTH = 500;
4967
+ /** One top layer a picture job is to draw, with when it was last put on the list. */
4968
+ const objectPictureWorkObjectSchema = object$1({
4969
+ objectId: string$1().min(1),
4970
+ wantedAt: datetime()
4971
+ });
4972
+ /** One picture a job drew and uploaded, in pixels of the stored picture. */
4973
+ const drawnObjectPictureSchema = object$1({
4974
+ size: objectPictureSizeSchema,
4975
+ width: number$2().int().positive(),
4976
+ height: number$2().int().positive(),
4977
+ bytes: number$2().int().positive(),
4978
+ storageKey: string$1().min(1).max(MAX_PICTURE_STORAGE_KEY_LENGTH),
4979
+ /** The text size of the top layer the page drew, as the list of pictures gives it. */
4980
+ textSize: number$2().positive().optional()
4981
+ });
4982
+ object$1({
4983
+ jobId: uuid$1(),
4984
+ loadedVersion: number$2().int().positive(),
4985
+ drawn: array$1(objectPictureWorkObjectSchema.extend({ pictures: array$1(drawnObjectPictureSchema).length(2) })).max(20),
4986
+ failed: array$1(object$1({
4987
+ objectId: string$1().min(1),
4988
+ message: string$1().min(1).max(MAX_PICTURE_FAILURE_LENGTH)
4989
+ })).max(20)
4990
+ });
4991
+ const coordinate$1 = number$2();
4992
+ const extent = number$2().nonnegative();
4993
+ /** A box in page coordinates. */
4994
+ const canvasOutlineBoxSchema = strictObject({
4995
+ x: coordinate$1,
4996
+ y: coordinate$1,
4997
+ width: extent,
4998
+ height: extent
4999
+ });
5000
+ /** What a browser measured of one top layer: its own box, and how far its descendants paint. */
5001
+ const canvasOutlineMeasurementSchema = strictObject({
5002
+ objectId: string$1().min(1),
5003
+ box: canvasOutlineBoxSchema,
5004
+ reach: canvasOutlineBoxSchema
5005
+ });
5006
+ strictObject({
5007
+ canvasId: uuid$1(),
5008
+ /** The revision of the document the browser had laid out when it measured. */
5009
+ version: number$2().int().positive(),
5010
+ measurements: array$1(canvasOutlineMeasurementSchema).min(1).max(200)
5011
+ });
5012
+ object$1({ stored: number$2().int().nonnegative() });
5013
+ strictObject({ canvasId: uuid$1() });
5014
+ object$1({ measurements: array$1(canvasOutlineMeasurementSchema.extend({ measuredVersion: number$2().int().nonnegative() })) });
4923
5015
  strictObject({});
4924
5016
  object$1({ firstAgentWorkAt: datetime().nullable() });
4925
5017
  /** Cursor pagination, defined once so no endpoint invents its own page shape. */
@@ -5028,13 +5120,18 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5028
5120
  createdAt: datetime(),
5029
5121
  lastActivityAt: datetime()
5030
5122
  });
5123
+ /**
5124
+ * A canvas with its full web address, which only the API can write: it is built from the web
5125
+ * address of the API's own environment, so a reader never joins an id to a host.
5126
+ */
5127
+ const linkedCanvasSchema = canvasSchema.extend({ url: url() });
5031
5128
  object$1({
5032
5129
  title: string$1().trim().min(1),
5033
5130
  /** The team to file it under, or null for the maker's own. Refused for one you are not on. */
5034
5131
  organisationId: uuid$1().nullable().default(null),
5035
5132
  sourceUrl: string$1().nullable().default(null)
5036
5133
  });
5037
- canvasSchema.extend({ version: number$2().int().positive() });
5134
+ linkedCanvasSchema.extend({ version: number$2().int().positive() });
5038
5135
  object$1({ canvasId: uuid$1() });
5039
5136
  object$1({
5040
5137
  collection: union$1([
@@ -5053,7 +5150,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5053
5150
  ]).default("all"),
5054
5151
  hasUnresolved: boolean$1().default(false)
5055
5152
  });
5056
- const canvasCardBaseSchema = canvasSchema.extend({
5153
+ const canvasCardBaseSchema = linkedCanvasSchema.extend({
5057
5154
  screenCount: number$2().int().min(0),
5058
5155
  hasRecording: boolean$1(),
5059
5156
  /** When the person listing last opened it in the web app; `null` if they never have. */
@@ -5493,6 +5590,11 @@ progression: object$1({
5493
5590
  clipContent: boolean$1().optional(),
5494
5591
  baselineSource: canvasBaselineSourceSchema.optional(),
5495
5592
  scrollbarGutter: canvasScrollbarGutterSchema.optional(),
5593
+ /**
5594
+ * The frame holds an embedded document. Chromium sizes that document's viewport in whole
5595
+ * pixels, rounding the frame's content box up, so what the frame holds resolves against that.
5596
+ */
5597
+ embeddedDocument: literal$1(true).optional(),
5496
5598
  container: canvasFlexLayoutSchema.partial().extend({ padding: canvasFlexPaddingSchema.partial().optional() }).optional()
5497
5599
  }).strict();
5498
5600
  //#endregion
@@ -5563,7 +5665,9 @@ progression: object$1({
5563
5665
  ]),
5564
5666
  paints: array$1(canvasPaintSchema),
5565
5667
  dashPattern: canvasDashPatternSchema.optional(),
5566
- dashCap: canvasDashCapSchema.optional()
5668
+ dashCap: canvasDashCapSchema.optional(),
5669
+ /** Captured CSS dashes, which the browser draws, as for a border. */
5670
+ dashOrigin: literal$1("css").optional()
5567
5671
  });
5568
5672
  const canvasShadowSchema = object$1({
5569
5673
  id: itemId,
@@ -6037,13 +6141,13 @@ progression: object$1({
6037
6141
  }).refine((asset) => asset.state === "ready" === (asset.metadata !== null), "Readiness must match verified metadata.").refine((asset) => asset.metadata === null || asset.metadata.kind === asset.kind, "Metadata must describe the reserved asset kind.").refine((asset) => isStoredContentType(asset.kind, asset.contentType), "Content type must match the asset kind.").refine((asset) => asset.path === (asset.kind === "image" ? canvasImageAssetPath(asset.canvasId, asset.assetId) : canvasFontAssetPath(asset.canvasId, asset.sha256)), "The resource path must match its native identity.").safeExtend({ upload: signedUploadSchema.nullable() }).refine((asset) => asset.state === "awaiting_upload" === (asset.upload !== null), "Only pending uploads receive upload access.");
6038
6142
  //#endregion
6039
6143
  //#region ../contract/src/canvas/canvas-css-values.lib.ts
6040
- const SIDES = [
6144
+ const SIDES$1 = [
6041
6145
  "top",
6042
6146
  "right",
6043
6147
  "bottom",
6044
6148
  "left"
6045
6149
  ];
6046
- SIDES.map((side) => `padding-${side}`), SIDES.map((side) => `margin-${side}`);
6150
+ SIDES$1.map((side) => `padding-${side}`), SIDES$1.map((side) => `margin-${side}`);
6047
6151
  //#endregion
6048
6152
  //#region ../contract/src/canvas/canvas-export-settings.schema.ts
6049
6153
  const format = _enum$1(["png", "jpeg"]);
@@ -6122,7 +6226,34 @@ progression: object$1({
6122
6226
  //#endregion
6123
6227
  //#region ../contract/src/canvas/canvas-scene.schema.ts
6124
6228
  const CANVAS_COMPOSITING_RETIRED = "Update Enhance: compositing is no longer supported. Use the isolation style or a mask group.";
6125
- const canvasDocumentFormatSchema = literal$1(15, { error: "This editor uses an unsupported document format. Update the editor before changing this canvas." });
6229
+ const CANVAS_FORMAT_UPDATE_REQUIRED = "This change needs a newer version of Enhance. Refresh the editor, or update the Enhance plugin or command-line tool, then try again.";
6230
+ const CANVAS_FORMAT_SERVER_UPDATING = "Enhance is being updated. Try again in a minute.";
6231
+ /** Marks an issue whose message was written for whoever sent the request, so the API keeps it. */
6232
+ const FOR_CALLER = { forCaller: true };
6233
+ /**
6234
+ * The format a writer was built for, as a plain whole number so tool schemas can describe it. Which
6235
+ * writes that format may make is `refuseUnsafeWriterFormat`'s call.
6236
+ */
6237
+ const canvasDocumentFormatSchema = number$2({ error: CANVAS_FORMAT_UPDATE_REQUIRED }).int({ error: CANVAS_FORMAT_UPDATE_REQUIRED }).positive({ error: CANVAS_FORMAT_UPDATE_REQUIRED }).meta({
6238
+ description: `The document format this client writes. The current format is ${String(15)}.`,
6239
+ examples: [15]
6240
+ });
6241
+ /**
6242
+ * Refuses a write its client's format could get wrong. A client whose format differs from the
6243
+ * current one only in its number may still name changes, but a whole value it sends may lack
6244
+ * fields added since, so that needs the current format.
6245
+ */
6246
+ const refuseUnsafeWriterFormat = (documentFormatVersion, writes, context) => {
6247
+ const writer = canvasWriterFormat(documentFormatVersion);
6248
+ if (writer === "current" || writer === "number-only" && writes === "names") return;
6249
+ context.addIssue({
6250
+ code: "custom",
6251
+ path: ["documentFormatVersion"],
6252
+ message: writer === "ahead" ? CANVAS_FORMAT_SERVER_UPDATING : CANVAS_FORMAT_UPDATE_REQUIRED,
6253
+ params: FOR_CALLER,
6254
+ input: documentFormatVersion
6255
+ });
6256
+ };
6126
6257
  object$1({
6127
6258
  signature: string$1().regex(/^[a-f0-9]{16}$/u),
6128
6259
  /** The captured picture of the page's text, inline as written or as its canvas image store path. */
@@ -6172,13 +6303,14 @@ progression: object$1({
6172
6303
  props: record(string$1(), unknown()).optional(),
6173
6304
  box: canvasSceneBoxSchema.optional()
6174
6305
  });
6306
+ const canvasSceneRelationshipSchema = object$1({
6307
+ parentId: string$1().min(1),
6308
+ sortKey: string$1().min(1)
6309
+ });
6175
6310
  const canvasSceneDocumentSchema = object$1({
6176
6311
  version: literal$1(15),
6177
6312
  nodes: record(string$1(), canvasSceneNodeSchema),
6178
- relationships: record(string$1(), object$1({
6179
- parentId: string$1().min(1),
6180
- sortKey: string$1().min(1)
6181
- })),
6313
+ relationships: record(string$1(), canvasSceneRelationshipSchema),
6182
6314
  tombstones: record(string$1(), literal$1(true)).default({})
6183
6315
  });
6184
6316
  const legacyRecordSchema = record(string$1(), unknown());
@@ -6202,6 +6334,10 @@ progression: object$1({
6202
6334
  relationships: {},
6203
6335
  tombstones: {}
6204
6336
  });
6337
+ canvasSceneDocumentSchema.extend({
6338
+ nodes: record(string$1(), unknown()),
6339
+ relationships: record(string$1(), unknown())
6340
+ });
6205
6341
  //#endregion
6206
6342
  //#region ../contract/src/canvas/canvas-conversion-draft.schema.ts
6207
6343
  const temporaryIdSchema = string$1().min(1);
@@ -6239,7 +6375,8 @@ progression: object$1({
6239
6375
  "image-shadows",
6240
6376
  "effect-noise",
6241
6377
  "effect-texture",
6242
- "effect-glass"
6378
+ "effect-glass",
6379
+ "mask-source"
6243
6380
  ]);
6244
6381
  const canvasConversionReportSchema = object$1({
6245
6382
  nodeCount: number$2().int().positive(),
@@ -6284,7 +6421,8 @@ progression: object$1({
6284
6421
  /** A capture that lands as a new editable frame on a page, with no screen layer. */
6285
6422
  const editableFrameCaptureSchema = object$1({
6286
6423
  screenId: string$1().min(1),
6287
- pageId: string$1().min(1)
6424
+ pageId: string$1().min(1),
6425
+ pictureNodeId: string$1().min(1).optional().describe("The capture's picture, which the frame replaces in place and whose id it keeps. Refused as capture-already-landed once the picture is a frame.")
6288
6426
  });
6289
6427
  const editableFrameInputBase = {
6290
6428
  canvasId: uuid$1(),
@@ -6299,7 +6437,9 @@ progression: object$1({
6299
6437
  }), strictObject({
6300
6438
  ...editableFrameInputBase,
6301
6439
  capture: editableFrameCaptureSchema.describe("The stored page a new capture lands from, and the page its frame goes on.")
6302
- })]);
6440
+ })]).superRefine((input, context) => {
6441
+ refuseUnsafeWriterFormat(input.documentFormatVersion, "whole", context);
6442
+ });
6303
6443
  const createEditableFrameResultSchema = object$1({
6304
6444
  canvasId: uuid$1(),
6305
6445
  mutationId: uuid$1(),
@@ -6362,7 +6502,8 @@ progression: object$1({
6362
6502
  "LOCAL_FONT_FALLBACK",
6363
6503
  "SOURCE_FALLBACK",
6364
6504
  "SCALE_REDUCED",
6365
- "LAYOUT_FALLBACK"
6505
+ "LAYOUT_FALLBACK",
6506
+ "DRAWN_APPROXIMATELY"
6366
6507
  ];
6367
6508
  //#endregion
6368
6509
  //#region ../contract/src/canvas/canvas-render.schema.ts
@@ -6604,7 +6745,12 @@ progression: object$1({
6604
6745
  }),
6605
6746
  object$1({
6606
6747
  kind: literal$1("replace"),
6607
- targetNodeId: string$1().min(1)
6748
+ targetNodeId: string$1().min(1),
6749
+ /**
6750
+ * A capture's swap: the target must still be the capture's picture. When another browser has
6751
+ * already made it editable, the swap is refused as `capture-already-landed`.
6752
+ */
6753
+ onlyPicture: literal$1(true).optional()
6608
6754
  })
6609
6755
  ]);
6610
6756
  const canvasConversionRequestSchema = object$1({
@@ -7336,7 +7482,7 @@ progression: object$1({
7336
7482
  removedText: record(nodeIdSchema$3, canvasSceneNodeSchema.pick({ props: true })).optional()
7337
7483
  })
7338
7484
  ]);
7339
- /** An older client's compositing write is refused with the CSS that replaces it. */
7485
+ currentCanvasOperationSchema.options;
7340
7486
  /** Each operation's name, for records that may state which kind failed and nothing else. */
7341
7487
  const CANVAS_OPERATION_NAMES = currentCanvasOperationSchema.options.map((option) => option.shape.op.value);
7342
7488
  const canvasOperationSchema = preprocess((value, context) => {
@@ -7390,13 +7536,16 @@ progression: object$1({
7390
7536
  /** Null while the blob has not landed. The client draws an empty frame with its label. */
7391
7537
  download: signedDownloadSchema.nullable()
7392
7538
  });
7539
+ const canvasMutationRevisionSchema = object$1({
7540
+ mutationId: uuid$1(),
7541
+ previousVersion: number$2().int().positive(),
7542
+ version: number$2().int().positive(),
7543
+ operations: array$1(canvasOperationSchema)
7544
+ });
7393
7545
  object$1({
7394
- mutations: array$1(object$1({
7395
- mutationId: uuid$1(),
7396
- previousVersion: number$2().int().positive(),
7397
- version: number$2().int().positive(),
7398
- operations: array$1(canvasOperationSchema)
7399
- })).optional(),
7546
+ /** The canvas's web address. An API older than the field answers without it. */
7547
+ url: url().optional(),
7548
+ mutations: array$1(canvasMutationRevisionSchema).optional(),
7400
7549
  version: number$2().int().min(1),
7401
7550
  /**
7402
7551
  * The revision the latest restore made, when there has been one. A reader at an older revision
@@ -7428,6 +7577,143 @@ progression: object$1({
7428
7577
  document: canvasDocumentBlobSchema
7429
7578
  })]);
7430
7579
  //#endregion
7580
+ //#region ../contract/src/canvas/canvas-document-parts.schema.ts
7581
+ /** One answer stops taking top layers once it holds this many layers, unless it is asked for more. */
7582
+ const CANVAS_PART_LAYER_LIMIT = 5e3;
7583
+ /** The most layers a read of parts may ask one answer to hold before it stops. */
7584
+ const CANVAS_PART_LAYER_LIMIT_MAX = 1e5;
7585
+ /** The most identifiers one read of parts may name in each list. */
7586
+ const CANVAS_PART_NAMED_LIMIT = 2e3;
7587
+ strictObject({ canvasId: uuid$1() });
7588
+ /** The font files a layer inside a top layer declares, without the rest of the layer. */
7589
+ const canvasFontDeclarationSchema = object$1({
7590
+ layerId: string$1(),
7591
+ /** The child of the root that holds the layer. */
7592
+ topLayerId: string$1(),
7593
+ fontFaces: array$1(unknown())
7594
+ });
7595
+ object$1({
7596
+ version: number$2().int().min(1),
7597
+ restoreFenceVersion: number$2().int().positive().optional(),
7598
+ /** The root and each child of the root, pages among them, and every removed-layer id. */
7599
+ document: canvasDocumentBlobSchema,
7600
+ screens: array$1(documentScreenSchema),
7601
+ /** Whether the canvas holds more than `LARGE_PAGE_LAYERS` layers, every page counted. */
7602
+ isLarge: boolean$1(),
7603
+ fontDeclarations: array$1(canvasFontDeclarationSchema)
7604
+ });
7605
+ const namedIds = array$1(string$1().min(1)).max(CANVAS_PART_NAMED_LIMIT);
7606
+ strictObject({
7607
+ canvasId: uuid$1(),
7608
+ /** Children of the root, answered in this order. */
7609
+ topLayerIds: namedIds.optional(),
7610
+ /** Layers anywhere; each is answered with the whole top layer that holds it. */
7611
+ layerIds: namedIds.optional(),
7612
+ /**
7613
+ * The layers after which the answer takes no further top layer. An editor raises it on a very
7614
+ * large canvas, so the whole canvas arrives in a bounded number of answers.
7615
+ */
7616
+ maxLayers: number$2().int().min(CANVAS_PART_LAYER_LIMIT).max(CANVAS_PART_LAYER_LIMIT_MAX).default(CANVAS_PART_LAYER_LIMIT)
7617
+ }).refine(({ topLayerIds = [], layerIds = [] }) => topLayerIds.length + layerIds.length > 0, "A read of parts names at least one layer.");
7618
+ object$1({
7619
+ /** The revision every layer of the answer was read at. */
7620
+ version: number$2().int().min(1),
7621
+ /** Each answered top layer's own record and every layer inside it: no root, no removed ids. */
7622
+ document: canvasDocumentBlobSchema,
7623
+ /** The top layers answered, in the order asked. */
7624
+ read: array$1(string$1()),
7625
+ /** The top layers left out because the answer was full, in the order asked. */
7626
+ notReached: array$1(string$1()),
7627
+ /** The named identifiers that are no top layer of the canvas, or are inside none. */
7628
+ absent: array$1(string$1())
7629
+ });
7630
+ //#endregion
7631
+ //#region ../contract/src/canvas/canvas-first-letter.lib.ts
7632
+ /** Custom CSS on a text layer that styles its first letter, one declaration per property. */
7633
+ const CANVAS_FIRST_LETTER_PREFIX = "--canvas-first-letter-";
7634
+ const SIDES = [
7635
+ "top",
7636
+ "right",
7637
+ "bottom",
7638
+ "left"
7639
+ ];
7640
+ /**
7641
+ * The properties a first letter takes (CSS Pseudo-Elements 4, `::first-letter`), each with the
7642
+ * value it has when a layer does not declare it: its block's for a property that inherits, the
7643
+ * initial value for one that does not.
7644
+ */
7645
+ const CANVAS_FIRST_LETTER_PROPERTIES = {
7646
+ ...Object.fromEntries([
7647
+ "color",
7648
+ "font-family",
7649
+ "font-size",
7650
+ "font-stretch",
7651
+ "font-style",
7652
+ "font-weight",
7653
+ "font-variant-caps",
7654
+ "font-variant-ligatures",
7655
+ "font-variant-numeric",
7656
+ "font-feature-settings",
7657
+ "font-variation-settings",
7658
+ "font-kerning",
7659
+ "letter-spacing",
7660
+ "line-height",
7661
+ "text-shadow",
7662
+ "text-transform",
7663
+ "word-spacing",
7664
+ "-webkit-text-fill-color",
7665
+ "-webkit-text-stroke-color",
7666
+ "-webkit-text-stroke-width"
7667
+ ].map((property) => [property, "inherit"])),
7668
+ ...Object.fromEntries([
7669
+ "float",
7670
+ "vertical-align",
7671
+ "initial-letter",
7672
+ "opacity",
7673
+ "background-color",
7674
+ "background-image",
7675
+ "box-shadow",
7676
+ "text-decoration-line",
7677
+ "text-decoration-style",
7678
+ "text-decoration-color",
7679
+ "text-decoration-thickness",
7680
+ ...SIDES.flatMap((side) => [
7681
+ `margin-${side}`,
7682
+ `padding-${side}`,
7683
+ `border-${side}-style`,
7684
+ `border-${side}-width`,
7685
+ `border-${side}-color`
7686
+ ]),
7687
+ ...[
7688
+ "top-left",
7689
+ "top-right",
7690
+ "bottom-right",
7691
+ "bottom-left"
7692
+ ].map((corner) => `border-${corner}-radius`)
7693
+ ].map((property) => [property, "initial"]))
7694
+ };
7695
+ `${Object.entries(CANVAS_FIRST_LETTER_PROPERTIES).map(([property, fallback]) => `${property}:var(${CANVAS_FIRST_LETTER_PREFIX}${property},${fallback})`).join(";")}`;
7696
+ //#endregion
7697
+ //#region ../contract/src/canvas/canvas-font-family.lib.ts
7698
+ const GENERIC_FAMILIES = /* @__PURE__ */ new Set([
7699
+ "-apple-system",
7700
+ "blinkmacsystemfont",
7701
+ "cursive",
7702
+ "emoji",
7703
+ "fantasy",
7704
+ "fangsong",
7705
+ "math",
7706
+ "monospace",
7707
+ "sans-serif",
7708
+ "serif",
7709
+ "system-ui",
7710
+ "ui-monospace",
7711
+ "ui-rounded",
7712
+ "ui-sans-serif",
7713
+ "ui-serif"
7714
+ ]);
7715
+ const isCanvasGenericFontFamily = (family) => GENERIC_FAMILIES.has(family.toLowerCase());
7716
+ //#endregion
7431
7717
  //#region ../contract/src/canvas/canvas-text-content.lib.ts
7432
7718
  const textLinkSchema = object$1({
7433
7719
  start: number$2().int().nonnegative(),
@@ -7459,13 +7745,30 @@ progression: object$1({
7459
7745
  "export",
7460
7746
  "source"
7461
7747
  ]);
7748
+ //#endregion
7749
+ //#region ../contract/src/canvas/canvas-inspection.schema.ts
7750
+ const MAX_RENDER_MESSAGE_LENGTH = 500;
7751
+ const MAX_RENDER_KIND_LENGTH = 100;
7752
+ /**
7753
+ * What a layer's box is: `placed` where the canvas draws the layer, `placed-before-transform` where
7754
+ * it draws the layer before the layer's own transform, `recorded` a size kept from when the layer
7755
+ * was made, for a layer the browser lays out.
7756
+ */
7757
+ const canvasBoxSourceSchema = _enum$1([
7758
+ "placed",
7759
+ "placed-before-transform",
7760
+ "recorded"
7761
+ ]);
7762
+ /** Present only on a read that holds a `recorded` box. */
7763
+ const boxNoteSchema = string$1().min(1).optional();
7462
7764
  const canvasInspectNodeSummarySchema = object$1({
7463
7765
  id: string$1().min(1),
7464
- label: string$1().max(500),
7465
- kind: string$1().min(1).max(100),
7766
+ label: string$1().max(MAX_RENDER_MESSAGE_LENGTH),
7767
+ kind: string$1().min(1).max(MAX_RENDER_KIND_LENGTH),
7466
7768
  parentId: string$1().min(1).nullable(),
7467
7769
  childCount: number$2().int().min(0),
7468
7770
  box: canvasSceneBoxSchema.nullable(),
7771
+ boxSource: canvasBoxSourceSchema.optional(),
7469
7772
  propertySections: array$1(canvasPropertySectionSchema)
7470
7773
  });
7471
7774
  object$1({ canvasId: uuid$1() });
@@ -7478,13 +7781,15 @@ progression: object$1({
7478
7781
  rootChildCount: number$2().int().min(0),
7479
7782
  bounds: canvasSceneBoxSchema.nullable(),
7480
7783
  kinds: record(string$1(), number$2().int().min(0)),
7784
+ boxNote: boxNoteSchema,
7481
7785
  next: array$1(string$1().min(1))
7482
7786
  });
7483
7787
  object$1({ canvasId: uuid$1() });
7484
7788
  object$1({
7485
7789
  canvasId: uuid$1(),
7486
7790
  version: number$2().int().positive(),
7487
- nodes: array$1(canvasInspectNodeSummarySchema)
7791
+ nodes: array$1(canvasInspectNodeSummarySchema),
7792
+ boxNote: boxNoteSchema
7488
7793
  });
7489
7794
  object$1({
7490
7795
  canvasId: uuid$1(),
@@ -7503,9 +7808,49 @@ progression: object$1({
7503
7808
  props: record(string$1(), unknown()),
7504
7809
  children: array$1(string$1().min(1))
7505
7810
  }),
7811
+ boxNote: boxNoteSchema,
7506
7812
  next: array$1(string$1().min(1))
7507
7813
  });
7508
7814
  //#endregion
7815
+ //#region ../contract/src/canvas/canvas-operation-writes.schema.ts
7816
+ /**
7817
+ * What each operation writes. `names` sets one plain value, places, removes, or merges a patch, so
7818
+ * values its client never knew stay as stored. `whole` brings a whole layer or replaces a whole
7819
+ * group of values, which a client that read the canvas in an older format may have stripped.
7820
+ */
7821
+ const CANVAS_OPERATION_WRITES = {
7822
+ insertConvertedSubtree: "whole",
7823
+ insertNode: "whole",
7824
+ insertText: "names",
7825
+ insertPrototype: "names",
7826
+ setPrototypeDeployment: "names",
7827
+ editText: "names",
7828
+ setText: "names",
7829
+ setBox: "names",
7830
+ setLabel: "names",
7831
+ setContainerKind: "names",
7832
+ setVisibility: "names",
7833
+ setLocked: "names",
7834
+ setConstraints: "names",
7835
+ setStyles: "names",
7836
+ patchExportSettings: "names",
7837
+ setAppearance: "names",
7838
+ setLayout: "whole",
7839
+ patchTypography: "names",
7840
+ setTypography: "whole",
7841
+ patchAdditionalStyles: "names",
7842
+ setAdditionalStyles: "whole",
7843
+ setArtworkColor: "whole",
7844
+ setTextStyleLibrary: "whole",
7845
+ patchFontLibrary: "names",
7846
+ setTextStyle: "whole",
7847
+ setGeometry: "whole",
7848
+ setProps: "whole",
7849
+ setParentage: "names",
7850
+ move: "names",
7851
+ remove: "names"
7852
+ };
7853
+ //#endregion
7509
7854
  //#region ../contract/src/canvas/canvas-mutation.schema.ts
7510
7855
  const nodeIdSchema$2 = canvasSceneNodeSchema.shape.id;
7511
7856
  const writableBoxSchema = canvasSceneBoxSchema.extend({
@@ -7513,6 +7858,8 @@ progression: object$1({
7513
7858
  height: number$2().positive()
7514
7859
  });
7515
7860
  const copiedNodeIdsSchema = record(nodeIdSchema$2, nodeIdSchema$2);
7861
+ /** A receipt stored before boxes said what they are holds none, so the source stays optional. */
7862
+ const canvasReceiptBoxSchema = canvasSceneBoxSchema.extend({ boxSource: canvasBoxSourceSchema.optional() });
7516
7863
  const canvasMutationRequestContextSchema = strictObject({
7517
7864
  fingerprint: string$1().regex(/^[a-f0-9]{64}$/u),
7518
7865
  revisionPolicy: _enum$1(["strict", "rebase"]),
@@ -7526,6 +7873,8 @@ progression: object$1({
7526
7873
  operations: array$1(canvasOperationSchema).min(1),
7527
7874
  requestContext: canvasMutationRequestContextSchema.optional(),
7528
7875
  writeScope: canvasWriteScopeSchema.optional()
7876
+ }).superRefine((input, context) => {
7877
+ refuseUnsafeWriterFormat(input.documentFormatVersion, input.operations.every((operation) => CANVAS_OPERATION_WRITES[operation.op] === "names") ? "names" : "whole", context);
7529
7878
  });
7530
7879
  const applyCanvasOperationsOutputSchema = object$1({
7531
7880
  canvasId: uuid$1(),
@@ -7536,7 +7885,7 @@ progression: object$1({
7536
7885
  insertedNodeIds: array$1(nodeIdSchema$2),
7537
7886
  changedNodeIds: array$1(nodeIdSchema$2),
7538
7887
  removedNodeIds: array$1(nodeIdSchema$2),
7539
- boxes: record(nodeIdSchema$2, canvasSceneBoxSchema),
7888
+ boxes: record(nodeIdSchema$2, canvasReceiptBoxSchema),
7540
7889
  affectedBounds: writableBoxSchema.nullable(),
7541
7890
  copiedNodeIds: copiedNodeIdsSchema.optional(),
7542
7891
  next: array$1(string$1().min(1))
@@ -7548,7 +7897,8 @@ progression: object$1({
7548
7897
  });
7549
7898
  discriminatedUnion$1("state", [strictObject({ state: literal$1("not-found") }), strictObject({
7550
7899
  state: literal$1("committed"),
7551
- result: applyCanvasOperationsOutputSchema
7900
+ /** `url` is the canvas's web address. An API older than the field answers without it. */
7901
+ result: applyCanvasOperationsOutputSchema.extend({ url: url().optional() })
7552
7902
  })]);
7553
7903
  //#endregion
7554
7904
  //#region ../contract/src/canvas/canvas-mutation-review.schema.ts
@@ -7951,8 +8301,10 @@ progression: object$1({
7951
8301
  sources: array$1(strictObject({
7952
8302
  screenId: uuid$1(),
7953
8303
  captureId: uuid$1(),
7954
- label: string$1().min(1)
7955
- })).min(1)
8304
+ /** What the frame is called. Absent, the frame takes the stored page's own title. */
8305
+ label: string$1().min(1).optional()
8306
+ })).min(1),
8307
+ landing: literal$1("editable-frame").optional().describe("Lands the page as an ordinary editable frame. Without it, the layers belong to a capture run.")
7956
8308
  }),
7957
8309
  canvasArrangePreparationSchema,
7958
8310
  canvasDuplicatePreparationSchema,
@@ -8033,7 +8385,11 @@ progression: object$1({
8033
8385
  job.extend({
8034
8386
  state: literal$1("succeeded"),
8035
8387
  phase: literal$1("complete"),
8036
- result: canvasPreparationPlanSchema.extend({ loadedVersion: number$2().int().positive() }),
8388
+ result: canvasPreparationPlanSchema.extend({
8389
+ loadedVersion: number$2().int().positive(),
8390
+ /** Where a screen compile fell back, such as a font it replaced; absent when it had none. */
8391
+ warnings: array$1(canvasRenderWarningSchema).optional()
8392
+ }),
8037
8393
  failure: _null()
8038
8394
  }),
8039
8395
  job.extend({
@@ -8422,7 +8778,8 @@ progression: object$1({
8422
8778
  "inspection",
8423
8779
  "snapshot",
8424
8780
  "thumbnail",
8425
- "export"
8781
+ "export",
8782
+ "object-pictures"
8426
8783
  ]),
8427
8784
  scale: number$2().positive(),
8428
8785
  maxOutputPixels: canvasRenderPixelLimitSchema.optional(),
@@ -8493,6 +8850,16 @@ progression: object$1({
8493
8850
  sourceState: _undefined().optional(),
8494
8851
  conversion: canvasConversionRequestSchema,
8495
8852
  scale: literal$1(1)
8853
+ }),
8854
+ claimRenderWorkBaseSchema.extend({
8855
+ purpose: literal$1("object-pictures"),
8856
+ target: canvasRenderTargetSchema,
8857
+ sourceState: _undefined().optional(),
8858
+ scale: number$2().positive(),
8859
+ maxOutputPixels: canvasRenderPixelLimitSchema.optional(),
8860
+ /** The top layers to draw, in order; each picture is stored under the prefix. */
8861
+ objects: array$1(objectPictureWorkObjectSchema).max(20),
8862
+ outputPrefix: string$1().min(1).max(MAX_STORAGE_KEY_LENGTH)
8496
8863
  })
8497
8864
  ]);
8498
8865
  object$1({
@@ -8639,6 +9006,7 @@ progression: object$1({
8639
9006
  nodes: array$1(canvasInspectNodeSummarySchema),
8640
9007
  contextRootId: nodeIdSchema.nullable(),
8641
9008
  visibleWorldBox: canvasWorldBoundsSchema.nullable(),
9009
+ boxNote: string$1().min(1).optional(),
8642
9010
  next: array$1(string$1().min(1)).max(MAX_SELECTION_COMMANDS)
8643
9011
  });
8644
9012
  //#endregion
@@ -8647,6 +9015,17 @@ progression: object$1({
8647
9015
  kind: literal$1("recording"),
8648
9016
  recordingId: string$1()
8649
9017
  })]);
9018
+ /**
9019
+ * The mark on a captured page's picture while it becomes editable. Every capture lands as this
9020
+ * picture first; whoever converts it replaces the same layer with the editable frame, through the
9021
+ * one swap (`insertConvertedSubtree` with destination `replace` and `onlyPicture`). A conversion
9022
+ * that fails writes `failed` with a short reason, so every viewer sees the failure rather than a
9023
+ * spinner that never ends; Try again writes `converting` again.
9024
+ */
9025
+ const captureLandingSchema = discriminatedUnion$1("state", [object$1({ state: literal$1("converting") }), object$1({
9026
+ state: literal$1("failed"),
9027
+ reason: string$1().min(1).max(200)
9028
+ })]);
8650
9029
  object$1({
8651
9030
  html: string$1().optional(),
8652
9031
  viewport: object$1({
@@ -8656,7 +9035,8 @@ progression: object$1({
8656
9035
  atMs: number$2(),
8657
9036
  screenId: string$1().nullable().default(null),
8658
9037
  sourceNodeId: string$1().optional(),
8659
- provenance: canvasCaptureProvenanceSchema.optional()
9038
+ provenance: canvasCaptureProvenanceSchema.optional(),
9039
+ landing: captureLandingSchema.optional()
8660
9040
  });
8661
9041
  object$1({
8662
9042
  provenance: canvasCaptureProvenanceSchema.optional(),
@@ -8784,12 +9164,16 @@ progression: object$1({
8784
9164
  versionId: uuid$1()
8785
9165
  });
8786
9166
  object$1({ entry: canvasVersionEntrySchema });
9167
+ /** A restore or a duplicate copies a version the API holds, so it only names what to change. */
9168
+ const refuseUnsafeVersionCopy = (input, context) => {
9169
+ refuseUnsafeWriterFormat(input.documentFormatVersion, "names", context);
9170
+ };
8787
9171
  object$1({
8788
9172
  canvasId: uuid$1(),
8789
9173
  documentFormatVersion: canvasDocumentFormatSchema,
8790
9174
  versionId: uuid$1(),
8791
9175
  expectedVersion: number$2().int().positive()
8792
- });
9176
+ }).superRefine(refuseUnsafeVersionCopy);
8793
9177
  object$1({
8794
9178
  canvasId: uuid$1(),
8795
9179
  version: number$2().int().positive(),
@@ -8803,7 +9187,7 @@ progression: object$1({
8803
9187
  versionId: uuid$1(),
8804
9188
  organisationId: union$1([uuid$1(), literal$1("personal")]),
8805
9189
  title: string$1().trim().min(1).optional()
8806
- });
9190
+ }).superRefine(refuseUnsafeVersionCopy);
8807
9191
  object$1({
8808
9192
  canvasId: uuid$1(),
8809
9193
  title: string$1().min(1),
@@ -9345,9 +9729,9 @@ progression: object$1({
9345
9729
  //#region ../contract/src/recording/frozen-screen.lib.ts
9346
9730
  const META_EVENT = 4;
9347
9731
  const FULL_SNAPSHOT$2 = 2;
9348
- const isObject$2 = (value) => typeof value === "object" && value !== null;
9349
- const isTimedEvent = (value, type) => isObject$2(value) && Reflect.get(value, "type") === type && typeof Reflect.get(value, "timestamp") === "number";
9350
- const isAnyTimedEvent = (value) => isObject$2(value) && typeof Reflect.get(value, "type") === "number" && typeof Reflect.get(value, "timestamp") === "number";
9732
+ const isObject$5 = (value) => typeof value === "object" && value !== null;
9733
+ const isTimedEvent = (value, type) => isObject$5(value) && Reflect.get(value, "type") === type && typeof Reflect.get(value, "timestamp") === "number";
9734
+ const isAnyTimedEvent = (value) => isObject$5(value) && typeof Reflect.get(value, "type") === "number" && typeof Reflect.get(value, "timestamp") === "number";
9351
9735
  /**
9352
9736
  * The durable form of one marked moment. It deliberately contains rrweb's serialized tree,
9353
9737
  * not HTML: reparsing `outerHTML` normalises the live DOM and can split working nested controls
@@ -9376,6 +9760,16 @@ progression: object$1({
9376
9760
  };
9377
9761
  return JSON.stringify(artifact);
9378
9762
  };
9763
+ object$1({ canvasId: uuid$1() });
9764
+ object$1({
9765
+ /** The only credential a page receives: it stores captures and does nothing else. */
9766
+ pass: string$1().min(1),
9767
+ expiresAt: datetime(),
9768
+ /** Where the capture script is published, for the snippet to load. */
9769
+ scriptUrl: url(),
9770
+ /** Where the page stores its capture: the API as the page reaches it. */
9771
+ apiUrl: url()
9772
+ });
9379
9773
  //#endregion
9380
9774
  //#region ../contract/src/comment/comment.schema.ts
9381
9775
  /** How many replies a thread hands back in one go before `hasMoreMessages` takes over. */
@@ -10669,6 +11063,12 @@ progression: object$1({
10669
11063
  version: number$2().int().positive()
10670
11064
  })]).optional()
10671
11065
  });
11066
+ object$1({ bytes: number$2().int().positive().max(Number.MAX_SAFE_INTEGER) });
11067
+ object$1({
11068
+ id: uuid$1(),
11069
+ upload: signedUploadSchema
11070
+ });
11071
+ object$1({ id: uuid$1() });
10672
11072
  const MAX_PROTOTYPE_CONTENT_TYPE_LENGTH = 200;
10673
11073
  const prototypePathSchema = string$1().min(1).refine((value) => !value.startsWith("/") && !value.endsWith("/") && !value.includes("\\") && !value.includes("\0") && value.split("/").every((part) => part !== "" && part !== "." && part !== ".."), { message: "prototype paths must be portable relative file paths" });
10674
11074
  const prototypeFileSchema = object$1({
@@ -10799,6 +11199,30 @@ progression: object$1({
10799
11199
  (/* @__PURE__ */ string()).check(/* @__PURE__ */ _maxLength(MAX_REASON_LENGTH));
10800
11200
  (/* @__PURE__ */ number()).check(/* @__PURE__ */ _gte(0), /* @__PURE__ */ _lte(1)), (/* @__PURE__ */ number()).check(/* @__PURE__ */ _gte(0), /* @__PURE__ */ _lte(1));
10801
11201
  //#endregion
11202
+ //#region ../contract/src/recording/canvas-context-kinds.lib.ts
11203
+ /**
11204
+ * Which drawing context each canvas holds, noted from the page's start. An empty read of a WebGL
11205
+ * canvas can hide a picture already given to the screen; an empty read of a 2D canvas, or of one
11206
+ * no script gave a context, is the truth. Only a watcher that runs before the page's scripts can
11207
+ * know which is which, because asking an untouched canvas for a context creates one.
11208
+ */
11209
+ const KINDS_KEY = Symbol.for("enhance.canvasContextKinds");
11210
+ const isContextKinds = (value) => typeof value === "object" && value !== null && typeof Reflect.get(value, "get") === "function";
11211
+ const kindsIn = (scope) => {
11212
+ const kinds = Reflect.get(scope, KINDS_KEY);
11213
+ return isContextKinds(kinds) ? kinds : null;
11214
+ };
11215
+ /** What the watcher in a canvas's own window knows of it; `unknown` when nothing watched it. */
11216
+ const canvasContextKnowledgeOf = (canvas) => {
11217
+ if (typeof canvas !== "object" || canvas === null) return "unknown";
11218
+ const owner = Reflect.get(canvas, "ownerDocument");
11219
+ const view = typeof owner === "object" && owner !== null ? Reflect.get(owner, "defaultView") : null;
11220
+ const kinds = typeof view === "object" && view !== null ? kindsIn(view) : null;
11221
+ return kinds === null ? "unknown" : kinds.get(canvas) ?? "none";
11222
+ };
11223
+ /** An empty read of a canvas in one of these states is the canvas's real picture. */
11224
+ const isEmptyReadTruthful = (knowledge) => knowledge === "none" || knowledge === "2d";
11225
+ //#endregion
10802
11226
  //#region ../contract/src/recording/inline-data-asset.lib.ts
10803
11227
  const INLINE_IMAGE = /^data:(image\/(?:avif|gif|jpeg|png|webp));base64,([a-z0-9+/]+={0,2})$/iu;
10804
11228
  const HASH_RADIX = 16;
@@ -10842,11 +11266,195 @@ progression: object$1({
10842
11266
  };
10843
11267
  };
10844
11268
  //#endregion
11269
+ //#region ../contract/src/recording/captured-media.lib.ts
11270
+ /**
11271
+ * What a capture saw a video, `object` or `embed` show, written on its copy: `picture` (the
11272
+ * picture is in the element's own picture attribute), `empty` (it showed nothing) or
11273
+ * `unreadable` (with a reason). A copy without it was made before captures read media.
11274
+ */
11275
+ const CAPTURED_MEDIA_ATTRIBUTE = "data-enhance-media";
11276
+ const CAPTURED_MEDIA_REASON_ATTRIBUTE = "data-enhance-media-reason";
11277
+ /** The attribute each media element shows its picture through, without a live source. */
11278
+ const MEDIA_PICTURE_ATTRIBUTES = {
11279
+ embed: "src",
11280
+ img: "src",
11281
+ object: "data",
11282
+ video: "poster"
11283
+ };
11284
+ const MEDIA_REASONS = {
11285
+ crossSite: "This video comes from another site that does not allow its frames to be copied.",
11286
+ protected: "This video is protected, so its frame cannot be copied.",
11287
+ embeddedPage: "This is an embedded web page or plugin, which Enhance does not draw.",
11288
+ notStored: "The picture this element showed could not be stored with the page.",
11289
+ pageOnly: "This image was made by the page while it ran and was not finished when it was captured, so it could not be stored."
11290
+ };
11291
+ const ELEMENT$5 = 2;
11292
+ const HAVE_CURRENT_DATA = 2;
11293
+ const isObject$4 = (value) => typeof value === "object" && value !== null;
11294
+ const localNameOf = (element) => String(Reflect.get(element, "localName") ?? "");
11295
+ const attributeOf = (element, name) => {
11296
+ const read = Reflect.get(element, "getAttribute");
11297
+ if (typeof read !== "function") return "";
11298
+ const value = Reflect.apply(read, element, [name]);
11299
+ return typeof value === "string" ? value.trim() : "";
11300
+ };
11301
+ const stringOf = (element, name) => {
11302
+ const value = Reflect.get(element, name);
11303
+ return typeof value === "string" ? value : "";
11304
+ };
11305
+ const numberOf = (element, name) => {
11306
+ const value = Number(Reflect.get(element, name));
11307
+ return Number.isFinite(value) ? value : 0;
11308
+ };
11309
+ const picture = (source) => ({
11310
+ kind: "picture",
11311
+ source
11312
+ });
11313
+ const unreadable = (reason) => ({
11314
+ kind: "unreadable",
11315
+ reason
11316
+ });
11317
+ const call = (target, name, args) => {
11318
+ const method = Reflect.get(target, name);
11319
+ return typeof method === "function" ? Reflect.apply(method, target, args) : void 0;
11320
+ };
11321
+ const isSecurityError = (error) => isObject$4(error) && Reflect.get(error, "name") === "SecurityError";
11322
+ /** Draws a decoded image at its own size as a PNG address, or says why it could not be read. */
11323
+ const pictureOf = (element, width, height, ifUnread) => {
11324
+ try {
11325
+ const owner = Reflect.get(element, "ownerDocument");
11326
+ const canvas = isObject$4(owner) ? call(owner, "createElement", ["canvas"]) : null;
11327
+ if (!isObject$4(canvas)) return unreadable(MEDIA_REASONS.notStored);
11328
+ Reflect.set(canvas, "width", width);
11329
+ Reflect.set(canvas, "height", height);
11330
+ const context = call(canvas, "getContext", ["2d"]);
11331
+ if (!isObject$4(context)) return unreadable(MEDIA_REASONS.notStored);
11332
+ call(context, "drawImage", [
11333
+ element,
11334
+ 0,
11335
+ 0
11336
+ ]);
11337
+ const encoded = String(call(canvas, "toDataURL", ["image/png"]));
11338
+ return inlineDataAssetReference(encoded)?.contentType === "image/png" ? picture(encoded) : unreadable(MEDIA_REASONS.notStored);
11339
+ } catch (error) {
11340
+ return unreadable(isSecurityError(error) ? ifUnread : MEDIA_REASONS.notStored);
11341
+ }
11342
+ };
11343
+ /**
11344
+ * The current frame, drawn at the video's own size, or why it could not be read: the browser
11345
+ * refuses to read a frame from another site that did not allow it.
11346
+ */
11347
+ const frameOf = (video) => pictureOf(video, numberOf(video, "videoWidth"), numberOf(video, "videoHeight"), MEDIA_REASONS.crossSite);
11348
+ /**
11349
+ * An image whose address the page made with `URL.createObjectURL` exists only inside that page,
11350
+ * so its decoded picture is what the capture keeps. Any other image is stored by its address.
11351
+ */
11352
+ const pageOnlyImageOf = (image) => {
11353
+ const current = stringOf(image, "currentSrc");
11354
+ if (!(current === "" ? stringOf(image, "src") : current).startsWith("blob:")) return null;
11355
+ const width = numberOf(image, "naturalWidth");
11356
+ const height = numberOf(image, "naturalHeight");
11357
+ if (width === 0 || height === 0 || Reflect.get(image, "complete") !== true) return unreadable(MEDIA_REASONS.pageOnly);
11358
+ return pictureOf(image, width, height, MEDIA_REASONS.notStored);
11359
+ };
11360
+ /**
11361
+ * A video shows its poster until it has played or been moved to another time, and while it has
11362
+ * no frame; otherwise its current frame.
11363
+ */
11364
+ const videoMediaOf = (video) => {
11365
+ const keys = Reflect.get(video, "mediaKeys");
11366
+ if (keys !== null && keys !== void 0) return unreadable(MEDIA_REASONS.protected);
11367
+ const poster = attributeOf(video, "poster") === "" ? "" : stringOf(video, "poster");
11368
+ const hasFrame = numberOf(video, "readyState") >= HAVE_CURRENT_DATA && numberOf(video, "videoWidth") > 0 && numberOf(video, "videoHeight") > 0;
11369
+ const played = Reflect.get(video, "played");
11370
+ const hasPlayed = isObject$4(played) && Number(Reflect.get(played, "length")) > 0;
11371
+ const hasMoved = numberOf(video, "currentTime") > 0 || Reflect.get(video, "seeking") === true;
11372
+ if (poster !== "" && (!hasFrame || !hasPlayed && !hasMoved)) return picture(poster);
11373
+ if (!hasFrame) return { kind: "empty" };
11374
+ return frameOf(video);
11375
+ };
11376
+ const contentDocumentOf = (element) => {
11377
+ try {
11378
+ const owned = Reflect.get(element, "contentDocument");
11379
+ if (owned !== void 0) return owned;
11380
+ const read = Reflect.get(element, "getSVGDocument");
11381
+ return typeof read === "function" ? Reflect.apply(read, element, []) : null;
11382
+ } catch {
11383
+ return null;
11384
+ }
11385
+ };
11386
+ /** What an `object` or `embed` shows: an image or SVG file by its address, or a web page. */
11387
+ const embeddedMediaOf = (element, attribute) => {
11388
+ if (attributeOf(element, attribute) === "") return localNameOf(element) === "object" ? null : { kind: "empty" };
11389
+ const document = contentDocumentOf(element);
11390
+ const root = isObject$4(document) ? Reflect.get(document, "documentElement") : null;
11391
+ if (isObject$4(root) && localNameOf(root) !== "svg") return unreadable(MEDIA_REASONS.embeddedPage);
11392
+ return picture(stringOf(element, attribute));
11393
+ };
11394
+ /** What a live media element showed, or null when it is not one or needs no answer. */
11395
+ const capturedMediaOf = (element) => {
11396
+ if (!isObject$4(element)) return null;
11397
+ switch (localNameOf(element)) {
11398
+ case "video": return videoMediaOf(element);
11399
+ case "object": return embeddedMediaOf(element, "data");
11400
+ case "embed": return embeddedMediaOf(element, "src");
11401
+ case "img": return pageOnlyImageOf(element);
11402
+ default: return null;
11403
+ }
11404
+ };
11405
+ /** Attributes that make a media element play or load from the live page. */
11406
+ const isLiveSourceAttribute = (name, tagName) => name.startsWith("rr_media") || name === "autoplay" || tagName === "video" && name === "src" || tagName === "img" && name === "srcset" || (tagName === "object" || tagName === "embed") && (name === "type" || name === "typemustmatch");
11407
+ const withoutLiveSources = (attributes, tagName) => Object.fromEntries(Object.entries(attributes).filter(([name]) => !isLiveSourceAttribute(name, tagName)));
11408
+ /** A media element's attributes with what it showed written on them and its live sources gone. */
11409
+ const capturedMediaAttributes = (tagName, attributes, media) => {
11410
+ const attribute = MEDIA_PICTURE_ATTRIBUTES[tagName];
11411
+ if (attribute === void 0) return attributes;
11412
+ if (media.kind === "unreadable") return {
11413
+ ...attributes,
11414
+ [CAPTURED_MEDIA_ATTRIBUTE]: "unreadable",
11415
+ [CAPTURED_MEDIA_REASON_ATTRIBUTE]: media.reason
11416
+ };
11417
+ const rest = Object.fromEntries(Object.entries(withoutLiveSources(attributes, tagName)).filter(([name]) => name !== attribute));
11418
+ return media.kind === "picture" ? {
11419
+ ...rest,
11420
+ [attribute]: media.source,
11421
+ [CAPTURED_MEDIA_ATTRIBUTE]: "picture"
11422
+ } : {
11423
+ ...rest,
11424
+ [CAPTURED_MEDIA_ATTRIBUTE]: "empty"
11425
+ };
11426
+ };
11427
+ /** The copy of a media element with what it showed written on it and its live sources gone. */
11428
+ const withCapturedMediaAnswer = (node, media) => {
11429
+ const tagName = node.tagName ?? "";
11430
+ if (MEDIA_PICTURE_ATTRIBUTES[tagName] === void 0) return node;
11431
+ const attributes = capturedMediaAttributes(tagName, node.attributes ?? {}, media);
11432
+ return media.kind === "unreadable" ? {
11433
+ ...node,
11434
+ attributes
11435
+ } : {
11436
+ ...node,
11437
+ attributes,
11438
+ childNodes: []
11439
+ };
11440
+ };
11441
+ /** Writes what each live media element in a snapshot showed onto its copy. */
11442
+ const withCapturedMedia = (node, nodeForId) => {
11443
+ const media = node.type === ELEMENT$5 && node.tagName !== void 0 && MEDIA_PICTURE_ATTRIBUTES[node.tagName] !== void 0 && typeof node.id === "number" ? capturedMediaOf(nodeForId(node.id)) : null;
11444
+ if (media !== null) return withCapturedMediaAnswer(node, media);
11445
+ const children = node.childNodes;
11446
+ if (children === void 0) return node;
11447
+ return {
11448
+ ...node,
11449
+ childNodes: children.map((child) => withCapturedMedia(child, nodeForId))
11450
+ };
11451
+ };
11452
+ //#endregion
10845
11453
  //#region ../contract/src/recording/captured-canvas.lib.ts
10846
11454
  const CAPTURED_CANVAS_SOURCE_ATTRIBUTE = "data-enhance-canvas-source";
10847
11455
  const RR_CANVAS_DATA_URL_ATTRIBUTE = "rr_dataURL";
10848
- const ELEMENT$2 = 2;
10849
- const isObject$1 = (value) => typeof value === "object" && value !== null;
11456
+ const ELEMENT$4 = 2;
11457
+ const isObject$3 = (value) => typeof value === "object" && value !== null;
10850
11458
  const isLosslessInlineCanvas = (value) => inlineDataAssetReference(value)?.contentType === "image/png";
10851
11459
  /** A canvas source produced by capture, either before or after recording-asset externalisation. */
10852
11460
  const isCapturedCanvasSource = (value) => typeof value === "string" && (isLosslessInlineCanvas(value) || value.startsWith("/v1/recording-assets/"));
@@ -10868,12 +11476,12 @@ progression: object$1({
10868
11476
  };
10869
11477
  const blankCanvasPng = (value) => {
10870
11478
  const owner = Reflect.get(value, "ownerDocument");
10871
- if (!isObject$1(owner)) return null;
11479
+ if (!isObject$3(owner)) return null;
10872
11480
  const create = Reflect.get(owner, "createElement");
10873
11481
  if (typeof create !== "function") return null;
10874
11482
  try {
10875
11483
  const blank = Reflect.apply(create, owner, ["canvas"]);
10876
- if (!isObject$1(blank)) return null;
11484
+ if (!isObject$3(blank)) return null;
10877
11485
  Reflect.set(blank, "width", Reflect.get(value, "width"));
10878
11486
  Reflect.set(blank, "height", Reflect.get(value, "height"));
10879
11487
  return encodedPng(blank);
@@ -10881,20 +11489,27 @@ progression: object$1({
10881
11489
  return null;
10882
11490
  }
10883
11491
  };
10884
- const canvasPng = (value) => {
10885
- if (!isObject$1(value)) return null;
11492
+ const CANVAS_REASONS = {
11493
+ crossSite: "This canvas shows a picture from another site, so its pixels cannot be copied.",
11494
+ unknownKind: "This canvas was empty or drawn with WebGL, and the capture could not tell which. Load the capture script before the page's own scripts to keep it.",
11495
+ webgl: "This canvas is drawn with WebGL, whose picture cannot be read once it is on screen."
11496
+ };
11497
+ const canvasRead = (value) => {
11498
+ if (!isObject$3(value)) return null;
10886
11499
  const source = encodedPng(value);
10887
- if (source === null || source === blankCanvasPng(value)) return null;
10888
- return source;
11500
+ if (source === null) return { reason: CANVAS_REASONS.crossSite };
11501
+ const knowledge = canvasContextKnowledgeOf(value);
11502
+ if (source === blankCanvasPng(value) && !isEmptyReadTruthful(knowledge)) return { reason: knowledge === "unknown" ? CANVAS_REASONS.unknownKind : CANVAS_REASONS.webgl };
11503
+ return { source };
10889
11504
  };
10890
- /** Adds readable backing-store pixels without letting one tainted canvas sink the snapshot. */
11505
+ /** Adds readable backing-store pixels, or why they could not be read, to each canvas. */
10891
11506
  const withReadableCanvasPixels = (node, nodeForId) => {
10892
- const source = node.type === ELEMENT$2 && node.tagName === "canvas" && typeof node.id === "number" ? canvasPng(nodeForId(node.id)) : null;
11507
+ const read = node.type === ELEMENT$4 && node.tagName === "canvas" && typeof node.id === "number" ? canvasRead(nodeForId(node.id)) : null;
10893
11508
  const childNodes = node.childNodes?.map((child) => withReadableCanvasPixels(child, nodeForId));
10894
- if (source === null && childNodes === void 0) return node;
10895
- const attributes = source === null ? void 0 : {
11509
+ if (read === null && childNodes === void 0) return node;
11510
+ const attributes = read === null ? void 0 : {
10896
11511
  ...node.attributes,
10897
- [RR_CANVAS_DATA_URL_ATTRIBUTE]: source
11512
+ ..."source" in read ? { [RR_CANVAS_DATA_URL_ATTRIBUTE]: read.source } : { [CAPTURED_MEDIA_REASON_ATTRIBUTE]: read.reason }
10898
11513
  };
10899
11514
  return {
10900
11515
  ...node,
@@ -10910,6 +11525,12 @@ progression: object$1({
10910
11525
  //#region ../contract/src/recording/captured-font-evidence.lib.ts
10911
11526
  const CAPTURED_LOADED_FONTS_ATTRIBUTE = "data-enhance-loaded-captured-fonts";
10912
11527
  const CAPTURED_UNAVAILABLE_FONTS_ATTRIBUTE = "data-enhance-unavailable-captured-fonts";
11528
+ /**
11529
+ * Font families the page names but declares no face for, which the capturing browser could draw:
11530
+ * fonts installed on that machine. The converting machine may lack them, and that says nothing of
11531
+ * what the person saw.
11532
+ */
11533
+ const CAPTURED_DRAWABLE_FONTS_ATTRIBUTE = "data-enhance-drawable-captured-fonts";
10913
11534
  const loadedCapturedFontFamilies = (fonts) => {
10914
11535
  if (typeof fonts !== "object" || fonts === null) return [];
10915
11536
  const forEach = Reflect.get(fonts, "forEach");
@@ -10923,8 +11544,109 @@ progression: object$1({
10923
11544
  return [...found];
10924
11545
  };
10925
11546
  //#endregion
11547
+ //#region ../contract/src/recording/missing-replay-asset.lib.ts
11548
+ const MISSING_ASSET_PREFIX = "data:application/x.enhance-missing-asset,";
11549
+ const missingReplayAssetSourceIn = (url) => {
11550
+ if (!url.startsWith(MISSING_ASSET_PREFIX)) return null;
11551
+ try {
11552
+ const source = decodeURIComponent(url.slice(41));
11553
+ return ["http:", "https:"].includes(new URL(source).protocol) ? source : null;
11554
+ } catch {
11555
+ return null;
11556
+ }
11557
+ };
11558
+ //#endregion
11559
+ //#region ../contract/src/recording/captured-media-replay.lib.ts
11560
+ /** The attribute through which a captured media element shows its picture, if it has one. */
11561
+ const capturedMediaPictureAttribute = (tagName, attributes) => {
11562
+ const attribute = MEDIA_PICTURE_ATTRIBUTES[tagName];
11563
+ return attribute !== void 0 && attributes["data-enhance-media"] === "picture" ? attribute : null;
11564
+ };
11565
+ /**
11566
+ * Whether a captured media element shows its own content (a picture or nothing), and why not when
11567
+ * it does not. `undefined` means the capture gave no answer.
11568
+ */
11569
+ const capturedMediaShown = (tagName, attributes) => {
11570
+ const answer = attributes[CAPTURED_MEDIA_ATTRIBUTE];
11571
+ if (answer === "empty") return { isShown: true };
11572
+ if (answer === "unreadable") {
11573
+ const reason = attributes[CAPTURED_MEDIA_REASON_ATTRIBUTE];
11574
+ return {
11575
+ isShown: false,
11576
+ reason: typeof reason === "string" ? reason : null
11577
+ };
11578
+ }
11579
+ const attribute = capturedMediaPictureAttribute(tagName, attributes);
11580
+ if (attribute === null) return void 0;
11581
+ const source = attributes[attribute];
11582
+ return typeof source === "string" && source !== "" && missingReplayAssetSourceIn(source) === null ? { isShown: true } : {
11583
+ isShown: false,
11584
+ reason: MEDIA_REASONS.notStored
11585
+ };
11586
+ };
11587
+ /** Whether a video, object or embed is drawn as its own content rather than a placeholder. */
11588
+ const isCapturedMediaShown = (tagName, attributes) => {
11589
+ const shown = capturedMediaShown(tagName, attributes);
11590
+ if (shown !== void 0) return shown.isShown;
11591
+ const data = attributes["data"];
11592
+ return tagName === "object" && attributes["rr_width"] === void 0 && (typeof data !== "string" || data.trim() === "");
11593
+ };
11594
+ /** A media placeholder keeps the capture's reason, or names a picture the store did not keep. */
11595
+ const withCapturedMediaReason = (tagName, captured, attributes) => {
11596
+ const shown = capturedMediaShown(tagName, captured);
11597
+ return shown === void 0 || shown.isShown || shown.reason === null ? attributes : {
11598
+ ...attributes,
11599
+ [CAPTURED_MEDIA_REASON_ATTRIBUTE]: shown.reason
11600
+ };
11601
+ };
11602
+ //#endregion
11603
+ //#region ../contract/src/recording/cdata-text.lib.ts
11604
+ const TEXT = 3;
11605
+ const CDATA = 4;
11606
+ /** What rrweb stores for the text of any script, so a page's script is never recorded. */
11607
+ const SCRIPT_PLACEHOLDER = "SCRIPT_PLACEHOLDER";
11608
+ const isObject$2 = (value) => typeof value === "object" && value !== null;
11609
+ /** An XML page names its elements in lower case and an HTML page in upper case. */
11610
+ const parentNameOf = (section) => {
11611
+ const parent = section["parentNode"];
11612
+ const name = isObject$2(parent) ? parent["nodeName"] : null;
11613
+ return typeof name === "string" ? name.toLowerCase() : "";
11614
+ };
11615
+ const baseUrlOf = (section) => {
11616
+ const owner = section["ownerDocument"];
11617
+ const base = isObject$2(owner) ? owner["baseURI"] : null;
11618
+ return typeof base === "string" ? base : "";
11619
+ };
11620
+ const sectionText = (section, absoluteCss) => {
11621
+ if (!isObject$2(section) || typeof section["data"] !== "string") return "";
11622
+ const parent = parentNameOf(section);
11623
+ if (parent === "script") return SCRIPT_PLACEHOLDER;
11624
+ return parent === "style" ? absoluteCss(section["data"], baseUrlOf(section)) : section["data"];
11625
+ };
11626
+ /**
11627
+ * Stores each CDATA section as the text it holds. rrweb records a section empty, and its replay
11628
+ * cannot rebuild one, because only an XML document may hold a CDATA section and a replay is HTML.
11629
+ */
11630
+ const withCdataAsText = (node, nodeForId, absoluteCss) => {
11631
+ if (node.type === CDATA) {
11632
+ const section = typeof node.id === "number" ? nodeForId(node.id) : null;
11633
+ return {
11634
+ ...node,
11635
+ type: TEXT,
11636
+ textContent: sectionText(section, absoluteCss)
11637
+ };
11638
+ }
11639
+ const children = node.childNodes;
11640
+ if (children === void 0) return node;
11641
+ const childNodes = children.map((child) => withCdataAsText(child, nodeForId, absoluteCss));
11642
+ return childNodes.every((child, index) => child === children[index]) ? node : {
11643
+ ...node,
11644
+ childNodes
11645
+ };
11646
+ };
11647
+ //#endregion
10926
11648
  //#region ../contract/src/recording/full-page-screen.lib.ts
10927
- const PERCENT = 100;
11649
+ const PERCENT$1 = 100;
10928
11650
  const CSS_TOKEN = /\/\*[\s\S]*?\*\/|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|url\((?:\\.|[^)])*\)|@media\b([^{}]+)\{|(?:--|-?[a-z_\u{80}-\u{10FFFF}]|\\(?:[\da-f]{1,6}\s?|[^\da-f\r\n\f]))[\w\u{80}-\u{10FFFF}-]*|(-?(?:\d*\.)?\d+(?:e[+-]?\d+)?)([sld]?v(?:min|max|[hwib]))\b/giu;
10929
11651
  const viewportUnit = (unit, options) => {
10930
11652
  if (unit.endsWith("min")) return Math.min(options.width, options.height);
@@ -10935,8 +11657,14 @@ progression: object$1({
10935
11657
  const fullPageScreenCss = (css, options) => css.replaceAll(CSS_TOKEN, (token, media, amount, unit) => {
10936
11658
  if (media !== void 0) return `@media ${options.matchesMedia(media) ? "all" : "not all"}{`;
10937
11659
  if (amount === void 0) return token;
10938
- return `${String(Number(amount) * viewportUnit(String(unit).toLowerCase(), options) / PERCENT)}px`;
11660
+ return `${String(Number(amount) * viewportUnit(String(unit).toLowerCase(), options) / PERCENT$1)}px`;
10939
11661
  });
11662
+ /** The root keeps the sizes the live window gave it; only its clipping is opened. */
11663
+ const addedRulesOf = (node, options) => {
11664
+ const override = node.id === void 0 ? void 0 : options.overrides.get(node.id);
11665
+ const isRoot = node.tagName === "html" || node.tagName === "body";
11666
+ return [...override === void 0 ? [] : [override], ...isRoot ? ["overflow:visible!important"] : []];
11667
+ };
10940
11668
  const fullPageAttributes = (node, options) => {
10941
11669
  const attributes = node.attributes === void 0 ? void 0 : { ...node.attributes };
10942
11670
  if (attributes !== void 0) {
@@ -10944,14 +11672,10 @@ progression: object$1({
10944
11672
  const value = attributes[key];
10945
11673
  if (typeof value === "string") attributes[key] = fullPageScreenCss(value, options);
10946
11674
  }
10947
- const override = node.id === void 0 ? void 0 : options.overrides.get(node.id);
10948
11675
  const inlineStyle = typeof attributes["style"] === "string" ? attributes["style"] : "";
10949
- if (override !== void 0) {
10950
- attributes["style"] = `${inlineStyle};${override}`;
10951
- attributes["rr_scrollTop"] = 0;
10952
- }
10953
- if (node.tagName === "html" || node.tagName === "body") {
10954
- attributes["style"] = `${inlineStyle};height:auto!important;min-height:100%!important;max-height:none!important;overflow:visible!important`;
11676
+ const rules = addedRulesOf(node, options);
11677
+ if (rules.length > 0) {
11678
+ attributes["style"] = [inlineStyle, ...rules].join(";");
10955
11679
  attributes["rr_scrollTop"] = 0;
10956
11680
  }
10957
11681
  }
@@ -10994,29 +11718,281 @@ progression: object$1({
10994
11718
  };
10995
11719
  };
10996
11720
  //#endregion
10997
- //#region ../contract/src/recording/missing-replay-asset.lib.ts
10998
- const MISSING_ASSET_PREFIX = "data:application/x.enhance-missing-asset,";
10999
- const missingReplayAssetSourceIn = (url) => {
11000
- if (!url.startsWith(MISSING_ASSET_PREFIX)) return null;
11001
- try {
11002
- const source = decodeURIComponent(url.slice(41));
11003
- return ["http:", "https:"].includes(new URL(source).protocol) ? source : null;
11004
- } catch {
11005
- return null;
11006
- }
11721
+ //#region ../contract/src/recording/unsupported-frame-label.lib.ts
11722
+ /** What stands in for an embedded page the capture could not keep, or null when it is kept. */
11723
+ const iframeSurfaceLabel = (attributes) => {
11724
+ const recordedSource = attributes["rr_src"];
11725
+ const isExplicitlyHidden = attributes["aria-hidden"] === "true" || attributes["width"] === "0" && attributes["height"] === "0";
11726
+ if (typeof recordedSource === "string" && !isExplicitlyHidden) return attributes["data-enhance-frame-unloaded"] === "" ? "Embedded content not loaded" : "Embedded content not supported";
11727
+ const source = attributes["src"] ?? attributes["srcdoc"];
11728
+ return typeof source === "string" && source.startsWith("blob:") ? "Embedded content not supported" : null;
11007
11729
  };
11730
+ const CROSS_LINE = "transparent calc(50% - 2px), rgba(255, 255, 255, 0.85) calc(50% - 1px), #a8a8b0 50%, rgba(255, 255, 255, 0.85) calc(50% + 1px), transparent calc(50% + 2px)";
11731
+ [`[data-enhance-unsupported]:not([data-enhance-unsupported-hidden]):not([style*="display: none"]) {
11732
+ align-items: center !important;
11733
+ background-color: transparent !important;
11734
+ background-image: ${`linear-gradient(to top right, ${CROSS_LINE}), linear-gradient(to bottom right, ${CROSS_LINE})`} !important;
11735
+ border: 1px solid #c7c7cc !important;
11736
+ box-sizing: border-box !important;
11737
+ color: #4f4f55 !important;
11738
+ display: flex !important;
11739
+ font: 500 14px/1.4 Inter, ui-sans-serif, system-ui, sans-serif !important;
11740
+ justify-content: center !important;
11741
+ overflow: hidden !important;
11742
+ text-align: center !important;
11743
+ }`, `[data-enhance-unsupported-hidden], [data-enhance-unsupported][style*="display: none"] {
11744
+ display: none !important;
11745
+ }`].join("\n");
11008
11746
  //#endregion
11009
- //#region ../contract/src/recording/page-asset-event-shapes.lib.ts
11747
+ //#region ../contract/src/recording/unsupported-surfaces.lib.ts
11748
+ const ELEMENT$3 = 2;
11010
11749
  const FULL_SNAPSHOT$1 = 2;
11011
11750
  const INCREMENTAL_SNAPSHOT$1 = 3;
11751
+ const MUTATION = 0;
11752
+ const OMIT_RECORDER_HOST = Symbol("omit-recorder-host");
11753
+ const isObject$1 = (value) => typeof value === "object" && value !== null;
11012
11754
  const isUnknownArray$1 = (value) => Array.isArray(value);
11013
- const recordIn$1 = (value) => typeof value === "object" && value !== null ? { ...value } : null;
11014
- const unknownArrayIn = (value) => {
11015
- if (!isUnknownArray$1(value)) return [];
11016
- return [...value];
11755
+ const isSnapshotNode$1 = (value) => isObject$1(value) && typeof value["type"] === "number";
11756
+ const withoutRecorderHost = (node) => {
11757
+ if (node.type === ELEMENT$3 && node.tagName === "enhance3-recorder") return null;
11758
+ if (node.childNodes === void 0) return node;
11759
+ return {
11760
+ ...node,
11761
+ childNodes: node.childNodes.flatMap((child) => {
11762
+ const kept = withoutRecorderHost(child);
11763
+ return kept === null ? [] : [kept];
11764
+ })
11765
+ };
11766
+ };
11767
+ const unsupportedSurfaceLabel = (tagName, attributes) => {
11768
+ switch (tagName) {
11769
+ case "canvas": return capturedCanvasSourceIn(attributes) === null ? "Canvas not supported" : null;
11770
+ case "video": return isCapturedMediaShown("video", attributes) ? null : "Video not supported";
11771
+ case "audio": return attributes["controls"] === void 0 && typeof attributes["rr_width"] !== "string" ? null : "Audio not supported";
11772
+ case "object":
11773
+ case "embed": return isCapturedMediaShown(tagName, attributes) ? null : "Embedded content not supported";
11774
+ case "img":
11775
+ case "image": {
11776
+ const source = attributes["src"] ?? attributes["href"] ?? attributes["xlink:href"];
11777
+ return typeof source === "string" && source.startsWith("blob:") ? "Image not supported" : null;
11778
+ }
11779
+ case "iframe": return iframeSurfaceLabel(attributes);
11780
+ case void 0: return null;
11781
+ default: return null;
11782
+ }
11783
+ };
11784
+ const labelFor = (node) => {
11785
+ if (node.type !== ELEMENT$3) return null;
11786
+ const attributes = node.attributes ?? {};
11787
+ const placeholder = attributes["data-enhance-unsupported"];
11788
+ if (typeof placeholder === "string" && node.tagName === "div") return placeholder;
11789
+ if (node.tagName === "iframe" && attributes["data-enhance-frame-unloaded"] === "") return iframeSurfaceLabel(attributes);
11790
+ const className = attributes["class"];
11791
+ const wasUnsupported = typeof className === "string" && className.split(/\s+/u).includes("enhance3-unsupported-surface");
11792
+ const wasBlocked = typeof attributes["rr_width"] === "string" && typeof attributes["rr_height"] === "string";
11793
+ if ((wasUnsupported || wasBlocked) && node.tagName === "iframe") return "Embedded content not supported";
11794
+ if ((wasUnsupported || wasBlocked) && (node.tagName === "img" || node.tagName === "image")) return "Image not supported";
11795
+ return unsupportedSurfaceLabel(node.tagName, attributes);
11796
+ };
11797
+ const placeholderAttributes = (attributes) => Object.fromEntries(Object.entries(attributes).flatMap(([name, value]) => {
11798
+ if (name.startsWith("rr_media")) return [];
11799
+ if (name !== "class" || typeof value !== "string") return [[name, value]];
11800
+ const cleaned = value.split(/\s+/u).filter((part) => part.length > 0 && part !== "enhance3-unsupported-surface").join(" ");
11801
+ return cleaned.length === 0 ? [] : [[name, cleaned]];
11802
+ }));
11803
+ const withoutFrameNavigation = (attributes) => Object.fromEntries(Object.entries(attributes).filter(([name]) => name !== "src" && name !== "rr_src" && name !== "srcdoc"));
11804
+ const wasDisplayNone = (attributes) => {
11805
+ const style = attributes["style"];
11806
+ return typeof style === "string" && /(?:^|;)\s*display\s*:\s*none(?:\s*!important)?\s*(?:;|$)/iu.test(style);
11807
+ };
11808
+ const wasZeroSizedBlock = (attributes) => {
11809
+ const width = attributes["rr_width"];
11810
+ const height = attributes["rr_height"];
11811
+ return typeof width === "string" && typeof height === "string" && Number(width.replace(/px$/u, "")) === 0 && Number(height.replace(/px$/u, "")) === 0;
11812
+ };
11813
+ const isExplicitlyHiddenFrame = (attributes) => attributes["aria-hidden"] === "true" || attributes["width"] === "0" && attributes["height"] === "0";
11814
+ const isUncapturedNavigatedFrame = (node) => {
11815
+ if (node.tagName !== "iframe") return false;
11816
+ const attributes = node.attributes ?? {};
11817
+ if (isExplicitlyHiddenFrame(attributes)) return false;
11818
+ const source = attributes["src"];
11819
+ if (!(typeof attributes["srcdoc"] !== "string" && typeof source === "string" && source !== "" && source !== "about:blank")) return false;
11820
+ return node.childNodes?.some((child) => child.type === 0) !== true;
11821
+ };
11822
+ /**
11823
+ * The same rrweb node, except a non-serialisable surface becomes an ordinary div. rrweb's block
11824
+ * selector supplies `rr_width` and `rr_height`; keeping them makes the replacement occupy the
11825
+ * exact rectangle the original did without keeping pixels that cannot become primitives later.
11826
+ */
11827
+ const replaceUnsupportedSurfaces = (node, onUnsupported) => {
11828
+ const label = labelFor(node) ?? (isUncapturedNavigatedFrame(node) ? "Embedded content not supported" : null);
11829
+ if (label !== null) {
11830
+ onUnsupported?.(label);
11831
+ const attributes = withCapturedMediaReason(node.tagName ?? "", node.attributes ?? {}, placeholderAttributes(node.attributes ?? {}));
11832
+ if (node.tagName === "iframe") return {
11833
+ ...node,
11834
+ attributes: {
11835
+ ...withoutFrameNavigation(attributes),
11836
+ "aria-hidden": "true",
11837
+ "data-enhance-unsupported": label,
11838
+ ...(wasDisplayNone(attributes) || wasZeroSizedBlock(attributes)) && { "data-enhance-unsupported-hidden": "" },
11839
+ role: "img"
11840
+ },
11841
+ childNodes: []
11842
+ };
11843
+ return {
11844
+ ...node,
11845
+ tagName: "div",
11846
+ attributes: {
11847
+ ...attributes,
11848
+ "aria-hidden": "true",
11849
+ "data-enhance-unsupported": label,
11850
+ role: "img"
11851
+ },
11852
+ childNodes: []
11853
+ };
11854
+ }
11855
+ if (node.type === ELEMENT$3 && node.tagName === "script") return {
11856
+ ...node,
11857
+ childNodes: []
11858
+ };
11859
+ return node.childNodes === void 0 ? node : {
11860
+ ...node,
11861
+ childNodes: node.childNodes.map((child) => replaceUnsupportedSurfaces(child, onUnsupported))
11862
+ };
11017
11863
  };
11018
- const isSnapshotNode$1 = (value) => typeof value === "object" && value !== null && typeof Reflect.get(value, "type") === "number";
11019
- const snapshotNodeIn = (value) => isSnapshotNode$1(value) ? value : null;
11864
+ const replaceFullSnapshot = (event, onUnsupported) => {
11865
+ const data = event["data"];
11866
+ if (!isObject$1(data)) return event;
11867
+ const node = data["node"];
11868
+ if (!isSnapshotNode$1(node)) return event;
11869
+ const prepared = withoutRecorderHost(replaceUnsupportedSurfaces(node, onUnsupported));
11870
+ if (prepared === null) return event;
11871
+ return {
11872
+ ...event,
11873
+ data: {
11874
+ ...data,
11875
+ node: prepared
11876
+ }
11877
+ };
11878
+ };
11879
+ const replaceAddedNode = (add, onUnsupported) => {
11880
+ if (!isObject$1(add)) return add;
11881
+ const node = add["node"];
11882
+ if (!isSnapshotNode$1(node)) return add;
11883
+ const prepared = withoutRecorderHost(replaceUnsupportedSurfaces(node, onUnsupported));
11884
+ return prepared === null ? OMIT_RECORDER_HOST : {
11885
+ ...add,
11886
+ node: prepared
11887
+ };
11888
+ };
11889
+ const replaceMutation = (event, onUnsupported) => {
11890
+ const data = event["data"];
11891
+ if (!isObject$1(data) || data["source"] !== MUTATION) return event;
11892
+ const adds = data["adds"];
11893
+ if (!isUnknownArray$1(adds)) return event;
11894
+ return {
11895
+ ...event,
11896
+ data: {
11897
+ ...data,
11898
+ adds: adds.flatMap((add) => {
11899
+ const prepared = replaceAddedNode(add, onUnsupported);
11900
+ return prepared === OMIT_RECORDER_HOST ? [] : [prepared];
11901
+ })
11902
+ }
11903
+ };
11904
+ };
11905
+ /** @justified intent Keep fallbacks honest and omit recorder-owned UI. */
11906
+ const replaceUnsupportedSurfacesInEvent = (event, onUnsupported) => {
11907
+ if (!isObject$1(event)) return event;
11908
+ if (event["type"] === FULL_SNAPSHOT$1) return replaceFullSnapshot(event, onUnsupported);
11909
+ if (event["type"] === INCREMENTAL_SNAPSHOT$1) return replaceMutation(event, onUnsupported);
11910
+ return event;
11911
+ };
11912
+ //#endregion
11913
+ //#region ../contract/src/recording/measured-placeholders.lib.ts
11914
+ const ELEMENT$2 = 2;
11915
+ const isObject = (value) => typeof value === "object" && value !== null;
11916
+ /**
11917
+ * Whether the placeholder can take this axis from the element's own styles: a percentage or a
11918
+ * `calc()` applies to the placeholder as it did to the element, and follows its container. Any
11919
+ * other size came from the element's attributes or from the browser's default size for it, which
11920
+ * an ordinary box does not have, or is a length that the measurement repeats.
11921
+ */
11922
+ const isSizedByStyles = (live, property) => {
11923
+ const styleMap = Reflect.get(live, "computedStyleMap");
11924
+ if (typeof styleMap !== "function") return false;
11925
+ try {
11926
+ const map = Reflect.apply(styleMap, live, []);
11927
+ if (!isObject(map)) return false;
11928
+ const read = Reflect.get(map, "get");
11929
+ if (typeof read !== "function") return false;
11930
+ const value = Reflect.apply(read, map, [property]);
11931
+ if (!isObject(value)) return false;
11932
+ const unit = Reflect.get(value, "unit");
11933
+ if (typeof unit === "string") return unit === "percent";
11934
+ return typeof Reflect.get(value, "operator") === "string";
11935
+ } catch {
11936
+ return false;
11937
+ }
11938
+ };
11939
+ const measuredBox = (live) => {
11940
+ if (!isObject(live)) return null;
11941
+ const measure = Reflect.get(live, "getBoundingClientRect");
11942
+ if (typeof measure !== "function") return null;
11943
+ const box = Reflect.apply(measure, live, []);
11944
+ if (!isObject(box)) return null;
11945
+ const width = Reflect.get(box, "width");
11946
+ const height = Reflect.get(box, "height");
11947
+ return typeof width === "number" && typeof height === "number" ? {
11948
+ width,
11949
+ height
11950
+ } : null;
11951
+ };
11952
+ /**
11953
+ * The size of a surface the capture turns into a placeholder, measured where it stands. A
11954
+ * placeholder is an ordinary box, so a surface sized by its attributes or by the browser's default
11955
+ * size would otherwise have no size. The replay applies `rr_width` and `rr_height` as the box's
11956
+ * width and height, as it does for a surface the recorder blocks. An embedded page keeps its own
11957
+ * element and so its size; an audio player is blocked, and so measured, already.
11958
+ */
11959
+ const placeholderSizeOf = (node, live) => {
11960
+ const attributes = node.attributes ?? {};
11961
+ if (node.type !== ELEMENT$2 || node.tagName === void 0 || ["iframe", "audio"].includes(node.tagName) || typeof attributes["rr_width"] === "string" || unsupportedSurfaceLabel(node.tagName, attributes) === null) return {};
11962
+ const box = measuredBox(live);
11963
+ if (box === null || !isObject(live)) return {};
11964
+ return {
11965
+ ...!isSizedByStyles(live, "width") && { rr_width: `${String(box.width)}px` },
11966
+ ...!isSizedByStyles(live, "height") && { rr_height: `${String(box.height)}px` }
11967
+ };
11968
+ };
11969
+ /** The snapshot with the measured size of each surface that will become a placeholder. */
11970
+ const withMeasuredPlaceholders = (node, nodeForId) => {
11971
+ const size = typeof node.id === "number" ? placeholderSizeOf(node, nodeForId(node.id)) : {};
11972
+ const childNodes = node.childNodes?.map((child) => withMeasuredPlaceholders(child, nodeForId));
11973
+ const isSized = Object.keys(size).length > 0;
11974
+ if (!isSized && childNodes === void 0) return node;
11975
+ return {
11976
+ ...node,
11977
+ ...isSized && { attributes: {
11978
+ ...node.attributes,
11979
+ ...size
11980
+ } },
11981
+ ...childNodes !== void 0 && { childNodes }
11982
+ };
11983
+ };
11984
+ //#endregion
11985
+ //#region ../contract/src/recording/page-asset-event-shapes.lib.ts
11986
+ const FULL_SNAPSHOT = 2;
11987
+ const INCREMENTAL_SNAPSHOT = 3;
11988
+ const isUnknownArray = (value) => Array.isArray(value);
11989
+ const recordIn$1 = (value) => typeof value === "object" && value !== null ? { ...value } : null;
11990
+ const unknownArrayIn = (value) => {
11991
+ if (!isUnknownArray(value)) return [];
11992
+ return [...value];
11993
+ };
11994
+ const isSnapshotNode = (value) => typeof value === "object" && value !== null && typeof Reflect.get(value, "type") === "number";
11995
+ const snapshotNodeIn = (value) => isSnapshotNode(value) ? value : null;
11020
11996
  const eventPartIn = (event, type) => {
11021
11997
  const outer = recordIn$1(event);
11022
11998
  if (outer === null || Reflect.get(outer, "type") !== type) return null;
@@ -11028,7 +12004,7 @@ progression: object$1({
11028
12004
  };
11029
12005
  };
11030
12006
  const fullSnapshotInEvent = (event) => {
11031
- const part = eventPartIn(event, FULL_SNAPSHOT$1);
12007
+ const part = eventPartIn(event, FULL_SNAPSHOT);
11032
12008
  if (part === null) return null;
11033
12009
  const node = snapshotNodeIn(Reflect.get(part.data, "node"));
11034
12010
  return node === null ? null : {
@@ -11037,7 +12013,7 @@ progression: object$1({
11037
12013
  };
11038
12014
  };
11039
12015
  const incrementalIn = (event) => {
11040
- const part = eventPartIn(event, INCREMENTAL_SNAPSHOT$1);
12016
+ const part = eventPartIn(event, INCREMENTAL_SNAPSHOT);
11041
12017
  if (part === null) return null;
11042
12018
  const source = Reflect.get(part.data, "source");
11043
12019
  return typeof source === "number" ? {
@@ -11240,6 +12216,7 @@ progression: object$1({
11240
12216
  const isSourceSet = name === "srcset" || name === "imagesrcset";
11241
12217
  if (attributes[UNSUPPORTED_PLACEHOLDER] !== void 0 && (isSourceSet || PLAIN_URL_ATTRIBUTES.has(name))) return [];
11242
12218
  if (isSourceSet) return srcsetReferences(value);
12219
+ if (capturedMediaPictureAttribute(tagName, attributes) === name) return whole(value);
11243
12220
  if (tagName === "canvas" && (name === "rr_dataURL" || name === "data-enhance-canvas-source")) return whole(value);
11244
12221
  if (PLAIN_URL_ATTRIBUTES.has(name)) return INERT_SOURCE_TAGS.has(tagName) ? [] : whole(value);
11245
12222
  if (name === "href" || name === "xlink:href") {
@@ -11870,249 +12847,62 @@ missingAssetCount: number$2().int().min(0) });
11870
12847
  lastMs: number$2().int().min(0),
11871
12848
  epoch: number$2().int().min(0),
11872
12849
  startsEpoch: boolean$1()
11873
- });
11874
- const recordingAudioManifestSchema = discriminatedUnion$1("state", [recordingAudioManifestBaseSchema.extend({
11875
- state: literal$1("available"),
11876
- download: signedDownloadSchema
11877
- }), recordingAudioManifestBaseSchema.extend({ state: literal$1("missing") })]);
11878
- object$1({
11879
- recordingId: uuid$1(),
11880
- durationMs: number$2().int().min(0),
11881
- viewport: viewportSchema,
11882
- /** The page it was taken from. A replay resolves its mirrored assets against this. */
11883
- sourceUrl: string$1(),
11884
- interrupted: boolean$1(),
11885
- integrity: recordingIntegritySchema,
11886
- chunks: array$1(recordingChunkManifestSchema),
11887
- /** Null when the walkthrough has no voice on it, which the player draws differently. */
11888
- audio: object$1({
11889
- mimeType: string$1(),
11890
- chunks: array$1(recordingAudioManifestSchema)
11891
- }).nullable(),
11892
- /** Our copy of what the page loaded, by the address the page used. Empty is a real answer. */
11893
- assets: array$1(object$1({
11894
- url: string$1(),
11895
- contentType: string$1(),
11896
- /** Stable identity; it can safely live in cached rrweb events and frozen screens. */
11897
- path: string$1().startsWith("/v1/recording-assets/")
11898
- })),
11899
- /** How much of the page we could not fetch. A replay says so rather than rendering short. */
11900
- missingAssetCount: number$2().int().min(0),
11901
- missingAssetUrls: array$1(string$1()).optional()
11902
- });
11903
- const refreshRecordingUploadInputSchema = object$1({
11904
- recordingId: uuid$1(),
11905
- track: recordingTrackSchema,
11906
- index: number$2().int().min(0)
11907
- });
11908
- object$1({ upload: signedUploadSchema });
11909
- refreshRecordingUploadInputSchema.extend({ etag: string$1().min(1).max(200) });
11910
- object$1({ integrity: recordingIntegritySchema });
11911
- object$1({ canvasId: uuid$1() });
11912
- cappedSchema(recordingSummarySchema).extend({
11913
- /** Completed recordings left out because their facts are missing; the API logs each by ID. */
11914
- unreadableCount: number$2().int().min(0) });
11915
- object$1({ recordingId: uuid$1() });
11916
- object$1({
11917
- recordingId: uuid$1(),
11918
- discarded: literal$1(true)
11919
- });
11920
- object$1({
11921
- canvasId: uuid$1(),
11922
- recordingId: uuid$1()
11923
- });
11924
- object$1({
11925
- recordingId: uuid$1(),
11926
- /** Screens survive with their provenance nulled. That is what makes iteration safe. */
11927
- detachedScreenCount: number$2().int().min(0)
11928
- });
11929
- [`[data-enhance-unsupported]:not([data-enhance-unsupported-hidden]):not([style*="display: none"]) {
11930
- align-items: center !important;
11931
- background-color: #f7f7f8 !important;
11932
- background-image: linear-gradient(to top right, transparent calc(50% - 1px), #a8a8b0 50%, transparent calc(50% + 1px)), linear-gradient(to bottom right, transparent calc(50% - 1px), #a8a8b0 50%, transparent calc(50% + 1px)) !important;
11933
- border: 1px solid #c7c7cc !important;
11934
- box-sizing: border-box !important;
11935
- color: #4f4f55 !important;
11936
- display: flex !important;
11937
- font: 500 14px/1.4 Inter, ui-sans-serif, system-ui, sans-serif !important;
11938
- justify-content: center !important;
11939
- overflow: hidden !important;
11940
- text-align: center !important;
11941
- }`, `[data-enhance-unsupported-hidden], [data-enhance-unsupported][style*="display: none"] {
11942
- display: none !important;
11943
- }`].join("\n");
11944
- //#endregion
11945
- //#region ../contract/src/recording/unsupported-surfaces.lib.ts
11946
- const ELEMENT = 2;
11947
- const FULL_SNAPSHOT = 2;
11948
- const INCREMENTAL_SNAPSHOT = 3;
11949
- const MUTATION = 0;
11950
- const OMIT_RECORDER_HOST = Symbol("omit-recorder-host");
11951
- const isObject = (value) => typeof value === "object" && value !== null;
11952
- const isUnknownArray = (value) => Array.isArray(value);
11953
- const isSnapshotNode = (value) => isObject(value) && typeof value["type"] === "number";
11954
- const withoutRecorderHost = (node) => {
11955
- if (node.type === ELEMENT && node.tagName === "enhance3-recorder") return null;
11956
- if (node.childNodes === void 0) return node;
11957
- return {
11958
- ...node,
11959
- childNodes: node.childNodes.flatMap((child) => {
11960
- const kept = withoutRecorderHost(child);
11961
- return kept === null ? [] : [kept];
11962
- })
11963
- };
11964
- };
11965
- const iframeSurfaceLabel = (attributes) => {
11966
- const recordedSource = attributes["rr_src"];
11967
- const isExplicitlyHidden = attributes["aria-hidden"] === "true" || attributes["width"] === "0" && attributes["height"] === "0";
11968
- if (typeof recordedSource === "string" && !isExplicitlyHidden) return attributes["data-enhance-frame-unloaded"] === "" ? "Embedded content not loaded" : "Embedded content not supported";
11969
- const source = attributes["src"] ?? attributes["srcdoc"];
11970
- return typeof source === "string" && source.startsWith("blob:") ? "Embedded content not supported" : null;
11971
- };
11972
- const unsupportedSurfaceLabel = (tagName, attributes) => {
11973
- switch (tagName) {
11974
- case "canvas": return capturedCanvasSourceIn(attributes) === null ? "Canvas not supported" : null;
11975
- case "video": return "Video not supported";
11976
- case "object":
11977
- case "embed": return "Embedded content not supported";
11978
- case "img":
11979
- case "image": {
11980
- const source = attributes["src"] ?? attributes["href"] ?? attributes["xlink:href"];
11981
- return typeof source === "string" && source.startsWith("blob:") ? "Image not supported" : null;
11982
- }
11983
- case "iframe": return iframeSurfaceLabel(attributes);
11984
- case void 0: return null;
11985
- default: return null;
11986
- }
11987
- };
11988
- const labelFor = (node) => {
11989
- if (node.type !== ELEMENT) return null;
11990
- const attributes = node.attributes ?? {};
11991
- const placeholder = attributes["data-enhance-unsupported"];
11992
- if (typeof placeholder === "string" && node.tagName === "div") return placeholder;
11993
- if (node.tagName === "iframe" && attributes["data-enhance-frame-unloaded"] === "") return iframeSurfaceLabel(attributes);
11994
- const className = attributes["class"];
11995
- const wasUnsupported = typeof className === "string" && className.split(/\s+/u).includes("enhance3-unsupported-surface");
11996
- const wasBlocked = typeof attributes["rr_width"] === "string" && typeof attributes["rr_height"] === "string";
11997
- if ((wasUnsupported || wasBlocked) && node.tagName === "iframe") return "Embedded content not supported";
11998
- if ((wasUnsupported || wasBlocked) && (node.tagName === "img" || node.tagName === "image")) return "Image not supported";
11999
- return unsupportedSurfaceLabel(node.tagName, attributes);
12000
- };
12001
- const placeholderAttributes = (attributes) => Object.fromEntries(Object.entries(attributes).flatMap(([name, value]) => {
12002
- if (name.startsWith("rr_media")) return [];
12003
- if (name !== "class" || typeof value !== "string") return [[name, value]];
12004
- const cleaned = value.split(/\s+/u).filter((part) => part.length > 0 && part !== "enhance3-unsupported-surface").join(" ");
12005
- return cleaned.length === 0 ? [] : [[name, cleaned]];
12006
- }));
12007
- const withoutFrameNavigation = (attributes) => Object.fromEntries(Object.entries(attributes).filter(([name]) => name !== "src" && name !== "rr_src" && name !== "srcdoc"));
12008
- const wasDisplayNone = (attributes) => {
12009
- const style = attributes["style"];
12010
- return typeof style === "string" && /(?:^|;)\s*display\s*:\s*none(?:\s*!important)?\s*(?:;|$)/iu.test(style);
12011
- };
12012
- const wasZeroSizedBlock = (attributes) => {
12013
- const width = attributes["rr_width"];
12014
- const height = attributes["rr_height"];
12015
- return typeof width === "string" && typeof height === "string" && Number(width.replace(/px$/u, "")) === 0 && Number(height.replace(/px$/u, "")) === 0;
12016
- };
12017
- const isExplicitlyHiddenFrame = (attributes) => attributes["aria-hidden"] === "true" || attributes["width"] === "0" && attributes["height"] === "0";
12018
- const isUncapturedNavigatedFrame = (node) => {
12019
- if (node.tagName !== "iframe") return false;
12020
- const attributes = node.attributes ?? {};
12021
- if (isExplicitlyHiddenFrame(attributes)) return false;
12022
- const source = attributes["src"];
12023
- if (!(typeof attributes["srcdoc"] !== "string" && typeof source === "string" && source !== "" && source !== "about:blank")) return false;
12024
- return node.childNodes?.some((child) => child.type === 0) !== true;
12025
- };
12026
- /**
12027
- * The same rrweb node, except a non-serialisable surface becomes an ordinary div. rrweb's block
12028
- * selector supplies `rr_width` and `rr_height`; keeping them makes the replacement occupy the
12029
- * exact rectangle the original did without keeping pixels that cannot become primitives later.
12030
- */
12031
- const replaceUnsupportedSurfaces = (node, onUnsupported) => {
12032
- const label = labelFor(node) ?? (isUncapturedNavigatedFrame(node) ? "Embedded content not supported" : null);
12033
- if (label !== null) {
12034
- onUnsupported?.(label);
12035
- const attributes = placeholderAttributes(node.attributes ?? {});
12036
- if (node.tagName === "iframe") return {
12037
- ...node,
12038
- attributes: {
12039
- ...withoutFrameNavigation(attributes),
12040
- "aria-hidden": "true",
12041
- "data-enhance-unsupported": label,
12042
- ...(wasDisplayNone(attributes) || wasZeroSizedBlock(attributes)) && { "data-enhance-unsupported-hidden": "" },
12043
- role: "img"
12044
- },
12045
- childNodes: []
12046
- };
12047
- return {
12048
- ...node,
12049
- tagName: "div",
12050
- attributes: {
12051
- ...attributes,
12052
- "aria-hidden": "true",
12053
- "data-enhance-unsupported": label,
12054
- role: "img"
12055
- },
12056
- childNodes: []
12057
- };
12058
- }
12059
- if (node.type === ELEMENT && node.tagName === "script") return {
12060
- ...node,
12061
- childNodes: []
12062
- };
12063
- return node.childNodes === void 0 ? node : {
12064
- ...node,
12065
- childNodes: node.childNodes.map((child) => replaceUnsupportedSurfaces(child, onUnsupported))
12066
- };
12067
- };
12068
- const replaceFullSnapshot = (event, onUnsupported) => {
12069
- const data = event["data"];
12070
- if (!isObject(data)) return event;
12071
- const node = data["node"];
12072
- if (!isSnapshotNode(node)) return event;
12073
- const prepared = withoutRecorderHost(replaceUnsupportedSurfaces(node, onUnsupported));
12074
- if (prepared === null) return event;
12075
- return {
12076
- ...event,
12077
- data: {
12078
- ...data,
12079
- node: prepared
12080
- }
12081
- };
12082
- };
12083
- const replaceAddedNode = (add, onUnsupported) => {
12084
- if (!isObject(add)) return add;
12085
- const node = add["node"];
12086
- if (!isSnapshotNode(node)) return add;
12087
- const prepared = withoutRecorderHost(replaceUnsupportedSurfaces(node, onUnsupported));
12088
- return prepared === null ? OMIT_RECORDER_HOST : {
12089
- ...add,
12090
- node: prepared
12091
- };
12092
- };
12093
- const replaceMutation = (event, onUnsupported) => {
12094
- const data = event["data"];
12095
- if (!isObject(data) || data["source"] !== MUTATION) return event;
12096
- const adds = data["adds"];
12097
- if (!isUnknownArray(adds)) return event;
12098
- return {
12099
- ...event,
12100
- data: {
12101
- ...data,
12102
- adds: adds.flatMap((add) => {
12103
- const prepared = replaceAddedNode(add, onUnsupported);
12104
- return prepared === OMIT_RECORDER_HOST ? [] : [prepared];
12105
- })
12106
- }
12107
- };
12108
- };
12109
- /** @justified intent Keep fallbacks honest and omit recorder-owned UI. */
12110
- const replaceUnsupportedSurfacesInEvent = (event, onUnsupported) => {
12111
- if (!isObject(event)) return event;
12112
- if (event["type"] === FULL_SNAPSHOT) return replaceFullSnapshot(event, onUnsupported);
12113
- if (event["type"] === INCREMENTAL_SNAPSHOT) return replaceMutation(event, onUnsupported);
12114
- return event;
12115
- };
12850
+ });
12851
+ const recordingAudioManifestSchema = discriminatedUnion$1("state", [recordingAudioManifestBaseSchema.extend({
12852
+ state: literal$1("available"),
12853
+ download: signedDownloadSchema
12854
+ }), recordingAudioManifestBaseSchema.extend({ state: literal$1("missing") })]);
12855
+ object$1({
12856
+ recordingId: uuid$1(),
12857
+ durationMs: number$2().int().min(0),
12858
+ viewport: viewportSchema,
12859
+ /** The page it was taken from. A replay resolves its mirrored assets against this. */
12860
+ sourceUrl: string$1(),
12861
+ interrupted: boolean$1(),
12862
+ integrity: recordingIntegritySchema,
12863
+ chunks: array$1(recordingChunkManifestSchema),
12864
+ /** Null when the walkthrough has no voice on it, which the player draws differently. */
12865
+ audio: object$1({
12866
+ mimeType: string$1(),
12867
+ chunks: array$1(recordingAudioManifestSchema)
12868
+ }).nullable(),
12869
+ /** Our copy of what the page loaded, by the address the page used. Empty is a real answer. */
12870
+ assets: array$1(object$1({
12871
+ url: string$1(),
12872
+ contentType: string$1(),
12873
+ /** Stable identity; it can safely live in cached rrweb events and frozen screens. */
12874
+ path: string$1().startsWith("/v1/recording-assets/")
12875
+ })),
12876
+ /** How much of the page we could not fetch. A replay says so rather than rendering short. */
12877
+ missingAssetCount: number$2().int().min(0),
12878
+ missingAssetUrls: array$1(string$1()).optional()
12879
+ });
12880
+ const refreshRecordingUploadInputSchema = object$1({
12881
+ recordingId: uuid$1(),
12882
+ track: recordingTrackSchema,
12883
+ index: number$2().int().min(0)
12884
+ });
12885
+ object$1({ upload: signedUploadSchema });
12886
+ refreshRecordingUploadInputSchema.extend({ etag: string$1().min(1).max(200) });
12887
+ object$1({ integrity: recordingIntegritySchema });
12888
+ object$1({ canvasId: uuid$1() });
12889
+ cappedSchema(recordingSummarySchema).extend({
12890
+ /** Completed recordings left out because their facts are missing; the API logs each by ID. */
12891
+ unreadableCount: number$2().int().min(0) });
12892
+ object$1({ recordingId: uuid$1() });
12893
+ object$1({
12894
+ recordingId: uuid$1(),
12895
+ discarded: literal$1(true)
12896
+ });
12897
+ object$1({
12898
+ canvasId: uuid$1(),
12899
+ recordingId: uuid$1()
12900
+ });
12901
+ object$1({
12902
+ recordingId: uuid$1(),
12903
+ /** Screens survive with their provenance nulled. That is what makes iteration safe. */
12904
+ detachedScreenCount: number$2().int().min(0)
12905
+ });
12116
12906
  object$1({
12117
12907
  /**
12118
12908
  * Client-minted, once per capture attempt. A retry is the same screen; a re-capture at the
@@ -12223,6 +13013,21 @@ unreadableCount: number$2().int().min(0) });
12223
13013
  const MAX_COUNT$1 = 1e6;
12224
13014
  const MAX_BYTES = 1073741824;
12225
13015
  const MAX_PROTOTYPE_OPEN_ATTEMPTS = 16;
13016
+ const MAX_SCRIPT_POSITION = 1e8;
13017
+ /** What the person was doing when a long frame ended; `idle` is nothing at all. */
13018
+ const longFrameActionSchema = _enum$1([
13019
+ "pan",
13020
+ "zoom",
13021
+ "drag",
13022
+ "typing",
13023
+ "paste",
13024
+ "undo",
13025
+ "redo",
13026
+ "edit",
13027
+ "opening",
13028
+ "loading",
13029
+ "idle"
13030
+ ]);
12226
13031
  /** How the read of a canvas's unsaved browser copy ended when the canvas opened. */
12227
13032
  const browserCopyCheckSchema = _enum$1([
12228
13033
  "answered",
@@ -12237,6 +13042,12 @@ unreadableCount: number$2().int().min(0) });
12237
13042
  releaseIdentity: string$1().min(1).max(100),
12238
13043
  capabilityVersion: number$2().int().min(1).max(MAX_CAPABILITY_VERSION$1)
12239
13044
  };
13045
+ const scriptSourceSchema = _enum$1([
13046
+ "app",
13047
+ "extension",
13048
+ "third-party",
13049
+ "unknown"
13050
+ ]);
12240
13051
  const mainThreadWork = {
12241
13052
  longTaskCount: countSchema,
12242
13053
  longTaskTotalMs: durationSchema$1,
@@ -12246,12 +13057,7 @@ unreadableCount: number$2().int().min(0) });
12246
13057
  loafLongestBlockingMs: durationSchema$1,
12247
13058
  loafStyleAndLayoutMs: durationSchema$1,
12248
13059
  loafTopScriptMs: durationSchema$1,
12249
- loafTopScriptSource: _enum$1([
12250
- "app",
12251
- "extension",
12252
- "third-party",
12253
- "unknown"
12254
- ])
13060
+ loafTopScriptSource: scriptSourceSchema
12255
13061
  };
12256
13062
  discriminatedUnion$1("name", [
12257
13063
  object$1({
@@ -12312,10 +13118,42 @@ unreadableCount: number$2().int().min(0) });
12312
13118
  durationMs: durationSchema$1,
12313
13119
  frameCount: countSchema,
12314
13120
  slowFrameCount: countSchema,
13121
+ over16FrameCount: countSchema.optional(),
13122
+ over33FrameCount: countSchema.optional(),
12315
13123
  worstFrameMs: durationSchema$1,
12316
13124
  nodeCount: countSchema,
12317
13125
  replayCount: countSchema
12318
13126
  }),
13127
+ object$1({
13128
+ ...base$1,
13129
+ name: literal$1("canvas_long_frame"),
13130
+ source: _enum$1(["long-animation-frame", "longtask"]),
13131
+ action: longFrameActionSchema,
13132
+ durationMs: durationSchema$1,
13133
+ blockingMs: durationSchema$1,
13134
+ styleAndLayoutMs: durationSchema$1,
13135
+ topScriptMs: durationSchema$1,
13136
+ topScriptSource: scriptSourceSchema,
13137
+ topScriptInvoker: _enum$1([
13138
+ "event-listener",
13139
+ "user-callback",
13140
+ "resolve-promise",
13141
+ "reject-promise",
13142
+ "classic-script",
13143
+ "module-script",
13144
+ "none"
13145
+ ]),
13146
+ topScriptEvent: string$1().regex(/^[a-z]{1,32}$/u).optional(),
13147
+ topScriptFile: string$1().regex(/^[\w-][\w.-]{0,124}\.js$/u).optional(),
13148
+ topScriptFunction: string$1().regex(/^[\w$.]{1,80}$/u).optional(),
13149
+ topScriptPosition: number$2().int().min(0).max(MAX_SCRIPT_POSITION).optional(),
13150
+ layerCount: countSchema,
13151
+ topLayerCount: countSchema,
13152
+ builtLayerCount: countSchema,
13153
+ zoomPercent: countSchema,
13154
+ frameNumber: countSchema,
13155
+ skippedCount: countSchema
13156
+ }),
12319
13157
  object$1({
12320
13158
  ...base$1,
12321
13159
  name: literal$1("canvas_measurement"),
@@ -12435,6 +13273,7 @@ unreadableCount: number$2().int().min(0) });
12435
13273
  "clipboard-unavailable",
12436
13274
  "clipboard-image-pending",
12437
13275
  "clipboard-image-unavailable",
13276
+ "paste-content-refused",
12438
13277
  "edit-target-unsupported",
12439
13278
  "edit-result-invalid",
12440
13279
  "react-hook-order",
@@ -12472,6 +13311,7 @@ unreadableCount: number$2().int().min(0) });
12472
13311
  subsystem: _enum$1([
12473
13312
  "menu",
12474
13313
  "menu-picture",
13314
+ "arrival-cue",
12475
13315
  "unknown"
12476
13316
  ]).optional(),
12477
13317
  repeats: count$1.optional(),
@@ -12546,7 +13386,18 @@ unreadableCount: number$2().int().min(0) });
12546
13386
  "whole-value-text",
12547
13387
  "retrying",
12548
13388
  "recovery",
12549
- "trace"
13389
+ "trace",
13390
+ "update-required"
13391
+ ];
13392
+ /** How a failed document read was answered, on the report of one worth a look. */
13393
+ const CANVAS_SYNC_READ_OUTCOMES = [
13394
+ "transient",
13395
+ "no-edit-access",
13396
+ "restored",
13397
+ "replan",
13398
+ "refused",
13399
+ "update-required",
13400
+ "fault"
12550
13401
  ];
12551
13402
  const CANVAS_SYNC_DETAILS = [
12552
13403
  ...CLIENT_SAVE_ISSUES,
@@ -12583,7 +13434,8 @@ unreadableCount: number$2().int().min(0) });
12583
13434
  "view-only",
12584
13435
  "sign-in",
12585
13436
  "gone",
12586
- "restored"
13437
+ "restored",
13438
+ "update-required"
12587
13439
  ];
12588
13440
  /** Whether a recovery state began in this visit or was reopened from the browser copy. */
12589
13441
  const CANVAS_SYNC_EPISODES = ["new", "reopened"];
@@ -12625,6 +13477,7 @@ unreadableCount: number$2().int().min(0) });
12625
13477
  "refused",
12626
13478
  "copy-refused",
12627
13479
  "copy-preview",
13480
+ "update-required",
12628
13481
  "unknown"
12629
13482
  ];
12630
13483
  const CANVAS_SAVE_SEVERITIES = [
@@ -12648,7 +13501,8 @@ unreadableCount: number$2().int().min(0) });
12648
13501
  "retry-upload",
12649
13502
  "choose-file",
12650
13503
  "remove-screen",
12651
- "go-to-canvases"
13504
+ "go-to-canvases",
13505
+ "reload"
12652
13506
  ];
12653
13507
  const CANVAS_SAVE_OUTCOMES = [
12654
13508
  "saved",
@@ -12742,6 +13596,7 @@ unreadableCount: number$2().int().min(0) });
12742
13596
  durationMs: number$2().int().nonnegative(),
12743
13597
  pendingChanges: number$2().int().nonnegative(),
12744
13598
  reason: _enum$1(CANVAS_SYNC_DETAILS).optional(),
13599
+ readOutcome: _enum$1(CANVAS_SYNC_READ_OUTCOMES).optional(),
12745
13600
  status: _enum$1(CANVAS_SYNC_REPORT_STATUSES).optional(),
12746
13601
  episode: _enum$1(CANVAS_SYNC_EPISODES).optional(),
12747
13602
  trace: canvasSaveTraceSchema.optional()
@@ -12995,6 +13850,419 @@ unreadableCount: number$2().int().min(0) });
12995
13850
  })
12996
13851
  ]);
12997
13852
  //#endregion
13853
+ //#region ../capture-browser/src/captured-local-fonts.lib.ts
13854
+ const LOCAL_FONT_ADDRESS = "https://local-fonts.invalid/";
13855
+ const addressOf = (postscriptName) => `${LOCAL_FONT_ADDRESS}${encodeURIComponent(postscriptName)}`;
13856
+ /** Whether an address is one a capture gave an installed font, which no server answers. */
13857
+ const isLocalFontAddress = (url) => url.startsWith(LOCAL_FONT_ADDRESS);
13858
+ /** The CSS weight each style name of an installed face stands for; the first match wins. */
13859
+ const WEIGHT_NAMES = {
13860
+ "100": /thin|hairline/iu,
13861
+ "200": /extra\s*light|ultra\s*light/iu,
13862
+ "600": /semi\s*bold|demi\s*bold/iu,
13863
+ "800": /extra\s*bold|ultra\s*bold/iu,
13864
+ "900": /black|heavy/iu,
13865
+ "300": /light/iu,
13866
+ "500": /medium/iu,
13867
+ "700": /bold/iu
13868
+ };
13869
+ const WEIGHT_ORDER = [
13870
+ "100",
13871
+ "200",
13872
+ "600",
13873
+ "800",
13874
+ "900",
13875
+ "300",
13876
+ "500",
13877
+ "700"
13878
+ ];
13879
+ const REGULAR_WEIGHT = 400;
13880
+ const OPENTYPE_CFF = "OTTO";
13881
+ const SIGNATURE_LENGTH = 4;
13882
+ const weightOf = (style) => Number(WEIGHT_ORDER.find((weight) => WEIGHT_NAMES[weight]?.test(style) === true) ?? REGULAR_WEIGHT);
13883
+ const isFontData = (value) => typeof value === "object" && value !== null && typeof Reflect.get(value, "family") === "string" && typeof Reflect.get(value, "style") === "string" && typeof Reflect.get(value, "postscriptName") === "string" && typeof Reflect.get(value, "blob") === "function";
13884
+ const localFontAccessOf = async (view) => {
13885
+ if (typeof Reflect.get(view, "queryLocalFonts") !== "function") return "none";
13886
+ try {
13887
+ const permissions = Reflect.get(view.navigator, "permissions");
13888
+ const query = typeof permissions === "object" && permissions !== null ? Reflect.get(permissions, "query") : void 0;
13889
+ if (typeof query !== "function") return "none";
13890
+ const status = await Reflect.apply(query, permissions, [{ name: "local-fonts" }]);
13891
+ const state = typeof status === "object" && status !== null ? Reflect.get(status, "state") : void 0;
13892
+ if (state === "granted") return "read";
13893
+ if (state !== "prompt") return "none";
13894
+ return view.navigator.webdriver ? "automated" : "read";
13895
+ } catch {
13896
+ return "none";
13897
+ }
13898
+ };
13899
+ const installedFonts = async (view) => {
13900
+ const query = Reflect.get(view, "queryLocalFonts");
13901
+ if (typeof query !== "function" || await localFontAccessOf(view) !== "read") return [];
13902
+ try {
13903
+ const fonts = await Reflect.apply(query, view, []);
13904
+ return Array.isArray(fonts) ? fonts.filter((font) => isFontData(font)) : [];
13905
+ } catch {
13906
+ return [];
13907
+ }
13908
+ };
13909
+ const typedFontOf = async (body) => {
13910
+ const signature = await body.slice(0, SIGNATURE_LENGTH).text();
13911
+ return new Blob([body], { type: signature === OPENTYPE_CFF ? "font/otf" : "font/ttf" });
13912
+ };
13913
+ /**
13914
+ * Reads the files of the installed fonts a page's text uses, where the browser offers them and the
13915
+ * page already may read them. The stored page then carries the fonts the person saw, so the server
13916
+ * measures with them and everyone who opens the canvas sees them.
13917
+ */
13918
+ const readLocalFontFaces = async (document, families) => {
13919
+ const view = document.defaultView;
13920
+ if (view === null || families.length === 0) return [];
13921
+ const wanted = new Set(families.map((family) => family.toLowerCase()));
13922
+ const fonts = (await installedFonts(view)).filter((font) => wanted.has(font.family.toLowerCase()));
13923
+ return Promise.all(fonts.map(async (font) => ({
13924
+ family: font.family,
13925
+ weight: weightOf(font.style),
13926
+ style: /italic|oblique/iu.test(font.style) ? "italic" : "normal",
13927
+ body: await typedFontOf(await font.blob()),
13928
+ url: addressOf(font.postscriptName)
13929
+ })));
13930
+ };
13931
+ /**
13932
+ * Reads the one installed font an address names, for a path that reads a page's files outside the
13933
+ * page and so holds no faces when it meets the address.
13934
+ */
13935
+ const readLocalFontFile = async (document, url) => {
13936
+ const view = document.defaultView;
13937
+ if (view === null || !isLocalFontAddress(url)) return void 0;
13938
+ const font = (await installedFonts(view)).find((candidate) => addressOf(candidate.postscriptName) === url);
13939
+ if (font === void 0) return void 0;
13940
+ const body = await typedFontOf(await font.blob());
13941
+ return {
13942
+ contentType: body.type,
13943
+ body
13944
+ };
13945
+ };
13946
+ const fontFaceRule = (face) => `@font-face{font-family:${JSON.stringify(face.family)};font-weight:${String(face.weight)};font-style:${face.style};src:url(${JSON.stringify(face.url)})}`;
13947
+ const ELEMENT = 2;
13948
+ const highestIdIn$1 = (node) => Math.max(node.id ?? 0, ...(node.childNodes ?? []).map((child) => highestIdIn$1(child)));
13949
+ const namesIn = (value) => {
13950
+ try {
13951
+ const parsed = JSON.parse(String(value));
13952
+ return Array.isArray(parsed) ? parsed.filter((name) => typeof name === "string") : [];
13953
+ } catch {
13954
+ return [];
13955
+ }
13956
+ };
13957
+ const fieldOf = (value, key) => typeof value === "object" && value !== null ? Reflect.get(value, key) : void 0;
13958
+ /** The installed families the capture recorded the browser could draw, read from its snapshot. */
13959
+ const drawableFontsRecordedIn = (snapshot) => {
13960
+ const children = fieldOf(fieldOf(fieldOf(snapshot, "data"), "node"), "childNodes");
13961
+ const html = Array.isArray(children) ? children.find((child) => fieldOf(child, "tagName") === "html") : void 0;
13962
+ return namesIn(fieldOf(fieldOf(html, "attributes"), CAPTURED_DRAWABLE_FONTS_ATTRIBUTE));
13963
+ };
13964
+ /**
13965
+ * Adds the installed fonts to a page snapshot as faces the page declares and loaded, which is what
13966
+ * they now are for whoever opens the stored page.
13967
+ */
13968
+ const withLocalFontFaces = (snapshot, faces) => {
13969
+ if (typeof snapshot !== "object" || snapshot === null || faces.length === 0) return snapshot;
13970
+ const copy = structuredClone(snapshot);
13971
+ const root = copy.data?.node;
13972
+ const html = root?.childNodes?.find((child) => child.tagName === "html");
13973
+ const head = html?.childNodes?.find((child) => child.tagName === "head");
13974
+ if (root === void 0 || head === void 0 || html?.attributes === void 0) return snapshot;
13975
+ head.childNodes = [...head.childNodes ?? [], {
13976
+ type: ELEMENT,
13977
+ id: highestIdIn$1(root) + 1,
13978
+ tagName: "style",
13979
+ attributes: {
13980
+ "data-enhance-local-fonts": "",
13981
+ _cssText: faces.map((face) => fontFaceRule(face)).join("\n")
13982
+ },
13983
+ childNodes: []
13984
+ }];
13985
+ const families = new Set(faces.map((face) => face.family.toLowerCase()));
13986
+ html.attributes[CAPTURED_LOADED_FONTS_ATTRIBUTE] = JSON.stringify([.../* @__PURE__ */ new Set([...namesIn(html.attributes[CAPTURED_LOADED_FONTS_ATTRIBUTE]), ...faces.map((face) => face.family)])]);
13987
+ html.attributes[CAPTURED_DRAWABLE_FONTS_ATTRIBUTE] = JSON.stringify(namesIn(html.attributes[CAPTURED_DRAWABLE_FONTS_ATTRIBUTE]).filter((name) => !families.has(name.toLowerCase())));
13988
+ return copy;
13989
+ };
13990
+ //#endregion
13991
+ //#region ../capture-browser/src/full-page-window-placed.lib.ts
13992
+ const PERCENT = 100;
13993
+ /** Each makes its element the box that absolute and fixed descendants are placed against. */
13994
+ const CONTAINING_PROPERTIES = [
13995
+ "transform",
13996
+ "perspective",
13997
+ "filter",
13998
+ "backdropFilter"
13999
+ ];
14000
+ const CONTAINING_CONTAINMENT = /\b(?:layout|paint|strict|content)\b/u;
14001
+ const CONTAINING_WILL_CHANGE = /\b(?:transform|perspective|filter)\b/u;
14002
+ const containsPlacedDescendants = (style) => style.position !== "static" || CONTAINING_PROPERTIES.some((property) => {
14003
+ const value = Reflect.get(style, property);
14004
+ return typeof value === "string" && value !== "" && value !== "none";
14005
+ }) || CONTAINING_CONTAINMENT.test(style.contain) || CONTAINING_WILL_CHANGE.test(style.willChange);
14006
+ /** Fixed, or absolute with no ancestor to be placed against: the window places it. */
14007
+ const isPlacedAgainstWindow = (element, style, view) => {
14008
+ if (style.position === "fixed") return true;
14009
+ if (style.position !== "absolute") return false;
14010
+ for (let parent = element.parentElement; parent !== null; parent = parent.parentElement) if (containsPlacedDescendants(view.getComputedStyle(parent))) return false;
14011
+ return true;
14012
+ };
14013
+ const computedValuesOf = (element) => {
14014
+ const read = Reflect.get(element, "computedStyleMap");
14015
+ if (typeof read !== "function") return void 0;
14016
+ const values = Reflect.apply(read, element, []);
14017
+ if (typeof values !== "object" || values === null) return void 0;
14018
+ const get = Reflect.get(values, "get");
14019
+ if (typeof get !== "function") return void 0;
14020
+ return (property) => {
14021
+ const value = Reflect.apply(get, values, [property]);
14022
+ const text = typeof value === "object" && value !== null ? Reflect.get(value, "toString") : void 0;
14023
+ const written = typeof text === "function" ? Reflect.apply(text, value, []) : void 0;
14024
+ return typeof written === "string" ? written : void 0;
14025
+ };
14026
+ };
14027
+ const isAutomatic = (value) => value === void 0 || value === "auto";
14028
+ const PERCENTAGE = /^(-?(?:\d*\.)?\d+)%$/u;
14029
+ /** A plain percentage of the window's height, in pixels. Anything else is left as written. */
14030
+ const percentageOfWindow = (value, window) => {
14031
+ const amount = value === void 0 ? null : PERCENTAGE.exec(value);
14032
+ return amount === null ? void 0 : `${String(Number(amount[1]) * window.height / PERCENT)}px`;
14033
+ };
14034
+ /**
14035
+ * Whether the element's height came from the window: from a top and bottom set together, or from a
14036
+ * percentage. A browser that cannot report computed values is taken to mean yes, which keeps the
14037
+ * picture right and makes a box that hugged its content a box of fixed height.
14038
+ */
14039
+ const heightCameFromWindow = (read) => {
14040
+ if (read === void 0) return true;
14041
+ const height = read("height");
14042
+ if (height?.includes("%") === true) return true;
14043
+ return isAutomatic(height) && !isAutomatic(read("top")) && !isAutomatic(read("bottom"));
14044
+ };
14045
+ /**
14046
+ * The rules that keep a box placed against the window where and as tall as the live window made
14047
+ * it, once the stored page is laid out in a window as tall as the page.
14048
+ */
14049
+ const windowPlacedRules = (element, style, window, view) => {
14050
+ if (!style.top.endsWith("px") || !isPlacedAgainstWindow(element, style, view)) return [];
14051
+ const read = computedValuesOf(element);
14052
+ const limits = ["min-height", "max-height"].flatMap((property) => {
14053
+ const pixels = percentageOfWindow(read?.(property), window);
14054
+ return pixels === void 0 ? [] : [`${property}:${pixels}!important`];
14055
+ });
14056
+ return [
14057
+ `top:${style.top}!important;bottom:auto!important;margin-top:${style.marginTop}!important;margin-bottom:${style.marginBottom}!important`,
14058
+ ...heightCameFromWindow(read) && style.height.endsWith("px") ? [`height:${style.height}!important`] : [],
14059
+ ...limits
14060
+ ];
14061
+ };
14062
+ //#endregion
14063
+ //#region ../capture-browser/src/full-page-capture.lib.ts
14064
+ const PRIMARY_SCROLL_WIDTH_RATIO = .7;
14065
+ const PRIMARY_SCROLL_HEIGHT_RATIO = .5;
14066
+ const hasViewportPixels = (element, width, height) => [...element.getClientRects()].some((box) => box.width > 0 && box.height > 0 && box.right > 0 && box.bottom > 0 && box.left < width && box.top < height) || [...element.children].some((child) => hasViewportPixels(child, width, height)) || element.shadowRoot !== null && [...element.shadowRoot.children].some((child) => hasViewportPixels(child, width, height));
14067
+ /**
14068
+ * The window scrolls the document, and a body whose overflow the root does not set hands its own
14069
+ * to the window. Neither is a scroller inside the page, so neither is opened.
14070
+ */
14071
+ const scrollsTheWindow = (element, view) => {
14072
+ const document = element.ownerDocument;
14073
+ if (element === document.documentElement) return true;
14074
+ if (element !== document.body) return false;
14075
+ const root = view.getComputedStyle(document.documentElement);
14076
+ return root.overflowX === "visible" && root.overflowY === "visible";
14077
+ };
14078
+ const isPrimaryScroller = (element, style, window, view) => element.clientWidth >= window.width * PRIMARY_SCROLL_WIDTH_RATIO && element.clientHeight >= window.height * PRIMARY_SCROLL_HEIGHT_RATIO && element.scrollHeight > element.clientHeight + 1 && [
14079
+ "auto",
14080
+ "scroll",
14081
+ "hidden"
14082
+ ].includes(style.overflowY) && !scrollsTheWindow(element, view);
14083
+ /** A box around an opened scroller may grow to hold it, and never shrinks below its live height. */
14084
+ const growRule = (style) => [
14085
+ "height:auto!important",
14086
+ ...style.height.endsWith("px") ? [`min-height:${style.height}!important`] : [],
14087
+ "max-height:none!important",
14088
+ "overflow-y:visible!important"
14089
+ ].join(";");
14090
+ const ancestorsOf = (element) => {
14091
+ const ancestors = [];
14092
+ for (let parent = element.parentElement; parent !== null; parent = parent.parentElement) ancestors.push(parent);
14093
+ return ancestors;
14094
+ };
14095
+ /**
14096
+ * What scrolls a sticky element: the window, or a scroller the capture opens. A scroller left as
14097
+ * it is still scrolls it, so the element needs nothing.
14098
+ */
14099
+ const scrollPortOf = (element, view, opened) => {
14100
+ for (let parent = element.parentElement; parent !== null; parent = parent.parentElement) {
14101
+ if (opened.includes(parent)) return parent;
14102
+ if (scrollsTheWindow(parent, view)) continue;
14103
+ if (view.getComputedStyle(parent).overflowY !== "visible") return void 0;
14104
+ }
14105
+ return "window";
14106
+ };
14107
+ /**
14108
+ * A box stuck to the bottom of what scrolls it stays where it was held: that bottom is now the
14109
+ * bottom of the whole page, so the box's own offset from it grows by the difference.
14110
+ */
14111
+ const stuckRulesOf = (stuck, page) => [...stuck].flatMap(([element, bottom]) => {
14112
+ const port = scrollPortOf(element, page.view, page.opened);
14113
+ if (port === void 0) return [];
14114
+ const heldAt = port === "window" ? page.window.height : port.getBoundingClientRect().bottom + page.scrolled;
14115
+ return [[element, `bottom:${String(bottom + page.fullHeight - heldAt)}px!important`]];
14116
+ });
14117
+ const windowRulesOf = (document, view, window, captured) => {
14118
+ const rulesOf = /* @__PURE__ */ new Map();
14119
+ const add = (element, rules) => {
14120
+ if (rules.length > 0) rulesOf.set(element, [...rulesOf.get(element) ?? [], ...rules]);
14121
+ };
14122
+ const scrolled = document.scrollingElement?.scrollTop ?? 0;
14123
+ const opened = [];
14124
+ const stuck = /* @__PURE__ */ new Map();
14125
+ let fullHeight = Math.max(window.height, document.documentElement.scrollHeight, document.body.scrollHeight);
14126
+ const elements = [...document.querySelectorAll("*")].filter((element) => captured(element));
14127
+ for (const element of elements) {
14128
+ const style = view.getComputedStyle(element);
14129
+ add(element, windowPlacedRules(element, style, window, view));
14130
+ if (style.position === "fixed" && !hasViewportPixels(element, window.width, window.height)) add(element, ["display:none!important"]);
14131
+ if (style.position === "sticky" && style.bottom.endsWith("px")) stuck.set(element, Number(style.bottom.slice(0, -2)));
14132
+ if (!isPrimaryScroller(element, style, window, view)) continue;
14133
+ const extent = element.scrollHeight;
14134
+ fullHeight = Math.max(fullHeight, Math.ceil(element.getBoundingClientRect().top + scrolled + extent));
14135
+ add(element, [`height:${String(extent)}px!important;max-height:none!important;overflow-y:visible!important`]);
14136
+ opened.push(element);
14137
+ }
14138
+ const stuckRules = stuckRulesOf(stuck, {
14139
+ view,
14140
+ opened,
14141
+ fullHeight,
14142
+ scrolled,
14143
+ window
14144
+ });
14145
+ for (const [element, rule] of stuckRules) add(element, [rule]);
14146
+ const around = new Set(opened.flatMap((element) => ancestorsOf(element)));
14147
+ for (const element of around) if (!opened.includes(element)) add(element, [growRule(view.getComputedStyle(element))]);
14148
+ const root = document.documentElement;
14149
+ if (opened.length === 0 && fullHeight > window.height && Math.abs(root.getBoundingClientRect().height - window.height) < 1) add(root, [`height:${String(window.height)}px!important`]);
14150
+ return {
14151
+ rulesOf,
14152
+ fullHeight
14153
+ };
14154
+ };
14155
+ /** What a stylesheet takes from the live window: its size, and the answer to a media condition. */
14156
+ const liveWindowOf = (document) => {
14157
+ const view = document.defaultView;
14158
+ const sized = document.compatMode === "BackCompat" ? document.body : document.documentElement;
14159
+ return {
14160
+ width: sized.clientWidth,
14161
+ height: sized.clientHeight,
14162
+ matchesMedia: (condition) => view?.matchMedia(condition).matches ?? false
14163
+ };
14164
+ };
14165
+ /**
14166
+ * Freezes a stylesheet's text with the live window's values, as a whole-page capture freezes the
14167
+ * CSS it carries. For a path that reads stylesheet files outside the page.
14168
+ */
14169
+ const fullPageStylesheetFreeze = (document) => {
14170
+ const options = {
14171
+ ...liveWindowOf(document),
14172
+ overrides: /* @__PURE__ */ new Map()
14173
+ };
14174
+ return (css) => fullPageScreenCss(css, options);
14175
+ };
14176
+ const ROOT_RULE = "overflow:visible!important";
14177
+ /**
14178
+ * Puts the rules a whole-page capture stores on the live page, so a picture taken beyond the
14179
+ * window shows what the stored page shows, and answers with how to take them off again. The
14180
+ * window keeps its size, so nothing sized by it moves.
14181
+ */
14182
+ const applyFullPageRules = (document) => {
14183
+ const view = document.defaultView;
14184
+ const window = liveWindowOf(document);
14185
+ if (view === null) return {
14186
+ height: window.height,
14187
+ restore: () => {}
14188
+ };
14189
+ const { rulesOf, fullHeight } = windowRulesOf(document, view, window, () => true);
14190
+ const rules = new Map(rulesOf);
14191
+ for (const root of [document.documentElement, document.body]) {
14192
+ const style = view.getComputedStyle(root);
14193
+ if (style.overflowX !== "visible" || style.overflowY !== "visible") rules.set(root, [...rules.get(root) ?? [], ROOT_RULE]);
14194
+ }
14195
+ const written = Array.from(rules, ([element, added]) => {
14196
+ const style = element.getAttribute("style");
14197
+ element.setAttribute("style", [style ?? "", ...added].join(";"));
14198
+ return [element, style];
14199
+ });
14200
+ return {
14201
+ height: fullHeight,
14202
+ restore: () => {
14203
+ for (const [element, style] of written) {
14204
+ element.toggleAttribute("style", style !== null);
14205
+ if (style !== null) element.setAttribute("style", style);
14206
+ }
14207
+ }
14208
+ };
14209
+ };
14210
+ const fullPageCaptureLayout = (document, idForNode) => {
14211
+ const live = liveWindowOf(document);
14212
+ const { width, height } = live;
14213
+ const view = document.defaultView;
14214
+ const { rulesOf, fullHeight } = view === null ? {
14215
+ rulesOf: /* @__PURE__ */ new Map(),
14216
+ fullHeight: Math.max(height, document.documentElement.scrollHeight, document.body.scrollHeight)
14217
+ } : windowRulesOf(document, view, {
14218
+ width,
14219
+ height
14220
+ }, (element) => idForNode(element) >= 0);
14221
+ const overrides = new Map(Array.from(rulesOf, ([element, rules]) => [idForNode(element), rules.join(";")]));
14222
+ return {
14223
+ options: {
14224
+ ...live,
14225
+ overrides
14226
+ },
14227
+ viewport: {
14228
+ width,
14229
+ height: fullHeight
14230
+ }
14231
+ };
14232
+ };
14233
+ //#endregion
14234
+ //#region ../capture-browser/src/capture-kernel-calls.lib.ts
14235
+ /** Where the page keeps the way back from the picture's rules, between two calls from Node. */
14236
+ const RESTORE = Symbol.for("enhance.capture.restore-picture-rules");
14237
+ const CHUNK = 32768;
14238
+ const base64Of = async (body) => {
14239
+ const bytes = new Uint8Array(await body.arrayBuffer());
14240
+ let binary = "";
14241
+ for (let start = 0; start < bytes.length; start += CHUNK) binary += String.fromCodePoint(...bytes.subarray(start, start + CHUNK));
14242
+ return btoa(binary);
14243
+ };
14244
+ /** One installed font's file, in a form that crosses from the page to Node. */
14245
+ const localFontFileBase64 = async (document, url) => {
14246
+ const file = await readLocalFontFile(document, url);
14247
+ return file === void 0 ? null : {
14248
+ contentType: file.contentType,
14249
+ base64: await base64Of(file.body)
14250
+ };
14251
+ };
14252
+ /**
14253
+ * Puts the stored page's rules on the live page for a picture. The picture is taken from Node, so
14254
+ * the way back waits on the page between this call and `closeAfterPicture`.
14255
+ */
14256
+ const openForPicture = (document) => {
14257
+ closeAfterPicture();
14258
+ Reflect.set(globalThis, RESTORE, applyFullPageRules(document).restore);
14259
+ };
14260
+ const closeAfterPicture = () => {
14261
+ const restore = Reflect.get(globalThis, RESTORE);
14262
+ Reflect.deleteProperty(globalThis, RESTORE);
14263
+ if (typeof restore === "function") Reflect.apply(restore, void 0, []);
14264
+ };
14265
+ //#endregion
12998
14266
  //#region ../capture-browser/src/cssom-style-correction.lib.ts
12999
14267
  const EMPTY_DECLARATION = /(?<=[{;])\s*([-\w]+)\s*:\s*;/dgu;
13000
14268
  const erasedProperties = (cssText) => {
@@ -13093,48 +14361,6 @@ unreadableCount: number$2().int().min(0) });
13093
14361
  return serialized;
13094
14362
  };
13095
14363
  //#endregion
13096
- //#region ../capture-browser/src/full-page-capture.lib.ts
13097
- const PRIMARY_SCROLL_WIDTH_RATIO = .7;
13098
- const PRIMARY_SCROLL_HEIGHT_RATIO = .5;
13099
- const hasViewportPixels = (element, width, height) => [...element.getClientRects()].some((box) => box.width > 0 && box.height > 0 && box.right > 0 && box.bottom > 0 && box.left < width && box.top < height) || [...element.children].some((child) => hasViewportPixels(child, width, height)) || element.shadowRoot !== null && [...element.shadowRoot.children].some((child) => hasViewportPixels(child, width, height));
13100
- const fixedPositionRules = (element, style, width, height) => [`top:${style.top}!important;bottom:auto!important;margin-top:${style.marginTop}!important;margin-bottom:${style.marginBottom}!important`, ...hasViewportPixels(element, width, height) ? [] : ["display:none!important"]];
13101
- const fullPageCaptureLayout = (document, idForNode) => {
13102
- const width = document.documentElement.clientWidth;
13103
- const height = document.documentElement.clientHeight;
13104
- const view = document.defaultView;
13105
- let fullHeight = Math.max(height, document.documentElement.scrollHeight, document.body.scrollHeight);
13106
- const overrides = /* @__PURE__ */ new Map();
13107
- if (view !== null) for (const element of document.querySelectorAll("*")) {
13108
- const id = idForNode(element);
13109
- if (id < 0) continue;
13110
- const style = view.getComputedStyle(element);
13111
- const rules = [];
13112
- if (style.position === "fixed") rules.push(...fixedPositionRules(element, style, width, height));
13113
- if (element.clientWidth >= width * PRIMARY_SCROLL_WIDTH_RATIO && element.clientHeight >= height * PRIMARY_SCROLL_HEIGHT_RATIO && element.scrollHeight > element.clientHeight + 1 && [
13114
- "auto",
13115
- "scroll",
13116
- "hidden"
13117
- ].includes(style.overflowY)) {
13118
- const extent = element.scrollHeight;
13119
- fullHeight = Math.max(fullHeight, Math.ceil(element.getBoundingClientRect().top + (document.scrollingElement?.scrollTop ?? 0) + extent));
13120
- rules.push(`height:${String(extent)}px!important;max-height:none!important;overflow-y:visible!important`);
13121
- }
13122
- overrides.set(id, rules.join(";"));
13123
- }
13124
- return {
13125
- options: {
13126
- width,
13127
- height,
13128
- overrides: new Map([...overrides].filter(([, rule]) => rule !== "")),
13129
- matchesMedia: (condition) => view?.matchMedia(condition).matches ?? false
13130
- },
13131
- viewport: {
13132
- width,
13133
- height: fullHeight
13134
- }
13135
- };
13136
- };
13137
- //#endregion
13138
14364
  //#region ../capture-browser/src/marked-snapshot-tree.lib.ts
13139
14365
  const isRecord$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
13140
14366
  const childEntries = (record) => Object.entries(record).filter(([key]) => key !== "attributes");
@@ -17478,6 +18704,79 @@ unreadableCount: number$2().int().min(0) });
17478
18704
  postcss.Root;
17479
18705
  postcss.Node;
17480
18706
  //#endregion
18707
+ //#region ../capture-browser/src/captured-drawable-fonts.lib.ts
18708
+ const PROBE_TEXT = "mmmmmmmmmmlli1WQ@#";
18709
+ const PROBE_SIZE = "72px";
18710
+ const FALLBACKS = [
18711
+ "monospace",
18712
+ "serif",
18713
+ "sans-serif"
18714
+ ];
18715
+ const unquoted = (family) => family.trim().replace(/^(['"])(.*)\1$/u, "$2");
18716
+ /** The families a computed font stack names, in order. */
18717
+ const familiesOf = (stack) => stack.split(",").map((family) => unquoted(family)).filter((family) => family !== "");
18718
+ const declaredFamiliesOf = (document) => {
18719
+ const declared = /* @__PURE__ */ new Set();
18720
+ const fonts = Reflect.get(document, "fonts");
18721
+ const forEach = typeof fonts === "object" && fonts !== null ? Reflect.get(fonts, "forEach") : null;
18722
+ if (typeof forEach !== "function") return declared;
18723
+ Reflect.apply(forEach, fonts, [(face) => {
18724
+ const family = typeof face === "object" && face !== null ? Reflect.get(face, "family") : null;
18725
+ if (typeof family === "string") declared.add(unquoted(family).toLowerCase());
18726
+ }]);
18727
+ return declared;
18728
+ };
18729
+ /** The width of the probe string in a font, measured on a canvas of its own. */
18730
+ const probeWidth = (document, font) => {
18731
+ const context = document.createElement("canvas").getContext("2d");
18732
+ if (context === null) return null;
18733
+ context.font = font;
18734
+ return context.measureText(PROBE_TEXT).width;
18735
+ };
18736
+ /** A generic family is a keyword, and quoting it would ask for an installed font of that name. */
18737
+ const probeNameOf = (family) => isCanvasGenericFontFamily(family) ? family : `"${family.replaceAll("\"", String.raw`\"`)}"`;
18738
+ /**
18739
+ * Whether the browser draws a family: a string measured in it differs in width from the same
18740
+ * string in at least one generic family. The long-standing way to tell an installed font in a page.
18741
+ * A generic family the browser does not know, as `ui-monospace` is to Chrome, measures as the
18742
+ * fallback each time, so it is one the browser cannot draw.
18743
+ */
18744
+ const canDrawFontFamily = (document, family) => FALLBACKS.some((fallback) => {
18745
+ const plain = probeWidth(document, `${PROBE_SIZE} ${fallback}`);
18746
+ const named = probeWidth(document, `${PROBE_SIZE} ${probeNameOf(family)}, ${fallback}`);
18747
+ return plain !== null && named !== null && named !== plain;
18748
+ });
18749
+ /**
18750
+ * The installed families the page's text is drawn in: for each element, the first family in its
18751
+ * stack that the browser can draw, when the page supplies no face for it and it is no generic
18752
+ * family. A later family is a last resort, as the emoji fonts that end Tailwind's default stack
18753
+ * are, and is neither sent nor asked for. The converting machine may lack what is found here.
18754
+ */
18755
+ const drawableUndeclaredFamilies = (document, blockSelector = ":not(*)") => {
18756
+ const view = document.defaultView;
18757
+ if (view === null) return [];
18758
+ const declared = declaredFamiliesOf(document);
18759
+ const drawable = /* @__PURE__ */ new Map();
18760
+ const isDrawn = (family) => {
18761
+ const key = family.toLowerCase();
18762
+ const wasDrawn = drawable.get(key);
18763
+ if (wasDrawn !== void 0) return wasDrawn;
18764
+ const isDrawable = declared.has(key) || canDrawFontFamily(document, family);
18765
+ drawable.set(key, isDrawable);
18766
+ return isDrawable;
18767
+ };
18768
+ const firstOf = /* @__PURE__ */ new Map();
18769
+ const used = /* @__PURE__ */ new Set();
18770
+ for (const element of document.querySelectorAll("*")) {
18771
+ if (element.closest(blockSelector) !== null) continue;
18772
+ const stack = view.getComputedStyle(element).fontFamily;
18773
+ if (!firstOf.has(stack)) firstOf.set(stack, familiesOf(stack).find((family) => isDrawn(family)));
18774
+ const first = firstOf.get(stack);
18775
+ if (first !== void 0 && !isCanvasGenericFontFamily(first) && !declared.has(first.toLowerCase())) used.add(first);
18776
+ }
18777
+ return [...used];
18778
+ };
18779
+ //#endregion
17481
18780
  //#region ../capture-browser/src/captured-font-evidence.lib.ts
17482
18781
  /** The families with a face the page tried and could not load, and no face it did load. */
17483
18782
  const unavailableFontFamilies = (fonts, loaded) => {
@@ -17494,15 +18793,17 @@ unreadableCount: number$2().int().min(0) });
17494
18793
  return [...failed];
17495
18794
  };
17496
18795
  /**
17497
- * Keeps the page's font evidence: the families it loaded, which a replay may not rebuild, and
17498
- * those it could not, so a conversion does not count them as fonts the capture lost.
18796
+ * Keeps the page's font evidence: the families it loaded, which a replay may not rebuild, those it
18797
+ * could not, so a conversion does not count them as fonts the capture lost, and the installed
18798
+ * families it could draw, which the converting machine may not have.
17499
18799
  */
17500
- const markCapturedFontEvidence = (node, document) => {
18800
+ const markCapturedFontEvidence = (node, document, blockSelector) => {
17501
18801
  const html = node?.childNodes?.find((child) => child.tagName === "html");
17502
18802
  if (html?.attributes === void 0) return;
17503
18803
  const loaded = loadedCapturedFontFamilies(document.fonts);
17504
18804
  Reflect.set(html.attributes, CAPTURED_LOADED_FONTS_ATTRIBUTE, JSON.stringify(loaded));
17505
18805
  Reflect.set(html.attributes, CAPTURED_UNAVAILABLE_FONTS_ATTRIBUTE, JSON.stringify(unavailableFontFamilies(document.fonts, new Set(loaded))));
18806
+ Reflect.set(html.attributes, CAPTURED_DRAWABLE_FONTS_ATTRIBUTE, JSON.stringify(drawableUndeclaredFamilies(document, blockSelector)));
17506
18807
  };
17507
18808
  //#endregion
17508
18809
  //#region ../capture-browser/src/snapshot-document.lib.ts
@@ -17577,8 +18878,10 @@ unreadableCount: number$2().int().min(0) });
17577
18878
  ...options.blockSelector !== void 0 && { blockSelector: options.blockSelector },
17578
18879
  onSerialize: options.onSerialize
17579
18880
  });
17580
- markCapturedFontEvidence(node, document);
17581
- return node === null ? null : withReadableCanvasPixels(node, (id) => mirror.getNode(id));
18881
+ markCapturedFontEvidence(node, document, options.blockSelector);
18882
+ if (node === null) return null;
18883
+ const nodeForId = (id) => mirror.getNode(id);
18884
+ return withMeasuredPlaceholders(withCapturedMedia(withReadableCanvasPixels(withCdataAsText(node, nodeForId, absolutifyURLs), nodeForId), nodeForId), nodeForId);
17582
18885
  };
17583
18886
  const isBlocked = (node, selector) => {
17584
18887
  const matches = Reflect.get(node, "matches");
@@ -17821,15 +19124,52 @@ unreadableCount: number$2().int().min(0) });
17821
19124
  };
17822
19125
  //#endregion
17823
19126
  //#region ../capture-browser/src/root-style-hint.lib.ts
19127
+ const NAMES_A_FILE = "url(";
19128
+ /** A page may not read a stylesheet from another origin, and the browser throws if it tries. */
19129
+ const rulesOf = (sheet) => {
19130
+ try {
19131
+ return [...sheet.cssRules];
19132
+ } catch {
19133
+ return [];
19134
+ }
19135
+ };
19136
+ const rememberDeclaredAddresses = (style, base, found) => {
19137
+ for (const property of style) {
19138
+ if (!property.startsWith("--")) continue;
19139
+ const written = assetUrlsInCss(style.getPropertyValue(property));
19140
+ for (const reference of written) {
19141
+ const [address = ""] = reference.split("#", 1);
19142
+ const absolute = URL.parse(address) === null ? URL.parse(address, base) : null;
19143
+ if (address !== "" && absolute !== null) found.set(address, absolute.href);
19144
+ }
19145
+ }
19146
+ };
19147
+ const rememberAddressesInRules = (rules, base, found, pageBase) => {
19148
+ for (const rule of rules) {
19149
+ if (rule.style !== void 0) rememberDeclaredAddresses(rule.style, base, found);
19150
+ if (rule.cssRules !== void 0) rememberAddressesInRules([...rule.cssRules], base, found, pageBase);
19151
+ if (rule.styleSheet !== void 0 && rule.styleSheet !== null) rememberAddressesInRules(rulesOf(rule.styleSheet), rule.styleSheet.href ?? pageBase, found, pageBase);
19152
+ }
19153
+ };
19154
+ /** Each relative address written in a custom property, as the stylesheet declaring it means it. */
19155
+ const addressesDeclaredInStylesheets = (document) => {
19156
+ const found = /* @__PURE__ */ new Map();
19157
+ for (const sheet of document.styleSheets) rememberAddressesInRules(rulesOf(sheet), sheet.href ?? document.baseURI, found, document.baseURI);
19158
+ return found;
19159
+ };
19160
+ /**
19161
+ * @justified intent
19162
+ * A custom property's computed value keeps `url()` as the stylesheet wrote it, and the browser
19163
+ * resolves it against that stylesheet. Pinned on the root element it would resolve against the
19164
+ * page instead, so an address in `/assets/index.css` would name a file that does not exist.
19165
+ */
17824
19166
  const captureRootStyle = (document) => {
17825
19167
  const pinned = document.createElement("div").style;
17826
19168
  const computed = document.defaultView?.getComputedStyle(document.documentElement);
17827
19169
  if (computed === void 0) return "";
17828
- for (const property of computed) {
17829
- if (!property.startsWith("--")) continue;
17830
- const value = computed.getPropertyValue(property);
17831
- if (value !== "") pinned.setProperty(property, value);
17832
- }
19170
+ const properties = [...computed].filter((property) => property.startsWith("--")).map((property) => [property, computed.getPropertyValue(property)]).filter(([, value]) => value !== "");
19171
+ const addresses = properties.some(([, value]) => value.includes(NAMES_A_FILE)) ? addressesDeclaredInStylesheets(document) : /* @__PURE__ */ new Map();
19172
+ for (const [property, value] of properties) pinned.setProperty(property, value.includes(NAMES_A_FILE) ? rewriteCssAssetUrls(value, addresses, document.baseURI) : value);
17833
19173
  return pinned.cssText;
17834
19174
  };
17835
19175
  const withRootStyle = (attributes, rootStyle) => {
@@ -18167,7 +19507,7 @@ unreadableCount: number$2().int().min(0) });
18167
19507
  /** Captures synchronously, then permits resource retention before the same snapshot is frozen. */
18168
19508
  const prepareBrowserScreen = (document, options) => {
18169
19509
  const marked = captureMarkedSnapshot(document, options.atMs ?? 0, {
18170
- blockSelector: options.blockSelector ?? ":not(*)",
19510
+ blockSelector: options.blockSelector ?? "audio[controls]",
18171
19511
  fullPage: options.extent === "full-page",
18172
19512
  ...options.inlineStylesheet !== void 0 && { inlineStylesheet: options.inlineStylesheet }
18173
19513
  });
@@ -18195,15 +19535,69 @@ unreadableCount: number$2().int().min(0) });
18195
19535
  }
18196
19536
  }
18197
19537
  });
19538
+ const fullPage = marked.fullPage;
19539
+ const freezeStylesheet = fullPage === null ? null : (css) => fullPageScreenCss(css, fullPage.options);
18198
19540
  return {
18199
19541
  documents: marked.documents,
18200
19542
  nodeForId: marked.nodeForId,
18201
- finish
19543
+ finish,
19544
+ freezeStylesheet,
19545
+ drawableFonts: drawableFontsRecordedIn(marked.snapshot)
18202
19546
  };
18203
19547
  };
18204
19548
  const captureBrowserScreen = (document, options) => prepareBrowserScreen(document, options).finish();
18205
19549
  //#endregion
19550
+ //#region ../capture-browser/src/capture-page.lib.ts
19551
+ /** What a program driving the browser can do so the page's installed fonts travel with it. */
19552
+ const LOCAL_FONTS_NOT_GRANTED = {
19553
+ code: "local-fonts-not-granted",
19554
+ message: "This page uses fonts installed on this machine, and they were not sent. Grant the page the \"local-fonts\" permission and capture again to include them: in Playwright, await context.grantPermissions([\"local-fonts\"])."
19555
+ };
19556
+ const frozenWith = async (document, options, readFonts) => {
19557
+ let fonts = [];
19558
+ const prepared = prepareBrowserScreen(document, {
19559
+ ...options,
19560
+ beforeFreeze: (hinted) => {
19561
+ const added = options.beforeFreeze?.(hinted) ?? hinted;
19562
+ return {
19563
+ ...added,
19564
+ snapshot: withLocalFontFaces(added.snapshot, fonts)
19565
+ };
19566
+ }
19567
+ });
19568
+ fonts = await readFonts(prepared.drawableFonts);
19569
+ return {
19570
+ screen: prepared.finish(),
19571
+ fonts,
19572
+ freezeStylesheet: prepared.freezeStylesheet
19573
+ };
19574
+ };
19575
+ /** Reads the installed fonts in the page, and says when a program must grant that first. */
19576
+ const frozenInPage = async (document, options) => {
19577
+ const noted = { isGrantMissing: false };
19578
+ const frozen = await frozenWith(document, options, async (families) => {
19579
+ noted.isGrantMissing = families.length > 0 && document.defaultView !== null && await localFontAccessOf(document.defaultView) === "automated";
19580
+ return readLocalFontFaces(document, families);
19581
+ });
19582
+ return noted.isGrantMissing ? {
19583
+ ...frozen,
19584
+ screen: {
19585
+ ...frozen.screen,
19586
+ issues: [...frozen.screen.issues, LOCAL_FONTS_NOT_GRANTED]
19587
+ }
19588
+ } : frozen;
19589
+ };
19590
+ async function freezeCapturedPage(document, options) {
19591
+ const { readFonts, ...freeze } = options;
19592
+ return readFonts === void 0 ? frozenInPage(document, freeze) : frozenWith(document, freeze, readFonts);
19593
+ }
19594
+ //#endregion
18206
19595
  exports.captureBrowserScreen = captureBrowserScreen;
19596
+ exports.closeAfterPicture = closeAfterPicture;
19597
+ exports.freezeCapturedPage = freezeCapturedPage;
18207
19598
  exports.fullPageCaptureLayout = fullPageCaptureLayout;
19599
+ exports.fullPageStylesheetFreeze = fullPageStylesheetFreeze;
19600
+ exports.localFontFileBase64 = localFontFileBase64;
19601
+ exports.openForPicture = openForPicture;
18208
19602
  return exports;
18209
19603
  })({});