PageSourceSearch

https://login.commonsku.com/dist/react/8974.4c39fc87.chunk.js

js commonsku.com collected 2026-10-02 03:13:37 UTC 56,345 bytes, 2 lines download raw bytes

1(globalThis.__LOADABLE_LOADED_CHUNKS__=globalThis.__LOADABLE_LOADED_CHUNKS__||[]).push([[8974],{2340(e,t,o){"use strict";o.d(t,{A:()=>$});var i=o(41594),a=o.n(i),s=o(83129),r=o.n(s),n=o(98483),l=o(39913),d=o(99315),c=o(10219),h=o(73882),p=(o(22224),o(73049)),u=o(31164),m=o(82865),g=o(63988);class x extends i.Component{constructor(e){super(e),this.state={charge_types:[{key:"run",value:"Run charge"},{key:"fixed",value:"Fixed Charge"}],loading:!1,errors:null},["onChangeColsNum","onChangeRowsNum"].forEach(e=>this[e]=this[e].bind(this))}componentDidMount(){}onChangeAttachment(e){this.props.updateDecoration({attached_file:e.target?e.target.value:e})}onChangeColsNum(e,t){const o=e.target?e.target.value:e;"+"==t?this.props.addMatrixCol(parseInt(o)):"-"==t&&this.props.removeMatrixCol(parseInt(o))}onChangeRowsNum(e,t){const o=e.target?e.target.value:e;"+"==t?this.props.addMatrixRow(parseInt(o)):"-"==t&&this.props.removeMatrixRow(parseInt(o))}updateType(e){if(this.props.type==e)return;const{decoration_data:{matrix:t}}=this.props,o={type:e,remove_cols:!0,data:[],children:"list-item"==e||"list"==e?[]:void 0};(!t.data||t.data&&!t.data.length||t.data&&(0,p.BE)(t)||window.confirm("By changing the type, your decoration table data might be deleted."))&&this.props.updateMatrix(o)}renderOnView(){const{decoration_data:{charge_desc:e}}=this.props;return(0,g.jsx)("div",{"data-test-name":"AddAdminDecoration.renderOnView",className:"medium-12 small-12 columns",style:{float:"left",textAlign:"left",fontSize:"0.6em",marginBottom:e?20:1},children:(e||"").split("\n").map((e,t)=>(0,g.jsx)("div",{"data-test-name":"AddAdminDecoration.renderOnView",children:e},t))})}hasMatrixPerAddUnit(){const{decoration_data:{matrix:e}}=this.props;return!!(e&&e.cols&&e.data&&e.data.length>1&&"table"==e.type&&"per_additional_unit"==e.data[e.data.length-1].price_by_type)}renderForm(){const{charge_types:e,error:t}=this.state,{decoration_id:o,decoration_data:{charge_name:i,charge_type:a,charge_desc:s,should_update:r,is_new:n,qty:l,unit:d},cols_num:c,rows_num:p,type:x}=this.props,_=(e,t)=>(0,g.jsx)("label",{htmlFor:t?t+"-"+o:o,style:{textAlign:"left"},children:e}),b={backgroundColor:"#02c0da",color:"#fff",paddingBottom:"0px",padding:"0",paddingRight:"2px",paddingLeft:"2px",fontSize:"1.1em",lineHeight:"0",fontWeight:"300",borderRadius:"3px 0px 0px 3px",textAlign:"center",borderColor:"#02c0da"};return(0,g.jsxs)("div",{"data-test-name":"AddAdminDecoration.renderForm",style:{marginBottom:20},children:[t&&(0,g.jsx)("div",{children:(0,g.jsx)("p",{style:{color:"red",fontWeight:"bold"},children:t})}),(0,g.jsxs)("div",{className:"columns large-3 medium-12 small-12",children:[_("Charge Name","charge-name"),(0,g.jsx)(m.A,{id:"charge-name-"+o,field:"charge_name",value:i,required:!0,disabled:0==r,onChange:e=>{this.props.updateDecoration({charge_name:e.target.value})},onBlur:e=>this.props.updateDecorationRequest({charge_name:e.target.value})})]}),i?(0,g.jsxs)("div",{className:"columns large-"+(a&&"run"==a?"2":"3")+" medium-12 small-12",children:[_("Charge Type","charge-type"),(0,g.jsx)(h.A,{className:"charge-type-select",id:"charge-type-"+o,style:{fontSize:"initial"},searchable:!0,options:e,disabled:0==r,value:a,required:!0,onChange:e=>{const t={charge_type:e.value};"fixed"==e.value?t.matrix_type="list":t.matrix_type="table",n?this.props.updateDecoration(t):window.confirm("By changing Charge Type, your decoration table data might be removed.")&&(this.props.updateDecoration(t),this.props.updateDecorationRequest({charge_type:e.value}),"fixed"==e.value&&c>2&&this.props.removeMatrixCol(c-1,c))}})]}):null,i&&a?(0,g.jsxs)("div",{className:"columns large-3 medium-12 small-12",style:{paddingRight:0,width:"fit-content",marginRight:20},children:[_("Type","type"),(0,g.jsxs)("div",{className:"primary-toggle",children:[(0,g.jsx)("a",{onClick:e=>{e.preventDefault(),this.updateType("list")},className:"list"===x?" active-toggle":" inactive-toggle",children:"run"==a?"Per Item":"List"}),(0,g.jsx)("a",{onClick:e=>{e.preventDefault(),this.updateType("table")},className:"table"===x?" active-toggle":" inactive-toggle",children:"Table"})]})]}):null,i&&a&&"table"==x?(0,g.jsxs)("div",{className:"columns large-3 medium-12 small-12",style:{paddingLeft:0,paddingRight:0},children:[(0,g.jsxs)("div",{className:"columns medium-6",style:{paddingLeft:0,paddingRight:0},children:[_("Rows","rows-num"),(0,g.jsxs)("div",{className:"input-group",children:[(0,g.jsx)("a",{className:"input-group-label",style:{...b},onClick:()=>{this.hasMatrixPerAddUnit()||this.props.removeMatrixRow(1,this.hasMatrixPerAddUnit()?p-1:p)},children:"-"}),(0,g.jsx)(m.A,{className:"input-group-field",id:"rows-num",field:"rows_num",value:p,disabled:!0,style:{textAlign:"center",borderRadius:0},required:!0,onChange:this.onChangeRowsNum}),(0,g.jsx)("a",{className:"input-group-label",style:{...b,borderRadius:"0 3px 3px 0",fontSize:"0.8em"},onClick:()=>{this.props.addMatrixRow(1,this.hasMatrixPerAddUnit()?p-1:p)},children:"+"})]})]}),a&&"fixed"!=a?(0,g.jsxs)("div",{className:"columns medium-6",style:{paddingLeft:"0.5rem",paddingRight:0},children:[_("Breakdowns","cols-num"),(0,g.jsxs)("div",{className:"input-group",style:{},children:[(0,g.jsx)("a",{className:"input-group-label",style:b,disabled:0==r,onClick:()=>this.props.removeMatrixCol(1,c),children:"-"}),(0,g.jsx)(m.A,{className:"input-group-field",id:"cols-num",field:"cols_num",value:c,disabled:!0,style:{textAlign:"center",borderRadius:0},required:!0,onChange:this.onChangeColsNum}),(0,g.jsx)("a",{className:"input-group-label",disabled:0==r,style:{...b,borderRadius:"0 3px 3px 0",fontSize:"0.8em"},onClick:()=>this.props.addMatrixCol(1,c),children:"+"})]})]}):null]}):null,(0,g.jsxs)("div",{className:"columns medium-12 small-12",children:[_("Description","desc"),(0,g.jsx)(u.A,{id:"charge-desc-"+o,field:"charge_desc",value:s,required:!1,disabled:0==r,onChange:e=>{this.props.updateDecoration({charge_desc:e.target.value})},onBlur:e=>this.props.updateDecorationRequest({charge_desc:e.target.value})})]})]})}
1render(){if(!this.state.loading)return this.props.can_edit?this.renderForm():this.renderOnView()}}const _=(0,n.Ng)((e,t)=>({}),(e,t)=>({updateDecoration:o=>{const{decoration_id:i,decorator_id:a,decoration_data:s}=t;if(e((0,c.kU)(i,o)),o.charge_type&&s.is_new&&s.charge_name)return e((0,c.md)({...s,...o}))},updateDecorationRequest:o=>{const{decoration_id:i,decorator_id:a,decoration_data:s}=t;return s.is_new&&s.charge_name&&s.charge_type?e((0,c.md)({...s,...o})):s.is_new?void 0:e((0,c.R3)({decoration_id:i,decorator_id:a,...o}))},addMatrixRow:(o,i)=>!(t.decoration_data.is_new&&!t.decoration_data.charge_type)&&e((0,c.vk)(t.decoration_id,o,i)),addMatrixCol:(o,i)=>!(t.decoration_data.is_new&&!t.decoration_data.charge_type)&&e((0,c.fv)(t.decoration_id,o,i)),removeMatrixRow:(o,i)=>{if(i>1)return!(t.decoration_data.is_new&&!t.decoration_data.charge_type)&&e((0,c.kf)(t.decoration_id,o,i))},removeMatrixCol:(o,i)=>{if(i>0){if(t.decoration_data.is_new&&!t.decoration_data.charge_type)return!1;e((0,c.a$)(t.decoration_id,o,i))}},updateMatrix:o=>e((0,c.hK)(t.decoration_id,o)),setFixedType:o=>e((0,c.T)(t.decoration_id,o)),onAddChargeToState:o=>e((0,c.sY)(t.decoration_id,o)),onAddCharge:o=>e((0,c.yC)(t.decoration_id,o)),onUpdateCharge:o=>e((0,c.WG)(t.decoration_id,o))}))(x);var b=o(36297),C=o(37163);const y=e=>{let{className:t,style:o,children:i,...a}=e;return(0,g.jsx)("div",{"data-test-name":"Cell",className:`c-table--td ${t}`,style:{...o,border:"0.5px solid #CCD5DA"},...a,children:i})};class v extends i.Component{constructor(e){super(e),this.onBlur=()=>{this.props.onCellBlur((0,p.h_)(this.state.inputValue))},this.onChangeInputValue=e=>{this.setState({inputValue:e.target.value})},this.state={inputValue:(0,p.h_)(this.props.children)}}componentDidUpdate(e){this.props.children!==e.children&&this.setState({inputValue:this.props.children})}render(){const{cellValue:e,onCellBlur:t,className:o,style:i,inputClass:a,disabled:s,isInputEditable:r,rowIndex:n,columnIndex:l,rowCount:d,columnCount:c,isNumberMatrix:h,minNum:p=(h?{min:"0"}:null),scrollToColumn:u,scrollToRow:m,isLastCol:x,..._}=this.props;return(0,g.jsx)("div",{"data-test-name":"EditableCell.render",className:o,style:i,..._,children:(0,g.jsx)("input",{id:this.props.decoration_id+"_cell_"+n+"_"+l,type:h?"number":"text",...p,style:{border:"0.5px solid #CCD5DA",borderWidth:"0px 1px 1px 0",height:"100%",width:"100%",borderRadius:"unset",boxShadow:"inset 0 0px 2px rgba(42, 56, 63, 0.1)",textAlign:"left",backgroundColor:r?"initial":"white",...1==n?{borderTop:0}:{},...1==l?{borderLeft:0}:{}},className:`c-editable-cell--input ${a}`,value:this.state.inputValue,onChange:this.onChangeInputValue,onBlur:this.onBlur,disabled:s||!r,onFocus:e=>e.target.select(),onKeyDown:e=>{if(e.shiftKey&&"Enter"==e.key){u(l),m(n-1);const e=document.getElementById(this.props.decoration_id+"_cell_"+(n-1)+"_"+l);e&&e.focus()}else if("Enter"==e.key){u(l),m(n+1);const e=document.getElementById(this.props.decoration_id+"_cell_"+(n+1)+"_"+l);e&&e.focus()}else if(e.shiftKey&&"Tab"==e.key)if(0!==l)u(l-1);else{u(c-1);const e=document.getElementById(this.props.decoration_id+"_cell_"+(n-1)+"_"+(c-1));e&&e.focus()}else"Tab"==e.key&&(x?(u(1),m(n+1),setTimeout(()=>{const e=document.getElementById(this.props.decoration_id+"_cell_"+(n+1)+"_1");e&&e.focus()},150)):u(l+1))}})})}}var f=o(31580),w=o.n(f);const j=e=>{let{isHeader:t,style:o,isBoxShadow:i,isChecked:a,onHandleCheckbox:s,className:r,checkboxKey:n,...l}=e;return t?(0,g.jsxs)("div",{className:w()("c-table--th c-checkbox-cell",{"c-table--box-shadow-th":i}),style:o,...l,children:[(0,g.jsx)("input",{id:`c-checkbox-label-${n}`,type:"checkbox",name:"checkbox",onChange:e=>s(e.target.checked),className:"c-checkbox-cell--input"}),(0,g.jsx)("label",{htmlFor:`c-checkbox-label-${n}`})]}):(0,g.jsxs)("div",{style:o,className:`c-table--td c-checkbox-cell ${r}`,...l,children:[(0,g.jsx)("input",{id:`c-checkbox-label-${n}`,type:"checkbox",onChange:e=>s(e.target.checked),checked:a,className:"c-checkbox-cell--input"}),(0,g.jsx)("label",{htmlFor:`c-checkbox-label-${n}`})]})},S=e=>{let{isAccending:t=!0,isActive:o=!1,...i}=e;return t?(0,g.jsx)("button",{className:w()("c-sort-button",{"c-sort-button--active":o}),...i,children:"↑"}):(0,g.jsx)("button",{className:w()("c-sort-button",{"c-sort-button--active":o}),...i,children:"↓"})},T=e=>{let{isSortOn:t,headerLabel:o,isActiveSortCell:i,onSort:a,isAccendingSort:s,style:r,isBoxShadow:n,onLabelClick:l,columnIndex:d,...c}=e;const h=0==d?"white":"#5CA3B6";return(0,g.jsxs)("div",{"data-test-name":"HeaderCell",style:{...r,textAlign:"center",backgroundColor:"#f2f2f2",fontWeight:"bold",color:h}
1,className:w()("c-table--th",{"c-table--box-shadow-th":n}),children:[(0,g.jsx)("p",{onClick:l||null,className:w()({"c-table--th-sort":t,"c-table--th-sort-active":i,"c-table--th-label-clickable":l}),children:o}),t&&(0,g.jsx)(S,{onClick:a,isActive:i,isAccending:s&&i})]})},D=e=>{let{style:t,isFirstCell:o,subHeaderTitle:i,...a}=e;return o?(0,g.jsx)("div",{style:t,className:"c-table--td c-table--sub-header-title",children:i}):(0,g.jsx)("div",{style:t,className:"c-table--td c-table--sub-header"})};class N extends i.Component{constructor(e){super(e),this.onBlur=()=>{this.props.onCellBlur(this.state.inputValue),this.props.checkValOnUpdate&&this.state.inputValue!==this.props.children&&this.setState({inputValue:this.props.children})},this.onChangeInputValue=e=>{this.props.checkNumber&&isNaN(e.target.value)||this.setState({inputValue:e.target.value})},this.state={inputValue:this.props.children},this.handleOnKeyDown=this.handleOnKeyDown.bind(this)}componentDidUpdate(e){this.props.children!==e.children&&this.setState({inputValue:this.props.children})}handleOnKeyDown(e){9==e.keyCode&&this.props.scrollToColumn(this.props.isLastCol?1:this.props.columnIndex+1)}renderInputLabel(){const{inputLabel:e,inputLabelPrefix:t,inputLabelPostfix:o}=this.props;return t&&o?t+e+o:t?t+e:o?e+o:e}render(){const{cellValue:e,onCellBlur:t,idx:o,isHeader:i,inputLabel:a,inputLabelPrefix:s,inputLabelPostfix:r,noInputLabel:n,checkNumber:l,inputStyles:d={},fixedColLabel:c,isInputEditable:h,hasDel:p,rowObj:u,...m}=this.props,x=u&&"per_additional_unit"==u.price_by_type;if(!1!==c&&null!=c)return(0,g.jsx)("div",{"data-test-name":"InputCell.render",className:"two columns end",style:{display:"inline-block",paddingRight:"5px",paddingLeft:"10px",overflow:"hidden",whiteSpace:"nowrap",width:"100%",textAlign:"left",marginTop:"10px"},children:(0,g.jsx)("label",{style:{fontSize:"1rem",overflow:"auto",whiteSpace:"nowrap",fontWeight:"bold"},children:c})});if(i)return!1===h?(0,g.jsxs)("div",{"data-test-name":"InputCell.render",style:{overflow:"hidden"},children:[(0,g.jsx)("div",{className:"three columns",style:{display:"inline-block",paddingRight:"5px",paddingLeft:"10px",overflow:"auto",whiteSpace:"nowrap",width:n?"100%":"50%",textAlign:n?"center":"right",marginTop:"10px"},children:(0,g.jsx)("label",{style:{fontSize:"1rem"},children:this.state.inputValue})}),n?null:(0,g.jsx)("div",{className:"two columns end",style:{display:"inline-block",paddingRight:"10px",paddingLeft:"2px",overflow:"auto",whiteSpace:"nowrap",width:"50%",textAlign:"left",marginTop:"10px"},children:(0,g.jsx)("label",{style:{fontSize:"1rem"},children:this.renderInputLabel()})})]}):(0,g.jsxs)("div",{"data-test-name":"InputCell.render",children:[(0,g.jsx)("div",{className:"three columns",style:{display:"inline-block",paddingLeft:"10px",paddingRight:"3px",width:n?"100%":"50%"},children:(0,g.jsx)("input",{type:l?"number":"text",className:"",id:"coldef_"+o,placeholder:this.props.placeholder,value:this.state.inputValue,style:{marginTop:"5px",textAlign:n?"center":"right",...d},onChange:this.onChangeInputValue,onBlur:this.onBlur,onFocus:e=>e.target.select()})}),n?null:(0,g.jsx)("div",{className:"two columns end",style:{display:"inline-block",paddingRight:"10px",paddingLeft:"2px",overflow:"hidden",whiteSpace:"nowrap",width:"50%",textAlign:"left",marginTop:"10px"},children:(0,g.jsx)("label",{style:{fontSize:"1rem",overflow:"auto"},children:this.renderInputLabel()})})]});let _={};return n&&(_={position:"inherit",width:"85%",left:12,top:1,marginBottom:10}),!1===h?(0,g.jsxs)("span",{"data-test-name":"InputCell.render",style:{fontSize:"1rem",paddingLeft:20,marginTop:x?0:15,float:"left",textAlign:"left"},children:[(0,g.jsxs)("span",{children:[x&&(0,g.jsx)("span",{style:{fontSize:"0.875rem"},children:(0,g.jsxs)("strong",{children:["Each ",(0,g.jsx)("br",{}),"Additional"]})})," ","  "+this.state.inputValue]}),n?null:(0,g.jsx)("div",{style:{marginBottom:6,verticalAlign:"middle",fontSize:"1rem",paddingLeft:"80px"},children:(0,g.jsx)("span",{children:a})})]}):!0===p?(0,g.jsx)("div",{"data-test-name":"InputCell.render",className:"row",style:{marginTop:-5},children:(0,g.jsxs)("div",{className:"input-group",style:{height:33,marginTop:2,display:"inline-block"},children:[!0===this.props.shouldDeleteRow()&&(0,g.jsx)("a",{className:"input-group-label",style:{color:"#5CA3B6",padding:0,fontSize:"0.6em",lineHeight:0,textAlign:"center",display:"inline-block",width:"15%",height:33,paddingBottom:0,paddingTop:15,background:"inherit",border:0,marginLeft:x?-45:-15,visibility:!0===this.props.isHovering?"visible":"hidden"},onClick:this.props.onDelete,children:"×"}),x&&(0,g.jsxs)("label",{style:{width:"10%",display:"inline-block",background:"none",border:0,overflow:"visible",marginRight:20,lineHeight:"normal",paddingRight:25},children:["Each ",(0,g.jsx)("br",{}),"Additional"]}),(0,g.jsx)("input",{className:"input-group-field",id:"rowdef_"+o,value:this.state.inputValue,field:"rowdef_"+o,type:l?"number":"text",style:{width:x?"40%":"80%",borderRadius:3,dis
1play:"inherit",height:"inherit",...x?{marginLeft:30,marginRight:-20}:{}},onChange:this.onChangeInputValue,onBlur:this.onBlur,onFocus:e=>e.target.select(),disabled:!1===h})]})}):(0,g.jsxs)("div",{"data-test-name":"InputCell.render",className:"row",style:{marginTop:-5},children:[(0,g.jsx)("div",{style:{height:33,left:3,position:"absolute",top:1,width:"100%",display:"inline-block",..._},children:(0,g.jsx)("input",{type:l?"number":"text",id:"rowdef_"+o,value:this.state.inputValue,style:{marginTop:2,height:"inherit",textAlign:"right",background:"initial",...d},onChange:this.onChangeInputValue,onBlur:this.onBlur,onFocus:e=>e.target.select(),disabled:!1===h})}),n?null:(0,g.jsx)("div",{style:{marginBottom:6,verticalAlign:"middle",fontSize:"1rem",paddingLeft:"80px"},children:(0,g.jsx)("span",{children:a})})]})}}var R=o(53949);class k extends a().PureComponent{constructor(){return super(...arguments),this.state={scrollToColumn:0,scrollToRow:0,instanceProps:{prevScrollToColumn:0,prevScrollToRow:0}},this._columnStartIndex=0,this._columnStopIndex=0,this._rowStartIndex=0,this._rowStopIndex=0,this._onKeyDown=e=>{const{columnCount:t,disabled:o,mode:i,rowCount:a}=this.props;if(o)return;const{scrollToColumn:s,scrollToRow:r}=this._getScrollState();let{scrollToColumn:n,scrollToRow:l}=this._getScrollState();e.shiftKey&&"Enter"==e.key?l="cells"===i?Math.max(l-1,0):Math.max(this._rowStartIndex-1,0):"Enter"==e.key?l="cells"===i?Math.min(l+1,a-1):Math.min(this._rowStopIndex+1,a-1):e.shiftKey&&"Tab"==e.key?n="cells"===i?Math.max(n-1,0):Math.max(this._columnStartIndex-1,0):"Tab"==e.key&&(console.log("right"),n="cells"===i?Math.min(n+1,t-1):Math.min(this._columnStopIndex+1,t-1)),n===s&&l===r||(e.preventDefault(),this._updateScrollState({scrollToColumn:n,scrollToRow:l}))},this._onSectionRendered=e=>{let{columnStartIndex:t,columnStopIndex:o,rowStartIndex:i,rowStopIndex:a}=e;this._columnStartIndex=t,this._columnStopIndex=o,this._rowStartIndex=i,this._rowStopIndex=a},this}static getDerivedStateFromProps(e,t){return e.isControlled?{}:e.scrollToColumn!==t.instanceProps.prevScrollToColumn||e.scrollToRow!==t.instanceProps.prevScrollToRow?{...t,scrollToColumn:e.scrollToColumn,scrollToRow:e.scrollToRow,instanceProps:{prevScrollToColumn:e.scrollToColumn,prevScrollToRow:e.scrollToRow}}:{}}setScrollIndexes(e){let{scrollToColumn:t,scrollToRow:o}=e;this.setState({scrollToRow:o,scrollToColumn:t})}render(){const{className:e,children:t}=this.props,{scrollToColumn:o,scrollToRow:i}=this._getScrollState();return(0,g.jsx)("div",{"data-test-name":"TabKeyStepper.render",className:e,onKeyDown:this._onKeyDown,children:t({onSectionRendered:this._onSectionRendered,scrollToColumn:o,scrollToRow:i})})}_getScrollState(){return this.props.isControlled?this.props:this.state}_updateScrollState(e){let{scrollToColumn:t,scrollToRow:o}=e;const{isControlled:i,onScrollToChange:a}=this.props;"function"==typeof a&&a({scrollToColumn:t,scrollToRow:o}),i||this.setState({scrollToColumn:t,scrollToRow:o})}}k.defaultProps={disabled:!1,isControlled:!1,mode:"edges",scrollToColumn:0,scrollToRow:0},(0,R.polyfill)(k);const A=k,I=function(e,t){let o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return e.sort((e,i)=>{if(o){if(e[t]>i[t])return-1;if(e[t]<i[t])return 1}else{if(e[t]<i[t])return-1;if(e[t]>i[t])return 1}return 0})};class L extends i.Component{constructor(e){super(e),this.state={hoveredColumnIndex:null,hoveredRowIndex:null,list:this.props.list,colDef:this.props.colDef,isAccending:!1,activeColumn:null,checkboxStates:{},scrollToColumn:0,scrollToRow:0},this._grid=null,this.cellRenderer=e=>{let{style:t,columnIndex:o,rowIndex:i,key:a}=e;const{list:s,colDef:r,isSortOn:n,isZebra:l,hoverOnX:d,hoverOnY:c,isBoxShadow:h,onLabelClick:p,showHeader:u}=this.props,m=s[i-1],x=r[o].key;if(r[o].style&&r[o].style,!r[o].disableHeader||r[o].disableHeader,0===i&&"checkbox"!==x){if(r[o].input_header){const e=r[o].input_header;return(0,g.jsx)(y,{"data-test-name":"Table",style:{...t,textAlign:"center",backgroundColor:"#f2f2f2",fontWeight:"bold",color:"#5CA3B6",alignItems:"baseline",...e.parentStyles?e.parentStyles:{},borderRight:0==o||o==r.length-1?"2px solid rgb(204, 213, 218)":"1px solid rgb(204, 213, 218)"}
1,className:"c-table--box-shadow-th row",onMouseOver:()=>this.onMouseOverCell(c,d,o,i),children:(0,g.jsx)(N,{isHeader:e.isHeader,idx:r[o][e.idxKey],inputLabel:e.inputLabel?e.inputLabel:r[o][e.inputLabelKey]?r[o][e.inputLabelKey]:"",inputLabelPrefix:o==r.length-1?e.inputLabelLastPrefix:e.inputLabelPrefix,onCellBlur:e=>this.onEditColDef(e,r[o]),noInputLabel:e.noInputLabel,checkNumber:e.checkNumber,placeholder:e.placeholder,checkValOnUpdate:e.checkValOnUpdate,inputStyles:e.inputStyles,fixedColLabel:o>0&&this.props.fixedColLabel,isInputEditable:this.props.isInputEditable,columnIndex:o,rowIndex:i,isLastCol:o===r.length-1,isLastRow:i===s.length-1,scrollToColumn:this._onScrollToColumnChange,scrollToRow:this._onScrollToRowChange,children:e.value?e.value:r[o][e.valueKey]})},a)}if(r[o].header_component){const e=r[o].header_component;return(0,g.jsx)(y,{"data-test-name":"Table",style:{...t,textAlign:"center",backgroundColor:"#f2f2f2",fontWeight:"bold",color:"#5CA3B6",alignItems:"baseline"},className:"c-table--box-shadow-th row",onMouseOver:()=>this.onMouseOverCell(c,d,o,i),children:(0,g.jsx)(e,{rowData:m,columnIndex:o,rowIndex:i,isLastCol:o===r.length-1,isLastRow:i===s.length-1,scrollToColumn:this._onScrollToColumnChange,scrollToRow:this._onScrollToRowChange,columnData:r[o],onColBlur:e=>this.onEditColDef(e,r[o]),onColChange:e=>this.onEditColDef(e,r[o]),fixedColLabel:o>0&&this.props.fixedColLabel})},a)}const e=r[o].label,l=this.state.activeColumn===x;return(0,g.jsx)(T,{"data-test-name":"Table",columnIndex:o,rowIndex:i,isLastCol:o===r.length-1,isLastRow:i===s.length-1,scrollToColumn:this._onScrollToColumnChange,scrollToRow:this._onScrollToRowChange,style:t,isBoxShadow:h,headerLabel:e,isSortOn:n,onSort:()=>this.sortColumn(x),onLabelClick:!!p&&(()=>p(r[o])),isInputEditable:this.props.isInputEditable,isActiveSortCell:l,isAccendingSort:this.state.isAccending&&l},a)}if(m&&m.subheader)return(0,g.jsx)(D,{"data-test-name":"Table",style:t,isFirstCell:0===o,subHeaderTitle:m.subheader},a);const _=l?this.getRowClass(i):"",b=c||d?this.getHoverCellClass(i,o):"";if("checkbox"===x){const e=0===i;return(0,g.jsx)(j,{"data-test-name":"Table",checkboxKey:a,style:t,className:`${_} ${b}`,isHeader:e,isBoxShadow:h,onHandleCheckbox:t=>this.onHandleCheckbox(t,e?"ALL":m),isChecked:m&&!!this.state.checkboxStates[m.id]&&this.state.checkboxStates[m.id].isChecked,onMouseOver:()=>this.onMouseOverCell(c,d,o,i)},a)}if(r[o].component){const e=r[o].component;return(0,g.jsx)(y,{"data-test-name":"Table",style:t,className:`${_} ${b}`,onMouseOver:()=>this.onMouseOverCell(c,d,o,i),children:(0,g.jsx)(e,{rowData:m,isInputEditable:this.props.isInputEditable,columnKey:x,onCellBlur:e=>this.onEditCell(e,m,x),onCellChange:e=>this.onEditCell(e,m,x),onMouseOver:()=>this.onMouseOverCell(c,d,o,i),isHovering:o===this.state.hoveredColumnIndex||i===this.state.hoveredRowIndex,columnIndex:o,rowIndex:i,isLastCol:o===r.length-1,isLastRow:i===s.length-1,scrollToColumn:this._onScrollToColumnChange,scrollToRow:this._onScrollToRowChange})},a)}if(r[o].input_component){const e=r[o].input_component;return(0,g.jsx)(y,{"data-test-name":"Table",style:{...t,borderBottom:"1px solid rgb(204, 213, 218)",borderRight:"2px solid rgb(204, 213, 218)"},className:`${_} ${b} c-header-bg`,onMouseOver:()=>this.onMouseOverCell(c,d,o,i),children:(0,g.jsx)(N,{isHeader:e.isHeader,idx:e.idx?e.idx:m[e.idxKey],inputLabel:e.inputLabel?e.inputLabel:m[e.inputLabelKey],onCellBlur:e=>this.onEditCell(e,m,x),checkNumber:e.checkNumber,checkValOnUpdate:e.checkValOnUpdate,inputStyles:e.inputStyles,noInputLabel:e.noInputLabel,isInputEditable:this.props.isInputEditable,hasDel:e.hasDel,onDelete:e=>{e.preventDefault(),this.props.onRemoveMatrixRow(i)},hoverCellClass:b,isHovering:o===this.state.hoveredColumnIndex||i===this.state.hoveredRowIndex,shouldDeleteRow:this.props.shouldDeleteRow,rowObj:m,columnIndex:o,rowIndex:i,isLastCol:o===r.length-1,isLastRow:i===s.length-1,scrollToColumn:this._onScrollToColumnChange,scrollToRow:this._onScrollToRowChange,children:e.value?e.value:m[e.valueKey]})},a)}return this.props.isEditable&&!1!==r[o].editable?(0,g.jsx)(v,{"data-test-name":"Table",style:t,className:`${_} ${b}`,inputClass:l?"c-table--input-zebra":"",onCellBlur:e=>this.onEditCell(e,m,x),isInputEditable:this.props.isInputEditable,isNumberMatrix:this.props.isNumberMatrix,onMouseOver:()=>this.onMouseOverCell(c,d,o,i),columnIndex:o,rowIndex:i,isLastCol:o===r.length-1,scrollToColumn:this._onScrollToColumnChange,scrollToRow:this._onScrollToRowChange,columnCount:r.length,rowCount:s.length,onClick:()=>{this._selectCell({scrollToColumn:o,scrollToRow:i})}
1,decoration_id:this.props.decoration_id,children:m[x]},a):(0,g.jsx)(y,{"data-test-name":"Table",style:t,className:`${_} ${b} c-cell-border`,onMouseOver:()=>this.onMouseOverCell(c,d,o,i),children:m[x]},a)},this.onHandleCheckbox=(e,t)=>{if("ALL"===t){const t=this.props.list.reduce((t,o,i,a)=>(t[o.id]={id:o.id,isChecked:e},t),{});this.setState({checkboxStates:t})}this.setState(o=>{let{checkboxStates:i}=o;return{checkboxStates:{...i,[t.id]:{id:t.id,isChecked:e}}}})},this.onMouseOverCell=(e,t,o,i)=>{(e||t)&&this.setState({hoveredColumnIndex:e?o:null,hoveredRowIndex:t?i:null})},this.getHoverCellClass=(e,t)=>t===this.state.hoveredColumnIndex||e===this.state.hoveredRowIndex?"c-table--td-hover-cell":"",this.onEditCell=(e,t,o)=>{this.props.onCellChange({rowObj:t,key:o,newValue:e})},this.onEditColDef=(e,t)=>{this.props.onColDefChange(e,t)},this.getRowClass=e=>e%2==0?"c-table--row-even":"c-table--row-odd",this.calculateGridWidth=(e,t)=>{const o=e.reduce((e,t)=>e+t.size,0);return o<t?o:t},this.calculateGridHeight=(e,t)=>t*(e.length+(this.props.showHeader?1:0)),this._onScrollToRowCol=(e,t,o,i)=>{this.setState({scrollToColumn:t,scrollToRow:e},()=>{})},this._selectCell=e=>{let{scrollToColumn:t,scrollToRow:o}=e;this.setState({scrollToColumn:t,scrollToRow:o})},this._onScrollToColumnChange=this._onScrollToColumnChange.bind(this),this._onScrollToRowChange=this._onScrollToRowChange.bind(this)}getHeaderHeight(){return this.props.showHeader?this.props.headerHeight:0}_onScrollToColumnChange(e){this.setState({scrollToColumn:e})}_onScrollToRowChange(e){this.setState({scrollToRow:e})}sortColumn(e){const t=this.state.activeColumn!==e,{isAccending:o}=this.state,{list:i,updateList:a}=this.props;if(t){let t=I(i,e,!0);a&&a(t),this.setState(t=>{let{isAccending:o}=t;return{isAccending:!0,activeColumn:e}},()=>this._grid.forceUpdateGrids())}else{let t=I(i,e,!o);a&&a(t),this.setState(t=>{let{isAccending:o}=t;return{isAccending:!o,activeColumn:e}},()=>this._grid.forceUpdateGrids())}}renderTabbed(){const{colDef:e,fixedRowCount:t,fixedColumnCount:o,fixedHeight:s,fixedWidth:r,style:n,rowHeight:l,isBoxShadow:d,footer:c,list:h}=this.props;return(0,g.jsx)(A,{"data-test-name":"Table.renderTabbed",columnCount:e.length,rowCount:h.length+1,scrollToRow:this.state.scrollToRow,scrollToColumn:this.state.scrollToColumn,mode:"cells",onScrollToChange:this._selectCell,children:p=>{let{onSectionRendered:u,scrollToColumn:m,scrollToRow:x}=p;return(0,g.jsx)(C.A,{disableHeight:!0,children:p=>{let{width:_}=p;return(0,g.jsxs)(i.Fragment,{children:[(0,g.jsx)(b.MultiGrid,{ref:e=>this._grid=e,style:{boxShadow:d?"0 1px 4px 0 rgba(41, 51, 57, 0.5)":"",...n},cellRenderer:this.cellRenderer,columnWidth:t=>{let{index:o}=t;return e[o].size},columnCount:e.length,fixedRowCount:t,fixedColumnCount:o,rowHeight:e=>0===e.index?this.getHeaderHeight():l,height:s||this.calculateGridHeight(h,l),width:r||this.calculateGridWidth(e,_),rowCount:h.length+1,classNameTopLeftGrid:"c-table--top-left-grid",classNameTopRightGrid:"c-table--top-right-grid",classNameBottomLeftGrid:"c-table--bottom-left-grid",classNameBottomRightGrid:"c-table--bottom-right-grid",scrollToRow:x,scrollToColumn:m,onSectionRendered:u}),c&&a().cloneElement(c,{width:r||this.calculateGridWidth(e,_)})]})}})}})}render(){const{colDef:e,fixedRowCount:t,fixedColumnCount:o,fixedHeight:s,fixedWidth:r,style:n,rowHeight:l,headerHeight:d,isBoxShadow:c,footer:h,list:p,showHeader:u}=this.props;return(0,g.jsx)(C.A,{"data-test-name":"Table.render",disableHeight:!0,children:d=>{let{width:u}=d;return(0,g.jsxs)(i.Fragment,{"data-test-name":"Table.render",children:[(0,g.jsx)(b.MultiGrid,{ref:e=>this._grid=e,style:{boxShadow:c?"0 1px 4px 0 rgba(41, 51, 57, 0.5)":"",...n},cellRenderer:this.cellRenderer,columnWidth:t=>{let{index:o}=t;return e[o].size},columnCount:e.length,fixedRowCount:t,fixedColumnCount:o,rowHeight:e=>0===e.index?this.getHeaderHeight():l,height:s||this.calculateGridHeight(p,l),width:r||this.calculateGridWidth(e,u),rowCount:p.length+1,classNameTopLeftGrid:"c-table--top-left-grid",classNameTopRightGrid:"c-table--top-right-grid",classNameBottomLeftGrid:"c-table--bottom-left-grid",classNameBottomRightGrid:"c-table--bottom-right-grid",scrollToRow:this.state.scrollToRow,scrollToColumn:this.state.scrollToColumn,onScrollToChange:this._selectCell}),h&&a().cloneElement(h,{width:r||this.calculateGridWidth(e,u)})]})}})}}L.defaultProps={isBoxShadow:!0,rowHeight:50,headerHeight:50,showHeader:!0};var M=o(88871);class B extends i.Component{constructor(e){super(e),this.onListItemChange=this.onListItemChange.bind(this),this.onListItemChangeRequest=this.onListItemChangeRequest.bind(this)}onListItemChange(e){null!==e.unit&&void 0!==e.unit?(this.props.updateDecoration({units:e.unit}),this.props.onUpdateChargesState({unit:e.unit})):null!==e.qty&&void 0!==e.qty&&(this.props.updateDecoration({qty:e.qty}),this.props.onUpdateChargesState({qty:e.qty}))}onListItemChangeRequest(e){null!==e.unit&&void 0!==e.unit?(this.props.updateDecorationRequest({units:e.unit}),this.props.onUpdateChargesState({unit:e.unit})):null!==e.qty&&void 0!==e.qty&&(this.props.updateDecorationRequest({qty:e.qty}),this.props.onUpdateChargesState({qty:e.qty}))}hasMatrixPerAddUnit(){const{decoration_data:{matrix:e}}=this.props;return!!(e&&e.cols&&e.data&&e.data.length>1&&"table"==e.type&&"per_additional_unit"==e.data[e.data.length-1].price_by_type)}renderList(){const{decoration_data:{matrix:e,charge_type:t,units:o,qty:i},updateMatrix:a,onAddCharge:s,onUpdateCharge:r,onRemoveListChargeItemRow:n,can_edit:l}=this.props;return(0,g.jsxs)("div",{"data-test-name":"AdminDecorationChargesMatrix.renderList",children:["fixed"==t?(0,g.jsx)(M.eP,{charge_data:{unit:o,qty:i},charge_type:t,onChange:this.onListItemChange,onUpdateRequest:this.onListItemChangeRequest,onDelete:()=>a({type:"list",all:!0}),is_parent:!0,is_decoration:!0,can_edit:l}):null,e.data.map((e,a)=>(0,g.jsx)(M.eP,{"data-test-name":"AdminDecorationChargesMatrix.renderList",charge_data:e,charge_type:t,idx:a,onChange:r,onDelete:n,is_child:!0,parent_data:{unit:o,qty:i},can_edit:l},e.row_num+"_"+e.cell_value+"_"+a)),l?(0,g.jsx)("div",{className:"columns medium-12 small-12 large-12",style:{textAlign:"left"},children:(0,g.jsx)("a",{style:{fontSize:"1rem"},onClick:e=>{e.preventDefault(),s({cell_value:(0,p.h_)(1),unit:"",qty:1,label:""})},children:"+ Add Charge"})}):null]})}renderTable(){const{decoration_data:{matrix:e,charge_type:t},updateMatrixCell:o,updateMatrixList:i,updateMatrixColsDef:a,onRemoveMatrixRow:s,can_edit:r}=this.props;return(0,g.jsx)("div",{"data-test-name":"AdminDecorationChargesMatrix.renderTable",children:(0,g.jsxs)("div",{className:"small-1"+(r?"1":"2")+" columns",style:{paddingLeft:0,float:"left"},children:[(0,g.jsx)("div",{id:"my-table",children:e.cols&&e.cols.length>0&&e.data.length>0?(0,g.jsx)(L,{colDef:e.cols,list:e.data,isInputEditable:r,isNumberMatrix:!0,isEditable:!0,fixedRowCount:1,fixedColumnCount:1,onCellChange:o,updateList:i,onColDefChange:(e,t)=>
1a({newValue:e,colObj:t}),fixedColLabel:"fixed"==t&&"Cost",onRemoveMatrixRow:t=>{e.data&&e.data.length>1&&s(parseInt(t))},shouldDeleteRow:()=>!!(e.data&&e.data.length>1),hoverOnX:!0,decoration_id:this.props.decoration_id}):null}),r&&"fixed"!=t&&e.data&&e.data.length>1&&!this.hasMatrixPerAddUnit()&&(0,g.jsx)("div",{style:{backgroundColor:"rgb(242, 242, 242)",textAlign:"left",fontSize:18,fontWeight:"bold",padding:10},children:(0,g.jsxs)("a",{onClick:()=>{this.props.addMatrixRow(1,{price_by_type:"per_additional_unit"})},children:["+ Greater than ",e.data[e.data.length-1]["-"]]})})]})})}render(){return"list"==this.props.type?this.renderList():this.renderTable()}}const H=(0,n.Ng)((e,t)=>({}),(e,t)=>({updateMatrixColsDef:o=>{if(!t.decoration_data.is_new)return 0==o.colObj.idx?(e((0,c.R3)({decoration_id:t.decoration_id,decorator_id:t.decorator_id,units:o.newValue})),e((0,c.hK)(t.decoration_id,{units:o.newValue}))):e((0,c.Rs)(t.decoration_id,o))},updateMatrixList:o=>{if(!t.decoration_data.is_new)return e((0,c.nP)(t.decoration_id,o))},updateMatrixCell:o=>{if(!t.decoration_data.is_new){if("-"==o.key)return e((0,c.tN)(t.decoration_id,o));{const i=t.decoration_data.matrix.cols.filter(e=>e.key==o.key)[0];return e((0,c.dc)(t.decoration_id,o,i))}}},updateDecoration:o=>{const{decoration_id:i,decorator_id:a,decoration_data:s}=t;e((0,c.kU)(i,o))},updateDecorationRequest:o=>{const{decoration_id:i,decorator_id:a,decoration_data:s}=t;return s.is_new&&s.charge_name&&s.charge_type?e((0,c.md)({...s,...o})):s.is_new?void 0:e((0,c.R3)({decoration_id:i,decorator_id:a,...o}))},onAddChargeState:()=>{const o=(0,p.Kl)(t.decoration_data.matrix.data.length,t.decoration_data.units);return e((0,c.sY)(t.decoration_id,o))},onAddCharge:o=>e((0,c.yC)(t.decoration_id,o)),onUpdateCharge:o=>{const{decoration_data:{matrix:i}}=t;let a=i.data.filter(e=>e.charge_id==o.charge_id)[0];return a&&a.charge_id&&-1!=a.charge_id.indexOf("temp_charge_")?e((0,c.yC)(t.decoration_id,{...a,...o})):e((0,c.WG)(t.decoration_id,o))},onUpdateChargeState:o=>e((0,c.j2)(t.decoration_id,o)),onUpdateChargesState:o=>e((0,c.Gc)(t.decoration_id,o)),onRemoveMatrixRow:o=>{const{decoration_data:{matrix:i}}=t;i.data.length>1&&e((0,c.Hc)(t.decoration_id,o))},onRemoveListChargeItemRow:o=>e((0,c.OZ)(t.decoration_id,o)),updateMatrix:o=>e((0,c.hK)(t.decoration_id,o)),addMatrixRow:(o,i)=>!(t.decoration_data.is_new&&!t.decoration_data.charge_type)&&e((0,c.vk)(t.decoration_id,o,i))}))(B);class O extends i.Component{constructor(e){super(e),this.state={removing:!1,charge_types:[{key:"run",value:"Run charge"},{key:"fixed",value:"Fixed Charge"}]},this.onDelete=this.onDelete.bind(this),this.onCopy=this.onCopy.bind(this)}onDelete(e){window.confirm("Are you sure you want to delete?")&&this.setState({removing:!0},()=>{setTimeout(()=>{this.props.deleteDecoration(e),this.setState({removing:!1})},300)})}onCopy(e){this.props.copyDecoration(e),window.scrollTo(0,document.body.scrollHeight)}render(){const{decoration:e,decorator_id:t,idx:o,decoration_id:i,cols_num:a,rows_num:s,onSave:r,deleteDecoration:n,copyDecoration:l,can_edit:d}=this.props,{removing:c}=this.state;return(0,g.jsx)("div",{"data-test-name":"Card.render",className:"medium-12 small-12 columns",style:{transition:"all 250ms linear",opacity:c?0:"unset",background:"rgb(235, 240, 243)"},children:(0,g.jsxs)("div",{className:"large-12 medium-12 columns card",style:{marginBottom:"20px",textAlign:"center",fontSize:"2em",padding:"10px 10px",paddingBottom:"30px"},children:[(0,g.jsxs)("div",{className:"medium-12 columns",children:[(0,g.jsxs)("h4",{children:[e?e.charge_name+"  ":null,d?null:(0,g.jsx)("span",{children:e&&e.charge_type?"("+this.state.charge_types.filter(t=>t.key==e.charge_type)[0].value+")":null})]}),d?(0,g.jsxs)("div",{className:"button-group",style:{float:"right"},children:[(0,g.jsx)("a",{className:"button secondary-button",style:{marginRight:"10px",borderRight:"none"},onClick:this.onDelete,children:"Delete"}),(0,g.jsx)("a",{className:"button secondary-button",style:{marginRight:"10px",borderRight:"none"},onClick:this.onCopy,children:"Copy"})]}):null]}),e.error?(0,g.jsx)("div",{className:"medium-12 columns",children:(0,g.jsx)("p",{style:{textAlign:"center",fontSize:"0.8em",fontWeight:"600",color:"red"},children:e.error})}):null,(0,g.jsx)(_,{decoration_id:i,decorator_id:t,decoration_data:e,cols_num:a,rows_num:s,edit_me:!!e.new,type:e.matrix.type,can_edit:d}),(0,g.jsx)("br",{}),!e.is_new||e.charge_type&&e.charge_name?(0,g.jsx)(H,{decoration_id:i,decorator_id:t,decoration_data:e,type:e.matrix.type,can_edit:d}):null]})}
1,"_"+o)}}const E=(0,n.Ng)((e,t)=>({}),(e,t)=>({createDecoration:o=>{const i="dec_temp_"+t.decorations.length+"-"+parseInt(1e3*Math.random());return e((0,c.Xq)(t.decorator_id,{decoration_id:i,...o}))},addDecoration:(t,o,i,a,s)=>e((0,c.md)(t,o,i,a,s)),deleteDecoration:()=>e((0,c.SW)(t.decoration_id)),copyDecoration:()=>e((0,c.cs)(t.decoration_id)),onSave:t=>t.is_new?e((0,c.md)(t)):e((0,c.R3)(t)),updateMatrix:o=>e((0,c.hK)(t.decoration_id,o))}))(O);var q=o(3602);class P extends i.Component{constructor(e){super(e),this.onUpdateDecoratorDesc=r()(e=>{this.setState({decorator_description:e}),this.props.updateDecorator(this.props.decorator_id,{description:e})},300),this.state={top_margin:null,decorator_type:"division",select_placeholder:"Select a decorator or type to find more",loading:this.props.loading,error:"",can_edit:!1,decorator_description:"",sMatches:!1},["onSelectDecorator","onAddNewDecoration","onClickSave","filterDecorators","onEditDone","scrollToBottom","onUpdateDecoratorDesc","onDeleteAll"].forEach(e=>this[e]=this[e].bind(this))}componentDidMount(){this.props.loadDivisions("supplier-account",!0),this.props.loadSuppliers(),this.props.loadDecorators(this.state.decorator_type),this.scrollToTop(),this.mediaQueriesHandle()}mediaQueriesHandle(){window.matchMedia("(max-width: 640px)").addListener(e=>this.setState({sMatches:e.matches}))}scrollToBottom(){this.root.scrollTo(0,this.root.scrollHeight+300),window.scrollTo(0,document.body.scrollHeight+300)}scrollToTop(){window.scrollTo({top:0,left:0,behavior:"smooth"}),this.root.scrollTo({top:0,left:0,behavior:"smooth",block:"start"})}getDecorationData(e){return this.props.decorations.data.filter(t=>t.decoration_id==e)[0]}getDecoratorData(e){const t=this.props.original_decorators.filter(t=>t.decorator_id==e);return t&&t.length>0?t[0]:{}}onSelectDecorator(e){const t=this.getDecoratorData(e.value);Object.entries(t).length>0?(this.props.setDecorator(e.value,e.label),this.setState({error:"",decorator_description:t.description,can_edit:!1})):(this.props.setDecorator(e.value,e.label),this.setState({error:"",decorator_description:this.getDecoratorData(e.value).description,can_edit:!0})),this.scrollToTop()}onAddNewDecoration(e){e.preventDefault(),this.props.decorator_id?(this.props.createDecoration(this.props.decorator_id,{decoration_id:"dec_temp_"+this.props.decorations.data.length+"-"+parseInt(1e3*Math.random()),qty:1}),setTimeout(()=>{this.scrollToBottom()},500)):this.setState({error:"Please select a decorator."})}onClickSave(e){if(!e)return void this.setState({error:"Please select a decorator."});const t=this.getDecorationData(e);this.props.addDecoration(e,t)}filterDecorators(e,t){if(""==e||"string"!=typeof e)return void t(this.props.decorators.map(e=>({value:e.key,label:e.value,isDisabled:e.disabled})));let o=this.props.divisions;"supplier"==this.state.decorator_type&&(o=this.props.suppliers),Array.isArray(o)&&o&&o.length?t(o.map(e=>({value:e.key,label:e.value,isDisabled:e.disabled})).filter(t=>(t.label?t.label.toLowerCase():"").includes(e.toLowerCase()))):t(this.props.decorators.map(e=>({value:e.key,label:e.value,isDisabled:e.disabled})))}onDeleteAll(){window.confirm("You are about to delete all matrices for this decorator, are you sure you want to do this?")&&(this.props.deleteDecorator(this.props.decorator_id),this.props.deleteAllDecorations(this.props.decorator_id),this.props.setDecorator(null,null),this.setState({can_edit:!1}))}onEditDone(){this.setState(e=>({can_edit:!e.can_edit})),this.props.onEditDone(this.props.decorator_id)}renderNoDecorations(){if(this.props.decorator_id)return(0,g.jsx)("div",{"data-test-name":"AdminDecorations.renderNoDecorations",className:"large-12 medium-12 small-12 columns",style:{marginTop:20,fontSize:"1.5em",fontWeight:600,color:"#3C505A",textAlign:"center"}})}renderLoading(){return(0,g.jsx)("div",{"data-test-name":"AdminDecorations.renderLoading",className:"row popup-content column decoration-matrix",style:{marginTop:30},children:(0,g.jsx)("div",{className:"small-12 columns",children:(0,g.jsxs)("div",{className:"small-12 text-center",children:[(0,g.jsx)("br",{}),(0,g.jsx)("img",{src:"/images/gears.gif"}),(0,g.jsx)("br",{})]})})})}editBtnCLass(){return this.state.can_edit?"cta-button":"btn"}render(){const e=this.props.style?this.props.style:{},t=!!this.props.inPopup,o=t?{}:{...e,top:0,left:0,zIndex:100,width:"100%",height:"100%",position:"absolute",overflow:"inherit",background:"#EBF0F3",top:this.state.top_margin,marginTop:"-1rem",scrollBehavior:"smooth",paddingBottom:100},i=(t?"":"main-content ")+"decoration-matrix",{decorator_id:a,decorations:s,decorators:n,decorator_type:l}=this.props,{error:d,select_placeholder:c,can_edit:p,decorator_description:m}=this.state,x=a?this.getDecoratorData(a):{};if("supplier"==l){if(!this.props.suppliers.length||!(this.props.suppliers.length&&this.props.suppliers.length>1))return this.renderLoading()}else if(!("division"!=l||this.props.divisions.length&&this.props.divisions.length&&this.props.divisions.length>1))return this.renderLoading();return(0,g.jsx)("div",{"data-test-name":"AdminDecorations.render",ref:e=>this.root=e,className:i,style:o,children:(0,g.jsxs)("div",{className:"row full-width",style:{marginTop:"2rem"},children:[(0,g.jsxs)("div",{className:"large-12 medium-12 columns decorator-selection",style:{marginBottom:5,position:t?"relative":"fixed",width:"100%",backgroundColor:"white",marginTop:-15,overflow:"inherit",zIndex:10,padding:10},children:[(0,g.jsx)("div",{className:"small-12 medium-12 large-5 columns sel-decorator-p",children:(0,g.jsx)(h.A,{id:"select_decorator",label:"Decorator",value:a,onChange:this.onSelectDecorator,onOpen:e=>{var t,o;this.setState({select_placeholder:"Type to search for more decorators"});const i=document.querySelector("#select_decorator .commonsku-styles-select__single-value");null!=i&&null!==(t=i.parentNode)&&void 0!==t&&null!==(o=t.previousSibling)&&void 0!==o&&o.firstChild&&(i.parentNode.previousSibling.firstChild.innerHTML="<b>Type to search for more decorators</b>")},onBlur:e=>{var t,o;const i=document.querySelector("#select_decorator .commonsku-styles-select__single-value");null!=i&&null!==(t=i.parentNode)&&void 0!==t&&null!==(o=t.previousSibling)&&void 0!==o&&o.firstChild&&a&&(i.parentNode.previousSibling.firstChild.innerHTML=this.getDecoratorData(a).decorator_name)},loadOptions:this.filterDecorators,placeholder:c,options:n,disabled:!1!==p&&a,async:!0,defaultOptions:!0})}),a?(0,g.jsxs)("div",{children:[this.state.sMatches?null:(0,g.jsx)("br",{}),p?(0,g.jsx)(q.IconButton,{size:"small",onClick:this.onAddNewDecoration,id:"add-btn",style:{marginRight:"12px"},children:"Add New Decoration"}):null,(0,g.jsx)(q.IconButton,{size:"small",id:"edit-done-btn",Icon:q.EditIcon,iconPosition:"left",style:{padding:"7px",marginRight:"1rem"},onClick:this.onEditDone,children:p?"Save":"Edit"}
1),p?null:(0,g.jsx)(q.IconButton,{preset:"delete",size:"small",id:"edit-done-btn",onClick:this.onDeleteAll})]}):null]}),a?(0,g.jsx)("div",{className:"medium-12 small-12 columns"+(t?"":" decorator-info-p"),style:t?{paddingTop:"12px",background:"rgb(235, 240, 243)"}:null,children:(0,g.jsxs)("div",{className:"large-12 medium-12 columns card",style:{marginBottom:"40px",background:"white",textAlign:"left",padding:"10px 10px",paddingBottom:"30px"},children:[(0,g.jsx)("div",{className:"medium-12 columns",children:(0,g.jsx)("h4",{children:x.decorator_name})}),(0,g.jsx)("div",{className:"medium-12 columns",children:p?(0,g.jsx)(u.A,{value:m,onChange:e=>{this.setState({decorator_description:e.target.value}),r()(t=>{this.props.updateDecorator(this.props.decorator_id,{description:e.target.value})},300)},onBlur:e=>{this.props.updateDecorator(a,{description:e.target.value})}}):(m||"").split("\n").map((e,t)=>(0,g.jsx)("div",{"data-test-name":"AdminDecorations.render",children:e},t))})]})}):null,d?(0,g.jsx)("div",{className:"medium-12 columns",style:{fontSize:"1.3em",textAlign:"center",fontWeight:"bold"},children:d}):null,s.data&&s.data.length?(0,g.jsx)("div",{children:s.data.map((e,t)=>e&&e.matrix&&(0,g.jsx)(E,{idx:t,decoration_id:e.decoration_id,decorator_id:a,decoration:e,cols_num:e.matrix.cols?0==e.matrix.cols.length?0:e.matrix.cols.length-1:0,rows_num:e.matrix.data.length,can_edit:p},"dec_card-"+t))}):s.loading?this.renderLoading():this.renderNoDecorations(),(0,g.jsx)("div",{className:"large-12 medium-12 columns",style:t?{textAlign:"left",paddingBottom:"12px",background:"rgb(235, 240, 243)"}:{textAlign:"left"},children:p?(0,g.jsx)(q.IconButton,{size:"small",onClick:this.onAddNewDecoration,children:"Add New Decoration"}):null})]})})}}const $=(0,n.Ng)((e,t)=>{let o=e.entities.divisions?e.entities.divisions:e.dropdowns.divisions;o=o?Object.values(o):[],o=o.map(e=>({key:e.division_id,value:e.division_name}));let i=e.entities.suppliers?e.entities.suppliers:e.dropdowns.suppliers;i=i?Object.values(i):[],i=i.map(e=>({key:e.supplier_id,value:e.supplier_name}));let a=e.dropdowns.decorators;return a=a?Object.values(a):[],a=a.map(e=>({key:e.decorator_id,value:e.decorator_name})),Array.isArray(a)&&a.push({value:(0,g.jsx)("a",{href:"#",onClick:e=>{var t;e.preventDefault(),null===(t=document.querySelector("#select_decorator .commonsku-styles-select__input"))||void 0===t||t.focus()},children:"Start typing for more decorators"}),key:"-",disabled:!0}),{original_decorators:e.dropdowns.decorators?Object.values(e.dropdowns.decorators):[],decorators:a,divisions:o,suppliers:i,decorations:e.entities.decorations,decorator_id:e.entities.decorator_id,loading:e.entities.decorations.loading}},(e,t)=>({loadDivisions:function(t){let o=arguments.length>1&&void 0!==arguments[1]&&arguments[1];e("collection"===t?(0,d.vl)(t):(0,d.gy)("commonsku"===t?"supplier-direct":t,o))},loadSuppliers:t=>e((0,d.vl)(t)),addSupplier:t=>e((0,d.w5)(t)),loadDecorators:t=>e((0,c.IO)(t)),loadDecorations:function(t){let o=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e((0,c.oz)(t,o))},loadDecorationCharges:t=>e((0,c.Uf)(t)),createDecoration:function(t){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e((0,c.Xq)(t,o))},addDecoration:(t,o,i,a,s)=>e((0,c.md)(t,o,i,a,s)),onCreateFetchSuppliers:(t,o,i,a)=>e((0,d.uy)(t,o,i,a)),onCreateAddSupplierPopup:t=>e((0,l.C9)(t)),addDecorator:(t,o)=>e((0,c.f3)({decorator_id:t,decorator_name:o})),deleteDecorator:t=>e((0,c.ZZ)(t)),setDecorator:(t,o)=>e((0,c.f3)({decorator_id:t,decorator_name:o})),onEditDone:e=>{},updateDecorator:(t,o)=>e((0,c.Bu)(t,o)),deleteAllDecorations:t=>e((0,c.nk)(t))}))(P)},88871(e,t,o){"use strict";o.d(t,{eP:()=>d,aG:()=>u,nm:()=>p});var i=o(41594),a=o(63988);i.Component;const s=e=>(0,a.jsx)("input",{type:"checkbox",...e});var r=o(82865),n=o(73049);const l=(e,t,o)=>(0,a.jsx)("label",{htmlFor:t||"-",style:{textAlign:"left"},...o,children:e});class d extends i.Component{constructor(e){super(e),this.state={hover:!1,removing:!1,cell_value:this.props.charge_data&&this.props.charge_data.cell_value||""},this._hoverOn=this.toggleHover(!0),this._hoverOff=this.toggleHover(!1)}onDelete(e){this.setState({removing:!0},()=>{setTimeout(()=>{this.props.onDelete(e)},300)})}toggleHover(e){return t=>{this.setState({hover:e})}}getHoverStyle(){let e={visibility:"hidden"};return this.state.hover&&(e={hoverStyles:"visible"}),e}renderParentItem(){const{charge_data:e,charge_type:t,can_edit:o,onChange:i,onUpdateRequest:s}=this.props;return(0,a.jsxs)("div",{"data-test-name":"ChargeListItem.renderParentItem",children:["fixed"==t?(0,a.jsxs)("div",{className:"columns large-2 medium-5 small-5",children:[l("Increment","increment-"+e.charge_id,{className:o||this.props.charge_data.qty?"":"error"}),(0,a.jsx)("input",{type:"number",min:"0",className:o||this.props.charge_data.qty?"":"error",placeholder:o||this.props.charge_data.qty?"":"Not filled 
1in",value:this.props.charge_data.qty,style:{textAlign:"left",...!1===o?{background:"white",border:0,boxShadow:"none"}:{}},disabled:!1===o,onChange:t=>{parseFloat(t.target.value),isNaN(t.target.value)&&""!=t.target.value||i({qty:t.target.value,charge_id:e.charge_id,type:"list-item",...this.props.is_child?{parent_id:e.parent_id}:{}})},onBlur:t=>{const o=parseFloat(t.target.value);(!isNaN(t.target.value)&&o>1e-4||""==t.target.value)&&s({qty:t.target.value,charge_id:e.charge_id,type:"list-item",...this.props.is_child?{parent_id:e.parent_id}:{}})},onFocus:e=>e.target.select()})]}):null,(0,a.jsxs)("div",{className:"columns large-2 medium-5 small-5",children:[l("Units","unit-"+e.charge_id,{className:o||this.props.charge_data.unit?"":"error"}),(0,a.jsx)(r.A,{placeholder:o||this.props.charge_data.unit?"(colors, stitches, ...)":"Not filled in",className:o||this.props.charge_data.unit?"":"error",style:{textAlign:"left",...!1===o?{background:"white",border:0,boxShadow:"none"}:{}},disabled:!1===o,value:this.props.charge_data.unit,onChange:t=>{i({unit:t.target.value,charge_id:e.charge_id,type:"list-item",...this.props.is_child?{parent_id:e.parent_id}:{}})},onBlur:t=>{s({unit:t.target.value,charge_id:e.charge_id,type:"list-item",...this.props.is_child?{parent_id:e.parent_id}:{}})},onFocus:e=>e.target.select()})]}),(0,a.jsx)("hr",{style:{maxWidth:"inherit"}})]})}render(){const{charge_data:e,parent_data:t,onChange:o,can_edit:i,charge_type:s}=this.props,{removing:l}=this.state;return this.props.is_parent?(0,a.jsx)("div",{"data-test-name":"ChargeListItem.render",style:{marginTop:5,transition:"all 250ms linear"},children:this.renderParentItem()}):(0,a.jsxs)("div",{"data-test-name":"ChargeListItem.render",style:{marginTop:5,transition:"all 250ms linear"},onMouseEnter:this._hoverOn,onMouseLeave:this._hoverOff,children:[i?(0,a.jsx)("div",{className:"columns medium-1 delete",style:{textAlign:"right",padding:0,margin:0,width:"2%",fontSize:"0.6em",marginTop:5},children:(0,a.jsx)("a",{style:{...this.getHoverStyle()},onClick:t=>{t.preventDefault(),this.onDelete(e)},children:"×"})}):null,(0,a.jsx)("div",{className:"columns large-3 medium-4 small-11",children:(0,a.jsx)(r.A,{style:{textAlign:"left",...!1===i?{background:"white",border:0,boxShadow:"none"}:{}},className:i||e.label?"":"error",disabled:!1===i,value:e.label,placeholder:i||e.label?"Add charge details":"Not filled in",onChange:t=>{t.preventDefault(),o({remote_update:!1,label:t.target.value,charge_id:e.charge_id,type:"list-item",...this.props.is_child?{parent_id:e.parent_id}:{}})},onBlur:t=>{t.preventDefault(),o({label:t.target.value,charge_id:e.charge_id,type:"list-item",...this.props.is_child?{parent_id:e.parent_id}:{}})},onFocus:e=>e.target.select()})}),(0,a.jsx)("div",{className:"columns large-2 medium-3 small-5",children:(0,a.jsxs)("div",{className:"input-group",style:{marginBottom:0},children:[(0,a.jsx)("span",{className:"input-group-label",style:{background:"white",border:0,borderWidth:0,fontSize:17,lineHeight:"normal",verticalAlign:"middle",paddingRight:5,paddingBottom:20,paddingLeft:0},children:"$"}),(0,a.jsx)("input",{className:this.state.cell_value?"":"error",type:"number",min:"0",placeholder:i||this.state.cell_value?"Price":"Not filled in",value:this.state.cell_value,disabled:!1===i,style:{textAlign:"left",borderRadius:3,marginTop:0,marginBottom:20,...!1===i?{background:"white",border:0,boxShadow:"none"}:{}},onChange:e=>{e.preventDefault(),this.setState({cell_value:e.target.value})},onBlur:t=>{t.preventDefault();const i=parseFloat(t.target.value);(!isNaN(t.target.value)&&i>1e-4||""==t.target.value)&&this.setState({cell_value:(0,n.h_)(t.target.value)},()=>{o({cell_value:this.state.cell_value,charge_id:e.charge_id,type:"list-item",...this.props.is_child?{parent_id:e.parent_id}:{}})})},onFocus:e=>e.target.select()})]})}),(0,a.jsx)("div",{className:"columns large-2 medium-4 small-5",style:{textAlign:"left",padding:0,margin:0,fontSize:17,marginTop:7},children:"run"==s?"Per Item":`per ${t.qty&&t.qty<=1?"":t.qty} ${t&&t.unit?t.unit:""}`}),(0,a.jsx)("hr",{style:{maxWidth:"inherit"}})]})}}var c=o(22078);const h=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e4;return Math.floor(Math.random()*Math.floor(e))}
1,p=e=>{let{data:t,cols:o,getChargeToAdd:i,isPresentation:s=!1,charge_data:r,...n}=e;const l=o.map(e=>(0,c.kf)(e.key)&&parseInt(e.key)),d=i({data:t,cols:o},null,!0),p=r&&r.decoration&&r.decoration.matrix?r.decoration.matrix.data:[];let u=!r.charge_to_add&&d?d.charge:r.charge_to_add;const m=!r.charge_to_add_col&&d&&d.colData?d.colData.idx:r.charge_to_add_col;let g=1;if(t&&t.length&&t[0].id&&p.length>0){const e=parseInt(t[0].id);e>1&&(g=p[e-2]?parseInt(p[e-2]["-"])+1:"")}function x(e){return"per_additional_unit"==e.price_by_type?"Each Additional "+e["-"]:g==e["-"]||""==g?e["-"]:g+("per_additional_unit"!=t[t.length-1].price_by_type?" - "+e["-"]:" +")}function _(e,o){return e[o]==u&&o==m&&"per_additional_unit"!=t[t.length-1].price_by_type?{background:"#65b6cc",color:"white",fontWeight:"bold"}:{}}return p&&p.length&&"per_additional_unit"==t[0].price_by_type&&(t=p.filter(e=>(0,c.kf)(e.id)&&parseInt(e.id)>=parseInt(t[0].id)-1)),(0,a.jsxs)("div",{"data-test-name":"PricingTable",className:"columns medium-12",children:[(0,a.jsxs)("table",{border:"0",className:"table",children:[(0,a.jsx)("thead",{style:{border:"none"},children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{style:{textAlign:"center"},children:r.d_unit}),o.map(e=>"-"==e.label?null:(0,a.jsxs)("th",{style:{textAlign:"center"},children:[e.label," ",e.until&&"0"!=e.until?"- "+e.until:"+"]},`col_${e.label}_${h()}`))]})}),(0,a.jsx)("tbody",{style:{border:"none",textAlign:"center"},children:t.map((e,o)=>(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{style:{textAlign:"center"},children:x(e)},`row_th_${e.id}_${e["-"]}_${h()}_${o}`),Object.keys(e).map((i,r)=>{if((0,c.kf)(i)&&l.includes(parseInt(i)))return(0,a.jsx)("td",{"data-test-name":"PricingTable",style:{textAlign:"center",..._(e,i)},onClick:o=>{"run"!=n.charge_type||s||""==t[0][i]||(u=e[i],"per_additional_unit"==t[t.length-1].price_by_type&&("per_additional_unit"!=e.price_by_type&&(u=t[t.length-1][i]),u=n.getPerAdditionalUnitCharge({charge:u,chargeKey:i})),n.updateChargesData({charge_to_add:u,charge_to_add_col:i}))},children:e[i]?"$"+e[i]:""},`row_td_${e.id}_${e["-"]}_${e[i]}_${h()}_${o}_${r}`)})]},`row_${e.id}_${h()}`))})]}),!1!==d&&u||s?u&&(0,a.jsxs)("p",{style:{textAlign:"center",fontWeight:"600"},children:["This charge will be applied: $",u]}):(0,a.jsx)("div",{className:"columns medium-12",style:{textAlign:"center"},children:(0,a.jsx)("p",{style:{color:"black",textAlign:"center"},children:"There is no charge matching the given quantity"})})]})};class u extends i.Component{constructor(e){super(e),this.state={calc_qty:0}}render(){const{charges:e,decoration_id:t,updateListCharges:o,updateChargesData:i,charge_type:s,charge_name:r,charge_data:n,isPresentation:l}=this.props;return(0,a.jsx)("div",{"data-test-name":"ListItemPricingTable.render",className:"columns medium-12",style:{marginBottom:30},children:e.map(e=>(0,a.jsx)(m,{"data-test-name":"ListItemPricingTable.render",charge:e,decoration_id:t,updateCharge:o,updateChargesData:i,charge_type:s,charge_name:r,charge_data:n},e.charge_id))})}}class m extends i.Component{constructor(e){super(e),this.state={charge_id:this.props.charge.charge_id,selected:!1},this.handleCheckboxChange=this.handleCheckboxChange.bind(this)}handleCheckboxChange(){this.setState(e=>({selected:!e.selected}),()=>{this.props.updateCharge(this.props.charge.charge_id,{checked:this.state.selected})})}renderPerQtyUnit(){const{charge:e,charge_data:{charge_type:t,d_unit:o,d_qty:i}}=this.props;if("run"==t)return`$${e.cell_value} Per Unit`;let a="";return e.cell_value&&(a+="$"+e.cell_value),"fixed"==t&&(a+=" per "+(1==i?"":i)+" "+o),a}render(){const{charge:e}=this.props;return(0,a.jsxs)("div",{"data-test-name":"ListItem.render",className:"columns medium-12",style:{fontWeight:"bold"},children:[(0,a.jsx)("div",{className:"columns medium-4",style:{textAlign:"left",marginTop:10},children:e.label?e.label:(0,a.jsx)("br",{})}),(0,a.jsx)("div",{className:"columns medium-3",style:{textAlign:"left",marginTop:10},children:this.renderPerQtyUnit()}),(0,a.jsx)("div",{className:"columns medium-2",style:{paddingLeft:"0.5rem",paddingRight:0},children:(0,a.jsx)(s,{checked:this.state.selected,onChange:this.handleCheckboxChange})})]})}}},96269(){},36297(e,t,o){e.exports=o(99735)(9127)}}]);
2//# sourceMappingURL=8974.4c39fc87.chunk.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.