@picked/vite-plugin-picked 0.0.1-dev.1787019239195 → 0.0.1-dev.1787537193674

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
@@ -2,29 +2,30 @@ import { existsSync as e } from "node:fs";
2
2
  import { join as t, resolve as n } from "node:path";
3
3
  import { createClientHeaders as r, fetchExperienceContent as i, fetchProject as a } from "@picked/delivery-api-client";
4
4
  import { generate as o } from "@picked/typegen";
5
- import { loadPickedConfig as s, loadResolvedPickedConfig as c } from "@picked/config";
6
- import { appendFile as l, mkdir as u, readFile as d, writeFile as f } from "node:fs/promises";
5
+ import { detectHostEnvironment as s, isTelemetryEnabled as c, isTelemetryForcedOffByEnvironment as l, loadPickedConfig as u, loadResolvedPickedConfig as d } from "@picked/config";
6
+ import { appendFile as f, mkdir as p, readFile as m, writeFile as h } from "node:fs/promises";
7
+ import { createSpanId as g, createTelemetryEmitter as _, createTraceId as v, toUnixNano as y } from "@picked/telemetry";
7
8
  //#region \0@oxc-project+runtime@0.142.0/helpers/esm/taggedTemplateLiteral.js
8
- function p(e, t) {
9
+ function b(e, t) {
9
10
  return t ||= e.slice(0), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } }));
10
11
  }
11
12
  //#endregion
12
13
  //#region src/launcher.ts
13
- var m;
14
- function h(e) {
14
+ var x;
15
+ function S(e) {
15
16
  let t = JSON.stringify(e), n = e.length > 0 ? e.map((e) => `
16
17
  <div class="feature-row">
17
18
  <label>
18
- <input type="checkbox" data-feature-id="${_(e.id)}" checked>
19
- <span class="feature-name">${g(e.name)}</span>
20
- <span class="feature-id">${g(e.id)}</span>
19
+ <input type="checkbox" data-feature-id="${w(e.id)}" checked>
20
+ <span class="feature-name">${C(e.name)}</span>
21
+ <span class="feature-id">${C(e.id)}</span>
21
22
  </label>
22
- <select data-value-for="${_(e.id)}">
23
+ <select data-value-for="${w(e.id)}">
23
24
  <option value="true" selected>true</option>
24
25
  <option value="false">false</option>
25
26
  </select>
26
27
  </div>`).join("") : "<p class=\"text no-features\">No features configured for this project.</p>";
27
- return String.raw(m ||= p([
28
+ return String.raw(x ||= b([
28
29
  "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <meta name=\"robots\" content=\"noindex, nofollow\">\n <title>Picked</title>\n <style>\n main {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n display: grid;\n align-items: center;\n justify-content: center;\n font-family: monospace;\n color: #4A4A4A\n }\n\n .wrap {\n padding-left: 1.5rem;\n padding-right: 1.5rem;\n max-width: 480px;\n width: 100%;\n }\n\n .title {\n font-size: 1.125rem;\n font-weight: 700;\n margin-bottom: 0;\n }\n\n .text {\n margin-top: .5rem;\n font-size: .875rem\n }\n\n .text a {\n color: #4A4A4A;\n text-decoration: none;\n }\n\n .text a:hover {\n cursor: pointer;\n text-decoration: underline\n }\n\n .preview-form {\n margin-top: 2rem;\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n }\n\n .preview-input {\n padding: 0.5rem;\n border: 1px solid #4A4A4A;\n border-radius: 0;\n font-family: monospace;\n }\n\n .preview-button {\n padding: 0.5rem;\n background: #4A4A4A;\n color: white;\n border: none;\n border-radius: 0;\n cursor: pointer;\n font-family: monospace;\n }\n\n .preview-button:hover {\n opacity: 0.9;\n }\n\n .buttons {\n display: grid;\n gap: 0.5em;\n grid-template-columns: 1fr 1fr;\n }\n\n #copy-status {\n font-size: 1em;\n text-align: right;\n margin-top: 0.5em;\n }\n\n .features-section {\n margin-top: 1.5rem;\n }\n\n .features-label {\n font-weight: 700;\n font-size: .875rem;\n margin-bottom: 0.5rem;\n }\n\n .feature-row {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 0.5rem;\n padding: 0.25rem 0;\n }\n\n .feature-row label {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n cursor: pointer;\n min-width: 0;\n flex: 1;\n }\n\n .feature-name {\n font-size: .875rem;\n }\n\n .feature-id {\n font-size: .75rem;\n color: #888;\n }\n\n .feature-row select {\n font-family: monospace;\n font-size: .75rem;\n padding: 0.125rem 0.25rem;\n border: 1px solid #4A4A4A;\n border-radius: 0;\n background: white;\n flex-shrink: 0;\n }\n\n .no-features {\n color: #888;\n font-style: italic;\n }\n\n .url-history {\n margin-top: 0.5rem;\n font-size: .75rem;\n }\n\n .url-history-item {\n display: flex;\n align-items: center;\n gap: 0.25rem;\n padding: 0.125rem 0;\n }\n\n .url-history-item button {\n background: none;\n border: none;\n cursor: pointer;\n font-family: monospace;\n font-size: .75rem;\n color: #888;\n padding: 0;\n }\n\n .url-history-item button.url-link {\n color: #4A4A4A;\n text-decoration: none;\n text-align: left;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n flex: 1;\n min-width: 0;\n }\n\n .url-history-item button.url-link:hover {\n text-decoration: underline;\n }\n\n .url-history-item button.url-delete:hover {\n color: #b71c1c;\n }\n\n @media (min-width: 640px) {\n .title {\n font-size: 1.25rem\n }\n\n .text {\n font-size: 1rem\n }\n }\n </style>\n</head>\n<body>\n\n<main>\n <div class=\"wrap\">\n <p class=\"title\">Picked</p>\n <p class=\"text\">\n Learn more at\n <a href=\"https://picked.app\">\n https://picked.app\n </a>\n </p>\n <div class=\"preview-form\">\n <input type=\"text\" id=\"url-input\" pattern=\"^(https?://)?.+\" placeholder=\"Enter preview URL\" required\n class=\"preview-input\">\n <div id=\"url-history\" class=\"url-history\"></div>\n <div class=\"features-section\">\n <p class=\"features-label\">Features</p>\n ",
29
30
  "\n </div>\n <div class=\"buttons\">\n <button type=\"button\" class=\"preview-button\" id=\"copy-btn\">Copy</button>\n <button type=\"button\" class=\"preview-button\" id=\"preview-btn\">Preview</button>\n </div>\n <p class=\"text\" id=\"copy-status\" aria-live=\"polite\" style=\"visibility:hidden;\">\n &nbsp;\n </p>\n </div>\n </div>\n\n <script>\n var FEATURES = ",
30
31
  ";\n var STORAGE_KEY_URL = 'picked-launcher-url';\n var STORAGE_KEY_HISTORY = 'picked-launcher-history';\n var STORAGE_KEY_SELECTIONS = 'picked-launcher-selections';\n\n function getUrlInput() {\n return document.getElementById('url-input');\n }\n\n // URL history\n function getHistory() {\n try {\n var raw = localStorage.getItem(STORAGE_KEY_HISTORY);\n if (!raw) return [];\n var parsed = JSON.parse(raw);\n return Array.isArray(parsed) ? parsed : [];\n } catch (e) {\n return [];\n }\n }\n\n function saveHistory(history) {\n localStorage.setItem(STORAGE_KEY_HISTORY, JSON.stringify(history));\n }\n\n function addToHistory(url) {\n var history = getHistory().filter(function(h) { return h !== url; });\n history.unshift(url);\n if (history.length > 10) history = history.slice(0, 10);\n saveHistory(history);\n renderHistory();\n }\n\n function removeFromHistory(url) {\n var history = getHistory().filter(function(h) { return h !== url; });\n saveHistory(history);\n renderHistory();\n }\n\n function renderHistory() {\n var container = document.getElementById('url-history');\n if (!container) return;\n var history = getHistory();\n if (history.length === 0) {\n container.innerHTML = '';\n return;\n }\n container.innerHTML = history.map(function(url) {\n return '<div class=\"url-history-item\">' +\n '<button type=\"button\" class=\"url-link\" data-history-url=\"' + escapeAttr(url) + '\">' + escapeHtml(url) + '</button>' +\n '<button type=\"button\" class=\"url-delete\" data-history-delete=\"' + escapeAttr(url) + '\">x</button>' +\n '</div>';\n }).join('');\n }\n\n // Feature selection persistence\n function getSelections() {\n try {\n var raw = localStorage.getItem(STORAGE_KEY_SELECTIONS);\n if (!raw) return {};\n var parsed = JSON.parse(raw);\n return typeof parsed === 'object' && parsed !== null ? parsed : {};\n } catch (e) {\n return {};\n }\n }\n\n function saveSelections() {\n var selections = {};\n FEATURES.forEach(function(f) {\n var checkbox = document.querySelector('input[data-feature-id=\"' + f.id + '\"]');\n var select = document.querySelector('select[data-value-for=\"' + f.id + '\"]');\n if (checkbox && select) {\n selections[f.id] = { checked: checkbox.checked, value: select.value };\n }\n });\n localStorage.setItem(STORAGE_KEY_SELECTIONS, JSON.stringify(selections));\n }\n\n function restoreSelections() {\n var selections = getSelections();\n FEATURES.forEach(function(f) {\n var saved = selections[f.id];\n if (!saved) return;\n var checkbox = document.querySelector('input[data-feature-id=\"' + f.id + '\"]');\n var select = document.querySelector('select[data-value-for=\"' + f.id + '\"]');\n if (checkbox) checkbox.checked = saved.checked;\n if (select) select.value = saved.value;\n });\n }\n\n function escapeHtml(str) {\n var div = document.createElement('div');\n div.textContent = str;\n return div.innerHTML;\n }\n\n function escapeAttr(str) {\n return str.replace(/&/g, '&amp;').replace(/\"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');\n }\n\n function buildTargetUrl(inputValue) {\n var value = inputValue;\n if (!value.startsWith('http://') && !value.startsWith('https://')) {\n value = 'https://' + value;\n }\n var hostname = window.location.hostname;\n var subdomain = hostname.split('.').length > 2 ? hostname.split('.')[0] : '';\n var target = value;\n var sep = target.includes('?') ? '&' : '?';\n if (subdomain) {\n target = target + sep + 'cvly_env=' + encodeURIComponent(subdomain);\n sep = '&';\n }\n FEATURES.forEach(function(f) {\n var checkbox = document.querySelector('input[data-feature-id=\"' + f.id + '\"]');\n var select = document.querySelector('select[data-value-for=\"' + f.id + '\"]');\n if (checkbox && checkbox.checked && select) {\n target = target + sep + 'picked-feature=' + encodeURIComponent(f.id + ':' + select.value);\n sep = '&';\n }\n });\n return target;\n }\n\n function showCopyStatus(message, success) {\n var el = document.getElementById('copy-status');\n if (!el) return;\n el.textContent = message;\n el.style.visibility = 'visible';\n el.style.color = success ? '#2e7d32' : '#b71c1c';\n setTimeout(function() {\n el.style.visibility = 'hidden';\n }, 2000);\n }\n\n // Init\n window.addEventListener('load', function() {\n var input = getUrlInput();\n var savedUrl = localStorage.getItem(STORAGE_KEY_URL);\n if (savedUrl && input) {\n input.value = savedUrl;\n }\n renderHistory();\n restoreSelections();\n });\n\n // Delegate click events\n document.addEventListener('click', function(e) {\n var target = e.target;\n\n // History URL click\n var historyUrl = target.getAttribute('data-history-url');\n if (historyUrl) {\n var input = getUrlInput();\n if (input) input.value = historyUrl;\n return;\n }\n\n // History delete click\n var deleteUrl = target.getAttribute('data-history-delete');\n if (deleteUrl) {\n removeFromHistory(deleteUrl);\n return;\n }\n });\n\n // Feature change persistence\n document.addEventListener('change', function(e) {\n var target = e.target;\n if (target.getAttribute('data-feature-id') || target.getAttribute('data-value-for')) {\n saveSelections();\n }\n });\n\n // Copy button\n document.getElementById('copy-btn').addEventListener('click', function() {\n var input = getUrlInput();\n if (!input || !input.value) return;\n localStorage.setItem(STORAGE_KEY_URL, input.value);\n addToHistory(input.value);\n saveSelections();\n var target = buildTargetUrl(input.value);\n navigator.clipboard.writeText(target).then(function() {\n showCopyStatus('Preview URL copied to clipboard', true);\n });\n });\n\n // Preview button\n document.getElementById('preview-btn').addEventListener('click', function() {\n var input = getUrlInput();\n if (!input || !input.value) return;\n localStorage.setItem(STORAGE_KEY_URL, input.value);\n addToHistory(input.value);\n saveSelections();\n var target = buildTargetUrl(input.value);\n window.location.href = target;\n });\n <\/script>\n</main>\n</body>\n</html>"
@@ -34,46 +35,46 @@ function h(e) {
34
35
  ";\n var STORAGE_KEY_URL = 'picked-launcher-url';\n var STORAGE_KEY_HISTORY = 'picked-launcher-history';\n var STORAGE_KEY_SELECTIONS = 'picked-launcher-selections';\n\n function getUrlInput() {\n return document.getElementById('url-input');\n }\n\n // URL history\n function getHistory() {\n try {\n var raw = localStorage.getItem(STORAGE_KEY_HISTORY);\n if (!raw) return [];\n var parsed = JSON.parse(raw);\n return Array.isArray(parsed) ? parsed : [];\n } catch (e) {\n return [];\n }\n }\n\n function saveHistory(history) {\n localStorage.setItem(STORAGE_KEY_HISTORY, JSON.stringify(history));\n }\n\n function addToHistory(url) {\n var history = getHistory().filter(function(h) { return h !== url; });\n history.unshift(url);\n if (history.length > 10) history = history.slice(0, 10);\n saveHistory(history);\n renderHistory();\n }\n\n function removeFromHistory(url) {\n var history = getHistory().filter(function(h) { return h !== url; });\n saveHistory(history);\n renderHistory();\n }\n\n function renderHistory() {\n var container = document.getElementById('url-history');\n if (!container) return;\n var history = getHistory();\n if (history.length === 0) {\n container.innerHTML = '';\n return;\n }\n container.innerHTML = history.map(function(url) {\n return '<div class=\"url-history-item\">' +\n '<button type=\"button\" class=\"url-link\" data-history-url=\"' + escapeAttr(url) + '\">' + escapeHtml(url) + '</button>' +\n '<button type=\"button\" class=\"url-delete\" data-history-delete=\"' + escapeAttr(url) + '\">x</button>' +\n '</div>';\n }).join('');\n }\n\n // Feature selection persistence\n function getSelections() {\n try {\n var raw = localStorage.getItem(STORAGE_KEY_SELECTIONS);\n if (!raw) return {};\n var parsed = JSON.parse(raw);\n return typeof parsed === 'object' && parsed !== null ? parsed : {};\n } catch (e) {\n return {};\n }\n }\n\n function saveSelections() {\n var selections = {};\n FEATURES.forEach(function(f) {\n var checkbox = document.querySelector('input[data-feature-id=\"' + f.id + '\"]');\n var select = document.querySelector('select[data-value-for=\"' + f.id + '\"]');\n if (checkbox && select) {\n selections[f.id] = { checked: checkbox.checked, value: select.value };\n }\n });\n localStorage.setItem(STORAGE_KEY_SELECTIONS, JSON.stringify(selections));\n }\n\n function restoreSelections() {\n var selections = getSelections();\n FEATURES.forEach(function(f) {\n var saved = selections[f.id];\n if (!saved) return;\n var checkbox = document.querySelector('input[data-feature-id=\"' + f.id + '\"]');\n var select = document.querySelector('select[data-value-for=\"' + f.id + '\"]');\n if (checkbox) checkbox.checked = saved.checked;\n if (select) select.value = saved.value;\n });\n }\n\n function escapeHtml(str) {\n var div = document.createElement('div');\n div.textContent = str;\n return div.innerHTML;\n }\n\n function escapeAttr(str) {\n return str.replace(/&/g, '&amp;').replace(/\"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');\n }\n\n function buildTargetUrl(inputValue) {\n var value = inputValue;\n if (!value.startsWith('http://') && !value.startsWith('https://')) {\n value = 'https://' + value;\n }\n var hostname = window.location.hostname;\n var subdomain = hostname.split('.').length > 2 ? hostname.split('.')[0] : '';\n var target = value;\n var sep = target.includes('?') ? '&' : '?';\n if (subdomain) {\n target = target + sep + 'cvly_env=' + encodeURIComponent(subdomain);\n sep = '&';\n }\n FEATURES.forEach(function(f) {\n var checkbox = document.querySelector('input[data-feature-id=\"' + f.id + '\"]');\n var select = document.querySelector('select[data-value-for=\"' + f.id + '\"]');\n if (checkbox && checkbox.checked && select) {\n target = target + sep + 'picked-feature=' + encodeURIComponent(f.id + ':' + select.value);\n sep = '&';\n }\n });\n return target;\n }\n\n function showCopyStatus(message, success) {\n var el = document.getElementById('copy-status');\n if (!el) return;\n el.textContent = message;\n el.style.visibility = 'visible';\n el.style.color = success ? '#2e7d32' : '#b71c1c';\n setTimeout(function() {\n el.style.visibility = 'hidden';\n }, 2000);\n }\n\n // Init\n window.addEventListener('load', function() {\n var input = getUrlInput();\n var savedUrl = localStorage.getItem(STORAGE_KEY_URL);\n if (savedUrl && input) {\n input.value = savedUrl;\n }\n renderHistory();\n restoreSelections();\n });\n\n // Delegate click events\n document.addEventListener('click', function(e) {\n var target = e.target;\n\n // History URL click\n var historyUrl = target.getAttribute('data-history-url');\n if (historyUrl) {\n var input = getUrlInput();\n if (input) input.value = historyUrl;\n return;\n }\n\n // History delete click\n var deleteUrl = target.getAttribute('data-history-delete');\n if (deleteUrl) {\n removeFromHistory(deleteUrl);\n return;\n }\n });\n\n // Feature change persistence\n document.addEventListener('change', function(e) {\n var target = e.target;\n if (target.getAttribute('data-feature-id') || target.getAttribute('data-value-for')) {\n saveSelections();\n }\n });\n\n // Copy button\n document.getElementById('copy-btn').addEventListener('click', function() {\n var input = getUrlInput();\n if (!input || !input.value) return;\n localStorage.setItem(STORAGE_KEY_URL, input.value);\n addToHistory(input.value);\n saveSelections();\n var target = buildTargetUrl(input.value);\n navigator.clipboard.writeText(target).then(function() {\n showCopyStatus('Preview URL copied to clipboard', true);\n });\n });\n\n // Preview button\n document.getElementById('preview-btn').addEventListener('click', function() {\n var input = getUrlInput();\n if (!input || !input.value) return;\n localStorage.setItem(STORAGE_KEY_URL, input.value);\n addToHistory(input.value);\n saveSelections();\n var target = buildTargetUrl(input.value);\n window.location.href = target;\n });\n <\/script>\n</main>\n</body>\n</html>"
35
36
  ]), n, t);
36
37
  }
37
- function g(e) {
38
+ function C(e) {
38
39
  return e.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll("\"", "&quot;");
39
40
  }
40
- function _(e) {
41
+ function w(e) {
41
42
  return e.replaceAll("&", "&amp;").replaceAll("\"", "&quot;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
42
43
  }
43
44
  //#endregion
44
45
  //#region src/log.ts
45
- var v = "picked", y = "\x1B[0m";
46
- function b() {
46
+ var T = "picked", ee = "\x1B[0m";
47
+ function te() {
47
48
  let e = process.env.NO_COLOR;
48
49
  return e === "1" || e === "true";
49
50
  }
50
- function x(e) {
51
- return (t) => b() ? t : `${e}${t}${y}`;
51
+ function E(e) {
52
+ return (t) => te() ? t : `${e}${t}${ee}`;
52
53
  }
53
- var S = [
54
+ var D = [
54
55
  "debug",
55
56
  "info",
56
57
  "warn",
57
58
  "error",
58
59
  "silent"
59
- ], C = {
60
+ ], O = {
60
61
  debug: {
61
- color: x("\x1B[2m"),
62
+ color: E("\x1B[2m"),
62
63
  log: console.debug,
63
64
  enabled: !1
64
65
  },
65
66
  info: {
66
- color: x("\x1B[36m"),
67
+ color: E("\x1B[36m"),
67
68
  log: console.log,
68
69
  enabled: !0
69
70
  },
70
71
  warn: {
71
- color: x("\x1B[33m"),
72
+ color: E("\x1B[33m"),
72
73
  log: console.warn,
73
74
  enabled: !0
74
75
  },
75
76
  error: {
76
- color: x("\x1B[31m"),
77
+ color: E("\x1B[31m"),
77
78
  log: console.error,
78
79
  enabled: !0
79
80
  },
@@ -82,52 +83,52 @@ var S = [
82
83
  enabled: !1
83
84
  }
84
85
  };
85
- function w(e, t) {
86
- return `${(/* @__PURE__ */ new Date()).toLocaleTimeString()} [${t ? `${v}:${t}` : v}] ${e}`;
86
+ function ne(e, t) {
87
+ return `${(/* @__PURE__ */ new Date()).toLocaleTimeString()} [${t ? `${T}:${t}` : T}] ${e}`;
87
88
  }
88
- function T(e, t, n, r) {
89
+ function k(e, t, n, r) {
89
90
  if (!e.enabled) return;
90
- let i = w(t, r);
91
+ let i = ne(t, r);
91
92
  e.log(e.color ? e.color(i) : i), n !== void 0 && e.log(n);
92
93
  }
93
- function E(e) {
94
- let t = C[e], n = /* @__PURE__ */ new Set();
94
+ function A(e) {
95
+ let t = O[e], n = /* @__PURE__ */ new Set();
95
96
  return Object.assign((e, n, r) => {
96
- T(t, e, n, r);
97
+ k(t, e, n, r);
97
98
  }, { once(e, r, i) {
98
- !t.enabled || n.has(e) || (n.add(e), T(t, e, r, i));
99
+ !t.enabled || n.has(e) || (n.add(e), k(t, e, r, i));
99
100
  } });
100
101
  }
101
- function D(e) {
102
- let t = S.indexOf(e);
102
+ function re(e) {
103
+ let t = D.indexOf(e);
103
104
  if (t === -1) {
104
- T(C.error, `invalid log level: ${e}`);
105
+ k(O.error, `invalid log level: ${e}`);
105
106
  return;
106
107
  }
107
- for (let [e, n] of S.entries()) C[n].enabled = e >= t;
108
+ for (let [e, n] of D.entries()) O[n].enabled = e >= t;
108
109
  }
109
- var O = x("\x1B[34m"), k = x("\x1B[36m");
110
- function A() {
110
+ var j = E("\x1B[34m"), M = E("\x1B[36m");
111
+ function ie() {
111
112
  let e = [
112
- ` ${O("_")} ${k("_")} _ _ _`,
113
- `${O("(_)")} ${k("(_)")} _ __(_)__| |_____ __| |`,
114
- ` ${O("_")} ${O("_")} | '_ \\ / _| / / -_) _\` |`,
115
- `${O("(_)")} ${O("(_)")} | .__/_\\__|_\\_\\___\\__,_|`,
113
+ ` ${j("_")} ${M("_")} _ _ _`,
114
+ `${j("(_)")} ${M("(_)")} _ __(_)__| |_____ __| |`,
115
+ ` ${j("_")} ${j("_")} | '_ \\ / _| / / -_) _\` |`,
116
+ `${j("(_)")} ${j("(_)")} | .__/_\\__|_\\_\\___\\__,_|`,
116
117
  " |_|\n "
117
118
  ];
118
119
  console.log(e.join("\n"));
119
120
  }
120
- var j = {
121
- banner: A,
122
- debug: E("debug"),
123
- info: E("info"),
124
- warn: E("warn"),
125
- error: E("error"),
126
- setLevel: D
121
+ var N = {
122
+ banner: ie,
123
+ debug: A("debug"),
124
+ info: A("info"),
125
+ warn: A("warn"),
126
+ error: A("error"),
127
+ setLevel: re
127
128
  };
128
129
  //#endregion
129
130
  //#region src/middleware.ts
130
- function ee(e) {
131
+ function ae(e) {
131
132
  return (t, n, r) => {
132
133
  if (t.method !== "GET") {
133
134
  r();
@@ -144,28 +145,28 @@ function ee(e) {
144
145
  }
145
146
  //#endregion
146
147
  //#region src/gitignore.ts
147
- var M = ".picked/";
148
- async function te(n, r) {
148
+ var P = ".picked/";
149
+ async function oe(n, r) {
149
150
  if (r) return;
150
151
  let i = t(n, ".gitignore");
151
152
  if (!e(i)) {
152
- await f(i, `${M}
153
+ await h(i, `${P}
153
154
  `);
154
155
  return;
155
156
  }
156
- let a = await d(i, "utf8");
157
- if (ne(a)) return;
158
- let o = `${a.length > 0 && !a.endsWith("\n") ? "\n" : ""}${M}
157
+ let a = await m(i, "utf8");
158
+ if (se(a)) return;
159
+ let o = `${a.length > 0 && !a.endsWith("\n") ? "\n" : ""}${P}
159
160
  `;
160
- await l(i, o);
161
+ await f(i, o);
161
162
  }
162
- function ne(e) {
163
- return e.split(/\r?\n/).map((e) => e.trim()).some((e) => e === M || e === ".picked");
163
+ function se(e) {
164
+ return e.split(/\r?\n/).map((e) => e.trim()).some((e) => e === P || e === ".picked");
164
165
  }
165
166
  //#endregion
166
167
  //#region src/retry.ts
167
- var N = 6, re = 5e3;
168
- function P(e) {
168
+ var F = 6, ce = 5e3;
169
+ function I(e) {
169
170
  let t;
170
171
  try {
171
172
  t = new URL(e).hostname;
@@ -174,12 +175,12 @@ function P(e) {
174
175
  }
175
176
  return t === "localhost" || t === "127.0.0.1" || t === "::1" || t === "[::1]" || t !== "api.picked.app" && t.endsWith(".picked.app");
176
177
  }
177
- function ie(e) {
178
+ function le(e) {
178
179
  return new Promise((t) => {
179
180
  setTimeout(t, e);
180
181
  });
181
182
  }
182
- async function F(e, t) {
183
+ async function L(e, t) {
183
184
  let n = null, r = null;
184
185
  try {
185
186
  n = await e();
@@ -187,9 +188,9 @@ async function F(e, t) {
187
188
  r = e;
188
189
  }
189
190
  if (n !== null) return n;
190
- for (let i = 1; i <= N; i++) {
191
- let a = re * 2 ** (i - 1);
192
- t(i, N, a), await ie(a), r = null;
191
+ for (let i = 1; i <= F; i++) {
192
+ let a = ce * 2 ** (i - 1);
193
+ t(i, F, a), await le(a), r = null;
193
194
  try {
194
195
  n = await e();
195
196
  } catch (e) {
@@ -202,13 +203,13 @@ async function F(e, t) {
202
203
  }
203
204
  //#endregion
204
205
  //#region src/util.ts
205
- function I(e) {
206
+ function R(e) {
206
207
  return Array.isArray(e) ? e : [];
207
208
  }
208
209
  //#endregion
209
210
  //#region src/prefetch.ts
210
- var L = 2;
211
- function R(e) {
211
+ var z = 2;
212
+ function B(e) {
212
213
  let n = t(e, ".picked");
213
214
  return {
214
215
  pickedDir: n,
@@ -217,75 +218,75 @@ function R(e) {
217
218
  experiencesDir: t(n, "experiences")
218
219
  };
219
220
  }
220
- async function ae(t) {
221
+ async function ue(t) {
221
222
  if (!e(t)) return null;
222
223
  try {
223
- let e = await d(t, "utf8"), n = JSON.parse(e);
224
- return oe(n) ? n : null;
224
+ let e = await m(t, "utf8"), n = JSON.parse(e);
225
+ return de(n) ? n : null;
225
226
  } catch {
226
227
  return null;
227
228
  }
228
229
  }
229
- function oe(e) {
230
+ function de(e) {
230
231
  return !(typeof e != "object" || !e || !("version" in e) || typeof e.version != "number" || !("projectVersionId" in e) || typeof e.projectVersionId != "string" || !("workspaceId" in e) || typeof e.workspaceId != "string" || !("experiences" in e) || !Array.isArray(e.experiences));
231
232
  }
232
- function z(e) {
233
+ function V(e) {
233
234
  let t = /* @__PURE__ */ new Set();
234
- for (let n of I(e.steps)) n.layoutContentId && t.add(n.id);
235
+ for (let n of R(e.steps)) n.layoutContentId && t.add(n.id);
235
236
  if (t.size === 0) return [];
236
237
  let n = [];
237
- for (let r of I(e.experiences)) I(r.nodes).some((e) => e.type === "step" && t.has(e.stepId)) && n.push(r.id);
238
+ for (let r of R(e.experiences)) R(r.nodes).some((e) => e.type === "step" && t.has(e.stepId)) && n.push(r.id);
238
239
  return n;
239
240
  }
240
- async function B(n) {
241
- let { apiUrl: r, projectId: i, projectRoot: a, headers: o, previewToken: s, reuseWhenUnchanged: c = !0 } = n, l = R(a), d = await H(r, i, o, s), p = z(d);
242
- if (await u(l.experiencesDir, { recursive: !0 }), await f(l.projectConfigPath, JSON.stringify(d, null, 2)), c) {
243
- let t = await ae(l.manifestPath);
244
- if (t?.version === L && t.projectVersionId === d.versionId && t.workspaceId === d.workspaceId) {
245
- let n = V(l, p);
241
+ async function H(n) {
242
+ let { apiUrl: r, projectId: i, projectRoot: a, headers: o, previewToken: s, reuseWhenUnchanged: c = !0 } = n, l = B(a), u = await fe(r, i, o, s), d = V(u);
243
+ if (await p(l.experiencesDir, { recursive: !0 }), await h(l.projectConfigPath, JSON.stringify(u, null, 2)), c) {
244
+ let t = await ue(l.manifestPath);
245
+ if (t?.version === z && t.projectVersionId === u.versionId && t.workspaceId === u.workspaceId) {
246
+ let n = U(l, d);
246
247
  if (Object.values(n).every((t) => e(t))) return {
247
- config: d,
248
+ config: u,
248
249
  manifest: t,
249
250
  experienceContentPaths: n
250
251
  };
251
- j.info("a manifest-referenced content file is missing; refetching every experience");
252
+ N.info("a manifest-referenced content file is missing; refetching every experience");
252
253
  }
253
254
  }
254
- let m = (/* @__PURE__ */ new Date()).toISOString(), h = [];
255
- for (let e of p) {
256
- let n = await U(r, i, e, o, s), a = t(l.experiencesDir, `${e}.json`);
257
- await f(a, JSON.stringify(n, null, 2)), h.push({
255
+ let f = (/* @__PURE__ */ new Date()).toISOString(), m = [];
256
+ for (let e of d) {
257
+ let n = await pe(r, i, e, o, s), a = t(l.experiencesDir, `${e}.json`);
258
+ await h(a, JSON.stringify(n, null, 2)), m.push({
258
259
  id: e,
259
- fetchedAt: m
260
+ fetchedAt: f
260
261
  });
261
262
  }
262
263
  let g = {
263
- version: L,
264
- fetchedAt: m,
265
- projectVersionId: d.versionId,
266
- workspaceId: d.workspaceId,
267
- projectId: d.id,
268
- experiences: h
264
+ version: z,
265
+ fetchedAt: f,
266
+ projectVersionId: u.versionId,
267
+ workspaceId: u.workspaceId,
268
+ projectId: u.id,
269
+ experiences: m
269
270
  };
270
- return await f(l.manifestPath, JSON.stringify(g, null, 2)), {
271
- config: d,
271
+ return await h(l.manifestPath, JSON.stringify(g, null, 2)), {
272
+ config: u,
272
273
  manifest: g,
273
- experienceContentPaths: V(l, p)
274
+ experienceContentPaths: U(l, d)
274
275
  };
275
276
  }
276
- function V(e, n) {
277
+ function U(e, n) {
277
278
  let r = {};
278
279
  for (let i of n) r[i] = t(e.experiencesDir, `${i}.json`);
279
280
  return r;
280
281
  }
281
- async function H(e, t, n, r) {
282
+ async function fe(e, t, n, r) {
282
283
  let i = () => a(e, t, {
283
284
  headers: n,
284
285
  previewToken: r
285
286
  }), o;
286
287
  try {
287
- o = P(e) ? await F(i, (e, t, n) => {
288
- j.info(`project config not ready, retrying in ${(n / 1e3).toString()}s (${e.toString()}/${t.toString()})`);
288
+ o = I(e) ? await L(i, (e, t, n) => {
289
+ N.info(`project config not ready, retrying in ${(n / 1e3).toString()}s (${e.toString()}/${t.toString()})`);
289
290
  }) : await i();
290
291
  } catch (n) {
291
292
  throw Error(`[picked] Build-time fetch of project config failed for "${t}" at ${e}: ${W(n)}`);
@@ -293,7 +294,7 @@ async function H(e, t, n, r) {
293
294
  if (!o) throw Error(`[picked] Build-time fetch of project config returned no usable response for "${t}" at ${e}. Confirm the API is reachable and the project ID is correct.`);
294
295
  return o;
295
296
  }
296
- async function U(e, t, n, r, a) {
297
+ async function pe(e, t, n, r, a) {
297
298
  let o;
298
299
  try {
299
300
  o = await i(e, t, n, {
@@ -316,13 +317,99 @@ function W(e) {
316
317
  }
317
318
  }
318
319
  //#endregion
320
+ //#region src/telemetry.ts
321
+ var me = "https://production.otel.picked.app/v1/traces", he = /* @__PURE__ */ new Set(["resolveId", "load"]);
322
+ function ge(e = v()) {
323
+ let t = g(), n = Date.now(), r = [], i = /* @__PURE__ */ new Map();
324
+ return {
325
+ record: (n, a) => {
326
+ if (he.has(n)) {
327
+ let e = i.get(n) ?? {
328
+ calls: 0,
329
+ totalMs: 0
330
+ };
331
+ i.set(n, {
332
+ calls: e.calls + 1,
333
+ totalMs: e.totalMs + a
334
+ });
335
+ return;
336
+ }
337
+ let o = Date.now();
338
+ r.push({
339
+ name: `picked.vite.${n}`,
340
+ traceId: e,
341
+ spanId: g(),
342
+ parentSpanId: t,
343
+ startTimeUnixNano: y(o - a),
344
+ endTimeUnixNano: y(o),
345
+ attributes: { "picked.vite.hook": n },
346
+ status: "ok"
347
+ });
348
+ },
349
+ flush: async (a) => {
350
+ let o = {};
351
+ for (let [e, t] of i) o[`picked.vite.${e}.calls`] = t.calls, o[`picked.vite.${e}.total_ms`] = Math.round(t.totalMs);
352
+ let c = s();
353
+ r.push({
354
+ name: "picked.vite.build",
355
+ traceId: e,
356
+ spanId: t,
357
+ startTimeUnixNano: y(n),
358
+ endTimeUnixNano: y(Date.now()),
359
+ attributes: {
360
+ "picked.env.provider": c.provider,
361
+ "picked.env.ci": c.ci,
362
+ ...a,
363
+ ...o
364
+ },
365
+ status: "ok"
366
+ });
367
+ try {
368
+ let e = _({
369
+ endpoint: me,
370
+ resource: { "service.name": "picked-vite-plugin" },
371
+ headers: { "Picked-Telemetry": "vite-plugin" },
372
+ maxBatchSize: r.length
373
+ });
374
+ for (let t of r) e.record(t);
375
+ await e.flush();
376
+ } catch {}
377
+ }
378
+ };
379
+ }
380
+ function _e(e) {
381
+ return typeof e == "object" && !!e && "then" in e;
382
+ }
383
+ function G(e, t, n) {
384
+ return function(...r) {
385
+ let i = performance.now(), a = () => {
386
+ n.record(e, performance.now() - i);
387
+ }, o = t.apply(this, r);
388
+ return _e(o) ? Promise.resolve(o).then(a, a) : a(), o;
389
+ };
390
+ }
391
+ function K(e) {
392
+ return typeof e == "function";
393
+ }
394
+ function ve(e, t) {
395
+ if (!e) return t;
396
+ for (let [n, r] of Object.entries(t)) if (n !== "name") {
397
+ if (K(r)) {
398
+ Reflect.set(t, n, G(n, r, e));
399
+ continue;
400
+ }
401
+ typeof r == "object" && r && "handler" in r && K(r.handler) && Reflect.set(r, "handler", G(n, r.handler, e));
402
+ }
403
+ return t;
404
+ }
405
+ //#endregion
319
406
  //#region src/virtual-module/api.ts
320
- function G() {
407
+ function ye() {
321
408
  return "export const manifestMetadata = {\n mode: 'api',\n fetchedAt: null,\n projectVersionId: null,\n workspaceId: null,\n}\n";
322
409
  }
323
410
  //#endregion
324
411
  //#region src/virtual-module/build.ts
325
- function K(e) {
412
+ function be(e) {
326
413
  let { projectConfigPath: t, experienceContentPaths: n, manifestMetadata: r } = e, i = (e) => JSON.stringify(e), a = Object.entries(n).map(([e, t]) => ` ${JSON.stringify(e)}: () => import(${i(t)}).then((m) => m.default ?? m),`).join("\n");
327
414
  return `import { registerPickedBundle } from '@picked/client/plugins/dynamic-experiences'
328
415
  import projectConfigJson from ${i(t)}
@@ -352,7 +439,7 @@ registerPickedBundle({ projectConfig, experienceContent, manifestMetadata })
352
439
  }
353
440
  //#endregion
354
441
  //#region src/virtual-module/dev.ts
355
- function se(e) {
442
+ function xe(e) {
356
443
  let { apiUrl: t, projectId: n, projectConfig: r, previewToken: i } = e, a = r ? "import { fetchExperienceContent, registerPickedBundle } from '@picked/client/plugins/dynamic-experiences'" : "import { fetchProject, fetchExperienceContent } from '@picked/client/plugins/dynamic-experiences'", o = r ? `export const projectConfig = ${JSON.stringify(r)}` : "export const projectConfig = await fetchProject(apiUrl, projectId, { previewToken: previewToken ?? undefined })", s = r ? "\nregisterPickedBundle({ projectConfig, experienceContent, manifestMetadata })\n" : "";
357
444
  return `${a}
358
445
 
@@ -378,10 +465,10 @@ ${s}`;
378
465
  }
379
466
  //#endregion
380
467
  //#region src/index.ts
381
- var q = 5;
382
- function J(e, t, n) {
468
+ var Se = 5;
469
+ function q(e, t, n) {
383
470
  if (t.length === 0) return;
384
- if (t.length > q) {
471
+ if (t.length > Se) {
385
472
  console.log(`\n ${e}: ${t.length.toString()} loaded\n`);
386
473
  return;
387
474
  }
@@ -396,10 +483,10 @@ function J(e, t, n) {
396
483
  ""
397
484
  ].join("\n"));
398
485
  }
399
- function ce(e, t) {
486
+ function Ce(e, t) {
400
487
  t.length !== 0 && console.log(`\n ${e}: ${t.length.toString()} loaded\n`);
401
488
  }
402
- var le = [
489
+ var we = [
403
490
  {
404
491
  header: "Name",
405
492
  value: (e) => e.name
@@ -420,7 +507,7 @@ var le = [
420
507
  header: "Ver",
421
508
  value: (e) => `v${e.version.toString()}`
422
509
  }
423
- ], ue = [
510
+ ], Te = [
424
511
  {
425
512
  header: "Name",
426
513
  value: (e) => e.name
@@ -441,7 +528,7 @@ var le = [
441
528
  header: "Targets",
442
529
  value: (e) => e.targets.length.toString()
443
530
  }
444
- ], de = [
531
+ ], Ee = [
445
532
  {
446
533
  header: "Name",
447
534
  value: (e) => e.name
@@ -454,7 +541,7 @@ var le = [
454
541
  header: "Fields",
455
542
  value: (e) => (e.fieldIds?.length ?? 0).toString()
456
543
  }
457
- ], fe = [
544
+ ], De = [
458
545
  {
459
546
  header: "Name",
460
547
  value: (e) => e.name
@@ -471,98 +558,101 @@ var le = [
471
558
  header: "Required",
472
559
  value: (e) => e.required ? "yes" : "no"
473
560
  }
474
- ], pe = [{
561
+ ], Oe = [{
475
562
  header: "Name",
476
563
  value: (e) => e.name
477
564
  }, {
478
565
  header: "Key",
479
566
  value: (e) => e.key
480
567
  }];
481
- function me() {
482
- return "0.0.1-dev.1787019239195";
568
+ function ke() {
569
+ return "0.0.1-dev.1787537193674";
483
570
  }
484
- var he = "https://api.picked.app", Y = "virtual:picked/data", X = `\0${Y}`;
485
- function ge(e) {
486
- for (let t of Object.values(e)) if (t.type === "chunk" && t.moduleIds.includes(X)) return t.fileName;
571
+ var Ae = "https://api.picked.app", J = "virtual:picked/data", Y = `\0${J}`;
572
+ function X(e) {
573
+ for (let t of Object.values(e)) if (t.type === "chunk" && t.moduleIds.includes(Y)) return t.fileName;
487
574
  }
488
- function _e(e, t) {
575
+ function je(e, t) {
489
576
  return e === "" || e.endsWith("/") ? `${e}${t}` : `${e}/${t}`;
490
577
  }
491
- async function ve(e) {
578
+ async function Me(e) {
492
579
  try {
493
580
  let t = await o({
494
581
  config: e,
495
582
  onWarn: (e) => {
496
- j.warn(e);
583
+ N.warn(e);
497
584
  }
498
585
  });
499
- j.info(`generated types at ${t.typesOutput}`);
586
+ N.info(`generated types at ${t.typesOutput}`);
500
587
  } catch (e) {
501
588
  let t = e instanceof Error ? e.message : String(e);
502
589
  throw Error(`type generation failed: ${t}. Fix the schema source, or set \`generateTypes: false\` on the picked plugin to skip it.`);
503
590
  }
504
591
  }
505
- async function ye(e, t) {
506
- let n = await c(e, t);
592
+ function Ne(e, t, n) {
593
+ return e && c(t, n) ? e : null;
594
+ }
595
+ async function Pe(e, t) {
596
+ let n = await d(e, t);
507
597
  if (!n) throw Error("picked.config.{ts,js,json} is required. Add a picked.config.ts with projectId and apiUrl.");
508
598
  return n;
509
599
  }
510
600
  function Z(e, t, n) {
511
601
  if (t !== void 0 && n !== void 0 && t !== n) throw Error(`picked plugin option \`${e}\` is "${t}", and picked.config says "${n}". Remove the plugin option; picked.config is the one place this belongs.`);
512
602
  }
513
- function be(e) {
603
+ function Fe(e) {
514
604
  let t = [];
515
605
  if (e.projectId !== void 0 && t.push("`projectId`"), e.apiUrl !== void 0 && t.push("`apiUrl`"), t.length === 0) return;
516
606
  let n = t.length > 1;
517
- j.warn(`picked plugin option${n ? "s" : ""} ${t.join(" and ")} ${n ? "are" : "is"} deprecated, and a future release drops ${n ? "them" : "it"}. Move ${n ? "them" : "it"} to picked.config, which the CLI and the type generator read from too.`);
607
+ N.warn(`picked plugin option${n ? "s" : ""} ${t.join(" and ")} ${n ? "are" : "is"} deprecated, and a future release drops ${n ? "them" : "it"}. Move ${n ? "them" : "it"} to picked.config, which the CLI and the type generator read from too.`);
518
608
  }
519
- async function xe(e, t) {
520
- let n = await s(e);
521
- n && n.projectId !== t && j.warn(`using project "${t}" (picked.config default: "${n.projectId}") — run 'picked status' to inspect`);
609
+ async function Ie(e, t) {
610
+ let n = await u(e);
611
+ n && n.projectId !== t && N.warn(`using project "${t}" (picked.config default: "${n.projectId}") — run 'picked status' to inspect`);
522
612
  }
523
613
  var Q = /* @__PURE__ */ new Map();
524
- function Se(e, t, n) {
614
+ function Le(e, t, n) {
525
615
  return JSON.stringify([
526
616
  e,
527
617
  t,
528
618
  n
529
619
  ]);
530
620
  }
531
- function Ce(t = {}) {
532
- let i = t.mode ?? "bundle", o = t.generateTypes ?? !0, c = [], l = process.cwd(), u = "serve", d = "/", f = null, p = !1, m, g, _ = null;
533
- return {
621
+ function Re(t = {}) {
622
+ let i = t.mode ?? "bundle", o = t.generateTypes ?? !0, s = [], c = process.cwd(), d = "serve", f = "/", p = null, m = !1, h, g, _ = null, v = l() ? null : ge();
623
+ return ve(v, {
534
624
  name: "picked",
535
- config: async (d, h) => {
536
- u = h.command, l = d.root === void 0 ? process.cwd() : n(process.cwd(), d.root);
537
- let { projectId: v, apiUrl: y } = t, b = await s(l);
538
- Z("projectId", v, b?.projectId), Z("apiUrl", y, b?.apiUrl), be({
539
- projectId: v,
540
- apiUrl: y
541
- }), f = await ye(l, {
542
- projectId: v,
543
- apiUrl: y
625
+ config: async (l, f) => {
626
+ d = f.command, c = l.root === void 0 ? process.cwd() : n(process.cwd(), l.root);
627
+ let { projectId: y, apiUrl: b } = t, x = await u(c);
628
+ Z("projectId", y, x?.projectId), Z("apiUrl", b, x?.apiUrl), Fe({
629
+ projectId: y,
630
+ apiUrl: b
631
+ }), p = await Pe(c, {
632
+ projectId: y,
633
+ apiUrl: b
544
634
  });
545
- let { projectId: x, apiUrl: S, previewToken: C } = f;
546
- j.banner(), o && !p && (p = !0, await ve(f)), S !== he && j.warn(`using custom API URL: ${S}`), await xe(l, x);
547
- let w = r("vite-plugin", me());
548
- if (i === "api") j.debug("mode is 'api': skipping the project-config prefetch");
549
- else if (h.command === "build") {
550
- let t = Se(S, x, l);
551
- m = t;
635
+ let { projectId: S, apiUrl: C, previewToken: w } = p;
636
+ v = Ne(v, p, t.telemetry), N.banner(), o && !m && (m = !0, await Me(p)), C !== Ae && N.warn(`using custom API URL: ${C}`), await Ie(c, S);
637
+ let T = r("vite-plugin", ke());
638
+ if (i === "api") N.debug("mode is 'api': skipping the project-config prefetch");
639
+ else if (f.command === "build") {
640
+ let t = Le(C, S, c);
641
+ h = t;
552
642
  let n = Q.get(t);
553
643
  n === void 0 && (n = (async () => {
554
- j.info(`prefetching project config + content for "${x}"`);
555
- let t = R(l), n = e(t.pickedDir), r = performance.now(), i = await B({
556
- apiUrl: S,
557
- projectId: x,
558
- projectRoot: l,
559
- headers: w,
560
- previewToken: C ?? void 0
644
+ N.info(`prefetching project config + content for "${S}"`);
645
+ let t = B(c), n = e(t.pickedDir), r = performance.now(), i = await H({
646
+ apiUrl: C,
647
+ projectId: S,
648
+ projectRoot: c,
649
+ headers: T,
650
+ previewToken: w ?? void 0
561
651
  }), a = (performance.now() - r).toFixed(0);
562
- await te(l, n);
652
+ await oe(c, n);
563
653
  let o = i.config;
564
654
  return $(o, a), {
565
- virtualSource: K({
655
+ virtualSource: be({
566
656
  projectConfigPath: t.projectConfigPath,
567
657
  experienceContentPaths: i.experienceContentPaths,
568
658
  manifestMetadata: {
@@ -572,36 +662,40 @@ function Ce(t = {}) {
572
662
  workspaceId: i.manifest.workspaceId
573
663
  }
574
664
  }),
575
- features: I(o.features)
665
+ features: R(o.features)
576
666
  };
577
667
  })(), n.catch(() => Q.delete(t)), Q.set(t, n));
578
668
  let r = await n;
579
- g = r.virtualSource, c = r.features;
580
- } else if (h.mode === "production") j.debug("skipping the dev project-config fetch for a production serve resolution");
669
+ g = r.virtualSource, s = r.features;
670
+ } else if (f.mode === "production") N.debug("skipping the dev project-config fetch for a production serve resolution");
581
671
  else {
582
- j.info(`fetching project config for "${x}" (dev)`);
583
- let e = performance.now(), t = () => a(S, x, {
584
- headers: w,
585
- previewToken: C ?? void 0
586
- }), n = P(S) ? await F(t, (e, t, n) => {
587
- j.info(`local API not ready, retrying in ${(n / 1e3).toString()}s (${e.toString()}/${t.toString()})`);
672
+ N.info(`fetching project config for "${S}" (dev)`);
673
+ let e = performance.now(), t = () => a(C, S, {
674
+ headers: T,
675
+ previewToken: w ?? void 0
676
+ }), n = I(C) ? await L(t, (e, t, n) => {
677
+ N.info(`local API not ready, retrying in ${(n / 1e3).toString()}s (${e.toString()}/${t.toString()})`);
588
678
  }) : await t(), r = (performance.now() - e).toFixed(0);
589
- _ = n, n ? (c = I(n.features), $(n, r)) : j.warn(`failed to fetch project config for "${x}" (${r}ms)`);
679
+ _ = n, n ? (s = R(n.features), $(n, r)) : N.warn(`failed to fetch project config for "${S}" (${r}ms)`);
590
680
  }
591
681
  },
592
682
  configResolved(e) {
593
- d = e.base;
683
+ f = e.base;
594
684
  },
595
685
  closeBundle() {
596
- m !== void 0 && Q.delete(m);
686
+ h !== void 0 && Q.delete(h), v?.flush({
687
+ "picked.vite.command": d,
688
+ "picked.data.mode": i,
689
+ "picked.source": p?.source ?? "unknown"
690
+ });
597
691
  },
598
692
  transformIndexHtml: {
599
693
  order: "post",
600
694
  handler(e, t) {
601
695
  if (i === "api" || t.bundle === void 0) return;
602
- let n = ge(t.bundle);
696
+ let n = X(t.bundle);
603
697
  if (n === void 0) return;
604
- let r = _e(d, n);
698
+ let r = je(f, n);
605
699
  if (!e.includes(`"${r}"`)) return [{
606
700
  tag: "link",
607
701
  attrs: {
@@ -614,24 +708,24 @@ function Ce(t = {}) {
614
708
  }
615
709
  },
616
710
  resolveId(e) {
617
- if (e === Y) return X;
711
+ if (e === J) return Y;
618
712
  },
619
713
  load(e) {
620
- if (e === X) {
621
- if (i === "api") return G();
622
- if (u === "build") return g;
623
- if (!f) throw Error("picked plugin config hook must run before virtual module load");
624
- return se({
625
- apiUrl: f.apiUrl,
626
- projectId: f.projectId,
714
+ if (e === Y) {
715
+ if (i === "api") return ye();
716
+ if (d === "build") return g;
717
+ if (!p) throw Error("picked plugin config hook must run before virtual module load");
718
+ return xe({
719
+ apiUrl: p.apiUrl,
720
+ projectId: p.projectId,
627
721
  projectConfig: _,
628
- previewToken: f.previewToken ?? void 0
722
+ previewToken: p.previewToken ?? void 0
629
723
  });
630
724
  }
631
725
  },
632
726
  configureServer(e) {
633
727
  if (t.disableLauncher) return;
634
- e.middlewares.use(ee(() => h(c)));
728
+ e.middlewares.use(ae(() => S(s)));
635
729
  let n = e.printUrls.bind(e);
636
730
  e.printUrls = () => {
637
731
  let t = e.resolvedUrls?.local[0];
@@ -647,21 +741,21 @@ function Ce(t = {}) {
647
741
  handler(e, n) {
648
742
  if (!t.disableLauncher) {
649
743
  if ("index.html" in n) {
650
- j.debug("index.html came from the build; skipping the launcher page");
744
+ N.debug("index.html came from the build; skipping the launcher page");
651
745
  return;
652
746
  }
653
747
  this.emitFile({
654
748
  type: "asset",
655
749
  fileName: "index.html",
656
- source: h(c)
750
+ source: S(s)
657
751
  });
658
752
  }
659
753
  }
660
754
  }
661
- };
755
+ });
662
756
  }
663
757
  function $(e, t) {
664
- let n = I(e.features), r = I(e.experiences), i = I(e.steps), a = I(e.fields), o = I(e.conditions), s = I(e.actions), c = JSON.stringify(e).length, l = [
758
+ let n = R(e.features), r = R(e.experiences), i = R(e.steps), a = R(e.fields), o = R(e.conditions), s = R(e.actions), c = JSON.stringify(e).length, l = [
665
759
  `${n.length.toString()} features`,
666
760
  `${r.length.toString()} experiences`,
667
761
  `${i.length.toString()} steps`,
@@ -669,7 +763,7 @@ function $(e, t) {
669
763
  `${o.length.toString()} conditions`,
670
764
  `${s.length.toString()} actions`
671
765
  ].join(", ");
672
- j.info(`fetched config in ${t}ms (${l})`), J("Features", n, le), J("Experiences", r, ue), J("Steps", i, de), J("Fields", a, fe), J("Conditions", o, pe), ce("Actions", s), j.debug(`config size: ${c.toString()} bytes`);
766
+ N.info(`fetched config in ${t}ms (${l})`), q("Features", n, we), q("Experiences", r, Te), q("Steps", i, Ee), q("Fields", a, De), q("Conditions", o, Oe), Ce("Actions", s), N.debug(`config size: ${c.toString()} bytes`);
673
767
  }
674
768
  //#endregion
675
- export { Ce as picked };
769
+ export { Re as picked };