@umituz/web-ai 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/{AIErrors-B2ogd1PB.d.ts → AIErrors-CLjXRty-.d.ts} +99 -92
  2. package/dist/{AIErrors-C5EasV_c.d.cts → AIErrors-DjZXUiLT.d.cts} +99 -92
  3. package/dist/{cancellation-error-DwHrDKBz.d.cts → cancellation-error-Cj7fJyCg.d.cts} +3 -3
  4. package/dist/{cancellation-error-CKcZRhFg.d.ts → cancellation-error-CkMn5Kft.d.ts} +3 -3
  5. package/dist/chat/index.cjs.map +1 -1
  6. package/dist/chat/index.d.cts +3 -3
  7. package/dist/chat/index.d.ts +3 -3
  8. package/dist/chat/index.js.map +1 -1
  9. package/dist/{chat.service-CL1qtYxe.d.cts → chat.service-9M-KpLo-.d.cts} +1 -1
  10. package/dist/{chat.service-q05GnhEm.d.ts → chat.service-B4FLFxR1.d.ts} +1 -1
  11. package/dist/content/index.cjs +1047 -490
  12. package/dist/content/index.cjs.map +1 -1
  13. package/dist/content/index.d.cts +165 -219
  14. package/dist/content/index.d.ts +165 -219
  15. package/dist/content/index.js +983 -491
  16. package/dist/content/index.js.map +1 -1
  17. package/dist/{create-ai-9PW752z8.d.ts → create-ai-0eZFFqTw.d.ts} +1 -1
  18. package/dist/{create-ai-CXYKPK6G.d.cts → create-ai-BrKR_5fQ.d.cts} +1 -1
  19. package/dist/hooks/index.cjs +66 -8
  20. package/dist/hooks/index.cjs.map +1 -1
  21. package/dist/hooks/index.d.cts +21 -11
  22. package/dist/hooks/index.d.ts +21 -11
  23. package/dist/hooks/index.js +65 -9
  24. package/dist/hooks/index.js.map +1 -1
  25. package/dist/index-BUVULo3h.d.ts +177 -0
  26. package/dist/index-BulSkB2L.d.cts +177 -0
  27. package/dist/index.cjs +1800 -15
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.cts +8 -5
  30. package/dist/index.d.ts +8 -5
  31. package/dist/index.js +1757 -15
  32. package/dist/index.js.map +1 -1
  33. package/dist/{provider.factory-DfDfk0dK.d.ts → provider.factory-BwPnqSEU.d.ts} +3 -1
  34. package/dist/{provider.factory-BxsfK4WW.d.cts → provider.factory-DyfJtR8M.d.cts} +3 -1
  35. package/dist/providers/index.cjs +9 -0
  36. package/dist/providers/index.cjs.map +1 -1
  37. package/dist/providers/index.d.cts +10 -8
  38. package/dist/providers/index.d.ts +10 -8
  39. package/dist/providers/index.js +7 -1
  40. package/dist/providers/index.js.map +1 -1
  41. package/dist/requestQueue-CkJ6Xc9K.d.cts +261 -0
  42. package/dist/requestQueue-CvxWxC-z.d.ts +261 -0
  43. package/dist/wizard/index.d.cts +2 -86
  44. package/dist/wizard/index.d.ts +2 -86
  45. package/package.json +16 -1
  46. package/dist/ContentGeneration-B6iK2B33.d.cts +0 -93
  47. package/dist/ContentGeneration-B6iK2B33.d.ts +0 -93
@@ -1,3 +1,61 @@
1
+ // src/content/domain/types/index.ts
2
+ var PLATFORM_SPECS = {
3
+ twitter: {
4
+ maxLength: 280,
5
+ style: "concise, engaging, thread-friendly",
6
+ emojiSupport: true,
7
+ hashtagSupport: true,
8
+ imageSupport: true,
9
+ videoSupport: true,
10
+ maxHashtags: 5
11
+ },
12
+ linkedin: {
13
+ maxLength: 3e3,
14
+ style: "professional, insightful, industry-focused",
15
+ emojiSupport: true,
16
+ hashtagSupport: true,
17
+ imageSupport: true,
18
+ videoSupport: true,
19
+ maxHashtags: 5
20
+ },
21
+ instagram: {
22
+ maxLength: 2200,
23
+ style: "visual, engaging, emoji-rich",
24
+ emojiSupport: true,
25
+ hashtagSupport: true,
26
+ imageSupport: true,
27
+ videoSupport: true,
28
+ maxHashtags: 30
29
+ },
30
+ threads: {
31
+ maxLength: 500,
32
+ style: "conversational, community-driven",
33
+ emojiSupport: true,
34
+ hashtagSupport: true,
35
+ imageSupport: true,
36
+ videoSupport: true,
37
+ maxHashtags: 5
38
+ },
39
+ tiktok: {
40
+ maxLength: 150,
41
+ style: "catchy, trending, short-form",
42
+ emojiSupport: true,
43
+ hashtagSupport: true,
44
+ imageSupport: false,
45
+ videoSupport: true,
46
+ maxHashtags: 5
47
+ },
48
+ facebook: {
49
+ maxLength: 63206,
50
+ style: "conversational, engaging, shareable",
51
+ emojiSupport: true,
52
+ hashtagSupport: true,
53
+ imageSupport: true,
54
+ videoSupport: true,
55
+ maxHashtags: 5
56
+ }
57
+ };
58
+
1
59
  // src/content/domain/calculations/ContentCreditCost.ts
2
60
  var CREDIT_COSTS = {
3
61
  "text-to-image": { standard: 1, hd: 2, "4k": 4 },
@@ -153,48 +211,428 @@ var AIError = class _AIError extends Error {
153
211
  this.cause = cause;
154
212
  this.metadata = metadata;
155
213
  }
156
- static from(error, fallbackCode = "UNKNOWN") {
157
- if (error instanceof _AIError) return error;
158
- if (error instanceof Error) {
159
- const code = mapMessageToCode(error.message, fallbackCode);
160
- return new _AIError(error.message, code, error);
161
- }
162
- return new _AIError(String(error), fallbackCode, error);
214
+ static from(error, fallbackCode = "UNKNOWN") {
215
+ if (error instanceof _AIError) return error;
216
+ if (error instanceof Error) {
217
+ const code = mapMessageToCode(error.message, fallbackCode);
218
+ return new _AIError(error.message, code, error);
219
+ }
220
+ return new _AIError(String(error), fallbackCode, error);
221
+ }
222
+ toString() {
223
+ const statusPart = typeof this.metadata.status === "number" ? ` (HTTP ${this.metadata.status})` : "";
224
+ return `${this.name} [${this.type}]: ${this.message}${statusPart}`;
225
+ }
226
+ toJSON() {
227
+ return {
228
+ name: this.name,
229
+ type: this.type,
230
+ code: this.code,
231
+ message: this.message,
232
+ metadata: this.metadata
233
+ };
234
+ }
235
+ };
236
+
237
+ // src/content/domain/errors/AIErrors.ts
238
+ var ValidationError = class extends AIError {
239
+ constructor(message) {
240
+ super(message, "VALIDATION_ERROR");
241
+ this.name = "ValidationError";
242
+ }
243
+ };
244
+ var ProviderUnavailableError = class extends AIError {
245
+ constructor(providerId) {
246
+ super(`Provider ${providerId} is not available`, "PROVIDER_UNAVAILABLE");
247
+ this.name = "ProviderUnavailableError";
248
+ }
249
+ };
250
+ var ProviderQuotaExhaustedError = class extends AIError {
251
+ constructor(providerId) {
252
+ super(`Provider ${providerId} quota exhausted`, "PROVIDER_QUOTA_EXHAUSTED");
253
+ this.name = "ProviderQuotaExhaustedError";
254
+ }
255
+ };
256
+
257
+ // src/content/domain/limits/ValidationLimits.ts
258
+ var ValidationLimits = {
259
+ TOPIC: {
260
+ MIN: 1,
261
+ MAX: 500
262
+ },
263
+ CONTENT: {
264
+ MIN: 1,
265
+ MAX: 1e4
266
+ },
267
+ KEYWORD: {
268
+ MAX_COUNT: 20,
269
+ MAX_LENGTH: 50
270
+ },
271
+ DURATION_SECONDS: {
272
+ MIN: 10,
273
+ MAX: 600
274
+ },
275
+ CALENDAR_DAYS: {
276
+ MIN: 1,
277
+ MAX: 90
278
+ },
279
+ HASHTAG_COUNT: {
280
+ MIN: 1,
281
+ MAX: 50
282
+ },
283
+ SEO_CONTENT_PREVIEW: 500,
284
+ BLOG_PROMPT_PREVIEW: 1e3,
285
+ AB_VARIANT_CONTENT_PREVIEW: 200
286
+ };
287
+
288
+ // src/content/domain/limits/SpeechPaceConfig.ts
289
+ var SpeechPaceConfig = {
290
+ WORDS_PER_SECOND: 2.5,
291
+ TOKENS_PER_SECOND: 10,
292
+ JSON_TOKEN_OVERHEAD: 500,
293
+ TOKENS_PER_CALENDAR_DAY: 150
294
+ };
295
+
296
+ // src/content/domain/limits/ProviderTimingConfig.ts
297
+ var ProviderTimingConfig = {
298
+ DEFAULT_TIMEOUT_MS: 3e4,
299
+ DEFAULT_RETRY_ATTEMPTS: 3,
300
+ FAL_TIMEOUT_MS: 12e4,
301
+ FAL_RETRY_ATTEMPTS: 2,
302
+ GEMINI_TIMEOUT_MS: 6e4,
303
+ GEMINI_RETRY_ATTEMPTS: 3,
304
+ GROQ_TIMEOUT_MS: 3e4,
305
+ GROQ_RETRY_ATTEMPTS: 3,
306
+ HEALTH_CHECK_TTL_MS: 5 * 60 * 1e3,
307
+ RETRY_BACKOFF_BASE_MS: 1e3
308
+ };
309
+
310
+ // src/content/domain/limits/ModelDefaults.ts
311
+ var ModelDefaults = {
312
+ GROQ_TEXT: "llama-3.1-8b-instant",
313
+ GROQ_CHAT: "llama-3.1-8b-instant",
314
+ FAL_IMAGE: "fal-ai/flux/schnell",
315
+ FAL_VIDEO: "fal-ai/hunyuan-video/1",
316
+ FAL_IMAGE_TO_VIDEO: "fal-ai/fast-animatediff/image-to-video",
317
+ GEMINI_TEXT: "gemini-2.0-flash",
318
+ GEMINI_IMAGE: "imagen-4.0-generate-001",
319
+ PRUNA_IMAGE: "p-image",
320
+ PRUNA_IMAGE_EDIT: "p-image-edit",
321
+ PRUNA_VIDEO: "p-video"
322
+ };
323
+ var TextModelDefaults = {
324
+ TEXT_MODEL: "claude-sonnet-4-20250514",
325
+ MAX_TOKENS: 4096,
326
+ DEFAULT_TEMPERATURE: 0.7,
327
+ DEFAULT_TOP_P: 0.9
328
+ };
329
+
330
+ // src/content/domain/limits/RequestQueueConfig.ts
331
+ var RequestQueueConfig = {
332
+ MAX_CONCURRENT: 3,
333
+ MAX_QUEUE_SIZE: 50,
334
+ DEFAULT_TIMEOUT_MS: 3e4,
335
+ RETRY_DELAY_MS: 1e3,
336
+ RATE_LIMIT: {
337
+ ENABLED: true,
338
+ WINDOW_MS: 6e4,
339
+ MAX_REQUESTS_PER_WINDOW: 100
340
+ },
341
+ POLL_INTERVAL_MS: 100
342
+ };
343
+
344
+ // src/content/domain/limits/MemoryConfig.ts
345
+ var MemoryConfig = {
346
+ MANAGER: {
347
+ MAX_SIZE_BYTES: 50 * 1024 * 1024,
348
+ CLEANUP_THRESHOLD_RATIO: 0.8,
349
+ RETENTION_RATIO: 0.5
350
+ },
351
+ POOL: {
352
+ DEFAULT_MAX_SIZE: 100
353
+ },
354
+ EXPIRING_CACHE: {
355
+ DEFAULT_TTL_MS: 6e4,
356
+ CLEANUP_INTERVAL_MS: 6e4
357
+ }
358
+ };
359
+
360
+ // src/content/domain/calculations/SpeechPaceEstimate.ts
361
+ function estimateWordCountForDuration(durationSeconds) {
362
+ return Math.floor(durationSeconds * SpeechPaceConfig.WORDS_PER_SECOND);
363
+ }
364
+ function estimateTokenBudgetForDuration(durationSeconds) {
365
+ return durationSeconds * SpeechPaceConfig.TOKENS_PER_SECOND + SpeechPaceConfig.JSON_TOKEN_OVERHEAD;
366
+ }
367
+ function estimateTokenBudgetForCalendarDays(days) {
368
+ return days * SpeechPaceConfig.TOKENS_PER_CALENDAR_DAY + SpeechPaceConfig.JSON_TOKEN_OVERHEAD;
369
+ }
370
+
371
+ // src/content/domain/calculations/SeoKeywordDensity.ts
372
+ function countKeywordOccurrences(content, keyword) {
373
+ if (!keyword) return 0;
374
+ const escaped = keyword.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
375
+ const matches = content.match(new RegExp(escaped, "gi"));
376
+ return matches ? matches.length : 0;
377
+ }
378
+ function countWordsInContent(content) {
379
+ const tokens = content.split(/\s+/).filter(Boolean);
380
+ return tokens.length || 1;
381
+ }
382
+ function calculateKeywordDensity(content, keyword) {
383
+ const totalWords = countWordsInContent(content);
384
+ const occurrences = countKeywordOccurrences(content, keyword);
385
+ return occurrences / totalWords * 100;
386
+ }
387
+
388
+ // src/content/domain/calculations/AbTestImprovementRatio.ts
389
+ function calculateImprovementPercentage(scoreA, scoreB) {
390
+ const higher = Math.max(scoreA, scoreB);
391
+ const lower = Math.min(scoreA, scoreB);
392
+ if (lower <= 0) {
393
+ return "100";
394
+ }
395
+ const delta = (higher / lower - 1) * 100;
396
+ return Math.abs(delta).toFixed(0);
397
+ }
398
+ function selectHigherScoreVariantId(scoreA, scoreB, idA = "A", idB = "B") {
399
+ return scoreA > scoreB ? idA : idB;
400
+ }
401
+
402
+ // src/content/domain/calculations/RetryBackoffDelay.ts
403
+ function calculateRetryBackoffDelayMs(attemptIndex) {
404
+ return ProviderTimingConfig.RETRY_BACKOFF_BASE_MS * Math.pow(2, attemptIndex);
405
+ }
406
+
407
+ // src/content/domain/calculations/ContentCalendarDateOffset.ts
408
+ var ONE_DAY_MS = 24 * 60 * 60 * 1e3;
409
+ function resolveCalendarEntryDate(dayIndex, baseTimestamp = Date.now()) {
410
+ return new Date(baseTimestamp + (dayIndex - 1) * ONE_DAY_MS);
411
+ }
412
+
413
+ // src/content/domain/calculations/DefaultModelSelection.ts
414
+ function resolveDefaultPrunaModel(generationType) {
415
+ switch (generationType) {
416
+ case "image-to-image":
417
+ return ModelDefaults.PRUNA_IMAGE_EDIT;
418
+ case "image-to-video":
419
+ return ModelDefaults.PRUNA_VIDEO;
420
+ case "text-to-image":
421
+ return ModelDefaults.PRUNA_IMAGE;
422
+ case "text-to-video":
423
+ return ModelDefaults.PRUNA_VIDEO;
424
+ }
425
+ }
426
+
427
+ // src/content/domain/predicates/KeywordProminenceClassifier.ts
428
+ var HIGH_DENSITY_THRESHOLD = 2;
429
+ var MEDIUM_DENSITY_THRESHOLD = 1;
430
+ function classifyKeywordProminence(densityPercent) {
431
+ if (densityPercent > HIGH_DENSITY_THRESHOLD) return "high";
432
+ if (densityPercent > MEDIUM_DENSITY_THRESHOLD) return "medium";
433
+ return "low";
434
+ }
435
+ function isUnderutilizedKeyword(densityPercent) {
436
+ return densityPercent < 1;
437
+ }
438
+
439
+ // src/content/domain/predicates/HashtagPriorityRanker.ts
440
+ var DEFAULT_HASHTAG_BUDGET = Number.MAX_SAFE_INTEGER;
441
+ function resolveHashtagBudget(platform) {
442
+ return PLATFORM_SPECS[platform]?.maxHashtags ?? DEFAULT_HASHTAG_BUDGET;
443
+ }
444
+ function rankAndTrimHashtags(hashtags, budget) {
445
+ if (hashtags.length <= budget) return [...hashtags];
446
+ return [...hashtags].sort((a, b) => b.length - a.length).slice(0, budget);
447
+ }
448
+
449
+ // src/content/domain/predicates/PlatformSpecResolver.ts
450
+ var FALLBACK_SPEC = {
451
+ maxLength: 280,
452
+ style: "concise, engaging, audience-friendly",
453
+ emojiSupport: true,
454
+ hashtagSupport: true,
455
+ imageSupport: true,
456
+ videoSupport: true,
457
+ maxHashtags: 5
458
+ };
459
+ function resolvePlatformSpec(platform) {
460
+ return PLATFORM_SPECS[platform] ?? FALLBACK_SPEC;
461
+ }
462
+ function resolveMaxContentLength(platform, override) {
463
+ return override ?? resolvePlatformSpec(platform).maxLength;
464
+ }
465
+
466
+ // src/content/domain/predicates/ScoreRangeGuard.ts
467
+ var SCORE_MIN = 0;
468
+ var SCORE_MAX = 100;
469
+ var SCORE_FALLBACK = 50;
470
+ var CONFIDENCE_MIN = 0;
471
+ var CONFIDENCE_MAX = 1;
472
+ var CONFIDENCE_FALLBACK = 0.5;
473
+ function clampScoreToValidRange(score, fallback = SCORE_FALLBACK) {
474
+ if (!Number.isFinite(score)) return fallback;
475
+ return Math.max(SCORE_MIN, Math.min(SCORE_MAX, score));
476
+ }
477
+ function clampConfidenceToValidRange(confidence, fallback = CONFIDENCE_FALLBACK) {
478
+ if (!Number.isFinite(confidence)) return fallback;
479
+ return Math.max(CONFIDENCE_MIN, Math.min(CONFIDENCE_MAX, confidence));
480
+ }
481
+
482
+ // src/content/domain/predicates/AbTestConfidence.ts
483
+ var AB_TEST_DEFAULT_CONFIDENCE = 0.7;
484
+
485
+ // src/content/domain/predicates/ProviderCostEstimator.ts
486
+ var FAL_FIXED_COST = 1;
487
+ var GROQ_FREE_TIER_COST = 0;
488
+ var GEMINI_IMAGE_COST = 0.02;
489
+ var GEMINI_TEXT_PER_1K_CHARS_COST = 1e-4;
490
+ var PRUNA_FIXED_COST = 1;
491
+ var UNKNOWN_PROVIDER_COST = 0;
492
+ function estimateGroqGenerationCost(_request) {
493
+ return GROQ_FREE_TIER_COST;
494
+ }
495
+ function estimateFalGenerationCost(_request) {
496
+ return FAL_FIXED_COST;
497
+ }
498
+ function estimateGeminiGenerationCost(request) {
499
+ if (request.type === "image") return GEMINI_IMAGE_COST;
500
+ return GEMINI_TEXT_PER_1K_CHARS_COST;
501
+ }
502
+ function estimatePrunaGenerationCost() {
503
+ return PRUNA_FIXED_COST;
504
+ }
505
+ function estimateUnknownProviderCost() {
506
+ return UNKNOWN_PROVIDER_COST;
507
+ }
508
+
509
+ // src/content/domain/predicates/FalImageRenderingOptions.ts
510
+ var FAL_FORMAT_TO_IMAGE_SIZE = {
511
+ square: "square_hd",
512
+ landscape: "landscape_16_9",
513
+ portrait: "portrait_9_16",
514
+ story: "portrait_9_16",
515
+ banner: "landscape_16_9"
516
+ };
517
+ var FAL_DEFAULT_IMAGE_SIZE = "square_hd";
518
+ var FAL_QUALITY_TO_STEPS = {
519
+ standard: 4,
520
+ high: 6,
521
+ ultra: 8
522
+ };
523
+ var FAL_DEFAULT_QUALITY_STEPS = 6;
524
+ function resolveFalImageSize(format) {
525
+ if (!format) return FAL_DEFAULT_IMAGE_SIZE;
526
+ return FAL_FORMAT_TO_IMAGE_SIZE[format] ?? FAL_DEFAULT_IMAGE_SIZE;
527
+ }
528
+ function resolveFalInferenceSteps(quality) {
529
+ if (!quality) return FAL_DEFAULT_QUALITY_STEPS;
530
+ return FAL_QUALITY_TO_STEPS[quality] ?? FAL_DEFAULT_QUALITY_STEPS;
531
+ }
532
+
533
+ // src/content/domain/validation/TopicTextValidator.ts
534
+ function validateTopicText(topic) {
535
+ if (typeof topic !== "string" || topic.trim().length < ValidationLimits.TOPIC.MIN) {
536
+ throw new ValidationError("Topic cannot be empty");
537
+ }
538
+ const trimmed = topic.trim();
539
+ if (trimmed.length > ValidationLimits.TOPIC.MAX) {
540
+ throw new ValidationError(`Topic exceeds maximum length of ${ValidationLimits.TOPIC.MAX} characters`);
541
+ }
542
+ return trimmed;
543
+ }
544
+
545
+ // src/content/domain/validation/ContentBodyValidator.ts
546
+ function validateContentBody(content) {
547
+ if (typeof content !== "string" || content.trim().length < ValidationLimits.CONTENT.MIN) {
548
+ throw new ValidationError("Content cannot be empty");
549
+ }
550
+ const trimmed = content.trim();
551
+ if (trimmed.length > ValidationLimits.CONTENT.MAX) {
552
+ throw new ValidationError(`Content exceeds maximum length of ${ValidationLimits.CONTENT.MAX} characters`);
553
+ }
554
+ return trimmed;
555
+ }
556
+ function truncateForSeoPreview(content) {
557
+ return content.substring(0, ValidationLimits.SEO_CONTENT_PREVIEW);
558
+ }
559
+ function truncateForBlogPromptPreview(content) {
560
+ return content.substring(0, ValidationLimits.BLOG_PROMPT_PREVIEW);
561
+ }
562
+ function truncateForAbVariantPreview(content) {
563
+ return content.substring(0, ValidationLimits.AB_VARIANT_CONTENT_PREVIEW);
564
+ }
565
+
566
+ // src/content/domain/validation/KeywordListValidator.ts
567
+ function validateKeywordList(keywords) {
568
+ if (!Array.isArray(keywords)) {
569
+ throw new ValidationError("Keywords must be an array");
570
+ }
571
+ if (keywords.length > ValidationLimits.KEYWORD.MAX_COUNT) {
572
+ throw new ValidationError(`Cannot process more than ${ValidationLimits.KEYWORD.MAX_COUNT} keywords`);
573
+ }
574
+ return keywords.filter((k) => typeof k === "string" && k.trim().length > 0).map((keyword) => {
575
+ const trimmed = keyword.trim();
576
+ if (trimmed.length > ValidationLimits.KEYWORD.MAX_LENGTH) {
577
+ const preview = trimmed.substring(0, 20);
578
+ throw new ValidationError(
579
+ `Keyword "${preview}..." exceeds maximum length of ${ValidationLimits.KEYWORD.MAX_LENGTH} characters`
580
+ );
581
+ }
582
+ return trimmed;
583
+ });
584
+ }
585
+
586
+ // src/content/domain/validation/DurationSecondsValidator.ts
587
+ function validateDurationSeconds(duration) {
588
+ if (!Number.isFinite(duration)) {
589
+ throw new ValidationError(
590
+ `Duration must be between ${ValidationLimits.DURATION_SECONDS.MIN} and ${ValidationLimits.DURATION_SECONDS.MAX} seconds`
591
+ );
592
+ }
593
+ if (duration < ValidationLimits.DURATION_SECONDS.MIN || duration > ValidationLimits.DURATION_SECONDS.MAX) {
594
+ throw new ValidationError(
595
+ `Duration must be between ${ValidationLimits.DURATION_SECONDS.MIN} and ${ValidationLimits.DURATION_SECONDS.MAX} seconds`
596
+ );
163
597
  }
164
- toString() {
165
- const statusPart = typeof this.metadata.status === "number" ? ` (HTTP ${this.metadata.status})` : "";
166
- return `${this.name} [${this.type}]: ${this.message}${statusPart}`;
598
+ return duration;
599
+ }
600
+
601
+ // src/content/domain/validation/CalendarDaysValidator.ts
602
+ function validateCalendarDays(days) {
603
+ if (!Number.isFinite(days)) {
604
+ throw new ValidationError(
605
+ `Days must be between ${ValidationLimits.CALENDAR_DAYS.MIN} and ${ValidationLimits.CALENDAR_DAYS.MAX}`
606
+ );
167
607
  }
168
- toJSON() {
169
- return {
170
- name: this.name,
171
- type: this.type,
172
- code: this.code,
173
- message: this.message,
174
- metadata: this.metadata
175
- };
608
+ if (days < ValidationLimits.CALENDAR_DAYS.MIN || days > ValidationLimits.CALENDAR_DAYS.MAX) {
609
+ throw new ValidationError(
610
+ `Days must be between ${ValidationLimits.CALENDAR_DAYS.MIN} and ${ValidationLimits.CALENDAR_DAYS.MAX}`
611
+ );
176
612
  }
177
- };
613
+ return days;
614
+ }
178
615
 
179
- // src/content/domain/errors/AIErrors.ts
180
- var ValidationError = class extends AIError {
181
- constructor(message) {
182
- super(message, "VALIDATION_ERROR");
183
- this.name = "ValidationError";
184
- }
185
- };
186
- var ProviderUnavailableError = class extends AIError {
187
- constructor(providerId) {
188
- super(`Provider ${providerId} is not available`, "PROVIDER_UNAVAILABLE");
189
- this.name = "ProviderUnavailableError";
616
+ // src/content/domain/validation/HashtagCountValidator.ts
617
+ function validateHashtagCount(count) {
618
+ if (!Number.isFinite(count)) {
619
+ throw new ValidationError(
620
+ `Hashtag count must be between ${ValidationLimits.HASHTAG_COUNT.MIN} and ${ValidationLimits.HASHTAG_COUNT.MAX}`
621
+ );
190
622
  }
191
- };
192
- var ProviderQuotaExhaustedError = class extends AIError {
193
- constructor(providerId) {
194
- super(`Provider ${providerId} quota exhausted`, "PROVIDER_QUOTA_EXHAUSTED");
195
- this.name = "ProviderQuotaExhaustedError";
623
+ if (count < ValidationLimits.HASHTAG_COUNT.MIN || count > ValidationLimits.HASHTAG_COUNT.MAX) {
624
+ throw new ValidationError(
625
+ `Hashtag count must be between ${ValidationLimits.HASHTAG_COUNT.MIN} and ${ValidationLimits.HASHTAG_COUNT.MAX}`
626
+ );
196
627
  }
197
- };
628
+ return Math.floor(count);
629
+ }
630
+
631
+ // src/content/domain/utils/IdGenerator.ts
632
+ function generateId(prefix) {
633
+ const id = typeof crypto !== "undefined" && typeof crypto.randomUUID === "function" ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 11)}`;
634
+ return prefix ? `${prefix}-${id}` : id;
635
+ }
198
636
 
199
637
  // src/core/errors/groq-error.ts
200
638
  var GroqError = class extends AIError {
@@ -263,18 +701,6 @@ function isTextProvider(provider) {
263
701
  return provider.capabilities.includes("text");
264
702
  }
265
703
 
266
- // src/content/domain/limits/ProviderTimingConfig.ts
267
- var ProviderTimingConfig = {
268
- DEFAULT_TIMEOUT_MS: 3e4,
269
- DEFAULT_RETRY_ATTEMPTS: 3,
270
- FAL_TIMEOUT_MS: 12e4,
271
- FAL_RETRY_ATTEMPTS: 2,
272
- GEMINI_TIMEOUT_MS: 6e4,
273
- GEMINI_RETRY_ATTEMPTS: 3,
274
- HEALTH_CHECK_TTL_MS: 5 * 60 * 1e3,
275
- RETRY_BACKOFF_BASE_MS: 1e3
276
- };
277
-
278
704
  // src/providers/factory/provider.factory.ts
279
705
  var ProviderFactory = class {
280
706
  providers = /* @__PURE__ */ new Map();
@@ -2048,11 +2474,6 @@ function findLastIndex2(items, predicate) {
2048
2474
  return -1;
2049
2475
  }
2050
2476
 
2051
- // src/content/domain/calculations/RetryBackoffDelay.ts
2052
- function calculateRetryBackoffDelayMs(attemptIndex) {
2053
- return ProviderTimingConfig.RETRY_BACKOFF_BASE_MS * Math.pow(2, attemptIndex);
2054
- }
2055
-
2056
2477
  // src/providers/base/base.provider.ts
2057
2478
  var BaseProvider = class {
2058
2479
  config;
@@ -2101,26 +2522,6 @@ var BaseProvider = class {
2101
2522
  }
2102
2523
  };
2103
2524
 
2104
- // src/content/domain/predicates/ProviderCostEstimator.ts
2105
- var FAL_FIXED_COST = 1;
2106
- var GEMINI_IMAGE_COST = 0.02;
2107
- var GEMINI_TEXT_PER_1K_CHARS_COST = 1e-4;
2108
- function estimateFalGenerationCost(_request) {
2109
- return FAL_FIXED_COST;
2110
- }
2111
- function estimateGeminiGenerationCost(request) {
2112
- if (request.type === "image") return GEMINI_IMAGE_COST;
2113
- return GEMINI_TEXT_PER_1K_CHARS_COST;
2114
- }
2115
-
2116
- // src/content/domain/limits/ModelDefaults.ts
2117
- var ModelDefaults = {
2118
- FAL_IMAGE: "fal-ai/flux/schnell",
2119
- FAL_VIDEO: "fal-ai/hunyuan-video/1",
2120
- FAL_IMAGE_TO_VIDEO: "fal-ai/fast-animatediff/image-to-video",
2121
- GEMINI_TEXT: "gemini-2.0-flash",
2122
- GEMINI_IMAGE: "imagen-4.0-generate-001"};
2123
-
2124
2525
  // src/providers/gemini/gemini.provider.ts
2125
2526
  var GEMINI_TIERS = {
2126
2527
  fast: "gemini-2.0-flash-lite",
@@ -2280,221 +2681,81 @@ var GeminiProvider = class extends BaseProvider {
2280
2681
  throw new AIError(
2281
2682
  classifyHttpStatus(response.status),
2282
2683
  `Gemini image generation error (${response.status}): ${message}`,
2283
- void 0,
2284
- { status: response.status }
2285
- );
2286
- }
2287
- const data = await response.json();
2288
- const imageData = data.candidates?.[0]?.content?.parts?.[0]?.inlineData;
2289
- if (!imageData) {
2290
- throw new AIError("SERVER_ERROR" /* SERVER_ERROR */, "No image data in Gemini response");
2291
- }
2292
- const url = `data:${imageData.mimeType};base64,${imageData.data}`;
2293
- return {
2294
- id: Date.now().toString(),
2295
- type: "image",
2296
- url,
2297
- metadata: {
2298
- provider: "gemini",
2299
- model: this.models.image,
2300
- mimeType: imageData.mimeType
2301
- },
2302
- createdAt: (/* @__PURE__ */ new Date()).toISOString()
2303
- };
2304
- } catch (error) {
2305
- throw new Error(`Gemini image generation failed: ${error instanceof Error ? error.message : "Unknown error"}`);
2306
- }
2307
- }
2308
- async generateVideo(_request) {
2309
- throw new Error("Gemini provider does not support video generation");
2310
- }
2311
- async imageToVideo(_request) {
2312
- throw new Error("Gemini provider does not support image-to-video conversion");
2313
- }
2314
- async videoToVideo(_request) {
2315
- throw new Error("Gemini provider does not support video-to-video conversion");
2316
- }
2317
- authHeaders() {
2318
- return {
2319
- "Content-Type": "application/json",
2320
- "x-goog-api-key": this.config.apiKey
2321
- };
2322
- }
2323
- buildImagePrompt(request) {
2324
- let prompt = request.prompt;
2325
- if (request.style) {
2326
- const styles = {
2327
- realistic: "photorealistic, highly detailed, 8k resolution",
2328
- cartoon: "cartoon style, colorful, animated",
2329
- abstract: "abstract art, modern, artistic",
2330
- minimalist: "minimalist, clean, simple",
2331
- vintage: "vintage style, retro, classic"
2332
- };
2333
- prompt += `, ${styles[request.style]}`;
2334
- }
2335
- if (request.quality === "ultra") {
2336
- prompt += ", ultra high quality, masterpiece";
2337
- }
2338
- return prompt;
2339
- }
2340
- };
2341
- function toGeminiContents(messages) {
2342
- return messages.filter((message) => message.role !== "system" && message.content.length > 0).map((message) => ({
2343
- role: message.role === "assistant" ? "model" : "user",
2344
- parts: [{ text: message.content }]
2345
- }));
2346
- }
2347
- function mapGeminiFinishReason(reason) {
2348
- if (reason === "STOP") return "stop";
2349
- if (reason === "MAX_TOKENS") return "length";
2350
- if (reason === "SAFETY" || reason === "PROHIBITED_CONTENT") return "content_filter";
2351
- return void 0;
2352
- }
2353
- function findLastIndex3(items, predicate) {
2354
- for (let i = items.length - 1; i >= 0; i--) {
2355
- if (predicate(items[i])) return i;
2356
- }
2357
- return -1;
2358
- }
2359
-
2360
- // src/content/domain/predicates/KeywordProminenceClassifier.ts
2361
- var HIGH_DENSITY_THRESHOLD = 2;
2362
- var MEDIUM_DENSITY_THRESHOLD = 1;
2363
- function classifyKeywordProminence(densityPercent) {
2364
- if (densityPercent > HIGH_DENSITY_THRESHOLD) return "high";
2365
- if (densityPercent > MEDIUM_DENSITY_THRESHOLD) return "medium";
2366
- return "low";
2367
- }
2368
- function isUnderutilizedKeyword(densityPercent) {
2369
- return densityPercent < 1;
2370
- }
2371
-
2372
- // src/content/domain/types/index.ts
2373
- var PLATFORM_SPECS = {
2374
- twitter: {
2375
- maxLength: 280,
2376
- style: "concise, engaging, thread-friendly",
2377
- emojiSupport: true,
2378
- hashtagSupport: true,
2379
- imageSupport: true,
2380
- videoSupport: true,
2381
- maxHashtags: 5
2382
- },
2383
- linkedin: {
2384
- maxLength: 3e3,
2385
- style: "professional, insightful, industry-focused",
2386
- emojiSupport: true,
2387
- hashtagSupport: true,
2388
- imageSupport: true,
2389
- videoSupport: true,
2390
- maxHashtags: 5
2391
- },
2392
- instagram: {
2393
- maxLength: 2200,
2394
- style: "visual, engaging, emoji-rich",
2395
- emojiSupport: true,
2396
- hashtagSupport: true,
2397
- imageSupport: true,
2398
- videoSupport: true,
2399
- maxHashtags: 30
2400
- },
2401
- threads: {
2402
- maxLength: 500,
2403
- style: "conversational, community-driven",
2404
- emojiSupport: true,
2405
- hashtagSupport: true,
2406
- imageSupport: true,
2407
- videoSupport: true,
2408
- maxHashtags: 5
2409
- },
2410
- tiktok: {
2411
- maxLength: 150,
2412
- style: "catchy, trending, short-form",
2413
- emojiSupport: true,
2414
- hashtagSupport: true,
2415
- imageSupport: false,
2416
- videoSupport: true,
2417
- maxHashtags: 5
2418
- },
2419
- facebook: {
2420
- maxLength: 63206,
2421
- style: "conversational, engaging, shareable",
2422
- emojiSupport: true,
2423
- hashtagSupport: true,
2424
- imageSupport: true,
2425
- videoSupport: true,
2426
- maxHashtags: 5
2684
+ void 0,
2685
+ { status: response.status }
2686
+ );
2687
+ }
2688
+ const data = await response.json();
2689
+ const imageData = data.candidates?.[0]?.content?.parts?.[0]?.inlineData;
2690
+ if (!imageData) {
2691
+ throw new AIError("SERVER_ERROR" /* SERVER_ERROR */, "No image data in Gemini response");
2692
+ }
2693
+ const url = `data:${imageData.mimeType};base64,${imageData.data}`;
2694
+ return {
2695
+ id: Date.now().toString(),
2696
+ type: "image",
2697
+ url,
2698
+ metadata: {
2699
+ provider: "gemini",
2700
+ model: this.models.image,
2701
+ mimeType: imageData.mimeType
2702
+ },
2703
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
2704
+ };
2705
+ } catch (error) {
2706
+ throw new Error(`Gemini image generation failed: ${error instanceof Error ? error.message : "Unknown error"}`);
2707
+ }
2708
+ }
2709
+ async generateVideo(_request) {
2710
+ throw new Error("Gemini provider does not support video generation");
2711
+ }
2712
+ async imageToVideo(_request) {
2713
+ throw new Error("Gemini provider does not support image-to-video conversion");
2714
+ }
2715
+ async videoToVideo(_request) {
2716
+ throw new Error("Gemini provider does not support video-to-video conversion");
2717
+ }
2718
+ authHeaders() {
2719
+ return {
2720
+ "Content-Type": "application/json",
2721
+ "x-goog-api-key": this.config.apiKey
2722
+ };
2723
+ }
2724
+ buildImagePrompt(request) {
2725
+ let prompt = request.prompt;
2726
+ if (request.style) {
2727
+ const styles = {
2728
+ realistic: "photorealistic, highly detailed, 8k resolution",
2729
+ cartoon: "cartoon style, colorful, animated",
2730
+ abstract: "abstract art, modern, artistic",
2731
+ minimalist: "minimalist, clean, simple",
2732
+ vintage: "vintage style, retro, classic"
2733
+ };
2734
+ prompt += `, ${styles[request.style]}`;
2735
+ }
2736
+ if (request.quality === "ultra") {
2737
+ prompt += ", ultra high quality, masterpiece";
2738
+ }
2739
+ return prompt;
2427
2740
  }
2428
2741
  };
2429
-
2430
- // src/content/domain/predicates/HashtagPriorityRanker.ts
2431
- var DEFAULT_HASHTAG_BUDGET = Number.MAX_SAFE_INTEGER;
2432
- function resolveHashtagBudget(platform) {
2433
- return PLATFORM_SPECS[platform]?.maxHashtags ?? DEFAULT_HASHTAG_BUDGET;
2434
- }
2435
- function rankAndTrimHashtags(hashtags, budget) {
2436
- if (hashtags.length <= budget) return [...hashtags];
2437
- return [...hashtags].sort((a, b) => b.length - a.length).slice(0, budget);
2438
- }
2439
-
2440
- // src/content/domain/predicates/PlatformSpecResolver.ts
2441
- var FALLBACK_SPEC = {
2442
- maxLength: 280,
2443
- style: "concise, engaging, audience-friendly",
2444
- emojiSupport: true,
2445
- hashtagSupport: true,
2446
- imageSupport: true,
2447
- videoSupport: true,
2448
- maxHashtags: 5
2449
- };
2450
- function resolvePlatformSpec(platform) {
2451
- return PLATFORM_SPECS[platform] ?? FALLBACK_SPEC;
2452
- }
2453
- function resolveMaxContentLength(platform, override) {
2454
- return override ?? resolvePlatformSpec(platform).maxLength;
2455
- }
2456
-
2457
- // src/content/domain/predicates/ScoreRangeGuard.ts
2458
- var SCORE_MIN = 0;
2459
- var SCORE_MAX = 100;
2460
- var SCORE_FALLBACK = 50;
2461
- var CONFIDENCE_MIN = 0;
2462
- var CONFIDENCE_MAX = 1;
2463
- var CONFIDENCE_FALLBACK = 0.5;
2464
- function clampScoreToValidRange(score, fallback = SCORE_FALLBACK) {
2465
- if (!Number.isFinite(score)) return fallback;
2466
- return Math.max(SCORE_MIN, Math.min(SCORE_MAX, score));
2467
- }
2468
- function clampConfidenceToValidRange(confidence, fallback = CONFIDENCE_FALLBACK) {
2469
- if (!Number.isFinite(confidence)) return fallback;
2470
- return Math.max(CONFIDENCE_MIN, Math.min(CONFIDENCE_MAX, confidence));
2742
+ function toGeminiContents(messages) {
2743
+ return messages.filter((message) => message.role !== "system" && message.content.length > 0).map((message) => ({
2744
+ role: message.role === "assistant" ? "model" : "user",
2745
+ parts: [{ text: message.content }]
2746
+ }));
2471
2747
  }
2472
-
2473
- // src/content/domain/predicates/AbTestConfidence.ts
2474
- var AB_TEST_DEFAULT_CONFIDENCE = 0.7;
2475
-
2476
- // src/content/domain/predicates/FalImageRenderingOptions.ts
2477
- var FAL_FORMAT_TO_IMAGE_SIZE = {
2478
- square: "square_hd",
2479
- landscape: "landscape_16_9",
2480
- portrait: "portrait_9_16",
2481
- story: "portrait_9_16",
2482
- banner: "landscape_16_9"
2483
- };
2484
- var FAL_DEFAULT_IMAGE_SIZE = "square_hd";
2485
- var FAL_QUALITY_TO_STEPS = {
2486
- standard: 4,
2487
- high: 6,
2488
- ultra: 8
2489
- };
2490
- var FAL_DEFAULT_QUALITY_STEPS = 6;
2491
- function resolveFalImageSize(format) {
2492
- if (!format) return FAL_DEFAULT_IMAGE_SIZE;
2493
- return FAL_FORMAT_TO_IMAGE_SIZE[format] ?? FAL_DEFAULT_IMAGE_SIZE;
2748
+ function mapGeminiFinishReason(reason) {
2749
+ if (reason === "STOP") return "stop";
2750
+ if (reason === "MAX_TOKENS") return "length";
2751
+ if (reason === "SAFETY" || reason === "PROHIBITED_CONTENT") return "content_filter";
2752
+ return void 0;
2494
2753
  }
2495
- function resolveFalInferenceSteps(quality) {
2496
- if (!quality) return FAL_DEFAULT_QUALITY_STEPS;
2497
- return FAL_QUALITY_TO_STEPS[quality] ?? FAL_DEFAULT_QUALITY_STEPS;
2754
+ function findLastIndex3(items, predicate) {
2755
+ for (let i = items.length - 1; i >= 0; i--) {
2756
+ if (predicate(items[i])) return i;
2757
+ }
2758
+ return -1;
2498
2759
  }
2499
2760
 
2500
2761
  // src/providers/fal/fal.provider.ts
@@ -3579,25 +3840,6 @@ function createAI(config = {}) {
3579
3840
  return factory;
3580
3841
  }
3581
3842
 
3582
- // src/content/domain/limits/SpeechPaceConfig.ts
3583
- var SpeechPaceConfig = {
3584
- WORDS_PER_SECOND: 2.5,
3585
- TOKENS_PER_SECOND: 10,
3586
- JSON_TOKEN_OVERHEAD: 500,
3587
- TOKENS_PER_CALENDAR_DAY: 150
3588
- };
3589
-
3590
- // src/content/domain/calculations/SpeechPaceEstimate.ts
3591
- function estimateWordCountForDuration(durationSeconds) {
3592
- return Math.floor(durationSeconds * SpeechPaceConfig.WORDS_PER_SECOND);
3593
- }
3594
- function estimateTokenBudgetForDuration(durationSeconds) {
3595
- return durationSeconds * SpeechPaceConfig.TOKENS_PER_SECOND + SpeechPaceConfig.JSON_TOKEN_OVERHEAD;
3596
- }
3597
- function estimateTokenBudgetForCalendarDays(days) {
3598
- return days * SpeechPaceConfig.TOKENS_PER_CALENDAR_DAY + SpeechPaceConfig.JSON_TOKEN_OVERHEAD;
3599
- }
3600
-
3601
3843
  // src/content/application/prompts/PromptBuilder.ts
3602
3844
  var PromptBuilder = class {
3603
3845
  static blogPost(input) {
@@ -3908,75 +4150,6 @@ Return only the JSON:
3908
4150
  }
3909
4151
  };
3910
4152
 
3911
- // src/content/domain/limits/ValidationLimits.ts
3912
- var ValidationLimits = {
3913
- TOPIC: {
3914
- MIN: 1,
3915
- MAX: 500
3916
- },
3917
- CONTENT: {
3918
- MIN: 1,
3919
- MAX: 1e4
3920
- },
3921
- KEYWORD: {
3922
- MAX_COUNT: 20,
3923
- MAX_LENGTH: 50
3924
- },
3925
- DURATION_SECONDS: {
3926
- MIN: 10,
3927
- MAX: 600
3928
- },
3929
- CALENDAR_DAYS: {
3930
- MIN: 1,
3931
- MAX: 90
3932
- },
3933
- HASHTAG_COUNT: {
3934
- MIN: 1,
3935
- MAX: 50
3936
- },
3937
- SEO_CONTENT_PREVIEW: 500,
3938
- BLOG_PROMPT_PREVIEW: 1e3,
3939
- AB_VARIANT_CONTENT_PREVIEW: 200
3940
- };
3941
-
3942
- // src/content/domain/validation/TopicTextValidator.ts
3943
- function validateTopicText(topic) {
3944
- if (typeof topic !== "string" || topic.trim().length < ValidationLimits.TOPIC.MIN) {
3945
- throw new ValidationError("Topic cannot be empty");
3946
- }
3947
- const trimmed = topic.trim();
3948
- if (trimmed.length > ValidationLimits.TOPIC.MAX) {
3949
- throw new ValidationError(`Topic exceeds maximum length of ${ValidationLimits.TOPIC.MAX} characters`);
3950
- }
3951
- return trimmed;
3952
- }
3953
-
3954
- // src/content/domain/validation/KeywordListValidator.ts
3955
- function validateKeywordList(keywords) {
3956
- if (!Array.isArray(keywords)) {
3957
- throw new ValidationError("Keywords must be an array");
3958
- }
3959
- if (keywords.length > ValidationLimits.KEYWORD.MAX_COUNT) {
3960
- throw new ValidationError(`Cannot process more than ${ValidationLimits.KEYWORD.MAX_COUNT} keywords`);
3961
- }
3962
- return keywords.filter((k) => typeof k === "string" && k.trim().length > 0).map((keyword) => {
3963
- const trimmed = keyword.trim();
3964
- if (trimmed.length > ValidationLimits.KEYWORD.MAX_LENGTH) {
3965
- const preview = trimmed.substring(0, 20);
3966
- throw new ValidationError(
3967
- `Keyword "${preview}..." exceeds maximum length of ${ValidationLimits.KEYWORD.MAX_LENGTH} characters`
3968
- );
3969
- }
3970
- return trimmed;
3971
- });
3972
- }
3973
-
3974
- // src/content/domain/utils/IdGenerator.ts
3975
- function generateId(prefix) {
3976
- const id = typeof crypto !== "undefined" && typeof crypto.randomUUID === "function" ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 11)}`;
3977
- return prefix ? `${prefix}-${id}` : id;
3978
- }
3979
-
3980
4153
  // src/content/application/services/BlogService.ts
3981
4154
  var BlogService = class {
3982
4155
  constructor(executor) {
@@ -3998,20 +4171,164 @@ var BlogService = class {
3998
4171
  includeSchema: request.includeSchema,
3999
4172
  includeImages: request.includeImages
4000
4173
  });
4001
- const parsed = await this.executor.runJson(
4002
- prompt,
4003
- {},
4004
- { maxTokens: request.wordCount * 2, temperature: 0.7 }
4174
+ const parsed = await this.executor.runJson(
4175
+ prompt,
4176
+ {},
4177
+ { maxTokens: request.wordCount * 2, temperature: 0.7 }
4178
+ );
4179
+ return {
4180
+ id: generateId("blog"),
4181
+ ...parsed,
4182
+ blogType: request.blogType,
4183
+ tone: request.tone,
4184
+ wordCount: request.wordCount,
4185
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
4186
+ };
4187
+ }
4188
+ };
4189
+
4190
+ // src/content/infrastructure/utils/requestQueue.ts
4191
+ var RequestPriority = /* @__PURE__ */ ((RequestPriority2) => {
4192
+ RequestPriority2[RequestPriority2["LOW"] = 0] = "LOW";
4193
+ RequestPriority2[RequestPriority2["NORMAL"] = 1] = "NORMAL";
4194
+ RequestPriority2[RequestPriority2["HIGH"] = 2] = "HIGH";
4195
+ RequestPriority2[RequestPriority2["URGENT"] = 3] = "URGENT";
4196
+ return RequestPriority2;
4197
+ })(RequestPriority || {});
4198
+ var DEFAULT_CONFIG = {
4199
+ maxConcurrent: RequestQueueConfig.MAX_CONCURRENT,
4200
+ maxQueueSize: RequestQueueConfig.MAX_QUEUE_SIZE,
4201
+ defaultTimeout: RequestQueueConfig.DEFAULT_TIMEOUT_MS,
4202
+ retryDelay: RequestQueueConfig.RETRY_DELAY_MS,
4203
+ enableRateLimit: RequestQueueConfig.RATE_LIMIT.ENABLED,
4204
+ rateLimitWindow: RequestQueueConfig.RATE_LIMIT.WINDOW_MS,
4205
+ rateLimitMaxRequests: RequestQueueConfig.RATE_LIMIT.MAX_REQUESTS_PER_WINDOW
4206
+ };
4207
+ var RequestQueue2 = class {
4208
+ queue = [];
4209
+ running = /* @__PURE__ */ new Set();
4210
+ config;
4211
+ requestHistory = [];
4212
+ isProcessing = false;
4213
+ constructor(config = {}) {
4214
+ this.config = { ...DEFAULT_CONFIG, ...config };
4215
+ }
4216
+ async add(fn, priority = 1 /* NORMAL */, maxRetries = 3) {
4217
+ if (this.queue.length >= this.config.maxQueueSize) {
4218
+ throw new Error("Queue is full");
4219
+ }
4220
+ return new Promise((resolve, reject) => {
4221
+ const request = {
4222
+ id: generateId("req"),
4223
+ priority,
4224
+ timestamp: Date.now(),
4225
+ fn,
4226
+ resolve,
4227
+ reject,
4228
+ retries: 0,
4229
+ maxRetries
4230
+ };
4231
+ this.queue.push(request);
4232
+ this.sortQueue();
4233
+ if (!this.isProcessing) {
4234
+ this.process();
4235
+ }
4236
+ });
4237
+ }
4238
+ sortQueue() {
4239
+ this.queue.sort((a, b) => {
4240
+ if (a.priority !== b.priority) {
4241
+ return b.priority - a.priority;
4242
+ }
4243
+ return a.timestamp - b.timestamp;
4244
+ });
4245
+ }
4246
+ async process() {
4247
+ if (this.isProcessing) return;
4248
+ this.isProcessing = true;
4249
+ while (this.queue.length > 0 || this.running.size > 0) {
4250
+ while (this.queue.length > 0 && this.running.size < this.config.maxConcurrent) {
4251
+ if (this.config.enableRateLimit && !this.canMakeRequest()) {
4252
+ break;
4253
+ }
4254
+ const request = this.queue.shift();
4255
+ if (!request) break;
4256
+ this.running.add(request.id);
4257
+ this.executeRequest(request);
4258
+ }
4259
+ await new Promise((resolve) => setTimeout(resolve, RequestQueueConfig.POLL_INTERVAL_MS));
4260
+ }
4261
+ this.isProcessing = false;
4262
+ }
4263
+ canMakeRequest() {
4264
+ const now = Date.now();
4265
+ const windowStart = now - this.config.rateLimitWindow;
4266
+ this.requestHistory = this.requestHistory.filter(
4267
+ (timestamp) => timestamp > windowStart
4005
4268
  );
4269
+ return this.requestHistory.length < this.config.rateLimitMaxRequests;
4270
+ }
4271
+ async executeRequest(request) {
4272
+ try {
4273
+ if (this.config.enableRateLimit) {
4274
+ this.requestHistory.push(Date.now());
4275
+ }
4276
+ const result = await this.withTimeout(
4277
+ request.fn,
4278
+ this.config.defaultTimeout
4279
+ );
4280
+ request.resolve(result);
4281
+ } catch (error) {
4282
+ if (request.retries < request.maxRetries) {
4283
+ request.retries++;
4284
+ const delay = this.config.retryDelay * request.retries;
4285
+ setTimeout(() => {
4286
+ this.queue.unshift(request);
4287
+ this.sortQueue();
4288
+ }, delay);
4289
+ } else {
4290
+ request.reject(error);
4291
+ }
4292
+ } finally {
4293
+ this.running.delete(request.id);
4294
+ }
4295
+ }
4296
+ async withTimeout(fn, timeout) {
4297
+ const controller = new AbortController();
4298
+ let timeoutId;
4299
+ const timeoutPromise = new Promise((_, reject) => {
4300
+ timeoutId = setTimeout(() => {
4301
+ controller.abort();
4302
+ reject(new Error("Request timeout"));
4303
+ }, timeout);
4304
+ });
4305
+ try {
4306
+ const result = await Promise.race([fn(controller.signal), timeoutPromise]);
4307
+ return result;
4308
+ } finally {
4309
+ if (timeoutId) clearTimeout(timeoutId);
4310
+ }
4311
+ }
4312
+ getStats() {
4006
4313
  return {
4007
- id: generateId("blog"),
4008
- ...parsed,
4009
- blogType: request.blogType,
4010
- tone: request.tone,
4011
- wordCount: request.wordCount,
4012
- createdAt: (/* @__PURE__ */ new Date()).toISOString()
4314
+ queued: this.queue.length,
4315
+ running: this.running.size,
4316
+ rateLimitRemaining: this.config.enableRateLimit ? this.config.rateLimitMaxRequests - this.requestHistory.filter(
4317
+ (timestamp) => Date.now() - timestamp < this.config.rateLimitWindow
4318
+ ).length : Infinity
4013
4319
  };
4014
4320
  }
4321
+ clear() {
4322
+ for (const request of this.queue) {
4323
+ request.reject(new Error("Queue cleared"));
4324
+ }
4325
+ this.queue = [];
4326
+ }
4327
+ async drain() {
4328
+ while (this.running.size > 0) {
4329
+ await new Promise((resolve) => setTimeout(resolve, RequestQueueConfig.POLL_INTERVAL_MS));
4330
+ }
4331
+ }
4015
4332
  };
4016
4333
  async function batchRequest(requests, options = {}) {
4017
4334
  const {
@@ -4044,21 +4361,6 @@ async function batchRequest(requests, options = {}) {
4044
4361
  return results;
4045
4362
  }
4046
4363
 
4047
- // src/content/domain/validation/HashtagCountValidator.ts
4048
- function validateHashtagCount(count) {
4049
- if (!Number.isFinite(count)) {
4050
- throw new ValidationError(
4051
- `Hashtag count must be between ${ValidationLimits.HASHTAG_COUNT.MIN} and ${ValidationLimits.HASHTAG_COUNT.MAX}`
4052
- );
4053
- }
4054
- if (count < ValidationLimits.HASHTAG_COUNT.MIN || count > ValidationLimits.HASHTAG_COUNT.MAX) {
4055
- throw new ValidationError(
4056
- `Hashtag count must be between ${ValidationLimits.HASHTAG_COUNT.MIN} and ${ValidationLimits.HASHTAG_COUNT.MAX}`
4057
- );
4058
- }
4059
- return Math.floor(count);
4060
- }
4061
-
4062
4364
  // src/content/application/services/SocialService.ts
4063
4365
  var MULTI_PLATFORMS = [
4064
4366
  "twitter",
@@ -4136,21 +4438,6 @@ var SocialService = class {
4136
4438
  }
4137
4439
  };
4138
4440
 
4139
- // src/content/domain/validation/DurationSecondsValidator.ts
4140
- function validateDurationSeconds(duration) {
4141
- if (!Number.isFinite(duration)) {
4142
- throw new ValidationError(
4143
- `Duration must be between ${ValidationLimits.DURATION_SECONDS.MIN} and ${ValidationLimits.DURATION_SECONDS.MAX} seconds`
4144
- );
4145
- }
4146
- if (duration < ValidationLimits.DURATION_SECONDS.MIN || duration > ValidationLimits.DURATION_SECONDS.MAX) {
4147
- throw new ValidationError(
4148
- `Duration must be between ${ValidationLimits.DURATION_SECONDS.MIN} and ${ValidationLimits.DURATION_SECONDS.MAX} seconds`
4149
- );
4150
- }
4151
- return duration;
4152
- }
4153
-
4154
4441
  // src/content/application/services/VideoScriptService.ts
4155
4442
  var buildScriptResult = (parsed, duration) => {
4156
4443
  const script = parsed.script ?? "";
@@ -4205,27 +4492,6 @@ var VideoScriptService = class {
4205
4492
  }
4206
4493
  };
4207
4494
 
4208
- // src/content/domain/validation/ContentBodyValidator.ts
4209
- function validateContentBody(content) {
4210
- if (typeof content !== "string" || content.trim().length < ValidationLimits.CONTENT.MIN) {
4211
- throw new ValidationError("Content cannot be empty");
4212
- }
4213
- const trimmed = content.trim();
4214
- if (trimmed.length > ValidationLimits.CONTENT.MAX) {
4215
- throw new ValidationError(`Content exceeds maximum length of ${ValidationLimits.CONTENT.MAX} characters`);
4216
- }
4217
- return trimmed;
4218
- }
4219
- function truncateForSeoPreview(content) {
4220
- return content.substring(0, ValidationLimits.SEO_CONTENT_PREVIEW);
4221
- }
4222
- function truncateForBlogPromptPreview(content) {
4223
- return content.substring(0, ValidationLimits.BLOG_PROMPT_PREVIEW);
4224
- }
4225
- function truncateForAbVariantPreview(content) {
4226
- return content.substring(0, ValidationLimits.AB_VARIANT_CONTENT_PREVIEW);
4227
- }
4228
-
4229
4495
  // src/content/application/services/AnalysisService.ts
4230
4496
  var DEFAULT_SENTIMENT = {
4231
4497
  sentiment: "neutral",
@@ -4278,23 +4544,6 @@ var AnalysisService = class {
4278
4544
  }
4279
4545
  };
4280
4546
 
4281
- // src/content/domain/calculations/SeoKeywordDensity.ts
4282
- function countKeywordOccurrences(content, keyword) {
4283
- if (!keyword) return 0;
4284
- const escaped = keyword.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
4285
- const matches = content.match(new RegExp(escaped, "gi"));
4286
- return matches ? matches.length : 0;
4287
- }
4288
- function countWordsInContent(content) {
4289
- const tokens = content.split(/\s+/).filter(Boolean);
4290
- return tokens.length || 1;
4291
- }
4292
- function calculateKeywordDensity(content, keyword) {
4293
- const totalWords = countWordsInContent(content);
4294
- const occurrences = countKeywordOccurrences(content, keyword);
4295
- return occurrences / totalWords * 100;
4296
- }
4297
-
4298
4547
  // src/content/application/services/SeoService.ts
4299
4548
  var DEFAULT_SEO_SCORE = {
4300
4549
  keywordDensity: 50,
@@ -4371,20 +4620,6 @@ var SeoService = class {
4371
4620
  }
4372
4621
  };
4373
4622
 
4374
- // src/content/domain/calculations/AbTestImprovementRatio.ts
4375
- function calculateImprovementPercentage(scoreA, scoreB) {
4376
- const higher = Math.max(scoreA, scoreB);
4377
- const lower = Math.min(scoreA, scoreB);
4378
- if (lower <= 0) {
4379
- return "100";
4380
- }
4381
- const delta = (higher / lower - 1) * 100;
4382
- return Math.abs(delta).toFixed(0);
4383
- }
4384
- function selectHigherScoreVariantId(scoreA, scoreB, idA = "A", idB = "B") {
4385
- return scoreA > scoreB ? idA : idB;
4386
- }
4387
-
4388
4623
  // src/content/application/services/ABTestService.ts
4389
4624
  var DEFAULT_PREDICTION = {
4390
4625
  variantId: "",
@@ -4486,27 +4721,6 @@ var ImagePromptService = class {
4486
4721
  }
4487
4722
  };
4488
4723
 
4489
- // src/content/domain/validation/CalendarDaysValidator.ts
4490
- function validateCalendarDays(days) {
4491
- if (!Number.isFinite(days)) {
4492
- throw new ValidationError(
4493
- `Days must be between ${ValidationLimits.CALENDAR_DAYS.MIN} and ${ValidationLimits.CALENDAR_DAYS.MAX}`
4494
- );
4495
- }
4496
- if (days < ValidationLimits.CALENDAR_DAYS.MIN || days > ValidationLimits.CALENDAR_DAYS.MAX) {
4497
- throw new ValidationError(
4498
- `Days must be between ${ValidationLimits.CALENDAR_DAYS.MIN} and ${ValidationLimits.CALENDAR_DAYS.MAX}`
4499
- );
4500
- }
4501
- return days;
4502
- }
4503
-
4504
- // src/content/domain/calculations/ContentCalendarDateOffset.ts
4505
- var ONE_DAY_MS = 24 * 60 * 60 * 1e3;
4506
- function resolveCalendarEntryDate(dayIndex, baseTimestamp = Date.now()) {
4507
- return new Date(baseTimestamp + (dayIndex - 1) * ONE_DAY_MS);
4508
- }
4509
-
4510
4724
  // src/content/application/services/ContentCalendarService.ts
4511
4725
  var toCalendarEntry = (item) => ({
4512
4726
  date: resolveCalendarEntryDate(item.day),
@@ -4599,7 +4813,10 @@ function safeJSONParse(text, fallback, onError) {
4599
4813
  const positionMatch = error.message.match(/position (\d+)/);
4600
4814
  const position = positionMatch ? parseInt(positionMatch[1], 10) : -1;
4601
4815
  if (position > 0) {
4602
- text.substring(Math.max(0, position - 50), position + 50);
4816
+ const context = text.substring(Math.max(0, position - 50), position + 50);
4817
+ onError?.(`JSON parse error at position ${position}: "${context}"`);
4818
+ } else {
4819
+ onError?.(`JSON parse error: ${error.message}`);
4603
4820
  }
4604
4821
  }
4605
4822
  return fallback;
@@ -4626,9 +4843,23 @@ function extractJSON(text) {
4626
4843
  function parseAIResponse(response, fallback, onError) {
4627
4844
  const json = extractJSON(response);
4628
4845
  if (!json) {
4846
+ onError?.("No JSON payload found in response");
4629
4847
  return fallback;
4630
4848
  }
4631
- return safeJSONParse(json, fallback);
4849
+ return safeJSONParse(json, fallback, onError);
4850
+ }
4851
+ function isValidJSON(text) {
4852
+ const trimmed = text.trim();
4853
+ if (trimmed.length === 0) return false;
4854
+ if (!(trimmed.startsWith("{") && trimmed.endsWith("}") || trimmed.startsWith("[") && trimmed.endsWith("]"))) {
4855
+ return false;
4856
+ }
4857
+ try {
4858
+ JSON.parse(trimmed);
4859
+ return true;
4860
+ } catch {
4861
+ return false;
4862
+ }
4632
4863
  }
4633
4864
 
4634
4865
  // src/content/application/services/GenerationExecutor.ts
@@ -4689,7 +4920,48 @@ function toAIProviderConfig(config) {
4689
4920
  ...pruna ? { pruna } : {}
4690
4921
  };
4691
4922
  }
4692
- var buildServices = (configOrGenerator) => {
4923
+ var buildServices = (configOrGenerator, model, customGenerator) => {
4924
+ if (customGenerator) {
4925
+ const executor2 = new GenerationExecutor(customGenerator);
4926
+ const emptyFactory = new ProviderFactory({
4927
+ priority: [],
4928
+ fallbackEnabled: false
4929
+ });
4930
+ return {
4931
+ providerFactory: emptyFactory,
4932
+ blogService: new BlogService(executor2),
4933
+ socialService: new SocialService(executor2),
4934
+ videoScriptService: new VideoScriptService(executor2),
4935
+ analysisService: new AnalysisService(executor2),
4936
+ seoService: new SeoService(executor2),
4937
+ abTestService: new ABTestService(executor2),
4938
+ imagePromptService: new ImagePromptService(executor2),
4939
+ contentCalendarService: new ContentCalendarService(executor2),
4940
+ mediaGenerationService: new MediaGenerationService(emptyFactory)
4941
+ };
4942
+ }
4943
+ if (typeof configOrGenerator === "string") {
4944
+ const aiConfig = {
4945
+ anthropic: {
4946
+ apiKey: configOrGenerator,
4947
+ ...model ? { models: { balanced: model } } : {}
4948
+ }
4949
+ };
4950
+ const factory2 = createAI(aiConfig);
4951
+ const executor2 = new GenerationExecutor(factory2);
4952
+ return {
4953
+ providerFactory: factory2,
4954
+ blogService: new BlogService(executor2),
4955
+ socialService: new SocialService(executor2),
4956
+ videoScriptService: new VideoScriptService(executor2),
4957
+ analysisService: new AnalysisService(executor2),
4958
+ seoService: new SeoService(executor2),
4959
+ abTestService: new ABTestService(executor2),
4960
+ imagePromptService: new ImagePromptService(executor2),
4961
+ contentCalendarService: new ContentCalendarService(executor2),
4962
+ mediaGenerationService: new MediaGenerationService(factory2)
4963
+ };
4964
+ }
4693
4965
  if (isTextGenerator(configOrGenerator)) {
4694
4966
  const executor2 = new GenerationExecutor(configOrGenerator);
4695
4967
  const emptyFactory = new ProviderFactory({
@@ -4735,8 +5007,8 @@ var AIContentService = class {
4735
5007
  imagePromptService;
4736
5008
  contentCalendarService;
4737
5009
  mediaGenerationService;
4738
- constructor(configOrGenerator) {
4739
- const bundle = buildServices(configOrGenerator);
5010
+ constructor(configOrGenerator, model, textGenerator) {
5011
+ const bundle = buildServices(configOrGenerator, model, textGenerator);
4740
5012
  this.providerFactory = bundle.providerFactory;
4741
5013
  this.blogService = bundle.blogService;
4742
5014
  this.socialService = bundle.socialService;
@@ -4817,6 +5089,226 @@ var AIContentService = class {
4817
5089
  }
4818
5090
  };
4819
5091
 
4820
- export { ABTestService, AIContentService, AIError, ASPECT_RATIO_OPTIONS, ASPECT_RATIO_VALUES, AnalysisService, BlogService, ContentCalendarService, CREDIT_COSTS as GENERATION_COSTS, GenerationExecutor, IMAGE_QUALITY_OPTIONS, IMAGE_QUALITY_VALUES, ImagePromptService, MOTION_OPTIONS, MediaGenerationService, PromptBuilder, ProviderQuotaExhaustedError, ProviderUnavailableError, STYLE_PRESETS, SeoService, SocialService, VIDEO_DURATION_OPTIONS, VIDEO_DURATION_OPTIONS_SECONDS, VIDEO_QUALITY_OPTIONS, VIDEO_QUALITY_VALUES, ValidationError, VideoScriptService, calculateContentCreditCost as calculateCreditCost, getDimensionsForAspectRatio, getRecommendedQuality };
5092
+ // src/wizard/content.wizard.ts
5093
+ var CONTENT_WIZARD_STEPS = [
5094
+ {
5095
+ id: "select-type",
5096
+ label: "Select Type",
5097
+ icon: "Layers",
5098
+ description: "Choose the type of content you want to generate",
5099
+ validate: (data) => Boolean(data.contentType)
5100
+ },
5101
+ {
5102
+ id: "input-topic",
5103
+ label: "Topic",
5104
+ icon: "Lightbulb",
5105
+ description: "Enter your topic or idea",
5106
+ validate: (data) => {
5107
+ const topic = data.topic;
5108
+ return typeof topic === "string" && topic.length > 0;
5109
+ }
5110
+ },
5111
+ {
5112
+ id: "configure",
5113
+ label: "Configure",
5114
+ icon: "Settings",
5115
+ description: "Set tone, audience, and platform",
5116
+ validate: (data) => {
5117
+ const d = data;
5118
+ return Boolean(d.tone && d.targetAudience);
5119
+ }
5120
+ },
5121
+ {
5122
+ id: "advanced",
5123
+ label: "Advanced",
5124
+ icon: "Sliders",
5125
+ description: "Additional options and optimizations",
5126
+ optional: true
5127
+ },
5128
+ {
5129
+ id: "preview",
5130
+ label: "Preview",
5131
+ icon: "Eye",
5132
+ description: "Review your settings before generation"
5133
+ },
5134
+ {
5135
+ id: "generating",
5136
+ label: "Generating",
5137
+ icon: "Sparkles",
5138
+ description: "AI is generating your content"
5139
+ },
5140
+ {
5141
+ id: "results",
5142
+ label: "Results",
5143
+ icon: "CheckCircle",
5144
+ description: "Your generated content is ready"
5145
+ }
5146
+ ];
5147
+ function buildContentRequest(data) {
5148
+ switch (data.contentType) {
5149
+ case "blog":
5150
+ return {
5151
+ topic: data.topic ?? "",
5152
+ blogType: "tutorial",
5153
+ targetKeywords: data.keywords ?? [],
5154
+ tone: data.tone ?? "professional",
5155
+ wordCount: data.wordCount ?? 1e3,
5156
+ targetAudience: data.targetAudience ?? "",
5157
+ seoOptimization: data.seoOptimization ?? false,
5158
+ includeImages: data.includeImages ?? false,
5159
+ includeSchema: false
5160
+ };
5161
+ case "social":
5162
+ return {
5163
+ topic: data.topic ?? "",
5164
+ platform: data.platform ?? "twitter",
5165
+ tone: data.tone ?? "casual",
5166
+ hashtags: true,
5167
+ targetAudience: data.targetAudience,
5168
+ includeCallToAction: data.includeCallToAction
5169
+ };
5170
+ case "script":
5171
+ return {
5172
+ topic: data.topic ?? "",
5173
+ tone: data.tone ?? "professional",
5174
+ duration: data.duration ?? 60,
5175
+ targetAudience: data.targetAudience ?? "",
5176
+ includeVisuals: true,
5177
+ includeCallToAction: data.includeCallToAction ?? false
5178
+ };
5179
+ default:
5180
+ throw new Error(`Unsupported content type: ${data.contentType}`);
5181
+ }
5182
+ }
5183
+
5184
+ // src/wizard/image.wizard.ts
5185
+ var IMAGE_WIZARD_STEPS = [
5186
+ {
5187
+ id: "input-prompt",
5188
+ label: "Describe Image",
5189
+ icon: "Image",
5190
+ description: "Describe the image you want to create",
5191
+ validate: (data) => {
5192
+ const prompt = data.prompt;
5193
+ return typeof prompt === "string" && prompt.length > 0;
5194
+ }
5195
+ },
5196
+ {
5197
+ id: "select-style",
5198
+ label: "Style",
5199
+ icon: "Palette",
5200
+ description: "Choose the artistic style",
5201
+ validate: (data) => Boolean(data.style)
5202
+ },
5203
+ {
5204
+ id: "configure",
5205
+ label: "Configure",
5206
+ icon: "Settings",
5207
+ description: "Set format, quality, and quantity",
5208
+ validate: (data) => {
5209
+ const d = data;
5210
+ return Boolean(d.format && d.quality);
5211
+ }
5212
+ },
5213
+ {
5214
+ id: "advanced",
5215
+ label: "Advanced",
5216
+ icon: "Sliders",
5217
+ description: "Color palette and platform optimization",
5218
+ optional: true
5219
+ },
5220
+ { id: "preview", label: "Preview", icon: "Eye", description: "Review your settings" },
5221
+ { id: "generating", label: "Generating", icon: "Sparkles", description: "AI is creating your image" },
5222
+ { id: "results", label: "Results", icon: "Image", description: "Your generated image is ready" }
5223
+ ];
5224
+ function buildImageRequest(data) {
5225
+ return {
5226
+ type: "image",
5227
+ prompt: data.prompt ?? "",
5228
+ style: data.style,
5229
+ format: data.format,
5230
+ quality: data.quality,
5231
+ quantity: data.quantity ?? 1
5232
+ };
5233
+ }
5234
+
5235
+ // src/wizard/video.wizard.ts
5236
+ var validateSource = (data) => {
5237
+ const d = data;
5238
+ if (d.generationType === "text-to-video") {
5239
+ return typeof d.prompt === "string" && d.prompt.length > 0;
5240
+ }
5241
+ if (d.generationType === "image-to-video") {
5242
+ return typeof d.imageUrl === "string" && d.imageUrl.length > 0;
5243
+ }
5244
+ if (d.generationType === "video-to-video") {
5245
+ return typeof d.sourceVideoUrl === "string" && d.sourceVideoUrl.length > 0 && typeof d.prompt === "string" && d.prompt.length > 0;
5246
+ }
5247
+ return false;
5248
+ };
5249
+ var VIDEO_WIZARD_STEPS = [
5250
+ {
5251
+ id: "select-type",
5252
+ label: "Select Type",
5253
+ icon: "Video",
5254
+ description: "Choose video generation type",
5255
+ validate: (data) => Boolean(data.generationType)
5256
+ },
5257
+ {
5258
+ id: "input-source",
5259
+ label: "Source",
5260
+ icon: "FileInput",
5261
+ description: "Provide your source (prompt, image, or video)",
5262
+ validate: validateSource
5263
+ },
5264
+ {
5265
+ id: "configure",
5266
+ label: "Configure",
5267
+ icon: "Settings",
5268
+ description: "Set duration, aspect ratio, and style",
5269
+ validate: (data) => {
5270
+ const d = data;
5271
+ return Boolean(d.duration && d.aspectRatio);
5272
+ }
5273
+ },
5274
+ { id: "advanced", label: "Advanced", icon: "Sliders", description: "Additional video options", optional: true },
5275
+ { id: "preview", label: "Preview", icon: "Eye", description: "Review your settings" },
5276
+ { id: "generating", label: "Generating", icon: "Sparkles", description: "AI is creating your video" },
5277
+ { id: "results", label: "Results", icon: "Video", description: "Your generated video is ready" }
5278
+ ];
5279
+ function buildVideoRequest(data) {
5280
+ switch (data.generationType) {
5281
+ case "text-to-video":
5282
+ return {
5283
+ type: "video",
5284
+ prompt: data.prompt ?? "",
5285
+ duration: data.duration ?? 5,
5286
+ aspectRatio: data.aspectRatio ?? "16:9",
5287
+ style: data.style,
5288
+ quality: data.quality
5289
+ };
5290
+ case "image-to-video":
5291
+ return {
5292
+ type: "video",
5293
+ imageUrl: data.imageUrl ?? "",
5294
+ prompt: data.prompt,
5295
+ duration: data.duration ?? 5,
5296
+ motion: data.motion ?? "medium",
5297
+ camera: data.camera ?? "static"
5298
+ };
5299
+ case "video-to-video":
5300
+ return {
5301
+ type: "video",
5302
+ sourceVideoUrl: data.sourceVideoUrl ?? "",
5303
+ prompt: data.prompt ?? "",
5304
+ styleTransfer: data.styleTransfer,
5305
+ enhanceQuality: data.enhanceQuality
5306
+ };
5307
+ default:
5308
+ throw new Error(`Unsupported generation type: ${data.generationType}`);
5309
+ }
5310
+ }
5311
+
5312
+ export { ABTestService, AB_TEST_DEFAULT_CONFIDENCE, AIContentService, AIError, ASPECT_RATIO_OPTIONS, ASPECT_RATIO_VALUES, AnalysisService, BlogService, CONTENT_WIZARD_STEPS, CREDIT_COSTS, ContentCalendarService, RequestQueue2 as ContentRequestQueue, DEFAULT_CREDIT_COST, DEFAULT_HASHTAG_BUDGET, CREDIT_COSTS as GENERATION_COSTS, GenerationExecutor, IMAGE_QUALITY_OPTIONS, IMAGE_QUALITY_VALUES, IMAGE_WIZARD_STEPS, ImagePromptService, MOTION_OPTIONS, MediaGenerationService, MemoryConfig, ModelDefaults, PLATFORM_SPECS, PromptBuilder, ProviderQuotaExhaustedError, ProviderTimingConfig, ProviderUnavailableError, RequestPriority, RequestQueueConfig, STYLE_PRESETS, SeoService, SocialService, SpeechPaceConfig, TextModelDefaults, VIDEO_DURATION_OPTIONS, VIDEO_DURATION_OPTIONS_SECONDS, VIDEO_QUALITY_OPTIONS, VIDEO_QUALITY_VALUES, VIDEO_WIZARD_STEPS, ValidationError, ValidationLimits, VideoScriptService, batchRequest, buildContentRequest, buildImageRequest, buildVideoRequest, calculateContentCreditCost, calculateContentCreditCost as calculateCreditCost, calculateImprovementPercentage, calculateKeywordDensity, calculateRetryBackoffDelayMs, clampConfidenceToValidRange, clampScoreToValidRange, classifyKeywordProminence, countKeywordOccurrences, countWordsInContent, estimateFalGenerationCost, estimateGeminiGenerationCost, estimateGroqGenerationCost, estimatePrunaGenerationCost, estimateTokenBudgetForCalendarDays, estimateTokenBudgetForDuration, estimateUnknownProviderCost, estimateWordCountForDuration, extractJSON, generateId, getDimensionsForAspectRatio, getRecommendedQuality, isUnderutilizedKeyword, isValidJSON, parseAIResponse, rankAndTrimHashtags, recommendQualityForAspectRatio, resolveCalendarEntryDate, resolveDefaultPrunaModel, resolveDimensionsForAspectRatio, resolveFalImageSize, resolveFalInferenceSteps, resolveHashtagBudget, resolveMaxContentLength, resolvePlatformSpec, safeJSONParse, selectHigherScoreVariantId, toQualityTier, truncateForAbVariantPreview, truncateForBlogPromptPreview, truncateForSeoPreview, validateCalendarDays, validateContentBody, validateDurationSeconds, validateHashtagCount, validateKeywordList, validateTopicText };
4821
5313
  //# sourceMappingURL=index.js.map
4822
5314
  //# sourceMappingURL=index.js.map