calmlens 0.36.0 → 0.37.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/README.md +2 -0
  2. package/bin/calmlens.js +23 -7
  3. package/cjs/{BrowserUpload-Bwfz85Id.js → BrowserUpload-84KQWr1Q.js} +1 -1
  4. package/cjs/{BrowserUpload-BGxUQPHj.d.ts → BrowserUpload-CuG3tWSo.d.ts} +2 -2
  5. package/cjs/{CalmLensAppClient-CBIAVX_e.js → CalmLensAppClient-D4tRb_P2.js} +2 -2
  6. package/cjs/{CalmLensAppClient-0to4ZZ7i.d.ts → CalmLensAppClient-QqtovWE-.d.ts} +1 -1
  7. package/cjs/{CalmLensCdn-Bfcr9qta.js → CalmLensCdn-CdYY_XtK.js} +1 -1
  8. package/cjs/{CalmLensConnection-By-EsCNB.js → CalmLensConnection-GkR2cKn5.js} +24 -11
  9. package/cjs/{CalmLensServerClient-BfkTpKwB.js → CalmLensServerClient-cgPOG4Sv.js} +3 -2
  10. package/cjs/{CalmLensServerClient-CiiaFN7R.d.ts → CalmLensServerClient-csSQqHBt.d.ts} +2 -2
  11. package/cjs/{CalmLensTestInputArguments-PYuRmE0j.js → CalmLensTestInputArguments-C6S09FVQ.js} +7 -1
  12. package/cjs/{CalmLensTypes-9kLIOd1C.d.ts → CalmLensTypes-_f7QVRtO.d.ts} +2 -2
  13. package/cjs/{Core-CFxvTass.d.ts → Core-4iFxKJnY.d.ts} +2 -2
  14. package/cjs/{Core-BcFDI-t4.js → Core-BlnBBJKb.js} +2 -2
  15. package/cjs/{ReactUpload-Dso2ir_F.d.ts → ReactUpload-4qd2xACg.d.ts} +1 -1
  16. package/cjs/{ReactUpload-DtqkbRO8.js → ReactUpload-D3AYIZBh.js} +1 -1
  17. package/cjs/{UploadController-DDLX2yS9.js → UploadController-BYuHuZ7K.js} +1 -1
  18. package/cjs/{WebhookPayload-Cv2uwykA.d.ts → WebhookPayload-BJtggTLd.d.ts} +1 -1
  19. package/cjs/app.d.ts +4 -4
  20. package/cjs/app.js +2 -2
  21. package/cjs/elements.d.ts +4 -4
  22. package/cjs/elements.js +4 -4
  23. package/cjs/{index-D-ZwYNRQ.d.ts → index-IEA75nev.d.ts} +2 -2
  24. package/cjs/index.d.ts +3 -3
  25. package/cjs/index.js +1 -1
  26. package/cjs/react-native.d.ts +2 -2
  27. package/cjs/react-native.js +4 -4
  28. package/cjs/react.d.ts +4 -4
  29. package/cjs/react.js +5 -5
  30. package/cjs/server.d.ts +4 -4
  31. package/cjs/server.js +2 -2
  32. package/cjs/test-inputs.js +1 -1
  33. package/cjs/testing.d.ts +20 -6
  34. package/cjs/testing.js +116 -11
  35. package/cjs/{ui-BkOZ_jV_.d.ts → ui-BMQW3Hse.d.ts} +2 -2
  36. package/cjs/{ui-TblNKrne.js → ui-Cy8MWXOw.js} +2 -2
  37. package/cjs/ui.d.ts +2 -2
  38. package/cjs/ui.js +3 -3
  39. package/cjs/vue.d.ts +5 -5
  40. package/cjs/vue.js +4 -4
  41. package/esm/{BrowserUpload-CLnrvVO0.js → BrowserUpload-C429CcUi.js} +1 -1
  42. package/esm/{BrowserUpload-BGxUQPHj.d.ts → BrowserUpload-CuG3tWSo.d.ts} +2 -2
  43. package/esm/{CalmLensAppClient-C3RuoUjN.js → CalmLensAppClient-Brvc-GXt.js} +2 -2
  44. package/esm/{CalmLensAppClient-0to4ZZ7i.d.ts → CalmLensAppClient-QqtovWE-.d.ts} +1 -1
  45. package/esm/{CalmLensCdn-DOdnpbSx.js → CalmLensCdn-cmxtF_dw.js} +1 -1
  46. package/esm/{CalmLensConnection-5EryxQTJ.js → CalmLensConnection-DEfpIugc.js} +24 -11
  47. package/esm/{CalmLensServerClient-DNMqxkhS.js → CalmLensServerClient-BpsCXVeO.js} +3 -2
  48. package/esm/{CalmLensServerClient-CiiaFN7R.d.ts → CalmLensServerClient-csSQqHBt.d.ts} +2 -2
  49. package/esm/{CalmLensTestInputArguments-CqPADTkl.js → CalmLensTestInputArguments-DS_3mt1C.js} +2 -2
  50. package/esm/{CalmLensTypes-9kLIOd1C.d.ts → CalmLensTypes-_f7QVRtO.d.ts} +2 -2
  51. package/esm/{Core-CFxvTass.d.ts → Core-4iFxKJnY.d.ts} +2 -2
  52. package/esm/{Core-CFceeESh.js → Core-C_f1o9RQ.js} +2 -2
  53. package/esm/{ReactUpload-Dso2ir_F.d.ts → ReactUpload-4qd2xACg.d.ts} +1 -1
  54. package/esm/{ReactUpload-H5rXCKLT.js → ReactUpload-Ch5qY7PS.js} +1 -1
  55. package/esm/{UploadController-Djvf_J_v.js → UploadController-9fkYFVZM.js} +1 -1
  56. package/esm/{WebhookPayload-Cv2uwykA.d.ts → WebhookPayload-BJtggTLd.d.ts} +1 -1
  57. package/esm/app.d.ts +4 -4
  58. package/esm/app.js +2 -2
  59. package/esm/elements.d.ts +4 -4
  60. package/esm/elements.js +4 -4
  61. package/esm/{index-D-ZwYNRQ.d.ts → index-IEA75nev.d.ts} +2 -2
  62. package/esm/index.d.ts +3 -3
  63. package/esm/index.js +1 -1
  64. package/esm/react-native.d.ts +2 -2
  65. package/esm/react-native.js +4 -4
  66. package/esm/react.d.ts +4 -4
  67. package/esm/react.js +5 -5
  68. package/esm/server.d.ts +4 -4
  69. package/esm/server.js +2 -2
  70. package/esm/test-inputs.js +1 -1
  71. package/esm/testing.d.ts +20 -6
  72. package/esm/testing.js +116 -11
  73. package/esm/{ui-BkOZ_jV_.d.ts → ui-BMQW3Hse.d.ts} +2 -2
  74. package/esm/{ui-C6wYNQgD.js → ui-HK74e42L.js} +2 -2
  75. package/esm/ui.d.ts +2 -2
  76. package/esm/ui.js +3 -3
  77. package/esm/vue.d.ts +5 -5
  78. package/esm/vue.js +4 -4
  79. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_CalmLensTestInputArguments = require("./CalmLensTestInputArguments-PYuRmE0j.js");
2
+ const require_CalmLensTestInputArguments = require("./CalmLensTestInputArguments-C6S09FVQ.js");
3
3
  // src/client/TestImagePng.ts
4
4
  /**
5
5
  * Encodes a painted test image as a PNG: 8-bit RGBA rows without filtering in stored deflate
package/cjs/testing.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { Jt as SignedUploadToken, Kt as SignUploadTokenOptions, Ln as PermissionGrant, Nn as TypedEvent, O as CalmLensAppClientOptions, Rn as Folder, Vn as AssetBinaryPayloadInput, k as CalmLensServerClientOptions, m as AssetModeration, on as UploadPresetDefinition, r as Asset } from "./CalmLensTypes-9kLIOd1C.js";
2
- import { t as CalmLensAppClient } from "./CalmLensAppClient-0to4ZZ7i.js";
3
- import { I as ApiErrorCode, n as WebhookEventPayload } from "./WebhookPayload-Cv2uwykA.js";
4
- import { t as CalmLensServerClient } from "./CalmLensServerClient-CiiaFN7R.js";
1
+ import { Jt as SignedUploadToken, Kt as SignUploadTokenOptions, Ln as PermissionGrant, Nn as TypedEvent, O as CalmLensAppClientOptions, Rn as Folder, Vn as AssetBinaryPayloadInput, k as CalmLensServerClientOptions, m as AssetModeration, on as UploadPresetDefinition, r as Asset } from "./CalmLensTypes-_f7QVRtO.js";
2
+ import { t as CalmLensAppClient } from "./CalmLensAppClient-QqtovWE-.js";
3
+ import { I as ApiErrorCode, n as WebhookEventPayload } from "./WebhookPayload-BJtggTLd.js";
4
+ import { t as CalmLensServerClient } from "./CalmLensServerClient-csSQqHBt.js";
5
5
  import { t as ClassificationTestSignal } from "./TestTriggers-CjDhhz78.js";
6
6
  import "zod";
7
7
  /**
@@ -84,6 +84,10 @@ type MockDetectedLink = EvaluatedFeature<"linkDetection">["links"][number];
84
84
  type MockDetectedPerson = EvaluatedFeature<"personDetection">["people"][number];
85
85
  /** A face that face detection found, as `classification.faceDetection.faces` reports one. */
86
86
  type MockDetectedFace = EvaluatedFeature<"faceDetection">["faces"][number];
87
+ /** A stricter status in one jurisdiction, as `classification.moderation.regions` reports one. */
88
+ type MockRegionalDecision = AssetModeration["regions"][number];
89
+ type Region = MockRegionalDecision["region"];
90
+ type RegionalStatus = MockRegionalDecision["status"];
87
91
  /** Why a decision waits for human review: `sampled`, or `uncertain` about some categories. */
88
92
  type MockPendingReviewReason = "sampled" | "uncertain";
89
93
  /**
@@ -104,6 +108,15 @@ export declare class MockDecision {
104
108
  flag(category: Category, score: number, qualifiers?: Record<string, number>): this;
105
109
  /** Marks `category` as not assessed (`not-evaluated` for reason `not-supported`). */
106
110
  notEvaluated(category: Category): this;
111
+ /**
112
+ * Adds a stricter `status` for viewers under the jurisdiction `region` (`DE`, `AT`, `FR`, `GB`,
113
+ * `EU`, `AU` or `BR`), set by the mandatory `rule`, optionally acting on `category`, as
114
+ * `classification.moderation.regions` reports it. The mock CDN applies it for a viewer whose
115
+ * `region` claim falls under that jurisdiction, while the project serves it.
116
+ */
117
+ region(region: Region, status: RegionalStatus, rule: string, category?: Category): this;
118
+ /** @internal The regional outcomes `region` added. */
119
+ get regionalDecisions(): MockRegionalDecision[];
107
120
  /**
108
121
  * Leaves the decision waiting for human review, as `classification.moderation.pendingReview`
109
122
  * reports: `sampled`, or `uncertain` with the `uncertainCategories` that made it so. The queue's
@@ -175,7 +188,8 @@ interface MockModerationInput {
175
188
  trigger: MockModerationTrigger;
176
189
  /**
177
190
  * `true` when the API would queue the work rather than answer with the decision: queued
178
- * uploads, retries and `completeProcessing`.
191
+ * uploads, uploads of audio, video, documents, websites and plain text over 4 MiB (always
192
+ * moderated in the background, even when the caller waits), retries and `completeProcessing`.
179
193
  */
180
194
  queued: boolean;
181
195
  }
@@ -493,4 +507,4 @@ export declare const createWebhookHeaders: (options: {
493
507
  }) => Promise<Record<string, string>>;
494
508
  /** A spoken media test phrase for `signal`, signed with the project's test input key. */
495
509
  export declare const generateMediaTestCode: (signal: ClassificationTestSignal, key: string) => Promise<string>;
496
- export { type MockAssetOutcome, type MockCalmLensAppClientOptions, type MockCalmLensCall, type MockCalmLensOperation, type MockCalmLensServerClientOptions, type MockDatabaseStorage, type MockDetectedFace, type MockDetectedLink, type MockDetectedPerson, type MockEventInput, type MockFailureOptions, type MockImageStorage, type MockModerate, type MockModerationInput, type MockModerationTrigger, type MockQrCode, type MockRequestFailure, type MockReviewDecision, type MockServedUrl, type MockStoredContent, type MockTextRegion, type MockUploadPreset, signUploadTokenWithApiKey as signUploadToken };
510
+ export { type MockAssetOutcome, type MockCalmLensAppClientOptions, type MockCalmLensCall, type MockCalmLensOperation, type MockCalmLensServerClientOptions, type MockDatabaseStorage, type MockDetectedFace, type MockDetectedLink, type MockDetectedPerson, type MockEventInput, type MockFailureOptions, type MockImageStorage, type MockModerate, type MockModerationInput, type MockModerationTrigger, type MockQrCode, type MockRegionalDecision, type MockRequestFailure, type MockReviewDecision, type MockServedUrl, type MockStoredContent, type MockTextRegion, type MockUploadPreset, signUploadTokenWithApiKey as signUploadToken };
package/cjs/testing.js CHANGED
@@ -1,12 +1,12 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_CalmLensTestInputArguments = require("./CalmLensTestInputArguments-PYuRmE0j.js");
2
+ const require_CalmLensTestInputArguments = require("./CalmLensTestInputArguments-C6S09FVQ.js");
3
3
  const require_CalmLensError = require("./CalmLensError-ifj5rLmk.js");
4
- const require_CalmLensCdn = require("./CalmLensCdn-Bfcr9qta.js");
5
- const require_CalmLensServerClient = require("./CalmLensServerClient-BfkTpKwB.js");
6
- const require_CalmLensConnection = require("./CalmLensConnection-By-EsCNB.js");
4
+ const require_CalmLensCdn = require("./CalmLensCdn-CdYY_XtK.js");
5
+ const require_CalmLensServerClient = require("./CalmLensServerClient-cgPOG4Sv.js");
6
+ const require_CalmLensConnection = require("./CalmLensConnection-GkR2cKn5.js");
7
7
  const require_CryptoUtils_BLCa_oZe = require("./CryptoUtils-BLCa-oZe-leCkr1ko.js");
8
- const require_CalmLensAppClient = require("./CalmLensAppClient-CBIAVX_e.js");
9
- const require_UploadController = require("./UploadController-DDLX2yS9.js");
8
+ const require_CalmLensAppClient = require("./CalmLensAppClient-D4tRb_P2.js");
9
+ const require_UploadController = require("./UploadController-BYuHuZ7K.js");
10
10
  let zod = require("zod");
11
11
  let zod$1 = require_CalmLensTestInputArguments.__toESM(zod, 1);
12
12
  zod = require_CalmLensTestInputArguments.__toESM(zod);
@@ -8373,6 +8373,21 @@ const STATUS_ACTION = {
8373
8373
  blocked: "block",
8374
8374
  purged: "purge"
8375
8375
  };
8376
+ const REGIONS = [
8377
+ "DE",
8378
+ "AT",
8379
+ "FR",
8380
+ "GB",
8381
+ "EU",
8382
+ "AU",
8383
+ "BR"
8384
+ ];
8385
+ const REGIONAL_STATUSES = [
8386
+ "limited",
8387
+ "age-restricted",
8388
+ "blocked",
8389
+ "purged"
8390
+ ];
8376
8391
  /** The likelihood the API reports for a score (ClassificationCategories.ts, scoreToLikelihood). */
8377
8392
  const scoreToLikelihood = (score) => score >= .8 ? "very-likely" : score >= .6 ? "likely" : score >= .4 ? "possible" : score >= .2 ? "unlikely" : "very-unlikely";
8378
8393
  const isScore = (score) => typeof score === "number" && Number.isFinite(score) && score >= 0 && score <= 1;
@@ -8385,6 +8400,7 @@ const isScore = (score) => typeof score === "number" && Number.isFinite(score) &
8385
8400
  var MockDecision = class {
8386
8401
  #flags = /* @__PURE__ */ new Map();
8387
8402
  #notEvaluated = /* @__PURE__ */ new Set();
8403
+ #regions = [];
8388
8404
  #pendingReview;
8389
8405
  #ocr;
8390
8406
  #linkDetection;
@@ -8424,6 +8440,30 @@ var MockDecision = class {
8424
8440
  return this;
8425
8441
  }
8426
8442
  /**
8443
+ * Adds a stricter `status` for viewers under the jurisdiction `region` (`DE`, `AT`, `FR`, `GB`,
8444
+ * `EU`, `AU` or `BR`), set by the mandatory `rule`, optionally acting on `category`, as
8445
+ * `classification.moderation.regions` reports it. The mock CDN applies it for a viewer whose
8446
+ * `region` claim falls under that jurisdiction, while the project serves it.
8447
+ */
8448
+ region(region, status, rule, category) {
8449
+ if (this.status === "pending" || this.status === "failed") throw require_CalmLensError.invalidArgument(`a ${this.status} decision has no regional outcomes`);
8450
+ if (!REGIONS.includes(region)) throw require_CalmLensError.invalidArgument(`region must be one of ${REGIONS.join(", ")}`);
8451
+ if (!REGIONAL_STATUSES.includes(status)) throw require_CalmLensError.invalidArgument(`a regional status must be one of ${REGIONAL_STATUSES.join(", ")}`);
8452
+ if (typeof rule !== "string" || !rule) throw require_CalmLensError.invalidArgument("rule must be a non-empty string");
8453
+ if (category !== void 0) this.#checkCategory(category);
8454
+ this.#regions.push({
8455
+ region,
8456
+ status,
8457
+ rule,
8458
+ ...category !== void 0 && { category }
8459
+ });
8460
+ return this;
8461
+ }
8462
+ /** @internal The regional outcomes `region` added. */
8463
+ get regionalDecisions() {
8464
+ return structuredClone(this.#regions);
8465
+ }
8466
+ /**
8427
8467
  * Leaves the decision waiting for human review, as `classification.moderation.pendingReview`
8428
8468
  * reports: `sampled`, or `uncertain` with the `uncertainCategories` that made it so. The queue's
8429
8469
  * decision (`decide` on the mock) clears it; `assets.decide` doesn't, as with the API.
@@ -8546,7 +8586,7 @@ var MockDecision = class {
8546
8586
  source: "policy",
8547
8587
  rule: null,
8548
8588
  automatedStatus: status,
8549
- regions: [],
8589
+ regions: structuredClone(this.#regions),
8550
8590
  timeline: null,
8551
8591
  flaggedCategories: evaluated.filter(([, score]) => action(score) !== "allow").map(([category]) => category),
8552
8592
  raw: {
@@ -9381,6 +9421,14 @@ const checkMockUploadPreset = (preset) => {
9381
9421
  const unknown = Object.keys(preset).filter((key) => !MOCK_UPLOAD_PRESET_KEYS.includes(key));
9382
9422
  if (unknown.length) throw require_CalmLensError.invalidArgument(`Unknown mockOptions.preset key${unknown.length > 1 ? "s" : ""}: ${unknown.join(", ")}`, { options: unknown });
9383
9423
  };
9424
+ /** How strict each status a regional outcome can set is, above an allowed asset's. */
9425
+ const REGIONAL_STATUS_RANK = {
9426
+ allowed: 0,
9427
+ limited: 1,
9428
+ "age-restricted": 2,
9429
+ blocked: 3,
9430
+ purged: 4
9431
+ };
9384
9432
  const MAX_PAGE_SIZE = 100;
9385
9433
  /** Hashes with a lower PDQ quality never match (HashList.ts, HASH_MATCH_MIN_QUALITY). */
9386
9434
  const HASH_MATCH_MIN_QUALITY = 50;
@@ -9833,6 +9881,11 @@ const isTextUpload = (request) => {
9833
9881
  return false;
9834
9882
  }
9835
9883
  };
9884
+ /**
9885
+ * Like the API (`classifiesInBackground`): audio, video, documents, websites and plain text over
9886
+ * 4 MiB are always moderated in the background, even when the caller waits.
9887
+ */
9888
+ const classifiesInBackground = (asset) => asset.type === "audio" || asset.type === "video" || asset.type === "multimedia-document" || asset.type === "website" || asset.type === "plaintext-document" && (asset.content.sizeInBytes ?? 0) > 4194304;
9836
9889
  /** Like the API: a new folder is 201 Created, a queued batch 202 Accepted, everything else 200. */
9837
9890
  const SUCCESS_STATUS = {
9838
9891
  "folders.create": 201,
@@ -10253,20 +10306,32 @@ var MockCalmLensApi = class {
10253
10306
  [...request.query].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0),
10254
10307
  isForm ? "multipart/form-data" : contentType,
10255
10308
  upload,
10256
- upload ? request.bytes.byteLength : new TextDecoder().decode(request.bytes),
10309
+ isForm ? null : upload ? request.bytes.byteLength : new TextDecoder().decode(request.bytes),
10257
10310
  formOptions ?? null
10258
10311
  ]);
10312
+ const replayOnly = headers.get("idempotency-replay-only") === "true";
10313
+ if (replayOnly && (key === void 0 || upload !== "part" || !isForm || request.segments.at(-1) === "part" || request.query.get("partNumber") !== "1")) return this.failureResponse(fail(require_CalmLensError.API_ERROR_CODES.INVALID_REQUEST), url);
10259
10314
  if (key !== void 0) {
10260
10315
  if (!isValidIdempotencyKey(key)) return this.failureResponse(fail(require_CalmLensError.API_ERROR_CODES.INVALID_IDEMPOTENCY_KEY), url);
10261
10316
  const saved = this.idempotentResults.get(key);
10262
10317
  if (saved) {
10263
10318
  if (saved.fingerprint !== fingerprint) return this.failureResponse(fail(require_CalmLensError.API_ERROR_CODES.IDEMPOTENCY_KEY_REUSED), url);
10319
+ if (replayOnly) {
10320
+ const { id } = JSON.parse(saved.body);
10321
+ const asset = await this.databaseStorage.getAsset(id);
10322
+ if (!asset) return this.response(204, null, url, {});
10323
+ return this.response(200, JSON.stringify(asset, this.publishAssets), url, {
10324
+ "Content-Type": "application/json",
10325
+ "Idempotent-Replayed": "true"
10326
+ });
10327
+ }
10264
10328
  return this.response(saved.status, saved.body, url, {
10265
10329
  "Content-Type": "application/json",
10266
10330
  "Idempotent-Replayed": "true"
10267
10331
  });
10268
10332
  }
10269
10333
  }
10334
+ if (replayOnly) return this.response(204, null, url, {});
10270
10335
  let answer;
10271
10336
  try {
10272
10337
  answer = await this.route(request, session);
@@ -11404,11 +11469,12 @@ var MockCalmLensApi = class {
11404
11469
  bytes: data,
11405
11470
  text: data && asset.type === "plaintext-document" ? new TextDecoder().decode(data) : null
11406
11471
  };
11472
+ const background = trigger === "upload" && classifiesInBackground(asset);
11407
11473
  return toDecision(await this.options.moderate({
11408
11474
  asset: this.toPublished(asset),
11409
11475
  content,
11410
11476
  trigger,
11411
- queued
11477
+ queued: queued || background
11412
11478
  }));
11413
11479
  }
11414
11480
  /**
@@ -12189,7 +12255,9 @@ var MockCalmLensApi = class {
12189
12255
  } catch {
12190
12256
  return this.jsonResponse(400, { code: "viewer-claims/invalid" }, url);
12191
12257
  }
12192
- if (status === "age-restricted" && claims.ageConfirmed !== true) return this.jsonResponse(403, { code: "viewer/age-confirmation-required" }, url);
12258
+ const gate = this.viewerAvailability(asset, claims);
12259
+ if (gate.availability === "unavailable") return gate.code === "asset/not-available" ? notAvailable() : this.jsonResponse(403, { code: gate.code }, url);
12260
+ if (gate.availability === "age-restricted") return this.jsonResponse(403, { code: "viewer/age-confirmation-required" }, url);
12193
12261
  const isPrivate = asset.visibility !== "public";
12194
12262
  if (isPrivate && !grant && !canDownload()) return this.jsonResponse(403, {
12195
12263
  code: "auth/permission-denied",
@@ -12243,6 +12311,43 @@ var MockCalmLensApi = class {
12243
12311
  });
12244
12312
  }
12245
12313
  /**
12314
+ * Whether the viewer the claims describe may see an asset that no unconditional check refused,
12315
+ * as the CDN decides (AssetAvailability.ts, decideAssetAvailability): while the project blocks
12316
+ * unmoderated assets, one still queued or processing is unavailable. Then the strictest of the
12317
+ * decision's regional outcomes that is stricter than its own status applies, among the viewer's
12318
+ * country and, in an EU member state, the EU, while the project serves that jurisdiction:
12319
+ * blocked or purged is unavailable and age-restricted needs `ageConfirmed`. An asset with such an
12320
+ * outcome needs the viewer's region, which the CDN reads from the connection when the claims
12321
+ * leave it out; the mock has no connection, so it needs the claim.
12322
+ */
12323
+ viewerAvailability(asset, claims) {
12324
+ const settings = this.toProjectSettings().settings;
12325
+ const processing = asset.classification.status === "queued" || asset.classification.status === "processing";
12326
+ if (settings.blockUnmoderatedAssets && processing) return {
12327
+ availability: "unavailable",
12328
+ code: "asset/not-available"
12329
+ };
12330
+ const status = asset.classification.moderation.decision;
12331
+ const base = REGIONAL_STATUS_RANK[status] ?? 0;
12332
+ const optedOut = settings.optOutJurisdictions ?? [];
12333
+ const stricter = (asset.classification.moderation.regions ?? []).filter((entry) => !optedOut.includes(entry.region) && REGIONAL_STATUS_RANK[entry.status] > base);
12334
+ let delivered = status;
12335
+ if (stricter.length) {
12336
+ const region = claims.region;
12337
+ if (typeof region !== "string" || !region) return {
12338
+ availability: "unavailable",
12339
+ code: "viewer/region-required"
12340
+ };
12341
+ const applied = stricter.filter((entry) => entry.region === region || entry.region === "EU" && require_CalmLensTestInputArguments.EU_COUNTRIES.has(region)).sort((a, b) => REGIONAL_STATUS_RANK[b.status] - REGIONAL_STATUS_RANK[a.status])[0];
12342
+ if (applied?.status === "blocked" || applied?.status === "purged") return {
12343
+ availability: "unavailable",
12344
+ code: "asset/not-available"
12345
+ };
12346
+ if (applied?.status === "age-restricted") delivered = "age-restricted";
12347
+ }
12348
+ return delivered === "age-restricted" && claims.ageConfirmed !== true ? { availability: "age-restricted" } : { availability: "available" };
12349
+ }
12350
+ /**
12246
12351
  * The display info at `/info`, like the CDN's (AssetInfo.ts): the allowlisted fields and whether
12247
12352
  * the viewer the claims describe can see the content, decided as the other resources decide it.
12248
12353
  * A private asset's needs a grant or an API key with `assets:download`.
@@ -12263,7 +12368,7 @@ var MockCalmLensApi = class {
12263
12368
  const status = asset.classification.moderation.decision;
12264
12369
  const restrictedInfo = isPrivate || status === "blocked" || status === "purged";
12265
12370
  if (restrictedInfo && !authorised) return this.jsonResponse(403, { code: "asset/not-available" }, url);
12266
- const availability = asset.content.safetyHold || asset.upload.status === "uploading" || status === "blocked" || status === "purged" || asset.classification.status === "failed" || asset.content.status === "removed" ? "unavailable" : status === "age-restricted" && claims.ageConfirmed !== true ? "age-restricted" : "available";
12371
+ const availability = asset.content.safetyHold || asset.upload.status === "uploading" || status === "blocked" || status === "purged" || asset.classification.status === "failed" || asset.content.status === "removed" ? "unavailable" : this.viewerAvailability(asset, claims).availability;
12267
12372
  const { content } = asset;
12268
12373
  const info = {
12269
12374
  id: asset.id,
@@ -1,5 +1,5 @@
1
- import "./CalmLensTypes-9kLIOd1C.js";
2
- import { K as AssetOptions, Z as AssetView, ct as DocumentViewerOptions, dt as TextViewerOptions, lt as PdfAssetOptions, pt as ViewerOptions, q as AssetSession, ut as SpreadsheetViewerOptions } from "./Core-CFxvTass.js";
1
+ import "./CalmLensTypes-_f7QVRtO.js";
2
+ import { K as AssetOptions, Z as AssetView, ct as DocumentViewerOptions, dt as TextViewerOptions, lt as PdfAssetOptions, pt as ViewerOptions, q as AssetSession, ut as SpreadsheetViewerOptions } from "./Core-4iFxKJnY.js";
3
3
  import "pdfjs-dist";
4
4
  /** A viewer mounted into an element, which it owns the children of. */
5
5
  interface AssetViewer<O extends ViewerOptions = ViewerOptions> {
@@ -1,5 +1,5 @@
1
- const require_CalmLensCdn = require("./CalmLensCdn-Bfcr9qta.js");
2
- require("./Core-BcFDI-t4.js");
1
+ const require_CalmLensCdn = require("./CalmLensCdn-CdYY_XtK.js");
2
+ require("./Core-BlnBBJKb.js");
3
3
  // src/ui/viewers/PdfLoader.ts
4
4
  let loading;
5
5
  /**
package/cjs/ui.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { $ as MediaPlayback, A as CustomUploadContext, B as isFileAccepted, C as formatMessage, D as resolveMessages, E as getUploadItemOutcome, F as UploadFile, G as AssetImageSource, H as AssetDisplay, I as UploadItem, J as AssetSessionState, K as AssetOptions, L as UploadSnapshot, M as UploadClient, N as UploadController, O as CalmLensProvidedOptions, P as UploadControllerOptions, Q as INSTANT_LOAD_MS, R as UploadStage, S as formatBytes, T as getUploadItemMessage, U as AssetDocumentOptions, V as withProvidedOptions, W as AssetImageOptions, X as AssetVideoOptions, Y as AssetSpreadsheetOptions, Z as AssetView, _ as DEFAULT_MESSAGES, _t as DEFAULT_VIEWER_MESSAGES, a as ProgressFetchOptions, at as isImageReady, b as describeUploadItem, bt as resolveViewerMessages, c as ICON_ATTRIBUTES, ct as DocumentViewerOptions, d as AssetDisplayOptions, dt as TextViewerOptions, et as getAssetAspectRatio, f as AssetEventHandlers, ft as ViewerAsset, g as CalmLensMessages, gt as isSpreadsheetFormat, h as UploaderProps, ht as getAssetViewerKind, i as CALMLENS_STYLES, it as getPlayedPercent, j as CustomUploadResult, k as CalmLensUpload, l as IconName, lt as PdfAssetOptions, m as UploaderDisplayOptions, mt as ViewerTextOptions, n as CalmLensTheme, nt as getAssetViewKey, o as createProgressFetch, ot as pickAssetSource, p as AssetProps, pt as ViewerOptions, q as AssetSession, r as resolveTheme, rt as getPeakHeights, s as ICONS, st as AssetViewerKind, t as CALMLENS_THEME, tt as getAssetView, u as ASSET_FILE_ICON_SIZE, ut as SpreadsheetViewerOptions, v as UploadItemView, vt as ViewerMessages, w as getDropzoneHint, x as describeUploader, y as UploaderView, yt as formatViewerMessage, z as createUploadController } from "./Core-CFxvTass.js";
2
- import { _ as spreadsheetColumnIndex, a as isMountedViewerKind, b as AssetViewer, c as AssetViewerOptionsByKind, d as createTextViewer, f as SpreadsheetCell, g as parseSpreadsheetText, h as getSpreadsheetPage, i as getMountedViewerOptions, l as VIEWER_STYLES, m as SpreadsheetSheet, n as AssetViewerMount, o as ASSET_VIEWERS, p as SpreadsheetRow, r as MountedViewerKind, s as AssetViewerName, t as MediaStreamPlayer, u as createSpreadsheetViewer, v as loadPdfJs, x as ViewerState, y as createDocumentViewer } from "./ui-BkOZ_jV_.js";
1
+ import { $ as MediaPlayback, A as CustomUploadContext, B as isFileAccepted, C as formatMessage, D as resolveMessages, E as getUploadItemOutcome, F as UploadFile, G as AssetImageSource, H as AssetDisplay, I as UploadItem, J as AssetSessionState, K as AssetOptions, L as UploadSnapshot, M as UploadClient, N as UploadController, O as CalmLensProvidedOptions, P as UploadControllerOptions, Q as INSTANT_LOAD_MS, R as UploadStage, S as formatBytes, T as getUploadItemMessage, U as AssetDocumentOptions, V as withProvidedOptions, W as AssetImageOptions, X as AssetVideoOptions, Y as AssetSpreadsheetOptions, Z as AssetView, _ as DEFAULT_MESSAGES, _t as DEFAULT_VIEWER_MESSAGES, a as ProgressFetchOptions, at as isImageReady, b as describeUploadItem, bt as resolveViewerMessages, c as ICON_ATTRIBUTES, ct as DocumentViewerOptions, d as AssetDisplayOptions, dt as TextViewerOptions, et as getAssetAspectRatio, f as AssetEventHandlers, ft as ViewerAsset, g as CalmLensMessages, gt as isSpreadsheetFormat, h as UploaderProps, ht as getAssetViewerKind, i as CALMLENS_STYLES, it as getPlayedPercent, j as CustomUploadResult, k as CalmLensUpload, l as IconName, lt as PdfAssetOptions, m as UploaderDisplayOptions, mt as ViewerTextOptions, n as CalmLensTheme, nt as getAssetViewKey, o as createProgressFetch, ot as pickAssetSource, p as AssetProps, pt as ViewerOptions, q as AssetSession, r as resolveTheme, rt as getPeakHeights, s as ICONS, st as AssetViewerKind, t as CALMLENS_THEME, tt as getAssetView, u as ASSET_FILE_ICON_SIZE, ut as SpreadsheetViewerOptions, v as UploadItemView, vt as ViewerMessages, w as getDropzoneHint, x as describeUploader, y as UploaderView, yt as formatViewerMessage, z as createUploadController } from "./Core-4iFxKJnY.js";
2
+ import { _ as spreadsheetColumnIndex, a as isMountedViewerKind, b as AssetViewer, c as AssetViewerOptionsByKind, d as createTextViewer, f as SpreadsheetCell, g as parseSpreadsheetText, h as getSpreadsheetPage, i as getMountedViewerOptions, l as VIEWER_STYLES, m as SpreadsheetSheet, n as AssetViewerMount, o as ASSET_VIEWERS, p as SpreadsheetRow, r as MountedViewerKind, s as AssetViewerName, t as MediaStreamPlayer, u as createSpreadsheetViewer, v as loadPdfJs, x as ViewerState, y as createDocumentViewer } from "./ui-BMQW3Hse.js";
3
3
  export { ASSET_FILE_ICON_SIZE, ASSET_VIEWERS, type AssetDisplay, type AssetDisplayOptions, type AssetDocumentOptions, type AssetEventHandlers, type AssetImageOptions, type AssetImageSource, type AssetOptions, type AssetProps, AssetSession, type AssetSessionState, type AssetSpreadsheetOptions, type AssetVideoOptions, type AssetView, type AssetViewer, type AssetViewerKind, AssetViewerMount, AssetViewerName, AssetViewerOptionsByKind, CALMLENS_STYLES, CALMLENS_THEME, type CalmLensMessages, type CalmLensProvidedOptions, type CalmLensTheme, type CalmLensUpload, type CustomUploadContext, type CustomUploadResult, DEFAULT_MESSAGES, DEFAULT_VIEWER_MESSAGES, type DocumentViewerOptions, ICONS, ICON_ATTRIBUTES, INSTANT_LOAD_MS, type IconName, type MediaPlayback, MediaStreamPlayer, type MountedViewerKind, type PdfAssetOptions, type ProgressFetchOptions, type SpreadsheetCell, type SpreadsheetRow, type SpreadsheetSheet, type SpreadsheetViewerOptions, type TextViewerOptions, type UploadClient, UploadController, type UploadControllerOptions, type UploadFile, type UploadItem, type UploadItemView, type UploadSnapshot, type UploadStage, type UploaderDisplayOptions, type UploaderProps, type UploaderView, VIEWER_STYLES, type ViewerAsset, type ViewerMessages, type ViewerOptions, type ViewerState, type ViewerTextOptions, createDocumentViewer, createProgressFetch, createSpreadsheetViewer, createTextViewer, createUploadController, describeUploadItem, describeUploader, formatBytes, formatMessage, formatViewerMessage, getAssetAspectRatio, getAssetView, getAssetViewKey, getAssetViewerKind, getDropzoneHint, getMountedViewerOptions, getPeakHeights, getPlayedPercent, getSpreadsheetPage, getUploadItemMessage, getUploadItemOutcome, isFileAccepted, isImageReady, isMountedViewerKind, isSpreadsheetFormat, loadPdfJs, parseSpreadsheetText, pickAssetSource, resolveMessages, resolveTheme, resolveViewerMessages, spreadsheetColumnIndex, withProvidedOptions };
package/cjs/ui.js CHANGED
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_ui = require("./ui-TblNKrne.js");
3
- const require_Core = require("./Core-BcFDI-t4.js");
4
- const require_UploadController = require("./UploadController-DDLX2yS9.js");
2
+ const require_ui = require("./ui-Cy8MWXOw.js");
3
+ const require_Core = require("./Core-BlnBBJKb.js");
4
+ const require_UploadController = require("./UploadController-BYuHuZ7K.js");
5
5
  exports.ASSET_FILE_ICON_SIZE = require_Core.ASSET_FILE_ICON_SIZE;
6
6
  exports.ASSET_VIEWERS = require_ui.ASSET_VIEWERS;
7
7
  exports.AssetSession = require_Core.AssetSession;
package/cjs/vue.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { O as CalmLensAppClientOptions, fn as ViewerClaims, g as AssetModerationStatus, i as AssetAvailability } from "./CalmLensTypes-9kLIOd1C.js";
2
- import "./index-D-ZwYNRQ.js";
3
- import { $ as MediaPlayback, A as CustomUploadContext, B as isFileAccepted, C as formatMessage, D as resolveMessages, E as getUploadItemOutcome, F as UploadFile, G as AssetImageSource, H as AssetDisplay, J as AssetSessionState, K as AssetOptions, M as UploadClient, N as UploadController, O as CalmLensProvidedOptions, Q as INSTANT_LOAD_MS, R as UploadStage, S as formatBytes, T as getUploadItemMessage, U as AssetDocumentOptions, V as withProvidedOptions, W as AssetImageOptions, X as AssetVideoOptions, Y as AssetSpreadsheetOptions, Z as AssetView, _ as DEFAULT_MESSAGES, _t as DEFAULT_VIEWER_MESSAGES, a as ProgressFetchOptions, at as isImageReady, b as describeUploadItem, bt as resolveViewerMessages, c as ICON_ATTRIBUTES, ct as DocumentViewerOptions, d as AssetDisplayOptions, dt as TextViewerOptions, et as getAssetAspectRatio, f as AssetEventHandlers, ft as ViewerAsset, g as CalmLensMessages, gt as isSpreadsheetFormat, ht as getAssetViewerKind, i as CALMLENS_STYLES, it as getPlayedPercent, j as CustomUploadResult, l as IconName, lt as PdfAssetOptions, m as UploaderDisplayOptions, mt as ViewerTextOptions, n as CalmLensTheme, nt as getAssetViewKey, o as createProgressFetch, ot as pickAssetSource, p as AssetProps, pt as ViewerOptions, q as AssetSession, r as resolveTheme, rt as getPeakHeights, s as ICONS, st as AssetViewerKind, t as CALMLENS_THEME, tt as getAssetView, u as ASSET_FILE_ICON_SIZE, ut as SpreadsheetViewerOptions, v as UploadItemView, vt as ViewerMessages, w as getDropzoneHint, x as describeUploader, y as UploaderView, yt as formatViewerMessage } from "./Core-CFxvTass.js";
4
- import { a as UploaderProps, i as UploadSnapshot, n as UploadControllerOptions, r as UploadItem, s as createUploadController, t as CalmLensUpload } from "./BrowserUpload-BGxUQPHj.js";
5
- import { _ as spreadsheetColumnIndex, a as isMountedViewerKind, b as AssetViewer, c as AssetViewerOptionsByKind, d as createTextViewer, f as SpreadsheetCell, g as parseSpreadsheetText, h as getSpreadsheetPage, i as getMountedViewerOptions, l as VIEWER_STYLES, m as SpreadsheetSheet, n as AssetViewerMount, o as ASSET_VIEWERS, p as SpreadsheetRow, r as MountedViewerKind, s as AssetViewerName, t as MediaStreamPlayer, u as createSpreadsheetViewer, v as loadPdfJs, x as ViewerState, y as createDocumentViewer } from "./ui-BkOZ_jV_.js";
1
+ import { O as CalmLensAppClientOptions, fn as ViewerClaims, g as AssetModerationStatus, i as AssetAvailability } from "./CalmLensTypes-_f7QVRtO.js";
2
+ import "./index-IEA75nev.js";
3
+ import { $ as MediaPlayback, A as CustomUploadContext, B as isFileAccepted, C as formatMessage, D as resolveMessages, E as getUploadItemOutcome, F as UploadFile, G as AssetImageSource, H as AssetDisplay, J as AssetSessionState, K as AssetOptions, M as UploadClient, N as UploadController, O as CalmLensProvidedOptions, Q as INSTANT_LOAD_MS, R as UploadStage, S as formatBytes, T as getUploadItemMessage, U as AssetDocumentOptions, V as withProvidedOptions, W as AssetImageOptions, X as AssetVideoOptions, Y as AssetSpreadsheetOptions, Z as AssetView, _ as DEFAULT_MESSAGES, _t as DEFAULT_VIEWER_MESSAGES, a as ProgressFetchOptions, at as isImageReady, b as describeUploadItem, bt as resolveViewerMessages, c as ICON_ATTRIBUTES, ct as DocumentViewerOptions, d as AssetDisplayOptions, dt as TextViewerOptions, et as getAssetAspectRatio, f as AssetEventHandlers, ft as ViewerAsset, g as CalmLensMessages, gt as isSpreadsheetFormat, ht as getAssetViewerKind, i as CALMLENS_STYLES, it as getPlayedPercent, j as CustomUploadResult, l as IconName, lt as PdfAssetOptions, m as UploaderDisplayOptions, mt as ViewerTextOptions, n as CalmLensTheme, nt as getAssetViewKey, o as createProgressFetch, ot as pickAssetSource, p as AssetProps, pt as ViewerOptions, q as AssetSession, r as resolveTheme, rt as getPeakHeights, s as ICONS, st as AssetViewerKind, t as CALMLENS_THEME, tt as getAssetView, u as ASSET_FILE_ICON_SIZE, ut as SpreadsheetViewerOptions, v as UploadItemView, vt as ViewerMessages, w as getDropzoneHint, x as describeUploader, y as UploaderView, yt as formatViewerMessage } from "./Core-4iFxKJnY.js";
4
+ import { a as UploaderProps, i as UploadSnapshot, n as UploadControllerOptions, r as UploadItem, s as createUploadController, t as CalmLensUpload } from "./BrowserUpload-CuG3tWSo.js";
5
+ import { _ as spreadsheetColumnIndex, a as isMountedViewerKind, b as AssetViewer, c as AssetViewerOptionsByKind, d as createTextViewer, f as SpreadsheetCell, g as parseSpreadsheetText, h as getSpreadsheetPage, i as getMountedViewerOptions, l as VIEWER_STYLES, m as SpreadsheetSheet, n as AssetViewerMount, o as ASSET_VIEWERS, p as SpreadsheetRow, r as MountedViewerKind, s as AssetViewerName, t as MediaStreamPlayer, u as createSpreadsheetViewer, v as loadPdfJs, x as ViewerState, y as createDocumentViewer } from "./ui-BMQW3Hse.js";
6
6
  import { App, MaybeRefOrGetter, PropType, ShallowRef } from "vue";
7
7
  /** Shows a text asset's text, escaped, in a scrolling region. */
8
8
  export declare const CalmLensTextViewer: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
package/cjs/vue.js CHANGED
@@ -1,9 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_ui = require("./ui-TblNKrne.js");
3
- const require_Core = require("./Core-BcFDI-t4.js");
4
- const require_UploadController = require("./UploadController-DDLX2yS9.js");
2
+ const require_ui = require("./ui-Cy8MWXOw.js");
3
+ const require_Core = require("./Core-BlnBBJKb.js");
4
+ const require_UploadController = require("./UploadController-BYuHuZ7K.js");
5
5
  const require_FileIcons = require("./FileIcons-Ob003MdS.js");
6
- const require_BrowserUpload = require("./BrowserUpload-Bwfz85Id.js");
6
+ const require_BrowserUpload = require("./BrowserUpload-84KQWr1Q.js");
7
7
  let vue = require("vue");
8
8
  // src/viewers/Vue.ts
9
9
  const optional$1 = (type) => ({
@@ -1,4 +1,4 @@
1
- import { n as createUploadController$1 } from "./UploadController-Djvf_J_v.js";
1
+ import { n as createUploadController$1 } from "./UploadController-9fkYFVZM.js";
2
2
  // src/ui/BrowserUpload.ts
3
3
  /** Creates an upload queue for the browser components, such as one a form starts on submit. */
4
4
  const createUploadController = (options) => createUploadController$1(options);
@@ -1,5 +1,5 @@
1
- import { F as UploadFile, I as UploadItem$1, L as UploadSnapshot$1, N as UploadController, P as UploadControllerOptions$1, h as UploaderProps$1, k as CalmLensUpload$1 } from "./Core-CFxvTass.js";
2
- import { r as UseCalmLensUploadResult$1 } from "./ReactUpload-Dso2ir_F.js";
1
+ import { F as UploadFile, I as UploadItem$1, L as UploadSnapshot$1, N as UploadController, P as UploadControllerOptions$1, h as UploaderProps$1, k as CalmLensUpload$1 } from "./Core-4iFxKJnY.js";
2
+ import { r as UseCalmLensUploadResult$1 } from "./ReactUpload-4qd2xACg.js";
3
3
  type UploadItem<F extends UploadFile = File> = UploadItem$1<F>;
4
4
  type CalmLensUpload<F extends UploadFile = File> = CalmLensUpload$1<F>;
5
5
  type UploadSnapshot<F extends UploadFile = File> = UploadSnapshot$1<F>;
@@ -1,6 +1,6 @@
1
1
  import { C as invalidConfig, S as invalidArgument } from "./CalmLensError-C15tWu8W.js";
2
- import { S as validateAppClientOptions, d as checkOptionKeys, o as buildAssetUrl, p as encodePathSegment, u as DEFAULT_CDN_BASE_URL } from "./CalmLensCdn-DOdnpbSx.js";
3
- import { c as prepareSubmitAssetOptions, f as APP_OPTION_KEYS, i as expectUploadedAsset, l as resolveConnectionOptions, t as CalmLensConnection, u as splitsIntoParts } from "./CalmLensConnection-5EryxQTJ.js";
2
+ import { S as validateAppClientOptions, d as checkOptionKeys, o as buildAssetUrl, p as encodePathSegment, u as DEFAULT_CDN_BASE_URL } from "./CalmLensCdn-cmxtF_dw.js";
3
+ import { c as prepareSubmitAssetOptions, f as APP_OPTION_KEYS, i as expectUploadedAsset, l as resolveConnectionOptions, t as CalmLensConnection, u as splitsIntoParts } from "./CalmLensConnection-DEfpIugc.js";
4
4
  // src/client/CalmLensAppClient.ts
5
5
  const inspectSymbol = Symbol.for("nodejs.util.inspect.custom");
6
6
  /** `options`, once `checkOptionKeys` finds only keys `operation` takes. */
@@ -1,4 +1,4 @@
1
- import { M as CdnAssetUrlOptions, O as CalmLensAppClientOptions, Rt as RequestOptions, Vt as RetrieveAssetOptions, an as UploadAssetPartOptions, ln as UploadPresetSubmitAssetOptions, un as UploadedAsset } from "./CalmLensTypes-9kLIOd1C.js";
1
+ import { M as CdnAssetUrlOptions, O as CalmLensAppClientOptions, Rt as RequestOptions, Vt as RetrieveAssetOptions, an as UploadAssetPartOptions, ln as UploadPresetSubmitAssetOptions, un as UploadedAsset } from "./CalmLensTypes-_f7QVRtO.js";
2
2
  declare const inspectSymbol: unique symbol;
3
3
  /**
4
4
  * The CalmLens client for browsers and React Native apps. It uploads through an upload preset,
@@ -152,7 +152,7 @@ const listPages = (fetchPage, { cursor, feed = false } = {}) => {
152
152
  };
153
153
  // src/client/CalmLensVersion.ts
154
154
  /** This SDK's version, from its package.json. */
155
- const SDK_VERSION = "0.36.0";
155
+ const SDK_VERSION = "0.37.1";
156
156
  const runtimeName = () => {
157
157
  const runtime = globalThis;
158
158
  if (isReactNativeRuntime()) return "react-native";
@@ -1,5 +1,5 @@
1
1
  import { S as invalidArgument, l as CalmLensError, w as API_ERROR_CODES, x as SDK_ERROR_CODES } from "./CalmLensError-C15tWu8W.js";
2
- import { A as MAX_OTHER_DOCUMENT_UPLOAD_BYTES, D as MAX_DIRECT_IMAGE_UPLOAD_BYTES, F as sleep, M as getRejectedUploadMimeTypeError, N as normalizeUploadMimeType, O as MAX_IMAGE_UPLOAD_BYTES, P as CalmLensTransport, T as UPLOAD_MIME_DOCUMENTS, U as resolveLogLevel, _ as randomUuid, j as MAX_PDF_UPLOAD_BYTES, k as MAX_NON_IMAGE_UPLOAD_BYTES, m as isAcceptedUploadMimeType, y as stringifyQuery } from "./CalmLensCdn-DOdnpbSx.js";
2
+ import { A as MAX_OTHER_DOCUMENT_UPLOAD_BYTES, D as MAX_DIRECT_IMAGE_UPLOAD_BYTES, F as sleep, M as getRejectedUploadMimeTypeError, N as normalizeUploadMimeType, O as MAX_IMAGE_UPLOAD_BYTES, P as CalmLensTransport, T as UPLOAD_MIME_DOCUMENTS, U as resolveLogLevel, _ as randomUuid, j as MAX_PDF_UPLOAD_BYTES, k as MAX_NON_IMAGE_UPLOAD_BYTES, m as isAcceptedUploadMimeType, y as stringifyQuery } from "./CalmLensCdn-cmxtF_dw.js";
3
3
  // src/contract/AssetPayload.js
4
4
  const bufferInputToBytes = (value) => {
5
5
  if (value instanceof ArrayBuffer) return new Uint8Array(value);
@@ -915,33 +915,46 @@ var CalmLensConnection = class CalmLensConnection {
915
915
  /**
916
916
  * Uploads content larger than `partSizeBytes` in parts: the first to `uploadsPath` with the
917
917
  * upload's fields, the rest to `partPath(assetId)`. Each part carries its own Idempotency-Key
918
- * (`<key>:part-<n>`), so it is retried safely and a repeated call with the same key resumes the
919
- * upload. A part the API already has is skipped, and a final part that finds the upload already
920
- * completed reads it back with `retrieve`.
918
+ * (`<key>:part-<n>`), so it is retried safely. With `resumes`, a repeated call with the same
919
+ * explicit key resumes the upload: it first asks which parts the API has, with the first part's
920
+ * options and an empty file (`Idempotency-Replay-Only`), and sends only the missing parts. A
921
+ * part the API already has is skipped, and a final part that finds the upload already completed
922
+ * reads it back with `retrieve`.
921
923
  */
922
- async submitInParts(uploadsPath, options, wait, { authHeaders = {}, partPath, onStarted, retrieve }) {
924
+ async submitInParts(uploadsPath, options, wait, { authHeaders = {}, partPath, onStarted, resumes = false, retrieve }) {
923
925
  const { content, idempotencyKey, ...fields } = options;
924
926
  const source = getSplittableContent(content);
925
927
  const partSize = this.partSizeBytes;
926
928
  const count = Math.ceil(source.size / partSize);
927
- const key = idempotencyKey ?? this.call.idempotencyKey ?? newIdempotencyKey();
929
+ const explicitKey = idempotencyKey ?? this.call.idempotencyKey;
930
+ const key = explicitKey ?? newIdempotencyKey();
928
931
  const part = (partNumber) => source.slice((partNumber - 1) * partSize, Math.min(partNumber * partSize, source.size));
929
- const first = await this.submitUpload(uploadsPath, {
932
+ const sendFirst = (payload, headers) => this.submitUpload(uploadsPath, {
930
933
  ...fields,
931
934
  part: {
932
- ...part(1),
935
+ ...payload,
933
936
  type: content.type,
937
+ sizeInBytes: Math.min(partSize, source.size),
934
938
  partNumber: 1,
935
939
  isFinal: false
936
940
  },
937
941
  totalSizeInBytes: source.size,
938
942
  idempotencyKey: key
939
- }, wait, authHeaders);
940
- const assetId = expectUploadedAsset(first).id;
943
+ }, wait, headers);
944
+ const existing = resumes && explicitKey ? await sendFirst({ uint8Array: /* @__PURE__ */ new Uint8Array(0) }, {
945
+ ...authHeaders,
946
+ "Idempotency-Replay-Only": "true"
947
+ }) : void 0;
948
+ const first = existing ?? await sendFirst(part(1), authHeaders);
949
+ const uploaded = expectUploadedAsset(first);
950
+ const assetId = uploaded.id;
941
951
  onStarted?.(assetId);
952
+ if (existing && uploaded.upload.status === "completed") return first;
942
953
  const laterParts = this.withCall({ extraBody: void 0 });
943
954
  let result = first;
944
- for (let partNumber = 2; partNumber <= count;) {
955
+ const received = uploaded.upload.partsReceived;
956
+ const nextPart = typeof received === "number" && received >= 2 && received < count ? received + 1 : 2;
957
+ for (let partNumber = nextPart; partNumber <= count;) {
945
958
  const isFinal = partNumber === count;
946
959
  try {
947
960
  result = await laterParts.uploadPart(partPath(assetId), {
@@ -1,6 +1,6 @@
1
1
  import { C as invalidConfig, S as invalidArgument, l as CalmLensError, x as SDK_ERROR_CODES } from "./CalmLensError-C15tWu8W.js";
2
- import { B as copyLastResponse, C as validateBatchAssetsOptions, H as readEnv, L as isBrowserRuntime, R as isReactNativeRuntime, V as listPages, b as toTextAssetOptions, d as checkOptionKeys, g as pollForDecision, i as appendSignedLocation, l as validateSignAssetUrlOptions, o as buildAssetUrl, p as encodePathSegment, s as getAssetInfo, u as DEFAULT_CDN_BASE_URL, w as validateServerClientOptions, y as stringifyQuery } from "./CalmLensCdn-DOdnpbSx.js";
3
- import { a as getMockHooks, c as prepareSubmitAssetOptions, d as validateCallOptions, l as resolveConnectionOptions, m as SERVER_OPTION_KEYS, o as invalidPayload, p as NULLABLE_OPTION_KEYS, r as expectAsset, s as newIdempotencyKey, t as CalmLensConnection, u as splitsIntoParts } from "./CalmLensConnection-5EryxQTJ.js";
2
+ import { B as copyLastResponse, C as validateBatchAssetsOptions, H as readEnv, L as isBrowserRuntime, R as isReactNativeRuntime, V as listPages, b as toTextAssetOptions, d as checkOptionKeys, g as pollForDecision, i as appendSignedLocation, l as validateSignAssetUrlOptions, o as buildAssetUrl, p as encodePathSegment, s as getAssetInfo, u as DEFAULT_CDN_BASE_URL, w as validateServerClientOptions, y as stringifyQuery } from "./CalmLensCdn-cmxtF_dw.js";
3
+ import { a as getMockHooks, c as prepareSubmitAssetOptions, d as validateCallOptions, l as resolveConnectionOptions, m as SERVER_OPTION_KEYS, o as invalidPayload, p as NULLABLE_OPTION_KEYS, r as expectAsset, s as newIdempotencyKey, t as CalmLensConnection, u as splitsIntoParts } from "./CalmLensConnection-DEfpIugc.js";
4
4
  import { n as sha256Hex, r as timingSafeEqual, t as hmacSha256Hex } from "./CryptoUtils-BLCa-oZe-DKr3LmN6.js";
5
5
  // src/contract/JsonUtils.js
6
6
  const stringifyJsonCanonical = (value) => JSON.stringify(value, (_key, nestedValue) => {
@@ -399,6 +399,7 @@ var CalmLensServerClient = class {
399
399
  const uploadsPath = `${this.#projectPath}/assets`;
400
400
  if ("content" in body && splitsIntoParts(body.content, connection.partSizeBytes)) return expectAsset(await connection.submitInParts(uploadsPath, body, wait, {
401
401
  partPath: (assetId) => `/assets/${encodeURIComponent(assetId)}/part`,
402
+ resumes: true,
402
403
  retrieve: (assetId, read) => read.json("GET", `/assets/${requireId(assetId, "Asset ID")}`)
403
404
  }));
404
405
  if ("content" in body || "part" in body) return expectAsset(await connection.submitUpload(uploadsPath, body, wait));
@@ -1,6 +1,6 @@
1
1
  import { c as HashList, l as HashListEntry } from "./Classification-C3pkrGYS-B7EygpJn.js";
2
- import { $t as UpdateFolderOptions, At as PolicyIdOptions, B as CreateHashListOptions, Bn as AssetSearchQuery, Bt as RetrieveAssetByExternalIdOptions, Ct as ListPoliciesOptions, D as BatchAssetsResponse, E as BatchAssetsOptions, Et as MoveFolderOptions, Ft as RemoveAssetContentOptions, G as DeleteAssetOptions, Gt as SignAssetUrlOptions, Hn as AssetInfo, Ht as RetryAssetOptions, I as ClassifyTextOptions, It as RequestAssetReviewOptions, J as EnsureLensesOptions, Jt as SignedUploadToken, K as DeleteMetadataFieldOptions, Kt as SignUploadTokenOptions, M as CdnAssetUrlOptions, Nt as ProjectSettingsResource, P as CdnServeOptions, Qt as UpdateAssetOptions, Rn as Folder, Rt as RequestOptions, St as ListLensesOptions, T as AssignPolicyOptions, Tt as MoveAssetOptions, U as CreatePolicyOptions, V as CreateLensOptions, Vt as RetrieveAssetOptions, W as DecideAssetOptions, Wt as SetPolicyAutomaticUpdatesOptions, X as EnsureUploadPresetsOptions, Xt as SubmitAssetOptions, Y as EnsureMetadataFieldsOptions, Z as EnsureUploadPresetsResponse, _ as AssetPage, _n as AssetReviewRequest, _t as ListAssetsOptions, an as UploadAssetPartOptions, at as GetAssetInfoOptions, b as AssetTimelinePage, bt as ListHashListEntriesOptions, cn as UploadPresetPage, ct as HashListIdOptions, dn as VerifyWebhookSignatureOptions, en as UpdateHashListOptions, ft as Lens, gt as ListAssetTimelineOptions, ht as ListAssetChildrenOptions, in as UpgradePolicyOptions, it as FolderPage, jt as PolicyPage, k as CalmLensServerClientOptions, kt as Policy, lt as HashListPage, mt as LensPage, nn as UpdatePolicyOptions, nt as EventsPage, o as AssetChildrenPage, ot as HashListEntryIdOptions, pn as WaitForAssetDecisionOptions, pt as LensIdOptions, q as EnsureLensOptions, qt as SignedAssetUrl, r as Asset, rn as UpdateProjectSettingsOptions, rt as FolderIdOptions, sn as UploadPresetIdOptions, st as HashListEntryPage, t as AddHashListEntryOptions, tn as UpdateLensOptions, v as AssetSearchResponse, vt as ListEventsOptions, wt as ListUploadPresetsOptions, xt as ListHashListsOptions, yn as MetadataFieldsResource, yt as ListFoldersOptions, z as CreateFolderOptions, zt as ResetPolicyOptions } from "./CalmLensTypes-9kLIOd1C.js";
3
- import { d as ListPromise, l as CalmLensResponse, r as CdnResponse } from "./WebhookPayload-Cv2uwykA.js";
2
+ import { $t as UpdateFolderOptions, At as PolicyIdOptions, B as CreateHashListOptions, Bn as AssetSearchQuery, Bt as RetrieveAssetByExternalIdOptions, Ct as ListPoliciesOptions, D as BatchAssetsResponse, E as BatchAssetsOptions, Et as MoveFolderOptions, Ft as RemoveAssetContentOptions, G as DeleteAssetOptions, Gt as SignAssetUrlOptions, Hn as AssetInfo, Ht as RetryAssetOptions, I as ClassifyTextOptions, It as RequestAssetReviewOptions, J as EnsureLensesOptions, Jt as SignedUploadToken, K as DeleteMetadataFieldOptions, Kt as SignUploadTokenOptions, M as CdnAssetUrlOptions, Nt as ProjectSettingsResource, P as CdnServeOptions, Qt as UpdateAssetOptions, Rn as Folder, Rt as RequestOptions, St as ListLensesOptions, T as AssignPolicyOptions, Tt as MoveAssetOptions, U as CreatePolicyOptions, V as CreateLensOptions, Vt as RetrieveAssetOptions, W as DecideAssetOptions, Wt as SetPolicyAutomaticUpdatesOptions, X as EnsureUploadPresetsOptions, Xt as SubmitAssetOptions, Y as EnsureMetadataFieldsOptions, Z as EnsureUploadPresetsResponse, _ as AssetPage, _n as AssetReviewRequest, _t as ListAssetsOptions, an as UploadAssetPartOptions, at as GetAssetInfoOptions, b as AssetTimelinePage, bt as ListHashListEntriesOptions, cn as UploadPresetPage, ct as HashListIdOptions, dn as VerifyWebhookSignatureOptions, en as UpdateHashListOptions, ft as Lens, gt as ListAssetTimelineOptions, ht as ListAssetChildrenOptions, in as UpgradePolicyOptions, it as FolderPage, jt as PolicyPage, k as CalmLensServerClientOptions, kt as Policy, lt as HashListPage, mt as LensPage, nn as UpdatePolicyOptions, nt as EventsPage, o as AssetChildrenPage, ot as HashListEntryIdOptions, pn as WaitForAssetDecisionOptions, pt as LensIdOptions, q as EnsureLensOptions, qt as SignedAssetUrl, r as Asset, rn as UpdateProjectSettingsOptions, rt as FolderIdOptions, sn as UploadPresetIdOptions, st as HashListEntryPage, t as AddHashListEntryOptions, tn as UpdateLensOptions, v as AssetSearchResponse, vt as ListEventsOptions, wt as ListUploadPresetsOptions, xt as ListHashListsOptions, yn as MetadataFieldsResource, yt as ListFoldersOptions, z as CreateFolderOptions, zt as ResetPolicyOptions } from "./CalmLensTypes-_f7QVRtO.js";
3
+ import { d as ListPromise, l as CalmLensResponse, r as CdnResponse } from "./WebhookPayload-BJtggTLd.js";
4
4
  interface TransportRequest {
5
5
  /** The client method sending the request, such as `assets.retrieve`, for hooks and logs. */
6
6
  operation?: string;
@@ -134,7 +134,7 @@ const JURISDICTION_SCHEMA = /* @__PURE__ */ lazySchema(() => z.enum(Object.keys(
134
134
  Object.keys(JURISDICTIONS).filter((code) => !JURISDICTIONS[code].optional);
135
135
  Object.keys(JURISDICTIONS).filter((code) => JURISDICTIONS[code].optional);
136
136
  new Set("AD AE AF AG AI AL AM AO AQ AR AS AT AU AW AX AZ BA BB BD BE BF BG BH BI BJ BL BM BN BO BQ BR BS BT BV BW BY BZ CA CC CD CF CG CH CI CK CL CM CN CO CR CU CV CW CX CY CZ DE DJ DK DM DO DZ EC EE EG EH ER ES ET FI FJ FK FM FO FR GA GB GD GE GF GG GH GI GL GM GN GP GQ GR GS GT GU GW GY HK HM HN HR HT HU ID IE IL IM IN IO IQ IR IS IT JE JM JO JP KE KG KH KI KM KN KP KR KW KY KZ LA LB LC LI LK LR LS LT LU LV LY MA MC MD ME MF MG MH MK ML MM MN MO MP MQ MR MS MT MU MV MW MX MY MZ NA NC NE NF NG NI NL NO NP NR NU NZ OM PA PE PF PG PH PK PL PM PN PR PS PT PW PY QA RE RO RS RU RW SA SB SC SD SE SG SH SI SJ SK SL SM SN SO SR SS ST SV SX SY SZ TC TD TF TG TH TJ TK TL TM TN TO TR TT TV TW TZ UA UG UM US UY UZ VA VC VE VG VI VN VU WF WS YE YT ZA ZM ZW".split(" "));
137
- new Set("AT BE BG HR CY CZ DK EE FI FR DE GR HU IE IT LV LT LU MT NL PL PT RO SK SI ES SE".split(" "));
137
+ const EU_COUNTRIES = new Set("AT BE BG HR CY CZ DK EE FI FR DE GR HU IE IT LV LT LU MT NL PL PT RO SK SI ES SE".split(" "));
138
138
  // src/contract/TestRegionalActions-Ce8EVv4q.js
139
139
  /**
140
140
  * Marks English text in shared, backend and data modules that the portal shows, so the app's
@@ -1978,4 +1978,4 @@ async function withValidTestInputArguments(key, generate) {
1978
1978
  throw error;
1979
1979
  }
1980
1980
  }
1981
- export { TEST_FACE_AGE_PRESETS as a, detectTestImage as c, getImageTestCategories as d, getTestInputTag as f, CLASSIFICATION_CATEGORIES as g, lazySchema as h, TEST_FACE_AGE_MAX as i, detectTestTrigger as l, testInputForSignal as m, TEST_DETECTIONS_MAX as n, TEST_INPUT_KEY_PATTERN as o, paintTestImage as p, TEST_DETECTION_BOX_MAX as r, TEST_INPUT_PRESETS as s, withValidTestInputArguments as t, generateTestTextCode as u };
1981
+ export { CLASSIFICATION_CATEGORIES as _, TEST_FACE_AGE_PRESETS as a, detectTestImage as c, getImageTestCategories as d, getTestInputTag as f, lazySchema as g, EU_COUNTRIES as h, TEST_FACE_AGE_MAX as i, detectTestTrigger as l, testInputForSignal as m, TEST_DETECTIONS_MAX as n, TEST_INPUT_KEY_PATTERN as o, paintTestImage as p, TEST_DETECTION_BOX_MAX as r, TEST_INPUT_PRESETS as s, withValidTestInputArguments as t, generateTestTextCode as u };
@@ -38010,7 +38010,7 @@ declare const DETECTED_FACE_SCHEMA: zod.ZodObject<{
38010
38010
  }, zod.core.$strict>>;
38011
38011
  }, zod.core.$strict>;
38012
38012
  type DetectedFace = zod.infer<typeof DETECTED_FACE_SCHEMA>;
38013
- declare const PROCESSING_FEATURE_RESULTS_SCHEMA: zod.ZodObject<{
38013
+ declare const ALL_FEATURE_RESULTS_SCHEMA: zod.ZodObject<{
38014
38014
  ocr: zod.ZodOptional<zod.ZodDiscriminatedUnion<[zod.ZodObject<{
38015
38015
  status: zod.ZodLiteral<"evaluated">;
38016
38016
  textRegions: zod.ZodArray<zod.ZodObject<{
@@ -38160,7 +38160,7 @@ declare const PROCESSING_FEATURE_RESULTS_SCHEMA: zod.ZodObject<{
38160
38160
  }>;
38161
38161
  }, zod.core.$strict>], "status">>;
38162
38162
  }, zod.core.$strict>;
38163
- type ProcessingFeatureResults = zod.infer<typeof PROCESSING_FEATURE_RESULTS_SCHEMA>;
38163
+ type ProcessingFeatureResults = Omit<zod.infer<typeof ALL_FEATURE_RESULTS_SCHEMA>, "linkSafety">;
38164
38164
  declare const UPLOAD_PRESET_SCHEMA: zod.ZodObject<{
38165
38165
  id: zod.ZodString;
38166
38166
  projectId: zod.ZodString;
@@ -1,5 +1,5 @@
1
- import { F as CdnTransform, O as CalmLensAppClientOptions, fn as ViewerClaims, g as AssetModerationStatus, i as AssetAvailability } from "./CalmLensTypes-9kLIOd1C.js";
2
- import { t as CalmLensAppClient } from "./CalmLensAppClient-0to4ZZ7i.js";
1
+ import { F as CdnTransform, O as CalmLensAppClientOptions, fn as ViewerClaims, g as AssetModerationStatus, i as AssetAvailability } from "./CalmLensTypes-_f7QVRtO.js";
2
+ import { t as CalmLensAppClient } from "./CalmLensAppClient-QqtovWE-.js";
3
3
  import { o as UploadFileIconFamily } from "./FileIcons-4qSX7DW2.js";
4
4
  /**
5
5
  * The text the asset viewers show, keyed by name. `{name}` placeholders are filled in when shown.
@@ -1,6 +1,6 @@
1
1
  import { l as CalmLensError } from "./CalmLensError-C15tWu8W.js";
2
- import { a as assetUrlOf, c as toUrlViewerClaims, r as appendAssetLocation, s as getAssetInfo, v as serializeTransform, x as transformSelector } from "./CalmLensCdn-DOdnpbSx.js";
3
- import { o as placeholderHashToDataURL } from "./UploadController-Djvf_J_v.js";
2
+ import { a as assetUrlOf, c as toUrlViewerClaims, r as appendAssetLocation, s as getAssetInfo, v as serializeTransform, x as transformSelector } from "./CalmLensCdn-cmxtF_dw.js";
3
+ import { o as placeholderHashToDataURL } from "./UploadController-9fkYFVZM.js";
4
4
  import { a as getFileIcon, c as renderFileIconSvg } from "./FileIcons-M6dzjFxd.js";
5
5
  // src/ui/viewers/ViewerAsset.ts
6
6
  /** Spreadsheet MIME types, as `content.format` reports them (compared lower-cased). */
@@ -1,4 +1,4 @@
1
- import { F as UploadFile, L as UploadSnapshot, N as UploadController, O as CalmLensProvidedOptions, P as UploadControllerOptions } from "./Core-CFxvTass.js";
1
+ import { F as UploadFile, L as UploadSnapshot, N as UploadController, O as CalmLensProvidedOptions, P as UploadControllerOptions } from "./Core-4iFxKJnY.js";
2
2
  import { ReactNode } from "react";
3
3
  type CalmLensProviderProps<F extends UploadFile = File> = CalmLensProvidedOptions<F> & {
4
4
  children?: ReactNode;
@@ -1,4 +1,4 @@
1
- import { i as withProvidedOptions, n as createUploadController } from "./UploadController-Djvf_J_v.js";
1
+ import { i as withProvidedOptions, n as createUploadController } from "./UploadController-9fkYFVZM.js";
2
2
  import { createContext, createElement, useContext, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
3
3
  // src/ui/ReactUpload.ts
4
4
  const CalmLensContext = createContext(void 0);
@@ -1,5 +1,5 @@
1
1
  import { l as CalmLensError, x as SDK_ERROR_CODES } from "./CalmLensError-C15tWu8W.js";
2
- import { t as CalmLensAppClient } from "./CalmLensAppClient-C3RuoUjN.js";
2
+ import { t as CalmLensAppClient } from "./CalmLensAppClient-Brvc-GXt.js";
3
3
  // src/contract/PlaceholderHashDecode.js
4
4
  /**
5
5
  * Decodes a ThumbHash to an RGBA image. RGB is not be premultiplied by A.