@goodwidget/ai-credits-widget 0.1.8 → 0.1.10

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.
@@ -7,7 +7,7 @@ import {
7
7
  buildQuoteAmounts,
8
8
  buildSetOperatorPayload,
9
9
  totalCreditUsdFromProfile
10
- } from "../chunk-635NKGPL.js";
10
+ } from "../chunk-3QY3YZDH.js";
11
11
 
12
12
  // src/mocked/AiCreditsMockWidget.tsx
13
13
  import { useMemo } from "react";
package/dist/register.cjs CHANGED
@@ -3669,22 +3669,29 @@ var init_useCopyFeedback = __esm({
3669
3669
  });
3670
3670
 
3671
3671
  // src/components/buy/GenerateSignerKeyPanel.tsx
3672
- function NumberedStep({ index, title }) {
3673
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_ui5.XStack, { gap: "$2", alignItems: "center", children: [
3674
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3675
- import_ui5.YStack,
3676
- {
3677
- width: 24,
3678
- height: 24,
3679
- borderRadius: "$full",
3680
- backgroundColor: "$backgroundSurface",
3681
- alignItems: "center",
3682
- justifyContent: "center",
3683
- flexShrink: 0,
3684
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Text, { fontSize: "$1", fontWeight: "700", children: index })
3685
- }
3686
- ),
3687
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Text, { fontSize: "$3", fontWeight: "700", children: title })
3672
+ function NumberedStep({
3673
+ index,
3674
+ title,
3675
+ note
3676
+ }) {
3677
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_ui5.YStack, { gap: "$1", children: [
3678
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_ui5.XStack, { gap: "$2", alignItems: "center", children: [
3679
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3680
+ import_ui5.YStack,
3681
+ {
3682
+ width: 24,
3683
+ height: 24,
3684
+ borderRadius: "$full",
3685
+ backgroundColor: "$backgroundSurface",
3686
+ alignItems: "center",
3687
+ justifyContent: "center",
3688
+ flexShrink: 0,
3689
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Text, { fontSize: "$1", fontWeight: "700", children: index })
3690
+ }
3691
+ ),
3692
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Text, { fontSize: "$3", fontWeight: "700", children: title })
3693
+ ] }),
3694
+ note && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Text, { marginLeft: 32, fontSize: "$2", color: "$warning", fontStyle: "italic", lineHeight: "$3", children: note })
3688
3695
  ] });
3689
3696
  }
3690
3697
  function GenerateSignerKeyPanel({
@@ -3718,11 +3725,18 @@ function GenerateSignerKeyPanel({
3718
3725
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_ui5.YStack, { gap: "$2", children: [
3719
3726
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(NumberedStep, { index: 1, title: "Open Antseed Desktop" }),
3720
3727
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(NumberedStep, { index: 2, title: "Go to Profile \u2192 Signer" }),
3721
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(NumberedStep, { index: 3, title: "Tap \u2191, paste your Signer Private Key, and save" })
3728
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3729
+ NumberedStep,
3730
+ {
3731
+ index: 3,
3732
+ title: "Back up your existing Signer Key",
3733
+ note: "\u26A0\uFE0F Tap \u2193 to back up your existing signer key. Importing a new signer key will replace it."
3734
+ }
3735
+ ),
3736
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(NumberedStep, { index: 4, title: "Tap \u2191 to paste your Signer Key, then save." })
3722
3737
  ] }),
3723
3738
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AntseedSignerRow, { mode: "generate", showCaption: false }),
3724
3739
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AiCreditsStatusNotice, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Text, { fontSize: "$2", tone: "soft", lineHeight: "$3", children: "The address you see when you paste your private key is the public address used for your AI credits." }) }),
3725
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AiCreditsStatusNotice, { borderColor: "$warning", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Text, { color: "$warning", fontSize: "$2", lineHeight: "$3", children: "Back up any existing AntSeed signer key before importing this one. Importing replaces the signer used by your AntSeed account." }) }),
3726
3740
  onOpenApiSetup && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_ui5.XStack, { gap: "$2", alignItems: "center", children: [
3727
3741
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Icon, { name: "settings", size: "xs", color: "muted" }),
3728
3742
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_ui5.Text, { fontSize: "$2", tone: "soft", flex: 1, lineHeight: "$3", children: [
@@ -4308,14 +4322,43 @@ var init_constants = __esm({
4308
4322
  });
4309
4323
 
4310
4324
  // src/components/manage/CreditsManagementCard.tsx
4311
- function StatCell({ label, children }) {
4312
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.Card, { raised: true, borderWidth: 0, flexGrow: 1, flexBasis: 0, children: [
4313
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { fontSize: "$1", tone: "soft", children: label }),
4314
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.YStack, { justifyContent: "center", children })
4315
- ] });
4325
+ function StatCell({
4326
+ label,
4327
+ icon: Glyph,
4328
+ children
4329
+ }) {
4330
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
4331
+ import_ui9.Card,
4332
+ {
4333
+ raised: true,
4334
+ borderWidth: 0,
4335
+ flexGrow: 1,
4336
+ flexBasis: 0,
4337
+ padding: "$3",
4338
+ gap: "$1",
4339
+ children: [
4340
+ Glyph ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
4341
+ import_ui9.XStack,
4342
+ {
4343
+ width: 28,
4344
+ height: 28,
4345
+ borderRadius: "$2",
4346
+ backgroundColor: "$background",
4347
+ alignItems: "center",
4348
+ justifyContent: "center",
4349
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Glyph, { size: 16, color: "$colorSoft" })
4350
+ }
4351
+ ) : null,
4352
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.YStack, { children: [
4353
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { fontSize: "$1", tone: "soft", children: label }),
4354
+ children
4355
+ ] })
4356
+ ]
4357
+ }
4358
+ );
4316
4359
  }
4317
4360
  function StatRow({ children }) {
4318
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.XStack, { gap: "$2", width: "100%", alignItems: "stretch", children });
4361
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.XStack, { gap: "$1", width: "100%", alignItems: "stretch", children });
4319
4362
  }
4320
4363
  function StatValueText({
4321
4364
  children,
@@ -4324,12 +4367,30 @@ function StatValueText({
4324
4367
  }) {
4325
4368
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { fontSize, fontWeight: "700", color, children });
4326
4369
  }
4370
+ function StatValue({
4371
+ value,
4372
+ unit,
4373
+ unitPosition,
4374
+ fontSize = "$2",
4375
+ unitFontSize = "$1",
4376
+ color
4377
+ }) {
4378
+ const hoistMarker = unitPosition === "prefix" && value.startsWith("<");
4379
+ const unitLabel = hoistMarker ? `<${unit}` : unit;
4380
+ const digits = hoistMarker ? value.slice(1) : value;
4381
+ const unitText = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { fontSize: unitFontSize, fontWeight: "700", tone: "soft", children: unitLabel });
4382
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.XStack, { alignItems: "baseline", gap: "$1", children: [
4383
+ unitPosition === "prefix" ? unitText : null,
4384
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValueText, { fontSize, color, children: digits }),
4385
+ unitPosition === "suffix" ? unitText : null
4386
+ ] });
4387
+ }
4327
4388
  function CompactGStatValue({ amount }) {
4328
4389
  const [open, setOpen] = (0, import_react8.useState)(false);
4329
4390
  const display = formatGValue(amount);
4330
4391
  const exact = formatExactGAmount(amount);
4331
4392
  if (!isGValueCompacted(amount)) {
4332
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValueText, { children: display });
4393
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValue, { value: display, unit: "G$", unitPosition: "suffix" });
4333
4394
  }
4334
4395
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
4335
4396
  import_ui9.XStack,
@@ -4345,7 +4406,7 @@ function CompactGStatValue({ amount }) {
4345
4406
  onBlur: () => setOpen(false),
4346
4407
  onPress: () => setOpen((prev) => !prev),
4347
4408
  children: [
4348
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValueText, { children: display }),
4409
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValue, { value: display, unit: "G$", unitPosition: "suffix" }),
4349
4410
  open && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
4350
4411
  import_ui9.YStack,
4351
4412
  {
@@ -4370,6 +4431,43 @@ function CompactGStatValue({ amount }) {
4370
4431
  function formatUsdAmount2(usdMicro) {
4371
4432
  return formatUsdMicroValue(usdMicro);
4372
4433
  }
4434
+ function CreditBalanceCard({
4435
+ balance,
4436
+ monthlyCredit
4437
+ }) {
4438
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.Card, { raised: true, borderWidth: 0, width: "100%", gap: "$2", children: [
4439
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { fontSize: "$1", tone: "soft", children: "Credit balance" }),
4440
+ balance !== null ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
4441
+ StatValue,
4442
+ {
4443
+ value: balance,
4444
+ unit: "US$",
4445
+ unitPosition: "prefix",
4446
+ fontSize: "$8",
4447
+ unitFontSize: "$5"
4448
+ }
4449
+ ) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Spinner, { size: "sm" }),
4450
+ monthlyCredit ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
4451
+ import_ui9.XStack,
4452
+ {
4453
+ alignSelf: "flex-start",
4454
+ alignItems: "center",
4455
+ gap: "$1",
4456
+ paddingHorizontal: "$2",
4457
+ paddingVertical: "$1",
4458
+ borderRadius: "$full",
4459
+ backgroundColor: "$infoMuted",
4460
+ children: [
4461
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.TrendingUp, { size: 14, color: "$primary" }),
4462
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.Text, { fontSize: "$1", fontWeight: "700", color: "$primary", children: [
4463
+ monthlyCredit.startsWith("<") ? monthlyCredit : `~${monthlyCredit}`,
4464
+ " / month"
4465
+ ] })
4466
+ ]
4467
+ }
4468
+ ) : null
4469
+ ] });
4470
+ }
4373
4471
  function CreditsManagementCard({ state, actions }) {
4374
4472
  const [isClosing, setIsClosing] = (0, import_react8.useState)(false);
4375
4473
  const [isWithdrawing, setIsWithdrawing] = (0, import_react8.useState)(false);
@@ -4394,7 +4492,7 @@ function CreditsManagementCard({ state, actions }) {
4394
4492
  streamBonusPercent: state.streamBonusPercent
4395
4493
  });
4396
4494
  if (usdMicro <= 0n) return null;
4397
- return formatUsdAmount2(usdMicro.toString());
4495
+ return formatUsdMicroAmount(usdMicro.toString());
4398
4496
  }, [
4399
4497
  monthlyStreamG,
4400
4498
  gdUsdPerToken,
@@ -4410,20 +4508,16 @@ function CreditsManagementCard({ state, actions }) {
4410
4508
  const canWithdraw = Boolean(signerPrvKey) && hasWithdrawableBalance && Boolean(withdrawAmount.trim()) && !isWithdrawing;
4411
4509
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.Card, { children: [
4412
4510
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Heading, { level: 6, children: "AI Credits" }),
4413
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(StatRow, { children: [
4414
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatCell, { label: "Total Credit (US$)", children: totalCreditDisplay !== null ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValueText, { fontSize: "$5", children: totalCreditDisplay }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Spinner, { size: "sm" }) }),
4415
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatCell, { label: "Monthly Credit (US$)", children: monthlyStreamUsdDisplay ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(StatValueText, { fontSize: "$5", color: "$primary", children: [
4416
- "~",
4417
- monthlyStreamUsdDisplay
4418
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValueText, { fontSize: "$5", children: "\u2014" }) })
4419
- ] }),
4420
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(StatRow, { children: [
4421
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatCell, { label: "Total Deposited (G$)", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CompactGStatValue, { amount: totalGdDepositedG ?? "0.00" }) }),
4422
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatCell, { label: "Monthly Stream (G$)", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CompactGStatValue, { amount: monthlyStreamG ?? "0.00" }) })
4423
- ] }),
4424
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(StatRow, { children: [
4425
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatCell, { label: "Bonus Earned (US$)", children: totalBonusDisplay !== null ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValueText, { children: totalBonusDisplay }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Spinner, { size: "sm" }) }),
4426
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatCell, { label: "Withdrawable (US$)", children: withdrawableDisplay !== null ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValueText, { children: withdrawableDisplay }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Spinner, { size: "sm" }) })
4511
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.YStack, { gap: "$2", width: "100%", children: [
4512
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CreditBalanceCard, { balance: totalCreditDisplay, monthlyCredit: monthlyStreamUsdDisplay }),
4513
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(StatRow, { children: [
4514
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatCell, { label: "Deposited", icon: import_ui9.Coins, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CompactGStatValue, { amount: totalGdDepositedG ?? "0.00" }) }),
4515
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatCell, { label: "Monthly Streaming", icon: import_ui9.Repeat, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CompactGStatValue, { amount: monthlyStreamG ?? "0.00" }) })
4516
+ ] }),
4517
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(StatRow, { children: [
4518
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatCell, { label: "Bonus", icon: import_ui9.Gift, children: totalBonusDisplay !== null ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValue, { value: totalBonusDisplay, unit: "US$", unitPosition: "prefix" }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Spinner, { size: "sm" }) }),
4519
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatCell, { label: "Withdrawable", icon: import_ui9.Wallet, children: withdrawableDisplay !== null ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValue, { value: withdrawableDisplay, unit: "US$", unitPosition: "prefix" }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Spinner, { size: "sm" }) })
4520
+ ] })
4427
4521
  ] }),
4428
4522
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.YStack, { gap: "$1", width: "100%", children: [
4429
4523
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.XStack, { gap: "$1", alignItems: "center", children: [