@postrun/react 2.3.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -14,6 +14,8 @@ var fi = require('react-icons/fi');
14
14
  var jsxRuntime = require('react/jsx-runtime');
15
15
  var twitterText = require('twitter-text');
16
16
  var lu = require('react-icons/lu');
17
+ var useEmblaCarousel = require('embla-carousel-react');
18
+ var io5 = require('react-icons/io5');
17
19
 
18
20
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
19
21
 
@@ -23,6 +25,7 @@ var pLimit__default = /*#__PURE__*/_interopDefault(pLimit);
23
25
  var pRetry__default = /*#__PURE__*/_interopDefault(pRetry);
24
26
  var axios__default = /*#__PURE__*/_interopDefault(axios);
25
27
  var twitterText__default = /*#__PURE__*/_interopDefault(twitterText);
28
+ var useEmblaCarousel__default = /*#__PURE__*/_interopDefault(useEmblaCarousel);
26
29
 
27
30
  // src/context.tsx
28
31
  function createDefaultQueryClient() {
@@ -1052,7 +1055,7 @@ var ACTIONS = [
1052
1055
  { label: "Share", Icon: fi.FiShare }
1053
1056
  ];
1054
1057
  function XPreviewActions() {
1055
- return /* @__PURE__ */ jsxRuntime.jsx("div", { style: ROW, children: ACTIONS.map(({ label, Icon }) => /* @__PURE__ */ jsxRuntime.jsx(Icon, { size: 18, "aria-label": label, role: "img" }, label)) });
1058
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: ROW, children: ACTIONS.map(({ label, Icon: Icon2 }) => /* @__PURE__ */ jsxRuntime.jsx(Icon2, { size: 18, "aria-label": label, role: "img" }, label)) });
1056
1059
  }
1057
1060
  var {
1058
1061
  extractCashtagsWithIndices,
@@ -1339,6 +1342,111 @@ function useIsDark(theme) {
1339
1342
  }
1340
1343
  return theme === "dark";
1341
1344
  }
1345
+ function domainOf(source) {
1346
+ try {
1347
+ return new URL(source).hostname.replace(/^www\./, "");
1348
+ } catch {
1349
+ return source;
1350
+ }
1351
+ }
1352
+ function ArticleCard({ article, thumbnail }) {
1353
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: cardStyle, children: [
1354
+ thumbnail ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: thumbnail.src, alt: thumbnail.alt ?? "", style: thumbStyle }) : null,
1355
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: metaStyle, children: [
1356
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: domainStyle, children: domainOf(article.source) }),
1357
+ article.title ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: titleStyle, children: article.title }) : null,
1358
+ article.description ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: descStyle, children: article.description }) : null
1359
+ ] })
1360
+ ] });
1361
+ }
1362
+ var cardStyle = {
1363
+ border: `1px solid ${varRef(LI_VAR.border)}`,
1364
+ borderRadius: 8,
1365
+ overflow: "hidden"
1366
+ };
1367
+ var thumbStyle = {
1368
+ width: "100%",
1369
+ display: "block",
1370
+ aspectRatio: "1.91 / 1",
1371
+ objectFit: "cover"
1372
+ };
1373
+ var metaStyle = {
1374
+ padding: "8px 12px",
1375
+ display: "flex",
1376
+ flexDirection: "column",
1377
+ gap: 2
1378
+ };
1379
+ var domainStyle = {
1380
+ fontSize: 12,
1381
+ color: varRef(LI_VAR.muted)
1382
+ };
1383
+ var titleStyle = {
1384
+ fontSize: 14,
1385
+ fontWeight: 600,
1386
+ color: varRef(LI_VAR.text),
1387
+ lineHeight: 1.3,
1388
+ display: "-webkit-box",
1389
+ WebkitLineClamp: 2,
1390
+ WebkitBoxOrient: "vertical",
1391
+ overflow: "hidden"
1392
+ };
1393
+ var descStyle = {
1394
+ fontSize: 12,
1395
+ color: varRef(LI_VAR.muted),
1396
+ lineHeight: 1.3,
1397
+ display: "-webkit-box",
1398
+ WebkitLineClamp: 1,
1399
+ WebkitBoxOrient: "vertical",
1400
+ overflow: "hidden"
1401
+ };
1402
+ function DocumentCard({ document, cover }) {
1403
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: cardStyle2, children: [
1404
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: pageStyle, children: cover ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: cover.src, alt: cover.alt ?? "", style: coverStyle }) : /* @__PURE__ */ jsxRuntime.jsx(fi.FiFileText, { size: 56, "aria-hidden": true, style: { opacity: 0.5 } }) }),
1405
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: barStyle, children: [
1406
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: titleStyle2, children: document.title }),
1407
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: kindStyle, children: "Document" })
1408
+ ] })
1409
+ ] });
1410
+ }
1411
+ var cardStyle2 = {
1412
+ border: `1px solid ${varRef(LI_VAR.border)}`,
1413
+ borderRadius: 8,
1414
+ overflow: "hidden"
1415
+ };
1416
+ var pageStyle = {
1417
+ position: "relative",
1418
+ aspectRatio: "4 / 3",
1419
+ background: "rgba(127,127,127,0.12)",
1420
+ display: "grid",
1421
+ placeItems: "center",
1422
+ color: varRef(LI_VAR.muted)
1423
+ };
1424
+ var coverStyle = {
1425
+ width: "100%",
1426
+ height: "100%",
1427
+ objectFit: "cover"
1428
+ };
1429
+ var barStyle = {
1430
+ background: "rgba(0,0,0,0.85)",
1431
+ color: "#fff",
1432
+ padding: "10px 14px",
1433
+ display: "flex",
1434
+ flexDirection: "column",
1435
+ gap: 1
1436
+ };
1437
+ var titleStyle2 = {
1438
+ fontSize: 14,
1439
+ fontWeight: 600,
1440
+ lineHeight: 1.3,
1441
+ display: "-webkit-box",
1442
+ WebkitLineClamp: 2,
1443
+ WebkitBoxOrient: "vertical",
1444
+ overflow: "hidden"
1445
+ };
1446
+ var kindStyle = {
1447
+ fontSize: 12,
1448
+ color: "rgba(255,255,255,0.7)"
1449
+ };
1342
1450
  var ROW2 = {
1343
1451
  display: "flex",
1344
1452
  justifyContent: "space-around",
@@ -1362,8 +1470,8 @@ var ACTIONS2 = [
1362
1470
  { label: "Send", Icon: fi.FiSend }
1363
1471
  ];
1364
1472
  function EngagementBar() {
1365
- return /* @__PURE__ */ jsxRuntime.jsx("div", { style: ROW2, children: ACTIONS2.map(({ label, Icon }) => /* @__PURE__ */ jsxRuntime.jsxs("span", { style: ITEM, children: [
1366
- /* @__PURE__ */ jsxRuntime.jsx(Icon, { size: 20, "aria-hidden": true }),
1473
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: ROW2, children: ACTIONS2.map(({ label, Icon: Icon2 }) => /* @__PURE__ */ jsxRuntime.jsxs("span", { style: ITEM, children: [
1474
+ /* @__PURE__ */ jsxRuntime.jsx(Icon2, { size: 20, "aria-hidden": true }),
1367
1475
  label
1368
1476
  ] }, label)) });
1369
1477
  }
@@ -1492,11 +1600,11 @@ function Tile({
1492
1600
  ] });
1493
1601
  }
1494
1602
  function ImageMosaic({ media }) {
1495
- if (media.length === 0) {
1603
+ const [only] = media;
1604
+ if (!only) {
1496
1605
  return null;
1497
1606
  }
1498
1607
  if (media.length === 1) {
1499
- const only = media[0];
1500
1608
  return /* @__PURE__ */ jsxRuntime.jsx(
1501
1609
  "img",
1502
1610
  {
@@ -1542,6 +1650,48 @@ function Media({ media }) {
1542
1650
  const images = media.filter((item) => item.kind === "image");
1543
1651
  return /* @__PURE__ */ jsxRuntime.jsx(ImageMosaic, { media: images });
1544
1652
  }
1653
+ function Poll({ poll }) {
1654
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: wrapStyle, children: [
1655
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: questionStyle, children: poll.question }),
1656
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: optionsStyle, children: poll.options.map((option, i) => /* @__PURE__ */ jsxRuntime.jsx("div", { style: optionStyle, children: option }, `${option}-${i}`)) }),
1657
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: footerStyle, children: [
1658
+ "0 votes \u2022 ",
1659
+ js.linkedinPollDurationLabel(poll.duration)
1660
+ ] })
1661
+ ] });
1662
+ }
1663
+ var wrapStyle = {
1664
+ border: `1px solid ${varRef(LI_VAR.border)}`,
1665
+ borderRadius: 8,
1666
+ padding: 12,
1667
+ display: "flex",
1668
+ flexDirection: "column",
1669
+ gap: 10
1670
+ };
1671
+ var questionStyle = {
1672
+ fontSize: 14,
1673
+ fontWeight: 600,
1674
+ color: varRef(LI_VAR.text),
1675
+ lineHeight: 1.35
1676
+ };
1677
+ var optionsStyle = {
1678
+ display: "flex",
1679
+ flexDirection: "column",
1680
+ gap: 8
1681
+ };
1682
+ var optionStyle = {
1683
+ border: `1px solid ${varRef(LI_VAR.accent)}`,
1684
+ borderRadius: 999,
1685
+ padding: "8px 16px",
1686
+ textAlign: "center",
1687
+ fontSize: 14,
1688
+ fontWeight: 600,
1689
+ color: varRef(LI_VAR.accent)
1690
+ };
1691
+ var footerStyle = {
1692
+ fontSize: 12,
1693
+ color: varRef(LI_VAR.muted)
1694
+ };
1545
1695
  var FOLD_CHARS = 200;
1546
1696
  var BODY_STYLE = {
1547
1697
  whiteSpace: "pre-wrap",
@@ -1669,7 +1819,7 @@ function LinkedInPostPreviewImpl({
1669
1819
  accent: varRef(LI_VAR.accent),
1670
1820
  muted: varRef(LI_VAR.muted)
1671
1821
  };
1672
- const cardStyle = {
1822
+ const cardStyle4 = {
1673
1823
  ...paletteVars(dark),
1674
1824
  background: varRef(LI_VAR.bg),
1675
1825
  color: varRef(LI_VAR.text),
@@ -1680,7 +1830,7 @@ function LinkedInPostPreviewImpl({
1680
1830
  fontFamily: FONT_STACK,
1681
1831
  ...style
1682
1832
  };
1683
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: cardStyle, children: [
1833
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: cardStyle4, children: [
1684
1834
  /* @__PURE__ */ jsxRuntime.jsx(Header, { author, visibility, time }),
1685
1835
  variant.body ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: "8px 16px 0" }, children: /* @__PURE__ */ jsxRuntime.jsx(
1686
1836
  PostBody,
@@ -1690,15 +1840,1016 @@ function LinkedInPostPreviewImpl({
1690
1840
  colors: bodyColors
1691
1841
  }
1692
1842
  ) }) : null,
1693
- resolvedMedia.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { marginTop: 12 }, children: /* @__PURE__ */ jsxRuntime.jsx(Media, { media: resolvedMedia }) }) : null,
1843
+ renderContent(variant, resolvedMedia),
1694
1844
  showActions ? /* @__PURE__ */ jsxRuntime.jsx(EngagementBar, {}) : null
1695
1845
  ] });
1696
1846
  }
1847
+ function renderContent(variant, media) {
1848
+ const settings = variant.settings;
1849
+ const kind = settings?.content_kind;
1850
+ const [firstMedia] = media;
1851
+ if (kind === "article" && settings?.article) {
1852
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: INSET, children: /* @__PURE__ */ jsxRuntime.jsx(ArticleCard, { article: settings.article, thumbnail: firstMedia }) });
1853
+ }
1854
+ if (kind === "poll" && settings?.poll) {
1855
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: INSET, children: /* @__PURE__ */ jsxRuntime.jsx(Poll, { poll: settings.poll }) });
1856
+ }
1857
+ if (kind === "document" && settings?.document) {
1858
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: INSET, children: /* @__PURE__ */ jsxRuntime.jsx(DocumentCard, { document: settings.document, cover: firstMedia }) });
1859
+ }
1860
+ return media.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { marginTop: 12 }, children: /* @__PURE__ */ jsxRuntime.jsx(Media, { media }) }) : null;
1861
+ }
1862
+ var INSET = { padding: "12px 16px 0" };
1697
1863
  var LinkedInPostPreview = react.memo(LinkedInPostPreviewImpl);
1864
+ var LINK_COLOR = "#8ab4ff";
1865
+ var TOKEN = /([#@][\p{L}\p{N}_.]+)/gu;
1866
+ var IS_TOKEN = /^[#@][\p{L}\p{N}_.]+$/u;
1867
+ function Caption({ body }) {
1868
+ const [expanded, setExpanded] = react.useState(false);
1869
+ const [overflowing, setOverflowing] = react.useState(false);
1870
+ const ref = react.useRef(null);
1871
+ react.useLayoutEffect(() => {
1872
+ const el = ref.current;
1873
+ if (!el || expanded) {
1874
+ return;
1875
+ }
1876
+ setOverflowing(el.scrollHeight > el.clientHeight + 1);
1877
+ }, [body, expanded]);
1878
+ const parts = body.split(TOKEN);
1879
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: wrapStyle2, children: [
1880
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref, style: expanded ? expandedTextStyle : clampedTextStyle, children: parts.map(
1881
+ (part, i) => IS_TOKEN.test(part) ? /* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: LINK_COLOR }, children: part }, i) : /* @__PURE__ */ jsxRuntime.jsx("span", { children: part }, i)
1882
+ ) }),
1883
+ overflowing || expanded ? /* @__PURE__ */ jsxRuntime.jsx(
1884
+ "button",
1885
+ {
1886
+ type: "button",
1887
+ "aria-expanded": expanded,
1888
+ "aria-label": expanded ? "Collapse caption" : "Expand caption",
1889
+ onClick: () => setExpanded((v) => !v),
1890
+ style: moreStyle,
1891
+ children: expanded ? "less" : "more"
1892
+ }
1893
+ ) : null
1894
+ ] });
1895
+ }
1896
+ var wrapStyle2 = {
1897
+ fontSize: 14,
1898
+ lineHeight: 1.35
1899
+ };
1900
+ var clampedTextStyle = {
1901
+ display: "-webkit-box",
1902
+ WebkitLineClamp: 2,
1903
+ WebkitBoxOrient: "vertical",
1904
+ overflow: "hidden",
1905
+ whiteSpace: "pre-wrap",
1906
+ wordBreak: "break-word"
1907
+ };
1908
+ var expandedTextStyle = {
1909
+ maxHeight: 180,
1910
+ overflowY: "auto",
1911
+ whiteSpace: "pre-wrap",
1912
+ wordBreak: "break-word",
1913
+ overscrollBehavior: "contain"
1914
+ };
1915
+ var moreStyle = {
1916
+ display: "inline-block",
1917
+ marginTop: 2,
1918
+ padding: 0,
1919
+ border: 0,
1920
+ background: "transparent",
1921
+ color: "rgba(255,255,255,0.82)",
1922
+ fontSize: 13,
1923
+ fontWeight: 600,
1924
+ cursor: "pointer",
1925
+ fontFamily: "inherit"
1926
+ };
1927
+ function Media2({
1928
+ media,
1929
+ pending = false
1930
+ }) {
1931
+ const [first] = media;
1932
+ if (!first) {
1933
+ return pending ? /* @__PURE__ */ jsxRuntime.jsx(ProcessingMedia, {}) : /* @__PURE__ */ jsxRuntime.jsx(EmptyMedia, {});
1934
+ }
1935
+ if (first.kind === "video") {
1936
+ return /* @__PURE__ */ jsxRuntime.jsx(
1937
+ "video",
1938
+ {
1939
+ src: first.src,
1940
+ poster: first.posterSrc,
1941
+ autoPlay: true,
1942
+ muted: true,
1943
+ loop: true,
1944
+ playsInline: true,
1945
+ style: coverStyle2
1946
+ }
1947
+ );
1948
+ }
1949
+ return /* @__PURE__ */ jsxRuntime.jsx(PhotoCarousel, { media });
1950
+ }
1951
+ function PhotoCarousel({ media }) {
1952
+ const [emblaRef, emblaApi] = useEmblaCarousel__default.default({
1953
+ loop: false,
1954
+ align: "start",
1955
+ containScroll: "trimSnaps"
1956
+ });
1957
+ const [selected, setSelected] = react.useState(0);
1958
+ const sync = react.useCallback((api) => {
1959
+ setSelected(api.selectedScrollSnap());
1960
+ }, []);
1961
+ react.useEffect(() => {
1962
+ if (!emblaApi) {
1963
+ return;
1964
+ }
1965
+ sync(emblaApi);
1966
+ emblaApi.on("select", sync).on("reInit", sync);
1967
+ return () => {
1968
+ emblaApi.off("select", sync).off("reInit", sync);
1969
+ };
1970
+ }, [emblaApi, sync]);
1971
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { position: "absolute", inset: 0 }, children: [
1972
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref: emblaRef, style: viewportStyle, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: containerStyle, children: media.map((m, i) => /* @__PURE__ */ jsxRuntime.jsx("div", { style: slideStyle, children: /* @__PURE__ */ jsxRuntime.jsx("img", { src: m.src, alt: m.alt ?? "", style: coverStyle2 }) }, `${m.src}-${i}`)) }) }),
1973
+ media.length > 1 ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: dotsStyle, children: media.map((m, i) => /* @__PURE__ */ jsxRuntime.jsx(
1974
+ "span",
1975
+ {
1976
+ style: { ...dotStyle, opacity: i === selected ? 1 : 0.4 }
1977
+ },
1978
+ `dot-${m.src}-${i}`
1979
+ )) }) : null
1980
+ ] });
1981
+ }
1982
+ function EmptyMedia() {
1983
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: emptyStyle, children: "No media yet" });
1984
+ }
1985
+ function ProcessingMedia() {
1986
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: emptyStyle, children: [
1987
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: shimmerStyle }),
1988
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: { position: "relative", zIndex: 1 }, children: "Processing media\u2026" })
1989
+ ] });
1990
+ }
1991
+ var coverStyle2 = {
1992
+ position: "absolute",
1993
+ inset: 0,
1994
+ width: "100%",
1995
+ height: "100%",
1996
+ objectFit: "cover"
1997
+ };
1998
+ var viewportStyle = {
1999
+ position: "absolute",
2000
+ inset: 0,
2001
+ overflow: "hidden"
2002
+ };
2003
+ var containerStyle = {
2004
+ display: "flex",
2005
+ height: "100%"
2006
+ };
2007
+ var slideStyle = {
2008
+ position: "relative",
2009
+ flex: "0 0 100%",
2010
+ minWidth: 0,
2011
+ height: "100%"
2012
+ };
2013
+ var dotsStyle = {
2014
+ position: "absolute",
2015
+ bottom: 124,
2016
+ left: "50%",
2017
+ transform: "translateX(-50%)",
2018
+ display: "flex",
2019
+ gap: 5,
2020
+ alignItems: "center"
2021
+ };
2022
+ var dotStyle = {
2023
+ width: 6,
2024
+ height: 6,
2025
+ borderRadius: "50%",
2026
+ background: "#fff",
2027
+ transition: "opacity 160ms ease"
2028
+ };
2029
+ var emptyStyle = {
2030
+ position: "absolute",
2031
+ inset: 0,
2032
+ display: "flex",
2033
+ alignItems: "center",
2034
+ justifyContent: "center",
2035
+ color: "rgba(255,255,255,0.55)",
2036
+ fontSize: 13,
2037
+ background: "linear-gradient(180deg,#1c1c20,#101013)",
2038
+ overflow: "hidden"
2039
+ };
2040
+ var shimmerStyle = {
2041
+ position: "absolute",
2042
+ inset: 0,
2043
+ background: "linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0) 100%)",
2044
+ backgroundSize: "200% 100%",
2045
+ animation: "pr-tt-shimmer 1.4s ease-in-out infinite"
2046
+ };
2047
+ var Icon = ({
2048
+ size = 24,
2049
+ viewBox,
2050
+ children,
2051
+ ...rest
2052
+ }) => /* @__PURE__ */ jsxRuntime.jsx(
2053
+ "svg",
2054
+ {
2055
+ width: size,
2056
+ height: size,
2057
+ viewBox,
2058
+ fill: "currentColor",
2059
+ xmlns: "http://www.w3.org/2000/svg",
2060
+ ...rest,
2061
+ children
2062
+ }
2063
+ );
2064
+ var HeartIcon = (p) => /* @__PURE__ */ jsxRuntime.jsx(Icon, { viewBox: "0 0 24 24", ...p, children: /* @__PURE__ */ jsxRuntime.jsx(
2065
+ "path",
2066
+ {
2067
+ fillRule: "evenodd",
2068
+ clipRule: "evenodd",
2069
+ d: "M7.5 2.25C10.5 2.25 12 4.25 12 4.25C12 4.25 13.5 2.25 16.5 2.25C20 2.25 22.5 4.99999 22.5 8.5C22.5 12.5 19.2311 16.0657 16.25 18.75C14.4095 20.4072 13 21.5 12 21.5C11 21.5 9.55051 20.3989 7.75 18.75C4.81949 16.0662 1.5 12.5 1.5 8.5C1.5 4.99999 4 2.25 7.5 2.25Z"
2070
+ }
2071
+ ) });
2072
+ var CommentIcon = (p) => /* @__PURE__ */ jsxRuntime.jsx(Icon, { viewBox: "0 0 48 48", ...p, children: /* @__PURE__ */ jsxRuntime.jsx(
2073
+ "path",
2074
+ {
2075
+ fillRule: "evenodd",
2076
+ clipRule: "evenodd",
2077
+ d: "M2 21.5c0-10.22 9.88-18 22-18s22 7.78 22 18c0 5.63-3.19 10.74-7.32 14.8a43.6 43.6 0 0 1-14.14 9.1A1.5 1.5 0 0 1 22.5 44v-5.04C11.13 38.4 2 31.34 2 21.5M14 25a3 3 0 1 0 0-6 3 3 0 0 0 0 6m10 0a3 3 0 1 0 0-6 3 3 0 0 0 0 6m13-3a3 3 0 1 1-6 0 3 3 0 0 1 6 0"
2078
+ }
2079
+ ) });
2080
+ var BookmarkIcon = (p) => /* @__PURE__ */ jsxRuntime.jsx(Icon, { viewBox: "0 0 24 24", ...p, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M4 4.5a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v15.13a1 1 0 0 1-1.555.831l-6.167-4.12a.5.5 0 0 0-.556 0l-6.167 4.12A1 1 0 0 1 4 19.63z" }) });
2081
+ var ShareIcon = (p) => /* @__PURE__ */ jsxRuntime.jsx(Icon, { viewBox: "0 0 20 20", ...p, children: /* @__PURE__ */ jsxRuntime.jsx(
2082
+ "path",
2083
+ {
2084
+ fillRule: "evenodd",
2085
+ clipRule: "evenodd",
2086
+ d: "M10.938 3.175a.674.674 0 0 1 1.138-.488l6.526 6.215c.574.547.554 1.47-.043 1.991l-6.505 5.676a.674.674 0 0 1-1.116-.508V13.49s-6.985-1.258-9.225 2.854c-.209.384-1.023.518-.857-1.395.692-3.52 2.106-9.017 10.082-9.017z"
2087
+ }
2088
+ ) });
2089
+ var PlusIcon = (p) => /* @__PURE__ */ jsxRuntime.jsx(Icon, { viewBox: "0 0 48 48", ...p, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M26 7a1 1 0 0 0-1-1h-2a1 1 0 0 0-1 1v15H7a1 1 0 0 0-1 1v2a1 1 0 0 0 1 1h15v15a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1V26h15a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1H26V7Z" }) });
2090
+ var DASH = "\u2011\u2011\u2011";
2091
+ function commercialLabel(settings) {
2092
+ if (settings?.brand_content_toggle) {
2093
+ return "Paid partnership";
2094
+ }
2095
+ if (settings?.brand_organic_toggle) {
2096
+ return "Promotional content";
2097
+ }
2098
+ return null;
2099
+ }
2100
+ function TikTokPostPreviewImpl({
2101
+ variant,
2102
+ creatorInfo,
2103
+ media,
2104
+ className,
2105
+ style
2106
+ }) {
2107
+ const resolvedMedia = useResolvedMedia(
2108
+ media,
2109
+ variant.media,
2110
+ altSignatureOf(variant.media)
2111
+ );
2112
+ const { creator } = creatorInfo;
2113
+ const handle = creator.username || creator.nickname;
2114
+ const label = commercialLabel(variant.settings);
2115
+ const isAigc = Boolean(variant.settings?.is_aigc);
2116
+ const pending = (media?.length ?? 0) > 0 && resolvedMedia.length === 0;
2117
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: { ...cardStyle3, ...style }, children: [
2118
+ /* @__PURE__ */ jsxRuntime.jsx("style", { children: KEYFRAMES }),
2119
+ /* @__PURE__ */ jsxRuntime.jsx(Media2, { media: resolvedMedia, pending }),
2120
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: scrimStyle }),
2121
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: infoStyle, children: [
2122
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: usernameStyle, children: handle }),
2123
+ variant.body ? /* @__PURE__ */ jsxRuntime.jsx(Caption, { body: variant.body }) : null,
2124
+ label || isAigc ? /* @__PURE__ */ jsxRuntime.jsxs("div", { style: labelsStyle, children: [
2125
+ label ? /* @__PURE__ */ jsxRuntime.jsx("span", { style: pillStyle, children: label }) : null,
2126
+ isAigc ? /* @__PURE__ */ jsxRuntime.jsx("span", { style: pillStyle, children: "Creator labeled as AI-generated" }) : null
2127
+ ] }) : null,
2128
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: musicRowStyle, children: [
2129
+ /* @__PURE__ */ jsxRuntime.jsx(io5.IoMusicalNotes, { size: 13 }),
2130
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
2131
+ "Original sound - ",
2132
+ creator.nickname
2133
+ ] })
2134
+ ] })
2135
+ ] }),
2136
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: railStyle, children: [
2137
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: avatarWrapStyle, children: [
2138
+ /* @__PURE__ */ jsxRuntime.jsx(Avatar, { url: creator.avatar_url, name: creator.nickname }),
2139
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: followBadgeStyle, children: /* @__PURE__ */ jsxRuntime.jsx(PlusIcon, { size: 14 }) })
2140
+ ] }),
2141
+ /* @__PURE__ */ jsxRuntime.jsx(RailAction, { icon: /* @__PURE__ */ jsxRuntime.jsx(HeartIcon, { size: 30 }), count: DASH }),
2142
+ /* @__PURE__ */ jsxRuntime.jsx(RailAction, { icon: /* @__PURE__ */ jsxRuntime.jsx(CommentIcon, { size: 30 }), count: DASH }),
2143
+ /* @__PURE__ */ jsxRuntime.jsx(RailAction, { icon: /* @__PURE__ */ jsxRuntime.jsx(BookmarkIcon, { size: 28 }), count: DASH }),
2144
+ /* @__PURE__ */ jsxRuntime.jsx(RailAction, { icon: /* @__PURE__ */ jsxRuntime.jsx(ShareIcon, { size: 28 }), count: DASH }),
2145
+ /* @__PURE__ */ jsxRuntime.jsx(Disc, { url: creator.avatar_url })
2146
+ ] })
2147
+ ] });
2148
+ }
2149
+ function RailAction({ icon, count }) {
2150
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: railActionStyle, children: [
2151
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: railIconStyle, children: icon }),
2152
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: railCountStyle, children: count })
2153
+ ] });
2154
+ }
2155
+ function Avatar({ url, name }) {
2156
+ if (url) {
2157
+ return /* @__PURE__ */ jsxRuntime.jsx("img", { src: url, alt: name, style: avatarStyle });
2158
+ }
2159
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { ...avatarStyle, ...avatarFallbackStyle }, children: name.slice(0, 1).toUpperCase() });
2160
+ }
2161
+ function Disc({ url }) {
2162
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: discStyle, children: url ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: url, alt: "", style: discImgStyle }) : null });
2163
+ }
2164
+ var cardStyle3 = {
2165
+ position: "relative",
2166
+ width: "100%",
2167
+ maxWidth: 320,
2168
+ aspectRatio: "9 / 16",
2169
+ borderRadius: 16,
2170
+ overflow: "hidden",
2171
+ background: "#000",
2172
+ color: "#fff",
2173
+ fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif'
2174
+ };
2175
+ var scrimStyle = {
2176
+ position: "absolute",
2177
+ inset: 0,
2178
+ background: "linear-gradient(180deg, rgba(0,0,0,0) 55%, rgba(0,0,0,0.55) 100%)",
2179
+ pointerEvents: "none"
2180
+ };
2181
+ var infoStyle = {
2182
+ position: "absolute",
2183
+ left: 14,
2184
+ right: 70,
2185
+ bottom: 14,
2186
+ display: "flex",
2187
+ flexDirection: "column",
2188
+ gap: 6,
2189
+ textShadow: "0 1px 3px rgba(0,0,0,0.5)"
2190
+ };
2191
+ var usernameStyle = {
2192
+ fontWeight: 600,
2193
+ fontSize: 16
2194
+ };
2195
+ var labelsStyle = {
2196
+ display: "flex",
2197
+ flexDirection: "column",
2198
+ alignItems: "flex-start",
2199
+ gap: 4,
2200
+ marginTop: 2
2201
+ };
2202
+ var pillStyle = {
2203
+ display: "inline-flex",
2204
+ alignItems: "center",
2205
+ background: "rgba(255,255,255,0.18)",
2206
+ color: "#fff",
2207
+ fontSize: 11,
2208
+ fontWeight: 500,
2209
+ padding: "2px 7px",
2210
+ borderRadius: 4
2211
+ };
2212
+ var musicRowStyle = {
2213
+ display: "flex",
2214
+ alignItems: "center",
2215
+ gap: 6,
2216
+ fontSize: 13,
2217
+ marginTop: 4
2218
+ };
2219
+ var railStyle = {
2220
+ position: "absolute",
2221
+ right: 8,
2222
+ bottom: 14,
2223
+ display: "flex",
2224
+ flexDirection: "column",
2225
+ alignItems: "center",
2226
+ gap: 16,
2227
+ color: "#fff"
2228
+ };
2229
+ var avatarWrapStyle = {
2230
+ position: "relative",
2231
+ marginBottom: 8
2232
+ };
2233
+ var avatarStyle = {
2234
+ width: 46,
2235
+ height: 46,
2236
+ borderRadius: "50%",
2237
+ objectFit: "cover",
2238
+ display: "block",
2239
+ border: "1px solid rgba(255,255,255,0.2)"
2240
+ };
2241
+ var avatarFallbackStyle = {
2242
+ display: "grid",
2243
+ placeItems: "center",
2244
+ background: "#3a3a40",
2245
+ color: "#fff",
2246
+ fontSize: 18,
2247
+ fontWeight: 700
2248
+ };
2249
+ var followBadgeStyle = {
2250
+ position: "absolute",
2251
+ bottom: -9,
2252
+ left: "50%",
2253
+ transform: "translateX(-50%)",
2254
+ width: 19,
2255
+ height: 19,
2256
+ borderRadius: "50%",
2257
+ background: "#fe2c55",
2258
+ color: "#fff",
2259
+ display: "grid",
2260
+ placeItems: "center"
2261
+ };
2262
+ var railActionStyle = {
2263
+ display: "flex",
2264
+ flexDirection: "column",
2265
+ alignItems: "center",
2266
+ gap: 3
2267
+ };
2268
+ var railIconStyle = {
2269
+ display: "grid",
2270
+ placeItems: "center",
2271
+ filter: "drop-shadow(0 1px 2px rgba(0,0,0,0.4))"
2272
+ };
2273
+ var railCountStyle = {
2274
+ fontSize: 12,
2275
+ fontWeight: 600,
2276
+ textShadow: "0 1px 2px rgba(0,0,0,0.4)"
2277
+ };
2278
+ var discStyle = {
2279
+ width: 44,
2280
+ height: 44,
2281
+ borderRadius: "50%",
2282
+ background: "radial-gradient(circle, #555 0 36%, #111 37% 100%)",
2283
+ display: "grid",
2284
+ placeItems: "center",
2285
+ marginTop: 2,
2286
+ animation: "pr-tt-spin 4s linear infinite"
2287
+ };
2288
+ var discImgStyle = {
2289
+ width: 22,
2290
+ height: 22,
2291
+ borderRadius: "50%",
2292
+ objectFit: "cover"
2293
+ };
2294
+ var KEYFRAMES = `@keyframes pr-tt-spin{from{transform:rotate(0)}to{transform:rotate(360deg)}}@keyframes pr-tt-shimmer{0%{background-position:-200% 0}100%{background-position:200% 0}}`;
2295
+ var TikTokPostPreview = react.memo(TikTokPostPreviewImpl);
2296
+ var TT_VAR = {
2297
+ text: "--pr-tt-text",
2298
+ muted: "--pr-tt-muted",
2299
+ border: "--pr-tt-border",
2300
+ accent: "--pr-tt-accent",
2301
+ switchOff: "--pr-tt-switch-off"
2302
+ };
2303
+ var LIGHT2 = {
2304
+ text: "rgba(0,0,0,0.9)",
2305
+ muted: "rgba(0,0,0,0.55)",
2306
+ border: "rgba(0,0,0,0.12)",
2307
+ accent: "#fe2c55",
2308
+ switchOff: "rgba(0,0,0,0.18)"
2309
+ };
2310
+ var DARK2 = {
2311
+ text: "rgba(255,255,255,0.92)",
2312
+ muted: "#8a8a92",
2313
+ border: "rgba(255,255,255,0.14)",
2314
+ accent: "#fe2c55",
2315
+ switchOff: "rgba(255,255,255,0.22)"
2316
+ };
2317
+ function varRef2(name) {
2318
+ return `var(${name})`;
2319
+ }
2320
+ function paletteVars2(dark) {
2321
+ const p = dark ? DARK2 : LIGHT2;
2322
+ return {
2323
+ [TT_VAR.text]: p.text,
2324
+ [TT_VAR.muted]: p.muted,
2325
+ [TT_VAR.border]: p.border,
2326
+ [TT_VAR.accent]: p.accent,
2327
+ [TT_VAR.switchOff]: p.switchOff
2328
+ };
2329
+ }
2330
+ function usePrefersDark2() {
2331
+ const [dark, setDark] = react.useState(false);
2332
+ react.useEffect(() => {
2333
+ if (typeof window === "undefined" || !window.matchMedia) {
2334
+ return;
2335
+ }
2336
+ const mq = window.matchMedia("(prefers-color-scheme: dark)");
2337
+ setDark(mq.matches);
2338
+ const onChange = (event) => setDark(event.matches);
2339
+ mq.addEventListener("change", onChange);
2340
+ return () => mq.removeEventListener("change", onChange);
2341
+ }, []);
2342
+ return dark;
2343
+ }
2344
+ function useIsDark2(theme) {
2345
+ const prefersDark = usePrefersDark2();
2346
+ if (theme === "auto") {
2347
+ return prefersDark;
2348
+ }
2349
+ return theme === "dark";
2350
+ }
2351
+ var MUTED = varRef2(TT_VAR.muted);
2352
+ var BORDER = varRef2(TT_VAR.border);
2353
+ var ACCENT = varRef2(TT_VAR.accent);
2354
+ var SWITCH_OFF = varRef2(TT_VAR.switchOff);
2355
+ var ON = "#34c759";
2356
+ function Row({
2357
+ label,
2358
+ sublabel,
2359
+ control,
2360
+ htmlFor
2361
+ }) {
2362
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: rowStyle, children: [
2363
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { htmlFor, style: { display: "flex", flexDirection: "column", gap: 2 }, children: [
2364
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 14 }, children: label }),
2365
+ sublabel ? /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 12, color: MUTED }, children: sublabel }) : null
2366
+ ] }),
2367
+ control
2368
+ ] });
2369
+ }
2370
+ function Switch({
2371
+ checked,
2372
+ onChange,
2373
+ disabled,
2374
+ id,
2375
+ ariaLabel
2376
+ }) {
2377
+ return /* @__PURE__ */ jsxRuntime.jsx(
2378
+ "button",
2379
+ {
2380
+ type: "button",
2381
+ role: "switch",
2382
+ id,
2383
+ "aria-label": ariaLabel,
2384
+ "aria-checked": checked,
2385
+ disabled,
2386
+ onClick: () => onChange(!checked),
2387
+ style: {
2388
+ ...switchTrackStyle,
2389
+ background: checked ? ON : SWITCH_OFF,
2390
+ opacity: disabled ? 0.4 : 1,
2391
+ cursor: disabled ? "not-allowed" : "pointer"
2392
+ },
2393
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2394
+ "span",
2395
+ {
2396
+ style: {
2397
+ ...switchKnobStyle,
2398
+ transform: checked ? "translateX(16px)" : "translateX(0)"
2399
+ }
2400
+ }
2401
+ )
2402
+ }
2403
+ );
2404
+ }
2405
+ function SectionLabel({ children }) {
2406
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: sectionLabelStyle, children });
2407
+ }
2408
+ function Hint({ children }) {
2409
+ return /* @__PURE__ */ jsxRuntime.jsx("p", { style: hintStyle, children });
2410
+ }
2411
+ function Notice({ children }) {
2412
+ return /* @__PURE__ */ jsxRuntime.jsx("p", { style: noticeStyle, children });
2413
+ }
2414
+ function CheckRow({
2415
+ label,
2416
+ checked,
2417
+ onChange
2418
+ }) {
2419
+ const id = react.useId();
2420
+ return /* @__PURE__ */ jsxRuntime.jsxs("label", { htmlFor: id, style: checkRowStyle, children: [
2421
+ /* @__PURE__ */ jsxRuntime.jsx(
2422
+ "input",
2423
+ {
2424
+ id,
2425
+ type: "checkbox",
2426
+ checked,
2427
+ onChange: (e) => onChange(e.target.checked),
2428
+ style: { accentColor: ACCENT, width: 16, height: 16 }
2429
+ }
2430
+ ),
2431
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 14 }, children: label })
2432
+ ] });
2433
+ }
2434
+ var rowStyle = {
2435
+ display: "flex",
2436
+ alignItems: "center",
2437
+ justifyContent: "space-between",
2438
+ gap: 12,
2439
+ minHeight: 36
2440
+ };
2441
+ var switchTrackStyle = {
2442
+ position: "relative",
2443
+ width: 40,
2444
+ height: 24,
2445
+ borderRadius: 999,
2446
+ border: 0,
2447
+ padding: 2,
2448
+ flex: "0 0 auto",
2449
+ transition: "background 160ms ease"
2450
+ };
2451
+ var switchKnobStyle = {
2452
+ display: "block",
2453
+ width: 20,
2454
+ height: 20,
2455
+ borderRadius: "50%",
2456
+ background: "#fff",
2457
+ boxShadow: "0 1px 2px rgba(0,0,0,0.3)",
2458
+ transition: "transform 160ms ease"
2459
+ };
2460
+ var sectionLabelStyle = {
2461
+ fontSize: 13,
2462
+ fontWeight: 600
2463
+ };
2464
+ var hintStyle = {
2465
+ margin: 0,
2466
+ fontSize: 12,
2467
+ color: ACCENT,
2468
+ lineHeight: 1.4
2469
+ };
2470
+ var noticeStyle = {
2471
+ margin: 0,
2472
+ fontSize: 12,
2473
+ color: MUTED,
2474
+ lineHeight: 1.4
2475
+ };
2476
+ var checkRowStyle = {
2477
+ display: "flex",
2478
+ alignItems: "center",
2479
+ gap: 10,
2480
+ cursor: "pointer"
2481
+ };
2482
+ var TOKENS = { MUTED, BORDER, ACCENT};
2483
+ function AudienceSelect({
2484
+ creatorInfo,
2485
+ value,
2486
+ onChange
2487
+ }) {
2488
+ const id = react.useId();
2489
+ const options = js.audiencePrivacyOptions(creatorInfo.privacy_options, value);
2490
+ const unselected = js.audienceUnselected(value);
2491
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: [
2492
+ /* @__PURE__ */ jsxRuntime.jsx(SectionLabel, { children: "Who can view this post" }),
2493
+ /* @__PURE__ */ jsxRuntime.jsxs(
2494
+ "select",
2495
+ {
2496
+ id,
2497
+ value: value.privacy_level ?? "",
2498
+ onChange: (e) => onChange({
2499
+ ...value,
2500
+ // Validate against the OFFERED (filtered) options, not the full set —
2501
+ // so a manipulated value (e.g. SELF_ONLY while branded) can't slip in.
2502
+ privacy_level: js.parsePrivacyLevel(e.target.value, options)
2503
+ }),
2504
+ style: selectStyle,
2505
+ children: [
2506
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", disabled: true, children: "Select who can view this post" }),
2507
+ options.map((level) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: level, children: js.tiktokPrivacyLabel(level) }, level))
2508
+ ]
2509
+ }
2510
+ ),
2511
+ unselected ? /* @__PURE__ */ jsxRuntime.jsx(Hint, { children: js.TIKTOK_AUDIENCE_REQUIRED_HINT }) : null
2512
+ ] });
2513
+ }
2514
+ var selectStyle = {
2515
+ width: "100%",
2516
+ appearance: "none",
2517
+ background: "transparent",
2518
+ color: "inherit",
2519
+ border: `1px solid ${TOKENS.BORDER}`,
2520
+ borderRadius: 10,
2521
+ padding: "10px 12px",
2522
+ fontSize: 14,
2523
+ fontFamily: "inherit",
2524
+ outline: "none",
2525
+ cursor: "pointer"
2526
+ };
2527
+ function TikTokCaptionField({
2528
+ value,
2529
+ onChange,
2530
+ postType,
2531
+ placeholder = "Describe your post\u2026",
2532
+ className,
2533
+ style
2534
+ }) {
2535
+ const id = react.useId();
2536
+ const max = js.captionMaxFor(postType);
2537
+ const count = value.length;
2538
+ const over = count > max;
2539
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: { ...wrapStyle3, ...style }, children: [
2540
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: labelRowStyle, children: [
2541
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: id, style: labelStyle, children: "Caption" }),
2542
+ /* @__PURE__ */ jsxRuntime.jsxs(
2543
+ "span",
2544
+ {
2545
+ style: {
2546
+ ...countStyle,
2547
+ color: over ? varRef2(TT_VAR.accent) : varRef2(TT_VAR.muted)
2548
+ },
2549
+ children: [
2550
+ count.toLocaleString(),
2551
+ " / ",
2552
+ max.toLocaleString()
2553
+ ]
2554
+ }
2555
+ )
2556
+ ] }),
2557
+ /* @__PURE__ */ jsxRuntime.jsx(
2558
+ "textarea",
2559
+ {
2560
+ id,
2561
+ value,
2562
+ onChange: (e) => onChange(e.target.value),
2563
+ placeholder,
2564
+ rows: 4,
2565
+ style: {
2566
+ ...textareaStyle,
2567
+ borderColor: over ? varRef2(TT_VAR.accent) : varRef2(TT_VAR.border)
2568
+ }
2569
+ }
2570
+ )
2571
+ ] });
2572
+ }
2573
+ var wrapStyle3 = {
2574
+ display: "flex",
2575
+ flexDirection: "column",
2576
+ gap: 6,
2577
+ fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif'
2578
+ };
2579
+ var labelRowStyle = {
2580
+ display: "flex",
2581
+ alignItems: "baseline",
2582
+ justifyContent: "space-between"
2583
+ };
2584
+ var labelStyle = {
2585
+ fontSize: 13,
2586
+ fontWeight: 600,
2587
+ color: "inherit"
2588
+ };
2589
+ var countStyle = {
2590
+ fontSize: 12,
2591
+ fontVariantNumeric: "tabular-nums"
2592
+ };
2593
+ var textareaStyle = {
2594
+ width: "100%",
2595
+ resize: "vertical",
2596
+ background: "transparent",
2597
+ color: "inherit",
2598
+ border: "1px solid rgba(255,255,255,0.14)",
2599
+ borderRadius: 10,
2600
+ padding: "10px 12px",
2601
+ fontSize: 14,
2602
+ lineHeight: 1.4,
2603
+ fontFamily: "inherit",
2604
+ outline: "none",
2605
+ boxSizing: "border-box"
2606
+ };
2607
+ function CommercialDisclosure({
2608
+ value,
2609
+ onChange
2610
+ }) {
2611
+ const labelNotice = js.commercialLabelNotice(value);
2612
+ const incomplete = js.commercialDisclosureIncomplete(value);
2613
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: [
2614
+ /* @__PURE__ */ jsxRuntime.jsx(SectionLabel, { children: "Disclose post content" }),
2615
+ /* @__PURE__ */ jsxRuntime.jsx(
2616
+ Row,
2617
+ {
2618
+ label: "Disclose commercial content",
2619
+ sublabel: "Turn on if this post promotes a brand, product, or service.",
2620
+ control: /* @__PURE__ */ jsxRuntime.jsx(
2621
+ Switch,
2622
+ {
2623
+ checked: value.commercial_disclosure,
2624
+ ariaLabel: "Disclose commercial content",
2625
+ onChange: (next) => onChange(js.setCommercialDisclosure(value, next))
2626
+ }
2627
+ )
2628
+ }
2629
+ ),
2630
+ value.commercial_disclosure ? /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 8, paddingLeft: 2 }, children: [
2631
+ /* @__PURE__ */ jsxRuntime.jsx(
2632
+ CheckRow,
2633
+ {
2634
+ label: "Your brand",
2635
+ checked: value.your_brand,
2636
+ onChange: (next) => onChange(js.setBrandKind(value, "your_brand", next))
2637
+ }
2638
+ ),
2639
+ /* @__PURE__ */ jsxRuntime.jsx(
2640
+ CheckRow,
2641
+ {
2642
+ label: "Branded content",
2643
+ checked: value.branded_content,
2644
+ onChange: (next) => onChange(js.setBrandKind(value, "branded_content", next))
2645
+ }
2646
+ ),
2647
+ incomplete ? /* @__PURE__ */ jsxRuntime.jsx(Hint, { children: js.TIKTOK_DISCLOSURE_REQUIRED_HINT }) : null,
2648
+ labelNotice ? /* @__PURE__ */ jsxRuntime.jsx(Notice, { children: labelNotice }) : null
2649
+ ] }) : null
2650
+ ] });
2651
+ }
2652
+ function Declaration({ brandedContent }) {
2653
+ return /* @__PURE__ */ jsxRuntime.jsxs("p", { style: declarationStyle, children: [
2654
+ "By posting, you agree to TikTok's",
2655
+ " ",
2656
+ brandedContent ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2657
+ /* @__PURE__ */ jsxRuntime.jsx(DeclarationLink, { href: js.TIKTOK_BRANDED_CONTENT_POLICY_URL, children: "Branded Content Policy" }),
2658
+ " ",
2659
+ "and",
2660
+ " "
2661
+ ] }) : null,
2662
+ /* @__PURE__ */ jsxRuntime.jsx(DeclarationLink, { href: js.TIKTOK_MUSIC_CONFIRMATION_URL, children: "Music Usage Confirmation" }),
2663
+ "."
2664
+ ] });
2665
+ }
2666
+ function DeclarationLink({ href, children }) {
2667
+ return /* @__PURE__ */ jsxRuntime.jsx("a", { href, target: "_blank", rel: "noreferrer", style: linkStyle2, children });
2668
+ }
2669
+ var declarationStyle = {
2670
+ margin: 0,
2671
+ fontSize: 12,
2672
+ color: TOKENS.MUTED,
2673
+ lineHeight: 1.45
2674
+ };
2675
+ var linkStyle2 = {
2676
+ color: "inherit",
2677
+ textDecoration: "underline"
2678
+ };
2679
+ function InteractionToggles({
2680
+ creatorInfo,
2681
+ value,
2682
+ onChange,
2683
+ isVideo
2684
+ }) {
2685
+ const rows = js.interactionRows(creatorInfo, isVideo);
2686
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: [
2687
+ /* @__PURE__ */ jsxRuntime.jsx(SectionLabel, { children: "Allow users to" }),
2688
+ rows.map((row) => {
2689
+ const on = Boolean(value[js.interactionValueKey(row.key)]);
2690
+ return /* @__PURE__ */ jsxRuntime.jsx(
2691
+ Row,
2692
+ {
2693
+ label: row.label,
2694
+ sublabel: row.disabled ? "Turned off by this creator" : void 0,
2695
+ control: /* @__PURE__ */ jsxRuntime.jsx(
2696
+ Switch,
2697
+ {
2698
+ checked: !row.disabled && on,
2699
+ disabled: row.disabled,
2700
+ ariaLabel: `Allow ${row.label}`,
2701
+ onChange: (next) => onChange(js.toggleInteraction(value, row.key, next))
2702
+ }
2703
+ )
2704
+ },
2705
+ row.key
2706
+ );
2707
+ })
2708
+ ] });
2709
+ }
2710
+ function mediaCountValid(postType, count) {
2711
+ if (postType === "carousel") {
2712
+ return count >= 2 && count <= 35;
2713
+ }
2714
+ return count === 1;
2715
+ }
2716
+ function TikTokPublishPanel({
2717
+ variant,
2718
+ creatorInfo,
2719
+ caption,
2720
+ onCaptionChange,
2721
+ options,
2722
+ onOptionsChange,
2723
+ onPost,
2724
+ posting = false,
2725
+ theme = "auto",
2726
+ className,
2727
+ style
2728
+ }) {
2729
+ const dark = useIsDark2(theme);
2730
+ const isVideo = variant.post_type === "video";
2731
+ const captionOver = caption.length > js.captionMaxFor(variant.post_type);
2732
+ const mediaOk = mediaCountValid(variant.post_type, variant.media?.length ?? 0);
2733
+ const ready = !captionOver && mediaOk && js.tiktokOptionsReady(options);
2734
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2735
+ "div",
2736
+ {
2737
+ className,
2738
+ style: {
2739
+ ...paletteVars2(dark),
2740
+ ...panelStyle,
2741
+ color: varRef2(TT_VAR.text),
2742
+ ...style
2743
+ },
2744
+ children: [
2745
+ /* @__PURE__ */ jsxRuntime.jsx(
2746
+ TikTokCaptionField,
2747
+ {
2748
+ value: caption,
2749
+ onChange: onCaptionChange,
2750
+ postType: variant.post_type
2751
+ }
2752
+ ),
2753
+ /* @__PURE__ */ jsxRuntime.jsx(Divider, {}),
2754
+ /* @__PURE__ */ jsxRuntime.jsx(AudienceSelect, { creatorInfo, value: options, onChange: onOptionsChange }),
2755
+ /* @__PURE__ */ jsxRuntime.jsx(Divider, {}),
2756
+ /* @__PURE__ */ jsxRuntime.jsx(
2757
+ InteractionToggles,
2758
+ {
2759
+ creatorInfo,
2760
+ value: options,
2761
+ onChange: onOptionsChange,
2762
+ isVideo
2763
+ }
2764
+ ),
2765
+ /* @__PURE__ */ jsxRuntime.jsx(Divider, {}),
2766
+ /* @__PURE__ */ jsxRuntime.jsx(CommercialDisclosure, { value: options, onChange: onOptionsChange }),
2767
+ isVideo ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2768
+ /* @__PURE__ */ jsxRuntime.jsx(Divider, {}),
2769
+ /* @__PURE__ */ jsxRuntime.jsx(
2770
+ Row,
2771
+ {
2772
+ label: "AI-generated content",
2773
+ sublabel: "Disclose if this video was created or substantially edited with AI.",
2774
+ control: /* @__PURE__ */ jsxRuntime.jsx(
2775
+ Switch,
2776
+ {
2777
+ checked: options.aigc,
2778
+ ariaLabel: "AI-generated content",
2779
+ onChange: (next) => onOptionsChange({ ...options, aigc: next })
2780
+ }
2781
+ )
2782
+ }
2783
+ )
2784
+ ] }) : null,
2785
+ /* @__PURE__ */ jsxRuntime.jsx(Divider, {}),
2786
+ /* @__PURE__ */ jsxRuntime.jsx(Notice, { children: js.TIKTOK_PROCESSING_NOTICE }),
2787
+ /* @__PURE__ */ jsxRuntime.jsx(Declaration, { brandedContent: js.brandedContentDeclared(options) }),
2788
+ /* @__PURE__ */ jsxRuntime.jsx(
2789
+ "button",
2790
+ {
2791
+ type: "button",
2792
+ disabled: !ready || posting,
2793
+ onClick: onPost,
2794
+ style: {
2795
+ ...postButtonStyle,
2796
+ opacity: !ready || posting ? 0.5 : 1,
2797
+ cursor: !ready || posting ? "not-allowed" : "pointer"
2798
+ },
2799
+ children: posting ? "Posting\u2026" : "Post"
2800
+ }
2801
+ )
2802
+ ]
2803
+ }
2804
+ );
2805
+ }
2806
+ function Divider() {
2807
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: dividerStyle });
2808
+ }
2809
+ var panelStyle = {
2810
+ display: "flex",
2811
+ flexDirection: "column",
2812
+ gap: 16,
2813
+ width: "100%",
2814
+ fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif'
2815
+ };
2816
+ var dividerStyle = {
2817
+ height: 1,
2818
+ background: TOKENS.BORDER
2819
+ };
2820
+ var postButtonStyle = {
2821
+ width: "100%",
2822
+ border: 0,
2823
+ borderRadius: 10,
2824
+ background: TOKENS.ACCENT,
2825
+ color: "#fff",
2826
+ fontSize: 15,
2827
+ fontWeight: 600,
2828
+ padding: "12px 16px",
2829
+ transition: "opacity 160ms ease"
2830
+ };
1698
2831
 
2832
+ Object.defineProperty(exports, "TIKTOK_CAPTION_MAX", {
2833
+ enumerable: true,
2834
+ get: function () { return js.TIKTOK_CAPTION_MAX; }
2835
+ });
2836
+ Object.defineProperty(exports, "captionMaxFor", {
2837
+ enumerable: true,
2838
+ get: function () { return js.captionMaxFor; }
2839
+ });
2840
+ exports.ArticleCard = ArticleCard;
2841
+ exports.AudienceSelect = AudienceSelect;
2842
+ exports.CommercialDisclosure = CommercialDisclosure;
1699
2843
  exports.Connect = Connect;
2844
+ exports.Declaration = Declaration;
2845
+ exports.DocumentCard = DocumentCard;
2846
+ exports.InteractionToggles = InteractionToggles;
1700
2847
  exports.LinkedInPostPreview = LinkedInPostPreview;
2848
+ exports.Poll = Poll;
1701
2849
  exports.PostrunProvider = PostrunProvider;
2850
+ exports.TikTokCaptionField = TikTokCaptionField;
2851
+ exports.TikTokPostPreview = TikTokPostPreview;
2852
+ exports.TikTokPublishPanel = TikTokPublishPanel;
1702
2853
  exports.UploadError = UploadError;
1703
2854
  exports.XPostPreview = XPostPreview;
1704
2855
  exports.connectionKeys = connectionKeys;