Liferay.Loader.define("portal-search-web$codemirror@5.62.0/addon/hint/sql-hint",["module","exports","require","../../lib/codemirror","../../mode/sql/sql"],(function(t,r,e){var n;window,n=function(t){"use strict";var r,e,n,o,i=t.Pos,s=t.cmpPos;function a(t){return"[object Array]"==Object.prototype.toString.call(t)}function l(t){return"string"==typeof t?t:t.text}function u(t,r){return a(r)&&(r={columns:r}),r.text||(r.text=t),r}function c(t){return r[t.toUpperCase()]}function f(t){var r={};for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e]);return r}function p(t,r){var e=t.length,n=l(r).substr(0,e);return t.toUpperCase()===n.toUpperCase()}function d(t,r,e,n){if(a(e))for(var o=0;o<e.length;o++)p(r,e[o])&&t.push(n(e[o]));else for(var i in e)if(e.hasOwnProperty(i)){var s=e[i];p(r,s=s&&!0!==s?s.displayText?{text:s.text,displayText:s.displayText}:s.text:i)&&t.push(n(s))}}function g(t){"."==t.charAt(0)&&(t=t.substr(1));for(var r=t.split(o+o),e=0;e<r.length;e++)r[e]=r[e].replace(new RegExp(o,"g"),"");return r.join(o)}function h(t){for(var r=l(t).split("."),e=0;e<r.length;e++)r[e]=o+r[e].replace(new RegExp(o,"g"),o+o)+o;var n=r.join(".");return"string"==typeof t?n:((t=f(t)).text=n,t)}function v(t,r){for(var e=t.split(/\s+/),n=0;n<e.length;n++)e[n]&&r(e[n].replace(/[`,;]/g,""))}function x(t,r){for(var e=r.doc,n=e.getValue(),o=t.toUpperCase(),a="",l="",u=[],f={start:i(0,0),end:i(r.lastLine(),r.getLineHandle(r.lastLine()).length)},p=n.indexOf(";");-1!=p;)u.push(e.posFromIndex(p)),p=n.indexOf(";",p+1);u.unshift(i(0,0)),u.push(i(r.lastLine(),r.getLineHandle(r.lastLine()).text.length));for(var d=null,g=r.getCursor(),h=0;h<u.length;h++){if((null==d||s(g,d)>0)&&s(g,u[h])<=0){f={start:d,end:u[h]};break}d=u[h]}if(f.start){var x=e.getRange(f.start,f.end,!1);for(h=0;h<x.length&&(v(x[h],(function(t){var r=t.toUpperCase();r===o&&c(a)&&(l=a),"AS"!==r&&(a=t)})),!l);h++);}return l}t.registerHelper("hint","sql",(function(s,p){r=function(t){var r={};if(a(t))for(var e=t.length-1;e>=0;e--){var n=t[e];r[l(n).toUpperCase()]=u(l(n),n)}else if(t)for(var o in t)r[o.toUpperCase()]=u(o,t[o]);return r}(p&&p.tables);var v=p&&p.defaultTable,m=p&&p.disableKeywords;e=v&&c(v),n=function(r){var e=r.doc.modeOption;return"sql"===e&&(e="text/x-sql"),t.resolveMode(e).keywords}(s),o=function(r){var e=r.doc.modeOption;return"sql"===e&&(e="text/x-sql"),t.resolveMode(e).identifierQuote||"`"}(s),v&&!e&&(e=x(v,s)),(e=e||[]).columns&&(e=e.columns);var b,y,C,w=s.getCursor(),q=[],A=s.getTokenAt(w);if(A.end>w.ch&&(A.end=w.ch,A.string=A.string.slice(0,w.ch-A.start)),A.string.match(/^[.`"'\w@][\w$#]*$/g)?(C=A.string,b=A.start,y=A.end):(b=y=w.ch,C=""),"."==C.charAt(0)||C.charAt(0)==o)b=function(t,n,s,a){for(var l=!1,u=[],p=n.start,v=!0;v;)v="."==n.string.charAt(0),l=l||n.string.charAt(0)==o,p=n.start,u.unshift(g(n.string)),"."==(n=a.getTokenAt(i(t.line,n.start))).string&&(v=!0,n=a.getTokenAt(i(t.line,n.start)));var m=u.join(".");d(s,m,r,(function(t){return l?h(t):t})),d(s,m,e,(function(t){return l?h(t):t})),m=u.pop();var b=u.join("."),y=!1,C=b;if(!c(b)){var w=b;(b=x(b,a))!==w&&(y=!0)}var q=c(b);return q&&q.columns&&(q=q.columns),q&&d(s,m,q,(function(t){var r=b;return 1==y&&(r=C),"string"==typeof t?t=r+"."+t:(t=f(t)).text=r+"."+t.text,l?h(t):t})),p}(w,A,q,s);else{var j=function(t,r){return"object"==typeof t?t.className=r:t={text:t,className:r},t};d(q,C,e,(function(t){return j(t,"CodeMirror-hint-table CodeMirror-hint-default-table")})),d(q,C,r,(function(t){return j(t,"CodeMirror-hint-table")})),m||d(q,C,n,(function(t){return j(t.toUpperCase(),"CodeMirror-hint-keyword")}))}return{list:q,from:i(w.line,b),to:i(w.line,y)}}))},"object"==typeof r&&"object"==typeof t?n(e("../../lib/codemirror"),e("../../mode/sql/sql")):n(CodeMirror)}));
//# sourceMappingURL=sql-hint.js.map