2020-06-14 21:07:32 -07:00
|
|
|
(this["webpackJsonpcalculator-react"]=this["webpackJsonpcalculator-react"]||[]).push([[0],{24:function(t,n,e){t.exports=e(37)},33:function(t,n,e){},37:function(t,n,e){"use strict";e.r(n);var o=e(0),i=e.n(o),r=e(16),a=e.n(r),u=e(2),c=e(13),s=function(t){return{type:"SETINPUTSTRING",inputString:t}},l=function(t){return{type:"SETOPERATIONSTRING",operationString:t}},d=Object(c.b)({innerWindowWidth:function(t,n){switch(t||(t=window.innerWidth),n.type){case"SETWINDOWINNERWIDTH":return n.windowInnerWidth;default:return t}},innerWindowHeight:function(t,n){switch(t||(t=window.innerHeight),n.type){case"SETWINDOWINNERHEIGHT":return n.windowInnerHeight;default:return t}},inputString:function(t,n){switch(t||(t=""),n.type){case"SETINPUTSTRING":return n.inputString;default:return t}},operationString:function(t,n){switch(t||(t=""),n.type){case"SETOPERATIONSTRING":return n.operationString;default:return t}}}),h=Object(c.c)(d),p=(e(33),e(3)),g=e(4),b=e(1),f=e(6),v=e(5),k=e(7),C=e(8),S=e(12),m="#00293C",E="#1e656d",y="#6d261e",j="#656d1e",O="#261e6d",w="#f1f3ce",M="#f62a00",R=["*","/","-","+"],W=function(t,n,e){var o=t,i=n.includes("=")?n.split("=")[1]:n,r=i;i.length>0&&["*","/","+","-","="].includes(e)&&"."===i.slice(-1)&&(i=i.slice(0,-1));if(["1","2","3","4","5","6","7","8","9"].includes(e))0===t.length?(o=e,r=i+e):1===t.length?"0"===t[0]?(o=e,r=i.slice(0,-1)+e):"-"===t[0]?1===i.length?(o=t+e,r=t+e):(o=t+e,r=i+e):["*","/","+"].includes(t[0])?(o=e,r=i+e):(o=t+e,r=i+e):2===t.length?"-"===t[0]&&"0"===t[1]?(o="-"+e,r=i.slice(0,-1)+e):(o=t+e,r=i+e):t.length>2&&(o=t+e,r=i+e);else if("0"===e)0===t.length?(o=e,r=i+e):1===t.length?"0"!==t[0]&&(["*","/","+"].includes(t[0])?(o=e,r=i+e):(o=t+e,r=i+e)):2===t.length?("-"!==t[0]||"0"!==t[1])&&(o=t+e,r=i+e):t.length>2&&(o=t+e,r=i+e);else if("-"===e)0===i.length?(o=e,r=e):1===i.length&&R.includes(i[0])||(o=e,r=i+e);else if(["*","/","+"].includes(e))1===i.length?R.includes(i.slice(-1))||(r=i+e,o=e):i.length>1&&(o=e,r=i+e);else if("."!==e||t.includes("."))if("="===e&&i.length>0){var a=i.slice(-1);R.includes(a)||"."===a?(o=x(i.slice(0,-1)),r=i.slice(0,-1)+"="+o):r=i+"="+(o=x(i))}else"b"===e&&(1===i.length?(o=t.slice(0,-1),r=i.slice(0,-1)):i.length>1&&(R.includes(i.slice(-1))?R.includes(i.slice(-2,-1))?(o=i.slice(-2,-1),r=i.slice(0,-1)):o=(r=i.slice(0,-1)).split(/[-*/+]/).slice(-1)[0]:R.includes(i.slice(-2,-1))?(o=i.slice(-2,-1),r=i.slice(0,-1)):(o=t.slice(0,-1),r=i.slice(0,-1))));else 0===t.length?(o="0.",r=i+"0."):1===t.length?0===i.length?"-"===t[0]?(o="-0.",r=i+"-0."):(o=t+e,r=i+e):R.includes(t[0])?(o="0.",r=i+"0."):(o=t+e,r=i+e):(o=t+e,r=i+e);return[o,r]},x=function(t){var n=[];for(t.split("").forEach((function(t,e){if(0===e)n.push(t);else if(R.includes(t))n.push(t);else if("-"===n[n.length-1])if(1===e||R.includes(n[n.length-2])){var o=n[n.length-1];n[n.length-1]=o+t}else n.push(t);else if(["*","/","+"].includes(n[n.length-1]))n.push(t);else{var i=n[n.length-1];n[n.length-1]=i+t}}));R.includes(n[n.length-1]);)n.pop();var e=n.filter((function(t,e){return!R.includes(n[e+1])||!R.includes(t)}));return 1===e.length?e[0]:A(e.map((function(t){return R.includes(t)?t:t.includes(".")?parseFloat(t):parseInt(t)})))[0].toString()},A=function t(n){if(1===n.length)return n;if(n.includes("*")){var e=n.indexOf("*");return t([].concat(Object(S.a)(n.slice(0,e-1)),[n[e-1]*n[e+1]],Object(S.a)(n.slice(e+2))))}if(n.includes("/")){var o=n.indexOf("/");return t([].concat(Object(S.a)(n.slice(0,o-1)),[n[o-1]/n[o+1]],Object(S.a)(n.slice(o+2))))}if(n.includes("-")){var i=n.indexOf("-");return t([].concat(Object(S.a)(n.slice(0,i-1)),[n[i-1]-n[i+1]],Object(S.a)(n.slice(i+2))))}if(n.includes("+")){var r=n.indexOf("+");return t([].concat(Object(S.a)(n.slice(0,r-1)),[n[r-1]+n[r+1]],Object(S.a)(n.slice(r+2))))}},T=function(t){Object(f.a)(e,t);var n=Object(v.a)(e);function e(t){var o;return Object(p.a)(this,e),(o=n.call(this,t)).handleClick=o.handleClick.bind(Object(b.a)(o)),o.handleMouseEvent=o.handleMouseEvent.bind(Object(b.a)(o)),o.state={backgroundColor:E},o}return Object(g.a)(e,[{key:"handleClick",value:function(){var t=W(this.props
|