@mux/ai 0.8.2 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{index-DP02N3iR.d.ts → index-CkJStzYO.d.ts} +12 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +198 -169
- package/dist/index.js.map +1 -1
- package/dist/workflows/index.d.ts +1 -1
- package/dist/workflows/index.js +197 -168
- package/dist/workflows/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AskQuestionsOptions, a as AskQuestionsResult, b as AskQuestionsType, c as AudioTranslationOptions, d as AudioTranslationResult, B as BurnedInCaptionsAnalysis, e as BurnedInCaptionsOptions, f as BurnedInCaptionsPromptOverrides, g as BurnedInCaptionsPromptSections, h as BurnedInCaptionsResult, C as Chapter, j as ChapterSystemPromptSections, k as ChaptersOptions, l as ChaptersPromptOverrides, m as ChaptersPromptSections, n as ChaptersResult, o as ChaptersType, E as EmbeddingsOptions, p as EmbeddingsResult, H as HIVE_SEXUAL_CATEGORIES, q as HIVE_VIOLENCE_CATEGORIES, r as HiveModerationOutput, s as HiveModerationSource, M as ModerationOptions, t as ModerationProvider, u as ModerationResult, Q as Question, v as QuestionAnswer, w as QuestionAnswerType, S as SUMMARY_KEYWORD_LIMIT, x as SummarizationOptions, y as SummarizationPromptOverrides, z as SummarizationPromptSections, D as SummaryAndTagsResult, F as SummaryType, T as ThumbnailModerationScore, G as TranslationOptions, I as TranslationPayload, J as TranslationResult, K as askQuestions, L as burnedInCaptionsSchema, N as chapterSchema, O as chaptersSchema, P as generateChapters, R as generateEmbeddings, U as generateVideoEmbeddings, V as getModerationScores, W as getSummaryAndTags, X as hasBurnedInCaptions, Y as questionAnswerSchema, Z as summarySchema, _ as translateAudio, $ as translateCaptions, a0 as translationSchema } from '../index-
|
|
1
|
+
export { A as AskQuestionsOptions, a as AskQuestionsResult, b as AskQuestionsType, c as AudioTranslationOptions, d as AudioTranslationResult, B as BurnedInCaptionsAnalysis, e as BurnedInCaptionsOptions, f as BurnedInCaptionsPromptOverrides, g as BurnedInCaptionsPromptSections, h as BurnedInCaptionsResult, C as Chapter, j as ChapterSystemPromptSections, k as ChaptersOptions, l as ChaptersPromptOverrides, m as ChaptersPromptSections, n as ChaptersResult, o as ChaptersType, E as EmbeddingsOptions, p as EmbeddingsResult, H as HIVE_SEXUAL_CATEGORIES, q as HIVE_VIOLENCE_CATEGORIES, r as HiveModerationOutput, s as HiveModerationSource, M as ModerationOptions, t as ModerationProvider, u as ModerationResult, Q as Question, v as QuestionAnswer, w as QuestionAnswerType, S as SUMMARY_KEYWORD_LIMIT, x as SummarizationOptions, y as SummarizationPromptOverrides, z as SummarizationPromptSections, D as SummaryAndTagsResult, F as SummaryType, T as ThumbnailModerationScore, G as TranslationOptions, I as TranslationPayload, J as TranslationResult, K as askQuestions, L as burnedInCaptionsSchema, N as chapterSchema, O as chaptersSchema, P as generateChapters, R as generateEmbeddings, U as generateVideoEmbeddings, V as getModerationScores, W as getSummaryAndTags, X as hasBurnedInCaptions, Y as questionAnswerSchema, Z as summarySchema, _ as translateAudio, $ as translateCaptions, a0 as translationSchema } from '../index-CkJStzYO.js';
|
|
2
2
|
import 'zod';
|
|
3
3
|
import '@ai-sdk/anthropic';
|
|
4
4
|
import '@ai-sdk/google';
|
package/dist/workflows/index.js
CHANGED
|
@@ -837,6 +837,12 @@ function createToneSection(instruction) {
|
|
|
837
837
|
content: instruction
|
|
838
838
|
};
|
|
839
839
|
}
|
|
840
|
+
function createLanguageSection(languageName) {
|
|
841
|
+
return {
|
|
842
|
+
tag: "language",
|
|
843
|
+
content: `All output (title, description, keywords, chapter titles) MUST be written in ${languageName}.`
|
|
844
|
+
};
|
|
845
|
+
}
|
|
840
846
|
|
|
841
847
|
// src/lib/retry.ts
|
|
842
848
|
var DEFAULT_RETRY_OPTIONS = {
|
|
@@ -1200,6 +1206,7 @@ var SYSTEM_PROMPT = dedent`
|
|
|
1200
1206
|
- Only describe observable evidence from frames or transcript
|
|
1201
1207
|
- Do not fabricate details or make unsupported assumptions
|
|
1202
1208
|
- Return structured data matching the requested schema exactly
|
|
1209
|
+
- Provide reasoning in the same language as the question
|
|
1203
1210
|
</constraints>
|
|
1204
1211
|
|
|
1205
1212
|
<language_guidelines>
|
|
@@ -1600,6 +1607,166 @@ async function hasBurnedInCaptions(assetId, options = {}) {
|
|
|
1600
1607
|
import { generateText as generateText3, Output as Output3 } from "ai";
|
|
1601
1608
|
import dedent3 from "dedent";
|
|
1602
1609
|
import { z as z4 } from "zod";
|
|
1610
|
+
|
|
1611
|
+
// src/lib/language-codes.ts
|
|
1612
|
+
var ISO639_1_TO_3 = {
|
|
1613
|
+
// Major world languages
|
|
1614
|
+
en: "eng",
|
|
1615
|
+
// English
|
|
1616
|
+
es: "spa",
|
|
1617
|
+
// Spanish
|
|
1618
|
+
fr: "fra",
|
|
1619
|
+
// French
|
|
1620
|
+
de: "deu",
|
|
1621
|
+
// German
|
|
1622
|
+
it: "ita",
|
|
1623
|
+
// Italian
|
|
1624
|
+
pt: "por",
|
|
1625
|
+
// Portuguese
|
|
1626
|
+
ru: "rus",
|
|
1627
|
+
// Russian
|
|
1628
|
+
zh: "zho",
|
|
1629
|
+
// Chinese
|
|
1630
|
+
ja: "jpn",
|
|
1631
|
+
// Japanese
|
|
1632
|
+
ko: "kor",
|
|
1633
|
+
// Korean
|
|
1634
|
+
ar: "ara",
|
|
1635
|
+
// Arabic
|
|
1636
|
+
hi: "hin",
|
|
1637
|
+
// Hindi
|
|
1638
|
+
// European languages
|
|
1639
|
+
nl: "nld",
|
|
1640
|
+
// Dutch
|
|
1641
|
+
pl: "pol",
|
|
1642
|
+
// Polish
|
|
1643
|
+
sv: "swe",
|
|
1644
|
+
// Swedish
|
|
1645
|
+
da: "dan",
|
|
1646
|
+
// Danish
|
|
1647
|
+
no: "nor",
|
|
1648
|
+
// Norwegian
|
|
1649
|
+
fi: "fin",
|
|
1650
|
+
// Finnish
|
|
1651
|
+
el: "ell",
|
|
1652
|
+
// Greek
|
|
1653
|
+
cs: "ces",
|
|
1654
|
+
// Czech
|
|
1655
|
+
hu: "hun",
|
|
1656
|
+
// Hungarian
|
|
1657
|
+
ro: "ron",
|
|
1658
|
+
// Romanian
|
|
1659
|
+
bg: "bul",
|
|
1660
|
+
// Bulgarian
|
|
1661
|
+
hr: "hrv",
|
|
1662
|
+
// Croatian
|
|
1663
|
+
sk: "slk",
|
|
1664
|
+
// Slovak
|
|
1665
|
+
sl: "slv",
|
|
1666
|
+
// Slovenian
|
|
1667
|
+
uk: "ukr",
|
|
1668
|
+
// Ukrainian
|
|
1669
|
+
tr: "tur",
|
|
1670
|
+
// Turkish
|
|
1671
|
+
// Asian languages
|
|
1672
|
+
th: "tha",
|
|
1673
|
+
// Thai
|
|
1674
|
+
vi: "vie",
|
|
1675
|
+
// Vietnamese
|
|
1676
|
+
id: "ind",
|
|
1677
|
+
// Indonesian
|
|
1678
|
+
ms: "msa",
|
|
1679
|
+
// Malay
|
|
1680
|
+
tl: "tgl",
|
|
1681
|
+
// Tagalog/Filipino
|
|
1682
|
+
// Other languages
|
|
1683
|
+
he: "heb",
|
|
1684
|
+
// Hebrew
|
|
1685
|
+
fa: "fas",
|
|
1686
|
+
// Persian/Farsi
|
|
1687
|
+
bn: "ben",
|
|
1688
|
+
// Bengali
|
|
1689
|
+
ta: "tam",
|
|
1690
|
+
// Tamil
|
|
1691
|
+
te: "tel",
|
|
1692
|
+
// Telugu
|
|
1693
|
+
mr: "mar",
|
|
1694
|
+
// Marathi
|
|
1695
|
+
gu: "guj",
|
|
1696
|
+
// Gujarati
|
|
1697
|
+
kn: "kan",
|
|
1698
|
+
// Kannada
|
|
1699
|
+
ml: "mal",
|
|
1700
|
+
// Malayalam
|
|
1701
|
+
pa: "pan",
|
|
1702
|
+
// Punjabi
|
|
1703
|
+
ur: "urd",
|
|
1704
|
+
// Urdu
|
|
1705
|
+
sw: "swa",
|
|
1706
|
+
// Swahili
|
|
1707
|
+
af: "afr",
|
|
1708
|
+
// Afrikaans
|
|
1709
|
+
ca: "cat",
|
|
1710
|
+
// Catalan
|
|
1711
|
+
eu: "eus",
|
|
1712
|
+
// Basque
|
|
1713
|
+
gl: "glg",
|
|
1714
|
+
// Galician
|
|
1715
|
+
is: "isl",
|
|
1716
|
+
// Icelandic
|
|
1717
|
+
et: "est",
|
|
1718
|
+
// Estonian
|
|
1719
|
+
lv: "lav",
|
|
1720
|
+
// Latvian
|
|
1721
|
+
lt: "lit"
|
|
1722
|
+
// Lithuanian
|
|
1723
|
+
};
|
|
1724
|
+
var ISO639_3_TO_1 = Object.fromEntries(
|
|
1725
|
+
Object.entries(ISO639_1_TO_3).map(([iso1, iso3]) => [iso3, iso1])
|
|
1726
|
+
);
|
|
1727
|
+
function toISO639_3(code) {
|
|
1728
|
+
const normalized = code.toLowerCase().trim();
|
|
1729
|
+
if (normalized.length === 3) {
|
|
1730
|
+
return normalized;
|
|
1731
|
+
}
|
|
1732
|
+
return ISO639_1_TO_3[normalized] ?? normalized;
|
|
1733
|
+
}
|
|
1734
|
+
function toISO639_1(code) {
|
|
1735
|
+
const normalized = code.toLowerCase().trim();
|
|
1736
|
+
if (normalized.length === 2) {
|
|
1737
|
+
return normalized;
|
|
1738
|
+
}
|
|
1739
|
+
return ISO639_3_TO_1[normalized] ?? normalized;
|
|
1740
|
+
}
|
|
1741
|
+
function getLanguageCodePair(code) {
|
|
1742
|
+
const normalized = code.toLowerCase().trim();
|
|
1743
|
+
if (normalized.length === 2) {
|
|
1744
|
+
return {
|
|
1745
|
+
iso639_1: normalized,
|
|
1746
|
+
iso639_3: toISO639_3(normalized)
|
|
1747
|
+
};
|
|
1748
|
+
} else if (normalized.length === 3) {
|
|
1749
|
+
return {
|
|
1750
|
+
iso639_1: toISO639_1(normalized),
|
|
1751
|
+
iso639_3: normalized
|
|
1752
|
+
};
|
|
1753
|
+
}
|
|
1754
|
+
return {
|
|
1755
|
+
iso639_1: normalized,
|
|
1756
|
+
iso639_3: normalized
|
|
1757
|
+
};
|
|
1758
|
+
}
|
|
1759
|
+
function getLanguageName(code) {
|
|
1760
|
+
const iso639_1 = toISO639_1(code);
|
|
1761
|
+
try {
|
|
1762
|
+
const displayNames = new Intl.DisplayNames(["en"], { type: "language" });
|
|
1763
|
+
return displayNames.of(iso639_1) ?? code.toUpperCase();
|
|
1764
|
+
} catch {
|
|
1765
|
+
return code.toUpperCase();
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
|
|
1769
|
+
// src/workflows/chapters.ts
|
|
1603
1770
|
var chapterSchema = z4.object({
|
|
1604
1771
|
startTime: z4.number(),
|
|
1605
1772
|
title: z4.string()
|
|
@@ -1660,7 +1827,8 @@ var chapterSystemPromptBuilder = createPromptBuilder({
|
|
|
1660
1827
|
content: dedent3`
|
|
1661
1828
|
- Only use information present in the transcript
|
|
1662
1829
|
- Return structured data that matches the requested JSON schema
|
|
1663
|
-
- Do not add commentary or extra text outside the JSON
|
|
1830
|
+
- Do not add commentary or extra text outside the JSON
|
|
1831
|
+
- When a <language> section is provided, all chapter titles MUST be written in that language`
|
|
1664
1832
|
},
|
|
1665
1833
|
qualityGuidelines: {
|
|
1666
1834
|
tag: "quality_guidelines",
|
|
@@ -1708,7 +1876,7 @@ var chaptersPromptBuilder = createPromptBuilder({
|
|
|
1708
1876
|
content: dedent3`
|
|
1709
1877
|
- Keep titles concise and descriptive
|
|
1710
1878
|
- Avoid filler or generic labels like "Chapter 1"
|
|
1711
|
-
- Use the transcript's
|
|
1879
|
+
- Use the transcript's terminology`
|
|
1712
1880
|
}
|
|
1713
1881
|
},
|
|
1714
1882
|
sectionOrder: ["task", "outputFormat", "chapterGuidelines", "titleGuidelines"]
|
|
@@ -1717,7 +1885,8 @@ function buildUserPrompt3({
|
|
|
1717
1885
|
timestampedTranscript,
|
|
1718
1886
|
promptOverrides,
|
|
1719
1887
|
minChaptersPerHour = 3,
|
|
1720
|
-
maxChaptersPerHour = 8
|
|
1888
|
+
maxChaptersPerHour = 8,
|
|
1889
|
+
languageName
|
|
1721
1890
|
}) {
|
|
1722
1891
|
const contextSections = [
|
|
1723
1892
|
{
|
|
@@ -1726,6 +1895,9 @@ function buildUserPrompt3({
|
|
|
1726
1895
|
attributes: { format: "seconds" }
|
|
1727
1896
|
}
|
|
1728
1897
|
];
|
|
1898
|
+
if (languageName) {
|
|
1899
|
+
contextSections.push(createLanguageSection(languageName));
|
|
1900
|
+
}
|
|
1729
1901
|
const dynamicChapterGuidelines = dedent3`
|
|
1730
1902
|
- Create at least ${minChaptersPerHour} and at most ${maxChaptersPerHour} chapters per hour of content
|
|
1731
1903
|
- Use start times in seconds (not HH:MM:SS)
|
|
@@ -1745,7 +1917,8 @@ async function generateChapters(assetId, languageCode, options = {}) {
|
|
|
1745
1917
|
promptOverrides,
|
|
1746
1918
|
minChaptersPerHour,
|
|
1747
1919
|
maxChaptersPerHour,
|
|
1748
|
-
credentials
|
|
1920
|
+
credentials,
|
|
1921
|
+
outputLanguageCode
|
|
1749
1922
|
} = options;
|
|
1750
1923
|
const modelConfig = resolveLanguageModelConfig({
|
|
1751
1924
|
...options,
|
|
@@ -1789,11 +1962,14 @@ async function generateChapters(assetId, languageCode, options = {}) {
|
|
|
1789
1962
|
const contentLabel = isAudioOnly ? "transcript" : "caption track";
|
|
1790
1963
|
throw new Error(`No usable content found in ${contentLabel}`);
|
|
1791
1964
|
}
|
|
1965
|
+
const resolvedLanguageCode = outputLanguageCode && outputLanguageCode !== "auto" ? outputLanguageCode : transcriptResult.track?.language_code ?? languageCode;
|
|
1966
|
+
const languageName = resolvedLanguageCode ? getLanguageName(resolvedLanguageCode) : void 0;
|
|
1792
1967
|
const userPrompt = buildUserPrompt3({
|
|
1793
1968
|
timestampedTranscript,
|
|
1794
1969
|
promptOverrides,
|
|
1795
1970
|
minChaptersPerHour,
|
|
1796
|
-
maxChaptersPerHour
|
|
1971
|
+
maxChaptersPerHour,
|
|
1972
|
+
languageName
|
|
1797
1973
|
});
|
|
1798
1974
|
let chaptersData = null;
|
|
1799
1975
|
try {
|
|
@@ -2752,6 +2928,7 @@ var SYSTEM_PROMPT3 = dedent4`
|
|
|
2752
2928
|
- Do not fabricate details or make unsupported assumptions
|
|
2753
2929
|
- Return structured data matching the requested schema
|
|
2754
2930
|
- Output only the JSON object; no markdown or extra text
|
|
2931
|
+
- When a <language> section is provided, all output text MUST be written in that language
|
|
2755
2932
|
</constraints>
|
|
2756
2933
|
|
|
2757
2934
|
<tone_guidance>
|
|
@@ -2806,6 +2983,7 @@ var AUDIO_ONLY_SYSTEM_PROMPT = dedent4`
|
|
|
2806
2983
|
- Return structured data matching the requested schema
|
|
2807
2984
|
- Focus entirely on audio/spoken content - there are no visual elements
|
|
2808
2985
|
- Output only the JSON object; no markdown or extra text
|
|
2986
|
+
- When a <language> section is provided, all output text MUST be written in that language
|
|
2809
2987
|
</constraints>
|
|
2810
2988
|
|
|
2811
2989
|
<tone_guidance>
|
|
@@ -2836,9 +3014,13 @@ function buildUserPrompt4({
|
|
|
2836
3014
|
isAudioOnly = false,
|
|
2837
3015
|
titleLength,
|
|
2838
3016
|
descriptionLength,
|
|
2839
|
-
tagCount
|
|
3017
|
+
tagCount,
|
|
3018
|
+
languageName
|
|
2840
3019
|
}) {
|
|
2841
3020
|
const contextSections = [createToneSection(TONE_INSTRUCTIONS[tone])];
|
|
3021
|
+
if (languageName) {
|
|
3022
|
+
contextSections.push(createLanguageSection(languageName));
|
|
3023
|
+
}
|
|
2842
3024
|
if (transcriptText) {
|
|
2843
3025
|
const format = isCleanTranscript ? "plain text" : "WebVTT";
|
|
2844
3026
|
contextSections.push(createTranscriptSection(transcriptText, format));
|
|
@@ -2951,7 +3133,8 @@ async function getSummaryAndTags(assetId, options) {
|
|
|
2951
3133
|
credentials,
|
|
2952
3134
|
titleLength,
|
|
2953
3135
|
descriptionLength,
|
|
2954
|
-
tagCount
|
|
3136
|
+
tagCount,
|
|
3137
|
+
outputLanguageCode
|
|
2955
3138
|
} = options ?? {};
|
|
2956
3139
|
if (!VALID_TONES.includes(tone)) {
|
|
2957
3140
|
throw new Error(
|
|
@@ -2978,12 +3161,15 @@ async function getSummaryAndTags(assetId, options) {
|
|
|
2978
3161
|
"Signed playback ID requires signing credentials. Set MUX_SIGNING_KEY and MUX_PRIVATE_KEY environment variables."
|
|
2979
3162
|
);
|
|
2980
3163
|
}
|
|
2981
|
-
const
|
|
3164
|
+
const transcriptResult = includeTranscript ? await fetchTranscriptForAsset(assetData, playbackId, {
|
|
2982
3165
|
cleanTranscript,
|
|
2983
3166
|
shouldSign: policy === "signed",
|
|
2984
3167
|
credentials: workflowCredentials,
|
|
2985
3168
|
required: isAudioOnly
|
|
2986
|
-
})
|
|
3169
|
+
}) : void 0;
|
|
3170
|
+
const transcriptText = transcriptResult?.transcriptText ?? "";
|
|
3171
|
+
const resolvedLanguageCode = outputLanguageCode && outputLanguageCode !== "auto" ? outputLanguageCode : transcriptResult?.track?.language_code ?? getReadyTextTracks(assetData)[0]?.language_code;
|
|
3172
|
+
const languageName = resolvedLanguageCode ? getLanguageName(resolvedLanguageCode) : void 0;
|
|
2987
3173
|
const userPrompt = buildUserPrompt4({
|
|
2988
3174
|
tone,
|
|
2989
3175
|
transcriptText,
|
|
@@ -2992,7 +3178,8 @@ async function getSummaryAndTags(assetId, options) {
|
|
|
2992
3178
|
isAudioOnly,
|
|
2993
3179
|
titleLength,
|
|
2994
3180
|
descriptionLength,
|
|
2995
|
-
tagCount
|
|
3181
|
+
tagCount,
|
|
3182
|
+
languageName
|
|
2996
3183
|
});
|
|
2997
3184
|
let analysisResponse;
|
|
2998
3185
|
let imageUrl;
|
|
@@ -3062,164 +3249,6 @@ async function getSummaryAndTags(assetId, options) {
|
|
|
3062
3249
|
};
|
|
3063
3250
|
}
|
|
3064
3251
|
|
|
3065
|
-
// src/lib/language-codes.ts
|
|
3066
|
-
var ISO639_1_TO_3 = {
|
|
3067
|
-
// Major world languages
|
|
3068
|
-
en: "eng",
|
|
3069
|
-
// English
|
|
3070
|
-
es: "spa",
|
|
3071
|
-
// Spanish
|
|
3072
|
-
fr: "fra",
|
|
3073
|
-
// French
|
|
3074
|
-
de: "deu",
|
|
3075
|
-
// German
|
|
3076
|
-
it: "ita",
|
|
3077
|
-
// Italian
|
|
3078
|
-
pt: "por",
|
|
3079
|
-
// Portuguese
|
|
3080
|
-
ru: "rus",
|
|
3081
|
-
// Russian
|
|
3082
|
-
zh: "zho",
|
|
3083
|
-
// Chinese
|
|
3084
|
-
ja: "jpn",
|
|
3085
|
-
// Japanese
|
|
3086
|
-
ko: "kor",
|
|
3087
|
-
// Korean
|
|
3088
|
-
ar: "ara",
|
|
3089
|
-
// Arabic
|
|
3090
|
-
hi: "hin",
|
|
3091
|
-
// Hindi
|
|
3092
|
-
// European languages
|
|
3093
|
-
nl: "nld",
|
|
3094
|
-
// Dutch
|
|
3095
|
-
pl: "pol",
|
|
3096
|
-
// Polish
|
|
3097
|
-
sv: "swe",
|
|
3098
|
-
// Swedish
|
|
3099
|
-
da: "dan",
|
|
3100
|
-
// Danish
|
|
3101
|
-
no: "nor",
|
|
3102
|
-
// Norwegian
|
|
3103
|
-
fi: "fin",
|
|
3104
|
-
// Finnish
|
|
3105
|
-
el: "ell",
|
|
3106
|
-
// Greek
|
|
3107
|
-
cs: "ces",
|
|
3108
|
-
// Czech
|
|
3109
|
-
hu: "hun",
|
|
3110
|
-
// Hungarian
|
|
3111
|
-
ro: "ron",
|
|
3112
|
-
// Romanian
|
|
3113
|
-
bg: "bul",
|
|
3114
|
-
// Bulgarian
|
|
3115
|
-
hr: "hrv",
|
|
3116
|
-
// Croatian
|
|
3117
|
-
sk: "slk",
|
|
3118
|
-
// Slovak
|
|
3119
|
-
sl: "slv",
|
|
3120
|
-
// Slovenian
|
|
3121
|
-
uk: "ukr",
|
|
3122
|
-
// Ukrainian
|
|
3123
|
-
tr: "tur",
|
|
3124
|
-
// Turkish
|
|
3125
|
-
// Asian languages
|
|
3126
|
-
th: "tha",
|
|
3127
|
-
// Thai
|
|
3128
|
-
vi: "vie",
|
|
3129
|
-
// Vietnamese
|
|
3130
|
-
id: "ind",
|
|
3131
|
-
// Indonesian
|
|
3132
|
-
ms: "msa",
|
|
3133
|
-
// Malay
|
|
3134
|
-
tl: "tgl",
|
|
3135
|
-
// Tagalog/Filipino
|
|
3136
|
-
// Other languages
|
|
3137
|
-
he: "heb",
|
|
3138
|
-
// Hebrew
|
|
3139
|
-
fa: "fas",
|
|
3140
|
-
// Persian/Farsi
|
|
3141
|
-
bn: "ben",
|
|
3142
|
-
// Bengali
|
|
3143
|
-
ta: "tam",
|
|
3144
|
-
// Tamil
|
|
3145
|
-
te: "tel",
|
|
3146
|
-
// Telugu
|
|
3147
|
-
mr: "mar",
|
|
3148
|
-
// Marathi
|
|
3149
|
-
gu: "guj",
|
|
3150
|
-
// Gujarati
|
|
3151
|
-
kn: "kan",
|
|
3152
|
-
// Kannada
|
|
3153
|
-
ml: "mal",
|
|
3154
|
-
// Malayalam
|
|
3155
|
-
pa: "pan",
|
|
3156
|
-
// Punjabi
|
|
3157
|
-
ur: "urd",
|
|
3158
|
-
// Urdu
|
|
3159
|
-
sw: "swa",
|
|
3160
|
-
// Swahili
|
|
3161
|
-
af: "afr",
|
|
3162
|
-
// Afrikaans
|
|
3163
|
-
ca: "cat",
|
|
3164
|
-
// Catalan
|
|
3165
|
-
eu: "eus",
|
|
3166
|
-
// Basque
|
|
3167
|
-
gl: "glg",
|
|
3168
|
-
// Galician
|
|
3169
|
-
is: "isl",
|
|
3170
|
-
// Icelandic
|
|
3171
|
-
et: "est",
|
|
3172
|
-
// Estonian
|
|
3173
|
-
lv: "lav",
|
|
3174
|
-
// Latvian
|
|
3175
|
-
lt: "lit"
|
|
3176
|
-
// Lithuanian
|
|
3177
|
-
};
|
|
3178
|
-
var ISO639_3_TO_1 = Object.fromEntries(
|
|
3179
|
-
Object.entries(ISO639_1_TO_3).map(([iso1, iso3]) => [iso3, iso1])
|
|
3180
|
-
);
|
|
3181
|
-
function toISO639_3(code) {
|
|
3182
|
-
const normalized = code.toLowerCase().trim();
|
|
3183
|
-
if (normalized.length === 3) {
|
|
3184
|
-
return normalized;
|
|
3185
|
-
}
|
|
3186
|
-
return ISO639_1_TO_3[normalized] ?? normalized;
|
|
3187
|
-
}
|
|
3188
|
-
function toISO639_1(code) {
|
|
3189
|
-
const normalized = code.toLowerCase().trim();
|
|
3190
|
-
if (normalized.length === 2) {
|
|
3191
|
-
return normalized;
|
|
3192
|
-
}
|
|
3193
|
-
return ISO639_3_TO_1[normalized] ?? normalized;
|
|
3194
|
-
}
|
|
3195
|
-
function getLanguageCodePair(code) {
|
|
3196
|
-
const normalized = code.toLowerCase().trim();
|
|
3197
|
-
if (normalized.length === 2) {
|
|
3198
|
-
return {
|
|
3199
|
-
iso639_1: normalized,
|
|
3200
|
-
iso639_3: toISO639_3(normalized)
|
|
3201
|
-
};
|
|
3202
|
-
} else if (normalized.length === 3) {
|
|
3203
|
-
return {
|
|
3204
|
-
iso639_1: toISO639_1(normalized),
|
|
3205
|
-
iso639_3: normalized
|
|
3206
|
-
};
|
|
3207
|
-
}
|
|
3208
|
-
return {
|
|
3209
|
-
iso639_1: normalized,
|
|
3210
|
-
iso639_3: normalized
|
|
3211
|
-
};
|
|
3212
|
-
}
|
|
3213
|
-
function getLanguageName(code) {
|
|
3214
|
-
const iso639_1 = toISO639_1(code);
|
|
3215
|
-
try {
|
|
3216
|
-
const displayNames = new Intl.DisplayNames(["en"], { type: "language" });
|
|
3217
|
-
return displayNames.of(iso639_1) ?? code.toUpperCase();
|
|
3218
|
-
} catch {
|
|
3219
|
-
return code.toUpperCase();
|
|
3220
|
-
}
|
|
3221
|
-
}
|
|
3222
|
-
|
|
3223
3252
|
// src/lib/s3-sigv4.ts
|
|
3224
3253
|
var AWS4_ALGORITHM = "AWS4-HMAC-SHA256";
|
|
3225
3254
|
var AWS4_REQUEST_TERMINATOR = "aws4_request";
|