sevago-library 1.7.3 → 1.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +200 -197
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.cjs.js
CHANGED
|
@@ -260,7 +260,7 @@ To suppress this warning, you need to explicitly provide the \`palette.${A}Chann
|
|
|
260
260
|
background-size: 20px 20px;
|
|
261
261
|
background-position: 0 0;
|
|
262
262
|
}
|
|
263
|
-
`,ta={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo",infiniteGrid:"transform-component-module_infiniteGrid__Z-aP3"};NO(jO);var FO=function(e){var A=e.children,t=e.wrapperClass,o=t===void 0?"":t,r=e.contentClass,i=r===void 0?"":r,s=e.wrapperStyle,a=e.contentStyle,l=e.wrapperProps,d=l===void 0?{}:l,u=e.contentProps,p=u===void 0?{}:u,f=e.infinite,h=f===void 0?!1:f,m=F.useContext(Bs),g=m.init,C=m.cleanupWindowEvents,b=F.useRef(null),q=F.useRef(null),w=F.useRef(null);return F.useEffect(function(){var y=b.current,S=q.current;return y!==null&&S!==null&&g&&(g==null||g(y,S)),function(){C==null||C()}},[]),F.useEffect(function(){if(h){var y=w.current;if(y){var S=function(){var v=m.state,T=v.positionX,M=v.positionY;y.style.backgroundPosition="".concat(T,"px ").concat(M,"px")};return S(),m.onChange(S)}}},[h,m]),c.jsxs("div",Vt({},d,{ref:b,className:"".concat(Ra.wrapperClass," ").concat(ta.wrapper," ").concat(o),style:s},{children:[h&&c.jsx("div",{ref:w,className:ta.infiniteGrid,"aria-hidden":!0}),c.jsx("div",Vt({},p,{ref:q,className:"".concat(Ra.contentClass," ").concat(ta.content," ").concat(i),style:Vt(Vt({},a),{transform:i5(m.state.positionX,m.state.positionY,m.state.scale)})},{children:A}))]}))};function LO(e,A){var t=Math.max(0,Math.min(e.x+e.width,A.x+A.width)-Math.max(e.x,A.x)),o=Math.max(0,Math.min(e.y+e.height,A.y+A.height)-Math.max(e.y,A.y));return t*o}function QO(e){var A=e.elementX,t=e.elementY,o=e.elementWidth,r=e.elementHeight,i=e.scale,s=e.positionX,a=e.positionY,l=e.viewportWidth,d=e.viewportHeight,u=e.margin,p=u===void 0?0:u,f=e.threshold,h=f===void 0?0:f,m={x:-p,y:-p,width:l+2*p,height:d+2*p},g={x:A*i+s,y:t*i+a,width:o*i,height:r*i};if(h<=0){var C=g.x<m.x+m.width&&g.x+g.width>m.x,b=g.y<m.y+m.height&&g.y+g.height>m.y;return C&&b}var q=g.width*g.height;if(q<=0)return!1;var w=LO(m,g);return w/q>=h}F.forwardRef(function(e,A){var t=e.x,o=e.y,r=e.width,i=e.height,s=e.margin,a=s===void 0?0:s,l=e.threshold,d=l===void 0?0:l,u=e.placeholder,p=u===void 0?null:u,f=e.onShow,h=e.onHide,m=e.children,g=e.className,C=e.style,b=F.useContext(Bs),q=F.useState(!1),w=q[0],y=q[1],S=F.useRef(!1),v=F.useRef(f),T=F.useRef(h);return v.current=f,T.current=h,F.useEffect(function(){var M=function(){var k,x,O=b.wrapperComponent;if(O){var P=QO({elementX:t,elementY:o,elementWidth:r,elementHeight:i,scale:b.state.scale,positionX:b.state.positionX,positionY:b.state.positionY,viewportWidth:O.offsetWidth,viewportHeight:O.offsetHeight,margin:a,threshold:d});P!==S.current&&(S.current=P,y(P),P?(k=v.current)===null||k===void 0||k.call(v):(x=T.current)===null||x===void 0||x.call(T))}};M();var D=b.onChange(M),B;return b.wrapperComponent||(B=b.onInit(function(){return M()})),function(){D(),B==null||B()}},[b,t,o,r,i,a,d]),w?c.jsx("div",Vt({ref:A,className:g,style:C},{children:m})):p?c.jsx(c.Fragment,{children:p}):null});const M1=({open:e,selectedImage:A,selectedIndex:t,imageCount:o,hasMultipleImages:r,showViewerCounter:i,canGoPrevious:s,canGoNext:a,labels:l,viewerPaperSx:d,viewerImageSx:u,onImageError:p,onClose:f,onPrevious:h,onNext:m})=>c.jsx(I.Dialog,{open:e,onClose:f,maxWidth:!1,disableScrollLock:!0,PaperProps:{sx:kt({width:"min(1120px, calc(100vw - 32px))",maxWidth:"none",overflow:"visible",backgroundColor:"transparent",boxShadow:"none"},d)},children:c.jsx(I.DialogContent,{sx:{position:"relative",padding:0,overflow:"visible",display:"grid",placeItems:"center"},children:c.jsxs(I.Box,{sx:{position:"relative",width:"100%"},children:[c.jsx(RO,{centerOnInit:!0,centerZoomedOut:!0,limitToBounds:!0,panning:{allowLeftClickPan:!0,velocityDisabled:!0},doubleClick:{mode:"reset"},children:c.jsx(FO,{wrapperStyle:{width:"100%",maxHeight:"calc(100vh - 96px)",overflow:"hidden",borderRadius:vA,cursor:"grab"},contentStyle:{width:"100%",display:"flex",justifyContent:"center"},children:c.jsx(I.Box,{component:"img",src:A.src,alt:A.alt,draggable:!1,onError:p,sx:kt({display:"block",width:"100%",maxHeight:"calc(100vh - 96px)",objectFit:"contain",borderRadius:vA,backgroundColor:hA[50]},u)})})},A.src),c.jsx(C0,{icon:"close",label:l.close,onClick:f,sx:{top:ve,right:ve}}),r&&c.jsxs(c.Fragment,{children:[c.jsx(C0,{icon:"chevron_left",label:l.previous,disabled:!s,onClick:h,sx:{left:TA,top:"50%",transform:"translateY(-50%)"}}),c.jsx(C0,{icon:"chevron_right",label:l.next,disabled:!a,onClick:m,sx:{right:TA,top:"50%",transform:"translateY(-50%)"}})]}),i&&r&&c.jsx(xA,{content:l.counter(t+1,o),sx:pB})]})})});var yi=(e=>(e.GALLERY="gallery",e.SUMMARY="summary",e))(yi||{});const g5=({images:e,variant:A=yi.GALLERY,activeIndex:t,initialIndex:o=0,mainAspectRatio:r="16 / 9",objectFit:i="cover",thumbnailObjectFit:s="cover",thumbnailSize:a=72,summaryMaxVisible:l=4,summaryThumbnailSize:d=xr.extra_large.width,showThumbnails:u=!0,showPreviewNavigation:p=!0,showViewerCounter:f=!0,openOnMainClick:h=!0,loop:m=!0,fallbackSrc:g,activeColor:C=Ze[500],borderRadius:b=dn,emptyContent:q,labels:w,mainSx:y,mainImageSx:S,summarySx:v,summaryItemSx:T,summaryCountSx:M,thumbnailListSx:D,thumbnailSx:B,viewerPaperSx:k,viewerImageSx:x,onActiveIndexChange:O,onOpenViewer:P,onCloseViewer:R,sx:N,...j})=>{const[V,Q]=F.useState(()=>dr(o,e.length)),[L,H]=F.useState(!1),G=F.useMemo(()=>fB(w),[w]),ee=F.useMemo(()=>e.map((se,Z)=>gB(se,Z,G)),[G,e]),_=ee.length,X=dr(t??V,_),J=ee[X],ne=_>1,le=A===yi.SUMMARY,re=!le&&ne&&u;F.useEffect(()=>{Q(se=>dr(se,_))},[_]);const W=F.useCallback(se=>{if(!g)return;const Z=se.currentTarget;Z.dataset.galleryFallback!=="true"&&(Z.dataset.galleryFallback="true",Z.src=g)},[g]),K=F.useCallback(se=>{const Z=dr(se,_),ie=ee[Z];ie&&(t==null&&Q(Z),O==null||O(Z,ie))},[t,_,ee,O]),Y=ne&&(m||X>0),Ae=ne&&(m||X<_-1),te=F.useCallback(()=>{Y&&K(S1(X,-1,_,m))},[Y,K,_,m,X]),pe=F.useCallback(()=>{Ae&&K(S1(X,1,_,m))},[Ae,K,_,m,X]),oe=F.useCallback(()=>{!J||!h||(H(!0),P==null||P(X,J))},[P,h,J,X]),fe=F.useCallback(se=>{if(!h)return;const Z=dr(se,_),ie=ee[Z];ie&&(Z!==X&&(t==null&&Q(Z),O==null||O(Z,ie)),H(!0),P==null||P(Z,ie))},[t,_,ee,O,P,h,X]),$=F.useCallback(()=>{H(!1),R==null||R()},[R]);return F.useEffect(()=>{if(!L||!ne)return;const se=Z=>{Z.key==="ArrowLeft"&&(Z.preventDefault(),te()),Z.key==="ArrowRight"&&(Z.preventDefault(),pe())};return window.addEventListener("keydown",se),()=>window.removeEventListener("keydown",se)},[pe,te,ne,L]),!_||!J?c.jsx(I.Box,{...j,sx:kt({width:"100%",minHeight:180,display:"grid",placeItems:"center",borderRadius:b,border:`1px solid ${Ve[300]}`,backgroundColor:qo[50]},N),children:q}):le?c.jsxs(I.Box,{...j,sx:kt({width:"fit-content"},N),children:[c.jsx(qB,{images:ee,maxVisible:l,thumbnailSize:d,thumbnailObjectFit:s,labels:G,summarySx:v,summaryItemSx:T,summaryCountSx:M,onOpenIndex:fe,onImageError:W}),c.jsx(M1,{open:L,selectedImage:J,selectedIndex:X,imageCount:_,hasMultipleImages:ne,showViewerCounter:f,canGoPrevious:Y,canGoNext:Ae,labels:G,viewerPaperSx:k,viewerImageSx:x,onImageError:W,onClose:$,onPrevious:te,onNext:pe})]}):c.jsxs(I.Box,{...j,sx:kt({width:"100%",overflow:"hidden",borderRadius:b,border:`1px solid ${Ve[300]}`,backgroundColor:hA[50]},N),children:[c.jsx(hB,{selectedImage:J,hasMultipleImages:ne,showPreviewNavigation:p,openOnMainClick:h,mainAspectRatio:r,objectFit:i,activeColor:C,canGoPrevious:Y,canGoNext:Ae,labels:G,mainSx:y,mainImageSx:S,onImageError:W,onOpenViewer:oe,onPrevious:te,onNext:pe}),re&&c.jsx(wB,{images:ee,selectedIndex:X,thumbnailSize:a,thumbnailObjectFit:s,activeColor:C,labels:G,thumbnailListSx:D,thumbnailSx:B,onSelectIndex:K,onImageError:W}),c.jsx(M1,{open:L,selectedImage:J,selectedIndex:X,imageCount:_,hasMultipleImages:ne,showViewerCounter:f,canGoPrevious:Y,canGoNext:Ae,labels:G,viewerPaperSx:k,viewerImageSx:x,onImageError:W,onClose:$,onPrevious:te,onNext:pe})]})},Nc=(e,A,t)=>Math.min(Math.max(e,A),t),jc=e=>Math.max(U0,e-br-i0),R1=(e,A)=>e==="left"?i0:Math.max(i0,A-br-i0),HO=(e,A)=>({side:e.x<A.width/2?"left":"right",top:Nc(e.y-br/2,U0,jc(A.height))}),N1=e=>{const A=e.split("?")[0].split("#")[0].trim();return!A||A==="/"?"/":A.endsWith("/")?A.slice(0,-1):A},UO=(e,A=[])=>{const t=N1(e);return A.some(o=>{const r=N1(o);if(r.includes("*")){const i=r.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replaceAll("\\*",".*");return new RegExp(`^${i}$`).test(t)}return t===r||t.startsWith(`${r}/`)})},zO=e=>!Array.isArray(e)&&"itemNoCode"in e,VO=e=>!Array.isArray(e)&&"list"in e,m5=e=>!e||Array.isArray(e)?[]:VO(e)?e.list:zO(e)?[e]:[],h5=e=>+!!e.imageUrl+ +!!e.renderImageUrl,WO=e=>e.renderImageUrl??e.imageUrl,GO=e=>e.reduce((A,t)=>A+h5(t),0),C5=e=>{const A=[];return e.imageUrl&&A.push({id:`${e.itemNoCode}-image`,src:e.imageUrl,alt:`${e.itemNoCode} 3D`,title:"3D"}),e.renderImageUrl&&A.push({id:`${e.itemNoCode}-render`,src:e.renderImageUrl,alt:`${e.itemNoCode} Render`,title:"Render"}),A},YO=e=>e?Array.isArray(e)?e:m5(e).flatMap(C5):[],KO=()=>{const[e,A]=F.useState("");return F.useEffect(()=>{if(typeof window>"u")return;const t=()=>A(window.location.pathname),o=()=>{window.setTimeout(()=>{window.dispatchEvent(new Event(j2))},0)},r=window.history.pushState,i=window.history.replaceState;return window.history.pushState=function(...a){const l=r.apply(this,a);return o(),l},window.history.replaceState=function(...a){const l=i.apply(this,a);return o(),l},t(),window.addEventListener("popstate",t),window.addEventListener(j2,t),()=>{window.history.pushState=r,window.history.replaceState=i,window.removeEventListener("popstate",t),window.removeEventListener(j2,t)}},[]),e},XO=()=>{const[e,A]=F.useState({width:0,height:0});return F.useEffect(()=>{if(typeof window>"u")return;const t=()=>A({width:window.innerWidth,height:window.innerHeight});return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),e},JO=e=>{const[A,t]=F.useState({side:"right",top:160});return F.useEffect(()=>{e.height&&t(o=>({...o,top:Nc(o.top,U0,jc(e.height))}))},[e.height]),{launcherPosition:A,setLauncherPosition:t}},ZO=({label:e,position:A,viewportSize:t,onPositionChange:o,onOpen:r})=>{const i=At.useAnimationControls(),s=F.useRef(!1),a=jc(t.height),l=R1(A.side,t.width),d=Nc(A.top,U0,a);return F.useEffect(()=>{t.width&&i.start({x:l,y:d,transition:sa})},[i,d,l,t.width]),c.jsx(Lr,{preset:!1,drag:!0,dragMomentum:!1,dragElastic:h3,"aria-label":e,title:e,onDragStart:()=>{s.current=!0},onDragEnd:(u,p)=>{const f=HO(p.point,t);o(f),i.start({x:R1(f.side,t.width),y:f.top,transition:sa}),window.setTimeout(()=>{s.current=!1},C3)},initial:{x:l,y:d},animate:i,whileHover:{scale:1.05},whileTap:{scale:.96},onClick:()=>{s.current||r()},sx:{position:"fixed",left:0,top:0,width:br,height:br,zIndex:p3,borderRadius:"50%",cursor:"grab",touchAction:"none",userSelect:"none",display:"grid",placeItems:"center",background:`linear-gradient(145deg, ${Cr[600]}, ${Cr[900]})`},children:c.jsx(I.Box,{sx:{width:ia,height:ia,borderRadius:"50%",display:"grid",placeItems:"center",backgroundColor:b3,border:y3},children:c.jsx(ye,{icon:"image_search",fill:1,sx:{color:hA[50],fontSize:u3}})})})},_O=({activeIndex:e,items:A,onChange:t})=>{if(A.length<=1)return null;const o=GO(A);return c.jsxs(I.Stack,{gap:Sn,sx:{padding:ve,borderRadius:vA,border:`1px solid ${Je[300]}`,backgroundColor:qo[50]},children:[c.jsxs(GA,{sx:{gap:ve},children:[c.jsxs(I.Typography,{children:["Tìm thấy ",A.length," mã thành phẩm"]}),c.jsxs(I.Typography,{children:[o," hình ảnh"]})]}),c.jsx(HA,{sx:{display:"grid",gridTemplateColumns:" repeat(3, minmax(0, 1fr))"},children:A.map((r,i)=>{const s=i===e,a=WO(r),l=h5(r);return c.jsx(I.ButtonBase,{"aria-label":`Chọn mã thành phẩm ${r.itemNoCode}`,onClick:()=>t(i),sx:{padding:yA,borderRadius:vA,border:`1px solid ${s?Ze[500]:Ve[300]}`,backgroundColor:s?Ze[50]:hA[50],textAlign:"left",transition:tt,"&:hover":{borderColor:Ze[500],backgroundColor:Ze[50]},"&:focus-visible":{outline:`2px solid ${Ze[500]}`,outlineOffset:"2px"}},children:c.jsxs(Xe,{sx:{width:"100%",gap:ve},children:[a&&c.jsx(un,{url:a,sizeType:"FULL_WIDTH",size:Mt.AVATAR_GROUP}),c.jsxs(I.Stack,{sx:{minWidth:0,flex:1,gap:yA},children:[c.jsx(I.Typography,{sx:{...Me.textXs.semiBold,color:Ve[900],overflowWrap:"anywhere"},children:r.itemNoCode}),c.jsxs(I.Typography,{sx:{color:Je[500]},children:[l," ảnh"]})]})]})},r.itemNoCode)})})]})},$O=({activeOptionIndex:e,defaultEmptyContent:A,displayLoading:t,galleryImages:o,galleryProps:r,loadingContent:i,open:s,panelTitle:a,searchContent:l,searchDebounceMs:d,searchLabel:u,searchName:p,searchPlaceholder:f,searchText:h,resultItems:m,onClose:g,onOptionChange:C,onSearchTextChange:b})=>c.jsx(zi,{open:s,onClose:g,label:a,maxWidth:!1,sx:{width:f3,maxWidth:g3},sxContent:{maxHeight:m3},nodeContent:c.jsxs(I.Stack,{gap:ve,children:[l,c.jsx(j4,{label:u,name:p,value:h,placeholder:f,disabled:t,debounceMs:d,onChange:q=>b(q.target.value??""),searchIcon:"search"}),c.jsx(_O,{items:m,activeIndex:e,onChange:C}),c.jsx(g5,{...r,images:t&&!o.length?[]:o,emptyContent:t&&!o.length?i??c.jsx(gt,{}):A})]})}),b5=({images:e,open:A,defaultOpen:t=!1,hideLauncher:o=!1,isLoading:r=!1,searchLabel:i="Mã sản phẩm",searchPlaceholder:s="Nhập hoặc quét mã sản phẩm...",searchName:a="finishGoodItemNoCode",searchContent:l,searchDebounceMs:d=300,emptyContent:u,loadingContent:p,axiosProductManagement:f,blacklist:h,launcherLabel:m="Tra cứu hình ảnh sản phẩm",panelTitle:g="Hình ảnh thành phẩm",onOpenChange:C,onSearch:b,textEmpty:q="Không có hình ảnh 3D/render",...w})=>{const y=u??c.jsx(Kn,{content:q}),[S,v]=F.useState(""),[T,M]=F.useState(),[D,B]=F.useState(!1),[k,x]=F.useState(0),[O,P]=F.useState(t),R=F.useRef(b),N=F.useRef(0),j=KO(),V=XO(),{launcherPosition:Q,setLauncherPosition:L}=JO(V),H=f?T:e,G=r||D,ee=F.useMemo(()=>m5(H),[H]),_=F.useMemo(()=>ee.length?C5(ee[k]??ee[0]):YO(H),[k,H,ee]),X=j?UO(j,h):!1,J=A??O,ne=W=>{A===void 0&&P(W),C==null||C(W)};R.current=b,F.useEffect(()=>{X&&ne(!1)},[X]),F.useEffect(()=>{x(0)},[H]);const le=async(W=S)=>{var Ae;const K=W.trim();if(Hn(K))return;if(!f){(Ae=R.current)==null||Ae.call(R,K);return}const Y=N.current+1;N.current=Y;try{B(!0);const te=await o3(f,K);if(N.current!==Y)return;M(te)}catch(te){if(N.current!==Y)return;M(void 0),console.error(te)}finally{N.current===Y&&B(!1)}},re=W=>{v(W),le(W)};return X||!V.width?null:c.jsxs(c.Fragment,{children:[!o&&!J&&c.jsx(ZO,{label:m,position:Q,viewportSize:V,onPositionChange:L,onOpen:()=>ne(!0)}),c.jsx($O,{activeOptionIndex:k,defaultEmptyContent:y,displayLoading:G,galleryImages:_,loadingContent:p,open:J,panelTitle:g,galleryProps:w,searchContent:l,searchDebounceMs:d,searchLabel:i,searchName:a,searchPlaceholder:s,searchText:S,resultItems:ee,onClose:()=>ne(!1),onOptionChange:x,onSearchTextChange:re})]})},ek=({url:e,content:A,caption:t,sizeType:o=Mt.MEDIUM,sx:r,sxContent:i,sxCaption:s,alt:a="",userTitleName:l})=>c.jsxs(HA,{alignItems:"center",sx:{...r,gap:ve},children:[c.jsx(ht,{alt:a,url:e,size:o}),c.jsx(X4,{userTitleName:l,content:A,caption:t,sxContent:i,sxCaption:s})]}),y5=({time:e,hasText:A})=>c.jsx(I.Typography,{variant:"caption",sx:{...XA(1),color:Je[500]},children:(A?"Cập nhật lúc ":"")+L3(e)}),x5=({time:e,content:A,height:t=q3})=>c.jsxs(rA.Stack,{sx:{height:t,gap:0,justifyContent:"space-between",alignItems:"flex-start"},children:[c.jsx(xA,{content:A}),c.jsx(y5,{time:e})]}),Ak=({url:e,content:A,time:t,sizeType:o=Mt.MEDIUM})=>c.jsxs(HA,{alignItems:"center",children:[c.jsx(ht,{url:e,size:o}),c.jsx(x5,{content:A,time:t})]}),tk=({loading:e,content:A,startIcon:t,endIcon:o,sx:r,permission:i,...s})=>i===!1?null:c.jsx(I.Button,{...s,startIcon:t&&!e&&c.jsx(un,{url:t,sx:{width:so.small,height:so.small,borderRadius:la,opacity:s.disabled?.6:1}}),endIcon:o&&!e&&c.jsx(un,{url:o,sx:{width:so.medium,height:so.medium,borderRadius:la,opacity:s.disabled?.6:1}}),sx:{textTransform:"none",borderRadius:QA,minWidth:"unset","& > .MuiButton-endIcon":{margin:0},...r},children:e?c.jsx(gt,{size:"small",sx:{minHeight:"24.5px"}}):c.jsx(I.Typography,{sx:{transform:"translateY(0.5px)",whiteSpace:"nowrap"},children:A})}),Fc=({multiple:e=!1,onChange:A,accept:t="image/*",permission:o,loading:r=!1,...i})=>{if(o===!1)return null;const[s,a]=F.useState([]),l=F.useRef(null),d=u=>{if(u.target.files){const f=Array.from(u.target.files).map(h=>Object.assign(h,{preview:URL.createObjectURL(h)}));a(f),A(f)}};return F.useEffect(()=>()=>s==null?void 0:s.forEach(u=>{URL.revokeObjectURL(u.preview)}),[s]),c.jsxs(F.Fragment,{children:[c.jsx(I.Stack,{sx:{width:"fit-content",height:"fit-content"},children:c.jsx(qt,{...i,loading:r,icon:"attach_file",onClick:()=>l.current&&l.current.click()})}),c.jsx("input",{type:"file",accept:t,hidden:!0,multiple:e,ref:l,onChange:d})]})},nk=(...e)=>e.flatMap(A=>A?Array.isArray(A)?A:[A]:[]),ok={minWidth:100,textTransform:"none",borderRadius:QA,width:"fit-content"},rk={...Me.textSm.regular,whiteSpace:"nowrap"},sA=({content:e,loading:A=!1,startIcon:t,endIcon:o,variant:r="contained",sx:i,disabled:s=!1,...a})=>{const{palette:l}=I.useTheme();return c.jsx(I.Button,{...a,variant:r,startIcon:!A&&t?typeof t=="string"?c.jsx(ye,{icon:t,sx:{cursor:"pointer"}}):t:void 0,endIcon:!A&&o?typeof o=="string"?c.jsx(ye,{icon:o,sx:{cursor:"pointer"}}):o:void 0,sx:nk(ok,i),disabled:s,children:A?c.jsx(gt,{color:r==="contained"?l.primary.contrastText:a.color,size:"small",sx:{minHeight:"24.5px"}}):c.jsx(I.Typography,{sx:rk,children:e})})},F0=({label:e,name:A,size:t="small",sx:o,...r})=>c.jsx(I.FormControlLabel,{sx:{marginRight:0},name:A,control:c.jsx(I.Checkbox,{size:t,...r,sx:{paddingTop:0,paddingBottom:0,paddingRight:ve,borderRadius:10,"&:hover":{backgroundColor:"unset"},...o}}),label:e}),ik=({open:e,anchorEl:A,title:t="Tùy chỉnh trường",items:o,onClose:r,onToggle:i})=>c.jsx(I.Popover,{open:e,anchorEl:A,onClose:r,disableScrollLock:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{sx:{mt:"8px",minWidth:320,maxHeight:520,borderRadius:En,border:`1px solid ${Ve[200]}`,boxShadow:"0 1px 2px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.1)",overflow:"hidden"}}},children:c.jsxs(I.Box,{sx:{backgroundColor:hA[50]},children:[c.jsxs(Xe,{sx:{justifyContent:"space-between",padding:"12px 12px 10px 12px",borderBottom:`1px solid ${Ve[200]}`},children:[c.jsx(I.Typography,{sx:{...Me.textMd.semiBold},children:t}),c.jsx(I.IconButton,{onClick:r,sx:{padding:.5},children:c.jsx(ye,{icon:"close"})})]}),c.jsx(bo,{sx:{alignItems:"stretch",gap:.5,padding:"10px 8px",maxHeight:460,overflowY:"auto"},children:o.map(s=>c.jsxs(Xe,{sx:{justifyContent:"space-between",gap:1,padding:"8px 8px",borderRadius:QA,opacity:s.disabled?.6:1},children:[c.jsxs(Xe,{sx:{gap:1,minWidth:0},children:[c.jsx(ye,{icon:"drag_indicator",sx:{color:Ve[400]}}),c.jsx(I.Typography,{sx:{...Me.textSm.regular,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:s.label})]}),c.jsx(I.Checkbox,{checked:s.checked,disabled:s.disabled,onChange:a=>i(s.key,a.target.checked),sx:{padding:0}})]},s.key))})]})}),sk=({headerAction:e,children:A,isCollapsible:t=!0,title:o,description:r,defaultExpanded:i=!0,sx:s,titleSx:a})=>{const[l,d]=F.useState(i),u=!!o&&t;return c.jsxs(I.Stack,{sx:{bgcolor:hA[50],borderRadius:QA,overflow:"hidden",gap:ve,boxShadow:2,p:TA,...s},children:[o&&c.jsxs(GA,{onClick:()=>d(p=>!p),sx:{"&:hover":{cursor:"pointer"}},children:[c.jsxs(HA,{gap:ve,children:[c.jsx(xA,{content:o,sx:{...Me.textMd.semiBold,color:Ze[500],...a}}),r]}),c.jsxs(Xe,{gap:0,children:[e,u&&c.jsx(qt,{icon:l?"expand_less":"expand_more"})]})]}),c.jsx(I.Collapse,{in:!u||l,unmountOnExit:u,children:c.jsx(I.Stack,{sx:{gap:ve},children:A})})]})},v5=({orientation:e="horizontal",color:A=IA.gray2,thickness:t=1,length:o="100%",sx:r,dashed:i=!0})=>e==="vertical"?c.jsx(rA.Box,{sx:{height:o,display:"flex",justifyContent:"center",alignSelf:"center","&::before":{content:'""',width:`${t}px`,height:"100%",borderLeft:`${t}px ${i?"dashed":"solid"} ${A}`,...r}}}):c.jsx(rA.Box,{sx:{borderBottom:`${t}px ${i?"dashed":"solid"} ${A}`,width:typeof o=="number"?`${o}px`:o,alignSelf:"stretch",display:"block",...r}}),q5="180px",ja="140px",w5="250px";var hn=(e=>(e.Equals="Equals",e.NotEquals="NotEquals",e.Contains="Contains",e.NotContains="NotContains",e.IsNull="IsNull",e.IsNotNull="IsNotNull",e.GreaterThan="GreaterThan",e.LessThan="LessThan",e.GreaterThanOrEqual="GreaterThanOrEqual",e.LessThanOrEqual="LessThanOrEqual",e))(hn||{}),MA=(e=>(e.EXACT="EXACT",e.DATE_RANGE="DATE_RANGE",e.TODAY="TODAY",e.TOMORROW="TOMORROW",e.YESTERDAY="YESTERDAY",e.THIS_WEEK="THIS_WEEK",e.LAST_WEEK="LAST_WEEK",e.THIS_MONTH="THIS_MONTH",e.LAST_MONTH="LAST_MONTH",e.LAST_7_DAYS="LAST_7_DAYS",e.NEXT_7_DAYS="NEXT_7_DAYS",e.LAST_30_DAYS="LAST_30_DAYS",e.NEXT_30_DAYS="NEXT_30_DAYS",e))(MA||{});const S5=[{label:"Là",value:"Equals"},{label:"Không là",value:"NotEquals"},{label:"Chứa",value:"Contains"},{label:"Không chứa",value:"NotContains"},{label:"Lớn hơn",value:"GreaterThan"},{label:"Lớn hơn hoặc bằng",value:"GreaterThanOrEqual"},{label:"Nhỏ hơn",value:"LessThan"},{label:"Nhỏ hơn hoặc bằng",value:"LessThanOrEqual"},{label:"Trống",value:"IsNull"},{label:"Không trống",value:"IsNotNull"}],E5=[{label:"Là",value:"Equals"},{label:"Không là",value:"NotEquals"},{label:"Chứa",value:"Contains"},{label:"Không chứa",value:"NotContains"},{label:"Trống",value:"IsNull"},{label:"Không trống",value:"IsNotNull"}],I5=[{label:"Là",value:"Equals"},{label:"Trống",value:"IsNull"},{label:"Không trống",value:"IsNotNull"}],T5=[{label:"ngày chính xác",value:"EXACT"},{label:"khoảng ngày",value:"DATE_RANGE"},{label:"hôm nay",value:"TODAY"},{label:"ngày mai",value:"TOMORROW"},{label:"hôm qua",value:"YESTERDAY"},{label:"tuần này",value:"THIS_WEEK"},{label:"tuần trước",value:"LAST_WEEK"},{label:"tháng này",value:"THIS_MONTH"},{label:"tháng trước",value:"LAST_MONTH"},{label:"trong 7 ngày qua",value:"LAST_7_DAYS"},{label:"trong 7 ngày tiếp theo",value:"NEXT_7_DAYS"},{label:"trong 30 ngày qua",value:"LAST_30_DAYS"},{label:"trong 30 ngày tiếp theo",value:"NEXT_30_DAYS"}],Wn=()=>typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():Math.random().toString(36).substring(2,9),D5=e=>{if(!e)return{};const A=Be().startOf("day"),t=e.split("|"),o=t[0];let r=A,i=A;if(o===MA.EXACT){const s=t[1];if(s){const a=Be(s).startOf("day"),l=Be(s).endOf("day");return{fromDate:a.unix(),toDate:l.unix()}}return{}}if(o===MA.DATE_RANGE){const s=t[1],a=t[2],l=s?Be(s).startOf("day").unix():void 0,d=a?Be(a).endOf("day").unix():void 0;return{fromDate:l,toDate:d}}switch(o){case MA.TODAY:r=A.startOf("day"),i=A.endOf("day");break;case MA.TOMORROW:r=A.add(1,"day").startOf("day"),i=A.add(1,"day").endOf("day");break;case MA.YESTERDAY:r=A.subtract(1,"day").startOf("day"),i=A.subtract(1,"day").endOf("day");break;case MA.THIS_WEEK:{const s=(7+(A.day()-1))%7;r=A.subtract(s,"day"),i=r.add(6,"day").endOf("day");break}case MA.LAST_WEEK:{const s=(7+(A.day()-1))%7;r=A.subtract(s,"day").subtract(7,"day"),i=r.add(6,"day").endOf("day");break}case MA.THIS_MONTH:r=A.startOf("month"),i=A.endOf("month");break;case MA.LAST_MONTH:r=A.subtract(1,"month").startOf("month"),i=A.subtract(1,"month").endOf("month");break;case MA.LAST_7_DAYS:r=A.subtract(7,"day"),i=A.endOf("day");break;case MA.NEXT_7_DAYS:r=A,i=A.add(7,"day").endOf("day");break;case MA.LAST_30_DAYS:r=A.subtract(30,"day"),i=A.endOf("day");break;case MA.NEXT_30_DAYS:r=A,i=A.add(30,"day").endOf("day");break;default:return{}}return{fromDate:r.unix(),toDate:i.unix()}},ak=e=>e.reduce((A,t)=>(A[t.key]=t.defaultValue,A),{}),j1=(e,A)=>{const t=e.filter(r=>((A==null?void 0:A[r.key])??r.defaultValue)!==r.defaultValue).map(r=>({id:Wn(),fieldKey:r.key,value:(A==null?void 0:A[r.key])??r.defaultValue}));if(t.length>0)return t;const o=e[0];return o?[{id:Wn(),fieldKey:o.key,value:(A==null?void 0:A[o.key])??o.defaultValue}]:[]},lk=({open:e,title:A="Tùy chỉnh bộ lọc",fields:t,value:o,anchorEl:r,offset:i,onClose:s,onApply:a})=>{const l=F.useMemo(()=>ak(t),[t]),d=F.useMemo(()=>t.map(y=>({label:y.label,value:y.key})),[t]),[u,p]=F.useState(()=>j1(t,o)),[f,h]=F.useState(null);F.useEffect(()=>{e&&(p(j1(t,o)),h(null))},[t,e,o]);const m=()=>{const y=t[0];if(!y){p([]);return}p([{id:Wn(),fieldKey:y.key,value:y.defaultValue}])},g=y=>{p(S=>{const v=S.filter((M,D)=>D!==y);if(v.length>0)return v;const T=t[0];return T?[{id:Wn(),fieldKey:T.key,value:T.defaultValue}]:[]})},C=()=>{p(y=>{const S=new Set(y.map(T=>T.fieldKey)),v=t.find(T=>!S.has(T.key));return v?[...y,{id:Wn(),fieldKey:v.key,value:v.defaultValue}]:y})},b=y=>{f===null||y===f||(p(S=>{const v=[...S],[T]=v.splice(f,1);return v.splice(y,0,T),v}),h(null))},q=()=>{const y={...l};u.forEach(S=>{S.fieldKey&&(y[S.fieldKey]=S.value)}),a(y),s()},w=u.length<t.length;return c.jsx(I.Popover,{open:e,anchorEl:r,onClose:s,disableScrollLock:!0,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},slotProps:{paper:{sx:{mt:`${(i==null?void 0:i.y)??8}px`,ml:`${(i==null?void 0:i.x)??0}px`,minWidth:320,maxWidth:"calc(100vw - 48px)",borderRadius:En,border:`1px solid ${Ve[300]}`,boxShadow:"0 8px 24px rgba(15, 23, 42, 0.12)",overflow:"hidden"}}},children:c.jsx(I.Box,{sx:{backgroundColor:hA[50],padding:2},children:c.jsxs(bo,{sx:{alignItems:"stretch",gap:2},children:[c.jsxs(GA,{sx:{gap:1},children:[c.jsx(I.Typography,{sx:{...Me.textMd.semiBold},children:A}),c.jsx(I.IconButton,{onClick:s,sx:{padding:yA},children:c.jsx(ye,{icon:"close"})})]}),c.jsx(bo,{sx:{alignItems:"stretch",gap:1.25},children:u.map((y,S)=>{const v=t.find(D=>D.key===y.fieldKey);if(!v)return null;const T=new Set(u.map(D=>D.fieldKey)),M=d.filter(D=>D.value===y.fieldKey||!T.has(D.value));return c.jsxs(Xe,{onDragOver:D=>D.preventDefault(),onDrop:()=>b(S),sx:{gap:1,alignItems:"flex-end"},children:[c.jsx(I.Box,{draggable:!0,onDragStart:()=>h(S),onDragEnd:()=>h(null),sx:{paddingBottom:"10px",cursor:"grab"},children:c.jsx(ye,{icon:"drag_indicator",sx:{color:Ve[500]}})}),c.jsx(I.Box,{sx:{flex:1,minWidth:220},children:c.jsx(qn,{label:"",value:y.fieldKey,options:M,placeholder:"",onChange:D=>{const B=D.target.value,k=t.find(x=>x.key===B);k&&p(x=>x.map((O,P)=>P===S?{...O,fieldKey:B,value:k.defaultValue}:O))}})}),c.jsx(I.Box,{sx:{flex:1,minWidth:220},children:c.jsx(qn,{label:"",value:y.value??v.defaultValue,options:v.options,placeholder:"Tất cả",onChange:D=>{const B=D.target.value;p(k=>k.map((x,O)=>O===S?{...x,value:B}:x))}})}),c.jsx(I.IconButton,{onClick:()=>g(S),children:c.jsx(ye,{icon:"delete_outline"})})]},y.id)})}),w&&c.jsx(sA,{content:"Thêm điều kiện",onClick:C,startIcon:"add",variant:"text",sx:{color:Ze[500],minWidth:0,paddingX:0}}),c.jsxs(GA,{sx:{marginTop:1},children:[c.jsx(sA,{content:"Mặc định",onClick:m,variant:"text",sx:{color:Ze[500],minWidth:0,paddingX:0}}),c.jsxs(Xe,{sx:{gap:1},children:[c.jsx(sA,{onClick:s,variant:"outlined",content:"Hủy"}),c.jsx(sA,{onClick:q,variant:"contained",content:"Áp dụng"})]})]})]})})})},ck=({field:e,rowValue:A,onChange:t})=>{switch(e.type){case"select":return c.jsx(qn,{label:"",value:A??e.defaultValue,options:e.options||[],placeholder:"Tất cả",onChange:o=>t(o.target.value)});case"date":{const o=A?A.split("|"):"",r=o[0],i=r===MA.EXACT?o[1]:"",s=r===MA.DATE_RANGE?o[1]:"",a=r===MA.DATE_RANGE?o[2]:"",l=r===MA.EXACT||r===MA.DATE_RANGE;return c.jsxs(I.Box,{sx:{display:"flex",gap:ve,width:"100%"},children:[c.jsx(I.Box,{sx:{width:l?"140px":"100%",flexShrink:0},children:c.jsx(qn,{label:"",value:r,options:T5,placeholder:"",onChange:d=>{const u=d.target.value;let p=u;u===MA.EXACT&&(p=`${MA.EXACT}|`),u===MA.DATE_RANGE&&(p=`${MA.DATE_RANGE}||`),t(p)}})}),r===MA.EXACT&&c.jsx(I.Box,{sx:{flex:1},children:c.jsx(R4,{name:`exact-date-${Wn()}`,label:"",value:i||null,onChange:d=>{const u=d.target.value,p=u?Be(u).format("YYYY-MM-DD"):"";t(`${MA.EXACT}|${p}`)}})}),r===MA.DATE_RANGE&&c.jsx(I.Box,{sx:{flex:1},children:c.jsx(y4,{format:"DD/MM/YYYY",placeholder:"Ngày bắt đầu — Ngày kết thúc",label:"",fromDate:s,toDate:a,onFromDateChange:d=>{const u=d?Be(d).format("YYYY-MM-DD"):"";t(`${MA.DATE_RANGE}|${u}|${a}`)},onToDateChange:d=>{const u=d?Be(d).format("YYYY-MM-DD"):"";t(`${MA.DATE_RANGE}|${s}|${u}`)}})})]})}}},dk=({open:e,title:A="Tùy chỉnh bộ lọc nâng cao",fields:t,value:o,operatorOptions:r=E5,fullOperator:i=!1,anchorEl:s,offset:a,onClose:l,onApply:d})=>{const[u,p]=F.useState([]),[f,h]=F.useState(null);F.useEffect(()=>{e&&(o&&o.length>0?p(o.map(v=>({id:Wn(),fieldKey:v.field,operator:v.operator,value:v.value}))):p([]),h(null))},[e,o]);const m=(v,T)=>{p(M=>M.map((D,B)=>B===v?{...D,...T}:D))},g=()=>p([]),C=v=>p(T=>T.filter((M,D)=>D!==v)),b=()=>{p(v=>{if(v.length>=t.length)return v;const T=new Set(v.map(D=>D.fieldKey)),M=t.find(D=>!T.has(D.key))||t[0];return M?[...v,{id:Wn(),fieldKey:M.key,operator:hn.Equals,value:M.defaultValue}]:v})},q=v=>{f===null||v===f||(p(T=>{const M=[...T],[D]=M.splice(f,1);return M.splice(v,0,D),M}),h(null))},w=()=>{const v=u.filter(T=>T.fieldKey).map(T=>{const M=t.find(x=>x.key===T.fieldKey);let D,B;if((M==null?void 0:M.type)==="date"&&T.operator!==hn.IsNull&&T.operator!==hn.IsNotNull){const x=D5(T.value);D=x.fromDate,B=x.toDate}return{field:T.fieldKey,operator:T.operator,value:T.operator===hn.IsNull||T.operator===hn.IsNotNull?"":T.value,fromDate:D,toDate:B}});d(v),l()},y=t.map(v=>({label:v.label,value:v.key})),S=u.map(v=>v.fieldKey);return c.jsx(I.Popover,{open:e,anchorEl:s,onClose:l,disableScrollLock:!0,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},slotProps:{paper:{sx:{mt:`${(a==null?void 0:a.y)??8}px`,ml:`${(a==null?void 0:a.x)??0}px`,width:"max-content",minWidth:"800px",maxWidth:"calc(100vw - 48px)",boxShadow:4,overflow:"hidden"}}},children:c.jsx(rA.Stack,{sx:{backgroundColor:Ve[50],padding:w3},children:c.jsxs(rA.Stack,{children:[c.jsxs(GA,{children:[c.jsx(I.Typography,{sx:{...Me.textMd.semiBold},children:A}),c.jsx(I.IconButton,{onClick:l,sx:{padding:yA},children:c.jsx(ye,{icon:"close"})})]}),c.jsxs(rA.Stack,{children:[u.length===0&&c.jsx(I.Typography,{sx:{color:Ve[400],fontStyle:"italic"},children:"Chưa có điều kiện lọc nào được áp dụng."}),u.map((v,T)=>{const M=t.find(O=>O.key===v.fieldKey);if(!M)return null;const D=M.type==="date";i&&(r=S5);const B=D?I5:r,k=v.operator===hn.IsNull||v.operator===hn.IsNotNull,x=y.filter(O=>!S.includes(O.value)||O.value===v.fieldKey);return c.jsxs(Xe,{onDragOver:O=>O.preventDefault(),onDrop:()=>q(T),sx:{gap:ve},children:[c.jsx(rA.Stack,{draggable:!0,onDragStart:()=>h(T),onDragEnd:()=>h(null),sx:{cursor:"grab"},children:c.jsx(ye,{icon:"drag_indicator",sx:{color:Ve[400]}})}),c.jsx(rA.Stack,{sx:{width:q5},children:c.jsx(qn,{label:"",value:v.fieldKey,options:x,placeholder:"",onChange:O=>{const P=O.target.value,R=t.find(N=>N.key===P);R&&m(T,{fieldKey:P,value:R.defaultValue,operator:hn.Equals})}})}),c.jsx(rA.Stack,{sx:{width:ja},children:c.jsx(qn,{label:"",value:v.operator,options:B,placeholder:"",onChange:O=>{const P=O.target.value,R=v.value;m(T,{operator:P,value:R})},sx:{width:ja}})}),c.jsx(rA.Stack,{sx:{flex:1,minWidth:w5},children:k?c.jsx(qn,{label:"",value:"",options:[],placeholder:"---",disabled:!0}):c.jsx(ck,{field:M,rowValue:v.value,onChange:O=>m(T,{value:O})})}),c.jsx(I.IconButton,{onClick:()=>C(T),children:c.jsx(ye,{icon:"delete_outline"})})]},v.id)})]}),u.length<t.length&&c.jsx(sA,{content:"Thêm điều kiện",onClick:b,startIcon:"add",variant:"text"}),c.jsxs(GA,{sx:{marginTop:Ya},children:[c.jsx(rA.Stack,{onClick:g,sx:{cursor:"pointer",color:Ze[500]},children:"Mặc định"}),c.jsxs(Xe,{sx:{gap:1},children:[c.jsx(sA,{onClick:l,variant:"outlined",content:"Hủy",sx:{borderRadius:QA}}),c.jsx(sA,{onClick:w,variant:"contained",content:"Áp dụng",sx:{borderRadius:QA}})]})]})]})})})},uk=({children:e,onApply:A,onReset:t,initialFilters:o={},sx:r={},ignoredKeysInCount:i=[]})=>{const[s,a]=F.useState(!1),[l,d]=F.useState(o),[u,p]=F.useState(o),f=Object.entries(l).filter(([C,b])=>i.includes(C)?!1:Array.isArray(b)?b.length>0:b!=null&&b!=="").length;F.useEffect(()=>{s&&p({...l})},[l,s]);const h=(C,b)=>{p(q=>({...q,[C]:b}))},m=()=>{d(u),A==null||A(u),a(!1)},g=()=>{p({}),d({}),t==null||t(),a(!1)};return c.jsxs(F.Fragment,{children:[c.jsx(sA,{sx:{...r,color:(f>0,Ze[500]),minWidth:"auto",p:s0},startIcon:"filter_list_alt",variant:"outlined",onClick:()=>a(!0),content:`Bộ lọc${f>0?` (${f})`:""}`}),c.jsx(I.Drawer,{anchor:"right",open:s,onClose:()=>a(!1),sx:{"& .MuiDrawer-paper":{width:320,padding:TA}},children:c.jsxs(rA.Stack,{sx:{height:"100%"},children:[c.jsxs(GA,{sx:{gap:0},children:[c.jsx(xA,{content:"Bộ lọc",sx:{...Me.textLg.semiBold}}),c.jsx(I.IconButton,{onClick:()=>a(!1),children:c.jsx(ye,{icon:"close"})})]}),c.jsx(rA.Stack,{sx:{flex:1,gap:ve,overflowY:"auto",scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:e({filters:l,tempFilters:u,setFilter:h,setTempFilters:p})}),c.jsxs(ap,{sx:{gap:ve},children:[c.jsx(sA,{variant:"outlined",onClick:g,content:"Đặt lại"}),c.jsx(sA,{variant:"contained",onClick:m,content:"Cập nhật"})]})]})})]})},zt=56,F1=42,L1=26,pk=12,X2=18,Os=76,fk=160,Q1={type:"spring",stiffness:520,damping:34},gk=e=>(zt+pk)*(e+1),Lc=(e,A,t)=>Math.min(Math.max(e,A),t),xi=e=>Math.max(Os,e-zt-X2),H1=(e,A)=>e==="left"?X2:Math.max(X2,A-zt-X2),mk=(e,A)=>({side:e.x<A.width/2?"left":"right",top:Lc(e.y-zt/2,Os,xi(A.height))}),hk=(e,A,t)=>({position:"absolute",right:0,bottom:t?gk(A):0,width:zt,height:zt,borderRadius:"50%",opacity:t?1:0,pointerEvents:t?"auto":"none",transform:t?"scale(1)":"scale(0.82)",transition:`bottom ${tt}, opacity ${tt}, transform ${tt}`,backgroundColor:e.backgroundColor??hA[50],border:`2px solid ${Ze[200]}`,boxShadow:"0 10px 24px rgba(0, 0, 0, 0.2)","&:hover":{borderColor:Ze[500],transform:t?"scale(1.04)":"scale(0.82)"},"&:focus-visible":{outline:`2px solid ${Ze[300]}`,outlineOffset:"2px"}}),Ck=()=>{const[e,A]=F.useState({width:0,height:0});return F.useEffect(()=>{if(typeof window>"u")return;const t=()=>A({width:window.innerWidth,height:window.innerHeight});return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),e},bk=e=>{const[A,t]=F.useState(null);return F.useEffect(()=>{!e.width||!e.height||t(o=>o?{...o,top:Lc(o.top,Os,xi(e.height))}:{side:"right",top:xi(e.height)})},[e.width,e.height]),{position:A,setPosition:t}},B5=({closeOnActionClick:e=!0,items:A,launcherIcon:t="chat",launcherLabel:o="Công cụ",sx:r})=>{const[i,s]=F.useState(!1),a=At.useAnimationControls(),l=F.useRef(!1),d=Ck(),{position:u,setPosition:p}=bk(d),f=!!d.width&&!!d.height&&!!u,h=u?H1(u.side,d.width):0,m=u?Lc(u.top,Os,xi(d.height)):0,g=r&&!Array.isArray(r)&&typeof r=="object"?r:void 0;F.useEffect(()=>{!u||!d.width||a.start({x:h,y:m,transition:Q1})},[a,u,m,h,d.width]);const C=c.jsxs(I.Stack,{sx:{position:"relative",width:zt,height:zt},children:[A.map((b,q)=>c.jsx(I.ButtonBase,{"aria-label":b.label,title:b.label,disabled:b.disabled,onClick:()=>{e&&s(!1),b.onClick()},sx:hk(b,q,i),children:c.jsx(ye,{icon:b.icon,fill:1,sx:{color:b.color??Ze[700],fontSize:L1}})},b.key)),c.jsx(I.ButtonBase,{"aria-label":o,title:o,onClick:()=>{l.current||s(b=>!b)},sx:{position:"absolute",right:0,bottom:0,width:zt,height:zt,borderRadius:"50%",backgroundColor:hA[50],border:`2px solid ${Ze[200]}`,boxShadow:"0 10px 24px rgba(0, 0, 0, 0.22)","&:hover":{borderColor:Ze[500]},"&:focus-visible":{outline:`2px solid ${Ze[300]}`,outlineOffset:"2px"}},children:c.jsx(I.Box,{sx:{width:F1,height:F1,borderRadius:"50%",display:"grid",placeItems:"center",backgroundColor:Ze[700],transform:i?"scale(0.96)":"scale(1)",transition:tt},children:c.jsx(ye,{icon:i?"close":t,fill:1,sx:{color:hA[50],fontSize:L1}})})})]});return!f||!u?null:c.jsx(Lr,{preset:!1,drag:!0,dragMomentum:!1,dragElastic:.08,onDragStart:()=>{l.current=!0},onDragEnd:(b,q)=>{const w=mk(q.point,d);p(w),a.start({x:H1(w.side,d.width),y:w.top,transition:Q1}),window.setTimeout(()=>{l.current=!1},fk)},initial:{x:h,y:m},animate:a,whileHover:{scale:1.05},whileTap:{scale:.96},sx:{position:"fixed",left:0,top:0,width:zt,height:zt,zIndex:1400,cursor:"grab",touchAction:"none",userSelect:"none",...g},children:C})},yk=({axiosProductManagement:e,enableFinishGoodGallery:A=!0,enableScale:t=!0,items:o=[],scaleAutoConnectAuthorized:r=!0})=>{const i=d2(),[s,a]=F.useState(!1),l=F.useRef(void 0),d=F.useRef(!1),u=(i==null?void 0:i.status)===eA.Connected,p=(i==null?void 0:i.status)===eA.Idle,f=(i==null?void 0:i.status)===eA.Connecting||(i==null?void 0:i.status)===eA.Disconnecting;F.useEffect(()=>{t||(l.current=void 0,d.current=!1)},[t]),F.useEffect(()=>{if(!t||!r||d.current||!i||!p||i.authorizedPorts.length!==1)return;const m=i.authorizedPorts[0],g=`${m.index}:${m.label}`;l.current!==g&&(l.current=g,i.connect({useAuthorizedPort:!0,authorizedPortIndex:m.index,silentNoAuthorizedPort:!0}))},[t,p,i,r]);const h=F.useMemo(()=>{const m=[];return t&&m.push({key:"scale",label:u?"Ngắt kết nối cân":"Kết nối cân",icon:"scale",disabled:!i||f,backgroundColor:u?mo[50]:void 0,color:u?mo[700]:void 0,onClick:()=>{if(!(!i||f)){if(u){d.current=!0,i.disconnect();return}if(d.current=!1,i.authorizedPorts.length){i.connect({useAuthorizedPort:!0,authorizedPortIndex:i.authorizedPorts[0].index});return}i.connect()}}}),A&&m.push({key:"finish-good-gallery",label:"Hình ảnh thành phẩm",icon:"image_search",onClick:()=>a(!0)}),m.push(...o),m},[A,t,f,u,o,i]);return h.length?c.jsxs(c.Fragment,{children:[c.jsx(B5,{items:h,launcherIcon:"support_agent",launcherLabel:"Công cụ"}),A?c.jsx(b5,{axiosProductManagement:e,hideLauncher:!0,open:s,onOpenChange:a}):null]}):null},O5=({titleNode:e,list:A,sxList:t={},sxListItem:o={},sxIconContent:r={},sxTitleNode:i={}})=>{const{palette:s}=I.useTheme();return c.jsxs(I.List,{sx:{display:"flex",flexDirection:"column",padding:0,...t},children:[e&&c.jsx(I.ListItem,{sx:{padding:ve,display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"8px","&:hover":{cursor:"default",backgroundColor:"unset",color:"unset"},...i},children:e}),A.map(a=>c.jsx(I.ListItem,{onClick:a.onClick,sx:{borderRadius:vA,padding:ve,transition:tt,"&:hover":{cursor:"pointer",backgroundColor:s.action.hover},...o},children:c.jsx(Tn,{content:a.content,icon:a.icon,sx:r})},a.content))]})},k5=({total:e=0,page:A=aa.page,take:t=aa.take,openRowsPerPage:o=!0,onChange:r,sx:i={}})=>{const s=Math.ceil(e/t),a=[10,20,30,50],l=a.includes(Number(t))?Number(t):10,{palette:d}=I.useTheme(),u=f=>{const h=Number(f.target.value);r({page:1,take:h})},p=(f,h)=>{r({page:h,take:t})};return c.jsxs(Xe,{gap:.5,sx:{ml:"auto",...i},children:[c.jsx(I.Pagination,{count:s,page:A,showFirstButton:!0,showLastButton:!0,onChange:p,size:"medium",variant:"outlined",shape:"rounded",sx:{"& .MuiPagination-ul":{gap:.5},"& .MuiPaginationItem-root":{borderRadius:QA,m:0},"& .MuiPaginationItem-root.Mui-disabled":{opacity:.5,pointerEvents:"none"},"& .MuiPaginationItem-root.Mui-selected":{background:d.primary.main,color:"white"}}}),o&&c.jsx(Xe,{children:c.jsx(I.FormControl,{size:"small",children:c.jsx(qn,{value:l,onChange:f=>u(f),options:a.map(f=>({value:f,label:`${f} / trang`})),sx:{"& .MuiOutlinedInput-root":{borderRadius:"0px !important"}}})})})]})},xk=({name:e,direction:A="row",label:t,disabled:o,iconLabel:r="event_list",defaultValue:i,value:s,onChange:a,children:l,required:d=!1,sx:u={}})=>{const p=f=>{a&&a({target:{name:e,value:f.target.value||void 0}})};return c.jsxs(I.FormControl,{disabled:o,sx:{gap:ve},onChange:p,children:[t&&c.jsx(I.InputLabel,{shrink:!0,required:d,sx:{transform:"translate(0px , -9px) scale(0.75)",zIndex:2,display:"flex"},children:c.jsxs(pp,{children:[c.jsx(ye,{icon:r,sx:{fontSize:Ja.FONT_SIZE_LABEL}}),t]})}),c.jsx(I.RadioGroup,{name:e,defaultValue:i,value:s,sx:{flexDirection:A,paddingTop:t?"calc(8.5px + 1.5px)":0,gap:TA,...u},children:l})]})},vk=({name:e,label:A,...t})=>c.jsx(I.FormControlLabel,{name:e,label:A,sx:{alignItems:"center",mr:0},control:c.jsx(I.Radio,{...t,sx:{paddingTop:0,paddingBottom:0,paddingRight:ve,marginLeft:"2px","&:hover":{backgroundColor:"unset"},"& .MuiSvgIcon-root":{fontSize:"18px"}}})}),qk=({label:e,value:A,children:t,sx:o,textTransform:r="uppercase"})=>{const{palette:i}=I.useTheme();return c.jsxs(Xe,{sx:{gap:1,...o},children:[c.jsx(I.Typography,{variant:"subtitle2",sx:{...Me.textMd.semiBold,textTransform:r,color:i.primary.main},children:e||t}),A!==void 0&&c.jsx(I.Typography,{variant:"subtitle2",sx:{...Me.textMd.semiBold,textTransform:r,color:i.primary.main},children:A})]})},P5=({name:e,value:A=!1,onChange:t})=>{const{palette:o}=I.useTheme(),r=()=>{t&&t({target:{name:e,value:!A}})};return c.jsx(At.MotionConfig,{transition:{duration:.2,ease:"easeOut"},children:c.jsx(At.motion.div,{className:"switch",initial:!1,animate:{backgroundColor:A?o.primary.main:o.text.disabled},onClick:r,style:{display:"flex",justifyContent:A?"flex-end":"flex-start",alignItems:"center",width:"30px",height:"14px",padding:"3px",borderRadius:"10px",boxSizing:"content-box",cursor:"pointer"},children:c.jsx(At.motion.div,{layout:!0,className:"handle",style:{background:"#fdfdfd",aspectRatio:1,height:"100%",borderRadius:"50%"}})})})},wk=({name:e,content:A,value:t=!1,onChange:o,sx:r={}})=>c.jsxs(Xe,{sx:{gap:ve,...r},children:[c.jsx(I.Typography,{children:A}),c.jsx(P5,{name:e,value:t,onChange:o})]});var Qc=(e=>(e.DISABLED_GET_ROW_MENU="DISABLED_GET_ROW_MENU",e.HISTORY_GET_ROW_MENU="HISTORY_GET_ROW_MENU",e.INFO="INFO",e.COPY="COPY",e.DELETE="DELETE",e.UPDATE="UPDATE",e.SELECT="SELECT",e.COLLAPSE="COLLAPSE",e.DISABLED_ALL_ACTIONS="DISABLED_ALL_ACTIONS",e.DISABLED_ROW="DISABLED_ROW",e.DISABLED_CHECKBOX="DISABLED_CHECKBOX",e))(Qc||{}),Rr=(e=>(e.TOTAL="TOTAL",e.TOTAL_INCOME="TOTAL_INCOME",e))(Rr||{}),sn=(e=>(e.ASC="asc",e.DESC="desc",e))(sn||{}),Qn=(e=>(e.TEXT="text",e.NUMBER="number",e.DATE="date",e.BOOLEAN="boolean",e))(Qn||{}),Pt=(e=>(e.INCLUDE="include",e.EXCLUDE="exclude",e))(Pt||{});const Vo=`1px solid ${Ve[300]}`,M5=80,g2=Object.keys(Qc).reduce((e,A)=>(e[A]=!1,e),{}),R5=e=>e?Array.isArray(e)?[...e]:[e]:[],go=(...e)=>e.flatMap(A=>R5(A)),N5=(e,A,t)=>go({width:`${e.width}px !important`,minWidth:`${e.width}px !important`,maxWidth:`${e.width}px !important`,padding:ve,borderRadius:"0 !important",color:t?Ve[500]:"inherit",...e.stickyCss?{position:"sticky",backgroundColor:hA[50],...e.stickyCss}:{}},e.sx,e.cellSx),j5=(e,A,t,o,r)=>({cursor:e?"pointer":"default","&:hover .MuiTableCell-root":{backgroundColor:"inherit !important"},...o[t]?o[t]:{},...r===t?{background:`linear-gradient(270deg, ${Ze[200]+xn[90]}, ${qo[100]}, ${hA[50]})`,backgroundSize:"600% 600%",animation:"loading-gradient-row-table 1.5s ease infinite"}:{}});function Sk({row:e,index:A,rowId:t,onSelectRow:o,onDeleteRow:r,onInfoRow:i,onCopyRow:s,onHistoryRow:a,onUpdateRow:l,getActionIcon:d,getRowMenu:u,onDisabled:p}){const[f,h]=F.useState(!1),m=t;if(m===Rr.TOTAL||m===Rr.TOTAL_INCOME)return null;const g=p?p(e,A):{...g2},C=g.DISABLED_ROW||g.DISABLED_ALL_ACTIONS,b=()=>u?u(e,A).map(q=>({...q,onClick:()=>{q.onClick(),h(!1)}})):[];return c.jsxs(c.Fragment,{children:[o&&c.jsx(ye,{icon:"remove_red_eye",onClick:q=>{q.stopPropagation(),o(e,A)},disabled:C||g.SELECT}),r&&c.jsx(ye,{icon:"delete",onClick:q=>{q.stopPropagation(),r(e,A)},sx:{color:C||g.DELETE?Ve[500]:xt[500]},disabled:C||g.DELETE}),i&&c.jsx(ye,{icon:"view_cozy",onClick:q=>{q.stopPropagation(),i(e,A)},disabled:C||g.INFO}),s&&c.jsx(ye,{icon:d&&d(e,A,"COPY")||"content_copy",onClick:q=>{q.stopPropagation(),s(e,A),window.scrollTo({top:0,behavior:"smooth"})},disabled:C||g.COPY}),a&&c.jsx(ye,{icon:"history",onClick:q=>{q.stopPropagation(),a(e,A)},disabled:C||g.HISTORY_GET_ROW_MENU}),l&&c.jsx(ye,{icon:d&&d(e,A,"UPDATE")||"settings",onClick:q=>{q.stopPropagation(),l(e,A),window.scrollTo({top:0,behavior:"smooth"})},disabled:C||g.UPDATE}),u&&(g.DISABLED_GET_ROW_MENU?c.jsx(ye,{icon:"open_in_browser",disabled:C||g.DISABLED_GET_ROW_MENU,onClick:q=>q.stopPropagation()}):c.jsx(an,{style:{cursor:"pointer",display:"flex",alignItems:"center"},placement:"bottom-end",open:f,onOpen:()=>h(!0),onClose:()=>h(!1),content:c.jsx(O5,{list:b()}),children:c.jsx(ye,{icon:"open_in_browser",onClick:q=>q.stopPropagation()})}))]})}function Ek({columns:e,row:A,indexRow:t,indexLoadingRow:o,rowSx:r={},getRowId:i,onClickRow:s,onDisabled:a,onClickSelectRow:l=!1,onSelectRowById:d,enableTree:u=!1,rowLevels:p={},rangeSelection:f}){const{palette:h}=I.useTheme(),m=i(A),g=a?a(A,t):{...g2},C=F.useCallback((w,y)=>{const S=y||"";return c.jsxs(GA,{sx:{color:Cr[950]},children:[w,c.jsx(ye,{icon:"content_copy",sx:{color:Cr[950],fontSize:so.medium},onClick:v=>{v.stopPropagation(),S&&navigator.clipboard.writeText(S)}})]})},[]),b=!!(l&&d),q=!!(s||b);return c.jsx(I.Fade,{in:!0,timeout:t*120,children:c.jsx(I.TableRow,{hover:!0,tabIndex:-1,onClick:()=>{s==null||s(A,t),b&&(d==null||d(m))},sx:{...j5(q,h,t,r,o),...m===Rr.TOTAL?{backgroundColor:Ze[50],"& .MuiTableCell-root":{backgroundColor:Ze[50]},"& *":{fontWeight:"bold"}}:{},...m===Rr.TOTAL_INCOME?{backgroundColor:Ve[300],"& .MuiTableCell-root":{backgroundColor:Ve[300]},"& *":{fontWeight:"bold"}}:{},'& .MuiTableCell-root[aria-selected="true"]':{backgroundColor:`${Ze[100]} !important`,boxShadow:`inset 0 0 0 1px ${Ze[300]}`}},children:e.map((w,y)=>{const S=u?p[m]??0:0,v=u?e.findIndex(M=>M.id!=="treeToggle"):-1,T=u&&y===v&&w.id!=="treeToggle";return c.jsx(I.TableCell,{"data-table-column-id":w.id,...f==null?void 0:f.getCellProps(t,w.id),align:w.align,sx:go(N5(w,h,g.DISABLED_ROW),{overflowWrap:"anywhere"},T?{pl:M=>`calc(${M.spacing(1)} + ${S*16}px)`}:void 0),onClick:w.id==="actions"||w.id==="selectCheckbox"?M=>{M.stopPropagation()}:void 0,children:(()=>{const M=A[w.id],D=Gn(w.render?w.render(A,t):M);if(!w.copyable)return D;const B=typeof w.copyable=="object"&&w.copyable.getValue?String(w.copyable.getValue(A,t)||""):String(M||"");return C(D,B)})()},w.id)})})})}const Ik={visibleRows:[],rowLevels:{},hasChildrenById:{}},Tk=({rows:e,enableTree:A,expandedRowIds:t,getRowId:o,getChildren:r})=>{if(!A)return{...Ik,visibleRows:e};const i={},s={},a=[],l=(d,u)=>{d.forEach(p=>{const f=o(p),h=r(p);i[f]=u,s[f]=h.length>0,a.push(p),h.length>0&&t.has(f)&&l(h,u+1)})};return l(e,0),{visibleRows:a,rowLevels:i,hasChildrenById:s}},Dk=({row:e,getRowId:A,rowLevels:t,hasChildrenById:o,expandedRowIds:r,onToggle:i})=>{const s=A(e),a=t[s]??0,l=o[s],d=r.has(s),u=16,p=Math.max(a*u+14,14),f=a*u+7;return c.jsxs(Xe,{alignItems:"stretch",sx:{cursor:l?"pointer":"default",minHeight:"100%"},onClick:h=>{l&&(h.stopPropagation(),i(s))},children:[c.jsx(I.Stack,{sx:{position:"relative",width:p,flexShrink:0,alignSelf:"stretch",minHeight:"100%"},children:a>0&&c.jsxs(c.Fragment,{children:[c.jsx(I.Stack,{sx:{position:"absolute",left:`${f}px`,top:"-1px",bottom:"50%",borderLeft:`1px solid ${Ve[300]}`}}),c.jsx(I.Stack,{sx:{position:"absolute",left:`${f}px`,top:"50%",width:`${u/2}px`,borderBottom:`1px solid ${Ve[300]}`,transform:"translateY(-50%)"}})]})}),c.jsx(Xe,{sx:{minHeight:"100%"},children:l?c.jsx(ye,{icon:d?"expand_more":"chevron_right"}):c.jsx(I.Stack,{sx:{width:8,height:8,borderRadius:"50%",bgcolor:Ve[500]}})})]})},Bk=({children:e,onScroll:A})=>c.jsx(I.Stack,{sx:{overflowY:A?"hidden":"auto",flex:1,...A?{minHeight:0}:{}},children:c.jsx(I.TableContainer,{onScroll:A,sx:{maxHeight:"100%",overflow:"auto",...A?{flex:1,minHeight:0}:{}},children:e})});var RA=(e=>(e.NONE="none",e.LEFT="left",e.RIGHT="right",e))(RA||{});const Nr=160,Ok=60,kk=1200,U1=10,Pk=6,Fa='input,textarea,select,button,a,[role="button"],[contenteditable]:not([contenteditable="false"]),[data-table-no-range],.material-symbols-rounded',F5=100,jr=50,z1=1e3,Mk=24,Rk=12,Nk="sevago.table.v1",vi=new Set(["actions","selectCheckbox","treeToggle","collapseToggle"]),L5={allView:"Tất cả",viewMode:"Chế độ xem",defaultView:"Mặc định",unsavedChanges:"Có thay đổi chưa lưu trong view",undoChanges:"Hoàn tác",save:"Lưu",cancel:"Hủy",copy:"Sao chép",copyError:"Không thể sao chép. Hãy chọn cột và nhấn Ctrl/Cmd+C.",hideColumn:"Ẩn cột",restoreColumns:"Hiển thị lại cột",columns:"Cột và view",close:"Đóng",show:"Hiển thị",moveLeft:"Chuyển sang trái",moveRight:"Chuyển sang phải",pin:"Ghim cột",unpinned:"Không ghim",pinLeft:"Ghim trái",pinRight:"Ghim phải",resize:"Đổi độ rộng",reset:"Khôi phục mặc định",views:"view đã lưu",viewName:"Tên view",saveView:"Lưu cấu hình hiện tại thành view mới",updateView:"Cập nhật view",renameView:"Đổi tên view",deleteView:"Xóa view",currentLayout:"view hiện tại",modified:"Đã thay đổi",localPersistence:"Tự động lưu cho người dùng này trong trình duyệt hiện tại.",sessionOnly:"Chưa bật lưu view. Truyền tableId và userId để ghi nhớ khi mở lại.",storageError:"Không đọc hoặc lưu được view trong trình duyệt. Bạn vẫn có thể tiếp tục dùng bảng.",rangeHint:"Bấm header chọn cột; kéo header hoặc ô để chọn vùng, kéo icon tay nắm để đổi thứ tự cột. Ctrl+C để sao chép sang Excel. Esc để bỏ chọn.",selectedCells:"Số ô đã chọn",viewNameRequired:"Vui lòng nhập tên view.",viewNameTooLong:"Tên view vượt quá độ dài cho phép."},Q5=e=>dt.object({name:dt.string().trim().required(e.viewNameRequired).max(jr,e.viewNameTooLong)}),V1=dt.object({id:dt.string().required(),width:dt.number().test("finite","Độ rộng cột không hợp lệ",e=>e===void 0||Number.isFinite(e)).optional(),hidden:dt.boolean().optional(),pin:dt.mixed().oneOf(Object.values(RA)).optional()}),jk=dt.object({version:dt.mixed().oneOf([1]).required(),columns:dt.array().of(V1).max(z1).required(),views:dt.array().of(dt.object({id:dt.string().required(),name:dt.string().max(jr).required(),columns:dt.array().of(V1).max(z1).required()})).max(F5).required(),activeViewId:dt.string().optional()});function Fk(e){const A=F.useRef(e);A.current=e;const t=F.useRef(void 0),[o,r]=F.useState(),i=!!e.onColumnMove;return F.useEffect(()=>{if(!i)return;const s=()=>{t.current=void 0,r(void 0)},a=d=>{var q,w;const u=t.current;if(!u||u.pointerId!==d.pointerId)return;if(!(d.buttons&1)){s();return}const p=Math.abs(d.clientX-u.x),f=Math.abs(d.clientY-u.y);if(u.mode==="pending"&&Math.max(p,f)>=Pk&&(u.mode="move"),u.mode!=="move")return;const h=(q=document.elementFromPoint(d.clientX,d.clientY))==null?void 0:q.closest("th[data-table-column-id]"),m=(h==null?void 0:h.closest("table"))===u.table?h==null?void 0:h.dataset.tableColumnId:void 0,g=(w=A.current.layoutController)==null?void 0:w.columnControls,C=g==null?void 0:g.find(y=>y.id===u.id),b=g==null?void 0:g.find(y=>y.id===m);u.targetId=b&&b.pin===(C==null?void 0:C.pin)&&m!==u.id?m:void 0,r(u.targetId)},l=d=>{var p,f;const u=t.current;!u||u.pointerId!==d.pointerId||(u.mode==="move"&&u.targetId&&((f=(p=A.current).onColumnMove)==null||f.call(p,u.id,u.targetId)),s())};return window.addEventListener("pointermove",a),window.addEventListener("pointerup",l),window.addEventListener("pointercancel",s),window.addEventListener("blur",s),()=>{window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",l),window.removeEventListener("pointercancel",s),window.removeEventListener("blur",s)}},[i]),{dropColumnId:o,onPointerDown:(s,a)=>{if(!e.onColumnMove||s.button!==0)return;s.stopPropagation();const l=s.currentTarget.closest("table");l&&(s.preventDefault(),t.current={id:a,pointerId:s.pointerId,x:s.clientX,y:s.clientY,table:l,mode:"pending"})}}}const M2=(e,A)=>({id:e.id,label:e.label,filter:e.filter,width:e.width,align:e.align,alignHead:e.alignHead,sx:go(e.sx,e.headSx),stickyCss:e.stickyCss,rowSpan:A,column:e}),Lk=(e,A)=>{var s,a,l,d,u,p;if(!(A!=null&&A.length))return[e.map(f=>M2(f))];const t=new Map;A.forEach(f=>{f.columnIds.forEach(h=>{t.set(h,f)})});const o=[],r=[];let i=0;for(;i<e.length;){const f=e[i],h=t.get(f.id);if(!h){o.push(M2(f,2)),i+=1;continue}let m=1;for(;i+m<e.length&&((s=t.get(e[i+m].id))==null?void 0:s.id)===h.id&&((a=e[i+m].stickyCss)==null?void 0:a.left)!=null==(((l=f.stickyCss)==null?void 0:l.left)!=null)&&((d=e[i+m].stickyCss)==null?void 0:d.right)!=null==(((u=f.stickyCss)==null?void 0:u.right)!=null);)m+=1;o.push({id:`${h.id}-${i}`,label:h.label,alignHead:h.align??"center",sx:h.sx,colSpan:m,stickyCss:f.stickyCss?{...f.stickyCss,right:(p=e[i+m-1].stickyCss)==null?void 0:p.right}:void 0});for(let g=0;g<m;g+=1)r.push(M2(e[i+g]));i+=m}return r.length?[o,r]:[e.map(f=>M2(f))]},qi=e=>e.configurable!==!1&&!vi.has(e.id),Qk=(e,A)=>{const t=Math.max(1,e.minWidth??Ok),o=Math.max(t,e.maxWidth??kk);return Math.round(Math.min(o,Math.max(t,Number.isFinite(A)?A:Nr)))},Hk=(e,A)=>`${Nk}:${encodeURIComponent(A)}:${encodeURIComponent(e)}`,oo=(e,A=[])=>{const t=new Map(e.map(a=>[a.id,a])),o=new Set,r=[];[...A,...e.map(a=>({id:a.id}))].forEach(a=>{var u,p;const l=t.get(a.id);if(!l||o.has(a.id))return;o.add(a.id);const d=qi(l);r.push({id:l.id,width:d?Qk(l,a.width??l.width??Nr):l.width,hidden:d&&a.hidden===!0,pin:a.pin??(((u=l.stickyCss)==null?void 0:u.left)!=null?RA.LEFT:((p=l.stickyCss)==null?void 0:p.right)!=null?RA.RIGHT:RA.NONE)})});const s=r.filter(a=>qi(t.get(a.id)));return s.length&&s.every(a=>a.hidden)&&(s[0].hidden=!1),[...r.filter(a=>a.pin===RA.LEFT),...r.filter(a=>a.pin!==RA.LEFT&&a.pin!==RA.RIGHT),...r.filter(a=>a.pin===RA.RIGHT)]},Uk=(e,A)=>{const t=new Map(e.map(d=>[d.id,d])),o=oo(e,A).filter(d=>!d.hidden),r=[...o.filter(d=>vi.has(d.id)&&d.id!=="actions"),...o.filter(d=>!vi.has(d.id)),...o.filter(d=>d.id==="actions")],i=[...r.filter(d=>d.pin===RA.LEFT),...r.filter(d=>d.pin!==RA.LEFT&&d.pin!==RA.RIGHT),...r.filter(d=>d.pin===RA.RIGHT)];let s=0,a=0;const l=new Map;return[...i].reverse().forEach(d=>{d.pin===RA.RIGHT&&(l.set(d.id,a),a+=d.width??Nr)}),i.map(d=>{const u=t.get(d.id),p={...u.stickyCss};delete p.left,delete p.right;const f=d.pin===RA.LEFT||d.pin===RA.RIGHT?{...p,[d.pin]:d.pin===RA.LEFT?s:l.get(d.id),zIndex:1.5}:void 0;return d.pin===RA.LEFT&&(s+=d.width??Nr),{...u,width:d.width,stickyCss:f}})},W1=e=>jk.validateSync(JSON.parse(e),{strict:!0}),G1={padding:ve},zk={open:"Bộ lọc",apply:"Áp dụng",clear:"Xóa bộ lọc khỏi cột",cancel:"Hủy",emptyOptions:"Không có giá trị phù hợp",loading:"Đang tải...",loadMore:"Tải thêm",searchLoaded:"Tìm trong các giá trị đã tải. Tải thêm để tìm các giá trị khác.",values:"Lọc theo giá trị",search:"Tìm kiếm giá trị",selectAll:"Chọn tất cả",deselectAll:"Bỏ chọn tất cả",selectLoaded:"Chọn các giá trị đã tải",deselectLoaded:"Bỏ chọn các giá trị đã tải",blanks:"(Trống)",sortAscending:"Sắp xếp tăng dần",sortDescending:"Sắp xếp giảm dần",sortTextAscending:"Sắp xếp từ A đến Z",sortTextDescending:"Sắp xếp từ Z đến A",sortNumberAscending:"Sắp xếp từ nhỏ đến lớn",sortNumberDescending:"Sắp xếp từ lớn đến nhỏ",sortDateAscending:"Sắp xếp từ cũ đến mới",sortDateDescending:"Sắp xếp từ mới đến cũ",clearSort:"Xóa sắp xếp"},Vk=(e,A=Qn.TEXT)=>{const t={...zk,...e},o={[Qn.TEXT]:[t.sortTextAscending,t.sortTextDescending],[Qn.NUMBER]:[t.sortNumberAscending,t.sortNumberDescending],[Qn.DATE]:[t.sortDateAscending,t.sortDateDescending],[Qn.BOOLEAN]:[t.sortAscending,t.sortDescending]};return{...t,sortAscending:(e==null?void 0:e.sortAscending)??o[A][0],sortDescending:(e==null?void 0:e.sortDescending)??o[A][1]}},Y1=(e,A,t)=>{const o=(e==null?void 0:e.mode)??Pt.EXCLUDE,r=(e==null?void 0:e.values)??[],i=o===Pt.INCLUDE===t?[...r,...A.filter(s=>!r.includes(s))]:r.filter(s=>!A.includes(s));return o===Pt.EXCLUDE&&!i.length?void 0:{mode:o,values:i}},m2=({content:e,contentHref:A,href:t,type:o="info"})=>{const{palette:r}=I.useTheme(),i={info:{icon:"error",title:"Info",color:r.success.dark},recommend:{icon:"gpp_maybe",title:"Recommend",color:r.info.dark},warning:{icon:"report",title:"Warning",color:r.warning.dark},error:{icon:"emergency_home",title:"Error",color:r.error.dark}};return c.jsxs(I.Stack,{sx:{gap:1,borderRadius:vA,borderColor:i[o].color,borderStyle:"solid",borderWidth:"1px 1px 1px 3px",padding:1.5},children:[c.jsxs(Xe,{sx:{gap:yA},children:[c.jsx(ye,{icon:i[o].icon,sx:{color:i[o].color}}),c.jsx(I.Typography,{sx:{color:i[o].color},variant:"body2",children:i[o].title})]}),c.jsxs(I.Typography,{sx:{color:i[o].color},children:[e,t&&A&&c.jsxs(F.Fragment,{children:[" ",c.jsx(Eo,{href:t,children:A})]})]})]})},Wk=I.createFilterOptions();function Gk({config:e,selection:A,labels:t,onChange:o}){const[r,i]=F.useState(""),s=e.optionsComplete===!1&&e.allowPartialSelection,a=e.options??[],l=Wk(a,{inputValue:r,getOptionLabel:f=>f.value?f.label:t.blanks}),d=e.disabled||e.loading,u=f=>!A||(A.mode===Pt.INCLUDE?A.values.includes(f):!A.values.includes(f)),p=f=>{if(!r&&e.optionsComplete!==!1&&!a.some(m=>m.disabled)){o(f?void 0:{mode:Pt.INCLUDE,values:[]});return}const h=l.filter(m=>!m.disabled).map(m=>m.value);o(Y1(A,h,f))};return c.jsxs(I.Stack,{gap:ve,children:[c.jsxs(GA,{children:[c.jsx(sA,{variant:"text",size:"small",content:s?t.selectLoaded:t.selectAll,disabled:d||!l.length,onClick:()=>p(!0)}),c.jsx(sA,{variant:"text",size:"small",content:s?t.deselectLoaded:t.deselectAll,disabled:d||!l.length,onClick:()=>p(!1)})]}),c.jsx(Is,{value:r,placeholder:e.placeholder??t.search,disabled:e.disabled,slotProps:{htmlInput:{"aria-label":t.search}},onChange:f=>i(f.target.value)}),s&&c.jsx(m2,{content:t.searchLoaded}),e.loading&&c.jsx(I.LinearProgress,{"aria-label":t.loading}),c.jsxs(I.Stack,{role:"group","aria-label":t.values,sx:{maxHeight:224,overflowY:"auto"},gap:ve,children:[l.map(f=>c.jsxs(GA,{children:[c.jsx(F0,{label:f.value?f.label:t.blanks,checked:u(f.value),disabled:d||f.disabled,onChange:(h,m)=>o(Y1(A,[f.value],m))}),e.optionsComplete!==!1&&f.count!==void 0&&c.jsx(xA,{content:`(${M3(f.count)})`,sx:{color:Je[500]}})]},f.value)),!l.length&&!e.loading&&c.jsx(xA,{content:t.emptyOptions})]})]})}function Yk({config:e,labels:A,rule:t,onApply:o,onClear:r,onCancel:i}){const s=l=>e.optionsComplete!==!1||!l.selection||e.allowPartialSelection&&l.selection.mode===Pt.INCLUDE,a=Si.useFormik({initialValues:e.allowPartialSelection&&e.optionsComplete===!1&&!t.selection?{selection:{mode:Pt.INCLUDE,values:[]}}:t,onSubmit:l=>{e.disabled||e.loading||e.errorText||!s(l)||o(l)}});return c.jsxs(c.Fragment,{children:[c.jsxs(I.Stack,{sx:{overflowY:"auto",minHeight:0,...G1},children:[e.render?e.render({rule:a.values,onRuleChange:l=>a.setValues(l),apply:()=>a.handleSubmit(),clear:r}):c.jsx(Gk,{config:e,labels:A,selection:a.values.selection,onChange:l=>a.setFieldValue("selection",l)}),(e.helperText||e.errorText)&&c.jsx(I.Stack,{role:e.errorText?"alert":void 0,sx:{color:e.errorText?xt[500]:Ve[700]},children:e.errorText||e.helperText})]}),c.jsx(I.Divider,{}),c.jsxs(Ui,{gap:ve,sx:{...G1,flexShrink:0},children:[c.jsx(sA,{variant:"outlined",content:A.cancel,onClick:i}),c.jsx(sA,{content:A.apply,disabled:e.disabled||e.loading||!!e.errorText||!s(a.values),onClick:l=>{l.preventDefault(),a.handleSubmit()}})]})]})}function Kk({columnId:e,columnLabel:A,config:t,rule:o,sort:r,labels:i,onRuleChange:s,onSortChange:a,onOpenChange:l}){const[d,u]=F.useState(),p=F.useId(),f=t.key??e,h=Vk({...i,...t.labels},t.dataType),m=!!(o!=null&&o.selection),g=!!s,C=(r==null?void 0:r.key)===f,b=()=>{u(void 0),l==null||l(f,!1)},q=y=>{t.disabled||(s==null||s(f,y!=null&&y.selection?y:void 0),b())},w=y=>{a==null||a(y?{key:f,direction:y}:void 0),b()};return c.jsxs(I.Stack,{onClick:y=>y.stopPropagation(),children:[c.jsx(I.IconButton,{size:"small",sx:{color:m||C?Ze[500]:Ve[700],"&:hover":{backgroundColor:Ze[50]},"&.Mui-disabled":{color:Ve[500]}},disabled:t.disabled,"aria-label":`${h.open}: ${A??e}`,"aria-haspopup":"dialog","aria-expanded":!!d,"aria-controls":d?p:void 0,onClick:y=>{u(y.currentTarget),l==null||l(f,!0)},children:c.jsx(ye,{icon:m?"filter_alt":"filter_list",fill:m?1:0})}),c.jsxs(I.Popover,{id:p,open:!!d,anchorEl:d,onClose:b,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{role:"dialog","aria-label":`${h.open}: ${A??e}`,sx:{width:320,maxWidth:"90vw",maxHeight:"90vh",overflow:"hidden",display:"flex",flexDirection:"column",borderRadius:vA,backgroundColor:hA[50],color:Ve[900]}}},children:[c.jsxs(I.MenuList,{dense:!0,sx:{"& .MuiMenuItem-root:hover":{backgroundColor:qo[100]},"& .MuiMenuItem-root.Mui-selected":{backgroundColor:Ze[50],color:Ze[500]},"& .MuiMenuItem-root.Mui-selected:hover":{backgroundColor:Ze[100]},"& .MuiMenuItem-root.Mui-disabled":{color:Ve[700],opacity:1}},children:[t.sortable!==!1&&a&&[c.jsx(I.MenuItem,{disabled:t.disabled,selected:C&&(r==null?void 0:r.direction)===sn.ASC,onClick:()=>w(sn.ASC),children:c.jsxs(Xe,{gap:ve,children:[c.jsx(ye,{icon:"arrow_upward"}),c.jsx(xA,{content:h.sortAscending})]})},"ascending"),c.jsx(I.MenuItem,{disabled:t.disabled,selected:C&&(r==null?void 0:r.direction)===sn.DESC,onClick:()=>w(sn.DESC),children:c.jsxs(Xe,{gap:ve,children:[c.jsx(ye,{icon:"arrow_downward"}),c.jsx(xA,{content:h.sortDescending})]})},"descending")],C&&a&&t.sortable!==!1&&c.jsx(I.MenuItem,{disabled:t.disabled,onClick:()=>w(),children:c.jsx(xA,{content:h.clearSort})}),g&&c.jsx(I.MenuItem,{disabled:t.disabled||!m,onClick:()=>q(),children:c.jsxs(Xe,{gap:ve,children:[c.jsx(ye,{icon:"filter_alt_off"}),c.jsx(xA,{content:h.clear})]})})]}),c.jsx(I.Divider,{}),d&&g&&c.jsx(Yk,{config:t,labels:h,rule:o??{},onApply:q,onClear:()=>q(),onCancel:b})]})]})}function Xk({columnId:e,name:A,width:t,label:o,onResize:r}){const i=F.useRef(void 0);return c.jsx(I.Box,{"data-table-no-range":!0,"data-table-copy-ignore":!0,role:"separator","aria-orientation":"vertical","aria-label":`${o}: ${A}`,"aria-valuenow":t,tabIndex:0,draggable:!1,onDragStart:s=>{s.preventDefault(),s.stopPropagation()},onPointerDown:s=>{var a;s.button===0&&(s.preventDefault(),s.stopPropagation(),i.current={x:s.clientX,width:((a=s.currentTarget.parentElement)==null?void 0:a.getBoundingClientRect().width)??t??0},s.currentTarget.setPointerCapture(s.pointerId))},onPointerMove:s=>{i.current&&r(e,i.current.width+s.clientX-i.current.x)},onPointerUp:s=>{i.current=void 0,s.currentTarget.hasPointerCapture(s.pointerId)&&s.currentTarget.releasePointerCapture(s.pointerId)},onPointerCancel:()=>{i.current=void 0},onClick:s=>s.stopPropagation(),onKeyDown:s=>{(s.key==="ArrowLeft"||s.key==="ArrowRight")&&(s.preventDefault(),s.stopPropagation(),r(e,(t??0)+(s.key==="ArrowRight"?U1:-U1)))},sx:{position:"absolute",right:0,top:0,bottom:0,width:ve,cursor:"col-resize",touchAction:"none","&:hover, &:focus-visible":{backgroundColor:Ze[200]}}})}function Jk({context:e,onClose:A,controller:t,copyColumn:o,labels:r}){const[i,s]=F.useState(!1),[a,l]=F.useState(!1),d=t==null?void 0:t.columnControls.find(p=>p.id===e.id),u=p=>{t==null||t.setPin(e.id,(d==null?void 0:d.pin)===p?RA.NONE:p),A()};return c.jsx(c.Fragment,{children:c.jsxs(I.Menu,{open:!0,anchorReference:"anchorPosition",anchorPosition:{top:e.y,left:e.x},onClose:A,children:[c.jsxs(I.MenuItem,{disabled:!o||a,onClick:async()=>{l(!0);try{await(o==null?void 0:o(e.id,e.table)),A()}catch{s(!0)}finally{l(!1)}},children:[c.jsx(I.ListItemIcon,{children:c.jsx(ye,{icon:"content_copy"})}),r.copy]}),t&&c.jsx(I.Divider,{}),t&&c.jsxs(I.MenuItem,{disabled:!(d!=null&&d.canHide),onClick:()=>{t.setVisible(e.id,!1),A()},children:[c.jsx(I.ListItemIcon,{children:c.jsx(ye,{icon:"visibility_off"})}),r.hideColumn]}),t&&c.jsxs(I.MenuItem,{selected:(d==null?void 0:d.pin)===RA.LEFT,onClick:()=>u(RA.LEFT),children:[c.jsx(I.ListItemIcon,{children:c.jsx(ye,{icon:"first_page"})}),r.pinLeft]}),t&&c.jsxs(I.MenuItem,{selected:(d==null?void 0:d.pin)===RA.RIGHT,onClick:()=>u(RA.RIGHT),children:[c.jsx(I.ListItemIcon,{children:c.jsx(ye,{icon:"last_page"})}),r.pinRight]}),i&&c.jsx(I.MenuItem,{role:"presentation",tabIndex:-1,children:c.jsx(I.Stack,{role:"alert",children:c.jsx(m2,{type:"error",content:r.copyError})})})]})})}function Zk({columnId:e,controller:A,firstColumn:t,lastColumn:o}){const{columnControls:r,labels:i}=A,s=r.findIndex(u=>u.id===e);if(s<0)return null;const a=[];for(let u=s-1;u>=0&&r[u].hidden;u--)a.unshift(r[u]);const l=r.slice(s+1),d=l.length>0&&l.every(u=>u.hidden)?l:[];return c.jsx(c.Fragment,{children:[a,d].map((u,p)=>u.length>0&&c.jsx(I.Box,{"data-table-no-range":!0,"data-table-copy-ignore":!0,sx:{position:"absolute",[p===0?"left":"right"]:0,top:"50%",transform:`translate(${p===0?t?"0":"-50%":o?"0":"50%"}, -50%)`,zIndex:5,width:TA,height:at.small},children:c.jsx(I.Tooltip,{title:`${i.restoreColumns}: ${u.map(f=>f.label).join(", ")}`,children:c.jsx(qt,{size:"small",icon:"unfold_more","aria-label":`${i.restoreColumns}: ${u.map(f=>f.label).join(", ")}`,onClick:f=>{f.stopPropagation();const h=new Set(u.map(m=>m.id));A.changeLayout(A.layout.map(m=>h.has(m.id)?{...m,hidden:!1}:m))},sx:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%) rotate(90deg)",width:at.small,height:TA,padding:0,minWidth:0,backgroundColor:"background.paper",border:1,borderColor:"divider"}})})},p))})}const K1=44;function _k({columns:e,headerGroups:A,filterLabels:t,filterRules:o,onFilterRuleChange:r,columnSort:i,onColumnSortChange:s,onFilterOpenChange:a,stickyHeader:l=!0,onColumnResize:d,onColumnMove:u,layoutLabels:p=L5,rangeSelection:f,onCopyColumn:h,layoutController:m}){const[g,C]=F.useState(),b=Fk({onColumnMove:u,layoutController:m}),q=F.useMemo(()=>Lk(e,A),[e,A]),w=q.length>1;return c.jsxs(c.Fragment,{children:[c.jsx(I.TableHead,{sx:{'& th[aria-selected="true"]':{backgroundColor:`${Ze[100]} !important`}},children:q.map((y,S)=>c.jsx(I.TableRow,{children:y.map(v=>{var D,B,k,x;const T=v.column&&qi(v.column),M=typeof v.label=="string"?v.label:v.id;return c.jsxs(I.TableCell,{"data-table-column-id":(D=v.column)==null?void 0:D.id,...v.column?f==null?void 0:f.getCellProps(-1,v.id):{},onContextMenu:v.column&&(m||f)?O=>{if(!T)return;const P=O.currentTarget.closest("table");P&&(O.preventDefault(),f==null||f.selectColumn(v.id,P),C({id:v.id,x:O.clientX,y:O.clientY,table:P}))}:void 0,align:v.align,colSpan:v.colSpan,rowSpan:v.rowSpan,sx:go({...v.width!=null?{width:`${v.width}px !important`,minWidth:`${v.width}px !important`,maxWidth:`${v.width}px !important`}:{},height:w?K1:void 0,position:l?void 0:"relative",fontWeight:550,userSelect:T&&u?"none":void 0,boxShadow:b.dropColumnId===v.id?`inset 3px 0 ${Ze[500]}`:void 0,padding:ve,borderRadius:"0 !important",backgroundColor:Je[50],verticalAlign:w&&v.rowSpan?"middle":"top",textAlign:v.alignHead?v.alignHead:"center",borderTop:S===0?Vo:"none",top:w?S*K1:0},v.stickyCss?{...v.stickyCss,position:"sticky",backgroundColor:hA[50],zIndex:4,borderRight:((B=v.stickyCss)==null?void 0:B.left)!=null?Vo:""}:{},v.sx),children:[c.jsxs(Xe,{justifyContent:v.alignHead??"center",sx:{gap:yA},children:[T&&u&&c.jsx(qt,{icon:"drag_indicator","data-table-column-drag-handle":!0,"data-table-no-range":!0,"data-table-copy-ignore":!0,"aria-label":`${p.moveLeft} / ${p.moveRight}: ${M}`,onPointerDown:O=>b.onPointerDown(O,v.id),onClick:O=>O.stopPropagation(),onKeyDown:T&&u?O=>{if(!O.altKey||!["ArrowLeft","ArrowRight"].includes(O.key))return;O.preventDefault(),O.stopPropagation();const P=m==null?void 0:m.columnControls.find(N=>N.id===v.id),R=O.key==="ArrowLeft"?P==null?void 0:P.moveLeftId:P==null?void 0:P.moveRightId;R&&u(v.id,R)}:void 0,sx:{cursor:"grab",touchAction:"none",flexShrink:0}}),c.jsx(xA,{content:v.label}),v.filter&&(r||s&&v.filter.sortable!==!1)&&c.jsx(Kk,{columnId:v.id,columnLabel:typeof v.label=="string"?v.label:void 0,config:v.filter,labels:t,rule:o==null?void 0:o[v.filter.key??v.id],onRuleChange:r,sort:i,onSortChange:s,onOpenChange:a})]}),v.column&&m&&c.jsx(Zk,{columnId:v.id,controller:m,firstColumn:((k=e[0])==null?void 0:k.id)===v.id,lastColumn:((x=e[e.length-1])==null?void 0:x.id)===v.id}),T&&d&&c.jsx(Xk,{columnId:v.id,name:M,width:v.width,label:p.resize,onResize:d})]},v.id)})},S))}),g&&c.jsx(Jk,{context:g,onClose:()=>C(void 0),controller:m,copyColumn:h,labels:p})]})}const $k=({columns:e,headerGroups:A,filterLabels:t,filterRules:o,onFilterRuleChange:r,columnSort:i,onColumnSortChange:s,onFilterOpenChange:a,rows:l=[],tableEventProps:d,onColumnResize:u,onColumnMove:p,layoutLabels:f,rangeSelection:h,onCopyColumn:m,layoutController:g,loading:C=!1,onLoadMore:b,hasMore:q=!1,loadingMore:w=!1,stickyHeader:y=!0,tableSx:S,tableRef:v,renderRow:T,renderLoading:M,renderEmpty:D})=>{const B=F.useRef(!1),k=F.useRef(0),x=C&&!w;F.useEffect(()=>{B.current=!1},[C,w,l.length,q]);const O=P=>{const R=P.currentTarget,N=R.scrollTop>k.current;k.current=R.scrollTop,!(!N||!b||!q||C||w||B.current||R.scrollHeight<=R.clientHeight||R.scrollHeight-R.scrollTop-R.clientHeight>M5)&&(B.current=!0,b())};return c.jsx(Bk,{onScroll:b?O:void 0,children:c.jsxs(I.Table,{...d,ref:v,stickyHeader:y,sx:[{height:x||l.length===0?"100%":"none",borderCollapse:"separate !important","& .MuiTableCell-root":{borderRight:Vo,borderBottom:Vo,"&:first-of-type":{borderLeft:Vo}}},...Array.isArray(S)?S:[S]],children:[c.jsx(_k,{columns:e,headerGroups:A,filterLabels:t,filterRules:o,onFilterRuleChange:r,columnSort:i,onColumnSortChange:s,onFilterOpenChange:a,onColumnResize:u,onColumnMove:p,layoutLabels:f,rangeSelection:h,onCopyColumn:m,layoutController:g,stickyHeader:y}),c.jsxs(I.TableBody,{children:[x?c.jsx(I.TableRow,{children:c.jsx(I.TableCell,{colSpan:e.length,children:M()})}):l.length?l.map((P,R)=>c.jsx(F.Fragment,{children:T(P,R)},R)):c.jsx(I.TableRow,{children:c.jsx(I.TableCell,{colSpan:e.length,children:D()})}),!x&&w&&c.jsx(I.TableRow,{children:c.jsx(I.TableCell,{colSpan:e.length,children:M()})})]})]})})};function eP({controller:e}){const{labels:A,activeView:t,modified:o}=e,r=Si.useFormik({initialValues:{name:""},validationSchema:Q5(A),validateOnMount:!0,onSubmit:({name:i},s)=>{e.saveView(i)&&s.resetForm()}});return c.jsxs(I.Stack,{sx:{gap:ve},children:[c.jsx(Is,{name:"name",label:A.viewName,value:r.values.name,inputProps:{maxLength:jr,"aria-label":A.viewName},onChange:r.handleChange,onBlur:r.handleBlur,error:r.touched.name?r.errors.name:void 0}),c.jsxs(Xe,{sx:{gap:ve,flexWrap:"wrap"},children:[c.jsx(sA,{content:A.saveView,disabled:!r.isValid||!e.canSaveView(r.values.name),onClick:()=>r.handleSubmit()}),c.jsx(sA,{content:A.updateView,disabled:!t||!o,onClick:e.updateView}),c.jsx(sA,{content:A.renameView,disabled:!r.isValid||!e.canRenameView(r.values.name),onClick:()=>{e.renameView(r.values.name)&&r.resetForm()}}),c.jsx(sA,{content:A.deleteView,disabled:!t,color:"error",onClick:()=>e.deleteView()})]})]})}function AP({open:e,onClose:A,controller:t}){const{labels:o}=t;return c.jsx(zi,{open:e,onClose:A,label:o.columns,iconLabel:"view_column",closeButton:!1,fullWidth:!0,maxWidth:"md",buttonLeft:{content:o.reset,onClick:t.reset},buttonRight:{content:o.close,onClick:A},nodeContent:c.jsxs(I.Stack,{sx:{gap:TA},children:[c.jsx(m2,{type:t.storageError?"warning":"info",content:t.storageError?o.storageError:t.storageKey?o.localPersistence:o.sessionOnly}),t.columnControls.map(r=>c.jsxs(Xe,{sx:{gap:ve,flexWrap:"wrap"},children:[c.jsx(I.Stack,{sx:{flex:1},children:c.jsx(F0,{label:r.label,checked:!r.hidden,disabled:!r.canHide,inputProps:{"aria-label":`${o.show}: ${r.label}`},onChange:(i,s)=>t.setVisible(r.id,s)})}),c.jsx(qt,{size:"small",icon:"arrow_back","aria-label":`${o.moveLeft}: ${r.label}`,disabled:!r.moveLeftId,onClick:()=>{r.moveLeftId&&t.move(r.id,r.moveLeftId)}}),c.jsx(qt,{size:"small",icon:"arrow_forward","aria-label":`${o.moveRight}: ${r.label}`,disabled:!r.moveRightId,onClick:()=>{r.moveRightId&&t.move(r.id,r.moveRightId)}}),c.jsx(I.Stack,{children:c.jsx(qn,{size:"small",value:r.pin??RA.NONE,options:t.pinOptions,inputProps:{"aria-label":`${o.pin}: ${r.label}`},onChange:i=>t.setPin(r.id,i.target.value)})})]},r.id)),c.jsx(eP,{controller:t})]})})}function tP({controller:e,initialName:A,viewId:t,onSaved:o,onCancel:r}){const{labels:i}=e,s=Si.useFormik({initialValues:{name:A},validationSchema:Q5(i),validateOnMount:!0,onSubmit:({name:a})=>{(t?e.renameView(a,t):e.saveView(a))&&o()}});return c.jsxs(I.Stack,{component:"form",onSubmit:a=>{a.preventDefault(),s.handleSubmit()},sx:{gap:yA},children:[c.jsx(Is,{autoFocus:!0,name:"name",label:i.viewName,value:s.values.name,inputProps:{maxLength:jr,"aria-label":i.viewName},onChange:s.handleChange,onBlur:s.handleBlur,error:s.touched.name?s.errors.name:void 0}),c.jsxs(Ui,{sx:{gap:yA},children:[c.jsx(sA,{type:"submit",content:i.save,disabled:!s.isValid||(t?!e.canRenameView(s.values.name,t):!e.canSaveView(s.values.name))}),c.jsx(sA,{variant:"outlined",content:i.cancel,onClick:r})]})]})}function nP({controller:e}){const{labels:A,activeView:t,modified:o}=e,[r,i]=F.useState(),[s,a]=F.useState(),l=()=>{i(void 0),a(void 0)};return c.jsxs(c.Fragment,{children:[c.jsx(sA,{sx:{maxWidth:"min(350px, 100%)",minWidth:0,"& .MuiTypography-root":{minWidth:0},"& .MuiButton-startIcon, & .MuiButton-endIcon":{flexShrink:0}},variant:"outlined","aria-label":`${A.viewMode}: ${(t==null?void 0:t.name)??A.allView}`,"aria-haspopup":"dialog","aria-expanded":!!r,startIcon:"table_rows",endIcon:"expand_more",onClick:d=>i(d.currentTarget),content:c.jsxs(I.Box,{component:"span",sx:{display:"inline-flex",alignItems:"center",maxWidth:"100%",minWidth:0,gap:yA},children:[c.jsx(I.Box,{component:"span",title:(t==null?void 0:t.name)??A.allView,sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:`${A.viewMode}: ${(t==null?void 0:t.name)??A.allView}`}),o&&c.jsx(I.Box,{component:"span",role:"status","aria-label":A.unsavedChanges,sx:{width:7,height:7,flexShrink:0,borderRadius:"50%",backgroundColor:e0[500]}})]})}),c.jsx(I.Popover,{open:!!r,anchorEl:r,onClose:l,anchorOrigin:{vertical:"bottom",horizontal:"left"},children:c.jsxs(I.Stack,{role:"dialog","aria-label":A.viewMode,sx:{width:350,maxWidth:"calc(100vw - 32px)",padding:ve,gap:yA},children:[c.jsx(xA,{content:A.viewMode}),c.jsxs(I.List,{disablePadding:!0,sx:{maxHeight:280,overflow:"auto"},children:[c.jsx(I.ListItem,{disablePadding:!0,secondaryAction:c.jsx(xA,{content:A.defaultView}),children:c.jsxs(I.ListItemButton,{selected:!t,onClick:()=>{e.applyView(""),l()},sx:{p:yA},children:[c.jsx(I.ListItemIcon,{sx:{minWidth:at.medium},children:!t&&c.jsx(ye,{icon:"check"})}),c.jsx(I.ListItemText,{primary:A.allView})]})}),e.viewOptions.map(d=>c.jsxs(I.ListItem,{disablePadding:!0,sx:{alignItems:"stretch"},children:[c.jsxs(I.ListItemButton,{selected:(t==null?void 0:t.id)===d.value,onClick:()=>{e.applyView(d.value),l()},sx:{padding:yA,minWidth:0,flex:1},children:[c.jsx(I.ListItemIcon,{sx:{minWidth:at.medium},children:(t==null?void 0:t.id)===d.value&&c.jsx(ye,{icon:"check"})}),c.jsx(I.ListItemText,{primary:d.label,sx:{minWidth:0},primaryTypographyProps:{sx:{overflowWrap:"anywhere",whiteSpace:"normal"}}})]}),c.jsxs(Xe,{sx:{gap:0,flexShrink:0},children:[c.jsx(qt,{icon:"edit","aria-label":`${A.renameView}: ${d.label}`,onClick:()=>a({id:d.value,name:d.label})}),c.jsx(qt,{icon:"delete",color:"error","aria-label":`${A.deleteView}: ${d.label}`,onClick:()=>{e.deleteView(d.value),l()}})]})]},d.value))]}),o&&c.jsxs(I.Stack,{sx:{border:1,borderColor:e0[200],backgroundColor:e0[50],borderRadius:QA,padding:yA,gap:yA},children:[c.jsx(xA,{content:`${A.unsavedChanges} "${(t==null?void 0:t.name)??A.allView}".`,sx:{color:e0[800],display:"block",WebkitLineClamp:"unset",overflow:"visible",overflowWrap:"anywhere",whiteSpace:"normal"}}),c.jsxs(Ui,{sx:{gap:yA,flexWrap:"wrap"},children:[c.jsx(sA,{content:t?A.updateView:A.reset,onClick:()=>{t?e.updateView():e.reset(),l()}}),t&&c.jsx(sA,{variant:"outlined",content:A.undoChanges,onClick:()=>{e.applyView(t.id),l()}})]})]}),c.jsx(v5,{dashed:!1}),s?c.jsx(tP,{controller:e,initialName:s.name,viewId:s.id,onSaved:l,onCancel:l},s.id??"new"):c.jsx(sA,{variant:"text",startIcon:"add",content:A.saveView,onClick:()=>a({name:""})})]})})]})}function oP({controller:e,enableManagement:A,enableRange:t,selectedCells:o,actions:r}){const[i,s]=F.useState(!1),{labels:a}=e;return c.jsxs(c.Fragment,{children:[c.jsxs(rA.Stack,{sx:{gap:yA},children:[t&&c.jsx(xA,{sx:{flexBasis:"100%",minWidth:0},content:o?`${a.selectedCells}: ${o}`:a.rangeHint}),c.jsxs(GA,{sx:{gap:yA},children:[A&&c.jsx(nP,{controller:e}),c.jsxs(HA,{sx:{gap:yA},children:[r,A&&c.jsx(an,{content:a.columns,children:c.jsx(qt,{"aria-label":a.columns,icon:"compare_arrows",variant:"outlined",onClick:()=>s(!0)})})]})]})]}),A&&e.storageError&&c.jsx(m2,{type:"warning",content:a.storageError}),A&&c.jsx(AP,{open:i,onClose:()=>s(!1),controller:e})]})}const rP=()=>()=>{},iP=()=>!0,sP=()=>!1,aP=(e,A)=>{const{enableColumnManagement:t,viewPersistence:o,columnLayout:r,defaultColumnLayout:i,onColumnLayoutChange:s,onViewPersistenceError:a}=A,l=F.useSyncExternalStore(rP,iP,sP),d=t&&o&&!Hn(o.tableId)&&!Hn(o.userId)?Hk(o.tableId,o.userId):void 0,u=d??"memory",p=F.useMemo(()=>{const B={version:1,columns:i??[],views:[]};try{const k=d&&l?window.localStorage.getItem(d):void 0;return{scope:u,data:k?W1(k):B}}catch(k){return{scope:u,data:B,error:k}}},[u,d,l]),[f,h]=F.useState(),m=(f==null?void 0:f.source)===p?f:p,g=m.data,C=oo(e,r??g.columns),b={...L5,...A.tableLayoutLabels},q=g.views.find(B=>B.id===g.activeViewId),w=JSON.stringify(oo(e,(q==null?void 0:q.columns)??i))!==JSON.stringify(C);F.useEffect(()=>{p.error&&(a==null||a(p.error))},[p]),F.useEffect(()=>{if(!d)return;const B=k=>{if(!(k.key!==d&&k.key!==null))try{const x=window.localStorage.getItem(d);h({source:p,data:x?W1(x):{version:1,columns:[],views:[]}})}catch(x){a==null||a(x)}};return window.addEventListener("storage",B),()=>window.removeEventListener("storage",B)},[p,d]);const y=(B,k=!1)=>{let x;if(d)try{window.localStorage.setItem(d,JSON.stringify(B))}catch(O){x=O,a==null||a(O)}h({source:p,data:B,error:x}),k&&(s==null||s(B.columns))},S=B=>y({...g,columns:oo(e,B)},!0),v=B=>!Hn(B)&&B.length<=jr&&g.views.length<F5&&!g.views.some(k=>k.name===B.trim()),T=(B,k=q==null?void 0:q.id)=>!!(k&&g.views.some(x=>x.id===k))&&!Hn(B)&&B.length<=jr&&!g.views.some(x=>x.id!==k&&x.name===B.trim()),M=C.filter(B=>{const k=e.find(x=>x.id===B.id);return k&&qi(k)}),D=M.filter(B=>!B.hidden).length;return{layout:C,labels:b,activeView:q,storageKey:d,storageError:!!m.error,modified:w,columnControls:M.map((B,k)=>{const x=e.find(R=>R.id===B.id),O=M[k-1],P=M[k+1];return{...B,label:typeof x.label=="string"?x.label:x.id,canHide:!!(B.hidden||D>1),moveLeftId:(O==null?void 0:O.pin)===B.pin?O.id:void 0,moveRightId:(P==null?void 0:P.pin)===B.pin?P.id:void 0}}),viewOptions:g.views.map(B=>({value:B.id,label:B.name})),pinOptions:[{value:RA.NONE,label:b.unpinned},{value:RA.LEFT,label:b.pinLeft},{value:RA.RIGHT,label:b.pinRight}],changeLayout:S,canSaveView:v,canRenameView:T,resize:(B,k)=>S(C.map(x=>x.id===B?{...x,width:k}:x)),setVisible:(B,k)=>S(C.map(x=>x.id===B?{...x,hidden:!k}:x)),setPin:(B,k)=>{Object.values(RA).includes(k)&&S(C.map(x=>x.id===B?{...x,pin:k}:x))},move:(B,k)=>{const x=C.find(R=>R.id===B),O=C.find(R=>R.id===k);if(!x||!O||x.pin!==O.pin)return;const P=C.filter(R=>R.id!==B);P.splice(C.findIndex(R=>R.id===k),0,x),S(P)},saveView:B=>{if(!v(B))return!1;const k=typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():`${Date.now()}-${Math.random()}`;return y({...g,columns:C,views:[...g.views,{id:k,name:B.trim(),columns:C}],activeViewId:k}),!0},applyView:B=>{const k=g.views.find(x=>x.id===B);if(!B){y({...g,activeViewId:void 0,columns:oo(e,i)},!0);return}k&&y({...g,activeViewId:B,columns:oo(e,k.columns)},!0)},updateView:()=>{q&&y({...g,columns:C,views:g.views.map(B=>B.id===q.id?{...B,columns:C}:B)})},renameView:(B,k=q==null?void 0:q.id)=>T(B,k)?(y({...g,views:g.views.map(x=>x.id===k?{...x,name:B.trim()}:x)}),!0):!1,deleteView:(B=q==null?void 0:q.id)=>{if(!B||!g.views.some(x=>x.id===B))return;const k=B===(q==null?void 0:q.id);y({...g,activeViewId:k?void 0:g.activeViewId,columns:k?oo(e,i):C,views:g.views.filter(x=>x.id!==B)},k)},reset:()=>y({...g,activeViewId:void 0,columns:oo(e,i)},!0)}},lP=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),cP=e=>({text:e.map(A=>A.map(t=>/[\t\r\n"]/.test(t)?`"${t.replace(/"/g,'""')}"`:t).join(" ")).join(`\r
|
|
263
|
+
`,ta={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo",infiniteGrid:"transform-component-module_infiniteGrid__Z-aP3"};NO(jO);var FO=function(e){var A=e.children,t=e.wrapperClass,o=t===void 0?"":t,r=e.contentClass,i=r===void 0?"":r,s=e.wrapperStyle,a=e.contentStyle,l=e.wrapperProps,d=l===void 0?{}:l,u=e.contentProps,p=u===void 0?{}:u,f=e.infinite,h=f===void 0?!1:f,m=F.useContext(Bs),g=m.init,C=m.cleanupWindowEvents,b=F.useRef(null),q=F.useRef(null),w=F.useRef(null);return F.useEffect(function(){var y=b.current,S=q.current;return y!==null&&S!==null&&g&&(g==null||g(y,S)),function(){C==null||C()}},[]),F.useEffect(function(){if(h){var y=w.current;if(y){var S=function(){var v=m.state,T=v.positionX,M=v.positionY;y.style.backgroundPosition="".concat(T,"px ").concat(M,"px")};return S(),m.onChange(S)}}},[h,m]),c.jsxs("div",Vt({},d,{ref:b,className:"".concat(Ra.wrapperClass," ").concat(ta.wrapper," ").concat(o),style:s},{children:[h&&c.jsx("div",{ref:w,className:ta.infiniteGrid,"aria-hidden":!0}),c.jsx("div",Vt({},p,{ref:q,className:"".concat(Ra.contentClass," ").concat(ta.content," ").concat(i),style:Vt(Vt({},a),{transform:i5(m.state.positionX,m.state.positionY,m.state.scale)})},{children:A}))]}))};function LO(e,A){var t=Math.max(0,Math.min(e.x+e.width,A.x+A.width)-Math.max(e.x,A.x)),o=Math.max(0,Math.min(e.y+e.height,A.y+A.height)-Math.max(e.y,A.y));return t*o}function QO(e){var A=e.elementX,t=e.elementY,o=e.elementWidth,r=e.elementHeight,i=e.scale,s=e.positionX,a=e.positionY,l=e.viewportWidth,d=e.viewportHeight,u=e.margin,p=u===void 0?0:u,f=e.threshold,h=f===void 0?0:f,m={x:-p,y:-p,width:l+2*p,height:d+2*p},g={x:A*i+s,y:t*i+a,width:o*i,height:r*i};if(h<=0){var C=g.x<m.x+m.width&&g.x+g.width>m.x,b=g.y<m.y+m.height&&g.y+g.height>m.y;return C&&b}var q=g.width*g.height;if(q<=0)return!1;var w=LO(m,g);return w/q>=h}F.forwardRef(function(e,A){var t=e.x,o=e.y,r=e.width,i=e.height,s=e.margin,a=s===void 0?0:s,l=e.threshold,d=l===void 0?0:l,u=e.placeholder,p=u===void 0?null:u,f=e.onShow,h=e.onHide,m=e.children,g=e.className,C=e.style,b=F.useContext(Bs),q=F.useState(!1),w=q[0],y=q[1],S=F.useRef(!1),v=F.useRef(f),T=F.useRef(h);return v.current=f,T.current=h,F.useEffect(function(){var M=function(){var k,x,O=b.wrapperComponent;if(O){var P=QO({elementX:t,elementY:o,elementWidth:r,elementHeight:i,scale:b.state.scale,positionX:b.state.positionX,positionY:b.state.positionY,viewportWidth:O.offsetWidth,viewportHeight:O.offsetHeight,margin:a,threshold:d});P!==S.current&&(S.current=P,y(P),P?(k=v.current)===null||k===void 0||k.call(v):(x=T.current)===null||x===void 0||x.call(T))}};M();var D=b.onChange(M),B;return b.wrapperComponent||(B=b.onInit(function(){return M()})),function(){D(),B==null||B()}},[b,t,o,r,i,a,d]),w?c.jsx("div",Vt({ref:A,className:g,style:C},{children:m})):p?c.jsx(c.Fragment,{children:p}):null});const M1=({open:e,selectedImage:A,selectedIndex:t,imageCount:o,hasMultipleImages:r,showViewerCounter:i,canGoPrevious:s,canGoNext:a,labels:l,viewerPaperSx:d,viewerImageSx:u,onImageError:p,onClose:f,onPrevious:h,onNext:m})=>c.jsx(I.Dialog,{open:e,onClose:f,maxWidth:!1,disableScrollLock:!0,PaperProps:{sx:kt({width:"min(1120px, calc(100vw - 32px))",maxWidth:"none",overflow:"visible",backgroundColor:"transparent",boxShadow:"none"},d)},children:c.jsx(I.DialogContent,{sx:{position:"relative",padding:0,overflow:"visible",display:"grid",placeItems:"center"},children:c.jsxs(I.Box,{sx:{position:"relative",width:"100%"},children:[c.jsx(RO,{centerOnInit:!0,centerZoomedOut:!0,limitToBounds:!0,panning:{allowLeftClickPan:!0,velocityDisabled:!0},doubleClick:{mode:"reset"},children:c.jsx(FO,{wrapperStyle:{width:"100%",maxHeight:"calc(100vh - 96px)",overflow:"hidden",borderRadius:vA,cursor:"grab"},contentStyle:{width:"100%",display:"flex",justifyContent:"center"},children:c.jsx(I.Box,{component:"img",src:A.src,alt:A.alt,draggable:!1,onError:p,sx:kt({display:"block",width:"100%",maxHeight:"calc(100vh - 96px)",objectFit:"contain",borderRadius:vA,backgroundColor:hA[50]},u)})})},A.src),c.jsx(C0,{icon:"close",label:l.close,onClick:f,sx:{top:ve,right:ve}}),r&&c.jsxs(c.Fragment,{children:[c.jsx(C0,{icon:"chevron_left",label:l.previous,disabled:!s,onClick:h,sx:{left:TA,top:"50%",transform:"translateY(-50%)"}}),c.jsx(C0,{icon:"chevron_right",label:l.next,disabled:!a,onClick:m,sx:{right:TA,top:"50%",transform:"translateY(-50%)"}})]}),i&&r&&c.jsx(xA,{content:l.counter(t+1,o),sx:pB})]})})});var yi=(e=>(e.GALLERY="gallery",e.SUMMARY="summary",e))(yi||{});const g5=({images:e,variant:A=yi.GALLERY,activeIndex:t,initialIndex:o=0,mainAspectRatio:r="16 / 9",objectFit:i="cover",thumbnailObjectFit:s="cover",thumbnailSize:a=72,summaryMaxVisible:l=4,summaryThumbnailSize:d=xr.extra_large.width,showThumbnails:u=!0,showPreviewNavigation:p=!0,showViewerCounter:f=!0,openOnMainClick:h=!0,loop:m=!0,fallbackSrc:g,activeColor:C=Ze[500],borderRadius:b=dn,emptyContent:q,labels:w,mainSx:y,mainImageSx:S,summarySx:v,summaryItemSx:T,summaryCountSx:M,thumbnailListSx:D,thumbnailSx:B,viewerPaperSx:k,viewerImageSx:x,onActiveIndexChange:O,onOpenViewer:P,onCloseViewer:R,sx:N,...j})=>{const[V,Q]=F.useState(()=>dr(o,e.length)),[L,H]=F.useState(!1),G=F.useMemo(()=>fB(w),[w]),ee=F.useMemo(()=>e.map((se,Z)=>gB(se,Z,G)),[G,e]),_=ee.length,X=dr(t??V,_),J=ee[X],ne=_>1,le=A===yi.SUMMARY,re=!le&&ne&&u;F.useEffect(()=>{Q(se=>dr(se,_))},[_]);const W=F.useCallback(se=>{if(!g)return;const Z=se.currentTarget;Z.dataset.galleryFallback!=="true"&&(Z.dataset.galleryFallback="true",Z.src=g)},[g]),K=F.useCallback(se=>{const Z=dr(se,_),ie=ee[Z];ie&&(t==null&&Q(Z),O==null||O(Z,ie))},[t,_,ee,O]),Y=ne&&(m||X>0),Ae=ne&&(m||X<_-1),te=F.useCallback(()=>{Y&&K(S1(X,-1,_,m))},[Y,K,_,m,X]),pe=F.useCallback(()=>{Ae&&K(S1(X,1,_,m))},[Ae,K,_,m,X]),oe=F.useCallback(()=>{!J||!h||(H(!0),P==null||P(X,J))},[P,h,J,X]),fe=F.useCallback(se=>{if(!h)return;const Z=dr(se,_),ie=ee[Z];ie&&(Z!==X&&(t==null&&Q(Z),O==null||O(Z,ie)),H(!0),P==null||P(Z,ie))},[t,_,ee,O,P,h,X]),$=F.useCallback(()=>{H(!1),R==null||R()},[R]);return F.useEffect(()=>{if(!L||!ne)return;const se=Z=>{Z.key==="ArrowLeft"&&(Z.preventDefault(),te()),Z.key==="ArrowRight"&&(Z.preventDefault(),pe())};return window.addEventListener("keydown",se),()=>window.removeEventListener("keydown",se)},[pe,te,ne,L]),!_||!J?c.jsx(I.Box,{...j,sx:kt({width:"100%",minHeight:180,display:"grid",placeItems:"center",borderRadius:b,border:`1px solid ${Ve[300]}`,backgroundColor:qo[50]},N),children:q}):le?c.jsxs(I.Box,{...j,sx:kt({width:"fit-content"},N),children:[c.jsx(qB,{images:ee,maxVisible:l,thumbnailSize:d,thumbnailObjectFit:s,labels:G,summarySx:v,summaryItemSx:T,summaryCountSx:M,onOpenIndex:fe,onImageError:W}),c.jsx(M1,{open:L,selectedImage:J,selectedIndex:X,imageCount:_,hasMultipleImages:ne,showViewerCounter:f,canGoPrevious:Y,canGoNext:Ae,labels:G,viewerPaperSx:k,viewerImageSx:x,onImageError:W,onClose:$,onPrevious:te,onNext:pe})]}):c.jsxs(I.Box,{...j,sx:kt({width:"100%",overflow:"hidden",borderRadius:b,border:`1px solid ${Ve[300]}`,backgroundColor:hA[50]},N),children:[c.jsx(hB,{selectedImage:J,hasMultipleImages:ne,showPreviewNavigation:p,openOnMainClick:h,mainAspectRatio:r,objectFit:i,activeColor:C,canGoPrevious:Y,canGoNext:Ae,labels:G,mainSx:y,mainImageSx:S,onImageError:W,onOpenViewer:oe,onPrevious:te,onNext:pe}),re&&c.jsx(wB,{images:ee,selectedIndex:X,thumbnailSize:a,thumbnailObjectFit:s,activeColor:C,labels:G,thumbnailListSx:D,thumbnailSx:B,onSelectIndex:K,onImageError:W}),c.jsx(M1,{open:L,selectedImage:J,selectedIndex:X,imageCount:_,hasMultipleImages:ne,showViewerCounter:f,canGoPrevious:Y,canGoNext:Ae,labels:G,viewerPaperSx:k,viewerImageSx:x,onImageError:W,onClose:$,onPrevious:te,onNext:pe})]})},Nc=(e,A,t)=>Math.min(Math.max(e,A),t),jc=e=>Math.max(U0,e-br-i0),R1=(e,A)=>e==="left"?i0:Math.max(i0,A-br-i0),HO=(e,A)=>({side:e.x<A.width/2?"left":"right",top:Nc(e.y-br/2,U0,jc(A.height))}),N1=e=>{const A=e.split("?")[0].split("#")[0].trim();return!A||A==="/"?"/":A.endsWith("/")?A.slice(0,-1):A},UO=(e,A=[])=>{const t=N1(e);return A.some(o=>{const r=N1(o);if(r.includes("*")){const i=r.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replaceAll("\\*",".*");return new RegExp(`^${i}$`).test(t)}return t===r||t.startsWith(`${r}/`)})},zO=e=>!Array.isArray(e)&&"itemNoCode"in e,VO=e=>!Array.isArray(e)&&"list"in e,m5=e=>!e||Array.isArray(e)?[]:VO(e)?e.list:zO(e)?[e]:[],h5=e=>+!!e.imageUrl+ +!!e.renderImageUrl,WO=e=>e.renderImageUrl??e.imageUrl,GO=e=>e.reduce((A,t)=>A+h5(t),0),C5=e=>{const A=[];return e.imageUrl&&A.push({id:`${e.itemNoCode}-image`,src:e.imageUrl,alt:`${e.itemNoCode} 3D`,title:"3D"}),e.renderImageUrl&&A.push({id:`${e.itemNoCode}-render`,src:e.renderImageUrl,alt:`${e.itemNoCode} Render`,title:"Render"}),A},YO=e=>e?Array.isArray(e)?e:m5(e).flatMap(C5):[],KO=()=>{const[e,A]=F.useState("");return F.useEffect(()=>{if(typeof window>"u")return;const t=()=>A(window.location.pathname),o=()=>{window.setTimeout(()=>{window.dispatchEvent(new Event(j2))},0)},r=window.history.pushState,i=window.history.replaceState;return window.history.pushState=function(...a){const l=r.apply(this,a);return o(),l},window.history.replaceState=function(...a){const l=i.apply(this,a);return o(),l},t(),window.addEventListener("popstate",t),window.addEventListener(j2,t),()=>{window.history.pushState=r,window.history.replaceState=i,window.removeEventListener("popstate",t),window.removeEventListener(j2,t)}},[]),e},XO=()=>{const[e,A]=F.useState({width:0,height:0});return F.useEffect(()=>{if(typeof window>"u")return;const t=()=>A({width:window.innerWidth,height:window.innerHeight});return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),e},JO=e=>{const[A,t]=F.useState({side:"right",top:160});return F.useEffect(()=>{e.height&&t(o=>({...o,top:Nc(o.top,U0,jc(e.height))}))},[e.height]),{launcherPosition:A,setLauncherPosition:t}},ZO=({label:e,position:A,viewportSize:t,onPositionChange:o,onOpen:r})=>{const i=At.useAnimationControls(),s=F.useRef(!1),a=jc(t.height),l=R1(A.side,t.width),d=Nc(A.top,U0,a);return F.useEffect(()=>{t.width&&i.start({x:l,y:d,transition:sa})},[i,d,l,t.width]),c.jsx(Lr,{preset:!1,drag:!0,dragMomentum:!1,dragElastic:h3,"aria-label":e,title:e,onDragStart:()=>{s.current=!0},onDragEnd:(u,p)=>{const f=HO(p.point,t);o(f),i.start({x:R1(f.side,t.width),y:f.top,transition:sa}),window.setTimeout(()=>{s.current=!1},C3)},initial:{x:l,y:d},animate:i,whileHover:{scale:1.05},whileTap:{scale:.96},onClick:()=>{s.current||r()},sx:{position:"fixed",left:0,top:0,width:br,height:br,zIndex:p3,borderRadius:"50%",cursor:"grab",touchAction:"none",userSelect:"none",display:"grid",placeItems:"center",background:`linear-gradient(145deg, ${Cr[600]}, ${Cr[900]})`},children:c.jsx(I.Box,{sx:{width:ia,height:ia,borderRadius:"50%",display:"grid",placeItems:"center",backgroundColor:b3,border:y3},children:c.jsx(ye,{icon:"image_search",fill:1,sx:{color:hA[50],fontSize:u3}})})})},_O=({activeIndex:e,items:A,onChange:t})=>{if(A.length<=1)return null;const o=GO(A);return c.jsxs(I.Stack,{gap:Sn,sx:{padding:ve,borderRadius:vA,border:`1px solid ${Je[300]}`,backgroundColor:qo[50]},children:[c.jsxs(GA,{sx:{gap:ve},children:[c.jsxs(I.Typography,{children:["Tìm thấy ",A.length," mã thành phẩm"]}),c.jsxs(I.Typography,{children:[o," hình ảnh"]})]}),c.jsx(HA,{sx:{display:"grid",gridTemplateColumns:" repeat(3, minmax(0, 1fr))"},children:A.map((r,i)=>{const s=i===e,a=WO(r),l=h5(r);return c.jsx(I.ButtonBase,{"aria-label":`Chọn mã thành phẩm ${r.itemNoCode}`,onClick:()=>t(i),sx:{padding:yA,borderRadius:vA,border:`1px solid ${s?Ze[500]:Ve[300]}`,backgroundColor:s?Ze[50]:hA[50],textAlign:"left",transition:tt,"&:hover":{borderColor:Ze[500],backgroundColor:Ze[50]},"&:focus-visible":{outline:`2px solid ${Ze[500]}`,outlineOffset:"2px"}},children:c.jsxs(Xe,{sx:{width:"100%",gap:ve},children:[a&&c.jsx(un,{url:a,sizeType:"FULL_WIDTH",size:Mt.AVATAR_GROUP}),c.jsxs(I.Stack,{sx:{minWidth:0,flex:1,gap:yA},children:[c.jsx(I.Typography,{sx:{...Me.textXs.semiBold,color:Ve[900],overflowWrap:"anywhere"},children:r.itemNoCode}),c.jsxs(I.Typography,{sx:{color:Je[500]},children:[l," ảnh"]})]})]})},r.itemNoCode)})})]})},$O=({activeOptionIndex:e,defaultEmptyContent:A,displayLoading:t,galleryImages:o,galleryProps:r,loadingContent:i,open:s,panelTitle:a,searchContent:l,searchDebounceMs:d,searchLabel:u,searchName:p,searchPlaceholder:f,searchText:h,resultItems:m,onClose:g,onOptionChange:C,onSearchTextChange:b})=>c.jsx(zi,{open:s,onClose:g,label:a,maxWidth:!1,sx:{width:f3,maxWidth:g3},sxContent:{maxHeight:m3},nodeContent:c.jsxs(I.Stack,{gap:ve,children:[l,c.jsx(j4,{label:u,name:p,value:h,placeholder:f,disabled:t,debounceMs:d,onChange:q=>b(q.target.value??""),searchIcon:"search"}),c.jsx(_O,{items:m,activeIndex:e,onChange:C}),c.jsx(g5,{...r,images:t&&!o.length?[]:o,emptyContent:t&&!o.length?i??c.jsx(gt,{}):A})]})}),b5=({images:e,open:A,defaultOpen:t=!1,hideLauncher:o=!1,isLoading:r=!1,searchLabel:i="Mã sản phẩm",searchPlaceholder:s="Nhập hoặc quét mã sản phẩm...",searchName:a="finishGoodItemNoCode",searchContent:l,searchDebounceMs:d=300,emptyContent:u,loadingContent:p,axiosProductManagement:f,blacklist:h,launcherLabel:m="Tra cứu hình ảnh sản phẩm",panelTitle:g="Hình ảnh thành phẩm",onOpenChange:C,onSearch:b,textEmpty:q="Không có hình ảnh 3D/render",...w})=>{const y=u??c.jsx(Kn,{content:q}),[S,v]=F.useState(""),[T,M]=F.useState(),[D,B]=F.useState(!1),[k,x]=F.useState(0),[O,P]=F.useState(t),R=F.useRef(b),N=F.useRef(0),j=KO(),V=XO(),{launcherPosition:Q,setLauncherPosition:L}=JO(V),H=f?T:e,G=r||D,ee=F.useMemo(()=>m5(H),[H]),_=F.useMemo(()=>ee.length?C5(ee[k]??ee[0]):YO(H),[k,H,ee]),X=j?UO(j,h):!1,J=A??O,ne=W=>{A===void 0&&P(W),C==null||C(W)};R.current=b,F.useEffect(()=>{X&&ne(!1)},[X]),F.useEffect(()=>{x(0)},[H]);const le=async(W=S)=>{var Ae;const K=W.trim();if(Hn(K))return;if(!f){(Ae=R.current)==null||Ae.call(R,K);return}const Y=N.current+1;N.current=Y;try{B(!0);const te=await o3(f,K);if(N.current!==Y)return;M(te)}catch(te){if(N.current!==Y)return;M(void 0),console.error(te)}finally{N.current===Y&&B(!1)}},re=W=>{v(W),le(W)};return X||!V.width?null:c.jsxs(c.Fragment,{children:[!o&&!J&&c.jsx(ZO,{label:m,position:Q,viewportSize:V,onPositionChange:L,onOpen:()=>ne(!0)}),c.jsx($O,{activeOptionIndex:k,defaultEmptyContent:y,displayLoading:G,galleryImages:_,loadingContent:p,open:J,panelTitle:g,galleryProps:w,searchContent:l,searchDebounceMs:d,searchLabel:i,searchName:a,searchPlaceholder:s,searchText:S,resultItems:ee,onClose:()=>ne(!1),onOptionChange:x,onSearchTextChange:re})]})},ek=({url:e,content:A,caption:t,sizeType:o=Mt.MEDIUM,sx:r,sxContent:i,sxCaption:s,alt:a="",userTitleName:l})=>c.jsxs(HA,{alignItems:"center",sx:{...r,gap:ve},children:[c.jsx(ht,{alt:a,url:e,size:o}),c.jsx(X4,{userTitleName:l,content:A,caption:t,sxContent:i,sxCaption:s})]}),y5=({time:e,hasText:A})=>c.jsx(I.Typography,{variant:"caption",sx:{...XA(1),color:Je[500]},children:(A?"Cập nhật lúc ":"")+L3(e)}),x5=({time:e,content:A,height:t=q3})=>c.jsxs(rA.Stack,{sx:{height:t,gap:0,justifyContent:"space-between",alignItems:"flex-start"},children:[c.jsx(xA,{content:A}),c.jsx(y5,{time:e})]}),Ak=({url:e,content:A,time:t,sizeType:o=Mt.MEDIUM})=>c.jsxs(HA,{alignItems:"center",children:[c.jsx(ht,{url:e,size:o}),c.jsx(x5,{content:A,time:t})]}),tk=({loading:e,content:A,startIcon:t,endIcon:o,sx:r,permission:i,...s})=>i===!1?null:c.jsx(I.Button,{...s,startIcon:t&&!e&&c.jsx(un,{url:t,sx:{width:so.small,height:so.small,borderRadius:la,opacity:s.disabled?.6:1}}),endIcon:o&&!e&&c.jsx(un,{url:o,sx:{width:so.medium,height:so.medium,borderRadius:la,opacity:s.disabled?.6:1}}),sx:{textTransform:"none",borderRadius:QA,minWidth:"unset","& > .MuiButton-endIcon":{margin:0},...r},children:e?c.jsx(gt,{size:"small",sx:{minHeight:"24.5px"}}):c.jsx(I.Typography,{sx:{transform:"translateY(0.5px)",whiteSpace:"nowrap"},children:A})}),Fc=({multiple:e=!1,onChange:A,accept:t="image/*",permission:o,loading:r=!1,...i})=>{if(o===!1)return null;const[s,a]=F.useState([]),l=F.useRef(null),d=u=>{if(u.target.files){const f=Array.from(u.target.files).map(h=>Object.assign(h,{preview:URL.createObjectURL(h)}));a(f),A(f)}};return F.useEffect(()=>()=>s==null?void 0:s.forEach(u=>{URL.revokeObjectURL(u.preview)}),[s]),c.jsxs(F.Fragment,{children:[c.jsx(I.Stack,{sx:{width:"fit-content",height:"fit-content"},children:c.jsx(qt,{...i,loading:r,icon:"attach_file",onClick:()=>l.current&&l.current.click()})}),c.jsx("input",{type:"file",accept:t,hidden:!0,multiple:e,ref:l,onChange:d})]})},nk=(...e)=>e.flatMap(A=>A?Array.isArray(A)?A:[A]:[]),ok={minWidth:100,textTransform:"none",borderRadius:QA,width:"fit-content"},rk={...Me.textSm.regular,whiteSpace:"nowrap"},sA=({content:e,loading:A=!1,startIcon:t,endIcon:o,variant:r="contained",sx:i,disabled:s=!1,...a})=>{const{palette:l}=I.useTheme();return c.jsx(I.Button,{...a,variant:r,startIcon:!A&&t?typeof t=="string"?c.jsx(ye,{icon:t,sx:{cursor:"pointer"}}):t:void 0,endIcon:!A&&o?typeof o=="string"?c.jsx(ye,{icon:o,sx:{cursor:"pointer"}}):o:void 0,sx:nk(ok,i),disabled:s,children:A?c.jsx(gt,{color:r==="contained"?l.primary.contrastText:a.color,size:"small",sx:{minHeight:"24.5px"}}):c.jsx(I.Typography,{sx:rk,children:e})})},F0=({label:e,name:A,size:t="small",sx:o,...r})=>c.jsx(I.FormControlLabel,{sx:{marginRight:0},name:A,control:c.jsx(I.Checkbox,{size:t,...r,sx:{paddingTop:0,paddingBottom:0,paddingRight:ve,borderRadius:10,"&:hover":{backgroundColor:"unset"},...o}}),label:e}),ik=({open:e,anchorEl:A,title:t="Tùy chỉnh trường",items:o,onClose:r,onToggle:i})=>c.jsx(I.Popover,{open:e,anchorEl:A,onClose:r,disableScrollLock:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{sx:{mt:"8px",minWidth:320,maxHeight:520,borderRadius:En,border:`1px solid ${Ve[200]}`,boxShadow:"0 1px 2px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.1)",overflow:"hidden"}}},children:c.jsxs(I.Box,{sx:{backgroundColor:hA[50]},children:[c.jsxs(Xe,{sx:{justifyContent:"space-between",padding:"12px 12px 10px 12px",borderBottom:`1px solid ${Ve[200]}`},children:[c.jsx(I.Typography,{sx:{...Me.textMd.semiBold},children:t}),c.jsx(I.IconButton,{onClick:r,sx:{padding:.5},children:c.jsx(ye,{icon:"close"})})]}),c.jsx(bo,{sx:{alignItems:"stretch",gap:.5,padding:"10px 8px",maxHeight:460,overflowY:"auto"},children:o.map(s=>c.jsxs(Xe,{sx:{justifyContent:"space-between",gap:1,padding:"8px 8px",borderRadius:QA,opacity:s.disabled?.6:1},children:[c.jsxs(Xe,{sx:{gap:1,minWidth:0},children:[c.jsx(ye,{icon:"drag_indicator",sx:{color:Ve[400]}}),c.jsx(I.Typography,{sx:{...Me.textSm.regular,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:s.label})]}),c.jsx(I.Checkbox,{checked:s.checked,disabled:s.disabled,onChange:a=>i(s.key,a.target.checked),sx:{padding:0}})]},s.key))})]})}),sk=({headerAction:e,children:A,isCollapsible:t=!0,title:o,description:r,defaultExpanded:i=!0,sx:s,titleSx:a})=>{const[l,d]=F.useState(i),u=!!o&&t;return c.jsxs(I.Stack,{sx:{bgcolor:hA[50],borderRadius:QA,overflow:"hidden",gap:ve,boxShadow:2,p:TA,...s},children:[o&&c.jsxs(GA,{onClick:()=>d(p=>!p),sx:{"&:hover":{cursor:"pointer"}},children:[c.jsxs(HA,{gap:ve,children:[c.jsx(xA,{content:o,sx:{...Me.textMd.semiBold,color:Ze[500],...a}}),r]}),c.jsxs(Xe,{gap:0,children:[e,u&&c.jsx(qt,{icon:l?"expand_less":"expand_more"})]})]}),c.jsx(I.Collapse,{in:!u||l,unmountOnExit:u,children:c.jsx(I.Stack,{sx:{gap:ve},children:A})})]})},v5=({orientation:e="horizontal",color:A=IA.gray2,thickness:t=1,length:o="100%",sx:r,dashed:i=!0})=>e==="vertical"?c.jsx(rA.Box,{sx:{height:o,display:"flex",justifyContent:"center",alignSelf:"center","&::before":{content:'""',width:`${t}px`,height:"100%",borderLeft:`${t}px ${i?"dashed":"solid"} ${A}`,...r}}}):c.jsx(rA.Box,{sx:{borderBottom:`${t}px ${i?"dashed":"solid"} ${A}`,width:typeof o=="number"?`${o}px`:o,alignSelf:"stretch",display:"block",...r}}),q5="180px",ja="140px",w5="250px";var hn=(e=>(e.Equals="Equals",e.NotEquals="NotEquals",e.Contains="Contains",e.NotContains="NotContains",e.IsNull="IsNull",e.IsNotNull="IsNotNull",e.GreaterThan="GreaterThan",e.LessThan="LessThan",e.GreaterThanOrEqual="GreaterThanOrEqual",e.LessThanOrEqual="LessThanOrEqual",e))(hn||{}),MA=(e=>(e.EXACT="EXACT",e.DATE_RANGE="DATE_RANGE",e.TODAY="TODAY",e.TOMORROW="TOMORROW",e.YESTERDAY="YESTERDAY",e.THIS_WEEK="THIS_WEEK",e.LAST_WEEK="LAST_WEEK",e.THIS_MONTH="THIS_MONTH",e.LAST_MONTH="LAST_MONTH",e.LAST_7_DAYS="LAST_7_DAYS",e.NEXT_7_DAYS="NEXT_7_DAYS",e.LAST_30_DAYS="LAST_30_DAYS",e.NEXT_30_DAYS="NEXT_30_DAYS",e))(MA||{});const S5=[{label:"Là",value:"Equals"},{label:"Không là",value:"NotEquals"},{label:"Chứa",value:"Contains"},{label:"Không chứa",value:"NotContains"},{label:"Lớn hơn",value:"GreaterThan"},{label:"Lớn hơn hoặc bằng",value:"GreaterThanOrEqual"},{label:"Nhỏ hơn",value:"LessThan"},{label:"Nhỏ hơn hoặc bằng",value:"LessThanOrEqual"},{label:"Trống",value:"IsNull"},{label:"Không trống",value:"IsNotNull"}],E5=[{label:"Là",value:"Equals"},{label:"Không là",value:"NotEquals"},{label:"Chứa",value:"Contains"},{label:"Không chứa",value:"NotContains"},{label:"Trống",value:"IsNull"},{label:"Không trống",value:"IsNotNull"}],I5=[{label:"Là",value:"Equals"},{label:"Trống",value:"IsNull"},{label:"Không trống",value:"IsNotNull"}],T5=[{label:"ngày chính xác",value:"EXACT"},{label:"khoảng ngày",value:"DATE_RANGE"},{label:"hôm nay",value:"TODAY"},{label:"ngày mai",value:"TOMORROW"},{label:"hôm qua",value:"YESTERDAY"},{label:"tuần này",value:"THIS_WEEK"},{label:"tuần trước",value:"LAST_WEEK"},{label:"tháng này",value:"THIS_MONTH"},{label:"tháng trước",value:"LAST_MONTH"},{label:"trong 7 ngày qua",value:"LAST_7_DAYS"},{label:"trong 7 ngày tiếp theo",value:"NEXT_7_DAYS"},{label:"trong 30 ngày qua",value:"LAST_30_DAYS"},{label:"trong 30 ngày tiếp theo",value:"NEXT_30_DAYS"}],Wn=()=>typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():Math.random().toString(36).substring(2,9),D5=e=>{if(!e)return{};const A=Be().startOf("day"),t=e.split("|"),o=t[0];let r=A,i=A;if(o===MA.EXACT){const s=t[1];if(s){const a=Be(s).startOf("day"),l=Be(s).endOf("day");return{fromDate:a.unix(),toDate:l.unix()}}return{}}if(o===MA.DATE_RANGE){const s=t[1],a=t[2],l=s?Be(s).startOf("day").unix():void 0,d=a?Be(a).endOf("day").unix():void 0;return{fromDate:l,toDate:d}}switch(o){case MA.TODAY:r=A.startOf("day"),i=A.endOf("day");break;case MA.TOMORROW:r=A.add(1,"day").startOf("day"),i=A.add(1,"day").endOf("day");break;case MA.YESTERDAY:r=A.subtract(1,"day").startOf("day"),i=A.subtract(1,"day").endOf("day");break;case MA.THIS_WEEK:{const s=(7+(A.day()-1))%7;r=A.subtract(s,"day"),i=r.add(6,"day").endOf("day");break}case MA.LAST_WEEK:{const s=(7+(A.day()-1))%7;r=A.subtract(s,"day").subtract(7,"day"),i=r.add(6,"day").endOf("day");break}case MA.THIS_MONTH:r=A.startOf("month"),i=A.endOf("month");break;case MA.LAST_MONTH:r=A.subtract(1,"month").startOf("month"),i=A.subtract(1,"month").endOf("month");break;case MA.LAST_7_DAYS:r=A.subtract(7,"day"),i=A.endOf("day");break;case MA.NEXT_7_DAYS:r=A,i=A.add(7,"day").endOf("day");break;case MA.LAST_30_DAYS:r=A.subtract(30,"day"),i=A.endOf("day");break;case MA.NEXT_30_DAYS:r=A,i=A.add(30,"day").endOf("day");break;default:return{}}return{fromDate:r.unix(),toDate:i.unix()}},ak=e=>e.reduce((A,t)=>(A[t.key]=t.defaultValue,A),{}),j1=(e,A)=>{const t=e.filter(r=>((A==null?void 0:A[r.key])??r.defaultValue)!==r.defaultValue).map(r=>({id:Wn(),fieldKey:r.key,value:(A==null?void 0:A[r.key])??r.defaultValue}));if(t.length>0)return t;const o=e[0];return o?[{id:Wn(),fieldKey:o.key,value:(A==null?void 0:A[o.key])??o.defaultValue}]:[]},lk=({open:e,title:A="Tùy chỉnh bộ lọc",fields:t,value:o,anchorEl:r,offset:i,onClose:s,onApply:a})=>{const l=F.useMemo(()=>ak(t),[t]),d=F.useMemo(()=>t.map(y=>({label:y.label,value:y.key})),[t]),[u,p]=F.useState(()=>j1(t,o)),[f,h]=F.useState(null);F.useEffect(()=>{e&&(p(j1(t,o)),h(null))},[t,e,o]);const m=()=>{const y=t[0];if(!y){p([]);return}p([{id:Wn(),fieldKey:y.key,value:y.defaultValue}])},g=y=>{p(S=>{const v=S.filter((M,D)=>D!==y);if(v.length>0)return v;const T=t[0];return T?[{id:Wn(),fieldKey:T.key,value:T.defaultValue}]:[]})},C=()=>{p(y=>{const S=new Set(y.map(T=>T.fieldKey)),v=t.find(T=>!S.has(T.key));return v?[...y,{id:Wn(),fieldKey:v.key,value:v.defaultValue}]:y})},b=y=>{f===null||y===f||(p(S=>{const v=[...S],[T]=v.splice(f,1);return v.splice(y,0,T),v}),h(null))},q=()=>{const y={...l};u.forEach(S=>{S.fieldKey&&(y[S.fieldKey]=S.value)}),a(y),s()},w=u.length<t.length;return c.jsx(I.Popover,{open:e,anchorEl:r,onClose:s,disableScrollLock:!0,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},slotProps:{paper:{sx:{mt:`${(i==null?void 0:i.y)??8}px`,ml:`${(i==null?void 0:i.x)??0}px`,minWidth:320,maxWidth:"calc(100vw - 48px)",borderRadius:En,border:`1px solid ${Ve[300]}`,boxShadow:"0 8px 24px rgba(15, 23, 42, 0.12)",overflow:"hidden"}}},children:c.jsx(I.Box,{sx:{backgroundColor:hA[50],padding:2},children:c.jsxs(bo,{sx:{alignItems:"stretch",gap:2},children:[c.jsxs(GA,{sx:{gap:1},children:[c.jsx(I.Typography,{sx:{...Me.textMd.semiBold},children:A}),c.jsx(I.IconButton,{onClick:s,sx:{padding:yA},children:c.jsx(ye,{icon:"close"})})]}),c.jsx(bo,{sx:{alignItems:"stretch",gap:1.25},children:u.map((y,S)=>{const v=t.find(D=>D.key===y.fieldKey);if(!v)return null;const T=new Set(u.map(D=>D.fieldKey)),M=d.filter(D=>D.value===y.fieldKey||!T.has(D.value));return c.jsxs(Xe,{onDragOver:D=>D.preventDefault(),onDrop:()=>b(S),sx:{gap:1,alignItems:"flex-end"},children:[c.jsx(I.Box,{draggable:!0,onDragStart:()=>h(S),onDragEnd:()=>h(null),sx:{paddingBottom:"10px",cursor:"grab"},children:c.jsx(ye,{icon:"drag_indicator",sx:{color:Ve[500]}})}),c.jsx(I.Box,{sx:{flex:1,minWidth:220},children:c.jsx(qn,{label:"",value:y.fieldKey,options:M,placeholder:"",onChange:D=>{const B=D.target.value,k=t.find(x=>x.key===B);k&&p(x=>x.map((O,P)=>P===S?{...O,fieldKey:B,value:k.defaultValue}:O))}})}),c.jsx(I.Box,{sx:{flex:1,minWidth:220},children:c.jsx(qn,{label:"",value:y.value??v.defaultValue,options:v.options,placeholder:"Tất cả",onChange:D=>{const B=D.target.value;p(k=>k.map((x,O)=>O===S?{...x,value:B}:x))}})}),c.jsx(I.IconButton,{onClick:()=>g(S),children:c.jsx(ye,{icon:"delete_outline"})})]},y.id)})}),w&&c.jsx(sA,{content:"Thêm điều kiện",onClick:C,startIcon:"add",variant:"text",sx:{color:Ze[500],minWidth:0,paddingX:0}}),c.jsxs(GA,{sx:{marginTop:1},children:[c.jsx(sA,{content:"Mặc định",onClick:m,variant:"text",sx:{color:Ze[500],minWidth:0,paddingX:0}}),c.jsxs(Xe,{sx:{gap:1},children:[c.jsx(sA,{onClick:s,variant:"outlined",content:"Hủy"}),c.jsx(sA,{onClick:q,variant:"contained",content:"Áp dụng"})]})]})]})})})},ck=({field:e,rowValue:A,onChange:t})=>{switch(e.type){case"select":return c.jsx(qn,{label:"",value:A??e.defaultValue,options:e.options||[],placeholder:"Tất cả",onChange:o=>t(o.target.value)});case"date":{const o=A?A.split("|"):"",r=o[0],i=r===MA.EXACT?o[1]:"",s=r===MA.DATE_RANGE?o[1]:"",a=r===MA.DATE_RANGE?o[2]:"",l=r===MA.EXACT||r===MA.DATE_RANGE;return c.jsxs(I.Box,{sx:{display:"flex",gap:ve,width:"100%"},children:[c.jsx(I.Box,{sx:{width:l?"140px":"100%",flexShrink:0},children:c.jsx(qn,{label:"",value:r,options:T5,placeholder:"",onChange:d=>{const u=d.target.value;let p=u;u===MA.EXACT&&(p=`${MA.EXACT}|`),u===MA.DATE_RANGE&&(p=`${MA.DATE_RANGE}||`),t(p)}})}),r===MA.EXACT&&c.jsx(I.Box,{sx:{flex:1},children:c.jsx(R4,{name:`exact-date-${Wn()}`,label:"",value:i||null,onChange:d=>{const u=d.target.value,p=u?Be(u).format("YYYY-MM-DD"):"";t(`${MA.EXACT}|${p}`)}})}),r===MA.DATE_RANGE&&c.jsx(I.Box,{sx:{flex:1},children:c.jsx(y4,{format:"DD/MM/YYYY",placeholder:"Ngày bắt đầu — Ngày kết thúc",label:"",fromDate:s,toDate:a,onFromDateChange:d=>{const u=d?Be(d).format("YYYY-MM-DD"):"";t(`${MA.DATE_RANGE}|${u}|${a}`)},onToDateChange:d=>{const u=d?Be(d).format("YYYY-MM-DD"):"";t(`${MA.DATE_RANGE}|${s}|${u}`)}})})]})}}},dk=({open:e,title:A="Tùy chỉnh bộ lọc nâng cao",fields:t,value:o,operatorOptions:r=E5,fullOperator:i=!1,anchorEl:s,offset:a,onClose:l,onApply:d})=>{const[u,p]=F.useState([]),[f,h]=F.useState(null);F.useEffect(()=>{e&&(o&&o.length>0?p(o.map(v=>({id:Wn(),fieldKey:v.field,operator:v.operator,value:v.value}))):p([]),h(null))},[e,o]);const m=(v,T)=>{p(M=>M.map((D,B)=>B===v?{...D,...T}:D))},g=()=>p([]),C=v=>p(T=>T.filter((M,D)=>D!==v)),b=()=>{p(v=>{if(v.length>=t.length)return v;const T=new Set(v.map(D=>D.fieldKey)),M=t.find(D=>!T.has(D.key))||t[0];return M?[...v,{id:Wn(),fieldKey:M.key,operator:hn.Equals,value:M.defaultValue}]:v})},q=v=>{f===null||v===f||(p(T=>{const M=[...T],[D]=M.splice(f,1);return M.splice(v,0,D),M}),h(null))},w=()=>{const v=u.filter(T=>T.fieldKey).map(T=>{const M=t.find(x=>x.key===T.fieldKey);let D,B;if((M==null?void 0:M.type)==="date"&&T.operator!==hn.IsNull&&T.operator!==hn.IsNotNull){const x=D5(T.value);D=x.fromDate,B=x.toDate}return{field:T.fieldKey,operator:T.operator,value:T.operator===hn.IsNull||T.operator===hn.IsNotNull?"":T.value,fromDate:D,toDate:B}});d(v),l()},y=t.map(v=>({label:v.label,value:v.key})),S=u.map(v=>v.fieldKey);return c.jsx(I.Popover,{open:e,anchorEl:s,onClose:l,disableScrollLock:!0,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},slotProps:{paper:{sx:{mt:`${(a==null?void 0:a.y)??8}px`,ml:`${(a==null?void 0:a.x)??0}px`,width:"max-content",minWidth:"800px",maxWidth:"calc(100vw - 48px)",boxShadow:4,overflow:"hidden"}}},children:c.jsx(rA.Stack,{sx:{backgroundColor:Ve[50],padding:w3},children:c.jsxs(rA.Stack,{children:[c.jsxs(GA,{children:[c.jsx(I.Typography,{sx:{...Me.textMd.semiBold},children:A}),c.jsx(I.IconButton,{onClick:l,sx:{padding:yA},children:c.jsx(ye,{icon:"close"})})]}),c.jsxs(rA.Stack,{children:[u.length===0&&c.jsx(I.Typography,{sx:{color:Ve[400],fontStyle:"italic"},children:"Chưa có điều kiện lọc nào được áp dụng."}),u.map((v,T)=>{const M=t.find(O=>O.key===v.fieldKey);if(!M)return null;const D=M.type==="date";i&&(r=S5);const B=D?I5:r,k=v.operator===hn.IsNull||v.operator===hn.IsNotNull,x=y.filter(O=>!S.includes(O.value)||O.value===v.fieldKey);return c.jsxs(Xe,{onDragOver:O=>O.preventDefault(),onDrop:()=>q(T),sx:{gap:ve},children:[c.jsx(rA.Stack,{draggable:!0,onDragStart:()=>h(T),onDragEnd:()=>h(null),sx:{cursor:"grab"},children:c.jsx(ye,{icon:"drag_indicator",sx:{color:Ve[400]}})}),c.jsx(rA.Stack,{sx:{width:q5},children:c.jsx(qn,{label:"",value:v.fieldKey,options:x,placeholder:"",onChange:O=>{const P=O.target.value,R=t.find(N=>N.key===P);R&&m(T,{fieldKey:P,value:R.defaultValue,operator:hn.Equals})}})}),c.jsx(rA.Stack,{sx:{width:ja},children:c.jsx(qn,{label:"",value:v.operator,options:B,placeholder:"",onChange:O=>{const P=O.target.value,R=v.value;m(T,{operator:P,value:R})},sx:{width:ja}})}),c.jsx(rA.Stack,{sx:{flex:1,minWidth:w5},children:k?c.jsx(qn,{label:"",value:"",options:[],placeholder:"---",disabled:!0}):c.jsx(ck,{field:M,rowValue:v.value,onChange:O=>m(T,{value:O})})}),c.jsx(I.IconButton,{onClick:()=>C(T),children:c.jsx(ye,{icon:"delete_outline"})})]},v.id)})]}),u.length<t.length&&c.jsx(sA,{content:"Thêm điều kiện",onClick:b,startIcon:"add",variant:"text"}),c.jsxs(GA,{sx:{marginTop:Ya},children:[c.jsx(rA.Stack,{onClick:g,sx:{cursor:"pointer",color:Ze[500]},children:"Mặc định"}),c.jsxs(Xe,{sx:{gap:1},children:[c.jsx(sA,{onClick:l,variant:"outlined",content:"Hủy",sx:{borderRadius:QA}}),c.jsx(sA,{onClick:w,variant:"contained",content:"Áp dụng",sx:{borderRadius:QA}})]})]})]})})})},uk=({children:e,onApply:A,onReset:t,initialFilters:o={},sx:r={},ignoredKeysInCount:i=[]})=>{const[s,a]=F.useState(!1),[l,d]=F.useState(o),[u,p]=F.useState(o),f=Object.entries(l).filter(([C,b])=>i.includes(C)?!1:Array.isArray(b)?b.length>0:b!=null&&b!=="").length;F.useEffect(()=>{s&&p({...l})},[l,s]);const h=(C,b)=>{p(q=>({...q,[C]:b}))},m=()=>{d(u),A==null||A(u),a(!1)},g=()=>{p({}),d({}),t==null||t(),a(!1)};return c.jsxs(F.Fragment,{children:[c.jsx(sA,{sx:{...r,color:(f>0,Ze[500]),minWidth:"auto",p:s0},startIcon:"filter_list_alt",variant:"outlined",onClick:()=>a(!0),content:`Bộ lọc${f>0?` (${f})`:""}`}),c.jsx(I.Drawer,{anchor:"right",open:s,onClose:()=>a(!1),sx:{"& .MuiDrawer-paper":{width:320,padding:TA}},children:c.jsxs(rA.Stack,{sx:{height:"100%"},children:[c.jsxs(GA,{sx:{gap:0},children:[c.jsx(xA,{content:"Bộ lọc",sx:{...Me.textLg.semiBold}}),c.jsx(I.IconButton,{onClick:()=>a(!1),children:c.jsx(ye,{icon:"close"})})]}),c.jsx(rA.Stack,{sx:{flex:1,gap:ve,overflowY:"auto",scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:e({filters:l,tempFilters:u,setFilter:h,setTempFilters:p})}),c.jsxs(ap,{sx:{gap:ve},children:[c.jsx(sA,{variant:"outlined",onClick:g,content:"Đặt lại"}),c.jsx(sA,{variant:"contained",onClick:m,content:"Cập nhật"})]})]})})]})},zt=56,F1=42,L1=26,pk=12,X2=18,Os=76,fk=160,Q1={type:"spring",stiffness:520,damping:34},gk=e=>(zt+pk)*(e+1),Lc=(e,A,t)=>Math.min(Math.max(e,A),t),xi=e=>Math.max(Os,e-zt-X2),H1=(e,A)=>e==="left"?X2:Math.max(X2,A-zt-X2),mk=(e,A)=>({side:e.x<A.width/2?"left":"right",top:Lc(e.y-zt/2,Os,xi(A.height))}),hk=(e,A,t)=>({position:"absolute",right:0,bottom:t?gk(A):0,width:zt,height:zt,borderRadius:"50%",opacity:t?1:0,pointerEvents:t?"auto":"none",transform:t?"scale(1)":"scale(0.82)",transition:`bottom ${tt}, opacity ${tt}, transform ${tt}`,backgroundColor:e.backgroundColor??hA[50],border:`2px solid ${Ze[200]}`,boxShadow:"0 10px 24px rgba(0, 0, 0, 0.2)","&:hover":{borderColor:Ze[500],transform:t?"scale(1.04)":"scale(0.82)"},"&:focus-visible":{outline:`2px solid ${Ze[300]}`,outlineOffset:"2px"}}),Ck=()=>{const[e,A]=F.useState({width:0,height:0});return F.useEffect(()=>{if(typeof window>"u")return;const t=()=>A({width:window.innerWidth,height:window.innerHeight});return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),e},bk=e=>{const[A,t]=F.useState(null);return F.useEffect(()=>{!e.width||!e.height||t(o=>o?{...o,top:Lc(o.top,Os,xi(e.height))}:{side:"right",top:xi(e.height)})},[e.width,e.height]),{position:A,setPosition:t}},B5=({closeOnActionClick:e=!0,items:A,launcherIcon:t="chat",launcherLabel:o="Công cụ",sx:r})=>{const[i,s]=F.useState(!1),a=At.useAnimationControls(),l=F.useRef(!1),d=Ck(),{position:u,setPosition:p}=bk(d),f=!!d.width&&!!d.height&&!!u,h=u?H1(u.side,d.width):0,m=u?Lc(u.top,Os,xi(d.height)):0,g=r&&!Array.isArray(r)&&typeof r=="object"?r:void 0;F.useEffect(()=>{!u||!d.width||a.start({x:h,y:m,transition:Q1})},[a,u,m,h,d.width]);const C=c.jsxs(I.Stack,{sx:{position:"relative",width:zt,height:zt},children:[A.map((b,q)=>c.jsx(I.ButtonBase,{"aria-label":b.label,title:b.label,disabled:b.disabled,onClick:()=>{e&&s(!1),b.onClick()},sx:hk(b,q,i),children:c.jsx(ye,{icon:b.icon,fill:1,sx:{color:b.color??Ze[700],fontSize:L1}})},b.key)),c.jsx(I.ButtonBase,{"aria-label":o,title:o,onClick:()=>{l.current||s(b=>!b)},sx:{position:"absolute",right:0,bottom:0,width:zt,height:zt,borderRadius:"50%",backgroundColor:hA[50],border:`2px solid ${Ze[200]}`,boxShadow:"0 10px 24px rgba(0, 0, 0, 0.22)","&:hover":{borderColor:Ze[500]},"&:focus-visible":{outline:`2px solid ${Ze[300]}`,outlineOffset:"2px"}},children:c.jsx(I.Box,{sx:{width:F1,height:F1,borderRadius:"50%",display:"grid",placeItems:"center",backgroundColor:Ze[700],transform:i?"scale(0.96)":"scale(1)",transition:tt},children:c.jsx(ye,{icon:i?"close":t,fill:1,sx:{color:hA[50],fontSize:L1}})})})]});return!f||!u?null:c.jsx(Lr,{preset:!1,drag:!0,dragMomentum:!1,dragElastic:.08,onDragStart:()=>{l.current=!0},onDragEnd:(b,q)=>{const w=mk(q.point,d);p(w),a.start({x:H1(w.side,d.width),y:w.top,transition:Q1}),window.setTimeout(()=>{l.current=!1},fk)},initial:{x:h,y:m},animate:a,whileHover:{scale:1.05},whileTap:{scale:.96},sx:{position:"fixed",left:0,top:0,width:zt,height:zt,zIndex:1400,cursor:"grab",touchAction:"none",userSelect:"none",...g},children:C})},yk=({axiosProductManagement:e,enableFinishGoodGallery:A=!0,enableScale:t=!0,items:o=[],scaleAutoConnectAuthorized:r=!0})=>{const i=d2(),[s,a]=F.useState(!1),l=F.useRef(void 0),d=F.useRef(!1),u=(i==null?void 0:i.status)===eA.Connected,p=(i==null?void 0:i.status)===eA.Idle,f=(i==null?void 0:i.status)===eA.Connecting||(i==null?void 0:i.status)===eA.Disconnecting;F.useEffect(()=>{t||(l.current=void 0,d.current=!1)},[t]),F.useEffect(()=>{if(!t||!r||d.current||!i||!p||i.authorizedPorts.length!==1)return;const m=i.authorizedPorts[0],g=`${m.index}:${m.label}`;l.current!==g&&(l.current=g,i.connect({useAuthorizedPort:!0,authorizedPortIndex:m.index,silentNoAuthorizedPort:!0}))},[t,p,i,r]);const h=F.useMemo(()=>{const m=[];return t&&m.push({key:"scale",label:u?"Ngắt kết nối cân":"Kết nối cân",icon:"scale",disabled:!i||f,backgroundColor:u?mo[50]:void 0,color:u?mo[700]:void 0,onClick:()=>{if(!(!i||f)){if(u){d.current=!0,i.disconnect();return}if(d.current=!1,i.authorizedPorts.length){i.connect({useAuthorizedPort:!0,authorizedPortIndex:i.authorizedPorts[0].index});return}i.connect()}}}),A&&m.push({key:"finish-good-gallery",label:"Hình ảnh thành phẩm",icon:"image_search",onClick:()=>a(!0)}),m.push(...o),m},[A,t,f,u,o,i]);return h.length?c.jsxs(c.Fragment,{children:[c.jsx(B5,{items:h,launcherIcon:"support_agent",launcherLabel:"Công cụ"}),A?c.jsx(b5,{axiosProductManagement:e,hideLauncher:!0,open:s,onOpenChange:a}):null]}):null},O5=({titleNode:e,list:A,sxList:t={},sxListItem:o={},sxIconContent:r={},sxTitleNode:i={}})=>{const{palette:s}=I.useTheme();return c.jsxs(I.List,{sx:{display:"flex",flexDirection:"column",padding:0,...t},children:[e&&c.jsx(I.ListItem,{sx:{padding:ve,display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"8px","&:hover":{cursor:"default",backgroundColor:"unset",color:"unset"},...i},children:e}),A.map(a=>c.jsx(I.ListItem,{onClick:a.onClick,sx:{borderRadius:vA,padding:ve,transition:tt,"&:hover":{cursor:"pointer",backgroundColor:s.action.hover},...o},children:c.jsx(Tn,{content:a.content,icon:a.icon,sx:r})},a.content))]})},k5=({total:e=0,page:A=aa.page,take:t=aa.take,openRowsPerPage:o=!0,onChange:r,sx:i={}})=>{const s=Math.ceil(e/t),a=[10,20,30,50],l=a.includes(Number(t))?Number(t):10,{palette:d}=I.useTheme(),u=f=>{const h=Number(f.target.value);r({page:1,take:h})},p=(f,h)=>{r({page:h,take:t})};return c.jsxs(Xe,{gap:.5,sx:{ml:"auto",...i},children:[c.jsx(I.Pagination,{count:s,page:A,showFirstButton:!0,showLastButton:!0,onChange:p,size:"medium",variant:"outlined",shape:"rounded",sx:{"& .MuiPagination-ul":{gap:.5},"& .MuiPaginationItem-root":{borderRadius:QA,m:0},"& .MuiPaginationItem-root.Mui-disabled":{opacity:.5,pointerEvents:"none"},"& .MuiPaginationItem-root.Mui-selected":{background:d.primary.main,color:"white"}}}),o&&c.jsx(Xe,{children:c.jsx(I.FormControl,{size:"small",children:c.jsx(qn,{value:l,onChange:f=>u(f),options:a.map(f=>({value:f,label:`${f} / trang`})),sx:{"& .MuiOutlinedInput-root":{borderRadius:"0px !important"}}})})})]})},xk=({name:e,direction:A="row",label:t,disabled:o,iconLabel:r="event_list",defaultValue:i,value:s,onChange:a,children:l,required:d=!1,sx:u={}})=>{const p=f=>{a&&a({target:{name:e,value:f.target.value||void 0}})};return c.jsxs(I.FormControl,{disabled:o,sx:{gap:ve},onChange:p,children:[t&&c.jsx(I.InputLabel,{shrink:!0,required:d,sx:{transform:"translate(0px , -9px) scale(0.75)",zIndex:2,display:"flex"},children:c.jsxs(pp,{children:[c.jsx(ye,{icon:r,sx:{fontSize:Ja.FONT_SIZE_LABEL}}),t]})}),c.jsx(I.RadioGroup,{name:e,defaultValue:i,value:s,sx:{flexDirection:A,paddingTop:t?"calc(8.5px + 1.5px)":0,gap:TA,...u},children:l})]})},vk=({name:e,label:A,...t})=>c.jsx(I.FormControlLabel,{name:e,label:A,sx:{alignItems:"center",mr:0},control:c.jsx(I.Radio,{...t,sx:{paddingTop:0,paddingBottom:0,paddingRight:ve,marginLeft:"2px","&:hover":{backgroundColor:"unset"},"& .MuiSvgIcon-root":{fontSize:"18px"}}})}),qk=({label:e,value:A,children:t,sx:o,textTransform:r="uppercase"})=>{const{palette:i}=I.useTheme();return c.jsxs(Xe,{sx:{gap:1,...o},children:[c.jsx(I.Typography,{variant:"subtitle2",sx:{...Me.textMd.semiBold,textTransform:r,color:i.primary.main},children:e||t}),A!==void 0&&c.jsx(I.Typography,{variant:"subtitle2",sx:{...Me.textMd.semiBold,textTransform:r,color:i.primary.main},children:A})]})},P5=({name:e,value:A=!1,onChange:t})=>{const{palette:o}=I.useTheme(),r=()=>{t&&t({target:{name:e,value:!A}})};return c.jsx(At.MotionConfig,{transition:{duration:.2,ease:"easeOut"},children:c.jsx(At.motion.div,{className:"switch",initial:!1,animate:{backgroundColor:A?o.primary.main:o.text.disabled},onClick:r,style:{display:"flex",justifyContent:A?"flex-end":"flex-start",alignItems:"center",width:"30px",height:"14px",padding:"3px",borderRadius:"10px",boxSizing:"content-box",cursor:"pointer"},children:c.jsx(At.motion.div,{layout:!0,className:"handle",style:{background:"#fdfdfd",aspectRatio:1,height:"100%",borderRadius:"50%"}})})})},wk=({name:e,content:A,value:t=!1,onChange:o,sx:r={}})=>c.jsxs(Xe,{sx:{gap:ve,...r},children:[c.jsx(I.Typography,{children:A}),c.jsx(P5,{name:e,value:t,onChange:o})]});var Qc=(e=>(e.DISABLED_GET_ROW_MENU="DISABLED_GET_ROW_MENU",e.HISTORY_GET_ROW_MENU="HISTORY_GET_ROW_MENU",e.INFO="INFO",e.COPY="COPY",e.DELETE="DELETE",e.UPDATE="UPDATE",e.SELECT="SELECT",e.COLLAPSE="COLLAPSE",e.DISABLED_ALL_ACTIONS="DISABLED_ALL_ACTIONS",e.DISABLED_ROW="DISABLED_ROW",e.DISABLED_CHECKBOX="DISABLED_CHECKBOX",e))(Qc||{}),Rr=(e=>(e.TOTAL="TOTAL",e.TOTAL_INCOME="TOTAL_INCOME",e))(Rr||{}),sn=(e=>(e.ASC="asc",e.DESC="desc",e))(sn||{}),Qn=(e=>(e.TEXT="text",e.NUMBER="number",e.DATE="date",e.BOOLEAN="boolean",e))(Qn||{}),Pt=(e=>(e.INCLUDE="include",e.EXCLUDE="exclude",e))(Pt||{});const Vo=`1px solid ${Ve[300]}`,M5=80,g2=Object.keys(Qc).reduce((e,A)=>(e[A]=!1,e),{}),R5=e=>e?Array.isArray(e)?[...e]:[e]:[],go=(...e)=>e.flatMap(A=>R5(A)),N5=(e,A,t)=>go({width:`${e.width}px !important`,minWidth:`${e.width}px !important`,maxWidth:`${e.width}px !important`,padding:ve,borderRadius:"0 !important",color:t?Ve[500]:"inherit",...e.stickyCss?{position:"sticky",backgroundColor:hA[50],...e.stickyCss}:{}},e.sx,e.cellSx),j5=(e,A,t,o,r)=>({cursor:e?"pointer":"default","&:hover .MuiTableCell-root":{backgroundColor:"inherit !important"},...o[t]?o[t]:{},...r===t?{background:`linear-gradient(270deg, ${Ze[200]+xn[90]}, ${qo[100]}, ${hA[50]})`,backgroundSize:"600% 600%",animation:"loading-gradient-row-table 1.5s ease infinite"}:{}});function Sk({row:e,index:A,rowId:t,onSelectRow:o,onDeleteRow:r,onInfoRow:i,onCopyRow:s,onHistoryRow:a,onUpdateRow:l,getActionIcon:d,getRowMenu:u,onDisabled:p}){const[f,h]=F.useState(!1),m=t;if(m===Rr.TOTAL||m===Rr.TOTAL_INCOME)return null;const g=p?p(e,A):{...g2},C=g.DISABLED_ROW||g.DISABLED_ALL_ACTIONS,b=()=>u?u(e,A).map(q=>({...q,onClick:()=>{q.onClick(),h(!1)}})):[];return c.jsxs(c.Fragment,{children:[o&&c.jsx(ye,{icon:"remove_red_eye",onClick:q=>{q.stopPropagation(),o(e,A)},disabled:C||g.SELECT}),r&&c.jsx(ye,{icon:"delete",onClick:q=>{q.stopPropagation(),r(e,A)},sx:{color:C||g.DELETE?Ve[500]:xt[500]},disabled:C||g.DELETE}),i&&c.jsx(ye,{icon:"view_cozy",onClick:q=>{q.stopPropagation(),i(e,A)},disabled:C||g.INFO}),s&&c.jsx(ye,{icon:d&&d(e,A,"COPY")||"content_copy",onClick:q=>{q.stopPropagation(),s(e,A),window.scrollTo({top:0,behavior:"smooth"})},disabled:C||g.COPY}),a&&c.jsx(ye,{icon:"history",onClick:q=>{q.stopPropagation(),a(e,A)},disabled:C||g.HISTORY_GET_ROW_MENU}),l&&c.jsx(ye,{icon:d&&d(e,A,"UPDATE")||"settings",onClick:q=>{q.stopPropagation(),l(e,A),window.scrollTo({top:0,behavior:"smooth"})},disabled:C||g.UPDATE}),u&&(g.DISABLED_GET_ROW_MENU?c.jsx(ye,{icon:"open_in_browser",disabled:C||g.DISABLED_GET_ROW_MENU,onClick:q=>q.stopPropagation()}):c.jsx(an,{style:{cursor:"pointer",display:"flex",alignItems:"center"},placement:"bottom-end",open:f,onOpen:()=>h(!0),onClose:()=>h(!1),content:c.jsx(O5,{list:b()}),children:c.jsx(ye,{icon:"open_in_browser",onClick:q=>q.stopPropagation()})}))]})}function Ek({columns:e,row:A,indexRow:t,indexLoadingRow:o,rowSx:r={},getRowId:i,onClickRow:s,onDisabled:a,onClickSelectRow:l=!1,onSelectRowById:d,enableTree:u=!1,rowLevels:p={},rangeSelection:f}){const{palette:h}=I.useTheme(),m=i(A),g=a?a(A,t):{...g2},C=F.useCallback((w,y)=>{const S=y||"";return c.jsxs(GA,{sx:{color:Cr[950]},children:[w,c.jsx(ye,{icon:"content_copy",sx:{color:Cr[950],fontSize:so.medium},onClick:v=>{v.stopPropagation(),S&&navigator.clipboard.writeText(S)}})]})},[]),b=!!(l&&d),q=!!(s||b);return c.jsx(I.Fade,{in:!0,timeout:t*120,children:c.jsx(I.TableRow,{hover:!0,tabIndex:-1,onClick:()=>{s==null||s(A,t),b&&(d==null||d(m))},sx:{...j5(q,h,t,r,o),...m===Rr.TOTAL?{backgroundColor:Ze[50],"& .MuiTableCell-root":{backgroundColor:Ze[50]},"& *":{fontWeight:"bold"}}:{},...m===Rr.TOTAL_INCOME?{backgroundColor:Ve[300],"& .MuiTableCell-root":{backgroundColor:Ve[300]},"& *":{fontWeight:"bold"}}:{},'& .MuiTableCell-root[aria-selected="true"]':{backgroundColor:`${Ze[100]} !important`,boxShadow:`inset 0 0 0 1px ${Ze[300]}`}},children:e.map((w,y)=>{const S=u?p[m]??0:0,v=u?e.findIndex(M=>M.id!=="treeToggle"):-1,T=u&&y===v&&w.id!=="treeToggle";return c.jsx(I.TableCell,{"data-table-column-id":w.id,...f==null?void 0:f.getCellProps(t,w.id),align:w.align,sx:go(N5(w,h,g.DISABLED_ROW),{overflowWrap:"anywhere"},T?{pl:M=>`calc(${M.spacing(1)} + ${S*16}px)`}:void 0),onClick:w.id==="actions"||w.id==="selectCheckbox"?M=>{M.stopPropagation()}:void 0,children:(()=>{const M=A[w.id],D=Gn(w.render?w.render(A,t):M);if(!w.copyable)return D;const B=typeof w.copyable=="object"&&w.copyable.getValue?String(w.copyable.getValue(A,t)||""):String(M||"");return C(D,B)})()},w.id)})})})}const Ik={visibleRows:[],rowLevels:{},hasChildrenById:{}},Tk=({rows:e,enableTree:A,expandedRowIds:t,getRowId:o,getChildren:r})=>{if(!A)return{...Ik,visibleRows:e};const i={},s={},a=[],l=(d,u)=>{d.forEach(p=>{const f=o(p),h=r(p);i[f]=u,s[f]=h.length>0,a.push(p),h.length>0&&t.has(f)&&l(h,u+1)})};return l(e,0),{visibleRows:a,rowLevels:i,hasChildrenById:s}},Dk=({row:e,getRowId:A,rowLevels:t,hasChildrenById:o,expandedRowIds:r,onToggle:i})=>{const s=A(e),a=t[s]??0,l=o[s],d=r.has(s),u=16,p=Math.max(a*u+14,14),f=a*u+7;return c.jsxs(Xe,{alignItems:"stretch",sx:{cursor:l?"pointer":"default",minHeight:"100%"},onClick:h=>{l&&(h.stopPropagation(),i(s))},children:[c.jsx(I.Stack,{sx:{position:"relative",width:p,flexShrink:0,alignSelf:"stretch",minHeight:"100%"},children:a>0&&c.jsxs(c.Fragment,{children:[c.jsx(I.Stack,{sx:{position:"absolute",left:`${f}px`,top:"-1px",bottom:"50%",borderLeft:`1px solid ${Ve[300]}`}}),c.jsx(I.Stack,{sx:{position:"absolute",left:`${f}px`,top:"50%",width:`${u/2}px`,borderBottom:`1px solid ${Ve[300]}`,transform:"translateY(-50%)"}})]})}),c.jsx(Xe,{sx:{minHeight:"100%"},children:l?c.jsx(ye,{icon:d?"expand_more":"chevron_right"}):c.jsx(I.Stack,{sx:{width:8,height:8,borderRadius:"50%",bgcolor:Ve[500]}})})]})},Bk=({children:e,onScroll:A})=>c.jsx(I.Stack,{sx:{overflowY:A?"hidden":"auto",flex:1,...A?{minHeight:0}:{}},children:c.jsx(I.TableContainer,{onScroll:A,sx:{maxHeight:"100%",overflow:"auto",...A?{flex:1,minHeight:0}:{}},children:e})});var RA=(e=>(e.NONE="none",e.LEFT="left",e.RIGHT="right",e))(RA||{});const Nr=160,Ok=60,kk=1200,U1=10,Pk=6,Fa='input,textarea,select,button,a,[role="button"],[contenteditable]:not([contenteditable="false"]),[data-table-no-range],.material-symbols-rounded',F5=100,jr=50,z1=1e3,Mk=24,Rk=12,Nk="sevago.table.v1",vi=new Set(["actions","selectCheckbox","treeToggle","collapseToggle"]),L5={allView:"Tất cả",viewMode:"Chế độ xem",defaultView:"Mặc định",unsavedChanges:"Có thay đổi chưa lưu trong view",undoChanges:"Hoàn tác",save:"Lưu",cancel:"Hủy",copy:"Sao chép",copyError:"Không thể sao chép. Hãy chọn cột và nhấn Ctrl/Cmd+C.",hideColumn:"Ẩn cột",restoreColumns:"Hiển thị lại cột",columns:"Cột và view",close:"Đóng",show:"Hiển thị",moveLeft:"Chuyển sang trái",moveRight:"Chuyển sang phải",pin:"Ghim cột",unpinned:"Không ghim",pinLeft:"Ghim trái",pinRight:"Ghim phải",resize:"Đổi độ rộng",reset:"Khôi phục mặc định",views:"view đã lưu",viewName:"Tên view",saveView:"Lưu cấu hình hiện tại thành view mới",updateView:"Cập nhật view",renameView:"Đổi tên view",deleteView:"Xóa view",currentLayout:"view hiện tại",modified:"Đã thay đổi",localPersistence:"Tự động lưu cho người dùng này trong trình duyệt hiện tại.",sessionOnly:"Chưa bật lưu view. Truyền tableId và userId để ghi nhớ khi mở lại.",storageError:"Không đọc hoặc lưu được view trong trình duyệt. Bạn vẫn có thể tiếp tục dùng bảng.",rangeHint:"Bấm header chọn cột; kéo header hoặc ô để chọn vùng, kéo icon tay nắm để đổi thứ tự cột. Ctrl+C để sao chép sang Excel. Esc để bỏ chọn.",selectedCells:"Số ô đã chọn",viewNameRequired:"Vui lòng nhập tên view.",viewNameTooLong:"Tên view vượt quá độ dài cho phép."},Q5=e=>dt.object({name:dt.string().trim().required(e.viewNameRequired).max(jr,e.viewNameTooLong)}),V1=dt.object({id:dt.string().required(),width:dt.number().test("finite","Độ rộng cột không hợp lệ",e=>e===void 0||Number.isFinite(e)).optional(),hidden:dt.boolean().optional(),pin:dt.mixed().oneOf(Object.values(RA)).optional()}),jk=dt.object({version:dt.mixed().oneOf([1]).required(),columns:dt.array().of(V1).max(z1).required(),views:dt.array().of(dt.object({id:dt.string().required(),name:dt.string().max(jr).required(),columns:dt.array().of(V1).max(z1).required()})).max(F5).required(),activeViewId:dt.string().optional()});function Fk(e){const A=F.useRef(e);A.current=e;const t=F.useRef(void 0),[o,r]=F.useState(),i=!!e.onColumnMove;return F.useEffect(()=>{if(!i)return;const s=()=>{t.current=void 0,r(void 0)},a=d=>{var q,w;const u=t.current;if(!u||u.pointerId!==d.pointerId)return;if(!(d.buttons&1)){s();return}const p=Math.abs(d.clientX-u.x),f=Math.abs(d.clientY-u.y);if(u.mode==="pending"&&Math.max(p,f)>=Pk&&(u.mode="move"),u.mode!=="move")return;const h=(q=document.elementFromPoint(d.clientX,d.clientY))==null?void 0:q.closest("th[data-table-column-id]"),m=(h==null?void 0:h.closest("table"))===u.table?h==null?void 0:h.dataset.tableColumnId:void 0,g=(w=A.current.layoutController)==null?void 0:w.columnControls,C=g==null?void 0:g.find(y=>y.id===u.id),b=g==null?void 0:g.find(y=>y.id===m);u.targetId=b&&b.pin===(C==null?void 0:C.pin)&&m!==u.id?m:void 0,r(u.targetId)},l=d=>{var p,f;const u=t.current;!u||u.pointerId!==d.pointerId||(u.mode==="move"&&u.targetId&&((f=(p=A.current).onColumnMove)==null||f.call(p,u.id,u.targetId)),s())};return window.addEventListener("pointermove",a),window.addEventListener("pointerup",l),window.addEventListener("pointercancel",s),window.addEventListener("blur",s),()=>{window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",l),window.removeEventListener("pointercancel",s),window.removeEventListener("blur",s)}},[i]),{dropColumnId:o,onPointerDown:(s,a)=>{if(!e.onColumnMove||s.button!==0)return;s.stopPropagation();const l=s.currentTarget.closest("table");l&&(s.preventDefault(),t.current={id:a,pointerId:s.pointerId,x:s.clientX,y:s.clientY,table:l,mode:"pending"})}}}const M2=(e,A)=>({id:e.id,label:e.label,filter:e.filter,width:e.width,align:e.align,alignHead:e.alignHead,sx:go(e.sx,e.headSx),stickyCss:e.stickyCss,rowSpan:A,column:e}),Lk=(e,A)=>{var s,a,l,d,u,p;if(!(A!=null&&A.length))return[e.map(f=>M2(f))];const t=new Map;A.forEach(f=>{f.columnIds.forEach(h=>{t.set(h,f)})});const o=[],r=[];let i=0;for(;i<e.length;){const f=e[i],h=t.get(f.id);if(!h){o.push(M2(f,2)),i+=1;continue}let m=1;for(;i+m<e.length&&((s=t.get(e[i+m].id))==null?void 0:s.id)===h.id&&((a=e[i+m].stickyCss)==null?void 0:a.left)!=null==(((l=f.stickyCss)==null?void 0:l.left)!=null)&&((d=e[i+m].stickyCss)==null?void 0:d.right)!=null==(((u=f.stickyCss)==null?void 0:u.right)!=null);)m+=1;o.push({id:`${h.id}-${i}`,label:h.label,alignHead:h.align??"center",sx:h.sx,colSpan:m,stickyCss:f.stickyCss?{...f.stickyCss,right:(p=e[i+m-1].stickyCss)==null?void 0:p.right}:void 0});for(let g=0;g<m;g+=1)r.push(M2(e[i+g]));i+=m}return r.length?[o,r]:[e.map(f=>M2(f))]},qi=e=>e.configurable!==!1&&!vi.has(e.id),Qk=(e,A)=>{const t=Math.max(1,e.minWidth??Ok),o=Math.max(t,e.maxWidth??kk);return Math.round(Math.min(o,Math.max(t,Number.isFinite(A)?A:Nr)))},Hk=(e,A)=>`${Nk}:${encodeURIComponent(A)}:${encodeURIComponent(e)}`,oo=(e,A=[])=>{const t=new Map(e.map(a=>[a.id,a])),o=new Set,r=[];[...A,...e.map(a=>({id:a.id}))].forEach(a=>{var u,p;const l=t.get(a.id);if(!l||o.has(a.id))return;o.add(a.id);const d=qi(l);r.push({id:l.id,width:d?Qk(l,a.width??l.width??Nr):l.width,hidden:d&&a.hidden===!0,pin:a.pin??(((u=l.stickyCss)==null?void 0:u.left)!=null?RA.LEFT:((p=l.stickyCss)==null?void 0:p.right)!=null?RA.RIGHT:RA.NONE)})});const s=r.filter(a=>qi(t.get(a.id)));return s.length&&s.every(a=>a.hidden)&&(s[0].hidden=!1),[...r.filter(a=>a.pin===RA.LEFT),...r.filter(a=>a.pin!==RA.LEFT&&a.pin!==RA.RIGHT),...r.filter(a=>a.pin===RA.RIGHT)]},Uk=(e,A)=>{const t=new Map(e.map(d=>[d.id,d])),o=oo(e,A).filter(d=>!d.hidden),r=[...o.filter(d=>vi.has(d.id)&&d.id!=="actions"),...o.filter(d=>!vi.has(d.id)),...o.filter(d=>d.id==="actions")],i=[...r.filter(d=>d.pin===RA.LEFT),...r.filter(d=>d.pin!==RA.LEFT&&d.pin!==RA.RIGHT),...r.filter(d=>d.pin===RA.RIGHT)];let s=0,a=0;const l=new Map;return[...i].reverse().forEach(d=>{d.pin===RA.RIGHT&&(l.set(d.id,a),a+=d.width??Nr)}),i.map(d=>{const u=t.get(d.id),p={...u.stickyCss};delete p.left,delete p.right;const f=d.pin===RA.LEFT||d.pin===RA.RIGHT?{...p,[d.pin]:d.pin===RA.LEFT?s:l.get(d.id),zIndex:1.5}:void 0;return d.pin===RA.LEFT&&(s+=d.width??Nr),{...u,width:d.width,stickyCss:f}})},W1=e=>jk.validateSync(JSON.parse(e),{strict:!0}),G1={padding:ve},zk={open:"Bộ lọc",apply:"Áp dụng",clear:"Xóa bộ lọc khỏi cột",cancel:"Hủy",emptyOptions:"Không có giá trị phù hợp",loading:"Đang tải...",loadMore:"Tải thêm",searchLoaded:"Tìm trong các giá trị đã tải. Tải thêm để tìm các giá trị khác.",values:"Lọc theo giá trị",search:"Tìm kiếm giá trị",selectAll:"Chọn tất cả",deselectAll:"Bỏ chọn tất cả",selectLoaded:"Chọn các giá trị đã tải",deselectLoaded:"Bỏ chọn các giá trị đã tải",blanks:"(Trống)",sortAscending:"Sắp xếp tăng dần",sortDescending:"Sắp xếp giảm dần",sortTextAscending:"Sắp xếp từ A đến Z",sortTextDescending:"Sắp xếp từ Z đến A",sortNumberAscending:"Sắp xếp từ nhỏ đến lớn",sortNumberDescending:"Sắp xếp từ lớn đến nhỏ",sortDateAscending:"Sắp xếp từ cũ đến mới",sortDateDescending:"Sắp xếp từ mới đến cũ",clearSort:"Xóa sắp xếp"},Vk=(e,A=Qn.TEXT)=>{const t={...zk,...e},o={[Qn.TEXT]:[t.sortTextAscending,t.sortTextDescending],[Qn.NUMBER]:[t.sortNumberAscending,t.sortNumberDescending],[Qn.DATE]:[t.sortDateAscending,t.sortDateDescending],[Qn.BOOLEAN]:[t.sortAscending,t.sortDescending]};return{...t,sortAscending:(e==null?void 0:e.sortAscending)??o[A][0],sortDescending:(e==null?void 0:e.sortDescending)??o[A][1]}},Y1=(e,A,t)=>{const o=(e==null?void 0:e.mode)??Pt.EXCLUDE,r=(e==null?void 0:e.values)??[],i=o===Pt.INCLUDE===t?[...r,...A.filter(s=>!r.includes(s))]:r.filter(s=>!A.includes(s));return o===Pt.EXCLUDE&&!i.length?void 0:{mode:o,values:i}},m2=({content:e,contentHref:A,href:t,type:o="info"})=>{const{palette:r}=I.useTheme(),i={info:{icon:"error",title:"Info",color:r.success.dark},recommend:{icon:"gpp_maybe",title:"Recommend",color:r.info.dark},warning:{icon:"report",title:"Warning",color:r.warning.dark},error:{icon:"emergency_home",title:"Error",color:r.error.dark}};return c.jsxs(I.Stack,{sx:{gap:1,borderRadius:vA,borderColor:i[o].color,borderStyle:"solid",borderWidth:"1px 1px 1px 3px",padding:1.5},children:[c.jsxs(Xe,{sx:{gap:yA},children:[c.jsx(ye,{icon:i[o].icon,sx:{color:i[o].color}}),c.jsx(I.Typography,{sx:{color:i[o].color},variant:"body2",children:i[o].title})]}),c.jsxs(I.Typography,{sx:{color:i[o].color},children:[e,t&&A&&c.jsxs(F.Fragment,{children:[" ",c.jsx(Eo,{href:t,children:A})]})]})]})},Wk=I.createFilterOptions();function Gk({config:e,selection:A,labels:t,onChange:o}){const[r,i]=F.useState(""),s=e.optionsComplete===!1&&e.allowPartialSelection,a=e.options??[],l=Wk(a,{inputValue:r,getOptionLabel:f=>f.value?f.label:t.blanks}),d=e.disabled||e.loading,u=f=>!A||(A.mode===Pt.INCLUDE?A.values.includes(f):!A.values.includes(f)),p=f=>{if(!r&&e.optionsComplete!==!1&&!a.some(m=>m.disabled)){o(f?void 0:{mode:Pt.INCLUDE,values:[]});return}const h=l.filter(m=>!m.disabled).map(m=>m.value);o(Y1(A,h,f))};return c.jsxs(I.Stack,{gap:ve,children:[c.jsxs(GA,{children:[c.jsx(sA,{variant:"text",size:"small",content:s?t.selectLoaded:t.selectAll,disabled:d||!l.length,onClick:()=>p(!0)}),c.jsx(sA,{variant:"text",size:"small",content:s?t.deselectLoaded:t.deselectAll,disabled:d||!l.length,onClick:()=>p(!1)})]}),c.jsx(Is,{value:r,placeholder:e.placeholder??t.search,disabled:e.disabled,slotProps:{htmlInput:{"aria-label":t.search}},onChange:f=>i(f.target.value)}),s&&c.jsx(m2,{content:t.searchLoaded}),e.loading&&c.jsx(I.LinearProgress,{"aria-label":t.loading}),c.jsxs(I.Stack,{role:"group","aria-label":t.values,sx:{maxHeight:224,overflowY:"auto"},gap:ve,children:[l.map(f=>c.jsxs(GA,{children:[c.jsx(F0,{label:f.value?f.label:t.blanks,checked:u(f.value),disabled:d||f.disabled,onChange:(h,m)=>o(Y1(A,[f.value],m))}),e.optionsComplete!==!1&&f.count!==void 0&&c.jsx(xA,{content:`(${M3(f.count)})`,sx:{color:Je[500]}})]},f.value)),!l.length&&!e.loading&&c.jsx(xA,{content:t.emptyOptions})]})]})}function Yk({config:e,labels:A,rule:t,onApply:o,onClear:r,onCancel:i}){const s=l=>e.optionsComplete!==!1||!l.selection||e.allowPartialSelection&&l.selection.mode===Pt.INCLUDE,a=Si.useFormik({initialValues:e.allowPartialSelection&&e.optionsComplete===!1&&!t.selection?{selection:{mode:Pt.INCLUDE,values:[]}}:t,onSubmit:l=>{e.disabled||e.loading||e.errorText||!s(l)||o(l)}});return c.jsxs(c.Fragment,{children:[c.jsxs(I.Stack,{sx:{overflowY:"auto",minHeight:0,...G1},children:[e.render?e.render({rule:a.values,onRuleChange:l=>a.setValues(l),apply:()=>a.handleSubmit(),clear:r}):c.jsx(Gk,{config:e,labels:A,selection:a.values.selection,onChange:l=>a.setFieldValue("selection",l)}),(e.helperText||e.errorText)&&c.jsx(I.Stack,{role:e.errorText?"alert":void 0,sx:{color:e.errorText?xt[500]:Ve[700]},children:e.errorText||e.helperText})]}),c.jsx(I.Divider,{}),c.jsxs(Ui,{gap:ve,sx:{...G1,flexShrink:0},children:[c.jsx(sA,{variant:"outlined",content:A.cancel,onClick:i}),c.jsx(sA,{content:A.apply,disabled:e.disabled||e.loading||!!e.errorText||!s(a.values),onClick:l=>{l.preventDefault(),a.handleSubmit()}})]})]})}function Kk({columnId:e,columnLabel:A,config:t,rule:o,sort:r,labels:i,onRuleChange:s,onSortChange:a,onOpenChange:l}){const[d,u]=F.useState(),p=F.useId(),f=t.key??e,h=Vk({...i,...t.labels},t.dataType),m=!!(o!=null&&o.selection),g=!!s,C=(r==null?void 0:r.key)===f,b=()=>{u(void 0),l==null||l(f,!1)},q=y=>{t.disabled||(s==null||s(f,y!=null&&y.selection?y:void 0),b())},w=y=>{a==null||a(y?{key:f,direction:y}:void 0),b()};return c.jsxs(I.Stack,{onClick:y=>y.stopPropagation(),children:[c.jsx(I.IconButton,{size:"small",sx:{color:m||C?Ze[500]:Ve[700],"&:hover":{backgroundColor:Ze[50]},"&.Mui-disabled":{color:Ve[500]}},disabled:t.disabled,"aria-label":`${h.open}: ${A??e}`,"aria-haspopup":"dialog","aria-expanded":!!d,"aria-controls":d?p:void 0,onClick:y=>{u(y.currentTarget),l==null||l(f,!0)},children:c.jsx(ye,{icon:m?"filter_alt":"filter_list",fill:m?1:0})}),c.jsxs(I.Popover,{id:p,open:!!d,anchorEl:d,onClose:b,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{role:"dialog","aria-label":`${h.open}: ${A??e}`,sx:{width:320,maxWidth:"90vw",maxHeight:"90vh",overflow:"hidden",display:"flex",flexDirection:"column",borderRadius:vA,backgroundColor:hA[50],color:Ve[900]}}},children:[c.jsxs(I.MenuList,{dense:!0,sx:{"& .MuiMenuItem-root:hover":{backgroundColor:qo[100]},"& .MuiMenuItem-root.Mui-selected":{backgroundColor:Ze[50],color:Ze[500]},"& .MuiMenuItem-root.Mui-selected:hover":{backgroundColor:Ze[100]},"& .MuiMenuItem-root.Mui-disabled":{color:Ve[700],opacity:1}},children:[t.sortable!==!1&&a&&[c.jsx(I.MenuItem,{disabled:t.disabled,selected:C&&(r==null?void 0:r.direction)===sn.ASC,onClick:()=>w(sn.ASC),children:c.jsxs(Xe,{gap:ve,children:[c.jsx(ye,{icon:"arrow_upward"}),c.jsx(xA,{content:h.sortAscending})]})},"ascending"),c.jsx(I.MenuItem,{disabled:t.disabled,selected:C&&(r==null?void 0:r.direction)===sn.DESC,onClick:()=>w(sn.DESC),children:c.jsxs(Xe,{gap:ve,children:[c.jsx(ye,{icon:"arrow_downward"}),c.jsx(xA,{content:h.sortDescending})]})},"descending")],C&&a&&t.sortable!==!1&&c.jsx(I.MenuItem,{disabled:t.disabled,onClick:()=>w(),children:c.jsx(xA,{content:h.clearSort})}),g&&c.jsx(I.MenuItem,{disabled:t.disabled||!m,onClick:()=>q(),children:c.jsxs(Xe,{gap:ve,children:[c.jsx(ye,{icon:"filter_alt_off"}),c.jsx(xA,{content:h.clear})]})})]}),c.jsx(I.Divider,{}),d&&g&&c.jsx(Yk,{config:t,labels:h,rule:o??{},onApply:q,onClear:()=>q(),onCancel:b})]})]})}function Xk({columnId:e,name:A,width:t,label:o,onResize:r}){const i=F.useRef(void 0);return c.jsx(I.Box,{"data-table-no-range":!0,"data-table-copy-ignore":!0,role:"separator","aria-orientation":"vertical","aria-label":`${o}: ${A}`,"aria-valuenow":t,tabIndex:0,draggable:!1,onDragStart:s=>{s.preventDefault(),s.stopPropagation()},onPointerDown:s=>{var a;s.button===0&&(s.preventDefault(),s.stopPropagation(),i.current={x:s.clientX,width:((a=s.currentTarget.parentElement)==null?void 0:a.getBoundingClientRect().width)??t??0},s.currentTarget.setPointerCapture(s.pointerId))},onPointerMove:s=>{i.current&&r(e,i.current.width+s.clientX-i.current.x)},onPointerUp:s=>{i.current=void 0,s.currentTarget.hasPointerCapture(s.pointerId)&&s.currentTarget.releasePointerCapture(s.pointerId)},onPointerCancel:()=>{i.current=void 0},onClick:s=>s.stopPropagation(),onKeyDown:s=>{(s.key==="ArrowLeft"||s.key==="ArrowRight")&&(s.preventDefault(),s.stopPropagation(),r(e,(t??0)+(s.key==="ArrowRight"?U1:-U1)))},sx:{position:"absolute",right:0,top:0,bottom:0,width:ve,cursor:"col-resize",touchAction:"none","&:hover, &:focus-visible":{backgroundColor:Ze[200]}}})}function Jk({context:e,onClose:A,controller:t,copyColumn:o,labels:r}){const[i,s]=F.useState(!1),[a,l]=F.useState(!1),d=t==null?void 0:t.columnControls.find(p=>p.id===e.id),u=p=>{t==null||t.setPin(e.id,(d==null?void 0:d.pin)===p?RA.NONE:p),A()};return c.jsx(c.Fragment,{children:c.jsxs(I.Menu,{open:!0,anchorReference:"anchorPosition",anchorPosition:{top:e.y,left:e.x},onClose:A,children:[c.jsxs(I.MenuItem,{disabled:!o||a,onClick:async()=>{l(!0);try{await(o==null?void 0:o(e.id,e.table)),A()}catch{s(!0)}finally{l(!1)}},children:[c.jsx(I.ListItemIcon,{children:c.jsx(ye,{icon:"content_copy"})}),r.copy]}),t&&c.jsx(I.Divider,{}),t&&c.jsxs(I.MenuItem,{disabled:!(d!=null&&d.canHide),onClick:()=>{t.setVisible(e.id,!1),A()},children:[c.jsx(I.ListItemIcon,{children:c.jsx(ye,{icon:"visibility_off"})}),r.hideColumn]}),t&&c.jsxs(I.MenuItem,{selected:(d==null?void 0:d.pin)===RA.LEFT,onClick:()=>u(RA.LEFT),children:[c.jsx(I.ListItemIcon,{children:c.jsx(ye,{icon:"first_page"})}),r.pinLeft]}),t&&c.jsxs(I.MenuItem,{selected:(d==null?void 0:d.pin)===RA.RIGHT,onClick:()=>u(RA.RIGHT),children:[c.jsx(I.ListItemIcon,{children:c.jsx(ye,{icon:"last_page"})}),r.pinRight]}),i&&c.jsx(I.MenuItem,{role:"presentation",tabIndex:-1,children:c.jsx(I.Stack,{role:"alert",children:c.jsx(m2,{type:"error",content:r.copyError})})})]})})}function Zk({columnId:e,controller:A,firstColumn:t,lastColumn:o}){const{columnControls:r,labels:i}=A,s=r.findIndex(u=>u.id===e);if(s<0)return null;const a=[];for(let u=s-1;u>=0&&r[u].hidden;u--)a.unshift(r[u]);const l=r.slice(s+1),d=l.length>0&&l.every(u=>u.hidden)?l:[];return c.jsx(c.Fragment,{children:[a,d].map((u,p)=>u.length>0&&c.jsx(I.Box,{"data-table-no-range":!0,"data-table-copy-ignore":!0,sx:{position:"absolute",[p===0?"left":"right"]:0,top:"50%",transform:`translate(${p===0?t?"0":"-50%":o?"0":"50%"}, -50%)`,zIndex:5,width:TA,height:at.small},children:c.jsx(I.Tooltip,{title:`${i.restoreColumns}: ${u.map(f=>f.label).join(", ")}`,children:c.jsx(qt,{size:"small",icon:"unfold_more","aria-label":`${i.restoreColumns}: ${u.map(f=>f.label).join(", ")}`,onClick:f=>{f.stopPropagation();const h=new Set(u.map(m=>m.id));A.changeLayout(A.layout.map(m=>h.has(m.id)?{...m,hidden:!1}:m))},sx:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%) rotate(90deg)",width:at.small,height:TA,padding:0,minWidth:0,backgroundColor:"background.paper",border:1,borderColor:"divider"}})})},p))})}const K1=44;function _k({columns:e,headerGroups:A,filterLabels:t,filterRules:o,onFilterRuleChange:r,columnSort:i,onColumnSortChange:s,onFilterOpenChange:a,stickyHeader:l=!0,onColumnResize:d,onColumnMove:u,layoutLabels:p=L5,rangeSelection:f,onCopyColumn:h,layoutController:m}){const[g,C]=F.useState(),b=Fk({onColumnMove:u,layoutController:m}),q=F.useMemo(()=>Lk(e,A),[e,A]),w=q.length>1;return c.jsxs(c.Fragment,{children:[c.jsx(I.TableHead,{sx:{'& th[aria-selected="true"]':{backgroundColor:`${Ze[100]} !important`}},children:q.map((y,S)=>c.jsx(I.TableRow,{children:y.map(v=>{var D,B,k,x;const T=v.column&&qi(v.column),M=typeof v.label=="string"?v.label:v.id;return c.jsxs(I.TableCell,{"data-table-column-id":(D=v.column)==null?void 0:D.id,...v.column?f==null?void 0:f.getCellProps(-1,v.id):{},onContextMenu:v.column&&(m||f)?O=>{if(!T)return;const P=O.currentTarget.closest("table");P&&(O.preventDefault(),f==null||f.selectColumn(v.id,P),C({id:v.id,x:O.clientX,y:O.clientY,table:P}))}:void 0,align:v.align,colSpan:v.colSpan,rowSpan:v.rowSpan,sx:go({...v.width!=null?{width:`${v.width}px !important`,minWidth:`${v.width}px !important`,maxWidth:`${v.width}px !important`}:{},height:w?K1:void 0,position:l?void 0:"relative",fontWeight:550,userSelect:T&&u?"none":void 0,boxShadow:b.dropColumnId===v.id?`inset 3px 0 ${Ze[500]}`:void 0,padding:ve,borderRadius:"0 !important",backgroundColor:Je[50],verticalAlign:"middle",textAlign:v.alignHead?v.alignHead:"center",borderTop:S===0?Vo:"none",top:w?S*K1:0},v.stickyCss?{...v.stickyCss,position:"sticky",backgroundColor:hA[50],zIndex:4,borderRight:((B=v.stickyCss)==null?void 0:B.left)!=null?Vo:""}:{},v.sx),children:[c.jsxs(Xe,{justifyContent:v.alignHead??"center",sx:{gap:0},children:[T&&u&&c.jsx(qt,{icon:"drag_indicator","data-table-column-drag-handle":!0,"data-table-no-range":!0,"data-table-copy-ignore":!0,"aria-label":`${p.moveLeft} / ${p.moveRight}: ${M}`,onPointerDown:O=>b.onPointerDown(O,v.id),onClick:O=>O.stopPropagation(),onKeyDown:T&&u?O=>{if(!O.altKey||!["ArrowLeft","ArrowRight"].includes(O.key))return;O.preventDefault(),O.stopPropagation();const P=m==null?void 0:m.columnControls.find(N=>N.id===v.id),R=O.key==="ArrowLeft"?P==null?void 0:P.moveLeftId:P==null?void 0:P.moveRightId;R&&u(v.id,R)}:void 0,sx:{cursor:"grab",touchAction:"none",flexShrink:0}}),c.jsx(I.Typography,{sx:{minWidth:0,whiteSpace:"normal",overflowWrap:"anywhere"},children:v.label}),v.filter&&(r||s&&v.filter.sortable!==!1)&&c.jsx(Kk,{columnId:v.id,columnLabel:typeof v.label=="string"?v.label:void 0,config:v.filter,labels:t,rule:o==null?void 0:o[v.filter.key??v.id],onRuleChange:r,sort:i,onSortChange:s,onOpenChange:a})]}),v.column&&m&&c.jsx(Zk,{columnId:v.id,controller:m,firstColumn:((k=e[0])==null?void 0:k.id)===v.id,lastColumn:((x=e[e.length-1])==null?void 0:x.id)===v.id}),T&&d&&c.jsx(Xk,{columnId:v.id,name:M,width:v.width,label:p.resize,onResize:d})]},v.id)})},S))}),g&&c.jsx(Jk,{context:g,onClose:()=>C(void 0),controller:m,copyColumn:h,labels:p})]})}const $k=({columns:e,headerGroups:A,filterLabels:t,filterRules:o,onFilterRuleChange:r,columnSort:i,onColumnSortChange:s,onFilterOpenChange:a,rows:l=[],tableEventProps:d,onColumnResize:u,onColumnMove:p,layoutLabels:f,rangeSelection:h,onCopyColumn:m,layoutController:g,loading:C=!1,onLoadMore:b,hasMore:q=!1,loadingMore:w=!1,stickyHeader:y=!0,tableSx:S,tableRef:v,renderRow:T,renderLoading:M,renderEmpty:D})=>{const B=F.useRef(!1),k=F.useRef(0),x=C&&!w;F.useEffect(()=>{B.current=!1},[C,w,l.length,q]);const O=P=>{const R=P.currentTarget,N=R.scrollTop>k.current;k.current=R.scrollTop,!(!N||!b||!q||C||w||B.current||R.scrollHeight<=R.clientHeight||R.scrollHeight-R.scrollTop-R.clientHeight>M5)&&(B.current=!0,b())};return c.jsx(Bk,{onScroll:b?O:void 0,children:c.jsxs(I.Table,{...d,ref:v,stickyHeader:y,sx:[{height:x||l.length===0?"100%":"none",borderCollapse:"separate !important","& .MuiTableCell-root":{borderRight:Vo,borderBottom:Vo,"&:first-of-type":{borderLeft:Vo}}},...Array.isArray(S)?S:[S]],children:[c.jsx(_k,{columns:e,headerGroups:A,filterLabels:t,filterRules:o,onFilterRuleChange:r,columnSort:i,onColumnSortChange:s,onFilterOpenChange:a,onColumnResize:u,onColumnMove:p,layoutLabels:f,rangeSelection:h,onCopyColumn:m,layoutController:g,stickyHeader:y}),c.jsxs(I.TableBody,{children:[x?c.jsx(I.TableRow,{children:c.jsx(I.TableCell,{colSpan:e.length,children:M()})}):l.length?l.map((P,R)=>c.jsx(F.Fragment,{children:T(P,R)},R)):c.jsx(I.TableRow,{children:c.jsx(I.TableCell,{colSpan:e.length,children:D()})}),!x&&w&&c.jsx(I.TableRow,{children:c.jsx(I.TableCell,{colSpan:e.length,children:M()})})]})]})})};function eP({controller:e}){const{labels:A,activeView:t,modified:o}=e,r=Si.useFormik({initialValues:{name:""},validationSchema:Q5(A),validateOnMount:!0,onSubmit:({name:i},s)=>{e.saveView(i)&&s.resetForm()}});return c.jsxs(I.Stack,{sx:{gap:ve},children:[c.jsx(Is,{name:"name",label:A.viewName,value:r.values.name,inputProps:{maxLength:jr,"aria-label":A.viewName},onChange:r.handleChange,onBlur:r.handleBlur,error:r.touched.name?r.errors.name:void 0}),c.jsxs(Xe,{sx:{gap:ve,flexWrap:"wrap"},children:[c.jsx(sA,{content:A.saveView,disabled:!r.isValid||!e.canSaveView(r.values.name),onClick:()=>r.handleSubmit()}),c.jsx(sA,{content:A.updateView,disabled:!t||!o,onClick:e.updateView}),c.jsx(sA,{content:A.renameView,disabled:!r.isValid||!e.canRenameView(r.values.name),onClick:()=>{e.renameView(r.values.name)&&r.resetForm()}}),c.jsx(sA,{content:A.deleteView,disabled:!t,color:"error",onClick:()=>e.deleteView()})]})]})}function AP({open:e,onClose:A,controller:t}){const{labels:o}=t;return c.jsx(zi,{open:e,onClose:A,label:o.columns,iconLabel:"view_column",closeButton:!1,fullWidth:!0,maxWidth:"md",buttonLeft:{content:o.reset,onClick:t.reset},buttonRight:{content:o.close,onClick:A},nodeContent:c.jsxs(I.Stack,{sx:{gap:TA},children:[c.jsx(m2,{type:t.storageError?"warning":"info",content:t.storageError?o.storageError:t.storageKey?o.localPersistence:o.sessionOnly}),t.columnControls.map(r=>c.jsxs(Xe,{sx:{gap:ve,flexWrap:"wrap"},children:[c.jsx(I.Stack,{sx:{flex:1},children:c.jsx(F0,{label:r.label,checked:!r.hidden,disabled:!r.canHide,inputProps:{"aria-label":`${o.show}: ${r.label}`},onChange:(i,s)=>t.setVisible(r.id,s)})}),c.jsx(qt,{size:"small",icon:"arrow_back","aria-label":`${o.moveLeft}: ${r.label}`,disabled:!r.moveLeftId,onClick:()=>{r.moveLeftId&&t.move(r.id,r.moveLeftId)}}),c.jsx(qt,{size:"small",icon:"arrow_forward","aria-label":`${o.moveRight}: ${r.label}`,disabled:!r.moveRightId,onClick:()=>{r.moveRightId&&t.move(r.id,r.moveRightId)}}),c.jsx(I.Stack,{children:c.jsx(qn,{size:"small",value:r.pin??RA.NONE,options:t.pinOptions,inputProps:{"aria-label":`${o.pin}: ${r.label}`},onChange:i=>t.setPin(r.id,i.target.value)})})]},r.id)),c.jsx(eP,{controller:t})]})})}function tP({controller:e,initialName:A,viewId:t,onSaved:o,onCancel:r}){const{labels:i}=e,s=Si.useFormik({initialValues:{name:A},validationSchema:Q5(i),validateOnMount:!0,onSubmit:({name:a})=>{(t?e.renameView(a,t):e.saveView(a))&&o()}});return c.jsxs(I.Stack,{component:"form",onSubmit:a=>{a.preventDefault(),s.handleSubmit()},sx:{gap:yA},children:[c.jsx(Is,{autoFocus:!0,name:"name",label:i.viewName,value:s.values.name,inputProps:{maxLength:jr,"aria-label":i.viewName},onChange:s.handleChange,onBlur:s.handleBlur,error:s.touched.name?s.errors.name:void 0}),c.jsxs(Ui,{sx:{gap:yA},children:[c.jsx(sA,{type:"submit",content:i.save,disabled:!s.isValid||(t?!e.canRenameView(s.values.name,t):!e.canSaveView(s.values.name))}),c.jsx(sA,{variant:"outlined",content:i.cancel,onClick:r})]})]})}function nP({controller:e}){const{labels:A,activeView:t,modified:o}=e,[r,i]=F.useState(),[s,a]=F.useState(),l=()=>{i(void 0),a(void 0)};return c.jsxs(c.Fragment,{children:[c.jsx(sA,{sx:{maxWidth:"min(350px, 100%)",minWidth:0,"& .MuiTypography-root":{minWidth:0},"& .MuiButton-startIcon, & .MuiButton-endIcon":{flexShrink:0}},variant:"outlined","aria-label":`${A.viewMode}: ${(t==null?void 0:t.name)??A.allView}`,"aria-haspopup":"dialog","aria-expanded":!!r,startIcon:"table_rows",endIcon:"expand_more",onClick:d=>i(d.currentTarget),content:c.jsxs(I.Box,{component:"span",sx:{display:"inline-flex",alignItems:"center",maxWidth:"100%",minWidth:0,gap:yA},children:[c.jsx(I.Box,{component:"span",title:(t==null?void 0:t.name)??A.allView,sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:`${A.viewMode}: ${(t==null?void 0:t.name)??A.allView}`}),o&&c.jsx(I.Box,{component:"span",role:"status","aria-label":A.unsavedChanges,sx:{width:7,height:7,flexShrink:0,borderRadius:"50%",backgroundColor:e0[500]}})]})}),c.jsx(I.Popover,{open:!!r,anchorEl:r,onClose:l,anchorOrigin:{vertical:"bottom",horizontal:"left"},children:c.jsxs(I.Stack,{role:"dialog","aria-label":A.viewMode,sx:{width:350,maxWidth:"calc(100vw - 32px)",padding:ve,gap:yA},children:[c.jsx(xA,{content:A.viewMode}),c.jsxs(I.List,{disablePadding:!0,sx:{maxHeight:280,overflow:"auto"},children:[c.jsx(I.ListItem,{disablePadding:!0,secondaryAction:c.jsx(xA,{content:A.defaultView}),children:c.jsxs(I.ListItemButton,{selected:!t,onClick:()=>{e.applyView(""),l()},sx:{p:yA},children:[c.jsx(I.ListItemIcon,{sx:{minWidth:at.medium},children:!t&&c.jsx(ye,{icon:"check"})}),c.jsx(I.ListItemText,{primary:A.allView})]})}),e.viewOptions.map(d=>c.jsxs(I.ListItem,{disablePadding:!0,sx:{alignItems:"stretch"},children:[c.jsxs(I.ListItemButton,{selected:(t==null?void 0:t.id)===d.value,onClick:()=>{e.applyView(d.value),l()},sx:{padding:yA,minWidth:0,flex:1},children:[c.jsx(I.ListItemIcon,{sx:{minWidth:at.medium},children:(t==null?void 0:t.id)===d.value&&c.jsx(ye,{icon:"check"})}),c.jsx(I.ListItemText,{primary:d.label,sx:{minWidth:0},primaryTypographyProps:{sx:{overflowWrap:"anywhere",whiteSpace:"normal"}}})]}),c.jsxs(Xe,{sx:{gap:0,flexShrink:0},children:[c.jsx(qt,{icon:"edit","aria-label":`${A.renameView}: ${d.label}`,onClick:()=>a({id:d.value,name:d.label})}),c.jsx(qt,{icon:"delete",color:"error","aria-label":`${A.deleteView}: ${d.label}`,onClick:()=>{e.deleteView(d.value),l()}})]})]},d.value))]}),o&&c.jsxs(I.Stack,{sx:{border:1,borderColor:e0[200],backgroundColor:e0[50],borderRadius:QA,padding:yA,gap:yA},children:[c.jsx(xA,{content:`${A.unsavedChanges} "${(t==null?void 0:t.name)??A.allView}".`,sx:{color:e0[800],display:"block",WebkitLineClamp:"unset",overflow:"visible",overflowWrap:"anywhere",whiteSpace:"normal"}}),c.jsxs(Ui,{sx:{gap:yA,flexWrap:"wrap"},children:[c.jsx(sA,{content:t?A.updateView:A.reset,onClick:()=>{t?e.updateView():e.reset(),l()}}),t&&c.jsx(sA,{variant:"outlined",content:A.undoChanges,onClick:()=>{e.applyView(t.id),l()}})]})]}),c.jsx(v5,{dashed:!1}),s?c.jsx(tP,{controller:e,initialName:s.name,viewId:s.id,onSaved:l,onCancel:l},s.id??"new"):c.jsx(sA,{variant:"text",startIcon:"add",content:A.saveView,onClick:()=>a({name:""})})]})})]})}function oP({controller:e,enableManagement:A,enableRange:t,selectedCells:o,actions:r}){const[i,s]=F.useState(!1),{labels:a}=e;return c.jsxs(c.Fragment,{children:[c.jsxs(rA.Stack,{sx:{gap:yA},children:[t&&c.jsx(xA,{sx:{flexBasis:"100%",minWidth:0},content:o?`${a.selectedCells}: ${o}`:a.rangeHint}),c.jsxs(GA,{sx:{gap:yA},children:[A&&c.jsx(nP,{controller:e}),c.jsxs(HA,{sx:{gap:yA},children:[r,A&&c.jsx(an,{content:a.columns,children:c.jsx(qt,{"aria-label":a.columns,icon:"compare_arrows",variant:"outlined",onClick:()=>s(!0)})})]})]})]}),A&&e.storageError&&c.jsx(m2,{type:"warning",content:a.storageError}),A&&c.jsx(AP,{open:i,onClose:()=>s(!1),controller:e})]})}const rP=()=>()=>{},iP=()=>!0,sP=()=>!1,aP=(e,A)=>{const{enableColumnManagement:t,viewPersistence:o,columnLayout:r,defaultColumnLayout:i,onColumnLayoutChange:s,onViewPersistenceError:a}=A,l=F.useSyncExternalStore(rP,iP,sP),d=t&&o&&!Hn(o.tableId)&&!Hn(o.userId)?Hk(o.tableId,o.userId):void 0,u=d??"memory",p=F.useMemo(()=>{const B={version:1,columns:i??[],views:[]};try{const k=d&&l?window.localStorage.getItem(d):void 0;return{scope:u,data:k?W1(k):B}}catch(k){return{scope:u,data:B,error:k}}},[u,d,l]),[f,h]=F.useState(),m=(f==null?void 0:f.source)===p?f:p,g=m.data,C=oo(e,r??g.columns),b={...L5,...A.tableLayoutLabels},q=g.views.find(B=>B.id===g.activeViewId),w=JSON.stringify(oo(e,(q==null?void 0:q.columns)??i))!==JSON.stringify(C);F.useEffect(()=>{p.error&&(a==null||a(p.error))},[p]),F.useEffect(()=>{if(!d)return;const B=k=>{if(!(k.key!==d&&k.key!==null))try{const x=window.localStorage.getItem(d);h({source:p,data:x?W1(x):{version:1,columns:[],views:[]}})}catch(x){a==null||a(x)}};return window.addEventListener("storage",B),()=>window.removeEventListener("storage",B)},[p,d]);const y=(B,k=!1)=>{let x;if(d)try{window.localStorage.setItem(d,JSON.stringify(B))}catch(O){x=O,a==null||a(O)}h({source:p,data:B,error:x}),k&&(s==null||s(B.columns))},S=B=>y({...g,columns:oo(e,B)},!0),v=B=>!Hn(B)&&B.length<=jr&&g.views.length<F5&&!g.views.some(k=>k.name===B.trim()),T=(B,k=q==null?void 0:q.id)=>!!(k&&g.views.some(x=>x.id===k))&&!Hn(B)&&B.length<=jr&&!g.views.some(x=>x.id!==k&&x.name===B.trim()),M=C.filter(B=>{const k=e.find(x=>x.id===B.id);return k&&qi(k)}),D=M.filter(B=>!B.hidden).length;return{layout:C,labels:b,activeView:q,storageKey:d,storageError:!!m.error,modified:w,columnControls:M.map((B,k)=>{const x=e.find(R=>R.id===B.id),O=M[k-1],P=M[k+1];return{...B,label:typeof x.label=="string"?x.label:x.id,canHide:!!(B.hidden||D>1),moveLeftId:(O==null?void 0:O.pin)===B.pin?O.id:void 0,moveRightId:(P==null?void 0:P.pin)===B.pin?P.id:void 0}}),viewOptions:g.views.map(B=>({value:B.id,label:B.name})),pinOptions:[{value:RA.NONE,label:b.unpinned},{value:RA.LEFT,label:b.pinLeft},{value:RA.RIGHT,label:b.pinRight}],changeLayout:S,canSaveView:v,canRenameView:T,resize:(B,k)=>S(C.map(x=>x.id===B?{...x,width:k}:x)),setVisible:(B,k)=>S(C.map(x=>x.id===B?{...x,hidden:!k}:x)),setPin:(B,k)=>{Object.values(RA).includes(k)&&S(C.map(x=>x.id===B?{...x,pin:k}:x))},move:(B,k)=>{const x=C.find(R=>R.id===B),O=C.find(R=>R.id===k);if(!x||!O||x.pin!==O.pin)return;const P=C.filter(R=>R.id!==B);P.splice(C.findIndex(R=>R.id===k),0,x),S(P)},saveView:B=>{if(!v(B))return!1;const k=typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():`${Date.now()}-${Math.random()}`;return y({...g,columns:C,views:[...g.views,{id:k,name:B.trim(),columns:C}],activeViewId:k}),!0},applyView:B=>{const k=g.views.find(x=>x.id===B);if(!B){y({...g,activeViewId:void 0,columns:oo(e,i)},!0);return}k&&y({...g,activeViewId:B,columns:oo(e,k.columns)},!0)},updateView:()=>{q&&y({...g,columns:C,views:g.views.map(B=>B.id===q.id?{...B,columns:C}:B)})},renameView:(B,k=q==null?void 0:q.id)=>T(B,k)?(y({...g,views:g.views.map(x=>x.id===k?{...x,name:B.trim()}:x)}),!0):!1,deleteView:(B=q==null?void 0:q.id)=>{if(!B||!g.views.some(x=>x.id===B))return;const k=B===(q==null?void 0:q.id);y({...g,activeViewId:k?void 0:g.activeViewId,columns:k?oo(e,i):C,views:g.views.filter(x=>x.id!==B)},k)},reset:()=>y({...g,activeViewId:void 0,columns:oo(e,i)},!0)}},lP=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),cP=e=>({text:e.map(A=>A.map(t=>/[\t\r\n"]/.test(t)?`"${t.replace(/"/g,'""')}"`:t).join(" ")).join(`\r
|
|
264
264
|
`),html:`<table>${e.map(A=>`<tr>${A.map(t=>`<td>${lP(t).replace(/\r\n|\r|\n/g,"<br>")}</td>`).join("")}</tr>`).join("")}</table>`}),dP=e=>{const A=t=>{if(t.nodeType===Node.TEXT_NODE)return t.textContent??"";if(!(t instanceof HTMLElement)||t.matches('[data-table-copy-ignore],.material-icons,.material-symbols-outlined,.material-symbols-rounded,[role="separator"]'))return"";const o=window.getComputedStyle(t);return o.display==="none"||o.visibility==="hidden"?"":t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?t.value:t instanceof HTMLSelectElement?Array.from(t.selectedOptions).map(r=>r.text).join(", "):t.tagName==="BR"?`
|
|
265
265
|
`:Array.from(t.childNodes).map(A).join("")};return e?A(e).trim():""},R2=(e,A)=>{if(!(e instanceof Element)||e.closest(Fa)||e.closest("table")!==A)return;const t=e.closest("[data-table-range-column]");if(t)return{row:Number(t.dataset.tableRangeRow),column:Number(t.dataset.tableRangeColumn)}},uP=(e,A,t)=>{const o=A.filter(v=>!vi.has(v.id)),r=o.map(v=>v.id).join("\0"),[i,s]=F.useState(),a=F.useRef(!1),l=F.useRef(e.length);l.current=e.length;const d=(v,T)=>v&&{...v,focus:v.anchor.row===-1&&T.row===-1?{...T,row:l.current-1}:T},u=F.useRef(void 0),p=F.useRef(void 0);F.useEffect(()=>{s(void 0),a.current=!1},[e,r,t]),F.useEffect(()=>{if(!t)return;const v=()=>{a.current=!1},T=k=>{p.current={x:k.clientX,y:k.clientY}};let M=0;const D=()=>{const k=u.current,x=k==null?void 0:k.closest(".MuiTableContainer-root");if(a.current&&k&&x&&p.current){const O=x.getBoundingClientRect(),{x:P,y:R}=p.current,N=Mk,j=Rk;x.scrollBy({left:P<O.left+N?-j:P>O.right-N?j:0,top:R<O.top+N?-j:R>O.bottom-N?j:0});const V=document.elementFromPoint(Math.max(O.left+1,Math.min(O.right-1,P)),Math.max(O.top+1,Math.min(O.bottom-1,R))),Q=V&&R2(V,k);Q&&s(L=>L&&(L.focus.row!==Q.row||L.focus.column!==Q.column)?d(L,Q):L)}a.current&&(M=requestAnimationFrame(D))},B=()=>{a.current&&(cancelAnimationFrame(M),M=requestAnimationFrame(D))};return window.addEventListener("pointerdown",B),window.addEventListener("pointerup",v),window.addEventListener("pointercancel",v),window.addEventListener("blur",v),window.addEventListener("pointermove",T),()=>{cancelAnimationFrame(M),window.removeEventListener("pointerdown",B),window.removeEventListener("pointerup",v),window.removeEventListener("pointercancel",v),window.removeEventListener("blur",v),window.removeEventListener("pointermove",T)}},[t]);const f=i?{firstRow:Math.min(i.anchor.row,i.focus.row),lastRow:Math.max(i.anchor.row,i.focus.row),firstColumn:Math.min(i.anchor.column,i.focus.column),lastColumn:Math.max(i.anchor.column,i.focus.column)}:void 0,h=(v,T)=>{const M=o.findIndex(D=>D.id===T);return!t||M<0?{}:{"data-table-range-row":v,"data-table-range-column":M,"aria-selected":!!(f&&v>=f.firstRow&&v<=f.lastRow&&M>=f.firstColumn&&M<=f.lastColumn)}},m=v=>{if(!t||v.button!==0)return;const T=R2(v.target,v.currentTarget);T&&(v.preventDefault(),v.currentTarget.focus({preventScroll:!0}),u.current=v.currentTarget,p.current={x:v.clientX,y:v.clientY},a.current=!0,s(M=>{const D=v.shiftKey&&M?M.anchor:T;return{anchor:D,focus:D.row===-1&&T.row===-1?{...T,row:e.length-1}:T}}))},g=v=>{if(!t||!a.current||!(v.buttons&1))return;const T=R2(v.target,v.currentTarget);T&&s(M=>d(M,T))},C=v=>{var D;if(!t||v.target instanceof Element&&(v.target.closest(Fa)||v.target.closest("table")!==v.currentTarget))return;if(v.key==="Escape"){s(void 0);return}if(!e.length||!o.length)return;if((v.ctrlKey||v.metaKey)&&v.key.toLowerCase()==="a"){v.preventDefault(),s({anchor:{row:0,column:0},focus:{row:e.length-1,column:o.length-1}});return}if(!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(v.key))return;v.preventDefault();const T=(i==null?void 0:i.focus)??{row:0,column:0},M={row:Math.max(-1,Math.min(e.length-1,T.row+(v.key==="ArrowDown"?1:v.key==="ArrowUp"?-1:0))),column:Math.max(0,Math.min(o.length-1,T.column+(v.key==="ArrowRight"?1:v.key==="ArrowLeft"?-1:0)))};s({anchor:v.shiftKey&&i?i.anchor:M,focus:M}),(D=v.currentTarget.querySelector(`[data-table-range-row="${M.row}"][data-table-range-column="${M.column}"]`))==null||D.scrollIntoView({block:"nearest",inline:"nearest"})},b=(v,T)=>{var D,B,k;const M=[];for(let x=T.firstRow;x<=T.lastRow;x++){const O=[];for(let P=T.firstColumn;P<=T.lastColumn;P++){const R=o[P];if(!R)continue;const N=e[x],j=R.getCopyValue??(typeof R.copyable=="object"?R.copyable.getValue:void 0);if(x>=0&&N!==void 0&&j){const V=j(N,x);O.push(V==null?"":String(V))}else{const Q=v.querySelector(`[data-table-range-row="${x}"][data-table-range-column="${P}"]`)??(x===-1?Array.from(((D=v.tHead)==null?void 0:D.querySelectorAll("[data-table-column-id]"))??[]).find(L=>L.dataset.tableColumnId===R.id):Array.from(((k=(B=v.tBodies[0])==null?void 0:B.rows[x])==null?void 0:k.cells)??[]).find(L=>L.dataset.tableColumnId===R.id));O.push(dP(Q??null))}}M.push(O)}return cP(M)},q=(v,T)=>{const M=o.findIndex(D=>D.id===v);!t||M<0||(u.current=T,T.focus({preventScroll:!0}),s({anchor:{row:-1,column:M},focus:{row:e.length-1,column:M}}))},w=async(v,T)=>{const M=o.findIndex(B=>B.id===v);if(M<0)return;const D=b(T,{firstRow:-1,lastRow:e.length-1,firstColumn:M,lastColumn:M});typeof ClipboardItem<"u"&&navigator.clipboard.write?await navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([D.text],{type:"text/plain"}),"text/html":new Blob([D.html],{type:"text/html"})})]):await navigator.clipboard.writeText(D.text)},y=v=>{if(!t||!f||v.target instanceof Element&&(v.target.closest(Fa)||v.target.closest("table")!==v.currentTarget))return;const T=b(v.currentTarget,f);v.preventDefault(),v.clipboardData.setData("text/plain",T.text),v.clipboardData.setData("text/html",T.html)},S=v=>{t&&R2(v.target,v.currentTarget)&&v.stopPropagation()};return{getCellProps:h,selectColumn:q,copyColumn:w,selectedCells:f?(f.lastRow-f.firstRow+1)*(f.lastColumn-f.firstColumn+1):0,tableProps:t?{tabIndex:0,onPointerDown:m,onPointerOver:g,onKeyDown:C,onCopy:y,onClickCapture:S}:{}}},pP=[];function Hc({loading:e=!1,onLoadMore:A,hasMore:t=!1,loadingMore:o=!1,rows:r,columns:i,enableColumnManagement:s=!1,columnLayout:a,defaultColumnLayout:l,onColumnLayoutChange:d,viewPersistence:u,onViewPersistenceError:p,tableLayoutLabels:f,enableRangeSelection:h=!1,toolbarActions:m,headerGroups:g,filterLabels:C,filterRules:b,onFilterRuleChange:q,columnSort:w,onColumnSortChange:y,onFilterOpenChange:S,indexLoadingRow:v,isStickyActions:T=!1,rowSx:M={},rowKey:D,onClickSelectRow:B=!1,enableTree:k=!1,getChildren:x,onClickRow:O,onDisabled:P,selectedRows:R,onSelectRows:N,onSelectRow:j,onDeleteRow:V,onInfoRow:Q,onCopyRow:L,onHistoryRow:H,onUpdateRow:G,getActionIcon:ee,getRowMenu:_,extraActionCount:X=0,stickyHeader:J=!0,tableSx:ne,tableRef:le,renderRow:re}){const W=F.useMemo(()=>r??pP,[r]),[K,Y]=F.useState(new Set),Ae=aP(i,{enableColumnManagement:s,columnLayout:a,defaultColumnLayout:l,onColumnLayoutChange:d,viewPersistence:u,onViewPersistenceError:p,tableLayoutLabels:f}),pe=[j,V,Q,L,H,G,_].filter(Boolean).length+X,oe=pe>0?pe*19+Math.max(pe-1,0)*16:0,fe=F.useCallback(Se=>D?D(Se):String(Se.id),[D]),$=F.useCallback(Se=>k?x?x(Se):Se&&Se.children||[]:[],[k,x]);F.useEffect(()=>{if(!k){Y(new Set);return}const Se=new Set,He=he=>{he.forEach(Ye=>{const bA=fe(Ye),qe=$(Ye);qe&&qe.length>0&&(Se.add(bA),He(qe))})};He(W),Y(Se)},[k,fe,$,W]);const{visibleRows:se,rowLevels:Z,hasChildrenById:ie}=F.useMemo(()=>Tk({rows:W,enableTree:k,expandedRowIds:K,getRowId:fe,getChildren:$}),[W,k,K,fe,$]),ae=F.useMemo(()=>Array.from(new Set(se.filter((Se,He)=>{const he=P==null?void 0:P(Se,He);return!(he!=null&&he.DISABLED_ROW)&&!(he!=null&&he.DISABLED_CHECKBOX)}).map(fe))),[se,P,fe]),Pe=F.useMemo(()=>new Set(R),[R]),Ne=ae.length>0&&ae.every(Se=>Pe.has(Se)),We=!Ne&&ae.some(Se=>Pe.has(Se)),Le=F.useCallback(()=>{const Se=new Set(ae);Ne?N==null||N((R??[]).filter(He=>!Se.has(He))):N==null||N(Array.from(new Set([...R??[],...ae])))},[Ne,N,ae,R]),uA=F.useCallback(Se=>{R&&(R.includes(Se)?N==null||N(R.filter(He=>He!==Se)):N==null||N([...R,Se]))},[R,N]),fA=F.useCallback(Se=>{Y(He=>{const he=new Set(He);return he.has(Se)?he.delete(Se):he.add(Se),he})},[]),Fe=F.useCallback((Se,He)=>c.jsx(Sk,{row:Se,index:He,rowId:fe(Se),onSelectRow:j,onDeleteRow:V,onInfoRow:Q,onCopyRow:L,onHistoryRow:H,onUpdateRow:G,getActionIcon:ee,getRowMenu:_,onDisabled:P}),[fe,j,V,Q,L,H,G,ee,_,P]),ke=F.useMemo(()=>{const Se=[...i];if(k&&Se.unshift({id:"treeToggle",label:"",width:32,alignHead:"center",render:he=>c.jsx(Dk,{row:he,getRowId:fe,rowLevels:Z,hasChildrenById:ie,expandedRowIds:K,onToggle:fA})}),N&&Se.unshift({id:"selectCheckbox",label:c.jsx(F0,{checked:Ne,indeterminate:We,disabled:ae.length===0,onClick:he=>{he.stopPropagation(),Le()}}),width:35,alignHead:"center",stickyCss:{left:0,zIndex:1.5},render:(he,Ye)=>{const bA=P?P(he,Ye):{...g2},qe=bA.DISABLED_ROW||bA.DISABLED_CHECKBOX;return c.jsx(F0,{checked:R==null?void 0:R.includes(fe(he)),disabled:qe,onClick:Ue=>{Ue.stopPropagation(),!qe&&uA(fe(he))}})}}),pe>0&&Se.push({id:"actions",label:"Actions",width:oe>70?oe:70,align:"center",alignHead:"center",stickyCss:T?{right:0,borderLeft:Vo,zIndex:1.5}:void 0,render:(he,Ye)=>c.jsx(Xo,{gap:1,onClick:bA=>bA.stopPropagation(),children:Fe(he,Ye)})}),!(g!=null&&g.length))return Se;const He=new Map;return g.forEach(he=>{he.columnIds.forEach(Ye=>{He.set(Ye,he)})}),Se.map(he=>{const Ye=He.get(he.id);return!Ye||!Ye.childrenHeadSx&&!Ye.childrenCellSx?he:{...he,...Ye.childrenHeadSx?{headSx:go(Ye.childrenHeadSx,he.headSx)}:{},...Ye.childrenCellSx?{cellSx:go(Ye.childrenCellSx,he.cellSx)}:{}}})},[i,g,k,N,pe,fe,Z,ie,K,fA,Le,Ne,We,ae.length,P,R,uA,oe,T,Fe]),ge=F.useMemo(()=>s?Uk(ke,Ae.layout):ke,[ke,s,Ae.layout]),Qe=uP(se,ge,h&&!e),gA=F.useCallback((Se,He,he)=>c.jsx(Ek,{columns:he??ge,row:Se,indexRow:He,indexLoadingRow:v,rowSx:M,getRowId:fe,onClickRow:O,onDisabled:P,onClickSelectRow:B,onSelectRowById:uA,enableTree:k,rowLevels:Z,rangeSelection:Qe}),[ge,k,fe,uA,v,O,B,P,Z,M,Qe]),lA=c.jsx($k,{columns:ge,headerGroups:g,filterLabels:C,filterRules:b,onFilterRuleChange:q,columnSort:w,onColumnSortChange:y,onFilterOpenChange:S,rows:se,tableEventProps:Qe.tableProps,onColumnResize:s?Ae.resize:void 0,onColumnMove:s?Ae.move:void 0,layoutLabels:Ae.labels,onCopyColumn:e?void 0:Qe.copyColumn,rangeSelection:h&&!e?Qe:void 0,layoutController:s?Ae:void 0,loading:e,onLoadMore:A,hasMore:t,loadingMore:o,indexLoadingRow:v,stickyHeader:J,tableRef:le,tableSx:go(s?{tableLayout:"fixed",width:ge.reduce((Se,He)=>Se+(He.width??Nr),0),minWidth:ge.reduce((Se,He)=>Se+(He.width??Nr),0),"& .MuiTableCell-root":{boxSizing:"border-box"}}:void 0,ne),renderLoading:()=>c.jsx(gt,{}),renderEmpty:()=>c.jsx(Kn,{}),renderRow:(Se,He)=>re?re({row:Se,index:He,columns:ge,renderDefaultRow:he=>gA(Se,He,he),renderActionsContent:Fe}):gA(Se,He)});return!s&&!h&&!m?lA:c.jsxs(I.Stack,{sx:{flex:1,minHeight:0,minWidth:0,gap:yA},children:[c.jsx(oP,{controller:Ae,enableManagement:s,enableRange:h,selectedCells:Qe.selectedCells,actions:m}),lA]})}const La="collapseToggle",H5=30,fP=20,Qa=e=>e.some(A=>A.id===La)?e:[{id:La,label:"",width:H5,align:"center",alignHead:"center",render:()=>null},...e],gP=(e,A,t)=>{if(A.onOpenCollapse)return t;if(A.property)return e[A.property]||[]},mP=(e,A)=>{const t=A.property?e==null?void 0:e[A.property]:e==null?void 0:e.children;return Array.isArray(t)?t:[]},hP=(e,A)=>mP(e,A).length>0,CP=(e,A)=>e?Math.max(e-parseInt(TA,10)*2-A,H5):"auto";function U5({columns:e,row:A,collapse:t,collapseTableWidth:o,collapseLevel:r=0,renderDefaultRow:i,onDisabled:s}){const[a,l]=F.useState(!1),[d,u]=F.useState(),[p,f]=F.useState(!1),{iconTitle:h,title:m,children:g,indentSize:C,...b}=t,{columns:q,...w}=b,y=(C??fP)*r,S=F.useCallback(async(R,N)=>{const j=!a;if(l(j),!(!j||!t.onOpenCollapse||d!==void 0)){f(!0);try{const V=await t.onOpenCollapse(R,N),Q=t.property?V==null?void 0:V[t.property]:V;u(Q)}catch(V){console.error(V)}finally{f(!1)}}},[t,a,d]),v=F.useCallback((R,N)=>{const j=s?s(R,N):{...g2},V=j.DISABLED_ROW||j.DISABLED_ALL_ACTIONS;return c.jsx(Xo,{onClick:Q=>Q.stopPropagation(),children:c.jsx(ye,{onClick:Q=>{Q.stopPropagation(),S(R,N)},icon:a?"keyboard_arrow_down":"keyboard_arrow_right",disabled:V||j.COLLAPSE})})},[s,a,S]),T=F.useMemo(()=>Qa(e).map(R=>R.id!==La?R:{...R,render:v}),[e,v]),M=gP(A,t,d),D=g==null?void 0:g[0],B=F.useMemo(()=>{if(!(D||!(M!=null&&M.some(R=>hP(R,t)))))return t},[t,M,D]),k=D??B,x=k?Qa(q):q,O=CP(o,y);F.useEffect(()=>{l(!1),u(void 0),f(!1)},[A]);const P=F.useCallback(({row:R,index:N,columns:j,renderDefaultRow:V})=>k?c.jsx(U5,{...w,columns:j,row:R,indexRow:N,collapse:k,collapseTableWidth:o,collapseLevel:r+1,renderDefaultRow:V}):null,[r,o,w,k]);return c.jsxs(F.Fragment,{children:[i(T),c.jsx(I.TableRow,{children:c.jsx(I.TableCell,{style:{paddingBottom:0,paddingTop:0},colSpan:T.length,children:c.jsx(I.Stack,{sx:{display:"block",overflowX:"visible",maxWidth:"none",minWidth:O,width:"max-content",marginLeft:`${y}px`},children:c.jsx(I.Collapse,{in:a,timeout:"auto",unmountOnExit:!0,children:c.jsxs(I.Stack,{sx:{padding:TA,borderRadius:vA,backgroundColor:hA[50],minWidth:O,width:"max-content"},children:[m&&c.jsx(Tn,{icon:h||"filter_list",content:m,size:"medium"}),c.jsx(Hc,{...w,columns:x,loading:p,rows:M,stickyHeader:!1,renderRow:k?P:void 0})]})})})})})]})}function bP({loading:e=!1,rows:A,columns:t,collapse:o,...r}){const i=F.useMemo(()=>A||[],[A]),s=F.useMemo(()=>Qa(t),[t]),a=F.useRef(null),[l,d]=F.useState(0);return F.useEffect(()=>{a.current&&d(a.current.clientWidth)},[]),c.jsx(Hc,{...r,columns:s,rows:i,loading:e,stickyHeader:!1,tableRef:a,tableSx:{height:e||i.length===0?"100%":"none"},renderRow:({row:u,index:p,columns:f,renderDefaultRow:h})=>c.jsx(U5,{...r,columns:f,row:u,indexRow:p,collapse:o,collapseTableWidth:l,renderDefaultRow:h})})}const yP={enableColumnManagement:{control:"boolean",description:"Ẩn/hiện, kéo dãn, đổi thứ tự, ghim cột và quản lý View. Mặc định tắt.",table:{defaultValue:{summary:"false"}}},enableRangeSelection:{control:"boolean",description:"Bấm header chọn cột; kéo header/dòng chọn vùng, Shift+click, Shift+mũi tên; Ctrl/Cmd+C copy ma trận sang Excel.",table:{defaultValue:{summary:"false"}}},toolbarActions:{control:!1,description:"ReactNode chứa action do ứng dụng truyền cạnh Chế độ xem và Cột và bố cục.",table:{type:{summary:"React.ReactNode"}}},viewPersistence:{control:!1,description:"Lưu local theo { tableId, userId } do app truyền. Không đồng bộ thiết bị."},columnLayout:{control:!1,description:"Controlled layout: thứ tự mảng, id, width, hidden, pin (left/right/none)."},defaultColumnLayout:{control:!1,description:"Layout ban đầu và khi reset."},onColumnLayoutChange:{action:"columnLayoutChanged"},onViewPersistenceError:{action:"viewPersistenceError"},tableLayoutLabels:{control:!1,description:"Override nhãn toolbar, dialog, View và hướng dẫn chọn vùng."},onLoadMore:{control:!1,action:"loadMore",description:"Gọi khi cuộn còn cách cuối bảng 80px. App tăng take hoặc tải trang tiếp theo.",table:{type:{summary:"() => void"}}},hasMore:{control:"boolean",description:"Còn dữ liệu để tải thêm.",table:{type:{summary:"boolean"},defaultValue:{summary:"false"}}},loadingMore:{control:"boolean",description:"Giữ các dòng hiện có, hiện loading cuối bảng và chặn tải thêm.",table:{type:{summary:"boolean"},defaultValue:{summary:"false"}}},loading:{control:"boolean",table:{type:{summary:"boolean"},defaultValue:{summary:"false"}}},columns:{control:!1,table:{type:{summary:"Column<R>[]"}}},headerGroups:{control:!1,table:{type:{summary:"TableHeaderGroup[]"}}},filterLabels:{control:!1,description:"Tùy chỉnh nhãn bộ lọc, tìm kiếm và trạng thái đang tải đầy đủ giá trị."},filterRules:{control:!1,description:"Quản lý các giá trị được chọn để bao gồm hoặc loại trừ theo từng cột."},onFilterRuleChange:{action:"filterRuleChanged",description:"Áp dụng bộ lọc khi nhấn OK. undefined sẽ xóa bộ lọc của cột. Ánh xạ dữ liệu theo cấu trúc API của ứng dụng."},columnSort:{control:!1,description:"Quản lý sắp xếp cột theo khóa (key) và thứ tự tăng dần/giảm dần."},onColumnSortChange:{action:"columnSortChanged"},onFilterOpenChange:{action:"filterOpenChanged",description:"Tải danh sách giá trị không trùng lặp và số lượng tương ứng khi mở bộ lọc."},rows:{control:!1,table:{type:{summary:"R[]"}}},indexLoadingRow:{control:"number",table:{type:{summary:"number | undefined"}}},isStickyActions:{control:"boolean",table:{type:{summary:"boolean"},defaultValue:{summary:"false"}}},onClickSelectRow:{control:"boolean",table:{type:{summary:"boolean"},defaultValue:{summary:"false"}}},selectedRows:{control:!1},rowSx:{control:!1},rowKey:{control:!1},requiredPermissions:{control:!1},onClickRow:{action:"rowClicked"},onSelectRows:{action:"rowsSelected"},onSelectRow:{action:"selectAction"},onDeleteRow:{action:"deleteAction"},onInfoRow:{action:"infoAction"},onCopyRow:{action:"copyAction"},onHistoryRow:{action:"historyAction"},onUpdateRow:{action:"updateAction"},getActionIcon:{control:!1},getRowMenu:{control:!1},onDisabled:{control:!1}};function xP(e){return c.jsx(Hc,{...e})}const vP={ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up"},qP=()=>{const e=F.useRef({}),A=F.useCallback((s,a)=>`${s}-${a}`,[]),t=F.useCallback((s,a)=>l=>{const d=A(s,a);if(l){e.current[d]=l;return}delete e.current[d]},[A]),o=F.useCallback((s,a)=>{const l=e.current[A(s,a)];return l==null||l.focus(),l==null||l.select(),l==null||l.scrollIntoView({behavior:"smooth",block:"center",inline:"center"}),!!l},[A]),r=F.useCallback(({cellKey:s,columnKeys:a,rowCount:l,rowIndex:d},u)=>{const p=a.indexOf(s);if(p<0)return;if(u==="left"||u==="right"){const h=u==="right"?1:-1;for(let m=p+h;m>=0;m+=h)if(m>=a.length||o(d,a[m]))return;return}const f=u==="down"?1:-1;for(let h=d+f;h>=0;h+=f)if(h>=l||o(h,s))return},[o]),i=F.useCallback(s=>a=>{const l=vP[a.key];l&&(a.preventDefault(),r(s,l))},[r]);return{focusCell:o,getKeyDownHandler:i,registerCell:t}};var st=(e=>(e.SERVER="server",e.CLIENT="client",e))(st||{});const et=e=>{var A;return((A=e.filter)==null?void 0:A.key)??e.id},h2=(e,A)=>Object.entries(e).some(([t,o])=>t!==A&&(o==null?void 0:o.length)===0),z5=e=>{const A={};for(const[t,o]of Object.entries(e))o&&(A[t]={selection:{mode:Pt.INCLUDE,values:o}});return A},L0=(e,A)=>{var o;const t=(o=A.filter)!=null&&o.getValue?A.filter.getValue(e):e[A.id];return typeof t=="string"||typeof t=="number"||typeof t=="boolean"?t:void 0},V5=(e,A,t,o)=>A.every(r=>{var a;const i=et(r),s=t[i];return!r.filter||i===o||!s||s.includes(((a=L0(e,r))==null?void 0:a.toString())??"")}),Uc=(e,A)=>{var o,r,i;const t=new Map;for(const s of e){const a=((o=L0(s,A))==null?void 0:o.toString())??"",l=t.get(a);l?l.count=(l.count??0)+1:t.set(a,{value:a,label:((i=(r=A.filter)==null?void 0:r.getOptionLabel)==null?void 0:i.call(r,a))??a,count:1})}return[...t.values()]},Ha=(e,A,t,o)=>{const r=e.filter(s=>V5(s,A,t)),i=o&&A.find(s=>et(s)===o.key);return i&&o&&r.sort((s,a)=>{const l=L0(s,i),d=L0(a,i),u=typeof l=="number"&&typeof d=="number"?l-d:((l==null?void 0:l.toString())??"").localeCompare((d==null?void 0:d.toString())??"","vi",{numeric:!0});return o.direction==="desc"?-u:u}),r},W5=async({fetchPage:e,take:A=500,maxPages:t=1e3,signal:o})=>{if(!Number.isInteger(A)||A<1||!Number.isInteger(t)||t<1)throw new Error("Invalid column-filter pagination limits.");const r=[];for(let i=1;i<=t;i++){o==null||o.throwIfAborted();const s=await e(i,A,o);if(o==null||o.throwIfAborted(),r.push(...s.rows),s.totalPages!==void 0?i>=s.totalPages:r.length>=s.total){if(r.length<s.total)throw new Error("Column-filter source is incomplete.");return r}if(!s.rows.length)throw new Error("Column-filter source ended before all rows were loaded.")}throw new Error("Column-filter source exceeded maxPages; use a distinct-values endpoint.")},zc=(e,A)=>{if(!e.openColumn)return;const t={...e.filters};let o=!1;for(const r of Object.keys(t))r===e.openColumn&&t[r]!==void 0&&(o=!0),o&&(A!=null&&A.some(i=>i.filter&&et(i)===r))&&delete t[r];return delete t[e.openColumn],h2(t)?void 0:{...e,page:1,filters:t}},wP=[];function G5({columns:e,state:A,onStateChange:t,rows:o=wP,total:r=o.length,loading:i=!1,mode:s=st.SERVER,optionsSource:a,onFilterOpenChange:l,onFiltersChange:d,isValueSupported:u,isSortSupported:p,incompleteOptionsText:f="Danh sách giá trị chưa đầy đủ. Vui lòng tải đầy đủ trước khi áp dụng bộ lọc."}){var R;const{openColumn:h}=A,m=h2(A.filters),g=F.useMemo(()=>s===st.CLIENT?Ha(o,e,A.filters,A.sort):o,[s,o,e,A.filters,A.sort]),C=(R=e.find(N=>N.filter&&et(N)===h))==null?void 0:R.filter,b=a!==void 0&&a.key===h,q=F.useMemo(()=>zc(A,e),[A,e]),w=F.useMemo(()=>{const N=e.find(j=>j.filter&&et(j)===h);return s===st.CLIENT&&N&&q?Uc(Ha(o,e,q.filters),N):[]},[s,o,e,h,q]),y=s===st.CLIENT?w:b?a.options:(C==null?void 0:C.options)??[],S=s===st.CLIENT?i:!!(b&&a.loading),v=s!==st.CLIENT&&b?a.errorText:void 0,T=s===st.CLIENT?!i:b?a.complete:!!(C!=null&&C.options&&C.optionsComplete!==!1),M=b&&a.allowPartialSelection,D=y.map(N=>{var j;return{...N,label:((j=C==null?void 0:C.getOptionLabel)==null?void 0:j.call(C,N.value))??N.label,disabled:N.disabled||s!==st.CLIENT&&(u==null?void 0:u(h??"",N.value))===!1}}),B=N=>{t(j=>{const V={...j.filters};for(const[Q,L]of Object.entries(N))L===void 0?delete V[Q]:V[Q]=L;return{...j,page:1,filters:V}}),d==null||d(N)},k=(N,j)=>{const V=e.find(G=>G.filter&&et(G)===N);if(!(V!=null&&V.filter)||V.filter.disabled)return;const Q=j==null?void 0:j.selection;if(Q&&(N!==h||!T&&!(M&&Q.mode===Pt.INCLUDE)||S||v))return;const L=!Q||Q.mode===Pt.EXCLUDE&&!Q.values.length?void 0:Q.mode===Pt.INCLUDE?Q.values:D.filter(G=>!G.disabled&&!Q.values.includes(G.value)).map(G=>G.value);if(s!==st.CLIENT&&(L!=null&&L.some(G=>(u==null?void 0:u(N,G))===!1)))return;const H={[N]:L};for(const G of V.filter.clearFields??[])H[G]=void 0;B(H)},x=N=>{N&&!e.some(j=>j.filter&&et(j)===N.key&&j.filter.sortable!==!1&&(s===st.CLIENT||(p==null?void 0:p(j.filter.sortKey??N.key))!==!1)&&!j.filter.disabled)||t(j=>({...j,page:1,sort:N}))},O=e.map(N=>{if(!N.filter)return N;const j=et(N),V={...N.filter,sortable:N.filter.sortable!==!1&&(s===st.CLIENT||(p==null?void 0:p(N.filter.sortKey??j))!==!1)};return{...N,filter:j===h?{...V,options:D,optionsComplete:T,allowPartialSelection:M,onLoadMore:b?a.onLoadMore:void 0,loading:S,errorText:v??(!T&&!S&&!M?f:void 0)}:V}}),P=m?[]:s===st.CLIENT?g.slice((A.page-1)*A.take,A.page*A.take):o;return{state:A,openColumn:h,rows:P,total:m?0:s===st.CLIENT?g.length:r,hasEmptySelection:m,setFilters:B,setPage:(N,j)=>t(V=>({...V,page:j!==void 0&&j!==V.take?1:N,take:j??V.take})),optionsState:q,tableProps:{columns:O,rows:P,loading:i,filterRules:z5(A.filters),columnSort:A.sort,onFilterRuleChange:k,onColumnSortChange:x,onFilterOpenChange:(N,j)=>{t(V=>({...V,openColumn:j?N:V.openColumn===N?void 0:V.openColumn})),l==null||l(N,j)}}}}const Ua=e=>!!e&&!e.includes(",")&&e===e.trim(),Vc=e=>{var A;return{page:e.page,take:e.length,filters:Object.fromEntries(Object.entries(e.filters??{}).filter(([,t])=>t!=="").map(([t,o])=>[t,Array.isArray(o)?o:o.split(",")])),sort:(A=e.sort)!=null&&A[0]?{key:e.sort[0].id,direction:e.sort[0].desc?sn.DESC:sn.ASC}:void 0}},Wc=e=>({isValueSupported:(A,t)=>Y5(e,A,t),isSortSupported:()=>!0,buildRequest:({state:A,columns:t,params:o})=>{var a,l;if(h2(A.filters))return;let r={...o,page:A.page,length:A.take};const i={};for(const[d,u]of Object.entries(o.filters??{}))if(!t.some(p=>p.filter&&et(p)===d)){if(!Array.isArray(u)){i[d]=u;continue}if(!u.length)return;if(u.some(p=>!Ua(p)))throw new Error(`The .NET CSV contract cannot represent filter ${d}.`);i[d]=u.join(",")}for(const d of t)d.filter&&(delete i[et(d)],d.filter.arrayParam&&delete r[d.filter.arrayParam]);for(const[d,u]of Object.entries(A.filters)){if(!u)continue;const p=t.find(f=>f.filter&&et(f)===d);if((a=p==null?void 0:p.filter)!=null&&a.arrayParam){const f=p.filter.dataType===Qn.NUMBER,h=f?u.map(Number):u;if(f&&(u.some(m=>!m.trim())||h.some(m=>!Number.isFinite(m))))throw new Error(`Invalid numeric filter: ${d}`);r={...r,[p.filter.arrayParam]:h}}else{if(u.some(f=>!Ua(f)))throw new Error(`The .NET CSV contract cannot represent filter ${d}; use arrayParam or a custom adapter.`);i[d]=u.join(",")}}const s=A.sort&&t.find(d=>{var u;return et(d)===((u=A.sort)==null?void 0:u.key)});return{...r,filters:i,sort:A.sort?[{id:((l=s==null?void 0:s.filter)==null?void 0:l.sortKey)??A.sort.key,desc:A.sort.direction===sn.DESC}]:void 0}},readPage:A=>{if(A.succeeded===!1||!A.data)throw new Error(A.message??"Cannot load .NET column-filter rows.");return{rows:A.data,total:A.totalCount,pageSize:A.pageSize,totalPages:A.totalPages}}}),Y5=(e,A,t)=>{var r;const o=(r=e.find(i=>et(i)===A))==null?void 0:r.filter;return o!=null&&o.arrayParam?o.dataType===Qn.NUMBER?!!t.trim()&&Number.isFinite(Number(t)):!0:Ua(t)},SP=({bindings:e,sortKeys:A=[]})=>({isSortSupported:t=>A.includes(t),isValueSupported:(t,o)=>{var r,i;return!!e[t]&&(((i=(r=e[t]).isValueSupported)==null?void 0:i.call(r,o))??!0)},buildRequest:({state:t,columns:o,params:r})=>{var s;if(h2(t.filters))return;let i={...r,page:t.page,take:t.take};delete i.order,delete i.orderBy;for(const[a,l]of Object.entries(t.filters))if(l&&!e[a])throw new Error(`No Node endpoint binding for column filter: ${a}`);for(const[a,l]of Object.entries(e)){const d=t.filters[a];if(d!=null&&d.some(u=>{var p;return((p=l.isValueSupported)==null?void 0:p.call(l,u))===!1}))throw new Error(`Unsupported Node column-filter value: ${a}`);i={...i,...l.serialize(d,r)}}if(t.sort){const a=o.find(d=>{var u;return et(d)===((u=t.sort)==null?void 0:u.key)}),l=((s=a==null?void 0:a.filter)==null?void 0:s.sortKey)??t.sort.key;if(!A.includes(l))throw new Error(`Node endpoint does not declare sorting by: ${l}`);i={...i,orderBy:l,order:t.sort.direction===sn.DESC?ti.DESC:ti.ASC}}return i},readPage:t=>({rows:t.list,total:t.total})});function X1(e,A,t,o){var i;const r=Wc(A).buildRequest({state:t,columns:A,params:e});if(r){if(o)for(const s of A){const a=(i=s.filter)==null?void 0:i.arrayParam;a&&t.filters[et(s)]===void 0&&e[a]!==void 0&&(r[a]=e[a])}return r}}function EP(e,A,t){const o={...Vc(e),openColumn:A},r=t(o);return{...e,page:r.page,length:r.take,filters:Object.fromEntries(Object.entries(r.filters).filter(i=>i[1]!==void 0)),sort:r.sort===o.sort?e.sort:r.sort?[{id:r.sort.key,desc:r.sort.direction===sn.DESC}]:void 0}}const IP=e=>Object.fromEntries(Object.entries(e).map(([A,t])=>[A,t===void 0?void 0:t.length?t.join(","):"[]"]));function TP({cacheKey:e,request:A,column:t,client:o,enabled:r,fetchPage:i,fetchOptions:s,readPage:a,optionsPageSize:l,optionsMaxPages:d}){var m,g;const{mutate:u}=Un.useSWRConfig(),p=t&&et(t),f=Un(r&&A&&(o||t)?["dotnet-column-filter-options",e,o?"client":p,A,!!(s&&!o),d]:null,async()=>{if(!o&&s&&t)return{rows:[],options:await s(A,t)};const C=await W5({fetchPage:async(b,q)=>a(await i({...A,page:b,length:q})),take:l,maxPages:d});return{rows:o?C:[],options:!o&&t?Uc(C,t):[]}},{revalidateOnFocus:!1,revalidateIfStale:!1,shouldRetryOnError:!1,keepPreviousData:!1}),h=F.useCallback(async()=>{await u(C=>Array.isArray(C)&&C[0]==="dotnet-column-filter-options"&&C[1]===e,void 0,{revalidate:!0})},[u,e]);return{rows:((m=f.data)==null?void 0:m.rows)??[],options:((g=f.data)==null?void 0:g.options)??[],complete:!!(r&&A&&f.data&&!f.error&&!f.isValidating),loading:f.isValidating,error:f.error,allowPartialSelection:!1,refresh:h}}function DP({cacheKey:e,columns:A,params:t,onParamsChange:o,fetchPage:r,enabled:i=!0,mode:s=st.SERVER,onFiltersChange:a,optionsSort:l,optionsPageSize:d=500,optionsMaxPages:u=1e3,fetchOptions:p,preserveExternalArrayParams:f=!0,incompleteOptionsText:h}){var Q,L,H;const[m,g]=F.useState(),C=Wc(A),b={...Vc(t),openColumn:m},q=s===st.CLIENT,w=q?void 0:X1(t,A,b,f),y=w&&{...w,sort:(Q=t.sort)==null?void 0:Q.map(G=>{var ee,_;return{...G,id:((_=(ee=A.find(X=>et(X)===G.id))==null?void 0:ee.filter)==null?void 0:_.sortKey)??G.id}})},S=zc(b,A),v=q?{...b,page:1,filters:Object.fromEntries(Object.entries(b.filters).filter(([G])=>!A.some(ee=>ee.filter&&et(ee)===G))),sort:void 0}:S,T=v&&X1(t,A,v,f),M=T&&{...T,page:1,length:d,sort:l??[{id:"id",desc:!1}]},D=A.find(G=>G.filter&&et(G)===m),B=TP({cacheKey:e,request:M,column:D,client:q,enabled:i,fetchPage:r,fetchOptions:p,readPage:C.readPage,optionsPageSize:d,optionsMaxPages:u}),k=Un(i&&!q&&y?["dotnet-column-filter-list",e,y]:null,async()=>C.readPage(await r(y)),{revalidateOnFocus:!1,revalidateIfStale:!0,shouldRetryOnError:!1,keepPreviousData:!1}),x=i&&(q?B.loading:!!y&&k.isValidating),O=q?B.rows:((L=k.data)==null?void 0:L.rows)??[],R=G5({columns:A,state:b,onStateChange:G=>{const ee=G(b);g(ee.openColumn),!(ee.page===b.page&&ee.take===b.take&&ee.filters===b.filters&&ee.sort===b.sort)&&o(_=>EP(_,m,G))},onFiltersChange:G=>a==null?void 0:a(IP(G)),mode:s,rows:i&&!x?O:[],total:!i||x||!y?0:((H=k.data)==null?void 0:H.total)??0,loading:x,isValueSupported:C.isValueSupported,isSortSupported:C.isSortSupported,incompleteOptionsText:h,optionsSource:m?{key:m,options:B.options,complete:B.complete,allowPartialSelection:B.allowPartialSelection,loading:B.loading,errorText:B.error?vr(B.error):void 0}:void 0}),{mutate:N}=k,{refresh:j}=B,V=F.useCallback(async()=>{await Promise.all([N(),j()])},[N,j]);return{...R,requestParams:y,loading:x,error:q?B.error:k.error,refresh:V}}const BP=({name:e="Hệ thống",department:A="Hệ thống",icon:t="person",sx:o})=>c.jsxs(I.Stack,{sx:o,children:[c.jsxs(I.Stack,{direction:"row",alignItems:"center",gap:1,children:[c.jsx(ye,{icon:t,sx:{fontSize:"16px",color:"#6B7280"}}),c.jsx(I.Typography,{variant:"body2",sx:{fontWeight:500},children:e})]}),A&&c.jsxs(I.Typography,{variant:"caption",sx:{color:"#6B7280",ml:2.5},children:["(",A,")"]})]}),OP=({name:e,loading:A,chart:t,sx:o})=>c.jsx(I.Fade,{in:!0,timeout:V0,children:c.jsxs(up,{children:[c.jsx(I.Typography,{variant:"subtitle1",sx:{lineHeight:1,textAlign:"center"},children:e}),c.jsx(I.Stack,{sx:{height:`calc(100% - 14px - ${ve})`,...o},children:A?c.jsx(gt,{}):t})]})}),kP=({iconLabel:e,label:A,nodeLabel:t,labelSize:o="medium",flex:r=1,height:i="fit-content",width:s,direction:a="column",directionNodeLabel:l="column",sx:d={},loading:u=!1,children:p,sxChildren:f={}})=>c.jsx(I.Fade,{in:!0,timeout:V0,children:c.jsxs(I.Stack,{sx:{...s?{width:s}:{flex:r},overflow:"hidden",height:i,...d},children:[(A||t)&&c.jsxs(Hi,{sx:{position:"sticky",alignItems:"stretch",top:0,zIndex:1,overflow:"hidden"},children:[A&&c.jsx(Tn,{icon:e,content:A,size:o}),t&&c.jsx(I.Stack,{sx:{flexDirection:l},children:t})]}),c.jsx(I.Stack,{sx:{flex:1,flexDirection:a,paddingTop:A||t?0:TA,...f},children:u?c.jsx(gt,{}):p})]})}),PP=({iconLabel:e,label:A,nodeAction:t,nodeLabel:o,labelSize:r="large",flex:i=1,height:s="fit-content",width:a,direction:l="column",directionNodeLabel:d="column",sx:u={},loading:p=!1,children:f,sxChildren:h={overflowY:"auto"},sxLabel:m={},divider:g,labelId:C,isTopLabel:b=!1})=>{const q=!!(A||t),w={large:Me.textSm.semiBold,medium:Me.textXs.semiBold,small:Me.textSmall.semiBold}[r];return c.jsx(I.Fade,{in:!0,timeout:V0,children:c.jsx(I.Stack,{sx:{...a?{width:a}:{flex:i},overflowY:"auto",overflowX:"hidden",height:s,boxShadow:1,borderRadius:vA,backgroundColor:hA[50],...u},children:c.jsxs(I.Stack,{sx:{flex:1,minHeight:0,overflow:"hidden",gap:0},children:[q&&c.jsxs(Hi,{sx:{position:"sticky",top:0,zIndex:1,gap:ve,minHeight:at.large,padding:s0,backgroundColor:hA[50],...m},children:[A&&c.jsx(Tn,{id:C,icon:e,content:A,size:r,isNowrap:!0,sx:{minWidth:0},sxText:{...w}}),t&&c.jsx(q0,{sx:{flexDirection:d,flexShrink:0,marginLeft:"auto"},children:t})]}),o&&c.jsx(sp,{sx:{minHeight:at.large,overflowX:"auto",padding:s0,borderTop:q?`1px solid ${Je[300]}`:"none"},children:o}),c.jsx(I.Stack,{sx:{flex:1,minHeight:0,flexDirection:l,padding:s0,marginTop:b?TA:0,borderTop:q||o?`1px solid ${Je[300]}`:"none",backgroundColor:hA[50],...h},divider:g,children:p?c.jsx(Xo,{height:100,width:"100%",children:c.jsx(gt,{})}):f})]})})})},MP=({isWrap:e=!1,children:A})=>e?c.jsx(Xo,{children:A}):c.jsx(c.Fragment,{children:A}),Gc=({app:e,iconSize:A,iconRadius:t,titleColor:o,showNameApps:r=!0,showIconApps:i=!0,direction:s="column"})=>c.jsxs(cp,{sx:{flexDirection:s,gap:ve},children:[i&&c.jsx(un,{sx:{width:A,height:A,borderRadius:t},url:e.icon,sizeType:"SQUARE"}),r&&c.jsx(I.Typography,{sx:{color:o,textAlign:"center",...Me.textMd.semiBold},children:e.content})]}),Yc=({apps:e,columns:A=5,rows:t=3,iconSize:o=120,iconRadius:r=7,titleColor:i,showPagination:s=!0,onClickApp:a,isShowAppHidden:l=!1})=>{const d=Math.max(1,A*Math.max(1,t)),u=Math.max(1,Math.ceil(e.length/d)),[p,f]=F.useState(0);F.useEffect(()=>{f(q=>q>=u?u-1:q)},[u,A,t,e.length]);const h=p*d,m=h+d,g=u>1?e.slice(h,m):e,C=l?Math.max(0,d-g.length):0,b=l?o+36.5:0;return c.jsxs(bo,{sx:{width:"100%",gap:3},children:[c.jsxs(Xe,{sx:{width:"100%",gap:3},children:[c.jsx(c.Fragment,{}),c.jsxs(I.Stack,{sx:{display:"grid",gridTemplateColumns:`repeat(${A}, 1fr)`,width:"100%"},children:[g.map((q,w)=>c.jsx(bo,{component:Lr,preset:"staggerItem",index:w,hover:!0,sx:{cursor:"pointer",flex:1},onClick:()=>a(q),children:c.jsx(Gc,{app:q,titleColor:i??hA[50],iconSize:o,iconRadius:r})},w)),C>0&&Array.from({length:C}).map((q,w)=>c.jsx(I.Box,{sx:{visibility:"hidden",width:1,minHeight:b}},`placeholder-${w}`))]})]}),s&&u>1&&c.jsx(Xe,{sx:{p:Sn,borderRadius:dn,backgroundColor:"rgba(255,255,255,0.15)",width:"fit-content"},children:Array.from({length:u}).map((q,w)=>c.jsx(I.Box,{onClick:()=>f(w),sx:{height:10,borderRadius:dn,cursor:"pointer",transition:"width 0.3s ease",width:w===p?"40px":"10px",backgroundColor:w===p?hA[50]:"rgba(255,255,255,0.35)"}},w))})]})},RP=({children:e})=>c.jsx(I.Stack,{sx:{backgroundColor:"background.default",minHeight:"100vh",width:"100%",overflowY:"auto"},children:c.jsx(I.Stack,{sx:{flex:1,alignItems:"center",py:TA,justifyContent:"center"},children:e})});var K5=(e=>(e.MAIN="logoMain",e.SUB1="logoSub1",e.SUB2="logoSub2",e.SUB3="logoSub3",e.SUB4="logoSub4",e.SUB5="logoSub5",e))(K5||{});const NP=({env:e,logoName:A="logoMain",height:t=v3,sx:o={},isLongSubDomain:r=!1})=>c.jsx(Eo,{href:r?y0[e].replace("dev.","develop.").replace("sta.","staging."):y0[e],children:c.jsx(un,{url:nA[A],sx:{height:t,borderRadius:"unset",width:"auto",...o}})});var vo=(e=>(e.LOADING="loading",e.AUTHENTICATED="authenticated",e.UNAUTHENTICATED="unauthenticated",e))(vo||{}),cn=(e=>(e.ALL="all",e.UNREAD="unread",e.READ="read",e))(cn||{});const X5=e=>{if(!(e<=0))return e<=99?e:"99+"},Kc=e=>!e||/^https?:\/\//i.test(e)||e.startsWith("//")?!1:e.startsWith("/"),Xc=e=>{const A=Number(e);return A in EA?A:EA.INFO},b0=e=>String(e??"").trim(),J5=e=>b0(e.id??("Id"in e?e.Id:void 0)).toLowerCase(),Z5=e=>{var r;const A=b0(e.title).toLowerCase(),t=b0(e.body).toLowerCase(),o=b0(e.createdAt??("data"in e?(r=e.data)==null?void 0:r.createdAt:void 0)).toLowerCase();return[A,t,o].join("|")},hr=e=>{const A=J5(e),t=Z5(e),o=[];return A&&o.push(`id:${A}`),t!=="||"&&o.push(`fingerprint:${t}`),o},Jc=e=>{var A;return b0(e.module??("data"in e?(A=e.data)==null?void 0:A.module:void 0)).toUpperCase()},_5=e=>{var t;const A=Jc(e);return(t=uo[A])==null?void 0:t.icon},$5=e=>{var r,i,s,a,l;const A=e.title??"",t=e.body??"",o=e.createdAt??((r=e.data)==null?void 0:r.createdAt)??new Date().toISOString();return{id:e.id??e.Id??`${A}-${o}`,eventType:e.eventType??((i=e.data)==null?void 0:i.actionName)??"Realtime",priority:Xc(e.priority??((s=e.data)==null?void 0:s.priority)),title:A,body:t,actionUrl:e.actionUrl??((a=e.data)==null?void 0:a.actionUrl),module:Jc(e),status:wn.UNREAD,acknowledgementRequired:e.acknowledgementRequired??((l=e.data)==null?void 0:l.acknowledgementRequired)??!1,createdAt:o}},Zc=e=>{const t=new Date(e).getTime();if(!Number.isFinite(t))return"vua xong";const o=Math.round((t-Date.now())/1e3),r=Math.abs(o),i=new Intl.RelativeTimeFormat("vi",{numeric:"auto"});if(r<60)return i.format(o,"second");const s=Math.round(o/60);if(Math.abs(s)<60)return i.format(s,"minute");const a=Math.round(s/60);if(Math.abs(a)<24)return i.format(a,"hour");const l=Math.round(a/24);if(Math.abs(l)<30)return i.format(l,"day");const d=Math.round(l/30);return Math.abs(d)<12?i.format(d,"month"):i.format(Math.round(d/12),"year")},jP="hub/notification-realtime",FP="NotificationReceived",LP="notification-be-list",e6="notification-be-unread-count",QP="notification-be-realtime",HP={axiosNotification:{},authStatus:vo.UNAUTHENTICATED,hasNewNotification:!1,unreadCount:0,markNotificationsSeen:()=>{},refreshNotifications:async()=>{}},A6=F.createContext(HP),UP={[EA.CRITICAL]:vt.ERROR,[EA.HIGH]:vt.WARNING,[EA.NORMAL]:vt.INFO,[EA.INFO]:vt.INFO},zP=e=>e.replace(/\/+$/,""),VP=e=>{const A=e.title??"",t=e.body;return t?`${A} - ${t}`:A},WP=(e,A)=>Array.isArray(e)&&e[0]===LP&&(!A||e[1]===A),t6=(e,A)=>Array.isArray(e)&&e[0]===e6&&(!A||e[1]===A),GP=(e,A)=>WP(e,A)||t6(e,A),YP=e=>e?[QP,e]:null;let na,J1="",J2="";const KP=(e,A)=>((!na||J1!==e)&&(na=new ra.HubConnectionBuilder().withUrl(e,{accessTokenFactory:A,withCredentials:!1}).withAutomaticReconnect([0,2e3,5e3,1e4]).build(),J1=e,J2=""),na),XP=({axiosNotification:e,authStatus:A,userName:t,hubBaseUrl:o,hubPath:r=jP,realtimeEventName:i=FP,accessTokenFactory:s,showSnackbar:a,children:l})=>{const{mutate:d}=Un.useSWRConfig(),[u,p]=F.useState(!1),f=F.useRef(new Set),h=F.useRef(()=>{}),m=A===vo.AUTHENTICATED&&t?[e6,t]:null,{data:g=0}=Un(m,async()=>(await za(e)).count??0,{revalidateOnFocus:!1,shouldRetryOnError:!1}),C=F.useCallback(async()=>{await d(S=>GP(S,t),void 0,{revalidate:!0})},[d,t]),b=F.useCallback(()=>{p(!1)},[]),q=F.useCallback(async S=>{const v=$5(S),T=YP(t);T&&await d(T,(M=[])=>{const D=hr(v);return M.some(k=>{const x=hr(k);return D.some(O=>x.includes(O))})?M:[v,...M].slice(0,50)},{revalidate:!1}),await d(M=>t6(M,t),M=>(M??0)+1,{revalidate:!1})},[d,t]),w=F.useCallback(async S=>{const v=hr(S);v.some(T=>f.current.has(T))||(v.forEach(T=>f.current.add(T)),p(!0),a==null||a({type:UP[Xc(S.priority)],message:VP(S)}),await q(S),await C(),setTimeout(()=>{v.forEach(T=>f.current.delete(T))},1e4))},[q,C,a]);F.useEffect(()=>{h.current=w},[w]),F.useEffect(()=>{if(A!==vo.AUTHENTICATED||!o||!t)return;const S=`${zP(o)}/${r.replace(/^\/+/,"")}`,v=KP(S,s),T=D=>{h.current(D)};return v.on(i,T),(async()=>{v.state===ra.HubConnectionState.Connected&&J2&&J2!==t&&await v.stop(),v.state===ra.HubConnectionState.Disconnected&&(J2=t,await v.start())})().catch(D=>{console.error("[NotificationReceived][global] connect error",D)}),()=>{v.off(i,T)}},[s,A,o,r,i,t]);const y=F.useMemo(()=>({axiosNotification:e,authStatus:A,userName:t,hasNewNotification:u,unreadCount:g,markNotificationsSeen:b,refreshNotifications:C,showSnackbar:a}),[A,e,u,b,C,a,g,t]);return c.jsx(A6.Provider,{value:y,children:l})},C2=()=>F.useContext(A6),n6=({notification:e,fallbackIcon:A,color:t})=>{const o=_5(e),r=e.priority??EA.INFO;return c.jsx(q0,{sx:{height:36,width:36},children:o?c.jsx(un,{alt:e.module||e.eventType||e.title,sizeType:"FULL_WIDTH",url:o,size:Mt.LARGE}):c.jsx(ye,{icon:A,sx:{color:t,fontSize:r===EA.INFO?19:20}})})},_c="notification-be-list",$c="notification-be-unread-count",o6="notification-be-realtime",Z1=e=>{if(e===cn.READ)return Ai.READ;if(e===cn.UNREAD)return Ai.UNREAD},JP=(e,A)=>A===cn.READ?e.status===wn.READ:A===cn.UNREAD?e.status===wn.UNREAD:!0,ZP=(e,A,t)=>{const o=A.filter(i=>JP(i,t)),r=new Set(e.flatMap(hr));return[...o.filter(i=>hr(i).every(s=>!r.has(s))),...e]},_P=(e,A)=>e.length!==A.length?!1:e.every((t,o)=>{const r=A[o];return t.id===r.id&&t.status===r.status&&t.title===r.title&&t.body===r.body&&t.createdAt===r.createdAt}),ed=(e,A)=>Array.isArray(e)&&e[0]===_c&&(!A||e[1]===A),Ad=(e,A)=>Array.isArray(e)&&e[0]===$c&&(!A||e[1]===A),$P=(e,A)=>ed(e,A)||Ad(e,A),r6=e=>e?[o6,e]:null,td=(e={},A=cn.ALL)=>{const{axiosNotification:t,authStatus:o,userName:r}=C2(),{mutate:i}=Un.useSWRConfig(),[s,a]=F.useState({page:1,pageSize:10,status:Z1(A),...e}),[l,d]=F.useState([]),[u,p]=F.useState(!1),f=F.useRef(!1),h=F.useMemo(()=>s,[s]),m=o===vo.AUTHENTICATED&&r?[_c,r,h]:null,g=o===vo.AUTHENTICATED&&r?r6(r):null;F.useEffect(()=>{a(D=>{const B=Z1(A);return D.status===B&&D.page===1?D:{...D,status:B,page:1}}),f.current=!1,d(D=>D.length===0?D:[])},[A]);const{data:C,error:b,isLoading:q}=Un(m,async([,,D])=>{const B=await r3(t,D);return{notifications:B.items??[],totalCount:B.total??0}},{revalidateOnFocus:!1,revalidateIfStale:!0,shouldRetryOnError:!1}),{data:w=[]}=Un(g,null,{fallbackData:[],revalidateOnFocus:!1}),y=Math.max((C==null?void 0:C.totalCount)??0,l.length),S=F.useMemo(()=>l.filter(D=>D.status===wn.UNREAD).length,[l]);F.useEffect(()=>{if(h.page!==1){if(!C)return;if(f.current){d(B=>[...B,...C.notifications]),f.current=!1;return}d(C.notifications);return}if(!C&&w.length===0)return;const D=ZP((C==null?void 0:C.notifications)??[],w,A);d(B=>_P(B,D)?B:D)},[C,h.page,A,w]);const v=F.useCallback(()=>{q||l.length>=y||(f.current=!0,a(D=>({...D,page:(D.page??1)+1})))},[q,l.length,y]),T=F.useCallback(D=>{f.current=!1,a(B=>({...B,page:D.page,pageSize:D.take}))},[]),M=F.useCallback(async()=>{p(!0),a(D=>({...D,page:1})),await i(D=>ed(D,r),void 0,{revalidate:!0}),await i(D=>Ad(D,r),void 0,{revalidate:!0}),p(!1)},[i,r]);return{notifications:l,totalCount:y,unreadCount:S,isLoading:q,isRefreshing:u,error:(C==null?void 0:C.error)??(b instanceof Error?b.message:void 0),handlePaginationChange:T,loadMore:v,page:s.page??1,pageSize:s.pageSize??10,refresh:M}},eM=()=>{const{axiosNotification:e,authStatus:A,userName:t}=C2(),o=A===vo.AUTHENTICATED&&t?[$c,t]:null,{data:r,isLoading:i,mutate:s}=Un(o,async()=>(await za(e)).count??0,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{unreadCount:r??0,isLoadingUnreadCount:i,refreshUnreadCount:s}},AM={[EA.CRITICAL]:"error",[EA.HIGH]:"warning",[EA.NORMAL]:"notifications",[EA.INFO]:"info"},_1={[EA.CRITICAL]:xt[500],[EA.HIGH]:jo[500],[EA.NORMAL]:Je[500],[EA.INFO]:Je[500]},tM={[EA.CRITICAL]:"Khẩn cấp",[EA.HIGH]:"Ưu tiên cao",[EA.NORMAL]:"",[EA.INFO]:""},nM=[{id:cn.ALL,name:"Tất cả"},{id:cn.UNREAD,name:"Chưa đọc"},{id:cn.READ,name:"Đã đọc"}],oM=({notification:e,onRead:A,onNavigate:t})=>{const o=F.useMemo(()=>Zc(e.createdAt),[e.createdAt]),r=e.status===wn.UNREAD,i=e.priority??EA.INFO,s=Kc(e.actionUrl),a=tM[i],l=async()=>{await A(),s&&e.actionUrl&&(t==null||t(e.actionUrl))};return c.jsx(I.Stack,{onClick:l,sx:{bgcolor:hA[50],border:`1px solid ${Je[200]}`,borderRadius:vA,boxShadow:r?`inset 3px 0 0 ${Ze[500]}`:"none",cursor:"pointer",p:ve,transition:tt,"&:hover":{bgcolor:Je[50],borderColor:Je[300]}},children:c.jsxs(Xe,{sx:{alignItems:"flex-start",gap:ve,minWidth:0},children:[c.jsx(n6,{notification:e,fallbackIcon:AM[i],color:_1[i]}),c.jsxs(I.Stack,{sx:{flex:1,gap:0,minWidth:0},children:[c.jsxs(GA,{sx:{alignItems:"flex-start",gap:ve},children:[c.jsx(xA,{content:Gn(e.title),sx:{...Me.textSm.semiBold,color:r?Je[900]:Je[700]}}),c.jsx(xA,{content:o,sx:{...Me.textXs.medium,color:Je[500],flexShrink:0}})]}),c.jsxs(GA,{sx:{alignItems:"flex-start",gap:ve},children:[c.jsx(I.Typography,{sx:{...Me.textXs.regular,color:Je[700],width:"85%",display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:5,overflow:"hidden"},children:Gn(e.body)}),c.jsx(xA,{content:r?"Chưa đọc":"Đã đọc",sx:{...Me.textXs.medium,color:r?Ze[600]:Je[500]}})]}),c.jsxs(Xe,{sx:{gap:yA},children:[a?c.jsx(xA,{content:a,sx:{...Me.textXs.medium,color:_1[i]}}):null,s?c.jsx(xA,{content:"Xem chi tiết",sx:{...Me.textXs.medium,color:Ze[600]}}):null]})]})]})})},i6=({onNavigate:e})=>{const{axiosNotification:A,showSnackbar:t}=C2(),[o,r]=F.useState(cn.ALL),{notifications:i,totalCount:s,unreadCount:a,isLoading:l,isRefreshing:d,error:u,handlePaginationChange:p,page:f,pageSize:h,refresh:m}=td({page:1,pageSize:10},o),g=async b=>{if(b.status===wn.UNREAD)try{await Va(A,b.id),await m()}catch(q){t==null||t({type:vt.ERROR,message:vr(q)})}},C=async()=>{if(a)try{const b=await Wa(A);await m(),t==null||t({type:vt.SUCCESS,message:b.success?"Đã đánh dấu tất cả thông báo là đã đọc":"Không có thông báo cần đánh dấu"})}catch(b){t==null||t({type:vt.ERROR,message:vr(b)})}};return c.jsxs(I.Stack,{sx:{flex:1,gap:0,minHeight:0,overflow:"hidden"},children:[c.jsx(I.Stack,{sx:{borderBottom:`1px solid ${Je[200]}`,gap:0,p:yA},children:c.jsx(ip,{children:c.jsx(dl,{tabs:nM.map(b=>({id:b.id,name:b.name,onClick:()=>r(b.id)})),idSelect:o})})}),c.jsxs(I.Stack,{sx:{flex:1,gap:ve,minHeight:0,overflow:"auto",p:TA},children:[c.jsxs(GA,{sx:{flexWrap:"wrap",gap:ve},children:[c.jsxs(I.Stack,{sx:{gap:yA},children:[c.jsx(xA,{content:`Danh sách (${s})`,sx:{...Me.textSm.semiBold}}),c.jsx(xA,{content:a?`${a} thông báo chưa đọc`:"Tất cả thông báo đã được đọc",sx:{...Me.textXs.medium,color:a?Ze[600]:Je[500]}})]}),a?c.jsx(sA,{content:"Đánh dấu tất cả đã đọc",disabled:d,endIcon:"done_all",loading:d,onClick:C,variant:"text"}):null]}),i.map(b=>c.jsx(oM,{notification:b,onNavigate:e,onRead:()=>g(b)},b.id)),!u&&i.length===0&&!l?c.jsx(q0,{sx:{flex:1,gap:ve,minHeight:220},children:c.jsx(Kn,{content:"Bạn sẽ nhận được thông báo khi có hoạt động mới"})}):null,l&&i.length===0?c.jsx(q0,{sx:{flex:1,minHeight:220},children:c.jsx(gt,{})}):null,u?c.jsx(Kn,{content:`Lỗi khi tải thông báo: ${u}`}):null]}),s>h?c.jsx(k5,{total:s,page:f,take:h,onChange:p}):null]})},rM=10,iM={[EA.CRITICAL]:"error",[EA.HIGH]:"warning",[EA.NORMAL]:"notifications",[EA.INFO]:"info"},sM={[EA.CRITICAL]:xt[500],[EA.HIGH]:jo[500],[EA.NORMAL]:Ze[500],[EA.INFO]:Je[500]},aM=({notification:e,onClick:A})=>{const t=F.useMemo(()=>Zc(e.createdAt),[e.createdAt]),o=e.status===wn.UNREAD,r=e.priority??EA.INFO;return c.jsx(I.ListItem,{onClick:()=>A(e),sx:{borderRadius:vA,cursor:"pointer",p:ve,transition:tt,bgcolor:o?Ze[50]:hA[50],"&:hover":{bgcolor:o?Ze[100]:Je[50]}},children:c.jsxs(Xe,{sx:{alignItems:"flex-start",gap:ve,width:"100%"},children:[c.jsx(n6,{notification:e,fallbackIcon:iM[r],color:sM[r]}),c.jsxs(I.Stack,{sx:{flex:1,gap:yA,minWidth:0},children:[c.jsxs(lp,{sx:{gap:ve},children:[c.jsx(xA,{content:Gn(e.title),sx:{...Me.textSm.semiBold}}),c.jsx(xA,{content:t,sx:{...Me.textXs.medium,flexShrink:0}})]}),c.jsx(xA,{content:Gn(e.body),sx:{...Me.textXs.regular}})]})]})})},lM=({onNavigate:e,dropdownPageSize:A=rM})=>{const{axiosNotification:t,hasNewNotification:o,unreadCount:r,markNotificationsSeen:i,refreshNotifications:s,showSnackbar:a}=C2(),[l,d]=F.useState(!1),[u,p]=F.useState(!1),[f,h]=F.useState(!1),{notifications:m,isLoading:g,refresh:C}=td({page:1,pageSize:A}),b=()=>{d(y=>!y),i()},q=async y=>{if(d(!1),y.status===wn.UNREAD)try{await Va(t,y.id),await s(),await C()}catch(S){a==null||a({type:vt.ERROR,message:vr(S)})}Kc(y.actionUrl)&&(e==null||e(y.actionUrl))},w=async()=>{h(!0);try{await Wa(t),await s(),await C(),a==null||a({type:vt.SUCCESS,message:"Đã đánh dấu tất cả thông báo là đã đọc"})}catch(y){a==null||a({type:vt.ERROR,message:vr(y)})}finally{h(!1)}};return c.jsxs(c.Fragment,{children:[c.jsx(gp,{open:l,onClickAway:()=>d(!1),placement:"bottom-end",content:c.jsxs(I.List,{sx:{display:"flex",flexDirection:"column",maxHeight:500,overflowY:"auto",p:0,width:360},children:[c.jsxs(I.ListItem,{sx:{alignItems:"center",bgcolor:hA[50],borderBottom:`1px solid ${Je[200]}`,display:"flex",justifyContent:"space-between",p:ve,position:"sticky",top:0,zIndex:1},children:[c.jsx(xA,{content:"Thông báo hệ thống",sx:{...Me.textMd.semiBold}}),c.jsxs(Xe,{sx:{gap:yA},children:[f?c.jsx(gt,{size:"small"}):null,c.jsx(qt,{icon:"mark_email_read",onClick:w,sx:{minHeight:30,minWidth:30}}),c.jsx(qt,{icon:"open_in_full",onClick:()=>{d(!1),p(!0)},sx:{minHeight:30,minWidth:30}})]})]}),g?c.jsx(gt,{}):null,!g&&m.length===0?c.jsx(Kn,{content:"Không có thông báo"}):null,g?null:m.map(y=>c.jsx(aM,{notification:y,onClick:q},y.id))]}),children:c.jsx(I.Badge,{badgeContent:X5(r),color:"error",invisible:r===0,sx:{cursor:"pointer","& .MuiBadge-badge":{...Me.textXs.semiBold,minWidth:16,height:16}},children:c.jsx(qt,{"aria-label":"Thông báo",icon:"notifications_none",onClick:b,sx:{bgcolor:o?jo[50]:"transparent",color:o?jo[700]:Je[600],minHeight:32,minWidth:32,"&:hover":{bgcolor:o?jo[100]:Je[100],color:o?jo[800]:Je[800]}}})})}),c.jsx(I.Drawer,{anchor:"right",open:u,onClose:()=>p(!1),children:c.jsxs(I.Stack,{sx:{height:"100vh",width:600,overflow:"hidden"},children:[c.jsxs(I.Stack,{sx:{borderBottom:`1px solid ${Je[200]}`,gap:yA,p:ve},children:[c.jsxs(GA,{sx:{gap:ve},children:[c.jsx(xA,{content:"Thông báo hệ thống",sx:{...Me.textMd.semiBold}}),c.jsx(qt,{icon:"close",onClick:()=>p(!1)})]}),c.jsx(xA,{content:"Xem và quản lý các thông báo của bạn",sx:{...Me.textXs.medium,color:Je[500]}})]}),c.jsx(i6,{onNavigate:e})]})})]})},cM=({isLineHeight1:e,price:A,originalPrice:t,discountPercent:o,onClick:r,color:i,size:s="small",sameSize:a=!1,sx:l={}})=>{const{palette:d}=I.useTheme(),u={small:"subtitle1",medium:"h6",large:"h5"};return r&&(l={...l,cursor:"pointer"}),c.jsxs(I.Stack,{sx:l,children:[c.jsxs(Xe,{sx:{color:i||d.error.main,gap:ve},children:[c.jsx(ye,{icon:"attach_money",size:s,sx:{marginRight:"-5px",marginLeft:"-4px"}}),c.jsx(I.Typography,{lineHeight:e?1:void 0,variant:u[s],children:+A.toFixed(1)})]}),t&&A!==t&&c.jsxs(Xe,{sx:{gap:ve},children:[c.jsxs(Xe,{sx:{color:d.text.disabled,gap:ve,position:"relative","&:after":{position:"absolute",content:"''",borderTop:`1px solid ${d.text.disabled}`,width:"100%"}},children:[c.jsx(ye,{icon:"attach_money",size:a?s:"small",sx:{marginRight:"-5px",marginLeft:"-4px"}}),c.jsx(I.Typography,{lineHeight:e?1:void 0,variant:a?u[s]:"body1",children:t})]}),o&&c.jsx(I.Typography,{lineHeight:e?1:void 0,color:o<0?"success.main":"error",variant:a?u[s]:"body1",children:(o<0?"+":"-")+Math.abs(o)+"%"})]})]})};var Z2={exports:{}},dM=Z2.exports,$1;function uM(){return $1||($1=1,(function(e,A){(function(t,o){e.exports=o()})(dM,(function(){var t="week",o="year";return function(r,i,s){var a=i.prototype;a.week=function(l){if(l===void 0&&(l=null),l!==null)return this.add(7*(l-this.week()),"day");var d=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var u=s(this).startOf(o).add(1,o).date(d),p=s(this).endOf(t);if(u.isBefore(p))return 1}var f=s(this).startOf(o).date(d).startOf(t).subtract(1,"millisecond"),h=this.diff(f,t,!0);return h<0?s(this).startOf("week").week():Math.ceil(h)},a.weeks=function(l){return l===void 0&&(l=null),this.week(l)}}}))})(Z2)),Z2.exports}var pM=uM();const fM=$n(pM);var _2={exports:{}},gM=_2.exports,e3;function mM(){return e3||(e3=1,(function(e,A){(function(t,o){e.exports=o()})(gM,(function(){return function(t,o,r){o.prototype.isBetween=function(i,s,a,l){var d=r(i),u=r(s),p=(l=l||"()")[0]==="(",f=l[1]===")";return(p?this.isAfter(d,a):!this.isBefore(d,a))&&(f?this.isBefore(u,a):!this.isAfter(u,a))||(p?this.isBefore(d,a):!this.isAfter(d,a))&&(f?this.isAfter(u,a):!this.isBefore(u,a))}}}))})(_2)),_2.exports}var hM=mM();const CM=$n(hM);var $2={exports:{}},bM=$2.exports,A3;function yM(){return A3||(A3=1,(function(e,A){(function(t,o){e.exports=o()})(bM,(function(){return function(t,o){var r=o.prototype,i=r.format;r.format=function(s){var a=this,l=this.$locale();if(!this.isValid())return i.bind(this)(s);var d=this.$utils(),u=(s||"YYYY-MM-DDTHH:mm:ssZ").replace(/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g,(function(p){switch(p){case"Q":return Math.ceil((a.$M+1)/3);case"Do":return l.ordinal(a.$D);case"gggg":return a.weekYear();case"GGGG":return a.isoWeekYear();case"wo":return l.ordinal(a.week(),"W");case"w":case"ww":return d.s(a.week(),p==="w"?1:2,"0");case"W":case"WW":return d.s(a.isoWeek(),p==="W"?1:2,"0");case"k":case"kk":return d.s(String(a.$H===0?24:a.$H),p==="k"?1:2,"0");case"X":return Math.floor(a.$d.getTime()/1e3);case"x":return a.$d.getTime();case"z":return"["+a.offsetName()+"]";case"zzz":return"["+a.offsetName("long")+"]";default:return p}}));return i.bind(this)(u)}}}))})($2)),$2.exports}var xM=yM();const vM=$n(xM);Be.extend(F3);Be.extend(fM);Be.extend(CM);Be.extend(vM);const qM={YY:"year",YYYY:{sectionType:"year",contentType:"digit",maxLength:4},M:{sectionType:"month",contentType:"digit",maxLength:2},MM:"month",MMM:{sectionType:"month",contentType:"letter"},MMMM:{sectionType:"month",contentType:"letter"},D:{sectionType:"day",contentType:"digit",maxLength:2},DD:"day",Do:{sectionType:"day",contentType:"digit-with-letter"},d:{sectionType:"weekDay",contentType:"digit",maxLength:2},dd:{sectionType:"weekDay",contentType:"letter"},ddd:{sectionType:"weekDay",contentType:"letter"},dddd:{sectionType:"weekDay",contentType:"letter"},A:"meridiem",a:"meridiem",H:{sectionType:"hours",contentType:"digit",maxLength:2},HH:"hours",h:{sectionType:"hours",contentType:"digit",maxLength:2},hh:"hours",m:{sectionType:"minutes",contentType:"digit",maxLength:2},mm:"minutes",s:{sectionType:"seconds",contentType:"digit",maxLength:2},ss:"seconds"},wM={year:"YYYY",month:"MMMM",monthShort:"MMM",dayOfMonth:"D",dayOfMonthFull:"Do",weekday:"dddd",weekdayShort:"dd",hours24h:"HH",hours12h:"hh",meridiem:"A",minutes:"mm",seconds:"ss",fullDate:"ll",keyboardDate:"L",shortDate:"MMM D",normalDate:"D MMMM",normalDateWithWeekday:"ddd, MMM D",fullTime12h:"hh:mm A",fullTime24h:"HH:mm",keyboardDateTime12h:"L hh:mm A",keyboardDateTime24h:"L HH:mm"},oa=["Missing UTC plugin","To be able to use UTC or timezones, you have to enable the `utc` plugin","Find more information on https://mui.com/x/react-date-pickers/timezone/#day-js-and-utc"].join(`
|
|
266
266
|
`),t3=["Missing timezone plugin","To be able to use timezones, you have to enable both the `utc` and the `timezone` plugin","Find more information on https://mui.com/x/react-date-pickers/timezone/#day-js-and-timezone"].join(`
|