@citiwave/im-disclaimer-modal
Version:
A customizable React disclaimer modal component with theme support
1,001 lines (997 loc) • 34.9 kB
JavaScript
import Me, { useState as W, useEffect as X, useRef as yr, useCallback as Ie } from "react";
import { Check as Le } from "lucide-react";
var de = { exports: {} }, q = {};
/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var We;
function xr() {
if (We)
return q;
We = 1;
var i = Me, c = Symbol.for("react.element"), f = Symbol.for("react.fragment"), h = Object.prototype.hasOwnProperty, j = i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, g = { key: !0, ref: !0, __self: !0, __source: !0 };
function k(w, u, R) {
var d, E = {}, _ = null, C = null;
R !== void 0 && (_ = "" + R), u.key !== void 0 && (_ = "" + u.key), u.ref !== void 0 && (C = u.ref);
for (d in u)
h.call(u, d) && !g.hasOwnProperty(d) && (E[d] = u[d]);
if (w && w.defaultProps)
for (d in u = w.defaultProps, u)
E[d] === void 0 && (E[d] = u[d]);
return { $$typeof: c, type: w, key: _, ref: C, props: E, _owner: j.current };
}
return q.Fragment = f, q.jsx = k, q.jsxs = k, q;
}
var J = {};
/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var Ye;
function jr() {
return Ye || (Ye = 1, process.env.NODE_ENV !== "production" && function() {
var i = Me, c = Symbol.for("react.element"), f = Symbol.for("react.portal"), h = Symbol.for("react.fragment"), j = Symbol.for("react.strict_mode"), g = Symbol.for("react.profiler"), k = Symbol.for("react.provider"), w = Symbol.for("react.context"), u = Symbol.for("react.forward_ref"), R = Symbol.for("react.suspense"), d = Symbol.for("react.suspense_list"), E = Symbol.for("react.memo"), _ = Symbol.for("react.lazy"), C = Symbol.for("react.offscreen"), Y = Symbol.iterator, N = "@@iterator";
function Z(e) {
if (e === null || typeof e != "object")
return null;
var r = Y && e[Y] || e[N];
return typeof r == "function" ? r : null;
}
var F = i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
function x(e) {
{
for (var r = arguments.length, t = new Array(r > 1 ? r - 1 : 0), a = 1; a < r; a++)
t[a - 1] = arguments[a];
$("error", e, t);
}
}
function $(e, r, t) {
{
var a = F.ReactDebugCurrentFrame, l = a.getStackAddendum();
l !== "" && (r += "%s", t = t.concat([l]));
var v = t.map(function(s) {
return String(s);
});
v.unshift("Warning: " + r), Function.prototype.apply.call(console[e], console, v);
}
}
var Q = !1, ee = !1, b = !1, p = !1, O = !1, ve;
ve = Symbol.for("react.module.reference");
function Be(e) {
return !!(typeof e == "string" || typeof e == "function" || e === h || e === g || O || e === j || e === R || e === d || p || e === C || Q || ee || b || typeof e == "object" && e !== null && (e.$$typeof === _ || e.$$typeof === E || e.$$typeof === k || e.$$typeof === w || e.$$typeof === u || // This needs to include all possible module reference object
// types supported by any Flight configuration anywhere since
// we don't know which Flight build this will end up being used
// with.
e.$$typeof === ve || e.getModuleId !== void 0));
}
function qe(e, r, t) {
var a = e.displayName;
if (a)
return a;
var l = r.displayName || r.name || "";
return l !== "" ? t + "(" + l + ")" : t;
}
function pe(e) {
return e.displayName || "Context";
}
function D(e) {
if (e == null)
return null;
if (typeof e.tag == "number" && x("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
return e.displayName || e.name || null;
if (typeof e == "string")
return e;
switch (e) {
case h:
return "Fragment";
case f:
return "Portal";
case g:
return "Profiler";
case j:
return "StrictMode";
case R:
return "Suspense";
case d:
return "SuspenseList";
}
if (typeof e == "object")
switch (e.$$typeof) {
case w:
var r = e;
return pe(r) + ".Consumer";
case k:
var t = e;
return pe(t._context) + ".Provider";
case u:
return qe(e, e.render, "ForwardRef");
case E:
var a = e.displayName || null;
return a !== null ? a : D(e.type) || "Memo";
case _: {
var l = e, v = l._payload, s = l._init;
try {
return D(s(v));
} catch {
return null;
}
}
}
return null;
}
var A = Object.assign, U = 0, he, be, me, ge, ye, xe, je;
function Ee() {
}
Ee.__reactDisabledLog = !0;
function Je() {
{
if (U === 0) {
he = console.log, be = console.info, me = console.warn, ge = console.error, ye = console.group, xe = console.groupCollapsed, je = console.groupEnd;
var e = {
configurable: !0,
enumerable: !0,
value: Ee,
writable: !0
};
Object.defineProperties(console, {
info: e,
log: e,
warn: e,
error: e,
group: e,
groupCollapsed: e,
groupEnd: e
});
}
U++;
}
}
function ze() {
{
if (U--, U === 0) {
var e = {
configurable: !0,
enumerable: !0,
writable: !0
};
Object.defineProperties(console, {
log: A({}, e, {
value: he
}),
info: A({}, e, {
value: be
}),
warn: A({}, e, {
value: me
}),
error: A({}, e, {
value: ge
}),
group: A({}, e, {
value: ye
}),
groupCollapsed: A({}, e, {
value: xe
}),
groupEnd: A({}, e, {
value: je
})
});
}
U < 0 && x("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
}
}
var re = F.ReactCurrentDispatcher, te;
function z(e, r, t) {
{
if (te === void 0)
try {
throw Error();
} catch (l) {
var a = l.stack.trim().match(/\n( *(at )?)/);
te = a && a[1] || "";
}
return `
` + te + e;
}
}
var ne = !1, K;
{
var Ke = typeof WeakMap == "function" ? WeakMap : Map;
K = new Ke();
}
function Re(e, r) {
if (!e || ne)
return "";
{
var t = K.get(e);
if (t !== void 0)
return t;
}
var a;
ne = !0;
var l = Error.prepareStackTrace;
Error.prepareStackTrace = void 0;
var v;
v = re.current, re.current = null, Je();
try {
if (r) {
var s = function() {
throw Error();
};
if (Object.defineProperty(s.prototype, "props", {
set: function() {
throw Error();
}
}), typeof Reflect == "object" && Reflect.construct) {
try {
Reflect.construct(s, []);
} catch (S) {
a = S;
}
Reflect.construct(e, [], s);
} else {
try {
s.call();
} catch (S) {
a = S;
}
e.call(s.prototype);
}
} else {
try {
throw Error();
} catch (S) {
a = S;
}
e();
}
} catch (S) {
if (S && a && typeof S.stack == "string") {
for (var o = S.stack.split(`
`), T = a.stack.split(`
`), m = o.length - 1, y = T.length - 1; m >= 1 && y >= 0 && o[m] !== T[y]; )
y--;
for (; m >= 1 && y >= 0; m--, y--)
if (o[m] !== T[y]) {
if (m !== 1 || y !== 1)
do
if (m--, y--, y < 0 || o[m] !== T[y]) {
var P = `
` + o[m].replace(" at new ", " at ");
return e.displayName && P.includes("<anonymous>") && (P = P.replace("<anonymous>", e.displayName)), typeof e == "function" && K.set(e, P), P;
}
while (m >= 1 && y >= 0);
break;
}
}
} finally {
ne = !1, re.current = v, ze(), Error.prepareStackTrace = l;
}
var L = e ? e.displayName || e.name : "", I = L ? z(L) : "";
return typeof e == "function" && K.set(e, I), I;
}
function Ge(e, r, t) {
return Re(e, !1);
}
function He(e) {
var r = e.prototype;
return !!(r && r.isReactComponent);
}
function G(e, r, t) {
if (e == null)
return "";
if (typeof e == "function")
return Re(e, He(e));
if (typeof e == "string")
return z(e);
switch (e) {
case R:
return z("Suspense");
case d:
return z("SuspenseList");
}
if (typeof e == "object")
switch (e.$$typeof) {
case u:
return Ge(e.render);
case E:
return G(e.type, r, t);
case _: {
var a = e, l = a._payload, v = a._init;
try {
return G(v(l), r, t);
} catch {
}
}
}
return "";
}
var V = Object.prototype.hasOwnProperty, _e = {}, we = F.ReactDebugCurrentFrame;
function H(e) {
if (e) {
var r = e._owner, t = G(e.type, e._source, r ? r.type : null);
we.setExtraStackFrame(t);
} else
we.setExtraStackFrame(null);
}
function Xe(e, r, t, a, l) {
{
var v = Function.call.bind(V);
for (var s in e)
if (v(e, s)) {
var o = void 0;
try {
if (typeof e[s] != "function") {
var T = Error((a || "React class") + ": " + t + " type `" + s + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[s] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
throw T.name = "Invariant Violation", T;
}
o = e[s](r, s, a, t, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
} catch (m) {
o = m;
}
o && !(o instanceof Error) && (H(l), x("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", a || "React class", t, s, typeof o), H(null)), o instanceof Error && !(o.message in _e) && (_e[o.message] = !0, H(l), x("Failed %s type: %s", t, o.message), H(null));
}
}
}
var Ze = Array.isArray;
function ae(e) {
return Ze(e);
}
function Qe(e) {
{
var r = typeof Symbol == "function" && Symbol.toStringTag, t = r && e[Symbol.toStringTag] || e.constructor.name || "Object";
return t;
}
}
function er(e) {
try {
return Te(e), !1;
} catch {
return !0;
}
}
function Te(e) {
return "" + e;
}
function Se(e) {
if (er(e))
return x("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Qe(e)), Te(e);
}
var B = F.ReactCurrentOwner, rr = {
key: !0,
ref: !0,
__self: !0,
__source: !0
}, ke, Oe, ie;
ie = {};
function tr(e) {
if (V.call(e, "ref")) {
var r = Object.getOwnPropertyDescriptor(e, "ref").get;
if (r && r.isReactWarning)
return !1;
}
return e.ref !== void 0;
}
function nr(e) {
if (V.call(e, "key")) {
var r = Object.getOwnPropertyDescriptor(e, "key").get;
if (r && r.isReactWarning)
return !1;
}
return e.key !== void 0;
}
function ar(e, r) {
if (typeof e.ref == "string" && B.current && r && B.current.stateNode !== r) {
var t = D(B.current.type);
ie[t] || (x('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', D(B.current.type), e.ref), ie[t] = !0);
}
}
function ir(e, r) {
{
var t = function() {
ke || (ke = !0, x("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
};
t.isReactWarning = !0, Object.defineProperty(e, "key", {
get: t,
configurable: !0
});
}
}
function or(e, r) {
{
var t = function() {
Oe || (Oe = !0, x("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
};
t.isReactWarning = !0, Object.defineProperty(e, "ref", {
get: t,
configurable: !0
});
}
}
var sr = function(e, r, t, a, l, v, s) {
var o = {
// This tag allows us to uniquely identify this as a React Element
$$typeof: c,
// Built-in properties that belong on the element
type: e,
key: r,
ref: t,
props: s,
// Record the component responsible for creating this element.
_owner: v
};
return o._store = {}, Object.defineProperty(o._store, "validated", {
configurable: !1,
enumerable: !1,
writable: !0,
value: !1
}), Object.defineProperty(o, "_self", {
configurable: !1,
enumerable: !1,
writable: !1,
value: a
}), Object.defineProperty(o, "_source", {
configurable: !1,
enumerable: !1,
writable: !1,
value: l
}), Object.freeze && (Object.freeze(o.props), Object.freeze(o)), o;
};
function lr(e, r, t, a, l) {
{
var v, s = {}, o = null, T = null;
t !== void 0 && (Se(t), o = "" + t), nr(r) && (Se(r.key), o = "" + r.key), tr(r) && (T = r.ref, ar(r, l));
for (v in r)
V.call(r, v) && !rr.hasOwnProperty(v) && (s[v] = r[v]);
if (e && e.defaultProps) {
var m = e.defaultProps;
for (v in m)
s[v] === void 0 && (s[v] = m[v]);
}
if (o || T) {
var y = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
o && ir(s, y), T && or(s, y);
}
return sr(e, o, T, l, a, B.current, s);
}
}
var oe = F.ReactCurrentOwner, Ce = F.ReactDebugCurrentFrame;
function M(e) {
if (e) {
var r = e._owner, t = G(e.type, e._source, r ? r.type : null);
Ce.setExtraStackFrame(t);
} else
Ce.setExtraStackFrame(null);
}
var se;
se = !1;
function le(e) {
return typeof e == "object" && e !== null && e.$$typeof === c;
}
function Pe() {
{
if (oe.current) {
var e = D(oe.current.type);
if (e)
return `
Check the render method of \`` + e + "`.";
}
return "";
}
}
function cr(e) {
{
if (e !== void 0) {
var r = e.fileName.replace(/^.*[\\\/]/, ""), t = e.lineNumber;
return `
Check your code at ` + r + ":" + t + ".";
}
return "";
}
}
var $e = {};
function ur(e) {
{
var r = Pe();
if (!r) {
var t = typeof e == "string" ? e : e.displayName || e.name;
t && (r = `
Check the top-level render call using <` + t + ">.");
}
return r;
}
}
function De(e, r) {
{
if (!e._store || e._store.validated || e.key != null)
return;
e._store.validated = !0;
var t = ur(r);
if ($e[t])
return;
$e[t] = !0;
var a = "";
e && e._owner && e._owner !== oe.current && (a = " It was passed a child from " + D(e._owner.type) + "."), M(e), x('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', t, a), M(null);
}
}
function Ne(e, r) {
{
if (typeof e != "object")
return;
if (ae(e))
for (var t = 0; t < e.length; t++) {
var a = e[t];
le(a) && De(a, r);
}
else if (le(e))
e._store && (e._store.validated = !0);
else if (e) {
var l = Z(e);
if (typeof l == "function" && l !== e.entries)
for (var v = l.call(e), s; !(s = v.next()).done; )
le(s.value) && De(s.value, r);
}
}
}
function fr(e) {
{
var r = e.type;
if (r == null || typeof r == "string")
return;
var t;
if (typeof r == "function")
t = r.propTypes;
else if (typeof r == "object" && (r.$$typeof === u || // Note: Memo only checks outer props here.
// Inner props are checked in the reconciler.
r.$$typeof === E))
t = r.propTypes;
else
return;
if (t) {
var a = D(r);
Xe(t, e.props, "prop", a, e);
} else if (r.PropTypes !== void 0 && !se) {
se = !0;
var l = D(r);
x("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", l || "Unknown");
}
typeof r.getDefaultProps == "function" && !r.getDefaultProps.isReactClassApproved && x("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
}
}
function dr(e) {
{
for (var r = Object.keys(e.props), t = 0; t < r.length; t++) {
var a = r[t];
if (a !== "children" && a !== "key") {
M(e), x("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", a), M(null);
break;
}
}
e.ref !== null && (M(e), x("Invalid attribute `ref` supplied to `React.Fragment`."), M(null));
}
}
var Fe = {};
function Ae(e, r, t, a, l, v) {
{
var s = Be(e);
if (!s) {
var o = "";
(e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (o += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
var T = cr(l);
T ? o += T : o += Pe();
var m;
e === null ? m = "null" : ae(e) ? m = "array" : e !== void 0 && e.$$typeof === c ? (m = "<" + (D(e.type) || "Unknown") + " />", o = " Did you accidentally export a JSX literal instead of a component?") : m = typeof e, x("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", m, o);
}
var y = lr(e, r, t, l, v);
if (y == null)
return y;
if (s) {
var P = r.children;
if (P !== void 0)
if (a)
if (ae(P)) {
for (var L = 0; L < P.length; L++)
Ne(P[L], e);
Object.freeze && Object.freeze(P);
} else
x("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
else
Ne(P, e);
}
if (V.call(r, "key")) {
var I = D(e), S = Object.keys(r).filter(function(gr) {
return gr !== "key";
}), ce = S.length > 0 ? "{key: someKey, " + S.join(": ..., ") + ": ...}" : "{key: someKey}";
if (!Fe[I + ce]) {
var mr = S.length > 0 ? "{" + S.join(": ..., ") + ": ...}" : "{}";
x(`A props object containing a "key" prop is being spread into JSX:
let props = %s;
<%s {...props} />
React keys must be passed directly to JSX without using spread:
let props = %s;
<%s key={someKey} {...props} />`, ce, I, mr, I), Fe[I + ce] = !0;
}
}
return e === h ? dr(y) : fr(y), y;
}
}
function vr(e, r, t) {
return Ae(e, r, t, !0);
}
function pr(e, r, t) {
return Ae(e, r, t, !1);
}
var hr = pr, br = vr;
J.Fragment = h, J.jsx = hr, J.jsxs = br;
}()), J;
}
process.env.NODE_ENV === "production" ? de.exports = xr() : de.exports = jr();
var n = de.exports;
const Ue = (i) => ({
title: i === "dark" ? "text-white" : "!text-gray-900",
heading: i === "dark" ? "text-white" : "!text-gray-900",
text: i === "dark" ? "text-gray-200" : "!text-gray-900"
}), Er = (i, c) => {
const f = Ue(c), h = f.text;
return /* @__PURE__ */ n.jsxs("div", { className: `mb-6 ${f.text}`, children: [
/* @__PURE__ */ n.jsx("h4", { className: `text-lg font-semibold mb-2 ${f.heading}`, children: i.heading }),
/* @__PURE__ */ n.jsx("p", { className: `mb-3 ${h}`, children: i.text }),
i.list && /* @__PURE__ */ n.jsx("ul", { className: `list-disc pl-5 space-y-1 ${h}`, children: i.list.map((j, g) => /* @__PURE__ */ n.jsx("li", { className: h, children: j }, g)) })
] }, i.heading);
}, Rr = (i, c = "dark") => {
if (!i)
return null;
const f = Ue(c);
return /* @__PURE__ */ n.jsxs("div", { className: "space-y-6", children: [
/* @__PURE__ */ n.jsx("h3", { className: `text-xl font-bold mb-6 ${f.title}`, children: i.title }),
i.sections.map((h) => Er(h, c))
] });
}, Ve = (i) => ({
dark: {
modal: "bg-gray-900 text-white",
header: "border-gray-800 bg-gray-900/95 backdrop-blur-sm",
tabBorder: "border-gray-800",
activeTab: "text-blue-400 border-blue-400",
inactiveTab: "text-gray-400 border-transparent hover:text-blue-400/80",
completedTab: "text-emerald-400",
content: "prose-invert",
footer: "border-gray-800 bg-gray-900/95 backdrop-blur-sm",
checkbox: {
base: "border-gray-600 group-hover:border-blue-400",
checked: "bg-blue-500 border-blue-500",
disabled: "opacity-50 cursor-not-allowed"
},
text: {
enabled: "text-gray-200",
disabled: "text-gray-500"
}
},
light: {
modal: "bg-white text-gray-900",
header: "border-gray-200 bg-white/95 backdrop-blur-sm",
tabBorder: "border-gray-200",
activeTab: "text-blue-600 border-blue-600",
inactiveTab: "text-gray-500 border-transparent hover:text-blue-600/80",
completedTab: "text-emerald-600",
content: "prose-base",
footer: "border-gray-200 bg-white/95 backdrop-blur-sm",
checkbox: {
base: "border-gray-300 group-hover:border-blue-500",
checked: "bg-blue-600 border-blue-600",
disabled: "opacity-50 cursor-not-allowed"
},
text: {
enabled: "text-gray-900",
disabled: "text-gray-500"
}
}
})[i], _r = ({
content: i,
onScroll: c,
onAgree: f,
isActive: h,
isScrolled: j,
isAgreed: g,
sectionTitle: k,
theme: w
}) => {
const u = yr(null), R = Ve(w);
return X(() => {
const d = () => {
if (!u.current)
return;
const { scrollHeight: _, scrollTop: C, clientHeight: Y } = u.current;
_ - C - Y < 20 && !j && c(!0);
}, E = u.current;
if (E)
return E.addEventListener("scroll", d), d(), () => E.removeEventListener("scroll", d);
}, [c, j]), h ? /* @__PURE__ */ n.jsxs("div", { className: "flex flex-col p-4", children: [
/* @__PURE__ */ n.jsx(
"div",
{
ref: u,
className: `
overflow-y-auto prose max-w-none mb-4 p-4 rounded-lg
${R.content}
${w === "light" ? "border border-gray-200 bg-white shadow-sm" : "border border-gray-700 bg-gray-800 shadow-sm"}
max-h-[calc(60vh-4rem)]
`,
children: i
}
),
/* @__PURE__ */ n.jsxs("label", { className: "flex items-center group cursor-pointer select-none", children: [
/* @__PURE__ */ n.jsxs("div", { className: "relative", children: [
/* @__PURE__ */ n.jsx(
"input",
{
type: "checkbox",
className: "sr-only",
checked: g,
onChange: f,
disabled: !j
}
),
/* @__PURE__ */ n.jsx(
"div",
{
className: `
w-5 h-5 border-2 rounded transition-all duration-200
${j ? R.checkbox.base : R.checkbox.disabled}
${g ? R.checkbox.checked : ""}
`
}
),
g && /* @__PURE__ */ n.jsx(Le, { className: "absolute top-0.5 left-0.5 w-4 h-4 text-white" })
] }),
/* @__PURE__ */ n.jsxs("span", { className: `ml-3 ${j ? R.text.enabled : R.text.disabled}`, children: [
"I have read and agree to the ",
k
] })
] })
] }) : null;
}, ue = "im-disclaimer-accepted", wr = ({
isOpen: i,
onClose: c,
title: f,
disclaimerContent: h,
disclaimerSections: j,
theme: g = "dark",
customTheme: k,
setAllAgreed: w,
onAllSectionsAgreed: u,
accentColor: R
}) => {
const d = h ? Object.entries(h).map(([b, p]) => ({
title: p.title,
required: p.required,
content: Rr(p.content, g)
})) : j || [], [E, _] = W(0), [C, Y] = W(
new Array(d.length).fill(!1)
), [N, Z] = W(
new Array(d.length).fill(!1)
), [F, x] = W(i), $ = k || Ve(g);
X(() => {
const b = localStorage.getItem(ue);
b && new Set(JSON.parse(b)).has(f) && x(!1);
}, [f]);
const Q = () => {
const b = localStorage.getItem(ue), p = b ? new Set(JSON.parse(b)) : /* @__PURE__ */ new Set();
p.add(f), localStorage.setItem(ue, JSON.stringify(Array.from(p))), x(!1), c == null || c();
};
if (X(() => {
const b = d.filter((p) => p.required).every((p, O) => N[O]);
w == null || w(b), u == null || u(b);
}, [d, N, u]), !F)
return null;
const ee = d.filter((b) => b.required).every((b, p) => N[p]);
return /* @__PURE__ */ n.jsxs(n.Fragment, { children: [
/* @__PURE__ */ n.jsx("div", { className: "fixed inset-0 z-40", children: /* @__PURE__ */ n.jsx("div", { className: "absolute inset-0 bg-black/40 backdrop-blur-md transition-all duration-300" }) }),
/* @__PURE__ */ n.jsx("div", { className: "fixed inset-0 z-50 flex items-center justify-center p-4", children: /* @__PURE__ */ n.jsxs(
"div",
{
className: `
w-full max-w-4xl rounded-xl shadow-2xl overflow-hidden
flex flex-col
${$.modal}
transform transition-all duration-200 ease-out
border border-gray-200/10
`,
children: [
/* @__PURE__ */ n.jsx("div", { className: `sticky top-0 z-10 px-6 py-4 border-b flex items-center ${$.header}`, children: /* @__PURE__ */ n.jsx("h2", { className: "text-2xl font-bold text-gray-900 dark:text-white mb-4", children: f }) }),
/* @__PURE__ */ n.jsx("div", { className: `sticky top-[4.5rem] z-10 flex border-b ${$.tabBorder} bg-inherit`, children: d.map((b, p) => {
const O = N[p] ? "completed" : C[p] ? "scrolled" : "pending";
return /* @__PURE__ */ n.jsxs(
"button",
{
onClick: () => _(p),
className: `
flex items-center gap-2 px-6 py-3 text-sm font-medium border-b-2 -mb-[2px]
transition-all duration-200
${E === p ? $.activeTab : O === "completed" ? $.completedTab : $.inactiveTab}
`,
children: [
O === "completed" ? /* @__PURE__ */ n.jsx(Le, { className: "w-4 h-4" }) : /* @__PURE__ */ n.jsx("div", { className: `w-2 h-2 rounded-full ${O === "scrolled" ? "bg-current" : "bg-current opacity-40"}` }),
b.title,
b.required && /* @__PURE__ */ n.jsx("span", { className: "text-red-500", children: "*" })
]
},
b.title
);
}) }),
/* @__PURE__ */ n.jsx("div", { className: `flex-1 overflow-y-auto ${$.content}`, children: d.map((b, p) => /* @__PURE__ */ n.jsx(
_r,
{
content: b.content,
onScroll: () => {
const O = [...C];
O[p] = !0, Y(O);
},
onAgree: () => {
const O = [...N];
O[p] = !0, Z(O);
},
isActive: E === p,
isScrolled: C[p],
isAgreed: N[p],
sectionTitle: b.title,
theme: g
},
b.title
)) }),
/* @__PURE__ */ n.jsx("div", { className: `sticky bottom-0 flex justify-end gap-4 px-6 py-4 border-t ${$.footer}`, children: /* @__PURE__ */ n.jsx(
"button",
{
onClick: Q,
disabled: !ee,
style: { backgroundColor: R },
className: `
px-6 py-2 rounded-lg font-medium
disabled:opacity-50 disabled:cursor-not-allowed
transition-all duration-200
`,
children: "Accept All"
}
) })
]
}
) })
] });
}, Tr = wr, fe = {
get: (i) => {
if (typeof window > "u")
return null;
try {
return localStorage.getItem(i);
} catch (c) {
return console.warn("Failed to access localStorage:", c), null;
}
},
set: (i, c) => {
if (!(typeof window > "u"))
try {
localStorage.setItem(i, c);
} catch (f) {
console.warn("Failed to write to localStorage:", f);
}
},
remove: (i) => {
if (!(typeof window > "u"))
try {
localStorage.removeItem(i);
} catch (c) {
console.warn("Failed to remove from localStorage:", c);
}
}
}, Sr = (i, c = {}) => {
const {
storagePrefix: f = "disclaimer",
defaultOpen: h = !0
} = c, [j, g] = W(!1), [k, w] = W(!1), [u, R] = W(!1);
X(() => {
w(!0);
const _ = `${f}_${i}`, C = fe.get(_) === "true";
g(!C && h);
}, [i, f, h]);
const d = Ie(() => {
if (u) {
const _ = `${f}_${i}`;
fe.set(_, "true"), g(!1);
}
}, [u, i, f]), E = Ie(() => {
const _ = `${f}_${i}`;
fe.remove(_), g(!0);
}, [i, f]);
return k ? { isOpen: j, onClose: d, reset: E, setAllSectionsAgreed: R } : {
isOpen: !1,
onClose: () => {
},
reset: () => {
},
setAllSectionsAgreed: () => {
}
};
}, kr = ({
id: i,
title: c,
disclaimerSections: f,
theme: h = "light",
storagePrefix: j = "disclaimer"
}) => {
const { isOpen: g, onClose: k } = Sr(i, {
storagePrefix: j,
defaultOpen: !0
});
return /* @__PURE__ */ n.jsx(
Tr,
{
isOpen: g,
onClose: k,
title: c,
disclaimerSections: f,
theme: h
}
);
}, Dr = kr, Or = () => /* @__PURE__ */ n.jsxs(n.Fragment, { children: [
/* @__PURE__ */ n.jsx("h3", { children: "Terms of Use" }),
/* @__PURE__ */ n.jsx("p", { children: "Please read these terms carefully. By accessing or using this service, you agree to be bound by these terms and conditions." }),
/* @__PURE__ */ n.jsx("h4", { children: "1. Service Overview" }),
/* @__PURE__ */ n.jsx("p", { children: "This section describes the service and its primary functions. Replace this content with your specific service description." }),
/* @__PURE__ */ n.jsx("h4", { children: "2. User Responsibilities" }),
/* @__PURE__ */ n.jsx("p", { children: "As a user of this service, you are responsible for:" }),
/* @__PURE__ */ n.jsxs("ul", { children: [
/* @__PURE__ */ n.jsx("li", { children: "Maintaining the confidentiality of your account" }),
/* @__PURE__ */ n.jsx("li", { children: "Providing accurate and truthful information" }),
/* @__PURE__ */ n.jsx("li", { children: "Complying with all applicable regulations" }),
/* @__PURE__ */ n.jsx("li", { children: "Protecting privacy and confidentiality" })
] })
] }), Cr = () => /* @__PURE__ */ n.jsxs(n.Fragment, { children: [
/* @__PURE__ */ n.jsx("h3", { children: "Privacy Policy" }),
/* @__PURE__ */ n.jsx("p", { children: "This Privacy Policy describes how we collect, use, and handle your information." }),
/* @__PURE__ */ n.jsx("h4", { children: "1. Information Collection" }),
/* @__PURE__ */ n.jsx("p", { children: "We collect information that you provide directly to us, including:" }),
/* @__PURE__ */ n.jsxs("ul", { children: [
/* @__PURE__ */ n.jsx("li", { children: "Account information" }),
/* @__PURE__ */ n.jsx("li", { children: "Usage data" }),
/* @__PURE__ */ n.jsx("li", { children: "Communication preferences" })
] }),
/* @__PURE__ */ n.jsx("h4", { children: "2. Data Usage" }),
/* @__PURE__ */ n.jsx("p", { children: "We use collected information to:" }),
/* @__PURE__ */ n.jsxs("ul", { children: [
/* @__PURE__ */ n.jsx("li", { children: "Provide and maintain our services" }),
/* @__PURE__ */ n.jsx("li", { children: "Improve user experience" }),
/* @__PURE__ */ n.jsx("li", { children: "Send important notifications" })
] })
] }), Nr = {
terms: {
id: "terms",
title: "Terms & Conditions",
content: /* @__PURE__ */ n.jsx(Or, {})
},
privacy: {
id: "privacy",
title: "Privacy Policy",
content: /* @__PURE__ */ n.jsx(Cr, {})
}
};
export {
Tr as DisclaimerModal,
Dr as DisclaimerProvider,
Cr as PrivacyTemplate,
Or as TermsTemplate,
Nr as exampleDisclaimers,
Rr as renderDisclaimerContent,
Sr as useDisclaimer
};
//# sourceMappingURL=index.es.js.map