@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.
package/dist/element.cjs CHANGED
@@ -3545,22 +3545,29 @@ function useCopyFeedback() {
3545
3545
 
3546
3546
  // src/components/buy/GenerateSignerKeyPanel.tsx
3547
3547
  var import_jsx_runtime3 = require("react/jsx-runtime");
3548
- function NumberedStep({ index, title }) {
3549
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_ui5.XStack, { gap: "$2", alignItems: "center", children: [
3550
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3551
- import_ui5.YStack,
3552
- {
3553
- width: 24,
3554
- height: 24,
3555
- borderRadius: "$full",
3556
- backgroundColor: "$backgroundSurface",
3557
- alignItems: "center",
3558
- justifyContent: "center",
3559
- flexShrink: 0,
3560
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Text, { fontSize: "$1", fontWeight: "700", children: index })
3561
- }
3562
- ),
3563
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Text, { fontSize: "$3", fontWeight: "700", children: title })
3548
+ function NumberedStep({
3549
+ index,
3550
+ title,
3551
+ note
3552
+ }) {
3553
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_ui5.YStack, { gap: "$1", children: [
3554
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_ui5.XStack, { gap: "$2", alignItems: "center", children: [
3555
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3556
+ import_ui5.YStack,
3557
+ {
3558
+ width: 24,
3559
+ height: 24,
3560
+ borderRadius: "$full",
3561
+ backgroundColor: "$backgroundSurface",
3562
+ alignItems: "center",
3563
+ justifyContent: "center",
3564
+ flexShrink: 0,
3565
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Text, { fontSize: "$1", fontWeight: "700", children: index })
3566
+ }
3567
+ ),
3568
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Text, { fontSize: "$3", fontWeight: "700", children: title })
3569
+ ] }),
3570
+ note && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Text, { marginLeft: 32, fontSize: "$2", color: "$warning", fontStyle: "italic", lineHeight: "$3", children: note })
3564
3571
  ] });
3565
3572
  }
3566
3573
  function GenerateSignerKeyPanel({
@@ -3594,11 +3601,18 @@ function GenerateSignerKeyPanel({
3594
3601
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_ui5.YStack, { gap: "$2", children: [
3595
3602
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(NumberedStep, { index: 1, title: "Open Antseed Desktop" }),
3596
3603
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(NumberedStep, { index: 2, title: "Go to Profile \u2192 Signer" }),
3597
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(NumberedStep, { index: 3, title: "Tap \u2191, paste your Signer Private Key, and save" })
3604
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3605
+ NumberedStep,
3606
+ {
3607
+ index: 3,
3608
+ title: "Back up your existing Signer Key",
3609
+ note: "\u26A0\uFE0F Tap \u2193 to back up your existing signer key. Importing a new signer key will replace it."
3610
+ }
3611
+ ),
3612
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(NumberedStep, { index: 4, title: "Tap \u2191 to paste your Signer Key, then save." })
3598
3613
  ] }),
3599
3614
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AntseedSignerRow, { mode: "generate", showCaption: false }),
3600
3615
  /* @__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." }) }),
3601
- /* @__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." }) }),
3602
3616
  onOpenApiSetup && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_ui5.XStack, { gap: "$2", alignItems: "center", children: [
3603
3617
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Icon, { name: "settings", size: "xs", color: "muted" }),
3604
3618
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_ui5.Text, { fontSize: "$2", tone: "soft", flex: 1, lineHeight: "$3", children: [
@@ -4147,14 +4161,43 @@ var WITHDRAW_TOOLTIP = "Withdraws principal to your payer wallet (not bonus). Re
4147
4161
 
4148
4162
  // src/components/manage/CreditsManagementCard.tsx
4149
4163
  var import_jsx_runtime7 = require("react/jsx-runtime");
4150
- function StatCell({ label, children }) {
4151
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.Card, { raised: true, borderWidth: 0, flexGrow: 1, flexBasis: 0, children: [
4152
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { fontSize: "$1", tone: "soft", children: label }),
4153
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.YStack, { justifyContent: "center", children })
4154
- ] });
4164
+ function StatCell({
4165
+ label,
4166
+ icon: Glyph,
4167
+ children
4168
+ }) {
4169
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
4170
+ import_ui9.Card,
4171
+ {
4172
+ raised: true,
4173
+ borderWidth: 0,
4174
+ flexGrow: 1,
4175
+ flexBasis: 0,
4176
+ padding: "$3",
4177
+ gap: "$1",
4178
+ children: [
4179
+ Glyph ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
4180
+ import_ui9.XStack,
4181
+ {
4182
+ width: 28,
4183
+ height: 28,
4184
+ borderRadius: "$2",
4185
+ backgroundColor: "$background",
4186
+ alignItems: "center",
4187
+ justifyContent: "center",
4188
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Glyph, { size: 16, color: "$colorSoft" })
4189
+ }
4190
+ ) : null,
4191
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.YStack, { children: [
4192
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { fontSize: "$1", tone: "soft", children: label }),
4193
+ children
4194
+ ] })
4195
+ ]
4196
+ }
4197
+ );
4155
4198
  }
4156
4199
  function StatRow({ children }) {
4157
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.XStack, { gap: "$2", width: "100%", alignItems: "stretch", children });
4200
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.XStack, { gap: "$1", width: "100%", alignItems: "stretch", children });
4158
4201
  }
4159
4202
  function StatValueText({
4160
4203
  children,
@@ -4163,12 +4206,30 @@ function StatValueText({
4163
4206
  }) {
4164
4207
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { fontSize, fontWeight: "700", color, children });
4165
4208
  }
4209
+ function StatValue({
4210
+ value,
4211
+ unit,
4212
+ unitPosition,
4213
+ fontSize = "$2",
4214
+ unitFontSize = "$1",
4215
+ color
4216
+ }) {
4217
+ const hoistMarker = unitPosition === "prefix" && value.startsWith("<");
4218
+ const unitLabel = hoistMarker ? `<${unit}` : unit;
4219
+ const digits = hoistMarker ? value.slice(1) : value;
4220
+ const unitText = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { fontSize: unitFontSize, fontWeight: "700", tone: "soft", children: unitLabel });
4221
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.XStack, { alignItems: "baseline", gap: "$1", children: [
4222
+ unitPosition === "prefix" ? unitText : null,
4223
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValueText, { fontSize, color, children: digits }),
4224
+ unitPosition === "suffix" ? unitText : null
4225
+ ] });
4226
+ }
4166
4227
  function CompactGStatValue({ amount }) {
4167
4228
  const [open, setOpen] = (0, import_react8.useState)(false);
4168
4229
  const display = formatGValue(amount);
4169
4230
  const exact = formatExactGAmount(amount);
4170
4231
  if (!isGValueCompacted(amount)) {
4171
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValueText, { children: display });
4232
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValue, { value: display, unit: "G$", unitPosition: "suffix" });
4172
4233
  }
4173
4234
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
4174
4235
  import_ui9.XStack,
@@ -4184,7 +4245,7 @@ function CompactGStatValue({ amount }) {
4184
4245
  onBlur: () => setOpen(false),
4185
4246
  onPress: () => setOpen((prev) => !prev),
4186
4247
  children: [
4187
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValueText, { children: display }),
4248
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValue, { value: display, unit: "G$", unitPosition: "suffix" }),
4188
4249
  open && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
4189
4250
  import_ui9.YStack,
4190
4251
  {
@@ -4209,6 +4270,43 @@ function CompactGStatValue({ amount }) {
4209
4270
  function formatUsdAmount2(usdMicro) {
4210
4271
  return formatUsdMicroValue(usdMicro);
4211
4272
  }
4273
+ function CreditBalanceCard({
4274
+ balance,
4275
+ monthlyCredit
4276
+ }) {
4277
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.Card, { raised: true, borderWidth: 0, width: "100%", gap: "$2", children: [
4278
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { fontSize: "$1", tone: "soft", children: "Credit balance" }),
4279
+ balance !== null ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
4280
+ StatValue,
4281
+ {
4282
+ value: balance,
4283
+ unit: "US$",
4284
+ unitPosition: "prefix",
4285
+ fontSize: "$8",
4286
+ unitFontSize: "$5"
4287
+ }
4288
+ ) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Spinner, { size: "sm" }),
4289
+ monthlyCredit ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
4290
+ import_ui9.XStack,
4291
+ {
4292
+ alignSelf: "flex-start",
4293
+ alignItems: "center",
4294
+ gap: "$1",
4295
+ paddingHorizontal: "$2",
4296
+ paddingVertical: "$1",
4297
+ borderRadius: "$full",
4298
+ backgroundColor: "$infoMuted",
4299
+ children: [
4300
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.TrendingUp, { size: 14, color: "$primary" }),
4301
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.Text, { fontSize: "$1", fontWeight: "700", color: "$primary", children: [
4302
+ monthlyCredit.startsWith("<") ? monthlyCredit : `~${monthlyCredit}`,
4303
+ " / month"
4304
+ ] })
4305
+ ]
4306
+ }
4307
+ ) : null
4308
+ ] });
4309
+ }
4212
4310
  function CreditsManagementCard({ state, actions }) {
4213
4311
  const [isClosing, setIsClosing] = (0, import_react8.useState)(false);
4214
4312
  const [isWithdrawing, setIsWithdrawing] = (0, import_react8.useState)(false);
@@ -4233,7 +4331,7 @@ function CreditsManagementCard({ state, actions }) {
4233
4331
  streamBonusPercent: state.streamBonusPercent
4234
4332
  });
4235
4333
  if (usdMicro <= 0n) return null;
4236
- return formatUsdAmount2(usdMicro.toString());
4334
+ return formatUsdMicroAmount(usdMicro.toString());
4237
4335
  }, [
4238
4336
  monthlyStreamG,
4239
4337
  gdUsdPerToken,
@@ -4249,20 +4347,16 @@ function CreditsManagementCard({ state, actions }) {
4249
4347
  const canWithdraw = Boolean(signerPrvKey) && hasWithdrawableBalance && Boolean(withdrawAmount.trim()) && !isWithdrawing;
4250
4348
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.Card, { children: [
4251
4349
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Heading, { level: 6, children: "AI Credits" }),
4252
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(StatRow, { children: [
4253
- /* @__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" }) }),
4254
- /* @__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: [
4255
- "~",
4256
- monthlyStreamUsdDisplay
4257
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValueText, { fontSize: "$5", children: "\u2014" }) })
4258
- ] }),
4259
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(StatRow, { children: [
4260
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatCell, { label: "Total Deposited (G$)", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CompactGStatValue, { amount: totalGdDepositedG ?? "0.00" }) }),
4261
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatCell, { label: "Monthly Stream (G$)", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CompactGStatValue, { amount: monthlyStreamG ?? "0.00" }) })
4262
- ] }),
4263
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(StatRow, { children: [
4264
- /* @__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" }) }),
4265
- /* @__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" }) })
4350
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.YStack, { gap: "$2", width: "100%", children: [
4351
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CreditBalanceCard, { balance: totalCreditDisplay, monthlyCredit: monthlyStreamUsdDisplay }),
4352
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(StatRow, { children: [
4353
+ /* @__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" }) }),
4354
+ /* @__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" }) })
4355
+ ] }),
4356
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(StatRow, { children: [
4357
+ /* @__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" }) }),
4358
+ /* @__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" }) })
4359
+ ] })
4266
4360
  ] }),
4267
4361
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.YStack, { gap: "$1", width: "100%", children: [
4268
4362
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.XStack, { gap: "$1", alignItems: "center", children: [