@wealthreach/site-kit 0.0.0-stage → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -2
- package/dist/a11y/client.d.ts +23 -0
- package/dist/a11y/client.js +72 -0
- package/dist/a11y/index.d.ts +43 -0
- package/dist/a11y/index.js +194 -0
- package/dist/a11y/shell-client.d.ts +19 -0
- package/dist/a11y/shell-client.js +45 -0
- package/dist/analytics/index.d.ts +47 -0
- package/dist/analytics/index.js +122 -0
- package/dist/attribution-DQaAWtA5.d.ts +41 -0
- package/dist/blog/index.d.ts +131 -0
- package/dist/blog/index.js +259 -0
- package/dist/chunk-4YRCSRZZ.js +32 -0
- package/dist/chunk-7GDXQ6UB.js +772 -0
- package/dist/chunk-QQP7VG2C.js +231 -0
- package/dist/chunk-Y77ARZE4.js +214 -0
- package/dist/config/index.d.ts +20 -0
- package/dist/config/index.js +445 -0
- package/dist/consent/index.d.ts +103 -0
- package/dist/consent/index.js +61 -0
- package/dist/disclosures/index.d.ts +57 -0
- package/dist/disclosures/index.js +361 -0
- package/dist/forms/index.d.ts +128 -0
- package/dist/forms/index.js +449 -0
- package/dist/mdx/index.d.ts +15 -0
- package/dist/mdx/index.js +45 -0
- package/dist/next/config.cjs +140 -0
- package/dist/next/config.d.cts +36 -0
- package/dist/next/config.d.ts +36 -0
- package/dist/next/config.js +111 -0
- package/dist/next/draft-route.d.ts +10 -0
- package/dist/next/draft-route.js +49 -0
- package/dist/next/leads-route.d.ts +138 -0
- package/dist/next/leads-route.js +771 -0
- package/dist/next/privacy-mode.d.ts +14 -0
- package/dist/next/privacy-mode.js +86 -0
- package/dist/next/proxy.d.ts +19 -0
- package/dist/next/proxy.js +93 -0
- package/dist/regulatory-schema-uDKNJ7q8.d.ts +1301 -0
- package/dist/schema-C1ixytx2.d.ts +2911 -0
- package/dist/schema-DD0nDOD0.d.ts +1744 -0
- package/package.json +85 -3
|
@@ -0,0 +1,772 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/consent/core.ts
|
|
4
|
+
var CONSENT_COOKIE = "wr_consent";
|
|
5
|
+
var MODE_COOKIE = "privacy_mode";
|
|
6
|
+
var CONSENT_MAX_AGE = 60 * 60 * 24 * 180;
|
|
7
|
+
var MODE_MAX_AGE = 60 * 60 * 24;
|
|
8
|
+
var VISITOR_SCRIPT_ID = "wr-site-script";
|
|
9
|
+
var GTM_SCRIPT_ID = "wr-gtm-script";
|
|
10
|
+
var GA4_SCRIPT_ID = "wr-ga4-script";
|
|
11
|
+
var OPT_IN_COUNTRIES = /* @__PURE__ */ new Set([
|
|
12
|
+
"AT",
|
|
13
|
+
"BE",
|
|
14
|
+
"BG",
|
|
15
|
+
"HR",
|
|
16
|
+
"CY",
|
|
17
|
+
"CZ",
|
|
18
|
+
"DK",
|
|
19
|
+
"EE",
|
|
20
|
+
"FI",
|
|
21
|
+
"FR",
|
|
22
|
+
"DE",
|
|
23
|
+
"GR",
|
|
24
|
+
"HU",
|
|
25
|
+
"IE",
|
|
26
|
+
"IT",
|
|
27
|
+
"LV",
|
|
28
|
+
"LT",
|
|
29
|
+
"LU",
|
|
30
|
+
"MT",
|
|
31
|
+
"NL",
|
|
32
|
+
"PL",
|
|
33
|
+
"PT",
|
|
34
|
+
"RO",
|
|
35
|
+
"SK",
|
|
36
|
+
"SI",
|
|
37
|
+
"ES",
|
|
38
|
+
"SE",
|
|
39
|
+
"IS",
|
|
40
|
+
"LI",
|
|
41
|
+
"NO",
|
|
42
|
+
"GB",
|
|
43
|
+
"CH"
|
|
44
|
+
]);
|
|
45
|
+
var DEFAULT_OPT_IN_US_REGIONS = /* @__PURE__ */ new Set(["CA"]);
|
|
46
|
+
function privacyModeForLocation(country, region, extraOptInUsRegions = []) {
|
|
47
|
+
if (!country) return "opt-in";
|
|
48
|
+
const cc = country.trim().toUpperCase();
|
|
49
|
+
if (!cc || OPT_IN_COUNTRIES.has(cc)) return "opt-in";
|
|
50
|
+
if (cc === "US" && region) {
|
|
51
|
+
const r = region.trim().toUpperCase();
|
|
52
|
+
if (DEFAULT_OPT_IN_US_REGIONS.has(r) || extraOptInUsRegions.some((extra) => extra.trim().toUpperCase() === r)) {
|
|
53
|
+
return "opt-in";
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return "opt-out";
|
|
57
|
+
}
|
|
58
|
+
function analyticsAllowed(consent, mode, gpcSignal) {
|
|
59
|
+
if (consent === "analytics:yes") return true;
|
|
60
|
+
if (consent === "analytics:no") return false;
|
|
61
|
+
return mode === "opt-out" && !gpcSignal;
|
|
62
|
+
}
|
|
63
|
+
function parseConsentValue(raw) {
|
|
64
|
+
if (!raw) return null;
|
|
65
|
+
if (raw === "analytics:yes" || raw === "analytics:no") return raw;
|
|
66
|
+
if (raw.includes("analytics:yes")) return "analytics:yes";
|
|
67
|
+
if (raw.includes("analytics:no")) return "analytics:no";
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
function readCookieFromString(cookieHeader, name) {
|
|
71
|
+
if (!cookieHeader) return null;
|
|
72
|
+
const parts = cookieHeader.split("; ");
|
|
73
|
+
for (const part of parts) {
|
|
74
|
+
if (part.startsWith(`${name}=`)) {
|
|
75
|
+
try {
|
|
76
|
+
return decodeURIComponent(part.slice(name.length + 1));
|
|
77
|
+
} catch {
|
|
78
|
+
return part.slice(name.length + 1);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
function readBrowserCookie(name) {
|
|
85
|
+
if (typeof document === "undefined") return null;
|
|
86
|
+
try {
|
|
87
|
+
return readCookieFromString(document.cookie, name);
|
|
88
|
+
} catch {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function readStoredConsent(legacyCookieNames = []) {
|
|
93
|
+
const direct = parseConsentValue(readBrowserCookie(CONSENT_COOKIE));
|
|
94
|
+
if (direct) return direct;
|
|
95
|
+
for (const legacy of legacyCookieNames) {
|
|
96
|
+
const migrated = parseConsentValue(readBrowserCookie(legacy));
|
|
97
|
+
if (migrated) return migrated;
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
function writeConsentCookie(value) {
|
|
102
|
+
if (typeof document === "undefined") return;
|
|
103
|
+
try {
|
|
104
|
+
const secure = typeof window !== "undefined" && window.location.protocol === "https:" ? "; Secure" : "";
|
|
105
|
+
document.cookie = `${CONSENT_COOKIE}=${encodeURIComponent(value)}; Path=/; Max-Age=${CONSENT_MAX_AGE}; SameSite=Lax${secure}`;
|
|
106
|
+
} catch {
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function readGpcSignal() {
|
|
110
|
+
if (typeof navigator === "undefined") return false;
|
|
111
|
+
return navigator.globalPrivacyControl === true;
|
|
112
|
+
}
|
|
113
|
+
function resolveGeoFromHeaders(headers) {
|
|
114
|
+
return {
|
|
115
|
+
country: headers.get("x-vercel-ip-country"),
|
|
116
|
+
region: headers.get("x-vercel-ip-country-region")
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// src/consent/bootstrap.ts
|
|
121
|
+
function safeJson(value) {
|
|
122
|
+
return JSON.stringify(value).replace(/</g, "\\u003c");
|
|
123
|
+
}
|
|
124
|
+
var GTM_ID_RE = /^GTM-[A-Z0-9]{4,16}$/;
|
|
125
|
+
var GA4_ID_RE = /^G-[A-Z0-9]{4,16}$/;
|
|
126
|
+
var ALLOWED_VISITOR_HOST_RE = /(?:^|\.)wealthreach\.(?:ai|com)$/i;
|
|
127
|
+
function sanitizeVisitorScriptUrl(raw) {
|
|
128
|
+
const trimmed = raw?.trim() || "";
|
|
129
|
+
if (!trimmed) return "";
|
|
130
|
+
if (trimmed.startsWith("/") && !trimmed.startsWith("//") && !trimmed.includes("\\")) {
|
|
131
|
+
return trimmed;
|
|
132
|
+
}
|
|
133
|
+
try {
|
|
134
|
+
const parsed = new URL(trimmed);
|
|
135
|
+
if (parsed.protocol === "https:" && ALLOWED_VISITOR_HOST_RE.test(parsed.hostname)) {
|
|
136
|
+
return parsed.toString();
|
|
137
|
+
}
|
|
138
|
+
} catch {
|
|
139
|
+
}
|
|
140
|
+
return "";
|
|
141
|
+
}
|
|
142
|
+
function sanitizeGtmId(raw) {
|
|
143
|
+
const trimmed = raw?.trim() || "";
|
|
144
|
+
return GTM_ID_RE.test(trimmed) ? trimmed : "";
|
|
145
|
+
}
|
|
146
|
+
function sanitizeGa4Id(raw) {
|
|
147
|
+
const trimmed = raw?.trim() || "";
|
|
148
|
+
return GA4_ID_RE.test(trimmed) ? trimmed : "";
|
|
149
|
+
}
|
|
150
|
+
function buildConsentBootstrapScript(options) {
|
|
151
|
+
const visitorUrl = sanitizeVisitorScriptUrl(options.visitorScriptUrl);
|
|
152
|
+
const gtmId = sanitizeGtmId(options.gtmId);
|
|
153
|
+
const ga4Id = sanitizeGa4Id(options.ga4MeasurementId);
|
|
154
|
+
if (!visitorUrl && !gtmId && !ga4Id) return null;
|
|
155
|
+
const legacy = options.legacyConsentCookies ?? [];
|
|
156
|
+
const loaders = [];
|
|
157
|
+
if (visitorUrl) {
|
|
158
|
+
loaders.push(
|
|
159
|
+
`if(!document.getElementById('${VISITOR_SCRIPT_ID}')){var s=document.createElement('script');s.id='${VISITOR_SCRIPT_ID}';s.async=true;s.src=${safeJson(visitorUrl)};s.setAttribute('data-consent-category','analytics');document.head.appendChild(s);}`
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
if (gtmId) {
|
|
163
|
+
loaders.push(
|
|
164
|
+
`if(!document.getElementById('${GTM_SCRIPT_ID}')){window.dataLayer=window.dataLayer||[];window.dataLayer.push({'gtm.start':Date.now(),event:'gtm.js'});var g=document.createElement('script');g.id='${GTM_SCRIPT_ID}';g.async=true;g.src=${safeJson(`https://www.googletagmanager.com/gtm.js?id=${encodeURIComponent(gtmId)}`)};g.setAttribute('data-consent-category','analytics');document.head.appendChild(g);}`
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
if (ga4Id) {
|
|
168
|
+
loaders.push(
|
|
169
|
+
`if(!document.getElementById('${GA4_SCRIPT_ID}')){window.dataLayer=window.dataLayer||[];function gtag(){window.dataLayer.push(arguments);}window.gtag=window.gtag||gtag;gtag('js',new Date());gtag('config',${safeJson(ga4Id)});var a=document.createElement('script');a.id='${GA4_SCRIPT_ID}';a.async=true;a.src=${safeJson(`https://www.googletagmanager.com/gtag/js?id=${encodeURIComponent(ga4Id)}`)};a.setAttribute('data-consent-category','analytics');document.head.appendChild(a);}`
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
return `(function(){try{var g=function(n){var p=document.cookie.split('; ').find(function(v){return v.indexOf(n+'=')===0});return p?decodeURIComponent(p.slice(n.length+1)):null};var c=g('${CONSENT_COOKIE}');if(!c){var leg=${safeJson(legacy)};for(var i=0;i<leg.length;i++){var lv=g(leg[i]);if(lv){c=lv.indexOf('analytics:yes')>-1?'analytics:yes':lv.indexOf('analytics:no')>-1?'analytics:no':null;if(c)break;}}}if(c==='analytics:no')return;var gpc=navigator.globalPrivacyControl===true;if(c!=='analytics:yes'&&!(g('${MODE_COOKIE}')==='opt-out'&&!gpc))return;${loaders.join("")}}catch(e){}})();`;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// src/consent/provider.tsx
|
|
176
|
+
import {
|
|
177
|
+
createContext,
|
|
178
|
+
useCallback,
|
|
179
|
+
useContext,
|
|
180
|
+
useEffect,
|
|
181
|
+
useMemo,
|
|
182
|
+
useRef,
|
|
183
|
+
useState
|
|
184
|
+
} from "react";
|
|
185
|
+
|
|
186
|
+
// src/config/schema.ts
|
|
187
|
+
import { z as z2 } from "zod";
|
|
188
|
+
|
|
189
|
+
// src/disclosures/regulatory-schema.ts
|
|
190
|
+
import { z } from "zod";
|
|
191
|
+
var text = z.string().trim().min(1);
|
|
192
|
+
var httpsUrl = z.string().trim().url().refine((value) => value.startsWith("https://"), {
|
|
193
|
+
message: "must be an https:// URL"
|
|
194
|
+
});
|
|
195
|
+
var urlOrPath = z.string().trim().min(1).refine(
|
|
196
|
+
(value) => value.startsWith("https://") || value.startsWith("/") && !value.startsWith("//"),
|
|
197
|
+
{ message: "must be an https:// URL or site-relative /path" }
|
|
198
|
+
);
|
|
199
|
+
var US_STATES = {
|
|
200
|
+
AL: "Alabama",
|
|
201
|
+
AK: "Alaska",
|
|
202
|
+
AZ: "Arizona",
|
|
203
|
+
AR: "Arkansas",
|
|
204
|
+
CA: "California",
|
|
205
|
+
CO: "Colorado",
|
|
206
|
+
CT: "Connecticut",
|
|
207
|
+
DE: "Delaware",
|
|
208
|
+
DC: "District of Columbia",
|
|
209
|
+
FL: "Florida",
|
|
210
|
+
GA: "Georgia",
|
|
211
|
+
HI: "Hawaii",
|
|
212
|
+
ID: "Idaho",
|
|
213
|
+
IL: "Illinois",
|
|
214
|
+
IN: "Indiana",
|
|
215
|
+
IA: "Iowa",
|
|
216
|
+
KS: "Kansas",
|
|
217
|
+
KY: "Kentucky",
|
|
218
|
+
LA: "Louisiana",
|
|
219
|
+
ME: "Maine",
|
|
220
|
+
MD: "Maryland",
|
|
221
|
+
MA: "Massachusetts",
|
|
222
|
+
MI: "Michigan",
|
|
223
|
+
MN: "Minnesota",
|
|
224
|
+
MS: "Mississippi",
|
|
225
|
+
MO: "Missouri",
|
|
226
|
+
MT: "Montana",
|
|
227
|
+
NE: "Nebraska",
|
|
228
|
+
NV: "Nevada",
|
|
229
|
+
NH: "New Hampshire",
|
|
230
|
+
NJ: "New Jersey",
|
|
231
|
+
NM: "New Mexico",
|
|
232
|
+
NY: "New York",
|
|
233
|
+
NC: "North Carolina",
|
|
234
|
+
ND: "North Dakota",
|
|
235
|
+
OH: "Ohio",
|
|
236
|
+
OK: "Oklahoma",
|
|
237
|
+
OR: "Oregon",
|
|
238
|
+
PA: "Pennsylvania",
|
|
239
|
+
RI: "Rhode Island",
|
|
240
|
+
SC: "South Carolina",
|
|
241
|
+
SD: "South Dakota",
|
|
242
|
+
TN: "Tennessee",
|
|
243
|
+
TX: "Texas",
|
|
244
|
+
UT: "Utah",
|
|
245
|
+
VT: "Vermont",
|
|
246
|
+
VA: "Virginia",
|
|
247
|
+
WA: "Washington",
|
|
248
|
+
WV: "West Virginia",
|
|
249
|
+
WI: "Wisconsin",
|
|
250
|
+
WY: "Wyoming"
|
|
251
|
+
};
|
|
252
|
+
var PROVINCES = {
|
|
253
|
+
AB: "Alberta",
|
|
254
|
+
BC: "British Columbia",
|
|
255
|
+
MB: "Manitoba",
|
|
256
|
+
NB: "New Brunswick",
|
|
257
|
+
NL: "Newfoundland and Labrador",
|
|
258
|
+
NS: "Nova Scotia",
|
|
259
|
+
NT: "Northwest Territories",
|
|
260
|
+
NU: "Nunavut",
|
|
261
|
+
ON: "Ontario",
|
|
262
|
+
PE: "Prince Edward Island",
|
|
263
|
+
QC: "Quebec",
|
|
264
|
+
SK: "Saskatchewan",
|
|
265
|
+
YT: "Yukon"
|
|
266
|
+
};
|
|
267
|
+
var keys = (o) => Object.keys(o);
|
|
268
|
+
var usStateSchema = z.enum(keys(US_STATES));
|
|
269
|
+
var provinceSchema = z.enum(keys(PROVINCES));
|
|
270
|
+
var crdSchema = z.string().regex(/^[0-9]{1,10}$/, "must be a CRD number, digits only");
|
|
271
|
+
var statesSchema = z.array(usStateSchema).min(1, "must name at least one state");
|
|
272
|
+
var regulatorSchema = z.union([
|
|
273
|
+
z.strictObject({ sec: z.literal(true) }),
|
|
274
|
+
z.strictObject({
|
|
275
|
+
states: statesSchema,
|
|
276
|
+
exemptElsewhere: z.boolean().default(false)
|
|
277
|
+
})
|
|
278
|
+
]);
|
|
279
|
+
var membershipSchema = z.enum(["FINRA", "SIPC", "MSRB"]);
|
|
280
|
+
var adviserEntitySchema = z.strictObject({
|
|
281
|
+
legalName: text,
|
|
282
|
+
regulator: regulatorSchema,
|
|
283
|
+
crd: crdSchema.optional(),
|
|
284
|
+
formAdvUrl: urlOrPath.optional(),
|
|
285
|
+
formCrsUrl: urlOrPath.optional()
|
|
286
|
+
});
|
|
287
|
+
var brokerDealerEntitySchema = z.strictObject({
|
|
288
|
+
legalName: text,
|
|
289
|
+
memberships: z.array(membershipSchema).min(1),
|
|
290
|
+
crd: crdSchema.optional()
|
|
291
|
+
});
|
|
292
|
+
var dualFirmSchema = brokerDealerEntitySchema.extend({
|
|
293
|
+
regulator: regulatorSchema,
|
|
294
|
+
formAdvUrl: urlOrPath.optional(),
|
|
295
|
+
formCrsUrl: urlOrPath.optional()
|
|
296
|
+
});
|
|
297
|
+
var transactsSchema = z.union([statesSchema, z.literal("registered-states")]);
|
|
298
|
+
var addOns = {
|
|
299
|
+
affiliates: z.array(
|
|
300
|
+
z.strictObject({
|
|
301
|
+
role: z.enum(["insurance", "tax", "law", "planning"]),
|
|
302
|
+
legalName: text,
|
|
303
|
+
relation: z.enum(["affiliated", "unaffiliated"]),
|
|
304
|
+
licensedStates: statesSchema.optional()
|
|
305
|
+
})
|
|
306
|
+
).optional(),
|
|
307
|
+
custodian: text.optional()
|
|
308
|
+
};
|
|
309
|
+
var houseText = z.boolean().optional();
|
|
310
|
+
var regulatorySchema = z.discriminatedUnion("kind", [
|
|
311
|
+
z.strictObject({
|
|
312
|
+
kind: z.literal("adviser"),
|
|
313
|
+
regulator: regulatorSchema,
|
|
314
|
+
crd: crdSchema.optional(),
|
|
315
|
+
formAdvUrl: urlOrPath.optional(),
|
|
316
|
+
formCrsUrl: urlOrPath.optional(),
|
|
317
|
+
secFileNumber: z.string().regex(/^[0-9]{3}-[0-9]{1,6}$/, "must be an SEC file number such as 801-12345").optional(),
|
|
318
|
+
...addOns
|
|
319
|
+
}),
|
|
320
|
+
z.strictObject({
|
|
321
|
+
kind: z.literal("adviser-representative"),
|
|
322
|
+
adviser: adviserEntitySchema,
|
|
323
|
+
relation: z.enum(["dba", "affiliated", "unaffiliated"]),
|
|
324
|
+
...addOns
|
|
325
|
+
}),
|
|
326
|
+
z.strictObject({
|
|
327
|
+
kind: z.literal("broker-dealer-and-adviser"),
|
|
328
|
+
brokerDealer: brokerDealerEntitySchema,
|
|
329
|
+
adviser: adviserEntitySchema,
|
|
330
|
+
relation: z.literal("unaffiliated"),
|
|
331
|
+
transacts: transactsSchema,
|
|
332
|
+
clearingFirm: text.optional(),
|
|
333
|
+
brokerCheck: httpsUrl.optional(),
|
|
334
|
+
houseText,
|
|
335
|
+
...addOns
|
|
336
|
+
}),
|
|
337
|
+
z.strictObject({
|
|
338
|
+
kind: z.literal("dual-registrant"),
|
|
339
|
+
firm: dualFirmSchema,
|
|
340
|
+
capacities: z.array(z.enum(["registered-representative", "investment-adviser-representative"])).min(1),
|
|
341
|
+
transacts: transactsSchema,
|
|
342
|
+
brokerCheck: httpsUrl.optional(),
|
|
343
|
+
houseText,
|
|
344
|
+
...addOns
|
|
345
|
+
}),
|
|
346
|
+
z.strictObject({
|
|
347
|
+
kind: z.literal("broker-dealer-representative"),
|
|
348
|
+
brokerDealer: brokerDealerEntitySchema,
|
|
349
|
+
transacts: transactsSchema,
|
|
350
|
+
clearingFirm: text.optional(),
|
|
351
|
+
brokerCheck: httpsUrl.optional(),
|
|
352
|
+
houseText,
|
|
353
|
+
...addOns
|
|
354
|
+
}),
|
|
355
|
+
z.strictObject({
|
|
356
|
+
kind: z.literal("insurance-only"),
|
|
357
|
+
licensedStates: statesSchema,
|
|
358
|
+
...addOns
|
|
359
|
+
}),
|
|
360
|
+
z.strictObject({
|
|
361
|
+
kind: z.literal("canadian-dealer-representative"),
|
|
362
|
+
dealer: z.strictObject({
|
|
363
|
+
legalName: text,
|
|
364
|
+
sro: z.literal("CIRO"),
|
|
365
|
+
protectionFund: z.literal("CIPF")
|
|
366
|
+
}),
|
|
367
|
+
provinces: z.array(provinceSchema).min(1, "must name at least one province"),
|
|
368
|
+
tradeName: z.boolean(),
|
|
369
|
+
productScope: text.optional(),
|
|
370
|
+
...addOns
|
|
371
|
+
}),
|
|
372
|
+
z.strictObject({ kind: z.literal("not-regulated"), ...addOns }),
|
|
373
|
+
z.strictObject({
|
|
374
|
+
kind: z.literal("unclassified"),
|
|
375
|
+
crd: crdSchema.optional(),
|
|
376
|
+
formAdvUrl: urlOrPath.optional()
|
|
377
|
+
})
|
|
378
|
+
]);
|
|
379
|
+
|
|
380
|
+
// src/config/schema.ts
|
|
381
|
+
var DEFAULT_LEADS_API_URL = "https://attract.wealthreach.ai/api/attract/site-leads";
|
|
382
|
+
var DEFAULT_ANALYTICS_ENDPOINT = "https://attract.wealthreach.ai/api/analytics/events";
|
|
383
|
+
var navItemSchema = z2.object({
|
|
384
|
+
label: z2.string().trim().min(1),
|
|
385
|
+
href: z2.string().trim().min(1)
|
|
386
|
+
});
|
|
387
|
+
var ctaLinkSchema = z2.object({
|
|
388
|
+
label: z2.string().trim().min(1),
|
|
389
|
+
href: z2.string().trim().min(1)
|
|
390
|
+
});
|
|
391
|
+
var socialLinkSchema = z2.object({
|
|
392
|
+
platform: z2.string().trim().min(1),
|
|
393
|
+
url: z2.string().trim().min(1)
|
|
394
|
+
});
|
|
395
|
+
var footerGroupSchema = z2.object({
|
|
396
|
+
heading: z2.string().trim().min(1),
|
|
397
|
+
links: z2.array(navItemSchema)
|
|
398
|
+
});
|
|
399
|
+
var bookingConfigSchema = z2.object({
|
|
400
|
+
provider: z2.enum(["calendly", "calcom", "none"]).default("none"),
|
|
401
|
+
url: z2.string().trim().optional().default(""),
|
|
402
|
+
mode: z2.enum(["embed", "link"]).default("link")
|
|
403
|
+
});
|
|
404
|
+
var consentConfigSchema = z2.object({
|
|
405
|
+
enabled: z2.boolean().default(true),
|
|
406
|
+
message: z2.string().trim().optional().default(""),
|
|
407
|
+
policyUrl: z2.string().trim().optional().default("/privacy-policy"),
|
|
408
|
+
/** Legacy cookie names to migrate silently for returning visitors (e.g. Brandywine Oak). */
|
|
409
|
+
legacyConsentCookies: z2.array(z2.string().trim().min(1)).optional().default([]),
|
|
410
|
+
/** Additional US states requiring opt-in beyond California (CA is always opt-in). */
|
|
411
|
+
extraOptInUsRegions: z2.array(z2.string().trim().length(2)).optional().default([]),
|
|
412
|
+
/** Set true if the site renders its own footer PrivacyChoicesButton instead of the floating one. */
|
|
413
|
+
hideFloatingPrivacyButton: z2.boolean().optional().default(false)
|
|
414
|
+
});
|
|
415
|
+
var visitorsConfigSchema = z2.object({
|
|
416
|
+
enabled: z2.boolean().default(false),
|
|
417
|
+
siteScriptUrl: z2.string().trim().optional().default("")
|
|
418
|
+
});
|
|
419
|
+
var blogConfigSchema = z2.object({
|
|
420
|
+
enabled: z2.boolean().optional().default(true),
|
|
421
|
+
routeSegment: z2.string().trim().min(1).optional().default("blog"),
|
|
422
|
+
postsDir: z2.string().trim().min(1).optional().default("data/blog"),
|
|
423
|
+
model: z2.enum(["data-module", "content-collection"]).optional().default("content-collection")
|
|
424
|
+
});
|
|
425
|
+
var complianceConfigSchema = z2.object({
|
|
426
|
+
disclosures: z2.array(z2.string()).default([]),
|
|
427
|
+
regulatory: regulatorySchema.optional(),
|
|
428
|
+
formAdvUrl: z2.string().trim().optional(),
|
|
429
|
+
formCrsUrl: z2.string().trim().optional(),
|
|
430
|
+
crd: z2.string().trim().optional(),
|
|
431
|
+
brokerCheckUrl: z2.string().trim().optional()
|
|
432
|
+
});
|
|
433
|
+
var integrationsConfigSchema = z2.object({
|
|
434
|
+
gtmId: z2.string().trim().optional(),
|
|
435
|
+
ga4MeasurementId: z2.string().trim().optional(),
|
|
436
|
+
vercelAnalytics: z2.boolean().optional().default(false)
|
|
437
|
+
});
|
|
438
|
+
var siteConfigSchema = z2.object({
|
|
439
|
+
version: z2.number().int().min(3).default(3),
|
|
440
|
+
siteId: z2.string().trim().optional().default(""),
|
|
441
|
+
advisorId: z2.string().trim().optional().default(""),
|
|
442
|
+
leadsApiUrl: z2.string().trim().optional().default(DEFAULT_LEADS_API_URL),
|
|
443
|
+
analyticsEndpoint: z2.string().trim().optional().default(DEFAULT_ANALYTICS_ENDPOINT),
|
|
444
|
+
analyticsApiKey: z2.string().trim().optional().default(""),
|
|
445
|
+
brand: z2.object({
|
|
446
|
+
legalName: z2.string().trim().min(1),
|
|
447
|
+
displayName: z2.string().trim().optional().default(""),
|
|
448
|
+
tagline: z2.string().trim().optional().default(""),
|
|
449
|
+
logoUrl: z2.string().trim().optional(),
|
|
450
|
+
ogImageUrl: z2.string().trim().optional()
|
|
451
|
+
}),
|
|
452
|
+
contact: z2.object({
|
|
453
|
+
email: z2.string().trim().optional().default(""),
|
|
454
|
+
phone: z2.string().trim().optional().default(""),
|
|
455
|
+
address: z2.string().trim().optional().default(""),
|
|
456
|
+
calendarUrl: z2.string().trim().optional().default("")
|
|
457
|
+
}).optional().default({ email: "", phone: "", address: "", calendarUrl: "" }),
|
|
458
|
+
booking: bookingConfigSchema.optional().default({
|
|
459
|
+
provider: "none",
|
|
460
|
+
url: "",
|
|
461
|
+
mode: "link"
|
|
462
|
+
}),
|
|
463
|
+
consent: consentConfigSchema.optional().default({
|
|
464
|
+
enabled: true,
|
|
465
|
+
message: "",
|
|
466
|
+
policyUrl: "/privacy-policy",
|
|
467
|
+
legacyConsentCookies: [],
|
|
468
|
+
extraOptInUsRegions: [],
|
|
469
|
+
hideFloatingPrivacyButton: false
|
|
470
|
+
}),
|
|
471
|
+
visitors: visitorsConfigSchema.optional(),
|
|
472
|
+
integrations: integrationsConfigSchema.optional().default({
|
|
473
|
+
vercelAnalytics: false
|
|
474
|
+
}),
|
|
475
|
+
forms: z2.object({
|
|
476
|
+
allowCustomEmailDispatch: z2.boolean().optional().default(false),
|
|
477
|
+
exemptFormIds: z2.array(z2.string()).optional().default([]),
|
|
478
|
+
lead: z2.union([
|
|
479
|
+
z2.literal(false),
|
|
480
|
+
z2.object({
|
|
481
|
+
enabled: z2.boolean().optional().default(true),
|
|
482
|
+
heading: z2.string().optional(),
|
|
483
|
+
buttonText: z2.string().optional(),
|
|
484
|
+
showPhone: z2.boolean().optional(),
|
|
485
|
+
showMessage: z2.boolean().optional()
|
|
486
|
+
}).passthrough()
|
|
487
|
+
]).optional()
|
|
488
|
+
}).passthrough().optional().default({ allowCustomEmailDispatch: false, exemptFormIds: [] }),
|
|
489
|
+
blog: blogConfigSchema.optional().default({
|
|
490
|
+
enabled: true,
|
|
491
|
+
routeSegment: "blog",
|
|
492
|
+
postsDir: "data/blog",
|
|
493
|
+
model: "content-collection"
|
|
494
|
+
}),
|
|
495
|
+
header: z2.object({
|
|
496
|
+
nav: z2.array(navItemSchema).optional().default([]),
|
|
497
|
+
cta: ctaLinkSchema.optional()
|
|
498
|
+
}).optional().default({ nav: [] }),
|
|
499
|
+
footer: z2.object({
|
|
500
|
+
groups: z2.array(footerGroupSchema).optional().default([]),
|
|
501
|
+
social: z2.array(socialLinkSchema).optional().default([])
|
|
502
|
+
}).optional().default({ groups: [], social: [] }),
|
|
503
|
+
seo: z2.object({
|
|
504
|
+
siteUrl: z2.string().trim().optional().default(""),
|
|
505
|
+
lang: z2.string().trim().optional().default("en"),
|
|
506
|
+
defaultTitle: z2.string().trim().optional().default(""),
|
|
507
|
+
titleTemplate: z2.string().trim().optional().default(""),
|
|
508
|
+
defaultDescription: z2.string().trim().optional().default(""),
|
|
509
|
+
ogImageUrl: z2.string().trim().optional(),
|
|
510
|
+
twitterHandle: z2.string().trim().optional()
|
|
511
|
+
}).optional().default({
|
|
512
|
+
siteUrl: "",
|
|
513
|
+
lang: "en",
|
|
514
|
+
defaultTitle: "",
|
|
515
|
+
titleTemplate: "",
|
|
516
|
+
defaultDescription: ""
|
|
517
|
+
}),
|
|
518
|
+
jsonLd: z2.object({
|
|
519
|
+
organization: z2.object({
|
|
520
|
+
type: z2.string().optional().default("FinancialService"),
|
|
521
|
+
sameAs: z2.array(z2.string()).optional(),
|
|
522
|
+
areaServed: z2.union([z2.string(), z2.array(z2.string())]).optional()
|
|
523
|
+
}).optional()
|
|
524
|
+
}).optional(),
|
|
525
|
+
compliance: complianceConfigSchema.optional().default({ disclosures: [] }),
|
|
526
|
+
theme: z2.record(z2.string(), z2.unknown()).optional()
|
|
527
|
+
}).passthrough().transform((parsed) => ({
|
|
528
|
+
...parsed,
|
|
529
|
+
brand: {
|
|
530
|
+
...parsed.brand,
|
|
531
|
+
displayName: parsed.brand.displayName || displayNameFromLegal(parsed.brand.legalName)
|
|
532
|
+
}
|
|
533
|
+
}));
|
|
534
|
+
var LEGAL_SUFFIX_RE = /,?\s+\b(?:LLC|L\.L\.C\.|LLP|L\.L\.P\.|Inc\.?|Corp\.?|Corporation|Ltd\.?|Limited|Co\.?|LP|L\.P\.|PC|P\.C\.|PLLC)\.?$/i;
|
|
535
|
+
function displayNameFromLegal(legalName) {
|
|
536
|
+
return legalName.trim().replace(LEGAL_SUFFIX_RE, "").trim() || legalName.trim();
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
// src/config/loader.ts
|
|
540
|
+
var cachedConfig = null;
|
|
541
|
+
function setGlobalSiteConfig(config) {
|
|
542
|
+
cachedConfig = config;
|
|
543
|
+
}
|
|
544
|
+
function getGlobalSiteConfig() {
|
|
545
|
+
return cachedConfig;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
// src/consent/provider.tsx
|
|
549
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
550
|
+
var CONSENT_CONTEXT_SYMBOL = /* @__PURE__ */ Symbol.for("@wealthreach/site-kit/ConsentContext");
|
|
551
|
+
function getConsentContext() {
|
|
552
|
+
const g = globalThis;
|
|
553
|
+
if (!g[CONSENT_CONTEXT_SYMBOL]) {
|
|
554
|
+
g[CONSENT_CONTEXT_SYMBOL] = createContext(null);
|
|
555
|
+
}
|
|
556
|
+
return g[CONSENT_CONTEXT_SYMBOL];
|
|
557
|
+
}
|
|
558
|
+
var ConsentContext = getConsentContext();
|
|
559
|
+
function mountOptionalScripts(config) {
|
|
560
|
+
if (typeof document === "undefined") return;
|
|
561
|
+
const visitorUrl = config.visitors?.enabled ? sanitizeVisitorScriptUrl(config.visitors.siteScriptUrl) : "";
|
|
562
|
+
if (visitorUrl && !document.getElementById(VISITOR_SCRIPT_ID)) {
|
|
563
|
+
const script = document.createElement("script");
|
|
564
|
+
script.id = VISITOR_SCRIPT_ID;
|
|
565
|
+
script.src = visitorUrl;
|
|
566
|
+
script.async = true;
|
|
567
|
+
script.setAttribute("data-consent-category", "analytics");
|
|
568
|
+
document.head.appendChild(script);
|
|
569
|
+
}
|
|
570
|
+
const gtmId = sanitizeGtmId(config.integrations?.gtmId);
|
|
571
|
+
if (gtmId && !document.getElementById(GTM_SCRIPT_ID)) {
|
|
572
|
+
const win = window;
|
|
573
|
+
win.dataLayer = win.dataLayer || [];
|
|
574
|
+
win.dataLayer.push({ "gtm.start": Date.now(), event: "gtm.js" });
|
|
575
|
+
const script = document.createElement("script");
|
|
576
|
+
script.id = GTM_SCRIPT_ID;
|
|
577
|
+
script.src = `https://www.googletagmanager.com/gtm.js?id=${encodeURIComponent(gtmId)}`;
|
|
578
|
+
script.async = true;
|
|
579
|
+
script.setAttribute("data-consent-category", "analytics");
|
|
580
|
+
document.head.appendChild(script);
|
|
581
|
+
}
|
|
582
|
+
const ga4Id = sanitizeGa4Id(config.integrations?.ga4MeasurementId);
|
|
583
|
+
if (ga4Id && !document.getElementById(GA4_SCRIPT_ID)) {
|
|
584
|
+
const win = window;
|
|
585
|
+
win.dataLayer = win.dataLayer || [];
|
|
586
|
+
const gtag = win.gtag ?? ((...args) => {
|
|
587
|
+
win.dataLayer?.push(args);
|
|
588
|
+
});
|
|
589
|
+
win.gtag = gtag;
|
|
590
|
+
gtag("js", /* @__PURE__ */ new Date());
|
|
591
|
+
gtag("config", ga4Id);
|
|
592
|
+
const script = document.createElement("script");
|
|
593
|
+
script.id = GA4_SCRIPT_ID;
|
|
594
|
+
script.src = `https://www.googletagmanager.com/gtag/js?id=${encodeURIComponent(ga4Id)}`;
|
|
595
|
+
script.async = true;
|
|
596
|
+
script.setAttribute("data-consent-category", "analytics");
|
|
597
|
+
document.head.appendChild(script);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
function hasMountedThirdPartyScripts() {
|
|
601
|
+
if (typeof document === "undefined") return false;
|
|
602
|
+
return Boolean(
|
|
603
|
+
document.getElementById(VISITOR_SCRIPT_ID) || document.getElementById(GTM_SCRIPT_ID) || document.getElementById(GA4_SCRIPT_ID)
|
|
604
|
+
);
|
|
605
|
+
}
|
|
606
|
+
function ConsentProvider({
|
|
607
|
+
config,
|
|
608
|
+
privacyModeEndpoint = "/api/privacy-mode",
|
|
609
|
+
children
|
|
610
|
+
}) {
|
|
611
|
+
setGlobalSiteConfig(config);
|
|
612
|
+
const [mode, setMode] = useState("opt-in");
|
|
613
|
+
const [decision, setDecision] = useState(null);
|
|
614
|
+
const [gpc, setGpc] = useState(false);
|
|
615
|
+
const [ready, setReady] = useState(false);
|
|
616
|
+
const [bannerOpen, setBannerOpen] = useState(false);
|
|
617
|
+
const [reopened, setReopened] = useState(false);
|
|
618
|
+
const triggerRef = useRef(null);
|
|
619
|
+
const registerTriggerRef = useCallback((el) => {
|
|
620
|
+
triggerRef.current = el;
|
|
621
|
+
}, []);
|
|
622
|
+
useEffect(() => {
|
|
623
|
+
let cancelled = false;
|
|
624
|
+
const legacyCookies = config.consent?.legacyConsentCookies ?? [];
|
|
625
|
+
const storedDecision = readStoredConsent(legacyCookies);
|
|
626
|
+
const detectedGpc = readGpcSignal();
|
|
627
|
+
const rawMode = readBrowserCookie(MODE_COOKIE);
|
|
628
|
+
const finalize = (resolvedMode) => {
|
|
629
|
+
if (cancelled) return;
|
|
630
|
+
setMode(resolvedMode);
|
|
631
|
+
setDecision(storedDecision);
|
|
632
|
+
setGpc(detectedGpc);
|
|
633
|
+
setReady(true);
|
|
634
|
+
const isAllowed = analyticsAllowed(storedDecision, resolvedMode, detectedGpc);
|
|
635
|
+
if (isAllowed) {
|
|
636
|
+
mountOptionalScripts(config);
|
|
637
|
+
}
|
|
638
|
+
if (config.consent?.enabled !== false && storedDecision === null) {
|
|
639
|
+
if (resolvedMode === "opt-in" || !detectedGpc) {
|
|
640
|
+
setBannerOpen(true);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
};
|
|
644
|
+
if (rawMode === "opt-in" || rawMode === "opt-out") {
|
|
645
|
+
finalize(rawMode);
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
fetch(privacyModeEndpoint, { cache: "no-store", credentials: "same-origin" }).then((res) => res.ok ? res.json() : null).then((data) => {
|
|
649
|
+
const resolved = data?.mode === "opt-out" ? "opt-out" : "opt-in";
|
|
650
|
+
finalize(resolved);
|
|
651
|
+
}).catch(() => {
|
|
652
|
+
finalize("opt-in");
|
|
653
|
+
});
|
|
654
|
+
return () => {
|
|
655
|
+
cancelled = true;
|
|
656
|
+
};
|
|
657
|
+
}, [config, privacyModeEndpoint]);
|
|
658
|
+
const allowed = useMemo(
|
|
659
|
+
() => ready ? analyticsAllowed(decision, mode, gpc) : false,
|
|
660
|
+
[ready, decision, mode, gpc]
|
|
661
|
+
);
|
|
662
|
+
const choose = useCallback(
|
|
663
|
+
(value2) => {
|
|
664
|
+
const wasMounted = hasMountedThirdPartyScripts();
|
|
665
|
+
writeConsentCookie(value2);
|
|
666
|
+
setDecision(value2);
|
|
667
|
+
setBannerOpen(false);
|
|
668
|
+
setReopened(false);
|
|
669
|
+
if (value2 === "analytics:yes") {
|
|
670
|
+
mountOptionalScripts(config);
|
|
671
|
+
} else if (value2 === "analytics:no") {
|
|
672
|
+
try {
|
|
673
|
+
window.sessionStorage.removeItem(`wr:session:${config.siteId}`);
|
|
674
|
+
} catch {
|
|
675
|
+
}
|
|
676
|
+
if (wasMounted && typeof window !== "undefined") {
|
|
677
|
+
window.location.reload();
|
|
678
|
+
return;
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
requestAnimationFrame(() => triggerRef.current?.focus());
|
|
682
|
+
},
|
|
683
|
+
[config]
|
|
684
|
+
);
|
|
685
|
+
const accept = useCallback(() => choose("analytics:yes"), [choose]);
|
|
686
|
+
const decline = useCallback(() => choose("analytics:no"), [choose]);
|
|
687
|
+
const openPreferences = useCallback(() => {
|
|
688
|
+
setReopened(true);
|
|
689
|
+
setBannerOpen(true);
|
|
690
|
+
}, []);
|
|
691
|
+
const closePreferences = useCallback(() => {
|
|
692
|
+
setBannerOpen(false);
|
|
693
|
+
setReopened(false);
|
|
694
|
+
requestAnimationFrame(() => triggerRef.current?.focus());
|
|
695
|
+
}, []);
|
|
696
|
+
const value = useMemo(
|
|
697
|
+
() => ({
|
|
698
|
+
config,
|
|
699
|
+
mode,
|
|
700
|
+
decision,
|
|
701
|
+
gpc,
|
|
702
|
+
allowed,
|
|
703
|
+
ready,
|
|
704
|
+
bannerOpen,
|
|
705
|
+
reopened,
|
|
706
|
+
accept,
|
|
707
|
+
decline,
|
|
708
|
+
openPreferences,
|
|
709
|
+
closePreferences,
|
|
710
|
+
registerTriggerRef
|
|
711
|
+
}),
|
|
712
|
+
[
|
|
713
|
+
config,
|
|
714
|
+
mode,
|
|
715
|
+
decision,
|
|
716
|
+
gpc,
|
|
717
|
+
allowed,
|
|
718
|
+
ready,
|
|
719
|
+
bannerOpen,
|
|
720
|
+
reopened,
|
|
721
|
+
accept,
|
|
722
|
+
decline,
|
|
723
|
+
openPreferences,
|
|
724
|
+
closePreferences,
|
|
725
|
+
registerTriggerRef
|
|
726
|
+
]
|
|
727
|
+
);
|
|
728
|
+
return /* @__PURE__ */ jsx(ConsentContext.Provider, { value, children });
|
|
729
|
+
}
|
|
730
|
+
function useConsent() {
|
|
731
|
+
const ctx = useContext(ConsentContext);
|
|
732
|
+
if (!ctx) {
|
|
733
|
+
throw new Error("useConsent() must be used inside <SiteShell> or <ConsentProvider>.");
|
|
734
|
+
}
|
|
735
|
+
return ctx;
|
|
736
|
+
}
|
|
737
|
+
function ConsentGate({
|
|
738
|
+
children,
|
|
739
|
+
fallback = null
|
|
740
|
+
}) {
|
|
741
|
+
const { allowed } = useConsent();
|
|
742
|
+
return /* @__PURE__ */ jsx(Fragment, { children: allowed ? children : fallback });
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
export {
|
|
746
|
+
CONSENT_COOKIE,
|
|
747
|
+
MODE_COOKIE,
|
|
748
|
+
CONSENT_MAX_AGE,
|
|
749
|
+
MODE_MAX_AGE,
|
|
750
|
+
VISITOR_SCRIPT_ID,
|
|
751
|
+
GTM_SCRIPT_ID,
|
|
752
|
+
GA4_SCRIPT_ID,
|
|
753
|
+
OPT_IN_COUNTRIES,
|
|
754
|
+
DEFAULT_OPT_IN_US_REGIONS,
|
|
755
|
+
privacyModeForLocation,
|
|
756
|
+
analyticsAllowed,
|
|
757
|
+
parseConsentValue,
|
|
758
|
+
readCookieFromString,
|
|
759
|
+
readBrowserCookie,
|
|
760
|
+
readStoredConsent,
|
|
761
|
+
writeConsentCookie,
|
|
762
|
+
readGpcSignal,
|
|
763
|
+
resolveGeoFromHeaders,
|
|
764
|
+
sanitizeVisitorScriptUrl,
|
|
765
|
+
sanitizeGtmId,
|
|
766
|
+
sanitizeGa4Id,
|
|
767
|
+
buildConsentBootstrapScript,
|
|
768
|
+
getGlobalSiteConfig,
|
|
769
|
+
ConsentProvider,
|
|
770
|
+
useConsent,
|
|
771
|
+
ConsentGate
|
|
772
|
+
};
|