dsh-model-allowance 1.0.6 → 1.1.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/README.md +12 -4
- package/README.zh.md +7 -4
- package/client.js +1487 -1228
- package/lib/balance.js +156 -20
- package/lib/debug.js +72 -13
- package/lib/providers/deepseek.js +4 -82
- package/lib/providers/holidays.js +89 -0
- package/lib/providers/placeholder.js +6 -62
- package/lib/providers/schedule.js +8 -6
- package/lib/providers/shared.js +6 -4
- package/lib/providers/xiaomi.js +285 -0
- package/lib/providers.js +44 -15
- package/lib/remote.js +3 -1
- package/package.json +2 -1
package/client.js
CHANGED
|
@@ -42,11 +42,14 @@ __export(index_exports, {
|
|
|
42
42
|
inject: () => inject
|
|
43
43
|
});
|
|
44
44
|
module.exports = __toCommonJS(index_exports);
|
|
45
|
-
var
|
|
45
|
+
var import_react8 = require("react");
|
|
46
46
|
|
|
47
47
|
// src/client/badge.js
|
|
48
|
-
var
|
|
49
|
-
var
|
|
48
|
+
var React6 = __toESM(require("react"), 1);
|
|
49
|
+
var import_react7 = require("react");
|
|
50
|
+
|
|
51
|
+
// src/client/components/balance-panel.js
|
|
52
|
+
var import_react6 = require("react");
|
|
50
53
|
|
|
51
54
|
// src/client/format.js
|
|
52
55
|
var CURRENCY_SYMBOLS = {
|
|
@@ -224,6 +227,67 @@ var OPENCODE_PATHS = [
|
|
|
224
227
|
{ d: "M180 240H60V120H180V240Z", opacity: 0.5 },
|
|
225
228
|
{ d: "M180 60H60V240H180V60ZM240 300H0V0H240V300Z", opacity: 1 }
|
|
226
229
|
];
|
|
230
|
+
var QWEN_PATHS = [
|
|
231
|
+
"M27.0482997609375,16.093917358203125L23.2809152609375,13.918146358203124C23.374042060937498,13.757291758203126,23.4248380609375,13.573860658203126,23.4248380609375,13.381963758203124L23.4248380609375,12.217883958203124C23.4248380609375,11.835501458203126,23.2202429609375,11.481338678203125,22.888655660937502,11.289441828203126L21.8797874609375,10.706696778203124C21.5482001609375,10.514799900203124,21.1404194609375,10.514799900203124,20.8088343609375,10.706696778203124L17.7201426009375,12.490208158203124C17.3885564509375,12.682105058203124,17.1839599609375,13.034856558203124,17.1839599609375,13.418650158203125L17.1839599609375,14.582729858203125C17.1839599609375,14.965112658203125,17.3885553809375,15.319275358203125,17.7201426009375,15.511172258203125L24.9684791609375,19.696214658203125C25.300065960937502,19.888112058203127,25.7078466609375,19.888112058203127,26.0394315609375,19.696214658203125L27.0482997609375,19.113469158203124C27.379887960937502,18.921571758203125,27.5844829609375,18.568820958203126,27.5844829609375,18.185026658203125L27.5844829609375,17.020946958203126C27.5844829609375,16.638564558203125,27.379887960937502,16.284401858203125,27.0482997609375,16.092504958203126L27.0482997609375,16.093917358203125Z",
|
|
232
|
+
"M22.335545490625,3.7476133590625L18.568160490625,5.923384639062499C18.475033490625,5.7625300390625,18.342399590625,5.627073739062499,18.175900890625,5.5311251390625L17.167031490625,4.9483796390625C16.835445390625,4.7564827390625,16.427664590625,4.7564827390625,16.096077490625,4.9483796390625L15.087208030625,5.5311251390625C14.755621880625,5.7230219390625,14.551025390625,6.0757734390625,14.551025390625,6.459567339062501L14.551025390625,10.026589839062499C14.551025390625,10.4089722390625,14.755620810625,10.7631349390625,15.087208030625,10.9550318390625L16.096077490625,11.5377769390625C16.427663590625,11.7296743390625,16.835444190625,11.7296743390625,17.167030290625,11.5377769390625L24.415367090625,7.3527338390625C24.746954390625,7.1608369390625,24.951549390625,6.8080854390625,24.951549390625,6.4242920390625L24.951549390625,5.2602123390625C24.951549390625,4.8778299390625,24.746954390625,4.5236670990625,24.415367090625,4.3317704790625005L23.406498890625002,3.7490251990625C23.074911090625,3.5571283180625,22.667130490625,3.5571283180625,22.335545490625,3.7490251990625L22.335545490625,3.7476133590625Z",
|
|
233
|
+
"M9.2878987390625,1.6551098L9.2878987390625,6.0052404C9.1030566390625,6.0052404,8.9182152390625,6.053215,8.7517166390625,6.1491632L7.7428471490625,6.7319088C7.4112609890625,6.9238057,7.2066650390625,7.276557,7.2066650390625,7.6603503L7.2066650390625,8.8244305C7.2066650390625,9.2068129,7.4112609890625,9.560976,7.7428471490625,9.7528725L10.8315389390625,11.536385C11.1631250390625,11.728281,11.570905639062499,11.728281,11.902493039062499,11.536385L12.9113621390625,10.953639C13.2429485390625,10.761743,13.4475450390625,10.408991,13.4475450390625,10.025197L13.4475450390625,1.6551098C13.4475450390625,1.2727274,13.2429494390625,0.91856486,12.9113621390625,0.726668L11.902493039062499,0.1439226C11.5709066390625,-0.047974203,11.1631262390625,-0.047974203,10.8315398390625,0.1439226L9.8226704390625,0.726668C9.4910843390625,0.91856486,9.2864885390625,1.2713163,9.2864885390625,1.6551098L9.2878987390625,1.6551098Z",
|
|
234
|
+
"M0.95170956375,11.90887979140625L4.71909524375,14.08465049140625C4.62596894375,14.245504891406249,4.57517244375,14.428935991406249,4.57517244375,14.62083289140625L4.57517244375,15.78491309140625C4.57517244375,16.16729549140625,4.77976844375,16.52145859140625,5.11135484375,16.71335509140625L6.12022404375,17.296099691406248C6.45181034375,17.487997091796875,6.85959104375,17.487997091796875,7.19117734375,17.296099691406248L10.27987004375,15.51258899140625C10.61145634375,15.32069209140625,10.81605234375,14.96794029140625,10.81605234375,14.584146491406251L10.81605234375,13.42006679140625C10.81605234375,13.03768439140625,10.61145734375,12.68352179140625,10.27987004375,12.491624791406249L3.03153274375,8.30658135140625C2.69994644375,8.11468447040625,2.2921658437500003,8.11468447040625,1.96057944375,8.30658135140625L0.95171022375,8.88932693140625C0.62012319375,9.07981253140625,0.41552734375,9.43397519140625,0.41552734375,9.81635769140625L0.41552734375,10.98043749140625C0.41552734375,11.36281989140625,0.62012319375,11.71698289140625,0.95170956375,11.90887979140625Z",
|
|
235
|
+
"M5.6630003703125,24.25519135703125L9.430386070312501,22.07942055703125C9.523513270312499,22.24027485703125,9.6561469703125,22.37573245703125,9.8226456703125,22.47168015703125L10.8315148703125,23.05442615703125C11.1631011703125,23.24632315703125,11.5708818703125,23.24632315703125,11.9024686703125,23.05442615703125L12.9113387703125,22.47168015703125C13.2429250703125,22.279783257031248,13.4475210703125,21.92703155703125,13.4475210703125,21.54323765703125L13.4475210703125,17.97621525703125C13.4475210703125,17.59383275703125,13.2429260703125,17.23966997703125,12.9113387703125,17.04777312703125L11.9024686703125,16.46502807703125C11.5708827703125,16.27313119903125,11.1631021703125,16.27313119903125,10.8315162703125,16.46502807703125L3.5831791803125,20.65007065703125C3.2515927603125,20.84196755703125,3.0469970703125,21.19471935703125,3.0469970703125,21.57851315703125L3.0469970703125,22.742592857031248C3.0469970703125,23.12497615703125,3.2515930203125,23.47913785703125,3.5831791803125,23.671034857031252L4.5920482703125,24.253780857031252C4.9236347703125,24.44567775703125,5.3314153703125005,24.44567775703125,5.6630019703125,24.253780857031252L5.6630003703125,24.25519135703125Z",
|
|
236
|
+
"M18.7120137640625,26.347708765625L18.7120137640625,21.997577665625002C18.8968553640625,21.997577665625002,19.0816964640625,21.949604065625,19.2481965640625,21.853654365625L20.2570648640625,21.270908365625C20.588652164062502,21.079011465625,20.7932476640625,20.726260165625,20.7932476640625,20.342466365625L20.7932476640625,19.178386465625C20.7932476640625,18.796002865625,20.588652164062502,18.441841165625,20.2570648640625,18.249944365625L17.1683730640625,16.466432955625C16.8367869640625,16.274536084625,16.4290063640625,16.274536084625,16.0974202640625,16.466432955625L15.0885508040625,17.049178005625C14.7569646540625,17.241074855625,14.5523681640625,17.593826265625,14.5523681640625,17.977620165625L14.5523681640625,26.347706765625C14.5523681640625,26.730089765625,14.7569635840625,27.084252765625,15.0885508040625,27.276148765625003L16.0974202640625,27.858895765625C16.4290063640625,28.050791765625,16.8367869640625,28.050791765625,17.1683730640625,27.858895765625L18.1772425640625,27.276148765625003C18.5088286640625,27.084252765625,18.713424164062502,26.731500765625,18.713424164062502,26.347706765625L18.7120137640625,26.347708765625Z"
|
|
237
|
+
];
|
|
238
|
+
var QWEN_GRADIENTS = [
|
|
239
|
+
{
|
|
240
|
+
id: "dsh-balance-qwen-0",
|
|
241
|
+
x1: -0.9480395913124084,
|
|
242
|
+
y1: -1.0930798053741455,
|
|
243
|
+
x2: 1.292371777143182,
|
|
244
|
+
y2: 0.9053882745851343
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
id: "dsh-balance-qwen-1",
|
|
248
|
+
x1: -0.4444444477558136,
|
|
249
|
+
y1: -0.7164570093154907,
|
|
250
|
+
x2: 2.0650320456884637,
|
|
251
|
+
y2: 1.2322934398033913
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
id: "dsh-balance-qwen-2",
|
|
255
|
+
x1: -0.1266109049320221,
|
|
256
|
+
y1: 0.11379560083150864,
|
|
257
|
+
x2: 1.3623472942105739,
|
|
258
|
+
y2: 2.9004999850663093
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
id: "dsh-balance-qwen-3",
|
|
262
|
+
x1: 4070004215463996e-19,
|
|
263
|
+
y1: -0.0901901125907898,
|
|
264
|
+
x2: 2.240818614500846,
|
|
265
|
+
y2: 1.9082775852882916
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
id: "dsh-balance-qwen-4",
|
|
269
|
+
x1: -0.5029168128967285,
|
|
270
|
+
y1: -0.7912299036979675,
|
|
271
|
+
x2: 2.006559339146774,
|
|
272
|
+
y2: 1.1575211847572104
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
id: "dsh-balance-qwen-5",
|
|
276
|
+
x1: -2.119149923324585,
|
|
277
|
+
y1: -0.8479101061820984,
|
|
278
|
+
x2: -0.6301921696742209,
|
|
279
|
+
y2: 1.9387942856270293
|
|
280
|
+
}
|
|
281
|
+
];
|
|
282
|
+
var QWEN_GRADIENT_STOPS = [
|
|
283
|
+
["#082DFF", "0"],
|
|
284
|
+
["#3FD2F9", "1"]
|
|
285
|
+
];
|
|
286
|
+
var XIAOMI_PATHS = [
|
|
287
|
+
"M73.7449 15.9987C73.4083 15.998 73.0857 15.8638 72.8479 15.6256C72.6101 15.3873 72.4766 15.0644 72.4766 14.7278V7.165C72.4914 6.83757 72.632 6.52848 72.869 6.30203C73.1059 6.07559 73.4211 5.94922 73.7488 5.94922C74.0766 5.94922 74.3918 6.07559 74.6287 6.30203C74.8657 6.52848 75.0062 6.83757 75.0211 7.165V14.7278C75.0208 14.895 74.9875 15.0606 74.9232 15.215C74.8588 15.3693 74.7647 15.5095 74.6462 15.6276C74.5277 15.7456 74.3871 15.8391 74.2325 15.9028C74.0778 15.9665 73.9122 15.9991 73.7449 15.9987Z",
|
|
288
|
+
"M87.3607 15.9993C87.0234 15.9993 86.6998 15.8655 86.4611 15.6272C86.2223 15.389 86.0878 15.0657 86.0871 14.7284V4.67881L81.4654 9.45281C81.2304 9.69657 80.9081 9.83697 80.5695 9.84312C80.231 9.84928 79.9038 9.72069 79.6601 9.48563C79.4163 9.25058 79.2759 8.92832 79.2697 8.58976C79.2667 8.42211 79.2967 8.25551 79.358 8.09947C79.4194 7.94342 79.5108 7.80098 79.6272 7.68028L86.4469 0.661082C86.6229 0.478921 86.8494 0.35354 87.0973 0.301033C87.3451 0.248526 87.603 0.271291 87.8378 0.366403C88.0727 0.461516 88.2737 0.624637 88.4151 0.834827C88.5566 1.04502 88.632 1.29268 88.6317 1.54603V14.7284C88.6317 15.0655 88.4978 15.3887 88.2594 15.6271C88.021 15.8654 87.6978 15.9993 87.3607 15.9993Z",
|
|
289
|
+
"M80.5514 9.82621C80.3824 9.82749 80.2149 9.79518 80.0584 9.73117C79.902 9.66716 79.7599 9.57272 79.6402 9.45332L72.8337 2.4315C72.599 2.18948 72.4701 1.86414 72.4752 1.52705C72.4804 1.18996 72.6193 0.868726 72.8613 0.634023C73.1033 0.399319 73.4287 0.270369 73.7658 0.27554C74.1028 0.280711 74.4241 0.419579 74.6588 0.661595L81.4653 7.66767C81.6389 7.84735 81.7558 8.07413 81.8015 8.31977C81.8472 8.56541 81.8196 8.81906 81.7222 9.04914C81.6248 9.27922 81.4618 9.47557 81.2537 9.61374C81.0455 9.75191 80.8013 9.8258 80.5514 9.82621Z"
|
|
290
|
+
];
|
|
227
291
|
var ICON_GEOMETRY = {
|
|
228
292
|
// DeepSeek's square icon draws 1..49.35 across and 7..43.35 down.
|
|
229
293
|
deepseek: { x: 1, y: 7, vbW: 48.35, vbH: 36.35, inkW: 48.35, inkH: 36.35 },
|
|
@@ -233,7 +297,13 @@ var ICON_GEOMETRY = {
|
|
|
233
297
|
// Kimi's K-only glyph draws 0..23.95 across and 0.94..24.19 down.
|
|
234
298
|
kimi: { x: 0, y: 0.94, vbW: 23.95, vbH: 23.25, inkW: 23.95, inkH: 23.25 },
|
|
235
299
|
// OpenCode's logo draws its 240x300 frame from the origin.
|
|
236
|
-
opencode: { x: 0, y: 0, vbW: 240, vbH: 300, inkW: 240, inkH: 300 }
|
|
300
|
+
opencode: { x: 0, y: 0, vbW: 240, vbH: 300, inkW: 240, inkH: 300 },
|
|
301
|
+
// Qwen's petals draw 0.42..27.58 across and -0.05..28.05 down, so the
|
|
302
|
+
// published 28x28 box would clip a hair of the outer petals.
|
|
303
|
+
qwen: { x: 0.4155, y: -0.048, vbW: 27.169, vbH: 28.0988, inkW: 27.169, inkH: 28.0988 },
|
|
304
|
+
// MiMo's M draws 72.475..88.632 across and 0.273..16.0 down inside the
|
|
305
|
+
// wordmark's own space; the box is cropped to the glyph.
|
|
306
|
+
xiaomi: { x: 72.475, y: 0.2734, vbW: 16.1567, vbH: 15.7259, inkW: 16.1567, inkH: 15.7259 }
|
|
237
307
|
};
|
|
238
308
|
function markOf(entry, route) {
|
|
239
309
|
const color = typeof entry?.color === "string" && entry.color !== "" ? entry.color : "#6b7280";
|
|
@@ -289,6 +359,37 @@ function providerIcon(route, inkHeight, mark) {
|
|
|
289
359
|
content = KIMI_PATHS.map(
|
|
290
360
|
(d, index) => (0, import_react.createElement)("path", { key: `kimi-${String(index)}`, d, fill: "currentColor" })
|
|
291
361
|
);
|
|
362
|
+
} else if (mark.icon === "qwen") {
|
|
363
|
+
content = [
|
|
364
|
+
(0, import_react.createElement)(
|
|
365
|
+
"defs",
|
|
366
|
+
{ key: "defs" },
|
|
367
|
+
...QWEN_GRADIENTS.map(
|
|
368
|
+
(gradient) => (0, import_react.createElement)(
|
|
369
|
+
"linearGradient",
|
|
370
|
+
{
|
|
371
|
+
key: gradient.id,
|
|
372
|
+
id: gradient.id,
|
|
373
|
+
x1: gradient.x1,
|
|
374
|
+
y1: gradient.y1,
|
|
375
|
+
x2: gradient.x2,
|
|
376
|
+
y2: gradient.y2,
|
|
377
|
+
gradientUnits: "objectBoundingBox"
|
|
378
|
+
},
|
|
379
|
+
...QWEN_GRADIENT_STOPS.map(
|
|
380
|
+
([color, offset]) => (0, import_react.createElement)("stop", { key: offset, offset, stopColor: color })
|
|
381
|
+
)
|
|
382
|
+
)
|
|
383
|
+
)
|
|
384
|
+
),
|
|
385
|
+
...QWEN_PATHS.map(
|
|
386
|
+
(d, index) => (0, import_react.createElement)("path", {
|
|
387
|
+
key: `qwen-${String(index)}`,
|
|
388
|
+
d,
|
|
389
|
+
fill: `url(#${String(QWEN_GRADIENTS[index].id)})`
|
|
390
|
+
})
|
|
391
|
+
)
|
|
392
|
+
];
|
|
292
393
|
} else if (mark.icon === "opencode") {
|
|
293
394
|
content = OPENCODE_PATHS.map(
|
|
294
395
|
(path, index) => (0, import_react.createElement)("path", {
|
|
@@ -298,6 +399,10 @@ function providerIcon(route, inkHeight, mark) {
|
|
|
298
399
|
fillOpacity: path.opacity
|
|
299
400
|
})
|
|
300
401
|
);
|
|
402
|
+
} else if (mark.icon === "xiaomi") {
|
|
403
|
+
content = XIAOMI_PATHS.map(
|
|
404
|
+
(d, index) => (0, import_react.createElement)("path", { key: `xiaomi-${String(index)}`, d, fill: "#1F2329" })
|
|
405
|
+
);
|
|
301
406
|
} else {
|
|
302
407
|
content = [(0, import_react.createElement)("path", { key: "mark", d: DEEPSEEK_PATH, fill: "currentColor" })];
|
|
303
408
|
}
|
|
@@ -469,96 +574,6 @@ function statusLabel(state, t) {
|
|
|
469
574
|
return key === void 0 ? t("status.unknown") : t(key);
|
|
470
575
|
}
|
|
471
576
|
|
|
472
|
-
// src/client/models.js
|
|
473
|
-
function providerGroup(catalog, provider) {
|
|
474
|
-
const groups = Array.isArray(catalog?.groups) ? catalog.groups : [];
|
|
475
|
-
return groups.find((group) => group?.id === provider);
|
|
476
|
-
}
|
|
477
|
-
function modelsForProvider(catalog, provider) {
|
|
478
|
-
const group = providerGroup(catalog, provider);
|
|
479
|
-
const models = Array.isArray(group?.models) ? group.models : [];
|
|
480
|
-
return models.filter((model) => typeof model?.id === "string" && model.id !== "");
|
|
481
|
-
}
|
|
482
|
-
function providerModelGroup(catalog, routes) {
|
|
483
|
-
const seen = /* @__PURE__ */ new Set();
|
|
484
|
-
for (const route of routes) {
|
|
485
|
-
if (typeof route !== "string" || route === "" || seen.has(route)) continue;
|
|
486
|
-
seen.add(route);
|
|
487
|
-
const models = modelsForProvider(catalog, route);
|
|
488
|
-
if (models.length > 0) return { provider: route, models };
|
|
489
|
-
}
|
|
490
|
-
return void 0;
|
|
491
|
-
}
|
|
492
|
-
function effortChoices(model) {
|
|
493
|
-
const reasoning = model?.reasoning;
|
|
494
|
-
const efforts = Array.isArray(reasoning?.efforts) ? reasoning.efforts : [];
|
|
495
|
-
if (efforts.length === 0) return null;
|
|
496
|
-
const entries = efforts.filter((effort) => typeof effort?.id === "string" && effort.id !== "").map((effort) => ({
|
|
497
|
-
id: effort.id,
|
|
498
|
-
name: typeof effort.name === "string" && effort.name !== "" ? effort.name : effort.id,
|
|
499
|
-
isDefault: effort.id === reasoning.defaultEffort
|
|
500
|
-
}));
|
|
501
|
-
if (reasoning.defaultEffort === void 0) {
|
|
502
|
-
entries.unshift({ id: void 0, providerDefault: true });
|
|
503
|
-
}
|
|
504
|
-
return entries;
|
|
505
|
-
}
|
|
506
|
-
function currentModelFor(selection, provider) {
|
|
507
|
-
const next = selection?.next ?? selection?.lastUsed;
|
|
508
|
-
if (next?.provider !== provider) return void 0;
|
|
509
|
-
return typeof next.model === "string" ? next.model : void 0;
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
// src/client/namespace.js
|
|
513
|
-
var balanceNamespace = null;
|
|
514
|
-
var settleBalanceNamespace;
|
|
515
|
-
var balanceNamespaceReady = new Promise((resolve) => {
|
|
516
|
-
settleBalanceNamespace = resolve;
|
|
517
|
-
});
|
|
518
|
-
async function getBalanceApi() {
|
|
519
|
-
if (balanceNamespace) return balanceNamespace;
|
|
520
|
-
return await balanceNamespaceReady;
|
|
521
|
-
}
|
|
522
|
-
function lookupBalanceNamespace(ctx) {
|
|
523
|
-
try {
|
|
524
|
-
return ctx.get("remote.balance");
|
|
525
|
-
} catch {
|
|
526
|
-
return void 0;
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
function setBalanceNamespace(value) {
|
|
530
|
-
balanceNamespace = value;
|
|
531
|
-
settleBalanceNamespace(value);
|
|
532
|
-
return value;
|
|
533
|
-
}
|
|
534
|
-
var modelSupport;
|
|
535
|
-
function resetBalanceNamespace() {
|
|
536
|
-
balanceNamespace = null;
|
|
537
|
-
modelSupport = void 0;
|
|
538
|
-
}
|
|
539
|
-
function lookupSessionFace(ctx) {
|
|
540
|
-
try {
|
|
541
|
-
const face = ctx.get("remote.session");
|
|
542
|
-
if (face !== void 0) return face;
|
|
543
|
-
} catch {
|
|
544
|
-
}
|
|
545
|
-
return ctx.remote?.session;
|
|
546
|
-
}
|
|
547
|
-
async function supportsModel(api) {
|
|
548
|
-
if (modelSupport !== void 0) return modelSupport;
|
|
549
|
-
if (typeof api?.capabilities !== "function") {
|
|
550
|
-
modelSupport = false;
|
|
551
|
-
return modelSupport;
|
|
552
|
-
}
|
|
553
|
-
try {
|
|
554
|
-
const result = await api.capabilities();
|
|
555
|
-
modelSupport = result?.ok === true && result.value?.modelScoped === true;
|
|
556
|
-
} catch {
|
|
557
|
-
modelSupport = false;
|
|
558
|
-
}
|
|
559
|
-
return modelSupport;
|
|
560
|
-
}
|
|
561
|
-
|
|
562
577
|
// src/client/schedule.js
|
|
563
578
|
var import_react2 = require("react");
|
|
564
579
|
function formatCountdown(ms) {
|
|
@@ -753,335 +768,6 @@ function scheduleView(schedule, now, t) {
|
|
|
753
768
|
);
|
|
754
769
|
}
|
|
755
770
|
|
|
756
|
-
// src/client/styles.js
|
|
757
|
-
var STYLES = [
|
|
758
|
-
".dsh-model-allowance-root{position:relative;display:inline-flex;align-items:center}",
|
|
759
|
-
// The badge is a trigger, the way the harness's own composer triggers
|
|
760
|
-
// are: no frame of its own, a transparent surface, and the hover tint
|
|
761
|
-
// only while the pointer is on it or the card is open. A bordered pill
|
|
762
|
-
// read as a field rather than a control.
|
|
763
|
-
".dsh-model-allowance-badge{display:inline-flex;align-items:center;gap:6px;height:24px;padding:0 8px;",
|
|
764
|
-
"border:0;border-radius:var(--dsw-radius-sm);background:0 0;",
|
|
765
|
-
"color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:1;cursor:pointer;",
|
|
766
|
-
"font-variant-numeric:tabular-nums;white-space:nowrap}",
|
|
767
|
-
".dsh-model-allowance-badge:hover{color:var(--dsw-alias-label-secondary);",
|
|
768
|
-
"background:var(--dsw-alias-interactive-bg-hover)}",
|
|
769
|
-
'.dsh-model-allowance-badge[aria-expanded="true"]{color:var(--dsw-alias-label-secondary);',
|
|
770
|
-
"background:var(--dsw-alias-interactive-bg-hover)}",
|
|
771
|
-
".dsh-model-allowance-badge:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);",
|
|
772
|
-
"outline-offset:1px}",
|
|
773
|
-
".dsh-model-allowance-dot{width:6px;height:6px;border-radius:50%;flex:none;",
|
|
774
|
-
"background:var(--dsw-alias-state-idle-primary)}",
|
|
775
|
-
// The dot reports the platform, not the reading: green while the service
|
|
776
|
-
// is available, red once its own status page says otherwise, and grey
|
|
777
|
-
// when this installation has no status source for the route.
|
|
778
|
-
'.dsh-model-allowance-root[data-service="operational"] .dsh-model-allowance-dot{',
|
|
779
|
-
"background:var(--dsw-alias-state-success-primary)}",
|
|
780
|
-
'.dsh-model-allowance-root[data-service="degraded"] .dsh-model-allowance-dot,',
|
|
781
|
-
'.dsh-model-allowance-root[data-service="partial-outage"] .dsh-model-allowance-dot,',
|
|
782
|
-
'.dsh-model-allowance-root[data-service="major-outage"] .dsh-model-allowance-dot,',
|
|
783
|
-
'.dsh-model-allowance-root[data-service="maintenance"] .dsh-model-allowance-dot{',
|
|
784
|
-
"background:var(--dsw-alias-state-error-primary)}",
|
|
785
|
-
'.dsh-model-allowance-root[data-loading="true"] .dsh-model-allowance-dot{opacity:.5}',
|
|
786
|
-
// The turn's difference rides beside the value for a few seconds. It is
|
|
787
|
-
// quieter than the value so the balance stays the thing being read, and
|
|
788
|
-
// it fades in rather than popping.
|
|
789
|
-
".dsh-model-allowance-delta{margin-left:-2px;font-size:11px;",
|
|
790
|
-
"color:var(--dsw-alias-label-secondary);animation:dsh-model-allowance-fade 200ms ease-out}",
|
|
791
|
-
'.dsh-model-allowance-delta[data-direction="up"]{',
|
|
792
|
-
"color:var(--dsw-alias-state-success-primary)}",
|
|
793
|
-
"@keyframes dsh-model-allowance-fade{from{opacity:0}to{opacity:1}}",
|
|
794
|
-
// Anchored to its own right edge: the badge sits next to the model seat
|
|
795
|
-
// near the trailing edge, so the panel opens leftwards instead of
|
|
796
|
-
// running off the side of the composer.
|
|
797
|
-
//
|
|
798
|
-
// The surface is the harness's own menu surface — a translucent white
|
|
799
|
-
// behind a heavy blur — and the shadow is its own elevation scale. The
|
|
800
|
-
// overlay token reads as a mask over the page behind, not as a panel
|
|
801
|
-
// surface: on it this card came out a flat grey slab.
|
|
802
|
-
// The floor is set for the layout, not for the content: with it removed
|
|
803
|
-
// the card collapses to 248px, so 300px is the slack that lets a label
|
|
804
|
-
// and its value read as two columns instead of one run-on line. The cap
|
|
805
|
-
// is the harness's own idiom for a floating surface, so a narrow window
|
|
806
|
-
// shrinks the card rather than pushing it off the composer.
|
|
807
|
-
".dsh-model-allowance-panel{position:absolute;bottom:calc(100% + 6px);right:0;z-index:20;",
|
|
808
|
-
"box-sizing:border-box;min-width:300px;max-width:calc(100vw - 24px);",
|
|
809
|
-
"padding:8px 10px 10px;border:0;",
|
|
810
|
-
"border-radius:var(--dsw-radius-lg);background:var(--dsw-specific-menu);",
|
|
811
|
-
"backdrop-filter:var(--dsw-menu-backdrop-filter);",
|
|
812
|
-
"box-shadow:var(--dsw-elevation-prominent);color:var(--dsw-alias-label-primary);",
|
|
813
|
-
"font-size:12px}",
|
|
814
|
-
".dsh-model-allowance-row{display:flex;justify-content:space-between;gap:16px;padding:2px 0}",
|
|
815
|
-
// Label first, value second, matching every other pair in the card
|
|
816
|
-
// (schedule title/state, status/reading time): the label carries the
|
|
817
|
-
// emphasis and the value reads as its detail. Reversed, the balance row
|
|
818
|
-
// stood out as the one pair laid out the other way round.
|
|
819
|
-
".dsh-model-allowance-row>span:first-child{color:var(--dsw-alias-label-primary)}",
|
|
820
|
-
".dsh-model-allowance-row>span:last-child{color:var(--dsw-alias-label-secondary)}",
|
|
821
|
-
".dsh-model-allowance-usage{font-variant-numeric:tabular-nums;",
|
|
822
|
-
"color:var(--dsw-alias-label-secondary)}",
|
|
823
|
-
// The row cancels the panel's own horizontal padding so the divider under
|
|
824
|
-
// it runs edge to edge, then puts the same padding back so the first mark
|
|
825
|
-
// lines up with the labels below. Without this the marks sit further from
|
|
826
|
-
// the edge than every other row and the whole strip reads as shifted left.
|
|
827
|
-
".dsh-model-allowance-switcher-wrap{position:relative;margin:-2px -10px 6px;",
|
|
828
|
-
"padding:0 10px 8px;border-bottom:1px solid var(--dsw-alias-border-l1)}",
|
|
829
|
-
".dsh-model-allowance-switcher{display:flex;flex-wrap:nowrap;align-items:center;",
|
|
830
|
-
"gap:4px;overflow:hidden}",
|
|
831
|
-
// The mark sits straight on the panel; the chip draws no surface of its
|
|
832
|
-
// own, so the panel's own surface shows through behind the logo.
|
|
833
|
-
//
|
|
834
|
-
// A frame means one thing here: this is the provider being read. It is
|
|
835
|
-
// not used to say anything else about a route, because a second meaning
|
|
836
|
-
// makes an unselected mark look selected.
|
|
837
|
-
".dsh-model-allowance-tab{display:inline-flex;align-items:center;justify-content:center;",
|
|
838
|
-
"box-sizing:border-box;width:26px;height:26px;flex:none;padding:0;",
|
|
839
|
-
"border:1px solid transparent;border-radius:var(--dsw-radius-sm);",
|
|
840
|
-
"background:0 0;line-height:1;cursor:pointer;",
|
|
841
|
-
"color:var(--provider-mark,var(--dsw-alias-label-primary));opacity:.66}",
|
|
842
|
-
".dsh-model-allowance-tab:hover{opacity:.9}",
|
|
843
|
-
// The selected mark gains the one frame the chip already has, and stops
|
|
844
|
-
// being dimmed. It must not use the brand colour: in this theme that is
|
|
845
|
-
// #0f1115, so a selected chip wore a near-black frame. It also gains no
|
|
846
|
-
// background, since any fill here reintroduces a tile on the panel.
|
|
847
|
-
'.dsh-model-allowance-tab[data-active="true"]{opacity:1;',
|
|
848
|
-
"border-color:var(--dsw-alias-border-l2)}",
|
|
849
|
-
".dsh-model-allowance-tab:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);",
|
|
850
|
-
"outline-offset:-1px}",
|
|
851
|
-
".dsh-model-allowance-tab svg{display:block}",
|
|
852
|
-
".dsh-model-allowance-tab-letter{font-size:11px;font-weight:600;line-height:1}",
|
|
853
|
-
".dsh-model-allowance-more{display:inline-flex;align-items:center;justify-content:center;",
|
|
854
|
-
"box-sizing:border-box;width:26px;height:26px;flex:none;margin-left:auto;padding:0;",
|
|
855
|
-
"border-radius:var(--dsw-radius-sm);",
|
|
856
|
-
"border:1px solid var(--dsw-alias-border-l1);background:0 0;cursor:pointer;",
|
|
857
|
-
"color:var(--dsw-alias-label-tertiary);font-size:13px;line-height:1}",
|
|
858
|
-
".dsh-model-allowance-more:hover{color:var(--dsw-alias-label-secondary);",
|
|
859
|
-
"border-color:var(--dsw-alias-border-l2)}",
|
|
860
|
-
// The overflow menu is a second floating surface, so it carries the same
|
|
861
|
-
// menu surface and elevation as the card it belongs to.
|
|
862
|
-
".dsh-model-allowance-menu{position:absolute;top:calc(100% + 2px);right:0;z-index:30;",
|
|
863
|
-
"min-width:150px;padding:4px;border:0;",
|
|
864
|
-
"border-radius:var(--dsw-radius-md);background:var(--dsw-specific-menu);",
|
|
865
|
-
"backdrop-filter:var(--dsw-menu-backdrop-filter);",
|
|
866
|
-
"box-shadow:var(--dsw-elevation-prominent)}",
|
|
867
|
-
".dsh-model-allowance-menu-item{display:flex;align-items:center;gap:8px;width:100%;",
|
|
868
|
-
"padding:4px 6px;border:0;border-radius:var(--dsw-radius-xs);background:0 0;",
|
|
869
|
-
"color:var(--dsw-alias-label-primary);font-size:12px;text-align:left;cursor:pointer}",
|
|
870
|
-
".dsh-model-allowance-menu-item:hover{background:var(--dsw-alias-interactive-bg-hover)}",
|
|
871
|
-
// Same rule as the strip chips: no surface of its own, so the mark sits
|
|
872
|
-
// on the menu instead of on a tile.
|
|
873
|
-
".dsh-model-allowance-menu-mark{display:inline-flex;align-items:center;",
|
|
874
|
-
"justify-content:center;width:20px;height:20px;flex:none;border-radius:var(--dsw-radius-xs);",
|
|
875
|
-
"line-height:1;background:0 0;",
|
|
876
|
-
"color:var(--provider-mark,var(--dsw-alias-label-primary))}",
|
|
877
|
-
".dsh-model-allowance-menu-mark svg{display:block}",
|
|
878
|
-
// The model list is a third floating surface. It opens upwards from the
|
|
879
|
-
// footer button, so it carries the same menu surface and elevation as the
|
|
880
|
-
// card and the provider overflow menu.
|
|
881
|
-
".dsh-model-allowance-model-wrap{position:relative;display:inline-flex}",
|
|
882
|
-
".dsh-model-allowance-model-menu{position:absolute;bottom:calc(100% + 4px);right:0;z-index:30;",
|
|
883
|
-
"min-width:180px;max-width:260px;max-height:240px;overflow-y:auto;padding:4px;border:0;",
|
|
884
|
-
"border-radius:var(--dsw-radius-md);background:var(--dsw-specific-menu);",
|
|
885
|
-
"backdrop-filter:var(--dsw-menu-backdrop-filter);",
|
|
886
|
-
"box-shadow:var(--dsw-elevation-prominent)}",
|
|
887
|
-
".dsh-model-allowance-model-item{display:flex;align-items:center;justify-content:space-between;",
|
|
888
|
-
"gap:10px;width:100%;padding:4px 6px;border:0;border-radius:var(--dsw-radius-xs);",
|
|
889
|
-
"background:0 0;color:var(--dsw-alias-label-primary);font-size:12px;text-align:left;cursor:pointer}",
|
|
890
|
-
".dsh-model-allowance-model-item:hover{background:var(--dsw-alias-interactive-bg-hover)}",
|
|
891
|
-
// The model the session uses is dimmed rather than framed: a frame here
|
|
892
|
-
// would give the chip a second meaning it does not have.
|
|
893
|
-
'.dsh-model-allowance-model-item[data-current="true"]{color:var(--dsw-alias-label-secondary)}',
|
|
894
|
-
".dsh-model-allowance-model-item[disabled]{opacity:.6;cursor:default}",
|
|
895
|
-
".dsh-model-allowance-model-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
|
|
896
|
-
// The trailing side of a model row carries its state label and, for a
|
|
897
|
-
// model with reasoning efforts, the arrow that says a flyout waits to
|
|
898
|
-
// the right.
|
|
899
|
-
".dsh-model-allowance-model-side{display:inline-flex;align-items:center;gap:4px;flex:none}",
|
|
900
|
-
".dsh-model-allowance-model-arrow{color:var(--dsw-alias-label-tertiary);font-size:12px;",
|
|
901
|
-
"line-height:1}",
|
|
902
|
-
// The effort flyout opens to the right of the list, on the row the
|
|
903
|
-
// pointer rests on, as a fourth floating surface of the card.
|
|
904
|
-
".dsh-model-allowance-effort-menu{position:absolute;left:calc(100% + 4px);z-index:31;",
|
|
905
|
-
"display:flex;flex-direction:column;min-width:130px;max-width:220px;padding:4px;border:0;",
|
|
906
|
-
"border-radius:var(--dsw-radius-md);background:var(--dsw-specific-menu);",
|
|
907
|
-
"backdrop-filter:var(--dsw-menu-backdrop-filter);",
|
|
908
|
-
"box-shadow:var(--dsw-elevation-prominent)}",
|
|
909
|
-
".dsh-model-allowance-effort-item{display:flex;align-items:center;justify-content:space-between;",
|
|
910
|
-
"gap:10px;width:100%;padding:3px 6px;border:0;border-radius:var(--dsw-radius-xs);",
|
|
911
|
-
"background:0 0;color:var(--dsw-alias-label-primary);font-size:12px;text-align:left;cursor:pointer}",
|
|
912
|
-
".dsh-model-allowance-effort-item:hover{background:var(--dsw-alias-interactive-bg-hover)}",
|
|
913
|
-
// The provider's own default effort is dimmed like the model in use, so
|
|
914
|
-
// the open submenu points at it before anything is picked.
|
|
915
|
-
'.dsh-model-allowance-effort-item[data-default="true"],',
|
|
916
|
-
'.dsh-model-allowance-effort-item[data-current="true"]{color:var(--dsw-alias-label-secondary)}',
|
|
917
|
-
".dsh-model-allowance-effort-item[disabled]{opacity:.6;cursor:default}",
|
|
918
|
-
// The trailing label names the state of one model: the one in use, or the
|
|
919
|
-
// one being switched to.
|
|
920
|
-
".dsh-model-allowance-model-note{flex:none;color:var(--dsw-alias-label-tertiary);font-size:11px}",
|
|
921
|
-
// A message covers the whole list: it loads, it is empty, or the switch
|
|
922
|
-
// failed and says why.
|
|
923
|
-
".dsh-model-allowance-model-message{padding:4px 6px;color:var(--dsw-alias-label-secondary);",
|
|
924
|
-
"font-size:11px;word-break:break-word}",
|
|
925
|
-
'.dsh-model-allowance-model-message[data-tone="error"]{',
|
|
926
|
-
"color:var(--dsw-alias-state-error-primary)}",
|
|
927
|
-
".dsh-model-allowance-window{margin-top:10px;padding-top:10px;",
|
|
928
|
-
"border-top:1px solid var(--dsw-alias-border-l1)}",
|
|
929
|
-
// The first window has no boundary above it: the switcher already ends
|
|
930
|
-
// in a divider, and a bare provider row should not be underlined.
|
|
931
|
-
'.dsh-model-allowance-window[data-first="true"]{margin-top:0;padding-top:8px;',
|
|
932
|
-
"border-top:0}",
|
|
933
|
-
".dsh-model-allowance-window-head{display:flex;justify-content:space-between;",
|
|
934
|
-
"align-items:baseline;gap:12px}",
|
|
935
|
-
".dsh-model-allowance-window-title{font-weight:500;color:var(--dsw-alias-label-primary)}",
|
|
936
|
-
".dsh-model-allowance-percent{margin-top:2px;color:var(--dsw-alias-label-secondary);",
|
|
937
|
-
"font-size:11px;font-variant-numeric:tabular-nums}",
|
|
938
|
-
// The bar's track is the harness's own hover tint, not a white well: on
|
|
939
|
-
// a white card a white track was invisible, and the inset frame around
|
|
940
|
-
// it drew the eye to the groove instead of to the fill.
|
|
941
|
-
".dsh-model-allowance-bar{margin-top:6px;height:6px;border-radius:999px;overflow:hidden;",
|
|
942
|
-
"background:var(--dsw-alias-interactive-bg-hover)}",
|
|
943
|
-
".dsh-model-allowance-bar-fill{height:100%;border-radius:999px;",
|
|
944
|
-
"background:var(--dsw-alias-state-success-primary);transition:width 300ms ease}",
|
|
945
|
-
'.dsh-model-allowance-bar-fill[data-tone="warn"]{',
|
|
946
|
-
"background:var(--dsw-alias-state-warn-primary)}",
|
|
947
|
-
'.dsh-model-allowance-bar-fill[data-tone="error"]{',
|
|
948
|
-
"background:var(--dsw-alias-state-error-primary)}",
|
|
949
|
-
".dsh-model-allowance-foot{display:flex;justify-content:space-between;",
|
|
950
|
-
"align-items:baseline;gap:10px;flex-wrap:wrap;margin-top:5px;",
|
|
951
|
-
"color:var(--dsw-alias-label-secondary);",
|
|
952
|
-
"font-size:11px;font-variant-numeric:tabular-nums;word-break:break-word}",
|
|
953
|
-
".dsh-model-allowance-error{padding:4px 0;color:var(--dsw-alias-state-error-primary)}",
|
|
954
|
-
".dsh-model-allowance-reason{padding:2px 0;color:var(--dsw-alias-label-secondary);",
|
|
955
|
-
"font-size:11px;word-break:break-word}",
|
|
956
|
-
// The footer is one right-aligned cluster: the reading time sits directly
|
|
957
|
-
// left of the two icon buttons.
|
|
958
|
-
".dsh-model-allowance-actions{display:flex;align-items:center;",
|
|
959
|
-
"justify-content:flex-end;gap:8px;margin-top:8px;padding-top:8px;",
|
|
960
|
-
"border-top:1px solid var(--dsw-alias-border-l1)}",
|
|
961
|
-
".dsh-model-allowance-updated{color:var(--dsw-alias-label-secondary);font-size:11px;",
|
|
962
|
-
"font-variant-numeric:tabular-nums;white-space:nowrap;margin-right:2px}",
|
|
963
|
-
".dsh-model-allowance-icon-button{display:inline-flex;align-items:center;",
|
|
964
|
-
"justify-content:center;box-sizing:border-box;width:26px;height:26px;flex:none;padding:0;",
|
|
965
|
-
"border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm);background:0 0;",
|
|
966
|
-
"color:var(--dsw-alias-label-tertiary);cursor:pointer;text-decoration:none}",
|
|
967
|
-
".dsh-model-allowance-icon-button:hover{color:var(--dsw-alias-label-secondary);",
|
|
968
|
-
"border-color:var(--dsw-alias-border-l3);background:var(--dsw-alias-interactive-bg-hover)}",
|
|
969
|
-
// The vendor in use paints the switch glyph in that vendor's own colour,
|
|
970
|
-
// so the button says which vendor the card is on. The frame stays
|
|
971
|
-
// neutral: a coloured frame would fight the vendor marks in the strip
|
|
972
|
-
// above it.
|
|
973
|
-
'.dsh-model-allowance-icon-button[data-in-use="true"]{',
|
|
974
|
-
"color:var(--provider-mark,var(--dsw-alias-label-primary));",
|
|
975
|
-
"border-color:var(--dsw-alias-border-l3)}",
|
|
976
|
-
'.dsh-model-allowance-icon-button[data-in-use="true"]:hover{',
|
|
977
|
-
"color:var(--provider-mark,var(--dsw-alias-label-primary));",
|
|
978
|
-
"background:var(--dsw-alias-interactive-bg-hover)}",
|
|
979
|
-
".dsh-model-allowance-icon-button:focus-visible{",
|
|
980
|
-
"outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}",
|
|
981
|
-
".dsh-model-allowance-icon-button[disabled]{opacity:.5;cursor:default}",
|
|
982
|
-
".dsh-model-allowance-icon-button svg{display:block}",
|
|
983
|
-
// The platform status row: one dot whose colour is the state, the
|
|
984
|
-
// localized label, and a link to the source page when the vendor
|
|
985
|
-
// publishes one. It sits at the left edge of the footer, so the margin
|
|
986
|
-
// below pushes the reading time and the buttons to the right edge.
|
|
987
|
-
".dsh-model-allowance-status-wrap{display:inline-flex;align-items:center;gap:5px;",
|
|
988
|
-
"margin-right:auto;min-width:0;font-size:11px}",
|
|
989
|
-
".dsh-model-allowance-status{display:inline-flex;align-items:center;gap:5px;",
|
|
990
|
-
"color:var(--dsw-alias-label-primary);text-decoration:none}",
|
|
991
|
-
"a.dsh-model-allowance-status:hover{text-decoration:underline}",
|
|
992
|
-
".dsh-model-allowance-status-label{flex:none}",
|
|
993
|
-
// The degraded reason hides behind a warning mark: the footer keeps one
|
|
994
|
-
// row, and the detail is one hover away. The mark wears the same hue an
|
|
995
|
-
// exhausted allowance does, so the two warnings read alike.
|
|
996
|
-
".dsh-model-allowance-status-help{position:relative;display:inline-flex;",
|
|
997
|
-
"align-items:center;justify-content:center;box-sizing:border-box;width:14px;height:14px;",
|
|
998
|
-
"flex:none;border:1px solid var(--dsw-alias-state-error-primary);border-radius:50%;",
|
|
999
|
-
"color:var(--dsw-alias-state-error-primary);font-size:9px;font-weight:700;line-height:1;",
|
|
1000
|
-
"cursor:help}",
|
|
1001
|
-
".dsh-model-allowance-status-help:hover,",
|
|
1002
|
-
".dsh-model-allowance-status-help:focus-visible{background:var(--dsw-alias-state-error-primary);",
|
|
1003
|
-
"color:var(--dsw-alias-label-primary-foreground);outline:none}",
|
|
1004
|
-
".dsh-model-allowance-status-tip{display:none;position:absolute;left:0;",
|
|
1005
|
-
"bottom:calc(100% + 8px);z-index:40;width:max-content;max-width:240px;padding:6px 8px;",
|
|
1006
|
-
"border:0;border-radius:var(--dsw-radius-sm);",
|
|
1007
|
-
"background:var(--dsw-alias-tooltip-bg);box-shadow:var(--dsw-elevation-prominent);",
|
|
1008
|
-
"font-size:11px;font-weight:400;line-height:1.5;",
|
|
1009
|
-
// The hint sits on the harness's own tooltip surface, so it takes the
|
|
1010
|
-
// text colour that surface is read with: white on the dark tooltip.
|
|
1011
|
-
"color:var(--dsw-static-neutral-bluish-00);",
|
|
1012
|
-
"white-space:normal;text-align:left}",
|
|
1013
|
-
".dsh-model-allowance-status-help:hover .dsh-model-allowance-status-tip,",
|
|
1014
|
-
".dsh-model-allowance-status-help:focus-visible .dsh-model-allowance-status-tip{display:block}",
|
|
1015
|
-
".dsh-model-allowance-status-dot{width:6px;height:6px;border-radius:50%;flex:none;",
|
|
1016
|
-
"background:var(--dsw-alias-state-success-primary)}",
|
|
1017
|
-
'.dsh-model-allowance-status[data-state="loading"] .dsh-model-allowance-status-dot,',
|
|
1018
|
-
'.dsh-model-allowance-status[data-state="unsupported"] .dsh-model-allowance-status-dot,',
|
|
1019
|
-
'.dsh-model-allowance-status[data-state="unknown"] .dsh-model-allowance-status-dot{',
|
|
1020
|
-
"background:var(--dsw-alias-state-idle-primary)}",
|
|
1021
|
-
'.dsh-model-allowance-status[data-state="loading"] .dsh-model-allowance-status-dot{opacity:.5}',
|
|
1022
|
-
'.dsh-model-allowance-status[data-state="degraded"] .dsh-model-allowance-status-dot,',
|
|
1023
|
-
'.dsh-model-allowance-status[data-state="maintenance"] .dsh-model-allowance-status-dot{',
|
|
1024
|
-
"background:var(--dsw-alias-state-warn-primary)}",
|
|
1025
|
-
'.dsh-model-allowance-status[data-state="partial-outage"] .dsh-model-allowance-status-dot,',
|
|
1026
|
-
'.dsh-model-allowance-status[data-state="major-outage"] .dsh-model-allowance-status-dot{',
|
|
1027
|
-
"background:var(--dsw-alias-state-error-primary)}",
|
|
1028
|
-
".dsh-model-allowance-status-arrow{font-size:10px;flex:none;",
|
|
1029
|
-
"color:var(--dsw-alias-label-tertiary)}",
|
|
1030
|
-
// The time-of-day pricing block: the phase the clock is in, how far
|
|
1031
|
-
// through that stretch of time it is, and the countdown. The rule itself
|
|
1032
|
-
// hides behind the help mark, so the card stays readable.
|
|
1033
|
-
".dsh-model-allowance-schedule{margin-top:10px;padding-top:10px;",
|
|
1034
|
-
"border-top:1px solid var(--dsw-alias-border-l1)}",
|
|
1035
|
-
".dsh-model-allowance-schedule-head{display:flex;justify-content:space-between;",
|
|
1036
|
-
"align-items:center;gap:12px}",
|
|
1037
|
-
".dsh-model-allowance-schedule-title{font-weight:500;color:var(--dsw-alias-label-primary)}",
|
|
1038
|
-
".dsh-model-allowance-schedule-help{position:relative;display:inline-flex;",
|
|
1039
|
-
"align-items:center;justify-content:center;box-sizing:border-box;width:16px;height:16px;",
|
|
1040
|
-
"flex:none;border:1px solid var(--dsw-alias-border-l2);border-radius:50%;",
|
|
1041
|
-
"color:var(--dsw-alias-label-tertiary);font-size:10px;font-weight:600;line-height:1;",
|
|
1042
|
-
"cursor:help}",
|
|
1043
|
-
".dsh-model-allowance-schedule-help:hover,",
|
|
1044
|
-
".dsh-model-allowance-schedule-help:focus-visible{color:var(--dsw-alias-label-primary);",
|
|
1045
|
-
"border-color:var(--dsw-alias-label-secondary);outline:none}",
|
|
1046
|
-
// Opens upwards: the block sits just above the footer, so a tooltip
|
|
1047
|
-
// hanging below it would leave the panel.
|
|
1048
|
-
".dsh-model-allowance-schedule-tip{display:none;position:absolute;right:0;",
|
|
1049
|
-
"bottom:calc(100% + 8px);z-index:40;width:max-content;max-width:240px;padding:6px 8px;",
|
|
1050
|
-
"border:0;border-radius:var(--dsw-radius-sm);",
|
|
1051
|
-
"background:var(--dsw-alias-tooltip-bg);box-shadow:var(--dsw-elevation-prominent);",
|
|
1052
|
-
"font-size:11px;font-weight:400;line-height:1.5;",
|
|
1053
|
-
"color:var(--dsw-static-neutral-bluish-00);",
|
|
1054
|
-
"white-space:normal;text-align:left}",
|
|
1055
|
-
".dsh-model-allowance-schedule-help:hover .dsh-model-allowance-schedule-tip,",
|
|
1056
|
-
".dsh-model-allowance-schedule-help:focus-visible .dsh-model-allowance-schedule-tip{",
|
|
1057
|
-
"display:block}",
|
|
1058
|
-
".dsh-model-allowance-schedule-tip-line{display:block}",
|
|
1059
|
-
// One 24-hour strip for the vendor's day: its peak windows tinted red
|
|
1060
|
-
// and the off-peak day tinted green, both at low saturation so the
|
|
1061
|
-
// strip reads at a glance without glaring, and a cursor where the
|
|
1062
|
-
// clock stands.
|
|
1063
|
-
".dsh-model-allowance-schedule-timeline{position:relative;margin-top:8px;height:8px;",
|
|
1064
|
-
"border-radius:4px;overflow:hidden;",
|
|
1065
|
-
"background:color-mix(in srgb, var(--dsw-alias-state-success-primary) 12%,",
|
|
1066
|
-
"var(--dsw-alias-interactive-bg-hover));}",
|
|
1067
|
-
".dsh-model-allowance-schedule-timeline-peak{position:absolute;top:0;bottom:0;",
|
|
1068
|
-
// The same hue the exhausted allowance uses, so "peak" and "spent" read
|
|
1069
|
-
// as one family of warnings rather than two unrelated colours.
|
|
1070
|
-
"background:var(--dsw-alias-state-error-primary);opacity:.4}",
|
|
1071
|
-
".dsh-model-allowance-schedule-timeline-now{position:absolute;top:0;bottom:0;width:2px;",
|
|
1072
|
-
"margin-left:-1px;border-radius:1px;background:var(--dsw-alias-label-primary);",
|
|
1073
|
-
"box-shadow:0 0 0 1px var(--dsw-alias-bg-layer-1)}",
|
|
1074
|
-
".dsh-model-allowance-schedule-ticks{display:flex;justify-content:space-between;",
|
|
1075
|
-
"margin-top:2px;font-size:9px;line-height:1;color:var(--dsw-alias-label-secondary);",
|
|
1076
|
-
"font-variant-numeric:tabular-nums}",
|
|
1077
|
-
".dsh-model-allowance-schedule-countdown{margin-top:4px;text-align:right;font-size:11px;",
|
|
1078
|
-
"color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums}",
|
|
1079
|
-
// A badge that fades or grows while a user asks for less motion is noise.
|
|
1080
|
-
"@media (prefers-reduced-motion:reduce){.dsh-model-allowance-delta{animation:none}",
|
|
1081
|
-
".dsh-model-allowance-bar-fill{transition:none}}"
|
|
1082
|
-
];
|
|
1083
|
-
var STYLES_JOINED = STYLES.join("");
|
|
1084
|
-
|
|
1085
771
|
// src/client/windows.js
|
|
1086
772
|
function windowTitle(window, t) {
|
|
1087
773
|
const label = window.label?.[activeLanguage()] ?? window.label?.en ?? window.label?.zh;
|
|
@@ -1139,73 +825,256 @@ function barTone(percent) {
|
|
|
1139
825
|
return "ok";
|
|
1140
826
|
}
|
|
1141
827
|
|
|
1142
|
-
// src/client/
|
|
1143
|
-
var
|
|
1144
|
-
|
|
1145
|
-
|
|
828
|
+
// src/client/components/effort-flyout.js
|
|
829
|
+
var import_react3 = require("react");
|
|
830
|
+
|
|
831
|
+
// src/client/models.js
|
|
832
|
+
function providerGroup(catalog, provider) {
|
|
833
|
+
const groups = Array.isArray(catalog?.groups) ? catalog.groups : [];
|
|
834
|
+
return groups.find((group) => group?.id === provider);
|
|
1146
835
|
}
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
return
|
|
1159
|
-
} catch (error) {
|
|
1160
|
-
console.error("[model-allowance] reading provider status failed", { provider, error });
|
|
1161
|
-
return { provider, state: "unknown", error: describe(error) };
|
|
836
|
+
function modelsForProvider(catalog, provider) {
|
|
837
|
+
const group = providerGroup(catalog, provider);
|
|
838
|
+
const models = Array.isArray(group?.models) ? group.models : [];
|
|
839
|
+
return models.filter((model) => typeof model?.id === "string" && model.id !== "");
|
|
840
|
+
}
|
|
841
|
+
function providerModelGroup(catalog, routes) {
|
|
842
|
+
const seen = /* @__PURE__ */ new Set();
|
|
843
|
+
for (const route of routes) {
|
|
844
|
+
if (typeof route !== "string" || route === "" || seen.has(route)) continue;
|
|
845
|
+
seen.add(route);
|
|
846
|
+
const models = modelsForProvider(catalog, route);
|
|
847
|
+
if (models.length > 0) return { provider: route, models };
|
|
1162
848
|
}
|
|
849
|
+
return void 0;
|
|
1163
850
|
}
|
|
1164
|
-
function
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
return
|
|
851
|
+
function effortChoices(model) {
|
|
852
|
+
const reasoning = model?.reasoning;
|
|
853
|
+
const efforts = Array.isArray(reasoning?.efforts) ? reasoning.efforts : [];
|
|
854
|
+
if (efforts.length === 0) return null;
|
|
855
|
+
const entries = efforts.filter((effort) => typeof effort?.id === "string" && effort.id !== "").map((effort) => ({
|
|
856
|
+
id: effort.id,
|
|
857
|
+
name: typeof effort.name === "string" && effort.name !== "" ? effort.name : effort.id,
|
|
858
|
+
isDefault: effort.id === reasoning.defaultEffort
|
|
859
|
+
}));
|
|
860
|
+
if (reasoning.defaultEffort === void 0) {
|
|
861
|
+
entries.unshift({ id: void 0, providerDefault: true });
|
|
862
|
+
}
|
|
863
|
+
return entries;
|
|
1168
864
|
}
|
|
1169
|
-
function
|
|
1170
|
-
const
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
865
|
+
function currentModelFor(selection, provider) {
|
|
866
|
+
const next = selection?.next ?? selection?.lastUsed;
|
|
867
|
+
if (next?.provider !== provider) return void 0;
|
|
868
|
+
return typeof next.model === "string" ? next.model : void 0;
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
// src/client/components/effort-flyout.js
|
|
872
|
+
function EffortFlyout({
|
|
873
|
+
t,
|
|
874
|
+
hoverModel,
|
|
875
|
+
currentModel,
|
|
876
|
+
selectedEffort,
|
|
877
|
+
switchingModel,
|
|
878
|
+
switchToModel,
|
|
879
|
+
keepEffortFlyout,
|
|
880
|
+
scheduleEffortFlyoutClose
|
|
881
|
+
}) {
|
|
882
|
+
return (0, import_react3.createElement)(
|
|
883
|
+
"div",
|
|
884
|
+
{
|
|
885
|
+
className: "dsh-model-allowance-effort-menu",
|
|
886
|
+
role: "menu",
|
|
887
|
+
"aria-label": t("model.title"),
|
|
888
|
+
style: { top: `${hoverModel.top}px` },
|
|
889
|
+
onMouseEnter: keepEffortFlyout,
|
|
890
|
+
onMouseLeave: () => {
|
|
891
|
+
scheduleEffortFlyoutClose(hoverModel.model.id);
|
|
892
|
+
}
|
|
893
|
+
},
|
|
894
|
+
...effortChoices(hoverModel.model).map((effort) => {
|
|
895
|
+
const isCurrentEffort = hoverModel.model.id === currentModel && effort.id === selectedEffort;
|
|
896
|
+
return (0, import_react3.createElement)(
|
|
897
|
+
"button",
|
|
898
|
+
{
|
|
899
|
+
type: "button",
|
|
900
|
+
key: effort.id ?? "provider-default",
|
|
901
|
+
role: "menuitemradio",
|
|
902
|
+
"aria-checked": isCurrentEffort ? "true" : "false",
|
|
903
|
+
"data-current": isCurrentEffort ? "true" : "false",
|
|
904
|
+
"data-default": effort.isDefault ? "true" : "false",
|
|
905
|
+
className: "dsh-model-allowance-effort-item",
|
|
906
|
+
disabled: switchingModel !== null,
|
|
907
|
+
onClick: () => {
|
|
908
|
+
void switchToModel(hoverModel.model, effort.id);
|
|
909
|
+
}
|
|
910
|
+
},
|
|
911
|
+
(0, import_react3.createElement)(
|
|
912
|
+
"span",
|
|
913
|
+
{ className: "dsh-model-allowance-model-name" },
|
|
914
|
+
effort.providerDefault ? t("model.effortDefault") : effort.name
|
|
915
|
+
),
|
|
916
|
+
effort.isDefault && !isCurrentEffort ? (0, import_react3.createElement)("span", { className: "dsh-model-allowance-model-note" }, t("model.effortDefault")) : null
|
|
917
|
+
);
|
|
918
|
+
})
|
|
919
|
+
);
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
// src/client/components/model-menu.js
|
|
923
|
+
var import_react4 = require("react");
|
|
924
|
+
function ModelMenu({
|
|
925
|
+
t,
|
|
926
|
+
models,
|
|
927
|
+
state,
|
|
928
|
+
modelError,
|
|
929
|
+
currentModel,
|
|
930
|
+
switchingModel,
|
|
931
|
+
switchToModel,
|
|
932
|
+
modelWrapRef,
|
|
933
|
+
showEffortFlyout,
|
|
934
|
+
scheduleEffortFlyoutClose
|
|
935
|
+
}) {
|
|
936
|
+
return (0, import_react4.createElement)(
|
|
937
|
+
"div",
|
|
938
|
+
{
|
|
939
|
+
className: "dsh-model-allowance-model-menu",
|
|
940
|
+
role: "menu",
|
|
941
|
+
"aria-label": t("model.title")
|
|
942
|
+
},
|
|
943
|
+
state === "loading" ? (0, import_react4.createElement)("div", { className: "dsh-model-allowance-model-message" }, t("model.loading")) : null,
|
|
944
|
+
state === "empty" ? (0, import_react4.createElement)("div", { className: "dsh-model-allowance-model-message" }, t("model.empty")) : null,
|
|
945
|
+
state === "error" ? (0, import_react4.createElement)(
|
|
946
|
+
"div",
|
|
947
|
+
{
|
|
948
|
+
className: "dsh-model-allowance-model-message",
|
|
949
|
+
"data-tone": "error"
|
|
950
|
+
},
|
|
951
|
+
modelError ?? t("model.unavailable")
|
|
952
|
+
) : null,
|
|
953
|
+
...models.map((model) => {
|
|
954
|
+
const isCurrent = model.id === currentModel;
|
|
955
|
+
const efforts = effortChoices(model);
|
|
956
|
+
const defaultEffortId = efforts?.find((effort) => effort.isDefault)?.id;
|
|
957
|
+
return (0, import_react4.createElement)(
|
|
958
|
+
"button",
|
|
959
|
+
{
|
|
960
|
+
type: "button",
|
|
961
|
+
key: model.id,
|
|
962
|
+
role: "menuitemradio",
|
|
963
|
+
"aria-checked": isCurrent ? "true" : "false",
|
|
964
|
+
"data-current": isCurrent ? "true" : "false",
|
|
965
|
+
className: "dsh-model-allowance-model-item",
|
|
966
|
+
disabled: switchingModel !== null,
|
|
967
|
+
title: model.id,
|
|
968
|
+
...efforts === null ? {} : { "aria-haspopup": "menu" },
|
|
969
|
+
onClick: () => {
|
|
970
|
+
void switchToModel(model, defaultEffortId);
|
|
971
|
+
},
|
|
972
|
+
...efforts === null ? {} : {
|
|
973
|
+
onMouseEnter: (event) => {
|
|
974
|
+
const wrap = modelWrapRef.current;
|
|
975
|
+
if (!wrap) return;
|
|
976
|
+
const top = event.currentTarget.getBoundingClientRect().top - wrap.getBoundingClientRect().top;
|
|
977
|
+
showEffortFlyout(model, top);
|
|
978
|
+
},
|
|
979
|
+
onMouseLeave: () => {
|
|
980
|
+
scheduleEffortFlyoutClose(model.id);
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
},
|
|
984
|
+
(0, import_react4.createElement)("span", { className: "dsh-model-allowance-model-name" }, model.name ?? model.id),
|
|
985
|
+
(0, import_react4.createElement)(
|
|
986
|
+
"span",
|
|
987
|
+
{ className: "dsh-model-allowance-model-side" },
|
|
988
|
+
switchingModel === model.id ? (0, import_react4.createElement)("span", { className: "dsh-model-allowance-model-note" }, t("model.switching")) : isCurrent ? (0, import_react4.createElement)("span", { className: "dsh-model-allowance-model-note" }, t("model.current")) : null,
|
|
989
|
+
efforts === null ? null : (0, import_react4.createElement)(
|
|
990
|
+
"span",
|
|
991
|
+
{
|
|
992
|
+
className: "dsh-model-allowance-model-arrow",
|
|
993
|
+
"aria-hidden": true
|
|
994
|
+
},
|
|
995
|
+
"\u203A"
|
|
996
|
+
)
|
|
997
|
+
)
|
|
998
|
+
);
|
|
999
|
+
}),
|
|
1000
|
+
// A failed switch keeps the list open and says why.
|
|
1001
|
+
modelError && state !== "error" ? (0, import_react4.createElement)(
|
|
1002
|
+
"div",
|
|
1003
|
+
{
|
|
1004
|
+
className: "dsh-model-allowance-model-message",
|
|
1005
|
+
"data-tone": "error"
|
|
1006
|
+
},
|
|
1007
|
+
modelError
|
|
1008
|
+
) : null
|
|
1009
|
+
);
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
// src/client/components/provider-strip.js
|
|
1013
|
+
var React2 = __toESM(require("react"), 1);
|
|
1014
|
+
var import_react5 = require("react");
|
|
1015
|
+
|
|
1016
|
+
// src/client/hooks/use-provider-directory.js
|
|
1017
|
+
var React = __toESM(require("react"), 1);
|
|
1018
|
+
|
|
1019
|
+
// src/client/namespace.js
|
|
1020
|
+
var balanceNamespace = null;
|
|
1021
|
+
var settleBalanceNamespace;
|
|
1022
|
+
var balanceNamespaceReady = new Promise((resolve) => {
|
|
1023
|
+
settleBalanceNamespace = resolve;
|
|
1024
|
+
});
|
|
1025
|
+
async function getBalanceApi() {
|
|
1026
|
+
if (balanceNamespace) return balanceNamespace;
|
|
1027
|
+
return await balanceNamespaceReady;
|
|
1028
|
+
}
|
|
1029
|
+
function lookupBalanceNamespace(ctx) {
|
|
1030
|
+
try {
|
|
1031
|
+
return ctx.get("remote.balance");
|
|
1032
|
+
} catch {
|
|
1033
|
+
return void 0;
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
function setBalanceNamespace(value) {
|
|
1037
|
+
balanceNamespace = value;
|
|
1038
|
+
settleBalanceNamespace(value);
|
|
1039
|
+
return value;
|
|
1040
|
+
}
|
|
1041
|
+
var modelSupport;
|
|
1042
|
+
function resetBalanceNamespace() {
|
|
1043
|
+
balanceNamespace = null;
|
|
1044
|
+
modelSupport = void 0;
|
|
1045
|
+
}
|
|
1046
|
+
function lookupSessionFace(ctx) {
|
|
1047
|
+
try {
|
|
1048
|
+
const face = ctx.get("remote.session");
|
|
1049
|
+
if (face !== void 0) return face;
|
|
1050
|
+
} catch {
|
|
1051
|
+
}
|
|
1052
|
+
return ctx.remote?.session;
|
|
1053
|
+
}
|
|
1054
|
+
async function supportsModel(api) {
|
|
1055
|
+
if (modelSupport !== void 0) return modelSupport;
|
|
1056
|
+
if (typeof api?.capabilities !== "function") {
|
|
1057
|
+
modelSupport = false;
|
|
1058
|
+
return modelSupport;
|
|
1059
|
+
}
|
|
1060
|
+
try {
|
|
1061
|
+
const result = await api.capabilities();
|
|
1062
|
+
modelSupport = result?.ok === true && result.value?.modelScoped === true;
|
|
1063
|
+
} catch {
|
|
1064
|
+
modelSupport = false;
|
|
1065
|
+
}
|
|
1066
|
+
return modelSupport;
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
// src/client/hooks/use-provider-directory.js
|
|
1070
|
+
function entryCovers(entry, route) {
|
|
1071
|
+
if (entry === void 0 || entry === null) return false;
|
|
1072
|
+
if (entry.route === route) return true;
|
|
1073
|
+
return Array.isArray(entry.aliases) && entry.aliases.includes(route);
|
|
1074
|
+
}
|
|
1075
|
+
function useProviderDirectory(selected) {
|
|
1076
|
+
const [directory, setDirectory] = React.useState([]);
|
|
1195
1077
|
const [defaultProvider, setDefaultProvider] = React.useState(null);
|
|
1196
|
-
const [providerStatus, setProviderStatus] = React.useState(null);
|
|
1197
|
-
const [schedule, setSchedule] = React.useState(null);
|
|
1198
|
-
const [modelList, setModelList] = React.useState([]);
|
|
1199
|
-
const [modelListRoute, setModelListRoute] = React.useState(null);
|
|
1200
|
-
const [catalogProvider, setCatalogProvider] = React.useState(null);
|
|
1201
|
-
const [modelListState, setModelListState] = React.useState("idle");
|
|
1202
|
-
const [modelError, setModelError] = React.useState(null);
|
|
1203
|
-
const [modelMenuOpen, setModelMenuOpen] = React.useState(false);
|
|
1204
|
-
const [hoverModel, setHoverModel] = React.useState(null);
|
|
1205
|
-
const hoverModelTimer = React.useRef(null);
|
|
1206
|
-
const [switchingModel, setSwitchingModel] = React.useState(null);
|
|
1207
|
-
const modelWrapRef = React.useRef(null);
|
|
1208
|
-
const catalogRef = React.useRef({ value: null, at: 0 });
|
|
1209
1078
|
React.useEffect(() => {
|
|
1210
1079
|
let cancelled = false;
|
|
1211
1080
|
(async () => {
|
|
@@ -1232,8 +1101,8 @@ function BalanceBadge(props) {
|
|
|
1232
1101
|
if (!api || typeof api.defaultProvider !== "function") return;
|
|
1233
1102
|
const result = await api.defaultProvider();
|
|
1234
1103
|
if (cancelled || result?.ok !== true) return;
|
|
1235
|
-
const
|
|
1236
|
-
if (typeof
|
|
1104
|
+
const provider = result.value?.provider;
|
|
1105
|
+
if (typeof provider === "string" && provider !== "") setDefaultProvider(provider);
|
|
1237
1106
|
} catch (error) {
|
|
1238
1107
|
console.error("[model-allowance] reading the default provider failed", { error });
|
|
1239
1108
|
}
|
|
@@ -1242,34 +1111,50 @@ function BalanceBadge(props) {
|
|
|
1242
1111
|
cancelled = true;
|
|
1243
1112
|
};
|
|
1244
1113
|
}, [selected]);
|
|
1245
|
-
const
|
|
1246
|
-
const
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
}
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
const
|
|
1259
|
-
const
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1114
|
+
const available = directory.filter((entry) => entry.configured);
|
|
1115
|
+
const entryOf = React.useCallback(
|
|
1116
|
+
(route) => directory.find((entry) => entryCovers(entry, route)),
|
|
1117
|
+
[directory]
|
|
1118
|
+
);
|
|
1119
|
+
const nameOf = React.useCallback((route) => pickName(entryOf(route), route), [entryOf]);
|
|
1120
|
+
return { available, defaultProvider, entryOf, nameOf };
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
// src/client/components/provider-strip.js
|
|
1124
|
+
function splitStrip(entries, stripWidth, activeProvider) {
|
|
1125
|
+
const MARK_SIZE = 26;
|
|
1126
|
+
const MARK_GAP = 4;
|
|
1127
|
+
const MENU_SIZE = 26;
|
|
1128
|
+
const perMark = MARK_SIZE + MARK_GAP;
|
|
1129
|
+
let visibleCount = entries.length;
|
|
1130
|
+
if (stripWidth > 0 && entries.length * perMark - MARK_GAP > stripWidth) {
|
|
1131
|
+
visibleCount = Math.max(1, Math.floor((stripWidth - MENU_SIZE - MARK_GAP) / perMark));
|
|
1132
|
+
visibleCount = Math.min(visibleCount, entries.length - 1);
|
|
1133
|
+
}
|
|
1134
|
+
let shown = entries.slice(0, visibleCount);
|
|
1135
|
+
let overflow = entries.slice(visibleCount);
|
|
1136
|
+
const activeIndex = overflow.findIndex((entry) => entryCovers(entry, activeProvider));
|
|
1137
|
+
if (activeIndex >= 0 && shown.length > 0) {
|
|
1138
|
+
const displaced = shown[shown.length - 1];
|
|
1139
|
+
shown = [...shown.slice(0, -1), overflow[activeIndex]];
|
|
1140
|
+
overflow = [...overflow.slice(0, activeIndex), displaced, ...overflow.slice(activeIndex + 1)];
|
|
1141
|
+
}
|
|
1142
|
+
return { shown, overflow };
|
|
1143
|
+
}
|
|
1144
|
+
function ProviderStrip({
|
|
1145
|
+
t,
|
|
1146
|
+
available,
|
|
1147
|
+
activeProvider,
|
|
1148
|
+
markFor,
|
|
1149
|
+
nameOf,
|
|
1150
|
+
onPick,
|
|
1151
|
+
menuOpen,
|
|
1152
|
+
setMenuOpen,
|
|
1153
|
+
stripWidth,
|
|
1154
|
+
setStripWidth,
|
|
1155
|
+
stripRef
|
|
1156
|
+
}) {
|
|
1157
|
+
React2.useEffect(() => {
|
|
1273
1158
|
const node = stripRef.current;
|
|
1274
1159
|
if (!node) return;
|
|
1275
1160
|
const measure = () => setStripWidth(node.clientWidth ?? 0);
|
|
@@ -1278,100 +1163,474 @@ function BalanceBadge(props) {
|
|
|
1278
1163
|
const observer = new ResizeObserver(measure);
|
|
1279
1164
|
observer.observe(node);
|
|
1280
1165
|
return () => observer.disconnect();
|
|
1281
|
-
}, [
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
const
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
};
|
|
1303
|
-
}, [open, modelMenuOpen]);
|
|
1304
|
-
const showingDifference = consumptionFreshAt(view?.consumption, now);
|
|
1305
|
-
React.useEffect(() => {
|
|
1306
|
-
if (!open && !showingDifference) return;
|
|
1307
|
-
setNow(Date.now());
|
|
1308
|
-
const timer = setInterval(() => setNow(Date.now()), 1e3);
|
|
1309
|
-
return () => clearInterval(timer);
|
|
1310
|
-
}, [open, showingDifference]);
|
|
1311
|
-
React.useEffect(() => {
|
|
1312
|
-
if (!open) return;
|
|
1313
|
-
let cancelled = false;
|
|
1314
|
-
(async () => {
|
|
1315
|
-
try {
|
|
1316
|
-
const api = await getBalanceApi();
|
|
1317
|
-
if (!api || typeof api.list !== "function") return;
|
|
1318
|
-
const result = await api.list();
|
|
1319
|
-
if (cancelled || !result.ok) return;
|
|
1320
|
-
setDirectory(result.value);
|
|
1321
|
-
} catch (error) {
|
|
1322
|
-
console.error("[model-allowance] listing providers failed", { error });
|
|
1323
|
-
}
|
|
1324
|
-
})();
|
|
1325
|
-
return () => {
|
|
1326
|
-
cancelled = true;
|
|
1327
|
-
};
|
|
1328
|
-
}, [open]);
|
|
1329
|
-
React.useEffect(() => {
|
|
1330
|
-
if (!activeProvider) {
|
|
1331
|
-
setView(null);
|
|
1332
|
-
setLoading(false);
|
|
1333
|
-
return;
|
|
1334
|
-
}
|
|
1335
|
-
let cancelled = false;
|
|
1336
|
-
let handle;
|
|
1337
|
-
setLoading(true);
|
|
1338
|
-
const readOnce = async (api, model) => {
|
|
1339
|
-
try {
|
|
1340
|
-
let result = await api.balance(activeProvider, model);
|
|
1341
|
-
if (!result.ok && model !== void 0) {
|
|
1342
|
-
result = await api.balance(activeProvider, void 0);
|
|
1343
|
-
}
|
|
1344
|
-
if (cancelled) return;
|
|
1345
|
-
if (!result.ok) {
|
|
1346
|
-
const detail = typeof result.error?.message === "string" ? result.error.message : typeof result.error === "string" ? result.error : "balance reading failed";
|
|
1347
|
-
throw new Error(detail);
|
|
1348
|
-
}
|
|
1349
|
-
setView(result.value);
|
|
1350
|
-
} catch (error) {
|
|
1351
|
-
console.error("[model-allowance] reading failed", {
|
|
1352
|
-
provider: activeProvider,
|
|
1353
|
-
model,
|
|
1354
|
-
error
|
|
1355
|
-
});
|
|
1356
|
-
if (!cancelled) {
|
|
1357
|
-
setView({
|
|
1358
|
-
provider: activeProvider,
|
|
1359
|
-
status: "failed",
|
|
1360
|
-
kind: "quota",
|
|
1361
|
-
error: error instanceof Error ? error.message : String(error)
|
|
1362
|
-
});
|
|
1166
|
+
}, [setStripWidth]);
|
|
1167
|
+
const { shown, overflow } = splitStrip(available, stripWidth, activeProvider);
|
|
1168
|
+
const markButton = (entry) => {
|
|
1169
|
+
const mark = markFor(entry.route);
|
|
1170
|
+
const name = nameOf(entry.route);
|
|
1171
|
+
const active = entryCovers(entry, activeProvider);
|
|
1172
|
+
return (0, import_react5.createElement)(
|
|
1173
|
+
"button",
|
|
1174
|
+
{
|
|
1175
|
+
type: "button",
|
|
1176
|
+
key: entry.route,
|
|
1177
|
+
role: "tab",
|
|
1178
|
+
className: "dsh-model-allowance-tab",
|
|
1179
|
+
"data-active": active ? "true" : "false",
|
|
1180
|
+
"aria-selected": active ? "true" : "false",
|
|
1181
|
+
"aria-label": name,
|
|
1182
|
+
title: name,
|
|
1183
|
+
style: { "--provider-mark": mark.color },
|
|
1184
|
+
onClick: () => {
|
|
1185
|
+
onPick(entry.route);
|
|
1186
|
+
setMenuOpen(false);
|
|
1363
1187
|
}
|
|
1364
|
-
}
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1188
|
+
},
|
|
1189
|
+
providerIcon(entry.route, 14, mark)
|
|
1190
|
+
);
|
|
1191
|
+
};
|
|
1192
|
+
const onTabKeyDown = (event) => {
|
|
1193
|
+
if (!["ArrowLeft", "ArrowRight", "Home", "End"].includes(event.key)) return;
|
|
1194
|
+
const tabs = [...event.currentTarget.querySelectorAll('[role="tab"]')];
|
|
1195
|
+
if (tabs.length === 0) return;
|
|
1196
|
+
const index = tabs.indexOf(document.activeElement);
|
|
1197
|
+
const next = event.key === "Home" ? 0 : event.key === "End" ? tabs.length - 1 : (index + (event.key === "ArrowRight" ? 1 : -1) + tabs.length) % tabs.length;
|
|
1198
|
+
event.preventDefault();
|
|
1199
|
+
tabs[next]?.focus();
|
|
1200
|
+
};
|
|
1201
|
+
return (0, import_react5.createElement)(
|
|
1202
|
+
"div",
|
|
1203
|
+
{ className: "dsh-model-allowance-switcher-wrap" },
|
|
1204
|
+
(0, import_react5.createElement)(
|
|
1205
|
+
"div",
|
|
1206
|
+
{
|
|
1207
|
+
ref: stripRef,
|
|
1208
|
+
className: "dsh-model-allowance-switcher",
|
|
1209
|
+
role: "tablist",
|
|
1210
|
+
"aria-label": t("detail.provider"),
|
|
1211
|
+
onKeyDown: onTabKeyDown
|
|
1212
|
+
},
|
|
1213
|
+
...shown.map(markButton),
|
|
1214
|
+
overflow.length > 0 ? (0, import_react5.createElement)(
|
|
1215
|
+
"button",
|
|
1216
|
+
{
|
|
1217
|
+
type: "button",
|
|
1218
|
+
className: "dsh-model-allowance-more",
|
|
1219
|
+
"aria-haspopup": "menu",
|
|
1220
|
+
"aria-expanded": menuOpen ? "true" : "false",
|
|
1221
|
+
"aria-label": t("detail.moreProviders"),
|
|
1222
|
+
title: t("detail.moreProviders"),
|
|
1223
|
+
onClick: () => setMenuOpen((value) => !value)
|
|
1224
|
+
},
|
|
1225
|
+
"\u22EF"
|
|
1226
|
+
) : null
|
|
1227
|
+
),
|
|
1228
|
+
menuOpen && overflow.length > 0 ? (0, import_react5.createElement)(
|
|
1229
|
+
"div",
|
|
1230
|
+
{ className: "dsh-model-allowance-menu", role: "menu" },
|
|
1231
|
+
...overflow.map(
|
|
1232
|
+
(entry) => (0, import_react5.createElement)(
|
|
1233
|
+
"button",
|
|
1234
|
+
{
|
|
1235
|
+
type: "button",
|
|
1236
|
+
key: entry.route,
|
|
1237
|
+
role: "menuitem",
|
|
1238
|
+
className: "dsh-model-allowance-menu-item",
|
|
1239
|
+
onClick: () => {
|
|
1240
|
+
onPick(entry.route);
|
|
1241
|
+
setMenuOpen(false);
|
|
1242
|
+
}
|
|
1243
|
+
},
|
|
1244
|
+
(0, import_react5.createElement)(
|
|
1245
|
+
"span",
|
|
1246
|
+
{
|
|
1247
|
+
className: "dsh-model-allowance-menu-mark",
|
|
1248
|
+
style: { "--provider-mark": markFor(entry.route).color }
|
|
1249
|
+
},
|
|
1250
|
+
providerIcon(entry.route, 11, markFor(entry.route))
|
|
1251
|
+
),
|
|
1252
|
+
(0, import_react5.createElement)("span", null, nameOf(entry.route))
|
|
1253
|
+
)
|
|
1254
|
+
)
|
|
1255
|
+
) : null
|
|
1256
|
+
);
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
// src/client/components/balance-panel.js
|
|
1260
|
+
function BalancePanel({
|
|
1261
|
+
t,
|
|
1262
|
+
now,
|
|
1263
|
+
view,
|
|
1264
|
+
activeProvider,
|
|
1265
|
+
available,
|
|
1266
|
+
schedule,
|
|
1267
|
+
currentStatus,
|
|
1268
|
+
serviceState,
|
|
1269
|
+
refresh,
|
|
1270
|
+
refreshing,
|
|
1271
|
+
canSwitch,
|
|
1272
|
+
inUse,
|
|
1273
|
+
switchLabel,
|
|
1274
|
+
selectedEffort,
|
|
1275
|
+
setPicked,
|
|
1276
|
+
nameOf,
|
|
1277
|
+
markFor,
|
|
1278
|
+
catalog,
|
|
1279
|
+
menuOpen,
|
|
1280
|
+
setMenuOpen,
|
|
1281
|
+
stripWidth,
|
|
1282
|
+
setStripWidth,
|
|
1283
|
+
stripRef
|
|
1284
|
+
}) {
|
|
1285
|
+
return (0, import_react6.createElement)(
|
|
1286
|
+
"div",
|
|
1287
|
+
{
|
|
1288
|
+
className: "dsh-model-allowance-panel",
|
|
1289
|
+
id: "dsh-model-allowance-panel",
|
|
1290
|
+
role: "dialog",
|
|
1291
|
+
"aria-label": t("detail.title")
|
|
1292
|
+
},
|
|
1293
|
+
// With more than one readable provider the card opens a switcher;
|
|
1294
|
+
// with one there is nothing to switch, so it just names it.
|
|
1295
|
+
available.length > 1 ? (0, import_react6.createElement)(ProviderStrip, {
|
|
1296
|
+
t,
|
|
1297
|
+
available,
|
|
1298
|
+
activeProvider,
|
|
1299
|
+
markFor,
|
|
1300
|
+
nameOf,
|
|
1301
|
+
onPick: setPicked,
|
|
1302
|
+
menuOpen,
|
|
1303
|
+
setMenuOpen,
|
|
1304
|
+
stripWidth,
|
|
1305
|
+
setStripWidth,
|
|
1306
|
+
stripRef
|
|
1307
|
+
}) : (0, import_react6.createElement)(
|
|
1308
|
+
"div",
|
|
1309
|
+
{ className: "dsh-model-allowance-row" },
|
|
1310
|
+
(0, import_react6.createElement)("span", null, t("detail.provider")),
|
|
1311
|
+
(0, import_react6.createElement)("span", null, nameOf(activeProvider))
|
|
1312
|
+
),
|
|
1313
|
+
view?.kind === "amount" && typeof view.amount === "number" ? (0, import_react6.createElement)(
|
|
1314
|
+
"div",
|
|
1315
|
+
{ className: "dsh-model-allowance-row" },
|
|
1316
|
+
(0, import_react6.createElement)("span", null, t("detail.amount")),
|
|
1317
|
+
(0, import_react6.createElement)("span", null, formatAmount(view.amount, view.currency))
|
|
1318
|
+
) : null,
|
|
1319
|
+
...Array.isArray(view?.windows) && view.windows.length > 0 ? view.windows.map((window, index) => {
|
|
1320
|
+
const consumed = windowUsedPercent(window);
|
|
1321
|
+
const percent = consumed === void 0 ? void 0 : Math.max(0, Math.round(consumed));
|
|
1322
|
+
const filled = consumed === void 0 ? 0 : Math.min(100, Math.max(0, consumed));
|
|
1323
|
+
const usage = windowUsage(window, t);
|
|
1324
|
+
return (0, import_react6.createElement)(
|
|
1325
|
+
"div",
|
|
1326
|
+
{
|
|
1327
|
+
className: "dsh-model-allowance-window",
|
|
1328
|
+
key: `w-${String(index)}`,
|
|
1329
|
+
// The first block needs no divider: the switcher above
|
|
1330
|
+
// it already ends in one, and a bare provider row does
|
|
1331
|
+
// not deserve a line either. Only the boundaries
|
|
1332
|
+
// *between* windows are drawn.
|
|
1333
|
+
"data-first": index === 0 ? "true" : void 0
|
|
1334
|
+
},
|
|
1335
|
+
(0, import_react6.createElement)(
|
|
1336
|
+
"div",
|
|
1337
|
+
{ className: "dsh-model-allowance-window-head" },
|
|
1338
|
+
(0, import_react6.createElement)("span", { className: "dsh-model-allowance-window-title" }, windowTitle(window, t)),
|
|
1339
|
+
// Countable units sit beside the title; a plan that
|
|
1340
|
+
// reports only a percentage has none to show.
|
|
1341
|
+
usage === void 0 ? null : (0, import_react6.createElement)("span", { className: "dsh-model-allowance-usage" }, usage)
|
|
1342
|
+
),
|
|
1343
|
+
percent === void 0 ? null : (0, import_react6.createElement)(
|
|
1344
|
+
"div",
|
|
1345
|
+
{ className: "dsh-model-allowance-percent" },
|
|
1346
|
+
t("window.usedPercent", { percent })
|
|
1347
|
+
),
|
|
1348
|
+
percent === void 0 ? null : (0, import_react6.createElement)(
|
|
1349
|
+
"div",
|
|
1350
|
+
{
|
|
1351
|
+
className: "dsh-model-allowance-bar",
|
|
1352
|
+
role: "progressbar",
|
|
1353
|
+
"aria-valuenow": percent,
|
|
1354
|
+
"aria-valuemin": 0,
|
|
1355
|
+
"aria-valuemax": 100,
|
|
1356
|
+
"aria-valuetext": t("window.usedPercent", { percent })
|
|
1357
|
+
},
|
|
1358
|
+
(0, import_react6.createElement)("div", {
|
|
1359
|
+
className: "dsh-model-allowance-bar-fill",
|
|
1360
|
+
"data-tone": barTone(percent),
|
|
1361
|
+
style: { width: `${String(filled)}%` }
|
|
1362
|
+
})
|
|
1363
|
+
),
|
|
1364
|
+
// A window with zero usage has not started its rolling timer
|
|
1365
|
+
// yet, so the countdown would be misleading. Hide it until
|
|
1366
|
+
// consumption begins.
|
|
1367
|
+
typeof window.resetAt === "number" && (typeof window.remainingPercent !== "number" || window.remainingPercent < 100) ? (0, import_react6.createElement)(
|
|
1368
|
+
"div",
|
|
1369
|
+
{ className: "dsh-model-allowance-foot" },
|
|
1370
|
+
(0, import_react6.createElement)(
|
|
1371
|
+
"span",
|
|
1372
|
+
null,
|
|
1373
|
+
t("window.resetIn", {
|
|
1374
|
+
duration: formatCountdown(window.resetAt - now)
|
|
1375
|
+
})
|
|
1376
|
+
),
|
|
1377
|
+
(0, import_react6.createElement)("span", null, formatResetAt(window.resetAt))
|
|
1378
|
+
) : null
|
|
1379
|
+
);
|
|
1380
|
+
}) : [],
|
|
1381
|
+
// A single scalar reading has no windows to break down.
|
|
1382
|
+
!Array.isArray(view?.windows) && typeof view?.remainingMs === "number" ? (0, import_react6.createElement)(
|
|
1383
|
+
"div",
|
|
1384
|
+
{ className: "dsh-model-allowance-row" },
|
|
1385
|
+
(0, import_react6.createElement)("span", null, t("detail.remaining")),
|
|
1386
|
+
(0, import_react6.createElement)("span", null, formatDuration(view.remainingMs, t))
|
|
1387
|
+
) : null,
|
|
1388
|
+
!Array.isArray(view?.windows) && typeof view?.remaining === "number" ? (0, import_react6.createElement)(
|
|
1389
|
+
"div",
|
|
1390
|
+
{ className: "dsh-model-allowance-row" },
|
|
1391
|
+
(0, import_react6.createElement)("span", null, t("detail.remaining")),
|
|
1392
|
+
(0, import_react6.createElement)("span", null, String(view.remaining))
|
|
1393
|
+
) : null,
|
|
1394
|
+
!Array.isArray(view?.windows) && typeof view?.total === "number" ? (0, import_react6.createElement)(
|
|
1395
|
+
"div",
|
|
1396
|
+
{ className: "dsh-model-allowance-row" },
|
|
1397
|
+
(0, import_react6.createElement)("span", null, t("detail.total")),
|
|
1398
|
+
(0, import_react6.createElement)("span", null, String(view.total))
|
|
1399
|
+
) : null,
|
|
1400
|
+
view?.status === "failed" ? (0, import_react6.createElement)(
|
|
1401
|
+
"div",
|
|
1402
|
+
{ className: "dsh-model-allowance-error" },
|
|
1403
|
+
t("detail.error"),
|
|
1404
|
+
// The Host reports why a reading failed; showing it is what
|
|
1405
|
+
// turns "it does not work" into something actionable.
|
|
1406
|
+
view.error ? (0, import_react6.createElement)("div", { className: "dsh-model-allowance-reason" }, view.error) : null
|
|
1407
|
+
) : null,
|
|
1408
|
+
view?.status === "unsupported" ? (0, import_react6.createElement)(
|
|
1409
|
+
"div",
|
|
1410
|
+
{ className: "dsh-model-allowance-reason" },
|
|
1411
|
+
t("badge.unsupportedWithName", { name: nameOf(activeProvider) })
|
|
1412
|
+
) : null,
|
|
1413
|
+
view?.status === "unconfigured" ? (0, import_react6.createElement)("div", { className: "dsh-model-allowance-reason" }, t("badge.unconfigured")) : null,
|
|
1414
|
+
// A vendor that prices by the wall clock gets its phase and
|
|
1415
|
+
// countdown here, above the footer.
|
|
1416
|
+
schedule && schedule.provider === activeProvider ? scheduleView(schedule, now, t) : null,
|
|
1417
|
+
(0, import_react6.createElement)(
|
|
1418
|
+
"div",
|
|
1419
|
+
{ className: "dsh-model-allowance-actions" },
|
|
1420
|
+
// The platform status sits at the left edge of the footer, on
|
|
1421
|
+
// the same line as the reading time: the card gains no extra
|
|
1422
|
+
// row, and the state and the source page stay together.
|
|
1423
|
+
(0, import_react6.createElement)(
|
|
1424
|
+
"span",
|
|
1425
|
+
{ className: "dsh-model-allowance-status-wrap" },
|
|
1426
|
+
(0, import_react6.createElement)(
|
|
1427
|
+
currentStatus?.url ? "a" : "span",
|
|
1428
|
+
{
|
|
1429
|
+
className: "dsh-model-allowance-status",
|
|
1430
|
+
"data-state": serviceState,
|
|
1431
|
+
...currentStatus?.url ? {
|
|
1432
|
+
href: currentStatus.url,
|
|
1433
|
+
target: "_blank",
|
|
1434
|
+
rel: "noreferrer noopener"
|
|
1435
|
+
} : {}
|
|
1436
|
+
},
|
|
1437
|
+
(0, import_react6.createElement)("span", {
|
|
1438
|
+
className: "dsh-model-allowance-status-dot",
|
|
1439
|
+
"aria-hidden": true
|
|
1440
|
+
}),
|
|
1441
|
+
(0, import_react6.createElement)(
|
|
1442
|
+
"span",
|
|
1443
|
+
{ className: "dsh-model-allowance-status-label" },
|
|
1444
|
+
statusLabel(serviceState, t)
|
|
1445
|
+
),
|
|
1446
|
+
...currentStatus?.url ? [
|
|
1447
|
+
(0, import_react6.createElement)(
|
|
1448
|
+
"span",
|
|
1449
|
+
{
|
|
1450
|
+
className: "dsh-model-allowance-status-arrow",
|
|
1451
|
+
"aria-hidden": true
|
|
1452
|
+
},
|
|
1453
|
+
"\u2197"
|
|
1454
|
+
)
|
|
1455
|
+
] : []
|
|
1456
|
+
),
|
|
1457
|
+
// The reason is a warning mark rather than another line:
|
|
1458
|
+
// the footer stays one row, and the detail is one hover
|
|
1459
|
+
// — or one keyboard focus — away.
|
|
1460
|
+
currentStatus?.summary ? (0, import_react6.createElement)(
|
|
1461
|
+
"span",
|
|
1462
|
+
{
|
|
1463
|
+
className: "dsh-model-allowance-status-help",
|
|
1464
|
+
tabIndex: 0,
|
|
1465
|
+
role: "note",
|
|
1466
|
+
"aria-label": currentStatus.summary
|
|
1467
|
+
},
|
|
1468
|
+
(0, import_react6.createElement)(
|
|
1469
|
+
"span",
|
|
1470
|
+
{
|
|
1471
|
+
"aria-hidden": true
|
|
1472
|
+
},
|
|
1473
|
+
"!"
|
|
1474
|
+
),
|
|
1475
|
+
(0, import_react6.createElement)(
|
|
1476
|
+
"span",
|
|
1477
|
+
{ className: "dsh-model-allowance-status-tip", role: "tooltip" },
|
|
1478
|
+
currentStatus.summary
|
|
1479
|
+
)
|
|
1480
|
+
) : null
|
|
1481
|
+
),
|
|
1482
|
+
view?.updatedAt ? (0, import_react6.createElement)(
|
|
1483
|
+
"span",
|
|
1484
|
+
{ className: "dsh-model-allowance-updated" },
|
|
1485
|
+
t("detail.updatedAt", { time: formatClock(view.updatedAt) })
|
|
1486
|
+
) : null,
|
|
1487
|
+
(0, import_react6.createElement)(
|
|
1488
|
+
"button",
|
|
1489
|
+
{
|
|
1490
|
+
type: "button",
|
|
1491
|
+
className: "dsh-model-allowance-icon-button",
|
|
1492
|
+
onClick: refresh,
|
|
1493
|
+
disabled: refreshing,
|
|
1494
|
+
title: refreshing ? t("detail.refreshing") : t("detail.refresh"),
|
|
1495
|
+
"aria-label": refreshing ? t("detail.refreshing") : t("detail.refresh")
|
|
1496
|
+
},
|
|
1497
|
+
refreshGlyph(16)
|
|
1498
|
+
),
|
|
1499
|
+
view?.consoleUrl ? (0, import_react6.createElement)(
|
|
1500
|
+
"a",
|
|
1501
|
+
{
|
|
1502
|
+
className: "dsh-model-allowance-icon-button",
|
|
1503
|
+
href: view.consoleUrl,
|
|
1504
|
+
target: "_blank",
|
|
1505
|
+
rel: "noreferrer noopener",
|
|
1506
|
+
title: t("detail.console"),
|
|
1507
|
+
"aria-label": t("detail.console")
|
|
1508
|
+
},
|
|
1509
|
+
consoleGlyph(16)
|
|
1510
|
+
) : null,
|
|
1511
|
+
// The switch to another model of this provider. It sits to the
|
|
1512
|
+
// right of the console link, which is the last thing the footer
|
|
1513
|
+
// offered before, so the two never trade places.
|
|
1514
|
+
canSwitch ? (0, import_react6.createElement)(
|
|
1515
|
+
"span",
|
|
1516
|
+
{ ref: catalog.modelWrapRef, className: "dsh-model-allowance-model-wrap" },
|
|
1517
|
+
(0, import_react6.createElement)(
|
|
1518
|
+
"button",
|
|
1519
|
+
{
|
|
1520
|
+
type: "button",
|
|
1521
|
+
className: "dsh-model-allowance-icon-button",
|
|
1522
|
+
"aria-haspopup": "menu",
|
|
1523
|
+
"aria-expanded": catalog.modelMenuOpen ? "true" : "false",
|
|
1524
|
+
// The vendor in use paints the glyph in its own
|
|
1525
|
+
// colour, so the button says which vendor the card is
|
|
1526
|
+
// on instead of the strip having to say it twice.
|
|
1527
|
+
"data-in-use": inUse ? "true" : "false",
|
|
1528
|
+
style: { "--provider-mark": markFor(activeProvider).color },
|
|
1529
|
+
title: switchLabel,
|
|
1530
|
+
"aria-label": switchLabel,
|
|
1531
|
+
onClick: catalog.toggleModelMenu
|
|
1532
|
+
},
|
|
1533
|
+
modelGlyph(16)
|
|
1534
|
+
),
|
|
1535
|
+
catalog.modelMenuOpen ? (0, import_react6.createElement)(ModelMenu, {
|
|
1536
|
+
t,
|
|
1537
|
+
models: catalog.shownModelList,
|
|
1538
|
+
state: catalog.shownModelListState,
|
|
1539
|
+
modelError: catalog.modelError,
|
|
1540
|
+
currentModel: catalog.currentModel,
|
|
1541
|
+
switchingModel: catalog.switchingModel,
|
|
1542
|
+
switchToModel: catalog.switchToModel,
|
|
1543
|
+
modelWrapRef: catalog.modelWrapRef,
|
|
1544
|
+
showEffortFlyout: catalog.showEffortFlyout,
|
|
1545
|
+
scheduleEffortFlyoutClose: catalog.scheduleEffortFlyoutClose
|
|
1546
|
+
}) : null,
|
|
1547
|
+
// The effort flyout is a sibling of the list, not a
|
|
1548
|
+
// child: the list scrolls, and a nested panel would be
|
|
1549
|
+
// clipped by it.
|
|
1550
|
+
catalog.modelMenuOpen && catalog.hoverModel !== null && catalog.shownModelList.includes(catalog.hoverModel.model) ? (0, import_react6.createElement)(EffortFlyout, {
|
|
1551
|
+
t,
|
|
1552
|
+
hoverModel: catalog.hoverModel,
|
|
1553
|
+
currentModel: catalog.currentModel,
|
|
1554
|
+
selectedEffort,
|
|
1555
|
+
switchingModel: catalog.switchingModel,
|
|
1556
|
+
switchToModel: catalog.switchToModel,
|
|
1557
|
+
keepEffortFlyout: catalog.keepEffortFlyout,
|
|
1558
|
+
scheduleEffortFlyoutClose: catalog.scheduleEffortFlyoutClose
|
|
1559
|
+
}) : null
|
|
1560
|
+
) : null
|
|
1561
|
+
)
|
|
1562
|
+
);
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
// src/client/hooks/use-balance-stream.js
|
|
1566
|
+
var React3 = __toESM(require("react"), 1);
|
|
1567
|
+
function describe(error) {
|
|
1568
|
+
return error instanceof Error ? error.message : String(error);
|
|
1569
|
+
}
|
|
1570
|
+
async function readProviderStatus(provider) {
|
|
1571
|
+
try {
|
|
1572
|
+
const api = await getBalanceApi();
|
|
1573
|
+
if (!api || typeof api.status !== "function") {
|
|
1574
|
+
return { provider, state: "unknown", error: "status API unavailable" };
|
|
1575
|
+
}
|
|
1576
|
+
const result = await api.status(provider);
|
|
1577
|
+
if (!result.ok) {
|
|
1578
|
+
const error = typeof result.error?.message === "string" ? result.error.message : typeof result.error === "string" ? result.error : "status reading failed";
|
|
1579
|
+
return { provider, state: "unknown", error };
|
|
1580
|
+
}
|
|
1581
|
+
return result.value;
|
|
1582
|
+
} catch (error) {
|
|
1583
|
+
console.error("[model-allowance] reading provider status failed", { provider, error });
|
|
1584
|
+
return { provider, state: "unknown", error: describe(error) };
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
function useBalanceStream({ activeProvider, activeModel, ctx, setView, setLoading }) {
|
|
1588
|
+
React3.useEffect(() => {
|
|
1589
|
+
if (!activeProvider) {
|
|
1590
|
+
setView(null);
|
|
1591
|
+
setLoading(false);
|
|
1592
|
+
return;
|
|
1593
|
+
}
|
|
1594
|
+
let cancelled = false;
|
|
1595
|
+
let handle;
|
|
1596
|
+
setLoading(true);
|
|
1597
|
+
const readOnce = async (api, model) => {
|
|
1598
|
+
try {
|
|
1599
|
+
let result = await api.balance(activeProvider, model);
|
|
1600
|
+
if (!result.ok && model !== void 0) {
|
|
1601
|
+
result = await api.balance(activeProvider, void 0);
|
|
1602
|
+
}
|
|
1603
|
+
if (cancelled) return;
|
|
1604
|
+
if (!result.ok) {
|
|
1605
|
+
const detail = typeof result.error?.message === "string" ? result.error.message : typeof result.error === "string" ? result.error : "balance reading failed";
|
|
1606
|
+
throw new Error(detail);
|
|
1607
|
+
}
|
|
1608
|
+
setView(result.value);
|
|
1609
|
+
} catch (error) {
|
|
1610
|
+
console.error("[model-allowance] reading failed", {
|
|
1611
|
+
provider: activeProvider,
|
|
1612
|
+
model,
|
|
1613
|
+
error
|
|
1614
|
+
});
|
|
1615
|
+
if (!cancelled) {
|
|
1616
|
+
setView({
|
|
1617
|
+
provider: activeProvider,
|
|
1618
|
+
status: "failed",
|
|
1619
|
+
kind: "quota",
|
|
1620
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1621
|
+
});
|
|
1622
|
+
}
|
|
1623
|
+
} finally {
|
|
1624
|
+
if (!cancelled) setLoading(false);
|
|
1625
|
+
}
|
|
1626
|
+
};
|
|
1627
|
+
(async () => {
|
|
1628
|
+
const api = await getBalanceApi();
|
|
1629
|
+
if (cancelled) return;
|
|
1630
|
+
if (!api) {
|
|
1631
|
+
setView({
|
|
1632
|
+
provider: activeProvider,
|
|
1633
|
+
status: "failed",
|
|
1375
1634
|
kind: "quota",
|
|
1376
1635
|
error: "balance namespace unavailable"
|
|
1377
1636
|
});
|
|
@@ -1423,8 +1682,570 @@ function BalanceBadge(props) {
|
|
|
1423
1682
|
cancelled = true;
|
|
1424
1683
|
handle?.dispose?.();
|
|
1425
1684
|
};
|
|
1426
|
-
}, [activeProvider, activeModel, ctx]);
|
|
1427
|
-
|
|
1685
|
+
}, [activeProvider, activeModel, ctx, setView, setLoading]);
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
// src/client/hooks/use-dismiss.js
|
|
1689
|
+
var React4 = __toESM(require("react"), 1);
|
|
1690
|
+
function useDismiss({ open, rootRef, modelMenuOpen, setOpen, setModelMenuOpen }) {
|
|
1691
|
+
React4.useEffect(() => {
|
|
1692
|
+
if (!open) return;
|
|
1693
|
+
const onPointerDown = (event) => {
|
|
1694
|
+
const root = rootRef.current;
|
|
1695
|
+
if (root && event.target instanceof Node && root.contains(event.target)) return;
|
|
1696
|
+
setOpen(false);
|
|
1697
|
+
};
|
|
1698
|
+
const onKeyDown = (event) => {
|
|
1699
|
+
if (event.key !== "Escape") return;
|
|
1700
|
+
if (modelMenuOpen) {
|
|
1701
|
+
setModelMenuOpen(false);
|
|
1702
|
+
return;
|
|
1703
|
+
}
|
|
1704
|
+
setOpen(false);
|
|
1705
|
+
};
|
|
1706
|
+
document.addEventListener("pointerdown", onPointerDown, true);
|
|
1707
|
+
document.addEventListener("keydown", onKeyDown);
|
|
1708
|
+
return () => {
|
|
1709
|
+
document.removeEventListener("pointerdown", onPointerDown, true);
|
|
1710
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
1711
|
+
};
|
|
1712
|
+
}, [open, modelMenuOpen, setOpen, setModelMenuOpen]);
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1715
|
+
// src/client/hooks/use-model-catalog.js
|
|
1716
|
+
var React5 = __toESM(require("react"), 1);
|
|
1717
|
+
var CATALOG_TTL_MS = 60 * 1e3;
|
|
1718
|
+
function useModelCatalog({ ctx, t, sessionId, activeProvider, entryOf, selection }) {
|
|
1719
|
+
const [modelList, setModelList] = React5.useState([]);
|
|
1720
|
+
const [modelListRoute, setModelListRoute] = React5.useState(null);
|
|
1721
|
+
const [catalogProvider, setCatalogProvider] = React5.useState(null);
|
|
1722
|
+
const [modelListState, setModelListState] = React5.useState("idle");
|
|
1723
|
+
const [modelError, setModelError] = React5.useState(null);
|
|
1724
|
+
const [modelMenuOpen, setModelMenuOpen] = React5.useState(false);
|
|
1725
|
+
const [hoverModel, setHoverModel] = React5.useState(null);
|
|
1726
|
+
const hoverModelTimer = React5.useRef(null);
|
|
1727
|
+
const [switchingModel, setSwitchingModel] = React5.useState(null);
|
|
1728
|
+
const modelWrapRef = React5.useRef(null);
|
|
1729
|
+
const catalogRef = React5.useRef({ value: null, at: 0 });
|
|
1730
|
+
const showModels = React5.useCallback(
|
|
1731
|
+
(catalog) => {
|
|
1732
|
+
const routes = [activeProvider, ...entryOf(activeProvider)?.modelRoutes ?? []];
|
|
1733
|
+
const group = providerModelGroup(catalog, routes);
|
|
1734
|
+
const models = group?.models ?? [];
|
|
1735
|
+
setCatalogProvider(group?.provider ?? null);
|
|
1736
|
+
setModelListRoute(activeProvider);
|
|
1737
|
+
setModelList(models);
|
|
1738
|
+
setModelListState(models.length > 0 ? "ready" : "empty");
|
|
1739
|
+
},
|
|
1740
|
+
[activeProvider, entryOf]
|
|
1741
|
+
);
|
|
1742
|
+
React5.useEffect(() => {
|
|
1743
|
+
if (!modelMenuOpen) return void 0;
|
|
1744
|
+
let cancelled = false;
|
|
1745
|
+
(async () => {
|
|
1746
|
+
const face = lookupSessionFace(ctx);
|
|
1747
|
+
if (face === void 0 || typeof face.modelCatalog !== "function") {
|
|
1748
|
+
setModelListState("error");
|
|
1749
|
+
setModelError(t("model.unavailable"));
|
|
1750
|
+
return;
|
|
1751
|
+
}
|
|
1752
|
+
const cached = catalogRef.current;
|
|
1753
|
+
if (cached.value !== null && Date.now() - cached.at < CATALOG_TTL_MS) {
|
|
1754
|
+
if (!cancelled) showModels(cached.value);
|
|
1755
|
+
return;
|
|
1756
|
+
}
|
|
1757
|
+
setModelListState("loading");
|
|
1758
|
+
try {
|
|
1759
|
+
const result = await face.modelCatalog();
|
|
1760
|
+
if (cancelled) return;
|
|
1761
|
+
if (!result?.ok) {
|
|
1762
|
+
setModelListState("error");
|
|
1763
|
+
setModelError(
|
|
1764
|
+
t("model.loadFailed", { error: result?.error?.message ?? result?.error?.code ?? "" })
|
|
1765
|
+
);
|
|
1766
|
+
return;
|
|
1767
|
+
}
|
|
1768
|
+
catalogRef.current = { value: result.value, at: Date.now() };
|
|
1769
|
+
showModels(result.value);
|
|
1770
|
+
} catch (error) {
|
|
1771
|
+
if (cancelled) return;
|
|
1772
|
+
setModelListState("error");
|
|
1773
|
+
setModelError(t("model.loadFailed", { error: describe(error) }));
|
|
1774
|
+
}
|
|
1775
|
+
})();
|
|
1776
|
+
return () => {
|
|
1777
|
+
cancelled = true;
|
|
1778
|
+
};
|
|
1779
|
+
}, [modelMenuOpen, ctx, t, showModels]);
|
|
1780
|
+
React5.useEffect(() => {
|
|
1781
|
+
if (!modelMenuOpen) return void 0;
|
|
1782
|
+
const onPointerDown = (event) => {
|
|
1783
|
+
const wrap = modelWrapRef.current;
|
|
1784
|
+
if (wrap && event.target instanceof Node && wrap.contains(event.target)) return;
|
|
1785
|
+
setModelMenuOpen(false);
|
|
1786
|
+
};
|
|
1787
|
+
document.addEventListener("pointerdown", onPointerDown, true);
|
|
1788
|
+
return () => {
|
|
1789
|
+
document.removeEventListener("pointerdown", onPointerDown, true);
|
|
1790
|
+
};
|
|
1791
|
+
}, [modelMenuOpen]);
|
|
1792
|
+
const switchToModel = React5.useCallback(
|
|
1793
|
+
async (model, effort) => {
|
|
1794
|
+
const face = lookupSessionFace(ctx);
|
|
1795
|
+
if (face === void 0 || typeof face.selectModel !== "function") {
|
|
1796
|
+
setModelError(t("model.unavailable"));
|
|
1797
|
+
return;
|
|
1798
|
+
}
|
|
1799
|
+
if (typeof sessionId !== "string" || sessionId === "") {
|
|
1800
|
+
setModelError(t("model.unavailable"));
|
|
1801
|
+
return;
|
|
1802
|
+
}
|
|
1803
|
+
setSwitchingModel(model.id);
|
|
1804
|
+
try {
|
|
1805
|
+
const result = await face.selectModel({
|
|
1806
|
+
sessionId,
|
|
1807
|
+
provider: catalogProvider ?? activeProvider,
|
|
1808
|
+
model: model.id,
|
|
1809
|
+
...typeof effort === "string" && effort !== "" ? { reasoningEffort: effort } : {}
|
|
1810
|
+
});
|
|
1811
|
+
if (!result?.ok) {
|
|
1812
|
+
setModelError(
|
|
1813
|
+
t("model.failed", { error: result?.error?.message ?? result?.error?.code ?? "" })
|
|
1814
|
+
);
|
|
1815
|
+
return;
|
|
1816
|
+
}
|
|
1817
|
+
setModelError(null);
|
|
1818
|
+
setModelMenuOpen(false);
|
|
1819
|
+
} catch (error) {
|
|
1820
|
+
console.error("[model-allowance] switching the model failed", { error });
|
|
1821
|
+
setModelError(t("model.failed", { error: describe(error) }));
|
|
1822
|
+
} finally {
|
|
1823
|
+
setSwitchingModel(null);
|
|
1824
|
+
}
|
|
1825
|
+
},
|
|
1826
|
+
[ctx, sessionId, activeProvider, catalogProvider, t]
|
|
1827
|
+
);
|
|
1828
|
+
const showEffortFlyout = React5.useCallback((model, top) => {
|
|
1829
|
+
clearTimeout(hoverModelTimer.current);
|
|
1830
|
+
setHoverModel({ model, top });
|
|
1831
|
+
}, []);
|
|
1832
|
+
const scheduleEffortFlyoutClose = React5.useCallback((id) => {
|
|
1833
|
+
clearTimeout(hoverModelTimer.current);
|
|
1834
|
+
hoverModelTimer.current = setTimeout(() => {
|
|
1835
|
+
setHoverModel((current) => current?.model?.id === id ? null : current);
|
|
1836
|
+
}, 150);
|
|
1837
|
+
}, []);
|
|
1838
|
+
const keepEffortFlyout = React5.useCallback(() => {
|
|
1839
|
+
clearTimeout(hoverModelTimer.current);
|
|
1840
|
+
}, []);
|
|
1841
|
+
const toggleModelMenu = React5.useCallback(() => {
|
|
1842
|
+
setModelError(null);
|
|
1843
|
+
clearTimeout(hoverModelTimer.current);
|
|
1844
|
+
setHoverModel(null);
|
|
1845
|
+
setModelMenuOpen((value) => !value);
|
|
1846
|
+
}, []);
|
|
1847
|
+
const modelProvider = catalogProvider ?? activeProvider;
|
|
1848
|
+
const currentModel = currentModelFor(selection, modelProvider);
|
|
1849
|
+
const shownModelList = modelListRoute === activeProvider ? modelList : [];
|
|
1850
|
+
const shownModelListState = modelListRoute === activeProvider ? modelListState : "loading";
|
|
1851
|
+
return {
|
|
1852
|
+
modelMenuOpen,
|
|
1853
|
+
setModelMenuOpen,
|
|
1854
|
+
modelWrapRef,
|
|
1855
|
+
shownModelList,
|
|
1856
|
+
shownModelListState,
|
|
1857
|
+
modelError,
|
|
1858
|
+
setModelError,
|
|
1859
|
+
currentModel,
|
|
1860
|
+
switchingModel,
|
|
1861
|
+
hoverModel,
|
|
1862
|
+
showEffortFlyout,
|
|
1863
|
+
scheduleEffortFlyoutClose,
|
|
1864
|
+
keepEffortFlyout,
|
|
1865
|
+
toggleModelMenu,
|
|
1866
|
+
switchToModel
|
|
1867
|
+
};
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1870
|
+
// src/client/styles.js
|
|
1871
|
+
var STYLES = [
|
|
1872
|
+
".dsh-model-allowance-root{position:relative;display:inline-flex;align-items:center}",
|
|
1873
|
+
// The badge is a trigger, the way the harness's own composer triggers
|
|
1874
|
+
// are: no frame of its own, a transparent surface, and the hover tint
|
|
1875
|
+
// only while the pointer is on it or the card is open. A bordered pill
|
|
1876
|
+
// read as a field rather than a control.
|
|
1877
|
+
".dsh-model-allowance-badge{display:inline-flex;align-items:center;gap:6px;height:24px;padding:0 8px;",
|
|
1878
|
+
"border:0;border-radius:var(--dsw-radius-sm);background:0 0;",
|
|
1879
|
+
"color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:1;cursor:pointer;",
|
|
1880
|
+
"font-variant-numeric:tabular-nums;white-space:nowrap}",
|
|
1881
|
+
".dsh-model-allowance-badge:hover{color:var(--dsw-alias-label-secondary);",
|
|
1882
|
+
"background:var(--dsw-alias-interactive-bg-hover)}",
|
|
1883
|
+
'.dsh-model-allowance-badge[aria-expanded="true"]{color:var(--dsw-alias-label-secondary);',
|
|
1884
|
+
"background:var(--dsw-alias-interactive-bg-hover)}",
|
|
1885
|
+
".dsh-model-allowance-badge:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);",
|
|
1886
|
+
"outline-offset:1px}",
|
|
1887
|
+
".dsh-model-allowance-dot{width:6px;height:6px;border-radius:50%;flex:none;",
|
|
1888
|
+
"background:var(--dsw-alias-state-idle-primary)}",
|
|
1889
|
+
// The dot reports the platform, not the reading: green while the service
|
|
1890
|
+
// is available, red once its own status page says otherwise, and grey
|
|
1891
|
+
// when this installation has no status source for the route.
|
|
1892
|
+
'.dsh-model-allowance-root[data-service="operational"] .dsh-model-allowance-dot{',
|
|
1893
|
+
"background:var(--dsw-alias-state-success-primary)}",
|
|
1894
|
+
'.dsh-model-allowance-root[data-service="degraded"] .dsh-model-allowance-dot,',
|
|
1895
|
+
'.dsh-model-allowance-root[data-service="partial-outage"] .dsh-model-allowance-dot,',
|
|
1896
|
+
'.dsh-model-allowance-root[data-service="major-outage"] .dsh-model-allowance-dot,',
|
|
1897
|
+
'.dsh-model-allowance-root[data-service="maintenance"] .dsh-model-allowance-dot{',
|
|
1898
|
+
"background:var(--dsw-alias-state-error-primary)}",
|
|
1899
|
+
'.dsh-model-allowance-root[data-loading="true"] .dsh-model-allowance-dot{opacity:.5}',
|
|
1900
|
+
// The turn's difference rides beside the value for a few seconds. It is
|
|
1901
|
+
// quieter than the value so the balance stays the thing being read, and
|
|
1902
|
+
// it fades in rather than popping.
|
|
1903
|
+
".dsh-model-allowance-delta{margin-left:-2px;font-size:11px;",
|
|
1904
|
+
"color:var(--dsw-alias-label-secondary);animation:dsh-model-allowance-fade 200ms ease-out}",
|
|
1905
|
+
'.dsh-model-allowance-delta[data-direction="up"]{',
|
|
1906
|
+
"color:var(--dsw-alias-state-success-primary)}",
|
|
1907
|
+
"@keyframes dsh-model-allowance-fade{from{opacity:0}to{opacity:1}}",
|
|
1908
|
+
// Anchored to its own right edge: the badge sits next to the model seat
|
|
1909
|
+
// near the trailing edge, so the panel opens leftwards instead of
|
|
1910
|
+
// running off the side of the composer.
|
|
1911
|
+
//
|
|
1912
|
+
// The surface is the harness's own menu surface — a translucent white
|
|
1913
|
+
// behind a heavy blur — and the shadow is its own elevation scale. The
|
|
1914
|
+
// overlay token reads as a mask over the page behind, not as a panel
|
|
1915
|
+
// surface: on it this card came out a flat grey slab.
|
|
1916
|
+
// The floor is set for the layout, not for the content: with it removed
|
|
1917
|
+
// the card collapses to 248px, so 300px is the slack that lets a label
|
|
1918
|
+
// and its value read as two columns instead of one run-on line. The cap
|
|
1919
|
+
// is the harness's own idiom for a floating surface, so a narrow window
|
|
1920
|
+
// shrinks the card rather than pushing it off the composer.
|
|
1921
|
+
".dsh-model-allowance-panel{position:absolute;bottom:calc(100% + 6px);right:0;z-index:20;",
|
|
1922
|
+
"box-sizing:border-box;min-width:300px;max-width:calc(100vw - 24px);",
|
|
1923
|
+
"padding:8px 10px 10px;border:0;",
|
|
1924
|
+
"border-radius:var(--dsw-radius-lg);background:var(--dsw-alias-bg-layer-2);",
|
|
1925
|
+
"box-shadow:var(--dsw-elevation-prominent);color:var(--dsw-alias-label-primary);",
|
|
1926
|
+
"font-size:12px}",
|
|
1927
|
+
".dsh-model-allowance-row{display:flex;justify-content:space-between;gap:16px;padding:2px 0}",
|
|
1928
|
+
// Label first, value second, matching every other pair in the card
|
|
1929
|
+
// (schedule title/state, status/reading time): the label carries the
|
|
1930
|
+
// emphasis and the value reads as its detail. Reversed, the balance row
|
|
1931
|
+
// stood out as the one pair laid out the other way round.
|
|
1932
|
+
".dsh-model-allowance-row>span:first-child{color:var(--dsw-alias-label-primary)}",
|
|
1933
|
+
".dsh-model-allowance-row>span:last-child{color:var(--dsw-alias-label-secondary)}",
|
|
1934
|
+
".dsh-model-allowance-usage{font-variant-numeric:tabular-nums;",
|
|
1935
|
+
"color:var(--dsw-alias-label-secondary)}",
|
|
1936
|
+
// The row cancels the panel's own horizontal padding so the divider under
|
|
1937
|
+
// it runs edge to edge, then puts the same padding back so the first mark
|
|
1938
|
+
// lines up with the labels below. Without this the marks sit further from
|
|
1939
|
+
// the edge than every other row and the whole strip reads as shifted left.
|
|
1940
|
+
".dsh-model-allowance-switcher-wrap{position:relative;margin:-2px -10px 6px;",
|
|
1941
|
+
"padding:0 10px 8px;border-bottom:1px solid var(--dsw-alias-border-l1)}",
|
|
1942
|
+
".dsh-model-allowance-switcher{display:flex;flex-wrap:nowrap;align-items:center;",
|
|
1943
|
+
"gap:4px;overflow:hidden}",
|
|
1944
|
+
// The mark sits straight on the panel; the chip draws no surface of its
|
|
1945
|
+
// own, so the panel's own surface shows through behind the logo.
|
|
1946
|
+
//
|
|
1947
|
+
// A frame means one thing here: this is the provider being read. It is
|
|
1948
|
+
// not used to say anything else about a route, because a second meaning
|
|
1949
|
+
// makes an unselected mark look selected.
|
|
1950
|
+
".dsh-model-allowance-tab{display:inline-flex;align-items:center;justify-content:center;",
|
|
1951
|
+
"box-sizing:border-box;width:26px;height:26px;flex:none;padding:0;",
|
|
1952
|
+
"border:1px solid transparent;border-radius:var(--dsw-radius-sm);",
|
|
1953
|
+
"background:0 0;line-height:1;cursor:pointer;",
|
|
1954
|
+
"color:var(--provider-mark,var(--dsw-alias-label-primary));opacity:.66}",
|
|
1955
|
+
".dsh-model-allowance-tab:hover{opacity:.9}",
|
|
1956
|
+
// The selected mark gains the one frame the chip already has, and stops
|
|
1957
|
+
// being dimmed. It must not use the brand colour: in this theme that is
|
|
1958
|
+
// #0f1115, so a selected chip wore a near-black frame. It also gains no
|
|
1959
|
+
// background, since any fill here reintroduces a tile on the panel.
|
|
1960
|
+
'.dsh-model-allowance-tab[data-active="true"]{opacity:1;',
|
|
1961
|
+
"border-color:var(--dsw-alias-border-l2)}",
|
|
1962
|
+
".dsh-model-allowance-tab:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);",
|
|
1963
|
+
"outline-offset:-1px}",
|
|
1964
|
+
".dsh-model-allowance-tab svg{display:block}",
|
|
1965
|
+
".dsh-model-allowance-tab-letter{font-size:11px;font-weight:600;line-height:1}",
|
|
1966
|
+
".dsh-model-allowance-more{display:inline-flex;align-items:center;justify-content:center;",
|
|
1967
|
+
"box-sizing:border-box;width:26px;height:26px;flex:none;margin-left:auto;padding:0;",
|
|
1968
|
+
"border-radius:var(--dsw-radius-sm);",
|
|
1969
|
+
"border:1px solid var(--dsw-alias-border-l1);background:0 0;cursor:pointer;",
|
|
1970
|
+
"color:var(--dsw-alias-label-tertiary);font-size:13px;line-height:1}",
|
|
1971
|
+
".dsh-model-allowance-more:hover{color:var(--dsw-alias-label-secondary);",
|
|
1972
|
+
"border-color:var(--dsw-alias-border-l2)}",
|
|
1973
|
+
// The overflow menu is a second floating surface, so it carries the same
|
|
1974
|
+
// solid layer and elevation as the card it belongs to.
|
|
1975
|
+
".dsh-model-allowance-menu{position:absolute;top:calc(100% + 2px);right:0;z-index:30;",
|
|
1976
|
+
"min-width:150px;padding:4px;border:0;",
|
|
1977
|
+
"border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-layer-2);",
|
|
1978
|
+
"box-shadow:var(--dsw-elevation-prominent)}",
|
|
1979
|
+
".dsh-model-allowance-menu-item{display:flex;align-items:center;gap:8px;width:100%;",
|
|
1980
|
+
"padding:4px 6px;border:0;border-radius:var(--dsw-radius-xs);background:0 0;",
|
|
1981
|
+
"color:var(--dsw-alias-label-primary);font-size:12px;text-align:left;cursor:pointer}",
|
|
1982
|
+
".dsh-model-allowance-menu-item:hover{background:var(--dsw-alias-interactive-bg-hover)}",
|
|
1983
|
+
// Same rule as the strip chips: no surface of its own, so the mark sits
|
|
1984
|
+
// on the menu instead of on a tile.
|
|
1985
|
+
".dsh-model-allowance-menu-mark{display:inline-flex;align-items:center;",
|
|
1986
|
+
"justify-content:center;width:20px;height:20px;flex:none;border-radius:var(--dsw-radius-xs);",
|
|
1987
|
+
"line-height:1;background:0 0;",
|
|
1988
|
+
"color:var(--provider-mark,var(--dsw-alias-label-primary))}",
|
|
1989
|
+
".dsh-model-allowance-menu-mark svg{display:block}",
|
|
1990
|
+
// The model list is a third floating surface. It opens upwards from the
|
|
1991
|
+
// footer button, so it carries the same menu surface and elevation as the
|
|
1992
|
+
// card and the provider overflow menu.
|
|
1993
|
+
//
|
|
1994
|
+
// It is the one surface that is not translucent: the list floats over the
|
|
1995
|
+
// conversation, and a frosted panel there let the text underneath show
|
|
1996
|
+
// through the model names. A solid layer keeps the list readable wherever
|
|
1997
|
+
// it opens.
|
|
1998
|
+
".dsh-model-allowance-model-wrap{position:relative;display:inline-flex}",
|
|
1999
|
+
".dsh-model-allowance-model-menu{position:absolute;bottom:calc(100% + 4px);right:0;z-index:30;",
|
|
2000
|
+
"min-width:180px;max-width:260px;max-height:240px;overflow-y:auto;padding:4px;border:0;",
|
|
2001
|
+
"border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-layer-2);",
|
|
2002
|
+
"box-shadow:var(--dsw-elevation-prominent)}",
|
|
2003
|
+
".dsh-model-allowance-model-item{display:flex;align-items:center;justify-content:space-between;",
|
|
2004
|
+
"gap:10px;width:100%;padding:4px 6px;border:0;border-radius:var(--dsw-radius-xs);",
|
|
2005
|
+
"background:0 0;color:var(--dsw-alias-label-primary);font-size:12px;text-align:left;cursor:pointer}",
|
|
2006
|
+
".dsh-model-allowance-model-item:hover{background:var(--dsw-alias-interactive-bg-hover)}",
|
|
2007
|
+
// The model the session uses is dimmed rather than framed: a frame here
|
|
2008
|
+
// would give the chip a second meaning it does not have.
|
|
2009
|
+
'.dsh-model-allowance-model-item[data-current="true"]{color:var(--dsw-alias-label-secondary)}',
|
|
2010
|
+
".dsh-model-allowance-model-item[disabled]{opacity:.6;cursor:default}",
|
|
2011
|
+
".dsh-model-allowance-model-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
|
|
2012
|
+
// The trailing side of a model row carries its state label and, for a
|
|
2013
|
+
// model with reasoning efforts, the arrow that says a flyout waits to
|
|
2014
|
+
// the right.
|
|
2015
|
+
".dsh-model-allowance-model-side{display:inline-flex;align-items:center;gap:4px;flex:none}",
|
|
2016
|
+
".dsh-model-allowance-model-arrow{color:var(--dsw-alias-label-tertiary);font-size:12px;",
|
|
2017
|
+
"line-height:1}",
|
|
2018
|
+
// The effort flyout opens to the right of the list, on the row the
|
|
2019
|
+
// pointer rests on, as a fourth floating surface of the card. It overlaps
|
|
2020
|
+
// the list, so it is solid for the same reason the list is.
|
|
2021
|
+
".dsh-model-allowance-effort-menu{position:absolute;left:calc(100% + 4px);z-index:31;",
|
|
2022
|
+
"display:flex;flex-direction:column;min-width:130px;max-width:220px;padding:4px;border:0;",
|
|
2023
|
+
"border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-layer-2);",
|
|
2024
|
+
"box-shadow:var(--dsw-elevation-prominent)}",
|
|
2025
|
+
".dsh-model-allowance-effort-item{display:flex;align-items:center;justify-content:space-between;",
|
|
2026
|
+
"gap:10px;width:100%;padding:3px 6px;border:0;border-radius:var(--dsw-radius-xs);",
|
|
2027
|
+
"background:0 0;color:var(--dsw-alias-label-primary);font-size:12px;text-align:left;cursor:pointer}",
|
|
2028
|
+
".dsh-model-allowance-effort-item:hover{background:var(--dsw-alias-interactive-bg-hover)}",
|
|
2029
|
+
// The provider's own default effort is dimmed like the model in use, so
|
|
2030
|
+
// the open submenu points at it before anything is picked.
|
|
2031
|
+
'.dsh-model-allowance-effort-item[data-default="true"],',
|
|
2032
|
+
'.dsh-model-allowance-effort-item[data-current="true"]{color:var(--dsw-alias-label-secondary)}',
|
|
2033
|
+
".dsh-model-allowance-effort-item[disabled]{opacity:.6;cursor:default}",
|
|
2034
|
+
// The trailing label names the state of one model: the one in use, or the
|
|
2035
|
+
// one being switched to.
|
|
2036
|
+
".dsh-model-allowance-model-note{flex:none;color:var(--dsw-alias-label-tertiary);font-size:11px}",
|
|
2037
|
+
// A message covers the whole list: it loads, it is empty, or the switch
|
|
2038
|
+
// failed and says why.
|
|
2039
|
+
".dsh-model-allowance-model-message{padding:4px 6px;color:var(--dsw-alias-label-secondary);",
|
|
2040
|
+
"font-size:11px;word-break:break-word}",
|
|
2041
|
+
'.dsh-model-allowance-model-message[data-tone="error"]{',
|
|
2042
|
+
"color:var(--dsw-alias-state-error-primary)}",
|
|
2043
|
+
".dsh-model-allowance-window{margin-top:10px;padding-top:10px;",
|
|
2044
|
+
"border-top:1px solid var(--dsw-alias-border-l1)}",
|
|
2045
|
+
// The first window has no boundary above it: the switcher already ends
|
|
2046
|
+
// in a divider, and a bare provider row should not be underlined.
|
|
2047
|
+
'.dsh-model-allowance-window[data-first="true"]{margin-top:0;padding-top:8px;',
|
|
2048
|
+
"border-top:0}",
|
|
2049
|
+
".dsh-model-allowance-window-head{display:flex;justify-content:space-between;",
|
|
2050
|
+
"align-items:baseline;gap:12px}",
|
|
2051
|
+
".dsh-model-allowance-window-title{font-weight:500;color:var(--dsw-alias-label-primary)}",
|
|
2052
|
+
".dsh-model-allowance-percent{margin-top:2px;color:var(--dsw-alias-label-secondary);",
|
|
2053
|
+
"font-size:11px;font-variant-numeric:tabular-nums}",
|
|
2054
|
+
// The bar's track is the harness's own hover tint, not a white well: on
|
|
2055
|
+
// a white card a white track was invisible, and the inset frame around
|
|
2056
|
+
// it drew the eye to the groove instead of to the fill.
|
|
2057
|
+
".dsh-model-allowance-bar{margin-top:6px;height:6px;border-radius:999px;overflow:hidden;",
|
|
2058
|
+
"background:var(--dsw-alias-interactive-bg-hover)}",
|
|
2059
|
+
".dsh-model-allowance-bar-fill{height:100%;border-radius:999px;",
|
|
2060
|
+
"background:var(--dsw-alias-state-success-primary);transition:width 300ms ease}",
|
|
2061
|
+
'.dsh-model-allowance-bar-fill[data-tone="warn"]{',
|
|
2062
|
+
"background:var(--dsw-alias-state-warn-primary)}",
|
|
2063
|
+
'.dsh-model-allowance-bar-fill[data-tone="error"]{',
|
|
2064
|
+
"background:var(--dsw-alias-state-error-primary)}",
|
|
2065
|
+
".dsh-model-allowance-foot{display:flex;justify-content:space-between;",
|
|
2066
|
+
"align-items:baseline;gap:10px;flex-wrap:wrap;margin-top:5px;",
|
|
2067
|
+
"color:var(--dsw-alias-label-secondary);",
|
|
2068
|
+
"font-size:11px;font-variant-numeric:tabular-nums;word-break:break-word}",
|
|
2069
|
+
".dsh-model-allowance-error{padding:4px 0;color:var(--dsw-alias-state-error-primary)}",
|
|
2070
|
+
".dsh-model-allowance-reason{padding:2px 0;color:var(--dsw-alias-label-secondary);",
|
|
2071
|
+
"font-size:11px;word-break:break-word}",
|
|
2072
|
+
// The footer is one right-aligned cluster: the reading time sits directly
|
|
2073
|
+
// left of the two icon buttons.
|
|
2074
|
+
".dsh-model-allowance-actions{display:flex;align-items:center;",
|
|
2075
|
+
"justify-content:flex-end;gap:8px;margin-top:8px;padding-top:8px;",
|
|
2076
|
+
"border-top:1px solid var(--dsw-alias-border-l1)}",
|
|
2077
|
+
".dsh-model-allowance-updated{color:var(--dsw-alias-label-secondary);font-size:11px;",
|
|
2078
|
+
"font-variant-numeric:tabular-nums;white-space:nowrap;margin-right:2px}",
|
|
2079
|
+
".dsh-model-allowance-icon-button{display:inline-flex;align-items:center;",
|
|
2080
|
+
"justify-content:center;box-sizing:border-box;width:26px;height:26px;flex:none;padding:0;",
|
|
2081
|
+
"border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm);background:0 0;",
|
|
2082
|
+
"color:var(--dsw-alias-label-tertiary);cursor:pointer;text-decoration:none}",
|
|
2083
|
+
".dsh-model-allowance-icon-button:hover{color:var(--dsw-alias-label-secondary);",
|
|
2084
|
+
"border-color:var(--dsw-alias-border-l3);background:var(--dsw-alias-interactive-bg-hover)}",
|
|
2085
|
+
// The vendor in use paints the switch glyph in that vendor's own colour,
|
|
2086
|
+
// so the button says which vendor the card is on. The frame stays
|
|
2087
|
+
// neutral: a coloured frame would fight the vendor marks in the strip
|
|
2088
|
+
// above it.
|
|
2089
|
+
'.dsh-model-allowance-icon-button[data-in-use="true"]{',
|
|
2090
|
+
"color:var(--provider-mark,var(--dsw-alias-label-primary));",
|
|
2091
|
+
"border-color:var(--dsw-alias-border-l3)}",
|
|
2092
|
+
'.dsh-model-allowance-icon-button[data-in-use="true"]:hover{',
|
|
2093
|
+
"color:var(--provider-mark,var(--dsw-alias-label-primary));",
|
|
2094
|
+
"background:var(--dsw-alias-interactive-bg-hover)}",
|
|
2095
|
+
".dsh-model-allowance-icon-button:focus-visible{",
|
|
2096
|
+
"outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}",
|
|
2097
|
+
".dsh-model-allowance-icon-button[disabled]{opacity:.5;cursor:default}",
|
|
2098
|
+
".dsh-model-allowance-icon-button svg{display:block}",
|
|
2099
|
+
// The platform status row: one dot whose colour is the state, the
|
|
2100
|
+
// localized label, and a link to the source page when the vendor
|
|
2101
|
+
// publishes one. It sits at the left edge of the footer, so the margin
|
|
2102
|
+
// below pushes the reading time and the buttons to the right edge.
|
|
2103
|
+
".dsh-model-allowance-status-wrap{display:inline-flex;align-items:center;gap:5px;",
|
|
2104
|
+
"margin-right:auto;min-width:0;font-size:11px}",
|
|
2105
|
+
".dsh-model-allowance-status{display:inline-flex;align-items:center;gap:5px;",
|
|
2106
|
+
"color:var(--dsw-alias-label-primary);text-decoration:none}",
|
|
2107
|
+
"a.dsh-model-allowance-status:hover{text-decoration:underline}",
|
|
2108
|
+
".dsh-model-allowance-status-label{flex:none}",
|
|
2109
|
+
// The degraded reason hides behind a warning mark: the footer keeps one
|
|
2110
|
+
// row, and the detail is one hover away. The mark wears the same hue an
|
|
2111
|
+
// exhausted allowance does, so the two warnings read alike.
|
|
2112
|
+
".dsh-model-allowance-status-help{position:relative;display:inline-flex;",
|
|
2113
|
+
"align-items:center;justify-content:center;box-sizing:border-box;width:14px;height:14px;",
|
|
2114
|
+
"flex:none;border:1px solid var(--dsw-alias-state-error-primary);border-radius:50%;",
|
|
2115
|
+
"color:var(--dsw-alias-state-error-primary);font-size:9px;font-weight:700;line-height:1;",
|
|
2116
|
+
"cursor:help}",
|
|
2117
|
+
".dsh-model-allowance-status-help:hover,",
|
|
2118
|
+
".dsh-model-allowance-status-help:focus-visible{background:var(--dsw-alias-state-error-primary);",
|
|
2119
|
+
"color:var(--dsw-alias-label-primary-foreground);outline:none}",
|
|
2120
|
+
".dsh-model-allowance-status-tip{display:none;position:absolute;left:0;",
|
|
2121
|
+
"bottom:calc(100% + 8px);z-index:40;width:max-content;max-width:240px;padding:6px 8px;",
|
|
2122
|
+
"border:0;border-radius:var(--dsw-radius-sm);",
|
|
2123
|
+
"background:var(--dsw-alias-tooltip-bg);box-shadow:var(--dsw-elevation-prominent);",
|
|
2124
|
+
"font-size:11px;font-weight:400;line-height:1.5;",
|
|
2125
|
+
// The hint sits on the harness's own tooltip surface, so it takes the
|
|
2126
|
+
// text colour that surface is read with: white on the dark tooltip.
|
|
2127
|
+
"color:var(--dsw-static-neutral-bluish-00);",
|
|
2128
|
+
"white-space:normal;text-align:left}",
|
|
2129
|
+
".dsh-model-allowance-status-help:hover .dsh-model-allowance-status-tip,",
|
|
2130
|
+
".dsh-model-allowance-status-help:focus-visible .dsh-model-allowance-status-tip{display:block}",
|
|
2131
|
+
".dsh-model-allowance-status-dot{width:6px;height:6px;border-radius:50%;flex:none;",
|
|
2132
|
+
"background:var(--dsw-alias-state-success-primary)}",
|
|
2133
|
+
'.dsh-model-allowance-status[data-state="loading"] .dsh-model-allowance-status-dot,',
|
|
2134
|
+
'.dsh-model-allowance-status[data-state="unsupported"] .dsh-model-allowance-status-dot,',
|
|
2135
|
+
'.dsh-model-allowance-status[data-state="unknown"] .dsh-model-allowance-status-dot{',
|
|
2136
|
+
"background:var(--dsw-alias-state-idle-primary)}",
|
|
2137
|
+
'.dsh-model-allowance-status[data-state="loading"] .dsh-model-allowance-status-dot{opacity:.5}',
|
|
2138
|
+
'.dsh-model-allowance-status[data-state="degraded"] .dsh-model-allowance-status-dot,',
|
|
2139
|
+
'.dsh-model-allowance-status[data-state="maintenance"] .dsh-model-allowance-status-dot{',
|
|
2140
|
+
"background:var(--dsw-alias-state-warn-primary)}",
|
|
2141
|
+
'.dsh-model-allowance-status[data-state="partial-outage"] .dsh-model-allowance-status-dot,',
|
|
2142
|
+
'.dsh-model-allowance-status[data-state="major-outage"] .dsh-model-allowance-status-dot{',
|
|
2143
|
+
"background:var(--dsw-alias-state-error-primary)}",
|
|
2144
|
+
".dsh-model-allowance-status-arrow{font-size:10px;flex:none;",
|
|
2145
|
+
"color:var(--dsw-alias-label-tertiary)}",
|
|
2146
|
+
// The time-of-day pricing block: the phase the clock is in, how far
|
|
2147
|
+
// through that stretch of time it is, and the countdown. The rule itself
|
|
2148
|
+
// hides behind the help mark, so the card stays readable.
|
|
2149
|
+
".dsh-model-allowance-schedule{margin-top:10px;padding-top:10px;",
|
|
2150
|
+
"border-top:1px solid var(--dsw-alias-border-l1)}",
|
|
2151
|
+
".dsh-model-allowance-schedule-head{display:flex;justify-content:space-between;",
|
|
2152
|
+
"align-items:center;gap:12px}",
|
|
2153
|
+
".dsh-model-allowance-schedule-title{font-weight:500;color:var(--dsw-alias-label-primary)}",
|
|
2154
|
+
".dsh-model-allowance-schedule-help{position:relative;display:inline-flex;",
|
|
2155
|
+
"align-items:center;justify-content:center;box-sizing:border-box;width:16px;height:16px;",
|
|
2156
|
+
"flex:none;border:1px solid var(--dsw-alias-border-l2);border-radius:50%;",
|
|
2157
|
+
"color:var(--dsw-alias-label-tertiary);font-size:10px;font-weight:600;line-height:1;",
|
|
2158
|
+
"cursor:help}",
|
|
2159
|
+
".dsh-model-allowance-schedule-help:hover,",
|
|
2160
|
+
".dsh-model-allowance-schedule-help:focus-visible{color:var(--dsw-alias-label-primary);",
|
|
2161
|
+
"border-color:var(--dsw-alias-label-secondary);outline:none}",
|
|
2162
|
+
// Opens upwards: the block sits just above the footer, so a tooltip
|
|
2163
|
+
// hanging below it would leave the panel.
|
|
2164
|
+
".dsh-model-allowance-schedule-tip{display:none;position:absolute;right:0;",
|
|
2165
|
+
"bottom:calc(100% + 8px);z-index:40;width:max-content;max-width:240px;padding:6px 8px;",
|
|
2166
|
+
"border:0;border-radius:var(--dsw-radius-sm);",
|
|
2167
|
+
"background:var(--dsw-alias-tooltip-bg);box-shadow:var(--dsw-elevation-prominent);",
|
|
2168
|
+
"font-size:11px;font-weight:400;line-height:1.5;",
|
|
2169
|
+
"color:var(--dsw-static-neutral-bluish-00);",
|
|
2170
|
+
"white-space:normal;text-align:left}",
|
|
2171
|
+
".dsh-model-allowance-schedule-help:hover .dsh-model-allowance-schedule-tip,",
|
|
2172
|
+
".dsh-model-allowance-schedule-help:focus-visible .dsh-model-allowance-schedule-tip{",
|
|
2173
|
+
"display:block}",
|
|
2174
|
+
".dsh-model-allowance-schedule-tip-line{display:block}",
|
|
2175
|
+
// One 24-hour strip for the vendor's day: its peak windows tinted red
|
|
2176
|
+
// and the off-peak day tinted green, both at low saturation so the
|
|
2177
|
+
// strip reads at a glance without glaring, and a cursor where the
|
|
2178
|
+
// clock stands.
|
|
2179
|
+
".dsh-model-allowance-schedule-timeline{position:relative;margin-top:8px;height:8px;",
|
|
2180
|
+
"border-radius:4px;overflow:hidden;",
|
|
2181
|
+
"background:color-mix(in srgb, var(--dsw-alias-state-success-primary) 12%,",
|
|
2182
|
+
"var(--dsw-alias-interactive-bg-hover));}",
|
|
2183
|
+
".dsh-model-allowance-schedule-timeline-peak{position:absolute;top:0;bottom:0;",
|
|
2184
|
+
// The same hue the exhausted allowance uses, so "peak" and "spent" read
|
|
2185
|
+
// as one family of warnings rather than two unrelated colours.
|
|
2186
|
+
"background:var(--dsw-alias-state-error-primary);opacity:.4}",
|
|
2187
|
+
".dsh-model-allowance-schedule-timeline-now{position:absolute;top:0;bottom:0;width:2px;",
|
|
2188
|
+
"margin-left:-1px;border-radius:1px;background:var(--dsw-alias-label-primary);",
|
|
2189
|
+
"box-shadow:0 0 0 1px var(--dsw-alias-bg-layer-1)}",
|
|
2190
|
+
".dsh-model-allowance-schedule-ticks{display:flex;justify-content:space-between;",
|
|
2191
|
+
"margin-top:2px;font-size:9px;line-height:1;color:var(--dsw-alias-label-secondary);",
|
|
2192
|
+
"font-variant-numeric:tabular-nums}",
|
|
2193
|
+
".dsh-model-allowance-schedule-countdown{margin-top:4px;text-align:right;font-size:11px;",
|
|
2194
|
+
"color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums}",
|
|
2195
|
+
// A badge that fades or grows while a user asks for less motion is noise.
|
|
2196
|
+
"@media (prefers-reduced-motion:reduce){.dsh-model-allowance-delta{animation:none}",
|
|
2197
|
+
".dsh-model-allowance-bar-fill{transition:none}}"
|
|
2198
|
+
];
|
|
2199
|
+
var STYLES_JOINED = STYLES.join("");
|
|
2200
|
+
|
|
2201
|
+
// src/client/badge.js
|
|
2202
|
+
function statusDisplayState(status) {
|
|
2203
|
+
if (status === null) return "loading";
|
|
2204
|
+
if (status.state === "unknown" && !status.url && !status.error) return "unsupported";
|
|
2205
|
+
return status.state;
|
|
2206
|
+
}
|
|
2207
|
+
function BalanceBadge(props) {
|
|
2208
|
+
const { useProjection, ctx, t } = props;
|
|
2209
|
+
const selection = useProjection("modelSelection");
|
|
2210
|
+
const selected = selection?.next?.provider ?? selection?.lastUsed?.provider ?? null;
|
|
2211
|
+
const selectedModel = selection?.next?.model ?? selection?.lastUsed?.model ?? void 0;
|
|
2212
|
+
const selectedEffort = selection?.next?.reasoningEffort ?? selection?.lastUsed?.reasoningEffort ?? void 0;
|
|
2213
|
+
const sessionId = props.sessionId;
|
|
2214
|
+
const [rawView, setView] = React6.useState(null);
|
|
2215
|
+
const [loading, setLoading] = React6.useState(false);
|
|
2216
|
+
const [open, setOpen] = React6.useState(false);
|
|
2217
|
+
const [refreshing, setRefreshing] = React6.useState(false);
|
|
2218
|
+
const rootRef = React6.useRef(null);
|
|
2219
|
+
const [now, setNow] = React6.useState(() => Date.now());
|
|
2220
|
+
const [picked, setPicked] = React6.useState(null);
|
|
2221
|
+
const [menuOpen, setMenuOpen] = React6.useState(false);
|
|
2222
|
+
const [providerStatus, setProviderStatus] = React6.useState(null);
|
|
2223
|
+
const [schedule, setSchedule] = React6.useState(null);
|
|
2224
|
+
const lastModelProvider = React6.useRef(null);
|
|
2225
|
+
React6.useEffect(() => {
|
|
2226
|
+
if (open) return;
|
|
2227
|
+
setPicked(null);
|
|
2228
|
+
setMenuOpen(false);
|
|
2229
|
+
}, [open]);
|
|
2230
|
+
const [stripWidth, setStripWidth] = React6.useState(0);
|
|
2231
|
+
const stripRef = React6.useRef(null);
|
|
2232
|
+
const { available, defaultProvider, entryOf, nameOf } = useProviderDirectory(selected);
|
|
2233
|
+
const provider = selected ?? defaultProvider;
|
|
2234
|
+
const activeProvider = picked ?? provider;
|
|
2235
|
+
const inUse = activeProvider === provider || entryOf(provider)?.route === activeProvider;
|
|
2236
|
+
const activeModel = inUse ? selectedModel : void 0;
|
|
2237
|
+
const switchLabel = t(inUse ? "detail.switchModelHere" : "detail.switchModelThere", {
|
|
2238
|
+
name: nameOf(activeProvider)
|
|
2239
|
+
});
|
|
2240
|
+
const view = rawView?.provider === activeProvider ? rawView : null;
|
|
2241
|
+
const showingDifference = consumptionFreshAt(view?.consumption, now);
|
|
2242
|
+
React6.useEffect(() => {
|
|
2243
|
+
if (!open && !showingDifference) return;
|
|
2244
|
+
setNow(Date.now());
|
|
2245
|
+
const timer = setInterval(() => setNow(Date.now()), 1e3);
|
|
2246
|
+
return () => clearInterval(timer);
|
|
2247
|
+
}, [open, showingDifference]);
|
|
2248
|
+
React6.useEffect(() => {
|
|
1428
2249
|
if (!activeProvider) return void 0;
|
|
1429
2250
|
let cancelled = false;
|
|
1430
2251
|
const readStatus = async () => {
|
|
@@ -1438,7 +2259,7 @@ function BalanceBadge(props) {
|
|
|
1438
2259
|
clearInterval(timer);
|
|
1439
2260
|
};
|
|
1440
2261
|
}, [activeProvider]);
|
|
1441
|
-
|
|
2262
|
+
React6.useEffect(() => {
|
|
1442
2263
|
if (!activeProvider) return void 0;
|
|
1443
2264
|
let cancelled = false;
|
|
1444
2265
|
(async () => {
|
|
@@ -1456,7 +2277,22 @@ function BalanceBadge(props) {
|
|
|
1456
2277
|
cancelled = true;
|
|
1457
2278
|
};
|
|
1458
2279
|
}, [activeProvider]);
|
|
1459
|
-
|
|
2280
|
+
useBalanceStream({ activeProvider, activeModel, ctx, setView, setLoading });
|
|
2281
|
+
const catalog = useModelCatalog({ ctx, t, sessionId, activeProvider, entryOf, selection });
|
|
2282
|
+
useDismiss({
|
|
2283
|
+
open,
|
|
2284
|
+
rootRef,
|
|
2285
|
+
modelMenuOpen: catalog.modelMenuOpen,
|
|
2286
|
+
setOpen,
|
|
2287
|
+
setModelMenuOpen: catalog.setModelMenuOpen
|
|
2288
|
+
});
|
|
2289
|
+
const selectionKey = `${provider ?? ""}\0${selectedModel ?? ""}`;
|
|
2290
|
+
React6.useEffect(() => {
|
|
2291
|
+
if (lastModelProvider.current === selectionKey) return;
|
|
2292
|
+
lastModelProvider.current = selectionKey;
|
|
2293
|
+
setPicked(null);
|
|
2294
|
+
});
|
|
2295
|
+
const refresh = React6.useCallback(async () => {
|
|
1460
2296
|
setRefreshing(true);
|
|
1461
2297
|
try {
|
|
1462
2298
|
const api = await getBalanceApi();
|
|
@@ -1479,115 +2315,10 @@ function BalanceBadge(props) {
|
|
|
1479
2315
|
setRefreshing(false);
|
|
1480
2316
|
}
|
|
1481
2317
|
}, [activeProvider, activeModel]);
|
|
1482
|
-
const
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
const models = group?.models ?? [];
|
|
1487
|
-
setCatalogProvider(group?.provider ?? null);
|
|
1488
|
-
setModelListRoute(activeProvider);
|
|
1489
|
-
setModelList(models);
|
|
1490
|
-
setModelListState(models.length > 0 ? "ready" : "empty");
|
|
1491
|
-
},
|
|
1492
|
-
[activeProvider, entryOf]
|
|
1493
|
-
);
|
|
1494
|
-
React.useEffect(() => {
|
|
1495
|
-
if (!modelMenuOpen) return void 0;
|
|
1496
|
-
let cancelled = false;
|
|
1497
|
-
(async () => {
|
|
1498
|
-
const face = lookupSessionFace(ctx);
|
|
1499
|
-
if (face === void 0 || typeof face.modelCatalog !== "function") {
|
|
1500
|
-
setModelListState("error");
|
|
1501
|
-
setModelError(t("model.unavailable"));
|
|
1502
|
-
return;
|
|
1503
|
-
}
|
|
1504
|
-
const cached = catalogRef.current;
|
|
1505
|
-
if (cached.value !== null && Date.now() - cached.at < CATALOG_TTL_MS) {
|
|
1506
|
-
if (!cancelled) showModels(cached.value);
|
|
1507
|
-
return;
|
|
1508
|
-
}
|
|
1509
|
-
setModelListState("loading");
|
|
1510
|
-
try {
|
|
1511
|
-
const result = await face.modelCatalog();
|
|
1512
|
-
if (cancelled) return;
|
|
1513
|
-
if (!result?.ok) {
|
|
1514
|
-
setModelListState("error");
|
|
1515
|
-
setModelError(
|
|
1516
|
-
t("model.loadFailed", { error: result?.error?.message ?? result?.error?.code ?? "" })
|
|
1517
|
-
);
|
|
1518
|
-
return;
|
|
1519
|
-
}
|
|
1520
|
-
catalogRef.current = { value: result.value, at: Date.now() };
|
|
1521
|
-
showModels(result.value);
|
|
1522
|
-
} catch (error) {
|
|
1523
|
-
if (cancelled) return;
|
|
1524
|
-
setModelListState("error");
|
|
1525
|
-
setModelError(t("model.loadFailed", { error: describe(error) }));
|
|
1526
|
-
}
|
|
1527
|
-
})();
|
|
1528
|
-
return () => {
|
|
1529
|
-
cancelled = true;
|
|
1530
|
-
};
|
|
1531
|
-
}, [modelMenuOpen, ctx, t, showModels]);
|
|
1532
|
-
React.useEffect(() => {
|
|
1533
|
-
if (!modelMenuOpen) return void 0;
|
|
1534
|
-
const onPointerDown = (event) => {
|
|
1535
|
-
const wrap = modelWrapRef.current;
|
|
1536
|
-
if (wrap && event.target instanceof Node && wrap.contains(event.target)) return;
|
|
1537
|
-
setModelMenuOpen(false);
|
|
1538
|
-
};
|
|
1539
|
-
document.addEventListener("pointerdown", onPointerDown, true);
|
|
1540
|
-
return () => {
|
|
1541
|
-
document.removeEventListener("pointerdown", onPointerDown, true);
|
|
1542
|
-
};
|
|
1543
|
-
}, [modelMenuOpen]);
|
|
1544
|
-
const switchToModel = React.useCallback(
|
|
1545
|
-
async (model, effort) => {
|
|
1546
|
-
const face = lookupSessionFace(ctx);
|
|
1547
|
-
if (face === void 0 || typeof face.selectModel !== "function") {
|
|
1548
|
-
setModelError(t("model.unavailable"));
|
|
1549
|
-
return;
|
|
1550
|
-
}
|
|
1551
|
-
if (typeof sessionId !== "string" || sessionId === "") {
|
|
1552
|
-
setModelError(t("model.unavailable"));
|
|
1553
|
-
return;
|
|
1554
|
-
}
|
|
1555
|
-
setSwitchingModel(model.id);
|
|
1556
|
-
try {
|
|
1557
|
-
const result = await face.selectModel({
|
|
1558
|
-
sessionId,
|
|
1559
|
-
provider: catalogProvider ?? activeProvider,
|
|
1560
|
-
model: model.id,
|
|
1561
|
-
...typeof effort === "string" && effort !== "" ? { reasoningEffort: effort } : {}
|
|
1562
|
-
});
|
|
1563
|
-
if (!result?.ok) {
|
|
1564
|
-
setModelError(
|
|
1565
|
-
t("model.failed", { error: result?.error?.message ?? result?.error?.code ?? "" })
|
|
1566
|
-
);
|
|
1567
|
-
return;
|
|
1568
|
-
}
|
|
1569
|
-
setModelError(null);
|
|
1570
|
-
setModelMenuOpen(false);
|
|
1571
|
-
} catch (error) {
|
|
1572
|
-
console.error("[model-allowance] switching the model failed", { error });
|
|
1573
|
-
setModelError(t("model.failed", { error: describe(error) }));
|
|
1574
|
-
} finally {
|
|
1575
|
-
setSwitchingModel(null);
|
|
1576
|
-
}
|
|
1577
|
-
},
|
|
1578
|
-
[ctx, sessionId, activeProvider, catalogProvider, t]
|
|
1579
|
-
);
|
|
1580
|
-
const showEffortFlyout = React.useCallback((model, top) => {
|
|
1581
|
-
clearTimeout(hoverModelTimer.current);
|
|
1582
|
-
setHoverModel({ model, top });
|
|
1583
|
-
}, []);
|
|
1584
|
-
const scheduleEffortFlyoutClose = React.useCallback((id) => {
|
|
1585
|
-
clearTimeout(hoverModelTimer.current);
|
|
1586
|
-
hoverModelTimer.current = setTimeout(() => {
|
|
1587
|
-
setHoverModel((current) => current?.model?.id === id ? null : current);
|
|
1588
|
-
}, 150);
|
|
1589
|
-
}, []);
|
|
1590
|
-
const label = React.useMemo(() => {
|
|
2318
|
+
const markFor = (route) => markOf(entryOf(route), route);
|
|
2319
|
+
const sessionFace = lookupSessionFace(ctx);
|
|
2320
|
+
const canSwitch = typeof sessionId === "string" && sessionId !== "" && sessionFace !== void 0 && typeof sessionFace.selectModel === "function";
|
|
2321
|
+
const label = React6.useMemo(() => {
|
|
1591
2322
|
if (!provider) return "";
|
|
1592
2323
|
if (!view) return t("badge.loading");
|
|
1593
2324
|
if (view.status === "ready") {
|
|
@@ -1625,56 +2356,7 @@ function BalanceBadge(props) {
|
|
|
1625
2356
|
if (!provider) return null;
|
|
1626
2357
|
const currentStatus = providerStatus?.provider === activeProvider ? providerStatus : null;
|
|
1627
2358
|
const serviceState = statusDisplayState(currentStatus);
|
|
1628
|
-
|
|
1629
|
-
const MARK_GAP = 4;
|
|
1630
|
-
const MENU_SIZE = 26;
|
|
1631
|
-
const perMark = MARK_SIZE + MARK_GAP;
|
|
1632
|
-
let visibleCount = available.length;
|
|
1633
|
-
if (stripWidth > 0 && available.length * perMark - MARK_GAP > stripWidth) {
|
|
1634
|
-
visibleCount = Math.max(1, Math.floor((stripWidth - MENU_SIZE - MARK_GAP) / perMark));
|
|
1635
|
-
visibleCount = Math.min(visibleCount, available.length - 1);
|
|
1636
|
-
}
|
|
1637
|
-
let shown = available.slice(0, visibleCount);
|
|
1638
|
-
let overflow = available.slice(visibleCount);
|
|
1639
|
-
const activeIndex = overflow.findIndex((entry) => entry.route === activeProvider);
|
|
1640
|
-
if (activeIndex >= 0 && shown.length > 0) {
|
|
1641
|
-
const displaced = shown[shown.length - 1];
|
|
1642
|
-
shown = [...shown.slice(0, -1), overflow[activeIndex]];
|
|
1643
|
-
overflow = [...overflow.slice(0, activeIndex), displaced, ...overflow.slice(activeIndex + 1)];
|
|
1644
|
-
}
|
|
1645
|
-
const markButton = (entry) => {
|
|
1646
|
-
const mark = markFor(entry.route);
|
|
1647
|
-
const name = nameOf(entry.route);
|
|
1648
|
-
return (0, import_react3.createElement)(
|
|
1649
|
-
"button",
|
|
1650
|
-
{
|
|
1651
|
-
type: "button",
|
|
1652
|
-
key: entry.route,
|
|
1653
|
-
role: "tab",
|
|
1654
|
-
className: "dsh-model-allowance-tab",
|
|
1655
|
-
"data-active": entry.route === activeProvider ? "true" : "false",
|
|
1656
|
-
"aria-selected": entry.route === activeProvider ? "true" : "false",
|
|
1657
|
-
"aria-label": name,
|
|
1658
|
-
title: name,
|
|
1659
|
-
style: { "--provider-mark": mark.color },
|
|
1660
|
-
onClick: () => {
|
|
1661
|
-
setPicked(entry.route);
|
|
1662
|
-
setMenuOpen(false);
|
|
1663
|
-
}
|
|
1664
|
-
},
|
|
1665
|
-
providerIcon(entry.route, 14, mark)
|
|
1666
|
-
);
|
|
1667
|
-
};
|
|
1668
|
-
const onTabKeyDown = (event) => {
|
|
1669
|
-
if (!["ArrowLeft", "ArrowRight", "Home", "End"].includes(event.key)) return;
|
|
1670
|
-
const tabs = [...event.currentTarget.querySelectorAll('[role="tab"]')];
|
|
1671
|
-
if (tabs.length === 0) return;
|
|
1672
|
-
const index = tabs.indexOf(document.activeElement);
|
|
1673
|
-
const next = event.key === "Home" ? 0 : event.key === "End" ? tabs.length - 1 : (index + (event.key === "ArrowRight" ? 1 : -1) + tabs.length) % tabs.length;
|
|
1674
|
-
event.preventDefault();
|
|
1675
|
-
tabs[next]?.focus();
|
|
1676
|
-
};
|
|
1677
|
-
return (0, import_react3.createElement)(
|
|
2359
|
+
return (0, import_react7.createElement)(
|
|
1678
2360
|
"div",
|
|
1679
2361
|
{
|
|
1680
2362
|
ref: rootRef,
|
|
@@ -1684,8 +2366,8 @@ function BalanceBadge(props) {
|
|
|
1684
2366
|
},
|
|
1685
2367
|
// Component-local styles: React removes them with the component, and
|
|
1686
2368
|
// every colour comes from a theme token so light and dark both follow.
|
|
1687
|
-
(0,
|
|
1688
|
-
(0,
|
|
2369
|
+
(0, import_react7.createElement)("style", { key: "styles" }, STYLES_JOINED),
|
|
2370
|
+
(0, import_react7.createElement)(
|
|
1689
2371
|
"button",
|
|
1690
2372
|
{
|
|
1691
2373
|
type: "button",
|
|
@@ -1695,12 +2377,12 @@ function BalanceBadge(props) {
|
|
|
1695
2377
|
"aria-controls": open ? "dsh-model-allowance-panel" : void 0,
|
|
1696
2378
|
onClick: () => setOpen((value) => !value)
|
|
1697
2379
|
},
|
|
1698
|
-
(0,
|
|
1699
|
-
(0,
|
|
2380
|
+
(0, import_react7.createElement)("span", { className: "dsh-model-allowance-dot", "aria-hidden": true }),
|
|
2381
|
+
(0, import_react7.createElement)("span", { className: "dsh-model-allowance-label" }, label),
|
|
1700
2382
|
// How far the number moved since the last reading, for a few seconds
|
|
1701
2383
|
// after it lands. The arrow follows the number shown beside it: down
|
|
1702
2384
|
// means the balance fell.
|
|
1703
|
-
showingDifference ? (0,
|
|
2385
|
+
showingDifference ? (0, import_react7.createElement)(
|
|
1704
2386
|
"span",
|
|
1705
2387
|
{
|
|
1706
2388
|
className: "dsh-model-allowance-delta",
|
|
@@ -1710,456 +2392,31 @@ function BalanceBadge(props) {
|
|
|
1710
2392
|
`${view.consumption.delta < 0 ? "\u2193" : "\u2191"}${formatDelta(view.consumption)}`
|
|
1711
2393
|
) : null
|
|
1712
2394
|
),
|
|
1713
|
-
open ? (0,
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
...shown.map(markButton),
|
|
1739
|
-
overflow.length > 0 ? (0, import_react3.createElement)(
|
|
1740
|
-
"button",
|
|
1741
|
-
{
|
|
1742
|
-
type: "button",
|
|
1743
|
-
className: "dsh-model-allowance-more",
|
|
1744
|
-
"aria-haspopup": "menu",
|
|
1745
|
-
"aria-expanded": menuOpen ? "true" : "false",
|
|
1746
|
-
"aria-label": t("detail.moreProviders"),
|
|
1747
|
-
title: t("detail.moreProviders"),
|
|
1748
|
-
onClick: () => setMenuOpen((value) => !value)
|
|
1749
|
-
},
|
|
1750
|
-
"\u22EF"
|
|
1751
|
-
) : null
|
|
1752
|
-
),
|
|
1753
|
-
menuOpen && overflow.length > 0 ? (0, import_react3.createElement)(
|
|
1754
|
-
"div",
|
|
1755
|
-
{ className: "dsh-model-allowance-menu", role: "menu" },
|
|
1756
|
-
...overflow.map(
|
|
1757
|
-
(entry) => (0, import_react3.createElement)(
|
|
1758
|
-
"button",
|
|
1759
|
-
{
|
|
1760
|
-
type: "button",
|
|
1761
|
-
key: entry.route,
|
|
1762
|
-
role: "menuitem",
|
|
1763
|
-
className: "dsh-model-allowance-menu-item",
|
|
1764
|
-
onClick: () => {
|
|
1765
|
-
setPicked(entry.route);
|
|
1766
|
-
setMenuOpen(false);
|
|
1767
|
-
}
|
|
1768
|
-
},
|
|
1769
|
-
(0, import_react3.createElement)(
|
|
1770
|
-
"span",
|
|
1771
|
-
{
|
|
1772
|
-
className: "dsh-model-allowance-menu-mark",
|
|
1773
|
-
style: { "--provider-mark": markFor(entry.route).color }
|
|
1774
|
-
},
|
|
1775
|
-
providerIcon(entry.route, 11, markFor(entry.route))
|
|
1776
|
-
),
|
|
1777
|
-
(0, import_react3.createElement)("span", null, nameOf(entry.route))
|
|
1778
|
-
)
|
|
1779
|
-
)
|
|
1780
|
-
) : null
|
|
1781
|
-
) : (0, import_react3.createElement)(
|
|
1782
|
-
"div",
|
|
1783
|
-
{ className: "dsh-model-allowance-row" },
|
|
1784
|
-
(0, import_react3.createElement)("span", null, t("detail.provider")),
|
|
1785
|
-
(0, import_react3.createElement)("span", null, nameOf(activeProvider))
|
|
1786
|
-
),
|
|
1787
|
-
view?.kind === "amount" && typeof view.amount === "number" ? (0, import_react3.createElement)(
|
|
1788
|
-
"div",
|
|
1789
|
-
{ className: "dsh-model-allowance-row" },
|
|
1790
|
-
(0, import_react3.createElement)("span", null, t("detail.amount")),
|
|
1791
|
-
(0, import_react3.createElement)("span", null, formatAmount(view.amount, view.currency))
|
|
1792
|
-
) : null,
|
|
1793
|
-
...Array.isArray(view?.windows) && view.windows.length > 0 ? view.windows.map((window, index) => {
|
|
1794
|
-
const consumed = windowUsedPercent(window);
|
|
1795
|
-
const percent = consumed === void 0 ? void 0 : Math.max(0, Math.round(consumed));
|
|
1796
|
-
const filled = consumed === void 0 ? 0 : Math.min(100, Math.max(0, consumed));
|
|
1797
|
-
const usage = windowUsage(window, t);
|
|
1798
|
-
return (0, import_react3.createElement)(
|
|
1799
|
-
"div",
|
|
1800
|
-
{
|
|
1801
|
-
className: "dsh-model-allowance-window",
|
|
1802
|
-
key: `w-${String(index)}`,
|
|
1803
|
-
// The first block needs no divider: the switcher above
|
|
1804
|
-
// it already ends in one, and a bare provider row does
|
|
1805
|
-
// not deserve a line either. Only the boundaries
|
|
1806
|
-
// *between* windows are drawn.
|
|
1807
|
-
"data-first": index === 0 ? "true" : void 0
|
|
1808
|
-
},
|
|
1809
|
-
(0, import_react3.createElement)(
|
|
1810
|
-
"div",
|
|
1811
|
-
{ className: "dsh-model-allowance-window-head" },
|
|
1812
|
-
(0, import_react3.createElement)(
|
|
1813
|
-
"span",
|
|
1814
|
-
{ className: "dsh-model-allowance-window-title" },
|
|
1815
|
-
windowTitle(window, t)
|
|
1816
|
-
),
|
|
1817
|
-
// Countable units sit beside the title; a plan that
|
|
1818
|
-
// reports only a percentage has none to show.
|
|
1819
|
-
usage === void 0 ? null : (0, import_react3.createElement)("span", { className: "dsh-model-allowance-usage" }, usage)
|
|
1820
|
-
),
|
|
1821
|
-
percent === void 0 ? null : (0, import_react3.createElement)(
|
|
1822
|
-
"div",
|
|
1823
|
-
{ className: "dsh-model-allowance-percent" },
|
|
1824
|
-
t("window.usedPercent", { percent })
|
|
1825
|
-
),
|
|
1826
|
-
percent === void 0 ? null : (0, import_react3.createElement)(
|
|
1827
|
-
"div",
|
|
1828
|
-
{
|
|
1829
|
-
className: "dsh-model-allowance-bar",
|
|
1830
|
-
role: "progressbar",
|
|
1831
|
-
"aria-valuenow": percent,
|
|
1832
|
-
"aria-valuemin": 0,
|
|
1833
|
-
"aria-valuemax": 100,
|
|
1834
|
-
"aria-valuetext": t("window.usedPercent", { percent })
|
|
1835
|
-
},
|
|
1836
|
-
(0, import_react3.createElement)("div", {
|
|
1837
|
-
className: "dsh-model-allowance-bar-fill",
|
|
1838
|
-
"data-tone": barTone(percent),
|
|
1839
|
-
style: { width: `${String(filled)}%` }
|
|
1840
|
-
})
|
|
1841
|
-
),
|
|
1842
|
-
// A window with zero usage has not started its rolling timer
|
|
1843
|
-
// yet, so the countdown would be misleading. Hide it until
|
|
1844
|
-
// consumption begins.
|
|
1845
|
-
typeof window.resetAt === "number" && (typeof window.remainingPercent !== "number" || window.remainingPercent < 100) ? (0, import_react3.createElement)(
|
|
1846
|
-
"div",
|
|
1847
|
-
{ className: "dsh-model-allowance-foot" },
|
|
1848
|
-
(0, import_react3.createElement)(
|
|
1849
|
-
"span",
|
|
1850
|
-
null,
|
|
1851
|
-
t("window.resetIn", {
|
|
1852
|
-
duration: formatCountdown(window.resetAt - now)
|
|
1853
|
-
})
|
|
1854
|
-
),
|
|
1855
|
-
(0, import_react3.createElement)("span", null, formatResetAt(window.resetAt))
|
|
1856
|
-
) : null
|
|
1857
|
-
);
|
|
1858
|
-
}) : [],
|
|
1859
|
-
// A single scalar reading has no windows to break down.
|
|
1860
|
-
!Array.isArray(view?.windows) && typeof view?.remainingMs === "number" ? (0, import_react3.createElement)(
|
|
1861
|
-
"div",
|
|
1862
|
-
{ className: "dsh-model-allowance-row" },
|
|
1863
|
-
(0, import_react3.createElement)("span", null, t("detail.remaining")),
|
|
1864
|
-
(0, import_react3.createElement)("span", null, formatDuration(view.remainingMs, t))
|
|
1865
|
-
) : null,
|
|
1866
|
-
!Array.isArray(view?.windows) && typeof view?.remaining === "number" ? (0, import_react3.createElement)(
|
|
1867
|
-
"div",
|
|
1868
|
-
{ className: "dsh-model-allowance-row" },
|
|
1869
|
-
(0, import_react3.createElement)("span", null, t("detail.remaining")),
|
|
1870
|
-
(0, import_react3.createElement)("span", null, String(view.remaining))
|
|
1871
|
-
) : null,
|
|
1872
|
-
!Array.isArray(view?.windows) && typeof view?.total === "number" ? (0, import_react3.createElement)(
|
|
1873
|
-
"div",
|
|
1874
|
-
{ className: "dsh-model-allowance-row" },
|
|
1875
|
-
(0, import_react3.createElement)("span", null, t("detail.total")),
|
|
1876
|
-
(0, import_react3.createElement)("span", null, String(view.total))
|
|
1877
|
-
) : null,
|
|
1878
|
-
view?.status === "failed" ? (0, import_react3.createElement)(
|
|
1879
|
-
"div",
|
|
1880
|
-
{ className: "dsh-model-allowance-error" },
|
|
1881
|
-
t("detail.error"),
|
|
1882
|
-
// The Host reports why a reading failed; showing it is what
|
|
1883
|
-
// turns "it does not work" into something actionable.
|
|
1884
|
-
view.error ? (0, import_react3.createElement)("div", { className: "dsh-model-allowance-reason" }, view.error) : null
|
|
1885
|
-
) : null,
|
|
1886
|
-
view?.status === "unsupported" ? (0, import_react3.createElement)(
|
|
1887
|
-
"div",
|
|
1888
|
-
{ className: "dsh-model-allowance-reason" },
|
|
1889
|
-
t("badge.unsupportedWithName", { name: nameOf(activeProvider) })
|
|
1890
|
-
) : null,
|
|
1891
|
-
view?.status === "unconfigured" ? (0, import_react3.createElement)("div", { className: "dsh-model-allowance-reason" }, t("badge.unconfigured")) : null,
|
|
1892
|
-
// A vendor that prices by the wall clock gets its phase and
|
|
1893
|
-
// countdown here, above the footer.
|
|
1894
|
-
schedule && schedule.provider === activeProvider ? scheduleView(schedule, now, t) : null,
|
|
1895
|
-
(0, import_react3.createElement)(
|
|
1896
|
-
"div",
|
|
1897
|
-
{ className: "dsh-model-allowance-actions" },
|
|
1898
|
-
// The platform status sits at the left edge of the footer, on
|
|
1899
|
-
// the same line as the reading time: the card gains no extra
|
|
1900
|
-
// row, and the state and the source page stay together.
|
|
1901
|
-
(0, import_react3.createElement)(
|
|
1902
|
-
"span",
|
|
1903
|
-
{ className: "dsh-model-allowance-status-wrap" },
|
|
1904
|
-
(0, import_react3.createElement)(
|
|
1905
|
-
currentStatus?.url ? "a" : "span",
|
|
1906
|
-
{
|
|
1907
|
-
className: "dsh-model-allowance-status",
|
|
1908
|
-
"data-state": serviceState,
|
|
1909
|
-
...currentStatus?.url ? {
|
|
1910
|
-
href: currentStatus.url,
|
|
1911
|
-
target: "_blank",
|
|
1912
|
-
rel: "noreferrer noopener"
|
|
1913
|
-
} : {}
|
|
1914
|
-
},
|
|
1915
|
-
(0, import_react3.createElement)("span", {
|
|
1916
|
-
className: "dsh-model-allowance-status-dot",
|
|
1917
|
-
"aria-hidden": true
|
|
1918
|
-
}),
|
|
1919
|
-
(0, import_react3.createElement)(
|
|
1920
|
-
"span",
|
|
1921
|
-
{ className: "dsh-model-allowance-status-label" },
|
|
1922
|
-
statusLabel(serviceState, t)
|
|
1923
|
-
),
|
|
1924
|
-
...currentStatus?.url ? [
|
|
1925
|
-
(0, import_react3.createElement)(
|
|
1926
|
-
"span",
|
|
1927
|
-
{
|
|
1928
|
-
className: "dsh-model-allowance-status-arrow",
|
|
1929
|
-
"aria-hidden": true
|
|
1930
|
-
},
|
|
1931
|
-
"\u2197"
|
|
1932
|
-
)
|
|
1933
|
-
] : []
|
|
1934
|
-
),
|
|
1935
|
-
// The reason is a warning mark rather than another line:
|
|
1936
|
-
// the footer stays one row, and the detail is one hover
|
|
1937
|
-
// — or one keyboard focus — away.
|
|
1938
|
-
currentStatus?.summary ? (0, import_react3.createElement)(
|
|
1939
|
-
"span",
|
|
1940
|
-
{
|
|
1941
|
-
className: "dsh-model-allowance-status-help",
|
|
1942
|
-
tabIndex: 0,
|
|
1943
|
-
role: "note",
|
|
1944
|
-
"aria-label": currentStatus.summary
|
|
1945
|
-
},
|
|
1946
|
-
(0, import_react3.createElement)(
|
|
1947
|
-
"span",
|
|
1948
|
-
{
|
|
1949
|
-
"aria-hidden": true
|
|
1950
|
-
},
|
|
1951
|
-
"!"
|
|
1952
|
-
),
|
|
1953
|
-
(0, import_react3.createElement)(
|
|
1954
|
-
"span",
|
|
1955
|
-
{ className: "dsh-model-allowance-status-tip", role: "tooltip" },
|
|
1956
|
-
currentStatus.summary
|
|
1957
|
-
)
|
|
1958
|
-
) : null
|
|
1959
|
-
),
|
|
1960
|
-
view?.updatedAt ? (0, import_react3.createElement)(
|
|
1961
|
-
"span",
|
|
1962
|
-
{ className: "dsh-model-allowance-updated" },
|
|
1963
|
-
t("detail.updatedAt", { time: formatClock(view.updatedAt) })
|
|
1964
|
-
) : null,
|
|
1965
|
-
(0, import_react3.createElement)(
|
|
1966
|
-
"button",
|
|
1967
|
-
{
|
|
1968
|
-
type: "button",
|
|
1969
|
-
className: "dsh-model-allowance-icon-button",
|
|
1970
|
-
onClick: refresh,
|
|
1971
|
-
disabled: refreshing,
|
|
1972
|
-
title: refreshing ? t("detail.refreshing") : t("detail.refresh"),
|
|
1973
|
-
"aria-label": refreshing ? t("detail.refreshing") : t("detail.refresh")
|
|
1974
|
-
},
|
|
1975
|
-
refreshGlyph(16)
|
|
1976
|
-
),
|
|
1977
|
-
view?.consoleUrl ? (0, import_react3.createElement)(
|
|
1978
|
-
"a",
|
|
1979
|
-
{
|
|
1980
|
-
className: "dsh-model-allowance-icon-button",
|
|
1981
|
-
href: view.consoleUrl,
|
|
1982
|
-
target: "_blank",
|
|
1983
|
-
rel: "noreferrer noopener",
|
|
1984
|
-
title: t("detail.console"),
|
|
1985
|
-
"aria-label": t("detail.console")
|
|
1986
|
-
},
|
|
1987
|
-
consoleGlyph(16)
|
|
1988
|
-
) : null,
|
|
1989
|
-
// The switch to another model of this provider. It sits to the
|
|
1990
|
-
// right of the console link, which is the last thing the footer
|
|
1991
|
-
// offered before, so the two never trade places.
|
|
1992
|
-
canSwitch ? (0, import_react3.createElement)(
|
|
1993
|
-
"span",
|
|
1994
|
-
{ ref: modelWrapRef, className: "dsh-model-allowance-model-wrap" },
|
|
1995
|
-
(0, import_react3.createElement)(
|
|
1996
|
-
"button",
|
|
1997
|
-
{
|
|
1998
|
-
type: "button",
|
|
1999
|
-
className: "dsh-model-allowance-icon-button",
|
|
2000
|
-
"aria-haspopup": "menu",
|
|
2001
|
-
"aria-expanded": modelMenuOpen ? "true" : "false",
|
|
2002
|
-
// The vendor in use paints the glyph in its own
|
|
2003
|
-
// colour, so the button says which vendor the card is
|
|
2004
|
-
// on instead of the strip having to say it twice.
|
|
2005
|
-
"data-in-use": inUse ? "true" : "false",
|
|
2006
|
-
style: { "--provider-mark": markFor(activeProvider).color },
|
|
2007
|
-
title: switchLabel,
|
|
2008
|
-
"aria-label": switchLabel,
|
|
2009
|
-
onClick: () => {
|
|
2010
|
-
setModelError(null);
|
|
2011
|
-
clearTimeout(hoverModelTimer.current);
|
|
2012
|
-
setHoverModel(null);
|
|
2013
|
-
setModelMenuOpen((value) => !value);
|
|
2014
|
-
}
|
|
2015
|
-
},
|
|
2016
|
-
modelGlyph(16)
|
|
2017
|
-
),
|
|
2018
|
-
modelMenuOpen ? (0, import_react3.createElement)(
|
|
2019
|
-
"div",
|
|
2020
|
-
{
|
|
2021
|
-
className: "dsh-model-allowance-model-menu",
|
|
2022
|
-
role: "menu",
|
|
2023
|
-
"aria-label": t("model.title")
|
|
2024
|
-
},
|
|
2025
|
-
shownModelListState === "loading" ? (0, import_react3.createElement)(
|
|
2026
|
-
"div",
|
|
2027
|
-
{ className: "dsh-model-allowance-model-message" },
|
|
2028
|
-
t("model.loading")
|
|
2029
|
-
) : null,
|
|
2030
|
-
shownModelListState === "empty" ? (0, import_react3.createElement)(
|
|
2031
|
-
"div",
|
|
2032
|
-
{ className: "dsh-model-allowance-model-message" },
|
|
2033
|
-
t("model.empty")
|
|
2034
|
-
) : null,
|
|
2035
|
-
shownModelListState === "error" ? (0, import_react3.createElement)(
|
|
2036
|
-
"div",
|
|
2037
|
-
{
|
|
2038
|
-
className: "dsh-model-allowance-model-message",
|
|
2039
|
-
"data-tone": "error"
|
|
2040
|
-
},
|
|
2041
|
-
modelError ?? t("model.unavailable")
|
|
2042
|
-
) : null,
|
|
2043
|
-
...shownModelList.map((model) => {
|
|
2044
|
-
const isCurrent = model.id === currentModel;
|
|
2045
|
-
const efforts = effortChoices(model);
|
|
2046
|
-
const defaultEffortId = efforts?.find((effort) => effort.isDefault)?.id;
|
|
2047
|
-
return (0, import_react3.createElement)(
|
|
2048
|
-
"button",
|
|
2049
|
-
{
|
|
2050
|
-
type: "button",
|
|
2051
|
-
key: model.id,
|
|
2052
|
-
role: "menuitemradio",
|
|
2053
|
-
"aria-checked": isCurrent ? "true" : "false",
|
|
2054
|
-
"data-current": isCurrent ? "true" : "false",
|
|
2055
|
-
className: "dsh-model-allowance-model-item",
|
|
2056
|
-
disabled: switchingModel !== null,
|
|
2057
|
-
title: model.id,
|
|
2058
|
-
...efforts === null ? {} : { "aria-haspopup": "menu" },
|
|
2059
|
-
onClick: () => {
|
|
2060
|
-
void switchToModel(model, defaultEffortId);
|
|
2061
|
-
},
|
|
2062
|
-
...efforts === null ? {} : {
|
|
2063
|
-
onMouseEnter: (event) => {
|
|
2064
|
-
const wrap = modelWrapRef.current;
|
|
2065
|
-
if (!wrap) return;
|
|
2066
|
-
const top = event.currentTarget.getBoundingClientRect().top - wrap.getBoundingClientRect().top;
|
|
2067
|
-
showEffortFlyout(model, top);
|
|
2068
|
-
},
|
|
2069
|
-
onMouseLeave: () => {
|
|
2070
|
-
scheduleEffortFlyoutClose(model.id);
|
|
2071
|
-
}
|
|
2072
|
-
}
|
|
2073
|
-
},
|
|
2074
|
-
(0, import_react3.createElement)(
|
|
2075
|
-
"span",
|
|
2076
|
-
{ className: "dsh-model-allowance-model-name" },
|
|
2077
|
-
model.name ?? model.id
|
|
2078
|
-
),
|
|
2079
|
-
(0, import_react3.createElement)(
|
|
2080
|
-
"span",
|
|
2081
|
-
{ className: "dsh-model-allowance-model-side" },
|
|
2082
|
-
switchingModel === model.id ? (0, import_react3.createElement)(
|
|
2083
|
-
"span",
|
|
2084
|
-
{ className: "dsh-model-allowance-model-note" },
|
|
2085
|
-
t("model.switching")
|
|
2086
|
-
) : isCurrent ? (0, import_react3.createElement)(
|
|
2087
|
-
"span",
|
|
2088
|
-
{ className: "dsh-model-allowance-model-note" },
|
|
2089
|
-
t("model.current")
|
|
2090
|
-
) : null,
|
|
2091
|
-
efforts === null ? null : (0, import_react3.createElement)(
|
|
2092
|
-
"span",
|
|
2093
|
-
{
|
|
2094
|
-
className: "dsh-model-allowance-model-arrow",
|
|
2095
|
-
"aria-hidden": true
|
|
2096
|
-
},
|
|
2097
|
-
"\u203A"
|
|
2098
|
-
)
|
|
2099
|
-
)
|
|
2100
|
-
);
|
|
2101
|
-
}),
|
|
2102
|
-
// A failed switch keeps the list open and says why.
|
|
2103
|
-
modelError && shownModelListState !== "error" ? (0, import_react3.createElement)(
|
|
2104
|
-
"div",
|
|
2105
|
-
{
|
|
2106
|
-
className: "dsh-model-allowance-model-message",
|
|
2107
|
-
"data-tone": "error"
|
|
2108
|
-
},
|
|
2109
|
-
modelError
|
|
2110
|
-
) : null
|
|
2111
|
-
) : null,
|
|
2112
|
-
// The effort flyout is a sibling of the list, not a
|
|
2113
|
-
// child: the list scrolls, and a nested panel would be
|
|
2114
|
-
// clipped by it. Sharing the hover with the row keeps
|
|
2115
|
-
// it open while the pointer crosses over.
|
|
2116
|
-
modelMenuOpen && hoverModel !== null && shownModelList.includes(hoverModel.model) ? (0, import_react3.createElement)(
|
|
2117
|
-
"div",
|
|
2118
|
-
{
|
|
2119
|
-
className: "dsh-model-allowance-effort-menu",
|
|
2120
|
-
role: "menu",
|
|
2121
|
-
"aria-label": t("model.title"),
|
|
2122
|
-
style: { top: `${hoverModel.top}px` },
|
|
2123
|
-
onMouseEnter: () => {
|
|
2124
|
-
clearTimeout(hoverModelTimer.current);
|
|
2125
|
-
},
|
|
2126
|
-
onMouseLeave: () => {
|
|
2127
|
-
scheduleEffortFlyoutClose(hoverModel.model.id);
|
|
2128
|
-
}
|
|
2129
|
-
},
|
|
2130
|
-
...effortChoices(hoverModel.model).map((effort) => {
|
|
2131
|
-
const isCurrentEffort = hoverModel.model.id === currentModel && effort.id === selectedEffort;
|
|
2132
|
-
return (0, import_react3.createElement)(
|
|
2133
|
-
"button",
|
|
2134
|
-
{
|
|
2135
|
-
type: "button",
|
|
2136
|
-
key: effort.id ?? "provider-default",
|
|
2137
|
-
role: "menuitemradio",
|
|
2138
|
-
"aria-checked": isCurrentEffort ? "true" : "false",
|
|
2139
|
-
"data-current": isCurrentEffort ? "true" : "false",
|
|
2140
|
-
"data-default": effort.isDefault ? "true" : "false",
|
|
2141
|
-
className: "dsh-model-allowance-effort-item",
|
|
2142
|
-
disabled: switchingModel !== null,
|
|
2143
|
-
onClick: () => {
|
|
2144
|
-
void switchToModel(hoverModel.model, effort.id);
|
|
2145
|
-
}
|
|
2146
|
-
},
|
|
2147
|
-
(0, import_react3.createElement)(
|
|
2148
|
-
"span",
|
|
2149
|
-
{ className: "dsh-model-allowance-model-name" },
|
|
2150
|
-
effort.providerDefault ? t("model.effortDefault") : effort.name
|
|
2151
|
-
),
|
|
2152
|
-
effort.isDefault && !isCurrentEffort ? (0, import_react3.createElement)(
|
|
2153
|
-
"span",
|
|
2154
|
-
{ className: "dsh-model-allowance-model-note" },
|
|
2155
|
-
t("model.effortDefault")
|
|
2156
|
-
) : null
|
|
2157
|
-
);
|
|
2158
|
-
})
|
|
2159
|
-
) : null
|
|
2160
|
-
) : null
|
|
2161
|
-
)
|
|
2162
|
-
) : null
|
|
2395
|
+
open ? (0, import_react7.createElement)(BalancePanel, {
|
|
2396
|
+
t,
|
|
2397
|
+
now,
|
|
2398
|
+
view,
|
|
2399
|
+
activeProvider,
|
|
2400
|
+
available,
|
|
2401
|
+
schedule,
|
|
2402
|
+
currentStatus,
|
|
2403
|
+
serviceState,
|
|
2404
|
+
refresh,
|
|
2405
|
+
refreshing,
|
|
2406
|
+
canSwitch,
|
|
2407
|
+
inUse,
|
|
2408
|
+
switchLabel,
|
|
2409
|
+
selectedEffort,
|
|
2410
|
+
setPicked,
|
|
2411
|
+
nameOf,
|
|
2412
|
+
markFor,
|
|
2413
|
+
catalog,
|
|
2414
|
+
menuOpen,
|
|
2415
|
+
setMenuOpen,
|
|
2416
|
+
stripWidth,
|
|
2417
|
+
setStripWidth,
|
|
2418
|
+
stripRef
|
|
2419
|
+
}) : null
|
|
2163
2420
|
);
|
|
2164
2421
|
}
|
|
2165
2422
|
|
|
@@ -2255,7 +2512,9 @@ function createBalanceContribution() {
|
|
|
2255
2512
|
configured: z.boolean(),
|
|
2256
2513
|
name: z.object({ zh: z.string().optional(), en: z.string().optional() }).optional(),
|
|
2257
2514
|
color: z.string().optional(),
|
|
2258
|
-
iconHint: z.string().optional()
|
|
2515
|
+
iconHint: z.string().optional(),
|
|
2516
|
+
aliases: z.array(z.string()).optional(),
|
|
2517
|
+
modelRoutes: z.array(z.string()).optional()
|
|
2259
2518
|
})
|
|
2260
2519
|
);
|
|
2261
2520
|
return {
|
|
@@ -2399,7 +2658,7 @@ function apply(ctx) {
|
|
|
2399
2658
|
id: "model-allowance",
|
|
2400
2659
|
order: 10
|
|
2401
2660
|
},
|
|
2402
|
-
(props) => (0,
|
|
2661
|
+
(props) => (0, import_react8.createElement)(BalanceBadge, { ...props, ctx, t })
|
|
2403
2662
|
)
|
|
2404
2663
|
);
|
|
2405
2664
|
}
|