@tamagui/logo 1.0.1-rc.8 → 1.0.1

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.
@@ -20,34 +20,15 @@ var TamaguiLogo_exports = {};
20
20
  __export(TamaguiLogo_exports, {
21
21
  LogoIcon: () => LogoIcon,
22
22
  LogoWords: () => LogoWords,
23
- TamaguiLogo: () => TamaguiLogo,
24
- logoColors: () => logoColors,
25
- tints: () => tints
23
+ TamaguiLogo: () => TamaguiLogo
26
24
  });
27
25
  module.exports = __toCommonJS(TamaguiLogo_exports);
28
26
  var import_jsx_runtime = require("react/jsx-runtime");
29
27
  var import_react = require("react");
30
28
  var import_tamagui = require("tamagui");
31
- const tints = [
32
- "orange",
33
- "yellow",
34
- "green",
35
- "blue",
36
- "purple",
37
- "pink",
38
- "red"
39
- ];
40
- const logoColors = tints.map((t) => `var(--${t}9)`);
29
+ var import_useTint = require("./useTint");
41
30
  const TamaguiLogo = (0, import_react.forwardRef)(
42
- ({
43
- showWords,
44
- color,
45
- downscale,
46
- onHoverLetter,
47
- pathPrefix,
48
- animated,
49
- ...props
50
- }, ref) => {
31
+ ({ showWords, downscale, animated, ...props }, ref) => {
51
32
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_tamagui.XStack, {
52
33
  tag: "span",
53
34
  ref,
@@ -57,135 +38,120 @@ const TamaguiLogo = (0, import_react.forwardRef)(
57
38
  ...props,
58
39
  children: [
59
40
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LogoIcon, {
60
- pathPrefix,
61
- downscale: (downscale ?? 1) * (showWords ? 2 : 1.5),
62
- color
41
+ downscale: (downscale ?? 1) * (showWords ? 2 : 1.5)
63
42
  }),
64
43
  showWords && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.YStack, {
65
44
  tag: "span",
66
45
  marginBottom: -4,
67
46
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LogoWords, {
68
47
  animated,
69
- onHoverLetter,
70
- downscale: downscale ?? 2,
71
- color
48
+ downscale: downscale ?? 2
72
49
  })
73
50
  })
74
51
  ]
75
52
  });
76
53
  }
77
54
  );
78
- const LogoWords = ({
79
- color,
80
- downscale = 1,
81
- onHoverLetter,
82
- animated
83
- }) => {
84
- const [index, setIndex] = (0, import_react.useState)(3);
85
- const [hovered, setHovered] = (0, import_react.useState)(false);
86
- const [mounted, setMounted] = (0, import_react.useState)("start");
87
- const updateHoveredLetter = (index2) => {
88
- setIndex(index2);
89
- setTimeout(() => {
90
- onHoverLetter == null ? void 0 : onHoverLetter(index2);
91
- });
92
- };
93
- (0, import_react.useEffect)(() => {
94
- setTimeout(() => {
95
- setMounted("animate");
96
- });
97
- setTimeout(() => {
98
- setMounted("done");
99
- }, 1500);
100
- }, []);
101
- (0, import_react.useEffect)(() => {
102
- var _a;
103
- return (_a = globalThis["onChangeTint"]) == null ? void 0 : _a.call(globalThis, (index2) => {
104
- setIndex(index2);
55
+ const LogoWords = (0, import_react.memo)(
56
+ ({ downscale = 1, animated }) => {
57
+ const Tint = (0, import_useTint.useTint)();
58
+ const { tintIndex: index, tint } = Tint;
59
+ const tints = Tint.tints.map((t) => `var(--${t}9)`);
60
+ const [hovered, setHovered] = (0, import_react.useState)(false);
61
+ const [mounted, setMounted] = (0, import_react.useState)("start");
62
+ (0, import_react.useEffect)(() => {
63
+ setTimeout(() => {
64
+ setMounted("animate");
65
+ });
66
+ setTimeout(() => {
67
+ setMounted("done");
68
+ }, 1500);
69
+ }, []);
70
+ const getColor = (i) => {
71
+ const isActive = mounted !== "start" && i === index;
72
+ if (mounted !== "done" || hovered) {
73
+ return isActive ? "var(--color)" : tints[index];
74
+ }
75
+ if (hovered && isActive) {
76
+ return "var(--color)";
77
+ }
78
+ return tints[i];
79
+ };
80
+ const x = Math.round(
81
+ index * 18.5 + 18 / 2 * (index / tints.length) + 3 + (index === 6 ? -3 : 0)
82
+ );
83
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_tamagui.XStack, {
84
+ onHoverIn: () => setHovered(true),
85
+ onHoverOut: () => setHovered(false),
86
+ paddingVertical: "$2",
87
+ marginVertical: "$-2",
88
+ position: "relative",
89
+ children: [
90
+ animated && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.Circle, {
91
+ animation: "quick",
92
+ position: "absolute",
93
+ top: 0,
94
+ left: 0,
95
+ y: mounted === "start" ? -30 : -3,
96
+ x,
97
+ size: 4,
98
+ backgroundColor: tint
99
+ }),
100
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", {
101
+ width: 373 * (1 / downscale) * 0.333333334,
102
+ height: 41 * (1 / downscale) * 0.333333334,
103
+ viewBox: "0 0 373 41",
104
+ children: [
105
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("polygon", {
106
+ shapeRendering: "crispEdges",
107
+ fill: getColor(0),
108
+ points: "24.3870968 40.1612903 24.3870968 8.67741935 32.2580645 8.67741935 32.2580645 0.806451613 0.774193548 0.806451613 0.774193548 8.67741935 8.64516129 8.67741935 8.64516129 40.1612903",
109
+ onMouseEnter: () => Tint.setTintIndex(0)
110
+ }),
111
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
112
+ shapeRendering: "crispEdges",
113
+ fill: getColor(1),
114
+ d: "M87.3548387,0.806451613 L87.3548387,8.67741935 L95.2258065,8.67741935 L95.2258065,40.1612903 L79.483871,40.1612903 L79.483871,24.4193548 L71.6129032,24.4193548 L71.6129032,40.1612903 L55.8709677,40.1612903 L55.8709677,8.67741935 L63.7419355,8.67741935 L63.7419355,0.806451613 L87.3548387,0.806451613 Z M79.483871,8.67741935 L71.6129032,8.67741935 L71.6129032,16.5483871 L79.483871,16.5483871 L79.483871,8.67741935 Z",
115
+ fillRule: "nonzero",
116
+ onMouseEnter: () => Tint.setTintIndex(1)
117
+ }),
118
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("polygon", {
119
+ shapeRendering: "crispEdges",
120
+ fill: getColor(2),
121
+ points: "130.645161 40.1612903 130.645161 22.4516129 138.516129 22.4516129 138.516129 40.1612903 154.258065 40.1612903 154.258065 0.806451613 142.451613 0.806451613 142.451613 8.67741935 126.709677 8.67741935 126.709677 0.806451613 114.903226 0.806451613 114.903226 40.1612903",
122
+ onMouseEnter: () => Tint.setTintIndex(2)
123
+ }),
124
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
125
+ fill: getColor(3),
126
+ d: "M205.419355,0.806451613 L205.419355,8.67741935 L213.290323,8.67741935 L213.290323,40.1612903 L197.548387,40.1612903 L197.548387,24.4193548 L189.677419,24.4193548 L189.677419,40.1612903 L173.935484,40.1612903 L173.935484,8.67741935 L181.806452,8.67741935 L181.806452,0.806451613 L205.419355,0.806451613 Z M197.548387,8.67741935 L189.677419,8.67741935 L189.677419,16.5483871 L197.548387,16.5483871 L197.548387,8.67741935 Z",
127
+ fillRule: "nonzero",
128
+ onMouseEnter: () => Tint.setTintIndex(3)
129
+ }),
130
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("polygon", {
131
+ shapeRendering: "crispEdges",
132
+ fill: getColor(4),
133
+ points: "264.451613 40.1612903 264.451613 32.2903226 272.322581 32.2903226 272.322581 16.5483871 256.580645 16.5483871 256.580645 32.2903226 248.709677 32.2903226 248.709677 8.67741935 272.322581 8.67741935 272.322581 0.806451613 240.83871 0.806451613 240.83871 8.67741935 232.967742 8.67741935 232.967742 32.2903226 240.83871 32.2903226 240.83871 40.1612903",
134
+ onMouseEnter: () => Tint.setTintIndex(4)
135
+ }),
136
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("polygon", {
137
+ shapeRendering: "crispEdges",
138
+ fill: getColor(5),
139
+ points: "323.483871 40.1612903 323.483871 32.2903226 331.354839 32.2903226 331.354839 0.806451613 315.612903 0.806451613 315.612903 32.2903226 307.741935 32.2903226 307.741935 0.806451613 292 0.806451613 292 32.2903226 299.870968 32.2903226 299.870968 40.1612903",
140
+ onMouseEnter: () => Tint.setTintIndex(5)
141
+ }),
142
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("polygon", {
143
+ shapeRendering: "crispEdges",
144
+ fill: getColor(6),
145
+ points: "372.677419 40.1612903 372.677419 0.806451613 356.935484 0.806451613 356.935484 40.1612903",
146
+ onMouseEnter: () => Tint.setTintIndex(6)
147
+ })
148
+ ]
149
+ })
150
+ ]
105
151
  });
106
- }, []);
107
- const getColor = (i) => {
108
- const isActive = mounted !== "start" && i === index;
109
- if (mounted !== "done" || hovered) {
110
- return isActive ? "var(--color)" : logoColors[index];
111
- }
112
- if (hovered && isActive) {
113
- return "var(--color)";
114
- }
115
- return logoColors[i];
116
- };
117
- const x = index * 18.5 + 18 / 2 * (index / logoColors.length) + 3 + (index === 6 ? -3 : 0);
118
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_tamagui.XStack, {
119
- onHoverIn: () => setHovered(true),
120
- onHoverOut: () => setHovered(false),
121
- paddingVertical: "$2",
122
- marginVertical: "$-2",
123
- position: "relative",
124
- children: [
125
- animated && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.Circle, {
126
- animation: "quick",
127
- position: "absolute",
128
- top: 0,
129
- left: 0,
130
- y: mounted === "start" ? -30 : -3,
131
- x,
132
- size: 4,
133
- backgroundColor: logoColors[index]
134
- }),
135
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", {
136
- width: 373 * (1 / downscale) * 0.333333334,
137
- height: 41 * (1 / downscale) * 0.333333334,
138
- viewBox: "0 0 373 41",
139
- children: [
140
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("polygon", {
141
- shapeRendering: "crispEdges",
142
- fill: color || getColor(0),
143
- points: "24.3870968 40.1612903 24.3870968 8.67741935 32.2580645 8.67741935 32.2580645 0.806451613 0.774193548 0.806451613 0.774193548 8.67741935 8.64516129 8.67741935 8.64516129 40.1612903",
144
- onMouseEnter: () => updateHoveredLetter(0)
145
- }),
146
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
147
- shapeRendering: "crispEdges",
148
- fill: color || getColor(1),
149
- d: "M87.3548387,0.806451613 L87.3548387,8.67741935 L95.2258065,8.67741935 L95.2258065,40.1612903 L79.483871,40.1612903 L79.483871,24.4193548 L71.6129032,24.4193548 L71.6129032,40.1612903 L55.8709677,40.1612903 L55.8709677,8.67741935 L63.7419355,8.67741935 L63.7419355,0.806451613 L87.3548387,0.806451613 Z M79.483871,8.67741935 L71.6129032,8.67741935 L71.6129032,16.5483871 L79.483871,16.5483871 L79.483871,8.67741935 Z",
150
- fillRule: "nonzero",
151
- onMouseEnter: () => updateHoveredLetter(1)
152
- }),
153
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("polygon", {
154
- shapeRendering: "crispEdges",
155
- fill: color || getColor(2),
156
- points: "130.645161 40.1612903 130.645161 22.4516129 138.516129 22.4516129 138.516129 40.1612903 154.258065 40.1612903 154.258065 0.806451613 142.451613 0.806451613 142.451613 8.67741935 126.709677 8.67741935 126.709677 0.806451613 114.903226 0.806451613 114.903226 40.1612903",
157
- onMouseEnter: () => updateHoveredLetter(2)
158
- }),
159
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
160
- fill: color || getColor(3),
161
- d: "M205.419355,0.806451613 L205.419355,8.67741935 L213.290323,8.67741935 L213.290323,40.1612903 L197.548387,40.1612903 L197.548387,24.4193548 L189.677419,24.4193548 L189.677419,40.1612903 L173.935484,40.1612903 L173.935484,8.67741935 L181.806452,8.67741935 L181.806452,0.806451613 L205.419355,0.806451613 Z M197.548387,8.67741935 L189.677419,8.67741935 L189.677419,16.5483871 L197.548387,16.5483871 L197.548387,8.67741935 Z",
162
- fillRule: "nonzero",
163
- onMouseEnter: () => updateHoveredLetter(3)
164
- }),
165
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("polygon", {
166
- shapeRendering: "crispEdges",
167
- fill: color || getColor(4),
168
- points: "264.451613 40.1612903 264.451613 32.2903226 272.322581 32.2903226 272.322581 16.5483871 256.580645 16.5483871 256.580645 32.2903226 248.709677 32.2903226 248.709677 8.67741935 272.322581 8.67741935 272.322581 0.806451613 240.83871 0.806451613 240.83871 8.67741935 232.967742 8.67741935 232.967742 32.2903226 240.83871 32.2903226 240.83871 40.1612903",
169
- onMouseEnter: () => updateHoveredLetter(4)
170
- }),
171
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("polygon", {
172
- shapeRendering: "crispEdges",
173
- fill: color || getColor(5),
174
- points: "323.483871 40.1612903 323.483871 32.2903226 331.354839 32.2903226 331.354839 0.806451613 315.612903 0.806451613 315.612903 32.2903226 307.741935 32.2903226 307.741935 0.806451613 292 0.806451613 292 32.2903226 299.870968 32.2903226 299.870968 40.1612903",
175
- onMouseEnter: () => updateHoveredLetter(5)
176
- }),
177
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("polygon", {
178
- shapeRendering: "crispEdges",
179
- fill: color || getColor(6),
180
- points: "372.677419 40.1612903 372.677419 0.806451613 356.935484 0.806451613 356.935484 40.1612903",
181
- onMouseEnter: () => updateHoveredLetter(6)
182
- })
183
- ]
184
- })
185
- ]
186
- });
187
- };
188
- const LogoIcon = ({ downscale = 2, pathPrefix }) => {
152
+ }
153
+ );
154
+ const LogoIcon = ({ downscale = 2 }) => {
189
155
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.YStack, {
190
156
  tag: "span",
191
157
  className: "unselectable",
@@ -198,7 +164,7 @@ const LogoIcon = ({ downscale = 2, pathPrefix }) => {
198
164
  className: "tamagui-icon",
199
165
  width: 450 / 8 / downscale,
200
166
  height: 420 / 8 / downscale,
201
- src: `${pathPrefix || ""}/tamagui-icon.svg`
167
+ src: `/tamagui-icon.svg`
202
168
  })
203
169
  });
204
170
  };
@@ -206,8 +172,6 @@ const LogoIcon = ({ downscale = 2, pathPrefix }) => {
206
172
  0 && (module.exports = {
207
173
  LogoIcon,
208
174
  LogoWords,
209
- TamaguiLogo,
210
- logoColors,
211
- tints
175
+ TamaguiLogo
212
176
  });
213
177
  //# sourceMappingURL=TamaguiLogo.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/TamaguiLogo.tsx"],
4
- "sourcesContent": ["import { forwardRef, useEffect, useState } from 'react'\nimport { Circle, ThemeName, XStack, XStackProps, YStack } from 'tamagui'\n\nexport const tints: ThemeName[] = [\n 'orange',\n 'yellow',\n 'green',\n 'blue',\n 'purple',\n 'pink',\n 'red',\n]\n\nexport const logoColors = tints.map((t) => `var(--${t}9)`)\n\ntype LogoProps = {\n onHoverLetter?: (i: number) => void\n showWords?: boolean\n color?: string\n downscale?: number\n pathPrefix?: string\n animated?: boolean\n} & XStackProps\n\nexport const TamaguiLogo = forwardRef<any, LogoProps>(\n (\n {\n showWords,\n color,\n downscale,\n onHoverLetter,\n pathPrefix,\n animated,\n ...props\n }: LogoProps,\n ref,\n ) => {\n return (\n <XStack\n tag=\"span\"\n ref={ref}\n alignItems=\"center\"\n justifyContent=\"center\"\n space=\"$5\"\n {...props}\n >\n <LogoIcon\n pathPrefix={pathPrefix}\n downscale={(downscale ?? 1) * (showWords ? 2 : 1.5)}\n color={color}\n />\n {showWords && (\n <YStack tag=\"span\" marginBottom={-4}>\n <LogoWords\n animated={animated}\n onHoverLetter={onHoverLetter}\n downscale={downscale ?? 2}\n color={color}\n />\n </YStack>\n )}\n </XStack>\n )\n },\n)\n\nexport const LogoWords = ({\n color,\n downscale = 1,\n onHoverLetter,\n animated,\n}: {\n color?: string\n downscale?: number\n onHoverLetter?: any\n animated?: boolean\n}) => {\n const [index, setIndex] = useState(3)\n const [hovered, setHovered] = useState(false)\n const [mounted, setMounted] = useState<'start' | 'animate' | 'done'>('start')\n\n const updateHoveredLetter = (index: number) => {\n setIndex(index)\n setTimeout(() => {\n onHoverLetter?.(index)\n })\n }\n\n useEffect(() => {\n setTimeout(() => {\n setMounted('animate')\n })\n\n setTimeout(() => {\n setMounted('done')\n }, 1500)\n }, [])\n\n useEffect(() => {\n // temp hack\n return globalThis['onChangeTint']?.((index) => {\n setIndex(index)\n })\n }, [])\n\n const getColor = (i: number) => {\n const isActive = mounted !== 'start' && i === index\n if (mounted !== 'done' || hovered) {\n return isActive ? 'var(--color)' : logoColors[index]\n }\n if (hovered && isActive) {\n return 'var(--color)'\n }\n return logoColors[i]\n }\n\n const x =\n index * 18.5 +\n (18 / 2) * (index / logoColors.length) +\n 3 +\n (index === 6 ? -3 : 0)\n\n return (\n <XStack\n onHoverIn={() => setHovered(true)}\n onHoverOut={() => setHovered(false)}\n paddingVertical=\"$2\"\n marginVertical=\"$-2\"\n position=\"relative\"\n >\n {animated && (\n <Circle\n animation=\"quick\"\n position=\"absolute\"\n top={0}\n left={0}\n y={mounted === 'start' ? -30 : -3}\n // the last i is less wide\n x={x}\n size={4}\n backgroundColor={logoColors[index]}\n />\n )}\n <svg\n width={373 * (1 / downscale) * 0.333333334}\n height={41 * (1 / downscale) * 0.333333334}\n viewBox=\"0 0 373 41\"\n >\n <polygon\n shapeRendering=\"crispEdges\"\n fill={color || getColor(0)}\n points=\"24.3870968 40.1612903 24.3870968 8.67741935 32.2580645 8.67741935 32.2580645 0.806451613 0.774193548 0.806451613 0.774193548 8.67741935 8.64516129 8.67741935 8.64516129 40.1612903\"\n onMouseEnter={() => updateHoveredLetter(0)}\n />\n <path\n shapeRendering=\"crispEdges\"\n fill={color || getColor(1)}\n d=\"M87.3548387,0.806451613 L87.3548387,8.67741935 L95.2258065,8.67741935 L95.2258065,40.1612903 L79.483871,40.1612903 L79.483871,24.4193548 L71.6129032,24.4193548 L71.6129032,40.1612903 L55.8709677,40.1612903 L55.8709677,8.67741935 L63.7419355,8.67741935 L63.7419355,0.806451613 L87.3548387,0.806451613 Z M79.483871,8.67741935 L71.6129032,8.67741935 L71.6129032,16.5483871 L79.483871,16.5483871 L79.483871,8.67741935 Z\"\n fillRule=\"nonzero\"\n onMouseEnter={() => updateHoveredLetter(1)}\n />\n <polygon\n shapeRendering=\"crispEdges\"\n fill={color || getColor(2)}\n points=\"130.645161 40.1612903 130.645161 22.4516129 138.516129 22.4516129 138.516129 40.1612903 154.258065 40.1612903 154.258065 0.806451613 142.451613 0.806451613 142.451613 8.67741935 126.709677 8.67741935 126.709677 0.806451613 114.903226 0.806451613 114.903226 40.1612903\"\n onMouseEnter={() => updateHoveredLetter(2)}\n />\n <path\n fill={color || getColor(3)}\n d=\"M205.419355,0.806451613 L205.419355,8.67741935 L213.290323,8.67741935 L213.290323,40.1612903 L197.548387,40.1612903 L197.548387,24.4193548 L189.677419,24.4193548 L189.677419,40.1612903 L173.935484,40.1612903 L173.935484,8.67741935 L181.806452,8.67741935 L181.806452,0.806451613 L205.419355,0.806451613 Z M197.548387,8.67741935 L189.677419,8.67741935 L189.677419,16.5483871 L197.548387,16.5483871 L197.548387,8.67741935 Z\"\n fillRule=\"nonzero\"\n onMouseEnter={() => updateHoveredLetter(3)}\n />\n <polygon\n shapeRendering=\"crispEdges\"\n fill={color || getColor(4)}\n points=\"264.451613 40.1612903 264.451613 32.2903226 272.322581 32.2903226 272.322581 16.5483871 256.580645 16.5483871 256.580645 32.2903226 248.709677 32.2903226 248.709677 8.67741935 272.322581 8.67741935 272.322581 0.806451613 240.83871 0.806451613 240.83871 8.67741935 232.967742 8.67741935 232.967742 32.2903226 240.83871 32.2903226 240.83871 40.1612903\"\n onMouseEnter={() => updateHoveredLetter(4)}\n />\n <polygon\n shapeRendering=\"crispEdges\"\n fill={color || getColor(5)}\n points=\"323.483871 40.1612903 323.483871 32.2903226 331.354839 32.2903226 331.354839 0.806451613 315.612903 0.806451613 315.612903 32.2903226 307.741935 32.2903226 307.741935 0.806451613 292 0.806451613 292 32.2903226 299.870968 32.2903226 299.870968 40.1612903\"\n onMouseEnter={() => updateHoveredLetter(5)}\n />\n <polygon\n shapeRendering=\"crispEdges\"\n fill={color || getColor(6)}\n points=\"372.677419 40.1612903 372.677419 0.806451613 356.935484 0.806451613 356.935484 40.1612903\"\n onMouseEnter={() => updateHoveredLetter(6)}\n />\n </svg>\n </XStack>\n )\n}\n\nexport const LogoIcon = ({ downscale = 2, pathPrefix }: any) => {\n return (\n <YStack\n tag=\"span\"\n className=\"unselectable\"\n alignSelf=\"center\"\n marginVertical={-10}\n pressStyle={{\n opacity: 0.7,\n }}\n >\n <img\n className=\"tamagui-icon\"\n width={450 / 8 / downscale}\n height={420 / 8 / downscale}\n src={`${pathPrefix || ''}/tamagui-icon.svg`}\n />\n </YStack>\n )\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAsCM;AAtCN,mBAAgD;AAChD,qBAA+D;AAExD,MAAM,QAAqB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,MAAM,aAAa,MAAM,IAAI,CAAC,MAAM,SAAS,KAAK;AAWlD,MAAM,kBAAc;AAAA,EACzB,CACE;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,OACG;AAAA,EACL,GACA,QACG;AACH,WACE,6CAAC;AAAA,MACC,KAAI;AAAA,MACJ;AAAA,MACA,YAAW;AAAA,MACX,gBAAe;AAAA,MACf,OAAM;AAAA,MACL,GAAG;AAAA,MAEJ;AAAA,oDAAC;AAAA,UACC;AAAA,UACA,YAAY,aAAa,MAAM,YAAY,IAAI;AAAA,UAC/C;AAAA,SACF;AAAA,QACC,aACC,4CAAC;AAAA,UAAO,KAAI;AAAA,UAAO,cAAc;AAAA,UAC/B,sDAAC;AAAA,YACC;AAAA,YACA;AAAA,YACA,WAAW,aAAa;AAAA,YACxB;AAAA,WACF;AAAA,SACF;AAAA;AAAA,KAEJ;AAAA,EAEJ;AACF;AAEO,MAAM,YAAY,CAAC;AAAA,EACxB;AAAA,EACA,YAAY;AAAA,EACZ;AAAA,EACA;AACF,MAKM;AACJ,QAAM,CAAC,OAAO,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U;AAAA,IACV,gBAAgB;AAAA,IAChB,YAAY;AAAA,MACV,SAAS;AAAA,IACX;AAAA,IAEA,sDAAC;AAAA,MACC,WAAU;AAAA,MACV,OAAO,MAAM,IAAI;AAAA,MACjB,QAAQ,MAAM,IAAI;AAAA,MAClB,KAAK,GAAG,cAAc;AAAA,KACxB;AAAA,GACF;AAEJ;",
6
- "names": ["index"]
4
+ "sourcesContent": ["import { forwardRef, memo, useEffect, useState } from 'react'\nimport { Circle, XStack, XStackProps, YStack } from 'tamagui'\n\nimport { useTint } from './useTint'\n\ntype LogoProps = {\n showWords?: boolean\n downscale?: number\n animated?: boolean\n} & XStackProps\n\nexport const TamaguiLogo = forwardRef<any, LogoProps>(\n ({ showWords, downscale, animated, ...props }: LogoProps, ref) => {\n return (\n <XStack\n tag=\"span\"\n ref={ref}\n alignItems=\"center\"\n justifyContent=\"center\"\n space=\"$5\"\n {...props}\n >\n <LogoIcon downscale={(downscale ?? 1) * (showWords ? 2 : 1.5)} />\n {showWords && (\n <YStack tag=\"span\" marginBottom={-4}>\n <LogoWords animated={animated} downscale={downscale ?? 2} />\n </YStack>\n )}\n </XStack>\n )\n }\n)\n\nexport const LogoWords = memo(\n ({ downscale = 1, animated }: { downscale?: number; animated?: boolean }) => {\n const Tint = useTint()\n const { tintIndex: index, tint } = Tint\n const tints = Tint.tints.map((t) => `var(--${t}9)`)\n const [hovered, setHovered] = useState(false)\n const [mounted, setMounted] = useState<'start' | 'animate' | 'done'>('start')\n\n useEffect(() => {\n setTimeout(() => {\n setMounted('animate')\n })\n\n setTimeout(() => {\n setMounted('done')\n }, 1500)\n }, [])\n\n const getColor = (i: number) => {\n const isActive = mounted !== 'start' && i === index\n if (mounted !== 'done' || hovered) {\n return isActive ? 'var(--color)' : tints[index]\n }\n if (hovered && isActive) {\n return 'var(--color)'\n }\n return tints[i]\n }\n\n const x = Math.round(\n index * 18.5 + (18 / 2) * (index / tints.length) + 3 + (index === 6 ? -3 : 0)\n )\n\n return (\n <XStack\n onHoverIn={() => setHovered(true)}\n onHoverOut={() => setHovered(false)}\n paddingVertical=\"$2\"\n marginVertical=\"$-2\"\n position=\"relative\"\n >\n {animated && (\n <Circle\n animation=\"quick\"\n position=\"absolute\"\n top={0}\n left={0}\n y={mounted === 'start' ? -30 : -3}\n // the last i is less wide\n x={x}\n size={4}\n backgroundColor={tint}\n />\n )}\n <svg\n width={373 * (1 / downscale) * 0.333333334}\n height={41 * (1 / downscale) * 0.333333334}\n viewBox=\"0 0 373 41\"\n >\n <polygon\n shapeRendering=\"crispEdges\"\n fill={getColor(0)}\n points=\"24.3870968 40.1612903 24.3870968 8.67741935 32.2580645 8.67741935 32.2580645 0.806451613 0.774193548 0.806451613 0.774193548 8.67741935 8.64516129 8.67741935 8.64516129 40.1612903\"\n onMouseEnter={() => Tint.setTintIndex(0)}\n />\n <path\n shapeRendering=\"crispEdges\"\n fill={getColor(1)}\n d=\"M87.3548387,0.806451613 L87.3548387,8.67741935 L95.2258065,8.67741935 L95.2258065,40.1612903 L79.483871,40.1612903 L79.483871,24.4193548 L71.6129032,24.4193548 L71.6129032,40.1612903 L55.8709677,40.1612903 L55.8709677,8.67741935 L63.7419355,8.67741935 L63.7419355,0.806451613 L87.3548387,0.806451613 Z M79.483871,8.67741935 L71.6129032,8.67741935 L71.6129032,16.5483871 L79.483871,16.5483871 L79.483871,8.67741935 Z\"\n fillRule=\"nonzero\"\n onMouseEnter={() => Tint.setTintIndex(1)}\n />\n <polygon\n shapeRendering=\"crispEdges\"\n fill={getColor(2)}\n points=\"130.645161 40.1612903 130.645161 22.4516129 138.516129 22.4516129 138.516129 40.1612903 154.258065 40.1612903 154.258065 0.806451613 142.451613 0.806451613 142.451613 8.67741935 126.709677 8.67741935 126.709677 0.806451613 114.903226 0.806451613 114.903226 40.1612903\"\n onMouseEnter={() => Tint.setTintIndex(2)}\n />\n <path\n fill={getColor(3)}\n d=\"M205.419355,0.806451613 L205.419355,8.67741935 L213.290323,8.67741935 L213.290323,40.1612903 L197.548387,40.1612903 L197.548387,24.4193548 L189.677419,24.4193548 L189.677419,40.1612903 L173.935484,40.1612903 L173.935484,8.67741935 L181.806452,8.67741935 L181.806452,0.806451613 L205.419355,0.806451613 Z M197.548387,8.67741935 L189.677419,8.67741935 L189.677419,16.5483871 L197.548387,16.5483871 L197.548387,8.67741935 Z\"\n fillRule=\"nonzero\"\n onMouseEnter={() => Tint.setTintIndex(3)}\n />\n <polygon\n shapeRendering=\"crispEdges\"\n fill={getColor(4)}\n points=\"264.451613 40.1612903 264.451613 32.2903226 272.322581 32.2903226 272.322581 16.5483871 256.580645 16.5483871 256.580645 32.2903226 248.709677 32.2903226 248.709677 8.67741935 272.322581 8.67741935 272.322581 0.806451613 240.83871 0.806451613 240.83871 8.67741935 232.967742 8.67741935 232.967742 32.2903226 240.83871 32.2903226 240.83871 40.1612903\"\n onMouseEnter={() => Tint.setTintIndex(4)}\n />\n <polygon\n shapeRendering=\"crispEdges\"\n fill={getColor(5)}\n points=\"323.483871 40.1612903 323.483871 32.2903226 331.354839 32.2903226 331.354839 0.806451613 315.612903 0.806451613 315.612903 32.2903226 307.741935 32.2903226 307.741935 0.806451613 292 0.806451613 292 32.2903226 299.870968 32.2903226 299.870968 40.1612903\"\n onMouseEnter={() => Tint.setTintIndex(5)}\n />\n <polygon\n shapeRendering=\"crispEdges\"\n fill={getColor(6)}\n points=\"372.677419 40.1612903 372.677419 0.806451613 356.935484 0.806451613 356.935484 40.1612903\"\n onMouseEnter={() => Tint.setTintIndex(6)}\n />\n </svg>\n </XStack>\n )\n }\n)\n\nexport const LogoIcon = ({ downscale = 2 }: any) => {\n return (\n <YStack\n tag=\"span\"\n className=\"unselectable\"\n alignSelf=\"center\"\n marginVertical={-10}\n pressStyle={{\n opacity: 0.7,\n }}\n >\n <img\n className=\"tamagui-icon\"\n width={450 / 8 / downscale}\n height={420 / 8 / downscale}\n src={`/tamagui-icon.svg`}\n />\n </YStack>\n )\n}\n"],
5
+ "mappings": ";;;;;;;;;;;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AA,cACP,cAAc,MAAM,KAAK,aAAa,CAAC;AAAA,aACzC;AAAA,YACA,4CAAC;AAAA,cACC,gBAAe;AAAA,cACf,MAAM,SAAS,CAAC;AAAA,cAChB,QAAO;AAAA,cACP,cAAc,MAAM,KAAK,aAAa,CAAC;AAAA,aACzC;AAAA,YACA,4CAAC;AAAA,cACC,gBAAe;AAAA,cACf,MAAM,SAAS,CAAC;AAAA,cAChB,QAAO;AAAA,cACP,cAAc,MAAM,KAAK,aAAa,CAAC;AAAA,aACzC;AAAA;AAAA,SACF;AAAA;AAAA,KACF;AAAA,EAEJ;AACF;AAEO,MAAM,WAAW,CAAC,EAAE,YAAY,EAAE,MAAW;AAClD,SACE,4CAAC;AAAA,IACC,KAAI;AAAA,IACJ,WAAU;AAAA,IACV,WAAU;AAAA,IACV,gBAAgB;AAAA,IAChB,YAAY;AAAA,MACV,SAAS;AAAA,IACX;AAAA,IAEA,sDAAC;AAAA,MACC,WAAU;AAAA,MACV,OAAO,MAAM,IAAI;AAAA,MACjB,QAAQ,MAAM,IAAI;AAAA,MAClB,KAAK;AAAA,KACP;AAAA,GACF;AAEJ;",
6
+ "names": []
7
7
  }
package/dist/cjs/index.js CHANGED
@@ -16,4 +16,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
16
16
  var src_exports = {};
17
17
  module.exports = __toCommonJS(src_exports);
18
18
  __reExport(src_exports, require("./TamaguiLogo"), module.exports);
19
+ __reExport(src_exports, require("./tints"), module.exports);
20
+ __reExport(src_exports, require("./useTint"), module.exports);
19
21
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.tsx"],
4
- "sourcesContent": ["export * from './TamaguiLogo'\n"],
5
- "mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,0BAAd;",
4
+ "sourcesContent": ["export * from './TamaguiLogo'\nexport * from './tints'\nexport * from './useTint'\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,0BAAd;AACA,wBAAc,oBADd;AAEA,wBAAc,sBAFd;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var tints_exports = {};
20
+ __export(tints_exports, {
21
+ getTints: () => getTints,
22
+ onTintFamilyChange: () => onTintFamilyChange,
23
+ setNextTintFamily: () => setNextTintFamily,
24
+ setTintFamily: () => setTintFamily,
25
+ useTints: () => useTints
26
+ });
27
+ module.exports = __toCommonJS(tints_exports);
28
+ var import_react = require("react");
29
+ const families = Object.freeze({
30
+ tamagui: ["orange", "yellow", "green", "blue", "purple", "pink", "red"],
31
+ xmas: ["red", "green", "red", "green", "red", "green", "red"]
32
+ });
33
+ let fam = "tamagui";
34
+ function getTints() {
35
+ return {
36
+ name: fam || "tamagui",
37
+ tints: families[fam] || families.tamagui,
38
+ families
39
+ };
40
+ }
41
+ function useTints() {
42
+ const [val, setVal] = (0, import_react.useState)(getTints());
43
+ (0, import_react.useEffect)(() => {
44
+ return onTintFamilyChange(() => {
45
+ setVal(getTints());
46
+ });
47
+ }, []);
48
+ return val;
49
+ }
50
+ const setTintFamily = (next) => {
51
+ if (!families[next])
52
+ throw `impossible`;
53
+ fam = next;
54
+ listeners.forEach((l) => l(next));
55
+ };
56
+ const setNextTintFamily = () => {
57
+ setTintFamily(fam === "tamagui" ? "xmas" : "tamagui");
58
+ };
59
+ const listeners = /* @__PURE__ */ new Set();
60
+ const onTintFamilyChange = (cb) => {
61
+ listeners.add(cb);
62
+ return () => {
63
+ listeners.delete(cb);
64
+ };
65
+ };
66
+ // Annotate the CommonJS export names for ESM import in node:
67
+ 0 && (module.exports = {
68
+ getTints,
69
+ onTintFamilyChange,
70
+ setNextTintFamily,
71
+ setTintFamily,
72
+ useTints
73
+ });
74
+ //# sourceMappingURL=tints.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/tints.tsx"],
4
+ "sourcesContent": ["import { useEffect, useState } from 'react'\nimport { ThemeName } from 'tamagui'\n\nconst families = Object.freeze({\n tamagui: ['orange', 'yellow', 'green', 'blue', 'purple', 'pink', 'red'],\n xmas: ['red', 'green', 'red', 'green', 'red', 'green', 'red'],\n}) as {\n [key in 'tamagui' | 'xmas']: ThemeName[]\n}\n\ntype TintFamily = keyof typeof families\n\nlet fam: TintFamily = 'tamagui'\n\nexport function getTints() {\n return {\n name: fam || 'tamagui',\n tints: families[fam] || families.tamagui,\n families,\n }\n}\n\nexport function useTints() {\n const [val, setVal] = useState(getTints())\n\n useEffect(() => {\n return onTintFamilyChange(() => {\n setVal(getTints())\n })\n }, [])\n\n return val\n}\n\nexport const setTintFamily = (next: TintFamily) => {\n if (!families[next]) throw `impossible`\n fam = next\n listeners.forEach((l) => l(next))\n}\n\nexport const setNextTintFamily = () => {\n setTintFamily(fam === 'tamagui' ? 'xmas' : 'tamagui')\n}\n\ntype ChangeHandler = (next: TintFamily) => void\n\nconst listeners = new Set<ChangeHandler>()\n\nexport const onTintFamilyChange = (cb: ChangeHandler) => {\n listeners.add(cb)\n return () => {\n listeners.delete(cb)\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAoC;AAGpC,MAAM,WAAW,OAAO,OAAO;AAAA,EAC7B,SAAS,CAAC,UAAU,UAAU,SAAS,QAAQ,UAAU,QAAQ,KAAK;AAAA,EACtE,MAAM,CAAC,OAAO,SAAS,OAAO,SAAS,OAAO,SAAS,KAAK;AAC9D,CAAC;AAMD,IAAI,MAAkB;AAEf,SAAS,WAAW;AACzB,SAAO;AAAA,IACL,MAAM,OAAO;AAAA,IACb,OAAO,SAAS,QAAQ,SAAS;AAAA,IACjC;AAAA,EACF;AACF;AAEO,SAAS,WAAW;AACzB,QAAM,CAAC,KAAK,MAAM,QAAI,uBAAS,SAAS,CAAC;AAEzC,8BAAU,MAAM;AACd,WAAO,mBAAmB,MAAM;AAC9B,aAAO,SAAS,CAAC;AAAA,IACnB,CAAC;AAAA,EACH,GAAG,CAAC,CAAC;AAEL,SAAO;AACT;AAEO,MAAM,gBAAgB,CAAC,SAAqB;AACjD,MAAI,CAAC,SAAS;AAAO,UAAM;AAC3B,QAAM;AACN,YAAU,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;AAClC;AAEO,MAAM,oBAAoB,MAAM;AACrC,gBAAc,QAAQ,YAAY,SAAS,SAAS;AACtD;AAIA,MAAM,YAAY,oBAAI,IAAmB;AAElC,MAAM,qBAAqB,CAAC,OAAsB;AACvD,YAAU,IAAI,EAAE;AAChB,SAAO,MAAM;AACX,cAAU,OAAO,EAAE;AAAA,EACrB;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var useTint_exports = {};
20
+ __export(useTint_exports, {
21
+ ThemeTint: () => ThemeTint,
22
+ initialTint: () => initialTint,
23
+ onTintChange: () => onTintChange,
24
+ setTintIndex: () => setTintIndex,
25
+ useTint: () => useTint
26
+ });
27
+ module.exports = __toCommonJS(useTint_exports);
28
+ var import_jsx_runtime = require("react/jsx-runtime");
29
+ var import_react = require("react");
30
+ var import_tamagui = require("tamagui");
31
+ var import_tints = require("./tints");
32
+ const initialTint = 3;
33
+ let current = initialTint;
34
+ const listeners = /* @__PURE__ */ new Set();
35
+ const onTintChange = (listener) => {
36
+ listeners.add(listener);
37
+ return () => {
38
+ listeners.delete(listener);
39
+ };
40
+ };
41
+ const numTints = (0, import_tints.getTints)().tints.length;
42
+ const setTintIndex = (next) => {
43
+ const val = next % numTints;
44
+ if (val === current)
45
+ return;
46
+ current = val;
47
+ listeners.forEach((x) => x(val));
48
+ };
49
+ const useTint = () => {
50
+ const index = (0, import_react.useSyncExternalStore)(
51
+ onTintChange,
52
+ () => current,
53
+ () => initialTint
54
+ );
55
+ const tintsContext = (0, import_tints.useTints)();
56
+ const { tints } = tintsContext;
57
+ return {
58
+ ...tintsContext,
59
+ tints: tintsContext.tints,
60
+ tintIndex: index,
61
+ tint: tints[index],
62
+ setTintIndex,
63
+ setNextTintFamily: import_tints.setNextTintFamily,
64
+ setNextTint: () => {
65
+ setTintIndex(index + 1);
66
+ }
67
+ };
68
+ };
69
+ const ThemeTint = (props) => {
70
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.Theme, {
71
+ name: useTint().tint,
72
+ children: (0, import_react.useMemo)(() => props.children, [props.children])
73
+ });
74
+ };
75
+ // Annotate the CommonJS export names for ESM import in node:
76
+ 0 && (module.exports = {
77
+ ThemeTint,
78
+ initialTint,
79
+ onTintChange,
80
+ setTintIndex,
81
+ useTint
82
+ });
83
+ //# sourceMappingURL=useTint.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/useTint.tsx"],
4
+ "sourcesContent": ["import { useMemo, useSyncExternalStore } from 'react'\nimport { Theme, ThemeName } from 'tamagui'\n\nimport { getTints, setNextTintFamily, useTints } from './tints'\n\n// TODO useSyncExternalStore\n\n// no localstorage because its not important to remember and causes a flicker\n// const tintVal = typeof localStorage !== 'undefined' ? localStorage.getItem('tint') : 0\n// const tint = tintVal ? +tintVal 0\nexport const initialTint = 3\n\nlet current = initialTint\n\nconst listeners = new Set<Function>()\n\nexport const onTintChange = (listener: (cur: number) => void) => {\n listeners.add(listener)\n return () => {\n listeners.delete(listener)\n }\n}\n\nconst numTints = getTints().tints.length\n\nexport const setTintIndex = (next: number) => {\n const val = next % numTints\n if (val === current) return\n current = val\n listeners.forEach((x) => x(val))\n}\n\nexport const useTint = () => {\n const index = useSyncExternalStore(\n onTintChange,\n () => current,\n () => initialTint\n )\n const tintsContext = useTints()\n const { tints } = tintsContext\n\n return {\n ...tintsContext,\n tints: tintsContext.tints as ThemeName[],\n tintIndex: index,\n tint: tints[index] as ThemeName,\n setTintIndex,\n setNextTintFamily,\n setNextTint: () => {\n setTintIndex(index + 1)\n },\n } as const\n}\n\nexport const ThemeTint = (props: { children: any }) => {\n return (\n <Theme name={useTint().tint}>\n {/* */}\n {useMemo(() => props.children, [props.children])}\n </Theme>\n )\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAwDI;AAxDJ,mBAA8C;AAC9C,qBAAiC;AAEjC,mBAAsD;AAO/C,MAAM,cAAc;AAE3B,IAAI,UAAU;AAEd,MAAM,YAAY,oBAAI,IAAc;AAE7B,MAAM,eAAe,CAAC,aAAoC;AAC/D,YAAU,IAAI,QAAQ;AACtB,SAAO,MAAM;AACX,cAAU,OAAO,QAAQ;AAAA,EAC3B;AACF;AAEA,MAAM,eAAW,uBAAS,EAAE,MAAM;AAE3B,MAAM,eAAe,CAAC,SAAiB;AAC5C,QAAM,MAAM,OAAO;AACnB,MAAI,QAAQ;AAAS;AACrB,YAAU;AACV,YAAU,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC;AACjC;AAEO,MAAM,UAAU,MAAM;AAC3B,QAAM,YAAQ;AAAA,IACZ;AAAA,IACA,MAAM;AAAA,IACN,MAAM;AAAA,EACR;AACA,QAAM,mBAAe,uBAAS;AAC9B,QAAM,EAAE,MAAM,IAAI;AAElB,SAAO;AAAA,IACL,GAAG;AAAA,IACH,OAAO,aAAa;AAAA,IACpB,WAAW;AAAA,IACX,MAAM,MAAM;AAAA,IACZ;AAAA,IACA;AAAA,IACA,aAAa,MAAM;AACjB,mBAAa,QAAQ,CAAC;AAAA,IACxB;AAAA,EACF;AACF;AAEO,MAAM,YAAY,CAAC,UAA6B;AACrD,SACE,4CAAC;AAAA,IAAM,MAAM,QAAQ,EAAE;AAAA,IAEpB,oCAAQ,MAAM,MAAM,UAAU,CAAC,MAAM,QAAQ,CAAC;AAAA,GACjD;AAEJ;",
6
+ "names": []
7
+ }