!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.Liquid=t()}(this,function(){"use strict";var M="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Q=function(e){return function(){var u=e.apply(this,arguments);return new Promise(function(o,a){return function t(e,r){try{var n=u[e](r),i=n.value}catch(e){return void a(e)}if(!n.done)return Promise.resolve(i).then(function(e){t("next",e)},function(e){t("throw",e)});o(i)}("next")})}},f=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},i=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},l=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t};!function(e){var s,t=Object.prototype,c=t.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},i=r.iterator||"@@iterator",n=r.asyncIterator||"@@asyncIterator",o=r.toStringTag||"@@toStringTag",a="object"===("undefined"==typeof module?"undefined":M(module)),u=e.regeneratorRuntime;if(u)a&&(module.exports=u);else{(u=e.regeneratorRuntime=a?module.exports:{}).wrap=w;var l="suspendedStart",p="suspendedYield",h="executing",g="completed",d={},f={};f[i]=function(){return this};var v=Object.getPrototypeOf,m=v&&v(v(j([])));m&&m!==t&&c.call(m,i)&&(f=m);var y=E.prototype=b.prototype=Object.create(f);k.prototype=y.constructor=E,E.constructor=k,E[o]=k.displayName="GeneratorFunction",u.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===k||"GeneratorFunction"===(t.displayName||t.name))},u.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,E):(e.__proto__=E,o in e||(e[o]="GeneratorFunction")),e.prototype=Object.create(y),e},u.awrap=function(e){return{__await:e}},T(_.prototype),_.prototype[n]=function(){return this},u.AsyncIterator=_,u.async=function(e,t,r,n){var i=new _(w(e,t,r,n));return u.isGeneratorFunction(t)?i:i.next().then(function(e){return e.done?e.value:i.next()})},T(y),y[o]="Generator",y[i]=function(){return this},y.toString=function(){return"[object Generator]"},u.keys=function(r){var n=[];for(var e in r)n.push(e);return n.reverse(),function e(){for(;n.length;){var t=n.pop();if(t in r)return e.value=t,e.done=!1,e}return e.done=!0,e}},u.values=j,L.prototype={constructor:L,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=s,this.done=!1,this.delegate=null,this.method="next",this.arg=s,this.tryEntries.forEach(O),!e)for(var t in this)"t"===t.charAt(0)&&c.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=s)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var n=this;function e(e,t){return o.type="throw",o.arg=r,n.next=e,t&&(n.method="next",n.arg=s),!!t}for(var t=this.tryEntries.length-1;0<=t;--t){var i=this.tryEntries[t],o=i.completion;if("root"===i.tryLoc)return e("end");if(i.tryLoc<=this.prev){var a=c.call(i,"catchLoc"),u=c.call(i,"finallyLoc");if(a&&u){if(this.prev=|<|>|\s+contains\s+/];var A=function(e){function r(e){f(this,r);var t=l(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t.name=t.constructor.name,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(t,t.constructor):t.stack=new Error(e).stack,t}return i(r,e),r}(Error),C=function(e){function c(e,t){f(this,c);var r=l(this,(c.__proto__||Object.getPrototypeOf(c)).call(this));r.input=t.input,r.line=t.line,r.file=t.file,r.message=function(e,t){e=e||"",t.file&&(e+=", file:"+t.file);t.line&&(e+=", line:"+t.line);return e}(e.message,t);var n,i,o,a,u,s=(n=t.input,i=t.line,o=n.split("\n"),a=Math.max(i-2,1),u=Math.min(i+3,o.length),function(e,t,r){1===arguments.length&&(t=e,e=0),r=r||1;for(var n=[],i=e;i> ":" ",(t=e,r=u,n=t+"",Array((r+"").length-n.length).join(" ")+n),"| ",o[e-1]].join("");var t,r,n}).join("\n"));return r.stack=s+"\n"+(r.stack||r.message)+(e.stack?"\nFrom "+e.stack:""),r}return i(c,A),c}(),D=function(e){function r(e,t){return f(this,r),l(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,{message:e},t))}return i(r,C),r}(),I=function(e){function n(e,t){f(this,n);var r=l(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e,t));return m(r,e),r.originalError=e,r}return i(n,C),n}(),q=function(e){function n(e,t){if(f(this,n),e instanceof n)return l(r,e);var r=l(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e,t.token));return m(r,e),r.originalError=e,r}return i(n,C),n}(),V=function(e){function t(e){return f(this,t),l(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e+""))}return i(t,A),t}(),$=function(e){function t(e){return f(this,t),l(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e+""))}return i(t,A),t}();function ae(e,t){if(!e)throw new $(t=t||"expect "+e+" to be true")}var N={getAll:function(){return this.contexts.reduce(function(e,t){return m(e,t)},ee(null))},get:function(e){var r=this,t=this.propertyAccessSeq(e),n=this.findContextFor(t[0])||y(this.contexts);return t.reduce(function(e,t){return r.readProperty(e,t)},n)},set:function(e,r){var n=this.propertyAccessSeq(e),i=this.findContextFor(n[0])||y(this.contexts);n.some(function(e,t){return!te(i)||(t===n.length-1?(i[e]=r,!0):(void 0===i[e]&&(i[e]={}),void(i=i[e])))})},unshift:function(e){return this.contexts.unshift(e)},push:function(e){return this.contexts.push(e)},pop:function(t){if(!arguments.length)return this.contexts.pop();var e=this.contexts.findIndex(function(e){return e===t});if(-1===e)throw new TypeError("scope not found, cannot pop");return this.contexts.splice(e,1)[0]},findContextFor:function(e,t){t=t||function(){return!0};for(var r=this.contexts.length-1;0<=r;r--){var n=this.contexts[r];if(t(n)&&e in n)return n}return null},readProperty:function(e,t){var r=void 0;if(n(e)?r=void 0:("function"==typeof e.to_liquid?e=e.to_liquid():"function"==typeof e.toLiquid&&(e=e.toLiquid()),r="size"===t&&(a(e)||Z(e))?e.length:e[t]),n(r)&&this.opts.strict_variables)throw new TypeError("undefined variable: "+t);return r},propertyAccessSeq:function(e){e=String(e);for(var t,r=[],n="",i=void 0,o=0;oh&&g.push(v(h,t.index)),g.push(t[1]?d(t[1],t[2].trim(),t.index):(u=t[3],s=t[4].trim(),c=t.index,{type:"value",line:p.get(c),trim_left:"{{-"===u.slice(0,3),trim_right:"-}}"===u.slice(-3),raw:u,value:s,input:o,file:a}));return o.length>h&&g.push(v(h,o.length)),function(a,u){u=m({greedy:!0},u);var s=!1;a.forEach(function(e,t){var r,n,i,o;i=e,o=u,!s&&("tag"===i.type?i.trim_left||o.trim_tag_left:"value"===i.type?i.trim_left||o.trim_value_left:void 0)&&function(e,t){if(e&&"html"===e.type){var r=t?/\s+$/g:/[\t\r ]*$/g;e.value=e.value.replace(r,"")}}(a[t-1],u.greedy),"tag"===e.type&&"raw"===e.name&&(s=!0),"tag"===e.type&&"endraw"===e.name&&(s=!1),r=e,n=u,!s&&("tag"===r.type?r.trim_right||n.trim_tag_right:"value"===r.type?r.trim_right||n.trim_value_right:void 0)&&function(e,t){if(e&&"html"===e.type){var r=t?/^\s+/g:/^[\t\r ]*\n?/g;e.value=e.value.replace(r,"")}}(a[t+1],u.greedy)})}(g,e),g;function d(e,t,r){var n=t.match(x),i={type:"tag",indent:l,line:p.get(r),trim_left:"{%-"===e.slice(0,3),trim_right:"-%}"===e.slice(-3),raw:e,value:t,input:o,file:a};if(!n)throw new D("illegal tag syntax",i);return i.name=n[1],i.args=n[2],i}function v(e,t){var r=o.slice(e,t);return l=y(r.split("\n")).length,{type:"html",raw:r,value:r}}}var z={};function U(e){return new Promise(function(r,n){z.readFile(e,"utf8",function(e,t){e?n(e):r(t)})})}function B(e){return new Promise(function(r,n){z.stat(e,function(e,t){return e?n(e):r(t)})})}var W={},J=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^/]+?|)(\.[^./]*|))(?:[/]*)$/,X=/^(?:\w+:)?\/\/([^\s.]+\.\S{2}|localhost[:?\d]*)\S*$/;function K(e,t){return a(e)&&(e=e[0]),e&&"/"!==y(e)&&(e+="/"),function(e,t){var r=document.createElement("base");r.href=e;var n=document.getElementsByTagName("head")[0];n.insertBefore(r,n.firstChild);var i=document.createElement("a");i.href=t;var o=i.href;return r.href=o,n.removeChild(r),o}(e,t)}var ue,se=(ue=le,{"==":function(e,t){return e===t},"!=":function(e,t){return e!==t},">":function(e,t){return null!==e&&null!==t&&t=":function(e,t){return null!==e&&null!==t&&t<=e},"<=":function(e,t){return null!==e&&null!==t&&e<=t},contains:function(e,t){return!!e&&"function"==typeof e.indexOf&&-1"),c+=''),c+='',i.push(t),e.next=7,U.renderer.renderTemplates(f.templates,i);case 7:return c+=e.sent,c+="",i.pop(t),e.abrupt("return",c);case 11:case"end":return e.stop()}},e,f)}));return function(e,t){return r.apply(this,arguments)}}());case 10:return 0"),e.abrupt("return",c);case 12:case"end":return e.stop()}},e,this)})),function(e,t){return W.apply(this,arguments)})}),K=t,(X=e).registerTag("unless",{parse:function(t,e){var r=this;this.templates=[],this.elseTemplates=[];var n=void 0,i=X.parser.parseStream(e).on("start",function(e){n=r.templates,r.cond=t.args}).on("tag:else",function(){return n=r.elseTemplates}).on("tag:endunless",function(e){return i.stop()}).on("template",function(e){return n.push(e)}).on("end",function(e){throw new Error("tag "+t.raw+" not closed")});i.start()},render:function(e,t){var r=K.evalExp(this.cond,e);return K.isFalsy(r)?X.renderer.renderTemplates(this.templates,e):X.renderer.renderTemplates(this.elseTemplates,e)}})}var Ee=["January","February","March","April","May","June","July","August","September","October","November","December"],Te=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],_e=Ee.map(Oe),Re=Te.map(Oe),Se={1:"st",2:"nd",3:"rd",default:"th"};function Oe(e){return e.slice(0,3)}var Le={daysInMonth:function(e){return[31,Le.isLeapYear(e)?29:28,31,30,31,30,31,31,30,31,30,31]},getDayOfYear:function(e){for(var t=0,r=0;r":">",'"':""","'":"'"},Fe={"&":"&","<":"<",">":">",""":'"',"'":"'"},Ae={abs:function(e){return Math.abs(e)},append:function(e,t){return e+t},capitalize:function(e){return Ie(e).charAt(0).toUpperCase()+e.slice(1)},ceil:function(e){return Math.ceil(e)},concat:function(e,t){return Array.prototype.concat.call(e,t)},date:function(e,t){var r,n=e;return"now"===e?n=new Date:Z(e)&&(n=new Date(e)),(r=n)instanceof Date&&!isNaN(r.getTime())?function(e,t){for(var r="",n=t;;){var i=/%./g,o=i.exec(n);if(!o)return r+n;r+=n.slice(0,i.lastIndex-2),n=n.slice(i.lastIndex);var a=o[0].charAt(1),u=Pe[a];r+=u?u.call(this,e):"%"+a}}(n,t):e},default:function(e,t){return le(e)?e:t},divided_by:function(e,t){return e/t},downcase:function(e){return e.toLowerCase()},escape:Ce,escape_once:function(e){return Ce(Ie(e).replace(/&(amp|lt|gt|#34|#39);/g,function(e){return Fe[e]}))},first:function(e){return e[0]},floor:function(e){return Math.floor(e)},join:function(e,t){return e.join(t)},last:function(e){return y(e)},lstrip:function(e){return Ie(e).replace(/^\s+/,"")},map:function(e,t){return e.map(function(e){return e[t]})},minus:qe(function(e,t){return e-t}),modulo:qe(function(e,t){return e%t}),newline_to_br:function(e){return e.replace(/\n/g,"
")},plus:qe(function(e,t){return Number(e)+Number(t)}),prepend:function(e,t){return t+e},remove:function(e,t){return e.split(t).join("")},remove_first:function(e,t){return e.replace(t,"")},replace:function(e,t,r){return Ie(e).split(t).join(r)},replace_first:function(e,t,r){return Ie(e).replace(t,r)},reverse:function(e){return e.reverse()},round:function(e,t){var r=Math.pow(10,t||0);return Math.round(e*r,t)/r},rstrip:function(e){return Ie(e).replace(/\s+$/,"")},size:function(e){return e.length},slice:function(e,t,r){return e.substr(t,void 0===r?1:r)},sort:function(e,t){return e.sort(t)},split:function(e,t){return Ie(e).split(t)},strip:function(e){return Ie(e).trim()},strip_html:function(e){return Ie(e).replace(/|||<.*?>/g,"")},strip_newlines:function(e){return Ie(e).replace(/\n/g,"")},times:function(e,t){return e*t},truncate:function(e,t,r){return r=void 0===r?"...":r,t=t||16,(e=Ie(e)).length<=t?e:e.substr(0,t-r.length)+r},truncatewords:function(e,t,r){void 0===r&&(r="...");var n=e.split(" "),i=n.slice(0,t).join(" ");return n.length>t&&(i+=r),i},uniq:function(e){var t={};return(e||[]).filter(function(e){return!t.hasOwnProperty(e)&&(t[e]=!0)})},upcase:function(e){return Ie(e).toUpperCase()},url_encode:encodeURIComponent};function Ce(e){return Ie(e).replace(/&|<|>|"|'/g,function(e){return Me[e]})}function De(e){var t=(e+"").split(".");return 1