Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

formulon

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

formulon - npm Package Compare versions

Comparing version 6.24.3 to 6.25.0

2

lib/formulon.lwc.min.js

@@ -1,1 +0,1 @@

import e from"decimal.js";var t=function(){function e(t,r,n,a){var u=Error.call(this,t);return Object.setPrototypeOf&&Object.setPrototypeOf(u,e.prototype),u.expected=r,u.found=n,u.location=a,u.name="SyntaxError",u}function t(e,t,r){return r=r||" ",e.length>t?e:(t-=e.length,e+(r+=r.repeat(t)).slice(0,t))}return function(e,t){function r(){this.constructor=e}r.prototype=t.prototype,e.prototype=new r}(e,Error),e.prototype.format=function(e){var r="Error: "+this.message;if(this.location){var n,a=null;for(n=0;n<e.length;n++)if(e[n].source===this.location.source){a=e[n].text.split(/\r\n|\n|\r/g);break}var u=this.location.start,o=this.location.source&&"function"==typeof this.location.source.offset?this.location.source.offset(u):u,i=this.location.source+":"+o.line+":"+o.column;if(a){var l=this.location.end,s=t("",o.line.toString().length," "),c=a[u.line-1],p=(u.line===l.line?l.column:c.length+1)-u.column||1;r+="\n --\x3e "+i+"\n"+s+" |\n"+o.line+" | "+c+"\n"+s+" | "+t("",u.column-1," ")+t("",p,"^")}else r+="\n at "+i}return r},e.buildMessage=function(e,t){var r={literal:function(e){return'"'+a(e.text)+'"'},class:function(e){var t=e.parts.map((function(e){return Array.isArray(e)?u(e[0])+"-"+u(e[1]):u(e)}));return"["+(e.inverted?"^":"")+t.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(e){return e.description}};function n(e){return e.charCodeAt(0).toString(16).toUpperCase()}function a(e){return e.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(e){return"\\x0"+n(e)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(e){return"\\x"+n(e)}))}function u(e){return e.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(e){return"\\x0"+n(e)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(e){return"\\x"+n(e)}))}function o(e){return r[e.type](e)}return"Expected "+function(e){var t,r,n=e.map(o);if(n.sort(),n.length>0){for(t=1,r=1;t<n.length;t++)n[t-1]!==n[t]&&(n[r]=n[t],r++);n.length=r}switch(n.length){case 1:return n[0];case 2:return n[0]+" or "+n[1];default:return n.slice(0,-1).join(", ")+", or "+n[n.length-1]}}(e)+" but "+function(e){return e?'"'+a(e)+'"':"end of input"}(t)+" found."},{SyntaxError:e,parse:function(t,r){var n,a={},u=(r=void 0!==r?r:{}).grammarSource,o={start:ke},i=ke,l="(",s=")",c="+",p="-",d="<=",f=">=",v="<>",m="==",h="!=",y="&&",g="||",b=/^[A-Za-z]/,x=/^[0-9]/,T=/^[1-9]/,$=/^[\n\r\u2028\u2029]/,w=Te("(",!1),C=Te(")",!1),A=Te("^",!1),k=Te("*",!1),E=Te("/",!1),M=Te("+",!1),U=Te("-",!1),O=Te("<=",!1),F=Te(">=",!1),S=Te("<>",!1),j=Te("<",!1),D=Te(">",!1),N=Te("==",!1),I=Te("=",!1),q=Te("!=",!1),R=Te("&&",!1),W=Te("||",!1),P=Te("&",!1),Z=Te("!",!1),_=Te(",",!1),L=$e([["A","Z"],["a","z"]],!1,!1),Y=Te("_",!1),z=Te("$",!1),Q=Te("[",!1),X=Te(".",!1),B=Te("]",!1),H=Te("0",!1),V=$e([["0","9"]],!1,!1),G=$e([["1","9"]],!1,!1),K=Te("true",!0),J=Te("false",!0),ee=Te("null",!0),te=Te("\\",!1),re=Te("'",!1),ne=Te('"',!1),ae={type:"any"},ue=$e(["\n","\r","\u2028","\u2029"],!1,!1),oe=Te("\t",!1),ie=Te("\v",!1),le=Te("\f",!1),se=Te(" ",!1),ce=Te(" ",!1),pe=Te("​",!1),de=Te("\ufeff",!1),fe=function(e,t){return function(e){const t=[],r=[];e.forEach((e=>{if("operator"===e.type){for(;t.length>0&&!(t[t.length-1].precedence<e.precedence);){let e=t.pop(),n=r.pop(),a=r.pop();r.push(He(e,a,n))}t.push(e)}else r.push(e)}));for(;t.length>0;){let e=t.pop(),n=r.pop(),a=r.pop();r.push(He(e,a,n))}return r.pop()}([e,t].flat(2))},ve=0,me=0,he=[{line:1,column:1}],ye=0,ge=[],be=0;if("startRule"in r){if(!(r.startRule in o))throw new Error("Can't start parsing from rule \""+r.startRule+'".');i=o[r.startRule]}function xe(){return t.substring(me,ve)}function Te(e,t){return{type:"literal",text:e,ignoreCase:t}}function $e(e,t,r){return{type:"class",parts:e,inverted:t,ignoreCase:r}}function we(e){var r,n=he[e];if(n)return n;for(r=e-1;!he[r];)r--;for(n={line:(n=he[r]).line,column:n.column};r<e;)10===t.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return he[e]=n,n}function Ce(e,t,r){var n=we(e),a=we(t),o={source:u,start:{offset:e,line:n.line,column:n.column},end:{offset:t,line:a.line,column:a.column}};return r&&u&&"function"==typeof u.offset&&(o.start=u.offset(o.start),o.end=u.offset(o.end)),o}function Ae(e){ve<ye||(ve>ye&&(ye=ve,ge=[]),ge.push(e))}function ke(){return Ee()}function Ee(){var e;return(e=Se())===a&&(e=function(){var e,r,n;e=ve,r=function(){var e;33===t.charCodeAt(ve)?(e="!",ve++):(e=a,0===be&&Ae(Z));return e}(),r!==a?(ze(),(n=Ee())!==a?(me=e,e={type:"callExpression",id:"not",arguments:[n]}):(ve=e,e=a)):(ve=e,e=a);return e}())===a&&(e=Ue())===a&&(e=De())===a&&(e=qe()),e}function Me(){var e,r,n,u;return(e=Ue())===a&&(e=De())===a&&(e=qe())===a&&(e=ve,40===t.charCodeAt(ve)?(r="(",ve++):(r=a,0===be&&Ae(w)),r!==a?(ze(),(n=Oe())!==a?(ze(),41===t.charCodeAt(ve)?(u=")",ve++):(u=a,0===be&&Ae(C)),u!==a?(me=e,e=n):(ve=e,e=a)):(ve=e,e=a)):(ve=e,e=a),e===a&&(e=ve,40===t.charCodeAt(ve)?(r="(",ve++):(r=a,0===be&&Ae(w)),r!==a?(ze(),(n=Se())!==a?(ze(),41===t.charCodeAt(ve)?(u=")",ve++):(u=a,0===be&&Ae(C)),u!==a?(me=e,e=n):(ve=e,e=a)):(ve=e,e=a)):(ve=e,e=a))),e}function Ue(){var e,r,n,u;return e=ve,r=function(){var e,r,n;e=ve,r=[],b.test(t.charAt(ve))?(n=t.charAt(ve),ve++):(n=a,0===be&&Ae(L));if(n!==a)for(;n!==a;)r.push(n),b.test(t.charAt(ve))?(n=t.charAt(ve),ve++):(n=a,0===be&&Ae(L));else r=a;r!==a&&(me=e,r=r.join("").toLowerCase());return e=r}(),r!==a?(ze(),n=function(){var e,r,n,u;e=ve,40===t.charCodeAt(ve)?(r=l,ve++):(r=a,0===be&&Ae(w));r!==a?(ze(),n=ve,u=function(){var e,r,n,u;e=ve,r=[],n=ve,(u=Ee())!==a?(ze(),44===t.charCodeAt(ve)?ve++:0===be&&Ae(_),ze(),me=n,n=u):(ve=n,n=a);if(n!==a)for(;n!==a;)r.push(n),n=ve,(u=Ee())!==a?(ze(),44===t.charCodeAt(ve)?ve++:0===be&&Ae(_),ze(),me=n,n=u):(ve=n,n=a);else r=a;r!==a&&(me=e);return e=r}(),u!==a?n=u=[u,ze()]:(ve=n,n=a),n===a&&(n=null),41===t.charCodeAt(ve)?(u=s,ve++):(u=a,0===be&&Ae(C)),u!==a?(me=e,e=n):(ve=e,e=a)):(ve=e,e=a);return e}(),n!==a?(me=e,e={type:"callExpression",id:r,arguments:(u=n,null!==u?u[0]:[])}):(ve=e,e=a)):(ve=e,e=a),e}function Oe(){var e,t,r,n;if(e=ve,(t=Me())!==a){for(ze(),r=[],n=Fe();n!==a;)r.push(n),n=Fe();me=e,e=fe(t,r)}else ve=e,e=a;return e}function Fe(){var e,r,n,u,o;return e=ve,ze(),r=function(){var e;94===t.charCodeAt(ve)?(e="^",ve++):(e=a,0===be&&Ae(A));e===a&&(42===t.charCodeAt(ve)?(e="*",ve++):(e=a,0===be&&Ae(k)),e===a&&(47===t.charCodeAt(ve)?(e="/",ve++):(e=a,0===be&&Ae(E)),e===a&&(43===t.charCodeAt(ve)?(e=c,ve++):(e=a,0===be&&Ae(M)),e===a&&(45===t.charCodeAt(ve)?(e=p,ve++):(e=a,0===be&&Ae(U))))));return e}(),r!==a?(ze(),(n=Me())!==a?(me=e,u=r,o=n,e=[Object.assign({type:"operator"},Xe[u]),o]):(ve=e,e=a)):(ve=e,e=a),e}function Se(){var e,r,n,u;return e=ve,(r=je())!==a?(ze(),n=function(){var e;t.substr(ve,2)===y?(e=y,ve+=2):(e=a,0===be&&Ae(R));e===a&&(t.substr(ve,2)===g?(e=g,ve+=2):(e=a,0===be&&Ae(W)));return e}(),n!==a?(ze(),(u=Se())!==a?(me=e,e=function(e,t,r){var n;switch(t){case"||":n="or";break;case"&&":n="and"}return{type:"callExpression",id:n,arguments:[e,r]}}(r,n,u)):(ve=e,e=a)):(ve=e,e=a)):(ve=e,e=a),e===a&&(e=je()),e}function je(){var e,r,n,u;return e=ve,(r=Oe())!==a?(ze(),n=function(){var e;t.substr(ve,2)===d?(e=d,ve+=2):(e=a,0===be&&Ae(O));e===a&&(t.substr(ve,2)===f?(e=f,ve+=2):(e=a,0===be&&Ae(F)),e===a&&(t.substr(ve,2)===v?(e=v,ve+=2):(e=a,0===be&&Ae(S)),e===a&&(60===t.charCodeAt(ve)?(e="<",ve++):(e=a,0===be&&Ae(j)),e===a&&(62===t.charCodeAt(ve)?(e=">",ve++):(e=a,0===be&&Ae(D)),e===a&&(t.substr(ve,2)===m?(e=m,ve+=2):(e=a,0===be&&Ae(N)),e===a&&(61===t.charCodeAt(ve)?(e="=",ve++):(e=a,0===be&&Ae(I)),e===a&&(t.substr(ve,2)===h?(e=h,ve+=2):(e=a,0===be&&Ae(q)))))))));return e}(),n===a&&(n=function(){var e;38===t.charCodeAt(ve)?(e="&",ve++):(e=a,0===be&&Ae(P));return e}()),n!==a?(ze(),(u=je())!==a?(me=e,e=function(e,t,r){var n;switch(t){case"<":n="lessThan";break;case"<=":n="lessThanOrEqual";break;case">":n="greaterThan";break;case">=":n="greaterThanOrEqual";break;case"==":case"=":n="equal";break;case"!=":case"<>":n="unequal";break;case"&":n="add"}return{type:"callExpression",id:n,arguments:[e,r]}}(r,n,u)):(ve=e,e=a)):(ve=e,e=a)):(ve=e,e=a),e===a&&(e=Oe()),e}function De(){var e,t,r;return e=ve,t=ve,be++,r=function(){var e;(e=Pe())===a&&(e=Ze());return e}(),be--,r===a?t=void 0:(ve=t,t=a),t!==a?(r=function(){var e,t,r,n;if(e=ve,(t=Ne())!==a){for(r=[],n=Ie();n!==a;)r.push(n),n=Ie();me=e,e={type:"identifier",name:t+r.join("")}}else ve=e,e=a;return e}(),r!==a?(me=e,e=r):(ve=e,e=a)):(ve=e,e=a),e}function Ne(){var e;return 95===t.charCodeAt(ve)?(e="_",ve++):(e=a,0===be&&Ae(Y)),e===a&&(36===t.charCodeAt(ve)?(e="$",ve++):(e=a,0===be&&Ae(z)),e===a&&(91===t.charCodeAt(ve)?(e="[",ve++):(e=a,0===be&&Ae(Q)),e===a&&(b.test(t.charAt(ve))?(e=t.charAt(ve),ve++):(e=a,0===be&&Ae(L))))),e}function Ie(){var e;return(e=Ne())===a&&(46===t.charCodeAt(ve)?(e=".",ve++):(e=a,0===be&&Ae(X)),e===a&&(93===t.charCodeAt(ve)?(e="]",ve++):(e=a,0===be&&Ae(B)),e===a&&(e=We()))),e}function qe(){var e;return(e=function(){var e,t,r;if(e=ve,Le()!==a){for(t=[],(r=_e())===a&&(r=Ye());r!==a;)t.push(r),(r=_e())===a&&(r=Ye());(r=Le())!==a?(me=e,e=Be(t)):(ve=e,e=a)}else ve=e,e=a;if(e===a)if(e=ve,Ye()!==a){for(t=[],(r=_e())===a&&(r=Le());r!==a;)t.push(r),(r=_e())===a&&(r=Le());(r=Ye())!==a?(me=e,e=function(e){return Be(e)}(t)):(ve=e,e=a)}else ve=e,e=a;return e}())===a&&(e=function(){var e,r,n,u,o,i;e=ve,r=ve,n=ze(),43===t.charCodeAt(ve)?(u=c,ve++):(u=a,0===be&&Ae(M));u!==a?r=n=[n,u]:(ve=r,r=a);r===a&&(r=ve,45===t.charCodeAt(ve)?(n=p,ve++):(n=a,0===be&&Ae(U)),n!==a?r=n=[n,u=ze()]:(ve=r,r=a));r===a&&(r=null);if((n=Re())!==a)if(46===t.charCodeAt(ve)?(u=".",ve++):(u=a,0===be&&Ae(X)),u!==a){for(o=[],i=We();i!==a;)o.push(i),i=We();me=e,l=xe().replace(/[\+\-]/g,"").split("."),e={type:"literal",value:parseFloat(xe()),dataType:"number",options:{length:l[0].length,scale:l[1].length}}}else ve=e,e=a;else ve=e,e=a;var l;e===a&&(e=ve,r=ve,n=ze(),43===t.charCodeAt(ve)?(u=c,ve++):(u=a,0===be&&Ae(M)),u!==a?r=n=[n,u]:(ve=r,r=a),r===a&&(r=ve,45===t.charCodeAt(ve)?(n=p,ve++):(n=a,0===be&&Ae(U)),n!==a?r=n=[n,u=ze()]:(ve=r,r=a)),r===a&&(r=null),(n=Re())!==a?(me=e,e={type:"literal",value:parseInt(xe()),dataType:"number",options:{length:xe().replace(/[\+\-]/g,"").length,scale:0}}):(ve=e,e=a));return e}())===a&&(e=Pe())===a&&(e=Ze()),e}function Re(){var e,r,n,u;if(48===t.charCodeAt(ve)?(e="0",ve++):(e=a,0===be&&Ae(H)),e===a)if(e=ve,r=function(){var e;T.test(t.charAt(ve))?(e=t.charAt(ve),ve++):(e=a,0===be&&Ae(G));return e}(),r!==a){for(n=[],u=We();u!==a;)n.push(u),u=We();e=r=[r,n]}else ve=e,e=a;return e}function We(){var e;return x.test(t.charAt(ve))?(e=t.charAt(ve),ve++):(e=a,0===be&&Ae(V)),e}function Pe(){var e,r;return e=ve,"true"===t.substr(ve,4).toLowerCase()?(r=t.substr(ve,4),ve+=4):(r=a,0===be&&Ae(K)),r!==a&&(me=e,r={type:"literal",value:!0,dataType:"checkbox",options:{}}),(e=r)===a&&(e=ve,"false"===t.substr(ve,5).toLowerCase()?(r=t.substr(ve,5),ve+=5):(r=a,0===be&&Ae(J)),r!==a&&(me=e,r={type:"literal",value:!1,dataType:"checkbox",options:{}}),e=r),e}function Ze(){var e,r;return e=ve,"null"===t.substr(ve,4).toLowerCase()?(r=t.substr(ve,4),ve+=4):(r=a,0===be&&Ae(ee)),r!==a&&(me=e,r={type:"literal",value:null,dataType:"null",options:{}}),e=r}function _e(){var e,r,n;return e=ve,r=ve,be++,n=function(){var e;(e=Le())===a&&(e=Ye());return e}(),n===a&&(92===t.charCodeAt(ve)?(n="\\",ve++):(n=a,0===be&&Ae(te))),be--,n===a?r=void 0:(ve=r,r=a),r!==a?(n=function(){var e;t.length>ve?(e=t.charAt(ve),ve++):(e=a,0===be&&Ae(ae));return e}(),n!==a?(me=e,e=xe()):(ve=e,e=a)):(ve=e,e=a),e}function Le(){var e;return 39===t.charCodeAt(ve)?(e="'",ve++):(e=a,0===be&&Ae(re)),e}function Ye(){var e;return 34===t.charCodeAt(ve)?(e='"',ve++):(e=a,0===be&&Ae(ne)),e}function ze(){var e,t;for(e=[],t=Qe();t!==a;)e.push(t),t=Qe();return e}function Qe(){var e;return 9===t.charCodeAt(ve)?(e="\t",ve++):(e=a,0===be&&Ae(oe)),e===a&&(e=function(){var e;return $.test(t.charAt(ve))?(e=t.charAt(ve),ve++):(e=a,0===be&&Ae(ue)),e}())===a&&(11===t.charCodeAt(ve)?(e="\v",ve++):(e=a,0===be&&Ae(ie)),e===a&&(12===t.charCodeAt(ve)?(e="\f",ve++):(e=a,0===be&&Ae(le)),e===a&&(32===t.charCodeAt(ve)?(e=" ",ve++):(e=a,0===be&&Ae(se)),e===a&&(160===t.charCodeAt(ve)?(e=" ",ve++):(e=a,0===be&&Ae(ce)),e===a&&(8203===t.charCodeAt(ve)?(e="​",ve++):(e=a,0===be&&Ae(pe)),e===a&&(65279===t.charCodeAt(ve)?(e="\ufeff",ve++):(e=a,0===be&&Ae(de)))))))),e}const Xe={"^":{functionName:"exponentiate",rightAssociative:!0,precedence:4},"*":{functionName:"multiply",rightAssociative:!1,precedence:3},"/":{functionName:"divide",rightAssociative:!1,precedence:3},"+":{functionName:"add",rightAssociative:!1,precedence:2},"-":{functionName:"subtract",rightAssociative:!1,precedence:2}};function Be(e){return{type:"literal",value:e.join(""),dataType:"text",options:{length:e.length}}}function He(e,t,r){return{type:"callExpression",id:e.functionName,arguments:[t,r]}}if((n=i())!==a&&ve===t.length)return n;throw n!==a&&ve<t.length&&Ae({type:"end"}),Ve=ge,Ge=ye<t.length?t.charAt(ye):null,Ke=ye<t.length?Ce(ye,ye+1):Ce(ye,ye),new e(e.buildMessage(Ve,Ge),Ve,Ge,Ke);var Ve,Ge,Ke}}}(),r=function(){function e(t,r,n,a){var u=Error.call(this,t);return Object.setPrototypeOf&&Object.setPrototypeOf(u,e.prototype),u.expected=r,u.found=n,u.location=a,u.name="SyntaxError",u}function t(e,t,r){return r=r||" ",e.length>t?e:(t-=e.length,e+(r+=r.repeat(t)).slice(0,t))}return function(e,t){function r(){this.constructor=e}r.prototype=t.prototype,e.prototype=new r}(e,Error),e.prototype.format=function(e){var r="Error: "+this.message;if(this.location){var n,a=null;for(n=0;n<e.length;n++)if(e[n].source===this.location.source){a=e[n].text.split(/\r\n|\n|\r/g);break}var u=this.location.start,o=this.location.source&&"function"==typeof this.location.source.offset?this.location.source.offset(u):u,i=this.location.source+":"+o.line+":"+o.column;if(a){var l=this.location.end,s=t("",o.line.toString().length," "),c=a[u.line-1],p=(u.line===l.line?l.column:c.length+1)-u.column||1;r+="\n --\x3e "+i+"\n"+s+" |\n"+o.line+" | "+c+"\n"+s+" | "+t("",u.column-1," ")+t("",p,"^")}else r+="\n at "+i}return r},e.buildMessage=function(e,t){var r={literal:function(e){return'"'+a(e.text)+'"'},class:function(e){var t=e.parts.map((function(e){return Array.isArray(e)?u(e[0])+"-"+u(e[1]):u(e)}));return"["+(e.inverted?"^":"")+t.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(e){return e.description}};function n(e){return e.charCodeAt(0).toString(16).toUpperCase()}function a(e){return e.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(e){return"\\x0"+n(e)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(e){return"\\x"+n(e)}))}function u(e){return e.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(e){return"\\x0"+n(e)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(e){return"\\x"+n(e)}))}function o(e){return r[e.type](e)}return"Expected "+function(e){var t,r,n=e.map(o);if(n.sort(),n.length>0){for(t=1,r=1;t<n.length;t++)n[t-1]!==n[t]&&(n[r]=n[t],r++);n.length=r}switch(n.length){case 1:return n[0];case 2:return n[0]+" or "+n[1];default:return n.slice(0,-1).join(", ")+", or "+n[n.length-1]}}(e)+" but "+function(e){return e?'"'+a(e)+'"':"end of input"}(t)+" found."},{SyntaxError:e,parse:function(t,r){var n,a,u,o,i={},l=(r=void 0!==r?r:{}).grammarSource,s={Time:E},c=E,p=/^[0-9]/,d=w(":",!1),f=w(".",!1),v={type:"class",parts:[["0","9"]],inverted:!1,ignoreCase:!1},m=function(e,t,r,n){return function(e,t,r,n){e>23&&$("hour part needs to be under 24");t>59&&$("minute part needs to be under 60");r>59&&$("second part needs to be under 60");n>999&&$("millisecond part needs to be under 1000")}(e,t,r,n),{type:"literal",value:new Date(n+1e3*r+60*t*1e3+60*e*60*1e3),dataType:"time",options:{}}},h=0,y=0,g=[{line:1,column:1}],b=0,x=[];if("startRule"in r){if(!(r.startRule in s))throw new Error("Can't start parsing from rule \""+r.startRule+'".');c=s[r.startRule]}function T(){return t.substring(y,h)}function $(t,r){throw function(t,r){return new e(t,null,null,r)}(t,r=void 0!==r?r:A(y,h))}function w(e,t){return{type:"literal",text:e,ignoreCase:t}}function C(e){var r,n=g[e];if(n)return n;for(r=e-1;!g[r];)r--;for(n={line:(n=g[r]).line,column:n.column};r<e;)10===t.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return g[e]=n,n}function A(e,t,r){var n=C(e),a=C(t),u={source:l,start:{offset:e,line:n.line,column:n.column},end:{offset:t,line:a.line,column:a.column}};return r&&l&&"function"==typeof l.offset&&(u.start=l.offset(u.start),u.end=l.offset(u.end)),u}function k(e){h<b||(h>b&&(b=h,x=[]),x.push(e))}function E(){var e,r,n,a,u,o,l,s;return e=h,r=function(){var e;e=h,M()!==i&&M()!==i?(y=e,e=parseInt(T())):(h=e,e=i);return e}(),r!==i?(58===t.charCodeAt(h)?(n=":",h++):(n=i,k(d)),n!==i?(a=function(){var e;e=h,M()!==i&&M()!==i?(y=e,e=parseInt(T())):(h=e,e=i);return e}(),a!==i?(58===t.charCodeAt(h)?(u=":",h++):(u=i,k(d)),u!==i?(o=function(){var e;e=h,M()!==i&&M()!==i?(y=e,e=parseInt(T())):(h=e,e=i);return e}(),o!==i?(46===t.charCodeAt(h)?(l=".",h++):(l=i,k(f)),l!==i?(s=function(){var e;e=h,M()!==i&&M()!==i&&M()!==i?(y=e,e=parseInt(T())):(h=e,e=i);return e}(),s!==i?(y=e,e=m(r,a,o,s)):(h=e,e=i)):(h=e,e=i)):(h=e,e=i)):(h=e,e=i)):(h=e,e=i)):(h=e,e=i)):(h=e,e=i),e}function M(){var e;return p.test(t.charAt(h))?(e=t.charAt(h),h++):(e=i,k(v)),e}if((n=c())!==i&&h===t.length)return n;throw n!==i&&h<t.length&&k({type:"end"}),a=x,u=b<t.length?t.charAt(b):null,o=b<t.length?A(b,b+1):A(b,b),new e(e.buildMessage(a,u),a,u,o)}}}();class n extends Error{constructor(e,t,r){super(e),this.errorType=t,this.options=r}}const a=(e,t)=>{if(e<0)return-1*a(-1*e,t);const r=10**t;return Math.round(e*r)/r},u=e=>{const t=e.toString().replace("-","");if(-1!==t.indexOf(".")){const e=t.split(".");return{length:e[0].length,scale:e[1].length}}return{length:t.length,scale:0}},o=(e,t,r)=>{switch(e){case"number":return a(t,r.scale);case"text":return t.substring(0,r.length);default:return t}},i=e=>{const t={type:"literal",value:e};if(null==e)return Object.assign(t,{value:null,dataType:"null",options:{}});const r=typeof e;switch(typeof e){case"number":return Object.assign(t,{dataType:"number",options:u(e)});case"string":return Object.assign(t,{dataType:"text",options:{length:e.length}});case"boolean":return Object.assign(t,{dataType:"checkbox",options:{}});default:throw new TypeError(`Unsupported type '${r}'`)}},l=(e,t,r)=>({type:"error",errorType:e,message:t,...r}),s=(e,t,r)=>e instanceof Date?s(e.getUTCFullYear(),e.getUTCMonth()+1,e.getUTCDate()):{type:"literal",dataType:"date",value:new Date(Date.UTC(e,t-1,r)),options:{}},c=e=>({type:"literal",dataType:"datetime",value:new Date(e),options:{}}),p=e=>({type:"literal",dataType:"time",value:new Date(e),options:{}}),d=e=>{try{return e()}catch(e){if(e instanceof n)return l(e.errorType,e.message,e.options);throw e}},f=(e,t)=>new Date(e.getTime()+864e5*t),v=e=>{if(!e.value&&"null"!==e.dataType&&0!==e.value&&!1!==e.value&&""!==e.value)return"";switch(e.dataType){case"null":return"NULL";case"number":return e.value.toString();case"text":case"picklist":return`"${e.value}"`;case"multipicklist":return`[${e.value.map((e=>`"${e}"`)).join(", ")}]`;case"checkbox":return e.value.toString().toUpperCase();case"date":return`${e.value.getUTCFullYear()}-${(e.value.getUTCMonth()+1).toString().padStart(2,"0")}-${e.value.getUTCDate().toString().padStart(2,"0")}`;case"datetime":return e.value.toISOString();case"time":return e.value.toISOString().split("T")[1].replace("Z","");case"geolocation":return t=e.value[0],r=e.value[1],t&&r||0===t||0===r?`${t.toFixed(6)}, ${r.toFixed(6)}`:"";default:return}var t,r};class m extends n{constructor(e,t){super(e,"NotImplementedError",t)}static throwError(e){throw new m(`Function ${e} not implemented yet.`,{name:e})}}const h=e=>Array.isArray(e)?e.map((e=>h(e))).join(", "):"string"!=typeof e?"":e.charAt(0).toUpperCase()+e.slice(1);class y extends n{constructor(e,t){super(e,"ArgumentError",t)}static throwWrongType(e,t,r){const n={function:e,expected:t,received:r},a=r||"Non-Salesforce";throw new y(`Incorrect parameter type for function '${e.toUpperCase()}()'. Expected ${h(t)}, received ${h(a)}`,n)}static throwIncorrectNumberOfArguments(e,t,r){const n={function:e,expected:t,received:r};throw new y(`Incorrect number of parameters for function '${e.toUpperCase()}()'. Expected ${t}, received ${r}`,n)}}const g=(e,t)=>{switch(e.dataType){case"date":case"datetime":return i(e.value.getTime()===t.value.getTime());default:return i(e.value===t.value)}},b=(e,t,r)=>i(e.value.substr(t.value-1,r.value)),x=(e,t)=>b(e,i(1),t);var T=Object.freeze({__proto__:null,sf$or:(...e)=>{const t=e.map((e=>e.value)).reduce(((e,t)=>e||t));return i(t)},sf$equal:g,sf$unequal:(e,t)=>i(!g(e,t).value),sf$greaterThan:(e,t)=>i(e.value>t.value),sf$greaterThanOrEqual:(e,t)=>i(e.value>=t.value),sf$lessThan:(e,t)=>i(e.value<t.value),sf$lessThanOrEqual:(e,t)=>i(e.value<=t.value),sf$addmonths:(e,t)=>s(((e,t)=>{const r=e.getUTCMonth()+t,n=new Date(Date.UTC(e.getUTCFullYear(),r,e.getUTCDate()));return e.getUTCDate()!==n.getUTCDate()&&n.setUTCDate(0),n})(e.value,t.value)),sf$date:(e,t,r)=>s(e.value,t.value,r.value),sf$datevalue:e=>s(new Date(Date.parse(e.value))),sf$datetimevalue:e=>c(Date.parse(`${e.value}Z`)),sf$day:e=>i(e.value.getUTCDate()),sf$hour:e=>i(e.value.getUTCHours()),sf$millisecond:e=>i(e.value.getUTCMilliseconds()),sf$minute:e=>i(e.value.getUTCMinutes()),sf$month:e=>i(e.value.getUTCMonth()+1),sf$now:()=>c((new Date).getTime()),sf$second:e=>i(e.value.getUTCSeconds()),sf$timenow:()=>p((new Date).getTime()%864e5),sf$timevalue:e=>(e=>{try{return r.parse(e)}catch(e){if(e instanceof r.SyntaxError)return i(null);throw e}})(e.value),sf$today:()=>s(new Date),sf$weekday:e=>i(e.value.getUTCDay()+1),sf$year:e=>i(e.value.getUTCFullYear()),sf$and:(...e)=>{const t=e.map((e=>e.value)).reduce(((e,t)=>e&&t));return i(t)},sf$blankvalue:(e,t)=>"null"===e.dataType||""===e.value?t:e,sf$case:(e,...t)=>{const r=t.length-1;if(r<=0){const e={function:"case",expected:4,received:r+2};throw new y(`Incorrect number of parameters for function '${e.function.toUpperCase()}()'. Expected ${e.expected}+, received ${e.received}`,e)}if(r%2!=0){const e={function:"case",expected:r+1,received:r+2};throw new y(`Incorrect number of parameters for function '${e.function.toUpperCase()}()'. Expected ${e.expected}, received ${e.received}`,e)}for(let n=0;n<r;n+=2)if(g(t[n],e).value)return t[n+1];return t[r]},sf$if:(e,t,r)=>e.value?t:r,sf$isblank:e=>i("null"===e.dataType||""===e.value),sf$isnull:e=>{m.throwError("isnull")},sf$isnumber:e=>{m.throwError("isnumber")},sf$not:e=>i(!e.value),sf$nullvalue:(e,t)=>{m.throwError("nullvalue")},sf$add:(t,r)=>{switch([t.dataType,r.dataType].join(" ")){case"date number":return s(f(t.value,r.value));case"number date":return s(f(r.value,t.value));case"time number":return p(t.value.getTime()+r.value);case"number time":return p(t.value+r.value.getTime());case"datetime number":return c(f(t.value,r.value));case"number datetime":return c(f(r.value,t.value));case"number number":return i(new e(t.value).plus(new e(r.value)).toNumber());case"text text":return i(t.value+r.value);case"text null":return t;default:y.throwWrongType("add","number",r.dataType)}},sf$subtract:(t,r)=>{switch([t.dataType,r.dataType].join(" ")){case"date number":return s(f(t.value,-1*r.value));case"time number":return p(t.value.getTime()+-1*r.value);case"datetime number":return c(f(t.value,-1*r.value));case"date date":case"datetime datetime":return i((n=t.value,a=r.value,(n.getTime()-a.getTime())/864e5));case"time time":return i(t.value.getTime()-r.value.getTime());case"number number":return i(new e(t.value).minus(new e(r.value)).toNumber());case"text text":return i(t.value-r.value);default:y.throwWrongType("subtract","number",r.dataType)}var n,a},sf$multiply:(t,r)=>("number number"!==[t.dataType,r.dataType].join(" ")&&y.throwWrongType("multiply","number",r.dataType),i(new e(t.value).times(new e(r.value)).toNumber())),sf$divide:(t,r)=>("number number"!==[t.dataType,r.dataType].join(" ")&&y.throwWrongType("divide","number",r.dataType),i(new e(t.value).dividedBy(new e(r.value)).toNumber())),sf$exponentiate:(t,r)=>("number number"!==[t.dataType,r.dataType].join(" ")&&y.throwWrongType("exponentiate","number",r.dataType),i(new e(t.value).toPower(new e(r.value)).toNumber())),sf$abs:e=>i(Math.abs(e.value)),sf$ceiling:e=>e.value<0?i(-1*Math.ceil(-1*e.value)):i(Math.ceil(e.value)),sf$distance:(e,t,r)=>{const n=r.value;if("km"!==n&&"mi"!==n){throw new y(`Incorrect parameter value for function 'DISTANCE()'. Expected 'mi'/'km', received '${n}'`,{function:"distance",expected:["km","mi"],received:n})}const[a,u]=e.value,[o,l]=t.value;if(a===o&&u===l)return i(0);const s=a*Math.PI/180,c=o*Math.PI/180,p=(o-a)*Math.PI/180,d=(l-u)*Math.PI/180,f=Math.sin(p/2)*Math.sin(p/2)+Math.cos(s)*Math.cos(c)*Math.sin(d/2)*Math.sin(d/2),v=6371009*(2*Math.atan2(Math.sqrt(f),Math.sqrt(1-f)))/1e3;return i("mi"===n?v/1.609344:v)},sf$exp:e=>i(Math.exp(e.value)),sf$floor:e=>e.value<0?i(-1*Math.floor(-1*e.value)):i(Math.floor(e.value)),sf$geolocation:(e,t)=>((e,t)=>({type:"literal",dataType:"geolocation",value:[e,t],options:{}}))(e.value,t.value),sf$ln:e=>i(Math.log(e.value)),sf$log:e=>i(Math.log10(e.value)),sf$max:(...e)=>{const t=e.map((e=>e.value));return i(Math.max(...t))},sf$mceiling:e=>i(Math.ceil(e.value)),sf$mfloor:e=>i(Math.floor(e.value)),sf$min:(...e)=>{const t=e.map((e=>e.value));return i(Math.min(...t))},sf$mod:(e,t)=>i(e.value%t.value),sf$round:(e,t)=>i(a(e.value,t.value)),sf$sqrt:e=>i(Math.sqrt(e.value)),sf$begins:(e,t)=>i(e.value.startsWith(t.value)),sf$br:()=>i("\n"),sf$casesafeid:e=>{let t="";return[0,1,2].forEach((r=>{let n=0;[0,1,2,3,4].forEach((t=>{const a=e.value[5*r+t];a.toUpperCase()===a&&a>="A"&&a<="Z"&&(n+=1<<t)})),t+="ABCDEFGHIJKLMNOPQRSTUVWXYZ012345"[n]})),i(e.value+t)},sf$concat:(e,t)=>i(e.value+t.value),sf$contains:(e,t)=>i(e.value.includes(t.value)),sf$find:(e,t,r=i(1))=>{if(r.value<=0||""===e.value)return i(0);const n=t.value.substring(r.value-1);return i(n.indexOf(e.value)+1)},sf$getsessionid:()=>i("00D3z000001eRlg!AQMAQC3Y4aM9sFux6SRWhyFcOUKin4taGaBxNMU8TN_R_1R0Y7ArI95eSyzQZVIlrnV_unTbmwHZlXex8xhlXz2kXZNP49Fa"),sf$hyperlink:(e,t,r=null)=>{const n=r?` target="${r.value}"`:"";return i(`<a href="${e.value}"${n}>${t.value}</a>`)},sf$image:(e,t,r=null,n=null)=>{const a=r?` height="${r.value}"`:"",u=n?` width="${n.value}"`:"";return i(`<img src="${e.value}" alt="${t.value}"${a}${u}/>`)},sf$includes:(e,t)=>i(e.value.includes(t.value)),sf$ispickval:(e,t)=>i(e.value===t.value),sf$mid:b,sf$left:x,sf$len:e=>i(e.value.length),sf$lower:(e,t)=>i(e.value.toLowerCase()),sf$lpad:(e,t,r)=>{if(null==r)return e;if(t.value<e.value.length)return x(e,t);const n=r.value.repeat(t.value);return i((n+e.value).slice(-t.value))},sf$right:(e,t)=>i(e.value.substr(e.value.length-t.value)),sf$rpad:(e,t,r)=>{if(null==r)return e;if(t.value<e.value.length)return x(e,t);const n=r.value.repeat(t.value);return i((e.value+n).substr(0,t.value))},sf$substitute:(e,t,r)=>i(e.value.replace(new RegExp(t.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),r.value)),sf$text:e=>"datetime"===e.dataType?i(v(e).replace("T"," ").replace(/\.\d{3}/,"")):"picklist"===e.dataType?i(e.value):i(v(e)),sf$trim:e=>i(e.value.trim()),sf$upper:(e,t)=>i(e.value.toUpperCase()),sf$value:e=>{const t=parseFloat(e.value);return i(t||null)},sf$currencyrate:e=>{m.throwError("currencyrate")},sf$regex:(e,t)=>{const r=new RegExp(`^${t.value}$`);return i(null!=r.exec(e.value))}});const $=e=>t=>r=>{r.length<e&&y.throwIncorrectNumberOfArguments(t,e,r.length)},w=e=>t=>r=>{r.length>e&&y.throwIncorrectNumberOfArguments(t,e,r.length)},C=(...e)=>t=>r=>{r.map(((t,r)=>[t.dataType,e[r]||e[e.length-1]])).forEach((([e,r])=>{"null"!==e&&(Array.isArray(r)?-1===r.indexOf(e)&&y.throwWrongType(t,r,e):e!==r&&y.throwWrongType(t,r,e))}))},A=()=>e=>t=>{const r=t.filter((e=>"null"!==e.dataType));r.length>0&&r.reduce(((t,r)=>(t.dataType!==r.dataType&&y.throwWrongType(e,t.dataType,r.dataType),r)))};class k extends n{constructor(e,t){super(e,"NoFunctionError",t)}}const E={abs:{validations:[$(1),w(1),C("number")],returnType:"number"},add:{validations:[$(2),w(2),C(["number","text","date","datetime","time"],["number","text","date","datetime","time"])],returnType:["number","text","date","datetime","time"]},addmonths:{validations:[$(2),w(2),C(["date","datetime"],["number"])],returnType:["date","datetime"]},and:{validations:[$(1),C("checkbox")],returnType:"checkbox"},begins:{validations:[$(2),w(2),C("text","text")],returnType:"checkbox"},blankvalue:{validations:[$(2),w(2),C(["text","number","date","datetime","geolocation"]),A()],returnType:["text","number"]},br:{validations:[$(0),w(0)],returnType:"text"},case:{validations:[$(4),C(["text","number","picklist","date","datetime"]),e=>t=>{const r="picklist"===t[0].dataType?"text":t[0].dataType,n=t.filter(((e,r)=>r%2==1&&r!==t.length-1)).find((e=>e.dataType!==r));n&&y.throwWrongType(e,r,n.dataType)}],returnType:["text","number","date","datetime"]},casesafeid:{validations:[$(1),w(1),C("text")],returnType:"text"},ceiling:{validations:[$(1),w(1),C("number")],returnType:"number"},contains:{validations:[$(2),w(2),C("text","text")],returnType:"checkbox"},currencyrate:{validations:[$(1),w(1),C("text")],returnType:"text"},date:{validations:[$(3),w(3),C("number","number","number")],returnType:"date"},datetimevalue:{validations:[$(1),w(1),C("text","date","datetime")],returnType:"datetime"},datevalue:{validations:[$(1),w(1),C(["text","date","datetime"])],returnType:"date"},day:{validations:[$(1),w(1),C("date")],returnType:"number"},distance:{validations:[$(3),w(3),C("geolocation","geolocation","text")],returnType:"number"},divide:{validations:[$(2),w(2),C("number","number")],returnType:"number"},equal:{validations:[$(2),w(2),C(["text","number","date","datetime","checkbox"]),A()],returnType:"checkbox"},exp:{validations:[$(1),w(1),C("number")],returnType:"number"},exponentiate:{validations:[$(2),w(2),C("number","number")],returnType:"number"},find:{validations:[$(2),w(3),C("text","text","number")],returnType:"number"},floor:{validations:[$(1),w(1),C("number")],returnType:"number"},geolocation:{validations:[$(2),w(2),C("number","number")],returnType:"geolocation"},getsessionid:{validations:[$(0),w(0)],returnType:"text"},greaterThan:{validations:[$(2),w(2),C(["number","date","datetime"]),A()],returnType:"checkbox"},greaterThanOrEqual:{validations:[$(2),w(2),C(["number","date","datetime"])],returnType:"checkbox"},hour:{validations:[$(1),w(1),C("datetime")],returnType:"number"},hyperlink:{validations:[$(2),w(3),C("text","text","text")],returnType:"text"},if:{validations:[$(3),w(3),C("checkbox",["text","number","date","datetime","checkbox","geolocation"],["text","number","date","datetime","checkbox","geolocation"])],returnType:["text","number","date","datetime","checkbox","geolocation"]},image:{validations:[$(2),w(4),C("text","text","number","number")],returnType:"text"},includes:{validations:[$(2),w(2),C("multipicklist","text")],returnType:"checkbox"},isblank:{validations:[$(1),w(1),C(["text","number","date","datetime","geolocation"])],returnType:"checkbox"},isnull:{validations:[$(1),w(1),C(["text","number"])],returnType:"checkbox"},ispickval:{validations:[$(2),w(2),C("picklist","text")],returnType:"checkbox"},isnumber:{validations:[$(1),w(1),C("text")],returnType:"checkbox"},left:{validations:[$(2),w(2),C("text","number")],returnType:"text"},len:{validations:[$(1),w(1),C("text")],returnType:"number"},lessThan:{validations:[$(2),w(2),C(["number","date","datetime"]),A()],returnType:"checkbox"},lessThanOrEqual:{validations:[$(2),w(2),C(["number","date","datetime"]),A()],returnType:"checkbox"},ln:{validations:[$(1),w(1),C("number")],returnType:"number"},log:{validations:[$(1),w(1),C("number")],returnType:"checkbox"},lower:{validations:[$(1),w(1),C("text")],returnType:"text"},lpad:{validations:[$(2),w(3),C("text","number","text")],returnType:"text"},max:{validations:[$(1),C("number")],returnType:"number"},mceiling:{validations:[$(1),w(1),C("number")],returnType:"number"},mfloor:{validations:[$(1),w(1),C("number")],returnType:"number"},mid:{validations:[$(3),w(3),C("text","number","number")],returnType:"number"},millisecond:{validations:[$(1),w(1),C("datetime")],returnType:"number"},min:{validations:[$(1),C("number")],returnType:"number"},minute:{validations:[$(1),w(1),C("datetime")],returnType:"number"},mod:{validations:[$(2),w(2),C("number","number")],returnType:"number"},month:{validations:[$(1),w(1),C("date")],returnType:"number"},multiply:{validations:[$(2),w(2),C("number","number")],returnType:"number"},not:{validations:[$(1),w(1),C("checkbox")],returnType:"checkbox"},now:{validations:[$(0),w(0)],returnType:"datetime"},nullvalue:{validations:[$(2),w(2),C(["text","number"],["text","number"])],returnType:["text","number"]},or:{validations:[$(1),C("checkbox")],returnType:"checkbox"},regex:{validations:[$(2),w(2),C("text","text")],returnType:"text"},right:{validations:[$(2),w(2),C("text","number")],returnType:"text"},round:{validations:[$(2),w(2),C("number","number")],returnType:"number"},rpad:{validations:[$(2),w(3),C("text","number","text")],returnType:"text"},second:{validations:[$(1),w(1),C("datetime")],returnType:"number"},sqrt:{validations:[$(1),w(1),C("number")],returnType:"number"},subtract:{validations:[$(2),w(2),C(["number","date","datetime","time"],["number","date","datetime","time"])],returnType:["number","date","datetime","time"]},substitute:{validations:[$(3),w(3),C("text","text","text")],returnType:"text"},text:{validations:[$(1),w(1),C(["number","date","datetime","picklist","time"])],returnType:"text"},timenow:{validations:[$(0),w(0)],returnType:"time"},timevalue:{validations:[$(1),w(1),C("text")],returnType:"time"},today:{validations:[$(0),w(0)],returnType:"date"},trim:{validations:[$(1),w(1),C("text")],returnType:"text"},unequal:{validations:[$(2),w(2),C(["text","number","date","datetime","checkbox"]),A()],returnType:"checkbox"},upper:{validations:[$(1),w(1),C("text")],returnType:"text"},value:{validations:[$(1),w(1),C("text")],returnType:"number"},weekday:{validations:[$(1),w(1),C("date")],returnType:"number"},year:{validations:[$(1),w(1),C("date")],returnType:"number"}};class M extends n{constructor(e,t){super(e,"ReferenceError",t)}}const U=e=>{switch(e.type){case"callExpression":return t=e.id,r=e.arguments.map((e=>U(e))),d((()=>{const e=r.find((e=>"error"===e.type));if(e)return e;const n=E[t];if(n)return n.validations.forEach((e=>e(t)(r))),T[`sf$${t}`](...r);throw new k(`Unknown function ${t.toUpperCase()}. Check spelling.`,{function:t})}));case"identifier":throw new M(`Field ${e.name} does not exist. Check spelling.`,{identifier:e.name});default:return e}var t,r},O=e=>{try{return t.parse(null==e?"":e.trim())}catch(e){if(e instanceof t.SyntaxError)return l("SyntaxError","Syntax error.",{});throw e}},F=(e,t=[])=>{switch(e.type){case"callExpression":return e.arguments.map((e=>F(e,t))).reduce(((e,t)=>e.concat(t)),[]);case"identifier":return t.concat(e.name);default:return t}},S=(e,t)=>"callExpression"===e.type?{type:"callExpression",id:e.id,arguments:e.arguments.map((e=>S(e,t)))}:"identifier"===e.type&&t[e.name]?{...t[e.name],type:"literal"}:e,j=(e,t={})=>{if(null==e||""===e.trim())return i("");const r=O(e),n=Object.keys(t).reduce(((e,r)=>{return{...e,[r]:(n=t[r],void 0===n.value||null===n.value||Number.isNaN(n.value)?{type:"literal",value:null,dataType:"null",options:{}}:{...n,value:o(n.dataType,n.value,n.options)})};var n}),{});return(e=>d((()=>U(e))))(S(r,n))},D=e=>{if(null==e||""===e.trim())return[];const t=O(e);return F(t).reduce(((e,t)=>(e.indexOf(t)<0&&e.push(t),e)),[])},N=e=>null==e||""===e.trim()?{}:O(e),I=e=>v(e);export{N as ast,D as extract,j as parse,I as toString};
import e from"decimal.js";var t=function(){function e(t,r,n,a){var u=Error.call(this,t);return Object.setPrototypeOf&&Object.setPrototypeOf(u,e.prototype),u.expected=r,u.found=n,u.location=a,u.name="SyntaxError",u}function t(e,t,r){return r=r||" ",e.length>t?e:(t-=e.length,e+(r+=r.repeat(t)).slice(0,t))}return function(e,t){function r(){this.constructor=e}r.prototype=t.prototype,e.prototype=new r}(e,Error),e.prototype.format=function(e){var r="Error: "+this.message;if(this.location){var n,a=null;for(n=0;n<e.length;n++)if(e[n].source===this.location.source){a=e[n].text.split(/\r\n|\n|\r/g);break}var u=this.location.start,o=this.location.source&&"function"==typeof this.location.source.offset?this.location.source.offset(u):u,i=this.location.source+":"+o.line+":"+o.column;if(a){var l=this.location.end,s=t("",o.line.toString().length," "),c=a[u.line-1],p=(u.line===l.line?l.column:c.length+1)-u.column||1;r+="\n --\x3e "+i+"\n"+s+" |\n"+o.line+" | "+c+"\n"+s+" | "+t("",u.column-1," ")+t("",p,"^")}else r+="\n at "+i}return r},e.buildMessage=function(e,t){var r={literal:function(e){return'"'+a(e.text)+'"'},class:function(e){var t=e.parts.map((function(e){return Array.isArray(e)?u(e[0])+"-"+u(e[1]):u(e)}));return"["+(e.inverted?"^":"")+t.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(e){return e.description}};function n(e){return e.charCodeAt(0).toString(16).toUpperCase()}function a(e){return e.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(e){return"\\x0"+n(e)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(e){return"\\x"+n(e)}))}function u(e){return e.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(e){return"\\x0"+n(e)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(e){return"\\x"+n(e)}))}function o(e){return r[e.type](e)}return"Expected "+function(e){var t,r,n=e.map(o);if(n.sort(),n.length>0){for(t=1,r=1;t<n.length;t++)n[t-1]!==n[t]&&(n[r]=n[t],r++);n.length=r}switch(n.length){case 1:return n[0];case 2:return n[0]+" or "+n[1];default:return n.slice(0,-1).join(", ")+", or "+n[n.length-1]}}(e)+" but "+function(e){return e?'"'+a(e)+'"':"end of input"}(t)+" found."},{SyntaxError:e,parse:function(t,r){var n,a={},u=(r=void 0!==r?r:{}).grammarSource,o={start:ke},i=ke,l="(",s=")",c="+",p="-",d="<=",f=">=",v="<>",m="==",h="!=",y="&&",g="||",b=/^[A-Za-z]/,x=/^[0-9]/,T=/^[1-9]/,$=/^[\n\r\u2028\u2029]/,w=Te("(",!1),C=Te(")",!1),A=Te("^",!1),k=Te("*",!1),E=Te("/",!1),M=Te("+",!1),U=Te("-",!1),O=Te("<=",!1),F=Te(">=",!1),S=Te("<>",!1),j=Te("<",!1),D=Te(">",!1),N=Te("==",!1),I=Te("=",!1),q=Te("!=",!1),R=Te("&&",!1),W=Te("||",!1),P=Te("&",!1),Z=Te("!",!1),_=Te(",",!1),L=$e([["A","Z"],["a","z"]],!1,!1),Y=Te("_",!1),z=Te("$",!1),Q=Te("[",!1),X=Te(".",!1),B=Te("]",!1),H=Te("0",!1),V=$e([["0","9"]],!1,!1),G=$e([["1","9"]],!1,!1),K=Te("true",!0),J=Te("false",!0),ee=Te("null",!0),te=Te("\\",!1),re=Te("'",!1),ne=Te('"',!1),ae={type:"any"},ue=$e(["\n","\r","\u2028","\u2029"],!1,!1),oe=Te("\t",!1),ie=Te("\v",!1),le=Te("\f",!1),se=Te(" ",!1),ce=Te(" ",!1),pe=Te("​",!1),de=Te("\ufeff",!1),fe=function(e,t){return function(e){const t=[],r=[];e.forEach((e=>{if("operator"===e.type){for(;t.length>0&&!(t[t.length-1].precedence<e.precedence);){let e=t.pop(),n=r.pop(),a=r.pop();r.push(He(e,a,n))}t.push(e)}else r.push(e)}));for(;t.length>0;){let e=t.pop(),n=r.pop(),a=r.pop();r.push(He(e,a,n))}return r.pop()}([e,t].flat(2))},ve=0,me=0,he=[{line:1,column:1}],ye=0,ge=[],be=0;if("startRule"in r){if(!(r.startRule in o))throw new Error("Can't start parsing from rule \""+r.startRule+'".');i=o[r.startRule]}function xe(){return t.substring(me,ve)}function Te(e,t){return{type:"literal",text:e,ignoreCase:t}}function $e(e,t,r){return{type:"class",parts:e,inverted:t,ignoreCase:r}}function we(e){var r,n=he[e];if(n)return n;for(r=e-1;!he[r];)r--;for(n={line:(n=he[r]).line,column:n.column};r<e;)10===t.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return he[e]=n,n}function Ce(e,t,r){var n=we(e),a=we(t),o={source:u,start:{offset:e,line:n.line,column:n.column},end:{offset:t,line:a.line,column:a.column}};return r&&u&&"function"==typeof u.offset&&(o.start=u.offset(o.start),o.end=u.offset(o.end)),o}function Ae(e){ve<ye||(ve>ye&&(ye=ve,ge=[]),ge.push(e))}function ke(){return Ee()}function Ee(){var e;return(e=Se())===a&&(e=function(){var e,r,n;e=ve,r=function(){var e;33===t.charCodeAt(ve)?(e="!",ve++):(e=a,0===be&&Ae(Z));return e}(),r!==a?(ze(),(n=Ee())!==a?(me=e,e={type:"callExpression",id:"not",arguments:[n]}):(ve=e,e=a)):(ve=e,e=a);return e}())===a&&(e=Ue())===a&&(e=De())===a&&(e=qe()),e}function Me(){var e,r,n,u;return(e=Ue())===a&&(e=De())===a&&(e=qe())===a&&(e=ve,40===t.charCodeAt(ve)?(r="(",ve++):(r=a,0===be&&Ae(w)),r!==a?(ze(),(n=Oe())!==a?(ze(),41===t.charCodeAt(ve)?(u=")",ve++):(u=a,0===be&&Ae(C)),u!==a?(me=e,e=n):(ve=e,e=a)):(ve=e,e=a)):(ve=e,e=a),e===a&&(e=ve,40===t.charCodeAt(ve)?(r="(",ve++):(r=a,0===be&&Ae(w)),r!==a?(ze(),(n=Se())!==a?(ze(),41===t.charCodeAt(ve)?(u=")",ve++):(u=a,0===be&&Ae(C)),u!==a?(me=e,e=n):(ve=e,e=a)):(ve=e,e=a)):(ve=e,e=a))),e}function Ue(){var e,r,n,u;return e=ve,r=function(){var e,r,n;e=ve,r=[],b.test(t.charAt(ve))?(n=t.charAt(ve),ve++):(n=a,0===be&&Ae(L));if(n!==a)for(;n!==a;)r.push(n),b.test(t.charAt(ve))?(n=t.charAt(ve),ve++):(n=a,0===be&&Ae(L));else r=a;r!==a&&(me=e,r=r.join("").toLowerCase());return e=r}(),r!==a?(ze(),n=function(){var e,r,n,u;e=ve,40===t.charCodeAt(ve)?(r=l,ve++):(r=a,0===be&&Ae(w));r!==a?(ze(),n=ve,u=function(){var e,r,n,u;e=ve,r=[],n=ve,(u=Ee())!==a?(ze(),44===t.charCodeAt(ve)?ve++:0===be&&Ae(_),ze(),me=n,n=u):(ve=n,n=a);if(n!==a)for(;n!==a;)r.push(n),n=ve,(u=Ee())!==a?(ze(),44===t.charCodeAt(ve)?ve++:0===be&&Ae(_),ze(),me=n,n=u):(ve=n,n=a);else r=a;r!==a&&(me=e);return e=r}(),u!==a?n=u=[u,ze()]:(ve=n,n=a),n===a&&(n=null),41===t.charCodeAt(ve)?(u=s,ve++):(u=a,0===be&&Ae(C)),u!==a?(me=e,e=n):(ve=e,e=a)):(ve=e,e=a);return e}(),n!==a?(me=e,e={type:"callExpression",id:r,arguments:(u=n,null!==u?u[0]:[])}):(ve=e,e=a)):(ve=e,e=a),e}function Oe(){var e,t,r,n;if(e=ve,(t=Me())!==a){for(ze(),r=[],n=Fe();n!==a;)r.push(n),n=Fe();me=e,e=fe(t,r)}else ve=e,e=a;return e}function Fe(){var e,r,n,u,o;return e=ve,ze(),r=function(){var e;94===t.charCodeAt(ve)?(e="^",ve++):(e=a,0===be&&Ae(A));e===a&&(42===t.charCodeAt(ve)?(e="*",ve++):(e=a,0===be&&Ae(k)),e===a&&(47===t.charCodeAt(ve)?(e="/",ve++):(e=a,0===be&&Ae(E)),e===a&&(43===t.charCodeAt(ve)?(e=c,ve++):(e=a,0===be&&Ae(M)),e===a&&(45===t.charCodeAt(ve)?(e=p,ve++):(e=a,0===be&&Ae(U))))));return e}(),r!==a?(ze(),(n=Me())!==a?(me=e,u=r,o=n,e=[Object.assign({type:"operator"},Xe[u]),o]):(ve=e,e=a)):(ve=e,e=a),e}function Se(){var e,r,n,u;return e=ve,(r=je())!==a?(ze(),n=function(){var e;t.substr(ve,2)===y?(e=y,ve+=2):(e=a,0===be&&Ae(R));e===a&&(t.substr(ve,2)===g?(e=g,ve+=2):(e=a,0===be&&Ae(W)));return e}(),n!==a?(ze(),(u=Se())!==a?(me=e,e=function(e,t,r){var n;switch(t){case"||":n="or";break;case"&&":n="and"}return{type:"callExpression",id:n,arguments:[e,r]}}(r,n,u)):(ve=e,e=a)):(ve=e,e=a)):(ve=e,e=a),e===a&&(e=je()),e}function je(){var e,r,n,u;return e=ve,(r=Oe())!==a?(ze(),n=function(){var e;t.substr(ve,2)===d?(e=d,ve+=2):(e=a,0===be&&Ae(O));e===a&&(t.substr(ve,2)===f?(e=f,ve+=2):(e=a,0===be&&Ae(F)),e===a&&(t.substr(ve,2)===v?(e=v,ve+=2):(e=a,0===be&&Ae(S)),e===a&&(60===t.charCodeAt(ve)?(e="<",ve++):(e=a,0===be&&Ae(j)),e===a&&(62===t.charCodeAt(ve)?(e=">",ve++):(e=a,0===be&&Ae(D)),e===a&&(t.substr(ve,2)===m?(e=m,ve+=2):(e=a,0===be&&Ae(N)),e===a&&(61===t.charCodeAt(ve)?(e="=",ve++):(e=a,0===be&&Ae(I)),e===a&&(t.substr(ve,2)===h?(e=h,ve+=2):(e=a,0===be&&Ae(q)))))))));return e}(),n===a&&(n=function(){var e;38===t.charCodeAt(ve)?(e="&",ve++):(e=a,0===be&&Ae(P));return e}()),n!==a?(ze(),(u=je())!==a?(me=e,e=function(e,t,r){var n;switch(t){case"<":n="lessThan";break;case"<=":n="lessThanOrEqual";break;case">":n="greaterThan";break;case">=":n="greaterThanOrEqual";break;case"==":case"=":n="equal";break;case"!=":case"<>":n="unequal";break;case"&":n="add"}return{type:"callExpression",id:n,arguments:[e,r]}}(r,n,u)):(ve=e,e=a)):(ve=e,e=a)):(ve=e,e=a),e===a&&(e=Oe()),e}function De(){var e,t,r;return e=ve,t=ve,be++,r=function(){var e;(e=Pe())===a&&(e=Ze());return e}(),be--,r===a?t=void 0:(ve=t,t=a),t!==a?(r=function(){var e,t,r,n;if(e=ve,(t=Ne())!==a){for(r=[],n=Ie();n!==a;)r.push(n),n=Ie();me=e,e={type:"identifier",name:t+r.join("")}}else ve=e,e=a;return e}(),r!==a?(me=e,e=r):(ve=e,e=a)):(ve=e,e=a),e}function Ne(){var e;return 95===t.charCodeAt(ve)?(e="_",ve++):(e=a,0===be&&Ae(Y)),e===a&&(36===t.charCodeAt(ve)?(e="$",ve++):(e=a,0===be&&Ae(z)),e===a&&(91===t.charCodeAt(ve)?(e="[",ve++):(e=a,0===be&&Ae(Q)),e===a&&(b.test(t.charAt(ve))?(e=t.charAt(ve),ve++):(e=a,0===be&&Ae(L))))),e}function Ie(){var e;return(e=Ne())===a&&(46===t.charCodeAt(ve)?(e=".",ve++):(e=a,0===be&&Ae(X)),e===a&&(93===t.charCodeAt(ve)?(e="]",ve++):(e=a,0===be&&Ae(B)),e===a&&(e=We()))),e}function qe(){var e;return(e=function(){var e,t,r;if(e=ve,Le()!==a){for(t=[],(r=_e())===a&&(r=Ye());r!==a;)t.push(r),(r=_e())===a&&(r=Ye());(r=Le())!==a?(me=e,e=Be(t)):(ve=e,e=a)}else ve=e,e=a;if(e===a)if(e=ve,Ye()!==a){for(t=[],(r=_e())===a&&(r=Le());r!==a;)t.push(r),(r=_e())===a&&(r=Le());(r=Ye())!==a?(me=e,e=function(e){return Be(e)}(t)):(ve=e,e=a)}else ve=e,e=a;return e}())===a&&(e=function(){var e,r,n,u,o,i;e=ve,r=ve,n=ze(),43===t.charCodeAt(ve)?(u=c,ve++):(u=a,0===be&&Ae(M));u!==a?r=n=[n,u]:(ve=r,r=a);r===a&&(r=ve,45===t.charCodeAt(ve)?(n=p,ve++):(n=a,0===be&&Ae(U)),n!==a?r=n=[n,u=ze()]:(ve=r,r=a));r===a&&(r=null);if((n=Re())!==a)if(46===t.charCodeAt(ve)?(u=".",ve++):(u=a,0===be&&Ae(X)),u!==a){for(o=[],i=We();i!==a;)o.push(i),i=We();me=e,l=xe().replace(/[\+\-]/g,"").split("."),e={type:"literal",value:parseFloat(xe()),dataType:"number",options:{length:l[0].length,scale:l[1].length}}}else ve=e,e=a;else ve=e,e=a;var l;e===a&&(e=ve,r=ve,n=ze(),43===t.charCodeAt(ve)?(u=c,ve++):(u=a,0===be&&Ae(M)),u!==a?r=n=[n,u]:(ve=r,r=a),r===a&&(r=ve,45===t.charCodeAt(ve)?(n=p,ve++):(n=a,0===be&&Ae(U)),n!==a?r=n=[n,u=ze()]:(ve=r,r=a)),r===a&&(r=null),(n=Re())!==a?(me=e,e={type:"literal",value:parseInt(xe()),dataType:"number",options:{length:xe().replace(/[\+\-]/g,"").length,scale:0}}):(ve=e,e=a));return e}())===a&&(e=Pe())===a&&(e=Ze()),e}function Re(){var e,r,n,u;if(48===t.charCodeAt(ve)?(e="0",ve++):(e=a,0===be&&Ae(H)),e===a)if(e=ve,r=function(){var e;T.test(t.charAt(ve))?(e=t.charAt(ve),ve++):(e=a,0===be&&Ae(G));return e}(),r!==a){for(n=[],u=We();u!==a;)n.push(u),u=We();e=r=[r,n]}else ve=e,e=a;return e}function We(){var e;return x.test(t.charAt(ve))?(e=t.charAt(ve),ve++):(e=a,0===be&&Ae(V)),e}function Pe(){var e,r;return e=ve,"true"===t.substr(ve,4).toLowerCase()?(r=t.substr(ve,4),ve+=4):(r=a,0===be&&Ae(K)),r!==a&&(me=e,r={type:"literal",value:!0,dataType:"checkbox",options:{}}),(e=r)===a&&(e=ve,"false"===t.substr(ve,5).toLowerCase()?(r=t.substr(ve,5),ve+=5):(r=a,0===be&&Ae(J)),r!==a&&(me=e,r={type:"literal",value:!1,dataType:"checkbox",options:{}}),e=r),e}function Ze(){var e,r;return e=ve,"null"===t.substr(ve,4).toLowerCase()?(r=t.substr(ve,4),ve+=4):(r=a,0===be&&Ae(ee)),r!==a&&(me=e,r={type:"literal",value:null,dataType:"null",options:{}}),e=r}function _e(){var e,r,n;return e=ve,r=ve,be++,n=function(){var e;(e=Le())===a&&(e=Ye());return e}(),n===a&&(92===t.charCodeAt(ve)?(n="\\",ve++):(n=a,0===be&&Ae(te))),be--,n===a?r=void 0:(ve=r,r=a),r!==a?(n=function(){var e;t.length>ve?(e=t.charAt(ve),ve++):(e=a,0===be&&Ae(ae));return e}(),n!==a?(me=e,e=xe()):(ve=e,e=a)):(ve=e,e=a),e}function Le(){var e;return 39===t.charCodeAt(ve)?(e="'",ve++):(e=a,0===be&&Ae(re)),e}function Ye(){var e;return 34===t.charCodeAt(ve)?(e='"',ve++):(e=a,0===be&&Ae(ne)),e}function ze(){var e,t;for(e=[],t=Qe();t!==a;)e.push(t),t=Qe();return e}function Qe(){var e;return 9===t.charCodeAt(ve)?(e="\t",ve++):(e=a,0===be&&Ae(oe)),e===a&&(e=function(){var e;return $.test(t.charAt(ve))?(e=t.charAt(ve),ve++):(e=a,0===be&&Ae(ue)),e}())===a&&(11===t.charCodeAt(ve)?(e="\v",ve++):(e=a,0===be&&Ae(ie)),e===a&&(12===t.charCodeAt(ve)?(e="\f",ve++):(e=a,0===be&&Ae(le)),e===a&&(32===t.charCodeAt(ve)?(e=" ",ve++):(e=a,0===be&&Ae(se)),e===a&&(160===t.charCodeAt(ve)?(e=" ",ve++):(e=a,0===be&&Ae(ce)),e===a&&(8203===t.charCodeAt(ve)?(e="​",ve++):(e=a,0===be&&Ae(pe)),e===a&&(65279===t.charCodeAt(ve)?(e="\ufeff",ve++):(e=a,0===be&&Ae(de)))))))),e}const Xe={"^":{functionName:"exponentiate",rightAssociative:!0,precedence:4},"*":{functionName:"multiply",rightAssociative:!1,precedence:3},"/":{functionName:"divide",rightAssociative:!1,precedence:3},"+":{functionName:"add",rightAssociative:!1,precedence:2},"-":{functionName:"subtract",rightAssociative:!1,precedence:2}};function Be(e){return{type:"literal",value:e.join(""),dataType:"text",options:{length:e.length}}}function He(e,t,r){return{type:"callExpression",id:e.functionName,arguments:[t,r]}}if((n=i())!==a&&ve===t.length)return n;throw n!==a&&ve<t.length&&Ae({type:"end"}),Ve=ge,Ge=ye<t.length?t.charAt(ye):null,Ke=ye<t.length?Ce(ye,ye+1):Ce(ye,ye),new e(e.buildMessage(Ve,Ge),Ve,Ge,Ke);var Ve,Ge,Ke}}}(),r=function(){function e(t,r,n,a){var u=Error.call(this,t);return Object.setPrototypeOf&&Object.setPrototypeOf(u,e.prototype),u.expected=r,u.found=n,u.location=a,u.name="SyntaxError",u}function t(e,t,r){return r=r||" ",e.length>t?e:(t-=e.length,e+(r+=r.repeat(t)).slice(0,t))}return function(e,t){function r(){this.constructor=e}r.prototype=t.prototype,e.prototype=new r}(e,Error),e.prototype.format=function(e){var r="Error: "+this.message;if(this.location){var n,a=null;for(n=0;n<e.length;n++)if(e[n].source===this.location.source){a=e[n].text.split(/\r\n|\n|\r/g);break}var u=this.location.start,o=this.location.source&&"function"==typeof this.location.source.offset?this.location.source.offset(u):u,i=this.location.source+":"+o.line+":"+o.column;if(a){var l=this.location.end,s=t("",o.line.toString().length," "),c=a[u.line-1],p=(u.line===l.line?l.column:c.length+1)-u.column||1;r+="\n --\x3e "+i+"\n"+s+" |\n"+o.line+" | "+c+"\n"+s+" | "+t("",u.column-1," ")+t("",p,"^")}else r+="\n at "+i}return r},e.buildMessage=function(e,t){var r={literal:function(e){return'"'+a(e.text)+'"'},class:function(e){var t=e.parts.map((function(e){return Array.isArray(e)?u(e[0])+"-"+u(e[1]):u(e)}));return"["+(e.inverted?"^":"")+t.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(e){return e.description}};function n(e){return e.charCodeAt(0).toString(16).toUpperCase()}function a(e){return e.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(e){return"\\x0"+n(e)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(e){return"\\x"+n(e)}))}function u(e){return e.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(e){return"\\x0"+n(e)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(e){return"\\x"+n(e)}))}function o(e){return r[e.type](e)}return"Expected "+function(e){var t,r,n=e.map(o);if(n.sort(),n.length>0){for(t=1,r=1;t<n.length;t++)n[t-1]!==n[t]&&(n[r]=n[t],r++);n.length=r}switch(n.length){case 1:return n[0];case 2:return n[0]+" or "+n[1];default:return n.slice(0,-1).join(", ")+", or "+n[n.length-1]}}(e)+" but "+function(e){return e?'"'+a(e)+'"':"end of input"}(t)+" found."},{SyntaxError:e,parse:function(t,r){var n,a,u,o,i={},l=(r=void 0!==r?r:{}).grammarSource,s={Time:E},c=E,p=/^[0-9]/,d=w(":",!1),f=w(".",!1),v={type:"class",parts:[["0","9"]],inverted:!1,ignoreCase:!1},m=function(e,t,r,n){return function(e,t,r,n){e>23&&$("hour part needs to be under 24");t>59&&$("minute part needs to be under 60");r>59&&$("second part needs to be under 60");n>999&&$("millisecond part needs to be under 1000")}(e,t,r,n),{type:"literal",value:new Date(n+1e3*r+60*t*1e3+60*e*60*1e3),dataType:"time",options:{}}},h=0,y=0,g=[{line:1,column:1}],b=0,x=[];if("startRule"in r){if(!(r.startRule in s))throw new Error("Can't start parsing from rule \""+r.startRule+'".');c=s[r.startRule]}function T(){return t.substring(y,h)}function $(t,r){throw function(t,r){return new e(t,null,null,r)}(t,r=void 0!==r?r:A(y,h))}function w(e,t){return{type:"literal",text:e,ignoreCase:t}}function C(e){var r,n=g[e];if(n)return n;for(r=e-1;!g[r];)r--;for(n={line:(n=g[r]).line,column:n.column};r<e;)10===t.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return g[e]=n,n}function A(e,t,r){var n=C(e),a=C(t),u={source:l,start:{offset:e,line:n.line,column:n.column},end:{offset:t,line:a.line,column:a.column}};return r&&l&&"function"==typeof l.offset&&(u.start=l.offset(u.start),u.end=l.offset(u.end)),u}function k(e){h<b||(h>b&&(b=h,x=[]),x.push(e))}function E(){var e,r,n,a,u,o,l,s;return e=h,r=function(){var e;e=h,M()!==i&&M()!==i?(y=e,e=parseInt(T())):(h=e,e=i);return e}(),r!==i?(58===t.charCodeAt(h)?(n=":",h++):(n=i,k(d)),n!==i?(a=function(){var e;e=h,M()!==i&&M()!==i?(y=e,e=parseInt(T())):(h=e,e=i);return e}(),a!==i?(58===t.charCodeAt(h)?(u=":",h++):(u=i,k(d)),u!==i?(o=function(){var e;e=h,M()!==i&&M()!==i?(y=e,e=parseInt(T())):(h=e,e=i);return e}(),o!==i?(46===t.charCodeAt(h)?(l=".",h++):(l=i,k(f)),l!==i?(s=function(){var e;e=h,M()!==i&&M()!==i&&M()!==i?(y=e,e=parseInt(T())):(h=e,e=i);return e}(),s!==i?(y=e,e=m(r,a,o,s)):(h=e,e=i)):(h=e,e=i)):(h=e,e=i)):(h=e,e=i)):(h=e,e=i)):(h=e,e=i)):(h=e,e=i),e}function M(){var e;return p.test(t.charAt(h))?(e=t.charAt(h),h++):(e=i,k(v)),e}if((n=c())!==i&&h===t.length)return n;throw n!==i&&h<t.length&&k({type:"end"}),a=x,u=b<t.length?t.charAt(b):null,o=b<t.length?A(b,b+1):A(b,b),new e(e.buildMessage(a,u),a,u,o)}}}();class n extends Error{constructor(e,t,r){super(e),this.errorType=t,this.options=r}}const a=(e,t)=>{if(e<0)return-1*a(-1*e,t);const r=10**t;return Math.round(e*r)/r},u=e=>{const t=e.toString().replace("-","");if(-1!==t.indexOf(".")){const e=t.split(".");return{length:e[0].length,scale:e[1].length}}return{length:t.length,scale:0}},o=(e,t,r)=>{switch(e){case"number":return a(t,r.scale);case"text":return t.substring(0,r.length);default:return t}},i=e=>{const t={type:"literal",value:e};if(null==e)return Object.assign(t,{value:null,dataType:"null",options:{}});const r=typeof e;switch(typeof e){case"number":return Object.assign(t,{dataType:"number",options:u(e)});case"string":return Object.assign(t,{dataType:"text",options:{length:e.length}});case"boolean":return Object.assign(t,{dataType:"checkbox",options:{}});default:throw new TypeError(`Unsupported type '${r}'`)}},l=(e,t,r)=>({type:"error",errorType:e,message:t,...r}),s=(e,t,r)=>e instanceof Date?s(e.getUTCFullYear(),e.getUTCMonth()+1,e.getUTCDate()):{type:"literal",dataType:"date",value:new Date(Date.UTC(e,t-1,r)),options:{}},c=e=>({type:"literal",dataType:"datetime",value:new Date(e),options:{}}),p=e=>({type:"literal",dataType:"time",value:new Date(e),options:{}}),d=e=>{try{return e()}catch(e){if(e instanceof n)return l(e.errorType,e.message,e.options);throw e}},f=(e,t)=>new Date(e.getTime()+864e5*t),v=e=>{if(!e.value&&"null"!==e.dataType&&0!==e.value&&!1!==e.value&&""!==e.value)return"";switch(e.dataType){case"null":return"NULL";case"number":return e.value.toString();case"text":case"picklist":return`"${e.value}"`;case"multipicklist":return`[${e.value.map((e=>`"${e}"`)).join(", ")}]`;case"checkbox":return e.value.toString().toUpperCase();case"date":return`${e.value.getUTCFullYear()}-${(e.value.getUTCMonth()+1).toString().padStart(2,"0")}-${e.value.getUTCDate().toString().padStart(2,"0")}`;case"datetime":return e.value.toISOString();case"time":return e.value.toISOString().split("T")[1].replace("Z","");case"geolocation":return t=e.value[0],r=e.value[1],t&&r||0===t||0===r?`${t.toFixed(6)}, ${r.toFixed(6)}`:"";default:return}var t,r};class m extends n{constructor(e,t){super(e,"NotImplementedError",t)}static throwError(e){throw new m(`Function ${e} not implemented yet.`,{name:e})}}const h=e=>Array.isArray(e)?e.map((e=>h(e))).join(", "):"string"!=typeof e?"":e.charAt(0).toUpperCase()+e.slice(1);class y extends n{constructor(e,t){super(e,"ArgumentError",t)}static throwWrongType(e,t,r){const n={function:e,expected:t,received:r},a=r||"Non-Salesforce";throw new y(`Incorrect parameter type for function '${e.toUpperCase()}()'. Expected ${h(t)}, received ${h(a)}`,n)}static throwIncorrectNumberOfArguments(e,t,r){const n={function:e,expected:t,received:r};throw new y(`Incorrect number of parameters for function '${e.toUpperCase()}()'. Expected ${t}, received ${r}`,n)}}const g=(e,t)=>{switch(e.dataType){case"date":case"datetime":return i(e.value.getTime()===t.value.getTime());default:return i(e.value===t.value)}},b=(e,t,r)=>i(e.value.substr(t.value-1,r.value)),x=(e,t)=>b(e,i(1),t);var T=Object.freeze({__proto__:null,sf$or:(...e)=>{const t=e.map((e=>e.value)).reduce(((e,t)=>e||t));return i(t)},sf$equal:g,sf$unequal:(e,t)=>i(!g(e,t).value),sf$greaterThan:(e,t)=>i(e.value>t.value),sf$greaterThanOrEqual:(e,t)=>i(e.value>=t.value),sf$lessThan:(e,t)=>i(e.value<t.value),sf$lessThanOrEqual:(e,t)=>i(e.value<=t.value),sf$addmonths:(e,t)=>s(((e,t)=>{const r=e.getUTCMonth()+t,n=new Date(Date.UTC(e.getUTCFullYear(),r,e.getUTCDate()));return e.getUTCDate()!==n.getUTCDate()&&n.setUTCDate(0),n})(e.value,t.value)),sf$date:(e,t,r)=>s(e.value,t.value,r.value),sf$datevalue:e=>s(new Date(Date.parse(e.value))),sf$datetimevalue:e=>c(Date.parse(`${e.value}Z`)),sf$day:e=>i(e.value.getUTCDate()),sf$hour:e=>i(e.value.getUTCHours()),sf$millisecond:e=>i(e.value.getUTCMilliseconds()),sf$minute:e=>i(e.value.getUTCMinutes()),sf$month:e=>i(e.value.getUTCMonth()+1),sf$now:()=>c((new Date).getTime()),sf$second:e=>i(e.value.getUTCSeconds()),sf$timenow:()=>p((new Date).getTime()%864e5),sf$timevalue:e=>(e=>{try{return r.parse(e)}catch(e){if(e instanceof r.SyntaxError)return i(null);throw e}})(e.value),sf$today:()=>s(new Date),sf$weekday:e=>i(e.value.getUTCDay()+1),sf$year:e=>i(e.value.getUTCFullYear()),sf$and:(...e)=>{const t=e.map((e=>e.value)).reduce(((e,t)=>e&&t));return i(t)},sf$blankvalue:(e,t)=>"null"===e.dataType||""===e.value?t:e,sf$case:(e,...t)=>{const r=t.length-1;if(r<=0){const e={function:"case",expected:4,received:r+2};throw new y(`Incorrect number of parameters for function '${e.function.toUpperCase()}()'. Expected ${e.expected}+, received ${e.received}`,e)}if(r%2!=0){const e={function:"case",expected:r+1,received:r+2};throw new y(`Incorrect number of parameters for function '${e.function.toUpperCase()}()'. Expected ${e.expected}, received ${e.received}`,e)}for(let n=0;n<r;n+=2)if(g(t[n],e).value)return t[n+1];return t[r]},sf$if:(e,t,r)=>e.value?t:r,sf$isblank:e=>i("null"===e.dataType||""===e.value),sf$isnull:e=>i("null"===e.dataType),sf$isnumber:e=>{m.throwError("isnumber")},sf$not:e=>i(!e.value),sf$nullvalue:(e,t)=>"null"===e.dataType?t:e,sf$add:(t,r)=>{switch([t.dataType,r.dataType].join(" ")){case"date number":return s(f(t.value,r.value));case"number date":return s(f(r.value,t.value));case"time number":return p(t.value.getTime()+r.value);case"number time":return p(t.value+r.value.getTime());case"datetime number":return c(f(t.value,r.value));case"number datetime":return c(f(r.value,t.value));case"number number":return i(new e(t.value).plus(new e(r.value)).toNumber());case"text text":return i(t.value+r.value);case"text null":return t;default:y.throwWrongType("add","number",r.dataType)}},sf$subtract:(t,r)=>{switch([t.dataType,r.dataType].join(" ")){case"date number":return s(f(t.value,-1*r.value));case"time number":return p(t.value.getTime()+-1*r.value);case"datetime number":return c(f(t.value,-1*r.value));case"date date":case"datetime datetime":return i((n=t.value,a=r.value,(n.getTime()-a.getTime())/864e5));case"time time":return i(t.value.getTime()-r.value.getTime());case"number number":return i(new e(t.value).minus(new e(r.value)).toNumber());case"text text":return i(t.value-r.value);default:y.throwWrongType("subtract","number",r.dataType)}var n,a},sf$multiply:(t,r)=>("number number"!==[t.dataType,r.dataType].join(" ")&&y.throwWrongType("multiply","number",r.dataType),i(new e(t.value).times(new e(r.value)).toNumber())),sf$divide:(t,r)=>("number number"!==[t.dataType,r.dataType].join(" ")&&y.throwWrongType("divide","number",r.dataType),i(new e(t.value).dividedBy(new e(r.value)).toNumber())),sf$exponentiate:(t,r)=>("number number"!==[t.dataType,r.dataType].join(" ")&&y.throwWrongType("exponentiate","number",r.dataType),i(new e(t.value).toPower(new e(r.value)).toNumber())),sf$abs:e=>i(Math.abs(e.value)),sf$ceiling:e=>e.value<0?i(-1*Math.ceil(-1*e.value)):i(Math.ceil(e.value)),sf$distance:(e,t,r)=>{const n=r.value;if("km"!==n&&"mi"!==n){throw new y(`Incorrect parameter value for function 'DISTANCE()'. Expected 'mi'/'km', received '${n}'`,{function:"distance",expected:["km","mi"],received:n})}const[a,u]=e.value,[o,l]=t.value;if(a===o&&u===l)return i(0);const s=a*Math.PI/180,c=o*Math.PI/180,p=(o-a)*Math.PI/180,d=(l-u)*Math.PI/180,f=Math.sin(p/2)*Math.sin(p/2)+Math.cos(s)*Math.cos(c)*Math.sin(d/2)*Math.sin(d/2),v=6371009*(2*Math.atan2(Math.sqrt(f),Math.sqrt(1-f)))/1e3;return i("mi"===n?v/1.609344:v)},sf$exp:e=>i(Math.exp(e.value)),sf$floor:e=>e.value<0?i(-1*Math.floor(-1*e.value)):i(Math.floor(e.value)),sf$geolocation:(e,t)=>((e,t)=>({type:"literal",dataType:"geolocation",value:[e,t],options:{}}))(e.value,t.value),sf$ln:e=>i(Math.log(e.value)),sf$log:e=>i(Math.log10(e.value)),sf$max:(...e)=>{const t=e.map((e=>e.value));return i(Math.max(...t))},sf$mceiling:e=>i(Math.ceil(e.value)),sf$mfloor:e=>i(Math.floor(e.value)),sf$min:(...e)=>{const t=e.map((e=>e.value));return i(Math.min(...t))},sf$mod:(e,t)=>i(e.value%t.value),sf$round:(e,t)=>i(a(e.value,t.value)),sf$sqrt:e=>i(Math.sqrt(e.value)),sf$begins:(e,t)=>i(e.value.startsWith(t.value)),sf$br:()=>i("\n"),sf$casesafeid:e=>{let t="";return[0,1,2].forEach((r=>{let n=0;[0,1,2,3,4].forEach((t=>{const a=e.value[5*r+t];a.toUpperCase()===a&&a>="A"&&a<="Z"&&(n+=1<<t)})),t+="ABCDEFGHIJKLMNOPQRSTUVWXYZ012345"[n]})),i(e.value+t)},sf$concat:(e,t)=>i(e.value+t.value),sf$contains:(e,t)=>i(e.value.includes(t.value)),sf$find:(e,t,r=i(1))=>{if(r.value<=0||""===e.value)return i(0);const n=t.value.substring(r.value-1);return i(n.indexOf(e.value)+1)},sf$getsessionid:()=>i("00D3z000001eRlg!AQMAQC3Y4aM9sFux6SRWhyFcOUKin4taGaBxNMU8TN_R_1R0Y7ArI95eSyzQZVIlrnV_unTbmwHZlXex8xhlXz2kXZNP49Fa"),sf$hyperlink:(e,t,r=null)=>{const n=r?` target="${r.value}"`:"";return i(`<a href="${e.value}"${n}>${t.value}</a>`)},sf$image:(e,t,r=null,n=null)=>{const a=r?` height="${r.value}"`:"",u=n?` width="${n.value}"`:"";return i(`<img src="${e.value}" alt="${t.value}"${a}${u}/>`)},sf$includes:(e,t)=>i(e.value.includes(t.value)),sf$ispickval:(e,t)=>i(e.value===t.value),sf$mid:b,sf$left:x,sf$len:e=>i(e.value.length),sf$lower:(e,t)=>i(e.value.toLowerCase()),sf$lpad:(e,t,r)=>{if(null==r)return e;if(t.value<e.value.length)return x(e,t);const n=r.value.repeat(t.value);return i((n+e.value).slice(-t.value))},sf$right:(e,t)=>i(e.value.substr(e.value.length-t.value)),sf$rpad:(e,t,r)=>{if(null==r)return e;if(t.value<e.value.length)return x(e,t);const n=r.value.repeat(t.value);return i((e.value+n).substr(0,t.value))},sf$substitute:(e,t,r)=>i(e.value.replace(new RegExp(t.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),r.value)),sf$text:e=>"datetime"===e.dataType?i(v(e).replace("T"," ").replace(/\.\d{3}/,"")):"picklist"===e.dataType?i(e.value):i(v(e)),sf$trim:e=>i(e.value.trim()),sf$upper:(e,t)=>i(e.value.toUpperCase()),sf$value:e=>{const t=parseFloat(e.value);return i(t||null)},sf$currencyrate:e=>{m.throwError("currencyrate")},sf$regex:(e,t)=>{const r=new RegExp(`^${t.value}$`);return i(null!=r.exec(e.value))}});const $=e=>t=>r=>{r.length<e&&y.throwIncorrectNumberOfArguments(t,e,r.length)},w=e=>t=>r=>{r.length>e&&y.throwIncorrectNumberOfArguments(t,e,r.length)},C=(...e)=>t=>r=>{r.map(((t,r)=>[t.dataType,e[r]||e[e.length-1]])).forEach((([e,r])=>{"null"!==e&&(Array.isArray(r)?-1===r.indexOf(e)&&y.throwWrongType(t,r,e):e!==r&&y.throwWrongType(t,r,e))}))},A=()=>e=>t=>{const r=t.filter((e=>"null"!==e.dataType));r.length>0&&r.reduce(((t,r)=>(t.dataType!==r.dataType&&y.throwWrongType(e,t.dataType,r.dataType),r)))};class k extends n{constructor(e,t){super(e,"NoFunctionError",t)}}const E={abs:{validations:[$(1),w(1),C("number")],returnType:"number"},add:{validations:[$(2),w(2),C(["number","text","date","datetime","time"],["number","text","date","datetime","time"])],returnType:["number","text","date","datetime","time"]},addmonths:{validations:[$(2),w(2),C(["date","datetime"],["number"])],returnType:["date","datetime"]},and:{validations:[$(1),C("checkbox")],returnType:"checkbox"},begins:{validations:[$(2),w(2),C("text","text")],returnType:"checkbox"},blankvalue:{validations:[$(2),w(2),C(["text","number","date","datetime","geolocation"]),A()],returnType:["text","number"]},br:{validations:[$(0),w(0)],returnType:"text"},case:{validations:[$(4),C(["text","number","picklist","date","datetime"]),e=>t=>{const r="picklist"===t[0].dataType?"text":t[0].dataType,n=t.filter(((e,r)=>r%2==1&&r!==t.length-1)).find((e=>e.dataType!==r));n&&y.throwWrongType(e,r,n.dataType)}],returnType:["text","number","date","datetime"]},casesafeid:{validations:[$(1),w(1),C("text")],returnType:"text"},ceiling:{validations:[$(1),w(1),C("number")],returnType:"number"},contains:{validations:[$(2),w(2),C("text","text")],returnType:"checkbox"},currencyrate:{validations:[$(1),w(1),C("text")],returnType:"text"},date:{validations:[$(3),w(3),C("number","number","number")],returnType:"date"},datetimevalue:{validations:[$(1),w(1),C("text","date","datetime")],returnType:"datetime"},datevalue:{validations:[$(1),w(1),C(["text","date","datetime"])],returnType:"date"},day:{validations:[$(1),w(1),C("date")],returnType:"number"},distance:{validations:[$(3),w(3),C("geolocation","geolocation","text")],returnType:"number"},divide:{validations:[$(2),w(2),C("number","number")],returnType:"number"},equal:{validations:[$(2),w(2),C(["text","number","date","datetime","checkbox"]),A()],returnType:"checkbox"},exp:{validations:[$(1),w(1),C("number")],returnType:"number"},exponentiate:{validations:[$(2),w(2),C("number","number")],returnType:"number"},find:{validations:[$(2),w(3),C("text","text","number")],returnType:"number"},floor:{validations:[$(1),w(1),C("number")],returnType:"number"},geolocation:{validations:[$(2),w(2),C("number","number")],returnType:"geolocation"},getsessionid:{validations:[$(0),w(0)],returnType:"text"},greaterThan:{validations:[$(2),w(2),C(["number","date","datetime"]),A()],returnType:"checkbox"},greaterThanOrEqual:{validations:[$(2),w(2),C(["number","date","datetime"])],returnType:"checkbox"},hour:{validations:[$(1),w(1),C("datetime")],returnType:"number"},hyperlink:{validations:[$(2),w(3),C("text","text","text")],returnType:"text"},if:{validations:[$(3),w(3),C("checkbox",["text","number","date","datetime","checkbox","geolocation"],["text","number","date","datetime","checkbox","geolocation"])],returnType:["text","number","date","datetime","checkbox","geolocation"]},image:{validations:[$(2),w(4),C("text","text","number","number")],returnType:"text"},includes:{validations:[$(2),w(2),C("multipicklist","text")],returnType:"checkbox"},isblank:{validations:[$(1),w(1),C(["text","number","date","datetime","geolocation"])],returnType:"checkbox"},isnull:{validations:[$(1),w(1),C(["text","number","date","datetime","geolocation"])],returnType:"checkbox"},ispickval:{validations:[$(2),w(2),C("picklist","text")],returnType:"checkbox"},isnumber:{validations:[$(1),w(1),C("text")],returnType:"checkbox"},left:{validations:[$(2),w(2),C("text","number")],returnType:"text"},len:{validations:[$(1),w(1),C("text")],returnType:"number"},lessThan:{validations:[$(2),w(2),C(["number","date","datetime"]),A()],returnType:"checkbox"},lessThanOrEqual:{validations:[$(2),w(2),C(["number","date","datetime"]),A()],returnType:"checkbox"},ln:{validations:[$(1),w(1),C("number")],returnType:"number"},log:{validations:[$(1),w(1),C("number")],returnType:"checkbox"},lower:{validations:[$(1),w(1),C("text")],returnType:"text"},lpad:{validations:[$(2),w(3),C("text","number","text")],returnType:"text"},max:{validations:[$(1),C("number")],returnType:"number"},mceiling:{validations:[$(1),w(1),C("number")],returnType:"number"},mfloor:{validations:[$(1),w(1),C("number")],returnType:"number"},mid:{validations:[$(3),w(3),C("text","number","number")],returnType:"number"},millisecond:{validations:[$(1),w(1),C("datetime")],returnType:"number"},min:{validations:[$(1),C("number")],returnType:"number"},minute:{validations:[$(1),w(1),C("datetime")],returnType:"number"},mod:{validations:[$(2),w(2),C("number","number")],returnType:"number"},month:{validations:[$(1),w(1),C("date")],returnType:"number"},multiply:{validations:[$(2),w(2),C("number","number")],returnType:"number"},not:{validations:[$(1),w(1),C("checkbox")],returnType:"checkbox"},now:{validations:[$(0),w(0)],returnType:"datetime"},nullvalue:{validations:[$(2),w(2),C(["text","number","date","datetime","geolocation"]),A()],returnType:["text","number"]},or:{validations:[$(1),C("checkbox")],returnType:"checkbox"},regex:{validations:[$(2),w(2),C("text","text")],returnType:"text"},right:{validations:[$(2),w(2),C("text","number")],returnType:"text"},round:{validations:[$(2),w(2),C("number","number")],returnType:"number"},rpad:{validations:[$(2),w(3),C("text","number","text")],returnType:"text"},second:{validations:[$(1),w(1),C("datetime")],returnType:"number"},sqrt:{validations:[$(1),w(1),C("number")],returnType:"number"},subtract:{validations:[$(2),w(2),C(["number","date","datetime","time"],["number","date","datetime","time"])],returnType:["number","date","datetime","time"]},substitute:{validations:[$(3),w(3),C("text","text","text")],returnType:"text"},text:{validations:[$(1),w(1),C(["number","date","datetime","picklist","time"])],returnType:"text"},timenow:{validations:[$(0),w(0)],returnType:"time"},timevalue:{validations:[$(1),w(1),C("text")],returnType:"time"},today:{validations:[$(0),w(0)],returnType:"date"},trim:{validations:[$(1),w(1),C("text")],returnType:"text"},unequal:{validations:[$(2),w(2),C(["text","number","date","datetime","checkbox"]),A()],returnType:"checkbox"},upper:{validations:[$(1),w(1),C("text")],returnType:"text"},value:{validations:[$(1),w(1),C("text")],returnType:"number"},weekday:{validations:[$(1),w(1),C("date")],returnType:"number"},year:{validations:[$(1),w(1),C("date")],returnType:"number"}};class M extends n{constructor(e,t){super(e,"ReferenceError",t)}}const U=e=>{switch(e.type){case"callExpression":return t=e.id,r=e.arguments.map((e=>U(e))),d((()=>{const e=r.find((e=>"error"===e.type));if(e)return e;const n=E[t];if(n)return n.validations.forEach((e=>e(t)(r))),T[`sf$${t}`](...r);throw new k(`Unknown function ${t.toUpperCase()}. Check spelling.`,{function:t})}));case"identifier":throw new M(`Field ${e.name} does not exist. Check spelling.`,{identifier:e.name});default:return e}var t,r},O=e=>{try{return t.parse(null==e?"":e.trim())}catch(e){if(e instanceof t.SyntaxError)return l("SyntaxError","Syntax error.",{});throw e}},F=(e,t=[])=>{switch(e.type){case"callExpression":return e.arguments.map((e=>F(e,t))).reduce(((e,t)=>e.concat(t)),[]);case"identifier":return t.concat(e.name);default:return t}},S=(e,t)=>"callExpression"===e.type?{type:"callExpression",id:e.id,arguments:e.arguments.map((e=>S(e,t)))}:"identifier"===e.type&&t[e.name]?{...t[e.name],type:"literal"}:e,j=(e,t={})=>{if(null==e||""===e.trim())return i("");const r=O(e),n=Object.keys(t).reduce(((e,r)=>{return{...e,[r]:(n=t[r],void 0===n.value||null===n.value||Number.isNaN(n.value)?{type:"literal",value:null,dataType:"null",options:{}}:{...n,value:o(n.dataType,n.value,n.options)})};var n}),{});return(e=>d((()=>U(e))))(S(r,n))},D=e=>{if(null==e||""===e.trim())return[];const t=O(e);return F(t).reduce(((e,t)=>(e.indexOf(t)<0&&e.push(t),e)),[])},N=e=>null==e||""===e.trim()?{}:O(e),I=e=>v(e);export{N as ast,D as extract,j as parse,I as toString};

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("decimal.js")):"function"==typeof define&&define.amd?define(["exports","decimal.js"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).formulon={},e.Decimal)}(this,(function(e,t){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=r(t),a=function(){function e(t,r,n,a){var u=Error.call(this,t);return Object.setPrototypeOf&&Object.setPrototypeOf(u,e.prototype),u.expected=r,u.found=n,u.location=a,u.name="SyntaxError",u}function t(e,t,r){return r=r||" ",e.length>t?e:(t-=e.length,e+(r+=r.repeat(t)).slice(0,t))}return function(e,t){function r(){this.constructor=e}r.prototype=t.prototype,e.prototype=new r}(e,Error),e.prototype.format=function(e){var r="Error: "+this.message;if(this.location){var n,a=null;for(n=0;n<e.length;n++)if(e[n].source===this.location.source){a=e[n].text.split(/\r\n|\n|\r/g);break}var u=this.location.start,o=this.location.source&&"function"==typeof this.location.source.offset?this.location.source.offset(u):u,i=this.location.source+":"+o.line+":"+o.column;if(a){var l=this.location.end,s=t("",o.line.toString().length," "),c=a[u.line-1],d=(u.line===l.line?l.column:c.length+1)-u.column||1;r+="\n --\x3e "+i+"\n"+s+" |\n"+o.line+" | "+c+"\n"+s+" | "+t("",u.column-1," ")+t("",d,"^")}else r+="\n at "+i}return r},e.buildMessage=function(e,t){var r={literal:function(e){return'"'+a(e.text)+'"'},class:function(e){var t=e.parts.map((function(e){return Array.isArray(e)?u(e[0])+"-"+u(e[1]):u(e)}));return"["+(e.inverted?"^":"")+t.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(e){return e.description}};function n(e){return e.charCodeAt(0).toString(16).toUpperCase()}function a(e){return e.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(e){return"\\x0"+n(e)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(e){return"\\x"+n(e)}))}function u(e){return e.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(e){return"\\x0"+n(e)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(e){return"\\x"+n(e)}))}function o(e){return r[e.type](e)}return"Expected "+function(e){var t,r,n=e.map(o);if(n.sort(),n.length>0){for(t=1,r=1;t<n.length;t++)n[t-1]!==n[t]&&(n[r]=n[t],r++);n.length=r}switch(n.length){case 1:return n[0];case 2:return n[0]+" or "+n[1];default:return n.slice(0,-1).join(", ")+", or "+n[n.length-1]}}(e)+" but "+function(e){return e?'"'+a(e)+'"':"end of input"}(t)+" found."},{SyntaxError:e,parse:function(t,r){var n,a={},u=(r=void 0!==r?r:{}).grammarSource,o={start:ke},i=ke,l="(",s=")",c="+",d="-",p="<=",f=">=",v="<>",m="==",h="!=",y="&&",g="||",b=/^[A-Za-z]/,x=/^[0-9]/,T=/^[1-9]/,$=/^[\n\r\u2028\u2029]/,w=Te("(",!1),C=Te(")",!1),A=Te("^",!1),k=Te("*",!1),E=Te("/",!1),M=Te("+",!1),U=Te("-",!1),O=Te("<=",!1),S=Te(">=",!1),F=Te("<>",!1),j=Te("<",!1),D=Te(">",!1),N=Te("==",!1),I=Te("=",!1),q=Te("!=",!1),R=Te("&&",!1),W=Te("||",!1),P=Te("&",!1),_=Te("!",!1),Z=Te(",",!1),L=$e([["A","Z"],["a","z"]],!1,!1),Y=Te("_",!1),z=Te("$",!1),Q=Te("[",!1),X=Te(".",!1),B=Te("]",!1),H=Te("0",!1),V=$e([["0","9"]],!1,!1),G=$e([["1","9"]],!1,!1),K=Te("true",!0),J=Te("false",!0),ee=Te("null",!0),te=Te("\\",!1),re=Te("'",!1),ne=Te('"',!1),ae={type:"any"},ue=$e(["\n","\r","\u2028","\u2029"],!1,!1),oe=Te("\t",!1),ie=Te("\v",!1),le=Te("\f",!1),se=Te(" ",!1),ce=Te(" ",!1),de=Te("​",!1),pe=Te("\ufeff",!1),fe=function(e,t){return function(e){const t=[],r=[];e.forEach((e=>{if("operator"===e.type){for(;t.length>0&&!(t[t.length-1].precedence<e.precedence);){let e=t.pop(),n=r.pop(),a=r.pop();r.push(He(e,a,n))}t.push(e)}else r.push(e)}));for(;t.length>0;){let e=t.pop(),n=r.pop(),a=r.pop();r.push(He(e,a,n))}return r.pop()}([e,t].flat(2))},ve=0,me=0,he=[{line:1,column:1}],ye=0,ge=[],be=0;if("startRule"in r){if(!(r.startRule in o))throw new Error("Can't start parsing from rule \""+r.startRule+'".');i=o[r.startRule]}function xe(){return t.substring(me,ve)}function Te(e,t){return{type:"literal",text:e,ignoreCase:t}}function $e(e,t,r){return{type:"class",parts:e,inverted:t,ignoreCase:r}}function we(e){var r,n=he[e];if(n)return n;for(r=e-1;!he[r];)r--;for(n={line:(n=he[r]).line,column:n.column};r<e;)10===t.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return he[e]=n,n}function Ce(e,t,r){var n=we(e),a=we(t),o={source:u,start:{offset:e,line:n.line,column:n.column},end:{offset:t,line:a.line,column:a.column}};return r&&u&&"function"==typeof u.offset&&(o.start=u.offset(o.start),o.end=u.offset(o.end)),o}function Ae(e){ve<ye||(ve>ye&&(ye=ve,ge=[]),ge.push(e))}function ke(){return Ee()}function Ee(){var e;return(e=Fe())===a&&(e=function(){var e,r,n;e=ve,r=function(){var e;33===t.charCodeAt(ve)?(e="!",ve++):(e=a,0===be&&Ae(_));return e}(),r!==a?(ze(),(n=Ee())!==a?(me=e,e={type:"callExpression",id:"not",arguments:[n]}):(ve=e,e=a)):(ve=e,e=a);return e}())===a&&(e=Ue())===a&&(e=De())===a&&(e=qe()),e}function Me(){var e,r,n,u;return(e=Ue())===a&&(e=De())===a&&(e=qe())===a&&(e=ve,40===t.charCodeAt(ve)?(r="(",ve++):(r=a,0===be&&Ae(w)),r!==a?(ze(),(n=Oe())!==a?(ze(),41===t.charCodeAt(ve)?(u=")",ve++):(u=a,0===be&&Ae(C)),u!==a?(me=e,e=n):(ve=e,e=a)):(ve=e,e=a)):(ve=e,e=a),e===a&&(e=ve,40===t.charCodeAt(ve)?(r="(",ve++):(r=a,0===be&&Ae(w)),r!==a?(ze(),(n=Fe())!==a?(ze(),41===t.charCodeAt(ve)?(u=")",ve++):(u=a,0===be&&Ae(C)),u!==a?(me=e,e=n):(ve=e,e=a)):(ve=e,e=a)):(ve=e,e=a))),e}function Ue(){var e,r,n,u;return e=ve,r=function(){var e,r,n;e=ve,r=[],b.test(t.charAt(ve))?(n=t.charAt(ve),ve++):(n=a,0===be&&Ae(L));if(n!==a)for(;n!==a;)r.push(n),b.test(t.charAt(ve))?(n=t.charAt(ve),ve++):(n=a,0===be&&Ae(L));else r=a;r!==a&&(me=e,r=r.join("").toLowerCase());return e=r}(),r!==a?(ze(),n=function(){var e,r,n,u;e=ve,40===t.charCodeAt(ve)?(r=l,ve++):(r=a,0===be&&Ae(w));r!==a?(ze(),n=ve,u=function(){var e,r,n,u;e=ve,r=[],n=ve,(u=Ee())!==a?(ze(),44===t.charCodeAt(ve)?ve++:0===be&&Ae(Z),ze(),me=n,n=u):(ve=n,n=a);if(n!==a)for(;n!==a;)r.push(n),n=ve,(u=Ee())!==a?(ze(),44===t.charCodeAt(ve)?ve++:0===be&&Ae(Z),ze(),me=n,n=u):(ve=n,n=a);else r=a;r!==a&&(me=e);return e=r}(),u!==a?n=u=[u,ze()]:(ve=n,n=a),n===a&&(n=null),41===t.charCodeAt(ve)?(u=s,ve++):(u=a,0===be&&Ae(C)),u!==a?(me=e,e=n):(ve=e,e=a)):(ve=e,e=a);return e}(),n!==a?(me=e,e={type:"callExpression",id:r,arguments:(u=n,null!==u?u[0]:[])}):(ve=e,e=a)):(ve=e,e=a),e}function Oe(){var e,t,r,n;if(e=ve,(t=Me())!==a){for(ze(),r=[],n=Se();n!==a;)r.push(n),n=Se();me=e,e=fe(t,r)}else ve=e,e=a;return e}function Se(){var e,r,n,u,o;return e=ve,ze(),r=function(){var e;94===t.charCodeAt(ve)?(e="^",ve++):(e=a,0===be&&Ae(A));e===a&&(42===t.charCodeAt(ve)?(e="*",ve++):(e=a,0===be&&Ae(k)),e===a&&(47===t.charCodeAt(ve)?(e="/",ve++):(e=a,0===be&&Ae(E)),e===a&&(43===t.charCodeAt(ve)?(e=c,ve++):(e=a,0===be&&Ae(M)),e===a&&(45===t.charCodeAt(ve)?(e=d,ve++):(e=a,0===be&&Ae(U))))));return e}(),r!==a?(ze(),(n=Me())!==a?(me=e,u=r,o=n,e=[Object.assign({type:"operator"},Xe[u]),o]):(ve=e,e=a)):(ve=e,e=a),e}function Fe(){var e,r,n,u;return e=ve,(r=je())!==a?(ze(),n=function(){var e;t.substr(ve,2)===y?(e=y,ve+=2):(e=a,0===be&&Ae(R));e===a&&(t.substr(ve,2)===g?(e=g,ve+=2):(e=a,0===be&&Ae(W)));return e}(),n!==a?(ze(),(u=Fe())!==a?(me=e,e=function(e,t,r){var n;switch(t){case"||":n="or";break;case"&&":n="and"}return{type:"callExpression",id:n,arguments:[e,r]}}(r,n,u)):(ve=e,e=a)):(ve=e,e=a)):(ve=e,e=a),e===a&&(e=je()),e}function je(){var e,r,n,u;return e=ve,(r=Oe())!==a?(ze(),n=function(){var e;t.substr(ve,2)===p?(e=p,ve+=2):(e=a,0===be&&Ae(O));e===a&&(t.substr(ve,2)===f?(e=f,ve+=2):(e=a,0===be&&Ae(S)),e===a&&(t.substr(ve,2)===v?(e=v,ve+=2):(e=a,0===be&&Ae(F)),e===a&&(60===t.charCodeAt(ve)?(e="<",ve++):(e=a,0===be&&Ae(j)),e===a&&(62===t.charCodeAt(ve)?(e=">",ve++):(e=a,0===be&&Ae(D)),e===a&&(t.substr(ve,2)===m?(e=m,ve+=2):(e=a,0===be&&Ae(N)),e===a&&(61===t.charCodeAt(ve)?(e="=",ve++):(e=a,0===be&&Ae(I)),e===a&&(t.substr(ve,2)===h?(e=h,ve+=2):(e=a,0===be&&Ae(q)))))))));return e}(),n===a&&(n=function(){var e;38===t.charCodeAt(ve)?(e="&",ve++):(e=a,0===be&&Ae(P));return e}()),n!==a?(ze(),(u=je())!==a?(me=e,e=function(e,t,r){var n;switch(t){case"<":n="lessThan";break;case"<=":n="lessThanOrEqual";break;case">":n="greaterThan";break;case">=":n="greaterThanOrEqual";break;case"==":case"=":n="equal";break;case"!=":case"<>":n="unequal";break;case"&":n="add"}return{type:"callExpression",id:n,arguments:[e,r]}}(r,n,u)):(ve=e,e=a)):(ve=e,e=a)):(ve=e,e=a),e===a&&(e=Oe()),e}function De(){var e,t,r;return e=ve,t=ve,be++,r=function(){var e;(e=Pe())===a&&(e=_e());return e}(),be--,r===a?t=void 0:(ve=t,t=a),t!==a?(r=function(){var e,t,r,n;if(e=ve,(t=Ne())!==a){for(r=[],n=Ie();n!==a;)r.push(n),n=Ie();me=e,e={type:"identifier",name:t+r.join("")}}else ve=e,e=a;return e}(),r!==a?(me=e,e=r):(ve=e,e=a)):(ve=e,e=a),e}function Ne(){var e;return 95===t.charCodeAt(ve)?(e="_",ve++):(e=a,0===be&&Ae(Y)),e===a&&(36===t.charCodeAt(ve)?(e="$",ve++):(e=a,0===be&&Ae(z)),e===a&&(91===t.charCodeAt(ve)?(e="[",ve++):(e=a,0===be&&Ae(Q)),e===a&&(b.test(t.charAt(ve))?(e=t.charAt(ve),ve++):(e=a,0===be&&Ae(L))))),e}function Ie(){var e;return(e=Ne())===a&&(46===t.charCodeAt(ve)?(e=".",ve++):(e=a,0===be&&Ae(X)),e===a&&(93===t.charCodeAt(ve)?(e="]",ve++):(e=a,0===be&&Ae(B)),e===a&&(e=We()))),e}function qe(){var e;return(e=function(){var e,t,r;if(e=ve,Le()!==a){for(t=[],(r=Ze())===a&&(r=Ye());r!==a;)t.push(r),(r=Ze())===a&&(r=Ye());(r=Le())!==a?(me=e,e=Be(t)):(ve=e,e=a)}else ve=e,e=a;if(e===a)if(e=ve,Ye()!==a){for(t=[],(r=Ze())===a&&(r=Le());r!==a;)t.push(r),(r=Ze())===a&&(r=Le());(r=Ye())!==a?(me=e,e=function(e){return Be(e)}(t)):(ve=e,e=a)}else ve=e,e=a;return e}())===a&&(e=function(){var e,r,n,u,o,i;e=ve,r=ve,n=ze(),43===t.charCodeAt(ve)?(u=c,ve++):(u=a,0===be&&Ae(M));u!==a?r=n=[n,u]:(ve=r,r=a);r===a&&(r=ve,45===t.charCodeAt(ve)?(n=d,ve++):(n=a,0===be&&Ae(U)),n!==a?r=n=[n,u=ze()]:(ve=r,r=a));r===a&&(r=null);if((n=Re())!==a)if(46===t.charCodeAt(ve)?(u=".",ve++):(u=a,0===be&&Ae(X)),u!==a){for(o=[],i=We();i!==a;)o.push(i),i=We();me=e,l=xe().replace(/[\+\-]/g,"").split("."),e={type:"literal",value:parseFloat(xe()),dataType:"number",options:{length:l[0].length,scale:l[1].length}}}else ve=e,e=a;else ve=e,e=a;var l;e===a&&(e=ve,r=ve,n=ze(),43===t.charCodeAt(ve)?(u=c,ve++):(u=a,0===be&&Ae(M)),u!==a?r=n=[n,u]:(ve=r,r=a),r===a&&(r=ve,45===t.charCodeAt(ve)?(n=d,ve++):(n=a,0===be&&Ae(U)),n!==a?r=n=[n,u=ze()]:(ve=r,r=a)),r===a&&(r=null),(n=Re())!==a?(me=e,e={type:"literal",value:parseInt(xe()),dataType:"number",options:{length:xe().replace(/[\+\-]/g,"").length,scale:0}}):(ve=e,e=a));return e}())===a&&(e=Pe())===a&&(e=_e()),e}function Re(){var e,r,n,u;if(48===t.charCodeAt(ve)?(e="0",ve++):(e=a,0===be&&Ae(H)),e===a)if(e=ve,r=function(){var e;T.test(t.charAt(ve))?(e=t.charAt(ve),ve++):(e=a,0===be&&Ae(G));return e}(),r!==a){for(n=[],u=We();u!==a;)n.push(u),u=We();e=r=[r,n]}else ve=e,e=a;return e}function We(){var e;return x.test(t.charAt(ve))?(e=t.charAt(ve),ve++):(e=a,0===be&&Ae(V)),e}function Pe(){var e,r;return e=ve,"true"===t.substr(ve,4).toLowerCase()?(r=t.substr(ve,4),ve+=4):(r=a,0===be&&Ae(K)),r!==a&&(me=e,r={type:"literal",value:!0,dataType:"checkbox",options:{}}),(e=r)===a&&(e=ve,"false"===t.substr(ve,5).toLowerCase()?(r=t.substr(ve,5),ve+=5):(r=a,0===be&&Ae(J)),r!==a&&(me=e,r={type:"literal",value:!1,dataType:"checkbox",options:{}}),e=r),e}function _e(){var e,r;return e=ve,"null"===t.substr(ve,4).toLowerCase()?(r=t.substr(ve,4),ve+=4):(r=a,0===be&&Ae(ee)),r!==a&&(me=e,r={type:"literal",value:null,dataType:"null",options:{}}),e=r}function Ze(){var e,r,n;return e=ve,r=ve,be++,n=function(){var e;(e=Le())===a&&(e=Ye());return e}(),n===a&&(92===t.charCodeAt(ve)?(n="\\",ve++):(n=a,0===be&&Ae(te))),be--,n===a?r=void 0:(ve=r,r=a),r!==a?(n=function(){var e;t.length>ve?(e=t.charAt(ve),ve++):(e=a,0===be&&Ae(ae));return e}(),n!==a?(me=e,e=xe()):(ve=e,e=a)):(ve=e,e=a),e}function Le(){var e;return 39===t.charCodeAt(ve)?(e="'",ve++):(e=a,0===be&&Ae(re)),e}function Ye(){var e;return 34===t.charCodeAt(ve)?(e='"',ve++):(e=a,0===be&&Ae(ne)),e}function ze(){var e,t;for(e=[],t=Qe();t!==a;)e.push(t),t=Qe();return e}function Qe(){var e;return 9===t.charCodeAt(ve)?(e="\t",ve++):(e=a,0===be&&Ae(oe)),e===a&&(e=function(){var e;return $.test(t.charAt(ve))?(e=t.charAt(ve),ve++):(e=a,0===be&&Ae(ue)),e}())===a&&(11===t.charCodeAt(ve)?(e="\v",ve++):(e=a,0===be&&Ae(ie)),e===a&&(12===t.charCodeAt(ve)?(e="\f",ve++):(e=a,0===be&&Ae(le)),e===a&&(32===t.charCodeAt(ve)?(e=" ",ve++):(e=a,0===be&&Ae(se)),e===a&&(160===t.charCodeAt(ve)?(e=" ",ve++):(e=a,0===be&&Ae(ce)),e===a&&(8203===t.charCodeAt(ve)?(e="​",ve++):(e=a,0===be&&Ae(de)),e===a&&(65279===t.charCodeAt(ve)?(e="\ufeff",ve++):(e=a,0===be&&Ae(pe)))))))),e}const Xe={"^":{functionName:"exponentiate",rightAssociative:!0,precedence:4},"*":{functionName:"multiply",rightAssociative:!1,precedence:3},"/":{functionName:"divide",rightAssociative:!1,precedence:3},"+":{functionName:"add",rightAssociative:!1,precedence:2},"-":{functionName:"subtract",rightAssociative:!1,precedence:2}};function Be(e){return{type:"literal",value:e.join(""),dataType:"text",options:{length:e.length}}}function He(e,t,r){return{type:"callExpression",id:e.functionName,arguments:[t,r]}}if((n=i())!==a&&ve===t.length)return n;throw n!==a&&ve<t.length&&Ae({type:"end"}),Ve=ge,Ge=ye<t.length?t.charAt(ye):null,Ke=ye<t.length?Ce(ye,ye+1):Ce(ye,ye),new e(e.buildMessage(Ve,Ge),Ve,Ge,Ke);var Ve,Ge,Ke}}}(),u=function(){function e(t,r,n,a){var u=Error.call(this,t);return Object.setPrototypeOf&&Object.setPrototypeOf(u,e.prototype),u.expected=r,u.found=n,u.location=a,u.name="SyntaxError",u}function t(e,t,r){return r=r||" ",e.length>t?e:(t-=e.length,e+(r+=r.repeat(t)).slice(0,t))}return function(e,t){function r(){this.constructor=e}r.prototype=t.prototype,e.prototype=new r}(e,Error),e.prototype.format=function(e){var r="Error: "+this.message;if(this.location){var n,a=null;for(n=0;n<e.length;n++)if(e[n].source===this.location.source){a=e[n].text.split(/\r\n|\n|\r/g);break}var u=this.location.start,o=this.location.source&&"function"==typeof this.location.source.offset?this.location.source.offset(u):u,i=this.location.source+":"+o.line+":"+o.column;if(a){var l=this.location.end,s=t("",o.line.toString().length," "),c=a[u.line-1],d=(u.line===l.line?l.column:c.length+1)-u.column||1;r+="\n --\x3e "+i+"\n"+s+" |\n"+o.line+" | "+c+"\n"+s+" | "+t("",u.column-1," ")+t("",d,"^")}else r+="\n at "+i}return r},e.buildMessage=function(e,t){var r={literal:function(e){return'"'+a(e.text)+'"'},class:function(e){var t=e.parts.map((function(e){return Array.isArray(e)?u(e[0])+"-"+u(e[1]):u(e)}));return"["+(e.inverted?"^":"")+t.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(e){return e.description}};function n(e){return e.charCodeAt(0).toString(16).toUpperCase()}function a(e){return e.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(e){return"\\x0"+n(e)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(e){return"\\x"+n(e)}))}function u(e){return e.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(e){return"\\x0"+n(e)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(e){return"\\x"+n(e)}))}function o(e){return r[e.type](e)}return"Expected "+function(e){var t,r,n=e.map(o);if(n.sort(),n.length>0){for(t=1,r=1;t<n.length;t++)n[t-1]!==n[t]&&(n[r]=n[t],r++);n.length=r}switch(n.length){case 1:return n[0];case 2:return n[0]+" or "+n[1];default:return n.slice(0,-1).join(", ")+", or "+n[n.length-1]}}(e)+" but "+function(e){return e?'"'+a(e)+'"':"end of input"}(t)+" found."},{SyntaxError:e,parse:function(t,r){var n,a,u,o,i={},l=(r=void 0!==r?r:{}).grammarSource,s={Time:E},c=E,d=/^[0-9]/,p=w(":",!1),f=w(".",!1),v={type:"class",parts:[["0","9"]],inverted:!1,ignoreCase:!1},m=function(e,t,r,n){return function(e,t,r,n){e>23&&$("hour part needs to be under 24");t>59&&$("minute part needs to be under 60");r>59&&$("second part needs to be under 60");n>999&&$("millisecond part needs to be under 1000")}(e,t,r,n),{type:"literal",value:new Date(n+1e3*r+60*t*1e3+60*e*60*1e3),dataType:"time",options:{}}},h=0,y=0,g=[{line:1,column:1}],b=0,x=[];if("startRule"in r){if(!(r.startRule in s))throw new Error("Can't start parsing from rule \""+r.startRule+'".');c=s[r.startRule]}function T(){return t.substring(y,h)}function $(t,r){throw function(t,r){return new e(t,null,null,r)}(t,r=void 0!==r?r:A(y,h))}function w(e,t){return{type:"literal",text:e,ignoreCase:t}}function C(e){var r,n=g[e];if(n)return n;for(r=e-1;!g[r];)r--;for(n={line:(n=g[r]).line,column:n.column};r<e;)10===t.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return g[e]=n,n}function A(e,t,r){var n=C(e),a=C(t),u={source:l,start:{offset:e,line:n.line,column:n.column},end:{offset:t,line:a.line,column:a.column}};return r&&l&&"function"==typeof l.offset&&(u.start=l.offset(u.start),u.end=l.offset(u.end)),u}function k(e){h<b||(h>b&&(b=h,x=[]),x.push(e))}function E(){var e,r,n,a,u,o,l,s;return e=h,r=function(){var e;e=h,M()!==i&&M()!==i?(y=e,e=parseInt(T())):(h=e,e=i);return e}(),r!==i?(58===t.charCodeAt(h)?(n=":",h++):(n=i,k(p)),n!==i?(a=function(){var e;e=h,M()!==i&&M()!==i?(y=e,e=parseInt(T())):(h=e,e=i);return e}(),a!==i?(58===t.charCodeAt(h)?(u=":",h++):(u=i,k(p)),u!==i?(o=function(){var e;e=h,M()!==i&&M()!==i?(y=e,e=parseInt(T())):(h=e,e=i);return e}(),o!==i?(46===t.charCodeAt(h)?(l=".",h++):(l=i,k(f)),l!==i?(s=function(){var e;e=h,M()!==i&&M()!==i&&M()!==i?(y=e,e=parseInt(T())):(h=e,e=i);return e}(),s!==i?(y=e,e=m(r,a,o,s)):(h=e,e=i)):(h=e,e=i)):(h=e,e=i)):(h=e,e=i)):(h=e,e=i)):(h=e,e=i)):(h=e,e=i),e}function M(){var e;return d.test(t.charAt(h))?(e=t.charAt(h),h++):(e=i,k(v)),e}if((n=c())!==i&&h===t.length)return n;throw n!==i&&h<t.length&&k({type:"end"}),a=x,u=b<t.length?t.charAt(b):null,o=b<t.length?A(b,b+1):A(b,b),new e(e.buildMessage(a,u),a,u,o)}}}();class o extends Error{constructor(e,t,r){super(e),this.errorType=t,this.options=r}}const i=864e5,l=(e,t)=>{if(e<0)return-1*l(-1*e,t);const r=10**t;return Math.round(e*r)/r},s=e=>{const t=e.toString().replace("-","");if(-1!==t.indexOf(".")){const e=t.split(".");return{length:e[0].length,scale:e[1].length}}return{length:t.length,scale:0}},c=(e,t,r)=>{switch(e){case"number":return l(t,r.scale);case"text":return t.substring(0,r.length);default:return t}},d=e=>{const t={type:"literal",value:e};if(null==e)return Object.assign(t,{value:null,dataType:"null",options:{}});const r=typeof e;switch(typeof e){case"number":return Object.assign(t,{dataType:"number",options:s(e)});case"string":return Object.assign(t,{dataType:"text",options:{length:e.length}});case"boolean":return Object.assign(t,{dataType:"checkbox",options:{}});default:throw new TypeError(`Unsupported type '${r}'`)}},p=(e,t,r)=>({type:"error",errorType:e,message:t,...r}),f=(e,t,r)=>e instanceof Date?f(e.getUTCFullYear(),e.getUTCMonth()+1,e.getUTCDate()):{type:"literal",dataType:"date",value:new Date(Date.UTC(e,t-1,r)),options:{}},v=e=>({type:"literal",dataType:"datetime",value:new Date(e),options:{}}),m=e=>({type:"literal",dataType:"time",value:new Date(e),options:{}}),h=e=>{try{return e()}catch(e){if(e instanceof o)return p(e.errorType,e.message,e.options);throw e}},y=(e,t)=>new Date(e.getTime()+t*i),g=e=>{if(!e.value&&"null"!==e.dataType&&0!==e.value&&!1!==e.value&&""!==e.value)return"";switch(e.dataType){case"null":return"NULL";case"number":return e.value.toString();case"text":case"picklist":return`"${e.value}"`;case"multipicklist":return`[${e.value.map((e=>`"${e}"`)).join(", ")}]`;case"checkbox":return e.value.toString().toUpperCase();case"date":return`${e.value.getUTCFullYear()}-${(e.value.getUTCMonth()+1).toString().padStart(2,"0")}-${e.value.getUTCDate().toString().padStart(2,"0")}`;case"datetime":return e.value.toISOString();case"time":return e.value.toISOString().split("T")[1].replace("Z","");case"geolocation":return t=e.value[0],r=e.value[1],t&&r||0===t||0===r?`${t.toFixed(6)}, ${r.toFixed(6)}`:"";default:return}var t,r};class b extends o{constructor(e,t){super(e,"NotImplementedError",t)}static throwError(e){throw new b(`Function ${e} not implemented yet.`,{name:e})}}const x=e=>Array.isArray(e)?e.map((e=>x(e))).join(", "):"string"!=typeof e?"":e.charAt(0).toUpperCase()+e.slice(1);class T extends o{constructor(e,t){super(e,"ArgumentError",t)}static throwWrongType(e,t,r){const n={function:e,expected:t,received:r},a=r||"Non-Salesforce";throw new T(`Incorrect parameter type for function '${e.toUpperCase()}()'. Expected ${x(t)}, received ${x(a)}`,n)}static throwIncorrectNumberOfArguments(e,t,r){const n={function:e,expected:t,received:r};throw new T(`Incorrect number of parameters for function '${e.toUpperCase()}()'. Expected ${t}, received ${r}`,n)}}const $=(e,t)=>{switch(e.dataType){case"date":case"datetime":return d(e.value.getTime()===t.value.getTime());default:return d(e.value===t.value)}},w=(e,t,r)=>d(e.value.substr(t.value-1,r.value)),C=(e,t)=>w(e,d(1),t);var A=Object.freeze({__proto__:null,sf$or:(...e)=>{const t=e.map((e=>e.value)).reduce(((e,t)=>e||t));return d(t)},sf$equal:$,sf$unequal:(e,t)=>d(!$(e,t).value),sf$greaterThan:(e,t)=>d(e.value>t.value),sf$greaterThanOrEqual:(e,t)=>d(e.value>=t.value),sf$lessThan:(e,t)=>d(e.value<t.value),sf$lessThanOrEqual:(e,t)=>d(e.value<=t.value),sf$addmonths:(e,t)=>f(((e,t)=>{const r=e.getUTCMonth()+t,n=new Date(Date.UTC(e.getUTCFullYear(),r,e.getUTCDate()));return e.getUTCDate()!==n.getUTCDate()&&n.setUTCDate(0),n})(e.value,t.value)),sf$date:(e,t,r)=>f(e.value,t.value,r.value),sf$datevalue:e=>f(new Date(Date.parse(e.value))),sf$datetimevalue:e=>v(Date.parse(`${e.value}Z`)),sf$day:e=>d(e.value.getUTCDate()),sf$hour:e=>d(e.value.getUTCHours()),sf$millisecond:e=>d(e.value.getUTCMilliseconds()),sf$minute:e=>d(e.value.getUTCMinutes()),sf$month:e=>d(e.value.getUTCMonth()+1),sf$now:()=>v((new Date).getTime()),sf$second:e=>d(e.value.getUTCSeconds()),sf$timenow:()=>m((new Date).getTime()%864e5),sf$timevalue:e=>(e=>{try{return u.parse(e)}catch(e){if(e instanceof u.SyntaxError)return d(null);throw e}})(e.value),sf$today:()=>f(new Date),sf$weekday:e=>d(e.value.getUTCDay()+1),sf$year:e=>d(e.value.getUTCFullYear()),sf$and:(...e)=>{const t=e.map((e=>e.value)).reduce(((e,t)=>e&&t));return d(t)},sf$blankvalue:(e,t)=>"null"===e.dataType||""===e.value?t:e,sf$case:(e,...t)=>{const r=t.length-1;if(r<=0){const e={function:"case",expected:4,received:r+2};throw new T(`Incorrect number of parameters for function '${e.function.toUpperCase()}()'. Expected ${e.expected}+, received ${e.received}`,e)}if(r%2!=0){const e={function:"case",expected:r+1,received:r+2};throw new T(`Incorrect number of parameters for function '${e.function.toUpperCase()}()'. Expected ${e.expected}, received ${e.received}`,e)}for(let n=0;n<r;n+=2)if($(t[n],e).value)return t[n+1];return t[r]},sf$if:(e,t,r)=>e.value?t:r,sf$isblank:e=>d("null"===e.dataType||""===e.value),sf$isnull:e=>{b.throwError("isnull")},sf$isnumber:e=>{b.throwError("isnumber")},sf$not:e=>d(!e.value),sf$nullvalue:(e,t)=>{b.throwError("nullvalue")},sf$add:(e,t)=>{switch([e.dataType,t.dataType].join(" ")){case"date number":return f(y(e.value,t.value));case"number date":return f(y(t.value,e.value));case"time number":return m(e.value.getTime()+t.value);case"number time":return m(e.value+t.value.getTime());case"datetime number":return v(y(e.value,t.value));case"number datetime":return v(y(t.value,e.value));case"number number":return d(new n.default(e.value).plus(new n.default(t.value)).toNumber());case"text text":return d(e.value+t.value);case"text null":return e;default:T.throwWrongType("add","number",t.dataType)}},sf$subtract:(e,t)=>{switch([e.dataType,t.dataType].join(" ")){case"date number":return f(y(e.value,-1*t.value));case"time number":return m(e.value.getTime()+-1*t.value);case"datetime number":return v(y(e.value,-1*t.value));case"date date":case"datetime datetime":return d((r=e.value,a=t.value,(r.getTime()-a.getTime())/i));case"time time":return d(e.value.getTime()-t.value.getTime());case"number number":return d(new n.default(e.value).minus(new n.default(t.value)).toNumber());case"text text":return d(e.value-t.value);default:T.throwWrongType("subtract","number",t.dataType)}var r,a},sf$multiply:(e,t)=>("number number"!==[e.dataType,t.dataType].join(" ")&&T.throwWrongType("multiply","number",t.dataType),d(new n.default(e.value).times(new n.default(t.value)).toNumber())),sf$divide:(e,t)=>("number number"!==[e.dataType,t.dataType].join(" ")&&T.throwWrongType("divide","number",t.dataType),d(new n.default(e.value).dividedBy(new n.default(t.value)).toNumber())),sf$exponentiate:(e,t)=>("number number"!==[e.dataType,t.dataType].join(" ")&&T.throwWrongType("exponentiate","number",t.dataType),d(new n.default(e.value).toPower(new n.default(t.value)).toNumber())),sf$abs:e=>d(Math.abs(e.value)),sf$ceiling:e=>e.value<0?d(-1*Math.ceil(-1*e.value)):d(Math.ceil(e.value)),sf$distance:(e,t,r)=>{const n=r.value;if("km"!==n&&"mi"!==n){throw new T(`Incorrect parameter value for function 'DISTANCE()'. Expected 'mi'/'km', received '${n}'`,{function:"distance",expected:["km","mi"],received:n})}const[a,u]=e.value,[o,i]=t.value;if(a===o&&u===i)return d(0);const l=a*Math.PI/180,s=o*Math.PI/180,c=(o-a)*Math.PI/180,p=(i-u)*Math.PI/180,f=Math.sin(c/2)*Math.sin(c/2)+Math.cos(l)*Math.cos(s)*Math.sin(p/2)*Math.sin(p/2),v=6371009*(2*Math.atan2(Math.sqrt(f),Math.sqrt(1-f)))/1e3;return d("mi"===n?v/1.609344:v)},sf$exp:e=>d(Math.exp(e.value)),sf$floor:e=>e.value<0?d(-1*Math.floor(-1*e.value)):d(Math.floor(e.value)),sf$geolocation:(e,t)=>((e,t)=>({type:"literal",dataType:"geolocation",value:[e,t],options:{}}))(e.value,t.value),sf$ln:e=>d(Math.log(e.value)),sf$log:e=>d(Math.log10(e.value)),sf$max:(...e)=>{const t=e.map((e=>e.value));return d(Math.max(...t))},sf$mceiling:e=>d(Math.ceil(e.value)),sf$mfloor:e=>d(Math.floor(e.value)),sf$min:(...e)=>{const t=e.map((e=>e.value));return d(Math.min(...t))},sf$mod:(e,t)=>d(e.value%t.value),sf$round:(e,t)=>d(l(e.value,t.value)),sf$sqrt:e=>d(Math.sqrt(e.value)),sf$begins:(e,t)=>d(e.value.startsWith(t.value)),sf$br:()=>d("\n"),sf$casesafeid:e=>{let t="";return[0,1,2].forEach((r=>{let n=0;[0,1,2,3,4].forEach((t=>{const a=e.value[5*r+t];a.toUpperCase()===a&&a>="A"&&a<="Z"&&(n+=1<<t)})),t+="ABCDEFGHIJKLMNOPQRSTUVWXYZ012345"[n]})),d(e.value+t)},sf$concat:(e,t)=>d(e.value+t.value),sf$contains:(e,t)=>d(e.value.includes(t.value)),sf$find:(e,t,r=d(1))=>{if(r.value<=0||""===e.value)return d(0);const n=t.value.substring(r.value-1);return d(n.indexOf(e.value)+1)},sf$getsessionid:()=>d("00D3z000001eRlg!AQMAQC3Y4aM9sFux6SRWhyFcOUKin4taGaBxNMU8TN_R_1R0Y7ArI95eSyzQZVIlrnV_unTbmwHZlXex8xhlXz2kXZNP49Fa"),sf$hyperlink:(e,t,r=null)=>{const n=r?` target="${r.value}"`:"";return d(`<a href="${e.value}"${n}>${t.value}</a>`)},sf$image:(e,t,r=null,n=null)=>{const a=r?` height="${r.value}"`:"",u=n?` width="${n.value}"`:"";return d(`<img src="${e.value}" alt="${t.value}"${a}${u}/>`)},sf$includes:(e,t)=>d(e.value.includes(t.value)),sf$ispickval:(e,t)=>d(e.value===t.value),sf$mid:w,sf$left:C,sf$len:e=>d(e.value.length),sf$lower:(e,t)=>d(e.value.toLowerCase()),sf$lpad:(e,t,r)=>{if(null==r)return e;if(t.value<e.value.length)return C(e,t);const n=r.value.repeat(t.value);return d((n+e.value).slice(-t.value))},sf$right:(e,t)=>d(e.value.substr(e.value.length-t.value)),sf$rpad:(e,t,r)=>{if(null==r)return e;if(t.value<e.value.length)return C(e,t);const n=r.value.repeat(t.value);return d((e.value+n).substr(0,t.value))},sf$substitute:(e,t,r)=>d(e.value.replace(new RegExp(t.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),r.value)),sf$text:e=>"datetime"===e.dataType?d(g(e).replace("T"," ").replace(/\.\d{3}/,"")):"picklist"===e.dataType?d(e.value):d(g(e)),sf$trim:e=>d(e.value.trim()),sf$upper:(e,t)=>d(e.value.toUpperCase()),sf$value:e=>{const t=parseFloat(e.value);return d(t||null)},sf$currencyrate:e=>{b.throwError("currencyrate")},sf$regex:(e,t)=>{const r=new RegExp(`^${t.value}$`);return d(null!=r.exec(e.value))}});const k=e=>t=>r=>{r.length<e&&T.throwIncorrectNumberOfArguments(t,e,r.length)},E=e=>t=>r=>{r.length>e&&T.throwIncorrectNumberOfArguments(t,e,r.length)},M=(...e)=>t=>r=>{r.map(((t,r)=>[t.dataType,e[r]||e[e.length-1]])).forEach((([e,r])=>{"null"!==e&&(Array.isArray(r)?-1===r.indexOf(e)&&T.throwWrongType(t,r,e):e!==r&&T.throwWrongType(t,r,e))}))},U=()=>e=>t=>{const r=t.filter((e=>"null"!==e.dataType));r.length>0&&r.reduce(((t,r)=>(t.dataType!==r.dataType&&T.throwWrongType(e,t.dataType,r.dataType),r)))};class O extends o{constructor(e,t){super(e,"NoFunctionError",t)}}const S={abs:{validations:[k(1),E(1),M("number")],returnType:"number"},add:{validations:[k(2),E(2),M(["number","text","date","datetime","time"],["number","text","date","datetime","time"])],returnType:["number","text","date","datetime","time"]},addmonths:{validations:[k(2),E(2),M(["date","datetime"],["number"])],returnType:["date","datetime"]},and:{validations:[k(1),M("checkbox")],returnType:"checkbox"},begins:{validations:[k(2),E(2),M("text","text")],returnType:"checkbox"},blankvalue:{validations:[k(2),E(2),M(["text","number","date","datetime","geolocation"]),U()],returnType:["text","number"]},br:{validations:[k(0),E(0)],returnType:"text"},case:{validations:[k(4),M(["text","number","picklist","date","datetime"]),e=>t=>{const r="picklist"===t[0].dataType?"text":t[0].dataType,n=t.filter(((e,r)=>r%2==1&&r!==t.length-1)).find((e=>e.dataType!==r));n&&T.throwWrongType(e,r,n.dataType)}],returnType:["text","number","date","datetime"]},casesafeid:{validations:[k(1),E(1),M("text")],returnType:"text"},ceiling:{validations:[k(1),E(1),M("number")],returnType:"number"},contains:{validations:[k(2),E(2),M("text","text")],returnType:"checkbox"},currencyrate:{validations:[k(1),E(1),M("text")],returnType:"text"},date:{validations:[k(3),E(3),M("number","number","number")],returnType:"date"},datetimevalue:{validations:[k(1),E(1),M("text","date","datetime")],returnType:"datetime"},datevalue:{validations:[k(1),E(1),M(["text","date","datetime"])],returnType:"date"},day:{validations:[k(1),E(1),M("date")],returnType:"number"},distance:{validations:[k(3),E(3),M("geolocation","geolocation","text")],returnType:"number"},divide:{validations:[k(2),E(2),M("number","number")],returnType:"number"},equal:{validations:[k(2),E(2),M(["text","number","date","datetime","checkbox"]),U()],returnType:"checkbox"},exp:{validations:[k(1),E(1),M("number")],returnType:"number"},exponentiate:{validations:[k(2),E(2),M("number","number")],returnType:"number"},find:{validations:[k(2),E(3),M("text","text","number")],returnType:"number"},floor:{validations:[k(1),E(1),M("number")],returnType:"number"},geolocation:{validations:[k(2),E(2),M("number","number")],returnType:"geolocation"},getsessionid:{validations:[k(0),E(0)],returnType:"text"},greaterThan:{validations:[k(2),E(2),M(["number","date","datetime"]),U()],returnType:"checkbox"},greaterThanOrEqual:{validations:[k(2),E(2),M(["number","date","datetime"])],returnType:"checkbox"},hour:{validations:[k(1),E(1),M("datetime")],returnType:"number"},hyperlink:{validations:[k(2),E(3),M("text","text","text")],returnType:"text"},if:{validations:[k(3),E(3),M("checkbox",["text","number","date","datetime","checkbox","geolocation"],["text","number","date","datetime","checkbox","geolocation"])],returnType:["text","number","date","datetime","checkbox","geolocation"]},image:{validations:[k(2),E(4),M("text","text","number","number")],returnType:"text"},includes:{validations:[k(2),E(2),M("multipicklist","text")],returnType:"checkbox"},isblank:{validations:[k(1),E(1),M(["text","number","date","datetime","geolocation"])],returnType:"checkbox"},isnull:{validations:[k(1),E(1),M(["text","number"])],returnType:"checkbox"},ispickval:{validations:[k(2),E(2),M("picklist","text")],returnType:"checkbox"},isnumber:{validations:[k(1),E(1),M("text")],returnType:"checkbox"},left:{validations:[k(2),E(2),M("text","number")],returnType:"text"},len:{validations:[k(1),E(1),M("text")],returnType:"number"},lessThan:{validations:[k(2),E(2),M(["number","date","datetime"]),U()],returnType:"checkbox"},lessThanOrEqual:{validations:[k(2),E(2),M(["number","date","datetime"]),U()],returnType:"checkbox"},ln:{validations:[k(1),E(1),M("number")],returnType:"number"},log:{validations:[k(1),E(1),M("number")],returnType:"checkbox"},lower:{validations:[k(1),E(1),M("text")],returnType:"text"},lpad:{validations:[k(2),E(3),M("text","number","text")],returnType:"text"},max:{validations:[k(1),M("number")],returnType:"number"},mceiling:{validations:[k(1),E(1),M("number")],returnType:"number"},mfloor:{validations:[k(1),E(1),M("number")],returnType:"number"},mid:{validations:[k(3),E(3),M("text","number","number")],returnType:"number"},millisecond:{validations:[k(1),E(1),M("datetime")],returnType:"number"},min:{validations:[k(1),M("number")],returnType:"number"},minute:{validations:[k(1),E(1),M("datetime")],returnType:"number"},mod:{validations:[k(2),E(2),M("number","number")],returnType:"number"},month:{validations:[k(1),E(1),M("date")],returnType:"number"},multiply:{validations:[k(2),E(2),M("number","number")],returnType:"number"},not:{validations:[k(1),E(1),M("checkbox")],returnType:"checkbox"},now:{validations:[k(0),E(0)],returnType:"datetime"},nullvalue:{validations:[k(2),E(2),M(["text","number"],["text","number"])],returnType:["text","number"]},or:{validations:[k(1),M("checkbox")],returnType:"checkbox"},regex:{validations:[k(2),E(2),M("text","text")],returnType:"text"},right:{validations:[k(2),E(2),M("text","number")],returnType:"text"},round:{validations:[k(2),E(2),M("number","number")],returnType:"number"},rpad:{validations:[k(2),E(3),M("text","number","text")],returnType:"text"},second:{validations:[k(1),E(1),M("datetime")],returnType:"number"},sqrt:{validations:[k(1),E(1),M("number")],returnType:"number"},subtract:{validations:[k(2),E(2),M(["number","date","datetime","time"],["number","date","datetime","time"])],returnType:["number","date","datetime","time"]},substitute:{validations:[k(3),E(3),M("text","text","text")],returnType:"text"},text:{validations:[k(1),E(1),M(["number","date","datetime","picklist","time"])],returnType:"text"},timenow:{validations:[k(0),E(0)],returnType:"time"},timevalue:{validations:[k(1),E(1),M("text")],returnType:"time"},today:{validations:[k(0),E(0)],returnType:"date"},trim:{validations:[k(1),E(1),M("text")],returnType:"text"},unequal:{validations:[k(2),E(2),M(["text","number","date","datetime","checkbox"]),U()],returnType:"checkbox"},upper:{validations:[k(1),E(1),M("text")],returnType:"text"},value:{validations:[k(1),E(1),M("text")],returnType:"number"},weekday:{validations:[k(1),E(1),M("date")],returnType:"number"},year:{validations:[k(1),E(1),M("date")],returnType:"number"}};class F extends o{constructor(e,t){super(e,"ReferenceError",t)}}const j=e=>{switch(e.type){case"callExpression":return t=e.id,r=e.arguments.map((e=>j(e))),h((()=>{const e=r.find((e=>"error"===e.type));if(e)return e;const n=S[t];if(n)return n.validations.forEach((e=>e(t)(r))),A[`sf$${t}`](...r);throw new O(`Unknown function ${t.toUpperCase()}. Check spelling.`,{function:t})}));case"identifier":throw new F(`Field ${e.name} does not exist. Check spelling.`,{identifier:e.name});default:return e}var t,r},D=e=>{try{return a.parse(null==e?"":e.trim())}catch(e){if(e instanceof a.SyntaxError)return p("SyntaxError","Syntax error.",{});throw e}},N=(e,t=[])=>{switch(e.type){case"callExpression":return e.arguments.map((e=>N(e,t))).reduce(((e,t)=>e.concat(t)),[]);case"identifier":return t.concat(e.name);default:return t}},I=(e,t)=>"callExpression"===e.type?{type:"callExpression",id:e.id,arguments:e.arguments.map((e=>I(e,t)))}:"identifier"===e.type&&t[e.name]?{...t[e.name],type:"literal"}:e;e.ast=e=>null==e||""===e.trim()?{}:D(e),e.extract=e=>{if(null==e||""===e.trim())return[];const t=D(e);return N(t).reduce(((e,t)=>(e.indexOf(t)<0&&e.push(t),e)),[])},e.parse=(e,t={})=>{if(null==e||""===e.trim())return d("");const r=D(e),n=Object.keys(t).reduce(((e,r)=>{return{...e,[r]:(n=t[r],void 0===n.value||null===n.value||Number.isNaN(n.value)?{type:"literal",value:null,dataType:"null",options:{}}:{...n,value:c(n.dataType,n.value,n.options)})};var n}),{});return(e=>h((()=>j(e))))(I(r,n))},e.toString=e=>g(e),Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("decimal.js")):"function"==typeof define&&define.amd?define(["exports","decimal.js"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).formulon={},e.Decimal)}(this,(function(e,t){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=r(t),a=function(){function e(t,r,n,a){var u=Error.call(this,t);return Object.setPrototypeOf&&Object.setPrototypeOf(u,e.prototype),u.expected=r,u.found=n,u.location=a,u.name="SyntaxError",u}function t(e,t,r){return r=r||" ",e.length>t?e:(t-=e.length,e+(r+=r.repeat(t)).slice(0,t))}return function(e,t){function r(){this.constructor=e}r.prototype=t.prototype,e.prototype=new r}(e,Error),e.prototype.format=function(e){var r="Error: "+this.message;if(this.location){var n,a=null;for(n=0;n<e.length;n++)if(e[n].source===this.location.source){a=e[n].text.split(/\r\n|\n|\r/g);break}var u=this.location.start,o=this.location.source&&"function"==typeof this.location.source.offset?this.location.source.offset(u):u,i=this.location.source+":"+o.line+":"+o.column;if(a){var l=this.location.end,s=t("",o.line.toString().length," "),c=a[u.line-1],d=(u.line===l.line?l.column:c.length+1)-u.column||1;r+="\n --\x3e "+i+"\n"+s+" |\n"+o.line+" | "+c+"\n"+s+" | "+t("",u.column-1," ")+t("",d,"^")}else r+="\n at "+i}return r},e.buildMessage=function(e,t){var r={literal:function(e){return'"'+a(e.text)+'"'},class:function(e){var t=e.parts.map((function(e){return Array.isArray(e)?u(e[0])+"-"+u(e[1]):u(e)}));return"["+(e.inverted?"^":"")+t.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(e){return e.description}};function n(e){return e.charCodeAt(0).toString(16).toUpperCase()}function a(e){return e.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(e){return"\\x0"+n(e)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(e){return"\\x"+n(e)}))}function u(e){return e.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(e){return"\\x0"+n(e)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(e){return"\\x"+n(e)}))}function o(e){return r[e.type](e)}return"Expected "+function(e){var t,r,n=e.map(o);if(n.sort(),n.length>0){for(t=1,r=1;t<n.length;t++)n[t-1]!==n[t]&&(n[r]=n[t],r++);n.length=r}switch(n.length){case 1:return n[0];case 2:return n[0]+" or "+n[1];default:return n.slice(0,-1).join(", ")+", or "+n[n.length-1]}}(e)+" but "+function(e){return e?'"'+a(e)+'"':"end of input"}(t)+" found."},{SyntaxError:e,parse:function(t,r){var n,a={},u=(r=void 0!==r?r:{}).grammarSource,o={start:ke},i=ke,l="(",s=")",c="+",d="-",p="<=",f=">=",v="<>",m="==",h="!=",y="&&",g="||",b=/^[A-Za-z]/,x=/^[0-9]/,T=/^[1-9]/,$=/^[\n\r\u2028\u2029]/,w=Te("(",!1),C=Te(")",!1),A=Te("^",!1),k=Te("*",!1),E=Te("/",!1),M=Te("+",!1),U=Te("-",!1),O=Te("<=",!1),S=Te(">=",!1),F=Te("<>",!1),j=Te("<",!1),D=Te(">",!1),N=Te("==",!1),I=Te("=",!1),q=Te("!=",!1),R=Te("&&",!1),W=Te("||",!1),P=Te("&",!1),_=Te("!",!1),Z=Te(",",!1),L=$e([["A","Z"],["a","z"]],!1,!1),Y=Te("_",!1),z=Te("$",!1),Q=Te("[",!1),X=Te(".",!1),B=Te("]",!1),H=Te("0",!1),V=$e([["0","9"]],!1,!1),G=$e([["1","9"]],!1,!1),K=Te("true",!0),J=Te("false",!0),ee=Te("null",!0),te=Te("\\",!1),re=Te("'",!1),ne=Te('"',!1),ae={type:"any"},ue=$e(["\n","\r","\u2028","\u2029"],!1,!1),oe=Te("\t",!1),ie=Te("\v",!1),le=Te("\f",!1),se=Te(" ",!1),ce=Te(" ",!1),de=Te("​",!1),pe=Te("\ufeff",!1),fe=function(e,t){return function(e){const t=[],r=[];e.forEach((e=>{if("operator"===e.type){for(;t.length>0&&!(t[t.length-1].precedence<e.precedence);){let e=t.pop(),n=r.pop(),a=r.pop();r.push(He(e,a,n))}t.push(e)}else r.push(e)}));for(;t.length>0;){let e=t.pop(),n=r.pop(),a=r.pop();r.push(He(e,a,n))}return r.pop()}([e,t].flat(2))},ve=0,me=0,he=[{line:1,column:1}],ye=0,ge=[],be=0;if("startRule"in r){if(!(r.startRule in o))throw new Error("Can't start parsing from rule \""+r.startRule+'".');i=o[r.startRule]}function xe(){return t.substring(me,ve)}function Te(e,t){return{type:"literal",text:e,ignoreCase:t}}function $e(e,t,r){return{type:"class",parts:e,inverted:t,ignoreCase:r}}function we(e){var r,n=he[e];if(n)return n;for(r=e-1;!he[r];)r--;for(n={line:(n=he[r]).line,column:n.column};r<e;)10===t.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return he[e]=n,n}function Ce(e,t,r){var n=we(e),a=we(t),o={source:u,start:{offset:e,line:n.line,column:n.column},end:{offset:t,line:a.line,column:a.column}};return r&&u&&"function"==typeof u.offset&&(o.start=u.offset(o.start),o.end=u.offset(o.end)),o}function Ae(e){ve<ye||(ve>ye&&(ye=ve,ge=[]),ge.push(e))}function ke(){return Ee()}function Ee(){var e;return(e=Fe())===a&&(e=function(){var e,r,n;e=ve,r=function(){var e;33===t.charCodeAt(ve)?(e="!",ve++):(e=a,0===be&&Ae(_));return e}(),r!==a?(ze(),(n=Ee())!==a?(me=e,e={type:"callExpression",id:"not",arguments:[n]}):(ve=e,e=a)):(ve=e,e=a);return e}())===a&&(e=Ue())===a&&(e=De())===a&&(e=qe()),e}function Me(){var e,r,n,u;return(e=Ue())===a&&(e=De())===a&&(e=qe())===a&&(e=ve,40===t.charCodeAt(ve)?(r="(",ve++):(r=a,0===be&&Ae(w)),r!==a?(ze(),(n=Oe())!==a?(ze(),41===t.charCodeAt(ve)?(u=")",ve++):(u=a,0===be&&Ae(C)),u!==a?(me=e,e=n):(ve=e,e=a)):(ve=e,e=a)):(ve=e,e=a),e===a&&(e=ve,40===t.charCodeAt(ve)?(r="(",ve++):(r=a,0===be&&Ae(w)),r!==a?(ze(),(n=Fe())!==a?(ze(),41===t.charCodeAt(ve)?(u=")",ve++):(u=a,0===be&&Ae(C)),u!==a?(me=e,e=n):(ve=e,e=a)):(ve=e,e=a)):(ve=e,e=a))),e}function Ue(){var e,r,n,u;return e=ve,r=function(){var e,r,n;e=ve,r=[],b.test(t.charAt(ve))?(n=t.charAt(ve),ve++):(n=a,0===be&&Ae(L));if(n!==a)for(;n!==a;)r.push(n),b.test(t.charAt(ve))?(n=t.charAt(ve),ve++):(n=a,0===be&&Ae(L));else r=a;r!==a&&(me=e,r=r.join("").toLowerCase());return e=r}(),r!==a?(ze(),n=function(){var e,r,n,u;e=ve,40===t.charCodeAt(ve)?(r=l,ve++):(r=a,0===be&&Ae(w));r!==a?(ze(),n=ve,u=function(){var e,r,n,u;e=ve,r=[],n=ve,(u=Ee())!==a?(ze(),44===t.charCodeAt(ve)?ve++:0===be&&Ae(Z),ze(),me=n,n=u):(ve=n,n=a);if(n!==a)for(;n!==a;)r.push(n),n=ve,(u=Ee())!==a?(ze(),44===t.charCodeAt(ve)?ve++:0===be&&Ae(Z),ze(),me=n,n=u):(ve=n,n=a);else r=a;r!==a&&(me=e);return e=r}(),u!==a?n=u=[u,ze()]:(ve=n,n=a),n===a&&(n=null),41===t.charCodeAt(ve)?(u=s,ve++):(u=a,0===be&&Ae(C)),u!==a?(me=e,e=n):(ve=e,e=a)):(ve=e,e=a);return e}(),n!==a?(me=e,e={type:"callExpression",id:r,arguments:(u=n,null!==u?u[0]:[])}):(ve=e,e=a)):(ve=e,e=a),e}function Oe(){var e,t,r,n;if(e=ve,(t=Me())!==a){for(ze(),r=[],n=Se();n!==a;)r.push(n),n=Se();me=e,e=fe(t,r)}else ve=e,e=a;return e}function Se(){var e,r,n,u,o;return e=ve,ze(),r=function(){var e;94===t.charCodeAt(ve)?(e="^",ve++):(e=a,0===be&&Ae(A));e===a&&(42===t.charCodeAt(ve)?(e="*",ve++):(e=a,0===be&&Ae(k)),e===a&&(47===t.charCodeAt(ve)?(e="/",ve++):(e=a,0===be&&Ae(E)),e===a&&(43===t.charCodeAt(ve)?(e=c,ve++):(e=a,0===be&&Ae(M)),e===a&&(45===t.charCodeAt(ve)?(e=d,ve++):(e=a,0===be&&Ae(U))))));return e}(),r!==a?(ze(),(n=Me())!==a?(me=e,u=r,o=n,e=[Object.assign({type:"operator"},Xe[u]),o]):(ve=e,e=a)):(ve=e,e=a),e}function Fe(){var e,r,n,u;return e=ve,(r=je())!==a?(ze(),n=function(){var e;t.substr(ve,2)===y?(e=y,ve+=2):(e=a,0===be&&Ae(R));e===a&&(t.substr(ve,2)===g?(e=g,ve+=2):(e=a,0===be&&Ae(W)));return e}(),n!==a?(ze(),(u=Fe())!==a?(me=e,e=function(e,t,r){var n;switch(t){case"||":n="or";break;case"&&":n="and"}return{type:"callExpression",id:n,arguments:[e,r]}}(r,n,u)):(ve=e,e=a)):(ve=e,e=a)):(ve=e,e=a),e===a&&(e=je()),e}function je(){var e,r,n,u;return e=ve,(r=Oe())!==a?(ze(),n=function(){var e;t.substr(ve,2)===p?(e=p,ve+=2):(e=a,0===be&&Ae(O));e===a&&(t.substr(ve,2)===f?(e=f,ve+=2):(e=a,0===be&&Ae(S)),e===a&&(t.substr(ve,2)===v?(e=v,ve+=2):(e=a,0===be&&Ae(F)),e===a&&(60===t.charCodeAt(ve)?(e="<",ve++):(e=a,0===be&&Ae(j)),e===a&&(62===t.charCodeAt(ve)?(e=">",ve++):(e=a,0===be&&Ae(D)),e===a&&(t.substr(ve,2)===m?(e=m,ve+=2):(e=a,0===be&&Ae(N)),e===a&&(61===t.charCodeAt(ve)?(e="=",ve++):(e=a,0===be&&Ae(I)),e===a&&(t.substr(ve,2)===h?(e=h,ve+=2):(e=a,0===be&&Ae(q)))))))));return e}(),n===a&&(n=function(){var e;38===t.charCodeAt(ve)?(e="&",ve++):(e=a,0===be&&Ae(P));return e}()),n!==a?(ze(),(u=je())!==a?(me=e,e=function(e,t,r){var n;switch(t){case"<":n="lessThan";break;case"<=":n="lessThanOrEqual";break;case">":n="greaterThan";break;case">=":n="greaterThanOrEqual";break;case"==":case"=":n="equal";break;case"!=":case"<>":n="unequal";break;case"&":n="add"}return{type:"callExpression",id:n,arguments:[e,r]}}(r,n,u)):(ve=e,e=a)):(ve=e,e=a)):(ve=e,e=a),e===a&&(e=Oe()),e}function De(){var e,t,r;return e=ve,t=ve,be++,r=function(){var e;(e=Pe())===a&&(e=_e());return e}(),be--,r===a?t=void 0:(ve=t,t=a),t!==a?(r=function(){var e,t,r,n;if(e=ve,(t=Ne())!==a){for(r=[],n=Ie();n!==a;)r.push(n),n=Ie();me=e,e={type:"identifier",name:t+r.join("")}}else ve=e,e=a;return e}(),r!==a?(me=e,e=r):(ve=e,e=a)):(ve=e,e=a),e}function Ne(){var e;return 95===t.charCodeAt(ve)?(e="_",ve++):(e=a,0===be&&Ae(Y)),e===a&&(36===t.charCodeAt(ve)?(e="$",ve++):(e=a,0===be&&Ae(z)),e===a&&(91===t.charCodeAt(ve)?(e="[",ve++):(e=a,0===be&&Ae(Q)),e===a&&(b.test(t.charAt(ve))?(e=t.charAt(ve),ve++):(e=a,0===be&&Ae(L))))),e}function Ie(){var e;return(e=Ne())===a&&(46===t.charCodeAt(ve)?(e=".",ve++):(e=a,0===be&&Ae(X)),e===a&&(93===t.charCodeAt(ve)?(e="]",ve++):(e=a,0===be&&Ae(B)),e===a&&(e=We()))),e}function qe(){var e;return(e=function(){var e,t,r;if(e=ve,Le()!==a){for(t=[],(r=Ze())===a&&(r=Ye());r!==a;)t.push(r),(r=Ze())===a&&(r=Ye());(r=Le())!==a?(me=e,e=Be(t)):(ve=e,e=a)}else ve=e,e=a;if(e===a)if(e=ve,Ye()!==a){for(t=[],(r=Ze())===a&&(r=Le());r!==a;)t.push(r),(r=Ze())===a&&(r=Le());(r=Ye())!==a?(me=e,e=function(e){return Be(e)}(t)):(ve=e,e=a)}else ve=e,e=a;return e}())===a&&(e=function(){var e,r,n,u,o,i;e=ve,r=ve,n=ze(),43===t.charCodeAt(ve)?(u=c,ve++):(u=a,0===be&&Ae(M));u!==a?r=n=[n,u]:(ve=r,r=a);r===a&&(r=ve,45===t.charCodeAt(ve)?(n=d,ve++):(n=a,0===be&&Ae(U)),n!==a?r=n=[n,u=ze()]:(ve=r,r=a));r===a&&(r=null);if((n=Re())!==a)if(46===t.charCodeAt(ve)?(u=".",ve++):(u=a,0===be&&Ae(X)),u!==a){for(o=[],i=We();i!==a;)o.push(i),i=We();me=e,l=xe().replace(/[\+\-]/g,"").split("."),e={type:"literal",value:parseFloat(xe()),dataType:"number",options:{length:l[0].length,scale:l[1].length}}}else ve=e,e=a;else ve=e,e=a;var l;e===a&&(e=ve,r=ve,n=ze(),43===t.charCodeAt(ve)?(u=c,ve++):(u=a,0===be&&Ae(M)),u!==a?r=n=[n,u]:(ve=r,r=a),r===a&&(r=ve,45===t.charCodeAt(ve)?(n=d,ve++):(n=a,0===be&&Ae(U)),n!==a?r=n=[n,u=ze()]:(ve=r,r=a)),r===a&&(r=null),(n=Re())!==a?(me=e,e={type:"literal",value:parseInt(xe()),dataType:"number",options:{length:xe().replace(/[\+\-]/g,"").length,scale:0}}):(ve=e,e=a));return e}())===a&&(e=Pe())===a&&(e=_e()),e}function Re(){var e,r,n,u;if(48===t.charCodeAt(ve)?(e="0",ve++):(e=a,0===be&&Ae(H)),e===a)if(e=ve,r=function(){var e;T.test(t.charAt(ve))?(e=t.charAt(ve),ve++):(e=a,0===be&&Ae(G));return e}(),r!==a){for(n=[],u=We();u!==a;)n.push(u),u=We();e=r=[r,n]}else ve=e,e=a;return e}function We(){var e;return x.test(t.charAt(ve))?(e=t.charAt(ve),ve++):(e=a,0===be&&Ae(V)),e}function Pe(){var e,r;return e=ve,"true"===t.substr(ve,4).toLowerCase()?(r=t.substr(ve,4),ve+=4):(r=a,0===be&&Ae(K)),r!==a&&(me=e,r={type:"literal",value:!0,dataType:"checkbox",options:{}}),(e=r)===a&&(e=ve,"false"===t.substr(ve,5).toLowerCase()?(r=t.substr(ve,5),ve+=5):(r=a,0===be&&Ae(J)),r!==a&&(me=e,r={type:"literal",value:!1,dataType:"checkbox",options:{}}),e=r),e}function _e(){var e,r;return e=ve,"null"===t.substr(ve,4).toLowerCase()?(r=t.substr(ve,4),ve+=4):(r=a,0===be&&Ae(ee)),r!==a&&(me=e,r={type:"literal",value:null,dataType:"null",options:{}}),e=r}function Ze(){var e,r,n;return e=ve,r=ve,be++,n=function(){var e;(e=Le())===a&&(e=Ye());return e}(),n===a&&(92===t.charCodeAt(ve)?(n="\\",ve++):(n=a,0===be&&Ae(te))),be--,n===a?r=void 0:(ve=r,r=a),r!==a?(n=function(){var e;t.length>ve?(e=t.charAt(ve),ve++):(e=a,0===be&&Ae(ae));return e}(),n!==a?(me=e,e=xe()):(ve=e,e=a)):(ve=e,e=a),e}function Le(){var e;return 39===t.charCodeAt(ve)?(e="'",ve++):(e=a,0===be&&Ae(re)),e}function Ye(){var e;return 34===t.charCodeAt(ve)?(e='"',ve++):(e=a,0===be&&Ae(ne)),e}function ze(){var e,t;for(e=[],t=Qe();t!==a;)e.push(t),t=Qe();return e}function Qe(){var e;return 9===t.charCodeAt(ve)?(e="\t",ve++):(e=a,0===be&&Ae(oe)),e===a&&(e=function(){var e;return $.test(t.charAt(ve))?(e=t.charAt(ve),ve++):(e=a,0===be&&Ae(ue)),e}())===a&&(11===t.charCodeAt(ve)?(e="\v",ve++):(e=a,0===be&&Ae(ie)),e===a&&(12===t.charCodeAt(ve)?(e="\f",ve++):(e=a,0===be&&Ae(le)),e===a&&(32===t.charCodeAt(ve)?(e=" ",ve++):(e=a,0===be&&Ae(se)),e===a&&(160===t.charCodeAt(ve)?(e=" ",ve++):(e=a,0===be&&Ae(ce)),e===a&&(8203===t.charCodeAt(ve)?(e="​",ve++):(e=a,0===be&&Ae(de)),e===a&&(65279===t.charCodeAt(ve)?(e="\ufeff",ve++):(e=a,0===be&&Ae(pe)))))))),e}const Xe={"^":{functionName:"exponentiate",rightAssociative:!0,precedence:4},"*":{functionName:"multiply",rightAssociative:!1,precedence:3},"/":{functionName:"divide",rightAssociative:!1,precedence:3},"+":{functionName:"add",rightAssociative:!1,precedence:2},"-":{functionName:"subtract",rightAssociative:!1,precedence:2}};function Be(e){return{type:"literal",value:e.join(""),dataType:"text",options:{length:e.length}}}function He(e,t,r){return{type:"callExpression",id:e.functionName,arguments:[t,r]}}if((n=i())!==a&&ve===t.length)return n;throw n!==a&&ve<t.length&&Ae({type:"end"}),Ve=ge,Ge=ye<t.length?t.charAt(ye):null,Ke=ye<t.length?Ce(ye,ye+1):Ce(ye,ye),new e(e.buildMessage(Ve,Ge),Ve,Ge,Ke);var Ve,Ge,Ke}}}(),u=function(){function e(t,r,n,a){var u=Error.call(this,t);return Object.setPrototypeOf&&Object.setPrototypeOf(u,e.prototype),u.expected=r,u.found=n,u.location=a,u.name="SyntaxError",u}function t(e,t,r){return r=r||" ",e.length>t?e:(t-=e.length,e+(r+=r.repeat(t)).slice(0,t))}return function(e,t){function r(){this.constructor=e}r.prototype=t.prototype,e.prototype=new r}(e,Error),e.prototype.format=function(e){var r="Error: "+this.message;if(this.location){var n,a=null;for(n=0;n<e.length;n++)if(e[n].source===this.location.source){a=e[n].text.split(/\r\n|\n|\r/g);break}var u=this.location.start,o=this.location.source&&"function"==typeof this.location.source.offset?this.location.source.offset(u):u,i=this.location.source+":"+o.line+":"+o.column;if(a){var l=this.location.end,s=t("",o.line.toString().length," "),c=a[u.line-1],d=(u.line===l.line?l.column:c.length+1)-u.column||1;r+="\n --\x3e "+i+"\n"+s+" |\n"+o.line+" | "+c+"\n"+s+" | "+t("",u.column-1," ")+t("",d,"^")}else r+="\n at "+i}return r},e.buildMessage=function(e,t){var r={literal:function(e){return'"'+a(e.text)+'"'},class:function(e){var t=e.parts.map((function(e){return Array.isArray(e)?u(e[0])+"-"+u(e[1]):u(e)}));return"["+(e.inverted?"^":"")+t.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(e){return e.description}};function n(e){return e.charCodeAt(0).toString(16).toUpperCase()}function a(e){return e.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(e){return"\\x0"+n(e)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(e){return"\\x"+n(e)}))}function u(e){return e.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(e){return"\\x0"+n(e)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(e){return"\\x"+n(e)}))}function o(e){return r[e.type](e)}return"Expected "+function(e){var t,r,n=e.map(o);if(n.sort(),n.length>0){for(t=1,r=1;t<n.length;t++)n[t-1]!==n[t]&&(n[r]=n[t],r++);n.length=r}switch(n.length){case 1:return n[0];case 2:return n[0]+" or "+n[1];default:return n.slice(0,-1).join(", ")+", or "+n[n.length-1]}}(e)+" but "+function(e){return e?'"'+a(e)+'"':"end of input"}(t)+" found."},{SyntaxError:e,parse:function(t,r){var n,a,u,o,i={},l=(r=void 0!==r?r:{}).grammarSource,s={Time:E},c=E,d=/^[0-9]/,p=w(":",!1),f=w(".",!1),v={type:"class",parts:[["0","9"]],inverted:!1,ignoreCase:!1},m=function(e,t,r,n){return function(e,t,r,n){e>23&&$("hour part needs to be under 24");t>59&&$("minute part needs to be under 60");r>59&&$("second part needs to be under 60");n>999&&$("millisecond part needs to be under 1000")}(e,t,r,n),{type:"literal",value:new Date(n+1e3*r+60*t*1e3+60*e*60*1e3),dataType:"time",options:{}}},h=0,y=0,g=[{line:1,column:1}],b=0,x=[];if("startRule"in r){if(!(r.startRule in s))throw new Error("Can't start parsing from rule \""+r.startRule+'".');c=s[r.startRule]}function T(){return t.substring(y,h)}function $(t,r){throw function(t,r){return new e(t,null,null,r)}(t,r=void 0!==r?r:A(y,h))}function w(e,t){return{type:"literal",text:e,ignoreCase:t}}function C(e){var r,n=g[e];if(n)return n;for(r=e-1;!g[r];)r--;for(n={line:(n=g[r]).line,column:n.column};r<e;)10===t.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return g[e]=n,n}function A(e,t,r){var n=C(e),a=C(t),u={source:l,start:{offset:e,line:n.line,column:n.column},end:{offset:t,line:a.line,column:a.column}};return r&&l&&"function"==typeof l.offset&&(u.start=l.offset(u.start),u.end=l.offset(u.end)),u}function k(e){h<b||(h>b&&(b=h,x=[]),x.push(e))}function E(){var e,r,n,a,u,o,l,s;return e=h,r=function(){var e;e=h,M()!==i&&M()!==i?(y=e,e=parseInt(T())):(h=e,e=i);return e}(),r!==i?(58===t.charCodeAt(h)?(n=":",h++):(n=i,k(p)),n!==i?(a=function(){var e;e=h,M()!==i&&M()!==i?(y=e,e=parseInt(T())):(h=e,e=i);return e}(),a!==i?(58===t.charCodeAt(h)?(u=":",h++):(u=i,k(p)),u!==i?(o=function(){var e;e=h,M()!==i&&M()!==i?(y=e,e=parseInt(T())):(h=e,e=i);return e}(),o!==i?(46===t.charCodeAt(h)?(l=".",h++):(l=i,k(f)),l!==i?(s=function(){var e;e=h,M()!==i&&M()!==i&&M()!==i?(y=e,e=parseInt(T())):(h=e,e=i);return e}(),s!==i?(y=e,e=m(r,a,o,s)):(h=e,e=i)):(h=e,e=i)):(h=e,e=i)):(h=e,e=i)):(h=e,e=i)):(h=e,e=i)):(h=e,e=i),e}function M(){var e;return d.test(t.charAt(h))?(e=t.charAt(h),h++):(e=i,k(v)),e}if((n=c())!==i&&h===t.length)return n;throw n!==i&&h<t.length&&k({type:"end"}),a=x,u=b<t.length?t.charAt(b):null,o=b<t.length?A(b,b+1):A(b,b),new e(e.buildMessage(a,u),a,u,o)}}}();class o extends Error{constructor(e,t,r){super(e),this.errorType=t,this.options=r}}const i=864e5,l=(e,t)=>{if(e<0)return-1*l(-1*e,t);const r=10**t;return Math.round(e*r)/r},s=e=>{const t=e.toString().replace("-","");if(-1!==t.indexOf(".")){const e=t.split(".");return{length:e[0].length,scale:e[1].length}}return{length:t.length,scale:0}},c=(e,t,r)=>{switch(e){case"number":return l(t,r.scale);case"text":return t.substring(0,r.length);default:return t}},d=e=>{const t={type:"literal",value:e};if(null==e)return Object.assign(t,{value:null,dataType:"null",options:{}});const r=typeof e;switch(typeof e){case"number":return Object.assign(t,{dataType:"number",options:s(e)});case"string":return Object.assign(t,{dataType:"text",options:{length:e.length}});case"boolean":return Object.assign(t,{dataType:"checkbox",options:{}});default:throw new TypeError(`Unsupported type '${r}'`)}},p=(e,t,r)=>({type:"error",errorType:e,message:t,...r}),f=(e,t,r)=>e instanceof Date?f(e.getUTCFullYear(),e.getUTCMonth()+1,e.getUTCDate()):{type:"literal",dataType:"date",value:new Date(Date.UTC(e,t-1,r)),options:{}},v=e=>({type:"literal",dataType:"datetime",value:new Date(e),options:{}}),m=e=>({type:"literal",dataType:"time",value:new Date(e),options:{}}),h=e=>{try{return e()}catch(e){if(e instanceof o)return p(e.errorType,e.message,e.options);throw e}},y=(e,t)=>new Date(e.getTime()+t*i),g=e=>{if(!e.value&&"null"!==e.dataType&&0!==e.value&&!1!==e.value&&""!==e.value)return"";switch(e.dataType){case"null":return"NULL";case"number":return e.value.toString();case"text":case"picklist":return`"${e.value}"`;case"multipicklist":return`[${e.value.map((e=>`"${e}"`)).join(", ")}]`;case"checkbox":return e.value.toString().toUpperCase();case"date":return`${e.value.getUTCFullYear()}-${(e.value.getUTCMonth()+1).toString().padStart(2,"0")}-${e.value.getUTCDate().toString().padStart(2,"0")}`;case"datetime":return e.value.toISOString();case"time":return e.value.toISOString().split("T")[1].replace("Z","");case"geolocation":return t=e.value[0],r=e.value[1],t&&r||0===t||0===r?`${t.toFixed(6)}, ${r.toFixed(6)}`:"";default:return}var t,r};class b extends o{constructor(e,t){super(e,"NotImplementedError",t)}static throwError(e){throw new b(`Function ${e} not implemented yet.`,{name:e})}}const x=e=>Array.isArray(e)?e.map((e=>x(e))).join(", "):"string"!=typeof e?"":e.charAt(0).toUpperCase()+e.slice(1);class T extends o{constructor(e,t){super(e,"ArgumentError",t)}static throwWrongType(e,t,r){const n={function:e,expected:t,received:r},a=r||"Non-Salesforce";throw new T(`Incorrect parameter type for function '${e.toUpperCase()}()'. Expected ${x(t)}, received ${x(a)}`,n)}static throwIncorrectNumberOfArguments(e,t,r){const n={function:e,expected:t,received:r};throw new T(`Incorrect number of parameters for function '${e.toUpperCase()}()'. Expected ${t}, received ${r}`,n)}}const $=(e,t)=>{switch(e.dataType){case"date":case"datetime":return d(e.value.getTime()===t.value.getTime());default:return d(e.value===t.value)}},w=(e,t,r)=>d(e.value.substr(t.value-1,r.value)),C=(e,t)=>w(e,d(1),t);var A=Object.freeze({__proto__:null,sf$or:(...e)=>{const t=e.map((e=>e.value)).reduce(((e,t)=>e||t));return d(t)},sf$equal:$,sf$unequal:(e,t)=>d(!$(e,t).value),sf$greaterThan:(e,t)=>d(e.value>t.value),sf$greaterThanOrEqual:(e,t)=>d(e.value>=t.value),sf$lessThan:(e,t)=>d(e.value<t.value),sf$lessThanOrEqual:(e,t)=>d(e.value<=t.value),sf$addmonths:(e,t)=>f(((e,t)=>{const r=e.getUTCMonth()+t,n=new Date(Date.UTC(e.getUTCFullYear(),r,e.getUTCDate()));return e.getUTCDate()!==n.getUTCDate()&&n.setUTCDate(0),n})(e.value,t.value)),sf$date:(e,t,r)=>f(e.value,t.value,r.value),sf$datevalue:e=>f(new Date(Date.parse(e.value))),sf$datetimevalue:e=>v(Date.parse(`${e.value}Z`)),sf$day:e=>d(e.value.getUTCDate()),sf$hour:e=>d(e.value.getUTCHours()),sf$millisecond:e=>d(e.value.getUTCMilliseconds()),sf$minute:e=>d(e.value.getUTCMinutes()),sf$month:e=>d(e.value.getUTCMonth()+1),sf$now:()=>v((new Date).getTime()),sf$second:e=>d(e.value.getUTCSeconds()),sf$timenow:()=>m((new Date).getTime()%864e5),sf$timevalue:e=>(e=>{try{return u.parse(e)}catch(e){if(e instanceof u.SyntaxError)return d(null);throw e}})(e.value),sf$today:()=>f(new Date),sf$weekday:e=>d(e.value.getUTCDay()+1),sf$year:e=>d(e.value.getUTCFullYear()),sf$and:(...e)=>{const t=e.map((e=>e.value)).reduce(((e,t)=>e&&t));return d(t)},sf$blankvalue:(e,t)=>"null"===e.dataType||""===e.value?t:e,sf$case:(e,...t)=>{const r=t.length-1;if(r<=0){const e={function:"case",expected:4,received:r+2};throw new T(`Incorrect number of parameters for function '${e.function.toUpperCase()}()'. Expected ${e.expected}+, received ${e.received}`,e)}if(r%2!=0){const e={function:"case",expected:r+1,received:r+2};throw new T(`Incorrect number of parameters for function '${e.function.toUpperCase()}()'. Expected ${e.expected}, received ${e.received}`,e)}for(let n=0;n<r;n+=2)if($(t[n],e).value)return t[n+1];return t[r]},sf$if:(e,t,r)=>e.value?t:r,sf$isblank:e=>d("null"===e.dataType||""===e.value),sf$isnull:e=>d("null"===e.dataType),sf$isnumber:e=>{b.throwError("isnumber")},sf$not:e=>d(!e.value),sf$nullvalue:(e,t)=>"null"===e.dataType?t:e,sf$add:(e,t)=>{switch([e.dataType,t.dataType].join(" ")){case"date number":return f(y(e.value,t.value));case"number date":return f(y(t.value,e.value));case"time number":return m(e.value.getTime()+t.value);case"number time":return m(e.value+t.value.getTime());case"datetime number":return v(y(e.value,t.value));case"number datetime":return v(y(t.value,e.value));case"number number":return d(new n.default(e.value).plus(new n.default(t.value)).toNumber());case"text text":return d(e.value+t.value);case"text null":return e;default:T.throwWrongType("add","number",t.dataType)}},sf$subtract:(e,t)=>{switch([e.dataType,t.dataType].join(" ")){case"date number":return f(y(e.value,-1*t.value));case"time number":return m(e.value.getTime()+-1*t.value);case"datetime number":return v(y(e.value,-1*t.value));case"date date":case"datetime datetime":return d((r=e.value,a=t.value,(r.getTime()-a.getTime())/i));case"time time":return d(e.value.getTime()-t.value.getTime());case"number number":return d(new n.default(e.value).minus(new n.default(t.value)).toNumber());case"text text":return d(e.value-t.value);default:T.throwWrongType("subtract","number",t.dataType)}var r,a},sf$multiply:(e,t)=>("number number"!==[e.dataType,t.dataType].join(" ")&&T.throwWrongType("multiply","number",t.dataType),d(new n.default(e.value).times(new n.default(t.value)).toNumber())),sf$divide:(e,t)=>("number number"!==[e.dataType,t.dataType].join(" ")&&T.throwWrongType("divide","number",t.dataType),d(new n.default(e.value).dividedBy(new n.default(t.value)).toNumber())),sf$exponentiate:(e,t)=>("number number"!==[e.dataType,t.dataType].join(" ")&&T.throwWrongType("exponentiate","number",t.dataType),d(new n.default(e.value).toPower(new n.default(t.value)).toNumber())),sf$abs:e=>d(Math.abs(e.value)),sf$ceiling:e=>e.value<0?d(-1*Math.ceil(-1*e.value)):d(Math.ceil(e.value)),sf$distance:(e,t,r)=>{const n=r.value;if("km"!==n&&"mi"!==n){throw new T(`Incorrect parameter value for function 'DISTANCE()'. Expected 'mi'/'km', received '${n}'`,{function:"distance",expected:["km","mi"],received:n})}const[a,u]=e.value,[o,i]=t.value;if(a===o&&u===i)return d(0);const l=a*Math.PI/180,s=o*Math.PI/180,c=(o-a)*Math.PI/180,p=(i-u)*Math.PI/180,f=Math.sin(c/2)*Math.sin(c/2)+Math.cos(l)*Math.cos(s)*Math.sin(p/2)*Math.sin(p/2),v=6371009*(2*Math.atan2(Math.sqrt(f),Math.sqrt(1-f)))/1e3;return d("mi"===n?v/1.609344:v)},sf$exp:e=>d(Math.exp(e.value)),sf$floor:e=>e.value<0?d(-1*Math.floor(-1*e.value)):d(Math.floor(e.value)),sf$geolocation:(e,t)=>((e,t)=>({type:"literal",dataType:"geolocation",value:[e,t],options:{}}))(e.value,t.value),sf$ln:e=>d(Math.log(e.value)),sf$log:e=>d(Math.log10(e.value)),sf$max:(...e)=>{const t=e.map((e=>e.value));return d(Math.max(...t))},sf$mceiling:e=>d(Math.ceil(e.value)),sf$mfloor:e=>d(Math.floor(e.value)),sf$min:(...e)=>{const t=e.map((e=>e.value));return d(Math.min(...t))},sf$mod:(e,t)=>d(e.value%t.value),sf$round:(e,t)=>d(l(e.value,t.value)),sf$sqrt:e=>d(Math.sqrt(e.value)),sf$begins:(e,t)=>d(e.value.startsWith(t.value)),sf$br:()=>d("\n"),sf$casesafeid:e=>{let t="";return[0,1,2].forEach((r=>{let n=0;[0,1,2,3,4].forEach((t=>{const a=e.value[5*r+t];a.toUpperCase()===a&&a>="A"&&a<="Z"&&(n+=1<<t)})),t+="ABCDEFGHIJKLMNOPQRSTUVWXYZ012345"[n]})),d(e.value+t)},sf$concat:(e,t)=>d(e.value+t.value),sf$contains:(e,t)=>d(e.value.includes(t.value)),sf$find:(e,t,r=d(1))=>{if(r.value<=0||""===e.value)return d(0);const n=t.value.substring(r.value-1);return d(n.indexOf(e.value)+1)},sf$getsessionid:()=>d("00D3z000001eRlg!AQMAQC3Y4aM9sFux6SRWhyFcOUKin4taGaBxNMU8TN_R_1R0Y7ArI95eSyzQZVIlrnV_unTbmwHZlXex8xhlXz2kXZNP49Fa"),sf$hyperlink:(e,t,r=null)=>{const n=r?` target="${r.value}"`:"";return d(`<a href="${e.value}"${n}>${t.value}</a>`)},sf$image:(e,t,r=null,n=null)=>{const a=r?` height="${r.value}"`:"",u=n?` width="${n.value}"`:"";return d(`<img src="${e.value}" alt="${t.value}"${a}${u}/>`)},sf$includes:(e,t)=>d(e.value.includes(t.value)),sf$ispickval:(e,t)=>d(e.value===t.value),sf$mid:w,sf$left:C,sf$len:e=>d(e.value.length),sf$lower:(e,t)=>d(e.value.toLowerCase()),sf$lpad:(e,t,r)=>{if(null==r)return e;if(t.value<e.value.length)return C(e,t);const n=r.value.repeat(t.value);return d((n+e.value).slice(-t.value))},sf$right:(e,t)=>d(e.value.substr(e.value.length-t.value)),sf$rpad:(e,t,r)=>{if(null==r)return e;if(t.value<e.value.length)return C(e,t);const n=r.value.repeat(t.value);return d((e.value+n).substr(0,t.value))},sf$substitute:(e,t,r)=>d(e.value.replace(new RegExp(t.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),r.value)),sf$text:e=>"datetime"===e.dataType?d(g(e).replace("T"," ").replace(/\.\d{3}/,"")):"picklist"===e.dataType?d(e.value):d(g(e)),sf$trim:e=>d(e.value.trim()),sf$upper:(e,t)=>d(e.value.toUpperCase()),sf$value:e=>{const t=parseFloat(e.value);return d(t||null)},sf$currencyrate:e=>{b.throwError("currencyrate")},sf$regex:(e,t)=>{const r=new RegExp(`^${t.value}$`);return d(null!=r.exec(e.value))}});const k=e=>t=>r=>{r.length<e&&T.throwIncorrectNumberOfArguments(t,e,r.length)},E=e=>t=>r=>{r.length>e&&T.throwIncorrectNumberOfArguments(t,e,r.length)},M=(...e)=>t=>r=>{r.map(((t,r)=>[t.dataType,e[r]||e[e.length-1]])).forEach((([e,r])=>{"null"!==e&&(Array.isArray(r)?-1===r.indexOf(e)&&T.throwWrongType(t,r,e):e!==r&&T.throwWrongType(t,r,e))}))},U=()=>e=>t=>{const r=t.filter((e=>"null"!==e.dataType));r.length>0&&r.reduce(((t,r)=>(t.dataType!==r.dataType&&T.throwWrongType(e,t.dataType,r.dataType),r)))};class O extends o{constructor(e,t){super(e,"NoFunctionError",t)}}const S={abs:{validations:[k(1),E(1),M("number")],returnType:"number"},add:{validations:[k(2),E(2),M(["number","text","date","datetime","time"],["number","text","date","datetime","time"])],returnType:["number","text","date","datetime","time"]},addmonths:{validations:[k(2),E(2),M(["date","datetime"],["number"])],returnType:["date","datetime"]},and:{validations:[k(1),M("checkbox")],returnType:"checkbox"},begins:{validations:[k(2),E(2),M("text","text")],returnType:"checkbox"},blankvalue:{validations:[k(2),E(2),M(["text","number","date","datetime","geolocation"]),U()],returnType:["text","number"]},br:{validations:[k(0),E(0)],returnType:"text"},case:{validations:[k(4),M(["text","number","picklist","date","datetime"]),e=>t=>{const r="picklist"===t[0].dataType?"text":t[0].dataType,n=t.filter(((e,r)=>r%2==1&&r!==t.length-1)).find((e=>e.dataType!==r));n&&T.throwWrongType(e,r,n.dataType)}],returnType:["text","number","date","datetime"]},casesafeid:{validations:[k(1),E(1),M("text")],returnType:"text"},ceiling:{validations:[k(1),E(1),M("number")],returnType:"number"},contains:{validations:[k(2),E(2),M("text","text")],returnType:"checkbox"},currencyrate:{validations:[k(1),E(1),M("text")],returnType:"text"},date:{validations:[k(3),E(3),M("number","number","number")],returnType:"date"},datetimevalue:{validations:[k(1),E(1),M("text","date","datetime")],returnType:"datetime"},datevalue:{validations:[k(1),E(1),M(["text","date","datetime"])],returnType:"date"},day:{validations:[k(1),E(1),M("date")],returnType:"number"},distance:{validations:[k(3),E(3),M("geolocation","geolocation","text")],returnType:"number"},divide:{validations:[k(2),E(2),M("number","number")],returnType:"number"},equal:{validations:[k(2),E(2),M(["text","number","date","datetime","checkbox"]),U()],returnType:"checkbox"},exp:{validations:[k(1),E(1),M("number")],returnType:"number"},exponentiate:{validations:[k(2),E(2),M("number","number")],returnType:"number"},find:{validations:[k(2),E(3),M("text","text","number")],returnType:"number"},floor:{validations:[k(1),E(1),M("number")],returnType:"number"},geolocation:{validations:[k(2),E(2),M("number","number")],returnType:"geolocation"},getsessionid:{validations:[k(0),E(0)],returnType:"text"},greaterThan:{validations:[k(2),E(2),M(["number","date","datetime"]),U()],returnType:"checkbox"},greaterThanOrEqual:{validations:[k(2),E(2),M(["number","date","datetime"])],returnType:"checkbox"},hour:{validations:[k(1),E(1),M("datetime")],returnType:"number"},hyperlink:{validations:[k(2),E(3),M("text","text","text")],returnType:"text"},if:{validations:[k(3),E(3),M("checkbox",["text","number","date","datetime","checkbox","geolocation"],["text","number","date","datetime","checkbox","geolocation"])],returnType:["text","number","date","datetime","checkbox","geolocation"]},image:{validations:[k(2),E(4),M("text","text","number","number")],returnType:"text"},includes:{validations:[k(2),E(2),M("multipicklist","text")],returnType:"checkbox"},isblank:{validations:[k(1),E(1),M(["text","number","date","datetime","geolocation"])],returnType:"checkbox"},isnull:{validations:[k(1),E(1),M(["text","number","date","datetime","geolocation"])],returnType:"checkbox"},ispickval:{validations:[k(2),E(2),M("picklist","text")],returnType:"checkbox"},isnumber:{validations:[k(1),E(1),M("text")],returnType:"checkbox"},left:{validations:[k(2),E(2),M("text","number")],returnType:"text"},len:{validations:[k(1),E(1),M("text")],returnType:"number"},lessThan:{validations:[k(2),E(2),M(["number","date","datetime"]),U()],returnType:"checkbox"},lessThanOrEqual:{validations:[k(2),E(2),M(["number","date","datetime"]),U()],returnType:"checkbox"},ln:{validations:[k(1),E(1),M("number")],returnType:"number"},log:{validations:[k(1),E(1),M("number")],returnType:"checkbox"},lower:{validations:[k(1),E(1),M("text")],returnType:"text"},lpad:{validations:[k(2),E(3),M("text","number","text")],returnType:"text"},max:{validations:[k(1),M("number")],returnType:"number"},mceiling:{validations:[k(1),E(1),M("number")],returnType:"number"},mfloor:{validations:[k(1),E(1),M("number")],returnType:"number"},mid:{validations:[k(3),E(3),M("text","number","number")],returnType:"number"},millisecond:{validations:[k(1),E(1),M("datetime")],returnType:"number"},min:{validations:[k(1),M("number")],returnType:"number"},minute:{validations:[k(1),E(1),M("datetime")],returnType:"number"},mod:{validations:[k(2),E(2),M("number","number")],returnType:"number"},month:{validations:[k(1),E(1),M("date")],returnType:"number"},multiply:{validations:[k(2),E(2),M("number","number")],returnType:"number"},not:{validations:[k(1),E(1),M("checkbox")],returnType:"checkbox"},now:{validations:[k(0),E(0)],returnType:"datetime"},nullvalue:{validations:[k(2),E(2),M(["text","number","date","datetime","geolocation"]),U()],returnType:["text","number"]},or:{validations:[k(1),M("checkbox")],returnType:"checkbox"},regex:{validations:[k(2),E(2),M("text","text")],returnType:"text"},right:{validations:[k(2),E(2),M("text","number")],returnType:"text"},round:{validations:[k(2),E(2),M("number","number")],returnType:"number"},rpad:{validations:[k(2),E(3),M("text","number","text")],returnType:"text"},second:{validations:[k(1),E(1),M("datetime")],returnType:"number"},sqrt:{validations:[k(1),E(1),M("number")],returnType:"number"},subtract:{validations:[k(2),E(2),M(["number","date","datetime","time"],["number","date","datetime","time"])],returnType:["number","date","datetime","time"]},substitute:{validations:[k(3),E(3),M("text","text","text")],returnType:"text"},text:{validations:[k(1),E(1),M(["number","date","datetime","picklist","time"])],returnType:"text"},timenow:{validations:[k(0),E(0)],returnType:"time"},timevalue:{validations:[k(1),E(1),M("text")],returnType:"time"},today:{validations:[k(0),E(0)],returnType:"date"},trim:{validations:[k(1),E(1),M("text")],returnType:"text"},unequal:{validations:[k(2),E(2),M(["text","number","date","datetime","checkbox"]),U()],returnType:"checkbox"},upper:{validations:[k(1),E(1),M("text")],returnType:"text"},value:{validations:[k(1),E(1),M("text")],returnType:"number"},weekday:{validations:[k(1),E(1),M("date")],returnType:"number"},year:{validations:[k(1),E(1),M("date")],returnType:"number"}};class F extends o{constructor(e,t){super(e,"ReferenceError",t)}}const j=e=>{switch(e.type){case"callExpression":return t=e.id,r=e.arguments.map((e=>j(e))),h((()=>{const e=r.find((e=>"error"===e.type));if(e)return e;const n=S[t];if(n)return n.validations.forEach((e=>e(t)(r))),A[`sf$${t}`](...r);throw new O(`Unknown function ${t.toUpperCase()}. Check spelling.`,{function:t})}));case"identifier":throw new F(`Field ${e.name} does not exist. Check spelling.`,{identifier:e.name});default:return e}var t,r},D=e=>{try{return a.parse(null==e?"":e.trim())}catch(e){if(e instanceof a.SyntaxError)return p("SyntaxError","Syntax error.",{});throw e}},N=(e,t=[])=>{switch(e.type){case"callExpression":return e.arguments.map((e=>N(e,t))).reduce(((e,t)=>e.concat(t)),[]);case"identifier":return t.concat(e.name);default:return t}},I=(e,t)=>"callExpression"===e.type?{type:"callExpression",id:e.id,arguments:e.arguments.map((e=>I(e,t)))}:"identifier"===e.type&&t[e.name]?{...t[e.name],type:"literal"}:e;e.ast=e=>null==e||""===e.trim()?{}:D(e),e.extract=e=>{if(null==e||""===e.trim())return[];const t=D(e);return N(t).reduce(((e,t)=>(e.indexOf(t)<0&&e.push(t),e)),[])},e.parse=(e,t={})=>{if(null==e||""===e.trim())return d("");const r=D(e),n=Object.keys(t).reduce(((e,r)=>{return{...e,[r]:(n=t[r],void 0===n.value||null===n.value||Number.isNaN(n.value)?{type:"literal",value:null,dataType:"null",options:{}}:{...n,value:c(n.dataType,n.value,n.options)})};var n}),{});return(e=>h((()=>j(e))))(I(r,n))},e.toString=e=>g(e),Object.defineProperty(e,"__esModule",{value:!0})}));
{
"name": "formulon",
"version": "6.24.3",
"version": "6.25.0",
"description": "Salesforce Formula Parser",

@@ -5,0 +5,0 @@ "main": "lib/formulon.js",

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc