PageSourceSearch

https://smartecom.ai/static/js/1045.6cdda6f9.chunk.js

js smartecom.ai collected 2026-10-05 15:05:58 UTC 354,025 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunklight_bootstrap_dashboard_react=self.webpackChunklight_bootstrap_dashboard_react||[]).push([[1045],{34018:function(e,t,r){var n=r(29439),a=r(88391),i=r(33412),o=r(71739),l=r(39437),s=r(69936),d=r(23712);t.Z=function(e){var t=e.show,r=e.onHide,c=e.title,u=void 0===c?"Ch\u1ecdn m\xe0u t\u1eeb th\u01b0 vi\u1ec7n":c,h=e.subtitle,p=e.colorTypes,g=void 0===p?[]:p,m=e.getTypeLabel,f=e.initialType,x=e.currentProductCode,_=e.confirmLabel,v=void 0===_?"L\u01b0u":_,y=e.saving,S=void 0!==y&&y,b=e.getProductsForType,C=e.isLoading,j=void 0!==C&&C,T=e.onTabActive,O=e.onConfirm,w=(0,a.useState)(f||g[0]||null),F=(0,n.Z)(w,2),N=F[0],E=F[1],L=(0,a.useState)(null),I=(0,n.Z)(L,2),Z=I[0],k=I[1],P=g.join("|");(0,a.useEffect)((function(){if(t){var e=f||g[0]||null;E(e),k(null),e&&T&&T(e)}}),[t,f,P]);var R=function(){S||r&&r()},A=N&&"function"===typeof b&&b(N)||[];return(0,d.jsxs)(i.Z,{show:t,onHide:R,centered:!0,size:"xl",backdrop:!S||"static",children:[(0,d.jsx)(i.Z.Header,{closeButton:!S,children:(0,d.jsxs)(i.Z.Title,{children:[u,h?(0,d.jsxs)("small",{style:{color:"#94a3b8",fontWeight:400},children:[" \u2014 ",h]}):null]})}),(0,d.jsxs)(i.Z.Body,{style:{maxHeight:"70vh",overflowY:"auto"},children:[(0,d.jsx)("ul",{className:"nav nav-tabs mb-3",children:g.map((function(e){return(0,d.jsx)("li",{className:"nav-item",children:(0,d.jsx)("button",{type:"button",className:"nav-link ".concat(N===e?"active":""),onClick:function(){return function(e){E(e),k(null),T&&T(e)}(e)},disabled:S,title:e,children:m?m(e):e})},e)}))}),j&&(0,d.jsx)("div",{style:{display:"flex",justifyContent:"center",padding:24},children:(0,d.jsx)(o.Z,{animation:"border",size:"sm"})}),!j&&N&&0===A.length&&(0,d.jsxs)("div",{className:"text-muted",style:{padding:12},children:["Kh\xf4ng c\xf3 s\u1ea3n ph\u1ea9m n\xe0o v\u1edbi product_type = ",N,"."]}),!j&&N&&A.length>0&&(0,d.jsx)("div",{className:"ses-color-library-grid",children:A.map((function(e){var t,r=String((null===(t=e.properties)||void 0===t?void 0:t.color)||"").trim(),n=/^#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{3})$/.test(r),a=n?r:"#eeeeee",i=x===e.product_code,o=(null===Z||void 0===Z?void 0:Z.product_code)===e.product_code,l=function(){S||k(e)};return(0,d.jsxs)("div",{role:"button",tabIndex:0,title:"".concat(e.sku_code," ").concat(e.size||"").concat(r?" \u2014 "+r:""),onClick:l,onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||S||(e.preventDefault(),l())},style:{display:"flex",flexDirection:"column",alignItems:"center",gap:6,padding:8,borderRadius:10,border:o?"2px solid #0d6efd":i?"2px dashed #0d6efd":"1px solid transparent",background:o?"#eef5ff":"transparent",cursor:S?"wait":"pointer",minWidth:0},children:[(0,d.jsx)("div",{style:{width:"100%",aspectRatio:"1 / 1",maxWidth:80,borderRadius:10,background:a,border:"1.5px solid #bbb",boxShadow:"0 1px 4px #0002"}}),(0,d.jsxs)("div",{style:{fontSize:12,textAlign:"center",wordBreak:"break-word",lineHeight:1.25},children:[(0,d.jsx)("div",{style:{fontWeight:600},children:(0,s.G)(e.sku_code)}),e.product_name&&(0,d.jsx)("div",{style:{color:"#475569",fontSize:11},title:e.product_name,children:e.product_name}),n&&(0,d.jsx)("div",{className:"text-muted",style:{fontFamily:"monospace",fontSize:11},children:r})]})]},e._id||e.product_code)}))})]}),(0,d.jsxs)(i.Z.Footer,{children:[S&&(0,d.jsx)(o.Z,{animation:"border",size:"sm",className:"me-2"}),(0,d.jsx)(l.Z,{variant:"secondary",onClick:R,disabled:S,children:"\u0110\xf3ng"}),(0,d.jsx)(l.Z,{variant:"primary",onClick:function(){return O&&O(Z)},disabled:!Z||S,children:S?"\u0110ang l\u01b0u...":v})]}),(0,d.jsx)("style",{children:"\n        .ses-color-library-grid {\n          display: grid;\n          grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));\n          gap: 12px;\n        }\n        @media (max-width: 768px) {\n          .ses-color-library-grid {\n            grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));\n            gap: 8px;\n          }\n        }\n      "})]})}},78157:function(e,t,r){r.d(t,{i:function(){return u}});var n=r(45987),a=r(1413),i=(r(88391),r(85472)),o=r(24576),l=r(23712),s=["node"],d=["node"],c=/\b(IMG|VIDEO)\s*#\s*(\d+)\b/gi,u=function(e,t){if(!t)return e;var r=Array.isArray(t.images)?t.images:[],n=Array.isArray(t.videos)?t.videos:[];return e.replace(c,(function(e,t,a){var i=parseInt(a,10);if(!Number.isFinite(i)||i<1)return e;var o=String(t).toUpperCase();if("IMG"===o){var l=r[i-1];return l?"![](".concat(l,")"):"**[".concat(e," \u2014 kh\xf4ng c\xf3]**")}if("VIDEO"===o){var s=n[i-1];return s?"[\ud83d\udcf9 Video](".concat(s,")"):"**[".concat(e," \u2014 kh\xf4ng c\xf3]**")}return e}))};t.Z=function(e){var t=e.value,r=e.markdown,c=void 0!==r&&r,h=e.placeholder,p=void 0===h?"-":h,g=(e.maxImageHeight,e.imgMaxWidth),m=void 0===g?"60%":g,f=e.imgMaxHeight,x=e.videoMaxWidth,_=void 0===x?"60%":x,v=e.videoMaxHeight,y=e.shortcodeAssets,S=void 0===y?null:y,b=e.className,C=e.style,j=null==t?"":String(t),T=S?u(j,S):j;if(!T.trim())return(0,l.jsx)("span",{className:b,style:C,children:p});if(c){var O=/\.(mp4|webm|ogg|mov|m4v|3gp|mkv|avi|wmv|flv)(\?|#|$)/i,w=function(e){return"string"===typeof e&&O.test(e)},F=function(e){return(0,l.jsx)("video",{src:e,controls:!0,preload:"metadata",style:(0,a.Z)((0,a.Z)({display:"block",margin:"8px auto",maxWidth:_},v?{maxHeight:v}:{}),{},{borderRadius:6,background:"#000"})})},N={img:function(e){e.node;var t=(0,n.Z)(e,s);return w(t.src)?F(t.src):(0,l.jsx)("img",(0,a.Z)((0,a.Z)({alt:t.alt||""},t),{},{loading:"lazy",onClick:function(e){t.src&&(e.preventDefault(),window.open(t.src,"_blank","noopener,noreferrer"))},style:(0,a.Z)((0,a.Z)({display:"block",margin:"8px auto",maxWidth:m,height:"auto"},f?{maxHeight:f}:{}),{},{borderRadius:6,cursor:"zoom-in"})}))},a:function(e){e.node;var t=(0,n.Z)(e,d);return w(t.href)?F(t.href):(0,l.jsx)("a",(0,a.Z)((0,a.Z)({},t),{},{target:"_blank",rel:"noopener noreferrer",children:t.children}))}};return(0,l.jsx)("div",{className:"note-markdown ".concat(b||""),style:(0,a.Z)({wordBreak:"break-word"},C),children:(0,l.jsx)(i.UG,{remarkPlugins:[o.Z],components:N,children:T})})}return(0,l.jsx)("span",{className:b,style:(0,a.Z)({whiteSpace:"pre-wrap",wordBreak:"break-word"},C),children:T})}},69936:function(e,t,r){r.d(t,{G:function(){return a},n:function(){return n}});var n=function(e){if(null==e||""===e)return e;var t=String(e).trim();if(!t)return e;var r=t.indexOf("_");if(r<=0)return t;var n=t.slice(0,r).trim();return/^\d{6}$/.test(n)&&t.slice(r+1).trim()||t},a=function(e){return n(e)}},96593:function(e,t,r){r.d(t,{Gc:function(){return Y},Gk:function(){return M},I0:function(){return F},LF:function(){return x},Pz:function(){return B},Ru:function(){return g},S9:function(){return S},Su:function(){return O},TT:function(){return L},XN:function(){return v},Xh:function(){return E},Xv:function(){return _},Z7:function(){return I},_o:function(){return G},aG:function(){return T},bl:function(){return y},cW:function(){return m},dJ:function(){return j},h4:function(){return b},jU:function(){return f},lq:function(){return p},lt:function(){return H},o1:function(){return h},oI:function(){return P},tA:function(){return c},x6:function(){return Z},yG:function(){return C},zV:function(){return A},zj:function(){return U}});var n=r(93433),a=r(4942),i=r(37762),o=r(37920),l=r.n(o),s=r(3875),d=r(36685);function c(){return l()().startOf("day").year()-1}function u(){return l()().startOf("day").year()-1}function h(){return l()().startOf("day").year()-2}function p(){var e=c();return{from:"".concat(e,"-01-01"),to:"".concat(e,"-12-31")}}function g(){var e=u(),t=e+1;return{from:"".concat(e,"-10-01"),to:"".concat(t,"-01-31")}}function m(e){return{from:"".concat(e,"-01-01"),to:"".concat(e,"-12-31")}}function f(e){var t=e+1;return{from:"".concat(e,"-10-01"),to:"".concat(t,"-01-31")}}function x(){return"N\u0103m ".concat(c())}function _(){return"Sale ".concat(u())}function v(e){return e}var y=["sale","rnd","fulfill"],S=["pageTitle","stt","orderDate","monthlyId","orderId","shop","customer","status","priority","startFulfill","finishFulfill","supervisorUser","executorUser","isUs","sku","inventory","image","t
1itle","size","quantity","orderQtyFailed","custom","productCustomField1","productCustomField2","orderCustomFilter1","orderCustomFilter2","estimateGrossWeight","realGrossWeight","buyerNote","sellerNote","fulfillNote","estDelivery","shippingAddress","email","ioss","available","shippingCenterDate","shippingCenterName","shippingLabelBoughtDate","shippingLabelCode","action"],b=S.filter((function(e){return"pageTitle"!==e})),C="column_order",j=["today","yesterday","this_week","last_week","month_0","month_1","month_2","year_0","year_quarter_1","year_quarter_2","year_quarter_3","year_quarter_4","last_year","last_sale","last_3_days","last_7_days","last_14_days","last_30_days","last_60_days","last_90_days","custom","all"],T=["date","shop","status","priority","shippingCenterName","orderCustomFilter1","orderCustomFilter2"];function O(){var e={};return j.forEach((function(t){e[t]=!1})),e}function w(e,t,r){var n=null===r||void 0===r?void 0:r[e];if(!n||"object"!==typeof n)return null;var a=n.dateFilterHidden;return a&&"object"===typeof a&&!0===a[t]||null}function F(e,t,r){return!(!r||"object"!==typeof r)&&("fulfill"===e||"rnd"===e?!0===w(e,t,r)||!0===w("sale",t,r):!0===w(e,t,r))}function N(e,t,r){var n=null===r||void 0===r?void 0:r[e];if(!n||"object"!==typeof n)return null;var a=n.hiddenFilters;return a&&"object"===typeof a&&!0===a[t]||null}function E(e,t,r){return!(!r||"object"!==typeof r)&&("fulfill"===e||"rnd"===e?!0===N(e,t,r)||!0===N("sale",t,r):!0===N(e,t,r))}function L(e){return{date:"Date",shop:"Shop",status:"Status",priority:"Priority",shippingCenterName:"Shipping Center Name",orderCustomFilter1:"Order Custom Filter 1",orderCustomFilter2:"Order Custom Filter 2"}[e]||e}function I(){var e={};return T.forEach((function(t){e[t]=!1})),e}function Z(e){switch(e){case"pageTitle":return(0,s.R6)(s.Nx.TEXT_ORDER_LIST);case"stt":return"STT";case"orderDate":return(0,s.R6)(s.Nx.TEXT_ORDER_DATE);case"monthlyId":return(0,s.R6)(s.Nx.TEXT_MONTHLY_ID);case"orderId":return(0,s.R6)(s.Nx.TEXT_ORDER_ID);case"shop":return(0,s.R6)(s.Nx.TEXT_SHOP);case"customer":return(0,s.R6)(s.Nx.TEXT_CUSTOMER);case"status":return(0,s.R6)(s.Nx.TEXT_STATUS);case"priority":return(0,s.R6)(s.Nx.TEXT_PRIORITY);case"supervisorUser":return"Supervisor (Team Sale)";case"executorUser":return"Executor (Team Fulfill)";case"isUs":return"\u0110\u01a1n h\xe0ng M\u1ef9";case"sku":return(0,s.R6)(s.Nx.TEXT_SKU_CODE);case"inventory":return"T\u1ed3n kho";case"image":return(0,s.R6)(s.Nx.TEXT_IMAGE);case"title":return(0,s.R6)(s.Nx.TEXT_PRODUCT_NAME);case"size":return(0,s.R6)(s.Nx.TEXT_SIZE);case"quantity":return(0,s.R6)(s.Nx.TEXT_QUANTITY)||"S\u1ed1 l\u01b0\u1ee3ng";case"orderQtyFailed":return"S\u1ed1 l\u01b0\u1ee3ng l\u1ed7i";case"custom":return"Custom";case"productCustomField1":return"Product Custom Field 1";case"productCustomField2":return"Product Custom Field 2";case"orderCustomFilter1":return"Order Custom Filter 1";case"orderCustomFilter2":return"Order Custom Filter 2";case"estimateGrossWeight":return(0,s.R6)(s.Nx.TEXT_ESTIMATE_GROSS_WEIGHT);case"realGrossWeight":return(0,s.R6)(s.Nx.TEXT_REAL_GROSS_WEIGHT);case"buyerNote":return(0,s.R6)(s.Nx.TEXT_BUYER_NOTE);case"sellerNote":return(0,s.R6)(s.Nx.TEXT_STAFF_NOTE);case"fulfillNote":return"Fulfill Note";case"startFulfill":return"B\u1eaft \u0111\u1ea7u Fulfill";case"finishFulfill":return"Ho\xe0n th\xe0nh Fulfill";case"estDelivery":return(0,s.R6)(s.Nx.TEXT_EST_DELIVERY);case"shippingAddress":return(0,s.R6)(s.Nx.TEXT_SHIPPING_ADDRESS);case"email":return(0,s.R6)(s.Nx.TEXT_EMAIL);case"ioss":return(0,s.R6)(s.Nx.TEXT_IOSS);case"available":return(0,s.R6)(s.Nx.TEXT_AVAILABLE);case"shippingCenterDate":return(0,s.R6)(s.Nx.TEXT_SHIPPING_CENTER_DATE);case"shippingCenterName":return"T\xean \u0110VVC";case"shippingLabelBoughtDate":return"Ng\xe0y mua m\xe3 tracking";case"shippingLabelCode":return"M\xe3 tracking";case"action":return(0,s.R6)(s.Nx.TEXT_ACTIONS);default:return e}}function k(e){return String(null!==e&&void 0!==e?e:"").split(/\r?\n/).map((function(e){return e.trim()})).filter(Boolean).map((function(e){return function(e){var t=String(null!==e&&void 0!==e?e:"").trim();if(!t)return{value:"",label:""};var r=t.indexOf(":");if(-1===r)return{value:"",label:""};var n=t.slice(0,r).trim();return{value:n,label:t.slice(r+1).trim()||n}}(e)})).filter((function(e){return e.value}))}function P(e){var t,r=new Set,n=[],a=(0,d.Dm)(e)[d.L7],o=(0,i.Z)(k(a));try{for(o.s();!(t=o.n()).done;){var l=t.value,s=l.value,c=l.label;r.has(s)||(r.add(s),n.push({value:s,label:c||s,key:d.L7}))}}catch(u){o.e(u)}finally{o.f()}return n}function R(e,t){if(!e||"object"!==typeof e)return null;if("pageTitle"===t){var r=e.pageTitle;return null!=r&&""!==String(r).trim()?String(r).trim():null}var n=e.headers;if(!n||"object"!==typeof n)return null;var a=n[t];return null!=a&&""!==String(a).trim()?String(a).trim():null}function A(e,t,r,n){if(!n||"object"!==typeof n)return r;for(var a=0,i="fulfill"===e||"rnd"===e?[e,"sale"]:[e];a<i.length;a++){var o=R(n[i[a]],t);
1if(null!=o)return o}return r}function D(e,t,r){var n=r[e];if(!n||"object"!==typeof n)return null;var a=n.hidden;return a&&"object"===typeof a?!0===a[t]||!1!==a[t]&&null:null}function M(e,t,r){if(!r||"object"!==typeof r)return!1;if("fulfill"===e||"rnd"===e){var n=D(e,t,r);if(!0===n)return!0;if(!1===n)return!1;var a=D("sale",t,r);return!0===a}return!0===D(e,t,r)}var H="show_filter_fulfill";function z(e,t){var r=null===t||void 0===t?void 0:t[e];if(!r||"object"!==typeof r)return null;var n=r[H];return!0===n||!1!==n&&null}function G(e,t){var r,n;if(!e||!["sale","rnd","fulfill"].includes(t))return!1;var a=null===(r=e.metadata)||void 0===r||null===(n=r.configs)||void 0===n?void 0:n.orderList;if(a&&"object"===typeof a){var i=z(t,a);if(!0===i)return!0;if(!1===i)return!1;if("rnd"===t||"fulfill"===t){var o=z("sale",a);if(!0===o)return!0;if(!1===o)return!1}}return!0===(0,d.Dm)(e)[H]}function U(){var e={},t={},r=I();return b.forEach((function(t){e[t]=""})),S.forEach((function(e){t[e]=!1})),(0,a.Z)({pageTitle:"",headers:e,hidden:t,hiddenFilters:r,show_filter_fulfill:!1},C,[])}function B(e){if(!Array.isArray(e))return[];var t=new Set,r=[];return e.forEach((function(e){var n=String(e||"").trim();b.includes(n)&&(t.has(n)||(t.add(n),r.push(n)))})),r}function Y(e,t){var r=[];if(t&&"object"===typeof t){var a=t[e];a&&"object"===typeof a&&(r=B(a[C]))}var i=b.filter((function(e){return!r.includes(e)}));return[].concat((0,n.Z)(r),(0,n.Z)(i))}},74961:function(e,t,r){r.d(t,{QS:function(){return l},dO:function(){return o},vl:function(){return i}});var n,a=r(4942),i={CANCELLED:"cancelled",WAITING_FOR_PAYMENT:"waiting_for_payment",WAIT_FOR_PROCESSING:"wait_for_processing",PROCESSING:"processing",PROCESSING_CUSTOM_ORDER:"processing_custom_order",SALE_5:"sale_5",SALE_6:"sale_6",SALE_7:"sale_7",SALE_8:"sale_8",SALE_9:"sale_9",FULFILL_PROCESSING:"fulfill_processing",PACKAGING:"packaging",PACKAGING_DONE:"packaging_done",WAITING_FOR_SHIPPING_LABEL:"waiting_for_shipping_label",SHIPPED_TO_SHIPPING_CENTER:"shipped_to_shipping_center",SHIPPED_TO_CUSTOMER:"shipped_to_customer",CUSTOMS_HOLD:"customs_hold",RETURNED_TO_SHIPPING_WAREHOUSE:"returned_to_shipping_warehouse",RETURNED_TO_SHIPPING_CENTER:"returned_to_shipping_center",RETURNED_TO_WAREHOUSE:"returned_to_warehouse",FAIL_REASON_1:"fail_reason_1",FAIL_REASON_2:"fail_reason_2",FAIL_REASON_3:"fail_reason_3",COMPLETED:"completed",REFUNDED:"refunded"},o=(n={},(0,a.Z)(n,i.CANCELLED,{code:0,enum:i.CANCELLED,display_text_vi:"\u0110\xe3 h\u1ee7y",display_text_en:"Cancelled"}),(0,a.Z)(n,i.WAITING_FOR_PAYMENT,{code:1,enum:i.WAITING_FOR_PAYMENT,display_text_vi:"Ch\u1edd thanh to\xe1n",display_text_en:"Waiting for payment"}),(0,a.Z)(n,i.WAIT_FOR_PROCESSING,{code:2,enum:i.WAIT_FOR_PROCESSING,display_text_vi:"Ch\u1edd x\u1eed l\xfd",display_text_en:"Wait for processing"}),(0,a.Z)(n,i.PROCESSING,{code:3,enum:i.PROCESSING,display_text_vi:"\u0110ang x\u1eed l\xfd",display_text_en:"Processing"}),(0,a.Z)(n,i.PROCESSING_CUSTOM_ORDER,{code:4,enum:i.PROCESSING_CUSTOM_ORDER,display_text_vi:"X\u1eed l\xfd \u0111\u01a1n custom",display_text_en:"Processing custom order"}),(0,a.Z)(n,i.SALE_5,{code:5,enum:i.SALE_5,display_text_vi:"Sale 5",display_text_en:"Sale 5",defaultHidden:!0}),(0,a.Z)(n,i.SALE_6,{code:6,enum:i.SALE_6,display_text_vi:"Sale 6",display_text_en:"Sale 6",defaultHidden:!0}),(0,a.Z)(n,i.SALE_7,{code:7,enum:i.SALE_7,display_text_vi:"Sale 7",display_text_en:"Sale 7",defaultHidden:!0}),(0,a.Z)(n,i.SALE_8,{code:8,enum:i.SALE_8,display_text_vi:"Sale 8",display_text_en:"Sale 8",defaultHidden:!0}),(0,a.Z)(n,i.SALE_9,{code:9,enum:i.SALE_9,display_text_vi:"Sale 9",display_text_en:"Sale 9",defaultHidden:!0}),(0,a.Z)(n,i.FULFILL_PROCESSING,{code:10,enum:i.FULFILL_PROCESSING,display_text_vi:"Fulfill x\u1eed l\xfd",display_text_en:"Fulfill processing"}),(0,a.Z)(n,i.PACKAGING,{code:11,enum:i.PACKAGING,display_text_vi:"\u0110\xf3ng g\xf3i",display_text_en:"Packaging"}),(0,a.Z)(n,i.PACKAGING_DONE,{code:12,enum:i.PACKAGING_DONE,display_text_vi:"\u0110\xe3 \u0111\xf3ng g\xf3i",display_text_en:"Packaging done"}),(0,a.Z)(n,i.WAITING_FOR_SHIPPING_LABEL,{code:13,enum:i.WAITING_FOR_SHIPPING_LABEL,display_text_vi:"Ch\u1edd d\xe1n nh\xe3n VC",display_text_en:"Waiting for shipping label"}),(0,a.Z)(n,i.SHIPPED_TO_SHIPPING_CENTER,{code:15,enum:i.SHIPPED_TO_SHIPPING_CENTER,display_text_vi:"\u0110\xe3 g\u1eedi \u0111\u1ebfn \u0110VVC",display_text_en:"Shipped to shipping center"}),(0,a.Z)(n,i.SHIPPED_TO_CUSTOMER,{code:20,enum:i.SHIPPED_TO_CUSTOMER,display_text_vi:"\u0110\xe3 g\u1eedi \u0111\u1ebfn KH",display_text_en:"Shipped to customer"}
1),(0,a.Z)(n,i.CUSTOMS_HOLD,{code:21,enum:i.CUSTOMS_HOLD,display_text_vi:"T\u1ea1m gi\u1eef h\u1ea3i quan",display_text_en:"Customs hold"}),(0,a.Z)(n,i.RETURNED_TO_SHIPPING_WAREHOUSE,{code:22,enum:i.RETURNED_TO_SHIPPING_WAREHOUSE,display_text_vi:"Tr\u1ea3 v\u1ec1 kho \u0110VVC",display_text_en:"Returned to shipping warehouse"}),(0,a.Z)(n,i.RETURNED_TO_SHIPPING_CENTER,{code:23,enum:i.RETURNED_TO_SHIPPING_CENTER,display_text_vi:"Tr\u1ea3 v\u1ec1 \u0110VVC",display_text_en:"Returned to shipping center"}),(0,a.Z)(n,i.RETURNED_TO_WAREHOUSE,{code:24,enum:i.RETURNED_TO_WAREHOUSE,display_text_vi:"Tr\u1ea3 v\u1ec1 kho",display_text_en:"Returned to warehouse"}),(0,a.Z)(n,i.FAIL_REASON_1,{code:25,enum:i.FAIL_REASON_1,display_text_vi:"L\u1ed7i 1",display_text_en:"Fail reason 1"}),(0,a.Z)(n,i.FAIL_REASON_2,{code:26,enum:i.FAIL_REASON_2,display_text_vi:"L\u1ed7i 2",display_text_en:"Fail reason 2"}),(0,a.Z)(n,i.FAIL_REASON_3,{code:27,enum:i.FAIL_REASON_3,display_text_vi:"L\u1ed7i 3",display_text_en:"Fail reason 3"}),(0,a.Z)(n,i.COMPLETED,{code:30,enum:i.COMPLETED,display_text_vi:"Ho\xe0n th\xe0nh",display_text_en:"Completed"}),(0,a.Z)(n,i.REFUNDED,{code:31,enum:i.REFUNDED,display_text_vi:"\u0110\xe3 ho\xe0n ti\u1ec1n",display_text_en:"Refunded"}),n),l={getStatusByEnum:function(e){return o[e]||null},getStatusByCode:function(e){return Object.values(o).find((function(t){return t.code===e}))||null},getAllStatuses:function(){return Object.values(o)},getEnumByCode:function(e){var t=Object.values(o).find((function(t){return t.code===e}));return t?t.enum:null},getCodeByEnum:function(e){var t=o[e];return t?t.code:null},getDisplayText:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en",r=o[e];return r?"vi"===t?r.display_text_vi:r.display_text_en:null},isValidStatus:function(e){return o.hasOwnProperty(e)}}},9226:function(e,t,r){r.d(t,{SB:function(){return a},Sk:function(){return l},W$:function(){return o},Xg:function(){return s},iH:function(){return i}
1,pe:function(){return d}});var n=r(74961),a=Object.freeze(Object.values(n.vl));function i(e){var t=n.dO[e];return t?t.display_text_vi:String(e)}function o(e,t,r){if(!r||"object"!==typeof r)return t;var n=r.labels;if(!n||"object"!==typeof n)return t;var a=n[e];return null!=a&&""!==String(a).trim()?String(a).trim():t}function l(e){var t;return!(null===(t=n.dO[e])||void 0===t||!t.defaultHidden)}function s(e,t){var r=null===t||void 0===t?void 0:t.hidden;return r&&"object"===typeof r&&e in r?!0===r[e]:l(e)}function d(){var e={},t={};return a.forEach((function(r){e[r]="",t[r]=l(r)})),{labels:e,hidden:t}}},71045:function(e,t,r){r.r(t),r.d(t,{default:function(){return _t}});var n=r(37762),a=r(45987),i=r(93433),o=r(61819),l=r(15861),s=r(29439),d=r(4942),c=r(15671),u=r(43144),h=r(97326),p=r(60136),g=r(29388),m=r(1413),f=r(88391),x=r(23774),_=r(58171),v=r(21867),y=r(59633),S=r(92930),b=r(66023),C=r(15545),j=r(7734),T=r(71097),O=r(71739),w=r(13559),F=r(5597),N=r(39437),E=r(85115),L=r(56097),I=(r(66574),function(){return function(){var e=(0,l.Z)((0,o.Z)().mark((function e(t){var r,n;return(0,o.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,L.OV.getAllTasks();case 3:r=e.sent,n=r.data.data,t(n?{type:E.v.ACTION_GET_ALL_TASKS_SUCCESS,payload:{data:n}}:{type:E.v.ACTION_GET_ALL_TASKS_FAIL,payload:{}}),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(0),t({type:E.v.ACTION_CALL_API_FAIL,payload:{message:e.t0}});case 11:case"end":return e.stop()}}),e,null,[[0,8]])})));return function(t){return e.apply(this,arguments)}}()}),Z=r(33412),k=r(30127),P=r(3379),R=function(e){return function(){var t=(0,l.Z)((0,o.Z)().mark((function t(r){return(0,o.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:P.Z.emit("call_agent_service",e);case 1:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},A=r(23712),D={GiftSymphony:"42604617",ResinEpic:"40890130",ANNA:"52811688"},M=function(e){var t=e.split("-")[0],r=Object.entries(D).find((function(e){var r=(0,s.Z)(e,2);r[0];return r[1]===t}));return r?r[0]:t},H=function(e){(0,p.Z)(r,e);var t=(0,g.Z)(r);function r(){var e;(0,c.Z)(this,r);for(var n=arguments.length,a=new Array(n),i=0;i<n;i++)a[i]=arguments[i];return(e=t.call.apply(t,[this].concat(a))).state={agents:[],loading:!1,dateFilter:"today",agentStatuses:{},deepScan:!1},e.loadAgents=function(){e.setState({loading:!0}),e.props.getAgents({agent_type:"auto_ecom_orders"}).finally((function(){e.setState({loading:!1})}))},e.loadTasks=function(){e.props.getAllTasks()},e.handleDateFilterChange=function(t){e.setState({dateFilter:t.target.value},e.loadAgents)},e.handleAgentToggle=function(t){var r=!e.state.agentStatuses[t.agent_id];e.setState((function(e){return{agentStatuses:(0,m.Z)((0,m.Z)({},e.agentStatuses),{},(0,d.Z)({},t.agent_id,r))}}),(function(){e.props.updateAgent({agent_id:t.agent_id,status:r?"active":"inactive"})}))},e.handleScanNow=function(t){e.props.callAgentService({agent_id:t.agent_id,agent_type:"main",action_data:{date_filter:e.state.dateFilter,deep_scan:e.state.deepScan},action:"scan_orders"})},e.handleRefreshShop=function(t){e.props.callAgentService({agent_id:t.agent_id,agent_type:"main",action:"refresh_webpage"})},e.handleSendWarning=function(t){var r="Tab qu\xe9t \u0111\u01a1n \u0111ang b\u1ecb \u0111\xf3ng. Vui l\xf2ng b\u1eadt l\u1ea1i. Xin c\u1ea3m \u01a1n !";r&&e.props.callAgentService({agent_id:t.agent_id,agent_type:"sub",action:"show_popup",action_data:{message:r}})},e.handleExportCSV=(0,l.Z)((0,o.Z)().mark((function t(){var r,n;return(0,o.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("all"!==(r=e.state.dateFilter)){t.next=4;break}return alert("Please select a specific date range for export"),t.abrupt("return");case 4:if(n={today:"today",yesterday:"yesterday","2days":"2days","3days":"3days","4days":"4days"}[r]){t.next=8;break}return t.abrupt("return");case 8:return t.prev=8,t.next=11,fetch("https://smartecom.ai:2053/api/order/export-csv?online=1&date=".concat(n));case 11:if(t.sent.ok){t.next=14;break}throw new Error("Export failed");case 14:alert("Export completed successfully"),t.next=21;break;case 17:t.prev=17,t.t0=t.catch(8),console.error("Export failed:",t.t0),alert("Failed to export CSV");case 21:case"end":return t.stop()}}),t,null,[[8,17]])}))),e}
1return(0,u.Z)(r,[{key:"componentDidMount",value:function(){this.loadAgents(),this.loadTasks(),this.agentsInterval=setInterval(this.loadAgents,12e4),this.tasksInterval=setInterval(this.loadTasks,12e4)}},{key:"componentWillUnmount",value:function(){clearInterval(this.agentsInterval),clearInterval(this.tasksInterval)}},{key:"renderLastPing",value:function(e){if(!e)return(0,A.jsx)(v.Z,{bg:"secondary",children:"No data"});var t=new Date(e),r=Math.round((Date.now()-t.getTime())/6e4)>5?"danger":"success";return(0,A.jsx)(v.Z,{bg:r,children:(0,k.iE)(t)})}},{key:"componentWillReceiveProps",value:function(e){if(e.agents){var t={};e.agents.forEach((function(e){t[e.agent_id]="active"===e.status})),this.setState({agents:e.agents,agentStatuses:t})}}},{key:"renderTaskStatus",value:function(e){switch(e){case 0:return(0,A.jsx)(v.Z,{bg:"secondary",children:"Pending"});case 1:return(0,A.jsx)(v.Z,{bg:"primary",children:"Running"});case 2:return(0,A.jsx)(v.Z,{bg:"success",children:"Completed"});case 3:return(0,A.jsx)(v.Z,{bg:"danger",children:"Failed"});default:return(0,A.jsx)(v.Z,{bg:"secondary",children:"Unknown"})}}},{key:"render",value:function(){var e=this,t=this.state,r=t.agents,n=t.loading,a=t.dateFilter,i=t.agentStatuses,o=t.deepScan,l=this.props,s=l.show,d=l.onHide,c=l.tasks,u=c?c.filter((function(e){return"scan_orders"===e.task_name})):[];return(0,A.jsxs)(Z.Z,{show:s,onHide:d,size:"xl",keyboard:!1,children:[(0,A.jsx)(Z.Z.Header,{closeButton:!0,children:(0,A.jsx)(Z.Z.Title,{children:"Scan Orders"})}),(0,A.jsx)(Z.Z.Body,{children:(0,A.jsxs)(b.Z,{fluid:!0,children:[(0,A.jsxs)(j.Z,{className:"mb-3",children:[(0,A.jsx)(y.Z,{md:3,children:(0,A.jsxs)(S.Z,{value:a,onChange:this.handleDateFilterChange,className:"mb-2",children:[(0,A.jsx)("option",{value:"today",children:"H\xf4m nay"}),(0,A.jsx)("option",{value:"yesterday",children:"H\xf4m qua"}),(0,A.jsx)("option",{value:"2days",children:"2 ng\xe0y tr\u01b0\u1edbc"}),(0,A.jsx)("option",{value:"3days",children:"3 ng\xe0y tr\u01b0\u1edbc"}),(0,A.jsx)("option",{value:"4days",children:"4 ng\xe0y tr\u01b0\u1edbc"}),(0,A.jsx)("option",{value:"all",children:"T\u1ea5t c\u1ea3"})]})}),(0,A.jsx)(y.Z,{md:3,children:(0,A.jsx)(F.Z,{type:"checkbox",id:"deep-scan-checkbox",label:"Deep Scan",checked:o,onChange:function(t){return e.setState({deepScan:t.target.checked})},className:"mb-2"})}),(0,A.jsx)(y.Z,{md:3,children:(0,A.jsx)(N.Z,{variant:"success",onClick:this.handleExportCSV,disabled:"all"===a,children:"Export CSV"})})]}),n&&(0,A.jsxs)("div",{className:"text-center mb-3",children:[(0,A.jsx)(O.Z,{animation:"border",variant:"primary"}),(0,A.jsx)("span",{className:"ms-2",children:"\u0110ang c\u1eadp nh\u1eadt Agents..."})]}),(0,A.jsx)("h3",{className:"mb-3",children:"Agents"}),(0,A.jsxs)(w.Z,{striped:!0,bordered:!0,hover:!0,className:"mb-4",children:[(0,A.jsx)("thead",{children:(0,A.jsxs)("tr",{children:[(0,A.jsx)("th",{children:"Agent"}),(0,A.jsx)("th",{children:"ID"}),(0,A.jsx)("th",{children:"Last Ping"}),(0,A.jsx)("th",{children:"Status"}),(0,A.jsx)("th",{children:"Action"})]})}),(0,A.jsx)("tbody",{children:r.map((function(t){return(0,A.jsxs)("tr",{children:[(0,A.jsx)("td",{children:(0,k.d1)(t.shop_id)}),(0,A.jsx)("td",{children:t.shop_id}),(0,A.jsx)("td",{children:e.renderLastPing(t.ping_time)}),(0,A.jsx)("td",{children:(0,A.jsx)(F.Z,{className:"pb-3 cursor-pointer",title:i[t.agent_id]?"T\u1eaft":"B\u1eadt",type:"switch",id:"agent-toggle-".concat(t.agent_id),checked:i[t.agent_id]||!1,onChange:function(){return e.handleAgentToggle(t)}})}),(0,A.jsxs)("td",{children:[(0,A.jsx)(N.Z,{className:"btn-sm pull-left me-2",type:"button",variant:"primary",onClick:function(){return e.handleScanNow(t)},disabled:!i[t.agent_id],children:"Scan Now"}),(0,A.jsx)(N.Z,{className:"btn-sm pull-left",type:"button",variant:"info",onClick:function(){return e.handleRefreshShop(t)},disabled:!i[t.agent_id],children:"Refresh Shop"}),(0,A.jsx)(N.Z,{className:"btn-sm pull-left ms-2",type:"button",variant:"warning",onClick:function(){return e.handleSendWarning(t)},disabled:!i[t.agent_id],children:"Send Warning"})]})]},t.agent_id)}))})]}),(0,A.jsx)("h3",{className:"mb-3",children:"Scan Orders Tasks"}),(0,A.jsxs)(w.Z,{striped:!0,bordered:!0,hover:!0,className:"mb-4",children:[(0,A.jsx)("thead",{children:(0,A.jsxs)("tr",{children:[(0,A.jsx)("th",{children:"Task ID"}),(0,A.jsx)("th",{children:"Shop Name"}),(0,A.jsx)("th",{children:"Agent ID"}),(0,A.jsx)("th",{children:"Date Filter"}),(0,A.jsx)("th",{children:"Start Time"}),(0,A.jsx)("th",{children:"Status"})]})}),(0,A.jsxs)("tbody",{children:[u.map((function(t){return(0,A.jsxs)("tr",{children:[(0,A.jsx)("td",{children:t._id}),(0,A.jsx)("td",{children:M(t.agent_id)}),(0,A.jsx)("td",{children:t.agent_id}),(0,A.jsx)("td",{children:JSON.parse(t.task_content).date_filter}
1),(0,A.jsx)("td",{children:new Date(t.start_time).toLocaleString()}),(0,A.jsx)("td",{children:e.renderTaskStatus(t.status)})]},t._id)})),0===u.length&&(0,A.jsx)("tr",{children:(0,A.jsx)("td",{colSpan:"6",className:"text-center",children:"No scan orders tasks found"})})]})]})]})}),(0,A.jsx)(Z.Z.Footer,{children:(0,A.jsx)(N.Z,{variant:"secondary",onClick:d,children:"Close"})})]})}}]),r}(f.Component),z=(0,x.$j)((function(e){return{agents:e.agentReducer.agents,tasks:e.taskReducer.tasks}}),{getAgents:_.j8,updateAgent:_.sE,callAgentService:R,getAllTasks:I})(H),G=r(3875),U=r(1885),B=r(15841),Y=r(74961),X=r(37920),V=r.n(X),W=r(86960),q=r(93847),K=(r(72632),r(89958)),Q=r(70438),$=r(5226),J=r(62590),ee=r(83969),te=function(e){var t=e.useProductTypeFilter,r=e.productTypeFilterValue,n=e.onProductTypeChange,a=e.productTypeMeta,i=e.bundleFilterValue,o=e.onBundleFilterChange,l=e.bundleFilterLabels,s=e.bundleProductPickerOn;return t?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(T.Z.Label,{children:"Filter Product Type"}),(0,A.jsxs)(T.Z.Select,{value:r||"all",onChange:n,title:"metadata.configs.general_config.display_product_type_filter",children:[(0,A.jsx)("option",{value:"all",children:a.allLabel}),a.options.map((function(e){return(0,A.jsx)("option",{value:e.value,children:e.label},e.value)}))]})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(T.Z.Label,{children:"L\u1ecdc s\u1ea3n ph\u1ea9m (ki\u1ec3u)"}),(0,A.jsxs)(T.Z.Select,{value:i,onChange:o,title:"metadata.configs.general_config.product_is_bundle",children:[(0,A.jsx)("option",{value:"all",children:l.all}),s&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("option",{value:"parent",children:l.parent}),(0,A.jsx)("option",{value:"child",children:l.child})]}),(0,A.jsx)("option",{value:"single",children:l.single}),(0,A.jsx)("option",{value:"template",children:l.template})]})]})},re=function(e){var t=e.show,r=e.onHide,n=e.onSave,a=e.form,o=e.onFormChange,l=(e.isSimpleOrder,e.mergedShopOptions),s=e.onShopNameChange,c=e.resolveAddedReasonSelectValue,u=e.getOrderListAddedReasonSelectRows,h=e.renderPriorityOption,p=e.useProductTypeFilterForNewOrder,g=e.newOrderProductTypeFilter,f=e.onProductTypeFilterChange,x=e.productTypeMetaForNewOrder,_=e.newOrderBf,v=e.onBundleFilterChange,S=e.bundleFilterLabels,b=e.bundleProductPickerOn,C=e.productOptionsForNewOrder,O=e.saving,F=a.items||[{product_code:"",quantity:1}],E=function(e){return o({target:{name:"items",value:e}})},L=function(e,t,r){var n=F.map((function(n,a){return a===e?(0,m.Z)((0,m.Z)({},n),{},(0,d.Z)({},t,r)):n}));E(n)},I=F.reduce((function(e,t){return e+(parseInt(t.quantity,10)||0)}),0),k=F.filter((function(e){return e.product_code&&(parseInt(e.quantity,10)||0)>0}));return(0,A.jsxs)(Z.Z,{show:t,onHide:r,size:"lg",children:[(0,A.jsx)(Z.Z.Header,{closeButton:!0,children:(0,A.jsx)(Z.Z.Title,{children:"T\u1ea1o nhi\u1ec1u \u0111\u01a1n"})}),(0,A.jsxs)(Z.Z.Body,{children:[(0,A.jsxs)(j.Z,{children:[(0,A.jsx)(y.Z,{md:6,children:(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsx)(T.Z.Label,{children:(0,G.R6)(G.Nx.TEXT_SHOP)}),(0,A.jsx)(J.Z,{value:l.find((function(e){return e.value===a.shop_name}))||null,onChange:s,options:l,placeholder:"Ch\u1ecdn ho\u1eb7c nh\u1eadp t\xean shop...",isClearable:!0,isSearchable:!0,formatCreateLabel:function(e){return'T\u1ea1o shop m\u1edbi: "'.concat(e,'"')},noOptionsMessage:function(){return"Kh\xf4ng t\xecm th\u1ea5y shop"}})]})}),(0,A.jsx)(y.Z,{md:6,children:(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsx)(T.Z.Label,{children:(0,G.R6)(G.Nx.TEXT_ORDER_DATE)}),(0,A.jsx)("div",{className:"react-datepicker-container-custom",children:(0,A.jsx)(ee.ZP,{selected:a.order_date,onChange:function(e){return o({target:{name:"order_date",value:e}})},dateFormat:"dd/MM/yyyy",className:"form-control",placeholderText:"Ch\u1ecdn ng\xe0y...",maxDate:new Date})})]})})]}),(0,A.jsxs)(j.Z,{children:[(0,A.jsx)(y.Z,{md:6,children:(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsx)(T.Z.Label,{children:(0,G.R6)(G.Nx.TEXT_ADDED_REASON)}),(0,A.jsx)(T.Z.Select,{name:"added_reason",value:c(a.added_reason,!1),onChange:o,children:u(a.added_reason,!1).map((function(e){return(0,A.jsx)("option",{value:e.value,children:e.label},e.value)}))})]})}),(0,A.jsx)(y.Z,{md:6,children:(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsx)(T.Z.Label,{children:(0,G.R6)(G.Nx.TEXT_PRIORITY)}),(0,A.jsx)(T.Z.Select,{name:"priority",value:a.priority,onChange:o,children:[1,2,3,4].map((function(e){return(0,A.jsx)("option",{value:e,children:h(e).props.children[1].props.children},e)}))})]})})]}),(0,A.jsxs)(j.Z,{children:[(0,A.jsx)(y.Z,{md:6,children:(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsx)(T.Z.Label,{children:(0,G.R6)(G.Nx.TEXT_BUYER_NOTE)}),(0,A.jsx)(T.Z.Control,{as:"textarea",rows:2,name:"buyer_note",value:a.buyer_note,onChange:o})]})}),(0,A.jsx)(y.Z,{md:6,children:(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsx)(T.Z.Label,{children:(0,G.R6)(G.Nx.TEXT_SELLER_NOTE)}),(0,A.jsx)(T.Z.Control,{as:"textarea",rows:2,name:"seller_note",value:a.seller_note,onChange:o})]})})]}),(0,A.jsx)("hr",{}),(0,A.jsx)("div",{className:"mb-3",children:(0,A.jsx)(te,{useProductTypeFilter:p,productTypeFilterValue:g,onProductTypeFilterChange:f,productTypeMeta:x,bundleFilterValue:_,onBundleFilterChange:v,bundleFilterLabels:S,bundleProductPickerOn:b})}),(0,A.jsxs)("div",{className:"mb-2 d-flex align-items-center justify-content-between",children:[(0,A.jsx)("b",{children:"Danh s\xe1ch s\u1ea3n ph\u1ea9m"}),(0,A.jsx)("span",{className:"text-muted small",children:"M\u1ed7i d\xf2ng = 1 \u0111\u01a1n h\xe0ng"})]}),(0,A.jsxs)(w.Z,{bordered:!0,size:"sm",className:"mb-2",children:[(0,A.jsx)("thead",{className:"table-light",children:(0,A.jsxs)("tr",{children:[(0,A.jsx)("th",{children:"STT"}),(0,A.jsx)("th",{children:"M\xe3 s\u1ea3n ph\u1ea9m"}),(0,A.jsx)("th",{style:{width:120},children:"S\u1ed1 l\u01b0\u1ee3ng"}),(0,A.jsx)("th",{style:{width:60},children:"Thao t\xe1c"})]})}),(0,A.jsx)("tbody",{children:F.map((function(e,t){return(0,A.jsxs)("tr",{children:[(0,A.jsx)("td",{className:"align-middle text-center",style:{width:40},children:t+1}),(0,A.jsx)("td",{children:(0,A.jsx)($.ZP,{value:C.find((function(t){return t.value===e.product_code}))||null,onChange:function(e){return L(t,"product_code",e?e.value:"")},options:C,placeholder:"T\xecm s\u1ea3n ph\u1ea9m...",isClearable:!0,isSearchable:!0,menuPortalTarget:document.body,styles:{menuPortal:function(e){return(0,m.Z)((0,m.Z)({},e),{},{zIndex:9999})}},noOptionsMessage:function(){return"Kh\xf4ng t\xecm th\u1ea5y"}})}),(0,A.jsx)("td",{children:(0,A.jsx)(T.Z.Control,{type:"text",inputMode:"numeric",value:e.quantity,onChange:function(e){return L(t,"quantity",e.target.value)}})}),(0,A.jsx)("td",{className:"align-middle text-center",children:(0,A.jsx)(N.Z,{variant:"outline-danger",size:"sm",disabled:F.length<=1,onClick:function(){return function(e){return E(F.filter((function(t,r){return r!==e})))}(t)},children:"X\xf3a"})})]},t)}))}),(0,A.jsx)("tfoot",{children:(0,A.jsxs)("tr",{children:[(0,A.jsxs)("td",{colSpan:2,className:"text-end fw-semibold",children:["T\u1ed5ng s\u1ed1 s\u1ea3n ph\u1ea9m: ",(0,A.jsx)("span",{className:"text-primary",children:F.length})]}),(0,A.jsxs)("td",{className:"fw-semibold",children:["T\u1ed5ng s\u1ed1 l\u01b0\u1ee3ng: ",(0,A.jsx)("span",{className:"text-success",children:I})]}),(0,A.jsx)("td",{})]})})]}),(0,A.jsx)(N.Z,{variant:"outline-primary",size:"sm",onClick:function(){return E([].concat((0,i.Z)(F),[{product_code:"",quantity:1}]))},children:"+ Th\xeam S\u1ea3n Ph\u1ea9m"})]}),(0,A.jsxs)(Z.Z.Footer,{children:[(0,A.jsx)(N.Z,{variant:"secondary",onClick:r,children:"Hu\u1ef7"}),(0,A.jsx)(N.Z,{variant:"primary",onClick:function(){return n(F)},disabled:O||0===k.length,children:O?"\u0110ang t\u1ea1o...":"T\u1ea1o ".concat(k.length," \u0111\u01a1n")})]})]})},ne=r(5191),ae=r(33609),ie=r(96593),oe=function(e){var t=e.visibleFilterKeys,r=e.targetPage,n=e.orderListCfg,a=e.orderFilterHiddenLocal,i=e.onToggleFilterHidden;return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)("p",{className:"text-muted small",children:["An bo loc tren thanh toolbar (luu cuc bo trinh duyet). Admin co the an cung theo cong ty tai"," ",(0,A.jsx)("strong",{children:"Quan ly cong ty -> Cau hinh -> Danh sach don"}),"."]}),(0,A.jsx)(T.Z,{children:t.map((function(e){var t=(0,ie.Xh)(r,e,n),o=!0===(null===a||void 0===a?void 0:a[e]),l=t||o;return(0,A.jsx)(T.Z.Check,{type:"switch",id:"order-filter-".concat(e),className:"mb-2",checked:l,disabled:t,label:(0,A.jsxs)("span",{children:[(0,A.jsx)("strong",{children:(0,ie.TT)(e)})," ",(0,A.jsx)("code",{className:"small text-muted",children:e}),t&&(0,A.jsx)("span",{className:"text-muted small ms-1",children:"(da an boi cong ty)"})]}),onChange:function(){return i(e)}},e)}))})]})},le=function(e){var t=e.show,r=e.onHide,n=e.onSave,a=e.modalTab,i=e.onTabSelect,o=e.targetPage,l=e.columnVisibility,s=e.orderListHeaderLabel,d=e.onToggleColumn,c=e.orderListCfg,u=e.orderDateFilterHiddenLocal,h=e.getDateFilterOptionLabel,p=e.onToggleDateFilterHidden,g=e.visibleOrderListFilterKeys,m=e.orderFilterHiddenLocal,f=e.onToggleFilterHidden,x=e.autoFulfillBatchSize,_=e.onChangeAutoFulfillBatchSize,v=e.fulfillStartFinis
1hTimeOnly,y=void 0!==v&&v,S=e.onToggleFulfillStartFinishTimeOnly,b=void 0===S?function(){}:S,C=e.orderListFrozenUptoOptions,j=void 0===C?[]:C,O=e.orderListFrozenUntilKey,w=void 0===O?"":O,F=e.onChangeOrderListFrozenUntilKey,E=void 0===F?function(){}:F,L=e.onExportSGB,I=e.onExportTHE,k=e.onExportViettelPost;return(0,A.jsxs)(Z.Z,{show:t,onHide:r,size:"lg",children:[(0,A.jsx)(Z.Z.Header,{closeButton:!0,children:(0,A.jsx)(Z.Z.Title,{children:(0,G.R6)(G.Nx.TEXT_DISPLAY_CONFIG)})}),(0,A.jsx)(Z.Z.Body,{className:"pt-2",children:(0,A.jsxs)(ne.Z.Container,{activeKey:a||"columns",onSelect:function(e){return null!=e&&i(e)},children:[(0,A.jsxs)(ae.Z,{variant:"tabs",className:"mb-3 flex-wrap",children:[(0,A.jsx)(ae.Z.Item,{children:(0,A.jsx)(ae.Z.Link,{eventKey:"columns",children:"C\u1ed9t b\u1ea3ng"})}),(0,A.jsx)(ae.Z.Item,{children:(0,A.jsx)(ae.Z.Link,{eventKey:"dateFilter",children:"L\u1ecdc ng\xe0y"})}),(0,A.jsx)(ae.Z.Item,{children:(0,A.jsx)(ae.Z.Link,{eventKey:"filters",children:"B\u1ed9 l\u1ecdc kh\xe1c"})}),(0,A.jsx)(ae.Z.Item,{children:(0,A.jsx)(ae.Z.Link,{eventKey:"autoFulfill",children:"Auto Fulfill"})}),"fulfill"===o&&(0,A.jsx)(ae.Z.Item,{children:(0,A.jsx)(ae.Z.Link,{eventKey:"sendOrder",children:"G\u1eedi \u0111\u01a1n"})})]}),(0,A.jsxs)(ne.Z.Content,{children:[(0,A.jsx)(ne.Z.Pane,{eventKey:"columns",children:(0,A.jsxs)(T.Z,{children:[(0,A.jsxs)(T.Z.Text,{className:"text-muted d-block mb-2",children:["Nh\xe3n c\u1ed9t theo c\xf4ng ty: ",(0,A.jsxs)("code",{children:["metadata.configs.orderList.",o,".headers"]})," \u2014 trang:"," ",(0,A.jsx)("code",{children:o}),"."]}),ie.h4.filter((function(e){return e in l})).map((function(e){return(0,A.jsx)(T.Z.Check,{type:"switch",id:"column-".concat(e),label:s(e),checked:!!l[e],onChange:function(){return d(e)},className:"mb-2"},e)})),(0,A.jsx)("hr",{className:"my-3"}),(0,A.jsx)(T.Z.Text,{className:"text-muted d-block mb-2",children:"\u0110\u1ecbnh d\u1ea1ng c\u1ed9t th\u1eddi gian fulfill"}),(0,A.jsx)(T.Z.Check,{type:"switch",id:"order-fulfill-start-finish-time-only",className:"mb-2",checked:!!y,onChange:function(){return b()},label:"B\u1ecf ng\xe0y \u1edf Start / Finish fulfill \u2014 khi b\u1eadt ch\u1ec9 hi\u1ec7n gi\u1edd (HH:mm)"}),(0,A.jsx)("hr",{className:"my-3"}),(0,A.jsxs)(T.Z.Group,{className:"mb-2",children:[(0,A.jsx)(T.Z.Label,{children:"Frozen \u0111\u1ebfn c\u1ed9t (khi cu\u1ed9n ngang b\u1ea3ng)"}),(0,A.jsxs)(T.Z.Text,{className:"text-muted d-block small mb-2",children:['Ch\u1ec9 hi\u1ec7n c\u1ed9t \u0111ang b\u1eadt; t\u1eeb tr\xe1i "\u0111\xf3ng b\u0103ng" \u0111\u1ebfn h\u1ebft c\u1ed9t \u0111\xe3 ch\u1ecdn. Sale / Fulfill c\xf3 c\u1ed9t',(0,A.jsx)("strong",{children:" Ch\u1ecdn \u0111\u01a1n"})," tr\u01b0\u1edbc c\xe1c c\u1ed9t d\u1eef li\u1ec7u; Rnd kh\xf4ng c\xf3. L\u01b0u theo ",(0,A.jsx)("code",{children:o}),"."]}),(0,A.jsx)(T.Z.Select,{value:w,onChange:function(e){return E(e.target.value)},"aria-label":"Frozen \u0111\u1ebfn c\u1ed9t",children:(j||[]).map((function(e){return(0,A.jsx)("option",{value:e.value,children:e.value?"\u0110\u1ebfn: ".concat(e.label):e.label},e.value||"__none")}))})]})]})}),(0,A.jsxs)(ne.Z.Pane,{eventKey:"dateFilter",children:[(0,A.jsxs)("p",{className:"text-muted small",children:["\u1ea8n m\u1ee5c kh\u1ecfi dropdown l\u1ecdc ng\xe0y (l\u01b0u c\u1ee5c b\u1ed9 tr\xecnh duy\u1ec7t). Admin c\xf3 th\u1ec3 \u1ea9n th\xeam theo c\xf4ng ty t\u1ea1i"," ",(0,A.jsx)("strong",{children:"Qu\u1ea3n l\xfd c\xf4ng ty \u2192 C\u1ea5u h\xecnh \u2192 Danh s\xe1ch \u0111\u01a1n \u2192 B\u1ed9 l\u1ecdc ng\xe0y"}),"."]}),(0,A.jsx)(T.Z,{children:ie.dJ.map((function(e){var t=(0,ie.I0)(o,e,c),r=!0===(null===u||void 0===u?void 0:u[e]),n=t||r;return(0,A.jsx)(T.Z.Check,{type:"switch",id:"order-df-".concat(e),className:"mb-2",checked:n,disabled:t,label:(0,A.jsxs)("span",{children:[(0,A.jsx)("strong",{children:h(e)}),"last_sale"!==e&&"last_year"!==e&&(0,A.jsxs)(A.Fragment,{children:[" ",(0,A.jsx)("code",{className:"small text-muted",children:e})]}),t&&(0,A.jsx)("span",{className:"text-muted small ms-1",children:"(\u0111\xe3 \u1ea9n b\u1edfi c\xf4ng ty)"})]}),onChange:function(){return p(e)}},e)}))})]}),(0,A.jsx)(ne.Z.Pane,{eventKey:"filters",children:(0,A.jsx)(oe,{visibleFilterKeys:g,targetPage:o,orderListCfg:c,orderFilterHiddenLocal:m,onToggleFilterHidden:f})}),(0,A.jsx)(ne.Z.Pane,{eventKey:"autoFulfill",children:(0,A.jsx)(T.Z,{children:(0,A.jsxs)(T.Z.Group,{children:[(0,A.jsx)(T.Z.Label,{children:"Batch Size (s\u1ed1 \u0111\u01a1n g\u1eedi m\u1ed7i l\u1ea7n)"}),(0,A.jsx)(T.Z.Control,{type:"text",inputMode:"numeric",value:x,onChange:function(e){var t=parseInt(e.target.value,10)||50;_(t)},placeholder:"50"}),(0,A.jsx)(T.Z.Text,{className:"text-muted",children:"S\u1ed1 l\u01b0\u1ee3ng \u0111\u01a1n h\xe0ng s\u1ebd \u0111\u01b0\u1ee3c g\u1eedi c\xf9ng l\xfac. Gi\xe1 tr\u1ecb l\u1edbn h\u01a1n s\u1ebd nhanh h\u01a1n nh\u01b0ng c\xf3 th\u1ec3 g\xe2y t\u1ea3i server."})]})})}),"fulfill"===o&&(0,A.jsxs)(ne.Z.Pane,{eventKey:"sendOrder",children:[(0,A.jsx)("p",{className:"text-muted small mb-3",children:"Ch\u1ecdn c\xe1c \u0111\u01a1n \u1edf danh s\xe1ch, sau \u0111\xf3 b\u1ea5m g\u1eedi sang Google Sheet \u0111\u01a1n v\u1ecb v\u1eadn chuy\u1ec3n (gi\u1ed1ng \u1edf trang Sale)."}),(0,A.jsxs)("div",{className:"d-flex flex-column gap-2",style:{maxWidth:260},children:[(0,A.jsx)(N.Z,{variant:"success",onClick:function(){return L&&L()},children:"G\u1eedi SGB"}),(0,A.jsx)(N.Z,{variant:"success",onClick:function(){return I&&I()},children:"G\u1eedi THE"}),(0,A.jsx)(N.Z,{variant:"info",onClick:function(){return k&&k()},children:"G\u1eedi Viettel Post"})]})]})]})]})}),(0,A.jsxs)(Z.Z.Footer,{children:[(0,A.jsx)(N.Z,{variant:"secondary",onClick:r,children:(0,G.R6)(G.Nx.TEXT_CANCEL)}),(0,A.jsx)(N.Z,{variant:"primary",onClick:n,children:(0,G.R6)(G.Nx.TEXT_SAVE_VIEW)})]})]})},se=function(e){var t=e.show,r=e.onHide,n=e.onSave,a=e.newOrderForm,i=e.isSimpleOrder,o=e.mergedShopOptions,l=e.onShopNameChange,s=e.onNewOrderFormChange,d=e.resolveAddedReasonSelectValue,c=e.getOrderListAddedReasonSelectRows,u=e.renderPri
1orityOption,h=e.useProductTypeFilterForNewOrder,p=e.newOrderProductTypeFilter,g=e.onProductTypeFilterChange,m=e.productTypeMetaForNewOrder,f=e.newOrderBf,x=e.onBundleFilterChange,_=e.bundleFilterLabels,v=e.bundleProductPickerOn,S=e.productOptionsForNewOrder,b=e.onNewOrderListingChange,C=e.showProductCustomField1,O=void 0!==C&&C,w=e.showProductCustomField2,F=void 0!==w&&w,E=e.productCustomField1Label,L=void 0===E?"Product Custom Field 1":E,I=e.productCustomField2Label,k=void 0===I?"Product Custom Field 2":I,P=e.showRefCompanyIds,R=void 0!==P&&P,D=e.showOrderIdInput,M=void 0!==D&&D;return(0,A.jsxs)(Z.Z,{show:t,onHide:r,size:"lg",children:[(0,A.jsx)(Z.Z.Header,{closeButton:!0,children:(0,A.jsx)(Z.Z.Title,{children:(0,G.R6)(G.Nx.TEXT_ADD_NEW_ORDER)})}),(0,A.jsx)(Z.Z.Body,{children:(0,A.jsxs)(T.Z,{children:[M&&(0,A.jsx)(j.Z,{children:(0,A.jsx)(y.Z,{md:6,children:(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsx)(T.Z.Label,{children:"Order ID"}),(0,A.jsx)(T.Z.Control,{type:"text",name:"order_id",value:a.order_id||"",onChange:s,placeholder:"\u0110\u1ec3 tr\u1ed1ng = t\u1ef1 sinh"})]})})}),(0,A.jsxs)(j.Z,{children:[(0,A.jsx)(y.Z,{md:6,children:(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsx)(T.Z.Label,{children:(0,G.R6)(G.Nx.TEXT_SHOP)}),(0,A.jsx)(J.Z,{value:o.find((function(e){return e.value===a.shop_name}))||null,onChange:l,options:o,placeholder:"Chon hoac nhap ten shop moi...",isClearable:!0,isSearchable:!0,formatCreateLabel:function(e){return'Tao shop moi: "'.concat(e,'"')},noOptionsMessage:function(){return"Khong tim thay shop"},required:!0})]})}),(0,A.jsx)(y.Z,{md:6,children:(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsx)(T.Z.Label,{children:(0,G.R6)(G.Nx.TEXT_ORDER_DATE)}),(0,A.jsx)("div",{className:"react-datepicker-container-custom",children:(0,A.jsx)(ee.ZP,{selected:a.order_date,onChange:function(e){return s({target:{name:"order_date",value:e}})},dateFormat:"dd/MM/yyyy",className:"form-control",placeholderText:"Chon ngay dat hang...",maxDate:new Date,style:{width:"100%"}})})]})})]}),(0,A.jsxs)(j.Z,{children:[(0,A.jsx)(y.Z,{md:6,children:(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsx)(T.Z.Label,{children:(0,G.R6)(G.Nx.TEXT_ADDED_REASON)}),(0,A.jsx)(T.Z.Select,{name:"added_reason",value:d(a.added_reason,!1),onChange:s,children:c(a.added_reason,!1).map((function(e){return(0,A.jsx)("option",{value:e.value,children:e.label},e.value)}))})]})}),(0,A.jsx)(y.Z,{md:6,children:(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsx)(T.Z.Label,{children:(0,G.R6)(G.Nx.TEXT_PRIORITY)}),(0,A.jsx)(T.Z.Select,{name:"priority",value:a.priority,onChange:s,children:[1,2,3,4].map((function(e){return(0,A.jsx)("option",{value:e,children:u(e).props.children[1].props.children},e)}))})]})})]}),!i&&(0,A.jsxs)(j.Z,{children:[(0,A.jsx)(y.Z,{md:6,children:(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsx)(T.Z.Label,{children:"Ma tham chieu (Order ID/Monthly ID)"}),(0,A.jsx)(T.Z.Control,{type:"text",name:"reference_code",value:a.reference_code,onChange:s,placeholder:"Nhap Order ID hoac Monthly ID..."})]})}),(0,A.jsx)(y.Z,{md:6,children:(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsx)(T.Z.Label,{children:(0,G.R6)(G.Nx.TEXT_IOSS)}),(0,A.jsx)(T.Z.Control,{type:"text",name:"ioss",value:a.ioss||"",onChange:s,placeholder:"Enter IOSS number..."})]})})]}),R&&(0,A.jsx)(j.Z,{children:(0,A.jsx)(y.Z,{md:12,children:(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsx)(T.Z.Label,{children:"Ref Company IDs"}),(0,A.jsx)(T.Z.Control,{type:"text",name:"ref_company_ids",value:a.ref_company_ids||"",onChange:s,placeholder:"VD: 000002,000009"}),(0,A.jsx)(T.Z.Text,{className:"text-muted",children:"company_id c\xe1ch nhau d\u1ea5u ph\u1ea9y (m\u1eb7c \u0111\u1ecbnh l\u1ea5y theo user)"})]})})}),!i&&(0,A.jsxs)(j.Z,{children:[(0,A.jsx)(y.Z,{md:6,children:(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsx)(T.Z.Label,{children:(0,G.R6)(G.Nx.TEXT_CUSTOMER)}),(0,A.jsx)(T.Z.Control,{type:"text",name:"customer_name",value:a.customer_name,onChange:s})]})}),(0,A.jsx)(y.Z,{md:6,children:(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsx)(T.Z.Label,{children:(0,G.R6)(G.Nx.TEXT_EMAIL)}),(0,A.jsx)(T.Z.Control,{type:"email",name:"email",value:a.email,onChange:s})]})})]}),!i&&(0,A.jsx)(j.Z,{children:(0,A.jsx)(y.Z,{md:12,children:(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsx)(T.Z.Label,{children:(0,G.R6)(G.Nx.TEXT_SHIPPING_ADDRESS)}),(0,A.jsx)(T.Z.Control,{as:"textarea",rows:4,name:"shipping_address",value:a.shipping_address,onChange:s})]})})}),(0,A.jsxs)(j.Z,{children:[(0,A.jsx)(y.Z,{md:6,children:(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsx)(T.Z.Label,{children:(0,G.R6)(G.Nx.TEXT_BUYER_NOTE)}),(0,A.jsx)(T.Z.Control,{as:"textarea",rows:2,name:"buyer_note",value:a.buyer_note,onChange:s})]})}),(0,A.jsx)(y.Z,{md:6,children:(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsx)(T.Z.Label,{children:(0,G.R6)(G.Nx.TEXT_SELLER_NOTE)}),(0,A.jsx)(T.Z.Control,{as:"textarea",rows:2,name:"seller_note",value:a.seller_note,onChange:s}),!i&&(0,A.jsx)(T.Z.Text,{className:"text-muted",children:"Ma tham 
1chieu se tu dong duoc them vao dau ghi chu"})]})})]}),(0,A.jsx)("hr",{}),(0,A.jsx)("h5",{children:(0,G.R6)(G.Nx.TEXT_LISTING_DETAILS)}),(0,A.jsx)(j.Z,{className:"mb-3",children:(0,A.jsx)(y.Z,{md:6,children:(0,A.jsx)(T.Z.Group,{children:(0,A.jsx)(te,{useProductTypeFilter:h,productTypeFilterValue:p||"all",onProductTypeChange:g,productTypeMeta:m,bundleFilterValue:f,onBundleFilterChange:x,bundleFilterLabels:_,bundleProductPickerOn:v})})})}),a.listings.map((function(e,t){var r,n=S.find((function(t){return t.value===e.product_code}))||null;return(0,A.jsx)("div",{className:"mb-3 p-3 border rounded",children:(0,A.jsxs)(j.Z,{className:"align-items-center",children:[(0,A.jsxs)(y.Z,{md:6,children:[(0,A.jsxs)(T.Z.Group,{className:"mb-2",children:[(0,A.jsx)(T.Z.Label,{children:"Chon san pham"}),(0,A.jsx)($.ZP,{value:n,onChange:function(e){return b(t,"product",e)},options:S,isClearable:!0,isSearchable:!0,placeholder:"Chon san pham (product_code)...",noOptionsMessage:function(){return"Khong tim thay san pham"},formatOptionLabel:function(e){return(0,A.jsxs)("div",{style:{display:"flex",alignItems:"center"},children:[e.img_url&&(0,A.jsx)("img",{src:e.img_url,alt:"",style:{width:32,height:32,marginRight:8,objectFit:"cover",borderRadius:4}}),(0,A.jsx)("span",{children:e.label})]})}})]}),(0,A.jsxs)(T.Z.Group,{className:"mb-2",children:[(0,A.jsx)(T.Z.Label,{children:(0,G.R6)(G.Nx.TEXT_PRODUCT_NAME)}),(0,A.jsx)(T.Z.Control,{type:"text",value:e.title,readOnly:!0})]}),(0,A.jsxs)(T.Z.Group,{className:"mb-2",children:[(0,A.jsx)(T.Z.Label,{children:"So luong"}),(0,A.jsx)(T.Z.Control,{type:"text",inputMode:"numeric",value:e.quantity||1,onChange:function(e){return b(t,"quantity",e.target.value)}})]}),(O||F)&&(0,A.jsxs)(j.Z,{children:[O&&(0,A.jsx)(y.Z,{md:F?6:12,children:(0,A.jsxs)(T.Z.Group,{className:"mb-2",children:[(0,A.jsx)(T.Z.Label,{children:L}),(0,A.jsx)(T.Z.Control,{type:"text",value:e.custom_field_1||"",onChange:function(e){return b(t,"custom_field_1",e.target.value)}})]})}),F&&(0,A.jsx)(y.Z,{md:O?6:12,children:(0,A.jsxs)(T.Z.Group,{className:"mb-2",children:[(0,A.jsx)(T.Z.Label,{children:k}),(0,A.jsx)(T.Z.Control,{type:"text",value:e.custom_field_2||"",onChange:function(e){return b(t,"custom_field_2",e.target.value)}})]})})]})]}),(0,A.jsx)(y.Z,{md:6,className:"text-center",children:e.img_url&&(0,A.jsx)("img",{src:null===(r=e.img_url)||void 0===r?void 0:r.replace("75x75","180x180"),alt:e.title,style:{width:180,height:180,objectFit:"cover",border:"1px solid #eee",borderRadius:6,marginTop:8}})})]})},t)}))]})}),(0,A.jsxs)(Z.Z.Footer,{children:[(0,A.jsx)(N.Z,{variant:"secondary",onClick:r,children:(0,G.R6)(G.Nx.TEXT_CANCEL)}),(0,A.jsx)(N.Z,{variant:"primary",onClick:n,disabled:!a.shop_name,style:a.shop_name?{}:{color:"#222",background:"#e9ecef",borderColor:"#dee2e6"},children:(0,G.R6)(G.Nx.TEXT_SAVE)})]})]})},de=function(e){var t=e.show,r=e.friendlyParentLabel,n=e.count,a=e.onCountChange,i=e.saving,o=void 0!==i&&i,l=e.onClose,s=e.onConfirm;return(0,A.jsxs)(Z.Z,{show:t,centered:!0,onHide:function(){o||l&&l()},backdrop:!o||"static",children:[(0,A.jsx)(Z.Z.Header,{closeButton:!o,children:(0,A.jsxs)(Z.Z.Title,{children:["T\u1ea1o \u0111\u01a1n con \u2014 ",r||""]})}),(0,A.jsx)(Z.Z.Body,{children:(0,A.jsxs)(T.Z.Group,{children:[(0,A.jsx)(T.Z.Label,{children:"S\u1ed1 l\u01b0\u1ee3ng \u0111\u01a1n con mu\u1ed1n t\u1ea1o"}),(0,A.jsx)(T.Z.Control,{type:"number",min:1,value:n,onChange:function(e){return a&&a(e.target.value)},disabled:o,autoFocus:!0,onKeyDown:function(e){"Enter"!==e.key||o||(e.preventDefault(),s&&s())}}),(0,A.jsxs)(T.Z.Text,{className:"text-muted",children:["M\u1ed7i \u0111\u01a1n con s\u1ebd c\xf3 ",(0,A.jsx)("code",{children:"order_id"})," d\u1ea1ng ",(0,A.jsxs)("code",{children:[r,"_NN"]})," v\u1edbi NN t\u1ef1 t\u0103ng."]})]})}),(0,A.jsxs)(Z.Z.Footer,{children:[(0,A.jsx)(N.Z,{variant:"secondary",onClick:l,disabled:o,children:"Hu\u1ef7"}),(0,A.jsx)(N.Z,{variant:"primary",onClick:s,disabled:o,children:o?"\u0110ang t\u1ea1o\u2026":"T\u1ea1o"})]})]})},ce=r(69936),ue=function(e){var t=e.show,r=e.onHide,n=e.exportMode,a=e.exportWarehouse,o=e.onExportWarehouseChange,l=e.exportFailTarget
1Status,s=e.onExportFailTargetStatusChange,d=e.exportViewProduct,c=e.onExportViewProductChange,u=e.exportNote,h=e.onExportNoteChange,p=e.exportItems,g=void 0===p?[]:p,m=e.exportSaving,f=e.onSubmit,x=e.showOrderQtyFailedColumn,_=e.orderQtyFailedMeta,v=void 0===_?{label:"SL L\u1ed7i"}:_,S=e.selectedOrders,b=void 0===S?[]:S,C=e.currentCompany,O=e.publicPartners,F=e.getOrderStatusDisplayLabel,E=e.formatOrderIdToHuman,L=e.formatMonthlyIdToHuman,I="FAIL"===n,k=(0,U.fL)(C,O),P=b.map((function(e){var t=L(e.monthly_id),r=E(e.order_id)||e.order_id||"-";return t&&"-"!==t?t:r})),R=Array.from(new Set(P.filter(Boolean)));return(0,A.jsxs)(Z.Z,{show:t,onHide:r,size:"lg",children:[(0,A.jsx)(Z.Z.Header,{closeButton:!0,children:(0,A.jsx)(Z.Z.Title,{children:I?"Xu\u1ea5t l\u1ed7i (Fulfill)":"Xu\u1ea5t h\xe0ng (Fulfill)"})}),(0,A.jsx)(Z.Z.Body,{children:(0,A.jsxs)(T.Z,{children:[(0,A.jsxs)(j.Z,{className:"mb-3 align-items-center",children:[(0,A.jsx)(y.Z,{md:6,children:(0,A.jsxs)(T.Z.Group,{children:[(0,A.jsx)(T.Z.Label,{children:"\u0110\u1ed1i t\xe1c"}),(0,A.jsxs)(T.Z.Select,{value:a,onChange:function(e){return o&&o(e.target.value)},children:[(0,A.jsx)("option",{value:"",children:"Ch\u1ecdn \u0111\u1ed1i t\xe1c..."}),k.map((function(e){return(0,A.jsx)("option",{value:e.value,children:e.label},e.value)}))]})]})}),(0,A.jsx)(y.Z,{md:6,className:"d-flex align-items-center",children:I?(0,A.jsxs)(T.Z.Group,{className:"w-100",children:[(0,A.jsx)(T.Z.Label,{children:"Tr\u1ea1ng th\xe1i \u0111\xedch"}),(0,A.jsxs)(T.Z.Select,{value:l,onChange:function(e){return s&&s(e.target.value)},children:[(0,A.jsxs)("option",{value:Y.vl.FAIL_REASON_1,children:["25 \u2014 ",F(Y.vl.FAIL_REASON_1)]}),(0,A.jsxs)("option",{value:Y.vl.FAIL_REASON_2,children:["26 \u2014 ",F(Y.vl.FAIL_REASON_2)]}),(0,A.jsxs)("option",{value:Y.vl.FAIL_REASON_3,children:["27 \u2014 ",F(Y.vl.FAIL_REASON_3)]})]})]}):(0,A.jsx)(T.Z.Check,{type:"checkbox",id:"export-view-product",label:"View S\u1ea3n ph\u1ea9m",checked:d,onChange:function(e){return c&&c(e.target.checked)},className:"ms-3"})})]}),(0,A.jsxs)(j.Z,{className:"mb-3",children:[(0,A.jsx)(y.Z,{md:6,children:(0,A.jsxs)(T.Z.Group,{children:[(0,A.jsx)(T.Z.Label,{children:"Danh s\xe1ch \u0111\u01a1n (t\u1ed5ng: ".concat(R.length," \u0111\u01a1n)")}),(0,A.jsx)(T.Z.Control,{as:"textarea",rows:4,value:R.join(", "),readOnly:!0})]})}),(0,A.jsx)(y.Z,{md:6,children:(0,A.jsxs)(T.Z.Group,{children:[(0,A.jsx)(T.Z.Label,{children:"Ghi ch\xfa"}),(0,A.jsx)(T.Z.Control,{as:"textarea",rows:4,value:u,onChange:function(e){return h&&h(e.target.value)},placeholder:"Nh\u1eadp ghi ch\xfa xu\u1ea5t h\xe0ng..."})]})})]}),d?(0,A.jsxs)(w.Z,{bordered:!0,hover:!0,size:"sm",children:[(0,A.jsx)("thead",{children:(0,A.jsxs)("tr",{children:[(0,A.jsx)("th",{children:"STT"}),(0,A.jsx)("th",{children:"SKU"}),(0,A.jsx)("th",{children:"T\xean SP"}),(0,A.jsx)("th",{children:"Size"}),(0,A.jsx)("th",{children:"SL"}),x&&(0,A.jsx)("th",{style:{color:"#dc3545"},children:v.label}),x&&(0,A.jsx)("th",{style:{color:"#198754"},children:"SL xu\u1ea5t"})]})}),(0,A.jsx)("tbody",{children:function(){var e=g.reduce((function(e,t){return e+(t.quantity||0)}),0),t=g.reduce((function(e,t){return e+Math.max(parseInt(t.qty_failed,10)||0,0)}),0),r=g.reduce((function(e,t){var r=Math.max(parseInt(t.qty_failed,10)||0,0),n=parseInt(t.quantity,10)||0;return e+(I?r:Math.max(n-r,0))}),0);return[].concat((0,i.Z)(g.map((function(e,t){return(0,A.jsxs)("tr",{children:[(0,A.jsx)("td",{children:t+1}),(0,A.jsx)("td",{children:(0,ce.G)(e.sku)}),(0,A.jsx)("td",{children:e.title||"-"}),(0,A.jsx)("td",{children:e.size}),(0,A.jsx)("td",{children:e.quantity}),x&&(0,A.jsx)("td",{style:{color:"#dc3545"},children:Math.max(parseInt(e.qty_failed,10)||0,0)}),x&&(0,A.jsx)("td",{style:{color:"#198754"},children:I?Math.max(parseInt(e.qty_failed,10)||0,0):Math.max((parseInt(e.quantity,10)||0)-(parseInt(e.qty_failed,10)||0),0)})]},t)}))),[(0,A.jsxs)("tr",{className:"table-info",children:[(0,A.jsx)("td",{colSpan:"4",className:"text-end fw-bold",children:"T\u1ed5ng s\u1ed1 l\u01b0\u1ee3ng s\u1ea3n ph\u1ea9m:"}),(0,A.jsx)("td",{className:"fw-bold",children:e}),x&&(0,A.jsx)("td",{className:"fw-bold",style:{color:"#dc3545"},children:t}),x&&(0,A.jsx)("td",{className:"fw-bold",style:{color:"#198754"},children:r})]},"total")])}()})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(w.Z,{bordered:!0,hover:!0,size:"sm",responsive:!0,style:{tableLayout:"fixed"},children:[(0,A.jsx)("thead",{children:(0,A.jsxs)("tr",{children:[(0,A.jsx)("th",{style:{width:"60px"},children:"STT"}),(0,A.jsx)("th",{style:{width:"110px"},children:"M\xe3 \u0111\u01a1n"}),(0,A.jsx)("th",{children:"S\u1ea3n ph\u1ea9m"}),(0,A.jsx)("th",{style:{width:"90px"},children:"S\u1ed1 l\u01b0\u1ee3ng"}),x&&(0,A.jsx)("th",{style:{width:"110px",color:"#dc3545"},children:v.label}),(0,A.jsx)("th",{style:{width:"90px",color:"#198754"},children:"SL xu\u1ea5t"})]})}),(0,A.jsx)("tbody",{children:b.map((function(e,t){var r={};
1(e.listings||[]).forEach((function(e){var t="".concat(e.sku,"||").concat(e.size),n=parseInt(e.quantity,10),a=Number.isFinite(n)&&n>0?n:1,i=parseInt(e.qty_failed,10),o=Number.isFinite(i)&&i>0?i:0;r[t]||(r[t]={sku:e.sku,size:e.size,title:e.title||"",qty:0,qtyFailed:0}),r[t].qty+=a,r[t].qtyFailed+=o}));var n=Object.values(r);return 0===n.length?(0,A.jsxs)("tr",{children:[(0,A.jsx)("td",{children:t+1}),(0,A.jsx)("td",{children:E(e.order_id)}),(0,A.jsx)("td",{children:"-"}),(0,A.jsx)("td",{style:{color:"#198754"},children:"0"}),x&&(0,A.jsx)("td",{style:{color:"#dc3545"},children:"0"}),(0,A.jsx)("td",{children:"0"})]},e.order_id||t):n.map((function(r,a){var i=I?r.qtyFailed||0:Math.max((r.qty||0)-(r.qtyFailed||0),0);return(0,A.jsxs)("tr",{children:[0===a&&(0,A.jsx)("td",{rowSpan:n.length,children:t+1}),0===a&&(0,A.jsx)("td",{rowSpan:n.length,children:E(e.order_id)}),(0,A.jsx)("td",{style:{wordBreak:"break-word",whiteSpace:"normal"},children:"".concat((0,ce.G)(r.sku)," (").concat(r.size,")").concat(r.title?" - ".concat(r.title):"")}),(0,A.jsx)("td",{children:r.qty||0}),x&&(0,A.jsx)("td",{style:{color:"#dc3545"},children:r.qtyFailed||0}),(0,A.jsx)("td",{style:{color:"#198754"},children:i})]},"".concat(e.order_id||t,"-").concat(r.sku,"-").concat(r.size,"-").concat(a))}))}))})]}),function(){var e=/^BOX\d+$/,t=g.filter((function(t){return e.test(t.sku)&&t.quantity>0}));return 0===t.length?null:(0,A.jsxs)("div",{className:"mt-3",children:[(0,A.jsx)("h6",{className:"text-primary",children:"H\u1ed9p g\u1ed7 c\u1ea7n xu\u1ea5t th\xeam:"}),(0,A.jsxs)(w.Z,{bordered:!0,hover:!0,size:"sm",className:"mt-2",children:[(0,A.jsx)("thead",{children:(0,A.jsxs)("tr",{children:[(0,A.jsx)("th",{children:"STT"}),(0,A.jsx)("th",{children:"SKU"}),(0,A.jsx)("th",{children:"Size"}),(0,A.jsx)("th",{children:"SL"})]})}),(0,A.jsx)("tbody",{children:t.map((function(e,t){return(0,A.jsxs)("tr",{children:[(0,A.jsx)("td",{children:t+1}),(0,A.jsx)("td",{children:(0,ce.G)(e.sku)}),(0,A.jsx)("td",{children:e.size}),(0,A.jsx)("td",{children:e.quantity})]},t)}))})]})]})}()]})]})}),(0,A.jsxs)(Z.Z.Footer,{children:[(0,A.jsx)(N.Z,{variant:"secondary",onClick:r,children:"H\u1ee7y"}),(0,A.jsx)(N.Z,{variant:"success",onClick:f,children:m?"\u0110ang l\u01b0u...":"L\u01b0u"})]})]})},he=function(e){if(!e)return null;var t=e,r=String(t.getDate()).padStart(2,"0"),n=String(t.getMonth()+1).padStart(2,"0"),a=t.getFullYear(),i=String(t.getHours()).padStart(2,"0"),o=String(t.getMinutes()).padStart(2,"0");return"".concat(r,"/").concat(n,"/").concat(a," ").concat(i,":").concat(o)},pe=function(e){var t,r,n=e.show,a=e.onClose,i=e.isAddingListing,o=e.editMode,l=e.targetPage,s=e.isSimpleOrder,d=e.enablePetArtMode,c=void 0!==d&&d,u=e.onUpdateCost,h=e.currentOrder,p=e.currentListing,g=e.editForm,f=e.products,x=void 0===f?[]:f,_=e.productOptionsForListingModal,v=void 0===_?[]:_,S=e.creatingOrderAlbum,b=void 0!==S&&S,C=e.formatOrderIdToHuman,O=e.formatMonthlyIdToHuman,w=e.renderPriorityOption,F=e.resolveAddedReasonSelectValue,E=e.getOrderListAddedReasonSelectRows,L=e.onFormChange,I=e.onSelectProduct,k=e.onShowListingImage,P=e.onDeleteListing,R=e.onDeleteOrder,D=e.onSubmit,M=e.onOpenOrderCustomAlbum,H=e.onCreateOrderCustomAlbum,z=e.useProductTypeFilterForNewOrder,U=e.newOrderProductTypeFilter,B=e.onProductTypeFilterChange,Y=e.productTypeMetaForNewOrder,X=e.newOrderBf,V=e.onBundleFilterChange,W=e.bundleFilterLabels,q=e.bundleProductPickerOn,K=e.showOrderIdInput,Q=void 0!==K&&K;return(0,A.jsxs)(Z.Z,{show:n,onHide:a,size:"lg",children:[(0,A.jsx)(Z.Z.Header,{closeButton:!0,children:(0,A.jsxs)(Z.Z.Title,{children:[i?"Th\xeam listing cho order [".concat(null!==h&&void 0!==h&&h.monthly_id?O(h.monthly_id):"-","]"):(0,G.R6)(G.Nx.TEXT_EDIT_LISTING_ORDER_NOTE),h&&!i&&(0,A.jsxs)("span",{className:"ms-2 text-muted",children:["[",h.monthly_id?O(h.monthly_id):"-","] ",C(h.order_id)]})]})}),(0,A.jsx)(Z.Z.Body,{children:(0,A.jsxs)(T.Z,{children:[("listing"===o||i)&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("h5",{children:(0,G.R6)(G.Nx.TEXT_LISTING_DETAILS)}),i&&(0,A.jsx)(j.Z,{className:"mb-3",children:(0,A.jsx)(y.Z,{md:6,children:(0,A.jsx)(T.Z.Group,{children:(0,A.jsx)(te,{useProductTypeFilter:z,productTypeFilterValue:U||"all",onProductTypeChange:B,productTypeMeta:Y,bundleFilterValue:X,onBundleFilterChange:V,bundleFilterLabels:W,bundleProductPickerOn:q})})})}),(0,A.jsxs)(j.Z,{className:"align-items-center",children:[(0,A.jsxs)(y.Z,{md:7,children:[(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsx)(T.Z.Label,{children:"Ch\u1ecdn s\u1ea3n ph\u1ea9m"}),(0,A.jsx)($.ZP,{value:v.find((function(e){return e.value===(p&&p.product_code)}))||null,onChange:function(e){if(e){var t=x.find((function(t){return t.product_code===e.value}));t&&I&&I(t)}else I&&I(null)},options:v,isClearable:!0,isSearchable:!0,placeholder:"Ch\u1ecdn s\u1ea3n ph\u1ea9m (product_code)...",noOptionsMessage:function(){return"Kh\xf4ng t\xecm th\u1ea5y s\u1ea3n ph\u1ea9m"},formatOptionLabel:function(e){return(0,A.jsxs)("div",{style:{display:"flex",alignItems:"center"},children:[e.img_url&&(0,A.jsx)("img",{src:e.img_url,alt:"",style:{width:32,height:32,marginRight:8,objectFit:"cover",borderRadius:4}}),(0,A.jsxs)("div",{children:[(0,A.jsx)("div",{children:e.label}),(0,A.jsxs)("small",{className:"text-muted",children:["SKU: ",(0,ce.G)(e.sku_code)," - Size: ",e.size]})]})]})}})]}),(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsx)(T.Z.Label,{children:(0,G.R6)(G.Nx.TEXT_PRODUCT_NAME)}),(0,A.jsx)(T.Z.Control,{type:"text",name:"title",value:g.title,onChange:L,readOnly:!0})]}),(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsx)(T.Z.Label,{children:"S\u1ed1 l\u01b0\u1ee3ng"}),(0,A.jsx)(T.Z.Control,{type:"text",inputMode:"numeric",name:"quantity",value:g.quantity,onChange:L})]})]}),(0,A.jsx)(y.Z,{md:5,className:"text-center",children:p&&p.img_url&&(0,A.jsx)("img",{src:null===(t=p.img_url)||void 0===t?void 0:t.replace("75x75","180x180"),alt:g.title,title:"Xem \u1ea3nh l\u1edbn",role:"button",tabIndex:0,onClick:function(){return k&&k((0,m.Z)((0,m.Z)({},p),{},{title:g.title||p.title}))},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),k&&k((0,m.Z)((0,m.Z)({},p),{},{title:g.title||p.title})))},style:{width:180,height:180,objectFit:"cover",border:"1px solid #eee",borderRadius:6,marginTop:8,cursor:"pointer"}})})]})]}),"order"===o&&!i&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)("div",{className:"d-flex justify-content-between align-items-center mb-2",children:[(0,A.jsx)("h5",{className:"mb-0",children:(0,G.R6)(G.Nx.TEXT_CUSTOMER_INFO)}),null!==h&&void 0!==h&&null!==(r=h.metadata)&&void 0!==r&&r.order_custom_album?(0,A.jsx)(N.Z,{variant:"outline-primary",size:"sm",onClick:function(){return M&&M(h)},children:"View Custom Album"}):(0,A.jsx)(N.Z,{variant:"outline-primary",size:"sm",onClick:H,disabled:b,children:b?"Creating...":"Upload Files"})]}),Q&&(0,A.jsx)(j.Z,{children:(0,A.jsx)(y.Z,{md:6,children:(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsx)(T.Z.Label,{children:"Order ID"}),(0,A.jsx)(T.Z.Control,{type:"text",name:"order_id",value:g.order_id||"",onChange:L})]})})}),!s&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(j.Z,{children:[(0,A.jsx)(y.Z,{md:6,children:(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsx)(T.Z.Label,{children:(0,G.R6)(G.Nx.TEXT_CUSTOMER)}),(0,A.jsx)(T.Z.Control,{type:"text",name:"customer_name",value:g.customer_name,onChange:L})]})}),(0,A.jsx)(y.Z,{md:6,children:(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsx)(T.Z.Label,{children:(0,G.R6)(G.Nx.TEXT_EMAIL)}),(0,A.jsx)(T.Z.Control,{type:"email",name:"email",value:g.email,onChange:L})]})})]}),(0,A.jsxs)(j.Z,{children:[(0,A.jsx)(y.Z,{md:6,children:(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsx)(T.Z.Label,{children:(0,G.R6)(G.Nx.TEXT_IOSS)}),(0,A.jsx)(T.Z.Control,{type:"text",name:"ioss",value:g.ioss||"",onChange:L,placeholder:"Enter IOSS number..."})]})}),(0,A.jsx)(y.Z,{md:6,children:(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsx)(T.Z.Label,{children:(0,G.R6)(G.Nx.TEXT_SHIPPING_ADDRESS)}),(0,A.jsx)(T.Z.Control,{as:"textarea",rows:6,name:"shipping_address",value:g.shipping_address,onChange:L})]})})]})]}),(0,A.jsxs)(j.Z,{children:[(0,A.jsx)(y.Z,{md:6,children:(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsx)(T.Z.Label,{children:(0,G.R6)(G.Nx.TEXT_ORDER_DATE)}),(0,A.jsx)("div",{className:"react-datepicker-container-custom",children:(0,A.jsx)(ee.ZP,{selected:g.order_date,onChange:function(e){return L({target:{name:"order_date",value:e}})},dateFormat:"dd/MM/yyyy",className:"form-control",placeholderText:"Ch\u1ecdn ng\xe0y \u0111\u1eb7t h\xe0ng...",maxDate:new Date})})]})}),(0,A.jsx)(y.Z,{md:6,children:(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsx)(T.Z.Label,{children:(0,G.R6)(G.Nx.TEXT_PRIORITY)}),(0,A.jsx)(T.Z.Select,{name:"priority",value:g.priority,onChange:L,children:[1,2,3,4].map((function(e){return(0,A.jsx)("option",{value:e,children:w(e).props.children[1].props.children},e)}))})]})})]}),(0,A.jsxs)(j.Z,{children:[(0,A.jsx)(y.Z,{md:6,children:(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsx)(T.Z.Label,{children:(0,G.R6)(G.Nx.TEXT_ADDED_REASON)}),(0,A.jsx)(T.Z.Select,{name:"added_reason",value:F(g.added_reason||"ETSY_NEW_ORDER",!0),onChange:L,children:E(g.added_reason||"ETSY_NEW_ORDER",!0).map((function(e){return(0,A.jsx)("option",{value:e.value,children:e.label},e.value)}))})]})}),(0,A.jsx)(y.Z,{md:6,children:(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsxs)(T.Z.Label,{children:["Deadline fulfill (gi\u1edd)",g.deadline_fulfill_hours&&(null===h||void 0===h?void 0:h.start_fulfill)&&function(){var e=function(e){if(null===e||void 0===e||!e.start_fulfill||null===e||void 0===e||!e.deadline_fulfill_hours)return null;var t=parseFloat(e.deadline_fulfill_hours);return isNaN(t)||t<=0?null:new Date(new Date(e.start_fulfill).getTime()+36e5*t)}({start_fulfill:h.start_fulfill,deadline_fulfill_hours:g.deadline_fulfill_hours});return e?(0,A.jsxs)("span",{style:{fontWeight:400,fontSize:12,color:"#0d6efd",marginLeft:8},children:["\u2192 ",he(e)]}):null}()]}),(0,A.jsx)(T.Z.Control,{type:"number",name:"deadline_fulfill_hours",value:g.deadline_fulfill_hours,onChange:L,placeholder:"VD: 1.5 (gi\u1edd)",min:"0",step:"0.5"})]})})]}),(0,A.jsx)("hr",{}),(0,A.jsx)("h5",{children:(0,G.R6)(G.Nx.TEXT_ORDER_NOTES)}),(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsx)(T.Z.Label,{children:(0,G.R6)(G.Nx.TEXT_BUYER_NOTE)}),(0,A.jsx)(T.Z.Control,{as:"textarea",rows:3,name:"buyer_note",value:g.buyer_note,onChange:L})]}),(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsx)(T.Z.Label,{children:(0,G.R6)(G.Nx.TEXT_SELLER_NOTE)}),(0,A.jsx)(T.Z.Control,{as:"textarea",rows:3,name:"seller_note",value:g.seller_note,onChange:L})]})]})]})}),(0,A.jsx)(Z.Z.Footer,{className:"justify-content-between",children:(0,A.jsxs)("div",{className:"d-flex w-100 justify-content-between align-items-center",children:[!i&&"listing"===o&&(0,A.jsx)("div",{children:(0,A.jsx)(N.Z,{variant:"danger",onClick:P,children:"Xo\xe1 Listing"})}),!i&&"order"===o&&(0,A.jsxs)("div",{className:"d-flex gap-2",children:[(0,A.jsx)(N.Z,{variant:"danger",onClick:R,children:"Xo\xe1 \u0111\u01a1n"}),c&&h&&(0,A.jsx)(N.Z,{variant:"warning",onClick:function(){return u&&u(h)},children:"\ud83d\udcb0 Update Cost"})]}),(0,A.jsxs)("div",{children:[(0,A.jsx)(N.Z,{variant:"secondary",onClick:a,className:"me-2",children:(0,G.R6)(G.Nx.TEXT_CANCEL)}),"sale"===l&&(0,A.jsx)(N.Z,{variant:"primary",onClick:D,children:(0,G.R6)(G.Nx.TEXT_SAVE_CHANGES)})]})]})})]})},ge=function(e){var t=e.show,r=e.current,n=void 0===r?0:r,a=e.total,i=void 0===a?0:a,o=e.progress,l=void 0===o?0:o;return(0,A.jsxs)(Z.Z,{show:t,onHide:function(){},backdrop:"static",keyboard:!1,centered:!0,children:[(0,A.jsx)(Z.Z.Header,{children:(0,A.jsx)(Z.Z.Title,{children:"Auto Fulfill \u0111ang x\u1eed l\xfd..."})}),(0,A.jsx)(Z.Z.Body,{children:(0,A.jsxs)("div",{className:"text-center",children:[(0,A.jsx)("div",{className:"mb-3",children:(0,A.jsxs)("strong",{children:["\u0110ang x\u1eed l\xfd: ",n," / ",i," \u0111\u01a1n h\xe0ng (",l,"%)"]})}),(0,A.jsx)("div",{className:"progress",style:{height:"30px"},children:(0,A.jsxs)("div",{className:"progress-bar progress-bar-striped progress-bar-animated",role:"progressbar",style:{width:"".concat(l,"%")}
1,"aria-valuenow":l,"aria-valuemin":"0","aria-valuemax":"100",children:[l,"%"]})}),(0,A.jsx)("div",{className:"mt-3 text-muted",children:"Vui l\xf2ng \u0111\u1ee3i trong khi h\u1ec7 th\u1ed1ng \u0111ang x\u1eed l\xfd..."})]})})]})},me=function(e){var t=e.show,r=e.noteValue,n=e.onNoteChange,a=e.onClose,i=e.onSubmit;return(0,A.jsxs)(Z.Z,{show:t,onHide:a,children:[(0,A.jsx)(Z.Z.Header,{closeButton:!0,children:(0,A.jsx)(Z.Z.Title,{children:"Ho\xe0n th\xe0nh \u0111\u01a1n custom"})}),(0,A.jsx)(Z.Z.Body,{children:(0,A.jsx)(T.Z,{children:(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsx)(T.Z.Label,{children:"Ghi ch\xfa RnD"}),(0,A.jsx)(T.Z.Control,{as:"textarea",rows:3,value:r,onChange:n,placeholder:"Nh\u1eadp ghi ch\xfa cho RnD..."})]})})}),(0,A.jsxs)(Z.Z.Footer,{children:[(0,A.jsx)(N.Z,{variant:"secondary",onClick:a,children:"\u0110\xf3ng"}),(0,A.jsx)(N.Z,{variant:"success",onClick:i,children:"X\xe1c nh\u1eadn ho\xe0n th\xe0nh"})]})]})},fe=function(e){var t=e.show,r=e.startDate,n=e.endDate,a=e.onDateRangeChange,i=e.onClose,o=e.onApply;return(0,A.jsxs)(Z.Z,{show:t,onHide:i,centered:!0,size:"md",children:[(0,A.jsx)(Z.Z.Header,{closeButton:!0,children:(0,A.jsx)(Z.Z.Title,{children:"Ch\u1ecdn kho\u1ea3ng th\u1eddi gian"})}),(0,A.jsx)(Z.Z.Body,{children:(0,A.jsxs)("div",{className:"text-center",children:[(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsx)(T.Z.Label,{children:"T\u1eeb ng\xe0y - \u0110\u1ebfn ng\xe0y:"}),(0,A.jsx)("div",{className:"d-flex justify-content-center",children:(0,A.jsx)(ee.ZP,{selected:r,onChange:a,startDate:r,endDate:n,selectsRange:!0,inline:!0,dateFormat:"dd/MM/yyyy",maxDate:new Date,popperClassName:"date-picker-popper"})})]}),(0,A.jsx)("div",{className:"text-muted small mb-3",children:r&&n&&(0,A.jsxs)(A.Fragment,{children:["\u0110\xe3 ch\u1ecdn: ",V()(r).format("DD/MM/YYYY")," - ",V()(n).format("DD/MM/YYYY"),(0,A.jsx)("br",{}),"(",V()(n).diff(V()(r),"days")+1," ng\xe0y)"]})})]})}),(0,A.jsxs)(Z.Z.Footer,{children:[(0,A.jsx)(N.Z,{variant:"secondary",onClick:i,children:"H\u1ee7y"}),(0,A.jsx)(N.Z,{variant:"primary",onClick:o,disabled:!r||!n,children:"\xc1p d\u1ee5ng"})]})]})},xe=r(52580),_e=function(e){return String(e||"").replace(/^\d{6}_/,"")},ve=function(e){return String(e||"").split(",").map((function(e){return parseInt(e.trim(),10)})).filter((function(e){return!isNaN(e)&&e>=1}))},ye=function(e){var t=e.show,r=e.onClose,n=e.target,a=e.mode,i=e.qty,o=e.loading,l=e.parentCode,s=e.onParentChange,d=e.onModeChange,c=e.onQtyChange,u=e.onSplitSubmit,h=e.onIncreaseSubmit,p=e.formatOrderIdToHuman,g=!(null===n||void 0===n||!n.parentProducts),m=g?n.parentProducts.find((function(e){return e.product_code===l}))||n.parentProducts[0]:null,f=parseInt(i,10),x=!(null===n||void 0===n||!n.listings),_=n?p(n.order_id)||n.order_id:"",v=n?g?(null===m||void 0===m?void 0:m.quantity)||0:x?n.gcd:n.quantity:0,y=(0,A.jsx)("div",{style:{display:"flex",gap:8,marginBottom:16},children:["split","increase"].map((function(e){return(0,A.jsx)("button",{onClick:function(){return d&&d(e)},style:{padding:"6px 18px",borderRadius:6,border:"1px solid",borderColor:a===e?"#0d6efd":"#dee2e6",background:a===e?"#0d6efd":"#fff",color:a===e?"#fff":"#495057",fontWeight:a===e?600:400,cursor:"pointer",fontSize:13},children:"split"===e?"\u2702 Chia":"\u21c5 \u0110i\u1ec1u ch\u1ec9nh"},e)}))}),S=n&&(0,A.jsxs)("p",{className:"text-muted mb-3",style:{fontSize:13},children:["\u0110\u01a1n ",(0,A.jsx)("strong",{children:_}),g&&m?(0,A.jsxs)(A.Fragment,{children:[" \u2014 B\u1ed9 ",(0,A.jsx)("strong",{children:_e(m.product_code)}),": ",(0,A.jsx)("strong",{children:v})," b\u1ed9"]}):(0,A.jsxs)(A.Fragment,{children:[" \u2014 S\u1ed1 b\u1ed9 hi\u1ec7n t\u1ea1i: ",(0,A.jsx)("strong",{children:v})]})]}),b=g&&(0,A.jsx)("div",{style:{display:"flex",gap:8,marginBottom:12,flexWrap:"wrap"},children:n.parentProducts.map((function(e){var t=_e(e.product_code),r=(null===m||void 0===m?void 0:m.product_code)===e.product_code;return(0,A.jsxs)("button",{onClick:function(){return s&&s(e.product_code)},style:{padding:"6px 14px",borderRadius:6,border:"1px solid",borderColor:r?"#0d6efd":"#dee2e6",background:r?"#e7f1ff":"#fff",color:r?"#0d6efd":"#495057",fontWeight:r?700:500,fontSize:13,cursor:"pointer"},children:[t," ",(0,A.jsxs)("span",{style:{color:"#6c757d",fontWeight:400},children:["(",e.quantity," b\u1ed9)"]})]},e.product_code)}))}),C=o,j=null,O="",w="#0d6efd";if(n)if("split"===a){if(g){var F=ve(i),E=F.reduce((function(e,t){return e+t}),0);C=C||!m||0===F.length||E<1||E>=v}else{var L=parseInt(i,10),I=n.listings?L<n.gcd:L<(n.quantity||0);C=C||isNaN(L)||L<1||!I}j=u,O=o?"\u0110ang x\u1eed l\xfd...":"T\xe1ch \u0111\u01a1n",w="#0d6efd"}else{var k=parseInt(i,10);if(g)C=C||isNaN(k)||k<1||k===v;else{var P=n.listings?n.gcd:n.quantity||1;C=C||isNaN(k)||k<=P}j=h,O=o?"\u0110ang x\u1eed l\xfd...":"\u0110i\u1ec1u ch\u1ec9nh",w="#198754"}return(0,A.jsxs)(Z.Z,{show:t,onHide:function(){return!o&&r&&r()},children:[(0,A.jsx)(Z.Z.Header,{closeButton:!0,children:(0,A.jsxs)(Z.Z.Title,{children:[(0,A.jsx)(xe.RDp,{className:"me-2"}),"\u0110i\u1ec1u ch\u1ec9nh s\u1ed1 l\u01b0\u1ee3ng"]})}),(0,A.jsx)(Z.Z.Body,{children:function(){if(!n)return null;if(g)return function(){if(!m)return null;if("split"===a){var e=ve(i),t=e.reduce((function(e,t){return e+t}),0),r=e.length>0&&t>=1&&t<v,n=v-t;return(0,A.jsxs)(A.Fragment,{children:[y,S,b,(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsxs)(T.Z.Label,{children:["S\u1ed1 b\u1ed9 t\xe1ch ra (vd: ",(0,A.jsx)("code",{children:"1, 1, 2"}),") \u2014 t\u1ed5ng < ",v]}),(0,A.jsx)(T.Z.Control,{type:"text",value:i,onChange:function(e){return c&&c(e.target.value)},placeholder:"vd: 1, 1, 2",autoFocus:!0})]}),r&&(0,A.jsxs)(T.Z.Text,{className:"text-muted",children:["\u2192 Order g\u1ed1c gi\u1eef ",(0,A.jsxs)("strong",{children:[n," b\u1ed9"]}),"; t\u1ea1o ",(0,A.jsx)("strong",{children:e.length})," order m\u1edbi: ",e.map((function(t,r){return(0,A.jsxs)("span",{style:{color:"#198754",fontWeight:700},children:[t,r<e.length-1?", ":""]},r)}))," b\u1ed9."]})]})}var o=!isNaN(f)&&f>=1&&f!==v,l=o?f-v:0,s=l>0?"#198754":l<0?"#dc2626":"#6c757d";return(0,A.jsxs)(A.Fragment,{children:[y,S,b,(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsxs)(T.Z.Label,{children:["S\u1ed1 b\u1ed9 m\u1edbi (\u2265 1, kh\xe1c ",v,")"]}),(0,A.jsx)(T.Z.Control,{type:"text",inputMode:"numeric",value:i,onChange:function(e){return c&&c(e.target.value)},placeholder:"vd: ".concat(Math.max(1,v+1)),autoFocus:!0})]}),o&&(0,A.jsxs)("table",{style:{width:"100%",fontSize:13,borderCollapse:"collapse"},children:[(0,A.jsx)("thead",{children:(0,A.jsxs)("tr",{style:{background:"#f8f9fa"},children:[(0,A.jsx)("th",{style:{padding:"4px 8px",textAlign:"left"},children:"Listing con"}),(0,A.jsx)("th",{style:{padding:"4px 8px",textAlign:"center"},children:"Thay \u0111\u1ed5i"})]})}),(0,A.jsx)("tbody",{children:(m.child_products||[]).map((function(e,t){var r=l*(e.quantity||1);return(0,A.jsxs)("tr",{style:{borderTop:"1px solid #dee2e6"},children:[(0,A.jsx)("td",{style:{padding:"4px 8px"},children:_e(e.product_code)}),(0,A.jsx)("td",{style:{padding:"4px 8px",textAlign:"center",color:s},children:(0,A.jsx)("strong",{children:r>0?"+".concat(r):r})})]},t)}))})]})]})}();if("split"===a){var e=v-1,t=!isNaN(f)&&f>=1&&f<=e;return(0,A.jsxs)(A.Fragment,{children:[y,S,(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsxs)(T.Z.Label,{children:["S\u1ed1 b\u1ed9 cho order m\u1edbi (1 \u2013 ",e,")"]}),(0,A.jsx)(T.Z.Control,{type:"text",inputMode:"numeric",value:i,onChange:function(e){return c&&c(e.target.value)},placeholder:"1 \u2013 ".concat(e),autoFocus:!0})]}),t&&function(){if(x){var e=n.listings,t=n.gcd;return(0,A.jsxs)("table",{style:{width:"100%",fontSize:13,borderCollapse:"collapse"},children:[(0,A.jsx)("thead",{children:(0,A.jsxs)("tr",{style:{background:"#f8f9fa"},children:[(0,A.jsx)("th",{style:{padding:"4px 8px",textAlign:"left"},children:"Listing"}),(0,A.jsx)("th",{style:{padding:"4px 8px",textAlign:"center"},children:"Hi\u1ec7n t\u1ea1i"}),(0,A.jsxs)("th",{style:{padding:"4px 8px",textAlign:"center"},children:["Order g\u1ed1c (",t-f," b\u1ed9)"]}),(0,A.jsxs)("th",{style:{padding:"4px 8px",textAlign:"center"},children:["Order m\u1edbi (",f," b\u1ed9)"]})]})}),(0,A.jsx)("tbody",{children:e.map((function(e,r){var n=e.quantity/t*f,a=e.quantity-n;return(0,A.jsxs)("tr",{style:{borderTop:"1px solid #dee2e6"},children:[(0,A.jsxs)("td",{style:{padding:"4px 8px"},children:[(0,ce.G)(e.sku),e.size?"-".concat(e.size):""]}),(0,A.jsx)("td",{style:{padding:"4px 8px",textAlign:"center"},children:e.quantity}),(0,A.jsx)("td",{style:{padding:"4px 8px",textAlign:"center",color:"#0d6efd"},children:(0,A.jsx)("strong",{children:a})}),(0,A.jsx)("td",{style:{padding:"4px 8px",textAlign:"center",color:"#198754"},children:(0,A.jsx)("strong",{children:n})})]},r)}))})]})}var r=n.quantity-f;return(0,A.jsxs)(T.Z.Text,{className:"text-muted",children:["\u2192 Order g\u1ed1c: ",(0,A.jsxs)("strong",{children:[r," b\u1ed9"]})," \xa0|\xa0 Order m\u1edbi: ",(0,A.jsxs)("strong",{children:[f," b\u1ed9"]})]})}()]})}var r=!isNaN(f)&&f>v;return(0,A.jsxs)(A.Fragment,{children:[y,S,(0,A.jsxs)(T.Z.Group,{className:"mb-3",children:[(0,A.jsxs)(T.Z.Label,{children:["S\u1ed1 b\u1ed9 m\u1edbi (l\u1edbn h\u01a1n ",v,")"]}),(0,A.jsx)(T.Z.Control,{type:"text",inputMode:"numeric",value:i,onChange:function(e){return c&&c(e.target.value)},placeholder:"> ".concat(v),autoFocus:!0})]}),r&&function(){if(x){var e=n.listings,t=n.gcd;return(0,A.jsxs)("table",{style:{width:"100%",fontSize:13,borderCollapse:"collapse"},children:[(0,A.jsx)("thead",{children:(0,A.jsxs)("tr",{style:{background:"#f8f9fa"},children:[(0,A.jsx)("th",{style:{padding:"4px 8px",textAlign:"left"},children:"Listing"}),(0,A.jsx)("th",{style:{padding:"4px 8px",textAlign:"center"},children:"Hi\u1ec7n t\u1ea1i"}),(0,A.jsx)("th",{style:{padding:"4px 8px",textAlign:"center"},children:"Sau khi t\u0103ng"})]})}),(0,A.jsx)("tbody",{children:e.map((function(e,r){var n=e.quantity/t;return(0,A.jsxs)("tr",{style:{borderTop:"1px solid #dee2e6"},children:[(0,A.jsxs)("td",{style:{padding:"4px 8px"},children:[e.sku,e.size?" / ".concat(e.size):""]}),(0,A.jsx)("td",{style:{padding:"4px 8px",textAlign:"center"},children:e.quantity}),(0,A.jsx)("td",{style:{padding:"4px 8px",textAlign:"center",color:"#198754"},children:(0,A.jsx)("strong",{children:Math.round(n*f)})})]},r)}))})]})}return(0,A.jsxs)(T.Z.Text,{className:"text-muted",children:["\u2192 SL m\u1edbi: ",(0,A.jsxs)("strong",{children:[f," b\u1ed9"]})]})}()]})}()}),(0,A.jsxs)(Z.Z.Footer,{children:[(0,A.jsx)(N.Z,{variant:"secondary",onClick:r,disabled:o,children:"Hu\u1ef7"}),(0,A.jsx)("button",{type:"button",onClick:C?void 0:j,style:{color:"#fff",backgroundColor:w,border:"1px solid ".concat(w),borderRadius:4,padding:"6px 16px",fontSize:14,cursor:C?"not-allowed":"pointer",opacity:C?.55:1},children:O})]})]})},Se=function(e){var t=e.show,r=e.metadata,n=e.onClose,a=e.canEdit,i=void 0!==a&&a,d=e.onSave,c=(0,f.useState)(!1),u=(0,s.Z)(c,2),h=u[0],p=u[1],g=(0,f.useState)(""),m=(0,s.Z)(g,2),x=m[0],_=m[1],v=(0,f.useState)(!1),y=(0,s.Z)(v,2),S=y[0],b=y[1],C=function(e){return null==e?"{}":"string"===typeof e?e:JSON.stringify(e,null,2)};(0,f.useEffect)((function(){p(!1),b(!1),_(C(r))}),[r,t]);var j=function(){try{return JSON.parse(x),!0}catch(e){return!1}}(),T=function(){var e=(0,l.Z)((0,o.Z)().mark((function e(){var t;return(0,o.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.prev=0,t=JSON.parse(x),e.next=7;break;case 4:return e.prev=4,e.t0=e.catch(0),e.abrupt("return");case 7:return b(!0),e.prev=8,e.next=11,null===d||void 0===d?void 0:d(t);case 11:p(!1),e.next=16;break;case 14:e.prev=14,e.t1=e.catch(8);case 16:return e.prev=16,b(!1),e.finish(16);case 19:case"end":return e.stop()}}),e,null,[[0,4],[8,14,16,19]])})));return function(){return e.apply(this,arguments)}}();return(0,A.jsxs)(Z.Z,{show:t,onHide:n,size:"lg",children:[(0,A.jsx)(Z.Z.Header,{closeButton:!0,children:(0,A.jsx)(Z.Z.Title,{children:"Metadata"})}),(0,A.jsx)(Z.Z.Body,{children:h?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("textarea",{value:x,onChange:function(e){return _(e.target.value)},rows:18,spellCheck:!1,style:{width:"100%",fontFamily:"monospace",fontSize:12,padding:10,border:"1px solid ".concat(j?"#dee2e6":"#dc3545"),borderRadius:6,resize:"vertical"}}),!j&&(0,A.jsx)("div",{style:{fontSize:12,color:"#dc3545",marginTop:4},children:"\u26a0\ufe0f JSON kh\xf4ng h\u1ee3p l\u1ec7"})]}):r?(0,A.jsx)("pre",{style:{backgroundColor:"#f5f5f5",padding:"15px",borderRadius:"5px",overflow:"auto",maxHeight:"500px",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:"string"===typeof r?r:JSON.stringify(r,null,2)}):(0,A.jsx)("p",{children:"Kh\xf4ng c\xf3 metadata"})}),(0,A.jsxs)(Z.Z.Footer,{children:[i&&!h&&(0,A.jsx)(N.Z,{variant:"outline-primary",onClick:function(){_(C(r)),p(!0)},children:"\u270f\ufe0f Ch\u1ec9nh s\u1eeda"}),h&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(N.Z,{variant:"primary",onClick:T,disabled:!j||S,children:S?"\u0110ang l\u01b0u...":"L\u01b0u"}),(0,A.jsx)(N.Z,{variant:"light",onClick:function(){return p(!1)},disabled:S,children:"Hu\u1ef7"})]}),(0,A.jsx)(N.Z,{variant:"secondary",onClick:n,children:"\u0110\xf3ng"})]})]})},be=r(87650),Ce=r(14817),je=function(e){var t=e.data,n=e.companyName,a=e.useMonthlyCode,i=e.formatOrderIdToHuman,d=e.formatMonthlyIdToHuman,c=e.onClose,u=e.onRecreate;if(!t)return null;var h=t.order,p=t.loading,g=t.shortUrl,m=i(h.order_id)||h.order_id,f=h.monthly_id?d(h.monthly_id):null,x=a&&f?f:m,_=Array.isArray(h.listings)?h.listings:[],v="order-list-label-".concat(h.order_id),y=function(){var e=(0,l.Z)((0,o.Z)().mark((function e(){var t,n,a,i,l,d,c,u,h;return(0,o.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=document.getElementById(v)){e.next=3;break}return e.abrupt("return");case 3:return n=t.style.transform,a=t.style.border,t.style.transform="none",t.style.border="none",e.prev=7,e.next=10,Promise.all([r.e(8105).then(r.t.bind(r,58105,23)),r.e(2507).then(r.bind(r,62507))]);case 10:return i=e.sent,l=(0,s.Z)(i,2),d=l[0].default,c=l[1].default,e.next=16,d(t,{scale:4,useCORS:!0,backgroundColor:"#ffffff",logging:!1});case 16:u=e.sent,(h=new c({orientation:"landscape",unit:"mm",format:[100,60]})).addImage(u.toDataURL("image/png"),"PNG",0,0,100,60),h.save("label-".concat(x,".pdf"));case 20:return e.prev=20,t.style.transform=n,t.style.border=a,e.finish(20);case 24:case"end":return e.stop()}}),e,null,[[7,,20,24]])})));return function(){return e.apply(this,arguments)}}();return be.createPortal((0,A.jsx)("div",{onClick:c,style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:99999},children:(0,A.jsxs)("div",{onClick:function(e){return e.stopPropagation()},style:{background:"#fff",borderRadius:12,padding:24,minWidth:320,boxShadow:"0 8px 32px rgba(0,0,0,0.18)"},children:[(0,A.jsxs)("div",{style:{fontWeight:700,fontSize:15,marginBottom:16,display:"flex",alignItems:"center",gap:8},children:[(0,A.jsx)(xe.rcQ,{})," Xem tr\u01b0\u1edbc nh\xe3n (30\xd750mm)",p?(0,A.jsx)(O.Z,{animation:"border",size:"sm"}):(0,A.jsx)("button",{title:"T\u1ea1o l\u1ea1i short URL & c\u1eadp nh\u1eadt metadata",onClick:u,style:{background:"none",border:"none",cursor:"pointer",padding:0,color:"#6c757d",display:"flex",alignItems:"center"},children:(0,A.jsx)(xe.lbL,{size:14})})]}),(0,A.jsx)("div",{style:{width:"calc(50mm * 2)",height:"calc(30mm * 2)",position:"relative",overflow:"hidden",opacity:p?.5:1},children:(0,A.jsxs)("div",{id:v,style:{border:"1px dashed #999",width:"50mm",height:"30mm",padding:"2mm",display:"flex",alignItems:"center",gap:"3mm",boxSizing:"border-box",background:"#fff",transform:"scale(2)",transformOrigin:"top left"},children:[(0,A.jsx)("div",{style:{flexShrink:0},children:g?(0,A.jsx)(Ce.t,{value:g,size:80}):(0,A.jsx)("div",{style:{width:80,height:80,background:"#f0f0f0",display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,
1color:"#999"},children:"QR"})}),(0,A.jsxs)("div",{style:{flex:1,minWidth:0},children:[n&&(0,A.jsx)("div",{style:{fontFamily:"sans-serif",fontSize:11,color:"#444",fontWeight:600,lineHeight:1.3,marginBottom:2},children:n}),(0,A.jsx)("div",{style:{fontFamily:"monospace",fontSize:12,fontWeight:700,lineHeight:1.3,marginBottom:2},children:x}),_.map((function(e,t){var r;return(0,A.jsxs)("div",{style:{fontFamily:"monospace",fontSize:9,color:"#333",lineHeight:1.4},children:[(0,ce.G)(e.sku),e.size?"-".concat(e.size):""," x ",null!==(r=e.quantity)&&void 0!==r?r:1]},t)}))]})]})}),(0,A.jsxs)("div",{style:{display:"flex",gap:8,marginTop:16,justifyContent:"flex-end"},children:[(0,A.jsxs)(N.Z,{variant:"primary",size:"sm",disabled:p||!g,onClick:y,children:[(0,A.jsx)(xe.rcQ,{className:"me-1"}),"Xu\u1ea5t PDF"]}),(0,A.jsx)(N.Z,{variant:"secondary",size:"sm",onClick:c,children:"\u0110\xf3ng"})]})]})}),document.body)},Te=r(48357),Oe=r(96495),we=r(40668),Fe=function(e){var t=e.show,r=e.onClose,n=e.order,a=e.logs,o=void 0===a?[]:a,l=e.pagination,s=void 0===l?{currentPage:1,totalPages:1,totalCount:0}:l,d=e.isShowLatest,c=e.logLevelFilter,u=e.onToggleLatest,h=e.onLogLevelChange,p=e.onReload,g=e.onPageChange,m=e.orderStatusConfig,f=e.formatOrderIdToHuman,x=e.formatMonthlyIdToHuman,_=e.getShopDisplayName,y=e.getOrderStatusDisplayLabel,S=function(e){if(null==e)return"";var t,r=null;m&&Array.isArray(m)&&(r="string"===typeof e?e:null===(t=m.find((function(t){return t.code===e})))||void 0===t?void 0:t.enum);return r?"[".concat(e,"] ").concat(y(r)):"[".concat(e,"] Unknown")};return(0,A.jsxs)(Te.Z,{isOpen:t,toggle:r,size:"xl",className:"modal-order-logs",style:{maxWidth:"90vw",width:"90vw",margin:"0 auto",zIndex:1050},centered:!0,children:[(0,A.jsx)(Oe.Z,{toggle:r,children:(0,A.jsxs)("strong",{children:["Order Logs - ",null!==n&&void 0!==n&&n.monthly_id?x(n.monthly_id):f(null===n||void 0===n?void 0:n.order_id)]})}),(0,A.jsxs)(we.Z,{children:[(0,A.jsxs)("div",{className:"d-flex align-items-center justify-content-between mb-3 flex-wrap",style:{gap:16},children:[(0,A.jsxs)("div",{className:"d-flex align-items-center flex-nowrap",style:{gap:16},children:[(0,A.jsx)(T.Z.Check,{type:"switch",label:"Latest Log",checked:d,onChange:u,style:{marginBottom:0,width:200}}),(0,A.jsxs)(T.Z.Select,{size:"sm",value:c,onChange:function(e){return h&&h(e.target.value)},style:{minWidth:120},children:[(0,A.jsx)("option",{value:"ALL",children:"T\u1ea5t c\u1ea3"}),(0,A.jsx)("option",{value:"1",children:"Level 1"}),(0,A.jsx)("option",{value:"2",children:"Level 2"}),(0,A.jsx)("option",{value:"3",children:"Level 3"}),(0,A.jsx)("option",{value:"4",children:"Level 4"})]})]}),(0,A.jsxs)("div",{className:"d-flex align-items-center",style:{gap:12},children:[(0,A.jsxs)("span",{className:"text-muted",style:{whiteSpace:"nowrap"},children:["Total Logs: ",s.totalCount]}),(0,A.jsx)(N.Z,{className:"btn-fill btn-sm",variant:"primary",onClick:p,children:"Reload"})]})]}),n&&(0,A.jsxs)("div",{className:"text-white mb-4",children:[(0,A.jsxs)(v.Z,{pill:!0,bg:"primary",children:["Order ID: ",f(n.order_id)]}),(0,A.jsxs)(v.Z,{pill:!0,bg:"primary",className:"ms-2",children:["Shop: ",_(n.shop_name)]}),(0,A.jsxs)(v.Z,{pill:!0,bg:"primary",className:"ms-2",children:["Status: ",S(n.status)]}),(0,A.jsxs)(v.Z,{pill:!0,bg:"primary",className:"ms-2",children:["Created: ",V()(n.order_date).format("YYYY/MM/DD HH:mm:ss")]})]}),(0,A.jsx)("div",{className:"modal-order-logs-list",style:{maxHeight:"60vh",overflowY:"auto"},children:o.length>0?(0,A.jsxs)(w.Z,{bordered:!0,hover:!0,size:"sm",children:[(0,A.jsx)("thead",{children:(0,A.jsxs)("tr",{children:[(0,A.jsx)("th",{children:"Time"}),(0,A.jsx)("th",{children:"Team"}),(0,A.jsx)("th",{children:"User"}),(0,A.jsx)("th",{children:"Status"}),(0,A.jsx)("th",{children:"Message"})]})}),(0,A.jsx)("tbody",{children:function(){var e=o.filter((function(e){return!d||o.indexOf(e)>=o.length-100})).filter((function(e){return"ALL"===c||String(e.level)===c}));return(e=d?(0,i.Z)(e).sort((function(e,t){return new Date(t.time)-new Date(e.time)})):(0,i.Z)(e).sort((function(e,t){return new Date(e.time)-new Date(t.time)}))).map((function(e){var t={};return 1===e.level?t={background:"#ffe5e5",color:"#b30000",fontWeight:"bold"}:2===e.level?t={background:"#fff5e5",color:"#b36b00",fontWeight:"bold"}:3===e.level?t={background:"#e5f0ff",color:"#005cb3"}:4===e.level&&(t={background:"#f2f2f2",color:"#666"}),(0,A.jsxs)("tr",{style:t,children:[(0,A.jsx)("td",{style:{whiteSpace:"nowrap"},children:V()(e.time).format("YYYY/MM/DD HH:mm:ss")}),(0,A.jsx)("td",{children:e.perform_by_team||"-"}),(0,A.jsx)("td",{children:e.perform_by_user||"-"}),(0,A.jsx)("td",{children:void 0!==e.status?S(e.status):""}),(0,A.jsx)("td",{style:{fontStyle:9===e.level?"italic":"normal",fontWeight:1===e.level?"bold":"normal"},children:e.message})]},e._id)}))}()})]}):(0,A.jsxs)("div",{className:"text-center",children:[(0,A.jsx)(O.Z,{animation:"border",variant:"primary"}),(0,A.jsx)("span",{className:"ms-2",children:"Loading logs..."})]})}),s.totalPages>1&&(0,A.jsx)("div",{className:"d-flex justify-content-center mt-3",children:(0,A.jsxs)("div",{className:"d-flex align-items-center",children:[(0,A.jsx)(N.Z,{variant:"outline-primary",className:"me-2",disabled:1===s.currentPage,onClick:function(){return g&&g(s.currentPage-1)},children:(0,G.R6)(G.Nx.TEXT_PREVIOUS)}),(0,A.jsxs)("span",{className:"mx-2",children:[(0,G.R6)(G.Nx.TEXT_PAGE)," ",s.currentPage," / ",s.totalPages]}),(0,A.jsx)(N.Z,{variant:"outline-primary",className:"ms-2",disabled:s.currentPage===s.totalPages,onClick:function(){return g&&g(s.currentPage+1)},children:(0,G.R6)(G.Nx.TEXT_NEXT)})]})})]})]})},Ne=r(69090),Ee=r(39394),Le=r(90005),Ie=r(46682),Ze=r(54467),ke={M:1,L:2,XL:3,XXL:4},Pe=function(e){return e.filter((function(e){return e.listings.length>0&&e.listings.every((function(e){return 1===e.available||2===e.available}))}))},Re=function(e){return(0,i.Z)(e).sort((function(e,t){return e.sku===t.sku?(ke[e.
1size]||0)-(ke[t.size]||0):e.sku.localeCompare(t.sku)}))},Ae=function(e){var t=e.orders,r=e.helpers,n=r.formatOrderIdToHuman,a=r.formatMonthlyIdToHuman,i=r.getShopDisplayName,o=r.onShowListingImage;return(0,A.jsxs)(w.Z,{striped:!0,bordered:!0,hover:!0,responsive:!0,size:"sm",style:{width:"100%",tableLayout:"fixed"},children:[(0,A.jsx)("thead",{children:(0,A.jsxs)("tr",{children:[(0,A.jsx)("th",{style:{width:"8%"},children:(0,G.R6)(G.Nx.TEXT_ORDER_DATE)}),(0,A.jsx)("th",{style:{width:"8%"},children:(0,G.R6)(G.Nx.TEXT_MONTHLY_ID)}),(0,A.jsx)("th",{style:{width:"8%"},children:(0,G.R6)(G.Nx.TEXT_ORDER_ID)}),(0,A.jsx)("th",{style:{width:"8%"},children:(0,G.R6)(G.Nx.TEXT_SHOP)}),(0,A.jsx)("th",{style:{width:"8%"},children:(0,G.R6)(G.Nx.TEXT_CUSTOMER)}),(0,A.jsx)("th",{style:{width:"8%"},children:(0,G.R6)(G.Nx.TEXT_SKU)}),(0,A.jsx)("th",{style:{width:"8%"},children:(0,G.R6)(G.Nx.TEXT_IMAGE)}),(0,A.jsx)("th",{style:{width:"10%"},children:(0,G.R6)(G.Nx.TEXT_NAME)}),(0,A.jsx)("th",{style:{width:"5%"},children:(0,G.R6)(G.Nx.TEXT_SIZE)}),(0,A.jsx)("th",{style:{width:"10%"},children:(0,G.R6)(G.Nx.TEXT_BUYER_NOTE)}),(0,A.jsx)("th",{style:{width:"10%"},children:(0,G.R6)(G.Nx.TEXT_USER_NOTE)}),(0,A.jsx)("th",{style:{width:"10%"},children:(0,G.R6)(G.Nx.TEXT_ADDRESS)}),(0,A.jsx)("th",{style:{width:"7%"},children:(0,G.R6)(G.Nx.TEXT_CELL_CODE)}),(0,A.jsx)("th",{style:{width:"7%"},children:(0,G.R6)(G.Nx.TEXT_IOSS)})]})}),(0,A.jsx)("tbody",{children:t.flatMap((function(e){return e.listings.map((function(t,r){var l,s;return(0,A.jsxs)("tr",{children:[(0,A.jsx)("td",{style:{whiteSpace:"nowrap"},children:V()(e.order_date).format("DD/MM/YYYY")}),(0,A.jsx)("td",{style:{whiteSpace:"nowrap"},children:a(e.monthly_id)||"-"}),(0,A.jsx)("td",{style:{whiteSpace:"nowrap"},children:n(e.order_id)}),(0,A.jsx)("td",{style:{whiteSpace:"nowrap"},children:i(e.shop_name)}),(0,A.jsx)("td",{style:{whiteSpace:"nowrap"},children:e.customer_name}),(0,A.jsx)("td",{style:{whiteSpace:"nowrap"},children:t.sku}),(0,A.jsx)("td",{style:{minWidth:"80px"},children:t.img_url?(0,A.jsx)("img",{src:null===(l=t.img_url)||void 0===l?void 0:l.replace("75x75","120x120"),alt:t.title,title:"Xem \u1ea3nh l\u1edbn",role:"button",tabIndex:0,onClick:function(e){e.stopPropagation(),o(t)},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),e.stopPropagation(),o(t))},style:{width:"120px",height:"120px",objectFit:"cover",cursor:"pointer"}}):(0,A.jsx)("span",{className:"text-muted",children:"\u2014"})}),(0,A.jsx)("td",{style:{maxWidth:"150px",fontSize:"0.9em"},children:(null===(s=t.title)||void 0===s?void 0:s.length)>40?"".concat(t.title.substring(0,40),"..."):t.title}),(0,A.jsx)("td",{style:{whiteSpace:"nowrap"},children:t.size}),(0,A.jsx)("td",{style:{minWidth:"150px",fontSize:"0.9em"},children:e.buyer_note||"-"}),(0,A.jsx)("td",{style:{minWidth:"150px",fontSize:"0.9em"},children:e.seller_note||"-"}),(0,A.jsx)("td",{style:{whiteSpace:"pre-line",fontSize:"0.9em"},children:e.shipping_address}),(0,A.jsx)("td",{style:{whiteSpace:"nowrap"},children:t.current_cell_code||"-"}),(0,A.jsx)("td",{style:{whiteSpace:"nowrap"},children:e.ioss||"-"})]},"".concat(e.order_id,"-").concat(t.sku,"-").concat(r))}))}))})]})},De=function(e){var t=e.rows,r=e.formatMonthlyIdToHuman;return(0,A.jsxs)(w.Z,{striped:!0,bordered:!0,hover:!0,responsive:!0,size:"sm",children:[(0,A.jsx)("thead",{children:(0,A.jsxs)("tr",{children:[(0,A.jsx)("th",{children:(0,G.R6)(G.Nx.TEXT_SKU)}),(0,A.jsx)("th",{children:(0,G.R6)(G.Nx.TEXT_SIZE)}),(0,A.jsx)("th",{children:(0,G.R6)(G.Nx.TEXT_QUANTITY)}),(0,A.jsx)("th",{children:(0,G.R6)(G.Nx.TEXT_CELL_CODE)}),(0,A.jsx)("th",{children:(0,G.R6)(G.Nx.TEXT_MONTHLY_ID)})]})}),(0,A.jsx)("tbody",{children:t.map((function(e,t){return(0,A.jsxs)("tr",{children:[(0,A.jsx)("td",{children:e.sku}),(0,A.jsx)("td",{children:e.size}),(0,A.jsx)("td",{children:e.quantity}),(0,A.jsx)("td",{children:e.cell||"-"}),(0,A.jsx)("td",{children:Array.from(e.monthlyIds).map((function(e){return r(e)})).join(", ")})]},t)}))})]})},Me=function(e){var t=e.show,r=e.onClose,n=e.ordersToFulfill,a=void 0===n?[]:n,i=e.activeTab,o=e.onToggleTab,l=e.onPrint,s=e.formatOrderIdToHuman,d=e.formatMonthlyIdToHuman,c=e.getShopDisplayName,u=e.onShowListingImage,h=Pe(a),p=Re(function(e){var t={};
1return Pe(e).forEach((function(e){e.listings.forEach((function(r){var n="".concat(r.sku,"-").concat(r.size,"-").concat(r.current_cell_code);t[n]||(t[n]={sku:r.sku,size:r.size,quantity:0,cell:r.current_cell_code,monthlyIds:new Set}),t[n].quantity+=1,t[n].monthlyIds.add(e.monthly_id)}))})),Object.values(t)}(a)),g=Re(function(e){var t={};return e.forEach((function(e){e.listings.filter((function(e){return 0===e.available})).forEach((function(r){var n="".concat(r.sku,"-").concat(r.size,"-").concat(r.current_cell_code);t[n]||(t[n]={sku:r.sku,size:r.size,quantity:0,cell:r.current_cell_code,monthlyIds:new Set}),t[n].quantity+=1,t[n].monthlyIds.add(e.monthly_id)}))})),Object.values(t)}(a)),m=p.reduce((function(e,t){return e+t.quantity}),0),f=g.reduce((function(e,t){return e+t.quantity}),0),x={formatOrderIdToHuman:s,formatMonthlyIdToHuman:d,getShopDisplayName:c,onShowListingImage:u};return(0,A.jsxs)(Te.Z,{isOpen:t,toggle:r,size:"xl",centered:!0,className:"iframe-modal",style:{maxWidth:"95vw",width:"95vw",margin:"0 auto",zIndex:1050},children:[(0,A.jsxs)(Oe.Z,{toggle:r,children:["Orders to Fulfill (",a.length,")"]}),(0,A.jsxs)(we.Z,{style:{padding:0},children:[(0,A.jsxs)(Ne.Z,{tabs:!0,children:[(0,A.jsx)(Ee.Z,{children:(0,A.jsxs)(Le.Z,{className:"0"===i?"active":"",onClick:function(){return o("0")},children:["T\u1ea5t c\u1ea3 \u0111\u01a1n n\u1ee3 (",a.length,")"]})}),(0,A.jsx)(Ee.Z,{children:(0,A.jsxs)(Le.Z,{className:"1"===i?"active":"",onClick:function(){return o("1")},children:[(0,G.R6)(G.Nx.TEXT_SHIPPABLE_ORDERS)," (",h.length,")"]})}),(0,A.jsx)(Ee.Z,{children:(0,A.jsxs)(Le.Z,{className:"2"===i?"active":"",onClick:function(){return o("2")},children:[(0,G.R6)(G.Nx.TEXT_WAREHOUSE_LAMPS)," (",m,")"]})}),(0,A.jsx)(Ee.Z,{children:(0,A.jsxs)(Le.Z,{className:"3"===i?"active":"",onClick:function(){return o("3")},children:[(0,G.R6)(G.Nx.TEXT_OUT_OF_STOCK_LAMPS)," (",f,")"]})})]}),(0,A.jsxs)(Ie.Z,{activeTab:i,children:[(0,A.jsxs)(Ze.Z,{tabId:"0",children:[(0,A.jsxs)("div",{className:"d-flex justify-content-between align-items-center p-2",children:[(0,A.jsx)("div",{children:(0,A.jsxs)("strong",{children:[(0,G.R6)(G.Nx.TEXT_TOTAL_ORDERS),": ",a.length]})}),(0,A.jsxs)(N.Z,{variant:"primary",onClick:function(){return l("allfulfill")},children:[(0,A.jsx)(xe.rcQ,{className:"me-2"}),"Print"]})]}),(0,A.jsx)("div",{style:{maxHeight:"80vh",overflowY:"auto"},children:(0,A.jsx)(Ae,{orders:a,helpers:x})})]}),(0,A.jsxs)(Ze.Z,{tabId:"1",children:[(0,A.jsxs)("div",{className:"d-flex justify-content-between align-items-center p-2",children:[(0,A.jsx)("div",{children:(0,A.jsxs)("strong",{children:[(0,G.R6)(G.Nx.TEXT_TOTAL_ORDERS),": ",h.length]})}),(0,A.jsxs)(N.Z,{variant:"primary",onClick:function(){return l("shipping")},children:[(0,A.jsx)(xe.rcQ,{className:"me-2"}),"Print"]})]}),(0,A.jsx)("div",{style:{maxHeight:"80vh",overflowY:"auto"},children:(0,A.jsx)(Ae,{orders:h,helpers:x})})]}),(0,A.jsxs)(Ze.Z,{tabId:"2",children:[(0,A.jsxs)("div",{className:"d-flex justify-content-between align-items-center p-2",children:[(0,A.jsx)("div",{children:(0,A.jsxs)("strong",{children:[(0,G.R6)(G.Nx.TEXT_TOTAL_LAMPS),": ",m]})}),(0,A.jsxs)(N.Z,{variant:"primary",onClick:function(){return l("warehouse")},children:[(0,A.jsx)(xe.rcQ,{className:"me-2"}),(0,G.R6)(G.Nx.TEXT_PRINT)]})]}),(0,A.jsx)("div",{style:{maxHeight:"80vh",overflowY:"auto"},children:(0,A.jsx)(De,{rows:p,formatMonthlyIdToHuman:d})})]}),(0,A.jsxs)(Ze.Z,{tabId:"3",children:[(0,A.jsxs)("div",{className:"d-flex justify-content-between align-items-center p-2",children:[(0,A.jsx)("div",{children:(0,A.jsxs)("strong",{children:[(0,G.R6)(G.Nx.TEXT_TOTAL_LAMPS),": ",f]})}),(0,A.jsxs)(N.Z,{variant:"primary",onClick:function(){return l("outofstock")},children:[(0,A.jsx)(xe.rcQ,{className:"me-2"}),(0,G.R6)(G.Nx.TEXT_PRINT)]})]}),(0,A.jsx)("div",{style:{maxHeight:"80vh",overflowY:"auto"},children:(0,A.jsx)(De,{rows:g,formatMonthlyIdToHuman:d})})]})]})]})]})},He=r(36685),ze=function(e){var t=e.targetPage,r=(e.orderListCfg,e.pageTitle),n=e.isOrderListHeaderHidden,a=e.filterShippingCountryEnabled,i=e.saleOrderStatusLimitEnabled,o=e.showCreateMonthlyIdButton,l=e.showShippingAgencyExportButtons,s=e.shippingCenterFilterBesideAddOrder,d=e.enableCreateMultipleOrder,c=e.enableExportFail,u=e.isUsFilter,h=e.onIsUsFilterChange,p=e.disableStatusRestriction,g=e.onDisableStatusRestrictionChange,m=e.onCreateMonthlyId,f=e.onExportSGB,x=e.onExportTHE,_=e.onExportViettelPost,v=e.shippingCenterNameFilter,y=e.onShippingCenterNameFilterChange,b=e.shippingCenterNameLabel,C=e.currentCompany,j=e.publicPartners,T=e.onAddOrder,O=e.hideAddNewOrder,w=e.onShowMultipleOrderModal,E=e.availableFilter,L=e.onAvailableFilterChange,I=e.showShippingCenterDateFilter,Z=e.shippingCenterDateFilterLabel,k=e.onShowShippingCenterDateFilterChange,P=e.shippingCenterDateFrom,R=e.shippingCenterDateTo,D=e.onShippingCenterDateFromChange,M=e.onShippingCenterDateToChange,H=e.statusFilter,z=e.selectedOrdersSize,B=e.onShowExportModal,X=e.onShowExportFailModal,V=e.onAutoFulfill,W=e.onFulfillLabelClick;return(0,A.jsxs)("div",{className:"d-flex justify-content-between align-items-center mb-3",children:[!n&&(0,A.jsx)("h2",{className:"text-center mb-0",children:r}),(0,A.jsxs)("div",{className:"d-flex gap-2 align-items-center ms-auto",children:[a&&(0,A.jsxs)(S.Z,{value:u,onChange:h,className:"me-2",style:{width:"auto"},title:"metadata.configs.general_config.".concat(He.by),children:[(0,A.jsx)("option",{value:"",children:"T\u1ea5t c\u1ea3 qu\u1ed1c gia"}),(0,A.jsx)("option",{value:"true",children:"\u0110\u01a1n h\xe0ng M\u1ef9"}),(0,A.jsx)("option",{value:"false",children:"\u0110\u01a1n h\xe0ng kh\xe1c"})]}),"sale"===t&&(0,A.jsxs)(A.Fragment,{children:[i&&(0,A.jsx)(F.Z,{type:"checkbox",id:"disableStatusRestriction",label:"T\u1eaft gi\u1edbi h\u1ea1n status",checked:p,onChange:g,className:"me-2 align-self-center",title:"metadata.configs.general_config.".concat(He.$N," = true")}),o&&(0,A.jsx)(N.Z,{variant:"warning",className:"me-2",onClick:m,title:"metadata.configs.general_config.".concat(He.y4," = true"),children:"T\u1ea1o m\xe3 \u0111\u01a1n"}),l&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(N.Z,{variant:"success",className:"me-2",onClick:f,children:"G\u1eedi SGB"}),(0,A.jsx)(N.Z,{variant:"success",className:"me-2",onClick:x,children:"G\u1eedi THE"}),(0,A.jsx)(N.Z,{variant:"info",className:"me-2",onClick:_,children:"G\u1eedi Viettel Post"})]}
1),s&&(0,A.jsxs)(S.Z,{size:"sm",value:v,onChange:y,className:"me-2",style:{width:"auto",minWidth:160,maxWidth:280},"aria-label":"L\u1ecdc ".concat(b),title:b,children:[(0,A.jsx)("option",{value:"",children:"T\u1ea5t c\u1ea3 ".concat(b)}),(0,U.fL)(C,j).map((function(e){return(0,A.jsx)("option",{value:e.value,children:e.label},e.value)}))]}),!O&&(0,A.jsx)(N.Z,{variant:"primary",onClick:T,children:(0,G.R6)(G.Nx.TEXT_ADD_ORDER)}),d&&(0,A.jsx)(N.Z,{variant:"outline-primary",onClick:w,children:"T\u1ea1o nhi\u1ec1u \u0111\u01a1n"})]}),"fulfill"===t&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(S.Z,{value:E,onChange:L,className:"me-3",style:{width:"auto"},children:[(0,A.jsx)("option",{value:"",children:"T\u1ea5t c\u1ea3 tr\u1ea1ng th\xe1i available"}),(0,A.jsx)("option",{value:"-1",children:(0,G.R6)(G.Nx.TEXT_AVAILABLE_PENDING)}),(0,A.jsx)("option",{value:"0",children:(0,G.R6)(G.Nx.TEXT_AVAILABLE_OUT_OF_STOCK)}),(0,A.jsx)("option",{value:"1",children:(0,G.R6)(G.Nx.TEXT_AVAILABLE_IN_STOCK)}),(0,A.jsx)("option",{value:"2",children:(0,G.R6)(G.Nx.TEXT_AVAILABLE_RESERVED)})]}),(0,A.jsx)(F.Z,{type:"checkbox",id:"shippingCenterDateFilter",label:Z,checked:I,onChange:k,className:"me-3"}),I&&(0,A.jsxs)("div",{className:"d-flex align-items-center gap-2 me-3",children:[(0,A.jsxs)("div",{className:"d-flex align-items-center gap-1",children:[(0,A.jsx)("label",{className:"form-label small mb-0 me-1",children:"T\u1eeb:"}),(0,A.jsx)(ee.ZP,{selected:P,onChange:D,dateFormat:"dd/MM/yyyy",placeholderText:"T\u1eeb ng\xe0y",className:"form-control form-control-sm",isClearable:!0,style:{width:"120px"},popperClassName:"date-picker-popper"})]}),(0,A.jsxs)("div",{className:"d-flex align-items-center gap-1",children:[(0,A.jsx)("label",{className:"form-label small mb-0 me-1",children:"\u0110\u1ebfn:"}),(0,A.jsx)(ee.ZP,{selected:R,onChange:M,dateFormat:"dd/MM/yyyy",placeholderText:"\u0110\u1ebfn ng\xe0y",className:"form-control form-control-sm",isClearable:!0,style:{width:"120px"},popperClassName:"date-picker-popper"})]})]}),(H===Y.vl.PACKAGING_DONE||H===Y.vl.WAITING_FOR_SHIPPING_LABEL)&&z>0&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(N.Z,{variant:"danger",className:"me-2",onClick:B,children:"Xu\u1ea5t h\xe0ng"}),c&&(0,A.jsx)(N.Z,{variant:"outline-danger",className:"me-2",onClick:X,children:"Xu\u1ea5t l\u1ed7i"})]}),(0,A.jsx)(N.Z,{variant:"warning",onClick:V,children:"Auto Fulfill"}),(0,A.jsx)(N.Z,{variant:"success",onClick:W,children:"Fulfill Label"})]})]})]})},Ge=function(e){var t=e.pageTitle,r=e.isOrderListHeaderHidden,n=e.showMobileFilterPanel,a=e.onToggleMobilePanel,i=e.targetPage,o=e.filterShippingCountryEnabled,l=e.saleOrderStatusLimitEnabled,s=e.showCreateMonthlyIdButton,d=e.showShippingAgencyExportButtons,c=e.shippingCenterFilterBesideAddOrder,u=e.enableCreateMultipleOrder,h=e.enableExportFail,p=e.isUsFilter,g=e.onIsUsFilterChange,m=e.disableStatusRestriction,f=e.onDisableStatusRestrictionChange,x=e.onCreateMonthlyId,_=e.onExportSGB,v=e.onExportTHE,y=e.onExportViettelPost,b=e.shippingCenterNameFilter,C=e.onShippingCenterNameFilterChange,j=e.shippingCenterNameLabel,T=e.currentCompany,O=e.publicPartners,w=e.onAddOrder,E=e.hideAddNewOrder,L=e.onShowMultipleOrderModal,I=e.availableFilter,Z=e.onAvailableFilterChange,k=e.showShippingCenterDateFilter,P=e.shippingCenterDateFilterLabel,R=e.onShowShippingCenterDateFilterChange,D=e.statusFilter,M=e.selectedOrdersSize,H=e.onShowExportModal,z=e.onShowExportFailModal,B=e.onAutoFulfill,X=e.onFulfillLabelClick;return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)("div",{className:"d-flex justify-content-between align-items-center mb-3",children:[!r&&(0,A.jsx)("h2",{className:"mb-0",children:t}),(0,A.jsx)(N.Z,{variant:n?"secondary":"outline-secondary",size:"sm",onClick:a,children:n?"\u1ea8n b\u1ed9 l\u1ecdc":"Hi\u1ec7n b\u1ed9 l\u1ecdc"})]}),n&&(0,A.jsxs)("div",{className:"order-list-mobile-filter-panel",children:[o&&(0,A.jsxs)(S.Z,{value:p,onChange:g,title:"metadata.configs.general_config.".concat(He.by),children:[(0,A.jsx)("option",{value:"",children:"T\u1ea5t c\u1ea3 qu\u1ed1c gia"}),(0,A.jsx)("option",{value:"true",children:"\u0110\u01a1n h\xe0ng M\u1ef9"}),(0,A.jsx)("option",{value:"false",children:"\u0110\u01a1n h\xe0ng kh\xe1c"})]}),"sale"===i&&(0,A.jsxs)(A.Fragment,{children:[l&&(0,A.jsx)(F.Z,{type:"checkbox",id:"disableStatusRestrictionMobile",label:"T\u1eaft gi\u1edbi h\u1ea1n status",checked:m,onChange:f,className:"mb-2",title:"metadata.configs.general_config.".concat(He.$N," = true")}),s&&(0,A.jsx)(N.Z,{variant:"warning",className:"w-100",onClick:x,title:"metadata.configs.general_config.".concat(He.y4," = true"),children:"T\u1ea1o m\xe3 \u0111\u01a1n"}),d&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(N.Z,{variant:"success",className:"w-100",onClick:_,children:"G\u1eedi SGB"}),(0,A.jsx)(N.Z,{variant:"success",className:"w-100",onClick:v,children:"G\u1eedi THE"}),(0,A.jsx)(N.Z,{variant:"info",className:"w-100",onClick:y,children:"G\u1eedi Viettel Post"})]}),c&&(0,A.jsxs)(S.Z,{size:"sm",value:b,onChange:C,"aria-label":"L\u1ecdc ".concat(j),title:j,children:[(0,A.jsx)("option",{value:"",children:"T\u1ea5t c\u1ea3 ".concat(j)}),(0,U.fL)(T,O).map((function(e){return(0,A.jsx)("option",{value:e.value,children:e.label},e.value)}))]}),!E&&(0,A.jsx)(N.Z,{variant:"primary",className:"w-100",onClick:w,children:(0,G.R6)(G.Nx.TEXT_ADD_ORDER)}),u&&(0,A.jsx)(N.Z,{variant:"outline-primary",className:"w-100",onClick:L,children:"T\u1ea1o nhi\u1ec1u \u0111\u01a1n"})]}),"fulfill"===i&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(S.Z,{value:
1I,onChange:Z,children:[(0,A.jsx)("option",{value:"",children:"T\u1ea5t c\u1ea3 tr\u1ea1ng th\xe1i available"}),(0,A.jsx)("option",{value:"-1",children:(0,G.R6)(G.Nx.TEXT_AVAILABLE_PENDING)}),(0,A.jsx)("option",{value:"0",children:(0,G.R6)(G.Nx.TEXT_AVAILABLE_OUT_OF_STOCK)}),(0,A.jsx)("option",{value:"1",children:(0,G.R6)(G.Nx.TEXT_AVAILABLE_IN_STOCK)}),(0,A.jsx)("option",{value:"2",children:(0,G.R6)(G.Nx.TEXT_AVAILABLE_RESERVED)})]}),(0,A.jsx)(F.Z,{type:"checkbox",id:"shippingCenterDateFilterMobile",label:P,checked:k,onChange:R,className:"mb-2"}),(D===Y.vl.PACKAGING_DONE||D===Y.vl.WAITING_FOR_SHIPPING_LABEL)&&M>0&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(N.Z,{variant:"danger",className:"w-100",onClick:H,children:"Xu\u1ea5t h\xe0ng"}),h&&(0,A.jsx)(N.Z,{variant:"outline-danger",className:"w-100 mt-2",onClick:z,children:"Xu\u1ea5t l\u1ed7i"})]}),(0,A.jsx)(N.Z,{variant:"warning",className:"w-100",onClick:B,children:"Auto Fulfill"}),(0,A.jsx)(N.Z,{variant:"success",className:"w-100",onClick:X,children:"Fulfill Label"})]})]})]})},Ue=function(e){var t=e.selectedBulkStatus,r=e.selectedOrders,n=e.isMobileViewport,a=e.targetPage,i=e.totalCount,o=e.filteredOrders,l=e.filteredOrdersCount,s=e.availableFilterText,d=e.showListingQtySummary,c=e.listingQtySummaryLabel,u=e.shownListingCount,h=e.stickHeader,p=e.itemsPerPage,g=e.availableStatuses,m=e.dateRangeDisplay,f=e.getOrderStatusDisplayLabel,x=e.onBulkStatusChange,_=e.onBulkStatusApply,v=e.onPrintOrderDetails,y=e.onConfigToggle,b=e.onItemsPerPageChange,C=e.canBulkDelete,j=void 0!==C&&C,O=e.onBulkDelete,w=!t||0===r.size;return(0,A.jsxs)("div",{className:"mb-3 d-flex justify-content-between align-items-center",children:[(0,A.jsxs)("div",{className:"d-flex align-items-center",children:[(0,A.jsxs)(S.Z,{value:t,onChange:x,className:"me-2",style:{width:"auto"},children:[(0,A.jsx)("option",{value:"",children:(0,G.R6)(G.Nx.TEXT_BULK_UPDATE_STATUS)}),g.map((function(e){return(0,A.jsxs)("option",{value:e.value,children:["[",e.code,"] ",f(e.value)]},e.value)}))]}),(0,A.jsx)(N.Z,{variant:"primary",size:"sm",onClick:_,disabled:w,style:{"&:disabled":{color:"#6c757d !important",backgroundColor:"#e9ecef !important",borderColor:"#dee2e6 !important"}},children:(0,A.jsx)("span",{style:{color:w?"#6c757d":"inherit"},children:(0,G.R6)(G.Nx.TEXT_APPLY)})}),j&&r.size>0&&(0,A.jsx)(N.Z,{variant:"danger",size:"sm",className:"ms-2",onClick:O,children:(0,G.R6)(G.Nx.TEXT_DELETE_ORDER)}),"fulfill"===a&&r.size>0&&(0,A.jsx)(N.Z,{variant:"info",size:"sm",className:"ms-2",onClick:v,children:"In Danh S\xe1ch \u0110\u01a1n"}),!n&&(0,A.jsxs)("span",{className:"text-muted ms-2",children:[r.size," ",(0,G.R6)(G.Nx.TEXT_ORDERS_SELECTED)]}),!n&&(0,A.jsxs)("span",{className:"ms-4 me-2",children:[(0,G.R6)(G.Nx.TEXT_TOTAL_ORDERS),": ",(0,A.jsx)("strong",{children:i})," ",m,s&&(0,A.jsxs)("span",{className:"ms-2",style:{color:"#007bff",fontWeight:"bold"},children:["(Tr\u1ea1ng th\xe1i ",(0,A.jsx)("strong",{children:s}),": ",(0,A.jsx)("strong",{children:l})," \u0111\u01a1n)"]}),"\xa0\xa0",(0,G.R6)(G.Nx.TEXT_SHOWING),": ",(0,A.jsx)("strong",{children:o.length}),d&&(0,A.jsxs)("span",{className:"ms-2",style:{color:"#0d6efd",fontWeight:700},children:[" ","\xb7 ",c,": ",(0,A.jsx)("strong",{children:u})]})]})]}),(0,A.jsxs)("div",{className:"d-flex align-items-center",children:[(0,A.jsxs)(N.Z,{variant:"secondary",size:"sm",onClick:y,className:"me-4",children:[(0,G.R6)(G.Nx.TEXT_CONFIG_VIEW),h&&(0,A.jsx)("span",{className:"ms-2 badge bg-success",title:"Sticky header enabled",children:"\ud83d\udccc"})]}),(0,A.jsxs)("span",{className:"me-2",children:[(0,G.R6)(G.Nx.TEXT_ITEMS_PER_PAGE),":"]}),(0,A.jsxs)(T.Z.Select,{value:p,onChange:b,style:{width:"auto"},children:[(0,A.jsx)("option",{value:10,children:"10"}),(0,A.jsx)("option",{value:20,children:"20"}),(0,A.jsx)("option",{value:50,children:"50"}),(0,A.jsx)("option",{value:100,children:"100"}),(0,A.jsx)("option",{value:200,children:"200"}),(0,A.jsx)("option",{value:500,children:"500"}),(0,A.jsx)("option",{value:1e3,children:"1000"}),(0,A.jsx)("option",{value:1500,children:"1500"}),(0,A.jsx)("option",{value:2e3,children:"2000"})]})]})]})},Be={width:"32px",height:"32px",padding:0,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",backgroundColor:"#0d6efd",border:"none",boxShadow:"0 2px 8px rgba(13, 110, 253, 0.15)",color:"#fff",fontSize:22,transition:"all 0.2s"},Ye=function(e){var t=document.querySelector(".main-panel");t?t.scrollTo({top:e,behavior:"smooth"}):window.scrollTo({top:e,behavior:"smooth"})},Xe=function(e){var t=e.isMobileViewport,r=e.showTitleAndFilters,n=e.onToggleTitleAndFilters;return t?null:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("div",{style:{position:"fixed",right:"20px",top:"20px",zIndex:1e4},children:(0,A.jsx)(N.Z,{variant:"outline-secondary",size:"sm",onClick:n,title:r?"\u1ea8n ti\xeau \u0111\u1ec1 v\xe0 b\u1ed9 l\u1ecdc":"Hi\u1ec7n t
1i\xeau \u0111\u1ec1 v\xe0 b\u1ed9 l\u1ecdc",style:{width:"40px",height:"40px",padding:0,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",backgroundColor:r?"#f8f9fa":"#007bff",border:"2px solid #dee2e6",color:r?"#6c757d":"#fff",fontSize:"16px",fontWeight:"bold",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",transition:"all 0.2s"},children:r?"\u25b2":"\u25bc"})}),(0,A.jsxs)("div",{style:{position:"fixed",right:"20px",bottom:"20px",zIndex:9999,display:"flex",flexDirection:"column",gap:"10px"},children:[(0,A.jsx)(N.Z,{variant:"primary",size:"sm",style:Be,onClick:function(){return Ye(0)},title:"L\xean \u0111\u1ea7u trang",children:(0,A.jsx)(xe.ZTc,{color:"#fff",size:18})}),(0,A.jsx)(N.Z,{variant:"primary",size:"sm",style:Be,onClick:function(){var e=document.querySelector(".main-panel");Ye(e?e.scrollHeight:document.documentElement.scrollHeight)},title:"Xu\u1ed1ng cu\u1ed1i trang",children:(0,A.jsx)(xe.NWQ,{color:"#fff",size:18})})]})]})},Ve=r(78157),We=function e(t,r){return 0===r?t:e(r,t%r)},qe=function(e){var t=e.targetPage,r=e.order,n=e.rowSpan,a=e.mergeFz,i=e.showAction,o=e.flags,l=void 0===o?{}:o,s=e.handlers,d=void 0===s?{}:s,c=function(e,t){if(!l.splitOrderEnabled)return!1;if(Array.isArray(null===(e=r.metadata)||void 0===e?void 0:e.parent_products)&&r.metadata.parent_products.length>0)return!0;var n=r.listings||[];return 1===n.length?((null===(t=n[0])||void 0===t?void 0:t.quantity)||0)>1:n.length>=2&&n.map((function(e){return e.quantity||1})).reduce((function(e,t){return We(e,t)}))>1}();return(0,A.jsx)("td",{rowSpan:n,style:a({minWidth:80,verticalAlign:"middle"}),children:(0,A.jsxs)("div",{className:"d-flex gap-1 flex-wrap",children:["sale"===t&&(0,A.jsxs)(A.Fragment,{children:[i("edit")&&(0,A.jsx)(N.Z,{variant:"primary",size:"sm",onClick:function(){return d.onEdit&&d.onEdit(r)},children:(0,G.R6)(G.Nx.TEXT_EDIT)}),i("add_listing")&&(0,A.jsx)(N.Z,{variant:"success",size:"sm",onClick:function(){return d.onAddListing&&d.onAddListing(r)},children:(0,G.R6)(G.Nx.TEXT_ADD_LISTING)}),l.colorModeEnabled&&i("add_color")&&(0,A.jsx)(N.Z,{variant:"outline-info",size:"sm",onClick:function(){return d.onAddColor&&d.onAddColor(r)},title:"Th\xeam m\xe0u v\xe0o \u0111\u01a1n",children:(0,A.jsx)(xe.SaA,{})}),l.cloneOrderEnabled&&i("clone")&&(0,A.jsx)(N.Z,{variant:"outline-success",size:"sm",onClick:function(){return d.onClone&&d.onClone(r)},title:"Clone order (t\u1ea1o \u0111\u01a1n gi\u1ed1ng h\u1ec7t)",children:(0,A.jsx)(xe.d_e,{})}),l.cloneChildOrderEnabled&&i("clone_child")&&(0,A.jsx)(N.Z,{variant:"outline-primary",size:"sm",onClick:function(){return d.onCloneChild&&d.onCloneChild(r)},title:"T\u1ea1o \u0111\u01a1n con (order_id + _NN)",children:(0,A.jsx)(xe.TdV,{})})]}),"rnd"===t&&(0,A.jsx)(N.Z,{variant:"success",size:"sm",onClick:function(){return d.onRndDone&&d.onRndDone(r.order_id)},children:"Done Custom"}),i("print")&&(0,A.jsx)(N.Z,{variant:"outline-secondary",size:"sm",onClick:function(){return d.onPrint&&d.onPrint(r)},title:"In nh\xe3n \u0111\u01a1n",children:(0,A.jsx)(xe.rcQ,{})}),i("detail")&&(0,A.jsx)(N.Z,{variant:"outline-primary",size:"sm",onClick:function(){return d.onOpenDetail&&d.onOpenDetail(r)},title:"Xem chi ti\u1ebft \u0111\u01a1n",children:(0,A.jsx)(xe.dSq,{})}),i("logs")&&(0,A.jsx)(N.Z,{variant:"info",size:"sm",onClick:function(){return d.onViewLogs&&d.onViewLogs(r)},children:(0,A.jsx)(xe.ceS,{})}),l.canViewMetadata&&i("metadata")&&(0,A.jsx)(N.Z,{variant:"secondary",size:"sm",onClick:function(){return d.onViewMetadata&&d.onViewMetadata(r)},title:"Xem / s\u1eeda metadata",children:(0,A.jsx)(xe.DAO,{})}),i("custom_album")&&(0,A.jsx)(N.Z,{variant:"warning",size:"sm",onClick:function(){return d.onOpenCustomAlbum&&d.onOpenCustomAlbum(r)},title:"Open Custom Album",children:(0,A.jsx)(xe.Jh6,{})}),c&&i("split_order")&&(0,A.jsx)(N.Z,{variant:"outline-secondary",size:"sm",onClick:function(){return d.onSplitOrder&&d.onSplitOrder(r)},title:"\u0110i\u1ec1u ch\u1ec9nh s\u1ed1 l\u01b0\u1ee3ng",children:(0,A.jsx)(xe.RDp,{})})]})})},Ke=function(e){if(!e)return null;var t=e,r=String(t.getDate()).padStart(2,"0"),n=String(t.getMonth()+1).padStart(2,"0"),a=t.getFullYear(),i=String(t.getHours()).padStart(2,"0"),o=String(t.getMinutes()).padStart(2,"0");return"".concat(r,"/").concat(n,"/").concat(a," ").concat(i,":").concat(o)},Qe=function(e,t,r){var n=r.colVisTable,a=r.targetPage,o=r.order,l=r.listing,s=r.listingIndex,d=r.i
1dxInGroup,c=r.groupSize,u=r.isFirst,h=r.stt,p=r.orderRowSpan,g=r.isFirstInOrder,x=r.orderQtyFailedMeta,_=r.orderCustomFilter1Meta,y=r.orderCustomFilter2Meta,S=r.orderProductCustomField1Meta,b=r.isSkuValid,C=r.isSizeValid,j=r.quantityCellHighlight,w=r.size;if(!n[t])return null;var F=function(n){return e.orderListMergeFrozenBodyStyle(t,r,n)};switch(t){case"stt":return u?(0,A.jsx)("td",{rowSpan:c,style:F({textAlign:"center"}),children:h}):null;case"orderDate":return u?(0,A.jsx)("td",{rowSpan:c,style:F({}),children:V()(o.order_date).format("DD/MM/YYYY")}):null;case"monthlyId":return u?(0,A.jsx)("td",{rowSpan:c,style:F({}),children:e.formatMonthlyIdToHuman(o.monthly_id)||"-"}):null;case"orderId":return g?(0,A.jsx)("td",{rowSpan:p,style:F({}),children:(0,A.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"6px",paddingLeft:e.isIncrementalChildOrder(o)?4:0,minHeight:28,fontWeight:e.isIncrementalParentOrder(o)?600:e.isIncrementalChildOrder(o)?500:void 0,color:e.isIncrementalChildOrder(o)?"#495057":void 0},children:[e.isIncrementalChildOrder(o)&&e.renderIncrementalChildConnector(),e.isIncrementalParentOrder(o)?(0,A.jsx)(v.Z,{bg:"warning",pill:!0,title:"\u0110\u01a1n nh\xf3m (c
1ha)",style:{flexShrink:0},children:e.formatOrderIdToHuman(o.order_id)}):(0,A.jsx)("span",{style:e.isIncrementalChildOrder(o)?{fontStyle:"italic"}:void 0,children:e.formatOrderIdToHuman(o.order_id)}),(0,A.jsx)("span",{onClick:function(){return e.handleCopyToClipboard(o.order_id,"M\xe3 \u0111\u01a1n h\xe0ng")},style:{cursor:"pointer",fontSize:"14px",opacity:.7},title:"Copy m\xe3 \u0111\u01a1n h\xe0ng",children:(0,A.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,A.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),(0,A.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})})]})}):null;case"sku":var E=!0===e.getGeneralConfig()[He.oR]&&"sale"===a,L=e.isOrderColorModeEnabled()?e.getListingColorInfo(l):{isColor:!1},I=L.isColor&&/^#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{3})$/.test(L.hex||"")?L.hex:null,Z=I?{display:"inline-block",background:I,color:e.getContrastTextColor(I),padding:"2px 8px",borderRadius:4,fontWeight:600}:{color:b?"inherit":"#dc3545",fontWeight:b?"normal":"bold"};return(0,A.jsxs)("td",{style:F({position:"relative"}),children:[(0,A.jsx)("span",{style:Z,children:(0,ce.G)(l.sku)}),E&&(0,A.jsx)("button",{type:"button",onClick:function(t){t.stopPropagation(),e.handleDeleteOrderListing(o,s)},title:"Xo\xe1 listing n\xe0y","aria-label":"Xo\xe1 listing n\xe0y",style:{position:"absolute",top:4,right:4,width:18,height:18,padding:0,border:"none",background:"transparent",color:"#6c757d",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",borderRadius:4,lineHeight:1},onMouseEnter:function(e){e.currentTarget.style.color="#dc3545",e.currentTarget.style.background="#fdecea"},onMouseLeave:function(e){e.currentTarget.style.color="#6c757d",e.currentTarget.style.background="transparent"},children:(0,A.jsx)(xe.aHS,{size:12})})]});case"image":var k,P=e.isOrderColorModeEnabled()?e.getListingColorInfo(l):{isColor:!1};if(P.isColor){var R=/^#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{3})$/.test(P.hex||"")?P.hex:"#eeeeee",D=function(t){t.stopPropagation(),e.handleOpenColorPickerForOrder(o,s)};return(0,A.jsx)("td",{style:F({minWidth:"80px",textAlign:"center",verticalAlign:"middle",padding:"8px 8px"}),children:(0,A.jsx)("div",{role:"button",tabIndex:0,title:"".concat(P.hex||P.productType," \u2014 Click \u0111\u1ec3 \u0111\u1ed5i m\xe0u"),onClick:D,onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),D(e))},style:{width:"60px",height:"60px",borderRadius:8,background:R,border:"1.5px solid #bbb",cursor:"pointer",boxShadow:"0 1px 4px #0002",display:"inline-block"}})})}return(0,A.jsx)("td",{style:F({minWidth:"80px"}),children:l.img_url?(0,A.jsx)("img",{src:null===(k=l.img_url)||void 0===k?void 0:k.replace("75x75","120x120"),alt:l.title,title:"Xem \u1ea3nh l\u1edbn",role:"button",tabIndex:0,onClick:function(t){t.stopPropagation(),e.handleShowListingImageModal(l)},onKeyDown:function(t){"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),t.stopPropagation(),e.handleShowListingImageModal(l))},style:{width:"120px",height:"120px",objectFit:"cover",cursor:"pointer"}}):(0,A.jsx)("span",{className:"text-muted",children:"\u2014"})});case"title":var M,H=e.isOrderColorModeEnabled()?e.getListingColorInfo(l):{isColor:!1},z=H.isColor&&/^#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{3})$/.test(H.hex||"")?H.hex:null,B=(null===(M=l.title)||void 0===M?void 0:M.length)>40?"".concat(l.title.substring(0,40),"..."):l.title||"-";return(0,A.jsxs)("td",{style:F({maxWidth:"150px",fontSize:"0.9em",position:"relative"}),children:[z?(0,A.jsx)("span",{style:{display:"inline-block",background:z,color:e.getContrastTextColor(z),padding:"2px 8px",borderRadius:4,fontWeight:600},children:B}):B,"sale"===a&&!e.isTruthyGeneralConfigFlag(e.getGeneralConfig()[He.nT])&&(0,A.jsx)(N.Z,{variant:"link",size:"sm",style:{boxShadow:"none",border:"none",background:"none",padding:0,marginLeft:4,position:"absolute",right:0,top:0},onClick:function(){return e.handleEditListingOnly(o,l,d)},title:"S\u1eeda s\u1ea3n ph\u1ea9m",children:(0,A.jsx)(xe.fmQ,{})})]});case"size":return(0,A.jsx)("td",{style:F({backgroundColor:w?"inherit":"#dc3545",color:C?"inherit":"#dc3545",fontWeight:C?"normal":"bold"}),children:l.size||"-"});case"quantity":return(0,A.jsx)("td",{style:F({backgroundColor:j?"#faf6eb":void 0,fontWeight:j?600:"normal"}),children:l.quantity&&0!==l.quantity?l.quantity:1});case"orderQtyFailed":return(0,A.jsx)("td",{style:F({color:"#dc3545"}),children:x.dropdownMax?(0,A.jsxs)(T.Z.Select,{size:"sm",value:parseInt(l.qty_failed,10)||0,onChange:function(t){return e.handleListingQtyFailedChange(o,s,t.target.value)},style:{minWidth:90,color:"#dc3545"},children:[(0,A.jsx)("option",{value:0,children:"0"}),Array.from({length:x.dropdownMax},(function(e,t){return t+1})).map((function(e){return(0,A.jsx)("option",{value:e,children:e},e)}))]}):(0,A.jsx)(T.Z.Control,{type:"text",inputMode:"numeric",value:parseInt(l.qty_failed,10)||0,onChange:function(t){return e.handleListingQtyFailedChange(o,s,t.target.value)},style:{minWidth:90,color:"#dc3545"}})});case"shop":return u?(0,A.jsx)("td",{rowSpan:c,style:F({}),children:e.getShopDisplayName(o.shop_name)}):null;case"customer":return u?(0,A.jsx)("td",{rowSpan:c,style:F({}),children:(0,A.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[(0,A.jsx)("span",{children:e.getDisplayCustomerName(o)}),(0,A.jsx)("span",{onClick:function(){return e.handleCopyToClipboard(e.getDisplayCustomerName(o),"T\xean kh\xe1ch")},style:{cursor:"pointer",fontSize:"14px",opacity:.7},title:"Copy t\xean kh\xe1ch",children:(0,A.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,A.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),(0,A.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})})]})}):null;case"status":return u?(0,A.jsx)("td",{rowSpan:c,style:F({}),children:(0,A.jsxs)("div",{className:"d-flex align-items-center gap-2",children:[(0,A.jsx)(T.Z.Select,{size:"sm",value:o.status,onChange:function(t){return e.handleStatusChange(o.order_id,t.target.value)},style:{width:"auto"},disabled:e.isIncrementalParentOrder(o),children:e.getAvailableStatuses(o.status,o.order_id).map((function(t){return(0,A.jsxs)("option",{value:t.value,children:["[",t.code,"] ",e.getOrderStatusDisplayLabel(t.value)]},t.value)}))}
1),e.isIncrementalParentOrder(o)?(0,A.jsx)("button",{type:"button",className:"btn btn-link p-0 border-0 d-inline-flex align-items-center",style:{color:"#0dcaf0",minWidth:24},title:"\u0110\u1ed3ng b\u1ed9 tr\u1ea1ng th\xe1i \u0111\u01a1n cha = min(code) c\xe1c \u0111\u01a1n con",disabled:e.state.syncingParentOrderId===o.order_id,onClick:function(){return e.handleSyncIncrementalParentStatusFromChildren(o)},children:e.state.syncingParentOrderId===o.order_id?(0,A.jsx)(O.Z,{animation:"border",size:"sm",style:{width:16,height:16}}):(0,A.jsx)(xe.lbL,{style:{fontSize:"16px"}})}):e.renderStatusBadge(o.status)]})}):null;case"priority":return u?(0,A.jsx)("td",{rowSpan:c,style:F({}),children:"sale"===a?(0,A.jsx)(T.Z.Select,{size:"sm",value:o.priority||2,onChange:function(t){return e.handlePriorityChange(o.order_id,t.target.value)},style:{width:"auto"},children:[1,2,3,4].map((function(t){return(0,A.jsx)("option",{value:t,children:e.renderPriorityOption(t).props.children[1].props.children},t)}))}):(0,A.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,A.jsx)("div",{style:{width:"12px",height:"12px",borderRadius:"50%",backgroundColor:e.getPriorityInfo(o.priority||2).bgColor,border:"1px solid #ccc"}}),e.renderPriorityBadge(o.priority||2)]})}):null;case"startFulfill":return u?(0,A.jsxs)("td",{rowSpan:c,style:F({whiteSpace:"nowrap"}),children:[o.start_fulfill?V()(o.start_fulfill).format(e.state.fulfillStartFinishTimeOnly?"HH:mm":"DD/MM/YYYY HH:mm"):"-",!0===e.getGeneralConfig()[He.C6]&&function(){var e=function(e){if(null===e||void 0===e||!e.start_fulfill||null===e||void 0===e||!e.deadline_fulfill_hours)return null;var t=parseFloat(e.deadline_fulfill_hours);return isNaN(t)||t<=0?null:new Date(new Date(e.start_fulfill).getTime()+36e5*t)}(o);if(!e)return null;var t=e<new Date;return(0,A.jsxs)("div",{style:{fontSize:11,marginTop:2,color:t?"#dc3545":"#fd7e14",fontWeight:600},children:["\u23f0 ",Ke(e)]})}()]}):null;case"finishFulfill":return u?(0,A.jsx)("td",{rowSpan:c,style:F({whiteSpace:"nowrap"}),children:o.finish_fulfill?V()(o.finish_fulfill).format(e.state.fulfillStartFinishTimeOnly?"HH:mm":"DD/MM/YYYY HH:mm"):"-"}):null;case"supervisorUser":return u?(0,A.jsx)("td",{rowSpan:c,style:F({}),children:(0,A.jsx)(T.Z.Select,{size:"sm",style:{minWidth:140,maxWidth:240},value:null!=o.supervisor_user?String(o.supervisor_user):"",onChange:function(t){return e.handleSupervisorUserChange(o.order_id,t.target.value)},"aria-label":e.orderListHeaderLabel("supervisorUser"),children:e.buildTeamUserSelectOptions(e.state.supervisorUserOptions,o.supervisor_user)})}):null;case"executorUser":return u?(0,A.jsx)("td",{rowSpan:c,style:F({}),children:function(){var t=null!=o.executor_user?String(o.executor_user).trim():"",r=e.state.executorUserOptions||[],n=r.some((function(e){return e&&e.username===t})),a=[{value:"",label:"\u2014"}].concat((0,i.Z)(t&&!n?[{value:t,label:t}]:[]),(0,i.Z)(r.filter((function(e){return e&&e.username})).map((function(e){return{value:e.username,label:e.fullname||e.username}})))),l=a.find((function(e){return e.value===t}))||a[0];return(0,A.jsx)($.ZP,{isSearchable:!0,menuPortalTarget:document.body,options:a,value:l,onChange:function(t){return e.handleExecutorUserChange(o.order_id,(null===t||void 0===t?void 0:t.value)||"")},"aria-label":e.orderListHeaderLabel("executorUser"),placeholder:"\u2014",noOptionsMessage:function(){return"Kh\xf4ng c\xf3 user"},styles:{menuPortal:function(e){return(0,m.Z)((0,m.Z)({},e),{},{zIndex:9999})},control:function(e){return(0,m.Z)((0,m.Z)({},e),{},{minWidth:140,maxWidth:240,minHeight:30,fontSize:12})},valueContainer:function(e){return(0,m.Z)((0,m.Z)({},e),{},{padding:"0 6px"})},indicatorsContainer:function(e){return(0,m.Z)((0,m.Z)({},e),{},{height:28})},dropdownIndicator:function(e){return(0,m.Z)((0,m.Z)({},e),{},{padding:4})},clearIndicator:function(e){return(0,m.Z)((0,m.Z)({},e),{},{padding:4})},option:function(e){return(0,m.Z)((0,m.Z)({},e),{},{fontSize:12,padding:"4px 8px"})}}})}()}):null;case"isUs":return u?(0,A.jsx)("td",{rowSpan:c,style:F({textAlign:"center"}),children:o.is_us?(0,A.jsx)(v.Z,{bg:"success",children:"US"}):(0,A.jsx)(v.Z,{bg:"secondary",children:"Non-US"})}):null;case"inventory":return(0,A.jsx)("td",{style:F({}),children:(0,A.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[(0,A.jsx)("span",{children:function(){var t=null;return l.product_code&&e.props.products?t=e.props.products.find((function(e){return e.product_code===l.product_code})):l.sku&&l.size&&e.props.products&&(t=e.props.products.find((function(e){return e.sku_code===l.sku&&e.size===l.size}
1))),t?t.current_qty||0:"-"}()}),e.getProductCodeFromListing(l)&&(0,A.jsx)(xe.ceS,{style:{cursor:"pointer",fontSize:"14px",opacity:.7,marginLeft:"4px"},onClick:function(){return e.handleViewQuantityChanges(l)},title:"Xem l\u1ecbch s\u1eed thay \u0111\u1ed5i s\u1ed1 l\u01b0\u1ee3ng"})]})});case"custom":var Y=l.personalization,X=null==Y?"":String(Y).trim(),W=""!==X&&"Not requested on this item."!==X;return(0,A.jsx)("td",{style:F({fontSize:"0.9em",color:W?"#dc3545":void 0,fontWeight:W?600:void 0}),children:X||"-"});case"productCustomField1":var q,K=String((null===o||void 0===o||null===(q=o.metadata)||void 0===q?void 0:q.parent_product_custom_field_1)||l.custom_field_1||"").trim();return u?(0,A.jsx)("td",{rowSpan:c,style:F({verticalAlign:"middle"}),children:(0,A.jsxs)("div",{className:"d-flex align-items-center gap-1",children:[(0,A.jsx)("span",{children:K||"-"}),K&&null!==S&&void 0!==S&&S.enableCopy?(0,A.jsx)(xe.esY,{style:{cursor:"pointer",opacity:.75,fontSize:"13px"},title:"Copy Custom Field 1",onClick:function(){return e.handleCopyToClipboard(K,(null===S||void 0===S?void 0:S.label)||"Custom Field 1")}}):null]})}):null;case"productCustomField2":var Q,J=String((null===o||void 0===o||null===(Q=o.metadata)||void 0===Q?void 0:Q.parent_product_custom_field_2)||l.custom_field_2||"").trim();return u?(0,A.jsx)("td",{rowSpan:c,style:F({verticalAlign:"middle"}),children:J||"-"}):null;case"orderCustomFilter1":return _.enabled&&u?(0,A.jsx)("td",{rowSpan:c,style:F({minWidth:"140px",maxWidth:"220px",verticalAlign:"middle"}),children:_.options.length>0?(0,A.jsxs)("div",{className:"d-flex flex-column align-items-stretch gap-2",style:{minWidth:0},children:[(0,A.jsxs)(T.Z.Select,{size:"sm",className:"w-100",style:{minWidth:0},value:o.custom_filter_1||"",onChange:function(t){return e.handleOrderInlineCustomFilterChange(o.order_id,"custom_filter_1",t.target.value)},children:[(0,A.jsx)("option",{value:"",children:_.allLabel||"T\u1ea5t c\u1ea3"}),_.options.map((function(e){return(0,A.jsx)("option",{value:e.value,children:e.label},e.value)}))]}),e.renderOrderCustomFilterSelectionBadge(_,o.custom_filter_1)]}):(0,A.jsx)("span",{children:o.custom_filter_1||"-"})}):null;case"orderCustomFilter2":return y.enabled&&u?(0,A.jsx)("td",{rowSpan:c,style:F({minWidth:"140px",maxWidth:"220px",verticalAlign:"middle"}),children:y.options.length>0?(0,A.jsxs)("div",{className:"d-flex flex-column align-items-stretch gap-2",style:{minWidth:0},children:[(0,A.jsxs)(T.Z.Select,{size:"sm",className:"w-100",style:{minWidth:0},value:o.custom_filter_2||"",onChange:function(t){return e.handleOrderInlineCustomFilterChange(o.order_id,"custom_filter_2",t.target.value)},children:[(0,A.jsx)("option",{value:"",children:y.allLabel||"T\u1ea5t c\u1ea3"}),y.options.map((function(e){return(0,A.jsx)("option",{value:e.value,children:e.label},e.value)}))]}),e.renderOrderCustomFilterSelectionBadge(y,o.custom_filter_2)]}):(0,A.jsx)("span",{children:o.custom_filter_2||"-"})}):null;case"estimateGrossWeight":return u?(0,A.jsx)("td",{rowSpan:c,style:F({textAlign:"center"}),children:o.estimate_gross_weight?"".concat(o.estimate_gross_weight,"g"):"-"}):null;case"realGrossWeight":return u?(0,A.jsx)("td",{rowSpan:c,style:F({textAlign:"center"}),children:e.state.editingRealGrossWeight===o.order_id?(0,A.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"4px",justifyContent:"center"},children:[(0,A.jsx)(T.Z.Control,{type:"text",inputMode:"decimal",value:e.state.realGrossWeightValue,onChange:e.handleRealGrossWeightChange,style:{width:"80px",fontSize:"0.9em",textAlign:"center"},autoFocus:!0}),(0,A.jsx)("span",{children:"g"}),(0,A.jsx)(N.Z,{variant:"success",size:"sm",onClick:function(){return e.handleRealGrossWeightSave(o.order_id)},style:{padding:"2px 8px"},children:(0,A.jsx)(xe.l_A,{})}),(0,A.jsx)(N.Z,{variant:"secondary",size:"sm",onClick:function(){return e.setState({editingRealGrossWeight:null})},style:{padding:"2px 8px"},children:(0,G.R6)(G.Nx.TEXT_CANCEL)})]}):(0,A.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"4px",justifyContent:"center"},children:[(0,A.jsx)("span",{children:o.real_gross_weight?"".concat(o.real_gross_weight,"g"):"-"}),"fulfill"===a&&(0,A.jsx)(N.Z,{variant:"link",size:"sm",style:{boxShadow:"none",border:"none",background:"none",padding:"0 4px"},onClick:function(){return e.handleRealGrossWeightEdit(o.order_id)},title:"S\u1eeda kh\u1ed1i l\u01b0\u1ee3ng th\u1ef1c t\u1ebf",children:(0,A.jsx)(xe.fmQ,{})})]})}):null;case"buyerNote":return u?(0,A.jsx)("td",{rowSpan:c,"data-column":"buyerNote",style:F({minWidth:"150px",fontSize:"0.9em"}),children:e.state.editingBuyerNote===o.order_id?"sale"===a?(0,A.jsxs)("div",{children:[(0,A.jsx)(T.Z.Control,{as:"textarea",rows:5,value:e.state.buyerNoteValue,onChange:e.handleBuyerNoteChange,style:{fontSize:"0.9em",width:"100%",resize:"vertical"}}),(0,A.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:8},children:[(0,A.jsx)(N.Z,{variant:"success",size:"sm",onClick:function(){return e.handleBuyerNoteSave(o.order_id)},style:{marginRight:8},children:(0,A.jsx)(xe.l_A,{})}),(0,A.jsx)(N.Z,{variant:"secondary",size:"sm",onClick:function(){return e.setState({editingBuyerNote:null})},children:(0,G.R6)(G.Nx.TEXT_CANCEL)})]})]}):(0,A.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",ga
1p:"4px"},children:[(0,A.jsx)(Ve.Z,{value:o.buyer_note,markdown:!0===e.getGeneralConfig()[He.oS],maxImageHeight:150}),o.buyer_note&&(0,A.jsx)("span",{onClick:function(){return e.handleCopyToClipboard(o.buyer_note,"Ghi ch\xfa kh\xe1ch h\xe0ng")},style:{cursor:"pointer",fontSize:"14px",opacity:.7},title:"Copy ghi ch\xfa kh\xe1ch h\xe0ng",children:(0,A.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,A.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),(0,A.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})})]}):(0,A.jsxs)("div",{style:{display:"flex",alignItems:"flex-start"},children:[(0,A.jsx)(Ve.Z,{value:o.buyer_note,markdown:!0===e.getGeneralConfig()[He.oS],style:{flex:1}}),(0,A.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[o.buyer_note&&(0,A.jsx)("span",{onClick:function(){return e.handleCopyToClipboard(o.buyer_note,"Ghi ch\xfa kh\xe1ch h\xe0ng")},style:{cursor:"pointer",fontSize:"14px",opacity:.7},title:"Copy ghi ch\xfa kh\xe1ch h\xe0ng",children:(0,A.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,A.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),(0,A.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}),"sale"===a&&(0,A.jsx)(N.Z,{variant:"link",size:"sm",style:{boxShadow:"none",border:"none",background:"none",padding:"0 4px"},onClick:function(){return e.handleBuyerNoteEdit(o.order_id)},title:"S\u1eeda ghi ch\xfa kh\xe1ch",children:(0,A.jsx)(xe.fmQ,{})})]})]})}):null;case"sellerNote":return u?(0,A.jsx)("td",{rowSpan:c,"data-column":"sellerNote",style:F({minWidth:"150px",fontSize:"0.9em"}),children:e.state.editingNote===o.order_id?"sale"===a?(0,A.jsxs)("div",{children:[(0,A.jsx)(T.Z.Control,{as:"textarea",rows:5,value:e.state.noteValue,onChange:e.handleNoteChange,style:{fontSize:"0.9em",width:"100%",resize:"vertical"}}),(0,A.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:8},children:[(0,A.jsx)(N.Z,{variant:"success",size:"sm",onClick:function(){return e.handleNoteSave(o.order_id)},style:{marginRight:8},children:(0,A.jsx)(xe.l_A,{})}),(0,A.jsx)(N.Z,{variant:"secondary",size:"sm",onClick:function(){return e.setState({editingNote:null})},children:(0,G.R6)(G.Nx.TEXT_CANCEL)})]})]}):(0,A.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:"4px"},children:[(0,A.jsx)(Ve.Z,{value:o.seller_note,markdown:!0===e.getGeneralConfig()[He.oS]}),o.seller_note&&(0,A.jsx)("span",{onClick:function(){return e.handleCopyToClipboard(o.seller_note,"Ghi ch\xfa nh\xe2n vi\xean")},style:{cursor:"pointer",fontSize:"14px",opacity:.7},title:"Copy ghi ch\xfa nh\xe2n vi\xean",children:(0,A.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,A.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),(0,A.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})})]}):(0,A.jsxs)("div",{style:{display:"flex",alignItems:"flex-start"},children:[(0,A.jsx)(Ve.Z,{value:o.seller_note,markdown:!0===e.getGeneralConfig()[He.oS],style:{flex:1}}),(0,A.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[o.seller_note&&(0,A.jsx)("span",{onClick:function(){return e.handleCopyToClipboard(o.seller_note,"Ghi ch\xfa nh\xe2n vi\xean")},style:{cursor:"pointer",fontSize:"14px",opacity:.7},title:"Copy ghi ch\xfa nh\xe2n vi\xean",children:(0,A.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,A.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),(0,A.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}),"sale"===a&&(0,A.jsx)(N.Z,{variant:"link",size:"sm",style:{boxShadow:"none",border:"none",background:"none",padding:"0 4px"},onClick:function(){return e.handleNoteEdit(o.order_id)},title:"S\u1eeda ghi ch\xfa",children:(0,A.jsx)(xe.fmQ,{})})]})]})}):null;case"fulfillNote":return u?(0,A.jsx)("td",{rowSpan:c,"data-column":"fulfillNote",style:F({minWidth:"150px",fontSize:"0.9em"}),children:e.state.editingFulfillNote===o.order_id?"fulfill"===a?(0,A.jsxs)("div",{children:[(0,A.jsx)(T.Z.Control,{as:"textarea",rows:5,value:e.state.fulfillNoteV
1alue,onChange:e.handleFulfillNoteChange,style:{fontSize:"0.9em",width:"100%",resize:"vertical"}}),(0,A.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:8},children:[(0,A.jsx)(N.Z,{variant:"success",size:"sm",onClick:function(){return e.handleFulfillNoteSave(o.order_id)},style:{marginRight:8},children:(0,A.jsx)(xe.l_A,{})}),(0,A.jsx)(N.Z,{variant:"secondary",size:"sm",onClick:function(){return e.setState({editingFulfillNote:null})},children:(0,G.R6)(G.Nx.TEXT_CANCEL)})]})]}):(0,A.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:"4px"},children:[(0,A.jsx)(Ve.Z,{value:o.fulfill_note,markdown:!0===e.getGeneralConfig()[He.oS]}),o.fulfill_note&&(0,A.jsx)("span",{onClick:function(){return e.handleCopyToClipboard(o.fulfill_note,"Fulfill Note")},style:{cursor:"pointer",fontSize:"14px",opacity:.7},title:"Copy fulfill note",children:(0,A.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,A.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),(0,A.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})})]}):(0,A.jsxs)("div",{style:{display:"flex",alignItems:"flex-start"},children:[(0,A.jsx)(Ve.Z,{value:o.fulfill_note,markdown:!0===e.getGeneralConfig()[He.oS],style:{flex:1}}),(0,A.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[o.fulfill_note&&(0,A.jsx)("span",{onClick:function(){return e.handleCopyToClipboard(o.fulfill_note,"Fulfill Note")},style:{cursor:"pointer",fontSize:"14px",opacity:.7},title:"Copy fulfill note",children:(0,A.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,A.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),(0,A.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}),"fulfill"===a&&(0,A.jsx)(N.Z,{variant:"link",size:"sm",style:{boxShadow:"none",border:"none",background:"none",padding:"0 4px"},onClick:function(){return e.handleFulfillNoteEdit(o.order_id)},title:"S\u1eeda fulfill note",children:(0,A.jsx)(xe.fmQ,{})})]})]})}):null;case"estDelivery":return u?(0,A.jsx)("td",{rowSpan:c,style:F({}),children:o.est_delivery_date}):null;case"shippingAddress":return u?(0,A.jsx)("td",{rowSpan:c,"data-column":"shippingAddress",style:F({whiteSpace:"pre-line",fontSize:"0.9em",minWidth:"200px"}),children:e.state.editingShippingAddress===o.order_id?"sale"===a?(0,A.jsxs)("div",{children:[(0,A.jsx)(T.Z.Control,{as:"textarea",rows:5,value:e.state.shippingAddressValue,onChange:e.handleShippingAddressChange,style:{fontSize:"0.9em",width:"100%",resize:"vertical"}}),(0,A.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:8},children:[(0,A.jsx)(N.Z,{variant:"success",size:"sm",onClick:function(){return e.handleShippingAddressSave(o.order_id)},style:{marginRight:8},children:(0,A.jsx)(xe.l_A,{})}),(0,A.jsx)(N.Z,{variant:"secondary",size:"sm",onClick:function(){return e.setState({editingShippingAddress:null})},children:(0,G.R6)(G.Nx.TEXT_CANCEL)})]})]}):(0,A.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:"4px"},children:[(0,A.jsx)("span",{children:o.shipping_address||"-"}),o.shipping_address&&(0,A.jsx)("span",{onClick:function(){return e.handleCopyToClipboard(o.shipping_address,"\u0110\u1ecba ch\u1ec9 giao h\xe0ng")},style:{cursor:"pointer",fontSize:"14px",opacity:.7,alignSelf:"flex-start"},title:"Copy \u0111\u1ecba ch\u1ec9 giao h\xe0ng",children:(0,A.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,A.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),(0,A.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})})]}):(0,A.jsxs)("div",{style:{display:"flex",alignItems:"flex-start"},children:[(0,A.jsx)("span",{style:{flex:1},children:o.shipping_address||"-"}),(0,A.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[o.shipping_address&&(0,A.jsx)("span",{onClick:function(){return e.handleCopyToClipboard(o.shipping_address,"\u0110\u1ecba ch\u1ec9 giao h\xe0ng")},style:{cursor:"pointer",fontSize:"14px",opacity:.7,alignSelf:"flex-start"},title:"Copy \u0111\u1ecba ch\u1ec9 giao h\xe0ng",children:(0,A.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,A.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),(0,A.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}),"sale"===a&&(0,A.jsx)(N.Z,{variant:"link",size:"sm",style:{boxShadow:"none",border:"none",background:"none",padding:"0 4px"}
1,onClick:function(){return e.handleShippingAddressEdit(o.order_id)},title:"S\u1eeda \u0111\u1ecba ch\u1ec9 giao h\xe0ng",children:(0,A.jsx)(xe.fmQ,{})})]})]})}):null;case"email":return u?(0,A.jsx)("td",{rowSpan:c,style:F({fontSize:"0.9em"}),children:o.email}):null;case"ioss":return u?(0,A.jsx)("td",{rowSpan:c,style:F({fontSize:"0.9em"}),children:o.ioss||"-"}):null;case"available":return(0,A.jsxs)(f.Fragment,{children:[n.available&&o.status<13&&(0,A.jsx)("td",{style:F({}),children:"fulfill"===a?(0,A.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,A.jsxs)(T.Z.Select,{size:"sm",value:l.available||0,onChange:function(t){return e.handleAvailableChange(o.order_id,l.sku,t.target.value)},style:{width:"auto"},children:[(0,A.jsx)("option",{value:-1,children:(0,G.R6)(G.Nx.TEXT_AVAILABLE_PENDING)}),(0,A.jsx)("option",{value:0,children:(0,G.R6)(G.Nx.TEXT_AVAILABLE_OUT_OF_STOCK)}),(0,A.jsx)("option",{value:1,children:(0,G.R6)(G.Nx.TEXT_AVAILABLE_IN_STOCK)}),(0,A.jsx)("option",{value:2,children:(0,G.R6)(G.Nx.TEXT_AVAILABLE_RESERVED)})]}),1===l.available&&(0,A.jsx)(v.Z,{bg:"success",children:"\xa0"}),0===l.available&&(0,A.jsx)(v.Z,{bg:"danger",children:"\xa0"}),2===l.available&&(0,A.jsx)(v.Z,{bg:"warning",text:"dark",children:"\xa0"}),-1===l.available&&(0,A.jsx)(v.Z,{bg:"secondary",children:"\xa0"}),0!==l.available&&1!==l.available&&2!==l.available&&-1!==l.available&&(0,A.jsx)(v.Z,{bg:"dark",children:"\xa0"})]}):(0,A.jsxs)(A.Fragment,{children:[1===l.available&&(0,A.jsx)(v.Z,{bg:"success",children:(0,G.R6)(G.Nx.TEXT_AVAILABLE_IN_STOCK)}),0===l.available&&(0,A.jsx)(v.Z,{bg:"danger",children:(0,G.R6)(G.Nx.TEXT_AVAILABLE_OUT_OF_STOCK)}),2===l.available&&(0,A.jsx)(v.Z,{bg:"warning",text:"dark",children:(0,G.R6)(G.Nx.TEXT_AVAILABLE_RESERVED)}),-1===l.available&&(0,A.jsx)(v.Z,{bg:"secondary",children:(0,G.R6)(G.Nx.TEXT_AVAILABLE_PENDING)}),0!==l.available&&1!==l.available&&2!==l.available&&-1!==l.available&&(0,A.jsx)(v.Z,{bg:"dark",children:(0,G.R6)(G.Nx.TEXT_AVAILABLE_UNKNOWN)})]})}),n.available&&(0,A.jsx)("td",{style:F({}),children:"fulfill"===a?(0,A.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,A.jsxs)(T.Z.Select,{size:"sm",value:l.available,onChange:function(t){return e.handleAvailableChange(o.order_id,l.sku,parseInt(t.target.value,10))},style:{width:"auto"},children:[(0,A.jsx)("option",{value:1,children:(0,G.R6)(G.Nx.TEXT_AVAILABLE_IN_STOCK)}),(0,A.jsx)("option",{value:0,children:(0,G.R6)(G.Nx.TEXT_AVAILABLE_OUT_OF_STOCK)}),(0,A.jsx)("option",{value:2,children:(0,G.R6)(G.Nx.TEXT_AVAILABLE_RESERVED)}),(0,A.jsx)("option",{value:-1,children:(0,G.R6)(G.Nx.TEXT_AVAILABLE_PENDING)})]}),1===l.available&&(0,A.jsx)(v.Z,{bg:"success",children:"\xa0"}),0===l.available&&(0,A.jsx)(v.Z,{bg:"danger",children:"\xa0"}),2===l.available&&(0,A.jsx)(v.Z,{bg:"warning",text:"dark",children:"\xa0"}),-1===l.available&&(0,A.jsx)(v.Z,{bg:"secondary",children:"\xa0"}),0!==l.available&&1!==l.available&&2!==l.available&&-1!==l.available&&(0,A.jsx)(v.Z,{bg:"dark",children:"\xa0"})]}):(0,A.jsxs)(A.Fragment,{children:[1===l.available&&(0,A.jsx)(v.Z,{bg:"success",children:(0,G.R6)(G.Nx.TEXT_AVAILABLE_IN_STOCK)}),0===l.available&&(0,A.jsx)(v.Z,{bg:"danger",children:(0,G.R6)(G.Nx.TEXT_AVAILABLE_OUT_OF_STOCK)}),2===l.available&&(0,A.jsx)(v.Z,{bg:"warning",text:"dark",children:(0,G.R6)(G.Nx.TEXT_AVAILABLE_RESERVED)}),-1===l.available&&(0,A.jsx)(v.Z,{bg:"secondary",children:(0,G.R6)(G.Nx.TEXT_AVAILABLE_PENDING)}),0!==l.available&&1!==l.available&&2!==l.available&&-1!==l.available&&(0,A.jsx)(v.Z,{bg:"dark",children:(0,G.R6)(G.Nx.TEXT_AVAILABLE_UNKNOWN)})]})})]});case"shippingCenterDate":return u?(0,A.jsx)("td",{rowSpan:c,style:F({whiteSpace:"nowrap"}),children:o.shipping_center_date?V()(o.shipping_center_date).format("DD/MM/YYYY HH:mm"):"-"}):null;case"shippingCenterName":return u?(0,A.jsx)("td",{rowSpan:c,style:F({whiteSpace:"nowrap"}),children:function(){var t=(0,U.fL)(e.props.currentCompany,e.props.publicPartners),r=o.shipping_center_name||"",n=t.find((function(e){return e.value===r}));return e.canEditShippingCenterName(o)?(0,A.jsxs)(T.Z.Select,{size:"sm",value:r,onChange:function(t){var r=t.target.value,n={order_id:o.order_id,shop_id:o.shop_id,shipping_center_name:r||null,perform_by_team:e.getPerformByTeam()};e.props.updateOrders([n],{isUpdated:!0}).then((function(){e.loadOrders()})).catch((function(t){console.error("Error updating shipping center name:",t),e.handleShowToast("C\u1eadp nh\u1eadt T\xean \u0110VVC th\u1ea5t b\u1ea1i!","danger")}))},style:{minWidth:"120px"},children:[(0,A.jsx)("option",{value:"",children:"-"}),t.map((function(e){return(0,A.jsx)("option",{value:e.value,children:e.label},e.value)}))]}):(null===n||void 0===n?void 0:n.label)||r||"-"}()}):null;case"shippingLabelBoughtDate":return u?(0,A.jsx)("td",{rowSpan:c,style:F({whiteSpace:"nowrap"}),children:o.shipping_label_bought_date?V()(o.shipping_label_bought_date).format("DD/MM/YYYY HH:mm"):"-"}):null;case"shippingLabelCode":return u?(0,A.jsx)("td",{rowSpan:c,style:F({whiteSpace:"nowrap"}),children:o.shpping_label_code||o.shipping_label_code||"-"}):null;case"action":var ee=e.getGeneralConfig(),te=(0,He.YV)(ee[He.zf]),re=e.isIncrementalChildOrder(o);return u?(0,A.jsx)(qe,{targetPage:a,order:o,rowSpan:c,mergeFz:F,showAction:function(e){return!(re&&te.has(e))},flags:{splitOrderEnabled:!0===ee[He.j6],cloneOrderEnabled:!0===ee[He.Sk],cloneChildOrderEnabled:!0===ee[He.p8],colorModeEnabled:e.isOrderColorModeEnabled(),canViewMetadata:e.canViewMetadataInAction()},handlers:{onEdit:e.handleEditOrderOnly,onAddListing:e.handleAddListingToOrder,onAddColor:function(t){return e.handleOpenColorPickerForOrder(t,null)},onClone:e.handleCloneOrder,onCloneChild:e.handleCloneChildOrder,onRndDone:e.handleShowRndDoneModal,onPrint:e.handlePrintOrderLabel,onOpenDetail:function(t){return e.setState({showOrderDetailModal:!0,orderDetailId:t.order_id})},onViewLogs:e.handleViewLogs,onViewMetadata:e.handleViewMetadata,onOpenCustomAlbum:e.handleOpenOrCreateOrderCustomAlbum,onSplitOrder:e.handleShowSplitOrderModal}}):null;default:return null}},$e=r(25281),Je=r(53285),et={"000006":"SGB","000007":"VP","000025":"THE",VIETTEL_POST:"VP",
1SGB:"SGB",THE:"THE"},tt=function(e){var t=e.type,r=e.ordersToFulfill,n=e.helpers;return"shipping"===t?function(e,t){var r=t.formatMonthlyIdToHuman,n=t.formatOrderIdToHuman,a=e.map((function(e){return e.listings.map((function(t){var a,i;return"\n            <tr>\n              <td>".concat(V()(e.order_date).format("DD/MM/YYYY"),"</td>\n              <td>").concat(r(e.monthly_id)||"-","</td>\n              <td>").concat(n(e.order_id),"</td>\n              <td>").concat(e.shop_name,"</td>\n              <td>").concat(e.customer_name,"</td>\n              <td>").concat(t.sku,'</td>\n              <td>\n                <img src="').concat(null===(a=t.img_url)||void 0===a?void 0:a.replace("75x75","120x120"),'" alt="').concat(t.title||"",'" class="product-image" />\n              </td>\n              <td>').concat((null===(i=t.title)||void 0===i?void 0:i.length)>40?"".concat(t.title.substring(0,40),"..."):t.title||"-","</td>\n              <td>").concat(t.size||"-","</td>\n              <td>").concat(e.buyer_note||"-","</td>\n              <td>").concat(e.seller_note||"-","</td>\n              <td>").concat(e.shipping_address||"-","</td>\n              <td>").concat(t.current_cell_code||"-","</td>\n              <td>").concat(e.ioss||"-","</td>\n              <td style={{ whiteSpace: 'nowrap' }}>").concat(e.shipping_center_date?V()(e.shipping_center_date).format("DD/MM/YYYY HH:mm"):"-","</td>\n            </tr>\n          ")})).join("")})).join("");return"\n    <html>\n      <head>\n        <title>".concat((0,G.R6)(G.Nx.TEXT_SHIPPABLE_ORDERS),"</title>\n        <style>\n          table { width: 100%; border-collapse: collapse; }\n          th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }\n          th { background-color: #f2f2f2; }\n          .product-image { width: 150px; height: 150px; object-fit: cover; display: block; margin: 0 auto; }\n          @media print { .product-image { max-width: 150px; max-height: 150px; } }\n        </style>\n      </head>\n      <body>\n        <h2>").concat((0,G.R6)(G.Nx.TEXT_SHIPPABLE_ORDERS),"</h2>\n        <div><strong>").concat((0,G.R6)(G.Nx.TEXT_TOTAL_ORDERS),": ").concat(e.length,"</strong></div>\n        <table>\n          <thead>\n            <tr>\n              <th>").concat((0,G.R6)(G.Nx.TEXT_ORDER_DATE),"</th>\n              <th>").concat((0,G.R6)(G.Nx.TEXT_MONTHLY_ID),"</th>\n              <th>").concat((0,G.R6)(G.Nx.TEXT_ORDER_ID),"</th>\n              <th>").concat((0,G.R6)(G.Nx.TEXT_SHOP),"</th>\n              <th>").concat((0,G.R6)(G.Nx.TEXT_CUSTOMER),"</th>\n              <th>").concat((0,G.R6)(G.Nx.TEXT_SKU),"</th>\n              <th>").concat((0,G.R6)(G.Nx.TEXT_IMAGE),"</th>\n              <th>").concat((0,G.R6)(G.Nx.TEXT_NAME),"</th>\n              <th>").concat((0,G.R6)(G.Nx.TEXT_SIZE),"</th>\n              <th>").concat((0,G.R6)(G.Nx.TEXT_BUYER_NOTE),"</th>\n              <th>").concat((0,G.R6)(G.Nx.TEXT_USER_NOTE),"</th>\n              <th>").concat((0,G.R6)(G.Nx.TEXT_ADDRESS),"</th>\n              <th>").concat((0,G.R6)(G.Nx.TEXT_CELL_CODE),"</th>\n              <th>").concat((0,G.R6)(G.Nx.TEXT_IOSS),"</th>\n              <th>").concat((0,G.R6)(G.Nx.TEXT_SHIPPING_CENTER_DATE),"</th>\n            </tr>\n          </thead>\n          <tbody>\n            ").concat(a,"\n          </tbody>\n        </table>\n      </body>\n    </html>\n  ")}(r.filter((function(e){return e.listings.length>0&&e.listings.every((function(e){return 1===e.available||2===e.available}))})),n):"warehouse"===t||"outofstock"===t?function(e,t,r){var n=r.formatMonthlyIdToHuman,a={};"warehouse"===t?e.filter((function(e){return e.listings.length>0&&e.listings.every((function(e){return 1===e.available||2===e.available}))})).forEach((function(e){e.listings.forEach((function(t){var r="".concat(t.sku,"-").concat(t.size,"-").concat(t.current_cell_code);a[r]||(a[r]={sku:t.sku,size:t.size,quantity:0,cell:t.current_cell_code,monthlyIds:new Set}),a[r].quantity+=1,a[r].monthlyIds.add(e.monthly_id)}))})):e.forEach((function(e){e.listings.filter((function(e){return 0===e.available})).forEach((function(t){var r="".concat(t.sku,"-").concat(t.size,"-").concat(t.current_cell_code);a[r]||(a[r]={sku:t.sku,size:t.size,quantity:0,cell:t.current_cell_code,monthlyIds:new Set}),a[r].quantity+=1,a[r].monthlyIds.add(e.monthly_id)}))}));var i=Object.values(a).sort((function(e,t){return e.sku===t.sku?(e.size||"").localeCompare(t.size||""):e.sku.localeCompare(t.sku)})),o=i.reduce((function(e,t){return e+t.quantity}),0),l=i.map((function(e){return"\n        <tr>\n          <td>".concat(e.sku,"</td>\n          <td>").concat(e.size,"</td>\n          <td>").concat(e.quantity,"</td>\n          <td>").concat(e.cell||"-","</td>\n          <td>").concat(Array.from(e.monthlyIds).map((function(e){return n(e)})).join(", "),"</td>\n        </tr>\n      ")})).join("");return"\n    <html>\n      <head>\n        <title>".concat((0,G.R6)("warehouse"===t?G.Nx.TEXT_WAREHOUSE_LAMPS:G.Nx.TEXT_OUT_OF_STOCK_LAMPS),"</title>\n        <style>\n          body { font-family: Arial, sans-serif; ").concat("warehouse"===t?"font-size: 28px;":""," }\n          table { width: 100%; border-collapse: collapse; margin-top: 20px; }\n          th, td { border: 1px solid #ddd; padding: ").concat("warehouse"===t?"12px":"8px","; text-align: left; }\n          th { background-color: #f5f5f5; ").concat("warehouse"===t?"font-size: 32px;":""," }\n          ").concat("warehouse"===t?"td { font-size: 28px; }":"","\n          .total { font-weight: bold; margin-top: 10px; ").concat("warehouse"===t?"font-size: 30px;":""," }\n          ").concat("warehouse"===t?"h2 { font-size: 36px; }":"","\n        </style>\n      </head>\n      <body>\n        <h2>").concat((0,G.R6)("warehouse"===t?G.Nx.TEXT_WAREHOUSE_LAMPS:G.Nx.TEXT_OUT_OF_STOCK_LAMPS),'</h2>\n        <div class="total">').concat((0,G.R6)(G.Nx.TEXT_TOTAL_LAMPS),": ").concat(o,"</div>\n        <table>\n          <thead>\n            <tr>\n              <th>").concat((0,G.R6)(G.Nx.TEXT_SKU),"</th>\n              <th>").concat((0,G.R6)(G.Nx.TEXT_SIZE),"</th>\n              <th>").concat((0,G.R6)(G.Nx.TEXT_QUANTITY),"</th>\n              <th>").concat((0,G.R6)(G.Nx.TEXT_CELL_CODE),"</th>\n              <th>").concat((0,G.R6)(G.Nx.TEXT_MONTHLY_ID),"</th>\n            </tr>\n          </thead>\n          <tbody>\n            ").concat(l,"\n          </tbody>\n        </table>\n      </body>\n    </html>\n  ")}(r,t,n):"allfulfill"===t?function(e,t){var r=t.formatMonthlyIdToHuman,n=e.map((function(e){var t=e.listings[0]||{},n=r(e.monthly_id);return"\n        <tr>\n          <td>".concat(e.shop_name||"-","</td>\n          <td>").concat(n||"-","</td>\n          <td>").concat(e.customer_name||"-","</td>\n          <td><b>").concat(t.sku||"-","</b></td>\n          <td><b>").concat(t.size||"-","</b></td>\n        </tr>\n      ")})).join("");return"\n    <html>\n      <head>\n        <title>
1All Orders to Fulfill</title>\n        <style>\n          table { width: 100%; border-collapse: collapse; }\n          th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }\n          th { background-color: #f2f2f2; font-size: 36px; }\n          td { font-size: 28px; height: 180px; text-align: center; }\n          tr { height: 150px; }\n          b { font-weight: bold; }\n        </style>\n      </head>\n      <body>\n        <table>\n          <tbody>\n            ".concat(n,"\n          </tbody>\n        </table>\n      </body>\n    </html>\n  ")}(r,n):""},rt=function(){var e=(0,l.Z)((0,o.Z)().mark((function e(t,r){var n,a,i;return(0,o.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.apiUrl,a=r.token,i=r.domain,e.abrupt("return",Promise.all(t.map(function(){var e=(0,l.Z)((0,o.Z)().mark((function e(t){var r,l,s,d,c,u,h;return(0,o.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(l=null===(r=t.metadata)||void 0===r?void 0:r.short_url_fulfill)){e.next=3;break}return e.abrupt("return",(0,m.Z)((0,m.Z)({},t),{},{_short_url:l}));case 3:return e.prev=3,d="https://".concat(i,"/admin/orders/order-detail/").concat(t.order_id,"?show_sidebar=false&ref_fulfill=true"),e.next=7,fetch("".concat(n,"/api/system/qr/create"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(a)},body:JSON.stringify({url:d,label:"Order #".concat(t.order_id)})});case 7:return c=e.sent,e.next=10,c.json();case 10:if(u=e.sent,!(h=null===u||void 0===u||null===(s=u.data)||void 0===s?void 0:s.shortUrl)){e.next=14;break}return e.abrupt("return",(0,m.Z)((0,m.Z)({},t),{},{_short_url:h}));case 14:e.next=18;break;case 16:e.prev=16,e.t0=e.catch(3);case 18:return e.abrupt("return",(0,m.Z)((0,m.Z)({},t),{},{_short_url:null}));case 19:case"end":return e.stop()}}),e,null,[[3,16]])})));return function(t){return e.apply(this,arguments)}}())));case 2:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),nt=function(e){var t=e.listings||[];return 0===t.length?"":(t[0].sku||"").toUpperCase()},at=function(e){var t=(e.listings||[]).length;if(function(e,t){return(e.listings||[]).some((function(e){return(e.sku||"").toUpperCase().includes(t.toUpperCase())}))}(e,"BOX"))return"B";if(1===t){var r=nt(e);return r.includes("MICA")?"A1":r.includes("3D")?"A2":"A3"}return"C"},it=function(e,t){var r=t.formatMonthlyIdToHuman,n=t.getShopDisplayName,a=e.map((function(e){return(0,m.Z)((0,m.Z)({},e),{},{category:at(e),firstSku:nt(e)})})),i={A1:[],A2:[],A3:[],B:[],C:[]};a.forEach((function(e){i[e.category]&&i[e.category].push(e)}
1)),Object.keys(i).forEach((function(e){i[e].sort((function(e,t){return(e.firstSku||"").localeCompare(t.firstSku||"")}))}));var o="",l=null,s=null;return["A1","A2","A3","B","C"].forEach((function(e){i[e].forEach((function(t){var a=t.firstSku||"",i=t.listings||[],d=i.length,c=null!==l&&l!==e||l===e&&null!==s&&s!==a,u=function(e){if(!e)return null;try{var t=$e.renderToStaticMarkup(f.createElement(Je.ZP,{value:e,size:100}));return"data:image/svg+xml;charset=utf-8,".concat(encodeURIComponent(t))}catch(r){return null}}(t._short_url),h=i.map((function(e,a){var i,o,l,s=e.quantity||1;return"\n            <tr>\n              ".concat(0===a?'<td rowspan="'.concat(d,'" style="width:110px;">\n                ').concat(u?'<img src="'.concat(u,'" style="width:100px;height:100px;display:block;margin:0 auto;" />'):"","\n              </td>"):"","\n              ").concat(0===a?'<td rowspan="'.concat(d,'" class="bold-large">\n                <div>').concat((l=t.shipping_center_name,l?et[l]||l:"-"),'</div>\n                <div style="font-size: 0.8em; font-weight: normal; margin-top: 4px;">').concat((o=function(e){if(!e)return"-";var t=e.split("\n").map((function(e){return e.trim()})).filter((function(e){return e}));if(0===t.length)return"-";var r=t[t.length-1];return/^[\d\s\-\+\(\)]+$/.test(r)&&t.length>1?t[t.length-2]:r}(t.shipping_address),o&&"-"!==o?o.split(" ").map((function(e){return e.length>8?e.substring(0,5)+"...":e})).join(" "):o),"</div>\n              </td>"):"","\n              ").concat(0===a?'<td rowspan="'.concat(d,'" class="bold-large">\n                <div>').concat(r(t.monthly_id)||"-",'</div>\n                <div style="font-size: 0.8em; font-weight: bold; margin-top: 4px;">').concat(n(t.shop_name)||"-","</div>\n              </td>"):"","\n              ").concat(0===a?'<td rowspan="'.concat(d,'" class="bold-large">').concat(function(e){if(!e)return"-";var t=e.split("\n")[0].trim();return t?t.length>15?t.substring(0,15)+"...":t:"-"}(t.shipping_address),"</td>"):"",'\n              <td class="bold-large">').concat((i=e.sku,(i||"-").replace(/^\d{6}_/,"")),'</td>\n              <td class="bold-large">').concat(e.size||"-",'</td>\n              <td class="bold-large">').concat(s,"</td>\n              <td>").concat(e.img_url?'<img src="'.concat(e.img_url.replace("75x75","120x120"),'" style="max-width:100px;max-height:100px;object-fit:cover;" />'):"-","</td>\n              ").concat(0===a?'<td rowspan="'.concat(d,'" class="note-column">').concat(t.buyer_note?t.buyer_note:"-","</td>"):"","\n              ").concat(0===a?'<td rowspan="'.concat(d,'" class="note-column">').concat(t.seller_note?t.seller_note:"-","</td>"):"","\n              ").concat(0===a?'<td rowspan="'.concat(d,'">').concat(t.order_date?V()(t.order_date).format("DD/MM/YYYY"):"-","</td>"):"","\n            </tr>\n          ")})).join("");o+='<tbody class="order-group '.concat(c?"page-break-before":"",'">').concat(h,"</tbody>"),l=e,s=a}))})),"\n    <html>\n      <head>\n        <title>Chi ti\u1ebft \u0111\u01a1n h\xe0ng</title>\n        <style>\n          @page { size: A4 landscape; }\n          body { font-family: Arial, sans-serif; }\n          table { width: 100%; border-collapse: collapse; }\n          th, td { border: 1px solid #bbb; padding: 4px; text-align: center; vertical-align: middle; }\n          th { background: #f5f5f5; }\n          tbody.order-group { page-break-inside: avoid; break-inside: avoid; }\n          tbody.order-group.page-break-before { page-break-before: always; break-before: page; }\n          tbody.order-group tr { min-height: 3.5cm; height: 3.5cm; }\n          tbody.order-group td { min-height: 3.5cm; }\n          img { display: block; margin: 0 auto; }\n          td[style*='white-space:pre-line;'] { text-align: left; }\n          .bold-large { font-weight: bold; font-size: 24px; }\n          .note-column { width: 200px; max-width: 200px; font-size: 12px; word-wrap: break-word; }\n          th:nth-child(1), td:nth-child(1) { width: 110px; }\n          th:nth-child(6), td:nth-child(6) { width: 60px; max-width: 60px; }\n          th:nth-child(7), td:nth-child(7) { width: 40px; max-width: 40px; }\n          th:nth-child(11), td:nth-child(11) { width: 90px; max-width: 90px; font-size: 13px; }\n        </style>\n      </head>\n      <body>\n        <table>\n          <thead>\n            <tr>\n              <th>QR</th>\n              <th>\u0110VVC / N\u01af\u1edaC</th>\n              <th>M\xc3 \u0110\u01a0N / SHOP</th>\n              <th>KH\xc1CH H\xc0NG</th>\n              <th>SKU</th>\n              <th>SIZE</th>\n              <th>SL</th>\n              <th>\u1ea2NH</th>\n              <th>GHI CH\xda KH\xc1CH</th>\n              <th>GHI CH\xda NH\xc2N VI\xcaN</th>\n              <th>NG\xc0Y \u0110\u1eb6T H\xc0NG</th>\n            </tr>\n          </thead>\n          ".concat(o,"\n        </table>\n      </body>\n    </html>\n  ")},ot=r(91473),lt=r(9226),st=r(44714),dt=["primary","success","warning","danger","info","secondary","dark"],ct=["#6f42c1","#fd7e14","#20c997","#e83e8c","#0aa2c0","#6610f2","#d63384"];var ut=r(34018),ht=["child_products"],pt=["style"],gt=["_id"],mt=["_id"],ft=function e(t,r){return 0===r?t:e(r,t%r)},xt=function(e){(0,p.Z)(r,e);var t=(0,g.Z)(r);function r(){var e;(0,c.Z)(this,r);for(var u=arguments.length,p=new Array(u),g=0;g<u;g++)p[g]=arguments[g];return(e=t.call.apply(t,[this].concat(p))).state={loading:!1,dateFilter:"yesterday",selectedOrders:new Set,showEditModal:!1,currentListing:null,currentOrder:null,showTitleAndFilters:!0,mobileFiltersPanelOpen:!1,editForm:{sku:"",size:"",title:"",buyer_note:"",seller_note:"",priority:2,customer_name:"",email:"",shipping_address:"",order_date:new Date,added_reason:"ETSY_NEW_ORDER",deadline_fulfill_hours:""},isNewSize:!1,editingNote:null,noteValue:"",showConfigModal:!1,orderListConfigModalTab:"columns",orderDateFilterHiddenLocal:{},orderFilterHiddenLocal:{},columnWidths:{},isResizing:!1,resizingColumn:null,columnVisibility:{stt:!0,orderDate:!0,monthlyId:!0,orderId:!0,shop:!0,customer:!0,status:!0,priority:!0,startFulfill:!0,finishFulfill:!0,supervisorUser:!0,executorUser:!0,isUs:!0,sku:!0,inventory:!0,image:!0,title:!0,size:!0,quantity:!0,orderQtyFailed:!0,custom:!0,productCustomField1:!0,productCustomField2:!0,orderCustomFilter1:!0,orderCustomFilter2:!0,estimateGrossWeight:!0,realGrossWeight:!0,buyerNote:!0,sellerNote:!0,fulfillNote:!0,estDelivery:!0,shippingAddress:!0,email:!0,ioss:!0,available:!0,shippingCenterDate:!0,shippingCenterName:!0,shippingLabelBoughtDate:!0,shippingLabelCode:!0,action:!0}
1,showScanOrdersModal:!1,currentPage:1,itemsPerPage:parseInt(localStorage.getItem("orderItemsPerPage"))||20,totalCount:0,selectedBulkStatus:"",targetPage:"sale",showRndDoneModal:!1,rndNoteValue:"",rndOrderId:null,showSplitOrderModal:!1,splitOrderTarget:null,splitOrderQty:"",splitOrderMode:"split",splitOrderParentCode:null,splitOrderLoading:!1,printOrderLabel:null,sortBy:"monthly_id",sortOrder:"asc",shopFilter:localStorage.getItem("orderShopFilter_sale")||"All",statusFilter:localStorage.getItem("orderStatusFilter_sale")||"",disableStatusRestriction:"true"===localStorage.getItem("orderDisableStatusRestriction_sale"),isUsFilter:localStorage.getItem("orderIsUsFilter_sale")||"",shippingCenterNameFilter:localStorage.getItem("orderShippingCenterNameFilter_sale")||"",priorityFilter:localStorage.getItem("orderPriorityFilter_sale")||"",orderCustomFilter1:localStorage.getItem("orderCustomFilter1_sale")||"",orderCustomFilter2:localStorage.getItem("orderCustomFilter2_sale")||"",shippingCenterDateFrom:localStorage.getItem("orderShippingCenterDateFrom_sale")?new Date(localStorage.getItem("orderShippingCenterDateFrom_sale")):null,shippingCenterDateTo:localStorage.getItem("orderShippingCenterDateTo_sale")?new Date(localStorage.getItem("orderShippingCenterDateTo_sale")):null,showShippingCenterDateFilter:"true"===localStorage.getItem("orderShowShippingCenterDateFilter_sale"),keyword:localStorage.getItem("orderKeyword_sale")||"",executorUserFilter:"",executorUserSearch:"",executorUserDropdownOpen:!1,availableFilter:localStorage.getItem("orderAvailableFilter_fulfill")||"",showLogModal:!1,currentOrderLogs:[],isShowLatestLog:!0,isShowSystemInfo:!0,currentOrderForLog:null,logPagination:{currentPage:1,totalPages:1,totalCount:0,limit:100},productListLoaded:!1,showOrderDetailModal:!1,orderDetailId:null,cloneChildPromptOrder:null,cloneChildPromptCount:1,cloneChildSaving:!1,colorPickerOrder:null,colorPickerListingIndex:null,colorPickerActiveType:null,colorPickerSaving:!1,colorPickerPendingProduct:null,showCustomAlbumModal:!1,customAlbumUrl:"",customAlbumTitle:"",showFulfillLabelModal:!1,showToast:!1,toastMessage:"",toastVariant:"success",creatingOrderAlbum:!1,activeTab:"1",showAddOrderModal:!1,showMultipleOrderModal:!1,multipleOrderForm:{shop_name:"",order_date:new Date,added_reason:"ETSY_WARRANTY_ORDER",priority:2,buyer_note:"",seller_note:"",items:[{product_code:"",quantity:1}]},multipleOrderSaving:!1,showQuantityChangeModal:!1,selectedProductCode:"",selectedProductName:"",showMetadataModal:!1,selectedMetadata:null,selectedMetadataOrderId:null,newOrderForm:{shop_name:"",customer_name:"",email:"",shipping_address:"",buyer_note:"",seller_note:"",priority:2,added_reason:"ETSY_WARRANTY_ORDER",reference_code:"",ref_company_ids:"",order_date:new Date,listings:[{sku:"",size:"",title:"",img_url:"",custom_field_1:"",custom_field_2:""}]},extraShopOptions:[],currentListingIndex:null,isAddingListing:!1,logLevelFilter:"ALL",editingBuyerNote:null,buyerNoteValue:"",editingFulfillNote:null,fulfillNoteValue:"",editingRealGrossWeight:null,realGrossWeightValue:"",editingShippingAddress:null,shippingAddressValue:"",editMode:"listing",editListingIndex:null,showExportModal:!1,exportMode:"NORMAL",exportFailTargetStatus:"",exportItems:[],exportWarehouse:localStorage.getItem("orderExportWarehouse_fulfill")||"",exportNote:"",exportSaving:!1,exportViewProduct:"true"===localStorage.getItem("orderExportViewProduct_fulfill"),stickHeader:"false"!==localStorage.getItem("orderStickHeader_".concat(e.props.targetPage||"sale")),showCustomDateModal:!1,customStartDate:new Date,customEndDate:new Date,showAutoFulfillProgress:!1,autoFulfillProgress:0,autoFulfillTotal:0,autoFulfillCurrent:0,autoFulfillBatchSize:parseInt(localStorage.getItem("autoFulfillBatchSize"))||50,newOrderProductBundleFilter:function(){var e=localStorage.getItem("orderListNewOrderProductBundleFilter")||"all";return"other"===e?"single":e}(),newOrderProductTypeFilter:localStorage.getItem("orderListNewOrderProductTypeFilter")||"all",syncingParentOrderId:null,supervisorUserOptions:[],executorUserOptions:[],showListingImageModal:!1,listingImageForModal:null,fulfillStartFinis
1hTimeOnly:!1,orderListFrozenUntilKey:""},e.getRefCompanyIdSet=function(){var t,r=new Set;return String((null===(t=e.props.user)||void 0===t?void 0:t.ref_company_ids)||"").split(",").map((function(e){return e.trim()})).filter(Boolean).forEach((function(e){r.add(e),/^\d+$/.test(e)&&r.add(String(Number(e)))})),r},e.refCompanyMatches=function(e,t){var r=String(e||"").trim();return!!r&&(!!t.has(r)||/^\d+$/.test(r)&&t.has(String(Number(r))))},e.getMergedShopOptions=function(){var t=(0,U.E4)(e.props.currentCompany,e.props.publicPartners),r=e.state.extraShopOptions||[],n=new Map;t.forEach((function(e){return n.set(e.value,e)})),r.forEach((function(e){e&&e.value&&!n.has(e.value)&&n.set(e.value,e)}));var a=Array.from(n.values());if((0,st.ki)(e.props.user)){var i=e.getRefCompanyIdSet();a=a.filter((function(t){return e.refCompanyMatches(t.company_id,i)}))}return a},e.getShopOptions=function(){return e.getMergedShopOptions()},e.getGeneralConfig=function(){var t=e.props.currentCompany;return e._generalConfigCacheCompany===t&&e._generalConfigCache||(e._generalConfigCache=(0,He.Dm)(t),e._generalConfigCacheCompany=t),e._generalConfigCache},e.getSaleOrderStatusLimitEnabled=function(){return!0===e.getGeneralConfig()[He.$N]},e.applySaleStatusRestriction=function(){return!(0,st.ki)(e.props.user)&&e.getSaleOrderStatusLimitEnabled()&&!e.state.disableStatusRestriction},e.getFilterShippingCountryEnabled=function(){return!0===e.getGeneralConfig()[He.by]},e.getShowFilterFulfillEnabled=function(){return(0,ie._o)(e.props.currentCompany,e.getOrderListTargetPage())},e.parseOrderCustomFilterOptions=function(e){return null==e?[]:String(e).split(/\r?\n/).map((function(e){return e.trim()})).filter(Boolean).map((function(e){var t=e.indexOf(":"),r=(-1===t?e:e.slice(0,t)).trim(),n=(-1===t?r:e.slice(t+1)).trim();return r?{value:r,label:n||r}:null})).filter(Boolean)},e.getOrderCustomFilterMeta=function(t){var r=e.getGeneralConfig(),n={1:{enabledKey:He.YN,allLabelKey:He.N3,optionsKey:He.kc,multipleBadgesKey:He.mA,hiddenFilterKey:"orderCustomFilter1"},2:{enabledKey:He._u,allLabelKey:He.x9,optionsKey:He.pU,multipleBadgesKey:He.jO,hiddenFilterKey:"orderCustomFilter2"}}[t];if(!n)return{enabled:!1,options:[],allLabel:"T\u1ea5t c\u1ea3",multipleBadges:!1,hiddenFilterKey:""};var a=r[n.allLabelKey];return{enabled:!0===r[n.enabledKey],options:e.parseOrderCustomFilterOptions(r[n.optionsKey]),allLabel:String(a||"T\u1ea5t c\u1ea3").trim()||"T\u1ea5t c\u1ea3",multipleBadges:!0===r[n.multipleBadgesKey],hiddenFilterKey:n.hiddenFilterKey}},e.renderOrderCustomFilterSelectionBadge=function(e,t){var r;if(null===e||void 0===e||!e.multipleBadges||null===(r=e.options)||void 0===r||!r.length)return null;var n=null!=t?String(t):"";if(""===n)return null;var a=e.options.findIndex((function(e){return e.value===n}));if(a<0)return null;var i=e.options[a],o=function(e){var t=Math.max(0,e);return t<dt.length?{bg:dt[t]}:{style:{backgroundColor:ct[(t-dt.length)%ct.length],color:"#fff"}}}(a);return(0,A.jsx)(v.Z,(0,m.Z)((0,m.Z)({className:"fw-normal align-self-center",title:i.label},o.bg?{bg:o.bg}:{}),{},{style:(0,m.Z)((0,m.Z)({},{fontSize:"0.875rem",padding:"0.4rem 0.7rem",lineHeight:1.35,maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis"}),o.style),children:i.label}))},e.getProductTypeMetaForNewOrder=function(){var t=e.getGeneralConfig(),r=String(t[He.dn]||"T\u1ea5t c\u1ea3 Product Type").trim()||"T\u1ea5t c\u1ea3 Product Type";return{enabled:!0===t[He.il],options:e.parseOrderCustomFilterOptions(t[He.LW]),allLabel:r}},e.getOrderQtyFailedMeta=function(){var t=e.getGeneralConfig(),r=!0===t[He.e2],n=t[He.md],a=String(n||e.orderListHeaderLabel("orderQtyFailed")).trim()||e.orderListHeaderLabel("orderQtyFailed"),i=parseInt(t[He.Lx],10);return{enabled:r,label:a,dropdownMax:Number.isFinite(i)&&i>0?i:null}},e.isTruthyGeneralConfigFlag=function(e){if(!0===e||1===e)return!0;var t=String(null==e?"":e).trim().toLowerCase();return"true"===t||"1"===t||"yes"===t||"on"===t},e.getOrderProductCustomFieldMeta=function(t){var r=e.getGeneralConfig();return 1===t?{enabled:!0,enableCopy:e.isTruthyGeneralConfigFlag(r[He.hh]),label:e.orderListHeaderLabel("productCustomField1")}:{enabled:!0,enableCopy:!1,label:e.orderListHeaderLabel("productCustomField2")}},e.getOrderListTargetPage=function(){return e.props.targetPage||e.state.targetPage||"sale"},e.orderListIsDateFilterOptionHidden=function(t){var r,n,a,i=e.getOrderListTargetPage(),o=null===(r=e.props.currentCompany)||void 0===r||null===(n=r.metadata)||void 0===n||null===(a=n.configs)||void 0===a?void 0:a.orderList;if((0,ie.I0)(i,t,o))return!0;var l=e.state.orderDateFilterHiddenLocal;return!0===(null===l||void 0===l?void 0:l[t])},e.orderListIsFilterOptionHidden=function(t){var r,n,a,i,o=e.getOrderListTargetPage(),l=null===(r=e.props.currentCompany)||void 0===r||null===(n=r.metadata)||void 0===n||null===(a=n.configs)||void 0===a?void 0:a.orderList;return!!(0,ie.Xh)(o,t,l)||!0===(null===(i=e.state.orderFilterHiddenLocal)||void 0===i?void 0:i[t])},e.getFirstVisibleDateFilterKey=function(){return ie.dJ.find((function(t){return!e.orderListIsDateFilterOptionHidden(t)}))||"yesterday"},e.ensureDateFilterStillValid=function(){var t=e.state.dateFilter;if("custom_pick"!==t)if(e.orderListIsDateFilterOptionHidden(t)){var r=e.getFirstVisibleDateFilterKey();if(r!==t){var n=e.getOrderListTargetPage();localStorage.setItem("orderDateFilter_".concat(n),r),e.setState({dateFilter:r,currentPage:1,selectedOrders:new Set},(function(){e.updateURL({date_filter:r,page:1}),e.loadOrders()}))}else e.loadOrders()}else e.loadOrders()},e.getDateFilterOptionLabel=function(e){var t=V()().startOf("day");switch(e){case"today":return(0,G.R6)(G.Nx.TEXT_TODAY);case"yesterday":return(0,G.R6)(G.Nx.TEXT_YESTERDAY);case"this_week":return(0,G.R6)(G.Nx.TEXT_THIS_WEEK);case"last_week":return(0,G.R6)(G.Nx.TEXT_LAST_WEEK);case"month_0":return"Th\xe1ng ".concat(t.month()+1);case"month_1":return"Th\xe1ng ".concat(t.clone().subtract(1,"month").month()+1);case"month_2":return"Th\xe1ng ".concat(t.clone().subtract(2,"month").month()+1);case"last_sale":return(0,ie.Xv)();case"last_year":return(0,ie.LF)();case"year_0":return"N\u0103m ".concat(t.year());case"year_quarter_1":case"year_quarter_2":case"year_quarter_3":case"year_quarter_4":var r=parseInt(e.replace("year_quarter_",""),10);return"Qu\xfd ".concat(r);case"last_3_days":return"3 ng\xe0y";case"last_7_days":return"7 ng\xe0y";case"last_14_days":return"14 ng\xe0y";case"last_30_days":return"30 ng\xe0y tr\u01b0\u1edbc";case"last_60_days":return"60 ng\xe0y tr\u01b0\u1edbc";case"last_90_days":return"90 ng\xe0y tr\u01b0\u1edbc";
1case"custom":return"Tu\u1ef3 ch\u1ecdn";case"all":return(0,G.R6)(G.Nx.TEXT_ALL);default:return e}},e.renderDateFilterSelectOptions=function(){for(var t=e.state.dateFilter,r=V()().startOf("day"),n=[],a=Math.floor(r.month()/3)+1;a>=1;a-=1)n.push("year_quarter_".concat(a));var i=[["today","yesterday","this_week","last_week"],["month_0","month_1","month_2"],[].concat(n),["year_0","last_year","last_sale"],["last_3_days","last_7_days","last_14_days","last_30_days","last_60_days","last_90_days"],["custom"],["all"]],o=[],l=!1;return i.forEach((function(r){var n=r.filter((function(t){return!e.orderListIsDateFilterOptionHidden(t)}));0!==n.length&&(l&&o.push((0,A.jsx)("option",{disabled:!0,value:"__sep-".concat(r[0]),children:"\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"},"sep-".concat(r[0]))),n.forEach((function(r){if("custom"===r)return o.push((0,A.jsx)("option",{value:"custom",children:e.getDateFilterOptionLabel("custom")},"custom")),void("custom"===t&&o.push((0,A.jsx)("option",{value:"custom_pick",children:"Tu\u1ef3 ch\u1ecdn"},"custom_pick")));o.push((0,A.jsx)("option",{value:r,children:e.getDateFilterOptionLabel(r)},r))})),l=!0)})),0===o.length&&o.push((0,A.jsx)("option",{value:"yesterday",children:(0,G.R6)(G.Nx.TEXT_YESTERDAY)},"yesterday-fallback")),o},e.handleOrderDateFilterHiddenLocalToggle=function(t){var r,n,a,i=e.getOrderListTargetPage();(0,ie.I0)(i,t,null===(r=e.props.currentCompany)||void 0===r||null===(n=r.metadata)||void 0===n||null===(a=n.configs)||void 0===a?void 0:a.orderList)||e.setState((function(e){return{orderDateFilterHiddenLocal:(0,m.Z)((0,m.Z)({},e.orderDateFilterHiddenLocal),{},(0,d.Z)({},t,!e.orderDateFilterHiddenLocal[t]))}}))},e.handleOrderFilterHiddenLocalToggle=function(t){var r,n,a,i=e.getOrderListTargetPage();(0,ie.Xh)(i,t,null===(r=e.props.currentCompany)||void 0===r||null===(n=r.metadata)||void 0===n||null===(a=n.configs)||void 0===a?void 0:a.orderList)||e.setState((function(e){return{orderFilterHiddenLocal:(0,m.Z)((0,m.Z)({},e.orderFilterHiddenLocal),{},(0,d.Z)({},t,!e.orderFilterHiddenLocal[t]))}}))},e.updateURL=function(t){var r=new URLSearchParams(window.location.search);Object.entries(t).forEach((function(t){var n,a=(0,s.Z)(t,2),i=a[0],o=a[1];"target_page"===i&&null!==(n=e.props.query)&&void 0!==n&&n.target_page||(o?r.set(i,o):r.delete(i))}));var n="".concat(window.location.pathname,"?").concat(r.toString());window.history.pushState({},"",n)},e.getDateFilterValue=function(t){var r=V()().startOf("day"),n="",a="";switch(t){case"today":default:n=r.format("YYYY-MM-DD"),a=r.format("YYYY-MM-DD");break;case"yesterday":a=n=r.clone().subtract(1,"days").format("YYYY-MM-DD");break;case"this_week":n=r.clone().startOf("week").add(1,"days").format("YYYY-MM-DD"),a=r.format("YYYY-MM-DD");break;case"last_week":n=r.clone().subtract(1,"weeks").startOf("week").add(1,"days").format("YYYY-MM-DD"),a=r.clone().subtract(1,"weeks").endOf("week").add(1,"days").format("YYYY-MM-DD");break;case"month_0":var i=r.clone().startOf("month");n=i.format("YYYY-MM-DD"),a=i.clone().endOf("month").format("YYYY-MM-DD");break;case"month_1":var o=r.clone().subtract(1,"month").startOf("month");n=o.format("YYYY-MM-DD"),a=o.clone().endOf("month").format("YYYY-MM-DD");break;case"month_2":var l=r.clone().subtract(2,"month").startOf("month");n=l.format("YYYY-MM-DD"),a=l.clone().endOf("month").format("YYYY-MM-DD");break;case"last_sale":var s=(0,ie.Ru)();n=s.from,a=s.to;break;case"last_year":var d=(0,ie.lq)();n=d.from,a=d.to;break;case"year_quarter_1":case"year_quarter_2":case"year_quarter_3":case"year_quarter_4":var c=parseInt(String(t).replace("year_quarter_",""),10);if(c>=1&&c<=4){var u=r.year();n=V()().year(u).quarter(c).startOf("quarter").format("YYYY-MM-DD"),a=V()().year(u).quarter(c).endOf("quarter").format("YYYY-MM-DD")}break;case"year_0":var h=r.clone().startOf("year");n=h.format("YYYY-MM-DD"),a=h.clone().endOf("year").format("YYYY-MM-DD");break;case"last_3_days":n=r.clone().subtract(2,"days").format("YYYY-MM-DD"),a=r.format("YYYY-MM-DD");break;case"last_7_days":n=r.clone().subtract(6,"days").format("YYYY-MM-DD"),a=r.format("YYYY-MM-DD");break;case"last_14_days":n=r.clone().subtract(13,"days").format("YYYY-MM-DD"),a=r.format("YYYY-MM-DD");break;case"last_30_days":n=r.clone().subtract(30,"days").format("YYYY-MM-DD"),a=r.format("YYYY-MM-DD");break;case"last_60_days":n=r.clone().subtract(60,"days").format("YYYY-MM-DD"),a=r.format("YYYY-MM-DD");break;case"last_90_days":n=r.clone().subtract(90,"days").format("YYYY-MM-DD"),a=r.format("YYYY-MM-DD");break;
1case"custom":e.state.customStartDate&&e.state.customEndDate?(n=V()(e.state.customStartDate).format("YYYY-MM-DD"),a=V()(e.state.customEndDate).format("YYYY-MM-DD")):(n=r.format("YYYY-MM-DD"),a=r.format("YYYY-MM-DD"));break;case"all":n="",a=""}return{from:n,to:a}},e.getDateRangeDisplay=function(){var t=e.state.dateFilter,r=e.getDateFilterValue(t),n=r.from,a=r.to;return n&&a?n===a?"(".concat(V()(n).format("DD/MM/YYYY"),")"):"(".concat(V()(n).format("DD/MM/YYYY")," - ").concat(V()(a).format("DD/MM/YYYY"),")"):"(T\u1ea5t c\u1ea3)"},e.loadOrders=function(){e.setState({loading:!0});var t=e.getDateFilterValue(e.state.dateFilter),r=t.from,n=t.to,a=e.props.targetPage||e.props.target_page||e.state.targetPage,i={order_date_from:r,order_date_to:n,currentPage:e.state.currentPage,itemsPerPage:e.state.itemsPerPage,target_page:a};if("rnd"===a)i.status=Y.vl.PROCESSING_CUSTOM_ORDER;else if(""!==e.state.statusFilter)if("mix"===e.state.statusFilter&&"fulfill"===a)i.status=[Y.vl.FULFILL_PROCESSING,Y.vl.PACKAGING,Y.vl.PACKAGING_DONE,Y.vl.WAITING_FOR_SHIPPING_LABEL].join(",");else if("inprogress"===e.state.statusFilter)i.status=[Y.vl.FULFILL_PROCESSING,Y.vl.PACKAGING,Y.vl.PACKAGING_DONE].join(",");else if("processing_sale"===e.state.statusFilter)i.status=[Y.vl.WAIT_FOR_PROCESSING,Y.vl.PROCESSING,Y.vl.PROCESSING_CUSTOM_ORDER,Y.vl.SALE_5,Y.vl.SALE_6,Y.vl.SALE_7,Y.vl.SALE_8,Y.vl.SALE_9].join(",");else if("processing_fulfill"===e.state.statusFilter){var o=Array.isArray(e.props.orderStatusConfig)?e.props.orderStatusConfig:[];i.status=o.filter((function(e){var t=Number(e.code);return Number.isFinite(t)&&t>=10&&t<=14})).map((function(e){return e.enum})).join(",")}else i.status=e.state.statusFilter;else if("fulfill"===a){var l=[Y.vl.FULFILL_PROCESSING,Y.vl.PACKAGING,Y.vl.PACKAGING_DONE,Y.vl.WAITING_FOR_SHIPPING_LABEL,Y.vl.SHIPPED_TO_SHIPPING_CENTER,Y.vl.SHIPPED_TO_CUSTOMER,Y.vl.CUSTOMS_HOLD,Y.vl.RETURNED_TO_SHIPPING_WAREHOUSE,Y.vl.RETURNED_TO_SHIPPING_CENTER,Y.vl.RETURNED_TO_WAREHOUSE,Y.vl.COMPLETED,Y.vl.REFUNDED];i.status=l.join(",")}e.state.shopFilter&&"All"!==e.state.shopFilter&&(i.shop_name=e.state.shopFilter),e.getFilterShippingCountryEnabled()&&""!==e.state.isUsFilter&&(i.is_us=e.state.isUsFilter),""!==e.state.shippingCenterNameFilter&&(i.shipping_center_name=e.state.shippingCenterNameFilter),""!==e.state.priorityFilter&&(i.priority=e.state.priorityFilter);var s=e.getOrderCustomFilterMeta(1),d=e.getOrderCustomFilterMeta(2),c=s.enabled&&!e.orderListIsFilterOptionHidden(s.hiddenFilterKey),u=d.enabled&&!e.orderListIsFilterOptionHidden(d.hiddenFilterKey);c&&""!==e.state.orderCustomFilter1&&(i.custom_filter_1=e.state.orderCustomFilter1),u&&""!==e.state.orderCustomFilter2&&(i.custom_filter_2=e.state.orderCustomFilter2),e.state.showShippingCenterDateFilter&&(e.state.shippingCenterDateFrom&&(i.shipping_center_date_from=V()(e.state.shippingCenterDateFrom).format("YYYY-MM-DD")),e.state.shippingCenterDateTo&&(i.shipping_center_date_to=V()(e.state.shippingCenterDateTo).format("YYYY-MM-DD")));var h=!0===e.getGeneralConfig()[He.y4],p=h?"monthly_id":"order_id";if(e.state.sortBy){var g="monthly_id"!==e.state.sortBy||h?e.state.sortBy:"order_id";i.sort=("asc"===e.state.sortOrder?"":"-")+g}else i.sort=p;e.state.keyword&&(i.keyword=e.state.keyword),("fulfill"===a||"rnd"===a||"sale"===a)&&e.getShowFilterFulfillEnabled()&&e.state.executorUserFilter&&(i.executor_user=e.state.executorUserFilter),e.props.getOrders(i).then((function(t){var r,n,a,i=null!==(r=null!==(n=null===t||void 0===t||null===(a=t.payload)||void 0===a?void 0:a.totalCount)&&void 0!==n?n:null===t||void 0===t?void 0:t.totalCount)&&void 0!==r?r:0;e.setState({totalCount:i})})).catch((function(e){console.error("Error loading orders:",e)})).finally((function(){e.setState({loading:!1})}))},e.handleDateFilterChange=function(t){var r=t.target.value;"custom_pick"!==r?(localStorage.setItem("orderDateFilter_".concat(e.state.targetPage),r),"custom"===r?e.setState({dateFilter:r,showCustomDateModal:!0,selectedOrders:new Set}):e.setState({dateFilter:r,selectedOrders:new Set},(function(){e.updateURL({date_filter:r,page:1}),e.loadOrders()}))):e.setState({showCustomDateModal:!0,selectedOrders:new Set})},e.handleCustomRangeClick=function(){e.setState({showCustomDateModal:!0,dateFilter:"custom"})},e.handleDateRangeChange=function(t){var r=(0,s.Z)(t,2),n=r[0],a=r[1];e.setState({customStartDate:n,customEndDate:a})},e.handleApplyDateRange=function(){var t=e.state,r=t.customStartDate,n=t.customEndDate,a=t.targetPage;r&&n&&(localStorage.setItem("orderCustomStartDate_".concat(a),r.toISOString()),localStorage.setItem("orderCustomEndDate_".concat(a),n.toISOString()),localStorage.setItem("orderDateFilter_".concat(a),"custom"),e.setState({showCustomDateModal:!1,dateFilter:"custom",selectedOrders:new Set},(function(){e.updateURL({date_filter:"custom",page:1}),e.loadOrders()})))},e.handleCloseCustomDatePicker=function(){var t=localStorage.getItem("orderDateFilter_".concat(e.state.targetPage))||"yesterday";e.setState({showCustomDateModal:!1,dateFilter:"custom"!==t?t:"yesterday"})},e.handleShopFilterChange=function(t){var r=t.target.value;localStorage.setItem("orderShopFilter_".concat(e.state.targetPage),r),e.setState({shopFilter:r,currentPage:1,selectedOrders:new Set},(function(){r&&"All"!==r?e.updateURL({shop_name:r,page:1}):e.updateURL({shop_name:"",page:1}),e.loadOrders()}))},e.handleDisableStatusRestrictionChange=function(t){var r=t.target.checked;localStorage.setItem("orderDisableStatusRestriction_".concat(e.state.targetPage),r?"true":"false"),e.setState({disableStatusRestriction:r,selectedOrders:new Set})},e.handleStatusFilterChange=function(t){var r=t.target.value;localStorage.setItem("orderStatusFilter_".concat(e.state.targetPage),r),e.setState({statusFilter:r,currentPage:1,selectedOrders:new Set},(function(){r?e.updateURL({status:r,page:1}):e.updateURL({status:"",page:1}),e.loadOrders()}))},e.handleIsUsFilterChange=function(t){var r=t.target.value;localStorage.setItem("orderIsUsFilter_".concat(e.state.targetPage),r),e.setState({isUsFilter:r,currentPage:1,selectedOrders:new Set},(function(){r?e.updateURL({is_us:r,page:1}):e.updateURL({is_us:"",page:1}),e.loadOrders()}))},e.handleShippingCenterNameFilterChange=function(t){var r=t.target.value;localStorage.setItem("orderShippingCenterNameFilter_".concat(e.state.targetPage),r),e.setState({shippingCenterNameFilter:r,currentPage:1,selectedOrders:new Set},(function(){r?e.updateURL({shipping_center_name:r,page:1}):e.updateURL({shipping_center_name:"",page:1}),e.loadOrders()}))},e.handlePriorityFilterChange=function(t){var r=t.target.value;localStorage.setItem("orderPriorityFilter_".concat(e.state.targetPage),r),e.setState({priorityFilter:r,currentPage:1,selectedOrders:new Set},(function(){r?e.updateURL({priority:r,page:1}):e.updateURL({priority:"",page:1}),e.loadOrders()}))},e.handleOrderCustomFilter1Change=function(t){var r=t.target.value;localStorage.setItem("orderCustomFilter1_".concat(e.state.targetPage),r),e.setState({orderCustomFilter1:r,currentPage:1,selectedOrders:new Set},(function(){e.updateURL({custom_filter_1:r,page:1}),e.loadOrders()}))},e.handleOrderCustomFilter2Change=function(t){var r=t.target.value;localStorage.setItem("orderCustomFilter2_".concat(e.state.targetPage),r),e.setState({orderCustomFilter2:r,currentPage:1,selectedOrders:new Set},(function(){e.updateURL({custom_filter_2:r,page:1}),e.loadOrders()}))},e.handleOrderInlineCustomFilterChange=function(t,r,n){if(t&&r){var a=(0,d.Z)({order_id:t},r,n);e.props.updateOrders([a],{isUpdated:!0}).then((function(){e.loadOrders()})).catch((function(t){console.error("Error updating ".concat(r,":"),t),e.handleShowToast("C\u1eadp nh\u1eadt ".concat(r," th\u1ea5t b\u1ea1i"),"danger")}))}},e.handleShippingCenterDateFromChange=function(t){localStorage.setItem("orderShippingCenterDateFrom_".concat(e.state.targetPage),t?t.toISOString():""),e.setState({shippingCenterDateFrom:t,currentPage:1,selectedOrders:new Set},(function(){e.updateURL({shipping_center_date_from:t?V()(t).format("YYYY-MM-DD"):"",page:1}),e.loadOrders()}))},e.handleShippingCenterDateToChange=function(t){localStorage.setItem("orderShippingCenterDateTo_".concat(e.state.targetPage),t?t.toISOString():""),e.setState({shippingCenterDateTo:t,currentPage:1,selectedOrders:new Set},(function(){e.updateURL({shipping_center_date_to:t?V()(t).format("YYYY-MM-DD"):"",page:1}),e.loadOrders()}))},e.handleShowShippingCenterDateFilterChange=function(t){var r=t.target.checked;localStorage.setItem("orderShowShippingCenterDateFilter_".concat(e.state.targetPage),r),r?e.setState({showShippingCenterDateFilter:r,currentPage:1,selectedOrders:new Set},(function(){e.loadOrders()})):(localStorage.setItem("orderShippingCenterDateFrom_".concat(e.state.targetPage),""),localStorage.setItem("orderShippingCenterDateTo_".concat(e.state.targetPage),""),e.setState({showShippingCenterDateFilter:r,shippingCenterDateFrom:null,shippingCenterDateTo:null,currentPage:1,selectedOrders:new Set},(function(){e.loadOrders()})))},e.handleAvailableFilterChange=function(t){var r=t.target.value;"fulfill"===e.state.targetPage&&(localStorage.setItem("orderAvailableFilter_fulfill",r),e.setState({availableFilter:r,selectedOrders:new Set}))},e.handleEditFormChange=function(t){var r=t.target,n=r.name,a=r.value;if("sku"===n){var i=(e.props.products||[]).find((function(e){return e.sku_code===a}));e.setState({editForm:(0,m.Z)((0,m.Z)({},e.state.editForm),{},{sku:a,title:i?i.product_name:""})})}else e.setState({editForm:(0,m.Z)((0,m.Z)({},e.state.editForm),{},(0,d.Z)({},n,a))})},e.handleSizeChange=function(t){var r=t.target.value;"new"===r?e.setState({isNewSize:!0,editForm:(0,m.Z)((0,m.Z)({},e.state.editForm),{},{size:""})}):e.setState({isNewSize:!1,editForm:(0,m.Z)((0,m.Z)({},e.state.editForm),{},{size:r})})},e.getPerformByTeam=function(){switch(e.state.targetPage){case"rnd":return"RND";case"sale":default:return"SALE";case"fulfill":return"FULFILL"}},e.loadOrderListTeamUsers=(0,l.Z)((0,o.Z)().mark((function t(){var r,n,a,i;return(0,o.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,Promise.all([e.props.ensureUsersByGroup(_.VR),e.props.ensureUsersByGroup(_.IY)]);case 3:r=t.sent,n=(0,s.Z)(r,2),a=n[0],i=n[1],e.setState({supervisorUserOptions:Array.isArray(a)?a:[],executorUserOptions:Array.isArray(i)?i:[]}),t.next=13;break;case 10:t.prev=10,t.t0=t.catch(0),console.error("OrderList loadOrderListTeamUsers:",t.t0);case 13:case"end":return t.stop()}}),t,null,[[0,10]])}))),e.getIncrementalChildOrdersInList=function(t){var r=e.props.orders,n=void 0===r?[]:r,a=null===t||void 0===t?void 0:t.order_id;if(!a)return[];var i=String(a).split("_"),o=null;(3===i.length||2===i.length)&&(o="".concat(i[0],"_").concat(i[1],"_"));var l=new Set,s=[];
1return n.forEach((function(e){if(e&&e.order_id&&e.order_id!==a){var t=!1;if(e.metadata&&String(e.metadata.parent_order_id||"")===String(a))t=!0;else if(o&&String(e.order_id).startsWith(o)){var r=e.order_id.slice(o.length),n=parseInt(r,10);!Number.isNaN(n)&&n>0&&(t=!0)}t&&!l.has(e.order_id)&&(l.add(e.order_id),s.push(e))}})),s},e.buildTeamUserSelectOptions=function(e,t){var r=String(t||"").trim(),n=e||[],a=n.some((function(e){return e&&e.username===r})),i=[(0,A.jsx)("option",{value:"",children:"\u2014"},"__empty")];return r&&!a&&i.push((0,A.jsx)("option",{value:r,children:r},"__orphan-".concat(r))),n.forEach((function(e){e&&e.username&&i.push((0,A.jsx)("option",{value:e.username,children:e.fullname||e.username},e.username))})),i},e.handleSupervisorUserChange=function(t,r){var n=e.props.orders.find((function(e){return e.order_id===t}));if(n){var a=null!=r?String(r).trim():"",i=e.getPerformByTeam(),o=function(e){return{order_id:e.order_id,shop_id:e.shop_id,supervisor_user:a,perform_by_team:i}},l=[o(n)];e.isIncrementalParentOrder(n)&&e.getIncrementalChildOrdersInList(n).forEach((function(e){return l.push(o(e))})),e.props.updateOrders(l,{isUpdated:!0}).then((function(){e.handleShowToast(e.isIncrementalParentOrder(n)?"\u0110\xe3 c\u1eadp nh\u1eadt Supervisor cho \u0111\u01a1n cha v\xe0 c\xe1c \u0111\u01a1n con":"\u0110\xe3 c\u1eadp nh\u1eadt Supervisor")})).catch((function(t){console.error(t),e.handleShowToast("Kh\xf4ng c\u1eadp nh\u1eadt \u0111\u01b0\u1ee3c Supervisor","danger")}))}},e.handleExecutorUserChange=function(t,r){var n=e.props.orders.find((function(e){return e.order_id===t}));if(n){var a=null!=r?String(r).trim():"",i=e.getPerformByTeam(),o=function(e){return{order_id:e.order_id,shop_id:e.shop_id,executor_user:a,perform_by_team:i}},l=[o(n)];e.isIncrementalParentOrder(n)&&e.getIncrementalChildOrdersInList(n).forEach((function(e){return l.push(o(e))})),e.props.updateOrders(l,{isUpdated:!0}).then((function(){e.handleShowToast(e.isIncrementalParentOrder(n)?"\u0110\xe3 c\u1eadp nh\u1eadt Executor cho \u0111\u01a1n cha v\xe0 c\xe1c \u0111\u01a1n con":"\u0110\xe3 c\u1eadp nh\u1eadt Executor")})).catch((function(t){console.error(t),e.handleShowToast("Kh\xf4ng c\u1eadp nh\u1eadt \u0111\u01b0\u1ee3c Executor","danger")}))}},e.handleListingQtyFailedChange=function(t,r,n){if(t&&Array.isArray(t.listings)){var a=Math.max(0,parseInt(n,10)||0),i=t.listings.map((function(e,t){return t===r?(0,m.Z)((0,m.Z)({},e),{},{qty_failed:a}):e})),o={order_id:t.order_id,shop_id:t.shop_id,perform_by_team:e.getPerformByTeam(),listings:i};e.props.updateOrders([o],{isUpdated:!0}).then((function(){e.handleShowToast("\u0110\xe3 c\u1eadp nh\u1eadt s\u1ed1 l\u01b0\u1ee3ng l\u1ed7i")})).catch((function(t){console.error("Error updating qty_failed:",t),e.handleShowToast("Kh\xf4ng c\u1eadp nh\u1eadt \u0111\u01b0\u1ee3c s\u1ed1 l\u01b0\u1ee3ng l\u1ed7i","danger")}))}},e.handleEditSubmit=function(){var t=e.state,r=t.currentOrder,n=t.currentListing,o=t.editForm,l=t.currentListingIndex,s=t.isAddingListing,d=t.editMode,c=t.editListingIndex;if(r){var u=!0===e.getGeneralConfig()[He.CN],h=String(r.shop_name||"").trim(),p=function(e){return u?(0,m.Z)((0,m.Z)({},e),{},{customer_name:h,email:"",shipping_address:"",ioss:"",reference_code:""}):e},g={order_id:r.order_id,shop_id:r.shop_id,perform_by_team:e.getPerformByTeam()},f="order"===d&&!s&&null===c,x=!0===e.getGeneralConfig()[He.e2];if(f){var _=String(o.order_id||"").trim();(0,st.ki)(e.props.user)&&_&&_!==r.order_id&&(g.order_id=_,r._id&&(g._id=r._id)),g.buyer_note=o.buyer_note,g.seller_note=o.seller_note,g.priority=o.priority,g.customer_name=o.customer_name,g.email=o.email,g.shipping_address=o.shipping_address,o.order_date&&(g.order_date=o.order_date.toISOString()),g.ioss=o.ioss,o.added_reason&&(g.added_reason=o.added_reason);var v=parseFloat(o.deadline_fulfill_hours);g.deadline_fulfill_hours=isNaN(v)||""===o.deadline_fulfill_hours?null:v,Object.assign(g,p(g))}else{var y;if(s){var S=e.props.products.find((function(e){return e.product_code===n.product_code}));if(!S)return void e.handleShowToast("Invalid product selection","danger");var b=(0,m.Z)({sku:S.sku_code,size:S.size,title:S.product_name,img_url:S.images&&S.images.length>0?S.images[0].image_link:"",product_code:S.product_code,custom_field_1:S.custom_field_1||"",custom_field_2:S.custom_field_2||"",quantity:o.quantity},x?{qty_failed:0}:{}),C=e.isTruthySesProductFlag(S.is_parent_product)?e.mergeListingChildProductsFromCatalog(b,S):b;y=[].concat((0,i.Z)(r.listings),[C])}else y=r.listings.map((function(t,r){if(r===l){var i=e.props.products.find((function(e){return e.product_code===n.product_code}));if(!i)return e.handleShowToast("Invalid product selection","danger"),t;var s=(0,m.Z)((0,m.Z)({},t),{},{sku:i.sku_code,size:i.size,title:i.product_name,img_url:i.images&&i.images.length>0?i.images[0].image_link:t.img_url,product_code:i.product_code,custom_field_1:i.custom_field_1||"",custom_field_2:i.custom_field_2||"",quantity:o.quantity});if(e.isTruthySesProductFlag(i.is_parent_product))return e.mergeListingChildProductsFromCatalog(s,i);s.child_products;return(0,a.Z)(s,ht)}return t}));if(g.listings=y,g.metadata=e.buildOrderMetadataWithParentCustomField(r.metadata,y),"order"===d||!d){g.buyer_note=o.buyer_note,g.seller_note=o.seller_note,g.priority=o.priority,g.customer_name=o.customer_name,g.email=o.email,g.shipping_address=o.shipping_address,o.order_date&&(g.order_date=o.order_date.toISOString()),g.ioss=o.ioss,o.added_reason&&(g.added_reason=o.added_reason);var j=parseFloat(o.deadline_fulfill_hours);g.deadline_fulfill_hours=isNaN(j)||""===o.deadline_fulfill_hours?null:j,Object.assign(g,p(g))}}e.props.updateOrders([g]).then((function(){e.setState({showEditModal:!1,isAddingListing:!1,currentListingIndex:null,editMode:null}),e.loadOrders(),e.handleShowToast(s?"Listing added successfully":"Order updated successfully")}
1)).catch((function(t){console.error("Error updating order:",t),e.handleShowToast(s?"Failed to add listing":"Failed to update order","danger")}))}},e.handleDeleteListing=function(){var t=e.state,r=t.currentOrder,n=t.currentListing;if(r)if(r.listings.length>1){var a=r.listings.filter((function(e){return!(e.sku===n.sku&&e.size===n.size)})),i={order_id:r.order_id,shop_id:r.shop_id,listings:a,perform_by_team:e.getPerformByTeam()};e.props.updateOrders([i]).then((function(){e.setState({showEditModal:!1}),e.loadOrders(),e.handleShowToast("Listing deleted successfully")})).catch((function(t){console.error("Error deleting listing:",t),e.handleShowToast("Failed to delete listing","danger")}))}else{var o={order_id:r.order_id,shop_id:r.shop_id,is_deleted:!0,perform_by_team:e.getPerformByTeam()};e.props.updateOrders([o]).then((function(){e.setState({showEditModal:!1}),e.loadOrders(),e.handleShowToast("Order deleted successfully")})).catch((function(t){console.error("Error deleting order:",t),e.handleShowToast("Failed to delete order","danger")}))}},e.handleDeleteOrder=function(){var t=e.state.currentOrder;if(t){var r=e.formatOrderIdToHuman(t.order_id)||t.order_id||"";if(window.confirm("B\u1ea1n c\xf3 ch\u1eafc mu\u1ed1n x\xf3a \u0111\u01a1n ".concat(r,"?\nThao t\xe1c n\xe0y s\u1ebd \u1ea9n \u0111\u01a1n kh\u1ecfi danh s\xe1ch."))){var n={order_id:t.order_id,shop_id:t.shop_id,is_deleted:!0,perform_by_team:e.getPerformByTeam()};e.props.updateOrders([n]).then((function(){e.setState({showEditModal:!1}),e.loadOrders(),e.handleShowToast("Order deleted successfully")})).catch((function(t){console.error("Error deleting order:",t),e.handleShowToast("Failed to delete order","danger")}))}}},e.handleOrderSelect=function(t){var r=new Set(e.state.selectedOrders),n=r.has(t);n?r.delete(t):r.add(t);var a=(e.props.orders||[]).find((function(e){return e.order_id===t}));a&&e.getIncrementalChildOrdersInList(a).forEach((function(e){null!==e&&void 0!==e&&e.order_id&&(n?r.delete(e.order_id):r.add(e.order_id))}));e.setState({selectedOrders:r})},e.handleBulkStatusChange=function(t){e.setState({selectedBulkStatus:t.target.value})},e.handleBulkStatusApply=function(){if(e.state.selectedBulkStatus&&0!==e.state.selectedOrders.size){var t=e.props.targetPage||e.state.targetPage,r=e.props,n=r.orders,a=void 0===n?[]:n,i=r.orderStatusConfig,o=Array.from(e.state.selectedOrders),l=null;if("sale"===t&&i&&Array.isArray(i)){var s=i.find((function(t){return t.enum===e.state.selectedBulkStatus}));s&&(l=s.code)}var d=o,c=0;if("sale"===t&&null!==l&&l>=10&&e.applySaleStatusRestriction()){var u=V()().startOf("day"),h=[];o.forEach((function(e){var t=a.find((function(t){return t.order_id===e}));if(t&&t.order_date){var r=V()(t.order_date),n=("string"===typeof t.priority?parseInt(t.priority):t.priority)>=3;r.isSame(u,"day")&&!n?c++:h.push(e)}else h.push(e)})),d=h,c>0&&e.handleShowToast("".concat(c," \u0111\u01a1n c\xf3 ng\xe0y \u0111\u1eb7t h\xe0ng l\xe0 h\xf4m nay \u0111\xe3 \u0111\u01b0\u1ee3c lo\u1ea1i tr\u1eeb (kh\xf4ng th\u1ec3 chuy\u1ec3n sang status >= 10)"),"warning")}if(0!==d.length){var p=d.map((function(t){return{order_id:t,status:e.state.selectedBulkStatus,perform_by_team:e.getPerformByTeam()}}));e.props.updateOrders(p).then((function(){e.setState({selectedOrders:new Set,selectedBulkStatus:""}),e.loadOrders();var t=c>0?"\u0110\xe3 c\u1eadp nh\u1eadt ".concat(d.length," \u0111\u01a1n (").concat(c," \u0111\u01a1n \u0111\xe3 \u0111\u01b0\u1ee3c lo\u1ea1i tr\u1eeb)"):"Updated status for ".concat(d.length," orders successfully");e.handleShowToast(t)})).catch((function(t){console.error("Error bulk updating orders:",t),e.handleShowToast("Failed to update orders in bulk","danger")}))}else e.handleShowToast("Kh\xf4ng c\xf3 \u0111\u01a1n n\xe0o h\u1ee3p l\u1ec7 \u0111\u1ec3 c\u1eadp nh\u1eadt","warning")}},e.canBulkDelete=function(){var t=e.props.user||{},r=String(t.username||"").trim().toLowerCase(),n=t.user_groups||t.group_ids||t.groups||[],a=Array.isArray(n)?n.map((function(e){return String(e||"").trim().toLowerCase()})):[];return"sroot"===r||a.some((function(e){return"root"===e||e.includes("super root")}))},e.handleBulkDelete=function(){if(e.canBulkDelete()&&0!==e.state.selectedOrders.size){var t=e.props.orders,r=void 0===t?[]:t,n=Array.from(e.state.selectedOrders);if(window.confirm("B\u1ea1n c\xf3 ch\u1eafc mu\u1ed1n x\xf3a ".concat(n.length," \u0111\u01a1n \u0111\xe3 ch\u1ecdn?\nThao t\xe1c n\xe0y s\u1ebd \u1ea9n \u0111\u01a1n kh\u1ecfi danh s\xe1ch."))){var a=n.map((function(t){var n=r.find((function(e){return e.order_id===t}));return{order_id:t,shop_id:null===n||void 0===n?void 0:n.shop_id,is_deleted:!0,perform_by_team:e.getPerformByTeam()}}));e.props.updateOrders(a).then((function(){e.setState({selectedOrders:new Set,selectedBulkStatus:""}),e.loadOrders(),e.handleShowToast("\u0110\xe3 x\xf3a ".concat(n.length," \u0111\u01a1n"))})).catch((function(t){console.error("Error bulk deleting orders:",t),e.handleShowToast("Failed to delete orders","danger")}))}}},e.handleNoteEdit=function(t){var r;e.setState({editingNote:t,noteValue:(null===(r=e.props.orders.find((function(e){return e.order_id===t})))||void 0===r?void 0:r.seller_note)||""})},e.handleNoteChange=function(t){e.setState({noteValue:t.target.value})},e.handleNoteSave=function(t){var r=e.props.orders.find((function(e){return e.order_id===t}));if(r){var n={order_id:r.order_id,shop_id:r.shop_id,seller_note:e.state.noteValue,perform_by_team:e.getPerformByTeam()};e.props.updateOrders([n],{isUpdated:!0}).then((function(){e.setState({editingNote:null})})).catch((function(e){console.error("Error updating note:",e),alert("Failed to update note. See console for details.")}))}},e.handleConfigToggle=function(){e.setState({showConfigModal:!e.state.showConfigModal})},e.handleToggleTitleAndFilters=function(){e.setState({showTitleAndFilters:!e.state.showTitleAndFilters})},e.handleShowListingImageModal=function(t){null!==t&&void 0!==t&&t.img_url&&e.setState({showListingImageModal:!0,listingImageForModal:t})},e.handleCloseListingImageModal=function(){e.setState({showListingImageModal:!1,listingImageForModal:null})},e.handleListingImageModalKeyDown=function(t){e.state.showListingImageModal&&"Escape"===t.key&&(t.preventDefault(),e.handleCloseListingImageModal())},e.handleCopyToClipboard=function(){var t=(0,l.Z)((0,o.Z)().mark((function t(r,n){return(0,o.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,navigator.clipboard.writeText(r);case 3:e.setState({showToast:!0,toastMessage:"\u0110\xe3 copy ".concat(n,": ").concat(r.length>50?r.substring(0,50)+"...":r)}),t.next=10;break;case 6:t.prev=6,t.t0=t.catch(0),console.error("Failed to copy text: ",t.t0),e.setState({showToast:!0,toastMessage:"L\u1ed7i khi copy ".concat(n)});case 10:case"end":return t.stop()}}),t,null,[[0,6]])})));return function(e,r){return t.apply(this,arguments)}}(),e.handleColumnToggle=function(t){e.setState((function(r){var n=e.props.targetPage||r.targetPage||"sale",a=(0,m.Z)((0,m.Z)({},r.columnVisibility),{},(0,d.Z)({},t,!r.columnVisibility[t]));return localStorage.setItem("orderColumnVisibility_".concat(n),JSON.stringify(a)),{columnVisibility:a}}))},e.handleSaveConfig=function(){var t=e.getOrderListTargetPage();localStorage.setItem("orderColumnVisibility_".concat(t),JSON.stringify(e.state.columnVisibility)),localStorage.setItem("orderDateFilterHidden_".concat(t),JSON.stringify(e.state.orderDateFilterHiddenLocal)),localStorage.setItem("orderFilterHidden_".concat(t),JSON.stringify(e.state.orderFilterHiddenLocal)),localStorage.setItem("autoFulfillBatchSize",e.state.autoFulfillBatchSize.toString()),localStorage.setItem("orderListFulfillStartFinis
1hTimeOnly_".concat(t),e.state.fulfillStartFinishTimeOnly?"true":"false");var r=null!=e._orderListLastEffectiveFrozenUntilKey?e._orderListLastEffectiveFrozenUntilKey:e.state.orderListFrozenUntilKey||"";localStorage.setItem("orderListFrozenUntilColumn_".concat(t),r),e.setState({showConfigModal:!1,orderListFrozenUntilKey:r},(function(){return e.ensureDateFilterStillValid()}))},e.handleFulfillStartFinishTimeOnlyToggle=function(){e.setState((function(e){return{fulfillStartFinishTimeOnly:!e.fulfillStartFinishTimeOnly}}))},e.handleOrderListFrozenUntilKeyChange=function(t){e.setState({orderListFrozenUntilKey:t||""})},e.resolveOrderListFrozenCountFromUntilKey=function(e,t,r){if(!r||"string"!==typeof r)return 0;var n=("rnd"!==e?["checkbox"].concat((0,i.Z)(t)):(0,i.Z)(t)).indexOf(r);return n>=0?n+1:0},e.handleMouseDown=function(t,r){t.preventDefault(),t.stopPropagation(),e.setState({isResizing:!0,resizingColumn:r});var n=t.clientX,a=e.state.columnWidths[r]||150,i=function(t){t.preventDefault();var i=Math.max(50,a+(t.clientX-n));e.setState((function(e){return{columnWidths:(0,m.Z)((0,m.Z)({},e.columnWidths),{},(0,d.Z)({},r,i))}}))};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",i),document.addEventListener("mouseup",(function t(r){r.preventDefault(),e.setState({isResizing:!1,resizingColumn:null});var n=e.state.targetPage;localStorage.setItem("orderColumnWidths_".concat(n),JSON.stringify(e.state.columnWidths)),document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",t),document.body.style.cursor="",document.body.style.userSelect=""}))},e.getColumnWidth=function(t){return e.state.columnWidths[t]||{checkbox:50,stt:60,orderDate:120,monthlyId:120,orderId:150,shop:120,customer:100,status:120,priority:100,startFulfill:155,finishFulfill:155,isUs:100,sku:120,image:80,title:200,size:80,quantity:80,custom:120,productCustomField1:150,productCustomField2:150,estimateGrossWeight:120,realGrossWeight:120,buyerNote:180,sellerNote:180,fulfillNote:180,estDelivery:120,shippingAddress:200,email:150,ioss:100,available:120,shippingCenterDate:150,shippingCenterName:150,shippingLabelBoughtDate:150,shippingLabelCode:150,action:100,orderCustomFilter1:200,orderCustomFilter2:200,inventory:120}[t]||150},e.getVisibleOrderListColumnKeys=function(e,t){var r,a=[],i=(0,n.Z)(e);try{for(i.s();!(r=i.n()).done;){var o=r.value;t.colVisTable[o]&&(("orderCustomFilter1"!==o||t.orderCustomFilter1Meta.enabled)&&("orderCustomFilter2"!==o||t.orderCustomFilter2Meta.enabled)&&a.push(o))}}catch(l){i.e(l)}finally{i.f()}return a},e.buildOrderListFrozenLayout=function(t,r,n){for(var a="rnd"!==t?["checkbox"].concat((0,i.Z)(r)):(0,i.Z)(r),o=Math.min(Math.max(0,parseInt(n,10)||0),a.length),l={},s={},d=0,c=0;c<o;c++){var u=a[c],h=e.getColumnWidth(u),p=o-c+140,g=o-c+8,m=c===o-1?"2px 0 4px -1px rgba(0,0,0,0.12)":void 0;l[u]={position:"sticky",left:d,top:0,zIndex:p,backgroundColor:"#f8f9fa",boxShadow:m},s[u]={position:"sticky",left:d,zIndex:g,boxShadow:m},d+=h}return{headerStyles:l,bodyStyles:s,maxFrozen:a.length}},e.orderListMergeFrozenBodyStyle=function(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=null===(r=t.orderListFrozenBodyStyleByKey)||void 0===r?void 0:r[e];if(!a)return n;var i=t.rowBackgroundColor||"#fff",o=(0,m.Z)((0,m.Z)({},a),n);return void 0!==n.backgroundColor&&"inherit"!==n.backgroundColor?o.backgroundColor=n.backgroundColor:o.backgroundColor=i,o},e.renderResizableHeader=function(t,r){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=i.style,l=(0,a.Z)(i,pt),s=null===(n=e._orderListFrozenHeaderStyles)||void 0===n?void 0:n[t],d=e.getColumnWidth(t),c=s?(0,m.Z)((0,m.Z)((0,m.Z)({},s),o),{},{width:d}):(0,m.Z)({width:d,position:"relative"},o);return(0,A.jsxs)("th",(0,m.Z)((0,m.Z)({style:c},l),{},{children:[r,(0,A.jsx)("div",{className:"resize-handle",onMouseDown:function(r){return e.handleMouseDown(r,t)}})]}))},e.renderOrderListConfigurableColumnHeader=function(t,r){var n,a,i=r.colVisTable,o=r.sortBy,l=r.sortOrder,s=r.orderQtyFailedMeta,d=r.orderCustomFilter1Meta,c=r.orderCustomFilter2Meta;if(!i[t])return null;switch(t){case"stt":return e.renderResizableHeader("stt",e.orderListHeaderLabel("stt"),{style:{textAlign:"center"}});case"orderDate":return e.renderResizableHeader("orderDate",e.orderListHeaderLabel("orderDate"));case"monthlyId":return e.renderResizableHeader("monthlyId",(0,A.jsxs)(A.Fragment,{children:[e.orderListHeaderLabel("monthlyId"),"monthly_id"===e.state.sortBy&&(0,A.jsx)("span",{children:"asc"===e.state.sortOrder?" \u25b2":" \u25bc"})]}),{style:{cursor:"pointer"},onClick:function(){return e.handleSort("monthly_id")}});case"orderId":return e.renderResizableHeader("orderId",e.orderListHeaderLabel("orderId"));case"sku":return e.renderResizableHeader("sku",e.orderListHeaderLabel("sku"));case"image":return e.renderResizableHeader("image",e.orderListHeaderLabel("image"));case"title":return e.renderResizableHeader("title",e.orderListHeaderLabel("title"));case"size":return e.renderResizableHeader("size",(0,A.jsxs)(A.Fragment,{children:[e.orderListHeaderLabel("size")," ","size"===o&&(l<0?"\u2193":"\u2191")]}),{style:{cursor:"pointer"},onClick:function(){return e.handleSort("size")}});case"quantity":return e.renderResizableHeader("quantity",(0,A.jsxs)(A.Fragment,{children:[e.orderListHeaderLabel("quantity")," ","quantity"===o&&(l<0?"\u2193":"\u2191")]}),{style:{cursor:"pointer"},onClick:function(){return e.handleSort("quantity")}});case"orderQtyFailed":return e.renderResizableHeader("orderQtyFailed",s.label,{style:{color:"#dc3545"}});case"shop":return e.renderResizableHeader("shop",e.orderListHeaderLabel("shop"));case"customer":return e.renderResizableHeader("customer",e.orderListHeaderLabel("customer"));case"status":return e.renderResizableHeader("status",e.orderListHeaderLabel("status"));case"priority":return e.renderResizableHeader("priority",(0,A.jsxs)(A.Fragment,{children:[e.orderListHeaderLabel("priority"),"priority"===e.state.sortBy&&(0,A.jsx)("span",{children:"asc"===e.state.sortOrder?" \u25b2":" \u25bc"})]}),{style:{cursor:"pointer"},onClick:function(){return e.handleSort("priority")}});case"startFulfill":return e.renderResizableHeader("startFulfill",e.orderListHeaderLabel("startFulfill"));case"finishFulfill":return e.renderResizableHeader("finishFulfill",e.orderListHeaderLabel("finishFulfill"));case"supervisorUser":return e.renderResizableHeader("supervisorUser",e.orderListHeaderLabel("supervisorUser"));case"executorUser":return e.renderResizableHeader("executorUser",e.orderListHeaderLabel("executorUser"));case"isUs":return e.renderResizableHeader("isUs",e.orderListHeaderLabel("isUs"),{style:{textAlign:"center"}});case"inventory":return e.renderResizableHeader("inventory",e.orderListHeaderLabel("inventory"));
1case"custom":return e.renderResizableHeader("custom",e.orderListHeaderLabel("custom"));case"productCustomField1":return e.renderResizableHeader("productCustomField1",(null===(n=r.orderProductCustomField1Meta)||void 0===n?void 0:n.label)||e.orderListHeaderLabel("productCustomField1"));case"productCustomField2":return e.renderResizableHeader("productCustomField2",(null===(a=r.orderProductCustomField2Meta)||void 0===a?void 0:a.label)||e.orderListHeaderLabel("productCustomField2"));case"orderCustomFilter1":return d.enabled?e.renderResizableHeader("orderCustomFilter1",e.orderListHeaderLabel("orderCustomFilter1")):null;case"orderCustomFilter2":return c.enabled?e.renderResizableHeader("orderCustomFilter2",e.orderListHeaderLabel("orderCustomFilter2")):null;case"estimateGrossWeight":return e.renderResizableHeader("estimateGrossWeight",(0,A.jsxs)(A.Fragment,{children:[e.orderListHeaderLabel("estimateGrossWeight")," ","estimate_gross_weight"===o&&(l<0?"\u2193":"\u2191")]}),{style:{cursor:"pointer"},onClick:function(){return e.handleSort("estimate_gross_weight")}});case"realGrossWeight":return e.renderResizableHeader("realGrossWeight",(0,A.jsxs)(A.Fragment,{children:[e.orderListHeaderLabel("realGrossWeight")," ","real_gross_weight"===o&&(l<0?"\u2193":"\u2191")]}),{style:{cursor:"pointer"},onClick:function(){return e.handleSort("real_gross_weight")}});case"buyerNote":return e.renderResizableHeader("buyerNote",e.orderListHeaderLabel("buyerNote"));case"sellerNote":return e.renderResizableHeader("sellerNote",e.orderListHeaderLabel("sellerNote"));case"fulfillNote":return e.renderResizableHeader("fulfillNote",e.orderListHeaderLabel("fulfillNote"));case"estDelivery":return e.renderResizableHeader("estDelivery",e.orderListHeaderLabel("estDelivery"));case"shippingAddress":return e.renderResizableHeader("shippingAddress",e.orderListHeaderLabel("shippingAddress"));case"email":return e.renderResizableHeader("email",e.orderListHeaderLabel("email"));case"ioss":return e.renderResizableHeader("ioss",e.orderListHeaderLabel("ioss"));case"available":return e.renderResizableHeader("available",e.orderListHeaderLabel("available"));case"shippingCenterDate":return e.renderResizableHeader("shippingCenterDate",e.orderListHeaderLabel("shippingCenterDate"));case"shippingCenterName":return e.renderResizableHeader("shippingCenterName",e.orderListHeaderLabel("shippingCenterName"));case"shippingLabelBoughtDate":return e.renderResizableHeader("shippingLabelBoughtDate",e.orderListHeaderLabel("shippingLabelBoughtDate"));case"shippingLabelCode":return e.renderResizableHeader("shippingLabelCode",e.orderListHeaderLabel("shippingLabelCode"));case"action":return e.renderResizableHeader("action",e.orderListHeaderLabel("action"),{style:{minWidth:160}});default:return null}},e.renderOrderListConfigurableColumnCell=function(t,r){return Qe((0,h.Z)(e),t,r)},e.orderListHeaderLabel=function(t){var r,n,a,i=e.getOrderListTargetPage(),o=null===(r=e.props.currentCompany)||void 0===r||null===(n=r.metadata)||void 0===n||null===(a=n.configs)||void 0===a?void 0:a.orderList,l=(0,ie.x6)(t);return(0,ie.zV)(i,t,l,o)},e.getAddedReasonSelectListMeta=function(){var t=(0,ie.oI)(e.props.currentCompany),r=[{value:"ETSY_NEW_ORDER",label:(0,G.R6)(G.Nx.TEXT_ETSY_NEW_ORDER)},{value:"ETSY_WARRANTY_ORDER",label:(0,G.R6)(G.Nx.TEXT_ETSY_WARRANTY_ORDER)},{value:"NON_ETSY_ORDER",label:(0,G.R6)(G.Nx.TEXT_NON_ETSY_ORDER)}];return{list:t.length>0?t:r}},e.resolveAddedReasonSelectValue=function(t){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=e.getAddedReasonSelectListMeta().list,a=new Set(n.map((function(e){return e.value}))),i=null!=t&&""!==t?String(t):"";return 0===n.length?i||"ETSY_NEW_ORDER":a.has(i)?i:r&&i||n[0].value},e.getOrderListAddedReasonSelectRows=function(t){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=e.getAddedReasonSelectListMeta().list,a=new Set(n.map((function(e){return e.value}))),o=null!=t&&""!==t?String(t):"";return o&&!a.has(o)&&r?[{value:o,label:o}].concat((0,i.Z)(n)):n},e.getOrderStatusDisplayLabel=function(t){var r,n,a=e.props,i=a.orderStatusConfig,o=a.currentCompany,l=null===o||void 0===o||null===(r=o.metadata)||void 0===r||null===(n=r.configs)||void 0===n?void 0:n.orderStatus,s=(0,lt.iH)(t);if(i&&Array.isArray(i)){var d=i.find((function(e){return e.enum===t}));null!==d&&void 0!==d&&d.display_text_vi&&(s=d.display_text_vi)}return(0,lt.W$)(t,s,l)},e.handleItemsPerPageChange=function(t){var r=parseInt(t.target.value),n=e.props.targetPage||e.state.targetPage;localStorage.setItem("orderItemsPerPage_".concat(n),r),e.setState({itemsPerPage:r,currentPage:1},(function(){e.updateURL({per_page:r,page:1}),e.loadOrders()}))},e.handlePageChange=function(t){t!==e.state.currentPage&&e.setState({currentPage:t},(function(){e.updateURL({page:t}),e.loadOrders()}))},e.getOrderStatusInfo=function(t){var r=e.props.orderStatusConfig;if(!r||!Array.isArray(r))return{bgColor:"#0099ff",text:"UNKNOWN",textColor:"#fff"};var n=null;
1if(!(n="string"===typeof t?r.find((function(e){return e.enum===t})):r.find((function(e){return e.code===Number(t)}))))return{bgColor:"#0099ff",text:"UNKNOWN",textColor:"#fff"};var a={cancelled:{bgColor:"#ff3b30",textColor:"#fff"},waiting_for_payment:{bgColor:"#ff9500",textColor:"#fff"},wait_for_processing:{bgColor:"#5ac8fa",textColor:"#222"},processing:{bgColor:"#007aff",textColor:"#fff"},processing_custom_order:{bgColor:"#b266ff",textColor:"#fff"},fulfill_processing:{bgColor:"#5ac8fa",textColor:"#222"},packaging:{bgColor:"#FFC300",textColor:"#222"},packaging_done:{bgColor:"#32d74b",textColor:"#fff"},waiting_for_shipping_label:{bgColor:"#ff9f43",textColor:"#fff"},shipped_to_shipping_center:{bgColor:"#30b0c7",textColor:"#fff"},shipped_to_customer:{bgColor:"#ff6f91",textColor:"#fff"},customs_hold:{bgColor:"#ffa500",textColor:"#fff"},returned_to_shipping_warehouse:{bgColor:"#6ee7b7",textColor:"#222"},returned_to_shipping_center:{bgColor:"#6ee7b7",textColor:"#222"},returned_to_warehouse:{bgColor:"#6ee7b7",textColor:"#222"},completed:{bgColor:"#228B22",textColor:"#fff"},refunded:{bgColor:"#ff4500",textColor:"#fff"}}[n.enum]||{bgColor:"#0099ff",textColor:"#fff"};return{bgColor:a.bgColor,text:n.enum.toUpperCase(),textColor:a.textColor}},e.getAvailableStatuses=function(t){var r,n,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=[],o=e.props,l=o.orders,s=void 0===l?[]:l,d=o.orderStatusConfig,c=o.currentCompany,u=e.props.targetPage||e.state.targetPage,h=null===c||void 0===c||null===(r=c.metadata)||void 0===r||null===(n=r.configs)||void 0===n?void 0:n.orderStatus,p=null;if(null!=t&&""!==t)if("string"===typeof t)p=t;else if(d){var g,f;p=null!==(g=null===(f=d.find((function(e){return e.code===Number(t)})))||void 0===f?void 0:f.enum)&&void 0!==g?g:null}var x=function(e){return!(0,lt.Xg)(e.enum,h)||null!=p&&e.enum===p};if(!d||!Array.isArray(d))return[];var _=s.reduce((function(e,t){var r=(t.status,t.status);return e[r]=(e[r]||0)+1,e}),{}),v=!1,y=!1,S=null;if("sale"===u&&a){var b=s.find((function(e){return e.order_id===a}));if(b)if(y=("string"===typeof b.priority?parseInt(b.priority):b.priority)>=3,b.order_date){var C=V()(b.order_date),j=V()().startOf("day");v=C.isSame(j,"day")}t&&(S="string"===typeof t?d.find((function(e){return e.enum===t})):d.find((function(e){return e.code===Number(t)})))}if("sale"===u){var T=e.applySaleStatusRestriction()&&v&&!y;T&&S&&S.code>=10&&x(S)&&i.push((0,m.Z)({value:S.enum,code:S.code,count:_[S.enum]||_[S.code]||0},e.getOrderStatusInfo(S.enum))),d.forEach((function(t){T&&t.code>=10?S&&(t.enum,S.enum):x(t)&&i.push((0,m.Z)({value:t.enum,code:t.code,count:_[t.enum]||_[t.code]||0},e.getOrderStatusInfo(t.enum)))}))}else if("fulfill"===u){var O=[Y.vl.FULFILL_PROCESSING,Y.vl.PACKAGING,Y.vl.PACKAGING_DONE,Y.vl.WAITING_FOR_SHIPPING_LABEL,Y.vl.SHIPPED_TO_SHIPPING_CENTER,Y.vl.SHIPPED_TO_CUSTOMER,Y.vl.CUSTOMS_HOLD,Y.vl.RETURNED_TO_SHIPPING_WAREHOUSE,Y.vl.RETURNED_TO_SHIPPING_CENTER,Y.vl.RETURNED_TO_WAREHOUSE,Y.vl.FAIL_REASON_1,Y.vl.FAIL_REASON_2,Y.vl.FAIL_REASON_3,Y.vl.COMPLETED,Y.vl.REFUNDED];d.filter((function(e){return O.includes(e.enum)})).forEach((function(t){x(t)&&i.push((0,m.Z)({value:t.enum,code:t.code,count:_[t.enum]||_[t.code]||0},e.getOrderStatusInfo(t.enum)))}))}else"rnd"===u&&d.forEach((function(t){x(t)&&i.push((0,m.Z)({value:t.enum,code:t.code,count:_[t.enum]||_[t.code]||0},e.getOrderStatusInfo(t.enum)))}));return i},e.handleStatusChange=function(t,r){var n=e.props.orders.find((function(e){return e.order_id===t}));if(n){if(e.isIncrementalParentOrder(n))return void e.handleShowToast("\u0110\u01a1n cha: d\xf9ng n\xfat \u0111\u1ed3ng b\u1ed9 (reload) \u0111\u1ec3 c\u1eadp nh\u1eadt tr\u1ea1ng th\xe1i t\u1eeb \u0111\u01a1n con","warning");var a=e.props.targetPage||e.state.targetPage,i=e.props.orderStatusConfig;if("sale"===a&&i&&Array.isArray(i)&&e.applySaleStatusRestriction()){var o=i.find((function(e){return e.enum===r}));if(o&&o.code>=10&&n.order_date){var l=V()(n.order_date),s=V()().startOf("day"),d=("string"===typeof n.priority?parseInt(n.priority):n.priority)>=3;if(l.isSame(s,"day")&&!d)return void e.handleShowToast("Kh\xf4ng th\u1ec3 chuy\u1ec3n \u0111\u01a1n c\xf3 ng\xe0y \u0111\u1eb7t h\xe0ng l\xe0 h\xf4m nay sang status >= 10","warning")}}var c={order_id:n.order_id,shop_id:n.shop_id,status:r,perform_by_team:e.getPerformByTeam()};e.props.updateOrders([c]).then((function(){e.handleShowToast("Order ".concat(t," status updated successfully"))})).catch((function(t){console.error("Error updating status:",t),e.handleShowToast("Failed to update status","danger")}))}},e.getPriorityInfo=function(e){return{1:{color:"secondary",text:"TEXT_PRIORITY_LOW",bgColor:"#6c757d",textColor:"#ffffff"},2:{color:"info",text:"TEXT_PRIORITY_MEDIUM",bgColor:"#0dcaf0",textColor:"#000000"},3:{color:"warning",text:"TEXT_PRIORITY_HIGH",bgColor:"#ffc107",textColor:"#000000"},4:{color:"danger",text:"TEXT_PRIORITY_EXPRESS",bgColor:"#dc3545",textColor:"#ffffff"}}[e]||{color:"secondary",text:"TEXT_PRIORITY_LOW",bgColor:"#6c757d",textColor:"#ffffff"}},e.handlePriorityChange=function(t,r){var n=e.props.orders.find((function(e){return e.order_id===t}));if(n){var a={order_id:n.order_id,shop_id:n.shop_id,priority:parseInt(r),perform_by_team:e.getPerformByTeam()};e.props.updateOrders([a]).then((function(){e.handleShowToast("Order ".concat(t," priority updated successfully"))})).catch((function(t){console.error("Error updating priority:",t),e.handleShowToast("Failed to update priority","danger")}))}}
1,e.renderStatusBadge=function(t){var r=e.getOrderStatusInfo(t);return(0,A.jsx)("span",{className:"badge",style:{background:r.bgColor,color:"#fff",minWidth:24,display:"inline-block"},children:"\xa0"})},e.isIncrementalParentOrder=function(e){var t;if(!e||null==e.order_id||""===e.order_id)return!1;var r=String(e.order_id).trim().split("_");if(r.length<2)return!1;if(!/^\d{5}$/.test(r[1]||""))return!1;if(r.length>=3)return 0===parseInt(r[r.length-1],10);var n=Number(null===(t=e.metadata)||void 0===t?void 0:t.child_orders_count);return Number.isFinite(n)&&n>0},e.isIncrementalChildOrder=function(t){if(!t||null==t.order_id||""===t.order_id)return!1;if(e.isIncrementalParentOrder(t))return!1;if(null!=t.metadata&&""!==String(t.metadata.parent_order_id||"").trim())return!0;var r=String(t.order_id).trim().split("_");if(r.length<3)return!1;if(!/^\d{5}$/.test(r[1]||""))return!1;var n=parseInt(r[r.length-1],10);return!Number.isNaN(n)&&n>0},e.getIncrementalFamilyRowStyle=function(t,r){var n=r?{backgroundColor:r}:{};return e.isIncrementalParentOrder(t)?{backgroundColor:"#fffbeb",borderLeft:"5px solid #d97706",boxSizing:"border-box",boxShadow:"inset 0 -1px 0 rgba(217, 119, 6, 0.12)"}:e.isIncrementalChildOrder(t)?(0,m.Z)((0,m.Z)({},n),{},{backgroundColor:r||"#fafafa",borderLeft:"3px solid #cbd5e1",boxSizing:"border-box",boxShadow:"inset 0 -1px 0 rgba(15, 23, 42, 0.05)"}):Object.keys(n).length?n:void 0},e.renderIncrementalChildConnector=function(){return(0,A.jsx)("span",{className:"order-incr-child-connector align-middle",title:"\u0110\u01a1n con (c\xf9ng nh\xf3m MH)","aria-hidden":!0,style:{display:"inline-flex",flexShrink:0,alignItems:"center",justifyContent:"center",width:22,height:22,color:"#94a3b8"},children:(0,A.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,A.jsx)("path",{d:"M5 3v8.5c0 1.1.9 2 2 2h7.5",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round"}),(0,A.jsx)("circle",{cx:"15.5",cy:"13.5",r:"1.35",fill:"currentColor"})]})})},e.handleSyncIncrementalParentStatusFromChildren=function(t){var r,n=null===t||void 0===t?void 0:t.order_id;if(n&&e.isIncrementalParentOrder(t)&&!e.state.syncingParentOrderId){var a=e.props,o=a.orders,l=void 0===o?[]:o,s=a.orderStatusConfig;if(s&&Array.isArray(s)){var d=String(n).split("_"),c=3===d.length?"".concat(d[0],"_").concat(d[1],"_"):null,u=new Set,h=[];l.forEach((function(e){if(e&&e.order_id&&e.order_id!==n){var t=!1;if(e.metadata&&String(e.metadata.parent_order_id||"")===String(n))t=!0;else if(c&&String(e.order_id).startsWith(c)){var r=e.order_id.slice(c.length),a=parseInt(r,10);!Number.isNaN(a)&&a>0&&(t=!0)}t&&!u.has(e.order_id)&&(u.add(e.order_id),h.push(e))}}));var p=Number(null===(r=t.metadata)||void 0===r?void 0:r.child_orders_count);if(0!==h.length){Number.isFinite(p)&&p>0&&h.length<p&&e.handleShowToast("Ch\u1ec9 c\xf3 ".concat(h.length,"/").concat(p," \u0111\u01a1n con \u0111\xe3 t\u1ea3i \u2014 \u0111\u1ed3ng b\u1ed9 theo c\xe1c \u0111\u01a1n hi\u1ec7n c\xf3"),"warning");var g=h.map((function(e){return function(e){if(null==e||""===e)return null;var t="string"===typeof e?s.find((function(t){return t.enum===e})):s.find((function(t){return t.code===Number(e)}));return t&&Number.isFinite(t.code)?t.code:null}(e.status)}));if(g.some((function(e){return null==e})))e.handleShowToast("Kh\xf4ng \u0111\u1ecdc \u0111\u01b0\u1ee3c m\xe3 tr\u1ea1ng th\xe1i m\u1ed9t s\u1ed1 \u0111\u01a1n con","danger");else{var m=Math.min.apply(Math,(0,i.Z)(g)),f=s.find((function(e){return e.code===m}));if(f&&f.enum)if(f.enum!==t.status){e.setState({syncingParentOrderId:n});var x={order_id:t.order_id,shop_id:t.shop_id,status:f.enum,perform_by_team:e.getPerformByTeam()};e.props.updateOrders([x]).then((function(){e.handleShowToast("\u0110\xe3 c\u1eadp nh\u1eadt tr\u1ea1ng th\xe1i cha \u2192 [".concat(f.code,"] ").concat(e.getOrderStatusDisplayLabel(f.enum)))})).catch((function(t){console.error("Error syncing parent status:",t),e.handleShowToast("Kh\xf4ng c\u1eadp nh\u1eadt \u0111\u01b0\u1ee3c tr\u1ea1ng th\xe1i \u0111\u01a1n cha","danger")})).finally((function(){e.setState({syncingParentOrderId:null})}))}else e.handleShowToast("Tr\u1ea1ng th\xe1i cha \u0111\xe3 kh\u1edbp \u0111\u01a1n con ch\u1eadm nh\u1ea5t (min code)","info");else e.handleShowToast("Kh\xf4ng x\xe1c \u0111\u1ecbnh \u0111\u01b0\u1ee3c tr\u1ea1ng th\xe1i \u0111\u1ed3ng b\u1ed9","danger")}}else e.handleShowToast("Kh\xf4ng t\xecm th\u1ea5y \u0111\u01a1n con trong danh s\xe1ch hi\u1ec7n t\u1ea1i","warning")}else e.handleShowToast("Thi\u1ebfu c\u1ea5u h\xecnh tr\u1ea1ng th\xe1i \u0111\u01a1n","danger")}}
1,e.renderPriorityOption=function(t){var r=e.getPriorityInfo(t);return(0,A.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,A.jsx)("div",{style:{width:"12px",height:"12px",borderRadius:"50%",backgroundColor:r.bgColor,border:"1px solid #ccc"}}),(0,A.jsxs)("span",{children:["[",t,"] ",(0,G.R6)(G.Nx[r.text])]})]})},e.renderPriorityBadge=function(t){var r=e.getPriorityInfo(t);return(0,A.jsx)(v.Z,{bg:r.color,style:{backgroundColor:r.bgColor,color:r.textColor,padding:"5px 10px",fontWeight:"bold"},children:(0,G.R6)(G.Nx[r.text])})},e.isFeatureEnabled=function(t){var r=e.state.targetPage;switch(t){case"scan_orders":return"sale"===r;case"bulk_update":case"edit_notes":return"sale"===r||"fulfill"===r;case"edit_priority":return"rnd"===r||"fulfill"===r;default:return!1}},e.handlePrintOrderLabel=function(){var t=(0,l.Z)((0,o.Z)().mark((function t(r){var n,a,i,l,s,d,c,u,h;return(0,o.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.setState({printOrderLabel:{order:r,loading:!0,shortUrl:null}}),a="localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname,i=(null===(n=r.metadata)||void 0===n?void 0:n.order_short_url)||null){t.next=22;break}return t.prev=4,s="".concat(window.location.origin,"/admin/orders/order-detail/").concat(r.order_id,"?show_sidebar=false&ref_link=scan_qr"),d=e.formatOrderIdToHuman(r.order_id)||r.order_id,c=(0,B.LP)(),t.next=10,fetch("".concat((0,U.kG)(),"/api/system/qr/create"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(c)},body:JSON.stringify({url:s,label:"\u0110\u01a1n ".concat(d)})});case 10:return u=t.sent,t.next=13,u.json();case 13:if(h=t.sent,!(i=(null===h||void 0===h||null===(l=h.data)||void 0===l?void 0:l.shortUrl)||(a?s:null))||a){t.next=18;break}return t.next=18,q.b.put("".concat((0,U.kG)(),"/api/order/").concat(r.order_id),{metadata:(0,m.Z)((0,m.Z)({},r.metadata||{}),{},{order_short_url:i})});case 18:t.next=22;break;case 20:t.prev=20,t.t0=t.catch(4);case 22:e.setState((function(e){return{printOrderLabel:e.printOrderLabel?(0,m.Z)((0,m.Z)({},e.printOrderLabel),{},{loading:!1,shortUrl:i}):null}}));case 23:case"end":return t.stop()}}),t,null,[[4,20]])})));return function(e){return t.apply(this,arguments)}}(),e.handleRecreateOrderLabel=(0,l.Z)((0,o.Z)().mark((function t(){var r,n,a,i,l,s,d,c,u,h;return(0,o.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null!==(r=e.state.printOrderLabel)&&void 0!==r&&r.order){t.next=3;break}return t.abrupt("return");case 3:return n=r.order,a="localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname,e.setState((function(e){return{printOrderLabel:e.printOrderLabel?(0,m.Z)((0,m.Z)({},e.printOrderLabel),{},{loading:!0,shortUrl:null}):null}})),t.prev=6,l="".concat(window.location.origin,"/admin/orders/order-detail/").concat(n.order_id,"?show_sidebar=false&ref_link=scan_qr"),s=e.formatOrderIdToHuman(n.order_id)||n.order_id,d=(0,B.LP)(),t.next=12,fetch("".concat((0,U.kG)(),"/api/system/qr/create"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(d)},body:JSON.stringify({url:l,label:"\u0110\u01a1n ".concat(s)})});case 12:return c=t.sent,t.next=15,c.json();case 15:if(u=t.sent,!(h=(null===u||void 0===u||null===(i=u.data)||void 0===i?void 0:i.shortUrl)||(a?l:null))||a){t.next=20;break}return t.next=20,q.b.put("".concat((0,U.kG)(),"/api/order/").concat(n.order_id),{metadata:(0,m.Z)((0,m.Z)({},n.metadata||{}),{},{order_short_url:h})});case 20:e.setState((function(e){return{printOrderLabel:e.printOrderLabel?(0,m.Z)((0,m.Z)({},e.printOrderLabel),{},{loading:!1,shortUrl:h}):null}})),t.next=26;break;case 23:t.prev=23,t.t0=t.catch(6),e.setState((function(e){return{printOrderLabel:e.printOrderLabel?(0,m.Z)((0,m.Z)({},e.printOrderLabel),{},{loading:!1}):null}}));case 26:case"end":return t.stop()}}),t,null,[[6,23]])}))),e.handleShowSplitOrderModal=function(t){var r,n,a,i,o=t.listings||[],l=Array.isArray(null===(r=t.metadata)||void 0===r?void 0:r.parent_products)?t.metadata.parent_products:[];if(l.length>0)i={order_id:t.order_id,parentProducts:l.map((function(e){return{product_code:e.product_code,quantity:e.quantity||0,child_products:Array.isArray(e.child_products)?e.child_products:[]}}))};else if(o.length>=2){var s=o.map((function(e){return e.quantity||1}
1)),d=s.reduce((function(e,t){return ft(e,t)}));i={order_id:t.order_id,listings:o.map((function(e){return{title:e.title,sku:e.sku,size:e.size,quantity:e.quantity||1}})),gcd:d}}else{var c;i={order_id:t.order_id,quantity:(null===(c=o[0])||void 0===c?void 0:c.quantity)||1}}e.setState({showSplitOrderModal:!0,splitOrderTarget:i,splitOrderQty:"",splitOrderMode:"split",splitOrderParentCode:(null===(n=i.parentProducts)||void 0===n||null===(a=n[0])||void 0===a?void 0:a.product_code)||null,splitOrderLoading:!1})},e.handleSplitOrderSubmit=(0,l.Z)((0,o.Z)().mark((function t(){var r,n,a,i,l,s,d,c,u,h,p,g;return(0,o.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.state,n=r.splitOrderTarget,a=r.splitOrderQty,i=r.splitOrderParentCode,n){t.next=3;break}return t.abrupt("return");case 3:if(!n.parentProducts){t.next=28;break}if(l=n.parentProducts.find((function(e){return e.product_code===i}))){t.next=7;break}return t.abrupt("return");case 7:if(0!==(s=String(a).split(",").map((function(e){return parseInt(e.trim(),10)})).filter((function(e){return!isNaN(e)&&e>=1}))).length){t.next=10;break}return t.abrupt("return");case 10:if(!(s.reduce((function(e,t){return e+t}),0)>=l.quantity)){t.next=13;break}return t.abrupt("return");case 13:return e.setState({splitOrderLoading:!0}),t.prev=14,t.next=17,q.b.post("".concat((0,U.kG)(),"/api/order/").concat(n.order_id,"/split"),{parent_product_code:l.product_code,split_numbers:s});case 17:e.setState({showSplitOrderModal:!1,splitOrderTarget:null,splitOrderQty:""}),e.handleSearch(),t.next=24;break;case 21:t.prev=21,t.t0=t.catch(14),e.handleShowToast((null===t.t0||void 0===t.t0||null===(d=t.t0.response)||void 0===d||null===(c=d.data)||void 0===c?void 0:c.message)||t.t0.message||"L\u1ed7i t\xe1ch \u0111\u01a1n","danger");case 24:return t.prev=24,e.setState({splitOrderLoading:!1}),t.finish(24);case 27:return t.abrupt("return");case 28:if(u=parseInt(a,10),!(isNaN(u)||u<1)){t.next=31;break}return t.abrupt("return");case 31:if(!((h=!!n.listings)&&u>=n.gcd)){t.next=34;break}return t.abrupt("return");case 34:if(h||!(u>=n.quantity)){t.next=36;break}return t.abrupt("return");case 36:return e.setState({splitOrderLoading:!0}),t.prev=37,t.next=40,q.b.post("".concat((0,U.kG)(),"/api/order/").concat(n.order_id,"/split"),{new_quantity:u});case 40:e.setState({showSplitOrderModal:!1,splitOrderTarget:null,splitOrderQty:""}),e.handleSearch(),t.next=47;break;case 44:t.prev=44,t.t1=t.catch(37),e.handleShowToast((null===t.t1||void 0===t.t1||null===(p=t.t1.response)||void 0===p||null===(g=p.data)||void 0===g?void 0:g.message)||t.t1.message||"L\u1ed7i t\xe1ch \u0111\u01a1n","danger");case 47:return t.prev=47,e.setState({splitOrderLoading:!1}),t.finish(47);case 50:case"end":return t.stop()}}),t,null,[[14,21,24,27],[37,44,47,50]])}))),e.handleIncreaseOrderSubmit=function(){var t=e.state,r=t.splitOrderTarget,n=t.splitOrderQty,a=t.splitOrderParentCode;if(r){var i=e.props.orders.find((function(e){return e.order_id===r.order_id}));if(i){var o=parseInt(n,10);if(r.parentProducts){var l,s=r.parentProducts.findIndex((function(e){return e.product_code===a}));if(s<0)return;var d=r.parentProducts[s];if(isNaN(o)||o<1||o===d.quantity)return;var c=o-d.quantity,u=new Map;(d.child_products||[]).forEach((function(e){u.set(e.product_code,(e.quantity||1)*c)}));var h=(i.listings||[]).map((function(e){var t=u.get(e.product_code)||0;if(0===t)return e;var r=e.quantity||0,n=Math.max(0,r+t),a=r>0?n/r:1,i=(0,m.Z)((0,m.Z)({},e),{},{quantity:n});return Array.isArray(e.child_products)&&(i.child_products=e.child_products.map((function(e){return(0,m.Z)((0,m.Z)({},e),{},{quantity:Math.round((e.quantity||1)*a)})}))),i})),p=((null===(l=i.metadata)||void 0===l?void 0:l.parent_products)||[]).map((function(e,t){return t===s?(0,m.Z)((0,m.Z)({},e),{},{quantity:o}):e})),g={order_id:i.order_id,shop_id:i.shop_id,perform_by_team:e.getPerformByTeam(),listings:h,metadata:(0,m.Z)((0,m.Z)({},i.metadata||{}),{},{parent_products:p})};return e.setState({splitOrderLoading:!0}),void e.props.updateOrders([g]).then((function(){e.setState({showSplitOrderModal:!1,splitOrderTarget:null,splitOrderQty:"",splitOrderLoading:!1}),e.handleSearch()})).catch((function(t){var r,n;e.handleShowToast((null===t||void 0===t||null===(r=t.response)||void 0===r||null===(n=r.data)||void 0===n?void 0:n.message)||t.message||"L\u1ed7i t\u0103ng s\u1ed1 l\u01b0\u1ee3ng","danger"),e.setState({splitOrderLoading:!1})}
1))}var f=!!r.listings?r.gcd:r.quantity||1;if(!(isNaN(o)||o<=f)){var x=(i.listings||[]).map((function(e){var t=(e.quantity||1)/f,r=(0,m.Z)((0,m.Z)({},e),{},{quantity:Math.round(t*o)});return Array.isArray(e.child_products)&&(r.child_products=e.child_products.map((function(e){return(0,m.Z)((0,m.Z)({},e),{},{quantity:Math.round((e.quantity||1)/f*o)})}))),r})),_={order_id:i.order_id,shop_id:i.shop_id,perform_by_team:e.getPerformByTeam(),listings:x};e.setState({splitOrderLoading:!0}),e.props.updateOrders([_]).then((function(){e.setState({showSplitOrderModal:!1,splitOrderTarget:null,splitOrderQty:"",splitOrderLoading:!1}),e.handleSearch()})).catch((function(t){var r,n;e.handleShowToast((null===t||void 0===t||null===(r=t.response)||void 0===r||null===(n=r.data)||void 0===n?void 0:n.message)||t.message||"L\u1ed7i t\u0103ng s\u1ed1 l\u01b0\u1ee3ng","danger"),e.setState({splitOrderLoading:!1})}))}}}},e.handleUpdateOrderCost=function(){var t=(0,l.Z)((0,o.Z)().mark((function t(r){var n,a;return(0,o.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null!==r&&void 0!==r&&r.order_id){t.next=2;break}return t.abrupt("return");case 2:return t.prev=2,t.next=5,q.b.post("".concat((0,U.kG)(),"/api/order/").concat(r.order_id,"/update-cost"));case 5:e.handleShowToast("\u0110\xe3 update cost"),e.handleSearch(),t.next=12;break;case 9:t.prev=9,t.t0=t.catch(2),e.handleShowToast((null===t.t0||void 0===t.t0||null===(n=t.t0.response)||void 0===n||null===(a=n.data)||void 0===a?void 0:a.message)||t.t0.message||"L\u1ed7i update cost","danger");case 12:case"end":return t.stop()}}),t,null,[[2,9]])})));return function(e){return t.apply(this,arguments)}}(),e.handleShowRndDoneModal=function(t){e.setState({showRndDoneModal:!0,rndOrderId:t,rndNoteValue:""})},e.handleRndNoteChange=function(t){e.setState({rndNoteValue:t.target.value})},e.handleRndDoneSubmit=function(){var t=e.state,r=t.rndOrderId,n=t.rndNoteValue,a=e.props.orders.find((function(e){return e.order_id===r}));if(a){var i=(new Date).toLocaleString(),o=(a.seller_note?a.seller_note+"\n":"")+"[".concat(i,"] [RnD Note]: ").concat(n),l={order_id:a.order_id,shop_id:a.shop_id,status:"processing",seller_note:o,perform_by_team:"RND"};e.props.updateOrders([l]).then((function(){e.setState({showRndDoneModal:!1,rndOrderId:null,rndNoteValue:""}),e.loadOrders()})).catch((function(e){alert("Failed to update order. See console for details.")}))}},e.handleSort=function(t){var r="asc";e.state.sortBy===t&&(r="asc"===e.state.sortOrder?"desc":"asc"),e.setState({sortBy:t,sortOrder:r},(function(){e.loadOrders()}))},e.handleKeywordChange=function(t){e.setState({keyword:t.target.value})},e.handleKeywordSearch=function(t){if("blur"===t.type||"keydown"===t.type&&"Enter"===t.key){var r=t.target.value.trim();localStorage.setItem("orderKeyword_".concat(e.state.targetPage),r),e.setState({keyword:r,currentPage:1,selectedOrders:new Set},(function(){r?e.updateURL({keyword:r,page:1}):e.updateURL({keyword:"",page:1}),e.loadOrders()}))}},e.handleExecutorUserFilterChange=function(t){var r=null!=t.target.value?String(t.target.value).trim():"",n=e.getOrderListTargetPage();"sale"!==n&&"rnd"!==n&&"fulfill"!==n||localStorage.setItem("orderExecutorUserFilter_".concat(n),r),e.setState({executorUserFilter:r,currentPage:1,selectedOrders:new Set},(function(){r?e.updateURL({executor_user:r,page:1}):e.updateURL({executor_user:"",page:1}),e.loadOrders()}))},e.handleViewLogs=function(t){e.setState({showLogModal:!0,currentOrderForLog:t,currentOrderLogs:[]},(function(){e.fetchOrderLogs(t.order_id)}))},e.fetchOrderLogs=function(){var t=(0,l.Z)((0,o.Z)().mark((function t(r){var n,a,i,l,s,d,c,u,h=arguments;return(0,o.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=h.length>1&&void 0!==h[1]?h[1]:1,t.prev=1,t.next=4,q.b.get("".concat((0,U.kG)(),"/api/order/get-logs/").concat(r,"?page=").concat(n));case 4:a=t.sent,i=a.data.data,l=i.logs,s=i.totalCount,d=i.currentPage,c=i.totalPages,u=i.limit,e.setState({currentOrderLogs:l,logPagination:{currentPage:d,totalPages:c,totalCount:s,limit:u}}),t.next=12;break;case 9:t.prev=9,t.t0=t.catch(1),console.error("Error fetching order logs:",t.t0);case 12:case"end":return t.stop()}}),t,null,[[1,9]])})));return function(e){return t.apply(this,arguments)}}(),e.handleToggleShowLatestLog=function(){e.setState((function(e){return{isShowLatestLog:!e.isShowLatestLog}}))},e.handleToggleShowSystemInfo=function(){e.setState((function(e){return{isShowSystemInfo:!e.isShowSystemInfo}}
1))},e.handleGetLatestLog=function(){e.state.currentOrderForLog&&e.fetchOrderLogs(e.state.currentOrderForLog.order_id)},e.handleLogPageChange=function(t){e.state.currentOrderForLog&&e.fetchOrderLogs(e.state.currentOrderForLog.order_id,t)},e.handleAddListing=function(){var t=e.state.currentOrder;if(t){var r={sku:"",size:"",title:"",img_url:"",custom_field_1:"",custom_field_2:""},n=[].concat((0,i.Z)(t.listings),[r]);e.setState({currentOrder:(0,m.Z)((0,m.Z)({},t),{},{listings:n}),currentListing:r,editForm:{sku:"",size:"",title:"",buyer_note:t.buyer_note||"",seller_note:t.seller_note||"",priority:t.priority||2,quantity:1},showEditModal:!0})}else e.setState({currentOrder:{order_id:"",shop_id:"",listings:[{sku:"",size:"",title:"",img_url:"",custom_field_1:"",custom_field_2:""}],buyer_note:"",seller_note:"",priority:2},currentListing:{sku:"",size:"",title:"",img_url:"",custom_field_1:"",custom_field_2:""},editForm:{sku:"",size:"",title:"",buyer_note:"",seller_note:"",priority:2,quantity:1},showEditModal:!0})},e.getProductColorTypes=function(){var t=e.getGeneralConfig();return(0,He.Ch)(t[He.wp])},e.isOrderColorModeEnabled=function(){return!0===e.getGeneralConfig()[He.nK]&&e.getProductColorTypes().length>0},e.getProductTypeLabel=function(t){if(!t)return"";var r=e.getGeneralConfig(),n=e.parseOrderCustomFilterOptions(r[He.LW]),a=String(t).toUpperCase(),i=n.find((function(e){return String(e.value||"").toUpperCase()===a}));return(null===i||void 0===i?void 0:i.label)||t},e.findProductByCode=function(t){return t&&(e.props.products||[]).find((function(e){return e.product_code===t}))||null},e.getListingColorInfo=function(t){var r;if(!t)return{isColor:!1};var n=e.getProductColorTypes();if(0===n.length)return{isColor:!1};var a=e.findProductByCode(t.product_code),i=String((null===a||void 0===a?void 0:a.product_type)||"").toUpperCase();return i&&n.includes(i)?{isColor:!0,hex:String((null===a||void 0===a||null===(r=a.properties)||void 0===r?void 0:r.color)||"").trim(),productType:i,product:a}:{isColor:!1}},e.getContrastTextColor=function(e){var t=String(e||"").trim();if(!/^#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{3})$/.test(t))return"#000";var r=t.slice(1);return 3===r.length&&(r=r.split("").map((function(e){return e+e})).join("")),(299*parseInt(r.slice(0,2),16)+587*parseInt(r.slice(2,4),16)+114*parseInt(r.slice(4,6),16))/1e3>=160?"#000":"#fff"},e.isAllColorListingsOrder=function(t){if(!e.isOrderColorModeEnabled())return!1;var r=(null===t||void 0===t?void 0:t.listings)||[];return 0!==r.length&&r.every((function(t){return e.getListingColorInfo(t).isColor}))},e.handleOpenColorPickerForOrder=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=e.getProductColorTypes();if(0!==n.length){var a=n[0];if(null!=r){var i,o=e.getListingColorInfo(null===(i=t.listings)||void 0===i?void 0:i[r]);o.isColor&&o.productType&&(a=o.productType)}e.setState({colorPickerOrder:t,colorPickerListingIndex:r,colorPickerActiveType:a,colorPickerPendingProduct:null})}},e.handleCloseColorPicker=function(){e.state.colorPickerSaving||e.setState({colorPickerOrder:null,colorPickerListingIndex:null,colorPickerActiveType:null,colorPickerPendingProduct:null})},e.handleSelectColorProduct=function(t){var r,n,a=e.state,o=a.colorPickerOrder,l=a.colorPickerListingIndex;if(o&&t){var s=!0===e.getGeneralConfig()[He.e2],d=(0,m.Z)({sku:t.sku_code,size:t.size,title:t.product_name,img_url:t.images&&t.images.length>0?t.images[0].image_link:"",product_code:t.product_code,custom_field_1:t.custom_field_1||"",custom_field_2:t.custom_field_2||"",quantity:null!=l&&(null===(r=o.listings)||void 0===r||null===(n=r[l])||void 0===n?void 0:n.quantity)||1},s?{qty_failed:0}:{}),c=o.listings||[],u=null!=l?c.map((function(e,t){return t===l?d:e})):[].concat((0,i.Z)(c),[d]),h={order_id:o.order_id,shop_id:o.shop_id,perform_by_team:e.getPerformByTeam(),listings:u,metadata:e.buildOrderMetadataWithParentCustomField(o.metadata,u)};e.setState({colorPickerSaving:!0}),e.props.updateOrders([h],{isUpdated:!0}).then((function(){e.handleShowToast(null!=l?"\u0110\xe3 \u0111\u1ed5i m\xe0u":"\u0110\xe3 th\xeam m\xe0u v\xe0o order"),e.setState({colorPickerSaving:!1,colorPickerOrder:null,colorPickerListingIndex:null,colorPickerActiveType:null,colorPickerPendingProduct:null}),e.loadOrders()})).catch((function(t){console.error("handleSelectColorProduct error",t),e.handleShowToast("C\u1eadp nh\u1eadt m\xe0u th\u1ea5t b\u1ea1i","danger"),e.setState({colorPickerSaving:!1})}
1))}},e.renderColorPickerOrderModal=function(){var t,r=e.state,n=r.colorPickerOrder,a=r.colorPickerActiveType,i=r.colorPickerListingIndex,o=r.colorPickerSaving;if(!n)return null;var l=e.getProductColorTypes(),s=e.props.products||[],d=null!=i,c=d?null===(t=n.listings)||void 0===t?void 0:t[i]:null,u=(null===c||void 0===c?void 0:c.product_code)||"",h=d?"L\u01b0u":"Th\xeam";return(0,A.jsx)(ut.Z,{show:!0,onHide:e.handleCloseColorPicker,subtitle:e.formatOrderIdToHuman(n.order_id)||n.order_id,colorTypes:l,getTypeLabel:e.getProductTypeLabel,initialType:a,currentProductCode:u,confirmLabel:h,saving:o,getProductsForType:function(e){return s.filter((function(t){return String(t.product_type||"").toUpperCase()===e})).sort((function(e,t){return String(e.sku_code||"").localeCompare(String(t.sku_code||""),void 0,{numeric:!0,sensitivity:"base"})}))},onTabActive:function(t){return e.setState({colorPickerActiveType:t})},onConfirm:function(t){return e.handleSelectColorProduct(t)}})},e.handleDeleteOrderListing=function(t,r){if(t&&Array.isArray(t.listings)&&!(null==r||r<0||r>=t.listings.length)){var n=t.listings[r],a="".concat((0,ce.G)((null===n||void 0===n?void 0:n.sku)||"")).concat(null!==n&&void 0!==n&&n.size?" / "+n.size:"");if(t.listings.length<=1){var i=e.formatOrderIdToHuman(t.order_id)||t.order_id||"";if(!window.confirm('Listing "'.concat(a,'" l\xe0 listing duy nh\u1ea5t c\u1ee7a \u0111\u01a1n ').concat(i,".\nXo\xe1 listing n\xe0y s\u1ebd xo\xe1 c\u1ea3 \u0111\u01a1n. Ti\u1ebfp t\u1ee5c?")))return;var o={order_id:t.order_id,shop_id:t.shop_id,is_deleted:!0,perform_by_team:e.getPerformByTeam()};e.props.updateOrders([o]).then((function(){e.handleShowToast("\u0110\xe3 xo\xe1 \u0111\u01a1n"),e.loadOrders()})).catch((function(t){console.error("handleDeleteOrderListing (delete order) error",t),e.handleShowToast("Xo\xe1 \u0111\u01a1n th\u1ea5t b\u1ea1i","danger")}))}else if(window.confirm('Xo\xe1 listing "'.concat(a,'" kh\u1ecfi \u0111\u01a1n n\xe0y?'))){var l=t.listings.filter((function(e,t){return t!==r})),s={order_id:t.order_id,shop_id:t.shop_id,perform_by_team:e.getPerformByTeam(),listings:l,metadata:e.buildOrderMetadataWithParentCustomField(t.metadata,l)};e.props.updateOrders([s],{isUpdated:!0}).then((function(){e.handleShowToast("\u0110\xe3 xo\xe1 listing"),e.loadOrders()})).catch((function(t){console.error("handleDeleteOrderListing error",t),e.handleShowToast("Xo\xe1 listing th\u1ea5t b\u1ea1i","danger")}))}}},e.getBaseParentOrderId=function(e){var t=String(e||"").trim();if(!t)return"";var r=t.split("_");return r.length>=3&&/^\d+$/.test(r[r.length-1])?r.slice(0,-1).join("_"):t},e.computeChildOrderId=function(t){var r=e.getBaseParentOrderId(t);if(!r)return"";var n=e.props.orders||[],a=new RegExp("^".concat(r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"_(\\d+)$")),i=0;n.forEach((function(e){var t=(null===e||void 0===e?void 0:e.order_id)&&String(e.order_id).match(a);if(t){var r=parseInt(t[1],10);Number.isFinite(r)&&r>i&&(i=r)}}));var o=i+1,l=Math.max(2,String(o).length);return"".concat(r,"_").concat(String(o).padStart(l,"0"))},e.resolveBaseParentOrder=function(){var t=(0,l.Z)((0,o.Z)().mark((function t(r,n){var a,i,l,s;return(0,o.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r){t.next=2;break}return t.abrupt("return",n);case 2:if(r!==(null===n||void 0===n?void 0:n.order_id)){t.next=4;break}return t.abrupt("return",n);case 4:if(!(a=(e.props.orders||[]).find((function(e){return(null===e||void 0===e?void 0:e.order_id)===r})))){t.next=7;break}return t.abrupt("return",a);case 7:return t.prev=7,t.next=10,q.b.get("".concat((0,U.kG)(),"/api/order/detail/").concat(encodeURIComponent(r)));case 10:if(l=t.sent,null===(s=(null===l||void 0===l||null===(i=l.data)||void 0===i?void 0:i.data)||(null===l||void 0===l?void 0:l.data)||null)||void 0===s||!s.order_id){t.next=14;break}return t.abrupt("return",s);case 14:t.next=18;break;case 16:t.prev=16,t.t0=t.catch(7);case 18:return t.abrupt("return",n);case 19:case"end":return t.stop()}}),t,null,[[7,16]])})));return function(e,r){return t.apply(this,arguments)}}(),e.computeChildOrderIdsBatch=function(t,r){var n=e.getBaseParentOrderId(t);if(!n)return[];var a=e.props.orders||[],i=new RegExp("^".concat(n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"_(\\d+)$")),o=0;a.forEach((function(e){var t=(null===e||void 0===e?void 0:e.order_id)&&String(e.order_id).match(i);if(t){var r=parseInt(t[1],10);Number.isFinite(r)&&r>o&&(o=r)}}));for(var l=[],s=1;s<=r;s++){var d=o+s,c=Math.max(2,String(d).length);l.push("".concat(n,"_").concat(String(d).padStart(c,"0")))}return l},e.handleCloneChildOrder=function(t){t&&(t.order_id?e.setState({cloneChildPromptOrder:t,cloneChildPromptCount:1,cloneChildSaving:!1}):e.handleShowToast("Kh\xf4ng x\xe1c \u0111\u1ecbnh \u0111\u01b0\u1ee3c order_id cha","danger"))},e.handleCloseCloneChildPrompt=function(){e.state.cloneChildSaving||e.setState({cloneChildPromptOrder:null,cloneChildPromptCount:1})},e.handleConfirmCloneChildOrder=(0,l.Z)((0,o.Z)().mark((function t(){var r,n,i,l,s,d,c,u,h,p,g,f,x,_,v,y,S,b,C,j,T;return(0,o.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.state,n=r.cloneChildPromptOrder,i=r.cloneChildPromptCount,n){t.next=3;break}return t.abrupt("return");case 3:if(l=n.order_id,s=e.getBaseParentOrderId(l),d=e.formatOrderIdToHuman(l)||l,c=parseInt(i,10),Number.isFinite(c)&&!(c<1)){t.next=10;break}return e.handleShowToast("S\u1ed1 l\u01b0\u1ee3ng ph\u1ea3i l\xe0 s\u1ed1 nguy\xean \u2265 1","warning"),t.abrupt("return");case 10:if(0!==(u=e.computeChildOrderIdsBatch(l,c)).length){t.next=14;break}return e.handleShowToast("Kh\xf4ng x\xe1c \u0111\u1ecbnh \u0111\u01b0\u1ee3c order_id con","danger"),t.abrupt("return");case 14:return h=e.getGeneralConfig(),p=!0===h[He.CN],g=!0===h[He.e2],f=(n.listings||[]).map((function(e){var t=e||{},r=(t._id,(0,a.Z)(t,gt));return g?(0,m.Z)((0,m.Z)({},r),{},{qty_failed:Number.isFinite(parseInt(r.qty_failed,10))?parseInt(r.qty_failed,10):0}):r})),x=e.buildOrderMetadataWithParentCustomField(n.metadata,f)||{},_=(0,m.Z)((0,m.Z)({},x),{},{parent_order_id:s}),t.next=22,e.resolveBaseParentOrder(s,n);case 22:v=t.sent,y=(v.listings||[]).map((function(e){return null===e||void 0===e?void 0:e.product_code}
1)).filter(Boolean).map((function(e){return(0,ce.n)(e)})),S=String(v.seller_note||"").trim(),b=y.length>0?y.join(", "):"",C=[S,b].filter(Boolean).join(" | "),j=function(t){var r;return(0,m.Z)({order_id:t,shop_id:n.shop_id,shop_name:n.shop_name,customer_name:n.customer_name||"",email:n.email||"",shipping_address:n.shipping_address||"",ioss:n.ioss||"",reference_code:n.reference_code||"",buyer_note:n.buyer_note||"",seller_note:C,priority:n.priority,added_reason:n.added_reason,deadline_fulfill_hours:null!==(r=n.deadline_fulfill_hours)&&void 0!==r?r:null,order_date:n.order_date||(new Date).toISOString(),listings:f,metadata:_,status:"wait_for_processing",group_child_products:!0===h[He.x0],separate_large_order:!0===h[He.Ib],perform_by_team:e.getPerformByTeam()},p?{customer_name:String(n.shop_name||"").trim(),email:"",shipping_address:"",ioss:"",reference_code:""}:{})},T=u.map(j),e.setState({cloneChildSaving:!0}),e.props.updateOrders(T).then((function(){e.handleShowToast("\u0110\xe3 t\u1ea1o ".concat(u.length," \u0111\u01a1n con c\u1ee7a ").concat(d)),e.setState({cloneChildPromptOrder:null,cloneChildPromptCount:1,cloneChildSaving:!1}),e.loadOrders()})).catch((function(t){console.error("handleCloneChildOrder error",t),e.handleShowToast("T\u1ea1o \u0111\u01a1n con th\u1ea5t b\u1ea1i","danger"),e.setState({cloneChildSaving:!1})}));case 31:case"end":return t.stop()}}),t)}))),e.renderCloneChildPromptModal=function(){var t=e.state,r=t.cloneChildPromptOrder,n=t.cloneChildPromptCount,a=t.cloneChildSaving;if(!r)return null;var i=e.formatOrderIdToHuman(r.order_id)||r.order_id;return(0,A.jsx)(de,{show:!0,friendlyParentLabel:i,count:n,onCountChange:function(t){return e.setState({cloneChildPromptCount:t})},saving:a,onClose:e.handleCloseCloneChildPrompt,onConfirm:e.handleConfirmCloneChildOrder})},e.handleCloneOrder=function(t){var r,n;if(t){var i=e.formatOrderIdToHuman(t.order_id)||t.order_id||"";if(window.confirm("T\u1ea1o b\u1ea3n sao c\u1ee7a \u0111\u01a1n ".concat(i,"?"))){var o=e.getGeneralConfig(),l=""!==String(null!==(r=o[He.yn])&&void 0!==r?r:"").trim(),s=!0===o[He.CN],d=!0===o[He.e2],c=(t.listings||[]).map((function(e){var t=e||{},r=(t._id,(0,a.Z)(t,mt));return d?(0,m.Z)((0,m.Z)({},r),{},{qty_failed:Number.isFinite(parseInt(r.qty_failed,10))?parseInt(r.qty_failed,10):0}):r})),u=(0,m.Z)((0,m.Z)({shop_id:t.shop_id,shop_name:t.shop_name,customer_name:t.customer_name||"",email:t.email||"",shipping_address:t.shipping_address||"",ioss:t.ioss||"",reference_code:t.reference_code||"",buyer_note:t.buyer_note||"",seller_note:t.seller_note||"",priority:t.priority,added_reason:t.added_reason,deadline_fulfill_hours:null!==(n=t.deadline_fulfill_hours)&&void 0!==n?n:null,order_date:t.order_date||(new Date).toISOString(),listings:c,metadata:e.buildOrderMetadataWithParentCustomField(t.metadata,c),status:"wait_for_processing",group_child_products:!0===o[He.x0],separate_large_order:!0===o[He.Ib],perform_by_team:e.getPerformByTeam()},l?{is_incremental_order:!0}:{order_id:"ODR"+Date.now()}),s?{customer_name:String(t.shop_name||"").trim(),email:"",shipping_address:"",ioss:"",reference_code:""}:{});e.props.updateOrders([u]).then((function(){e.handleShowToast("\u0110\xe3 clone order"),e.loadOrders()})).catch((function(t){console.error("handleCloneOrder error",t),e.handleShowToast("Clone order th\u1ea5t b\u1ea1i","danger")}))}}},e.handleAddListingToOrder=function(t){e.setState({currentOrder:t,currentListing:{product_code:"",sku:"",size:"",title:"",img_url:"",custom_field_1:"",custom_field_2:""},editForm:{sku:"",size:"",title:"",product_code:"",quantity:1,custom_field_1:"",custom_field_2:""},showEditModal:!0,isAddingListing:!0,currentListingIndex:null})},e.handleAutoFulfill=(0,l.Z)((0,o.Z)().mark((function t(){var r,n,a,i,l,s,c,u,h,p,g,f,x,_,v,y,S,b,C,j,T,O,w,F;return(0,o.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,e.setState({showAutoFulfillProgress:!0,autoFulfillProgress:0,autoFulfillTotal:0,autoFulfillCurrent:0}),t.next=4,e.props.getSESProducts({currentPage:1,itemsPerPage:9999,sortBy:"product_code",sortOrder:1});case 4:r=e.props,n=r.products,a=void 0===n?[]:n,i=r.orders,l=void 0===i?[]:i,s=[],c=e.getOrderListTargetPage(),"mix"===e.state.statusFilter&&"fulfill"===c?(h=[Y.vl.FULFILL_PROCESSING,Y.vl.PACKAGING,Y.vl.PACKAGING_DONE,Y.vl.WAITING_FOR_SHIPPING_LABEL],s=l.filter((function(e){return h.includes(e.status)})),u={},(0,d.Z)(u,Y.vl.WAITING_FOR_SHIPPING_LABEL,1),(0,d.Z)(u,Y.vl.PACKAGING_DONE,2),(0,d.Z)(u,Y.vl.PACKAGING,3),(0,d.Z)(u,Y.vl.FULFILL_PROCESSING,4),p=u,s.sort((function(e,t){return(p[e.status]||999)-(p[t.status]||999)}))):s=l.filter((function(e){return e.status===Y.vl.FULFILL_PROCESSING})),e.setState({autoFulfillTotal:s.length,autoFulfillCurrent:0,autoFulfillProgress:0}),g=function(e){return String(e||"").replace(/__\d+$/,"")},f={},x={},a.forEach((function(e){var t=e.product_code,r=e.current_qty||0;if(f[t]=(f[t]||0)+r,x[t]||(x[t]=e.current_cell_code),e.sku_code&&e.size){var n="".concat(g(e.sku_code),"-").concat(e.size);n!==t&&(f[n]=(f[n]||0)+r,x[n]||(x[n]=e.current_cell_code))}})),_=s.map((function(e){var t=e.listings.map((function(e){var t=e.product_code||"".concat(e.sku,"-").concat(e.size),r="".concat(g(e.sku),"-").concat(e.size),n=void 0!==f[t]?t:r;if(-1===e.available)return e;var a=e.quantity||1;return 2===e.available?(f[n]=Math.max(0,f[n]-a),e):f[n]>=a?(f[n]-=a,(0,m.Z)((0,m.Z)({},e),{},{available:1,current_cell_code:x[n]||e.current_cell_code})):(0,m.Z)((0,m.Z)({},e),{},{available:0})}));return(0,m.Z)((0,m.Z)({},e),{},{listings:t})})),v=_.filter((function(e,t){var r=s[t];return e.listings.some((function(e,t){var n=r.listings[t];return e.available!==n.available||e.current_cell_code!==n.current_cell_code}))})),y=e.state.autoFulfillBatchSize||50,S=Math.ceil(v.length/y),b=0;case 18:if(!(b<S)){t.next=31;break}return C=b*y,j=Math.min(C+y,v.length),T=v.slice(C,j),O=T.map((function(e){return{order_id:e.order_id,shop_id:e.shop_id,listings:e.listings,perform_by_team:"FULFILL"}})),t.next=25,e.props.updateOrders(O);case 25:w=j,F=Math.round(w/v.length*100),e.setState({autoFulfillCurrent:w,autoFulfillProgress:F});case 28:b++,t.next=18;break;case 31:e.setState({showAutoFulfillProgress:!1,autoFulfillProgress:0,autoFulfillTotal:0,autoFulfillCurrent:0}),0===v.length?e.handleShowToast("Auto Fulfill: kh\xf4ng c\xf3 \u0111\u01a1n n\xe0o thay \u0111\u1ed5i (".concat(s.length," \u0111\u01a1n, ki\u1ec3m tra t\u1ed3n kho)"),"warning"):e.handleShowToast("Auto Fulfill ho\xe0n th\xe0nh: \u0111\xe3 c\u1eadp nh\u1eadt ".concat(v.length,"/").concat(s.length," \u0111\u01a1n")),e.loadOrders(),t.next=41;break;case 36:t.prev=36,t.t0=t.catch(0),console.error("Error in auto fulfill:",t.t0),e.setState({showAutoFulfillProgress:!1,autoFulfillProgress:0,autoFulfillTotal:0,autoFulfillCurrent:0}),e.handleShowToast("Failed to complete auto fulfill","danger");case 41:case"end":return t.stop()}}),t,null,[[0,36]])}))),e.handleAvailableChange=function(){var t=(0,l.Z)((0,o.Z)().mark((function t(r,n,a){var i,l,s,d,c;return(0,o.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=e.props.orders.find((function(e){return e.order_id===r})),l=e.props.products,s=void 0===l?[]:l,!i){t.next=16;break}return d=i.listings.map((function(e){if(e.sku===n){var t=s.find((function(e){return e.sku_code===n})),r=(0,m.Z)((0,m.Z)({},e),{},{available:parseInt(a)});return null!==t&&void 0!==t&&t.current_cell_code&&(r.current_cell_code=t.current_cell_code),r}return e})),c={order_id:i.order_id,shop_id:i.shop_id,listings:d,perform_by_team:"FULFILL"},t.prev=5,t.next=8,e.props.updateOrders([c]);case 8:e.loadOrders(),e.handleShowToast("Listing availability updated successfully"),t.next=16;break;case 12:t.prev=12,t.t0=t.catch(5),console.error("Error updating available status:",t.t0),e.handleShowToast("Failed to update available status","danger");case 16:case"end":return t.stop()}}),t,null,[[5,12]])})));return function(e,r,n){return t.apply(this,arguments)}}(),e.getAvailableStatusInfo=function(e){return{"-1":{color:"secondary",text:"TEXT_AVAILABLE_PENDING"}
1,0:{color:"danger",text:"TEXT_AVAILABLE_OUT_OF_STOCK"},1:{color:"success",text:"TEXT_AVAILABLE_IN_STOCK"},2:{color:"warning",text:"TEXT_AVAILABLE_RESERVED"}}[e]||{color:"secondary",text:"TEXT_AVAILABLE_UNKNOWN"}},e.getOrdersToFulfill=function(){var t=e.props.orders,r=void 0===t?[]:t,n=[Y.vl.FULFILL_PROCESSING,Y.vl.PACKAGING,Y.vl.PACKAGING_DONE,Y.vl.WAITING_FOR_SHIPPING_LABEL,Y.vl.SHIPPED_TO_SHIPPING_CENTER,Y.vl.SHIPPED_TO_CUSTOMER,Y.vl.CUSTOMS_HOLD,Y.vl.RETURNED_TO_SHIPPING_WAREHOUSE,Y.vl.RETURNED_TO_SHIPPING_CENTER,Y.vl.RETURNED_TO_WAREHOUSE,Y.vl.COMPLETED,Y.vl.REFUNDED];return r.filter((function(e){if("string"===typeof e.status)return n.includes(e.status);return[10,11,12,13,14,15,16,17,18,19,20,21].includes(Number(e.status))}))},e.handleFulfillLabelClick=function(){e.getOrdersToFulfill();e.setState({showFulfillLabelModal:!0,activeTab:"1"},(function(){}))},e.handleShowToast=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"success";e.setState({showToast:!0,toastMessage:t,toastVariant:r}),setTimeout((function(){e.setState({showToast:!1})}),3e3)},e.toggleTab=function(t){e.state.activeTab!==t&&e.setState({activeTab:t})},e.handlePrint=function(t){var r=window.open("","_blank"),n=e.getOrdersToFulfill(),a=tt({type:t,ordersToFulfill:n,helpers:{formatMonthlyIdToHuman:e.formatMonthlyIdToHuman,formatOrderIdToHuman:e.formatOrderIdToHuman}});r.document.write(a),r.document.close(),r.focus(),r.print(),r.close()},e.getNewOrderShopStorageKey=function(){var t=e.props.currentCompany,r=null!=(null===t||void 0===t?void 0:t._id)?String(t._id):null!=(null===t||void 0===t?void 0:t.company_id)?String(t.company_id):"default";return"orderListNewOrderShopName_".concat(r)},e.handleAddOrder=function(){var t,r,n,a=null!==(t=null===(r=e.getAddedReasonSelectListMeta().list[0])||void 0===r?void 0:r.value)&&void 0!==t?t:"ETSY_WARRANTY_ORDER",i=!0===e.getGeneralConfig()[He.CN],o="";if(i)try{o=localStorage.getItem(e.getNewOrderShopStorageKey())||""}catch(l){o=""}e.setState({showAddOrderModal:!0,newOrderForm:{shop_name:o,customer_name:i&&o?o:"",email:"",shipping_address:"",buyer_note:"",seller_note:"",priority:2,added_reason:a,reference_code:"",ref_company_ids:(null===(n=e.props.user)||void 0===n?void 0:n.ref_company_ids)||"",order_date:new Date,listings:[{sku:"",size:"",title:"",img_url:"",custom_field_1:"",custom_field_2:""}]}})},e.handleShowMultipleOrderModal=function(){var t,r,n=null!==(t=null===(r=e.getAddedReasonSelectListMeta().list[0])||void 0===r?void 0:r.value)&&void 0!==t?t:"ETSY_WARRANTY_ORDER";e.setState({showMultipleOrderModal:!0,multipleOrderForm:{shop_name:"",order_date:new Date,added_reason:n,priority:2,buyer_note:"",seller_note:"",items:[{product_code:"",quantity:1}]}})},e.handleMultipleOrderFormChange=function(t){var r=t.target,n=r.name,a=r.value;e.setState((function(e){return{multipleOrderForm:(0,m.Z)((0,m.Z)({},e.multipleOrderForm),{},(0,d.Z)({},n,a))}}))},e.handleCreateMultipleOrders=function(){var t=(0,l.Z)((0,o.Z)().mark((function t(r){var n,a,i,l,s,d,c,u,h,p,g;return(0,o.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=e.state.multipleOrderForm,0!==(i=r.filter((function(e){return e.product_code&&(parseInt(e.quantity,10)||0)>0}))).length){t.next=4;break}return t.abrupt("return");case 4:return l=e.getGeneralConfig(),s=String(null!==(n=l[He.yn])&&void 0!==n?n:"").trim(),d=""!==s,c=!0===l[He.CN],u=!0===l[He.x0],h=!0===l[He.Ib],p=String(a.shop_name||"").trim(),e.setState({multipleOrderSaving:!0}),t.prev=12,g=i.map((function(t){var r=parseInt(t.quantity,10)||1,n={sku:t.product_code,size:"",title:t.product_code,img_url:"",quantity:r,custom_field_1:"",custom_field_2:""};return(0,m.Z)((0,m.Z)({shop_name:p,order_date:a.order_date instanceof Date?a.order_date.toISOString():new Date(a.order_date).toISOString(),added_reason:e.resolveAddedReasonSelectValue(a.added_reason,!1),priority:a.priority,buyer_note:a.buyer_note,seller_note:a.seller_note,status:"wait_for_processing",listings:[n],group_child_products:u,separate_large_order:h,perform_by_team:e.getPerformByTeam()},d?{is_incremental_order:!0}:{order_id:"ODR"+Date.now()+Math.random().toString(36).slice(2,6)}),c?{customer_name:p,email:"",shipping_address:"",ioss:"",reference_code:""}:{})})),t.next=16,e.props.updateOrders(g);case 16:e.setState({showMultipleOrderModal:!1}),e.loadOrders(),e.handleShowToast("\u0110\xe3 t\u1ea1o ".concat(g.length," \u0111\u01a1n h\xe0ng th\xe0nh c\xf4ng")),t.next=25;break;case 21:t.prev=21,t.t0=t.catch(12),console.error("handleCreateMultipleOrders error:",t.t0),e.handleShowToast("T\u1ea1o \u0111\u01a1n h\xe0ng th\u1ea5t b\u1ea1i","danger");case 25:return t.prev=25,e.setState({multipleOrderSaving:!1}),t.finish(25);case 28:case"end":return t.stop()}}),t,null,[[12,21,25,28]])})));return function(e){return t.apply(this,arguments)}}(),e.handleNewOrderFormChange=function(t){var r=t.target,n=r.name,a=r.value;if("reference_code"===n){var i=a?"[Reference: ".concat(a,"]\n"):"";e.setState((function(e){return{newOrderForm:(0,m.Z)((0,m.Z)({},e.newOrderForm),{},{reference_code:a,seller_note:i+(e.newOrderForm.seller_note.replace(/^\[Reference:.*?\]\n/,"")||"")})}}))}else if("seller_note"===n)e.setState((function(e){return{newOrderForm:(0,m.Z)((0,m.Z)({},e.newOrderForm),{},{reference_code:e.newOrderForm.reference_code,seller_note:(e.newOrderForm.reference_code?"[Reference: ".concat(e.newOrderForm.reference_code,"]\n"):"")+a.replace(/^\[Reference:.*?\]\n/,"")})}}));else if("order_date"===n)e.setState((function(e){return{newOrderForm:(0,m.Z)((0,m.Z)({},e.newOrderForm),{},{order_date:a})}}));else if("customer_name"===n&&"Sign in with Apple user"===a){var o=e.state.newOrderForm.shipping_address,l=o?o.split("\n")[0]:"";e.setState((function(e){return{newOrderForm:(0,m.Z)((0,m.Z)({},e.newOrderForm),{},{customer_name:l||a})}}))}else e.setState((function(e){return{newOrderForm:(0,m.Z)((0,m.Z)({},e.newOrderForm),{},(0,d.Z)({},n,a))}}))},e.handleNewOrderListingChange=function(t,r,n){e.setState((function(e){var a=(0,i.Z)(e.newOrderForm.listings);return a[t]="product"===r?(0,m.Z)((0,m.Z)({},a[t]),{},{product_code:n?n.value:"",sku:n?n.sku_code:"",size:n?n.size:"",title:n?n.product_name:"",img_url:n?n.img_url:"",custom_field_1:n&&n.custom_field_1||"",custom_field_2:n&&n.custom_field_2||"",is_parent_product:!!n&&!!n.is_parent_product}):(0,m.Z)((0,m.Z)({},a[t]),{},(0,d.Z)({},r,n)),{newOrderForm:(0,m.Z)((0,m.Z)({},e.newOrderForm),{},{listings:a})}}))},e.isTruthySesProductFlag=function(e){return!0===e||1===e||"true"===String(e||"").toLowerCase()},e.mergeListingChildProductsFromCatalog=function(e,t){if(!t||!Array.isArray(t.child_products)||0===t.child_products.length)return e;var r=t.child_products.map((function(e){var t={product_code:String(e.product_code||"").trim(),quantity:null!=e.quantity&&""!==e.quantity?Math.max(1,Number(e.quantity)||1):1};
1return null!=e._id&&""!==e._id&&(t._id=e._id),t}));return(0,m.Z)((0,m.Z)({},e),{},{child_products:r})},e.buildOrderMetadataWithParentCustomField=function(e,t){var r=(Array.isArray(t)?t:[]).filter((function(e){return e&&Array.isArray(e.child_products)&&e.child_products.length>0})),n=r.map((function(e){return String(e.custom_field_1||"").trim()})).find((function(e){return""!==e})),a=r.map((function(e){return String(e.custom_field_2||"").trim()})).find((function(e){return""!==e})),i=(0,m.Z)({},e||{});return n?i.parent_product_custom_field_1=n:delete i.parent_product_custom_field_1,a?i.parent_product_custom_field_2=a:delete i.parent_product_custom_field_2,i},e.expandNewOrderListingsForParentProducts=function(t,r){for(var n=[],a=function(){var a=t[i],o=a.product_code;if(!o)return n.push(a),"continue";var l,s=r.find((function(e){return String(e.product_code||"").trim().toUpperCase()===String(o).trim().toUpperCase()}));if(!s)return n.push(a),"continue";if(e.isTruthySesProductFlag(s.is_parent_product)){var d=null!=a.quantity&&""!==a.quantity?Number(a.quantity):1,c=Number.isFinite(d)&&d>0?d:1,u=s.images&&s.images.length>0&&s.images[0].image_link?s.images[0].image_link:a.img_url||"";l={product_code:s.product_code,sku:s.sku_code,size:s.size,title:s.product_name||a.title,img_url:u,custom_field_1:null!=s.custom_field_1&&""!==String(s.custom_field_1).trim()?s.custom_field_1:a.custom_field_1||"",custom_field_2:null!=s.custom_field_2&&""!==String(s.custom_field_2).trim()?s.custom_field_2:a.custom_field_2||"",quantity:c}}else l=(0,m.Z)({},a);n.push(e.mergeListingChildProductsFromCatalog(l,s))},i=0;i<t.length;i+=1)a();return{listings:n,error:null}},e.handleAddNewOrder=(0,l.Z)((0,o.Z)().mark((function t(){var r,n,a,i,l,s,d,c,u,h,p,g,f,x,_,v,y,S,b,C,j;return(0,o.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=e.state.newOrderForm,l="wait_for_processing",s=[],t.prev=3,t.next=6,L.ht.getSESProducts({currentPage:1,itemsPerPage:9999,sortBy:"product_code",sortOrder:1});case 6:u=t.sent,s=(null===u||void 0===u||null===(d=u.data)||void 0===d||null===(c=d.data)||void 0===c?void 0:c.result)||[],t.next=14;break;case 10:t.prev=10,t.t0=t.catch(3),console.error("getSESProducts for new order:",t.t0),s=e.props.products||[];case 14:if(!(h=e.expandNewOrderListingsForParentProducts(i.listings,s)).error){t.next=18;break}return e.handleShowToast(h.error,"danger"),t.abrupt("return");case 18:p=e.getGeneralConfig(),g=String(null!==(r=p[He.yn])&&void 0!==r?r:"").trim(),f=""!==g,delete(x=(0,m.Z)({},i)).order_id,_=i.order_id||"ODR"+Date.now(),v=!0===e.getGeneralConfig()[He.CN],y=!0===p[He.x0],S=!0===p[He.Ib],b=!0===p[He.e2],C=String(i.shop_name||"").trim(),(j=(0,m.Z)((0,m.Z)((0,m.Z)((0,m.Z)({},x),{},{added_reason:e.resolveAddedReasonSelectValue(i.added_reason,!1),listings:h.listings.map((function(e){return b?(0,m.Z)((0,m.Z)({},e),{},{qty_failed:Number.isFinite(parseInt(e.qty_failed,10))?parseInt(e.qty_failed,10):0}):e})),order_date:i.order_date.toISOString(),status:l,group_child_products:y,separate_large_order:S,perform_by_team:e.getPerformByTeam()},!0===e.getGeneralConfig()[He.QE]?{ref_company_ids:(0,st.ki)(e.props.user)?(null===(n=e.props.user)||void 0===n?void 0:n.ref_company_ids)||"":i.ref_company_ids||(null===(a=e.props.user)||void 0===a?void 0:a.ref_company_ids)||""}:{}),String(i.order_id||"").trim()?{order_id:String(i.order_id).trim()}:f?{is_incremental_order:!0}:{order_id:_}),v?{customer_name:C,email:"",shipping_address:"",ioss:"",reference_code:""}:{})).metadata=e.buildOrderMetadataWithParentCustomField(i.metadata,j.listings),e.props.updateOrders([j]).then((function(){e.setState({showAddOrderModal:!1}),e.loadOrders(),e.handleShowToast("Order added successfully")})).catch((function(t){console.error("Error adding order:",t),e.handleShowToast("Failed to add order","danger")}));case 32:case"end":return t.stop()}}),t,null,[[3,10]])}))),e.handleShopNameChange=function(t){t&&!e.getMergedShopOptions().find((function(e){return e.value===t.value}))&&e.setState((function(e){return{extraShopOptions:[].concat((0,i.Z)(e.extraShopOptions),[{value:t.value,label:t.label||t.value,company_id:t.company_id,company_
1shortcode:t.company_shortcode}])}}));var r=t?t.value:"",n=!0===e.getGeneralConfig()[He.CN];if(e.setState((function(e){return{newOrderForm:(0,m.Z)((0,m.Z)({},e.newOrderForm),{},{shop_name:r},n?{customer_name:r}:{})}})),r)try{localStorage.setItem(e.getNewOrderShopStorageKey(),r)}catch(a){}},e.handleExportSGB=(0,l.Z)((0,o.Z)().mark((function t(){var r,n,a,i,l,s,d,c;return(0,o.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(0!==(r=Array.from(e.state.selectedOrders)).length){t.next=4;break}return e.handleShowToast("Vui l\xf2ng ch\u1ecdn \xedt nh\u1ea5t m\u1ed9t \u0111\u01a1n h\xe0ng \u0111\u1ec3 g\u1eedi SGB!","warning"),t.abrupt("return");case 4:if(0!==(n=(e.props.orders||[]).filter((function(e){return r.includes(e.order_id)&&!e.is_deleted}))).length){t.next=8;break}return e.handleShowToast("Kh\xf4ng c\xf3 \u0111\u01a1n n\xe0o h\u1ee3p l\u1ec7 \u0111\u1ec3 g\u1eedi SGB!","warning"),t.abrupt("return");case 8:if(0!==(a=n.map((function(e){return e.monthly_id})).filter((function(e){return e}))).length){t.next=12;break}return e.handleShowToast("Kh\xf4ng c\xf3 monthly_id h\u1ee3p l\u1ec7 trong c\xe1c \u0111\u01a1n \u0111\xe3 ch\u1ecdn \u0111\u1ec3 g\u1eedi SGB!","warning"),t.abrupt("return");case 12:if(t.prev=12,i=a.join(","),l=(0,B.LP)()){t.next=18;break}return e.handleShowToast("Kh\xf4ng t\xecm th\u1ea5y token \u0111\u0103ng nh\u1eadp!","danger"),t.abrupt("return");case 18:return s="".concat((0,U.kG)(),"/api/order/export-data-sgb?monthly_ids=").concat(i),t.next=21,fetch(s,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(l)}});case 21:return d=t.sent,t.next=24,d.json();case 24:1===(c=t.sent).status&&c.data&&c.data.sheetUrl?(window.open(c.data.sheetUrl,"_blank"),e.handleShowToast("\u0110\xe3 g\u1eedi y\xeau c\u1ea7u v\xe0 m\u1edf Google Sheet SGB!")):e.handleShowToast(c.message||"\u0110\xe3 g\u1eedi y\xeau c\u1ea7u c\u1eadp nh\u1eadt Google Sheet cho SGB!"),t.next=31;break;case 28:t.prev=28,t.t0=t.catch(12),e.handleShowToast("G\u1eedi SGB th\u1ea5t b\u1ea1i!","danger");case 31:case"end":return t.stop()}}),t,null,[[12,28]])}))),e.handleExportTHE=(0,l.Z)((0,o.Z)().mark((function t(){var r,n,a,i,l,s,d,c;return(0,o.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(0!==(r=Array.from(e.state.selectedOrders)).length){t.next=4;break}return e.handleShowToast("Vui l\xf2ng ch\u1ecdn \xedt nh\u1ea5t m\u1ed9t \u0111\u01a1n h\xe0ng \u0111\u1ec3 g\u1eedi THE!","warning"),t.abrupt("return");case 4:if(0!==(n=(e.props.orders||[]).filter((function(e){return r.includes(e.order_id)&&!e.is_deleted}))).length){t.next=8;break}return e.handleShowToast("Kh\xf4ng c\xf3 \u0111\u01a1n n\xe0o h\u1ee3p l\u1ec7 \u0111\u1ec3 g\u1eedi THE!","warning"),t.abrupt("return");case 8:if(0!==(a=n.map((function(e){return e.monthly_id})).filter((function(e){return e}))).length){t.next=12;break}return e.handleShowToast("Kh\xf4ng c\xf3 monthly_id h\u1ee3p l\u1ec7 trong c\xe1c \u0111\u01a1n \u0111\xe3 ch\u1ecdn \u0111\u1ec3 g\u1eedi THE!","warning"),t.abrupt("return");case 12:if(t.prev=12,i=a.join(","),l=(0,B.LP)()){t.next=18;break}return e.handleShowToast("Kh\xf4ng t\xecm th\u1ea5y token \u0111\u0103ng nh\u1eadp!","danger"),t.abrupt("return");case 18:return s="".concat((0,U.kG)(),"/api/order/export-data-the?monthly_ids=").concat(i),t.next=21,fetch(s,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(l)}});case 21:return d=t.sent,t.next=24,d.json();case 24:1===(c=t.sent).status&&c.data&&c.data.sheetUrl?(window.open(c.data.sheetUrl,"_blank"),e.handleShowToast("\u0110\xe3 g\u1eedi y\xeau c\u1ea7u v\xe0 m\u1edf Google Sheet THE!")):e.handleShowToast(c.message||"\u0110\xe3 g\u1eedi y\xeau c\u1ea7u c\u1eadp nh\u1eadt Google Sheet cho THE!"),t.next=31;break;case 28:t.prev=28,t.t0=t.catch(12),e.handleShowToast("G\u1eedi THE th\u1ea5t b\u1ea1i!","danger");case 31:case"end":return t.stop()}}),t,null,[[12,28]])}))),e.handleExportViettelPost=(0,l.Z)((0,o.Z)().mark((function t(){var r,n,a,i,l,s;return(0,o.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(0!==(r=Array.from(e.state.selectedOrders)).length){t.next=4;break}return e.handleShowToast("Vui l\xf2ng ch\u1ecdn \xedt nh\u1ea5t m\u1ed9t \u0111\u01a1n h\xe0ng \u0111\u1ec3 g\u1eedi Viettel Post!","warning"),t.abrupt("return");case 4:if(0!==(n=(e.props.orders||[]).filter((function(e){return r.includes(e.order_id)&&!e.is_deleted}))).length){t.next=8;break}return e.handleShowToast("Kh\xf4ng c\xf3 \u0111\u01a1n n\xe0o h\u1ee3p l\u1ec7 \u0111\u1ec3 g\u1eedi Viettel Post!","warning"),t.abrupt("return");case 8:if(0!==(a=n.map((function(e){return e.monthly_id})).filter((function(e){return e}))).length){t.next=12;break}return e.handleShowToast("Kh\xf4ng c\xf3 monthly_id h\u1ee3p l\u1ec7 trong c\xe1c \u0111\u01a1n \u0111\xe3 ch\u1ecdn \u0111\u1ec3 g\u1eedi Viettel Post!","warning"),t.abrupt("return");case 12:return t.prev=12,i=a.join(","),t.next=16,fetch("".concat((0,U.kG)(),"/api/order/export-data-viettel-post?monthly_ids=").concat(i));
1case 16:return l=t.sent,t.next=19,l.json();case 19:1===(s=t.sent).status&&s.data&&s.data.sheetUrl?(window.open(s.data.sheetUrl,"_blank"),e.handleShowToast("\u0110\xe3 g\u1eedi y\xeau c\u1ea7u v\xe0 m\u1edf Google Sheet Viettel Post!")):e.handleShowToast(s.message||"\u0110\xe3 g\u1eedi y\xeau c\u1ea7u c\u1eadp nh\u1eadt Google Sheet cho Viettel Post!"),t.next=26;break;case 23:t.prev=23,t.t0=t.catch(12),e.handleShowToast("G\u1eedi Viettel Post th\u1ea5t b\u1ea1i!","danger");case 26:case"end":return t.stop()}}),t,null,[[12,23]])}))),e.handleBuyerNoteEdit=function(t){var r;e.setState({editingBuyerNote:t,buyerNoteValue:(null===(r=e.props.orders.find((function(e){return e.order_id===t})))||void 0===r?void 0:r.buyer_note)||""})},e.handleBuyerNoteChange=function(t){e.setState({buyerNoteValue:t.target.value})},e.handleBuyerNoteSave=function(t){var r=e.props.orders.find((function(e){return e.order_id===t}));if(r){var n={order_id:r.order_id,shop_id:r.shop_id,buyer_note:e.state.buyerNoteValue,perform_by_team:e.getPerformByTeam()};e.props.updateOrders([n],{isUpdated:!0}).then((function(){e.setState({editingBuyerNote:null})})).catch((function(e){console.error("Error updating buyer note:",e),alert("Failed to update buyer note. See console for details.")}))}},e.handleShippingAddressEdit=function(t){var r;e.setState({editingShippingAddress:t,shippingAddressValue:(null===(r=e.props.orders.find((function(e){return e.order_id===t})))||void 0===r?void 0:r.shipping_address)||""})},e.handleShippingAddressChange=function(t){e.setState({shippingAddressValue:t.target.value})},e.handleShippingAddressSave=function(t){var r=e.props.orders.find((function(e){return e.order_id===t}));if(r){var n={order_id:r.order_id,shop_id:r.shop_id,shipping_address:e.state.shippingAddressValue,perform_by_team:e.getPerformByTeam()};e.props.updateOrders([n],{isUpdated:!0}).then((function(){e.setState({editingShippingAddress:null})})).catch((function(e){console.error("Error updating shipping address:",e),alert("Failed to update shipping address. See console for details.")}))}},e.handleFulfillNoteEdit=function(t){var r;e.setState({editingFulfillNote:t,fulfillNoteValue:(null===(r=e.props.orders.find((function(e){return e.order_id===t})))||void 0===r?void 0:r.fulfill_note)||""})},e.handleFulfillNoteChange=function(t){e.setState({fulfillNoteValue:t.target.value})},e.handleFulfillNoteSave=function(t){var r=e.props.orders.find((function(e){return e.order_id===t}));if(r){var n={order_id:r.order_id,shop_id:r.shop_id,fulfill_note:e.state.fulfillNoteValue,perform_by_team:e.getPerformByTeam()};e.props.updateOrders([n],{isUpdated:!0}).then((function(){e.setState({editingFulfillNote:null})})).catch((function(e){console.error("Error updating fulfill note:",e),alert("Failed to update fulfill note. See console for details.")}))}},e.handleRealGrossWeightEdit=function(t){var r;e.setState({editingRealGrossWeight:t,realGrossWeightValue:(null===(r=e.props.orders.find((function(e){return e.order_id===t})))||void 0===r?void 0:r.real_gross_weight)||""})},e.handleRealGrossWeightChange=function(t){e.setState({realGrossWeightValue:t.target.value})},e.handleRealGrossWeightSave=function(t){var r=e.props.orders.find((function(e){return e.order_id===t}));if(r){var n=e.state.realGrossWeightValue?parseFloat(e.state.realGrossWeightValue):null,a={order_id:r.order_id,shop_id:r.shop_id,real_gross_weight:n,perform_by_team:e.getPerformByTeam()};e.props.updateOrders([a],{isUpdated:!0}).then((function(){e.setState({editingRealGrossWeight:null}),e.loadOrders()})).catch((function(e){console.error("Error updating real gross weight:",e),alert("Failed to update real gross weight. See console for details.")}))}},e.getOrderStatusCode=function(t){var r=e.props.orderStatusConfig;if(!r||!Array.isArray(r))return null;var n=t.status;if("string"===typeof n){var a=r.find((function(e){return e.enum===n}));return a?a.code:null}return Number(n)},e.canEditShippingCenterName=function(t){var r=e.getOrderStatusCode(t);return null!==r&&r<=10},e.handleCreateMonthlyId=(0,l.Z)((0,o.Z)().mark((function t(){var r,n;return(0,o.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!0===e.getGeneralConfig()[He.y4]){t.next=2;break}return t.abrupt("return");case 2:return t.prev=2,t.next=5,q.b.get("".concat((0,U.kG)(),"/api/order/create-monthly-id"));
1case 5:(r=t.sent).data&&1===r.data.status?(e.handleShowToast("T\u1ea1o m\xe3 \u0111\u01a1n th\xe0nh c\xf4ng!"),e.loadOrders()):e.handleShowToast((null===(n=r.data)||void 0===n?void 0:n.message)||"T\u1ea1o m\xe3 \u0111\u01a1n th\u1ea5t b\u1ea1i!","danger"),t.next=12;break;case 9:t.prev=9,t.t0=t.catch(2),e.handleShowToast("T\u1ea1o m\xe3 \u0111\u01a1n th\u1ea5t b\u1ea1i!","danger");case 12:case"end":return t.stop()}}),t,null,[[2,9]])}))),e.formatMonthlyIdToHuman=function(t){return(0,He.H7)(t,e.props.currentCompany)},e.formatOrderIdToHuman=function(t){return(0,He.a4)(t,e.props.currentCompany)},e.handleEditListingOnly=function(t,r,n){var a,i=e.props.products,o=void 0===i?[]:i,l="";if(r.sku&&r.size){var s=o.find((function(e){return e.sku_code===r.sku&&e.size===r.size}));s&&(l=s.product_code)}e.setState((a={showEditModal:!0,currentOrder:t,currentListing:(0,m.Z)((0,m.Z)({},r),{},{product_code:l}),currentListingIndex:n,editForm:{sku:r.sku,size:r.size,title:r.title,product_code:l||"",quantity:r.quantity||1},editMode:"listing"},(0,d.Z)(a,"currentListingIndex",n),(0,d.Z)(a,"isAddingListing",!1),a))},e.handleEditOrderOnly=function(t){e.setState({showEditModal:!0,currentOrder:t,currentListing:null,currentListingIndex:null,editForm:{order_id:t.order_id||"",customer_name:e.isSimpleOrderEnabled()?t.shop_name||"":t.customer_name||"",email:t.email||"",shipping_address:t.shipping_address||"",buyer_note:t.buyer_note||"",seller_note:t.seller_note||"",priority:t.priority||2,ioss:t.ioss||"",order_date:t.order_date?new Date(t.order_date):new Date,added_reason:t.added_reason||"ETSY_NEW_ORDER",deadline_fulfill_hours:null!=t.deadline_fulfill_hours?String(t.deadline_fulfill_hours):""},editMode:"order",editListingIndex:null,isAddingListing:!1})},e.isSimpleOrderEnabled=function(){return!0===e.getGeneralConfig()[He.CN]},e.handleCreateOrderCustomAlbum=(0,l.Z)((0,o.Z)().mark((function t(){var r,n,a,i,s,d,c;return(0,o.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null!==(r=e.state.currentOrder)&&void 0!==r&&r.order_id){t.next=4;break}return e.handleShowToast("Kh\xf4ng t\xecm th\u1ea5y Order ID \u0111\u1ec3 t\u1ea1o album","danger"),t.abrupt("return");case 4:return n="ORDER_".concat(r.order_id,"_IMAGES"),a={mid:n,name:n,description:"Custom images for order ".concat(r.order_id),type:"ORDER_CUSTOM",status:"ACTIVE",metadata:{source:"ORDER_EDIT_MODAL",order_id:r.order_id}},i=function(){var t=(0,l.Z)((0,o.Z)().mark((function t(){var a;return(0,o.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a={order_id:r.order_id,shop_id:r.shop_id,metadata:(0,m.Z)((0,m.Z)({},r.metadata||{}),{},{order_custom_album:n})},t.next=3,e.props.updateOrders([a],{isUpdated:!0});case 3:e.setState((function(e){var t;return{currentOrder:(0,m.Z)((0,m.Z)({},e.currentOrder),{},{metadata:(0,m.Z)((0,m.Z)({},(null===(t=e.currentOrder)||void 0===t?void 0:t.metadata)||{}),{},{order_custom_album:n})})}}));case 4:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),e.setState({creatingOrderAlbum:!0}),t.prev=8,t.next=11,ot.bN.createImageAlbum(a);case 11:return t.next=13,i();case 13:e.handleShowToast("T\u1ea1o album th\xe0nh c\xf4ng: ".concat(n)),window.open("/admin/se-media/album-detail/".concat(encodeURIComponent(n)),"_blank"),t.next=28;break;case 17:if(t.prev=17,t.t0=t.catch(8),!(c=((null===t.t0||void 0===t.t0||null===(s=t.t0.response)||void 0===s||null===(d=s.data)||void 0===d?void 0:d.message)||(null===t.t0||void 0===t.t0?void 0:t.t0.message)||"").toLowerCase()).includes("exist")&&!c.includes("duplicate")){t.next=27;break}return t.next=23,i();case 23:e.handleShowToast("Album \u0111\xe3 t\u1ed3n t\u1ea1i: ".concat(n),"warning"),window.open("/admin/se-media/album-detail/".concat(encodeURIComponent(n)),"_blank"),t.next=28;break;case 27:e.handleShowToast("T\u1ea1o album th\u1ea5t b\u1ea1i","danger");case 28:return t.prev=28,e.setState({creatingOrderAlbum:!1}),t.finish(28);case 31:case"end":return t.stop()}}),t,null,[[8,17,28,31]])}))),e.handleViewOrderCustomAlbum=function(t){var r=null!==t&&void 0!==t&&t.order_id?"ORDER_".concat(t.order_id,"_IMAGES"):null;r&&e.setState({showCustomAlbumModal:!0,customAlbumUrl:"/admin/se-media/album-detail/".concat(encodeURIComponent(r)),customAlbumTitle:"Custom Album - ".concat(r)})},e.handleOpenOrderCustomAlbumInNewTab=function(e){var t=null!==e&&void 0!==e&&e.order_id?"ORDER_".concat(e.order_id,"_IMAGES"):null;t&&window.open("/admin/se-media/album-detail/".concat(encodeURIComponent(t)),"_blank")},e.handleOpenOrCreateOrderCustomAlbum=function(t){var r=null===t||void 0===t?void 0:t.order_id;if(r){var n="ORDER_".concat(r,"_IMAGES");
1e.setState({showCustomAlbumModal:!0,customAlbumUrl:"/admin/se-media/album-detail/".concat(encodeURIComponent(n)),customAlbumTitle:"Custom Album - ".concat(n)})}else e.handleShowToast("Kh\xf4ng t\xecm th\u1ea5y Order ID \u0111\u1ec3 m\u1edf album","danger")},e.isOrderAlreadyShippedToShippingCenter=function(e){if(!e)return!1;var t=Y.QS.getCodeByEnum(Y.vl.SHIPPED_TO_SHIPPING_CENTER),r=e.status;if(null==r||""===r)return!1;if("string"===typeof r){if(r===Y.vl.SHIPPED_TO_SHIPPING_CENTER)return!0;var n=Number(r);return Number.isFinite(n)&&null!=t&&n===t}return Number(r)===t},e.fetchOrderDetailRealtime=function(){var e=(0,l.Z)((0,o.Z)().mark((function e(t){var r,n;return(0,o.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,q.b.get("".concat((0,U.kG)(),"/api/order/detail/").concat(encodeURIComponent(t)));case 2:return n=e.sent,e.abrupt("return",(null===n||void 0===n||null===(r=n.data)||void 0===r?void 0:r.data)||(null===n||void 0===n?void 0:n.data)||null);case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.buildExportItemsFromOrders=function(e){var t={};(e||[]).forEach((function(e){(e.listings||[]).forEach((function(r){var n=parseInt(r.quantity,10),a=Number.isFinite(n)&&n>0?n:1,i=parseInt(r.qty_failed,10),o=Number.isFinite(i)&&i>0?i:0,l=r.sku||"",s=r.size||"",d=l&&s?"".concat(l,"-").concat(s):l||"",c="".concat(d,"__").concat(l,"__").concat(s);t[c]||(t[c]={product_code:d,sku:l,size:s,title:r.title||"",quantity:0,qty_failed:0,orderIds:{}}),t[c].quantity+=a,t[c].qty_failed+=o,e.monthly_id&&(t[c].orderIds[e.monthly_id]||(t[c].orderIds[e.monthly_id]=0),t[c].orderIds[e.monthly_id]+=a)}))}));var r=/^(BOX\d+)-([A-Z])$/,n={};Object.values(t).forEach((function(e){var t=e.sku.match(r);if(t){var a=t[1],i=e.size||"";if(i){var o="".concat(a,"-").concat(i,"__").concat(a,"__").concat(i);n[o]||(n[o]={product_code:"".concat(a,"-").concat(i),sku:a,size:i,quantity:0,qty_failed:0,orderIds:{}}),n[o].quantity+=e.quantity,n[o].qty_failed+=e.qty_failed||0,Object.entries(e.orderIds).forEach((function(e){var t=(0,s.Z)(e,2),r=t[0],a=t[1];n[o].orderIds[r]||(n[o].orderIds[r]=0),n[o].orderIds[r]+=a}))}}})),Object.entries(n).forEach((function(e){var r=(0,s.Z)(e,2),n=r[0],a=r[1];t[n]?(t[n].quantity+=a.quantity,t[n].qty_failed+=a.qty_failed||0,Object.entries(a.orderIds).forEach((function(e){var r=(0,s.Z)(e,2),a=r[0],i=r[1];t[n].orderIds[a]||(t[n].orderIds[a]=0),t[n].orderIds[a]+=i}))):t[n]=a}));var a=Object.values(t).map((function(e){return(0,m.Z)((0,m.Z)({},e),{},{orderIds:Object.entries(e.orderIds).map((function(e){var t=(0,s.Z)(e,2);return{monthly_id:t[0],count:t[1]}}))})})),i={M:1,L:2,XL:3,XXL:4};return a=a.sort((function(e,t){return e.sku===t.sku?(i[e.size]||0)-(i[t.size]||0):(e.sku||"").localeCompare(t.sku||"")}))},e.handleShowExportModal=function(){var t=e.props.orders,r=void 0===t?[]:t,n=Array.from(e.state.selectedOrders),a=r.filter((function(e){return n.includes(e.order_id)})),i=e.buildExportItemsFromOrders(a);e.setState({showExportModal:!0,exportMode:"NORMAL",exportFailTargetStatus:"",exportItems:i,exportWarehouse:localStorage.getItem("orderExportWarehouse_fulfill")||"",exportNote:"",exportSaving:!1})},e.handleShowExportFailModal=function(){var t=e.props.orders,r=void 0===t?[]:t,n=Array.from(e.state.selectedOrders),a=r.filter((function(e){return n.includes(e.order_id)})),i=e.buildExportItemsFromOrders(a);e.setState({showExportModal:!0,exportMode:"FAIL",exportFailTargetStatus:Y.vl.FAIL_REASON_1,exportItems:i,exportWarehouse:localStorage.getItem("orderExportWarehouse_fulfill")||"",exportNote:"",exportSaving:!1})},e.exportSGBSilently=function(){var e=(0,l.Z)((0,o.Z)().mark((function e(t){var r,n,a,i,l;return(0,o.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,r=t.join(","),n=(0,B.LP)()){e.next=5;break}return e.abrupt("return");case 5:return a="".concat((0,U.kG)(),"/api/order/export-data-sgb?monthly_ids=").concat(r),e.next=8,fetch(a,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(n)}});case 8:return i=e.sent,e.next=11,i.json();case 11:return l=e.sent,e.abrupt("return",l);case 15:return e.prev=15,e.t0=e.catch(0),e.abrupt("return",null);case 18:case"end":return e.stop()}}),e,null,[[0,15]])})));return function(t){return e.apply(this,arguments)}}(),e.exportTHESilently=function(){var e=(0,l.Z)((0,o.Z)().mark((function e(t){var r,n,a,i,l;return(0,o.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,r=t.join(","),n=(0,B.LP)()){e.
1next=5;break}return e.abrupt("return");case 5:return a="".concat((0,U.kG)(),"/api/order/export-data-the?monthly_ids=").concat(r),e.next=8,fetch(a,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(n)}});case 8:return i=e.sent,e.next=11,i.json();case 11:return l=e.sent,e.abrupt("return",l);case 15:return e.prev=15,e.t0=e.catch(0),e.abrupt("return",null);case 18:case"end":return e.stop()}}),e,null,[[0,15]])})));return function(t){return e.apply(this,arguments)}}(),e.exportViettelPostSilently=function(){var e=(0,l.Z)((0,o.Z)().mark((function e(t){var r,n,a;return(0,o.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,r=t.join(","),e.next=4,fetch("".concat((0,U.kG)(),"/api/order/export-data-viettel-post?monthly_ids=").concat(r));case 4:return n=e.sent,e.next=7,n.json();case 7:return a=e.sent,e.abrupt("return",a);case 11:return e.prev=11,e.t0=e.catch(0),e.abrupt("return",null);case 14:case"end":return e.stop()}}),e,null,[[0,11]])})));return function(t){return e.apply(this,arguments)}}(),e.handleExportSubmit=(0,l.Z)((0,o.Z)().mark((function t(){var r,n,a,i,l,s,d,c,u,h,p,g,m,f,x,_,v,y,S,b,C,j,T,O,w,F,N,E,L,I,Z,k;return(0,o.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.state,n=r.exportWarehouse,a=r.exportNote,i=r.exportSaving,l=r.exportMode,s=r.exportFailTargetStatus,n&&!i){t.next=3;break}return t.abrupt("return");case 3:if(!(d="FAIL"===l)||s){t.next=7;break}return e.handleShowToast("Vui l\xf2ng ch\u1ecdn tr\u1ea1ng th\xe1i \u0111\xedch cho Xu\u1ea5t l\u1ed7i.","warning"),t.abrupt("return");case 7:if(e.setState({exportSaving:!0}),t.prev=8,c=e.getOrderQtyFailedMeta(),u=!0===c.enabled,e.props.products&&0!==e.props.products.length){t.next=18;break}return t.next=14,e.props.getSIVProductList();case 14:if(e.props.products&&0!==e.props.products.length){t.next=18;break}return e.handleShowToast("Kh\xf4ng th\u1ec3 load danh s\xe1ch s\u1ea3n ph\u1ea9m. Vui l\xf2ng th\u1eed l\u1ea1i sau.","danger"),e.setState({exportSaving:!1}),t.abrupt("return");case 18:return h=e.props.orders||[],p=Array.from(e.state.selectedOrders),g=h.filter((function(e){return p.includes(e.order_id)&&!e.is_deleted})),t.next=23,Promise.allSettled(g.map((function(t){return e.fetchOrderDetailRealtime(t.order_id)})));case 23:if(m=t.sent,!((f=m.filter((function(e){return"rejected"===e.status}))).length>0)){t.next=29;break}return e.handleShowToast("Kh\xf4ng th\u1ec3 check realtime tr\u1ea1ng th\xe1i cho ".concat(f.length,"/").concat(g.length," \u0111\u01a1n. Vui l\xf2ng th\u1eed l\u1ea1i."),"danger"),e.setState({exportSaving:!1}),t.abrupt("return");case 29:if(x=m.map((function(e){return"fulfilled"===e.status?e.value:null})).filter((function(e){return e&&!e.is_deleted})),_=d?[]:x.filter((function(t){return e.isOrderAlreadyShippedToShippingCenter(t)})),0!==(v=d?x:x.filter((function(t){return!e.isOrderAlreadyShippedToShippingCenter(t)}))).length){t.next=36;break}return e.handleShowToast(_.length>0?"C\xe1c \u0111\u01a1n \u0111\xe3 ch\u1ecdn \u0111\u1ec1u \u0111\xe3 \u1edf tr\u1ea1ng th\xe1i \u0110\xe3 g\u1eedi \u0110VVC (15) \u2014 kh\xf4ng xu\u1ea5t l\u1ea1i.":"Kh\xf4ng c\xf3 \u0111\u01a1n h\u1ee3p l\u1ec7 \u0111\u1ec3 xu\u1ea5t.","warning"),e.setState({exportSaving:!1}),t.abrupt("return");case 36:if(_.length>0&&e.handleShowToast("\u0110\xe3 b\u1ecf qua ".concat(_.length," \u0111\u01a1n \u0111\xe3 xu\u1ea5t (tr\u1ea1ng th\xe1i 15). Ch\u1ec9 xu\u1ea5t ").concat(v.length," \u0111\u01a1n c\xf2n l\u1ea1i."),"info"),y=e.buildExportItemsFromOrders(v),S=v.map((function(t){var r=e.formatMonthlyIdToHuman(t.monthly_id),n=e.formatOrderIdToHuman(t.order_id)||t.order_id||"";return r&&"-"!==r?r:n})).filter(Boolean),b=Array.from(new Set(S)).join(","),0!==(C=y.map((function(t){var r=(e.props.products||[]).find((function(e){return e.product_code===t.product_code})),n=r&&r.current_qty||0,a=parseInt(t.quantity,10),i=Number.isFinite(a)&&a>0?a:0,o=parseInt(t.qty_failed,10),l=Number.isFinite(o)&&o>0?o:0,s=-(d?l:u?Math.max(i-l,0):i),c=r?n+s:void 0,h=t.title||(null===r||void 0===r?void 0:r.product_name)||(null===r||void 0===r?void 0:r.title)||(null===r||void 0===r?void 0:r.name)||"";return{product_code:t.product_code,product_name:h,quantity_change:s,quantity:c,warehouse_id:1}})).filter((function(e){return 0!==e.quantity_change}
1))).length){t.next=45;break}return e.handleShowToast("Kh\xf4ng c\xf3 s\u1ea3n ph\u1ea9m c\u1ea7n xu\u1ea5t (SL xu\u1ea5t = 0).","warning"),e.setState({exportSaving:!1}),t.abrupt("return");case 45:return t.next=47,e.props.setSIVProductInventoryTransaction({type:"EXPORT",partner_id:n,staff_note:a,system_note:b,items:C});case 47:if(j=t.sent,!0!==e.getGeneralConfig()[He.V4]){t.next=64;break}if(!(T=(null===j||void 0===j?void 0:j._id)||(null===j||void 0===j?void 0:j.transaction_id))){t.next=63;break}return t.prev=52,t.next=55,q.b.post("".concat((0,U.kG)(),"/api/siv-product-inventory-transaction/sync-partner"),{transaction_id:T});case 55:e.handleShowToast("Sync partner transaction th\xe0nh c\xf4ng"),t.next=61;break;case 58:t.prev=58,t.t0=t.catch(52),e.handleShowToast("Sync partner th\u1ea5t b\u1ea1i: ".concat((null===t.t0||void 0===t.t0||null===(O=t.t0.response)||void 0===O||null===(w=O.data)||void 0===w?void 0:w.message)||(null===t.t0||void 0===t.t0?void 0:t.t0.message)||"L\u1ed7i"),"danger");case 61:t.next=64;break;case 63:e.handleShowToast("Sync partner: kh\xf4ng l\u1ea5y \u0111\u01b0\u1ee3c transaction_id t\u1eeb response","warning");case 64:return F=d?s:Y.vl.SHIPPED_TO_SHIPPING_CENTER,N=v.map((function(e){return{order_id:e.order_id,status:F,perform_by_team:"FULFILL"}})),t.next=68,e.props.updateOrders(N);case 68:if(d){t.next=88;break}if(!((E=v.map((function(e){return e.monthly_id})).filter((function(e){return e}))).length>0)){t.next=88;break}if(L=(0,U.fL)(e.props.currentCompany,e.props.publicPartners),I=L.find((function(e){return e.value===n})),Z=I&&I.company_shortcode||"",k=n,"SGB"!==Z&&"SAIGONBAY"!==k){t.next=80;break}return t.next=78,e.exportSGBSilently(E);case 78:t.next=88;break;case 80:if("VTPOST"!==Z&&"VIETTEL_POST"!==k){t.next=85;break}return t.next=83,e.exportViettelPostSilently(E);case 83:t.next=88;break;case 85:if("THE"!==Z&&"THE"!==k){t.next=88;break}return t.next=88,e.exportTHESilently(E);case 88:e.setState({showExportModal:!1,exportSaving:!1}),e.loadOrders(),e.handleShowToast(d?"Xu\u1ea5t l\u1ed7i v\xe0 c\u1eadp nh\u1eadt tr\u1ea1ng th\xe1i th\xe0nh c\xf4ng!":"Xu\u1ea5t h\xe0ng v\xe0 c\u1eadp nh\u1eadt tr\u1ea1ng th\xe1i th\xe0nh c\xf4ng!"),t.next=97;break;case 93:t.prev=93,t.t1=t.catch(8),e.setState({exportSaving:!1}),e.handleShowToast(d?"L\u1ed7i khi Xu\u1ea5t l\u1ed7i ho\u1eb7c c\u1eadp nh\u1eadt tr\u1ea1ng th\xe1i!":"L\u1ed7i khi xu\u1ea5t h\xe0ng ho\u1eb7c c\u1eadp nh\u1eadt tr\u1ea1ng th\xe1i!","danger");case 97:case"end":return t.stop()}}),t,null,[[8,93],[52,58]])}))),e.getShopDisplayName=function(t){if(!t)return t;var r=e.getMergedShopOptions().find((function(e){return e.value===t}));return null!==r&&void 0!==r&&r.company_shortcode?r.company_shortcode:t},e.handlePrintDebtOrders=function(){var t=e.props.orders,r=void 0===t?[]:t,n=e.state.selectedOrders,a=r.filter((function(e){return n.has(e.order_id)}));if(0!==a.length){var i=window.open("","_blank"),o=function(e,t){var r=t.formatMonthlyIdToHuman,n=t.getShopDisplayName,a=e.map((function(e){var t=e.listings[0]||{},a=r(e.monthly_id),i=e.shipping_address?e.shipping_address.split("\n")[0].trim():"-",o=n(e.shop_name)||e.shop_name;return"\n        <tr>\n          <td>".concat(o||"-","</td>\n          <td>").concat(a||"-","</td>\n          <td>").concat(i,"</td>\n          <td><b>").concat(t.sku||"-","</b></td>\n          <td><b>").concat(t.size||"-","</b></td>\n        </tr>\n      ")})).join("");return"\n    <html>\n      <head>\n        <title>In M\xe3 \u0110\u01a1n N\u1ee3</title>\n        <style>\n          @page { margin: 0; padding: 0; }\n          body { margin: 0; padding: 0; }\n          table { width: 100%; border-collapse: collapse; margin: 0; padding: 0; }\n          td { border: 1px solid #ddd; padding: 8px; text-align: left; font-size: 28px; height: 180px; text-align: center; }\n          tr { height: 150px; }\n          b { font-weight: bold; }\n        </style>\n      </head>\n      <body>\n        <table>\n          <tbody>\n            ".concat(a,"\n          </tbody>\n        </table>\n      </body>\n    </html>\n  ")}(a,{formatMonthlyIdToHuman:e.formatMonthlyIdToHuman,getShopDisplayName:e.getShopDisplayName});i.document.write(o),i.document.close(),i.focus(),setTimeout((function(){i.print(),i.close()}),500)}else e.handleShowToast("Kh\xf4ng c\xf3 \u0111\u01a1n n\u1ee3 n\xe0o \u0111\u01b0\u1ee3c ch\u1ecdn","warning")},e.handlePrintOrderDetails=(0,l.Z)((0,o.Z)().mark((function t(){var r,n,a,i,l,s,d;return(0,o.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.props.orders,n=void 0===r?[]:r,a=Array.from(e.state.selectedOrders),i=n.filter((function(e){return a.includes(e.order_id)})),l=window.open("","_blank")){t.next=7;break}return alert("Please allow popups for this website"),t.abrupt("return");case 7:return t.next=9,rt(i,{apiUrl:(0,U.kG)(),token:(0,B.LP)(),domain:window.location.hostname});case 9:s=t.sent,d=it(s,{formatMonthlyIdToHuman:e.formatMonthlyIdToHuman,getShopDisplayName:e.getShopDisplayName}),l.document.write(d),l.document.close(),setTimeout((function(){l.print(),l.close()}),300);case 14:case"end":return t.stop()}}),t)}))),e.handleScrollToTop=function(){window.scrollTo({top:0,behavior:"smooth"})},e.handleScrollToBottom=function(){window.scrollTo({top:document.documentElement.scrollHeight,behavior:"smooth"})},e.getDisplayCustomerName=function(e){if("Sign in with Apple user"===e.customer_name&&e.shipping_address)return e.shipping_address.split("\n")[0].trim()||e.customer_name;return e.customer_name},e.getProductCodeFromListing=function(t){if(t.product_code)return t.product_code;if(t.sku&&t.size&&e.props.products){var r=e.props.products.find((function(e){return e.sku_code===t.sku&&e.size===t.size}));if(r)return r.product_code}if(t.sku&&e.props.products){var n=e.props.products.find((function(e){return e.sku_code===t.sku}));return n?n.product_code:null}return null},e.handleViewQuantityChanges=function(t){var r=e.getProductCodeFromListing(t);if(r){var n="";if(e.props.products){var a=null;t.product_code?a=e.props.products.find((function(e){return e.product_code===t.product_code})):t.sku&&t.size?a=e.props.products.find((function(e){return e.sku_code===t.sku&&e.size===t.size})):t.sku&&(a=e.props.products.find((function(e){return e.sku_code===t.sku}))),n=a?a.product_name:""}e.setState({showQuantityChangeModal:!0,selectedProductCode:r,selectedProductName:n})}else alert("Kh\xf4ng t\xecm th\u1ea5y product_code cho s\u1ea3n ph\u1ea9m n\xe0y")},e.handleViewMetadata=function(t){e.setState({showMetadataModal:!0,selectedMetadata:t.metadata||null,selectedMetadataOrderId:t.order_id})},e.handleSaveMetadata=function(){var t=(0,l.Z)((0,o.Z)().mark((function t(r){var n;return(0,o.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.state.selectedMetadataOrderId){t.next=3;break}return t.abrupt("return");case 3:return t.prev=3,t.next=6,q.b.put("".concat((0,U.kG)(),"/api/order/").concat(n),{metadata:r});case 6:e.setState({selectedMetadata:r}),e.handleShowToast("\u0110\xe3 c\u1eadp nh\u1eadt metadata"),e.loadOrders(),t.next=15;break;case 11:throw t.prev=11,t.t0=t.catch(3),e.handleShowToast("C\u1eadp nh\u1eadt metadata th\u1ea5t b\u1ea1i","danger"),t.t0;case 15:case"end":return t.stop()}}),t,null,[[3,11]])})));return function(e){return t.apply(this,arguments)}}(),e.canViewMetadataInAction=function(){return!0},e}
1return(0,u.Z)(r,[{key:"componentDidMount",value:function(){var e=this;this.props.getOrderStatusConfig();var t,r=new URLSearchParams(window.location.search),n=this.props.targetPage||"sale",a=localStorage.getItem("orderDateFilter_".concat(n)),i=null==(t=a||r.get("date_filter")||"yesterday")||""===t?"yesterday":(0,ie.XN)({this_month:"month_0",last_month:"month_1",last_2_months:"month_2",debt_14_days:"last_30_days",debt_noel:"last_30_days",year_1:"last_year",year_2023:"last_year",sale_2023:"last_sale",year_minus_2:"last_year",sale_minus_2:"last_sale"}[t]||t),o=parseInt(r.get("page"))||1,l=parseInt(r.get("per_page"))||parseInt(localStorage.getItem("orderItemsPerPage_".concat(n)))||20,s=localStorage.getItem("orderShopFilter_".concat(n))||"All",d=r.get("status")||localStorage.getItem("orderStatusFilter_".concat(n))||"",c="true"===localStorage.getItem("orderDisableStatusRestriction_".concat(n)),u=localStorage.getItem("orderIsUsFilter_".concat(n))||"",h=localStorage.getItem("orderShippingCenterNameFilter_".concat(n))||"",p=localStorage.getItem("orderPriorityFilter_".concat(n))||"",g=r.get("custom_filter_1")||localStorage.getItem("orderCustomFilter1_".concat(n))||"",f=r.get("custom_filter_2")||localStorage.getItem("orderCustomFilter2_".concat(n))||"",x=localStorage.getItem("orderShippingCenterDateFrom_".concat(n))?new Date(localStorage.getItem("orderShippingCenterDateFrom_".concat(n))):null,_=localStorage.getItem("orderShippingCenterDateTo_".concat(n))?new Date(localStorage.getItem("orderShippingCenterDateTo_".concat(n))):null,v="true"===localStorage.getItem("orderShowShippingCenterDateFilter_".concat(n)),y=localStorage.getItem("orderKeyword_".concat(n))||"",S=("fulfill"===n||"rnd"===n||"sale"===n)&&(r.get("executor_user")||localStorage.getItem("orderExecutorUserFilter_".concat(n)))||"",b="fulfill"===n&&localStorage.getItem("orderAvailableFilter_fulfill")||"",C="false"!==localStorage.getItem("orderStickHeader_".concat(n)),j=localStorage.getItem("orderCustomStartDate_".concat(n))?new Date(localStorage.getItem("orderCustomStartDate_".concat(n))):new Date,T=localStorage.getItem("orderCustomEndDate_".concat(n))?new Date(localStorage.getItem("orderCustomEndDate_".concat(n))):new Date,O=localStorage.getItem("orderColumnVisibility_".concat(n)),w=this.state.columnVisibility;if(O)try{var F=JSON.parse(O);w=(0,m.Z)((0,m.Z)({},w),F)}catch(D){console.error("Failed to parse column visibility from localStorage",D)}var N=localStorage.getItem("orderColumnWidths_".concat(n)),E={};if(N)try{E=JSON.parse(N)}catch(D){console.error("Failed to parse column widths from localStorage",D)}var L=parseInt(localStorage.getItem("autoFulfillBatchSize"))||50,I={};try{var Z=localStorage.getItem("orderDateFilterHidden_".concat(n));Z&&(I=JSON.parse(Z)||{})}catch(D){I={}}var k={};try{var P=localStorage.getItem("orderFilterHidden_".concat(n));P&&(k=JSON.parse(P)||{})}catch(D){k={}}var R="true"===localStorage.getItem("orderListFulfillStartFinishTimeOnly_".concat(n)),A=localStorage.getItem("orderListFrozenUntilColumn_".concat(n))||"";null!=localStorage.getItem("orderListFrozenColumnCount_".concat(n))&&localStorage.removeItem("orderListFrozenColumnCount_".concat(n)),this.setState({targetPage:n,dateFilter:i,currentPage:o,itemsPerPage:l,shopFilter:s,statusFilter:d,disableStatusRestriction:c,isUsFilter:u,shippingCenterNameFilter:h,priorityFilter:p,orderCustomFilter1:g,orderCustomFilter2:f,shippingCenterDateFrom:x,shippingCenterDateTo:_,showShippingCenterDateFilter:v,keyword:y,executorUserFilter:S,availableFilter:b,columnVisibility:w,columnWidths:E,stickHeader:C,customStartDate:j,customEndDate:T,autoFulfillBatchSize:L,orderDateFilterHiddenLocal:I,orderFilterHiddenLocal:k,fulfillStartFinishTimeOnly:R,orderListFrozenUntilKey:A},(function(){e.updateURL({date_filter:i,page:o,per_page:l,custom_filter_1:g,custom_filter_2:f,executor_user:"fulfill"===n||"rnd"===n||"sale"===n?S:""}),e.ensureDateFilterStillValid()})),this.props.products&&0!==this.props.products.length||(this.setState({productListLoaded:!0}),this.props.getSESProducts({currentPage:1,itemsPerPage:9999,sortBy:"product_code",sortOrder:1})),this.loadOrderListTeamUsers(),document.addEventListener("keydown",this.handleListingImageModalKeyDown)}},{key:"componentWillUnmount",value:function(){document.removeEventListener("keydown",this.handleListingImageModalKeyDown)}},{key:"componentDidUpdate",value:function(e){var t,r,n,a,i,o,l,s,d=this;if(e.locationSearch!==this.props.locationSearch&&e.targetPage===this.props.targetPage){var c=new URLSearchParams(this.props.locationSearch||""),u=this.props.targetPage,h=c.get("status")||"",p=c.get("custom_filter_2")||"",g={};h!==this.state.statusFilter&&(g.statusFilter=h,localStorage.setItem("orderStatusFilter_".concat(u),h)),p!==this.state.orderCustomFilter2&&(g.orderCustomFilter2=p,localStorage.setItem("orderCustomFilter2_".concat(u),p)),Object.keys(g).length>0&&this.setState((0,m.Z)((0,m.Z)({},g),{},{currentPage:1,selectedOrders:new Set}),(function(){return d.loadOrders()}))}if(this.props.targetPage&&e.targetPage!==this.props.targetPage){var f={};try{var x=localStorage.getItem("orderDateFilterHidden_".concat(this.props.targetPage));x&&(f=JSON.parse(x)||{})}
1catch(M){f={}}var _={};try{var v=localStorage.getItem("orderFilterHidden_".concat(this.props.targetPage));v&&(_=JSON.parse(v)||{})}catch(M){_={}}var y=this.props.targetPage,S="fulfill"===y||"rnd"===y||"sale"===y?localStorage.getItem("orderExecutorUserFilter_".concat(y))||"":this.state.executorUserFilter,b=localStorage.getItem("orderCustomFilter1_".concat(y))||"",C=localStorage.getItem("orderCustomFilter2_".concat(y))||"",j="true"===localStorage.getItem("orderListFulfillStartFinishTimeOnly_".concat(y));null!=localStorage.getItem("orderListFrozenColumnCount_".concat(y))&&localStorage.removeItem("orderListFrozenColumnCount_".concat(y));var T=localStorage.getItem("orderListFrozenUntilColumn_".concat(y))||"";this.setState({targetPage:y,orderDateFilterHiddenLocal:f,orderFilterHiddenLocal:_,executorUserFilter:S,orderCustomFilter1:b,orderCustomFilter2:C,fulfillStartFinishTimeOnly:j,orderListFrozenUntilKey:T},(function(){return d.ensureDateFilterStillValid()}))}(null===(t=e.currentCompany)||void 0===t||null===(r=t.metadata)||void 0===r||null===(n=r.configs)||void 0===n?void 0:n.orderList)!==(null===(a=this.props.currentCompany)||void 0===a||null===(i=a.metadata)||void 0===i||null===(o=i.configs)||void 0===o?void 0:o.orderList)&&this.ensureDateFilterStillValid();var O=!0===(0,He.Dm)(e.currentCompany)[He.GY],w=!0===this.getGeneralConfig()[He.GY];if((null===(l=e.currentCompany)||void 0===l?void 0:l._id)!==(null===(s=this.props.currentCompany)||void 0===s?void 0:s._id)||O!==w){var F=(0,He.a7)(this.state.newOrderProductBundleFilter,w);F!==this.state.newOrderProductBundleFilter&&(localStorage.setItem("orderListNewOrderProductBundleFilter",F),this.setState({newOrderProductBundleFilter:F}))}var N=this.props.currentCompany&&this.props.currentCompany._id;if(N&&!this.getFilterShippingCountryEnabled()&&""!==this.state.isUsFilter){var E=this.props.targetPage||this.state.targetPage;localStorage.setItem("orderIsUsFilter_".concat(E),""),this.setState({isUsFilter:"",currentPage:1,selectedOrders:new Set},(function(){d.updateURL({is_us:"",page:1}),d.loadOrders()}))}var L=this.props.targetPage||this.state.targetPage,I=e.currentCompany&&(0,ie._o)(e.currentCompany,L),Z=this.getShowFilterFulfillEnabled();if(N&&I&&!Z&&this.state.executorUserFilter){var k=this.props.targetPage||this.state.targetPage;"sale"!==k&&"rnd"!==k&&"fulfill"!==k||localStorage.setItem("orderExecutorUserFilter_".concat(k),""),this.setState({executorUserFilter:"",currentPage:1,selectedOrders:new Set},(function(){d.updateURL({executor_user:"",page:1}),d.loadOrders()}))}if(N){var P=this.getOrderCustomFilterMeta(1),R=this.getOrderCustomFilterMeta(2),A=P.enabled&&!this.orderListIsFilterOptionHidden(P.hiddenFilterKey),D=R.enabled&&!this.orderListIsFilterOptionHidden(R.hiddenFilterKey);if(!A&&""!==this.state.orderCustomFilter1)return localStorage.setItem("orderCustomFilter1_".concat(L),""),void this.setState({orderCustomFilter1:"",currentPage:1},(function(){d.updateURL({custom_filter_1:"",page:1}),d.loadOrders()}));D||""===this.state.orderCustomFilter2||(localStorage.setItem("orderCustomFilter2_".concat(L),""),this.setState({orderCustomFilter2:"",currentPage:1},(function(){d.updateURL({custom_filter_2:"",page:1}),d.loadOrders()})))}(!e.products||0===e.products.length)&&this.props.products&&this.props.products.length>0&&this.state.productListLoaded&&this.setState({productListLoaded:!1})}},{key:"render",value:function(){var e,t,r,n,a,o=this,l=this.state,s=l.loading,d=l.dateFilter,c=l.selectedOrders,u=l.showEditModal,h=l.editForm,p=l.showConfigModal,g=l.orderListConfigModalTab,x=l.orderDateFilterHiddenLocal,_=l.orderFilterHiddenLocal,v=l.columnVisibility,E=l.showScanOrdersModal,L=l.currentPage,I=l.itemsPerPage,Z=l.totalCount,k=l.selectedBulkStatus,P=l.showRndDoneModal,R=l.rndNoteValue,D=(l.rndOrderId,l.sortBy),M=l.sortOrder,H=(l.shopFilter,l.statusFilter,l.keyword,l.showLogModal),B=l.currentOrderLogs,X=l.isShowLatestLog,V=(l.isShowSystemInfo,l.currentOrderForLog),W=l.logPagination,q=l.showCustomAlbumModal,$=l.customAlbumUrl,J=l.customAlbumTitle,ee=l.showFulfillLabelModal,te=l.showAddOrderModal,ne=(l.newOrderForm,l.showMultipleOrderModal),ae=l.multipleOrderForm,oe=l.multipleOrderSaving,de=(l.showExportModal,l.exportWarehouse,l.exportItems,l.exportNote,l.exportSaving,l.editingBuyerNote,l.buyerNoteValue,l.showTitleAndFilters),he=l.showListingImageModal,xe
1=l.listingImageForModal,_e=this.props,ve=_e.orders,be=void 0===ve?[]:ve,Ce=_e.products,Te=void 0===Ce?[]:Ce,Oe=_e.targetPage||this.state.targetPage,we=null===(e=this.props.currentCompany)||void 0===e||null===(t=e.metadata)||void 0===t||null===(r=t.configs)||void 0===r?void 0:r.orderList,Ne=this.getGeneralConfig(),Ee=(0,He.Tj)(this.props.currentCompany),Le=(0,st.ki)(this.props.user),Ie=!Le&&!0===Ne[He.qq],Ze=!Le&&!0===Ne[He.y4],ke=!0===Ne[He.CN],Pe=(Ne[He.j6],Ne[He.C6],(0,m.Z)({},v));ie.h4.forEach((function(e){(0,ie.Gk)(Oe,e,we)&&(Pe[e]=!1)})),Le&&["monthlyId","inventory","available","ioss","shippingLabelBoughtDate","shippingLabelCode","estDelivery","productCustomField1","productCustomField2"].forEach((function(e){Pe[e]=!1}));var Re=("sale"===Oe||"rnd"===Oe||"fulfill"===Oe)&&this.getShowFilterFulfillEnabled(),Ae=this.getOrderCustomFilterMeta(1),De=this.getOrderCustomFilterMeta(2),Be=this.getOrderProductCustomFieldMeta(1),Ye=this.getOrderProductCustomFieldMeta(2),Ve=this.getOrderQtyFailedMeta(),We=!0===Ve.enabled,qe=Ae.enabled&&!this.orderListIsFilterOptionHidden(Ae.hiddenFilterKey),Ke=De.enabled&&!this.orderListIsFilterOptionHidden(De.hiddenFilterKey),Qe=!this.orderListIsFilterOptionHidden("date"),$e=!this.orderListIsFilterOptionHidden("shop"),Je=!this.orderListIsFilterOptionHidden("status"),et=!this.orderListIsFilterOptionHidden("priority"),tt=!this.orderListIsFilterOptionHidden("shippingCenterName"),rt=ie.aG.filter((function(e){return"orderCustomFilter1"===e?Ae.enabled:"orderCustomFilter2"!==e||De.enabled})),nt=!Le&&Re&&"sale"===Oe&&tt;We||(Pe.orderQtyFailed=!1);var at=(0,m.Z)({},v),it=(0,ie.Gc)(Oe,we),ot={colVisTable:Pe,sortBy:D,sortOrder:M,orderQtyFailedMeta:Ve,orderCustomFilter1Meta:Ae,orderCustomFilter2Meta:De,orderProductCustomField1Meta:Be,orderProductCustomField2Meta:Ye},dt=this.getVisibleOrderListColumnKeys(it,ot),ct="rnd"!==Oe?["checkbox"].concat((0,i.Z)(dt)):(0,i.Z)(dt),ut=ct.includes(this.state.orderListFrozenUntilKey)?this.state.orderListFrozenUntilKey:"",ht=[{value:"",label:"Kh\xf4ng c\u1ed1 \u0111\u1ecbnh"}].concat((0,i.Z)(ct.map((function(e){return{value:e,label:"checkbox"===e?"Ch\u1ecdn \u0111\u01a1n":o.orderListHeaderLabel(e)}})))),pt=this.resolveOrderListFrozenCountFromUntilKey(Oe,dt,ut),gt=this.buildOrderListFrozenLayout(Oe,dt,pt);this._orderListFrozenHeaderStyles=gt.headerStyles,this._orderListLastEffectiveFrozenUntilKey=ut;var mt=(0,A.jsx)(y.Z,{xs:6,md:!0,children:(0,A.jsxs)(S.Z,{value:this.state.shippingCenterNameFilter,onChange:this.handleShippingCenterNameFilterChange,className:"mb-2","aria-label":"L\u1ecdc ".concat(this.orderListHeaderLabel("shippingCenterName")),children:[(0,A.jsx)("option",{value:"",children:"T\u1ea5t c\u1ea3 ".concat(this.orderListHeaderLabel("shippingCenterName"))}),(0,U.fL)(this.props.currentCompany,this.props.publicPartners).map((function(e){return(0,A.jsx)("option",{value:e.value,children:e.label},e.value)}))]})},"filter-shipping-center-name"),ft=function(){var e=o.state,t=e.executorUserFilter,r=e.executorUserSearch,n=e.executorUserDropdownOpen,a="T\u1ea5t c\u1ea3 ".concat(o.orderListHeaderLabel("executorUser")),i=o.state.executorUserOptions||[],l=(r||"").toLowerCase(),s=i.filter((function(e){return(null===e||void 0===e?void 0:e.username)&&(!l||(e.fullname||e.full_name||e.username).toLowerCase().includes(l)||e.username.toLowerCase().includes(l))})),d=i.find((function(e){return e.username===t})),c=n?r:d?d.fullname||d.full_name||d.username:"",u={padding:"6px 12px",cursor:"pointer",fontSize:13};return(0,A.jsxs)(y.Z,{xs:6,md:!0,style:{position:"relative"},children:[(0,A.jsx)("input",{type:"text",className:"form-control mb-2",placeholder:a,value:c,onFocus:function(){return o.setState({executorUserDropdownOpen:!0,executorUserSearch:""})},onChange:function(e){return o.setState({executorUserSearch:e.target.value,executorUserDropdownOpen:!0})},onBlur:function(){return setTimeout((function(){return o.setState({executorUserDropdownOpen:!1,executorUserSearch:""})}),150)},style:{maxWidth:"100%"}}),n&&(0,A.jsxs)("div",{style:{position:"absolute",top:"calc(100% - 8px)",left:0,right:0,background:"#fff",border:"1px solid #ced4da",borderRadius:4,zIndex:1050,maxHeight:220,overflowY:"auto",boxShadow:"0 4px 12px rgba(0,0,0,0.15)"},children:[(0,A.jsx)("div",{style:(0,m.Z)((0,m.Z)({},u),{}
1,{color:"#6c757d",borderBottom:"1px solid #f0f0f0"}),onMouseDown:function(){o.handleExecutorUserFilterChange({target:{value:""}}),o.setState({executorUserDropdownOpen:!1,executorUserSearch:""})},children:a}),0===s.length?(0,A.jsx)("div",{style:(0,m.Z)((0,m.Z)({},u),{},{color:"#adb5bd"}),children:"Kh\xf4ng t\xecm th\u1ea5y"}):s.map((function(e){return(0,A.jsx)("div",{style:(0,m.Z)((0,m.Z)({},u),{},{background:e.username===t?"#e8f0fe":"transparent"}),onMouseDown:function(){o.handleExecutorUserFilterChange({target:{value:e.username}}),o.setState({executorUserDropdownOpen:!1,executorUserSearch:""})},children:e.fullname||e.full_name||e.username},e.username)}))]})]},"filter-executor-user")}(),xt=new Map;Te&&Te.length>0?Te.forEach((function(e){var t=e.product_code.split("-").slice(0,-1).join("-");xt.has(t)||xt.set(t,new Set),xt.get(t).add(e.size)})):this.props.products&&0!==this.props.products.length||this.state.productListLoaded||(this.setState({productListLoaded:!0}),this.props.getSESProducts({currentPage:1,itemsPerPage:9999,sortBy:"product_code",sortOrder:1}));Te.map((function(e){return{value:e.sku_code,label:"".concat((0,ce.G)(e.sku_code)," - ").concat(e.product_name)}}));var _t=this.getOrdersToFulfill(),vt=function(e){return{value:e.product_code,label:"".concat((0,ce.n)(e.product_code)," - ").concat(e.product_name),img_url:e.images&&e.images.length>0?e.images[0].image_link:"",product_name:e.product_name,sku_code:e.sku_code,size:e.size,custom_field_1:e.custom_field_1||"",custom_field_2:e.custom_field_2||"",is_parent_product:!0===e.is_parent_product||1===e.is_parent_product||"true"===String(e.is_parent_product||"").toLowerCase()}},yt=(Te||[]).map(vt),St=this.getProductTypeMetaForNewOrder(),bt=St.enabled,Ct=!0===Ne[He.GY],jt=(0,He.a7)(this.state.newOrderProductBundleFilter||"all",Ct),Tt=function(e){var t=e.products,r=e.useProductTypeFilter,n=e.selectedProductTypeFilter,a=e.newOrderProductBundleFilter,i=e.bundleProductPickerOn,o=t||[];if(r)return n&&"all"!==n?o.filter((function(e){var t;return String(null!==(t=null===e||void 0===e?void 0:e.product_type)&&void 0!==t?t:"").trim()===String(n).trim()})):o;var l=(0,He.a7)(a||"all",i);return"all"===l?o:o.filter((function(e){return(0,He.Jn)(e,l)}))}({products:Te,useProductTypeFilter:bt,selectedProductTypeFilter:this.state.newOrderProductTypeFilter||"all",newOrderProductBundleFilter:this.state.newOrderProductBundleFilter||"all",bundleProductPickerOn:Ct}),Ot=Tt.map(vt),wt=this.state.isAddingListing?Ot:yt,Ft={},Nt=0,Et=["#f3f3f3","#e9f0fa"];be.forEach((function(e){e.monthly_id&&!(e.monthly_id in Ft)&&(Ft[e.monthly_id]=Nt%2,Nt++)}));var Lt=be,It=Z,Zt="",kt="undefined"!==typeof window&&window.innerWidth<992,Pt=kt&&this.state.mobileFiltersPanelOpen;if("fulfill"===Oe&&""!==this.state.availableFilter){var Rt=parseInt(this.state.availableFilter);It=(Lt=be.filter((function(e){var t=e.listings.map((function(e){return void 0!==e.available&&null!==e.available?parseInt(e.available):-1}));return 1===Rt?t.every((function(e){return 1===e})):t.some((function(e){return e===Rt}))}))).length,Zt={"-1":(0,G.R6)(G.Nx.TEXT_AVAILABLE_PENDING),0:(0,G.R6)(G.Nx.TEXT_AVAILABLE_OUT_OF_STOCK),1:(0,G.R6)(G.Nx.TEXT_AVAILABLE_IN_STOCK),2:(0,G.R6)(G.Nx.TEXT_AVAILABLE_RESERVED)}[this.state.availableFilter]||""}var At=!0===Ne[He.Hl],Dt=String(Ne[He.JF]||"SL s\u1ea3n ph\u1ea9m (listing)").trim()||"SL s\u1ea3n ph\u1ea9m (listing)",Mt=String(Ne[He.J4]||"Mix: 10 + 11 + 12 + 13 (Fulfill \u0111ang x\u1eed l\xfd)").trim()||"Mix: 10 + 11 + 12 + 13 (Fulfill \u0111ang x\u1eed l\xfd)",Ht=String(Ne[He.eV]||"").trim(),zt=String(Ne[He.wg]||"").trim(),Gt=String(Ne[He.d7]||"").trim(),Ut=String(Ne[He.ai]||"Filter ng\xe0y giao \u0110VVC").trim()||"Filter ng\xe0y giao \u0110VVC",Bt=(Lt||[]).reduce((function(e,t){return e+(Array.isArray(null===t||void 0===t?void 0:t.listings)?t.listings:[]).reduce((function(e,t){var r=Number(null===t||void 0===t?void 0:t.quantity);return e+(Number.isFinite(r)&&r>0?r:1)}),0)}),0);return(0,A.jsxs)(b.Z,{fluid:!0,children:[(0,A.jsx)("style",{children:"\n            .date-picker-popper {\n              z-index: 9999 !important;\n            }\n            .react-datepicker-popper {\n              z-index: 9999 !important;\n            }\n            .order-list-mobile-filter-panel {\n              border: 1px solid #e5e7eb;\n              border-radius: 12px;\n              padding: 12px;\n              background: #ffffff;\n              margin-bottom: 12px;\n            }\n            .order-list-mobile-filter-panel .btn,\n            .order-list-mobile-filter-panel .form-select,\n            .order-list-mobile-filter-panel .form-control {\n              margin-bottom: 8px;\n            }\n            .order-list-mobile-summary {\n              font-size: 14px;\n              color: #374151;\n              margin-bottom: 12px;\n            }\n            .compact-color-actions { gap: 2px !important; }\n            .compact-color-actions .btn { padding: 1px 6px; font-size: 11px; line-height: 1.2; }\n            .compact-color-actions .btn svg { width: 11px; height: 11px; }\n            .ses-color-picker-grid {\n              display: grid;\n              grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));\n              gap: 10px;\n            }\n            @media (max-width: 768px) {\n              .ses-color-picker-grid {\n                grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));\n                gap: 8px;\n              }\n            }\n          "}),(0,A.jsxs)(C.Z,{show:this.state.showToast,onClose:function(){return o.setState({showToast:!1})},delay:3e3,autohide:!0,style:{position:"fixed",top:20,right:20,zIndex:9999},bg:this.state.toastVariant,text:"white",children:[(0,A.jsx)(C.Z.Header,{closeButton:!0,children:(0,A.jsx)("strong",{className:"me-auto",children:"Notification"})}),(0,A.jsx)(C.Z.Body,{children:this.state.toastMessage})]}),de&&!kt&&(0,A.jsx)(ze,{targetPage:Oe,orderListCfg:we,pageTitle:this.orderListHeaderLabel("pageTitle"),isOrderListHeaderHidden:(0,ie.Gk)(Oe,"pageTitle",we),filterShippingCountryEnabled:!Le&&this.getFilterShippingCountryEnabled(),saleOrderStatusLimitEnabled:!Le&&this.get
1SaleOrderStatusLimitEnabled(),showCreateMonthlyIdButton:Ze,showShippingAgencyExportButtons:Ie,shippingCenterFilterBesideAddOrder:nt,enableCreateMultipleOrder:!Le&&!0===Ne[He._T],enableExportFail:!0===this.getGeneralConfig()[He.aY],isUsFilter:this.state.isUsFilter,onIsUsFilterChange:this.handleIsUsFilterChange,disableStatusRestriction:this.state.disableStatusRestriction,onDisableStatusRestrictionChange:this.handleDisableStatusRestrictionChange,onCreateMonthlyId:this.handleCreateMonthlyId,onExportSGB:this.handleExportSGB,onExportTHE:this.handleExportTHE,onExportViettelPost:this.handleExportViettelPost,shippingCenterNameFilter:this.state.shippingCenterNameFilter,onShippingCenterNameFilterChange:this.handleShippingCenterNameFilterChange,shippingCenterNameLabel:this.orderListHeaderLabel("shippingCenterName"),currentCompany:this.props.currentCompany,publicPartners:this.props.publicPartners,onAddOrder:this.handleAddOrder,hideAddNewOrder:!0===Ne[He.RV],onShowMultipleOrderModal:this.handleShowMultipleOrderModal,availableFilter:this.state.availableFilter,onAvailableFilterChange:this.handleAvailableFilterChange,showShippingCenterDateFilter:this.state.showShippingCenterDateFilter,shippingCenterDateFilterLabel:Ut,onShowShippingCenterDateFilterChange:this.handleShowShippingCenterDateFilterChange,shippingCenterDateFrom:this.state.shippingCenterDateFrom,shippingCenterDateTo:this.state.shippingCenterDateTo,onShippingCenterDateFromChange:this.handleShippingCenterDateFromChange,onShippingCenterDateToChange:this.handleShippingCenterDateToChange,statusFilter:this.state.statusFilter,selectedOrdersSize:this.state.selectedOrders.size,onShowExportModal:this.handleShowExportModal,onShowExportFailModal:this.handleShowExportFailModal,onAutoFulfill:this.handleAutoFulfill,onFulfillLabelClick:this.handleFulfillLabelClick}),de&&kt&&(0,A.jsx)(Ge,{pageTitle:this.orderListHeaderLabel("pageTitle"),isOrderListHeaderHidden:(0,ie.Gk)(Oe,"pageTitle",we),showMobileFilterPanel:Pt,onToggleMobilePanel:function(){return o.setState((function(e){return{mobileFiltersPanelOpen:!e.mobileFiltersPanelOpen}}))},targetPage:Oe,filterShippingCountryEnabled:!Le&&this.getFilterShippingCountryEnabled(),saleOrderStatusLimitEnabled:!Le&&this.get
1SaleOrderStatusLimitEnabled(),showCreateMonthlyIdButton:Ze,showShippingAgencyExportButtons:Ie,shippingCenterFilterBesideAddOrder:nt,enableCreateMultipleOrder:!Le&&!0===Ne[He._T],enableExportFail:!0===this.getGeneralConfig()[He.aY],isUsFilter:this.state.isUsFilter,onIsUsFilterChange:this.handleIsUsFilterChange,disableStatusRestriction:this.state.disableStatusRestriction,onDisableStatusRestrictionChange:this.handleDisableStatusRestrictionChange,onCreateMonthlyId:this.handleCreateMonthlyId,onExportSGB:this.handleExportSGB,onExportTHE:this.handleExportTHE,onExportViettelPost:this.handleExportViettelPost,shippingCenterNameFilter:this.state.shippingCenterNameFilter,onShippingCenterNameFilterChange:this.handleShippingCenterNameFilterChange,shippingCenterNameLabel:this.orderListHeaderLabel("shippingCenterName"),currentCompany:this.props.currentCompany,publicPartners:this.props.publicPartners,onAddOrder:this.handleAddOrder,hideAddNewOrder:!0===Ne[He.RV],onShowMultipleOrderModal:this.handleShowMultipleOrderModal,availableFilter:this.state.availableFilter,onAvailableFilterChange:this.handleAvailableFilterChange,showShippingCenterDateFilter:this.state.showShippingCenterDateFilter,shippingCenterDateFilterLabel:Ut,onShowShippingCenterDateFilterChange:this.handleShowShippingCenterDateFilterChange,statusFilter:this.state.statusFilter,selectedOrdersSize:this.state.selectedOrders.size,onShowExportModal:this.handleShowExportModal,onShowExportFailModal:this.handleShowExportFailModal,onAutoFulfill:this.handleAutoFulfill,onFulfillLabelClick:this.handleFulfillLabelClick}),de&&(!kt||Pt)&&(0,A.jsxs)(j.Z,{className:"mb-3",children:[Qe&&(0,A.jsx)(y.Z,{xs:6,md:!0,children:(0,A.jsx)(S.Z,{value:d,onChange:this.handleDateFilterChange,className:"mb-2",children:this.renderDateFilterSelectOptions()})}),$e&&(0,A.jsx)(y.Z,{xs:6,md:!0,children:(0,A.jsxs)(S.Z,{value:this.state.shopFilter,onChange:this.handleShopFilterChange,className:"mb-2","aria-label":"L\u1ecdc ".concat(this.orderListHeaderLabel("shop")),children:[(0,A.jsx)("option",{value:"All",children:"T\u1ea5t c\u1ea3 ".concat(this.orderListHeaderLabel("shop"))}),this.getShopOptions().map((function(e){return(0,A.jsx)("option",{value:e.value,children:e.label},e.value)}))]})}),Re&&"sale"!==Oe&&tt&&mt,Je&&(0,A.jsx)(y.Z,{xs:6,md:!0,children:(0,A.jsxs)(S.Z,{value:this.state.statusFilter,onChange:this.handleStatusFilterChange,className:"mb-2",children:[(0,A.jsx)("option",{value:"",children:"T\u1ea5t c\u1ea3 tr\u1ea1ng th\xe1i"}),function(e,t,r){var n=o.props.orderStatusConfig;if(!n||!Array.isArray(n))return null;var a=[];if("sale"===Oe)a=n;else if("fulfill"===Oe){var i=[Y.vl.FULFILL_PROCESSING,Y.vl.PACKAGING,Y.vl.PACKAGING_DONE,Y.vl.WAITING_FOR_SHIPPING_LABEL,Y.vl.SHIPPED_TO_SHIPPING_CENTER,Y.vl.SHIPPED_TO_CUSTOMER,Y.vl.CUSTOMS_HOLD,Y.vl.RETURNED_TO_SHIPPING_WAREHOUSE,Y.vl.RETURNED_TO_SHIPPING_CENTER,Y.vl.RETURNED_TO_WAREHOUSE,Y.vl.FAIL_REASON_1,Y.vl.FAIL_REASON_2,Y.vl.FAIL_REASON_3,Y.vl.COMPLETED,Y.vl.REFUNDED];a=n.filter((function(e){return i.includes(e.enum)}))}var l=null===(e=o.props.currentCompany)||void 0===e||null===(t=e.metadata)||void 0===t||null===(r=t.configs)||void 0===r?void 0:r.orderStatus;return a=a.filter((function(e){return!(0,lt.Xg)(e.enum,l)})),Le&&(a=a.filter((function(e){return Number.isFinite(Number(e.code))&&Number(e.code)<=15}))),(0,A.jsxs)(A.Fragment,{children:["fulfill"===Oe&&(0,A.jsx)("option",{value:"mix",children:Mt}),"fulfill"===Oe&&Ht&&(0,A.jsx)("option",{value:"inprogress",children:Ht}),zt&&(0,A.jsx)("option",{value:"processing_sale",children:zt}),Gt&&(0,A.jsx)("option",{value:"processing_fulfill",children:Gt}),a.map((function(e){return(0,A.jsxs)("option",{value:e.enum,children:["[",e.code,"] ",o.getOrderStatusDisplayLabel(e.enum)]},e.enum)}))]})}()]})}),et&&(0,A.jsx)(y.Z,{xs:6,md:!0,children:(0,A.jsxs)(S.Z,{value:this.state.priorityFilter,onChange:this.handlePriorityFilterChange,className:"mb-2",children:[(0,A.jsx)("option",{value:"",children:"T\u1ea5t c\u1ea3 \u0111\u1ed9 \u01b0u ti\xean"}),(0,A.jsx)("option",{value:"1",children:"[1] Th\u1ea5p"}),(0,A.jsx)("option",{value:"2",children:"[2] Trung b\xecnh"}),(0,A.jsx)("option",{value:"3",children:"[3] Cao"}),(0,A.jsx)("option",{value:"4",children:"[4] Ho\u1ea3 t\u1ed1c"})]})}),qe&&(0,A.jsx)(y.Z,{xs:6,md:!0,children:(0,A.jsxs)(S.Z,{value:this.state.orderCustomFilter1,onChange:this.handleOrderCustomFilter1Change,className:"mb-2","aria-label":(0,ie.TT)("orderCustomFilter1"),children:[(0,A.jsx)("option",{value:"",children:Ae.allLabel||"T\u1ea5t c\u1ea3 ".concat((0,ie.TT)("orderCustomFilter1"))}),Ae.options.map((function(e){return(0,A.jsx)("option",{value:e.value,children:e.label},e.value)}))]})}),Ke&&(0,A.jsx)(y.Z,{xs:6,md:!0,children:(0,A.jsxs)(S.Z,{value:this.state.orderCustomFilter2,onChange:this.handleOrderCustomFilter2Change,className:"mb-2","aria-label":(0,ie.TT)("orderCustomFilter2"),children:[(0,A.jsx)("option",{value:"",children:De.allLabel||"T\u1ea5t c\u1ea3 ".concat((0,ie.TT)("orderCustomFilter2"))}),De.options.map((function(e){return(0,A.jsx)("option",{value:e.value,children:e.label},e.value)}))]})}),!Re&&tt&&mt,Re&&ft,(0,A.jsx)(y.Z,{xs:6,md:!0,children:(0,A.jsxs)("div",{className:"position-relative",children:[(0,A.jsx)(T.Z.Control,{type:"text",placeholder:"T\xecm ki\u1ebfm...",value:this.state.keyword,onChange:this.handleKeywordChange,onBlur:this.handleKeywordSearch,onKeyDown:this.handleKeywordSearch,className:"mb-2 pe-5"}),this.state.keyword&&(0,A.jsx)("span",{style:{position:"absolute",right:16,top:"50%",transform:"translateY(-50%)",cursor:"pointer",color:"#888",fontSize:18,zIndex:2},onClick:function(){localStorage.setItem("orderKeyword_".concat(Oe),""),o.setState({keyword:"",currentPage:1},(function(){o.updateURL({keyword:"",page:1}),o.loadOrders()}))},title:"X\xf3a t\xecm ki\u1ebfm",children:"\xd7"})]})})]}),this.isFeatureEnabled("bulk_update")&&de&&(!kt||Pt)&&(0,A.jsx)(Ue,{selectedBulkStatus:k,selectedOrders:c,isMobileViewport:kt,targetPage:Oe,totalCount:Z,filteredOrders:Lt,filteredOrdersCount:It,availableFilterText:Zt,showListingQtySummary:At,listingQtySummaryLabel:Dt,shownListingCount:Bt,stickHeader:this.state.stickHeader,itemsPerPage:I,availableStatuses:this.getAvailableStatuses(),dateRangeDisplay:this.getDateRangeDisplay(),getOrderStatusDisplayLabel:this.getOrderStatusDisplayLabel,onBulkStatusChange:this.handleBulkStatusChange,onBulkStatusApply:this.handleBulkStatusApply,onPrintOrderDetails:this.handlePrintOrderDetails,onConfigToggle:this.handleConfigToggle,onItemsPerPageChange:this.handleItemsPerPageChange,canBulkDelete:this.canBulkDelete(),onBulkDelete:this.handleBulkDelete}),de&&kt&&(0,A.jsxs)("div",{className:"order-list-mobile-summary",children:[c.size," ",(0,G.R6)(G.Nx.TEXT_ORDERS_SELECTED)," \xb7 ",(0,G.R6)(G.Nx.TEXT_TOTAL_ORDERS),": ",(0,A.jsx)("strong",{children:Z})," \xb7 ",(0,G.R6)(G.Nx.TEXT_SHOWING),": ",(0,A.jsx)("strong",{children:Lt.length}),Zt&&(0,A.jsxs)("span",{style:{color:"#007bff",fontWeight:"bold"},children:[" ","\xb7 Tr\u1ea1ng th\xe1i ",(0,A.jsx)("strong",{children:Zt}),": ",(0,A.jsx)("strong",{children:It})," \u0111\u01a1n"]}),At&&(0,A.jsxs)("span",{style:{color:"#0d6efd",fontWeight:700},children:[" ","\xb7 ",Dt,": ",(0,A.jsx)("strong",{children:Bt})]})]}),s&&(0,A.jsxs)("div",{className:"text-center mb-3",children:[(0,A.jsx)(O.Z,{animation:"border",variant:"primary"}),(0,A.jsx)("span",{className:"ms-2",children:(0,G.R6)(G.Nx.TEXT_LOADING)})]}),!s&&0===be.length&&(0,A.jsx)("div",{className:"text-center mb-3",children:(0,A.jsx)("p",{children:(0,G.R6)(G.Nx.TEXT_NO_ORDERS_FOUND)})}),(0,A.jsx)("div",{className:"table-responsive order-list-table",style:{overflowX:"auto",overflowY:"auto",width:"100%",height:de?"75vh":"95vh",maxHeight:de?"75vh":"95vh"},children:(0,A.jsxs)(w.Z,{bordered:!0,size:"sm",className:"table-sticky-header",style:{minWidth:"max-content",tableLayout:"fixed",width:"max-content"},children:[(0,A.jsx)("thead",{children:(0,A.jsxs)("tr",{children:["rnd"!==Oe&&this.renderResizableHeader("checkbox",(0,A.jsx)(F.Z,{checked:c.size>
10&&c.size===Lt.length,onChange:function(e){e.target.checked?o.setState({selectedOrders:new Set(Lt.map((function(e){return e.order_id})))}):o.setState({selectedOrders:new Set})},disabled:0===Lt.length}),{style:{textAlign:"center"}}),it.map((function(e){return(0,A.jsx)(f.Fragment,{children:o.renderOrderListConfigurableColumnHeader(e,ot)},e)}))]})}),(0,A.jsx)("tbody",{children:function(){var e={};Lt.forEach((function(t){var r=function(e){var t=null===e||void 0===e?void 0:e.monthly_id;return null!=t&&""!==String(t).trim()?String(t).trim():"__order:".concat((null===e||void 0===e?void 0:e.order_id)||(null===e||void 0===e?void 0:e._id)||"")}(t);e[r]||(e[r]=[]),e[r].push(t)}));var t=[];Object.values(e).forEach((function(e){var r=e.reduce((function(e,t){return e+t.listings.length}),0),n=0;e.forEach((function(e){e.listings.forEach((function(a,i){t.push({order:e,listing:a,listingIndex:i,idxInGroup:n,groupSize:r,isFirst:0===n,orderRowSpan:e.listings.length,isFirstInOrder:0===i}),n++}))}))}));var r=new Map,n=(L-1)*I+1;Object.values(e).forEach((function(e){var t=e[0];t&&r.set(t._id,n++)}));var a=!0===o.getGeneralConfig()[He.BH];return t.map((function(e,t){var n,i=e.order,l=e.listing,s=e.listingIndex,d=e.idxInGroup,c=e.groupSize,u=e.isFirst,h=e.orderRowSpan,p=e.isFirstInOrder,g=l.sku,x=l.size,_=xt.has(g),v=x&&(null===(n=xt.get(g))||void 0===n?void 0:n.has(x)),y=i.monthly_id?Et[Ft[i.monthly_id]]:void 0,S=o.getIncrementalFamilyRowStyle(i,y),b=Number(l.quantity)||0,C=a&&b>1,j=S&&S.backgroundColor||y||"#ffffff",T=gt.bodyStyles.checkbox,O=T?(0,m.Z)((0,m.Z)({},T),{},{backgroundColor:j}):void 0,w={colVisTable:Pe,targetPage:Oe,order:i,listing:l,listingIndex:s,idxInGroup:d,groupSize:c,isFirst:u,stt:u?r.get(i._id):void 0,orderRowSpan:h,isFirstInOrder:p,orderQtyFailedMeta:Ve,orderCustomFilter1Meta:Ae,orderCustomFilter2Meta:De,orderProductCustomField1Meta:Be,isSkuValid:_,isSizeValid:v,quantityCellHighlight:C,sku:g,size:x,rowBackgroundColor:j,orderListFrozenBodyStyleByKey:gt.bodyStyles};return(0,A.jsxs)("tr",{style:S||(y?{backgroundColor:y}:void 0),children:["rnd"!==Oe&&u&&(0,A.jsx)("td",{rowSpan:c,style:O,children:(0,A.jsx)(F.Z,{checked:o.state.selectedOrders.has(i.order_id),onChange:function(){return o.handleOrderSelect(i.order_id)}})}),it.map((function(e){return(0,A.jsx)(f.Fragment,{children:o.renderOrderListConfigurableColumnCell(e,w)},e)}))]},"".concat(i.order_id,"-").concat(l.sku,"-").concat(d))}))}()})]})}),(0,A.jsx)("div",{className:"d-flex justify-content-center mt-3",children:Math.ceil(Z/I)>1&&(0,A.jsxs)("div",{className:"d-flex align-items-center",children:[(0,A.jsx)(N.Z,{variant:"outline-primary",className:"me-2",disabled:1===L,onClick:function(){return o.handlePageChange(L-1)},children:(0,G.R6)(G.Nx.TEXT_PREVIOUS)}),(0,A.jsxs)("span",{className:"mx-2",children:[(0,G.R6)(G.Nx.TEXT_PAGE)," ",L," / ",Math.ceil(Z/I)]}),(0,A.jsx)(N.Z,{variant:"outline-primary",className:"ms-2",disabled:L===Math.ceil(Z/I),onClick:function(){return o.handlePageChange(L+1)},children:(0,G.R6)(G.Nx.TEXT_NEXT)})]})}),(0,A.jsx)("div",{style:{paddingBottom:40}}),(0,A.jsx)(pe,{show:u,onClose:function(){return o.setState({showEditModal:!1,isAddingListing:!1})},isAddingListing:this.state.isAddingListing,editMode:this.state.editMode,targetPage:Oe,isSimpleOrder:ke,enablePetArtMode:!0===this.getGeneralConfig()[He.c],onUpdateCost:this.handleUpdateOrderCost,currentOrder:this.state.currentOrder,currentListing:this.state.currentListing,editForm:h,showOrderIdInput:Le,products:this.props.products,productOptionsForListingModal:wt,creatingOrderAlbum:this.state.creatingOrderAlbum,formatOrderIdToHuman:this.formatOrderIdToHuman,formatMonthlyIdToHuman:this.formatMonthlyIdToHuman,renderPriorityOption:this.renderPriorityOption,resolveAddedReasonSelectValue:this.resolveAddedReasonSelectValue,getOrderListAddedReasonSelectRows:this.getOrderListAddedReasonSelectRows,onFormChange:this.handleEditFormChange,onSelectProduct:function(e){e?o.setState((function(t){return{editForm:(0,m.Z)((0,m.Z)({},t.editForm),{},{sku:e.sku_code,size:e.size,title:e.product_name,product_code:e.product_code}),currentListing:(0,m.Z)((0,m.Z)({},t.currentListing),{},{product_code:e.product_code,sku:e.sku_code,size:e.size,title:e.product_name,img_url:e.images&&e.images.length>0?e.images[0].image_link:""})}})):o.setState((function(e){return{editForm:(0,m.Z)((0,m.Z)({},e.editForm),{},{sku:"",size:"",title:"",product_code:""}),currentListing:(0,m.Z)((0,m.Z)({},e.currentListing),{},{product_code:"",sku:"",size:"",title:"",img_url:""})}}))},onShowListingImage:this.handleShowListingImageModal,onDeleteListing:this.handleDeleteListing,onDeleteOrder:this.handleDeleteOrder,onSubmit:this.handleEditSubmit,onOpenOrderCustomAlbum:this.handleOpenOrderCustomAlbumInNewTab,onCreateOrderCustomAlbum:this.handleCreateOrderCustomAlbum,useProductTypeFilterForNewOrder:bt,newOrderProductTypeFilter:this.state.newOrderProductTypeFilter||"all",onProductTypeFilterChange:function(e){var t=e.target.value;localStorage.setItem("orderListNewOrderProductTypeFilter",t),o.setState({newOrderProductTypeFilter:t})},productTypeMetaForNewOrder:St,newOrderBf:jt,onBundleFilterChange:function(e){var t=e.target.value;localStorage.setItem("orderListNewOrderProductBundleFilter",t),o.setState({newOrderProductBundleFilter:t})},bundleFilterLabels:Ee,bundleProductPickerOn:Ct}),(0,A.jsx)(le,{show:p,onHide:function(){return o.setState({showConfigModal:!1})},onSave:this.handleSaveConfig,modalTab:g,onTabSelect:function(e){return o.setState({orderListConfigModalTab:e})},targetPage:Oe,columnVisibility:at,orderListHeaderLabel:this.orderListHeaderLabel,onToggleColumn:this.handleColumnToggle,orderListCfg:we,orderDateFilterHiddenLocal:x,getDateFilterOptionLabel:this.getDateFilterOptionLabel,onToggleDateFilterHidden:this.handleOrderDateFilterHiddenLocalToggle,visibleOrderListFilterKeys:rt,orderFilterHiddenLocal:_,onToggleFilterHidden:this.handleOrderFilterHiddenLocalToggle,autoFulfillBatchSize:this.state.autoFulfillBatchSize,onChangeAutoFulfillBatchSize:function(e){return o.setState({autoFulfillBatchSize:e})}
1,fulfillStartFinishTimeOnly:this.state.fulfillStartFinishTimeOnly,onToggleFulfillStartFinishTimeOnly:this.handleFulfillStartFinishTimeOnlyToggle,orderListFrozenUptoOptions:ht,orderListFrozenUntilKey:ut,onChangeOrderListFrozenUntilKey:this.handleOrderListFrozenUntilKeyChange,onExportSGB:this.handleExportSGB,onExportTHE:this.handleExportTHE,onExportViettelPost:this.handleExportViettelPost}),(0,A.jsx)(z,{show:E,onHide:function(){return o.setState({showScanOrdersModal:!1})}}),(0,A.jsx)(me,{show:P,noteValue:R,onNoteChange:this.handleRndNoteChange,onClose:function(){return o.setState({showRndDoneModal:!1,rndOrderId:null,rndNoteValue:""})},onSubmit:this.handleRndDoneSubmit}),(0,A.jsx)(ye,{show:this.state.showSplitOrderModal,onClose:function(){return o.setState({showSplitOrderModal:!1})},target:this.state.splitOrderTarget,mode:this.state.splitOrderMode,qty:this.state.splitOrderQty,loading:this.state.splitOrderLoading,parentCode:this.state.splitOrderParentCode,onParentChange:function(e){return o.setState({splitOrderParentCode:e,splitOrderQty:""})},onModeChange:function(e){return o.setState({splitOrderMode:e,splitOrderQty:""})},onQtyChange:function(e){return o.setState({splitOrderQty:e})},onSplitSubmit:this.handleSplitOrderSubmit,onIncreaseSubmit:this.handleIncreaseOrderSubmit,formatOrderIdToHuman:this.formatOrderIdToHuman}),(0,A.jsx)(je,{data:this.state.printOrderLabel,companyName:null===(n=this.props.currentCompany)||void 0===n?void 0:n.name,useMonthlyCode:!0===this.getGeneralConfig()[He.y4],formatOrderIdToHuman:this.formatOrderIdToHuman,formatMonthlyIdToHuman:this.formatMonthlyIdToHuman,onClose:function(){return o.setState({printOrderLabel:null})},onRecreate:this.handleRecreateOrderLabel}),(0,A.jsx)(Fe,{show:H,onClose:function(){return o.setState({showLogModal:!1})},order:V,logs:B,pagination:W,isShowLatest:X,logLevelFilter:this.state.logLevelFilter,onToggleLatest:this.handleToggleShowLatestLog,onLogLevelChange:function(e){return o.setState({logLevelFilter:e})},onReload:this.handleGetLatestLog,onPageChange:this.handleLogPageChange,orderStatusConfig:this.props.orderStatusConfig,formatOrderIdToHuman:this.formatOrderIdToHuman,formatMonthlyIdToHuman:this.formatMonthlyIdToHuman,getShopDisplayName:this.getShopDisplayName,getOrderStatusDisplayLabel:this.getOrderStatusDisplayLabel}),(0,A.jsx)(K.Z,{show:this.state.showOrderDetailModal,onHide:function(){return o.setState({showOrderDetailModal:!1,orderDetailId:null})},url:this.state.orderDetailId?"/admin/orders/order-detail/".concat(this.state.orderDetailId):"",title:"Chi ti\u1ebft \u0111\u01a1n: ".concat(this.state.orderDetailId||""),showSidebar:!1,showOpenInNewTab:!0}),this.renderColorPickerOrderModal(),this.renderCloneChildPromptModal(),(0,A.jsx)(K.Z,{show:q,onHide:function(){return o.setState({showCustomAlbumModal:!1,customAlbumUrl:"",customAlbumTitle:""})},url:$,title:J||"Custom Album",showSidebar:!1}),(0,A.jsx)(Q.Z,{show:this.state.showQuantityChangeModal,onHide:function(){return o.setState({showQuantityChangeModal:!1,selectedProductCode:"",selectedProductName:""})},productCode:this.state.selectedProductCode,productName:this.state.selectedProductName,showCalculateButton:!1}),(0,A.jsx)(Se,{show:this.state.showMetadataModal,metadata:this.state.selectedMetadata,canEdit:this.canViewMetadataInAction(),onSave:this.handleSaveMetadata,onClose:function(){return o.setState({showMetadataModal:!1,selectedMetadata:null,selectedMetadataOrderId:null})}}),(0,A.jsx)(Me,{show:ee,onClose:function(){return o.setState({showFulfillLabelModal:!1})},ordersToFulfill:_t,activeTab:this.state.activeTab,onToggleTab:this.toggleTab,onPrint:this.handlePrint,formatOrderIdToHuman:this.formatOrderIdToHuman,formatMonthlyIdToHuman:this.formatMonthlyIdToHuman,getShopDisplayName:this.getShopDisplayName,onShowListingImage:this.handleShowListingImageModal}),(0,A.jsx)(fe,{show:this.state.showCustomDateModal,startDate:this.state.customStartDate,endDate:this.state.customEndDate,onDateRangeChange:this.handleDateRangeChange,onClose:this.handleCloseCustomDatePicker,onApply:this.handleApplyDateRange}),(0,A.jsx)(se,{show:te,onHide:function(){return o.setState({showAddOrderModal:!1})},onSave:this.handleAddNewOrder,newOrderForm:this.state.newOrderForm,isSimpleOrder:ke,mergedShopOptions:this.getMergedShopOptions(),onShopNameChange:this.handleShopNameChange,onNewOrderFormChange:this.handleNewOrderFormChange,resolveAddedReasonSelectValue:this.resolveAddedReasonSelectValue,getOrderListAddedReasonSelectRows:this.getOrderListAddedReasonSelectRows,renderPri
1orityOption:this.renderPriorityOption,useProductTypeFilterForNewOrder:bt,newOrderProductTypeFilter:this.state.newOrderProductTypeFilter||"all",onProductTypeFilterChange:function(e){var t=e.target.value;localStorage.setItem("orderListNewOrderProductTypeFilter",t),o.setState({newOrderProductTypeFilter:t})},productTypeMetaForNewOrder:St,newOrderBf:jt,onBundleFilterChange:function(e){var t=e.target.value;localStorage.setItem("orderListNewOrderProductBundleFilter",t),o.setState({newOrderProductBundleFilter:t})},bundleFilterLabels:Ee,bundleProductPickerOn:Ct,productOptionsForNewOrder:Ot,onNewOrderListingChange:this.handleNewOrderListingChange,showProductCustomField1:!1,showProductCustomField2:!1,productCustomField1Label:Be.label,productCustomField2Label:Ye.label,showRefCompanyIds:!0===this.getGeneralConfig()[He.QE]&&!(0,st.ki)(this.props.user),showOrderIdInput:Le}),(0,A.jsx)(re,{show:ne,onHide:function(){return o.setState({showMultipleOrderModal:!1})},onSave:this.handleCreateMultipleOrders,form:ae,onFormChange:this.handleMultipleOrderFormChange,isSimpleOrder:ke,mergedShopOptions:this.getMergedShopOptions(),onShopNameChange:function(e){return o.setState((function(t){return{multipleOrderForm:(0,m.Z)((0,m.Z)({},t.multipleOrderForm),{},{shop_name:e?e.value:""})}}))},resolveAddedReasonSelectValue:this.resolveAddedReasonSelectValue,getOrderListAddedReasonSelectRows:this.getOrderListAddedReasonSelectRows,renderPriorityOption:this.renderPriorityOption,useProductTypeFilterForNewOrder:bt,newOrderProductTypeFilter:this.state.newOrderProductTypeFilter||"all",onProductTypeFilterChange:function(e){var t=e.target.value;localStorage.setItem("orderListNewOrderProductTypeFilter",t),o.setState({newOrderProductTypeFilter:t})},productTypeMetaForNewOrder:St,newOrderBf:jt,onBundleFilterChange:function(e){var t=e.target.value;localStorage.setItem("orderListNewOrderProductBundleFilter",t),o.setState({newOrderProductBundleFilter:t})},bundleFilterLabels:Ee,bundleProductPickerOn:Ct,productOptionsForNewOrder:Ot,saving:oe}),(0,A.jsx)(ue,{show:this.state.showExportModal,onHide:function(){return o.setState({showExportModal:!1})},exportMode:this.state.exportMode,exportWarehouse:this.state.exportWarehouse,onExportWarehouseChange:function(e){localStorage.setItem("orderExportWarehouse_fulfill",e),o.setState({exportWarehouse:e})},exportFailTargetStatus:this.state.exportFailTargetStatus,onExportFailTargetStatusChange:function(e){return o.setState({exportFailTargetStatus:e})},exportViewProduct:this.state.exportViewProduct,onExportViewProductChange:function(e){localStorage.setItem("orderExportViewProduct_fulfill",String(e)),o.setState({exportViewProduct:e})},exportNote:this.state.exportNote,onExportNoteChange:function(e){return o.setState({exportNote:e})},exportItems:this.state.exportItems||[],exportSaving:this.state.exportSaving,onSubmit:this.handleExportSubmit,showOrderQtyFailedColumn:We,orderQtyFailedMeta:Ve,selectedOrders:(this.props.orders||[]).filter((function(e){return Array.from(o.state.selectedOrders).includes(e.order_id)})),currentCompany:this.props.currentCompany,publicPartners:this.props.publicPartners,getOrderStatusDisplayLabel:this.getOrderStatusDisplayLabel,formatOrderIdToHuman:this.formatOrderIdToHuman,formatMonthlyIdToHuman:this.formatMonthlyIdToHuman}),(0,A.jsx)(ge,{show:this.state.showAutoFulfillProgress,current:this.state.autoFulfillCurrent,total:this.state.autoFulfillTotal,progress:this.state.autoFulfillProgress}),(0,A.jsx)(Xe,{isMobileViewport:kt,showTitleAndFilters:de,onToggleTitleAndFilters:this.handleToggleTitleAndFilters}),he&&(null===xe||void 0===xe?void 0:xe.img_url)&&(0,A.jsx)("div",{style:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",background:"rgba(0,0,0,0.7)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:2e4},onClick:this.handleCloseListingImageModal,role:"presentation",children:(0,A.jsxs)("div",{style:{position:"relative",maxWidth:"90vw",maxHeight:"90vh"},onClick:function(e){return e.stopPropagation()},role:"presentation",children:[(0,A.jsx)("img",{src:null===(a=xe.img_url)||void 0===a?void 0:a.replace("75x75","120x120"),alt:xe.title||"Listing",style:{maxWidth:"100%",maxHeight:"80vh",borderRadius:8,boxShadow:"0 2px 16px rgba(0,0,0,0.5)"},onClick:function(e){return e.stopPropagation()}}),(0,A.jsxs)("div",{style:{position:"absolute",top:16,left:16,background:"rgba(0,0,0,0.8)",color:"#fff",padding:"12px 16px",borderRadius:8,fontSize:"14px",maxWidth:"min(300px, 85vw)"},children:[(0,A.jsx)("div",{style:{fontWeight:"bold",marginBottom:"4px"},children:xe.title||"\u2014"}),(0,A.jsxs)("div",{style:{fontSize:"12px",opacity:.9},children:["SKU: ",(0,ce.G)(xe.sku)||"N/A"," \u2014 Size:"," ",xe.size||"N/A"]})]}),(0,A.jsx)("button",{type:"button",onClick:this.handleCloseListingImageModal,style:{position:"absolute",top:8,right:8,background:"#fff",border:"none",borderRadius:"50%",width:32,height:32,fontSize:20,lineHeight:1,cursor:"pointer",boxShadow:"0 1px 4px rgba(0,0,0,0.2)"},title:"\u0110\xf3ng",children:"\xd7"})]})})]})}}]),r}(f.Component),_t=(0,x.$j)((function(e){return{orders:e.orderReducer.orders,products:e.sesProductReducer.products,orderStatusConfig:e.systemReducer.orderStatusConfig,currentCompany:e.companyReducer.currentCompany,publicPartners:e.companyReducer.publicPartners,user:e.authen
1Reducer.user}}),{getOrders:_.AU,updateOrders:_.PT,getSESProducts:_.GZ,setSIVProductInventoryTransaction:_.FC,getOrderStatusConfig:_.WM.getOrderStatusConfig,ensureUsersByGroup:_.zQ})((function(e){var t=(0,W.TH)(),r=new URLSearchParams(t.search).get("target_page")||"sale";return t.pathname.includes("/rnd/orders")?r="rnd":t.pathname.includes("/sale/orders")?r="sale":t.pathname.includes("/fulfill/orders")&&(r="fulfill"),(0,A.jsx)(xt,(0,m.Z)((0,m.Z)({},e),{},{targetPage:r,locationSearch:t.search}))}))},70438:function(e,t,r){var n=r(93433),a=r(61819),i=r(15861),o=r(15671),l=r(43144),s=r(60136),d=r(29388),c=r(88391),u=r(39437),h=r(71739),p=r(13559),g=r(21867),m=r(48357),f=r(96495),x=r(40668),_=r(93847),v=r(52580),y=r(3875),S=r(15841),b=r(1885),C=r(37920),j=r.n(C),T=r(52127),O=(r(88282),r(23712)),w=function(e){(0,s.Z)(r,e);var t=(0,d.Z)(r);function r(){var e;(0,o.Z)(this,r);for(var l=arguments.length,s=new Array(l),d=0;d<l;d++)s[d]=arguments[d];return(e=t.call.apply(t,[this].concat(s))).state={loading:!1,changes:[],sortBy:"created_at",sortOrder:-1,recalculating:!1},e.loadQuantityChanges=(0,i.Z)((0,a.Z)().mark((function t(){var r,n,i,o,l;return(0,a.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.props.productCode){t.next=3;break}return t.abrupt("return");case 3:return e.setState({loading:!0}),t.prev=4,t.next=7,_.b.get("".concat((0,b.kG)(),"/api/ses-product-qty-change/product/").concat(r));case 7:i=t.sent,o=null===i||void 0===i||null===(n=i.data)||void 0===n?void 0:n.data,l=Array.isArray(o)?o:Array.isArray(null===o||void 0===o?void 0:o.result)?o.result:[],e.setState({changes:e.sortChanges(l)}),t.next=16;break;case 13:t.prev=13,t.t0=t.catch(4),console.error("Error loading quantity changes:",t.t0);case 16:return t.prev=16,e.setState({loading:!1}),t.finish(16);case 19:case"end":return t.stop()}}),t,null,[[4,13,16,19]])}))),e.handleSort=function(){e.setState((function(e){return{sortOrder:-e.sortOrder}}),(function(){e.setState((function(t){return{changes:e.sortChanges(t.changes)}}))}))},e.sortChanges=function(t){var r=e.state.sortOrder;return(0,n.Z)(t).sort((function(e,t){var n=new Date(e.transaction_date||e.created_at).getTime(),a=new Date(t.transaction_date||t.created_at).getTime();return r*(n-a)}))},e.handleRecalculate=(0,i.Z)((0,a.Z)().mark((function t(){var r,n,i;return(0,a.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.props.productCode){t.next=3;break}return t.abrupt("return");case 3:return e.setState({recalculating:!0}),n=(0,S.LP)(),t.prev=5,t.next=8,fetch("".concat((0,b.kG)(),"/api/ses-product-qty-change/recalculate?&product_code=").concat(r),{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(n)}});case 8:if((i=t.sent).ok){t.next=11;break}throw new Error("HTTP error! status: ".concat(i.status));case 11:return t.next=13,i.json();case 13:t.sent,T.Am.success("Recalculation completed successfully!"),e.loadQuantityChanges(),t.next=22;break;case 18:t.prev=18,t.t0=t.catch(5),console.error("Error recalculating inventory:",t.t0),T.Am.error("Failed to recalculate inventory. See console for details.");case 22:return t.prev=22,e.setState({recalculating:!1}),t.finish(22);case 25:case"end":return t.stop()}}),t,null,[[5,18,22,25]])}))),e}return(0,l.Z)(r,[{key:"componentDidMount",value:function(){this.loadQuantityChanges()}},{key:"componentDidUpdate",value:function(e){(e.productCode!==this.props.productCode||!e.show&&this.props.show)&&this.loadQuantityChanges()}},{key:"render",value:function(){var e=this.props,t=e.show,r=e.onHide,n=e.productCode,a=e.productName,i=e.showCalculateButton,o=void 0!==i&&i,l=this.state,s=l.loading,d=l.changes,c=l.sortOrder,_=l.recalculating;return(0,O.jsxs)(m.Z,{isOpen:t,toggle:r,size:"xl",style:{maxWidth:"90vw",margin:"0 auto"},children:[(0,O.jsx)(f.Z,{toggle:r,children:(0,O.jsxs)("div",{className:"d-flex align-items-center",children:[(0,O.jsxs)("div",{children:[(0,y.R6)(y.Nx.TEXT_QUANTITY_CHANGE_HISTORY_FOR)," ",n,a&&" (".concat(a,")")]}),o&&(0,O.jsx)(u.Z,{variant:"primary",size:"sm",onClick:this.handleRecalculate,disabled:_,title:"Recalculate Inventory",className:"ms-3",children:_?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(h.Z,{size:"sm",animation:"border",className:"me-2"}),"Recalculating..."]}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(v.T_s,{})," Recalculate"]})})]})}),(0,O.jsxs)(x.Z,{children:[!s&&d.length>0&&(0,O.jsxs)("div",{className:"mb-3",style:{fontSize:"16px",fontWeight:"bold",color:"#007bff"},children:["S\u1ed1 l\u01b0\u1ee3ng t\u1ed3n kho hi\u1ec7n t\u1ea1i: ",(0,O.jsx)("span",{style:{color:"#28a745"},children:d[0].quantity})]}),s?(0,O.jsxs)("div",{className:"text-center",children:[(0,O.jsx)(h.Z,{animation:"border",variant:"primary"}),(0,O.jsx)("span",{className:"ms-2",children:(0,y.R6)(y.Nx.TEXT_LOADING)})]}):(0,O.jsxs)(p.Z,{striped:!0,bordered:!0,hover:!0,responsive:!0,style:{minWidth:700},children:[(0,O.jsx)("thead",{children:(0,O.jsxs)("tr",{children:[(0,O.jsxs)("th",{onClick:this.handleSort,style:{cursor:"pointer"},children:[(0,y.R6)(y.Nx.TEXT_TRANSACTION_DATE)," ",c<0?(0,O.jsx)(v.sF,{}):(0,O.jsx)(v.h3_,{})]}),(0,O.jsx)("th",{children:(0,y.R6)(y.Nx.TEXT_TYPE)}),(0,O.jsx)("th",{children:(0,y.R6)(y.Nx.TEXT_CHANGE_AMOUNT)}),(0,O.jsx)("th",{children:(0,y.R6)(y.Nx.TEXT_NEW_QUANTITY)}),(0,O.jsx)("th",{children:(0,y.R6)(y.Nx.TEXT_UPDATED_BY)}),(0,O.jsx)("th",{children:(0,y.R6)(y.Nx.TEXT_SYSTEM_NOTE)}),(0,O.jsx)("th",{children:(0,y.R6)(y.Nx.TEXT_STAFF_NOTE)}),(0,O.jsx)("th",{children:(0,y.R6)(y.Nx.TEXT_CREATED_AT)})]})}),(0,O.jsxs)("tbody",{children:[d.map((function(e,t){return(0,O.jsxs)("tr",{children:[(0,O.jsx)("td",{children:j()(e.transaction_date||e.created_at).format("DD/MM/YYYY HH:mm:ss")}),(0,O.jsx)("td",{children:(0,O.jsx)(g.Z,{bg:"IMPORT"===e.type?"success":"EXPORT"===e.type?"danger":"INVENTORY_CHECK"===e.type?"warning":"secondary",children:(0,y.R6)(y.Nx["TEXT_QUANTITY_CHANGE_TYPE_".concat(e.type)])||e.type})}),(0,O.jsxs)("td",{className:e.quantity_change>0?"text-success":"text-danger",children:[e.quantity_change>0?"+":"",e.quantity_change]}),(0,O.jsx)("td",{children:e.quantity}),(0,O.jsx)("td",{children:e.updated_by}),(0,O.jsx)("td",{children:e.system_note||"-"}),(0,O.jsx)("td",{children:e.staff_note||"-"}),(0,O.jsx)("td",{children:j()(e.created_at).format("DD/MM/YYYY HH:mm:ss")})]},t)})),0===d.length&&(0,O.jsx)("tr",{children:(0,O.jsx)("td",{colSpan:"9",className:"text-center",children:(0,y.R6)(y.Nx.TEXT_NO_QUANTITY_CHANGES)})})]})]})]})]})}}]),r}(c.Component);t.Z=w}}]);

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.