@netlify/spark-ui 1.18.0-alpha.0 → 1.18.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.
@@ -1,8 +1,16 @@
1
1
  export default class Analytics {
2
2
  /**
3
- * Pushes an event payload into the dataLayer.
3
+ * Pushes an event payload into both Google Analytics (gtag) and Segment.
4
4
  * @param eventName e.g. 'www:search_new_query'
5
5
  * @param payload additional key/value data
6
6
  */
7
7
  track(eventName: string, payload?: Record<string, any>): void;
8
8
  }
9
+ declare global {
10
+ interface Window {
11
+ analytics: {
12
+ track: (event: string, properties?: Record<string, any>, options?: Record<string, any>, callback?: () => void) => void;
13
+ };
14
+ }
15
+ function gtag(...args: any[]): void;
16
+ }
@@ -1 +1 @@
1
- .n-fadeIn{opacity:0;animation:fadeIn var(--animation-duration, .3s) ease-out forwards}.n-fadeInUp{opacity:0;transform:translateY(var(--animation-transformY, 5px));animation:fadeInUp var(--animation-duration, .3s) ease-out forwards}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}@keyframes fadeInUp{to{opacity:1;transform:translateY(0)}}.grecaptcha-badge{visibility:hidden}.n-ask-chat-container{opacity:0;animation:appearContainer .12s ease-in-out forwards;animation-delay:.14s}.n-ask-conversation{position:relative;display:grid;align-items:flex-end;gap:var(--space-s);height:calc(var(--n-search-container-height) + var(--n-search-footer-height));padding:var(--n-search-padding-inline);overflow-y:auto;scroll-behavior:smooth;grid-template-rows:1fr}.n-ask-form{display:flex;align-items:center;gap:var(--space-s);position:relative;height:var(--n-search-input-height);background-color:var(--search-input-bg-color)}.n-ask-form:after{content:"";display:block;position:absolute;top:0;left:0;width:100%;height:1px;background:var(--color-bg-3)}.n-ask-question{border:none;border-radius:var(--radius-pill);transform:translate(-.75rem);color:var(--color-text-1);background:none;padding:var(--space-2xs, .5rem);font-size:var(--step--1, .9rem);font-weight:var(--font-weight-regular);text-align:left;text-wrap:pretty;cursor:pointer;display:flex;align-items:center;gap:var(--space-2xs);transition:background-color .2s ease-out}.n-ask-question [data-icon=caretRight]{opacity:0;height:.8em;color:var(--color-text-weaker);transform:translate(-3px);transition:transform .2s ease-out}.n-ask-question:hover{background-color:var(--n-search-color-bg-2)}.n-ask-question:hover [data-icon=caretRight]{opacity:1;transform:translate(0)}.n-ask-question-list{padding:0}.n-ask-question-list .n-ask-question-list-item{position:relative;width:fit-content;opacity:0;transform:translateY(10px);animation:fadeInUp .5s forwards}.n-ask-message{display:grid;grid-template-columns:minmax(0,1fr);gap:var(--space-s);font-size:var(--font-size-text-md, 1rem)}.n-ask-message:first-of-type{margin-block-start:var(--space-2xl)}.n-ask-message-bubble{width:fit-content;max-width:85%;padding:var(--space-xs) var(--space-s);background:var(--search-answer-message-color);border-radius:var(--radius-l);font-size:var(--step-0)}.n-ask-user-message{margin-inline-start:auto;background:var(--search-user-message-color)}.n-ask-sources{margin-block-start:var(--space-xs)}.n-ask-sources-title{font-size:var(--step-0);font-weight:var(--font-weight-bold)}.n-ask-sources a{font-size:var(--step--1)}.n-ask-sources details summary::marker{display:none;content:none}.n-ask-sources details{background:var(--search-source-list-color);padding:var(--space-xs) var(--space-xs);border-radius:var(--radius-l)}.n-ask-sources details summary{display:flex;align-items:center;justify-content:space-between;gap:var(--space-xs);cursor:pointer}.n-ask-sources details ul{margin-block-start:var(--space-3xs)}.n-ask-sources [data-icon=caretRight]{width:.8em;display:inline-block;transform:rotate(90deg);height:auto;color:var(--color-text-weaker)}.n-ask-sources details[open] [data-icon=caretRight]{transform:rotate(270deg)}.n-ask-action-bar{margin-block-start:var(--space-m)}.n-ask-action-bar button{display:grid;border:none}.n-ask-action-bar button svg{pointer-events:none}.n-ask-action-bar .n-popover{--n-popover-padding: var(--space-2xs) var(--space-xs)}.n-ask-action-bar [id*=icon-]{width:auto;height:14px}.n-ask-input{border:none;outline:none;padding-inline:var(--n-search-padding-inline)}.n-ask-form-submit{display:flex;padding:.7rem;margin-inline-end:var(--space-2xs);border:none;border-radius:var(--radius-pill);background:var(--search-submit-btn-bg-color);color:var(--neutral-000);transition:background-color .15s ease-out}.n-ask-form-submit>svg{width:1rem;height:auto;aspect-ratio:1 / 1;border-radius:1.5px;transition:opacity .15s ease-out}.n-ask-form-submit[disabled]{background:var(--neutral-500)}.n-ask-form-submit[disabled]>*{opacity:.5}button.n-ask-button-back{position:absolute;z-index:1;width:fit-content;margin:1rem;padding:var(--space-xs) var(--space-s);background:var(--search-back-btn-bg-color);border:.5px solid var(--color-bg-3);border-radius:var(--radius-pill);font-size:var(--font-size-text-md, 1rem);font-weight:var(--font-weight-semibold, 500);color:var(--color-text-1);cursor:pointer;line-height:var(--line-height-none, 1)}button.n-ask-button-back [data-icon=caretRight]{color:var(--color-text-weak);transform:rotate(180deg)}.n-ask-prose{font-size:var(--step--0)}.n-ask-prose>*+*{margin-top:var(--flow-space, var(--space-s))}.n-ask-prose :where(ol,ul,li)>*+*{margin-top:var(--flow-space, var(--space-3xs))}.n-ask-prose h1,.n-ask-prose h2,.n-ask-prose h3{font-size:var(--step-1);font-weight:var(--font-weight-bold)}.n-ask-prose h4,.n-ask-prose h5,.n-ask-prose h6{font-size:var(--step-0);font-weight:var(--font-weight-bold)}.n-ask-prose pre{max-width:100%;background:var(--neutral-light-700, var(--neutral-700));border-radius:var(--radius-m);box-sizing:border-box;color:var(--neutral-100);color-scheme:dark;overflow-x:auto}.n-ask-prose code{overflow-x:auto;padding:var(--space-s)}.n-ask-prose code[class*=language-],.n-ask-prose pre[class*=language-]{display:block;font-size:var(--font-size-text-xs)}.n-ask-message-loader{width:2.5rem;height:auto;display:block;color:var(--search-loading-color)}.n-ask-message-loader :where(#ask-netlify-tick-1,#ask-netlify-tick-2,#ask-netlify-tick-3){opacity:0;animation:fadeIn .8s ease-in-out infinite}.n-ask-message-loader #ask-netlify-tick-1{animation-delay:.1s}.n-ask-message-loader #ask-netlify-tick-2{animation-delay:.2s}.n-ask-message-loader #ask-netlify-tick-3{animation-delay:.3s}.n-ask-message-loader :where(#ask-netlify-eyelid-left,#ask-netlify-eyelid-right){--n-ask-netlify-eyelid-color: var(--search-bg-color);transform-origin:top center;transform:scaleY(1.035);animation:askEyeBlink 4s infinite;animation-delay:1s}@keyframes askEyeBlink{0%,5%{transform:scaleY(1.035)}6%,10%{transform:scaleY(1.3)}11%,15%{transform:scaleY(1.035)}16%,20%{transform:scaleY(1.3)}21%,to{transform:scaleY(1.035)}}
1
+ .n-fadeIn{opacity:0;animation:fadeIn var(--animation-duration, .3s) ease-out forwards}.n-fadeInUp{opacity:0;transform:translateY(var(--animation-transformY, 5px));animation:fadeInUp var(--animation-duration, .3s) ease-out forwards}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}@keyframes fadeInUp{to{opacity:1;transform:translateY(0)}}.grecaptcha-badge{visibility:hidden}.n-ask-chat-container{opacity:0;animation:appearContainer .12s ease-in-out forwards;animation-delay:.14s}.n-ask-conversation{position:relative;display:grid;align-items:flex-end;gap:var(--space-s);height:calc(var(--n-search-container-height) + var(--n-search-footer-height));padding:var(--n-search-padding-inline);overflow-y:auto;scroll-behavior:smooth;grid-template-rows:1fr}.n-ask-form{display:flex;align-items:center;gap:var(--space-s);position:relative;height:var(--n-search-input-height);background-color:var(--search-input-bg-color)}.n-ask-form:after{content:"";display:block;position:absolute;top:0;left:0;width:100%;height:1px;background:var(--color-bg-3)}.n-ask-question{border:none;border-radius:var(--radius-pill);transform:translate(-.75rem);color:var(--color-text-1);background:none;padding:var(--space-2xs, .5rem);font-size:var(--step--1, .9rem);font-weight:var(--font-weight-regular);text-align:left;text-wrap:pretty;cursor:pointer;display:flex;align-items:center;gap:var(--space-2xs);transition:background-color .2s ease-out}.n-ask-question [data-icon=caretRight]{opacity:0;height:.8em;color:var(--color-text-weaker);transform:translate(-3px);transition:transform .2s ease-out}.n-ask-question:hover{background-color:var(--n-search-color-bg-2)}.n-ask-question:hover [data-icon=caretRight]{opacity:1;transform:translate(0)}.n-ask-question-list{padding:0}.n-ask-question-list .n-ask-question-list-item{position:relative;width:fit-content;opacity:0;transform:translateY(10px);animation:fadeInUp .5s forwards}.n-ask-message{display:grid;grid-template-columns:minmax(0,1fr);gap:var(--space-s);font-size:var(--font-size-text-md, 1rem)}.n-ask-message:first-of-type{margin-block-start:var(--space-2xl)}.n-ask-message-bubble{width:fit-content;max-width:85%;padding:var(--space-xs) var(--space-s);background:var(--search-answer-message-color);border-radius:var(--radius-l);font-size:var(--step-0)}.n-ask-user-message{margin-inline-start:auto;background:var(--search-user-message-color)}.n-ask-sources{margin-block-start:var(--space-xs)}.n-ask-sources-title{font-size:var(--step-0);font-weight:var(--font-weight-bold)}.n-ask-sources a{font-size:var(--step--1)}.n-ask-sources details summary::marker{display:none;content:none}.n-ask-sources details{background:var(--search-source-list-color);padding:var(--space-xs) var(--space-xs);border-radius:var(--radius-l)}.n-ask-sources details summary{display:flex;align-items:center;justify-content:space-between;gap:var(--space-xs);cursor:pointer}.n-ask-sources details ul{margin-block-start:var(--space-3xs)}.n-ask-sources [data-icon=caretRight]{width:.8em;display:inline-block;transform:rotate(90deg);height:auto;color:var(--color-text-weaker)}.n-ask-sources details[open] [data-icon=caretRight]{transform:rotate(270deg)}.n-ask-action-bar{margin-block-start:var(--space-m)}.n-ask-action-bar button{display:grid;border:none}.n-ask-action-bar button svg{pointer-events:none}.n-ask-action-bar .n-popover{--n-popover-padding: var(--space-3xs) var(--space-2xs);--n-popover-bottom: 125%}.n-ask-action-bar [id*=icon-]{width:auto;height:1rem}.n-ask-input{border:none;outline:none;padding-inline:var(--n-search-padding-inline)}.n-ask-form-submit{display:flex;padding:.7rem;margin-inline-end:var(--space-2xs);border:none;border-radius:var(--radius-pill);background:var(--search-submit-btn-bg-color);color:var(--neutral-000);transition:background-color .15s ease-out}.n-ask-form-submit>svg{width:1rem;height:auto;aspect-ratio:1 / 1;border-radius:1.5px;transition:opacity .15s ease-out}.n-ask-form-submit[disabled]{background:var(--neutral-500)}.n-ask-form-submit[disabled]>*{opacity:.5}button.n-ask-button-back{position:absolute;z-index:1;width:fit-content;margin:1rem;padding:var(--space-xs) var(--space-s);background:var(--search-back-btn-bg-color);border:.5px solid var(--color-bg-3);border-radius:var(--radius-pill);font-size:var(--font-size-text-md, 1rem);font-weight:var(--font-weight-semibold, 500);color:var(--color-text-1);cursor:pointer;line-height:var(--line-height-none, 1)}button.n-ask-button-back [data-icon=caretRight]{color:var(--color-text-weak);transform:rotate(180deg)}.n-ask-prose{font-size:var(--step--0)}.n-ask-prose>*+*{margin-top:var(--flow-space, var(--space-s))}.n-ask-prose :where(ol,ul,li)>*+*{margin-top:var(--flow-space, var(--space-3xs))}.n-ask-prose h1,.n-ask-prose h2,.n-ask-prose h3{font-size:var(--step-1);font-weight:var(--font-weight-bold)}.n-ask-prose h4,.n-ask-prose h5,.n-ask-prose h6{font-size:var(--step-0);font-weight:var(--font-weight-bold)}.n-ask-prose pre{max-width:100%;background:var(--neutral-light-700, var(--neutral-700));border-radius:var(--radius-m);box-sizing:border-box;color:var(--neutral-100);color-scheme:dark;overflow-x:auto}.n-ask-prose code{overflow-x:auto;padding:var(--space-s)}.n-ask-prose code[class*=language-],.n-ask-prose pre[class*=language-]{display:block;font-size:var(--font-size-text-xs)}.n-ask-message-loader{width:2.5rem;height:auto;display:block;color:var(--search-loading-color)}.n-ask-message-loader :where(#ask-netlify-tick-1,#ask-netlify-tick-2,#ask-netlify-tick-3){opacity:0;animation:fadeIn .8s ease-in-out infinite}.n-ask-message-loader #ask-netlify-tick-1{animation-delay:.1s}.n-ask-message-loader #ask-netlify-tick-2{animation-delay:.2s}.n-ask-message-loader #ask-netlify-tick-3{animation-delay:.3s}.n-ask-message-loader :where(#ask-netlify-eyelid-left,#ask-netlify-eyelid-right){--n-ask-netlify-eyelid-color: var(--search-bg-color);transform-origin:top center;transform:scaleY(1.035);animation:askEyeBlink 4s infinite;animation-delay:1s}@keyframes askEyeBlink{0%,5%{transform:scaleY(1.035)}6%,10%{transform:scaleY(1.3)}11%,15%{transform:scaleY(1.035)}16%,20%{transform:scaleY(1.3)}21%,to{transform:scaleY(1.035)}}
@@ -1 +1 @@
1
- .n-popover-container{position:relative;display:inline-block;font-size:var(--font-size-text-xs)}.n-popover-trigger{display:block;background-color:transparent;border:none;padding:0;font:inherit;color:var(--color-text-weak);cursor:pointer}.n-popover{position:absolute;background-color:var(--color-bg-2);color:var(--color-text);padding:var(--n-popover-padding, var(--space-xs) var(--space-s));border-radius:var(--radius-s);opacity:0;pointer-events:none;transition:opacity .2s ease-in-out;z-index:10}.n-popover:after{content:"";position:absolute;border-style:solid}.n-popover-container:hover .n-popover{opacity:1;pointer-events:auto}.n-popover-top .n-popover{bottom:145%;left:50%;transform:translate(-50%);width:max-content;max-width:var(--n-popover-width, 255px);box-shadow:var(--shadow-light)}.n-popover-top .n-popover:after{top:100%;left:50%;margin-left:-5px;border-width:5px;border-color:var(--color-bg-2) transparent transparent transparent}.n-popover-bottom .n-popover{top:145%;left:50%;transform:translate(-50%)}.n-popover-bottom .n-popover:after{bottom:100%;left:50%;margin-left:-5px;border-width:5px;border-color:transparent transparent var(--color-bg-2) transparent}.n-popover-left .n-popover{right:125%;top:50%;transform:translateY(-50%)}.n-popover-left .n-popover:after{top:50%;left:100%;margin-top:-5px;border-width:5px;border-color:transparent transparent transparent var(--color-bg-2)}.n-popover-right .n-popover{left:125%;top:50%;transform:translateY(-50%)}.n-popover-right .n-popover:after{top:50%;right:100%;margin-top:-5px;border-width:5px;border-color:transparent var(--color-bg-2) transparent transparent}
1
+ .n-popover-container{position:relative;display:inline-block;font-size:var(--font-size-text-xs)}.n-popover-trigger{display:block;background-color:transparent;border:none;padding:0;font:inherit;color:var(--color-text-weak);cursor:pointer}.n-popover{position:absolute;background-color:var(--color-bg-2);color:var(--color-text);padding:var(--n-popover-padding, var(--space-xs) var(--space-s));border-radius:var(--radius-s);opacity:0;pointer-events:none;transition:opacity .2s ease-in-out;z-index:10}.n-popover:after{content:"";position:absolute;border-style:solid}.n-popover-container:hover .n-popover{opacity:1;pointer-events:auto}.n-popover-top .n-popover{bottom:var(--n-popover-bottom, 145%);left:50%;transform:translate(-50%);width:max-content;max-width:var(--n-popover-width, 255px);box-shadow:var(--shadow-light)}.n-popover-top .n-popover:after{top:100%;left:50%;margin-left:-5px;border-width:5px;border-color:var(--color-bg-2) transparent transparent transparent}.n-popover-bottom .n-popover{top:145%;left:50%;transform:translate(-50%)}.n-popover-bottom .n-popover:after{bottom:100%;left:50%;margin-left:-5px;border-width:5px;border-color:transparent transparent var(--color-bg-2) transparent}.n-popover-left .n-popover{right:125%;top:50%;transform:translateY(-50%)}.n-popover-left .n-popover:after{top:50%;left:100%;margin-top:-5px;border-width:5px;border-color:transparent transparent transparent var(--color-bg-2)}.n-popover-right .n-popover{left:125%;top:50%;transform:translateY(-50%)}.n-popover-right .n-popover:after{top:50%;right:100%;margin-top:-5px;border-width:5px;border-color:transparent var(--color-bg-2) transparent transparent}
@@ -12,7 +12,7 @@ var na = (e, a, t, i) => ({
12
12
  }
13
13
  });
14
14
  import { u as S } from "./jsxRuntime.module.Bzuv3cXw.js";
15
- import { A as Z, T as ot, q as F, y as Q, x as pa, d as ve, h as Kt } from "./hooks.module.DGkdD5n9.js";
15
+ import { A as Z, T as ot, q as F, y as J, x as pa, d as ve, h as Kt } from "./hooks.module.DGkdD5n9.js";
16
16
  import { _ as Vn, C as Wn, R as Jn, D as Yn } from "./compat.module.8cuvf1_R.js";
17
17
  import { createElement as Xn, createRef as Zn, Component as $t, createContext as Je } from "preact";
18
18
  import { questions as ei } from "../components/preact/AskNetlify/components/QuestionList/questions.js";
@@ -20,7 +20,7 @@ import { QuestionList as ai } from "../components/preact/AskNetlify/components/Q
20
20
  import { BackButton as ti } from "../components/preact/AskNetlify/components/BackButton.js";
21
21
  import { ChatMessages as ni } from "../components/preact/AskNetlify/components/ChatMessages.js";
22
22
  import ii from "../components/preact/Popover/Popover.js";
23
- function V(e) {
23
+ function Q(e) {
24
24
  if (e === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
25
25
  return e;
26
26
  }
@@ -406,7 +406,7 @@ var Ni = /* @__PURE__ */ function(e) {
406
406
  ri(a, e);
407
407
  function a(i) {
408
408
  var n;
409
- return n = e.call(this, i) || this, n._hcaptcha = void 0, n.renderCaptcha = n.renderCaptcha.bind(V(n)), n.resetCaptcha = n.resetCaptcha.bind(V(n)), n.removeCaptcha = n.removeCaptcha.bind(V(n)), n.isReady = n.isReady.bind(V(n)), n._onReady = null, n.loadCaptcha = n.loadCaptcha.bind(V(n)), n.handleOnLoad = n.handleOnLoad.bind(V(n)), n.handleSubmit = n.handleSubmit.bind(V(n)), n.handleExpire = n.handleExpire.bind(V(n)), n.handleError = n.handleError.bind(V(n)), n.handleOpen = n.handleOpen.bind(V(n)), n.handleClose = n.handleClose.bind(V(n)), n.handleChallengeExpired = n.handleChallengeExpired.bind(V(n)), n.ref = /* @__PURE__ */ Zn(), n.apiScriptRequested = !1, n.sentryHub = null, n.captchaId = "", n.state = {
409
+ return n = e.call(this, i) || this, n._hcaptcha = void 0, n.renderCaptcha = n.renderCaptcha.bind(Q(n)), n.resetCaptcha = n.resetCaptcha.bind(Q(n)), n.removeCaptcha = n.removeCaptcha.bind(Q(n)), n.isReady = n.isReady.bind(Q(n)), n._onReady = null, n.loadCaptcha = n.loadCaptcha.bind(Q(n)), n.handleOnLoad = n.handleOnLoad.bind(Q(n)), n.handleSubmit = n.handleSubmit.bind(Q(n)), n.handleExpire = n.handleExpire.bind(Q(n)), n.handleError = n.handleError.bind(Q(n)), n.handleOpen = n.handleOpen.bind(Q(n)), n.handleClose = n.handleClose.bind(Q(n)), n.handleChallengeExpired = n.handleChallengeExpired.bind(Q(n)), n.ref = /* @__PURE__ */ Zn(), n.apiScriptRequested = !1, n.sentryHub = null, n.captchaId = "", n.state = {
410
410
  isApiReady: !1,
411
411
  isRemoved: !1,
412
412
  elementId: i.id
@@ -1450,7 +1450,7 @@ function _r(e) {
1450
1450
  getVisitorData: g
1451
1451
  };
1452
1452
  }, [y, g]);
1453
- return Q(function() {
1453
+ return J(function() {
1454
1454
  (!l.current || i) && (l.current = f());
1455
1455
  }, [i, k, f]), S(On.Provider, { value: v, children: t });
1456
1456
  }
@@ -1503,7 +1503,7 @@ function Or(e, a) {
1503
1503
  });
1504
1504
  });
1505
1505
  }, [o, n]);
1506
- Q(function() {
1506
+ J(function() {
1507
1507
  i && l().catch(function(m) {
1508
1508
  console.error("Failed to fetch visitor data on mount: ".concat(m));
1509
1509
  });
@@ -1533,7 +1533,7 @@ var Sr = { immediate: !0 }, Xe = class {
1533
1533
  onUnsubscribe() {
1534
1534
  }
1535
1535
  }, ya = typeof window > "u" || "Deno" in globalThis;
1536
- function J() {
1536
+ function W() {
1537
1537
  }
1538
1538
  function Cr(e, a) {
1539
1539
  return typeof e == "function" ? e(a) : e;
@@ -1924,18 +1924,18 @@ var M = Hr(), Re, qt, Pn = (qt = class {
1924
1924
  clearGcTimeout() {
1925
1925
  h(this, Re) && (clearTimeout(h(this, Re)), j(this, Re, void 0));
1926
1926
  }
1927
- }, Re = new WeakMap(), qt), De, Ne, W, _e, K, Ve, ze, Y, se, Dt, Br = (Dt = class extends Pn {
1927
+ }, Re = new WeakMap(), qt), De, Ne, V, _e, K, Ve, ze, Y, se, Dt, Br = (Dt = class extends Pn {
1928
1928
  constructor(a) {
1929
1929
  super();
1930
1930
  z(this, Y);
1931
1931
  z(this, De);
1932
1932
  z(this, Ne);
1933
- z(this, W);
1933
+ z(this, V);
1934
1934
  z(this, _e);
1935
1935
  z(this, K);
1936
1936
  z(this, Ve);
1937
1937
  z(this, ze);
1938
- j(this, ze, !1), j(this, Ve, a.defaultOptions), this.setOptions(a.options), this.observers = [], j(this, _e, a.client), j(this, W, h(this, _e).getQueryCache()), this.queryKey = a.queryKey, this.queryHash = a.queryHash, j(this, De, Vr(this.options)), this.state = a.state ?? h(this, De), this.scheduleGc();
1938
+ j(this, ze, !1), j(this, Ve, a.defaultOptions), this.setOptions(a.options), this.observers = [], j(this, _e, a.client), j(this, V, h(this, _e).getQueryCache()), this.queryKey = a.queryKey, this.queryHash = a.queryHash, j(this, De, Vr(this.options)), this.state = a.state ?? h(this, De), this.scheduleGc();
1939
1939
  }
1940
1940
  get meta() {
1941
1941
  return this.options.meta;
@@ -1948,7 +1948,7 @@ var M = Hr(), Re, qt, Pn = (qt = class {
1948
1948
  this.options = { ...h(this, Ve), ...a }, this.updateGcTime(this.options.gcTime);
1949
1949
  }
1950
1950
  optionalRemove() {
1951
- !this.observers.length && this.state.fetchStatus === "idle" && h(this, W).remove(this);
1951
+ !this.observers.length && this.state.fetchStatus === "idle" && h(this, V).remove(this);
1952
1952
  }
1953
1953
  setData(a, t) {
1954
1954
  const i = Dr(this.state.data, a, this.options);
@@ -1965,7 +1965,7 @@ var M = Hr(), Re, qt, Pn = (qt = class {
1965
1965
  cancel(a) {
1966
1966
  var i, n;
1967
1967
  const t = (i = h(this, K)) == null ? void 0 : i.promise;
1968
- return (n = h(this, K)) == null || n.cancel(a), t ? t.then(J).catch(J) : Promise.resolve();
1968
+ return (n = h(this, K)) == null || n.cancel(a), t ? t.then(W).catch(W) : Promise.resolve();
1969
1969
  }
1970
1970
  destroy() {
1971
1971
  super.destroy(), this.cancel({ silent: !0 });
@@ -2005,10 +2005,10 @@ var M = Hr(), Re, qt, Pn = (qt = class {
2005
2005
  a == null || a.refetch({ cancelRefetch: !1 }), (t = h(this, K)) == null || t.continue();
2006
2006
  }
2007
2007
  addObserver(a) {
2008
- this.observers.includes(a) || (this.observers.push(a), this.clearGcTimeout(), h(this, W).notify({ type: "observerAdded", query: this, observer: a }));
2008
+ this.observers.includes(a) || (this.observers.push(a), this.clearGcTimeout(), h(this, V).notify({ type: "observerAdded", query: this, observer: a }));
2009
2009
  }
2010
2010
  removeObserver(a) {
2011
- this.observers.includes(a) && (this.observers = this.observers.filter((t) => t !== a), this.observers.length || (h(this, K) && (h(this, ze) ? h(this, K).cancel({ revert: !0 }) : h(this, K).cancelRetry()), this.scheduleGc()), h(this, W).notify({ type: "observerRemoved", query: this, observer: a }));
2011
+ this.observers.includes(a) && (this.observers = this.observers.filter((t) => t !== a), this.observers.length || (h(this, K) && (h(this, ze) ? h(this, K).cancel({ revert: !0 }) : h(this, K).cancelRetry()), this.scheduleGc()), h(this, V).notify({ type: "observerRemoved", query: this, observer: a }));
2012
2012
  }
2013
2013
  getObserversCount() {
2014
2014
  return this.observers.length;
@@ -2067,11 +2067,11 @@ var M = Hr(), Re, qt, Pn = (qt = class {
2067
2067
  Oa(p) && p.silent || D(this, Y, se).call(this, {
2068
2068
  type: "error",
2069
2069
  error: p
2070
- }), Oa(p) || ((f = (k = h(this, W).config).onError) == null || f.call(
2070
+ }), Oa(p) || ((f = (k = h(this, V).config).onError) == null || f.call(
2071
2071
  k,
2072
2072
  p,
2073
2073
  this
2074
- ), (g = (m = h(this, W).config).onSettled) == null || g.call(
2074
+ ), (g = (m = h(this, V).config).onSettled) == null || g.call(
2075
2075
  m,
2076
2076
  this.state.data,
2077
2077
  p,
@@ -2096,7 +2096,7 @@ var M = Hr(), Re, qt, Pn = (qt = class {
2096
2096
  d(y);
2097
2097
  return;
2098
2098
  }
2099
- (f = (k = h(this, W).config).onSuccess) == null || f.call(k, p, this), (g = (m = h(this, W).config).onSettled) == null || g.call(
2099
+ (f = (k = h(this, V).config).onSuccess) == null || f.call(k, p, this), (g = (m = h(this, V).config).onSettled) == null || g.call(
2100
2100
  m,
2101
2101
  p,
2102
2102
  this.state.error,
@@ -2119,7 +2119,7 @@ var M = Hr(), Re, qt, Pn = (qt = class {
2119
2119
  canRun: () => !0
2120
2120
  })), h(this, K).start();
2121
2121
  }
2122
- }, De = new WeakMap(), Ne = new WeakMap(), W = new WeakMap(), _e = new WeakMap(), K = new WeakMap(), Ve = new WeakMap(), ze = new WeakMap(), Y = new WeakSet(), se = function(a) {
2122
+ }, De = new WeakMap(), Ne = new WeakMap(), V = new WeakMap(), _e = new WeakMap(), K = new WeakMap(), Ve = new WeakMap(), ze = new WeakMap(), Y = new WeakSet(), se = function(a) {
2123
2123
  const t = (i) => {
2124
2124
  switch (a.type) {
2125
2125
  case "failed":
@@ -2186,7 +2186,7 @@ var M = Hr(), Re, qt, Pn = (qt = class {
2186
2186
  this.state = t(this.state), M.batch(() => {
2187
2187
  this.observers.forEach((i) => {
2188
2188
  i.onQueryUpdate();
2189
- }), h(this, W).notify({ query: this, type: "updated", action: a });
2189
+ }), h(this, V).notify({ query: this, type: "updated", action: a });
2190
2190
  });
2191
2191
  }, Dt);
2192
2192
  function Qr(e, a) {
@@ -2578,7 +2578,7 @@ var ce, X, We, Lt, Yr = (Lt = class extends Xe {
2578
2578
  const a = this.getAll().filter((t) => t.state.isPaused);
2579
2579
  return M.batch(
2580
2580
  () => Promise.all(
2581
- a.map((t) => t.continue().catch(J))
2581
+ a.map((t) => t.continue().catch(W))
2582
2582
  )
2583
2583
  );
2584
2584
  }
@@ -2766,7 +2766,7 @@ var P, ge, fe, Fe, Le, ke, Me, Ue, Mt, Zr = (Mt = class {
2766
2766
  const t = { revert: !0, ...a }, i = M.batch(
2767
2767
  () => h(this, P).findAll(e).map((n) => n.cancel(t))
2768
2768
  );
2769
- return Promise.all(i).then(J).catch(J);
2769
+ return Promise.all(i).then(W).catch(W);
2770
2770
  }
2771
2771
  invalidateQueries(e, a = {}) {
2772
2772
  return M.batch(() => (h(this, P).findAll(e).forEach((t) => {
@@ -2786,10 +2786,10 @@ var P, ge, fe, Fe, Le, ke, Me, Ue, Mt, Zr = (Mt = class {
2786
2786
  }, i = M.batch(
2787
2787
  () => h(this, P).findAll(e).filter((n) => !n.isDisabled() && !n.isStatic()).map((n) => {
2788
2788
  let r = n.fetch(void 0, t);
2789
- return t.throwOnError || (r = r.catch(J)), n.state.fetchStatus === "paused" ? Promise.resolve() : r;
2789
+ return t.throwOnError || (r = r.catch(W)), n.state.fetchStatus === "paused" ? Promise.resolve() : r;
2790
2790
  })
2791
2791
  );
2792
- return Promise.all(i).then(J);
2792
+ return Promise.all(i).then(W);
2793
2793
  }
2794
2794
  fetchQuery(e) {
2795
2795
  const a = this.defaultQueryOptions(e);
@@ -2800,13 +2800,13 @@ var P, ge, fe, Fe, Le, ke, Me, Ue, Mt, Zr = (Mt = class {
2800
2800
  ) ? t.fetch(a) : Promise.resolve(t.state.data);
2801
2801
  }
2802
2802
  prefetchQuery(e) {
2803
- return this.fetchQuery(e).then(J).catch(J);
2803
+ return this.fetchQuery(e).then(W).catch(W);
2804
2804
  }
2805
2805
  fetchInfiniteQuery(e) {
2806
2806
  return e.behavior = wt(e.pages), this.fetchQuery(e);
2807
2807
  }
2808
2808
  prefetchInfiniteQuery(e) {
2809
- return this.fetchInfiniteQuery(e).then(J).catch(J);
2809
+ return this.fetchInfiniteQuery(e).then(W).catch(W);
2810
2810
  }
2811
2811
  ensureInfiniteQueryData(e) {
2812
2812
  return e.behavior = wt(e.pages), this.ensureQueryData(e);
@@ -2954,7 +2954,7 @@ var P, ge, fe, Fe, Le, ke, Me, Ue, Mt, Zr = (Mt = class {
2954
2954
  }, to = ({
2955
2955
  client: e,
2956
2956
  children: a
2957
- }) => (Q(() => (e.mount(), () => {
2957
+ }) => (J(() => (e.mount(), () => {
2958
2958
  e.unmount();
2959
2959
  }), [e]), /* @__PURE__ */ S(Dn.Provider, { value: e, children: a }));
2960
2960
  function no(e, a) {
@@ -2964,7 +2964,7 @@ function no(e, a) {
2964
2964
  e
2965
2965
  )
2966
2966
  );
2967
- Q(() => {
2967
+ J(() => {
2968
2968
  i.setOptions(e);
2969
2969
  }, [i, e]);
2970
2970
  const n = Wn(
@@ -2975,7 +2975,7 @@ function no(e, a) {
2975
2975
  () => i.getCurrentResult()
2976
2976
  ), r = F(
2977
2977
  (o, s) => {
2978
- i.mutate(o, s).catch(J);
2978
+ i.mutate(o, s).catch(W);
2979
2979
  },
2980
2980
  [i]
2981
2981
  );
@@ -3322,9 +3322,9 @@ async function Eo(e, a) {
3322
3322
  var jo = "565487b2-a67c-4aac-bb92-3fb64732c7b8", Ln = Yn(
3323
3323
  ({ onLoad: e, scriptLocation: a }, t) => {
3324
3324
  const [i, n] = ve(!1);
3325
- return Q(() => {
3325
+ return J(() => {
3326
3326
  window.hcaptcha && window.hcaptcha.render && n(!0);
3327
- }, []), Q(() => {
3327
+ }, []), J(() => {
3328
3328
  i && e();
3329
3329
  }, [i, e]), /* @__PURE__ */ S(
3330
3330
  Ni,
@@ -3343,7 +3343,7 @@ var jo = "565487b2-a67c-4aac-bb92-3fb64732c7b8", Ln = Yn(
3343
3343
  Ln.displayName = "HCaptcha";
3344
3344
  var St = "kapa-recaptcha-script", Ro = ({ siteKey: e, config: a, onLoad: t }) => {
3345
3345
  const { loadScript: i = !0 } = a || {}, [n, r] = ve(!1);
3346
- return Q(() => {
3346
+ return J(() => {
3347
3347
  var o;
3348
3348
  if (!i) return;
3349
3349
  const s = () => {
@@ -3366,7 +3366,7 @@ var St = "kapa-recaptcha-script", Ro = ({ siteKey: e, config: a, onLoad: t }) =>
3366
3366
  return u.addEventListener("load", s), u.addEventListener("error", d), () => {
3367
3367
  u && (u.removeEventListener("load", s), u.removeEventListener("error", d));
3368
3368
  };
3369
- }, [e, i]), Q(() => {
3369
+ }, [e, i]), J(() => {
3370
3370
  if (n && window.grecaptcha)
3371
3371
  try {
3372
3372
  window.grecaptcha.enterprise.ready(() => {
@@ -4095,7 +4095,7 @@ var $o = "MHIUVE6Y4VV6H5lpgMyI", Bn = Je(void 0), At = ({
4095
4095
  l.conversation
4096
4096
  ]
4097
4097
  );
4098
- Q(() => {
4098
+ J(() => {
4099
4099
  l.conversation.filter(
4100
4100
  (R) => R.status === "pending_completion"
4101
4101
  ).forEach((R) => {
@@ -4311,32 +4311,28 @@ function cs({ setModalState: e, searchQuery: a, urlParamQuery: t }) {
4311
4311
  isPreparingAnswer: f,
4312
4312
  stopGeneration: m,
4313
4313
  addFeedback: g
4314
- } = Ho();
4315
- Q(() => {
4316
- console.log(l);
4317
- }, [l]);
4318
- const y = (v) => {
4314
+ } = Ho(), y = (v) => {
4319
4315
  v.preventDefault();
4320
4316
  const w = v.target, x = w == null ? void 0 : w.getAttribute("data-question-id"), O = x ? ei[x] : i;
4321
4317
  O.trim() && p(O.trim()), x || n(""), o(!0);
4322
4318
  };
4323
- return Q(() => {
4319
+ return J(() => {
4324
4320
  r && u.current && (u.current.scrollIntoView({ behavior: "smooth" }), o(!1));
4325
- }, [r]), Q(() => {
4321
+ }, [r]), J(() => {
4326
4322
  a && (n(""), p(a.trim()), o(!0));
4327
- }, [a, n, o]), Q(() => {
4323
+ }, [a, n, o]), J(() => {
4328
4324
  !a && t && n(t);
4329
4325
  }, [t, a, n]), /* @__PURE__ */ S("div", { className: "n-ask-chat-container", children: [
4330
4326
  /* @__PURE__ */ S(ti, { onClick: () => e == null ? void 0 : e({ current: "search" }) }),
4331
4327
  /* @__PURE__ */ S("div", { ref: s, className: "n-ask-conversation n-search-window", children: [
4332
4328
  !l.length && !t && !a && /* @__PURE__ */ S(ai, { onClick: y, menuRef: d }),
4333
- /* @__PURE__ */ S(
4329
+ l.length > 0 && /* @__PURE__ */ S(
4334
4330
  ni,
4335
4331
  {
4336
4332
  isPreparingAnswer: f,
4337
4333
  conversation: l,
4338
4334
  lastMessageRef: u,
4339
- addFeedback: g
4335
+ feedback: g
4340
4336
  }
4341
4337
  )
4342
4338
  ] }),
@@ -0,0 +1,20 @@
1
+ class i {
2
+ /**
3
+ * Pushes an event payload into both Google Analytics (gtag) and Segment.
4
+ * @param eventName e.g. 'www:search_new_query'
5
+ * @param payload additional key/value data
6
+ */
7
+ track(t, n = {}) {
8
+ if (typeof gtag == "function" ? gtag("event", t, { ...n }) : console.error(`gtag is not defined. Event [${t}] failed.`), typeof window < "u" && window.analytics)
9
+ try {
10
+ window.analytics.track(t, n);
11
+ } catch (e) {
12
+ console.error(`Segment track failed for event [${t}]:`, e);
13
+ }
14
+ else
15
+ console.warn(`Segment analytics is not loaded. Event [${t}] not sent to Segment.`);
16
+ }
17
+ }
18
+ export {
19
+ i as A
20
+ };
@@ -1,6 +1,6 @@
1
1
  import "../../../chunks/jsxRuntime.module.Bzuv3cXw.js";
2
2
  import "../../../chunks/hooks.module.DGkdD5n9.js";
3
- import { A as d } from "../../../chunks/AskNetlify.nCAFTKgo.js";
3
+ import { A as d } from "../../../chunks/AskNetlify.CpaPeYsd.js";
4
4
  import "./components/QuestionList/questions.js";
5
5
  import "./components/QuestionList/QuestionList.js";
6
6
  import "./components/BackButton.js";
@@ -1,7 +1,7 @@
1
1
  interface ActionBarProps {
2
2
  answer: string;
3
3
  questionAnswerId: string;
4
- addFeedback: (id: string, type: string, meta?: object) => void;
4
+ feedback: (id: string, type: string, meta?: object) => void;
5
5
  }
6
- export declare function ActionBar({ answer, questionAnswerId, addFeedback }: ActionBarProps): import("preact").JSX.Element;
6
+ export declare function ActionBar({ answer, questionAnswerId, feedback }: ActionBarProps): import("preact").JSX.Element;
7
7
  export {};
@@ -1,68 +1,78 @@
1
1
  import { u as t } from "../../../../chunks/jsxRuntime.module.Bzuv3cXw.js";
2
- import i from "../../Icon/index.js";
3
- import l from "../../Popover/Popover.js";
4
- const d = (c) => {
5
- const e = c.target.closest("button");
6
- if (!e) return;
7
- const o = e.classList.contains("btn-feedback-helpful"), r = e.classList.contains("btn-feedback-incorrect");
8
- if (!o && !r) return;
9
- const n = e.closest(".n-ask-action-bar"), u = n == null ? void 0 : n.querySelector(".btn-feedback-helpful"), f = n == null ? void 0 : n.querySelector(".btn-feedback-incorrect");
10
- [u, f].forEach((s) => {
11
- if (!s) return;
12
- s.querySelectorAll('[id*="icon"]').forEach((a, p) => {
13
- p === 0 ? a.classList.remove("hidden") : a.classList.add("hidden");
2
+ import s from "../../Icon/index.js";
3
+ import r from "../../Popover/Popover.js";
4
+ import { A as m } from "../../../../chunks/analytics.D_dJH08O.js";
5
+ const u = (a) => {
6
+ const e = "btn-feedback-helpful", n = "btn-feedback-inaccurate", c = a.target.closest("button");
7
+ if (!c) return;
8
+ const i = c.classList.contains(e), f = c.classList.contains(n);
9
+ if (!i && !f) return;
10
+ const o = c.closest(".n-ask-action-bar"), p = o == null ? void 0 : o.querySelector(`.${e}`), b = o == null ? void 0 : o.querySelector(`.${n}`);
11
+ [p, b].forEach((l) => {
12
+ if (!l) return;
13
+ l.querySelectorAll('[id*="icon"]').forEach((d, h) => {
14
+ h === 0 ? d.classList.remove("hidden") : d.classList.add("hidden");
14
15
  });
15
- }), e.querySelectorAll('[id*="icon"]').forEach((s) => {
16
- s.classList.toggle("hidden");
16
+ }), c.querySelectorAll('[id*="icon"]').forEach((l) => {
17
+ l.classList.toggle("hidden");
17
18
  });
18
- }, b = async (c) => {
19
- const e = document.getElementById("copy-popover");
19
+ }, k = async (a) => {
20
+ const e = document.getElementById("copy-popover"), n = 2e3;
20
21
  try {
21
- await navigator.clipboard.writeText(c), e && (e.textContent = "Copied", setTimeout(() => {
22
+ await navigator.clipboard.writeText(a), e && (e.textContent = "Copied", setTimeout(() => {
22
23
  e.textContent = "Copy", e.blur();
23
- }, 2e3));
24
- } catch (o) {
25
- console.error("Failed to copy code: ", o), e && (e.textContent = "Failed to copy", setTimeout(() => {
24
+ }, n));
25
+ } catch (c) {
26
+ console.error("Failed to copy code: ", c), e && (e.textContent = "Failed to copy", setTimeout(() => {
26
27
  e.textContent = "Copy", e.blur();
27
- }, 2e3));
28
+ }, n));
28
29
  }
29
30
  };
30
- function v({ answer: c, questionAnswerId: e, addFeedback: o }) {
31
+ function T({ answer: a, questionAnswerId: e, feedback: n }) {
32
+ const c = new m();
31
33
  return /* @__PURE__ */ t("div", { className: "n-ask-action-bar", children: [
32
- /* @__PURE__ */ t(l, { id: "copy", content: "Copy", children: /* @__PURE__ */ t("button", { onClick: () => b(c), children: /* @__PURE__ */ t(i, { name: "copy" }) }) }),
33
- /* @__PURE__ */ t(l, { id: "feedback-helpful", content: "Helpful", children: /* @__PURE__ */ t(
34
+ /* @__PURE__ */ t(r, { id: "copy", content: "Copy", children: /* @__PURE__ */ t(
35
+ "button",
36
+ {
37
+ onClick: () => {
38
+ k(a), c.track("ask:copy_answer", { id: e });
39
+ },
40
+ children: /* @__PURE__ */ t(s, { name: "copy" })
41
+ }
42
+ ) }),
43
+ /* @__PURE__ */ t(r, { id: "feedback-helpful", content: "Helpful", children: /* @__PURE__ */ t(
34
44
  "button",
35
45
  {
36
46
  class: "btn-feedback-helpful n-stack",
37
- onClick: (r) => {
38
- d(r), o(e, "upvote");
47
+ onClick: (i) => {
48
+ u(i), n(e, "upvote"), c.track("ask:feedback_helpful", { id: e });
39
49
  },
40
50
  children: [
41
- /* @__PURE__ */ t(i, { name: "thumbsUp" }),
42
- /* @__PURE__ */ t(i, { name: "thumbsUpSolid", className: "hidden" })
51
+ /* @__PURE__ */ t(s, { name: "thumbsUp" }),
52
+ /* @__PURE__ */ t(s, { name: "thumbsUpSolid", className: "hidden" })
43
53
  ]
44
54
  }
45
55
  ) }),
46
- /* @__PURE__ */ t(l, { id: "feedback-incorrect", content: "Not helpful", children: /* @__PURE__ */ t(
56
+ /* @__PURE__ */ t(r, { id: "feedback-inaccurate", content: "Not helpful", children: /* @__PURE__ */ t(
47
57
  "button",
48
58
  {
49
- class: "btn-feedback-incorrect n-stack",
50
- onClick: (r) => {
51
- d(r), o(e, "downvote", {
59
+ class: "btn-feedback-inaccurate n-stack",
60
+ onClick: (i) => {
61
+ u(i), n(e, "downvote", {
52
62
  incorrect: !0,
53
63
  irrelevant: !1,
54
64
  unaddressed: !1,
55
- issue: "This information isn't accurate"
56
- });
65
+ issue: "This information is inaccurate"
66
+ }), c.track("ask:feedback_inaccurate", { id: e });
57
67
  },
58
68
  children: [
59
- /* @__PURE__ */ t(i, { name: "thumbsDown" }),
60
- /* @__PURE__ */ t(i, { name: "thumbsDownSolid", className: "hidden" })
69
+ /* @__PURE__ */ t(s, { name: "thumbsDown" }),
70
+ /* @__PURE__ */ t(s, { name: "thumbsDownSolid", className: "hidden" })
61
71
  ]
62
72
  }
63
73
  ) })
64
74
  ] });
65
75
  }
66
76
  export {
67
- v as ActionBar
77
+ T as ActionBar
68
78
  };
@@ -1,7 +1,7 @@
1
1
  import { Ref } from 'preact';
2
- export declare function ChatMessages({ conversation, lastMessageRef, isPreparingAnswer, addFeedback, }: {
2
+ export declare function ChatMessages({ conversation, lastMessageRef, isPreparingAnswer, feedback, }: {
3
3
  conversation: any[];
4
4
  lastMessageRef: Ref<HTMLDivElement>;
5
5
  isPreparingAnswer: boolean;
6
- addFeedback: any;
6
+ feedback: any;
7
7
  }): import("preact").JSX.Element;
@@ -1570,7 +1570,7 @@ function ft({
1570
1570
  conversation: n,
1571
1571
  lastMessageRef: e,
1572
1572
  isPreparingAnswer: t,
1573
- addFeedback: r
1573
+ feedback: r
1574
1574
  }) {
1575
1575
  return /* @__PURE__ */ w(ve, { children: [
1576
1576
  n.map((s, i) => {
@@ -1592,14 +1592,7 @@ function ft({
1592
1592
  dangerouslySetInnerHTML: { __html: f.parse(s.answer) }
1593
1593
  }
1594
1594
  ),
1595
- s.id && /* @__PURE__ */ w(
1596
- Re,
1597
- {
1598
- answer: s.answer,
1599
- addFeedback: r,
1600
- questionAnswerId: s.id
1601
- }
1602
- ),
1595
+ s.id && /* @__PURE__ */ w(Re, { answer: s.answer, feedback: r, questionAnswerId: s.id }),
1603
1596
  s.id && /* @__PURE__ */ w($e, { sources: s.sources })
1604
1597
  ] }) })
1605
1598
  ] }, s.id || `qa-${i}`);
@@ -1,5 +1,5 @@
1
1
  import { A as o, q as n } from "../../../../chunks/hooks.module.DGkdD5n9.js";
2
- import { A as u } from "../../../../chunks/analytics.Ch1vuuOl.js";
2
+ import { A as u } from "../../../../chunks/analytics.D_dJH08O.js";
3
3
  function A() {
4
4
  const r = o(new u()).current, s = n((e) => {
5
5
  !e.question || !e.threadId || r == null || r.track("ask:new_query", {
@@ -1,6 +1,6 @@
1
1
  import { u as e } from "../../../../../chunks/jsxRuntime.module.Bzuv3cXw.js";
2
2
  import { A as g, y as f, d } from "../../../../../chunks/hooks.module.DGkdD5n9.js";
3
- import { A as K, K as L } from "../../../../../chunks/AskNetlify.nCAFTKgo.js";
3
+ import { A as K, K as L } from "../../../../../chunks/AskNetlify.CpaPeYsd.js";
4
4
  import P from "../../../Modal/Modal.js";
5
5
  import h from "../../../KeyboardKey/KeyboardKey.js";
6
6
  import M from "../SearchWindow.js";
@@ -1,5 +1,5 @@
1
1
  import { A as y, y as h, q as d } from "../../../../chunks/hooks.module.DGkdD5n9.js";
2
- import { A as T } from "../../../../chunks/analytics.Ch1vuuOl.js";
2
+ import { A as T } from "../../../../chunks/analytics.D_dJH08O.js";
3
3
  function A(r, l) {
4
4
  const n = y(new T()).current, e = (c) => c.debug_mode = !0;
5
5
  return h(() => {
@@ -4,7 +4,7 @@ import { default as m } from "./Icon/index.js";
4
4
  import { default as s } from "./SearchModal/components/SearchLink/SearchLink.js";
5
5
  import { default as u } from "./SearchModal/components/SearchHeading/SearchHeading.js";
6
6
  import { default as i } from "./SearchModal/components/SearchToggle/SearchToggle.js";
7
- import { A as S } from "../../chunks/AskNetlify.nCAFTKgo.js";
7
+ import { A as S } from "../../chunks/AskNetlify.CpaPeYsd.js";
8
8
  import "preact";
9
9
  import "../../chunks/hooks.module.DGkdD5n9.js";
10
10
  import { default as n } from "./SearchModal/components/SearchModal/SearchModal.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@netlify/spark-ui",
3
3
  "description": "Assets, design tokens, components, and utilities",
4
- "version": "1.18.0-alpha.0",
4
+ "version": "1.18.0",
5
5
  "type": "module",
6
6
  "main": "dist/components/preact/index.js",
7
7
  "types": "dist/components/preact/index.d.ts",
@@ -1,16 +1,40 @@
1
1
  export default class Analytics {
2
-
3
2
  /**
4
- * Pushes an event payload into the dataLayer.
3
+ * Pushes an event payload into both Google Analytics (gtag) and Segment.
5
4
  * @param eventName e.g. 'www:search_new_query'
6
5
  * @param payload additional key/value data
7
6
  */
8
7
  track(eventName: string, payload: Record<string, any> = {}): void {
9
- // Ensures that gtag is available before pushing events
8
+ // Track with Google Analytics (gtag)
10
9
  if (typeof gtag === 'function') {
11
10
  gtag('event', eventName, { ...payload });
12
11
  } else {
13
12
  console.error(`gtag is not defined. Event [${eventName}] failed.`);
14
13
  }
14
+
15
+ // Track with Segment
16
+ if (typeof window !== 'undefined' && window.analytics) {
17
+ try {
18
+ window.analytics.track(eventName, payload);
19
+ } catch (error) {
20
+ console.error(`Segment track failed for event [${eventName}]:`, error);
21
+ }
22
+ } else {
23
+ console.warn(`Segment analytics is not loaded. Event [${eventName}] not sent to Segment.`);
24
+ }
25
+ }
26
+ }
27
+
28
+ declare global {
29
+ interface Window {
30
+ analytics: {
31
+ track: (
32
+ event: string,
33
+ properties?: Record<string, any>,
34
+ options?: Record<string, any>,
35
+ callback?: () => void
36
+ ) => void;
37
+ };
15
38
  }
16
- }
39
+ function gtag(...args: any[]): void;
40
+ }
@@ -182,12 +182,13 @@
182
182
  }
183
183
 
184
184
  .n-ask-action-bar .n-popover {
185
- --n-popover-padding: var(--space-2xs) var(--space-xs);
185
+ --n-popover-padding: var(--space-3xs) var(--space-2xs);
186
+ --n-popover-bottom: 125%;
186
187
  }
187
188
 
188
189
  .n-ask-action-bar [id*='icon-'] {
189
190
  width: auto;
190
- height: 14px;
191
+ height: 1rem;
191
192
  }
192
193
 
193
194
  /* ----------------------------- */
@@ -32,10 +32,6 @@ export default function AskNetlify({ setModalState, searchQuery, urlParamQuery }
32
32
  addFeedback,
33
33
  } = useChat();
34
34
 
35
- useEffect(() => {
36
- console.log(conversation);
37
- }, [conversation]);
38
-
39
35
  const handleSubmit = (e: Event | preact.JSX.TargetedMouseEvent<HTMLButtonElement>) => {
40
36
  e.preventDefault();
41
37
  const target = e.target as HTMLButtonElement;
@@ -83,14 +79,14 @@ export default function AskNetlify({ setModalState, searchQuery, urlParamQuery }
83
79
  <QuestionList onClick={handleSubmit} menuRef={menuRef} />
84
80
  )}
85
81
 
86
- {
82
+ {conversation.length > 0 && (
87
83
  <ChatMessages
88
84
  isPreparingAnswer={isPreparingAnswer}
89
85
  conversation={conversation}
90
86
  lastMessageRef={lastMessageRef}
91
- addFeedback={addFeedback}
87
+ feedback={addFeedback}
92
88
  />
93
- }
89
+ )}
94
90
  </div>
95
91
 
96
92
  <form onSubmit={handleSubmit} className="n-ask-form n-search-input-wrapper">
@@ -1,29 +1,32 @@
1
1
  import Icon from '@components/preact/Icon';
2
2
  import Popover from '@components/preact/Popover/Popover';
3
+ import Analytics from '@analtyics/analytics';
3
4
 
4
5
  interface ActionBarProps {
5
6
  answer: string;
6
7
  questionAnswerId: string;
7
- addFeedback: (id: string, type: string, meta?: object) => void;
8
+ feedback: (id: string, type: string, meta?: object) => void;
8
9
  }
9
10
 
10
11
  const toggleFeedbackButton = (e: MouseEvent): void => {
12
+ const feedbackHelpfulId = 'btn-feedback-helpful';
13
+ const feedbackInaccurateId = 'btn-feedback-inaccurate';
11
14
  const btn = (e.target as HTMLElement).closest('button');
12
15
  if (!btn) return;
13
16
 
14
- const isHelpfulBtn = btn.classList.contains('btn-feedback-helpful');
15
- const isIncorrectBtn = btn.classList.contains('btn-feedback-incorrect');
17
+ const isHelpfulBtn = btn.classList.contains(feedbackHelpfulId);
18
+ const isInaccurateBtn = btn.classList.contains(feedbackInaccurateId);
16
19
 
17
20
  // Only proceed if it's one of the feedback buttons
18
- if (!isHelpfulBtn && !isIncorrectBtn) return;
21
+ if (!isHelpfulBtn && !isInaccurateBtn) return;
19
22
 
20
23
  // Get both feedback buttons
21
24
  const actionBar = btn.closest('.n-ask-action-bar');
22
- const helpfulBtn = actionBar?.querySelector('.btn-feedback-helpful');
23
- const incorrectBtn = actionBar?.querySelector('.btn-feedback-incorrect');
25
+ const helpfulBtn = actionBar?.querySelector(`.${feedbackHelpfulId}`);
26
+ const inaccurateBtn = actionBar?.querySelector(`.${feedbackInaccurateId}`);
24
27
 
25
28
  // Reset both buttons first (hide all solid icons, show all outline icons)
26
- [helpfulBtn, incorrectBtn].forEach(button => {
29
+ [helpfulBtn, inaccurateBtn].forEach(button => {
27
30
  if (!button) return;
28
31
  const icons = button.querySelectorAll('[id*="icon"]');
29
32
  icons.forEach((icon, index) => {
@@ -44,6 +47,7 @@ const toggleFeedbackButton = (e: MouseEvent): void => {
44
47
 
45
48
  const copyToClipboard = async (text: string): Promise<void> => {
46
49
  const copyPopover = document.getElementById('copy-popover');
50
+ const MAX_TIME = 2000;
47
51
  try {
48
52
  await navigator.clipboard.writeText(text);
49
53
  if (copyPopover) {
@@ -51,7 +55,7 @@ const copyToClipboard = async (text: string): Promise<void> => {
51
55
  setTimeout(() => {
52
56
  copyPopover.textContent = 'Copy';
53
57
  copyPopover.blur();
54
- }, 2000);
58
+ }, MAX_TIME);
55
59
  }
56
60
  } catch (error) {
57
61
  console.error('Failed to copy code: ', error);
@@ -60,16 +64,23 @@ const copyToClipboard = async (text: string): Promise<void> => {
60
64
  setTimeout(() => {
61
65
  copyPopover.textContent = 'Copy';
62
66
  copyPopover.blur();
63
- }, 2000);
67
+ }, MAX_TIME);
64
68
  }
65
69
  }
66
70
  };
67
71
 
68
- export function ActionBar({ answer, questionAnswerId, addFeedback }: ActionBarProps) {
72
+ export function ActionBar({ answer, questionAnswerId, feedback }: ActionBarProps) {
73
+ const analytics = new Analytics();
74
+
69
75
  return (
70
76
  <div className="n-ask-action-bar">
71
77
  <Popover id="copy" content={`Copy`}>
72
- <button onClick={() => copyToClipboard(answer)}>
78
+ <button
79
+ onClick={() => {
80
+ copyToClipboard(answer);
81
+ analytics.track('ask:copy_answer', { id: questionAnswerId });
82
+ }}
83
+ >
73
84
  <Icon name="copy" />
74
85
  </button>
75
86
  </Popover>
@@ -79,7 +90,8 @@ export function ActionBar({ answer, questionAnswerId, addFeedback }: ActionBarPr
79
90
  class="btn-feedback-helpful n-stack"
80
91
  onClick={e => {
81
92
  toggleFeedbackButton(e as unknown as MouseEvent);
82
- addFeedback(questionAnswerId, 'upvote');
93
+ feedback(questionAnswerId, 'upvote');
94
+ analytics.track('ask:feedback_helpful', { id: questionAnswerId });
83
95
  }}
84
96
  >
85
97
  <Icon name="thumbsUp" />
@@ -87,17 +99,18 @@ export function ActionBar({ answer, questionAnswerId, addFeedback }: ActionBarPr
87
99
  </button>
88
100
  </Popover>
89
101
 
90
- <Popover id="feedback-incorrect" content={`Not helpful`}>
102
+ <Popover id="feedback-inaccurate" content={`Not helpful`}>
91
103
  <button
92
- class="btn-feedback-incorrect n-stack"
104
+ class="btn-feedback-inaccurate n-stack"
93
105
  onClick={e => {
94
106
  toggleFeedbackButton(e as unknown as MouseEvent);
95
- addFeedback(questionAnswerId, 'downvote', {
107
+ feedback(questionAnswerId, 'downvote', {
96
108
  incorrect: true,
97
109
  irrelevant: false,
98
110
  unaddressed: false,
99
- issue: "This information isn't accurate",
111
+ issue: 'This information is inaccurate',
100
112
  });
113
+ analytics.track('ask:feedback_inaccurate', { id: questionAnswerId });
101
114
  }}
102
115
  >
103
116
  <Icon name="thumbsDown" />
@@ -8,12 +8,12 @@ export function ChatMessages({
8
8
  conversation,
9
9
  lastMessageRef,
10
10
  isPreparingAnswer,
11
- addFeedback,
11
+ feedback,
12
12
  }: {
13
13
  conversation: any[];
14
14
  lastMessageRef: Ref<HTMLDivElement>;
15
15
  isPreparingAnswer: boolean;
16
- addFeedback: any;
16
+ feedback: any;
17
17
  }) {
18
18
  return (
19
19
  <>
@@ -38,11 +38,7 @@ export function ChatMessages({
38
38
  dangerouslySetInnerHTML={{ __html: marked.parse(qa.answer) }}
39
39
  />
40
40
  {qa.id && (
41
- <ActionBar
42
- answer={qa.answer}
43
- addFeedback={addFeedback}
44
- questionAnswerId={qa.id}
45
- />
41
+ <ActionBar answer={qa.answer} feedback={feedback} questionAnswerId={qa.id} />
46
42
  )}
47
43
  {qa.id && <SourcesList sources={qa.sources} />}
48
44
  </div>
@@ -38,7 +38,7 @@
38
38
  }
39
39
 
40
40
  .n-popover-top .n-popover {
41
- bottom: 145%;
41
+ bottom: var(--n-popover-bottom, 145%);
42
42
  left: 50%;
43
43
  transform: translateX(-50%);
44
44
  width: max-content;
@@ -1,13 +0,0 @@
1
- class n {
2
- /**
3
- * Pushes an event payload into the dataLayer.
4
- * @param eventName e.g. 'www:search_new_query'
5
- * @param payload additional key/value data
6
- */
7
- track(t, e = {}) {
8
- typeof gtag == "function" ? gtag("event", t, { ...e }) : console.error(`gtag is not defined. Event [${t}] failed.`);
9
- }
10
- }
11
- export {
12
- n as A
13
- };