@ssml-builder-js/ssml-editor-elements 2.4.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.js ADDED
@@ -0,0 +1,3822 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ SsmlEditorElement: () => SsmlEditorElement,
34
+ defineSsmlEditorElement: () => defineSsmlEditorElement
35
+ });
36
+ module.exports = __toCommonJS(index_exports);
37
+
38
+ // src/SsmlEditorElement.ts
39
+ var import_ssml_core2 = require("@ssml-builder-js/ssml-core");
40
+
41
+ // ../ssml-editor-react/src/clearSsmlDocument.ts
42
+ function getDocumentChildren(document2) {
43
+ return document2.children ?? (document2.content === void 0 ? [] : [document2.content]);
44
+ }
45
+ function appendNode(nodes, node) {
46
+ if (typeof node === "string") {
47
+ const lastNode = nodes[nodes.length - 1];
48
+ if (typeof lastNode === "string") {
49
+ nodes[nodes.length - 1] = lastNode + node;
50
+ } else if (node !== "") {
51
+ nodes.push(node);
52
+ }
53
+ return;
54
+ }
55
+ nodes.push(node);
56
+ }
57
+ function clearNodes(nodes) {
58
+ const clearedNodes = [];
59
+ for (const node of nodes) {
60
+ if (typeof node === "string") {
61
+ appendNode(clearedNodes, node);
62
+ continue;
63
+ }
64
+ if (node.type === "text") {
65
+ appendNode(clearedNodes, node.value);
66
+ continue;
67
+ }
68
+ const children = clearNodes(node.children ?? []);
69
+ if (node.type === "voice") {
70
+ appendNode(clearedNodes, { ...node, children });
71
+ continue;
72
+ }
73
+ for (const child of children) {
74
+ appendNode(clearedNodes, child);
75
+ }
76
+ }
77
+ return clearedNodes;
78
+ }
79
+ function clearSsmlDocument(document2) {
80
+ const nextDocument = {
81
+ ...document2,
82
+ children: clearNodes(getDocumentChildren(document2))
83
+ };
84
+ if (nextDocument.content !== void 0) {
85
+ delete nextDocument.content;
86
+ }
87
+ return nextDocument;
88
+ }
89
+
90
+ // ../ssml-editor-react/src/editableSsml.ts
91
+ var import_ssml_core = require("@ssml-builder-js/ssml-core");
92
+
93
+ // ../ssml-editor-react/src/formatXml.ts
94
+ var INDENT = " ";
95
+ var FRAGMENT_ROOT = "ssml-builder-fragment";
96
+ var XML_ENTITY_NAMES = /* @__PURE__ */ new Set(["amp", "apos", "gt", "lt", "quot"]);
97
+ var INTRINSICALLY_EMPTY_ELEMENTS = /* @__PURE__ */ new Set([
98
+ "break",
99
+ "bookmark",
100
+ "lexicon",
101
+ "mark",
102
+ "mstts:silence",
103
+ "mstts:viseme",
104
+ "silence",
105
+ "viseme"
106
+ ]);
107
+ function isXmlNameStart(value) {
108
+ return value !== void 0 && /[A-Za-z_]/.test(value);
109
+ }
110
+ function isXmlNameCharacter(value) {
111
+ return value !== void 0 && /[A-Za-z0-9_.:-]/.test(value);
112
+ }
113
+ function isXmlWhitespace(value) {
114
+ return value === " " || value === " " || value === "\r" || value === "\n";
115
+ }
116
+ function fail(message) {
117
+ throw new Error(message);
118
+ }
119
+ function skipWhitespace(source, index) {
120
+ while (isXmlWhitespace(source[index])) {
121
+ index += 1;
122
+ }
123
+ return index;
124
+ }
125
+ function readName(source, start, end) {
126
+ if (!isXmlNameStart(source[start])) {
127
+ fail("Invalid XML name");
128
+ }
129
+ let index = start + 1;
130
+ while (index < end && isXmlNameCharacter(source[index])) {
131
+ index += 1;
132
+ }
133
+ return { name: source.slice(start, index), index };
134
+ }
135
+ function validateCharacterReference(entity) {
136
+ const isHexadecimal = entity.startsWith("#x") || entity.startsWith("#X");
137
+ const isDecimal = entity.startsWith("#");
138
+ if (!isHexadecimal && !isDecimal) {
139
+ if (!XML_ENTITY_NAMES.has(entity)) {
140
+ fail(`Unknown XML entity: &${entity};`);
141
+ }
142
+ return;
143
+ }
144
+ const digits = entity.slice(isHexadecimal ? 2 : 1);
145
+ const validDigits = isHexadecimal ? /^[0-9A-Fa-f]+$/.test(digits) : /^[0-9]+$/.test(digits);
146
+ const codePoint = Number.parseInt(digits, isHexadecimal ? 16 : 10);
147
+ if (!validDigits || !Number.isInteger(codePoint) || codePoint < 0 || codePoint > 1114111 || codePoint >= 55296 && codePoint <= 57343 || codePoint < 32 && ![9, 10, 13].includes(codePoint)) {
148
+ fail(`Invalid XML character reference: &${entity};`);
149
+ }
150
+ }
151
+ function validateEntityReferences(value) {
152
+ let index = 0;
153
+ while (true) {
154
+ const ampersand = value.indexOf("&", index);
155
+ if (ampersand === -1) {
156
+ return;
157
+ }
158
+ const semicolon = value.indexOf(";", ampersand + 1);
159
+ if (semicolon === -1) {
160
+ fail("Unterminated XML entity reference");
161
+ }
162
+ validateCharacterReference(value.slice(ampersand + 1, semicolon));
163
+ index = semicolon + 1;
164
+ }
165
+ }
166
+ function findTagEnd(source, start, hasInternalSubset = false) {
167
+ let quote;
168
+ let subsetDepth = 0;
169
+ for (let index = start + 1; index < source.length; index += 1) {
170
+ const character = source[index];
171
+ if (quote !== void 0) {
172
+ if (character === quote) {
173
+ quote = void 0;
174
+ }
175
+ continue;
176
+ }
177
+ if (character === '"' || character === "'") {
178
+ quote = character;
179
+ continue;
180
+ }
181
+ if (hasInternalSubset) {
182
+ if (character === "[") {
183
+ subsetDepth += 1;
184
+ continue;
185
+ }
186
+ if (character === "]" && subsetDepth > 0) {
187
+ subsetDepth -= 1;
188
+ continue;
189
+ }
190
+ }
191
+ if (character === ">" && subsetDepth === 0) {
192
+ return index;
193
+ }
194
+ }
195
+ fail("Unclosed XML markup");
196
+ }
197
+ function parseStartTag(source, start, end) {
198
+ const nameResult = readName(source, start + 1, end);
199
+ let index = nameResult.index;
200
+ let hasAttribute = false;
201
+ const attributeNames = /* @__PURE__ */ new Set();
202
+ while (index < end) {
203
+ const beforeWhitespace = index;
204
+ index = skipWhitespace(source, index);
205
+ if (index === end) {
206
+ break;
207
+ }
208
+ if (source[index] === "/") {
209
+ if (index + 1 !== end) {
210
+ fail("Invalid XML self-closing tag");
211
+ }
212
+ return { name: nameResult.name, selfClosing: true };
213
+ }
214
+ if (hasAttribute && beforeWhitespace === index) {
215
+ fail("XML attributes must be separated by whitespace");
216
+ }
217
+ const attribute = readName(source, index, end);
218
+ index = skipWhitespace(source, attribute.index);
219
+ if (source[index] !== "=") {
220
+ fail(`XML attribute ${attribute.name} must have a value`);
221
+ }
222
+ index = skipWhitespace(source, index + 1);
223
+ const quote = source[index];
224
+ if (quote !== '"' && quote !== "'") {
225
+ fail(`XML attribute ${attribute.name} must use a quoted value`);
226
+ }
227
+ index += 1;
228
+ const valueStart = index;
229
+ while (index < end && source[index] !== quote) {
230
+ if (source[index] === "<") {
231
+ fail(`Invalid "<" in XML attribute ${attribute.name}`);
232
+ }
233
+ index += 1;
234
+ }
235
+ if (index === end) {
236
+ fail(`Unclosed XML attribute ${attribute.name}`);
237
+ }
238
+ if (attributeNames.has(attribute.name)) {
239
+ fail(`Duplicate XML attribute: ${attribute.name}`);
240
+ }
241
+ attributeNames.add(attribute.name);
242
+ validateEntityReferences(source.slice(valueStart, index));
243
+ index += 1;
244
+ hasAttribute = true;
245
+ }
246
+ return { name: nameResult.name, selfClosing: false };
247
+ }
248
+ function parseClosingTag(source, start, end) {
249
+ const nameResult = readName(source, start + 2, end);
250
+ if (skipWhitespace(source, nameResult.index) !== end) {
251
+ fail("Invalid XML closing tag");
252
+ }
253
+ return nameResult.name;
254
+ }
255
+ function parseProcessingInstruction(source, start, end) {
256
+ readName(source, start + 2, end);
257
+ }
258
+ function parseDeclaration(source, start, end) {
259
+ readName(source, start + 2, end);
260
+ }
261
+ function appendNode2(nodes, node) {
262
+ const previous = nodes[nodes.length - 1];
263
+ if (node.kind === "text" && previous?.kind === "text") {
264
+ previous.value += node.value;
265
+ return;
266
+ }
267
+ nodes.push(node);
268
+ }
269
+ function currentElement(stack) {
270
+ return stack[stack.length - 1];
271
+ }
272
+ function parseXml(source) {
273
+ const children = [];
274
+ const stack = [];
275
+ let root;
276
+ let index = 0;
277
+ while (index < source.length) {
278
+ if (source[index] !== "<") {
279
+ const textStart = index;
280
+ while (index < source.length && source[index] !== "<") {
281
+ index += 1;
282
+ }
283
+ const value = source.slice(textStart, index);
284
+ if (value.includes("]]>")) {
285
+ fail("CDATA termination is not valid in ordinary XML text");
286
+ }
287
+ validateEntityReferences(value);
288
+ if (stack.length === 0 && value.trim() !== "") {
289
+ fail("Unexpected text outside the root XML element");
290
+ }
291
+ appendNode2(currentElement(stack)?.children ?? children, { kind: "text", value });
292
+ continue;
293
+ }
294
+ if (source.startsWith("<!--", index)) {
295
+ const end2 = source.indexOf("-->", index + 4);
296
+ if (end2 === -1) {
297
+ fail("Unclosed XML comment");
298
+ }
299
+ const content = source.slice(index + 4, end2);
300
+ if (content.includes("--") || content.endsWith("-")) {
301
+ fail("Invalid XML comment");
302
+ }
303
+ appendNode2(currentElement(stack)?.children ?? children, {
304
+ kind: "comment",
305
+ raw: source.slice(index, end2 + 3)
306
+ });
307
+ index = end2 + 3;
308
+ continue;
309
+ }
310
+ if (source.startsWith("<![CDATA[", index)) {
311
+ const end2 = source.indexOf("]]>", index + "<![CDATA[".length);
312
+ if (end2 === -1) {
313
+ fail("Unclosed XML CDATA section");
314
+ }
315
+ if (stack.length === 0) {
316
+ fail("CDATA is not allowed outside the root XML element");
317
+ }
318
+ appendNode2(currentElement(stack)?.children ?? children, {
319
+ kind: "cdata",
320
+ raw: source.slice(index, end2 + 3)
321
+ });
322
+ index = end2 + 3;
323
+ continue;
324
+ }
325
+ if (source.startsWith("<?", index)) {
326
+ const end2 = source.indexOf("?>", index + 2);
327
+ if (end2 === -1) {
328
+ fail("Unclosed XML processing instruction");
329
+ }
330
+ parseProcessingInstruction(source, index, end2);
331
+ appendNode2(currentElement(stack)?.children ?? children, {
332
+ kind: "processing-instruction",
333
+ raw: source.slice(index, end2 + 2)
334
+ });
335
+ index = end2 + 2;
336
+ continue;
337
+ }
338
+ if (source.startsWith("</", index)) {
339
+ const end2 = findTagEnd(source, index);
340
+ const name2 = parseClosingTag(source, index, end2);
341
+ const element = currentElement(stack);
342
+ if (element === void 0 || element.name !== name2) {
343
+ fail(`Mismatched closing XML element: </${name2}>`);
344
+ }
345
+ element.close = source.slice(index, end2 + 1);
346
+ stack.pop();
347
+ index = end2 + 1;
348
+ continue;
349
+ }
350
+ if (source.startsWith("<!", index)) {
351
+ const end2 = findTagEnd(source, index, true);
352
+ parseDeclaration(source, index, end2);
353
+ appendNode2(currentElement(stack)?.children ?? children, {
354
+ kind: "declaration",
355
+ raw: source.slice(index, end2 + 1)
356
+ });
357
+ index = end2 + 1;
358
+ continue;
359
+ }
360
+ const end = findTagEnd(source, index);
361
+ const { name, selfClosing } = parseStartTag(source, index, end);
362
+ if (stack.length === 0) {
363
+ if (root !== void 0) {
364
+ fail("Multiple root XML elements are not allowed");
365
+ }
366
+ root = {
367
+ kind: "element",
368
+ name,
369
+ open: source.slice(index, end + 1),
370
+ selfClosing,
371
+ children: []
372
+ };
373
+ children.push(root);
374
+ } else {
375
+ const element = {
376
+ kind: "element",
377
+ name,
378
+ open: source.slice(index, end + 1),
379
+ selfClosing,
380
+ children: []
381
+ };
382
+ currentElement(stack)?.children.push(element);
383
+ if (!selfClosing) {
384
+ stack.push(element);
385
+ }
386
+ index = end + 1;
387
+ continue;
388
+ }
389
+ if (!selfClosing) {
390
+ stack.push(root);
391
+ }
392
+ index = end + 1;
393
+ }
394
+ if (stack.length > 0) {
395
+ fail(`Unclosed XML element: <${currentElement(stack)?.name}>`);
396
+ }
397
+ if (root === void 0) {
398
+ fail("XML input does not contain a root element");
399
+ }
400
+ return { children, root };
401
+ }
402
+ function indentation(depth) {
403
+ return INDENT.repeat(depth);
404
+ }
405
+ function renderInline(node) {
406
+ const content = node.children.map((child) => {
407
+ if (child.kind === "element") {
408
+ return renderInline(child);
409
+ }
410
+ return child.kind === "text" ? child.value : child.raw;
411
+ }).join("");
412
+ return `${node.open}${content}${node.close ?? ""}`;
413
+ }
414
+ function hasOnlyTextChildren(node) {
415
+ return node.children.every((child) => child.kind === "text");
416
+ }
417
+ function hasSignificantText(node) {
418
+ return node.children.some((child) => child.kind === "text" && child.value.trim() !== "");
419
+ }
420
+ function hasOnlyWhitespaceText(node) {
421
+ return node.children.every((child) => child.kind === "text" && child.value.trim() === "");
422
+ }
423
+ function toSelfClosingTag(open) {
424
+ return `${open.slice(0, -1).trimEnd()}/>`;
425
+ }
426
+ function formatElement(node, depth, isRoot) {
427
+ const prefix = indentation(depth);
428
+ if (node.selfClosing) {
429
+ return [`${prefix}${node.open}`];
430
+ }
431
+ if (node.close === void 0) {
432
+ fail(`Unclosed XML element: <${node.name}>`);
433
+ }
434
+ if (INTRINSICALLY_EMPTY_ELEMENTS.has(node.name) && hasOnlyWhitespaceText(node)) {
435
+ return [`${prefix}${toSelfClosingTag(node.open)}`];
436
+ }
437
+ if (isRoot && hasOnlyTextChildren(node)) {
438
+ const text = node.children.filter((child) => child.kind === "text").map((child) => child.value).join("");
439
+ const trimmedText = text.trim();
440
+ if (trimmedText === "") {
441
+ return [`${prefix}${node.open}`, `${prefix}${node.close}`];
442
+ }
443
+ if (text.includes("\n") || text.includes("\r") || text !== trimmedText) {
444
+ return [`${prefix}${renderInline(node)}`];
445
+ }
446
+ return [`${prefix}${node.open}`, `${indentation(depth + 1)}${trimmedText}`, `${prefix}${node.close}`];
447
+ }
448
+ if (hasSignificantText(node)) {
449
+ return [`${prefix}${renderInline(node)}`];
450
+ }
451
+ const lines = [`${prefix}${node.open}`];
452
+ for (const child of node.children) {
453
+ if (child.kind === "text") {
454
+ continue;
455
+ }
456
+ if (child.kind === "element") {
457
+ lines.push(...formatElement(child, depth + 1, false));
458
+ } else {
459
+ lines.push(`${indentation(depth + 1)}${child.raw}`);
460
+ }
461
+ }
462
+ lines.push(`${prefix}${node.close}`);
463
+ return lines;
464
+ }
465
+ function stripTrailingWhitespace(value) {
466
+ return value.replace(/[ \t]+$/gm, "");
467
+ }
468
+ function getTrailingLineBreaks(value) {
469
+ let start = value.length;
470
+ while (start > 0) {
471
+ if (value[start - 1] === "\n") {
472
+ start -= 1;
473
+ if (start > 0 && value[start - 1] === "\r") {
474
+ start -= 1;
475
+ }
476
+ continue;
477
+ }
478
+ if (value[start - 1] === "\r") {
479
+ start -= 1;
480
+ continue;
481
+ }
482
+ break;
483
+ }
484
+ return value.slice(start);
485
+ }
486
+ function stripTrailingLineBreaks(value) {
487
+ let end = value.length;
488
+ while (end > 0) {
489
+ if (value[end - 1] === "\n") {
490
+ end -= 1;
491
+ if (end > 0 && value[end - 1] === "\r") {
492
+ end -= 1;
493
+ }
494
+ continue;
495
+ }
496
+ if (value[end - 1] === "\r") {
497
+ end -= 1;
498
+ continue;
499
+ }
500
+ break;
501
+ }
502
+ return value.slice(0, end);
503
+ }
504
+ function preserveTrailingLineBreak(formatted, trailingLineBreaks) {
505
+ if (trailingLineBreaks === "") {
506
+ return formatted;
507
+ }
508
+ return `${stripTrailingLineBreaks(formatted)}${trailingLineBreaks}`;
509
+ }
510
+ function renderDocument(document2) {
511
+ const lines = [];
512
+ for (const child of document2.children) {
513
+ if (child.kind === "text") {
514
+ continue;
515
+ }
516
+ if (child.kind === "element") {
517
+ lines.push(...formatElement(child, 0, child === document2.root));
518
+ } else {
519
+ lines.push(child.raw);
520
+ }
521
+ }
522
+ return stripTrailingWhitespace(lines.join("\n")).trim();
523
+ }
524
+ function unwrapFormattedFragment(formatted) {
525
+ const opening = `<${FRAGMENT_ROOT}>`;
526
+ const closing = `</${FRAGMENT_ROOT}>`;
527
+ if (!formatted.startsWith(opening) || !formatted.endsWith(closing)) {
528
+ return void 0;
529
+ }
530
+ if (formatted === `${opening}${closing}`) {
531
+ return "";
532
+ }
533
+ const multilineOpening = `${opening}
534
+ `;
535
+ const multilineClosing = `
536
+ ${closing}`;
537
+ if (formatted.startsWith(multilineOpening) && formatted.endsWith(multilineClosing)) {
538
+ const content = formatted.slice(multilineOpening.length, -multilineClosing.length);
539
+ return content.split("\n").map((line) => line.startsWith(INDENT) ? line.slice(INDENT.length) : line).join("\n");
540
+ }
541
+ return formatted.slice(opening.length, -closing.length);
542
+ }
543
+ function formatXmlFragment(xml) {
544
+ const trailingLineBreaks = getTrailingLineBreaks(xml);
545
+ const source = xml.trim();
546
+ if (source === "") {
547
+ return "";
548
+ }
549
+ const wrapped = `<${FRAGMENT_ROOT}>${source}</${FRAGMENT_ROOT}>`;
550
+ let formatted;
551
+ try {
552
+ formatted = renderDocument(parseXml(wrapped));
553
+ } catch {
554
+ return xml;
555
+ }
556
+ return preserveTrailingLineBreak(unwrapFormattedFragment(formatted) ?? xml, trailingLineBreaks);
557
+ }
558
+
559
+ // ../ssml-editor-react/src/editableSsml.ts
560
+ function isSsmlElement(node) {
561
+ return typeof node !== "string" && node.type !== "text";
562
+ }
563
+ function isVoice(element) {
564
+ return element.type === "voice";
565
+ }
566
+ function isProsody(element) {
567
+ return element.type === "prosody";
568
+ }
569
+ function getSsmlElementName(element) {
570
+ return element.type === "custom" || element.type === "element" ? element.name : element.type;
571
+ }
572
+ function findEditableTagEnd(source, start) {
573
+ let quote;
574
+ for (let index = start + 1; index < source.length; index += 1) {
575
+ const character = source[index];
576
+ if (quote !== void 0) {
577
+ if (character === quote) {
578
+ quote = void 0;
579
+ }
580
+ continue;
581
+ }
582
+ if (character === '"' || character === "'") {
583
+ quote = character;
584
+ continue;
585
+ }
586
+ if (character === ">") {
587
+ return index;
588
+ }
589
+ }
590
+ return source.length;
591
+ }
592
+ function collectEditableStartTags(source) {
593
+ const tags = [];
594
+ let index = 0;
595
+ while (index < source.length) {
596
+ if (source[index] !== "<") {
597
+ index += 1;
598
+ continue;
599
+ }
600
+ if (source.startsWith("<!--", index)) {
601
+ const end2 = source.indexOf("-->", index + 4);
602
+ index = end2 === -1 ? source.length : end2 + 3;
603
+ continue;
604
+ }
605
+ if (source.startsWith("<![CDATA[", index)) {
606
+ const end2 = source.indexOf("]]>", index + 9);
607
+ index = end2 === -1 ? source.length : end2 + 3;
608
+ continue;
609
+ }
610
+ if (source.startsWith("<?", index)) {
611
+ const end2 = source.indexOf("?>", index + 2);
612
+ index = end2 === -1 ? source.length : end2 + 2;
613
+ continue;
614
+ }
615
+ if (source.startsWith("</", index) || source.startsWith("<!", index)) {
616
+ const end2 = findEditableTagEnd(source, index);
617
+ index = end2 === source.length ? source.length : end2 + 1;
618
+ continue;
619
+ }
620
+ const end = findEditableTagEnd(source, index);
621
+ if (end === source.length) {
622
+ break;
623
+ }
624
+ const raw = source.slice(index, end + 1);
625
+ const match = raw.match(/^<([A-Za-z_][A-Za-z0-9_.:-]*)/);
626
+ if (match) {
627
+ tags.push({ name: match[1], selfClosing: /\/\s*>$/.test(raw) });
628
+ }
629
+ index = end + 1;
630
+ }
631
+ return tags;
632
+ }
633
+ function preserveEmptyPairElements(nodes, startTags, startTagIndex) {
634
+ return nodes.map((node) => {
635
+ if (!isSsmlElement(node)) {
636
+ return node;
637
+ }
638
+ const elementName = getSsmlElementName(node);
639
+ const startTag = startTags[startTagIndex.value];
640
+ startTagIndex.value += 1;
641
+ if (node.children === void 0 || node.children.length === 0) {
642
+ return startTag?.name === elementName && !startTag.selfClosing && !INTRINSICALLY_EMPTY_ELEMENTS.has(elementName) ? { ...node, children: [""] } : node;
643
+ }
644
+ const children = preserveEmptyPairElements(node.children, startTags, startTagIndex);
645
+ if (children.every((child, index) => child === node.children?.[index])) {
646
+ return node;
647
+ }
648
+ return { ...node, children };
649
+ });
650
+ }
651
+ function getDocumentChildren2(document2) {
652
+ return document2.children ?? (document2.content === void 0 ? [] : [document2.content]);
653
+ }
654
+ function findFirstElementPath(nodes, predicate, ancestors = []) {
655
+ for (const node of nodes) {
656
+ if (!isSsmlElement(node)) {
657
+ continue;
658
+ }
659
+ const path = [...ancestors, node];
660
+ if (predicate(node)) {
661
+ return path;
662
+ }
663
+ const childPath = findFirstElementPath(node.children ?? [], predicate, path);
664
+ if (childPath) {
665
+ return childPath;
666
+ }
667
+ }
668
+ return void 0;
669
+ }
670
+ function updateFirstElement(nodes, predicate, update) {
671
+ let updated = false;
672
+ const nextNodes = nodes.map((node) => {
673
+ if (updated || !isSsmlElement(node)) {
674
+ return node;
675
+ }
676
+ if (predicate(node)) {
677
+ updated = true;
678
+ return update(node);
679
+ }
680
+ if (node.children) {
681
+ const result = updateFirstElement(node.children, predicate, update);
682
+ if (result.updated) {
683
+ updated = true;
684
+ return { ...node, children: result.nodes };
685
+ }
686
+ }
687
+ return node;
688
+ });
689
+ return { nodes: nextNodes, updated };
690
+ }
691
+ function withChildren(document2, children) {
692
+ const nextDocument = { ...document2, children };
693
+ if (nextDocument.content !== void 0) {
694
+ delete nextDocument.content;
695
+ }
696
+ return nextDocument;
697
+ }
698
+ function parseEditableText(value, lang) {
699
+ try {
700
+ const wrapper = (0, import_ssml_core.buildSsml)({
701
+ version: "1.0",
702
+ lang,
703
+ children: []
704
+ });
705
+ const openingTagEnd = wrapper.indexOf(">") + 1;
706
+ const children = (0, import_ssml_core.parseSsml)(`${wrapper.slice(0, openingTagEnd)}${value}</speak>`).children ?? [];
707
+ return children.some(isSsmlElement) ? preserveEmptyPairElements(children, collectEditableStartTags(value), { value: 0 }) : [value];
708
+ } catch {
709
+ return [value];
710
+ }
711
+ }
712
+ function serializeEditableText(nodes, lang) {
713
+ if (nodes.length === 1 && typeof nodes[0] === "string") {
714
+ return nodes[0];
715
+ }
716
+ const xml = (0, import_ssml_core.buildSsml)({
717
+ version: "1.0",
718
+ lang,
719
+ children: nodes
720
+ });
721
+ const contentStart = xml.indexOf(">") + 1;
722
+ return xml.slice(contentStart, -"</speak>".length);
723
+ }
724
+ function getEditableRegion(document2) {
725
+ const children = getDocumentChildren2(document2);
726
+ const path = findFirstElementPath(children, isProsody) ?? findFirstElementPath(children, isVoice);
727
+ const element = path ? path[path.length - 1] : void 0;
728
+ const voice = path ? [...path].reverse().find(isVoice) : void 0;
729
+ return {
730
+ children: element?.children ?? children,
731
+ ...voice ? { voiceName: voice.name } : {}
732
+ };
733
+ }
734
+ function getEditableText(document2) {
735
+ return serializeEditableText(getEditableRegion(document2).children, document2.lang);
736
+ }
737
+ function updateEditableText(document2, value) {
738
+ const nextChildren = parseEditableText(value, document2.lang);
739
+ const editableChildren = nextChildren.length > 0 ? nextChildren : [value];
740
+ const children = getDocumentChildren2(document2);
741
+ const prosodyResult = updateFirstElement(children, isProsody, (prosody) => ({
742
+ ...prosody,
743
+ children: editableChildren
744
+ }));
745
+ if (prosodyResult.updated) {
746
+ return withChildren(document2, prosodyResult.nodes);
747
+ }
748
+ const voiceResult = updateFirstElement(children, isVoice, (voice) => ({
749
+ ...voice,
750
+ children: editableChildren
751
+ }));
752
+ if (voiceResult.updated) {
753
+ return withChildren(document2, voiceResult.nodes);
754
+ }
755
+ return withChildren(document2, editableChildren);
756
+ }
757
+
758
+ // ../ssml-editor-react/src/constants/ssmlPresets.ts
759
+ var ssmlPresets_exports = {};
760
+ __export(ssmlPresets_exports, {
761
+ BREAK_STRENGTH_PRESETS: () => BREAK_STRENGTH_PRESETS,
762
+ BREAK_TIME_DESCRIPTIONS: () => BREAK_TIME_DESCRIPTIONS,
763
+ BREAK_TIME_PRESETS: () => BREAK_TIME_PRESETS,
764
+ EMPHASIS_LEVEL_DESCRIPTIONS: () => EMPHASIS_LEVEL_DESCRIPTIONS,
765
+ EMPHASIS_LEVEL_PRESETS: () => EMPHASIS_LEVEL_PRESETS,
766
+ EXPRESS_AS_ROLE_PRESETS: () => EXPRESS_AS_ROLE_PRESETS,
767
+ EXPRESS_AS_STYLE_CATEGORIES: () => EXPRESS_AS_STYLE_CATEGORIES,
768
+ EXPRESS_AS_STYLE_DESCRIPTIONS: () => EXPRESS_AS_STYLE_DESCRIPTIONS,
769
+ EXPRESS_AS_STYLE_PRESETS: () => EXPRESS_AS_STYLE_PRESETS,
770
+ LANGUAGE_DESCRIPTIONS: () => LANGUAGE_DESCRIPTIONS,
771
+ LANGUAGE_PRESETS: () => LANGUAGE_PRESETS,
772
+ PHONEME_ALPHABET_PRESETS: () => PHONEME_ALPHABET_PRESETS,
773
+ PROSODY_PITCH_DESCRIPTIONS: () => PROSODY_PITCH_DESCRIPTIONS,
774
+ PROSODY_PITCH_PRESETS: () => PROSODY_PITCH_PRESETS,
775
+ PROSODY_RATE_DESCRIPTIONS: () => PROSODY_RATE_DESCRIPTIONS,
776
+ PROSODY_RATE_PRESETS: () => PROSODY_RATE_PRESETS,
777
+ PROSODY_RATE_VALUES: () => PROSODY_RATE_VALUES,
778
+ PROSODY_VOLUME_DESCRIPTIONS: () => PROSODY_VOLUME_DESCRIPTIONS,
779
+ PROSODY_VOLUME_PRESETS: () => PROSODY_VOLUME_PRESETS,
780
+ SAY_AS_DESCRIPTIONS: () => SAY_AS_DESCRIPTIONS,
781
+ SAY_AS_PRESETS: () => SAY_AS_PRESETS,
782
+ SILENCE_TYPE_PRESETS: () => SILENCE_TYPE_PRESETS,
783
+ SILENCE_VALUE_DESCRIPTIONS: () => SILENCE_VALUE_DESCRIPTIONS,
784
+ SILENCE_VALUE_PRESETS: () => SILENCE_VALUE_PRESETS,
785
+ SSML_ATTRIBUTE_PRESETS: () => SSML_ATTRIBUTE_PRESETS,
786
+ SSML_PRESETS: () => SSML_PRESETS,
787
+ SSML_PRESET_EXAMPLES: () => SSML_PRESET_EXAMPLES,
788
+ VISEME_TYPE_PRESETS: () => VISEME_TYPE_PRESETS,
789
+ VOICE_STYLE_MAP: () => VOICE_STYLE_MAP,
790
+ getExpressAsStyleCategory: () => getExpressAsStyleCategory,
791
+ resolveExpressAsStyles: () => resolveExpressAsStyles
792
+ });
793
+ var SSML_PRESETS = [
794
+ {
795
+ id: "basic",
796
+ label: "Basic speech",
797
+ ssml: '<speak version="1.0" xml:lang="en-US">Hello, world!</speak>',
798
+ description: "A minimal SSML document."
799
+ },
800
+ {
801
+ id: "voice",
802
+ label: "Voice selection",
803
+ ssml: '<speak version="1.0" xml:lang="en-US"><voice name="en-US-JennyNeural">Hello, world!</voice></speak>',
804
+ description: "Speaks text with a selected voice."
805
+ },
806
+ {
807
+ id: "prosody",
808
+ label: "Prosody",
809
+ ssml: '<speak version="1.0" xml:lang="en-US"><prosody rate="fast" pitch="+2st">Hello, world!</prosody></speak>',
810
+ description: "Adjusts the speech rate and pitch."
811
+ }
812
+ ];
813
+ var BREAK_TIME_PRESETS = ["500ms", "1s", "2s", "3s"];
814
+ var BREAK_STRENGTH_PRESETS = ["none", "x-weak", "weak", "medium", "strong", "x-strong"];
815
+ var PROSODY_RATE_PRESETS = ["x-slow", "slow", "medium", "fast", "x-fast"];
816
+ var PROSODY_RATE_VALUES = [...PROSODY_RATE_PRESETS, "percentage"];
817
+ var PROSODY_PITCH_PRESETS = ["+2st", "-2st", "0st", "+4st", "-4st", "+8st", "-8st", "+12st", "-12st"];
818
+ var PROSODY_VOLUME_PRESETS = ["silent", "x-soft", "soft", "medium", "loud", "x-loud"];
819
+ var EXPRESS_AS_STYLE_PRESETS = [
820
+ "cheerful",
821
+ "friendly",
822
+ "calm",
823
+ "sad",
824
+ "angry",
825
+ "excited",
826
+ "serious",
827
+ "assistant",
828
+ "chat",
829
+ "customerservice",
830
+ "hopeful",
831
+ "newscast",
832
+ "shouting",
833
+ "terrified",
834
+ "unfriendly",
835
+ "whispering",
836
+ "empathetic",
837
+ "relieved",
838
+ "fearful",
839
+ "depressed",
840
+ "disgruntled",
841
+ "embarrassed",
842
+ "narration-relaxed",
843
+ "poetry-reading",
844
+ "sports_commentary",
845
+ "sports_commentary_excited",
846
+ "story"
847
+ ];
848
+ var EXPRESS_AS_STYLE_CATEGORIES = {
849
+ emotions: [
850
+ "cheerful",
851
+ "sad",
852
+ "angry",
853
+ "calm",
854
+ "fearful",
855
+ "depressed",
856
+ "disgruntled",
857
+ "embarrassed",
858
+ "empathetic",
859
+ "envious",
860
+ "excited",
861
+ "friendly",
862
+ "gentle",
863
+ "hopeful",
864
+ "relieved",
865
+ "serious",
866
+ "shouting",
867
+ "terrified",
868
+ "unfriendly",
869
+ "whispering"
870
+ ],
871
+ scenarios: ["chat", "customerservice", "assistant", "livecommercial", "poetry-reading", "story"],
872
+ media: [
873
+ "newscast",
874
+ "newscast-casual",
875
+ "newscast-formal",
876
+ "narration-professional",
877
+ "narration-relaxed",
878
+ "documentary-narration",
879
+ "advertisement_upbeat",
880
+ "sports_commentary",
881
+ "sports_commentary_excited"
882
+ ]
883
+ };
884
+ function getExpressAsStyleCategory(style) {
885
+ for (const [category, styles] of Object.entries(EXPRESS_AS_STYLE_CATEGORIES)) {
886
+ if (styles.includes(style)) {
887
+ return category;
888
+ }
889
+ }
890
+ return "other";
891
+ }
892
+ var VOICE_STYLE_MAP = {
893
+ "ja-JP-MayuNeural": ["calm", "cheerful", "sad"],
894
+ "ja-JP-KeitaNeural": ["chat"],
895
+ "ja-JP-NanamiNeural": ["chat", "customerservice", "cheerful", "whispering", "sad"],
896
+ "en-US-JennyMultilingualNeural": [
897
+ "cheerful",
898
+ "empathetic",
899
+ "excited",
900
+ "friendly",
901
+ "hopeful",
902
+ "sad",
903
+ "shouting",
904
+ "terrified",
905
+ "unfriendly",
906
+ "whispering"
907
+ ],
908
+ "en-US-AndrewNeural": ["empathetic", "relieved"],
909
+ "en-US-JennyNeural": [
910
+ "assistant",
911
+ "chat",
912
+ "customerservice",
913
+ "newscast",
914
+ "cheerful",
915
+ "empathetic",
916
+ "excited",
917
+ "friendly",
918
+ "hopeful",
919
+ "sad",
920
+ "shouting",
921
+ "terrified",
922
+ "unfriendly",
923
+ "whispering"
924
+ ],
925
+ "en-US-GuyNeural": [
926
+ "angry",
927
+ "cheerful",
928
+ "excited",
929
+ "friendly",
930
+ "hopeful",
931
+ "newscast",
932
+ "sad",
933
+ "shouting",
934
+ "terrified",
935
+ "unfriendly",
936
+ "whispering"
937
+ ],
938
+ "ko-KR-SunHiNeural": ["cheerful", "sad"],
939
+ "zh-CN-XiaoxiaoNeural": [
940
+ "assistant",
941
+ "chat",
942
+ "customerservice",
943
+ "newscast",
944
+ "cheerful",
945
+ "empathetic",
946
+ "excited",
947
+ "friendly",
948
+ "hopeful",
949
+ "sad",
950
+ "terrified",
951
+ "whispering",
952
+ "poetry-reading",
953
+ "sports_commentary",
954
+ "sports_commentary_excited",
955
+ "story"
956
+ ],
957
+ "zh-CN-YunxiNeural": [
958
+ "narration-relaxed",
959
+ "embarrassed",
960
+ "fearful",
961
+ "sad",
962
+ "disgruntled",
963
+ "serious",
964
+ "angry",
965
+ "depressed",
966
+ "chat",
967
+ "cheerful",
968
+ "assistant"
969
+ ],
970
+ "fr-FR-DeniseNeural": ["cheerful", "sad"],
971
+ "fr-FR-HenriNeural": ["cheerful", "sad"],
972
+ "pt-BR-FranciscaNeural": ["calm"],
973
+ "it-IT-ElsaNeural": ["cheerful", "sad"],
974
+ "de-DE-KatjaNeural": ["cheerful", "sad"],
975
+ "de-DE-ConradNeural": ["cheerful", "sad"],
976
+ "ru-RU-SvetlanaNeural": ["cheerful", "sad", "angry", "disgruntled", "embarrassed", "fearful"]
977
+ };
978
+ var VOICE_STYLE_MAP_BY_NORMALIZED_NAME = new Map(
979
+ Object.entries(VOICE_STYLE_MAP).map(([voiceName, styles]) => [voiceName.toLowerCase(), styles])
980
+ );
981
+ function resolveExpressAsStyles(voiceName, candidates = EXPRESS_AS_STYLE_PRESETS) {
982
+ const normalizedVoiceName = voiceName?.trim().toLowerCase();
983
+ if (!normalizedVoiceName) {
984
+ return candidates;
985
+ }
986
+ const supportedStyles = VOICE_STYLE_MAP_BY_NORMALIZED_NAME.get(normalizedVoiceName);
987
+ if (supportedStyles === void 0) {
988
+ return [];
989
+ }
990
+ const supportedStyleSet = new Set(supportedStyles);
991
+ return candidates.filter((style) => supportedStyleSet.has(style));
992
+ }
993
+ var EXPRESS_AS_ROLE_PRESETS = [
994
+ "Girl",
995
+ "Boy",
996
+ "YoungAdultFemale",
997
+ "YoungAdultMale",
998
+ "OlderAdultFemale",
999
+ "OlderAdultMale",
1000
+ "SeniorFemale",
1001
+ "SeniorMale"
1002
+ ];
1003
+ var EMPHASIS_LEVEL_PRESETS = ["strong", "moderate", "reduced", "none"];
1004
+ var SAY_AS_PRESETS = [
1005
+ "characters",
1006
+ "spell-out",
1007
+ "cardinal",
1008
+ "ordinal",
1009
+ "number",
1010
+ "date",
1011
+ "time",
1012
+ "telephone",
1013
+ "fraction",
1014
+ "address",
1015
+ "name",
1016
+ "currency"
1017
+ ];
1018
+ var LANGUAGE_PRESETS = ["ja-JP", "en-US", "de-DE", "fr-FR"];
1019
+ var SILENCE_VALUE_PRESETS = ["300ms", "500ms", "1s"];
1020
+ var SILENCE_TYPE_PRESETS = [
1021
+ "Leading",
1022
+ "Tailing",
1023
+ "Sentenceboundary",
1024
+ "Comma",
1025
+ "Semicolon",
1026
+ "Enumerationcomma"
1027
+ ];
1028
+ var PHONEME_ALPHABET_PRESETS = ["ipa", "sapi", "ups", "x-sampa"];
1029
+ var VISEME_TYPE_PRESETS = ["redlips_front", "FacialExpression"];
1030
+ var SSML_ATTRIBUTE_PRESETS = {
1031
+ break: {
1032
+ strength: BREAK_STRENGTH_PRESETS,
1033
+ time: BREAK_TIME_PRESETS
1034
+ },
1035
+ prosody: {
1036
+ rate: PROSODY_RATE_PRESETS,
1037
+ pitch: PROSODY_PITCH_PRESETS,
1038
+ volume: PROSODY_VOLUME_PRESETS
1039
+ },
1040
+ "mstts:express-as": {
1041
+ style: EXPRESS_AS_STYLE_PRESETS,
1042
+ role: EXPRESS_AS_ROLE_PRESETS
1043
+ },
1044
+ "express-as": {
1045
+ style: EXPRESS_AS_STYLE_PRESETS,
1046
+ role: EXPRESS_AS_ROLE_PRESETS
1047
+ },
1048
+ expressAs: {
1049
+ style: EXPRESS_AS_STYLE_PRESETS,
1050
+ role: EXPRESS_AS_ROLE_PRESETS
1051
+ },
1052
+ "say-as": {
1053
+ "interpret-as": SAY_AS_PRESETS
1054
+ },
1055
+ sayAs: {
1056
+ "interpret-as": SAY_AS_PRESETS
1057
+ },
1058
+ emphasis: {
1059
+ level: EMPHASIS_LEVEL_PRESETS
1060
+ },
1061
+ lang: {
1062
+ "xml:lang": LANGUAGE_PRESETS
1063
+ },
1064
+ phoneme: {
1065
+ alphabet: PHONEME_ALPHABET_PRESETS
1066
+ },
1067
+ "mstts:silence": {
1068
+ type: SILENCE_TYPE_PRESETS,
1069
+ value: SILENCE_VALUE_PRESETS
1070
+ },
1071
+ silence: {
1072
+ type: SILENCE_TYPE_PRESETS,
1073
+ value: SILENCE_VALUE_PRESETS
1074
+ },
1075
+ "mstts:viseme": {
1076
+ type: VISEME_TYPE_PRESETS
1077
+ },
1078
+ viseme: {
1079
+ type: VISEME_TYPE_PRESETS
1080
+ }
1081
+ };
1082
+ var SSML_PRESET_EXAMPLES = {
1083
+ breakTime: "500ms",
1084
+ prosodyRate: "fast",
1085
+ prosodyPitch: "+2st",
1086
+ prosodyVolume: "loud",
1087
+ expressAsStyle: "cheerful",
1088
+ phonemeAlphabet: "ipa",
1089
+ silenceValue: "300ms"
1090
+ };
1091
+ var BREAK_TIME_DESCRIPTIONS = {
1092
+ "500ms": {
1093
+ ja: "500\u30DF\u30EA\u79D2\u306E\u7121\u97F3",
1094
+ en: "Inserts 500 milliseconds of silence."
1095
+ },
1096
+ "1s": {
1097
+ ja: "1\u79D2\u306E\u7121\u97F3",
1098
+ en: "Inserts one second of silence."
1099
+ },
1100
+ "2s": {
1101
+ ja: "2\u79D2\u306E\u7121\u97F3",
1102
+ en: "Inserts two seconds of silence."
1103
+ },
1104
+ "3s": {
1105
+ ja: "3\u79D2\u306E\u7121\u97F3",
1106
+ en: "Inserts three seconds of silence."
1107
+ }
1108
+ };
1109
+ var EMPHASIS_LEVEL_DESCRIPTIONS = {
1110
+ strong: {
1111
+ ja: "\u5F37\u3044\u5F37\u8ABF",
1112
+ en: "Applies strong emphasis."
1113
+ },
1114
+ moderate: {
1115
+ ja: "\u4E2D\u7A0B\u5EA6\u306E\u5F37\u8ABF",
1116
+ en: "Applies moderate emphasis."
1117
+ },
1118
+ reduced: {
1119
+ ja: "\u5F31\u3081\u306E\u5F37\u8ABF",
1120
+ en: "Applies reduced emphasis."
1121
+ },
1122
+ none: {
1123
+ ja: "\u5F37\u8ABF\u306A\u3057",
1124
+ en: "Applies no emphasis."
1125
+ }
1126
+ };
1127
+ var PROSODY_RATE_DESCRIPTIONS = {
1128
+ "x-slow": {
1129
+ ja: "\u6700\u3082\u9045\u3044\u901F\u5EA6",
1130
+ en: "Uses the slowest speech rate."
1131
+ },
1132
+ slow: {
1133
+ ja: "\u9045\u3044\u901F\u5EA6",
1134
+ en: "Uses a slow speech rate."
1135
+ },
1136
+ medium: {
1137
+ ja: "\u6A19\u6E96\u7684\u306A\u901F\u5EA6",
1138
+ en: "Uses the standard speech rate."
1139
+ },
1140
+ fast: {
1141
+ ja: "\u901F\u3044\u901F\u5EA6",
1142
+ en: "Uses a fast speech rate."
1143
+ },
1144
+ "x-fast": {
1145
+ ja: "\u6700\u3082\u901F\u3044\u901F\u5EA6",
1146
+ en: "Uses the fastest speech rate."
1147
+ }
1148
+ };
1149
+ var PROSODY_PITCH_DESCRIPTIONS = {
1150
+ "+2st": {
1151
+ ja: "\u57FA\u6E96\u306E\u58F0\u306E\u9AD8\u3055\u3088\u308A2\u534A\u97F3\u4E0A",
1152
+ en: "Raises the pitch by two semitones."
1153
+ },
1154
+ "-2st": {
1155
+ ja: "\u57FA\u6E96\u306E\u58F0\u306E\u9AD8\u3055\u3088\u308A2\u534A\u97F3\u4E0B",
1156
+ en: "Lowers the pitch by two semitones."
1157
+ },
1158
+ "0st": {
1159
+ ja: "\u57FA\u6E96\u306E\u58F0\u306E\u9AD8\u3055",
1160
+ en: "Keeps the baseline pitch."
1161
+ },
1162
+ "+4st": {
1163
+ ja: "\u57FA\u6E96\u306E\u58F0\u306E\u9AD8\u3055\u3088\u308A4\u534A\u97F3\u4E0A",
1164
+ en: "Raises the pitch by four semitones."
1165
+ },
1166
+ "-4st": {
1167
+ ja: "\u57FA\u6E96\u306E\u58F0\u306E\u9AD8\u3055\u3088\u308A4\u534A\u97F3\u4E0B",
1168
+ en: "Lowers the pitch by four semitones."
1169
+ },
1170
+ "+8st": {
1171
+ ja: "\u57FA\u6E96\u306E\u58F0\u306E\u9AD8\u3055\u3088\u308A8\u534A\u97F3\u4E0A",
1172
+ en: "Raises the pitch by eight semitones."
1173
+ },
1174
+ "-8st": {
1175
+ ja: "\u57FA\u6E96\u306E\u58F0\u306E\u9AD8\u3055\u3088\u308A8\u534A\u97F3\u4E0B",
1176
+ en: "Lowers the pitch by eight semitones."
1177
+ },
1178
+ "+12st": {
1179
+ ja: "\u57FA\u6E96\u306E\u58F0\u306E\u9AD8\u3055\u3088\u308A12\u534A\u97F3\u4E0A",
1180
+ en: "Raises the pitch by twelve semitones."
1181
+ },
1182
+ "-12st": {
1183
+ ja: "\u57FA\u6E96\u306E\u58F0\u306E\u9AD8\u3055\u3088\u308A12\u534A\u97F3\u4E0B",
1184
+ en: "Lowers the pitch by twelve semitones."
1185
+ }
1186
+ };
1187
+ var PROSODY_VOLUME_DESCRIPTIONS = {
1188
+ silent: {
1189
+ ja: "\u7121\u97F3",
1190
+ en: "Makes the selected text silent."
1191
+ },
1192
+ "x-soft": {
1193
+ ja: "\u6700\u3082\u5C0F\u3055\u3044\u97F3\u91CF",
1194
+ en: "Uses the quietest volume."
1195
+ },
1196
+ soft: {
1197
+ ja: "\u5C0F\u3055\u3044\u97F3\u91CF",
1198
+ en: "Uses a soft volume."
1199
+ },
1200
+ medium: {
1201
+ ja: "\u6A19\u6E96\u7684\u306A\u97F3\u91CF",
1202
+ en: "Uses the standard volume."
1203
+ },
1204
+ loud: {
1205
+ ja: "\u5927\u304D\u3044\u97F3\u91CF",
1206
+ en: "Uses a loud volume."
1207
+ },
1208
+ "x-loud": {
1209
+ ja: "\u6700\u3082\u5927\u304D\u3044\u97F3\u91CF",
1210
+ en: "Uses the loudest volume."
1211
+ }
1212
+ };
1213
+ var EXPRESS_AS_STYLE_DESCRIPTIONS = {
1214
+ cheerful: {
1215
+ ja: "\u660E\u308B\u304F\u5143\u6C17\u306A\u30B9\u30BF\u30A4\u30EB",
1216
+ en: "Uses a cheerful style."
1217
+ },
1218
+ friendly: {
1219
+ ja: "\u89AA\u3057\u307F\u3084\u3059\u3044\u30B9\u30BF\u30A4\u30EB",
1220
+ en: "Uses a friendly style."
1221
+ },
1222
+ calm: {
1223
+ ja: "\u7A4F\u3084\u304B\u306A\u30B9\u30BF\u30A4\u30EB",
1224
+ en: "Uses a calm style."
1225
+ },
1226
+ sad: {
1227
+ ja: "\u60B2\u3057\u3052\u306A\u30B9\u30BF\u30A4\u30EB",
1228
+ en: "Uses a sad style."
1229
+ },
1230
+ angry: {
1231
+ ja: "\u6012\u3063\u305F\u3088\u3046\u306A\u30B9\u30BF\u30A4\u30EB",
1232
+ en: "Uses an angry style."
1233
+ },
1234
+ excited: {
1235
+ ja: "\u8208\u596E\u3057\u305F\u30B9\u30BF\u30A4\u30EB",
1236
+ en: "Uses an excited style."
1237
+ },
1238
+ empathetic: {
1239
+ ja: "\u5171\u611F\u3092\u793A\u3059\u30B9\u30BF\u30A4\u30EB",
1240
+ en: "Uses an empathetic style."
1241
+ },
1242
+ relieved: {
1243
+ ja: "\u5B89\u5FC3\u3057\u305F\u30B9\u30BF\u30A4\u30EB",
1244
+ en: "Uses a relieved style."
1245
+ },
1246
+ fearful: {
1247
+ ja: "\u6050\u308C\u3092\u611F\u3058\u3055\u305B\u308B\u30B9\u30BF\u30A4\u30EB",
1248
+ en: "Uses a fearful style."
1249
+ },
1250
+ depressed: {
1251
+ ja: "\u843D\u3061\u8FBC\u3093\u3060\u30B9\u30BF\u30A4\u30EB",
1252
+ en: "Uses a depressed style."
1253
+ },
1254
+ disgruntled: {
1255
+ ja: "\u4E0D\u6E80\u3092\u611F\u3058\u3055\u305B\u308B\u30B9\u30BF\u30A4\u30EB",
1256
+ en: "Uses a disgruntled style."
1257
+ },
1258
+ embarrassed: {
1259
+ ja: "\u6065\u305A\u304B\u3057\u305D\u3046\u306A\u30B9\u30BF\u30A4\u30EB",
1260
+ en: "Uses an embarrassed style."
1261
+ },
1262
+ serious: {
1263
+ ja: "\u771F\u5263\u306A\u30B9\u30BF\u30A4\u30EB",
1264
+ en: "Uses a serious style."
1265
+ },
1266
+ assistant: {
1267
+ ja: "\u30C7\u30B8\u30BF\u30EB\u30A2\u30B7\u30B9\u30BF\u30F3\u30C8\u5411\u3051\u306E\u30B9\u30BF\u30A4\u30EB",
1268
+ en: "Uses a digital assistant style."
1269
+ },
1270
+ chat: {
1271
+ ja: "\u4F1A\u8A71\u5411\u3051\u306E\u30B9\u30BF\u30A4\u30EB",
1272
+ en: "Uses a conversational style."
1273
+ },
1274
+ customerservice: {
1275
+ ja: "\u30AB\u30B9\u30BF\u30DE\u30FC\u30B5\u30FC\u30D3\u30B9\u5411\u3051\u306E\u30B9\u30BF\u30A4\u30EB",
1276
+ en: "Uses a customer service style."
1277
+ },
1278
+ hopeful: {
1279
+ ja: "\u5E0C\u671B\u306B\u6E80\u3061\u305F\u30B9\u30BF\u30A4\u30EB",
1280
+ en: "Uses a hopeful style."
1281
+ },
1282
+ newscast: {
1283
+ ja: "\u30CB\u30E5\u30FC\u30B9\u8AAD\u307F\u4E0A\u3052\u5411\u3051\u306E\u30B9\u30BF\u30A4\u30EB",
1284
+ en: "Uses a newscast style."
1285
+ },
1286
+ shouting: {
1287
+ ja: "\u53EB\u3076\u3088\u3046\u306A\u30B9\u30BF\u30A4\u30EB",
1288
+ en: "Uses a shouting style."
1289
+ },
1290
+ terrified: {
1291
+ ja: "\u6050\u6016\u306B\u6E80\u3061\u305F\u30B9\u30BF\u30A4\u30EB",
1292
+ en: "Uses a terrified style."
1293
+ },
1294
+ unfriendly: {
1295
+ ja: "\u7121\u611B\u60F3\u306A\u30B9\u30BF\u30A4\u30EB",
1296
+ en: "Uses an unfriendly style."
1297
+ },
1298
+ whispering: {
1299
+ ja: "\u3055\u3055\u3084\u304F\u3088\u3046\u306A\u30B9\u30BF\u30A4\u30EB",
1300
+ en: "Uses a whispering style."
1301
+ },
1302
+ "narration-relaxed": {
1303
+ ja: "\u30EA\u30E9\u30C3\u30AF\u30B9\u3057\u305F\u30CA\u30EC\u30FC\u30B7\u30E7\u30F3\u5411\u3051\u306E\u30B9\u30BF\u30A4\u30EB",
1304
+ en: "Uses a relaxed narration style."
1305
+ },
1306
+ "poetry-reading": {
1307
+ ja: "\u8A69\u306E\u6717\u8AAD\u5411\u3051\u306E\u30B9\u30BF\u30A4\u30EB",
1308
+ en: "Uses a poetry-reading style."
1309
+ },
1310
+ sports_commentary: {
1311
+ ja: "\u30B9\u30DD\u30FC\u30C4\u5B9F\u6CC1\u5411\u3051\u306E\u30B9\u30BF\u30A4\u30EB",
1312
+ en: "Uses a sports commentary style."
1313
+ },
1314
+ sports_commentary_excited: {
1315
+ ja: "\u8208\u596E\u3057\u305F\u30B9\u30DD\u30FC\u30C4\u5B9F\u6CC1\u5411\u3051\u306E\u30B9\u30BF\u30A4\u30EB",
1316
+ en: "Uses an excited sports commentary style."
1317
+ },
1318
+ story: {
1319
+ ja: "\u7269\u8A9E\u306E\u6717\u8AAD\u5411\u3051\u306E\u30B9\u30BF\u30A4\u30EB",
1320
+ en: "Uses a storytelling style."
1321
+ }
1322
+ };
1323
+ var SAY_AS_DESCRIPTIONS = {
1324
+ characters: {
1325
+ ja: "1\u6587\u5B57\u305A\u3064\u306E\u8AAD\u307F\u4E0A\u3052",
1326
+ en: "Speaks the characters one by one."
1327
+ },
1328
+ "spell-out": {
1329
+ ja: "\u7DB4\u308A\u306E\u8AAD\u307F\u4E0A\u3052\uFF081\u6587\u5B57\u305A\u3064\uFF09",
1330
+ en: "Spells out the text character by character."
1331
+ },
1332
+ cardinal: {
1333
+ ja: "\u57FA\u6570\u3068\u3057\u3066\u306E\u8AAD\u307F\u4E0A\u3052",
1334
+ en: "Speaks the value as a cardinal number."
1335
+ },
1336
+ ordinal: {
1337
+ ja: "\u5E8F\u6570\u3068\u3057\u3066\u306E\u8AAD\u307F\u4E0A\u3052",
1338
+ en: "Speaks the value as an ordinal number."
1339
+ },
1340
+ number: {
1341
+ ja: "\u6570\u5024\u3068\u3057\u3066\u306E\u8AAD\u307F\u4E0A\u3052",
1342
+ en: "Speaks the value as a number."
1343
+ },
1344
+ date: {
1345
+ ja: "\u65E5\u4ED8\u3068\u3057\u3066\u306E\u8AAD\u307F\u4E0A\u3052",
1346
+ en: "Speaks the value as a date."
1347
+ },
1348
+ time: {
1349
+ ja: "\u6642\u523B\u3068\u3057\u3066\u306E\u8AAD\u307F\u4E0A\u3052",
1350
+ en: "Speaks the value as a time."
1351
+ },
1352
+ telephone: {
1353
+ ja: "\u96FB\u8A71\u756A\u53F7\u3068\u3057\u3066\u306E\u8AAD\u307F\u4E0A\u3052",
1354
+ en: "Speaks the value as a telephone number."
1355
+ },
1356
+ fraction: {
1357
+ ja: "\u5206\u6570\u3068\u3057\u3066\u306E\u8AAD\u307F\u4E0A\u3052",
1358
+ en: "Speaks the value as a fraction."
1359
+ },
1360
+ address: {
1361
+ ja: "\u4F4F\u6240\u3068\u3057\u3066\u306E\u8AAD\u307F\u4E0A\u3052",
1362
+ en: "Speaks the value as an address."
1363
+ },
1364
+ name: {
1365
+ ja: "\u540D\u524D\u3068\u3057\u3066\u306E\u8AAD\u307F\u4E0A\u3052",
1366
+ en: "Speaks the value as a name."
1367
+ },
1368
+ currency: {
1369
+ ja: "\u901A\u8CA8\u3068\u3057\u3066\u306E\u8AAD\u307F\u4E0A\u3052",
1370
+ en: "Speaks the value as currency."
1371
+ }
1372
+ };
1373
+ var LANGUAGE_DESCRIPTIONS = {
1374
+ "ja-JP": {
1375
+ ja: "\u65E5\u672C\u8A9E\uFF08\u65E5\u672C\uFF09\u3067\u8AAD\u307F\u4E0A\u3052\u307E\u3059\u3002",
1376
+ en: "Speaks the text in Japanese (Japan)."
1377
+ },
1378
+ "en-US": {
1379
+ ja: "\u82F1\u8A9E\uFF08\u7C73\u56FD\uFF09\u3067\u8AAD\u307F\u4E0A\u3052\u307E\u3059\u3002",
1380
+ en: "Speaks the text in English (United States)."
1381
+ },
1382
+ "de-DE": {
1383
+ ja: "\u30C9\u30A4\u30C4\u8A9E\uFF08\u30C9\u30A4\u30C4\uFF09\u3067\u8AAD\u307F\u4E0A\u3052\u307E\u3059\u3002",
1384
+ en: "Speaks the text in German (Germany)."
1385
+ },
1386
+ "fr-FR": {
1387
+ ja: "\u30D5\u30E9\u30F3\u30B9\u8A9E\uFF08\u30D5\u30E9\u30F3\u30B9\uFF09\u3067\u8AAD\u307F\u4E0A\u3052\u307E\u3059\u3002",
1388
+ en: "Speaks the text in French (France)."
1389
+ }
1390
+ };
1391
+ var SILENCE_VALUE_DESCRIPTIONS = {
1392
+ "300ms": {
1393
+ ja: "\u5148\u982D\u306B300\u30DF\u30EA\u79D2\u306E\u7121\u97F3\u3092\u633F\u5165\u3057\u307E\u3059\u3002",
1394
+ en: "Inserts 300 milliseconds of leading silence."
1395
+ },
1396
+ "500ms": {
1397
+ ja: "\u5148\u982D\u306B500\u30DF\u30EA\u79D2\u306E\u7121\u97F3\u3092\u633F\u5165\u3057\u307E\u3059\u3002",
1398
+ en: "Inserts 500 milliseconds of leading silence."
1399
+ },
1400
+ "1s": {
1401
+ ja: "\u5148\u982D\u306B1\u79D2\u306E\u7121\u97F3\u3092\u633F\u5165\u3057\u307E\u3059\u3002",
1402
+ en: "Inserts one second of leading silence."
1403
+ }
1404
+ };
1405
+
1406
+ // ../ssml-editor-react/src/ssmlContext.ts
1407
+ function findTagEnd2(source, start, limit) {
1408
+ let quote;
1409
+ for (let index = start + 1; index < limit; index += 1) {
1410
+ const character = source[index];
1411
+ if (quote !== void 0) {
1412
+ if (character === quote) {
1413
+ quote = void 0;
1414
+ }
1415
+ continue;
1416
+ }
1417
+ if (character === '"' || character === "'") {
1418
+ quote = character;
1419
+ continue;
1420
+ }
1421
+ if (character === ">") {
1422
+ return index;
1423
+ }
1424
+ }
1425
+ return -1;
1426
+ }
1427
+ function getVoiceName(tag) {
1428
+ return tag.match(/\bname\s*=\s*(["'])([\s\S]*?)\1/i)?.[2];
1429
+ }
1430
+ function closeElement(stack, name) {
1431
+ for (let index = stack.length - 1; index >= 0; index -= 1) {
1432
+ if (stack[index]?.name === name) {
1433
+ stack.splice(index);
1434
+ return;
1435
+ }
1436
+ }
1437
+ }
1438
+ function findActiveSsmlTags(source, offset) {
1439
+ const limit = Math.max(0, Math.min(offset, source.length));
1440
+ const stack = [];
1441
+ let index = 0;
1442
+ while (index < source.length) {
1443
+ const tagStart = source.indexOf("<", index);
1444
+ if (tagStart === -1 || tagStart > limit) {
1445
+ break;
1446
+ }
1447
+ const nonContentEnd = source.startsWith("<!--", tagStart) ? source.indexOf("-->", tagStart + 4) : source.startsWith("<![CDATA[", tagStart) ? source.indexOf("]]>", tagStart + 9) : source.startsWith("<?", tagStart) ? source.indexOf("?>", tagStart + 2) : void 0;
1448
+ if (nonContentEnd !== void 0) {
1449
+ const delimiterLength = source.startsWith("<?", tagStart) ? 2 : 3;
1450
+ const end = nonContentEnd === -1 ? source.length : nonContentEnd + delimiterLength;
1451
+ if (limit < end) {
1452
+ break;
1453
+ }
1454
+ index = end;
1455
+ continue;
1456
+ }
1457
+ const tagEnd = findTagEnd2(source, tagStart, source.length);
1458
+ const tag = source.slice(tagStart, tagEnd === -1 ? source.length : tagEnd + 1);
1459
+ const closingMatch = tag.match(/^<\s*\/\s*([A-Za-z_][A-Za-z0-9_.:-]*)/);
1460
+ const openingMatch = tag.match(/^<\s*([A-Za-z_][A-Za-z0-9_.:-]*)/);
1461
+ if (tagEnd === -1 || limit <= tagEnd) {
1462
+ if (openingMatch?.[1]) {
1463
+ stack.push({ name: openingMatch[1].toLowerCase() });
1464
+ }
1465
+ break;
1466
+ }
1467
+ if (closingMatch?.[1]) {
1468
+ closeElement(stack, closingMatch[1].toLowerCase());
1469
+ } else if (openingMatch?.[1] && !/\/\s*>$/.test(tag)) {
1470
+ stack.push({ name: openingMatch[1].toLowerCase() });
1471
+ }
1472
+ index = tagEnd + 1;
1473
+ }
1474
+ return new Set(stack.map(({ name }) => name));
1475
+ }
1476
+ function findSsmlVoiceContext(source, offset) {
1477
+ const limit = Math.max(0, Math.min(offset, source.length));
1478
+ const stack = [];
1479
+ let index = 0;
1480
+ while (index < limit) {
1481
+ const tagStart = source.indexOf("<", index);
1482
+ if (tagStart === -1 || tagStart >= limit) {
1483
+ break;
1484
+ }
1485
+ if (source.startsWith("<!--", tagStart)) {
1486
+ const end = source.indexOf("-->", tagStart + 4);
1487
+ index = end === -1 || end + 3 > limit ? limit : end + 3;
1488
+ continue;
1489
+ }
1490
+ if (source.startsWith("<![CDATA[", tagStart)) {
1491
+ const end = source.indexOf("]]>", tagStart + 9);
1492
+ index = end === -1 || end + 3 > limit ? limit : end + 3;
1493
+ continue;
1494
+ }
1495
+ if (source.startsWith("<?", tagStart)) {
1496
+ const end = source.indexOf("?>", tagStart + 2);
1497
+ index = end === -1 || end + 2 > limit ? limit : end + 2;
1498
+ continue;
1499
+ }
1500
+ const tagEnd = findTagEnd2(source, tagStart, limit);
1501
+ if (tagEnd === -1) {
1502
+ break;
1503
+ }
1504
+ const tag = source.slice(tagStart, tagEnd + 1);
1505
+ if (tag.startsWith("<!")) {
1506
+ index = tagEnd + 1;
1507
+ continue;
1508
+ }
1509
+ const closingMatch = tag.match(/^<\s*\/\s*([A-Za-z_][A-Za-z0-9_.:-]*)/);
1510
+ if (closingMatch?.[1]) {
1511
+ closeElement(stack, closingMatch[1].toLowerCase());
1512
+ index = tagEnd + 1;
1513
+ continue;
1514
+ }
1515
+ const openingMatch = tag.match(/^<\s*([A-Za-z_][A-Za-z0-9_.:-]*)/);
1516
+ if (openingMatch?.[1] && !/\/\s*>$/.test(tag)) {
1517
+ const name = openingMatch[1].toLowerCase();
1518
+ stack.push({
1519
+ name,
1520
+ ...name === "voice" ? { voiceName: getVoiceName(tag) } : {}
1521
+ });
1522
+ }
1523
+ index = tagEnd + 1;
1524
+ }
1525
+ for (let stackIndex = stack.length - 1; stackIndex >= 0; stackIndex -= 1) {
1526
+ const element = stack[stackIndex];
1527
+ if (element?.name === "voice") {
1528
+ return element.voiceName === void 0 ? {} : { voiceName: element.voiceName };
1529
+ }
1530
+ }
1531
+ return void 0;
1532
+ }
1533
+
1534
+ // ../ssml-editor-react/src/ssmlCompletion.ts
1535
+ var SSML_ATTRIBUTE_VALUE_PATTERN = /<([\w:-]+)\s+[^>]*?\b([\w:-]+)=["']([^"']*)$/i;
1536
+ var EXPRESS_AS_TAG_NAMES = /* @__PURE__ */ new Set(["mstts:express-as", "express-as", "expressas"]);
1537
+ function findSsmlAttributePresets(tagName, attributeName) {
1538
+ const tagPresets = Object.entries(SSML_ATTRIBUTE_PRESETS).find(
1539
+ ([presetTagName]) => presetTagName.toLowerCase() === tagName.toLowerCase()
1540
+ )?.[1];
1541
+ return Object.entries(tagPresets ?? {}).find(
1542
+ ([presetAttributeName]) => presetAttributeName.toLowerCase() === attributeName.toLowerCase()
1543
+ )?.[1];
1544
+ }
1545
+ var SSML_COMPLETION_SNIPPETS = [
1546
+ {
1547
+ label: "break",
1548
+ insertText: '<break time="500ms" />'
1549
+ },
1550
+ {
1551
+ label: "prosody",
1552
+ insertText: `<prosody rate="medium" pitch="medium">\${1:text}</prosody>`
1553
+ },
1554
+ {
1555
+ label: "mstts:express-as",
1556
+ insertText: `<mstts:express-as style="cheerful">\${1:text}</mstts:express-as>`
1557
+ },
1558
+ {
1559
+ label: "sub",
1560
+ insertText: `<sub alias="\${1:\u8AAD\u307F}">\${2:\u6F22\u5B57}</sub>`
1561
+ }
1562
+ ];
1563
+ function registerSsmlCompletionProvider(monaco, options = {}) {
1564
+ const provider = {
1565
+ provideCompletionItems(model, position) {
1566
+ if (options.model && options.model !== model) {
1567
+ return { suggestions: [] };
1568
+ }
1569
+ const value = model.getValue();
1570
+ const offset = model.getOffsetAt(position);
1571
+ const textUntilPosition = value.slice(0, offset);
1572
+ const isClosingTag = /<\/[a-zA-Z0-9:-]*$/.test(textUntilPosition);
1573
+ if (isClosingTag) {
1574
+ return { suggestions: [] };
1575
+ }
1576
+ const attributeMatch = SSML_ATTRIBUTE_VALUE_PATTERN.exec(textUntilPosition);
1577
+ let attributeValues = attributeMatch ? findSsmlAttributePresets(attributeMatch[1], attributeMatch[2]) : void 0;
1578
+ if (attributeMatch && attributeValues && EXPRESS_AS_TAG_NAMES.has(attributeMatch[1].toLowerCase()) && attributeMatch[2].toLowerCase() === "style") {
1579
+ const voiceContext = findSsmlVoiceContext(value, offset);
1580
+ const voiceName = voiceContext === void 0 ? options.getOuterVoiceName?.() : voiceContext.voiceName;
1581
+ attributeValues = resolveExpressAsStyles(voiceName, attributeValues);
1582
+ }
1583
+ const openTagMatch = textUntilPosition.match(/<(?!\/)[a-zA-Z0-9:-]*$/);
1584
+ const openTagLength = openTagMatch?.[0].length ?? 0;
1585
+ const isAfterBracket = model.getValueInRange({
1586
+ startLineNumber: position.lineNumber,
1587
+ startColumn: position.column - 1,
1588
+ endLineNumber: position.lineNumber,
1589
+ endColumn: position.column
1590
+ }) === "<";
1591
+ const hasClosingBracket = isAfterBracket && model.getValueInRange({
1592
+ startLineNumber: position.lineNumber,
1593
+ startColumn: position.column,
1594
+ endLineNumber: position.lineNumber,
1595
+ endColumn: position.column + 1
1596
+ }) === ">";
1597
+ const range = {
1598
+ startLineNumber: position.lineNumber,
1599
+ startColumn: openTagLength > 0 ? position.column - openTagLength : position.column,
1600
+ endLineNumber: position.lineNumber,
1601
+ endColumn: hasClosingBracket ? position.column + 1 : position.column
1602
+ };
1603
+ return {
1604
+ suggestions: [
1605
+ ...attributeMatch ? [] : SSML_COMPLETION_SNIPPETS.map(({ label, insertText }) => ({
1606
+ label,
1607
+ kind: monaco.languages.CompletionItemKind.Snippet,
1608
+ insertText,
1609
+ insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
1610
+ range
1611
+ })),
1612
+ ...attributeValues?.map((value2) => ({
1613
+ label: value2,
1614
+ kind: monaco.languages.CompletionItemKind.Value,
1615
+ insertText: value2,
1616
+ range
1617
+ })) ?? []
1618
+ ]
1619
+ };
1620
+ },
1621
+ triggerCharacters: ["<", '"', "'"]
1622
+ };
1623
+ return monaco.languages.registerCompletionItemProvider("xml", provider);
1624
+ }
1625
+
1626
+ // ../ssml-editor-react/src/locales.ts
1627
+ var EDITOR_COPY = {
1628
+ ja: {
1629
+ editorAriaLabel: "SSML\u30A8\u30C7\u30A3\u30BF\u30FC",
1630
+ toolbarAriaLabel: "SSML\u30C4\u30FC\u30EB\u30D0\u30FC",
1631
+ clearAll: "\u5168\u3066\u30AF\u30EA\u30A2",
1632
+ clearAllTitle: "\u97F3\u58F0\u8A2D\u5B9A\u3092\u4FDD\u6301\u3057\u3066XML\u8981\u7D20\u3092\u524A\u9664\u3057\u672C\u6587\u3092\u6B8B\u3059",
1633
+ undo: "\u5143\u306B\u623B\u3059",
1634
+ undoTitle: "\u76F4\u524D\u306E\u5909\u66F4\u3092\u5143\u306B\u623B\u3059",
1635
+ redo: "\u3084\u308A\u76F4\u3059",
1636
+ redoTitle: "\u5143\u306B\u623B\u3057\u305F\u5909\u66F4\u3092\u3084\u308A\u76F4\u3059",
1637
+ help: "\u8AAC\u660E",
1638
+ helpTitle: "\u30DC\u30BF\u30F3\u3068\u30D1\u30E9\u30E1\u30FC\u30BF\u306E\u8AAC\u660E\u3092\u8868\u793A",
1639
+ helpHeading: "\u30DC\u30BF\u30F3\u3068\u30D1\u30E9\u30E1\u30FC\u30BF\u306E\u8AAC\u660E",
1640
+ helpDescription: "\u5404\u30B3\u30F3\u30C8\u30ED\u30FC\u30EB\u306E\u6A5F\u80FD\u3068\u30D1\u30E9\u30E1\u30FC\u30BF\u3092\u78BA\u8A8D\u3067\u304D\u307E\u3059\u3002",
1641
+ parameters: "\u30D1\u30E9\u30E1\u30FC\u30BF",
1642
+ format: "\u30D5\u30A9\u30FC\u30DE\u30C3\u30C8",
1643
+ formatTitle: "\u672C\u6587\u306EXML\u3092\u6539\u884C\u3057\u3066\u898B\u3084\u3059\u304F\u8868\u793A",
1644
+ decorations: "\u88C5\u98FE",
1645
+ decorationsShowTitle: "\u30A4\u30F3\u30E9\u30A4\u30F3\u88C5\u98FE\u3092\u8868\u793A",
1646
+ decorationsHideTitle: "\u30A4\u30F3\u30E9\u30A4\u30F3\u88C5\u98FE\u3092\u975E\u8868\u793A",
1647
+ syntaxError: "\u69CB\u6587\u30A8\u30E9\u30FC",
1648
+ selectionActions: "\u9078\u629E\u7BC4\u56F2\u306E\u64CD\u4F5C",
1649
+ selectionCountSuffix: "\u6587\u5B57",
1650
+ previewSelection: "\u9078\u629E\u90E8\u5206\u3092\u8A66\u8074",
1651
+ previewSelectionTitle: "\u9078\u629E\u90E8\u5206\u306ESSML\u3092\u8A66\u8074",
1652
+ noAvailableOptions: "\u5229\u7528\u53EF\u80FD\u306A\u9078\u629E\u80A2\u304C\u3042\u308A\u307E\u305B\u3093\u3002",
1653
+ styleNotSupported: "\u3053\u306E\u97F3\u58F0\u306F\u30B9\u30BF\u30A4\u30EB\u6307\u5B9A\u306B\u5BFE\u5FDC\u3057\u3066\u3044\u307E\u305B\u3093",
1654
+ categoryEmotions: "\u611F\u60C5\u30FB\u30C8\u30FC\u30F3",
1655
+ categoryScenarios: "\u4F1A\u8A71\u30FB\u30B7\u30CA\u30EA\u30AA",
1656
+ categoryMedia: "\u30E1\u30C7\u30A3\u30A2\u30FB\u30CA\u30EC\u30FC\u30B7\u30E7\u30F3",
1657
+ categoryOther: "\u305D\u306E\u4ED6"
1658
+ },
1659
+ en: {
1660
+ editorAriaLabel: "SSML editor",
1661
+ toolbarAriaLabel: "SSML toolbar",
1662
+ clearAll: "Clear all",
1663
+ clearAllTitle: "Remove non-voice XML elements and keep the text and voice settings",
1664
+ undo: "Undo",
1665
+ undoTitle: "Undo the last change",
1666
+ redo: "Redo",
1667
+ redoTitle: "Redo the last undone change",
1668
+ help: "Help",
1669
+ helpTitle: "Show button and parameter descriptions",
1670
+ helpHeading: "Button and parameter descriptions",
1671
+ helpDescription: "Review what each control does and its parameters.",
1672
+ parameters: "Parameters",
1673
+ format: "Format",
1674
+ formatTitle: "Format the XML in the editor",
1675
+ decorations: "Decorations",
1676
+ decorationsShowTitle: "Show inline decorations",
1677
+ decorationsHideTitle: "Hide inline decorations",
1678
+ syntaxError: "Syntax error",
1679
+ selectionActions: "Selection actions",
1680
+ selectionCountSuffix: " characters",
1681
+ previewSelection: "Preview selection",
1682
+ previewSelectionTitle: "Preview the selected SSML",
1683
+ noAvailableOptions: "No options are available.",
1684
+ styleNotSupported: "This voice does not support style selection.",
1685
+ categoryEmotions: "Emotions / Tone",
1686
+ categoryScenarios: "Conversations / Scenarios",
1687
+ categoryMedia: "Media / Broadcast",
1688
+ categoryOther: "Other"
1689
+ }
1690
+ };
1691
+ var SSML_HOVER_COPY = {
1692
+ ja: {
1693
+ parameterHeading: "\u30D1\u30E9\u30E1\u30FC\u30BF",
1694
+ parametersHeading: "\u30D1\u30E9\u30E1\u30FC\u30BF",
1695
+ allowedValues: "\u4F7F\u7528\u3067\u304D\u308B\u5024",
1696
+ example: "\u4F8B",
1697
+ noParameters: "\u3053\u306E\u8981\u7D20\u306B\u30D1\u30E9\u30E1\u30FC\u30BF\u306F\u3042\u308A\u307E\u305B\u3093\u3002",
1698
+ tags: {
1699
+ voice: {
1700
+ title: "\u97F3\u58F0",
1701
+ description: "\u56F2\u307E\u308C\u305F\u30C6\u30AD\u30B9\u30C8\u306E\u5408\u6210\u306B\u4F7F\u7528\u3059\u308B\u97F3\u58F0\u3068\u3001\u4EFB\u610F\u306E\u97F3\u58F0\u52B9\u679C\u3092\u9078\u629E\u3057\u307E\u3059\u3002",
1702
+ parameters: {
1703
+ name: { title: "name", description: "\u97F3\u58F0\u540D\u3002\u4F8B: `en-US-JennyNeural`\u3002" },
1704
+ effect: { title: "effect", description: "\u4EFB\u610F\u306E\u97F3\u58F0\u52B9\u679C\u3002\u4F8B: `eq_car`\u3002" }
1705
+ }
1706
+ },
1707
+ prosody: {
1708
+ title: "\u97FB\u5F8B",
1709
+ description: "\u56F2\u307E\u308C\u305F\u30C6\u30AD\u30B9\u30C8\u306E\u901F\u5EA6\u3001\u30D4\u30C3\u30C1\u3001\u97F3\u91CF\u3001\u307E\u305F\u306F\u30D4\u30C3\u30C1\u66F2\u7DDA\u3092\u5909\u66F4\u3057\u307E\u3059\u3002",
1710
+ parameters: {
1711
+ rate: { title: "rate", description: "\u767A\u8A71\u901F\u5EA6\u3092\u6307\u5B9A\u3057\u307E\u3059\u3002" },
1712
+ pitch: { title: "pitch", description: "\u540D\u524D\u4ED8\u304D\u306E\u5024\u3001\u5272\u5408\u3001\u5468\u6CE2\u6570\u3001\u307E\u305F\u306F\u534A\u97F3\u3067\u30D4\u30C3\u30C1\u3092\u8ABF\u6574\u3057\u307E\u3059\u3002" },
1713
+ volume: { title: "volume", description: "\u540D\u524D\u4ED8\u304D\u306E\u5024\u3001\u5272\u5408\u3001\u307E\u305F\u306F\u30C7\u30B7\u30D9\u30EB\u5024\u3067\u97F3\u91CF\u3092\u6307\u5B9A\u3057\u307E\u3059\u3002" },
1714
+ contour: { title: "contour", description: "\u30C6\u30AD\u30B9\u30C8\u5185\u306E\u4F4D\u7F6E\u3054\u3068\u306E\u76F8\u5BFE\u7684\u306A\u30D4\u30C3\u30C1\u5909\u5316\u3092\u5B9A\u7FA9\u3057\u307E\u3059\u3002" },
1715
+ range: { title: "range", description: "\u97F3\u58F0\u306E\u30D4\u30C3\u30C1\u7BC4\u56F2\u3092\u8ABF\u6574\u3057\u307E\u3059\u3002" }
1716
+ }
1717
+ },
1718
+ break: {
1719
+ title: "\u9593",
1720
+ description: "\u5358\u8A9E\u3084\u305D\u306E\u4ED6\u306E\u97F3\u58F0\u30B3\u30F3\u30C6\u30F3\u30C4\u306E\u9593\u306B\u30DD\u30FC\u30BA\u3092\u633F\u5165\u3057\u307E\u3059\u3002",
1721
+ parameters: {
1722
+ time: { title: "time", description: "\u30DD\u30FC\u30BA\u306E\u9577\u3055\u3002\u4F8B: `500ms` \u307E\u305F\u306F `1s`\u3002" },
1723
+ strength: { title: "strength", description: "\u76F8\u5BFE\u7684\u306A\u30DD\u30FC\u30BA\u306E\u5F37\u3055\u3002" }
1724
+ }
1725
+ },
1726
+ "mstts:express-as": {
1727
+ title: "\u8868\u73FE",
1728
+ description: "\u56F2\u307E\u308C\u305F\u30C6\u30AD\u30B9\u30C8\u306B\u97F3\u58F0\u30B9\u30BF\u30A4\u30EB\u3001\u30B9\u30BF\u30A4\u30EB\u306E\u5F37\u3055\u3001\u307E\u305F\u306F\u5F79\u5272\u3092\u9069\u7528\u3057\u307E\u3059\u3002",
1729
+ parameters: {
1730
+ style: { title: "style", description: "\u9078\u629E\u3057\u305F\u97F3\u58F0\u304C\u5BFE\u5FDC\u3059\u308B\u97F3\u58F0\u30B9\u30BF\u30A4\u30EB\u3002\u4F8B: `cheerful`\u3002" },
1731
+ styledegree: { title: "styledegree", description: "\u9078\u629E\u3057\u305F\u97F3\u58F0\u30B9\u30BF\u30A4\u30EB\u306E\u5F37\u3055\u3092\u6307\u5B9A\u3057\u307E\u3059\u3002" },
1732
+ role: { title: "role", description: "\u5BFE\u5FDC\u3057\u3066\u3044\u308B\u5834\u5408\u306B\u97F3\u58F0\u306E\u5F79\u5272\u3092\u5909\u66F4\u3057\u307E\u3059\u3002" }
1733
+ }
1734
+ },
1735
+ "say-as": {
1736
+ title: "\u8AAD\u307F\u4E0A\u3052\u65B9",
1737
+ description: "\u56F2\u307E\u308C\u305F\u30C6\u30AD\u30B9\u30C8\u306E\u89E3\u91C8\u65B9\u6CD5\u3068\u8AAD\u307F\u4E0A\u3052\u65B9\u3092\u6307\u5B9A\u3057\u307E\u3059\u3002",
1738
+ parameters: {
1739
+ "interpret-as": { title: "interpret-as", description: "\u6587\u5B57\u3001\u6570\u5B57\u3001\u65E5\u4ED8\u3001\u6642\u523B\u306A\u3069\u306E\u89E3\u91C8\u3092\u6307\u5B9A\u3057\u307E\u3059\u3002" },
1740
+ format: { title: "format", description: "\u9078\u629E\u3057\u305F\u89E3\u91C8\u306E\u5F62\u5F0F\u3092\u88DC\u8DB3\u3057\u307E\u3059\u3002" },
1741
+ detail: { title: "detail", description: "\u9078\u629E\u3057\u305F\u89E3\u91C8\u306E\u8A73\u7D30\u3092\u88DC\u8DB3\u3057\u307E\u3059\u3002" }
1742
+ }
1743
+ },
1744
+ phoneme: {
1745
+ title: "\u97F3\u7D20",
1746
+ description: "\u6307\u5B9A\u3057\u305F\u97F3\u7D20\u8868\u8A18\u3067\u901A\u5E38\u306E\u767A\u97F3\u3092\u7F6E\u304D\u63DB\u3048\u307E\u3059\u3002",
1747
+ parameters: {
1748
+ alphabet: { title: "alphabet", description: "`ph` \u5024\u306B\u4F7F\u7528\u3059\u308B\u97F3\u7D20\u30A2\u30EB\u30D5\u30A1\u30D9\u30C3\u30C8\u3002" },
1749
+ ph: { title: "ph", description: "\u56F2\u307E\u308C\u305F\u30C6\u30AD\u30B9\u30C8\u306E\u97F3\u7D20\u8868\u8A18\u3002" }
1750
+ }
1751
+ },
1752
+ emphasis: {
1753
+ title: "\u5F37\u8ABF",
1754
+ description: "\u56F2\u307E\u308C\u305F\u30C6\u30AD\u30B9\u30C8\u3092\u5F37\u8ABF\u3057\u307E\u3059\u3002",
1755
+ parameters: {
1756
+ level: { title: "level", description: "\u5F37\u8ABF\u306E\u5EA6\u5408\u3044\u3092\u6307\u5B9A\u3057\u307E\u3059\u3002" }
1757
+ }
1758
+ },
1759
+ audio: {
1760
+ title: "\u97F3\u58F0\u30D5\u30A1\u30A4\u30EB",
1761
+ description: "\u5408\u6210\u7D50\u679C\u306E\u4E00\u90E8\u3068\u3057\u3066\u97F3\u58F0\u30D5\u30A1\u30A4\u30EB\u3092\u518D\u751F\u3057\u307E\u3059\u3002",
1762
+ parameters: {
1763
+ src: { title: "src", description: "\u97F3\u58F0\u30D5\u30A1\u30A4\u30EB\u306E URI\u3002" },
1764
+ desc: { title: "desc", description: "\u97F3\u58F0\u3092\u518D\u751F\u3067\u304D\u306A\u3044\u5834\u5408\u306B\u4F7F\u7528\u3059\u308B\u4EE3\u66FF\u30C6\u30AD\u30B9\u30C8\u3002" },
1765
+ clipBegin: { title: "clipBegin", description: "\u97F3\u58F0\u30D5\u30A1\u30A4\u30EB\u5185\u306E\u958B\u59CB\u4F4D\u7F6E\u3002\u4F8B: `0s`\u3002" },
1766
+ clipEnd: { title: "clipEnd", description: "\u97F3\u58F0\u30D5\u30A1\u30A4\u30EB\u5185\u306E\u7D42\u4E86\u4F4D\u7F6E\u3002\u4F8B: `5s`\u3002" },
1767
+ speed: { title: "speed", description: "\u97F3\u58F0\u30D5\u30A1\u30A4\u30EB\u306E\u518D\u751F\u901F\u5EA6\u3002\u4F8B: `1.0`\u3002" },
1768
+ repeatCount: { title: "repeatCount", description: "\u97F3\u58F0\u3092\u7E70\u308A\u8FD4\u3059\u56DE\u6570\u3002\u4F8B: `2`\u3002" },
1769
+ repeatDuration: { title: "repeatDuration", description: "\u97F3\u58F0\u3092\u7E70\u308A\u8FD4\u3059\u5408\u8A08\u6642\u9593\u3002\u4F8B: `10s`\u3002" },
1770
+ soundLevel: { title: "soundLevel", description: "\u30C7\u30B7\u30D9\u30EB\u5358\u4F4D\u306E\u97F3\u91CF\u8ABF\u6574\u3002\u4F8B: `-3dB`\u3002" }
1771
+ }
1772
+ },
1773
+ sub: {
1774
+ title: "\u7F6E\u63DB",
1775
+ description: "\u56F2\u307E\u308C\u305F\u30C6\u30AD\u30B9\u30C8\u306E\u4EE3\u308F\u308A\u306B\u5225\u540D\u30C6\u30AD\u30B9\u30C8\u3092\u8AAD\u307F\u4E0A\u3052\u307E\u3059\u3002",
1776
+ parameters: {
1777
+ alias: { title: "alias", description: "\u5143\u306E\u30C6\u30AD\u30B9\u30C8\u306E\u4EE3\u308F\u308A\u306B\u8AAD\u307F\u4E0A\u3052\u308B\u30C6\u30AD\u30B9\u30C8\u3002\u4F8B: `World Wide Web`\u3002" }
1778
+ }
1779
+ },
1780
+ lang: {
1781
+ title: "\u8A00\u8A9E",
1782
+ description: "\u56F2\u307E\u308C\u305F\u30C6\u30AD\u30B9\u30C8\u306E\u8AAD\u307F\u4E0A\u3052\u8A00\u8A9E\u3092\u5909\u66F4\u3057\u307E\u3059\u3002",
1783
+ parameters: {
1784
+ "xml:lang": { title: "xml:lang", description: "BCP-47 \u8A00\u8A9E\u30BF\u30B0\u3002\u4F8B: `ja-JP`\u3002" }
1785
+ }
1786
+ },
1787
+ mark: {
1788
+ title: "\u30DE\u30FC\u30AB\u30FC",
1789
+ description: "\u5408\u6210\u97F3\u58F0\u30B9\u30C8\u30EA\u30FC\u30E0\u306B\u30AB\u30B9\u30BF\u30E0\u30DE\u30FC\u30AB\u30FC\u3092\u633F\u5165\u3057\u307E\u3059\u3002",
1790
+ parameters: {
1791
+ name: { title: "name", description: "\u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3\u3067\u5B9A\u7FA9\u3057\u305F\u30DE\u30FC\u30AB\u30FC\u540D\u3002\u4F8B: `chapter-1`\u3002" }
1792
+ }
1793
+ },
1794
+ bookmark: {
1795
+ title: "\u30D6\u30C3\u30AF\u30DE\u30FC\u30AF",
1796
+ description: "\u5408\u6210\u97F3\u58F0\u30B9\u30C8\u30EA\u30FC\u30E0\u306B\u30D6\u30C3\u30AF\u30DE\u30FC\u30AF\u30DE\u30FC\u30AB\u30FC\u3092\u633F\u5165\u3057\u307E\u3059\u3002",
1797
+ parameters: {
1798
+ mark: { title: "mark", description: "\u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3\u3067\u5B9A\u7FA9\u3057\u305F\u30D6\u30C3\u30AF\u30DE\u30FC\u30AF\u540D\u3002\u4F8B: `chapter-1`\u3002" }
1799
+ }
1800
+ },
1801
+ lexicon: {
1802
+ title: "\u767A\u97F3\u8F9E\u66F8",
1803
+ description: "\u5408\u6210\u6587\u66F8\u306B\u767A\u97F3\u8F9E\u66F8\u3092\u95A2\u9023\u4ED8\u3051\u307E\u3059\u3002",
1804
+ parameters: {
1805
+ uri: { title: "uri", description: "\u767A\u97F3\u8F9E\u66F8\u306E URI\u3002" }
1806
+ }
1807
+ },
1808
+ p: { title: "\u6BB5\u843D", description: "\u30C6\u30AD\u30B9\u30C8\u3092\u6BB5\u843D\u3068\u3057\u3066\u307E\u3068\u3081\u307E\u3059\u3002", parameters: {} },
1809
+ s: { title: "\u6587", description: "\u30C6\u30AD\u30B9\u30C8\u3092\u6587\u3068\u3057\u3066\u307E\u3068\u3081\u307E\u3059\u3002", parameters: {} },
1810
+ w: { title: "\u5358\u8A9E", description: "\u30C6\u30AD\u30B9\u30C8\u3092\u5358\u8A9E\u3068\u3057\u3066\u307E\u3068\u3081\u307E\u3059\u3002", parameters: {} },
1811
+ "mstts:silence": {
1812
+ title: "\u7121\u97F3",
1813
+ description: "\u30C6\u30AD\u30B9\u30C8\u306E\u524D\u5F8C\u3001\u307E\u305F\u306F\u53E5\u8AAD\u70B9\u306E\u5883\u754C\u306B\u6307\u5B9A\u3057\u305F\u7121\u97F3\u3092\u8FFD\u52A0\u3057\u307E\u3059\u3002",
1814
+ parameters: {
1815
+ type: { title: "type", description: "\u7121\u97F3\u306E\u4F4D\u7F6E\u307E\u305F\u306F\u53E5\u8AAD\u70B9\u306E\u5883\u754C\u3002" },
1816
+ value: { title: "value", description: "\u7121\u97F3\u306E\u9577\u3055\u3002\u4F8B: `300ms`\u3002" }
1817
+ }
1818
+ },
1819
+ "mstts:viseme": {
1820
+ title: "\u30D3\u30BC\u30FC\u30E0",
1821
+ description: "\u5408\u6210\u97F3\u58F0\u306E\u30D3\u30BC\u30FC\u30E0\u30A4\u30D9\u30F3\u30C8\u3092\u8981\u6C42\u3057\u307E\u3059\u3002",
1822
+ parameters: {
1823
+ type: { title: "type", description: "\u30D3\u30BC\u30FC\u30E0\u30A4\u30D9\u30F3\u30C8\u306E\u5F62\u5F0F\u3002" }
1824
+ }
1825
+ }
1826
+ }
1827
+ },
1828
+ en: {
1829
+ parameterHeading: "Parameter",
1830
+ parametersHeading: "Parameters",
1831
+ allowedValues: "Allowed values",
1832
+ example: "Example",
1833
+ noParameters: "This element has no parameters.",
1834
+ tags: {
1835
+ voice: {
1836
+ title: "Voice",
1837
+ description: "Selects the voice and optional voice effect used to synthesize the enclosed text.",
1838
+ parameters: {
1839
+ name: { title: "name", description: "The voice name, such as `en-US-JennyNeural`." },
1840
+ effect: { title: "effect", description: "An optional voice effect, such as `eq_car`." }
1841
+ }
1842
+ },
1843
+ prosody: {
1844
+ title: "Prosody",
1845
+ description: "Changes the speaking rate, pitch, volume, or pitch contour of the enclosed text.",
1846
+ parameters: {
1847
+ rate: { title: "rate", description: "Controls speaking speed." },
1848
+ pitch: {
1849
+ title: "pitch",
1850
+ description: "Adjusts pitch using a named value, percentage, frequency, or semitone value."
1851
+ },
1852
+ volume: {
1853
+ title: "volume",
1854
+ description: "Controls loudness using a named value, percentage, or decibel value."
1855
+ },
1856
+ contour: {
1857
+ title: "contour",
1858
+ description: "Defines a sequence of relative pitch changes at positions in the text."
1859
+ },
1860
+ range: { title: "range", description: "Adjusts the pitch range of the voice." }
1861
+ }
1862
+ },
1863
+ break: {
1864
+ title: "Break",
1865
+ description: "Inserts a pause between words or other spoken content.",
1866
+ parameters: {
1867
+ time: { title: "time", description: "The pause duration, for example `500ms` or `1s`." },
1868
+ strength: { title: "strength", description: "The relative pause strength." }
1869
+ }
1870
+ },
1871
+ "mstts:express-as": {
1872
+ title: "Express-as",
1873
+ description: "Applies a speaking style, style degree, or role to the enclosed text.",
1874
+ parameters: {
1875
+ style: {
1876
+ title: "style",
1877
+ description: "The speaking style supported by the selected voice, such as `cheerful`."
1878
+ },
1879
+ styledegree: { title: "styledegree", description: "Controls the intensity of the selected speaking style." },
1880
+ role: { title: "role", description: "Changes the speaking role when supported by the selected voice." }
1881
+ }
1882
+ },
1883
+ "say-as": {
1884
+ title: "Say-as",
1885
+ description: "Controls how the enclosed text is interpreted and spoken.",
1886
+ parameters: {
1887
+ "interpret-as": {
1888
+ title: "interpret-as",
1889
+ description: "Specifies the interpretation, such as characters, digits, date, or time."
1890
+ },
1891
+ format: { title: "format", description: "Provides a format hint for the selected interpretation." },
1892
+ detail: {
1893
+ title: "detail",
1894
+ description: "Provides an additional detail hint for the selected interpretation."
1895
+ }
1896
+ }
1897
+ },
1898
+ phoneme: {
1899
+ title: "Phoneme",
1900
+ description: "Replaces normal pronunciation with the supplied phonetic pronunciation.",
1901
+ parameters: {
1902
+ alphabet: { title: "alphabet", description: "The phonetic alphabet used by the `ph` value." },
1903
+ ph: { title: "ph", description: "The phonetic pronunciation for the enclosed text." }
1904
+ }
1905
+ },
1906
+ emphasis: {
1907
+ title: "Emphasis",
1908
+ description: "Adds emphasis to the enclosed text.",
1909
+ parameters: {
1910
+ level: { title: "level", description: "Controls the amount of emphasis." }
1911
+ }
1912
+ },
1913
+ audio: {
1914
+ title: "Audio",
1915
+ description: "Plays an audio file as part of the synthesized output.",
1916
+ parameters: {
1917
+ src: { title: "src", description: "The URI of the audio file." },
1918
+ desc: { title: "desc", description: "Alternative text to use if the audio cannot be played." },
1919
+ clipBegin: { title: "clipBegin", description: "The starting offset within the audio file." },
1920
+ clipEnd: { title: "clipEnd", description: "The ending offset within the audio file." },
1921
+ speed: { title: "speed", description: "The playback speed of the audio file." },
1922
+ repeatCount: { title: "repeatCount", description: "The number of times to repeat the audio." },
1923
+ repeatDuration: {
1924
+ title: "repeatDuration",
1925
+ description: "The total duration for which the audio may repeat."
1926
+ },
1927
+ soundLevel: { title: "soundLevel", description: "The audio volume adjustment in decibels." }
1928
+ }
1929
+ },
1930
+ sub: {
1931
+ title: "Substitution",
1932
+ description: "Substitutes the alias text when speaking the enclosed text.",
1933
+ parameters: {
1934
+ alias: { title: "alias", description: "The text to speak instead of the enclosed text." }
1935
+ }
1936
+ },
1937
+ lang: {
1938
+ title: "Language",
1939
+ description: "Changes the language used for the enclosed text.",
1940
+ parameters: {
1941
+ "xml:lang": { title: "xml:lang", description: "The BCP-47 language tag." }
1942
+ }
1943
+ },
1944
+ mark: {
1945
+ title: "Mark",
1946
+ description: "Inserts a custom marker into the synthesized audio stream.",
1947
+ parameters: {
1948
+ name: { title: "name", description: "The application-defined marker name." }
1949
+ }
1950
+ },
1951
+ bookmark: {
1952
+ title: "Bookmark",
1953
+ description: "Inserts a bookmark marker into the synthesized audio stream.",
1954
+ parameters: {
1955
+ mark: { title: "mark", description: "The application-defined bookmark name." }
1956
+ }
1957
+ },
1958
+ lexicon: {
1959
+ title: "Lexicon",
1960
+ description: "Associates a pronunciation lexicon with the synthesized document.",
1961
+ parameters: {
1962
+ uri: { title: "uri", description: "The URI of the pronunciation lexicon." }
1963
+ }
1964
+ },
1965
+ p: { title: "Paragraph", description: "Groups text into a paragraph.", parameters: {} },
1966
+ s: { title: "Sentence", description: "Groups text into a sentence.", parameters: {} },
1967
+ w: { title: "Word", description: "Groups text into a word.", parameters: {} },
1968
+ "mstts:silence": {
1969
+ title: "Silence",
1970
+ description: "Adds a specified silence before or after text or at a punctuation boundary.",
1971
+ parameters: {
1972
+ type: { title: "type", description: "The silence position or punctuation boundary." },
1973
+ value: { title: "value", description: "The silence duration, for example `300ms`." }
1974
+ }
1975
+ },
1976
+ "mstts:viseme": {
1977
+ title: "Viseme",
1978
+ description: "Requests viseme events for the synthesized audio.",
1979
+ parameters: {
1980
+ type: { title: "type", description: "The viseme event format." }
1981
+ }
1982
+ }
1983
+ }
1984
+ }
1985
+ };
1986
+
1987
+ // ../ssml-editor-react/src/ssmlHover.ts
1988
+ var {
1989
+ BREAK_STRENGTH_PRESETS: BREAK_STRENGTH_PRESETS2,
1990
+ EMPHASIS_LEVEL_PRESETS: EMPHASIS_LEVEL_PRESETS2,
1991
+ PHONEME_ALPHABET_PRESETS: PHONEME_ALPHABET_PRESETS2,
1992
+ PROSODY_RATE_VALUES: PROSODY_RATE_VALUES2,
1993
+ PROSODY_VOLUME_PRESETS: PROSODY_VOLUME_PRESETS2,
1994
+ SILENCE_TYPE_PRESETS: SILENCE_TYPE_PRESETS2,
1995
+ SSML_PRESET_EXAMPLES: SSML_PRESET_EXAMPLES2,
1996
+ VISEME_TYPE_PRESETS: VISEME_TYPE_PRESETS2
1997
+ } = ssmlPresets_exports;
1998
+ var SSML_TAG_DEFINITIONS = [
1999
+ {
2000
+ name: "voice",
2001
+ description: "Selects the voice and optional voice effect used to synthesize the enclosed text.",
2002
+ parameters: [
2003
+ {
2004
+ name: "name",
2005
+ description: "The voice name, such as `en-US-JennyNeural`.",
2006
+ example: "en-US-JennyNeural"
2007
+ },
2008
+ {
2009
+ name: "effect",
2010
+ description: "An optional voice effect, such as `eq_car`."
2011
+ }
2012
+ ]
2013
+ },
2014
+ {
2015
+ name: "prosody",
2016
+ description: "Changes the speaking rate, pitch, volume, or pitch contour of the enclosed text.",
2017
+ parameters: [
2018
+ {
2019
+ name: "rate",
2020
+ description: "Controls speaking speed.",
2021
+ values: PROSODY_RATE_VALUES2,
2022
+ example: SSML_PRESET_EXAMPLES2.prosodyRate
2023
+ },
2024
+ {
2025
+ name: "pitch",
2026
+ description: "Adjusts pitch using a named value, percentage, frequency, or semitone value.",
2027
+ example: SSML_PRESET_EXAMPLES2.prosodyPitch
2028
+ },
2029
+ {
2030
+ name: "volume",
2031
+ description: "Controls loudness using a named value, percentage, or decibel value.",
2032
+ values: PROSODY_VOLUME_PRESETS2,
2033
+ example: SSML_PRESET_EXAMPLES2.prosodyVolume
2034
+ },
2035
+ {
2036
+ name: "contour",
2037
+ description: "Defines a sequence of relative pitch changes at positions in the text.",
2038
+ example: "(0%,+0st) (100%,+2st)"
2039
+ },
2040
+ {
2041
+ name: "range",
2042
+ description: "Adjusts the pitch range of the voice.",
2043
+ example: "+2st"
2044
+ }
2045
+ ]
2046
+ },
2047
+ {
2048
+ name: "break",
2049
+ description: "Inserts a pause between words or other spoken content.",
2050
+ parameters: [
2051
+ {
2052
+ name: "time",
2053
+ description: "The pause duration, for example `500ms` or `1s`.",
2054
+ example: SSML_PRESET_EXAMPLES2.breakTime
2055
+ },
2056
+ {
2057
+ name: "strength",
2058
+ description: "The relative pause strength.",
2059
+ values: BREAK_STRENGTH_PRESETS2
2060
+ }
2061
+ ]
2062
+ },
2063
+ {
2064
+ name: "mstts:express-as",
2065
+ aliases: ["express-as", "expressAs"],
2066
+ description: "Applies a speaking style, style degree, or role to the enclosed text.",
2067
+ parameters: [
2068
+ {
2069
+ name: "style",
2070
+ description: "The speaking style supported by the selected voice, such as `cheerful`.",
2071
+ example: SSML_PRESET_EXAMPLES2.expressAsStyle
2072
+ },
2073
+ {
2074
+ name: "styledegree",
2075
+ aliases: ["style-degree", "styleDegree"],
2076
+ description: "Controls the intensity of the selected speaking style.",
2077
+ example: "1.5"
2078
+ },
2079
+ {
2080
+ name: "role",
2081
+ description: "Changes the speaking role when supported by the selected voice.",
2082
+ example: "YoungAdultFemale"
2083
+ }
2084
+ ]
2085
+ },
2086
+ {
2087
+ name: "say-as",
2088
+ aliases: ["sayAs"],
2089
+ description: "Controls how the enclosed text is interpreted and spoken.",
2090
+ parameters: [
2091
+ {
2092
+ name: "interpret-as",
2093
+ description: "Specifies the interpretation, such as characters, digits, date, or time.",
2094
+ example: "characters"
2095
+ },
2096
+ {
2097
+ name: "format",
2098
+ description: "Provides a format hint for the selected interpretation."
2099
+ },
2100
+ {
2101
+ name: "detail",
2102
+ description: "Provides an additional detail hint for the selected interpretation."
2103
+ }
2104
+ ]
2105
+ },
2106
+ {
2107
+ name: "phoneme",
2108
+ description: "Replaces normal pronunciation with the supplied phonetic pronunciation.",
2109
+ parameters: [
2110
+ {
2111
+ name: "alphabet",
2112
+ description: "The phonetic alphabet used by the `ph` value.",
2113
+ values: PHONEME_ALPHABET_PRESETS2,
2114
+ example: SSML_PRESET_EXAMPLES2.phonemeAlphabet
2115
+ },
2116
+ {
2117
+ name: "ph",
2118
+ description: "The phonetic pronunciation for the enclosed text.",
2119
+ example: "h\u0259\u02C8lo\u028A"
2120
+ }
2121
+ ]
2122
+ },
2123
+ {
2124
+ name: "emphasis",
2125
+ description: "Adds emphasis to the enclosed text.",
2126
+ parameters: [
2127
+ {
2128
+ name: "level",
2129
+ description: "Controls the amount of emphasis.",
2130
+ values: EMPHASIS_LEVEL_PRESETS2
2131
+ }
2132
+ ]
2133
+ },
2134
+ {
2135
+ name: "audio",
2136
+ description: "Plays an audio file as part of the synthesized output.",
2137
+ parameters: [
2138
+ {
2139
+ name: "src",
2140
+ description: "The URI of the audio file.",
2141
+ example: "https://example.com/intro.wav"
2142
+ },
2143
+ {
2144
+ name: "desc",
2145
+ description: "Alternative text to use if the audio cannot be played."
2146
+ },
2147
+ {
2148
+ name: "clipBegin",
2149
+ description: "The starting offset within the audio file.",
2150
+ example: "0s"
2151
+ },
2152
+ {
2153
+ name: "clipEnd",
2154
+ description: "The ending offset within the audio file.",
2155
+ example: "5s"
2156
+ },
2157
+ {
2158
+ name: "speed",
2159
+ description: "The playback speed of the audio file.",
2160
+ example: "1.0"
2161
+ },
2162
+ {
2163
+ name: "repeatCount",
2164
+ description: "The number of times to repeat the audio.",
2165
+ example: "2"
2166
+ },
2167
+ {
2168
+ name: "repeatDuration",
2169
+ description: "The total duration for which the audio may repeat.",
2170
+ example: "10s"
2171
+ },
2172
+ {
2173
+ name: "soundLevel",
2174
+ description: "The audio volume adjustment in decibels.",
2175
+ example: "-3dB"
2176
+ }
2177
+ ]
2178
+ },
2179
+ {
2180
+ name: "sub",
2181
+ description: "Substitutes the alias text when speaking the enclosed text.",
2182
+ parameters: [
2183
+ {
2184
+ name: "alias",
2185
+ description: "The text to speak instead of the enclosed text.",
2186
+ example: "World Wide Web"
2187
+ }
2188
+ ]
2189
+ },
2190
+ {
2191
+ name: "lang",
2192
+ description: "Changes the language used for the enclosed text.",
2193
+ parameters: [
2194
+ {
2195
+ name: "xml:lang",
2196
+ aliases: ["lang"],
2197
+ description: "The BCP-47 language tag.",
2198
+ example: "ja-JP"
2199
+ }
2200
+ ]
2201
+ },
2202
+ {
2203
+ name: "mark",
2204
+ description: "Inserts a custom marker into the synthesized audio stream.",
2205
+ parameters: [
2206
+ {
2207
+ name: "name",
2208
+ description: "The application-defined marker name.",
2209
+ example: "chapter-1"
2210
+ }
2211
+ ]
2212
+ },
2213
+ {
2214
+ name: "bookmark",
2215
+ description: "Inserts a bookmark marker into the synthesized audio stream.",
2216
+ parameters: [
2217
+ {
2218
+ name: "mark",
2219
+ description: "The application-defined bookmark name.",
2220
+ example: "chapter-1"
2221
+ }
2222
+ ]
2223
+ },
2224
+ {
2225
+ name: "lexicon",
2226
+ description: "Associates a pronunciation lexicon with the synthesized document.",
2227
+ parameters: [
2228
+ {
2229
+ name: "uri",
2230
+ description: "The URI of the pronunciation lexicon.",
2231
+ example: "https://example.com/lexicon.pls"
2232
+ }
2233
+ ]
2234
+ },
2235
+ {
2236
+ name: "p",
2237
+ description: "Groups text into a paragraph.",
2238
+ parameters: []
2239
+ },
2240
+ {
2241
+ name: "s",
2242
+ description: "Groups text into a sentence.",
2243
+ parameters: []
2244
+ },
2245
+ {
2246
+ name: "w",
2247
+ description: "Groups text into a word.",
2248
+ parameters: []
2249
+ },
2250
+ {
2251
+ name: "mstts:silence",
2252
+ aliases: ["silence"],
2253
+ description: "Adds a specified silence before or after text or at a punctuation boundary.",
2254
+ parameters: [
2255
+ {
2256
+ name: "type",
2257
+ description: "The silence position or punctuation boundary.",
2258
+ values: SILENCE_TYPE_PRESETS2
2259
+ },
2260
+ {
2261
+ name: "value",
2262
+ description: "The silence duration, for example `300ms`.",
2263
+ example: SSML_PRESET_EXAMPLES2.silenceValue
2264
+ }
2265
+ ]
2266
+ },
2267
+ {
2268
+ name: "mstts:viseme",
2269
+ aliases: ["viseme"],
2270
+ description: "Requests viseme events for the synthesized audio.",
2271
+ parameters: [
2272
+ {
2273
+ name: "type",
2274
+ description: "The viseme event format.",
2275
+ values: VISEME_TYPE_PRESETS2
2276
+ }
2277
+ ]
2278
+ }
2279
+ ];
2280
+ var definitionsByName = /* @__PURE__ */ new Map();
2281
+ for (const definition of SSML_TAG_DEFINITIONS) {
2282
+ definitionsByName.set(definition.name, definition);
2283
+ for (const alias of definition.aliases ?? []) {
2284
+ definitionsByName.set(alias, definition);
2285
+ }
2286
+ }
2287
+ function isXmlNameStart2(value) {
2288
+ return value !== void 0 && /[A-Za-z_]/.test(value);
2289
+ }
2290
+ function isXmlNameCharacter2(value) {
2291
+ return value !== void 0 && /[A-Za-z0-9_.:-]/.test(value);
2292
+ }
2293
+ function isXmlWhitespace2(value) {
2294
+ return value === " " || value === " " || value === "\r" || value === "\n";
2295
+ }
2296
+ function positionToOffset(source, lineNumber, column) {
2297
+ if (!Number.isInteger(lineNumber) || !Number.isInteger(column) || lineNumber < 1 || column < 1) {
2298
+ return void 0;
2299
+ }
2300
+ let lineStart = 0;
2301
+ for (let line = 1; line < lineNumber; line += 1) {
2302
+ const newline = source.indexOf("\n", lineStart);
2303
+ if (newline === -1) {
2304
+ return void 0;
2305
+ }
2306
+ lineStart = newline + 1;
2307
+ }
2308
+ const lineEnd = source.indexOf("\n", lineStart);
2309
+ const lineLength = lineEnd === -1 ? source.length - lineStart : lineEnd - lineStart;
2310
+ if (column > lineLength + 1) {
2311
+ return void 0;
2312
+ }
2313
+ return lineStart + column - 1;
2314
+ }
2315
+ function offsetToPosition(source, offset) {
2316
+ const lastNewline = source.lastIndexOf("\n", offset - 1);
2317
+ const lineNumber = source.slice(0, offset).split("\n").length;
2318
+ return {
2319
+ lineNumber,
2320
+ column: offset - lastNewline
2321
+ };
2322
+ }
2323
+ function toRange(source, token) {
2324
+ const start = offsetToPosition(source, token.start);
2325
+ const end = offsetToPosition(source, token.end);
2326
+ return {
2327
+ startLineNumber: start.lineNumber,
2328
+ startColumn: start.column,
2329
+ endLineNumber: end.lineNumber,
2330
+ endColumn: end.column
2331
+ };
2332
+ }
2333
+ function containsOffset(token, offset) {
2334
+ return offset >= token.start && offset < token.end;
2335
+ }
2336
+ function findTagEnd3(source, start) {
2337
+ let quote;
2338
+ for (let index = start; index < source.length; index += 1) {
2339
+ const character = source[index];
2340
+ if (quote !== void 0) {
2341
+ if (character === quote) {
2342
+ quote = void 0;
2343
+ }
2344
+ } else if (character === '"' || character === "'") {
2345
+ quote = character;
2346
+ } else if (character === ">") {
2347
+ return index;
2348
+ }
2349
+ }
2350
+ return void 0;
2351
+ }
2352
+ function parseTag(source, start, contentEnd, tokenEnd) {
2353
+ let index = start + 1;
2354
+ let closing = false;
2355
+ if (source[index] === "/") {
2356
+ closing = true;
2357
+ index += 1;
2358
+ }
2359
+ while (index < contentEnd && isXmlWhitespace2(source[index])) {
2360
+ index += 1;
2361
+ }
2362
+ if (!isXmlNameStart2(source[index])) {
2363
+ return void 0;
2364
+ }
2365
+ const nameStart = index;
2366
+ index += 1;
2367
+ while (index < contentEnd && isXmlNameCharacter2(source[index])) {
2368
+ index += 1;
2369
+ }
2370
+ const nameEnd = index;
2371
+ const attributes = [];
2372
+ if (!closing) {
2373
+ while (index < contentEnd) {
2374
+ while (index < contentEnd && isXmlWhitespace2(source[index])) {
2375
+ index += 1;
2376
+ }
2377
+ if (index >= contentEnd || source[index] === "/") {
2378
+ break;
2379
+ }
2380
+ if (!isXmlNameStart2(source[index])) {
2381
+ index += 1;
2382
+ continue;
2383
+ }
2384
+ const attributeStart = index;
2385
+ index += 1;
2386
+ while (index < contentEnd && isXmlNameCharacter2(source[index])) {
2387
+ index += 1;
2388
+ }
2389
+ const attributeEnd = index;
2390
+ while (index < contentEnd && isXmlWhitespace2(source[index])) {
2391
+ index += 1;
2392
+ }
2393
+ let value;
2394
+ if (source[index] === "=") {
2395
+ index += 1;
2396
+ while (index < contentEnd && isXmlWhitespace2(source[index])) {
2397
+ index += 1;
2398
+ }
2399
+ const quote = source[index];
2400
+ if (quote === '"' || quote === "'") {
2401
+ index += 1;
2402
+ const valueStart = index;
2403
+ while (index < contentEnd && source[index] !== quote) {
2404
+ index += 1;
2405
+ }
2406
+ value = { start: valueStart, end: index };
2407
+ if (index < contentEnd) {
2408
+ index += 1;
2409
+ }
2410
+ } else {
2411
+ const valueStart = index;
2412
+ while (index < contentEnd && !isXmlWhitespace2(source[index]) && source[index] !== "/") {
2413
+ index += 1;
2414
+ }
2415
+ value = { start: valueStart, end: index };
2416
+ }
2417
+ }
2418
+ attributes.push({
2419
+ name: { start: attributeStart, end: attributeEnd },
2420
+ value
2421
+ });
2422
+ }
2423
+ }
2424
+ return {
2425
+ name: source.slice(nameStart, nameEnd),
2426
+ nameRange: { start: nameStart, end: nameEnd },
2427
+ start,
2428
+ end: tokenEnd,
2429
+ closing,
2430
+ attributes
2431
+ };
2432
+ }
2433
+ function findTagAtOffset(source, offset) {
2434
+ let searchStart = 0;
2435
+ while (searchStart < source.length) {
2436
+ const start = source.indexOf("<", searchStart);
2437
+ if (start === -1 || start > offset) {
2438
+ return void 0;
2439
+ }
2440
+ if (source.startsWith("<!--", start)) {
2441
+ const commentEnd = source.indexOf("-->", start + 4);
2442
+ const tokenEnd2 = commentEnd === -1 ? source.length : commentEnd + 3;
2443
+ if (offset < tokenEnd2) {
2444
+ return void 0;
2445
+ }
2446
+ searchStart = tokenEnd2;
2447
+ continue;
2448
+ }
2449
+ if (source.startsWith("<![CDATA[", start)) {
2450
+ const cdataEnd = source.indexOf("]]>", start + 9);
2451
+ const tokenEnd2 = cdataEnd === -1 ? source.length : cdataEnd + 3;
2452
+ if (offset < tokenEnd2) {
2453
+ return void 0;
2454
+ }
2455
+ searchStart = tokenEnd2;
2456
+ continue;
2457
+ }
2458
+ if (source.startsWith("<?", start)) {
2459
+ const processingEnd = source.indexOf("?>", start + 2);
2460
+ const tokenEnd2 = processingEnd === -1 ? source.length : processingEnd + 2;
2461
+ if (offset < tokenEnd2) {
2462
+ return void 0;
2463
+ }
2464
+ searchStart = tokenEnd2;
2465
+ continue;
2466
+ }
2467
+ const tagEnd = findTagEnd3(source, start + 1);
2468
+ const contentEnd = tagEnd ?? source.length;
2469
+ const tokenEnd = tagEnd === void 0 ? source.length : tagEnd + 1;
2470
+ if (offset < tokenEnd) {
2471
+ return parseTag(source, start, contentEnd, tokenEnd);
2472
+ }
2473
+ if (tagEnd === void 0) {
2474
+ return void 0;
2475
+ }
2476
+ searchStart = tokenEnd;
2477
+ }
2478
+ return void 0;
2479
+ }
2480
+ function findParameter(definition, name) {
2481
+ return definition.parameters.find(
2482
+ (parameter) => parameter.name === name || parameter.aliases?.includes(name) === true
2483
+ );
2484
+ }
2485
+ function getSsmlTagDefinition(name) {
2486
+ return definitionsByName.get(name);
2487
+ }
2488
+ function findSsmlHoverTarget(source, lineNumber, column) {
2489
+ const offset = positionToOffset(source, lineNumber, column);
2490
+ if (offset === void 0) {
2491
+ return void 0;
2492
+ }
2493
+ const tag = findTagAtOffset(source, offset);
2494
+ if (!tag) {
2495
+ return void 0;
2496
+ }
2497
+ const definition = getSsmlTagDefinition(tag.name);
2498
+ if (!definition) {
2499
+ return void 0;
2500
+ }
2501
+ if (containsOffset(tag.nameRange, offset)) {
2502
+ return {
2503
+ kind: "tag",
2504
+ tagName: tag.name,
2505
+ isClosingTag: tag.closing,
2506
+ definition,
2507
+ range: toRange(source, tag.nameRange)
2508
+ };
2509
+ }
2510
+ for (const attribute of tag.attributes) {
2511
+ if (containsOffset(attribute.name, offset)) {
2512
+ const parameter = findParameter(definition, source.slice(attribute.name.start, attribute.name.end));
2513
+ if (!parameter) {
2514
+ return void 0;
2515
+ }
2516
+ return {
2517
+ kind: "parameter",
2518
+ tagName: tag.name,
2519
+ isClosingTag: tag.closing,
2520
+ definition,
2521
+ parameter,
2522
+ range: toRange(source, attribute.name)
2523
+ };
2524
+ }
2525
+ if (attribute.value && containsOffset(attribute.value, offset)) {
2526
+ const parameter = findParameter(definition, source.slice(attribute.name.start, attribute.name.end));
2527
+ if (!parameter) {
2528
+ return void 0;
2529
+ }
2530
+ return {
2531
+ kind: "parameter-value",
2532
+ tagName: tag.name,
2533
+ isClosingTag: tag.closing,
2534
+ definition,
2535
+ parameter,
2536
+ range: toRange(source, attribute.value)
2537
+ };
2538
+ }
2539
+ }
2540
+ return void 0;
2541
+ }
2542
+ function code(value) {
2543
+ return `\`${value.replace(/\\/g, "\\\\").replace(/`/g, "\\`")}\``;
2544
+ }
2545
+ function formatParameter(parameter, tagName, locale) {
2546
+ const localizedParameter = SSML_HOVER_COPY[locale].tags[tagName]?.parameters[parameter.name];
2547
+ const description = localizedParameter?.description ?? parameter.description;
2548
+ const values = parameter.values && parameter.values.length > 0 ? ` ${SSML_HOVER_COPY[locale].allowedValues}: ${parameter.values.map(code).join(", ")}.` : "";
2549
+ const example = parameter.example ? ` ${SSML_HOVER_COPY[locale].example}: ${code(parameter.example)}.` : "";
2550
+ return `- ${code(parameter.name)}: ${description}${values}${example}`;
2551
+ }
2552
+ function formatSsmlHover(target, locale = "en") {
2553
+ const localizedTag = SSML_HOVER_COPY[locale].tags[target.definition.name];
2554
+ const tagTitle = localizedTag?.title ?? target.definition.name;
2555
+ const tagDescription = localizedTag?.description ?? target.definition.description;
2556
+ const tagSyntax = target.isClosingTag ? `</${target.tagName}>` : `<${target.tagName}>`;
2557
+ const lines = [`### ${code(tagSyntax)}`, "", `**${tagTitle}**`, "", tagDescription];
2558
+ if (target.parameter) {
2559
+ const localizedParameter = localizedTag?.parameters[target.parameter.name];
2560
+ const parameterTitle = localizedParameter?.title ?? target.parameter.name;
2561
+ const parameterDescription = localizedParameter?.description ?? target.parameter.description;
2562
+ lines.push("", `**${SSML_HOVER_COPY[locale].parameterHeading} ${code(parameterTitle)}**`, "", parameterDescription);
2563
+ if (target.parameter.values && target.parameter.values.length > 0) {
2564
+ lines.push("", `${SSML_HOVER_COPY[locale].allowedValues}: ${target.parameter.values.map(code).join(", ")}.`);
2565
+ }
2566
+ if (target.parameter.example) {
2567
+ lines.push("", `${SSML_HOVER_COPY[locale].example}: ${code(target.parameter.example)}.`);
2568
+ }
2569
+ } else if (target.definition.parameters.length > 0) {
2570
+ lines.push(
2571
+ "",
2572
+ `**${SSML_HOVER_COPY[locale].parametersHeading}**`,
2573
+ "",
2574
+ ...target.definition.parameters.map((parameter) => formatParameter(parameter, target.definition.name, locale))
2575
+ );
2576
+ } else {
2577
+ lines.push("", SSML_HOVER_COPY[locale].noParameters);
2578
+ }
2579
+ return lines.join("\n");
2580
+ }
2581
+
2582
+ // ../ssml-editor-react/src/constants/ui.ts
2583
+ var SSML_INSERTION_MODES = {
2584
+ insert: "insert",
2585
+ wrap: "wrap"
2586
+ };
2587
+
2588
+ // ../ssml-editor-react/src/ssmlInsertion.ts
2589
+ function isLineStart(value, offset) {
2590
+ return offset === 0 || value[offset - 1] === "\n" || value[offset - 1] === "\r";
2591
+ }
2592
+ function isLineEnd(value, offset) {
2593
+ return offset === value.length || value[offset] === "\n" || value[offset] === "\r";
2594
+ }
2595
+ function getLineBreakAt(value, offset) {
2596
+ if (value.startsWith("\r\n", offset)) {
2597
+ return "\r\n";
2598
+ }
2599
+ if (value[offset] === "\n" || value[offset] === "\r") {
2600
+ return value[offset];
2601
+ }
2602
+ return "";
2603
+ }
2604
+ function startsWithLineBreak(value) {
2605
+ return value.startsWith("\n") || value.startsWith("\r");
2606
+ }
2607
+ function endsWithLineBreak(value) {
2608
+ return value.endsWith("\n") || value.endsWith("\r");
2609
+ }
2610
+ function createSsmlInsertionEdit(source, startOffset, endOffset, template, eol = "\n", selectedText = startOffset === endOffset ? "" : source.slice(startOffset, endOffset)) {
2611
+ if (template.mode === SSML_INSERTION_MODES.wrap) {
2612
+ const trailingLineBreak2 = getLineBreakAt(source, endOffset) === "" ? eol : "";
2613
+ return {
2614
+ replacement: `${template.prefix}${selectedText}${template.suffix}${trailingLineBreak2}`,
2615
+ selectionOffset: template.prefix.length
2616
+ };
2617
+ }
2618
+ const followingLineBreak = getLineBreakAt(source, endOffset);
2619
+ const leadingLineBreak = !isLineStart(source, startOffset) && !startsWithLineBreak(template.prefix) ? eol : "";
2620
+ const needsTrailingLineBreak = selectedText.length > 0 ? !selectedText.startsWith("\n") && !selectedText.startsWith("\r") : !isLineEnd(source, endOffset) || followingLineBreak === "";
2621
+ const trailingLineBreak = needsTrailingLineBreak && !endsWithLineBreak(template.prefix) ? eol : "";
2622
+ const insertionPrefix = `${leadingLineBreak}${template.prefix}`;
2623
+ return {
2624
+ replacement: `${insertionPrefix}${trailingLineBreak}${selectedText}`,
2625
+ selectionOffset: insertionPrefix.length + trailingLineBreak.length + (selectedText.length === 0 && trailingLineBreak === "" ? followingLineBreak.length : 0)
2626
+ };
2627
+ }
2628
+
2629
+ // ../ssml-editor-react/src/ssmlInsertions.ts
2630
+ function createInsertionOptions(values, descriptions) {
2631
+ return values.map((value) => ({
2632
+ value,
2633
+ labels: { ja: value, en: value },
2634
+ ...descriptions?.[value] ? { descriptions: descriptions[value] } : {}
2635
+ }));
2636
+ }
2637
+ var SSML_INSERTIONS = [
2638
+ {
2639
+ id: "break",
2640
+ icon: "\u23F8",
2641
+ tagName: "break",
2642
+ selfClosing: true,
2643
+ labels: { ja: "\u9593", en: "Break" },
2644
+ descriptions: {
2645
+ ja: "\u6307\u5B9A\u3057\u305F\u6642\u9593\u3060\u3051\u7121\u97F3\u306E\u9593\u3092\u633F\u5165\u3057\u307E\u3059\u3002",
2646
+ en: "Inserts a silent pause for the selected duration."
2647
+ },
2648
+ parameterDescription: {
2649
+ ja: "\u7121\u97F3\u306B\u3059\u308B\u6642\u9593\u3092\u9078\u629E\u3057\u307E\u3059\u3002",
2650
+ en: "Selects the duration of the silent pause."
2651
+ },
2652
+ options: createInsertionOptions(BREAK_TIME_PRESETS, BREAK_TIME_DESCRIPTIONS),
2653
+ createTemplate: (value) => ({
2654
+ prefix: `<break time="${value}"/>`,
2655
+ suffix: "",
2656
+ mode: "insert"
2657
+ })
2658
+ },
2659
+ {
2660
+ id: "emphasis",
2661
+ icon: "\u2726",
2662
+ tagName: "emphasis",
2663
+ labels: { ja: "\u5F37\u8ABF", en: "Emphasis" },
2664
+ descriptions: {
2665
+ ja: "\u9078\u629E\u7BC4\u56F2\u306E\u5F37\u8ABF\u30EC\u30D9\u30EB\u3092\u5909\u66F4\u3057\u307E\u3059\u3002",
2666
+ en: "Changes the emphasis level of the selected text."
2667
+ },
2668
+ parameterDescription: {
2669
+ ja: "\u9078\u629E\u7BC4\u56F2\u306E\u5F37\u8ABF\u30EC\u30D9\u30EB\u3092\u9078\u629E\u3057\u307E\u3059\u3002",
2670
+ en: "Selects the emphasis level for the selected text."
2671
+ },
2672
+ options: createInsertionOptions(EMPHASIS_LEVEL_PRESETS, EMPHASIS_LEVEL_DESCRIPTIONS),
2673
+ createTemplate: (value) => ({
2674
+ prefix: `<emphasis level="${value}">`,
2675
+ suffix: "</emphasis>",
2676
+ mode: "wrap"
2677
+ })
2678
+ },
2679
+ {
2680
+ id: "rate",
2681
+ icon: "\u2195",
2682
+ tagName: "prosody",
2683
+ labels: { ja: "\u901F\u5EA6", en: "Rate" },
2684
+ descriptions: {
2685
+ ja: "\u9078\u629E\u7BC4\u56F2\u306E\u8AAD\u307F\u4E0A\u3052\u901F\u5EA6\u3092\u5909\u66F4\u3057\u307E\u3059\u3002",
2686
+ en: "Changes the speech rate of the selected text."
2687
+ },
2688
+ parameterDescription: {
2689
+ ja: "\u9078\u629E\u7BC4\u56F2\u306E\u8AAD\u307F\u4E0A\u3052\u901F\u5EA6\u3092\u9078\u629E\u3057\u307E\u3059\u3002",
2690
+ en: "Selects the speech rate for the selected text."
2691
+ },
2692
+ options: createInsertionOptions(PROSODY_RATE_PRESETS, PROSODY_RATE_DESCRIPTIONS),
2693
+ createTemplate: (value) => ({
2694
+ prefix: `<prosody rate="${value}">`,
2695
+ suffix: "</prosody>",
2696
+ mode: "wrap"
2697
+ })
2698
+ },
2699
+ {
2700
+ id: "pitch",
2701
+ icon: "\u2197",
2702
+ tagName: "prosody",
2703
+ labels: { ja: "\u9AD8\u3055", en: "Pitch" },
2704
+ descriptions: {
2705
+ ja: "\u9078\u629E\u7BC4\u56F2\u306E\u58F0\u306E\u9AD8\u3055\u3092\u5909\u66F4\u3057\u307E\u3059\u3002",
2706
+ en: "Changes the pitch of the selected text."
2707
+ },
2708
+ parameterDescription: {
2709
+ ja: "\u9078\u629E\u7BC4\u56F2\u306E\u58F0\u306E\u9AD8\u3055\u3092\u534A\u97F3\u5358\u4F4D\u3067\u9078\u629E\u3057\u307E\u3059\u3002",
2710
+ en: "Selects the pitch adjustment in semitone steps."
2711
+ },
2712
+ options: createInsertionOptions(PROSODY_PITCH_PRESETS, PROSODY_PITCH_DESCRIPTIONS),
2713
+ createTemplate: (value) => ({
2714
+ prefix: `<prosody pitch="${value}">`,
2715
+ suffix: "</prosody>",
2716
+ mode: "wrap"
2717
+ })
2718
+ },
2719
+ {
2720
+ id: "volume",
2721
+ icon: "\u{1F50A}",
2722
+ tagName: "prosody",
2723
+ labels: { ja: "\u97F3\u91CF", en: "Volume" },
2724
+ descriptions: {
2725
+ ja: "\u9078\u629E\u7BC4\u56F2\u306E\u97F3\u91CF\u3092\u5909\u66F4\u3057\u307E\u3059\u3002",
2726
+ en: "Changes the volume of the selected text."
2727
+ },
2728
+ parameterDescription: {
2729
+ ja: "\u9078\u629E\u7BC4\u56F2\u306E\u97F3\u91CF\u30EC\u30D9\u30EB\u3092\u9078\u629E\u3057\u307E\u3059\u3002",
2730
+ en: "Selects the volume level for the selected text."
2731
+ },
2732
+ options: createInsertionOptions(PROSODY_VOLUME_PRESETS, PROSODY_VOLUME_DESCRIPTIONS),
2733
+ createTemplate: (value) => ({
2734
+ prefix: `<prosody volume="${value}">`,
2735
+ suffix: "</prosody>",
2736
+ mode: "wrap"
2737
+ })
2738
+ },
2739
+ {
2740
+ id: "emotion",
2741
+ icon: "\u263A",
2742
+ tagName: "mstts:express-as",
2743
+ labels: { ja: "\u611F\u60C5", en: "Emotion" },
2744
+ descriptions: {
2745
+ ja: "\u9078\u629E\u7BC4\u56F2\u306B\u97F3\u58F0\u306E\u611F\u60C5\u30B9\u30BF\u30A4\u30EB\u3092\u9069\u7528\u3057\u307E\u3059\u3002",
2746
+ en: "Applies a voice emotion style to the selected text."
2747
+ },
2748
+ parameterDescription: {
2749
+ ja: "\u9078\u629E\u7BC4\u56F2\u306B\u9069\u7528\u3059\u308B\u97F3\u58F0\u306E\u611F\u60C5\u30B9\u30BF\u30A4\u30EB\u3092\u9078\u629E\u3057\u307E\u3059\u3002",
2750
+ en: "Selects the voice emotion style to apply."
2751
+ },
2752
+ options: createInsertionOptions(EXPRESS_AS_STYLE_PRESETS, EXPRESS_AS_STYLE_DESCRIPTIONS),
2753
+ createTemplate: (value) => ({
2754
+ prefix: `<mstts:express-as style="${value}">`,
2755
+ suffix: "</mstts:express-as>",
2756
+ mode: "wrap"
2757
+ })
2758
+ },
2759
+ {
2760
+ id: "say-as",
2761
+ icon: "Aa",
2762
+ tagName: "say-as",
2763
+ labels: { ja: "\u8AAD\u307F\u4E0A\u3052", en: "Say as" },
2764
+ descriptions: {
2765
+ ja: "\u6570\u5B57\u3084\u65E5\u4ED8\u306A\u3069\u306E\u8AAD\u307F\u4E0A\u3052\u65B9\u3092\u6307\u5B9A\u3057\u307E\u3059\u3002",
2766
+ en: "Specifies how values such as numbers or dates are spoken."
2767
+ },
2768
+ parameterDescription: {
2769
+ ja: "\u9078\u629E\u7BC4\u56F2\u306E\u8AAD\u307F\u4E0A\u3052\u65B9\u3092\u9078\u629E\u3057\u307E\u3059\u3002",
2770
+ en: "Selects how the selected text is spoken."
2771
+ },
2772
+ options: createInsertionOptions(SAY_AS_PRESETS, SAY_AS_DESCRIPTIONS),
2773
+ createTemplate: (value) => ({
2774
+ prefix: `<say-as interpret-as="${value}">`,
2775
+ suffix: "</say-as>",
2776
+ mode: "wrap"
2777
+ })
2778
+ },
2779
+ {
2780
+ id: "lang",
2781
+ icon: "\u6587",
2782
+ tagName: "lang",
2783
+ labels: { ja: "\u8A00\u8A9E", en: "Language" },
2784
+ descriptions: {
2785
+ ja: "\u9078\u629E\u7BC4\u56F2\u306E\u8AAD\u307F\u4E0A\u3052\u8A00\u8A9E\u3092\u5909\u66F4\u3057\u307E\u3059\u3002",
2786
+ en: "Changes the speaking language of the selected text."
2787
+ },
2788
+ parameterDescription: {
2789
+ ja: "\u9078\u629E\u7BC4\u56F2\u306B\u9069\u7528\u3059\u308B BCP-47 \u8A00\u8A9E\u30BF\u30B0\u3092\u9078\u629E\u3057\u307E\u3059\u3002",
2790
+ en: "Selects the BCP-47 language tag for the selected text."
2791
+ },
2792
+ options: createInsertionOptions(LANGUAGE_PRESETS, LANGUAGE_DESCRIPTIONS),
2793
+ createTemplate: (value) => ({
2794
+ prefix: `<lang xml:lang="${value}">`,
2795
+ suffix: "</lang>",
2796
+ mode: "wrap"
2797
+ })
2798
+ },
2799
+ {
2800
+ id: "mstts:silence",
2801
+ icon: "\u23F3",
2802
+ tagName: "mstts:silence",
2803
+ selfClosing: true,
2804
+ labels: { ja: "\u7121\u97F3", en: "Silence" },
2805
+ descriptions: {
2806
+ ja: "\u7121\u97F3\u6642\u9593\u3092\u633F\u5165\u3057\u307E\u3059\u3002",
2807
+ en: "Inserts a silence interval."
2808
+ },
2809
+ parameterDescription: {
2810
+ ja: "\u7121\u97F3\u306B\u3059\u308B\u6642\u9593\u3092\u9078\u629E\u3057\u307E\u3059\u3002",
2811
+ en: "Selects the silence duration."
2812
+ },
2813
+ options: createInsertionOptions(SILENCE_VALUE_PRESETS, SILENCE_VALUE_DESCRIPTIONS),
2814
+ createTemplate: (value) => ({
2815
+ prefix: `<mstts:silence type="Leading" value="${value}"/>`,
2816
+ suffix: "",
2817
+ mode: "insert"
2818
+ })
2819
+ }
2820
+ ];
2821
+ var DEFAULT_INSERTION_GROUPS = [
2822
+ {
2823
+ id: "pauses",
2824
+ labels: { ja: "\u9593\u30FB\u7121\u97F3", en: "Pauses" },
2825
+ insertionIds: ["break", "mstts:silence"]
2826
+ },
2827
+ {
2828
+ id: "prosody",
2829
+ labels: { ja: "\u58F0\u306E\u8ABF\u6574", en: "Voice" },
2830
+ insertionIds: ["rate", "pitch", "volume"]
2831
+ },
2832
+ {
2833
+ id: "expression",
2834
+ labels: { ja: "\u8868\u73FE", en: "Expression" },
2835
+ insertionIds: ["emphasis", "emotion"]
2836
+ },
2837
+ {
2838
+ id: "pronunciation",
2839
+ labels: { ja: "\u8AAD\u307F\u4E0A\u3052", en: "Pronunciation" },
2840
+ insertionIds: ["say-as", "lang"]
2841
+ }
2842
+ ];
2843
+
2844
+ // src/SsmlEditorElement.ts
2845
+ var HTMLElementBase = typeof HTMLElement === "undefined" ? class {
2846
+ } : HTMLElement;
2847
+ var STYLE_ID = "ssml-editor-elements-theme";
2848
+ var STYLE_CSS = `
2849
+ [data-ssml-editor] {
2850
+ --ssml-editor-color: #111827;
2851
+ --ssml-editor-bg: #ffffff;
2852
+ --ssml-editor-border: #d1d5db;
2853
+ --ssml-editor-control-bg: #f9fafb;
2854
+ --ssml-editor-control-border: #9ca3af;
2855
+ --ssml-editor-active-bg: #dbeafe;
2856
+ --ssml-editor-active-border: #2563eb;
2857
+ --ssml-editor-preview-bg: #f3f4f6;
2858
+ }
2859
+ section[data-ssml-editor] {
2860
+ display: grid;
2861
+ grid-template-rows: auto minmax(8rem, 1fr);
2862
+ gap: 0.75rem;
2863
+ box-sizing: border-box;
2864
+ width: 100%;
2865
+ min-height: 100%;
2866
+ padding: 1rem;
2867
+ border: 1px solid var(--ssml-editor-border);
2868
+ border-radius: 0.5rem;
2869
+ color: var(--ssml-editor-color);
2870
+ background: var(--ssml-editor-bg);
2871
+ }
2872
+ [data-ssml-editor][data-theme="dark"] {
2873
+ --ssml-editor-color: #f9fafb;
2874
+ --ssml-editor-bg: #1f2937;
2875
+ --ssml-editor-border: #374151;
2876
+ --ssml-editor-control-bg: #111827;
2877
+ --ssml-editor-control-border: #4b5563;
2878
+ --ssml-editor-active-bg: #1e3a8a;
2879
+ --ssml-editor-active-border: #60a5fa;
2880
+ --ssml-editor-preview-bg: #111827;
2881
+ }
2882
+ [data-ssml-editor] .ssml-editor-toolbar {
2883
+ display: flex;
2884
+ align-items: center;
2885
+ flex-wrap: wrap;
2886
+ gap: 0.5rem;
2887
+ }
2888
+ [data-ssml-editor] .ssml-editor-toolbar-actions {
2889
+ display: flex;
2890
+ align-items: center;
2891
+ flex-wrap: wrap;
2892
+ gap: 0.5rem;
2893
+ }
2894
+ [data-ssml-editor] .ssml-editor-toolbar-separator {
2895
+ width: 1px;
2896
+ height: 2.25rem;
2897
+ margin: 0 0.25rem;
2898
+ background: var(--ssml-editor-border);
2899
+ }
2900
+ [data-ssml-editor] .ssml-editor-toolbar-dropdown {
2901
+ display: inline-block;
2902
+ }
2903
+ [data-ssml-editor] .ssml-editor-toolbar-button {
2904
+ display: inline-flex;
2905
+ align-items: center;
2906
+ gap: 0.375rem;
2907
+ min-height: 2.25rem;
2908
+ padding: 0.375rem 0.625rem;
2909
+ border: 1px solid var(--ssml-editor-control-border);
2910
+ border-radius: 0.25rem;
2911
+ color: var(--ssml-editor-color);
2912
+ background: var(--ssml-editor-control-bg);
2913
+ font: inherit;
2914
+ cursor: pointer;
2915
+ }
2916
+ [data-ssml-editor] .ssml-editor-toolbar-button:hover,
2917
+ [data-ssml-editor] .ssml-editor-toolbar-option:hover {
2918
+ background: var(--ssml-editor-preview-bg);
2919
+ }
2920
+ [data-ssml-editor] .ssml-editor-toolbar-button:disabled {
2921
+ cursor: not-allowed;
2922
+ opacity: 0.55;
2923
+ }
2924
+ [data-ssml-editor] .ssml-editor-toolbar-button[data-active="true"] {
2925
+ border-color: var(--ssml-editor-active-border);
2926
+ background: var(--ssml-editor-active-bg);
2927
+ }
2928
+ [data-ssml-editor] .ssml-editor-toolbar-icon {
2929
+ display: inline-flex;
2930
+ width: 1.25rem;
2931
+ justify-content: center;
2932
+ font-size: 1.1rem;
2933
+ line-height: 1;
2934
+ }
2935
+ [data-ssml-editor] .ssml-editor-toolbar-chevron {
2936
+ font-size: 0.7rem;
2937
+ line-height: 1;
2938
+ }
2939
+ [data-ssml-editor] .ssml-editor-toolbar-switch {
2940
+ display: inline-flex;
2941
+ align-items: center;
2942
+ gap: 0.375rem;
2943
+ min-height: 2.25rem;
2944
+ }
2945
+ [data-ssml-editor] .ssml-editor-switch-track {
2946
+ display: inline-flex;
2947
+ align-items: center;
2948
+ width: 2.75rem;
2949
+ height: 1.5rem;
2950
+ padding: 0.1875rem;
2951
+ border: 0;
2952
+ border-radius: 999px;
2953
+ background: var(--ssml-editor-control-border);
2954
+ cursor: pointer;
2955
+ transition: background-color 0.2s ease;
2956
+ }
2957
+ [data-ssml-editor] .ssml-editor-switch-track[aria-checked="true"] {
2958
+ background: var(--ssml-editor-active-border);
2959
+ }
2960
+ [data-ssml-editor] .ssml-editor-switch-track:focus-visible {
2961
+ outline: 2px solid var(--ssml-editor-active-border);
2962
+ outline-offset: 2px;
2963
+ }
2964
+ [data-ssml-editor] .ssml-editor-switch-thumb {
2965
+ width: 1.125rem;
2966
+ height: 1.125rem;
2967
+ border-radius: 50%;
2968
+ background: var(--ssml-editor-bg);
2969
+ transition: transform 0.2s ease;
2970
+ }
2971
+ [data-ssml-editor] .ssml-editor-switch-track[aria-checked="true"] .ssml-editor-switch-thumb {
2972
+ transform: translateX(1.25rem);
2973
+ }
2974
+ [data-ssml-editor].ssml-editor-toolbar-menu {
2975
+ position: fixed;
2976
+ z-index: 9999;
2977
+ display: grid;
2978
+ min-width: max-content;
2979
+ max-height: min(24rem, calc(100vh - 1rem));
2980
+ gap: 0.125rem;
2981
+ padding: 0.25rem;
2982
+ border: 1px solid var(--ssml-editor-control-border);
2983
+ border-radius: 0.25rem;
2984
+ background: var(--ssml-editor-control-bg);
2985
+ box-shadow: 0 0.25rem 0.75rem rgb(0 0 0 / 20%);
2986
+ overflow-y: auto;
2987
+ }
2988
+ [data-ssml-editor] .ssml-editor-toolbar-option {
2989
+ padding: 0.375rem 0.5rem;
2990
+ border: 0;
2991
+ border-radius: 0.125rem;
2992
+ color: var(--ssml-editor-color);
2993
+ background: transparent;
2994
+ font: inherit;
2995
+ text-align: left;
2996
+ white-space: nowrap;
2997
+ cursor: pointer;
2998
+ }
2999
+ [data-ssml-editor] .ssml-editor-toolbar-option-group {
3000
+ display: grid;
3001
+ gap: 0.125rem;
3002
+ margin: 0;
3003
+ padding: 0;
3004
+ border: 0;
3005
+ }
3006
+ [data-ssml-editor] .ssml-editor-toolbar-option-group legend {
3007
+ padding: 0.375rem 0.5rem 0.125rem;
3008
+ font-size: 0.875rem;
3009
+ font-weight: 600;
3010
+ white-space: nowrap;
3011
+ }
3012
+ [data-ssml-editor] .ssml-editor-help {
3013
+ display: grid;
3014
+ gap: 0.5rem;
3015
+ padding: 0.75rem;
3016
+ border: 1px solid var(--ssml-editor-control-border);
3017
+ border-radius: 0.25rem;
3018
+ background: var(--ssml-editor-preview-bg);
3019
+ }
3020
+ [data-ssml-editor] .ssml-editor-help h3,
3021
+ [data-ssml-editor] .ssml-editor-help p {
3022
+ margin: 0;
3023
+ }
3024
+ [data-ssml-editor] .ssml-editor-help-list {
3025
+ display: grid;
3026
+ gap: 0.375rem;
3027
+ margin: 0;
3028
+ padding-left: 1.25rem;
3029
+ }
3030
+ [data-ssml-editor] .ssml-editor-help-item {
3031
+ list-style: none;
3032
+ }
3033
+ [data-ssml-editor] .ssml-editor-help-item details {
3034
+ margin-top: 0.375rem;
3035
+ border: 1px solid var(--ssml-editor-control-border);
3036
+ border-radius: 0.25rem;
3037
+ background: var(--ssml-editor-control-bg);
3038
+ }
3039
+ [data-ssml-editor] .ssml-editor-help-item summary {
3040
+ padding: 0.5rem 0.625rem;
3041
+ cursor: pointer;
3042
+ }
3043
+ [data-ssml-editor] .ssml-editor-help-item details p,
3044
+ [data-ssml-editor] .ssml-editor-help-item details ul {
3045
+ margin: 0.5rem 0.75rem 0.75rem;
3046
+ font-size: 0.875rem;
3047
+ }
3048
+ [data-ssml-editor] .ssml-editor-display {
3049
+ display: grid;
3050
+ grid-template-rows: auto minmax(8rem, 1fr);
3051
+ gap: 0.5rem;
3052
+ min-height: 0;
3053
+ }
3054
+ [data-ssml-editor] .ssml-editor-editor {
3055
+ position: relative;
3056
+ min-height: 8rem;
3057
+ height: 100%;
3058
+ border: 1px solid var(--ssml-editor-control-border);
3059
+ border-radius: 0.25rem;
3060
+ overflow: visible;
3061
+ }
3062
+ `.trim();
3063
+ function injectStyles() {
3064
+ if (typeof document === "undefined" || document.getElementById(STYLE_ID)) {
3065
+ return;
3066
+ }
3067
+ const style = document.createElement("style");
3068
+ style.id = STYLE_ID;
3069
+ style.textContent = STYLE_CSS;
3070
+ document.head.appendChild(style);
3071
+ }
3072
+ function isDarkTheme(theme) {
3073
+ return theme === "vs-dark" || theme.toLowerCase().includes("dark");
3074
+ }
3075
+ function getMenuPosition(trigger, menu) {
3076
+ const bounds = trigger.getBoundingClientRect();
3077
+ const margin = 8;
3078
+ const top = Math.min(bounds.bottom + 4, window.innerHeight - menu.offsetHeight - margin);
3079
+ const left = Math.min(bounds.left, window.innerWidth - menu.offsetWidth - margin);
3080
+ return {
3081
+ top: Math.max(margin, top),
3082
+ left: Math.max(margin, left)
3083
+ };
3084
+ }
3085
+ var SsmlEditorElement = class extends HTMLElementBase {
3086
+ constructor() {
3087
+ super(...arguments);
3088
+ this.editor = null;
3089
+ this.model = null;
3090
+ this.monaco = null;
3091
+ this.root = null;
3092
+ this.toolbar = null;
3093
+ this.toolbarActions = null;
3094
+ this.display = null;
3095
+ this.editorContainer = null;
3096
+ this.helpPanel = null;
3097
+ this.openMenu = null;
3098
+ this.openMenuTrigger = null;
3099
+ this.toolbarButtons = /* @__PURE__ */ new Map();
3100
+ this.contentDisposable = null;
3101
+ this.cursorDisposable = null;
3102
+ this.completionDisposable = null;
3103
+ this.hoverDisposable = null;
3104
+ this.suppressChangeEvent = false;
3105
+ this.initializationToken = 0;
3106
+ this.documentState = null;
3107
+ this.decorationsVisible = false;
3108
+ this.helpOpen = false;
3109
+ this.handleDocumentPointerDown = (event) => {
3110
+ const target = event.target;
3111
+ if (this.openMenu && target instanceof Node && !this.openMenu.contains(target) && !this.openMenuTrigger?.contains(target)) {
3112
+ this.closeMenu();
3113
+ }
3114
+ };
3115
+ this.handleDocumentKeyDown = (event) => {
3116
+ if (event.key === "Escape" && this.openMenu) {
3117
+ this.closeMenu(true);
3118
+ }
3119
+ };
3120
+ }
3121
+ get value() {
3122
+ return this.valueState ?? this.getAttribute("value") ?? "";
3123
+ }
3124
+ set value(value) {
3125
+ this.valueState = value;
3126
+ this.setAttribute("value", value);
3127
+ }
3128
+ get theme() {
3129
+ return this.getAttribute("theme") || "light";
3130
+ }
3131
+ set theme(theme) {
3132
+ this.setAttribute("theme", theme);
3133
+ }
3134
+ get readonly() {
3135
+ return this.hasAttribute("readonly");
3136
+ }
3137
+ set readonly(readonly) {
3138
+ if (readonly) {
3139
+ this.setAttribute("readonly", "");
3140
+ } else {
3141
+ this.removeAttribute("readonly");
3142
+ }
3143
+ }
3144
+ get locale() {
3145
+ return this.getAttribute("locale") === "en" ? "en" : "ja";
3146
+ }
3147
+ set locale(locale) {
3148
+ this.setAttribute("locale", locale);
3149
+ }
3150
+ prepareDocument(value) {
3151
+ try {
3152
+ this.documentState = (0, import_ssml_core2.parseSsml)(value);
3153
+ return getEditableText(this.documentState);
3154
+ } catch {
3155
+ this.documentState = null;
3156
+ return value;
3157
+ }
3158
+ }
3159
+ connectedCallback() {
3160
+ if (this.editor || this.root) {
3161
+ return;
3162
+ }
3163
+ injectStyles();
3164
+ document.addEventListener("pointerdown", this.handleDocumentPointerDown);
3165
+ document.addEventListener("keydown", this.handleDocumentKeyDown);
3166
+ this.render();
3167
+ const token = ++this.initializationToken;
3168
+ void this.initialize(token);
3169
+ }
3170
+ disconnectedCallback() {
3171
+ this.initializationToken += 1;
3172
+ document.removeEventListener("pointerdown", this.handleDocumentPointerDown);
3173
+ document.removeEventListener("keydown", this.handleDocumentKeyDown);
3174
+ this.closeMenu();
3175
+ this.disposeEditor();
3176
+ }
3177
+ attributeChangedCallback(name, _oldValue, newValue) {
3178
+ if (name === "value") {
3179
+ this.valueState = newValue ?? "";
3180
+ if (this.editor) {
3181
+ const value = newValue ?? "";
3182
+ const editableValue = this.prepareDocument(value);
3183
+ if (this.editor.getValue() !== editableValue) {
3184
+ this.suppressChangeEvent = true;
3185
+ try {
3186
+ this.editor.setValue(editableValue);
3187
+ } finally {
3188
+ this.suppressChangeEvent = false;
3189
+ }
3190
+ }
3191
+ }
3192
+ return;
3193
+ }
3194
+ if (name === "theme" && this.monaco) {
3195
+ this.monaco.editor.setTheme(this.theme);
3196
+ this.updateTheme();
3197
+ return;
3198
+ }
3199
+ if (name === "readonly") {
3200
+ this.editor?.updateOptions({ readOnly: this.readonly });
3201
+ this.renderToolbar();
3202
+ return;
3203
+ }
3204
+ if (name === "locale" || name === "show-toolbar" || name === "show-toolbar-labels") {
3205
+ this.renderToolbar();
3206
+ this.renderHelp();
3207
+ return;
3208
+ }
3209
+ if (name === "show-decorations") {
3210
+ this.decorationsVisible = newValue !== null;
3211
+ this.updateDecorations();
3212
+ }
3213
+ }
3214
+ render() {
3215
+ const root = document.createElement("section");
3216
+ root.dataset.ssmlEditor = "";
3217
+ root.setAttribute("aria-label", EDITOR_COPY[this.locale].editorAriaLabel);
3218
+ root.dataset.theme = isDarkTheme(this.theme) ? "dark" : "light";
3219
+ const toolbar = document.createElement("div");
3220
+ toolbar.className = "ssml-editor-toolbar";
3221
+ toolbar.dataset.ssmlEditorToolbar = "";
3222
+ const toolbarActions = document.createElement("div");
3223
+ toolbarActions.className = "ssml-editor-toolbar-actions";
3224
+ toolbarActions.setAttribute("role", "toolbar");
3225
+ toolbarActions.setAttribute("aria-label", EDITOR_COPY[this.locale].toolbarAriaLabel);
3226
+ toolbarActions.dataset.ssmlEditorToolbarActions = "";
3227
+ toolbar.append(toolbarActions);
3228
+ const display = document.createElement("div");
3229
+ display.className = "ssml-editor-display";
3230
+ display.dataset.ssmlEditorDisplay = "";
3231
+ const editorContainer = document.createElement("div");
3232
+ editorContainer.className = "ssml-editor-editor";
3233
+ display.append(editorContainer);
3234
+ root.append(toolbar, display);
3235
+ this.replaceChildren(root);
3236
+ this.root = root;
3237
+ this.toolbar = toolbar;
3238
+ this.toolbarActions = toolbarActions;
3239
+ this.display = display;
3240
+ this.editorContainer = editorContainer;
3241
+ this.renderToolbar();
3242
+ this.renderHelp();
3243
+ }
3244
+ renderToolbar() {
3245
+ const toolbar = this.toolbar;
3246
+ const toolbarActions = this.toolbarActions;
3247
+ if (!toolbar || !toolbarActions) {
3248
+ return;
3249
+ }
3250
+ this.closeMenu();
3251
+ const copy = EDITOR_COPY[this.locale];
3252
+ toolbar.hidden = this.getAttribute("show-toolbar") === "false";
3253
+ toolbar.setAttribute("aria-label", copy.toolbarAriaLabel);
3254
+ toolbarActions.setAttribute("aria-label", copy.toolbarAriaLabel);
3255
+ toolbarActions.replaceChildren();
3256
+ this.toolbarButtons.clear();
3257
+ if (toolbar.hidden) {
3258
+ return;
3259
+ }
3260
+ const insertionById = new Map(SSML_INSERTIONS.map((insertion) => [insertion.id, insertion]));
3261
+ const toolbarIds = [
3262
+ "undo",
3263
+ "redo",
3264
+ ...DEFAULT_INSERTION_GROUPS.flatMap((group) => group.insertionIds),
3265
+ "clearAll",
3266
+ "format",
3267
+ "decorations",
3268
+ "help"
3269
+ ];
3270
+ const groupByButtonId = /* @__PURE__ */ new Map();
3271
+ for (const group of DEFAULT_INSERTION_GROUPS) {
3272
+ for (const buttonId of group.insertionIds) {
3273
+ groupByButtonId.set(buttonId, group.id);
3274
+ }
3275
+ }
3276
+ groupByButtonId.set("undo", "history");
3277
+ groupByButtonId.set("redo", "history");
3278
+ groupByButtonId.set("clearAll", "document");
3279
+ groupByButtonId.set("format", "document");
3280
+ groupByButtonId.set("decorations", "document");
3281
+ groupByButtonId.set("help", "help");
3282
+ let previousGroup;
3283
+ for (const id of toolbarIds) {
3284
+ const group = groupByButtonId.get(id);
3285
+ if (previousGroup !== void 0 && group !== previousGroup) {
3286
+ const separator = document.createElement("span");
3287
+ separator.className = "ssml-editor-toolbar-separator";
3288
+ separator.setAttribute("aria-hidden", "true");
3289
+ toolbarActions.append(separator);
3290
+ }
3291
+ previousGroup = group;
3292
+ const insertion = insertionById.get(id);
3293
+ if (insertion) {
3294
+ toolbarActions.append(this.createInsertionButton(insertion));
3295
+ } else if (id === "decorations") {
3296
+ toolbarActions.append(this.createDecorationsSwitch());
3297
+ } else {
3298
+ toolbarActions.append(this.createActionButton(id));
3299
+ }
3300
+ }
3301
+ this.updateActiveButtons();
3302
+ }
3303
+ createActionButton(id) {
3304
+ const copy = EDITOR_COPY[this.locale];
3305
+ const labels = {
3306
+ undo: copy.undo,
3307
+ redo: copy.redo,
3308
+ clearAll: copy.clearAll,
3309
+ format: copy.format,
3310
+ help: copy.help
3311
+ };
3312
+ const icons = {
3313
+ undo: "\u21A9",
3314
+ redo: "\u21AA",
3315
+ clearAll: "\xD7",
3316
+ format: "\u2261",
3317
+ help: "?"
3318
+ };
3319
+ const titles = {
3320
+ undo: copy.undoTitle,
3321
+ redo: copy.redoTitle,
3322
+ clearAll: copy.clearAllTitle,
3323
+ format: copy.formatTitle,
3324
+ help: copy.helpTitle
3325
+ };
3326
+ const button = document.createElement("button");
3327
+ button.type = "button";
3328
+ button.className = "ssml-editor-toolbar-button";
3329
+ button.dataset.ssmlEditorButton = id;
3330
+ button.setAttribute("aria-label", labels[id] ?? id);
3331
+ button.title = titles[id] ?? labels[id] ?? id;
3332
+ button.disabled = this.readonly && id !== "help";
3333
+ if (id === "help") {
3334
+ button.setAttribute("aria-expanded", String(this.helpOpen));
3335
+ }
3336
+ const icon = document.createElement("span");
3337
+ icon.className = "ssml-editor-toolbar-icon";
3338
+ icon.setAttribute("aria-hidden", "true");
3339
+ icon.textContent = icons[id] ?? "";
3340
+ button.append(icon);
3341
+ if (this.hasAttribute("show-toolbar-labels")) {
3342
+ button.append(document.createTextNode(labels[id] ?? id));
3343
+ }
3344
+ button.addEventListener("click", () => {
3345
+ if (id === "help") {
3346
+ this.helpOpen = !this.helpOpen;
3347
+ button.setAttribute("aria-expanded", String(this.helpOpen));
3348
+ this.renderHelp();
3349
+ } else if (!this.readonly) {
3350
+ this.handleAction(id);
3351
+ }
3352
+ });
3353
+ this.toolbarButtons.set(id, button);
3354
+ return button;
3355
+ }
3356
+ createDecorationsSwitch() {
3357
+ const copy = EDITOR_COPY[this.locale];
3358
+ const wrapper = document.createElement("div");
3359
+ wrapper.className = "ssml-editor-toolbar-switch";
3360
+ const icon = document.createElement("span");
3361
+ icon.className = "ssml-editor-toolbar-icon";
3362
+ icon.setAttribute("aria-hidden", "true");
3363
+ icon.textContent = "\u2606";
3364
+ wrapper.append(icon);
3365
+ if (this.hasAttribute("show-toolbar-labels")) {
3366
+ wrapper.append(document.createTextNode(copy.decorations));
3367
+ }
3368
+ const button = document.createElement("button");
3369
+ button.type = "button";
3370
+ button.className = "ssml-editor-switch-track";
3371
+ button.dataset.ssmlEditorButton = "decorations";
3372
+ button.setAttribute("role", "switch");
3373
+ button.setAttribute("aria-label", copy.decorations);
3374
+ button.addEventListener("click", () => {
3375
+ this.decorationsVisible = !this.decorationsVisible;
3376
+ this.updateDecorations();
3377
+ });
3378
+ wrapper.append(button);
3379
+ this.toolbarButtons.set("decorations", button);
3380
+ this.updateDecorations();
3381
+ return wrapper;
3382
+ }
3383
+ createInsertionButton(insertion) {
3384
+ const button = document.createElement("button");
3385
+ button.type = "button";
3386
+ button.className = "ssml-editor-toolbar-button";
3387
+ button.dataset.ssmlEditorButton = insertion.id;
3388
+ button.setAttribute("aria-label", insertion.labels[this.locale]);
3389
+ button.setAttribute("aria-haspopup", "menu");
3390
+ button.setAttribute("aria-expanded", "false");
3391
+ button.title = insertion.titles?.[this.locale] ?? `${insertion.labels[this.locale]} \u2014 ${insertion.descriptions[this.locale]}`;
3392
+ const icon = document.createElement("span");
3393
+ icon.className = "ssml-editor-toolbar-icon";
3394
+ icon.setAttribute("aria-hidden", "true");
3395
+ icon.textContent = insertion.icon;
3396
+ button.append(icon);
3397
+ if (this.hasAttribute("show-toolbar-labels")) {
3398
+ button.append(document.createTextNode(insertion.labels[this.locale]));
3399
+ }
3400
+ const chevron = document.createElement("span");
3401
+ chevron.className = "ssml-editor-toolbar-chevron";
3402
+ chevron.setAttribute("aria-hidden", "true");
3403
+ chevron.textContent = "\u25BE";
3404
+ button.append(chevron);
3405
+ button.addEventListener("click", () => this.toggleInsertionMenu(insertion, button));
3406
+ this.toolbarButtons.set(insertion.id, button);
3407
+ const wrapper = document.createElement("div");
3408
+ wrapper.className = "ssml-editor-toolbar-dropdown";
3409
+ wrapper.append(button);
3410
+ return wrapper;
3411
+ }
3412
+ toggleInsertionMenu(insertion, trigger) {
3413
+ if (this.openMenuTrigger === trigger) {
3414
+ this.closeMenu();
3415
+ return;
3416
+ }
3417
+ this.closeMenu();
3418
+ const menu = this.createInsertionMenu(insertion);
3419
+ document.body.append(menu);
3420
+ const position = getMenuPosition(trigger, menu);
3421
+ menu.style.top = `${position.top}px`;
3422
+ menu.style.left = `${position.left}px`;
3423
+ trigger.setAttribute("aria-expanded", "true");
3424
+ trigger.setAttribute("aria-controls", menu.id);
3425
+ this.openMenu = menu;
3426
+ this.openMenuTrigger = trigger;
3427
+ }
3428
+ createInsertionMenu(insertion) {
3429
+ const menu = document.createElement("div");
3430
+ menu.className = "ssml-editor-toolbar-menu";
3431
+ menu.dataset.ssmlEditor = "";
3432
+ menu.dataset.theme = isDarkTheme(this.theme) ? "dark" : "light";
3433
+ menu.id = `ssml-editor-elements-menu-${insertion.id.replace(/[^A-Za-z0-9_-]/g, "-")}`;
3434
+ menu.setAttribute("role", "menu");
3435
+ menu.setAttribute("aria-label", insertion.labels[this.locale]);
3436
+ menu.addEventListener("pointerdown", (event) => event.stopPropagation());
3437
+ const options = this.getInsertionOptions(insertion);
3438
+ if (options.length === 0) {
3439
+ const empty = document.createElement("p");
3440
+ empty.className = "ssml-editor-toolbar-option";
3441
+ empty.textContent = EDITOR_COPY[this.locale].noAvailableOptions;
3442
+ menu.append(empty);
3443
+ } else {
3444
+ for (const group of this.getOptionGroups(insertion, options)) {
3445
+ if (group.label) {
3446
+ const fieldset = document.createElement("fieldset");
3447
+ fieldset.className = "ssml-editor-toolbar-option-group";
3448
+ const legend = document.createElement("legend");
3449
+ legend.textContent = group.label;
3450
+ fieldset.append(legend);
3451
+ for (const option of group.options) {
3452
+ fieldset.append(this.createOptionButton(insertion, option));
3453
+ }
3454
+ menu.append(fieldset);
3455
+ } else {
3456
+ for (const option of group.options) {
3457
+ menu.append(this.createOptionButton(insertion, option));
3458
+ }
3459
+ }
3460
+ }
3461
+ }
3462
+ return menu;
3463
+ }
3464
+ getInsertionOptions(insertion) {
3465
+ if (insertion.id !== "emotion") {
3466
+ return insertion.options;
3467
+ }
3468
+ const model = this.model;
3469
+ const selection = this.editor?.getSelection();
3470
+ const voiceContext = model && selection ? findSsmlVoiceContext(model.getValue(), model.getOffsetAt(selection.getStartPosition())) : void 0;
3471
+ const voiceName = voiceContext === void 0 ? this.documentState ? getEditableRegion(this.documentState).voiceName : void 0 : voiceContext.voiceName;
3472
+ const availableStyles = new Set(
3473
+ resolveExpressAsStyles(
3474
+ voiceName,
3475
+ insertion.options.map((option) => option.value)
3476
+ )
3477
+ );
3478
+ return insertion.options.filter((option) => availableStyles.has(option.value));
3479
+ }
3480
+ getOptionGroups(insertion, options) {
3481
+ if (insertion.id !== "emotion") {
3482
+ return [{ label: "", options }];
3483
+ }
3484
+ const copy = EDITOR_COPY[this.locale];
3485
+ const labels = {
3486
+ emotions: copy.categoryEmotions,
3487
+ scenarios: copy.categoryScenarios,
3488
+ media: copy.categoryMedia,
3489
+ other: copy.categoryOther
3490
+ };
3491
+ const categories = ["emotions", "scenarios", "media", "other"];
3492
+ return categories.map((category) => ({
3493
+ label: labels[category],
3494
+ options: options.filter((option) => getExpressAsStyleCategory(option.value) === category)
3495
+ })).filter((group) => group.options.length > 0);
3496
+ }
3497
+ createOptionButton(insertion, option) {
3498
+ const button = document.createElement("button");
3499
+ button.type = "button";
3500
+ button.className = "ssml-editor-toolbar-option";
3501
+ button.setAttribute("role", "menuitem");
3502
+ button.title = option.descriptions?.[this.locale] ?? insertion.descriptions[this.locale];
3503
+ button.textContent = option.labels[this.locale];
3504
+ button.disabled = this.readonly;
3505
+ button.addEventListener("click", () => {
3506
+ if (!this.readonly) {
3507
+ this.applyInsertion(insertion, option);
3508
+ }
3509
+ this.closeMenu(true);
3510
+ });
3511
+ button.addEventListener("mousedown", (event) => event.preventDefault());
3512
+ return button;
3513
+ }
3514
+ handleAction(id) {
3515
+ if (!this.editor) {
3516
+ return;
3517
+ }
3518
+ if (id === "undo" || id === "redo") {
3519
+ this.editor.trigger("ssml-toolbar", id, null);
3520
+ this.editor.focus();
3521
+ } else if (id === "clearAll") {
3522
+ if (this.documentState) {
3523
+ this.replaceDocument(clearSsmlDocument(this.documentState));
3524
+ }
3525
+ } else if (id === "format") {
3526
+ if (this.documentState) {
3527
+ this.replaceDocument(updateEditableText(this.documentState, formatXmlFragment(this.editor.getValue())));
3528
+ } else {
3529
+ this.replaceEditorValue(formatXmlFragment(this.editor.getValue()));
3530
+ }
3531
+ }
3532
+ }
3533
+ applyInsertion(insertion, option) {
3534
+ const editor = this.editor;
3535
+ const model = this.model;
3536
+ const selection = editor?.getSelection();
3537
+ if (!editor || !model || !selection) {
3538
+ return;
3539
+ }
3540
+ const startOffset = model.getOffsetAt(selection.getStartPosition());
3541
+ const endOffset = model.getOffsetAt(selection.getEndPosition());
3542
+ const selectedText = selection.isEmpty() ? "" : model.getValueInRange(selection);
3543
+ const result = createSsmlInsertionEdit(
3544
+ model.getValue(),
3545
+ startOffset,
3546
+ endOffset,
3547
+ insertion.createTemplate(option.value),
3548
+ model.getEOL(),
3549
+ selectedText
3550
+ );
3551
+ editor.pushUndoStop();
3552
+ const applied = editor.executeEdits("ssml-toolbar", [{ range: selection, text: result.replacement }]);
3553
+ editor.pushUndoStop();
3554
+ if (!applied) {
3555
+ return;
3556
+ }
3557
+ const start = model.getPositionAt(startOffset + result.selectionOffset);
3558
+ const end = model.getPositionAt(endOffset + result.selectionOffset);
3559
+ editor.setSelection({
3560
+ selectionStartLineNumber: start.lineNumber,
3561
+ selectionStartColumn: start.column,
3562
+ positionLineNumber: end.lineNumber,
3563
+ positionColumn: end.column
3564
+ });
3565
+ editor.focus();
3566
+ }
3567
+ replaceEditorValue(value) {
3568
+ const editor = this.editor;
3569
+ const model = editor?.getModel();
3570
+ if (!editor || !model || editor.getValue() === value) {
3571
+ return;
3572
+ }
3573
+ editor.pushUndoStop();
3574
+ editor.executeEdits("ssml-editor-toolbar", [
3575
+ {
3576
+ range: model.getFullModelRange(),
3577
+ text: value,
3578
+ forceMoveMarkers: true
3579
+ }
3580
+ ]);
3581
+ editor.pushUndoStop();
3582
+ editor.focus();
3583
+ }
3584
+ replaceDocument(document2) {
3585
+ const editor = this.editor;
3586
+ const model = editor?.getModel();
3587
+ const editableValue = getEditableText(document2);
3588
+ const fullValue = (0, import_ssml_core2.buildSsml)(document2);
3589
+ this.documentState = document2;
3590
+ this.valueState = fullValue;
3591
+ if (!editor || !model || editor.getValue() === editableValue) {
3592
+ this.updateActiveButtons();
3593
+ this.dispatchChange(fullValue);
3594
+ return;
3595
+ }
3596
+ editor.pushUndoStop();
3597
+ editor.executeEdits("ssml-editor-toolbar", [
3598
+ {
3599
+ range: model.getFullModelRange(),
3600
+ text: editableValue,
3601
+ forceMoveMarkers: true
3602
+ }
3603
+ ]);
3604
+ editor.pushUndoStop();
3605
+ editor.focus();
3606
+ }
3607
+ dispatchChange(value) {
3608
+ if (this.suppressChangeEvent) {
3609
+ return;
3610
+ }
3611
+ this.dispatchEvent(
3612
+ new CustomEvent("change", {
3613
+ detail: { value },
3614
+ bubbles: true,
3615
+ composed: true
3616
+ })
3617
+ );
3618
+ }
3619
+ updateDecorations() {
3620
+ const button = this.toolbarButtons.get("decorations");
3621
+ if (button) {
3622
+ const copy = EDITOR_COPY[this.locale];
3623
+ button.setAttribute("aria-checked", String(this.decorationsVisible));
3624
+ button.title = this.decorationsVisible ? copy.decorationsHideTitle : copy.decorationsShowTitle;
3625
+ }
3626
+ this.editor?.updateOptions({
3627
+ inlayHints: { enabled: this.decorationsVisible ? "on" : "off" }
3628
+ });
3629
+ }
3630
+ renderHelp() {
3631
+ const display = this.display;
3632
+ if (!display) {
3633
+ return;
3634
+ }
3635
+ this.helpPanel?.remove();
3636
+ this.helpPanel = null;
3637
+ const root = this.root;
3638
+ if (root) {
3639
+ root.setAttribute("aria-label", EDITOR_COPY[this.locale].editorAriaLabel);
3640
+ this.updateTheme();
3641
+ }
3642
+ if (!this.helpOpen || this.getAttribute("show-toolbar") === "false") {
3643
+ return;
3644
+ }
3645
+ const copy = EDITOR_COPY[this.locale];
3646
+ const panel = document.createElement("section");
3647
+ panel.className = "ssml-editor-help";
3648
+ panel.setAttribute("aria-label", copy.helpHeading);
3649
+ const heading = document.createElement("h3");
3650
+ heading.textContent = copy.helpHeading;
3651
+ const description = document.createElement("p");
3652
+ description.textContent = copy.helpDescription;
3653
+ const list = document.createElement("ul");
3654
+ list.className = "ssml-editor-help-list";
3655
+ for (const insertion of SSML_INSERTIONS) {
3656
+ const item = document.createElement("li");
3657
+ item.className = "ssml-editor-help-item";
3658
+ const details = document.createElement("details");
3659
+ const summary = document.createElement("summary");
3660
+ summary.textContent = `${insertion.icon} ${insertion.labels[this.locale]} \u2014 ${insertion.descriptions[this.locale]}`;
3661
+ const parameters = document.createElement("p");
3662
+ parameters.textContent = `${copy.parameters}: ${insertion.parameterDescription[this.locale]}`;
3663
+ const options = document.createElement("ul");
3664
+ for (const option of insertion.options) {
3665
+ const optionItem = document.createElement("li");
3666
+ optionItem.textContent = `${option.labels[this.locale]}${option.descriptions?.[this.locale] ? ` \u2014 ${option.descriptions[this.locale]}` : ""}`;
3667
+ options.append(optionItem);
3668
+ }
3669
+ details.append(summary, parameters, options);
3670
+ item.append(details);
3671
+ list.append(item);
3672
+ }
3673
+ panel.append(heading, description, list);
3674
+ display.prepend(panel);
3675
+ this.helpPanel = panel;
3676
+ }
3677
+ updateTheme() {
3678
+ if (this.root) {
3679
+ this.root.dataset.theme = isDarkTheme(this.theme) ? "dark" : "light";
3680
+ }
3681
+ }
3682
+ updateActiveButtons() {
3683
+ const editor = this.editor;
3684
+ const model = this.model;
3685
+ const selection = editor?.getSelection();
3686
+ if (!editor || !model || !selection) {
3687
+ return;
3688
+ }
3689
+ const activeTags = findActiveSsmlTags(model.getValue(), model.getOffsetAt(selection.getStartPosition()));
3690
+ for (const insertion of SSML_INSERTIONS) {
3691
+ const button = this.toolbarButtons.get(insertion.id);
3692
+ if (button) {
3693
+ button.dataset.active = String(
3694
+ insertion.tagName !== void 0 && activeTags.has(insertion.tagName.toLowerCase())
3695
+ );
3696
+ }
3697
+ }
3698
+ }
3699
+ async initialize(token) {
3700
+ const container = this.editorContainer;
3701
+ if (!container) {
3702
+ return;
3703
+ }
3704
+ const monacoModule = await import("monaco-editor");
3705
+ if (token !== this.initializationToken || !this.isConnected) {
3706
+ return;
3707
+ }
3708
+ const model = monacoModule.editor.createModel(this.prepareDocument(this.value), "xml");
3709
+ const editor = monacoModule.editor.create(container, {
3710
+ model,
3711
+ theme: this.theme,
3712
+ readOnly: this.readonly,
3713
+ automaticLayout: true,
3714
+ minimap: { enabled: false },
3715
+ wordWrap: "on",
3716
+ inlayHints: { enabled: this.decorationsVisible ? "on" : "off" }
3717
+ });
3718
+ if (token !== this.initializationToken || !this.isConnected) {
3719
+ editor.dispose();
3720
+ model.dispose();
3721
+ return;
3722
+ }
3723
+ this.monaco = monacoModule;
3724
+ this.model = model;
3725
+ this.editor = editor;
3726
+ this.contentDisposable = editor.onDidChangeModelContent(() => {
3727
+ const value = editor.getValue();
3728
+ let nextValue = value;
3729
+ if (this.documentState) {
3730
+ this.documentState = updateEditableText(this.documentState, value);
3731
+ nextValue = (0, import_ssml_core2.buildSsml)(this.documentState);
3732
+ }
3733
+ this.valueState = nextValue;
3734
+ this.updateActiveButtons();
3735
+ this.dispatchChange(nextValue);
3736
+ });
3737
+ this.cursorDisposable = editor.onDidChangeCursorPosition(() => this.updateActiveButtons());
3738
+ this.completionDisposable = registerSsmlCompletionProvider(monacoModule, {
3739
+ model,
3740
+ getOuterVoiceName: () => this.documentState ? getEditableRegion(this.documentState).voiceName : void 0
3741
+ });
3742
+ this.hoverDisposable = monacoModule.languages.registerHoverProvider("xml", {
3743
+ provideHover: (hoverModel, position) => {
3744
+ const target = findSsmlHoverTarget(hoverModel.getValue(), position.lineNumber, position.column);
3745
+ if (!target) {
3746
+ return void 0;
3747
+ }
3748
+ return {
3749
+ contents: [
3750
+ {
3751
+ isTrusted: false,
3752
+ supportHtml: false,
3753
+ value: formatSsmlHover(target)
3754
+ }
3755
+ ],
3756
+ range: target.range
3757
+ };
3758
+ }
3759
+ });
3760
+ this.updateActiveButtons();
3761
+ }
3762
+ closeMenu(restoreFocus = false) {
3763
+ this.openMenu?.remove();
3764
+ this.openMenu = null;
3765
+ if (this.openMenuTrigger) {
3766
+ this.openMenuTrigger.setAttribute("aria-expanded", "false");
3767
+ this.openMenuTrigger.removeAttribute("aria-controls");
3768
+ if (restoreFocus) {
3769
+ this.openMenuTrigger.focus();
3770
+ }
3771
+ }
3772
+ this.openMenuTrigger = null;
3773
+ }
3774
+ disposeEditor() {
3775
+ this.closeMenu();
3776
+ this.contentDisposable?.dispose();
3777
+ this.contentDisposable = null;
3778
+ this.cursorDisposable?.dispose();
3779
+ this.cursorDisposable = null;
3780
+ this.completionDisposable?.dispose();
3781
+ this.completionDisposable = null;
3782
+ this.hoverDisposable?.dispose();
3783
+ this.hoverDisposable = null;
3784
+ this.editor?.dispose();
3785
+ this.editor = null;
3786
+ this.model?.dispose();
3787
+ this.model = null;
3788
+ this.monaco = null;
3789
+ this.root?.remove();
3790
+ this.root = null;
3791
+ this.toolbar = null;
3792
+ this.toolbarActions = null;
3793
+ this.display = null;
3794
+ this.editorContainer = null;
3795
+ this.helpPanel = null;
3796
+ this.toolbarButtons.clear();
3797
+ }
3798
+ };
3799
+ SsmlEditorElement.tagName = "ssml-editor";
3800
+ SsmlEditorElement.observedAttributes = [
3801
+ "value",
3802
+ "theme",
3803
+ "readonly",
3804
+ "locale",
3805
+ "show-toolbar",
3806
+ "show-toolbar-labels",
3807
+ "show-decorations"
3808
+ ];
3809
+
3810
+ // src/index.ts
3811
+ function defineSsmlEditorElement() {
3812
+ if (typeof customElements === "undefined" || customElements.get(SsmlEditorElement.tagName)) {
3813
+ return;
3814
+ }
3815
+ customElements.define(SsmlEditorElement.tagName, SsmlEditorElement);
3816
+ }
3817
+ // Annotate the CommonJS export names for ESM import in node:
3818
+ 0 && (module.exports = {
3819
+ SsmlEditorElement,
3820
+ defineSsmlEditorElement
3821
+ });
3822
+ //# sourceMappingURL=index.js.map