'use strict';function_extends(){return_extends=Object.assign||function(a){for(varb,c=1;c<arguments.length;c++)for(vardinb=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);returna},_extends.apply(this,arguments)}function_typeof(a){return_typeof="function"==typeofSymbol&&"symbol"==typeofSymbol.iterator?function(a){returntypeofa}:function(a){returna&&"function"==typeofSymbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeofa},_typeof(a)}function_classCallCheck(a,b){if(!(ainstanceofb))thrownewTypeError("Cannot call a class as a function")}function_defineProperties(a,b){for(varc,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0// hack: remove weird animation after a drop
,"value"inc&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function_createClass(a,b,c){returnb&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),a}function_possibleConstructorReturn(a,b){returnb&&("object"===_typeof(b)||"function"==typeofb)?b:_assertThisInitialized(a)}function_assertThisInitialized(a){if(void0===a)thrownewReferenceError("this hasn't been initialised - super() hasn't been called");returna}function_getPrototypeOf(a){return_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(a){returna.__proto__||Object.getPrototypeOf(a)},_getPrototypeOf(a)}function_inherits(a,b){if("function"!=typeofb&&null!==b)thrownewTypeError("Super expression must either be null or a function");a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),b&&_setPrototypeOf(a,b)}function_setPrototypeOf(a,b){return_setPrototypeOf=Object.setPrototypeOf||function(a,b){returna.__proto__=b,a},_setPrototypeOf(a,b)}function_slicedToArray(a,b){return_arrayWithHoles(a)||_iterableToArrayLimit(a,b)||_nonIterableRest()}function_nonIterableRest(){thrownewTypeError("Invalid attempt to destructure non-iterable instance")}function_iterableToArrayLimit(a,b){if(Symbol.iteratorinObject(a)||"[object Arguments]"===Object.prototype.toString.call(a)){varc=[],d=!0,e=!1,f=void0;try{for(varg,h=a[Symbol.iterator]();!(d=(g=h.next()).done)&&(c.push(g.value),!(b&&c.length===b));d=!0);}catch(a){e=!0,f=a}finally{try{d||null==h["return"]||h["return"]()}finally{if(e)throwf}}returnc}}function_arrayWithHoles(a){if(Array.isArray(a))returna}functionownKeys(a,b){varc=Object.keys(a);if(Object.getOwnPropertySymbols){vard=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){returnObject.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}returnc}function_objectSpread(a){for(varb,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(b,!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(b).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});returna}function_defineProperty(a,b,c){returnbina?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}var_window$ReactBeautifu=window.ReactBeautifulDnd,DragDropContext=_window$ReactBeautifu.DragDropContext,Draggable=_window$ReactBeautifu.Draggable,Droppable=_window$ReactBeautifu.Droppable,data=window.shop_data,productStyle=function(a,b,c,d,e){varf={opacity:b.isDragging?.7:1,backgroundColor:d||e?"#eae7f7":"initial"};returnb.isDropAnimating?(c&&(f.transitionDuration="0.001s"),_objectSpread({},a,{},f)):_objectSpread({},a,{},f)},cartStyle=function(a,b){varc=b.isDraggingOver;return_objectSpread({},a,{},{backgroundColor:c?"#f2f2f2":"#f9f9f9",border:c?"1px dashed #ccc":"0"})},nbrConnectorsStyle=function(a){if(!a||!a.nbrCurrentSlot)return{};varb=100*a.nbrCurrentSlot/a.nbrSlotMax;return100<b&&(b=100),{width:"".concat(b,"%")}},nbrClocksStyle=function(a){if(!a||!a.nbrCurrentClock)return{};varb=100*a.nbrCurrentClock/a.nbrClockMax;return100<b&&(b=100),{width:"".concat(b,"%")}},copy=function(a,b,c,d,e){varf=Array.from(b.itemIds),g=Array.from(c.items),h=f[d.index];returng.splice(e.index,0,_objectSpread({},a[h],{id:uuidv4()})),g},reorder=function(a,b,c){vard=Array.from(a),e=d.splice(b,1),f=_slicedToArray(e,1),g=f[0];returnd.splice(c,0,g),d},remove=function(a,b){varc=Array.from(a);returnc.splice(b,1),c},nbrOccupiedSlotsInCrate=function(a){returna.reduce(function(a,b){returna+(8===b.hp?2:1)},0)};functionformatMoney(a){varb=Math.abs,c=1<arguments.length&&void0!==arguments[1]?arguments[1]:2,d=2<arguments.length&&void0!==arguments[2]?arguments[2]:".",e=3<arguments.length&&void0!==arguments[3]?arguments[3]:",";// https://stackoverflow.com/questions/149055/how-can-i-format-numbers-as-currency-string-in-javascript
// changes: return amount if error in order to avoid empty value
this.handleOnDragEnd({source:{droppableId:"backlog",index:0},destination:{droppableId:"cart",index:0},draggableId:null})}},{key:"componentDidUpdate",value:functioncomponentDidUpdate(a,b){(b.columns.cart.items!==this.state.columns.cart.items||b.currentMode!==this.state.currentMode)&&this.checkAlerts(b.columns.cart.items,this.state.columns.cart.items)}},{key:"handleCrateModeChange",value:functionhandleCrateModeChange(a){this.setState({currentMode:a})}},{key:"handleDeleteItem",value:functionhandleDeleteItem(a){varb=Array.from(this.state.columns.cart.items);b.splice(a,1),this.setState(_objectSpread({},this.state,{columns:_objectSpread({},this.state.columns,{cart:_objectSpread({},this.state.columns.cart,{items:b})})}))}},{key:"handleDeleteAllItems",value:functionhandleDeleteAllItems(){this.setState(_objectSpread({},this.state,{columns:_objectSpread({},this.state.columns,{cart:_objectSpread({},this.state.columns.cart,{items:[]})})}))}},{key:"handleMouseEnterItem",value:functionhandleMouseEnterItem(a){this.setState(_objectSpread({},this.state,{currentItemHovered:a}))}},{key:"handleMouseLeaveItem",value:functionhandleMouseLeaveItem(){this.setState(_objectSpread({},this.state,{currentItemHovered:null}))}},{key:"handleClickAddItem",value:functionhandleClickAddItem(a){varb={droppableId:"cart",index:this.state.columns.cart.items.length};this.handleOnDragEnd({source:{droppableId:"backlog",index:a},destination:b,draggableId:null})}},{key:"handleToggleItemProgress",value:functionhandleToggleItemProgress(a,b){varc=Array.from(this.state.columns.cart.items);this.setState(_objectSpread({},this.state,{columns:_objectSpread({},this.state.columns,{cart:_objectSpread({},this.state.columns.cart,{items:c.map(function(c,d){return_objectSpread({},c,{showProgress:d===a&&b,showOverlayRemove:!1,showWarning:!1})})})})}))}},{key:"handleToggleItemWarning",value:functionhandleToggleItemWarning(a,b){varc=Array.from(this.state.columns.cart.items);this.setState(_objectSpread({},this.state,{columns:_objectSpread({},this.state.columns,{cart:_objectSpread({},this.state.columns.cart,{items:c.map(function(c,d){return_objectSpread({},c,{showWarning:d===a&&b,showProgress:!1,showOverlayRemove:!1})})})})}))}},{key:"handleClickSelectItem",value:functionhandleClickSelectItem(a){varb=Array.from(this.state.columns.cart.items);this.setState(_objectSpread({},this.state,{columns:_objectSpread({},this.state.columns,{cart:_objectSpread({},this.state.columns.cart,{items:b.map(function(b,c){return_objectSpread({},b,{selected:c===a})})})})}))}},{key:"handleToggleOverlayRemove",value:functionhandleToggleOverlayRemove(a,b){varc=Array.from(this.state.columns.cart.items);this.setState(_objectSpread({},this.state,{columns:_objectSpread({},this.state.columns,{cart:_objectSpread({},this.state.columns.cart,{items:c.map(function(c,d){return_objectSpread({},c,{showOverlayRemove:d===a&&b,showProgress:!1,showWarning:!1})})})})}))}},{key:"handleClickSubmit",value:functionhandleClickSubmit(b){varc={items:[],type:this.state.currentMode},d=Array.from(this.state.columns.cart.items);for(vargind){varh=d[g];c.items.push({name:h.name})}vare=document.createElement("a"),a=newDate().getTime(),f="Hello!\n\nI would like to request a quotation for my below configuration:\n\n".concat(JSON.stringify(c),"\n\n(Please do not edit the machine-readable representation above)\n\n");b&&(f="".concat(f,"\n\nAdditional note:\n\n").concat(b?b.trim():"")),document.body.appendChild(e),e.style="display: none",e.href="mailto:sales@m-labs.hk?subject=".concat("[Order hardware] - Request Quote","&body=").concat(encodeURIComponent(f)),e.click()}},{key:"handleOnDragEnd",value:functionhandleOnDragEnd(a){varb=a.source,c=a.destination,d=a.draggableId;if(!c)returnvoid("cart"===b.droppableId&&this.setState(_objectSpread({},this.state,{columns:_objectSpread({},this.state.columns,_defineProperty({},b.droppableId,_objectSpread({},this.state.columns[b.droppableId],{items:remove(this.state.columns[b.droppableId].items,b.index)})))})));switch(b.droppableId){case"backlog":this.setState(_objectSpread({},thi
for(varu=h.reduce(function(a,b,c){return("kasli"===b.type||"kasli-backplane"===b.type||"clocker"===b.type)&&a.push(c),a},[]),v=0;v<=u.length-1;v++){varw=void0,x=0,y=u[v];w=v==u.length-1?h.slice(y+1):h.slice(y+1,u[v+1]),x=w.reduce(function(a,b){returna+b.clockOccupied},0),yinj?j[y].nbrCurrentClock?j[y].nbrCurrentClock+=x:j[y].nbrCurrentClock=x:(j[y]=_objectSpread({},h[y]),j[y].nbrCurrentClock=x,j[y].warnings={}),x>h[y].nbrClockMax&&(k[h[y].rules.maxClock.type]=_objectSpread({},h[y].rules.maxClock),j[y].warnings.maxClockWarning=_objectSpread({},h[y].rules.maxClockWarning))}// check for number of recommanded EEM connectors
["novo","urukul","koster"].map(function(a){returnh.find(function(b){returnb.type===a})&&(k[c.state.items[a].rules.connectors.type]=_objectSpread({},c.state.items[a].rules.connectors)),a});for(varz=h.reduce(function(a,b,c){return"idc-bnc"===b.type&&a.push(c),a},[]),A=z.length-1;0<=A;A--){varB=z[A],C=!1;if(0==B)C=!0;elseif(1<=B){varH=z[A]-1;"zotino"!==h[H].type&&"hd68"!==h[H].type&&"idc-bnc"!==h[H].type&&(C=!0)}C&&(j[B]=_objectSpread({},h[B]),j[B].warnings={},j[B].warnings.wrong=_objectSpread({},h[B].rules.wrong))}// check number of IDC-BNC adapters for a Zotino and HD68-IDC
for(varD=h.reduce(function(a,b,c){return("zotino"===b.type||"hd68"===b.type)&&a.push(c),a},[]),E=function(a){varb=void0,c=0,d=D[a];b=a===D.length-1?h.slice(d+1):h.slice(d+1,D[a+1]);vare=!1;// check if HD68-IDC has at least 1 IDC-BNC adapter
if(c=b.reduce(function(a,b,c,d){return0===c&&"idc-bnc"===b.type?a+1:"idc-bnc"===d[0].type&&0<c&&"idc-bnc"===d[c-1].type?("idc-bnc"!==b.type&&(e=!0),a+("idc-bnc"!==b.type||e?0:1)):a},0),(dinj)?(j[d].nbrCurrentSlot=c,!("warnings"inj[d])&&(j[d].warnings={})):(j[d]=_objectSpread({},h[d]),j[d].nbrCurrentSlot=c,j[d].warnings={}),0<c&&(k[h[d].rules.maxSlot.type]=_objectSpread({},h[d].rules.maxSlot)),c>h[d].nbrSlotMax&&(j[d].warnings.maxSlotWarning=_objectSpread({},h[d].rules.maxSlotWarning)),"hd68"===h[d].type){varf=!1;d<h.length-1?"idc-bnc"!==h[d+1].type&&(f=!0):d===h.length-1&&(f=!0),f&&((dinj)?j[d].warnings.minAdapter=_objectSpread({},h[d].rules.minAdapter):(j[d]=_objectSpread({},h[d]),j[d].warnings={},j[d].warnings.minAdapter=_objectSpread({},h[d].rules.minAdapter)))}},F=0;F<=D.length-1;F++)E(F);// update state with rules
this.setState(_objectSpread({},this.state,{columns:_objectSpread({},this.state.columns,{cart:_objectSpread({},this.state.columns.cart,{itemsData:_objectSpread({},j)})}),rules:_objectSpread({},k)}))}},{key:"render",value:functionrender(){vara=this.state,b=a.currency,c=a.currentItemHovered,d=a.currentMode,e=a.crateModeSlots,f=a.crateModeItems,g=a.items,h=a.columns,i=a.rules;returnReact.createElement(DragDropContext,{onDragEnd:this.handleOnDragEnd},React.createElement(Layout,{className:"shop",aside:React.createElement(Backlog,{currency:b,items:g,data:h.backlog,onClickAddItem:this.handleClickAddItem}),main:React.createElement(OrderPanel,{title:"Order hardware",description:" Drag and drop the cards you want into the crate below to see how the combination would look like. If you have any issues with this ordering system, or if you need other configurations, email us directly anytime at sales@m-****.hk. The price is estimated and must be confirmed by a quote.",crateMode:React.createElement(CrateMode,{items:f,mode:d,onClickMode:this.handleCrateModeChange}),crate:React.createElement(Crate,{cart:React.createElement(Cart,{nbrSlots:e[d],data:h.cart,itemHovered:c,onToggleProgress:this.handleToggleItemProgress,onToggleWarning:this.handleToggleItemWarning,onToggleOverlayRemove:this.handleToggleOverlayRemove,onClickRemoveItem:this.handleDeleteItem}),rules:Object.values(i).filter(function(a){returna})}),summaryPrice:React.createElement(OrderSumary,{currency:b,currentMode:d,modes:f,summary:h.cart.items,itemsData:h.cart.itemsData,onMouseEnterItem:this.handleMouseEnterItem,onMouseLeaveItem:this.handleMouseLeaveItem,onDeleteItem:this.handleDeleteItem,onDeleteAllItems:this.handleDeleteAllItems,onClickSelectItem:this.handleClickSelectItem}),form:React.createElement(OrderForm,{onClickSubmit:this.handleClickSubmit})})}))}}]),b}(React.PureComponent);/**