jvcgpt / dist /assets /index-NR4DZ1UN.js
Greums's picture
fix the slider
63e28ac
raw
history blame
52.9 kB
(function polyfill() {
const relList = document.createElement("link").relList;
if (relList && relList.supports && relList.supports("modulepreload")) {
return;
}
for (const link of document.querySelectorAll('link[rel="modulepreload"]')) {
processPreload(link);
}
new MutationObserver((mutations) => {
for (const mutation of mutations) {
if (mutation.type !== "childList") {
continue;
}
for (const node of mutation.addedNodes) {
if (node.tagName === "LINK" && node.rel === "modulepreload")
processPreload(node);
}
}
}).observe(document, { childList: true, subtree: true });
function getFetchOpts(link) {
const fetchOpts = {};
if (link.integrity) fetchOpts.integrity = link.integrity;
if (link.referrerPolicy) fetchOpts.referrerPolicy = link.referrerPolicy;
if (link.crossOrigin === "use-credentials")
fetchOpts.credentials = "include";
else if (link.crossOrigin === "anonymous") fetchOpts.credentials = "omit";
else fetchOpts.credentials = "same-origin";
return fetchOpts;
}
function processPreload(link) {
if (link.ep)
return;
link.ep = true;
const fetchOpts = getFetchOpts(link);
fetch(link.href, fetchOpts);
}
})();
var n, l$1, u$2, i$1, r$1, o$1, e$1, f$2, c$1, s$1, a$1, p$1 = {}, v$1 = [], y$1 = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, d$1 = Array.isArray;
function w$1(n2, l2) {
for (var u2 in l2) n2[u2] = l2[u2];
return n2;
}
function _(n2) {
n2 && n2.parentNode && n2.parentNode.removeChild(n2);
}
function g(l2, u2, t2) {
var i2, r2, o2, e2 = {};
for (o2 in u2) "key" == o2 ? i2 = u2[o2] : "ref" == o2 ? r2 = u2[o2] : e2[o2] = u2[o2];
if (arguments.length > 2 && (e2.children = arguments.length > 3 ? n.call(arguments, 2) : t2), "function" == typeof l2 && null != l2.defaultProps) for (o2 in l2.defaultProps) void 0 === e2[o2] && (e2[o2] = l2.defaultProps[o2]);
return m$1(l2, e2, i2, r2, null);
}
function m$1(n2, t2, i2, r2, o2) {
var e2 = { type: n2, props: t2, key: i2, ref: r2, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: null == o2 ? ++u$2 : o2, __i: -1, __u: 0 };
return null == o2 && null != l$1.vnode && l$1.vnode(e2), e2;
}
function k$1(n2) {
return n2.children;
}
function x(n2, l2) {
this.props = n2, this.context = l2;
}
function C$1(n2, l2) {
if (null == l2) return n2.__ ? C$1(n2.__, n2.__i + 1) : null;
for (var u2; l2 < n2.__k.length; l2++) if (null != (u2 = n2.__k[l2]) && null != u2.__e) return u2.__e;
return "function" == typeof n2.type ? C$1(n2) : null;
}
function S(n2) {
var l2, u2;
if (null != (n2 = n2.__) && null != n2.__c) {
for (n2.__e = n2.__c.base = null, l2 = 0; l2 < n2.__k.length; l2++) if (null != (u2 = n2.__k[l2]) && null != u2.__e) {
n2.__e = n2.__c.base = u2.__e;
break;
}
return S(n2);
}
}
function M(n2) {
(!n2.__d && (n2.__d = true) && i$1.push(n2) && !P.__r++ || r$1 !== l$1.debounceRendering) && ((r$1 = l$1.debounceRendering) || o$1)(P);
}
function P() {
var n2, u2, t2, r2, o2, f2, c2, s2;
for (i$1.sort(e$1); n2 = i$1.shift(); ) n2.__d && (u2 = i$1.length, r2 = void 0, f2 = (o2 = (t2 = n2).__v).__e, c2 = [], s2 = [], t2.__P && ((r2 = w$1({}, o2)).__v = o2.__v + 1, l$1.vnode && l$1.vnode(r2), j$1(t2.__P, r2, o2, t2.__n, t2.__P.namespaceURI, 32 & o2.__u ? [f2] : null, c2, null == f2 ? C$1(o2) : f2, !!(32 & o2.__u), s2), r2.__v = o2.__v, r2.__.__k[r2.__i] = r2, z$1(c2, r2, s2), r2.__e != f2 && S(r2)), i$1.length > u2 && i$1.sort(e$1));
P.__r = 0;
}
function $(n2, l2, u2, t2, i2, r2, o2, e2, f2, c2, s2) {
var a2, h2, y2, d2, w2, _2, g2 = t2 && t2.__k || v$1, m2 = l2.length;
for (f2 = I(u2, l2, g2, f2, m2), a2 = 0; a2 < m2; a2++) null != (y2 = u2.__k[a2]) && (h2 = -1 === y2.__i ? p$1 : g2[y2.__i] || p$1, y2.__i = a2, _2 = j$1(n2, y2, h2, i2, r2, o2, e2, f2, c2, s2), d2 = y2.__e, y2.ref && h2.ref != y2.ref && (h2.ref && V(h2.ref, null, y2), s2.push(y2.ref, y2.__c || d2, y2)), null == w2 && null != d2 && (w2 = d2), 4 & y2.__u || h2.__k === y2.__k ? f2 = A(y2, f2, n2) : "function" == typeof y2.type && void 0 !== _2 ? f2 = _2 : d2 && (f2 = d2.nextSibling), y2.__u &= -7);
return u2.__e = w2, f2;
}
function I(n2, l2, u2, t2, i2) {
var r2, o2, e2, f2, c2, s2 = u2.length, a2 = s2, h2 = 0;
for (n2.__k = new Array(i2), r2 = 0; r2 < i2; r2++) null != (o2 = l2[r2]) && "boolean" != typeof o2 && "function" != typeof o2 ? (f2 = r2 + h2, (o2 = n2.__k[r2] = "string" == typeof o2 || "number" == typeof o2 || "bigint" == typeof o2 || o2.constructor == String ? m$1(null, o2, null, null, null) : d$1(o2) ? m$1(k$1, { children: o2 }, null, null, null) : void 0 === o2.constructor && o2.__b > 0 ? m$1(o2.type, o2.props, o2.key, o2.ref ? o2.ref : null, o2.__v) : o2).__ = n2, o2.__b = n2.__b + 1, e2 = null, -1 !== (c2 = o2.__i = L(o2, u2, f2, a2)) && (a2--, (e2 = u2[c2]) && (e2.__u |= 2)), null == e2 || null === e2.__v ? (-1 == c2 && h2--, "function" != typeof o2.type && (o2.__u |= 4)) : c2 != f2 && (c2 == f2 - 1 ? h2-- : c2 == f2 + 1 ? h2++ : (c2 > f2 ? h2-- : h2++, o2.__u |= 4))) : n2.__k[r2] = null;
if (a2) for (r2 = 0; r2 < s2; r2++) null != (e2 = u2[r2]) && 0 == (2 & e2.__u) && (e2.__e == t2 && (t2 = C$1(e2)), q$1(e2, e2));
return t2;
}
function A(n2, l2, u2) {
var t2, i2;
if ("function" == typeof n2.type) {
for (t2 = n2.__k, i2 = 0; t2 && i2 < t2.length; i2++) t2[i2] && (t2[i2].__ = n2, l2 = A(t2[i2], l2, u2));
return l2;
}
n2.__e != l2 && (l2 && n2.type && !u2.contains(l2) && (l2 = C$1(n2)), u2.insertBefore(n2.__e, l2 || null), l2 = n2.__e);
do {
l2 = l2 && l2.nextSibling;
} while (null != l2 && 8 == l2.nodeType);
return l2;
}
function L(n2, l2, u2, t2) {
var i2, r2, o2 = n2.key, e2 = n2.type, f2 = l2[u2];
if (null === f2 || f2 && o2 == f2.key && e2 === f2.type && 0 == (2 & f2.__u)) return u2;
if (t2 > (null != f2 && 0 == (2 & f2.__u) ? 1 : 0)) for (i2 = u2 - 1, r2 = u2 + 1; i2 >= 0 || r2 < l2.length; ) {
if (i2 >= 0) {
if ((f2 = l2[i2]) && 0 == (2 & f2.__u) && o2 == f2.key && e2 === f2.type) return i2;
i2--;
}
if (r2 < l2.length) {
if ((f2 = l2[r2]) && 0 == (2 & f2.__u) && o2 == f2.key && e2 === f2.type) return r2;
r2++;
}
}
return -1;
}
function T$1(n2, l2, u2) {
"-" == l2[0] ? n2.setProperty(l2, null == u2 ? "" : u2) : n2[l2] = null == u2 ? "" : "number" != typeof u2 || y$1.test(l2) ? u2 : u2 + "px";
}
function F(n2, l2, u2, t2, i2) {
var r2;
n: if ("style" == l2) if ("string" == typeof u2) n2.style.cssText = u2;
else {
if ("string" == typeof t2 && (n2.style.cssText = t2 = ""), t2) for (l2 in t2) u2 && l2 in u2 || T$1(n2.style, l2, "");
if (u2) for (l2 in u2) t2 && u2[l2] === t2[l2] || T$1(n2.style, l2, u2[l2]);
}
else if ("o" == l2[0] && "n" == l2[1]) r2 = l2 != (l2 = l2.replace(f$2, "$1")), l2 = l2.toLowerCase() in n2 || "onFocusOut" == l2 || "onFocusIn" == l2 ? l2.toLowerCase().slice(2) : l2.slice(2), n2.l || (n2.l = {}), n2.l[l2 + r2] = u2, u2 ? t2 ? u2.u = t2.u : (u2.u = c$1, n2.addEventListener(l2, r2 ? a$1 : s$1, r2)) : n2.removeEventListener(l2, r2 ? a$1 : s$1, r2);
else {
if ("http://www.w3.org/2000/svg" == i2) l2 = l2.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
else if ("width" != l2 && "height" != l2 && "href" != l2 && "list" != l2 && "form" != l2 && "tabIndex" != l2 && "download" != l2 && "rowSpan" != l2 && "colSpan" != l2 && "role" != l2 && "popover" != l2 && l2 in n2) try {
n2[l2] = null == u2 ? "" : u2;
break n;
} catch (n3) {
}
"function" == typeof u2 || (null == u2 || false === u2 && "-" != l2[4] ? n2.removeAttribute(l2) : n2.setAttribute(l2, "popover" == l2 && 1 == u2 ? "" : u2));
}
}
function O(n2) {
return function(u2) {
if (this.l) {
var t2 = this.l[u2.type + n2];
if (null == u2.t) u2.t = c$1++;
else if (u2.t < t2.u) return;
return t2(l$1.event ? l$1.event(u2) : u2);
}
};
}
function j$1(n2, u2, t2, i2, r2, o2, e2, f2, c2, s2) {
var a2, h2, p2, v2, y2, g2, m2, b, C2, S2, M2, P2, I2, A2, H, L2, T2, F2 = u2.type;
if (void 0 !== u2.constructor) return null;
128 & t2.__u && (c2 = !!(32 & t2.__u), o2 = [f2 = u2.__e = t2.__e]), (a2 = l$1.__b) && a2(u2);
n: if ("function" == typeof F2) try {
if (b = u2.props, C2 = "prototype" in F2 && F2.prototype.render, S2 = (a2 = F2.contextType) && i2[a2.__c], M2 = a2 ? S2 ? S2.props.value : a2.__ : i2, t2.__c ? m2 = (h2 = u2.__c = t2.__c).__ = h2.__E : (C2 ? u2.__c = h2 = new F2(b, M2) : (u2.__c = h2 = new x(b, M2), h2.constructor = F2, h2.render = B$1), S2 && S2.sub(h2), h2.props = b, h2.state || (h2.state = {}), h2.context = M2, h2.__n = i2, p2 = h2.__d = true, h2.__h = [], h2._sb = []), C2 && null == h2.__s && (h2.__s = h2.state), C2 && null != F2.getDerivedStateFromProps && (h2.__s == h2.state && (h2.__s = w$1({}, h2.__s)), w$1(h2.__s, F2.getDerivedStateFromProps(b, h2.__s))), v2 = h2.props, y2 = h2.state, h2.__v = u2, p2) C2 && null == F2.getDerivedStateFromProps && null != h2.componentWillMount && h2.componentWillMount(), C2 && null != h2.componentDidMount && h2.__h.push(h2.componentDidMount);
else {
if (C2 && null == F2.getDerivedStateFromProps && b !== v2 && null != h2.componentWillReceiveProps && h2.componentWillReceiveProps(b, M2), !h2.__e && (null != h2.shouldComponentUpdate && false === h2.shouldComponentUpdate(b, h2.__s, M2) || u2.__v == t2.__v)) {
for (u2.__v != t2.__v && (h2.props = b, h2.state = h2.__s, h2.__d = false), u2.__e = t2.__e, u2.__k = t2.__k, u2.__k.some(function(n3) {
n3 && (n3.__ = u2);
}), P2 = 0; P2 < h2._sb.length; P2++) h2.__h.push(h2._sb[P2]);
h2._sb = [], h2.__h.length && e2.push(h2);
break n;
}
null != h2.componentWillUpdate && h2.componentWillUpdate(b, h2.__s, M2), C2 && null != h2.componentDidUpdate && h2.__h.push(function() {
h2.componentDidUpdate(v2, y2, g2);
});
}
if (h2.context = M2, h2.props = b, h2.__P = n2, h2.__e = false, I2 = l$1.__r, A2 = 0, C2) {
for (h2.state = h2.__s, h2.__d = false, I2 && I2(u2), a2 = h2.render(h2.props, h2.state, h2.context), H = 0; H < h2._sb.length; H++) h2.__h.push(h2._sb[H]);
h2._sb = [];
} else do {
h2.__d = false, I2 && I2(u2), a2 = h2.render(h2.props, h2.state, h2.context), h2.state = h2.__s;
} while (h2.__d && ++A2 < 25);
h2.state = h2.__s, null != h2.getChildContext && (i2 = w$1(w$1({}, i2), h2.getChildContext())), C2 && !p2 && null != h2.getSnapshotBeforeUpdate && (g2 = h2.getSnapshotBeforeUpdate(v2, y2)), f2 = $(n2, d$1(L2 = null != a2 && a2.type === k$1 && null == a2.key ? a2.props.children : a2) ? L2 : [L2], u2, t2, i2, r2, o2, e2, f2, c2, s2), h2.base = u2.__e, u2.__u &= -161, h2.__h.length && e2.push(h2), m2 && (h2.__E = h2.__ = null);
} catch (n3) {
if (u2.__v = null, c2 || null != o2) if (n3.then) {
for (u2.__u |= c2 ? 160 : 128; f2 && 8 == f2.nodeType && f2.nextSibling; ) f2 = f2.nextSibling;
o2[o2.indexOf(f2)] = null, u2.__e = f2;
} else for (T2 = o2.length; T2--; ) _(o2[T2]);
else u2.__e = t2.__e, u2.__k = t2.__k;
l$1.__e(n3, u2, t2);
}
else null == o2 && u2.__v == t2.__v ? (u2.__k = t2.__k, u2.__e = t2.__e) : f2 = u2.__e = N(t2.__e, u2, t2, i2, r2, o2, e2, c2, s2);
return (a2 = l$1.diffed) && a2(u2), 128 & u2.__u ? void 0 : f2;
}
function z$1(n2, u2, t2) {
for (var i2 = 0; i2 < t2.length; i2++) V(t2[i2], t2[++i2], t2[++i2]);
l$1.__c && l$1.__c(u2, n2), n2.some(function(u3) {
try {
n2 = u3.__h, u3.__h = [], n2.some(function(n3) {
n3.call(u3);
});
} catch (n3) {
l$1.__e(n3, u3.__v);
}
});
}
function N(u2, t2, i2, r2, o2, e2, f2, c2, s2) {
var a2, h2, v2, y2, w2, g2, m2, b = i2.props, k2 = t2.props, x2 = t2.type;
if ("svg" == x2 ? o2 = "http://www.w3.org/2000/svg" : "math" == x2 ? o2 = "http://www.w3.org/1998/Math/MathML" : o2 || (o2 = "http://www.w3.org/1999/xhtml"), null != e2) {
for (a2 = 0; a2 < e2.length; a2++) if ((w2 = e2[a2]) && "setAttribute" in w2 == !!x2 && (x2 ? w2.localName == x2 : 3 == w2.nodeType)) {
u2 = w2, e2[a2] = null;
break;
}
}
if (null == u2) {
if (null == x2) return document.createTextNode(k2);
u2 = document.createElementNS(o2, x2, k2.is && k2), c2 && (l$1.__m && l$1.__m(t2, e2), c2 = false), e2 = null;
}
if (null === x2) b === k2 || c2 && u2.data === k2 || (u2.data = k2);
else {
if (e2 = e2 && n.call(u2.childNodes), b = i2.props || p$1, !c2 && null != e2) for (b = {}, a2 = 0; a2 < u2.attributes.length; a2++) b[(w2 = u2.attributes[a2]).name] = w2.value;
for (a2 in b) if (w2 = b[a2], "children" == a2) ;
else if ("dangerouslySetInnerHTML" == a2) v2 = w2;
else if (!(a2 in k2)) {
if ("value" == a2 && "defaultValue" in k2 || "checked" == a2 && "defaultChecked" in k2) continue;
F(u2, a2, null, w2, o2);
}
for (a2 in k2) w2 = k2[a2], "children" == a2 ? y2 = w2 : "dangerouslySetInnerHTML" == a2 ? h2 = w2 : "value" == a2 ? g2 = w2 : "checked" == a2 ? m2 = w2 : c2 && "function" != typeof w2 || b[a2] === w2 || F(u2, a2, w2, b[a2], o2);
if (h2) c2 || v2 && (h2.__html === v2.__html || h2.__html === u2.innerHTML) || (u2.innerHTML = h2.__html), t2.__k = [];
else if (v2 && (u2.innerHTML = ""), $(u2, d$1(y2) ? y2 : [y2], t2, i2, r2, "foreignObject" == x2 ? "http://www.w3.org/1999/xhtml" : o2, e2, f2, e2 ? e2[0] : i2.__k && C$1(i2, 0), c2, s2), null != e2) for (a2 = e2.length; a2--; ) _(e2[a2]);
c2 || (a2 = "value", "progress" == x2 && null == g2 ? u2.removeAttribute("value") : void 0 !== g2 && (g2 !== u2[a2] || "progress" == x2 && !g2 || "option" == x2 && g2 !== b[a2]) && F(u2, a2, g2, b[a2], o2), a2 = "checked", void 0 !== m2 && m2 !== u2[a2] && F(u2, a2, m2, b[a2], o2));
}
return u2;
}
function V(n2, u2, t2) {
try {
if ("function" == typeof n2) {
var i2 = "function" == typeof n2.__u;
i2 && n2.__u(), i2 && null == u2 || (n2.__u = n2(u2));
} else n2.current = u2;
} catch (n3) {
l$1.__e(n3, t2);
}
}
function q$1(n2, u2, t2) {
var i2, r2;
if (l$1.unmount && l$1.unmount(n2), (i2 = n2.ref) && (i2.current && i2.current !== n2.__e || V(i2, null, u2)), null != (i2 = n2.__c)) {
if (i2.componentWillUnmount) try {
i2.componentWillUnmount();
} catch (n3) {
l$1.__e(n3, u2);
}
i2.base = i2.__P = null;
}
if (i2 = n2.__k) for (r2 = 0; r2 < i2.length; r2++) i2[r2] && q$1(i2[r2], u2, t2 || "function" != typeof n2.type);
t2 || _(n2.__e), n2.__c = n2.__ = n2.__e = void 0;
}
function B$1(n2, l2, u2) {
return this.constructor(n2, u2);
}
function D$1(u2, t2, i2) {
var r2, o2, e2, f2;
t2 == document && (t2 = document.documentElement), l$1.__ && l$1.__(u2, t2), o2 = (r2 = false) ? null : t2.__k, e2 = [], f2 = [], j$1(t2, u2 = t2.__k = g(k$1, null, [u2]), o2 || p$1, p$1, t2.namespaceURI, o2 ? null : t2.firstChild ? n.call(t2.childNodes) : null, e2, o2 ? o2.__e : t2.firstChild, r2, f2), z$1(e2, u2, f2);
}
n = v$1.slice, l$1 = { __e: function(n2, l2, u2, t2) {
for (var i2, r2, o2; l2 = l2.__; ) if ((i2 = l2.__c) && !i2.__) try {
if ((r2 = i2.constructor) && null != r2.getDerivedStateFromError && (i2.setState(r2.getDerivedStateFromError(n2)), o2 = i2.__d), null != i2.componentDidCatch && (i2.componentDidCatch(n2, t2 || {}), o2 = i2.__d), o2) return i2.__E = i2;
} catch (l3) {
n2 = l3;
}
throw n2;
} }, u$2 = 0, x.prototype.setState = function(n2, l2) {
var u2;
u2 = null != this.__s && this.__s !== this.state ? this.__s : this.__s = w$1({}, this.state), "function" == typeof n2 && (n2 = n2(w$1({}, u2), this.props)), n2 && w$1(u2, n2), null != n2 && this.__v && (l2 && this._sb.push(l2), M(this));
}, x.prototype.forceUpdate = function(n2) {
this.__v && (this.__e = true, n2 && this.__h.push(n2), M(this));
}, x.prototype.render = k$1, i$1 = [], o$1 = "function" == typeof Promise ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, e$1 = function(n2, l2) {
return n2.__v.__b - l2.__v.__b;
}, P.__r = 0, f$2 = /(PointerCapture)$|Capture$/i, c$1 = 0, s$1 = O(false), a$1 = O(true);
var f$1 = 0;
function u$1(e2, t2, n2, o2, i2, u2) {
t2 || (t2 = {});
var a2, c2, p2 = t2;
if ("ref" in p2) for (c2 in p2 = {}, t2) "ref" == c2 ? a2 = t2[c2] : p2[c2] = t2[c2];
var l2 = { type: e2, props: p2, key: n2, ref: a2, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --f$1, __i: -1, __u: 0, __source: i2, __self: u2 };
if ("function" == typeof e2 && (a2 = e2.defaultProps)) for (c2 in a2) void 0 === p2[c2] && (p2[c2] = a2[c2]);
return l$1.vnode && l$1.vnode(l2), l2;
}
var t, r, u, i, o = 0, f = [], c = l$1, e = c.__b, a = c.__r, v = c.diffed, l = c.__c, m = c.unmount, s = c.__;
function d(n2, t2) {
c.__h && c.__h(r, n2, o || t2), o = 0;
var u2 = r.__H || (r.__H = { __: [], __h: [] });
return n2 >= u2.__.length && u2.__.push({}), u2.__[n2];
}
function h(n2) {
return o = 1, p(D, n2);
}
function p(n2, u2, i2) {
var o2 = d(t++, 2);
if (o2.t = n2, !o2.__c && (o2.__ = [D(void 0, u2), function(n3) {
var t2 = o2.__N ? o2.__N[0] : o2.__[0], r2 = o2.t(t2, n3);
t2 !== r2 && (o2.__N = [r2, o2.__[1]], o2.__c.setState({}));
}], o2.__c = r, !r.u)) {
var f2 = function(n3, t2, r2) {
if (!o2.__c.__H) return true;
var u3 = o2.__c.__H.__.filter(function(n4) {
return !!n4.__c;
});
if (u3.every(function(n4) {
return !n4.__N;
})) return !c2 || c2.call(this, n3, t2, r2);
var i3 = o2.__c.props !== n3;
return u3.forEach(function(n4) {
if (n4.__N) {
var t3 = n4.__[0];
n4.__ = n4.__N, n4.__N = void 0, t3 !== n4.__[0] && (i3 = true);
}
}), c2 && c2.call(this, n3, t2, r2) || i3;
};
r.u = true;
var c2 = r.shouldComponentUpdate, e2 = r.componentWillUpdate;
r.componentWillUpdate = function(n3, t2, r2) {
if (this.__e) {
var u3 = c2;
c2 = void 0, f2(n3, t2, r2), c2 = u3;
}
e2 && e2.call(this, n3, t2, r2);
}, r.shouldComponentUpdate = f2;
}
return o2.__N || o2.__;
}
function y(n2, u2) {
var i2 = d(t++, 3);
!c.__s && C(i2.__H, u2) && (i2.__ = n2, i2.i = u2, r.__H.__h.push(i2));
}
function T(n2, r2) {
var u2 = d(t++, 7);
return C(u2.__H, r2) && (u2.__ = n2(), u2.__H = r2, u2.__h = n2), u2.__;
}
function q(n2, t2) {
return o = 8, T(function() {
return n2;
}, t2);
}
function j() {
for (var n2; n2 = f.shift(); ) if (n2.__P && n2.__H) try {
n2.__H.__h.forEach(z), n2.__H.__h.forEach(B), n2.__H.__h = [];
} catch (t2) {
n2.__H.__h = [], c.__e(t2, n2.__v);
}
}
c.__b = function(n2) {
r = null, e && e(n2);
}, c.__ = function(n2, t2) {
n2 && t2.__k && t2.__k.__m && (n2.__m = t2.__k.__m), s && s(n2, t2);
}, c.__r = function(n2) {
a && a(n2), t = 0;
var i2 = (r = n2.__c).__H;
i2 && (u === r ? (i2.__h = [], r.__h = [], i2.__.forEach(function(n3) {
n3.__N && (n3.__ = n3.__N), n3.i = n3.__N = void 0;
})) : (i2.__h.forEach(z), i2.__h.forEach(B), i2.__h = [], t = 0)), u = r;
}, c.diffed = function(n2) {
v && v(n2);
var t2 = n2.__c;
t2 && t2.__H && (t2.__H.__h.length && (1 !== f.push(t2) && i === c.requestAnimationFrame || ((i = c.requestAnimationFrame) || w)(j)), t2.__H.__.forEach(function(n3) {
n3.i && (n3.__H = n3.i), n3.i = void 0;
})), u = r = null;
}, c.__c = function(n2, t2) {
t2.some(function(n3) {
try {
n3.__h.forEach(z), n3.__h = n3.__h.filter(function(n4) {
return !n4.__ || B(n4);
});
} catch (r2) {
t2.some(function(n4) {
n4.__h && (n4.__h = []);
}), t2 = [], c.__e(r2, n3.__v);
}
}), l && l(n2, t2);
}, c.unmount = function(n2) {
m && m(n2);
var t2, r2 = n2.__c;
r2 && r2.__H && (r2.__H.__.forEach(function(n3) {
try {
z(n3);
} catch (n4) {
t2 = n4;
}
}), r2.__H = void 0, t2 && c.__e(t2, r2.__v));
};
var k = "function" == typeof requestAnimationFrame;
function w(n2) {
var t2, r2 = function() {
clearTimeout(u2), k && cancelAnimationFrame(t2), setTimeout(n2);
}, u2 = setTimeout(r2, 100);
k && (t2 = requestAnimationFrame(r2));
}
function z(n2) {
var t2 = r, u2 = n2.__c;
"function" == typeof u2 && (n2.__c = void 0, u2()), r = t2;
}
function B(n2) {
var t2 = r;
n2.__c = n2.__(), r = t2;
}
function C(n2, t2) {
return !n2 || n2.length !== t2.length || t2.some(function(t3, r2) {
return t3 !== n2[r2];
});
}
function D(n2, t2) {
return "function" == typeof t2 ? t2(n2) : t2;
}
const header = "_header_1hnaa_1";
const logo = "_logo_1hnaa_6";
const style$a = {
header,
logo
};
const container = "_container_1putz_1";
const style$9 = {
container
};
function Container(props) {
return /* @__PURE__ */ u$1("div", { class: style$9.container, children: props.children });
}
const itemKey$1 = "topics";
function loadTopics() {
const storedTopics = localStorage.getItem(itemKey$1);
if (storedTopics) {
return JSON.parse(storedTopics);
} else {
return [];
}
}
function saveTopics(topics) {
localStorage.setItem(itemKey$1, JSON.stringify(topics));
}
function getDefaultExportFromCjs(x2) {
return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
}
var classnames = { exports: {} };
/*!
Copyright (c) 2018 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/
var hasRequiredClassnames;
function requireClassnames() {
if (hasRequiredClassnames) return classnames.exports;
hasRequiredClassnames = 1;
(function(module) {
(function() {
var hasOwn = {}.hasOwnProperty;
function classNames() {
var classes = "";
for (var i2 = 0; i2 < arguments.length; i2++) {
var arg = arguments[i2];
if (arg) {
classes = appendClass(classes, parseValue(arg));
}
}
return classes;
}
function parseValue(arg) {
if (typeof arg === "string" || typeof arg === "number") {
return arg;
}
if (typeof arg !== "object") {
return "";
}
if (Array.isArray(arg)) {
return classNames.apply(null, arg);
}
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
return arg.toString();
}
var classes = "";
for (var key in arg) {
if (hasOwn.call(arg, key) && arg[key]) {
classes = appendClass(classes, key);
}
}
return classes;
}
function appendClass(value, newClass) {
if (!newClass) {
return value;
}
if (value) {
return value + " " + newClass;
}
return value + newClass;
}
if (module.exports) {
classNames.default = classNames;
module.exports = classNames;
} else {
window.classNames = classNames;
}
})();
})(classnames);
return classnames.exports;
}
var classnamesExports = requireClassnames();
const cn = /* @__PURE__ */ getDefaultExportFromCjs(classnamesExports);
const spinnerSquare = "_spinnerSquare_4vgl0_1";
const square1 = "_square1_4vgl0_14";
const square2 = "_square2_4vgl0_18";
const square3 = "_square3_4vgl0_22";
const style$8 = {
spinnerSquare,
square1,
"square-anim": "_square-anim_4vgl0_1",
square2,
square3
};
function Spinner(props) {
return /* @__PURE__ */ u$1("div", { className: cn(style$8.spinnerSquare, props.className), children: [
/* @__PURE__ */ u$1("div", { className: style$8.square1 }),
/* @__PURE__ */ u$1("div", { className: style$8.square2 }),
/* @__PURE__ */ u$1("div", { className: style$8.square3 })
] });
}
const spinner$1 = "_spinner_1pqws_1";
const list = "_list_1pqws_5";
const highlight = "_highlight_1pqws_44";
const head = "_head_1pqws_48";
const generationSettings$1 = "_generationSettings_1pqws_52";
const style$7 = {
spinner: spinner$1,
list,
highlight,
head,
generationSettings: generationSettings$1
};
const routes = {
home: "home",
topic: "topic",
settings: "settings"
};
const btn = "_btn_1ts7o_1";
const disabled = "_disabled_1ts7o_18";
const secondary = "_secondary_1ts7o_22";
const spinner = "_spinner_1ts7o_32";
const load3 = "_load3_1ts7o_1";
const style$6 = {
btn,
disabled,
secondary,
spinner,
load3
};
function Button(props) {
const disabled2 = props.disabled || props.loading;
const buttonClass = cn(style$6.btn, { [style$6.secondary]: props.secondary }, "button", props.className, { [style$6.disabled]: disabled2 });
let spinner2 = void 0;
if (props.loading) {
spinner2 = /* @__PURE__ */ u$1("span", { className: style$6.spinner });
}
return /* @__PURE__ */ u$1(
"button",
{
type: "button",
onClick: () => {
if (!disabled2) {
props.onClick();
}
},
className: buttonClass,
disabled: disabled2,
title: props.title,
children: [
spinner2,
props.children
]
}
);
}
const iso8601ToFrenchRegex = /(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/;
function iso8601ToFrench(iso8601) {
console.log("iso8601ToTokens", iso8601);
const matches = iso8601.match(iso8601ToFrenchRegex);
const year = matches[1];
const month = months[parseInt(matches[2], 10) - 1];
const day = matches[3];
const hours = matches[4];
const minutes = matches[5];
const seconds = matches[6];
return `${day} ${month} ${year} à ${hours}:${minutes}:${seconds}`;
}
const frenchToIso8601Regex = /(\d{1,2}) ([a-zA-Z\u00C0-\u024F]+) (\d{4}) à (\d{2}):(\d{2}):(\d{2})/;
function frenchToIso8601(french) {
console.log("tokensToIso8601", french);
const match = french.match(frenchToIso8601Regex);
if (!match) {
throw new Error("Invalid date format");
}
const [, day, month, year, hours, minutes, seconds] = match;
const monthNumber = (months.indexOf(month) + 1).toString();
if (!monthNumber) {
throw new Error("Invalid month name");
}
const isoDate = `${year}-${monthNumber.padStart(2, "0")}-${day.padStart(2, "0")}T${hours}:${minutes}:${seconds}`;
return isoDate;
}
const months = [
"janvier",
"février",
"mars",
"avril",
"mai",
"juin",
"juillet",
"août",
"septembre",
"octobre",
"novembre",
"décembre"
];
const formGroup = "_formGroup_b3g81_1";
const style$5 = {
formGroup
};
function FormGroup(props) {
return /* @__PURE__ */ u$1("div", { className: style$5.formGroup, children: props.children });
}
const slider = "_slider_1hlzr_1";
const outputContainer = "_outputContainer_1hlzr_36";
const output = "_output_1hlzr_36";
const progress = "_progress_1hlzr_56";
const input$1 = "_input_1hlzr_83";
const style$4 = {
slider,
outputContainer,
output,
progress,
input: input$1
};
function Slider(props) {
return /* @__PURE__ */ u$1(
"div",
{
className: cn(style$4.slider, props.className),
style: {
"--value": props.value,
"--min": props.min,
"--max": props.max,
"--step": props.step
},
children: [
/* @__PURE__ */ u$1(
"input",
{
type: "range",
className: style$4.input,
name: props.name,
min: props.min,
max: props.max,
step: props.step,
value: props.value,
onInput: (e2) => props.onChange(Number(e2.target.value))
}
),
/* @__PURE__ */ u$1("div", { className: style$4.progress }),
/* @__PURE__ */ u$1("div", { className: style$4.outputContainer, children: /* @__PURE__ */ u$1("output", { className: style$4.output, children: props.value }) })
]
}
);
}
function Topics(props) {
const sortedTopics = T(() => {
if (props.topics === null || props.topics.length < 1) {
return props.topics;
}
return props.topics.sort((topicA, topicB) => {
if (topicA.posts.length < 1 || topicB.posts.length < 1) {
return 0;
}
return topicB.posts[topicB.posts.length - 1].date.localeCompare(topicA.posts[topicA.posts.length - 1].date);
});
}, [props.topics]);
return /* @__PURE__ */ u$1("div", { children: [
sortedTopics === null ? /* @__PURE__ */ u$1(Spinner, { className: style$7.spinner }) : /* @__PURE__ */ u$1(
List,
{
topics: sortedTopics,
setRoute: props.setRoute,
latestGeneratedTopicId: props.latestGeneratedTopicId
}
),
/* @__PURE__ */ u$1("div", { children: [
/* @__PURE__ */ u$1("h2", { children: "Nouveau sujet" }),
/* @__PURE__ */ u$1("div", { className: style$7.generationSettings, children: /* @__PURE__ */ u$1(FormGroup, { children: [
/* @__PURE__ */ u$1("label", { for: "postCount", children: "Nombre de posts" }),
/* @__PURE__ */ u$1(
Slider,
{
name: "postCount",
value: props.settings.postCount,
onChange: (v2) => props.setSettings({ ...props.settings, postCount: v2 }),
min: 1,
max: 10,
step: 1
}
)
] }) }),
/* @__PURE__ */ u$1(
Button,
{
onClick: () => props.generateTopic(props.settings.postCount),
secondary: true,
loading: props.pendingGeneration,
children: "Générer"
}
)
] }),
/* @__PURE__ */ u$1("hr", {})
] });
}
function List(props) {
return /* @__PURE__ */ u$1("ul", { className: style$7.list, children: [
/* @__PURE__ */ u$1("li", { className: style$7.head, children: [
/* @__PURE__ */ u$1("span", { children: "Sujet" }),
/* @__PURE__ */ u$1("span", { children: "Auteur" }),
/* @__PURE__ */ u$1("span", { children: "NB" }),
/* @__PURE__ */ u$1("span", { children: "Dernier msg" })
] }),
props.topics.length < 1 && /* @__PURE__ */ u$1("li", { children: [
/* @__PURE__ */ u$1("span", { children: "Aucun sujet" }),
/* @__PURE__ */ u$1("span", {}),
/* @__PURE__ */ u$1("span", {}),
/* @__PURE__ */ u$1("span", {})
] }),
props.topics.map((topic) => /* @__PURE__ */ u$1("li", { className: cn({ [style$7.highlight]: topic.id === props.latestGeneratedTopicId }), children: [
/* @__PURE__ */ u$1("span", { children: /* @__PURE__ */ u$1("a", { href: "#", onClick: (e2) => {
e2.preventDefault();
props.setRoute(routes.topic, 0, topic.id);
}, children: topic.title }) }),
/* @__PURE__ */ u$1("span", { children: topic.posts[0].user }),
/* @__PURE__ */ u$1("span", { children: topic.posts.length }),
/* @__PURE__ */ u$1("span", { children: iso8601ToFrench(topic.posts[topic.posts.length - 1].date) })
] }))
] });
}
const post = "_post_uuidr_1";
const postHeader = "_postHeader_uuidr_12";
const avatar = "_avatar_uuidr_23";
const user = "_user_uuidr_31";
const date = "_date_uuidr_39";
const generationSettings = "_generationSettings_uuidr_46";
const style$3 = {
post,
postHeader,
avatar,
user,
date,
generationSettings
};
const wrapper$1 = "_wrapper_cfqzy_1";
const style$2 = {
wrapper: wrapper$1
};
const smileysMap = [
[":)", "1"],
// https://image.jeuxvideo.com/smileys_img/1.gif
[":snif:", "20"],
[":gba:", "17"],
[":g)", "3"],
[":-)", "46"],
[":snif2:", "13"],
[":bravo:", "69"],
[":d)", "4"],
[":hap:", "18"],
[":ouch:", "22"],
[":pacg:", "9"],
[":cd:", "5"],
[":-)))", "23"],
[":ouch2:", "57"],
[":pacd:", "10"],
[":cute:", "nyu"],
[":content:", "24"],
[":p)", "7"],
[":-p", "31"],
[":noel:", "11"],
[":oui:", "37"],
[":(", "45"],
[":peur:", "47"],
[":question:", "2"],
[":cool:", "26"],
[":-(", "14"],
[":coeur:", "54"],
[":mort:", "21"],
[":rire:", "39"],
[":-((", "15"],
[":fou:", "50"],
[":sleep:", "27"],
[":-D", "40"],
[":nonnon:", "25"],
[":fier:", "53"],
[":honte:", "30"],
[":rire2:", "41"],
[":non2:", "33"],
[":sarcastic:", "43"],
[":monoeil:", "34"],
[":o))", "12"],
[":nah:", "19"],
[":doute:", "28"],
[":rouge:", "55"],
[":ok:", "36"],
[":non:", "35"],
[":malade:", "8"],
[":fete:", "66"],
[":sournois:", "67"],
[":hum:", "68"],
[":ange:", "60"],
[":diable:", "61"],
[":gni:", "62"],
[":play:", "play"],
[":desole:", "65"],
[":spoiler:", "63"],
[":merci:", "58"],
[":svp:", "59"],
[":sors:", "56"],
[":salut:", "42"],
[":rechercher:", "38"],
[":hello:", "29"],
[":up:", "44"],
[":bye:", "48"],
[":gne:", "51"],
[":lol:", "32"],
[":dpdr:", "49"],
[":dehors:", "52"],
[":hs:", "64"],
[":banzai:", "70"],
[":bave:", "71"],
[":pf:", "pf"],
[":cimer:", "cimer"],
[":ddb:", "ddb"],
[":pave:", "pave"],
[":objection:", "objection"],
[":siffle:", "siffle"]
];
function Preview(props) {
const html = T(() => {
const escaped = escapeHtml(props.raw);
return injectHTML(escaped).replace(/\n/g, "<br/>");
}, [props.raw]);
return /* @__PURE__ */ u$1("div", { className: style$2.wrapper, dangerouslySetInnerHTML: { __html: html } });
}
const jvcodeMap = [
// [/(https?:\/\/image\.noelshack\.com\/\S+)/g]: "<img width=\"68\" height=\"51\" alt=\"noelshak\" src=\"$1\"/>"
[
// Stickers
/(^| )https?:\/\/image\.noelshack\.com\/(?:fichiers|minis)(\S+)/gm,
'$1<img width="68" height="51" alt="noelshak" src="https://image.noelshack.com/minis/$2"/>'
],
[
// Vocaroo
/(^| )https:\/\/vocaroo.com\/(.+)/gm,
'$1<div><iframe width="300" height="60" src="https://vocaroo.com/embed/$2?autoplay=0" frameborder="0" allow="autoplay"></iframe></div>'
],
[
// Citations
/^(?:&gt;.*(?:\n&gt;.*)*)/g,
(reg, raw) => {
const match = reg.exec(raw);
if (!match) return raw;
console.log(match);
const index = match.index;
const length = match[0].length;
return raw.substring(0, index) + `<blockquote>${match[0].replace(/^&gt;/gm, "")}</blockquote>` + raw.substring(index + length);
}
],
[
// Spoil
/&lt;spoil&gt;(.*?)&lt;\/spoil&gt;/gm,
(reg, raw) => {
return raw.replace(reg, (_2, matched) => {
const randomId = (Math.random() + 1).toString(36).substring(2);
return `<span class="bloc-spoil-jv"><input type="checkbox" id="${randomId}" class="open-spoil"><label class="barre-head" for="${randomId}"><span class="txt-spoil">Spoil</span></label><span class="contenu-spoil">${matched}</span></span>`;
});
}
],
[
// Regular links
/(^| )(https?:\/\/\S+)/gm,
'$1<a href="$2" target="_blank">$2</a>'
],
// Generate regexes for smileys
// ...smileysMap.map((maping) => {
// return [new RegExp(
// Object.keys(smileysMap).map(s => (
// "(?:(?:^| )" + s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + ")"
// )).join("|"), "gm"
// ), `<img src="${maping[1]}" width="16" height="16" alt=""/>`]
// })
// (() => {
// new RegExp(
// smileysMap.map((mapping) => (
// "(?:(?:^| )" + s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + ")"
// )).join("|"), "gm"
// )
// return [/(https?:\/\/image\.noelshack\.com\/\S+)/g, "<img width=\"68\" height=\"51\" alt=\"noelshak\" src=\"$1\"/>"]
// })()
...smileysMap.map((mapping) => {
return [
new RegExp("(?:(^| )" + mapping[0].replace(/[.*+?^${}()|[\]\\]/g, "\\$&") + ")", "gm"),
`$1<img src="https://image.jeuxvideo.com/smileys_img/${mapping[1]}.gif" alt="${mapping[0]}"/>`
];
})
];
function injectHTML(input2) {
do {
for (const [regex, htmlOrFunc] of jvcodeMap) {
if (htmlOrFunc instanceof Function) {
input2 = htmlOrFunc(regex, input2);
} else {
input2 = input2.replace(regex, htmlOrFunc);
}
}
} while (false);
return input2;
}
function escapeHtml(unsafe) {
return unsafe.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
}
function Topic(props) {
console.log(props.topic);
return /* @__PURE__ */ u$1("div", { children: [
props.topic.posts.map((post2) => /* @__PURE__ */ u$1(Post, { post: post2 })),
/* @__PURE__ */ u$1("div", { children: [
/* @__PURE__ */ u$1("h2", { children: "Ajout de posts" }),
/* @__PURE__ */ u$1("div", { className: style$3.generationSettings, children: /* @__PURE__ */ u$1(FormGroup, { children: [
/* @__PURE__ */ u$1("label", { htmlFor: "postCount", children: "Nombre de posts" }),
/* @__PURE__ */ u$1(
Slider,
{
name: "postCount",
value: props.settings.postCount,
onChange: (v2) => props.setSettings({ ...props.settings, postCount: v2 }),
min: 1,
max: 10,
step: 1
}
)
] }) }),
/* @__PURE__ */ u$1(
Button,
{
onClick: () => props.addPosts(props.topic.id, props.settings.postCount),
secondary: true,
loading: props.pendingGeneration,
children: "Générer"
}
)
] }),
/* @__PURE__ */ u$1("hr", {})
] });
}
function Post(props) {
return /* @__PURE__ */ u$1("div", { className: style$3.post, children: [
/* @__PURE__ */ u$1("div", { className: style$3.postHeader, children: [
/* @__PURE__ */ u$1("img", { src: "https://image.jeuxvideo.com/avatar-sm/default.jpg", className: style$3.avatar, alt: "ahi" }),
/* @__PURE__ */ u$1("div", { className: style$3.user, children: props.post.user }),
/* @__PURE__ */ u$1("div", { className: style$3.date, children: iso8601ToFrench(props.post.date) })
] }),
/* @__PURE__ */ u$1(Preview, { raw: props.post.content })
] });
}
const wrapper = "_wrapper_1dmrl_1";
const icon = "_icon_1dmrl_6";
const input = "_input_1dmrl_14";
const style$1 = {
wrapper,
icon,
input
};
const Input = ({
type,
icon: icon2,
value,
placeholder,
onChange,
className,
disabled: disabled2,
id,
name
}) => {
const [focused, setFocused] = h(false);
const inputClass = cn(style$1.input, "generic-input", className, {
focused,
disabled: disabled2
});
const handleInputChange = (event) => {
console.log("handleInputChange");
const target = event.target;
onChange(type === "number" ? parseFloat(target.value) || 0 : target.value);
};
const Icon = icon2;
return /* @__PURE__ */ u$1("div", { className: style$1.wrapper, children: [
/* @__PURE__ */ u$1(Icon, { className: style$1.icon, size: 18 }),
/* @__PURE__ */ u$1(
"input",
{
title: "Le pseudo doit avoir une longueur comprise entre 3 et 15 caractères.",
type,
id,
name,
value,
placeholder,
onInput: handleInputChange,
className: inputClass,
disabled: disabled2,
onFocus: () => setFocused(true),
onBlur: () => setFocused(false)
}
)
] });
};
const Link = (props) => {
const color = props.color || "currentColor";
const size = props.size || 24;
delete props.color;
delete props.size;
return g(
"svg",
Object.assign({ xmlns: "http://www.w3.org/2000/svg", width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: color, "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }, props),
g("path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" }),
g("path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" })
);
};
const Settings$1 = (props) => {
const color = props.color || "currentColor";
const size = props.size || 24;
delete props.color;
delete props.size;
return g(
"svg",
Object.assign({ xmlns: "http://www.w3.org/2000/svg", width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: color, "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }, props),
g("circle", { cx: "12", cy: "12", r: "3" }),
g("path", { d: "M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z" })
);
};
function Settings(props) {
return /* @__PURE__ */ u$1("div", { children: /* @__PURE__ */ u$1("form", { children: [
/* @__PURE__ */ u$1(FormGroup, { children: [
/* @__PURE__ */ u$1("label", { htmlFor: "api", children: "API" }),
/* @__PURE__ */ u$1(
Input,
{
type: "text",
placeholder: "URl d'API ex: https://ouruq7zepnehg2-5000.proxy.runpod.net/",
icon: Link,
value: props.settings.apiURL,
onChange: (v2) => props.setSettings({ ...props.settings, apiURL: v2 })
}
)
] }),
/* @__PURE__ */ u$1(FormGroup, { children: [
/* @__PURE__ */ u$1("label", { for: "temperature", children: "Temperature" }),
/* @__PURE__ */ u$1(
Slider,
{
name: "temperature",
value: props.settings.temperature,
onChange: (v2) => props.setSettings({ ...props.settings, temperature: v2 }),
min: 0.1,
max: 2,
step: 0.1
}
)
] }),
/* @__PURE__ */ u$1("div", { children: /* @__PURE__ */ u$1(
Button,
{
onClick: () => {
props.resetApp();
},
secondary: true,
title: "Tout réinitialiser",
children: "Réinitialiser"
}
) }),
/* @__PURE__ */ u$1("br", {}),
/* @__PURE__ */ u$1("div", { children: /* @__PURE__ */ u$1(
Button,
{
onClick: () => {
history.go(-1);
},
children: "Retour"
}
) })
] }) });
}
const breadcrumbs = "_breadcrumbs_145yl_1";
const actions = "_actions_145yl_10";
const style = {
breadcrumbs,
actions
};
function Layout(props) {
return /* @__PURE__ */ u$1("div", { children: [
/* @__PURE__ */ u$1("nav", { className: style.breadcrumbs, children: [
props.breadcrumbs,
/* @__PURE__ */ u$1("div", { className: style.actions, children: /* @__PURE__ */ u$1("a", { href: "#", title: "Paramètres", onClick: (e2) => {
e2.preventDefault();
props.setRoute(routes.settings);
}, children: /* @__PURE__ */ u$1(Settings$1, { size: 18 }) }) })
] }),
/* @__PURE__ */ u$1("h2", { children: props.title }),
props.children
] });
}
const itemKey = "settings";
const defaultSettings = {
apiURL: "http://localhost:5000",
temperature: 0.9,
postCount: 3
};
function fetchSettings() {
const storedSettings = localStorage.getItem(itemKey);
if (storedSettings) {
return { ...defaultSettings, ...JSON.parse(storedSettings) };
} else {
return defaultSettings;
}
}
function saveSettings(settings) {
localStorage.setItem(itemKey, JSON.stringify(settings));
}
function resetSettings() {
localStorage.removeItem(itemKey);
}
function generateUUID() {
return "10000000-1000-4000-8000-100000000000".replace(
/[018]/g,
(c2) => (+c2 ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> +c2 / 4).toString(16)
);
}
const titleRegex = /Sujet\s+:\s+"(.+?)"?<\|eot_id\|>/;
const userRegex = /<\|im_pseudo\|>([^<]+)<\|end_pseudo\|>/;
const dateRegex = /<\|im_date\|>([^<]+)<\|end_date\|>/;
const contentRegex = /<\|begin_of_post\|>([\s\S]+)(?:<\|end_of_post\|>)?$/;
function tokensToTopic(tokens) {
const topic = {
id: generateUUID(),
title: "",
posts: []
};
for (const postTokens of tokens.split("<|end_of_post|>").slice(0, -1)) {
console.log("Post tokens:");
console.log(postTokens);
if (topic.posts.length < 1) {
const titleMatch = postTokens.match(titleRegex);
console.log(`title: ${titleMatch[1]}`);
topic.title = titleMatch[1];
}
topic.posts = topic.posts.concat(tokensToPosts(postTokens));
}
return topic;
}
function tokensToPosts(tokens) {
const posts = [];
for (const postTokens of tokens.split("<|end_of_post|>")) {
if (postTokens.length < 1) {
continue;
}
console.log("Post tokens:");
console.log(postTokens);
const userMatch = postTokens.match(userRegex);
console.log(`user: ${userMatch[1]}`);
const dateMatch = postTokens.match(dateRegex);
console.log(`date: ${dateMatch[1]}`);
const contentMatch = postTokens.match(contentRegex);
console.log(`content: ${contentMatch[1]}`);
posts.push({
user: userMatch[1],
date: frenchToIso8601(dateMatch[1]),
content: contentMatch[1]
});
}
return posts;
}
function tokenizeTopic(topic) {
if (topic.posts.length === 0) {
throw new Error("Topic must have at least one post");
}
const tokenizedPosts = topic.posts.map((post2) => tokenizePost(post2, topic.posts[0].user)).flat().join("");
let lines = [
"<|start_header_id|><|sujet|><|end_header_id|>",
"",
`Sujet : "${topic.title}"`
];
return lines.join("\n") + tokenizedPosts;
}
function tokenizePost(post2, poster) {
let lines = [
`<|eot_id|><|start_header_id|><|${post2.user === poster ? "autheur" : "khey"}|>`,
"<|end_header_id|>",
"",
`<|im_pseudo|>${post2.user}<|end_pseudo|>`,
`<|im_date|>Le ${iso8601ToFrench(post2.date)}<|end_date|>`,
"",
`<|begin_of_post|>${post2.content}<|end_of_post|>`
];
return lines.join("\n");
}
async function generateTopic(settings, nPosts) {
console.log(settings);
const rawOutput = await fetApiWithStream(settings, "<|start_header_id|>", nPosts);
return tokensToTopic(rawOutput);
}
async function generatePosts(settings, nPosts, topic) {
const rawOutput = await fetApiWithStream(settings, tokenizeTopic(topic), nPosts);
console.log("rawOutput");
console.log(rawOutput);
return tokensToPosts(rawOutput);
}
const postEndToken = "<|end_of_post|>";
async function fetApiWithStream(settings, prompt, nPosts) {
const controller = new AbortController();
const response = await fetch(new URL("/v1/completions", settings.apiURL), {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
prompt,
temperature: settings.temperature,
max_tokens: 2e3,
stream: true,
skip_special_tokens: false
// stop: "<|end_of_post|>"
// top_p: 1,
// frequency_penalty: 0,
// presence_penalty: 0,
}),
signal: controller.signal
});
if (!response.ok) {
throw new Error(`Failed to fetch API (${response.status} ${response.statusText}): ${await response.text()}`);
}
console.log(`Fetching topic with ${nPosts} posts...`);
let endTokenCount = 0;
let tokens = "";
let finishReason = null;
try {
await response.body.pipeThrough(new TextDecoderStream("utf-8")).pipeTo(new WritableStream({
write(rawChunk) {
for (const rawChunkLine of rawChunk.split("\n")) {
if (!rawChunkLine.startsWith("data:")) continue;
const chunk = JSON.parse(rawChunkLine.slice(6));
const text = chunk.choices[0].text;
console.log(text);
tokens += chunk.choices[0].text;
if (text.includes(postEndToken)) {
endTokenCount++;
if (endTokenCount >= nPosts) {
finishReason = "custom_stop";
controller.abort();
break;
}
} else {
finishReason = chunk.choices[0].finish_reason;
}
}
}
}));
} catch (e2) {
if (e2.name !== "AbortError") {
throw e2;
}
}
console.log("Done fetching data");
console.log(`Finish reason: ${finishReason}`);
console.log(`Tokens: ${tokens}`);
return tokens;
}
function App() {
const [route, _setRoute] = h(routes.home);
const [page, setPage] = h(0);
const [topicId, setTopicId] = h(null);
const [topics, setTopics] = h(loadTopics);
const [latestGeneratedTopicId, setLatestGeneratedTopicId] = h(null);
const [pendingGeneration, setPendingGeneration] = h(false);
y(() => {
console.log("save !");
saveTopics(topics);
}, [topics]);
const _generateTopic = async (postsCount) => {
setPendingGeneration(true);
const topic = await generateTopic(settings, postsCount);
setLatestGeneratedTopicId(topic.id);
setTopics((topics2) => [...topics2, topic]);
setPendingGeneration(false);
};
const addPosts = async (topicId2, postsCount) => {
setPendingGeneration(true);
const posts = await generatePosts(settings, postsCount, topics.find((t2) => t2.id === topicId2));
const newTopics = [...topics];
const foundIndex = newTopics.findIndex((t2) => t2.id === topicId2);
newTopics[foundIndex].posts = newTopics[foundIndex].posts.concat(posts);
setTopics(newTopics);
setPendingGeneration(false);
};
const [settings, setSettings] = h(fetchSettings);
y(() => {
saveSettings(settings);
}, [settings]);
const resetApp = () => {
resetSettings();
setSettings(fetchSettings);
setTopics([]);
};
const updateRoute = q(() => {
const url = new URL(window.location.href);
const route2 = url.searchParams.get("route");
if (route2 && route2 in routes) {
_setRoute(route2);
}
const page2 = url.searchParams.get("page");
if (page2) {
setPage(parseInt(page2));
}
const id = url.searchParams.get("id");
if (id) {
setTopicId(id);
}
}, []);
y(() => {
updateRoute();
}, []);
y(() => {
function listener() {
updateRoute();
}
window.addEventListener("popstate", listener);
return () => {
window.removeEventListener("popstate", listener);
};
}, []);
const setRoute = q((route2, page2, id) => {
const url = new URL(window.location.href);
url.searchParams.set("route", route2);
_setRoute(route2);
if (page2 !== void 0) {
url.searchParams.set("page", String(page2));
setPage(page2);
} else {
url.searchParams.delete("page");
setPage(0);
}
if (id !== void 0) {
url.searchParams.set("id", id);
setTopicId(id);
} else {
url.searchParams.delete("id");
setTopicId(null);
}
const newUrl = url.toString();
if (newUrl !== window.location.href) {
window.history.pushState({}, "", newUrl);
}
}, []);
let routeComponent = void 0;
let breadcrumbs2 = void 0;
let title = void 0;
switch (route) {
case routes.home:
routeComponent = /* @__PURE__ */ u$1(
Topics,
{
topics,
setRoute,
settings,
setSettings,
generateTopic: _generateTopic,
pendingGeneration,
latestGeneratedTopicId
}
);
breadcrumbs2 = "accueil";
title = "Liste des sujets";
break;
case routes.topic:
if (topicId === null) {
routeComponent = /* @__PURE__ */ u$1("div", { children: "Impossible d'afficher le sujet" });
breadcrumbs2 = "accueil";
title = "Sujet";
} else {
if (topics === null) {
routeComponent = /* @__PURE__ */ u$1("div", { children: "Chargement..." });
breadcrumbs2 = `accueil / sujet`;
title = `Chargement...`;
} else {
const topic = topics.find((t2) => t2.id === topicId);
routeComponent = /* @__PURE__ */ u$1(
Topic,
{
topic,
settings,
setSettings,
addPosts,
pendingGeneration
}
);
breadcrumbs2 = `accueil / ${topic.title}`;
title = `Sujet : ${topic.title}`;
}
}
break;
case routes.settings:
routeComponent = /* @__PURE__ */ u$1(Settings, { settings, setSettings, resetApp });
breadcrumbs2 = "accueil / paramètres";
title = "Paramètres";
break;
}
return /* @__PURE__ */ u$1(k$1, { children: [
/* @__PURE__ */ u$1("header", { className: style$a.header, children: /* @__PURE__ */ u$1(Container, { children: /* @__PURE__ */ u$1("h1", { className: style$a.logo, children: /* @__PURE__ */ u$1("a", { href: "#", onClick: (e2) => {
e2.preventDefault();
setRoute(routes.home);
}, children: "JVCGPT" }) }) }) }),
/* @__PURE__ */ u$1("main", { children: /* @__PURE__ */ u$1(Container, { children: /* @__PURE__ */ u$1(
Layout,
{
breadcrumbs: breadcrumbs2,
title,
setRoute,
children: routeComponent
}
) }) })
] });
}
D$1(g(App, null), document.getElementById("app"));