calmlens 0.19.0 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/README.md +13 -9
  2. package/bin/calmlens.js +1646 -706
  3. package/cjs/{BrowserUpload-CJ4Xc9bR.js → BrowserUpload-CeSwiMo5.js} +1 -1
  4. package/{esm/BrowserUpload-RkxV_Vv7.d.ts → cjs/BrowserUpload-D-NnAN7g.d.ts} +2 -2
  5. package/cjs/{CalmLensAppClient-LHMEQ-UZ.js → CalmLensAppClient-0UVCuNqW.js} +30 -10
  6. package/cjs/{CalmLensAppClient-B5gfOB6J.d.ts → CalmLensAppClient-gG16T2py.d.ts} +13 -3
  7. package/cjs/{CalmLensOptionKeys-BUj7v5AG.js → CalmLensOptionKeys-CYY6elxg.js} +242 -345
  8. package/cjs/{CalmLensServerClient-DCSbwIBs.d.ts → CalmLensServerClient-BHx3x_nZ.d.ts} +107 -49
  9. package/cjs/{CalmLensServerClient-BVOEUT_v.js → CalmLensServerClient-nfu6_YEW.js} +297 -92
  10. package/cjs/{CalmLensTypes-DpU-hXq2.d.ts → CalmLensTypes-CUB0YYVz.d.ts} +26601 -27354
  11. package/cjs/{Classification-D3SkprrQ-CMnQKW13.d.ts → Classification-Q5zGpR8l-CEWjnE39.d.ts} +731 -607
  12. package/cjs/Core-C82YmjjX.d.ts +823 -0
  13. package/cjs/Core-Dc3cteU7.js +998 -0
  14. package/cjs/FileIcons-4qSX7DW2.d.ts +67 -0
  15. package/cjs/{ModerationContextLimits-FDpQmw_T.js → ModerationContextLimits-BxOmeSqq.js} +970 -278
  16. package/cjs/{ReactUpload-BvpW4hJi.js → ReactUpload-BK2O3dnK.js} +1 -1
  17. package/cjs/{ReactUpload-huIMnOJ4.d.ts → ReactUpload-DiiXfKvj.d.ts} +1 -1
  18. package/cjs/{TestTriggers-CMwMrbjy-K0YBzu2a.js → TestTriggers-BTyXtX0Q-ATuFDhLX.js} +343 -35
  19. package/{esm/TestTriggers-D-fwfhEP-hlaP1oW2.d.ts → cjs/TestTriggers-D0pYHbkr-D5T0VdSn.d.ts} +146 -8
  20. package/cjs/{UploadController-D4qOZZc3.js → UploadController-DLyiLDTB.js} +34 -14
  21. package/cjs/{WebhookPayload-CQg8BBZQ.d.ts → WebhookPayload-BLT2y_Jy.d.ts} +93 -86
  22. package/cjs/app.d.ts +6 -7
  23. package/cjs/app.js +4 -3
  24. package/cjs/elements.d.ts +123 -22
  25. package/cjs/elements.js +553 -156
  26. package/cjs/file-icons.d.ts +2 -67
  27. package/cjs/index-CKRgjV16.d.ts +16 -0
  28. package/cjs/index.d.ts +5 -6
  29. package/cjs/index.js +3 -2
  30. package/cjs/react-native.d.ts +52 -11
  31. package/cjs/react-native.js +231 -99
  32. package/cjs/react.d.ts +42 -9
  33. package/cjs/react.js +381 -118
  34. package/cjs/server.d.ts +48 -7
  35. package/cjs/server.js +7 -3
  36. package/cjs/test-inputs.d.ts +2 -2
  37. package/cjs/test-inputs.js +13 -9
  38. package/cjs/testing.d.ts +29 -16
  39. package/cjs/testing.js +1511 -397
  40. package/cjs/ui-CTBUxnVp.d.ts +139 -0
  41. package/cjs/ui-CZ8exACq.js +1359 -0
  42. package/cjs/ui.d.ts +3 -2
  43. package/cjs/ui.js +45 -22
  44. package/cjs/vue.d.ts +802 -199
  45. package/cjs/vue.js +359 -127
  46. package/{cjs/BrowserUpload-RkxV_Vv7.d.ts → esm/BrowserUpload-D-NnAN7g.d.ts} +2 -2
  47. package/esm/{BrowserUpload-DpzS2bbj.js → BrowserUpload-i9OhCzMJ.js} +1 -1
  48. package/esm/{CalmLensAppClient-BjlvBweS.js → CalmLensAppClient-CK4_Py0c.js} +30 -10
  49. package/esm/{CalmLensAppClient-B5gfOB6J.d.ts → CalmLensAppClient-gG16T2py.d.ts} +13 -3
  50. package/esm/{CalmLensOptionKeys-BKez0Wiw.js → CalmLensOptionKeys-BGZlIsT2.js} +235 -338
  51. package/esm/{CalmLensServerClient-DCSbwIBs.d.ts → CalmLensServerClient-BHx3x_nZ.d.ts} +107 -49
  52. package/esm/{CalmLensServerClient-DemxbNMn.js → CalmLensServerClient-dAQUcDWb.js} +274 -93
  53. package/esm/{CalmLensTypes-DpU-hXq2.d.ts → CalmLensTypes-CUB0YYVz.d.ts} +26601 -27354
  54. package/esm/{Classification-D3SkprrQ-CMnQKW13.d.ts → Classification-Q5zGpR8l-CEWjnE39.d.ts} +731 -607
  55. package/esm/Core-BxeIud_S.js +843 -0
  56. package/esm/Core-C82YmjjX.d.ts +823 -0
  57. package/esm/FileIcons-4qSX7DW2.d.ts +67 -0
  58. package/esm/{ModerationContextLimits-lLfmyLni.js → ModerationContextLimits-B6_RalCQ.js} +911 -261
  59. package/esm/{ReactUpload-huIMnOJ4.d.ts → ReactUpload-DiiXfKvj.d.ts} +1 -1
  60. package/esm/{ReactUpload-6klucehl.js → ReactUpload-DxwVqfX1.js} +1 -1
  61. package/esm/{TestTriggers-CMwMrbjy-bdowBBKw.js → TestTriggers-BTyXtX0Q-GRB9jQwo.js} +320 -36
  62. package/{cjs/TestTriggers-D-fwfhEP-hlaP1oW2.d.ts → esm/TestTriggers-D0pYHbkr-D5T0VdSn.d.ts} +146 -8
  63. package/esm/{UploadController-UxP6gj7A.js → UploadController-D9Z-h00Q.js} +34 -14
  64. package/esm/{WebhookPayload-CQg8BBZQ.d.ts → WebhookPayload-BLT2y_Jy.d.ts} +93 -86
  65. package/esm/app.d.ts +6 -7
  66. package/esm/app.js +3 -3
  67. package/esm/elements.d.ts +123 -22
  68. package/esm/elements.js +497 -128
  69. package/esm/file-icons.d.ts +2 -67
  70. package/esm/index-CKRgjV16.d.ts +16 -0
  71. package/esm/index.d.ts +5 -6
  72. package/esm/index.js +1 -1
  73. package/esm/react-native.d.ts +52 -11
  74. package/esm/react-native.js +205 -75
  75. package/esm/react.d.ts +42 -9
  76. package/esm/react.js +327 -91
  77. package/esm/server.d.ts +48 -7
  78. package/esm/server.js +3 -3
  79. package/esm/styles.css +142 -22
  80. package/esm/svelte/AssetViewer.svelte +25 -0
  81. package/esm/svelte/CalmLensAsset.svelte +318 -0
  82. package/esm/svelte/CalmLensDocumentViewer.svelte +7 -0
  83. package/esm/svelte/CalmLensImageViewer.svelte +7 -0
  84. package/esm/svelte/CalmLensSpreadsheetViewer.svelte +7 -0
  85. package/esm/svelte/CalmLensTextViewer.svelte +7 -0
  86. package/esm/svelte/CalmLensWebsiteViewer.svelte +7 -0
  87. package/esm/svelte/index.d.ts +29 -6
  88. package/esm/svelte/index.js +7 -2
  89. package/esm/test-inputs.d.ts +2 -2
  90. package/esm/test-inputs.js +1 -1
  91. package/esm/testing.d.ts +29 -16
  92. package/esm/testing.js +1507 -393
  93. package/esm/ui-CTBUxnVp.d.ts +139 -0
  94. package/esm/ui-Cr7s6JHm.js +1258 -0
  95. package/esm/ui.d.ts +3 -2
  96. package/esm/ui.js +4 -3
  97. package/esm/vue.d.ts +802 -199
  98. package/esm/vue.js +308 -103
  99. package/package.json +3 -1
  100. package/cjs/ModerationContext-9lGm-Mna-CcmbRnOy.d.ts +0 -67
  101. package/cjs/index-BcDDQJF2.d.ts +0 -253
  102. package/cjs/ui-B23r8BvW.d.ts +0 -539
  103. package/cjs/ui-Dq-cm6Rx.js +0 -586
  104. package/esm/ModerationContext-9lGm-Mna-CcmbRnOy.d.ts +0 -67
  105. package/esm/index-BcDDQJF2.d.ts +0 -253
  106. package/esm/svelte/CalmLensMedia.svelte +0 -134
  107. package/esm/ui-B23r8BvW.d.ts +0 -539
  108. package/esm/ui-Bn29rfAi.js +0 -461
@@ -1,4 +1,4 @@
1
- import { n as ClassificationCategory } from "./Classification-D3SkprrQ-CMnQKW13.js";
1
+ import { r as ClassificationCategory } from "./Classification-Q5zGpR8l-CEWjnE39.js";
2
2
  import * as z from "zod";
3
3
  interface RgbaImage {
4
4
  width: number;
@@ -11,6 +11,41 @@ declare const TEST_INPUT_KEY_PATTERN: RegExp;
11
11
  /** Category shortcuts are presets in the same instance-based format. */
12
12
  declare function testInputForSignal(signal: ClassificationTestSignal, kind?: "image" | "text"): TestInput;
13
13
  declare const getImageTestCategories: () => ClassificationTestSignal[];
14
+ /** Each detection list holds at most this many entries; 32 faces fit a test image. */
15
+ declare const TEST_DETECTIONS_MAX = 32;
16
+ /** Box values are integer basis points of the image width and height: 10000 is the full side. */
17
+ declare const TEST_DETECTION_BOX_MAX = 10000;
18
+ /** Age presets and the range a custom estimate may use. */
19
+ declare const TEST_FACE_AGE_PRESETS: {
20
+ readonly adult: {
21
+ readonly low: 25;
22
+ readonly high: 35;
23
+ };
24
+ readonly minor: {
25
+ readonly low: 12;
26
+ readonly high: 16;
27
+ };
28
+ };
29
+ declare const TEST_FACE_AGE_MAX = 120;
30
+ /** Person and face detection results a test image reports instead of running detection. */
31
+ declare const TEST_DETECTIONS_SCHEMA: z.ZodObject<{
32
+ people: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodObject<{
33
+ box: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
34
+ confidence: z.ZodOptional<z.ZodNumber>;
35
+ }, z.core.$strict>>, z.ZodLiteral<"unavailable">]>>;
36
+ faces: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodObject<{
37
+ box: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
38
+ confidence: z.ZodOptional<z.ZodNumber>;
39
+ age: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
40
+ adult: "adult";
41
+ minor: "minor";
42
+ }>, z.ZodObject<{
43
+ low: z.ZodNumber;
44
+ high: z.ZodNumber;
45
+ }, z.core.$strict>]>>;
46
+ }, z.core.$strict>>, z.ZodLiteral<"unavailable">]>>;
47
+ }, z.core.$strict>;
48
+ type TestDetections = z.infer<typeof TEST_DETECTIONS_SCHEMA>;
14
49
  /** Each row is one qualifying instance. Unselected qualifiers are explicitly absent. */
15
50
  declare const TEST_INPUT_SCHEMA: z.ZodObject<{
16
51
  regionalActions: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -157,6 +192,7 @@ declare const TEST_INPUT_SCHEMA: z.ZodObject<{
157
192
  "sexual-extreme": "sexual-extreme";
158
193
  "sexual-fictional": "sexual-fictional";
159
194
  "sexual-historical": "sexual-historical";
195
+ "sexual-incest": "sexual-incest";
160
196
  "sexual-intimate-image-abuse": "sexual-intimate-image-abuse";
161
197
  "sexual-minors": "sexual-minors";
162
198
  "sexual-non-consensual": "sexual-non-consensual";
@@ -166,6 +202,7 @@ declare const TEST_INPUT_SCHEMA: z.ZodObject<{
166
202
  "sexual-pornographic-media": "sexual-pornographic-media";
167
203
  "sexual-revealing-clothing": "sexual-revealing-clothing";
168
204
  "sexual-solicitation": "sexual-solicitation";
205
+ "sexual-strangulation": "sexual-strangulation";
169
206
  "sexual-suggestive": "sexual-suggestive";
170
207
  "sexual-support-prevention": "sexual-support-prevention";
171
208
  "sexual-text": "sexual-text";
@@ -195,6 +232,23 @@ declare const TEST_INPUT_SCHEMA: z.ZodObject<{
195
232
  "violence-wish": "violence-wish";
196
233
  }>>;
197
234
  }, z.core.$strict>>;
235
+ detections: z.ZodOptional<z.ZodObject<{
236
+ people: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodObject<{
237
+ box: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
238
+ confidence: z.ZodOptional<z.ZodNumber>;
239
+ }, z.core.$strict>>, z.ZodLiteral<"unavailable">]>>;
240
+ faces: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodObject<{
241
+ box: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
242
+ confidence: z.ZodOptional<z.ZodNumber>;
243
+ age: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
244
+ adult: "adult";
245
+ minor: "minor";
246
+ }>, z.ZodObject<{
247
+ low: z.ZodNumber;
248
+ high: z.ZodNumber;
249
+ }, z.core.$strict>]>>;
250
+ }, z.core.$strict>>, z.ZodLiteral<"unavailable">]>>;
251
+ }, z.core.$strict>>;
198
252
  }, z.core.$strict>;
199
253
  type TestInput = z.infer<typeof TEST_INPUT_SCHEMA>;
200
254
  declare const TEST_INPUT_PRESETS: {
@@ -247,21 +301,91 @@ declare const TEST_INPUT_PRESETS: {
247
301
  qualifiers: "harassment-threat"[];
248
302
  })[];
249
303
  };
304
+ oneFace: {
305
+ instances: never[];
306
+ detections: {
307
+ people: {
308
+ box: [number, number, number, number];
309
+ }[];
310
+ faces: {
311
+ box: [number, number, number, number];
312
+ }[];
313
+ };
314
+ };
315
+ noFace: {
316
+ instances: never[];
317
+ detections: {
318
+ people: never[];
319
+ faces: never[];
320
+ };
321
+ };
322
+ adultFace: {
323
+ instances: never[];
324
+ detections: {
325
+ people: {
326
+ box: [number, number, number, number];
327
+ }[];
328
+ faces: {
329
+ box: [number, number, number, number];
330
+ age: "adult";
331
+ }[];
332
+ };
333
+ };
334
+ minorFace: {
335
+ instances: never[];
336
+ detections: {
337
+ people: {
338
+ box: [number, number, number, number];
339
+ }[];
340
+ faces: {
341
+ box: [number, number, number, number];
342
+ age: "minor";
343
+ }[];
344
+ };
345
+ };
346
+ group: {
347
+ instances: never[];
348
+ detections: {
349
+ people: {
350
+ box: [number, number, number, number];
351
+ }[];
352
+ faces: {
353
+ box: [number, number, number, number];
354
+ }[];
355
+ };
356
+ };
250
357
  };
251
358
  declare function generateTestTextCode(scenario: TestInput | ClassificationTestSignal, key: string): Promise<string>;
359
+ /**
360
+ * The scenario a text declares when the whole text is one code signed with `key`; surrounding
361
+ * text, a second code or an altered code all return undefined, so the text is moderated as
362
+ * ordinary content.
363
+ */
252
364
  declare function detectTestTrigger(text: string, key: string): Promise<TestInput | undefined>;
253
365
  /**
254
- * The text code's signed bytes as a grid (TestImageGrid.ts): the scenario JSON's length (two
255
- * bytes, big-endian), the 16-byte tag, then the JSON. The reader rebuilds the text code, so images
256
- * and text share one verification.
366
+ * The text code's signed bytes as a grid (TestImageGrid.ts): the signed payload's length (two
367
+ * bytes, big-endian), the 16-byte tag, then the payload (the scenario JSON). The reader rebuilds
368
+ * the text code, so images and text share one verification.
257
369
  */
258
370
  declare function paintTestImage(scenario: TestInput | ClassificationTestSignal, key: string): Promise<{
259
371
  width: number;
260
372
  height: number;
261
373
  rgba: Uint8Array<ArrayBuffer>;
262
374
  }>;
263
- /** The test input a project's test image carries, also after video encoding and resizing. */
264
- declare function detectTestImage(image: RgbaImage, key: string): Promise<{
375
+ /**
376
+ * The test input an image declares when the whole image is one of the project's test images,
377
+ * also after lossy formats and resizing: the grid, optionally on a uniform border. Every pixel
378
+ * must match the grid repainted from the bytes it carries (TestImageGrid.ts,
379
+ * `matchesTestImageGrid`), so nothing else can be drawn on or around it.
380
+ */
381
+ declare function detectTestImage(image: RgbaImage, key: string,
382
+ /**
383
+ * `whole: false` only reads the grid, for a video frame: media moderation sees the frame anyway,
384
+ * so its findings can only add to that moderation.
385
+ */
386
+ { whole }?: {
387
+ whole?: boolean;
388
+ }): Promise<{
265
389
  regionalActions?: {
266
390
  region: "AT" | "AU" | "BR" | "DE" | "EU" | "FR" | "GB";
267
391
  action: "age-restrict" | "block" | "limit";
@@ -271,7 +395,21 @@ declare function detectTestImage(image: RgbaImage, key: string): Promise<{
271
395
  category: "criminal-activity" | "harassment" | "hate" | "personal-information" | "profanity" | "self-harm" | "sexual" | "violence";
272
396
  score?: number | undefined;
273
397
  action?: "age-restrict" | "allow" | "block" | "limit" | undefined;
274
- qualifiers: ("criminal-activity-alcohol" | "criminal-activity-coded-incitement" | "criminal-activity-csam" | "criminal-activity-demonstration" | "criminal-activity-discussion" | "criminal-activity-documentary" | "criminal-activity-educational" | "criminal-activity-fictional" | "criminal-activity-fraud" | "criminal-activity-gambling" | "criminal-activity-graffiti" | "criminal-activity-grooming" | "criminal-activity-historical" | "criminal-activity-instructions" | "criminal-activity-preparation" | "criminal-activity-promotion" | "criminal-activity-request" | "criminal-activity-sexual-solicitation" | "criminal-activity-substances" | "criminal-activity-support-prevention" | "criminal-activity-tobacco" | "harassment-abuse" | "harassment-bullying" | "harassment-documentary" | "harassment-educational" | "harassment-encouragement" | "harassment-fictional" | "harassment-historical" | "harassment-mild" | "harassment-public-target" | "harassment-sexual" | "harassment-support-prevention" | "harassment-threat" | "hate-abuse" | "hate-adjudicated-nazi-crimes-denial" | "hate-counterspeech" | "hate-dehumanization" | "hate-documentary" | "hate-educational" | "hate-exclusion" | "hate-fictional" | "hate-historical" | "hate-hostility" | "hate-inferiority" | "hate-nazi-genocide-denial-or-approval" | "hate-nazi-genocide-public-peace" | "hate-nazi-insignia-public-display" | "hate-nazi-symbols-public-display" | "hate-personal" | "hate-slurs" | "hate-support-prevention" | "hate-symbol" | "hate-threat" | "personal-information-contact" | "personal-information-credentials" | "personal-information-documentary" | "personal-information-educational" | "personal-information-email" | "personal-information-fictional" | "personal-information-financial" | "personal-information-government-id" | "personal-information-historical" | "personal-information-identifiers" | "personal-information-location" | "personal-information-phone" | "personal-information-request" | "personal-information-self-disclosure" | "personal-information-support-prevention" | "personal-information-third-party" | "profanity-documentary" | "profanity-educational" | "profanity-fictional" | "profanity-historical" | "profanity-mild" | "profanity-obfuscated" | "profanity-slurs" | "profanity-strong" | "profanity-support-prevention" | "self-harm-act" | "self-harm-age-restricted" | "self-harm-documentary" | "self-harm-educational" | "self-harm-encouragement" | "self-harm-fictional" | "self-harm-historical" | "self-harm-methods" | "self-harm-preparation" | "self-harm-support-prevention" | "self-harm-thoughts" | "sexual-activity" | "sexual-adult-promotion" | "sexual-assault-media" | "sexual-discussion" | "sexual-documentary" | "sexual-educational" | "sexual-explicit-language" | "sexual-extreme" | "sexual-fictional" | "sexual-historical" | "sexual-intimate-image-abuse" | "sexual-minors" | "sexual-non-consensual" | "sexual-non-erotic-nudity" | "sexual-nudity" | "sexual-paid" | "sexual-pornographic-media" | "sexual-revealing-clothing" | "sexual-solicitation" | "sexual-suggestive" | "sexual-support-prevention" | "sexual-text" | "violence-attack" | "violence-coded-incitement" | "violence-decapitation-act" | "violence-discussion" | "violence-documentary" | "violence-educational" | "violence-encouragement" | "violence-extremism" | "violence-fantasy" | "violence-fictional" | "violence-gore" | "violence-graphic" | "violence-high-impact" | "violence-historical" | "violence-injury" | "violence-natural-death" | "violence-preparation" | "violence-sport" | "violence-support-prevention" | "violence-text" | "violence-threat" | "violence-violent-death" | "violence-weapon" | "violence-wish")[];
398
+ qualifiers: ("criminal-activity-alcohol" | "criminal-activity-coded-incitement" | "criminal-activity-csam" | "criminal-activity-demonstration" | "criminal-activity-discussion" | "criminal-activity-documentary" | "criminal-activity-educational" | "criminal-activity-fictional" | "criminal-activity-fraud" | "criminal-activity-gambling" | "criminal-activity-graffiti" | "criminal-activity-grooming" | "criminal-activity-historical" | "criminal-activity-instructions" | "criminal-activity-preparation" | "criminal-activity-promotion" | "criminal-activity-request" | "criminal-activity-sexual-solicitation" | "criminal-activity-substances" | "criminal-activity-support-prevention" | "criminal-activity-tobacco" | "harassment-abuse" | "harassment-bullying" | "harassment-documentary" | "harassment-educational" | "harassment-encouragement" | "harassment-fictional" | "harassment-historical" | "harassment-mild" | "harassment-public-target" | "harassment-sexual" | "harassment-support-prevention" | "harassment-threat" | "hate-abuse" | "hate-adjudicated-nazi-crimes-denial" | "hate-counterspeech" | "hate-dehumanization" | "hate-documentary" | "hate-educational" | "hate-exclusion" | "hate-fictional" | "hate-historical" | "hate-hostility" | "hate-inferiority" | "hate-nazi-genocide-denial-or-approval" | "hate-nazi-genocide-public-peace" | "hate-nazi-insignia-public-display" | "hate-nazi-symbols-public-display" | "hate-personal" | "hate-slurs" | "hate-support-prevention" | "hate-symbol" | "hate-threat" | "personal-information-contact" | "personal-information-credentials" | "personal-information-documentary" | "personal-information-educational" | "personal-information-email" | "personal-information-fictional" | "personal-information-financial" | "personal-information-government-id" | "personal-information-historical" | "personal-information-identifiers" | "personal-information-location" | "personal-information-phone" | "personal-information-request" | "personal-information-self-disclosure" | "personal-information-support-prevention" | "personal-information-third-party" | "profanity-documentary" | "profanity-educational" | "profanity-fictional" | "profanity-historical" | "profanity-mild" | "profanity-obfuscated" | "profanity-slurs" | "profanity-strong" | "profanity-support-prevention" | "self-harm-act" | "self-harm-age-restricted" | "self-harm-documentary" | "self-harm-educational" | "self-harm-encouragement" | "self-harm-fictional" | "self-harm-historical" | "self-harm-methods" | "self-harm-preparation" | "self-harm-support-prevention" | "self-harm-thoughts" | "sexual-activity" | "sexual-adult-promotion" | "sexual-assault-media" | "sexual-discussion" | "sexual-documentary" | "sexual-educational" | "sexual-explicit-language" | "sexual-extreme" | "sexual-fictional" | "sexual-historical" | "sexual-incest" | "sexual-intimate-image-abuse" | "sexual-minors" | "sexual-non-consensual" | "sexual-non-erotic-nudity" | "sexual-nudity" | "sexual-paid" | "sexual-pornographic-media" | "sexual-revealing-clothing" | "sexual-solicitation" | "sexual-strangulation" | "sexual-suggestive" | "sexual-support-prevention" | "sexual-text" | "violence-attack" | "violence-coded-incitement" | "violence-decapitation-act" | "violence-discussion" | "violence-documentary" | "violence-educational" | "violence-encouragement" | "violence-extremism" | "violence-fantasy" | "violence-fictional" | "violence-gore" | "violence-graphic" | "violence-high-impact" | "violence-historical" | "violence-injury" | "violence-natural-death" | "violence-preparation" | "violence-sport" | "violence-support-prevention" | "violence-text" | "violence-threat" | "violence-violent-death" | "violence-weapon" | "violence-wish")[];
275
399
  }[];
400
+ detections?: {
401
+ people?: "unavailable" | {
402
+ box: [number, number, number, number];
403
+ confidence?: number | undefined;
404
+ }[] | undefined;
405
+ faces?: "unavailable" | {
406
+ box: [number, number, number, number];
407
+ confidence?: number | undefined;
408
+ age?: "adult" | "minor" | {
409
+ low: number;
410
+ high: number;
411
+ } | undefined;
412
+ }[] | undefined;
413
+ } | undefined;
276
414
  } | undefined>;
277
- export { detectTestImage as a, getImageTestCategories as c, TestInput as i, paintTestImage as l, TEST_INPUT_KEY_PATTERN as n, detectTestTrigger as o, TEST_INPUT_PRESETS as r, generateTestTextCode as s, ClassificationTestSignal as t, testInputForSignal as u };
415
+ export { TEST_FACE_AGE_PRESETS as a, TestDetections as c, detectTestTrigger as d, generateTestTextCode as f, testInputForSignal as h, TEST_FACE_AGE_MAX as i, TestInput as l, paintTestImage as m, TEST_DETECTIONS_MAX as n, TEST_INPUT_KEY_PATTERN as o, getImageTestCategories as p, TEST_DETECTION_BOX_MAX as r, TEST_INPUT_PRESETS as s, ClassificationTestSignal as t, detectTestImage as u };
@@ -1,5 +1,5 @@
1
- import { M as SDK_ERROR_CODES, j as CalmLensError } from "./ModerationContextLimits-lLfmyLni.js";
2
- import { t as CalmLensAppClient } from "./CalmLensAppClient-BjlvBweS.js";
1
+ import { R as CalmLensError, z as SDK_ERROR_CODES } from "./ModerationContextLimits-B6_RalCQ.js";
2
+ import { t as CalmLensAppClient } from "./CalmLensAppClient-CK4_Py0c.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.
@@ -307,6 +307,22 @@ const sleep = (ms, signal) => new Promise((resolve) => {
307
307
  resolve();
308
308
  });
309
309
  });
310
+ /** A custom upload is settled once it has a status other than `pending`, or reports none. */
311
+ const checkedCustomUpload = (id, status) => ({
312
+ id,
313
+ status,
314
+ settled: status !== "pending"
315
+ });
316
+ /**
317
+ * An upload preset's upload is settled once its processing is `completed` or `failed`; its
318
+ * moderation status is present only when the preset shows decisions.
319
+ */
320
+ const checkedPresetUpload = ({ id, classification }) => ({
321
+ id,
322
+ status: classification.moderation?.status,
323
+ settled: classification.status === "completed" || classification.status === "failed",
324
+ failed: classification.status === "failed"
325
+ });
310
326
  let nextKey = 0;
311
327
  /**
312
328
  * Uploads files through an upload preset and tracks each one until it has a moderation
@@ -498,12 +514,22 @@ var UploadController = class {
498
514
  });
499
515
  }
500
516
  const deadline = Date.now() + (options.decisionTimeoutMs ?? DEFAULT_DECISION_TIMEOUT_MS);
501
- for (let delay = 1e3; asset.status === "pending" && check && Date.now() < deadline; delay *= 2) {
517
+ for (let delay = 1e3; !asset.settled && check && Date.now() < deadline; delay *= 2) {
502
518
  await sleep(Math.min(delay, Math.max(0, deadline - Date.now())), abort.signal);
503
519
  if (abort.signal.aborted) return;
504
520
  asset = await check(asset.id);
505
521
  }
506
522
  if (abort.signal.aborted) return;
523
+ if (asset.failed) {
524
+ this.#checks.delete(key);
525
+ this.#update(key, {
526
+ stage: "failed",
527
+ progress: null
528
+ });
529
+ const item = this.#find(key);
530
+ if (item) options.onFailed?.(item);
531
+ return;
532
+ }
507
533
  this.#update(key, {
508
534
  stage: "complete",
509
535
  status: asset.status
@@ -540,15 +566,9 @@ var UploadController = class {
540
566
  signal,
541
567
  onProgress
542
568
  });
543
- return {
544
- id: assetId,
545
- status
546
- };
569
+ return checkedCustomUpload(assetId, status);
547
570
  },
548
- retrieve: checkStatus ? async (assetId) => ({
549
- id: assetId,
550
- status: await checkStatus(assetId, { signal })
551
- }) : void 0
571
+ retrieve: checkStatus ? async (assetId) => checkedCustomUpload(assetId, await checkStatus(assetId, { signal })) : void 0
552
572
  };
553
573
  if (!uploadPresetId) throw new CalmLensError(SDK_ERROR_CODES.INVALID_CONFIG, { message: "The uploader needs an uploadPresetId or an upload function" });
554
574
  const options = {
@@ -562,7 +582,7 @@ var UploadController = class {
562
582
  return {
563
583
  create: async () => {
564
584
  const type = file.type || "application/octet-stream";
565
- return client.assets.create({
585
+ return checkedPresetUpload(await client.assets.create({
566
586
  name: file.name,
567
587
  content: isBlob(file) ? {
568
588
  data: file,
@@ -571,9 +591,9 @@ var UploadController = class {
571
591
  uint8Array: new Uint8Array(await file.arrayBuffer()),
572
592
  type
573
593
  }
574
- });
594
+ }));
575
595
  },
576
- retrieve: (assetId) => client.assets.retrieve({ assetId })
596
+ retrieve: async (assetId) => checkedPresetUpload(await client.assets.retrieve({ assetId }))
577
597
  };
578
598
  }
579
599
  async #tokenFor(file, signal) {