@wealthreach/site-kit 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/a11y/client.d.ts +23 -0
  2. package/dist/a11y/client.js +72 -0
  3. package/dist/a11y/index.d.ts +43 -0
  4. package/dist/a11y/index.js +194 -0
  5. package/dist/a11y/shell-client.d.ts +19 -0
  6. package/dist/a11y/shell-client.js +45 -0
  7. package/dist/analytics/index.d.ts +47 -0
  8. package/dist/analytics/index.js +122 -0
  9. package/dist/attribution-DQaAWtA5.d.ts +41 -0
  10. package/dist/blog/index.d.ts +92 -0
  11. package/dist/blog/index.js +239 -0
  12. package/dist/chunk-4YRCSRZZ.js +32 -0
  13. package/dist/chunk-7GDXQ6UB.js +772 -0
  14. package/dist/chunk-QQP7VG2C.js +231 -0
  15. package/dist/chunk-Y77ARZE4.js +214 -0
  16. package/dist/config/index.d.ts +20 -0
  17. package/dist/config/index.js +445 -0
  18. package/dist/consent/index.d.ts +103 -0
  19. package/dist/consent/index.js +61 -0
  20. package/dist/disclosures/index.d.ts +57 -0
  21. package/dist/disclosures/index.js +361 -0
  22. package/dist/forms/index.d.ts +128 -0
  23. package/dist/forms/index.js +449 -0
  24. package/dist/mdx/index.d.ts +15 -0
  25. package/dist/mdx/index.js +45 -0
  26. package/dist/next/config.cjs +140 -0
  27. package/dist/next/config.d.cts +36 -0
  28. package/dist/next/config.d.ts +36 -0
  29. package/dist/next/config.js +111 -0
  30. package/dist/next/draft-route.d.ts +10 -0
  31. package/dist/next/draft-route.js +49 -0
  32. package/dist/next/leads-route.d.ts +129 -0
  33. package/dist/next/leads-route.js +760 -0
  34. package/dist/next/privacy-mode.d.ts +14 -0
  35. package/dist/next/privacy-mode.js +86 -0
  36. package/dist/next/proxy.d.ts +19 -0
  37. package/dist/next/proxy.js +93 -0
  38. package/dist/regulatory-schema-uDKNJ7q8.d.ts +1301 -0
  39. package/dist/schema-C1ixytx2.d.ts +2911 -0
  40. package/dist/schema-DD0nDOD0.d.ts +1744 -0
  41. package/package.json +85 -3
  42. package/README.md +0 -3
@@ -0,0 +1,231 @@
1
+ "use client";
2
+ import {
3
+ MODE_COOKIE,
4
+ analyticsAllowed,
5
+ getGlobalSiteConfig,
6
+ readBrowserCookie,
7
+ readGpcSignal,
8
+ readStoredConsent
9
+ } from "./chunk-7GDXQ6UB.js";
10
+
11
+ // src/analytics/attribution.ts
12
+ var ATTRIBUTION_STORAGE_KEY = "wr:attribution:v1";
13
+ var ATTRIBUTION_PARAMS = [
14
+ "gclid",
15
+ "gbraid",
16
+ "wbraid",
17
+ "utm_source",
18
+ "utm_medium",
19
+ "utm_campaign",
20
+ "utm_term",
21
+ "utm_content",
22
+ "utm_id",
23
+ "adgroup"
24
+ ];
25
+ function sanitizeAttributionValue(raw) {
26
+ if (!raw) return void 0;
27
+ const cleaned = raw.trim().replace(/[\x00-\x1f\x7f<>]/g, "").slice(0, 500);
28
+ return cleaned || void 0;
29
+ }
30
+ function captureAttributionOnLanding() {
31
+ if (typeof window === "undefined") return {};
32
+ let existing = {};
33
+ try {
34
+ const raw = window.sessionStorage.getItem(ATTRIBUTION_STORAGE_KEY);
35
+ if (raw) {
36
+ const parsed = JSON.parse(raw);
37
+ if (parsed && typeof parsed === "object") {
38
+ existing = parsed;
39
+ }
40
+ }
41
+ } catch {
42
+ }
43
+ const params = new URLSearchParams(window.location.search);
44
+ const next = { ...existing };
45
+ for (const key of ATTRIBUTION_PARAMS) {
46
+ const incoming = sanitizeAttributionValue(params.get(key));
47
+ if (incoming && !next[key]) {
48
+ next[key] = incoming;
49
+ }
50
+ }
51
+ if (!next.landing_path) {
52
+ next.landing_path = sanitizeAttributionValue(window.location.pathname);
53
+ }
54
+ if (!next.referrer_host && document.referrer) {
55
+ try {
56
+ const refUrl = new URL(document.referrer);
57
+ if (refUrl.host && refUrl.host !== window.location.host) {
58
+ next.referrer_host = sanitizeAttributionValue(refUrl.host);
59
+ }
60
+ } catch {
61
+ }
62
+ }
63
+ if (!next.captured_at) {
64
+ next.captured_at = (/* @__PURE__ */ new Date()).toISOString();
65
+ }
66
+ try {
67
+ window.sessionStorage.setItem(ATTRIBUTION_STORAGE_KEY, JSON.stringify(next));
68
+ } catch {
69
+ }
70
+ return next;
71
+ }
72
+ function readAttributionSnapshot() {
73
+ if (typeof window === "undefined") return {};
74
+ try {
75
+ const raw = window.sessionStorage.getItem(ATTRIBUTION_STORAGE_KEY);
76
+ if (raw) {
77
+ const parsed = JSON.parse(raw);
78
+ if (parsed && typeof parsed === "object") {
79
+ return parsed;
80
+ }
81
+ }
82
+ } catch {
83
+ }
84
+ return captureAttributionOnLanding();
85
+ }
86
+ var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
87
+ function readConsentedWebsiteVisit(siteId, consentAllowed) {
88
+ if (!consentAllowed || typeof window === "undefined") return void 0;
89
+ const win = window;
90
+ let visitorKey;
91
+ let sessionId;
92
+ let journey;
93
+ try {
94
+ const bridge = win.__wrVisitor?.getVisitContext?.();
95
+ if (bridge) {
96
+ visitorKey = bridge.visitorKey;
97
+ sessionId = bridge.sessionId;
98
+ journey = bridge.journey;
99
+ } else if (win.__wrVisitor) {
100
+ visitorKey = win.__wrVisitor.visitorKey;
101
+ sessionId = win.__wrVisitor.sessionId;
102
+ }
103
+ } catch {
104
+ }
105
+ if (!sessionId && siteId) {
106
+ try {
107
+ sessionId = window.sessionStorage.getItem(`wr:session:${siteId}`) ?? void 0;
108
+ } catch {
109
+ }
110
+ }
111
+ if (!visitorKey) {
112
+ try {
113
+ visitorKey = window.localStorage.getItem("wr_visitor_key") ?? void 0;
114
+ } catch {
115
+ }
116
+ }
117
+ if (!visitorKey || !sessionId || !UUID_RE.test(visitorKey) || !UUID_RE.test(sessionId)) {
118
+ return void 0;
119
+ }
120
+ const device = typeof window.matchMedia === "function" && window.matchMedia("(max-width: 767px)").matches ? "mobile" : "desktop";
121
+ return {
122
+ visitorKey,
123
+ sessionId,
124
+ device,
125
+ ...journey ? { journey } : {}
126
+ };
127
+ }
128
+
129
+ // src/analytics/tracker.ts
130
+ var inMemorySessionId = null;
131
+ function isConsentCurrentlyAllowed(config) {
132
+ const decision = readStoredConsent(config.consent?.legacyConsentCookies ?? []);
133
+ const rawMode = readBrowserCookie(MODE_COOKIE);
134
+ const mode = rawMode === "opt-out" ? "opt-out" : "opt-in";
135
+ return analyticsAllowed(decision, mode, readGpcSignal());
136
+ }
137
+ function readStoredSession(siteId) {
138
+ try {
139
+ return window.sessionStorage.getItem(`wr:session:${siteId}`);
140
+ } catch {
141
+ return null;
142
+ }
143
+ }
144
+ function storeSession(siteId, value) {
145
+ try {
146
+ window.sessionStorage.setItem(`wr:session:${siteId}`, value);
147
+ } catch {
148
+ }
149
+ }
150
+ async function postFirstPartyEvent(args, configOverride) {
151
+ const config = configOverride ?? getGlobalSiteConfig();
152
+ if (!config) return;
153
+ if (config.visitors?.enabled || !config.analyticsEndpoint || !config.siteId) return;
154
+ if (!isConsentCurrentlyAllowed(config)) return;
155
+ const currentSessionId = inMemorySessionId ?? (typeof window !== "undefined" ? readStoredSession(config.siteId) : null);
156
+ try {
157
+ const response = await fetch(config.analyticsEndpoint, {
158
+ method: "POST",
159
+ headers: {
160
+ "Content-Type": "application/json",
161
+ ...config.analyticsApiKey ? { "x-api-key": config.analyticsApiKey } : {}
162
+ },
163
+ body: JSON.stringify({
164
+ siteId: config.siteId,
165
+ ...currentSessionId ? { sessionId: currentSessionId } : {},
166
+ eventName: args.eventName,
167
+ pageSlug: args.pageSlug,
168
+ ...args.payload ? { payload: args.payload } : {},
169
+ createSessionIfMissing: args.createSessionIfMissing ?? !currentSessionId
170
+ })
171
+ });
172
+ if (response.ok) {
173
+ const data = await response.json();
174
+ if (data.sessionId && !currentSessionId) {
175
+ inMemorySessionId = data.sessionId;
176
+ if (typeof window !== "undefined") {
177
+ storeSession(config.siteId, data.sessionId);
178
+ }
179
+ }
180
+ }
181
+ } catch {
182
+ }
183
+ }
184
+ function trackPageView(pageSlug, config) {
185
+ void postFirstPartyEvent(
186
+ { eventName: "page_view", pageSlug, createSessionIfMissing: true },
187
+ config
188
+ );
189
+ }
190
+ function trackEvent(eventName, pageSlug, payload, config) {
191
+ void postFirstPartyEvent({ eventName, pageSlug, payload }, config);
192
+ }
193
+ function trackCtaClick(ctaLabel, pageSlug, config) {
194
+ void postFirstPartyEvent(
195
+ { eventName: "cta_click", pageSlug, payload: { ctaLabel } },
196
+ config
197
+ );
198
+ }
199
+ function trackFormSubmission(formId, pageSlug, config) {
200
+ void postFirstPartyEvent(
201
+ { eventName: "form_submission", pageSlug, payload: { formId } },
202
+ config
203
+ );
204
+ }
205
+ function trackBookingCompleted(provider, pageSlug, config) {
206
+ void postFirstPartyEvent(
207
+ { eventName: "booking_completed", pageSlug, payload: { provider } },
208
+ config
209
+ );
210
+ }
211
+ function pushDataLayerEvent(event, extra, configOverride) {
212
+ if (typeof window === "undefined") return false;
213
+ const config = configOverride ?? getGlobalSiteConfig();
214
+ if (!config || !isConsentCurrentlyAllowed(config)) return false;
215
+ const win = window;
216
+ win.dataLayer = win.dataLayer || [];
217
+ win.dataLayer.push({ event, ...extra });
218
+ return true;
219
+ }
220
+
221
+ export {
222
+ captureAttributionOnLanding,
223
+ readAttributionSnapshot,
224
+ readConsentedWebsiteVisit,
225
+ trackPageView,
226
+ trackEvent,
227
+ trackCtaClick,
228
+ trackFormSubmission,
229
+ trackBookingCompleted,
230
+ pushDataLayerEvent
231
+ };
@@ -0,0 +1,214 @@
1
+ "use client";
2
+ import {
3
+ useConsent
4
+ } from "./chunk-7GDXQ6UB.js";
5
+
6
+ // src/consent/banner.tsx
7
+ import { useEffect, useId, useRef } from "react";
8
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
+ function PrivacyChoicesButton({
10
+ label = "Privacy choices",
11
+ className,
12
+ onClick,
13
+ ...rest
14
+ }) {
15
+ const { openPreferences, registerTriggerRef } = useConsent();
16
+ return /* @__PURE__ */ jsx(
17
+ "button",
18
+ {
19
+ ref: registerTriggerRef,
20
+ type: "button",
21
+ "data-wr-privacy-choices": "",
22
+ className,
23
+ onClick: (e) => {
24
+ onClick?.(e);
25
+ if (!e.defaultPrevented) openPreferences();
26
+ },
27
+ ...rest,
28
+ children: label
29
+ }
30
+ );
31
+ }
32
+ function ConsentBanner({
33
+ floatingButtonClassName,
34
+ bannerClassName
35
+ } = {}) {
36
+ const {
37
+ config,
38
+ mode,
39
+ gpc,
40
+ bannerOpen,
41
+ reopened,
42
+ accept,
43
+ decline,
44
+ closePreferences
45
+ } = useConsent();
46
+ const headingId = useId();
47
+ const dialogRef = useRef(null);
48
+ useEffect(() => {
49
+ if (!bannerOpen) return;
50
+ if (reopened) {
51
+ dialogRef.current?.focus();
52
+ }
53
+ const onKeyDown = (e) => {
54
+ if (e.key === "Escape" && reopened) {
55
+ e.preventDefault();
56
+ closePreferences();
57
+ }
58
+ };
59
+ window.addEventListener("keydown", onKeyDown);
60
+ return () => window.removeEventListener("keydown", onKeyDown);
61
+ }, [bannerOpen, reopened, closePreferences]);
62
+ if (config.consent?.enabled === false) return null;
63
+ const isOptOut = mode === "opt-out" && !gpc;
64
+ const message = config.consent?.message?.trim() || (isOptOut ? "We use cookies to understand website visits. You can turn analytics off at any time." : "May we use cookies to understand website visits? Forms and core site features work either way.");
65
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
66
+ !config.consent?.hideFloatingPrivacyButton && /* @__PURE__ */ jsx(
67
+ PrivacyChoicesButton,
68
+ {
69
+ className: floatingButtonClassName ?? "wr-privacy-trigger",
70
+ style: floatingButtonClassName ? void 0 : {
71
+ position: "fixed",
72
+ bottom: "0.75rem",
73
+ left: "0.75rem",
74
+ zIndex: 40,
75
+ padding: "0.5rem 0.875rem",
76
+ fontSize: "0.875rem",
77
+ lineHeight: 1.25,
78
+ borderRadius: "var(--wr-radius, 0.375rem)",
79
+ border: "1px solid var(--wr-border, #d1d5db)",
80
+ backgroundColor: "var(--wr-surface, #ffffff)",
81
+ color: "var(--wr-foreground, #111827)",
82
+ cursor: "pointer"
83
+ }
84
+ }
85
+ ),
86
+ bannerOpen && /* @__PURE__ */ jsx(
87
+ "section",
88
+ {
89
+ ref: dialogRef,
90
+ role: "dialog",
91
+ "aria-modal": reopened ? "true" : void 0,
92
+ "aria-labelledby": headingId,
93
+ tabIndex: -1,
94
+ "data-wr-consent-banner": "",
95
+ className: bannerClassName,
96
+ style: bannerClassName ? void 0 : {
97
+ position: "fixed",
98
+ bottom: 0,
99
+ left: 0,
100
+ right: 0,
101
+ zIndex: 50,
102
+ borderTop: "1px solid var(--wr-border, #d1d5db)",
103
+ backgroundColor: "var(--wr-surface, #ffffff)",
104
+ color: "var(--wr-foreground, #111827)",
105
+ padding: "1.25rem 1.5rem",
106
+ boxShadow: "0 -4px 20px rgba(0, 0, 0, 0.12)"
107
+ },
108
+ children: /* @__PURE__ */ jsxs(
109
+ "div",
110
+ {
111
+ style: {
112
+ maxWidth: "72rem",
113
+ margin: "0 auto",
114
+ display: "flex",
115
+ flexWrap: "wrap",
116
+ alignItems: "center",
117
+ justifyContent: "space-between",
118
+ gap: "1rem"
119
+ },
120
+ children: [
121
+ /* @__PURE__ */ jsxs("div", { style: { flex: "1 1 20rem" }, children: [
122
+ /* @__PURE__ */ jsx(
123
+ "h2",
124
+ {
125
+ id: headingId,
126
+ style: {
127
+ margin: "0 0 0.25rem",
128
+ fontSize: "1rem",
129
+ fontWeight: 600
130
+ },
131
+ children: "Cookie preferences"
132
+ }
133
+ ),
134
+ /* @__PURE__ */ jsxs("p", { style: { margin: 0, fontSize: "0.875rem", lineHeight: 1.5 }, children: [
135
+ message,
136
+ " ",
137
+ config.consent?.policyUrl && /* @__PURE__ */ jsx(
138
+ "a",
139
+ {
140
+ href: config.consent.policyUrl,
141
+ style: { textDecoration: "underline", color: "inherit" },
142
+ children: "Privacy policy"
143
+ }
144
+ )
145
+ ] })
146
+ ] }),
147
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexWrap: "wrap", gap: "0.625rem" }, children: [
148
+ reopened && /* @__PURE__ */ jsx(
149
+ "button",
150
+ {
151
+ type: "button",
152
+ onClick: closePreferences,
153
+ style: {
154
+ padding: "0.5rem 1rem",
155
+ fontSize: "0.875rem",
156
+ borderRadius: "var(--wr-radius, 0.375rem)",
157
+ border: "1px solid var(--wr-border, #d1d5db)",
158
+ background: "transparent",
159
+ color: "inherit",
160
+ cursor: "pointer"
161
+ },
162
+ children: "Close"
163
+ }
164
+ ),
165
+ /* @__PURE__ */ jsx(
166
+ "button",
167
+ {
168
+ type: "button",
169
+ "data-wr-consent-action": "decline",
170
+ onClick: decline,
171
+ style: {
172
+ padding: "0.5rem 1rem",
173
+ fontSize: "0.875rem",
174
+ borderRadius: "var(--wr-radius, 0.375rem)",
175
+ border: "1px solid var(--wr-border, #6b7280)",
176
+ backgroundColor: "transparent",
177
+ color: "inherit",
178
+ cursor: "pointer"
179
+ },
180
+ children: "Decline analytics"
181
+ }
182
+ ),
183
+ /* @__PURE__ */ jsx(
184
+ "button",
185
+ {
186
+ type: "button",
187
+ "data-wr-consent-action": "accept",
188
+ onClick: accept,
189
+ style: {
190
+ padding: "0.5rem 1rem",
191
+ fontSize: "0.875rem",
192
+ fontWeight: 600,
193
+ borderRadius: "var(--wr-radius, 0.375rem)",
194
+ border: "1px solid transparent",
195
+ backgroundColor: "var(--wr-primary, #111827)",
196
+ color: "var(--wr-primary-foreground, #ffffff)",
197
+ cursor: "pointer"
198
+ },
199
+ children: "Allow analytics"
200
+ }
201
+ )
202
+ ] })
203
+ ]
204
+ }
205
+ )
206
+ }
207
+ )
208
+ ] });
209
+ }
210
+
211
+ export {
212
+ PrivacyChoicesButton,
213
+ ConsentBanner
214
+ };
@@ -0,0 +1,20 @@
1
+ import { S as SiteConfig } from '../schema-C1ixytx2.js';
2
+ export { B as BlogConfig, a as BookingConfig, C as ComplianceConfig, b as ConsentConfig, c as CtaLink, D as DEFAULT_ANALYTICS_ENDPOINT, d as DEFAULT_LEADS_API_URL, F as FooterGroup, I as IntegrationsConfig, N as NavItem, e as SocialLink, V as VisitorsConfig, f as blogConfigSchema, g as bookingConfigSchema, h as complianceConfigSchema, i as consentConfigSchema, j as ctaLinkSchema, k as displayNameFromLegal, l as footerGroupSchema, m as integrationsConfigSchema, n as navItemSchema, s as siteConfigSchema, o as socialLinkSchema, v as visitorsConfigSchema } from '../schema-C1ixytx2.js';
3
+ import { Metadata } from 'next';
4
+ import 'zod';
5
+ import '../regulatory-schema-uDKNJ7q8.js';
6
+
7
+ /** Validates and normalizes raw `data/site-config.json` into a typed SiteConfig. */
8
+ declare function normalizeSiteConfig(raw: unknown): SiteConfig;
9
+ /** Helper for defining and caching a client site's normalized config once at module load. */
10
+ declare function defineSiteConfig(raw: unknown): () => SiteConfig;
11
+ /** Optional singleton registry for shared client hooks when SiteShell/ConsentProvider is absent. */
12
+ declare function setGlobalSiteConfig(config: SiteConfig): void;
13
+ declare function getGlobalSiteConfig(): SiteConfig | null;
14
+
15
+ declare function buildMetadata(config: SiteConfig, overrides?: Partial<Metadata>): Metadata;
16
+ declare function buildOrganizationJsonLd(config: SiteConfig): Record<string, unknown> | null;
17
+ /** XSS-safe JSON serialization for inline `<script type="application/ld+json">`. */
18
+ declare function serializeJsonLd(data: unknown): string;
19
+
20
+ export { SiteConfig, buildMetadata, buildOrganizationJsonLd, defineSiteConfig, getGlobalSiteConfig, normalizeSiteConfig, serializeJsonLd, setGlobalSiteConfig };