@medialane/ui 0.245.0 → 0.247.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 (89) hide show
  1. package/dist/components/asset-comments-dialog.cjs +2 -2
  2. package/dist/components/asset-comments-dialog.cjs.map +1 -1
  3. package/dist/components/asset-comments-dialog.d.cts +3 -9
  4. package/dist/components/asset-comments-dialog.d.ts +3 -9
  5. package/dist/components/asset-comments-dialog.js +2 -2
  6. package/dist/components/asset-comments-dialog.js.map +1 -1
  7. package/dist/components/asset-page.cjs +6 -7
  8. package/dist/components/asset-page.cjs.map +1 -1
  9. package/dist/components/asset-page.d.cts +4 -13
  10. package/dist/components/asset-page.d.ts +4 -13
  11. package/dist/components/asset-page.js +6 -7
  12. package/dist/components/asset-page.js.map +1 -1
  13. package/dist/components/collection-page.cjs +3 -2
  14. package/dist/components/collection-page.cjs.map +1 -1
  15. package/dist/components/collection-page.d.cts +0 -5
  16. package/dist/components/collection-page.d.ts +0 -5
  17. package/dist/components/collection-page.js +3 -2
  18. package/dist/components/collection-page.js.map +1 -1
  19. package/dist/components/comments-section.cjs +304 -0
  20. package/dist/components/comments-section.cjs.map +1 -0
  21. package/dist/components/comments-section.d.cts +10 -0
  22. package/dist/components/comments-section.d.ts +10 -0
  23. package/dist/components/comments-section.js +270 -0
  24. package/dist/components/comments-section.js.map +1 -0
  25. package/dist/components/medialane-app.cjs.map +1 -1
  26. package/dist/components/medialane-app.d.cts +3 -0
  27. package/dist/components/medialane-app.d.ts +3 -0
  28. package/dist/components/medialane-app.js.map +1 -1
  29. package/dist/components/pop-burn-button.cjs +65 -0
  30. package/dist/components/pop-burn-button.cjs.map +1 -0
  31. package/dist/components/pop-burn-button.d.cts +10 -0
  32. package/dist/components/pop-burn-button.d.ts +10 -0
  33. package/dist/components/pop-burn-button.js +41 -0
  34. package/dist/components/pop-burn-button.js.map +1 -0
  35. package/dist/components/pop-claim-button.cjs +92 -0
  36. package/dist/components/pop-claim-button.cjs.map +1 -0
  37. package/dist/components/pop-claim-button.d.cts +7 -0
  38. package/dist/components/pop-claim-button.d.ts +7 -0
  39. package/dist/components/pop-claim-button.js +68 -0
  40. package/dist/components/pop-claim-button.js.map +1 -0
  41. package/dist/components/pop-manage-page.cjs +224 -0
  42. package/dist/components/pop-manage-page.cjs.map +1 -0
  43. package/dist/components/pop-manage-page.d.cts +7 -0
  44. package/dist/components/pop-manage-page.d.ts +7 -0
  45. package/dist/components/pop-manage-page.js +190 -0
  46. package/dist/components/pop-manage-page.js.map +1 -0
  47. package/dist/components/portfolio-sponsorships.cjs +209 -0
  48. package/dist/components/portfolio-sponsorships.cjs.map +1 -0
  49. package/dist/components/portfolio-sponsorships.d.cts +5 -0
  50. package/dist/components/portfolio-sponsorships.d.ts +5 -0
  51. package/dist/components/portfolio-sponsorships.js +175 -0
  52. package/dist/components/portfolio-sponsorships.js.map +1 -0
  53. package/dist/components/sponsorship-offer-page.cjs +181 -0
  54. package/dist/components/sponsorship-offer-page.cjs.map +1 -0
  55. package/dist/components/sponsorship-offer-page.d.cts +7 -0
  56. package/dist/components/sponsorship-offer-page.d.ts +7 -0
  57. package/dist/components/sponsorship-offer-page.js +147 -0
  58. package/dist/components/sponsorship-offer-page.js.map +1 -0
  59. package/dist/components/sponsorship-offers-page.cjs +118 -0
  60. package/dist/components/sponsorship-offers-page.cjs.map +1 -0
  61. package/dist/components/sponsorship-offers-page.d.cts +5 -0
  62. package/dist/components/sponsorship-offers-page.d.ts +5 -0
  63. package/dist/components/sponsorship-offers-page.js +84 -0
  64. package/dist/components/sponsorship-offers-page.js.map +1 -0
  65. package/dist/components/transaction-done.cjs +46 -0
  66. package/dist/components/transaction-done.cjs.map +1 -0
  67. package/dist/components/transaction-done.d.cts +18 -0
  68. package/dist/components/transaction-done.d.ts +18 -0
  69. package/dist/components/transaction-done.js +22 -0
  70. package/dist/components/transaction-done.js.map +1 -0
  71. package/dist/components/transfer-collection-ownership.cjs +137 -0
  72. package/dist/components/transfer-collection-ownership.cjs.map +1 -0
  73. package/dist/components/transfer-collection-ownership.d.cts +11 -0
  74. package/dist/components/transfer-collection-ownership.d.ts +11 -0
  75. package/dist/components/transfer-collection-ownership.js +113 -0
  76. package/dist/components/transfer-collection-ownership.js.map +1 -0
  77. package/dist/index.cjs +27 -0
  78. package/dist/index.cjs.map +1 -1
  79. package/dist/index.d.cts +11 -2
  80. package/dist/index.d.ts +11 -2
  81. package/dist/index.js +18 -0
  82. package/dist/index.js.map +1 -1
  83. package/dist/utils/use-transaction.cjs +2 -0
  84. package/dist/utils/use-transaction.cjs.map +1 -1
  85. package/dist/utils/use-transaction.d.cts +1 -1
  86. package/dist/utils/use-transaction.d.ts +1 -1
  87. package/dist/utils/use-transaction.js +2 -0
  88. package/dist/utils/use-transaction.js.map +1 -1
  89. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/comments-section.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useRef, useState } from \"react\";\nimport { ExternalLink, Flag, Loader2, MessageCircle, Send, Zap } from \"lucide-react\";\nimport { normalizeAddress, profileHref, STARKNET_NFTCOMMENTS_CONTRACT } from \"@medialane/sdk\";\nimport { AddressDisplay } from \"./address-display.js\";\nimport { Button } from \"./button.js\";\nimport Link from \"./link.js\";\nimport { useMedialaneApp, type ReportTarget } from \"./medialane-app.js\";\nimport { RewardEarned } from \"./rewards/reward-earned.js\";\nimport { Skeleton } from \"./skeleton.js\";\nimport { Textarea } from \"./textarea.js\";\nimport { TransactionDialog } from \"./transaction-dialog.js\";\nimport { TransactionDone } from \"./transaction-done.js\";\nimport { cn } from \"../utils/cn.js\";\nimport { EXPLORER_URL } from \"../utils/explorer-url.js\";\nimport { runIntentCalls } from \"../utils/run-intent-calls.js\";\nimport { timeAgo } from \"../utils/time.js\";\nimport { useComments } from \"../utils/use-comments.js\";\nimport { useTransaction } from \"../utils/use-transaction.js\";\n\nconst MAX_LEN = 1000;\n\nexport interface CommentsSectionProps {\n contract: string;\n tokenId: string;\n className?: string;\n}\n\nexport function CommentsSection({ contract, tokenId, className }: CommentsSectionProps) {\n const app = useMedialaneApp();\n const walletAddress = app.walletAddress;\n const hasWallet = !!walletAddress;\n const { ReportDialog } = app;\n const { comments, isLoading, mutate } = useComments(contract, tokenId);\n const tx = useTransaction();\n\n const [text, setText] = useState(\"\");\n const [reportTarget, setReportTarget] = useState<ReportTarget | null>(null);\n\n const messagesRef = useRef<HTMLDivElement>(null);\n const bottomRef = useRef<HTMLDivElement>(null);\n const composeRef = useRef<HTMLTextAreaElement>(null);\n\n const byteLen = new TextEncoder().encode(text).length;\n const canSubmit = text.trim().length > 0 && byteLen <= MAX_LEN && !!STARKNET_NFTCOMMENTS_CONTRACT;\n const isProcessing = tx.phase === \"preparing\" || tx.phase === \"submitting\" || tx.phase === \"confirming\";\n\n const isOwn = (author: string) =>\n !!walletAddress && normalizeAddress(\"STARKNET\", author) === normalizeAddress(\"STARKNET\", walletAddress);\n\n const isNearBottom = () => {\n const el = messagesRef.current;\n if (!el) return true;\n return el.scrollHeight - el.scrollTop - el.clientHeight < 100;\n };\n\n useEffect(() => {\n if (isNearBottom()) {\n bottomRef.current?.scrollIntoView({ behavior: \"smooth\" });\n }\n\n }, [comments.length]);\n\n const handleTextInput = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n setText(e.target.value);\n e.target.style.height = \"auto\";\n e.target.style.height = Math.min(e.target.scrollHeight, 96) + \"px\";\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (e.key === \"Enter\" && !e.shiftKey && canSubmit && !isProcessing) {\n e.preventDefault();\n post();\n }\n };\n\n const post = () => {\n const body = text.trim();\n void tx\n .run(async (signer) => {\n await runIntentCalls(signer, () =>\n app.getClient().api.intents.create(\"comment\", { author: signer.address, nftContract: contract, tokenId, text: body }),\n );\n })\n .then((ok) => {\n if (!ok) return;\n setText(\"\");\n if (composeRef.current) composeRef.current.style.height = \"auto\";\n void mutate();\n });\n };\n\n const handleStartConversation = () => {\n if (hasWallet) composeRef.current?.focus();\n };\n\n return (\n <div className={cn(\"flex flex-col h-[480px] overflow-hidden\", className)}>\n\n <div ref={messagesRef} className=\"flex-1 overflow-y-auto px-4 py-4\">\n {isLoading ? (\n <div className=\"space-y-4\">\n {([\n { own: false, w: \"w-40\" },\n { own: true, w: \"w-56\" },\n { own: false, w: \"w-48\" },\n { own: true, w: \"w-32\" },\n ] as const).map((item, i) => (\n <div key={i} className={`flex ${item.own ? \"justify-end\" : \"justify-start\"} gap-2`}>\n {!item.own && <Skeleton className=\"h-8 w-8 rounded-full shrink-0\" />}\n <Skeleton\n className={`h-10 ${item.w} rounded-2xl ${item.own ? \"rounded-tr-sm\" : \"rounded-tl-sm\"}`}\n />\n </div>\n ))}\n </div>\n ) : comments.length === 0 ? (\n <div className=\"flex flex-col items-center justify-center h-full gap-4 text-center px-4\">\n <div className=\"flex h-16 w-16 items-center justify-center rounded-full\" style={{ background: \"linear-gradient(135deg, hsl(var(--brand-blue) / 0.15), hsl(var(--brand-purple) / 0.15))\" }}>\n <MessageCircle className=\"h-7 w-7\" style={{ color: \"hsl(var(--brand-blue))\" }} />\n </div>\n <div>\n <p className=\"text-sm font-semibold\">Nothing here yet</p>\n <p className=\"text-xs text-muted-foreground mt-1 leading-relaxed max-w-[220px]\">\n Your comment will be minted onchain — attached to this NFT forever.\n </p>\n </div>\n <Button\n size=\"sm\"\n onClick={handleStartConversation}\n className=\"rounded-full text-white px-5\"\n style={{ background: \"linear-gradient(135deg, hsl(var(--brand-blue)), hsl(var(--brand-purple)))\" }}\n >\n Write the first comment\n </Button>\n </div>\n ) : (\n <div className=\"space-y-5\">\n {comments.map((comment) => {\n const own = isOwn(comment.author);\n const avatarSeed = parseInt(comment.author.slice(2, 8), 16) % 360;\n const avatarBg = own\n ? \"linear-gradient(135deg, hsl(var(--brand-blue)), hsl(var(--brand-purple)))\"\n : `linear-gradient(135deg, hsl(${avatarSeed}, 65%, 45%), hsl(${(avatarSeed + 60) % 360}, 65%, 55%))`;\n\n return (\n <div\n key={comment.id}\n className={`group flex gap-2.5 ${own ? \"flex-row-reverse\" : \"flex-row\"}`}\n >\n\n <Link href={profileHref({ address: comment.author })} className=\"shrink-0 mt-0.5\">\n <div\n className=\"h-9 w-9 rounded-full flex items-center justify-center text-2xs font-bold text-white select-none ring-2 ring-background hover:ring-primary/40 transition-all\"\n style={{ background: avatarBg }}\n >\n {comment.author.slice(2, 5).toUpperCase()}\n </div>\n </Link>\n\n <div className={`flex flex-col max-w-[75%] gap-1 ${own ? \"items-end\" : \"items-start\"}`}>\n\n <div className={`flex items-center gap-2 px-1 ${own ? \"flex-row-reverse\" : \"flex-row\"}`}>\n <Link\n href={profileHref({ address: comment.author })}\n className=\"text-xs font-semibold text-foreground hover:underline underline-offset-2\"\n >\n {own ? \"You\" : <AddressDisplay address={comment.author} chars={5} showCopy={false} />}\n </Link>\n <span className=\"text-2xs text-muted-foreground\" title={comment.postedAt}>\n {timeAgo(comment.postedAt)}\n </span>\n </div>\n\n <div className=\"relative\">\n {own ? (\n <div\n className=\"px-3.5 py-2.5 text-sm leading-relaxed break-words rounded-2xl rounded-tr-sm text-white\"\n style={{ background: \"linear-gradient(135deg, hsl(var(--brand-blue)), hsl(var(--brand-purple)))\" }}\n >\n {comment.content}\n </div>\n ) : (\n <div className=\"px-3.5 py-2.5 text-sm leading-relaxed break-words bg-muted rounded-2xl rounded-tl-sm border border-border/50\">\n {comment.content}\n </div>\n )}\n {!own && hasWallet && (\n <button\n className=\"absolute -top-1 -right-5 opacity-0 group-hover:opacity-100 transition-opacity text-muted-foreground/40 hover:text-destructive/70\"\n title=\"Report comment\"\n aria-label=\"Report comment\"\n onClick={() => setReportTarget({ type: \"COMMENT\", commentId: comment.id })}\n >\n <Flag className=\"h-3 w-3\" />\n </button>\n )}\n </div>\n\n {comment.txHash && (\n <a\n href={`${EXPLORER_URL}/tx/${comment.txHash}`}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"flex items-center gap-1 px-1 text-2xs font-medium transition-colors\"\n style={{ color: \"hsl(var(--brand-blue) / 0.55)\" }}\n onMouseEnter={(e) => (e.currentTarget.style.color = \"hsl(var(--brand-blue))\")}\n onMouseLeave={(e) => (e.currentTarget.style.color = \"hsl(var(--brand-blue) / 0.55)\")}\n >\n <span>⛓</span>\n <span>onchain proof</span>\n <ExternalLink className=\"h-2.5 w-2.5\" />\n </a>\n )}\n </div>\n </div>\n );\n })}\n <div ref={bottomRef} />\n </div>\n )}\n </div>\n\n <div className=\"border-t border-border/60 shrink-0\">\n {!hasWallet ? (\n <div className=\"flex items-center justify-center px-4 h-16\">\n <button type=\"button\" onClick={app.onRequireWallet} className=\"text-sm text-primary hover:underline\">\n {app.connectLabel ?? \"Connect\"} to comment\n </button>\n </div>\n ) : (\n <div className=\"px-3 pt-2 pb-3 space-y-2\">\n\n <div className=\"flex items-center gap-1.5\">\n <Zap className=\"h-3 w-3\" style={{ color: \"hsl(var(--brand-blue))\" }} />\n <span className=\"text-2xs font-semibold\" style={{ color: \"hsl(var(--brand-blue))\" }}>\n Mint your message onchain\n </span>\n </div>\n\n <div\n className=\"rounded-xl border bg-background/60 transition-all focus-within:ring-2\"\n style={{\n borderColor: \"hsl(var(--border))\",\n }}\n onFocusCapture={(e) => {\n (e.currentTarget as HTMLDivElement).style.borderColor = \"hsl(var(--brand-blue) / 0.6)\";\n (e.currentTarget as HTMLDivElement).style.boxShadow = \"0 0 0 3px hsl(var(--brand-blue) / 0.12)\";\n }}\n onBlurCapture={(e) => {\n (e.currentTarget as HTMLDivElement).style.borderColor = \"hsl(var(--border))\";\n (e.currentTarget as HTMLDivElement).style.boxShadow = \"\";\n }}\n >\n <Textarea\n ref={composeRef}\n placeholder=\"Say something onchain… it's permanent.\"\n value={text}\n onChange={handleTextInput}\n onKeyDown={handleKeyDown}\n rows={2}\n className=\"resize-none min-h-[52px] max-h-[120px] w-full border-0 bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0 px-3 pt-2.5 pb-1 text-sm rounded-xl\"\n disabled={isProcessing}\n />\n <div className=\"flex items-center justify-between px-3 pb-2.5\">\n <span className=\"text-2xs text-muted-foreground/40 flex items-center gap-1\">\n Enter ↵ to post\n </span>\n <div className=\"flex items-center gap-2\">\n {byteLen > 800 && (\n <span className={`text-2xs ${byteLen > MAX_LEN ? \"text-destructive\" : \"text-muted-foreground\"}`}>\n {byteLen}/{MAX_LEN}\n </span>\n )}\n <button\n onClick={post}\n disabled={!canSubmit || isProcessing}\n className=\"flex items-center gap-1.5 h-7 px-3 text-xs font-semibold rounded-full text-white transition-all hover:opacity-90 active:scale-95 disabled:opacity-40 disabled:cursor-not-allowed\"\n style={{ background: \"linear-gradient(135deg, hsl(var(--brand-blue)), hsl(var(--brand-purple)))\" }}\n >\n {isProcessing ? <Loader2 className=\"h-3 w-3 animate-spin\" /> : <Send className=\"h-3 w-3\" />}\n Post onchain\n </button>\n </div>\n </div>\n </div>\n </div>\n )}\n </div>\n\n {reportTarget && ReportDialog && (\n <ReportDialog\n target={reportTarget}\n open={!!reportTarget}\n onOpenChange={(open) => { if (!open) setReportTarget(null); }}\n />\n )}\n\n <TransactionDialog tx={tx} title=\"Comment\" workingLabel=\"Posting your comment…\" firstStepLabel=\"Prepare comment\">\n <TransactionDone\n tx={tx}\n name=\"Comment\"\n title=\"Comment posted!\"\n description=\"Your comment is onchain and will appear here once indexed (~30s).\"\n footer={<RewardEarned actionType=\"comment\" />}\n />\n </TransactionDialog>\n </div>\n );\n}\n"],"mappings":";AA6Gc,SACgB,KADhB;AA3Gd,SAAS,WAAW,QAAQ,gBAAgB;AAC5C,SAAS,cAAc,MAAM,SAAS,eAAe,MAAM,WAAW;AACtE,SAAS,kBAAkB,aAAa,qCAAqC;AAC7E,SAAS,sBAAsB;AAC/B,SAAS,cAAc;AACvB,OAAO,UAAU;AACjB,SAAS,uBAA0C;AACnD,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB;AACzB,SAAS,gBA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E;AAAA,cACA,qBAAC,SAAI,WAAU,2BACZ;AAAA,0BAAU,OACT,qBAAC,UAAK,WAAW,YAAY,UAAU,UAAU,qBAAqB,uBAAuB,IAC1F;AAAA;AAAA,kBAAQ;AAAA,kBAAE;AAAA,mBACb;AAAA,gBAEF;AAAA,kBAAC;AAAA;AAAA,oBACC,SAAS;AAAA,oBACT,UAAU,CAAC,aAAa;AAAA,oBACxB,WAAU;AAAA,oBACV,OAAO,EAAE,YAAY,4EAA4E;AAAA,oBAEhG;AAAA,qCAAe,oBAAC,WAAQ,WAAU,wBAAuB,IAAK,oBAAC,QAAK,WAAU,WAAU;AAAA,sBAAG;AAAA;AAAA;AAAA,gBAE9F;AAAA,iBACF;AAAA,eACF;AAAA;AAAA;AAAA,MACF;AAAA,OACF,GAEJ;AAAA,IAEC,gBAAgB,gBACf;AAAA,MAAC;AAAA;AAAA,QACC,QAAQ;AAAA,QACR,MAAM,CAAC,CAAC;AAAA,QACR,cAAc,CAAC,SAAS;AAAE,cAAI,CAAC,KAAM,iBAAgB,IAAI;AAAA,QAAG;AAAA;AAAA,IAC9D;AAAA,IAGF,oBAAC,qBAAkB,IAAQ,OAAM,WAAU,cAAa,8BAAwB,gBAAe,mBAC7F;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,MAAK;AAAA,QACL,OAAM;AAAA,QACN,aAAY;AAAA,QACZ,QAAQ,oBAAC,gBAAa,YAAW,WAAU;AAAA;AAAA,IAC7C,GACF;AAAA,KACF;AAEJ;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/medialane-app.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, useContext, type ComponentType, type ElementType, type ReactNode } from \"react\";\nimport type { MedialaneClient } from \"@medialane/sdk/starknet\";\nimport type { FastMintSigner } from \"./fast-mint/types.js\";\nimport type { ApiToken } from \"@medialane/sdk\";\nimport type { ImageResolver } from \"../utils/ipfs.js\";\n\nexport type AssetRef = Pick<ApiToken, \"chain\" | \"contractAddress\" | \"tokenId\">;\n\nexport interface CompanionApp {\n title: string;\n description: string;\n icon: ElementType;\n origin: string;\n}\n\nexport type ReportTarget =\n | { type: \"TOKEN\"; contract: string; tokenId: string; name?: string }\n | { type: \"COLLECTION\"; contract: string; name?: string }\n | { type: \"CREATOR\"; address: string; name?: string };\n\nexport type ReportDialogSlot = ComponentType<{ open: boolean; onOpenChange: (open: boolean) => void; target: ReportTarget }>;\n\nexport interface MedialaneApp {\n getClient: () => MedialaneClient;\n getSigner: () => Promise<FastMintSigner> | FastMintSigner;\n walletAddress: string | null;\n walletLoading?: boolean;\n onRequireWallet: () => void;\n releaseSigner?: () => void;\n ensureSignedIn?: () => Promise<void>;\n connectLabel?: string;\n connectDescription?: string;\n companion?: CompanionApp;\n ReportDialog?: ReportDialogSlot;\n resolveImage?: ImageResolver;\n}\n\nexport const MedialaneAppContext = createContext<MedialaneApp | null>(null);\n\nexport function MedialaneAppProvider({ value, children }: { value: MedialaneApp; children: ReactNode }) {\n return <MedialaneAppContext.Provider value={value}>{children}</MedialaneAppContext.Provider>;\n}\n\nexport function useMedialaneApp(): MedialaneApp {\n const app = useContext(MedialaneAppContext);\n if (!app) throw new Error(\"MedialaneAppProvider missing\");\n return app;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0CS;AAxCT,mBAAgG;AAqCzF,MAAM,0BAAsB,4BAAmC,IAAI;AAEnE,SAAS,qBAAqB,EAAE,OAAO,SAAS,GAAiD;AACtG,SAAO,4CAAC,oBAAoB,UAApB,EAA6B,OAAe,UAAS;AAC/D;AAEO,SAAS,kBAAgC;AAC9C,QAAM,UAAM,yBAAW,mBAAmB;AAC1C,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,8BAA8B;AACxD,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/components/medialane-app.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, useContext, type ComponentType, type ElementType, type ReactNode } from \"react\";\nimport type { MedialaneClient } from \"@medialane/sdk/starknet\";\nimport type { FastMintSigner } from \"./fast-mint/types.js\";\nimport type { ApiToken } from \"@medialane/sdk\";\nimport type { ImageResolver } from \"../utils/ipfs.js\";\n\nexport type AssetRef = Pick<ApiToken, \"chain\" | \"contractAddress\" | \"tokenId\">;\n\nexport interface CompanionApp {\n title: string;\n description: string;\n icon: ElementType;\n origin: string;\n}\n\nexport type ReportTarget =\n | { type: \"TOKEN\"; contract: string; tokenId: string; name?: string }\n | { type: \"COLLECTION\"; contract: string; name?: string }\n | { type: \"CREATOR\"; address: string; name?: string }\n | { type: \"COMMENT\"; commentId: string };\n\nexport type ReportDialogSlot = ComponentType<{ open: boolean; onOpenChange: (open: boolean) => void; target: ReportTarget }>;\n\nexport interface MedialaneApp {\n getClient: () => MedialaneClient;\n getSigner: () => Promise<FastMintSigner> | FastMintSigner;\n walletAddress: string | null;\n walletLoading?: boolean;\n onRequireWallet: () => void;\n releaseSigner?: () => void;\n ensureSignedIn?: () => Promise<void>;\n connectLabel?: string;\n connectDescription?: string;\n companion?: CompanionApp;\n ReportDialog?: ReportDialogSlot;\n resolveImage?: ImageResolver;\n}\n\nexport const MedialaneAppContext = createContext<MedialaneApp | null>(null);\n\nexport function MedialaneAppProvider({ value, children }: { value: MedialaneApp; children: ReactNode }) {\n return <MedialaneAppContext.Provider value={value}>{children}</MedialaneAppContext.Provider>;\n}\n\nexport function useMedialaneApp(): MedialaneApp {\n const app = useContext(MedialaneAppContext);\n if (!app) throw new Error(\"MedialaneAppProvider missing\");\n return app;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA2CS;AAzCT,mBAAgG;AAsCzF,MAAM,0BAAsB,4BAAmC,IAAI;AAEnE,SAAS,qBAAqB,EAAE,OAAO,SAAS,GAAiD;AACtG,SAAO,4CAAC,oBAAoB,UAApB,EAA6B,OAAe,UAAS;AAC/D;AAEO,SAAS,kBAAgC;AAC9C,QAAM,UAAM,yBAAW,mBAAmB;AAC1C,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,8BAA8B;AACxD,SAAO;AACT;","names":[]}
@@ -27,6 +27,9 @@ type ReportTarget = {
27
27
  type: "CREATOR";
28
28
  address: string;
29
29
  name?: string;
30
+ } | {
31
+ type: "COMMENT";
32
+ commentId: string;
30
33
  };
31
34
  type ReportDialogSlot = ComponentType<{
32
35
  open: boolean;
@@ -27,6 +27,9 @@ type ReportTarget = {
27
27
  type: "CREATOR";
28
28
  address: string;
29
29
  name?: string;
30
+ } | {
31
+ type: "COMMENT";
32
+ commentId: string;
30
33
  };
31
34
  type ReportDialogSlot = ComponentType<{
32
35
  open: boolean;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/medialane-app.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, useContext, type ComponentType, type ElementType, type ReactNode } from \"react\";\nimport type { MedialaneClient } from \"@medialane/sdk/starknet\";\nimport type { FastMintSigner } from \"./fast-mint/types.js\";\nimport type { ApiToken } from \"@medialane/sdk\";\nimport type { ImageResolver } from \"../utils/ipfs.js\";\n\nexport type AssetRef = Pick<ApiToken, \"chain\" | \"contractAddress\" | \"tokenId\">;\n\nexport interface CompanionApp {\n title: string;\n description: string;\n icon: ElementType;\n origin: string;\n}\n\nexport type ReportTarget =\n | { type: \"TOKEN\"; contract: string; tokenId: string; name?: string }\n | { type: \"COLLECTION\"; contract: string; name?: string }\n | { type: \"CREATOR\"; address: string; name?: string };\n\nexport type ReportDialogSlot = ComponentType<{ open: boolean; onOpenChange: (open: boolean) => void; target: ReportTarget }>;\n\nexport interface MedialaneApp {\n getClient: () => MedialaneClient;\n getSigner: () => Promise<FastMintSigner> | FastMintSigner;\n walletAddress: string | null;\n walletLoading?: boolean;\n onRequireWallet: () => void;\n releaseSigner?: () => void;\n ensureSignedIn?: () => Promise<void>;\n connectLabel?: string;\n connectDescription?: string;\n companion?: CompanionApp;\n ReportDialog?: ReportDialogSlot;\n resolveImage?: ImageResolver;\n}\n\nexport const MedialaneAppContext = createContext<MedialaneApp | null>(null);\n\nexport function MedialaneAppProvider({ value, children }: { value: MedialaneApp; children: ReactNode }) {\n return <MedialaneAppContext.Provider value={value}>{children}</MedialaneAppContext.Provider>;\n}\n\nexport function useMedialaneApp(): MedialaneApp {\n const app = useContext(MedialaneAppContext);\n if (!app) throw new Error(\"MedialaneAppProvider missing\");\n return app;\n}\n"],"mappings":";AA0CS;AAxCT,SAAS,eAAe,kBAAwE;AAqCzF,MAAM,sBAAsB,cAAmC,IAAI;AAEnE,SAAS,qBAAqB,EAAE,OAAO,SAAS,GAAiD;AACtG,SAAO,oBAAC,oBAAoB,UAApB,EAA6B,OAAe,UAAS;AAC/D;AAEO,SAAS,kBAAgC;AAC9C,QAAM,MAAM,WAAW,mBAAmB;AAC1C,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,8BAA8B;AACxD,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/components/medialane-app.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, useContext, type ComponentType, type ElementType, type ReactNode } from \"react\";\nimport type { MedialaneClient } from \"@medialane/sdk/starknet\";\nimport type { FastMintSigner } from \"./fast-mint/types.js\";\nimport type { ApiToken } from \"@medialane/sdk\";\nimport type { ImageResolver } from \"../utils/ipfs.js\";\n\nexport type AssetRef = Pick<ApiToken, \"chain\" | \"contractAddress\" | \"tokenId\">;\n\nexport interface CompanionApp {\n title: string;\n description: string;\n icon: ElementType;\n origin: string;\n}\n\nexport type ReportTarget =\n | { type: \"TOKEN\"; contract: string; tokenId: string; name?: string }\n | { type: \"COLLECTION\"; contract: string; name?: string }\n | { type: \"CREATOR\"; address: string; name?: string }\n | { type: \"COMMENT\"; commentId: string };\n\nexport type ReportDialogSlot = ComponentType<{ open: boolean; onOpenChange: (open: boolean) => void; target: ReportTarget }>;\n\nexport interface MedialaneApp {\n getClient: () => MedialaneClient;\n getSigner: () => Promise<FastMintSigner> | FastMintSigner;\n walletAddress: string | null;\n walletLoading?: boolean;\n onRequireWallet: () => void;\n releaseSigner?: () => void;\n ensureSignedIn?: () => Promise<void>;\n connectLabel?: string;\n connectDescription?: string;\n companion?: CompanionApp;\n ReportDialog?: ReportDialogSlot;\n resolveImage?: ImageResolver;\n}\n\nexport const MedialaneAppContext = createContext<MedialaneApp | null>(null);\n\nexport function MedialaneAppProvider({ value, children }: { value: MedialaneApp; children: ReactNode }) {\n return <MedialaneAppContext.Provider value={value}>{children}</MedialaneAppContext.Provider>;\n}\n\nexport function useMedialaneApp(): MedialaneApp {\n const app = useContext(MedialaneAppContext);\n if (!app) throw new Error(\"MedialaneAppProvider missing\");\n return app;\n}\n"],"mappings":";AA2CS;AAzCT,SAAS,eAAe,kBAAwE;AAsCzF,MAAM,sBAAsB,cAAmC,IAAI;AAEnE,SAAS,qBAAqB,EAAE,OAAO,SAAS,GAAiD;AACtG,SAAO,oBAAC,oBAAoB,UAApB,EAA6B,OAAe,UAAS;AAC/D;AAEO,SAAS,kBAAgC;AAC9C,QAAM,MAAM,WAAW,mBAAmB;AAC1C,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,8BAA8B;AACxD,SAAO;AACT;","names":[]}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ "use client";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var pop_burn_button_exports = {};
21
+ __export(pop_burn_button_exports, {
22
+ PopBurnButton: () => PopBurnButton
23
+ });
24
+ module.exports = __toCommonJS(pop_burn_button_exports);
25
+ var import_jsx_runtime = require("react/jsx-runtime");
26
+ var import_react = require("react");
27
+ var import_lucide_react = require("lucide-react");
28
+ var import_button = require("./button.js");
29
+ var import_medialane_app = require("./medialane-app.js");
30
+ var import_run_intent_calls = require("../utils/run-intent-calls.js");
31
+ var import_use_transaction = require("../utils/use-transaction.js");
32
+ function PopBurnButton({ collectionAddress, tokenId, onBurned }) {
33
+ const app = (0, import_medialane_app.useMedialaneApp)();
34
+ const [confirming, setConfirming] = (0, import_react.useState)(false);
35
+ const tx = (0, import_use_transaction.useTransaction)();
36
+ const busy = tx.phase === "preparing" || tx.phase === "submitting" || tx.phase === "confirming";
37
+ (0, import_react.useEffect)(() => {
38
+ if (tx.phase === "success") onBurned?.();
39
+ }, [tx.phase, onBurned]);
40
+ if (tx.phase === "success") {
41
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-xs text-muted-foreground", children: "Removed from your wallet." });
42
+ }
43
+ if (!confirming) {
44
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_button.Button, { variant: "ghost", size: "sm", className: "text-muted-foreground", onClick: () => setConfirming(true), children: [
45
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Trash2, { className: "h-3.5 w-3.5 mr-1.5" }),
46
+ "Remove from my wallet"
47
+ ] });
48
+ }
49
+ const remove = () => void tx.run(async (signer) => {
50
+ await (0, import_run_intent_calls.runIntentCalls)(signer, () => app.getClient().api.intents.create("pop-burn", { owner: signer.address, collection: collectionAddress, tokenId: String(tokenId) }));
51
+ });
52
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "space-y-2 rounded-xl border border-border p-3", children: [
53
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-xs text-muted-foreground", children: "This permanently destroys this credential. You won't be able to claim it again." }),
54
+ tx.phase === "error" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-xs text-destructive", children: tx.error }),
55
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex gap-2", children: [
56
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_button.Button, { variant: "outline", size: "sm", className: "flex-1", disabled: busy, onClick: () => setConfirming(false), children: "Keep it" }),
57
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_button.Button, { variant: "destructive", size: "sm", className: "flex-1", disabled: busy, onClick: remove, children: busy ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Loader2, { className: "h-3.5 w-3.5 animate-spin" }) : "Remove" })
58
+ ] })
59
+ ] });
60
+ }
61
+ // Annotate the CommonJS export names for ESM import in node:
62
+ 0 && (module.exports = {
63
+ PopBurnButton
64
+ });
65
+ //# sourceMappingURL=pop-burn-button.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/pop-burn-button.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useState } from \"react\";\nimport { Loader2, Trash2 } from \"lucide-react\";\nimport { Button } from \"./button.js\";\nimport { useMedialaneApp } from \"./medialane-app.js\";\nimport { runIntentCalls } from \"../utils/run-intent-calls.js\";\nimport { useTransaction } from \"../utils/use-transaction.js\";\n\nexport interface PopBurnButtonProps {\n collectionAddress: string;\n tokenId: string;\n onBurned?: () => void;\n}\n\nexport function PopBurnButton({ collectionAddress, tokenId, onBurned }: PopBurnButtonProps) {\n const app = useMedialaneApp();\n const [confirming, setConfirming] = useState(false);\n const tx = useTransaction();\n const busy = tx.phase === \"preparing\" || tx.phase === \"submitting\" || tx.phase === \"confirming\";\n\n useEffect(() => {\n if (tx.phase === \"success\") onBurned?.();\n }, [tx.phase, onBurned]);\n\n if (tx.phase === \"success\") {\n return <p className=\"text-xs text-muted-foreground\">Removed from your wallet.</p>;\n }\n\n if (!confirming) {\n return (\n <Button variant=\"ghost\" size=\"sm\" className=\"text-muted-foreground\" onClick={() => setConfirming(true)}>\n <Trash2 className=\"h-3.5 w-3.5 mr-1.5\" />\n Remove from my wallet\n </Button>\n );\n }\n\n const remove = () =>\n void tx.run(async (signer) => {\n await runIntentCalls(signer, () => app.getClient().api.intents.create(\"pop-burn\", { owner: signer.address, collection: collectionAddress, tokenId: String(tokenId) }));\n });\n\n return (\n <div className=\"space-y-2 rounded-xl border border-border p-3\">\n <p className=\"text-xs text-muted-foreground\">\n This permanently destroys this credential. You won&apos;t be able to claim it again.\n </p>\n {tx.phase === \"error\" && <p className=\"text-xs text-destructive\">{tx.error}</p>}\n <div className=\"flex gap-2\">\n <Button variant=\"outline\" size=\"sm\" className=\"flex-1\" disabled={busy} onClick={() => setConfirming(false)}>\n Keep it\n </Button>\n <Button variant=\"destructive\" size=\"sm\" className=\"flex-1\" disabled={busy} onClick={remove}>\n {busy ? <Loader2 className=\"h-3.5 w-3.5 animate-spin\" /> : \"Remove\"}\n </Button>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA0BW;AAxBX,mBAAoC;AACpC,0BAAgC;AAChC,oBAAuB;AACvB,2BAAgC;AAChC,8BAA+B;AAC/B,6BAA+B;AAQxB,SAAS,cAAc,EAAE,mBAAmB,SAAS,SAAS,GAAuB;AAC1F,QAAM,UAAM,sCAAgB;AAC5B,QAAM,CAAC,YAAY,aAAa,QAAI,uBAAS,KAAK;AAClD,QAAM,SAAK,uCAAe;AAC1B,QAAM,OAAO,GAAG,UAAU,eAAe,GAAG,UAAU,gBAAgB,GAAG,UAAU;AAEnF,8BAAU,MAAM;AACd,QAAI,GAAG,UAAU,UAAW,YAAW;AAAA,EACzC,GAAG,CAAC,GAAG,OAAO,QAAQ,CAAC;AAEvB,MAAI,GAAG,UAAU,WAAW;AAC1B,WAAO,4CAAC,OAAE,WAAU,iCAAgC,uCAAyB;AAAA,EAC/E;AAEA,MAAI,CAAC,YAAY;AACf,WACE,6CAAC,wBAAO,SAAQ,SAAQ,MAAK,MAAK,WAAU,yBAAwB,SAAS,MAAM,cAAc,IAAI,GACnG;AAAA,kDAAC,8BAAO,WAAU,sBAAqB;AAAA,MAAE;AAAA,OAE3C;AAAA,EAEJ;AAEA,QAAM,SAAS,MACb,KAAK,GAAG,IAAI,OAAO,WAAW;AAC5B,cAAM,wCAAe,QAAQ,MAAM,IAAI,UAAU,EAAE,IAAI,QAAQ,OAAO,YAAY,EAAE,OAAO,OAAO,SAAS,YAAY,mBAAmB,SAAS,OAAO,OAAO,EAAE,CAAC,CAAC;AAAA,EACvK,CAAC;AAEH,SACE,6CAAC,SAAI,WAAU,iDACb;AAAA,gDAAC,OAAE,WAAU,iCAAgC,6FAE7C;AAAA,IACC,GAAG,UAAU,WAAW,4CAAC,OAAE,WAAU,4BAA4B,aAAG,OAAM;AAAA,IAC3E,6CAAC,SAAI,WAAU,cACb;AAAA,kDAAC,wBAAO,SAAQ,WAAU,MAAK,MAAK,WAAU,UAAS,UAAU,MAAM,SAAS,MAAM,cAAc,KAAK,GAAG,qBAE5G;AAAA,MACA,4CAAC,wBAAO,SAAQ,eAAc,MAAK,MAAK,WAAU,UAAS,UAAU,MAAM,SAAS,QACjF,iBAAO,4CAAC,+BAAQ,WAAU,4BAA2B,IAAK,UAC7D;AAAA,OACF;AAAA,KACF;AAEJ;","names":[]}
@@ -0,0 +1,10 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ interface PopBurnButtonProps {
4
+ collectionAddress: string;
5
+ tokenId: string;
6
+ onBurned?: () => void;
7
+ }
8
+ declare function PopBurnButton({ collectionAddress, tokenId, onBurned }: PopBurnButtonProps): react_jsx_runtime.JSX.Element;
9
+
10
+ export { PopBurnButton, type PopBurnButtonProps };
@@ -0,0 +1,10 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ interface PopBurnButtonProps {
4
+ collectionAddress: string;
5
+ tokenId: string;
6
+ onBurned?: () => void;
7
+ }
8
+ declare function PopBurnButton({ collectionAddress, tokenId, onBurned }: PopBurnButtonProps): react_jsx_runtime.JSX.Element;
9
+
10
+ export { PopBurnButton, type PopBurnButtonProps };
@@ -0,0 +1,41 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useState } from "react";
4
+ import { Loader2, Trash2 } from "lucide-react";
5
+ import { Button } from "./button.js";
6
+ import { useMedialaneApp } from "./medialane-app.js";
7
+ import { runIntentCalls } from "../utils/run-intent-calls.js";
8
+ import { useTransaction } from "../utils/use-transaction.js";
9
+ function PopBurnButton({ collectionAddress, tokenId, onBurned }) {
10
+ const app = useMedialaneApp();
11
+ const [confirming, setConfirming] = useState(false);
12
+ const tx = useTransaction();
13
+ const busy = tx.phase === "preparing" || tx.phase === "submitting" || tx.phase === "confirming";
14
+ useEffect(() => {
15
+ if (tx.phase === "success") onBurned?.();
16
+ }, [tx.phase, onBurned]);
17
+ if (tx.phase === "success") {
18
+ return /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Removed from your wallet." });
19
+ }
20
+ if (!confirming) {
21
+ return /* @__PURE__ */ jsxs(Button, { variant: "ghost", size: "sm", className: "text-muted-foreground", onClick: () => setConfirming(true), children: [
22
+ /* @__PURE__ */ jsx(Trash2, { className: "h-3.5 w-3.5 mr-1.5" }),
23
+ "Remove from my wallet"
24
+ ] });
25
+ }
26
+ const remove = () => void tx.run(async (signer) => {
27
+ await runIntentCalls(signer, () => app.getClient().api.intents.create("pop-burn", { owner: signer.address, collection: collectionAddress, tokenId: String(tokenId) }));
28
+ });
29
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-2 rounded-xl border border-border p-3", children: [
30
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "This permanently destroys this credential. You won't be able to claim it again." }),
31
+ tx.phase === "error" && /* @__PURE__ */ jsx("p", { className: "text-xs text-destructive", children: tx.error }),
32
+ /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
33
+ /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", className: "flex-1", disabled: busy, onClick: () => setConfirming(false), children: "Keep it" }),
34
+ /* @__PURE__ */ jsx(Button, { variant: "destructive", size: "sm", className: "flex-1", disabled: busy, onClick: remove, children: busy ? /* @__PURE__ */ jsx(Loader2, { className: "h-3.5 w-3.5 animate-spin" }) : "Remove" })
35
+ ] })
36
+ ] });
37
+ }
38
+ export {
39
+ PopBurnButton
40
+ };
41
+ //# sourceMappingURL=pop-burn-button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/pop-burn-button.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useState } from \"react\";\nimport { Loader2, Trash2 } from \"lucide-react\";\nimport { Button } from \"./button.js\";\nimport { useMedialaneApp } from \"./medialane-app.js\";\nimport { runIntentCalls } from \"../utils/run-intent-calls.js\";\nimport { useTransaction } from \"../utils/use-transaction.js\";\n\nexport interface PopBurnButtonProps {\n collectionAddress: string;\n tokenId: string;\n onBurned?: () => void;\n}\n\nexport function PopBurnButton({ collectionAddress, tokenId, onBurned }: PopBurnButtonProps) {\n const app = useMedialaneApp();\n const [confirming, setConfirming] = useState(false);\n const tx = useTransaction();\n const busy = tx.phase === \"preparing\" || tx.phase === \"submitting\" || tx.phase === \"confirming\";\n\n useEffect(() => {\n if (tx.phase === \"success\") onBurned?.();\n }, [tx.phase, onBurned]);\n\n if (tx.phase === \"success\") {\n return <p className=\"text-xs text-muted-foreground\">Removed from your wallet.</p>;\n }\n\n if (!confirming) {\n return (\n <Button variant=\"ghost\" size=\"sm\" className=\"text-muted-foreground\" onClick={() => setConfirming(true)}>\n <Trash2 className=\"h-3.5 w-3.5 mr-1.5\" />\n Remove from my wallet\n </Button>\n );\n }\n\n const remove = () =>\n void tx.run(async (signer) => {\n await runIntentCalls(signer, () => app.getClient().api.intents.create(\"pop-burn\", { owner: signer.address, collection: collectionAddress, tokenId: String(tokenId) }));\n });\n\n return (\n <div className=\"space-y-2 rounded-xl border border-border p-3\">\n <p className=\"text-xs text-muted-foreground\">\n This permanently destroys this credential. You won&apos;t be able to claim it again.\n </p>\n {tx.phase === \"error\" && <p className=\"text-xs text-destructive\">{tx.error}</p>}\n <div className=\"flex gap-2\">\n <Button variant=\"outline\" size=\"sm\" className=\"flex-1\" disabled={busy} onClick={() => setConfirming(false)}>\n Keep it\n </Button>\n <Button variant=\"destructive\" size=\"sm\" className=\"flex-1\" disabled={busy} onClick={remove}>\n {busy ? <Loader2 className=\"h-3.5 w-3.5 animate-spin\" /> : \"Remove\"}\n </Button>\n </div>\n </div>\n );\n}\n"],"mappings":";AA0BW,cAKL,YALK;AAxBX,SAAS,WAAW,gBAAgB;AACpC,SAAS,SAAS,cAAc;AAChC,SAAS,cAAc;AACvB,SAAS,uBAAuB;AAChC,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAQxB,SAAS,cAAc,EAAE,mBAAmB,SAAS,SAAS,GAAuB;AAC1F,QAAM,MAAM,gBAAgB;AAC5B,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,KAAK;AAClD,QAAM,KAAK,eAAe;AAC1B,QAAM,OAAO,GAAG,UAAU,eAAe,GAAG,UAAU,gBAAgB,GAAG,UAAU;AAEnF,YAAU,MAAM;AACd,QAAI,GAAG,UAAU,UAAW,YAAW;AAAA,EACzC,GAAG,CAAC,GAAG,OAAO,QAAQ,CAAC;AAEvB,MAAI,GAAG,UAAU,WAAW;AAC1B,WAAO,oBAAC,OAAE,WAAU,iCAAgC,uCAAyB;AAAA,EAC/E;AAEA,MAAI,CAAC,YAAY;AACf,WACE,qBAAC,UAAO,SAAQ,SAAQ,MAAK,MAAK,WAAU,yBAAwB,SAAS,MAAM,cAAc,IAAI,GACnG;AAAA,0BAAC,UAAO,WAAU,sBAAqB;AAAA,MAAE;AAAA,OAE3C;AAAA,EAEJ;AAEA,QAAM,SAAS,MACb,KAAK,GAAG,IAAI,OAAO,WAAW;AAC5B,UAAM,eAAe,QAAQ,MAAM,IAAI,UAAU,EAAE,IAAI,QAAQ,OAAO,YAAY,EAAE,OAAO,OAAO,SAAS,YAAY,mBAAmB,SAAS,OAAO,OAAO,EAAE,CAAC,CAAC;AAAA,EACvK,CAAC;AAEH,SACE,qBAAC,SAAI,WAAU,iDACb;AAAA,wBAAC,OAAE,WAAU,iCAAgC,6FAE7C;AAAA,IACC,GAAG,UAAU,WAAW,oBAAC,OAAE,WAAU,4BAA4B,aAAG,OAAM;AAAA,IAC3E,qBAAC,SAAI,WAAU,cACb;AAAA,0BAAC,UAAO,SAAQ,WAAU,MAAK,MAAK,WAAU,UAAS,UAAU,MAAM,SAAS,MAAM,cAAc,KAAK,GAAG,qBAE5G;AAAA,MACA,oBAAC,UAAO,SAAQ,eAAc,MAAK,MAAK,WAAU,UAAS,UAAU,MAAM,SAAS,QACjF,iBAAO,oBAAC,WAAQ,WAAU,4BAA2B,IAAK,UAC7D;AAAA,OACF;AAAA,KACF;AAEJ;","names":[]}
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ "use client";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var pop_claim_button_exports = {};
21
+ __export(pop_claim_button_exports, {
22
+ PopClaimButton: () => PopClaimButton
23
+ });
24
+ module.exports = __toCommonJS(pop_claim_button_exports);
25
+ var import_jsx_runtime = require("react/jsx-runtime");
26
+ var import_react = require("react");
27
+ var import_lucide_react = require("lucide-react");
28
+ var import_starknet = require("@medialane/sdk/starknet");
29
+ var import_button = require("./button.js");
30
+ var import_transaction_dialog = require("./transaction-dialog.js");
31
+ var import_transaction_done = require("./transaction-done.js");
32
+ var import_reward_earned = require("./rewards/reward-earned.js");
33
+ var import_medialane_app = require("./medialane-app.js");
34
+ var import_claim_proof = require("../utils/drop/claim-proof.js");
35
+ var import_run_intent_calls = require("../utils/run-intent-calls.js");
36
+ var import_use_pop = require("../utils/use-pop.js");
37
+ var import_use_transaction = require("../utils/use-transaction.js");
38
+ function PopClaimButton({ collectionAddress }) {
39
+ const app = (0, import_medialane_app.useMedialaneApp)();
40
+ const { walletAddress } = app;
41
+ const { hasClaimed, mutate } = (0, import_use_pop.usePopClaimStatus)(collectionAddress, walletAddress);
42
+ const [proof, setProof] = (0, import_react.useState)(null);
43
+ const [info, setInfo] = (0, import_react.useState)(null);
44
+ const tx = (0, import_use_transaction.useTransaction)();
45
+ const busy = tx.phase === "preparing" || tx.phase === "submitting" || tx.phase === "confirming";
46
+ (0, import_react.useEffect)(() => {
47
+ let storage = null;
48
+ try {
49
+ storage = window.sessionStorage;
50
+ } catch {
51
+ storage = null;
52
+ }
53
+ setProof((0, import_claim_proof.claimProofFor)(storage, collectionAddress, window.location.hash));
54
+ app.getClient().api.chainReads.popClaimInfo(collectionAddress).then(setInfo).catch(() => setInfo(null));
55
+ }, [app, collectionAddress]);
56
+ (0, import_react.useEffect)(() => {
57
+ if (tx.phase === "success") void mutate();
58
+ }, [tx.phase, mutate]);
59
+ const state = (0, import_starknet.popClaimState)({
60
+ hasClaimed,
61
+ proof,
62
+ wallet: walletAddress,
63
+ info: info && { ...info, now: Math.floor(Date.now() / 1e3) }
64
+ });
65
+ const claim = () => {
66
+ if (!proof) return;
67
+ void tx.run(async (signer) => {
68
+ await (0, import_run_intent_calls.runIntentCalls)(signer, () => app.getClient().api.intents.create("pop-claim", { claimer: signer.address, collection: collectionAddress, proof }));
69
+ });
70
+ };
71
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
72
+ (state === "ready" || busy) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_button.Button, { size: "sm", className: "w-full gap-1.5", onClick: claim, disabled: busy, children: [
73
+ busy ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Loader2, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Award, { className: "h-3.5 w-3.5" }),
74
+ busy ? "Claiming\u2026" : "Claim credential"
75
+ ] }),
76
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_transaction_dialog.TransactionDialog, { tx, title: "Claim credential", workingLabel: "Claiming your credential\u2026", firstStepLabel: "Prepare claim", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
77
+ import_transaction_done.TransactionDone,
78
+ {
79
+ tx,
80
+ name: "Credential",
81
+ title: "Credential claimed!",
82
+ description: "Your proof of participation is now on-chain.",
83
+ footer: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_reward_earned.RewardEarned, { actionType: "claim_pop" })
84
+ }
85
+ ) })
86
+ ] });
87
+ }
88
+ // Annotate the CommonJS export names for ESM import in node:
89
+ 0 && (module.exports = {
90
+ PopClaimButton
91
+ });
92
+ //# sourceMappingURL=pop-claim-button.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/pop-claim-button.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useState } from \"react\";\nimport { Award, Loader2 } from \"lucide-react\";\nimport { popClaimState, type PopClaimInfo } from \"@medialane/sdk/starknet\";\nimport { Button } from \"./button.js\";\nimport { TransactionDialog } from \"./transaction-dialog.js\";\nimport { TransactionDone } from \"./transaction-done.js\";\nimport { RewardEarned } from \"./rewards/reward-earned.js\";\nimport { useMedialaneApp } from \"./medialane-app.js\";\nimport { claimProofFor } from \"../utils/drop/claim-proof.js\";\nimport { runIntentCalls } from \"../utils/run-intent-calls.js\";\nimport { usePopClaimStatus } from \"../utils/use-pop.js\";\nimport { useTransaction } from \"../utils/use-transaction.js\";\n\nexport function PopClaimButton({ collectionAddress }: { collectionAddress: string }) {\n const app = useMedialaneApp();\n const { walletAddress } = app;\n const { hasClaimed, mutate } = usePopClaimStatus(collectionAddress, walletAddress);\n const [proof, setProof] = useState<string[] | null>(null);\n const [info, setInfo] = useState<PopClaimInfo | null>(null);\n const tx = useTransaction();\n const busy = tx.phase === \"preparing\" || tx.phase === \"submitting\" || tx.phase === \"confirming\";\n\n useEffect(() => {\n let storage: Storage | null = null;\n try {\n storage = window.sessionStorage;\n } catch {\n storage = null;\n }\n setProof(claimProofFor(storage, collectionAddress, window.location.hash));\n app.getClient().api.chainReads.popClaimInfo(collectionAddress)\n .then(setInfo)\n .catch(() => setInfo(null));\n }, [app, collectionAddress]);\n\n useEffect(() => {\n if (tx.phase === \"success\") void mutate();\n }, [tx.phase, mutate]);\n\n const state = popClaimState({\n hasClaimed,\n proof,\n wallet: walletAddress,\n info: info && { ...info, now: Math.floor(Date.now() / 1000) },\n });\n\n const claim = () => {\n if (!proof) return;\n void tx.run(async (signer) => {\n await runIntentCalls(signer, () => app.getClient().api.intents.create(\"pop-claim\", { claimer: signer.address, collection: collectionAddress, proof }));\n });\n };\n\n return (\n <>\n {(state === \"ready\" || busy) && (\n <Button size=\"sm\" className=\"w-full gap-1.5\" onClick={claim} disabled={busy}>\n {busy ? <Loader2 className=\"h-3.5 w-3.5 animate-spin\" /> : <Award className=\"h-3.5 w-3.5\" />}\n {busy ? \"Claiming…\" : \"Claim credential\"}\n </Button>\n )}\n <TransactionDialog tx={tx} title=\"Claim credential\" workingLabel=\"Claiming your credential…\" firstStepLabel=\"Prepare claim\">\n <TransactionDone\n tx={tx}\n name=\"Credential\"\n title=\"Credential claimed!\"\n description=\"Your proof of participation is now on-chain.\"\n footer={<RewardEarned actionType=\"claim_pop\" />}\n />\n </TransactionDialog>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAwDI;AAtDJ,mBAAoC;AACpC,0BAA+B;AAC/B,sBAAiD;AACjD,oBAAuB;AACvB,gCAAkC;AAClC,8BAAgC;AAChC,2BAA6B;AAC7B,2BAAgC;AAChC,yBAA8B;AAC9B,8BAA+B;AAC/B,qBAAkC;AAClC,6BAA+B;AAExB,SAAS,eAAe,EAAE,kBAAkB,GAAkC;AACnF,QAAM,UAAM,sCAAgB;AAC5B,QAAM,EAAE,cAAc,IAAI;AAC1B,QAAM,EAAE,YAAY,OAAO,QAAI,kCAAkB,mBAAmB,aAAa;AACjF,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAA0B,IAAI;AACxD,QAAM,CAAC,MAAM,OAAO,QAAI,uBAA8B,IAAI;AAC1D,QAAM,SAAK,uCAAe;AAC1B,QAAM,OAAO,GAAG,UAAU,eAAe,GAAG,UAAU,gBAAgB,GAAG,UAAU;AAEnF,8BAAU,MAAM;AACd,QAAI,UAA0B;AAC9B,QAAI;AACF,gBAAU,OAAO;AAAA,IACnB,QAAQ;AACN,gBAAU;AAAA,IACZ;AACA,iBAAS,kCAAc,SAAS,mBAAmB,OAAO,SAAS,IAAI,CAAC;AACxE,QAAI,UAAU,EAAE,IAAI,WAAW,aAAa,iBAAiB,EAC1D,KAAK,OAAO,EACZ,MAAM,MAAM,QAAQ,IAAI,CAAC;AAAA,EAC9B,GAAG,CAAC,KAAK,iBAAiB,CAAC;AAE3B,8BAAU,MAAM;AACd,QAAI,GAAG,UAAU,UAAW,MAAK,OAAO;AAAA,EAC1C,GAAG,CAAC,GAAG,OAAO,MAAM,CAAC;AAErB,QAAM,YAAQ,+BAAc;AAAA,IAC1B;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,MAAM,QAAQ,EAAE,GAAG,MAAM,KAAK,KAAK,MAAM,KAAK,IAAI,IAAI,GAAI,EAAE;AAAA,EAC9D,CAAC;AAED,QAAM,QAAQ,MAAM;AAClB,QAAI,CAAC,MAAO;AACZ,SAAK,GAAG,IAAI,OAAO,WAAW;AAC5B,gBAAM,wCAAe,QAAQ,MAAM,IAAI,UAAU,EAAE,IAAI,QAAQ,OAAO,aAAa,EAAE,SAAS,OAAO,SAAS,YAAY,mBAAmB,MAAM,CAAC,CAAC;AAAA,IACvJ,CAAC;AAAA,EACH;AAEA,SACE,4EACI;AAAA,eAAU,WAAW,SACrB,6CAAC,wBAAO,MAAK,MAAK,WAAU,kBAAiB,SAAS,OAAO,UAAU,MACpE;AAAA,aAAO,4CAAC,+BAAQ,WAAU,4BAA2B,IAAK,4CAAC,6BAAM,WAAU,eAAc;AAAA,MACzF,OAAO,mBAAc;AAAA,OACxB;AAAA,IAEF,4CAAC,+CAAkB,IAAQ,OAAM,oBAAmB,cAAa,kCAA4B,gBAAe,iBAC1G;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,MAAK;AAAA,QACL,OAAM;AAAA,QACN,aAAY;AAAA,QACZ,QAAQ,4CAAC,qCAAa,YAAW,aAAY;AAAA;AAAA,IAC/C,GACF;AAAA,KACF;AAEJ;","names":[]}
@@ -0,0 +1,7 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ declare function PopClaimButton({ collectionAddress }: {
4
+ collectionAddress: string;
5
+ }): react_jsx_runtime.JSX.Element;
6
+
7
+ export { PopClaimButton };
@@ -0,0 +1,7 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ declare function PopClaimButton({ collectionAddress }: {
4
+ collectionAddress: string;
5
+ }): react_jsx_runtime.JSX.Element;
6
+
7
+ export { PopClaimButton };
@@ -0,0 +1,68 @@
1
+ "use client";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useState } from "react";
4
+ import { Award, Loader2 } from "lucide-react";
5
+ import { popClaimState } from "@medialane/sdk/starknet";
6
+ import { Button } from "./button.js";
7
+ import { TransactionDialog } from "./transaction-dialog.js";
8
+ import { TransactionDone } from "./transaction-done.js";
9
+ import { RewardEarned } from "./rewards/reward-earned.js";
10
+ import { useMedialaneApp } from "./medialane-app.js";
11
+ import { claimProofFor } from "../utils/drop/claim-proof.js";
12
+ import { runIntentCalls } from "../utils/run-intent-calls.js";
13
+ import { usePopClaimStatus } from "../utils/use-pop.js";
14
+ import { useTransaction } from "../utils/use-transaction.js";
15
+ function PopClaimButton({ collectionAddress }) {
16
+ const app = useMedialaneApp();
17
+ const { walletAddress } = app;
18
+ const { hasClaimed, mutate } = usePopClaimStatus(collectionAddress, walletAddress);
19
+ const [proof, setProof] = useState(null);
20
+ const [info, setInfo] = useState(null);
21
+ const tx = useTransaction();
22
+ const busy = tx.phase === "preparing" || tx.phase === "submitting" || tx.phase === "confirming";
23
+ useEffect(() => {
24
+ let storage = null;
25
+ try {
26
+ storage = window.sessionStorage;
27
+ } catch {
28
+ storage = null;
29
+ }
30
+ setProof(claimProofFor(storage, collectionAddress, window.location.hash));
31
+ app.getClient().api.chainReads.popClaimInfo(collectionAddress).then(setInfo).catch(() => setInfo(null));
32
+ }, [app, collectionAddress]);
33
+ useEffect(() => {
34
+ if (tx.phase === "success") void mutate();
35
+ }, [tx.phase, mutate]);
36
+ const state = popClaimState({
37
+ hasClaimed,
38
+ proof,
39
+ wallet: walletAddress,
40
+ info: info && { ...info, now: Math.floor(Date.now() / 1e3) }
41
+ });
42
+ const claim = () => {
43
+ if (!proof) return;
44
+ void tx.run(async (signer) => {
45
+ await runIntentCalls(signer, () => app.getClient().api.intents.create("pop-claim", { claimer: signer.address, collection: collectionAddress, proof }));
46
+ });
47
+ };
48
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
49
+ (state === "ready" || busy) && /* @__PURE__ */ jsxs(Button, { size: "sm", className: "w-full gap-1.5", onClick: claim, disabled: busy, children: [
50
+ busy ? /* @__PURE__ */ jsx(Loader2, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ jsx(Award, { className: "h-3.5 w-3.5" }),
51
+ busy ? "Claiming\u2026" : "Claim credential"
52
+ ] }),
53
+ /* @__PURE__ */ jsx(TransactionDialog, { tx, title: "Claim credential", workingLabel: "Claiming your credential\u2026", firstStepLabel: "Prepare claim", children: /* @__PURE__ */ jsx(
54
+ TransactionDone,
55
+ {
56
+ tx,
57
+ name: "Credential",
58
+ title: "Credential claimed!",
59
+ description: "Your proof of participation is now on-chain.",
60
+ footer: /* @__PURE__ */ jsx(RewardEarned, { actionType: "claim_pop" })
61
+ }
62
+ ) })
63
+ ] });
64
+ }
65
+ export {
66
+ PopClaimButton
67
+ };
68
+ //# sourceMappingURL=pop-claim-button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/pop-claim-button.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useState } from \"react\";\nimport { Award, Loader2 } from \"lucide-react\";\nimport { popClaimState, type PopClaimInfo } from \"@medialane/sdk/starknet\";\nimport { Button } from \"./button.js\";\nimport { TransactionDialog } from \"./transaction-dialog.js\";\nimport { TransactionDone } from \"./transaction-done.js\";\nimport { RewardEarned } from \"./rewards/reward-earned.js\";\nimport { useMedialaneApp } from \"./medialane-app.js\";\nimport { claimProofFor } from \"../utils/drop/claim-proof.js\";\nimport { runIntentCalls } from \"../utils/run-intent-calls.js\";\nimport { usePopClaimStatus } from \"../utils/use-pop.js\";\nimport { useTransaction } from \"../utils/use-transaction.js\";\n\nexport function PopClaimButton({ collectionAddress }: { collectionAddress: string }) {\n const app = useMedialaneApp();\n const { walletAddress } = app;\n const { hasClaimed, mutate } = usePopClaimStatus(collectionAddress, walletAddress);\n const [proof, setProof] = useState<string[] | null>(null);\n const [info, setInfo] = useState<PopClaimInfo | null>(null);\n const tx = useTransaction();\n const busy = tx.phase === \"preparing\" || tx.phase === \"submitting\" || tx.phase === \"confirming\";\n\n useEffect(() => {\n let storage: Storage | null = null;\n try {\n storage = window.sessionStorage;\n } catch {\n storage = null;\n }\n setProof(claimProofFor(storage, collectionAddress, window.location.hash));\n app.getClient().api.chainReads.popClaimInfo(collectionAddress)\n .then(setInfo)\n .catch(() => setInfo(null));\n }, [app, collectionAddress]);\n\n useEffect(() => {\n if (tx.phase === \"success\") void mutate();\n }, [tx.phase, mutate]);\n\n const state = popClaimState({\n hasClaimed,\n proof,\n wallet: walletAddress,\n info: info && { ...info, now: Math.floor(Date.now() / 1000) },\n });\n\n const claim = () => {\n if (!proof) return;\n void tx.run(async (signer) => {\n await runIntentCalls(signer, () => app.getClient().api.intents.create(\"pop-claim\", { claimer: signer.address, collection: collectionAddress, proof }));\n });\n };\n\n return (\n <>\n {(state === \"ready\" || busy) && (\n <Button size=\"sm\" className=\"w-full gap-1.5\" onClick={claim} disabled={busy}>\n {busy ? <Loader2 className=\"h-3.5 w-3.5 animate-spin\" /> : <Award className=\"h-3.5 w-3.5\" />}\n {busy ? \"Claiming…\" : \"Claim credential\"}\n </Button>\n )}\n <TransactionDialog tx={tx} title=\"Claim credential\" workingLabel=\"Claiming your credential…\" firstStepLabel=\"Prepare claim\">\n <TransactionDone\n tx={tx}\n name=\"Credential\"\n title=\"Credential claimed!\"\n description=\"Your proof of participation is now on-chain.\"\n footer={<RewardEarned actionType=\"claim_pop\" />}\n />\n </TransactionDialog>\n </>\n );\n}\n"],"mappings":";AAwDI,mBAGc,KADV,YAFJ;AAtDJ,SAAS,WAAW,gBAAgB;AACpC,SAAS,OAAO,eAAe;AAC/B,SAAS,qBAAwC;AACjD,SAAS,cAAc;AACvB,SAAS,yBAAyB;AAClC,SAAS,uBAAuB;AAChC,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAChC,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB;AAC/B,SA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