!function(){"use strict";varf={compile:function(r){returni.template.replace(i.pattern,function(t,e){varn=i.middleware(e,r[e],i.template);returnvoid0!==n?n:r[e]||t})},setOptions:function(t){i.pattern=t.pattern||i.pattern,i.template=t.template||i.template,"function"==typeoft.middleware&&(i.middleware=t.middleware)}};consti={pattern:/\{(.*?)\}/g,template:"",middleware:function(){}};varn=function(t,e){varn=e.length,r=t.length;if(n<r)return!1;if(r===n)returnt===e;t:for(vari=0,o=0;i<r;i++){for(varu=t.charCodeAt(i);o<n;)if(e.charCodeAt(o++)===u)continuet;return!1}return!0},e=newfunction(){this.matches=function(t,e){returnn(e.toLowerCase(),t.toLowerCase())}},r=newfunction(){this.matches=function(e,t){return!!e&&(e=e.trim().toLowerCase(),(t=t.trim().toLowerCase()).split("").filter(function(t){return0<=e.indexOf(t)}).length===t.split("").length)}},d={put:function(t){if(l(t))returna(t);if(function(t){returnBoolean(t)&&"[object Array]"===Object.prototype.toString.call(t)}(t))returnfunction(n){constr=[];s();for(lett=0,e=n.length;t<e;t++)l(n[t])&&r.push(a(n[t]));returnr}(t);returnundefined},clear:s,search:function(t){returnt?function(e,n,r,i){consto=[];for(lett=0;t<e.length&&o.length<i.limit;t++){varu=function(t,e,n,r){for(constiint)if(!function(n,r){for(lett=0,e=r.length;t<e;t++){vari=r[t];if(newRegExp(i).test(n))return!0}return!1}(t[i],r.exclude)&&n.matches(t[i],e))returnt}(e[t],n,r,i);u&&o.push(u)}returno}(u,t,c.searchStrategy,c).sort(c.sort):[]},setOptions:function(t){c=t||{},c.fuzzy=t.fuzzy||!1,c.limit=t.limit||10,c.searchStrategy=t.fuzzy?e:r,c.sort=t.sort||o,c.exclude=t.exclude||[]}};functiono(){return0}constu=[];letc={};functions(){returnu.length=0,u}functionl(t){returnBoolean(t)&&"[object Object]"===Object.prototype.toString.call(t)}functiona(t){returnu.push(t),u}c.fuzzy=!1,c.limit=10,c.searchStrategy=c.fuzzy?e:r,c.sort=o,c.exclude=[];varp={load:function(t,e){constn=window.XMLHttpRequest?newwindow.XMLHttpRequest:newActiveXObject("Microsoft.XMLHTTP");n.open("GET",t,!0),n.onreadystatechange=h(n,e),n.send()}};functionh(e,n){returnfunction(){if(4===e.readyState&&200===e.status)try{n(null,JSON.parse(e.responseText))}catch(t){n(t,null)}}}varm=functiony(t){if(!(e=t)||!("undefined"!=typeofe.required&&e.requiredinstanceofArray))thrownewError("-- OptionsValidator: required options missing");vare;if(!(thisinstanceofy))returnnewy(t);constr=t.required;this.getRequiredOptions=function(){returnr},this.validate=function(e){constn=[];returnr.forEach(function(t){"undefined"==typeofe[t]&&n.push(t)}),n}},w={merge:function(t,e){constn={};for(constrint)n[r]=t[r],"undefined"!=typeofe[r]&&(n[r]=e[r]);returnn},isJSON:function(t){try{returntinstanceofObject&&JSON.parse(JSON.stringify(t))?!0:!1}catch(e){return!1}}};!function(t){leti={searchInput:null,resultsContainer:null,json:[],success:Function.prototype,searchResultTemplate:'<li><a href="{url}" title="{desc}">{title}</a></li>',templateMiddleware:Function.prototype,sortMiddleware:function(){return0},noResultsText:"No results found",limit:10,fuzzy:!1,debounceTime:null,exclude:[]},n;conste=function(t,e){e?(clearTimeout(n),n=setTimeout(t,e)):t.call()};varr=["searchInput","resultsContainer","json"];consto=m({required:r});functionu(t){d.put(t),i.searchInput.addEventListener("input",function(t){-1===[13,16,20,37,38,39,40,91].indexOf(t.which)&&(c(),e(function(){l(t.target.value)},i.debounceTime))})}functionc(){i.resultsContainer.innerHTML=""}functions(t){i.resultsContainer.innerHTML+=t}functionl(t){vare;(e=t)&&0<e.length&&(c(),function(e,n){varr=e.length;if(0===r)returns(i.noResultsText);for(lett=0;t<r;t++)e[t].query=n,s(f.compile(e[t]))}(d.search(t),t))}functiona(t){thrownewError("SimpleJekyllSearch --- "+t)}t.SimpleJekyllSearch=function(t){varn;0<o.validate(t).length&&a("You must specify the following required options: "+r),i=w.merge(i,t),f.setOptions({template:i.searchResultTemplate,middleware:i.templateMiddleware}),d.setOptions({fuzzy:i.fuzzy,limit:i.limit,sort:i.sortMiddleware,exclude:i.exclude}),w.isJSON(i.json)?u(i.json):(n=i.json,p.load(n,function(t,e){t&&a("failed to get JSON ("+n+")"),u(e)}));t={search:l};return"function"==typeofi.success&&i.success.call(t),t}}(window)}();