@tetsuo-ai/marketplace-react 0.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.
Files changed (112) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/LICENSE +21 -0
  3. package/README.md +172 -0
  4. package/dist/chunk-5OTKSRHM.js +128 -0
  5. package/dist/chunk-5OTKSRHM.js.map +1 -0
  6. package/dist/chunk-ABS77JB2.js +94 -0
  7. package/dist/chunk-ABS77JB2.js.map +1 -0
  8. package/dist/chunk-GN5DYVN5.js +35 -0
  9. package/dist/chunk-GN5DYVN5.js.map +1 -0
  10. package/dist/chunk-KJMR6OGC.js +1198 -0
  11. package/dist/chunk-KJMR6OGC.js.map +1 -0
  12. package/dist/chunk-YORZNYZZ.js +107 -0
  13. package/dist/chunk-YORZNYZZ.js.map +1 -0
  14. package/dist/components/agenc-components.css +570 -0
  15. package/dist/components/index.cjs +1335 -0
  16. package/dist/components/index.cjs.map +1 -0
  17. package/dist/components/index.d.cts +5 -0
  18. package/dist/components/index.d.ts +5 -0
  19. package/dist/components/index.js +5 -0
  20. package/dist/components/index.js.map +1 -0
  21. package/dist/hooks/index.cjs +493 -0
  22. package/dist/hooks/index.cjs.map +1 -0
  23. package/dist/hooks/index.d.cts +294 -0
  24. package/dist/hooks/index.d.ts +294 -0
  25. package/dist/hooks/index.js +339 -0
  26. package/dist/hooks/index.js.map +1 -0
  27. package/dist/index-BLrlBVj-.d.cts +1129 -0
  28. package/dist/index-CKTYsNPH.d.ts +1129 -0
  29. package/dist/index.cjs +1690 -0
  30. package/dist/index.cjs.map +1 -0
  31. package/dist/index.d.cts +235 -0
  32. package/dist/index.d.ts +235 -0
  33. package/dist/index.js +127 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/signers/index.cjs +166 -0
  36. package/dist/signers/index.cjs.map +1 -0
  37. package/dist/signers/index.d.cts +136 -0
  38. package/dist/signers/index.d.ts +136 -0
  39. package/dist/signers/index.js +4 -0
  40. package/dist/signers/index.js.map +1 -0
  41. package/dist/testing/index.cjs +62 -0
  42. package/dist/testing/index.cjs.map +1 -0
  43. package/dist/testing/index.d.cts +71 -0
  44. package/dist/testing/index.d.ts +71 -0
  45. package/dist/testing/index.js +60 -0
  46. package/dist/testing/index.js.map +1 -0
  47. package/dist/theme/agenc-tailwind-preset.cjs +184 -0
  48. package/dist/theme/agenc-tokens.css +132 -0
  49. package/dist/types-jvISR6bc.d.cts +135 -0
  50. package/dist/types-jvISR6bc.d.ts +135 -0
  51. package/dist/useAgentTrackRecord-BLf1nrbu.d.cts +249 -0
  52. package/dist/useAgentTrackRecord-BLf1nrbu.d.ts +249 -0
  53. package/package.json +139 -0
  54. package/src/components/DisputeBanner.stories.tsx +39 -0
  55. package/src/components/DisputeBanner.tsx +110 -0
  56. package/src/components/HireButton.stories.tsx +72 -0
  57. package/src/components/HireButton.tsx +151 -0
  58. package/src/components/HireCheckoutModal.stories.tsx +107 -0
  59. package/src/components/HireCheckoutModal.tsx +284 -0
  60. package/src/components/ListingCard.stories.tsx +55 -0
  61. package/src/components/ListingCard.tsx +148 -0
  62. package/src/components/ListingGrid.stories.tsx +44 -0
  63. package/src/components/ListingGrid.tsx +137 -0
  64. package/src/components/Modal.tsx +121 -0
  65. package/src/components/PoweredByAgenC.tsx +85 -0
  66. package/src/components/ProviderCard.stories.tsx +61 -0
  67. package/src/components/ProviderCard.tsx +154 -0
  68. package/src/components/ReferrerDisclosure.tsx +67 -0
  69. package/src/components/ReviewPanel.stories.tsx +65 -0
  70. package/src/components/ReviewPanel.tsx +141 -0
  71. package/src/components/TaskTimeline.stories.tsx +43 -0
  72. package/src/components/TaskTimeline.tsx +156 -0
  73. package/src/components/__fixtures__/index.tsx +173 -0
  74. package/src/components/agenc-components.css +570 -0
  75. package/src/components/badges.tsx +115 -0
  76. package/src/components/format.ts +150 -0
  77. package/src/components/index.ts +102 -0
  78. package/src/components/primitives.tsx +236 -0
  79. package/src/components/strings.ts +131 -0
  80. package/src/components/useFocusTrap.ts +122 -0
  81. package/src/hooks/index.ts +90 -0
  82. package/src/hooks/internal.ts +70 -0
  83. package/src/hooks/useAgentTrackRecord.ts +166 -0
  84. package/src/hooks/useDispute.ts +130 -0
  85. package/src/hooks/useHire.ts +198 -0
  86. package/src/hooks/useListing.ts +138 -0
  87. package/src/hooks/useListings.ts +133 -0
  88. package/src/hooks/useReferrerEarnings.ts +134 -0
  89. package/src/hooks/useSubmissionReview.ts +179 -0
  90. package/src/hooks/useTaskStatus.ts +192 -0
  91. package/src/hooks/useWalletSigner.ts +99 -0
  92. package/src/index.ts +170 -0
  93. package/src/provider/AgencProvider.tsx +169 -0
  94. package/src/provider/context.ts +35 -0
  95. package/src/provider/index.ts +17 -0
  96. package/src/provider/network.ts +68 -0
  97. package/src/provider/referrer.ts +97 -0
  98. package/src/signers/README.md +130 -0
  99. package/src/signers/embedded-wallet-mock.ts +158 -0
  100. package/src/signers/embedded-wallet.ts +64 -0
  101. package/src/signers/index.ts +48 -0
  102. package/src/signers/strings.ts +39 -0
  103. package/src/signers/types.ts +158 -0
  104. package/src/signers/wallet-account.ts +128 -0
  105. package/src/signers/wallet-adapter.ts +149 -0
  106. package/src/strings/index.ts +119 -0
  107. package/src/testing/index.ts +24 -0
  108. package/src/theme/agenc-tailwind-preset.cjs +184 -0
  109. package/src/theme/agenc-tokens.css +132 -0
  110. package/src/theme/index.ts +94 -0
  111. package/src/transport/index.ts +164 -0
  112. package/src/types.ts +224 -0
@@ -0,0 +1,1198 @@
1
+ import { useAgencContext, useHire, useWalletSigner } from './chunk-YORZNYZZ.js';
2
+ import { EN_STRINGS, t } from './chunk-GN5DYVN5.js';
3
+ import { TaskStatus, values } from '@tetsuo-ai/marketplace-sdk';
4
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
5
+ import { useEffect, useRef, useId, useState, useCallback } from 'react';
6
+
7
+ // src/theme/index.ts
8
+ var AGENC_THEME_CLASS = "agenc";
9
+ var AGENC_TOKENS_CSS_PATH = "@tetsuo-ai/marketplace-react/theme.css";
10
+ function resolveThemeClassName(unstyled, extra) {
11
+ if (unstyled) {
12
+ return extra && extra.trim() !== "" ? extra : void 0;
13
+ }
14
+ const composed = [AGENC_THEME_CLASS, extra].filter((part) => Boolean(part && part.trim() !== "")).join(" ");
15
+ return composed === "" ? void 0 : composed;
16
+ }
17
+ function agencThemeStyleTag() {
18
+ return `:root,.${AGENC_THEME_CLASS}{--agenc-void:#0A0612;--agenc-surface:#16102A;--agenc-surface-2:#221638;--agenc-surface-3:#2E1A4A;--agenc-violet:#7B3FFF;--agenc-magenta:#FF2E93;--agenc-orange:#FF6B1A;--agenc-cyan:#48C8EF;--agenc-text:#F5F0FF;--agenc-text-muted:#B8A8D9;--agenc-text-dim:#6E5C8F;--agenc-success:#3FFFA0;--agenc-warning:#FFC53F;--agenc-danger:#FF3D3D;--agenc-border:#2E1A4A;--agenc-border-strong:#4A2E7A;--agenc-radius-sm:4px;--agenc-radius:8px;--agenc-radius-lg:12px;--agenc-radius-pill:9999px;}`;
19
+ }
20
+
21
+ // src/components/strings.ts
22
+ var EN_COMPONENT_STRINGS = {
23
+ // Shared / cross-component.
24
+ "components.common.loading": "Loading\u2026",
25
+ "components.common.empty": "Nothing to show yet.",
26
+ "components.common.error": "Something went wrong.",
27
+ "components.common.retry": "Retry",
28
+ "components.common.close": "Close",
29
+ "components.common.verified": "Verified",
30
+ "components.common.unverified": "Unverified",
31
+ "components.common.sol": "SOL",
32
+ "components.common.lamports": "lamports",
33
+ // ListingCard.
34
+ "components.listingCard.priceLabel": "Price",
35
+ "components.listingCard.byProvider": "by {provider}",
36
+ "components.listingCard.untitled": "Untitled service",
37
+ "components.listingCard.hires": "{count} hires",
38
+ "components.listingCard.category": "Category",
39
+ // ListingGrid.
40
+ "components.listingGrid.empty": "No listings match your filters yet.",
41
+ "components.listingGrid.loadMore": "Load more",
42
+ "components.listingGrid.error": "Could not load listings.",
43
+ // HireButton / Checkout.
44
+ "components.hire.cta": "Hire",
45
+ "components.hire.ctaPrice": "Hire \u2014 {price}",
46
+ "components.hire.checkoutTitle": "Confirm hire",
47
+ "components.hire.priceLabel": "You pay",
48
+ "components.hire.escrowNote": "Funds are held in protocol escrow and released to the provider only when you accept the result.",
49
+ "components.hire.confirm": "Confirm and fund escrow",
50
+ "components.hire.cancel": "Cancel",
51
+ "components.hire.pending": "Confirming\u2026",
52
+ "components.hire.success": "Escrow funded.",
53
+ "components.hire.successDetail": "Your task is created. Track it below.",
54
+ "components.hire.viewTask": "View task",
55
+ "components.hire.errorTitle": "Hire failed",
56
+ "components.hire.moderationAttested": "Moderation attested",
57
+ "components.hire.moderationPending": "Moderation pending",
58
+ "components.hire.moderationIssues": "Moderation issues found",
59
+ "components.hire.notConnected": "Connect a wallet to hire.",
60
+ // Referrer disclosure (P6.2 gate — never claims a live fee).
61
+ "components.referrer.disclosure": "This site earns a referral fee.",
62
+ "components.referrer.disclosurePending": "This site earns a referral fee (pending protocol support).",
63
+ "components.referrer.feeBps": "{bps} bps",
64
+ // TaskTimeline.
65
+ "components.taskTimeline.title": "Task progress",
66
+ "components.taskTimeline.empty": "No task to track yet.",
67
+ "components.taskTimeline.status.Open": "Open",
68
+ "components.taskTimeline.status.InProgress": "In progress",
69
+ "components.taskTimeline.status.PendingValidation": "Pending review",
70
+ "components.taskTimeline.status.Completed": "Completed",
71
+ "components.taskTimeline.status.Cancelled": "Cancelled",
72
+ "components.taskTimeline.status.Disputed": "Disputed",
73
+ "components.taskTimeline.status.RejectFrozen": "Rejected (frozen)",
74
+ // ReviewPanel.
75
+ "components.review.title": "Review submission",
76
+ "components.review.noSubmission": "Awaiting the worker's submission.",
77
+ "components.review.accept": "Accept and release escrow",
78
+ "components.review.reject": "Reject",
79
+ "components.review.requestChanges": "Request changes",
80
+ "components.review.accepted": "Result accepted. Escrow released.",
81
+ "components.review.rejected": "Result rejected.",
82
+ "components.review.changesRequested": "Changes requested.",
83
+ "components.review.pending": "Submitting\u2026",
84
+ "components.review.errorTitle": "Review action failed",
85
+ // DisputeBanner.
86
+ "components.dispute.title": "This task is in dispute.",
87
+ "components.dispute.body": "A dispute has been opened. A protocol resolver decides the outcome; funds stay in escrow until then.",
88
+ "components.dispute.initiate": "Open a dispute",
89
+ "components.dispute.pending": "Opening dispute\u2026",
90
+ "components.dispute.opened": "Dispute opened.",
91
+ "components.dispute.none": "No open dispute.",
92
+ "components.dispute.errorTitle": "Could not open dispute",
93
+ // ProviderCard.
94
+ "components.provider.title": "Provider",
95
+ "components.provider.completionRate": "Completion rate",
96
+ "components.provider.disputeRate": "Dispute rate",
97
+ "components.provider.completions": "{count} completed",
98
+ "components.provider.disputes": "{count} disputes",
99
+ "components.provider.provisional": "provisional",
100
+ "components.provider.noData": "No track record yet.",
101
+ "components.provider.unavailable": "Track record is unavailable on this read transport.",
102
+ // PoweredByAgenC.
103
+ "components.poweredBy.label": "Powered by AgenC",
104
+ "components.poweredBy.trustLink": "Learn how this works"
105
+ };
106
+ var COMPONENT_CATALOG = {
107
+ ...EN_STRINGS,
108
+ ...EN_COMPONENT_STRINGS
109
+ };
110
+
111
+ // src/components/format.ts
112
+ function tc(id, vars, options) {
113
+ return t(id, vars, { catalog: COMPONENT_CATALOG, ...options });
114
+ }
115
+ var LAMPORTS_PER_SOL = 1000000000n;
116
+ function formatSol(lamports) {
117
+ const negative = lamports < 0n;
118
+ const abs = negative ? -lamports : lamports;
119
+ const whole = abs / LAMPORTS_PER_SOL;
120
+ const frac = abs % LAMPORTS_PER_SOL;
121
+ let out;
122
+ if (frac === 0n) {
123
+ out = whole.toString();
124
+ } else {
125
+ const fracStr = frac.toString().padStart(9, "0").replace(/0+$/, "");
126
+ out = `${whole.toString()}.${fracStr}`;
127
+ }
128
+ return negative ? `-${out}` : out;
129
+ }
130
+ function formatPriceSol(lamports, options) {
131
+ return `${formatSol(lamports)} ${t("components.common.sol", void 0, {
132
+ catalog: COMPONENT_CATALOG,
133
+ ...options
134
+ })}`;
135
+ }
136
+ function truncateAddress(value, head = 4, tail = 4) {
137
+ if (value === null || value === void 0) return "";
138
+ const s = String(value);
139
+ if (s.length <= head + tail + 1) return s;
140
+ return `${s.slice(0, head)}\u2026${s.slice(-tail)}`;
141
+ }
142
+ function decodeListingName(listing) {
143
+ try {
144
+ return values.decodeListingName(Uint8Array.from(listing.name));
145
+ } catch {
146
+ return "";
147
+ }
148
+ }
149
+ function decodeListingCategory(listing) {
150
+ try {
151
+ return values.decodeListingCategory(Uint8Array.from(listing.category));
152
+ } catch {
153
+ return "";
154
+ }
155
+ }
156
+ function decodeListingTags(listing) {
157
+ try {
158
+ return values.decodeListingTags(Uint8Array.from(listing.tags));
159
+ } catch {
160
+ return [];
161
+ }
162
+ }
163
+ function toHex(bytes) {
164
+ let out = "";
165
+ for (let i = 0; i < bytes.length; i++) {
166
+ out += bytes[i].toString(16).padStart(2, "0");
167
+ }
168
+ return out;
169
+ }
170
+ function formatRate(rate, fallback = "\u2014") {
171
+ if (rate === null || Number.isNaN(rate)) return fallback;
172
+ const pct = Math.round(rate * 100);
173
+ return `${pct}%`;
174
+ }
175
+ function cx(...parts) {
176
+ return parts.filter((p) => Boolean(p)).join(" ");
177
+ }
178
+ function elementClass(base, unstyled, extra) {
179
+ if (unstyled) return extra && extra.trim() !== "" ? extra : void 0;
180
+ return cx(base, extra) || void 0;
181
+ }
182
+ function rootClass(base, unstyled, extra) {
183
+ if (unstyled) return extra && extra.trim() !== "" ? extra : void 0;
184
+ return cx(AGENC_THEME_CLASS, base, extra) || void 0;
185
+ }
186
+ var STATE_STRING = {
187
+ loading: "components.common.loading",
188
+ empty: "components.common.empty",
189
+ error: "components.common.error"
190
+ };
191
+ function StateMessage({
192
+ kind,
193
+ message,
194
+ onRetry,
195
+ role,
196
+ unstyled,
197
+ className
198
+ }) {
199
+ const text = message ?? tc(STATE_STRING[kind]);
200
+ const resolvedRole = role ?? (kind === "error" ? "alert" : "status");
201
+ return /* @__PURE__ */ jsxs(
202
+ "div",
203
+ {
204
+ className: elementClass(`agenc-state agenc-state--${kind}`, unstyled, className),
205
+ role: resolvedRole,
206
+ "aria-live": kind === "error" ? "assertive" : "polite",
207
+ "aria-busy": kind === "loading" ? true : void 0,
208
+ children: [
209
+ kind === "loading" ? /* @__PURE__ */ jsx(Spinner, { unstyled }) : null,
210
+ /* @__PURE__ */ jsx("span", { className: unstyled ? void 0 : "agenc-state__text", children: text }),
211
+ onRetry && kind !== "loading" ? /* @__PURE__ */ jsx(Button, { unstyled, variant: "ghost", onClick: onRetry, children: tc("components.common.retry") }) : null
212
+ ]
213
+ }
214
+ );
215
+ }
216
+ function Spinner({ label, unstyled, className }) {
217
+ return /* @__PURE__ */ jsx(
218
+ "span",
219
+ {
220
+ className: elementClass("agenc-spinner", unstyled, className),
221
+ role: "status",
222
+ "aria-live": "polite",
223
+ children: /* @__PURE__ */ jsx("span", { className: unstyled ? void 0 : "agenc-visually-hidden", children: label ?? tc("components.common.loading") })
224
+ }
225
+ );
226
+ }
227
+ function Badge({
228
+ tone = "neutral",
229
+ children,
230
+ label,
231
+ unstyled,
232
+ className
233
+ }) {
234
+ return /* @__PURE__ */ jsx(
235
+ "span",
236
+ {
237
+ className: elementClass(
238
+ `agenc-badge agenc-badge--${tone}`,
239
+ unstyled,
240
+ className
241
+ ),
242
+ title: label,
243
+ "aria-label": label,
244
+ children
245
+ }
246
+ );
247
+ }
248
+ function Button({
249
+ variant = "primary",
250
+ loading = false,
251
+ unstyled,
252
+ className,
253
+ children,
254
+ disabled,
255
+ type,
256
+ ...rest
257
+ }) {
258
+ return /* @__PURE__ */ jsxs(
259
+ "button",
260
+ {
261
+ type: type ?? "button",
262
+ className: elementClass(
263
+ `agenc-button agenc-button--${variant}`,
264
+ unstyled,
265
+ className
266
+ ),
267
+ disabled: disabled || loading,
268
+ "aria-busy": loading || void 0,
269
+ ...rest,
270
+ children: [
271
+ loading ? /* @__PURE__ */ jsx(Spinner, { unstyled }) : null,
272
+ /* @__PURE__ */ jsx("span", { className: unstyled ? void 0 : "agenc-button__label", children })
273
+ ]
274
+ }
275
+ );
276
+ }
277
+ function moderationStateOf(moderation) {
278
+ if (!moderation) return "pending";
279
+ return moderation.metadataValid ? "attested" : "issues";
280
+ }
281
+ var MODERATION_TONE = {
282
+ attested: "success",
283
+ pending: "neutral",
284
+ issues: "warning"
285
+ };
286
+ var MODERATION_STRING = {
287
+ attested: "components.hire.moderationAttested",
288
+ pending: "components.hire.moderationPending",
289
+ // Distinct from `pending` ("Moderation pending") so a buyer can textually
290
+ // tell "we found problems" apart from "we haven't checked", not just by tone.
291
+ issues: "components.hire.moderationIssues"
292
+ };
293
+ function ModerationBadge({
294
+ moderation,
295
+ state,
296
+ unstyled,
297
+ className
298
+ }) {
299
+ const resolved = state ?? moderationStateOf(moderation);
300
+ const label = tc(MODERATION_STRING[resolved]);
301
+ const issues = resolved === "issues" && moderation?.metadataIssues?.length ? moderation.metadataIssues.join("; ") : void 0;
302
+ return /* @__PURE__ */ jsx(
303
+ Badge,
304
+ {
305
+ tone: MODERATION_TONE[resolved],
306
+ unstyled,
307
+ className,
308
+ label: issues ?? label,
309
+ children: label
310
+ }
311
+ );
312
+ }
313
+ function VerifiedBadge({
314
+ verified,
315
+ unstyled,
316
+ className
317
+ }) {
318
+ return /* @__PURE__ */ jsx(
319
+ Badge,
320
+ {
321
+ tone: verified ? "success" : "neutral",
322
+ unstyled,
323
+ className,
324
+ children: verified ? tc("components.common.verified") : tc("components.common.unverified")
325
+ }
326
+ );
327
+ }
328
+ var FOCUSABLE_SELECTOR = [
329
+ "a[href]",
330
+ "button:not([disabled])",
331
+ "textarea:not([disabled])",
332
+ "input:not([disabled])",
333
+ "select:not([disabled])",
334
+ '[tabindex]:not([tabindex="-1"])'
335
+ ].join(",");
336
+ function focusableWithin(container) {
337
+ return Array.from(
338
+ container.querySelectorAll(FOCUSABLE_SELECTOR)
339
+ ).filter((el) => el.offsetParent !== null || el === document.activeElement);
340
+ }
341
+ function useFocusTrap(containerRef, active, onEscape) {
342
+ useEffect(() => {
343
+ if (!active) return;
344
+ const container = containerRef.current;
345
+ if (!container) return;
346
+ const previouslyFocused = document.activeElement instanceof HTMLElement ? document.activeElement : null;
347
+ const initial = focusableWithin(container)[0] ?? container;
348
+ initial.focus();
349
+ function onKeyDown(event) {
350
+ if (event.key === "Escape") {
351
+ event.stopPropagation();
352
+ onEscape?.();
353
+ return;
354
+ }
355
+ if (event.key !== "Tab") return;
356
+ const focusable = focusableWithin(container);
357
+ if (focusable.length === 0) {
358
+ event.preventDefault();
359
+ container.focus();
360
+ return;
361
+ }
362
+ const first = focusable[0];
363
+ const last = focusable[focusable.length - 1];
364
+ const activeEl = document.activeElement;
365
+ if (event.shiftKey) {
366
+ if (activeEl === first || activeEl === container) {
367
+ event.preventDefault();
368
+ last.focus();
369
+ }
370
+ } else if (activeEl === last) {
371
+ event.preventDefault();
372
+ first.focus();
373
+ }
374
+ }
375
+ function onFocusIn(event) {
376
+ const target = event.target;
377
+ if (!(target instanceof Node)) return;
378
+ if (container.contains(target)) return;
379
+ event.stopPropagation();
380
+ const focusable = focusableWithin(container);
381
+ (focusable[0] ?? container).focus();
382
+ }
383
+ container.addEventListener("keydown", onKeyDown);
384
+ document.addEventListener("focusin", onFocusIn);
385
+ return () => {
386
+ container.removeEventListener("keydown", onKeyDown);
387
+ document.removeEventListener("focusin", onFocusIn);
388
+ previouslyFocused?.focus();
389
+ };
390
+ }, [containerRef, active, onEscape]);
391
+ }
392
+ function Modal({
393
+ open,
394
+ onClose,
395
+ title,
396
+ children,
397
+ footer,
398
+ disableEscapeClose = false,
399
+ disableOverlayClose = false,
400
+ hideCloseButton = false,
401
+ closeLabel,
402
+ unstyled,
403
+ className
404
+ }) {
405
+ const dialogRef = useRef(null);
406
+ const titleId = useId();
407
+ const bodyId = useId();
408
+ useFocusTrap(dialogRef, open, () => {
409
+ if (!disableEscapeClose) onClose();
410
+ });
411
+ if (!open) return null;
412
+ const overlayClass = rootClass("agenc-modal", unstyled, className);
413
+ return /* @__PURE__ */ jsx(
414
+ "div",
415
+ {
416
+ className: overlayClass,
417
+ onMouseDown: (event) => {
418
+ if (disableOverlayClose) return;
419
+ if (event.target === event.currentTarget) onClose();
420
+ },
421
+ children: /* @__PURE__ */ jsxs(
422
+ "div",
423
+ {
424
+ className: unstyled ? void 0 : "agenc-modal__dialog",
425
+ ref: dialogRef,
426
+ role: "dialog",
427
+ "aria-modal": "true",
428
+ "aria-labelledby": titleId,
429
+ "aria-describedby": bodyId,
430
+ tabIndex: -1,
431
+ children: [
432
+ /* @__PURE__ */ jsxs("header", { className: unstyled ? void 0 : "agenc-modal__header", children: [
433
+ /* @__PURE__ */ jsx("h2", { id: titleId, className: unstyled ? void 0 : "agenc-modal__title", children: title }),
434
+ hideCloseButton ? null : /* @__PURE__ */ jsx(
435
+ "button",
436
+ {
437
+ type: "button",
438
+ className: unstyled ? void 0 : "agenc-modal__close",
439
+ "aria-label": closeLabel ?? tc("components.common.close"),
440
+ onClick: onClose,
441
+ children: /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "\xD7" })
442
+ }
443
+ )
444
+ ] }),
445
+ /* @__PURE__ */ jsx("div", { id: bodyId, className: unstyled ? void 0 : "agenc-modal__body", children }),
446
+ footer ? /* @__PURE__ */ jsx("footer", { className: unstyled ? void 0 : "agenc-modal__footer", children: footer }) : null
447
+ ]
448
+ }
449
+ )
450
+ }
451
+ );
452
+ }
453
+ function ListingCard({
454
+ listing,
455
+ moderation,
456
+ onHire,
457
+ onSelect,
458
+ hidePrice = false,
459
+ unstyled,
460
+ className
461
+ }) {
462
+ const { account } = listing;
463
+ const name = decodeListingName(account) || tc("components.listingCard.untitled");
464
+ const category = decodeListingCategory(account);
465
+ const price = formatPriceSol(account.price);
466
+ const provider = truncateAddress(account.providerAgent);
467
+ const hires = account.totalHires;
468
+ const cardClass = rootClass("agenc-listing-card", unstyled, className);
469
+ const selectable = Boolean(onSelect);
470
+ const heading = /* @__PURE__ */ jsx("h3", { className: unstyled ? void 0 : "agenc-listing-card__title", children: name });
471
+ return /* @__PURE__ */ jsxs(
472
+ "article",
473
+ {
474
+ className: cardClass,
475
+ "aria-label": name,
476
+ children: [
477
+ /* @__PURE__ */ jsxs("header", { className: unstyled ? void 0 : "agenc-listing-card__header", children: [
478
+ selectable ? /* @__PURE__ */ jsx(
479
+ "button",
480
+ {
481
+ type: "button",
482
+ className: unstyled ? void 0 : "agenc-listing-card__title-button",
483
+ onClick: () => onSelect?.(listing),
484
+ children: heading
485
+ }
486
+ ) : heading,
487
+ /* @__PURE__ */ jsx(ModerationBadge, { moderation, unstyled })
488
+ ] }),
489
+ /* @__PURE__ */ jsxs("dl", { className: unstyled ? void 0 : "agenc-listing-card__meta", children: [
490
+ category ? /* @__PURE__ */ jsxs("div", { className: unstyled ? void 0 : "agenc-listing-card__meta-row", children: [
491
+ /* @__PURE__ */ jsx("dt", { children: tc("components.listingCard.category") }),
492
+ /* @__PURE__ */ jsx("dd", { children: /* @__PURE__ */ jsx(Badge, { tone: "info", unstyled, children: category }) })
493
+ ] }) : null,
494
+ /* @__PURE__ */ jsxs("div", { className: unstyled ? void 0 : "agenc-listing-card__meta-row", children: [
495
+ /* @__PURE__ */ jsx("dt", { children: tc("components.listingCard.byProvider", { provider }) }),
496
+ /* @__PURE__ */ jsx("dd", { children: tc("components.listingCard.hires", { count: String(hires) }) })
497
+ ] })
498
+ ] }),
499
+ /* @__PURE__ */ jsxs("footer", { className: unstyled ? void 0 : "agenc-listing-card__footer", children: [
500
+ hidePrice ? null : /* @__PURE__ */ jsxs("p", { className: unstyled ? void 0 : "agenc-listing-card__price", children: [
501
+ /* @__PURE__ */ jsx("span", { className: unstyled ? void 0 : "agenc-listing-card__price-label", children: tc("components.listingCard.priceLabel") }),
502
+ " ",
503
+ /* @__PURE__ */ jsx("span", { className: unstyled ? void 0 : "agenc-listing-card__price-value", children: price })
504
+ ] }),
505
+ onHire ? /* @__PURE__ */ jsx(
506
+ Button,
507
+ {
508
+ unstyled,
509
+ variant: "primary",
510
+ onClick: () => onHire(listing),
511
+ children: tc("components.hire.cta")
512
+ }
513
+ ) : null
514
+ ] })
515
+ ]
516
+ }
517
+ );
518
+ }
519
+ function ListingGrid({
520
+ listings,
521
+ isLoading = false,
522
+ error = null,
523
+ hasMore = false,
524
+ onLoadMore,
525
+ onRetry,
526
+ onHire,
527
+ onSelect,
528
+ moderationByPda,
529
+ emptyMessage,
530
+ unstyled,
531
+ className
532
+ }) {
533
+ const gridClass = rootClass("agenc-listing-grid", unstyled, className);
534
+ if (error) {
535
+ return /* @__PURE__ */ jsx("div", { className: gridClass, children: /* @__PURE__ */ jsx(
536
+ StateMessage,
537
+ {
538
+ kind: "error",
539
+ message: tc("components.listingGrid.error"),
540
+ onRetry,
541
+ unstyled
542
+ }
543
+ ) });
544
+ }
545
+ if (isLoading && listings.length === 0) {
546
+ return /* @__PURE__ */ jsx("div", { className: gridClass, children: /* @__PURE__ */ jsx(StateMessage, { kind: "loading", unstyled }) });
547
+ }
548
+ if (listings.length === 0) {
549
+ return /* @__PURE__ */ jsx("div", { className: gridClass, children: /* @__PURE__ */ jsx(
550
+ StateMessage,
551
+ {
552
+ kind: "empty",
553
+ message: emptyMessage ?? tc("components.listingGrid.empty"),
554
+ unstyled
555
+ }
556
+ ) });
557
+ }
558
+ return /* @__PURE__ */ jsxs("div", { className: gridClass, children: [
559
+ /* @__PURE__ */ jsx(
560
+ "ul",
561
+ {
562
+ className: unstyled ? void 0 : "agenc-listing-grid__list",
563
+ children: listings.map((listing) => /* @__PURE__ */ jsx(
564
+ "li",
565
+ {
566
+ className: unstyled ? void 0 : "agenc-listing-grid__item",
567
+ children: /* @__PURE__ */ jsx(
568
+ ListingCard,
569
+ {
570
+ listing,
571
+ moderation: moderationByPda?.[String(listing.address)] ?? null,
572
+ onHire,
573
+ onSelect,
574
+ unstyled
575
+ }
576
+ )
577
+ },
578
+ String(listing.address)
579
+ ))
580
+ }
581
+ ),
582
+ hasMore && onLoadMore ? /* @__PURE__ */ jsx("div", { className: unstyled ? void 0 : "agenc-listing-grid__more", children: /* @__PURE__ */ jsx(
583
+ "button",
584
+ {
585
+ type: "button",
586
+ className: unstyled ? void 0 : "agenc-button agenc-button--secondary",
587
+ onClick: onLoadMore,
588
+ children: tc("components.listingGrid.loadMore")
589
+ }
590
+ ) }) : null
591
+ ] });
592
+ }
593
+ function ReferrerDisclosure({
594
+ referrer,
595
+ live = false,
596
+ showFee = true,
597
+ unstyled,
598
+ className
599
+ }) {
600
+ const text = live ? tc("components.referrer.disclosure") : tc("components.referrer.disclosurePending");
601
+ return /* @__PURE__ */ jsxs(
602
+ "p",
603
+ {
604
+ className: unstyled ? className : cx("agenc-referrer-disclosure", className),
605
+ role: "note",
606
+ children: [
607
+ /* @__PURE__ */ jsx("span", { children: text }),
608
+ showFee ? /* @__PURE__ */ jsxs("span", { className: unstyled ? void 0 : "agenc-referrer-disclosure__fee", children: [
609
+ " ",
610
+ tc("components.referrer.feeBps", { bps: String(referrer.feeBps) })
611
+ ] }) : null
612
+ ]
613
+ }
614
+ );
615
+ }
616
+ function HireCheckoutModal({
617
+ open,
618
+ onClose,
619
+ listing,
620
+ onConfirm,
621
+ status = "idle",
622
+ error = null,
623
+ taskPda = null,
624
+ onViewTask,
625
+ moderation,
626
+ referrer,
627
+ referrerLive = false,
628
+ connected = true,
629
+ unstyled,
630
+ className
631
+ }) {
632
+ const pending = status === "pending";
633
+ const success = status === "success";
634
+ const price = formatPriceSol(listing.account.price);
635
+ const [submitting, setSubmitting] = useState(false);
636
+ const submittingRef = useRef(false);
637
+ useEffect(() => {
638
+ if (!open || !pending) {
639
+ submittingRef.current = false;
640
+ setSubmitting(false);
641
+ }
642
+ }, [open, pending]);
643
+ const handleConfirm = useCallback(() => {
644
+ if (submittingRef.current) return;
645
+ submittingRef.current = true;
646
+ setSubmitting(true);
647
+ let result;
648
+ try {
649
+ result = onConfirm();
650
+ } catch {
651
+ submittingRef.current = false;
652
+ setSubmitting(false);
653
+ return;
654
+ }
655
+ if (result && typeof result.then === "function") {
656
+ void result.finally(() => {
657
+ submittingRef.current = false;
658
+ setSubmitting(false);
659
+ });
660
+ }
661
+ }, [onConfirm]);
662
+ const confirmDisabled = !connected || pending || submitting;
663
+ const lockClose = pending || submitting;
664
+ const footer = success ? /* @__PURE__ */ jsxs(Fragment, { children: [
665
+ taskPda && onViewTask ? /* @__PURE__ */ jsx(
666
+ Button,
667
+ {
668
+ unstyled,
669
+ variant: "primary",
670
+ onClick: () => onViewTask(taskPda),
671
+ children: tc("components.hire.viewTask")
672
+ }
673
+ ) : null,
674
+ /* @__PURE__ */ jsx(Button, { unstyled, variant: "secondary", onClick: onClose, children: tc("components.common.close") })
675
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
676
+ /* @__PURE__ */ jsx(
677
+ Button,
678
+ {
679
+ unstyled,
680
+ variant: "secondary",
681
+ onClick: onClose,
682
+ disabled: pending || submitting,
683
+ children: tc("components.hire.cancel")
684
+ }
685
+ ),
686
+ /* @__PURE__ */ jsx(
687
+ Button,
688
+ {
689
+ unstyled,
690
+ variant: "primary",
691
+ loading: pending || submitting,
692
+ disabled: confirmDisabled,
693
+ onClick: handleConfirm,
694
+ children: pending || submitting ? tc("components.hire.pending") : tc("components.hire.confirm")
695
+ }
696
+ )
697
+ ] });
698
+ return /* @__PURE__ */ jsx(
699
+ Modal,
700
+ {
701
+ open,
702
+ onClose,
703
+ title: tc("components.hire.checkoutTitle"),
704
+ footer,
705
+ disableEscapeClose: lockClose,
706
+ disableOverlayClose: lockClose,
707
+ hideCloseButton: lockClose,
708
+ unstyled,
709
+ className,
710
+ children: /* @__PURE__ */ jsxs("div", { className: unstyled ? void 0 : "agenc-checkout", children: [
711
+ /* @__PURE__ */ jsxs("div", { className: unstyled ? void 0 : "agenc-checkout__row", children: [
712
+ /* @__PURE__ */ jsx("span", { className: unstyled ? void 0 : "agenc-checkout__price-label", children: tc("components.hire.priceLabel") }),
713
+ /* @__PURE__ */ jsx("span", { className: unstyled ? void 0 : "agenc-checkout__price", children: price })
714
+ ] }),
715
+ /* @__PURE__ */ jsx("div", { className: unstyled ? void 0 : "agenc-checkout__moderation", children: /* @__PURE__ */ jsx(ModerationBadge, { moderation, unstyled }) }),
716
+ /* @__PURE__ */ jsx("p", { className: unstyled ? void 0 : "agenc-checkout__escrow-note", children: tc("components.hire.escrowNote") }),
717
+ referrer ? /* @__PURE__ */ jsx(
718
+ ReferrerDisclosure,
719
+ {
720
+ referrer,
721
+ live: referrerLive,
722
+ unstyled
723
+ }
724
+ ) : null,
725
+ /* @__PURE__ */ jsxs(
726
+ "div",
727
+ {
728
+ className: unstyled ? void 0 : "agenc-checkout__status",
729
+ role: "status",
730
+ "aria-live": "polite",
731
+ children: [
732
+ pending ? tc("components.hire.pending") : null,
733
+ success ? /* @__PURE__ */ jsxs(Fragment, { children: [
734
+ /* @__PURE__ */ jsx("strong", { children: tc("components.hire.success") }),
735
+ " ",
736
+ tc("components.hire.successDetail")
737
+ ] }) : null
738
+ ]
739
+ }
740
+ ),
741
+ error ? /* @__PURE__ */ jsxs(
742
+ "div",
743
+ {
744
+ className: unstyled ? void 0 : "agenc-checkout__error",
745
+ role: "alert",
746
+ "aria-live": "assertive",
747
+ children: [
748
+ /* @__PURE__ */ jsx("strong", { children: tc("components.hire.errorTitle") }),
749
+ /* @__PURE__ */ jsx("span", { children: error.message })
750
+ ]
751
+ }
752
+ ) : null,
753
+ !connected && !success ? /* @__PURE__ */ jsx("p", { className: unstyled ? void 0 : "agenc-checkout__hint", children: tc("components.hire.notConnected") }) : null
754
+ ] })
755
+ }
756
+ );
757
+ }
758
+ function HireButton({
759
+ listing,
760
+ buildHireInput,
761
+ onHired,
762
+ onViewTask,
763
+ showPriceInLabel = true,
764
+ label,
765
+ unstyled,
766
+ className
767
+ }) {
768
+ const ctx = useAgencContext();
769
+ const { hire, status, error, taskPda, reset } = useHire();
770
+ const { connected } = useWalletSigner();
771
+ const [open, setOpen] = useState(false);
772
+ const inFlightRef = useRef(false);
773
+ const capability = ctx.resolveReferrerCapability();
774
+ const close = useCallback(() => {
775
+ setOpen(false);
776
+ inFlightRef.current = false;
777
+ reset();
778
+ }, [reset]);
779
+ const confirm = useCallback(async () => {
780
+ if (inFlightRef.current) return;
781
+ inFlightRef.current = true;
782
+ try {
783
+ const input = buildHireInput(listing);
784
+ const result = await hire(input);
785
+ onHired?.(result.taskPda);
786
+ } finally {
787
+ inFlightRef.current = false;
788
+ }
789
+ }, [buildHireInput, hire, listing, onHired]);
790
+ const buttonLabel = label ?? (showPriceInLabel ? tc("components.hire.ctaPrice", {
791
+ price: formatPriceSol(listing.account.price)
792
+ }) : tc("components.hire.cta"));
793
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
794
+ /* @__PURE__ */ jsx(
795
+ Button,
796
+ {
797
+ unstyled,
798
+ className,
799
+ variant: "primary",
800
+ onClick: () => setOpen(true),
801
+ children: buttonLabel
802
+ }
803
+ ),
804
+ /* @__PURE__ */ jsx(
805
+ HireCheckoutModal,
806
+ {
807
+ open,
808
+ onClose: close,
809
+ listing,
810
+ onConfirm: confirm,
811
+ status,
812
+ error,
813
+ taskPda,
814
+ onViewTask,
815
+ referrer: ctx.referrer,
816
+ referrerLive: capability.live,
817
+ connected,
818
+ unstyled
819
+ }
820
+ )
821
+ ] });
822
+ }
823
+ var HAPPY_PATH = [
824
+ { status: TaskStatus.Open, stringId: "components.taskTimeline.status.Open" },
825
+ {
826
+ status: TaskStatus.InProgress,
827
+ stringId: "components.taskTimeline.status.InProgress"
828
+ },
829
+ {
830
+ status: TaskStatus.PendingValidation,
831
+ stringId: "components.taskTimeline.status.PendingValidation"
832
+ },
833
+ {
834
+ status: TaskStatus.Completed,
835
+ stringId: "components.taskTimeline.status.Completed"
836
+ }
837
+ ];
838
+ var OFF_PATH = {
839
+ [TaskStatus.Cancelled]: {
840
+ stringId: "components.taskTimeline.status.Cancelled",
841
+ tone: "cancelled"
842
+ },
843
+ [TaskStatus.Disputed]: {
844
+ stringId: "components.taskTimeline.status.Disputed",
845
+ tone: "disputed"
846
+ },
847
+ [TaskStatus.RejectFrozen]: {
848
+ stringId: "components.taskTimeline.status.RejectFrozen",
849
+ tone: "rejected"
850
+ }
851
+ };
852
+ function happyIndex(status) {
853
+ return HAPPY_PATH.findIndex((s) => s.status === status);
854
+ }
855
+ function TaskTimeline({
856
+ status,
857
+ isLoading = false,
858
+ error = null,
859
+ onRetry,
860
+ unstyled,
861
+ className
862
+ }) {
863
+ const timelineClass = rootClass("agenc-timeline", unstyled, className);
864
+ if (error) {
865
+ return /* @__PURE__ */ jsx("div", { className: timelineClass, children: /* @__PURE__ */ jsx(StateMessage, { kind: "error", onRetry, unstyled }) });
866
+ }
867
+ if (isLoading && status === null) {
868
+ return /* @__PURE__ */ jsx("div", { className: timelineClass, children: /* @__PURE__ */ jsx(StateMessage, { kind: "loading", unstyled }) });
869
+ }
870
+ if (status === null) {
871
+ return /* @__PURE__ */ jsx("div", { className: timelineClass, children: /* @__PURE__ */ jsx(
872
+ StateMessage,
873
+ {
874
+ kind: "empty",
875
+ message: tc("components.taskTimeline.empty"),
876
+ unstyled
877
+ }
878
+ ) });
879
+ }
880
+ const offPath = OFF_PATH[status];
881
+ const currentIndex = offPath ? -1 : happyIndex(status);
882
+ return /* @__PURE__ */ jsxs("div", { className: timelineClass, "aria-label": tc("components.taskTimeline.title"), children: [
883
+ /* @__PURE__ */ jsx("ol", { className: unstyled ? void 0 : "agenc-timeline__list", children: HAPPY_PATH.map((stage, index) => {
884
+ const done = currentIndex > index;
885
+ const current = currentIndex === index;
886
+ const state = done ? "done" : current ? "current" : "upcoming";
887
+ return /* @__PURE__ */ jsxs(
888
+ "li",
889
+ {
890
+ className: unstyled ? void 0 : cx("agenc-timeline__step", `agenc-timeline__step--${state}`),
891
+ "aria-current": current ? "step" : void 0,
892
+ children: [
893
+ /* @__PURE__ */ jsx(
894
+ "span",
895
+ {
896
+ className: unstyled ? void 0 : "agenc-timeline__marker",
897
+ "aria-hidden": "true"
898
+ }
899
+ ),
900
+ /* @__PURE__ */ jsx("span", { className: unstyled ? void 0 : "agenc-timeline__label", children: tc(stage.stringId) })
901
+ ]
902
+ },
903
+ stage.status
904
+ );
905
+ }) }),
906
+ offPath ? /* @__PURE__ */ jsx(
907
+ "p",
908
+ {
909
+ className: unstyled ? void 0 : cx(
910
+ "agenc-timeline__terminal",
911
+ `agenc-timeline__terminal--${offPath.tone}`
912
+ ),
913
+ role: "status",
914
+ children: tc(offPath.stringId)
915
+ }
916
+ ) : null
917
+ ] });
918
+ }
919
+ var SUCCESS_STRING = {
920
+ accept: "components.review.accepted",
921
+ reject: "components.review.rejected",
922
+ requestChanges: "components.review.changesRequested"
923
+ };
924
+ function ReviewPanel({
925
+ hasSubmission = false,
926
+ onAccept,
927
+ onReject,
928
+ onRequestChanges,
929
+ status = "idle",
930
+ error = null,
931
+ settledAction,
932
+ unstyled,
933
+ className
934
+ }) {
935
+ const panelClass = rootClass("agenc-review", unstyled, className);
936
+ const pending = status === "pending";
937
+ const success = status === "success";
938
+ return /* @__PURE__ */ jsxs(
939
+ "section",
940
+ {
941
+ className: panelClass,
942
+ "aria-label": tc("components.review.title"),
943
+ children: [
944
+ /* @__PURE__ */ jsx("h3", { className: unstyled ? void 0 : "agenc-review__title", children: tc("components.review.title") }),
945
+ !hasSubmission ? /* @__PURE__ */ jsx(
946
+ StateMessage,
947
+ {
948
+ kind: "empty",
949
+ message: tc("components.review.noSubmission"),
950
+ unstyled
951
+ }
952
+ ) : /* @__PURE__ */ jsxs("div", { className: unstyled ? void 0 : "agenc-review__actions", children: [
953
+ /* @__PURE__ */ jsx(
954
+ Button,
955
+ {
956
+ unstyled,
957
+ variant: "primary",
958
+ loading: pending,
959
+ disabled: pending || !onAccept,
960
+ onClick: onAccept,
961
+ children: tc("components.review.accept")
962
+ }
963
+ ),
964
+ /* @__PURE__ */ jsx(
965
+ Button,
966
+ {
967
+ unstyled,
968
+ variant: "secondary",
969
+ disabled: pending || !onRequestChanges,
970
+ onClick: onRequestChanges,
971
+ children: tc("components.review.requestChanges")
972
+ }
973
+ ),
974
+ /* @__PURE__ */ jsx(
975
+ Button,
976
+ {
977
+ unstyled,
978
+ variant: "danger",
979
+ disabled: pending || !onReject,
980
+ onClick: onReject,
981
+ children: tc("components.review.reject")
982
+ }
983
+ )
984
+ ] }),
985
+ /* @__PURE__ */ jsxs(
986
+ "div",
987
+ {
988
+ className: unstyled ? void 0 : "agenc-review__status",
989
+ role: "status",
990
+ "aria-live": "polite",
991
+ children: [
992
+ pending ? tc("components.review.pending") : null,
993
+ success && settledAction ? tc(SUCCESS_STRING[settledAction]) : null
994
+ ]
995
+ }
996
+ ),
997
+ error ? /* @__PURE__ */ jsxs(
998
+ "div",
999
+ {
1000
+ className: unstyled ? void 0 : "agenc-review__error",
1001
+ role: "alert",
1002
+ "aria-live": "assertive",
1003
+ children: [
1004
+ /* @__PURE__ */ jsx("strong", { children: tc("components.review.errorTitle") }),
1005
+ /* @__PURE__ */ jsx("span", { children: error.message })
1006
+ ]
1007
+ }
1008
+ ) : null
1009
+ ]
1010
+ }
1011
+ );
1012
+ }
1013
+ function DisputeBanner({
1014
+ disputeOpen = false,
1015
+ onInitiate,
1016
+ status = "idle",
1017
+ error = null,
1018
+ unstyled,
1019
+ className
1020
+ }) {
1021
+ const bannerClass = rootClass(
1022
+ cx(
1023
+ "agenc-dispute",
1024
+ disputeOpen ? "agenc-dispute--open" : "agenc-dispute--none"
1025
+ ),
1026
+ unstyled,
1027
+ className
1028
+ );
1029
+ const pending = status === "pending";
1030
+ const opened = status === "success";
1031
+ if (disputeOpen) {
1032
+ return /* @__PURE__ */ jsxs("div", { className: bannerClass, role: "alert", children: [
1033
+ /* @__PURE__ */ jsx("strong", { className: unstyled ? void 0 : "agenc-dispute__title", children: tc("components.dispute.title") }),
1034
+ /* @__PURE__ */ jsx("p", { className: unstyled ? void 0 : "agenc-dispute__body", children: tc("components.dispute.body") })
1035
+ ] });
1036
+ }
1037
+ return /* @__PURE__ */ jsxs("div", { className: bannerClass, role: "region", "aria-label": tc("components.dispute.none"), children: [
1038
+ /* @__PURE__ */ jsx("p", { className: unstyled ? void 0 : "agenc-dispute__none", children: tc("components.dispute.none") }),
1039
+ onInitiate ? /* @__PURE__ */ jsx(
1040
+ Button,
1041
+ {
1042
+ unstyled,
1043
+ variant: "secondary",
1044
+ loading: pending,
1045
+ disabled: pending,
1046
+ onClick: onInitiate,
1047
+ children: pending ? tc("components.dispute.pending") : tc("components.dispute.initiate")
1048
+ }
1049
+ ) : null,
1050
+ /* @__PURE__ */ jsx(
1051
+ "div",
1052
+ {
1053
+ className: unstyled ? void 0 : "agenc-dispute__status",
1054
+ role: "status",
1055
+ "aria-live": "polite",
1056
+ children: opened ? tc("components.dispute.opened") : null
1057
+ }
1058
+ ),
1059
+ error ? /* @__PURE__ */ jsxs(
1060
+ "div",
1061
+ {
1062
+ className: unstyled ? void 0 : "agenc-dispute__error",
1063
+ role: "alert",
1064
+ "aria-live": "assertive",
1065
+ children: [
1066
+ /* @__PURE__ */ jsx("strong", { children: tc("components.dispute.errorTitle") }),
1067
+ /* @__PURE__ */ jsx("span", { children: error.message })
1068
+ ]
1069
+ }
1070
+ ) : null
1071
+ ] });
1072
+ }
1073
+ function ProviderCard({
1074
+ agent,
1075
+ trackRecord,
1076
+ verified = false,
1077
+ isLoading = false,
1078
+ error = null,
1079
+ onRetry,
1080
+ unstyled,
1081
+ className
1082
+ }) {
1083
+ const cardClass = rootClass("agenc-provider", unstyled, className);
1084
+ const header = /* @__PURE__ */ jsxs("header", { className: unstyled ? void 0 : "agenc-provider__header", children: [
1085
+ /* @__PURE__ */ jsxs("div", { className: unstyled ? void 0 : "agenc-provider__id", children: [
1086
+ /* @__PURE__ */ jsx("span", { className: unstyled ? void 0 : "agenc-provider__label", children: tc("components.provider.title") }),
1087
+ agent ? /* @__PURE__ */ jsx("span", { className: unstyled ? void 0 : "agenc-provider__pda", children: truncateAddress(agent) }) : null
1088
+ ] }),
1089
+ /* @__PURE__ */ jsx(VerifiedBadge, { verified, unstyled })
1090
+ ] });
1091
+ if (error) {
1092
+ return /* @__PURE__ */ jsxs("section", { className: cardClass, "aria-label": tc("components.provider.title"), children: [
1093
+ header,
1094
+ /* @__PURE__ */ jsx(
1095
+ StateMessage,
1096
+ {
1097
+ kind: "error",
1098
+ message: tc("components.provider.unavailable"),
1099
+ onRetry,
1100
+ unstyled
1101
+ }
1102
+ )
1103
+ ] });
1104
+ }
1105
+ if (isLoading && trackRecord === null) {
1106
+ return /* @__PURE__ */ jsxs("section", { className: cardClass, "aria-label": tc("components.provider.title"), children: [
1107
+ header,
1108
+ /* @__PURE__ */ jsx(StateMessage, { kind: "loading", unstyled })
1109
+ ] });
1110
+ }
1111
+ if (trackRecord === null) {
1112
+ return /* @__PURE__ */ jsxs("section", { className: cardClass, "aria-label": tc("components.provider.title"), children: [
1113
+ header,
1114
+ /* @__PURE__ */ jsx(
1115
+ StateMessage,
1116
+ {
1117
+ kind: "empty",
1118
+ message: tc("components.provider.noData"),
1119
+ unstyled
1120
+ }
1121
+ )
1122
+ ] });
1123
+ }
1124
+ const provisional = trackRecord.partial;
1125
+ return /* @__PURE__ */ jsxs("section", { className: cardClass, "aria-label": tc("components.provider.title"), children: [
1126
+ header,
1127
+ /* @__PURE__ */ jsxs("dl", { className: unstyled ? void 0 : "agenc-provider__stats", children: [
1128
+ /* @__PURE__ */ jsxs("div", { className: unstyled ? void 0 : "agenc-provider__stat", children: [
1129
+ /* @__PURE__ */ jsx("dt", { children: tc("components.provider.completionRate") }),
1130
+ /* @__PURE__ */ jsxs("dd", { children: [
1131
+ formatRate(trackRecord.completionRate),
1132
+ provisional ? /* @__PURE__ */ jsxs("span", { className: unstyled ? void 0 : "agenc-provider__provisional", children: [
1133
+ " ",
1134
+ "(",
1135
+ tc("components.provider.provisional"),
1136
+ ")"
1137
+ ] }) : null
1138
+ ] })
1139
+ ] }),
1140
+ /* @__PURE__ */ jsxs("div", { className: unstyled ? void 0 : "agenc-provider__stat", children: [
1141
+ /* @__PURE__ */ jsx("dt", { children: tc("components.provider.disputeRate") }),
1142
+ /* @__PURE__ */ jsxs("dd", { children: [
1143
+ formatRate(trackRecord.disputeRate),
1144
+ provisional ? /* @__PURE__ */ jsxs("span", { className: unstyled ? void 0 : "agenc-provider__provisional", children: [
1145
+ " ",
1146
+ "(",
1147
+ tc("components.provider.provisional"),
1148
+ ")"
1149
+ ] }) : null
1150
+ ] })
1151
+ ] }),
1152
+ /* @__PURE__ */ jsxs("div", { className: unstyled ? void 0 : "agenc-provider__stat", children: [
1153
+ /* @__PURE__ */ jsx("dt", { children: tc("components.provider.completions", {
1154
+ count: String(trackRecord.completions)
1155
+ }) }),
1156
+ /* @__PURE__ */ jsx("dd", { children: tc("components.provider.disputes", {
1157
+ count: String(trackRecord.disputesLost)
1158
+ }) })
1159
+ ] })
1160
+ ] })
1161
+ ] });
1162
+ }
1163
+ var DEFAULT_TRUST_HREF = "https://agenc.tech/trust";
1164
+ var SAFE_HREF_SCHEMES = /* @__PURE__ */ new Set(["http:", "https:", "mailto:"]);
1165
+ function safeHref(href) {
1166
+ try {
1167
+ const url = new URL(href, DEFAULT_TRUST_HREF);
1168
+ return SAFE_HREF_SCHEMES.has(url.protocol) ? href : DEFAULT_TRUST_HREF;
1169
+ } catch {
1170
+ return DEFAULT_TRUST_HREF;
1171
+ }
1172
+ }
1173
+ function PoweredByAgenC({
1174
+ href = DEFAULT_TRUST_HREF,
1175
+ newTab = true,
1176
+ label,
1177
+ unstyled,
1178
+ className
1179
+ }) {
1180
+ const linkClass = rootClass("agenc-powered-by", unstyled, className);
1181
+ return /* @__PURE__ */ jsx(
1182
+ "a",
1183
+ {
1184
+ className: linkClass,
1185
+ href: safeHref(href),
1186
+ target: newTab ? "_blank" : void 0,
1187
+ rel: newTab ? "noopener noreferrer" : void 0,
1188
+ "aria-label": `${label ?? tc("components.poweredBy.label")} \u2014 ${tc(
1189
+ "components.poweredBy.trustLink"
1190
+ )}`,
1191
+ children: /* @__PURE__ */ jsx("span", { className: unstyled ? void 0 : "agenc-powered-by__label", children: label ?? tc("components.poweredBy.label") })
1192
+ }
1193
+ );
1194
+ }
1195
+
1196
+ export { AGENC_THEME_CLASS, AGENC_TOKENS_CSS_PATH, Badge, Button, COMPONENT_CATALOG, DEFAULT_TRUST_HREF, DisputeBanner, EN_COMPONENT_STRINGS, HireButton, HireCheckoutModal, ListingCard, ListingGrid, Modal, ModerationBadge, PoweredByAgenC, ProviderCard, ReferrerDisclosure, ReviewPanel, Spinner, StateMessage, TaskTimeline, VerifiedBadge, agencThemeStyleTag, cx, decodeListingCategory, decodeListingName, decodeListingTags, elementClass, formatPriceSol, formatRate, formatSol, moderationStateOf, resolveThemeClassName, rootClass, tc, toHex, truncateAddress, useFocusTrap };
1197
+ //# sourceMappingURL=chunk-KJMR6OGC.js.map
1198
+ //# sourceMappingURL=chunk-KJMR6OGC.js.map