encoding-converter-ai 0.1.1 → 0.2.1

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.
package/dist/converter.js CHANGED
@@ -3690,6 +3690,1772 @@ var require_lib = __commonJS({
3690
3690
  }
3691
3691
  });
3692
3692
 
3693
+ // node_modules/picomatch/lib/constants.js
3694
+ var require_constants = __commonJS({
3695
+ "node_modules/picomatch/lib/constants.js"(exports2, module2) {
3696
+ "use strict";
3697
+ var WIN_SLASH = "\\\\/";
3698
+ var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
3699
+ var DEFAULT_MAX_EXTGLOB_RECURSION = 0;
3700
+ var DOT_LITERAL = "\\.";
3701
+ var PLUS_LITERAL = "\\+";
3702
+ var QMARK_LITERAL = "\\?";
3703
+ var SLASH_LITERAL = "\\/";
3704
+ var ONE_CHAR = "(?=.)";
3705
+ var QMARK = "[^/]";
3706
+ var END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
3707
+ var START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
3708
+ var DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
3709
+ var NO_DOT = `(?!${DOT_LITERAL})`;
3710
+ var NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
3711
+ var NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
3712
+ var NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
3713
+ var QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
3714
+ var STAR = `${QMARK}*?`;
3715
+ var SEP = "/";
3716
+ var POSIX_CHARS = {
3717
+ DOT_LITERAL,
3718
+ PLUS_LITERAL,
3719
+ QMARK_LITERAL,
3720
+ SLASH_LITERAL,
3721
+ ONE_CHAR,
3722
+ QMARK,
3723
+ END_ANCHOR,
3724
+ DOTS_SLASH,
3725
+ NO_DOT,
3726
+ NO_DOTS,
3727
+ NO_DOT_SLASH,
3728
+ NO_DOTS_SLASH,
3729
+ QMARK_NO_DOT,
3730
+ STAR,
3731
+ START_ANCHOR,
3732
+ SEP
3733
+ };
3734
+ var WINDOWS_CHARS = {
3735
+ ...POSIX_CHARS,
3736
+ SLASH_LITERAL: `[${WIN_SLASH}]`,
3737
+ QMARK: WIN_NO_SLASH,
3738
+ STAR: `${WIN_NO_SLASH}*?`,
3739
+ DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
3740
+ NO_DOT: `(?!${DOT_LITERAL})`,
3741
+ NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
3742
+ NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
3743
+ NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
3744
+ QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
3745
+ START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
3746
+ END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
3747
+ SEP: "\\"
3748
+ };
3749
+ var POSIX_REGEX_SOURCE = {
3750
+ __proto__: null,
3751
+ alnum: "a-zA-Z0-9",
3752
+ alpha: "a-zA-Z",
3753
+ ascii: "\\x00-\\x7F",
3754
+ blank: " \\t",
3755
+ cntrl: "\\x00-\\x1F\\x7F",
3756
+ digit: "0-9",
3757
+ graph: "\\x21-\\x7E",
3758
+ lower: "a-z",
3759
+ print: "\\x20-\\x7E ",
3760
+ punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
3761
+ space: " \\t\\r\\n\\v\\f",
3762
+ upper: "A-Z",
3763
+ word: "A-Za-z0-9_",
3764
+ xdigit: "A-Fa-f0-9"
3765
+ };
3766
+ module2.exports = {
3767
+ DEFAULT_MAX_EXTGLOB_RECURSION,
3768
+ MAX_LENGTH: 1024 * 64,
3769
+ POSIX_REGEX_SOURCE,
3770
+ // regular expressions
3771
+ REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
3772
+ REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
3773
+ REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
3774
+ REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
3775
+ REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
3776
+ REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
3777
+ // Replace globs with equivalent patterns to reduce parsing time.
3778
+ REPLACEMENTS: {
3779
+ __proto__: null,
3780
+ "***": "*",
3781
+ "**/**": "**",
3782
+ "**/**/**": "**"
3783
+ },
3784
+ // Digits
3785
+ CHAR_0: 48,
3786
+ /* 0 */
3787
+ CHAR_9: 57,
3788
+ /* 9 */
3789
+ // Alphabet chars.
3790
+ CHAR_UPPERCASE_A: 65,
3791
+ /* A */
3792
+ CHAR_LOWERCASE_A: 97,
3793
+ /* a */
3794
+ CHAR_UPPERCASE_Z: 90,
3795
+ /* Z */
3796
+ CHAR_LOWERCASE_Z: 122,
3797
+ /* z */
3798
+ CHAR_LEFT_PARENTHESES: 40,
3799
+ /* ( */
3800
+ CHAR_RIGHT_PARENTHESES: 41,
3801
+ /* ) */
3802
+ CHAR_ASTERISK: 42,
3803
+ /* * */
3804
+ // Non-alphabetic chars.
3805
+ CHAR_AMPERSAND: 38,
3806
+ /* & */
3807
+ CHAR_AT: 64,
3808
+ /* @ */
3809
+ CHAR_BACKWARD_SLASH: 92,
3810
+ /* \ */
3811
+ CHAR_CARRIAGE_RETURN: 13,
3812
+ /* \r */
3813
+ CHAR_CIRCUMFLEX_ACCENT: 94,
3814
+ /* ^ */
3815
+ CHAR_COLON: 58,
3816
+ /* : */
3817
+ CHAR_COMMA: 44,
3818
+ /* , */
3819
+ CHAR_DOT: 46,
3820
+ /* . */
3821
+ CHAR_DOUBLE_QUOTE: 34,
3822
+ /* " */
3823
+ CHAR_EQUAL: 61,
3824
+ /* = */
3825
+ CHAR_EXCLAMATION_MARK: 33,
3826
+ /* ! */
3827
+ CHAR_FORM_FEED: 12,
3828
+ /* \f */
3829
+ CHAR_FORWARD_SLASH: 47,
3830
+ /* / */
3831
+ CHAR_GRAVE_ACCENT: 96,
3832
+ /* ` */
3833
+ CHAR_HASH: 35,
3834
+ /* # */
3835
+ CHAR_HYPHEN_MINUS: 45,
3836
+ /* - */
3837
+ CHAR_LEFT_ANGLE_BRACKET: 60,
3838
+ /* < */
3839
+ CHAR_LEFT_CURLY_BRACE: 123,
3840
+ /* { */
3841
+ CHAR_LEFT_SQUARE_BRACKET: 91,
3842
+ /* [ */
3843
+ CHAR_LINE_FEED: 10,
3844
+ /* \n */
3845
+ CHAR_NO_BREAK_SPACE: 160,
3846
+ /* \u00A0 */
3847
+ CHAR_PERCENT: 37,
3848
+ /* % */
3849
+ CHAR_PLUS: 43,
3850
+ /* + */
3851
+ CHAR_QUESTION_MARK: 63,
3852
+ /* ? */
3853
+ CHAR_RIGHT_ANGLE_BRACKET: 62,
3854
+ /* > */
3855
+ CHAR_RIGHT_CURLY_BRACE: 125,
3856
+ /* } */
3857
+ CHAR_RIGHT_SQUARE_BRACKET: 93,
3858
+ /* ] */
3859
+ CHAR_SEMICOLON: 59,
3860
+ /* ; */
3861
+ CHAR_SINGLE_QUOTE: 39,
3862
+ /* ' */
3863
+ CHAR_SPACE: 32,
3864
+ /* */
3865
+ CHAR_TAB: 9,
3866
+ /* \t */
3867
+ CHAR_UNDERSCORE: 95,
3868
+ /* _ */
3869
+ CHAR_VERTICAL_LINE: 124,
3870
+ /* | */
3871
+ CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
3872
+ /* \uFEFF */
3873
+ /**
3874
+ * Create EXTGLOB_CHARS
3875
+ */
3876
+ extglobChars(chars) {
3877
+ return {
3878
+ "!": { type: "negate", open: "(?:(?!(?:", close: `))${chars.STAR})` },
3879
+ "?": { type: "qmark", open: "(?:", close: ")?" },
3880
+ "+": { type: "plus", open: "(?:", close: ")+" },
3881
+ "*": { type: "star", open: "(?:", close: ")*" },
3882
+ "@": { type: "at", open: "(?:", close: ")" }
3883
+ };
3884
+ },
3885
+ /**
3886
+ * Create GLOB_CHARS
3887
+ */
3888
+ globChars(win32) {
3889
+ return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
3890
+ }
3891
+ };
3892
+ }
3893
+ });
3894
+
3895
+ // node_modules/picomatch/lib/utils.js
3896
+ var require_utils = __commonJS({
3897
+ "node_modules/picomatch/lib/utils.js"(exports2) {
3898
+ "use strict";
3899
+ var {
3900
+ REGEX_BACKSLASH,
3901
+ REGEX_REMOVE_BACKSLASH,
3902
+ REGEX_SPECIAL_CHARS,
3903
+ REGEX_SPECIAL_CHARS_GLOBAL
3904
+ } = require_constants();
3905
+ exports2.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
3906
+ exports2.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
3907
+ exports2.isRegexChar = (str) => str.length === 1 && exports2.hasRegexChars(str);
3908
+ exports2.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
3909
+ exports2.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
3910
+ exports2.isWindows = () => {
3911
+ if (typeof navigator !== "undefined" && navigator.platform) {
3912
+ const platform = navigator.platform.toLowerCase();
3913
+ return platform === "win32" || platform === "windows";
3914
+ }
3915
+ if (typeof process !== "undefined" && process.platform) {
3916
+ return process.platform === "win32";
3917
+ }
3918
+ return false;
3919
+ };
3920
+ exports2.removeBackslashes = (str) => {
3921
+ return str.replace(REGEX_REMOVE_BACKSLASH, (match) => {
3922
+ return match === "\\" ? "" : match;
3923
+ });
3924
+ };
3925
+ exports2.escapeLast = (input, char, lastIdx) => {
3926
+ const idx = input.lastIndexOf(char, lastIdx);
3927
+ if (idx === -1)
3928
+ return input;
3929
+ if (input[idx - 1] === "\\")
3930
+ return exports2.escapeLast(input, char, idx - 1);
3931
+ return `${input.slice(0, idx)}\\${input.slice(idx)}`;
3932
+ };
3933
+ exports2.removePrefix = (input, state = {}) => {
3934
+ let output = input;
3935
+ if (output.startsWith("./")) {
3936
+ output = output.slice(2);
3937
+ state.prefix = "./";
3938
+ }
3939
+ return output;
3940
+ };
3941
+ exports2.wrapOutput = (input, state = {}, options = {}) => {
3942
+ const prepend = options.contains ? "" : "^";
3943
+ const append = options.contains ? "" : "$";
3944
+ let output = `${prepend}(?:${input})${append}`;
3945
+ if (state.negated === true) {
3946
+ output = `(?:^(?!${output}).*$)`;
3947
+ }
3948
+ return output;
3949
+ };
3950
+ exports2.basename = (path4, { windows } = {}) => {
3951
+ const segs = path4.split(windows ? /[\\/]/ : "/");
3952
+ const last = segs[segs.length - 1];
3953
+ if (last === "") {
3954
+ return segs[segs.length - 2];
3955
+ }
3956
+ return last;
3957
+ };
3958
+ }
3959
+ });
3960
+
3961
+ // node_modules/picomatch/lib/scan.js
3962
+ var require_scan = __commonJS({
3963
+ "node_modules/picomatch/lib/scan.js"(exports2, module2) {
3964
+ "use strict";
3965
+ var utils = require_utils();
3966
+ var {
3967
+ CHAR_ASTERISK,
3968
+ /* * */
3969
+ CHAR_AT,
3970
+ /* @ */
3971
+ CHAR_BACKWARD_SLASH,
3972
+ /* \ */
3973
+ CHAR_COMMA,
3974
+ /* , */
3975
+ CHAR_DOT,
3976
+ /* . */
3977
+ CHAR_EXCLAMATION_MARK,
3978
+ /* ! */
3979
+ CHAR_FORWARD_SLASH,
3980
+ /* / */
3981
+ CHAR_LEFT_CURLY_BRACE,
3982
+ /* { */
3983
+ CHAR_LEFT_PARENTHESES,
3984
+ /* ( */
3985
+ CHAR_LEFT_SQUARE_BRACKET,
3986
+ /* [ */
3987
+ CHAR_PLUS,
3988
+ /* + */
3989
+ CHAR_QUESTION_MARK,
3990
+ /* ? */
3991
+ CHAR_RIGHT_CURLY_BRACE,
3992
+ /* } */
3993
+ CHAR_RIGHT_PARENTHESES,
3994
+ /* ) */
3995
+ CHAR_RIGHT_SQUARE_BRACKET
3996
+ /* ] */
3997
+ } = require_constants();
3998
+ var isPathSeparator = (code) => {
3999
+ return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
4000
+ };
4001
+ var depth = (token) => {
4002
+ if (token.isPrefix !== true) {
4003
+ token.depth = token.isGlobstar ? Infinity : 1;
4004
+ }
4005
+ };
4006
+ var scan = (input, options) => {
4007
+ const opts = options || {};
4008
+ const length = input.length - 1;
4009
+ const scanToEnd = opts.parts === true || opts.scanToEnd === true;
4010
+ const slashes = [];
4011
+ const tokens = [];
4012
+ const parts = [];
4013
+ let str = input;
4014
+ let index = -1;
4015
+ let start = 0;
4016
+ let lastIndex = 0;
4017
+ let isBrace = false;
4018
+ let isBracket = false;
4019
+ let isGlob = false;
4020
+ let isExtglob = false;
4021
+ let isGlobstar = false;
4022
+ let braceEscaped = false;
4023
+ let backslashes = false;
4024
+ let negated = false;
4025
+ let negatedExtglob = false;
4026
+ let finished = false;
4027
+ let braces = 0;
4028
+ let prev;
4029
+ let code;
4030
+ let token = { value: "", depth: 0, isGlob: false };
4031
+ const eos = () => index >= length;
4032
+ const peek = () => str.charCodeAt(index + 1);
4033
+ const advance = () => {
4034
+ prev = code;
4035
+ return str.charCodeAt(++index);
4036
+ };
4037
+ while (index < length) {
4038
+ code = advance();
4039
+ let next;
4040
+ if (code === CHAR_BACKWARD_SLASH) {
4041
+ backslashes = token.backslashes = true;
4042
+ code = advance();
4043
+ if (code === CHAR_LEFT_CURLY_BRACE) {
4044
+ braceEscaped = true;
4045
+ }
4046
+ continue;
4047
+ }
4048
+ if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
4049
+ braces++;
4050
+ while (eos() !== true && (code = advance())) {
4051
+ if (code === CHAR_BACKWARD_SLASH) {
4052
+ backslashes = token.backslashes = true;
4053
+ advance();
4054
+ continue;
4055
+ }
4056
+ if (code === CHAR_LEFT_CURLY_BRACE) {
4057
+ braces++;
4058
+ continue;
4059
+ }
4060
+ if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
4061
+ isBrace = token.isBrace = true;
4062
+ isGlob = token.isGlob = true;
4063
+ finished = true;
4064
+ if (scanToEnd === true) {
4065
+ continue;
4066
+ }
4067
+ break;
4068
+ }
4069
+ if (braceEscaped !== true && code === CHAR_COMMA) {
4070
+ isBrace = token.isBrace = true;
4071
+ isGlob = token.isGlob = true;
4072
+ finished = true;
4073
+ if (scanToEnd === true) {
4074
+ continue;
4075
+ }
4076
+ break;
4077
+ }
4078
+ if (code === CHAR_RIGHT_CURLY_BRACE) {
4079
+ braces--;
4080
+ if (braces === 0) {
4081
+ braceEscaped = false;
4082
+ isBrace = token.isBrace = true;
4083
+ finished = true;
4084
+ break;
4085
+ }
4086
+ }
4087
+ }
4088
+ if (scanToEnd === true) {
4089
+ continue;
4090
+ }
4091
+ break;
4092
+ }
4093
+ if (code === CHAR_FORWARD_SLASH) {
4094
+ slashes.push(index);
4095
+ tokens.push(token);
4096
+ token = { value: "", depth: 0, isGlob: false };
4097
+ if (finished === true)
4098
+ continue;
4099
+ if (prev === CHAR_DOT && index === start + 1) {
4100
+ start += 2;
4101
+ continue;
4102
+ }
4103
+ lastIndex = index + 1;
4104
+ continue;
4105
+ }
4106
+ if (opts.noext !== true) {
4107
+ const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
4108
+ if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
4109
+ isGlob = token.isGlob = true;
4110
+ isExtglob = token.isExtglob = true;
4111
+ finished = true;
4112
+ if (code === CHAR_EXCLAMATION_MARK && index === start) {
4113
+ negatedExtglob = true;
4114
+ }
4115
+ if (scanToEnd === true) {
4116
+ while (eos() !== true && (code = advance())) {
4117
+ if (code === CHAR_BACKWARD_SLASH) {
4118
+ backslashes = token.backslashes = true;
4119
+ code = advance();
4120
+ continue;
4121
+ }
4122
+ if (code === CHAR_RIGHT_PARENTHESES) {
4123
+ isGlob = token.isGlob = true;
4124
+ finished = true;
4125
+ break;
4126
+ }
4127
+ }
4128
+ continue;
4129
+ }
4130
+ break;
4131
+ }
4132
+ }
4133
+ if (code === CHAR_ASTERISK) {
4134
+ if (prev === CHAR_ASTERISK)
4135
+ isGlobstar = token.isGlobstar = true;
4136
+ isGlob = token.isGlob = true;
4137
+ finished = true;
4138
+ if (scanToEnd === true) {
4139
+ continue;
4140
+ }
4141
+ break;
4142
+ }
4143
+ if (code === CHAR_QUESTION_MARK) {
4144
+ isGlob = token.isGlob = true;
4145
+ finished = true;
4146
+ if (scanToEnd === true) {
4147
+ continue;
4148
+ }
4149
+ break;
4150
+ }
4151
+ if (code === CHAR_LEFT_SQUARE_BRACKET) {
4152
+ while (eos() !== true && (next = advance())) {
4153
+ if (next === CHAR_BACKWARD_SLASH) {
4154
+ backslashes = token.backslashes = true;
4155
+ advance();
4156
+ continue;
4157
+ }
4158
+ if (next === CHAR_RIGHT_SQUARE_BRACKET) {
4159
+ isBracket = token.isBracket = true;
4160
+ isGlob = token.isGlob = true;
4161
+ finished = true;
4162
+ break;
4163
+ }
4164
+ }
4165
+ if (scanToEnd === true) {
4166
+ continue;
4167
+ }
4168
+ break;
4169
+ }
4170
+ if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
4171
+ negated = token.negated = true;
4172
+ start++;
4173
+ continue;
4174
+ }
4175
+ if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
4176
+ isGlob = token.isGlob = true;
4177
+ if (scanToEnd === true) {
4178
+ while (eos() !== true && (code = advance())) {
4179
+ if (code === CHAR_LEFT_PARENTHESES) {
4180
+ backslashes = token.backslashes = true;
4181
+ code = advance();
4182
+ continue;
4183
+ }
4184
+ if (code === CHAR_RIGHT_PARENTHESES) {
4185
+ finished = true;
4186
+ break;
4187
+ }
4188
+ }
4189
+ continue;
4190
+ }
4191
+ break;
4192
+ }
4193
+ if (isGlob === true) {
4194
+ finished = true;
4195
+ if (scanToEnd === true) {
4196
+ continue;
4197
+ }
4198
+ break;
4199
+ }
4200
+ }
4201
+ if (opts.noext === true) {
4202
+ isExtglob = false;
4203
+ isGlob = false;
4204
+ }
4205
+ let base = str;
4206
+ let prefix = "";
4207
+ let glob = "";
4208
+ if (start > 0) {
4209
+ prefix = str.slice(0, start);
4210
+ str = str.slice(start);
4211
+ lastIndex -= start;
4212
+ }
4213
+ if (base && isGlob === true && lastIndex > 0) {
4214
+ base = str.slice(0, lastIndex);
4215
+ glob = str.slice(lastIndex);
4216
+ } else if (isGlob === true) {
4217
+ base = "";
4218
+ glob = str;
4219
+ } else {
4220
+ base = str;
4221
+ }
4222
+ if (base && base !== "" && base !== "/" && base !== str) {
4223
+ if (isPathSeparator(base.charCodeAt(base.length - 1))) {
4224
+ base = base.slice(0, -1);
4225
+ }
4226
+ }
4227
+ if (opts.unescape === true) {
4228
+ if (glob)
4229
+ glob = utils.removeBackslashes(glob);
4230
+ if (base && backslashes === true) {
4231
+ base = utils.removeBackslashes(base);
4232
+ }
4233
+ }
4234
+ const state = {
4235
+ prefix,
4236
+ input,
4237
+ start,
4238
+ base,
4239
+ glob,
4240
+ isBrace,
4241
+ isBracket,
4242
+ isGlob,
4243
+ isExtglob,
4244
+ isGlobstar,
4245
+ negated,
4246
+ negatedExtglob
4247
+ };
4248
+ if (opts.tokens === true) {
4249
+ state.maxDepth = 0;
4250
+ if (!isPathSeparator(code)) {
4251
+ tokens.push(token);
4252
+ }
4253
+ state.tokens = tokens;
4254
+ }
4255
+ if (opts.parts === true || opts.tokens === true) {
4256
+ let prevIndex;
4257
+ for (let idx = 0; idx < slashes.length; idx++) {
4258
+ const n = prevIndex ? prevIndex + 1 : start;
4259
+ const i = slashes[idx];
4260
+ const value = input.slice(n, i);
4261
+ if (opts.tokens) {
4262
+ if (idx === 0 && start !== 0) {
4263
+ tokens[idx].isPrefix = true;
4264
+ tokens[idx].value = prefix;
4265
+ } else {
4266
+ tokens[idx].value = value;
4267
+ }
4268
+ depth(tokens[idx]);
4269
+ state.maxDepth += tokens[idx].depth;
4270
+ }
4271
+ if (idx !== 0 || value !== "") {
4272
+ parts.push(value);
4273
+ }
4274
+ prevIndex = i;
4275
+ }
4276
+ if (prevIndex && prevIndex + 1 < input.length) {
4277
+ const value = input.slice(prevIndex + 1);
4278
+ parts.push(value);
4279
+ if (opts.tokens) {
4280
+ tokens[tokens.length - 1].value = value;
4281
+ depth(tokens[tokens.length - 1]);
4282
+ state.maxDepth += tokens[tokens.length - 1].depth;
4283
+ }
4284
+ }
4285
+ state.slashes = slashes;
4286
+ state.parts = parts;
4287
+ }
4288
+ return state;
4289
+ };
4290
+ module2.exports = scan;
4291
+ }
4292
+ });
4293
+
4294
+ // node_modules/picomatch/lib/parse.js
4295
+ var require_parse = __commonJS({
4296
+ "node_modules/picomatch/lib/parse.js"(exports2, module2) {
4297
+ "use strict";
4298
+ var constants = require_constants();
4299
+ var utils = require_utils();
4300
+ var {
4301
+ MAX_LENGTH,
4302
+ POSIX_REGEX_SOURCE,
4303
+ REGEX_NON_SPECIAL_CHARS,
4304
+ REGEX_SPECIAL_CHARS_BACKREF,
4305
+ REPLACEMENTS
4306
+ } = constants;
4307
+ var expandRange = (args, options) => {
4308
+ if (typeof options.expandRange === "function") {
4309
+ return options.expandRange(...args, options);
4310
+ }
4311
+ args.sort();
4312
+ const value = `[${args.join("-")}]`;
4313
+ try {
4314
+ new RegExp(value);
4315
+ } catch (ex) {
4316
+ return args.map((v) => utils.escapeRegex(v)).join("..");
4317
+ }
4318
+ return value;
4319
+ };
4320
+ var syntaxError = (type, char) => {
4321
+ return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
4322
+ };
4323
+ var splitTopLevel = (input) => {
4324
+ const parts = [];
4325
+ let bracket = 0;
4326
+ let paren = 0;
4327
+ let quote = 0;
4328
+ let value = "";
4329
+ let escaped = false;
4330
+ for (const ch of input) {
4331
+ if (escaped === true) {
4332
+ value += ch;
4333
+ escaped = false;
4334
+ continue;
4335
+ }
4336
+ if (ch === "\\") {
4337
+ value += ch;
4338
+ escaped = true;
4339
+ continue;
4340
+ }
4341
+ if (ch === '"') {
4342
+ quote = quote === 1 ? 0 : 1;
4343
+ value += ch;
4344
+ continue;
4345
+ }
4346
+ if (quote === 0) {
4347
+ if (ch === "[") {
4348
+ bracket++;
4349
+ } else if (ch === "]" && bracket > 0) {
4350
+ bracket--;
4351
+ } else if (bracket === 0) {
4352
+ if (ch === "(") {
4353
+ paren++;
4354
+ } else if (ch === ")" && paren > 0) {
4355
+ paren--;
4356
+ } else if (ch === "|" && paren === 0) {
4357
+ parts.push(value);
4358
+ value = "";
4359
+ continue;
4360
+ }
4361
+ }
4362
+ }
4363
+ value += ch;
4364
+ }
4365
+ parts.push(value);
4366
+ return parts;
4367
+ };
4368
+ var isPlainBranch = (branch) => {
4369
+ let escaped = false;
4370
+ for (const ch of branch) {
4371
+ if (escaped === true) {
4372
+ escaped = false;
4373
+ continue;
4374
+ }
4375
+ if (ch === "\\") {
4376
+ escaped = true;
4377
+ continue;
4378
+ }
4379
+ if (/[?*+@!()[\]{}]/.test(ch)) {
4380
+ return false;
4381
+ }
4382
+ }
4383
+ return true;
4384
+ };
4385
+ var normalizeSimpleBranch = (branch) => {
4386
+ let value = branch.trim();
4387
+ let changed = true;
4388
+ while (changed === true) {
4389
+ changed = false;
4390
+ if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
4391
+ value = value.slice(2, -1);
4392
+ changed = true;
4393
+ }
4394
+ }
4395
+ if (!isPlainBranch(value)) {
4396
+ return;
4397
+ }
4398
+ return value.replace(/\\(.)/g, "$1");
4399
+ };
4400
+ var hasRepeatedCharPrefixOverlap = (branches) => {
4401
+ const values = branches.map(normalizeSimpleBranch).filter(Boolean);
4402
+ for (let i = 0; i < values.length; i++) {
4403
+ for (let j = i + 1; j < values.length; j++) {
4404
+ const a = values[i];
4405
+ const b = values[j];
4406
+ const char = a[0];
4407
+ if (!char || a !== char.repeat(a.length) || b !== char.repeat(b.length)) {
4408
+ continue;
4409
+ }
4410
+ if (a === b || a.startsWith(b) || b.startsWith(a)) {
4411
+ return true;
4412
+ }
4413
+ }
4414
+ }
4415
+ return false;
4416
+ };
4417
+ var parseRepeatedExtglob = (pattern, requireEnd = true) => {
4418
+ if (pattern[0] !== "+" && pattern[0] !== "*" || pattern[1] !== "(") {
4419
+ return;
4420
+ }
4421
+ let bracket = 0;
4422
+ let paren = 0;
4423
+ let quote = 0;
4424
+ let escaped = false;
4425
+ for (let i = 1; i < pattern.length; i++) {
4426
+ const ch = pattern[i];
4427
+ if (escaped === true) {
4428
+ escaped = false;
4429
+ continue;
4430
+ }
4431
+ if (ch === "\\") {
4432
+ escaped = true;
4433
+ continue;
4434
+ }
4435
+ if (ch === '"') {
4436
+ quote = quote === 1 ? 0 : 1;
4437
+ continue;
4438
+ }
4439
+ if (quote === 1) {
4440
+ continue;
4441
+ }
4442
+ if (ch === "[") {
4443
+ bracket++;
4444
+ continue;
4445
+ }
4446
+ if (ch === "]" && bracket > 0) {
4447
+ bracket--;
4448
+ continue;
4449
+ }
4450
+ if (bracket > 0) {
4451
+ continue;
4452
+ }
4453
+ if (ch === "(") {
4454
+ paren++;
4455
+ continue;
4456
+ }
4457
+ if (ch === ")") {
4458
+ paren--;
4459
+ if (paren === 0) {
4460
+ if (requireEnd === true && i !== pattern.length - 1) {
4461
+ return;
4462
+ }
4463
+ return {
4464
+ type: pattern[0],
4465
+ body: pattern.slice(2, i),
4466
+ end: i
4467
+ };
4468
+ }
4469
+ }
4470
+ }
4471
+ };
4472
+ var getStarExtglobSequenceOutput = (pattern) => {
4473
+ let index = 0;
4474
+ const chars = [];
4475
+ while (index < pattern.length) {
4476
+ const match = parseRepeatedExtglob(pattern.slice(index), false);
4477
+ if (!match || match.type !== "*") {
4478
+ return;
4479
+ }
4480
+ const branches = splitTopLevel(match.body).map((branch2) => branch2.trim());
4481
+ if (branches.length !== 1) {
4482
+ return;
4483
+ }
4484
+ const branch = normalizeSimpleBranch(branches[0]);
4485
+ if (!branch || branch.length !== 1) {
4486
+ return;
4487
+ }
4488
+ chars.push(branch);
4489
+ index += match.end + 1;
4490
+ }
4491
+ if (chars.length < 1) {
4492
+ return;
4493
+ }
4494
+ const source = chars.length === 1 ? utils.escapeRegex(chars[0]) : `[${chars.map((ch) => utils.escapeRegex(ch)).join("")}]`;
4495
+ return `${source}*`;
4496
+ };
4497
+ var repeatedExtglobRecursion = (pattern) => {
4498
+ let depth = 0;
4499
+ let value = pattern.trim();
4500
+ let match = parseRepeatedExtglob(value);
4501
+ while (match) {
4502
+ depth++;
4503
+ value = match.body.trim();
4504
+ match = parseRepeatedExtglob(value);
4505
+ }
4506
+ return depth;
4507
+ };
4508
+ var analyzeRepeatedExtglob = (body, options) => {
4509
+ if (options.maxExtglobRecursion === false) {
4510
+ return { risky: false };
4511
+ }
4512
+ const max = typeof options.maxExtglobRecursion === "number" ? options.maxExtglobRecursion : constants.DEFAULT_MAX_EXTGLOB_RECURSION;
4513
+ const branches = splitTopLevel(body).map((branch) => branch.trim());
4514
+ if (branches.length > 1) {
4515
+ if (branches.some((branch) => branch === "") || branches.some((branch) => /^[*?]+$/.test(branch)) || hasRepeatedCharPrefixOverlap(branches)) {
4516
+ return { risky: true };
4517
+ }
4518
+ }
4519
+ for (const branch of branches) {
4520
+ const safeOutput = getStarExtglobSequenceOutput(branch);
4521
+ if (safeOutput) {
4522
+ return { risky: true, safeOutput };
4523
+ }
4524
+ if (repeatedExtglobRecursion(branch) > max) {
4525
+ return { risky: true };
4526
+ }
4527
+ }
4528
+ return { risky: false };
4529
+ };
4530
+ var parse = (input, options) => {
4531
+ if (typeof input !== "string") {
4532
+ throw new TypeError("Expected a string");
4533
+ }
4534
+ input = REPLACEMENTS[input] || input;
4535
+ const opts = { ...options };
4536
+ const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
4537
+ let len = input.length;
4538
+ if (len > max) {
4539
+ throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
4540
+ }
4541
+ const bos = { type: "bos", value: "", output: opts.prepend || "" };
4542
+ const tokens = [bos];
4543
+ const capture = opts.capture ? "" : "?:";
4544
+ const PLATFORM_CHARS = constants.globChars(opts.windows);
4545
+ const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
4546
+ const {
4547
+ DOT_LITERAL,
4548
+ PLUS_LITERAL,
4549
+ SLASH_LITERAL,
4550
+ ONE_CHAR,
4551
+ DOTS_SLASH,
4552
+ NO_DOT,
4553
+ NO_DOT_SLASH,
4554
+ NO_DOTS_SLASH,
4555
+ QMARK,
4556
+ QMARK_NO_DOT,
4557
+ STAR,
4558
+ START_ANCHOR
4559
+ } = PLATFORM_CHARS;
4560
+ const globstar = (opts2) => {
4561
+ return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
4562
+ };
4563
+ const nodot = opts.dot ? "" : NO_DOT;
4564
+ const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
4565
+ let star = opts.bash === true ? globstar(opts) : STAR;
4566
+ if (opts.capture) {
4567
+ star = `(${star})`;
4568
+ }
4569
+ if (typeof opts.noext === "boolean") {
4570
+ opts.noextglob = opts.noext;
4571
+ }
4572
+ const state = {
4573
+ input,
4574
+ index: -1,
4575
+ start: 0,
4576
+ dot: opts.dot === true,
4577
+ consumed: "",
4578
+ output: "",
4579
+ prefix: "",
4580
+ backtrack: false,
4581
+ negated: false,
4582
+ brackets: 0,
4583
+ braces: 0,
4584
+ parens: 0,
4585
+ quotes: 0,
4586
+ globstar: false,
4587
+ tokens
4588
+ };
4589
+ input = utils.removePrefix(input, state);
4590
+ len = input.length;
4591
+ const extglobs = [];
4592
+ const braces = [];
4593
+ const stack = [];
4594
+ let prev = bos;
4595
+ let value;
4596
+ const eos = () => state.index === len - 1;
4597
+ const peek = state.peek = (n = 1) => input[state.index + n];
4598
+ const advance = state.advance = () => input[++state.index] || "";
4599
+ const remaining = () => input.slice(state.index + 1);
4600
+ const consume = (value2 = "", num = 0) => {
4601
+ state.consumed += value2;
4602
+ state.index += num;
4603
+ };
4604
+ const append = (token) => {
4605
+ state.output += token.output != null ? token.output : token.value;
4606
+ consume(token.value);
4607
+ };
4608
+ const negate = () => {
4609
+ let count = 1;
4610
+ while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
4611
+ advance();
4612
+ state.start++;
4613
+ count++;
4614
+ }
4615
+ if (count % 2 === 0) {
4616
+ return false;
4617
+ }
4618
+ state.negated = true;
4619
+ state.start++;
4620
+ return true;
4621
+ };
4622
+ const increment = (type) => {
4623
+ state[type]++;
4624
+ stack.push(type);
4625
+ };
4626
+ const decrement = (type) => {
4627
+ state[type]--;
4628
+ stack.pop();
4629
+ };
4630
+ const push = (tok) => {
4631
+ if (prev.type === "globstar") {
4632
+ const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
4633
+ const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
4634
+ if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
4635
+ state.output = state.output.slice(0, -prev.output.length);
4636
+ prev.type = "star";
4637
+ prev.value = "*";
4638
+ prev.output = star;
4639
+ state.output += prev.output;
4640
+ }
4641
+ }
4642
+ if (extglobs.length && tok.type !== "paren") {
4643
+ extglobs[extglobs.length - 1].inner += tok.value;
4644
+ }
4645
+ if (tok.value || tok.output)
4646
+ append(tok);
4647
+ if (prev && prev.type === "text" && tok.type === "text") {
4648
+ prev.output = (prev.output || prev.value) + tok.value;
4649
+ prev.value += tok.value;
4650
+ return;
4651
+ }
4652
+ tok.prev = prev;
4653
+ tokens.push(tok);
4654
+ prev = tok;
4655
+ };
4656
+ const extglobOpen = (type, value2) => {
4657
+ const token = { ...EXTGLOB_CHARS[value2], conditions: 1, inner: "" };
4658
+ token.prev = prev;
4659
+ token.parens = state.parens;
4660
+ token.output = state.output;
4661
+ token.startIndex = state.index;
4662
+ token.tokensIndex = tokens.length;
4663
+ const output = (opts.capture ? "(" : "") + token.open;
4664
+ increment("parens");
4665
+ push({ type, value: value2, output: state.output ? "" : ONE_CHAR });
4666
+ push({ type: "paren", extglob: true, value: advance(), output });
4667
+ extglobs.push(token);
4668
+ };
4669
+ const extglobClose = (token) => {
4670
+ const literal = input.slice(token.startIndex, state.index + 1);
4671
+ const body = input.slice(token.startIndex + 2, state.index);
4672
+ const analysis = analyzeRepeatedExtglob(body, opts);
4673
+ if ((token.type === "plus" || token.type === "star") && analysis.risky) {
4674
+ const safeOutput = analysis.safeOutput ? (token.output ? "" : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput) : void 0;
4675
+ const open2 = tokens[token.tokensIndex];
4676
+ open2.type = "text";
4677
+ open2.value = literal;
4678
+ open2.output = safeOutput || utils.escapeRegex(literal);
4679
+ for (let i = token.tokensIndex + 1; i < tokens.length; i++) {
4680
+ tokens[i].value = "";
4681
+ tokens[i].output = "";
4682
+ delete tokens[i].suffix;
4683
+ }
4684
+ state.output = token.output + open2.output;
4685
+ state.backtrack = true;
4686
+ push({ type: "paren", extglob: true, value, output: "" });
4687
+ decrement("parens");
4688
+ return;
4689
+ }
4690
+ let output = token.close + (opts.capture ? ")" : "");
4691
+ let rest;
4692
+ if (token.type === "negate") {
4693
+ let extglobStar = star;
4694
+ if (token.inner && token.inner.length > 1 && token.inner.includes("/")) {
4695
+ extglobStar = globstar(opts);
4696
+ }
4697
+ if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
4698
+ output = token.close = `)$))${extglobStar}`;
4699
+ }
4700
+ if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
4701
+ const expression = parse(rest, { ...options, fastpaths: false }).output;
4702
+ output = token.close = `)${expression})${extglobStar})`;
4703
+ }
4704
+ if (token.prev.type === "bos") {
4705
+ state.negatedExtglob = true;
4706
+ }
4707
+ }
4708
+ push({ type: "paren", extglob: true, value, output });
4709
+ decrement("parens");
4710
+ };
4711
+ if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
4712
+ let backslashes = false;
4713
+ let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
4714
+ if (first === "\\") {
4715
+ backslashes = true;
4716
+ return m;
4717
+ }
4718
+ if (first === "?") {
4719
+ if (esc) {
4720
+ return esc + first + (rest ? QMARK.repeat(rest.length) : "");
4721
+ }
4722
+ if (index === 0) {
4723
+ return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : "");
4724
+ }
4725
+ return QMARK.repeat(chars.length);
4726
+ }
4727
+ if (first === ".") {
4728
+ return DOT_LITERAL.repeat(chars.length);
4729
+ }
4730
+ if (first === "*") {
4731
+ if (esc) {
4732
+ return esc + first + (rest ? star : "");
4733
+ }
4734
+ return star;
4735
+ }
4736
+ return esc ? m : `\\${m}`;
4737
+ });
4738
+ if (backslashes === true) {
4739
+ if (opts.unescape === true) {
4740
+ output = output.replace(/\\/g, "");
4741
+ } else {
4742
+ output = output.replace(/\\+/g, (m) => {
4743
+ return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
4744
+ });
4745
+ }
4746
+ }
4747
+ if (output === input && opts.contains === true) {
4748
+ state.output = input;
4749
+ return state;
4750
+ }
4751
+ state.output = utils.wrapOutput(output, state, options);
4752
+ return state;
4753
+ }
4754
+ while (!eos()) {
4755
+ value = advance();
4756
+ if (value === "\0") {
4757
+ continue;
4758
+ }
4759
+ if (value === "\\") {
4760
+ const next = peek();
4761
+ if (next === "/" && opts.bash !== true) {
4762
+ continue;
4763
+ }
4764
+ if (next === "." || next === ";") {
4765
+ continue;
4766
+ }
4767
+ if (!next) {
4768
+ value += "\\";
4769
+ push({ type: "text", value });
4770
+ continue;
4771
+ }
4772
+ const match = /^\\+/.exec(remaining());
4773
+ let slashes = 0;
4774
+ if (match && match[0].length > 2) {
4775
+ slashes = match[0].length;
4776
+ state.index += slashes;
4777
+ if (slashes % 2 !== 0) {
4778
+ value += "\\";
4779
+ }
4780
+ }
4781
+ if (opts.unescape === true) {
4782
+ value = advance();
4783
+ } else {
4784
+ value += advance();
4785
+ }
4786
+ if (state.brackets === 0) {
4787
+ push({ type: "text", value });
4788
+ continue;
4789
+ }
4790
+ }
4791
+ if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
4792
+ if (opts.posix !== false && value === ":") {
4793
+ const inner = prev.value.slice(1);
4794
+ if (inner.includes("[")) {
4795
+ prev.posix = true;
4796
+ if (inner.includes(":")) {
4797
+ const idx = prev.value.lastIndexOf("[");
4798
+ const pre = prev.value.slice(0, idx);
4799
+ const rest2 = prev.value.slice(idx + 2);
4800
+ const posix = POSIX_REGEX_SOURCE[rest2];
4801
+ if (posix) {
4802
+ prev.value = pre + posix;
4803
+ state.backtrack = true;
4804
+ advance();
4805
+ if (!bos.output && tokens.indexOf(prev) === 1) {
4806
+ bos.output = ONE_CHAR;
4807
+ }
4808
+ continue;
4809
+ }
4810
+ }
4811
+ }
4812
+ }
4813
+ if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") {
4814
+ value = `\\${value}`;
4815
+ }
4816
+ if (value === "]" && (prev.value === "[" || prev.value === "[^")) {
4817
+ value = `\\${value}`;
4818
+ }
4819
+ if (opts.posix === true && value === "!" && prev.value === "[") {
4820
+ value = "^";
4821
+ }
4822
+ prev.value += value;
4823
+ append({ value });
4824
+ continue;
4825
+ }
4826
+ if (state.quotes === 1 && value !== '"') {
4827
+ value = utils.escapeRegex(value);
4828
+ prev.value += value;
4829
+ append({ value });
4830
+ continue;
4831
+ }
4832
+ if (value === '"') {
4833
+ state.quotes = state.quotes === 1 ? 0 : 1;
4834
+ if (opts.keepQuotes === true) {
4835
+ push({ type: "text", value });
4836
+ }
4837
+ continue;
4838
+ }
4839
+ if (value === "(") {
4840
+ increment("parens");
4841
+ push({ type: "paren", value });
4842
+ continue;
4843
+ }
4844
+ if (value === ")") {
4845
+ if (state.parens === 0 && opts.strictBrackets === true) {
4846
+ throw new SyntaxError(syntaxError("opening", "("));
4847
+ }
4848
+ const extglob = extglobs[extglobs.length - 1];
4849
+ if (extglob && state.parens === extglob.parens + 1) {
4850
+ extglobClose(extglobs.pop());
4851
+ continue;
4852
+ }
4853
+ push({ type: "paren", value, output: state.parens ? ")" : "\\)" });
4854
+ decrement("parens");
4855
+ continue;
4856
+ }
4857
+ if (value === "[") {
4858
+ if (opts.nobracket === true || !remaining().includes("]")) {
4859
+ if (opts.nobracket !== true && opts.strictBrackets === true) {
4860
+ throw new SyntaxError(syntaxError("closing", "]"));
4861
+ }
4862
+ value = `\\${value}`;
4863
+ } else {
4864
+ increment("brackets");
4865
+ }
4866
+ push({ type: "bracket", value });
4867
+ continue;
4868
+ }
4869
+ if (value === "]") {
4870
+ if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
4871
+ push({ type: "text", value, output: `\\${value}` });
4872
+ continue;
4873
+ }
4874
+ if (state.brackets === 0) {
4875
+ if (opts.strictBrackets === true) {
4876
+ throw new SyntaxError(syntaxError("opening", "["));
4877
+ }
4878
+ push({ type: "text", value, output: `\\${value}` });
4879
+ continue;
4880
+ }
4881
+ decrement("brackets");
4882
+ const prevValue = prev.value.slice(1);
4883
+ if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) {
4884
+ value = `/${value}`;
4885
+ }
4886
+ prev.value += value;
4887
+ append({ value });
4888
+ if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) {
4889
+ continue;
4890
+ }
4891
+ const escaped = utils.escapeRegex(prev.value);
4892
+ state.output = state.output.slice(0, -prev.value.length);
4893
+ if (opts.literalBrackets === true) {
4894
+ state.output += escaped;
4895
+ prev.value = escaped;
4896
+ continue;
4897
+ }
4898
+ prev.value = `(${capture}${escaped}|${prev.value})`;
4899
+ state.output += prev.value;
4900
+ continue;
4901
+ }
4902
+ if (value === "{" && opts.nobrace !== true) {
4903
+ increment("braces");
4904
+ const open2 = {
4905
+ type: "brace",
4906
+ value,
4907
+ output: "(",
4908
+ outputIndex: state.output.length,
4909
+ tokensIndex: state.tokens.length
4910
+ };
4911
+ braces.push(open2);
4912
+ push(open2);
4913
+ continue;
4914
+ }
4915
+ if (value === "}") {
4916
+ const brace = braces[braces.length - 1];
4917
+ if (opts.nobrace === true || !brace) {
4918
+ push({ type: "text", value, output: value });
4919
+ continue;
4920
+ }
4921
+ let output = ")";
4922
+ if (brace.dots === true) {
4923
+ const arr = tokens.slice();
4924
+ const range = [];
4925
+ for (let i = arr.length - 1; i >= 0; i--) {
4926
+ tokens.pop();
4927
+ if (arr[i].type === "brace") {
4928
+ break;
4929
+ }
4930
+ if (arr[i].type !== "dots") {
4931
+ range.unshift(arr[i].value);
4932
+ }
4933
+ }
4934
+ output = expandRange(range, opts);
4935
+ state.backtrack = true;
4936
+ }
4937
+ if (brace.comma !== true && brace.dots !== true) {
4938
+ const out = state.output.slice(0, brace.outputIndex);
4939
+ const toks = state.tokens.slice(brace.tokensIndex);
4940
+ brace.value = brace.output = "\\{";
4941
+ value = output = "\\}";
4942
+ state.output = out;
4943
+ for (const t of toks) {
4944
+ state.output += t.output || t.value;
4945
+ }
4946
+ }
4947
+ push({ type: "brace", value, output });
4948
+ decrement("braces");
4949
+ braces.pop();
4950
+ continue;
4951
+ }
4952
+ if (value === "|") {
4953
+ if (extglobs.length > 0) {
4954
+ extglobs[extglobs.length - 1].conditions++;
4955
+ }
4956
+ push({ type: "text", value });
4957
+ continue;
4958
+ }
4959
+ if (value === ",") {
4960
+ let output = value;
4961
+ const brace = braces[braces.length - 1];
4962
+ if (brace && stack[stack.length - 1] === "braces") {
4963
+ brace.comma = true;
4964
+ output = "|";
4965
+ }
4966
+ push({ type: "comma", value, output });
4967
+ continue;
4968
+ }
4969
+ if (value === "/") {
4970
+ if (prev.type === "dot" && state.index === state.start + 1) {
4971
+ state.start = state.index + 1;
4972
+ state.consumed = "";
4973
+ state.output = "";
4974
+ tokens.pop();
4975
+ prev = bos;
4976
+ continue;
4977
+ }
4978
+ push({ type: "slash", value, output: SLASH_LITERAL });
4979
+ continue;
4980
+ }
4981
+ if (value === ".") {
4982
+ if (state.braces > 0 && prev.type === "dot") {
4983
+ if (prev.value === ".")
4984
+ prev.output = DOT_LITERAL;
4985
+ const brace = braces[braces.length - 1];
4986
+ prev.type = "dots";
4987
+ prev.output += value;
4988
+ prev.value += value;
4989
+ brace.dots = true;
4990
+ continue;
4991
+ }
4992
+ if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
4993
+ push({ type: "text", value, output: DOT_LITERAL });
4994
+ continue;
4995
+ }
4996
+ push({ type: "dot", value, output: DOT_LITERAL });
4997
+ continue;
4998
+ }
4999
+ if (value === "?") {
5000
+ const isGroup = prev && prev.value === "(";
5001
+ if (!isGroup && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
5002
+ extglobOpen("qmark", value);
5003
+ continue;
5004
+ }
5005
+ if (prev && prev.type === "paren") {
5006
+ const next = peek();
5007
+ let output = value;
5008
+ if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) {
5009
+ output = `\\${value}`;
5010
+ }
5011
+ push({ type: "text", value, output });
5012
+ continue;
5013
+ }
5014
+ if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
5015
+ push({ type: "qmark", value, output: QMARK_NO_DOT });
5016
+ continue;
5017
+ }
5018
+ push({ type: "qmark", value, output: QMARK });
5019
+ continue;
5020
+ }
5021
+ if (value === "!") {
5022
+ if (opts.noextglob !== true && peek() === "(") {
5023
+ if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
5024
+ extglobOpen("negate", value);
5025
+ continue;
5026
+ }
5027
+ }
5028
+ if (opts.nonegate !== true && state.index === 0) {
5029
+ negate();
5030
+ continue;
5031
+ }
5032
+ }
5033
+ if (value === "+") {
5034
+ if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
5035
+ extglobOpen("plus", value);
5036
+ continue;
5037
+ }
5038
+ if (prev && prev.value === "(" || opts.regex === false) {
5039
+ push({ type: "plus", value, output: PLUS_LITERAL });
5040
+ continue;
5041
+ }
5042
+ if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
5043
+ push({ type: "plus", value });
5044
+ continue;
5045
+ }
5046
+ push({ type: "plus", value: PLUS_LITERAL });
5047
+ continue;
5048
+ }
5049
+ if (value === "@") {
5050
+ if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
5051
+ push({ type: "at", extglob: true, value, output: "" });
5052
+ continue;
5053
+ }
5054
+ push({ type: "text", value });
5055
+ continue;
5056
+ }
5057
+ if (value !== "*") {
5058
+ if (value === "$" || value === "^") {
5059
+ value = `\\${value}`;
5060
+ }
5061
+ const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
5062
+ if (match) {
5063
+ value += match[0];
5064
+ state.index += match[0].length;
5065
+ }
5066
+ push({ type: "text", value });
5067
+ continue;
5068
+ }
5069
+ if (prev && (prev.type === "globstar" || prev.star === true)) {
5070
+ prev.type = "star";
5071
+ prev.star = true;
5072
+ prev.value += value;
5073
+ prev.output = star;
5074
+ state.backtrack = true;
5075
+ state.globstar = true;
5076
+ consume(value);
5077
+ continue;
5078
+ }
5079
+ let rest = remaining();
5080
+ if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
5081
+ extglobOpen("star", value);
5082
+ continue;
5083
+ }
5084
+ if (prev.type === "star") {
5085
+ if (opts.noglobstar === true) {
5086
+ consume(value);
5087
+ continue;
5088
+ }
5089
+ const prior = prev.prev;
5090
+ const before = prior.prev;
5091
+ const isStart = prior.type === "slash" || prior.type === "bos";
5092
+ const afterStar = before && (before.type === "star" || before.type === "globstar");
5093
+ if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
5094
+ push({ type: "star", value, output: "" });
5095
+ continue;
5096
+ }
5097
+ const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
5098
+ const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
5099
+ if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
5100
+ push({ type: "star", value, output: "" });
5101
+ continue;
5102
+ }
5103
+ while (rest.slice(0, 3) === "/**") {
5104
+ const after = input[state.index + 4];
5105
+ if (after && after !== "/") {
5106
+ break;
5107
+ }
5108
+ rest = rest.slice(3);
5109
+ consume("/**", 3);
5110
+ }
5111
+ if (prior.type === "bos" && eos()) {
5112
+ prev.type = "globstar";
5113
+ prev.value += value;
5114
+ prev.output = globstar(opts);
5115
+ state.output = prev.output;
5116
+ state.globstar = true;
5117
+ consume(value);
5118
+ continue;
5119
+ }
5120
+ if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
5121
+ state.output = state.output.slice(0, -(prior.output + prev.output).length);
5122
+ prior.output = `(?:${prior.output}`;
5123
+ prev.type = "globstar";
5124
+ prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
5125
+ prev.value += value;
5126
+ state.globstar = true;
5127
+ state.output += prior.output + prev.output;
5128
+ consume(value);
5129
+ continue;
5130
+ }
5131
+ if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
5132
+ const end = rest[1] !== void 0 ? "|$" : "";
5133
+ state.output = state.output.slice(0, -(prior.output + prev.output).length);
5134
+ prior.output = `(?:${prior.output}`;
5135
+ prev.type = "globstar";
5136
+ prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
5137
+ prev.value += value;
5138
+ state.output += prior.output + prev.output;
5139
+ state.globstar = true;
5140
+ consume(value + advance());
5141
+ push({ type: "slash", value: "/", output: "" });
5142
+ continue;
5143
+ }
5144
+ if (prior.type === "bos" && rest[0] === "/") {
5145
+ prev.type = "globstar";
5146
+ prev.value += value;
5147
+ prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
5148
+ state.output = prev.output;
5149
+ state.globstar = true;
5150
+ consume(value + advance());
5151
+ push({ type: "slash", value: "/", output: "" });
5152
+ continue;
5153
+ }
5154
+ state.output = state.output.slice(0, -prev.output.length);
5155
+ prev.type = "globstar";
5156
+ prev.output = globstar(opts);
5157
+ prev.value += value;
5158
+ state.output += prev.output;
5159
+ state.globstar = true;
5160
+ consume(value);
5161
+ continue;
5162
+ }
5163
+ const token = { type: "star", value, output: star };
5164
+ if (opts.bash === true) {
5165
+ token.output = ".*?";
5166
+ if (prev.type === "bos" || prev.type === "slash") {
5167
+ token.output = nodot + token.output;
5168
+ }
5169
+ push(token);
5170
+ continue;
5171
+ }
5172
+ if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
5173
+ token.output = value;
5174
+ push(token);
5175
+ continue;
5176
+ }
5177
+ if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
5178
+ if (prev.type === "dot") {
5179
+ state.output += NO_DOT_SLASH;
5180
+ prev.output += NO_DOT_SLASH;
5181
+ } else if (opts.dot === true) {
5182
+ state.output += NO_DOTS_SLASH;
5183
+ prev.output += NO_DOTS_SLASH;
5184
+ } else {
5185
+ state.output += nodot;
5186
+ prev.output += nodot;
5187
+ }
5188
+ if (peek() !== "*") {
5189
+ state.output += ONE_CHAR;
5190
+ prev.output += ONE_CHAR;
5191
+ }
5192
+ }
5193
+ push(token);
5194
+ }
5195
+ while (state.brackets > 0) {
5196
+ if (opts.strictBrackets === true)
5197
+ throw new SyntaxError(syntaxError("closing", "]"));
5198
+ state.output = utils.escapeLast(state.output, "[");
5199
+ decrement("brackets");
5200
+ }
5201
+ while (state.parens > 0) {
5202
+ if (opts.strictBrackets === true)
5203
+ throw new SyntaxError(syntaxError("closing", ")"));
5204
+ state.output = utils.escapeLast(state.output, "(");
5205
+ decrement("parens");
5206
+ }
5207
+ while (state.braces > 0) {
5208
+ if (opts.strictBrackets === true)
5209
+ throw new SyntaxError(syntaxError("closing", "}"));
5210
+ state.output = utils.escapeLast(state.output, "{");
5211
+ decrement("braces");
5212
+ }
5213
+ if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) {
5214
+ push({ type: "maybe_slash", value: "", output: `${SLASH_LITERAL}?` });
5215
+ }
5216
+ if (state.backtrack === true) {
5217
+ state.output = "";
5218
+ for (const token of state.tokens) {
5219
+ state.output += token.output != null ? token.output : token.value;
5220
+ if (token.suffix) {
5221
+ state.output += token.suffix;
5222
+ }
5223
+ }
5224
+ }
5225
+ return state;
5226
+ };
5227
+ parse.fastpaths = (input, options) => {
5228
+ const opts = { ...options };
5229
+ const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
5230
+ const len = input.length;
5231
+ if (len > max) {
5232
+ throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
5233
+ }
5234
+ input = REPLACEMENTS[input] || input;
5235
+ const {
5236
+ DOT_LITERAL,
5237
+ SLASH_LITERAL,
5238
+ ONE_CHAR,
5239
+ DOTS_SLASH,
5240
+ NO_DOT,
5241
+ NO_DOTS,
5242
+ NO_DOTS_SLASH,
5243
+ STAR,
5244
+ START_ANCHOR
5245
+ } = constants.globChars(opts.windows);
5246
+ const nodot = opts.dot ? NO_DOTS : NO_DOT;
5247
+ const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
5248
+ const capture = opts.capture ? "" : "?:";
5249
+ const state = { negated: false, prefix: "" };
5250
+ let star = opts.bash === true ? ".*?" : STAR;
5251
+ if (opts.capture) {
5252
+ star = `(${star})`;
5253
+ }
5254
+ const globstar = (opts2) => {
5255
+ if (opts2.noglobstar === true)
5256
+ return star;
5257
+ return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
5258
+ };
5259
+ const create = (str) => {
5260
+ switch (str) {
5261
+ case "*":
5262
+ return `${nodot}${ONE_CHAR}${star}`;
5263
+ case ".*":
5264
+ return `${DOT_LITERAL}${ONE_CHAR}${star}`;
5265
+ case "*.*":
5266
+ return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
5267
+ case "*/*":
5268
+ return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
5269
+ case "**":
5270
+ return nodot + globstar(opts);
5271
+ case "**/*":
5272
+ return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
5273
+ case "**/*.*":
5274
+ return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
5275
+ case "**/.*":
5276
+ return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
5277
+ default: {
5278
+ const match = /^(.*?)\.(\w+)$/.exec(str);
5279
+ if (!match)
5280
+ return;
5281
+ const source2 = create(match[1]);
5282
+ if (!source2)
5283
+ return;
5284
+ return source2 + DOT_LITERAL + match[2];
5285
+ }
5286
+ }
5287
+ };
5288
+ const output = utils.removePrefix(input, state);
5289
+ let source = create(output);
5290
+ if (source && opts.strictSlashes !== true) {
5291
+ source += `${SLASH_LITERAL}?`;
5292
+ }
5293
+ return source;
5294
+ };
5295
+ module2.exports = parse;
5296
+ }
5297
+ });
5298
+
5299
+ // node_modules/picomatch/lib/picomatch.js
5300
+ var require_picomatch = __commonJS({
5301
+ "node_modules/picomatch/lib/picomatch.js"(exports2, module2) {
5302
+ "use strict";
5303
+ var scan = require_scan();
5304
+ var parse = require_parse();
5305
+ var utils = require_utils();
5306
+ var constants = require_constants();
5307
+ var isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
5308
+ var picomatch2 = (glob, options, returnState = false) => {
5309
+ if (Array.isArray(glob)) {
5310
+ const fns = glob.map((input) => picomatch2(input, options, returnState));
5311
+ const arrayMatcher = (str) => {
5312
+ for (const isMatch of fns) {
5313
+ const state2 = isMatch(str);
5314
+ if (state2)
5315
+ return state2;
5316
+ }
5317
+ return false;
5318
+ };
5319
+ return arrayMatcher;
5320
+ }
5321
+ const isState = isObject(glob) && glob.tokens && glob.input;
5322
+ if (glob === "" || typeof glob !== "string" && !isState) {
5323
+ throw new TypeError("Expected pattern to be a non-empty string");
5324
+ }
5325
+ const opts = options || {};
5326
+ const posix = opts.windows;
5327
+ const regex = isState ? picomatch2.compileRe(glob, options) : picomatch2.makeRe(glob, options, false, true);
5328
+ const state = regex.state;
5329
+ delete regex.state;
5330
+ let isIgnored = () => false;
5331
+ if (opts.ignore) {
5332
+ const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
5333
+ isIgnored = picomatch2(opts.ignore, ignoreOpts, returnState);
5334
+ }
5335
+ const matcher = (input, returnObject = false) => {
5336
+ const { isMatch, match, output } = picomatch2.test(input, regex, options, { glob, posix });
5337
+ const result = { glob, state, regex, posix, input, output, match, isMatch };
5338
+ if (typeof opts.onResult === "function") {
5339
+ opts.onResult(result);
5340
+ }
5341
+ if (isMatch === false) {
5342
+ result.isMatch = false;
5343
+ return returnObject ? result : false;
5344
+ }
5345
+ if (isIgnored(input)) {
5346
+ if (typeof opts.onIgnore === "function") {
5347
+ opts.onIgnore(result);
5348
+ }
5349
+ result.isMatch = false;
5350
+ return returnObject ? result : false;
5351
+ }
5352
+ if (typeof opts.onMatch === "function") {
5353
+ opts.onMatch(result);
5354
+ }
5355
+ return returnObject ? result : true;
5356
+ };
5357
+ if (returnState) {
5358
+ matcher.state = state;
5359
+ }
5360
+ return matcher;
5361
+ };
5362
+ picomatch2.test = (input, regex, options, { glob, posix } = {}) => {
5363
+ if (typeof input !== "string") {
5364
+ throw new TypeError("Expected input to be a string");
5365
+ }
5366
+ if (input === "") {
5367
+ return { isMatch: false, output: "" };
5368
+ }
5369
+ const opts = options || {};
5370
+ const format = opts.format || (posix ? utils.toPosixSlashes : null);
5371
+ let match = input === glob;
5372
+ let output = match && format ? format(input) : input;
5373
+ if (match === false) {
5374
+ output = format ? format(input) : input;
5375
+ match = output === glob;
5376
+ }
5377
+ if (match === false || opts.capture === true) {
5378
+ if (opts.matchBase === true || opts.basename === true) {
5379
+ match = picomatch2.matchBase(input, regex, options, posix);
5380
+ } else {
5381
+ match = regex.exec(output);
5382
+ }
5383
+ }
5384
+ return { isMatch: Boolean(match), match, output };
5385
+ };
5386
+ picomatch2.matchBase = (input, glob, options) => {
5387
+ const regex = glob instanceof RegExp ? glob : picomatch2.makeRe(glob, options);
5388
+ return regex.test(utils.basename(input));
5389
+ };
5390
+ picomatch2.isMatch = (str, patterns, options) => picomatch2(patterns, options)(str);
5391
+ picomatch2.parse = (pattern, options) => {
5392
+ if (Array.isArray(pattern))
5393
+ return pattern.map((p) => picomatch2.parse(p, options));
5394
+ return parse(pattern, { ...options, fastpaths: false });
5395
+ };
5396
+ picomatch2.scan = (input, options) => scan(input, options);
5397
+ picomatch2.compileRe = (state, options, returnOutput = false, returnState = false) => {
5398
+ if (returnOutput === true) {
5399
+ return state.output;
5400
+ }
5401
+ const opts = options || {};
5402
+ const prepend = opts.contains ? "" : "^";
5403
+ const append = opts.contains ? "" : "$";
5404
+ let source = `${prepend}(?:${state.output})${append}`;
5405
+ if (state && state.negated === true) {
5406
+ source = `^(?!${source}).*$`;
5407
+ }
5408
+ const regex = picomatch2.toRegex(source, options);
5409
+ if (returnState === true) {
5410
+ regex.state = state;
5411
+ }
5412
+ return regex;
5413
+ };
5414
+ picomatch2.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
5415
+ if (!input || typeof input !== "string") {
5416
+ throw new TypeError("Expected a non-empty string");
5417
+ }
5418
+ let parsed = { negated: false, fastpaths: true };
5419
+ if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) {
5420
+ parsed.output = parse.fastpaths(input, options);
5421
+ }
5422
+ if (!parsed.output) {
5423
+ parsed = parse(input, options);
5424
+ }
5425
+ return picomatch2.compileRe(parsed, options, returnOutput, returnState);
5426
+ };
5427
+ picomatch2.toRegex = (source, options) => {
5428
+ try {
5429
+ const opts = options || {};
5430
+ return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
5431
+ } catch (err) {
5432
+ if (options && options.debug === true)
5433
+ throw err;
5434
+ return /$^/;
5435
+ }
5436
+ };
5437
+ picomatch2.constants = constants;
5438
+ module2.exports = picomatch2;
5439
+ }
5440
+ });
5441
+
5442
+ // node_modules/picomatch/index.js
5443
+ var require_picomatch2 = __commonJS({
5444
+ "node_modules/picomatch/index.js"(exports2, module2) {
5445
+ "use strict";
5446
+ var pico = require_picomatch();
5447
+ var utils = require_utils();
5448
+ function picomatch2(glob, options, returnState = false) {
5449
+ if (options && (options.windows === null || options.windows === void 0)) {
5450
+ options = { ...options, windows: utils.isWindows() };
5451
+ }
5452
+ return pico(glob, options, returnState);
5453
+ }
5454
+ Object.assign(picomatch2, pico);
5455
+ module2.exports = picomatch2;
5456
+ }
5457
+ });
5458
+
3693
5459
  // src/claude-code.ts
3694
5460
  var claude_code_exports = {};
3695
5461
  __export(claude_code_exports, {
@@ -3698,7 +5464,7 @@ __export(claude_code_exports, {
3698
5464
  module.exports = __toCommonJS(claude_code_exports);
3699
5465
 
3700
5466
  // src/core.ts
3701
- var fs4 = __toESM(require("fs/promises"));
5467
+ var fs5 = __toESM(require("fs/promises"));
3702
5468
  var crypto2 = __toESM(require("crypto"));
3703
5469
  var import_iconv_lite = __toESM(require_lib());
3704
5470
 
@@ -3906,10 +5672,87 @@ async function removeState(filePath) {
3906
5672
  }
3907
5673
  }
3908
5674
 
3909
- // src/core.ts
3910
- var DEFAULT_OPTIONS = {
3911
- confidenceThreshold: 0.8
5675
+ // src/config.ts
5676
+ var fs4 = __toESM(require("fs/promises"));
5677
+ var path3 = __toESM(require("path"));
5678
+ var import_picomatch = __toESM(require_picomatch2());
5679
+ var DEFAULT_CONFIG = {
5680
+ targetEncoding: "UTF-8",
5681
+ confidenceThreshold: 0.8,
5682
+ defaultEncoding: "GB18030"
3912
5683
  };
5684
+ function migrateLegacyConfig(parsed) {
5685
+ if (parsed.sourceEncoding && !parsed.defaultEncoding) {
5686
+ parsed.defaultEncoding = parsed.sourceEncoding;
5687
+ delete parsed.sourceEncoding;
5688
+ }
5689
+ }
5690
+ function globSpecificity(pattern) {
5691
+ const segments = pattern.split("/");
5692
+ let score = 0;
5693
+ for (const segment of segments) {
5694
+ if (segment === "**") {
5695
+ score += 1;
5696
+ } else if (segment === "*") {
5697
+ score += 10;
5698
+ } else if (segment.includes("*")) {
5699
+ score += 100;
5700
+ } else {
5701
+ score += 1e3;
5702
+ }
5703
+ }
5704
+ return score;
5705
+ }
5706
+ async function loadProjectConfig(cwd) {
5707
+ const configPath = path3.join(cwd, ".encoding-converter.json");
5708
+ try {
5709
+ const content = await fs4.readFile(configPath, "utf-8");
5710
+ const parsed = JSON.parse(content);
5711
+ migrateLegacyConfig(parsed);
5712
+ return { ...DEFAULT_CONFIG, ...parsed };
5713
+ } catch (err) {
5714
+ if (err.code !== "ENOENT") {
5715
+ log("error", "Failed to parse config file", { path: configPath, error: err.message });
5716
+ }
5717
+ return { ...DEFAULT_CONFIG };
5718
+ }
5719
+ }
5720
+ function matchDirectoryRule(filePath, projectRoot, config) {
5721
+ if (!config.directoryRules || Object.keys(config.directoryRules).length === 0) {
5722
+ return {
5723
+ confidenceThreshold: config.confidenceThreshold,
5724
+ defaultEncoding: config.defaultEncoding
5725
+ };
5726
+ }
5727
+ const relativePath = path3.relative(projectRoot, filePath).replace(/\\/g, "/");
5728
+ const matches = [];
5729
+ for (const [pattern, rule] of Object.entries(config.directoryRules)) {
5730
+ try {
5731
+ if ((0, import_picomatch.default)(pattern)(relativePath)) {
5732
+ matches.push({
5733
+ pattern,
5734
+ rule,
5735
+ specificity: globSpecificity(pattern)
5736
+ });
5737
+ }
5738
+ } catch {
5739
+ log("info", "Invalid glob pattern in directoryRules", { pattern });
5740
+ }
5741
+ }
5742
+ if (matches.length === 0) {
5743
+ return {
5744
+ confidenceThreshold: config.confidenceThreshold,
5745
+ defaultEncoding: config.defaultEncoding
5746
+ };
5747
+ }
5748
+ const best = matches.reduce((a, b) => a.specificity >= b.specificity ? a : b);
5749
+ return {
5750
+ confidenceThreshold: best.rule.confidenceThreshold ?? config.confidenceThreshold,
5751
+ defaultEncoding: best.rule.defaultEncoding ?? config.defaultEncoding
5752
+ };
5753
+ }
5754
+
5755
+ // src/core.ts
3913
5756
  function isGBEncoding(encoding) {
3914
5757
  const upper = encoding.toUpperCase();
3915
5758
  return upper.includes("GB") || upper === "GB2312" || upper === "GBK" || upper === "GB18030";
@@ -3923,14 +5766,15 @@ function computeHash(buffer) {
3923
5766
  }
3924
5767
  async function fileExists(filePath) {
3925
5768
  try {
3926
- await fs4.access(filePath);
5769
+ await fs5.access(filePath);
3927
5770
  return true;
3928
5771
  } catch {
3929
5772
  return false;
3930
5773
  }
3931
5774
  }
3932
- async function convertToUtf8(filePath, toolType, options) {
3933
- const opts = { ...DEFAULT_OPTIONS, ...options };
5775
+ async function convertToUtf8(filePath, toolType, projectRoot) {
5776
+ const config = await loadProjectConfig(projectRoot);
5777
+ const encodingConfig = matchDirectoryRule(filePath, projectRoot, config);
3934
5778
  if (!await fileExists(filePath)) {
3935
5779
  log("debug", "File does not exist, skipping", { filePath });
3936
5780
  return false;
@@ -3941,14 +5785,14 @@ async function convertToUtf8(filePath, toolType, options) {
3941
5785
  }
3942
5786
  const detection = await detectEncoding(filePath);
3943
5787
  let encoding = detection.encoding;
3944
- if (!encoding || detection.confidence < opts.confidenceThreshold) {
3945
- if (opts.defaultEncoding) {
3946
- encoding = opts.defaultEncoding;
5788
+ if (!encoding || detection.confidence < encodingConfig.confidenceThreshold) {
5789
+ if (encodingConfig.defaultEncoding) {
5790
+ encoding = encodingConfig.defaultEncoding;
3947
5791
  log("info", "Low confidence, using defaultEncoding", {
3948
5792
  filePath,
3949
5793
  detected: detection.encoding,
3950
5794
  confidence: detection.confidence,
3951
- fallback: opts.defaultEncoding
5795
+ fallback: encodingConfig.defaultEncoding
3952
5796
  });
3953
5797
  } else {
3954
5798
  log("debug", "Low confidence and no fallback, skipping", {
@@ -3967,7 +5811,7 @@ async function convertToUtf8(filePath, toolType, options) {
3967
5811
  log("debug", "Encoding is not GB-family, skipping", { filePath, encoding });
3968
5812
  return false;
3969
5813
  }
3970
- const buffer = await fs4.readFile(filePath);
5814
+ const buffer = await fs5.readFile(filePath);
3971
5815
  const utf8String = import_iconv_lite.default.decode(buffer, encoding);
3972
5816
  const utf8Encoded = Buffer.from(utf8String, "utf-8");
3973
5817
  const contentHash = computeHash(utf8Encoded);
@@ -3976,12 +5820,13 @@ async function convertToUtf8(filePath, toolType, options) {
3976
5820
  log("info", "State already exists (concurrent access), skipping", { filePath });
3977
5821
  return false;
3978
5822
  }
3979
- await fs4.writeFile(filePath, utf8Encoded);
5823
+ await fs5.writeFile(filePath, utf8Encoded);
3980
5824
  log("info", "Converted to UTF-8", { filePath, from: encoding });
3981
5825
  return true;
3982
5826
  }
3983
- async function detectAndRecord(filePath, toolType, options) {
3984
- const opts = { ...DEFAULT_OPTIONS, ...options };
5827
+ async function detectAndRecord(filePath, toolType, projectRoot) {
5828
+ const config = await loadProjectConfig(projectRoot);
5829
+ const encodingConfig = matchDirectoryRule(filePath, projectRoot, config);
3985
5830
  if (!await fileExists(filePath)) {
3986
5831
  log("debug", "File does not exist (new file), skipping record", { filePath });
3987
5832
  return false;
@@ -3992,9 +5837,9 @@ async function detectAndRecord(filePath, toolType, options) {
3992
5837
  }
3993
5838
  const detection = await detectEncoding(filePath);
3994
5839
  let encoding = detection.encoding;
3995
- if (!encoding || detection.confidence < opts.confidenceThreshold) {
3996
- if (opts.defaultEncoding) {
3997
- encoding = opts.defaultEncoding;
5840
+ if (!encoding || detection.confidence < encodingConfig.confidenceThreshold) {
5841
+ if (encodingConfig.defaultEncoding) {
5842
+ encoding = encodingConfig.defaultEncoding;
3998
5843
  } else {
3999
5844
  return false;
4000
5845
  }
@@ -4020,66 +5865,46 @@ async function restoreFromUtf8(filePath) {
4020
5865
  return false;
4021
5866
  }
4022
5867
  try {
4023
- const buffer = await fs4.readFile(filePath);
5868
+ const buffer = await fs5.readFile(filePath);
4024
5869
  const encoded = import_iconv_lite.default.encode(buffer.toString("utf-8"), state.originalEncoding);
4025
- await fs4.writeFile(filePath, encoded);
5870
+ await fs5.writeFile(filePath, encoded);
4026
5871
  log("info", "Restored from UTF-8", { filePath, to: state.originalEncoding });
4027
5872
  } finally {
4028
5873
  await removeState(filePath);
4029
5874
  }
4030
5875
  return true;
4031
5876
  }
4032
- async function convertFromUtf8(filePath, projectConfig) {
5877
+ async function convertFromUtf8(filePath, projectRoot) {
4033
5878
  const state = await loadState(filePath);
4034
5879
  if (state) {
4035
5880
  try {
4036
- const buffer = await fs4.readFile(filePath);
5881
+ const buffer = await fs5.readFile(filePath);
4037
5882
  const encoded = import_iconv_lite.default.encode(buffer.toString("utf-8"), state.originalEncoding);
4038
- await fs4.writeFile(filePath, encoded);
5883
+ await fs5.writeFile(filePath, encoded);
4039
5884
  log("info", "Converted from UTF-8 (Write post)", { filePath, to: state.originalEncoding });
4040
5885
  } finally {
4041
5886
  await removeState(filePath);
4042
5887
  }
4043
5888
  return true;
4044
5889
  }
4045
- if (projectConfig?.defaultEncoding) {
5890
+ const config = await loadProjectConfig(projectRoot);
5891
+ const encodingConfig = matchDirectoryRule(filePath, projectRoot, config);
5892
+ if (encodingConfig.defaultEncoding && encodingConfig.defaultEncoding.toUpperCase() !== "UTF-8") {
4046
5893
  if (!await fileExists(filePath))
4047
5894
  return false;
4048
- const buffer = await fs4.readFile(filePath);
4049
- const encoded = import_iconv_lite.default.encode(buffer.toString("utf-8"), projectConfig.defaultEncoding);
4050
- await fs4.writeFile(filePath, encoded);
5895
+ const buffer = await fs5.readFile(filePath);
5896
+ const encoded = import_iconv_lite.default.encode(buffer.toString("utf-8"), encodingConfig.defaultEncoding);
5897
+ await fs5.writeFile(filePath, encoded);
4051
5898
  log("info", "Converted new file from UTF-8", {
4052
5899
  filePath,
4053
- to: projectConfig.defaultEncoding
5900
+ to: encodingConfig.defaultEncoding
4054
5901
  });
4055
5902
  return true;
4056
5903
  }
4057
- log("debug", "No state and no defaultEncoding config, keeping UTF-8", { filePath });
5904
+ log("debug", "No state and defaultEncoding is UTF-8, keeping UTF-8", { filePath });
4058
5905
  return false;
4059
5906
  }
4060
5907
 
4061
- // src/config.ts
4062
- var fs5 = __toESM(require("fs/promises"));
4063
- var path3 = __toESM(require("path"));
4064
- var DEFAULT_CONFIG = {
4065
- sourceEncoding: "GB18030",
4066
- targetEncoding: "UTF-8",
4067
- confidenceThreshold: 0.8
4068
- };
4069
- async function loadProjectConfig(cwd) {
4070
- const configPath = path3.join(cwd, ".encoding-converter.json");
4071
- try {
4072
- const content = await fs5.readFile(configPath, "utf-8");
4073
- const parsed = JSON.parse(content);
4074
- return { ...DEFAULT_CONFIG, ...parsed };
4075
- } catch (err) {
4076
- if (err.code !== "ENOENT") {
4077
- log("error", "Failed to parse config file", { path: configPath, error: err.message });
4078
- }
4079
- return { ...DEFAULT_CONFIG };
4080
- }
4081
- }
4082
-
4083
5908
  // src/claude-code.ts
4084
5909
  var SUPPORTED_TOOLS = /* @__PURE__ */ new Set(["Read", "Write", "Edit"]);
4085
5910
  async function handleHook(phase, input) {
@@ -4092,25 +5917,20 @@ async function handleHook(phase, input) {
4092
5917
  log("error", "No file_path in tool_input", { tool_name });
4093
5918
  return;
4094
5919
  }
4095
- const config = await loadProjectConfig(cwd);
4096
- const convertOptions = {
4097
- confidenceThreshold: config.confidenceThreshold,
4098
- defaultEncoding: config.defaultEncoding
4099
- };
4100
5920
  try {
4101
5921
  switch (phase) {
4102
5922
  case "pre":
4103
5923
  if (tool_name === "Read" || tool_name === "Edit") {
4104
- await convertToUtf8(filePath, tool_name, convertOptions);
5924
+ await convertToUtf8(filePath, tool_name, cwd);
4105
5925
  } else if (tool_name === "Write") {
4106
- await detectAndRecord(filePath, tool_name, convertOptions);
5926
+ await detectAndRecord(filePath, tool_name, cwd);
4107
5927
  }
4108
5928
  break;
4109
5929
  case "post":
4110
5930
  if (tool_name === "Read" || tool_name === "Edit") {
4111
5931
  await restoreFromUtf8(filePath);
4112
5932
  } else if (tool_name === "Write") {
4113
- await convertFromUtf8(filePath, config);
5933
+ await convertFromUtf8(filePath, cwd);
4114
5934
  }
4115
5935
  break;
4116
5936
  case "post-failure":