twig
Version:
JS port of the Twig templating language.
2 lines • 111 kB
JavaScript
/*! For license information please see twig.min.js.LICENSE.txt */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Twig=t():e.Twig=t()}(self,()=>{return e={683(e){"use strict";e.exports=function(e){return e.ParseState.prototype.parseAsync=function(e,t){return this.parse(e,t,!0)},e.expression.parseAsync=function(t,r,n){return e.expression.parse.call(this,t,r,n,!0)},e.logic.parseAsync=function(t,r,n){return e.logic.parse.call(this,t,r,n,!0)},e.Template.prototype.renderAsync=function(e,t){return this.render(e,t,!0)},e.async={},e.isPromise=function(e){return e&&e.then&&"function"==typeof e.then},e.async.potentiallyAsync=function(t,r,n){return r?e.Promise.resolve(n.call(t)):function(t,r,n){var o=n.call(t),i=null,s=!0;if(!e.isPromise(o))return o;if(o.then(function(e){o=e,s=!1}).catch(function(e){i=e}),null!==i)throw i;if(s)throw new e.Error("You are using Twig.js in sync mode in combination with async extensions.");return o}(t,0,n)},e.Thenable=function(e,t,r){this.then=e,this._value=r?t:null,this._state=r||0},e.Thenable.prototype.catch=function(e){return 1===this._state?this:this.then(null,e)},e.Thenable.resolvedThen=function(t){try{return e.Promise.resolve(t(this._value))}catch(t){return e.Promise.reject(t)}},e.Thenable.rejectedThen=function(t,r){if(!r||"function"!=typeof r)return this;var n,o=this._value;try{n=r(o)}catch(t){n=e.Promise.reject(t)}return e.Promise.resolve(n)},e.Promise=function(t){var r=0,n=null,o=function(e,t){r=e,n=t};return function(e,t,r){try{e(t,r)}catch(e){r(e)}}(t,function(e){o(1,e)},function(e){o(2,e)}),1===r?e.Promise.resolve(n):2===r?e.Promise.reject(n):(o=new e.FullPromise).promise},e.FullPromise=function(){var t=null;function r(e){e(s._value)}function n(e,t){t(s._value)}var o=function(e,r){t=function(e,t,r){var n=[t,r,-2];return e?-2===e[2]?e=[e,n]:e.push(n):e=n,e}(t,e,r)};function i(e,i){if(!s._state&&(s._value=i,s._state=e,o=1===e?r:n,t)){if(-2===t[2])return o(t[0],t[1]),void(t=null);t.forEach(function(e){o(e[0],e[1])}),t=null}}var s=new e.Thenable(function(t,r){var n="function"==typeof t;if(1===s._state&&!n)return e.Promise.resolve(s._value);if(1===s._state)try{return e.Promise.resolve(t(s._value))}catch(t){return e.Promise.reject(t)}var i="function"==typeof r;return new e.Promise(function(e,s){o(n?function(r){try{e(t(r))}catch(e){s(e)}}:e,i?function(t){try{e(r(t))}catch(e){s(e)}}:s)})});return i.promise=s,i},e.Promise.defaultResolved=new e.Thenable(e.Thenable.resolvedThen,void 0,1),e.Promise.emptyStringResolved=new e.Thenable(e.Thenable.resolvedThen,"",1),e.Promise.resolve=function(t){return 0===arguments.length||void 0===t?e.Promise.defaultResolved:e.isPromise(t)?t:""===t?e.Promise.emptyStringResolved:new e.Thenable(e.Thenable.resolvedThen,t,1)},e.Promise.reject=function(t){return new e.Thenable(e.Thenable.rejectedThen,t,2)},e.Promise.all=function(t){var r=new Array(t.length);return e.async.forEach(t,function(t,n){if(e.isPromise(t)){if(1!==t._state)return t.then(function(e){r[n]=e});r[n]=t._value}else r[n]=t}).then(function(){return r})},e.async.forEach=function(t,r){var n=t?t.length:0,o=0;return function i(){var s=null;do{if(o===n)return e.Promise.resolve();s=r(t[o],o),o++}while(!s||!e.isPromise(s)||1===s._state);return s.then(i)}()},e}},198(e){"use strict";e.exports=function(e){return e.compiler={module:{}},e.compiler.compile=function(t,r){var n=JSON.stringify(t.tokens),o=t.id,i=null;if(r.module){if(void 0===e.compiler.module[r.module])throw new e.Error("Unable to find module type "+r.module);i=e.compiler.module[r.module](o,n,r.twig)}else i=e.compiler.wrap(o,n);return i},e.compiler.module={amd:function(t,r,n){return'define(["'+n+'"], function (Twig) {\n\tvar twig, templates;\ntwig = Twig.twig;\ntemplates = '+e.compiler.wrap(t,r)+"\n\treturn templates;\n});"},node:function(t,r){return'var twig = require("twig").twig;\nexports.template = '+e.compiler.wrap(t,r)},cjs2:function(t,r,n){return'module.declare([{ twig: "'+n+'" }], function (require, exports, module) {\n\tvar twig = require("twig").twig;\n\texports.template = '+e.compiler.wrap(t,r)+"\n});"}},e.compiler.wrap=function(e,t){return'twig({id:"'+e.replace('"','\\"')+'", data:'+t+", precompiled: true});\n"},e}},636(e,t,r){"use strict";var n=r(994)(r(693));function o(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function i(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?o(Object(r),!0).forEach(function(t){(0,n.default)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}e.exports=function(e){function t(t,r){if(t.template.options.rethrow)throw"string"==typeof r&&(r=new e.Error(r)),"TwigException"!==r.type||r.file||(r.file=t.template.id),r;if(e.log.error("Error parsing twig template "+t.template.id+": "),r.stack?e.log.error(r.stack):e.log.error(r.toString()),e.debug)return r.toString()}return e.trace=!1,e.debug=!1,e.cache=!0,e.noop=function(){},e.merge=function(e,t,r){return Object.keys(t).forEach(function(n){r&&!(n in e)||(e[n]=t[n])}),e},e.Error=function(e,t){this.message=e,this.name="TwigException",this.type="TwigException",this.file=t},e.Error.prototype.toString=function(){return this.name+": "+this.message},e.log={trace:function(){if(e.trace&&console){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];console.log(Array.prototype.slice.call(r))}},debug:function(){if(e.debug&&console){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];console.log(Array.prototype.slice.call(r))}}},"undefined"==typeof console?e.log.error=function(){}:void 0!==console.error?e.log.error=function(){var e;(e=console).error.apply(e,arguments)}:void 0!==console.log&&(e.log.error=function(){var e;(e=console).log.apply(e,arguments)}),e.token={},e.token.type={output:"output",logic:"logic",comment:"comment",raw:"raw",outputWhitespacePre:"output_whitespace_pre",outputWhitespacePost:"output_whitespace_post",outputWhitespaceBoth:"output_whitespace_both",logicWhitespacePre:"logic_whitespace_pre",logicWhitespacePost:"logic_whitespace_post",logicWhitespaceBoth:"logic_whitespace_both"},e.token.definitions=[{type:e.token.type.raw,open:"{% raw %}",close:"{% endraw %}"},{type:e.token.type.raw,open:"{% verbatim %}",close:"{% endverbatim %}"},{type:e.token.type.outputWhitespacePre,open:"{{-",close:"}}"},{type:e.token.type.outputWhitespacePost,open:"{{",close:"-}}"},{type:e.token.type.outputWhitespaceBoth,open:"{{-",close:"-}}"},{type:e.token.type.logicWhitespacePre,open:"{%-",close:"%}"},{type:e.token.type.logicWhitespacePost,open:"{%",close:"-%}"},{type:e.token.type.logicWhitespaceBoth,open:"{%-",close:"-%}"},{type:e.token.type.output,open:"{{",close:"}}"},{type:e.token.type.logic,open:"{%",close:"%}"},{type:e.token.type.comment,open:"{#",close:"#}"}],e.token.strings=['"',"'"],e.token.findStart=function(t){var r,n,o,i,s={position:null,def:null},a=null,p=e.token.definitions.length;for(r=0;r<p;r++)n=e.token.definitions[r],o=t.indexOf(n.open),i=t.indexOf(n.close),e.log.trace("Twig.token.findStart: ","Searching for ",n.open," found at ",o),o>=0&&n.open.length!==n.close.length&&i<0||(o>=0&&(null===s.position||o<s.position)?(s.position=o,s.def=n,a=i):o>=0&&null!==s.position&&o===s.position&&(n.open.length>s.def.open.length?(s.position=o,s.def=n,a=i):n.open.length===s.def.open.length&&(n.close.length,s.def.close.length,i>=0&&i<a&&(s.position=o,s.def=n,a=i))));return s},e.token.findEnd=function(t,r,n){for(var o,i,s=null,a=!1,p=0,c=null,l=null,u=null,h=null,f=null,d=null;!a;){if(c=null,l=null,!((u=t.indexOf(r.close,p))>=0))throw new e.Error("Unable to find closing bracket '"+r.close+"' opened near template position "+n);if(s=u,a=!0,r.type===e.token.type.comment)break;if(r.type===e.token.type.raw)break;for(i=e.token.strings.length,o=0;o<i;o+=1)(f=t.indexOf(e.token.strings[o],p))>0&&f<u&&(null===c||f<c)&&(c=f,l=e.token.strings[o]);if(null!==c)for(h=c+1,s=null,a=!1;;){if((d=t.indexOf(l,h))<0)throw e.Error("Unclosed string in template");if("\\"!==t.slice(d-1,d)){p=d+1;break}h=d+1}}return s},e.tokenize=function(t){for(var r=[],n=0,o=null,i=null;t.length>0;)if(o=e.token.findStart(t),e.log.trace("Twig.tokenize: ","Found token: ",o),null===o.position)r.push({type:e.token.type.raw,value:t,position:{start:n,end:n+o.position}}),t="";else{if(o.position>0&&r.push({type:e.token.type.raw,value:t.slice(0,Math.max(0,o.position)),position:{start:n,end:n+Math.max(0,o.position)}}),t=t.slice(o.position+o.def.open.length),n+=o.position+o.def.open.length,i=e.token.findEnd(t,o.def,n),e.log.trace("Twig.tokenize: ","Token ends at ",i),r.push({type:o.def.type,value:t.slice(0,Math.max(0,i)).trim(),position:{start:n-o.def.open.length,end:n+i+o.def.close.length}}),"\n"===t.slice(i+o.def.close.length,i+o.def.close.length+1))switch(o.def.type){case"logic_whitespace_pre":case"logic_whitespace_post":case"logic_whitespace_both":case"logic":i+=1}t=t.slice(i+o.def.close.length),n+=i+o.def.close.length}return r},e.compile=function(t){var r=this;try{for(var n=[],o=[],i=[],s=null,a=null,p=null,c=null,l=null,u=null,h=null,f=null,d=null,y=null,m=null,g=function(t){e.expression.compile.call(r,t),o.length>0?i.push(t):n.push(t)},x=function(t){if((a=e.logic.compile.call(r,t)).position=t.position,d=a.type,y=e.logic.handler[d].open,m=e.logic.handler[d].next,e.log.trace("Twig.compile: ","Compiled logic token to ",a," next is: ",m," open is : ",y),void 0!==y&&!y){if(c=o.pop(),!e.logic.handler[c.type].next.includes(d))throw new Error(d+" not expected after a "+c.type);c.output=c.output||[],c.output=c.output.concat(i),i=[],f={type:e.token.type.logic,token:c,position:{open:c.position,close:t.position}},o.length>0?i.push(f):n.push(f)}void 0!==m&&m.length>0?(e.log.trace("Twig.compile: ","Pushing ",a," to logic stack."),o.length>0&&((c=o.pop()).output=c.output||[],c.output=c.output.concat(i),o.push(c),i=[]),o.push(a)):void 0!==y&&y&&(f={type:e.token.type.logic,token:a,position:a.position},o.length>0?i.push(f):n.push(f))};t.length>0;){switch(s=t.shift(),l=n[n.length-1],u=i[i.length-1],h=t[0],e.log.trace("Compiling token ",s),s.type){case e.token.type.raw:o.length>0?i.push(s):n.push(s);break;case e.token.type.logic:x.call(r,s);break;case e.token.type.comment:break;case e.token.type.output:g.call(r,s);break;case e.token.type.logicWhitespacePre:case e.token.type.logicWhitespacePost:case e.token.type.logicWhitespaceBoth:case e.token.type.outputWhitespacePre:case e.token.type.outputWhitespacePost:case e.token.type.outputWhitespaceBoth:switch(s.type!==e.token.type.outputWhitespacePost&&s.type!==e.token.type.logicWhitespacePost&&(l&&l.type===e.token.type.raw&&(n.pop(),l.value=l.value.trimEnd(),n.push(l)),u&&u.type===e.token.type.raw&&(i.pop(),u.value=u.value.trimEnd(),i.push(u))),s.type){case e.token.type.outputWhitespacePre:case e.token.type.outputWhitespacePost:case e.token.type.outputWhitespaceBoth:g.call(r,s);break;case e.token.type.logicWhitespacePre:case e.token.type.logicWhitespacePost:case e.token.type.logicWhitespaceBoth:x.call(r,s)}s.type!==e.token.type.outputWhitespacePre&&s.type!==e.token.type.logicWhitespacePre&&h&&h.type===e.token.type.raw&&(t.shift(),h.value=h.value.trimStart(),t.unshift(h))}e.log.trace("Twig.compile: "," Output: ",n," Logic Stack: ",o," Pending Output: ",i)}if(o.length>0)throw p=o.pop(),new Error("Unable to find an end tag for "+p.type+", expecting one of "+p.next);return n}catch(t){if(r.options.rethrow)throw"TwigException"!==t.type||t.file||(t.file=r.id),t;e.log.error("Error compiling twig template "+r.id+": "),t.stack?e.log.error(t.stack):e.log.error(t.toString())}},e.prepare=function(t){e.log.debug("Twig.prepare: ","Tokenizing ",t);var r=e.tokenize.call(this,t);e.log.debug("Twig.prepare: ","Compiling ",r);var n=e.compile.call(this,r);return e.log.debug("Twig.prepare: ","Compiled ",n),n},e.output=function(t){var r=this.options.autoescape;if(!r)return t.join("");var n="string"==typeof r?r:"html",o=t.map(function(t){return!t||!0===t.twigMarkup||t.twigMarkup===n||"html"===n&&"html_attr"===t.twigMarkup||(t=e.filters.escape(t,[n])),t});if(0===o.length)return"";var i=o.join("");return 0===i.length?"":new e.Markup(i,!0)},e.Templates={loaders:{},parsers:{},registry:{}},e.validateId=function(t){if("prototype"===t)throw new e.Error(t+" is not a valid twig identifier");if(e.cache&&Object.hasOwnProperty.call(e.Templates.registry,t))throw new e.Error("There is already a template with the ID "+t);return!0},e.Templates.registerLoader=function(t,r,n){if("function"!=typeof r)throw new e.Error("Unable to add loader for "+t+": Invalid function reference given.");n&&(r=r.bind(n)),this.loaders[t]=r},e.Templates.unRegisterLoader=function(e){this.isRegisteredLoader(e)&&delete this.loaders[e]},e.Templates.isRegisteredLoader=function(e){return Object.hasOwnProperty.call(this.loaders,e)},e.Templates.registerParser=function(t,r,n){if("function"!=typeof r)throw new e.Error("Unable to add parser for "+t+": Invalid function regerence given.");n&&(r=r.bind(n)),this.parsers[t]=r},e.Templates.unRegisterParser=function(e){this.isRegisteredParser(e)&&delete this.parsers[e]},e.Templates.isRegisteredParser=function(e){return Object.hasOwnProperty.call(this.parsers,e)},e.Templates.save=function(t){if(void 0===t.id)throw new e.Error("Unable to save template with no id");e.Templates.registry[t.id]=t},e.Templates.load=function(t){return Object.hasOwnProperty.call(e.Templates.registry,t)?e.Templates.registry[t]:null},e.Templates.loadRemote=function(t,r,n,o){var i=void 0===r.id?t:r.id,s=e.Templates.registry[i];return e.cache&&void 0!==s?("function"==typeof n&&n(s),s):(r.parser=r.parser||"twig",r.id=i,void 0===r.async&&(r.async=!0),(this.loaders[r.method]||this.loaders.fs).call(this,t,r,n,o))},e.Block=function(e,t){this.template=e,this.token=t},e.Block.prototype.render=function(t,r){var n=t.template;return t.template=this.template,(this.token.expression?e.expression.parseAsync.call(t,this.token.output,r):t.parseAsync(this.token.output,r)).then(function(n){return e.expression.parseAsync.call(t,{type:e.expression.type.string,value:n},r)}).then(function(e){return t.template=n,e})},e.ParseState=function(e,t,r){this.renderedBlocks={},this.overrideBlocks=void 0===t?{}:t,this.context=void 0===r?{}:r,this.macros={},this.nestingStack=[],this.template=e},e.ParseState.prototype.getBlock=function(e,t){var r;return!0!==t&&(r=this.overrideBlocks[e]),void 0===r&&(r=this.template.getBlock(e,t)),void 0===r&&null!==this.template.parentTemplate&&(r=this.template.parentTemplate.getBlock(e)),r},e.ParseState.prototype.getBlocks=function(e){var t={};return!1!==e&&null!==this.template.parentTemplate&&this.template.parentTemplate!==this.template&&(t=this.template.parentTemplate.getBlocks()),t=i(i(i({},t),this.template.getBlocks()),this.overrideBlocks)},e.ParseState.prototype.getNestingStackToken=function(e){var t;return this.nestingStack.forEach(function(r){void 0===t&&r.type===e&&(t=r)}),t},e.ParseState.prototype.parse=function(r,n,o){var i,s=this,a=[],p=null,c=!0,l=!0;function u(e){a.push(e)}function h(e){void 0!==e.chain&&(l=e.chain),void 0!==e.context&&(s.context=e.context),void 0!==e.output&&a.push(e.output)}if(n&&(s.context=n),i=e.async.forEach(r,function(t){switch(e.log.debug("Twig.ParseState.parse: ","Parsing token: ",t),t.type){case e.token.type.raw:a.push(e.filters.raw(t.value));break;case e.token.type.logic:return e.logic.parseAsync.call(s,t.token,s.context,l).then(h);case e.token.type.comment:break;case e.token.type.outputWhitespacePre:case e.token.type.outputWhitespacePost:case e.token.type.outputWhitespaceBoth:case e.token.type.output:return e.log.debug("Twig.ParseState.parse: ","Output token: ",t.stack),e.expression.parseAsync.call(s,t.stack,s.context).then(u)}}).then(function(){return a=e.output.call(s.template,a),c=!1,a}).catch(function(e){o&&t(s,e),p=e}),o)return i;if(null!==p)return t(s,p);if(c)throw new e.Error("You are using Twig.js in sync mode in combination with async extensions.");return a},e.Template=function(t){var r,n,o,i=t.data,s=t.id,a=t.base,p=t.path,c=t.url,l=t.name,u=t.method,h=t.options;this.base=a,this.blocks={defined:{},imported:{}},this.id=s,this.method=u,this.name=l,this.options=h,this.parentTemplate=null,this.path=p,this.url=c,r="String",n=i,o=Object.prototype.toString.call(n).slice(8,-1),this.tokens=null!=n&&o===r?e.prepare.call(this,i):i,void 0!==s&&e.Templates.save(this)},e.Template.prototype.getBlock=function(e,t){var r,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return!0!==t&&(r=this.blocks.defined[e]),n&&void 0===r&&(r=this.blocks.imported[e]),void 0===r&&null!==this.parentTemplate&&(r=this.parentTemplate.getBlock(e,t,n=!1)),r},e.Template.prototype.getBlocks=function(){var e={};return e=i(i(i({},e),this.blocks.imported),this.blocks.defined)},e.Template.prototype.render=function(t,r,n){var o=this;return r=r||{},e.async.potentiallyAsync(o,n,function(){var n=new e.ParseState(o,r.blocks,t);return n.parseAsync(o.tokens).then(function(t){var i,s;return null!==o.parentTemplate?(o.options.allowInlineIncludes&&(i=e.Templates.load(o.parentTemplate))&&(i.options=o.options),i||(s=e.path.parsePath(o,o.parentTemplate),i=e.Templates.loadRemote(s,{method:o.getLoaderMethod(),base:o.base,async:!1,id:s,options:o.options})),o.parentTemplate=i,o.parentTemplate.renderAsync(n.context,{blocks:n.getBlocks(!1),isInclude:!0})):!0===r.isInclude?t:t.valueOf()})})},e.Template.prototype.importFile=function(t){var r,n=null;if(!this.url&&this.options.allowInlineIncludes){if(t=this.path?e.path.parsePath(this,t):t,!(r=e.Templates.load(t))&&!(r=e.Templates.loadRemote(n,{id:t,method:this.getLoaderMethod(),async:!1,path:t,options:this.options})))throw new e.Error("Unable to find the template "+t);return r.options=this.options,r}return n=e.path.parsePath(this,t),r=e.Templates.loadRemote(n,{method:this.getLoaderMethod(),base:this.base,async:!1,options:this.options,id:n})},e.Template.prototype.getLoaderMethod=function(){return this.path?"fs":this.url?"ajax":this.method||"fs"},e.Template.prototype.compile=function(t){return e.compiler.compile(this,t)},e.Markup=function(e,t){if("string"!=typeof e)return e;var r=new String(e);return r.twigMarkup=void 0===t||t,r},e}},68(e){"use strict";e.exports=function(e){return e.exports={VERSION:e.VERSION},e.exports.twig=function(t){var r=t.id,n={strictVariables:t.strict_variables||!1,autoescape:null!==t.autoescape&&t.autoescape||!1,allowInlineIncludes:t.allowInlineIncludes||!1,rethrow:t.rethrow||!1,namespaces:t.namespaces};if(e.cache&&r&&e.validateId(r),void 0!==t.debug&&(e.debug=t.debug),void 0!==t.trace&&(e.trace=t.trace),void 0!==t.data)return e.Templates.parsers.twig({data:t.data,path:Object.hasOwnProperty.call(t,"path")?t.path:void 0,module:t.module,id:r,options:n});if(void 0!==t.ref){if(void 0!==t.id)throw new e.Error("Both ref and id cannot be set on a twig.js template.");return e.Templates.load(t.ref)}if(void 0!==t.method){if(!e.Templates.isRegisteredLoader(t.method))throw new e.Error('Loader for "'+t.method+'" is not defined.');return e.Templates.loadRemote(t.name||t.href||t.path||r||void 0,{id:r,method:t.method,parser:t.parser||"twig",base:t.base,module:t.module,precompiled:t.precompiled,async:t.async,options:n},t.load,t.error)}return void 0!==t.href?e.Templates.loadRemote(t.href,{id:r,method:"ajax",parser:t.parser||"twig",base:t.base,module:t.module,precompiled:t.precompiled,async:t.async,options:n},t.load,t.error):void 0!==t.path?e.Templates.loadRemote(t.path,{id:r,method:"fs",parser:t.parser||"twig",base:t.base,module:t.module,precompiled:t.precompiled,async:t.async,options:n},t.load,t.error):void 0},e.exports.extendFilter=function(t,r){e.filter.extend(t,r)},e.exports.extendFunction=function(t,r){e._function.extend(t,r)},e.exports.extendTest=function(t,r){e.test.extend(t,r)},e.exports.extendTag=function(t){e.logic.extend(t)},e.exports.extend=function(t){t(e)},e.exports.compile=function(t,r){var n=r.filename,o=r.filename,i=new e.Template({data:t,path:o,id:n,options:r.settings["twig options"]});return function(e){return i.render(e)}},e.exports.renderFile=function(t,r,n){"function"==typeof r&&(n=r,r={});var o=(r=r||{}).settings||{},i=o["twig options"],s={path:t,base:o.views,load:function(e){i&&i.allowAsync?e.renderAsync(r).then(function(e){return n(null,e)},n):n(null,String(e.render(r)))},error:function(e){n(e)}};if(i)for(var a in i)Object.hasOwnProperty.call(i,a)&&(s[a]=i[a]);e.exports.twig(s)},e.exports.__express=e.exports.renderFile,e.exports.cache=function(t){e.cache=t},e.exports.path=e.path,e.exports.filters=e.filters,e.exports.tests=e.tests,e.exports.functions=e.functions,e.exports.Promise=e.Promise,e}},989(e,t,r){"use strict";var n=r(994),o=n(r(738)),i=n(r(132));e.exports=function(e){function t(t,r,n){return r?e.expression.parseAsync.call(t,r,n):e.Promise.resolve(!1)}for(e.expression={},r(611)(e),e.expression.reservedWords=["true","false","null","TRUE","FALSE","NULL","_context","and","b-and","or","b-or","b-xor","in","not in","if","matches","starts","ends","with"],e.expression.type={comma:"Twig.expression.type.comma",operator:{unary:"Twig.expression.type.operator.unary",binary:"Twig.expression.type.operator.binary"},string:"Twig.expression.type.string",bool:"Twig.expression.type.bool",slice:"Twig.expression.type.slice",array:{start:"Twig.expression.type.array.start",end:"Twig.expression.type.array.end"},object:{start:"Twig.expression.type.object.start",end:"Twig.expression.type.object.end"},parameter:{start:"Twig.expression.type.parameter.start",end:"Twig.expression.type.parameter.end"},subexpression:{start:"Twig.expression.type.subexpression.start",end:"Twig.expression.type.subexpression.end"},key:{period:"Twig.expression.type.key.period",brackets:"Twig.expression.type.key.brackets"},filter:"Twig.expression.type.filter",_function:"Twig.expression.type._function",variable:"Twig.expression.type.variable",number:"Twig.expression.type.number",_null:"Twig.expression.type.null",context:"Twig.expression.type.context",test:"Twig.expression.type.test"},e.expression.set={operations:[e.expression.type.filter,e.expression.type.operator.unary,e.expression.type.operator.binary,e.expression.type.array.end,e.expression.type.object.end,e.expression.type.parameter.end,e.expression.type.subexpression.end,e.expression.type.comma,e.expression.type.test],expressions:[e.expression.type._function,e.expression.type.bool,e.expression.type.string,e.expression.type.variable,e.expression.type.number,e.expression.type._null,e.expression.type.context,e.expression.type.parameter.start,e.expression.type.array.start,e.expression.type.object.start,e.expression.type.subexpression.start,e.expression.type.operator.unary]},e.expression.set.operationsExtended=e.expression.set.operations.concat([e.expression.type.key.period,e.expression.type.key.brackets,e.expression.type.slice]),e.expression.fn={compile:{push:function(e,t,r){r.push(e)},pushBoth:function(e,t,r){r.push(e),t.push(e)}},parse:{push:function(e,t){t.push(e)},pushValue:function(e,t){t.push(e.value)}}},e.expression.definitions=[{type:e.expression.type.test,regex:/^is\s+(not)?\s*([a-zA-Z_]\w*(\s?(?:as|by))?)/,next:e.expression.set.operations.concat([e.expression.type.parameter.start]),compile:function(e,t,r){e.filter=e.match[2],e.modifier=e.match[1],delete e.match,delete e.value,r.push(e)},parse:function(r,n,o){var i=n.pop();return t(this,r.params,o).then(function(t){var o=e.test(r.filter,i,t);"not"===r.modifier?n.push(!o):n.push(o)})}},{type:e.expression.type.comma,regex:/^,/,next:e.expression.set.expressions.concat([e.expression.type.array.end,e.expression.type.object.end]),compile:function(t,r,n){var o,i=r.length-1;for(delete t.match,delete t.value;i>=0;i--){if((o=r.pop()).type===e.expression.type.object.start||o.type===e.expression.type.parameter.start||o.type===e.expression.type.array.start){r.push(o);break}n.push(o)}n.push(t)}},{type:e.expression.type.number,regex:/^-?\d+(\.\d+)?/,next:e.expression.set.operations,compile:function(e,t,r){e.value=Number(e.value),r.push(e)},parse:e.expression.fn.parse.pushValue},{type:e.expression.type.operator.binary,regex:/(^\?\?|^\?\s*:|^(b-and)|^(b-or)|^(b-xor)|^[+\-~%?]|^(<=>)|^[:](?!\d\])|^[!=]==?|^[!<>]=?|^\*\*?|^\/\/?|^(and)[(|\s+]|^(or)[(|\s+]|^(in)[(|\s+]|^(not in)[(|\s+]|^(matches)|^(starts with)|^(ends with)|^\.\.)/,next:e.expression.set.expressions,transform:function(e,t){switch(e[0]){case"and(":case"or(":case"in(":case"not in(":return t[t.length-1].value=e[2],e[0];default:return""}},compile:function(t,r,n){delete t.match,t.value.match(/^\?\s*:/)&&(t.value="?:"),t.value=t.value.trim();var o=t.value,i=e.expression.operator.lookup(o,t);for(e.log.trace("Twig.expression.compile: ","Operator: ",i," from ",o);r.length>0&&(r[r.length-1].type===e.expression.type.operator.unary||r[r.length-1].type===e.expression.type.operator.binary)&&(i.associativity===e.expression.operator.leftToRight&&i.precidence>=r[r.length-1].precidence||i.associativity===e.expression.operator.rightToLeft&&i.precidence>r[r.length-1].precidence);){var s=r.pop();n.push(s)}if(":"===o)if(r[r.length-1]&&"?"===r[r.length-1].value);else{var a=n.pop();if(a.type===e.expression.type.string||a.type===e.expression.type.variable)t.key=a.value;else if(a.type===e.expression.type.number)t.key=a.value.toString();else{if(!a.expression||a.type!==e.expression.type.parameter.end&&a.type!==e.expression.type.subexpression.end)throw new e.Error("Unexpected value before ':' of "+a.type+" = "+a.value);t.params=a.params}n.push(t)}else r.push(i)},parse:function(t,r,n){if(t.key)r.push(t);else{if(t.params)return e.expression.parseAsync.call(this,t.params,n).then(function(e){t.key=e,r.push(t),n.loop||delete t.params});e.expression.operator.parse(t.value,r)}}},{type:e.expression.type.operator.unary,regex:/(^not\s+)/,next:e.expression.set.expressions,compile:function(t,r,n){delete t.match,t.value=t.value.trim();var o=t.value,i=e.expression.operator.lookup(o,t);for(e.log.trace("Twig.expression.compile: ","Operator: ",i," from ",o);r.length>0&&(r[r.length-1].type===e.expression.type.operator.unary||r[r.length-1].type===e.expression.type.operator.binary)&&(i.associativity===e.expression.operator.leftToRight&&i.precidence>=r[r.length-1].precidence||i.associativity===e.expression.operator.rightToLeft&&i.precidence>r[r.length-1].precidence);){var s=r.pop();n.push(s)}r.push(i)},parse:function(t,r){e.expression.operator.parse(t.value,r)}},{type:e.expression.type.string,regex:/^(["'])(?:(?=(\\?))\2[\s\S])*?\1/,next:e.expression.set.operationsExtended,compile:function(t,r,n){var o=t.value;delete t.match,o='"'===o.slice(0,1)?o.replace('\\"','"'):o.replace("\\'","'"),t.value=o.slice(1,-1).replace(/\\n/g,"\n").replace(/\\r/g,"\r"),e.log.trace("Twig.expression.compile: ","String value: ",t.value),n.push(t)},parse:e.expression.fn.parse.pushValue},{type:e.expression.type.subexpression.start,regex:/^\(/,next:e.expression.set.expressions.concat([e.expression.type.subexpression.end]),compile:function(e,t,r){e.value="(",r.push(e),t.push(e)},parse:e.expression.fn.parse.push},{type:e.expression.type.subexpression.end,regex:/^\)/,next:e.expression.set.operationsExtended,validate:function(t,r){for(var n=r.length-1,o=!1,i=!1,s=0;!o&&n>=0;){var a=r[n];(o=a.type===e.expression.type.subexpression.start)&&i&&(i=!1,o=!1),a.type===e.expression.type.parameter.start?s++:a.type===e.expression.type.parameter.end?s--:a.type===e.expression.type.subexpression.end&&(i=!0),n--}return o&&0===s},compile:function(t,r,n){var o,i=t;for(o=r.pop();r.length>0&&o.type!==e.expression.type.subexpression.start;)n.push(o),o=r.pop();for(var s=[];t.type!==e.expression.type.subexpression.start;)s.unshift(t),t=n.pop();s.unshift(t),void 0===(o=r[r.length-1])||o.type!==e.expression.type._function&&o.type!==e.expression.type.filter&&o.type!==e.expression.type.test&&o.type!==e.expression.type.key.brackets?(i.expression=!0,s.pop(),s.shift(),i.params=s,n.push(i)):(i.expression=!1,o.params=s)},parse:function(t,r,n){if(t.expression)return e.expression.parseAsync.call(this,t.params,n).then(function(e){r.push(e)});throw new e.Error("Unexpected subexpression end when token is not marked as an expression")}},{type:e.expression.type.parameter.start,regex:/^\(/,next:e.expression.set.expressions.concat([e.expression.type.parameter.end]),validate:function(t,r){var n=r[r.length-1];return n&&!e.expression.reservedWords.includes(n.value.trim())},compile:e.expression.fn.compile.pushBoth,parse:e.expression.fn.parse.push},{type:e.expression.type.parameter.end,regex:/^\)/,next:e.expression.set.operationsExtended,compile:function(t,r,n){var o,i=t;for(o=r.pop();r.length>0&&o.type!==e.expression.type.parameter.start;)n.push(o),o=r.pop();for(var s=[];t.type!==e.expression.type.parameter.start;)s.unshift(t),t=n.pop();s.unshift(t),void 0===(t=n[n.length-1])||t.type!==e.expression.type._function&&t.type!==e.expression.type.filter&&t.type!==e.expression.type.test&&t.type!==e.expression.type.key.brackets?(i.expression=!0,s.pop(),s.shift(),i.params=s,n.push(i)):(i.expression=!1,t.params=s)},parse:function(t,r,n){var o=[],i=!1,s=null;if(t.expression)return e.expression.parseAsync.call(this,t.params,n).then(function(e){r.push(e)});for(;r.length>0;){if((s=r.pop())&&s.type&&s.type===e.expression.type.parameter.start){i=!0;break}o.unshift(s)}if(!i)throw new e.Error("Expected end of parameter set.");r.push(o)}},{type:e.expression.type.slice,regex:/^\[(-?\w*:-?\w*)\]/,next:e.expression.set.operationsExtended,compile:function(e,t,r){var n=e.match[1].split(":"),o=n[0],i=n[1];e.value="slice",e.params=[o,i],i||(e.params=[o]),r.push(e)},parse:function(t,r,n){var o=r.pop(),i=t.params,s=this;if(parseInt(i[0],10).toString()===i[0])i[0]=parseInt(i[0],10);else{var a=n[i[0]];if(s.template.options.strictVariables&&void 0===a)throw new e.Error('Variable "'+i[0]+'" does not exist.');i[0]=a}if(i[1])if(parseInt(i[1],10).toString()===i[1])i[1]=parseInt(i[1],10);else{var p=n[i[1]];if(s.template.options.strictVariables&&void 0===p)throw new e.Error('Variable "'+i[1]+'" does not exist.');void 0===p?i=[i[0]]:i[1]=p}r.push(e.filter.call(s,t.value,o,i))}},{type:e.expression.type.array.start,regex:/^\[/,next:e.expression.set.expressions.concat([e.expression.type.array.end]),compile:e.expression.fn.compile.pushBoth,parse:e.expression.fn.parse.push},{type:e.expression.type.array.end,regex:/^\]/,next:e.expression.set.operationsExtended,compile:function(t,r,n){for(var o,i=r.length-1;i>=0&&(o=r.pop()).type!==e.expression.type.array.start;i--)n.push(o);n.push(t)},parse:function(t,r){for(var n=[],o=!1,i=null;r.length>0;){if((i=r.pop())&&i.type&&i.type===e.expression.type.array.start){o=!0;break}n.unshift(i)}if(!o)throw new e.Error("Expected end of array.");r.push(n)}},{type:e.expression.type.object.start,regex:/^\{/,next:e.expression.set.expressions.concat([e.expression.type.object.end]),compile:e.expression.fn.compile.pushBoth,parse:e.expression.fn.parse.push},{type:e.expression.type.object.end,regex:/^\}/,next:e.expression.set.operationsExtended,compile:function(t,r,n){for(var o,i=r.length-1;i>=0&&(!(o=r.pop())||o.type!==e.expression.type.object.start);i--)n.push(o);n.push(t)},parse:function(t,r){for(var n={},o=!1,i=null,s=!1,a=null;r.length>0;){if((i=r.pop())&&i.type&&i.type===e.expression.type.object.start){o=!0;break}if(i&&i.type&&(i.type===e.expression.type.operator.binary||i.type===e.expression.type.operator.unary)&&i.key){if(!s)throw new e.Error("Missing value for key '"+i.key+"' in object definition.");n[i.key]=a,void 0===n._keys&&(n._keys=[]),n._keys.unshift(i.key),a=null,s=!1}else s=!0,a=i}if(!o)throw new e.Error("Unexpected end of object.");r.push(n)}},{type:e.expression.type.filter,regex:/^\|\s?([a-zA-Z_][a-zA-Z0-9_-]*)/,next:e.expression.set.operationsExtended.concat([e.expression.type.parameter.start]),compile:function(e,t,r){e.value=e.match[1],r.push(e)},parse:function(r,n,o){var i=n.pop(),s=this;return t(s,r.params,o).then(function(t){return e.filter.call(s,r.value,i,t)}).then(function(e){n.push(e)})}},{type:e.expression.type._function,regex:/^([a-zA-Z_]\w*)\s*\(/,next:e.expression.type.parameter.start,validate:function(t){return t[1]&&!e.expression.reservedWords.includes(t[1])},transform:function(){return"("},compile:function(e,t,r){var n=e.match[1];e.fn=n,delete e.match,delete e.value,r.push(e)},parse:function(r,n,o){var s,a=this,p=r.fn;return t(a,r.params,o).then(function(t){if(e.functions[p])s=e.functions[p].apply(a,t);else{if("function"!=typeof o[p])throw new e.Error(p+" function does not exist and is not defined in the context");s=o[p].apply(o,(0,i.default)(t))}return s}).then(function(e){n.push(e)})}},{type:e.expression.type.variable,regex:/^[a-zA-Z_]\w*/,next:e.expression.set.operationsExtended.concat([e.expression.type.parameter.start]),compile:e.expression.fn.compile.push,validate:function(t){return!e.expression.reservedWords.includes(t[0])},parse:function(t,r,n){var o=this;return e.expression.resolveAsync.call(o,n[t.value],n).then(function(n){if(o.template.options.strictVariables&&void 0===n)throw new e.Error('Variable "'+t.value+'" does not exist.');r.push(n)})}},{type:e.expression.type.key.period,regex:/^\.(\w+)/,next:e.expression.set.operationsExtended.concat([e.expression.type.parameter.start]),compile:function(e,t,r){e.key=e.match[1],delete e.match,delete e.value,r.push(e)},parse:function(r,n,i,s){var a,p=this,c=r.key,l=n.pop();if(l&&!Object.prototype.hasOwnProperty.call(l,c)&&p.template.options.strictVariables)throw Object.keys(l).length>0?new e.Error('Key "'+c+'" for object with keys "'+Object.keys(l).join(", ")+'" does not exist.'):new e.Error('Key "'+c+'" does not exist as the object is empty.');return t(p,r.params,i).then(function(t){if(null==l)a=void 0;else{var r=function(e){return e.slice(0,1).toUpperCase()+e.slice(1)};a="object"===(0,o.default)(l)&&c in l?l[c]:l["get"+r(c)]?l["get"+r(c)]:l["is"+r(c)]?l["is"+r(c)]:void 0}return e.expression.resolveAsync.call(p,a,i,t,s,l)}).then(function(e){n.push(e)})}},{type:e.expression.type.key.brackets,regex:/^\[([^\]]*)\]/,next:e.expression.set.operationsExtended.concat([e.expression.type.parameter.start]),compile:function(t,r,n){var o=t.match[1];delete t.value,delete t.match,t.stack=e.expression.compile({value:o}).stack,n.push(t)},parse:function(r,n,i,s){var a,p,c=this,l=null;return t(c,r.params,i).then(function(t){return l=t,e.expression.parseAsync.call(c,r.stack,i)}).then(function(t){if((a=n.pop())&&!Object.prototype.hasOwnProperty.call(a,t)&&c.template.options.strictVariables){var r=Object.keys(a);throw r.length>0?new e.Error('Key "'+t+'" for array with keys "'+r.join(", ")+'" does not exist.'):new e.Error('Key "'+t+'" does not exist as the array is empty.')}return null==a?null:(p="object"===(0,o.default)(a)&&t in a?a[t]:null,e.expression.resolveAsync.call(c,p,a,l,s))}).then(function(e){n.push(e)})}},{type:e.expression.type._null,regex:/^(null|NULL|none|NONE)/,next:e.expression.set.operations,compile:function(e,t,r){delete e.match,e.value=null,r.push(e)},parse:e.expression.fn.parse.pushValue},{type:e.expression.type.context,regex:/^_context/,next:e.expression.set.operationsExtended.concat([e.expression.type.parameter.start]),compile:e.expression.fn.compile.push,parse:function(e,t,r){t.push(r)}},{type:e.expression.type.bool,regex:/^(true|TRUE|false|FALSE)/,next:e.expression.set.operations,compile:function(e,t,r){e.value="true"===e.match[0].toLowerCase(),delete e.match,r.push(e)},parse:e.expression.fn.parse.pushValue}],e.expression.resolveAsync=function(t,r,n,o,i){var s=this;if("function"!=typeof t)return e.Promise.resolve(t);var a=e.Promise.resolve(n);return o&&o.type===e.expression.type.parameter.end&&(a=a.then(function(){return o.params&&e.expression.parseAsync.call(s,o.params,r,!0)}).then(function(e){return o.cleanup=!0,e})),a.then(function(e){return t.apply(i||r,e||[])})},e.expression.resolve=function(t,r,n,o,i){return e.async.potentiallyAsync(this,!1,function(){return e.expression.resolveAsync.call(this,t,r,n,o,i)})},e.expression.handler={},e.expression.extendType=function(t){e.expression.type[t]="Twig.expression.type."+t},e.expression.extend=function(t){if(!t.type)throw new e.Error("Unable to extend logic definition. No type provided for "+t);e.expression.handler[t.type]=t};e.expression.definitions.length>0;)e.expression.extend(e.expression.definitions.shift());return e.expression.tokenize=function(t){var r,n,o,i,s,a=t.value,p=[],c=0,l=null,u=[],h=function(){for(var n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];for(var h=arguments.length-2,f=new Array(h);h-- >0;)f[h]=o[h];if(e.log.trace("Twig.expression.tokenize","Matched a ",r," regular expression of ",f),l&&!l.includes(r))return u.push(r+" cannot follow a "+p[p.length-1].type+" at template:"+c+" near '"+f[0].slice(0,20)+"...'"),f[0];var d=e.expression.handler[r];if(d.validate&&!d.validate(f,p))return f[0];u=[];var y={type:r,value:f[0],match:f};return t.position&&(y.position=t.position),p.push(y),s=!0,l=i,c+=f[0].length,d.transform?d.transform(f,p):""};for(e.log.debug("Twig.expression.tokenize","Tokenizing expression ",a);a.length>0;){for(r in a=a.trim(),e.expression.handler)if(Object.hasOwnProperty.call(e.expression.handler,r)){if(i=e.expression.handler[r].next,n=e.expression.handler[r].regex,e.log.trace("Checking type ",r," on ",a),s=!1,Array.isArray(n))for(o=n.length;o-- >0;)a=a.replace(n[o],h);else a=a.replace(n,h);if(s)break}if(!s)throw u.length>0?new e.Error(u.join(" OR ")):new e.Error("Unable to parse '"+a+"' at template position"+c)}return e.log.trace("Twig.expression.tokenize","Tokenized to ",p),p},e.expression.compile=function(t){var r=e.expression.tokenize(t),n=null,o=[],i=[],s=null;for(e.log.trace("Twig.expression.compile: ","Compiling ",t.value);r.length>0;)n=r.shift(),s=e.expression.handler[n.type],e.log.trace("Twig.expression.compile: ","Compiling ",n),s.compile(n,i,o),e.log.trace("Twig.expression.compile: ","Stack is",i),e.log.trace("Twig.expression.compile: ","Output is",o);for(;i.length>0;)o.push(i.pop());return e.log.trace("Twig.expression.compile: ","Final output is",o),t.stack=o,delete t.value,t},e.expression.parse=function(t,r,n,o){var i=this;Array.isArray(t)||(t=[t]);var s=[],a=[],p=e.expression.type.operator.binary;return e.async.potentiallyAsync(i,o,function(){return e.async.forEach(t,function(n,o){var c,l=null,u=null;if(!n.cleanup)return t.length>o+1&&(u=t[o+1]),(l=e.expression.handler[n.type]).parse&&(c=l.parse.call(i,n,s,r,u)),n.type===p&&r.loop&&a.push(n),c}).then(function(){for(var e=a.length,t=null;e-- >0;)(t=a[e]).params&&t.key&&delete t.key;if(n){var r=s.splice(0);s.push(r)}return s.pop()})})},e}},611(e){"use strict";e.exports=function(e){e.expression.operator={leftToRight:"leftToRight",rightToLeft:"rightToLeft"};var t=function(e,t){if(null==t)return null;if(void 0!==t.indexOf)return(e===t||""!==e)&&t.includes(e);var r;for(r in t)if(Object.hasOwnProperty.call(t,r)&&t[r]===e)return!0;return!1};return e.expression.operator.lookup=function(t,r){switch(t){case"..":r.precidence=20,r.associativity=e.expression.operator.leftToRight;break;case",":r.precidence=18,r.associativity=e.expression.operator.leftToRight;break;case"?:":case"?":case":":r.precidence=16,r.associativity=e.expression.operator.rightToLeft;break;case"??":r.precidence=15,r.associativity=e.expression.operator.rightToLeft;break;case"or":r.precidence=14,r.associativity=e.expression.operator.leftToRight;break;case"and":r.precidence=13,r.associativity=e.expression.operator.leftToRight;break;case"b-or":r.precidence=12,r.associativity=e.expression.operator.leftToRight;break;case"b-xor":r.precidence=11,r.associativity=e.expression.operator.leftToRight;break;case"b-and":r.precidence=10,r.associativity=e.expression.operator.leftToRight;break;case"==":case"!=":case"<=>":r.precidence=9,r.associativity=e.expression.operator.leftToRight;break;case"<":case"<=":case">":case">=":case"not in":case"in":case"matches":case"starts with":case"ends with":r.precidence=8,r.associativity=e.expression.operator.leftToRight;break;case"~":case"+":case"-":r.precidence=6,r.associativity=e.expression.operator.leftToRight;break;case"//":case"**":case"*":case"/":case"%":r.precidence=5,r.associativity=e.expression.operator.leftToRight;break;case"not":r.precidence=3,r.associativity=e.expression.operator.rightToLeft;break;default:throw new e.Error("Failed to lookup operator: "+t+" is an unknown operator.")}return r.operator=t,r},e.expression.operator.parse=function(r,n){var o,i,s;if(e.log.trace("Twig.expression.operator.parse: ","Handling ",r),"?"===r&&(s=n.pop()),i=n.pop(),"not"!==r&&(o=n.pop()),"in"!==r&&"not in"!==r&&"??"!==r&&(o&&Array.isArray(o)&&(o=o.length),"?"!==r&&i&&Array.isArray(i)&&(i=i.length)),"matches"===r&&i&&"string"==typeof i){var a=i.match(/^\/(.*)\/([gims]?)$/),p=a[1],c=a[2];i=new RegExp(p,c)}switch(r){case":":break;case"??":void 0===o&&(o=i,i=s,s=void 0),null!=o?n.push(o):n.push(i);break;case"?:":e.lib.boolval(o)?n.push(o):n.push(i);break;case"?":void 0===o&&(o=i,i=s,s=void 0),e.lib.boolval(o)?n.push(i):n.push(s);break;case"+":i=parseFloat(i),o=parseFloat(o),n.push(o+i);break;case"-":i=parseFloat(i),o=parseFloat(o),n.push(o-i);break;case"*":i=parseFloat(i),o=parseFloat(o),n.push(o*i);break;case"/":i=parseFloat(i),o=parseFloat(o),n.push(o/i);break;case"//":i=parseFloat(i),o=parseFloat(o),n.push(Math.floor(o/i));break;case"%":i=parseFloat(i),o=parseFloat(o),n.push(o%i);break;case"~":n.push((null!=o?o.toString():"")+(null!=i?i.toString():""));break;case"not":case"!":n.push(!e.lib.boolval(i));break;case"<=>":n.push(o===i?0:o<i?-1:1);break;case"<":n.push(o<i);break;case"<=":n.push(o<=i);break;case">":n.push(o>i);break;case">=":n.push(o>=i);break;case"===":n.push(o===i);break;case"==":n.push(o==i);break;case"!==":n.push(o!==i);break;case"!=":n.push(o!=i);break;case"or":n.push(e.lib.boolval(o)||e.lib.boolval(i));break;case"b-or":n.push(o|i);break;case"b-xor":n.push(o^i);break;case"and":n.push(e.lib.boolval(o)&&e.lib.boolval(i));break;case"b-and":n.push(o&i);break;case"**":n.push(Math.pow(o,i));break;case"not in":n.push(!t(o,i));break;case"in":n.push(t(o,i));break;case"matches":n.push(i.test(o));break;case"starts with":n.push("string"==typeof o&&0===o.indexOf(i));break;case"ends with":n.push("string"==typeof o&&o.includes(i,o.length-i.length));break;case"..":n.push(e.functions.range(o,i));break;default:throw new e.Error("Failed to parse operator: "+r+" is an unknown operator.")}},e}},393(e,t,r){"use strict";e.exports=function e(){var t={VERSION:"3.0.0"};return r(636)(t),r(198)(t),r(989)(t),r(672)(t),r(682)(t),r(916)(t),r(354)(t),r(143)(t),r(857)(t),r(497)(t),r(241)(t),r(188)(t),r(230)(t),r(683)(t),r(68)(t),t.exports.factory=e,t.exports}},672(e,t,r){"use strict";var n=r(994)(r(738));e.exports=function(e){function t(e,t){var r=Object.prototype.toString.call(t).slice(8,-1);return null!=t&&r===e}return e.filters={upper:function(e){return"string"!=typeof e?e:e.toUpperCase()},lower:function(e){return"string"!=typeof e?e:e.toLowerCase()},capitalize:function(e){return"string"!=typeof e?e:e.slice(0,1).toUpperCase()+e.toLowerCase().slice(1)},title:function(e){return"string"!=typeof e?e:e.toLowerCase().replace(/(^|\s)([a-z])/g,function(e,t,r){return t+r.toUpperCase()})},length:function(t){return e.lib.is("Array",t)||"string"==typeof t?t.length:e.lib.is("Object",t)?void 0===t._keys?Object.keys(t).length:t._keys.length:0},reverse:function(e){if(t("Array",e))return e.reverse();if(t("String",e))return e.split("").reverse().join("");if(t("Object",e)){var r=e._keys||Object.keys(e).reverse();return e._keys=r,e}},sort:function(e){if(t("Array",e))return e.sort();if(t("Object",e)){delete e._keys;var r=Object.keys(e).sort(function(t,r){var n,o;return e[t]>e[r]==!(e[t]<=e[r])?e[t]>e[r]?1:e[t]<e[r]?-1:0:isNaN(n=parseFloat(e[t]))||isNaN(o=parseFloat(e[r]))?"string"==typeof e[t]?e[t]>e[r].toString()?1:e[t]<e[r].toString()?-1:0:"string"==typeof e[r]?e[t].toString()>e[r]?1:e[t].toString()<e[r]?-1:0:null:n>o?1:n<o?-1:0});return e._keys=r,e}},keys:function(e){if(null!=e){var t=e._keys||Object.keys(e),r=[];return t.forEach(function(t){"_keys"!==t&&Object.hasOwnProperty.call(e,t)&&r.push(t)}),r}},url_encode:function(t){if(null!=t){if(e.lib.is("Object",t)){var r=function(t,n){var o=[];return(t._keys||Object.keys(t)).forEach(function(i){if(Object.prototype.hasOwnProperty.call(t,i)){var s=n?n+"["+i+"]":i,a=t[i];o.push(e.lib.is("Object",a)||Array.isArray(a)?r(a,s):encodeURIComponent(s)+"="+encodeURIComponent(a))}}),o.join("&")};return r(t)}var n=encodeURIComponent(t);return n=n.replace("'","%27")}},join:function(e,r){if(null!=e){var n="",o=[];return r&&r[0]&&(n=r[0]),t("Array",e)?o=e:(e._keys||Object.keys(e)).forEach(function(t){"_keys"!==t&&Object.hasOwnProperty.call(e,t)&&o.push(e[t])}),o.join(n)}},default:function(t,r){if(void 0!==r&&r.length>1)throw new e.Error("default filter expects one argument");return null==t||""===t?void 0===r?"":r[0]:t},json_encode:function(r){if(null==r)return"null";if("object"===(0,n.default)(r)&&t("Array",r)){var o=[];return r.forEach(function(t){o.push(e.filters.json_encode(t))}),"["+o.join(",")+"]"}if("object"===(0,n.default)(r)&&t("Date",r))return'"'+r.toISOString()+'"';if("object"===(0,n.default)(r)){var i=r._keys||Object.keys(r),s=[];return i.forEach(function(t){s.push(JSON.stringify(t)+":"+e.filters.json_encode(r[t]))}),"{"+s.join(",")+"}"}return JSON.stringify(r)},merge:function(r,n){var o=[],i=0;if(t("Array",r)?n.forEach(function(e){t("Array",e)||(o={})}):o={},t("Array",o)||(o._keys=[]),t("Array",r)?r.forEach(function(e){o._keys&&o._keys.push(i),o[i]=e,i++}):(r._keys||Object.keys(r)).forEach(function(e){o[e]=r[e],o._keys.push(e);var t=parseInt(e,10);!isNaN(t)&&t>=i&&(i=t+1)}),n.forEach(function(e){t("Array",e)?e.forEach(function(e){o._keys&&o._keys.push(i),o[i]=e,i++}):(e._keys||Object.keys(e)).forEach(function(t){o[t]||o._keys.push(t),o[t]=e[t];var r=parseInt(t,10);!isNaN(r)&&r>=i&&(i=r+1)})}),0===n.length)throw new e.Error("Filter merge expects at least one parameter");return o},date:function(t,r){var n=e.functions.date(t),o=r&&Boolean(r.length)?r[0]:"F j, Y H:i";return e.lib.date(o.replace(/\\\\/g,"\\"),n)},date_modify:function(t,r){if(null!=t){if(void 0===r||1!==r.length)throw new e.Error("date_modify filter expects 1 argument");var n,o=r[0];return e.lib.is("Date",t)&&(n=e.lib.strtotime(o,t.getTime()/1e3)),e.lib.is("String",t)&&(n=e.lib.strtotime(o,e.lib.strtotime(t))),e.lib.is("Number",t)&&(n=e.lib.strtotime(o,t)),new Date(1e3*n)}},replace:function(t,r){if(null!=t){var n,o=r[0];for(n in o)Object.hasOwnProperty.call(o,n)&&"_keys"!==n&&(t=e.lib.replaceAll(t,n,o[n]));return t}},format:function(t,r){if(null!=t&&""!==t)return e.lib.vsprintf(t,r)},striptags:function(t,r){if(null!=t)return e.lib.stripTags(t,r)},escape:function(t,r){if(null!=t&&""!==t){var n="html";if(r&&Boolean(r.length)&&!0!==r[0]&&(n=r[0]),"html"===n){var o=t.toString().replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'");return new e.Markup(o,"html")}if("js"===n){for(var i=t.toString(),s="",a=0;a<i.length;a++)if(i[a].match(/^[a-zA-Z0-9,._]$/))s+=i[a];else{var p=i.charAt(a),c=i.charCodeAt(a),l={"\\":"\\\\","/":"\\/","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"};s+=l[p]?l[p]:e.lib.sprintf("\\u%04s",c.toString(16).toUpperCase())}return new e.Markup(s,"js")}if("css"===n){for(var u=t.toString(),h="",f=0;f<u.length;f++)u[f].match(/^[a-zA-Z0-9]$/)?h+=u[f]:h+="\\"+u.charCodeAt(f).toString(16).toUpperCase()+" ";return new e.Markup(h,"css")}if("url"===n){var d=e.filters.url_encode(t);return new e.Markup(d,"url")}if("html_attr"===n){for(var y=t.toString(),m="",g=0;g<y.length;g++)if(y[g].match(/^[a-zA-Z0-9,.\-_]$/))m+=y[g];else if(y[g].match(/^[&<>"]$/))m+=y[g].replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");else{var x=y.charCodeAt(g);m+=x<=31&&9!==x&&10!==x&&13!==x?"�":x<128?e.lib.sprintf("&#x%02s;",x.toString(16).toUpperCase()):e.lib.sprintf("&#x%04s;",x.toString(16).toUpperCase())}return new e.Markup(m,"html_attr")}throw new e.Error("escape strategy unsupported")}},e:function(t,r){return e.filters.escape(t,r)},nl2br:function(t){if(null!=t&&""!==t){var r="BACKSLASH_n_replace",n="<br />"+r;return t=e.filters.escape(t).replace(/\r\n/g,n).replace(/\r/g,n).replace(/\n/g,n),t=e.lib.replaceAll(t,r,"\n"),new e.Markup(t)}},number_format:function(e,t){var r=e,n=t&&t[0]?t[0]:void 0,o=t&&void 0!==t[1]?t[1]:".",i=t&&void 0!==t[2]?t[2]:",";r=String(r).replace(/[^0-9+\-Ee.]/g,"");var s=isFinite(Number(r))?Number(r):0,a=isFinite(Number(n))?Math.abs(n):0,p="";return p=(a?function(e,t){var r=Math.pow(10,t);return String(Math.round(e*r)/r)}(s,a):String(Math.round(s))).split("."),p[0].length>3&&(p[0]=p[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,i)),(p[1]||"").length<a&&(p[1]=p[1]||"",p[1]+=new Array(a-p[1].length+1).join("0")),p.join(o)},trim:function(e,t){if(null!=e){var r,n=String(e);r=t&&t[0]?String(t[0]):" \n\r\t\f\v \u2028\u2029 ";for(var o=0;o<n.length;o++)if(!r.includes(n.charAt(o))){n=n.slice(Math.max(0,o));break}for(var i=n.length-1;i>=0;i--)if(!r.includes(n.charAt(i))){n=n.slice(0,Math.max(0,i+1));break}return r.includes(n.charAt(0))?"":n}},truncate:function(e,t){var r=30,n=!1,o="...";if(e=String(e),t&&(t[0]&&(r=t[0]),t[1]&&(n=t[1]),t[2]&&(o=t[2])),e.length>r){if(n&&-1===(r=e.indexOf(" ",r)))return e;e=e.slice(0,r)+o}return e},slice:function(t,r){if(null!=t){if(void 0===r||0===r.length)throw new e.Error("slice filter expects at least 1 argument");var n=r[0]||0,o=r.length>1?r[1]:t.length,i=n>=0?n:Math.max(t.length+n,0);if(o<0&&(o=t.length-i+o),e.lib.is("Array",t)){for(var s=[],a=i;a<i+o&&a<t.length;a++)s.push(t[a]);return s}if(e.lib.is("String",t))return t.slice(i,i+o);throw new e.Error("slice filter expects value to be an array or string")