text: (window.webpackJsonp=window.webpackJsonp||[]).push([[0],{15:function(e,t,n){e.exports=n(43)},21:function(e,t,n){},42:function(e,t,n){},43:function(e,t,n){"use strict";n.r(t);var r=n(0),a=n.n(r),o=n(13),l=n.n(o),c=(n(21),n(2)),i=n.n(c),u=n(6),s=n(3),p=n(5),d=n(14),m=n.n(d);var v=function(e){return a.a.createElement("input",{key:"hidato-cell-".concat(e.row,"-").concat(e.col),className:"hidato-cell",disabled:!e.fromInput&&""!==e.val,style:{textAlign:"center",border:"1px solid gray",visibility:e.visible?"visible":"hidden",backgroundColor:1==e.val||40==e.val?"#d50000":e.fromInput&&""!==e.val?"#4dd0e1":"white",transition:"all 0.5s",fontSize:"1.2rem",color:1==e.val||40==e.val?"white":e.fromInput?"#424242":"green"},value:e.val,onChange:function(t){t.preventDefault();var n=t.target.value,r=Number(t.target.value);""===n||Number.isInteger(r)&&r>=1&&r<=40?e.callback(t.target.value):window.alert("Input must be positive number between 0 and 40 (inclusive)")}})},f="http://hidato.herokuapp.com/solve";function w(){return[{startX:0,endX:4},{startX:0,endX:4},{startX:0,endX:5},{startX:0,endX:5},{startX:0,endX:6},{startX:2,endX:6},{startX:4,endX:7},{startX:6,endX:7}].map(function(e,t){var n=e.startX,r=e.endX;return new Array(8).fill(0).map(function(e,a){return{row:t,col:a,visible:a>=n&&a<=r,val:"",fromInput:!1}})})}function b(e){return new Set(e.map(function(e){return e.val}))}function h(e){return g.apply(this,arguments)}function g(){return(g=Object(p.a)(i.a.mark(function e(t){var n,r,a,o,l,c;return i.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n=function(e){return e.reduce(function(e,t){var n=t.filter(function(e){return e.visible&&""!=e.val});return e.concat(n.map(function(e){return{row:e.row+1,col:e.col+1,val:Number(e.val)}}))},[])}(t),r=b(n),a=!0,n.sort(function(e,t){return e.val-t.val}),r.size!==n.length?(window.alert("Input should be unique. There is duplicate element"),a=!1):n.length<12?(window.alert("You should provide a minimum of 12 numbers"),a=!1):1===n[0].val&&40===n[n.length-1].val||(window.alert("Please input 1 and 40"),a=!1),a){e.next=8;break}return e.abrupt("return",{points:t});case 8:return e.prev=8,e.next=11,m.a.post(f,n,{headers:{"Content-Type":"application/json","Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST, PATCH, PUT, DELETE, OPTIONS","Access-Control-Allow-Headers":"Origin, Content-Type, X-Auth-Token"}});case 11:return o=e.sent,console.log("Get response: "),console.log(o),l=new Array(8).fill(0).map(function(){return new Array(8).fill(0)}),o.data.forEach(function(e,t){l[e.row-1][e.col-1]=e.val}),console.log(l),console.log(t),t=t.map(function(e){return e.map(function(e){return Object(u.a)({},e,{val:l[e.row][e.col]})})}),e.abrupt("return",{points:t});case 22:return e.prev=22,e.t0=e.catch(8),c=!1,e.t0.response&&500==e.t0.response.status&&(c=!0),c||window.alert("Error: ",e.t0),e.abrupt("return",{points:t,unsolvable:c});case 28:case"end":return e.stop()}},e,null,[[8,22]])}))).apply(this,arguments)}var E=function(){var e=Object(r.useState)(w()),t=Object(s.a)(e,2),n=t[0],o=t[1],l=Object(r.useState)(!1),c=Object(s.a)(l,2),d=c[0],m=c[1],f=Object(r.useState)(!1),b=Object(s.a)(f,2),g=b[0],E=b[1],y=Object(r.useState)(!1),X=Object(s.a)(y,2),O=X[0],k=X[1];return a.a.createElement(a.a.Fragment,null,a.a.createElement("div",{style:{display:"grid",gridTemplateColumns:"repeat(8, 2.5rem)",gridTemplateRows:"repeat(8, 2.5rem)"}},n.reduce(function(e,t){return e.concat(t.map(function(e){return a.a.createElement(v,Object.assign({key:"hidato-cell-".concat(e.row,"-").concat(e.col),callback:function(t){var r=n.map(function(n,r){return r!==e.row?n:n.map(function(n,r){return r!==e.col?n:Object(u.a)({},n,{val:t,fromInput:!0})})});o(r)}},e))}))},[])),O&&a.a.createElement("h4",null,"Given Puzzle is unsolvable. Please Clear and input different puzzle."),a.a.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",marginTop:"1rem"}},!g&&a.a.createElement("button",{onClick:Object(p.a)(i.a.mark(function e(){var t,r,a;return i.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return m(!0),e.next=3,h(n,o);case 3:t=e.sent,r=t.points,a=t.unsolvable,E(!0),o(r),m(!1),a&&k(!0);case 10:case"end":return e.stop()}},e)}))},"Solve"),a.a.createElement("button",{style:{marginLeft:"1rem"},onClick:function(){o(w()),E(!1),k(!1)}},"Clear")),d&&a.a.createElement("h4",null,"Solving... Please Wait."))};n(42);var y=function(){return a.a.createElement("div",{className:"App"},a.a.createElement("header",{className:"App-header"},a.a.createElement("h1",null,"Hidato Solver"),a.a.createElement("h2",null,"Standard Square-shaped")),a.a.createElement(E,null))};Boolean("localhost"===window.location.hostname||"[::1]"===window.location.hostname||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));l.a.render(a.a.createElement(y,null),document.getElementById("root")),"serviceWorker"in navigator&&navigator.serviceWorker.ready.then(function(e){e.unregister()})}},[[15,1,2]]]);
  //# sourceMappingURL=main.99c172d8.chunk.js.map