(function(t){function e(e){for(var r,i,s=e[0],c=e[1],l=e[2],d=0,f=[];dDesigner',4),w=Object(r["f"])("h2",null,"Material",-1),m=Object(r["f"])("label",{for:"boardThickness"},"Board thickness",-1),y=Object(r["f"])("label",{for:"boardLength"},"Board length",-1),k=Object(r["f"])("label",{for:"bladeKerf"},"Blade kerf",-1),x=Object(r["f"])("h2",null,"End grain",-1),W=Object(r["f"])("label",{for:"crosscutWidth"},"Crosscut width",-1),L=Object(r["f"])("label",{for:"alternateDirection"},"Alternate direction",-1);Object(r["i"])();var P=v((function(t,e,n,o,a,i){return Object(r["h"])(),Object(r["c"])("div",j,[g,Object(r["f"])("input",{id:"borders",type:"checkbox",checked:i.settings.borders,onChange:e[1]||(e[1]=function(e){return t.$store.commit("updateSettings",{borders:e.target.checked})})},null,40,["checked"]),w,m,Object(r["f"])("input",{id:"boardThickness",type:"number",value:i.settings.boardThickness,onChange:e[2]||(e[2]=function(e){return t.$store.commit("updateSettings",{boardThickness:i.parseFloatDef(e.target.value)})})},null,40,["value"]),y,Object(r["f"])("input",{id:"boardLength",type:"number",value:i.settings.boardLength,onChange:e[3]||(e[3]=function(e){return t.$store.commit("updateSettings",{boardLength:i.parseFloatDef(e.target.value)})})},null,40,["value"]),k,Object(r["f"])("input",{id:"bladeKerf",type:"number",value:i.settings.bladeKerf,onChange:e[4]||(e[4]=function(e){return t.$store.commit("updateSettings",{bladeKerf:i.parseFloatDef(e.target.value)})})},null,40,["value"]),x,W,Object(r["f"])("input",{id:"crosscutWidth",type:"number",value:i.settings.crosscutWidth,onChange:e[5]||(e[5]=function(e){return t.$store.commit("updateSettings",{crosscutWidth:i.parseFloatDef(e.target.value)})})},null,40,["value"]),L,Object(r["f"])("input",{id:"alternateDirection",type:"checkbox",checked:i.settings.alternateDirection,onChange:e[6]||(e[6]=function(e){return t.$store.commit("updateSettings",{alternateDirection:e.target.checked})})},null,40,["checked"])])})),S=(n("2b19"),25.4),$=10,C=1,B={toPixels:function(t,e){return this.toMillimeters(t,e)*C},toMillimeters:function(t,e){switch(e){case"mm":return t;case"cm":return t*$;case"inch":return t*S}return console.error("Invalid units type: "+e),0},fromMillimeters:function(t,e){switch(e){case"mm":return t;case"cm":return t/$;case"inch":return t/S}return console.error("Invalid units type: "+e),0}},M={computed:{settings:function(){return this.$store.state.settings}},methods:{parseFloatDef:function(t){var e=parseFloat(t);return Object.is(e,NaN)?0:e}}};n("e334");M.render=P,M.__scopeId="data-v-660f17f9";var F=M,D=Object(r["s"])("data-v-535527d4");Object(r["j"])("data-v-535527d4");var _={class:"layers"},H={class:"add"},T=Object(r["f"])("span",{class:"header"}," ",-1),E=Object(r["f"])("span",{class:"header"},"Wood type",-1),N=Object(r["f"])("span",{class:"header"},"Width",-1),I=Object(r["f"])("span",{class:"header"}," ",-1),U={class:"index"},A={class:"remove"};Object(r["i"])();var K=D((function(t,e,n,o,a,i){return Object(r["h"])(),Object(r["c"])("div",_,[Object(r["f"])("div",H,[Object(r["f"])("button",{onClick:e[1]||(e[1]=function(t){return i.addLayer()})},"Add layer")]),T,E,N,I,(Object(r["h"])(!0),Object(r["c"])(r["a"],null,Object(r["l"])(i.layers,(function(t,e){return Object(r["h"])(),Object(r["c"])(r["a"],null,[Object(r["f"])("div",U,Object(r["n"])(e+1),1),Object(r["r"])(Object(r["f"])("select",{"onUpdate:modelValue":function(e){return t.wood=e},class:"wood"},[(Object(r["h"])(!0),Object(r["c"])(r["a"],null,Object(r["l"])(i.wood,(function(t,e){return Object(r["h"])(),Object(r["c"])("option",{value:e},Object(r["n"])(t.name),9,["value"])})),256))],8,["onUpdate:modelValue"]),[[r["o"],t.wood]]),Object(r["f"])("input",{type:"number",class:"width",value:t.width,onInput:function(e){return t.width=i.parseFloatDef(e.target.value)}},null,40,["value","onInput"]),Object(r["f"])("div",A,[Object(r["f"])("button",{onClick:function(t){return i.removeLayer(e)}},"X",8,["onClick"])])],64)})),256))])})),V={computed:{settings:function(){return this.$store.state.settings},wood:function(){return this.$store.state.wood},layers:function(){return this.$store.state.boards[0].layers}},methods:{parseFloatDef:function(t){var e=parseFloat(t);return Object.is(e,NaN)?0:e},addLayer:function(){this.$store.commit("addLayer",0)},removeLayer:function(t){this.$store.commit("removeLayer",{board:0,layer:t})}}};n("23b6");V.render=K,V.__scopeId="data-v-535527d4";var G=V,J=Object(r["s"])("data-v-55181d8c");Object(r["j"])("data-v-55181d8c");var R={class:"wood"},X={class:"add"},Y=Object(r["f"])("span",{class:"header"}," ",-1),q=Object(r["f"])("span",{class:"header"},"Name",-1),z=Object(r["f"])("span",{class:"header"},"Colour",-1),Q=Object(r["f"])("span",{class:"header"}," ",-1),Z=Object(r["f"])("span",null," ",-1),tt={class:"remove"};Object(r["i"])();var et=J((function(t,e,n,o,a,i){return Object(r["h"])(),Object(r["c"])("div",R,[Object(r["f"])("div",X,[Object(r["f"])("button",{onClick:e[1]||(e[1]=function(t){return i.addWood()})},"Add wood type")]),Y,q,z,Q,(Object(r["h"])(!0),Object(r["c"])(r["a"],null,Object(r["l"])(i.wood,(function(t,e){return Object(r["h"])(),Object(r["c"])(r["a"],null,[Z,Object(r["r"])(Object(r["f"])("input",{type:"text",class:"name","onUpdate:modelValue":function(e){return t.name=e}},null,8,["onUpdate:modelValue"]),[[r["p"],t.name]]),Object(r["r"])(Object(r["f"])("input",{type:"color",class:"color","onUpdate:modelValue":function(e){return t.color=e}},null,8,["onUpdate:modelValue"]),[[r["p"],t.color]]),Object(r["f"])("div",tt,[Object(r["f"])("button",{onClick:function(t){return i.removeWood(e)}},"X",8,["onClick"])])],64)})),256))])})),nt={computed:{settings:function(){return this.$store.state.settings},wood:function(){return this.$store.state.wood}},methods:{addWood:function(){this.$store.commit("addWood")},removeWood:function(t){this.$store.commit("removeWood",t)}}};n("667a");nt.render=et,nt.__scopeId="data-v-55181d8c";var rt=nt,ot={class:"preview"};function at(t,e,n,o,a,i){return Object(r["h"])(),Object(r["c"])("div",ot,[(Object(r["h"])(),Object(r["c"])("svg",{width:i.viewportWidth,height:i.viewportHeight,viewBox:i.viewBox},[(Object(r["h"])(!0),Object(r["c"])(r["a"],null,Object(r["l"])(i.layers,(function(t,e){return Object(r["h"])(),Object(r["c"])("rect",{width:i.toPixels(i.settings.boardLength),height:i.toPixels(t.width),x:"0",y:i.getLayerOffset(e),style:i.getLayerStyle(e)},null,12,["width","height","y"])})),256))],8,["width","height","viewBox"]))])}n("d81d"),n("13d5"),n("a9e3");var it={props:{scale:Number},computed:{settings:function(){return this.$store.state.settings},wood:function(){return this.$store.state.wood},layers:function(){return this.$store.state.boards[0].layers},boardWidth:function(){return this.toPixels(this.settings.boardLength)},boardHeight:function(){return this.layers.map((function(t){return t.width})).reduce((function(t,e){return t+e}))},viewportWidth:function(){return Math.floor(this.boardWidth*this.scale)},viewportHeight:function(){return Math.floor(this.boardHeight*this.scale)},viewBox:function(){return"0 0 "+this.boardWidth+" "+this.boardHeight}},methods:{toPixels:function(t){return B.toPixels(t,this.settings.units)},getLayerOffset:function(t){if(t<0||t>=this.layers.length)return 0;for(var e=0,n=0;n=this.layers.length)return"fill: fuchsia";var e=this.layers[t].wood;if(null===e)return"";var n=this.settings.borders?"; stroke-width: 1; stroke: black":"";return"fill: "+this.wood[e].color+n}}};it.render=at;var st=it,ct={class:"preview"},lt={id:"strip"};function ut(t,e,n,o,a,i){return Object(r["h"])(),Object(r["c"])("div",ct,[(Object(r["h"])(),Object(r["c"])("svg",{width:i.viewportWidth,height:i.viewportHeight,viewBox:i.viewBox},[Object(r["f"])("defs",null,[Object(r["f"])("g",lt,[(Object(r["h"])(!0),Object(r["c"])(r["a"],null,Object(r["l"])(i.layers,(function(t,e){return Object(r["h"])(),Object(r["c"])("rect",{width:i.toPixels(i.settings.boardThickness),height:i.toPixels(t.width),x:"0",y:i.getLayerOffset(e),style:i.getLayerStyle(e)},null,12,["width","height","y"])})),256))])]),(Object(r["h"])(!0),Object(r["c"])(r["a"],null,Object(r["l"])(i.stripsPerBoard,(function(t,e){return Object(r["h"])(),Object(r["c"])("use",{"xlink:href":"#strip",x:e*i.settings.boardThickness,y:"0",transform:i.getLayerTransform(e)},null,8,["x","transform"])})),256))],8,["width","height","viewBox"]))])}var dt={props:{scale:Number},computed:{settings:function(){return this.$store.state.settings},wood:function(){return this.$store.state.wood},layers:function(){return this.$store.state.boards[0].layers},stripsPerBoard:function(){var t=this.settings.crosscutWidth+this.settings.bladeKerf;return 0===t?0:Math.floor((this.settings.boardLength+this.settings.bladeKerf)/t)},boardWidth:function(){var t=this.stripsPerBoard*this.settings.boardThickness;return this.toPixels(t)},boardHeight:function(){return this.layers.map((function(t){return t.width})).reduce((function(t,e){return t+e}))},viewportWidth:function(){return Math.floor(this.boardWidth*this.scale)},viewportHeight:function(){return Math.floor(this.boardHeight*this.scale)},viewBox:function(){return"0 0 "+this.boardWidth+" "+this.boardHeight}},methods:{toPixels:function(t){return B.toPixels(t,this.settings.units)},getLayerOffset:function(t){if(t<0||t>=this.layers.length)return 0;for(var e=0,n=0;n=this.layers.length)return"fill: fuchsia";var e=this.layers[t].wood;if(null===e)return"";var n=this.settings.borders?"; stroke-width: 1; stroke: black":"";return"fill: "+this.wood[e].color+n},getLayerTransform:function(t){return this.settings.alternateDirection&&t%2!=0?"scale(1, -1) translate(0, -"+this.boardHeight+")":""}}};dt.render=ut;var ft=dt,ht=n("21a6"),bt={name:"App",components:{EndGrainPreview:st,EdgeGrainPreview:ft,Settings:F,Layers:G,Wood:rt},data:function(){return{saveFilename:"My cutting board"}},methods:{save:function(){var t=this.$store.getters.save,e=new Blob([t],{type:"text/plain; charset=utf-8"});Object(ht["saveAs"])(e,this.saveFilename+".json")},load:function(){var t=this,e=document.getElementById("loadFile").files[0];if(e){this.saveFilename=e.name.toLowerCase().endsWith(".json")?e.name.substring(0,e.name.length-5):e.name;var n=new FileReader;n.addEventListener("load",(function(e){t.$store.commit("load",e.target.result)})),n.readAsBinaryString(e)}}}};n("0f21");bt.render=O;var pt=bt,Ot=(n("4160"),n("a434"),n("159b"),n("5502"));function vt(t,e){for(var n in t)t.hasOwnProperty(n)&&e.hasOwnProperty(n)&&(e[n]=t[n])}function jt(t){var e=parseFloat(t);return Object.is(e,NaN)?0:e}var gt=Object(Ot["a"])({state:{settings:{units:"mm",borders:!1,boardThickness:20,boardLength:700,bladeKerf:3.5,crosscutWidth:30,alternateDirection:!0},wood:[{name:"Walnut",color:"#58443f"},{name:"Maple",color:"#f2e0aa"},{name:"Cherry",color:"#bb8359"},{name:"Mahogany",color:"#98473f"},{name:"Yellowheart",color:"#ffff84"},{name:"White oak",color:"#fdf4b9"},{name:"Bubinga",color:"#7e3c34"},{name:"Jatoba",color:"#9b281c"},{name:"Padouk",color:"#933350"}],boards:[{layers:[{wood:0,width:20},{wood:1,width:20},{wood:0,width:20},{wood:1,width:20},{wood:0,width:20},{wood:1,width:20},{wood:0,width:20},{wood:1,width:20},{wood:0,width:20},{wood:1,width:20},{wood:0,width:20},{wood:1,width:20},{wood:0,width:20},{wood:1,width:20}]}]},mutations:{addLayer:function(t,e){e<0||e>=t.boards.length||t.boards[e].layers.push({wood:0,width:B.fromMillimeters(20,t.settings.units)})},removeLayer:function(t,e){e.board<0||e.board>=t.boards.length||e.layer<0||e.layer>=t.boards[e.board].length||t.boards[e.board].layers.splice(e.layer,1)},addWood:function(t){t.wood.push({name:"Wood #"+(t.wood.length+1),color:"#f2e0aa"})},removeWood:function(t,e){e<0||e>=t.wood.length||(t.boards.forEach((function(t){t.layers.forEach((function(t){t.wood===e?t.wood=null:t.wood>e&&t.wood--}))})),t.wood.splice(e,1))},updateSettings:function(t,e){vt(e,t.settings)},load:function(t,e){var n=JSON.parse(e);if(n.hasOwnProperty("settings")&&vt(n.settings,t.settings),n.hasOwnProperty("boards")){var r=n.boards.map((function(t){return t.hasOwnProperty("layers")?{layers:t.layers.map((function(t){return{wood:jt(t.wood),width:jt(t.width)}}))}:{layers:[]}}));0===r.length&&r.push({layers:[]}),t.boards=r}if(n.hasOwnProperty("wood")){var o=n.wood.map((function(t){return{name:t.name,color:t.color}}));t.wood=o}}},getters:{save:function(t){return JSON.stringify(t)}}});Object(r["b"])(pt).use(gt).mount("#app")},"667a":function(t,e,n){"use strict";n("6ac4")},"6ac4":function(t,e,n){},"9e5f":function(t,e,n){},d747:function(t,e,n){},e334:function(t,e,n){"use strict";n("9e5f")},ec56:function(t,e,n){}}); //# sourceMappingURL=app.ed26f79c.js.map