UNPKG

contentstack-chat-widget-sdk

Version:

React TypeScript SDK for embedding ContentStack AI-powered chat widgets into websites

1,894 lines 286 kB
import Ei, { useState as ze, useRef as st, useEffect as Xe, useCallback as Fe } from "react"; function ur(e) { return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e; } var rt = { exports: {} }, qe = {}; /** * @license React * react-jsx-runtime.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var xn; function vi() { if (xn) return qe; xn = 1; var e = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment"); function t(r, l, o) { var i = null; if (o !== void 0 && (i = "" + o), l.key !== void 0 && (i = "" + l.key), "key" in l) { o = {}; for (var a in l) a !== "key" && (o[a] = l[a]); } else o = l; return l = o.ref, { $$typeof: e, type: r, key: i, ref: l !== void 0 ? l : null, props: o }; } return qe.Fragment = n, qe.jsx = t, qe.jsxs = t, qe; } var Ue = {}; /** * @license React * react-jsx-runtime.development.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var yn; function Ii() { return yn || (yn = 1, process.env.NODE_ENV !== "production" && (function() { function e(p) { if (p == null) return null; if (typeof p == "function") return p.$$typeof === b ? null : p.displayName || p.name || null; if (typeof p == "string") return p; switch (p) { case k: return "Fragment"; case x: return "Profiler"; case E: return "StrictMode"; case D: return "Suspense"; case y: return "SuspenseList"; case U: return "Activity"; } if (typeof p == "object") switch (typeof p.tag == "number" && console.error( "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue." ), p.$$typeof) { case g: return "Portal"; case C: return (p.displayName || "Context") + ".Provider"; case S: return (p._context.displayName || "Context") + ".Consumer"; case A: var N = p.render; return p = p.displayName, p || (p = N.displayName || N.name || "", p = p !== "" ? "ForwardRef(" + p + ")" : "ForwardRef"), p; case _: return N = p.displayName || null, N !== null ? N : e(p.type) || "Memo"; case F: N = p._payload, p = p._init; try { return e(p(N)); } catch { } } return null; } function n(p) { return "" + p; } function t(p) { try { n(p); var N = !1; } catch { N = !0; } if (N) { N = console; var V = N.error, d = typeof Symbol == "function" && Symbol.toStringTag && p[Symbol.toStringTag] || p.constructor.name || "Object"; return V.call( N, "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", d ), n(p); } } function r(p) { if (p === k) return "<>"; if (typeof p == "object" && p !== null && p.$$typeof === F) return "<...>"; try { var N = e(p); return N ? "<" + N + ">" : "<...>"; } catch { return "<...>"; } } function l() { var p = R.A; return p === null ? null : p.getOwner(); } function o() { return Error("react-stack-top-frame"); } function i(p) { if (L.call(p, "key")) { var N = Object.getOwnPropertyDescriptor(p, "key").get; if (N && N.isReactWarning) return !1; } return p.key !== void 0; } function a(p, N) { function V() { M || (M = !0, console.error( "%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://react.dev/link/special-props)", N )); } V.isReactWarning = !0, Object.defineProperty(p, "key", { get: V, configurable: !0 }); } function s() { var p = e(this.type); return K[p] || (K[p] = !0, console.error( "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release." )), p = this.props.ref, p !== void 0 ? p : null; } function u(p, N, V, d, Z, te, G, ke) { return V = te.ref, p = { $$typeof: h, type: p, key: N, props: te, _owner: Z }, (V !== void 0 ? V : null) !== null ? Object.defineProperty(p, "ref", { enumerable: !1, get: s }) : Object.defineProperty(p, "ref", { enumerable: !1, value: null }), p._store = {}, Object.defineProperty(p._store, "validated", { configurable: !1, enumerable: !1, writable: !0, value: 0 }), Object.defineProperty(p, "_debugInfo", { configurable: !1, enumerable: !1, writable: !0, value: null }), Object.defineProperty(p, "_debugStack", { configurable: !1, enumerable: !1, writable: !0, value: G }), Object.defineProperty(p, "_debugTask", { configurable: !1, enumerable: !1, writable: !0, value: ke }), Object.freeze && (Object.freeze(p.props), Object.freeze(p)), p; } function f(p, N, V, d, Z, te, G, ke) { var Q = N.children; if (Q !== void 0) if (d) if (z(Q)) { for (d = 0; d < Q.length; d++) c(Q[d]); Object.freeze && Object.freeze(Q); } else console.error( "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 c(Q); if (L.call(N, "key")) { Q = e(p); var se = Object.keys(N).filter(function(Pe) { return Pe !== "key"; }); d = 0 < se.length ? "{key: someKey, " + se.join(": ..., ") + ": ...}" : "{key: someKey}", he[Q + d] || (se = 0 < se.length ? "{" + se.join(": ..., ") + ": ...}" : "{}", console.error( `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} />`, d, Q, se, Q ), he[Q + d] = !0); } if (Q = null, V !== void 0 && (t(V), Q = "" + V), i(N) && (t(N.key), Q = "" + N.key), "key" in N) { V = {}; for (var ge in N) ge !== "key" && (V[ge] = N[ge]); } else V = N; return Q && a( V, typeof p == "function" ? p.displayName || p.name || "Unknown" : p ), u( p, Q, te, Z, l(), V, G, ke ); } function c(p) { typeof p == "object" && p !== null && p.$$typeof === h && p._store && (p._store.validated = 1); } var m = Ei, h = Symbol.for("react.transitional.element"), g = Symbol.for("react.portal"), k = Symbol.for("react.fragment"), E = Symbol.for("react.strict_mode"), x = Symbol.for("react.profiler"), S = Symbol.for("react.consumer"), C = Symbol.for("react.context"), A = Symbol.for("react.forward_ref"), D = Symbol.for("react.suspense"), y = Symbol.for("react.suspense_list"), _ = Symbol.for("react.memo"), F = Symbol.for("react.lazy"), U = Symbol.for("react.activity"), b = Symbol.for("react.client.reference"), R = m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, L = Object.prototype.hasOwnProperty, z = Array.isArray, P = console.createTask ? console.createTask : function() { return null; }; m = { react_stack_bottom_frame: function(p) { return p(); } }; var M, K = {}, J = m.react_stack_bottom_frame.bind( m, o )(), le = P(r(o)), he = {}; Ue.Fragment = k, Ue.jsx = function(p, N, V, d, Z) { var te = 1e4 > R.recentlyCreatedOwnerStacks++; return f( p, N, V, !1, d, Z, te ? Error("react-stack-top-frame") : J, te ? P(r(p)) : le ); }, Ue.jsxs = function(p, N, V, d, Z) { var te = 1e4 > R.recentlyCreatedOwnerStacks++; return f( p, N, V, !0, d, Z, te ? Error("react-stack-top-frame") : J, te ? P(r(p)) : le ); }; })()), Ue; } var kn; function Ti() { return kn || (kn = 1, process.env.NODE_ENV === "production" ? rt.exports = vi() : rt.exports = Ii()), rt.exports; } var I = Ti(); const Ai = { primaryColor: "#6a5ddf", secondaryColor: "#f3f4f6", backgroundColor: "#ffffff", textColor: "#1f2937", userMessageColor: "#6a5ddf", assistantMessageColor: "#f3f4f6", borderRadius: "12px", fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif' }; class cr { // constructor(apiEndpoint: string = 'http://localhost:5002/api/contentstack/query-stream') { constructor(n = "http://localhost:5002/api/contentstack/query-stream") { this.apiEndpoint = n; } async sendMessageStream(n, t, r, l, o, i = 30, a) { try { const s = await fetch(this.apiEndpoint, { method: "POST", headers: { "Content-Type": "application/json", Accept: "text/event-stream" }, body: JSON.stringify(n), signal: a?.signal // Support request cancellation }); if (!s.ok) throw new Error(`HTTP error! status: ${s.status}`); const u = s.body?.getReader(); if (!u) throw new Error("Failed to get response reader"); const f = new TextDecoder(); let c = "", m = [], h = !1, g = !1; const k = () => a?.signal.aborted ? (g = !0, m.length = 0, !0) : !1, E = async () => { if (!(h || m.length === 0 || g)) { for (h = !0; m.length > 0 && !g && !k(); ) { const x = m.shift(); t(x); let S = i; x === " " ? S = i * 0.5 : [".", "!", "?", ",", ";", ":"].includes(x) ? S = i * 2 : x === ` ` && (S = i * 3); const C = S * 0.2 * (Math.random() - 0.5); S = Math.max(10, S + C), await new Promise((A) => setTimeout(A, S)); } h = !1; } }; for (; ; ) { if (k()) { u.cancel(); return; } const { done: x, value: S } = await u.read(); if (x) { for (; m.length > 0 && !g && !k(); ) { const A = m.shift(); t(A), await new Promise((D) => setTimeout(D, i)); } break; } c += f.decode(S, { stream: !0 }); const C = c.split(` `); c = C.pop() || ""; for (const A of C) if (A.startsWith("data: ")) { const D = A.slice(6); if (D === "[DONE]") { for (; m.length > 0; ) { const y = m.shift(); t(y), await new Promise((_) => setTimeout(_, i)); } r?.(); return; } try { const y = JSON.parse(D); if (y.chunk) { const _ = y.chunk.split(""); m.push(..._), E(); } else if (y.type === "status" && y.message) o?.(y.message); else if (y.type === "complete") { for (; m.length > 0; ) { const _ = m.shift(); t(_), await new Promise((F) => setTimeout(F, i)); } r?.(); return; } else if (y.error) { l?.(y.error); return; } } catch { continue; } } } g || r?.(); } catch (s) { if (s instanceof Error && s.name === "AbortError") { console.log("Request was cancelled by user"); return; } console.error("ContentStack Chat Streaming API Error:", s), l?.(s instanceof Error ? s.message : "Unknown error occurred"); } } // Utility method to create a properly formatted request createRequest(n, t = {}) { return { query: n, tenantId: t.tenantId, apiKey: t.apiKey, projectId: t.projectId, provider: t.provider, model: t.model, sessionId: t.sessionId }; } } const lf = new cr(), Pi = (e) => { const [n, t] = ze([]), [r, l] = ze(!1), [o] = ze(() => `session_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`), i = e.provider || "groq", a = e.model || "llama-3.1-8b-instant", s = st(new cr(e.apiEndpoint)), u = st(null), f = st(null); Xe(() => { u.current?.scrollIntoView({ behavior: "smooth" }); }, [n]), Xe(() => { if (e.welcomeMessage && n.length === 0) { const g = { id: `welcome-${Date.now()}`, type: "assistant", content: e.welcomeMessage, timestamp: /* @__PURE__ */ new Date() }; t([g]); } }, [e.welcomeMessage, n.length]); const c = Fe(() => { f.current && (f.current.abort(), f.current = null, l(!1)); }, []), m = Fe(async (g) => { if (!g.trim()) return; r && c(); const k = new AbortController(); f.current = k; const E = { id: `user-${Date.now()}`, type: "user", content: g.trim(), timestamp: /* @__PURE__ */ new Date() }; t((A) => [...A, E]), l(!0); const x = `status-${Date.now()}`, S = { id: x, type: "status", content: "⏳ Processing your request...", timestamp: /* @__PURE__ */ new Date(), isStatus: !0 }; t((A) => [...A, S]); const C = { id: `assistant-${Date.now()}`, type: "assistant", content: "", timestamp: /* @__PURE__ */ new Date(), isLoading: !0 }; try { const A = s.current.createRequest(g, { tenantId: e.tenantId, apiKey: e.apiKey, projectId: e.projectId, provider: i, model: a, sessionId: o }); console.log("🔍 SDK Debug - Props provider:", e.provider), console.log("🔍 SDK Debug - Props model:", e.model), console.log("🔍 SDK Debug - Final provider:", i), console.log("🔍 SDK Debug - Final model:", a), console.log("🔍 SDK Debug - Request payload:", A), await s.current.sendMessageStream( A, // onChunk - append each character for typing effect (D) => { t((y) => y.some((F) => F.id === C.id) ? y.map( (F) => F.id === C.id ? { ...F, content: F.content + D, isLoading: !0 } : F ) : y.filter((F) => F.id !== x).concat([{ ...C, content: D, isLoading: !0 }])); }, // onComplete - mark message as complete and remove status message () => { let D; t((y) => { const _ = y.filter((F) => F.id !== x).map( (F) => F.id === C.id ? { ...F, isLoading: !1 } : F ); return D = _.find((F) => F.id === C.id), _; }), l(!1), f.current = null, e.onMessage && D && e.onMessage(D); }, // onError - handle streaming errors (D) => { console.error("Streaming error:", D); const y = { id: C.id, type: "assistant", content: "I apologize, but I encountered an error. Please try again.", timestamp: /* @__PURE__ */ new Date(), isLoading: !1 }; t( (_) => _.filter((F) => F.id !== x).map((F) => F.id === C.id ? y : F) ), l(!1), f.current = null; }, // onStatus - update status message (D) => { t( (y) => y.map( (_) => _.id === x ? { ..._, content: D } : _ ) ); }, // typingSpeed - configurable typing speed e.typingSpeed || 30, // abortController - for cancellation support k ); } catch (A) { console.error("Error sending message:", A); const D = { id: C.id, type: "assistant", content: "I apologize, but I encountered an error. Please try again.", timestamp: /* @__PURE__ */ new Date(), isLoading: !1 }; t( (y) => y.map((_) => _.id === C.id ? D : _) ), l(!1), f.current = null; } }, [ r, i, a, e.tenantId, e.apiKey, e.projectId, e.onMessage ]), h = Fe(() => { if (t([]), e.welcomeMessage) { const g = { id: `welcome-${Date.now()}`, type: "assistant", content: e.welcomeMessage, timestamp: /* @__PURE__ */ new Date() }; t([g]); } }, [e.welcomeMessage]); return { messages: n, isLoading: r, sendMessage: m, cancelCurrentRequest: c, clearMessages: h, messagesEndRef: u }; }, Di = (e = !1) => { const [n, t] = ze(e), r = Fe(() => { t((i) => !i); }, []), l = Fe(() => { t(!0); }, []), o = Fe(() => { t(!1); }, []); return { isOpen: n, toggle: r, open: l, close: o }; }; function Ri(e, n) { const t = {}; return (e[e.length - 1] === "" ? [...e, ""] : e).join( (t.padRight ? " " : "") + "," + (t.padLeft === !1 ? "" : " ") ).trim(); } const _i = /^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u, Li = /^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u, zi = {}; function bn(e, n) { return (zi.jsx ? Li : _i).test(e); } const Fi = /[ \t\n\f\r]/g; function Oi(e) { return typeof e == "object" ? e.type === "text" ? wn(e.value) : !1 : wn(e); } function wn(e) { return e.replace(Fi, "") === ""; } class et { /** * @param {SchemaType['property']} property * Property. * @param {SchemaType['normal']} normal * Normal. * @param {Space | undefined} [space] * Space. * @returns * Schema. */ constructor(n, t, r) { this.normal = t, this.property = n, r && (this.space = r); } } et.prototype.normal = {}; et.prototype.property = {}; et.prototype.space = void 0; function fr(e, n) { const t = {}, r = {}; for (const l of e) Object.assign(t, l.property), Object.assign(r, l.normal); return new et(t, r, n); } function Ot(e) { return e.toLowerCase(); } class ae { /** * @param {string} property * Property. * @param {string} attribute * Attribute. * @returns * Info. */ constructor(n, t) { this.attribute = t, this.property = n; } } ae.prototype.attribute = ""; ae.prototype.booleanish = !1; ae.prototype.boolean = !1; ae.prototype.commaOrSpaceSeparated = !1; ae.prototype.commaSeparated = !1; ae.prototype.defined = !1; ae.prototype.mustUseProperty = !1; ae.prototype.number = !1; ae.prototype.overloadedBoolean = !1; ae.prototype.property = ""; ae.prototype.spaceSeparated = !1; ae.prototype.space = void 0; let Ni = 0; const B = Ae(), ee = Ae(), Nt = Ae(), v = Ae(), X = Ae(), Oe = Ae(), ce = Ae(); function Ae() { return 2 ** ++Ni; } const Mt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, boolean: B, booleanish: ee, commaOrSpaceSeparated: ce, commaSeparated: Oe, number: v, overloadedBoolean: Nt, spaceSeparated: X }, Symbol.toStringTag, { value: "Module" })), kt = ( /** @type {ReadonlyArray<keyof typeof types>} */ Object.keys(Mt) ); class Yt extends ae { /** * @constructor * @param {string} property * Property. * @param {string} attribute * Attribute. * @param {number | null | undefined} [mask] * Mask. * @param {Space | undefined} [space] * Space. * @returns * Info. */ constructor(n, t, r, l) { let o = -1; if (super(n, t), Cn(this, "space", l), typeof r == "number") for (; ++o < kt.length; ) { const i = kt[o]; Cn(this, kt[o], (r & Mt[i]) === Mt[i]); } } } Yt.prototype.defined = !0; function Cn(e, n, t) { t && (e[n] = t); } function Me(e) { const n = {}, t = {}; for (const [r, l] of Object.entries(e.properties)) { const o = new Yt( r, e.transform(e.attributes || {}, r), l, e.space ); e.mustUseProperty && e.mustUseProperty.includes(r) && (o.mustUseProperty = !0), n[r] = o, t[Ot(r)] = r, t[Ot(o.attribute)] = r; } return new et(n, t, e.space); } const hr = Me({ properties: { ariaActiveDescendant: null, ariaAtomic: ee, ariaAutoComplete: null, ariaBusy: ee, ariaChecked: ee, ariaColCount: v, ariaColIndex: v, ariaColSpan: v, ariaControls: X, ariaCurrent: null, ariaDescribedBy: X, ariaDetails: null, ariaDisabled: ee, ariaDropEffect: X, ariaErrorMessage: null, ariaExpanded: ee, ariaFlowTo: X, ariaGrabbed: ee, ariaHasPopup: null, ariaHidden: ee, ariaInvalid: null, ariaKeyShortcuts: null, ariaLabel: null, ariaLabelledBy: X, ariaLevel: v, ariaLive: null, ariaModal: ee, ariaMultiLine: ee, ariaMultiSelectable: ee, ariaOrientation: null, ariaOwns: X, ariaPlaceholder: null, ariaPosInSet: v, ariaPressed: ee, ariaReadOnly: ee, ariaRelevant: null, ariaRequired: ee, ariaRoleDescription: X, ariaRowCount: v, ariaRowIndex: v, ariaRowSpan: v, ariaSelected: ee, ariaSetSize: v, ariaSort: null, ariaValueMax: v, ariaValueMin: v, ariaValueNow: v, ariaValueText: null, role: null }, transform(e, n) { return n === "role" ? n : "aria-" + n.slice(4).toLowerCase(); } }); function pr(e, n) { return n in e ? e[n] : n; } function mr(e, n) { return pr(e, n.toLowerCase()); } const Mi = Me({ attributes: { acceptcharset: "accept-charset", classname: "class", htmlfor: "for", httpequiv: "http-equiv" }, mustUseProperty: ["checked", "multiple", "muted", "selected"], properties: { // Standard Properties. abbr: null, accept: Oe, acceptCharset: X, accessKey: X, action: null, allow: null, allowFullScreen: B, allowPaymentRequest: B, allowUserMedia: B, alt: null, as: null, async: B, autoCapitalize: null, autoComplete: X, autoFocus: B, autoPlay: B, blocking: X, capture: null, charSet: null, checked: B, cite: null, className: X, cols: v, colSpan: null, content: null, contentEditable: ee, controls: B, controlsList: X, coords: v | Oe, crossOrigin: null, data: null, dateTime: null, decoding: null, default: B, defer: B, dir: null, dirName: null, disabled: B, download: Nt, draggable: ee, encType: null, enterKeyHint: null, fetchPriority: null, form: null, formAction: null, formEncType: null, formMethod: null, formNoValidate: B, formTarget: null, headers: X, height: v, hidden: Nt, high: v, href: null, hrefLang: null, htmlFor: X, httpEquiv: X, id: null, imageSizes: null, imageSrcSet: null, inert: B, inputMode: null, integrity: null, is: null, isMap: B, itemId: null, itemProp: X, itemRef: X, itemScope: B, itemType: X, kind: null, label: null, lang: null, language: null, list: null, loading: null, loop: B, low: v, manifest: null, max: null, maxLength: v, media: null, method: null, min: null, minLength: v, multiple: B, muted: B, name: null, nonce: null, noModule: B, noValidate: B, onAbort: null, onAfterPrint: null, onAuxClick: null, onBeforeMatch: null, onBeforePrint: null, onBeforeToggle: null, onBeforeUnload: null, onBlur: null, onCancel: null, onCanPlay: null, onCanPlayThrough: null, onChange: null, onClick: null, onClose: null, onContextLost: null, onContextMenu: null, onContextRestored: null, onCopy: null, onCueChange: null, onCut: null, onDblClick: null, onDrag: null, onDragEnd: null, onDragEnter: null, onDragExit: null, onDragLeave: null, onDragOver: null, onDragStart: null, onDrop: null, onDurationChange: null, onEmptied: null, onEnded: null, onError: null, onFocus: null, onFormData: null, onHashChange: null, onInput: null, onInvalid: null, onKeyDown: null, onKeyPress: null, onKeyUp: null, onLanguageChange: null, onLoad: null, onLoadedData: null, onLoadedMetadata: null, onLoadEnd: null, onLoadStart: null, onMessage: null, onMessageError: null, onMouseDown: null, onMouseEnter: null, onMouseLeave: null, onMouseMove: null, onMouseOut: null, onMouseOver: null, onMouseUp: null, onOffline: null, onOnline: null, onPageHide: null, onPageShow: null, onPaste: null, onPause: null, onPlay: null, onPlaying: null, onPopState: null, onProgress: null, onRateChange: null, onRejectionHandled: null, onReset: null, onResize: null, onScroll: null, onScrollEnd: null, onSecurityPolicyViolation: null, onSeeked: null, onSeeking: null, onSelect: null, onSlotChange: null, onStalled: null, onStorage: null, onSubmit: null, onSuspend: null, onTimeUpdate: null, onToggle: null, onUnhandledRejection: null, onUnload: null, onVolumeChange: null, onWaiting: null, onWheel: null, open: B, optimum: v, pattern: null, ping: X, placeholder: null, playsInline: B, popover: null, popoverTarget: null, popoverTargetAction: null, poster: null, preload: null, readOnly: B, referrerPolicy: null, rel: X, required: B, reversed: B, rows: v, rowSpan: v, sandbox: X, scope: null, scoped: B, seamless: B, selected: B, shadowRootClonable: B, shadowRootDelegatesFocus: B, shadowRootMode: null, shape: null, size: v, sizes: null, slot: null, span: v, spellCheck: ee, src: null, srcDoc: null, srcLang: null, srcSet: null, start: v, step: null, style: null, tabIndex: v, target: null, title: null, translate: null, type: null, typeMustMatch: B, useMap: null, value: ee, width: v, wrap: null, writingSuggestions: null, // Legacy. // See: https://html.spec.whatwg.org/#other-elements,-attributes-and-apis align: null, // Several. Use CSS `text-align` instead, aLink: null, // `<body>`. Use CSS `a:active {color}` instead archive: X, // `<object>`. List of URIs to archives axis: null, // `<td>` and `<th>`. Use `scope` on `<th>` background: null, // `<body>`. Use CSS `background-image` instead bgColor: null, // `<body>` and table elements. Use CSS `background-color` instead border: v, // `<table>`. Use CSS `border-width` instead, borderColor: null, // `<table>`. Use CSS `border-color` instead, bottomMargin: v, // `<body>` cellPadding: null, // `<table>` cellSpacing: null, // `<table>` char: null, // Several table elements. When `align=char`, sets the character to align on charOff: null, // Several table elements. When `char`, offsets the alignment classId: null, // `<object>` clear: null, // `<br>`. Use CSS `clear` instead code: null, // `<object>` codeBase: null, // `<object>` codeType: null, // `<object>` color: null, // `<font>` and `<hr>`. Use CSS instead compact: B, // Lists. Use CSS to reduce space between items instead declare: B, // `<object>` event: null, // `<script>` face: null, // `<font>`. Use CSS instead frame: null, // `<table>` frameBorder: null, // `<iframe>`. Use CSS `border` instead hSpace: v, // `<img>` and `<object>` leftMargin: v, // `<body>` link: null, // `<body>`. Use CSS `a:link {color: *}` instead longDesc: null, // `<frame>`, `<iframe>`, and `<img>`. Use an `<a>` lowSrc: null, // `<img>`. Use a `<picture>` marginHeight: v, // `<body>` marginWidth: v, // `<body>` noResize: B, // `<frame>` noHref: B, // `<area>`. Use no href instead of an explicit `nohref` noShade: B, // `<hr>`. Use background-color and height instead of borders noWrap: B, // `<td>` and `<th>` object: null, // `<applet>` profile: null, // `<head>` prompt: null, // `<isindex>` rev: null, // `<link>` rightMargin: v, // `<body>` rules: null, // `<table>` scheme: null, // `<meta>` scrolling: ee, // `<frame>`. Use overflow in the child context standby: null, // `<object>` summary: null, // `<table>` text: null, // `<body>`. Use CSS `color` instead topMargin: v, // `<body>` valueType: null, // `<param>` version: null, // `<html>`. Use a doctype. vAlign: null, // Several. Use CSS `vertical-align` instead vLink: null, // `<body>`. Use CSS `a:visited {color}` instead vSpace: v, // `<img>` and `<object>` // Non-standard Properties. allowTransparency: null, autoCorrect: null, autoSave: null, disablePictureInPicture: B, disableRemotePlayback: B, prefix: null, property: null, results: v, security: null, unselectable: null }, space: "html", transform: mr }), ji = Me({ attributes: { accentHeight: "accent-height", alignmentBaseline: "alignment-baseline", arabicForm: "arabic-form", baselineShift: "baseline-shift", capHeight: "cap-height", className: "class", clipPath: "clip-path", clipRule: "clip-rule", colorInterpolation: "color-interpolation", colorInterpolationFilters: "color-interpolation-filters", colorProfile: "color-profile", colorRendering: "color-rendering", crossOrigin: "crossorigin", dataType: "datatype", dominantBaseline: "dominant-baseline", enableBackground: "enable-background", fillOpacity: "fill-opacity", fillRule: "fill-rule", floodColor: "flood-color", floodOpacity: "flood-opacity", fontFamily: "font-family", fontSize: "font-size", fontSizeAdjust: "font-size-adjust", fontStretch: "font-stretch", fontStyle: "font-style", fontVariant: "font-variant", fontWeight: "font-weight", glyphName: "glyph-name", glyphOrientationHorizontal: "glyph-orientation-horizontal", glyphOrientationVertical: "glyph-orientation-vertical", hrefLang: "hreflang", horizAdvX: "horiz-adv-x", horizOriginX: "horiz-origin-x", horizOriginY: "horiz-origin-y", imageRendering: "image-rendering", letterSpacing: "letter-spacing", lightingColor: "lighting-color", markerEnd: "marker-end", markerMid: "marker-mid", markerStart: "marker-start", navDown: "nav-down", navDownLeft: "nav-down-left", navDownRight: "nav-down-right", navLeft: "nav-left", navNext: "nav-next", navPrev: "nav-prev", navRight: "nav-right", navUp: "nav-up", navUpLeft: "nav-up-left", navUpRight: "nav-up-right", onAbort: "onabort", onActivate: "onactivate", onAfterPrint: "onafterprint", onBeforePrint: "onbeforeprint", onBegin: "onbegin", onCancel: "oncancel", onCanPlay: "oncanplay", onCanPlayThrough: "oncanplaythrough", onChange: "onchange", onClick: "onclick", onClose: "onclose", onCopy: "oncopy", onCueChange: "oncuechange", onCut: "oncut", onDblClick: "ondblclick", onDrag: "ondrag", onDragEnd: "ondragend", onDragEnter: "ondragenter", onDragExit: "ondragexit", onDragLeave: "ondragleave", onDragOver: "ondragover", onDragStart: "ondragstart", onDrop: "ondrop", onDurationChange: "ondurationchange", onEmptied: "onemptied", onEnd: "onend", onEnded: "onended", onError: "onerror", onFocus: "onfocus", onFocusIn: "onfocusin", onFocusOut: "onfocusout", onHashChange: "onhashchange", onInput: "oninput", onInvalid: "oninvalid", onKeyDown: "onkeydown", onKeyPress: "onkeypress", onKeyUp: "onkeyup", onLoad: "onload", onLoadedData: "onloadeddata", onLoadedMetadata: "onloadedmetadata", onLoadStart: "onloadstart", onMessage: "onmessage", onMouseDown: "onmousedown", onMouseEnter: "onmouseenter", onMouseLeave: "onmouseleave", onMouseMove: "onmousemove", onMouseOut: "onmouseout", onMouseOver: "onmouseover", onMouseUp: "onmouseup", onMouseWheel: "onmousewheel", onOffline: "onoffline", onOnline: "ononline", onPageHide: "onpagehide", onPageShow: "onpageshow", onPaste: "onpaste", onPause: "onpause", onPlay: "onplay", onPlaying: "onplaying", onPopState: "onpopstate", onProgress: "onprogress", onRateChange: "onratechange", onRepeat: "onrepeat", onReset: "onreset", onResize: "onresize", onScroll: "onscroll", onSeeked: "onseeked", onSeeking: "onseeking", onSelect: "onselect", onShow: "onshow", onStalled: "onstalled", onStorage: "onstorage", onSubmit: "onsubmit", onSuspend: "onsuspend", onTimeUpdate: "ontimeupdate", onToggle: "ontoggle", onUnload: "onunload", onVolumeChange: "onvolumechange", onWaiting: "onwaiting", onZoom: "onzoom", overlinePosition: "overline-position", overlineThickness: "overline-thickness", paintOrder: "paint-order", panose1: "panose-1", pointerEvents: "pointer-events", referrerPolicy: "referrerpolicy", renderingIntent: "rendering-intent", shapeRendering: "shape-rendering", stopColor: "stop-color", stopOpacity: "stop-opacity", strikethroughPosition: "strikethrough-position", strikethroughThickness: "strikethrough-thickness", strokeDashArray: "stroke-dasharray", strokeDashOffset: "stroke-dashoffset", strokeLineCap: "stroke-linecap", strokeLineJoin: "stroke-linejoin", strokeMiterLimit: "stroke-miterlimit", strokeOpacity: "stroke-opacity", strokeWidth: "stroke-width", tabIndex: "tabindex", textAnchor: "text-anchor", textDecoration: "text-decoration", textRendering: "text-rendering", transformOrigin: "transform-origin", typeOf: "typeof", underlinePosition: "underline-position", underlineThickness: "underline-thickness", unicodeBidi: "unicode-bidi", unicodeRange: "unicode-range", unitsPerEm: "units-per-em", vAlphabetic: "v-alphabetic", vHanging: "v-hanging", vIdeographic: "v-ideographic", vMathematical: "v-mathematical", vectorEffect: "vector-effect", vertAdvY: "vert-adv-y", vertOriginX: "vert-origin-x", vertOriginY: "vert-origin-y", wordSpacing: "word-spacing", writingMode: "writing-mode", xHeight: "x-height", // These were camelcased in Tiny. Now lowercased in SVG 2 playbackOrder: "playbackorder", timelineBegin: "timelinebegin" }, properties: { about: ce, accentHeight: v, accumulate: null, additive: null, alignmentBaseline: null, alphabetic: v, amplitude: v, arabicForm: null, ascent: v, attributeName: null, attributeType: null, azimuth: v, bandwidth: null, baselineShift: null, baseFrequency: null, baseProfile: null, bbox: null, begin: null, bias: v, by: null, calcMode: null, capHeight: v, className: X, clip: null, clipPath: null, clipPathUnits: null, clipRule: null, color: null, colorInterpolation: null, colorInterpolationFilters: null, colorProfile: null, colorRendering: null, content: null, contentScriptType: null, contentStyleType: null, crossOrigin: null, cursor: null, cx: null, cy: null, d: null, dataType: null, defaultAction: null, descent: v, diffuseConstant: v, direction: null, display: null, dur: null, divisor: v, dominantBaseline: null, download: B, dx: null, dy: null, edgeMode: null, editable: null, elevation: v, enableBackground: null, end: null, event: null, exponent: v, externalResourcesRequired: null, fill: null, fillOpacity: v, fillRule: null, filter: null, filterRes: null, filterUnits: null, floodColor: null, floodOpacity: null, focusable: null, focusHighlight: null, fontFamily: null, fontSize: null, fontSizeAdjust: null, fontStretch: null, fontStyle: null, fontVariant: null, fontWeight: null, format: null, fr: null, from: null, fx: null, fy: null, g1: Oe, g2: Oe, glyphName: Oe, glyphOrientationHorizontal: null, glyphOrientationVertical: null, glyphRef: null, gradientTransform: null, gradientUnits: null, handler: null, hanging: v, hatchContentUnits: null, hatchUnits: null, height: null, href: null, hrefLang: null, horizAdvX: v, horizOriginX: v, horizOriginY: v, id: null, ideographic: v, imageRendering: null, initialVisibility: null, in: null, in2: null, intercept: v, k: v, k1: v, k2: v, k3: v, k4: v, kernelMatrix: ce, kernelUnitLength: null, keyPoints: null, // SEMI_COLON_SEPARATED keySplines: null, // SEMI_COLON_SEPARATED keyTimes: null, // SEMI_COLON_SEPARATED kerning: null, lang: null, lengthAdjust: null, letterSpacing: null, lightingColor: null, limitingConeAngle: v, local: null, markerEnd: null, markerMid: null, markerStart: null, markerHeight: null, markerUnits: null, markerWidth: null, mask: null, maskContentUnits: null, maskUnits: null, mathematical: null, max: null, media: null, mediaCharacterEncoding: null, mediaContentEncodings: null, mediaSize: v, mediaTime: null, method: null, min: null, mode: null, name: null, navDown: null, navDownLeft: null, navDownRight: null, navLeft: null, navNext: null, navPrev: null, navRight: null, navUp: null, navUpLeft: null, navUpRight: null, numOctaves: null, observer: null, offset: null, onAbort: null, onActivate: null, onAfterPrint: null, onBeforePrint: null, onBegin: null, onCancel: null, onCanPlay: null, onCanPlayThrough: null, onChange: null, onClick: null, onClose: null, onCopy: null, onCueChange: null, onCut: null, onDblClick: null, onDrag: null, onDragEnd: null, onDragEnter: null, onDragExit: null, onDragLeave: null, onDragOver: null, onDragStart: null, onDrop: null, onDurationChange: null, onEmptied: null, onEnd: null, onEnded: null, onError: null, onFocus: null, onFocusIn: null, onFocusOut: null, onHashChange: null, onInput: null, onInvalid: null, onKeyDown: null, onKeyPress: null, onKeyUp: null, onLoad: null, onLoadedData: null, onLoadedMetadata: null, onLoadStart: null, onMessage: null, onMouseDown: null, onMouseEnter: null, onMouseLeave: null, onMouseMove: null, onMouseOut: null, onMouseOver: null, onMouseUp: null, onMouseWheel: null, onOffline: null, onOnline: null, onPageHide: null, onPageShow: null, onPaste: null, onPause: null, onPlay: null, onPlaying: null, onPopState: null, onProgress: null, onRateChange: null, onRepeat: null, onReset: null, onResize: null, onScroll: null, onSeeked: null, onSeeking: null, onSelect: null, onShow: null, onStalled: null, onStorage: null, onSubmit: null, onSuspend: null, onTimeUpdate: null, onToggle: null, onUnload: null, onVolumeChange: null, onWaiting: null, onZoom: null, opacity: null, operator: null, order: null, orient: null, orientation: null, origin: null, overflow: null, overlay: null, overlinePosition: v, overlineThickness: v, paintOrder: null, panose1: null, path: null, pathLength: v, patternContentUnits: null, patternTransform: null, patternUnits: null, phase: null, ping: X, pitch: null, playbackOrder: null, pointerEvents: null, points: null, pointsAtX: v, pointsAtY: v, pointsAtZ: v, preserveAlpha: null, preserveAspectRatio: null, primitiveUnits: null, propagate: null, property: ce, r: null, radius: null, referrerPolicy: null, refX: null, refY: null, rel: ce, rev: ce, renderingIntent: null, repeatCount: null, repeatDur: null, requiredExtensions: ce, requiredFeatures: ce, requiredFonts: ce, requiredFormats: ce, resource: null, restart: null, result: null, rotate: null, rx: null, ry: null, scale: null, seed: null, shapeRendering: null, side: null, slope: null, snapshotTime: null, specularConstant: v, specularExponent: v, spreadMethod: null, spacing: null, startOffset: null, stdDeviation: null, stemh: null, stemv: null, stitchTiles: null, stopColor: null, stopOpacity: null, strikethroughPosition: v, strikethroughThickness: v, string: null, stroke: null, strokeDashArray: ce, strokeDashOffset: null, strokeLineCap: null, strokeLineJoin: null, strokeMiterLimit: v, strokeOpacity: v, strokeWidth: null, style: null, surfaceScale: v, syncBehavior: null, syncBehaviorDefault: null, syncMaster: null, syncTolerance: null, syncToleranceDefault: null, systemLanguage: ce, tabIndex: v, tableValues: null, target: null, targetX: v, targetY: v, textAnchor: null, textDecoration: null, textRendering: null, textLength: null, timelineBegin: null, title: null, transformBehavior: null, type: null, typeOf: ce, to: null, transform: null, transformOrigin: null, u1: null, u2: null, underlinePosition: v, underlineThickness: v, unicode: null, unicodeBidi: null, unicodeRange: null, unitsPerEm: v, values: null, vAlphabetic: v, vMathematical: v, vectorEffect: null, vHanging: v, vIdeographic: v, version: null, vertAdvY: v, vertOriginX: v, vertOriginY: v, viewBox: null, viewTarget: null, visibility: null, width: null, widths: null, wordSpacing: null, writingMode: null, x: null, x1: null, x2: null, xChannelSelector: null, xHeight: v, y: null, y1: null, y2: null, yChannelSelector: null, z: null, zoomAndPan: null }, space: "svg", transform: pr }), dr = Me({ properties: { xLinkActuate: null, xLinkArcRole: null, xLinkHref: null, xLinkRole: null, xLinkShow: null, xLinkTitle: null, xLinkType: null }, space: "xlink", transform(e, n) { return "xlink:" + n.slice(5).toLowerCase(); } }), gr = Me({ attributes: { xmlnsxlink: "xmlns:xlink" }, properties: { xmlnsXLink: null, xmlns: null }, space: "xmlns", transform: mr }), xr = Me({ properties: { xmlBase: null, xmlLang: null, xmlSpace: null }, space: "xml", transform(e, n) { return "xml:" + n.slice(3).toLowerCase(); } }), Bi = { classId: "classID", dataType: "datatype", itemId: "itemID", strokeDashArray: "strokeDasharray", strokeDashOffset: "strokeDashoffset", strokeLineCap: "strokeLinecap", strokeLineJoin: "strokeLinejoin", strokeMiterLimit: "strokeMiterlimit", typeOf: "typeof", xLinkActuate: "xlinkActuate", xLinkArcRole: "xlinkArcrole", xLinkHref: "xlinkHref", xLinkRole: "xlinkRole", xLinkShow: "xlinkShow", xLinkTitle: "xlinkTitle", xLinkType: "xlinkType", xmlnsXLink: "xmlnsXlink" }, $i = /[A-Z]/g, Sn = /-[a-z]/g, qi = /^data[-\w.:]+$/i; function Ui(e, n) { const t = Ot(n); let r = n, l = ae; if (t in e.normal) return e.property[e.normal[t]]; if (t.length > 4 && t.slice(0, 4) === "data" && qi.test(n)) { if (n.charAt(4) === "-") { const o = n.slice(5).replace(Sn, Vi); r = "data" + o.charAt(0).toUpperCase() + o.slice(1); } else { const o = n.slice(4); if (!Sn.test(o)) { let i = o.replace($i, Hi); i.charAt(0) !== "-" && (i = "-" + i), n = "data" + i; } } l = Yt; } return new l(r, n); } function Hi(e) { return "-" + e.toLowerCase(); } function Vi(e) { return e.charAt(1).toUpperCase(); } const Wi = fr([hr, Mi, dr, gr, xr], "html"), Xt = fr([hr, ji, dr, gr, xr], "svg"); function Yi(e) { return e.join(" ").trim(); } var Re = {}, bt, En; function Xi() { if (En) return bt; En = 1; var e = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g, n = /\n/g, t = /^\s*/, r = /^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/, l = /^:\s*/, o = /^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/, i = /^[;\s]*/, a = /^\s+|\s+$/g, s = ` `, u = "/", f = "*", c = "", m = "comment", h = "declaration"; bt = function(k, E) { if (typeof k != "string") throw new TypeError("First argument must be a string"); if (!k) return []; E = E || {}; var x = 1, S = 1; function C(z) { var P = z.match(n); P && (x += P.length); var M = z.lastIndexOf(s); S = ~M ? z.length - M : S + z.length; } function A() { var z = { line: x, column: S }; return function(P) { return P.position = new D(z), F(), P; }; } function D(z) { this.start = z, this.end = { line: x, column: S }, this.source = E.source; } D.prototype.content = k; function y(z) { var P = new Error( E.source + ":" + x + ":" + S + ": " + z ); if (P.reason = z, P.filename = E.source, P.line = x, P.column = S, P.source = k, !E.silent) throw P; } function _(z) { var P = z.exec(k); if (P) { var M = P[0]; return C(M), k = k.slice(M.length), P; } } function F() { _(t); } function U(z) { var P; for (z = z || []; P = b(); ) P !== !1 && z.push(P); return z; } function b() { var z = A(); if (!(u != k.charAt(0) || f != k.charAt(1))) { for (var P = 2; c != k.charAt(P) && (f != k.charAt(P) || u != k.charAt(P + 1)); ) ++P; if (P += 2, c === k.charAt(P - 1)) return y("End of comment missing"); var M = k.slice(2, P - 2); return S += 2, C(M), k = k.slice(P), S += 2, z({ type: m, comment: M }); } } function R() { var z = A(), P = _(r); if (P) { if (b(), !_(l)) return y("property missing ':'"); var M = _(o), K = z({ type: h, property: g(P[0].replace(e, c)), value: M ? g(M[0].replace(e, c)) : c }); return _(i), K; } } function L() { var z = []; U(z); for (var P; P = R(); ) P !== !1 && (z.push(P), U(z)); return z; } return F(), L(); }; function g(k) { return k ? k.replace(a, c) : c; } return bt; } var vn; function Qi() { if (vn) return Re; vn = 1; var e = Re && Re.__importDefault || function(r) { return r && r.__esModule ? r : { default: r }; }; Object.defineProperty(Re, "__esModule", { value: !0 }), Re.default = t; var n = e(Xi()); function t(r, l) { var o = null; if (!r || typeof r != "string") return o; var i = (0, n.default)(r), a = typeof l == "function"; return i.forEach(function(s) { if (s.type === "declaration") { var u = s.property, f = s.value; a ? l(u, f, s) : f && (o = o || {}, o[u] = f); } }), o; } return Re; } var He = {}, In; function Ki() { if (In) return He; In = 1, Object.defineProperty(He, "__esModule", { value: !0 }), He.camelCase = void 0; var e = /^--[a-zA-Z0-9_-]+$/, n = /-([a-z])/g, t = /^[^-]+$/, r = /^-(webkit|moz|ms|o|khtml)-/, l = /^-(ms)-/, o = function(u) { return !u || t.test(u) || e.test(u); }, i = function(u, f) { return f.toUpperCase(); }, a = function(u, f) { return "".concat(f, "-"); }, s = function(u, f) { return f === void 0 && (f = {}), o(u) ? u : (u = u.toLowerCase(), f.reactCompat ? u = u.replace(l, a) : u = u.replace(r, a), u.replace(n, i)); }; return He.camelCase = s, He; } var Ve, Tn; function Gi() { if (Tn) return Ve; Tn = 1; var e = Ve && Ve.__importDefault || function(l) { return l && l.__esModule ? l : { default: l }; }, n = e(Qi()), t = Ki(); function r(l, o) { var i = {}; return !l || typeof l != "string" || (0, n.default)(l, function(a, s) { a && s && (i[(0, t.camelCase)(a, o)] = s); }), i; } return r.default = r, Ve = r, Ve; } var Ji = Gi(); const Zi = /* @__PURE__ */ ur(Ji), yr = kr("end"), Qt = kr("start"); function kr(e) { return n; function n(t) { const r = t && t.position && t.position[e] || {}; if (typeof r.line == "number" && r.line > 0 && typeof r.column == "number" && r.column > 0) return { line: r.line, column: r.