@medialane/ui 0.209.1 → 0.210.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.
- package/dist/components/article-body.cjs +151 -0
- package/dist/components/article-body.cjs.map +1 -0
- package/dist/components/article-body.d.cts +8 -0
- package/dist/components/article-body.d.ts +8 -0
- package/dist/components/article-body.js +127 -0
- package/dist/components/article-body.js.map +1 -0
- package/dist/components/asset-page.cjs +92 -55
- package/dist/components/asset-page.cjs.map +1 -1
- package/dist/components/asset-page.js +93 -56
- package/dist/components/asset-page.js.map +1 -1
- package/dist/components/asset-publication-header.cjs +74 -0
- package/dist/components/asset-publication-header.cjs.map +1 -0
- package/dist/components/asset-publication-header.d.cts +19 -0
- package/dist/components/asset-publication-header.d.ts +19 -0
- package/dist/components/asset-publication-header.js +40 -0
- package/dist/components/asset-publication-header.js.map +1 -0
- package/dist/components/button.d.cts +1 -1
- package/dist/components/button.d.ts +1 -1
- package/dist/components/fast-mint/fast-mint.d.cts +2 -2
- package/dist/components/fast-mint/fast-mint.d.ts +2 -2
- package/dist/components/sheet.d.cts +1 -1
- package/dist/components/sheet.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,151 @@
|
|
|
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 article_body_exports = {};
|
|
21
|
+
__export(article_body_exports, {
|
|
22
|
+
ArticleBody: () => ArticleBody
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(article_body_exports);
|
|
25
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var import_cn = require("../utils/cn.js");
|
|
28
|
+
var import_ipfs = require("../utils/ipfs.js");
|
|
29
|
+
const INLINE = /(!\[([^\]]*)\]\(([^)\s]+)\)|\[([^\]]+)\]\(([^)\s]+)\)|\*\*([^*]+)\*\*|\*([^*\n]+)\*|`([^`\n]+)`|(https?:\/\/[^\s<]+[^\s<.,;:!?)\]])|\\([\\`*[\]#>+\-.)(!]))/g;
|
|
30
|
+
const IMAGE_LINE = /^!\[([^\]]*)\]\(([^)\s]+)\)$/;
|
|
31
|
+
const HEADING = /^(#{1,6})\s+(.*)$/;
|
|
32
|
+
const RULE = /^(-{3,}|\*{3,}|_{3,})$/;
|
|
33
|
+
const BULLET = /^[-*+]\s+(.*)$/;
|
|
34
|
+
const NUMBERED = /^\d+[.)]\s+(.*)$/;
|
|
35
|
+
const safeLink = (href) => /^(https?:\/\/|mailto:)/i.test(href);
|
|
36
|
+
const safeImage = (src) => /^(https?:\/\/|ipfs:\/\/)/i.test(src);
|
|
37
|
+
function Link({ href, children }) {
|
|
38
|
+
if (!safeLink(href)) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
|
|
39
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { href, target: "_blank", rel: "noopener noreferrer nofollow ugc", className: "text-primary underline underline-offset-2 hover:opacity-80 break-words", children });
|
|
40
|
+
}
|
|
41
|
+
function Picture({ src, alt }) {
|
|
42
|
+
if (!safeImage(src)) return null;
|
|
43
|
+
const url = (0, import_ipfs.ipfsToHttp)(src, { width: null });
|
|
44
|
+
if (!url) return null;
|
|
45
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", { src: url, alt, loading: "lazy", referrerPolicy: "no-referrer", className: "my-6 h-auto max-w-full rounded-2xl" });
|
|
46
|
+
}
|
|
47
|
+
function inline(text) {
|
|
48
|
+
const out = [];
|
|
49
|
+
let last = 0;
|
|
50
|
+
let key = 0;
|
|
51
|
+
for (const m of text.matchAll(INLINE)) {
|
|
52
|
+
const at = m.index ?? 0;
|
|
53
|
+
if (at > last) out.push(text.slice(last, at));
|
|
54
|
+
if (m[3] !== void 0) out.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Picture, { src: m[3], alt: m[2] }, key++));
|
|
55
|
+
else if (m[5] !== void 0) out.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Link, { href: m[5], children: m[4] }, key++));
|
|
56
|
+
else if (m[6] !== void 0) out.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { className: "font-semibold text-foreground", children: m[6] }, key++));
|
|
57
|
+
else if (m[7] !== void 0) out.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)("em", { children: m[7] }, key++));
|
|
58
|
+
else if (m[8] !== void 0) out.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { className: "rounded bg-muted px-1.5 py-0.5 text-[0.9em]", children: m[8] }, key++));
|
|
59
|
+
else if (m[9] !== void 0) out.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Link, { href: m[9], children: m[9] }, key++));
|
|
60
|
+
else out.push(m[10]);
|
|
61
|
+
last = at + m[0].length;
|
|
62
|
+
}
|
|
63
|
+
if (last < text.length) out.push(text.slice(last));
|
|
64
|
+
return out;
|
|
65
|
+
}
|
|
66
|
+
function lines(text) {
|
|
67
|
+
return text.split("\n").map((line, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
|
|
68
|
+
i > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}) : null,
|
|
69
|
+
inline(line)
|
|
70
|
+
] }, i));
|
|
71
|
+
}
|
|
72
|
+
const HEADING_CLASS = {
|
|
73
|
+
2: "mt-10 mb-3 text-2xl lg:text-3xl font-bold",
|
|
74
|
+
3: "mt-8 mb-2 text-xl lg:text-2xl font-semibold",
|
|
75
|
+
4: "mt-6 mb-2 text-lg font-semibold"
|
|
76
|
+
};
|
|
77
|
+
function blocks(text) {
|
|
78
|
+
const rows = text.replace(/\r\n?/g, "\n").split("\n");
|
|
79
|
+
const out = [];
|
|
80
|
+
let i = 0;
|
|
81
|
+
let key = 0;
|
|
82
|
+
while (i < rows.length) {
|
|
83
|
+
const row = rows[i].trim();
|
|
84
|
+
if (!row) {
|
|
85
|
+
i++;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (row.startsWith("```")) {
|
|
89
|
+
const code = [];
|
|
90
|
+
i++;
|
|
91
|
+
while (i < rows.length && !rows[i].trim().startsWith("```")) code.push(rows[i++]);
|
|
92
|
+
i++;
|
|
93
|
+
out.push(
|
|
94
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { className: "my-6 overflow-x-auto rounded-2xl bg-muted/60 p-4 text-sm leading-relaxed", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { children: code.join("\n") }) }, key++)
|
|
95
|
+
);
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
const heading = row.match(HEADING);
|
|
99
|
+
if (heading) {
|
|
100
|
+
const level = Math.min(Math.max(heading[1].length + 1, 2), 4);
|
|
101
|
+
const Tag = `h${level}`;
|
|
102
|
+
out.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tag, { className: HEADING_CLASS[level], children: inline(heading[2]) }, key++));
|
|
103
|
+
i++;
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (RULE.test(row)) {
|
|
107
|
+
out.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)("hr", { className: "my-10 border-border" }, key++));
|
|
108
|
+
i++;
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (row.startsWith(">")) {
|
|
112
|
+
const quote = [];
|
|
113
|
+
while (i < rows.length && rows[i].trim().startsWith(">")) quote.push(rows[i++].trim().replace(/^>\s?/, ""));
|
|
114
|
+
out.push(
|
|
115
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("blockquote", { className: "my-6 border-l-2 border-primary/50 pl-5 italic text-muted-foreground", children: lines(quote.join("\n")) }, key++)
|
|
116
|
+
);
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
const ordered = NUMBERED.test(row);
|
|
120
|
+
if (ordered || BULLET.test(row)) {
|
|
121
|
+
const item = ordered ? NUMBERED : BULLET;
|
|
122
|
+
const items = [];
|
|
123
|
+
while (i < rows.length && item.test(rows[i].trim())) items.push(rows[i++].trim().match(item)[1]);
|
|
124
|
+
const List = ordered ? "ol" : "ul";
|
|
125
|
+
out.push(
|
|
126
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(List, { className: (0, import_cn.cn)("my-5 space-y-1.5 pl-6", ordered ? "list-decimal" : "list-disc"), children: items.map((it, n) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: inline(it) }, n)) }, key++)
|
|
127
|
+
);
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
const image = row.match(IMAGE_LINE);
|
|
131
|
+
if (image) {
|
|
132
|
+
out.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Picture, { src: image[2], alt: image[1] }, key++));
|
|
133
|
+
i++;
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
const paragraph = [];
|
|
137
|
+
while (i < rows.length && rows[i].trim() && !rows[i].trim().startsWith("```") && !HEADING.test(rows[i].trim()) && !RULE.test(rows[i].trim()) && !rows[i].trim().startsWith(">") && !IMAGE_LINE.test(rows[i].trim())) {
|
|
138
|
+
paragraph.push(rows[i++].trim());
|
|
139
|
+
}
|
|
140
|
+
out.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "my-5", children: lines(paragraph.join("\n")) }, key++));
|
|
141
|
+
}
|
|
142
|
+
return out;
|
|
143
|
+
}
|
|
144
|
+
function ArticleBody({ text, className }) {
|
|
145
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: (0, import_cn.cn)("text-base lg:text-lg leading-8 text-foreground/90 break-words", className), children: blocks(text) });
|
|
146
|
+
}
|
|
147
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
148
|
+
0 && (module.exports = {
|
|
149
|
+
ArticleBody
|
|
150
|
+
});
|
|
151
|
+
//# sourceMappingURL=article-body.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/article-body.tsx"],"sourcesContent":["\"use client\";\n\nimport { Fragment, type ReactNode } from \"react\";\nimport { cn } from \"../utils/cn.js\";\nimport { ipfsToHttp } from \"../utils/ipfs.js\";\n\nconst INLINE = /(!\\[([^\\]]*)\\]\\(([^)\\s]+)\\)|\\[([^\\]]+)\\]\\(([^)\\s]+)\\)|\\*\\*([^*]+)\\*\\*|\\*([^*\\n]+)\\*|`([^`\\n]+)`|(https?:\\/\\/[^\\s<]+[^\\s<.,;:!?)\\]])|\\\\([\\\\`*[\\]#>+\\-.)(!]))/g;\nconst IMAGE_LINE = /^!\\[([^\\]]*)\\]\\(([^)\\s]+)\\)$/;\nconst HEADING = /^(#{1,6})\\s+(.*)$/;\nconst RULE = /^(-{3,}|\\*{3,}|_{3,})$/;\nconst BULLET = /^[-*+]\\s+(.*)$/;\nconst NUMBERED = /^\\d+[.)]\\s+(.*)$/;\n\nconst safeLink = (href: string) => /^(https?:\\/\\/|mailto:)/i.test(href);\nconst safeImage = (src: string) => /^(https?:\\/\\/|ipfs:\\/\\/)/i.test(src);\n\nfunction Link({ href, children }: { href: string; children: ReactNode }) {\n if (!safeLink(href)) return <>{children}</>;\n return (\n <a href={href} target=\"_blank\" rel=\"noopener noreferrer nofollow ugc\" className=\"text-primary underline underline-offset-2 hover:opacity-80 break-words\">\n {children}\n </a>\n );\n}\n\nfunction Picture({ src, alt }: { src: string; alt: string }) {\n if (!safeImage(src)) return null;\n const url = ipfsToHttp(src, { width: null });\n if (!url) return null;\n return <img src={url} alt={alt} loading=\"lazy\" referrerPolicy=\"no-referrer\" className=\"my-6 h-auto max-w-full rounded-2xl\" />;\n}\n\nfunction inline(text: string): ReactNode[] {\n const out: ReactNode[] = [];\n let last = 0;\n let key = 0;\n for (const m of text.matchAll(INLINE)) {\n const at = m.index ?? 0;\n if (at > last) out.push(text.slice(last, at));\n if (m[3] !== undefined) out.push(<Picture key={key++} src={m[3]} alt={m[2]} />);\n else if (m[5] !== undefined) out.push(<Link key={key++} href={m[5]}>{m[4]}</Link>);\n else if (m[6] !== undefined) out.push(<strong key={key++} className=\"font-semibold text-foreground\">{m[6]}</strong>);\n else if (m[7] !== undefined) out.push(<em key={key++}>{m[7]}</em>);\n else if (m[8] !== undefined) out.push(<code key={key++} className=\"rounded bg-muted px-1.5 py-0.5 text-[0.9em]\">{m[8]}</code>);\n else if (m[9] !== undefined) out.push(<Link key={key++} href={m[9]}>{m[9]}</Link>);\n else out.push(m[10]);\n last = at + m[0].length;\n }\n if (last < text.length) out.push(text.slice(last));\n return out;\n}\n\nfunction lines(text: string): ReactNode[] {\n return text.split(\"\\n\").map((line, i) => (\n <Fragment key={i}>\n {i > 0 ? <br /> : null}\n {inline(line)}\n </Fragment>\n ));\n}\n\nconst HEADING_CLASS: Record<number, string> = {\n 2: \"mt-10 mb-3 text-2xl lg:text-3xl font-bold\",\n 3: \"mt-8 mb-2 text-xl lg:text-2xl font-semibold\",\n 4: \"mt-6 mb-2 text-lg font-semibold\",\n};\n\nfunction blocks(text: string): ReactNode[] {\n const rows = text.replace(/\\r\\n?/g, \"\\n\").split(\"\\n\");\n const out: ReactNode[] = [];\n let i = 0;\n let key = 0;\n\n while (i < rows.length) {\n const row = rows[i].trim();\n if (!row) { i++; continue; }\n\n if (row.startsWith(\"```\")) {\n const code: string[] = [];\n i++;\n while (i < rows.length && !rows[i].trim().startsWith(\"```\")) code.push(rows[i++]);\n i++;\n out.push(\n <pre key={key++} className=\"my-6 overflow-x-auto rounded-2xl bg-muted/60 p-4 text-sm leading-relaxed\">\n <code>{code.join(\"\\n\")}</code>\n </pre>,\n );\n continue;\n }\n\n const heading = row.match(HEADING);\n if (heading) {\n const level = Math.min(Math.max(heading[1].length + 1, 2), 4);\n const Tag = `h${level}` as \"h2\" | \"h3\" | \"h4\";\n out.push(<Tag key={key++} className={HEADING_CLASS[level]}>{inline(heading[2])}</Tag>);\n i++;\n continue;\n }\n\n if (RULE.test(row)) {\n out.push(<hr key={key++} className=\"my-10 border-border\" />);\n i++;\n continue;\n }\n\n if (row.startsWith(\">\")) {\n const quote: string[] = [];\n while (i < rows.length && rows[i].trim().startsWith(\">\")) quote.push(rows[i++].trim().replace(/^>\\s?/, \"\"));\n out.push(\n <blockquote key={key++} className=\"my-6 border-l-2 border-primary/50 pl-5 italic text-muted-foreground\">\n {lines(quote.join(\"\\n\"))}\n </blockquote>,\n );\n continue;\n }\n\n const ordered = NUMBERED.test(row);\n if (ordered || BULLET.test(row)) {\n const item = ordered ? NUMBERED : BULLET;\n const items: string[] = [];\n while (i < rows.length && item.test(rows[i].trim())) items.push(rows[i++].trim().match(item)![1]);\n const List = ordered ? \"ol\" : \"ul\";\n out.push(\n <List key={key++} className={cn(\"my-5 space-y-1.5 pl-6\", ordered ? \"list-decimal\" : \"list-disc\")}>\n {items.map((it, n) => <li key={n}>{inline(it)}</li>)}\n </List>,\n );\n continue;\n }\n\n const image = row.match(IMAGE_LINE);\n if (image) {\n out.push(<Picture key={key++} src={image[2]} alt={image[1]} />);\n i++;\n continue;\n }\n\n const paragraph: string[] = [];\n while (i < rows.length && rows[i].trim() && !rows[i].trim().startsWith(\"```\") && !HEADING.test(rows[i].trim()) && !RULE.test(rows[i].trim()) && !rows[i].trim().startsWith(\">\") && !IMAGE_LINE.test(rows[i].trim())) {\n paragraph.push(rows[i++].trim());\n }\n out.push(<p key={key++} className=\"my-5\">{lines(paragraph.join(\"\\n\"))}</p>);\n }\n return out;\n}\n\nexport function ArticleBody({ text, className }: { text: string; className?: string }) {\n return <div className={cn(\"text-base lg:text-lg leading-8 text-foreground/90 break-words\", className)}>{blocks(text)}</div>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiB8B;AAf9B,mBAAyC;AACzC,gBAAmB;AACnB,kBAA2B;AAE3B,MAAM,SAAS;AACf,MAAM,aAAa;AACnB,MAAM,UAAU;AAChB,MAAM,OAAO;AACb,MAAM,SAAS;AACf,MAAM,WAAW;AAEjB,MAAM,WAAW,CAAC,SAAiB,0BAA0B,KAAK,IAAI;AACtE,MAAM,YAAY,CAAC,QAAgB,4BAA4B,KAAK,GAAG;AAEvE,SAAS,KAAK,EAAE,MAAM,SAAS,GAA0C;AACvE,MAAI,CAAC,SAAS,IAAI,EAAG,QAAO,2EAAG,UAAS;AACxC,SACE,4CAAC,OAAE,MAAY,QAAO,UAAS,KAAI,oCAAmC,WAAU,0EAC7E,UACH;AAEJ;AAEA,SAAS,QAAQ,EAAE,KAAK,IAAI,GAAiC;AAC3D,MAAI,CAAC,UAAU,GAAG,EAAG,QAAO;AAC5B,QAAM,UAAM,wBAAW,KAAK,EAAE,OAAO,KAAK,CAAC;AAC3C,MAAI,CAAC,IAAK,QAAO;AACjB,SAAO,4CAAC,SAAI,KAAK,KAAK,KAAU,SAAQ,QAAO,gBAAe,eAAc,WAAU,sCAAqC;AAC7H;AAEA,SAAS,OAAO,MAA2B;AACzC,QAAM,MAAmB,CAAC;AAC1B,MAAI,OAAO;AACX,MAAI,MAAM;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ACA,QAAI,KAAK,4CAAC,OAAc,WAAU,QAAQ,gBAAM,UAAU,KAAK,IAAI,CAAC,KAAnD,KAAqD,CAAI;AAAA,EAC5E;AACA,SAAO;AACT;AAEO,SAAS,YAAY,EAAE,MAAM,UAAU,GAAyC;AACrF,SAAO,4CAAC,SAAI,eAAW,cAAG,iEAAiE,SAAS,GAAI,iBAAO,IAAI,GAAE;AACvH;","names":[]}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Fragment as Fragment2 } from "react";
|
|
4
|
+
import { cn } from "../utils/cn.js";
|
|
5
|
+
import { ipfsToHttp } from "../utils/ipfs.js";
|
|
6
|
+
const INLINE = /(!\[([^\]]*)\]\(([^)\s]+)\)|\[([^\]]+)\]\(([^)\s]+)\)|\*\*([^*]+)\*\*|\*([^*\n]+)\*|`([^`\n]+)`|(https?:\/\/[^\s<]+[^\s<.,;:!?)\]])|\\([\\`*[\]#>+\-.)(!]))/g;
|
|
7
|
+
const IMAGE_LINE = /^!\[([^\]]*)\]\(([^)\s]+)\)$/;
|
|
8
|
+
const HEADING = /^(#{1,6})\s+(.*)$/;
|
|
9
|
+
const RULE = /^(-{3,}|\*{3,}|_{3,})$/;
|
|
10
|
+
const BULLET = /^[-*+]\s+(.*)$/;
|
|
11
|
+
const NUMBERED = /^\d+[.)]\s+(.*)$/;
|
|
12
|
+
const safeLink = (href) => /^(https?:\/\/|mailto:)/i.test(href);
|
|
13
|
+
const safeImage = (src) => /^(https?:\/\/|ipfs:\/\/)/i.test(src);
|
|
14
|
+
function Link({ href, children }) {
|
|
15
|
+
if (!safeLink(href)) return /* @__PURE__ */ jsx(Fragment, { children });
|
|
16
|
+
return /* @__PURE__ */ jsx("a", { href, target: "_blank", rel: "noopener noreferrer nofollow ugc", className: "text-primary underline underline-offset-2 hover:opacity-80 break-words", children });
|
|
17
|
+
}
|
|
18
|
+
function Picture({ src, alt }) {
|
|
19
|
+
if (!safeImage(src)) return null;
|
|
20
|
+
const url = ipfsToHttp(src, { width: null });
|
|
21
|
+
if (!url) return null;
|
|
22
|
+
return /* @__PURE__ */ jsx("img", { src: url, alt, loading: "lazy", referrerPolicy: "no-referrer", className: "my-6 h-auto max-w-full rounded-2xl" });
|
|
23
|
+
}
|
|
24
|
+
function inline(text) {
|
|
25
|
+
const out = [];
|
|
26
|
+
let last = 0;
|
|
27
|
+
let key = 0;
|
|
28
|
+
for (const m of text.matchAll(INLINE)) {
|
|
29
|
+
const at = m.index ?? 0;
|
|
30
|
+
if (at > last) out.push(text.slice(last, at));
|
|
31
|
+
if (m[3] !== void 0) out.push(/* @__PURE__ */ jsx(Picture, { src: m[3], alt: m[2] }, key++));
|
|
32
|
+
else if (m[5] !== void 0) out.push(/* @__PURE__ */ jsx(Link, { href: m[5], children: m[4] }, key++));
|
|
33
|
+
else if (m[6] !== void 0) out.push(/* @__PURE__ */ jsx("strong", { className: "font-semibold text-foreground", children: m[6] }, key++));
|
|
34
|
+
else if (m[7] !== void 0) out.push(/* @__PURE__ */ jsx("em", { children: m[7] }, key++));
|
|
35
|
+
else if (m[8] !== void 0) out.push(/* @__PURE__ */ jsx("code", { className: "rounded bg-muted px-1.5 py-0.5 text-[0.9em]", children: m[8] }, key++));
|
|
36
|
+
else if (m[9] !== void 0) out.push(/* @__PURE__ */ jsx(Link, { href: m[9], children: m[9] }, key++));
|
|
37
|
+
else out.push(m[10]);
|
|
38
|
+
last = at + m[0].length;
|
|
39
|
+
}
|
|
40
|
+
if (last < text.length) out.push(text.slice(last));
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
function lines(text) {
|
|
44
|
+
return text.split("\n").map((line, i) => /* @__PURE__ */ jsxs(Fragment2, { children: [
|
|
45
|
+
i > 0 ? /* @__PURE__ */ jsx("br", {}) : null,
|
|
46
|
+
inline(line)
|
|
47
|
+
] }, i));
|
|
48
|
+
}
|
|
49
|
+
const HEADING_CLASS = {
|
|
50
|
+
2: "mt-10 mb-3 text-2xl lg:text-3xl font-bold",
|
|
51
|
+
3: "mt-8 mb-2 text-xl lg:text-2xl font-semibold",
|
|
52
|
+
4: "mt-6 mb-2 text-lg font-semibold"
|
|
53
|
+
};
|
|
54
|
+
function blocks(text) {
|
|
55
|
+
const rows = text.replace(/\r\n?/g, "\n").split("\n");
|
|
56
|
+
const out = [];
|
|
57
|
+
let i = 0;
|
|
58
|
+
let key = 0;
|
|
59
|
+
while (i < rows.length) {
|
|
60
|
+
const row = rows[i].trim();
|
|
61
|
+
if (!row) {
|
|
62
|
+
i++;
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (row.startsWith("```")) {
|
|
66
|
+
const code = [];
|
|
67
|
+
i++;
|
|
68
|
+
while (i < rows.length && !rows[i].trim().startsWith("```")) code.push(rows[i++]);
|
|
69
|
+
i++;
|
|
70
|
+
out.push(
|
|
71
|
+
/* @__PURE__ */ jsx("pre", { className: "my-6 overflow-x-auto rounded-2xl bg-muted/60 p-4 text-sm leading-relaxed", children: /* @__PURE__ */ jsx("code", { children: code.join("\n") }) }, key++)
|
|
72
|
+
);
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
const heading = row.match(HEADING);
|
|
76
|
+
if (heading) {
|
|
77
|
+
const level = Math.min(Math.max(heading[1].length + 1, 2), 4);
|
|
78
|
+
const Tag = `h${level}`;
|
|
79
|
+
out.push(/* @__PURE__ */ jsx(Tag, { className: HEADING_CLASS[level], children: inline(heading[2]) }, key++));
|
|
80
|
+
i++;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
if (RULE.test(row)) {
|
|
84
|
+
out.push(/* @__PURE__ */ jsx("hr", { className: "my-10 border-border" }, key++));
|
|
85
|
+
i++;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (row.startsWith(">")) {
|
|
89
|
+
const quote = [];
|
|
90
|
+
while (i < rows.length && rows[i].trim().startsWith(">")) quote.push(rows[i++].trim().replace(/^>\s?/, ""));
|
|
91
|
+
out.push(
|
|
92
|
+
/* @__PURE__ */ jsx("blockquote", { className: "my-6 border-l-2 border-primary/50 pl-5 italic text-muted-foreground", children: lines(quote.join("\n")) }, key++)
|
|
93
|
+
);
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
const ordered = NUMBERED.test(row);
|
|
97
|
+
if (ordered || BULLET.test(row)) {
|
|
98
|
+
const item = ordered ? NUMBERED : BULLET;
|
|
99
|
+
const items = [];
|
|
100
|
+
while (i < rows.length && item.test(rows[i].trim())) items.push(rows[i++].trim().match(item)[1]);
|
|
101
|
+
const List = ordered ? "ol" : "ul";
|
|
102
|
+
out.push(
|
|
103
|
+
/* @__PURE__ */ jsx(List, { className: cn("my-5 space-y-1.5 pl-6", ordered ? "list-decimal" : "list-disc"), children: items.map((it, n) => /* @__PURE__ */ jsx("li", { children: inline(it) }, n)) }, key++)
|
|
104
|
+
);
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
const image = row.match(IMAGE_LINE);
|
|
108
|
+
if (image) {
|
|
109
|
+
out.push(/* @__PURE__ */ jsx(Picture, { src: image[2], alt: image[1] }, key++));
|
|
110
|
+
i++;
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
const paragraph = [];
|
|
114
|
+
while (i < rows.length && rows[i].trim() && !rows[i].trim().startsWith("```") && !HEADING.test(rows[i].trim()) && !RULE.test(rows[i].trim()) && !rows[i].trim().startsWith(">") && !IMAGE_LINE.test(rows[i].trim())) {
|
|
115
|
+
paragraph.push(rows[i++].trim());
|
|
116
|
+
}
|
|
117
|
+
out.push(/* @__PURE__ */ jsx("p", { className: "my-5", children: lines(paragraph.join("\n")) }, key++));
|
|
118
|
+
}
|
|
119
|
+
return out;
|
|
120
|
+
}
|
|
121
|
+
function ArticleBody({ text, className }) {
|
|
122
|
+
return /* @__PURE__ */ jsx("div", { className: cn("text-base lg:text-lg leading-8 text-foreground/90 break-words", className), children: blocks(text) });
|
|
123
|
+
}
|
|
124
|
+
export {
|
|
125
|
+
ArticleBody
|
|
126
|
+
};
|
|
127
|
+
//# sourceMappingURL=article-body.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/article-body.tsx"],"sourcesContent":["\"use client\";\n\nimport { Fragment, type ReactNode } from \"react\";\nimport { cn } from \"../utils/cn.js\";\nimport { ipfsToHttp } from \"../utils/ipfs.js\";\n\nconst INLINE = /(!\\[([^\\]]*)\\]\\(([^)\\s]+)\\)|\\[([^\\]]+)\\]\\(([^)\\s]+)\\)|\\*\\*([^*]+)\\*\\*|\\*([^*\\n]+)\\*|`([^`\\n]+)`|(https?:\\/\\/[^\\s<]+[^\\s<.,;:!?)\\]])|\\\\([\\\\`*[\\]#>+\\-.)(!]))/g;\nconst IMAGE_LINE = /^!\\[([^\\]]*)\\]\\(([^)\\s]+)\\)$/;\nconst HEADING = /^(#{1,6})\\s+(.*)$/;\nconst RULE = /^(-{3,}|\\*{3,}|_{3,})$/;\nconst BULLET = /^[-*+]\\s+(.*)$/;\nconst NUMBERED = /^\\d+[.)]\\s+(.*)$/;\n\nconst safeLink = (href: string) => /^(https?:\\/\\/|mailto:)/i.test(href);\nconst safeImage = (src: string) => /^(https?:\\/\\/|ipfs:\\/\\/)/i.test(src);\n\nfunction Link({ href, children }: { href: string; children: ReactNode }) {\n if (!safeLink(href)) return <>{children}</>;\n return (\n <a href={href} target=\"_blank\" rel=\"noopener noreferrer nofollow ugc\" className=\"text-primary underline underline-offset-2 hover:opacity-80 break-words\">\n {children}\n </a>\n );\n}\n\nfunction Picture({ src, alt }: { src: string; alt: string }) {\n if (!safeImage(src)) return null;\n const url = ipfsToHttp(src, { width: null });\n if (!url) return null;\n return <img src={url} alt={alt} loading=\"lazy\" referrerPolicy=\"no-referrer\" className=\"my-6 h-auto max-w-full rounded-2xl\" />;\n}\n\nfunction inline(text: string): ReactNode[] {\n const out: ReactNode[] = [];\n let last = 0;\n let key = 0;\n for (const m of text.matchAll(INLINE)) {\n const at = m.index ?? 0;\n if (at > last) out.push(text.slice(last, at));\n if (m[3] !== undefined) out.push(<Picture key={key++} src={m[3]} alt={m[2]} />);\n else if (m[5] !== undefined) out.push(<Link key={key++} href={m[5]}>{m[4]}</Link>);\n else if (m[6] !== undefined) out.push(<strong key={key++} className=\"font-semibold text-foreground\">{m[6]}</strong>);\n else if (m[7] !== undefined) out.push(<em key={key++}>{m[7]}</em>);\n else if (m[8] !== undefined) out.push(<code key={key++} className=\"rounded bg-muted px-1.5 py-0.5 text-[0.9em]\">{m[8]}</code>);\n else if (m[9] !== undefined) out.push(<Link key={key++} href={m[9]}>{m[9]}</Link>);\n else out.push(m[10]);\n last = at + m[0].length;\n }\n if (last < text.length) out.push(text.slice(last));\n return out;\n}\n\nfunction lines(text: string): ReactNode[] {\n return text.split(\"\\n\").map((line, i) => (\n <Fragment key={i}>\n {i > 0 ? <br /> : null}\n {inline(line)}\n </Fragment>\n ));\n}\n\nconst HEADING_CLASS: Record<number, string> = {\n 2: \"mt-10 mb-3 text-2xl lg:text-3xl font-bold\",\n 3: \"mt-8 mb-2 text-xl lg:text-2xl font-semibold\",\n 4: \"mt-6 mb-2 text-lg font-semibold\",\n};\n\nfunction blocks(text: string): ReactNode[] {\n const rows = text.replace(/\\r\\n?/g, \"\\n\").split(\"\\n\");\n const out: ReactNode[] = [];\n let i = 0;\n let key = 0;\n\n while (i < rows.length) {\n const row = rows[i].trim();\n if (!row) { i++; continue; }\n\n if (row.startsWith(\"```\")) {\n const code: string[] = [];\n i++;\n while (i < rows.length && !rows[i].trim().startsWith(\"```\")) code.push(rows[i++]);\n i++;\n out.push(\n <pre key={key++} className=\"my-6 overflow-x-auto rounded-2xl bg-muted/60 p-4 text-sm leading-relaxed\">\n <code>{code.join(\"\\n\")}</code>\n </pre>,\n );\n continue;\n }\n\n const heading = row.match(HEADING);\n if (heading) {\n const level = Math.min(Math.max(heading[1].length + 1, 2), 4);\n const Tag = `h${level}` as \"h2\" | \"h3\" | \"h4\";\n out.push(<Tag key={key++} className={HEADING_CLASS[level]}>{inline(heading[2])}</Tag>);\n i++;\n continue;\n }\n\n if (RULE.test(row)) {\n out.push(<hr key={key++} className=\"my-10 border-border\" />);\n i++;\n continue;\n }\n\n if (row.startsWith(\">\")) {\n const quote: string[] = [];\n while (i < rows.length && rows[i].trim().startsWith(\">\")) quote.push(rows[i++].trim().replace(/^>\\s?/, \"\"));\n out.push(\n <blockquote key={key++} className=\"my-6 border-l-2 border-primary/50 pl-5 italic text-muted-foreground\">\n {lines(quote.join(\"\\n\"))}\n </blockquote>,\n );\n continue;\n }\n\n const ordered = NUMBERED.test(row);\n if (ordered || BULLET.test(row)) {\n const item = ordered ? NUMBERED : BULLET;\n const items: string[] = [];\n while (i < rows.length && item.test(rows[i].trim())) items.push(rows[i++].trim().match(item)![1]);\n const List = ordered ? \"ol\" : \"ul\";\n out.push(\n <List key={key++} className={cn(\"my-5 space-y-1.5 pl-6\", ordered ? \"list-decimal\" : \"list-disc\")}>\n {items.map((it, n) => <li key={n}>{inline(it)}</li>)}\n </List>,\n );\n continue;\n }\n\n const image = row.match(IMAGE_LINE);\n if (image) {\n out.push(<Picture key={key++} src={image[2]} alt={image[1]} />);\n i++;\n continue;\n }\n\n const paragraph: string[] = [];\n while (i < rows.length && rows[i].trim() && !rows[i].trim().startsWith(\"```\") && !HEADING.test(rows[i].trim()) && !RULE.test(rows[i].trim()) && !rows[i].trim().startsWith(\">\") && !IMAGE_LINE.test(rows[i].trim())) {\n paragraph.push(rows[i++].trim());\n }\n out.push(<p key={key++} className=\"my-5\">{lines(paragraph.join(\"\\n\"))}</p>);\n }\n return out;\n}\n\nexport function ArticleBody({ text, className }: { text: string; className?: string }) {\n return <div className={cn(\"text-base lg:text-lg leading-8 text-foreground/90 break-words\", className)}>{blocks(text)}</div>;\n}\n"],"mappings":";AAiB8B,wBAqC1B,YArC0B;AAf9B,SAAS,YAAAA,iBAAgC;AACzC,SAAS,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,QACF,oBAAC,QAAiB,WAAW,GAAG,yBAAyB,UAAU,iBAAiB,WAAW,GAC5F,gBAAM,IAAI,CAAC,IAAI,MAAM,oBAAC,QAAY,iBAAO,EAAE,KAAb,CAAe,CAAK,KAD1C,KAEX;AAAA,MACF;AACA;AAAA,IACF;AAEA,UAAM,QAAQ,IAAI,MAAM,UAAU;AAClC,QAAI,OAAO;AACT,UAAI,KAAK,oBAAC,WAAoB,KAAK,MAAM,CAAC,GAAG,KAAK,MAAM,CAAC,KAAlC,KAAqC,CAAE;AAC9D;AACA;AAAA,IACF;AAEA,UAAM,YAAsB,CAAC;AAC7B,WAAO,IAAI,KAAK,UAAU,KAAK,CAAC,EAAE,KAAK,KAAK,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,WAAW,KAAK,KAAK,CAAC,QAAQ,KAAK,KAAK,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,KAAK,KAAK,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,WAAW,GAAG,KAAK,CAAC,WAAW,KAAK,KAAK,CAAC,EAAE,KAAK,CAAC,GAAG;AACnN,gBAAU,KAAK,KAAK,GAAG,EAAE,KAAK,CAAC;AAAA,IACjC;AACA,QAAI,KAAK,oBAAC,OAAc,WAAU,QAAQ,gBAAM,UAAU,KAAK,IAAI,CAAC,KAAnD,KAAqD,CAAI;AAAA,EAC5E;AACA,SAAO;AACT;AAEO,SAAS,YAAY,EAAE,MAAM,UAAU,GAAyC;AACrF,SAAO,oBAAC,SAAI,WAAW,GAAG,iEAAiE,SAAS,GAAI,iBAAO,IAAI,GAAE;AACvH;","names":["Fragment"]}
|
|
@@ -33,6 +33,8 @@ var import_router = require("./router.js");
|
|
|
33
33
|
var import_page_container = require("./page-container.js");
|
|
34
34
|
var import_media_header = require("./media-header.js");
|
|
35
35
|
var import_asset_top_sections = require("./asset-top-sections.js");
|
|
36
|
+
var import_asset_publication_header = require("./asset-publication-header.js");
|
|
37
|
+
var import_article_body = require("./article-body.js");
|
|
36
38
|
var import_asset_utility_icons = require("./asset-utility-icons.js");
|
|
37
39
|
var import_asset_marketplace_panel = require("./asset-marketplace-panel.js");
|
|
38
40
|
var import_asset_owners_panel = require("./asset-owners-panel.js");
|
|
@@ -70,6 +72,7 @@ const KINDS = {
|
|
|
70
72
|
membership: { namePrefix: "Membership", accents: import_asset_accents.ASSET_ACCENTS.membership, market: true, remix: false, Panel: import_asset_type_panels.MembershipPanel },
|
|
71
73
|
pop: { namePrefix: "POP", accents: import_asset_accents.ASSET_ACCENTS.standard, market: false, remix: false }
|
|
72
74
|
};
|
|
75
|
+
const PUBLICATION_TYPES = /* @__PURE__ */ new Set(["publications", "posts"]);
|
|
73
76
|
const VARIANT_KINDS = { edition: "edition", ticket: "ticket", club: "membership", pop: "pop" };
|
|
74
77
|
function detectAssetKind(service, standard) {
|
|
75
78
|
const variant = (0, import_sdk.getService)(service)?.uiVariant;
|
|
@@ -158,11 +161,97 @@ function AssetPageView({
|
|
|
158
161
|
const marketCount = market.activeListings.length + market.activeBids.length;
|
|
159
162
|
const { Panel } = config;
|
|
160
163
|
const { Comments, PopBurn } = slots;
|
|
164
|
+
const content = token.metadata?.content?.trim() || null;
|
|
165
|
+
const description = token.metadata?.description?.trim() || null;
|
|
166
|
+
const articleText = content ?? description;
|
|
167
|
+
const isPublication = !!articleText && PUBLICATION_TYPES.has((token.metadata?.ipType ?? "").toLowerCase());
|
|
168
|
+
const publisherName = collection?.name ?? contract.slice(0, 8) + "\u2026";
|
|
169
|
+
const marketBlock = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
170
|
+
Panel ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Panel, { contract, tokenId, quantityOwned: market.quantityOwned }) : null,
|
|
171
|
+
config.market ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
172
|
+
import_asset_marketplace_panel.AssetMarketplacePanel,
|
|
173
|
+
{
|
|
174
|
+
asset: token,
|
|
175
|
+
cheapest: market.cheapest,
|
|
176
|
+
usdValue: market.cheapestUsd,
|
|
177
|
+
isOwner: market.isOwner,
|
|
178
|
+
isProcessing: actions.isProcessing,
|
|
179
|
+
isERC1155: market.isERC1155,
|
|
180
|
+
canListMoreEditions: market.canListMoreEditions,
|
|
181
|
+
isMarketLoading: listingsLoading,
|
|
182
|
+
myListing: market.myListing,
|
|
183
|
+
activeBids: market.activeBids,
|
|
184
|
+
remixEnabled: config.remix && remixPolicy.canRemixDirect,
|
|
185
|
+
showDealOption: config.remix && remixPolicy.showDealOption,
|
|
186
|
+
onCancelClick: actions.cancel,
|
|
187
|
+
onAcceptBid: actions.acceptBid,
|
|
188
|
+
onOpenListing: actions.list,
|
|
189
|
+
onOpenTransfer: actions.transfer,
|
|
190
|
+
onOpenPurchase: actions.buy,
|
|
191
|
+
onOpenOffer: actions.offer,
|
|
192
|
+
onOpenRemix: () => router.push(`/create/remix/${contract}/${tokenId}`)
|
|
193
|
+
}
|
|
194
|
+
) : null,
|
|
195
|
+
kind === "pop" && market.isOwner ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopBurn, { collectionAddress: contract, tokenId }) : null,
|
|
196
|
+
market.isERC1155 && holders.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_asset_owners_panel.AssetOwnersPanel, { balances: holders, total: token.holderCount, editions: Number(token.supply ?? 0) }) : null
|
|
197
|
+
] });
|
|
198
|
+
const detailsBlock = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pt-5 space-y-5", children: [
|
|
199
|
+
ownerAddress ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_asset_top_sections.AssetOwnerRow, { ownerAddress, ownerHref: (0, import_sdk2.profileHref)({ address: ownerAddress }) }) : null,
|
|
200
|
+
collection?.service === "drop-collection" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_drop_token_link.DropTokenLink, { contract, name: collection.name ?? null }) : null,
|
|
201
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
202
|
+
import_asset_collection_bar.AssetCollectionBar,
|
|
203
|
+
{
|
|
204
|
+
collectionName: publisherName,
|
|
205
|
+
collectionImage: resolveImage(collection?.image),
|
|
206
|
+
collectionHref: (0, import_sdk.collectionHref)("STARKNET", contract),
|
|
207
|
+
currentTokenId: tokenId,
|
|
208
|
+
siblingTokens: collectionTokens.map((t) => ({
|
|
209
|
+
tokenId: t.tokenId,
|
|
210
|
+
image: resolveImage(t.metadata?.image)
|
|
211
|
+
})),
|
|
212
|
+
onNavigate: (id) => router.push((0, import_sdk.assetHref)("STARKNET", contract, id)),
|
|
213
|
+
floorPriceRaw: collection?.floorPrice
|
|
214
|
+
}
|
|
215
|
+
),
|
|
216
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "-ml-3", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
217
|
+
import_asset_utility_icons.AssetUtilityIcons,
|
|
218
|
+
{
|
|
219
|
+
contractExplorerHref: `${import_explorer_url.EXPLORER_URL}/contract/${token.contractAddress}`,
|
|
220
|
+
shareTitle: name,
|
|
221
|
+
onReportClick: () => setReportOpen(true)
|
|
222
|
+
}
|
|
223
|
+
) })
|
|
224
|
+
] });
|
|
161
225
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "relative z-0 min-h-screen", children: [
|
|
162
226
|
token.isHidden ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_hidden_content_banner.HiddenContentBanner, {}) : null,
|
|
163
227
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_media_header.PageBackdrop, { image }),
|
|
164
228
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_page_container.PageContainer, { className: "pt-20 space-y-8 pb-8", children: [
|
|
165
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
229
|
+
isPublication ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
230
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
231
|
+
import_asset_publication_header.AssetPublicationHeader,
|
|
232
|
+
{
|
|
233
|
+
name,
|
|
234
|
+
ipType: token.metadata?.ipType ?? "Publications",
|
|
235
|
+
standfirst: content ? description : null,
|
|
236
|
+
image,
|
|
237
|
+
imgError,
|
|
238
|
+
onImageError: () => setImgError(true),
|
|
239
|
+
onZoom: () => setLightboxOpen(true),
|
|
240
|
+
publisherName,
|
|
241
|
+
publisherImage: resolveImage(collection?.image),
|
|
242
|
+
publisherHref: (0, import_sdk.collectionHref)("STARKNET", contract),
|
|
243
|
+
author: attributes.find((a) => a.trait_type === "Author")?.value ?? token.metadata?.author,
|
|
244
|
+
publishedAt: fullTokenData?.registeredAt
|
|
245
|
+
}
|
|
246
|
+
),
|
|
247
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "grid grid-cols-1 lg:grid-cols-[minmax(0,1fr)_22rem] lg:gap-14 gap-8 items-start", children: [
|
|
248
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "order-2 lg:order-1 min-w-0 max-w-3xl", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_article_body.ArticleBody, { text: articleText }) }),
|
|
249
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("aside", { className: "order-1 lg:order-2 space-y-6 lg:sticky lg:top-20", children: [
|
|
250
|
+
marketBlock,
|
|
251
|
+
detailsBlock
|
|
252
|
+
] })
|
|
253
|
+
] })
|
|
254
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "grid grid-cols-1 lg:grid-cols-2 lg:gap-10 gap-8 items-start", children: [
|
|
166
255
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
167
256
|
import_asset_top_sections.AssetMediaColumn,
|
|
168
257
|
{
|
|
@@ -199,60 +288,8 @@ function AssetPageView({
|
|
|
199
288
|
] }) : null
|
|
200
289
|
}
|
|
201
290
|
),
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
import_asset_marketplace_panel.AssetMarketplacePanel,
|
|
205
|
-
{
|
|
206
|
-
asset: token,
|
|
207
|
-
cheapest: market.cheapest,
|
|
208
|
-
usdValue: market.cheapestUsd,
|
|
209
|
-
isOwner: market.isOwner,
|
|
210
|
-
isProcessing: actions.isProcessing,
|
|
211
|
-
isERC1155: market.isERC1155,
|
|
212
|
-
canListMoreEditions: market.canListMoreEditions,
|
|
213
|
-
isMarketLoading: listingsLoading,
|
|
214
|
-
myListing: market.myListing,
|
|
215
|
-
activeBids: market.activeBids,
|
|
216
|
-
remixEnabled: config.remix && remixPolicy.canRemixDirect,
|
|
217
|
-
showDealOption: config.remix && remixPolicy.showDealOption,
|
|
218
|
-
onCancelClick: actions.cancel,
|
|
219
|
-
onAcceptBid: actions.acceptBid,
|
|
220
|
-
onOpenListing: actions.list,
|
|
221
|
-
onOpenTransfer: actions.transfer,
|
|
222
|
-
onOpenPurchase: actions.buy,
|
|
223
|
-
onOpenOffer: actions.offer,
|
|
224
|
-
onOpenRemix: () => router.push(`/create/remix/${contract}/${tokenId}`)
|
|
225
|
-
}
|
|
226
|
-
) : null,
|
|
227
|
-
kind === "pop" && market.isOwner ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopBurn, { collectionAddress: contract, tokenId }) : null,
|
|
228
|
-
market.isERC1155 && holders.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_asset_owners_panel.AssetOwnersPanel, { balances: holders, total: token.holderCount, editions: Number(token.supply ?? 0) }) : null,
|
|
229
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pt-5 space-y-5", children: [
|
|
230
|
-
ownerAddress ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_asset_top_sections.AssetOwnerRow, { ownerAddress, ownerHref: (0, import_sdk2.profileHref)({ address: ownerAddress }) }) : null,
|
|
231
|
-
collection?.service === "drop-collection" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_drop_token_link.DropTokenLink, { contract, name: collection.name ?? null }) : null,
|
|
232
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
233
|
-
import_asset_collection_bar.AssetCollectionBar,
|
|
234
|
-
{
|
|
235
|
-
collectionName: collection?.name ?? contract.slice(0, 8) + "\u2026",
|
|
236
|
-
collectionImage: resolveImage(collection?.image),
|
|
237
|
-
collectionHref: (0, import_sdk.collectionHref)("STARKNET", contract),
|
|
238
|
-
currentTokenId: tokenId,
|
|
239
|
-
siblingTokens: collectionTokens.map((t) => ({
|
|
240
|
-
tokenId: t.tokenId,
|
|
241
|
-
image: resolveImage(t.metadata?.image)
|
|
242
|
-
})),
|
|
243
|
-
onNavigate: (id) => router.push((0, import_sdk.assetHref)("STARKNET", contract, id)),
|
|
244
|
-
floorPriceRaw: collection?.floorPrice
|
|
245
|
-
}
|
|
246
|
-
),
|
|
247
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "-ml-3", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
248
|
-
import_asset_utility_icons.AssetUtilityIcons,
|
|
249
|
-
{
|
|
250
|
-
contractExplorerHref: `${import_explorer_url.EXPLORER_URL}/contract/${token.contractAddress}`,
|
|
251
|
-
shareTitle: name,
|
|
252
|
-
onReportClick: () => setReportOpen(true)
|
|
253
|
-
}
|
|
254
|
-
) })
|
|
255
|
-
] })
|
|
291
|
+
marketBlock,
|
|
292
|
+
detailsBlock
|
|
256
293
|
]
|
|
257
294
|
}
|
|
258
295
|
)
|