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