qidian-vue-ui 1.0.81 → 1.0.83

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1351,6 +1351,8 @@ const isPromise = (val) => {
1351
1351
  const identifyType = (val) => {
1352
1352
  return toTypeStr(val).replace("[object ", "").replace("]", "").toLowerCase();
1353
1353
  };
1354
+ function noop() {
1355
+ }
1354
1356
  function isEmpty(val) {
1355
1357
  if (val == null) return true;
1356
1358
  if (typeof val === "string" && val.trim() === "") return true;
@@ -11650,6 +11652,673 @@ var __extends = /* @__PURE__ */ (function() {
11650
11652
  })(RSAKey);
11651
11653
  var _a;
11652
11654
  typeof process !== "undefined" ? (_a = __vite_import_meta_env__1) === null || _a === void 0 ? void 0 : _a.npm_package_version : void 0;
11655
+ class JSONRepairError extends Error {
11656
+ constructor(message, position) {
11657
+ super(`${message} at position ${position}`);
11658
+ this.position = position;
11659
+ }
11660
+ }
11661
+ const codeSpace = 32;
11662
+ const codeNewline = 10;
11663
+ const codeTab = 9;
11664
+ const codeReturn = 13;
11665
+ const codeNonBreakingSpace = 160;
11666
+ const codeEnQuad = 8192;
11667
+ const codeHairSpace = 8202;
11668
+ const codeNarrowNoBreakSpace = 8239;
11669
+ const codeMediumMathematicalSpace = 8287;
11670
+ const codeIdeographicSpace = 12288;
11671
+ function isHex(char) {
11672
+ return /^[0-9A-Fa-f]$/.test(char);
11673
+ }
11674
+ function isDigit(char) {
11675
+ return char >= "0" && char <= "9";
11676
+ }
11677
+ function isValidStringCharacter(char) {
11678
+ return char >= " ";
11679
+ }
11680
+ function isDelimiter(char) {
11681
+ return ",:[]/{}()\n+".includes(char);
11682
+ }
11683
+ function isFunctionNameCharStart(char) {
11684
+ return char >= "a" && char <= "z" || char >= "A" && char <= "Z" || char === "_" || char === "$";
11685
+ }
11686
+ function isFunctionNameChar(char) {
11687
+ return char >= "a" && char <= "z" || char >= "A" && char <= "Z" || char === "_" || char === "$" || char >= "0" && char <= "9";
11688
+ }
11689
+ const regexUrlStart = /^(http|https|ftp|mailto|file|data|irc):\/\/$/;
11690
+ const regexUrlChar = /^[A-Za-z0-9-._~:/?#@!$&'()*+;=]$/;
11691
+ function isUnquotedStringDelimiter(char) {
11692
+ return ",[]/{}\n+".includes(char);
11693
+ }
11694
+ function isStartOfValue(char) {
11695
+ return isQuote(char) || regexStartOfValue.test(char);
11696
+ }
11697
+ const regexStartOfValue = /^[[{\w-]$/;
11698
+ function isControlCharacter(char) {
11699
+ return char === "\n" || char === "\r" || char === " " || char === "\b" || char === "\f";
11700
+ }
11701
+ function isWhitespace(text, index2) {
11702
+ const code = text.charCodeAt(index2);
11703
+ return code === codeSpace || code === codeNewline || code === codeTab || code === codeReturn;
11704
+ }
11705
+ function isWhitespaceExceptNewline(text, index2) {
11706
+ const code = text.charCodeAt(index2);
11707
+ return code === codeSpace || code === codeTab || code === codeReturn;
11708
+ }
11709
+ function isSpecialWhitespace(text, index2) {
11710
+ const code = text.charCodeAt(index2);
11711
+ return code === codeNonBreakingSpace || code >= codeEnQuad && code <= codeHairSpace || code === codeNarrowNoBreakSpace || code === codeMediumMathematicalSpace || code === codeIdeographicSpace;
11712
+ }
11713
+ function isQuote(char) {
11714
+ return isDoubleQuoteLike(char) || isSingleQuoteLike(char);
11715
+ }
11716
+ function isDoubleQuoteLike(char) {
11717
+ return char === '"' || char === "“" || char === "”";
11718
+ }
11719
+ function isDoubleQuote(char) {
11720
+ return char === '"';
11721
+ }
11722
+ function isSingleQuoteLike(char) {
11723
+ return char === "'" || char === "‘" || char === "’" || char === "`" || char === "´";
11724
+ }
11725
+ function isSingleQuote(char) {
11726
+ return char === "'";
11727
+ }
11728
+ function stripLastOccurrence(text, textToStrip) {
11729
+ let stripRemainingText = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
11730
+ const index2 = text.lastIndexOf(textToStrip);
11731
+ return index2 !== -1 ? text.substring(0, index2) + (stripRemainingText ? "" : text.substring(index2 + 1)) : text;
11732
+ }
11733
+ function insertBeforeLastWhitespace(text, textToInsert) {
11734
+ let index2 = text.length;
11735
+ if (!isWhitespace(text, index2 - 1)) {
11736
+ return text + textToInsert;
11737
+ }
11738
+ while (isWhitespace(text, index2 - 1)) {
11739
+ index2--;
11740
+ }
11741
+ return text.substring(0, index2) + textToInsert + text.substring(index2);
11742
+ }
11743
+ function removeAtIndex(text, start, count) {
11744
+ return text.substring(0, start) + text.substring(start + count);
11745
+ }
11746
+ function endsWithCommaOrNewline(text) {
11747
+ return /[,\n][ \t\r]*$/.test(text);
11748
+ }
11749
+ const controlCharacters = {
11750
+ "\b": "\\b",
11751
+ "\f": "\\f",
11752
+ "\n": "\\n",
11753
+ "\r": "\\r",
11754
+ " ": "\\t"
11755
+ };
11756
+ const escapeCharacters = {
11757
+ '"': '"',
11758
+ "\\": "\\",
11759
+ "/": "/",
11760
+ b: "\b",
11761
+ f: "\f",
11762
+ n: "\n",
11763
+ r: "\r",
11764
+ t: " "
11765
+ // note that \u is handled separately in parseString()
11766
+ };
11767
+ function jsonrepair(text) {
11768
+ let i = 0;
11769
+ let output = "";
11770
+ parseMarkdownCodeBlock(["```", "[```", "{```"]);
11771
+ const processed = parseValue();
11772
+ if (!processed) {
11773
+ throwUnexpectedEnd();
11774
+ }
11775
+ parseMarkdownCodeBlock(["```", "```]", "```}"]);
11776
+ const processedComma = parseCharacter(",");
11777
+ if (processedComma) {
11778
+ parseWhitespaceAndSkipComments();
11779
+ }
11780
+ if (isStartOfValue(text[i]) && endsWithCommaOrNewline(output)) {
11781
+ if (!processedComma) {
11782
+ output = insertBeforeLastWhitespace(output, ",");
11783
+ }
11784
+ parseNewlineDelimitedJSON();
11785
+ } else if (processedComma) {
11786
+ output = stripLastOccurrence(output, ",");
11787
+ }
11788
+ while (text[i] === "}" || text[i] === "]") {
11789
+ i++;
11790
+ parseWhitespaceAndSkipComments();
11791
+ }
11792
+ if (i >= text.length) {
11793
+ return output;
11794
+ }
11795
+ throwUnexpectedCharacter();
11796
+ function parseValue() {
11797
+ parseWhitespaceAndSkipComments();
11798
+ const processed2 = parseObject() || parseArray() || parseString() || parseNumber() || parseKeywords() || parseUnquotedString(false) || parseRegex();
11799
+ parseWhitespaceAndSkipComments();
11800
+ return processed2;
11801
+ }
11802
+ function parseWhitespaceAndSkipComments() {
11803
+ let skipNewline = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
11804
+ const start = i;
11805
+ let changed = parseWhitespace(skipNewline);
11806
+ do {
11807
+ changed = parseComment();
11808
+ if (changed) {
11809
+ changed = parseWhitespace(skipNewline);
11810
+ }
11811
+ } while (changed);
11812
+ return i > start;
11813
+ }
11814
+ function parseWhitespace(skipNewline) {
11815
+ const _isWhiteSpace = skipNewline ? isWhitespace : isWhitespaceExceptNewline;
11816
+ let whitespace = "";
11817
+ while (true) {
11818
+ if (_isWhiteSpace(text, i)) {
11819
+ whitespace += text[i];
11820
+ i++;
11821
+ } else if (isSpecialWhitespace(text, i)) {
11822
+ whitespace += " ";
11823
+ i++;
11824
+ } else {
11825
+ break;
11826
+ }
11827
+ }
11828
+ if (whitespace.length > 0) {
11829
+ output += whitespace;
11830
+ return true;
11831
+ }
11832
+ return false;
11833
+ }
11834
+ function parseComment() {
11835
+ if (text[i] === "/" && text[i + 1] === "*") {
11836
+ while (i < text.length && !atEndOfBlockComment(text, i)) {
11837
+ i++;
11838
+ }
11839
+ i += 2;
11840
+ return true;
11841
+ }
11842
+ if (text[i] === "/" && text[i + 1] === "/") {
11843
+ while (i < text.length && text[i] !== "\n") {
11844
+ i++;
11845
+ }
11846
+ return true;
11847
+ }
11848
+ return false;
11849
+ }
11850
+ function parseMarkdownCodeBlock(blocks) {
11851
+ if (skipMarkdownCodeBlock(blocks)) {
11852
+ if (isFunctionNameCharStart(text[i])) {
11853
+ while (i < text.length && isFunctionNameChar(text[i])) {
11854
+ i++;
11855
+ }
11856
+ }
11857
+ parseWhitespaceAndSkipComments();
11858
+ return true;
11859
+ }
11860
+ return false;
11861
+ }
11862
+ function skipMarkdownCodeBlock(blocks) {
11863
+ parseWhitespace(true);
11864
+ for (const block of blocks) {
11865
+ const end = i + block.length;
11866
+ if (text.slice(i, end) === block) {
11867
+ i = end;
11868
+ return true;
11869
+ }
11870
+ }
11871
+ return false;
11872
+ }
11873
+ function parseCharacter(char) {
11874
+ if (text[i] === char) {
11875
+ output += text[i];
11876
+ i++;
11877
+ return true;
11878
+ }
11879
+ return false;
11880
+ }
11881
+ function skipCharacter(char) {
11882
+ if (text[i] === char) {
11883
+ i++;
11884
+ return true;
11885
+ }
11886
+ return false;
11887
+ }
11888
+ function skipEscapeCharacter() {
11889
+ return skipCharacter("\\");
11890
+ }
11891
+ function skipEllipsis() {
11892
+ parseWhitespaceAndSkipComments();
11893
+ if (text[i] === "." && text[i + 1] === "." && text[i + 2] === ".") {
11894
+ i += 3;
11895
+ parseWhitespaceAndSkipComments();
11896
+ skipCharacter(",");
11897
+ return true;
11898
+ }
11899
+ return false;
11900
+ }
11901
+ function parseObject() {
11902
+ if (text[i] === "{") {
11903
+ output += "{";
11904
+ i++;
11905
+ parseWhitespaceAndSkipComments();
11906
+ if (skipCharacter(",")) {
11907
+ parseWhitespaceAndSkipComments();
11908
+ }
11909
+ let initial = true;
11910
+ while (i < text.length && text[i] !== "}") {
11911
+ let processedComma2;
11912
+ if (!initial) {
11913
+ processedComma2 = parseCharacter(",");
11914
+ if (!processedComma2) {
11915
+ output = insertBeforeLastWhitespace(output, ",");
11916
+ }
11917
+ parseWhitespaceAndSkipComments();
11918
+ } else {
11919
+ processedComma2 = true;
11920
+ initial = false;
11921
+ }
11922
+ skipEllipsis();
11923
+ const processedKey = parseString() || parseUnquotedString(true);
11924
+ if (!processedKey) {
11925
+ if (text[i] === "}" || text[i] === "{" || text[i] === "]" || text[i] === "[" || text[i] === void 0) {
11926
+ output = stripLastOccurrence(output, ",");
11927
+ } else {
11928
+ throwObjectKeyExpected();
11929
+ }
11930
+ break;
11931
+ }
11932
+ parseWhitespaceAndSkipComments();
11933
+ const processedColon = parseCharacter(":");
11934
+ const truncatedText = i >= text.length;
11935
+ if (!processedColon) {
11936
+ if (isStartOfValue(text[i]) || truncatedText) {
11937
+ output = insertBeforeLastWhitespace(output, ":");
11938
+ } else {
11939
+ throwColonExpected();
11940
+ }
11941
+ }
11942
+ const processedValue = parseValue();
11943
+ if (!processedValue) {
11944
+ if (processedColon || truncatedText) {
11945
+ output += "null";
11946
+ } else {
11947
+ throwColonExpected();
11948
+ }
11949
+ }
11950
+ }
11951
+ if (text[i] === "}") {
11952
+ output += "}";
11953
+ i++;
11954
+ } else {
11955
+ output = insertBeforeLastWhitespace(output, "}");
11956
+ }
11957
+ return true;
11958
+ }
11959
+ return false;
11960
+ }
11961
+ function parseArray() {
11962
+ if (text[i] === "[") {
11963
+ output += "[";
11964
+ i++;
11965
+ parseWhitespaceAndSkipComments();
11966
+ if (skipCharacter(",")) {
11967
+ parseWhitespaceAndSkipComments();
11968
+ }
11969
+ let initial = true;
11970
+ while (i < text.length && text[i] !== "]") {
11971
+ if (!initial) {
11972
+ const processedComma2 = parseCharacter(",");
11973
+ if (!processedComma2) {
11974
+ output = insertBeforeLastWhitespace(output, ",");
11975
+ }
11976
+ } else {
11977
+ initial = false;
11978
+ }
11979
+ skipEllipsis();
11980
+ const processedValue = parseValue();
11981
+ if (!processedValue) {
11982
+ output = stripLastOccurrence(output, ",");
11983
+ break;
11984
+ }
11985
+ }
11986
+ if (text[i] === "]") {
11987
+ output += "]";
11988
+ i++;
11989
+ } else {
11990
+ output = insertBeforeLastWhitespace(output, "]");
11991
+ }
11992
+ return true;
11993
+ }
11994
+ return false;
11995
+ }
11996
+ function parseNewlineDelimitedJSON() {
11997
+ let initial = true;
11998
+ let processedValue = true;
11999
+ while (processedValue) {
12000
+ if (!initial) {
12001
+ const processedComma2 = parseCharacter(",");
12002
+ if (!processedComma2) {
12003
+ output = insertBeforeLastWhitespace(output, ",");
12004
+ }
12005
+ } else {
12006
+ initial = false;
12007
+ }
12008
+ processedValue = parseValue();
12009
+ }
12010
+ if (!processedValue) {
12011
+ output = stripLastOccurrence(output, ",");
12012
+ }
12013
+ output = `[
12014
+ ${output}
12015
+ ]`;
12016
+ }
12017
+ function parseString() {
12018
+ let stopAtDelimiter = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
12019
+ let stopAtIndex = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : -1;
12020
+ let skipEscapeChars = text[i] === "\\";
12021
+ if (skipEscapeChars) {
12022
+ i++;
12023
+ skipEscapeChars = true;
12024
+ }
12025
+ if (isQuote(text[i])) {
12026
+ const isEndQuote = isDoubleQuote(text[i]) ? isDoubleQuote : isSingleQuote(text[i]) ? isSingleQuote : isSingleQuoteLike(text[i]) ? isSingleQuoteLike : isDoubleQuoteLike;
12027
+ const iBefore = i;
12028
+ const oBefore = output.length;
12029
+ let str = '"';
12030
+ i++;
12031
+ while (true) {
12032
+ if (i >= text.length) {
12033
+ const iPrev = prevNonWhitespaceIndex(i - 1);
12034
+ if (!stopAtDelimiter && isDelimiter(text.charAt(iPrev))) {
12035
+ i = iBefore;
12036
+ output = output.substring(0, oBefore);
12037
+ return parseString(true);
12038
+ }
12039
+ str = insertBeforeLastWhitespace(str, '"');
12040
+ output += str;
12041
+ return true;
12042
+ }
12043
+ if (i === stopAtIndex) {
12044
+ str = insertBeforeLastWhitespace(str, '"');
12045
+ output += str;
12046
+ return true;
12047
+ }
12048
+ if (isEndQuote(text[i])) {
12049
+ const iQuote = i;
12050
+ const oQuote = str.length;
12051
+ str += '"';
12052
+ i++;
12053
+ output += str;
12054
+ parseWhitespaceAndSkipComments(false);
12055
+ if (stopAtDelimiter || i >= text.length || isDelimiter(text[i]) || isQuote(text[i]) || isDigit(text[i])) {
12056
+ parseConcatenatedString();
12057
+ return true;
12058
+ }
12059
+ const iPrevChar = prevNonWhitespaceIndex(iQuote - 1);
12060
+ const prevChar = text.charAt(iPrevChar);
12061
+ if (prevChar === ",") {
12062
+ i = iBefore;
12063
+ output = output.substring(0, oBefore);
12064
+ return parseString(false, iPrevChar);
12065
+ }
12066
+ if (isDelimiter(prevChar)) {
12067
+ i = iBefore;
12068
+ output = output.substring(0, oBefore);
12069
+ return parseString(true);
12070
+ }
12071
+ output = output.substring(0, oBefore);
12072
+ i = iQuote + 1;
12073
+ str = `${str.substring(0, oQuote)}\\${str.substring(oQuote)}`;
12074
+ } else if (stopAtDelimiter && isUnquotedStringDelimiter(text[i])) {
12075
+ if (text[i - 1] === ":" && regexUrlStart.test(text.substring(iBefore + 1, i + 2))) {
12076
+ while (i < text.length && regexUrlChar.test(text[i])) {
12077
+ str += text[i];
12078
+ i++;
12079
+ }
12080
+ }
12081
+ str = insertBeforeLastWhitespace(str, '"');
12082
+ output += str;
12083
+ parseConcatenatedString();
12084
+ return true;
12085
+ } else if (text[i] === "\\") {
12086
+ const char = text.charAt(i + 1);
12087
+ const escapeChar = escapeCharacters[char];
12088
+ if (escapeChar !== void 0) {
12089
+ str += text.slice(i, i + 2);
12090
+ i += 2;
12091
+ } else if (char === "u") {
12092
+ let j = 2;
12093
+ while (j < 6 && isHex(text[i + j])) {
12094
+ j++;
12095
+ }
12096
+ if (j === 6) {
12097
+ str += text.slice(i, i + 6);
12098
+ i += 6;
12099
+ } else if (i + j >= text.length) {
12100
+ i = text.length;
12101
+ } else {
12102
+ throwInvalidUnicodeCharacter();
12103
+ }
12104
+ } else {
12105
+ str += char;
12106
+ i += 2;
12107
+ }
12108
+ } else {
12109
+ const char = text.charAt(i);
12110
+ if (char === '"' && text[i - 1] !== "\\") {
12111
+ str += `\\${char}`;
12112
+ i++;
12113
+ } else if (isControlCharacter(char)) {
12114
+ str += controlCharacters[char];
12115
+ i++;
12116
+ } else {
12117
+ if (!isValidStringCharacter(char)) {
12118
+ throwInvalidCharacter(char);
12119
+ }
12120
+ str += char;
12121
+ i++;
12122
+ }
12123
+ }
12124
+ if (skipEscapeChars) {
12125
+ skipEscapeCharacter();
12126
+ }
12127
+ }
12128
+ }
12129
+ return false;
12130
+ }
12131
+ function parseConcatenatedString() {
12132
+ let processed2 = false;
12133
+ parseWhitespaceAndSkipComments();
12134
+ while (text[i] === "+") {
12135
+ processed2 = true;
12136
+ i++;
12137
+ parseWhitespaceAndSkipComments();
12138
+ output = stripLastOccurrence(output, '"', true);
12139
+ const start = output.length;
12140
+ const parsedStr = parseString();
12141
+ if (parsedStr) {
12142
+ output = removeAtIndex(output, start, 1);
12143
+ } else {
12144
+ output = insertBeforeLastWhitespace(output, '"');
12145
+ }
12146
+ }
12147
+ return processed2;
12148
+ }
12149
+ function parseNumber() {
12150
+ const start = i;
12151
+ if (text[i] === "-") {
12152
+ i++;
12153
+ if (atEndOfNumber()) {
12154
+ repairNumberEndingWithNumericSymbol(start);
12155
+ return true;
12156
+ }
12157
+ if (!isDigit(text[i])) {
12158
+ i = start;
12159
+ return false;
12160
+ }
12161
+ }
12162
+ while (isDigit(text[i])) {
12163
+ i++;
12164
+ }
12165
+ if (text[i] === ".") {
12166
+ i++;
12167
+ if (atEndOfNumber()) {
12168
+ repairNumberEndingWithNumericSymbol(start);
12169
+ return true;
12170
+ }
12171
+ if (!isDigit(text[i])) {
12172
+ i = start;
12173
+ return false;
12174
+ }
12175
+ while (isDigit(text[i])) {
12176
+ i++;
12177
+ }
12178
+ }
12179
+ if (text[i] === "e" || text[i] === "E") {
12180
+ i++;
12181
+ if (text[i] === "-" || text[i] === "+") {
12182
+ i++;
12183
+ }
12184
+ if (atEndOfNumber()) {
12185
+ repairNumberEndingWithNumericSymbol(start);
12186
+ return true;
12187
+ }
12188
+ if (!isDigit(text[i])) {
12189
+ i = start;
12190
+ return false;
12191
+ }
12192
+ while (isDigit(text[i])) {
12193
+ i++;
12194
+ }
12195
+ }
12196
+ if (!atEndOfNumber()) {
12197
+ i = start;
12198
+ return false;
12199
+ }
12200
+ if (i > start) {
12201
+ const num = text.slice(start, i);
12202
+ const hasInvalidLeadingZero = /^0\d/.test(num);
12203
+ output += hasInvalidLeadingZero ? `"${num}"` : num;
12204
+ return true;
12205
+ }
12206
+ return false;
12207
+ }
12208
+ function parseKeywords() {
12209
+ return parseKeyword("true", "true") || parseKeyword("false", "false") || parseKeyword("null", "null") || // repair Python keywords True, False, None
12210
+ parseKeyword("True", "true") || parseKeyword("False", "false") || parseKeyword("None", "null");
12211
+ }
12212
+ function parseKeyword(name, value) {
12213
+ if (text.slice(i, i + name.length) === name) {
12214
+ output += value;
12215
+ i += name.length;
12216
+ return true;
12217
+ }
12218
+ return false;
12219
+ }
12220
+ function parseUnquotedString(isKey2) {
12221
+ const start = i;
12222
+ if (isFunctionNameCharStart(text[i])) {
12223
+ while (i < text.length && isFunctionNameChar(text[i])) {
12224
+ i++;
12225
+ }
12226
+ let j = i;
12227
+ while (isWhitespace(text, j)) {
12228
+ j++;
12229
+ }
12230
+ if (text[j] === "(") {
12231
+ i = j + 1;
12232
+ parseValue();
12233
+ if (text[i] === ")") {
12234
+ i++;
12235
+ if (text[i] === ";") {
12236
+ i++;
12237
+ }
12238
+ }
12239
+ return true;
12240
+ }
12241
+ }
12242
+ while (i < text.length && !isUnquotedStringDelimiter(text[i]) && !isQuote(text[i]) && (!isKey2 || text[i] !== ":")) {
12243
+ i++;
12244
+ }
12245
+ if (text[i - 1] === ":" && regexUrlStart.test(text.substring(start, i + 2))) {
12246
+ while (i < text.length && regexUrlChar.test(text[i])) {
12247
+ i++;
12248
+ }
12249
+ }
12250
+ if (i > start) {
12251
+ while (isWhitespace(text, i - 1) && i > 0) {
12252
+ i--;
12253
+ }
12254
+ const symbol = text.slice(start, i);
12255
+ output += symbol === "undefined" ? "null" : JSON.stringify(symbol);
12256
+ if (text[i] === '"') {
12257
+ i++;
12258
+ }
12259
+ return true;
12260
+ }
12261
+ }
12262
+ function parseRegex() {
12263
+ if (text[i] === "/") {
12264
+ const start = i;
12265
+ i++;
12266
+ while (i < text.length && (text[i] !== "/" || text[i - 1] === "\\")) {
12267
+ i++;
12268
+ }
12269
+ i++;
12270
+ output += `"${text.substring(start, i)}"`;
12271
+ return true;
12272
+ }
12273
+ }
12274
+ function prevNonWhitespaceIndex(start) {
12275
+ let prev = start;
12276
+ while (prev > 0 && isWhitespace(text, prev)) {
12277
+ prev--;
12278
+ }
12279
+ return prev;
12280
+ }
12281
+ function atEndOfNumber() {
12282
+ return i >= text.length || isDelimiter(text[i]) || isWhitespace(text, i);
12283
+ }
12284
+ function repairNumberEndingWithNumericSymbol(start) {
12285
+ output += `${text.slice(start, i)}0`;
12286
+ }
12287
+ function throwInvalidCharacter(char) {
12288
+ throw new JSONRepairError(`Invalid character ${JSON.stringify(char)}`, i);
12289
+ }
12290
+ function throwUnexpectedCharacter() {
12291
+ throw new JSONRepairError(`Unexpected character ${JSON.stringify(text[i])}`, i);
12292
+ }
12293
+ function throwUnexpectedEnd() {
12294
+ throw new JSONRepairError("Unexpected end of json string", text.length);
12295
+ }
12296
+ function throwObjectKeyExpected() {
12297
+ throw new JSONRepairError("Object key expected", i);
12298
+ }
12299
+ function throwColonExpected() {
12300
+ throw new JSONRepairError("Colon expected", i);
12301
+ }
12302
+ function throwInvalidUnicodeCharacter() {
12303
+ const chars = text.slice(i, i + 6);
12304
+ throw new JSONRepairError(`Invalid unicode character "${chars}"`, i);
12305
+ }
12306
+ }
12307
+ function atEndOfBlockComment(text, i) {
12308
+ return text[i] === "*" && text[i + 1] === "/";
12309
+ }
12310
+ function parseRelaxedJSON(str, options) {
12311
+ const startObj = str.indexOf("{");
12312
+ const endObj = str.lastIndexOf("}");
12313
+ const startArr = str.indexOf("[");
12314
+ const endArr = str.lastIndexOf("]");
12315
+ if (startObj > -1 && endObj > -1 && endObj > startObj) {
12316
+ str = str.slice(startObj, endObj + 1);
12317
+ } else if (startArr > -1 && endArr > -1 && endArr > startArr) {
12318
+ str = str.slice(startArr, endArr + 1);
12319
+ }
12320
+ return JSON.parse(jsonrepair(str));
12321
+ }
11653
12322
  function to(promise, errorExt) {
11654
12323
  return promise.then((data) => [null, data]).catch((err) => {
11655
12324
  return [err ?? true, void 0];
@@ -11939,7 +12608,42 @@ function useServicePagination({
11939
12608
  };
11940
12609
  }
11941
12610
  const __vite_import_meta_env__ = {};
11942
- __vite_import_meta_env__1?.NODE_ENV !== "production" || __vite_import_meta_env__ && false;
12611
+ const cslType = ["log", "warn", "error"];
12612
+ const isDev = __vite_import_meta_env__1?.NODE_ENV !== "production" || __vite_import_meta_env__ && false;
12613
+ function useCsl(module2) {
12614
+ const toStr = (data) => {
12615
+ if (typeof data === "object") return data.join(".");
12616
+ if (typeof data === "number") return data.toString();
12617
+ return data;
12618
+ };
12619
+ module2 = toStr(module2);
12620
+ const getModule = (childModule) => {
12621
+ if (isEmpty(childModule)) return `[${module2}]`;
12622
+ childModule = toStr(childModule);
12623
+ if (childModule) childModule = "." + childModule;
12624
+ return `[${module2}${childModule}]`;
12625
+ };
12626
+ const core2 = (type = "log", childModule, ...rest) => {
12627
+ if (isEmpty(rest)) {
12628
+ console[type](getModule(), childModule);
12629
+ return;
12630
+ }
12631
+ console[type](getModule(childModule), ...rest);
12632
+ };
12633
+ const csl2 = {
12634
+ useNext(childModule) {
12635
+ return useCsl(getModule(childModule).replace(/\[|\]/g, ""));
12636
+ }
12637
+ };
12638
+ cslType.forEach((item) => {
12639
+ const temp = (childModule, ...rest) => {
12640
+ core2(item, childModule, ...rest);
12641
+ };
12642
+ temp.dev = isDev ? temp : noop;
12643
+ csl2[item] = temp;
12644
+ });
12645
+ return csl2;
12646
+ }
11943
12647
  function useTimer(type = "timeout") {
11944
12648
  const timer = vue.ref(null);
11945
12649
  const clearTimer = () => {
@@ -11989,6 +12693,10 @@ const QdConfigProvider = vue.defineComponent({
11989
12693
  type: Object,
11990
12694
  default: void 0
11991
12695
  },
12696
+ agentChat: {
12697
+ type: Object,
12698
+ default: void 0
12699
+ },
11992
12700
  globalConfig: {
11993
12701
  type: Object,
11994
12702
  default: void 0
@@ -12006,24 +12714,22 @@ const QdConfigProvider = vue.defineComponent({
12006
12714
  vue.provide(PROVIDE_DICT, props.dict);
12007
12715
  vue.provide(PROVIDE_UPLOAD, props.upload);
12008
12716
  vue.provide(PROVIDE_GLOBAL_CONFIG, mergedGlobalConfig);
12009
- if (typeof window !== "undefined") {
12010
- window.__QIDIAN_USER__ = props.user;
12011
- window.__QIDIAN_DICT__ = props.dict;
12012
- }
12013
12717
  vue.watch(
12014
- () => [props.user, props.dict],
12015
- ([newUser, newDict]) => {
12718
+ () => [props.user, props.dict, props.agentChat],
12719
+ ([newUser, newDict, newAgentChat]) => {
12016
12720
  if (typeof window !== "undefined") {
12017
12721
  window.__QIDIAN_USER__ = newUser;
12018
12722
  window.__QIDIAN_DICT__ = newDict;
12723
+ window.__QIDIAN_AGENT_CHAT__ = newAgentChat;
12019
12724
  }
12020
- }
12725
+ },
12726
+ { immediate: true }
12021
12727
  );
12022
12728
  vue.watchEffect(async () => {
12023
12729
  const localeMap = {
12024
12730
  "zh-CN": () => Promise.resolve().then(() => zhCN$1),
12025
- "zh-TW": () => Promise.resolve().then(() => require("./zh-TW-cICAXa5I.js")),
12026
- "en-US": () => Promise.resolve().then(() => require("./en-US-VDFbyOjk.js"))
12731
+ "zh-TW": () => Promise.resolve().then(() => require("./zh-TW-1dtDvCc9.js")),
12732
+ "en-US": () => Promise.resolve().then(() => require("./en-US-_vWm0Hkp.js"))
12027
12733
  };
12028
12734
  const loadLocale = localeMap[props.locale] || localeMap["zh-CN"];
12029
12735
  const [err, res] = await to(
@@ -16497,6 +17203,330 @@ const _sfc_main$7 = /* @__PURE__ */ vue.defineComponent({
16497
17203
  }
16498
17204
  });
16499
17205
  const QdCrudSearch = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["__scopeId", "data-v-13ddedb2"]]);
17206
+ async function getBytes(stream, onChunk) {
17207
+ const reader = stream.getReader();
17208
+ let result;
17209
+ while (!(result = await reader.read()).done) {
17210
+ onChunk(result.value);
17211
+ }
17212
+ }
17213
+ function getLines(onLine) {
17214
+ let buffer;
17215
+ let position;
17216
+ let fieldLength;
17217
+ let discardTrailingNewline = false;
17218
+ return function onChunk(arr) {
17219
+ if (buffer === void 0) {
17220
+ buffer = arr;
17221
+ position = 0;
17222
+ fieldLength = -1;
17223
+ } else {
17224
+ buffer = concat(buffer, arr);
17225
+ }
17226
+ const bufLength = buffer.length;
17227
+ let lineStart = 0;
17228
+ while (position < bufLength) {
17229
+ if (discardTrailingNewline) {
17230
+ if (buffer[position] === 10) {
17231
+ lineStart = ++position;
17232
+ }
17233
+ discardTrailingNewline = false;
17234
+ }
17235
+ let lineEnd = -1;
17236
+ for (; position < bufLength && lineEnd === -1; ++position) {
17237
+ switch (buffer[position]) {
17238
+ case 58:
17239
+ if (fieldLength === -1) {
17240
+ fieldLength = position - lineStart;
17241
+ }
17242
+ break;
17243
+ case 13:
17244
+ discardTrailingNewline = true;
17245
+ case 10:
17246
+ lineEnd = position;
17247
+ break;
17248
+ }
17249
+ }
17250
+ if (lineEnd === -1) {
17251
+ break;
17252
+ }
17253
+ onLine(buffer.subarray(lineStart, lineEnd), fieldLength);
17254
+ lineStart = position;
17255
+ fieldLength = -1;
17256
+ }
17257
+ if (lineStart === bufLength) {
17258
+ buffer = void 0;
17259
+ } else if (lineStart !== 0) {
17260
+ buffer = buffer.subarray(lineStart);
17261
+ position -= lineStart;
17262
+ }
17263
+ };
17264
+ }
17265
+ function getMessages(onId, onRetry, onMessage) {
17266
+ let message = newMessage();
17267
+ const decoder2 = new TextDecoder();
17268
+ return function onLine(line, fieldLength) {
17269
+ if (line.length === 0) {
17270
+ onMessage === null || onMessage === void 0 ? void 0 : onMessage(message);
17271
+ message = newMessage();
17272
+ } else if (fieldLength > 0) {
17273
+ const field = decoder2.decode(line.subarray(0, fieldLength));
17274
+ const valueOffset = fieldLength + (line[fieldLength + 1] === 32 ? 2 : 1);
17275
+ const value = decoder2.decode(line.subarray(valueOffset));
17276
+ switch (field) {
17277
+ case "data":
17278
+ message.data = message.data ? message.data + "\n" + value : value;
17279
+ break;
17280
+ case "event":
17281
+ message.event = value;
17282
+ break;
17283
+ case "id":
17284
+ onId(message.id = value);
17285
+ break;
17286
+ case "retry":
17287
+ const retry = parseInt(value, 10);
17288
+ if (!isNaN(retry)) {
17289
+ onRetry(message.retry = retry);
17290
+ }
17291
+ break;
17292
+ }
17293
+ }
17294
+ };
17295
+ }
17296
+ function concat(a, b) {
17297
+ const res = new Uint8Array(a.length + b.length);
17298
+ res.set(a);
17299
+ res.set(b, a.length);
17300
+ return res;
17301
+ }
17302
+ function newMessage() {
17303
+ return {
17304
+ data: "",
17305
+ event: "",
17306
+ id: "",
17307
+ retry: void 0
17308
+ };
17309
+ }
17310
+ var __rest = function(s, e) {
17311
+ var t = {};
17312
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
17313
+ t[p] = s[p];
17314
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17315
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17316
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
17317
+ t[p[i]] = s[p[i]];
17318
+ }
17319
+ return t;
17320
+ };
17321
+ const EventStreamContentType = "text/event-stream";
17322
+ const DefaultRetryInterval = 1e3;
17323
+ const LastEventId = "last-event-id";
17324
+ function fetchEventSource(input, _a2) {
17325
+ var { signal: inputSignal, headers: inputHeaders, onopen: inputOnOpen, onmessage, onclose, onerror, openWhenHidden, fetch: inputFetch } = _a2, rest = __rest(_a2, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
17326
+ return new Promise((resolve, reject) => {
17327
+ const headers = Object.assign({}, inputHeaders);
17328
+ if (!headers.accept) {
17329
+ headers.accept = EventStreamContentType;
17330
+ }
17331
+ let curRequestController;
17332
+ function onVisibilityChange() {
17333
+ curRequestController.abort();
17334
+ if (!document.hidden) {
17335
+ create();
17336
+ }
17337
+ }
17338
+ if (!openWhenHidden) {
17339
+ document.addEventListener("visibilitychange", onVisibilityChange);
17340
+ }
17341
+ let retryInterval = DefaultRetryInterval;
17342
+ let retryTimer = 0;
17343
+ function dispose() {
17344
+ document.removeEventListener("visibilitychange", onVisibilityChange);
17345
+ window.clearTimeout(retryTimer);
17346
+ curRequestController.abort();
17347
+ }
17348
+ inputSignal === null || inputSignal === void 0 ? void 0 : inputSignal.addEventListener("abort", () => {
17349
+ dispose();
17350
+ resolve();
17351
+ });
17352
+ const fetch = inputFetch !== null && inputFetch !== void 0 ? inputFetch : window.fetch;
17353
+ const onopen = inputOnOpen !== null && inputOnOpen !== void 0 ? inputOnOpen : defaultOnOpen;
17354
+ async function create() {
17355
+ var _a3;
17356
+ curRequestController = new AbortController();
17357
+ try {
17358
+ const response = await fetch(input, Object.assign(Object.assign({}, rest), { headers, signal: curRequestController.signal }));
17359
+ await onopen(response);
17360
+ await getBytes(response.body, getLines(getMessages((id) => {
17361
+ if (id) {
17362
+ headers[LastEventId] = id;
17363
+ } else {
17364
+ delete headers[LastEventId];
17365
+ }
17366
+ }, (retry) => {
17367
+ retryInterval = retry;
17368
+ }, onmessage)));
17369
+ onclose === null || onclose === void 0 ? void 0 : onclose();
17370
+ dispose();
17371
+ resolve();
17372
+ } catch (err) {
17373
+ if (!curRequestController.signal.aborted) {
17374
+ try {
17375
+ const interval = (_a3 = onerror === null || onerror === void 0 ? void 0 : onerror(err)) !== null && _a3 !== void 0 ? _a3 : retryInterval;
17376
+ window.clearTimeout(retryTimer);
17377
+ retryTimer = window.setTimeout(create, interval);
17378
+ } catch (innerErr) {
17379
+ dispose();
17380
+ reject(innerErr);
17381
+ }
17382
+ }
17383
+ }
17384
+ }
17385
+ create();
17386
+ });
17387
+ }
17388
+ function defaultOnOpen(response) {
17389
+ const contentType = response.headers.get("content-type");
17390
+ if (!(contentType === null || contentType === void 0 ? void 0 : contentType.startsWith(EventStreamContentType))) {
17391
+ throw new Error(`Expected content-type to be ${EventStreamContentType}, Actual: ${contentType}`);
17392
+ }
17393
+ }
17394
+ const csl = useCsl("useAgentChat");
17395
+ function useAgentChat(options) {
17396
+ const globalOpt = window.__QIDIAN_AGENT_CHAT__ || {};
17397
+ const mergeOpt = { ...globalOpt, ...options };
17398
+ const loading = vue.ref(false);
17399
+ const agentId = vue.ref(mergeOpt.agentId);
17400
+ const apiKey = vue.ref(mergeOpt.apiKey);
17401
+ const sessionId = vue.ref("");
17402
+ let abortController;
17403
+ async function send({
17404
+ prompt,
17405
+ files,
17406
+ reSend,
17407
+ extParams,
17408
+ refreshSessionId,
17409
+ onOpen,
17410
+ onMessage,
17411
+ onClose,
17412
+ onError
17413
+ }) {
17414
+ const allData = { content: "", reasoning: "" };
17415
+ if (!prompt && isEmpty(files) && isEmpty(extParams)) return allData;
17416
+ loading.value = true;
17417
+ const agInfo = await getAgentInfo();
17418
+ if (!agInfo) {
17419
+ loading.value = false;
17420
+ return allData;
17421
+ }
17422
+ const sId = await getSessionId({ ...agInfo, refreshSessionId });
17423
+ if (!sId) {
17424
+ loading.value = false;
17425
+ return allData;
17426
+ }
17427
+ const getUrl = mergeOpt.getUrl;
17428
+ if (!getUrl) {
17429
+ loading.value = false;
17430
+ console.error("[useAgentChat.getUrl] 必须配置 getUrl 函数");
17431
+ return allData;
17432
+ }
17433
+ abortController = new AbortController();
17434
+ csl.log.dev("send", { ...agInfo, sessionId: sId });
17435
+ return new Promise((resolve, reject) => {
17436
+ fetchEventSource(getUrl(agInfo.agentId, sId), {
17437
+ method: "POST",
17438
+ headers: {
17439
+ "Content-Type": "application/json;charset=UTF-8",
17440
+ Authorization: `Bearer ${agInfo.apiKey}`
17441
+ },
17442
+ signal: abortController?.signal,
17443
+ openWhenHidden: true,
17444
+ body: JSON.stringify({
17445
+ message: prompt || "",
17446
+ re_chat: reSend ?? false,
17447
+ document_list: files,
17448
+ client_id: agInfo.apiKey,
17449
+ client_type: "API_KEY",
17450
+ ...extParams
17451
+ }),
17452
+ onopen: async (res) => {
17453
+ csl.log.dev("onOpen", res);
17454
+ await onOpen?.(res);
17455
+ },
17456
+ onmessage: (res) => {
17457
+ const { data } = res;
17458
+ let reData = { content: "", reasoning: "" };
17459
+ try {
17460
+ reData = parseRelaxedJSON(data);
17461
+ if (reData.content) allData.content += reData.content;
17462
+ if (reData.reasoning) allData.reasoning += reData.reasoning;
17463
+ } catch (err) {
17464
+ console.warn("[useAgentChat.send.onMessage]", err);
17465
+ }
17466
+ csl.log.dev("onMessage", reData);
17467
+ onMessage?.({ data: reData, allData });
17468
+ },
17469
+ onclose: () => {
17470
+ csl.log.dev("onClose", allData);
17471
+ loading.value = false;
17472
+ onClose?.(allData);
17473
+ resolve(allData);
17474
+ },
17475
+ onerror: (err) => {
17476
+ csl.log.dev("onError", err);
17477
+ loading.value = false;
17478
+ onError?.(err);
17479
+ reject(err);
17480
+ throw err;
17481
+ }
17482
+ });
17483
+ });
17484
+ }
17485
+ function stop() {
17486
+ abortController?.abort();
17487
+ }
17488
+ async function getAgentInfo() {
17489
+ if (agentId.value && apiKey.value) {
17490
+ return { agentId: agentId.value, apiKey: apiKey.value };
17491
+ }
17492
+ const getFn = mergeOpt.getAgentInfo;
17493
+ if (!getFn) {
17494
+ console.warn("[useAgentChat.getAgentInfo] 必须配置 agentId、apiKey 或者 getAgentInfo 函数");
17495
+ return;
17496
+ }
17497
+ const [err, res] = await suspectedWrapperPromise(getFn());
17498
+ if (err) return;
17499
+ if (!res?.agentId || !res.apiKey) {
17500
+ console.warn("[useAgentChat.getAgentInfo] 未获取到 agentId、apiKey", res);
17501
+ return;
17502
+ }
17503
+ return res;
17504
+ }
17505
+ async function getSessionId({
17506
+ agentId: agentId2,
17507
+ apiKey: apiKey2,
17508
+ refreshSessionId
17509
+ }) {
17510
+ if (sessionId.value && !refreshSessionId) return sessionId.value;
17511
+ const getFn = mergeOpt.getSessionId;
17512
+ if (!getFn) {
17513
+ console.warn("[useAgentChat.getSessionId] 必须配置 getSessionId 函数");
17514
+ return;
17515
+ }
17516
+ const [err, res] = await suspectedWrapperPromise(getFn(agentId2, apiKey2));
17517
+ if (err) return;
17518
+ sessionId.value = res;
17519
+ return res;
17520
+ }
17521
+ return {
17522
+ loading,
17523
+ agentId,
17524
+ apiKey,
17525
+ sessionId,
17526
+ send,
17527
+ stop
17528
+ };
17529
+ }
16500
17530
  const dictCache = /* @__PURE__ */ new Map();
16501
17531
  const dictPromiseCache = /* @__PURE__ */ new Map();
16502
17532
  function useDict(...args) {
@@ -18534,7 +19564,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
18534
19564
  onWaitingUploadFilesChange: { type: Function }
18535
19565
  }, qdUploadProps),
18536
19566
  emits: ["update:modelValue", "update:files"],
18537
- setup(__props, { emit: __emit }) {
19567
+ setup(__props, { expose: __expose, emit: __emit }) {
18538
19568
  const props = __props;
18539
19569
  const emit = __emit;
18540
19570
  const { modelValue, files: fileList } = /* @__PURE__ */ useVModels(props, emit, {
@@ -18861,6 +19891,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
18861
19891
  vue.onMounted(() => {
18862
19892
  Object.assign(expose, uploadRef.value, { uploadFiles });
18863
19893
  });
19894
+ __expose(expose);
18864
19895
  return (_ctx, _cache) => {
18865
19896
  return vue.openBlock(), vue.createBlock(vue.unref(tdesignVueNext.Upload), vue.mergeProps({
18866
19897
  ref: "upload",
@@ -18952,7 +19983,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
18952
19983
  };
18953
19984
  }
18954
19985
  });
18955
- const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-12f87975"]]);
19986
+ const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-49e8a4e0"]]);
18956
19987
  exports.PROVIDE_FORM_ADD_BEFORE_SUBMIT_QUEUE = PROVIDE_FORM_ADD_BEFORE_SUBMIT_QUEUE;
18957
19988
  exports.PROVIDE_GRID_ITEM_PROPS_KEY = PROVIDE_GRID_ITEM_PROPS_KEY;
18958
19989
  exports.PROVIDE_GRID_WIDTH_KEY = PROVIDE_GRID_WIDTH_KEY;
@@ -18995,9 +20026,10 @@ exports.select = select;
18995
20026
  exports.setValueByPath = setValueByPath;
18996
20027
  exports.table = table;
18997
20028
  exports.tag = tag;
20029
+ exports.useAgentChat = useAgentChat;
18998
20030
  exports.useDict = useDict;
18999
20031
  exports.useDictDynamic = useDictDynamic;
19000
20032
  exports.useDisabled = useDisabled;
19001
20033
  exports.useModal = useModal;
19002
20034
  exports.useReadonly = useReadonly;
19003
- //# sourceMappingURL=index-BlJoQteI.js.map
20035
+ //# sourceMappingURL=index-LWHwXGdo.js.map