!function(){"undefined"==typeof window&&(window=root);var t=(window.excelFormulaUtilities=window.excelFormulaUtilities||{},window.excelFormulaUtilities.core={});window.excelFormulaUtilities.string=window.excelFormulaUtilities.string||{};var e=(window.excelFormulaUtilities.string.formatStr=function(t){for(var e=t,n=1;n)*|(?:\s| |<\s*br\s*\/*\s*>)*$/,"")},t.isFunction=function(t){return"function"==typeof t}),n=t.isArray=function(t){return"object"==typeof t&&t.length},r=t.isWindow=function(){return obj&&"object"==typeof obj&&"setInterval"in obj},o=t.isPlainObject=function(t){if(!t||"object"!=typeof t||t.nodeType||r(t))return!1;if(t.constructor&&!hasOwnProperty.call(t,"constructor")&&!hasOwnProperty.call(t.constructor.prototype,"isPrototypeOf"))return!1;var e;for(e in t);return void 0===e||hasOwnProperty.call(t,e)};t.extend=function(){var r,i,a,s,p,u,l=arguments[0]||{},c=1,d=arguments.length,g=!1;for("boolean"==typeof l&&(g=l,l=arguments[1]||{},c=2),"object"==typeof l||e(l)||(l={}),d===c&&(l=this,--c);c=this.items.length-1},this.moveNext=function(){return!this.EOF()&&(this.index+=1,!0)},this.current=function(){return this.index===-1?null:this.items[this.index]},this.next=function(){return this.EOF()?null:this.items[this.index+1]},this.previous=function(){return this.index<1?null:this.items[this.index-1]}}function r(){this.items=[],this.push=function(t){this.items.push(t)},this.pop=function(t){var n=this.items.pop();return new e(t||"",n.type,k)},this.token=function(){return this.items.length>0?this.items[this.items.length-1]:null},this.value=function(){return this.token()?this.token().value.toString():""},this.type=function(){return this.token()?this.token().type.toString():""},this.subtype=function(){return this.token()?this.token().subtype.toString():""}}function o(e){for(var o=new n,i=new r,a=0,s=function(){return e.substr(a,1)},p=function(){return e.substr(a,2)},u=function(){return e.substr(a+1,1)},l=function(){return a>=e.length},c="",C=!1,N=!1,Y=!1,K=!1,B=/^[1-9]{1}(\.[0-9]+)?E{1}$/;e.length>0;){if(" "!==e.substr(0,1)){"="===e.substr(0,1)&&(e=e.substr(1));break}e=e.substr(1)}for(;!l();)if(C)'"'===s()?'"'===u()?(c+='"',a+=1):(C=!1,o.add(c,g,v),c=""):c+=s(),a+=1;else if(N)"'"===s()?"'"===u()?(c+="'",a+=1):(N=!1,c+="'"):c+=s(),a+=1;else if(Y)"]"===s()&&(Y=!1),c+=s(),a+=1;else if(K)c+=s(),a+=1,",#NULL!,#DIV/0!,#VALUE!,#REF!,#NAME?,#NUM!,#N/A,".indexOf(","+c+",")!==-1&&(K=!1,o.add(c,g,R),c="");else if("+-".indexOf(s())!==-1&&c.length>1&&c.match(B))c+=s(),a+=1;else if('"'!==s())if("'"!==s())if("["!==s())if("#"!==s())if("{"!==s())if(";"!==s())if("}"!==s())if(" "!==s())",>=,<=,<>,".indexOf(","+p()+",")===-1?"+-*/^&=><".indexOf(s())===-1?"%".indexOf(s())===-1?"("!==s()?","!==s()||t.excelFormulaUtilities.isEu?")"!==s()?(c+=s(),a+=1):(c.length>0&&(o.add(c,g),c=""),o.addRef(i.pop()),a+=1):(c.length>0&&(o.add(c,g),c=""),i.type()!==f?o.add(s(),h,P):o.add(s(),S),a+=1):(c.length>0?(i.push(o.add(c,f,O)),c=""):i.push(o.add("",m,O)),a+=1):(c.length>0&&(o.add(c,g),c=""),o.add(s(),y),a+=1):(c.length>0&&(o.add(c,g),c=""),o.add(s(),h),a+=1):(c.length>0&&(o.add(c,g),c=""),o.add(p(),h,E),a+=2);else for(c.length>0&&(o.add(c,g),c=""),o.add("",T),a+=1;" "===s()&&!l();)a+=1;else c.length>0&&(o.add(c,g),c=""),o.addRef(i.pop("ARRAYROWSTOP")),o.addRef(i.pop("ARRAYSTOP")),a+=1;else{if(t.excelFormulaUtilities.isEu){c.length>0&&(o.add(c,g),c=""),i.type()!==f?o.add(s(),h,P):o.add(s(),S),a+=1;continue}c.length>0&&(o.add(c,g),c=""),o.addRef(i.pop()),o.add(",",S),i.push(o.add("ARRAYROW",f,O)),a+=1}else c.length>0&&(o.add(c,x),c=""),i.push(o.add("ARRAY",f,O)),i.push(o.add("ARRAYROW",f,O)),a+=1;else c.length>0&&(o.add(c,x),c=""),K=!0,c+=s(),a+=1;else Y=!0,c+=s(),a+=1;else c.length>0&&(o.add(c,x),c=""),c="'",N=!0,a+=1;else c.length>0&&(o.add(c,x),c=""),C=!0,a+=1;c.length>0&&o.add(c,g);for(var I=new n;o.moveNext();)if(c=o.current(),c.type.toString()!==T)I.addRef(c);else{var L=o.BOF()||o.EOF();L=L&&(o.previous().type.toString()===f&&o.previous().subtype.toString()===k||o.previous().type.toString()===m&&o.previous().subtype.toString()===k||o.previous().type.toString()===g),L=L&&(o.next().type.toString()===f&&o.next().subtype.toString()===O||o.next().type.toString()===m&&o.next().subtype.toString()===O||o.next().type.toString()===g),L&&I.add(c.value.toString(),h,F)}for(;I.moveNext();)c=I.current(),c.type.toString()!==h||"-"!==c.value.toString()?c.type.toString()!==h||"+"!==c.value.toString()?c.type.toString()!==h||0!==c.subtype.length?c.type.toString()!==g||0!==c.subtype.length?c.type.toString()!==f||"@"===c.value.substr(0,1)&&(c.value=c.value.substr(1).toString()):isNaN(parseFloat(c.value))?"TRUE"===c.value.toString()||"FALSE"===c.value.toString()?c.subtype=E.toString():c.subtype=_.toString():c.subtype=w.toString():"<>=".indexOf(c.value.substr(0,1))!==-1?c.subtype=E.toString():"&"===c.value.toString()?c.subtype=U.toString():c.subtype=A.toString():I.BOF()?c.type=d.toString():I.previous().type.toString()===f&&I.previous().subtype.toString()===k||I.previous().type.toString()===m&&I.previous().subtype.toString()===k||I.previous().type.toString()===y||I.previous().type.toString()===g?c.subtype=A.toString():c.type=d.toString():I.BOF()?c.type=b.toString():I.previous().type.toString()===f&&I.previous().subtype.toString()===k||I.previous().type.toString()===m&&I.previous().subtype.toString()===k||I.previous().type.toString()===y||I.previous().type.toString()===g?c.subtype=A.toString():c.type=b.toString();for(I.reset(),o=new n;I.moveNext();)I.current().type.toString()!==d&&o.addRef(I.current());return o.reset(),o}function i(t,e){if(!RegExp("[a-z]+[0-9]+:[a-z]+[0-9]+","gi").test(t))throw"This is not a valid range: "+t;var n=t.split(":"),r=parseInt(n[0].match(/[0-9]+/gi)[0]),o=n[0].match(/[A-Z]+/gi)[0],i=N(o);for(endRow=parseInt(n[1].match(/[0-9]+/gi)[0]),endCol=n[1].match(/[A-Z]+/gi)[0],endColDec=N(endCol),totalRows=endRow-r+1,totalCols=N(endCol)-N(o)+1,curCol=0,curRow=1,curCell="",retStr="";curRow<=totalRows;curRow+=1){for(;curCol",p+="",p+="index",p+="type",p+="subtype",p+="token",p+="token tree";s.moveNext();){var u=s.current();u.subtype===k&&(n-=n>0?1:0),p+="",p+=""+(s.index+1)+"",p+=""+u.type+"",p+=""+(0===u.subtype.length?" ":u.subtype.toString())+"",p+=""+(0===u.value.length?" ":u.value).split(" ").join(" ")+"",p+=""+r()+(0===u.value.length?" ":u.value).split(" ").join(" ")+"",p+="",u.subtype===O&&(n+=1)}p+="",document.getElementById(e).innerHTML=p,i.select(),i.focus()},s.toBase26=function(t){t=Math.abs(t);var e,n="",r=!1;do e=t%26,r&&t<25&&e--,n=String.fromCharCode(e+"A".charCodeAt(0))+n,t=Math.floor((t-e)/26),r=!0;while(t>0);return n}),N=s.fromBase26=function(t){t=t.toUpperCase();var e=0,n=0,r=0;if(null!==t&&"undefined"!=typeof t&&t.length>0)for(;n0?1:0);var y=(new RegExp("^"+e.newLine,""),new RegExp(e.newLine+"$","")),T=m(h),x=f,v=x?s():e.tmplIndentSpace,w=T?e.newLine:"";d+=a(b,e,v,w,e.customTokenRender,S),b.subtype.toString()===O&&(i+=1),f=T||y.test(d),n=!1,S=b}return d=e.prefix+l(d)+e.postfix},K=(s.formatFormulaHTML=function(t){var e={tmplFunctionStart:'{{autoindent}}{{token}}(
',tmplFunctionStop:'
{{autoindent}}{{token}})',tmplOperandText:'{{autoindent}}"{{token}}"',tmplArgument:"{{token}}
",tmplSubexpressionStart:"{{autoindent}}(",tmplSubexpressionStop:" )",tmplIndentTab:'    ',tmplIndentSpace:" ",newLine:"
",autoLineBreak:"TOK_TYPE_FUNCTION | TOK_TYPE_ARGUMENT | TOK_SUBTYPE_LOGICAL | TOK_TYPE_OP_IN ",trim:!0,prefix:"=",customTokenRender:null};return Y(t,e)},s.formula2CSharp=function(t){var e=[],n=function(t,n,r,o){var a="",s=t,p={"=":"==","<>":"!=",MIN:"Math.min",MAX:"Math.max",ABS:"Math.abs",SUM:"",IF:"","&":"+",AND:"",OR:""},u=e[e.length-1],l=!1;switch(n.type.toString()){case f:switch(n.subtype){case O:e.push({name:s,argumentNumber:0}),a="string"==typeof p[s.toUpperCase()]?p[s.toUpperCase()]:s,l=!0;break;case k:switch(l=!0,u.name.toLowerCase()){case"if":a=")",l=!1;break;default:a="string"==typeof p[s.toUpperCase()]?p[s.toUpperCase()]:s}e.pop()}break;case S:switch(u.name.toLowerCase()){case"if":switch(u.argumentNumber){case 0:a="?";break;case 1:a=":"}break;case"sum":a="+";break;case"and":a="&&";break;case"or":a="||";break;default:a="string"==typeof p[s.toUpperCase()]?p[s.toUpperCase()]:s,l=!0}u.argumentNumber+=1;break;case g:switch(n.subtype){case _:if(!u)break;switch(u.name.toLowerCase()){case"sum":RegExp(":","gi").test(s)?a=i(s,"+"):outStr=s;break;case"and":RegExp(":","gi").test(s)?a=i(s,"&&"):outStr=s;break;case"or":RegExp(":","gi").test(s)?a=i(s,"||"):outStr=s;break;default:a=RegExp(":","gi").test(s)?"["+i(s,",")+"]":s}}default:""===a&&(a="string"==typeof p[s.toUpperCase()]?p[s.toUpperCase()]:s),l=!0}return{tokenString:a,useTemplate:l}},r=Y(t,{tmplFunctionStart:"{{token}}(",tmplFunctionStop:"{{token}})",tmplOperandError:"{{token}}",tmplOperandRange:"{{token}}",tmplOperandLogical:"{{token}}",tmplOperandNumber:"{{token}}",tmplOperandText:'"{{token}}"',tmplArgument:"{{token}}",tmplOperandOperatorInfix:"{{token}}",tmplFunctionStartArray:"",tmplFunctionStartArrayRow:"{",tmplFunctionStopArrayRow:"}",tmplFunctionStopArray:"",tmplSubexpressionStart:"(",tmplSubexpressionStop:")",tmplIndentTab:"\t",tmplIndentSpace:" ",autoLineBreak:"TOK_SUBTYPE_STOP | TOK_SUBTYPE_START | TOK_TYPE_ARGUMENT",trim:!0,customTokenRender:n});return r});s.formula2JavaScript=function(t){return K(t).replace("==","===")};s.getTokens=o}(window||module.exports||{});