@tscircuit/cli 0.1.206 → 0.1.208

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.
Files changed (3) hide show
  1. package/README.md +2 -1
  2. package/dist/main.js +1400 -92
  3. package/package.json +5 -4
package/dist/main.js CHANGED
@@ -62957,7 +62957,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
62957
62957
  import { execSync as execSync2 } from "node:child_process";
62958
62958
  var import_semver2 = __toESM2(require_semver2(), 1);
62959
62959
  // package.json
62960
- var version = "0.1.205";
62960
+ var version = "0.1.207";
62961
62961
  var package_default = {
62962
62962
  name: "@tscircuit/cli",
62963
62963
  version,
@@ -62984,6 +62984,7 @@ var package_default = {
62984
62984
  "bun-match-svg": "^0.0.12",
62985
62985
  chokidar: "4.0.1",
62986
62986
  "circuit-json-to-readable-netlist": "^0.0.13",
62987
+ "circuit-json-to-tscircuit": "^0.0.9",
62987
62988
  commander: "^14.0.0",
62988
62989
  conf: "^13.1.0",
62989
62990
  configstore: "^7.0.0",
@@ -62991,10 +62992,13 @@ var package_default = {
62991
62992
  debug: "^4.4.0",
62992
62993
  delay: "^6.0.0",
62993
62994
  "dsn-converter": "^0.0.63",
62995
+ easyeda: "^0.0.227",
62996
+ "fuse.js": "^7.1.0",
62994
62997
  "get-port": "^7.1.0",
62995
62998
  globby: "^14.1.0",
62996
62999
  jsonwebtoken: "^9.0.2",
62997
63000
  "jwt-decode": "^4.0.0",
63001
+ "kicad-component-converter": "^0.1.14",
62998
63002
  kleur: "^4.1.5",
62999
63003
  ky: "^1.7.4",
63000
63004
  "looks-same": "^9.0.1",
@@ -63008,9 +63012,6 @@ var package_default = {
63008
63012
  tscircuit: "^0.0.633-libonly",
63009
63013
  tsx: "^4.7.1",
63010
63014
  "typed-ky": "^0.0.4",
63011
- "circuit-json-to-tscircuit": "^0.0.9",
63012
- "kicad-component-converter": "^0.1.14",
63013
- easyeda: "^0.0.227",
63014
63015
  zod: "3"
63015
63016
  },
63016
63017
  peerDependencies: {
@@ -69576,38 +69577,1345 @@ var registerConfigSet = (program3) => {
69576
69577
  });
69577
69578
  };
69578
69579
 
69580
+ // node_modules/fuse.js/dist/fuse.mjs
69581
+ function isArray(value) {
69582
+ return !Array.isArray ? getTag(value) === "[object Array]" : Array.isArray(value);
69583
+ }
69584
+ var INFINITY = 1 / 0;
69585
+ function baseToString(value) {
69586
+ if (typeof value == "string") {
69587
+ return value;
69588
+ }
69589
+ let result = value + "";
69590
+ return result == "0" && 1 / value == -INFINITY ? "-0" : result;
69591
+ }
69592
+ function toString(value) {
69593
+ return value == null ? "" : baseToString(value);
69594
+ }
69595
+ function isString2(value) {
69596
+ return typeof value === "string";
69597
+ }
69598
+ function isNumber(value) {
69599
+ return typeof value === "number";
69600
+ }
69601
+ function isBoolean(value) {
69602
+ return value === true || value === false || isObjectLike(value) && getTag(value) == "[object Boolean]";
69603
+ }
69604
+ function isObject3(value) {
69605
+ return typeof value === "object";
69606
+ }
69607
+ function isObjectLike(value) {
69608
+ return isObject3(value) && value !== null;
69609
+ }
69610
+ function isDefined(value) {
69611
+ return value !== undefined && value !== null;
69612
+ }
69613
+ function isBlank(value) {
69614
+ return !value.trim().length;
69615
+ }
69616
+ function getTag(value) {
69617
+ return value == null ? value === undefined ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(value);
69618
+ }
69619
+ var INCORRECT_INDEX_TYPE = "Incorrect 'index' type";
69620
+ var LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY = (key) => `Invalid value for key ${key}`;
69621
+ var PATTERN_LENGTH_TOO_LARGE = (max) => `Pattern length exceeds max of ${max}.`;
69622
+ var MISSING_KEY_PROPERTY = (name) => `Missing ${name} property in key`;
69623
+ var INVALID_KEY_WEIGHT_VALUE = (key) => `Property 'weight' in key '${key}' must be a positive integer`;
69624
+ var hasOwn = Object.prototype.hasOwnProperty;
69625
+
69626
+ class KeyStore {
69627
+ constructor(keys) {
69628
+ this._keys = [];
69629
+ this._keyMap = {};
69630
+ let totalWeight = 0;
69631
+ keys.forEach((key) => {
69632
+ let obj = createKey(key);
69633
+ this._keys.push(obj);
69634
+ this._keyMap[obj.id] = obj;
69635
+ totalWeight += obj.weight;
69636
+ });
69637
+ this._keys.forEach((key) => {
69638
+ key.weight /= totalWeight;
69639
+ });
69640
+ }
69641
+ get(keyId) {
69642
+ return this._keyMap[keyId];
69643
+ }
69644
+ keys() {
69645
+ return this._keys;
69646
+ }
69647
+ toJSON() {
69648
+ return JSON.stringify(this._keys);
69649
+ }
69650
+ }
69651
+ function createKey(key) {
69652
+ let path23 = null;
69653
+ let id = null;
69654
+ let src = null;
69655
+ let weight = 1;
69656
+ let getFn = null;
69657
+ if (isString2(key) || isArray(key)) {
69658
+ src = key;
69659
+ path23 = createKeyPath(key);
69660
+ id = createKeyId(key);
69661
+ } else {
69662
+ if (!hasOwn.call(key, "name")) {
69663
+ throw new Error(MISSING_KEY_PROPERTY("name"));
69664
+ }
69665
+ const name = key.name;
69666
+ src = name;
69667
+ if (hasOwn.call(key, "weight")) {
69668
+ weight = key.weight;
69669
+ if (weight <= 0) {
69670
+ throw new Error(INVALID_KEY_WEIGHT_VALUE(name));
69671
+ }
69672
+ }
69673
+ path23 = createKeyPath(name);
69674
+ id = createKeyId(name);
69675
+ getFn = key.getFn;
69676
+ }
69677
+ return { path: path23, id, weight, src, getFn };
69678
+ }
69679
+ function createKeyPath(key) {
69680
+ return isArray(key) ? key : key.split(".");
69681
+ }
69682
+ function createKeyId(key) {
69683
+ return isArray(key) ? key.join(".") : key;
69684
+ }
69685
+ function get(obj, path23) {
69686
+ let list = [];
69687
+ let arr = false;
69688
+ const deepGet = (obj2, path24, index) => {
69689
+ if (!isDefined(obj2)) {
69690
+ return;
69691
+ }
69692
+ if (!path24[index]) {
69693
+ list.push(obj2);
69694
+ } else {
69695
+ let key = path24[index];
69696
+ const value = obj2[key];
69697
+ if (!isDefined(value)) {
69698
+ return;
69699
+ }
69700
+ if (index === path24.length - 1 && (isString2(value) || isNumber(value) || isBoolean(value))) {
69701
+ list.push(toString(value));
69702
+ } else if (isArray(value)) {
69703
+ arr = true;
69704
+ for (let i = 0, len = value.length;i < len; i += 1) {
69705
+ deepGet(value[i], path24, index + 1);
69706
+ }
69707
+ } else if (path24.length) {
69708
+ deepGet(value, path24, index + 1);
69709
+ }
69710
+ }
69711
+ };
69712
+ deepGet(obj, isString2(path23) ? path23.split(".") : path23, 0);
69713
+ return arr ? list : list[0];
69714
+ }
69715
+ var MatchOptions = {
69716
+ includeMatches: false,
69717
+ findAllMatches: false,
69718
+ minMatchCharLength: 1
69719
+ };
69720
+ var BasicOptions = {
69721
+ isCaseSensitive: false,
69722
+ ignoreDiacritics: false,
69723
+ includeScore: false,
69724
+ keys: [],
69725
+ shouldSort: true,
69726
+ sortFn: (a, b) => a.score === b.score ? a.idx < b.idx ? -1 : 1 : a.score < b.score ? -1 : 1
69727
+ };
69728
+ var FuzzyOptions = {
69729
+ location: 0,
69730
+ threshold: 0.6,
69731
+ distance: 100
69732
+ };
69733
+ var AdvancedOptions = {
69734
+ useExtendedSearch: false,
69735
+ getFn: get,
69736
+ ignoreLocation: false,
69737
+ ignoreFieldNorm: false,
69738
+ fieldNormWeight: 1
69739
+ };
69740
+ var Config = {
69741
+ ...BasicOptions,
69742
+ ...MatchOptions,
69743
+ ...FuzzyOptions,
69744
+ ...AdvancedOptions
69745
+ };
69746
+ var SPACE = /[^ ]+/g;
69747
+ function norm(weight = 1, mantissa = 3) {
69748
+ const cache = new Map;
69749
+ const m2 = Math.pow(10, mantissa);
69750
+ return {
69751
+ get(value) {
69752
+ const numTokens = value.match(SPACE).length;
69753
+ if (cache.has(numTokens)) {
69754
+ return cache.get(numTokens);
69755
+ }
69756
+ const norm2 = 1 / Math.pow(numTokens, 0.5 * weight);
69757
+ const n2 = parseFloat(Math.round(norm2 * m2) / m2);
69758
+ cache.set(numTokens, n2);
69759
+ return n2;
69760
+ },
69761
+ clear() {
69762
+ cache.clear();
69763
+ }
69764
+ };
69765
+ }
69766
+
69767
+ class FuseIndex {
69768
+ constructor({
69769
+ getFn = Config.getFn,
69770
+ fieldNormWeight = Config.fieldNormWeight
69771
+ } = {}) {
69772
+ this.norm = norm(fieldNormWeight, 3);
69773
+ this.getFn = getFn;
69774
+ this.isCreated = false;
69775
+ this.setIndexRecords();
69776
+ }
69777
+ setSources(docs = []) {
69778
+ this.docs = docs;
69779
+ }
69780
+ setIndexRecords(records = []) {
69781
+ this.records = records;
69782
+ }
69783
+ setKeys(keys = []) {
69784
+ this.keys = keys;
69785
+ this._keysMap = {};
69786
+ keys.forEach((key, idx) => {
69787
+ this._keysMap[key.id] = idx;
69788
+ });
69789
+ }
69790
+ create() {
69791
+ if (this.isCreated || !this.docs.length) {
69792
+ return;
69793
+ }
69794
+ this.isCreated = true;
69795
+ if (isString2(this.docs[0])) {
69796
+ this.docs.forEach((doc, docIndex) => {
69797
+ this._addString(doc, docIndex);
69798
+ });
69799
+ } else {
69800
+ this.docs.forEach((doc, docIndex) => {
69801
+ this._addObject(doc, docIndex);
69802
+ });
69803
+ }
69804
+ this.norm.clear();
69805
+ }
69806
+ add(doc) {
69807
+ const idx = this.size();
69808
+ if (isString2(doc)) {
69809
+ this._addString(doc, idx);
69810
+ } else {
69811
+ this._addObject(doc, idx);
69812
+ }
69813
+ }
69814
+ removeAt(idx) {
69815
+ this.records.splice(idx, 1);
69816
+ for (let i = idx, len = this.size();i < len; i += 1) {
69817
+ this.records[i].i -= 1;
69818
+ }
69819
+ }
69820
+ getValueForItemAtKeyId(item, keyId) {
69821
+ return item[this._keysMap[keyId]];
69822
+ }
69823
+ size() {
69824
+ return this.records.length;
69825
+ }
69826
+ _addString(doc, docIndex) {
69827
+ if (!isDefined(doc) || isBlank(doc)) {
69828
+ return;
69829
+ }
69830
+ let record = {
69831
+ v: doc,
69832
+ i: docIndex,
69833
+ n: this.norm.get(doc)
69834
+ };
69835
+ this.records.push(record);
69836
+ }
69837
+ _addObject(doc, docIndex) {
69838
+ let record = { i: docIndex, $: {} };
69839
+ this.keys.forEach((key, keyIndex) => {
69840
+ let value = key.getFn ? key.getFn(doc) : this.getFn(doc, key.path);
69841
+ if (!isDefined(value)) {
69842
+ return;
69843
+ }
69844
+ if (isArray(value)) {
69845
+ let subRecords = [];
69846
+ const stack = [{ nestedArrIndex: -1, value }];
69847
+ while (stack.length) {
69848
+ const { nestedArrIndex, value: value2 } = stack.pop();
69849
+ if (!isDefined(value2)) {
69850
+ continue;
69851
+ }
69852
+ if (isString2(value2) && !isBlank(value2)) {
69853
+ let subRecord = {
69854
+ v: value2,
69855
+ i: nestedArrIndex,
69856
+ n: this.norm.get(value2)
69857
+ };
69858
+ subRecords.push(subRecord);
69859
+ } else if (isArray(value2)) {
69860
+ value2.forEach((item, k) => {
69861
+ stack.push({
69862
+ nestedArrIndex: k,
69863
+ value: item
69864
+ });
69865
+ });
69866
+ } else
69867
+ ;
69868
+ }
69869
+ record.$[keyIndex] = subRecords;
69870
+ } else if (isString2(value) && !isBlank(value)) {
69871
+ let subRecord = {
69872
+ v: value,
69873
+ n: this.norm.get(value)
69874
+ };
69875
+ record.$[keyIndex] = subRecord;
69876
+ }
69877
+ });
69878
+ this.records.push(record);
69879
+ }
69880
+ toJSON() {
69881
+ return {
69882
+ keys: this.keys,
69883
+ records: this.records
69884
+ };
69885
+ }
69886
+ }
69887
+ function createIndex(keys, docs, { getFn = Config.getFn, fieldNormWeight = Config.fieldNormWeight } = {}) {
69888
+ const myIndex = new FuseIndex({ getFn, fieldNormWeight });
69889
+ myIndex.setKeys(keys.map(createKey));
69890
+ myIndex.setSources(docs);
69891
+ myIndex.create();
69892
+ return myIndex;
69893
+ }
69894
+ function parseIndex(data, { getFn = Config.getFn, fieldNormWeight = Config.fieldNormWeight } = {}) {
69895
+ const { keys, records } = data;
69896
+ const myIndex = new FuseIndex({ getFn, fieldNormWeight });
69897
+ myIndex.setKeys(keys);
69898
+ myIndex.setIndexRecords(records);
69899
+ return myIndex;
69900
+ }
69901
+ function computeScore$1(pattern, {
69902
+ errors = 0,
69903
+ currentLocation = 0,
69904
+ expectedLocation = 0,
69905
+ distance = Config.distance,
69906
+ ignoreLocation = Config.ignoreLocation
69907
+ } = {}) {
69908
+ const accuracy = errors / pattern.length;
69909
+ if (ignoreLocation) {
69910
+ return accuracy;
69911
+ }
69912
+ const proximity = Math.abs(expectedLocation - currentLocation);
69913
+ if (!distance) {
69914
+ return proximity ? 1 : accuracy;
69915
+ }
69916
+ return accuracy + proximity / distance;
69917
+ }
69918
+ function convertMaskToIndices(matchmask = [], minMatchCharLength = Config.minMatchCharLength) {
69919
+ let indices = [];
69920
+ let start = -1;
69921
+ let end = -1;
69922
+ let i = 0;
69923
+ for (let len = matchmask.length;i < len; i += 1) {
69924
+ let match = matchmask[i];
69925
+ if (match && start === -1) {
69926
+ start = i;
69927
+ } else if (!match && start !== -1) {
69928
+ end = i - 1;
69929
+ if (end - start + 1 >= minMatchCharLength) {
69930
+ indices.push([start, end]);
69931
+ }
69932
+ start = -1;
69933
+ }
69934
+ }
69935
+ if (matchmask[i - 1] && i - start >= minMatchCharLength) {
69936
+ indices.push([start, i - 1]);
69937
+ }
69938
+ return indices;
69939
+ }
69940
+ var MAX_BITS = 32;
69941
+ function search(text, pattern, patternAlphabet, {
69942
+ location = Config.location,
69943
+ distance = Config.distance,
69944
+ threshold = Config.threshold,
69945
+ findAllMatches = Config.findAllMatches,
69946
+ minMatchCharLength = Config.minMatchCharLength,
69947
+ includeMatches = Config.includeMatches,
69948
+ ignoreLocation = Config.ignoreLocation
69949
+ } = {}) {
69950
+ if (pattern.length > MAX_BITS) {
69951
+ throw new Error(PATTERN_LENGTH_TOO_LARGE(MAX_BITS));
69952
+ }
69953
+ const patternLen = pattern.length;
69954
+ const textLen = text.length;
69955
+ const expectedLocation = Math.max(0, Math.min(location, textLen));
69956
+ let currentThreshold = threshold;
69957
+ let bestLocation = expectedLocation;
69958
+ const computeMatches = minMatchCharLength > 1 || includeMatches;
69959
+ const matchMask = computeMatches ? Array(textLen) : [];
69960
+ let index;
69961
+ while ((index = text.indexOf(pattern, bestLocation)) > -1) {
69962
+ let score = computeScore$1(pattern, {
69963
+ currentLocation: index,
69964
+ expectedLocation,
69965
+ distance,
69966
+ ignoreLocation
69967
+ });
69968
+ currentThreshold = Math.min(score, currentThreshold);
69969
+ bestLocation = index + patternLen;
69970
+ if (computeMatches) {
69971
+ let i = 0;
69972
+ while (i < patternLen) {
69973
+ matchMask[index + i] = 1;
69974
+ i += 1;
69975
+ }
69976
+ }
69977
+ }
69978
+ bestLocation = -1;
69979
+ let lastBitArr = [];
69980
+ let finalScore = 1;
69981
+ let binMax = patternLen + textLen;
69982
+ const mask = 1 << patternLen - 1;
69983
+ for (let i = 0;i < patternLen; i += 1) {
69984
+ let binMin = 0;
69985
+ let binMid = binMax;
69986
+ while (binMin < binMid) {
69987
+ const score2 = computeScore$1(pattern, {
69988
+ errors: i,
69989
+ currentLocation: expectedLocation + binMid,
69990
+ expectedLocation,
69991
+ distance,
69992
+ ignoreLocation
69993
+ });
69994
+ if (score2 <= currentThreshold) {
69995
+ binMin = binMid;
69996
+ } else {
69997
+ binMax = binMid;
69998
+ }
69999
+ binMid = Math.floor((binMax - binMin) / 2 + binMin);
70000
+ }
70001
+ binMax = binMid;
70002
+ let start = Math.max(1, expectedLocation - binMid + 1);
70003
+ let finish = findAllMatches ? textLen : Math.min(expectedLocation + binMid, textLen) + patternLen;
70004
+ let bitArr = Array(finish + 2);
70005
+ bitArr[finish + 1] = (1 << i) - 1;
70006
+ for (let j = finish;j >= start; j -= 1) {
70007
+ let currentLocation = j - 1;
70008
+ let charMatch = patternAlphabet[text.charAt(currentLocation)];
70009
+ if (computeMatches) {
70010
+ matchMask[currentLocation] = +!!charMatch;
70011
+ }
70012
+ bitArr[j] = (bitArr[j + 1] << 1 | 1) & charMatch;
70013
+ if (i) {
70014
+ bitArr[j] |= (lastBitArr[j + 1] | lastBitArr[j]) << 1 | 1 | lastBitArr[j + 1];
70015
+ }
70016
+ if (bitArr[j] & mask) {
70017
+ finalScore = computeScore$1(pattern, {
70018
+ errors: i,
70019
+ currentLocation,
70020
+ expectedLocation,
70021
+ distance,
70022
+ ignoreLocation
70023
+ });
70024
+ if (finalScore <= currentThreshold) {
70025
+ currentThreshold = finalScore;
70026
+ bestLocation = currentLocation;
70027
+ if (bestLocation <= expectedLocation) {
70028
+ break;
70029
+ }
70030
+ start = Math.max(1, 2 * expectedLocation - bestLocation);
70031
+ }
70032
+ }
70033
+ }
70034
+ const score = computeScore$1(pattern, {
70035
+ errors: i + 1,
70036
+ currentLocation: expectedLocation,
70037
+ expectedLocation,
70038
+ distance,
70039
+ ignoreLocation
70040
+ });
70041
+ if (score > currentThreshold) {
70042
+ break;
70043
+ }
70044
+ lastBitArr = bitArr;
70045
+ }
70046
+ const result = {
70047
+ isMatch: bestLocation >= 0,
70048
+ score: Math.max(0.001, finalScore)
70049
+ };
70050
+ if (computeMatches) {
70051
+ const indices = convertMaskToIndices(matchMask, minMatchCharLength);
70052
+ if (!indices.length) {
70053
+ result.isMatch = false;
70054
+ } else if (includeMatches) {
70055
+ result.indices = indices;
70056
+ }
70057
+ }
70058
+ return result;
70059
+ }
70060
+ function createPatternAlphabet(pattern) {
70061
+ let mask = {};
70062
+ for (let i = 0, len = pattern.length;i < len; i += 1) {
70063
+ const char = pattern.charAt(i);
70064
+ mask[char] = (mask[char] || 0) | 1 << len - i - 1;
70065
+ }
70066
+ return mask;
70067
+ }
70068
+ var stripDiacritics = String.prototype.normalize ? (str) => str.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g, "") : (str) => str;
70069
+
70070
+ class BitapSearch {
70071
+ constructor(pattern, {
70072
+ location = Config.location,
70073
+ threshold = Config.threshold,
70074
+ distance = Config.distance,
70075
+ includeMatches = Config.includeMatches,
70076
+ findAllMatches = Config.findAllMatches,
70077
+ minMatchCharLength = Config.minMatchCharLength,
70078
+ isCaseSensitive = Config.isCaseSensitive,
70079
+ ignoreDiacritics = Config.ignoreDiacritics,
70080
+ ignoreLocation = Config.ignoreLocation
70081
+ } = {}) {
70082
+ this.options = {
70083
+ location,
70084
+ threshold,
70085
+ distance,
70086
+ includeMatches,
70087
+ findAllMatches,
70088
+ minMatchCharLength,
70089
+ isCaseSensitive,
70090
+ ignoreDiacritics,
70091
+ ignoreLocation
70092
+ };
70093
+ pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
70094
+ pattern = ignoreDiacritics ? stripDiacritics(pattern) : pattern;
70095
+ this.pattern = pattern;
70096
+ this.chunks = [];
70097
+ if (!this.pattern.length) {
70098
+ return;
70099
+ }
70100
+ const addChunk = (pattern2, startIndex) => {
70101
+ this.chunks.push({
70102
+ pattern: pattern2,
70103
+ alphabet: createPatternAlphabet(pattern2),
70104
+ startIndex
70105
+ });
70106
+ };
70107
+ const len = this.pattern.length;
70108
+ if (len > MAX_BITS) {
70109
+ let i = 0;
70110
+ const remainder = len % MAX_BITS;
70111
+ const end = len - remainder;
70112
+ while (i < end) {
70113
+ addChunk(this.pattern.substr(i, MAX_BITS), i);
70114
+ i += MAX_BITS;
70115
+ }
70116
+ if (remainder) {
70117
+ const startIndex = len - MAX_BITS;
70118
+ addChunk(this.pattern.substr(startIndex), startIndex);
70119
+ }
70120
+ } else {
70121
+ addChunk(this.pattern, 0);
70122
+ }
70123
+ }
70124
+ searchIn(text) {
70125
+ const { isCaseSensitive, ignoreDiacritics, includeMatches } = this.options;
70126
+ text = isCaseSensitive ? text : text.toLowerCase();
70127
+ text = ignoreDiacritics ? stripDiacritics(text) : text;
70128
+ if (this.pattern === text) {
70129
+ let result2 = {
70130
+ isMatch: true,
70131
+ score: 0
70132
+ };
70133
+ if (includeMatches) {
70134
+ result2.indices = [[0, text.length - 1]];
70135
+ }
70136
+ return result2;
70137
+ }
70138
+ const {
70139
+ location,
70140
+ distance,
70141
+ threshold,
70142
+ findAllMatches,
70143
+ minMatchCharLength,
70144
+ ignoreLocation
70145
+ } = this.options;
70146
+ let allIndices = [];
70147
+ let totalScore = 0;
70148
+ let hasMatches = false;
70149
+ this.chunks.forEach(({ pattern, alphabet, startIndex }) => {
70150
+ const { isMatch, score, indices } = search(text, pattern, alphabet, {
70151
+ location: location + startIndex,
70152
+ distance,
70153
+ threshold,
70154
+ findAllMatches,
70155
+ minMatchCharLength,
70156
+ includeMatches,
70157
+ ignoreLocation
70158
+ });
70159
+ if (isMatch) {
70160
+ hasMatches = true;
70161
+ }
70162
+ totalScore += score;
70163
+ if (isMatch && indices) {
70164
+ allIndices = [...allIndices, ...indices];
70165
+ }
70166
+ });
70167
+ let result = {
70168
+ isMatch: hasMatches,
70169
+ score: hasMatches ? totalScore / this.chunks.length : 1
70170
+ };
70171
+ if (hasMatches && includeMatches) {
70172
+ result.indices = allIndices;
70173
+ }
70174
+ return result;
70175
+ }
70176
+ }
70177
+
70178
+ class BaseMatch {
70179
+ constructor(pattern) {
70180
+ this.pattern = pattern;
70181
+ }
70182
+ static isMultiMatch(pattern) {
70183
+ return getMatch(pattern, this.multiRegex);
70184
+ }
70185
+ static isSingleMatch(pattern) {
70186
+ return getMatch(pattern, this.singleRegex);
70187
+ }
70188
+ search() {}
70189
+ }
70190
+ function getMatch(pattern, exp) {
70191
+ const matches = pattern.match(exp);
70192
+ return matches ? matches[1] : null;
70193
+ }
70194
+
70195
+ class ExactMatch extends BaseMatch {
70196
+ constructor(pattern) {
70197
+ super(pattern);
70198
+ }
70199
+ static get type() {
70200
+ return "exact";
70201
+ }
70202
+ static get multiRegex() {
70203
+ return /^="(.*)"$/;
70204
+ }
70205
+ static get singleRegex() {
70206
+ return /^=(.*)$/;
70207
+ }
70208
+ search(text) {
70209
+ const isMatch = text === this.pattern;
70210
+ return {
70211
+ isMatch,
70212
+ score: isMatch ? 0 : 1,
70213
+ indices: [0, this.pattern.length - 1]
70214
+ };
70215
+ }
70216
+ }
70217
+
70218
+ class InverseExactMatch extends BaseMatch {
70219
+ constructor(pattern) {
70220
+ super(pattern);
70221
+ }
70222
+ static get type() {
70223
+ return "inverse-exact";
70224
+ }
70225
+ static get multiRegex() {
70226
+ return /^!"(.*)"$/;
70227
+ }
70228
+ static get singleRegex() {
70229
+ return /^!(.*)$/;
70230
+ }
70231
+ search(text) {
70232
+ const index = text.indexOf(this.pattern);
70233
+ const isMatch = index === -1;
70234
+ return {
70235
+ isMatch,
70236
+ score: isMatch ? 0 : 1,
70237
+ indices: [0, text.length - 1]
70238
+ };
70239
+ }
70240
+ }
70241
+
70242
+ class PrefixExactMatch extends BaseMatch {
70243
+ constructor(pattern) {
70244
+ super(pattern);
70245
+ }
70246
+ static get type() {
70247
+ return "prefix-exact";
70248
+ }
70249
+ static get multiRegex() {
70250
+ return /^\^"(.*)"$/;
70251
+ }
70252
+ static get singleRegex() {
70253
+ return /^\^(.*)$/;
70254
+ }
70255
+ search(text) {
70256
+ const isMatch = text.startsWith(this.pattern);
70257
+ return {
70258
+ isMatch,
70259
+ score: isMatch ? 0 : 1,
70260
+ indices: [0, this.pattern.length - 1]
70261
+ };
70262
+ }
70263
+ }
70264
+
70265
+ class InversePrefixExactMatch extends BaseMatch {
70266
+ constructor(pattern) {
70267
+ super(pattern);
70268
+ }
70269
+ static get type() {
70270
+ return "inverse-prefix-exact";
70271
+ }
70272
+ static get multiRegex() {
70273
+ return /^!\^"(.*)"$/;
70274
+ }
70275
+ static get singleRegex() {
70276
+ return /^!\^(.*)$/;
70277
+ }
70278
+ search(text) {
70279
+ const isMatch = !text.startsWith(this.pattern);
70280
+ return {
70281
+ isMatch,
70282
+ score: isMatch ? 0 : 1,
70283
+ indices: [0, text.length - 1]
70284
+ };
70285
+ }
70286
+ }
70287
+
70288
+ class SuffixExactMatch extends BaseMatch {
70289
+ constructor(pattern) {
70290
+ super(pattern);
70291
+ }
70292
+ static get type() {
70293
+ return "suffix-exact";
70294
+ }
70295
+ static get multiRegex() {
70296
+ return /^"(.*)"\$$/;
70297
+ }
70298
+ static get singleRegex() {
70299
+ return /^(.*)\$$/;
70300
+ }
70301
+ search(text) {
70302
+ const isMatch = text.endsWith(this.pattern);
70303
+ return {
70304
+ isMatch,
70305
+ score: isMatch ? 0 : 1,
70306
+ indices: [text.length - this.pattern.length, text.length - 1]
70307
+ };
70308
+ }
70309
+ }
70310
+
70311
+ class InverseSuffixExactMatch extends BaseMatch {
70312
+ constructor(pattern) {
70313
+ super(pattern);
70314
+ }
70315
+ static get type() {
70316
+ return "inverse-suffix-exact";
70317
+ }
70318
+ static get multiRegex() {
70319
+ return /^!"(.*)"\$$/;
70320
+ }
70321
+ static get singleRegex() {
70322
+ return /^!(.*)\$$/;
70323
+ }
70324
+ search(text) {
70325
+ const isMatch = !text.endsWith(this.pattern);
70326
+ return {
70327
+ isMatch,
70328
+ score: isMatch ? 0 : 1,
70329
+ indices: [0, text.length - 1]
70330
+ };
70331
+ }
70332
+ }
70333
+
70334
+ class FuzzyMatch extends BaseMatch {
70335
+ constructor(pattern, {
70336
+ location = Config.location,
70337
+ threshold = Config.threshold,
70338
+ distance = Config.distance,
70339
+ includeMatches = Config.includeMatches,
70340
+ findAllMatches = Config.findAllMatches,
70341
+ minMatchCharLength = Config.minMatchCharLength,
70342
+ isCaseSensitive = Config.isCaseSensitive,
70343
+ ignoreDiacritics = Config.ignoreDiacritics,
70344
+ ignoreLocation = Config.ignoreLocation
70345
+ } = {}) {
70346
+ super(pattern);
70347
+ this._bitapSearch = new BitapSearch(pattern, {
70348
+ location,
70349
+ threshold,
70350
+ distance,
70351
+ includeMatches,
70352
+ findAllMatches,
70353
+ minMatchCharLength,
70354
+ isCaseSensitive,
70355
+ ignoreDiacritics,
70356
+ ignoreLocation
70357
+ });
70358
+ }
70359
+ static get type() {
70360
+ return "fuzzy";
70361
+ }
70362
+ static get multiRegex() {
70363
+ return /^"(.*)"$/;
70364
+ }
70365
+ static get singleRegex() {
70366
+ return /^(.*)$/;
70367
+ }
70368
+ search(text) {
70369
+ return this._bitapSearch.searchIn(text);
70370
+ }
70371
+ }
70372
+
70373
+ class IncludeMatch extends BaseMatch {
70374
+ constructor(pattern) {
70375
+ super(pattern);
70376
+ }
70377
+ static get type() {
70378
+ return "include";
70379
+ }
70380
+ static get multiRegex() {
70381
+ return /^'"(.*)"$/;
70382
+ }
70383
+ static get singleRegex() {
70384
+ return /^'(.*)$/;
70385
+ }
70386
+ search(text) {
70387
+ let location = 0;
70388
+ let index;
70389
+ const indices = [];
70390
+ const patternLen = this.pattern.length;
70391
+ while ((index = text.indexOf(this.pattern, location)) > -1) {
70392
+ location = index + patternLen;
70393
+ indices.push([index, location - 1]);
70394
+ }
70395
+ const isMatch = !!indices.length;
70396
+ return {
70397
+ isMatch,
70398
+ score: isMatch ? 0 : 1,
70399
+ indices
70400
+ };
70401
+ }
70402
+ }
70403
+ var searchers = [
70404
+ ExactMatch,
70405
+ IncludeMatch,
70406
+ PrefixExactMatch,
70407
+ InversePrefixExactMatch,
70408
+ InverseSuffixExactMatch,
70409
+ SuffixExactMatch,
70410
+ InverseExactMatch,
70411
+ FuzzyMatch
70412
+ ];
70413
+ var searchersLen = searchers.length;
70414
+ var SPACE_RE = / +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/;
70415
+ var OR_TOKEN = "|";
70416
+ function parseQuery(pattern, options = {}) {
70417
+ return pattern.split(OR_TOKEN).map((item) => {
70418
+ let query = item.trim().split(SPACE_RE).filter((item2) => item2 && !!item2.trim());
70419
+ let results = [];
70420
+ for (let i = 0, len = query.length;i < len; i += 1) {
70421
+ const queryItem = query[i];
70422
+ let found = false;
70423
+ let idx = -1;
70424
+ while (!found && ++idx < searchersLen) {
70425
+ const searcher = searchers[idx];
70426
+ let token = searcher.isMultiMatch(queryItem);
70427
+ if (token) {
70428
+ results.push(new searcher(token, options));
70429
+ found = true;
70430
+ }
70431
+ }
70432
+ if (found) {
70433
+ continue;
70434
+ }
70435
+ idx = -1;
70436
+ while (++idx < searchersLen) {
70437
+ const searcher = searchers[idx];
70438
+ let token = searcher.isSingleMatch(queryItem);
70439
+ if (token) {
70440
+ results.push(new searcher(token, options));
70441
+ break;
70442
+ }
70443
+ }
70444
+ }
70445
+ return results;
70446
+ });
70447
+ }
70448
+ var MultiMatchSet = new Set([FuzzyMatch.type, IncludeMatch.type]);
70449
+
70450
+ class ExtendedSearch {
70451
+ constructor(pattern, {
70452
+ isCaseSensitive = Config.isCaseSensitive,
70453
+ ignoreDiacritics = Config.ignoreDiacritics,
70454
+ includeMatches = Config.includeMatches,
70455
+ minMatchCharLength = Config.minMatchCharLength,
70456
+ ignoreLocation = Config.ignoreLocation,
70457
+ findAllMatches = Config.findAllMatches,
70458
+ location = Config.location,
70459
+ threshold = Config.threshold,
70460
+ distance = Config.distance
70461
+ } = {}) {
70462
+ this.query = null;
70463
+ this.options = {
70464
+ isCaseSensitive,
70465
+ ignoreDiacritics,
70466
+ includeMatches,
70467
+ minMatchCharLength,
70468
+ findAllMatches,
70469
+ ignoreLocation,
70470
+ location,
70471
+ threshold,
70472
+ distance
70473
+ };
70474
+ pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
70475
+ pattern = ignoreDiacritics ? stripDiacritics(pattern) : pattern;
70476
+ this.pattern = pattern;
70477
+ this.query = parseQuery(this.pattern, this.options);
70478
+ }
70479
+ static condition(_, options) {
70480
+ return options.useExtendedSearch;
70481
+ }
70482
+ searchIn(text) {
70483
+ const query = this.query;
70484
+ if (!query) {
70485
+ return {
70486
+ isMatch: false,
70487
+ score: 1
70488
+ };
70489
+ }
70490
+ const { includeMatches, isCaseSensitive, ignoreDiacritics } = this.options;
70491
+ text = isCaseSensitive ? text : text.toLowerCase();
70492
+ text = ignoreDiacritics ? stripDiacritics(text) : text;
70493
+ let numMatches = 0;
70494
+ let allIndices = [];
70495
+ let totalScore = 0;
70496
+ for (let i = 0, qLen = query.length;i < qLen; i += 1) {
70497
+ const searchers2 = query[i];
70498
+ allIndices.length = 0;
70499
+ numMatches = 0;
70500
+ for (let j = 0, pLen = searchers2.length;j < pLen; j += 1) {
70501
+ const searcher = searchers2[j];
70502
+ const { isMatch, indices, score } = searcher.search(text);
70503
+ if (isMatch) {
70504
+ numMatches += 1;
70505
+ totalScore += score;
70506
+ if (includeMatches) {
70507
+ const type = searcher.constructor.type;
70508
+ if (MultiMatchSet.has(type)) {
70509
+ allIndices = [...allIndices, ...indices];
70510
+ } else {
70511
+ allIndices.push(indices);
70512
+ }
70513
+ }
70514
+ } else {
70515
+ totalScore = 0;
70516
+ numMatches = 0;
70517
+ allIndices.length = 0;
70518
+ break;
70519
+ }
70520
+ }
70521
+ if (numMatches) {
70522
+ let result = {
70523
+ isMatch: true,
70524
+ score: totalScore / numMatches
70525
+ };
70526
+ if (includeMatches) {
70527
+ result.indices = allIndices;
70528
+ }
70529
+ return result;
70530
+ }
70531
+ }
70532
+ return {
70533
+ isMatch: false,
70534
+ score: 1
70535
+ };
70536
+ }
70537
+ }
70538
+ var registeredSearchers = [];
70539
+ function register(...args) {
70540
+ registeredSearchers.push(...args);
70541
+ }
70542
+ function createSearcher(pattern, options) {
70543
+ for (let i = 0, len = registeredSearchers.length;i < len; i += 1) {
70544
+ let searcherClass = registeredSearchers[i];
70545
+ if (searcherClass.condition(pattern, options)) {
70546
+ return new searcherClass(pattern, options);
70547
+ }
70548
+ }
70549
+ return new BitapSearch(pattern, options);
70550
+ }
70551
+ var LogicalOperator = {
70552
+ AND: "$and",
70553
+ OR: "$or"
70554
+ };
70555
+ var KeyType = {
70556
+ PATH: "$path",
70557
+ PATTERN: "$val"
70558
+ };
70559
+ var isExpression = (query) => !!(query[LogicalOperator.AND] || query[LogicalOperator.OR]);
70560
+ var isPath = (query) => !!query[KeyType.PATH];
70561
+ var isLeaf = (query) => !isArray(query) && isObject3(query) && !isExpression(query);
70562
+ var convertToExplicit = (query) => ({
70563
+ [LogicalOperator.AND]: Object.keys(query).map((key) => ({
70564
+ [key]: query[key]
70565
+ }))
70566
+ });
70567
+ function parse3(query, options, { auto = true } = {}) {
70568
+ const next = (query2) => {
70569
+ let keys = Object.keys(query2);
70570
+ const isQueryPath = isPath(query2);
70571
+ if (!isQueryPath && keys.length > 1 && !isExpression(query2)) {
70572
+ return next(convertToExplicit(query2));
70573
+ }
70574
+ if (isLeaf(query2)) {
70575
+ const key = isQueryPath ? query2[KeyType.PATH] : keys[0];
70576
+ const pattern = isQueryPath ? query2[KeyType.PATTERN] : query2[key];
70577
+ if (!isString2(pattern)) {
70578
+ throw new Error(LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY(key));
70579
+ }
70580
+ const obj = {
70581
+ keyId: createKeyId(key),
70582
+ pattern
70583
+ };
70584
+ if (auto) {
70585
+ obj.searcher = createSearcher(pattern, options);
70586
+ }
70587
+ return obj;
70588
+ }
70589
+ let node = {
70590
+ children: [],
70591
+ operator: keys[0]
70592
+ };
70593
+ keys.forEach((key) => {
70594
+ const value = query2[key];
70595
+ if (isArray(value)) {
70596
+ value.forEach((item) => {
70597
+ node.children.push(next(item));
70598
+ });
70599
+ }
70600
+ });
70601
+ return node;
70602
+ };
70603
+ if (!isExpression(query)) {
70604
+ query = convertToExplicit(query);
70605
+ }
70606
+ return next(query);
70607
+ }
70608
+ function computeScore(results, { ignoreFieldNorm = Config.ignoreFieldNorm }) {
70609
+ results.forEach((result) => {
70610
+ let totalScore = 1;
70611
+ result.matches.forEach(({ key, norm: norm2, score }) => {
70612
+ const weight = key ? key.weight : null;
70613
+ totalScore *= Math.pow(score === 0 && weight ? Number.EPSILON : score, (weight || 1) * (ignoreFieldNorm ? 1 : norm2));
70614
+ });
70615
+ result.score = totalScore;
70616
+ });
70617
+ }
70618
+ function transformMatches(result, data) {
70619
+ const matches = result.matches;
70620
+ data.matches = [];
70621
+ if (!isDefined(matches)) {
70622
+ return;
70623
+ }
70624
+ matches.forEach((match) => {
70625
+ if (!isDefined(match.indices) || !match.indices.length) {
70626
+ return;
70627
+ }
70628
+ const { indices, value } = match;
70629
+ let obj = {
70630
+ indices,
70631
+ value
70632
+ };
70633
+ if (match.key) {
70634
+ obj.key = match.key.src;
70635
+ }
70636
+ if (match.idx > -1) {
70637
+ obj.refIndex = match.idx;
70638
+ }
70639
+ data.matches.push(obj);
70640
+ });
70641
+ }
70642
+ function transformScore(result, data) {
70643
+ data.score = result.score;
70644
+ }
70645
+ function format(results, docs, {
70646
+ includeMatches = Config.includeMatches,
70647
+ includeScore = Config.includeScore
70648
+ } = {}) {
70649
+ const transformers = [];
70650
+ if (includeMatches)
70651
+ transformers.push(transformMatches);
70652
+ if (includeScore)
70653
+ transformers.push(transformScore);
70654
+ return results.map((result) => {
70655
+ const { idx } = result;
70656
+ const data = {
70657
+ item: docs[idx],
70658
+ refIndex: idx
70659
+ };
70660
+ if (transformers.length) {
70661
+ transformers.forEach((transformer) => {
70662
+ transformer(result, data);
70663
+ });
70664
+ }
70665
+ return data;
70666
+ });
70667
+ }
70668
+
70669
+ class Fuse {
70670
+ constructor(docs, options = {}, index) {
70671
+ this.options = { ...Config, ...options };
70672
+ if (this.options.useExtendedSearch && false) {}
70673
+ this._keyStore = new KeyStore(this.options.keys);
70674
+ this.setCollection(docs, index);
70675
+ }
70676
+ setCollection(docs, index) {
70677
+ this._docs = docs;
70678
+ if (index && !(index instanceof FuseIndex)) {
70679
+ throw new Error(INCORRECT_INDEX_TYPE);
70680
+ }
70681
+ this._myIndex = index || createIndex(this.options.keys, this._docs, {
70682
+ getFn: this.options.getFn,
70683
+ fieldNormWeight: this.options.fieldNormWeight
70684
+ });
70685
+ }
70686
+ add(doc) {
70687
+ if (!isDefined(doc)) {
70688
+ return;
70689
+ }
70690
+ this._docs.push(doc);
70691
+ this._myIndex.add(doc);
70692
+ }
70693
+ remove(predicate = () => false) {
70694
+ const results = [];
70695
+ for (let i = 0, len = this._docs.length;i < len; i += 1) {
70696
+ const doc = this._docs[i];
70697
+ if (predicate(doc, i)) {
70698
+ this.removeAt(i);
70699
+ i -= 1;
70700
+ len -= 1;
70701
+ results.push(doc);
70702
+ }
70703
+ }
70704
+ return results;
70705
+ }
70706
+ removeAt(idx) {
70707
+ this._docs.splice(idx, 1);
70708
+ this._myIndex.removeAt(idx);
70709
+ }
70710
+ getIndex() {
70711
+ return this._myIndex;
70712
+ }
70713
+ search(query, { limit = -1 } = {}) {
70714
+ const {
70715
+ includeMatches,
70716
+ includeScore,
70717
+ shouldSort,
70718
+ sortFn,
70719
+ ignoreFieldNorm
70720
+ } = this.options;
70721
+ let results = isString2(query) ? isString2(this._docs[0]) ? this._searchStringList(query) : this._searchObjectList(query) : this._searchLogical(query);
70722
+ computeScore(results, { ignoreFieldNorm });
70723
+ if (shouldSort) {
70724
+ results.sort(sortFn);
70725
+ }
70726
+ if (isNumber(limit) && limit > -1) {
70727
+ results = results.slice(0, limit);
70728
+ }
70729
+ return format(results, this._docs, {
70730
+ includeMatches,
70731
+ includeScore
70732
+ });
70733
+ }
70734
+ _searchStringList(query) {
70735
+ const searcher = createSearcher(query, this.options);
70736
+ const { records } = this._myIndex;
70737
+ const results = [];
70738
+ records.forEach(({ v: text, i: idx, n: norm2 }) => {
70739
+ if (!isDefined(text)) {
70740
+ return;
70741
+ }
70742
+ const { isMatch, score, indices } = searcher.searchIn(text);
70743
+ if (isMatch) {
70744
+ results.push({
70745
+ item: text,
70746
+ idx,
70747
+ matches: [{ score, value: text, norm: norm2, indices }]
70748
+ });
70749
+ }
70750
+ });
70751
+ return results;
70752
+ }
70753
+ _searchLogical(query) {
70754
+ const expression = parse3(query, this.options);
70755
+ const evaluate = (node, item, idx) => {
70756
+ if (!node.children) {
70757
+ const { keyId, searcher } = node;
70758
+ const matches = this._findMatches({
70759
+ key: this._keyStore.get(keyId),
70760
+ value: this._myIndex.getValueForItemAtKeyId(item, keyId),
70761
+ searcher
70762
+ });
70763
+ if (matches && matches.length) {
70764
+ return [
70765
+ {
70766
+ idx,
70767
+ item,
70768
+ matches
70769
+ }
70770
+ ];
70771
+ }
70772
+ return [];
70773
+ }
70774
+ const res = [];
70775
+ for (let i = 0, len = node.children.length;i < len; i += 1) {
70776
+ const child = node.children[i];
70777
+ const result = evaluate(child, item, idx);
70778
+ if (result.length) {
70779
+ res.push(...result);
70780
+ } else if (node.operator === LogicalOperator.AND) {
70781
+ return [];
70782
+ }
70783
+ }
70784
+ return res;
70785
+ };
70786
+ const records = this._myIndex.records;
70787
+ const resultMap = {};
70788
+ const results = [];
70789
+ records.forEach(({ $: item, i: idx }) => {
70790
+ if (isDefined(item)) {
70791
+ let expResults = evaluate(expression, item, idx);
70792
+ if (expResults.length) {
70793
+ if (!resultMap[idx]) {
70794
+ resultMap[idx] = { idx, item, matches: [] };
70795
+ results.push(resultMap[idx]);
70796
+ }
70797
+ expResults.forEach(({ matches }) => {
70798
+ resultMap[idx].matches.push(...matches);
70799
+ });
70800
+ }
70801
+ }
70802
+ });
70803
+ return results;
70804
+ }
70805
+ _searchObjectList(query) {
70806
+ const searcher = createSearcher(query, this.options);
70807
+ const { keys, records } = this._myIndex;
70808
+ const results = [];
70809
+ records.forEach(({ $: item, i: idx }) => {
70810
+ if (!isDefined(item)) {
70811
+ return;
70812
+ }
70813
+ let matches = [];
70814
+ keys.forEach((key, keyIndex) => {
70815
+ matches.push(...this._findMatches({
70816
+ key,
70817
+ value: item[keyIndex],
70818
+ searcher
70819
+ }));
70820
+ });
70821
+ if (matches.length) {
70822
+ results.push({
70823
+ idx,
70824
+ item,
70825
+ matches
70826
+ });
70827
+ }
70828
+ });
70829
+ return results;
70830
+ }
70831
+ _findMatches({ key, value, searcher }) {
70832
+ if (!isDefined(value)) {
70833
+ return [];
70834
+ }
70835
+ let matches = [];
70836
+ if (isArray(value)) {
70837
+ value.forEach(({ v: text, i: idx, n: norm2 }) => {
70838
+ if (!isDefined(text)) {
70839
+ return;
70840
+ }
70841
+ const { isMatch, score, indices } = searcher.searchIn(text);
70842
+ if (isMatch) {
70843
+ matches.push({
70844
+ score,
70845
+ key,
70846
+ value: text,
70847
+ idx,
70848
+ norm: norm2,
70849
+ indices
70850
+ });
70851
+ }
70852
+ });
70853
+ } else {
70854
+ const { v: text, n: norm2 } = value;
70855
+ const { isMatch, score, indices } = searcher.searchIn(text);
70856
+ if (isMatch) {
70857
+ matches.push({ score, key, value: text, norm: norm2, indices });
70858
+ }
70859
+ }
70860
+ return matches;
70861
+ }
70862
+ }
70863
+ Fuse.version = "7.1.0";
70864
+ Fuse.createIndex = createIndex;
70865
+ Fuse.parseIndex = parseIndex;
70866
+ Fuse.config = Config;
70867
+ {
70868
+ Fuse.parseQuery = parse3;
70869
+ }
70870
+ {
70871
+ register(ExtendedSearch);
70872
+ }
70873
+
69579
70874
  // cli/search/register.ts
69580
70875
  var registerSearch = (program3) => {
69581
- program3.command("search").description("Search for packages in the tscircuit registry").argument("<query>", "Search query (e.g. keyword, author, or package name)").action(async (query) => {
69582
- const ky2 = getRegistryApiKy();
70876
+ program3.command("search").description("Search for footprints, CAD models or packages in the tscircuit ecosystem").argument("<query>", "Search query (e.g. keyword, author, or package name)").option("--kicad", "Only search KiCad footprints").action(async (query, opts) => {
70877
+ const onlyKicad = opts.kicad;
69583
70878
  let results = { packages: [] };
69584
70879
  let jlcResults = [];
70880
+ let kicadResults = [];
69585
70881
  try {
69586
- results = await ky2.post("packages/search", {
69587
- json: { query }
69588
- }).json();
69589
- const jlcSearchUrl = "https://jlcsearch.tscircuit.com/api/search?limit=10&q=" + encodeURIComponent(query);
69590
- jlcResults = (await fetch(jlcSearchUrl).then((r) => r.json())).components;
70882
+ if (!onlyKicad) {
70883
+ const ky2 = getRegistryApiKy();
70884
+ results = await ky2.post("packages/search", {
70885
+ json: { query }
70886
+ }).json();
70887
+ const jlcSearchUrl = "https://jlcsearch.tscircuit.com/api/search?limit=10&q=" + encodeURIComponent(query);
70888
+ jlcResults = (await fetch(jlcSearchUrl).then((r) => r.json())).components;
70889
+ }
70890
+ const kicadFiles = await fetch("https://kicad-mod-cache.tscircuit.com/kicad_files.json").then((r) => r.json());
70891
+ const fuse = new Fuse(kicadFiles);
70892
+ kicadResults = fuse.search(query).slice(0, 10).map((r) => r.item);
69591
70893
  } catch (error) {
69592
70894
  console.error(kleur_default.red("Failed to search registry:"), error instanceof Error ? error.message : error);
69593
70895
  process.exit(1);
69594
70896
  }
69595
- if (!results.packages.length && !jlcResults.length) {
70897
+ if (!kicadResults.length && (!results.packages.length && !jlcResults.length || onlyKicad)) {
69596
70898
  console.log(kleur_default.yellow("No results found matching your query."));
69597
70899
  return;
69598
70900
  }
69599
- if (results.packages.length) {
70901
+ if (kicadResults.length) {
70902
+ console.log(kleur_default.bold().underline(`Found ${kicadResults.length} footprint(s) from KiCad:`));
70903
+ kicadResults.forEach((path23, idx) => {
70904
+ console.log(`${(idx + 1).toString().padStart(2, " ")}. ${path23.replace(".kicad_mod", "").replace(".pretty", "")}`);
70905
+ });
70906
+ }
70907
+ if (!onlyKicad && results.packages.length) {
69600
70908
  console.log(kleur_default.bold().underline(`Found ${results.packages.length} package(s) in the tscircuit registry:`));
69601
70909
  results.packages.forEach((pkg, idx) => {
69602
70910
  const star = pkg.star_count ?? 0;
69603
70911
  console.log(`${idx + 1}. ${pkg.name} (v${pkg.version}) - Stars: ${star}${pkg.description ? ` - ${pkg.description}` : ""}`);
69604
70912
  });
69605
70913
  }
69606
- if (jlcResults.length) {
70914
+ if (!onlyKicad && jlcResults.length) {
69607
70915
  console.log();
69608
70916
  console.log(kleur_default.bold().underline(`Found ${jlcResults.length} component(s) in JLC search:`));
69609
70917
  jlcResults.forEach((comp, idx) => {
69610
- console.log(`${idx + 1}. ${comp.mfr} (C${comp.lcsc}) - ${comp.description}`);
70918
+ console.log(`${idx + 1}. ${comp.mfr} (C${comp.lcsc}) - ${comp.description} (stock: ${comp.stock.toLocaleString("en-US")})`);
69611
70919
  });
69612
70920
  }
69613
70921
  console.log(`
@@ -76082,13 +77390,13 @@ var require_common3 = __commonJS2({
76082
77390
  }
76083
77391
  }
76084
77392
  }
76085
- function matchesTemplate(search, template) {
77393
+ function matchesTemplate(search2, template) {
76086
77394
  let searchIndex = 0;
76087
77395
  let templateIndex = 0;
76088
77396
  let starIndex = -1;
76089
77397
  let matchIndex = 0;
76090
- while (searchIndex < search.length) {
76091
- if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) {
77398
+ while (searchIndex < search2.length) {
77399
+ if (templateIndex < template.length && (template[templateIndex] === search2[searchIndex] || template[templateIndex] === "*")) {
76092
77400
  if (template[templateIndex] === "*") {
76093
77401
  starIndex = templateIndex;
76094
77402
  matchIndex = searchIndex;
@@ -87320,7 +88628,7 @@ var require_react_reconciler_development2 = __commonJS2({
87320
88628
  }
87321
88629
  }
87322
88630
  var assign2 = Object.assign;
87323
- function get(key) {
88631
+ function get2(key) {
87324
88632
  return key._reactInternals;
87325
88633
  }
87326
88634
  function set(key, value) {
@@ -87595,7 +88903,7 @@ var require_react_reconciler_development2 = __commonJS2({
87595
88903
  instance._warnedAboutRefsInRender = true;
87596
88904
  }
87597
88905
  }
87598
- var fiber = get(component);
88906
+ var fiber = get2(component);
87599
88907
  if (!fiber) {
87600
88908
  return false;
87601
88909
  }
@@ -87743,7 +89051,7 @@ var require_react_reconciler_development2 = __commonJS2({
87743
89051
  return null;
87744
89052
  }
87745
89053
  var isArrayImpl = Array.isArray;
87746
- function isArray(a) {
89054
+ function isArray2(a) {
87747
89055
  return isArrayImpl(a);
87748
89056
  }
87749
89057
  var getPublicInstance = $$$hostConfig.getPublicInstance;
@@ -90425,7 +91733,7 @@ See https://reactjs.org/link/refs-must-have-owner for more information.`);
90425
91733
  return createChild(returnFiber, init2(payload), lanes);
90426
91734
  }
90427
91735
  }
90428
- if (isArray(newChild) || getIteratorFn(newChild)) {
91736
+ if (isArray2(newChild) || getIteratorFn(newChild)) {
90429
91737
  var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null);
90430
91738
  _created3.return = returnFiber;
90431
91739
  return _created3;
@@ -90469,7 +91777,7 @@ See https://reactjs.org/link/refs-must-have-owner for more information.`);
90469
91777
  return updateSlot(returnFiber, oldFiber, init2(payload), lanes);
90470
91778
  }
90471
91779
  }
90472
- if (isArray(newChild) || getIteratorFn(newChild)) {
91780
+ if (isArray2(newChild) || getIteratorFn(newChild)) {
90473
91781
  if (key !== null) {
90474
91782
  return null;
90475
91783
  }
@@ -90504,7 +91812,7 @@ See https://reactjs.org/link/refs-must-have-owner for more information.`);
90504
91812
  var init2 = newChild._init;
90505
91813
  return updateFromMap(existingChildren, returnFiber, newIdx, init2(payload), lanes);
90506
91814
  }
90507
- if (isArray(newChild) || getIteratorFn(newChild)) {
91815
+ if (isArray2(newChild) || getIteratorFn(newChild)) {
90508
91816
  var _matchedFiber3 = existingChildren.get(newIdx) || null;
90509
91817
  return updateFragment2(returnFiber, _matchedFiber3, newChild, lanes, null);
90510
91818
  }
@@ -90872,7 +92180,7 @@ See https://reactjs.org/link/refs-must-have-owner for more information.`);
90872
92180
  var init2 = newChild._init;
90873
92181
  return reconcileChildFibers2(returnFiber, currentFirstChild, init2(payload), lanes);
90874
92182
  }
90875
- if (isArray(newChild)) {
92183
+ if (isArray2(newChild)) {
90876
92184
  return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes);
90877
92185
  }
90878
92186
  if (getIteratorFn(newChild)) {
@@ -91781,7 +93089,7 @@ See https://reactjs.org/link/refs-must-have-owner for more information.`);
91781
93089
  }
91782
93090
  function checkDepsAreArrayDev(deps) {
91783
93091
  {
91784
- if (deps !== undefined && deps !== null && !isArray(deps)) {
93092
+ if (deps !== undefined && deps !== null && !isArray2(deps)) {
91785
93093
  error("%s received a final argument that is not an array (instead, received `%s`). When specified, the final argument must be an array.", currentHookNameInDev, typeof deps);
91786
93094
  }
91787
93095
  }
@@ -93763,7 +95071,7 @@ Incoming: %s`, currentHookNameInDev, "[" + prevDeps.join(", ") + "]", "[" + next
93763
95071
  var classComponentUpdater = {
93764
95072
  isMounted,
93765
95073
  enqueueSetState: function(inst, payload, callback) {
93766
- var fiber = get(inst);
95074
+ var fiber = get2(inst);
93767
95075
  var eventTime = requestEventTime();
93768
95076
  var lane = requestUpdateLane(fiber);
93769
95077
  var update = createUpdate(eventTime, lane);
@@ -93784,7 +95092,7 @@ Incoming: %s`, currentHookNameInDev, "[" + prevDeps.join(", ") + "]", "[" + next
93784
95092
  }
93785
95093
  },
93786
95094
  enqueueReplaceState: function(inst, payload, callback) {
93787
- var fiber = get(inst);
95095
+ var fiber = get2(inst);
93788
95096
  var eventTime = requestEventTime();
93789
95097
  var lane = requestUpdateLane(fiber);
93790
95098
  var update = createUpdate(eventTime, lane);
@@ -93806,7 +95114,7 @@ Incoming: %s`, currentHookNameInDev, "[" + prevDeps.join(", ") + "]", "[" + next
93806
95114
  }
93807
95115
  },
93808
95116
  enqueueForceUpdate: function(inst, callback) {
93809
- var fiber = get(inst);
95117
+ var fiber = get2(inst);
93810
95118
  var eventTime = requestEventTime();
93811
95119
  var lane = requestUpdateLane(fiber);
93812
95120
  var update = createUpdate(eventTime, lane);
@@ -93935,7 +95243,7 @@ Learn more about this warning here: https://reactjs.org/link/legacy-context`, na
93935
95243
  error("%s: getSnapshotBeforeUpdate() is defined as a static method and will be ignored. Instead, declare it as an instance method.", name);
93936
95244
  }
93937
95245
  var _state = instance.state;
93938
- if (_state && (typeof _state !== "object" || isArray(_state))) {
95246
+ if (_state && (typeof _state !== "object" || isArray2(_state))) {
93939
95247
  error("%s.state: must be set to an object or null", name);
93940
95248
  }
93941
95249
  if (typeof instance.getChildContext === "function" && typeof ctor.childContextTypes !== "object") {
@@ -95711,7 +97019,7 @@ Check the render method of \`` + ownerName + "`.";
95711
97019
  }
95712
97020
  function validateSuspenseListNestedChild(childSlot, index2) {
95713
97021
  {
95714
- var isAnArray = isArray(childSlot);
97022
+ var isAnArray = isArray2(childSlot);
95715
97023
  var isIterable = !isAnArray && typeof getIteratorFn(childSlot) === "function";
95716
97024
  if (isAnArray || isIterable) {
95717
97025
  var type = isAnArray ? "array" : "iterable";
@@ -95724,7 +97032,7 @@ Check the render method of \`` + ownerName + "`.";
95724
97032
  function validateSuspenseListChildren(children, revealOrder) {
95725
97033
  {
95726
97034
  if ((revealOrder === "forwards" || revealOrder === "backwards") && children !== undefined && children !== null && children !== false) {
95727
- if (isArray(children)) {
97035
+ if (isArray2(children)) {
95728
97036
  for (var i = 0;i < children.length; i++) {
95729
97037
  if (!validateSuspenseListNestedChild(children[i], i)) {
95730
97038
  return;
@@ -101547,7 +102855,7 @@ Check the render method of \`` + ownerName + "`.";
101547
102855
  if (!parentComponent) {
101548
102856
  return emptyContextObject;
101549
102857
  }
101550
- var fiber = get(parentComponent);
102858
+ var fiber = get2(parentComponent);
101551
102859
  var parentContext = findCurrentUnmaskedContext(fiber);
101552
102860
  if (fiber.tag === ClassComponent) {
101553
102861
  var Component = fiber.type;
@@ -101558,7 +102866,7 @@ Check the render method of \`` + ownerName + "`.";
101558
102866
  return parentContext;
101559
102867
  }
101560
102868
  function findHostInstance(component) {
101561
- var fiber = get(component);
102869
+ var fiber = get2(component);
101562
102870
  if (fiber === undefined) {
101563
102871
  if (typeof component.render === "function") {
101564
102872
  throw new Error("Unable to find node on an unmounted component.");
@@ -101575,7 +102883,7 @@ Check the render method of \`` + ownerName + "`.";
101575
102883
  }
101576
102884
  function findHostInstanceWithWarning(component, methodName) {
101577
102885
  {
101578
- var fiber = get(component);
102886
+ var fiber = get2(component);
101579
102887
  if (fiber === undefined) {
101580
102888
  if (typeof component.render === "function") {
101581
102889
  throw new Error("Unable to find node on an unmounted component.");
@@ -101790,9 +103098,9 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
101790
103098
  {
101791
103099
  var copyWithDeleteImpl = function(obj, path23, index2) {
101792
103100
  var key = path23[index2];
101793
- var updated = isArray(obj) ? obj.slice() : assign2({}, obj);
103101
+ var updated = isArray2(obj) ? obj.slice() : assign2({}, obj);
101794
103102
  if (index2 + 1 === path23.length) {
101795
- if (isArray(updated)) {
103103
+ if (isArray2(updated)) {
101796
103104
  updated.splice(key, 1);
101797
103105
  } else {
101798
103106
  delete updated[key];
@@ -101807,11 +103115,11 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
101807
103115
  };
101808
103116
  var copyWithRenameImpl = function(obj, oldPath, newPath, index2) {
101809
103117
  var oldKey = oldPath[index2];
101810
- var updated = isArray(obj) ? obj.slice() : assign2({}, obj);
103118
+ var updated = isArray2(obj) ? obj.slice() : assign2({}, obj);
101811
103119
  if (index2 + 1 === oldPath.length) {
101812
103120
  var newKey = newPath[index2];
101813
103121
  updated[newKey] = updated[oldKey];
101814
- if (isArray(updated)) {
103122
+ if (isArray2(updated)) {
101815
103123
  updated.splice(oldKey, 1);
101816
103124
  } else {
101817
103125
  delete updated[oldKey];
@@ -101840,7 +103148,7 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
101840
103148
  return value;
101841
103149
  }
101842
103150
  var key = path23[index2];
101843
- var updated = isArray(obj) ? obj.slice() : assign2({}, obj);
103151
+ var updated = isArray2(obj) ? obj.slice() : assign2({}, obj);
101844
103152
  updated[key] = copyWithSetImpl(obj[key], path23, index2 + 1, value);
101845
103153
  return updated;
101846
103154
  };
@@ -107127,12 +108435,12 @@ var require_extend_shallow = __commonJS2({
107127
108435
  };
107128
108436
  function assign2(a, b3) {
107129
108437
  for (var key in b3) {
107130
- if (hasOwn(b3, key)) {
108438
+ if (hasOwn2(b3, key)) {
107131
108439
  a[key] = b3[key];
107132
108440
  }
107133
108441
  }
107134
108442
  }
107135
- function hasOwn(obj, key) {
108443
+ function hasOwn2(obj, key) {
107136
108444
  return Object.prototype.hasOwnProperty.call(obj, key);
107137
108445
  }
107138
108446
  }
@@ -107153,7 +108461,7 @@ var require_is_buffer = __commonJS2({
107153
108461
  var require_kind_of = __commonJS2({
107154
108462
  "node_modules/kind-of/index.js"(exports2, module2) {
107155
108463
  var isBuffer = require_is_buffer();
107156
- var toString = Object.prototype.toString;
108464
+ var toString2 = Object.prototype.toString;
107157
108465
  module2.exports = function kindOf(val) {
107158
108466
  if (typeof val === "undefined") {
107159
108467
  return "undefined";
@@ -107182,7 +108490,7 @@ var require_kind_of = __commonJS2({
107182
108490
  if (val instanceof Date) {
107183
108491
  return "date";
107184
108492
  }
107185
- var type = toString.call(val);
108493
+ var type = toString2.call(val);
107186
108494
  if (type === "[object RegExp]") {
107187
108495
  return "regexp";
107188
108496
  }
@@ -114868,14 +116176,14 @@ var BinTrieFlags;
114868
116176
  BinTrieFlags2[BinTrieFlags2["BRANCH_LENGTH"] = 16256] = "BRANCH_LENGTH";
114869
116177
  BinTrieFlags2[BinTrieFlags2["JUMP_TABLE"] = 127] = "JUMP_TABLE";
114870
116178
  })(BinTrieFlags || (BinTrieFlags = {}));
114871
- function isNumber(code) {
116179
+ function isNumber2(code) {
114872
116180
  return code >= CharCodes.ZERO && code <= CharCodes.NINE;
114873
116181
  }
114874
116182
  function isHexadecimalCharacter(code) {
114875
116183
  return code >= CharCodes.UPPER_A && code <= CharCodes.UPPER_F || code >= CharCodes.LOWER_A && code <= CharCodes.LOWER_F;
114876
116184
  }
114877
116185
  function isAsciiAlphaNumeric(code) {
114878
- return code >= CharCodes.UPPER_A && code <= CharCodes.UPPER_Z || code >= CharCodes.LOWER_A && code <= CharCodes.LOWER_Z || isNumber(code);
116186
+ return code >= CharCodes.UPPER_A && code <= CharCodes.UPPER_Z || code >= CharCodes.LOWER_A && code <= CharCodes.LOWER_Z || isNumber2(code);
114879
116187
  }
114880
116188
  function isEntityInAttributeInvalidEnd(code) {
114881
116189
  return code === CharCodes.EQUALS || isAsciiAlphaNumeric(code);
@@ -114962,7 +116270,7 @@ var EntityDecoder = class {
114962
116270
  const startIdx = offset;
114963
116271
  while (offset < str.length) {
114964
116272
  const char = str.charCodeAt(offset);
114965
- if (isNumber(char) || isHexadecimalCharacter(char)) {
116273
+ if (isNumber2(char) || isHexadecimalCharacter(char)) {
114966
116274
  offset += 1;
114967
116275
  } else {
114968
116276
  this.addToNumericResult(str, startIdx, offset, 16);
@@ -114976,7 +116284,7 @@ var EntityDecoder = class {
114976
116284
  const startIdx = offset;
114977
116285
  while (offset < str.length) {
114978
116286
  const char = str.charCodeAt(offset);
114979
- if (isNumber(char)) {
116287
+ if (isNumber2(char)) {
114980
116288
  offset += 1;
114981
116289
  } else {
114982
116290
  this.addToNumericResult(str, startIdx, offset, 10);
@@ -116003,7 +117311,7 @@ function isQuote(c) {
116003
117311
  function isWhitespace(c) {
116004
117312
  return c === 32 || c === 9 || c === 10 || c === 12 || c === 13;
116005
117313
  }
116006
- function parse3(selector) {
117314
+ function parse4(selector) {
116007
117315
  const subselects2 = [];
116008
117316
  const endIndex = parseSelector(subselects2, `${selector}`, 0);
116009
117317
  if (endIndex < selector.length) {
@@ -116898,7 +118206,7 @@ function compilePseudoSelector(next, selector, options, context, compileToken2)
116898
118206
  if (data != null) {
116899
118207
  throw new Error(`Pseudo ${name} doesn't have any arguments`);
116900
118208
  }
116901
- const alias = parse3(stringPseudo);
118209
+ const alias = parse4(stringPseudo);
116902
118210
  return subselects["is"](next, alias, options, context, compileToken2);
116903
118211
  }
116904
118212
  if (typeof userPseudo === "function") {
@@ -117050,7 +118358,7 @@ function compile2(selector, options, context) {
117050
118358
  return ensureIsTag(next, options.adapter);
117051
118359
  }
117052
118360
  function compileUnsafe(selector, options, context) {
117053
- const token = typeof selector === "string" ? parse3(selector) : selector;
118361
+ const token = typeof selector === "string" ? parse4(selector) : selector;
117054
118362
  return compileToken(token, options, context);
117055
118363
  }
117056
118364
  function includesScopePseudo(t3) {
@@ -122109,7 +123417,7 @@ To pass a single animation please supply them in simple values, e.g. animation('
122109
123417
  "78": `base must be set in "px" or "%" but you set it in "%s".
122110
123418
  `
122111
123419
  };
122112
- function format() {
123420
+ function format2() {
122113
123421
  for (var _len = arguments.length, args = new Array(_len), _key = 0;_key < _len; _key++) {
122114
123422
  args[_key] = arguments[_key];
122115
123423
  }
@@ -122132,7 +123440,7 @@ var PolishedError = /* @__PURE__ */ function(_Error) {
122132
123440
  for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1;_key2 < _len2; _key2++) {
122133
123441
  args[_key2 - 1] = arguments[_key2];
122134
123442
  }
122135
- _this = _Error.call(this, format.apply(undefined, [ERRORS[code]].concat(args))) || this;
123443
+ _this = _Error.call(this, format2.apply(undefined, [ERRORS[code]].concat(args))) || this;
122136
123444
  }
122137
123445
  return _assertThisInitialized(_this);
122138
123446
  }
@@ -125976,8 +127284,8 @@ function computeDumbbellPaths({
125976
127284
  return closestPoint;
125977
127285
  const dirX = closestPoint.x - circleCenter.x;
125978
127286
  const dirY = closestPoint.y - circleCenter.y;
125979
- const norm = Math.sqrt(dirX * dirX + dirY * dirY);
125980
- if (norm === 0) {
127287
+ const norm2 = Math.sqrt(dirX * dirX + dirY * dirY);
127288
+ if (norm2 === 0) {
125981
127289
  const segDirX = segment2.end.x - segment2.start.x;
125982
127290
  const segDirY = segment2.end.y - segment2.start.y;
125983
127291
  const segNorm = Math.sqrt(segDirX * segDirX + segDirY * segDirY);
@@ -125990,8 +127298,8 @@ function computeDumbbellPaths({
125990
127298
  };
125991
127299
  }
125992
127300
  return {
125993
- x: circleCenter.x + r3 * dirX / norm,
125994
- y: circleCenter.y + r3 * dirY / norm,
127301
+ x: circleCenter.x + r3 * dirX / norm2,
127302
+ y: circleCenter.y + r3 * dirY / norm2,
125995
127303
  t: closestPoint.t,
125996
127304
  isSpecial: true,
125997
127305
  specialType: circleCenter === A3 ? "A" : "B"
@@ -126311,12 +127619,12 @@ function computeDumbbellPaths({
126311
127619
  const closestPt = closestPointOnSegment(segment2, oppositePoint);
126312
127620
  const dirX = closestPt.x - oppositePoint.x;
126313
127621
  const dirY = closestPt.y - oppositePoint.y;
126314
- const norm = Math.sqrt(dirX * dirX + dirY * dirY);
127622
+ const norm2 = Math.sqrt(dirX * dirX + dirY * dirY);
126315
127623
  let adjustedPoint = null;
126316
- if (norm > 0.000001) {
127624
+ if (norm2 > 0.000001) {
126317
127625
  adjustedPoint = {
126318
- x: oppositePoint.x + minDistThreshold * dirX / norm,
126319
- y: oppositePoint.y + minDistThreshold * dirY / norm
127626
+ x: oppositePoint.x + minDistThreshold * dirX / norm2,
127627
+ y: oppositePoint.y + minDistThreshold * dirY / norm2
126320
127628
  };
126321
127629
  } else {
126322
127630
  const segDirX = segment2.end.x - segment2.start.x;
@@ -126716,10 +128024,10 @@ var TwoCrossingRoutesHighDensitySolver = class extends BaseSolver {
126716
128024
  const pushAmount = overlap * pushDecayFactor;
126717
128025
  const dx2 = currentVia1.x - endpoint.x;
126718
128026
  const dy2 = currentVia1.y - endpoint.y;
126719
- const norm = Math.sqrt(dx2 * dx2 + dy2 * dy2);
126720
- if (norm > 0.000001) {
126721
- currentVia1.x += dx2 / norm * pushAmount;
126722
- currentVia1.y += dy2 / norm * pushAmount;
128027
+ const norm2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
128028
+ if (norm2 > 0.000001) {
128029
+ currentVia1.x += dx2 / norm2 * pushAmount;
128030
+ currentVia1.y += dy2 / norm2 * pushAmount;
126723
128031
  via1Moved = true;
126724
128032
  }
126725
128033
  }
@@ -126729,10 +128037,10 @@ var TwoCrossingRoutesHighDensitySolver = class extends BaseSolver {
126729
128037
  const pushAmount = overlap * pushDecayFactor;
126730
128038
  const dx2 = currentVia2.x - endpoint.x;
126731
128039
  const dy2 = currentVia2.y - endpoint.y;
126732
- const norm = Math.sqrt(dx2 * dx2 + dy2 * dy2);
126733
- if (norm > 0.000001) {
126734
- currentVia2.x += dx2 / norm * pushAmount;
126735
- currentVia2.y += dy2 / norm * pushAmount;
128040
+ const norm2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
128041
+ if (norm2 > 0.000001) {
128042
+ currentVia2.x += dx2 / norm2 * pushAmount;
128043
+ currentVia2.y += dy2 / norm2 * pushAmount;
126736
128044
  via2Moved = true;
126737
128045
  }
126738
128046
  }
@@ -126743,12 +128051,12 @@ var TwoCrossingRoutesHighDensitySolver = class extends BaseSolver {
126743
128051
  const pushAmount = overlap / 2;
126744
128052
  const dx2 = currentVia2.x - currentVia1.x;
126745
128053
  const dy2 = currentVia2.y - currentVia1.y;
126746
- const norm = Math.sqrt(dx2 * dx2 + dy2 * dy2);
126747
- if (norm > 0.000001) {
126748
- currentVia1.x -= dx2 / norm * pushAmount;
126749
- currentVia1.y -= dy2 / norm * pushAmount;
126750
- currentVia2.x += dx2 / norm * pushAmount;
126751
- currentVia2.y += dy2 / norm * pushAmount;
128054
+ const norm2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
128055
+ if (norm2 > 0.000001) {
128056
+ currentVia1.x -= dx2 / norm2 * pushAmount;
128057
+ currentVia1.y -= dy2 / norm2 * pushAmount;
128058
+ currentVia2.x += dx2 / norm2 * pushAmount;
128059
+ currentVia2.y += dy2 / norm2 * pushAmount;
126752
128060
  via1Moved = true;
126753
128061
  via2Moved = true;
126754
128062
  } else {
@@ -126768,12 +128076,12 @@ var TwoCrossingRoutesHighDensitySolver = class extends BaseSolver {
126768
128076
  const pushAmount = overlap / 2;
126769
128077
  const dx2 = currentVia2.x - currentVia1.x;
126770
128078
  const dy2 = currentVia2.y - currentVia1.y;
126771
- const norm = Math.sqrt(dx2 * dx2 + dy2 * dy2);
126772
- if (norm > 0.000001) {
126773
- currentVia1.x -= dx2 / norm * pushAmount;
126774
- currentVia1.y -= dy2 / norm * pushAmount;
126775
- currentVia2.x += dx2 / norm * pushAmount;
126776
- currentVia2.y += dy2 / norm * pushAmount;
128079
+ const norm2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
128080
+ if (norm2 > 0.000001) {
128081
+ currentVia1.x -= dx2 / norm2 * pushAmount;
128082
+ currentVia1.y -= dy2 / norm2 * pushAmount;
128083
+ currentVia2.x += dx2 / norm2 * pushAmount;
128084
+ currentVia2.y += dy2 / norm2 * pushAmount;
126777
128085
  } else {
126778
128086
  currentVia1.x -= pushAmount;
126779
128087
  currentVia2.x += pushAmount;
@@ -154694,9 +156002,9 @@ var Line$1 = class Line extends Shape {
154694
156002
  return;
154695
156003
  }
154696
156004
  if (args.length === 1 && args[0] instanceof Object && args[0].name === "line") {
154697
- let { pt: pt2, norm } = args[0];
156005
+ let { pt: pt2, norm: norm2 } = args[0];
154698
156006
  this.pt = new Flatten.Point(pt2);
154699
- this.norm = new Flatten.Vector(norm);
156007
+ this.norm = new Flatten.Vector(norm2);
154700
156008
  return;
154701
156009
  }
154702
156010
  if (args.length === 2) {
@@ -158662,7 +159970,7 @@ __export3(components_exports, {
158662
159970
  FabricationNotePath: () => FabricationNotePath,
158663
159971
  FabricationNoteText: () => FabricationNoteText,
158664
159972
  Footprint: () => Footprint,
158665
- Fuse: () => Fuse,
159973
+ Fuse: () => Fuse2,
158666
159974
  Group: () => Group,
158667
159975
  Hole: () => Hole,
158668
159976
  Inductor: () => Inductor,
@@ -166791,7 +168099,7 @@ var Diode = class extends NormalComponent {
166791
168099
  neg = this.portMap.pin2;
166792
168100
  cathode = this.portMap.pin2;
166793
168101
  };
166794
- var Fuse = class extends NormalComponent {
168102
+ var Fuse2 = class extends NormalComponent {
166795
168103
  get config() {
166796
168104
  return {
166797
168105
  componentName: "fuse",
@@ -170037,13 +171345,13 @@ var require_ms2 = __commonJS3({
170037
171345
  options = options || {};
170038
171346
  var type = typeof val;
170039
171347
  if (type === "string" && val.length > 0) {
170040
- return parse4(val);
171348
+ return parse5(val);
170041
171349
  } else if (type === "number" && isFinite(val)) {
170042
171350
  return options.long ? fmtLong(val) : fmtShort(val);
170043
171351
  }
170044
171352
  throw new Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(val));
170045
171353
  };
170046
- function parse4(str) {
171354
+ function parse5(str) {
170047
171355
  str = String(str);
170048
171356
  if (str.length > 100) {
170049
171357
  return;
@@ -170182,12 +171490,12 @@ var require_common4 = __commonJS3({
170182
171490
  args.unshift("%O");
170183
171491
  }
170184
171492
  let index = 0;
170185
- args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format2) => {
171493
+ args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format3) => {
170186
171494
  if (match === "%%") {
170187
171495
  return "%";
170188
171496
  }
170189
171497
  index++;
170190
- const formatter = createDebug.formatters[format2];
171498
+ const formatter = createDebug.formatters[format3];
170191
171499
  if (typeof formatter === "function") {
170192
171500
  const val = args[index];
170193
171501
  match = formatter.call(self2, val);
@@ -170246,13 +171554,13 @@ var require_common4 = __commonJS3({
170246
171554
  }
170247
171555
  }
170248
171556
  }
170249
- function matchesTemplate(search, template) {
171557
+ function matchesTemplate(search2, template) {
170250
171558
  let searchIndex = 0;
170251
171559
  let templateIndex = 0;
170252
171560
  let starIndex = -1;
170253
171561
  let matchIndex = 0;
170254
- while (searchIndex < search.length) {
170255
- if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) {
171562
+ while (searchIndex < search2.length) {
171563
+ if (templateIndex < template.length && (template[templateIndex] === search2[searchIndex] || template[templateIndex] === "*")) {
170256
171564
  if (template[templateIndex] === "*") {
170257
171565
  starIndex = templateIndex;
170258
171566
  matchIndex = searchIndex;