-
Notifications
You must be signed in to change notification settings - Fork 1
/
fzf.js
28 lines (23 loc) · 15.1 KB
/
fzf.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
(function (global){(function (){
"use strict";
var _fzf = require("fzf");
global.getFzf = function (list) {
return new _fzf.Fzf(list, {
match: _fzf.extendedMatch,
tiebreakers: [_fzf.byLengthAsc],
selector: function selector(item) {
return item["search_string"];
}
});
};
console.log("fzfjs");
}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"fzf":2}],2:[function(require,module,exports){
/** @license
* fzf v0.4.1
* Copyright (c) 2021 Ajit
* Licensed under BSD 3-Clause
*/
var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(t,e,r)=>e in t?__defProp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,__spreadValues=(t,e)=>{for(var r in e||(e={}))__hasOwnProp.call(e,r)&&__defNormalProp(t,r,e[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(e))__propIsEnum.call(e,r)&&__defNormalProp(t,r,e[r]);return t},__spreadProps=(t,e)=>__defProps(t,__getOwnPropDescs(e));!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).fzf={})}(this,(function(t){"use strict";const e={216:"O",223:"s",248:"o",273:"d",295:"h",305:"i",320:"l",322:"l",359:"t",383:"s",384:"b",385:"B",387:"b",390:"O",392:"c",393:"D",394:"D",396:"d",398:"E",400:"E",402:"f",403:"G",407:"I",409:"k",410:"l",412:"M",413:"N",414:"n",415:"O",421:"p",427:"t",429:"t",430:"T",434:"V",436:"y",438:"z",477:"e",485:"g",544:"N",545:"d",549:"z",564:"l",565:"n",566:"t",567:"j",570:"A",571:"C",572:"c",573:"L",574:"T",575:"s",576:"z",579:"B",580:"U",581:"V",582:"E",583:"e",584:"J",585:"j",586:"Q",587:"q",588:"R",589:"r",590:"Y",591:"y",592:"a",593:"a",595:"b",596:"o",597:"c",598:"d",599:"d",600:"e",603:"e",604:"e",605:"e",606:"e",607:"j",608:"g",609:"g",610:"G",613:"h",614:"h",616:"i",618:"I",619:"l",620:"l",621:"l",623:"m",624:"m",625:"m",626:"n",627:"n",628:"N",629:"o",633:"r",634:"r",635:"r",636:"r",637:"r",638:"r",639:"r",640:"R",641:"R",642:"s",647:"t",648:"t",649:"u",651:"v",652:"v",653:"w",654:"y",655:"Y",656:"z",657:"z",663:"c",665:"B",666:"e",667:"G",668:"H",669:"j",670:"k",671:"L",672:"q",686:"h",867:"a",868:"e",869:"i",870:"o",871:"u",872:"c",873:"d",874:"h",875:"m",876:"r",877:"t",878:"v",879:"x",7424:"A",7427:"B",7428:"C",7429:"D",7431:"E",7432:"e",7433:"i",7434:"J",7435:"K",7436:"L",7437:"M",7438:"N",7439:"O",7440:"O",7441:"o",7442:"o",7443:"o",7446:"o",7447:"o",7448:"P",7449:"R",7450:"R",7451:"T",7452:"U",7453:"u",7454:"u",7455:"m",7456:"V",7457:"W",7458:"Z",7522:"i",7523:"r",7524:"u",7525:"v",7834:"a",7835:"s",8305:"i",8341:"h",8342:"k",8343:"l",8344:"m",8345:"n",8346:"p",8347:"s",8348:"t",8580:"c"};for(let Z="̀".codePointAt(0);Z<="ͯ".codePointAt(0);++Z){const t=String.fromCodePoint(Z);for(const r of"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"){const n=(r+t).normalize().codePointAt(0);n>126&&(e[n]=r)}}const r={a:[7844,7863],e:[7870,7879],o:[7888,7907],u:[7912,7921]};for(const Z of Object.keys(r)){const t=Z.toUpperCase();for(let n=r[Z][0];n<=r[Z][1];++n)e[n]=n%2==0?t:Z}function n(t){if(t<192||t>8580)return t;const r=e[t];return void 0!==r?r.codePointAt(0):t}function o(t,e){return t>e?t:e}const s=t=>t.split("").map((t=>t.codePointAt(0))),i=t=>t.map((t=>String.fromCodePoint(t))).join(""),l=new Set(" \f\n\r\t\v \u2028\u2029 \ufeff".split("").map((t=>t.codePointAt(0))));for(let Z=" ".codePointAt(0);Z<=" ".codePointAt(0);Z++)l.add(Z);const a=t=>l.has(t),c=t=>{let e=0;for(const r of t){if(!a(r))break;e++}return e},u=t=>{let e=0;for(let r=t.length-1;r>=0&&a(t[r]);r--)e++;return e},f="".codePointAt(0),h="A".codePointAt(0),d="Z".codePointAt(0),p="a".codePointAt(0),g="z".codePointAt(0),b="0".codePointAt(0),m="9".codePointAt(0);function y(t,e,r){return r?t:e-t-1}const P=16;var _,w;function S(t){return t?new Set:null}function z(t,e,r){if(null!==e&&e.i16.length>t+r){return[t+r,e.i16.subarray(t,t+r)]}return[t,new Int16Array(r)]}function A(t,e,r){if(null!==e&&e.i32.length>t+r){return[t+r,e.i32.subarray(t,t+r)]}return[t,new Int32Array(r)]}function v(t){return t>=p&&t<=g?1:t>=h&&t<=d?2:t>=b&&t<=m?4:0}function L(t){const e=String.fromCodePoint(t);return e!==e.toUpperCase()?1:e!==e.toLowerCase()?2:null!==e.match(/\p{Number}/gu)?4:null!==e.match(/\p{Letter}/gu)?3:0}function C(t){return t<=f?v(t):L(t)}function O(t,e){return 0===t&&0!==e?8:1===t&&2===e||4!==t&&4===e?7:0===e?8:0}function x(t,e,r,n){let o=t.slice(n),s=o.indexOf(r);if(0===s)return n;if(!e&&r>=p&&r<=g){s>0&&(o=o.slice(0,s));const t=o.indexOf(r-32);t>=0&&(s=t)}return s<0?-1:n+s}function k(t){for(const e of t)if(e>=128)return!1;return!0}function j(t,e,r){if(!k(t))return 0;if(!k(e))return-1;let n=0,o=0;for(let s=0;s<e.length;s++){if(o=x(t,r,e[s],o),o<0)return-1;0===s&&o>0&&(n=o-1),o++}return n}(w=_||(_={}))[w.NonWord=0]="NonWord",w[w.Lower=1]="Lower",w[w.Upper=2]="Upper",w[w.Letter=3]="Letter",w[w.Number=4]="Number";const E=(t,e,r,s,i,l,a)=>{const c=i.length;if(0===c)return[{start:0,end:0,score:0},S(l)];const u=s.length;if(null!==a&&u*c>a.i16.length)return F(t,e,r,s,i,l);const h=j(s,i,t);if(h<0)return[{start:-1,end:-1,score:0},null];let d=0,p=0,g=null,b=null,m=null,y=null;[d,g]=z(d,a,u),[d,b]=z(d,a,u),[d,m]=z(d,a,u),[p,y]=A(p,a,c);const[,_]=A(p,a,u);for(let n=0;n<_.length;n++)_[n]=s[n];let w=0,C=0,x=0,k=0;const E=i[0];let N=i[0],I=0,M=0,R=!1,W=_.subarray(h),V=g.subarray(h).subarray(0,W.length),q=b.subarray(h).subarray(0,W.length),D=m.subarray(h).subarray(0,W.length);for(let[S,z]of W.entries()){let s=null;z<=f?(s=v(z),t||2!==s||(z+=32)):(s=L(z),t||2!==s||(z=String.fromCodePoint(z).toLowerCase().codePointAt(0)),e&&(z=n(z))),W[S]=z;const l=O(M,s);if(D[S]=l,M=s,z===N&&(x<c&&(y[x]=h+S,x++,N=i[Math.min(x,c-1)]),k=h+S),z===E){const t=P+2*l;if(V[S]=t,q[S]=1,1===c&&(r&&t>w||!r&&t>=w)&&(w=t,C=h+S,r&&8===l))break;R=!1}else V[S]=o(R?I+-1:I+-3,0),q[S]=0,R=!0;I=V[S]}if(x!==c)return[{start:-1,end:-1,score:0},null];if(1===c){const t={start:C,end:C+1,score:w};if(!l)return[t,null];const e=new Set;return e.add(C),[t,e]}const T=y[0],U=k-T+1;let B=null;[d,B]=z(d,a,U*c);{const t=g.subarray(T,k+1);for(const[e,r]of t.entries())B[e]=r}let[,G]=z(d,a,U*c);{const t=b.subarray(T,k+1);for(const[e,r]of t.entries())G[e]=r}const J=y.subarray(1),Y=i.slice(1).slice(0,J.length);for(const[n,f]of J.entries()){let t=!1;const e=Y[n],s=n+1,i=s*U,l=_.subarray(f,k+1),a=m.subarray(f).subarray(0,l.length),u=G.subarray(i+f-T).subarray(0,l.length),h=G.subarray(i+f-T-1-U).subarray(0,l.length),d=B.subarray(i+f-T).subarray(0,l.length),p=B.subarray(i+f-T-1-U).subarray(0,l.length),g=B.subarray(i+f-T-1).subarray(0,l.length);g[0]=0;for(const[n,b]of l.entries()){const i=n+f;let l=0,y=0,_=0;if(y=t?g[n]+-1:g[n]+-3,e===b){l=p[n]+P;let t=a[n];_=h[n]+1,8===t?_=1:_>1&&(t=o(t,o(4,m[i-_+1]))),l+t<y?(l+=a[n],_=0):l+=t}u[n]=_,t=l<y;const S=o(o(l,y),0);s===c-1&&(r&&S>w||!r&&S>=w)&&(w=S,C=i),d[n]=S}}const Z=S(l);let H=T;if(l&&null!==Z){let t=c-1;H=C;let e=!0;for(;;){const r=t*U,n=H-T,o=B[r+n];let s=0,i=0;if(t>0&&H>=y[t]&&(s=B[r-U+n-1]),H>y[t]&&(i=B[r+n-1]),o>s&&(o>i||o===i&&e)){if(Z.add(H),0===t)break;t--}e=G[r+n]>1||r+U+n+1<G.length&&G[r+U+n+1]>0,H--}}return[{start:H,end:C+1,score:w},Z]};function N(t,e,r,s,i,l,a){let c=0,u=0,p=!1,g=0,b=0;const m=S(a);let y=0;i>0&&(y=C(r[i-1]));for(let _=i;_<l;_++){let i=r[_];const l=C(i);if(t||(i>=h&&i<=d?i+=32:i>f&&(i=String.fromCodePoint(i).toLowerCase().codePointAt(0))),e&&(i=n(i)),i===s[c]){a&&null!==m&&m.add(_),u+=P;let t=O(y,l);0===g?b=t:(8===t&&(b=t),t=o(o(t,b),4)),u+=0===c?2*t:t,p=!1,g++,c++}else u+=p?-1:-3,p=!0,g=0,b=0;y=l}return[u,m]}const F=(t,e,r,o,s,i,l)=>{if(0===s.length)return[{start:0,end:0,score:0},null];if(j(o,s,t)<0)return[{start:-1,end:-1,score:0},null];let a=0,c=-1,u=-1;const p=o.length,g=s.length;for(let b=0;b<p;b++){let i=o[y(b,p,r)];t||(i>=h&&i<=d?i+=32:i>f&&(i=String.fromCodePoint(i).toLowerCase().codePointAt(0))),e&&(i=n(i));if(i===s[y(a,g,r)]&&(c<0&&(c=b),a++,a===g)){u=b+1;break}}if(c>=0&&u>=0){a--;for(let e=u-1;e>=c;e--){let n=o[y(e,p,r)];t||(n>=h&&n<=d?n+=32:n>f&&(n=String.fromCodePoint(n).toLowerCase().codePointAt(0)));if(n===s[y(a,g,r)]&&(a--,a<0)){c=e;break}}if(!r){const t=c;c=p-u,u=p-t}const[n,l]=N(t,e,o,s,c,u,i);return[{start:c,end:u,score:n},l]}return[{start:-1,end:-1,score:0},null]},I=(t,e,r,o,s,i,l)=>{if(0===s.length)return[{start:0,end:0,score:0},null];const a=o.length,c=s.length;if(a<c)return[{start:-1,end:-1,score:0},null];if(j(o,s,t)<0)return[{start:-1,end:-1,score:0},null];let u=0,p=-1,g=0,b=-1;for(let _=0;_<a;_++){const i=y(_,a,r);let l=o[i];t||(l>=h&&l<=d?l+=32:l>f&&(l=String.fromCodePoint(l).toLowerCase().codePointAt(0))),e&&(l=n(l));const w=y(u,c,r);if(s[w]===l){if(0===w&&(m=o,g=0===(P=i)?8:O(C(m[P-1]),C(m[P]))),u++,u===c){if(g>b&&(p=_,b=g),8===g)break;_-=u-1,u=0,g=0}}else _-=u,u=0,g=0}var m,P;if(p>=0){let n=0,i=0;r?(n=p-c+1,i=p+1):(n=a-(p+1),i=a-(p-c+1));const[l]=N(t,e,o,s,n,i,!1);return[{start:n,end:i,score:l},null]}return[{start:-1,end:-1,score:0},null]};const M=(R=2048,{i16:new Int16Array(102400),i32:new Int32Array(R)});var R,W,V;(V=W||(W={}))[V.Fuzzy=0]="Fuzzy",V[V.Exact=1]="Exact",V[V.Prefix=2]="Prefix",V[V.Suffix=3]="Suffix",V[V.Equal=4]="Equal";const q={0:E,1:I,2:(t,e,r,o,s,i,l)=>{if(0===s.length)return[{start:0,end:0,score:0},null];let u=0;if(a(s[0])||(u=c(o)),o.length-u<s.length)return[{start:-1,end:-1,score:0},null];for(const[a,c]of s.entries()){let r=o[u+a];if(t||(r=String.fromCodePoint(r).toLowerCase().codePointAt(0)),e&&(r=n(r)),r!==c)return[{start:-1,end:-1,score:0},null]}const f=s.length,[h]=N(t,e,o,s,u,u+f,!1);return[{start:u,end:u+f,score:h},null]},3:(t,e,r,o,s,i,l)=>{let c=o.length;if(0!==s.length&&a(s[s.length-1])||(c-=u(o)),0===s.length)return[{start:c,end:c,score:0},null];const f=c-s.length;if(f<0)return[{start:-1,end:-1,score:0},null];for(const[a,u]of s.entries()){let r=o[a+f];if(t||(r=String.fromCodePoint(r).toLowerCase().codePointAt(0)),e&&(r=n(r)),r!==u)return[{start:-1,end:-1,score:0},null]}const h=c-s.length,d=c,[p]=N(t,e,o,s,h,d,!1);return[{start:h,end:d,score:p},null]},4:(t,e,r,o,s,l,f)=>{const h=s.length;if(0===h)return[{start:-1,end:-1,score:0},null];let d=0;a(s[0])||(d=c(o));let p=0;if(a(s[h-1])||(p=u(o)),o.length-d-p!=h)return[{start:-1,end:-1,score:0},null];let g=!0;if(e){const e=o;for(const[r,o]of s.entries()){let s=e[d+r];if(t||(s=String.fromCodePoint(s).toLowerCase().codePointAt(0)),n(o)!==n(s)){g=!1;break}}}else{let e=i(o).substring(d,o.length-p);t||(e=e.toLowerCase()),g=e===i(s)}return g?[{start:d,end:d+h,score:24*h+8},null]:[{start:-1,end:-1,score:0},null]}};function D(t,e,r,o){let l=!0;{const t=(o=o.trimLeft()).trimRight();o=t.endsWith("\\")&&" "===o[t.length]?t+" ":t}let a=!1,c=[];c=function(t,e,r,o){const l=(o=o.replace(/\\ /g,"\t")).split(/ +/),a=[];let c=[],u=!1,f=!1;for(const h of l){let o=0,l=!1,d=h.replace(/\t/g," ");const p=d.toLowerCase(),g="case-sensitive"===e||"smart-case"===e&&d!==p,b=r&&p===i(s(p).map(n));if(g||(d=p),t||(o=1),c.length>0&&!f&&"|"===d)u=!1,f=!0;else if(f=!1,d.startsWith("!")&&(l=!0,o=1,d=d.substring(1)),"$"!==d&&d.endsWith("$")&&(o=3,d=d.substring(0,d.length-1)),d.startsWith("'")?(o=t&&!l?1:0,d=d.substring(1)):d.startsWith("^")&&(o=3===o?4:2,d=d.substring(1)),d.length>0){u&&(a.push(c),c=[]);let t=s(d);b&&(t=t.map(n)),c.push({typ:o,inv:l,text:t,caseSensitive:g,normalize:b}),u=!0}}c.length>0&&a.push(c);return a}(t,e,r,o);t:for(const n of c)for(const[e,r]of n.entries())if(r.inv||(a=!0),(!l||e>0||r.inv||t&&0!==r.typ||!t&&1!==r.typ)&&(l=!1,a))break t;return{str:o,termSets:c,sortable:a,cacheable:l,fuzzy:t}}function T(t,e,r,n,o,s,i){for(const l of e){const[e,a]=t(r,n,o,l.text,s,!0,i);if(e.start>=0){const t=e.start+l.prefixLength,r=e.end+l.prefixLength;if(null!==a){const n=new Set;return a.forEach((t=>n.add(l.prefixLength+t))),[[t,r],e.score,n]}return[[t,r],e.score,a]}}return[[-1,-1],0,null]}function U(t,e,r,n){const o=[{text:t,prefixLength:0}],s=[];let i=0;const l=new Set;for(const a of e.termSets){let t=[0,0],e=0,c=!1;for(const s of a){let i=q[s.typ];s.typ===W.Fuzzy&&(i=r);const[a,u,f]=T(i,o,s.caseSensitive,s.normalize,n,s.text,M);if(a[0]>=0){if(s.inv)continue;if(t=a,e=u,c=!0,null!==f)f.forEach((t=>l.add(t)));else for(let t=a[0];t<a[1];++t)l.add(t);break}s.inv&&(t=[0,0],e=0,c=!0)}c&&(s.push(t),i+=e)}return{offsets:s,totalScore:i,allPos:l}}function B(t){const{queryRunes:e,caseSensitive:r}=((t,e,r)=>{let o=!1;switch(e){case"smart-case":t.toLowerCase()!==t&&(o=!0);break;case"case-sensitive":o=!0;break;case"case-insensitive":t=t.toLowerCase(),o=!1}let i=s(t);return r&&(i=i.map(n)),{queryRunes:i,caseSensitive:o}})(t,this.opts.casing,this.opts.normalize),o={};for(let n=0,s=this.runesList.length;n<s;++n){const t=this.runesList[n];if(e.length>t.length)continue;let[s,i]=this.algoFn(r,this.opts.normalize,this.opts.forward,t,e,!0,M);if(-1===s.start)continue;if(!1===this.opts.fuzzy){i=new Set;for(let t=s.start;t<s.end;++t)i.add(t)}const l=this.opts.sort?s.score:0;void 0===o[l]&&(o[l]=[]),o[l].push(__spreadProps(__spreadValues({item:this.items[n]},s),{positions:null!=i?i:new Set}))}return G(o,this.opts.limit)}function G(t,e){const r=Object.keys(t).map((t=>parseInt(t,10))).sort(((t,e)=>e-t)),n=[];for(const o of r)if(n.push(...t[o]),n.length>=e)break;return n}const J={limit:1/0,selector:t=>t,casing:"smart-case",normalize:!0,fuzzy:"v2",match:B,tiebreakers:[],sort:!0,forward:!0};class Y{constructor(t,...e){switch(this.opts=__spreadValues(__spreadValues({},J),e[0]),this.items=t,this.runesList=t.map((t=>s(this.opts.selector(t).normalize()))),this.algoFn=I,this.opts.fuzzy){case"v2":this.algoFn=E;break;case"v1":this.algoFn=F}}find(t){t=t.normalize();let e=this.opts.match.bind(this)(t);if(this.opts.sort)for(const r of this.opts.tiebreakers)e.sort(((t,e)=>t.score===e.score?r(t,e,this.opts):0));return Number.isFinite(this.opts.limit)&&e.splice(this.opts.limit),e}}t.Fzf=class{constructor(t,...e){this.finder=new Y(t,...e),this.find=this.finder.find.bind(this.finder)}},t.basicMatch=B,t.byLengthAsc=function(t,e,r){return r.selector(t.item).length-r.selector(e.item).length},t.byStartAsc=function(t,e){return t.start-e.start},t.extendedMatch=function(t){const e=D(Boolean(this.opts.fuzzy),this.opts.casing,this.opts.normalize,t),r={};for(const[n,o]of this.runesList.entries()){const t=U(o,e,this.algoFn,this.opts.forward);if(t.offsets.length!==e.termSets.length)continue;let s=-1,i=-1;t.allPos.size>0&&(s=Math.min(...t.allPos),i=Math.max(...t.allPos)+1);const l=this.opts.sort?t.totalScore:0;void 0===r[l]&&(r[l]=[]),r[l].push({score:t.totalScore,item:this.items[n],positions:t.allPos,start:s,end:i})}return G(r,this.opts.limit)},Object.defineProperty(t,"__esModule",{value:!0}),t[Symbol.toStringTag]="Module"}));
},{}]},{},[1]);