@vibedev-si/dsh-vibedev 0.11.2 → 0.11.4

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.
@@ -1531,6 +1531,175 @@ window.__ModuleLoader__.load({
1531
1531
  msgUnreadCount: "{count} unread notifications"
1532
1532
  };
1533
1533
  //#endregion
1534
+ //#region src/client/AccountCenter/voice-profile-locales.ts
1535
+ /** The 「我的音色」 page's words (voice profiles for Suno voice covers). Every key has both languages. */
1536
+ const voiceProfileZh = {
1537
+ centerVoiceProfiles: "我的音色",
1538
+ centerVoiceProfilesIntro: "用你自己的人声创建音色,用于 Suno 音色翻唱。创建音色免费,不会生成歌曲。",
1539
+ voiceNewTitle: "新建音色",
1540
+ voiceFile: "人声音频",
1541
+ voiceChooseFile: "选择音频文件",
1542
+ voiceFileHint: "6–60 秒(建议 10–60 秒)、不超过 10 MB,支持 mp3、wav、m4a、aac、flac、ogg;尽量是干净的人声,不带伴奏。",
1543
+ voiceName: "音色名称",
1544
+ voiceNamePlaceholder: "例如:我的主唱音色",
1545
+ voiceCreate: "创建音色",
1546
+ voiceCreateAnother: "再建一个",
1547
+ voiceFileChosen: "{name} · {size}",
1548
+ voiceFileSeconds: "时长 {seconds} 秒",
1549
+ voiceFileSecondsUnknown: "浏览器量不到这段音频的时长,上传后由服务端测量;量不到会提示你换成标准 WAV 或 MP3。",
1550
+ voiceFileShortHint: "不到 10 秒也能创建,但音色还原度通常更好的是 10–60 秒。",
1551
+ voiceStepCheck: "本地检查",
1552
+ voiceStepUpload: "上传并提交",
1553
+ voiceStepProcess: "网关处理中",
1554
+ voiceStepReady: "可以使用",
1555
+ voiceChecking: "正在检查音频格式、大小和时长…",
1556
+ voiceUploading: "正在上传音频并提交,请不要关闭页面…",
1557
+ voiceProcessing: "音色正在创建,已等待 {seconds} 秒。通常需要几十秒,完成后会自动更新。",
1558
+ voiceProcessingSlow: "还在处理中(已等待 {seconds} 秒)。可以先离开,稍后回来刷新查看。",
1559
+ voiceReadyNotice: "音色「{title}」已可用,可在音乐生成里作为音色翻唱使用。",
1560
+ voiceFailedNotice: "音色创建失败:{reason}",
1561
+ voiceFailedUnknown: "网关没有给出原因",
1562
+ voiceList: "我的音色列表",
1563
+ voiceColName: "名称",
1564
+ voiceColStatus: "状态",
1565
+ voiceColDuration: "时长",
1566
+ voiceColCreated: "创建时间",
1567
+ voiceColActions: "操作",
1568
+ voiceStatusProcessing: "创建中",
1569
+ voiceStatusReady: "可用",
1570
+ voiceStatusFailed: "失败",
1571
+ voiceUntitled: "未命名音色",
1572
+ voiceSeconds: "{seconds} 秒",
1573
+ voiceEmpty: "还没有音色",
1574
+ voiceEmptyHint: "上传一段 10–60 秒的干净人声,就能创建你的第一个音色。",
1575
+ voiceLoading: "正在读取音色…",
1576
+ voiceUnsupported: "当前网关尚未开放音色管理。",
1577
+ voiceRefresh: "刷新",
1578
+ voiceDelete: "删除",
1579
+ voiceDeleteTitle: "删除音色「{title}」?",
1580
+ voiceDeleteBody: "删除后该音色将永久关闭、不可恢复,不能再用于新的音色翻唱;已生成的歌曲不受影响。",
1581
+ voiceDeleteConfirm: "永久删除",
1582
+ voiceDeleteCancel: "取消",
1583
+ voiceDeleting: "正在删除…",
1584
+ voiceDeleted: "音色已删除。",
1585
+ voiceFree: "创建音色免费",
1586
+ voiceKeepNote: "音色由网关保存,不保证永久保留;请保留好你的原始录音。",
1587
+ voiceErrFormat: "文件格式不支持:请选择 mp3、wav、m4a、aac、flac 或 ogg 音频。",
1588
+ voiceErrEmpty: "这个文件是空的。",
1589
+ voiceErrTooLarge: "文件超过 10 MB,请压缩或剪短后再试。",
1590
+ voiceErrTooShort: "音频太短:至少需要 6 秒(建议 10–60 秒)。",
1591
+ voiceErrTooLong: "音频太长:最多 60 秒,请剪到 10–60 秒的干净人声。",
1592
+ voiceErrDurationUnknown: "量不到这段音频的时长,请导出为标准 WAV 或 MP3 后重试。",
1593
+ voiceErrUpload: "音频上传失败,音色没有创建,请稍后重试。",
1594
+ voiceErrTitle: "请填写 1–80 个字的音色名称。",
1595
+ voiceErrRead: "读取本地文件失败,请重新选择。",
1596
+ voiceErrAccountChanged: "账号已切换,请刷新页面后再操作。",
1597
+ voiceErrorCode: "错误码 {code}",
1598
+ voiceRejectSimilar: "这段样本和已有录音太像,请换一段干净、独特的人声。",
1599
+ voiceRejectNotClean: "这不是干净的人声:请换一段只有一个人声、不带伴奏和杂音的录音。",
1600
+ voiceRejectOriginal: "原始原因:{reason}",
1601
+ voiceDropTitle: "点击或拖入音频文件",
1602
+ voiceFileAdvice: "建议 10–60 秒、只有一个人声的干净录音,不带伴奏和杂音。",
1603
+ voiceDropActive: "松开即可添加",
1604
+ voiceDropFormats: "mp3 · wav · m4a · aac · flac · ogg,6–60 秒,不超过 10 MB",
1605
+ voiceChangeFile: "重新选择",
1606
+ voiceMeasuring: "正在测量时长…",
1607
+ voicePickFile: "选择音频文件",
1608
+ voiceNameHint: "最多 {max} 个字,只用来在列表里区分音色。",
1609
+ voiceNeedFile: "请先选择一个音频文件",
1610
+ voiceNeedName: "请填写音色名称",
1611
+ voiceListCount: "共 {count} 个",
1612
+ voiceLoadFailed: "音色列表没有读到",
1613
+ voiceUnsupportedTitle: "暂未开放音色管理",
1614
+ voiceRetry: "重试",
1615
+ voiceWaitingGateway: "网关处理中,已等待 {seconds} 秒。较长的样本可能需要 1–3 分钟,请不要关闭页面。",
1616
+ voiceConfirming: "网关没有及时回复,音色可能已经创建,正在确认(已等待 {seconds} 秒)…",
1617
+ voiceUnconfirmed: "网关处理超时。可能已在网关侧创建,请稍后刷新列表确认;若列表没有,再重试。"
1618
+ };
1619
+ const voiceProfileEn = {
1620
+ centerVoiceProfiles: "My voices",
1621
+ centerVoiceProfilesIntro: "Create voice profiles from your own singing voice for Suno voice covers. Creating one is free and makes no song.",
1622
+ voiceNewTitle: "New voice",
1623
+ voiceFile: "Vocal recording",
1624
+ voiceChooseFile: "Choose an audio file",
1625
+ voiceFileHint: "6–60 seconds (10–60 s recommended), up to 10 MB, mp3, wav, m4a, aac, flac or ogg; clean solo vocals without accompaniment work best.",
1626
+ voiceName: "Voice name",
1627
+ voiceNamePlaceholder: "For example: My lead vocal",
1628
+ voiceCreate: "Create voice",
1629
+ voiceCreateAnother: "Create another",
1630
+ voiceFileChosen: "{name} · {size}",
1631
+ voiceFileSeconds: "{seconds} seconds long",
1632
+ voiceFileSecondsUnknown: "The browser could not measure this recording; it will be measured after the upload, and you will be told if it cannot be.",
1633
+ voiceFileShortHint: "Under 10 seconds works, but 10–60 seconds usually captures the voice better.",
1634
+ voiceStepCheck: "Check",
1635
+ voiceStepUpload: "Upload and submit",
1636
+ voiceStepProcess: "Processing",
1637
+ voiceStepReady: "Ready",
1638
+ voiceChecking: "Checking the format, size and length…",
1639
+ voiceUploading: "Uploading and submitting. Keep this page open…",
1640
+ voiceProcessing: "Creating the voice, {seconds} s so far. This usually takes under a minute and updates on its own.",
1641
+ voiceProcessingSlow: "Still processing ({seconds} s so far). You can leave and refresh later.",
1642
+ voiceReadyNotice: "The voice “{title}” is ready for voice covers in music generation.",
1643
+ voiceFailedNotice: "The voice could not be created: {reason}",
1644
+ voiceFailedUnknown: "the gateway gave no reason",
1645
+ voiceList: "My voices",
1646
+ voiceColName: "Name",
1647
+ voiceColStatus: "Status",
1648
+ voiceColDuration: "Length",
1649
+ voiceColCreated: "Created",
1650
+ voiceColActions: "Actions",
1651
+ voiceStatusProcessing: "Creating",
1652
+ voiceStatusReady: "Ready",
1653
+ voiceStatusFailed: "Failed",
1654
+ voiceUntitled: "Untitled voice",
1655
+ voiceSeconds: "{seconds} s",
1656
+ voiceEmpty: "No voices yet",
1657
+ voiceEmptyHint: "Upload 10–60 seconds of clean vocals to create your first voice.",
1658
+ voiceLoading: "Reading voices…",
1659
+ voiceUnsupported: "This gateway does not offer voice profiles yet.",
1660
+ voiceRefresh: "Refresh",
1661
+ voiceDelete: "Delete",
1662
+ voiceDeleteTitle: "Delete the voice “{title}”?",
1663
+ voiceDeleteBody: "The voice will be closed for good and cannot be restored or used for new voice covers. Songs already made with it are not affected.",
1664
+ voiceDeleteConfirm: "Delete permanently",
1665
+ voiceDeleteCancel: "Cancel",
1666
+ voiceDeleting: "Deleting…",
1667
+ voiceDeleted: "The voice was deleted.",
1668
+ voiceFree: "Creating a voice is free",
1669
+ voiceKeepNote: "Voices are kept by the gateway and are not guaranteed forever; keep your original recording.",
1670
+ voiceErrFormat: "Unsupported file: choose an mp3, wav, m4a, aac, flac or ogg recording.",
1671
+ voiceErrEmpty: "This file is empty.",
1672
+ voiceErrTooLarge: "The file is over 10 MB. Compress or shorten it and try again.",
1673
+ voiceErrTooShort: "Too short: at least 6 seconds are needed (10–60 s recommended).",
1674
+ voiceErrTooLong: "Too long: at most 60 seconds. Trim it to 10–60 s of clean vocals.",
1675
+ voiceErrDurationUnknown: "The length of this recording could not be measured. Export it as a standard WAV or MP3 and try again.",
1676
+ voiceErrUpload: "The upload failed and no voice was created. Try again later.",
1677
+ voiceErrTitle: "Enter a voice name of 1–80 characters.",
1678
+ voiceErrRead: "The file could not be read. Choose it again.",
1679
+ voiceErrAccountChanged: "The account changed. Refresh the page and try again.",
1680
+ voiceErrorCode: "Error code {code}",
1681
+ voiceRejectSimilar: "This sample is too similar to an existing recording. Use a different clean, original vocal.",
1682
+ voiceRejectNotClean: "This is not a clean solo vocal. Use a recording of one voice without accompaniment or background noise.",
1683
+ voiceRejectOriginal: "Original reason: {reason}",
1684
+ voiceDropTitle: "Click or drop an audio file here",
1685
+ voiceFileAdvice: "A clean recording of one voice, 10–60 s, without accompaniment or background noise, works best.",
1686
+ voiceDropActive: "Release to add it",
1687
+ voiceDropFormats: "mp3 · wav · m4a · aac · flac · ogg, 6–60 s, up to 10 MB",
1688
+ voiceChangeFile: "Choose another",
1689
+ voiceMeasuring: "Measuring length…",
1690
+ voicePickFile: "Choose an audio file",
1691
+ voiceNameHint: "Up to {max} characters, only to tell your voices apart.",
1692
+ voiceNeedFile: "Choose an audio file first",
1693
+ voiceNeedName: "Enter a name for the voice",
1694
+ voiceListCount: "{count} in total",
1695
+ voiceLoadFailed: "The voice list could not be read",
1696
+ voiceUnsupportedTitle: "Voice profiles are not available yet",
1697
+ voiceRetry: "Try again",
1698
+ voiceWaitingGateway: "The gateway is processing, {seconds} s so far. A longer sample can take 1–3 minutes; keep this page open.",
1699
+ voiceConfirming: "The gateway did not answer in time. The voice may already exist; checking ({seconds} s so far)…",
1700
+ voiceUnconfirmed: "The gateway timed out. The voice may have been created there: refresh the list in a little while to check, and try again only if it is not there."
1701
+ };
1702
+ //#endregion
1534
1703
  //#region src/client/AccountCenter/center-locales.ts
1535
1704
  const centerZh = {
1536
1705
  centerUsagePromo: "限时特惠 −{discount}(原价 {total})",
@@ -1539,6 +1708,7 @@ window.__ModuleLoader__.load({
1539
1708
  ...memberZh,
1540
1709
  ...businessZh,
1541
1710
  ...announcementZh,
1711
+ ...voiceProfileZh,
1542
1712
  centerRechargeIntro: "选择充值金额或订阅,确认费用后完成支付。",
1543
1713
  centerOrdersIntro: "查看自己的订单、支付进度和退款申请。",
1544
1714
  centerRedeemIntro: "兑换余额或订阅权益,查看兑换记录。",
@@ -1687,6 +1857,7 @@ window.__ModuleLoader__.load({
1687
1857
  ...memberEn,
1688
1858
  ...businessEn,
1689
1859
  ...announcementEn,
1860
+ ...voiceProfileEn,
1690
1861
  centerRechargeIntro: "Choose balance credit or a subscription, review the cost and complete payment.",
1691
1862
  centerOrdersIntro: "View your orders, payment progress and refund requests.",
1692
1863
  centerRedeemIntro: "Redeem balance or subscription benefits and view history.",
@@ -2266,7 +2437,8 @@ window.__ModuleLoader__.load({
2266
2437
  "redeem",
2267
2438
  "affiliate",
2268
2439
  "profile",
2269
- "messages"
2440
+ "messages",
2441
+ "voice_profiles"
2270
2442
  ]);
2271
2443
  function normalizeAccountPage(page) {
2272
2444
  return page === "available_channels" ? "model_prices" : page;
@@ -2286,7 +2458,8 @@ window.__ModuleLoader__.load({
2286
2458
  redeem: "/redeem",
2287
2459
  affiliate: "/affiliate",
2288
2460
  profile: "/profile",
2289
- messages: "/dashboard"
2461
+ messages: "/dashboard",
2462
+ voice_profiles: "/dashboard"
2290
2463
  };
2291
2464
  function centerWebUrl(origin, page) {
2292
2465
  return `${new URL(origin).origin}${ACCOUNT_CENTER_WEB_PATHS[page]}`;
@@ -2821,6 +2994,42 @@ window.__ModuleLoader__.load({
2821
2994
  @container(max-width:560px){.member-polish{gap:14px}.member-polish .center-section{padding:17px}.member-polish-intro{align-items:flex-start;gap:10px}.member-polish-intro>p{font-size:11px}.member-polish-metrics{grid-template-columns:repeat(2,minmax(0,1fr));gap:9px}.member-polish-metric{padding:14px}.member-polish-metric>strong{font-size:23px}.member-polish-metric>span{font-size:10px}.member-polish .member-polish-redeem-card{padding:20px 17px}.member-polish-code-heading{gap:10px}.member-polish-credit-types{gap:5px}.member-polish-credit-types>span{font-size:10px;padding:3px 6px}.member-polish-transfer-content{display:grid;grid-template-columns:minmax(0,1fr)}.member-polish-transfer-content>*{grid-column:auto!important;grid-row:auto!important}.member-polish-transfer-total{display:flex;justify-content:space-between;align-items:baseline;padding-block:12px;border-block:1px solid var(--member-border)}.member-polish .center-member-facts{gap:12px}.member-polish-receipt-body{gap:11px}.member-polish-receipt-footer{gap:10px}.member-polish .center-member-pagination{align-items:flex-start;flex-direction:column;gap:12px}.member-polish .center-member-pagination>.center-member-actions{width:100%;justify-content:flex-end}}
2822
2995
  @container(max-width:380px){.member-polish .center-section{padding:14px}.member-polish .member-polish-redeem-card{padding:17px 13px}.member-polish-code-input{padding-left:8px}.member-polish-code-input>button{max-width:80px;font-size:10px;padding-inline:6px}.member-polish-gift{width:36px;height:36px;padding:8px}.member-polish-gift svg{width:20px;height:20px}.member-polish-credit-types{gap:4px}.member-polish-metric{padding:12px}.member-polish-metric>strong{font-size:21px}.member-polish-intro>button{padding-inline:8px}.member-polish-invitation-card .center-section-head{align-items:flex-start}.member-polish-invitation>code{padding:11px;font-size:11px}.member-polish-invitation>button{width:100%;justify-self:stretch}.member-polish-empty{padding:22px 12px}.member-polish .center-member-facts{grid-template-columns:1fr}}
2823
2996
  .member-polish-subtext{display:block;margin-top:2px;font-size:10px;font-weight:400;color:var(--member-muted)}.member-polish-more{display:flex;justify-content:center;margin-top:12px}.member-polish-program{display:grid;gap:4px;padding:12px 14px;border:1px solid var(--member-border);border-radius:8px;background:var(--member-inset);font-size:12px;line-height:1.6}.member-polish-program>p{margin:0}
2997
+ `;
2998
+ //#endregion
2999
+ //#region src/client/AccountCenter/voice-profile-styles.ts
3000
+ /**
3001
+ * 「我的音色」 styles, scoped under `.center-voices`. The page sits inside `.member-polish` (the 兑换 page's shell), so
3002
+ * it takes that shell's width, section padding and `--member-*` tokens (surface, inset, border, muted, accent) and its
3003
+ * dashed empty state (`.member-polish-empty`); every other color is a DSH theme token with the same fallbacks the
3004
+ * other account-center pages use, so light and dark themes both come from the host.
3005
+ */
3006
+ const VOICE_PROFILE_STYLES = `
3007
+ .member-polish.center-voices{max-width:880px;--voice-success:var(--dsw-alias-state-success-primary,#15803d);--voice-danger:var(--dsw-alias-state-error-primary,#c0392b);--voice-warn:var(--dsw-alias-state-warn-primary,#b77700)}
3008
+ .center-voices-intro>p{display:flex;flex-wrap:wrap;align-items:center;gap:8px;font-size:12px}.center-voices-free{display:inline-flex;align-items:center;padding:2px 9px;border-radius:999px;font-size:11px;font-weight:500;color:var(--member-accent);background:color-mix(in srgb,var(--member-accent) 9%,transparent)}
3009
+ .center-voices-form{display:grid;gap:18px;max-width:560px;min-width:0}.center-voices-form .center-field{display:grid;gap:8px;min-width:0;flex:none}.center-voices-form .center-field>label{font-size:12px;font-weight:500;color:var(--dsw-alias-label-primary,#202124)}
3010
+ .center-voices-hint{display:block;margin:0;font-size:11px;line-height:1.6;color:var(--member-muted)}
3011
+ .center-voices-drop{display:grid;justify-items:center;gap:6px;width:100%;padding:26px 16px;border:1.5px dashed var(--member-border);border-radius:10px;background:var(--member-inset);color:inherit;font:inherit;text-align:center;cursor:pointer;transition:border-color .15s,background-color .15s}.center-voices-drop strong{font-size:13px;font-weight:600}.center-voices-drop .center-muted{font-size:11px}
3012
+ .center-voices-drop:hover:not(:disabled),.center-voices-drop[data-over]{border-color:var(--member-accent);background:color-mix(in srgb,var(--member-accent) 6%,var(--member-surface))}.center-voices-drop:disabled{cursor:not-allowed;opacity:.55}
3013
+ .center-voices-drop-icon,.center-voices-avatar{display:inline-flex;align-items:center;justify-content:center;flex:none;border-radius:10px;color:var(--member-accent);background:color-mix(in srgb,var(--member-accent) 9%,var(--member-surface))}.center-voices-drop-icon{width:40px;height:40px}.center-voices-avatar{width:36px;height:36px;border-radius:9px}.center-voices-avatar svg{width:18px;height:18px}
3014
+ .center-voices-file-chip{display:flex;align-items:center;gap:12px;min-width:0;padding:10px 10px 10px 12px;border:1px solid var(--member-border);border-radius:10px;background:var(--member-inset)}.center-voices-file-chip[data-over]{border-color:var(--member-accent)}.center-voices-file-chip>button{flex:none}
3015
+ .center-voices-row-main{display:grid;gap:3px;flex:1;min-width:0}.center-voices-row-main strong{font-size:13px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.center-voices-row-meta{font-size:11px;color:var(--member-muted);font-variant-numeric:tabular-nums}
3016
+ .center-voices-submit{display:grid;justify-items:start;gap:6px}.center-voices-submit>button{min-height:38px;padding-inline:20px;font-weight:600}
3017
+ .center-voices-steps{display:flex;gap:8px;flex-wrap:wrap;margin:0;padding:0;list-style:none;font-size:11px}.center-voices-steps li{display:flex;align-items:center;gap:6px;padding:3px 10px;border-radius:999px;border:1px solid var(--member-border);color:var(--member-muted)}
3018
+ .center-voices-steps li[data-state=active]{color:var(--member-accent);border-color:var(--member-accent);font-weight:600}.center-voices-steps li[data-state=done]{color:var(--voice-success);border-color:color-mix(in srgb,var(--voice-success) 40%,transparent)}
3019
+ .center-voices-progress-box{display:grid;gap:8px}.center-voices-progress-box p{font-size:12px}.center-voices-progress{height:4px;border-radius:2px;background:var(--member-border);overflow:hidden}.center-voices-progress>span{display:block;height:100%;width:40%;background:var(--member-accent);animation:center-voices-bar 1.4s ease-in-out infinite}
3020
+ @keyframes center-voices-bar{0%{transform:translateX(-100%)}100%{transform:translateX(250%)}}@keyframes center-voices-spin{to{transform:rotate(360deg)}}@keyframes center-voices-pulse{50%{opacity:.45}}
3021
+ .center-voices-notice{margin:0;padding:10px 12px;border-radius:8px;font-size:12px;line-height:1.6}.center-voices-notice[data-tone=success]{color:var(--voice-success);background:color-mix(in srgb,var(--voice-success) 9%,transparent)}.center-voices-notice[data-tone=warn]{color:var(--voice-warn);background:color-mix(in srgb,var(--voice-warn) 10%,transparent)}.center-voices-notice[data-tone=danger]{color:var(--voice-danger);background:color-mix(in srgb,var(--voice-danger) 8%,transparent)}
3022
+ .center-voices-count{font-size:11px;color:var(--member-muted)}
3023
+ .center-voices-list{display:grid;margin:0;padding:0;list-style:none}.center-voices-row{display:flex;align-items:center;gap:12px;min-width:0;padding:12px 2px;border-bottom:1px solid var(--member-border)}.center-voices-row:last-child{border-bottom:0}.center-voices-row-title{display:flex;align-items:center;gap:8px;min-width:0}
3024
+ .center-voices-status{display:inline-flex;align-items:center;gap:5px;flex:none;padding:1px 8px;border-radius:999px;font-size:11px;font-weight:500;line-height:18px}
3025
+ .center-voices-status[data-status=ready]{color:var(--voice-success);background:color-mix(in srgb,var(--voice-success) 11%,transparent)}.center-voices-status[data-status=processing]{color:var(--member-accent);background:color-mix(in srgb,var(--member-accent) 11%,transparent)}.center-voices-status[data-status=failed]{color:var(--voice-danger);background:color-mix(in srgb,var(--voice-danger) 10%,transparent)}
3026
+ .center-voices-spinner{width:9px;height:9px;border:1.5px solid currentColor;border-right-color:transparent;border-radius:50%;animation:center-voices-spin .8s linear infinite}
3027
+ .center-voices-reason{font-size:11px;line-height:1.55;color:var(--voice-danger);overflow-wrap:anywhere}
3028
+ .center-voices .center-voices-delete{flex:none;color:var(--member-muted)}.center-voices-row:hover .center-voices-delete:not(:disabled),.center-voices .center-voices-delete:focus-visible{color:var(--voice-danger)}.center-voices .center-voices-delete:hover:not(:disabled){background:color-mix(in srgb,var(--voice-danger) 8%,transparent)}
3029
+ .member-polish-empty.center-voices-empty{width:100%;max-width:440px;margin:6px auto;padding:28px 20px}.center-voices-empty>strong{font-size:13px;font-weight:600}.center-voices-empty>span{color:var(--member-accent);opacity:1}.center-voices-empty[data-tone=warn]>span{color:var(--voice-warn)}.center-voices-empty>p{max-width:340px}
3030
+ .center-voices-skeleton{display:grid}.center-voices-skeleton-row{display:flex;align-items:center;gap:12px;padding:12px 2px;border-bottom:1px solid var(--member-border)}.center-voices-skeleton-row:last-of-type{border-bottom:0}.center-voices-skeleton-row>span{width:36px;height:36px;flex:none;border-radius:9px;background:var(--dsw-alias-bg-layer-3,#f2f4f7);animation:center-voices-pulse 1.4s ease-in-out infinite}.center-voices-skeleton-row>div{display:grid;gap:7px;flex:1}.center-voices-skeleton-row i{display:block;height:9px;border-radius:5px;background:var(--dsw-alias-bg-layer-3,#f2f4f7);animation:center-voices-pulse 1.4s ease-in-out infinite}.center-voices-skeleton-row i:first-child{width:38%}.center-voices-skeleton-row i:last-child{width:22%}
3031
+ .center-voices-confirm{display:grid;gap:8px;margin-bottom:12px;padding:14px;border:1px solid color-mix(in srgb,var(--voice-danger) 45%,transparent);border-radius:10px;background:color-mix(in srgb,var(--voice-danger) 5%,var(--member-surface))}.center-voices-confirm h3{margin:0;font-size:13px}.center-voices-confirm p{margin:0;font-size:12px}
3032
+ @container(max-width:560px){.center-voices-row{flex-wrap:wrap}.center-voices-row-main{flex-basis:calc(100% - 48px)}.center-voices .center-voices-delete{margin-left:48px;padding-inline:6px}.center-voices-drop{padding:20px 12px}.center-voices-submit>button{width:100%}.center-voices-submit{justify-items:stretch}}
2824
3033
  `;
2825
3034
  //#endregion
2826
3035
  //#region src/client/AccountCenter/shared.tsx
@@ -3007,7 +3216,7 @@ window.__ModuleLoader__.load({
3007
3216
  .center-detail-modal{width:min(720px,100%)!important;max-height:100%;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-2);overflow:hidden!important;gap:16px!important}.center-detail-modal-content{min-height:0;flex:1;overflow:hidden}.center-detail-modal-content>div:first-child{flex-shrink:0}.center-detail-modal-content>div:last-child{min-height:0;overflow-y:auto;overscroll-behavior:contain;margin-top:4px;padding-bottom:8px}.center-detail-modal>div:last-child{flex-shrink:0}.center-detail-modal .center-stack{gap:20px}.center-detail-modal .center-detail-list{font-size:13px;line-height:1.6}.center-detail-modal h3{font-size:14px;margin:0 0 12px}.center-detail-modal .center-muted{line-height:1.6}
3008
3217
  .vibedev-center{container-type:inline-size;font-size:13px;line-height:1.5}.center-stack{display:grid;gap:20px}.center-section{padding:20px;border:1px solid var(--dsw-alias-border-l2);border-radius:12px;background:var(--dsw-alias-bg-layer-2);min-width:0}.center-section-head{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:12px;margin-bottom:16px}.center-section h2{font-size:15px;margin:0}.center-section h3{font-size:14px;margin:0 0 12px}.center-muted{color:var(--dsw-alias-label-secondary);font-size:12px}.center-warning{color:var(--dsw-alias-state-warn-primary,#b77700)}.center-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,210px),1fr));gap:12px}.center-metric{padding:16px;border:1px solid var(--dsw-alias-border-l2);border-radius:8px;min-width:0}.center-metric-value{font-size:22px;font-weight:600;margin:8px 0;overflow-wrap:anywhere}.center-metric dl,.center-detail-list{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:6px 16px;margin:0}.center-metric dt,.center-detail-list dt{color:var(--dsw-alias-label-secondary)}.center-metric dd,.center-detail-list dd{margin:0;text-align:right;overflow-wrap:anywhere;font-variant-numeric:tabular-nums}.center-actions,.center-filters,.center-range{display:flex;flex-wrap:wrap;align-items:end;gap:12px}.center-range{gap:16px}.center-field{display:grid;gap:6px;min-width:120px;max-width:100%;flex:1}.center-field>span{font-size:12px;color:var(--dsw-alias-label-secondary)}.center-field select{font:inherit;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l2);border-radius:8px;min-height:34px;padding:6px 10px;max-width:100%}.center-scroll{overflow:auto;max-width:100%}.center-table{width:100%;border-collapse:collapse;font-size:12px;font-variant-numeric:tabular-nums}.center-table th,.center-table td{padding:10px 8px;text-align:left;border-bottom:1px solid var(--dsw-alias-border-l2);vertical-align:top;overflow-wrap:anywhere}.center-table th{font-weight:500;color:var(--dsw-alias-label-secondary);white-space:nowrap}.center-table button{font:inherit;color:inherit}.center-inline-button{background:transparent;border:0;padding:0;cursor:pointer;text-decoration:underline}.center-distribution{display:grid;grid-template-columns:100px minmax(0,1fr);gap:20px;align-items:start}.center-bars{display:grid;gap:10px;margin-top:8px}.center-bars progress{width:100%;accent-color:var(--dsw-alias-state-business-primary)}.center-columns{display:flex;gap:12px;flex-wrap:wrap;padding:12px 0}.center-columns label{display:flex;gap:6px;align-items:center}.center-chart{height:180px;width:100%;color:var(--dsw-alias-state-business-primary);overflow:visible}.center-chart-table{max-height:220px;margin-top:12px}.center-tabs{display:flex;gap:8px;border-bottom:1px solid var(--dsw-alias-border-l2);padding-bottom:12px}.center-tab[aria-selected=true]{font-weight:600;border-bottom:2px solid var(--dsw-alias-state-business-primary)}.center-sub-head{display:flex;flex-wrap:wrap;justify-content:space-between;gap:12px}.center-sub-head h2{margin:0;font-size:16px}.center-badge{display:inline-block;border:1px solid var(--dsw-alias-border-l2);border-radius:4px;padding:2px 6px;font-size:11px}.center-sub-window{display:grid;gap:6px;margin-top:16px}.center-sub-window progress{width:100%;accent-color:var(--dsw-alias-state-business-primary)}.center-sr-only{position:absolute;width:1px;height:1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.center-status{padding:8px 0;margin:0} .center-two-col{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,340px),1fr));gap:20px}
3009
3218
  @container(max-width:680px){.vibedev-center-nav{display:none}.vibedev-center-picker{display:block}.center-section{padding:16px}.center-distribution{grid-template-columns:1fr}.center-distribution>svg{display:none}.center-field{min-width:120px}.center-metric-value{font-size:20px}}
3010
- ` + CENTER_SHELL_STYLES + SUBSCRIPTION_UI_STYLES + DASHBOARD_STYLES + USAGE_UI_STYLES + PRICE_STYLES + STATUS_STYLES + COMMERCE_STYLES + ORDERS_STYLES + MEMBER_STYLES + MEMBER_POLISH_STYLES + PROFILE_STYLES + ANNOUNCEMENT_STYLES + `
3219
+ ` + CENTER_SHELL_STYLES + SUBSCRIPTION_UI_STYLES + DASHBOARD_STYLES + USAGE_UI_STYLES + PRICE_STYLES + STATUS_STYLES + COMMERCE_STYLES + ORDERS_STYLES + MEMBER_STYLES + MEMBER_POLISH_STYLES + PROFILE_STYLES + ANNOUNCEMENT_STYLES + VOICE_PROFILE_STYLES + `
3011
3220
  .center-ui-v2 .center-native-nav{flex-wrap:wrap;overflow:visible;flex:1;row-gap:0}.center-ui-v2 .center-business-receipt{display:grid;gap:10px}.center-business-receipt>h2,.center-business-receipt>p{margin:0}.center-business-confirm{padding:14px;border:1px solid var(--dsw-alias-border-l2,#dce0e6);border-radius:8px;background:var(--dsw-alias-bg-layer-3,#f7f8fa)}.center-business-operation code{font-size:12px}.center-business-confirm h3{margin:0 0 8px}.center-business-confirm .center-actions{margin-top:10px}
3012
3221
  @container(max-width:760px){.center-ui-v2 .center-native-nav{display:none}.center-ui-v2 .center-page-picker{display:block}.center-ui-v2 .center-navigation-row{padding-bottom:10px}}
3013
3222
  .center-refresh-icon{flex:none;transform-origin:center}.center-refresh-icon[data-busy=true]{animation:center-refresh-spin .9s linear infinite}@keyframes center-refresh-spin{to{transform:rotate(360deg)}}
@@ -6071,7 +6280,7 @@ window.__ModuleLoader__.load({
6071
6280
  */
6072
6281
  let cached;
6073
6282
  let inflight;
6074
- const record = (value) => typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
6283
+ const record$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
6075
6284
  const string = (value) => typeof value === "string" && value.trim() !== "" ? value : void 0;
6076
6285
  const amount = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : void 0;
6077
6286
  const identifier = (value) => {
@@ -6084,7 +6293,7 @@ window.__ModuleLoader__.load({
6084
6293
  * @returns the promotion, or undefined.
6085
6294
  */
6086
6295
  function parsePromotion(value) {
6087
- const source = record(value);
6296
+ const source = record$1(value);
6088
6297
  if (source === void 0) return void 0;
6089
6298
  const model = string(source.model);
6090
6299
  const startsAt = string(source.starts_at);
@@ -6093,7 +6302,7 @@ window.__ModuleLoader__.load({
6093
6302
  if (!Number.isFinite(Date.parse(startsAt)) || !Number.isFinite(Date.parse(endsAt))) return void 0;
6094
6303
  const dailyCap = amount(source.daily_cap);
6095
6304
  const tiers = Array.isArray(source.tiers) ? source.tiers.flatMap((item) => {
6096
- const tier = record(item);
6305
+ const tier = record$1(item);
6097
6306
  const prevSpendMin = tier === void 0 ? void 0 : amount(tier.prev_spend_min);
6098
6307
  const discountRate = tier === void 0 ? void 0 : amount(tier.discount_rate);
6099
6308
  return prevSpendMin === void 0 || discountRate === void 0 || discountRate <= 0 ? [] : [{
@@ -6117,8 +6326,8 @@ window.__ModuleLoader__.load({
6117
6326
  * @returns the listing, or undefined.
6118
6327
  */
6119
6328
  function parsePromotionListing(value) {
6120
- const body = record(value);
6121
- const data = record(body?.data);
6329
+ const body = record$1(value);
6330
+ const data = record$1(body?.data);
6122
6331
  const items = data?.items;
6123
6332
  if (!Array.isArray(items)) return void 0;
6124
6333
  const groupId = identifier(data?.group_id);
@@ -13880,6 +14089,1107 @@ window.__ModuleLoader__.load({
13880
14089
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ProfileContent, { ...props }, props.identity);
13881
14090
  }
13882
14091
  //#endregion
14092
+ //#region src/client/AccountCenter/voice-profile-api.ts
14093
+ const VOICE_ROUTE = "/api/dsh-vibedev/voice-profiles";
14094
+ const VOICE_DELETE_ROUTE = "/api/dsh-vibedev/voice-profiles/delete";
14095
+ /** Mirrors the Host's limits; the Host checks again. */
14096
+ const VOICE_LIMITS = {
14097
+ maxBytes: 10485760,
14098
+ minSeconds: 6,
14099
+ maxSeconds: 60,
14100
+ recommendedMinSeconds: 10,
14101
+ extensions: [
14102
+ "mp3",
14103
+ "wav",
14104
+ "m4a",
14105
+ "aac",
14106
+ "flac",
14107
+ "ogg"
14108
+ ],
14109
+ titleMax: 80
14110
+ };
14111
+ /** What the file picker offers. */
14112
+ const VOICE_ACCEPT = ".mp3,.wav,.m4a,.aac,.flac,.ogg,audio/mpeg,audio/wav,audio/x-wav,audio/mp4,audio/x-m4a,audio/aac,audio/flac,audio/ogg";
14113
+ const record = (value) => typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
14114
+ const str = (value) => typeof value === "string" && value !== "" ? value : void 0;
14115
+ /** A recognised provider refusal in the page's words (format, length, a recording too like an existing one, not a clean vocal). */
14116
+ const REJECTION_KEYS = {
14117
+ similar_recording: "voiceRejectSimilar",
14118
+ too_short: "voiceErrTooShort",
14119
+ too_long: "voiceErrTooLong",
14120
+ format: "voiceErrFormat",
14121
+ not_clean_vocal: "voiceRejectNotClean"
14122
+ };
14123
+ /** One profile from a Host answer; anything without a `vp_…` id is dropped. */
14124
+ function readVoiceProfile(value) {
14125
+ const raw = record(value);
14126
+ const id = str(raw?.id);
14127
+ if (raw === void 0 || id === void 0 || !/^vp_[A-Za-z0-9_-]{1,120}$/.test(id)) return void 0;
14128
+ const status = raw.status === "ready" ? "ready" : raw.status === "failed" ? "failed" : "processing";
14129
+ const seconds = typeof raw.durationSeconds === "number" && Number.isFinite(raw.durationSeconds) ? raw.durationSeconds : void 0;
14130
+ return {
14131
+ id,
14132
+ status,
14133
+ ...str(raw.title) === void 0 ? {} : { title: str(raw.title) },
14134
+ ...str(raw.failureReason) === void 0 ? {} : { failureReason: str(raw.failureReason) },
14135
+ ...typeof raw.failureKind === "string" && Object.hasOwn(REJECTION_KEYS, raw.failureKind) ? { failureKind: raw.failureKind } : {},
14136
+ ...seconds === void 0 ? {} : { durationSeconds: seconds },
14137
+ ...str(raw.createdAt) === void 0 ? {} : { createdAt: str(raw.createdAt) }
14138
+ };
14139
+ }
14140
+ /** The extension of a file name, lower-case. */
14141
+ const extension = (name) => /\.([a-z0-9]{2,5})$/i.exec(name)?.[1]?.toLowerCase();
14142
+ /** Rule names the Host reports, and the codes it uses, mapped to the page's words. */
14143
+ const CODE_KEYS = {
14144
+ VOICE_SAMPLE_FORMAT: "voiceErrFormat",
14145
+ VOICE_SAMPLE_EMPTY: "voiceErrEmpty",
14146
+ VOICE_SAMPLE_TOO_LARGE: "voiceErrTooLarge",
14147
+ VOICE_SAMPLE_TOO_SHORT: "voiceErrTooShort",
14148
+ VOICE_SAMPLE_TOO_LONG: "voiceErrTooLong",
14149
+ VOICE_SAMPLE_DURATION_UNKNOWN: "voiceErrDurationUnknown",
14150
+ VOICE_SAMPLE_UPLOAD_FAILED: "voiceErrUpload",
14151
+ VOICE_SAMPLE_URL_UNAVAILABLE: "voiceErrUpload",
14152
+ VOICE_TITLE_REQUIRED: "voiceErrTitle",
14153
+ VOICE_TITLE_INVALID: "voiceErrTitle",
14154
+ VOICE_TITLE_TOO_LONG: "voiceErrTitle",
14155
+ ACCOUNT_CHANGED: "voiceErrAccountChanged",
14156
+ VOICE_PROFILE_UNCONFIRMED: "voiceUnconfirmed"
14157
+ };
14158
+ /** Everything else, by the error category — the account center's own words (`centerError*`). */
14159
+ const CATEGORY_KEYS = {
14160
+ authentication: "centerErrorAuth",
14161
+ access_restricted: "centerRestricted",
14162
+ rate_limited: "centerErrorRate",
14163
+ billing: "centerErrorQuota",
14164
+ invalid_input: "centerErrorInvalid",
14165
+ content_rejected: "centerErrorInvalid",
14166
+ model_unavailable: "centerErrorUnavailable",
14167
+ service_unavailable: "centerErrorUnavailable",
14168
+ submission_uncertain: "centerErrorUpstream",
14169
+ internal_error: "centerErrorInternal"
14170
+ };
14171
+ /**
14172
+ * The words for a failure answer.
14173
+ * @param body - the Host's `{ error: { code, category } }`, or nothing for a network failure.
14174
+ * @returns the dictionary key and the code to show next to it.
14175
+ */
14176
+ function voiceFailureOf(body) {
14177
+ const error = record(record(body)?.error);
14178
+ const code = str(error?.code);
14179
+ const rule = str(error?.rule);
14180
+ return {
14181
+ key: (code === "VOICE_SAMPLE_REJECTED" && rule !== void 0 && Object.hasOwn(REJECTION_KEYS, rule) ? REJECTION_KEYS[rule] : void 0) ?? (code === void 0 ? void 0 : CODE_KEYS[code]) ?? CATEGORY_KEYS[str(error?.category) ?? ""] ?? (error === void 0 ? "centerErrorUnavailable" : "centerErrorInternal"),
14182
+ ...code === void 0 ? {} : { code }
14183
+ };
14184
+ }
14185
+ /**
14186
+ * Check a chosen file before anything is read: extension and size.
14187
+ * @param file - the file.
14188
+ * @returns the failure, or undefined when it may go on.
14189
+ */
14190
+ function checkVoiceFile(file) {
14191
+ const ext = extension(file.name);
14192
+ if (ext === void 0 || !VOICE_LIMITS.extensions.includes(ext)) return { key: "voiceErrFormat" };
14193
+ if (file.size === 0) return { key: "voiceErrEmpty" };
14194
+ if (file.size > VOICE_LIMITS.maxBytes) return { key: "voiceErrTooLarge" };
14195
+ }
14196
+ /** Check a measured length; an unmeasured one goes on (the Host measures it after the upload). */
14197
+ function checkVoiceSeconds(seconds) {
14198
+ if (seconds === void 0) return void 0;
14199
+ if (seconds < VOICE_LIMITS.minSeconds) return { key: "voiceErrTooShort" };
14200
+ if (seconds > VOICE_LIMITS.maxSeconds) return { key: "voiceErrTooLong" };
14201
+ }
14202
+ /** A title the Host takes: 1–80 characters after trimming. */
14203
+ function voiceTitleOk(title) {
14204
+ const value = title.replace(/\s+/g, " ").trim();
14205
+ return value !== "" && [...value].length <= VOICE_LIMITS.titleMax;
14206
+ }
14207
+ /**
14208
+ * The length of an audio file as the browser's own decoder reads it (metadata only).
14209
+ * @param file - the file.
14210
+ * @param timeoutMs - give up after this long.
14211
+ * @returns seconds, or undefined when the browser cannot tell.
14212
+ */
14213
+ function measureVoiceFile(file, timeoutMs = 1e4) {
14214
+ if (typeof document === "undefined" || typeof URL === "undefined" || typeof URL.createObjectURL !== "function") return Promise.resolve(void 0);
14215
+ return new Promise((resolve) => {
14216
+ const audio = document.createElement("audio");
14217
+ const url = URL.createObjectURL(file);
14218
+ let done = false;
14219
+ const finish = (value) => {
14220
+ if (done) return;
14221
+ done = true;
14222
+ clearTimeout(timer);
14223
+ audio.removeAttribute("src");
14224
+ URL.revokeObjectURL(url);
14225
+ resolve(value);
14226
+ };
14227
+ const timer = setTimeout(() => finish(void 0), timeoutMs);
14228
+ audio.preload = "metadata";
14229
+ audio.onloadedmetadata = () => finish(Number.isFinite(audio.duration) && audio.duration > 0 ? audio.duration : void 0);
14230
+ audio.onerror = () => finish(void 0);
14231
+ audio.src = url;
14232
+ });
14233
+ }
14234
+ /** A file's bytes as base64, for the Host route. */
14235
+ function fileBase64(file) {
14236
+ return new Promise((resolve, reject) => {
14237
+ const reader = new FileReader();
14238
+ reader.onerror = () => reject(reader.error ?? /* @__PURE__ */ new Error("read failed"));
14239
+ reader.onload = () => {
14240
+ const value = typeof reader.result === "string" ? reader.result : "";
14241
+ const comma = value.indexOf(",");
14242
+ if (comma < 0) reject(/* @__PURE__ */ new Error("read failed"));
14243
+ else resolve(value.slice(comma + 1));
14244
+ };
14245
+ reader.readAsDataURL(file);
14246
+ });
14247
+ }
14248
+ /**
14249
+ * When to read the list again while a voice is being created: 2 s, 3 s, 5 s, then every 8 s, for at most 5 minutes.
14250
+ * @param round - how many reads were made since the wait began.
14251
+ * @param elapsedMs - how long the wait has run.
14252
+ * @returns the delay, or undefined to stop (the page then offers 刷新).
14253
+ */
14254
+ function voicePollDelay(round, elapsedMs) {
14255
+ if (elapsedMs >= 3e5) return void 0;
14256
+ return [
14257
+ 2e3,
14258
+ 3e3,
14259
+ 5e3
14260
+ ][round] ?? 8e3;
14261
+ }
14262
+ /**
14263
+ * Which of the four steps (0 check, 1 upload and submit, 2 processing, 3 ready) a creation is at.
14264
+ * @param phase - the page's phase.
14265
+ * @param waitedSeconds - how long the creation has run.
14266
+ */
14267
+ function voiceStepOf(phase, waitedSeconds) {
14268
+ if (phase === "checking") return 0;
14269
+ if (phase === "uploading") return waitedSeconds >= 15 ? 2 : 1;
14270
+ if (phase === "confirming" || phase === "processing") return 2;
14271
+ return phase === "ready" ? 3 : -1;
14272
+ }
14273
+ /**
14274
+ * The voice a creation without an answer made: one listed now that was not listed before, under the same title first.
14275
+ * @param items - the list now.
14276
+ * @param before - the ids listed before the creation.
14277
+ * @param title - the title it was created under.
14278
+ */
14279
+ function findConfirmedVoice(items, before, title) {
14280
+ const fresh = items.filter((item) => !before.has(item.id));
14281
+ return fresh.find((item) => item.title === title) ?? fresh[0];
14282
+ }
14283
+ /** The signed-in user the page shows, from the account center's identity (`[origin, source, userId]`). */
14284
+ function expectedUserOf(identity) {
14285
+ try {
14286
+ const parts = JSON.parse(identity);
14287
+ return Array.isArray(parts) && typeof parts[2] === "string" && parts[2] !== "" ? parts[2] : void 0;
14288
+ } catch {
14289
+ return;
14290
+ }
14291
+ }
14292
+ const fetcherOf = (fetcher) => fetcher ?? ((input, init) => fetch(input, init));
14293
+ async function bodyOf(response) {
14294
+ try {
14295
+ return await response.json();
14296
+ } catch {
14297
+ return;
14298
+ }
14299
+ }
14300
+ /** Read the list. */
14301
+ async function listVoices(identity, signal, fetcher) {
14302
+ const user = expectedUserOf(identity);
14303
+ try {
14304
+ const response = await fetcherOf(fetcher)(VOICE_ROUTE, {
14305
+ ...signal === void 0 ? {} : { signal },
14306
+ headers: user === void 0 ? {} : { "X-VibeDev-Expected-User": user }
14307
+ });
14308
+ const body = record(await bodyOf(response));
14309
+ if (response.status === 404 || response.status === 405 || body?.unsupported === true) return { kind: "unsupported" };
14310
+ if (!response.ok) return {
14311
+ kind: "failed",
14312
+ failure: voiceFailureOf(body)
14313
+ };
14314
+ const items = record(body?.data)?.items;
14315
+ return {
14316
+ kind: "ready",
14317
+ items: Array.isArray(items) ? items.map(readVoiceProfile).filter((item) => item !== void 0) : []
14318
+ };
14319
+ } catch (error) {
14320
+ if (signal?.aborted === true) throw error;
14321
+ return {
14322
+ kind: "failed",
14323
+ failure: voiceFailureOf(void 0)
14324
+ };
14325
+ }
14326
+ }
14327
+ async function post(route, payload, read, fetcher) {
14328
+ try {
14329
+ const response = await fetcherOf(fetcher)(route, {
14330
+ method: "POST",
14331
+ headers: { "content-type": "application/json" },
14332
+ body: JSON.stringify(payload)
14333
+ });
14334
+ const body = await bodyOf(response);
14335
+ if (!response.ok) return {
14336
+ ok: false,
14337
+ failure: voiceFailureOf(body)
14338
+ };
14339
+ const value = read(record(body)?.data);
14340
+ return value === void 0 ? {
14341
+ ok: false,
14342
+ failure: { key: "centerErrorInternal" }
14343
+ } : {
14344
+ ok: true,
14345
+ value
14346
+ };
14347
+ } catch {
14348
+ return {
14349
+ ok: false,
14350
+ failure: voiceFailureOf(void 0)
14351
+ };
14352
+ }
14353
+ }
14354
+ /** Upload and create one voice. */
14355
+ function createVoice(identity, input, fetcher) {
14356
+ return post(VOICE_ROUTE, {
14357
+ ...input,
14358
+ expected_user_id: expectedUserOf(identity) ?? ""
14359
+ }, readVoiceProfile, fetcher);
14360
+ }
14361
+ /** Delete one voice for good. */
14362
+ function deleteVoice(identity, id, fetcher) {
14363
+ return post(VOICE_DELETE_ROUTE, {
14364
+ id,
14365
+ expected_user_id: expectedUserOf(identity) ?? ""
14366
+ }, (data) => str(record(data)?.id), fetcher);
14367
+ }
14368
+ //#endregion
14369
+ //#region src/client/AccountCenter/VoiceProfilesPage.tsx
14370
+ /**
14371
+ * 「我的音色」: the user's voice profiles for Suno voice covers — list (name, status with the failure reason, length,
14372
+ * creation time, delete), a new voice (choose a recording → checked here → uploaded → named → created → the list is
14373
+ * read again until it is ready), and deletion behind a confirmation that says it is permanent.
14374
+ */
14375
+ const seconds = (value) => (Math.round(value * 10) / 10).toFixed(1).replace(/\.0$/, "");
14376
+ const megabytes = (bytes) => `${(bytes / 1048576).toFixed(bytes < 1048576 ? 2 : 1)} MB`;
14377
+ /** A failure in the page's words, with the code when there is one. */
14378
+ function FailureText({ failure, t }) {
14379
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [t(failure.key), failure.code === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
14380
+ className: "center-muted",
14381
+ children: [" · ", fill$1(t("voiceErrorCode"), { code: failure.code })]
14382
+ })] });
14383
+ }
14384
+ /** Why a voice failed: a recognised refusal in plain words (the provider's reason after it), else the reason as it came. */
14385
+ function failureText(profile, t) {
14386
+ if (profile.failureKind !== void 0) {
14387
+ const plain = t(REJECTION_KEYS[profile.failureKind]);
14388
+ return profile.failureReason === void 0 ? plain : `${plain} ${fill$1(t("voiceRejectOriginal"), { reason: profile.failureReason })}`;
14389
+ }
14390
+ return profile.failureReason ?? t("voiceFailedUnknown");
14391
+ }
14392
+ /** The four steps of a creation and where it stands. */
14393
+ function VoiceSteps({ phase, waited = 0, t }) {
14394
+ const at = phase === "failed" || phase === "idle" ? -1 : voiceStepOf(phase, waited);
14395
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ol", {
14396
+ className: "center-voices-steps",
14397
+ "aria-label": t("voiceNewTitle"),
14398
+ children: [
14399
+ "voiceStepCheck",
14400
+ "voiceStepUpload",
14401
+ "voiceStepProcess",
14402
+ "voiceStepReady"
14403
+ ].map((label, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
14404
+ "data-state": index < at || phase === "ready" ? "done" : index === at ? "active" : "pending",
14405
+ "aria-current": index === at && phase !== "ready" ? "step" : void 0,
14406
+ children: [
14407
+ index + 1,
14408
+ ". ",
14409
+ t(label)
14410
+ ]
14411
+ }, label))
14412
+ });
14413
+ }
14414
+ /** Line icons in the account center's style (1.5 stroke, currentColor). */
14415
+ const ICON = {
14416
+ width: 20,
14417
+ height: 20,
14418
+ viewBox: "0 0 24 24",
14419
+ fill: "none",
14420
+ stroke: "currentColor",
14421
+ strokeWidth: 1.5,
14422
+ strokeLinecap: "round",
14423
+ strokeLinejoin: "round",
14424
+ "aria-hidden": true
14425
+ };
14426
+ function MicIcon() {
14427
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
14428
+ ...ICON,
14429
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
14430
+ x: "9",
14431
+ y: "3",
14432
+ width: "6",
14433
+ height: "11",
14434
+ rx: "3"
14435
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M5.5 11a6.5 6.5 0 0 0 13 0M12 17.5V21M8.5 21h7" })]
14436
+ });
14437
+ }
14438
+ function UploadIcon() {
14439
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
14440
+ ...ICON,
14441
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M12 16V4M7 9l5-5 5 5M4 16v2.5A1.5 1.5 0 0 0 5.5 20h13a1.5 1.5 0 0 0 1.5-1.5V16" })
14442
+ });
14443
+ }
14444
+ function WaveIcon() {
14445
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
14446
+ ...ICON,
14447
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M4 10v4M8 7v10M12 4v16M16 8v8M20 11v2" })
14448
+ });
14449
+ }
14450
+ function AlertIcon() {
14451
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
14452
+ ...ICON,
14453
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M12 4 2.8 19.5h18.4L12 4ZM12 10v4.5M12 17.2v.3" })
14454
+ });
14455
+ }
14456
+ function RefreshIcon() {
14457
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
14458
+ width: "14",
14459
+ height: "14",
14460
+ viewBox: "0 0 20 20",
14461
+ fill: "none",
14462
+ stroke: "currentColor",
14463
+ strokeWidth: "1.5",
14464
+ "aria-hidden": "true",
14465
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M16 8a6 6 0 1 0-1 7M16 3v5h-5" })
14466
+ });
14467
+ }
14468
+ /** One row's status as a pill (ready green, creating blue with a spinner, failed red), with the failure reason under a failed one. */
14469
+ function VoiceStatus({ profile, t }) {
14470
+ const label = profile.status === "ready" ? "voiceStatusReady" : profile.status === "failed" ? "voiceStatusFailed" : "voiceStatusProcessing";
14471
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
14472
+ className: "center-voices-status",
14473
+ "data-status": profile.status,
14474
+ children: [profile.status === "processing" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
14475
+ className: "center-voices-spinner",
14476
+ "aria-hidden": "true"
14477
+ }), t(label)]
14478
+ });
14479
+ }
14480
+ /** The list as rows: icon, name and status, 「时长 · 创建时间」, and delete on the right. */
14481
+ function VoiceTable({ items, t, busy, onDelete, onPick }) {
14482
+ if (items.length === 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
14483
+ className: "member-polish-empty center-voices-empty",
14484
+ "data-voice-empty": true,
14485
+ children: [
14486
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MicIcon, {}) }),
14487
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: t("voiceEmpty") }),
14488
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
14489
+ className: "center-muted",
14490
+ children: t("voiceEmptyHint")
14491
+ }),
14492
+ onPick !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
14493
+ type: "button",
14494
+ variant: "primary",
14495
+ size: "sm",
14496
+ "data-voice-empty-pick": true,
14497
+ onClick: onPick,
14498
+ children: t("voicePickFile")
14499
+ })
14500
+ ]
14501
+ });
14502
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
14503
+ className: "center-voices-list",
14504
+ "aria-label": t("voiceList"),
14505
+ "data-voice-table": true,
14506
+ children: items.map((profile) => {
14507
+ const facts = [profile.durationSeconds === void 0 ? void 0 : fill$1(t("voiceSeconds"), { seconds: seconds(profile.durationSeconds) }), profile.createdAt === void 0 ? void 0 : dateTime(profile.createdAt, t)].filter((item) => item !== void 0);
14508
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
14509
+ className: "center-voices-row",
14510
+ "data-voice-id": profile.id,
14511
+ "data-status": profile.status,
14512
+ children: [
14513
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
14514
+ className: "center-voices-avatar",
14515
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MicIcon, {})
14516
+ }),
14517
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
14518
+ className: "center-voices-row-main",
14519
+ children: [
14520
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
14521
+ className: "center-voices-row-title",
14522
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: profile.title ?? t("voiceUntitled") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(VoiceStatus, {
14523
+ profile,
14524
+ t
14525
+ })]
14526
+ }),
14527
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
14528
+ className: "center-voices-row-meta",
14529
+ children: facts.length === 0 ? "—" : facts.join(" · ")
14530
+ }),
14531
+ profile.status === "failed" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
14532
+ className: "center-voices-reason",
14533
+ children: failureText(profile, t)
14534
+ })
14535
+ ]
14536
+ }),
14537
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
14538
+ type: "button",
14539
+ variant: "ghost",
14540
+ size: "sm",
14541
+ className: "center-voices-delete",
14542
+ disabled: busy,
14543
+ "data-voice-delete": profile.id,
14544
+ "aria-label": `${t("voiceDelete")} ${profile.title ?? t("voiceUntitled")}`,
14545
+ onClick: () => onDelete(profile),
14546
+ children: t("voiceDelete")
14547
+ })
14548
+ ]
14549
+ }, profile.id);
14550
+ })
14551
+ });
14552
+ }
14553
+ /** A loading, failed or unsupported list, as a placeholder of the list's own shape rather than one line of text. */
14554
+ function VoicePlaceholder({ kind, t, failure, onRetry }) {
14555
+ if (kind === "loading") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
14556
+ className: "center-voices-skeleton",
14557
+ role: "status",
14558
+ "aria-label": t("voiceLoading"),
14559
+ "data-voice-loading": true,
14560
+ children: [[
14561
+ 0,
14562
+ 1,
14563
+ 2
14564
+ ].map((index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
14565
+ className: "center-voices-skeleton-row",
14566
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {})] })]
14567
+ }, index)), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
14568
+ className: "center-sr-only",
14569
+ children: t("voiceLoading")
14570
+ })]
14571
+ });
14572
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
14573
+ className: "member-polish-empty center-voices-empty",
14574
+ "data-tone": kind === "failed" ? "warn" : void 0,
14575
+ role: kind === "failed" ? "alert" : "status",
14576
+ "data-voice-placeholder": kind,
14577
+ children: [
14578
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: kind === "failed" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AlertIcon, {}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WaveIcon, {}) }),
14579
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: t(kind === "failed" ? "voiceLoadFailed" : "voiceUnsupportedTitle") }),
14580
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
14581
+ className: "center-muted",
14582
+ children: kind === "failed" && failure !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FailureText, {
14583
+ failure,
14584
+ t
14585
+ }) : t("voiceUnsupported")
14586
+ }),
14587
+ kind === "failed" && onRetry !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
14588
+ type: "button",
14589
+ variant: "outline",
14590
+ size: "sm",
14591
+ onClick: onRetry,
14592
+ children: t("voiceRetry")
14593
+ })
14594
+ ]
14595
+ });
14596
+ }
14597
+ /** The recording picker: a dashed drop area until a file is chosen, then a pill with its name, length and size. */
14598
+ function VoiceDropzone({ file, fileSeconds, disabled, t, onPick, onChoose }) {
14599
+ const [over, setOver] = (0, react.useState)(false);
14600
+ const drop = {
14601
+ onDragOver: (event) => {
14602
+ if (disabled) return;
14603
+ event.preventDefault();
14604
+ setOver(true);
14605
+ },
14606
+ onDragLeave: () => setOver(false),
14607
+ onDrop: (event) => {
14608
+ event.preventDefault();
14609
+ setOver(false);
14610
+ if (!disabled) onChoose(event.dataTransfer.files[0]);
14611
+ }
14612
+ };
14613
+ if (file === void 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
14614
+ type: "button",
14615
+ className: "center-voices-drop",
14616
+ "data-over": over || void 0,
14617
+ disabled,
14618
+ onClick: onPick,
14619
+ "data-voice-drop": true,
14620
+ ...drop,
14621
+ children: [
14622
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
14623
+ className: "center-voices-drop-icon",
14624
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(UploadIcon, {})
14625
+ }),
14626
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: t(over ? "voiceDropActive" : "voiceDropTitle") }),
14627
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
14628
+ className: "center-muted",
14629
+ children: t("voiceDropFormats")
14630
+ })
14631
+ ]
14632
+ });
14633
+ const facts = [typeof fileSeconds === "number" ? fill$1(t("voiceSeconds"), { seconds: seconds(fileSeconds) }) : fileSeconds === "measuring" ? t("voiceMeasuring") : void 0, megabytes(file.size)].filter((item) => item !== void 0);
14634
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
14635
+ className: "center-voices-file-chip",
14636
+ "data-over": over || void 0,
14637
+ "data-voice-file": true,
14638
+ ...drop,
14639
+ children: [
14640
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
14641
+ className: "center-voices-avatar",
14642
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WaveIcon, {})
14643
+ }),
14644
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
14645
+ className: "center-voices-row-main",
14646
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", {
14647
+ title: file.name,
14648
+ children: file.name
14649
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
14650
+ className: "center-voices-row-meta",
14651
+ children: facts.join(" · ")
14652
+ })]
14653
+ }),
14654
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
14655
+ type: "button",
14656
+ variant: "ghost",
14657
+ size: "sm",
14658
+ disabled,
14659
+ onClick: onPick,
14660
+ "data-voice-repick": true,
14661
+ children: t("voiceChangeFile")
14662
+ })
14663
+ ]
14664
+ });
14665
+ }
14666
+ /** The confirmation in front of a deletion. */
14667
+ function VoiceDeleteConfirm({ profile, t, busy, onConfirm, onCancel }) {
14668
+ const titleId = (0, react.useId)();
14669
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
14670
+ className: "center-voices-confirm",
14671
+ role: "alertdialog",
14672
+ "aria-labelledby": titleId,
14673
+ "data-voice-confirm": profile.id,
14674
+ children: [
14675
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
14676
+ id: titleId,
14677
+ children: fill$1(t("voiceDeleteTitle"), { title: profile.title ?? t("voiceUntitled") })
14678
+ }),
14679
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t("voiceDeleteBody") }),
14680
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
14681
+ className: "center-actions",
14682
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
14683
+ type: "button",
14684
+ variant: "primary",
14685
+ disabled: busy,
14686
+ "data-voice-confirm-delete": true,
14687
+ onClick: onConfirm,
14688
+ children: busy ? t("voiceDeleting") : t("voiceDeleteConfirm")
14689
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
14690
+ type: "button",
14691
+ variant: "outline",
14692
+ disabled: busy,
14693
+ onClick: onCancel,
14694
+ children: t("voiceDeleteCancel")
14695
+ })]
14696
+ })
14697
+ ]
14698
+ });
14699
+ }
14700
+ function VoiceProfilesContent({ identity, refresh, t }) {
14701
+ const reportActivity = (0, react.useContext)(CenterReadActivityContext);
14702
+ const [items, setItems] = (0, react.useState)();
14703
+ const [listState, setListState] = (0, react.useState)("loading");
14704
+ const [listFailure, setListFailure] = (0, react.useState)();
14705
+ const [reload, setReload] = (0, react.useState)(0);
14706
+ const poll = (0, react.useRef)({
14707
+ round: 0,
14708
+ since: 0
14709
+ });
14710
+ const [pollStopped, setPollStopped] = (0, react.useState)(false);
14711
+ const [file, setFile] = (0, react.useState)();
14712
+ const [fileSeconds, setFileSeconds] = (0, react.useState)();
14713
+ const [fileFailure, setFileFailure] = (0, react.useState)();
14714
+ const [title, setTitle] = (0, react.useState)("");
14715
+ const [titleInvalid, setTitleInvalid] = (0, react.useState)(false);
14716
+ const [phase, setPhase] = (0, react.useState)("idle");
14717
+ const [createFailure, setCreateFailure] = (0, react.useState)();
14718
+ const [created, setCreated] = (0, react.useState)();
14719
+ const [startedAt, setStartedAt] = (0, react.useState)(0);
14720
+ /** The ids listed before the last creation, to recognise the new one when the creation ended without an answer. */
14721
+ const [beforeIds, setBeforeIds] = (0, react.useState)(() => /* @__PURE__ */ new Set());
14722
+ const [now, setNow] = (0, react.useState)(() => Date.now());
14723
+ const [formKey, setFormKey] = (0, react.useState)(0);
14724
+ const [confirming, setConfirming] = (0, react.useState)();
14725
+ const [deleting, setDeleting] = (0, react.useState)(false);
14726
+ const [deleteFailure, setDeleteFailure] = (0, react.useState)();
14727
+ const [deleted, setDeleted] = (0, react.useState)(false);
14728
+ const fileId = (0, react.useId)(), titleId = (0, react.useId)();
14729
+ (0, react.useEffect)(() => {
14730
+ const controller = new AbortController(), token = Symbol("voice-profiles");
14731
+ reportActivity(token, true);
14732
+ listVoices(identity, controller.signal).then((result) => {
14733
+ if (controller.signal.aborted) return;
14734
+ if (result.kind === "ready") {
14735
+ setItems(result.items);
14736
+ setListState("ready");
14737
+ setListFailure(void 0);
14738
+ } else if (result.kind === "unsupported") setListState("unsupported");
14739
+ else {
14740
+ setListState("failed");
14741
+ setListFailure(result.failure);
14742
+ }
14743
+ }).catch(() => void 0).finally(() => reportActivity(token, false));
14744
+ return () => {
14745
+ controller.abort();
14746
+ reportActivity(token, false);
14747
+ };
14748
+ }, [
14749
+ identity,
14750
+ refresh,
14751
+ reload,
14752
+ reportActivity
14753
+ ]);
14754
+ const processing = items?.some((item) => item.status === "processing") === true || phase === "processing" || phase === "confirming";
14755
+ (0, react.useEffect)(() => {
14756
+ if (!processing) {
14757
+ poll.current = {
14758
+ round: 0,
14759
+ since: 0
14760
+ };
14761
+ setPollStopped(false);
14762
+ return;
14763
+ }
14764
+ if (poll.current.since === 0) poll.current.since = Date.now();
14765
+ const wait = voicePollDelay(poll.current.round, Date.now() - poll.current.since);
14766
+ if (wait === void 0) {
14767
+ setPollStopped(true);
14768
+ return;
14769
+ }
14770
+ const timer = setTimeout(() => {
14771
+ poll.current.round++;
14772
+ setReload((value) => value + 1);
14773
+ }, wait);
14774
+ return () => clearTimeout(timer);
14775
+ }, [processing, items]);
14776
+ (0, react.useEffect)(() => {
14777
+ if (phase !== "processing" && phase !== "uploading" && phase !== "confirming") return;
14778
+ const timer = setInterval(() => setNow(Date.now()), 1e3);
14779
+ return () => clearInterval(timer);
14780
+ }, [phase]);
14781
+ (0, react.useEffect)(() => {
14782
+ if (phase !== "confirming") return;
14783
+ const found = findConfirmedVoice(items ?? [], beforeIds, title.trim());
14784
+ if (found === void 0) return;
14785
+ setCreated(found);
14786
+ setCreateFailure(void 0);
14787
+ setPhase(found.status === "ready" ? "ready" : found.status === "failed" ? "failed" : "processing");
14788
+ }, [
14789
+ items,
14790
+ phase,
14791
+ beforeIds,
14792
+ title
14793
+ ]);
14794
+ (0, react.useEffect)(() => {
14795
+ if (created === void 0 || phase !== "processing") return;
14796
+ const found = items?.find((item) => item.id === created.id);
14797
+ if (found === void 0 || found.status === "processing") return;
14798
+ setCreated(found);
14799
+ setPhase(found.status === "ready" ? "ready" : "failed");
14800
+ }, [
14801
+ items,
14802
+ created,
14803
+ phase
14804
+ ]);
14805
+ const busy = phase === "checking" || phase === "uploading";
14806
+ /** Still confirming a creation without an answer (until the list reads stop, when retrying is offered). */
14807
+ const confirmingNow = phase === "confirming" && !pollStopped;
14808
+ const fileInput = (0, react.useRef)(null);
14809
+ /** Open the system picker (the drop area, 重新选择 and the empty list's button all lead here). */
14810
+ const pickFile = () => {
14811
+ fileInput.current?.focus();
14812
+ fileInput.current?.click();
14813
+ };
14814
+ const chooseFile = (chosen) => {
14815
+ if (chosen === void 0) return;
14816
+ if (fileInput.current !== null) fileInput.current.value = "";
14817
+ setFile(chosen);
14818
+ setFileFailure(void 0);
14819
+ setFileSeconds(void 0);
14820
+ setCreateFailure(void 0);
14821
+ if (phase === "failed" || phase === "ready") {
14822
+ setPhase("idle");
14823
+ setCreated(void 0);
14824
+ }
14825
+ if (chosen === void 0) return;
14826
+ const failure = checkVoiceFile(chosen);
14827
+ if (failure !== void 0) {
14828
+ setFileFailure(failure);
14829
+ return;
14830
+ }
14831
+ setFileSeconds("measuring");
14832
+ measureVoiceFile(chosen).then((measured) => {
14833
+ setFileSeconds(measured ?? "unknown");
14834
+ const tooLong = checkVoiceSeconds(measured);
14835
+ if (tooLong !== void 0) setFileFailure(tooLong);
14836
+ });
14837
+ };
14838
+ const submit = async (event) => {
14839
+ event.preventDefault();
14840
+ if (busy || confirmingNow || phase === "processing" || file === void 0) return;
14841
+ setCreateFailure(void 0);
14842
+ setCreated(void 0);
14843
+ setPhase("checking");
14844
+ const failure = checkVoiceFile(file) ?? checkVoiceSeconds(typeof fileSeconds === "number" ? fileSeconds : void 0);
14845
+ if (failure !== void 0) {
14846
+ setFileFailure(failure);
14847
+ setPhase("idle");
14848
+ return;
14849
+ }
14850
+ if (!voiceTitleOk(title)) {
14851
+ setTitleInvalid(true);
14852
+ setPhase("idle");
14853
+ return;
14854
+ }
14855
+ setBeforeIds(new Set((items ?? []).map((item) => item.id)));
14856
+ setStartedAt(Date.now());
14857
+ setNow(Date.now());
14858
+ setPhase("uploading");
14859
+ let data;
14860
+ try {
14861
+ data = await fileBase64(file);
14862
+ } catch {
14863
+ setCreateFailure({ key: "voiceErrRead" });
14864
+ setPhase("failed");
14865
+ return;
14866
+ }
14867
+ const result = await createVoice(identity, {
14868
+ title: title.trim(),
14869
+ filename: file.name,
14870
+ data
14871
+ });
14872
+ if (!result.ok) {
14873
+ setCreateFailure(result.failure);
14874
+ if (result.failure.code === "VOICE_PROFILE_UNCONFIRMED" || result.failure.code === "GATEWAY_TIMEOUT") {
14875
+ setPollStopped(false);
14876
+ poll.current = {
14877
+ round: 0,
14878
+ since: 0
14879
+ };
14880
+ setPhase("confirming");
14881
+ setReload((value) => value + 1);
14882
+ } else setPhase("failed");
14883
+ return;
14884
+ }
14885
+ const profile = result.value;
14886
+ setCreated(profile);
14887
+ setItems((current) => [profile, ...(current ?? []).filter((item) => item.id !== profile.id)]);
14888
+ if (profile.status === "ready") setPhase("ready");
14889
+ else if (profile.status === "failed") setPhase("failed");
14890
+ else setPhase("processing");
14891
+ };
14892
+ const another = () => {
14893
+ setFile(void 0);
14894
+ setFileSeconds(void 0);
14895
+ setFileFailure(void 0);
14896
+ setTitle("");
14897
+ setTitleInvalid(false);
14898
+ setPhase("idle");
14899
+ setCreated(void 0);
14900
+ setCreateFailure(void 0);
14901
+ setFormKey((value) => value + 1);
14902
+ };
14903
+ const confirmDelete = async () => {
14904
+ if (confirming === void 0 || deleting) return;
14905
+ setDeleting(true);
14906
+ setDeleteFailure(void 0);
14907
+ const result = await deleteVoice(identity, confirming.id);
14908
+ setDeleting(false);
14909
+ if (!result.ok) {
14910
+ setDeleteFailure(result.failure);
14911
+ return;
14912
+ }
14913
+ setItems((current) => (current ?? []).filter((item) => item.id !== confirming.id));
14914
+ setConfirming(void 0);
14915
+ setDeleted(true);
14916
+ setReload((value) => value + 1);
14917
+ };
14918
+ const waited = Math.max(0, Math.round((now - startedAt) / 1e3));
14919
+ const short = typeof fileSeconds === "number" && fileSeconds >= VOICE_LIMITS.minSeconds && fileSeconds < VOICE_LIMITS.recommendedMinSeconds;
14920
+ const locked = busy || confirmingNow || phase === "processing";
14921
+ /** Why 创建音色 cannot be pressed yet, shown under it (and as its tooltip). */
14922
+ const blockedReason = locked ? void 0 : file === void 0 ? t("voiceNeedFile") : title.trim() === "" ? t("voiceNeedName") : void 0;
14923
+ const refreshList = () => {
14924
+ setDeleted(false);
14925
+ setReload((value) => value + 1);
14926
+ };
14927
+ const refreshButton = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
14928
+ type: "button",
14929
+ variant: "outline",
14930
+ size: "sm",
14931
+ disabled: listState === "loading" && items === void 0,
14932
+ onClick: refreshList,
14933
+ "data-voice-refresh": true,
14934
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RefreshIcon, {}),
14935
+ children: t("voiceRefresh")
14936
+ });
14937
+ if (listState === "unsupported") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
14938
+ className: "member-polish center-voices",
14939
+ "data-voice-page": true,
14940
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
14941
+ className: "center-section",
14942
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(VoicePlaceholder, {
14943
+ kind: "unsupported",
14944
+ t
14945
+ })
14946
+ })
14947
+ });
14948
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
14949
+ className: "member-polish center-voices",
14950
+ "data-voice-page": true,
14951
+ children: [
14952
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
14953
+ className: "member-polish-intro center-voices-intro",
14954
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
14955
+ className: "center-muted",
14956
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
14957
+ className: "center-voices-free",
14958
+ children: t("voiceFree")
14959
+ }), t("voiceKeepNote")]
14960
+ }), refreshButton]
14961
+ }),
14962
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Section, {
14963
+ className: "center-voices-card",
14964
+ title: t("voiceNewTitle"),
14965
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
14966
+ className: "center-voices-form",
14967
+ onSubmit: (event) => {
14968
+ submit(event);
14969
+ },
14970
+ "data-voice-form": true,
14971
+ children: [
14972
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
14973
+ className: "center-field",
14974
+ children: [
14975
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
14976
+ htmlFor: fileId,
14977
+ children: t("voiceFile")
14978
+ }),
14979
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
14980
+ ref: fileInput,
14981
+ id: fileId,
14982
+ className: "center-sr-only",
14983
+ type: "file",
14984
+ accept: VOICE_ACCEPT,
14985
+ "aria-label": t("voiceChooseFile"),
14986
+ disabled: locked,
14987
+ tabIndex: -1,
14988
+ onChange: (event) => chooseFile(event.target.files?.[0])
14989
+ }),
14990
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(VoiceDropzone, {
14991
+ ...file === void 0 ? {} : { file },
14992
+ ...fileSeconds === void 0 ? {} : { fileSeconds },
14993
+ disabled: locked,
14994
+ t,
14995
+ onPick: pickFile,
14996
+ onChoose: chooseFile
14997
+ }),
14998
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", {
14999
+ className: "center-voices-hint",
15000
+ title: t("voiceFileHint"),
15001
+ children: t("voiceFileAdvice")
15002
+ })
15003
+ ]
15004
+ }),
15005
+ fileSeconds === "unknown" && fileFailure === void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
15006
+ className: "center-voices-hint",
15007
+ role: "status",
15008
+ children: t("voiceFileSecondsUnknown")
15009
+ }),
15010
+ short && fileFailure === void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
15011
+ className: "center-voices-hint",
15012
+ children: t("voiceFileShortHint")
15013
+ }),
15014
+ fileFailure !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
15015
+ className: "center-warning",
15016
+ role: "alert",
15017
+ "data-voice-file-error": true,
15018
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FailureText, {
15019
+ failure: fileFailure,
15020
+ t
15021
+ })
15022
+ }),
15023
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
15024
+ className: "center-field",
15025
+ children: [
15026
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
15027
+ htmlFor: titleId,
15028
+ children: t("voiceName")
15029
+ }),
15030
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Input, {
15031
+ id: titleId,
15032
+ value: title,
15033
+ maxLength: VOICE_LIMITS.titleMax,
15034
+ placeholder: t("voiceNamePlaceholder"),
15035
+ disabled: locked,
15036
+ "aria-invalid": titleInvalid,
15037
+ onChange: (event) => {
15038
+ setTitle(event.target.value);
15039
+ setTitleInvalid(false);
15040
+ }
15041
+ }),
15042
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", {
15043
+ className: "center-voices-hint",
15044
+ children: fill$1(t("voiceNameHint"), { max: VOICE_LIMITS.titleMax })
15045
+ })
15046
+ ]
15047
+ }),
15048
+ titleInvalid && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
15049
+ className: "center-warning",
15050
+ role: "alert",
15051
+ children: t("voiceErrTitle")
15052
+ }),
15053
+ phase !== "idle" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(VoiceSteps, {
15054
+ phase,
15055
+ waited,
15056
+ t
15057
+ }),
15058
+ (busy || confirmingNow || phase === "processing") && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
15059
+ className: "center-voices-progress-box",
15060
+ role: "status",
15061
+ "aria-live": "polite",
15062
+ "data-voice-progress": true,
15063
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
15064
+ className: "center-voices-progress",
15065
+ "aria-hidden": "true",
15066
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {})
15067
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
15068
+ className: "center-muted",
15069
+ children: phase === "checking" ? t("voiceChecking") : phase === "uploading" ? voiceStepOf("uploading", waited) >= 2 ? fill$1(t("voiceWaitingGateway"), { seconds: waited }) : t("voiceUploading") : phase === "confirming" ? fill$1(t("voiceConfirming"), { seconds: waited }) : fill$1(t(pollStopped ? "voiceProcessingSlow" : "voiceProcessing"), { seconds: waited })
15070
+ })]
15071
+ }),
15072
+ phase === "confirming" && pollStopped && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
15073
+ className: "center-voices-notice",
15074
+ "data-tone": "warn",
15075
+ role: "status",
15076
+ "data-voice-unconfirmed": true,
15077
+ children: t("voiceUnconfirmed")
15078
+ }),
15079
+ phase === "ready" && created !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
15080
+ className: "center-voices-notice",
15081
+ "data-tone": "success",
15082
+ role: "status",
15083
+ children: fill$1(t("voiceReadyNotice"), { title: created.title ?? title })
15084
+ }),
15085
+ phase === "failed" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
15086
+ className: "center-voices-notice",
15087
+ "data-tone": "danger",
15088
+ role: "alert",
15089
+ "data-voice-create-error": true,
15090
+ children: createFailure !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FailureText, {
15091
+ failure: createFailure,
15092
+ t
15093
+ }) : fill$1(t("voiceFailedNotice"), { reason: created === void 0 ? t("voiceFailedUnknown") : failureText(created, t) })
15094
+ }),
15095
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
15096
+ className: "center-voices-submit",
15097
+ children: [phase === "ready" || phase === "failed" && createFailure === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
15098
+ type: "button",
15099
+ variant: "outline",
15100
+ onClick: another,
15101
+ children: t("voiceCreateAnother")
15102
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
15103
+ type: "submit",
15104
+ variant: "primary",
15105
+ "data-voice-create": true,
15106
+ title: blockedReason,
15107
+ disabled: locked || file === void 0 || fileFailure !== void 0 || fileSeconds === "measuring" || title.trim() === "",
15108
+ children: t("voiceCreate")
15109
+ }), blockedReason !== void 0 && phase !== "ready" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", {
15110
+ className: "center-voices-hint",
15111
+ "data-voice-blocked": true,
15112
+ children: blockedReason
15113
+ })]
15114
+ })
15115
+ ]
15116
+ }, formKey)
15117
+ }),
15118
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Section, {
15119
+ className: "center-voices-card",
15120
+ title: t("voiceList"),
15121
+ action: items !== void 0 && items.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
15122
+ className: "center-voices-count",
15123
+ children: fill$1(t("voiceListCount"), { count: items.length })
15124
+ }) : void 0,
15125
+ children: [
15126
+ deleted && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
15127
+ className: "center-voices-notice",
15128
+ "data-tone": "success",
15129
+ role: "status",
15130
+ children: t("voiceDeleted")
15131
+ }),
15132
+ confirming !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(VoiceDeleteConfirm, {
15133
+ profile: confirming,
15134
+ t,
15135
+ busy: deleting,
15136
+ onConfirm: () => {
15137
+ confirmDelete();
15138
+ },
15139
+ onCancel: () => {
15140
+ setConfirming(void 0);
15141
+ setDeleteFailure(void 0);
15142
+ }
15143
+ }),
15144
+ deleteFailure !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
15145
+ className: "center-warning",
15146
+ role: "alert",
15147
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FailureText, {
15148
+ failure: deleteFailure,
15149
+ t
15150
+ })
15151
+ }),
15152
+ listState === "failed" && listFailure !== void 0 && items !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
15153
+ className: "center-warning",
15154
+ role: "alert",
15155
+ "data-voice-list-error": true,
15156
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(FailureText, {
15157
+ failure: listFailure,
15158
+ t
15159
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
15160
+ className: "center-muted",
15161
+ children: [" · ", t("centerStale")]
15162
+ })]
15163
+ }),
15164
+ items !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(VoiceTable, {
15165
+ items,
15166
+ t,
15167
+ busy: deleting,
15168
+ onPick: pickFile,
15169
+ onDelete: (profile) => {
15170
+ setDeleted(false);
15171
+ setDeleteFailure(void 0);
15172
+ setConfirming(profile);
15173
+ }
15174
+ }) : listState === "failed" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(VoicePlaceholder, {
15175
+ kind: "failed",
15176
+ t,
15177
+ ...listFailure === void 0 ? {} : { failure: listFailure },
15178
+ onRetry: refreshList
15179
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(VoicePlaceholder, {
15180
+ kind: "loading",
15181
+ t
15182
+ })
15183
+ ]
15184
+ })
15185
+ ]
15186
+ });
15187
+ }
15188
+ /** The page; a different account starts it afresh. */
15189
+ function VoiceProfilesPage(props) {
15190
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(VoiceProfilesContent, { ...props }, props.identity);
15191
+ }
15192
+ //#endregion
13883
15193
  //#region src/client/AccountCenter.tsx
13884
15194
  const ACCOUNT_CENTER_PANEL = "vibedev-account-center";
13885
15195
  const PAGES = [
@@ -13893,12 +15203,29 @@ window.__ModuleLoader__.load({
13893
15203
  ["redeem", "centerRedeem"],
13894
15204
  ["affiliate", "centerAffiliate"],
13895
15205
  ["profile", "centerProfile"],
15206
+ ["voice_profiles", "centerVoiceProfiles"],
13896
15207
  ["messages", "centerMessages"]
13897
15208
  ];
13898
15209
  function AccountCenterIcon({ size = 16 }) {
13899
15210
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconUserOutlineMedium, { size });
13900
15211
  }
13901
15212
  function PageIcon({ page }) {
15213
+ if (page === "voice_profiles") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
15214
+ viewBox: "0 0 20 20",
15215
+ width: "16",
15216
+ height: "16",
15217
+ fill: "none",
15218
+ stroke: "currentColor",
15219
+ strokeWidth: "1.5",
15220
+ "aria-hidden": "true",
15221
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
15222
+ x: "7.5",
15223
+ y: "2.5",
15224
+ width: "5",
15225
+ height: "9",
15226
+ rx: "2.5"
15227
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M4.5 9.5a5.5 5.5 0 0 0 11 0M10 15v2.5" })]
15228
+ });
13902
15229
  if (page === "messages") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
13903
15230
  viewBox: "0 0 20 20",
13904
15231
  width: "16",
@@ -14006,7 +15333,7 @@ window.__ModuleLoader__.load({
14006
15333
  setRefresh((value) => value + 1);
14007
15334
  Promise.allSettled([store.refresh(true), store.refreshSubscriptions(true)]).finally(() => setRefreshing(false));
14008
15335
  };
14009
- const intro = page === "dashboard" ? "centerDashboardIntro" : page === "usage" ? "centerUsageIntro" : page === "subscriptions" ? "centerSubscriptionsIntro" : page === "channel_status" ? "centerMonitorIntro" : page === "model_prices" ? "centerModelPricesIntro" : page === "recharge" ? "centerRechargeIntro" : page === "orders" ? "centerOrdersIntro" : page === "redeem" ? "centerRedeemIntro" : page === "affiliate" ? "centerAffiliateIntro" : page === "profile" ? "centerProfileIntro" : page === "messages" ? "centerMessagesIntro" : "centerWebsiteHint";
15336
+ const intro = page === "dashboard" ? "centerDashboardIntro" : page === "usage" ? "centerUsageIntro" : page === "subscriptions" ? "centerSubscriptionsIntro" : page === "channel_status" ? "centerMonitorIntro" : page === "model_prices" ? "centerModelPricesIntro" : page === "recharge" ? "centerRechargeIntro" : page === "orders" ? "centerOrdersIntro" : page === "redeem" ? "centerRedeemIntro" : page === "affiliate" ? "centerAffiliateIntro" : page === "profile" ? "centerProfileIntro" : page === "messages" ? "centerMessagesIntro" : page === "voice_profiles" ? "centerVoiceProfilesIntro" : "centerWebsiteHint";
14010
15337
  const accountUpdated = () => {
14011
15338
  store.refresh(true);
14012
15339
  store.refreshSubscriptions(true);
@@ -14144,6 +15471,11 @@ window.__ModuleLoader__.load({
14144
15471
  store: announcements,
14145
15472
  t
14146
15473
  }),
15474
+ page === "voice_profiles" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(VoiceProfilesPage, {
15475
+ identity,
15476
+ refresh,
15477
+ t
15478
+ }, identity),
14147
15479
  page === "dashboard" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Dashboard, {
14148
15480
  store,
14149
15481
  view: account.view,