@byte_fluffy/nexra-sdk 0.1.0-alpha.20 → 0.1.0-alpha.21

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.
package/README.md CHANGED
@@ -9,18 +9,14 @@ npm install @byte_fluffy/nexra-sdk@next
9
9
  ```
10
10
 
11
11
  ```ts
12
- import { createNexra, getModelSpec, projectMediaGeometry } from "@byte_fluffy/nexra-sdk";
12
+ import { createNexra, getModelSpec, type NexraImageGenerateInput } from "@byte_fluffy/nexra-sdk";
13
13
 
14
14
  const nexra = createNexra({ apiKey: process.env.NEXRA_API_KEY });
15
15
  const spec = getModelSpec("openai/gpt-image-2");
16
- const geometry = projectMediaGeometry(spec!.operations[0]!.inputSchema);
17
- // geometry.resolution.options → ["1K","2K","4K"]; geometry.ratio.options → ["1:1", ...]
18
-
19
- const input = {
20
- model: spec!.id,
21
- prompt: "A paper boat on a blue table",
22
- resolution: "1K",
23
- ratio: "1:1",
16
+ const input: NexraImageGenerateInput = {
17
+ content: [{ type: "text", text: "A paper boat on a blue table", role: "prompt" }],
18
+ resolution: "1k",
19
+ aspect_ratio: "1:1",
24
20
  quality: "medium",
25
21
  };
26
22
  const quote = await nexra.catalog.quote({
@@ -28,10 +24,15 @@ const quote = await nexra.catalog.quote({
28
24
  operation: "image.generate",
29
25
  input,
30
26
  });
31
- const result = await nexra.run(spec!.id, { input, quoteToken: quote.quoteToken });
27
+ const result = await nexra.run(spec!.id, input, { quoteToken: quote.quoteToken });
32
28
  ```
33
29
 
34
- Apps should send the unified geometry (`resolution` + `ratio` + `quality`). Quote and `run`/`create` map those fields onto the model's native catalog parameters (GPT Image `size: 1024x1024`, Seedream `size: 2K`, Grok `resolution: 1k` + `aspect_ratio`, …). `encodeMediaGeometry` / `decodeMediaGeometry` expose the same mapping without making a request. Native `size` already in the body is left unchanged.
30
+ Media apps send the versioned Nexra category contract: ordered `content` parts plus
31
+ the common parameters for `image.generate`, `video.generate`, `audio.generate` or
32
+ `image.upscale`. The server resolves the selected model component and explicitly
33
+ adapts that input to the channel Provider. The SDK does not expose or emulate
34
+ Provider-native endpoints. Protocol constants, schemas and types are also
35
+ available from `@byte_fluffy/nexra-sdk/media`.
35
36
 
36
37
  The default API base URL is `https://api.nexra-ai.com/v1`. When overriding
37
38
  `baseUrl`, include the `/v1` API prefix.
@@ -0,0 +1,61 @@
1
+ import { J as JsonObject } from './json-Drjj1OKl.js';
2
+
3
+ declare const MEDIA_KINDS: readonly ["image", "video", "audio", "document", "archive", "other"];
4
+ type MediaKind = (typeof MEDIA_KINDS)[number];
5
+ type MediaAssetStatus = "pending" | "ready" | "failed" | "deleted";
6
+ interface MediaAsset {
7
+ id: string;
8
+ kind: MediaKind;
9
+ status: MediaAssetStatus;
10
+ source: "upload" | "generated" | "provider" | "imported";
11
+ name?: string;
12
+ mimeType?: string;
13
+ sizeBytes?: number;
14
+ width?: number;
15
+ height?: number;
16
+ durationMs?: number;
17
+ checksumSha256?: string;
18
+ url?: string;
19
+ downloadUrl?: string;
20
+ expiresAt?: string;
21
+ metadata?: JsonObject;
22
+ createdAt: string;
23
+ }
24
+ interface AssetReference {
25
+ assetId: string;
26
+ }
27
+ type AssetInput = AssetReference | Blob | File | MediaAsset | string | URL;
28
+ interface AssetUploadOptions {
29
+ kind?: MediaKind;
30
+ name?: string;
31
+ signal?: AbortSignal;
32
+ }
33
+ interface AssetImportRequest {
34
+ url: string;
35
+ kind?: MediaKind;
36
+ name?: string;
37
+ }
38
+ type AssetCertificationProvider = "seedance";
39
+ type AssetCertificationStatus = "processing" | "ready" | "failed";
40
+ interface AssetCertification {
41
+ assetId: string;
42
+ provider: AssetCertificationProvider;
43
+ status: AssetCertificationStatus;
44
+ providerAssetId?: string;
45
+ assetUri?: string;
46
+ groupId?: string;
47
+ library: "general" | "liveness";
48
+ error?: string;
49
+ createdAt: string;
50
+ updatedAt: string;
51
+ }
52
+ interface AssetCertificationRequest {
53
+ library?: "general" | "liveness";
54
+ }
55
+ interface AssetCertificationWaitOptions {
56
+ pollIntervalMs?: number;
57
+ timeoutMs?: number;
58
+ signal?: AbortSignal;
59
+ }
60
+
61
+ export { type AssetReference as A, MEDIA_KINDS as M, type AssetImportRequest as a, type AssetInput as b, type AssetUploadOptions as c, type MediaAsset as d, type MediaAssetStatus as e, type MediaKind as f, type AssetCertificationRequest as g, type AssetCertification as h, type AssetCertificationWaitOptions as i };
package/dist/catalog.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { H as HttpTransport, N as NexraSalePriceList, C as CreateNexraQuoteRequest, a as NexraQuote, b as CreateNexraDisplayQuoteBatchRequest, c as NexraDisplayQuoteBatch, d as NexraCatalogRevision, e as NexraModelSpec, f as NexraModelSpecFilter } from './media-geometry-Ckr1-Mh3.js';
2
- export { M as MediaGeometryField, g as MediaGeometryProjection, h as NexraBillingCurrency, i as NexraModelEndpointSpec, j as NexraModelOperation, k as NexraSalePrice, l as NexraSettlement, U as UnifiedMediaGeometry, m as applyMediaGeometry, n as decodeMediaGeometry, o as encodeMediaGeometry, p as projectMediaGeometry } from './media-geometry-Ckr1-Mh3.js';
1
+ import { H as HttpTransport, N as NexraSalePriceList, C as CreateNexraQuoteRequest, a as NexraQuote, b as CreateNexraDisplayQuoteBatchRequest, c as NexraDisplayQuoteBatch, d as NexraCatalogRevision, e as NexraModelSpec, f as NexraModelSpecFilter } from './media-geometry-Bo6ukeIQ.js';
2
+ export { M as MediaGeometryField, g as MediaGeometryProjection, h as NexraBillingCurrency, i as NexraModelEndpointSpec, j as NexraModelOperation, k as NexraSalePrice, l as NexraSettlement, U as UnifiedMediaGeometry, m as applyMediaGeometry, n as decodeMediaGeometry, o as encodeMediaGeometry, p as projectMediaGeometry } from './media-geometry-Bo6ukeIQ.js';
3
+ import './json-Drjj1OKl.js';
3
4
 
4
5
  declare class CatalogClient {
5
6
  private readonly transport;
package/dist/catalog.js CHANGED
@@ -6,7 +6,8 @@ import {
6
6
  getModelSpec,
7
7
  listModelSpecs,
8
8
  projectMediaGeometry
9
- } from "./chunk-PAVF5LNU.js";
9
+ } from "./chunk-WU62FGYW.js";
10
+ import "./chunk-TA3YGQQY.js";
10
11
  export {
11
12
  CatalogClient,
12
13
  applyMediaGeometry,
@@ -0,0 +1,386 @@
1
+ // ../contracts/src/assets.ts
2
+ var MEDIA_KINDS = [
3
+ "image",
4
+ "video",
5
+ "audio",
6
+ "document",
7
+ "archive",
8
+ "other"
9
+ ];
10
+
11
+ // ../contracts/src/media-api.ts
12
+ var NEXRA_MEDIA_API_VERSION = 1;
13
+ var NEXRA_GENERATION_OPERATIONS = [
14
+ "text.generate",
15
+ "image.generate",
16
+ "video.generate",
17
+ "audio.generate",
18
+ "image.upscale",
19
+ "video.upscale"
20
+ ];
21
+ var NEXRA_MEDIA_OPERATIONS = [
22
+ "image.generate",
23
+ "video.generate",
24
+ "audio.generate",
25
+ "image.upscale",
26
+ "video.upscale"
27
+ ];
28
+ var NEXRA_PUBLISHED_MEDIA_OPERATIONS = [
29
+ "image.generate",
30
+ "video.generate",
31
+ "audio.generate",
32
+ "image.upscale"
33
+ ];
34
+ var NEXRA_MEDIA_FEATURES = [
35
+ "text-to-image",
36
+ "image-to-image",
37
+ "image-reference",
38
+ "image-edit",
39
+ "image-inpaint",
40
+ "image-control",
41
+ "text-to-video",
42
+ "first-frame",
43
+ "first-last-frame",
44
+ "image-to-video",
45
+ "video-to-video",
46
+ "audio-to-video",
47
+ "avatar-video",
48
+ "reference-image",
49
+ "reference-video",
50
+ "reference-audio",
51
+ "omni-reference",
52
+ "tts",
53
+ "music",
54
+ "sfx",
55
+ "voice-reference",
56
+ "scale-factor",
57
+ "target-resolution"
58
+ ];
59
+ var NEXRA_MEDIA_OPERATION_DEFINITIONS = Object.freeze([
60
+ {
61
+ operation: "image.generate",
62
+ status: "active",
63
+ outputKind: "image",
64
+ features: ["text-to-image", "image-to-image", "image-reference", "image-edit", "image-inpaint", "image-control"],
65
+ parameterKeys: ["aspect_ratio", "resolution", "quality", "count", "output_format", "seed"]
66
+ },
67
+ {
68
+ operation: "video.generate",
69
+ status: "active",
70
+ outputKind: "video",
71
+ features: ["text-to-video", "first-frame", "first-last-frame", "image-to-video", "video-to-video", "audio-to-video", "avatar-video", "reference-image", "reference-video", "reference-audio", "omni-reference"],
72
+ parameterKeys: ["voice", "aspect_ratio", "resolution", "quality", "duration", "generate_audio", "output_format", "seed"]
73
+ },
74
+ {
75
+ operation: "audio.generate",
76
+ status: "active",
77
+ outputKind: "audio",
78
+ features: ["tts", "music", "sfx", "voice-reference"],
79
+ parameterKeys: ["voice", "language", "duration", "output_format", "sample_rate", "speed", "volume", "pitch", "emotion", "instrumental", "loop", "prompt_influence", "seed"]
80
+ },
81
+ {
82
+ operation: "image.upscale",
83
+ status: "active",
84
+ outputKind: "image",
85
+ features: ["scale-factor", "target-resolution"],
86
+ parameterKeys: ["scale", "resolution", "output_format", "preserve_details"]
87
+ },
88
+ {
89
+ operation: "video.upscale",
90
+ status: "hold",
91
+ outputKind: "video",
92
+ features: ["scale-factor", "target-resolution"],
93
+ parameterKeys: ["scale", "resolution", "output_format", "preserve_details"]
94
+ }
95
+ ]);
96
+ var mediaSourceSchema = {
97
+ oneOf: [
98
+ { type: "string", minLength: 1 },
99
+ {
100
+ type: "object",
101
+ properties: { assetId: { type: "string", minLength: 1 } },
102
+ required: ["assetId"],
103
+ additionalProperties: false
104
+ }
105
+ ]
106
+ };
107
+ function textPartSchema(roles) {
108
+ return {
109
+ type: "object",
110
+ properties: {
111
+ type: { const: "text" },
112
+ text: { type: "string", minLength: 1 },
113
+ role: { type: "string", enum: [...roles] }
114
+ },
115
+ required: ["type", "text"],
116
+ additionalProperties: false
117
+ };
118
+ }
119
+ function mediaPartSchema(type, roles) {
120
+ return {
121
+ type: "object",
122
+ properties: {
123
+ type: { const: type },
124
+ source: structuredClone(mediaSourceSchema),
125
+ role: { type: "string", enum: [...roles] },
126
+ ...type === "image" ? { name: { type: "string", minLength: 1, maxLength: 64, pattern: "^[^\\s@]+$" } } : {}
127
+ },
128
+ required: ["type", "source"],
129
+ additionalProperties: false
130
+ };
131
+ }
132
+ function inputSchema(contentItems, properties, contentBounds = {}) {
133
+ return {
134
+ $schema: "https://json-schema.org/draft/2020-12/schema",
135
+ type: "object",
136
+ properties: {
137
+ content: {
138
+ type: "array",
139
+ minItems: contentBounds.minItems ?? 1,
140
+ ...contentBounds.maxItems === void 0 ? {} : { maxItems: contentBounds.maxItems },
141
+ items: { oneOf: contentItems.map((item) => structuredClone(item)) },
142
+ "x-ui": { control: "content-parts", order: 0 }
143
+ },
144
+ ...properties
145
+ },
146
+ required: ["content"],
147
+ additionalProperties: false
148
+ };
149
+ }
150
+ var imagePart = mediaPartSchema("image", ["source", "reference", "first_frame", "last_frame", "mask", "control", "subject", "background"]);
151
+ var videoPart = mediaPartSchema("video", ["source", "reference", "edit", "extend"]);
152
+ var audioPart = mediaPartSchema("audio", ["source", "reference", "voice_reference"]);
153
+ var draftPart = {
154
+ type: "object",
155
+ properties: {
156
+ type: { const: "draft_task" },
157
+ draft_task: { type: "object", properties: { id: { type: "string", minLength: 1 } }, required: ["id"], additionalProperties: false }
158
+ },
159
+ required: ["type", "draft_task"],
160
+ additionalProperties: false
161
+ };
162
+ var NEXRA_MEDIA_INPUT_SCHEMAS = Object.freeze({
163
+ "image.generate": inputSchema(
164
+ [textPartSchema(["prompt", "negative_prompt"]), imagePart],
165
+ {
166
+ aspect_ratio: { type: "string", minLength: 1, "x-ui": { order: 10 } },
167
+ resolution: { type: "string", minLength: 1, "x-ui": { order: 11 } },
168
+ quality: { type: "string", minLength: 1, "x-ui": { order: 12 } },
169
+ count: { type: "integer", minimum: 1, "x-ui": { order: 13, control: "number" } },
170
+ output_format: { type: "string", minLength: 1, "x-ui": { order: 14 } },
171
+ seed: { type: "integer", minimum: 0, "x-ui": { order: 15, control: "number" } }
172
+ }
173
+ ),
174
+ "video.generate": inputSchema(
175
+ [textPartSchema(["prompt", "negative_prompt", "script"]), imagePart, videoPart, audioPart, draftPart],
176
+ {
177
+ voice: { type: "string", minLength: 1, "x-ui": { order: 9, control: "resource", resource: "voice" } },
178
+ draft: { type: "boolean", "x-ui": { control: "switch" } },
179
+ aspect_ratio: { type: "string", minLength: 1, "x-ui": { order: 10 } },
180
+ resolution: { type: "string", minLength: 1, "x-ui": { order: 11 } },
181
+ quality: { type: "string", minLength: 1, "x-ui": { order: 12 } },
182
+ duration: { type: "number", exclusiveMinimum: 0, "x-ui": { order: 13, control: "number" } },
183
+ generate_audio: { type: "boolean", "x-ui": { order: 14, control: "switch" } },
184
+ output_format: { type: "string", minLength: 1, "x-ui": { order: 15 } },
185
+ seed: { type: "integer", minimum: 0, "x-ui": { order: 16, control: "number" } }
186
+ }
187
+ ),
188
+ "audio.generate": inputSchema(
189
+ [textPartSchema(["prompt", "script", "lyrics"]), audioPart],
190
+ {
191
+ voice: { type: "string", minLength: 1, "x-ui": { order: 10, control: "resource", resource: "voice" } },
192
+ language: { type: "string", minLength: 1, "x-ui": { order: 11 } },
193
+ duration: { type: "number", exclusiveMinimum: 0, "x-ui": { order: 12, control: "number" } },
194
+ output_format: { type: "string", minLength: 1, "x-ui": { order: 13 } },
195
+ sample_rate: { type: "integer", minimum: 1, "x-ui": { order: 14, control: "number" } },
196
+ speed: { type: "number", exclusiveMinimum: 0, "x-ui": { order: 15, control: "number" } },
197
+ volume: { type: "number", "x-ui": { order: 16, control: "number" } },
198
+ pitch: { type: "number", "x-ui": { order: 17, control: "number" } },
199
+ emotion: { type: "string", minLength: 1, "x-ui": { order: 18 } },
200
+ instrumental: { type: "boolean", "x-ui": { order: 19, control: "switch" } },
201
+ loop: { type: "boolean", "x-ui": { order: 20, control: "switch" } },
202
+ prompt_influence: { type: "number", minimum: 0, maximum: 1, "x-ui": { order: 21, control: "number" } },
203
+ seed: { type: "integer", minimum: 0, "x-ui": { order: 22, control: "number" } }
204
+ }
205
+ ),
206
+ "image.upscale": inputSchema(
207
+ [mediaPartSchema("image", ["source"])],
208
+ {
209
+ scale: { type: "number", exclusiveMinimum: 1, "x-ui": { order: 10, control: "number" } },
210
+ resolution: { type: "string", minLength: 1, "x-ui": { order: 11 } },
211
+ output_format: { type: "string", minLength: 1, "x-ui": { order: 12 } },
212
+ preserve_details: { type: "boolean", "x-ui": { order: 13, control: "switch" } }
213
+ },
214
+ { minItems: 1, maxItems: 1 }
215
+ )
216
+ });
217
+ function nexraMediaInputSchema(operation) {
218
+ if (!(operation in NEXRA_MEDIA_INPUT_SCHEMAS)) return void 0;
219
+ return structuredClone(NEXRA_MEDIA_INPUT_SCHEMAS[operation]);
220
+ }
221
+ function isNexraMediaInput(value) {
222
+ if (!value || typeof value !== "object" || Array.isArray(value)) return false;
223
+ const input = value;
224
+ if ("model" in input) return false;
225
+ const content = input.content;
226
+ return Array.isArray(content) && content.length > 0 && content.every((part) => {
227
+ if (!part || typeof part !== "object" || Array.isArray(part)) return false;
228
+ if (part.type === "text") return typeof part.text === "string" && part.text.length > 0;
229
+ if (!["image", "video", "audio"].includes(String(part.type))) return false;
230
+ if (typeof part.source === "string") return part.source.length > 0;
231
+ return Boolean(part.source && typeof part.source === "object" && !Array.isArray(part.source) && typeof part.source.assetId === "string" && part.source.assetId.length > 0);
232
+ });
233
+ }
234
+ function nexraMediaOperationForMode(mode) {
235
+ if (["text-to-image", "image-to-image"].includes(mode)) return "image.generate";
236
+ if (["text-to-video", "image-to-video", "multimodal-to-video", "avatar-video"].includes(mode)) return "video.generate";
237
+ if (["text-to-speech", "text-to-music", "text-to-sfx"].includes(mode)) return "audio.generate";
238
+ if (mode === "image-upscale") return "image.upscale";
239
+ return void 0;
240
+ }
241
+ function nexraMediaInputSchemaForMode(mode) {
242
+ const operation = nexraMediaOperationForMode(mode);
243
+ const schema = operation ? nexraMediaInputSchema(operation) : void 0;
244
+ if (!schema) return void 0;
245
+ const properties = schema.properties;
246
+ const content = properties.content;
247
+ const items = content.items;
248
+ const variants = Array.isArray(items.oneOf) ? items.oneOf : [];
249
+ if (mode === "avatar-video") {
250
+ for (const variant of variants) {
251
+ const variantProperties = variant.properties;
252
+ if (variantProperties.type.const === "text") {
253
+ variantProperties.role = { type: "string", enum: ["script"] };
254
+ }
255
+ }
256
+ }
257
+ const allowed = mode === "text-to-image" || mode === "text-to-video" || mode === "text-to-music" || mode === "text-to-sfx" ? /* @__PURE__ */ new Set(["text"]) : mode === "image-to-image" ? /* @__PURE__ */ new Set(["text", "image"]) : mode === "image-to-video" ? /* @__PURE__ */ new Set(["text", "image", "audio"]) : mode === "text-to-speech" ? /* @__PURE__ */ new Set(["text", "audio"]) : /* @__PURE__ */ new Set(["text", "image", "video", "audio"]);
258
+ items.oneOf = variants.filter((variant) => allowed.has(String(variant.properties.type.const)));
259
+ if (mode === "image-to-video") {
260
+ for (const variant of items.oneOf) {
261
+ const variantProperties = variant.properties;
262
+ if (variantProperties.type.const !== "image") continue;
263
+ variantProperties.role = { type: "string", enum: ["first_frame", "last_frame"] };
264
+ const required = new Set(Array.isArray(variant.required) ? variant.required.filter((key) => typeof key === "string") : []);
265
+ required.add("role");
266
+ variant.required = [...required];
267
+ }
268
+ }
269
+ if (mode === "multimodal-to-video") {
270
+ for (const variant of items.oneOf) {
271
+ const variantProperties = variant.properties;
272
+ const type = String(variantProperties.type.const);
273
+ if (!["image", "video", "audio"].includes(type)) continue;
274
+ variantProperties.role = type === "image" ? { type: "string", enum: ["reference", "subject", "background"] } : type === "video" ? { type: "string", enum: ["reference", "edit", "extend"] } : { type: "string", const: "reference" };
275
+ const required = new Set(Array.isArray(variant.required) ? variant.required.filter((key) => typeof key === "string") : []);
276
+ required.add("role");
277
+ variant.required = [...required];
278
+ }
279
+ }
280
+ const requiredMedia = mode === "image-to-image" || mode === "image-to-video" || mode === "avatar-video" ? "image" : void 0;
281
+ const requiresReferenceMedia = mode === "multimodal-to-video";
282
+ content.allOf = [
283
+ ...mode === "avatar-video" ? [] : [{
284
+ contains: { type: "object", properties: { type: { const: "text" } }, required: ["type"] },
285
+ minContains: 1
286
+ }],
287
+ ...requiredMedia ? [{
288
+ contains: { type: "object", properties: { type: { const: requiredMedia } }, required: ["type"] },
289
+ minContains: 1
290
+ }] : [],
291
+ ...requiresReferenceMedia ? [{
292
+ contains: { type: "object", properties: { type: { enum: ["image", "video", "audio"] } }, required: ["type"] },
293
+ minContains: 1
294
+ }] : []
295
+ ];
296
+ if (mode === "text-to-speech") {
297
+ properties.voice = { ...properties.voice, "x-ui": { order: 10, control: "resource", resource: "voice" } };
298
+ }
299
+ const allowedParameters = mode === "avatar-video" ? /* @__PURE__ */ new Set(["content", "voice", "aspect_ratio", "resolution"]) : mode === "text-to-speech" ? /* @__PURE__ */ new Set(["content", "voice", "language", "output_format", "sample_rate", "speed", "volume", "pitch", "emotion"]) : mode === "text-to-music" ? /* @__PURE__ */ new Set(["content", "duration", "output_format", "instrumental", "prompt_influence", "seed"]) : mode === "text-to-sfx" ? /* @__PURE__ */ new Set(["content", "duration", "output_format", "loop", "prompt_influence", "seed"]) : void 0;
300
+ if (allowedParameters) {
301
+ schema.properties = Object.fromEntries(Object.entries(properties).filter(([key]) => allowedParameters.has(key)));
302
+ }
303
+ return schema;
304
+ }
305
+
306
+ // ../contracts/src/tasks.ts
307
+ var TASK_STATUSES = [
308
+ "queued",
309
+ "running",
310
+ "succeeded",
311
+ "failed",
312
+ "cancelling",
313
+ "cancelled"
314
+ ];
315
+ var CREATE_TASK_CONTROL_FIELDS = [
316
+ "model",
317
+ "callback_url",
318
+ "metadata",
319
+ "quoteToken",
320
+ "submittedAt",
321
+ "schemaVersion",
322
+ "webhook"
323
+ ];
324
+ function createTaskRequest(model, input, controls = {}) {
325
+ for (const field of [...CREATE_TASK_CONTROL_FIELDS, "input"]) {
326
+ if (Object.hasOwn(input, field)) {
327
+ throw new Error(`Nexra model parameters cannot use reserved Task field: ${field}`);
328
+ }
329
+ }
330
+ return { model, ...input, ...controls };
331
+ }
332
+ function isTerminalTaskStatus(status) {
333
+ return status === "succeeded" || status === "failed" || status === "cancelled";
334
+ }
335
+
336
+ // ../contracts/src/ratio-display-order.ts
337
+ function parseRatioParts(value) {
338
+ const matched = /^\s*(\d+(?:\.\d+)?)\s*:\s*(\d+(?:\.\d+)?)\s*$/.exec(value);
339
+ if (!matched) return void 0;
340
+ const w = Number(matched[1]);
341
+ const h = Number(matched[2]);
342
+ return w > 0 && h > 0 ? { w, h } : void 0;
343
+ }
344
+ function ratioDisplayOrderKey(value) {
345
+ const normalized = value.trim();
346
+ const parts = parseRatioParts(normalized);
347
+ if (!parts) {
348
+ const auto = normalized.toLowerCase() === "auto" ? 0 : 1;
349
+ return [0, auto, 0, 0, value];
350
+ }
351
+ if (parts.w === parts.h) return [1, 0, 0, 0, value];
352
+ const long = Math.max(parts.w, parts.h);
353
+ const short = Math.min(parts.w, parts.h);
354
+ const landscape = parts.w > parts.h ? 1 : 0;
355
+ return short === 1 ? [3, long, landscape, -short, value] : [2, long, landscape, -short, value];
356
+ }
357
+ function compareRatioDisplayOrder(a, b) {
358
+ const ka = ratioDisplayOrderKey(a);
359
+ const kb = ratioDisplayOrderKey(b);
360
+ for (let index = 0; index < ka.length; index += 1) {
361
+ if (ka[index] !== kb[index]) return ka[index] < kb[index] ? -1 : 1;
362
+ }
363
+ return 0;
364
+ }
365
+ function sortRatioDisplayOrder(values) {
366
+ return [...values].sort(compareRatioDisplayOrder);
367
+ }
368
+
369
+ export {
370
+ MEDIA_KINDS,
371
+ NEXRA_MEDIA_API_VERSION,
372
+ NEXRA_GENERATION_OPERATIONS,
373
+ NEXRA_MEDIA_OPERATIONS,
374
+ NEXRA_PUBLISHED_MEDIA_OPERATIONS,
375
+ NEXRA_MEDIA_FEATURES,
376
+ NEXRA_MEDIA_OPERATION_DEFINITIONS,
377
+ NEXRA_MEDIA_INPUT_SCHEMAS,
378
+ nexraMediaInputSchema,
379
+ isNexraMediaInput,
380
+ nexraMediaOperationForMode,
381
+ nexraMediaInputSchemaForMode,
382
+ TASK_STATUSES,
383
+ createTaskRequest,
384
+ isTerminalTaskStatus,
385
+ sortRatioDisplayOrder
386
+ };