@embedpdf/plugin-stamp 3.0.0-next.21 → 3.0.0-next.23

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.
@@ -1,6 +1,6 @@
1
1
  import { BatchResult, DeepPartial, EventHook, OperationOptions, SettingsApi } from "@embedpdf/core";
2
- import { Annotation, AnnotationRef, BinarySource, LocalEngine, PageRef } from "@embedpdf/engine-core/runtime";
3
2
  import { StampPlacement, StampPlacement as StampPlacement$1 } from "@embedpdf/plugin-annotation/contract";
3
+ import { Annotation, AnnotationRef, BinarySource, LocalEngine, PageRef } from "@embedpdf/engine-core/runtime";
4
4
  //#region src/token.d.ts
5
5
  declare const StampToken: import("@embedpdf/core").CapabilityToken<StampCapability>;
6
6
  //#endregion
@@ -96,29 +96,29 @@ type MarkSource = {
96
96
  */
97
97
  interface StampAsset {
98
98
  /** Derived and stable: `${libraryId}:${name}` (never allocated). */
99
- id: string;
100
- libraryId: string;
101
- kind: StampAssetKind;
99
+ readonly id: string;
100
+ readonly libraryId: string;
101
+ readonly kind: StampAssetKind;
102
102
  /**
103
103
  * The stamp's identifier: the text before the first `=` in its library
104
104
  * key, and the placed annotation's `/Name`: a standard name (`Approved`)
105
105
  * or a custom one (`#LBGiYhk8V_oAfmqAPENiwD`). Not display text.
106
106
  */
107
- name: string;
107
+ readonly name: string;
108
108
  /** What the picker shows and the placed annotation's default `/Subj`:
109
109
  * the text after `=` in the library key (`Goedgekeurd`). */
110
- label: string;
110
+ readonly label: string;
111
111
  /** Intrinsic size in PDF points (the source page's crop box / image pixels 1:1). */
112
- size: {
112
+ readonly size: {
113
113
  width: number;
114
114
  height: number;
115
115
  };
116
116
  /** The library page that is this asset. Every asset is a page: a raster
117
117
  * added to a library becomes a page carrying the image. */
118
- page: PageRef;
118
+ readonly page: PageRef;
119
119
  /** An explicit `/Subj` override (PieceInfo); placements use `label` otherwise. */
120
- subject?: string;
121
- categories?: string[];
120
+ readonly subject?: string;
121
+ readonly categories?: string[];
122
122
  }
123
123
  /**
124
124
  * A library is a PDF: its `/Title` is the name, its `/Names /Pages` registry
@@ -127,15 +127,15 @@ interface StampAsset {
127
127
  */
128
128
  interface StampLibrary {
129
129
  /** PieceInfo `Id`: stable while the title is editable. */
130
- id: string;
131
- name: string;
130
+ readonly id: string;
131
+ readonly name: string;
132
132
  /** PieceInfo `Kind`: `'stamps'`, `'signatures'`, or an embedder's own. */
133
- kind: StampLibraryKind;
133
+ readonly kind: StampLibraryKind;
134
134
  /** PieceInfo `Locale`: the language of the labels, when the library says. */
135
- locale?: string;
136
- categories?: string[];
135
+ readonly locale?: string;
136
+ readonly categories?: string[];
137
137
  /** Asset ids in display order. */
138
- assetIds: string[];
138
+ readonly assetIds: string[];
139
139
  }
140
140
  /**
141
141
  * The local engine stamp libraries open in, or a function that makes one. A
@@ -227,7 +227,7 @@ interface ImportLibraryOptions extends OperationOptions {
227
227
  /** Library categories written to catalog `/PieceInfo`. */
228
228
  categories?: string[];
229
229
  /** Kind stamped onto every imported asset. Default `'stamp'`. */
230
- kind?: StampAssetKind;
230
+ assetKind?: StampAssetKind;
231
231
  /** What the file is for; overrides what the file says (an Acrobat-authored set imported for a toolbar). */
232
232
  libraryKind?: StampLibraryKind;
233
233
  /**
@@ -237,7 +237,7 @@ interface ImportLibraryOptions extends OperationOptions {
237
237
  */
238
238
  assetName?: (pageIndex: number) => string;
239
239
  }
240
- interface AddAssetInput {
240
+ interface CreateAssetInput {
241
241
  /** Target library; omitted, a new single-asset library named after the asset. */
242
242
  libraryId?: string;
243
243
  /** The identifier (placed `/Name`). Omit to mint an Acrobat-style `#…` one. */
@@ -265,7 +265,7 @@ interface AddAssetInput {
265
265
  };
266
266
  }
267
267
  /** What `createAssetFromAnnotations()` takes besides the annotations: where the stamp goes and its name. */
268
- type AssetFromAnnotationsInput = Omit<AddAssetInput, 'source' | 'mark' | 'size'>;
268
+ type AssetFromAnnotationsInput = Omit<CreateAssetInput, 'source' | 'mark' | 'size'>;
269
269
  interface StampAssetPatch {
270
270
  readonly label?: string;
271
271
  /** `null` drops the subject override, so placements use the label. */
@@ -274,8 +274,8 @@ interface StampAssetPatch {
274
274
  }
275
275
  /** A cached, browser-paintable render of an asset (PNG from import; raster assets as-is). */
276
276
  interface StampAssetPreview {
277
- bytes: Uint8Array;
278
- mimeType: string;
277
+ readonly bytes: Uint8Array;
278
+ readonly mimeType: string;
279
279
  }
280
280
  interface StampLibraryFilter {
281
281
  readonly kind?: StampLibraryKind | readonly StampLibraryKind[];
@@ -288,7 +288,7 @@ interface StampAssetFilter {
288
288
  /** A library's bytes changed, and why: the one to save it on. */
289
289
  interface StampLibraryChangedEvent {
290
290
  readonly libraryId: string;
291
- readonly reason: 'created' | 'imported' | 'updated' | 'asset-added' | 'asset-updated' | 'asset-removed' | 'removed';
291
+ readonly type: 'created' | 'imported' | 'updated' | 'asset-created' | 'asset-updated' | 'asset-deleted' | 'deleted';
292
292
  }
293
293
  interface StampLibraryCreatedEvent {
294
294
  readonly libraryId: string;
@@ -345,7 +345,7 @@ interface StampCapability extends SettingsApi<StampSettings> {
345
345
  width: number;
346
346
  } & OperationOptions): Promise<StampAssetPreview | null>;
347
347
  /** A copy of the asset's placement bytes (a one-page PDF), or null. */
348
- readAssetBytes(assetId: string): Uint8Array | null;
348
+ getAssetBytes(assetId: string): Uint8Array | null;
349
349
  /** Create an empty library. Fires `onLibraryCreated` and `onLibraryChanged`. */
350
350
  createLibrary(name: string, options?: CreateLibraryOptions): Promise<{
351
351
  library: StampLibrary;
@@ -371,7 +371,7 @@ interface StampCapability extends SettingsApi<StampSettings> {
371
371
  * library, `invalid-input` for bytes that aren't a picture or a taken
372
372
  * identifier. Fires `onAssetCreated`.
373
373
  */
374
- createAsset(input: AddAssetInput, options?: OperationOptions): Promise<{
374
+ createAsset(input: CreateAssetInput, options?: OperationOptions): Promise<{
375
375
  asset: StampAsset;
376
376
  }>;
377
377
  /**
@@ -445,5 +445,5 @@ interface StampCapability extends SettingsApi<StampSettings> {
445
445
  readonly onLibraryChanged: EventHook<StampLibraryChangedEvent>;
446
446
  }
447
447
  //#endregion
448
- export { StampPlacement$1 as A, StampLibraryChangedEvent as C, StampLibraryKind as D, StampLibraryFilter as E, restoreStampLibraries as F, DEFAULT_LIBRARY_KIND as I, StampToken as L, StampLibraryStore as M, memoryStampStore as N, StampLibraryPatch as O, persistStampLibraries as P, StampLibrary as S, StampLibraryDeletedEvent as T, StampAssetUpdatedEvent as _, MarkSource as a, StampDocumentOptions as b, StampArmOptions as c, StampAssetDeletedEvent as d, StampAssetEngine as f, StampAssetPreview as g, StampAssetPatch as h, ImportLibraryOptions as i, StampSettings as j, StampLibraryUpdatedEvent as k, StampAsset as l, StampAssetKind as m, AssetFromAnnotationsInput as n, STAMP_DEFAULTS as o, StampAssetFilter as p, CreateLibraryOptions as r, StampArmChangedEvent as s, AddAssetInput as t, StampAssetCreatedEvent as u, StampCapability as v, StampLibraryCreatedEvent as w, StampFont as x, StampConfig as y };
449
- //# sourceMappingURL=contract-BQP56Vp4.d.cts.map
448
+ export { StampPlacement$1 as A, StampLibraryChangedEvent as C, StampLibraryKind as D, StampLibraryFilter as E, restoreStampLibraries as F, DEFAULT_LIBRARY_KIND as I, StampToken as L, StampLibraryStore as M, memoryStampStore as N, StampLibraryPatch as O, persistStampLibraries as P, StampLibrary as S, StampLibraryDeletedEvent as T, StampAssetUpdatedEvent as _, MarkSource as a, StampDocumentOptions as b, StampArmOptions as c, StampAssetDeletedEvent as d, StampAssetEngine as f, StampAssetPreview as g, StampAssetPatch as h, ImportLibraryOptions as i, StampSettings as j, StampLibraryUpdatedEvent as k, StampAsset as l, StampAssetKind as m, CreateAssetInput as n, STAMP_DEFAULTS as o, StampAssetFilter as p, CreateLibraryOptions as r, StampArmChangedEvent as s, AssetFromAnnotationsInput as t, StampAssetCreatedEvent as u, StampCapability as v, StampLibraryCreatedEvent as w, StampFont as x, StampConfig as y };
449
+ //# sourceMappingURL=contract-Bazr1NDb.d.ts.map
@@ -1,6 +1,6 @@
1
1
  import { BatchResult, DeepPartial, EventHook, OperationOptions, SettingsApi } from "@embedpdf/core";
2
- import { StampPlacement, StampPlacement as StampPlacement$1 } from "@embedpdf/plugin-annotation/contract";
3
2
  import { Annotation, AnnotationRef, BinarySource, LocalEngine, PageRef } from "@embedpdf/engine-core/runtime";
3
+ import { StampPlacement, StampPlacement as StampPlacement$1 } from "@embedpdf/plugin-annotation/contract";
4
4
  //#region src/token.d.ts
5
5
  declare const StampToken: import("@embedpdf/core").CapabilityToken<StampCapability>;
6
6
  //#endregion
@@ -96,29 +96,29 @@ type MarkSource = {
96
96
  */
97
97
  interface StampAsset {
98
98
  /** Derived and stable: `${libraryId}:${name}` (never allocated). */
99
- id: string;
100
- libraryId: string;
101
- kind: StampAssetKind;
99
+ readonly id: string;
100
+ readonly libraryId: string;
101
+ readonly kind: StampAssetKind;
102
102
  /**
103
103
  * The stamp's identifier: the text before the first `=` in its library
104
104
  * key, and the placed annotation's `/Name`: a standard name (`Approved`)
105
105
  * or a custom one (`#LBGiYhk8V_oAfmqAPENiwD`). Not display text.
106
106
  */
107
- name: string;
107
+ readonly name: string;
108
108
  /** What the picker shows and the placed annotation's default `/Subj`:
109
109
  * the text after `=` in the library key (`Goedgekeurd`). */
110
- label: string;
110
+ readonly label: string;
111
111
  /** Intrinsic size in PDF points (the source page's crop box / image pixels 1:1). */
112
- size: {
112
+ readonly size: {
113
113
  width: number;
114
114
  height: number;
115
115
  };
116
116
  /** The library page that is this asset. Every asset is a page: a raster
117
117
  * added to a library becomes a page carrying the image. */
118
- page: PageRef;
118
+ readonly page: PageRef;
119
119
  /** An explicit `/Subj` override (PieceInfo); placements use `label` otherwise. */
120
- subject?: string;
121
- categories?: string[];
120
+ readonly subject?: string;
121
+ readonly categories?: string[];
122
122
  }
123
123
  /**
124
124
  * A library is a PDF: its `/Title` is the name, its `/Names /Pages` registry
@@ -127,15 +127,15 @@ interface StampAsset {
127
127
  */
128
128
  interface StampLibrary {
129
129
  /** PieceInfo `Id`: stable while the title is editable. */
130
- id: string;
131
- name: string;
130
+ readonly id: string;
131
+ readonly name: string;
132
132
  /** PieceInfo `Kind`: `'stamps'`, `'signatures'`, or an embedder's own. */
133
- kind: StampLibraryKind;
133
+ readonly kind: StampLibraryKind;
134
134
  /** PieceInfo `Locale`: the language of the labels, when the library says. */
135
- locale?: string;
136
- categories?: string[];
135
+ readonly locale?: string;
136
+ readonly categories?: string[];
137
137
  /** Asset ids in display order. */
138
- assetIds: string[];
138
+ readonly assetIds: string[];
139
139
  }
140
140
  /**
141
141
  * The local engine stamp libraries open in, or a function that makes one. A
@@ -227,7 +227,7 @@ interface ImportLibraryOptions extends OperationOptions {
227
227
  /** Library categories written to catalog `/PieceInfo`. */
228
228
  categories?: string[];
229
229
  /** Kind stamped onto every imported asset. Default `'stamp'`. */
230
- kind?: StampAssetKind;
230
+ assetKind?: StampAssetKind;
231
231
  /** What the file is for; overrides what the file says (an Acrobat-authored set imported for a toolbar). */
232
232
  libraryKind?: StampLibraryKind;
233
233
  /**
@@ -237,7 +237,7 @@ interface ImportLibraryOptions extends OperationOptions {
237
237
  */
238
238
  assetName?: (pageIndex: number) => string;
239
239
  }
240
- interface AddAssetInput {
240
+ interface CreateAssetInput {
241
241
  /** Target library; omitted, a new single-asset library named after the asset. */
242
242
  libraryId?: string;
243
243
  /** The identifier (placed `/Name`). Omit to mint an Acrobat-style `#…` one. */
@@ -265,7 +265,7 @@ interface AddAssetInput {
265
265
  };
266
266
  }
267
267
  /** What `createAssetFromAnnotations()` takes besides the annotations: where the stamp goes and its name. */
268
- type AssetFromAnnotationsInput = Omit<AddAssetInput, 'source' | 'mark' | 'size'>;
268
+ type AssetFromAnnotationsInput = Omit<CreateAssetInput, 'source' | 'mark' | 'size'>;
269
269
  interface StampAssetPatch {
270
270
  readonly label?: string;
271
271
  /** `null` drops the subject override, so placements use the label. */
@@ -274,8 +274,8 @@ interface StampAssetPatch {
274
274
  }
275
275
  /** A cached, browser-paintable render of an asset (PNG from import; raster assets as-is). */
276
276
  interface StampAssetPreview {
277
- bytes: Uint8Array;
278
- mimeType: string;
277
+ readonly bytes: Uint8Array;
278
+ readonly mimeType: string;
279
279
  }
280
280
  interface StampLibraryFilter {
281
281
  readonly kind?: StampLibraryKind | readonly StampLibraryKind[];
@@ -288,7 +288,7 @@ interface StampAssetFilter {
288
288
  /** A library's bytes changed, and why: the one to save it on. */
289
289
  interface StampLibraryChangedEvent {
290
290
  readonly libraryId: string;
291
- readonly reason: 'created' | 'imported' | 'updated' | 'asset-added' | 'asset-updated' | 'asset-removed' | 'removed';
291
+ readonly type: 'created' | 'imported' | 'updated' | 'asset-created' | 'asset-updated' | 'asset-deleted' | 'deleted';
292
292
  }
293
293
  interface StampLibraryCreatedEvent {
294
294
  readonly libraryId: string;
@@ -345,7 +345,7 @@ interface StampCapability extends SettingsApi<StampSettings> {
345
345
  width: number;
346
346
  } & OperationOptions): Promise<StampAssetPreview | null>;
347
347
  /** A copy of the asset's placement bytes (a one-page PDF), or null. */
348
- readAssetBytes(assetId: string): Uint8Array | null;
348
+ getAssetBytes(assetId: string): Uint8Array | null;
349
349
  /** Create an empty library. Fires `onLibraryCreated` and `onLibraryChanged`. */
350
350
  createLibrary(name: string, options?: CreateLibraryOptions): Promise<{
351
351
  library: StampLibrary;
@@ -371,7 +371,7 @@ interface StampCapability extends SettingsApi<StampSettings> {
371
371
  * library, `invalid-input` for bytes that aren't a picture or a taken
372
372
  * identifier. Fires `onAssetCreated`.
373
373
  */
374
- createAsset(input: AddAssetInput, options?: OperationOptions): Promise<{
374
+ createAsset(input: CreateAssetInput, options?: OperationOptions): Promise<{
375
375
  asset: StampAsset;
376
376
  }>;
377
377
  /**
@@ -445,5 +445,5 @@ interface StampCapability extends SettingsApi<StampSettings> {
445
445
  readonly onLibraryChanged: EventHook<StampLibraryChangedEvent>;
446
446
  }
447
447
  //#endregion
448
- export { StampPlacement$1 as A, StampLibraryChangedEvent as C, StampLibraryKind as D, StampLibraryFilter as E, restoreStampLibraries as F, DEFAULT_LIBRARY_KIND as I, StampToken as L, StampLibraryStore as M, memoryStampStore as N, StampLibraryPatch as O, persistStampLibraries as P, StampLibrary as S, StampLibraryDeletedEvent as T, StampAssetUpdatedEvent as _, MarkSource as a, StampDocumentOptions as b, StampArmOptions as c, StampAssetDeletedEvent as d, StampAssetEngine as f, StampAssetPreview as g, StampAssetPatch as h, ImportLibraryOptions as i, StampSettings as j, StampLibraryUpdatedEvent as k, StampAsset as l, StampAssetKind as m, AssetFromAnnotationsInput as n, STAMP_DEFAULTS as o, StampAssetFilter as p, CreateLibraryOptions as r, StampArmChangedEvent as s, AddAssetInput as t, StampAssetCreatedEvent as u, StampCapability as v, StampLibraryCreatedEvent as w, StampFont as x, StampConfig as y };
449
- //# sourceMappingURL=contract-D6Hs6iO3.d.ts.map
448
+ export { StampPlacement$1 as A, StampLibraryChangedEvent as C, StampLibraryKind as D, StampLibraryFilter as E, restoreStampLibraries as F, DEFAULT_LIBRARY_KIND as I, StampToken as L, StampLibraryStore as M, memoryStampStore as N, StampLibraryPatch as O, persistStampLibraries as P, StampLibrary as S, StampLibraryDeletedEvent as T, StampAssetUpdatedEvent as _, MarkSource as a, StampDocumentOptions as b, StampArmOptions as c, StampAssetDeletedEvent as d, StampAssetEngine as f, StampAssetPreview as g, StampAssetPatch as h, ImportLibraryOptions as i, StampSettings as j, StampLibraryUpdatedEvent as k, StampAsset as l, StampAssetKind as m, CreateAssetInput as n, STAMP_DEFAULTS as o, StampAssetFilter as p, CreateLibraryOptions as r, StampArmChangedEvent as s, AssetFromAnnotationsInput as t, StampAssetCreatedEvent as u, StampCapability as v, StampLibraryCreatedEvent as w, StampFont as x, StampConfig as y };
449
+ //# sourceMappingURL=contract-CyQ2OdVy.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract-DHcn38S9.js","names":[],"sources":["../src/token.ts","../src/convention.ts","../src/contract.ts"],"sourcesContent":["/** The package token, created once here and re-exported by `contract.ts`. */\nimport { createCapabilityToken } from '@embedpdf/core';\n\nimport type { StampCapability } from './contract';\n\nexport const StampToken = createCapabilityToken<StampCapability>('stamp', {\n hint: `add stampPlugin() from '@embedpdf/plugin-stamp' to your plugins list`,\n});\n","/**\n * Acrobat's stamp-library convention, interpreted in one place. A library is\n * a PDF whose `/Names /Pages` registry names each stamp page with a key of\n * the form `identifier=label`:\n *\n * - `identifier` (before the first `=`) is the stamp's durable identity\n * and becomes the placed annotation's `/Name` — a standard name such as\n * `Approved`, or a custom one such as Acrobat's `#LBGiYhk8V_oAfmqAPENiwD`;\n * - `label` (after it) is what the picker shows and the placed\n * annotation's default `/Subj`.\n *\n * The engine never interprets key text; this module does. A key without\n * `=` is its own label. `#` is never stripped: it is part of the identity.\n */\nimport type { PieceInfoPatch } from '@embedpdf/engine-core/runtime';\nimport type { StampAssetKind } from './contract';\n\nexport interface StampKey {\n name: string;\n label: string;\n}\n\nexport function parseStampKey(key: string): StampKey {\n const separator = key.indexOf('=');\n if (separator < 0) return { name: key, label: key };\n return { name: key.slice(0, separator), label: key.slice(separator + 1) };\n}\n\nexport function stampKey(name: string, label: string): string {\n return `${name}=${label}`;\n}\n\nconst BASE62 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n\n/**\n * A fresh identifier for a stamp authored here, in Acrobat's own shape\n * (`#` + 22 base-62 characters) so a stamp created in this viewer keeps its\n * identity when the library is opened and placed in Acrobat.\n */\nexport function customStampName(random: () => number = Math.random): string {\n let name = '#';\n for (let i = 0; i < 22; i++) name += BASE62[Math.floor(random() * BASE62.length)];\n return name;\n}\n\n/** Asset ids are derived, not allocated: library id + identifier. */\nexport function assetIdFor(libraryId: string, name: string): string {\n return `${libraryId}:${name}`;\n}\n\n// ── PieceInfo: only what has no standard home ────────────────────────────────\n//\n// The title, the registry, and the artwork are standard PDF. What remains\n// (a durable library id, categories, a locale, a stamp's kind and an explicit\n// `/Subj` override) rides `/PieceInfo` under these application names, in the\n// shape below, so every write produces the dictionary the import reads.\n\n/** Catalog `/PieceInfo` application name for library-level data. */\nexport const STAMP_LIBRARY_PIECEINFO_APP = 'EMBD_StampLibrary';\n/** Page `/PieceInfo` application name for per-stamp data. */\nexport const STAMP_PIECEINFO_APP = 'EMBD_Stamp';\n/** The PieceInfo format version both dictionaries carry in `Version`. */\nexport const STAMP_PIECEINFO_VERSION = 2;\n\n/** The library kind every file has unless it says otherwise. */\nexport const DEFAULT_LIBRARY_KIND = 'stamps';\n\n/** `/Kind` names: the two the plugin defines keep their PDF spellings; others are written as given. */\nexport function libraryKindToPdfName(kind: string): string {\n return kind === 'stamps' ? 'StampLibrary' : kind === 'signatures' ? 'SignatureLibrary' : kind;\n}\n\nexport function libraryKindFromPdfName(name: string | undefined): string {\n if (!name || name === 'StampLibrary') return DEFAULT_LIBRARY_KIND;\n return name === 'SignatureLibrary' ? 'signatures' : name;\n}\n\nexport function stampKindToPdfName(kind: StampAssetKind): string {\n return kind === 'signature' ? 'Signature' : kind === 'initials' ? 'Initials' : 'Stamp';\n}\n\n/** The catalog patch: library id, categories, locale. The name is `/Title`. */\nexport function stampLibraryPieceInfo(\n id: string,\n options: { kind?: string; categories?: readonly string[]; locale?: string } = {},\n): PieceInfoPatch {\n return {\n Version: STAMP_PIECEINFO_VERSION,\n Id: id,\n Kind: { name: libraryKindToPdfName(options.kind ?? DEFAULT_LIBRARY_KIND) },\n // Format version 2 keeps the name in the PDF's /Title.\n Name: null,\n Categories: options.categories ?? null,\n Locale: options.locale ?? null,\n };\n}\n\n/** The page patch: kind, an explicit `/Subj` override, categories. */\nexport function stampPieceInfo(\n kind: StampAssetKind,\n options: { subject?: string | null; categories?: readonly string[] } = {},\n): PieceInfoPatch {\n return {\n Version: STAMP_PIECEINFO_VERSION,\n Kind: { name: stampKindToPdfName(kind) },\n // Format version 2 keeps the identifier and label in the /Names /Pages\n // key; only an explicit /Subj override has no standard home. The format\n // version 1 `Name`/`Subject` keys are cleared, so a re-imported format\n // version 1 library cannot disagree with its registry.\n Name: null,\n Subject: null,\n SubjectOverride: options.subject ?? null,\n Categories: options.categories ?? null,\n };\n}\n","/** @embedpdf/plugin-stamp/contract: the public stamp vocabulary. */\nimport type {\n BatchResult,\n DeepPartial,\n EventHook,\n OperationOptions,\n SettingsApi,\n} from '@embedpdf/core';\nimport type {\n Annotation,\n AnnotationRef,\n BinarySource,\n LocalEngine,\n PageRef,\n} from '@embedpdf/engine-core/runtime';\nimport type { StampPlacement } from '@embedpdf/plugin-annotation/contract';\n\nexport { StampToken } from './token';\nexport { DEFAULT_LIBRARY_KIND } from './convention';\nexport type { StampLibraryStore } from './persistence';\nexport type { StampPlacement } from '@embedpdf/plugin-annotation/contract';\n\n/**\n * The stamp plugin: a workspace-scoped asset substrate.\n *\n * The design law (\"documents have a home; assets ride the wire\"): imported\n * PDF libraries retain one canonical PDF whose catalog/page `/PieceInfo`\n * carries their metadata. Per-asset PDFs and previews are derived caches used\n * for placement. Standalone PNG/JPEG assets remain loose because the engine\n * intentionally has no raster-to-PDF-page authoring primitive.\n */\n\nexport type StampAssetKind = 'stamp' | 'signature' | 'initials';\n\n/**\n * What a library file is for: the routing key a surface queries by. Open:\n * the plugin defines `stamps` (the default) and `signatures`; an embedder\n * may define its own (`toolbar`, `legal-seals`). Persisted in the file.\n */\nexport type StampLibraryKind = string;\n\n/**\n * How a mark is authored: drawn strokes (kept as a vector path), typed text\n * in a standard font or one of the `fonts` setting's (embedded by the\n * flatten), a raster image, or a page\n * of a PDF. Ink strokes are in points, from the top-left and y down like\n * every page position, any origin — the asset page is the mark's bounds.\n */\nexport type MarkSource =\n | {\n kind: 'ink';\n strokes: ReadonlyArray<ReadonlyArray<{ x: number; y: number }>>;\n color?: string;\n strokeWidth?: number;\n }\n | { kind: 'text'; text: string; fontFamily: string; color?: string; fontSize?: number }\n | { kind: 'image'; source: BinarySource }\n | { kind: 'pdf'; source: BinarySource; pageIndex?: number };\n\n/**\n * One asset's serializable descriptor. The bytes and the cached preview are\n * deliberately not here: session state holds serializable data only, and\n * binary lives in the capability and crosses only as call arguments and\n * return values, mirroring the engine's own BinarySource rule.\n */\nexport interface StampAsset {\n /** Derived and stable: `${libraryId}:${name}` (never allocated). */\n id: string;\n libraryId: string;\n kind: StampAssetKind;\n /**\n * The stamp's identifier: the text before the first `=` in its library\n * key, and the placed annotation's `/Name`: a standard name (`Approved`)\n * or a custom one (`#LBGiYhk8V_oAfmqAPENiwD`). Not display text.\n */\n name: string;\n /** What the picker shows and the placed annotation's default `/Subj`:\n * the text after `=` in the library key (`Goedgekeurd`). */\n label: string;\n /** Intrinsic size in PDF points (the source page's crop box / image pixels 1:1). */\n size: { width: number; height: number };\n /** The library page that is this asset. Every asset is a page: a raster\n * added to a library becomes a page carrying the image. */\n page: PageRef;\n /** An explicit `/Subj` override (PieceInfo); placements use `label` otherwise. */\n subject?: string;\n categories?: string[];\n}\n\n/**\n * A library is a PDF: its `/Title` is the name, its `/Names /Pages` registry\n * the assets, its pages the artwork, PieceInfo only what has no standard\n * home. One imported PDF becomes one library; `exportLibrary` returns it.\n */\nexport interface StampLibrary {\n /** PieceInfo `Id`: stable while the title is editable. */\n id: string;\n name: string;\n /** PieceInfo `Kind`: `'stamps'`, `'signatures'`, or an embedder's own. */\n kind: StampLibraryKind;\n /** PieceInfo `Locale`: the language of the labels, when the library says. */\n locale?: string;\n categories?: string[];\n /** Asset ids in display order. */\n assetIds: string[];\n}\n\n// ── settings ──────────────────────────────────────────────────────────────\n\n/**\n * The local engine stamp libraries open in, or a function that makes one. A\n * function is called on the first import, not at startup, and its engine is\n * destroyed with the plugin.\n */\nexport type StampAssetEngine = LocalEngine | (() => LocalEngine | Promise<LocalEngine>);\n\n/**\n * A font typed marks can be written in (`mark: { kind: 'text', fontFamily: key }`), beyond the\n * standard 14 and the asset engine's own: registered on the asset engine the first time a mark\n * names it.\n */\nexport interface StampFont {\n /** What a typed mark's `fontFamily` names it by. */\n readonly key: string;\n /** Its TrueType or OpenType file, read the first time a mark names it. */\n readonly load: () => Promise<Uint8Array>;\n}\n\n/**\n * The stamp plugin's settings. `stampPlugin(config)` registers them over\n * {@link STAMP_DEFAULTS}, and `updateSettings()` changes them while the app\n * runs.\n */\nexport interface StampSettings {\n /**\n * The engine stamp libraries open in. `null` uses the viewer's own engine,\n * which is right when that engine is local. A cloud viewer passes a local\n * engine, or a function that makes one:\n *\n * ```ts\n * stampPlugin({\n * assetEngine: () => import('@embedpdf/engine').then((module) => module.createLocalEngine()),\n * })\n * ```\n */\n readonly assetEngine: StampAssetEngine | null;\n /**\n * The fonts typed marks can be written in, each registered on the asset engine the first time\n * a mark names it: a mark is written on the asset engine, so the font goes there, whichever\n * engine the viewer draws with.\n */\n readonly fonts: readonly StampFont[];\n /** The width of a stamp's thumbnail, in device pixels. */\n readonly previewWidth: number;\n /**\n * Fill in a dynamic stamp's form fields when it's armed or placed.\n * Scripting itself is the workspace's one JavaScript switch,\n * `actionsPlugin({ javascript: { enabled } })`: without the actions plugin,\n * or with scripting off, a stamp is placed as it is. `false` keeps every\n * stamp as reviewed, even with scripting on.\n */\n readonly dynamic: boolean;\n}\n\n/** What the stamp settings are when the app registers none. */\nexport const STAMP_DEFAULTS: StampSettings = {\n assetEngine: null,\n fonts: [],\n previewWidth: 256,\n dynamic: true,\n};\n\n/** What `stampPlugin(config)` takes: any of the settings, merged over the defaults. */\nexport type StampConfig = DeepPartial<StampSettings>;\n\n// ── verbs ─────────────────────────────────────────────────────────────────\n\n/**\n * Which document a placing verb acts on. Left out, it is the document in\n * scope (`useStamp()` inside a `<DocumentScope>`, a document plugin's\n * `ctx.get(StampToken)`), else the active document.\n */\nexport interface StampDocumentOptions extends OperationOptions {\n readonly documentId?: string;\n}\n\n/** `armAsset()`'s options. */\nexport interface StampArmOptions extends StampDocumentOptions {\n /** Placed width in PDF points; the stamp's own width by default. */\n readonly targetWidth?: number;\n}\n\nexport interface CreateLibraryOptions extends OperationOptions {\n /** The library's id; a fresh one when left out or taken. */\n readonly id?: string;\n /** What the library is for. Default `'stamps'`. */\n readonly kind?: StampLibraryKind;\n readonly categories?: string[];\n}\n\nexport interface StampLibraryPatch {\n readonly name?: string;\n readonly categories?: string[];\n}\n\nexport interface ImportLibraryOptions extends OperationOptions {\n /**\n * Fallback library name, applied only when the PDF carries no `/Title`\n * (an Acrobat-authored or previously exported library names itself).\n * Default `'Stamps'`.\n */\n name?: string;\n /** Library categories written to catalog `/PieceInfo`. */\n categories?: string[];\n /** Kind stamped onto every imported asset. Default `'stamp'`. */\n kind?: StampAssetKind;\n /** What the file is for; overrides what the file says (an Acrobat-authored set imported for a toolbar). */\n libraryKind?: StampLibraryKind;\n /**\n * Fallback per-page labels for a plain PDF (no `/Names /Pages` registry):\n * every page becomes a stamp named `Stamp<n>` with this label. Ignored\n * when the PDF registers its stamps itself.\n */\n assetName?: (pageIndex: number) => string;\n}\n\nexport interface AddAssetInput {\n /** Target library; omitted, a new single-asset library named after the asset. */\n libraryId?: string;\n /** The identifier (placed `/Name`). Omit to mint an Acrobat-style `#…` one. */\n name?: string;\n /** Picker text and default `/Subj`. Defaults to `name`. */\n label?: string;\n kind?: StampAssetKind;\n subject?: string;\n categories?: string[];\n /**\n * PNG, JPEG, or single-page PDF bytes. Exactly one of `source` / `mark`. A\n * raster becomes a page of the library sized to `size` (default: its\n * pixels as points, 1:1) with the image flattened into it, so every asset\n * is a page and every library a complete PDF.\n */\n source?: BinarySource;\n /** An authored mark: drawn, typed, an image, or a PDF page. Exactly one of `source` / `mark`. */\n mark?: MarkSource;\n /** Thumbnail override for pickers (PNG/JPEG); rendered from the page otherwise. */\n preview?: BinarySource;\n /** Page size in PDF points for a raster source. Ignored for PDF sources (the page has one). */\n size?: { width: number; height: number };\n}\n\n/** What `createAssetFromAnnotations()` takes besides the annotations: where the stamp goes and its name. */\nexport type AssetFromAnnotationsInput = Omit<AddAssetInput, 'source' | 'mark' | 'size'>;\n\nexport interface StampAssetPatch {\n readonly label?: string;\n /** `null` drops the subject override, so placements use the label. */\n readonly subject?: string | null;\n readonly categories?: string[];\n}\n\n/** A cached, browser-paintable render of an asset (PNG from import; raster assets as-is). */\nexport interface StampAssetPreview {\n bytes: Uint8Array;\n mimeType: string;\n}\n\nexport interface StampLibraryFilter {\n readonly kind?: StampLibraryKind | readonly StampLibraryKind[];\n}\nexport interface StampAssetFilter {\n readonly libraryId?: string;\n readonly kind?: StampAssetKind;\n readonly category?: string;\n}\n\n// ── events ────────────────────────────────────────────────────────────────\n\n/** A library's bytes changed, and why: the one to save it on. */\nexport interface StampLibraryChangedEvent {\n readonly libraryId: string;\n readonly reason:\n | 'created'\n | 'imported'\n | 'updated'\n | 'asset-added'\n | 'asset-updated'\n | 'asset-removed'\n | 'removed';\n}\nexport interface StampLibraryCreatedEvent {\n readonly libraryId: string;\n readonly library: StampLibrary;\n}\nexport interface StampLibraryUpdatedEvent {\n readonly libraryId: string;\n readonly library: StampLibrary;\n}\nexport interface StampLibraryDeletedEvent {\n readonly libraryId: string;\n readonly library: null;\n}\nexport interface StampAssetCreatedEvent {\n readonly assetId: string;\n readonly libraryId: string;\n readonly asset: StampAsset;\n}\nexport interface StampAssetUpdatedEvent {\n readonly assetId: string;\n readonly libraryId: string;\n readonly asset: StampAsset;\n}\nexport interface StampAssetDeletedEvent {\n readonly assetId: string;\n readonly libraryId: string;\n readonly asset: null;\n}\n/** A stamp was armed on a document, or disarmed (`asset: null`). */\nexport interface StampArmChangedEvent {\n readonly documentId: string;\n readonly asset: StampAsset | null;\n}\n\n/**\n * Stamp libraries and their assets, shared by every document, and placing\n * them on a document. The placing verbs act on the document in scope, else\n * the active one, or the one their options name (`documentId`). A library is\n * a PDF (one page per asset): `exportLibrary` returns the persistence format,\n * `importLibrary` reads it back. Every verb rejects with a `PluginError`, and\n * every async verb takes a `signal`: cancelled, it rejects\n * `operation-cancelled` and changes nothing. The settings belong to the\n * plugin, not to a document.\n */\nexport interface StampCapability extends SettingsApi<StampSettings> {\n // ── reading ──\n listLibraries(filter?: StampLibraryFilter): readonly StampLibrary[];\n getLibrary(libraryId: string): StampLibrary | null;\n /** Assets in the order a picker shows them: by library, then within it. */\n listAssets(filter?: StampAssetFilter): readonly StampAsset[];\n getAsset(assetId: string): StampAsset | null;\n /** The cached thumbnail (the `previewWidth` setting), or null. */\n getAssetPreview(assetId: string): StampAssetPreview | null;\n /** A preview at any width, rendered by the asset engine and cached per width. Rejects `not-found`. */\n renderAssetPreview(\n assetId: string,\n options: { width: number } & OperationOptions,\n ): Promise<StampAssetPreview | null>;\n /** A copy of the asset's placement bytes (a one-page PDF), or null. */\n readAssetBytes(assetId: string): Uint8Array | null;\n\n // ── libraries ──\n /** Create an empty library. Fires `onLibraryCreated` and `onLibraryChanged`. */\n createLibrary(name: string, options?: CreateLibraryOptions): Promise<{ library: StampLibrary }>;\n /** Rename a library or change its categories. Rejects `not-found`. Fires `onLibraryUpdated`. */\n updateLibrary(\n libraryId: string,\n changes: StampLibraryPatch,\n options?: OperationOptions,\n ): Promise<{ library: StampLibrary }>;\n /** Delete a library with its assets. Fires `onLibraryDeleted`. */\n deleteLibrary(libraryId: string, options?: OperationOptions): Promise<void>;\n /**\n * A PDF becomes a library (one asset per page). Rejects `invalid-input` for\n * bytes that aren't a PDF, `unsupported` without a local asset engine.\n * Fires `onLibraryCreated`, then `onAssetCreated` per stamp.\n */\n importLibrary(\n source: BinarySource,\n options?: ImportLibraryOptions,\n ): Promise<{ library: StampLibrary }>;\n /** The library as the PDF it is. Rejects `not-found`. */\n exportLibrary(libraryId: string, options?: OperationOptions): Promise<Uint8Array>;\n\n // ── assets ──\n /**\n * Add a stamp from bytes or a mark. Rejects `not-found` for an unknown\n * library, `invalid-input` for bytes that aren't a picture or a taken\n * identifier. Fires `onAssetCreated`.\n */\n createAsset(input: AddAssetInput, options?: OperationOptions): Promise<{ asset: StampAsset }>;\n /**\n * Annotations on a page of a document become one stamp, exactly as they\n * look. All or nothing: a hidden annotation, one without an appearance, or\n * one on another page fails the call. Rejects `permission-denied` without\n * `doc.download` (see `canCreateFromAnnotations`), `not-found` for a page\n * that isn't in the document.\n */\n createAssetFromAnnotations(\n page: PageRef | number,\n refs: readonly AnnotationRef[],\n input: AssetFromAnnotationsInput,\n options?: StampDocumentOptions,\n ): Promise<{ asset: StampAsset }>;\n /** Change a stamp's label, subject or categories; its identifier never changes. Rejects `not-found`. */\n updateAsset(\n assetId: string,\n changes: StampAssetPatch,\n options?: OperationOptions,\n ): Promise<{ asset: StampAsset }>;\n /** Remove a stamp from its library. Fires `onAssetDeleted`. */\n deleteAsset(assetId: string, options?: OperationOptions): Promise<void>;\n /** Move a stamp to another library: a copy there, with a new id, then the original goes. */\n moveAsset(\n assetId: string,\n to: { libraryId: string },\n options?: OperationOptions,\n ): Promise<{ asset: StampAsset }>;\n /** Copy a stamp within its library. */\n duplicateAsset(\n assetId: string,\n options?: { label?: string } & OperationOptions,\n ): Promise<{ asset: StampAsset }>;\n\n // ── placing, on one document ──\n /**\n * Arm a stamp: the next click on the document places it, with a preview\n * under the pointer. Rejects `not-found` for an unknown asset,\n * `permission-denied` without `annotations:create` (see `canPlace`).\n * Fires `onArmChanged`.\n */\n armAsset(assetId: string, options?: StampArmOptions): Promise<void>;\n /** Disarm the stamp without placing it. Fires `onArmChanged` when one was armed. */\n disarm(documentId?: string): void;\n /** The stamp the next click on the document places, or null. */\n getArmedAsset(documentId?: string): StampAsset | null;\n /**\n * Place a stamp without the pointer, its middle on `center`, sized by its\n * picture and kept on the page. Resolves `{ annotation }`. Selected only\n * with `select: true`. Rejects `permission-denied` without\n * `annotations:create`, `not-found` for an unknown asset or page.\n */\n placeAsset(\n assetId: string,\n placement: StampPlacement,\n options?: StampDocumentOptions,\n ): Promise<{ annotation: Annotation }>;\n /**\n * Place one stamp at the same spot on several pages (refs or indexes), or\n * on `'all'`. Resolves the placed stamps, and the pages that failed.\n */\n placeAssetOnPages(\n assetId: string,\n pages: readonly (PageRef | number)[] | 'all',\n placement: Omit<StampPlacement, 'page'>,\n options?: StampDocumentOptions,\n ): Promise<BatchResult<Annotation, PageRef>>;\n /** Whether a stamp may be armed or placed on the document (`annotations:create`). */\n canPlace(documentId?: string): boolean;\n /** Whether annotations of the document may become a stamp, which copies them out (`doc.download`). */\n canCreateFromAnnotations(documentId?: string): boolean;\n /** Whether libraries can be imported: false once an import found no local engine to open them in. */\n canImport(): boolean;\n\n // ── events ──\n readonly onLibraryCreated: EventHook<StampLibraryCreatedEvent>;\n readonly onLibraryUpdated: EventHook<StampLibraryUpdatedEvent>;\n readonly onLibraryDeleted: EventHook<StampLibraryDeletedEvent>;\n readonly onAssetCreated: EventHook<StampAssetCreatedEvent>;\n readonly onAssetUpdated: EventHook<StampAssetUpdatedEvent>;\n readonly onAssetDeleted: EventHook<StampAssetDeletedEvent>;\n /** A stamp was armed or disarmed on a document. */\n readonly onArmChanged: EventHook<StampArmChangedEvent>;\n /** A library's bytes changed (subscribe to persist). */\n readonly onLibraryChanged: EventHook<StampLibraryChangedEvent>;\n}\n"],"mappings":";;;AAKA,MAAa,aAAa,sBAAuC,SAAS,EACxE,MAAM,uEACR,CAAC;;;ACeD,SAAgB,cAAc,KAAuB;CACnD,MAAM,YAAY,IAAI,QAAQ,GAAG;CACjC,IAAI,YAAY,GAAG,OAAO;EAAE,MAAM;EAAK,OAAO;CAAI;CAClD,OAAO;EAAE,MAAM,IAAI,MAAM,GAAG,SAAS;EAAG,OAAO,IAAI,MAAM,YAAY,CAAC;CAAE;AAC1E;AAEA,SAAgB,SAAS,MAAc,OAAuB;CAC5D,OAAO,GAAG,KAAK,GAAG;AACpB;AAEA,MAAM,SAAS;;;;;;AAOf,SAAgB,gBAAgB,SAAuB,KAAK,QAAgB;CAC1E,IAAI,OAAO;CACX,KAAK,IAAI,IAAI,GAAG,IAAI,IAAI,KAAK,QAAQ,OAAO,KAAK,MAAM,OAAO,IAAI,EAAa;CAC/E,OAAO;AACT;;AAGA,SAAgB,WAAW,WAAmB,MAAsB;CAClE,OAAO,GAAG,UAAU,GAAG;AACzB;;AAUA,MAAa,8BAA8B;;AAE3C,MAAa,sBAAsB;;AAKnC,MAAa,uBAAuB;;AAGpC,SAAgB,qBAAqB,MAAsB;CACzD,OAAO,SAAS,WAAW,iBAAiB,SAAS,eAAe,qBAAqB;AAC3F;AAEA,SAAgB,uBAAuB,MAAkC;CACvE,IAAI,CAAC,QAAQ,SAAS,gBAAgB,OAAO;CAC7C,OAAO,SAAS,qBAAqB,eAAe;AACtD;AAEA,SAAgB,mBAAmB,MAA8B;CAC/D,OAAO,SAAS,cAAc,cAAc,SAAS,aAAa,aAAa;AACjF;;AAGA,SAAgB,sBACd,IACA,UAA8E,CAAC,GAC/D;CAChB,OAAO;EACL,SAAA;EACA,IAAI;EACJ,MAAM,EAAE,MAAM,qBAAqB,QAAQ,QAAA,QAA4B,EAAE;EAEzE,MAAM;EACN,YAAY,QAAQ,cAAc;EAClC,QAAQ,QAAQ,UAAU;CAC5B;AACF;;AAGA,SAAgB,eACd,MACA,UAAuE,CAAC,GACxD;CAChB,OAAO;EACL,SAAA;EACA,MAAM,EAAE,MAAM,mBAAmB,IAAI,EAAE;EAKvC,MAAM;EACN,SAAS;EACT,iBAAiB,QAAQ,WAAW;EACpC,YAAY,QAAQ,cAAc;CACpC;AACF;;;;ACmDA,MAAa,iBAAgC;CAC3C,aAAa;CACb,OAAO,CAAC;CACR,cAAc;CACd,SAAS;AACX"}
1
+ {"version":3,"file":"contract-DHcn38S9.js","names":[],"sources":["../src/token.ts","../src/convention.ts","../src/contract.ts"],"sourcesContent":["/** The package token, created once here and re-exported by `contract.ts`. */\nimport { createCapabilityToken } from '@embedpdf/core';\n\nimport type { StampCapability } from './contract';\n\nexport const StampToken = createCapabilityToken<StampCapability>('stamp', {\n hint: `add stampPlugin() from '@embedpdf/plugin-stamp' to your plugins list`,\n});\n","/**\n * Acrobat's stamp-library convention, interpreted in one place. A library is\n * a PDF whose `/Names /Pages` registry names each stamp page with a key of\n * the form `identifier=label`:\n *\n * - `identifier` (before the first `=`) is the stamp's durable identity\n * and becomes the placed annotation's `/Name` — a standard name such as\n * `Approved`, or a custom one such as Acrobat's `#LBGiYhk8V_oAfmqAPENiwD`;\n * - `label` (after it) is what the picker shows and the placed\n * annotation's default `/Subj`.\n *\n * The engine never interprets key text; this module does. A key without\n * `=` is its own label. `#` is never stripped: it is part of the identity.\n */\nimport type { PieceInfoPatch } from '@embedpdf/engine-core/runtime';\nimport type { StampAssetKind } from './contract';\n\nexport interface StampKey {\n name: string;\n label: string;\n}\n\nexport function parseStampKey(key: string): StampKey {\n const separator = key.indexOf('=');\n if (separator < 0) return { name: key, label: key };\n return { name: key.slice(0, separator), label: key.slice(separator + 1) };\n}\n\nexport function stampKey(name: string, label: string): string {\n return `${name}=${label}`;\n}\n\nconst BASE62 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n\n/**\n * A fresh identifier for a stamp authored here, in Acrobat's own shape\n * (`#` + 22 base-62 characters) so a stamp created in this viewer keeps its\n * identity when the library is opened and placed in Acrobat.\n */\nexport function customStampName(random: () => number = Math.random): string {\n let name = '#';\n for (let i = 0; i < 22; i++) name += BASE62[Math.floor(random() * BASE62.length)];\n return name;\n}\n\n/** Asset ids are derived, not allocated: library id + identifier. */\nexport function assetIdFor(libraryId: string, name: string): string {\n return `${libraryId}:${name}`;\n}\n\n// ── PieceInfo: only what has no standard home ────────────────────────────────\n//\n// The title, the registry, and the artwork are standard PDF. What remains\n// (a durable library id, categories, a locale, a stamp's kind and an explicit\n// `/Subj` override) rides `/PieceInfo` under these application names, in the\n// shape below, so every write produces the dictionary the import reads.\n\n/** Catalog `/PieceInfo` application name for library-level data. */\nexport const STAMP_LIBRARY_PIECEINFO_APP = 'EMBD_StampLibrary';\n/** Page `/PieceInfo` application name for per-stamp data. */\nexport const STAMP_PIECEINFO_APP = 'EMBD_Stamp';\n/** The PieceInfo format version both dictionaries carry in `Version`. */\nexport const STAMP_PIECEINFO_VERSION = 2;\n\n/** The library kind every file has unless it says otherwise. */\nexport const DEFAULT_LIBRARY_KIND = 'stamps';\n\n/** `/Kind` names: the two the plugin defines keep their PDF spellings; others are written as given. */\nexport function libraryKindToPdfName(kind: string): string {\n return kind === 'stamps' ? 'StampLibrary' : kind === 'signatures' ? 'SignatureLibrary' : kind;\n}\n\nexport function libraryKindFromPdfName(name: string | undefined): string {\n if (!name || name === 'StampLibrary') return DEFAULT_LIBRARY_KIND;\n return name === 'SignatureLibrary' ? 'signatures' : name;\n}\n\nexport function stampKindToPdfName(kind: StampAssetKind): string {\n return kind === 'signature' ? 'Signature' : kind === 'initials' ? 'Initials' : 'Stamp';\n}\n\n/** The catalog patch: library id, categories, locale. The name is `/Title`. */\nexport function stampLibraryPieceInfo(\n id: string,\n options: { kind?: string; categories?: readonly string[]; locale?: string } = {},\n): PieceInfoPatch {\n return {\n Version: STAMP_PIECEINFO_VERSION,\n Id: id,\n Kind: { name: libraryKindToPdfName(options.kind ?? DEFAULT_LIBRARY_KIND) },\n // Format version 2 keeps the name in the PDF's /Title.\n Name: null,\n Categories: options.categories ?? null,\n Locale: options.locale ?? null,\n };\n}\n\n/** The page patch: kind, an explicit `/Subj` override, categories. */\nexport function stampPieceInfo(\n kind: StampAssetKind,\n options: { subject?: string | null; categories?: readonly string[] } = {},\n): PieceInfoPatch {\n return {\n Version: STAMP_PIECEINFO_VERSION,\n Kind: { name: stampKindToPdfName(kind) },\n // Format version 2 keeps the identifier and label in the /Names /Pages\n // key; only an explicit /Subj override has no standard home. The format\n // version 1 `Name`/`Subject` keys are cleared, so a re-imported format\n // version 1 library cannot disagree with its registry.\n Name: null,\n Subject: null,\n SubjectOverride: options.subject ?? null,\n Categories: options.categories ?? null,\n };\n}\n","/** @embedpdf/plugin-stamp/contract: the public stamp vocabulary. */\nimport type {\n BatchResult,\n DeepPartial,\n EventHook,\n OperationOptions,\n SettingsApi,\n} from '@embedpdf/core';\nimport type {\n Annotation,\n AnnotationRef,\n BinarySource,\n LocalEngine,\n PageRef,\n} from '@embedpdf/engine-core/runtime';\nimport type { StampPlacement } from '@embedpdf/plugin-annotation/contract';\n\nexport { StampToken } from './token';\nexport { DEFAULT_LIBRARY_KIND } from './convention';\nexport type { StampLibraryStore } from './persistence';\nexport type { StampPlacement } from '@embedpdf/plugin-annotation/contract';\n\n/**\n * The stamp plugin: a workspace-scoped asset substrate.\n *\n * The design law (\"documents have a home; assets ride the wire\"): imported\n * PDF libraries retain one canonical PDF whose catalog/page `/PieceInfo`\n * carries their metadata. Per-asset PDFs and previews are derived caches used\n * for placement. Standalone PNG/JPEG assets remain loose because the engine\n * intentionally has no raster-to-PDF-page authoring primitive.\n */\n\nexport type StampAssetKind = 'stamp' | 'signature' | 'initials';\n\n/**\n * What a library file is for: the routing key a surface queries by. Open:\n * the plugin defines `stamps` (the default) and `signatures`; an embedder\n * may define its own (`toolbar`, `legal-seals`). Persisted in the file.\n */\nexport type StampLibraryKind = string;\n\n/**\n * How a mark is authored: drawn strokes (kept as a vector path), typed text\n * in a standard font or one of the `fonts` setting's (embedded by the\n * flatten), a raster image, or a page\n * of a PDF. Ink strokes are in points, from the top-left and y down like\n * every page position, any origin — the asset page is the mark's bounds.\n */\nexport type MarkSource =\n | {\n kind: 'ink';\n strokes: ReadonlyArray<ReadonlyArray<{ x: number; y: number }>>;\n color?: string;\n strokeWidth?: number;\n }\n | { kind: 'text'; text: string; fontFamily: string; color?: string; fontSize?: number }\n | { kind: 'image'; source: BinarySource }\n | { kind: 'pdf'; source: BinarySource; pageIndex?: number };\n\n/**\n * One asset's serializable descriptor. The bytes and the cached preview are\n * deliberately not here: session state holds serializable data only, and\n * binary lives in the capability and crosses only as call arguments and\n * return values, mirroring the engine's own BinarySource rule.\n */\nexport interface StampAsset {\n /** Derived and stable: `${libraryId}:${name}` (never allocated). */\n readonly id: string;\n readonly libraryId: string;\n readonly kind: StampAssetKind;\n /**\n * The stamp's identifier: the text before the first `=` in its library\n * key, and the placed annotation's `/Name`: a standard name (`Approved`)\n * or a custom one (`#LBGiYhk8V_oAfmqAPENiwD`). Not display text.\n */\n readonly name: string;\n /** What the picker shows and the placed annotation's default `/Subj`:\n * the text after `=` in the library key (`Goedgekeurd`). */\n readonly label: string;\n /** Intrinsic size in PDF points (the source page's crop box / image pixels 1:1). */\n readonly size: { width: number; height: number };\n /** The library page that is this asset. Every asset is a page: a raster\n * added to a library becomes a page carrying the image. */\n readonly page: PageRef;\n /** An explicit `/Subj` override (PieceInfo); placements use `label` otherwise. */\n readonly subject?: string;\n readonly categories?: string[];\n}\n\n/**\n * A library is a PDF: its `/Title` is the name, its `/Names /Pages` registry\n * the assets, its pages the artwork, PieceInfo only what has no standard\n * home. One imported PDF becomes one library; `exportLibrary` returns it.\n */\nexport interface StampLibrary {\n /** PieceInfo `Id`: stable while the title is editable. */\n readonly id: string;\n readonly name: string;\n /** PieceInfo `Kind`: `'stamps'`, `'signatures'`, or an embedder's own. */\n readonly kind: StampLibraryKind;\n /** PieceInfo `Locale`: the language of the labels, when the library says. */\n readonly locale?: string;\n readonly categories?: string[];\n /** Asset ids in display order. */\n readonly assetIds: string[];\n}\n\n// ── settings ──────────────────────────────────────────────────────────────\n\n/**\n * The local engine stamp libraries open in, or a function that makes one. A\n * function is called on the first import, not at startup, and its engine is\n * destroyed with the plugin.\n */\nexport type StampAssetEngine = LocalEngine | (() => LocalEngine | Promise<LocalEngine>);\n\n/**\n * A font typed marks can be written in (`mark: { kind: 'text', fontFamily: key }`), beyond the\n * standard 14 and the asset engine's own: registered on the asset engine the first time a mark\n * names it.\n */\nexport interface StampFont {\n /** What a typed mark's `fontFamily` names it by. */\n readonly key: string;\n /** Its TrueType or OpenType file, read the first time a mark names it. */\n readonly load: () => Promise<Uint8Array>;\n}\n\n/**\n * The stamp plugin's settings. `stampPlugin(config)` registers them over\n * {@link STAMP_DEFAULTS}, and `updateSettings()` changes them while the app\n * runs.\n */\nexport interface StampSettings {\n /**\n * The engine stamp libraries open in. `null` uses the viewer's own engine,\n * which is right when that engine is local. A cloud viewer passes a local\n * engine, or a function that makes one:\n *\n * ```ts\n * stampPlugin({\n * assetEngine: () => import('@embedpdf/engine').then((module) => module.createLocalEngine()),\n * })\n * ```\n */\n readonly assetEngine: StampAssetEngine | null;\n /**\n * The fonts typed marks can be written in, each registered on the asset engine the first time\n * a mark names it: a mark is written on the asset engine, so the font goes there, whichever\n * engine the viewer draws with.\n */\n readonly fonts: readonly StampFont[];\n /** The width of a stamp's thumbnail, in device pixels. */\n readonly previewWidth: number;\n /**\n * Fill in a dynamic stamp's form fields when it's armed or placed.\n * Scripting itself is the workspace's one JavaScript switch,\n * `actionsPlugin({ javascript: { enabled } })`: without the actions plugin,\n * or with scripting off, a stamp is placed as it is. `false` keeps every\n * stamp as reviewed, even with scripting on.\n */\n readonly dynamic: boolean;\n}\n\n/** What the stamp settings are when the app registers none. */\nexport const STAMP_DEFAULTS: StampSettings = {\n assetEngine: null,\n fonts: [],\n previewWidth: 256,\n dynamic: true,\n};\n\n/** What `stampPlugin(config)` takes: any of the settings, merged over the defaults. */\nexport type StampConfig = DeepPartial<StampSettings>;\n\n// ── verbs ─────────────────────────────────────────────────────────────────\n\n/**\n * Which document a placing verb acts on. Left out, it is the document in\n * scope (`useStamp()` inside a `<DocumentScope>`, a document plugin's\n * `ctx.get(StampToken)`), else the active document.\n */\nexport interface StampDocumentOptions extends OperationOptions {\n readonly documentId?: string;\n}\n\n/** `armAsset()`'s options. */\nexport interface StampArmOptions extends StampDocumentOptions {\n /** Placed width in PDF points; the stamp's own width by default. */\n readonly targetWidth?: number;\n}\n\nexport interface CreateLibraryOptions extends OperationOptions {\n /** The library's id; a fresh one when left out or taken. */\n readonly id?: string;\n /** What the library is for. Default `'stamps'`. */\n readonly kind?: StampLibraryKind;\n readonly categories?: string[];\n}\n\nexport interface StampLibraryPatch {\n readonly name?: string;\n readonly categories?: string[];\n}\n\nexport interface ImportLibraryOptions extends OperationOptions {\n /**\n * Fallback library name, applied only when the PDF carries no `/Title`\n * (an Acrobat-authored or previously exported library names itself).\n * Default `'Stamps'`.\n */\n name?: string;\n /** Library categories written to catalog `/PieceInfo`. */\n categories?: string[];\n /** Kind stamped onto every imported asset. Default `'stamp'`. */\n assetKind?: StampAssetKind;\n /** What the file is for; overrides what the file says (an Acrobat-authored set imported for a toolbar). */\n libraryKind?: StampLibraryKind;\n /**\n * Fallback per-page labels for a plain PDF (no `/Names /Pages` registry):\n * every page becomes a stamp named `Stamp<n>` with this label. Ignored\n * when the PDF registers its stamps itself.\n */\n assetName?: (pageIndex: number) => string;\n}\n\nexport interface CreateAssetInput {\n /** Target library; omitted, a new single-asset library named after the asset. */\n libraryId?: string;\n /** The identifier (placed `/Name`). Omit to mint an Acrobat-style `#…` one. */\n name?: string;\n /** Picker text and default `/Subj`. Defaults to `name`. */\n label?: string;\n kind?: StampAssetKind;\n subject?: string;\n categories?: string[];\n /**\n * PNG, JPEG, or single-page PDF bytes. Exactly one of `source` / `mark`. A\n * raster becomes a page of the library sized to `size` (default: its\n * pixels as points, 1:1) with the image flattened into it, so every asset\n * is a page and every library a complete PDF.\n */\n source?: BinarySource;\n /** An authored mark: drawn, typed, an image, or a PDF page. Exactly one of `source` / `mark`. */\n mark?: MarkSource;\n /** Thumbnail override for pickers (PNG/JPEG); rendered from the page otherwise. */\n preview?: BinarySource;\n /** Page size in PDF points for a raster source. Ignored for PDF sources (the page has one). */\n size?: { width: number; height: number };\n}\n\n/** What `createAssetFromAnnotations()` takes besides the annotations: where the stamp goes and its name. */\nexport type AssetFromAnnotationsInput = Omit<CreateAssetInput, 'source' | 'mark' | 'size'>;\n\nexport interface StampAssetPatch {\n readonly label?: string;\n /** `null` drops the subject override, so placements use the label. */\n readonly subject?: string | null;\n readonly categories?: string[];\n}\n\n/** A cached, browser-paintable render of an asset (PNG from import; raster assets as-is). */\nexport interface StampAssetPreview {\n readonly bytes: Uint8Array;\n readonly mimeType: string;\n}\n\nexport interface StampLibraryFilter {\n readonly kind?: StampLibraryKind | readonly StampLibraryKind[];\n}\nexport interface StampAssetFilter {\n readonly libraryId?: string;\n readonly kind?: StampAssetKind;\n readonly category?: string;\n}\n\n// ── events ────────────────────────────────────────────────────────────────\n\n/** A library's bytes changed, and why: the one to save it on. */\nexport interface StampLibraryChangedEvent {\n readonly libraryId: string;\n readonly type:\n | 'created'\n | 'imported'\n | 'updated'\n | 'asset-created'\n | 'asset-updated'\n | 'asset-deleted'\n | 'deleted';\n}\nexport interface StampLibraryCreatedEvent {\n readonly libraryId: string;\n readonly library: StampLibrary;\n}\nexport interface StampLibraryUpdatedEvent {\n readonly libraryId: string;\n readonly library: StampLibrary;\n}\nexport interface StampLibraryDeletedEvent {\n readonly libraryId: string;\n readonly library: null;\n}\nexport interface StampAssetCreatedEvent {\n readonly assetId: string;\n readonly libraryId: string;\n readonly asset: StampAsset;\n}\nexport interface StampAssetUpdatedEvent {\n readonly assetId: string;\n readonly libraryId: string;\n readonly asset: StampAsset;\n}\nexport interface StampAssetDeletedEvent {\n readonly assetId: string;\n readonly libraryId: string;\n readonly asset: null;\n}\n/** A stamp was armed on a document, or disarmed (`asset: null`). */\nexport interface StampArmChangedEvent {\n readonly documentId: string;\n readonly asset: StampAsset | null;\n}\n\n/**\n * Stamp libraries and their assets, shared by every document, and placing\n * them on a document. The placing verbs act on the document in scope, else\n * the active one, or the one their options name (`documentId`). A library is\n * a PDF (one page per asset): `exportLibrary` returns the persistence format,\n * `importLibrary` reads it back. Every verb rejects with a `PluginError`, and\n * every async verb takes a `signal`: cancelled, it rejects\n * `operation-cancelled` and changes nothing. The settings belong to the\n * plugin, not to a document.\n */\nexport interface StampCapability extends SettingsApi<StampSettings> {\n // ── reading ──\n listLibraries(filter?: StampLibraryFilter): readonly StampLibrary[];\n getLibrary(libraryId: string): StampLibrary | null;\n /** Assets in the order a picker shows them: by library, then within it. */\n listAssets(filter?: StampAssetFilter): readonly StampAsset[];\n getAsset(assetId: string): StampAsset | null;\n /** The cached thumbnail (the `previewWidth` setting), or null. */\n getAssetPreview(assetId: string): StampAssetPreview | null;\n /** A preview at any width, rendered by the asset engine and cached per width. Rejects `not-found`. */\n renderAssetPreview(\n assetId: string,\n options: { width: number } & OperationOptions,\n ): Promise<StampAssetPreview | null>;\n /** A copy of the asset's placement bytes (a one-page PDF), or null. */\n getAssetBytes(assetId: string): Uint8Array | null;\n\n // ── libraries ──\n /** Create an empty library. Fires `onLibraryCreated` and `onLibraryChanged`. */\n createLibrary(name: string, options?: CreateLibraryOptions): Promise<{ library: StampLibrary }>;\n /** Rename a library or change its categories. Rejects `not-found`. Fires `onLibraryUpdated`. */\n updateLibrary(\n libraryId: string,\n changes: StampLibraryPatch,\n options?: OperationOptions,\n ): Promise<{ library: StampLibrary }>;\n /** Delete a library with its assets. Fires `onLibraryDeleted`. */\n deleteLibrary(libraryId: string, options?: OperationOptions): Promise<void>;\n /**\n * A PDF becomes a library (one asset per page). Rejects `invalid-input` for\n * bytes that aren't a PDF, `unsupported` without a local asset engine.\n * Fires `onLibraryCreated`, then `onAssetCreated` per stamp.\n */\n importLibrary(\n source: BinarySource,\n options?: ImportLibraryOptions,\n ): Promise<{ library: StampLibrary }>;\n /** The library as the PDF it is. Rejects `not-found`. */\n exportLibrary(libraryId: string, options?: OperationOptions): Promise<Uint8Array>;\n\n // ── assets ──\n /**\n * Add a stamp from bytes or a mark. Rejects `not-found` for an unknown\n * library, `invalid-input` for bytes that aren't a picture or a taken\n * identifier. Fires `onAssetCreated`.\n */\n createAsset(input: CreateAssetInput, options?: OperationOptions): Promise<{ asset: StampAsset }>;\n /**\n * Annotations on a page of a document become one stamp, exactly as they\n * look. All or nothing: a hidden annotation, one without an appearance, or\n * one on another page fails the call. Rejects `permission-denied` without\n * `doc.download` (see `canCreateFromAnnotations`), `not-found` for a page\n * that isn't in the document.\n */\n createAssetFromAnnotations(\n page: PageRef | number,\n refs: readonly AnnotationRef[],\n input: AssetFromAnnotationsInput,\n options?: StampDocumentOptions,\n ): Promise<{ asset: StampAsset }>;\n /** Change a stamp's label, subject or categories; its identifier never changes. Rejects `not-found`. */\n updateAsset(\n assetId: string,\n changes: StampAssetPatch,\n options?: OperationOptions,\n ): Promise<{ asset: StampAsset }>;\n /** Remove a stamp from its library. Fires `onAssetDeleted`. */\n deleteAsset(assetId: string, options?: OperationOptions): Promise<void>;\n /** Move a stamp to another library: a copy there, with a new id, then the original goes. */\n moveAsset(\n assetId: string,\n to: { libraryId: string },\n options?: OperationOptions,\n ): Promise<{ asset: StampAsset }>;\n /** Copy a stamp within its library. */\n duplicateAsset(\n assetId: string,\n options?: { label?: string } & OperationOptions,\n ): Promise<{ asset: StampAsset }>;\n\n // ── placing, on one document ──\n /**\n * Arm a stamp: the next click on the document places it, with a preview\n * under the pointer. Rejects `not-found` for an unknown asset,\n * `permission-denied` without `annotations:create` (see `canPlace`).\n * Fires `onArmChanged`.\n */\n armAsset(assetId: string, options?: StampArmOptions): Promise<void>;\n /** Disarm the stamp without placing it. Fires `onArmChanged` when one was armed. */\n disarm(documentId?: string): void;\n /** The stamp the next click on the document places, or null. */\n getArmedAsset(documentId?: string): StampAsset | null;\n /**\n * Place a stamp without the pointer, its middle on `center`, sized by its\n * picture and kept on the page. Resolves `{ annotation }`. Selected only\n * with `select: true`. Rejects `permission-denied` without\n * `annotations:create`, `not-found` for an unknown asset or page.\n */\n placeAsset(\n assetId: string,\n placement: StampPlacement,\n options?: StampDocumentOptions,\n ): Promise<{ annotation: Annotation }>;\n /**\n * Place one stamp at the same spot on several pages (refs or indexes), or\n * on `'all'`. Resolves the placed stamps, and the pages that failed.\n */\n placeAssetOnPages(\n assetId: string,\n pages: readonly (PageRef | number)[] | 'all',\n placement: Omit<StampPlacement, 'page'>,\n options?: StampDocumentOptions,\n ): Promise<BatchResult<Annotation, PageRef>>;\n /** Whether a stamp may be armed or placed on the document (`annotations:create`). */\n canPlace(documentId?: string): boolean;\n /** Whether annotations of the document may become a stamp, which copies them out (`doc.download`). */\n canCreateFromAnnotations(documentId?: string): boolean;\n /** Whether libraries can be imported: false once an import found no local engine to open them in. */\n canImport(): boolean;\n\n // ── events ──\n readonly onLibraryCreated: EventHook<StampLibraryCreatedEvent>;\n readonly onLibraryUpdated: EventHook<StampLibraryUpdatedEvent>;\n readonly onLibraryDeleted: EventHook<StampLibraryDeletedEvent>;\n readonly onAssetCreated: EventHook<StampAssetCreatedEvent>;\n readonly onAssetUpdated: EventHook<StampAssetUpdatedEvent>;\n readonly onAssetDeleted: EventHook<StampAssetDeletedEvent>;\n /** A stamp was armed or disarmed on a document. */\n readonly onArmChanged: EventHook<StampArmChangedEvent>;\n /** A library's bytes changed (subscribe to persist). */\n readonly onLibraryChanged: EventHook<StampLibraryChangedEvent>;\n}\n"],"mappings":";;;AAKA,MAAa,aAAa,sBAAuC,SAAS,EACxE,MAAM,uEACR,CAAC;;;ACeD,SAAgB,cAAc,KAAuB;CACnD,MAAM,YAAY,IAAI,QAAQ,GAAG;CACjC,IAAI,YAAY,GAAG,OAAO;EAAE,MAAM;EAAK,OAAO;CAAI;CAClD,OAAO;EAAE,MAAM,IAAI,MAAM,GAAG,SAAS;EAAG,OAAO,IAAI,MAAM,YAAY,CAAC;CAAE;AAC1E;AAEA,SAAgB,SAAS,MAAc,OAAuB;CAC5D,OAAO,GAAG,KAAK,GAAG;AACpB;AAEA,MAAM,SAAS;;;;;;AAOf,SAAgB,gBAAgB,SAAuB,KAAK,QAAgB;CAC1E,IAAI,OAAO;CACX,KAAK,IAAI,IAAI,GAAG,IAAI,IAAI,KAAK,QAAQ,OAAO,KAAK,MAAM,OAAO,IAAI,EAAa;CAC/E,OAAO;AACT;;AAGA,SAAgB,WAAW,WAAmB,MAAsB;CAClE,OAAO,GAAG,UAAU,GAAG;AACzB;;AAUA,MAAa,8BAA8B;;AAE3C,MAAa,sBAAsB;;AAKnC,MAAa,uBAAuB;;AAGpC,SAAgB,qBAAqB,MAAsB;CACzD,OAAO,SAAS,WAAW,iBAAiB,SAAS,eAAe,qBAAqB;AAC3F;AAEA,SAAgB,uBAAuB,MAAkC;CACvE,IAAI,CAAC,QAAQ,SAAS,gBAAgB,OAAO;CAC7C,OAAO,SAAS,qBAAqB,eAAe;AACtD;AAEA,SAAgB,mBAAmB,MAA8B;CAC/D,OAAO,SAAS,cAAc,cAAc,SAAS,aAAa,aAAa;AACjF;;AAGA,SAAgB,sBACd,IACA,UAA8E,CAAC,GAC/D;CAChB,OAAO;EACL,SAAA;EACA,IAAI;EACJ,MAAM,EAAE,MAAM,qBAAqB,QAAQ,QAAA,QAA4B,EAAE;EAEzE,MAAM;EACN,YAAY,QAAQ,cAAc;EAClC,QAAQ,QAAQ,UAAU;CAC5B;AACF;;AAGA,SAAgB,eACd,MACA,UAAuE,CAAC,GACxD;CAChB,OAAO;EACL,SAAA;EACA,MAAM,EAAE,MAAM,mBAAmB,IAAI,EAAE;EAKvC,MAAM;EACN,SAAS;EACT,iBAAiB,QAAQ,WAAW;EACpC,YAAY,QAAQ,cAAc;CACpC;AACF;;;;ACmDA,MAAa,iBAAgC;CAC3C,aAAa;CACb,OAAO,CAAC;CACR,cAAc;CACd,SAAS;AACX"}
@@ -1 +1 @@
1
- {"version":3,"file":"contract-Dj5KiMyW.cjs","names":[],"sources":["../src/token.ts","../src/convention.ts","../src/contract.ts"],"sourcesContent":["/** The package token, created once here and re-exported by `contract.ts`. */\nimport { createCapabilityToken } from '@embedpdf/core';\n\nimport type { StampCapability } from './contract';\n\nexport const StampToken = createCapabilityToken<StampCapability>('stamp', {\n hint: `add stampPlugin() from '@embedpdf/plugin-stamp' to your plugins list`,\n});\n","/**\n * Acrobat's stamp-library convention, interpreted in one place. A library is\n * a PDF whose `/Names /Pages` registry names each stamp page with a key of\n * the form `identifier=label`:\n *\n * - `identifier` (before the first `=`) is the stamp's durable identity\n * and becomes the placed annotation's `/Name` — a standard name such as\n * `Approved`, or a custom one such as Acrobat's `#LBGiYhk8V_oAfmqAPENiwD`;\n * - `label` (after it) is what the picker shows and the placed\n * annotation's default `/Subj`.\n *\n * The engine never interprets key text; this module does. A key without\n * `=` is its own label. `#` is never stripped: it is part of the identity.\n */\nimport type { PieceInfoPatch } from '@embedpdf/engine-core/runtime';\nimport type { StampAssetKind } from './contract';\n\nexport interface StampKey {\n name: string;\n label: string;\n}\n\nexport function parseStampKey(key: string): StampKey {\n const separator = key.indexOf('=');\n if (separator < 0) return { name: key, label: key };\n return { name: key.slice(0, separator), label: key.slice(separator + 1) };\n}\n\nexport function stampKey(name: string, label: string): string {\n return `${name}=${label}`;\n}\n\nconst BASE62 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n\n/**\n * A fresh identifier for a stamp authored here, in Acrobat's own shape\n * (`#` + 22 base-62 characters) so a stamp created in this viewer keeps its\n * identity when the library is opened and placed in Acrobat.\n */\nexport function customStampName(random: () => number = Math.random): string {\n let name = '#';\n for (let i = 0; i < 22; i++) name += BASE62[Math.floor(random() * BASE62.length)];\n return name;\n}\n\n/** Asset ids are derived, not allocated: library id + identifier. */\nexport function assetIdFor(libraryId: string, name: string): string {\n return `${libraryId}:${name}`;\n}\n\n// ── PieceInfo: only what has no standard home ────────────────────────────────\n//\n// The title, the registry, and the artwork are standard PDF. What remains\n// (a durable library id, categories, a locale, a stamp's kind and an explicit\n// `/Subj` override) rides `/PieceInfo` under these application names, in the\n// shape below, so every write produces the dictionary the import reads.\n\n/** Catalog `/PieceInfo` application name for library-level data. */\nexport const STAMP_LIBRARY_PIECEINFO_APP = 'EMBD_StampLibrary';\n/** Page `/PieceInfo` application name for per-stamp data. */\nexport const STAMP_PIECEINFO_APP = 'EMBD_Stamp';\n/** The PieceInfo format version both dictionaries carry in `Version`. */\nexport const STAMP_PIECEINFO_VERSION = 2;\n\n/** The library kind every file has unless it says otherwise. */\nexport const DEFAULT_LIBRARY_KIND = 'stamps';\n\n/** `/Kind` names: the two the plugin defines keep their PDF spellings; others are written as given. */\nexport function libraryKindToPdfName(kind: string): string {\n return kind === 'stamps' ? 'StampLibrary' : kind === 'signatures' ? 'SignatureLibrary' : kind;\n}\n\nexport function libraryKindFromPdfName(name: string | undefined): string {\n if (!name || name === 'StampLibrary') return DEFAULT_LIBRARY_KIND;\n return name === 'SignatureLibrary' ? 'signatures' : name;\n}\n\nexport function stampKindToPdfName(kind: StampAssetKind): string {\n return kind === 'signature' ? 'Signature' : kind === 'initials' ? 'Initials' : 'Stamp';\n}\n\n/** The catalog patch: library id, categories, locale. The name is `/Title`. */\nexport function stampLibraryPieceInfo(\n id: string,\n options: { kind?: string; categories?: readonly string[]; locale?: string } = {},\n): PieceInfoPatch {\n return {\n Version: STAMP_PIECEINFO_VERSION,\n Id: id,\n Kind: { name: libraryKindToPdfName(options.kind ?? DEFAULT_LIBRARY_KIND) },\n // Format version 2 keeps the name in the PDF's /Title.\n Name: null,\n Categories: options.categories ?? null,\n Locale: options.locale ?? null,\n };\n}\n\n/** The page patch: kind, an explicit `/Subj` override, categories. */\nexport function stampPieceInfo(\n kind: StampAssetKind,\n options: { subject?: string | null; categories?: readonly string[] } = {},\n): PieceInfoPatch {\n return {\n Version: STAMP_PIECEINFO_VERSION,\n Kind: { name: stampKindToPdfName(kind) },\n // Format version 2 keeps the identifier and label in the /Names /Pages\n // key; only an explicit /Subj override has no standard home. The format\n // version 1 `Name`/`Subject` keys are cleared, so a re-imported format\n // version 1 library cannot disagree with its registry.\n Name: null,\n Subject: null,\n SubjectOverride: options.subject ?? null,\n Categories: options.categories ?? null,\n };\n}\n","/** @embedpdf/plugin-stamp/contract: the public stamp vocabulary. */\nimport type {\n BatchResult,\n DeepPartial,\n EventHook,\n OperationOptions,\n SettingsApi,\n} from '@embedpdf/core';\nimport type {\n Annotation,\n AnnotationRef,\n BinarySource,\n LocalEngine,\n PageRef,\n} from '@embedpdf/engine-core/runtime';\nimport type { StampPlacement } from '@embedpdf/plugin-annotation/contract';\n\nexport { StampToken } from './token';\nexport { DEFAULT_LIBRARY_KIND } from './convention';\nexport type { StampLibraryStore } from './persistence';\nexport type { StampPlacement } from '@embedpdf/plugin-annotation/contract';\n\n/**\n * The stamp plugin: a workspace-scoped asset substrate.\n *\n * The design law (\"documents have a home; assets ride the wire\"): imported\n * PDF libraries retain one canonical PDF whose catalog/page `/PieceInfo`\n * carries their metadata. Per-asset PDFs and previews are derived caches used\n * for placement. Standalone PNG/JPEG assets remain loose because the engine\n * intentionally has no raster-to-PDF-page authoring primitive.\n */\n\nexport type StampAssetKind = 'stamp' | 'signature' | 'initials';\n\n/**\n * What a library file is for: the routing key a surface queries by. Open:\n * the plugin defines `stamps` (the default) and `signatures`; an embedder\n * may define its own (`toolbar`, `legal-seals`). Persisted in the file.\n */\nexport type StampLibraryKind = string;\n\n/**\n * How a mark is authored: drawn strokes (kept as a vector path), typed text\n * in a standard font or one of the `fonts` setting's (embedded by the\n * flatten), a raster image, or a page\n * of a PDF. Ink strokes are in points, from the top-left and y down like\n * every page position, any origin — the asset page is the mark's bounds.\n */\nexport type MarkSource =\n | {\n kind: 'ink';\n strokes: ReadonlyArray<ReadonlyArray<{ x: number; y: number }>>;\n color?: string;\n strokeWidth?: number;\n }\n | { kind: 'text'; text: string; fontFamily: string; color?: string; fontSize?: number }\n | { kind: 'image'; source: BinarySource }\n | { kind: 'pdf'; source: BinarySource; pageIndex?: number };\n\n/**\n * One asset's serializable descriptor. The bytes and the cached preview are\n * deliberately not here: session state holds serializable data only, and\n * binary lives in the capability and crosses only as call arguments and\n * return values, mirroring the engine's own BinarySource rule.\n */\nexport interface StampAsset {\n /** Derived and stable: `${libraryId}:${name}` (never allocated). */\n id: string;\n libraryId: string;\n kind: StampAssetKind;\n /**\n * The stamp's identifier: the text before the first `=` in its library\n * key, and the placed annotation's `/Name`: a standard name (`Approved`)\n * or a custom one (`#LBGiYhk8V_oAfmqAPENiwD`). Not display text.\n */\n name: string;\n /** What the picker shows and the placed annotation's default `/Subj`:\n * the text after `=` in the library key (`Goedgekeurd`). */\n label: string;\n /** Intrinsic size in PDF points (the source page's crop box / image pixels 1:1). */\n size: { width: number; height: number };\n /** The library page that is this asset. Every asset is a page: a raster\n * added to a library becomes a page carrying the image. */\n page: PageRef;\n /** An explicit `/Subj` override (PieceInfo); placements use `label` otherwise. */\n subject?: string;\n categories?: string[];\n}\n\n/**\n * A library is a PDF: its `/Title` is the name, its `/Names /Pages` registry\n * the assets, its pages the artwork, PieceInfo only what has no standard\n * home. One imported PDF becomes one library; `exportLibrary` returns it.\n */\nexport interface StampLibrary {\n /** PieceInfo `Id`: stable while the title is editable. */\n id: string;\n name: string;\n /** PieceInfo `Kind`: `'stamps'`, `'signatures'`, or an embedder's own. */\n kind: StampLibraryKind;\n /** PieceInfo `Locale`: the language of the labels, when the library says. */\n locale?: string;\n categories?: string[];\n /** Asset ids in display order. */\n assetIds: string[];\n}\n\n// ── settings ──────────────────────────────────────────────────────────────\n\n/**\n * The local engine stamp libraries open in, or a function that makes one. A\n * function is called on the first import, not at startup, and its engine is\n * destroyed with the plugin.\n */\nexport type StampAssetEngine = LocalEngine | (() => LocalEngine | Promise<LocalEngine>);\n\n/**\n * A font typed marks can be written in (`mark: { kind: 'text', fontFamily: key }`), beyond the\n * standard 14 and the asset engine's own: registered on the asset engine the first time a mark\n * names it.\n */\nexport interface StampFont {\n /** What a typed mark's `fontFamily` names it by. */\n readonly key: string;\n /** Its TrueType or OpenType file, read the first time a mark names it. */\n readonly load: () => Promise<Uint8Array>;\n}\n\n/**\n * The stamp plugin's settings. `stampPlugin(config)` registers them over\n * {@link STAMP_DEFAULTS}, and `updateSettings()` changes them while the app\n * runs.\n */\nexport interface StampSettings {\n /**\n * The engine stamp libraries open in. `null` uses the viewer's own engine,\n * which is right when that engine is local. A cloud viewer passes a local\n * engine, or a function that makes one:\n *\n * ```ts\n * stampPlugin({\n * assetEngine: () => import('@embedpdf/engine').then((module) => module.createLocalEngine()),\n * })\n * ```\n */\n readonly assetEngine: StampAssetEngine | null;\n /**\n * The fonts typed marks can be written in, each registered on the asset engine the first time\n * a mark names it: a mark is written on the asset engine, so the font goes there, whichever\n * engine the viewer draws with.\n */\n readonly fonts: readonly StampFont[];\n /** The width of a stamp's thumbnail, in device pixels. */\n readonly previewWidth: number;\n /**\n * Fill in a dynamic stamp's form fields when it's armed or placed.\n * Scripting itself is the workspace's one JavaScript switch,\n * `actionsPlugin({ javascript: { enabled } })`: without the actions plugin,\n * or with scripting off, a stamp is placed as it is. `false` keeps every\n * stamp as reviewed, even with scripting on.\n */\n readonly dynamic: boolean;\n}\n\n/** What the stamp settings are when the app registers none. */\nexport const STAMP_DEFAULTS: StampSettings = {\n assetEngine: null,\n fonts: [],\n previewWidth: 256,\n dynamic: true,\n};\n\n/** What `stampPlugin(config)` takes: any of the settings, merged over the defaults. */\nexport type StampConfig = DeepPartial<StampSettings>;\n\n// ── verbs ─────────────────────────────────────────────────────────────────\n\n/**\n * Which document a placing verb acts on. Left out, it is the document in\n * scope (`useStamp()` inside a `<DocumentScope>`, a document plugin's\n * `ctx.get(StampToken)`), else the active document.\n */\nexport interface StampDocumentOptions extends OperationOptions {\n readonly documentId?: string;\n}\n\n/** `armAsset()`'s options. */\nexport interface StampArmOptions extends StampDocumentOptions {\n /** Placed width in PDF points; the stamp's own width by default. */\n readonly targetWidth?: number;\n}\n\nexport interface CreateLibraryOptions extends OperationOptions {\n /** The library's id; a fresh one when left out or taken. */\n readonly id?: string;\n /** What the library is for. Default `'stamps'`. */\n readonly kind?: StampLibraryKind;\n readonly categories?: string[];\n}\n\nexport interface StampLibraryPatch {\n readonly name?: string;\n readonly categories?: string[];\n}\n\nexport interface ImportLibraryOptions extends OperationOptions {\n /**\n * Fallback library name, applied only when the PDF carries no `/Title`\n * (an Acrobat-authored or previously exported library names itself).\n * Default `'Stamps'`.\n */\n name?: string;\n /** Library categories written to catalog `/PieceInfo`. */\n categories?: string[];\n /** Kind stamped onto every imported asset. Default `'stamp'`. */\n kind?: StampAssetKind;\n /** What the file is for; overrides what the file says (an Acrobat-authored set imported for a toolbar). */\n libraryKind?: StampLibraryKind;\n /**\n * Fallback per-page labels for a plain PDF (no `/Names /Pages` registry):\n * every page becomes a stamp named `Stamp<n>` with this label. Ignored\n * when the PDF registers its stamps itself.\n */\n assetName?: (pageIndex: number) => string;\n}\n\nexport interface AddAssetInput {\n /** Target library; omitted, a new single-asset library named after the asset. */\n libraryId?: string;\n /** The identifier (placed `/Name`). Omit to mint an Acrobat-style `#…` one. */\n name?: string;\n /** Picker text and default `/Subj`. Defaults to `name`. */\n label?: string;\n kind?: StampAssetKind;\n subject?: string;\n categories?: string[];\n /**\n * PNG, JPEG, or single-page PDF bytes. Exactly one of `source` / `mark`. A\n * raster becomes a page of the library sized to `size` (default: its\n * pixels as points, 1:1) with the image flattened into it, so every asset\n * is a page and every library a complete PDF.\n */\n source?: BinarySource;\n /** An authored mark: drawn, typed, an image, or a PDF page. Exactly one of `source` / `mark`. */\n mark?: MarkSource;\n /** Thumbnail override for pickers (PNG/JPEG); rendered from the page otherwise. */\n preview?: BinarySource;\n /** Page size in PDF points for a raster source. Ignored for PDF sources (the page has one). */\n size?: { width: number; height: number };\n}\n\n/** What `createAssetFromAnnotations()` takes besides the annotations: where the stamp goes and its name. */\nexport type AssetFromAnnotationsInput = Omit<AddAssetInput, 'source' | 'mark' | 'size'>;\n\nexport interface StampAssetPatch {\n readonly label?: string;\n /** `null` drops the subject override, so placements use the label. */\n readonly subject?: string | null;\n readonly categories?: string[];\n}\n\n/** A cached, browser-paintable render of an asset (PNG from import; raster assets as-is). */\nexport interface StampAssetPreview {\n bytes: Uint8Array;\n mimeType: string;\n}\n\nexport interface StampLibraryFilter {\n readonly kind?: StampLibraryKind | readonly StampLibraryKind[];\n}\nexport interface StampAssetFilter {\n readonly libraryId?: string;\n readonly kind?: StampAssetKind;\n readonly category?: string;\n}\n\n// ── events ────────────────────────────────────────────────────────────────\n\n/** A library's bytes changed, and why: the one to save it on. */\nexport interface StampLibraryChangedEvent {\n readonly libraryId: string;\n readonly reason:\n | 'created'\n | 'imported'\n | 'updated'\n | 'asset-added'\n | 'asset-updated'\n | 'asset-removed'\n | 'removed';\n}\nexport interface StampLibraryCreatedEvent {\n readonly libraryId: string;\n readonly library: StampLibrary;\n}\nexport interface StampLibraryUpdatedEvent {\n readonly libraryId: string;\n readonly library: StampLibrary;\n}\nexport interface StampLibraryDeletedEvent {\n readonly libraryId: string;\n readonly library: null;\n}\nexport interface StampAssetCreatedEvent {\n readonly assetId: string;\n readonly libraryId: string;\n readonly asset: StampAsset;\n}\nexport interface StampAssetUpdatedEvent {\n readonly assetId: string;\n readonly libraryId: string;\n readonly asset: StampAsset;\n}\nexport interface StampAssetDeletedEvent {\n readonly assetId: string;\n readonly libraryId: string;\n readonly asset: null;\n}\n/** A stamp was armed on a document, or disarmed (`asset: null`). */\nexport interface StampArmChangedEvent {\n readonly documentId: string;\n readonly asset: StampAsset | null;\n}\n\n/**\n * Stamp libraries and their assets, shared by every document, and placing\n * them on a document. The placing verbs act on the document in scope, else\n * the active one, or the one their options name (`documentId`). A library is\n * a PDF (one page per asset): `exportLibrary` returns the persistence format,\n * `importLibrary` reads it back. Every verb rejects with a `PluginError`, and\n * every async verb takes a `signal`: cancelled, it rejects\n * `operation-cancelled` and changes nothing. The settings belong to the\n * plugin, not to a document.\n */\nexport interface StampCapability extends SettingsApi<StampSettings> {\n // ── reading ──\n listLibraries(filter?: StampLibraryFilter): readonly StampLibrary[];\n getLibrary(libraryId: string): StampLibrary | null;\n /** Assets in the order a picker shows them: by library, then within it. */\n listAssets(filter?: StampAssetFilter): readonly StampAsset[];\n getAsset(assetId: string): StampAsset | null;\n /** The cached thumbnail (the `previewWidth` setting), or null. */\n getAssetPreview(assetId: string): StampAssetPreview | null;\n /** A preview at any width, rendered by the asset engine and cached per width. Rejects `not-found`. */\n renderAssetPreview(\n assetId: string,\n options: { width: number } & OperationOptions,\n ): Promise<StampAssetPreview | null>;\n /** A copy of the asset's placement bytes (a one-page PDF), or null. */\n readAssetBytes(assetId: string): Uint8Array | null;\n\n // ── libraries ──\n /** Create an empty library. Fires `onLibraryCreated` and `onLibraryChanged`. */\n createLibrary(name: string, options?: CreateLibraryOptions): Promise<{ library: StampLibrary }>;\n /** Rename a library or change its categories. Rejects `not-found`. Fires `onLibraryUpdated`. */\n updateLibrary(\n libraryId: string,\n changes: StampLibraryPatch,\n options?: OperationOptions,\n ): Promise<{ library: StampLibrary }>;\n /** Delete a library with its assets. Fires `onLibraryDeleted`. */\n deleteLibrary(libraryId: string, options?: OperationOptions): Promise<void>;\n /**\n * A PDF becomes a library (one asset per page). Rejects `invalid-input` for\n * bytes that aren't a PDF, `unsupported` without a local asset engine.\n * Fires `onLibraryCreated`, then `onAssetCreated` per stamp.\n */\n importLibrary(\n source: BinarySource,\n options?: ImportLibraryOptions,\n ): Promise<{ library: StampLibrary }>;\n /** The library as the PDF it is. Rejects `not-found`. */\n exportLibrary(libraryId: string, options?: OperationOptions): Promise<Uint8Array>;\n\n // ── assets ──\n /**\n * Add a stamp from bytes or a mark. Rejects `not-found` for an unknown\n * library, `invalid-input` for bytes that aren't a picture or a taken\n * identifier. Fires `onAssetCreated`.\n */\n createAsset(input: AddAssetInput, options?: OperationOptions): Promise<{ asset: StampAsset }>;\n /**\n * Annotations on a page of a document become one stamp, exactly as they\n * look. All or nothing: a hidden annotation, one without an appearance, or\n * one on another page fails the call. Rejects `permission-denied` without\n * `doc.download` (see `canCreateFromAnnotations`), `not-found` for a page\n * that isn't in the document.\n */\n createAssetFromAnnotations(\n page: PageRef | number,\n refs: readonly AnnotationRef[],\n input: AssetFromAnnotationsInput,\n options?: StampDocumentOptions,\n ): Promise<{ asset: StampAsset }>;\n /** Change a stamp's label, subject or categories; its identifier never changes. Rejects `not-found`. */\n updateAsset(\n assetId: string,\n changes: StampAssetPatch,\n options?: OperationOptions,\n ): Promise<{ asset: StampAsset }>;\n /** Remove a stamp from its library. Fires `onAssetDeleted`. */\n deleteAsset(assetId: string, options?: OperationOptions): Promise<void>;\n /** Move a stamp to another library: a copy there, with a new id, then the original goes. */\n moveAsset(\n assetId: string,\n to: { libraryId: string },\n options?: OperationOptions,\n ): Promise<{ asset: StampAsset }>;\n /** Copy a stamp within its library. */\n duplicateAsset(\n assetId: string,\n options?: { label?: string } & OperationOptions,\n ): Promise<{ asset: StampAsset }>;\n\n // ── placing, on one document ──\n /**\n * Arm a stamp: the next click on the document places it, with a preview\n * under the pointer. Rejects `not-found` for an unknown asset,\n * `permission-denied` without `annotations:create` (see `canPlace`).\n * Fires `onArmChanged`.\n */\n armAsset(assetId: string, options?: StampArmOptions): Promise<void>;\n /** Disarm the stamp without placing it. Fires `onArmChanged` when one was armed. */\n disarm(documentId?: string): void;\n /** The stamp the next click on the document places, or null. */\n getArmedAsset(documentId?: string): StampAsset | null;\n /**\n * Place a stamp without the pointer, its middle on `center`, sized by its\n * picture and kept on the page. Resolves `{ annotation }`. Selected only\n * with `select: true`. Rejects `permission-denied` without\n * `annotations:create`, `not-found` for an unknown asset or page.\n */\n placeAsset(\n assetId: string,\n placement: StampPlacement,\n options?: StampDocumentOptions,\n ): Promise<{ annotation: Annotation }>;\n /**\n * Place one stamp at the same spot on several pages (refs or indexes), or\n * on `'all'`. Resolves the placed stamps, and the pages that failed.\n */\n placeAssetOnPages(\n assetId: string,\n pages: readonly (PageRef | number)[] | 'all',\n placement: Omit<StampPlacement, 'page'>,\n options?: StampDocumentOptions,\n ): Promise<BatchResult<Annotation, PageRef>>;\n /** Whether a stamp may be armed or placed on the document (`annotations:create`). */\n canPlace(documentId?: string): boolean;\n /** Whether annotations of the document may become a stamp, which copies them out (`doc.download`). */\n canCreateFromAnnotations(documentId?: string): boolean;\n /** Whether libraries can be imported: false once an import found no local engine to open them in. */\n canImport(): boolean;\n\n // ── events ──\n readonly onLibraryCreated: EventHook<StampLibraryCreatedEvent>;\n readonly onLibraryUpdated: EventHook<StampLibraryUpdatedEvent>;\n readonly onLibraryDeleted: EventHook<StampLibraryDeletedEvent>;\n readonly onAssetCreated: EventHook<StampAssetCreatedEvent>;\n readonly onAssetUpdated: EventHook<StampAssetUpdatedEvent>;\n readonly onAssetDeleted: EventHook<StampAssetDeletedEvent>;\n /** A stamp was armed or disarmed on a document. */\n readonly onArmChanged: EventHook<StampArmChangedEvent>;\n /** A library's bytes changed (subscribe to persist). */\n readonly onLibraryChanged: EventHook<StampLibraryChangedEvent>;\n}\n"],"mappings":";;AAKA,MAAa,cAAA,2BAAA,CAAA,CAAA,sBAAA,CAAoD,SAAS,EACxE,MAAM,uEACR,CAAC;;;ACeD,SAAgB,cAAc,KAAuB;CACnD,MAAM,YAAY,IAAI,QAAQ,GAAG;CACjC,IAAI,YAAY,GAAG,OAAO;EAAE,MAAM;EAAK,OAAO;CAAI;CAClD,OAAO;EAAE,MAAM,IAAI,MAAM,GAAG,SAAS;EAAG,OAAO,IAAI,MAAM,YAAY,CAAC;CAAE;AAC1E;AAEA,SAAgB,SAAS,MAAc,OAAuB;CAC5D,OAAO,GAAG,KAAK,GAAG;AACpB;AAEA,MAAM,SAAS;;;;;;AAOf,SAAgB,gBAAgB,SAAuB,KAAK,QAAgB;CAC1E,IAAI,OAAO;CACX,KAAK,IAAI,IAAI,GAAG,IAAI,IAAI,KAAK,QAAQ,OAAO,KAAK,MAAM,OAAO,IAAI,EAAa;CAC/E,OAAO;AACT;;AAGA,SAAgB,WAAW,WAAmB,MAAsB;CAClE,OAAO,GAAG,UAAU,GAAG;AACzB;;AAUA,MAAa,8BAA8B;;AAE3C,MAAa,sBAAsB;;AAKnC,MAAa,uBAAuB;;AAGpC,SAAgB,qBAAqB,MAAsB;CACzD,OAAO,SAAS,WAAW,iBAAiB,SAAS,eAAe,qBAAqB;AAC3F;AAEA,SAAgB,uBAAuB,MAAkC;CACvE,IAAI,CAAC,QAAQ,SAAS,gBAAgB,OAAO;CAC7C,OAAO,SAAS,qBAAqB,eAAe;AACtD;AAEA,SAAgB,mBAAmB,MAA8B;CAC/D,OAAO,SAAS,cAAc,cAAc,SAAS,aAAa,aAAa;AACjF;;AAGA,SAAgB,sBACd,IACA,UAA8E,CAAC,GAC/D;CAChB,OAAO;EACL,SAAA;EACA,IAAI;EACJ,MAAM,EAAE,MAAM,qBAAqB,QAAQ,QAAA,QAA4B,EAAE;EAEzE,MAAM;EACN,YAAY,QAAQ,cAAc;EAClC,QAAQ,QAAQ,UAAU;CAC5B;AACF;;AAGA,SAAgB,eACd,MACA,UAAuE,CAAC,GACxD;CAChB,OAAO;EACL,SAAA;EACA,MAAM,EAAE,MAAM,mBAAmB,IAAI,EAAE;EAKvC,MAAM;EACN,SAAS;EACT,iBAAiB,QAAQ,WAAW;EACpC,YAAY,QAAQ,cAAc;CACpC;AACF;;;;ACmDA,MAAa,iBAAgC;CAC3C,aAAa;CACb,OAAO,CAAC;CACR,cAAc;CACd,SAAS;AACX"}
1
+ {"version":3,"file":"contract-Dj5KiMyW.cjs","names":[],"sources":["../src/token.ts","../src/convention.ts","../src/contract.ts"],"sourcesContent":["/** The package token, created once here and re-exported by `contract.ts`. */\nimport { createCapabilityToken } from '@embedpdf/core';\n\nimport type { StampCapability } from './contract';\n\nexport const StampToken = createCapabilityToken<StampCapability>('stamp', {\n hint: `add stampPlugin() from '@embedpdf/plugin-stamp' to your plugins list`,\n});\n","/**\n * Acrobat's stamp-library convention, interpreted in one place. A library is\n * a PDF whose `/Names /Pages` registry names each stamp page with a key of\n * the form `identifier=label`:\n *\n * - `identifier` (before the first `=`) is the stamp's durable identity\n * and becomes the placed annotation's `/Name` — a standard name such as\n * `Approved`, or a custom one such as Acrobat's `#LBGiYhk8V_oAfmqAPENiwD`;\n * - `label` (after it) is what the picker shows and the placed\n * annotation's default `/Subj`.\n *\n * The engine never interprets key text; this module does. A key without\n * `=` is its own label. `#` is never stripped: it is part of the identity.\n */\nimport type { PieceInfoPatch } from '@embedpdf/engine-core/runtime';\nimport type { StampAssetKind } from './contract';\n\nexport interface StampKey {\n name: string;\n label: string;\n}\n\nexport function parseStampKey(key: string): StampKey {\n const separator = key.indexOf('=');\n if (separator < 0) return { name: key, label: key };\n return { name: key.slice(0, separator), label: key.slice(separator + 1) };\n}\n\nexport function stampKey(name: string, label: string): string {\n return `${name}=${label}`;\n}\n\nconst BASE62 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n\n/**\n * A fresh identifier for a stamp authored here, in Acrobat's own shape\n * (`#` + 22 base-62 characters) so a stamp created in this viewer keeps its\n * identity when the library is opened and placed in Acrobat.\n */\nexport function customStampName(random: () => number = Math.random): string {\n let name = '#';\n for (let i = 0; i < 22; i++) name += BASE62[Math.floor(random() * BASE62.length)];\n return name;\n}\n\n/** Asset ids are derived, not allocated: library id + identifier. */\nexport function assetIdFor(libraryId: string, name: string): string {\n return `${libraryId}:${name}`;\n}\n\n// ── PieceInfo: only what has no standard home ────────────────────────────────\n//\n// The title, the registry, and the artwork are standard PDF. What remains\n// (a durable library id, categories, a locale, a stamp's kind and an explicit\n// `/Subj` override) rides `/PieceInfo` under these application names, in the\n// shape below, so every write produces the dictionary the import reads.\n\n/** Catalog `/PieceInfo` application name for library-level data. */\nexport const STAMP_LIBRARY_PIECEINFO_APP = 'EMBD_StampLibrary';\n/** Page `/PieceInfo` application name for per-stamp data. */\nexport const STAMP_PIECEINFO_APP = 'EMBD_Stamp';\n/** The PieceInfo format version both dictionaries carry in `Version`. */\nexport const STAMP_PIECEINFO_VERSION = 2;\n\n/** The library kind every file has unless it says otherwise. */\nexport const DEFAULT_LIBRARY_KIND = 'stamps';\n\n/** `/Kind` names: the two the plugin defines keep their PDF spellings; others are written as given. */\nexport function libraryKindToPdfName(kind: string): string {\n return kind === 'stamps' ? 'StampLibrary' : kind === 'signatures' ? 'SignatureLibrary' : kind;\n}\n\nexport function libraryKindFromPdfName(name: string | undefined): string {\n if (!name || name === 'StampLibrary') return DEFAULT_LIBRARY_KIND;\n return name === 'SignatureLibrary' ? 'signatures' : name;\n}\n\nexport function stampKindToPdfName(kind: StampAssetKind): string {\n return kind === 'signature' ? 'Signature' : kind === 'initials' ? 'Initials' : 'Stamp';\n}\n\n/** The catalog patch: library id, categories, locale. The name is `/Title`. */\nexport function stampLibraryPieceInfo(\n id: string,\n options: { kind?: string; categories?: readonly string[]; locale?: string } = {},\n): PieceInfoPatch {\n return {\n Version: STAMP_PIECEINFO_VERSION,\n Id: id,\n Kind: { name: libraryKindToPdfName(options.kind ?? DEFAULT_LIBRARY_KIND) },\n // Format version 2 keeps the name in the PDF's /Title.\n Name: null,\n Categories: options.categories ?? null,\n Locale: options.locale ?? null,\n };\n}\n\n/** The page patch: kind, an explicit `/Subj` override, categories. */\nexport function stampPieceInfo(\n kind: StampAssetKind,\n options: { subject?: string | null; categories?: readonly string[] } = {},\n): PieceInfoPatch {\n return {\n Version: STAMP_PIECEINFO_VERSION,\n Kind: { name: stampKindToPdfName(kind) },\n // Format version 2 keeps the identifier and label in the /Names /Pages\n // key; only an explicit /Subj override has no standard home. The format\n // version 1 `Name`/`Subject` keys are cleared, so a re-imported format\n // version 1 library cannot disagree with its registry.\n Name: null,\n Subject: null,\n SubjectOverride: options.subject ?? null,\n Categories: options.categories ?? null,\n };\n}\n","/** @embedpdf/plugin-stamp/contract: the public stamp vocabulary. */\nimport type {\n BatchResult,\n DeepPartial,\n EventHook,\n OperationOptions,\n SettingsApi,\n} from '@embedpdf/core';\nimport type {\n Annotation,\n AnnotationRef,\n BinarySource,\n LocalEngine,\n PageRef,\n} from '@embedpdf/engine-core/runtime';\nimport type { StampPlacement } from '@embedpdf/plugin-annotation/contract';\n\nexport { StampToken } from './token';\nexport { DEFAULT_LIBRARY_KIND } from './convention';\nexport type { StampLibraryStore } from './persistence';\nexport type { StampPlacement } from '@embedpdf/plugin-annotation/contract';\n\n/**\n * The stamp plugin: a workspace-scoped asset substrate.\n *\n * The design law (\"documents have a home; assets ride the wire\"): imported\n * PDF libraries retain one canonical PDF whose catalog/page `/PieceInfo`\n * carries their metadata. Per-asset PDFs and previews are derived caches used\n * for placement. Standalone PNG/JPEG assets remain loose because the engine\n * intentionally has no raster-to-PDF-page authoring primitive.\n */\n\nexport type StampAssetKind = 'stamp' | 'signature' | 'initials';\n\n/**\n * What a library file is for: the routing key a surface queries by. Open:\n * the plugin defines `stamps` (the default) and `signatures`; an embedder\n * may define its own (`toolbar`, `legal-seals`). Persisted in the file.\n */\nexport type StampLibraryKind = string;\n\n/**\n * How a mark is authored: drawn strokes (kept as a vector path), typed text\n * in a standard font or one of the `fonts` setting's (embedded by the\n * flatten), a raster image, or a page\n * of a PDF. Ink strokes are in points, from the top-left and y down like\n * every page position, any origin — the asset page is the mark's bounds.\n */\nexport type MarkSource =\n | {\n kind: 'ink';\n strokes: ReadonlyArray<ReadonlyArray<{ x: number; y: number }>>;\n color?: string;\n strokeWidth?: number;\n }\n | { kind: 'text'; text: string; fontFamily: string; color?: string; fontSize?: number }\n | { kind: 'image'; source: BinarySource }\n | { kind: 'pdf'; source: BinarySource; pageIndex?: number };\n\n/**\n * One asset's serializable descriptor. The bytes and the cached preview are\n * deliberately not here: session state holds serializable data only, and\n * binary lives in the capability and crosses only as call arguments and\n * return values, mirroring the engine's own BinarySource rule.\n */\nexport interface StampAsset {\n /** Derived and stable: `${libraryId}:${name}` (never allocated). */\n readonly id: string;\n readonly libraryId: string;\n readonly kind: StampAssetKind;\n /**\n * The stamp's identifier: the text before the first `=` in its library\n * key, and the placed annotation's `/Name`: a standard name (`Approved`)\n * or a custom one (`#LBGiYhk8V_oAfmqAPENiwD`). Not display text.\n */\n readonly name: string;\n /** What the picker shows and the placed annotation's default `/Subj`:\n * the text after `=` in the library key (`Goedgekeurd`). */\n readonly label: string;\n /** Intrinsic size in PDF points (the source page's crop box / image pixels 1:1). */\n readonly size: { width: number; height: number };\n /** The library page that is this asset. Every asset is a page: a raster\n * added to a library becomes a page carrying the image. */\n readonly page: PageRef;\n /** An explicit `/Subj` override (PieceInfo); placements use `label` otherwise. */\n readonly subject?: string;\n readonly categories?: string[];\n}\n\n/**\n * A library is a PDF: its `/Title` is the name, its `/Names /Pages` registry\n * the assets, its pages the artwork, PieceInfo only what has no standard\n * home. One imported PDF becomes one library; `exportLibrary` returns it.\n */\nexport interface StampLibrary {\n /** PieceInfo `Id`: stable while the title is editable. */\n readonly id: string;\n readonly name: string;\n /** PieceInfo `Kind`: `'stamps'`, `'signatures'`, or an embedder's own. */\n readonly kind: StampLibraryKind;\n /** PieceInfo `Locale`: the language of the labels, when the library says. */\n readonly locale?: string;\n readonly categories?: string[];\n /** Asset ids in display order. */\n readonly assetIds: string[];\n}\n\n// ── settings ──────────────────────────────────────────────────────────────\n\n/**\n * The local engine stamp libraries open in, or a function that makes one. A\n * function is called on the first import, not at startup, and its engine is\n * destroyed with the plugin.\n */\nexport type StampAssetEngine = LocalEngine | (() => LocalEngine | Promise<LocalEngine>);\n\n/**\n * A font typed marks can be written in (`mark: { kind: 'text', fontFamily: key }`), beyond the\n * standard 14 and the asset engine's own: registered on the asset engine the first time a mark\n * names it.\n */\nexport interface StampFont {\n /** What a typed mark's `fontFamily` names it by. */\n readonly key: string;\n /** Its TrueType or OpenType file, read the first time a mark names it. */\n readonly load: () => Promise<Uint8Array>;\n}\n\n/**\n * The stamp plugin's settings. `stampPlugin(config)` registers them over\n * {@link STAMP_DEFAULTS}, and `updateSettings()` changes them while the app\n * runs.\n */\nexport interface StampSettings {\n /**\n * The engine stamp libraries open in. `null` uses the viewer's own engine,\n * which is right when that engine is local. A cloud viewer passes a local\n * engine, or a function that makes one:\n *\n * ```ts\n * stampPlugin({\n * assetEngine: () => import('@embedpdf/engine').then((module) => module.createLocalEngine()),\n * })\n * ```\n */\n readonly assetEngine: StampAssetEngine | null;\n /**\n * The fonts typed marks can be written in, each registered on the asset engine the first time\n * a mark names it: a mark is written on the asset engine, so the font goes there, whichever\n * engine the viewer draws with.\n */\n readonly fonts: readonly StampFont[];\n /** The width of a stamp's thumbnail, in device pixels. */\n readonly previewWidth: number;\n /**\n * Fill in a dynamic stamp's form fields when it's armed or placed.\n * Scripting itself is the workspace's one JavaScript switch,\n * `actionsPlugin({ javascript: { enabled } })`: without the actions plugin,\n * or with scripting off, a stamp is placed as it is. `false` keeps every\n * stamp as reviewed, even with scripting on.\n */\n readonly dynamic: boolean;\n}\n\n/** What the stamp settings are when the app registers none. */\nexport const STAMP_DEFAULTS: StampSettings = {\n assetEngine: null,\n fonts: [],\n previewWidth: 256,\n dynamic: true,\n};\n\n/** What `stampPlugin(config)` takes: any of the settings, merged over the defaults. */\nexport type StampConfig = DeepPartial<StampSettings>;\n\n// ── verbs ─────────────────────────────────────────────────────────────────\n\n/**\n * Which document a placing verb acts on. Left out, it is the document in\n * scope (`useStamp()` inside a `<DocumentScope>`, a document plugin's\n * `ctx.get(StampToken)`), else the active document.\n */\nexport interface StampDocumentOptions extends OperationOptions {\n readonly documentId?: string;\n}\n\n/** `armAsset()`'s options. */\nexport interface StampArmOptions extends StampDocumentOptions {\n /** Placed width in PDF points; the stamp's own width by default. */\n readonly targetWidth?: number;\n}\n\nexport interface CreateLibraryOptions extends OperationOptions {\n /** The library's id; a fresh one when left out or taken. */\n readonly id?: string;\n /** What the library is for. Default `'stamps'`. */\n readonly kind?: StampLibraryKind;\n readonly categories?: string[];\n}\n\nexport interface StampLibraryPatch {\n readonly name?: string;\n readonly categories?: string[];\n}\n\nexport interface ImportLibraryOptions extends OperationOptions {\n /**\n * Fallback library name, applied only when the PDF carries no `/Title`\n * (an Acrobat-authored or previously exported library names itself).\n * Default `'Stamps'`.\n */\n name?: string;\n /** Library categories written to catalog `/PieceInfo`. */\n categories?: string[];\n /** Kind stamped onto every imported asset. Default `'stamp'`. */\n assetKind?: StampAssetKind;\n /** What the file is for; overrides what the file says (an Acrobat-authored set imported for a toolbar). */\n libraryKind?: StampLibraryKind;\n /**\n * Fallback per-page labels for a plain PDF (no `/Names /Pages` registry):\n * every page becomes a stamp named `Stamp<n>` with this label. Ignored\n * when the PDF registers its stamps itself.\n */\n assetName?: (pageIndex: number) => string;\n}\n\nexport interface CreateAssetInput {\n /** Target library; omitted, a new single-asset library named after the asset. */\n libraryId?: string;\n /** The identifier (placed `/Name`). Omit to mint an Acrobat-style `#…` one. */\n name?: string;\n /** Picker text and default `/Subj`. Defaults to `name`. */\n label?: string;\n kind?: StampAssetKind;\n subject?: string;\n categories?: string[];\n /**\n * PNG, JPEG, or single-page PDF bytes. Exactly one of `source` / `mark`. A\n * raster becomes a page of the library sized to `size` (default: its\n * pixels as points, 1:1) with the image flattened into it, so every asset\n * is a page and every library a complete PDF.\n */\n source?: BinarySource;\n /** An authored mark: drawn, typed, an image, or a PDF page. Exactly one of `source` / `mark`. */\n mark?: MarkSource;\n /** Thumbnail override for pickers (PNG/JPEG); rendered from the page otherwise. */\n preview?: BinarySource;\n /** Page size in PDF points for a raster source. Ignored for PDF sources (the page has one). */\n size?: { width: number; height: number };\n}\n\n/** What `createAssetFromAnnotations()` takes besides the annotations: where the stamp goes and its name. */\nexport type AssetFromAnnotationsInput = Omit<CreateAssetInput, 'source' | 'mark' | 'size'>;\n\nexport interface StampAssetPatch {\n readonly label?: string;\n /** `null` drops the subject override, so placements use the label. */\n readonly subject?: string | null;\n readonly categories?: string[];\n}\n\n/** A cached, browser-paintable render of an asset (PNG from import; raster assets as-is). */\nexport interface StampAssetPreview {\n readonly bytes: Uint8Array;\n readonly mimeType: string;\n}\n\nexport interface StampLibraryFilter {\n readonly kind?: StampLibraryKind | readonly StampLibraryKind[];\n}\nexport interface StampAssetFilter {\n readonly libraryId?: string;\n readonly kind?: StampAssetKind;\n readonly category?: string;\n}\n\n// ── events ────────────────────────────────────────────────────────────────\n\n/** A library's bytes changed, and why: the one to save it on. */\nexport interface StampLibraryChangedEvent {\n readonly libraryId: string;\n readonly type:\n | 'created'\n | 'imported'\n | 'updated'\n | 'asset-created'\n | 'asset-updated'\n | 'asset-deleted'\n | 'deleted';\n}\nexport interface StampLibraryCreatedEvent {\n readonly libraryId: string;\n readonly library: StampLibrary;\n}\nexport interface StampLibraryUpdatedEvent {\n readonly libraryId: string;\n readonly library: StampLibrary;\n}\nexport interface StampLibraryDeletedEvent {\n readonly libraryId: string;\n readonly library: null;\n}\nexport interface StampAssetCreatedEvent {\n readonly assetId: string;\n readonly libraryId: string;\n readonly asset: StampAsset;\n}\nexport interface StampAssetUpdatedEvent {\n readonly assetId: string;\n readonly libraryId: string;\n readonly asset: StampAsset;\n}\nexport interface StampAssetDeletedEvent {\n readonly assetId: string;\n readonly libraryId: string;\n readonly asset: null;\n}\n/** A stamp was armed on a document, or disarmed (`asset: null`). */\nexport interface StampArmChangedEvent {\n readonly documentId: string;\n readonly asset: StampAsset | null;\n}\n\n/**\n * Stamp libraries and their assets, shared by every document, and placing\n * them on a document. The placing verbs act on the document in scope, else\n * the active one, or the one their options name (`documentId`). A library is\n * a PDF (one page per asset): `exportLibrary` returns the persistence format,\n * `importLibrary` reads it back. Every verb rejects with a `PluginError`, and\n * every async verb takes a `signal`: cancelled, it rejects\n * `operation-cancelled` and changes nothing. The settings belong to the\n * plugin, not to a document.\n */\nexport interface StampCapability extends SettingsApi<StampSettings> {\n // ── reading ──\n listLibraries(filter?: StampLibraryFilter): readonly StampLibrary[];\n getLibrary(libraryId: string): StampLibrary | null;\n /** Assets in the order a picker shows them: by library, then within it. */\n listAssets(filter?: StampAssetFilter): readonly StampAsset[];\n getAsset(assetId: string): StampAsset | null;\n /** The cached thumbnail (the `previewWidth` setting), or null. */\n getAssetPreview(assetId: string): StampAssetPreview | null;\n /** A preview at any width, rendered by the asset engine and cached per width. Rejects `not-found`. */\n renderAssetPreview(\n assetId: string,\n options: { width: number } & OperationOptions,\n ): Promise<StampAssetPreview | null>;\n /** A copy of the asset's placement bytes (a one-page PDF), or null. */\n getAssetBytes(assetId: string): Uint8Array | null;\n\n // ── libraries ──\n /** Create an empty library. Fires `onLibraryCreated` and `onLibraryChanged`. */\n createLibrary(name: string, options?: CreateLibraryOptions): Promise<{ library: StampLibrary }>;\n /** Rename a library or change its categories. Rejects `not-found`. Fires `onLibraryUpdated`. */\n updateLibrary(\n libraryId: string,\n changes: StampLibraryPatch,\n options?: OperationOptions,\n ): Promise<{ library: StampLibrary }>;\n /** Delete a library with its assets. Fires `onLibraryDeleted`. */\n deleteLibrary(libraryId: string, options?: OperationOptions): Promise<void>;\n /**\n * A PDF becomes a library (one asset per page). Rejects `invalid-input` for\n * bytes that aren't a PDF, `unsupported` without a local asset engine.\n * Fires `onLibraryCreated`, then `onAssetCreated` per stamp.\n */\n importLibrary(\n source: BinarySource,\n options?: ImportLibraryOptions,\n ): Promise<{ library: StampLibrary }>;\n /** The library as the PDF it is. Rejects `not-found`. */\n exportLibrary(libraryId: string, options?: OperationOptions): Promise<Uint8Array>;\n\n // ── assets ──\n /**\n * Add a stamp from bytes or a mark. Rejects `not-found` for an unknown\n * library, `invalid-input` for bytes that aren't a picture or a taken\n * identifier. Fires `onAssetCreated`.\n */\n createAsset(input: CreateAssetInput, options?: OperationOptions): Promise<{ asset: StampAsset }>;\n /**\n * Annotations on a page of a document become one stamp, exactly as they\n * look. All or nothing: a hidden annotation, one without an appearance, or\n * one on another page fails the call. Rejects `permission-denied` without\n * `doc.download` (see `canCreateFromAnnotations`), `not-found` for a page\n * that isn't in the document.\n */\n createAssetFromAnnotations(\n page: PageRef | number,\n refs: readonly AnnotationRef[],\n input: AssetFromAnnotationsInput,\n options?: StampDocumentOptions,\n ): Promise<{ asset: StampAsset }>;\n /** Change a stamp's label, subject or categories; its identifier never changes. Rejects `not-found`. */\n updateAsset(\n assetId: string,\n changes: StampAssetPatch,\n options?: OperationOptions,\n ): Promise<{ asset: StampAsset }>;\n /** Remove a stamp from its library. Fires `onAssetDeleted`. */\n deleteAsset(assetId: string, options?: OperationOptions): Promise<void>;\n /** Move a stamp to another library: a copy there, with a new id, then the original goes. */\n moveAsset(\n assetId: string,\n to: { libraryId: string },\n options?: OperationOptions,\n ): Promise<{ asset: StampAsset }>;\n /** Copy a stamp within its library. */\n duplicateAsset(\n assetId: string,\n options?: { label?: string } & OperationOptions,\n ): Promise<{ asset: StampAsset }>;\n\n // ── placing, on one document ──\n /**\n * Arm a stamp: the next click on the document places it, with a preview\n * under the pointer. Rejects `not-found` for an unknown asset,\n * `permission-denied` without `annotations:create` (see `canPlace`).\n * Fires `onArmChanged`.\n */\n armAsset(assetId: string, options?: StampArmOptions): Promise<void>;\n /** Disarm the stamp without placing it. Fires `onArmChanged` when one was armed. */\n disarm(documentId?: string): void;\n /** The stamp the next click on the document places, or null. */\n getArmedAsset(documentId?: string): StampAsset | null;\n /**\n * Place a stamp without the pointer, its middle on `center`, sized by its\n * picture and kept on the page. Resolves `{ annotation }`. Selected only\n * with `select: true`. Rejects `permission-denied` without\n * `annotations:create`, `not-found` for an unknown asset or page.\n */\n placeAsset(\n assetId: string,\n placement: StampPlacement,\n options?: StampDocumentOptions,\n ): Promise<{ annotation: Annotation }>;\n /**\n * Place one stamp at the same spot on several pages (refs or indexes), or\n * on `'all'`. Resolves the placed stamps, and the pages that failed.\n */\n placeAssetOnPages(\n assetId: string,\n pages: readonly (PageRef | number)[] | 'all',\n placement: Omit<StampPlacement, 'page'>,\n options?: StampDocumentOptions,\n ): Promise<BatchResult<Annotation, PageRef>>;\n /** Whether a stamp may be armed or placed on the document (`annotations:create`). */\n canPlace(documentId?: string): boolean;\n /** Whether annotations of the document may become a stamp, which copies them out (`doc.download`). */\n canCreateFromAnnotations(documentId?: string): boolean;\n /** Whether libraries can be imported: false once an import found no local engine to open them in. */\n canImport(): boolean;\n\n // ── events ──\n readonly onLibraryCreated: EventHook<StampLibraryCreatedEvent>;\n readonly onLibraryUpdated: EventHook<StampLibraryUpdatedEvent>;\n readonly onLibraryDeleted: EventHook<StampLibraryDeletedEvent>;\n readonly onAssetCreated: EventHook<StampAssetCreatedEvent>;\n readonly onAssetUpdated: EventHook<StampAssetUpdatedEvent>;\n readonly onAssetDeleted: EventHook<StampAssetDeletedEvent>;\n /** A stamp was armed or disarmed on a document. */\n readonly onArmChanged: EventHook<StampArmChangedEvent>;\n /** A library's bytes changed (subscribe to persist). */\n readonly onLibraryChanged: EventHook<StampLibraryChangedEvent>;\n}\n"],"mappings":";;AAKA,MAAa,cAAA,2BAAA,CAAA,CAAA,sBAAA,CAAoD,SAAS,EACxE,MAAM,uEACR,CAAC;;;ACeD,SAAgB,cAAc,KAAuB;CACnD,MAAM,YAAY,IAAI,QAAQ,GAAG;CACjC,IAAI,YAAY,GAAG,OAAO;EAAE,MAAM;EAAK,OAAO;CAAI;CAClD,OAAO;EAAE,MAAM,IAAI,MAAM,GAAG,SAAS;EAAG,OAAO,IAAI,MAAM,YAAY,CAAC;CAAE;AAC1E;AAEA,SAAgB,SAAS,MAAc,OAAuB;CAC5D,OAAO,GAAG,KAAK,GAAG;AACpB;AAEA,MAAM,SAAS;;;;;;AAOf,SAAgB,gBAAgB,SAAuB,KAAK,QAAgB;CAC1E,IAAI,OAAO;CACX,KAAK,IAAI,IAAI,GAAG,IAAI,IAAI,KAAK,QAAQ,OAAO,KAAK,MAAM,OAAO,IAAI,EAAa;CAC/E,OAAO;AACT;;AAGA,SAAgB,WAAW,WAAmB,MAAsB;CAClE,OAAO,GAAG,UAAU,GAAG;AACzB;;AAUA,MAAa,8BAA8B;;AAE3C,MAAa,sBAAsB;;AAKnC,MAAa,uBAAuB;;AAGpC,SAAgB,qBAAqB,MAAsB;CACzD,OAAO,SAAS,WAAW,iBAAiB,SAAS,eAAe,qBAAqB;AAC3F;AAEA,SAAgB,uBAAuB,MAAkC;CACvE,IAAI,CAAC,QAAQ,SAAS,gBAAgB,OAAO;CAC7C,OAAO,SAAS,qBAAqB,eAAe;AACtD;AAEA,SAAgB,mBAAmB,MAA8B;CAC/D,OAAO,SAAS,cAAc,cAAc,SAAS,aAAa,aAAa;AACjF;;AAGA,SAAgB,sBACd,IACA,UAA8E,CAAC,GAC/D;CAChB,OAAO;EACL,SAAA;EACA,IAAI;EACJ,MAAM,EAAE,MAAM,qBAAqB,QAAQ,QAAA,QAA4B,EAAE;EAEzE,MAAM;EACN,YAAY,QAAQ,cAAc;EAClC,QAAQ,QAAQ,UAAU;CAC5B;AACF;;AAGA,SAAgB,eACd,MACA,UAAuE,CAAC,GACxD;CAChB,OAAO;EACL,SAAA;EACA,MAAM,EAAE,MAAM,mBAAmB,IAAI,EAAE;EAKvC,MAAM;EACN,SAAS;EACT,iBAAiB,QAAQ,WAAW;EACpC,YAAY,QAAQ,cAAc;CACpC;AACF;;;;ACmDA,MAAa,iBAAgC;CAC3C,aAAa;CACb,OAAO,CAAC;CACR,cAAc;CACd,SAAS;AACX"}
@@ -1,2 +1,2 @@
1
- import { A as StampPlacement, C as StampLibraryChangedEvent, D as StampLibraryKind, E as StampLibraryFilter, I as DEFAULT_LIBRARY_KIND, L as StampToken, M as StampLibraryStore, O as StampLibraryPatch, S as StampLibrary, T as StampLibraryDeletedEvent, _ as StampAssetUpdatedEvent, a as MarkSource, b as StampDocumentOptions, c as StampArmOptions, d as StampAssetDeletedEvent, f as StampAssetEngine, g as StampAssetPreview, h as StampAssetPatch, i as ImportLibraryOptions, j as StampSettings, k as StampLibraryUpdatedEvent, l as StampAsset, m as StampAssetKind, n as AssetFromAnnotationsInput, o as STAMP_DEFAULTS, p as StampAssetFilter, r as CreateLibraryOptions, s as StampArmChangedEvent, t as AddAssetInput, u as StampAssetCreatedEvent, v as StampCapability, w as StampLibraryCreatedEvent, x as StampFont, y as StampConfig } from "./contract-BQP56Vp4.cjs";
2
- export { AddAssetInput, AssetFromAnnotationsInput, CreateLibraryOptions, DEFAULT_LIBRARY_KIND, ImportLibraryOptions, MarkSource, STAMP_DEFAULTS, StampArmChangedEvent, StampArmOptions, StampAsset, StampAssetCreatedEvent, StampAssetDeletedEvent, StampAssetEngine, StampAssetFilter, StampAssetKind, StampAssetPatch, StampAssetPreview, StampAssetUpdatedEvent, StampCapability, StampConfig, StampDocumentOptions, StampFont, StampLibrary, StampLibraryChangedEvent, StampLibraryCreatedEvent, StampLibraryDeletedEvent, StampLibraryFilter, StampLibraryKind, StampLibraryPatch, type StampLibraryStore, StampLibraryUpdatedEvent, type StampPlacement, StampSettings, StampToken };
1
+ import { A as StampPlacement, C as StampLibraryChangedEvent, D as StampLibraryKind, E as StampLibraryFilter, I as DEFAULT_LIBRARY_KIND, L as StampToken, M as StampLibraryStore, O as StampLibraryPatch, S as StampLibrary, T as StampLibraryDeletedEvent, _ as StampAssetUpdatedEvent, a as MarkSource, b as StampDocumentOptions, c as StampArmOptions, d as StampAssetDeletedEvent, f as StampAssetEngine, g as StampAssetPreview, h as StampAssetPatch, i as ImportLibraryOptions, j as StampSettings, k as StampLibraryUpdatedEvent, l as StampAsset, m as StampAssetKind, n as CreateAssetInput, o as STAMP_DEFAULTS, p as StampAssetFilter, r as CreateLibraryOptions, s as StampArmChangedEvent, t as AssetFromAnnotationsInput, u as StampAssetCreatedEvent, v as StampCapability, w as StampLibraryCreatedEvent, x as StampFont, y as StampConfig } from "./contract-CyQ2OdVy.cjs";
2
+ export { AssetFromAnnotationsInput, CreateAssetInput, CreateLibraryOptions, DEFAULT_LIBRARY_KIND, ImportLibraryOptions, MarkSource, STAMP_DEFAULTS, StampArmChangedEvent, StampArmOptions, StampAsset, StampAssetCreatedEvent, StampAssetDeletedEvent, StampAssetEngine, StampAssetFilter, StampAssetKind, StampAssetPatch, StampAssetPreview, StampAssetUpdatedEvent, StampCapability, StampConfig, StampDocumentOptions, StampFont, StampLibrary, StampLibraryChangedEvent, StampLibraryCreatedEvent, StampLibraryDeletedEvent, StampLibraryFilter, StampLibraryKind, StampLibraryPatch, type StampLibraryStore, StampLibraryUpdatedEvent, type StampPlacement, StampSettings, StampToken };
@@ -1,2 +1,2 @@
1
- import { A as StampPlacement, C as StampLibraryChangedEvent, D as StampLibraryKind, E as StampLibraryFilter, I as DEFAULT_LIBRARY_KIND, L as StampToken, M as StampLibraryStore, O as StampLibraryPatch, S as StampLibrary, T as StampLibraryDeletedEvent, _ as StampAssetUpdatedEvent, a as MarkSource, b as StampDocumentOptions, c as StampArmOptions, d as StampAssetDeletedEvent, f as StampAssetEngine, g as StampAssetPreview, h as StampAssetPatch, i as ImportLibraryOptions, j as StampSettings, k as StampLibraryUpdatedEvent, l as StampAsset, m as StampAssetKind, n as AssetFromAnnotationsInput, o as STAMP_DEFAULTS, p as StampAssetFilter, r as CreateLibraryOptions, s as StampArmChangedEvent, t as AddAssetInput, u as StampAssetCreatedEvent, v as StampCapability, w as StampLibraryCreatedEvent, x as StampFont, y as StampConfig } from "./contract-D6Hs6iO3.js";
2
- export { AddAssetInput, AssetFromAnnotationsInput, CreateLibraryOptions, DEFAULT_LIBRARY_KIND, ImportLibraryOptions, MarkSource, STAMP_DEFAULTS, StampArmChangedEvent, StampArmOptions, StampAsset, StampAssetCreatedEvent, StampAssetDeletedEvent, StampAssetEngine, StampAssetFilter, StampAssetKind, StampAssetPatch, StampAssetPreview, StampAssetUpdatedEvent, StampCapability, StampConfig, StampDocumentOptions, StampFont, StampLibrary, StampLibraryChangedEvent, StampLibraryCreatedEvent, StampLibraryDeletedEvent, StampLibraryFilter, StampLibraryKind, StampLibraryPatch, type StampLibraryStore, StampLibraryUpdatedEvent, type StampPlacement, StampSettings, StampToken };
1
+ import { A as StampPlacement, C as StampLibraryChangedEvent, D as StampLibraryKind, E as StampLibraryFilter, I as DEFAULT_LIBRARY_KIND, L as StampToken, M as StampLibraryStore, O as StampLibraryPatch, S as StampLibrary, T as StampLibraryDeletedEvent, _ as StampAssetUpdatedEvent, a as MarkSource, b as StampDocumentOptions, c as StampArmOptions, d as StampAssetDeletedEvent, f as StampAssetEngine, g as StampAssetPreview, h as StampAssetPatch, i as ImportLibraryOptions, j as StampSettings, k as StampLibraryUpdatedEvent, l as StampAsset, m as StampAssetKind, n as CreateAssetInput, o as STAMP_DEFAULTS, p as StampAssetFilter, r as CreateLibraryOptions, s as StampArmChangedEvent, t as AssetFromAnnotationsInput, u as StampAssetCreatedEvent, v as StampCapability, w as StampLibraryCreatedEvent, x as StampFont, y as StampConfig } from "./contract-Bazr1NDb.js";
2
+ export { AssetFromAnnotationsInput, CreateAssetInput, CreateLibraryOptions, DEFAULT_LIBRARY_KIND, ImportLibraryOptions, MarkSource, STAMP_DEFAULTS, StampArmChangedEvent, StampArmOptions, StampAsset, StampAssetCreatedEvent, StampAssetDeletedEvent, StampAssetEngine, StampAssetFilter, StampAssetKind, StampAssetPatch, StampAssetPreview, StampAssetUpdatedEvent, StampCapability, StampConfig, StampDocumentOptions, StampFont, StampLibrary, StampLibraryChangedEvent, StampLibraryCreatedEvent, StampLibraryDeletedEvent, StampLibraryFilter, StampLibraryKind, StampLibraryPatch, type StampLibraryStore, StampLibraryUpdatedEvent, type StampPlacement, StampSettings, StampToken };