@livo-tv/blocks 1.36.0 → 1.36.1-pr.6.5933ec9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/consent.cjs +85 -0
- package/dist/consent.cjs.map +1 -0
- package/dist/consent.d.cts +20 -0
- package/dist/consent.d.ts +20 -0
- package/dist/consent.js +73 -0
- package/dist/consent.js.map +1 -0
- package/dist/index.cjs +380 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +63 -1
- package/dist/index.d.ts +63 -1
- package/dist/index.js +363 -1
- package/dist/index.js.map +1 -1
- package/package.json +11 -1
package/dist/consent.cjs
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/lib/cookie-consent.ts
|
|
4
|
+
var COOKIE_CONSENT_NAME = "livo-cookie-consent";
|
|
5
|
+
var COOKIE_CONSENT_VALUES = ["necessary", "all"];
|
|
6
|
+
var COOKIE_CONSENT_MAX_AGE = 180 * 24 * 60 * 60;
|
|
7
|
+
function isCookieConsentValue(value) {
|
|
8
|
+
return typeof value === "string" && COOKIE_CONSENT_VALUES.includes(value);
|
|
9
|
+
}
|
|
10
|
+
function cookieConsentAllowsReplay(value) {
|
|
11
|
+
return value === "all";
|
|
12
|
+
}
|
|
13
|
+
function cookieDomainFromHostname(hostname) {
|
|
14
|
+
const host = hostname.toLowerCase();
|
|
15
|
+
if (host === "localhost" || host === "127.0.0.1") return void 0;
|
|
16
|
+
if (host.endsWith(".livo.tv") || host === "livo.tv") return ".livo.tv";
|
|
17
|
+
if (host.endsWith(".livo-tv.workers.dev") || host === "livo-tv.workers.dev") {
|
|
18
|
+
return ".livo-tv.workers.dev";
|
|
19
|
+
}
|
|
20
|
+
return void 0;
|
|
21
|
+
}
|
|
22
|
+
function readCookieMap(cookieSource) {
|
|
23
|
+
const map = /* @__PURE__ */ new Map();
|
|
24
|
+
for (const part of cookieSource.split(";")) {
|
|
25
|
+
const trimmed = part.trim();
|
|
26
|
+
if (!trimmed) continue;
|
|
27
|
+
const eq = trimmed.indexOf("=");
|
|
28
|
+
if (eq < 0) continue;
|
|
29
|
+
const name = trimmed.slice(0, eq).trim();
|
|
30
|
+
const raw = trimmed.slice(eq + 1).trim();
|
|
31
|
+
map.set(name, decodeURIComponent(raw));
|
|
32
|
+
}
|
|
33
|
+
return map;
|
|
34
|
+
}
|
|
35
|
+
function parseCookieConsent(cookieSource) {
|
|
36
|
+
const raw = readCookieMap(cookieSource).get(COOKIE_CONSENT_NAME);
|
|
37
|
+
return isCookieConsentValue(raw) ? raw : null;
|
|
38
|
+
}
|
|
39
|
+
function readCookieConsent() {
|
|
40
|
+
if (typeof document === "undefined") return null;
|
|
41
|
+
return parseCookieConsent(document.cookie);
|
|
42
|
+
}
|
|
43
|
+
function serializeCookieConsent(value, options = {}) {
|
|
44
|
+
const maxAge = options.maxAge ?? COOKIE_CONSENT_MAX_AGE;
|
|
45
|
+
const secure = options.secure ?? (typeof window !== "undefined" && window.location.protocol === "https:");
|
|
46
|
+
const parts = [
|
|
47
|
+
`${COOKIE_CONSENT_NAME}=${encodeURIComponent(value)}`,
|
|
48
|
+
"Path=/",
|
|
49
|
+
`Max-Age=${maxAge}`,
|
|
50
|
+
"SameSite=Lax"
|
|
51
|
+
];
|
|
52
|
+
if (options.domain) {
|
|
53
|
+
parts.push(`Domain=${options.domain}`);
|
|
54
|
+
}
|
|
55
|
+
if (secure) {
|
|
56
|
+
parts.push("Secure");
|
|
57
|
+
}
|
|
58
|
+
return parts.join("; ");
|
|
59
|
+
}
|
|
60
|
+
function writeCookieConsent(value, options = {}) {
|
|
61
|
+
if (typeof document === "undefined") return;
|
|
62
|
+
document.cookie = serializeCookieConsent(value, options);
|
|
63
|
+
}
|
|
64
|
+
function isEmbeddedWindow() {
|
|
65
|
+
if (typeof window === "undefined") return false;
|
|
66
|
+
try {
|
|
67
|
+
return window.self !== window.top;
|
|
68
|
+
} catch {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
exports.COOKIE_CONSENT_MAX_AGE = COOKIE_CONSENT_MAX_AGE;
|
|
74
|
+
exports.COOKIE_CONSENT_NAME = COOKIE_CONSENT_NAME;
|
|
75
|
+
exports.COOKIE_CONSENT_VALUES = COOKIE_CONSENT_VALUES;
|
|
76
|
+
exports.cookieConsentAllowsReplay = cookieConsentAllowsReplay;
|
|
77
|
+
exports.cookieDomainFromHostname = cookieDomainFromHostname;
|
|
78
|
+
exports.isCookieConsentValue = isCookieConsentValue;
|
|
79
|
+
exports.isEmbeddedWindow = isEmbeddedWindow;
|
|
80
|
+
exports.parseCookieConsent = parseCookieConsent;
|
|
81
|
+
exports.readCookieConsent = readCookieConsent;
|
|
82
|
+
exports.serializeCookieConsent = serializeCookieConsent;
|
|
83
|
+
exports.writeCookieConsent = writeCookieConsent;
|
|
84
|
+
//# sourceMappingURL=consent.cjs.map
|
|
85
|
+
//# sourceMappingURL=consent.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/cookie-consent.ts"],"names":[],"mappings":";;;AAAO,IAAM,mBAAA,GAAsB;AAE5B,IAAM,qBAAA,GAAwB,CAAC,WAAA,EAAa,KAAK;AAKjD,IAAM,sBAAA,GAAyB,GAAA,GAAM,EAAA,GAAK,EAAA,GAAK;AAQ/C,SAAS,qBACf,KAAA,EAC8B;AAC9B,EAAA,OACC,OAAO,KAAA,KAAU,QAAA,IAChB,qBAAA,CAA4C,SAAS,KAAK,CAAA;AAE7D;AAEO,SAAS,0BACf,KAAA,EACU;AACV,EAAA,OAAO,KAAA,KAAU,KAAA;AAClB;AAEO,SAAS,yBAAyB,QAAA,EAAsC;AAC9E,EAAA,MAAM,IAAA,GAAO,SAAS,WAAA,EAAY;AAClC,EAAA,IAAI,IAAA,KAAS,WAAA,IAAe,IAAA,KAAS,WAAA,EAAa,OAAO,MAAA;AACzD,EAAA,IAAI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GAAqC,EAAC,EAC7B;AACT,EAAA,MAAM,MAAA,GAAS,QAAQ,MAAA,IAAU,sBAAA;AACjC,EAAA,MAAM,MAAA,GACL,QAAQ,MAAA,KACP,OAAO,WAAW,WAAA,IAAe,MAAA,CAAO,SAAS,QAAA,KAAa,QAAA,CAAA;AAChE,EAAA,MAAM,KAAA,GAAQ;AAAA,IACb,CAAA,EAAG,mBAAmB,CAAA,CAAA,EAAI,kBAAA,CAAmB,KAAK,CAAC,CAAA,CAAA;AAAA,IACnD,QAAA;AAAA,IACA,WAAW,MAAM,CAAA,CAAA;AAAA,IACjB;AAAA,GACD;AACA,EAAA,IAAI,QAAQ,MAAA,EAAQ;AACnB,IAAA,KAAA,CAAM,IAAA,CAAK,CAAA,OAAA,EAAU,OAAA,CAAQ,MAAM,CAAA,CAAE,CAAA;AAAA,EACtC;AACA,EAAA,IAAI,MAAA,EAAQ;AACX,IAAA,KAAA,CAAM,KAAK,QAAQ,CAAA;AAAA,EACpB;AACA,EAAA,OAAO,KAAA,CAAM,KAAK,IAAI,CAAA;AACvB;AAEO,SAAS,kBAAA,CACf,KAAA,EACA,OAAA,GAAqC,EAAC,EAC/B;AACP,EAAA,IAAI,OAAO,aAAa,WAAA,EAAa;AACrC,EAAA,QAAA,CAAS,MAAA,GAAS,sBAAA,CAAuB,KAAA,EAAO,OAAO,CAAA;AACxD;AAEO,SAAS,gBAAA,GAA4B;AAC3C,EAAA,IAAI,OAAO,MAAA,KAAW,WAAA,EAAa,OAAO,KAAA;AAC1C,EAAA,IAAI;AACH,IAAA,OAAO,MAAA,CAAO,SAAS,MAAA,CAAO,GAAA;AAAA,EAC/B,CAAA,CAAA,MAAQ;AACP,IAAA,OAAO,IAAA;AAAA,EACR;AACD","file":"consent.cjs","sourcesContent":["export const COOKIE_CONSENT_NAME = \"livo-cookie-consent\";\n\nexport const COOKIE_CONSENT_VALUES = [\"necessary\", \"all\"] as const;\n\nexport type CookieConsentValue = (typeof COOKIE_CONSENT_VALUES)[number];\n\n/** ~180 days, matching contracts §1.2. */\nexport const COOKIE_CONSENT_MAX_AGE = 180 * 24 * 60 * 60;\n\nexport type WriteCookieConsentOptions = {\n\tdomain?: string;\n\tsecure?: boolean;\n\tmaxAge?: number;\n};\n\nexport function isCookieConsentValue(\n\tvalue: unknown,\n): value is CookieConsentValue {\n\treturn (\n\t\ttypeof value === \"string\" &&\n\t\t(COOKIE_CONSENT_VALUES as readonly string[]).includes(value)\n\t);\n}\n\nexport function cookieConsentAllowsReplay(\n\tvalue: CookieConsentValue | null | undefined,\n): boolean {\n\treturn value === \"all\";\n}\n\nexport function cookieDomainFromHostname(hostname: string): string | undefined {\n\tconst host = hostname.toLowerCase();\n\tif (host === \"localhost\" || host === \"127.0.0.1\") return undefined;\n\tif (host.endsWith(\".livo.tv\") || host === \"livo.tv\") return \".livo.tv\";\n\tif (host.endsWith(\".livo-tv.workers.dev\") || host === \"livo-tv.workers.dev\") {\n\t\treturn \".livo-tv.workers.dev\";\n\t}\n\treturn undefined;\n}\n\nfunction readCookieMap(cookieSource: string): Map<string, string> {\n\tconst map = new Map<string, string>();\n\tfor (const part of cookieSource.split(\";\")) {\n\t\tconst trimmed = part.trim();\n\t\tif (!trimmed) continue;\n\t\tconst eq = trimmed.indexOf(\"=\");\n\t\tif (eq < 0) continue;\n\t\tconst name = trimmed.slice(0, eq).trim();\n\t\tconst raw = trimmed.slice(eq + 1).trim();\n\t\tmap.set(name, decodeURIComponent(raw));\n\t}\n\treturn map;\n}\n\nexport function parseCookieConsent(\n\tcookieSource: string,\n): CookieConsentValue | null {\n\tconst raw = readCookieMap(cookieSource).get(COOKIE_CONSENT_NAME);\n\treturn isCookieConsentValue(raw) ? raw : null;\n}\n\nexport function readCookieConsent(): CookieConsentValue | null {\n\tif (typeof document === \"undefined\") return null;\n\treturn parseCookieConsent(document.cookie);\n}\n\nexport function serializeCookieConsent(\n\tvalue: CookieConsentValue,\n\toptions: WriteCookieConsentOptions = {},\n): string {\n\tconst maxAge = options.maxAge ?? COOKIE_CONSENT_MAX_AGE;\n\tconst secure =\n\t\toptions.secure ??\n\t\t(typeof window !== \"undefined\" && window.location.protocol === \"https:\");\n\tconst parts = [\n\t\t`${COOKIE_CONSENT_NAME}=${encodeURIComponent(value)}`,\n\t\t\"Path=/\",\n\t\t`Max-Age=${maxAge}`,\n\t\t\"SameSite=Lax\",\n\t];\n\tif (options.domain) {\n\t\tparts.push(`Domain=${options.domain}`);\n\t}\n\tif (secure) {\n\t\tparts.push(\"Secure\");\n\t}\n\treturn parts.join(\"; \");\n}\n\nexport function writeCookieConsent(\n\tvalue: CookieConsentValue,\n\toptions: WriteCookieConsentOptions = {},\n): void {\n\tif (typeof document === \"undefined\") return;\n\tdocument.cookie = serializeCookieConsent(value, options);\n}\n\nexport function isEmbeddedWindow(): boolean {\n\tif (typeof window === \"undefined\") return false;\n\ttry {\n\t\treturn window.self !== window.top;\n\t} catch {\n\t\treturn true;\n\t}\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare const COOKIE_CONSENT_NAME = "livo-cookie-consent";
|
|
2
|
+
declare const COOKIE_CONSENT_VALUES: readonly ["necessary", "all"];
|
|
3
|
+
type CookieConsentValue = (typeof COOKIE_CONSENT_VALUES)[number];
|
|
4
|
+
/** ~180 days, matching contracts §1.2. */
|
|
5
|
+
declare const COOKIE_CONSENT_MAX_AGE: number;
|
|
6
|
+
type WriteCookieConsentOptions = {
|
|
7
|
+
domain?: string;
|
|
8
|
+
secure?: boolean;
|
|
9
|
+
maxAge?: number;
|
|
10
|
+
};
|
|
11
|
+
declare function isCookieConsentValue(value: unknown): value is CookieConsentValue;
|
|
12
|
+
declare function cookieConsentAllowsReplay(value: CookieConsentValue | null | undefined): boolean;
|
|
13
|
+
declare function cookieDomainFromHostname(hostname: string): string | undefined;
|
|
14
|
+
declare function parseCookieConsent(cookieSource: string): CookieConsentValue | null;
|
|
15
|
+
declare function readCookieConsent(): CookieConsentValue | null;
|
|
16
|
+
declare function serializeCookieConsent(value: CookieConsentValue, options?: WriteCookieConsentOptions): string;
|
|
17
|
+
declare function writeCookieConsent(value: CookieConsentValue, options?: WriteCookieConsentOptions): void;
|
|
18
|
+
declare function isEmbeddedWindow(): boolean;
|
|
19
|
+
|
|
20
|
+
export { COOKIE_CONSENT_MAX_AGE, COOKIE_CONSENT_NAME, COOKIE_CONSENT_VALUES, type CookieConsentValue, type WriteCookieConsentOptions, cookieConsentAllowsReplay, cookieDomainFromHostname, isCookieConsentValue, isEmbeddedWindow, parseCookieConsent, readCookieConsent, serializeCookieConsent, writeCookieConsent };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare const COOKIE_CONSENT_NAME = "livo-cookie-consent";
|
|
2
|
+
declare const COOKIE_CONSENT_VALUES: readonly ["necessary", "all"];
|
|
3
|
+
type CookieConsentValue = (typeof COOKIE_CONSENT_VALUES)[number];
|
|
4
|
+
/** ~180 days, matching contracts §1.2. */
|
|
5
|
+
declare const COOKIE_CONSENT_MAX_AGE: number;
|
|
6
|
+
type WriteCookieConsentOptions = {
|
|
7
|
+
domain?: string;
|
|
8
|
+
secure?: boolean;
|
|
9
|
+
maxAge?: number;
|
|
10
|
+
};
|
|
11
|
+
declare function isCookieConsentValue(value: unknown): value is CookieConsentValue;
|
|
12
|
+
declare function cookieConsentAllowsReplay(value: CookieConsentValue | null | undefined): boolean;
|
|
13
|
+
declare function cookieDomainFromHostname(hostname: string): string | undefined;
|
|
14
|
+
declare function parseCookieConsent(cookieSource: string): CookieConsentValue | null;
|
|
15
|
+
declare function readCookieConsent(): CookieConsentValue | null;
|
|
16
|
+
declare function serializeCookieConsent(value: CookieConsentValue, options?: WriteCookieConsentOptions): string;
|
|
17
|
+
declare function writeCookieConsent(value: CookieConsentValue, options?: WriteCookieConsentOptions): void;
|
|
18
|
+
declare function isEmbeddedWindow(): boolean;
|
|
19
|
+
|
|
20
|
+
export { COOKIE_CONSENT_MAX_AGE, COOKIE_CONSENT_NAME, COOKIE_CONSENT_VALUES, type CookieConsentValue, type WriteCookieConsentOptions, cookieConsentAllowsReplay, cookieDomainFromHostname, isCookieConsentValue, isEmbeddedWindow, parseCookieConsent, readCookieConsent, serializeCookieConsent, writeCookieConsent };
|
package/dist/consent.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// src/lib/cookie-consent.ts
|
|
2
|
+
var COOKIE_CONSENT_NAME = "livo-cookie-consent";
|
|
3
|
+
var COOKIE_CONSENT_VALUES = ["necessary", "all"];
|
|
4
|
+
var COOKIE_CONSENT_MAX_AGE = 180 * 24 * 60 * 60;
|
|
5
|
+
function isCookieConsentValue(value) {
|
|
6
|
+
return typeof value === "string" && COOKIE_CONSENT_VALUES.includes(value);
|
|
7
|
+
}
|
|
8
|
+
function cookieConsentAllowsReplay(value) {
|
|
9
|
+
return value === "all";
|
|
10
|
+
}
|
|
11
|
+
function cookieDomainFromHostname(hostname) {
|
|
12
|
+
const host = hostname.toLowerCase();
|
|
13
|
+
if (host === "localhost" || host === "127.0.0.1") return void 0;
|
|
14
|
+
if (host.endsWith(".livo.tv") || host === "livo.tv") return ".livo.tv";
|
|
15
|
+
if (host.endsWith(".livo-tv.workers.dev") || host === "livo-tv.workers.dev") {
|
|
16
|
+
return ".livo-tv.workers.dev";
|
|
17
|
+
}
|
|
18
|
+
return void 0;
|
|
19
|
+
}
|
|
20
|
+
function readCookieMap(cookieSource) {
|
|
21
|
+
const map = /* @__PURE__ */ new Map();
|
|
22
|
+
for (const part of cookieSource.split(";")) {
|
|
23
|
+
const trimmed = part.trim();
|
|
24
|
+
if (!trimmed) continue;
|
|
25
|
+
const eq = trimmed.indexOf("=");
|
|
26
|
+
if (eq < 0) continue;
|
|
27
|
+
const name = trimmed.slice(0, eq).trim();
|
|
28
|
+
const raw = trimmed.slice(eq + 1).trim();
|
|
29
|
+
map.set(name, decodeURIComponent(raw));
|
|
30
|
+
}
|
|
31
|
+
return map;
|
|
32
|
+
}
|
|
33
|
+
function parseCookieConsent(cookieSource) {
|
|
34
|
+
const raw = readCookieMap(cookieSource).get(COOKIE_CONSENT_NAME);
|
|
35
|
+
return isCookieConsentValue(raw) ? raw : null;
|
|
36
|
+
}
|
|
37
|
+
function readCookieConsent() {
|
|
38
|
+
if (typeof document === "undefined") return null;
|
|
39
|
+
return parseCookieConsent(document.cookie);
|
|
40
|
+
}
|
|
41
|
+
function serializeCookieConsent(value, options = {}) {
|
|
42
|
+
const maxAge = options.maxAge ?? COOKIE_CONSENT_MAX_AGE;
|
|
43
|
+
const secure = options.secure ?? (typeof window !== "undefined" && window.location.protocol === "https:");
|
|
44
|
+
const parts = [
|
|
45
|
+
`${COOKIE_CONSENT_NAME}=${encodeURIComponent(value)}`,
|
|
46
|
+
"Path=/",
|
|
47
|
+
`Max-Age=${maxAge}`,
|
|
48
|
+
"SameSite=Lax"
|
|
49
|
+
];
|
|
50
|
+
if (options.domain) {
|
|
51
|
+
parts.push(`Domain=${options.domain}`);
|
|
52
|
+
}
|
|
53
|
+
if (secure) {
|
|
54
|
+
parts.push("Secure");
|
|
55
|
+
}
|
|
56
|
+
return parts.join("; ");
|
|
57
|
+
}
|
|
58
|
+
function writeCookieConsent(value, options = {}) {
|
|
59
|
+
if (typeof document === "undefined") return;
|
|
60
|
+
document.cookie = serializeCookieConsent(value, options);
|
|
61
|
+
}
|
|
62
|
+
function isEmbeddedWindow() {
|
|
63
|
+
if (typeof window === "undefined") return false;
|
|
64
|
+
try {
|
|
65
|
+
return window.self !== window.top;
|
|
66
|
+
} catch {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export { COOKIE_CONSENT_MAX_AGE, COOKIE_CONSENT_NAME, COOKIE_CONSENT_VALUES, cookieConsentAllowsReplay, cookieDomainFromHostname, isCookieConsentValue, isEmbeddedWindow, parseCookieConsent, readCookieConsent, serializeCookieConsent, writeCookieConsent };
|
|
72
|
+
//# sourceMappingURL=consent.js.map
|
|
73
|
+
//# sourceMappingURL=consent.js.map
|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AAK,IAAI,CAAA;AACvB;AAEO,SAAS,kBAAA,CACf,KAAA,EACA,OAAA,GAAqC,EAAC,EAC/B;AACP,EAAA,IAAI,OAAO,aAAa,WAAA,EAAa;AACrC,EAAA,QAAA,CAAS,MAAA,GAAS,sBAAA,CAAuB,KAAA,EAAO,OAAO,CAAA;AACxD;AAEO,SAAS,gBAAA,GAA4B;AAC3C,EAAA,IAAI,OAAO,MAAA,KAAW,WAAA,EAAa,OAAO,KAAA;AAC1C,EAAA,IAAI;AACH,IAAA,OAAO,MAAA,CAAO,SAAS,MAAA,CAAO,GAAA;AAAA,EAC/B,CAAA,CAAA,MAAQ;AACP,IAAA,OAAO,IAAA;AAAA,EACR;AACD","file":"consent.js","sourcesContent":["export const COOKIE_CONSENT_NAME = \"livo-cookie-consent\";\n\nexport const COOKIE_CONSENT_VALUES = [\"necessary\", \"all\"] as const;\n\nexport type CookieConsentValue = (typeof COOKIE_CONSENT_VALUES)[number];\n\n/** ~180 days, matching contracts §1.2. */\nexport const COOKIE_CONSENT_MAX_AGE = 180 * 24 * 60 * 60;\n\nexport type WriteCookieConsentOptions = {\n\tdomain?: string;\n\tsecure?: boolean;\n\tmaxAge?: number;\n};\n\nexport function isCookieConsentValue(\n\tvalue: unknown,\n): value is CookieConsentValue {\n\treturn (\n\t\ttypeof value === \"string\" &&\n\t\t(COOKIE_CONSENT_VALUES as readonly string[]).includes(value)\n\t);\n}\n\nexport function cookieConsentAllowsReplay(\n\tvalue: CookieConsentValue | null | undefined,\n): boolean {\n\treturn value === \"all\";\n}\n\nexport function cookieDomainFromHostname(hostname: string): string | undefined {\n\tconst host = hostname.toLowerCase();\n\tif (host === \"localhost\" || host === \"127.0.0.1\") return undefined;\n\tif (host.endsWith(\".livo.tv\") || host === \"livo.tv\") return \".livo.tv\";\n\tif (host.endsWith(\".livo-tv.workers.dev\") || host === \"livo-tv.workers.dev\") {\n\t\treturn \".livo-tv.workers.dev\";\n\t}\n\treturn undefined;\n}\n\nfunction readCookieMap(cookieSource: string): Map<string, string> {\n\tconst map = new Map<string, string>();\n\tfor (const part of cookieSource.split(\";\")) {\n\t\tconst trimmed = part.trim();\n\t\tif (!trimmed) continue;\n\t\tconst eq = trimmed.indexOf(\"=\");\n\t\tif (eq < 0) continue;\n\t\tconst name = trimmed.slice(0, eq).trim();\n\t\tconst raw = trimmed.slice(eq + 1).trim();\n\t\tmap.set(name, decodeURIComponent(raw));\n\t}\n\treturn map;\n}\n\nexport function parseCookieConsent(\n\tcookieSource: string,\n): CookieConsentValue | null {\n\tconst raw = readCookieMap(cookieSource).get(COOKIE_CONSENT_NAME);\n\treturn isCookieConsentValue(raw) ? raw : null;\n}\n\nexport function readCookieConsent(): CookieConsentValue | null {\n\tif (typeof document === \"undefined\") return null;\n\treturn parseCookieConsent(document.cookie);\n}\n\nexport function serializeCookieConsent(\n\tvalue: CookieConsentValue,\n\toptions: WriteCookieConsentOptions = {},\n): string {\n\tconst maxAge = options.maxAge ?? COOKIE_CONSENT_MAX_AGE;\n\tconst secure =\n\t\toptions.secure ??\n\t\t(typeof window !== \"undefined\" && window.location.protocol === \"https:\");\n\tconst parts = [\n\t\t`${COOKIE_CONSENT_NAME}=${encodeURIComponent(value)}`,\n\t\t\"Path=/\",\n\t\t`Max-Age=${maxAge}`,\n\t\t\"SameSite=Lax\",\n\t];\n\tif (options.domain) {\n\t\tparts.push(`Domain=${options.domain}`);\n\t}\n\tif (secure) {\n\t\tparts.push(\"Secure\");\n\t}\n\treturn parts.join(\"; \");\n}\n\nexport function writeCookieConsent(\n\tvalue: CookieConsentValue,\n\toptions: WriteCookieConsentOptions = {},\n): void {\n\tif (typeof document === \"undefined\") return;\n\tdocument.cookie = serializeCookieConsent(value, options);\n}\n\nexport function isEmbeddedWindow(): boolean {\n\tif (typeof window === \"undefined\") return false;\n\ttry {\n\t\treturn window.self !== window.top;\n\t} catch {\n\t\treturn true;\n\t}\n}\n"]}
|
package/dist/index.cjs
CHANGED
|
@@ -3341,14 +3341,383 @@ function MetricSkeleton({ className, bars = 4 }) {
|
|
|
3341
3341
|
);
|
|
3342
3342
|
}
|
|
3343
3343
|
|
|
3344
|
+
// src/lib/cookie-consent.ts
|
|
3345
|
+
var COOKIE_CONSENT_NAME = "livo-cookie-consent";
|
|
3346
|
+
var COOKIE_CONSENT_VALUES = ["necessary", "all"];
|
|
3347
|
+
var COOKIE_CONSENT_MAX_AGE = 180 * 24 * 60 * 60;
|
|
3348
|
+
function isCookieConsentValue(value) {
|
|
3349
|
+
return typeof value === "string" && COOKIE_CONSENT_VALUES.includes(value);
|
|
3350
|
+
}
|
|
3351
|
+
function cookieConsentAllowsReplay(value) {
|
|
3352
|
+
return value === "all";
|
|
3353
|
+
}
|
|
3354
|
+
function cookieDomainFromHostname(hostname) {
|
|
3355
|
+
const host = hostname.toLowerCase();
|
|
3356
|
+
if (host === "localhost" || host === "127.0.0.1") return void 0;
|
|
3357
|
+
if (host.endsWith(".livo.tv") || host === "livo.tv") return ".livo.tv";
|
|
3358
|
+
if (host.endsWith(".livo-tv.workers.dev") || host === "livo-tv.workers.dev") {
|
|
3359
|
+
return ".livo-tv.workers.dev";
|
|
3360
|
+
}
|
|
3361
|
+
return void 0;
|
|
3362
|
+
}
|
|
3363
|
+
function readCookieMap(cookieSource) {
|
|
3364
|
+
const map = /* @__PURE__ */ new Map();
|
|
3365
|
+
for (const part of cookieSource.split(";")) {
|
|
3366
|
+
const trimmed = part.trim();
|
|
3367
|
+
if (!trimmed) continue;
|
|
3368
|
+
const eq = trimmed.indexOf("=");
|
|
3369
|
+
if (eq < 0) continue;
|
|
3370
|
+
const name = trimmed.slice(0, eq).trim();
|
|
3371
|
+
const raw = trimmed.slice(eq + 1).trim();
|
|
3372
|
+
map.set(name, decodeURIComponent(raw));
|
|
3373
|
+
}
|
|
3374
|
+
return map;
|
|
3375
|
+
}
|
|
3376
|
+
function parseCookieConsent(cookieSource) {
|
|
3377
|
+
const raw = readCookieMap(cookieSource).get(COOKIE_CONSENT_NAME);
|
|
3378
|
+
return isCookieConsentValue(raw) ? raw : null;
|
|
3379
|
+
}
|
|
3380
|
+
function readCookieConsent() {
|
|
3381
|
+
if (typeof document === "undefined") return null;
|
|
3382
|
+
return parseCookieConsent(document.cookie);
|
|
3383
|
+
}
|
|
3384
|
+
function serializeCookieConsent(value, options = {}) {
|
|
3385
|
+
const maxAge = options.maxAge ?? COOKIE_CONSENT_MAX_AGE;
|
|
3386
|
+
const secure = options.secure ?? (typeof window !== "undefined" && window.location.protocol === "https:");
|
|
3387
|
+
const parts = [
|
|
3388
|
+
`${COOKIE_CONSENT_NAME}=${encodeURIComponent(value)}`,
|
|
3389
|
+
"Path=/",
|
|
3390
|
+
`Max-Age=${maxAge}`,
|
|
3391
|
+
"SameSite=Lax"
|
|
3392
|
+
];
|
|
3393
|
+
if (options.domain) {
|
|
3394
|
+
parts.push(`Domain=${options.domain}`);
|
|
3395
|
+
}
|
|
3396
|
+
if (secure) {
|
|
3397
|
+
parts.push("Secure");
|
|
3398
|
+
}
|
|
3399
|
+
return parts.join("; ");
|
|
3400
|
+
}
|
|
3401
|
+
function writeCookieConsent(value, options = {}) {
|
|
3402
|
+
if (typeof document === "undefined") return;
|
|
3403
|
+
document.cookie = serializeCookieConsent(value, options);
|
|
3404
|
+
}
|
|
3405
|
+
function isEmbeddedWindow() {
|
|
3406
|
+
if (typeof window === "undefined") return false;
|
|
3407
|
+
try {
|
|
3408
|
+
return window.self !== window.top;
|
|
3409
|
+
} catch {
|
|
3410
|
+
return true;
|
|
3411
|
+
}
|
|
3412
|
+
}
|
|
3413
|
+
var DEFAULT_COOKIE_CONSENT_BANNER_LABELS = {
|
|
3414
|
+
message: "We use necessary cookies to run Livo. Extra cookies can be used for diagnostics if you opt in.",
|
|
3415
|
+
acceptAll: "Accept all",
|
|
3416
|
+
necessaryOnly: "Necessary only",
|
|
3417
|
+
policy: "Cookies policy"
|
|
3418
|
+
};
|
|
3419
|
+
function CookieConsentBanner({
|
|
3420
|
+
domain,
|
|
3421
|
+
policyHref,
|
|
3422
|
+
labels,
|
|
3423
|
+
onChoice,
|
|
3424
|
+
variant = "default",
|
|
3425
|
+
className
|
|
3426
|
+
}) {
|
|
3427
|
+
const copy = { ...DEFAULT_COOKIE_CONSENT_BANNER_LABELS, ...labels };
|
|
3428
|
+
const [consent, setConsent] = React.useState(
|
|
3429
|
+
"pending"
|
|
3430
|
+
);
|
|
3431
|
+
React.useEffect(() => {
|
|
3432
|
+
if (variant === "embed" || isEmbeddedWindow()) {
|
|
3433
|
+
setConsent("necessary");
|
|
3434
|
+
return;
|
|
3435
|
+
}
|
|
3436
|
+
setConsent(readCookieConsent());
|
|
3437
|
+
}, [variant]);
|
|
3438
|
+
if (variant === "embed") return null;
|
|
3439
|
+
if (consent === "pending" || consent) return null;
|
|
3440
|
+
const choose = (value) => {
|
|
3441
|
+
const resolvedDomain = domain ?? (typeof window === "undefined" ? void 0 : cookieDomainFromHostname(window.location.hostname));
|
|
3442
|
+
writeCookieConsent(value, { domain: resolvedDomain });
|
|
3443
|
+
setConsent(value);
|
|
3444
|
+
onChoice?.(value);
|
|
3445
|
+
};
|
|
3446
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3447
|
+
"div",
|
|
3448
|
+
{
|
|
3449
|
+
role: "dialog",
|
|
3450
|
+
"aria-label": copy.message,
|
|
3451
|
+
className: cn(
|
|
3452
|
+
"fixed inset-x-0 bottom-0 z-50 border-t bg-background/95 p-4 shadow-lg backdrop-blur-sm",
|
|
3453
|
+
className
|
|
3454
|
+
),
|
|
3455
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mx-auto flex w-full max-w-5xl flex-col gap-3 sm:flex-row sm:items-center sm:justify-between", children: [
|
|
3456
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-muted-foreground", children: [
|
|
3457
|
+
copy.message,
|
|
3458
|
+
policyHref ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3459
|
+
" ",
|
|
3460
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3461
|
+
"a",
|
|
3462
|
+
{
|
|
3463
|
+
href: policyHref,
|
|
3464
|
+
className: "text-foreground underline underline-offset-4",
|
|
3465
|
+
children: copy.policy
|
|
3466
|
+
}
|
|
3467
|
+
)
|
|
3468
|
+
] }) : null
|
|
3469
|
+
] }),
|
|
3470
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex shrink-0 flex-wrap gap-2", children: [
|
|
3471
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3472
|
+
Button,
|
|
3473
|
+
{
|
|
3474
|
+
type: "button",
|
|
3475
|
+
variant: "outline",
|
|
3476
|
+
onClick: () => choose("necessary"),
|
|
3477
|
+
children: copy.necessaryOnly
|
|
3478
|
+
}
|
|
3479
|
+
),
|
|
3480
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { type: "button", onClick: () => choose("all"), children: copy.acceptAll })
|
|
3481
|
+
] })
|
|
3482
|
+
] })
|
|
3483
|
+
}
|
|
3484
|
+
);
|
|
3485
|
+
}
|
|
3486
|
+
var DEFAULT_LEGAL_ACCEPT_DIALOG_LABELS = {
|
|
3487
|
+
title: "Updated terms",
|
|
3488
|
+
description: "We updated the Terms of Service and Privacy Policy. Please accept to continue.",
|
|
3489
|
+
accept: "Accept",
|
|
3490
|
+
terms: "Terms of Service",
|
|
3491
|
+
privacy: "Privacy Policy"
|
|
3492
|
+
};
|
|
3493
|
+
function LegalAcceptDialog({
|
|
3494
|
+
open,
|
|
3495
|
+
termsHref,
|
|
3496
|
+
privacyHref,
|
|
3497
|
+
summary,
|
|
3498
|
+
accepting = false,
|
|
3499
|
+
labels,
|
|
3500
|
+
onAccept
|
|
3501
|
+
}) {
|
|
3502
|
+
const copy = { ...DEFAULT_LEGAL_ACCEPT_DIALOG_LABELS, ...labels };
|
|
3503
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3504
|
+
AlertDialog,
|
|
3505
|
+
{
|
|
3506
|
+
open,
|
|
3507
|
+
onOpenChange: (next) => {
|
|
3508
|
+
if (next) return;
|
|
3509
|
+
},
|
|
3510
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3511
|
+
AlertDialogContent,
|
|
3512
|
+
{
|
|
3513
|
+
onEscapeKeyDown: (event) => {
|
|
3514
|
+
event.preventDefault();
|
|
3515
|
+
},
|
|
3516
|
+
children: [
|
|
3517
|
+
/* @__PURE__ */ jsxRuntime.jsxs(AlertDialogHeader, { children: [
|
|
3518
|
+
/* @__PURE__ */ jsxRuntime.jsx(AlertDialogTitle, { children: copy.title }),
|
|
3519
|
+
/* @__PURE__ */ jsxRuntime.jsxs(AlertDialogDescription, { children: [
|
|
3520
|
+
copy.description,
|
|
3521
|
+
summary ? ` ${summary}` : ""
|
|
3522
|
+
] })
|
|
3523
|
+
] }),
|
|
3524
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm", children: [
|
|
3525
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3526
|
+
"a",
|
|
3527
|
+
{
|
|
3528
|
+
href: termsHref,
|
|
3529
|
+
target: "_blank",
|
|
3530
|
+
rel: "noopener noreferrer",
|
|
3531
|
+
className: "underline underline-offset-4",
|
|
3532
|
+
children: copy.terms
|
|
3533
|
+
}
|
|
3534
|
+
),
|
|
3535
|
+
" \xB7 ",
|
|
3536
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3537
|
+
"a",
|
|
3538
|
+
{
|
|
3539
|
+
href: privacyHref,
|
|
3540
|
+
target: "_blank",
|
|
3541
|
+
rel: "noopener noreferrer",
|
|
3542
|
+
className: "underline underline-offset-4",
|
|
3543
|
+
children: copy.privacy
|
|
3544
|
+
}
|
|
3545
|
+
)
|
|
3546
|
+
] }),
|
|
3547
|
+
/* @__PURE__ */ jsxRuntime.jsx(AlertDialogFooter, { children: /* @__PURE__ */ jsxRuntime.jsx(Button, { type: "button", disabled: accepting, onClick: onAccept, children: copy.accept }) })
|
|
3548
|
+
]
|
|
3549
|
+
}
|
|
3550
|
+
)
|
|
3551
|
+
}
|
|
3552
|
+
);
|
|
3553
|
+
}
|
|
3554
|
+
var DEFAULT_LEGAL_ACCEPT_CHECKBOX_LABELS = {
|
|
3555
|
+
label: "I agree to the Terms of Service and Privacy Policy",
|
|
3556
|
+
terms: "Terms of Service",
|
|
3557
|
+
privacy: "Privacy Policy"
|
|
3558
|
+
};
|
|
3559
|
+
function LegalAcceptCheckbox({
|
|
3560
|
+
id = "legal-accept",
|
|
3561
|
+
checked,
|
|
3562
|
+
onCheckedChange,
|
|
3563
|
+
termsHref,
|
|
3564
|
+
privacyHref,
|
|
3565
|
+
labels,
|
|
3566
|
+
disabled = false,
|
|
3567
|
+
className
|
|
3568
|
+
}) {
|
|
3569
|
+
const copy = { ...DEFAULT_LEGAL_ACCEPT_CHECKBOX_LABELS, ...labels };
|
|
3570
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex items-start gap-3", className), children: [
|
|
3571
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3572
|
+
"input",
|
|
3573
|
+
{
|
|
3574
|
+
id,
|
|
3575
|
+
type: "checkbox",
|
|
3576
|
+
checked,
|
|
3577
|
+
disabled,
|
|
3578
|
+
onChange: (event) => onCheckedChange(event.target.checked),
|
|
3579
|
+
className: "mt-1 size-4 shrink-0 accent-primary"
|
|
3580
|
+
}
|
|
3581
|
+
),
|
|
3582
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { htmlFor: id, className: "text-sm leading-5", children: [
|
|
3583
|
+
copy.label,
|
|
3584
|
+
" ",
|
|
3585
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3586
|
+
"a",
|
|
3587
|
+
{
|
|
3588
|
+
href: termsHref,
|
|
3589
|
+
target: "_blank",
|
|
3590
|
+
rel: "noopener noreferrer",
|
|
3591
|
+
className: "underline underline-offset-4",
|
|
3592
|
+
children: copy.terms
|
|
3593
|
+
}
|
|
3594
|
+
),
|
|
3595
|
+
" \xB7 ",
|
|
3596
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3597
|
+
"a",
|
|
3598
|
+
{
|
|
3599
|
+
href: privacyHref,
|
|
3600
|
+
target: "_blank",
|
|
3601
|
+
rel: "noopener noreferrer",
|
|
3602
|
+
className: "underline underline-offset-4",
|
|
3603
|
+
children: copy.privacy
|
|
3604
|
+
}
|
|
3605
|
+
)
|
|
3606
|
+
] })
|
|
3607
|
+
] });
|
|
3608
|
+
}
|
|
3609
|
+
function sanitizeHref(href) {
|
|
3610
|
+
const trimmed = href.trim();
|
|
3611
|
+
if (/^https?:\/\//i.test(trimmed) || /^mailto:/i.test(trimmed)) {
|
|
3612
|
+
return trimmed;
|
|
3613
|
+
}
|
|
3614
|
+
if (trimmed.startsWith("/") && !trimmed.startsWith("//")) {
|
|
3615
|
+
return trimmed;
|
|
3616
|
+
}
|
|
3617
|
+
return null;
|
|
3618
|
+
}
|
|
3619
|
+
function renderInline(text) {
|
|
3620
|
+
const nodes = [];
|
|
3621
|
+
const pattern = /(\*\*[^*]+\*\*|\*[^*]+\*|`[^`]+`|\[[^\]]+\]\([^)]+\))/g;
|
|
3622
|
+
let last = 0;
|
|
3623
|
+
let match;
|
|
3624
|
+
let key = 0;
|
|
3625
|
+
while ((match = pattern.exec(text)) !== null) {
|
|
3626
|
+
if (match.index > last) {
|
|
3627
|
+
nodes.push(text.slice(last, match.index));
|
|
3628
|
+
}
|
|
3629
|
+
const token = match[0];
|
|
3630
|
+
if (token.startsWith("**")) {
|
|
3631
|
+
nodes.push(/* @__PURE__ */ jsxRuntime.jsx("strong", { children: token.slice(2, -2) }, key));
|
|
3632
|
+
} else if (token.startsWith("*")) {
|
|
3633
|
+
nodes.push(/* @__PURE__ */ jsxRuntime.jsx("em", { children: token.slice(1, -1) }, key));
|
|
3634
|
+
} else if (token.startsWith("`")) {
|
|
3635
|
+
nodes.push(
|
|
3636
|
+
/* @__PURE__ */ jsxRuntime.jsx("code", { className: "rounded bg-muted px-1 py-0.5 text-[0.9em]", children: token.slice(1, -1) }, key)
|
|
3637
|
+
);
|
|
3638
|
+
} else {
|
|
3639
|
+
const link = token.match(/^\[([^\]]+)\]\(([^)]+)\)$/);
|
|
3640
|
+
const href = link ? sanitizeHref(link[2] ?? "") : null;
|
|
3641
|
+
if (link && href) {
|
|
3642
|
+
nodes.push(
|
|
3643
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3644
|
+
"a",
|
|
3645
|
+
{
|
|
3646
|
+
href,
|
|
3647
|
+
className: "underline underline-offset-4",
|
|
3648
|
+
rel: "noopener noreferrer",
|
|
3649
|
+
children: link[1]
|
|
3650
|
+
},
|
|
3651
|
+
key
|
|
3652
|
+
)
|
|
3653
|
+
);
|
|
3654
|
+
} else {
|
|
3655
|
+
nodes.push(token);
|
|
3656
|
+
}
|
|
3657
|
+
}
|
|
3658
|
+
key += 1;
|
|
3659
|
+
last = match.index + token.length;
|
|
3660
|
+
}
|
|
3661
|
+
if (last < text.length) {
|
|
3662
|
+
nodes.push(text.slice(last));
|
|
3663
|
+
}
|
|
3664
|
+
return nodes;
|
|
3665
|
+
}
|
|
3666
|
+
function headingTag(line) {
|
|
3667
|
+
if (line.startsWith("### ")) return { Tag: "h3", text: line.slice(4) };
|
|
3668
|
+
if (line.startsWith("## ")) return { Tag: "h2", text: line.slice(3) };
|
|
3669
|
+
if (line.startsWith("# ")) return { Tag: "h1", text: line.slice(2) };
|
|
3670
|
+
return null;
|
|
3671
|
+
}
|
|
3672
|
+
function isUnorderedItem(line) {
|
|
3673
|
+
return /^[-*] /.test(line);
|
|
3674
|
+
}
|
|
3675
|
+
function isOrderedItem(line) {
|
|
3676
|
+
return /^\d+\. /.test(line);
|
|
3677
|
+
}
|
|
3678
|
+
function LegalMarkdown({ markdown, className }) {
|
|
3679
|
+
const blocks = markdown.replace(/\r\n/g, "\n").trim().split(/\n{2,}/);
|
|
3680
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3681
|
+
"div",
|
|
3682
|
+
{
|
|
3683
|
+
className: cn(
|
|
3684
|
+
"legal-markdown space-y-4 text-sm leading-6 [&_h1]:text-3xl [&_h1]:font-semibold [&_h2]:text-xl [&_h2]:font-semibold [&_h3]:text-lg [&_h3]:font-semibold [&_ul]:list-disc [&_ul]:pl-5 [&_ol]:list-decimal [&_ol]:pl-5",
|
|
3685
|
+
className
|
|
3686
|
+
),
|
|
3687
|
+
children: blocks.map((block, index) => {
|
|
3688
|
+
const lines = block.split("\n");
|
|
3689
|
+
const heading = headingTag(lines[0] ?? "");
|
|
3690
|
+
if (heading && lines.length === 1) {
|
|
3691
|
+
const { Tag, text } = heading;
|
|
3692
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Tag, { children: renderInline(text) }, index);
|
|
3693
|
+
}
|
|
3694
|
+
if (lines.every(isUnorderedItem)) {
|
|
3695
|
+
return /* @__PURE__ */ jsxRuntime.jsx("ul", { children: lines.map((line, itemIndex) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: renderInline(line.replace(/^[-*] /, "")) }, itemIndex)) }, index);
|
|
3696
|
+
}
|
|
3697
|
+
if (lines.every(isOrderedItem)) {
|
|
3698
|
+
return /* @__PURE__ */ jsxRuntime.jsx("ol", { children: lines.map((line, itemIndex) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: renderInline(line.replace(/^\d+\. /, "")) }, itemIndex)) }, index);
|
|
3699
|
+
}
|
|
3700
|
+
return /* @__PURE__ */ jsxRuntime.jsx("p", { children: renderInline(lines.join(" ")) }, index);
|
|
3701
|
+
})
|
|
3702
|
+
}
|
|
3703
|
+
);
|
|
3704
|
+
}
|
|
3705
|
+
|
|
3344
3706
|
exports.AvatarEditor = AvatarEditor;
|
|
3345
3707
|
exports.AvatarEditorDialog = AvatarEditorDialog;
|
|
3708
|
+
exports.COOKIE_CONSENT_MAX_AGE = COOKIE_CONSENT_MAX_AGE;
|
|
3709
|
+
exports.COOKIE_CONSENT_NAME = COOKIE_CONSENT_NAME;
|
|
3710
|
+
exports.COOKIE_CONSENT_VALUES = COOKIE_CONSENT_VALUES;
|
|
3346
3711
|
exports.ConfirmDestructiveDialog = ConfirmDestructiveDialog;
|
|
3712
|
+
exports.CookieConsentBanner = CookieConsentBanner;
|
|
3347
3713
|
exports.CostBreakdownCard = CostBreakdownCard;
|
|
3714
|
+
exports.DEFAULT_COOKIE_CONSENT_BANNER_LABELS = DEFAULT_COOKIE_CONSENT_BANNER_LABELS;
|
|
3348
3715
|
exports.DEFAULT_EDITABLE_SECTION_LABELS = DEFAULT_EDITABLE_SECTION_LABELS;
|
|
3349
3716
|
exports.DEFAULT_FILE_DROPZONE_LABELS = DEFAULT_FILE_DROPZONE_LABELS;
|
|
3350
3717
|
exports.DEFAULT_FILE_UPLOAD_LABELS = DEFAULT_FILE_UPLOAD_LABELS;
|
|
3351
3718
|
exports.DEFAULT_FILE_UPLOAD_TRAY_LABELS = DEFAULT_FILE_UPLOAD_TRAY_LABELS;
|
|
3719
|
+
exports.DEFAULT_LEGAL_ACCEPT_CHECKBOX_LABELS = DEFAULT_LEGAL_ACCEPT_CHECKBOX_LABELS;
|
|
3720
|
+
exports.DEFAULT_LEGAL_ACCEPT_DIALOG_LABELS = DEFAULT_LEGAL_ACCEPT_DIALOG_LABELS;
|
|
3352
3721
|
exports.DEFAULT_NOTIFICATION_BELL_LABELS = DEFAULT_NOTIFICATION_BELL_LABELS;
|
|
3353
3722
|
exports.DataList = DataList;
|
|
3354
3723
|
exports.DataListItem = DataListItem;
|
|
@@ -3368,6 +3737,9 @@ exports.FileUploadMenu = FileUploadMenu;
|
|
|
3368
3737
|
exports.FileUploadTray = FileUploadTray;
|
|
3369
3738
|
exports.LanguageContext = LanguageContext;
|
|
3370
3739
|
exports.LanguageSwitcher = LanguageSwitcher;
|
|
3740
|
+
exports.LegalAcceptCheckbox = LegalAcceptCheckbox;
|
|
3741
|
+
exports.LegalAcceptDialog = LegalAcceptDialog;
|
|
3742
|
+
exports.LegalMarkdown = LegalMarkdown;
|
|
3371
3743
|
exports.LoadingState = LoadingState;
|
|
3372
3744
|
exports.MetricChartCard = MetricChartCard;
|
|
3373
3745
|
exports.MetricEmptyState = MetricEmptyState;
|
|
@@ -3381,15 +3753,23 @@ exports.ThemeSwitcher = ThemeSwitcher;
|
|
|
3381
3753
|
exports.TimeRangePicker = TimeRangePicker;
|
|
3382
3754
|
exports.avatarFallbackStyle = avatarFallbackStyle;
|
|
3383
3755
|
exports.cn = cn;
|
|
3756
|
+
exports.cookieConsentAllowsReplay = cookieConsentAllowsReplay;
|
|
3757
|
+
exports.cookieDomainFromHostname = cookieDomainFromHostname;
|
|
3384
3758
|
exports.createMultipartUploadController = createMultipartUploadController;
|
|
3385
3759
|
exports.defaultLanguages = defaultLanguages;
|
|
3386
3760
|
exports.fileMatchesAccept = fileMatchesAccept;
|
|
3387
3761
|
exports.getAvatarColors = getAvatarColors;
|
|
3388
3762
|
exports.getInitials = getInitials;
|
|
3763
|
+
exports.isCookieConsentValue = isCookieConsentValue;
|
|
3764
|
+
exports.isEmbeddedWindow = isEmbeddedWindow;
|
|
3765
|
+
exports.parseCookieConsent = parseCookieConsent;
|
|
3389
3766
|
exports.partRanges = partRanges;
|
|
3390
3767
|
exports.progressFromBytes = progressFromBytes;
|
|
3768
|
+
exports.readCookieConsent = readCookieConsent;
|
|
3769
|
+
exports.serializeCookieConsent = serializeCookieConsent;
|
|
3391
3770
|
exports.useEditableSection = useEditableSection;
|
|
3392
3771
|
exports.useLanguageContext = useLanguageContext;
|
|
3393
3772
|
exports.useMediaQuery = useMediaQuery2;
|
|
3773
|
+
exports.writeCookieConsent = writeCookieConsent;
|
|
3394
3774
|
//# sourceMappingURL=index.cjs.map
|
|
3395
3775
|
//# sourceMappingURL=index.cjs.map
|