smart-chat-asp
Version:
smartChat component
1,508 lines (1,507 loc) • 46.1 kB
JavaScript
import { onBeforeUpdate as yt, defineComponent as J, ref as z, computed as C, toRef as wt, watch as Ne, nextTick as ye, onBeforeUnmount as xt, h as _, Transition as je, watchEffect as Be, openBlock as H, createElementBlock as Q, createElementVNode as o, toDisplayString as l, createVNode as g, unref as u, withCtx as x, createTextVNode as D, normalizeClass as kt, Fragment as $t, renderList as St, onMounted as _t, createBlock as xe, createCommentVNode as ke } from "vue";
import { c as G, a as i, b as I, d as le, f as Pe, i as Ct, e as zt, u as Fe, g as he, h as Rt, j as Tt, k as $e, l as Vt, m as Se, V as It, n as Dt, r as Mt, o as Nt, s as Bt, p as re, q as de, t as ce, v as Pt, w as At, x as Et, y as Ut, z as jt, N as Ft, A as Ot, B as _e, C as Ht, D as Lt, E as Gt, F as Kt, G as Oe, H as ue, I as P, _ as K, J as Wt, K as Yt, L as X, M as He, O as Xt, P as Jt, Q as qt, R as we } from "./lib-abebf4b0.mjs";
const Qt = G([i("slider", `
display: block;
padding: calc((var(--n-handle-size) - var(--n-rail-height)) / 2) 0;
position: relative;
z-index: 0;
width: 100%;
cursor: pointer;
user-select: none;
-webkit-user-select: none;
`, [I("reverse", [i("slider-handles", [i("slider-handle-wrapper", `
transform: translate(50%, -50%);
`)]), i("slider-dots", [i("slider-dot", `
transform: translateX(50%, -50%);
`)]), I("vertical", [i("slider-handles", [i("slider-handle-wrapper", `
transform: translate(-50%, -50%);
`)]), i("slider-marks", [i("slider-mark", `
transform: translateY(calc(-50% + var(--n-dot-height) / 2));
`)]), i("slider-dots", [i("slider-dot", `
transform: translateX(-50%) translateY(0);
`)])])]), I("vertical", `
box-sizing: content-box;
padding: 0 calc((var(--n-handle-size) - var(--n-rail-height)) / 2);
width: var(--n-rail-width-vertical);
height: 100%;
`, [i("slider-handles", `
top: calc(var(--n-handle-size) / 2);
right: 0;
bottom: calc(var(--n-handle-size) / 2);
left: 0;
`, [i("slider-handle-wrapper", `
top: unset;
left: 50%;
transform: translate(-50%, 50%);
`)]), i("slider-rail", `
height: 100%;
`, [le("fill", `
top: unset;
right: 0;
bottom: unset;
left: 0;
`)]), I("with-mark", `
width: var(--n-rail-width-vertical);
margin: 0 32px 0 8px;
`), i("slider-marks", `
top: calc(var(--n-handle-size) / 2);
right: unset;
bottom: calc(var(--n-handle-size) / 2);
left: 22px;
font-size: var(--n-mark-font-size);
`, [i("slider-mark", `
transform: translateY(50%);
white-space: nowrap;
`)]), i("slider-dots", `
top: calc(var(--n-handle-size) / 2);
right: unset;
bottom: calc(var(--n-handle-size) / 2);
left: 50%;
`, [i("slider-dot", `
transform: translateX(-50%) translateY(50%);
`)])]), I("disabled", `
cursor: not-allowed;
opacity: var(--n-opacity-disabled);
`, [i("slider-handle", `
cursor: not-allowed;
`)]), I("with-mark", `
width: 100%;
margin: 8px 0 32px 0;
`), G("&:hover", [i("slider-rail", {
backgroundColor: "var(--n-rail-color-hover)"
}, [le("fill", {
backgroundColor: "var(--n-fill-color-hover)"
})]), i("slider-handle", {
boxShadow: "var(--n-handle-box-shadow-hover)"
})]), I("active", [i("slider-rail", {
backgroundColor: "var(--n-rail-color-hover)"
}, [le("fill", {
backgroundColor: "var(--n-fill-color-hover)"
})]), i("slider-handle", {
boxShadow: "var(--n-handle-box-shadow-hover)"
})]), i("slider-marks", `
position: absolute;
top: 18px;
left: calc(var(--n-handle-size) / 2);
right: calc(var(--n-handle-size) / 2);
`, [i("slider-mark", `
position: absolute;
transform: translateX(-50%);
white-space: nowrap;
`)]), i("slider-rail", `
width: 100%;
position: relative;
height: var(--n-rail-height);
background-color: var(--n-rail-color);
transition: background-color .3s var(--n-bezier);
border-radius: calc(var(--n-rail-height) / 2);
`, [le("fill", `
position: absolute;
top: 0;
bottom: 0;
border-radius: calc(var(--n-rail-height) / 2);
transition: background-color .3s var(--n-bezier);
background-color: var(--n-fill-color);
`)]), i("slider-handles", `
position: absolute;
top: 0;
right: calc(var(--n-handle-size) / 2);
bottom: 0;
left: calc(var(--n-handle-size) / 2);
`, [i("slider-handle-wrapper", `
outline: none;
position: absolute;
top: 50%;
transform: translate(-50%, -50%);
cursor: pointer;
display: flex;
`, [i("slider-handle", `
height: var(--n-handle-size);
width: var(--n-handle-size);
border-radius: 50%;
overflow: hidden;
transition: box-shadow .2s var(--n-bezier), background-color .3s var(--n-bezier);
background-color: var(--n-handle-color);
box-shadow: var(--n-handle-box-shadow);
`, [G("&:hover", `
box-shadow: var(--n-handle-box-shadow-hover);
`)]), G("&:focus", [i("slider-handle", `
box-shadow: var(--n-handle-box-shadow-focus);
`, [G("&:hover", `
box-shadow: var(--n-handle-box-shadow-active);
`)])])])]), i("slider-dots", `
position: absolute;
top: 50%;
left: calc(var(--n-handle-size) / 2);
right: calc(var(--n-handle-size) / 2);
`, [I("transition-disabled", [i("slider-dot", "transition: none;")]), i("slider-dot", `
transition:
border-color .3s var(--n-bezier),
box-shadow .3s var(--n-bezier),
background-color .3s var(--n-bezier);
position: absolute;
transform: translate(-50%, -50%);
height: var(--n-dot-height);
width: var(--n-dot-width);
border-radius: var(--n-dot-border-radius);
overflow: hidden;
box-sizing: border-box;
border: var(--n-dot-border);
background-color: var(--n-dot-color);
`, [I("active", "border: var(--n-dot-border-active);")])])]), i("slider-handle-indicator", `
font-size: var(--n-font-size);
padding: 6px 10px;
border-radius: var(--n-indicator-border-radius);
color: var(--n-indicator-text-color);
background-color: var(--n-indicator-color);
box-shadow: var(--n-indicator-box-shadow);
`, [Pe()]), i("slider-handle-indicator", `
font-size: var(--n-font-size);
padding: 6px 10px;
border-radius: var(--n-indicator-border-radius);
color: var(--n-indicator-text-color);
background-color: var(--n-indicator-color);
box-shadow: var(--n-indicator-box-shadow);
`, [I("top", `
margin-bottom: 12px;
`), I("right", `
margin-left: 12px;
`), I("bottom", `
margin-top: 12px;
`), I("left", `
margin-right: 12px;
`), Pe()]), Ct(i("slider", [i("slider-dot", "background-color: var(--n-dot-color-modal);")])), zt(i("slider", [i("slider-dot", "background-color: var(--n-dot-color-popover);")]))]);
function Ae(t) {
return window.TouchEvent && t instanceof window.TouchEvent;
}
function Ee() {
const t = /* @__PURE__ */ new Map(), a = (m) => (r) => {
t.set(m, r);
};
return yt(() => {
t.clear();
}), [t, a];
}
const Zt = 0, en = Object.assign(Object.assign({}, he.props), {
to: Se.propTo,
defaultValue: {
type: [Number, Array],
default: 0
},
marks: Object,
disabled: {
type: Boolean,
default: void 0
},
formatTooltip: Function,
keyboard: {
type: Boolean,
default: !0
},
min: {
type: Number,
default: 0
},
max: {
type: Number,
default: 100
},
step: {
type: [Number, String],
default: 1
},
range: Boolean,
value: [Number, Array],
placement: String,
showTooltip: {
type: Boolean,
default: void 0
},
tooltip: {
type: Boolean,
default: !0
},
vertical: Boolean,
reverse: Boolean,
"onUpdate:value": [Function, Array],
onUpdateValue: [Function, Array],
onDragstart: [Function],
onDragend: [Function]
}), Ue = J({
name: "Slider",
props: en,
slots: Object,
setup(t) {
const {
mergedClsPrefixRef: a,
namespaceRef: m,
inlineThemeDisabled: r
} = Fe(t), d = he("Slider", "-slider", Qt, Bt, t, a), f = z(null), [p, $] = Ee(), [c, h] = Ee(), k = z(/* @__PURE__ */ new Set()), j = Rt(t), {
mergedDisabledRef: A
} = j, E = C(() => {
const {
step: e
} = t;
if (Number(e) <= 0 || e === "mark")
return 0;
const n = e.toString();
let s = 0;
return n.includes(".") && (s = n.length - n.indexOf(".") - 1), s;
}), L = z(t.defaultValue), ve = wt(t, "value"), q = Tt(ve, L), M = C(() => {
const {
value: e
} = q;
return (t.range ? e : [e]).map(Ve);
}), Z = C(() => M.value.length > 2), y = C(() => t.placement === void 0 ? t.vertical ? "right" : "top" : t.placement), S = C(() => {
const {
marks: e
} = t;
return e ? Object.keys(e).map(Number.parseFloat) : null;
}), b = z(-1), F = z(-1), B = z(-1), N = z(!1), ee = z(!1), fe = C(() => {
const {
vertical: e,
reverse: n
} = t;
return e ? n ? "top" : "bottom" : n ? "right" : "left";
}), Ge = C(() => {
if (Z.value)
return;
const e = M.value, n = te(t.range ? Math.min(...e) : t.min), s = te(t.range ? Math.max(...e) : e[0]), {
value: v
} = fe;
return t.vertical ? {
[v]: `${n}%`,
height: `${s - n}%`
} : {
[v]: `${n}%`,
width: `${s - n}%`
};
}), Ke = C(() => {
const e = [], {
marks: n
} = t;
if (n) {
const s = M.value.slice();
s.sort((V, T) => V - T);
const {
value: v
} = fe, {
value: w
} = Z, {
range: R
} = t, U = w ? () => !1 : (V) => R ? V >= s[0] && V <= s[s.length - 1] : V <= s[0];
for (const V of Object.keys(n)) {
const T = Number(V);
e.push({
active: U(T),
key: T,
label: n[V],
style: {
[v]: `${te(T)}%`
}
});
}
}
return e;
});
function We(e, n) {
const s = te(e), {
value: v
} = fe;
return {
[v]: `${s}%`,
zIndex: n === b.value ? 1 : 0
};
}
function ze(e) {
return t.showTooltip || B.value === e || b.value === e && N.value;
}
function Ye(e) {
return N.value ? !(b.value === e && F.value === e) : !0;
}
function Xe(e) {
var n;
~e && (b.value = e, (n = p.get(e)) === null || n === void 0 || n.focus());
}
function Je() {
c.forEach((e, n) => {
ze(n) && e.syncPosition();
});
}
function Re(e) {
const {
"onUpdate:value": n,
onUpdateValue: s
} = t, {
nTriggerFormInput: v,
nTriggerFormChange: w
} = j;
s && re(s, e), n && re(n, e), L.value = e, v(), w();
}
function Te(e) {
const {
range: n
} = t;
if (n) {
if (Array.isArray(e)) {
const {
value: s
} = M;
e.join() !== s.join() && Re(e);
}
} else
Array.isArray(e) || M.value[0] !== e && Re(e);
}
function me(e, n) {
if (t.range) {
const s = M.value.slice();
s.splice(n, 1, e), Te(s);
} else
Te(e);
}
function pe(e, n, s) {
const v = s !== void 0;
s || (s = e - n > 0 ? 1 : -1);
const w = S.value || [], {
step: R
} = t;
if (R === "mark") {
const T = ne(e, w.concat(n), v ? s : void 0);
return T ? T.value : n;
}
if (R <= 0)
return n;
const {
value: U
} = E;
let V;
if (v) {
const T = Number((n / R).toFixed(U)), O = Math.floor(T), ge = T > O ? O : O - 1, be = T < O ? O : O + 1;
V = ne(n, [Number((ge * R).toFixed(U)), Number((be * R).toFixed(U)), ...w], s);
} else {
const T = Qe(e);
V = ne(e, [...w, T]);
}
return V ? Ve(V.value) : n;
}
function Ve(e) {
return Math.min(t.max, Math.max(t.min, e));
}
function te(e) {
const {
max: n,
min: s
} = t;
return (e - s) / (n - s) * 100;
}
function qe(e) {
const {
max: n,
min: s
} = t;
return s + (n - s) * e;
}
function Qe(e) {
const {
step: n,
min: s
} = t;
if (Number(n) <= 0 || n === "mark")
return e;
const v = Math.round((e - s) / n) * n + s;
return Number(v.toFixed(E.value));
}
function ne(e, n = S.value, s) {
if (!(n != null && n.length))
return null;
let v = null, w = -1;
for (; ++w < n.length; ) {
const R = n[w] - e, U = Math.abs(R);
// find marks in the same direction
(s === void 0 || R * s > 0) && (v === null || U < v.distance) && (v = {
index: w,
distance: U,
value: n[w]
});
}
return v;
}
function Ie(e) {
const n = f.value;
if (!n)
return;
const s = Ae(e) ? e.touches[0] : e, v = n.getBoundingClientRect();
let w;
return t.vertical ? w = (v.bottom - s.clientY) / v.height : w = (s.clientX - v.left) / v.width, t.reverse && (w = 1 - w), qe(w);
}
function Ze(e) {
if (A.value || !t.keyboard)
return;
const {
vertical: n,
reverse: s
} = t;
switch (e.key) {
case "ArrowUp":
e.preventDefault(), se(n && s ? -1 : 1);
break;
case "ArrowRight":
e.preventDefault(), se(!n && s ? -1 : 1);
break;
case "ArrowDown":
e.preventDefault(), se(n && s ? 1 : -1);
break;
case "ArrowLeft":
e.preventDefault(), se(!n && s ? 1 : -1);
break;
}
}
function se(e) {
const n = b.value;
if (n === -1)
return;
const {
step: s
} = t, v = M.value[n], w = Number(s) <= 0 || s === "mark" ? v : v + s * e;
me(
// Avoid the number of value does not change when `step` is null
pe(w, v, e > 0 ? 1 : -1),
n
);
}
function et(e) {
var n, s;
if (A.value || !Ae(e) && e.button !== Zt)
return;
const v = Ie(e);
if (v === void 0)
return;
const w = M.value.slice(), R = t.range ? (s = (n = ne(v, w)) === null || n === void 0 ? void 0 : n.index) !== null && s !== void 0 ? s : -1 : 0;
R !== -1 && (e.preventDefault(), Xe(R), tt(), me(pe(v, M.value[R]), R));
}
function tt() {
N.value || (N.value = !0, t.onDragstart && re(t.onDragstart), de("touchend", document, ie), de("mouseup", document, ie), de("touchmove", document, ae), de("mousemove", document, ae));
}
function oe() {
N.value && (N.value = !1, t.onDragend && re(t.onDragend), ce("touchend", document, ie), ce("mouseup", document, ie), ce("touchmove", document, ae), ce("mousemove", document, ae));
}
function ae(e) {
const {
value: n
} = b;
if (!N.value || n === -1) {
oe();
return;
}
const s = Ie(e);
s !== void 0 && me(pe(s, M.value[n]), n);
}
function ie() {
oe();
}
function nt(e) {
b.value = e, A.value || (B.value = e);
}
function st(e) {
b.value === e && (b.value = -1, oe()), B.value === e && (B.value = -1);
}
function ot(e) {
B.value = e;
}
function at(e) {
B.value === e && (B.value = -1);
}
Ne(b, (e, n) => void ye(() => F.value = n)), Ne(q, () => {
if (t.marks) {
if (ee.value)
return;
ee.value = !0, ye(() => {
ee.value = !1;
});
}
ye(Je);
}), xt(() => {
oe();
});
const De = C(() => {
const {
self: {
markFontSize: e,
railColor: n,
railColorHover: s,
fillColor: v,
fillColorHover: w,
handleColor: R,
opacityDisabled: U,
dotColor: V,
dotColorModal: T,
handleBoxShadow: O,
handleBoxShadowHover: ge,
handleBoxShadowActive: be,
handleBoxShadowFocus: it,
dotBorder: lt,
dotBoxShadow: rt,
railHeight: dt,
railWidthVertical: ct,
handleSize: ut,
dotHeight: ht,
dotWidth: vt,
dotBorderRadius: ft,
fontSize: mt,
dotBorderActive: pt,
dotColorPopover: gt
},
common: {
cubicBezierEaseInOut: bt
}
} = d.value;
return {
"--n-bezier": bt,
"--n-dot-border": lt,
"--n-dot-border-active": pt,
"--n-dot-border-radius": ft,
"--n-dot-box-shadow": rt,
"--n-dot-color": V,
"--n-dot-color-modal": T,
"--n-dot-color-popover": gt,
"--n-dot-height": ht,
"--n-dot-width": vt,
"--n-fill-color": v,
"--n-fill-color-hover": w,
"--n-font-size": mt,
"--n-handle-box-shadow": O,
"--n-handle-box-shadow-active": be,
"--n-handle-box-shadow-focus": it,
"--n-handle-box-shadow-hover": ge,
"--n-handle-color": R,
"--n-handle-size": ut,
"--n-opacity-disabled": U,
"--n-rail-color": n,
"--n-rail-color-hover": s,
"--n-rail-height": dt,
"--n-rail-width-vertical": ct,
"--n-mark-font-size": e
};
}), W = r ? $e("slider", void 0, De, t) : void 0, Me = C(() => {
const {
self: {
fontSize: e,
indicatorColor: n,
indicatorBoxShadow: s,
indicatorTextColor: v,
indicatorBorderRadius: w
}
} = d.value;
return {
"--n-font-size": e,
"--n-indicator-border-radius": w,
"--n-indicator-box-shadow": s,
"--n-indicator-color": n,
"--n-indicator-text-color": v
};
}), Y = r ? $e("slider-indicator", void 0, Me, t) : void 0;
return {
mergedClsPrefix: a,
namespace: m,
uncontrolledValue: L,
mergedValue: q,
mergedDisabled: A,
mergedPlacement: y,
isMounted: Vt(),
adjustedTo: Se(t),
dotTransitionDisabled: ee,
markInfos: Ke,
isShowTooltip: ze,
shouldKeepTooltipTransition: Ye,
handleRailRef: f,
setHandleRefs: $,
setFollowerRefs: h,
fillStyle: Ge,
getHandleStyle: We,
activeIndex: b,
arrifiedValues: M,
followerEnabledIndexSet: k,
handleRailMouseDown: et,
handleHandleFocus: nt,
handleHandleBlur: st,
handleHandleMouseEnter: ot,
handleHandleMouseLeave: at,
handleRailKeyDown: Ze,
indicatorCssVars: r ? void 0 : Me,
indicatorThemeClass: Y == null ? void 0 : Y.themeClass,
indicatorOnRender: Y == null ? void 0 : Y.onRender,
cssVars: r ? void 0 : De,
themeClass: W == null ? void 0 : W.themeClass,
onRender: W == null ? void 0 : W.onRender
};
},
render() {
var t;
const {
mergedClsPrefix: a,
themeClass: m,
formatTooltip: r
} = this;
return (t = this.onRender) === null || t === void 0 || t.call(this), _("div", {
class: [`${a}-slider`, m, {
[`${a}-slider--disabled`]: this.mergedDisabled,
[`${a}-slider--active`]: this.activeIndex !== -1,
[`${a}-slider--with-mark`]: this.marks,
[`${a}-slider--vertical`]: this.vertical,
[`${a}-slider--reverse`]: this.reverse
}],
style: this.cssVars,
onKeydown: this.handleRailKeyDown,
onMousedown: this.handleRailMouseDown,
onTouchstart: this.handleRailMouseDown
}, _("div", {
class: `${a}-slider-rail`
}, _("div", {
class: `${a}-slider-rail__fill`,
style: this.fillStyle
}), this.marks ? _("div", {
class: [`${a}-slider-dots`, this.dotTransitionDisabled && `${a}-slider-dots--transition-disabled`]
}, this.markInfos.map((d) => _("div", {
key: d.key,
class: [`${a}-slider-dot`, {
[`${a}-slider-dot--active`]: d.active
}],
style: d.style
}))) : null, _("div", {
ref: "handleRailRef",
class: `${a}-slider-handles`
}, this.arrifiedValues.map((d, f) => {
const p = this.isShowTooltip(f);
return _(It, null, {
default: () => [_(Dt, null, {
default: () => _("div", {
ref: this.setHandleRefs(f),
class: `${a}-slider-handle-wrapper`,
tabindex: this.mergedDisabled ? -1 : 0,
role: "slider",
"aria-valuenow": d,
"aria-valuemin": this.min,
"aria-valuemax": this.max,
"aria-orientation": this.vertical ? "vertical" : "horizontal",
"aria-disabled": this.disabled,
style: this.getHandleStyle(d, f),
onFocus: () => {
this.handleHandleFocus(f);
},
onBlur: () => {
this.handleHandleBlur(f);
},
onMouseenter: () => {
this.handleHandleMouseEnter(f);
},
onMouseleave: () => {
this.handleHandleMouseLeave(f);
}
}, Mt(this.$slots.thumb, () => [_("div", {
class: `${a}-slider-handle`
})]))
}), this.tooltip && _(Nt, {
ref: this.setFollowerRefs(f),
show: p,
to: this.adjustedTo,
enabled: this.showTooltip && !this.range || this.followerEnabledIndexSet.has(f),
teleportDisabled: this.adjustedTo === Se.tdkey,
placement: this.mergedPlacement,
containerClass: this.namespace
}, {
default: () => _(je, {
name: "fade-in-scale-up-transition",
appear: this.isMounted,
css: this.shouldKeepTooltipTransition(f),
onEnter: () => {
this.followerEnabledIndexSet.add(f);
},
onAfterLeave: () => {
this.followerEnabledIndexSet.delete(f);
}
}, {
default: () => {
var $;
return p ? (($ = this.indicatorOnRender) === null || $ === void 0 || $.call(this), _("div", {
class: [`${a}-slider-handle-indicator`, this.indicatorThemeClass, `${a}-slider-handle-indicator--${this.mergedPlacement}`],
style: this.indicatorCssVars
}, typeof r == "function" ? r(d) : d)) : null;
}
})
})]
});
})), this.marks ? _("div", {
class: `${a}-slider-marks`
}, this.markInfos.map((d) => _("div", {
key: d.key,
class: `${a}-slider-mark`,
style: d.style
}, typeof d.label == "function" ? d.label() : d.label))) : null));
}
}), tn = G([G("@keyframes spin-rotate", `
from {
transform: rotate(0);
}
to {
transform: rotate(360deg);
}
`), i("spin-container", `
position: relative;
`, [i("spin-body", `
position: absolute;
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-50%);
`, [Pt()])]), i("spin-body", `
display: inline-flex;
align-items: center;
justify-content: center;
flex-direction: column;
`), i("spin", `
display: inline-flex;
height: var(--n-size);
width: var(--n-size);
font-size: var(--n-size);
color: var(--n-color);
`, [I("rotate", `
animation: spin-rotate 2s linear infinite;
`)]), i("spin-description", `
display: inline-block;
font-size: var(--n-font-size);
color: var(--n-text-color);
transition: color .3s var(--n-bezier);
margin-top: 8px;
`), i("spin-content", `
opacity: 1;
transition: opacity .3s var(--n-bezier);
pointer-events: all;
`, [I("spinning", `
user-select: none;
-webkit-user-select: none;
pointer-events: none;
opacity: var(--n-opacity-spinning);
`)])]), nn = {
small: 20,
medium: 18,
large: 16
}, sn = Object.assign(Object.assign({}, he.props), {
contentClass: String,
contentStyle: [Object, String],
description: String,
stroke: String,
size: {
type: [String, Number],
default: "medium"
},
show: {
type: Boolean,
default: !0
},
strokeWidth: Number,
rotate: {
type: Boolean,
default: !0
},
spinning: {
type: Boolean,
validator: () => !0,
default: void 0
},
delay: Number
}), on = J({
name: "Spin",
props: sn,
slots: Object,
setup(t) {
process.env.NODE_ENV !== "production" && Be(() => {
t.spinning !== void 0 && At("spin", "`spinning` is deprecated, please use `show` instead.");
});
const {
mergedClsPrefixRef: a,
inlineThemeDisabled: m
} = Fe(t), r = he("Spin", "-spin", tn, Ot, t, a), d = C(() => {
const {
size: c
} = t, {
common: {
cubicBezierEaseInOut: h
},
self: k
} = r.value, {
opacitySpinning: j,
color: A,
textColor: E
} = k, L = typeof c == "number" ? Et(c) : k[Ut("size", c)];
return {
"--n-bezier": h,
"--n-opacity-spinning": j,
"--n-size": L,
"--n-color": A,
"--n-text-color": E
};
}), f = m ? $e("spin", C(() => {
const {
size: c
} = t;
return typeof c == "number" ? String(c) : c[0];
}), d, t) : void 0, p = jt(t, ["spinning", "show"]), $ = z(!1);
return Be((c) => {
let h;
if (p.value) {
const {
delay: k
} = t;
if (k) {
h = window.setTimeout(() => {
$.value = !0;
}, k), c(() => {
clearTimeout(h);
});
return;
}
}
$.value = p.value;
}), {
mergedClsPrefix: a,
active: $,
mergedStrokeWidth: C(() => {
const {
strokeWidth: c
} = t;
if (c !== void 0)
return c;
const {
size: h
} = t;
return nn[typeof h == "number" ? "medium" : h];
}),
cssVars: m ? void 0 : d,
themeClass: f == null ? void 0 : f.themeClass,
onRender: f == null ? void 0 : f.onRender
};
},
render() {
var t, a;
const {
$slots: m,
mergedClsPrefix: r,
description: d
} = this, f = m.icon && this.rotate, p = (d || m.description) && _("div", {
class: `${r}-spin-description`
}, d || ((t = m.description) === null || t === void 0 ? void 0 : t.call(m))), $ = m.icon ? _("div", {
class: [`${r}-spin-body`, this.themeClass]
}, _("div", {
class: [`${r}-spin`, f && `${r}-spin--rotate`],
style: m.default ? "" : this.cssVars
}, m.icon()), p) : _("div", {
class: [`${r}-spin-body`, this.themeClass]
}, _(Ft, {
clsPrefix: r,
style: m.default ? "" : this.cssVars,
stroke: this.stroke,
"stroke-width": this.mergedStrokeWidth,
class: `${r}-spin`
}), p);
return (a = this.onRender) === null || a === void 0 || a.call(this), m.default ? _("div", {
class: [`${r}-spin-container`, this.themeClass],
style: this.cssVars
}, _("div", {
class: [`${r}-spin-content`, this.active && `${r}-spin-content--spinning`, this.contentClass],
style: this.contentStyle
}, m), _(je, {
name: "fade-in-transition"
}, {
default: () => this.active ? $ : null
})) : $;
}
}), Ce = "settingsStorage";
function Le() {
return {
systemMessage: "You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.",
temperature: 0.8,
top_p: 1
};
}
function an() {
const t = _e.get(Ce);
return { ...Le(), ...t };
}
function ln(t) {
_e.set(Ce, t);
}
function rn() {
_e.remove(Ce);
}
const dn = Ht("setting-store", {
state: () => an(),
actions: {
updateSetting(t) {
this.$state = { ...this.$state, ...t }, this.recordState();
},
resetSetting() {
this.$state = Le(), rn();
},
recordState() {
ln(this.$state);
}
}
});
function cn() {
const t = /* @__PURE__ */ new Date(), a = t.getDate(), m = t.getMonth() + 1;
return `${t.getFullYear()}-${m}-${a}`;
}
const un = { class: "p-4 space-y-5 min-h-[200px]" }, hn = { class: "space-y-6" }, vn = { class: "flex items-center space-x-4" }, fn = { class: "flex-shrink-0 w-[100px]" }, mn = { class: "flex-1" }, pn = { class: "flex items-center space-x-4" }, gn = { class: "flex-shrink-0 w-[100px]" }, bn = { class: "w-[200px]" }, yn = { class: "flex items-center space-x-4" }, wn = { class: "flex-shrink-0 w-[100px]" }, xn = { class: "flex-1" }, kn = { class: "flex-shrink-0 w-[100px]" }, $n = { class: "flex flex-wrap items-center gap-4" }, Sn = { class: "flex items-center space-x-4" }, _n = { class: "flex-shrink-0 w-[100px]" }, Cn = { class: "flex flex-wrap items-center gap-4" }, zn = { class: "flex items-center space-x-4" }, Rn = { class: "flex-shrink-0 w-[100px]" }, Tn = { class: "flex flex-wrap items-center gap-4" }, Vn = { class: "flex items-center space-x-4" }, In = { class: "flex-shrink-0 w-[100px]" }, Dn = /* @__PURE__ */ J({
__name: "General",
setup(t) {
const a = Lt(), m = Gt(), { isMobile: r } = Kt(), d = Oe(), f = C(() => a.theme), p = C(() => m.userInfo), $ = z(p.value.avatar ?? ""), c = z(p.value.name ?? ""), h = z(p.value.description ?? ""), k = C({
get() {
return a.language;
},
set(y) {
a.setLanguage(y);
}
}), j = [
{
label: "Auto",
key: "auto",
icon: "ri:contrast-line"
},
{
label: "Light",
key: "light",
icon: "ri:sun-foggy-line"
},
{
label: "Dark",
key: "dark",
icon: "ri:moon-foggy-line"
}
], A = [
{ label: "English", key: "en-US", value: "en-US" },
{ label: "Español", key: "es-ES", value: "es-ES" },
{ label: "한국어", key: "ko-KR", value: "ko-KR" },
{ label: "Русский язык", key: "ru-RU", value: "ru-RU" },
{ label: "Tiếng Việt", key: "vi-VN", value: "vi-VN" },
{ label: "简体中文", key: "zh-CN", value: "zh-CN" },
{ label: "繁體中文", key: "zh-TW", value: "zh-TW" }
];
function E(y) {
m.updateUserInfo(y), d.success(X("common.success"));
}
function L() {
m.resetUserInfo(), d.success(X("common.success")), window.location.reload();
}
function ve() {
const y = cn(), S = localStorage.getItem("chatStorage") || "{}", b = JSON.stringify(JSON.parse(S), null, 2), F = new Blob([b], { type: "application/json" }), B = URL.createObjectURL(F), N = document.createElement("a");
N.href = B, N.download = `chat-store_${y}.json`, document.body.appendChild(N), N.click(), document.body.removeChild(N);
}
function q(y) {
const S = y.target;
if (!S || !S.files)
return;
const b = S.files[0];
if (!b)
return;
const F = new FileReader();
F.onload = () => {
try {
const B = JSON.parse(F.result);
localStorage.setItem("chatStorage", JSON.stringify(B)), d.success(X("common.success")), location.reload();
} catch {
d.error(X("common.invalidFileFormat"));
}
}, F.readAsText(b);
}
function M() {
localStorage.removeItem("chatStorage"), location.reload();
}
function Z() {
const y = document.getElementById("fileInput");
y && y.click();
}
return (y, S) => (H(), Q("div", un, [
o("div", hn, [
o("div", vn, [
o("span", fn, l(y.$t("setting.avatarLink")), 1),
o("div", mn, [
g(u(ue), {
value: $.value,
"onUpdate:value": S[0] || (S[0] = (b) => $.value = b),
placeholder: ""
}, null, 8, ["value"])
]),
g(u(P), {
size: "tiny",
text: "",
type: "primary",
onClick: S[1] || (S[1] = (b) => E({ avatar: $.value }))
}, {
default: x(() => [
D(l(y.$t("common.save")), 1)
]),
_: 1
})
]),
o("div", pn, [
o("span", gn, l(y.$t("setting.name")), 1),
o("div", bn, [
g(u(ue), {
value: c.value,
"onUpdate:value": S[2] || (S[2] = (b) => c.value = b),
placeholder: ""
}, null, 8, ["value"])
]),
g(u(P), {
size: "tiny",
text: "",
type: "primary",
onClick: S[3] || (S[3] = (b) => E({ name: c.value }))
}, {
default: x(() => [
D(l(y.$t("common.save")), 1)
]),
_: 1
})
]),
o("div", yn, [
o("span", wn, l(y.$t("setting.description")), 1),
o("div", xn, [
g(u(ue), {
value: h.value,
"onUpdate:value": S[4] || (S[4] = (b) => h.value = b),
placeholder: ""
}, null, 8, ["value"])
]),
g(u(P), {
size: "tiny",
text: "",
type: "primary",
onClick: S[5] || (S[5] = (b) => E({ description: h.value }))
}, {
default: x(() => [
D(l(y.$t("common.save")), 1)
]),
_: 1
})
]),
o("div", {
class: kt(["flex items-center space-x-4", u(r) && "items-start"])
}, [
o("span", kn, l(y.$t("setting.chatHistory")), 1),
o("div", $n, [
g(u(P), {
size: "small",
onClick: ve
}, {
icon: x(() => [
g(u(K), { icon: "ri:download-2-fill" })
]),
default: x(() => [
D(" " + l(y.$t("common.export")), 1)
]),
_: 1
}),
o("input", {
id: "fileInput",
type: "file",
style: { display: "none" },
onChange: q
}, null, 32),
g(u(P), {
size: "small",
onClick: Z
}, {
icon: x(() => [
g(u(K), { icon: "ri:upload-2-fill" })
]),
default: x(() => [
D(" " + l(y.$t("common.import")), 1)
]),
_: 1
}),
g(u(Wt), {
placement: "bottom",
onPositiveClick: M
}, {
trigger: x(() => [
g(u(P), { size: "small" }, {
icon: x(() => [
g(u(K), { icon: "ri:close-circle-line" })
]),
default: x(() => [
D(" " + l(y.$t("common.clear")), 1)
]),
_: 1
})
]),
default: x(() => [
D(" " + l(y.$t("chat.clearHistoryConfirm")), 1)
]),
_: 1
})
])
], 2),
o("div", Sn, [
o("span", _n, l(y.$t("setting.theme")), 1),
o("div", Cn, [
(H(), Q($t, null, St(j, (b) => g(u(P), {
key: b.key,
size: "small",
type: b.key === f.value ? "primary" : void 0,
onClick: (F) => u(a).setTheme(b.key)
}, {
icon: x(() => [
g(u(K), {
icon: b.icon
}, null, 8, ["icon"])
]),
_: 2
}, 1032, ["type", "onClick"])), 64))
])
]),
o("div", zn, [
o("span", Rn, l(y.$t("setting.language")), 1),
o("div", Tn, [
g(u(Yt), {
style: { width: "140px" },
value: k.value,
options: A,
onUpdateValue: S[6] || (S[6] = (b) => u(a).setLanguage(b))
}, null, 8, ["value"])
])
]),
o("div", Vn, [
o("span", In, l(y.$t("setting.resetUserInfo")), 1),
g(u(P), {
size: "small",
onClick: L
}, {
default: x(() => [
D(l(y.$t("common.reset")), 1)
]),
_: 1
})
])
])
]));
}
}), Mn = { class: "p-4 space-y-5 min-h-[200px]" }, Nn = { class: "space-y-6" }, Bn = { class: "flex items-center space-x-4" }, Pn = { class: "flex-shrink-0 w-[120px]" }, An = { class: "flex-1" }, En = { class: "flex items-center space-x-4" }, Un = { class: "flex-shrink-0 w-[120px]" }, jn = { class: "flex-1" }, Fn = { class: "flex items-center space-x-4" }, On = { class: "flex-shrink-0 w-[120px]" }, Hn = { class: "flex-1" }, Ln = { class: "flex items-center space-x-4" }, Gn = /* @__PURE__ */ J({
__name: "Advanced",
setup(t) {
const a = dn(), m = Oe(), r = z(a.systemMessage ?? ""), d = z(a.temperature ?? 0.5), f = z(a.top_p ?? 1);
function p(c) {
a.updateSetting(c), m.success(X("common.success"));
}
function $() {
a.resetSetting(), m.success(X("common.success")), window.location.reload();
}
return (c, h) => (H(), Q("div", Mn, [
o("div", Nn, [
o("div", Bn, [
o("span", Pn, l(c.$t("setting.role")), 1),
o("div", An, [
g(u(ue), {
value: r.value,
"onUpdate:value": h[0] || (h[0] = (k) => r.value = k),
type: "textarea",
autosize: { minRows: 1, maxRows: 4 }
}, null, 8, ["value"])
]),
g(u(P), {
size: "tiny",
text: "",
type: "primary",
onClick: h[1] || (h[1] = (k) => p({ systemMessage: r.value }))
}, {
default: x(() => [
D(l(c.$t("common.save")), 1)
]),
_: 1
})
]),
o("div", En, [
o("span", Un, l(c.$t("setting.temperature")), 1),
o("div", jn, [
g(u(Ue), {
value: d.value,
"onUpdate:value": h[2] || (h[2] = (k) => d.value = k),
max: 2,
min: 0,
step: 0.1
}, null, 8, ["value"])
]),
o("span", null, l(d.value), 1),
g(u(P), {
size: "tiny",
text: "",
type: "primary",
onClick: h[3] || (h[3] = (k) => p({ temperature: d.value }))
}, {
default: x(() => [
D(l(c.$t("common.save")), 1)
]),
_: 1
})
]),
o("div", Fn, [
o("span", On, l(c.$t("setting.top_p")), 1),
o("div", Hn, [
g(u(Ue), {
value: f.value,
"onUpdate:value": h[4] || (h[4] = (k) => f.value = k),
max: 1,
min: 0,
step: 0.1
}, null, 8, ["value"])
]),
o("span", null, l(f.value), 1),
g(u(P), {
size: "tiny",
text: "",
type: "primary",
onClick: h[5] || (h[5] = (k) => p({ top_p: f.value }))
}, {
default: x(() => [
D(l(c.$t("common.save")), 1)
]),
_: 1
})
]),
o("div", Ln, [
h[6] || (h[6] = o("span", { class: "flex-shrink-0 w-[120px]" }, " ", -1)),
g(u(P), {
size: "small",
onClick: $
}, {
default: x(() => [
D(l(c.$t("common.reset")), 1)
]),
_: 1
})
])
])
]));
}
}), Kn = "smart-chat-asp", Wn = "1.0.11", Yn = "smartChat component", Xn = "", Jn = [
"smartchat-web",
"smart-chat",
"chatbot",
"vue",
"smart",
"smartChat"
], qn = "lib/smart-chat.umd.js", Qn = "lib/smart-chat.es.js", Zn = "lib/smart-chat.d.ts", es = [
"lib/*"
], ts = {
dev: "vite",
"build-check": "run-p type-check build-only",
preview: "vite preview",
"build-only": "vite build",
build: "vite build",
"type-check": "vue-tsc --noEmit",
lint: "eslint .",
"lint:fix": "eslint . --fix",
bootstrap: "pnpm install && pnpm run common:prepare",
"common:cleanup": "rimraf node_modules && rimraf pnpm-lock.yaml",
"common:prepare": "husky install"
}, ns = {
"@vscode/markdown-it-katex": "^1.0.3",
"@vueuse/core": "^10.11.1",
"highlight.js": "^11.7.0",
"html-to-image": "^1.11.11",
katex: "^0.16.4",
"markdown-it": "^13.0.1",
"mermaid-it-markdown": "^1.0.8",
"naive-ui": "^2.34.3",
pinia: "^2.0.33",
"vite-plugin-compression": "^0.5.1",
"vite-plugin-tsconfig-paths": "^1.4.1",
vue: "^3.2.47",
"vue-i18n": "^9.2.2",
"vue-router": "^4.1.6"
}, ss = {
"@antfu/eslint-config": "^0.35.3",
"@commitlint/cli": "^17.4.4",
"@commitlint/config-conventional": "^17.4.4",
"@iconify/vue": "^4.1.0",
"@types/crypto-js": "^4.1.1",
"@types/katex": "^0.16.0",
"@types/markdown-it": "^12.2.3",
"@types/markdown-it-link-attributes": "^3.0.1",
"@types/node": "^18.14.6",
"@vitejs/plugin-vue": "^4.0.0",
autoprefixer: "^10.4.13",
axios: "^1.3.4",
"crypto-js": "^4.1.1",
eslint: "^8.35.0",
husky: "^8.0.3",
less: "^4.1.3",
"lint-staged": "^13.1.2",
"markdown-it-link-attributes": "^4.0.1",
"npm-run-all": "^4.1.5",
postcss: "^8.4.21",
rimraf: "^4.3.0",
"rollup-plugin-copy": "^3.5.0",
tailwindcss: "^3.2.7",
typescript: "~4.9.5",
vite: "^4.2.0",
"vite-plugin-pwa": "^0.14.4"
}, os = {
name: Kn,
version: Wn,
private: !1,
description: Yn,
author: Xn,
keywords: Jn,
main: qn,
module: Qn,
types: Zn,
files: es,
scripts: ts,
dependencies: ns,
devDependencies: ss,
"lint-staged": {
"*.{ts,tsx,vue}": [
"pnpm lint:fix"
]
}
}, as = { class: "p-4 space-y-4" }, is = { class: "text-xl font-bold" }, ls = { class: "p-2 space-y-2 rounded-md bg-neutral-100 dark:bg-neutral-700" }, rs = { key: 0 }, ds = { key: 1 }, cs = /* @__PURE__ */ J({
__name: "About",
setup(t) {
const a = He(), m = z(!1), r = z(), d = C(() => !!a.isChatGPTAPI);
async function f() {
try {
m.value = !0;
const { data: p } = await Xt();
r.value = p;
} finally {
m.value = !1;
}
}
return _t(() => {
f();
}), (p, $) => (H(), xe(u(on), { show: m.value }, {
default: x(() => {
var c, h, k, j, A, E;
return [
o("div", as, [
o("h2", is, " Version - " + l(u(os).version), 1),
o("div", ls, [
o("p", null, [
D(l(p.$t("setting.openSource")) + " ", 1),
$[0] || ($[0] = o("a", {
class: "text-blue-600 dark:text-blue-500",
href: "https://github.com/Chanzhaoyu/chatgpt-web",
target: "_blank"
}, " GitHub ", -1)),
D(" " + l(p.$t("setting.freeMIT")), 1)
]),
o("p", null, l(p.$t("setting.stars")), 1)
]),
o("p", null, l(p.$t("setting.api")) + ":" + l(((c = r.value) == null ? void 0 : c.apiModel) ?? "-"), 1),
d.value ? (H(), Q("p", rs, l(p.$t("setting.monthlyUsage")) + ":" + l(((h = r.value) == null ? void 0 : h.usage) ?? "-"), 1)) : ke("", !0),
d.value ? ke("", !0) : (H(), Q("p", ds, l(p.$t("setting.reverseProxy")) + ":" + l(((k = r.value) == null ? void 0 : k.reverseProxy) ?? "-"), 1)),
o("p", null, l(p.$t("setting.timeout")) + ":" + l(((j = r.value) == null ? void 0 : j.timeoutMs) ?? "-"), 1),
o("p", null, l(p.$t("setting.socks")) + ":" + l(((A = r.value) == null ? void 0 : A.socksProxy) ?? "-"), 1),
o("p", null, l(p.$t("setting.httpsProxy")) + ":" + l(((E = r.value) == null ? void 0 : E.httpsProxy) ?? "-"), 1)
])
];
}),
_: 1
}, 8, ["show"]));
}
}), us = { class: "ml-2" }, hs = { class: "min-h-[100px]" }, vs = { class: "ml-2" }, fs = { class: "min-h-[100px]" }, ms = { class: "ml-2" }, bs = /* @__PURE__ */ J({
__name: "index",
props: {
visible: { type: Boolean }
},
emits: ["update:visible"],
setup(t, { emit: a }) {
const m = t, r = a, d = He(), f = C(() => !!d.isChatGPTAPI), p = z("General"), $ = C({
get() {
return m.visible;
},
set(c) {
r("update:visible", c);
}
});
return (c, h) => (H(), xe(u(Jt), {
show: $.value,
"onUpdate:show": h[1] || (h[1] = (k) => $.value = k),
"auto-focus": !1,
preset: "card",
style: { width: "95%", "max-width": "640px" }
}, {
default: x(() => [
o("div", null, [
g(u(qt), {
value: p.value,
"onUpdate:value": h[0] || (h[0] = (k) => p.value = k),
type: "line",
animated: ""
}, {
default: x(() => [
g(u(we), {
name: "General",
tab: "General"
}, {
tab: x(() => [
g(u(K), {
class: "text-lg",
icon: "ri:file-user-line"
}),
o("span", us, l(c.$t("setting.general")), 1)
]),
default: x(() => [
o("div", hs, [
g(Dn)
])
]),
_: 1
}),
f.value ? (H(), xe(u(we), {
key: 0,
name: "Advanced",
tab: "Advanced"
}, {
tab: x(() => [
g(u(K), {
class: "text-lg",
icon: "ri:equalizer-line"
}),
o("span", vs, l(c.$t("setting.advanced")), 1)
]),
default: x(() => [
o("div", fs, [
g(Gn)
])
]),
_: 1
})) : ke("", !0),
g(u(we), {
name: "Config",
tab: "Config"
}, {
tab: x(() => [
g(u(K), {
class: "text-lg",
icon: "ri:list-settings-line"
}),
o("span", ms, l(c.$t("setting.config")), 1)
]),
default: x(() => [
g(cs)
]),
_: 1
})
]),
_: 1
}, 8, ["value"])
])
]),
_: 1
}, 8, ["show"]));
}
});
export {
bs as default
};