esquery.lite.min.js 24 KB

12
  1. !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("estraverse")):"function"==typeof define&&define.amd?define(["estraverse"],e):(t=t||self).esquery=e(t.estraverse)}(this,(function(t){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,u,o,a,s=[],c=!0,i=!1;try{if(o=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=o.call(r)).done)&&(s.push(n.value),s.length!==e);c=!0);}catch(t){i=!0,u=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(i)throw u}}return s}}(t,e)||u(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t){return function(t){if(Array.isArray(t))return o(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||u(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(t,e){if(t){if("string"==typeof t)return o(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(t,e):void 0}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var a=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t){t.exports&&(t.exports=function(){function t(e,r,n,u){this.message=e,this.expected=r,this.found=n,this.location=u,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,t)}return function(t,e){function r(){this.constructor=t}r.prototype=e.prototype,t.prototype=new r}(t,Error),t.buildMessage=function(t,e){var r={literal:function(t){return'"'+u(t.text)+'"'},class:function(t){var e,r="";for(e=0;e<t.parts.length;e++)r+=t.parts[e]instanceof Array?o(t.parts[e][0])+"-"+o(t.parts[e][1]):o(t.parts[e]);return"["+(t.inverted?"^":"")+r+"]"},any:function(t){return"any character"},end:function(t){return"end of input"},other:function(t){return t.description}};function n(t){return t.charCodeAt(0).toString(16).toUpperCase()}function u(t){return t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(t){return"\\x0"+n(t)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(t){return"\\x"+n(t)}))}function o(t){return t.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(t){return"\\x0"+n(t)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(t){return"\\x"+n(t)}))}return"Expected "+function(t){var e,n,u,o=new Array(t.length);for(e=0;e<t.length;e++)o[e]=(u=t[e],r[u.type](u));if(o.sort(),o.length>0){for(e=1,n=1;e<o.length;e++)o[e-1]!==o[e]&&(o[n]=o[e],n++);o.length=n}switch(o.length){case 1:return o[0];case 2:return o[0]+" or "+o[1];default:return o.slice(0,-1).join(", ")+", or "+o[o.length-1]}}(t)+" but "+function(t){return t?'"'+u(t)+'"':"end of input"}(e)+" found."},{SyntaxError:t,parse:function(e,r){r=void 0!==r?r:{};var n,u,o,a,s={},c={start:bt},i=bt,l=yt(" ",!1),f=/^[^ [\],():#!=><~+.]/,h=dt([" ","[","]",",","(",")",":","#","!","=",">","<","~","+","."],!0,!1),p=yt(">",!1),v=yt("~",!1),y=yt("+",!1),d=yt(",",!1),A=yt("!",!1),x=yt("*",!1),g=yt("#",!1),b=yt("[",!1),m=yt("]",!1),P=/^[><!]/,C=dt([">","<","!"],!1,!1),w=yt("=",!1),j=function(t){return(t||"")+"="},E=/^[><]/,S=dt([">","<"],!1,!1),k=yt(".",!1),I=function(t,e,r){return{type:"attribute",name:t,operator:e,value:r}},F=yt('"',!1),L=/^[^\\"]/,T=dt(["\\",'"'],!0,!1),O=yt("\\",!1),D={type:"any"},R=function(t,e){return t+e},K=function(t){return{type:"literal",value:(e=t.join(""),e.replace(/\\(.)/g,(function(t,e){switch(e){case"b":return"\b";case"f":return"\f";case"n":return"\n";case"r":return"\r";case"t":return"\t";case"v":return"\v";default:return e}})))};var e},M=yt("'",!1),U=/^[^\\']/,_=dt(["\\","'"],!0,!1),q=/^[0-9]/,G=dt([["0","9"]],!1,!1),H=yt("type(",!1),V=/^[^ )]/,W=dt([" ",")"],!0,!1),$=yt(")",!1),z=/^[imsu]/,B=dt(["i","m","s","u"],!1,!1),J=yt("/",!1),N=/^[^\/]/,Q=dt(["/"],!0,!1),X=yt(":not(",!1),Y=yt(":matches(",!1),Z=yt(":has(",!1),tt=yt(":first-child",!1),et=yt(":last-child",!1),rt=yt(":nth-child(",!1),nt=yt(":nth-last-child(",!1),ut=yt(":",!1),ot=yt("statement",!0),at=yt("expression",!0),st=yt("declaration",!0),ct=yt("function",!0),it=yt("pattern",!0),lt=0,ft=[{line:1,column:1}],ht=0,pt=[],vt={};if("startRule"in r){if(!(r.startRule in c))throw new Error("Can't start parsing from rule \""+r.startRule+'".');i=c[r.startRule]}function yt(t,e){return{type:"literal",text:t,ignoreCase:e}}function dt(t,e,r){return{type:"class",parts:t,inverted:e,ignoreCase:r}}function At(t){var r,n=ft[t];if(n)return n;for(r=t-1;!ft[r];)r--;for(n={line:(n=ft[r]).line,column:n.column};r<t;)10===e.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return ft[t]=n,n}function xt(t,e){var r=At(t),n=At(e);return{start:{offset:t,line:r.line,column:r.column},end:{offset:e,line:n.line,column:n.column}}}function gt(t){lt<ht||(lt>ht&&(ht=lt,pt=[]),pt.push(t))}function bt(){var t,e,r,n,u=30*lt+0,o=vt[u];return o?(lt=o.nextPos,o.result):(t=lt,(e=mt())!==s&&(r=wt())!==s&&mt()!==s?t=e=1===(n=r).length?n[0]:{type:"matches",selectors:n}:(lt=t,t=s),t===s&&(t=lt,(e=mt())!==s&&(e=void 0),t=e),vt[u]={nextPos:lt,result:t},t)}function mt(){var t,r,n=30*lt+1,u=vt[n];if(u)return lt=u.nextPos,u.result;for(t=[],32===e.charCodeAt(lt)?(r=" ",lt++):(r=s,gt(l));r!==s;)t.push(r),32===e.charCodeAt(lt)?(r=" ",lt++):(r=s,gt(l));return vt[n]={nextPos:lt,result:t},t}function Pt(){var t,r,n,u=30*lt+2,o=vt[u];if(o)return lt=o.nextPos,o.result;if(r=[],f.test(e.charAt(lt))?(n=e.charAt(lt),lt++):(n=s,gt(h)),n!==s)for(;n!==s;)r.push(n),f.test(e.charAt(lt))?(n=e.charAt(lt),lt++):(n=s,gt(h));else r=s;return r!==s&&(r=r.join("")),t=r,vt[u]={nextPos:lt,result:t},t}function Ct(){var t,r,n,u=30*lt+3,o=vt[u];return o?(lt=o.nextPos,o.result):(t=lt,(r=mt())!==s?(62===e.charCodeAt(lt)?(n=">",lt++):(n=s,gt(p)),n!==s&&mt()!==s?t=r="child":(lt=t,t=s)):(lt=t,t=s),t===s&&(t=lt,(r=mt())!==s?(126===e.charCodeAt(lt)?(n="~",lt++):(n=s,gt(v)),n!==s&&mt()!==s?t=r="sibling":(lt=t,t=s)):(lt=t,t=s),t===s&&(t=lt,(r=mt())!==s?(43===e.charCodeAt(lt)?(n="+",lt++):(n=s,gt(y)),n!==s&&mt()!==s?t=r="adjacent":(lt=t,t=s)):(lt=t,t=s),t===s&&(t=lt,32===e.charCodeAt(lt)?(r=" ",lt++):(r=s,gt(l)),r!==s&&(n=mt())!==s?t=r="descendant":(lt=t,t=s)))),vt[u]={nextPos:lt,result:t},t)}function wt(){var t,r,n,u,o,a,c,i,l=30*lt+4,f=vt[l];if(f)return lt=f.nextPos,f.result;if(t=lt,(r=jt())!==s){for(n=[],u=lt,(o=mt())!==s?(44===e.charCodeAt(lt)?(a=",",lt++):(a=s,gt(d)),a!==s&&(c=mt())!==s&&(i=jt())!==s?u=o=[o,a,c,i]:(lt=u,u=s)):(lt=u,u=s);u!==s;)n.push(u),u=lt,(o=mt())!==s?(44===e.charCodeAt(lt)?(a=",",lt++):(a=s,gt(d)),a!==s&&(c=mt())!==s&&(i=jt())!==s?u=o=[o,a,c,i]:(lt=u,u=s)):(lt=u,u=s);n!==s?t=r=[r].concat(n.map((function(t){return t[3]}))):(lt=t,t=s)}else lt=t,t=s;return vt[l]={nextPos:lt,result:t},t}function jt(){var t,e,r,n,u,o,a,c=30*lt+5,i=vt[c];if(i)return lt=i.nextPos,i.result;if(t=lt,(e=Et())!==s){for(r=[],n=lt,(u=Ct())!==s&&(o=Et())!==s?n=u=[u,o]:(lt=n,n=s);n!==s;)r.push(n),n=lt,(u=Ct())!==s&&(o=Et())!==s?n=u=[u,o]:(lt=n,n=s);r!==s?(a=e,t=e=r.reduce((function(t,e){return{type:e[0],left:t,right:e[1]}}),a)):(lt=t,t=s)}else lt=t,t=s;return vt[c]={nextPos:lt,result:t},t}function Et(){var t,r,n,u,o,a,c,i=30*lt+6,l=vt[i];if(l)return lt=l.nextPos,l.result;if(t=lt,33===e.charCodeAt(lt)?(r="!",lt++):(r=s,gt(A)),r===s&&(r=null),r!==s){if(n=[],(u=St())!==s)for(;u!==s;)n.push(u),u=St();else n=s;n!==s?(o=r,c=1===(a=n).length?a[0]:{type:"compound",selectors:a},o&&(c.subject=!0),t=r=c):(lt=t,t=s)}else lt=t,t=s;return vt[i]={nextPos:lt,result:t},t}function St(){var t,r=30*lt+7,n=vt[r];return n?(lt=n.nextPos,n.result):((t=function(){var t,r,n=30*lt+8,u=vt[n];return u?(lt=u.nextPos,u.result):(42===e.charCodeAt(lt)?(r="*",lt++):(r=s,gt(x)),r!==s&&(r={type:"wildcard",value:r}),t=r,vt[n]={nextPos:lt,result:t},t)}())===s&&(t=function(){var t,r,n,u=30*lt+9,o=vt[u];return o?(lt=o.nextPos,o.result):(t=lt,35===e.charCodeAt(lt)?(r="#",lt++):(r=s,gt(g)),r===s&&(r=null),r!==s&&(n=Pt())!==s?t=r={type:"identifier",value:n}:(lt=t,t=s),vt[u]={nextPos:lt,result:t},t)}())===s&&(t=function(){var t,r,n,u,o=30*lt+10,a=vt[o];return a?(lt=a.nextPos,a.result):(t=lt,91===e.charCodeAt(lt)?(r="[",lt++):(r=s,gt(b)),r!==s&&mt()!==s&&(n=function(){var t,r,n,u,o=30*lt+14,a=vt[o];return a?(lt=a.nextPos,a.result):(t=lt,(r=kt())!==s&&mt()!==s&&(n=function(){var t,r,n,u=30*lt+12,o=vt[u];return o?(lt=o.nextPos,o.result):(t=lt,33===e.charCodeAt(lt)?(r="!",lt++):(r=s,gt(A)),r===s&&(r=null),r!==s?(61===e.charCodeAt(lt)?(n="=",lt++):(n=s,gt(w)),n!==s?(r=j(r),t=r):(lt=t,t=s)):(lt=t,t=s),vt[u]={nextPos:lt,result:t},t)}())!==s&&mt()!==s?((u=function(){var t,r,n,u,o,a=30*lt+18,c=vt[a];if(c)return lt=c.nextPos,c.result;if(t=lt,"type("===e.substr(lt,5)?(r="type(",lt+=5):(r=s,gt(H)),r!==s)if(mt()!==s){if(n=[],V.test(e.charAt(lt))?(u=e.charAt(lt),lt++):(u=s,gt(W)),u!==s)for(;u!==s;)n.push(u),V.test(e.charAt(lt))?(u=e.charAt(lt),lt++):(u=s,gt(W));else n=s;n!==s&&(u=mt())!==s?(41===e.charCodeAt(lt)?(o=")",lt++):(o=s,gt($)),o!==s?(r={type:"type",value:n.join("")},t=r):(lt=t,t=s)):(lt=t,t=s)}else lt=t,t=s;else lt=t,t=s;return vt[a]={nextPos:lt,result:t},t}())===s&&(u=function(){var t,r,n,u,o,a,c=30*lt+20,i=vt[c];if(i)return lt=i.nextPos,i.result;if(t=lt,47===e.charCodeAt(lt)?(r="/",lt++):(r=s,gt(J)),r!==s){if(n=[],N.test(e.charAt(lt))?(u=e.charAt(lt),lt++):(u=s,gt(Q)),u!==s)for(;u!==s;)n.push(u),N.test(e.charAt(lt))?(u=e.charAt(lt),lt++):(u=s,gt(Q));else n=s;n!==s?(47===e.charCodeAt(lt)?(u="/",lt++):(u=s,gt(J)),u!==s?((o=function(){var t,r,n=30*lt+19,u=vt[n];if(u)return lt=u.nextPos,u.result;if(t=[],z.test(e.charAt(lt))?(r=e.charAt(lt),lt++):(r=s,gt(B)),r!==s)for(;r!==s;)t.push(r),z.test(e.charAt(lt))?(r=e.charAt(lt),lt++):(r=s,gt(B));else t=s;return vt[n]={nextPos:lt,result:t},t}())===s&&(o=null),o!==s?(a=o,r={type:"regexp",value:new RegExp(n.join(""),a?a.join(""):"")},t=r):(lt=t,t=s)):(lt=t,t=s)):(lt=t,t=s)}else lt=t,t=s;return vt[c]={nextPos:lt,result:t},t}()),u!==s?(r=I(r,n,u),t=r):(lt=t,t=s)):(lt=t,t=s),t===s&&(t=lt,(r=kt())!==s&&mt()!==s&&(n=function(){var t,r,n,u=30*lt+11,o=vt[u];return o?(lt=o.nextPos,o.result):(t=lt,P.test(e.charAt(lt))?(r=e.charAt(lt),lt++):(r=s,gt(C)),r===s&&(r=null),r!==s?(61===e.charCodeAt(lt)?(n="=",lt++):(n=s,gt(w)),n!==s?(r=j(r),t=r):(lt=t,t=s)):(lt=t,t=s),t===s&&(E.test(e.charAt(lt))?(t=e.charAt(lt),lt++):(t=s,gt(S))),vt[u]={nextPos:lt,result:t},t)}())!==s&&mt()!==s?((u=function(){var t,r,n,u,o,a,c=30*lt+15,i=vt[c];if(i)return lt=i.nextPos,i.result;if(t=lt,34===e.charCodeAt(lt)?(r='"',lt++):(r=s,gt(F)),r!==s){for(n=[],L.test(e.charAt(lt))?(u=e.charAt(lt),lt++):(u=s,gt(T)),u===s&&(u=lt,92===e.charCodeAt(lt)?(o="\\",lt++):(o=s,gt(O)),o!==s?(e.length>lt?(a=e.charAt(lt),lt++):(a=s,gt(D)),a!==s?(o=R(o,a),u=o):(lt=u,u=s)):(lt=u,u=s));u!==s;)n.push(u),L.test(e.charAt(lt))?(u=e.charAt(lt),lt++):(u=s,gt(T)),u===s&&(u=lt,92===e.charCodeAt(lt)?(o="\\",lt++):(o=s,gt(O)),o!==s?(e.length>lt?(a=e.charAt(lt),lt++):(a=s,gt(D)),a!==s?(o=R(o,a),u=o):(lt=u,u=s)):(lt=u,u=s));n!==s?(34===e.charCodeAt(lt)?(u='"',lt++):(u=s,gt(F)),u!==s?(r=K(n),t=r):(lt=t,t=s)):(lt=t,t=s)}else lt=t,t=s;if(t===s)if(t=lt,39===e.charCodeAt(lt)?(r="'",lt++):(r=s,gt(M)),r!==s){for(n=[],U.test(e.charAt(lt))?(u=e.charAt(lt),lt++):(u=s,gt(_)),u===s&&(u=lt,92===e.charCodeAt(lt)?(o="\\",lt++):(o=s,gt(O)),o!==s?(e.length>lt?(a=e.charAt(lt),lt++):(a=s,gt(D)),a!==s?(o=R(o,a),u=o):(lt=u,u=s)):(lt=u,u=s));u!==s;)n.push(u),U.test(e.charAt(lt))?(u=e.charAt(lt),lt++):(u=s,gt(_)),u===s&&(u=lt,92===e.charCodeAt(lt)?(o="\\",lt++):(o=s,gt(O)),o!==s?(e.length>lt?(a=e.charAt(lt),lt++):(a=s,gt(D)),a!==s?(o=R(o,a),u=o):(lt=u,u=s)):(lt=u,u=s));n!==s?(39===e.charCodeAt(lt)?(u="'",lt++):(u=s,gt(M)),u!==s?(r=K(n),t=r):(lt=t,t=s)):(lt=t,t=s)}else lt=t,t=s;return vt[c]={nextPos:lt,result:t},t}())===s&&(u=function(){var t,r,n,u,o,a,c,i=30*lt+16,l=vt[i];if(l)return lt=l.nextPos,l.result;for(t=lt,r=lt,n=[],q.test(e.charAt(lt))?(u=e.charAt(lt),lt++):(u=s,gt(G));u!==s;)n.push(u),q.test(e.charAt(lt))?(u=e.charAt(lt),lt++):(u=s,gt(G));if(n!==s?(46===e.charCodeAt(lt)?(u=".",lt++):(u=s,gt(k)),u!==s?r=n=[n,u]:(lt=r,r=s)):(lt=r,r=s),r===s&&(r=null),r!==s){if(n=[],q.test(e.charAt(lt))?(u=e.charAt(lt),lt++):(u=s,gt(G)),u!==s)for(;u!==s;)n.push(u),q.test(e.charAt(lt))?(u=e.charAt(lt),lt++):(u=s,gt(G));else n=s;n!==s?(a=n,c=(o=r)?[].concat.apply([],o).join(""):"",r={type:"literal",value:parseFloat(c+a.join(""))},t=r):(lt=t,t=s)}else lt=t,t=s;return vt[i]={nextPos:lt,result:t},t}())===s&&(u=function(){var t,e,r=30*lt+17,n=vt[r];return n?(lt=n.nextPos,n.result):((e=Pt())!==s&&(e={type:"literal",value:e}),t=e,vt[r]={nextPos:lt,result:t},t)}()),u!==s?(r=I(r,n,u),t=r):(lt=t,t=s)):(lt=t,t=s),t===s&&(t=lt,(r=kt())!==s&&(r={type:"attribute",name:r}),t=r)),vt[o]={nextPos:lt,result:t},t)}())!==s&&mt()!==s?(93===e.charCodeAt(lt)?(u="]",lt++):(u=s,gt(m)),u!==s?t=r=n:(lt=t,t=s)):(lt=t,t=s),vt[o]={nextPos:lt,result:t},t)}())===s&&(t=function(){var t,r,n,u,o,a,c,i,l=30*lt+21,f=vt[l];if(f)return lt=f.nextPos,f.result;if(t=lt,46===e.charCodeAt(lt)?(r=".",lt++):(r=s,gt(k)),r!==s)if((n=Pt())!==s){for(u=[],o=lt,46===e.charCodeAt(lt)?(a=".",lt++):(a=s,gt(k)),a!==s&&(c=Pt())!==s?o=a=[a,c]:(lt=o,o=s);o!==s;)u.push(o),o=lt,46===e.charCodeAt(lt)?(a=".",lt++):(a=s,gt(k)),a!==s&&(c=Pt())!==s?o=a=[a,c]:(lt=o,o=s);u!==s?(i=n,r={type:"field",name:u.reduce((function(t,e){return t+e[0]+e[1]}),i)},t=r):(lt=t,t=s)}else lt=t,t=s;else lt=t,t=s;return vt[l]={nextPos:lt,result:t},t}())===s&&(t=function(){var t,r,n,u,o=30*lt+22,a=vt[o];return a?(lt=a.nextPos,a.result):(t=lt,":not("===e.substr(lt,5)?(r=":not(",lt+=5):(r=s,gt(X)),r!==s&&mt()!==s&&(n=wt())!==s&&mt()!==s?(41===e.charCodeAt(lt)?(u=")",lt++):(u=s,gt($)),u!==s?t=r={type:"not",selectors:n}:(lt=t,t=s)):(lt=t,t=s),vt[o]={nextPos:lt,result:t},t)}())===s&&(t=function(){var t,r,n,u,o=30*lt+23,a=vt[o];return a?(lt=a.nextPos,a.result):(t=lt,":matches("===e.substr(lt,9)?(r=":matches(",lt+=9):(r=s,gt(Y)),r!==s&&mt()!==s&&(n=wt())!==s&&mt()!==s?(41===e.charCodeAt(lt)?(u=")",lt++):(u=s,gt($)),u!==s?t=r={type:"matches",selectors:n}:(lt=t,t=s)):(lt=t,t=s),vt[o]={nextPos:lt,result:t},t)}())===s&&(t=function(){var t,r,n,u,o=30*lt+24,a=vt[o];return a?(lt=a.nextPos,a.result):(t=lt,":has("===e.substr(lt,5)?(r=":has(",lt+=5):(r=s,gt(Z)),r!==s&&mt()!==s&&(n=wt())!==s&&mt()!==s?(41===e.charCodeAt(lt)?(u=")",lt++):(u=s,gt($)),u!==s?t=r={type:"has",selectors:n}:(lt=t,t=s)):(lt=t,t=s),vt[o]={nextPos:lt,result:t},t)}())===s&&(t=function(){var t,r,n=30*lt+25,u=vt[n];return u?(lt=u.nextPos,u.result):(":first-child"===e.substr(lt,12)?(r=":first-child",lt+=12):(r=s,gt(tt)),r!==s&&(r=It(1)),t=r,vt[n]={nextPos:lt,result:t},t)}())===s&&(t=function(){var t,r,n=30*lt+26,u=vt[n];return u?(lt=u.nextPos,u.result):(":last-child"===e.substr(lt,11)?(r=":last-child",lt+=11):(r=s,gt(et)),r!==s&&(r=Ft(1)),t=r,vt[n]={nextPos:lt,result:t},t)}())===s&&(t=function(){var t,r,n,u,o,a=30*lt+27,c=vt[a];if(c)return lt=c.nextPos,c.result;if(t=lt,":nth-child("===e.substr(lt,11)?(r=":nth-child(",lt+=11):(r=s,gt(rt)),r!==s)if(mt()!==s){if(n=[],q.test(e.charAt(lt))?(u=e.charAt(lt),lt++):(u=s,gt(G)),u!==s)for(;u!==s;)n.push(u),q.test(e.charAt(lt))?(u=e.charAt(lt),lt++):(u=s,gt(G));else n=s;n!==s&&(u=mt())!==s?(41===e.charCodeAt(lt)?(o=")",lt++):(o=s,gt($)),o!==s?(r=It(parseInt(n.join(""),10)),t=r):(lt=t,t=s)):(lt=t,t=s)}else lt=t,t=s;else lt=t,t=s;return vt[a]={nextPos:lt,result:t},t}())===s&&(t=function(){var t,r,n,u,o,a=30*lt+28,c=vt[a];if(c)return lt=c.nextPos,c.result;if(t=lt,":nth-last-child("===e.substr(lt,16)?(r=":nth-last-child(",lt+=16):(r=s,gt(nt)),r!==s)if(mt()!==s){if(n=[],q.test(e.charAt(lt))?(u=e.charAt(lt),lt++):(u=s,gt(G)),u!==s)for(;u!==s;)n.push(u),q.test(e.charAt(lt))?(u=e.charAt(lt),lt++):(u=s,gt(G));else n=s;n!==s&&(u=mt())!==s?(41===e.charCodeAt(lt)?(o=")",lt++):(o=s,gt($)),o!==s?(r=Ft(parseInt(n.join(""),10)),t=r):(lt=t,t=s)):(lt=t,t=s)}else lt=t,t=s;else lt=t,t=s;return vt[a]={nextPos:lt,result:t},t}())===s&&(t=function(){var t,r,n,u=30*lt+29,o=vt[u];return o?(lt=o.nextPos,o.result):(t=lt,58===e.charCodeAt(lt)?(r=":",lt++):(r=s,gt(ut)),r!==s?("statement"===e.substr(lt,9).toLowerCase()?(n=e.substr(lt,9),lt+=9):(n=s,gt(ot)),n===s&&("expression"===e.substr(lt,10).toLowerCase()?(n=e.substr(lt,10),lt+=10):(n=s,gt(at)),n===s&&("declaration"===e.substr(lt,11).toLowerCase()?(n=e.substr(lt,11),lt+=11):(n=s,gt(st)),n===s&&("function"===e.substr(lt,8).toLowerCase()?(n=e.substr(lt,8),lt+=8):(n=s,gt(ct)),n===s&&("pattern"===e.substr(lt,7).toLowerCase()?(n=e.substr(lt,7),lt+=7):(n=s,gt(it)))))),n!==s?t=r={type:"class",name:n}:(lt=t,t=s)):(lt=t,t=s),vt[u]={nextPos:lt,result:t},t)}()),vt[r]={nextPos:lt,result:t},t)}function kt(){var t,r,n,u,o,a,c,i,l=30*lt+13,f=vt[l];if(f)return lt=f.nextPos,f.result;if(t=lt,(r=Pt())!==s){for(n=[],u=lt,46===e.charCodeAt(lt)?(o=".",lt++):(o=s,gt(k)),o!==s&&(a=Pt())!==s?u=o=[o,a]:(lt=u,u=s);u!==s;)n.push(u),u=lt,46===e.charCodeAt(lt)?(o=".",lt++):(o=s,gt(k)),o!==s&&(a=Pt())!==s?u=o=[o,a]:(lt=u,u=s);n!==s?(c=r,i=n,t=r=[].concat.apply([c],i).join("")):(lt=t,t=s)}else lt=t,t=s;return vt[l]={nextPos:lt,result:t},t}function It(t){return{type:"nth-child",index:{type:"literal",value:t}}}function Ft(t){return{type:"nth-last-child",index:{type:"literal",value:t}}}if((n=i())!==s&&lt===e.length)return n;throw n!==s&&lt<e.length&&gt({type:"end"}),u=pt,o=ht<e.length?e.charAt(ht):null,a=ht<e.length?xt(ht,ht+1):xt(ht,ht),new t(t.buildMessage(u,o),u,o,a)}}}())}));function s(t,e){for(var r=0;r<e.length;++r){if(null==t)return t;t=t[e[r]]}return t}var c="function"==typeof WeakMap?new WeakMap:null;function i(t){if(null==t)return function(){return!0};if(null!=c){var e=c.get(t);return null!=e||(e=l(t),c.set(t,e)),e}return l(t)}function l(r){switch(r.type){case"wildcard":return function(){return!0};case"identifier":var n=r.value.toLowerCase();return function(t){return n===t.type.toLowerCase()};case"field":var u=r.name.split(".");return function(t,e){return function t(e,r,n,u){for(var o=r,a=u;a<n.length;++a){if(null==o)return!1;var s=o[n[a]];if(Array.isArray(s)){for(var c=0;c<s.length;++c)if(t(e,s[c],n,a+1))return!0;return!1}o=s}return e===o}(t,e[u.length-1],u,0)};case"matches":var o=r.selectors.map(i);return function(t,e,r){for(var n=0;n<o.length;++n)if(o[n](t,e,r))return!0;return!1};case"compound":var a=r.selectors.map(i);return function(t,e,r){for(var n=0;n<a.length;++n)if(!a[n](t,e,r))return!1;return!0};case"not":var c=r.selectors.map(i);return function(t,e,r){for(var n=0;n<c.length;++n)if(c[n](t,e,r))return!1;return!0};case"has":var l=r.selectors.map(i);return function(e,r,n){var u=!1,o=[];return t.traverse(e,{enter:function(t,e){null!=e&&o.unshift(e);for(var r=0;r<l.length;++r)if(l[r](t,o,n))return u=!0,void this.break()},leave:function(){o.shift()},keys:n&&n.visitorKeys,fallback:n&&n.fallback||"iteration"}),u};case"child":var f=i(r.left),h=i(r.right);return function(t,e,r){return!!(e.length>0&&h(t,e,r))&&f(e[0],e.slice(1),r)};case"descendant":var d=i(r.left),A=i(r.right);return function(t,e,r){if(A(t,e,r))for(var n=0,u=e.length;n<u;++n)if(d(e[n],e.slice(n+1),r))return!0;return!1};case"attribute":var x=r.name.split(".");switch(r.operator){case void 0:return function(t){return null!=s(t,x)};case"=":switch(r.value.type){case"regexp":return function(t){var e=s(t,x);return"string"==typeof e&&r.value.value.test(e)};case"literal":var g="".concat(r.value.value);return function(t){return g==="".concat(s(t,x))};case"type":return function(t){return r.value.value===e(s(t,x))}}throw new Error("Unknown selector value type: ".concat(r.value.type));case"!=":switch(r.value.type){case"regexp":return function(t){return!r.value.value.test(s(t,x))};case"literal":var b="".concat(r.value.value);return function(t){return b!=="".concat(s(t,x))};case"type":return function(t){return r.value.value!==e(s(t,x))}}throw new Error("Unknown selector value type: ".concat(r.value.type));case"<=":return function(t){return s(t,x)<=r.value.value};case"<":return function(t){return s(t,x)<r.value.value};case">":return function(t){return s(t,x)>r.value.value};case">=":return function(t){return s(t,x)>=r.value.value}}throw new Error("Unknown operator: ".concat(r.operator));case"sibling":var m=i(r.left),P=i(r.right);return function(t,e,n){return P(t,e,n)&&p(t,m,e,"LEFT_SIDE",n)||r.left.subject&&m(t,e,n)&&p(t,P,e,"RIGHT_SIDE",n)};case"adjacent":var C=i(r.left),w=i(r.right);return function(t,e,n){return w(t,e,n)&&v(t,C,e,"LEFT_SIDE",n)||r.right.subject&&C(t,e,n)&&v(t,w,e,"RIGHT_SIDE",n)};case"nth-child":var j=r.index.value,E=i(r.right);return function(t,e,r){return E(t,e,r)&&y(t,e,j,r)};case"nth-last-child":var S=-r.index.value,k=i(r.right);return function(t,e,r){return k(t,e,r)&&y(t,e,S,r)};case"class":var I=r.name.toLowerCase();return function(t,e){switch(I){case"statement":if("Statement"===t.type.slice(-9))return!0;case"declaration":return"Declaration"===t.type.slice(-11);case"pattern":if("Pattern"===t.type.slice(-7))return!0;case"expression":return"Expression"===t.type.slice(-10)||"Literal"===t.type.slice(-7)||"Identifier"===t.type&&(0===e.length||"MetaProperty"!==e[0].type)||"MetaProperty"===t.type;case"function":return"FunctionDeclaration"===t.type||"FunctionExpression"===t.type||"ArrowFunctionExpression"===t.type}throw new Error("Unknown class name: ".concat(r.name))}}throw new Error("Unknown selector type: ".concat(r.type))}function f(e,r){var n=e.type;return r&&r.visitorKeys&&r.visitorKeys[n]?r.visitorKeys[n]:t.VisitorKeys[n]?t.VisitorKeys[n]:r&&"function"==typeof r.fallback?r.fallback(e):Object.keys(e).filter((function(t){return"type"!==t}))}function h(t){return null!==t&&"object"===e(t)&&"string"==typeof t.type}function p(t,e,n,u,o){var a=r(n,1)[0];if(!a)return!1;for(var s=f(a,o),c=0;c<s.length;++c){var i=a[s[c]];if(Array.isArray(i)){var l=i.indexOf(t);if(l<0)continue;var p=void 0,v=void 0;"LEFT_SIDE"===u?(p=0,v=l):(p=l+1,v=i.length);for(var y=p;y<v;++y)if(h(i[y])&&e(i[y],n,o))return!0}}return!1}function v(t,e,n,u,o){var a=r(n,1)[0];if(!a)return!1;for(var s=f(a,o),c=0;c<s.length;++c){var i=a[s[c]];if(Array.isArray(i)){var l=i.indexOf(t);if(l<0)continue;if("LEFT_SIDE"===u&&l>0&&h(i[l-1])&&e(i[l-1],n,o))return!0;if("RIGHT_SIDE"===u&&l<i.length-1&&h(i[l+1])&&e(i[l+1],n,o))return!0}}return!1}function y(t,e,n,u){if(0===n)return!1;var o=r(e,1)[0];if(!o)return!1;for(var a=f(o,u),s=0;s<a.length;++s){var c=o[a[s]];if(Array.isArray(c)){var i=n<0?c.length+n:n-1;if(i>=0&&i<c.length&&c[i]===t)return!0}}return!1}function d(r,u,o,a){if(u){var s=[],c=i(u),l=function t(r,u){if(null==r||"object"!=e(r))return[];null==u&&(u=r);for(var o=r.subject?[u]:[],a=Object.keys(r),s=0;s<a.length;++s){var c=a[s],i=r[c];o.push.apply(o,n(t(i,"left"===c?i:u)))}return o}(u).map(i);t.traverse(r,{enter:function(t,e){if(null!=e&&s.unshift(e),c(t,s,a))if(l.length)for(var r=0,n=l.length;r<n;++r){l[r](t,s,a)&&o(t,e,s);for(var u=0,i=s.length;u<i;++u){var f=s.slice(u+1);l[r](s[u],f,a)&&o(s[u],e,f)}}else o(t,e,s)},leave:function(){s.shift()},keys:a&&a.visitorKeys,fallback:a&&a.fallback||"iteration"})}}function A(t,e,r){var n=[];return d(t,e,(function(t){n.push(t)}),r),n}function x(t){return a.parse(t)}function g(t,e,r){return A(t,x(e),r)}return g.parse=x,g.match=A,g.traverse=d,g.matches=function(t,e,r,n){return!e||!!t&&(r||(r=[]),i(e)(t,r,n))},g.query=g,g}));
  2. //# sourceMappingURL=esquery.lite.min.js.map