@uniformdev/context-devtools 14.2.1-alpha.34 → 15.0.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/esm/index.js CHANGED
@@ -1,4 +1,50 @@
1
- import{jsx as t}from"@emotion/react";import*as m from"react";import{css as S}from"@emotion/react";var St=[{title:"Dimensions",href:"/dimensions",icon:`<svg
1
+ // ../../scripts/emotion-jsx-shim.js
2
+ import { jsx } from "@emotion/react";
3
+ import * as React from "react";
4
+
5
+ // src/components/Navigation/Menu.tsx
6
+ import { css } from "@emotion/react";
7
+
8
+ // src/lib/DevToolsSettingsContext.tsx
9
+ import { createContext, useContext } from "react";
10
+ var DevToolsSettingsContext = createContext({
11
+ settings: {},
12
+ saveSettings: () => null
13
+ });
14
+ var useDevToolsSettingsContext = () => useContext(DevToolsSettingsContext);
15
+ var DevToolsSettingsContextProvider = ({
16
+ children,
17
+ settings,
18
+ saveSettings
19
+ }) => {
20
+ return /* @__PURE__ */ jsx(DevToolsSettingsContext.Provider, {
21
+ value: {
22
+ settings,
23
+ saveSettings
24
+ }
25
+ }, children);
26
+ };
27
+
28
+ // src/components/Navigation/NavigationLink.tsx
29
+ var NavigationLink = ({ route, children, className }) => {
30
+ const { settings, saveSettings } = useDevToolsSettingsContext();
31
+ return /* @__PURE__ */ jsx("a", {
32
+ href: "",
33
+ className,
34
+ onClick: (e) => {
35
+ e.preventDefault();
36
+ saveSettings({ ...settings, route });
37
+ }
38
+ }, children);
39
+ };
40
+ var NavigationLink_default = NavigationLink;
41
+
42
+ // src/components/Navigation/Menu.tsx
43
+ var links = [
44
+ {
45
+ title: "Dimensions",
46
+ href: "/dimensions",
47
+ icon: `<svg
2
48
  width="24"
3
49
  height="24"
4
50
  viewBox="0 0 24 24"
@@ -15,7 +61,20 @@ import{jsx as t}from"@emotion/react";import*as m from"react";import{css as S}fro
15
61
  fill="currentColor"
16
62
  />
17
63
  </svg>
18
- `},{title:"Quirks",href:"/quirks",icon:`<svg
64
+ `
65
+ },
66
+ {
67
+ title: "What if?",
68
+ href: "/overrides",
69
+ icon: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
70
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M16.5123 7.91666L14.5804 8.4343L13.9179 5.96175L11.3371 10.0021L11.3575 10.0143C11.1348 10.3854 10.8997 10.7125 10.6556 11.0003H18.7603L16.9135 9.15347L18.3277 7.73926L22.5703 11.9819L18.3276 16.2245L16.9134 14.8103L18.7235 13.0003H6.65606C6.89995 13.2879 7.13495 13.6148 7.35749 13.9857L7.33713 13.9979L9.9179 18.0382L10.5804 15.5657L12.5123 16.0833L10.9594 21.8789L5.16384 20.326L5.68147 18.3941L8.20425 19.0701C8.20425 19.0701 6.17064 16.0325 5.21659 14.398C4.70173 13.7544 4.17055 13.4257 3.70352 13.2461C3.10532 13.016 2.54358 13.0011 2.06154 13.0003H2V13.0002V11.0003V11.0002L2.02253 11.0002C2.05059 11.0002 2.07985 11.0002 2.11025 11.0003H6V10.9998C6.49549 10.9998 7.07968 10.9939 7.70352 10.7539C8.17055 10.5743 8.70173 10.2456 9.21659 9.60198C10.1706 7.96745 12.2043 4.92988 12.2043 4.92988L9.68147 5.60586L9.16384 3.67401L14.9594 2.12109L16.5123 7.91666Z" fill="white"/>
71
+ </svg>
72
+ `
73
+ },
74
+ {
75
+ title: "Quirks",
76
+ href: "/quirks",
77
+ icon: `<svg
19
78
  width="24"
20
79
  height="24"
21
80
  viewBox="0 0 24 24"
@@ -30,53 +89,151 @@ import{jsx as t}from"@emotion/react";import*as m from"react";import{css as S}fro
30
89
  d="M12 8.5C10.067 8.5 8.5 10.067 8.5 12C8.5 13.933 10.067 15.5 12 15.5C13.933 15.5 15.5 13.933 15.5 12C15.5 10.067 13.933 8.5 12 8.5Z"
31
90
  fill="currentColor"
32
91
  />
33
- </svg>`},{title:"Settings",href:"/settings",icon:`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
92
+ </svg>`
93
+ },
94
+ {
95
+ title: "Settings",
96
+ href: "/settings",
97
+ icon: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
34
98
  <path d="M19.1469 12.716C19.1986 12.2636 19.201 11.8069 19.1539 11.354L21.7429 9.474C21.8681 9.3822 21.9548 9.24723 21.9862 9.0952C22.0176 8.94316 21.9915 8.78489 21.9129 8.651L19.9939 5.399C19.9182 5.26986 19.7985 5.17231 19.6568 5.1242C19.515 5.07608 19.3606 5.08063 19.2219 5.137L16.3599 6.292C15.9237 5.9578 15.4502 5.67525 14.9489 5.45L14.5739 2.545C14.5547 2.39441 14.4813 2.25598 14.3673 2.15566C14.2534 2.05534 14.1068 1.99999 13.9549 2H10.0859C9.93402 1.99997 9.78728 2.05527 9.67317 2.15558C9.55906 2.25588 9.48539 2.39432 9.46595 2.545L9.09395 5.433C8.63957 5.63249 8.20723 5.87882 7.80395 6.168L5.00895 4.954C4.87173 4.89484 4.71787 4.88672 4.57519 4.9311C4.4325 4.97549 4.3104 5.06945 4.23095 5.196L2.22195 8.398C2.1396 8.52998 2.10934 8.68789 2.13707 8.84096C2.1648 8.99403 2.24854 9.1313 2.37195 9.226L4.86795 11.142C4.83172 11.4266 4.81302 11.7131 4.81195 12C4.81195 12.18 4.82095 12.362 4.83795 12.558L2.26495 14.375C2.13766 14.4647 2.04844 14.5987 2.01478 14.7508C1.98112 14.9028 2.00543 15.0619 2.08295 15.197L3.95695 18.474C4.11095 18.742 4.43695 18.857 4.72595 18.746L7.56095 17.644C8.00795 17.997 8.49195 18.294 9.00795 18.53L9.33795 21.396C9.37495 21.709 9.63795 21.946 9.95195 21.95L13.8169 22H13.8249C14.1349 22 14.3989 21.771 14.4439 21.463L14.8549 18.59C15.3703 18.3674 15.8579 18.0855 16.3079 17.75L19.1279 18.93C19.4129 19.05 19.7419 18.944 19.9029 18.679L21.8669 15.452C21.9477 15.319 21.976 15.1608 21.9464 15.0081C21.9168 14.8554 21.8315 14.7192 21.7069 14.626L19.1469 12.716ZM11.9999 15C10.3459 15 8.99995 13.655 8.99995 12C8.99995 10.346 10.3449 9 11.9999 9C13.6539 9 14.9999 10.345 14.9999 12C14.9999 13.654 13.6539 15 11.9999 15Z" fill="white"/>
35
99
  </svg>
36
- `}],rt=({...e})=>{let r=o=>{if(o.preventDefault(),o.currentTarget.pathname)return e.saveSettings({...e.settings,route:o.currentTarget.pathname})},n=o=>{var i;let a="active";return!((i=e.settings)==null?void 0:i.route)&&o==="/dimensions"||e.settings.route===o?a:""};return t("nav",{css:S`
100
+ `
101
+ }
102
+ ];
103
+ var Menu = ({ ...props }) => {
104
+ const isActivePath = (href) => {
105
+ var _a;
106
+ const cssName = "active";
107
+ if (!((_a = props.settings) == null ? void 0 : _a.route) && href === "/dimensions") {
108
+ return cssName;
109
+ }
110
+ return props.settings.route === href ? cssName : "";
111
+ };
112
+ return /* @__PURE__ */ jsx("nav", {
113
+ css: css`
37
114
  background: var(--brand-secondary-1);
38
115
  padding: var(--spacing-base);
39
116
  min-width: 200px;
40
- `},t("a",{css:S`
117
+ `
118
+ }, /* @__PURE__ */ jsx(NavigationLink_default, {
119
+ css: css`
41
120
  display: inline-block;
42
121
  margin: 0 var(--spacing-base);
43
- `,href:"/settings",onClick:o=>r(o)},t("svg",{css:{display:"block"},width:"120",height:"38",viewBox:"0 0 120 38",fill:"none",xmlns:"http://www.w3.org/2000/svg"},t("g",{clipPath:"url(#clip0_41_612)"},t("path",{d:"M8.82261 3.73315L0 8.82209V18.9999L8.82261 13.911L17.6474 8.82209L8.82261 3.73315Z",fill:"#83C6E1"}),t("path",{d:"M8.82261 24.089V13.9111L0 19.0001V29.1779L8.82261 34.2669L17.6474 29.1779V19.0001L8.82261 24.089Z",fill:"#438FD5"}),t("path",{d:"M17.6474 8.82202L8.82263 13.911L17.6474 18.9999V29.1777L26.47 24.0888V13.911L17.6474 8.82202Z",fill:"#F4220B"}),t("path",{d:"M64.6069 13.9025H67.8036V25.5528H64.6069V13.9025ZM64.4902 8.5415H67.9181V11.7348H64.4902V8.5415ZM72.5153 10.1025V13.9025H70.3691V16.6272H72.5153V25.5528H75.7119V16.6272H78.2774V13.9025H75.7119V11.2684H78.2774V8.5415H75.2213L72.5153 10.1025ZM83.1059 13.7859L80.3999 15.3469V24.1084L83.1059 25.6694H88.0748L90.7808 24.1084V15.3469L88.0748 13.7859H83.1059ZM87.5842 22.9425H83.5943V16.5106H87.5842V22.9425ZM97.4723 14.8611L95.8103 13.9025H94.2779V25.5528H97.4745V16.6272H101.486V13.9025H99.1344L97.4723 14.8611ZM55.713 13.7859L53.8499 14.8611L51.9847 13.7859H50.7289V25.5528H53.9256V16.5106H57.9133V25.5528H61.1099V15.3469L58.4039 13.7859H55.713ZM44.0353 22.9425H40.0454V13.9025H36.851V24.1084L39.557 25.6694H42.3753L44.0309 24.7129L44.0331 24.7151L44.0353 24.7129V24.7151L45.6887 25.6694H47.2297V13.9025H44.0353V22.9425ZM117.51 13.7859H115.271L113.079 15.0425L110.909 13.7859H108.67L107.015 14.7402L105.359 13.7859H103.818V25.5528H107.015V16.5106H110.421V25.5528H113.615V16.5106H117.022V25.5528H120.216V15.3469L117.51 13.7859Z",fill:"white"})),t("defs",null,t("clipPath",{id:"clip0_41_612"},t("rect",{width:"120",height:"38",fill:"white"}))))),t("ul",{css:S`
122
+ `,
123
+ route: "/settings"
124
+ }, /* @__PURE__ */ jsx("svg", {
125
+ css: { display: "block" },
126
+ width: "120",
127
+ height: "38",
128
+ viewBox: "0 0 120 38",
129
+ fill: "none",
130
+ xmlns: "http://www.w3.org/2000/svg"
131
+ }, /* @__PURE__ */ jsx("g", {
132
+ clipPath: "url(#clip0_41_612)"
133
+ }, /* @__PURE__ */ jsx("path", {
134
+ d: "M8.82261 3.73315L0 8.82209V18.9999L8.82261 13.911L17.6474 8.82209L8.82261 3.73315Z",
135
+ fill: "#83C6E1"
136
+ }), /* @__PURE__ */ jsx("path", {
137
+ d: "M8.82261 24.089V13.9111L0 19.0001V29.1779L8.82261 34.2669L17.6474 29.1779V19.0001L8.82261 24.089Z",
138
+ fill: "#438FD5"
139
+ }), /* @__PURE__ */ jsx("path", {
140
+ d: "M17.6474 8.82202L8.82263 13.911L17.6474 18.9999V29.1777L26.47 24.0888V13.911L17.6474 8.82202Z",
141
+ fill: "#F4220B"
142
+ }), /* @__PURE__ */ jsx("path", {
143
+ d: "M64.6069 13.9025H67.8036V25.5528H64.6069V13.9025ZM64.4902 8.5415H67.9181V11.7348H64.4902V8.5415ZM72.5153 10.1025V13.9025H70.3691V16.6272H72.5153V25.5528H75.7119V16.6272H78.2774V13.9025H75.7119V11.2684H78.2774V8.5415H75.2213L72.5153 10.1025ZM83.1059 13.7859L80.3999 15.3469V24.1084L83.1059 25.6694H88.0748L90.7808 24.1084V15.3469L88.0748 13.7859H83.1059ZM87.5842 22.9425H83.5943V16.5106H87.5842V22.9425ZM97.4723 14.8611L95.8103 13.9025H94.2779V25.5528H97.4745V16.6272H101.486V13.9025H99.1344L97.4723 14.8611ZM55.713 13.7859L53.8499 14.8611L51.9847 13.7859H50.7289V25.5528H53.9256V16.5106H57.9133V25.5528H61.1099V15.3469L58.4039 13.7859H55.713ZM44.0353 22.9425H40.0454V13.9025H36.851V24.1084L39.557 25.6694H42.3753L44.0309 24.7129L44.0331 24.7151L44.0353 24.7129V24.7151L45.6887 25.6694H47.2297V13.9025H44.0353V22.9425ZM117.51 13.7859H115.271L113.079 15.0425L110.909 13.7859H108.67L107.015 14.7402L105.359 13.7859H103.818V25.5528H107.015V16.5106H110.421V25.5528H113.615V16.5106H117.022V25.5528H120.216V15.3469L117.51 13.7859Z",
144
+ fill: "white"
145
+ })), /* @__PURE__ */ jsx("defs", null, /* @__PURE__ */ jsx("clipPath", {
146
+ id: "clip0_41_612"
147
+ }, /* @__PURE__ */ jsx("rect", {
148
+ width: "120",
149
+ height: "38",
150
+ fill: "white"
151
+ }))))), /* @__PURE__ */ jsx("ul", {
152
+ css: css`
44
153
  display: flex;
45
154
  flex-flow: column nowrap;
46
155
  padding: 0;
47
156
  margin: 0;
48
157
  list-style-type: none;
49
158
  height: calc(100% - var(--spacing-base) * 2.5);
50
- `},St.map((o,a)=>t("li",{css:S`
51
- padding: 0;
52
- margin: 0;
53
- list-style-type: none;
54
-
55
- &:last-of-type {
56
- margin-top: auto;
57
- }
58
- `,key:a},t("a",{css:S`
59
- align-items: center;
60
- border-radius: var(--rounded-base);
61
- display: flex;
62
- color: var(--white);
63
- gap: var(--spacing-sm);
64
- padding: var(--spacing-sm) var(--spacing-base);
65
- text-decoration: none;
66
- transition: background-color 0.25s ease-in-out;
67
-
68
- &:hover,
69
- &.active {
70
- background: var(--gray-700);
159
+ `
160
+ }, links.map((item, index) => {
161
+ var _a, _b, _c, _d;
162
+ let overrideCount = 0;
163
+ if (item.href === "/overrides" && Object.keys((_a = props.settings.scoreOverrides) != null ? _a : {}).length > 0) {
164
+ overrideCount = Object.keys((_b = props.settings.scoreOverrides) != null ? _b : {}).length;
165
+ }
166
+ if (item.href === "/quirks" && Object.keys((_c = props.settings.quirkOverrides) != null ? _c : {}).length > 0) {
167
+ overrideCount = Object.keys((_d = props.settings.quirkOverrides) != null ? _d : {}).length;
168
+ }
169
+ return /* @__PURE__ */ jsx("li", {
170
+ css: css`
171
+ padding: 0;
172
+ margin: 0;
173
+ list-style-type: none;
174
+
175
+ &:last-of-type {
176
+ margin-top: auto;
71
177
  }
72
- `,className:n(o.href),href:o.href,title:o.title,onClick:i=>r(i)},t("i",{css:S`
178
+ `,
179
+ key: index
180
+ }, /* @__PURE__ */ jsx(NavigationLink_default, {
181
+ css: css`
73
182
  align-items: center;
183
+ border-radius: var(--rounded-base);
74
184
  display: flex;
75
- `,dangerouslySetInnerHTML:{__html:o.icon}}),o.title)))))};var nt=()=>t("article",null,t("h1",null,"Something when wrong"),t("p",null,"We could not find the page you're looking for."));import*as _ from"react";import{css as H}from"@emotion/react";import*as I from"react";var at=H({willChange:"height"}),Ht=H`
185
+ color: var(--white);
186
+ gap: var(--spacing-sm);
187
+ padding: var(--spacing-sm) var(--spacing-base);
188
+ text-decoration: none;
189
+ transition: background-color 0.25s ease-in-out;
190
+
191
+ &:hover,
192
+ &.active {
193
+ background: var(--gray-700);
194
+ }
195
+ `,
196
+ className: isActivePath(item.href),
197
+ route: item.href
198
+ }, /* @__PURE__ */ jsx("i", {
199
+ css: css`
200
+ align-items: center;
201
+ display: flex;
202
+ `,
203
+ dangerouslySetInnerHTML: { __html: item.icon }
204
+ }), item.title, overrideCount ? /* @__PURE__ */ jsx("span", {
205
+ css: css`
206
+ font-size: var(--font-xxs);
207
+ display: inline-block;
208
+ width: 12px;
209
+ height: 12px;
210
+ border-radius: 6px;
211
+ background-color: var(--red-tooltip);
212
+ text-align: center;
213
+ line-height: 12px;
214
+ `
215
+ }, overrideCount) : null));
216
+ })));
217
+ };
218
+
219
+ // src/components/StatusPages/NotFound.tsx
220
+ var NotFound = () => {
221
+ return /* @__PURE__ */ jsx("article", null, /* @__PURE__ */ jsx("h1", null, "Something when wrong"), /* @__PURE__ */ jsx("p", null, "We could not find the page you're looking for."));
222
+ };
223
+
224
+ // src/components/Personalization/Dimensions.tsx
225
+ import * as React4 from "react";
226
+
227
+ // src/components/Accordion/Accordion.tsx
228
+ import { css as css2 } from "@emotion/react";
229
+ import * as React2 from "react";
230
+ var willChange = css2({ willChange: "height" });
231
+ var titleStyle = css2`
76
232
  border-bottom: 2px solid var(--brand-secondary-1);
77
233
  font-size: var(--font-base);
78
234
  margin: 0;
79
- `,Vt=H`
235
+ `;
236
+ var btnStyle = css2`
80
237
  align-items: center;
81
238
  border: none;
82
239
  background: none;
@@ -86,13 +243,59 @@ import{jsx as t}from"@emotion/react";import*as m from"react";import{css as S}fro
86
243
  padding: var(--spacing-sm) 0;
87
244
  font-weight: var(--font-bold);
88
245
  justify-content: space-between;
89
- `,Pt=H`
246
+ `;
247
+ var iconStyle = css2`
90
248
  align-self: center;
91
- `,At=H`
249
+ `;
250
+ var iconActiveStyle = css2`
92
251
  transform: rotate(-180deg);
93
- `,E=({children:e})=>t("div",{css:[at]},e),B=({title:e,children:r})=>{let[n,o]=I.useState(!1),a=e.split(" ").join("-").toLocaleLowerCase();return t(I.Fragment,null,t("h3",{css:Ht},t("button",{"aria-expanded":n,css:Vt,title:e,id:a,"aria-controls":`${a}-section`,onClick:()=>o(i=>!i),type:"button"},e,t("i",{css:[Pt,n?At:void 0]},t("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},t("path",{d:"M6.34317 7.75732L4.92896 9.17154L12 16.2426L19.0711 9.17157L17.6569 7.75735L12 13.4142L6.34317 7.75732Z",fill:"currentColor"}))))),t("div",{id:`${a}-section`,css:[at,H`
252
+ `;
253
+ var Accordion = ({ children }) => {
254
+ return /* @__PURE__ */ jsx("div", {
255
+ css: [willChange]
256
+ }, children);
257
+ };
258
+ var AccordionItem = ({ title, children }) => {
259
+ const [visibility, setVisibility] = React2.useState(false);
260
+ const id = title.split(" ").join("-").toLocaleLowerCase();
261
+ return /* @__PURE__ */ jsx(React2.Fragment, null, /* @__PURE__ */ jsx("h3", {
262
+ css: titleStyle
263
+ }, /* @__PURE__ */ jsx("button", {
264
+ "aria-expanded": visibility,
265
+ css: btnStyle,
266
+ title,
267
+ id,
268
+ "aria-controls": `${id}-section`,
269
+ onClick: () => setVisibility((prev) => !prev),
270
+ type: "button"
271
+ }, title, /* @__PURE__ */ jsx("i", {
272
+ css: [iconStyle, visibility ? iconActiveStyle : void 0]
273
+ }, /* @__PURE__ */ jsx("svg", {
274
+ width: "24",
275
+ height: "24",
276
+ viewBox: "0 0 24 24",
277
+ fill: "none",
278
+ xmlns: "http://www.w3.org/2000/svg"
279
+ }, /* @__PURE__ */ jsx("path", {
280
+ d: "M6.34317 7.75732L4.92896 9.17154L12 16.2426L19.0711 9.17157L17.6569 7.75735L12 13.4142L6.34317 7.75732Z",
281
+ fill: "currentColor"
282
+ }))))), /* @__PURE__ */ jsx("div", {
283
+ id: `${id}-section`,
284
+ css: [
285
+ willChange,
286
+ css2`
94
287
  padding: var(--spacing-sm) 0;
95
- `],role:"region","aria-labelledby":a},n?r:null))};import{css as T}from"@emotion/react";import*as it from"react";var Mt=T`
288
+ `
289
+ ],
290
+ role: "region",
291
+ "aria-labelledby": id
292
+ }, visibility ? children : null));
293
+ };
294
+
295
+ // src/components/Buttons/Button.tsx
296
+ import { css as css3 } from "@emotion/react";
297
+ import * as React3 from "react";
298
+ var buttonStyle = css3`
96
299
  align-items: center;
97
300
  border: 1px solid transparent;
98
301
  cursor: pointer;
@@ -103,29 +306,55 @@ import{jsx as t}from"@emotion/react";import*as m from"react";import{css as S}fro
103
306
  &:hover {
104
307
  opacity: 0.8;
105
308
  }
106
- `;function zt(e){let r=T`
309
+ `;
310
+ function buttonVariant(variant) {
311
+ const white = css3`
107
312
  color: var(--white);
108
- `,n=T`
313
+ `;
314
+ const bold = css3`
109
315
  font-weight: var(--font-bold);
110
- `;switch(e){case"primary":return T`
316
+ `;
317
+ switch (variant) {
318
+ case "primary":
319
+ return css3`
111
320
  background: var(--brand-secondary-1);
112
- ${r}
113
- ${n}
114
- `;case"secondary":return T`
321
+ ${white}
322
+ ${bold}
323
+ `;
324
+ case "secondary":
325
+ return css3`
115
326
  background: var(--brand-secondary-5);
116
- ${r}
117
- ${n}
118
- `;case"unimportant":return T`
327
+ ${white}
328
+ ${bold}
329
+ `;
330
+ case "unimportant":
331
+ return css3`
119
332
  background: var(--brand-secondary-3);
120
333
  color: var(--brand-secondary-1);
121
- ${n}
122
- `;case"ghost":return T`
334
+ ${bold}
335
+ `;
336
+ case "ghost":
337
+ return css3`
123
338
  background: transparent;
124
339
  color: var(--brand-secondary-5);
125
340
  &:hover {
126
341
  border: 1px solid var(--brand-secondary-5);
127
342
  }
128
- `}}var k=({buttonType:e="primary",children:r,className:n,...o})=>t(it.Fragment,null,t("button",{type:"button",css:[Mt,zt(e)],className:n,...o},r));import{css as V}from"@emotion/react";var F=V`
343
+ `;
344
+ }
345
+ }
346
+ var Button = ({ buttonType = "primary", children, className, ...props }) => {
347
+ return /* @__PURE__ */ jsx(React3.Fragment, null, /* @__PURE__ */ jsx("button", {
348
+ type: "button",
349
+ css: [buttonStyle, buttonVariant(buttonType)],
350
+ className,
351
+ ...props
352
+ }, children));
353
+ };
354
+
355
+ // src/components/CallToAction/cta.styles.ts
356
+ import { css as css4 } from "@emotion/react";
357
+ var cta = css4`
129
358
  background-color: var(--gray-100);
130
359
  padding: var(--spacing-base) var(--spacing-md);
131
360
  margin: var(--spacing-base) 0;
@@ -133,21 +362,25 @@ import{jsx as t}from"@emotion/react";import*as m from"react";import{css as S}fro
133
362
  &:first-of-type {
134
363
  margin: 0 0 var(--spacing-base);
135
364
  }
136
- `,st=V`
365
+ `;
366
+ var ctaWithIcon = css4`
137
367
  background: var(--gray-100)
138
368
  url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%0A%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M9 2C8.44771 2 8 2.44772 8 3V5C8 5.55228 8.44771 6 9 6C9.55229 6 10 5.55228 10 5V3C10 2.44772 9.55229 2 9 2ZM8 9H16V11C16 13.2091 14.2091 15 12 15C9.79086 15 8 13.2091 8 11V9ZM13 16.917C15.8377 16.441 18 13.973 18 11V7H6V11C6 13.973 8.16229 16.441 11 16.917V22C11 22.5523 11.4477 23 12 23C12.5523 23 13 22.5523 13 22V16.917ZM14 3C14 2.44772 14.4477 2 15 2C15.5523 2 16 2.44772 16 3V5C16 5.55228 15.5523 6 15 6C14.4477 6 14 5.55228 14 5V3Z' fill='%232ecdb4' /%3E%3C/svg%3E")
139
369
  no-repeat var(--spacing-sm) var(--spacing-base);
140
370
  padding: var(--spacing-base) var(--spacing-xl);
141
- `,Z=V`
371
+ `;
372
+ var ctaTitle = css4`
142
373
  color: var(--brand-secondary-1);
143
374
  margin: 0;
144
375
  font-size: var(--font-base);
145
376
  font-weight: var(--font-bold);
146
- `,U=V`
377
+ `;
378
+ var ctaText = css4`
147
379
  color: var(--brand-secondary-1);
148
380
  margin: var(--spacing-xs) 0 0;
149
381
  font-size: var(--font-sm);
150
- `,ct=V`
382
+ `;
383
+ var ctaClose = css4`
151
384
  align-items: center;
152
385
  border: none;
153
386
  background: transparent
@@ -167,21 +400,43 @@ import{jsx as t}from"@emotion/react";import*as m from"react";import{css as S}fro
167
400
  &:hover {
168
401
  opacity: 0.6;
169
402
  }
170
- `,N=V`
403
+ `;
404
+ var ctaBtnGroup = css4`
171
405
  display: flex;
172
406
  margin: var(--spacing-sm) 0 0;
173
407
  gap: var(--spacing-base);
174
- `;var O=({title:e,text:r,buttonGroup:n,children:o})=>t("div",{css:F},t("h2",{css:Z},e),t("p",{css:U},r),o,n?t("div",{css:N},n):null);import{css as A}from"@emotion/react";var lt=A`
408
+ `;
409
+
410
+ // src/components/CallToAction/NoActiveDimensions.tsx
411
+ var NoActiveDimensions = ({ title, text, buttonGroup, children }) => {
412
+ return /* @__PURE__ */ jsx("div", {
413
+ css: cta
414
+ }, /* @__PURE__ */ jsx("h2", {
415
+ css: ctaTitle
416
+ }, title), /* @__PURE__ */ jsx("p", {
417
+ css: ctaText
418
+ }, text), children, buttonGroup ? /* @__PURE__ */ jsx("div", {
419
+ css: ctaBtnGroup
420
+ }, buttonGroup) : null);
421
+ };
422
+
423
+ // src/components/Inputs/input-switch.styles.ts
424
+ import { css as css5 } from "@emotion/react";
425
+ var inputSwitch = css5`
175
426
  align-items: center;
176
427
  cursor: pointer;
177
428
  display: flex;
178
429
  gap: var(--spacing-xs);
179
- `,pt=A`
430
+ margin-top: var(--spacing-base);
431
+ `;
432
+ var inputSwitchLabel = css5`
180
433
  color: var(--gray-500);
181
434
  font-size: var(--font-sm);
182
- `,ge=A`
435
+ `;
436
+ var inputSwitchControl = css5`
183
437
  background: var(--gray-600);
184
- `,dt=A`
438
+ `;
439
+ var inputSwitchBtn = css5`
185
440
  display: block;
186
441
  background: var(--gray-400);
187
442
  border-radius: var(--rounded-full);
@@ -202,7 +457,8 @@ import{jsx as t}from"@emotion/react";import*as m from"react";import{css as S}fro
202
457
  transform: translateX(2px);
203
458
  transition: transform 0.2s ease-in-out, background-color 0.3s ease-in-out;
204
459
  }
205
- `,mt=A`
460
+ `;
461
+ var inputSwitchCheckbox = css5`
206
462
  overflow: hidden;
207
463
  clip: rect(0, 0, 0, 0);
208
464
  height: 0;
@@ -216,49 +472,60 @@ import{jsx as t}from"@emotion/react";import*as m from"react";import{css as S}fro
216
472
  &:checked ~ span {
217
473
  background: var(--brand-secondary-5);
218
474
  }
219
- `;var ut=({label:e,...r})=>t("label",{css:lt},t("span",{css:pt},e),t("input",{type:"checkbox",css:mt,...r}),t("span",{css:dt}));import{css as y}from"@emotion/react";var M=({children:e})=>t("table",{css:y`
220
- border-collapse: collapse;
221
- display: table;
222
- width: 100%;
223
- font-size: var(--font-sm);
224
- `},e),gt=({children:e})=>t("thead",{css:y`
225
- background: var(--gray-50);
226
- text-align: left;
227
- & tr {
228
- border-bottom: 1px solid var(--gray-200);
229
- }
230
- `},e),z=({children:e})=>t("tbody",null,e),P=({border:e,children:r})=>t("tr",{css:e?y`
231
- border-bottom: 1px solid var(--gray-200);
232
- &:where(:last-child) {
233
- border: none;
234
- }
235
- `:void 0},r),J=({children:e})=>t("th",{css:y`
236
- outline: none;
237
- padding: var(--spacing-sm);
238
- `},e);function It(e){switch(e){case"light":return y`
239
- color: var(--gray-400);
240
- `;case"dark":return y`
241
- color: var(--brand-secondary-1);
242
- `}}function Et(e){return y`
243
- text-align: ${e};
244
- `}var w=({alignment:e="left",border:r,color:n="dark",children:o})=>t("td",{css:[y`
245
- padding: var(--spacing-base);
246
- max-width: 180px;
247
- overflow-wrap: break-word;
248
- position: relative;
249
- `,It(n),Et(e),r?y`
250
- border-left: 1px solid var(--gray-200);
251
- `:void 0]},o);import{css as x,keyframes as Bt}from"@emotion/react";var Ft=Bt`from {
475
+ `;
476
+
477
+ // src/components/Inputs/SwitchInput.tsx
478
+ var SwitchInput = ({ label, ...props }) => {
479
+ return /* @__PURE__ */ jsx("label", {
480
+ css: inputSwitch
481
+ }, /* @__PURE__ */ jsx("span", {
482
+ css: inputSwitchLabel
483
+ }, label), /* @__PURE__ */ jsx("input", {
484
+ type: "checkbox",
485
+ css: inputSwitchCheckbox,
486
+ ...props
487
+ }), /* @__PURE__ */ jsx("span", {
488
+ css: inputSwitchBtn
489
+ }));
490
+ };
491
+ var FormikSwitchInput = ({ field, form, meta, ...rawProps }) => {
492
+ const { label } = rawProps;
493
+ return /* @__PURE__ */ jsx("label", {
494
+ css: inputSwitch
495
+ }, /* @__PURE__ */ jsx("span", {
496
+ css: inputSwitchLabel
497
+ }, label), /* @__PURE__ */ jsx("input", {
498
+ type: "checkbox",
499
+ css: inputSwitchCheckbox,
500
+ checked: field.value,
501
+ ...field
502
+ }), /* @__PURE__ */ jsx("span", {
503
+ css: inputSwitchBtn
504
+ }));
505
+ };
506
+
507
+ // src/components/Personalization/page.styles.ts
508
+ import { css as css6, keyframes } from "@emotion/react";
509
+ var popIn = keyframes`from {
252
510
  transform: scale(1);
253
511
  }
254
512
  to {
255
513
  transform: scale(1.2);
256
514
  }
257
- `,g={page:x`
515
+ `;
516
+ var styles = {
517
+ page: css6`
258
518
  color: var(--brand-secondary-1);
259
- `,text:x`
519
+ `,
520
+ text: css6`
260
521
  margin: var(--spacing-sm) 0;
261
- `,title:x`
522
+ `,
523
+ reset: css6`
524
+ margin: 0 var(--spacing-md);
525
+ font-size: var(--font-sm);
526
+ color: var(--gray-500);
527
+ `,
528
+ title: css6`
262
529
  margin: 0 0 var(--spacing-sm);
263
530
  font-size: var(--font-md);
264
531
  & > small {
@@ -267,11 +534,14 @@ to {
267
534
  font-weight: var(--font-regular);
268
535
  margin: var(--spacing-xxs) 0 0;
269
536
  }
270
- `,headingGroup:x`
537
+ `,
538
+ headingGroup: css6`
271
539
  align-items: baseline;
272
540
  display: flex;
273
541
  justify-content: space-between;
274
- `,divider:x`
542
+ align-items: center;
543
+ `,
544
+ divider: css6`
275
545
  background: var(--gray-300);
276
546
  display: block;
277
547
  width: 1px;
@@ -279,15 +549,449 @@ to {
279
549
  position: absolute;
280
550
  inset: 0 auto 0 0;
281
551
  margin: auto 0;
282
- `,submitButton:x`
552
+ `,
553
+ submitButton: css6`
283
554
  position: absolute;
284
555
  right: var(--spacing-base);
285
556
  bottom: var(--spacing-base);
286
- animation: 0.5s 2 alternate ${Ft};
287
- `,error:x`
557
+ animation: 0.5s 2 alternate ${popIn};
558
+ `,
559
+ cancelButton: css6`
560
+ position: absolute;
561
+ left: calc(200px + var(--spacing-base));
562
+ bottom: var(--spacing-base);
563
+ background: white;
564
+ padding: var(--spacing-sm);
565
+ border: 1px solid var(--gray-300);
566
+ `,
567
+ error: css6`
288
568
  color: var(--brand-secondary-5);
289
569
  font-size: var(--font-sm);
290
- `};var ft=({dimensionIndex:{index:e},state:{scores:r,data:n},actions:o})=>{let a=_.useMemo(()=>Object.keys(e).filter(l=>!r[l]).map(l=>{var p;return(p=e[l])!=null?p:{name:l,dim:l,type:"Unknown"}}),[r,e]),i=Object.keys(r).length,u=i+a.length,b=()=>{o.rawUpdate([{type:"setcontrol",data:!n.controlGroup}])};return t(_.Fragment,null,t("article",{css:g.page},t("div",{css:g.headingGroup},t("h2",{css:g.title},"Dimensions",t("small",null,i," active of ",u)),t(ut,{label:"Control Group",onChange:b,checked:n.controlGroup})),i>0?t(M,null,t(z,null,Object.entries(r).map(([l,p],d)=>{var C;let{name:h,type:v,category:f}=(C=e==null?void 0:e[l])!=null?C:{name:l,dim:l,type:"Unknown"};return t(P,{key:d},t(w,null,t("b",null,p)),t(w,null,t("span",{css:g.divider,role:"presentation"}),t("strong",null,f?`${f}:`:""," ",h)),t(w,{alignment:"right",color:"light"},v))}))):t(O,{title:n.controlGroup?"In control group":"No active dimensions",text:n.controlGroup?"You are part of the personalization control group. While in the control group you do not have dimension scores and will not see personalized content. A/B tests will still run.":"You do not have score in any dimensions yet.",buttonGroup:n.controlGroup?t(k,{buttonType:"secondary",onClick:b},"Exit control group"):null}),t(E,null,t(B,{title:"Inactive Dimensions"},t(M,null,t(z,null,a.map(({dim:l,type:p,name:d,category:h})=>t(P,{key:l},t(w,null,t("strong",null,h?`${h}:`:""," ",d)),t(w,{alignment:"right",color:"light"},p)))))))))};var bt=({...e})=>{let{state:{data:r}}=e;return t(m.Fragment,null,t("article",{css:g.page},t("h1",{css:g.title},"Quirks"),t("p",{css:g.text},"Keys defined in Uniform and their current, programmatically defined values for this visit."),Object.keys(r.quirks).length?t(M,null,t(gt,null,t(P,null,t(J,null,"Key"),t(J,null,"Value"))),t(z,null,Object.entries(r.quirks).map(([n,o],a)=>t(P,{key:a,border:"bottom"},t(w,null,t("strong",null,n)),t(w,null,o))))):t(O,{title:"No quirks configured",text:"There are currently no quirks setup."})))};import{Field as X,Form as _t,Formik as Gt}from"formik";import{ErrorMessage as Zt}from"formik";import{css as D}from"@emotion/react";var ht=D`
570
+ `
571
+ };
572
+
573
+ // src/components/Table/Table.tsx
574
+ import { css as css7 } from "@emotion/react";
575
+ var Table = ({ children }) => {
576
+ return /* @__PURE__ */ jsx("table", {
577
+ css: css7`
578
+ border-collapse: collapse;
579
+ display: table;
580
+ width: 100%;
581
+ font-size: var(--font-sm);
582
+ `
583
+ }, children);
584
+ };
585
+ var THead = ({ children }) => {
586
+ return /* @__PURE__ */ jsx("thead", {
587
+ css: css7`
588
+ background: var(--gray-50);
589
+ text-align: left;
590
+ & tr {
591
+ border-bottom: 1px solid var(--gray-200);
592
+ }
593
+ `
594
+ }, children);
595
+ };
596
+ var TBody = ({ children }) => {
597
+ return /* @__PURE__ */ jsx("tbody", null, children);
598
+ };
599
+ var TRow = ({ border, children }) => {
600
+ return /* @__PURE__ */ jsx("tr", {
601
+ css: border ? css7`
602
+ border-bottom: 1px solid var(--gray-200);
603
+ &:where(:last-child) {
604
+ border: none;
605
+ }
606
+ ` : void 0
607
+ }, children);
608
+ };
609
+ var THeading = ({ children }) => {
610
+ return /* @__PURE__ */ jsx("th", {
611
+ css: css7`
612
+ outline: none;
613
+ padding: var(--spacing-sm);
614
+ `
615
+ }, children);
616
+ };
617
+ function colour(color) {
618
+ switch (color) {
619
+ case "light":
620
+ return css7`
621
+ color: var(--gray-400);
622
+ `;
623
+ case "dark":
624
+ return css7`
625
+ color: var(--brand-secondary-1);
626
+ `;
627
+ }
628
+ }
629
+ function align(alignment) {
630
+ return css7`
631
+ text-align: ${alignment};
632
+ `;
633
+ }
634
+ var TData = ({ alignment = "left", border, color = "dark", children }) => {
635
+ return /* @__PURE__ */ jsx("td", {
636
+ css: [
637
+ css7`
638
+ padding: var(--spacing-base);
639
+ max-width: 180px;
640
+ overflow-wrap: break-word;
641
+ position: relative;
642
+ `,
643
+ colour(color),
644
+ align(alignment),
645
+ border ? css7`
646
+ border-left: 1px solid var(--gray-200);
647
+ ` : void 0
648
+ ]
649
+ }, children);
650
+ };
651
+
652
+ // src/components/Table/table.styles.ts
653
+ import { css as css8 } from "@emotion/react";
654
+ var scoreTd = css8`
655
+ position: relative;
656
+ display: inline-block;
657
+ font-size: var(--font-base);
658
+ `;
659
+ var overriddenValue = css8`
660
+ display: block;
661
+ `;
662
+ var isOverriddenTooltip = css8`
663
+ position: absolute;
664
+ width: 6px;
665
+ height: 6px;
666
+ right: -10px;
667
+ top: 9px;
668
+ background: var(--red-tooltip);
669
+ border-radius: 3px;
670
+ `;
671
+
672
+ // src/styles/icons.tsx
673
+ import { css as css9 } from "@emotion/react";
674
+ var audienceIcon = `<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
675
+ <path d="M4.2 7.2C4.53137 7.2 4.8 6.93137 4.8 6.6C4.8 6.26863 4.53137 6 4.2 6C3.86863 6 3.6 6.26863 3.6 6.6C3.6 6.93137 3.86863 7.2 4.2 7.2Z" fill="#828282"/>
676
+ <path d="M8.4 6.6C8.4 6.93137 8.13137 7.2 7.8 7.2C7.46863 7.2 7.2 6.93137 7.2 6.6C7.2 6.26863 7.46863 6 7.8 6C8.13137 6 8.4 6.26863 8.4 6.6Z" fill="#828282"/>
677
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M6 12C9.31371 12 12 9.31371 12 6C12 2.68629 9.31371 0 6 0C2.68629 0 0 2.68629 0 6C0 9.31371 2.68629 12 6 12ZM6 10.8C8.65097 10.8 10.8 8.65097 10.8 6C10.8 5.49824 10.723 5.01447 10.5802 4.55984C10.0795 4.69533 9.55274 4.76763 9.00913 4.76763C6.77526 4.76763 4.82652 3.54683 3.79366 1.73601C2.25282 2.53492 1.2 4.14451 1.2 6C1.2 8.65097 3.34903 10.8 6 10.8Z" fill="#828282"/>
678
+ </svg>`;
679
+ var enrichmentIcon = `<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
680
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M3.59995 5.05775C4.9254 5.05775 5.99992 3.98325 5.99992 2.65778C5.99992 1.33232 4.9254 0.257812 3.59995 0.257812C2.27448 0.257812 1.19998 1.33232 1.19998 2.65778C1.19998 3.98325 2.27448 5.05775 3.59995 5.05775ZM3.59999 3.85777C4.26272 3.85777 4.79997 3.32052 4.79997 2.65778C4.79997 1.99505 4.26272 1.4578 3.59999 1.4578C2.93725 1.4578 2.4 1.99505 2.4 2.65778C2.4 3.32052 2.93725 3.85777 3.59999 3.85777Z" fill="#828282"/>
681
+ <path d="M5.39993 6.8577C5.73131 6.8577 5.99993 7.12632 5.99993 7.45769V11.0576H7.19991V7.45769C7.19991 6.46356 6.39406 5.65771 5.39993 5.65771H1.79998C0.80588 5.65771 0 6.46356 0 7.45769V11.0576H1.19999V7.45769C1.19999 7.12632 1.46861 6.8577 1.79998 6.8577H5.39993Z" fill="#828282"/>
682
+ <path d="M11.9999 5.05762H8.3999V6.2576H11.9999V5.05762Z" fill="#828282"/>
683
+ <path d="M8.3999 7.45752H11.9999V8.6575H8.3999V7.45752Z" fill="#828282"/>
684
+ <path d="M11.9999 2.65771H8.3999V3.8577H11.9999V2.65771Z" fill="#828282"/>
685
+ </svg>`;
686
+ var signalIcon = `<svg width="15" height="11" viewBox="0 0 15 11" fill="none" xmlns="http://www.w3.org/2000/svg">
687
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M7.113 3.12646C8.16729 3.12646 9.02195 3.98113 9.02195 5.03541C9.02195 5.86658 8.49075 6.57368 7.74932 6.83573V10.1259H6.47669V6.83573C5.73526 6.57368 5.20405 5.86658 5.20405 5.03541C5.20405 3.98113 6.05872 3.12646 7.113 3.12646ZM7.113 4.39909C7.46443 4.39909 7.74932 4.68398 7.74932 5.03541C7.74932 5.38684 7.46443 5.67172 7.113 5.67172C6.76158 5.67172 6.47669 5.38684 6.47669 5.03541C6.47669 4.68398 6.76158 4.39909 7.113 4.39909Z" fill="#828282"/>
688
+ <path d="M3.96336 1.88578C3.15733 2.69183 2.65879 3.80537 2.65879 5.03535C2.65879 6.42093 3.29145 7.65875 4.28366 8.47569L5.1895 7.56984C4.42501 6.98876 3.93142 6.06969 3.93142 5.03535C3.93142 4.1568 4.28752 3.36142 4.86325 2.78567L3.96336 1.88578Z" fill="#828282"/>
689
+ <path d="M9.36269 2.7856C9.93846 3.36136 10.2946 4.15676 10.2946 5.03535C10.2946 6.06973 9.80096 6.98882 9.03643 7.5699L9.94228 8.47575C10.9345 7.65881 11.5672 6.42096 11.5672 5.03535C11.5672 3.80533 11.0687 2.69177 10.2626 1.88571L9.36269 2.7856Z" fill="#828282"/>
690
+ <path d="M0.113525 5.03534C0.113525 3.10251 0.896953 1.35266 2.16359 0.0860049L3.06347 0.985892C2.02714 2.02224 1.38616 3.45394 1.38616 5.03534C1.38616 6.61674 2.02714 8.04844 3.06347 9.08479L2.16358 9.98468C0.89695 8.71802 0.113525 6.96817 0.113525 5.03534Z" fill="#828282"/>
691
+ <path d="M12.0624 9.98474C13.329 8.71809 14.1125 6.96821 14.1125 5.03534C14.1125 3.10248 13.329 1.3526 12.0624 0.0859375L11.1625 0.985824C12.1988 2.02218 12.8398 3.4539 12.8398 5.03534C12.8398 6.61678 12.1988 8.0485 11.1625 9.08486L12.0624 9.98474Z" fill="#828282"/>
692
+ </svg>`;
693
+ var Icon = ({ type }) => {
694
+ let iconHtml = "";
695
+ switch (type) {
696
+ case "Audience":
697
+ iconHtml = audienceIcon;
698
+ break;
699
+ case "Signal":
700
+ iconHtml = signalIcon;
701
+ break;
702
+ case "Intent":
703
+ iconHtml = signalIcon;
704
+ break;
705
+ case "Enrichment":
706
+ iconHtml = enrichmentIcon;
707
+ break;
708
+ }
709
+ return /* @__PURE__ */ jsx("i", {
710
+ css: css9`
711
+ align-items: center;
712
+ display: inline-block;
713
+ `,
714
+ dangerouslySetInnerHTML: { __html: iconHtml }
715
+ });
716
+ };
717
+
718
+ // src/components/Table/DimensionsTable.tsx
719
+ var DimensionsTable = ({
720
+ dimensionIndex,
721
+ dimensions,
722
+ disableEditOverride,
723
+ onClick,
724
+ preemptiveOverrides
725
+ }) => {
726
+ var _a;
727
+ const { settings } = useDevToolsSettingsContext();
728
+ const overrides = (_a = preemptiveOverrides != null ? preemptiveOverrides : settings.scoreOverrides) != null ? _a : {};
729
+ return /* @__PURE__ */ jsx(Table, null, /* @__PURE__ */ jsx(TBody, null, Object.entries(dimensions).sort(([a], [b]) => a.localeCompare(b)).map(([key, value]) => {
730
+ var _a2;
731
+ const { dim, name, type, category } = (_a2 = dimensionIndex[key]) != null ? _a2 : {
732
+ name: key,
733
+ dim: key,
734
+ type: void 0,
735
+ category: void 0
736
+ };
737
+ const override = overrides[dim];
738
+ return /* @__PURE__ */ jsx(TRow, {
739
+ key: dim
740
+ }, /* @__PURE__ */ jsx(TData, null, override !== void 0 ? /* @__PURE__ */ jsx("s", {
741
+ css: overriddenValue
742
+ }, override.initial) : null, /* @__PURE__ */ jsx("b", {
743
+ css: scoreTd
744
+ }, value, override !== void 0 && /* @__PURE__ */ jsx("i", {
745
+ css: isOverriddenTooltip
746
+ }))), /* @__PURE__ */ jsx(TData, null, /* @__PURE__ */ jsx("div", {
747
+ onClick: () => onClick == null ? void 0 : onClick(dim),
748
+ css: onClick ? { cursor: "pointer" } : void 0
749
+ }, /* @__PURE__ */ jsx("span", {
750
+ css: styles.divider,
751
+ role: "presentation"
752
+ }), /* @__PURE__ */ jsx("div", null, /* @__PURE__ */ jsx(Icon, {
753
+ type
754
+ }), " ", type), /* @__PURE__ */ jsx("strong", null, category ? `${category}:` : "", " ", name))), /* @__PURE__ */ jsx(TData, {
755
+ alignment: "right",
756
+ color: "light"
757
+ }, override !== void 0 && !disableEditOverride ? /* @__PURE__ */ jsx(NavigationLink_default, {
758
+ route: `/overrides/${dim}`
759
+ }, "Edit override") : null));
760
+ })));
761
+ };
762
+ var DimensionsTable_default = DimensionsTable;
763
+
764
+ // src/components/Buttons/LinkButton.tsx
765
+ import { css as css10 } from "@emotion/react";
766
+ var btnStyle2 = css10`
767
+ background: none;
768
+ border: none;
769
+ color: var(--brand-secondary-3);
770
+ cursor: pointer;
771
+ padding: 0;
772
+ font-weight: var(--font-bold);
773
+ margin-left: auto;
774
+ font-size: var(--font-sm);
775
+ `;
776
+ var LinkButton = ({ children, ...props }) => {
777
+ return /* @__PURE__ */ jsx("button", {
778
+ type: "button",
779
+ css: btnStyle2,
780
+ ...props
781
+ }, children);
782
+ };
783
+
784
+ // src/lib/deleteOverride.ts
785
+ async function deleteScoreOverrides({
786
+ actions,
787
+ saveSettings,
788
+ scores,
789
+ settings
790
+ }) {
791
+ var _a, _b;
792
+ const scoreOverrides = (_a = settings.scoreOverrides) != null ? _a : {};
793
+ const newOverrides = { ...scoreOverrides };
794
+ const commands = [];
795
+ for (const dim of Object.keys(scoreOverrides)) {
796
+ const override = scoreOverrides == null ? void 0 : scoreOverrides[dim];
797
+ delete newOverrides[dim];
798
+ commands.push({
799
+ type: "modscoreS",
800
+ data: { dimension: dim, delta: override.initial - ((_b = scores[dim]) != null ? _b : 0) }
801
+ });
802
+ }
803
+ await saveSettings({
804
+ ...settings,
805
+ scoreOverrides: newOverrides
806
+ });
807
+ await actions.rawUpdate(commands);
808
+ }
809
+ async function deleteQuirkOverride({
810
+ quirk: dim,
811
+ settings,
812
+ saveSettings,
813
+ actions
814
+ }) {
815
+ var _a;
816
+ const override = (_a = settings.quirkOverrides) == null ? void 0 : _a[dim];
817
+ if (!override) {
818
+ return;
819
+ }
820
+ const newOverrides = { ...settings.quirkOverrides };
821
+ delete newOverrides[dim];
822
+ await saveSettings({
823
+ ...settings,
824
+ quirkOverrides: newOverrides
825
+ });
826
+ await actions.rawUpdate([{ type: "setquirk", data: { key: dim, value: override.initial } }]);
827
+ }
828
+
829
+ // src/components/Personalization/Dimensions.tsx
830
+ var Dimensions = ({
831
+ dimensionIndex: { index: dimensionIndex },
832
+ state: { scores, data },
833
+ actions,
834
+ saveSettings,
835
+ settings
836
+ }) => {
837
+ const remainingDimensions = React4.useMemo(() => {
838
+ const newRemainingDimensions = {};
839
+ Object.keys(dimensionIndex).filter((dimension) => !scores[dimension]).map((key) => {
840
+ newRemainingDimensions[dimensionIndex[key].dim] = 0;
841
+ });
842
+ return newRemainingDimensions;
843
+ }, [scores, dimensionIndex]);
844
+ const activeDims = Object.keys(scores).length;
845
+ const totalDims = activeDims + Object.keys(remainingDimensions).length;
846
+ const toggleControlGroup = () => {
847
+ actions.rawUpdate([{ type: "setcontrol", data: !data.controlGroup }]);
848
+ };
849
+ return /* @__PURE__ */ jsx(React4.Fragment, null, /* @__PURE__ */ jsx("article", {
850
+ css: styles.page
851
+ }, /* @__PURE__ */ jsx("div", {
852
+ css: styles.headingGroup
853
+ }, /* @__PURE__ */ jsx("h2", {
854
+ css: styles.title
855
+ }, "Dimensions", /* @__PURE__ */ jsx("small", null, activeDims, " active of ", totalDims)), /* @__PURE__ */ jsx("div", {
856
+ css: styles.reset
857
+ }, /* @__PURE__ */ jsx(LinkButton, {
858
+ onClick: () => deleteScoreOverrides({ actions, saveSettings, scores, settings }).then(actions.forget)
859
+ }, "clear all dimensions")), /* @__PURE__ */ jsx(SwitchInput, {
860
+ label: "Control Group",
861
+ onChange: toggleControlGroup,
862
+ checked: data.controlGroup
863
+ })), activeDims > 0 ? /* @__PURE__ */ jsx(DimensionsTable_default, {
864
+ dimensionIndex,
865
+ dimensions: scores
866
+ }) : /* @__PURE__ */ jsx(NoActiveDimensions, {
867
+ title: data.controlGroup ? "In control group" : "No active dimensions",
868
+ text: data.controlGroup ? "You are part of the personalization control group. While in the control group you do not have dimension scores and will not see personalized content. A/B tests will still run." : "You do not have score in any dimensions yet.",
869
+ buttonGroup: data.controlGroup ? /* @__PURE__ */ jsx(Button, {
870
+ buttonType: "secondary",
871
+ onClick: toggleControlGroup
872
+ }, "Exit control group") : null
873
+ }), /* @__PURE__ */ jsx(Accordion, null, /* @__PURE__ */ jsx(AccordionItem, {
874
+ title: `Inactive Dimensions (${Object.keys(remainingDimensions).length})`
875
+ }, /* @__PURE__ */ jsx(DimensionsTable_default, {
876
+ dimensionIndex,
877
+ dimensions: remainingDimensions
878
+ })))));
879
+ };
880
+
881
+ // src/components/Personalization/Overrides.tsx
882
+ import * as React5 from "react";
883
+
884
+ // src/components/CallToAction/AddButton.tsx
885
+ import { css as css11 } from "@emotion/react";
886
+ function AddButton({
887
+ onClick
888
+ }) {
889
+ return /* @__PURE__ */ jsx("button", {
890
+ css: css11`
891
+ width: 3.5rem;
892
+ height: 3.5rem;
893
+ display: flex;
894
+ align-items: center;
895
+ border-radius: 9999px;
896
+ border: none;
897
+ cursor: pointer;
898
+ background-color: var(--red-button);
899
+
900
+ svg {
901
+ color: var(--red-button);
902
+ }
903
+ `,
904
+ onClick,
905
+ "aria-label": "Add new override",
906
+ className: "text-secondary shadow-xl rounded-full flex items-center bg-secondary",
907
+ "data-test-id": "add-new-overrides-button"
908
+ }, /* @__PURE__ */ jsx("svg", {
909
+ xmlns: "http://www.w3.org/2000/svg",
910
+ width: "66",
911
+ height: "66",
912
+ viewBox: "0 0 66 66"
913
+ }, /* @__PURE__ */ jsx("g", {
914
+ fill: "none",
915
+ fillRule: "evenodd"
916
+ }, /* @__PURE__ */ jsx("circle", {
917
+ cx: "33",
918
+ cy: "33",
919
+ r: "33",
920
+ fill: "currentColor"
921
+ }), /* @__PURE__ */ jsx("g", {
922
+ fill: "#FFF",
923
+ transform: "translate(19 19)"
924
+ }, /* @__PURE__ */ jsx("rect", {
925
+ width: "4",
926
+ height: "28",
927
+ x: "12",
928
+ rx: "2"
929
+ }), /* @__PURE__ */ jsx("path", {
930
+ d: "M14,0 C15.1045695,-2.02906125e-16 16,0.8954305 16,2 L16,26 C16,27.1045695 15.1045695,28 14,28 C12.8954305,28 12,27.1045695 12,26 L12,2 C12,0.8954305 12.8954305,2.02906125e-16 14,0 Z",
931
+ transform: "rotate(90 14 14)"
932
+ })))));
933
+ }
934
+
935
+ // src/components/Personalization/Overrides.tsx
936
+ var Overrides = ({
937
+ dimensionIndex: { index: dimensionIndex },
938
+ state: { data, scores },
939
+ actions,
940
+ settings,
941
+ saveSettings
942
+ }) => {
943
+ var _a;
944
+ const overrides = (_a = settings.scoreOverrides) != null ? _a : {};
945
+ const totalOverrides = Object.keys(overrides).length;
946
+ const addNewOverride = (e) => {
947
+ e.preventDefault();
948
+ return saveSettings({ ...settings, route: "/overrides/add" });
949
+ };
950
+ const toggleControlGroup = () => {
951
+ actions.rawUpdate([{ type: "setcontrol", data: !data.controlGroup }]);
952
+ };
953
+ const scoresAffectedByOverrides = {};
954
+ Object.entries(scores).map(([key, value]) => {
955
+ if (overrides[key] !== void 0) {
956
+ scoresAffectedByOverrides[key] = value;
957
+ }
958
+ });
959
+ return /* @__PURE__ */ jsx(React5.Fragment, null, /* @__PURE__ */ jsx("article", {
960
+ css: styles.page
961
+ }, /* @__PURE__ */ jsx("div", {
962
+ css: styles.headingGroup
963
+ }, /* @__PURE__ */ jsx("h2", {
964
+ css: styles.title
965
+ }, "What if?"), /* @__PURE__ */ jsx("div", {
966
+ css: styles.reset
967
+ }, /* @__PURE__ */ jsx(LinkButton, {
968
+ onClick: () => deleteScoreOverrides({ actions, settings, saveSettings, scores })
969
+ }, "delete all overrides")), /* @__PURE__ */ jsx(AddButton, {
970
+ onClick: addNewOverride
971
+ })), /* @__PURE__ */ jsx("p", null, "Override dimension scores to test personalization"), totalOverrides > 0 ? /* @__PURE__ */ jsx(DimensionsTable_default, {
972
+ dimensionIndex,
973
+ dimensions: scoresAffectedByOverrides,
974
+ onClick: (dim) => saveSettings({ ...settings, route: `/overrides/${dim}` })
975
+ }) : /* @__PURE__ */ jsx(NoActiveDimensions, {
976
+ title: data.controlGroup ? "In control group" : "No overrides",
977
+ text: data.controlGroup ? "You are part of the personalization control group. While in the control group you do not have dimension scores and will not see personalized content. A/B tests will still run." : "You do not have any dimension overrides yet.",
978
+ buttonGroup: data.controlGroup ? /* @__PURE__ */ jsx(Button, {
979
+ buttonType: "secondary",
980
+ onClick: toggleControlGroup
981
+ }, "Exit control group") : null
982
+ })));
983
+ };
984
+
985
+ // src/components/Personalization/AddOverride.tsx
986
+ import { Field as Field2, Form, Formik } from "formik";
987
+ import * as yup from "yup";
988
+
989
+ // src/components/Inputs/SelectInput.tsx
990
+ import { ErrorMessage } from "formik";
991
+
992
+ // src/components/Inputs/inputs.styles.ts
993
+ import { css as css12 } from "@emotion/react";
994
+ var textInput = css12`
291
995
  background: var(--white);
292
996
  border: 1px solid var(--gray-500);
293
997
  border-radius: var(--rounded-base);
@@ -298,9 +1002,12 @@ to {
298
1002
  cursor: not-allowed;
299
1003
  color: var(--gray-200);
300
1004
  }
301
- `,vt=D`
1005
+ `;
1006
+ var selectInput = css12`
302
1007
  appearance: none;
303
- background: var(--white) url('./assets/chevon-down.svg') no-repeat 98% 50%;
1008
+ background: var(--white)
1009
+ url('data:image/svg+xml;base64,PHN2ZwogIHdpZHRoPSIyNCIKICBoZWlnaHQ9IjI0IgogIHZpZXdCb3g9IjAgMCAyNCAyNCIKICBmaWxsPSJub25lIgogIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKPgogIDxwYXRoCiAgICBkPSJNNi4zNDMxNyA3Ljc1NzMyTDQuOTI4OTYgOS4xNzE1NEwxMiAxNi4yNDI2TDE5LjA3MTEgOS4xNzE1N0wxNy42NTY5IDcuNzU3MzVMMTIgMTMuNDE0Mkw2LjM0MzE3IDcuNzU3MzJaIgogICAgZmlsbD0iIzgyODI4MiIKICAvPgo8L3N2Zz4=')
1010
+ no-repeat 98% 50%;
304
1011
  border: 1px solid var(--gray-500);
305
1012
  border-radius: var(--rounded-base);
306
1013
  color: var(--brand-secondary-1);
@@ -309,31 +1016,780 @@ to {
309
1016
  cursor: not-allowed;
310
1017
  color: var(--gray-200);
311
1018
  }
312
- `,G=D`
1019
+ `;
1020
+ var editableInput = css12`
1021
+ padding: var(--spacing-sm);
1022
+ max-width: 160px;
1023
+ `;
1024
+ var inputWrapper = css12`
313
1025
  margin: var(--spacing-base) 0;
314
- `,K=D`
1026
+ `;
1027
+ var inputLabel = css12`
315
1028
  color: var(--brand-secondary-1);
316
1029
  display: flex;
317
1030
  flex-direction: column;
318
1031
  margin: 0 0 var(--spacing-sm);
319
- `,$=D`
1032
+ `;
1033
+ var inputText = css12`
320
1034
  color: var(--brand-secondary-1);
321
1035
  display: block;
1036
+ flex: 1 100%;
322
1037
  font-weight: var(--font-bold);
323
1038
  margin: 0 0 var(--spacing-sm);
324
- `,q=D`
1039
+ `;
1040
+ var inputCaption = css12`
325
1041
  color: var(--gray-600);
326
1042
  font-size: var(--font-sm);
327
- `,W=D`
1043
+ `;
1044
+ var errorMsg = css12`
328
1045
  color: var(--brand-secondary-5);
329
1046
  display: block;
330
- `;var Q=({field:e,form:r,meta:n,...o})=>{let{label:a,caption:i,...u}=o;return t("div",{css:G},t("label",{css:K},t("span",{css:$},a),t("input",{type:"text",css:ht,...e,...u})),i?t("span",{css:q},i):null,t(Zt,{component:"div",css:W,name:e.name}))};import{ErrorMessage as Ut}from"formik";var yt=({field:e,form:r,meta:n,...o})=>{let{label:a,options:i,caption:u,...b}=o;return t("div",{css:G},t("label",{css:K},t("span",{css:$},a),t("select",{...e,...b,css:vt},i.map((l,p)=>t("option",{value:l.value,key:p},l.text)))),u?t("span",{css:q},u):null,t(Ut,{component:"div",css:W,name:e.name}))};import*as R from"yup";import{css as Nt}from"@emotion/react";var j=({children:e,...r})=>t("fieldset",{css:Nt`
1047
+ `;
1048
+ var rangeInput = css12`
1049
+ flex-direction: row;
1050
+ flex-wrap: wrap;
1051
+
1052
+ input[type='range'] {
1053
+ height: 28px;
1054
+ -webkit-appearance: none;
1055
+ margin: 10px 0;
1056
+ width: 100%;
1057
+ flex: 1 0 80%;
1058
+ }
1059
+
1060
+ input[type='range']:focus {
1061
+ outline: none;
1062
+ }
1063
+
1064
+ input[type='range']::-webkit-slider-runnable-track {
1065
+ width: 100%;
1066
+ height: 6px;
1067
+ cursor: pointer;
1068
+ animate: 0.2s;
1069
+ box-shadow: 0 0 0 #000000;
1070
+ background: #2ecdb4;
1071
+ border-radius: 0;
1072
+ border: 0 solid #000000;
1073
+ }
1074
+
1075
+ input[type='range']::-moz-range-track {
1076
+ width: 100%;
1077
+ height: 6px;
1078
+ cursor: pointer;
1079
+ animate: 0.2s;
1080
+ box-shadow: 0 0 0 #000000;
1081
+ background: #2ecdb4;
1082
+ border-radius: 0;
1083
+ border: 0 solid #000000;
1084
+ }
1085
+
1086
+ input[type='range']::-webkit-slider-thumb {
1087
+ box-shadow: 1px 1px 2px #000000;
1088
+ border: 1px solid #000000;
1089
+ height: 20px;
1090
+ width: 20px;
1091
+ border-radius: 20px;
1092
+ background: #ffffff;
1093
+ cursor: pointer;
1094
+ -webkit-appearance: none;
1095
+ margin-top: -7.5px;
1096
+ }
1097
+ input[type='range']::-moz-range-thumb {
1098
+ box-shadow: 1px 1px 2px #000000;
1099
+ border: 1px solid #000000;
1100
+ height: 20px;
1101
+ width: 20px;
1102
+ border-radius: 20px;
1103
+ background: #ffffff;
1104
+ cursor: pointer;
1105
+ -webkit-appearance: none;
1106
+ margin-top: -7.5px;
1107
+ }
1108
+ input[type='range']:focus::-webkit-slider-runnable-track {
1109
+ background: #2ecdb4;
1110
+ }
1111
+
1112
+ .value-display {
1113
+ flex: 1 0 20%;
1114
+ padding: 10px;
1115
+ }
1116
+ `;
1117
+
1118
+ // src/components/Inputs/SelectInput.tsx
1119
+ var SelectInput = ({ field, form, meta, ...rawProps }) => {
1120
+ const { label, options, caption, ...passThroughProps } = rawProps;
1121
+ return /* @__PURE__ */ jsx("div", {
1122
+ css: inputWrapper
1123
+ }, /* @__PURE__ */ jsx("label", {
1124
+ css: inputLabel
1125
+ }, /* @__PURE__ */ jsx("span", {
1126
+ css: inputText
1127
+ }, label), /* @__PURE__ */ jsx("select", {
1128
+ ...field,
1129
+ ...passThroughProps,
1130
+ css: selectInput
1131
+ }, options.map((o, index) => /* @__PURE__ */ jsx("option", {
1132
+ value: o.value,
1133
+ key: index
1134
+ }, o.text)))), caption ? /* @__PURE__ */ jsx("span", {
1135
+ css: inputCaption
1136
+ }, caption) : null, /* @__PURE__ */ jsx(ErrorMessage, {
1137
+ component: "div",
1138
+ css: errorMsg,
1139
+ name: field.name
1140
+ }));
1141
+ };
1142
+
1143
+ // src/components/Inputs/DependableSelectBox.tsx
1144
+ import { Field } from "formik";
1145
+
1146
+ // src/components/Inputs/SliderInput.tsx
1147
+ var SliderInput = ({ field, form, meta, ...rawProps }) => {
1148
+ var _a, _b;
1149
+ const { label, caption, min = 0, max = 100, step } = rawProps;
1150
+ return /* @__PURE__ */ jsx("div", null, /* @__PURE__ */ jsx("label", {
1151
+ css: [inputLabel, rangeInput]
1152
+ }, /* @__PURE__ */ jsx("span", {
1153
+ css: inputText
1154
+ }, label), /* @__PURE__ */ jsx("input", {
1155
+ type: "range",
1156
+ min,
1157
+ max,
1158
+ step,
1159
+ ...field,
1160
+ value: (_a = field.value) != null ? _a : 0
1161
+ }), /* @__PURE__ */ jsx("span", {
1162
+ className: "value-display"
1163
+ }, (_b = field.value) != null ? _b : 0)), /* @__PURE__ */ jsx("p", {
1164
+ css: inputCaption
1165
+ }, caption));
1166
+ };
1167
+ var SliderInput_default = SliderInput;
1168
+
1169
+ // src/components/Inputs/DependableSelectBox.tsx
1170
+ var DependableSelectBox = ({
1171
+ name,
1172
+ label,
1173
+ dimensionToOverride,
1174
+ isSubmitting
1175
+ }) => {
1176
+ const rangeProps = {
1177
+ max: 100,
1178
+ step: 20
1179
+ };
1180
+ if (dimensionToOverride) {
1181
+ rangeProps.max = dimensionToOverride.cap;
1182
+ rangeProps.step = dimensionToOverride.str;
1183
+ }
1184
+ return /* @__PURE__ */ jsx(Field, {
1185
+ component: SliderInput_default,
1186
+ label,
1187
+ caption: `Range: 0 - ${rangeProps.max} in increments of ${rangeProps.step}`,
1188
+ id: name,
1189
+ name,
1190
+ disabled: isSubmitting,
1191
+ ...rangeProps
1192
+ });
1193
+ };
1194
+ var DependableSelectBox_default = DependableSelectBox;
1195
+
1196
+ // src/components/Form/Fieldset.tsx
1197
+ import { css as css13 } from "@emotion/react";
1198
+ var Fieldset = ({ children, ...props }) => {
1199
+ return /* @__PURE__ */ jsx("fieldset", {
1200
+ css: css13`
331
1201
  border: none;
332
1202
  padding: 0;
333
- `,...r},e);import{css as Ot}from"@emotion/react";var tt=({children:e})=>t("legend",{css:Ot`
334
- font-size: var(--font-base);
1203
+ `,
1204
+ ...props
1205
+ }, children);
1206
+ };
1207
+
1208
+ // src/components/Form/Legend.tsx
1209
+ import { css as css14 } from "@emotion/react";
1210
+ var Legend = ({ children }) => {
1211
+ return /* @__PURE__ */ jsx("legend", {
1212
+ css: css14`
1213
+ font-size: var(--font-md);
335
1214
  font-weight: var(--font-bold);
336
- `},e);var Kt=R.object({apiKey:R.string().matches(/^uf.+$/,"API keys start with `uf`, double check your API key"),apiHost:R.string().matches(/^https:\/\/(localhost:8889|([a-z]+\.)?uniform.app)$/,"API host must be a Uniform domain."),logLevel:R.string(),projectId:R.string().uuid()}),wt=({settings:e,saveSettings:r,dimensionIndex:{error:n,loading:o}})=>{let a=[{value:"none",text:"Logging off"},{value:"info",text:"Log info, warnings, and errors"},{value:"warn",text:"Log warnings and errors"},{value:"error",text:"Log errors"},{value:"debug",text:"Verbose debug logging"}];return t(Gt,{initialValues:{apiHost:"",apiKey:"",projectId:"",logLevel:"none",...e},validationSchema:Kt,enableReinitialize:!0,onSubmit:i=>{r({...e,apiHost:i.apiHost,apiKey:i.apiKey,projectId:i.projectId,logLevel:i.logLevel})}},({dirty:i,isValid:u,isSubmitting:b})=>t(_t,{css:g.page},t("h1",{css:g.title},"Settings"),t(X,{component:yt,label:"Logging",caption:"Logs can be viewed in the browser console",id:"logging",name:"logLevel",options:a,disabled:b}),t(j,{disabled:b},t(tt,null,"Data Connection"),!o&&n?t("p",{css:g.error},"Unable to fetch data from Uniform",t("br",null),t("em",null,n.message)):null,t("p",{css:g.text},t("small",null,"Adding an API key and project ID enables richer dimension data to be shown. You must have access to the Uniform project to do this.")),t(X,{component:Q,label:"Uniform API key",caption:"Generate an API key in your Uniform team settings. Grant only Context: Read Drafts permission.",id:"api-key",name:"apiKey",autoComplete:"off"}),t(X,{component:Q,label:"Uniform Project ID",caption:"Available after generating an API key ",id:"project-id",name:"projectId",autoComplete:"off"}),t(E,null,t(B,{title:"Advanced"},t(X,{component:Q,label:"Alternative API Host",caption:"Use a non-standard Uniform API endpoint. Most people will not not need this option.",id:"api-host",name:"apiHost",autoComplete:"off"}))),i?t(k,{type:"submit",css:g.submitButton,disabled:!u},"Save"):null)))};var et=({settings:e,saveSettings:r})=>{let n=()=>{r({...e,route:"/settings"})},o=()=>{r({...e,ignoreApiKeyPrompt:!0})},a=!(e==null?void 0:e.apiKey);return!e.ignoreApiKeyPrompt&&a?t("div",{css:[F,st]},t("h2",{css:Z},"Connect this site"),t("p",{css:U},"Add a Uniform API key to get better data."),t("div",{css:N},t(k,{buttonType:"secondary",onClick:n},"Connect this site"),t(k,{buttonType:"ghost",onClick:o},"Skip for now")),t("button",{type:"button",css:ct,title:"close",onClick:o},t("span",{hidden:!0},"Close"))):null};import{computeDimensionDefinitionDisplayData as $t,computeDimensionDisplayData as Ct,DimensionClient as qt}from"@uniformdev/context/api";import{useAsync as Wt}from"react-use";import*as Lt from"react";function Tt({apiHost:e,apiKey:r,projectId:n},o){let a=Lt.useMemo(()=>{var p,d,h,v;let l={};return o&&(Object.keys((d=(p=o==null?void 0:o.project.pz)==null?void 0:p.sig)!=null?d:{}).forEach(f=>{let C=Ct(f,o);C&&(l[f]=C)}),Object.keys((v=(h=o==null?void 0:o.project.pz)==null?void 0:h.agg)!=null?v:{}).forEach(f=>{let C=Ct(f,o);C&&(l[f]=C)})),l},[o]),{loading:i,error:u,value:b}=Wt(async()=>{if(!r||!n)return a;let p=(await new qt({projectId:n,apiKey:r,apiHost:e||void 0}).get()).dimensions,d={...a};return p.forEach(h=>{d[h.dim]=$t(h)}),d},[e,r,n,a]);return{loading:i,error:u,index:b!=null?b:a}}import{css as ot}from"@emotion/react";function Y(){return t("style",null,`
1215
+ border-bottom: 1px solid var(--gray-400);
1216
+ width: 100%;
1217
+ `
1218
+ }, children);
1219
+ };
1220
+
1221
+ // src/lib/computeOverrideEffects.ts
1222
+ import { Context, TransitionDataStore } from "@uniformdev/context";
1223
+ function computeOverrideEffects({ manifest, visitor, override }) {
1224
+ const contextCopy = new Context({
1225
+ manifest,
1226
+ transitionStore: new CopyTransitionDataStore({ initialData: visitor })
1227
+ });
1228
+ const currentScores = { ...contextCopy.scores };
1229
+ contextCopy.storage.updateData([override]);
1230
+ const newScores = { ...contextCopy.scores };
1231
+ const changes = { ...newScores };
1232
+ Object.entries(changes).forEach(([key, value]) => {
1233
+ const oldScore = currentScores[key];
1234
+ if (oldScore === value) {
1235
+ delete changes[key];
1236
+ }
1237
+ });
1238
+ return changes;
1239
+ }
1240
+ var CopyTransitionDataStore = class extends TransitionDataStore {
1241
+ async handleDelete() {
1242
+ }
1243
+ async handleUpdateData() {
1244
+ }
1245
+ };
1246
+
1247
+ // src/lib/applyOverrides.ts
1248
+ function applyScoreOverrides({
1249
+ scores,
1250
+ scoreOverrides
1251
+ }) {
1252
+ const commands = [];
1253
+ if (!scoreOverrides)
1254
+ return [];
1255
+ Object.entries(scoreOverrides).forEach(([dim, override]) => {
1256
+ var _a;
1257
+ const score = (_a = scores[dim]) != null ? _a : 0;
1258
+ if (score === override.override) {
1259
+ return;
1260
+ }
1261
+ const delta = override.override - score;
1262
+ commands.push({
1263
+ type: "modscoreS",
1264
+ data: { dimension: dim, delta }
1265
+ });
1266
+ });
1267
+ return commands;
1268
+ }
1269
+ function applyQuirkOverrides({
1270
+ quirks,
1271
+ quirkOverrides
1272
+ }) {
1273
+ const quirkVector = {};
1274
+ if (!quirkOverrides)
1275
+ return void 0;
1276
+ Object.entries(quirkOverrides).forEach(([quirk, override]) => {
1277
+ const quirkValue = quirks[quirk];
1278
+ if (quirkValue === override.override) {
1279
+ return;
1280
+ }
1281
+ quirkVector[quirk] = override.override;
1282
+ });
1283
+ return Object.keys(quirkVector).length > 0 ? quirkVector : void 0;
1284
+ }
1285
+
1286
+ // src/components/Personalization/AddOverride.tsx
1287
+ var overrideSettingsSchema = yup.object({
1288
+ dimension: yup.string(),
1289
+ score: yup.number()
1290
+ });
1291
+ var AddOverride = ({
1292
+ settings,
1293
+ saveSettings,
1294
+ state,
1295
+ actions,
1296
+ dimensionIndex: { index }
1297
+ }) => {
1298
+ var _a, _b;
1299
+ const routeParams = settings.route ? [...settings.route.matchAll(/overrides\/(?!.*add)(\w+)?/g)] : [];
1300
+ const overriddenDimension = routeParams[0] ? routeParams[0][1] : "";
1301
+ if (!((_a = state.manifest.project.pz) == null ? void 0 : _a.sig)) {
1302
+ return /* @__PURE__ */ jsx("p", null, "Error, manifest is broken or there is no signal to override.");
1303
+ }
1304
+ const overridableDimensions = Object.entries(index).filter(([, value]) => value.type !== "Audience" && value.type !== "Intent").map(([key, value]) => {
1305
+ const type = value.type ? `${value.type}: ` : "";
1306
+ const category = value.category ? `${value.category} - ` : "";
1307
+ const text = `${type}${category}${value.name}`;
1308
+ return {
1309
+ value: key,
1310
+ text
1311
+ };
1312
+ });
1313
+ overridableDimensions.unshift({
1314
+ value: "_none",
1315
+ text: "Choose dimension to override"
1316
+ });
1317
+ return /* @__PURE__ */ jsx(Formik, {
1318
+ initialValues: {
1319
+ dimension: overriddenDimension,
1320
+ score: (_b = state.scores[overriddenDimension]) != null ? _b : 0
1321
+ },
1322
+ validationSchema: overrideSettingsSchema,
1323
+ enableReinitialize: true,
1324
+ onSubmit: async (values) => {
1325
+ var _a2, _b2, _c, _d, _e, _f;
1326
+ const cap = (_b2 = (_a2 = index[values.dimension]) == null ? void 0 : _a2.cap) != null ? _b2 : 0;
1327
+ const cappedOverrideScore = Math.min(values.score, cap);
1328
+ const newSettings = {
1329
+ ...settings,
1330
+ scoreOverrides: {
1331
+ ...settings.scoreOverrides,
1332
+ [values.dimension]: {
1333
+ initial: (_f = (_e = (_d = (_c = settings.scoreOverrides) == null ? void 0 : _c[values.dimension]) == null ? void 0 : _d.initial) != null ? _e : state.scores[values.dimension]) != null ? _f : 0,
1334
+ override: cappedOverrideScore
1335
+ }
1336
+ },
1337
+ route: "/overrides"
1338
+ };
1339
+ await saveSettings(newSettings);
1340
+ const applyCommands = applyScoreOverrides({
1341
+ scores: state.scores,
1342
+ scoreOverrides: newSettings.scoreOverrides
1343
+ });
1344
+ actions.rawUpdate(applyCommands);
1345
+ }
1346
+ }, ({ dirty, isValid, isSubmitting, values }) => {
1347
+ var _a2;
1348
+ const overrideEffects = computeOverrideEffects({
1349
+ manifest: state.manifest,
1350
+ visitor: state.data,
1351
+ override: {
1352
+ type: "modscore",
1353
+ data: {
1354
+ dimension: values.dimension,
1355
+ delta: values.score - ((_a2 = state.scores[values.dimension]) != null ? _a2 : 0)
1356
+ }
1357
+ }
1358
+ });
1359
+ const preemptiveOverrides = Object.entries(state.scores).reduce((acc, [key, value]) => {
1360
+ acc[key] = {
1361
+ initial: value,
1362
+ override: value
1363
+ };
1364
+ return acc;
1365
+ }, {});
1366
+ const hasScoreEffects = values.score && Object.keys(overrideEffects).length > 0;
1367
+ return /* @__PURE__ */ jsx(Form, {
1368
+ css: styles.page
1369
+ }, /* @__PURE__ */ jsx("h1", {
1370
+ css: styles.title
1371
+ }, "Override Dimension"), /* @__PURE__ */ jsx(Field2, {
1372
+ component: SelectInput,
1373
+ label: "Dimension",
1374
+ id: "dimension",
1375
+ name: "dimension",
1376
+ options: overridableDimensions,
1377
+ disabled: isSubmitting
1378
+ }), /* @__PURE__ */ jsx("p", {
1379
+ css: styles.text
1380
+ }, /* @__PURE__ */ jsx("small", null, "Audiences and Intents are aggregated from other dimension scores and cannot be overridden directly.")), values.dimension ? /* @__PURE__ */ jsx(DependableSelectBox_default, {
1381
+ name: "score",
1382
+ label: "Score",
1383
+ dimensionToOverride: index[values.dimension],
1384
+ isSubmitting
1385
+ }) : null, /* @__PURE__ */ jsx(Fieldset, {
1386
+ disabled: isSubmitting,
1387
+ css: { marginBottom: "2rem" }
1388
+ }, hasScoreEffects ? /* @__PURE__ */ jsx(Accordion, null, /* @__PURE__ */ jsx(AccordionItem, {
1389
+ title: `Impacted Dimensions (${Object.keys(overrideEffects).length})`
1390
+ }, /* @__PURE__ */ jsx(DimensionsTable_default, {
1391
+ preemptiveOverrides,
1392
+ dimensionIndex: index,
1393
+ dimensions: overrideEffects,
1394
+ disableEditOverride: true
1395
+ }))) : null, dirty ? /* @__PURE__ */ jsx(Button, {
1396
+ type: "submit",
1397
+ css: styles.submitButton,
1398
+ disabled: !isValid
1399
+ }, "Save") : null, /* @__PURE__ */ jsx(NavigationLink_default, {
1400
+ route: "/overrides",
1401
+ css: styles.cancelButton
1402
+ }, "Cancel")));
1403
+ });
1404
+ };
1405
+
1406
+ // src/components/Personalization/Quirks.tsx
1407
+ import { useState as useState3 } from "react";
1408
+
1409
+ // src/components/Inputs/EditableText.tsx
1410
+ import { useState as useState2, useEffect } from "react";
1411
+ var EditableText = ({ name, value, submit }) => {
1412
+ const [inputValue, setInputValue] = useState2(value != null ? value : "");
1413
+ useEffect(() => {
1414
+ setInputValue(value != null ? value : "");
1415
+ }, [value]);
1416
+ const onChange = (e) => {
1417
+ setInputValue(e.target.value);
1418
+ };
1419
+ return /* @__PURE__ */ jsx("div", {
1420
+ css: { display: "flex", gap: "var(--spacing-sm)" }
1421
+ }, /* @__PURE__ */ jsx("input", {
1422
+ type: "text",
1423
+ css: [textInput, editableInput],
1424
+ name,
1425
+ value: inputValue,
1426
+ onChange
1427
+ }), /* @__PURE__ */ jsx(Button, {
1428
+ buttonType: "primary",
1429
+ onClick: () => submit(name, inputValue != null ? inputValue : "")
1430
+ }, "Save"));
1431
+ };
1432
+ var EditableText_default = EditableText;
1433
+
1434
+ // src/components/Inputs/EditableSelectBox.tsx
1435
+ var EditableSelectBox = ({ name, value, submit, options }) => {
1436
+ const onChange = (e) => submit(e.target.name, e.target.value);
1437
+ return /* @__PURE__ */ jsx("select", {
1438
+ name,
1439
+ defaultValue: value,
1440
+ onChange,
1441
+ css: [selectInput, editableInput]
1442
+ }, /* @__PURE__ */ jsx("option", {
1443
+ key: "_none",
1444
+ value: "_none"
1445
+ }, "None"), (options != null ? options : []).map((option) => /* @__PURE__ */ jsx("option", {
1446
+ key: option.value,
1447
+ value: option.value
1448
+ }, option.name)));
1449
+ };
1450
+ var EditableSelectBox_default = EditableSelectBox;
1451
+
1452
+ // src/components/Personalization/Quirks.tsx
1453
+ var Quirks = ({ ...props }) => {
1454
+ const {
1455
+ state: {
1456
+ data: { quirks }
1457
+ },
1458
+ quirksIndex: { index: quirksIndex },
1459
+ settings,
1460
+ saveSettings,
1461
+ actions
1462
+ } = props;
1463
+ const [editable, setEditable] = useState3("");
1464
+ let editableQuirkMetaData;
1465
+ if (editable) {
1466
+ editableQuirkMetaData = quirksIndex[editable];
1467
+ }
1468
+ const submitOverride = async (name, value) => {
1469
+ var _a, _b, _c;
1470
+ setEditable("");
1471
+ const newSettings = {
1472
+ ...settings,
1473
+ quirkOverrides: {
1474
+ ...settings.quirkOverrides,
1475
+ [name]: { initial: (_c = (_b = (_a = settings.quirkOverrides) == null ? void 0 : _a[name]) == null ? void 0 : _b.initial) != null ? _c : quirks[name], override: value }
1476
+ }
1477
+ };
1478
+ await saveSettings(newSettings);
1479
+ const quirkOverrides = applyQuirkOverrides({
1480
+ quirks,
1481
+ quirkOverrides: newSettings.quirkOverrides
1482
+ });
1483
+ actions.update({ quirks: quirkOverrides });
1484
+ };
1485
+ return /* @__PURE__ */ jsx(React.Fragment, null, /* @__PURE__ */ jsx("article", {
1486
+ css: styles.page
1487
+ }, /* @__PURE__ */ jsx("h1", {
1488
+ css: styles.title
1489
+ }, "Quirks"), /* @__PURE__ */ jsx("p", {
1490
+ css: styles.text
1491
+ }, "Keys defined in Uniform and their current, programmatically defined values for this visit."), Object.keys(quirksIndex).length ? /* @__PURE__ */ jsx(Table, null, /* @__PURE__ */ jsx(THead, null, /* @__PURE__ */ jsx(TRow, null, /* @__PURE__ */ jsx(THeading, null, "Key"), /* @__PURE__ */ jsx(THeading, null, "Value"), /* @__PURE__ */ jsx(TData, null, ""))), /* @__PURE__ */ jsx(TBody, null, Object.values(quirksIndex).map(({ name, value, id }) => {
1492
+ var _a, _b, _c;
1493
+ const initialValue = (_b = (_a = settings.quirkOverrides) == null ? void 0 : _a[name]) == null ? void 0 : _b.initial;
1494
+ return /* @__PURE__ */ jsx(TRow, {
1495
+ key: id,
1496
+ border: "bottom"
1497
+ }, /* @__PURE__ */ jsx(TData, null, /* @__PURE__ */ jsx("strong", null, name)), /* @__PURE__ */ jsx(TData, null, editable !== id ? /* @__PURE__ */ jsx("div", {
1498
+ onClick: () => {
1499
+ setEditable(id);
1500
+ }
1501
+ }, initialValue ? /* @__PURE__ */ jsx("div", null, /* @__PURE__ */ jsx("s", null, initialValue)) : null, value) : null, editable === id && editableQuirkMetaData && /* @__PURE__ */ jsx(React.Fragment, null, editableQuirkMetaData.options ? /* @__PURE__ */ jsx(EditableSelectBox_default, {
1502
+ name: id,
1503
+ value,
1504
+ submit: submitOverride,
1505
+ options: editableQuirkMetaData.options
1506
+ }) : /* @__PURE__ */ jsx(EditableText_default, {
1507
+ name: id,
1508
+ value,
1509
+ submit: submitOverride
1510
+ }))), /* @__PURE__ */ jsx(TData, null, editable ? null : ((_c = settings.quirkOverrides) == null ? void 0 : _c[id]) ? /* @__PURE__ */ jsx(LinkButton, {
1511
+ onClick: () => {
1512
+ deleteQuirkOverride({ quirk: id, settings, saveSettings, actions });
1513
+ }
1514
+ }, /* @__PURE__ */ jsx("small", null, "Clear Override")) : /* @__PURE__ */ jsx(LinkButton, {
1515
+ onClick: () => {
1516
+ setEditable(id);
1517
+ }
1518
+ }, /* @__PURE__ */ jsx("small", null, "Override"))));
1519
+ }))) : /* @__PURE__ */ jsx(NoActiveDimensions, {
1520
+ title: "No quirks configured",
1521
+ text: "There are currently no quirks setup. Try to connect to Uniform API to load additional information about Quirks and Quirks without defined value."
1522
+ })));
1523
+ };
1524
+
1525
+ // src/components/Personalization/Settings.tsx
1526
+ import { Field as Field3, Form as Form2, Formik as Formik2 } from "formik";
1527
+
1528
+ // src/components/Inputs/InputText.tsx
1529
+ import { ErrorMessage as ErrorMessage2 } from "formik";
1530
+ var InputText = ({ field, form, meta, ...rawProps }) => {
1531
+ const { label, caption, ...passThroughProps } = rawProps;
1532
+ return /* @__PURE__ */ jsx("div", {
1533
+ css: inputWrapper
1534
+ }, /* @__PURE__ */ jsx("label", {
1535
+ css: inputLabel
1536
+ }, /* @__PURE__ */ jsx("span", {
1537
+ css: inputText
1538
+ }, label), /* @__PURE__ */ jsx("input", {
1539
+ type: "text",
1540
+ css: textInput,
1541
+ ...field,
1542
+ ...passThroughProps
1543
+ })), caption ? /* @__PURE__ */ jsx("span", {
1544
+ css: inputCaption
1545
+ }, caption) : null, /* @__PURE__ */ jsx(ErrorMessage2, {
1546
+ component: "div",
1547
+ css: errorMsg,
1548
+ name: field.name
1549
+ }));
1550
+ };
1551
+
1552
+ // src/components/Personalization/Settings.tsx
1553
+ import * as yup2 from "yup";
1554
+ var editableSettingsSchema = yup2.object({
1555
+ apiKey: yup2.string().matches(/^uf.+$/, "API keys start with `uf`, double check your API key"),
1556
+ apiHost: yup2.string().matches(/^https:\/\/(localhost:8889|([a-z]+\.)?uniform.app)$/, "API host must be a Uniform domain."),
1557
+ logging: yup2.boolean(),
1558
+ projectId: yup2.string().uuid(),
1559
+ consentMode: yup2.boolean()
1560
+ });
1561
+ var Settings = ({
1562
+ settings,
1563
+ saveSettings,
1564
+ actions,
1565
+ state: { data },
1566
+ dimensionIndex: { error, loading }
1567
+ }) => {
1568
+ var _a, _b, _c;
1569
+ return /* @__PURE__ */ jsx(Formik2, {
1570
+ initialValues: {
1571
+ apiHost: (_a = settings.apiHost) != null ? _a : "",
1572
+ apiKey: (_b = settings.apiKey) != null ? _b : "",
1573
+ projectId: (_c = settings.projectId) != null ? _c : "",
1574
+ consentMode: !!data.consent,
1575
+ logging: settings.logLevel !== "none" && Boolean(settings.logLevel)
1576
+ },
1577
+ validationSchema: editableSettingsSchema,
1578
+ enableReinitialize: true,
1579
+ onSubmit: (values) => {
1580
+ saveSettings({
1581
+ ...settings,
1582
+ apiHost: values.apiHost,
1583
+ apiKey: values.apiKey,
1584
+ projectId: values.projectId,
1585
+ logLevel: values.logging ? "debug" : "none",
1586
+ consentMode: values.consentMode
1587
+ });
1588
+ actions.rawUpdate([{ type: "consent", data: values.consentMode }]);
1589
+ }
1590
+ }, ({ dirty, isValid, isSubmitting }) => /* @__PURE__ */ jsx(Form2, {
1591
+ css: styles.page
1592
+ }, /* @__PURE__ */ jsx("h1", {
1593
+ css: styles.title
1594
+ }, "Settings"), /* @__PURE__ */ jsx(Fieldset, {
1595
+ disabled: isSubmitting
1596
+ }, /* @__PURE__ */ jsx(Legend, null, "Data Connection"), !loading && error ? /* @__PURE__ */ jsx("p", {
1597
+ css: styles.error
1598
+ }, "Unable to fetch data from Uniform", /* @__PURE__ */ jsx("br", null), /* @__PURE__ */ jsx("em", null, error.message)) : null, /* @__PURE__ */ jsx("p", {
1599
+ css: styles.text
1600
+ }, /* @__PURE__ */ jsx("small", null, "Adding an API key and project ID enables richer dimension data to be shown. You must have access to the Uniform project to do this.")), /* @__PURE__ */ jsx(Field3, {
1601
+ component: InputText,
1602
+ label: "Uniform API key",
1603
+ caption: "Generate an API key in your Uniform team settings. Grant only Context: Read Drafts permission.",
1604
+ id: "api-key",
1605
+ name: "apiKey",
1606
+ autoComplete: "off"
1607
+ }), /* @__PURE__ */ jsx(Field3, {
1608
+ component: InputText,
1609
+ label: "Uniform Project ID",
1610
+ caption: "Available to copy after generating an API key",
1611
+ id: "project-id",
1612
+ name: "projectId",
1613
+ autoComplete: "off"
1614
+ }), /* @__PURE__ */ jsx(Accordion, null, /* @__PURE__ */ jsx(AccordionItem, {
1615
+ title: "Advanced"
1616
+ }, /* @__PURE__ */ jsx(Field3, {
1617
+ component: InputText,
1618
+ label: "Alternative API Host",
1619
+ caption: "Use a non-standard Uniform API endpoint. Most people will not not need this option.",
1620
+ id: "api-host",
1621
+ name: "apiHost",
1622
+ autoComplete: "off"
1623
+ }))), /* @__PURE__ */ jsx(Fieldset, null, /* @__PURE__ */ jsx(Legend, null, "Storage Consent"), /* @__PURE__ */ jsx(Field3, {
1624
+ component: FormikSwitchInput,
1625
+ label: "Store visitor data",
1626
+ id: "consent-mode",
1627
+ name: "consentMode"
1628
+ }), /* @__PURE__ */ jsx("p", null, /* @__PURE__ */ jsx("small", null, "Turning on consents to storing behavior in this browser for personalization across sessions. Only affects this browser. Personalization works with this disabled, but dimension scores are lost on refresh."))), /* @__PURE__ */ jsx(Fieldset, null, /* @__PURE__ */ jsx(Legend, null, "Logging"), /* @__PURE__ */ jsx(Field3, {
1629
+ component: FormikSwitchInput,
1630
+ label: "Write Uniform Context diagnostic logs to browser console",
1631
+ id: "logging",
1632
+ name: "logging"
1633
+ })), dirty ? /* @__PURE__ */ jsx(Button, {
1634
+ type: "submit",
1635
+ css: styles.submitButton,
1636
+ disabled: !isValid
1637
+ }, "Save") : null)));
1638
+ };
1639
+
1640
+ // src/components/CallToAction/ConnectApiKey.tsx
1641
+ var ConnectApiKey = ({ settings, saveSettings }) => {
1642
+ const handleRedirect = () => {
1643
+ saveSettings({ ...settings, route: "/settings" });
1644
+ };
1645
+ const dismissPrompt = () => {
1646
+ saveSettings({ ...settings, ignoreApiKeyPrompt: true });
1647
+ };
1648
+ const missingApiKey = !(settings == null ? void 0 : settings.apiKey);
1649
+ return !settings.ignoreApiKeyPrompt && missingApiKey ? /* @__PURE__ */ jsx("div", {
1650
+ css: [cta, ctaWithIcon]
1651
+ }, /* @__PURE__ */ jsx("h2", {
1652
+ css: ctaTitle
1653
+ }, "Connect this site"), /* @__PURE__ */ jsx("p", {
1654
+ css: ctaText
1655
+ }, "Add a Uniform API key to get better data."), /* @__PURE__ */ jsx("div", {
1656
+ css: ctaBtnGroup
1657
+ }, /* @__PURE__ */ jsx(Button, {
1658
+ buttonType: "secondary",
1659
+ onClick: handleRedirect
1660
+ }, "Connect this site"), /* @__PURE__ */ jsx(Button, {
1661
+ buttonType: "ghost",
1662
+ onClick: dismissPrompt
1663
+ }, "Skip for now")), /* @__PURE__ */ jsx("button", {
1664
+ type: "button",
1665
+ css: ctaClose,
1666
+ title: "close",
1667
+ onClick: dismissPrompt
1668
+ }, /* @__PURE__ */ jsx("span", {
1669
+ hidden: true
1670
+ }, "Close"))) : null;
1671
+ };
1672
+
1673
+ // src/hooks/useDimensionIndex.ts
1674
+ import {
1675
+ computeDimensionDefinitionDisplayData,
1676
+ computeDimensionDisplayData,
1677
+ DimensionClient
1678
+ } from "@uniformdev/context/api";
1679
+ import { useAsync } from "react-use";
1680
+ import * as React6 from "react";
1681
+ function useDimensionIndex({ apiHost, apiKey, projectId }, manifest) {
1682
+ const { loading, error, value } = useAsync(async () => {
1683
+ if (!apiKey || !projectId) {
1684
+ return manifestData;
1685
+ }
1686
+ const client = new DimensionClient({
1687
+ projectId,
1688
+ apiKey,
1689
+ apiHost: apiHost ? apiHost : void 0
1690
+ });
1691
+ const dimensions = (await client.get()).dimensions;
1692
+ const result = {};
1693
+ dimensions.map((dimension) => {
1694
+ var _a, _b, _c, _d;
1695
+ result[dimension.dim] = {
1696
+ ...computeDimensionDefinitionDisplayData(dimension),
1697
+ cap: dimension.cap,
1698
+ str: 10
1699
+ };
1700
+ if (result[dimension.dim].type === "Enrichment") {
1701
+ const enrId = dimension.dim.split("_")[0];
1702
+ result[dimension.dim].cap = (_d = (_c = (_b = (_a = manifest == null ? void 0 : manifest.project.pz) == null ? void 0 : _a.enr) == null ? void 0 : _b[enrId]) == null ? void 0 : _c.cap) != null ? _d : 100;
1703
+ }
1704
+ });
1705
+ return result;
1706
+ }, [apiHost, apiKey, projectId]);
1707
+ const manifestData = React6.useMemo(() => {
1708
+ var _a, _b, _c, _d;
1709
+ const data = {};
1710
+ if (!manifest) {
1711
+ return data;
1712
+ }
1713
+ Object.entries((_b = (_a = manifest == null ? void 0 : manifest.project.pz) == null ? void 0 : _a.sig) != null ? _b : {}).map(([dimensionId, dimension]) => {
1714
+ const dim = computeDimensionDisplayData(dimensionId, manifest);
1715
+ if (dim) {
1716
+ data[dimensionId] = { ...dimension, ...dim };
1717
+ }
1718
+ });
1719
+ Object.entries((_d = (_c = manifest == null ? void 0 : manifest.project.pz) == null ? void 0 : _c.enr) != null ? _d : {}).map(([dimensionId, enr]) => {
1720
+ var _a2;
1721
+ const dim = computeDimensionDisplayData(dimensionId, manifest);
1722
+ const signal = { cap: (_a2 = enr.cap) != null ? _a2 : 100, str: 10 };
1723
+ if (dim) {
1724
+ data[dimensionId] = { ...dim, cap: signal.cap, str: signal.str };
1725
+ }
1726
+ });
1727
+ if (value) {
1728
+ Object.entries(value).map(([dimensionId, dimension]) => {
1729
+ data[dimensionId] = {
1730
+ ...data[dimensionId],
1731
+ ...dimension
1732
+ };
1733
+ });
1734
+ }
1735
+ return data;
1736
+ }, [manifest, value]);
1737
+ return {
1738
+ loading,
1739
+ error,
1740
+ index: manifestData
1741
+ };
1742
+ }
1743
+
1744
+ // src/hooks/useQuirkIndex.ts
1745
+ import { useMemo as useMemo3 } from "react";
1746
+ import { QuirkClient } from "@uniformdev/context/api";
1747
+ import { useAsync as useAsync2 } from "react-use";
1748
+ function useQuirkIndex({ apiHost, apiKey, projectId }, quirksData) {
1749
+ const { loading, error, value } = useAsync2(async () => {
1750
+ if (!apiKey || !projectId) {
1751
+ return {};
1752
+ }
1753
+ const client = new QuirkClient({
1754
+ projectId,
1755
+ apiKey,
1756
+ apiHost: apiHost ? apiHost : void 0
1757
+ });
1758
+ const quirksResponse = await client.get();
1759
+ const quirksIndexData = {};
1760
+ quirksResponse.quirks.map((quirkData) => {
1761
+ quirksIndexData[quirkData.id] = { ...quirkData, value: quirksData[quirkData.id] };
1762
+ });
1763
+ return quirksIndexData;
1764
+ }, [apiHost, apiKey, projectId]);
1765
+ const contextStateQuirkData = useMemo3(() => {
1766
+ const data = {};
1767
+ Object.entries(quirksData).map(([quirkId, queryrValue]) => data[quirkId] = {
1768
+ value: queryrValue,
1769
+ id: quirkId,
1770
+ name: quirkId
1771
+ });
1772
+ if (value) {
1773
+ Object.entries(value).map(([quirkId, quirkValue]) => data[quirkId] = {
1774
+ ...quirkValue,
1775
+ value: quirksData[quirkId]
1776
+ });
1777
+ }
1778
+ return data;
1779
+ }, [quirksData, value]);
1780
+ return {
1781
+ loading,
1782
+ error,
1783
+ index: contextStateQuirkData
1784
+ };
1785
+ }
1786
+
1787
+ // src/components/ContextDevTools.tsx
1788
+ import { css as css15 } from "@emotion/react";
1789
+
1790
+ // src/styles/Theme.tsx
1791
+ function Theme() {
1792
+ return /* @__PURE__ */ jsx("style", null, `
337
1793
  :root {
338
1794
  --brand-primary-1: #438fd5; /* bright blue */
339
1795
  --brand-primary-2: #f4220b; /* red */
@@ -393,6 +1849,10 @@ to {
393
1849
  --gray-800: #1f2937;
394
1850
  --gray-900: #111827;
395
1851
 
1852
+ /* Red CTA */
1853
+ --red-button: rgb(217 83 79);
1854
+ --red-tooltip: #D9534F;
1855
+
396
1856
  /* z-indexs */
397
1857
  --z-10: 10;
398
1858
  }
@@ -694,7 +2154,29 @@ Add the correct display in Chrome and Safari.
694
2154
 
695
2155
  summary {
696
2156
  display: list-item;
697
- }`)}var Qt=ot`
2157
+ }`);
2158
+ }
2159
+
2160
+ // src/components/StatusPages/AdditionalDataLoading.tsx
2161
+ import { useEffect as useEffect2, useState as useState4 } from "react";
2162
+ import { useMountedState } from "react-use";
2163
+ var AdditionalDataLoading = () => {
2164
+ const [viz, setViz] = useState4(false);
2165
+ const mounted = useMountedState();
2166
+ useEffect2(() => {
2167
+ setTimeout(() => {
2168
+ if (mounted()) {
2169
+ setViz(true);
2170
+ }
2171
+ }, 1e3);
2172
+ }, [mounted]);
2173
+ return viz ? /* @__PURE__ */ jsx("article", {
2174
+ css: styles.page
2175
+ }, /* @__PURE__ */ jsx("h1", null, "Loading..."), /* @__PURE__ */ jsx("p", null, "Connecting to Uniform API for complete data.")) : null;
2176
+ };
2177
+
2178
+ // src/components/ContextDevTools.tsx
2179
+ var mainLayoutStyle = css15`
698
2180
  background: var(--white);
699
2181
  padding: var(--spacing-base);
700
2182
  overflow-y: auto;
@@ -723,23 +2205,169 @@ summary {
723
2205
  &::-webkit-scrollbar-thumb:hover {
724
2206
  background: var(--gray-500);
725
2207
  }
726
- `;function kt(e){let r=typeof chrome!="undefined"&&typeof chrome.storage!="undefined",n=Tt(e.settings,e.state.manifest),o={...e,dimensionIndex:n},a=()=>{var i;switch((i=e.settings)==null?void 0:i.route){case void 0:case"/":case"/dimensions":return t(ft,{...o});case"/quirks":return t(bt,{...o});case"/settings":return t(wt,{...o});default:return t(nt,null)}};return t(m.Fragment,null,t(Y,null),t("div",{css:[ot`
727
- display: grid;
728
- grid-template-columns: 200px auto;
729
- font-weight: var(--font-regular);
730
- font-size: var(--base-font-size);
731
- font-family: var(--base-font-family);
732
- line-height: var(--base-line-height);
733
- height: var(--min-height);
734
- min-width: var(--site-width);
735
- `,r?void 0:ot`
736
- box-shadow: var(--shadow-base);
737
- position: fixed;
738
- bottom: 82px;
739
- right: var(--spacing-base);
740
- z-index: var(--z-10);
741
- max-width: var(--site-width);
742
- `]},t(rt,{...e}),t("main",{css:Qt},t(et,{...e}),a())))}import{Context as Xt,createDebugConsoleLogDrain as Yt}from"@uniformdev/context";import*as L from"react";function xt({context:e,initialSettings:r}){let n=e!=null?e:typeof window!="undefined"?window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__:void 0,o=n!=null?n:new Xt({manifest:{project:{}}}),[a,i]=L.useState({data:o.storage.data,manifest:o.manifest.data,scores:o.scores,personalizations:[],tests:[]}),[u,b]=L.useState(r!=null?r:{});L.useEffect(()=>{var d;let p=Yt((d=u.logLevel)!=null?d:"none");return o.events.on("log",p),()=>{o.events.off("log",p)}},[u,o]),L.useEffect(()=>{let p=()=>{i(v=>({...v,scores:o.scores,data:o.storage.data,manifest:o.manifest.data}))},d=v=>{!v.changed||i(f=>({...f,personalizations:[...f.personalizations,v]}))},h=v=>{!v.variantAssigned||i(f=>({...f,tests:[...f.tests,v]}))};return o.events.on("personalizationResult",d),o.events.on("testResult",h),o.storage.events.on("*",p),()=>{o.storage.events.off("*",p),o.events.off("personalizationResult",d),o.events.off("testResult",h)}},[o,u]);let l=L.useMemo(()=>({update:d=>o.update(d),forget:()=>o.forget(!1),rawUpdate:d=>o.storage.updateData(d)}),[o]);return n?t(kt,{state:a,actions:l,settings:u,saveSettings:b}):t("p",null,"Unable to find Uniform Context. Ensure the devtools plugin is activated.")}import*as Rt from"react";import{css as Jt}from"@emotion/react";var jt=Jt`
2208
+ `;
2209
+ function ContextDevTools(props) {
2210
+ const dimensionIndex = useDimensionIndex(props.settings, props.state.manifest);
2211
+ const quirksIndex = useQuirkIndex(props.settings, props.state.data.quirks);
2212
+ const routeProps = {
2213
+ ...props,
2214
+ dimensionIndex,
2215
+ quirksIndex
2216
+ };
2217
+ const component = () => {
2218
+ var _a;
2219
+ if (dimensionIndex.loading || quirksIndex.loading) {
2220
+ return /* @__PURE__ */ jsx(AdditionalDataLoading, null);
2221
+ }
2222
+ if (props.settings.route) {
2223
+ if (props.settings.route.match(/overrides\/\w+/)) {
2224
+ return /* @__PURE__ */ jsx(AddOverride, {
2225
+ ...routeProps
2226
+ });
2227
+ }
2228
+ }
2229
+ switch ((_a = props.settings) == null ? void 0 : _a.route) {
2230
+ case void 0:
2231
+ case "/":
2232
+ case "/dimensions":
2233
+ return /* @__PURE__ */ jsx(Dimensions, {
2234
+ ...routeProps
2235
+ });
2236
+ case "/overrides":
2237
+ return /* @__PURE__ */ jsx(Overrides, {
2238
+ ...routeProps
2239
+ });
2240
+ case "/overrides/add":
2241
+ return /* @__PURE__ */ jsx(AddOverride, {
2242
+ ...routeProps
2243
+ });
2244
+ case "/quirks":
2245
+ return /* @__PURE__ */ jsx(Quirks, {
2246
+ ...routeProps
2247
+ });
2248
+ case "/settings":
2249
+ return /* @__PURE__ */ jsx(Settings, {
2250
+ ...routeProps
2251
+ });
2252
+ default:
2253
+ return /* @__PURE__ */ jsx(NotFound, null);
2254
+ }
2255
+ };
2256
+ return /* @__PURE__ */ jsx(DevToolsSettingsContextProvider, {
2257
+ settings: props.settings,
2258
+ saveSettings: props.saveSettings
2259
+ }, /* @__PURE__ */ jsx(Theme, null), /* @__PURE__ */ jsx("div", {
2260
+ css: css15`
2261
+ display: grid;
2262
+ grid-template-columns: 200px auto;
2263
+ font-weight: var(--font-regular);
2264
+ font-size: var(--base-font-size);
2265
+ font-family: var(--base-font-family);
2266
+ line-height: var(--base-line-height);
2267
+ height: var(--min-height);
2268
+ min-width: var(--site-width);
2269
+ `
2270
+ }, /* @__PURE__ */ jsx(Menu, {
2271
+ ...props
2272
+ }), /* @__PURE__ */ jsx("main", {
2273
+ css: mainLayoutStyle
2274
+ }, /* @__PURE__ */ jsx(ConnectApiKey, {
2275
+ ...props
2276
+ }), component())));
2277
+ }
2278
+
2279
+ // src/components/EmbeddedContextDevTools.tsx
2280
+ import {
2281
+ Context as Context2,
2282
+ createDebugConsoleLogDrain
2283
+ } from "@uniformdev/context";
2284
+ import * as React7 from "react";
2285
+ function EmbeddedContextDevTools({ context, initialSettings }) {
2286
+ const contextValue = context != null ? context : typeof window !== "undefined" ? window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__ : void 0;
2287
+ const contextInstance = contextValue != null ? contextValue : new Context2({ manifest: { project: {} } });
2288
+ const [state, setState] = React7.useState({
2289
+ data: contextInstance.storage.data,
2290
+ manifest: contextInstance.manifest.data,
2291
+ scores: contextInstance.scores,
2292
+ personalizations: [],
2293
+ tests: []
2294
+ });
2295
+ const [settings, setSettings] = React7.useState(initialSettings != null ? initialSettings : {});
2296
+ React7.useEffect(() => {
2297
+ var _a;
2298
+ const drain = createDebugConsoleLogDrain((_a = settings.logLevel) != null ? _a : "none");
2299
+ contextInstance.events.on("log", drain);
2300
+ return () => {
2301
+ contextInstance.events.off("log", drain);
2302
+ };
2303
+ }, [settings, contextInstance]);
2304
+ React7.useEffect(() => {
2305
+ const onContextDataUpdated = () => {
2306
+ const quirkOverrides = applyQuirkOverrides({
2307
+ quirks: contextInstance.storage.data.quirks,
2308
+ quirkOverrides: settings.quirkOverrides
2309
+ });
2310
+ if (quirkOverrides) {
2311
+ console.log("Applying overridden quirks:", quirkOverrides);
2312
+ contextInstance.update({ quirks: quirkOverrides });
2313
+ }
2314
+ const overrideCommands = applyScoreOverrides({
2315
+ scores: contextInstance.scores,
2316
+ scoreOverrides: settings.scoreOverrides
2317
+ });
2318
+ if (overrideCommands.length) {
2319
+ console.log("Applying overridden scores:", overrideCommands);
2320
+ contextInstance.storage.updateData(overrideCommands);
2321
+ }
2322
+ setState((old) => ({
2323
+ ...old,
2324
+ scores: contextInstance.scores,
2325
+ data: contextInstance.storage.data,
2326
+ manifest: contextInstance.manifest.data
2327
+ }));
2328
+ };
2329
+ const onPersonalizationResult = (e) => {
2330
+ if (!e.changed)
2331
+ return;
2332
+ setState((old) => ({ ...old, personalizations: [...old.personalizations, e] }));
2333
+ };
2334
+ const onTestResult = (e) => {
2335
+ if (!e.variantAssigned)
2336
+ return;
2337
+ setState((old) => ({ ...old, tests: [...old.tests, e] }));
2338
+ };
2339
+ contextInstance.events.on("personalizationResult", onPersonalizationResult);
2340
+ contextInstance.events.on("testResult", onTestResult);
2341
+ contextInstance.storage.events.on("*", onContextDataUpdated);
2342
+ return () => {
2343
+ contextInstance.storage.events.off("*", onContextDataUpdated);
2344
+ contextInstance.events.off("personalizationResult", onPersonalizationResult);
2345
+ contextInstance.events.off("testResult", onTestResult);
2346
+ };
2347
+ }, [contextInstance, settings]);
2348
+ const actions = React7.useMemo(() => {
2349
+ const actions2 = {
2350
+ update: (up) => contextInstance.update(up),
2351
+ forget: () => contextInstance.forget(false),
2352
+ rawUpdate: (commands) => contextInstance.storage.updateData(commands)
2353
+ };
2354
+ return actions2;
2355
+ }, [contextInstance]);
2356
+ return contextValue ? /* @__PURE__ */ jsx(ContextDevTools, {
2357
+ state,
2358
+ actions,
2359
+ settings,
2360
+ saveSettings: setSettings
2361
+ }) : /* @__PURE__ */ jsx("p", null, "Unable to find Uniform Context. Ensure the devtools plugin is activated.");
2362
+ }
2363
+
2364
+ // src/components/ToggleEmbeddedContextDevTools.tsx
2365
+ import { css as css17 } from "@emotion/react";
2366
+ import * as React8 from "react";
2367
+
2368
+ // src/components/Buttons/EmbedToggleButton.tsx
2369
+ import { css as css16 } from "@emotion/react";
2370
+ var btnStyle3 = css16`
743
2371
  align-items: center;
744
2372
  border-radius: var(--rounded-full);
745
2373
  background: var(--brand-secondary-5);
@@ -765,4 +2393,54 @@ summary {
765
2393
  max-width: 100%;
766
2394
  height: auto;
767
2395
  }
768
- `,Dt=({...e})=>t("button",{type:"button",css:jt,...e},t("span",{hidden:!0},"Uniform devtools"),t("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},t("path",{d:"M13.325 3.05011L8.66741 20.4323L10.5993 20.9499L15.2568 3.56775L13.325 3.05011Z",fill:"currentColor"}),t("path",{d:"M7.61197 18.3608L8.97136 16.9124L8.97086 16.8933L3.87657 12.1121L8.66699 7.00798L7.20868 5.63928L1.04956 12.2017L7.61197 18.3608Z",fill:"currentColor"}),t("path",{d:"M16.388 18.3608L15.0286 16.9124L15.0291 16.8933L20.1234 12.1121L15.333 7.00798L16.7913 5.63928L22.9504 12.2017L16.388 18.3608Z",fill:"currentColor"})));function Eo(e){var a;let[r,n]=Rt.useState(!1);return((a=e.context)!=null?a:typeof window!="undefined"?window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__:void 0)?t("div",null,t(Y,null),t(Dt,{onClick:()=>n(i=>!i)}),r?t(xt,{...e}):null):t("p",null,"Unable to find Uniform Context. Ensure the devtools plugin is activated.")}export{kt as ContextDevTools,xt as EmbeddedContextDevTools,Eo as ToggleEmbeddedContextDevTools};
2396
+ `;
2397
+ var EmbedToggleButton = ({ ...props }) => {
2398
+ return /* @__PURE__ */ jsx("button", {
2399
+ type: "button",
2400
+ css: btnStyle3,
2401
+ ...props
2402
+ }, /* @__PURE__ */ jsx("span", {
2403
+ hidden: true
2404
+ }, "Uniform devtools"), /* @__PURE__ */ jsx("svg", {
2405
+ width: "24",
2406
+ height: "24",
2407
+ viewBox: "0 0 24 24",
2408
+ fill: "none",
2409
+ xmlns: "http://www.w3.org/2000/svg"
2410
+ }, /* @__PURE__ */ jsx("path", {
2411
+ d: "M13.325 3.05011L8.66741 20.4323L10.5993 20.9499L15.2568 3.56775L13.325 3.05011Z",
2412
+ fill: "currentColor"
2413
+ }), /* @__PURE__ */ jsx("path", {
2414
+ d: "M7.61197 18.3608L8.97136 16.9124L8.97086 16.8933L3.87657 12.1121L8.66699 7.00798L7.20868 5.63928L1.04956 12.2017L7.61197 18.3608Z",
2415
+ fill: "currentColor"
2416
+ }), /* @__PURE__ */ jsx("path", {
2417
+ d: "M16.388 18.3608L15.0286 16.9124L15.0291 16.8933L20.1234 12.1121L15.333 7.00798L16.7913 5.63928L22.9504 12.2017L16.388 18.3608Z",
2418
+ fill: "currentColor"
2419
+ })));
2420
+ };
2421
+
2422
+ // src/components/ToggleEmbeddedContextDevTools.tsx
2423
+ function ToggleEmbeddedContextDevTools(props) {
2424
+ var _a;
2425
+ const [devtoolsOpen, setDevtoolsOpen] = React8.useState(false);
2426
+ const contextValue = (_a = props.context) != null ? _a : typeof window !== "undefined" ? window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__ : void 0;
2427
+ return contextValue ? /* @__PURE__ */ jsx("div", null, /* @__PURE__ */ jsx(Theme, null), /* @__PURE__ */ jsx(EmbedToggleButton, {
2428
+ onClick: () => setDevtoolsOpen((prev) => !prev)
2429
+ }), devtoolsOpen ? /* @__PURE__ */ jsx("div", {
2430
+ css: css17`
2431
+ box-shadow: var(--shadow-base);
2432
+ position: fixed;
2433
+ bottom: 82px;
2434
+ right: var(--spacing-base);
2435
+ z-index: var(--z-10);
2436
+ max-width: var(--site-width);
2437
+ `
2438
+ }, /* @__PURE__ */ jsx(EmbeddedContextDevTools, {
2439
+ ...props
2440
+ })) : null) : /* @__PURE__ */ jsx("p", null, "Unable to find Uniform Context. Ensure the devtools plugin is activated.");
2441
+ }
2442
+ export {
2443
+ ContextDevTools,
2444
+ EmbeddedContextDevTools,
2445
+ ToggleEmbeddedContextDevTools
2446
+ };