@tetsuo-ai/marketplace-react 0.4.1 → 0.5.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 (84) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/README.md +93 -47
  3. package/dist/chunk-7NKRSPPN.js +227 -0
  4. package/dist/chunk-7NKRSPPN.js.map +1 -0
  5. package/dist/{chunk-JVXGNW3Q.js → chunk-CDDHUFMG.js} +6 -5
  6. package/dist/chunk-CDDHUFMG.js.map +1 -0
  7. package/dist/chunk-FIDFPM5A.cjs +40 -0
  8. package/dist/chunk-FIDFPM5A.cjs.map +1 -0
  9. package/dist/chunk-IJKWKY4H.cjs +1370 -0
  10. package/dist/chunk-IJKWKY4H.cjs.map +1 -0
  11. package/dist/chunk-JTSG5FGC.cjs +397 -0
  12. package/dist/chunk-JTSG5FGC.cjs.map +1 -0
  13. package/dist/chunk-ONC6L3IX.cjs +97 -0
  14. package/dist/chunk-ONC6L3IX.cjs.map +1 -0
  15. package/dist/chunk-R76EUYDI.cjs +233 -0
  16. package/dist/chunk-R76EUYDI.cjs.map +1 -0
  17. package/dist/{chunk-XLA7DARS.js → chunk-RG5JZ6JL.js} +159 -36
  18. package/dist/chunk-RG5JZ6JL.js.map +1 -0
  19. package/dist/components/index.cjs +158 -1594
  20. package/dist/components/index.cjs.map +1 -1
  21. package/dist/components/index.d.cts +2 -2
  22. package/dist/components/index.d.ts +2 -2
  23. package/dist/components/index.js +2 -2
  24. package/dist/hooks/index.cjs +656 -509
  25. package/dist/hooks/index.cjs.map +1 -1
  26. package/dist/hooks/index.d.cts +63 -29
  27. package/dist/hooks/index.d.ts +63 -29
  28. package/dist/hooks/index.js +619 -196
  29. package/dist/hooks/index.js.map +1 -1
  30. package/dist/{index-CmVz0OOm.d.ts → index-BAyr1ODZ.d.ts} +28 -3
  31. package/dist/{index-DAZzhuO4.d.cts → index-C20NVU7_.d.cts} +28 -3
  32. package/dist/index.cjs +284 -1833
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.d.cts +7 -8
  35. package/dist/index.d.ts +7 -8
  36. package/dist/index.js +64 -4
  37. package/dist/index.js.map +1 -1
  38. package/dist/signers/index.cjs +22 -161
  39. package/dist/signers/index.cjs.map +1 -1
  40. package/dist/signers/index.d.cts +16 -11
  41. package/dist/signers/index.d.ts +16 -11
  42. package/dist/signers/index.js +1 -1
  43. package/dist/testing/index.d.cts +1 -1
  44. package/dist/testing/index.d.ts +1 -1
  45. package/dist/theme/agenc-tailwind-preset.cjs +134 -108
  46. package/dist/{types-jvISR6bc.d.cts → types-B10rndEI.d.cts} +16 -7
  47. package/dist/{types-jvISR6bc.d.ts → types-B10rndEI.d.ts} +16 -7
  48. package/dist/{useAgentTrackRecord-DPt3SfYz.d.cts → useAgentTrackRecord-Ch7gHTFj.d.cts} +1 -1
  49. package/dist/{useAgentTrackRecord-DPt3SfYz.d.ts → useAgentTrackRecord-Ch7gHTFj.d.ts} +1 -1
  50. package/package.json +6 -3
  51. package/src/components/HireCheckoutModal.tsx +5 -2
  52. package/src/hooks/index.ts +1 -0
  53. package/src/hooks/internal.ts +178 -24
  54. package/src/hooks/useAgentTrackRecord.ts +5 -2
  55. package/src/hooks/useCompletionBond.ts +56 -21
  56. package/src/hooks/useDispute.ts +46 -9
  57. package/src/hooks/useHire.ts +113 -23
  58. package/src/hooks/useHumanlessHireFlow.ts +335 -115
  59. package/src/hooks/useListing.ts +2 -2
  60. package/src/hooks/useListings.ts +2 -2
  61. package/src/hooks/useRateHire.ts +32 -5
  62. package/src/hooks/useReferrerEarnings.ts +4 -1
  63. package/src/hooks/useSubmissionReview.ts +95 -32
  64. package/src/hooks/useTaskActivation.ts +51 -9
  65. package/src/hooks/useTaskGuarantee.ts +4 -1
  66. package/src/hooks/useTaskLifecycle.ts +104 -24
  67. package/src/hooks/useTaskStatus.ts +121 -26
  68. package/src/hooks/useTaskWork.ts +76 -12
  69. package/src/hooks/useWalletSigner.ts +11 -16
  70. package/src/index.ts +3 -0
  71. package/src/provider/AgencProvider.tsx +95 -3
  72. package/src/provider/referrer.ts +1 -1
  73. package/src/signers/README.md +13 -7
  74. package/src/signers/index.ts +6 -1
  75. package/src/signers/strings.ts +13 -1
  76. package/src/signers/types.ts +16 -5
  77. package/src/signers/wallet-account.ts +115 -29
  78. package/src/signers/wallet-adapter.ts +38 -4
  79. package/src/theme/agenc-tailwind-preset.cjs +134 -108
  80. package/src/types.ts +27 -1
  81. package/dist/chunk-JVXGNW3Q.js.map +0 -1
  82. package/dist/chunk-ON6XR4XO.js +0 -128
  83. package/dist/chunk-ON6XR4XO.js.map +0 -1
  84. package/dist/chunk-XLA7DARS.js.map +0 -1
@@ -1,1602 +1,166 @@
1
1
  'use strict';
2
2
 
3
- var marketplaceSdk = require('@tetsuo-ai/marketplace-sdk');
4
- var jsxRuntime = require('react/jsx-runtime');
5
- var reactQuery = require('@tanstack/react-query');
6
- var react = require('react');
7
- var kit = require('@solana/kit');
3
+ var chunkIJKWKY4H_cjs = require('../chunk-IJKWKY4H.cjs');
4
+ require('../chunk-JTSG5FGC.cjs');
5
+ require('../chunk-FIDFPM5A.cjs');
8
6
 
9
- // src/theme/index.ts
10
- var AGENC_THEME_CLASS = "agenc";
11
7
 
12
- // src/strings/index.ts
13
- var EN_STRINGS = {
14
- // Provider / context wiring errors (developer-facing, but routed for parity).
15
- "provider.missingContext": "useAgencContext must be used within <AgencProvider>.",
16
- "provider.missingWriteClient": "No write client is configured. Pass config.client, or config.rpcUrl + config.signer, to <AgencProvider> before using a mutating hook.",
17
- "provider.missingSigner": "No signer is configured on <AgencProvider>. Connect a wallet or pass config.signer.",
18
- // Referrer config validation / capability surface.
19
- "referrer.invalidWallet": "Referrer wallet is not a valid base58 Solana address: {wallet}.",
20
- "referrer.invalidFeeBps": "Referrer feeBps must be an integer between {min} and {max} (basis points); got {feeBps}.",
21
- "referrer.notLive": "Referral fee is not active for this hire.",
22
- "referrer.notLiveReason": "No referrer is configured for this provider.",
23
- "referrer.earningsNotLiveReason": "Referral settlement is live, but no earnings endpoint is available on this network (configure indexer.baseUrl).",
24
- "referrer.earningsFetchFailed": "The referrer earnings endpoint could not be read.",
25
- // Read transport.
26
- "transport.noReadSource": "No read source is configured. Pass an indexer baseUrl, an rpc/queryTransport, to <AgencProvider> or createReadTransport().",
27
- // Generic loading / empty / error states (components extend these).
28
- "state.loading": "Loading\u2026",
29
- "state.empty": "Nothing to show yet.",
30
- "state.error": "Something went wrong.",
31
- // Hire flow shells (components fill out the rest).
32
- "hire.cta": "Hire",
33
- "hire.pending": "Confirming\u2026",
34
- "hire.funded": "Escrow funded."
35
- };
36
- function t(id, vars, options) {
37
- const catalog = options?.catalog ?? EN_STRINGS;
38
- const template = catalog[id] ?? id;
39
- if (vars === void 0) return template;
40
- return template.replace(/\{(\w+)\}/g, (match, key) => {
41
- const value = vars[key];
42
- return value === void 0 ? match : String(value);
43
- });
44
- }
45
8
 
46
- // src/components/strings.ts
47
- var EN_COMPONENT_STRINGS = {
48
- // Shared / cross-component.
49
- "components.common.loading": "Loading\u2026",
50
- "components.common.empty": "Nothing to show yet.",
51
- "components.common.error": "Something went wrong.",
52
- "components.common.retry": "Retry",
53
- "components.common.close": "Close",
54
- "components.common.verified": "Verified",
55
- "components.common.unverified": "Unverified",
56
- "components.common.sol": "SOL",
57
- "components.common.lamports": "lamports",
58
- // ListingCard.
59
- "components.listingCard.priceLabel": "Price",
60
- "components.listingCard.byProvider": "by {provider}",
61
- "components.listingCard.untitled": "Untitled service",
62
- "components.listingCard.hires": "{count} hires",
63
- "components.listingCard.category": "Category",
64
- // ListingGrid.
65
- "components.listingGrid.empty": "No listings match your filters yet.",
66
- "components.listingGrid.loadMore": "Load more",
67
- "components.listingGrid.error": "Could not load listings.",
68
- // HireButton / Checkout.
69
- "components.hire.cta": "Hire",
70
- "components.hire.ctaPrice": "Hire \u2014 {price}",
71
- "components.hire.checkoutTitle": "Confirm hire",
72
- "components.hire.priceLabel": "You pay",
73
- "components.hire.escrowNote": "Funds are held in protocol escrow and released to the provider only when you accept the result.",
74
- "components.hire.confirm": "Confirm and fund escrow",
75
- "components.hire.cancel": "Cancel",
76
- "components.hire.pending": "Confirming\u2026",
77
- "components.hire.success": "Escrow funded.",
78
- "components.hire.successDetail": "Your task is created. Track it below.",
79
- "components.hire.viewTask": "View task",
80
- "components.hire.errorTitle": "Hire failed",
81
- "components.hire.moderationAttested": "Moderation attested",
82
- "components.hire.moderationPending": "Moderation pending",
83
- "components.hire.moderationIssues": "Moderation issues found",
84
- "components.hire.notConnected": "Connect a wallet to hire.",
85
- // Referrer disclosure.
86
- "components.referrer.disclosure": "This site earns a referral fee.",
87
- "components.referrer.disclosurePending": "Referral fee is not active for this hire.",
88
- "components.referrer.feeBps": "{bps} bps",
89
- // TaskTimeline.
90
- "components.taskTimeline.title": "Task progress",
91
- "components.taskTimeline.empty": "No task to track yet.",
92
- "components.taskTimeline.status.Open": "Open",
93
- "components.taskTimeline.status.InProgress": "In progress",
94
- "components.taskTimeline.status.PendingValidation": "Pending review",
95
- "components.taskTimeline.status.Completed": "Completed",
96
- "components.taskTimeline.status.Cancelled": "Cancelled",
97
- "components.taskTimeline.status.Disputed": "Disputed",
98
- "components.taskTimeline.status.RejectFrozen": "Rejected (frozen)",
99
- // ReviewPanel.
100
- "components.review.title": "Review submission",
101
- "components.review.noSubmission": "Awaiting the worker's submission.",
102
- "components.review.accept": "Accept and release escrow",
103
- "components.review.reject": "Reject",
104
- "components.review.requestChanges": "Request changes",
105
- "components.review.accepted": "Result accepted. Escrow released.",
106
- "components.review.rejected": "Result rejected.",
107
- "components.review.changesRequested": "Changes requested.",
108
- "components.review.pending": "Submitting\u2026",
109
- "components.review.errorTitle": "Review action failed",
110
- // DisputeBanner.
111
- "components.dispute.title": "This task is in dispute.",
112
- "components.dispute.body": "A dispute has been opened. A protocol resolver decides the outcome; funds stay in escrow until then.",
113
- "components.dispute.initiate": "Open a dispute",
114
- "components.dispute.pending": "Opening dispute\u2026",
115
- "components.dispute.opened": "Dispute opened.",
116
- "components.dispute.none": "No open dispute.",
117
- "components.dispute.errorTitle": "Could not open dispute",
118
- // ProviderCard.
119
- "components.provider.title": "Provider",
120
- "components.provider.completionRate": "Completion rate",
121
- "components.provider.disputeRate": "Dispute rate",
122
- "components.provider.completions": "{count} completed",
123
- "components.provider.disputes": "{count} disputes",
124
- "components.provider.provisional": "provisional",
125
- "components.provider.noData": "No track record yet.",
126
- "components.provider.unavailable": "Track record is unavailable on this read transport.",
127
- // Domain trust (P7.3) — VERIFIED is an on-chain attestation; CLAIMED is the
128
- // operator's self-reported metadata. The copy keeps them distinct so a buyer
129
- // never reads an unverified claim as a proven one.
130
- "components.provider.verifiedDomain": "Verified: {domain}",
131
- "components.provider.verifiedDomainLabel": "Verified domain {domain}",
132
- "components.provider.claimedDomain": "Claims: {domain}",
133
- "components.provider.claimedDomainLabel": "Claimed domain {domain} (not verified on-chain)",
134
- // GuaranteedBadge (WP-H3 Guaranteed Hire). The detail copy is deliberately
135
- // phase-1-honest: the buyer is refunded (escrow) and the worker FORFEITS the
136
- // bond — it does NOT say the buyer receives the bond, because a forfeited
137
- // bond pays the protocol treasury until phase 2 redirects it.
138
- "components.guarantee.badge": "Guaranteed \u2014 worker has 25% at stake",
139
- "components.guarantee.detail": "Worker has 25% at stake \u2014 if the result fails review you're refunded and the worker forfeits the bond.",
140
- // PoweredByAgenC.
141
- "components.poweredBy.label": "Powered by AgenC",
142
- "components.poweredBy.trustLink": "Learn how this works"
143
- };
144
- var COMPONENT_CATALOG = {
145
- ...EN_STRINGS,
146
- ...EN_COMPONENT_STRINGS
147
- };
148
-
149
- // src/components/format.ts
150
- function tc(id, vars, options) {
151
- return t(id, vars, { catalog: COMPONENT_CATALOG, ...options });
152
- }
153
- var LAMPORTS_PER_SOL = 1000000000n;
154
- function formatSol(lamports) {
155
- const negative = lamports < 0n;
156
- const abs = negative ? -lamports : lamports;
157
- const whole = abs / LAMPORTS_PER_SOL;
158
- const frac = abs % LAMPORTS_PER_SOL;
159
- let out;
160
- if (frac === 0n) {
161
- out = whole.toString();
162
- } else {
163
- const fracStr = frac.toString().padStart(9, "0").replace(/0+$/, "");
164
- out = `${whole.toString()}.${fracStr}`;
165
- }
166
- return negative ? `-${out}` : out;
167
- }
168
- function formatPriceSol(lamports, options) {
169
- return `${formatSol(lamports)} ${t("components.common.sol", void 0, {
170
- catalog: COMPONENT_CATALOG,
171
- ...options
172
- })}`;
173
- }
174
- function truncateAddress(value, head = 4, tail = 4) {
175
- if (value === null || value === void 0) return "";
176
- const s = String(value);
177
- if (s.length <= head + tail + 1) return s;
178
- return `${s.slice(0, head)}\u2026${s.slice(-tail)}`;
179
- }
180
- function decodeListingName(listing) {
181
- try {
182
- return marketplaceSdk.values.decodeListingName(Uint8Array.from(listing.name));
183
- } catch {
184
- return "";
185
- }
186
- }
187
- function decodeListingCategory(listing) {
188
- try {
189
- return marketplaceSdk.values.decodeListingCategory(Uint8Array.from(listing.category));
190
- } catch {
191
- return "";
192
- }
193
- }
194
- function decodeListingTags(listing) {
195
- try {
196
- return marketplaceSdk.values.decodeListingTags(Uint8Array.from(listing.tags));
197
- } catch {
198
- return [];
199
- }
200
- }
201
- function toHex(bytes) {
202
- let out = "";
203
- for (let i = 0; i < bytes.length; i++) {
204
- out += bytes[i].toString(16).padStart(2, "0");
205
- }
206
- return out;
207
- }
208
- function formatRate(rate, fallback = "\u2014") {
209
- if (rate === null || Number.isNaN(rate)) return fallback;
210
- const pct = Math.round(rate * 100);
211
- return `${pct}%`;
212
- }
213
- function cx(...parts) {
214
- return parts.filter((p) => Boolean(p)).join(" ");
215
- }
216
- function elementClass(base, unstyled, extra) {
217
- if (unstyled) return extra && extra.trim() !== "" ? extra : void 0;
218
- return cx(base, extra) || void 0;
219
- }
220
- function rootClass(base, unstyled, extra) {
221
- if (unstyled) return extra && extra.trim() !== "" ? extra : void 0;
222
- return cx(AGENC_THEME_CLASS, base, extra) || void 0;
223
- }
224
- var STATE_STRING = {
225
- loading: "components.common.loading",
226
- empty: "components.common.empty",
227
- error: "components.common.error"
228
- };
229
- function StateMessage({
230
- kind,
231
- message,
232
- onRetry,
233
- role,
234
- unstyled,
235
- className
236
- }) {
237
- const text = message ?? tc(STATE_STRING[kind]);
238
- const resolvedRole = role ?? (kind === "error" ? "alert" : "status");
239
- return /* @__PURE__ */ jsxRuntime.jsxs(
240
- "div",
241
- {
242
- className: elementClass(`agenc-state agenc-state--${kind}`, unstyled, className),
243
- role: resolvedRole,
244
- "aria-live": kind === "error" ? "assertive" : "polite",
245
- "aria-busy": kind === "loading" ? true : void 0,
246
- children: [
247
- kind === "loading" ? /* @__PURE__ */ jsxRuntime.jsx(Spinner, { unstyled }) : null,
248
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: unstyled ? void 0 : "agenc-state__text", children: text }),
249
- onRetry && kind !== "loading" ? /* @__PURE__ */ jsxRuntime.jsx(Button, { unstyled, variant: "ghost", onClick: onRetry, children: tc("components.common.retry") }) : null
250
- ]
251
- }
252
- );
253
- }
254
- function Spinner({ label, unstyled, className }) {
255
- return /* @__PURE__ */ jsxRuntime.jsx(
256
- "span",
257
- {
258
- className: elementClass("agenc-spinner", unstyled, className),
259
- role: "status",
260
- "aria-live": "polite",
261
- children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: unstyled ? void 0 : "agenc-visually-hidden", children: label ?? tc("components.common.loading") })
262
- }
263
- );
264
- }
265
- function Badge({
266
- tone = "neutral",
267
- children,
268
- label,
269
- unstyled,
270
- className
271
- }) {
272
- return /* @__PURE__ */ jsxRuntime.jsx(
273
- "span",
274
- {
275
- className: elementClass(
276
- `agenc-badge agenc-badge--${tone}`,
277
- unstyled,
278
- className
279
- ),
280
- title: label,
281
- "aria-label": label,
282
- children
283
- }
284
- );
285
- }
286
- function Button({
287
- variant = "primary",
288
- loading = false,
289
- unstyled,
290
- className,
291
- children,
292
- disabled,
293
- type,
294
- ...rest
295
- }) {
296
- return /* @__PURE__ */ jsxRuntime.jsxs(
297
- "button",
298
- {
299
- type: type ?? "button",
300
- className: elementClass(
301
- `agenc-button agenc-button--${variant}`,
302
- unstyled,
303
- className
304
- ),
305
- disabled: disabled || loading,
306
- "aria-busy": loading || void 0,
307
- ...rest,
308
- children: [
309
- loading ? /* @__PURE__ */ jsxRuntime.jsx(Spinner, { unstyled }) : null,
310
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: unstyled ? void 0 : "agenc-button__label", children })
311
- ]
312
- }
313
- );
314
- }
315
- function moderationStateOf(moderation) {
316
- if (!moderation) return "pending";
317
- return moderation.metadataValid ? "attested" : "issues";
318
- }
319
- var MODERATION_TONE = {
320
- attested: "success",
321
- pending: "neutral",
322
- issues: "warning"
323
- };
324
- var MODERATION_STRING = {
325
- attested: "components.hire.moderationAttested",
326
- pending: "components.hire.moderationPending",
327
- // Distinct from `pending` ("Moderation pending") so a buyer can textually
328
- // tell "we found problems" apart from "we haven't checked", not just by tone.
329
- issues: "components.hire.moderationIssues"
330
- };
331
- function ModerationBadge({
332
- moderation,
333
- state,
334
- unstyled,
335
- className
336
- }) {
337
- const resolved = state ?? moderationStateOf(moderation);
338
- const label = tc(MODERATION_STRING[resolved]);
339
- const issues = resolved === "issues" && moderation?.metadataIssues?.length ? moderation.metadataIssues.join("; ") : void 0;
340
- return /* @__PURE__ */ jsxRuntime.jsx(
341
- Badge,
342
- {
343
- tone: MODERATION_TONE[resolved],
344
- unstyled,
345
- className,
346
- label: issues ?? label,
347
- children: label
348
- }
349
- );
350
- }
351
- function VerifiedBadge({
352
- verified,
353
- unstyled,
354
- className
355
- }) {
356
- return /* @__PURE__ */ jsxRuntime.jsx(
357
- Badge,
358
- {
359
- tone: verified ? "success" : "neutral",
360
- unstyled,
361
- className,
362
- children: verified ? tc("components.common.verified") : tc("components.common.unverified")
363
- }
364
- );
365
- }
366
- var AgencContext = react.createContext(null);
367
- AgencContext.displayName = "AgencContext";
368
- function useAgencContext() {
369
- const ctx = react.useContext(AgencContext);
370
- if (ctx === null) {
371
- throw new Error(t("provider.missingContext"));
372
- }
373
- return ctx;
374
- }
375
-
376
- // src/hooks/internal.ts
377
- var QUERY_KEY_ROOT = "agenc";
378
- var queryKeys = {
379
- /** All listings list queries (with their filter object as the leaf). */
380
- listings: (filter) => [QUERY_KEY_ROOT, "listings", filter ?? null],
381
- /** One listing + its joined provider/track-record/moderation. */
382
- listing: (pda) => [QUERY_KEY_ROOT, "listing", pda],
383
- /** One agent's indexer track record. */
384
- agentTrackRecord: (agentPda) => [QUERY_KEY_ROOT, "agentTrackRecord", agentPda],
385
- /** One task's status (read via transport / svm decode). */
386
- taskStatus: (taskPda) => [QUERY_KEY_ROOT, "taskStatus", taskPda],
387
- /** One task's dispute record. */
388
- dispute: (taskPda) => [QUERY_KEY_ROOT, "dispute", taskPda],
389
- /** One task's completion-bond ("Guaranteed Hire") state. */
390
- taskGuarantee: (taskPda) => [QUERY_KEY_ROOT, "taskGuarantee", taskPda],
391
- /** One referrer wallet's earnings (indexer-gated; see useReferrerEarnings). */
392
- referrerEarnings: (wallet) => [QUERY_KEY_ROOT, "referrerEarnings", wallet]
393
- };
394
- function requireClient(client) {
395
- if (client === null) {
396
- throw new Error(t("provider.missingWriteClient"));
397
- }
398
- return client;
399
- }
400
- function pdaKey(pda) {
401
- return String(pda);
402
- }
403
- function resolveReferrerArgs(ctx) {
404
- const capability = ctx.resolveReferrerCapability();
405
- if (!capability.live || !capability.referrer) {
406
- return { referrerArgs: {}, referrerInjected: false };
407
- }
408
- return {
409
- referrerArgs: {
410
- referrer: capability.referrer.wallet,
411
- referrerFeeBps: capability.referrer.feeBps
412
- },
413
- referrerInjected: true
414
- };
415
- }
416
- function signerAddress(signerOrAddress) {
417
- if (typeof signerOrAddress === "string") {
418
- return signerOrAddress;
419
- }
420
- if (typeof signerOrAddress === "object" && signerOrAddress !== null && "address" in signerOrAddress && typeof signerOrAddress.address === "string") {
421
- return signerOrAddress.address;
422
- }
423
- throw new Error("Expected a TransactionSigner or Address with an address field.");
424
- }
425
- function withoutReferrerArgs(input) {
426
- const {
427
- referrer: _referrer,
428
- referrerFeeBps: _referrerFeeBps,
429
- ...rest
430
- } = input;
431
- return rest;
432
- }
433
-
434
- // src/hooks/useTaskGuarantee.ts
435
- function useTaskGuarantee(taskPda, options) {
436
- const ctx = useAgencContext();
437
- const injected = options?.guaranteeReader;
438
- const rpcUrl = ctx.rpcUrl;
439
- const reader = react.useMemo(() => {
440
- if (injected) return injected;
441
- if (!rpcUrl) return null;
442
- return (pda) => marketplaceSdk.fetchTaskGuarantee(
443
- kit.createSolanaRpc(rpcUrl),
444
- pda
445
- );
446
- }, [injected, rpcUrl]);
447
- const enabled = (options?.enabled ?? true) && Boolean(taskPda) && reader !== null;
448
- const query = reactQuery.useQuery({
449
- queryKey: queryKeys.taskGuarantee(taskPda ? pdaKey(taskPda) : ""),
450
- enabled,
451
- queryFn: () => reader(taskPda)
452
- });
453
- const guarantee = query.data ?? null;
454
- return {
455
- guarantee,
456
- guaranteed: guarantee?.guaranteed ?? false,
457
- isLoading: query.isLoading,
458
- error: query.error ?? null,
459
- refetch: () => void query.refetch()
460
- };
461
- }
462
- function GuaranteedBadge({
463
- task,
464
- guarantee,
465
- guaranteeReader,
466
- unstyled,
467
- className
468
- }) {
469
- const overridden = guarantee !== void 0;
470
- const read = useTaskGuarantee(overridden ? null : task, {
471
- guaranteeReader,
472
- enabled: !overridden
473
- });
474
- const resolved = overridden ? guarantee : read.guarantee;
475
- if (!resolved?.guaranteed) return null;
476
- return /* @__PURE__ */ jsxRuntime.jsx(
477
- Badge,
478
- {
479
- tone: "success",
480
- unstyled,
481
- className,
482
- label: tc("components.guarantee.detail"),
483
- children: tc("components.guarantee.badge")
484
- }
485
- );
486
- }
487
- var FOCUSABLE_SELECTOR = [
488
- "a[href]",
489
- "button:not([disabled])",
490
- "textarea:not([disabled])",
491
- "input:not([disabled])",
492
- "select:not([disabled])",
493
- '[tabindex]:not([tabindex="-1"])'
494
- ].join(",");
495
- function focusableWithin(container) {
496
- return Array.from(
497
- container.querySelectorAll(FOCUSABLE_SELECTOR)
498
- ).filter((el) => el.offsetParent !== null || el === document.activeElement);
499
- }
500
- function useFocusTrap(containerRef, active, onEscape) {
501
- react.useEffect(() => {
502
- if (!active) return;
503
- const container = containerRef.current;
504
- if (!container) return;
505
- const previouslyFocused = document.activeElement instanceof HTMLElement ? document.activeElement : null;
506
- const initial = focusableWithin(container)[0] ?? container;
507
- initial.focus();
508
- function onKeyDown(event) {
509
- if (event.key === "Escape") {
510
- event.stopPropagation();
511
- onEscape?.();
512
- return;
513
- }
514
- if (event.key !== "Tab") return;
515
- const focusable = focusableWithin(container);
516
- if (focusable.length === 0) {
517
- event.preventDefault();
518
- container.focus();
519
- return;
520
- }
521
- const first = focusable[0];
522
- const last = focusable[focusable.length - 1];
523
- const activeEl = document.activeElement;
524
- if (event.shiftKey) {
525
- if (activeEl === first || activeEl === container) {
526
- event.preventDefault();
527
- last.focus();
528
- }
529
- } else if (activeEl === last) {
530
- event.preventDefault();
531
- first.focus();
532
- }
533
- }
534
- function onFocusIn(event) {
535
- const target = event.target;
536
- if (!(target instanceof Node)) return;
537
- if (container.contains(target)) return;
538
- event.stopPropagation();
539
- const focusable = focusableWithin(container);
540
- (focusable[0] ?? container).focus();
541
- }
542
- container.addEventListener("keydown", onKeyDown);
543
- document.addEventListener("focusin", onFocusIn);
544
- return () => {
545
- container.removeEventListener("keydown", onKeyDown);
546
- document.removeEventListener("focusin", onFocusIn);
547
- previouslyFocused?.focus();
548
- };
549
- }, [containerRef, active, onEscape]);
550
- }
551
- function Modal({
552
- open,
553
- onClose,
554
- title,
555
- children,
556
- footer,
557
- disableEscapeClose = false,
558
- disableOverlayClose = false,
559
- hideCloseButton = false,
560
- closeLabel,
561
- unstyled,
562
- className
563
- }) {
564
- const dialogRef = react.useRef(null);
565
- const titleId = react.useId();
566
- const bodyId = react.useId();
567
- useFocusTrap(dialogRef, open, () => {
568
- if (!disableEscapeClose) onClose();
569
- });
570
- if (!open) return null;
571
- const overlayClass = rootClass("agenc-modal", unstyled, className);
572
- return /* @__PURE__ */ jsxRuntime.jsx(
573
- "div",
574
- {
575
- className: overlayClass,
576
- onMouseDown: (event) => {
577
- if (disableOverlayClose) return;
578
- if (event.target === event.currentTarget) onClose();
579
- },
580
- children: /* @__PURE__ */ jsxRuntime.jsxs(
581
- "div",
582
- {
583
- className: unstyled ? void 0 : "agenc-modal__dialog",
584
- ref: dialogRef,
585
- role: "dialog",
586
- "aria-modal": "true",
587
- "aria-labelledby": titleId,
588
- "aria-describedby": bodyId,
589
- tabIndex: -1,
590
- children: [
591
- /* @__PURE__ */ jsxRuntime.jsxs("header", { className: unstyled ? void 0 : "agenc-modal__header", children: [
592
- /* @__PURE__ */ jsxRuntime.jsx("h2", { id: titleId, className: unstyled ? void 0 : "agenc-modal__title", children: title }),
593
- hideCloseButton ? null : /* @__PURE__ */ jsxRuntime.jsx(
594
- "button",
595
- {
596
- type: "button",
597
- className: unstyled ? void 0 : "agenc-modal__close",
598
- "aria-label": closeLabel ?? tc("components.common.close"),
599
- onClick: onClose,
600
- children: /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", children: "\xD7" })
601
- }
602
- )
603
- ] }),
604
- /* @__PURE__ */ jsxRuntime.jsx("div", { id: bodyId, className: unstyled ? void 0 : "agenc-modal__body", children }),
605
- footer ? /* @__PURE__ */ jsxRuntime.jsx("footer", { className: unstyled ? void 0 : "agenc-modal__footer", children: footer }) : null
606
- ]
607
- }
608
- )
609
- }
610
- );
611
- }
612
- function ListingCard({
613
- listing,
614
- moderation,
615
- onHire,
616
- onSelect,
617
- hidePrice = false,
618
- unstyled,
619
- className
620
- }) {
621
- const { account } = listing;
622
- const name = decodeListingName(account) || tc("components.listingCard.untitled");
623
- const category = decodeListingCategory(account);
624
- const price = formatPriceSol(account.price);
625
- const provider = truncateAddress(account.providerAgent);
626
- const hires = account.totalHires;
627
- const cardClass = rootClass("agenc-listing-card", unstyled, className);
628
- const selectable = Boolean(onSelect);
629
- const heading = /* @__PURE__ */ jsxRuntime.jsx("h3", { className: unstyled ? void 0 : "agenc-listing-card__title", children: name });
630
- return /* @__PURE__ */ jsxRuntime.jsxs(
631
- "article",
632
- {
633
- className: cardClass,
634
- "aria-label": name,
635
- children: [
636
- /* @__PURE__ */ jsxRuntime.jsxs("header", { className: unstyled ? void 0 : "agenc-listing-card__header", children: [
637
- selectable ? /* @__PURE__ */ jsxRuntime.jsx(
638
- "button",
639
- {
640
- type: "button",
641
- className: unstyled ? void 0 : "agenc-listing-card__title-button",
642
- onClick: () => onSelect?.(listing),
643
- children: heading
644
- }
645
- ) : heading,
646
- /* @__PURE__ */ jsxRuntime.jsx(ModerationBadge, { moderation, unstyled })
647
- ] }),
648
- /* @__PURE__ */ jsxRuntime.jsxs("dl", { className: unstyled ? void 0 : "agenc-listing-card__meta", children: [
649
- category ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: unstyled ? void 0 : "agenc-listing-card__meta-row", children: [
650
- /* @__PURE__ */ jsxRuntime.jsx("dt", { children: tc("components.listingCard.category") }),
651
- /* @__PURE__ */ jsxRuntime.jsx("dd", { children: /* @__PURE__ */ jsxRuntime.jsx(Badge, { tone: "info", unstyled, children: category }) })
652
- ] }) : null,
653
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: unstyled ? void 0 : "agenc-listing-card__meta-row", children: [
654
- /* @__PURE__ */ jsxRuntime.jsx("dt", { children: tc("components.listingCard.byProvider", { provider }) }),
655
- /* @__PURE__ */ jsxRuntime.jsx("dd", { children: tc("components.listingCard.hires", { count: String(hires) }) })
656
- ] })
657
- ] }),
658
- /* @__PURE__ */ jsxRuntime.jsxs("footer", { className: unstyled ? void 0 : "agenc-listing-card__footer", children: [
659
- hidePrice ? null : /* @__PURE__ */ jsxRuntime.jsxs("p", { className: unstyled ? void 0 : "agenc-listing-card__price", children: [
660
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: unstyled ? void 0 : "agenc-listing-card__price-label", children: tc("components.listingCard.priceLabel") }),
661
- " ",
662
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: unstyled ? void 0 : "agenc-listing-card__price-value", children: price })
663
- ] }),
664
- onHire ? /* @__PURE__ */ jsxRuntime.jsx(
665
- Button,
666
- {
667
- unstyled,
668
- variant: "primary",
669
- onClick: () => onHire(listing),
670
- children: tc("components.hire.cta")
671
- }
672
- ) : null
673
- ] })
674
- ]
675
- }
676
- );
677
- }
678
- function ListingGrid({
679
- listings,
680
- isLoading = false,
681
- error = null,
682
- hasMore = false,
683
- onLoadMore,
684
- onRetry,
685
- onHire,
686
- onSelect,
687
- moderationByPda,
688
- emptyMessage,
689
- unstyled,
690
- className
691
- }) {
692
- const gridClass = rootClass("agenc-listing-grid", unstyled, className);
693
- if (error) {
694
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: gridClass, children: /* @__PURE__ */ jsxRuntime.jsx(
695
- StateMessage,
696
- {
697
- kind: "error",
698
- message: tc("components.listingGrid.error"),
699
- onRetry,
700
- unstyled
701
- }
702
- ) });
703
- }
704
- if (isLoading && listings.length === 0) {
705
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: gridClass, children: /* @__PURE__ */ jsxRuntime.jsx(StateMessage, { kind: "loading", unstyled }) });
706
- }
707
- if (listings.length === 0) {
708
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: gridClass, children: /* @__PURE__ */ jsxRuntime.jsx(
709
- StateMessage,
710
- {
711
- kind: "empty",
712
- message: emptyMessage ?? tc("components.listingGrid.empty"),
713
- unstyled
714
- }
715
- ) });
716
- }
717
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: gridClass, children: [
718
- /* @__PURE__ */ jsxRuntime.jsx(
719
- "ul",
720
- {
721
- className: unstyled ? void 0 : "agenc-listing-grid__list",
722
- children: listings.map((listing) => /* @__PURE__ */ jsxRuntime.jsx(
723
- "li",
724
- {
725
- className: unstyled ? void 0 : "agenc-listing-grid__item",
726
- children: /* @__PURE__ */ jsxRuntime.jsx(
727
- ListingCard,
728
- {
729
- listing,
730
- moderation: moderationByPda?.[String(listing.address)] ?? null,
731
- onHire,
732
- onSelect,
733
- unstyled
734
- }
735
- )
736
- },
737
- String(listing.address)
738
- ))
739
- }
740
- ),
741
- hasMore && onLoadMore ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: unstyled ? void 0 : "agenc-listing-grid__more", children: /* @__PURE__ */ jsxRuntime.jsx(
742
- "button",
743
- {
744
- type: "button",
745
- className: unstyled ? void 0 : "agenc-button agenc-button--secondary",
746
- onClick: onLoadMore,
747
- children: tc("components.listingGrid.loadMore")
748
- }
749
- ) }) : null
750
- ] });
751
- }
752
- function readRpc(input) {
753
- return input.rpc ?? (input.rpcUrl ? kit.createSolanaRpc(input.rpcUrl) : null);
754
- }
755
- async function resolveRosterEntry(rpc, moderator) {
756
- const [moderationConfigPda] = await marketplaceSdk.findModerationConfigPda();
757
- const moderationConfig = await marketplaceSdk.fetchMaybeModerationConfig(
758
- rpc,
759
- moderationConfigPda
760
- );
761
- if (moderationConfig.exists && moderationConfig.data.moderationAuthority === moderator) {
762
- return void 0;
763
- }
764
- const [rosterPda] = await marketplaceSdk.findModerationAttestorPda({ attestor: moderator });
765
- const roster = await marketplaceSdk.fetchMaybeModerationAttestor(rpc, rosterPda);
766
- return roster.exists ? rosterPda : void 0;
767
- }
768
- async function resolveHireListingModerationAccounts(input) {
769
- try {
770
- const rpc = readRpc(input);
771
- if (!rpc) return {};
772
- const moderationAttestor = await resolveRosterEntry(rpc, input.moderator);
773
- const attestorPart = moderationAttestor !== void 0 ? { moderationAttestor } : {};
774
- const [v2Pda] = await marketplaceSdk.findListingModerationPda({
775
- listing: input.listing,
776
- jobSpecHash: input.listingSpecHash,
777
- moderator: input.moderator
778
- });
779
- const v2 = await marketplaceSdk.fetchMaybeListingModeration(rpc, v2Pda);
780
- if (v2.exists) return attestorPart;
781
- const [legacyPda] = await marketplaceSdk.facade.findLegacyListingModerationPda({
782
- listing: input.listing,
783
- jobSpecHash: input.listingSpecHash
784
- });
785
- const legacy = await marketplaceSdk.fetchMaybeListingModeration(rpc, legacyPda);
786
- if (legacy.exists && legacy.data.moderator === input.moderator) {
787
- return { ...attestorPart, listingModeration: legacyPda };
788
- }
789
- return attestorPart;
790
- } catch {
791
- return {};
792
- }
793
- }
794
-
795
- // src/hooks/useHire.ts
796
- function useHire() {
797
- const ctx = useAgencContext();
798
- const mutation = reactQuery.useMutation({
799
- mutationFn: async (input) => {
800
- const client = requireClient(ctx.client);
801
- const { referrerArgs, referrerInjected } = resolveReferrerArgs(ctx);
802
- const hireInput = withoutReferrerArgs(input);
803
- const listingSpecHash = input.listingSpecHash;
804
- let moderationArgs = {};
805
- if (input.moderationAttestor === void 0 && input.moderatorIsAttestor === void 0 && input.listingModeration === void 0 && listingSpecHash !== void 0) {
806
- moderationArgs = await resolveHireListingModerationAccounts({
807
- rpcUrl: ctx.rpcUrl,
808
- listing: input.listing,
809
- listingSpecHash,
810
- moderator: input.moderator
811
- });
812
- }
813
- const creator = input.creator ?? client.signer;
814
- let signature;
815
- if (input.humanless === true) {
816
- const result = await client.hireFromListingHumanless({
817
- ...hireInput,
818
- ...moderationArgs,
819
- creator,
820
- ...referrerArgs
821
- });
822
- signature = result.signature;
823
- } else {
824
- const authority = input.authority ?? client.signer;
825
- const result = await client.hireFromListing({
826
- ...hireInput,
827
- ...moderationArgs,
828
- authority,
829
- creator,
830
- ...referrerArgs
831
- });
832
- signature = result.signature;
833
- }
834
- const [taskPda] = await marketplaceSdk.findTaskPda({
835
- creator: signerAddress(creator),
836
- taskId: input.taskId
837
- });
838
- return { signature, taskPda, referrerInjected };
839
- }
840
- });
841
- const hire = react.useCallback(
842
- (input) => mutation.mutateAsync(input),
843
- [mutation]
844
- );
845
- const status = react.useMemo(() => {
846
- if (mutation.isPending) return "pending";
847
- if (mutation.isError) return "error";
848
- if (mutation.isSuccess) return "success";
849
- return "idle";
850
- }, [mutation.isPending, mutation.isError, mutation.isSuccess]);
851
- return {
852
- hire,
853
- status,
854
- taskPda: mutation.data?.taskPda ?? null,
855
- signature: mutation.data?.signature ?? null,
856
- error: mutation.error ?? null,
857
- isPending: mutation.isPending,
858
- reset: mutation.reset
859
- };
860
- }
861
- function useWalletSigner(options) {
862
- const ctx = useAgencContext();
863
- const adapter = options?.adapter;
864
- const signer = ctx.signer ?? null;
865
- const connected = adapter !== void 0 ? adapter.connected ?? adapter.signer !== null : ctx.signer !== null;
866
- const connect = react.useCallback(() => {
867
- return void 0;
868
- }, [adapter]);
869
- return { signer, connected, connect };
870
- }
871
- function ReferrerDisclosure({
872
- referrer,
873
- live = false,
874
- showFee = true,
875
- unstyled,
876
- className
877
- }) {
878
- const text = live ? tc("components.referrer.disclosure") : tc("components.referrer.disclosurePending");
879
- return /* @__PURE__ */ jsxRuntime.jsxs(
880
- "p",
881
- {
882
- className: unstyled ? className : cx("agenc-referrer-disclosure", className),
883
- role: "note",
884
- children: [
885
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: text }),
886
- showFee ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: unstyled ? void 0 : "agenc-referrer-disclosure__fee", children: [
887
- " ",
888
- tc("components.referrer.feeBps", { bps: String(referrer.feeBps) })
889
- ] }) : null
890
- ]
891
- }
892
- );
893
- }
894
- function HireCheckoutModal({
895
- open,
896
- onClose,
897
- listing,
898
- onConfirm,
899
- status = "idle",
900
- error = null,
901
- taskPda = null,
902
- onViewTask,
903
- moderation,
904
- referrer,
905
- referrerLive = false,
906
- connected = true,
907
- unstyled,
908
- className
909
- }) {
910
- const pending = status === "pending";
911
- const success = status === "success";
912
- const price = formatPriceSol(listing.account.price);
913
- const [submitting, setSubmitting] = react.useState(false);
914
- const submittingRef = react.useRef(false);
915
- react.useEffect(() => {
916
- if (!open || !pending) {
917
- submittingRef.current = false;
918
- setSubmitting(false);
919
- }
920
- }, [open, pending]);
921
- const handleConfirm = react.useCallback(() => {
922
- if (submittingRef.current) return;
923
- submittingRef.current = true;
924
- setSubmitting(true);
925
- let result;
926
- try {
927
- result = onConfirm();
928
- } catch {
929
- submittingRef.current = false;
930
- setSubmitting(false);
931
- return;
932
- }
933
- if (result && typeof result.then === "function") {
934
- void result.finally(() => {
935
- submittingRef.current = false;
936
- setSubmitting(false);
937
- });
938
- }
939
- }, [onConfirm]);
940
- const confirmDisabled = !connected || pending || submitting;
941
- const lockClose = pending || submitting;
942
- const footer = success ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
943
- taskPda && onViewTask ? /* @__PURE__ */ jsxRuntime.jsx(
944
- Button,
945
- {
946
- unstyled,
947
- variant: "primary",
948
- onClick: () => onViewTask(taskPda),
949
- children: tc("components.hire.viewTask")
950
- }
951
- ) : null,
952
- /* @__PURE__ */ jsxRuntime.jsx(Button, { unstyled, variant: "secondary", onClick: onClose, children: tc("components.common.close") })
953
- ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
954
- /* @__PURE__ */ jsxRuntime.jsx(
955
- Button,
956
- {
957
- unstyled,
958
- variant: "secondary",
959
- onClick: onClose,
960
- disabled: pending || submitting,
961
- children: tc("components.hire.cancel")
962
- }
963
- ),
964
- /* @__PURE__ */ jsxRuntime.jsx(
965
- Button,
966
- {
967
- unstyled,
968
- variant: "primary",
969
- loading: pending || submitting,
970
- disabled: confirmDisabled,
971
- onClick: handleConfirm,
972
- children: pending || submitting ? tc("components.hire.pending") : tc("components.hire.confirm")
973
- }
974
- )
975
- ] });
976
- return /* @__PURE__ */ jsxRuntime.jsx(
977
- Modal,
978
- {
979
- open,
980
- onClose,
981
- title: tc("components.hire.checkoutTitle"),
982
- footer,
983
- disableEscapeClose: lockClose,
984
- disableOverlayClose: lockClose,
985
- hideCloseButton: lockClose,
986
- unstyled,
987
- className,
988
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: unstyled ? void 0 : "agenc-checkout", children: [
989
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: unstyled ? void 0 : "agenc-checkout__row", children: [
990
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: unstyled ? void 0 : "agenc-checkout__price-label", children: tc("components.hire.priceLabel") }),
991
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: unstyled ? void 0 : "agenc-checkout__price", children: price })
992
- ] }),
993
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: unstyled ? void 0 : "agenc-checkout__moderation", children: /* @__PURE__ */ jsxRuntime.jsx(ModerationBadge, { moderation, unstyled }) }),
994
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: unstyled ? void 0 : "agenc-checkout__escrow-note", children: tc("components.hire.escrowNote") }),
995
- referrer ? /* @__PURE__ */ jsxRuntime.jsx(
996
- ReferrerDisclosure,
997
- {
998
- referrer,
999
- live: referrerLive,
1000
- unstyled
1001
- }
1002
- ) : null,
1003
- /* @__PURE__ */ jsxRuntime.jsxs(
1004
- "div",
1005
- {
1006
- className: unstyled ? void 0 : "agenc-checkout__status",
1007
- role: "status",
1008
- "aria-live": "polite",
1009
- children: [
1010
- pending ? tc("components.hire.pending") : null,
1011
- success ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1012
- /* @__PURE__ */ jsxRuntime.jsx("strong", { children: tc("components.hire.success") }),
1013
- " ",
1014
- tc("components.hire.successDetail")
1015
- ] }) : null
1016
- ]
1017
- }
1018
- ),
1019
- error ? /* @__PURE__ */ jsxRuntime.jsxs(
1020
- "div",
1021
- {
1022
- className: unstyled ? void 0 : "agenc-checkout__error",
1023
- role: "alert",
1024
- "aria-live": "assertive",
1025
- children: [
1026
- /* @__PURE__ */ jsxRuntime.jsx("strong", { children: tc("components.hire.errorTitle") }),
1027
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: error.message })
1028
- ]
1029
- }
1030
- ) : null,
1031
- !connected && !success ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: unstyled ? void 0 : "agenc-checkout__hint", children: tc("components.hire.notConnected") }) : null
1032
- ] })
1033
- }
1034
- );
1035
- }
1036
- function HireButton({
1037
- listing,
1038
- buildHireInput,
1039
- onHired,
1040
- onViewTask,
1041
- showPriceInLabel = true,
1042
- label,
1043
- unstyled,
1044
- className
1045
- }) {
1046
- const ctx = useAgencContext();
1047
- const { hire, status, error, taskPda, reset } = useHire();
1048
- const { connected } = useWalletSigner();
1049
- const [open, setOpen] = react.useState(false);
1050
- const inFlightRef = react.useRef(false);
1051
- const capability = ctx.resolveReferrerCapability();
1052
- const close = react.useCallback(() => {
1053
- setOpen(false);
1054
- inFlightRef.current = false;
1055
- reset();
1056
- }, [reset]);
1057
- const confirm = react.useCallback(async () => {
1058
- if (inFlightRef.current) return;
1059
- inFlightRef.current = true;
1060
- try {
1061
- const input = buildHireInput(listing);
1062
- const result = await hire(input);
1063
- onHired?.(result.taskPda);
1064
- } finally {
1065
- inFlightRef.current = false;
1066
- }
1067
- }, [buildHireInput, hire, listing, onHired]);
1068
- const buttonLabel = label ?? (showPriceInLabel ? tc("components.hire.ctaPrice", {
1069
- price: formatPriceSol(listing.account.price)
1070
- }) : tc("components.hire.cta"));
1071
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1072
- /* @__PURE__ */ jsxRuntime.jsx(
1073
- Button,
1074
- {
1075
- unstyled,
1076
- className,
1077
- variant: "primary",
1078
- onClick: () => setOpen(true),
1079
- children: buttonLabel
1080
- }
1081
- ),
1082
- /* @__PURE__ */ jsxRuntime.jsx(
1083
- HireCheckoutModal,
1084
- {
1085
- open,
1086
- onClose: close,
1087
- listing,
1088
- onConfirm: confirm,
1089
- status,
1090
- error,
1091
- taskPda,
1092
- onViewTask,
1093
- referrer: ctx.referrer,
1094
- referrerLive: capability.live,
1095
- connected,
1096
- unstyled
1097
- }
1098
- )
1099
- ] });
1100
- }
1101
- var HAPPY_PATH = [
1102
- { status: marketplaceSdk.TaskStatus.Open, stringId: "components.taskTimeline.status.Open" },
1103
- {
1104
- status: marketplaceSdk.TaskStatus.InProgress,
1105
- stringId: "components.taskTimeline.status.InProgress"
1106
- },
1107
- {
1108
- status: marketplaceSdk.TaskStatus.PendingValidation,
1109
- stringId: "components.taskTimeline.status.PendingValidation"
1110
- },
1111
- {
1112
- status: marketplaceSdk.TaskStatus.Completed,
1113
- stringId: "components.taskTimeline.status.Completed"
1114
- }
1115
- ];
1116
- var OFF_PATH = {
1117
- [marketplaceSdk.TaskStatus.Cancelled]: {
1118
- stringId: "components.taskTimeline.status.Cancelled",
1119
- tone: "cancelled"
1120
- },
1121
- [marketplaceSdk.TaskStatus.Disputed]: {
1122
- stringId: "components.taskTimeline.status.Disputed",
1123
- tone: "disputed"
1124
- },
1125
- [marketplaceSdk.TaskStatus.RejectFrozen]: {
1126
- stringId: "components.taskTimeline.status.RejectFrozen",
1127
- tone: "rejected"
1128
- }
1129
- };
1130
- function happyIndex(status) {
1131
- return HAPPY_PATH.findIndex((s) => s.status === status);
1132
- }
1133
- function TaskTimeline({
1134
- status,
1135
- isLoading = false,
1136
- error = null,
1137
- onRetry,
1138
- unstyled,
1139
- className
1140
- }) {
1141
- const timelineClass = rootClass("agenc-timeline", unstyled, className);
1142
- if (error) {
1143
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: timelineClass, children: /* @__PURE__ */ jsxRuntime.jsx(StateMessage, { kind: "error", onRetry, unstyled }) });
1144
- }
1145
- if (isLoading && status === null) {
1146
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: timelineClass, children: /* @__PURE__ */ jsxRuntime.jsx(StateMessage, { kind: "loading", unstyled }) });
1147
- }
1148
- if (status === null) {
1149
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: timelineClass, children: /* @__PURE__ */ jsxRuntime.jsx(
1150
- StateMessage,
1151
- {
1152
- kind: "empty",
1153
- message: tc("components.taskTimeline.empty"),
1154
- unstyled
1155
- }
1156
- ) });
1157
- }
1158
- const offPath = OFF_PATH[status];
1159
- const currentIndex = offPath ? -1 : happyIndex(status);
1160
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: timelineClass, "aria-label": tc("components.taskTimeline.title"), children: [
1161
- /* @__PURE__ */ jsxRuntime.jsx("ol", { className: unstyled ? void 0 : "agenc-timeline__list", children: HAPPY_PATH.map((stage, index) => {
1162
- const done = currentIndex > index;
1163
- const current = currentIndex === index;
1164
- const state = done ? "done" : current ? "current" : "upcoming";
1165
- return /* @__PURE__ */ jsxRuntime.jsxs(
1166
- "li",
1167
- {
1168
- className: unstyled ? void 0 : cx("agenc-timeline__step", `agenc-timeline__step--${state}`),
1169
- "aria-current": current ? "step" : void 0,
1170
- children: [
1171
- /* @__PURE__ */ jsxRuntime.jsx(
1172
- "span",
1173
- {
1174
- className: unstyled ? void 0 : "agenc-timeline__marker",
1175
- "aria-hidden": "true"
1176
- }
1177
- ),
1178
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: unstyled ? void 0 : "agenc-timeline__label", children: tc(stage.stringId) })
1179
- ]
1180
- },
1181
- stage.status
1182
- );
1183
- }) }),
1184
- offPath ? /* @__PURE__ */ jsxRuntime.jsx(
1185
- "p",
1186
- {
1187
- className: unstyled ? void 0 : cx(
1188
- "agenc-timeline__terminal",
1189
- `agenc-timeline__terminal--${offPath.tone}`
1190
- ),
1191
- role: "status",
1192
- children: tc(offPath.stringId)
1193
- }
1194
- ) : null
1195
- ] });
1196
- }
1197
- var SUCCESS_STRING = {
1198
- accept: "components.review.accepted",
1199
- reject: "components.review.rejected",
1200
- requestChanges: "components.review.changesRequested"
1201
- };
1202
- function ReviewPanel({
1203
- hasSubmission = false,
1204
- onAccept,
1205
- onReject,
1206
- onRequestChanges,
1207
- status = "idle",
1208
- error = null,
1209
- settledAction,
1210
- unstyled,
1211
- className
1212
- }) {
1213
- const panelClass = rootClass("agenc-review", unstyled, className);
1214
- const pending = status === "pending";
1215
- const success = status === "success";
1216
- return /* @__PURE__ */ jsxRuntime.jsxs(
1217
- "section",
1218
- {
1219
- className: panelClass,
1220
- "aria-label": tc("components.review.title"),
1221
- children: [
1222
- /* @__PURE__ */ jsxRuntime.jsx("h3", { className: unstyled ? void 0 : "agenc-review__title", children: tc("components.review.title") }),
1223
- !hasSubmission ? /* @__PURE__ */ jsxRuntime.jsx(
1224
- StateMessage,
1225
- {
1226
- kind: "empty",
1227
- message: tc("components.review.noSubmission"),
1228
- unstyled
1229
- }
1230
- ) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: unstyled ? void 0 : "agenc-review__actions", children: [
1231
- /* @__PURE__ */ jsxRuntime.jsx(
1232
- Button,
1233
- {
1234
- unstyled,
1235
- variant: "primary",
1236
- loading: pending,
1237
- disabled: pending || !onAccept,
1238
- onClick: onAccept,
1239
- children: tc("components.review.accept")
1240
- }
1241
- ),
1242
- /* @__PURE__ */ jsxRuntime.jsx(
1243
- Button,
1244
- {
1245
- unstyled,
1246
- variant: "secondary",
1247
- disabled: pending || !onRequestChanges,
1248
- onClick: onRequestChanges,
1249
- children: tc("components.review.requestChanges")
1250
- }
1251
- ),
1252
- /* @__PURE__ */ jsxRuntime.jsx(
1253
- Button,
1254
- {
1255
- unstyled,
1256
- variant: "danger",
1257
- disabled: pending || !onReject,
1258
- onClick: onReject,
1259
- children: tc("components.review.reject")
1260
- }
1261
- )
1262
- ] }),
1263
- /* @__PURE__ */ jsxRuntime.jsxs(
1264
- "div",
1265
- {
1266
- className: unstyled ? void 0 : "agenc-review__status",
1267
- role: "status",
1268
- "aria-live": "polite",
1269
- children: [
1270
- pending ? tc("components.review.pending") : null,
1271
- success && settledAction ? tc(SUCCESS_STRING[settledAction]) : null
1272
- ]
1273
- }
1274
- ),
1275
- error ? /* @__PURE__ */ jsxRuntime.jsxs(
1276
- "div",
1277
- {
1278
- className: unstyled ? void 0 : "agenc-review__error",
1279
- role: "alert",
1280
- "aria-live": "assertive",
1281
- children: [
1282
- /* @__PURE__ */ jsxRuntime.jsx("strong", { children: tc("components.review.errorTitle") }),
1283
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: error.message })
1284
- ]
1285
- }
1286
- ) : null
1287
- ]
1288
- }
1289
- );
1290
- }
1291
- function DisputeBanner({
1292
- disputeOpen = false,
1293
- onInitiate,
1294
- status = "idle",
1295
- error = null,
1296
- unstyled,
1297
- className
1298
- }) {
1299
- const bannerClass = rootClass(
1300
- cx(
1301
- "agenc-dispute",
1302
- disputeOpen ? "agenc-dispute--open" : "agenc-dispute--none"
1303
- ),
1304
- unstyled,
1305
- className
1306
- );
1307
- const pending = status === "pending";
1308
- const opened = status === "success";
1309
- if (disputeOpen) {
1310
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: bannerClass, role: "alert", children: [
1311
- /* @__PURE__ */ jsxRuntime.jsx("strong", { className: unstyled ? void 0 : "agenc-dispute__title", children: tc("components.dispute.title") }),
1312
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: unstyled ? void 0 : "agenc-dispute__body", children: tc("components.dispute.body") })
1313
- ] });
1314
- }
1315
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: bannerClass, role: "region", "aria-label": tc("components.dispute.none"), children: [
1316
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: unstyled ? void 0 : "agenc-dispute__none", children: tc("components.dispute.none") }),
1317
- onInitiate ? /* @__PURE__ */ jsxRuntime.jsx(
1318
- Button,
1319
- {
1320
- unstyled,
1321
- variant: "secondary",
1322
- loading: pending,
1323
- disabled: pending,
1324
- onClick: onInitiate,
1325
- children: pending ? tc("components.dispute.pending") : tc("components.dispute.initiate")
1326
- }
1327
- ) : null,
1328
- /* @__PURE__ */ jsxRuntime.jsx(
1329
- "div",
1330
- {
1331
- className: unstyled ? void 0 : "agenc-dispute__status",
1332
- role: "status",
1333
- "aria-live": "polite",
1334
- children: opened ? tc("components.dispute.opened") : null
1335
- }
1336
- ),
1337
- error ? /* @__PURE__ */ jsxRuntime.jsxs(
1338
- "div",
1339
- {
1340
- className: unstyled ? void 0 : "agenc-dispute__error",
1341
- role: "alert",
1342
- "aria-live": "assertive",
1343
- children: [
1344
- /* @__PURE__ */ jsxRuntime.jsx("strong", { children: tc("components.dispute.errorTitle") }),
1345
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: error.message })
1346
- ]
1347
- }
1348
- ) : null
1349
- ] });
1350
- }
1351
- var UNVERIFIED = Object.freeze({
1352
- verified: false
9
+ Object.defineProperty(exports, "Badge", {
10
+ enumerable: true,
11
+ get: function () { return chunkIJKWKY4H_cjs.Badge; }
12
+ });
13
+ Object.defineProperty(exports, "Button", {
14
+ enumerable: true,
15
+ get: function () { return chunkIJKWKY4H_cjs.Button; }
16
+ });
17
+ Object.defineProperty(exports, "COMPONENT_CATALOG", {
18
+ enumerable: true,
19
+ get: function () { return chunkIJKWKY4H_cjs.COMPONENT_CATALOG; }
20
+ });
21
+ Object.defineProperty(exports, "DEFAULT_TRUST_HREF", {
22
+ enumerable: true,
23
+ get: function () { return chunkIJKWKY4H_cjs.DEFAULT_TRUST_HREF; }
24
+ });
25
+ Object.defineProperty(exports, "DisputeBanner", {
26
+ enumerable: true,
27
+ get: function () { return chunkIJKWKY4H_cjs.DisputeBanner; }
28
+ });
29
+ Object.defineProperty(exports, "EN_COMPONENT_STRINGS", {
30
+ enumerable: true,
31
+ get: function () { return chunkIJKWKY4H_cjs.EN_COMPONENT_STRINGS; }
32
+ });
33
+ Object.defineProperty(exports, "GuaranteedBadge", {
34
+ enumerable: true,
35
+ get: function () { return chunkIJKWKY4H_cjs.GuaranteedBadge; }
36
+ });
37
+ Object.defineProperty(exports, "HireButton", {
38
+ enumerable: true,
39
+ get: function () { return chunkIJKWKY4H_cjs.HireButton; }
40
+ });
41
+ Object.defineProperty(exports, "HireCheckoutModal", {
42
+ enumerable: true,
43
+ get: function () { return chunkIJKWKY4H_cjs.HireCheckoutModal; }
44
+ });
45
+ Object.defineProperty(exports, "ListingCard", {
46
+ enumerable: true,
47
+ get: function () { return chunkIJKWKY4H_cjs.ListingCard; }
48
+ });
49
+ Object.defineProperty(exports, "ListingGrid", {
50
+ enumerable: true,
51
+ get: function () { return chunkIJKWKY4H_cjs.ListingGrid; }
52
+ });
53
+ Object.defineProperty(exports, "Modal", {
54
+ enumerable: true,
55
+ get: function () { return chunkIJKWKY4H_cjs.Modal; }
56
+ });
57
+ Object.defineProperty(exports, "ModerationBadge", {
58
+ enumerable: true,
59
+ get: function () { return chunkIJKWKY4H_cjs.ModerationBadge; }
60
+ });
61
+ Object.defineProperty(exports, "PoweredByAgenC", {
62
+ enumerable: true,
63
+ get: function () { return chunkIJKWKY4H_cjs.PoweredByAgenC; }
64
+ });
65
+ Object.defineProperty(exports, "ProviderCard", {
66
+ enumerable: true,
67
+ get: function () { return chunkIJKWKY4H_cjs.ProviderCard; }
68
+ });
69
+ Object.defineProperty(exports, "ReferrerDisclosure", {
70
+ enumerable: true,
71
+ get: function () { return chunkIJKWKY4H_cjs.ReferrerDisclosure; }
72
+ });
73
+ Object.defineProperty(exports, "ReviewPanel", {
74
+ enumerable: true,
75
+ get: function () { return chunkIJKWKY4H_cjs.ReviewPanel; }
76
+ });
77
+ Object.defineProperty(exports, "Spinner", {
78
+ enumerable: true,
79
+ get: function () { return chunkIJKWKY4H_cjs.Spinner; }
80
+ });
81
+ Object.defineProperty(exports, "StateMessage", {
82
+ enumerable: true,
83
+ get: function () { return chunkIJKWKY4H_cjs.StateMessage; }
84
+ });
85
+ Object.defineProperty(exports, "TaskTimeline", {
86
+ enumerable: true,
87
+ get: function () { return chunkIJKWKY4H_cjs.TaskTimeline; }
88
+ });
89
+ Object.defineProperty(exports, "UNVERIFIED", {
90
+ enumerable: true,
91
+ get: function () { return chunkIJKWKY4H_cjs.UNVERIFIED; }
92
+ });
93
+ Object.defineProperty(exports, "VerifiedBadge", {
94
+ enumerable: true,
95
+ get: function () { return chunkIJKWKY4H_cjs.VerifiedBadge; }
96
+ });
97
+ Object.defineProperty(exports, "agentVerificationReaderFromRpc", {
98
+ enumerable: true,
99
+ get: function () { return chunkIJKWKY4H_cjs.agentVerificationReaderFromRpc; }
100
+ });
101
+ Object.defineProperty(exports, "cx", {
102
+ enumerable: true,
103
+ get: function () { return chunkIJKWKY4H_cjs.cx; }
104
+ });
105
+ Object.defineProperty(exports, "decodeListingCategory", {
106
+ enumerable: true,
107
+ get: function () { return chunkIJKWKY4H_cjs.decodeListingCategory; }
108
+ });
109
+ Object.defineProperty(exports, "decodeListingName", {
110
+ enumerable: true,
111
+ get: function () { return chunkIJKWKY4H_cjs.decodeListingName; }
112
+ });
113
+ Object.defineProperty(exports, "decodeListingTags", {
114
+ enumerable: true,
115
+ get: function () { return chunkIJKWKY4H_cjs.decodeListingTags; }
116
+ });
117
+ Object.defineProperty(exports, "elementClass", {
118
+ enumerable: true,
119
+ get: function () { return chunkIJKWKY4H_cjs.elementClass; }
120
+ });
121
+ Object.defineProperty(exports, "evaluateAgentVerification", {
122
+ enumerable: true,
123
+ get: function () { return chunkIJKWKY4H_cjs.evaluateAgentVerification; }
124
+ });
125
+ Object.defineProperty(exports, "formatPriceSol", {
126
+ enumerable: true,
127
+ get: function () { return chunkIJKWKY4H_cjs.formatPriceSol; }
128
+ });
129
+ Object.defineProperty(exports, "formatRate", {
130
+ enumerable: true,
131
+ get: function () { return chunkIJKWKY4H_cjs.formatRate; }
132
+ });
133
+ Object.defineProperty(exports, "formatSol", {
134
+ enumerable: true,
135
+ get: function () { return chunkIJKWKY4H_cjs.formatSol; }
136
+ });
137
+ Object.defineProperty(exports, "moderationStateOf", {
138
+ enumerable: true,
139
+ get: function () { return chunkIJKWKY4H_cjs.moderationStateOf; }
140
+ });
141
+ Object.defineProperty(exports, "rootClass", {
142
+ enumerable: true,
143
+ get: function () { return chunkIJKWKY4H_cjs.rootClass; }
144
+ });
145
+ Object.defineProperty(exports, "tc", {
146
+ enumerable: true,
147
+ get: function () { return chunkIJKWKY4H_cjs.tc; }
148
+ });
149
+ Object.defineProperty(exports, "toHex", {
150
+ enumerable: true,
151
+ get: function () { return chunkIJKWKY4H_cjs.toHex; }
152
+ });
153
+ Object.defineProperty(exports, "truncateAddress", {
154
+ enumerable: true,
155
+ get: function () { return chunkIJKWKY4H_cjs.truncateAddress; }
156
+ });
157
+ Object.defineProperty(exports, "useAgentVerification", {
158
+ enumerable: true,
159
+ get: function () { return chunkIJKWKY4H_cjs.useAgentVerification; }
160
+ });
161
+ Object.defineProperty(exports, "useFocusTrap", {
162
+ enumerable: true,
163
+ get: function () { return chunkIJKWKY4H_cjs.useFocusTrap; }
1353
164
  });
1354
- function evaluateAgentVerification(account, nowSeconds) {
1355
- if (!account) return UNVERIFIED;
1356
- if (account.revoked) return UNVERIFIED;
1357
- if (account.expiresAt !== 0n && nowSeconds >= account.expiresAt) {
1358
- return UNVERIFIED;
1359
- }
1360
- return {
1361
- verified: true,
1362
- domain: account.verifiedDomain,
1363
- method: account.method,
1364
- verifiedBy: account.verifiedBy,
1365
- verifiedAt: account.verifiedAt,
1366
- expiresAt: account.expiresAt,
1367
- revoked: false
1368
- };
1369
- }
1370
- function defaultNow() {
1371
- return BigInt(Math.floor(Date.now() / 1e3));
1372
- }
1373
- function agentVerificationReaderFromRpc(rpc, options) {
1374
- const now = options?.now ?? defaultNow;
1375
- return async (agentPda) => {
1376
- const [pda] = await marketplaceSdk.findAgentVerificationPda({ agent: agentPda });
1377
- const maybe = await marketplaceSdk.fetchMaybeAgentVerification(rpc, pda);
1378
- return evaluateAgentVerification(maybe.exists ? maybe.data : null, now());
1379
- };
1380
- }
1381
- function useAgentVerification(agentPda, options) {
1382
- const reader = options?.reader;
1383
- const enabled = (options?.enabled ?? true) && Boolean(agentPda) && Boolean(reader);
1384
- const query = reactQuery.useQuery({
1385
- queryKey: ["agenc", "agentVerification", agentPda ? String(agentPda) : ""],
1386
- enabled,
1387
- queryFn: async () => {
1388
- return reader(agentPda);
1389
- }
1390
- });
1391
- const verification = query.error ? UNVERIFIED : query.data ?? UNVERIFIED;
1392
- return {
1393
- verification,
1394
- verified: verification.verified,
1395
- isLoading: query.isLoading && enabled,
1396
- error: query.error ?? null,
1397
- refetch: () => void query.refetch()
1398
- };
1399
- }
1400
- function VerifiedDomainBadge({
1401
- domain,
1402
- unstyled
1403
- }) {
1404
- return /* @__PURE__ */ jsxRuntime.jsx(
1405
- Badge,
1406
- {
1407
- tone: "success",
1408
- unstyled,
1409
- className: unstyled ? void 0 : "agenc-provider__domain agenc-provider__domain--verified",
1410
- label: tc("components.provider.verifiedDomainLabel", { domain }),
1411
- children: tc("components.provider.verifiedDomain", { domain })
1412
- }
1413
- );
1414
- }
1415
- function ClaimedDomainBadge({
1416
- domain,
1417
- unstyled
1418
- }) {
1419
- return /* @__PURE__ */ jsxRuntime.jsx(
1420
- Badge,
1421
- {
1422
- tone: "neutral",
1423
- unstyled,
1424
- className: unstyled ? void 0 : "agenc-provider__domain agenc-provider__domain--claimed",
1425
- label: tc("components.provider.claimedDomainLabel", { domain }),
1426
- children: tc("components.provider.claimedDomain", { domain })
1427
- }
1428
- );
1429
- }
1430
- function ProviderCard({
1431
- agent,
1432
- trackRecord,
1433
- verification = UNVERIFIED,
1434
- operatorDomain,
1435
- verified = false,
1436
- isLoading = false,
1437
- error = null,
1438
- onRetry,
1439
- unstyled,
1440
- className
1441
- }) {
1442
- const cardClass = rootClass("agenc-provider", unstyled, className);
1443
- const isVerified = verification.verified || verification === UNVERIFIED && verified;
1444
- const verifiedDomain = verification.verified ? verification.domain : null;
1445
- const claimed = typeof operatorDomain === "string" && operatorDomain.trim() !== "" ? operatorDomain.trim() : null;
1446
- const domainBadge = verifiedDomain ? /* @__PURE__ */ jsxRuntime.jsx(VerifiedDomainBadge, { domain: verifiedDomain, unstyled }) : claimed ? /* @__PURE__ */ jsxRuntime.jsx(ClaimedDomainBadge, { domain: claimed, unstyled }) : null;
1447
- const header = /* @__PURE__ */ jsxRuntime.jsxs("header", { className: unstyled ? void 0 : "agenc-provider__header", children: [
1448
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: unstyled ? void 0 : "agenc-provider__id", children: [
1449
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: unstyled ? void 0 : "agenc-provider__label", children: tc("components.provider.title") }),
1450
- agent ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: unstyled ? void 0 : "agenc-provider__pda", children: truncateAddress(agent) }) : null
1451
- ] }),
1452
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: unstyled ? void 0 : "agenc-provider__badges", children: [
1453
- domainBadge,
1454
- /* @__PURE__ */ jsxRuntime.jsx(VerifiedBadge, { verified: isVerified, unstyled })
1455
- ] })
1456
- ] });
1457
- if (error) {
1458
- return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: cardClass, "aria-label": tc("components.provider.title"), children: [
1459
- header,
1460
- /* @__PURE__ */ jsxRuntime.jsx(
1461
- StateMessage,
1462
- {
1463
- kind: "error",
1464
- message: tc("components.provider.unavailable"),
1465
- onRetry,
1466
- unstyled
1467
- }
1468
- )
1469
- ] });
1470
- }
1471
- if (isLoading && trackRecord === null) {
1472
- return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: cardClass, "aria-label": tc("components.provider.title"), children: [
1473
- header,
1474
- /* @__PURE__ */ jsxRuntime.jsx(StateMessage, { kind: "loading", unstyled })
1475
- ] });
1476
- }
1477
- if (trackRecord === null) {
1478
- return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: cardClass, "aria-label": tc("components.provider.title"), children: [
1479
- header,
1480
- /* @__PURE__ */ jsxRuntime.jsx(
1481
- StateMessage,
1482
- {
1483
- kind: "empty",
1484
- message: tc("components.provider.noData"),
1485
- unstyled
1486
- }
1487
- )
1488
- ] });
1489
- }
1490
- const provisional = trackRecord.partial;
1491
- return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: cardClass, "aria-label": tc("components.provider.title"), children: [
1492
- header,
1493
- /* @__PURE__ */ jsxRuntime.jsxs("dl", { className: unstyled ? void 0 : "agenc-provider__stats", children: [
1494
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: unstyled ? void 0 : "agenc-provider__stat", children: [
1495
- /* @__PURE__ */ jsxRuntime.jsx("dt", { children: tc("components.provider.completionRate") }),
1496
- /* @__PURE__ */ jsxRuntime.jsxs("dd", { children: [
1497
- formatRate(trackRecord.completionRate),
1498
- provisional ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: unstyled ? void 0 : "agenc-provider__provisional", children: [
1499
- " ",
1500
- "(",
1501
- tc("components.provider.provisional"),
1502
- ")"
1503
- ] }) : null
1504
- ] })
1505
- ] }),
1506
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: unstyled ? void 0 : "agenc-provider__stat", children: [
1507
- /* @__PURE__ */ jsxRuntime.jsx("dt", { children: tc("components.provider.disputeRate") }),
1508
- /* @__PURE__ */ jsxRuntime.jsxs("dd", { children: [
1509
- formatRate(trackRecord.disputeRate),
1510
- provisional ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: unstyled ? void 0 : "agenc-provider__provisional", children: [
1511
- " ",
1512
- "(",
1513
- tc("components.provider.provisional"),
1514
- ")"
1515
- ] }) : null
1516
- ] })
1517
- ] }),
1518
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: unstyled ? void 0 : "agenc-provider__stat", children: [
1519
- /* @__PURE__ */ jsxRuntime.jsx("dt", { children: tc("components.provider.completions", {
1520
- count: String(trackRecord.completions)
1521
- }) }),
1522
- /* @__PURE__ */ jsxRuntime.jsx("dd", { children: tc("components.provider.disputes", {
1523
- count: String(trackRecord.disputesLost)
1524
- }) })
1525
- ] })
1526
- ] })
1527
- ] });
1528
- }
1529
- var DEFAULT_TRUST_HREF = "https://agenc.tech/trust";
1530
- var SAFE_HREF_SCHEMES = /* @__PURE__ */ new Set(["http:", "https:", "mailto:"]);
1531
- function safeHref(href) {
1532
- try {
1533
- const url = new URL(href, DEFAULT_TRUST_HREF);
1534
- return SAFE_HREF_SCHEMES.has(url.protocol) ? href : DEFAULT_TRUST_HREF;
1535
- } catch {
1536
- return DEFAULT_TRUST_HREF;
1537
- }
1538
- }
1539
- function PoweredByAgenC({
1540
- href = DEFAULT_TRUST_HREF,
1541
- newTab = true,
1542
- label,
1543
- unstyled,
1544
- className
1545
- }) {
1546
- const linkClass = rootClass("agenc-powered-by", unstyled, className);
1547
- return /* @__PURE__ */ jsxRuntime.jsx(
1548
- "a",
1549
- {
1550
- className: linkClass,
1551
- href: safeHref(href),
1552
- target: newTab ? "_blank" : void 0,
1553
- rel: newTab ? "noopener noreferrer" : void 0,
1554
- "aria-label": `${label ?? tc("components.poweredBy.label")} \u2014 ${tc(
1555
- "components.poweredBy.trustLink"
1556
- )}`,
1557
- children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: unstyled ? void 0 : "agenc-powered-by__label", children: label ?? tc("components.poweredBy.label") })
1558
- }
1559
- );
1560
- }
1561
-
1562
- exports.Badge = Badge;
1563
- exports.Button = Button;
1564
- exports.COMPONENT_CATALOG = COMPONENT_CATALOG;
1565
- exports.DEFAULT_TRUST_HREF = DEFAULT_TRUST_HREF;
1566
- exports.DisputeBanner = DisputeBanner;
1567
- exports.EN_COMPONENT_STRINGS = EN_COMPONENT_STRINGS;
1568
- exports.GuaranteedBadge = GuaranteedBadge;
1569
- exports.HireButton = HireButton;
1570
- exports.HireCheckoutModal = HireCheckoutModal;
1571
- exports.ListingCard = ListingCard;
1572
- exports.ListingGrid = ListingGrid;
1573
- exports.Modal = Modal;
1574
- exports.ModerationBadge = ModerationBadge;
1575
- exports.PoweredByAgenC = PoweredByAgenC;
1576
- exports.ProviderCard = ProviderCard;
1577
- exports.ReferrerDisclosure = ReferrerDisclosure;
1578
- exports.ReviewPanel = ReviewPanel;
1579
- exports.Spinner = Spinner;
1580
- exports.StateMessage = StateMessage;
1581
- exports.TaskTimeline = TaskTimeline;
1582
- exports.UNVERIFIED = UNVERIFIED;
1583
- exports.VerifiedBadge = VerifiedBadge;
1584
- exports.agentVerificationReaderFromRpc = agentVerificationReaderFromRpc;
1585
- exports.cx = cx;
1586
- exports.decodeListingCategory = decodeListingCategory;
1587
- exports.decodeListingName = decodeListingName;
1588
- exports.decodeListingTags = decodeListingTags;
1589
- exports.elementClass = elementClass;
1590
- exports.evaluateAgentVerification = evaluateAgentVerification;
1591
- exports.formatPriceSol = formatPriceSol;
1592
- exports.formatRate = formatRate;
1593
- exports.formatSol = formatSol;
1594
- exports.moderationStateOf = moderationStateOf;
1595
- exports.rootClass = rootClass;
1596
- exports.tc = tc;
1597
- exports.toHex = toHex;
1598
- exports.truncateAddress = truncateAddress;
1599
- exports.useAgentVerification = useAgentVerification;
1600
- exports.useFocusTrap = useFocusTrap;
1601
165
  //# sourceMappingURL=index.cjs.map
1602
166
  //# sourceMappingURL=index.cjs.map