@tscircuit/cli 0.1.206 → 0.1.207

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 +1 -1
  2. package/dist/main.js +1389 -84
  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.206";
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,26 +69577,1330 @@ 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) => {
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)").action(async (query) => {
69582
70877
  const ky2 = getRegistryApiKy();
69583
70878
  let results = { packages: [] };
69584
70879
  let jlcResults = [];
70880
+ let kicadResults = [];
69585
70881
  try {
69586
70882
  results = await ky2.post("packages/search", {
69587
70883
  json: { query }
69588
70884
  }).json();
69589
70885
  const jlcSearchUrl = "https://jlcsearch.tscircuit.com/api/search?limit=10&q=" + encodeURIComponent(query);
69590
70886
  jlcResults = (await fetch(jlcSearchUrl).then((r) => r.json())).components;
70887
+ const kicadFiles = await fetch("https://kicad-mod-cache.tscircuit.com/kicad_files.json").then((r) => r.json());
70888
+ const fuse = new Fuse(kicadFiles);
70889
+ kicadResults = fuse.search(query).slice(0, 10).map((r) => r.item);
69591
70890
  } catch (error) {
69592
70891
  console.error(kleur_default.red("Failed to search registry:"), error instanceof Error ? error.message : error);
69593
70892
  process.exit(1);
69594
70893
  }
69595
- if (!results.packages.length && !jlcResults.length) {
70894
+ if (!results.packages.length && !jlcResults.length && !kicadResults.length) {
69596
70895
  console.log(kleur_default.yellow("No results found matching your query."));
69597
70896
  return;
69598
70897
  }
70898
+ if (kicadResults.length) {
70899
+ console.log(kleur_default.bold().underline(`Found ${kicadResults.length} footprint(s) from KiCad:`));
70900
+ kicadResults.forEach((path23, idx) => {
70901
+ console.log(`${(idx + 1).toString().padStart(2, " ")}. ${path23.replace(".kicad_mod", "").replace(".pretty", "")}`);
70902
+ });
70903
+ }
69599
70904
  if (results.packages.length) {
69600
70905
  console.log(kleur_default.bold().underline(`Found ${results.packages.length} package(s) in the tscircuit registry:`));
69601
70906
  results.packages.forEach((pkg, idx) => {
@@ -69607,7 +70912,7 @@ var registerSearch = (program3) => {
69607
70912
  console.log();
69608
70913
  console.log(kleur_default.bold().underline(`Found ${jlcResults.length} component(s) in JLC search:`));
69609
70914
  jlcResults.forEach((comp, idx) => {
69610
- console.log(`${idx + 1}. ${comp.mfr} (C${comp.lcsc}) - ${comp.description}`);
70915
+ console.log(`${idx + 1}. ${comp.mfr} (C${comp.lcsc}) - ${comp.description} (stock: ${comp.stock.toLocaleString("en-US")})`);
69611
70916
  });
69612
70917
  }
69613
70918
  console.log(`
@@ -76082,13 +77387,13 @@ var require_common3 = __commonJS2({
76082
77387
  }
76083
77388
  }
76084
77389
  }
76085
- function matchesTemplate(search, template) {
77390
+ function matchesTemplate(search2, template) {
76086
77391
  let searchIndex = 0;
76087
77392
  let templateIndex = 0;
76088
77393
  let starIndex = -1;
76089
77394
  let matchIndex = 0;
76090
- while (searchIndex < search.length) {
76091
- if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) {
77395
+ while (searchIndex < search2.length) {
77396
+ if (templateIndex < template.length && (template[templateIndex] === search2[searchIndex] || template[templateIndex] === "*")) {
76092
77397
  if (template[templateIndex] === "*") {
76093
77398
  starIndex = templateIndex;
76094
77399
  matchIndex = searchIndex;
@@ -87320,7 +88625,7 @@ var require_react_reconciler_development2 = __commonJS2({
87320
88625
  }
87321
88626
  }
87322
88627
  var assign2 = Object.assign;
87323
- function get(key) {
88628
+ function get2(key) {
87324
88629
  return key._reactInternals;
87325
88630
  }
87326
88631
  function set(key, value) {
@@ -87595,7 +88900,7 @@ var require_react_reconciler_development2 = __commonJS2({
87595
88900
  instance._warnedAboutRefsInRender = true;
87596
88901
  }
87597
88902
  }
87598
- var fiber = get(component);
88903
+ var fiber = get2(component);
87599
88904
  if (!fiber) {
87600
88905
  return false;
87601
88906
  }
@@ -87743,7 +89048,7 @@ var require_react_reconciler_development2 = __commonJS2({
87743
89048
  return null;
87744
89049
  }
87745
89050
  var isArrayImpl = Array.isArray;
87746
- function isArray(a) {
89051
+ function isArray2(a) {
87747
89052
  return isArrayImpl(a);
87748
89053
  }
87749
89054
  var getPublicInstance = $$$hostConfig.getPublicInstance;
@@ -90425,7 +91730,7 @@ See https://reactjs.org/link/refs-must-have-owner for more information.`);
90425
91730
  return createChild(returnFiber, init2(payload), lanes);
90426
91731
  }
90427
91732
  }
90428
- if (isArray(newChild) || getIteratorFn(newChild)) {
91733
+ if (isArray2(newChild) || getIteratorFn(newChild)) {
90429
91734
  var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null);
90430
91735
  _created3.return = returnFiber;
90431
91736
  return _created3;
@@ -90469,7 +91774,7 @@ See https://reactjs.org/link/refs-must-have-owner for more information.`);
90469
91774
  return updateSlot(returnFiber, oldFiber, init2(payload), lanes);
90470
91775
  }
90471
91776
  }
90472
- if (isArray(newChild) || getIteratorFn(newChild)) {
91777
+ if (isArray2(newChild) || getIteratorFn(newChild)) {
90473
91778
  if (key !== null) {
90474
91779
  return null;
90475
91780
  }
@@ -90504,7 +91809,7 @@ See https://reactjs.org/link/refs-must-have-owner for more information.`);
90504
91809
  var init2 = newChild._init;
90505
91810
  return updateFromMap(existingChildren, returnFiber, newIdx, init2(payload), lanes);
90506
91811
  }
90507
- if (isArray(newChild) || getIteratorFn(newChild)) {
91812
+ if (isArray2(newChild) || getIteratorFn(newChild)) {
90508
91813
  var _matchedFiber3 = existingChildren.get(newIdx) || null;
90509
91814
  return updateFragment2(returnFiber, _matchedFiber3, newChild, lanes, null);
90510
91815
  }
@@ -90872,7 +92177,7 @@ See https://reactjs.org/link/refs-must-have-owner for more information.`);
90872
92177
  var init2 = newChild._init;
90873
92178
  return reconcileChildFibers2(returnFiber, currentFirstChild, init2(payload), lanes);
90874
92179
  }
90875
- if (isArray(newChild)) {
92180
+ if (isArray2(newChild)) {
90876
92181
  return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes);
90877
92182
  }
90878
92183
  if (getIteratorFn(newChild)) {
@@ -91781,7 +93086,7 @@ See https://reactjs.org/link/refs-must-have-owner for more information.`);
91781
93086
  }
91782
93087
  function checkDepsAreArrayDev(deps) {
91783
93088
  {
91784
- if (deps !== undefined && deps !== null && !isArray(deps)) {
93089
+ if (deps !== undefined && deps !== null && !isArray2(deps)) {
91785
93090
  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
93091
  }
91787
93092
  }
@@ -93763,7 +95068,7 @@ Incoming: %s`, currentHookNameInDev, "[" + prevDeps.join(", ") + "]", "[" + next
93763
95068
  var classComponentUpdater = {
93764
95069
  isMounted,
93765
95070
  enqueueSetState: function(inst, payload, callback) {
93766
- var fiber = get(inst);
95071
+ var fiber = get2(inst);
93767
95072
  var eventTime = requestEventTime();
93768
95073
  var lane = requestUpdateLane(fiber);
93769
95074
  var update = createUpdate(eventTime, lane);
@@ -93784,7 +95089,7 @@ Incoming: %s`, currentHookNameInDev, "[" + prevDeps.join(", ") + "]", "[" + next
93784
95089
  }
93785
95090
  },
93786
95091
  enqueueReplaceState: function(inst, payload, callback) {
93787
- var fiber = get(inst);
95092
+ var fiber = get2(inst);
93788
95093
  var eventTime = requestEventTime();
93789
95094
  var lane = requestUpdateLane(fiber);
93790
95095
  var update = createUpdate(eventTime, lane);
@@ -93806,7 +95111,7 @@ Incoming: %s`, currentHookNameInDev, "[" + prevDeps.join(", ") + "]", "[" + next
93806
95111
  }
93807
95112
  },
93808
95113
  enqueueForceUpdate: function(inst, callback) {
93809
- var fiber = get(inst);
95114
+ var fiber = get2(inst);
93810
95115
  var eventTime = requestEventTime();
93811
95116
  var lane = requestUpdateLane(fiber);
93812
95117
  var update = createUpdate(eventTime, lane);
@@ -93935,7 +95240,7 @@ Learn more about this warning here: https://reactjs.org/link/legacy-context`, na
93935
95240
  error("%s: getSnapshotBeforeUpdate() is defined as a static method and will be ignored. Instead, declare it as an instance method.", name);
93936
95241
  }
93937
95242
  var _state = instance.state;
93938
- if (_state && (typeof _state !== "object" || isArray(_state))) {
95243
+ if (_state && (typeof _state !== "object" || isArray2(_state))) {
93939
95244
  error("%s.state: must be set to an object or null", name);
93940
95245
  }
93941
95246
  if (typeof instance.getChildContext === "function" && typeof ctor.childContextTypes !== "object") {
@@ -95711,7 +97016,7 @@ Check the render method of \`` + ownerName + "`.";
95711
97016
  }
95712
97017
  function validateSuspenseListNestedChild(childSlot, index2) {
95713
97018
  {
95714
- var isAnArray = isArray(childSlot);
97019
+ var isAnArray = isArray2(childSlot);
95715
97020
  var isIterable = !isAnArray && typeof getIteratorFn(childSlot) === "function";
95716
97021
  if (isAnArray || isIterable) {
95717
97022
  var type = isAnArray ? "array" : "iterable";
@@ -95724,7 +97029,7 @@ Check the render method of \`` + ownerName + "`.";
95724
97029
  function validateSuspenseListChildren(children, revealOrder) {
95725
97030
  {
95726
97031
  if ((revealOrder === "forwards" || revealOrder === "backwards") && children !== undefined && children !== null && children !== false) {
95727
- if (isArray(children)) {
97032
+ if (isArray2(children)) {
95728
97033
  for (var i = 0;i < children.length; i++) {
95729
97034
  if (!validateSuspenseListNestedChild(children[i], i)) {
95730
97035
  return;
@@ -101547,7 +102852,7 @@ Check the render method of \`` + ownerName + "`.";
101547
102852
  if (!parentComponent) {
101548
102853
  return emptyContextObject;
101549
102854
  }
101550
- var fiber = get(parentComponent);
102855
+ var fiber = get2(parentComponent);
101551
102856
  var parentContext = findCurrentUnmaskedContext(fiber);
101552
102857
  if (fiber.tag === ClassComponent) {
101553
102858
  var Component = fiber.type;
@@ -101558,7 +102863,7 @@ Check the render method of \`` + ownerName + "`.";
101558
102863
  return parentContext;
101559
102864
  }
101560
102865
  function findHostInstance(component) {
101561
- var fiber = get(component);
102866
+ var fiber = get2(component);
101562
102867
  if (fiber === undefined) {
101563
102868
  if (typeof component.render === "function") {
101564
102869
  throw new Error("Unable to find node on an unmounted component.");
@@ -101575,7 +102880,7 @@ Check the render method of \`` + ownerName + "`.";
101575
102880
  }
101576
102881
  function findHostInstanceWithWarning(component, methodName) {
101577
102882
  {
101578
- var fiber = get(component);
102883
+ var fiber = get2(component);
101579
102884
  if (fiber === undefined) {
101580
102885
  if (typeof component.render === "function") {
101581
102886
  throw new Error("Unable to find node on an unmounted component.");
@@ -101790,9 +103095,9 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
101790
103095
  {
101791
103096
  var copyWithDeleteImpl = function(obj, path23, index2) {
101792
103097
  var key = path23[index2];
101793
- var updated = isArray(obj) ? obj.slice() : assign2({}, obj);
103098
+ var updated = isArray2(obj) ? obj.slice() : assign2({}, obj);
101794
103099
  if (index2 + 1 === path23.length) {
101795
- if (isArray(updated)) {
103100
+ if (isArray2(updated)) {
101796
103101
  updated.splice(key, 1);
101797
103102
  } else {
101798
103103
  delete updated[key];
@@ -101807,11 +103112,11 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
101807
103112
  };
101808
103113
  var copyWithRenameImpl = function(obj, oldPath, newPath, index2) {
101809
103114
  var oldKey = oldPath[index2];
101810
- var updated = isArray(obj) ? obj.slice() : assign2({}, obj);
103115
+ var updated = isArray2(obj) ? obj.slice() : assign2({}, obj);
101811
103116
  if (index2 + 1 === oldPath.length) {
101812
103117
  var newKey = newPath[index2];
101813
103118
  updated[newKey] = updated[oldKey];
101814
- if (isArray(updated)) {
103119
+ if (isArray2(updated)) {
101815
103120
  updated.splice(oldKey, 1);
101816
103121
  } else {
101817
103122
  delete updated[oldKey];
@@ -101840,7 +103145,7 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
101840
103145
  return value;
101841
103146
  }
101842
103147
  var key = path23[index2];
101843
- var updated = isArray(obj) ? obj.slice() : assign2({}, obj);
103148
+ var updated = isArray2(obj) ? obj.slice() : assign2({}, obj);
101844
103149
  updated[key] = copyWithSetImpl(obj[key], path23, index2 + 1, value);
101845
103150
  return updated;
101846
103151
  };
@@ -107127,12 +108432,12 @@ var require_extend_shallow = __commonJS2({
107127
108432
  };
107128
108433
  function assign2(a, b3) {
107129
108434
  for (var key in b3) {
107130
- if (hasOwn(b3, key)) {
108435
+ if (hasOwn2(b3, key)) {
107131
108436
  a[key] = b3[key];
107132
108437
  }
107133
108438
  }
107134
108439
  }
107135
- function hasOwn(obj, key) {
108440
+ function hasOwn2(obj, key) {
107136
108441
  return Object.prototype.hasOwnProperty.call(obj, key);
107137
108442
  }
107138
108443
  }
@@ -107153,7 +108458,7 @@ var require_is_buffer = __commonJS2({
107153
108458
  var require_kind_of = __commonJS2({
107154
108459
  "node_modules/kind-of/index.js"(exports2, module2) {
107155
108460
  var isBuffer = require_is_buffer();
107156
- var toString = Object.prototype.toString;
108461
+ var toString2 = Object.prototype.toString;
107157
108462
  module2.exports = function kindOf(val) {
107158
108463
  if (typeof val === "undefined") {
107159
108464
  return "undefined";
@@ -107182,7 +108487,7 @@ var require_kind_of = __commonJS2({
107182
108487
  if (val instanceof Date) {
107183
108488
  return "date";
107184
108489
  }
107185
- var type = toString.call(val);
108490
+ var type = toString2.call(val);
107186
108491
  if (type === "[object RegExp]") {
107187
108492
  return "regexp";
107188
108493
  }
@@ -114868,14 +116173,14 @@ var BinTrieFlags;
114868
116173
  BinTrieFlags2[BinTrieFlags2["BRANCH_LENGTH"] = 16256] = "BRANCH_LENGTH";
114869
116174
  BinTrieFlags2[BinTrieFlags2["JUMP_TABLE"] = 127] = "JUMP_TABLE";
114870
116175
  })(BinTrieFlags || (BinTrieFlags = {}));
114871
- function isNumber(code) {
116176
+ function isNumber2(code) {
114872
116177
  return code >= CharCodes.ZERO && code <= CharCodes.NINE;
114873
116178
  }
114874
116179
  function isHexadecimalCharacter(code) {
114875
116180
  return code >= CharCodes.UPPER_A && code <= CharCodes.UPPER_F || code >= CharCodes.LOWER_A && code <= CharCodes.LOWER_F;
114876
116181
  }
114877
116182
  function isAsciiAlphaNumeric(code) {
114878
- return code >= CharCodes.UPPER_A && code <= CharCodes.UPPER_Z || code >= CharCodes.LOWER_A && code <= CharCodes.LOWER_Z || isNumber(code);
116183
+ return code >= CharCodes.UPPER_A && code <= CharCodes.UPPER_Z || code >= CharCodes.LOWER_A && code <= CharCodes.LOWER_Z || isNumber2(code);
114879
116184
  }
114880
116185
  function isEntityInAttributeInvalidEnd(code) {
114881
116186
  return code === CharCodes.EQUALS || isAsciiAlphaNumeric(code);
@@ -114962,7 +116267,7 @@ var EntityDecoder = class {
114962
116267
  const startIdx = offset;
114963
116268
  while (offset < str.length) {
114964
116269
  const char = str.charCodeAt(offset);
114965
- if (isNumber(char) || isHexadecimalCharacter(char)) {
116270
+ if (isNumber2(char) || isHexadecimalCharacter(char)) {
114966
116271
  offset += 1;
114967
116272
  } else {
114968
116273
  this.addToNumericResult(str, startIdx, offset, 16);
@@ -114976,7 +116281,7 @@ var EntityDecoder = class {
114976
116281
  const startIdx = offset;
114977
116282
  while (offset < str.length) {
114978
116283
  const char = str.charCodeAt(offset);
114979
- if (isNumber(char)) {
116284
+ if (isNumber2(char)) {
114980
116285
  offset += 1;
114981
116286
  } else {
114982
116287
  this.addToNumericResult(str, startIdx, offset, 10);
@@ -116003,7 +117308,7 @@ function isQuote(c) {
116003
117308
  function isWhitespace(c) {
116004
117309
  return c === 32 || c === 9 || c === 10 || c === 12 || c === 13;
116005
117310
  }
116006
- function parse3(selector) {
117311
+ function parse4(selector) {
116007
117312
  const subselects2 = [];
116008
117313
  const endIndex = parseSelector(subselects2, `${selector}`, 0);
116009
117314
  if (endIndex < selector.length) {
@@ -116898,7 +118203,7 @@ function compilePseudoSelector(next, selector, options, context, compileToken2)
116898
118203
  if (data != null) {
116899
118204
  throw new Error(`Pseudo ${name} doesn't have any arguments`);
116900
118205
  }
116901
- const alias = parse3(stringPseudo);
118206
+ const alias = parse4(stringPseudo);
116902
118207
  return subselects["is"](next, alias, options, context, compileToken2);
116903
118208
  }
116904
118209
  if (typeof userPseudo === "function") {
@@ -117050,7 +118355,7 @@ function compile2(selector, options, context) {
117050
118355
  return ensureIsTag(next, options.adapter);
117051
118356
  }
117052
118357
  function compileUnsafe(selector, options, context) {
117053
- const token = typeof selector === "string" ? parse3(selector) : selector;
118358
+ const token = typeof selector === "string" ? parse4(selector) : selector;
117054
118359
  return compileToken(token, options, context);
117055
118360
  }
117056
118361
  function includesScopePseudo(t3) {
@@ -122109,7 +123414,7 @@ To pass a single animation please supply them in simple values, e.g. animation('
122109
123414
  "78": `base must be set in "px" or "%" but you set it in "%s".
122110
123415
  `
122111
123416
  };
122112
- function format() {
123417
+ function format2() {
122113
123418
  for (var _len = arguments.length, args = new Array(_len), _key = 0;_key < _len; _key++) {
122114
123419
  args[_key] = arguments[_key];
122115
123420
  }
@@ -122132,7 +123437,7 @@ var PolishedError = /* @__PURE__ */ function(_Error) {
122132
123437
  for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1;_key2 < _len2; _key2++) {
122133
123438
  args[_key2 - 1] = arguments[_key2];
122134
123439
  }
122135
- _this = _Error.call(this, format.apply(undefined, [ERRORS[code]].concat(args))) || this;
123440
+ _this = _Error.call(this, format2.apply(undefined, [ERRORS[code]].concat(args))) || this;
122136
123441
  }
122137
123442
  return _assertThisInitialized(_this);
122138
123443
  }
@@ -125976,8 +127281,8 @@ function computeDumbbellPaths({
125976
127281
  return closestPoint;
125977
127282
  const dirX = closestPoint.x - circleCenter.x;
125978
127283
  const dirY = closestPoint.y - circleCenter.y;
125979
- const norm = Math.sqrt(dirX * dirX + dirY * dirY);
125980
- if (norm === 0) {
127284
+ const norm2 = Math.sqrt(dirX * dirX + dirY * dirY);
127285
+ if (norm2 === 0) {
125981
127286
  const segDirX = segment2.end.x - segment2.start.x;
125982
127287
  const segDirY = segment2.end.y - segment2.start.y;
125983
127288
  const segNorm = Math.sqrt(segDirX * segDirX + segDirY * segDirY);
@@ -125990,8 +127295,8 @@ function computeDumbbellPaths({
125990
127295
  };
125991
127296
  }
125992
127297
  return {
125993
- x: circleCenter.x + r3 * dirX / norm,
125994
- y: circleCenter.y + r3 * dirY / norm,
127298
+ x: circleCenter.x + r3 * dirX / norm2,
127299
+ y: circleCenter.y + r3 * dirY / norm2,
125995
127300
  t: closestPoint.t,
125996
127301
  isSpecial: true,
125997
127302
  specialType: circleCenter === A3 ? "A" : "B"
@@ -126311,12 +127616,12 @@ function computeDumbbellPaths({
126311
127616
  const closestPt = closestPointOnSegment(segment2, oppositePoint);
126312
127617
  const dirX = closestPt.x - oppositePoint.x;
126313
127618
  const dirY = closestPt.y - oppositePoint.y;
126314
- const norm = Math.sqrt(dirX * dirX + dirY * dirY);
127619
+ const norm2 = Math.sqrt(dirX * dirX + dirY * dirY);
126315
127620
  let adjustedPoint = null;
126316
- if (norm > 0.000001) {
127621
+ if (norm2 > 0.000001) {
126317
127622
  adjustedPoint = {
126318
- x: oppositePoint.x + minDistThreshold * dirX / norm,
126319
- y: oppositePoint.y + minDistThreshold * dirY / norm
127623
+ x: oppositePoint.x + minDistThreshold * dirX / norm2,
127624
+ y: oppositePoint.y + minDistThreshold * dirY / norm2
126320
127625
  };
126321
127626
  } else {
126322
127627
  const segDirX = segment2.end.x - segment2.start.x;
@@ -126716,10 +128021,10 @@ var TwoCrossingRoutesHighDensitySolver = class extends BaseSolver {
126716
128021
  const pushAmount = overlap * pushDecayFactor;
126717
128022
  const dx2 = currentVia1.x - endpoint.x;
126718
128023
  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;
128024
+ const norm2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
128025
+ if (norm2 > 0.000001) {
128026
+ currentVia1.x += dx2 / norm2 * pushAmount;
128027
+ currentVia1.y += dy2 / norm2 * pushAmount;
126723
128028
  via1Moved = true;
126724
128029
  }
126725
128030
  }
@@ -126729,10 +128034,10 @@ var TwoCrossingRoutesHighDensitySolver = class extends BaseSolver {
126729
128034
  const pushAmount = overlap * pushDecayFactor;
126730
128035
  const dx2 = currentVia2.x - endpoint.x;
126731
128036
  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;
128037
+ const norm2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
128038
+ if (norm2 > 0.000001) {
128039
+ currentVia2.x += dx2 / norm2 * pushAmount;
128040
+ currentVia2.y += dy2 / norm2 * pushAmount;
126736
128041
  via2Moved = true;
126737
128042
  }
126738
128043
  }
@@ -126743,12 +128048,12 @@ var TwoCrossingRoutesHighDensitySolver = class extends BaseSolver {
126743
128048
  const pushAmount = overlap / 2;
126744
128049
  const dx2 = currentVia2.x - currentVia1.x;
126745
128050
  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;
128051
+ const norm2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
128052
+ if (norm2 > 0.000001) {
128053
+ currentVia1.x -= dx2 / norm2 * pushAmount;
128054
+ currentVia1.y -= dy2 / norm2 * pushAmount;
128055
+ currentVia2.x += dx2 / norm2 * pushAmount;
128056
+ currentVia2.y += dy2 / norm2 * pushAmount;
126752
128057
  via1Moved = true;
126753
128058
  via2Moved = true;
126754
128059
  } else {
@@ -126768,12 +128073,12 @@ var TwoCrossingRoutesHighDensitySolver = class extends BaseSolver {
126768
128073
  const pushAmount = overlap / 2;
126769
128074
  const dx2 = currentVia2.x - currentVia1.x;
126770
128075
  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;
128076
+ const norm2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
128077
+ if (norm2 > 0.000001) {
128078
+ currentVia1.x -= dx2 / norm2 * pushAmount;
128079
+ currentVia1.y -= dy2 / norm2 * pushAmount;
128080
+ currentVia2.x += dx2 / norm2 * pushAmount;
128081
+ currentVia2.y += dy2 / norm2 * pushAmount;
126777
128082
  } else {
126778
128083
  currentVia1.x -= pushAmount;
126779
128084
  currentVia2.x += pushAmount;
@@ -154694,9 +155999,9 @@ var Line$1 = class Line extends Shape {
154694
155999
  return;
154695
156000
  }
154696
156001
  if (args.length === 1 && args[0] instanceof Object && args[0].name === "line") {
154697
- let { pt: pt2, norm } = args[0];
156002
+ let { pt: pt2, norm: norm2 } = args[0];
154698
156003
  this.pt = new Flatten.Point(pt2);
154699
- this.norm = new Flatten.Vector(norm);
156004
+ this.norm = new Flatten.Vector(norm2);
154700
156005
  return;
154701
156006
  }
154702
156007
  if (args.length === 2) {
@@ -158662,7 +159967,7 @@ __export3(components_exports, {
158662
159967
  FabricationNotePath: () => FabricationNotePath,
158663
159968
  FabricationNoteText: () => FabricationNoteText,
158664
159969
  Footprint: () => Footprint,
158665
- Fuse: () => Fuse,
159970
+ Fuse: () => Fuse2,
158666
159971
  Group: () => Group,
158667
159972
  Hole: () => Hole,
158668
159973
  Inductor: () => Inductor,
@@ -166791,7 +168096,7 @@ var Diode = class extends NormalComponent {
166791
168096
  neg = this.portMap.pin2;
166792
168097
  cathode = this.portMap.pin2;
166793
168098
  };
166794
- var Fuse = class extends NormalComponent {
168099
+ var Fuse2 = class extends NormalComponent {
166795
168100
  get config() {
166796
168101
  return {
166797
168102
  componentName: "fuse",
@@ -170037,13 +171342,13 @@ var require_ms2 = __commonJS3({
170037
171342
  options = options || {};
170038
171343
  var type = typeof val;
170039
171344
  if (type === "string" && val.length > 0) {
170040
- return parse4(val);
171345
+ return parse5(val);
170041
171346
  } else if (type === "number" && isFinite(val)) {
170042
171347
  return options.long ? fmtLong(val) : fmtShort(val);
170043
171348
  }
170044
171349
  throw new Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(val));
170045
171350
  };
170046
- function parse4(str) {
171351
+ function parse5(str) {
170047
171352
  str = String(str);
170048
171353
  if (str.length > 100) {
170049
171354
  return;
@@ -170182,12 +171487,12 @@ var require_common4 = __commonJS3({
170182
171487
  args.unshift("%O");
170183
171488
  }
170184
171489
  let index = 0;
170185
- args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format2) => {
171490
+ args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format3) => {
170186
171491
  if (match === "%%") {
170187
171492
  return "%";
170188
171493
  }
170189
171494
  index++;
170190
- const formatter = createDebug.formatters[format2];
171495
+ const formatter = createDebug.formatters[format3];
170191
171496
  if (typeof formatter === "function") {
170192
171497
  const val = args[index];
170193
171498
  match = formatter.call(self2, val);
@@ -170246,13 +171551,13 @@ var require_common4 = __commonJS3({
170246
171551
  }
170247
171552
  }
170248
171553
  }
170249
- function matchesTemplate(search, template) {
171554
+ function matchesTemplate(search2, template) {
170250
171555
  let searchIndex = 0;
170251
171556
  let templateIndex = 0;
170252
171557
  let starIndex = -1;
170253
171558
  let matchIndex = 0;
170254
- while (searchIndex < search.length) {
170255
- if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) {
171559
+ while (searchIndex < search2.length) {
171560
+ if (templateIndex < template.length && (template[templateIndex] === search2[searchIndex] || template[templateIndex] === "*")) {
170256
171561
  if (template[templateIndex] === "*") {
170257
171562
  starIndex = templateIndex;
170258
171563
  matchIndex = searchIndex;