dhx-react-suite 1.2.1 → 1.2.2

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.
@@ -1,4 +1,4 @@
1
- (function(q,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react/jsx-runtime"),require("react"),require("recharts"),require("@dhx/trial-richtext")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","recharts","@dhx/trial-richtext"],e):(q=typeof globalThis<"u"?globalThis:q||self,e(q.DhxReactSuite={},q.ReactJSXRuntime,q.React,q.Recharts,q.DhxRichtext))})(this,function(q,e,g,Z,Ve){"use strict";const t={primary:"#0288d1",primaryDk:"#01579b",primaryLt:"#e1f5fe",success:"#43a047",danger:"#e53935",warning:"#fb8c00",bg:"#f5f7fa",surface:"#ffffff",border:"#dde3ea",borderDk:"#b0bec5",text:"#3d4a5c",textSec:"#6b7a8d",textMut:"#9aa5b1",shadow:"0 2px 8px rgba(0,0,0,.10)",shadowLg:"0 8px 28px rgba(0,0,0,.14)",r:"4px",rMd:"8px",font:"'Segoe UI', system-ui, -apple-system, sans-serif"},Te="dhx-react-styles";function R(){if(typeof document>"u"||document.getElementById(Te))return;const r=document.createElement("style");r.id=Te,r.textContent=`
1
+ (function(G,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react/jsx-runtime"),require("react"),require("recharts")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","recharts"],e):(G=typeof globalThis<"u"?globalThis:G||self,e(G.DhxReactSuite={},G.ReactJSXRuntime,G.React,G.Recharts))})(this,function(G,e,p,re){"use strict";const t={primary:"#0288d1",primaryDk:"#01579b",primaryLt:"#e1f5fe",success:"#43a047",danger:"#e53935",warning:"#fb8c00",bg:"#f5f7fa",surface:"#ffffff",border:"#dde3ea",borderDk:"#b0bec5",text:"#3d4a5c",textSec:"#6b7a8d",textMut:"#9aa5b1",shadow:"0 2px 8px rgba(0,0,0,.10)",shadowLg:"0 8px 28px rgba(0,0,0,.14)",r:"4px",rMd:"8px",font:"'Segoe UI', system-ui, -apple-system, sans-serif"},We="dhx-react-styles";function ne(){if(typeof document>"u"||document.getElementById(We))return;const r=document.createElement("style");r.id=We,r.textContent=`
2
2
  *,*::before,*::after{box-sizing:border-box}
3
3
  .dhx{font-family:${t.font};font-size:14px;color:${t.text}}
4
4
  .dhx *{box-sizing:border-box}
@@ -38,4 +38,4 @@
38
38
  .dhx-tag-success{background:#e8f5e9;color:#1b5e20}
39
39
  .dhx-tag-danger{background:#ffebee;color:#b71c1c}
40
40
  .dhx-tag-warning{background:#fff3e0;color:#e65100}
41
- `,document.head.appendChild(r)}const Xe={sm:{height:24,padding:"0 8px",fontSize:12},md:{},lg:{height:38,padding:"0 18px",fontSize:14}};function qe({children:r,variant:s="primary",size:a="md",icon:i,disabled:f,onClick:d,style:p,className:u=""}){return g.useEffect(R,[]),e.jsxs("button",{className:`dhx dhx-btn dhx-btn-${s} ${u}`,style:{...Xe[a],...p},disabled:f,onClick:d,children:[i&&e.jsx("span",{style:{fontSize:16},children:i}),r]})}function ce(r,s){g.useEffect(()=>{const a=i=>{r.current&&!r.current.contains(i.target)&&s(i)};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[r,s])}function Ee(r){const s=g.useRef(!1),a=g.useRef({x:0,y:0,ox:0,oy:0});return g.useCallback((i,f=0,d=0)=>{s.current=!0,a.current={x:i.clientX,y:i.clientY,ox:f,oy:d};const p=y=>{if(!s.current)return;const{x:m,y:o,ox:b,oy:C}=a.current;r(b+y.clientX-m,C+y.clientY-o)},u=()=>{s.current=!1,document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",u)};document.addEventListener("mousemove",p),document.addEventListener("mouseup",u),i.preventDefault()},[r])}function ie({items:r,onSelect:s,style:a}){const[i,f]=g.useState(null);return e.jsx("div",{className:"dhx dhx-anim-fade",style:{position:"absolute",top:"calc(100% + 4px)",left:0,minWidth:180,background:t.surface,border:`1px solid ${t.border}`,borderRadius:t.r,boxShadow:t.shadowLg,zIndex:200,padding:"4px 0",...a},children:r.map((d,p)=>{var y,m;if(d.type==="separator")return e.jsx("div",{style:{height:1,background:t.border,margin:"4px 0"}},p);const u=i===p;return e.jsxs("div",{style:{position:"relative"},onMouseEnter:()=>f(p),onMouseLeave:()=>f(null),children:[e.jsxs("div",{onClick:()=>{var o;return!d.disabled&&!((o=d.items)!=null&&o.length)&&s(d)},style:{display:"flex",alignItems:"center",gap:8,padding:"8px 14px",cursor:d.disabled?"not-allowed":"pointer",fontSize:13,color:d.disabled?t.textMut:t.text,background:u&&!d.disabled?t.bg:"transparent",opacity:d.disabled?.5:1},children:[d.icon&&e.jsx("span",{style:{fontSize:15,width:18,textAlign:"center"},children:d.icon}),e.jsx("span",{style:{flex:1},children:d.value||d.id}),d.hotkey&&e.jsx("span",{style:{fontSize:11,color:t.textMut},children:d.hotkey}),(y=d.items)!=null&&y.length?e.jsx("span",{style:{fontSize:10,color:t.textMut},children:"▶"}):null]}),u&&((m=d.items)!=null&&m.length)?e.jsx(ie,{items:d.items,onSelect:s,style:{position:"absolute",left:"100%",top:-4}}):null]},d.id||p)})})}function Ge({items:r=[],label:s="Menu",onSelect:a,style:i}){const[f,d]=g.useState(!1),p=g.useRef(null);return g.useEffect(R,[]),ce(p,g.useCallback(()=>d(!1),[])),e.jsxs("div",{ref:p,className:"dhx",style:{position:"relative",display:"inline-block",...i},children:[e.jsxs("button",{className:"dhx dhx-btn dhx-btn-secondary",onClick:()=>d(u=>!u),children:[s," ",e.jsx("span",{style:{fontSize:10},children:f?"▲":"▼"})]}),f&&e.jsx(ie,{items:r,onSelect:u=>{a==null||a(u),d(!1)}})]})}function Je({items:r=[],onSelect:s,children:a}){const[i,f]=g.useState(null),d=g.useRef(null);g.useEffect(R,[]),ce(d,g.useCallback(()=>f(null),[]));const p=u=>{u.preventDefault(),f({x:u.clientX,y:u.clientY})};return e.jsxs("div",{ref:d,onContextMenu:p,style:{position:"relative",display:"contents"},children:[a,i&&e.jsx("div",{style:{position:"fixed",left:i.x,top:i.y,zIndex:9999},children:e.jsx(ie,{items:r,onSelect:u=>{s==null||s(u),f(null)}})})]})}function Ne({count:r}){return e.jsx("span",{style:{position:"absolute",top:2,right:2,minWidth:16,height:16,background:t.danger,color:"#fff",borderRadius:8,fontSize:10,fontWeight:700,display:"flex",alignItems:"center",justifyContent:"center",padding:"0 3px",lineHeight:1,pointerEvents:"none"},children:r})}function Ue({items:r=[],onAction:s,style:a}){const[i,f]=g.useState(null),[d,p]=g.useState(()=>{const o={};return r.forEach(b=>{b.id&&(b.twoState||b.group)&&b.active&&(o[b.id]=!0)}),o}),u=g.useRef(null);g.useEffect(R,[]),ce(u,g.useCallback(()=>f(null),[]));const y=(o,b)=>{var C,N;if(!o.disabled){if(o.twoState&&o.id&&p(D=>({...D,[o.id]:!D[o.id]})),o.group&&o.id&&p(D=>{const c={...D};return r.forEach(z=>{z.group===o.group&&z.id&&(c[z.id]=!1)}),c[o.id]=!0,c}),(C=o.items)!=null&&C.length){f(D=>D===b?null:b);return}(N=o.onClick)==null||N.call(o,o.id||""),s==null||s(o.id||"")}},m=(o,b)=>{var c,z;if(o.hidden)return null;if(o.type==="separator")return e.jsx("div",{style:{width:1,background:t.border,margin:"6px 4px",alignSelf:"stretch"}},b);if(o.type==="spacer")return e.jsx("div",{style:{flex:1}},b);if(o.type==="input")return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[o.label&&e.jsx("span",{style:{fontSize:12,color:t.textSec,fontWeight:500},children:o.label}),e.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center"},children:[o.icon&&e.jsx("span",{style:{position:"absolute",left:8,color:t.textMut,fontSize:15,pointerEvents:"none",zIndex:1},children:o.icon}),e.jsx("input",{className:"dhx dhx-input",style:{width:o.width||140,height:28,paddingLeft:o.icon?30:void 0},placeholder:o.placeholder,defaultValue:o.value,onChange:$=>{var I;return(I=o.onChange)==null?void 0:I.call(o,$.target.value)}})]})]},b);if(o.type==="select")return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[o.label&&e.jsx("span",{style:{fontSize:12,color:t.textSec,fontWeight:500},children:o.label}),e.jsx("select",{className:"dhx dhx-input",style:{width:o.width||100,height:28,cursor:"pointer"},defaultValue:o.value,onChange:$=>{var I;return(I=o.onChange)==null?void 0:I.call(o,$.target.value)},children:(c=o.options)==null?void 0:c.map($=>e.jsx("option",{value:$.value,children:$.label},$.value))})]},b);if(o.type==="imageButton")return e.jsxs("button",{title:o.tooltip,disabled:o.disabled,style:{position:"relative",width:32,height:32,padding:2,border:"none",borderRadius:"50%",overflow:"hidden",cursor:o.disabled?"not-allowed":"pointer",background:"transparent",flexShrink:0},onClick:()=>y(o,b),children:[o.src&&e.jsx("img",{src:o.src,alt:o.value||"",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}),o.count!==void 0&&e.jsx(Ne,{count:o.count})]},b);const C=!!(o.id&&d[o.id]),N=o.value??o.text,D=!!((z=o.items)!=null&&z.length);return e.jsxs("div",{style:{position:"relative"},children:[e.jsxs("button",{className:"dhx dhx-btn dhx-btn-ghost",title:o.tooltip,disabled:o.disabled,style:{height:32,gap:4,position:"relative",background:C?t.primaryLt:"transparent",color:C?t.primary:o.disabled?t.textMut:t.text,opacity:o.disabled?.55:1,cursor:o.disabled?"not-allowed":"pointer"},onClick:()=>y(o,b),children:[o.icon&&e.jsx("span",{style:{fontSize:16},children:o.icon}),N&&e.jsx("span",{style:{fontSize:13},children:N}),D&&e.jsx("span",{style:{fontSize:9,opacity:.55,marginLeft:2},children:"▼"}),o.count!==void 0&&e.jsx(Ne,{count:o.count})]}),D&&i===b&&e.jsx(ie,{items:o.items,onSelect:()=>f(null),style:{top:"100%",left:0}})]},b)};return e.jsx("div",{ref:u,className:"dhx",style:{display:"flex",alignItems:"center",gap:2,padding:"4px 8px",background:t.surface,borderBottom:`1px solid ${t.border}`,minHeight:44,flexWrap:"wrap",...a},children:r.map(m)})}function Qe(r){return r==="primary"?t.primary:r==="success"?"#43a047":r==="secondary"?"#9e9e9e":"#e53935"}function Ze(r,s){const a=[],i=f=>{var d;f.id&&f.group===s&&a.push(f.id),(d=f.items)==null||d.forEach(i)};return r.forEach(i),a}function Re(r){const s={},a=i=>{var f;i.id&&i.twoState&&i.active&&(s[i.id]=!0),(f=i.items)==null||f.forEach(a)};return r.forEach(a),s}function et({items:r=[],width:s=240,minWidth:a=64,header:i,footer:f,collapsed:d,defaultCollapsed:p,selected:u,defaultSelected:y,onSelect:m,onCollapse:o,onExpand:b,onBeforeCollapse:C,onBeforeExpand:N,onToggleItem:D,style:c}){const z=d!==void 0,$=u!==void 0,[I,A]=g.useState(p??!1),[M,L]=g.useState(y??null),[V,h]=g.useState({}),[W,l]=g.useState(()=>Re(r));g.useEffect(R,[]);const x=z?d:I,K=$?u??null:M,P=x?a:s,n=()=>{if(x){if((N==null?void 0:N())===!1)return;z||A(!1),b==null||b()}else{if((C==null?void 0:C())===!1)return;z||A(!0),o==null||o()}},E=S=>{$||L(S.id??null),m==null||m(S),S.id&&S.onClick&&S.onClick(S.id)},F=S=>{if(!S.id)return;const j=!W[S.id];let X={...W,[S.id]:j};S.group&&j&&Ze(r,S.group).forEach(Q=>{Q!==S.id&&(X[Q]=!1)}),l(X),D==null||D(S.id,j)},w=(S,j)=>{if(S.count===void 0)return null;const X=Qe(S.countColor),Q=S.count>99?"99+":String(S.count);return j?e.jsx("span",{style:{position:"absolute",top:1,right:1,background:X,color:"#fff",borderRadius:8,fontSize:9,fontWeight:700,padding:"0 3px",minWidth:14,textAlign:"center",lineHeight:"14px",pointerEvents:"none"},children:Q}):e.jsx("span",{style:{background:X,color:"#fff",borderRadius:10,padding:"1px 6px",fontSize:11,fontWeight:700,flexShrink:0},children:Q})},k=(S,j,X)=>{var ae;if(S.hidden)return null;const Q=S.id??`${S.type??"navItem"}-${j}-${X}`,G=S.type??"navItem";if(G==="separator")return e.jsx("div",{style:{height:1,background:t.border,margin:"6px 8px",flexShrink:0}},Q);if(G==="spacer")return e.jsx("div",{style:{flex:1}},Q);if(G==="title")return x?null:e.jsx("div",{style:{padding:"10px 14px 4px",fontSize:10,fontWeight:700,textTransform:"uppercase",letterSpacing:1,color:t.textMut,flexShrink:0},children:S.value},Q);if(G==="customHTML")return e.jsx("div",{dangerouslySetInnerHTML:{__html:S.html??""},style:{padding:"8px 12px",flexShrink:0}},Q);const U=(((ae=S.items)==null?void 0:ae.length)??0)>0,ee=!!V[S.id??""],te=S.twoState?!!W[S.id??""]:!1,re=!S.twoState&&K===S.id||te,O=!!S.disabled,de=x?0:12+j*16,$e=()=>{O||(S.twoState?(F(S),E(S)):(U&&h(le=>({...le,[S.id??""]:!le[S.id??""]})),E(S)))};return e.jsxs("div",{style:{flexShrink:0},children:[e.jsxs("div",{title:S.tooltip,onClick:$e,style:{display:"flex",alignItems:"center",gap:x?0:8,justifyContent:x?"center":"flex-start",paddingTop:8,paddingBottom:8,paddingLeft:x?0:de,paddingRight:x?0:10,borderRadius:t.r,margin:"1px 6px",cursor:O?"not-allowed":"pointer",userSelect:"none",transition:"background .15s",background:re?t.primaryLt:"transparent",color:O?t.textMut:re?t.primary:t.text,opacity:O?.55:1},onMouseEnter:le=>{!re&&!O&&(le.currentTarget.style.background=t.bg)},onMouseLeave:le=>{!re&&!O&&(le.currentTarget.style.background="transparent")},children:[e.jsxs("span",{style:{position:"relative",minWidth:22,textAlign:"center",fontSize:18,flexShrink:0,lineHeight:1},children:[S.icon??(S.value&&!S.icon,null),x&&w(S,!0)]}),!x&&e.jsx("span",{style:{flex:1,fontSize:13,fontWeight:re?600:400,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:S.value}),!x&&w(S,!1),!x&&S.twoState&&e.jsx("span",{style:{width:14,height:14,borderRadius:2,border:`2px solid ${re?t.primary:t.borderDk}`,background:re?t.primary:"transparent",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:re&&e.jsx("span",{style:{color:"#fff",fontSize:8,fontWeight:700,lineHeight:1},children:"✓"})}),!x&&U&&!S.twoState&&e.jsx("span",{style:{fontSize:11,color:t.textMut,flexShrink:0,transition:"transform .2s",transform:ee?"rotate(90deg)":"rotate(0deg)",display:"inline-block"},children:"▶"})]}),U&&ee&&!x&&e.jsx("div",{children:S.items.map((le,ge)=>k(le,j+1,ge))})]},Q)},T=e.jsxs("div",{onClick:n,style:{display:"flex",alignItems:"center",justifyContent:x?"center":"flex-start",gap:8,padding:x?"8px 0":"8px 14px",margin:"4px 6px",borderRadius:t.r,cursor:"pointer",color:t.textMut,fontSize:13,userSelect:"none",transition:"background .15s",flexShrink:0},onMouseEnter:S=>S.currentTarget.style.background=t.bg,onMouseLeave:S=>S.currentTarget.style.background="transparent",children:[e.jsx("span",{style:{fontSize:16,fontWeight:700,lineHeight:1},children:x?"›":"‹"}),!x&&e.jsx("span",{children:"Collapse"})]});return e.jsxs("div",{className:"dhx",style:{width:P,minWidth:P,background:t.surface,borderRight:`1px solid ${t.border}`,display:"flex",flexDirection:"column",transition:"width .2s ease, min-width .2s ease",overflow:"hidden",...c},children:[i&&e.jsx("div",{style:{padding:x?"12px 0":"12px 14px",borderBottom:`1px solid ${t.border}`,fontWeight:700,fontSize:15,display:"flex",alignItems:"center",justifyContent:x?"center":"flex-start",overflow:"hidden",flexShrink:0},children:i}),e.jsx("div",{className:"dhx-scroll",style:{flex:1,overflowY:"auto",overflowX:"hidden",display:"flex",flexDirection:"column"},children:r.map((S,j)=>k(S,0,j))}),T,f&&!x&&e.jsx("div",{style:{padding:"10px 14px",borderTop:`1px solid ${t.border}`,flexShrink:0},children:f})]})}function tt({config:r}){const[s,a]=g.useState(!1),i={position:"relative",background:t.surface,border:`1px solid ${t.border}`,borderRadius:t.r,overflow:"hidden",...r.width?{width:r.width,minWidth:r.width}:{flex:1},...r.height?{height:r.height,minHeight:r.height}:{minHeight:40},...s?{flex:"0 0 auto"}:{}};return e.jsxs("div",{style:i,children:[r.header&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 12px",background:t.bg,borderBottom:`1px solid ${t.border}`,fontSize:12,fontWeight:600,color:t.textSec,userSelect:"none"},children:[e.jsx("span",{children:r.header}),r.collapsable&&e.jsx("button",{onClick:()=>a(f=>!f),style:{background:"none",border:"none",cursor:"pointer",color:t.textMut,fontSize:16,lineHeight:1},children:s?"▼":"▲"})]}),!s&&e.jsxs("div",{style:{padding:r.padding||0,height:r.header?"calc(100% - 33px)":"100%",overflow:"auto"},children:[r.html?e.jsx("div",{dangerouslySetInnerHTML:{__html:r.html}}):r.content,(r.rows||r.cols)&&e.jsx(Ie,{rows:r.rows,cols:r.cols,style:{height:"100%"}})]})]})}function Ie({rows:r,cols:s,type:a="line",style:i,children:f}){g.useEffect(R,[]);const d=a==="space"?12:a==="wide"?8:1,p=r||s,u=!!r;return p?e.jsx("div",{className:"dhx",style:{display:"flex",flexDirection:u?"column":"row",gap:d,width:"100%",height:"100%",...i},children:p.map((y,m)=>e.jsx(tt,{config:y},y.id||m))}):e.jsx("div",{className:"dhx",style:{width:"100%",height:"100%",...i},children:f})}function rt({views:r=[],mode:s="top",tabAlign:a="left",closable:i=[],disabled:f=[],defaultActive:d,onBeforeChange:p,onChange:u,style:y}){var M;const[m,o]=g.useState(d||((M=r[0])==null?void 0:M.id)),[b,C]=g.useState(r.map(L=>L.id));g.useEffect(R,[]);const N=(L,V)=>{L.stopPropagation(),C(h=>h.filter(W=>W!==V)),m===V&&o(b.find(h=>h!==V)??"")},D=L=>{f.includes(L)||p&&p(L)===!1||(o(L),u==null||u(L))},c=s==="left"||s==="right",z=r.filter(L=>b.includes(L.id)),$=e.jsx("div",{style:{display:"flex",flexDirection:c?"column":"row",justifyContent:a==="center"?"center":a==="right"?"flex-end":"flex-start",background:t.surface,borderBottom:!c&&s!=="bottom"?`2px solid ${t.border}`:"none",borderTop:s==="bottom"?`2px solid ${t.border}`:"none",borderRight:s==="left"?`2px solid ${t.border}`:"none",borderLeft:s==="right"?`2px solid ${t.border}`:"none",overflowX:"auto",flexShrink:0},children:z.map(L=>{const V=m===L.id,h=f.includes(L.id),W=s==="bottom"?{borderTop:`2px solid ${t.primary}`,color:t.primary,fontWeight:600}:c?{color:t.primary,fontWeight:600,background:t.primaryLt,[s==="left"?"borderRight":"borderLeft"]:`2px solid ${t.primary}`}:{borderBottom:`2px solid ${t.primary}`,color:t.primary,fontWeight:600};return e.jsxs("div",{onClick:()=>D(L.id),style:{display:"flex",alignItems:"center",gap:6,padding:"10px 16px",cursor:h?"not-allowed":"pointer",whiteSpace:"nowrap",fontSize:13,transition:"color .15s",userSelect:"none",minWidth:c?120:"auto",...V?W:{color:h?t.textMut:t.textSec}},children:[L.icon&&e.jsx("span",{style:{fontSize:16},children:L.icon}),e.jsx("span",{children:L.tab}),i.includes(L.id)&&e.jsx("span",{onClick:l=>N(l,L.id),style:{marginLeft:4,opacity:.6,fontSize:12,cursor:"pointer"},children:"✕"})]},L.id)})}),I=z.find(L=>L.id===m),A=e.jsxs("div",{className:"dhx-scroll",style:{flex:1,overflow:"auto"},children:[I==null?void 0:I.content,(I==null?void 0:I.html)&&e.jsx("div",{dangerouslySetInnerHTML:{__html:I.html},style:{padding:16}})]});return e.jsxs("div",{className:"dhx",style:{display:"flex",flexDirection:s==="top"?"column":s==="bottom"?"column-reverse":s==="left"?"row":"row-reverse",width:"100%",height:"100%",background:t.surface,border:`1px solid ${t.border}`,borderRadius:t.r,overflow:"hidden",...y},children:[$,A]})}const he=`1px solid ${t.border}`;function nt({active:r,dir:s}){return e.jsxs("span",{style:{display:"inline-flex",flexDirection:"column",gap:1,flexShrink:0,marginLeft:4},children:[e.jsx("svg",{width:"7",height:"4",viewBox:"0 0 7 4",children:e.jsx("path",{d:"M3.5 0L7 4H0z",fill:r&&s==="asc"?t.primary:t.borderDk})}),e.jsx("svg",{width:"7",height:"4",viewBox:"0 0 7 4",children:e.jsx("path",{d:"M3.5 4L0 0H7z",fill:r&&s==="desc"?t.primary:t.borderDk})})]})}function ot({options:r,value:s,onChange:a,onCommit:i,onCancel:f}){const[d,p]=g.useState(s),[u,y]=g.useState(!0),m=g.useRef(null);g.useEffect(()=>{const b=C=>{m.current&&!m.current.contains(C.target)&&i()};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[i]);const o=r.filter(b=>!d||b.toLowerCase().includes(d.toLowerCase()));return e.jsxs("div",{ref:m,style:{width:"100%",position:"relative"},children:[e.jsx("input",{autoFocus:!0,value:d,onChange:b=>{p(b.target.value),a(b.target.value),y(!0)},onKeyDown:b=>{b.key==="Enter"&&i(),b.key==="Escape"&&f()},onClick:b=>b.stopPropagation(),style:{width:"100%",border:"none",outline:`2px solid ${t.primary}`,borderRadius:2,fontSize:13,padding:"2px 4px",background:t.surface,color:t.text}}),u&&o.length>0&&e.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,zIndex:50,background:t.surface,border:`1px solid ${t.border}`,borderRadius:t.r,boxShadow:t.shadowLg,maxHeight:160,overflowY:"auto"},children:o.map(b=>e.jsx("div",{onMouseDown:C=>{C.preventDefault(),a(b),p(b),y(!1),i()},style:{padding:"6px 10px",cursor:"pointer",fontSize:13,color:t.text},onMouseEnter:C=>C.currentTarget.style.background=t.bg,onMouseLeave:C=>C.currentTarget.style.background=t.surface,children:b},b))})]})}function st(r,s){if(r==null)return"";if(s==="number")return typeof r=="number"?r.toLocaleString():String(r);if(s==="date"){const a=r instanceof Date?r:new Date(String(r));return isNaN(a.getTime())?String(r):a.toLocaleDateString()}return String(r)}function lt(r,s,a){return r==null?1:s==null?-1:a==="date"?new Date(String(r)).getTime()-new Date(String(s)).getTime():a==="number"?Number(r)-Number(s):String(r)<String(s)?-1:String(r)>String(s)?1:0}function ye(r){var s;return Array.isArray(r.header)&&((s=r.header[1])==null?void 0:s.content)!=null?r.header[1].content:r.filterable?r.filterType==="select"?"selectFilter":"inputFilter":null}function it(r,s,a,i,f){const d={width:"100%",border:"none",outline:`2px solid ${t.primary}`,borderRadius:2,fontSize:13,padding:"2px 4px",background:t.surface,color:t.text},p=r.editorType??"input";if(p==="select")return e.jsx("select",{autoFocus:!0,value:s,onChange:y=>a(y.target.value),onBlur:i,onKeyDown:y=>{y.key==="Enter"&&i(),y.key==="Escape"&&f()},onClick:y=>y.stopPropagation(),style:{...d,cursor:"pointer"},children:(r.options??[]).map(y=>e.jsx("option",{value:y,children:y},y))});if(p==="combobox")return e.jsx(ot,{options:r.options??[],value:s,onChange:a,onCommit:i,onCancel:f});const u=r.type==="number"?"number":r.type==="date"?"date":"text";return e.jsx("input",{autoFocus:!0,type:u,value:s,onChange:y=>a(y.target.value),onBlur:i,onKeyDown:y=>{y.key==="Enter"&&i(),y.key==="Escape"&&f()},onClick:y=>y.stopPropagation(),style:d})}function dt({columns:r,data:s=[],height:a=400,rowHeight:i=40,headerRowHeight:f=40,footerRowHeight:d=40,sortable:p=!0,resizable:u=!0,editable:y=!1,stripe:m=!1,autoWidth:o=!1,keyNavigation:b=!1,selection:C,multiselect:N,leftSplit:D=0,onSelect:c,onChange:z,style:$}){var Oe;const[I,A]=g.useState(null),[M,L]=g.useState("asc"),[V,h]=g.useState({}),[W,l]=g.useState(new Set),[x,K]=g.useState(-1),[P,n]=g.useState(()=>Object.fromEntries(r.map(v=>[v.id,v.width??v.minWidth??150]))),[E,F]=g.useState(null),[w,k]=g.useState(""),[T,S]=g.useState({}),j=g.useRef(null),[X,Q]=g.useState(0);g.useEffect(R,[]),g.useEffect(()=>{if(!o||!j.current)return;const v=new ResizeObserver(()=>{var B;return Q(((B=j.current)==null?void 0:B.offsetWidth)??0)});return v.observe(j.current),()=>v.disconnect()},[o]);const G=g.useMemo(()=>r.map(v=>v.summary&&(!v.footer||v.footer.length===0)?{...v,footer:[{summary:v.summary}]}:v),[r]),U=g.useMemo(()=>G.filter(v=>!v.hidden),[G]),ee=g.useMemo(()=>{if(!o||X===0)return P;const v=U.reduce((H,Y)=>H+(P[Y.id]??150),0);if(X<=v)return P;const B=(X-v)/U.length;return Object.fromEntries(U.map(H=>[H.id,(P[H.id]??150)+B]))},[o,X,P,U]),te=g.useMemo(()=>{let v=s.map((B,H)=>{const Y=String(B.id??H);return T[Y]?{...B,...T[Y]}:B}).filter(B=>Object.entries(V).every(([H,Y])=>!Y||String(B[H]??"").toLowerCase().includes(Y.toLowerCase())));if(I){const B=G.find(H=>H.id===I);v=[...v].sort((H,Y)=>{const J=lt(H[I],Y[I],B==null?void 0:B.type);return M==="asc"?J:-J})}return v},[s,I,M,V,T,G]),pe=g.useMemo(()=>{const v={};return G.forEach(B=>{var H;if((H=B.footer)!=null&&H.some(Y=>Y.summary)){const Y=te.map(_=>Number(_[B.id])).filter(_=>!isNaN(_)),J=Y.reduce((_,ne)=>_+ne,0);v[B.id]={sum:J,avg:Y.length?J/Y.length:0,count:te.length,min:Y.length?Math.min(...Y):0,max:Y.length?Math.max(...Y):0}}}),v},[te,G]),re=g.useMemo(()=>{const v={};return U.filter(B=>{const H=ye(B);return H==="selectFilter"||H==="comboFilter"}).forEach(B=>{v[B.id]=[...new Set(s.map(H=>String(H[B.id]??"")))].sort()}),v},[s,U]),O=U.some(v=>ye(v)!==null),de=G.some(v=>{var B;return(B=v.footer)==null?void 0:B.length}),$e=U.reduce((v,B)=>v+(ee[B.id]??150),0),ae=g.useMemo(()=>{if(!D)return{};let v=0;const B={};return U.forEach((H,Y)=>{Y<D&&(B[H.id]=v,v+=ee[H.id]??150)}),B},[D,U,ee]),le=D>0?(Oe=U[D-1])==null?void 0:Oe.id:null,ge=(v,B)=>v.id??B,Bt=v=>{!p||v.sortable===!1||(L(B=>I===v.id&&B==="asc"?"desc":"asc"),A(v.id))},De=(v,B)=>{if(!C)return;const H=ge(v,B);K(B),l(Y=>{const J=N?new Set(Y):new Set;return J.has(H)?J.delete(H):J.add(H),J}),c==null||c(v)},Ht=()=>{if(!E)return;const{key:v,colId:B}=E;S(Y=>({...Y,[String(v)]:{...Y[String(v)]||{},[B]:w}}));const H=te.find((Y,J)=>ge(Y,J)===v);H&&(z==null||z(H,B,w)),F(null)},At=v=>{if(E&&v.key==="Escape"){F(null);return}if(!(!b||!C)){if(v.key==="ArrowDown"){v.preventDefault();const B=Math.min(x+1,te.length-1);B>=0&&De(te[B],B)}else if(v.key==="ArrowUp"){v.preventDefault();const B=Math.max(x-1,0);B>=0&&De(te[B],B)}}},jt=(v,B)=>{v.preventDefault(),v.stopPropagation();const H=v.clientX,Y=P[B]??150,J=r.find(oe=>oe.id===B),_=oe=>n(ue=>({...ue,[B]:Math.max((J==null?void 0:J.minWidth)||50,Y+oe.clientX-H)})),ne=()=>{document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",ne)};document.addEventListener("mousemove",_),document.addEventListener("mouseup",ne)},Le=(v,B,H,Y,J,_="hidden")=>{const ne=v in ae;return{width:B,minWidth:B,flexShrink:0,boxSizing:"border-box",padding:"0 12px",height:J,display:"flex",alignItems:"center",overflow:_,textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:13,textAlign:H,justifyContent:H==="center"?"center":H==="right"?"flex-end":"flex-start",borderLeft:Y?"none":he,position:ne?"sticky":"relative",...ne?{left:ae[v],zIndex:1,boxShadow:v===le?"2px 0 6px rgba(0,0,0,0.1)":void 0}:{}}};return e.jsx("div",{ref:j,className:"dhx",tabIndex:b?0:void 0,onKeyDown:At,style:{width:"100%",height:a,display:"flex",flexDirection:"column",border:he,borderRadius:t.r,overflow:"hidden",outline:"none",...$},children:e.jsx("div",{className:"dhx-scroll",style:{overflow:"auto",flex:1},children:e.jsxs("div",{style:{minWidth:$e,display:"flex",flexDirection:"column",minHeight:"100%"},children:[e.jsx("div",{style:{display:"flex",background:t.bg,borderBottom:he,flexShrink:0,position:"sticky",top:0,zIndex:3},children:U.map((v,B)=>{const H=Array.isArray(v.header)?v.header[0]:null,Y=(H==null?void 0:H.text)??(typeof v.header=="string"?v.header:v.id),J=(H==null?void 0:H.align)??v.align,_=ee[v.id]??150,ne=v.id in ae;return e.jsxs("div",{onClick:()=>Bt(v),style:{...Le(v.id,_,J,B===0,f),fontWeight:500,color:t.text,background:t.bg,cursor:p&&v.sortable!==!1?"pointer":"default",userSelect:"none",...ne?{zIndex:4}:{}},children:[H!=null&&H.htmlEnable?e.jsx("span",{style:{flex:1,overflow:"hidden"},dangerouslySetInnerHTML:{__html:Y}}):e.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Y}),p&&v.sortable!==!1&&e.jsx(nt,{active:I===v.id,dir:M}),u&&v.resizable!==!1&&B<U.length-1&&e.jsx("div",{onMouseDown:oe=>jt(oe,v.id),onClick:oe=>oe.stopPropagation(),style:{position:"absolute",right:0,top:0,bottom:0,width:4,cursor:"col-resize",zIndex:1},onMouseEnter:oe=>oe.currentTarget.style.background=t.primary+"55",onMouseLeave:oe=>oe.currentTarget.style.background="transparent"})]},v.id)})}),O&&e.jsx("div",{style:{display:"flex",borderBottom:he,background:t.surface,flexShrink:0,...D?{position:"sticky",top:f,zIndex:3}:{}},children:U.map((v,B)=>{const H=ye(v),Y=ee[v.id]??150,J=v.id in ae;return e.jsx("div",{style:{width:Y,minWidth:Y,flexShrink:0,padding:"4px 6px",boxSizing:"border-box",borderLeft:B===0?"none":he,background:t.surface,...J?{position:"sticky",left:ae[v.id],zIndex:4,boxShadow:v.id===le?"2px 0 6px rgba(0,0,0,0.1)":void 0}:{}},children:H==="selectFilter"||H==="comboFilter"?e.jsxs("select",{className:"dhx dhx-input",style:{height:26,fontSize:12,padding:"0 4px"},value:V[v.id]||"",onChange:_=>h(ne=>({...ne,[v.id]:_.target.value})),children:[e.jsx("option",{value:"",children:"All"}),(re[v.id]||[]).map(_=>e.jsx("option",{value:_,children:_},_))]}):H==="inputFilter"?e.jsx("input",{className:"dhx dhx-input",style:{height:26,fontSize:12},placeholder:"Filter...",value:V[v.id]||"",onChange:_=>h(ne=>({...ne,[v.id]:_.target.value}))}):null},v.id)})}),e.jsxs("div",{style:{flex:1},children:[te.map((v,B)=>{const H=ge(v,B),Y=W.has(H),J=Y?t.primaryLt:m&&B%2!==0?t.bg:t.surface;return e.jsx("div",{style:{display:"flex",height:i,borderBottom:he,flexShrink:0,background:J,transition:"background .1s",cursor:C?"pointer":"default"},onMouseEnter:_=>!Y&&(_.currentTarget.style.background=t.primaryLt+"80"),onMouseLeave:_=>!Y&&(_.currentTarget.style.background=J),children:U.map((_,ne)=>{const oe=(E==null?void 0:E.key)===H&&(E==null?void 0:E.colId)===_.id,ue=v[_.id],Pt=ee[_.id]??150,Fe=(y||_.editable)&&_.editable!==!1;let fe;return oe?fe=it(_,w,k,Ht,()=>F(null)):_.template?fe=_.template(ue,v):_.htmlEnable?fe=e.jsx("span",{dangerouslySetInnerHTML:{__html:String(ue??"")}}):_.type==="boolean"?fe=e.jsx("input",{type:"checkbox",readOnly:!0,checked:!!ue,style:{width:16,height:16,accentColor:t.primary,cursor:Fe?"pointer":"default"}}):fe=st(ue,_.type),e.jsx("div",{onClick:()=>{if(De(v,B),!!Fe)if(_.type==="boolean"){const Ye=!ue,_e=String(H);S(Ke=>({...Ke,[_e]:{...Ke[_e]||{},[_.id]:Ye}})),z==null||z(v,_.id,Ye)}else F({key:H,colId:_.id}),k(String(ue??""))},style:{...Le(_.id,Pt,_.align,ne===0,i,oe?"visible":"hidden"),background:J},children:fe},_.id)})},String(H))}),te.length===0&&e.jsx("div",{style:{textAlign:"center",padding:40,color:t.textMut,fontSize:13},children:"No data"})]}),de&&e.jsx("div",{style:{display:"flex",borderTop:he,background:t.bg,flexShrink:0,position:"sticky",bottom:0,zIndex:2},children:U.map((v,B)=>{var oe;const H=(oe=v.footer)==null?void 0:oe[0],Y=pe[v.id]??{sum:0,avg:0,count:0,min:0,max:0};let J="";H&&(typeof H.text=="function"?J=H.text(Y):H.text?J=H.text:H.summary&&(J=String(Math.round(Y[H.summary]*100)/100)));const _=ee[v.id]??150,ne=v.id in ae;return e.jsx("div",{style:{...Le(v.id,_,v.align,B===0,d),fontWeight:600,color:t.text,background:t.bg,...ne?{zIndex:3}:{}},children:J},v.id)})})]})})})}const se=["#0288d1","#43a047","#f57c00","#e53935","#8e24aa","#00838f","#ef6c00","#2e7d32"];function at(r,s,a){const i=r.filter(d=>!d.parent),f=r.filter(d=>!!d.parent);return i.map(d=>({name:d[a],children:f.filter(p=>p.parent===d.id).map(p=>({name:p[a],value:Number(p[s]??0)}))}))}function ct({type:r="bar",data:s=[],series:a=[],scales:i={},legend:f,height:d=280,style:p}){var z,$,I,A,M,L,V,h,W,l,x,K,P,n,E,F;g.useEffect(R,[]);const u=((z=i.bottom)==null?void 0:z.text)||s[0]&&Object.keys(s[0])[0]||"x",y=e.jsx(Z.Tooltip,{contentStyle:{fontSize:12,borderRadius:t.r,border:`1px solid ${t.border}`}}),m=f?e.jsx(Z.Legend,{iconSize:10,wrapperStyle:{fontSize:12},verticalAlign:f.valign==="bottom"?"bottom":f.valign==="middle"?"middle":"top",align:f.halign??"center"}):null,o=e.jsx(Z.CartesianGrid,{strokeDasharray:"3 3",stroke:t.border}),b=e.jsx(Z.XAxis,{dataKey:u,tick:{fontSize:11,fill:t.textSec},axisLine:{stroke:t.border},tickLine:!1,label:($=i.bottom)!=null&&$.title?{value:i.bottom.title,position:"insideBottom",offset:-4,fontSize:11}:void 0}),C=e.jsx(Z.YAxis,{tick:{fontSize:11,fill:t.textSec},axisLine:!1,tickLine:!1,domain:[((I=i.left)==null?void 0:I.min)??"auto",((A=i.left)==null?void 0:A.max)??"auto"],tickCount:(M=i.left)==null?void 0:M.maxTicks,label:(L=i.left)!=null&&L.title?{value:i.left.title,angle:-90,position:"insideLeft",fontSize:11}:void 0}),N={top:10,right:20,left:0,bottom:(V=i.bottom)!=null&&V.title?20:0},D={data:s,margin:N};let c;if(r==="bar")c=e.jsxs(Z.BarChart,{...D,children:[o,b,C,y,m,a.map((w,k)=>e.jsx(Z.Bar,{dataKey:w.value||w.id||"",name:w.label||w.id,fill:w.fill||w.color||se[k%se.length],radius:[3,3,0,0]},w.id??k))]});else if(r==="line")c=e.jsxs(Z.LineChart,{...D,children:[o,b,C,y,m,a.map((w,k)=>{const T=w.color||se[k%se.length];return e.jsx(Z.Line,{type:"monotone",dataKey:w.value||w.id||"",name:w.label||w.id,stroke:T,strokeWidth:w.strokeWidth??2,dot:{r:3,fill:T}},w.id??k)})]});else if(r==="area")c=e.jsxs(Z.AreaChart,{...D,children:[o,b,C,y,m,a.map((w,k)=>{const T=w.color||se[k%se.length];return e.jsx(Z.Area,{type:"monotone",dataKey:w.value||w.id||"",name:w.label||w.id,stroke:T,fill:(w.fill||T)+"33",strokeWidth:w.strokeWidth??2},w.id??k)})]});else if(r==="pie"||r==="donut"){const w=a[0]||{},k=w.value||"value",T=w.text||"name",S=w.color&&s[0]&&w.color in s[0]?w.color:null;c=e.jsxs(Z.PieChart,{children:[e.jsx(Z.Pie,{data:s,cx:"50%",cy:"50%",outerRadius:r==="donut"?"70%":"80%",innerRadius:r==="donut"?"40%":0,dataKey:k,nameKey:T,stroke:w.stroke||"none",strokeWidth:w.strokeWidth??0,label:({name:j,percent:X})=>`${j??""} ${((X??0)*100).toFixed(0)}%`,labelLine:!0,paddingAngle:2,children:s.map((j,X)=>e.jsx(Z.Cell,{fill:S?j[S]:se[X%se.length]},X))}),y,m]})}else if(r==="radar"){const w=((h=i.radial)==null?void 0:h.value)||u;c=e.jsxs(Z.RadarChart,{...D,cx:"50%",cy:"50%",children:[e.jsx(Z.PolarGrid,{}),e.jsx(Z.PolarAngleAxis,{dataKey:w,tick:{fontSize:11}}),e.jsx(Z.PolarRadiusAxis,{tick:{fontSize:9,fill:t.textMut},axisLine:!1}),a.map((k,T)=>{const S=k.color||k.pointColor||se[T%se.length];return e.jsx(Z.Radar,{dataKey:k.value||k.id||"",name:k.label||k.id,stroke:S,fill:S+"44"},k.id??T)}),y,m]})}else if(r==="scatter")c=e.jsxs(Z.ScatterChart,{margin:N,children:[o,e.jsx(Z.XAxis,{type:"number",dataKey:"x",name:((W=i.bottom)==null?void 0:W.title)||"x",tick:{fontSize:11,fill:t.textSec},tickLine:!1,domain:[((l=i.bottom)==null?void 0:l.min)??"auto",((x=i.bottom)==null?void 0:x.max)??"auto"],label:(K=i.bottom)!=null&&K.title?{value:i.bottom.title,position:"insideBottom",offset:-4,fontSize:11}:void 0}),e.jsx(Z.YAxis,{type:"number",dataKey:"y",name:((P=i.left)==null?void 0:P.title)||"y",tick:{fontSize:11,fill:t.textSec},tickLine:!1,axisLine:!1,domain:[((n=i.left)==null?void 0:n.min)??"auto",((E=i.left)==null?void 0:E.max)??"auto"],label:(F=i.left)!=null&&F.title?{value:i.left.title,angle:-90,position:"insideLeft",fontSize:11}:void 0}),y,m,a.map((w,k)=>{const T=w.value||"x",S=w.valueY||"y",j=(w.data||s).map(X=>({x:X[T],y:X[S]}));return e.jsx(Z.Scatter,{data:j,name:w.label||w.id,fill:w.color||se[k%se.length]},w.id??k)})]});else if(r==="treeMap"){const w=a[0]||{},k=w.value||"value",T=w.text||"name",S=at(s,k,T),j=w.stroke||t.surface,X=w.strokeWidth??2;c=e.jsx(Z.Treemap,{data:S,dataKey:"value",aspectRatio:4/3,stroke:j,content:Q=>{const{x:G,y:U,width:ee,height:te,depth:pe,index:re,name:O}=Q;if(pe===0)return null;const de=se[re%se.length];return e.jsxs("g",{children:[e.jsx("rect",{x:G,y:U,width:ee,height:te,fill:de,stroke:j,strokeWidth:X,style:{borderRadius:3}}),ee>40&&te>20&&e.jsx("text",{x:G+ee/2,y:U+te/2,textAnchor:"middle",dominantBaseline:"middle",fill:"#fff",fontSize:11,pointerEvents:"none",children:O})]})}})}return e.jsx("div",{className:"dhx",style:{width:"100%",height:d,padding:12,background:t.surface,borderRadius:t.rMd,...p},children:e.jsx(Z.ResponsiveContainer,{width:"100%",height:"100%",children:c})})}const pt=["January","February","March","April","May","June","July","August","September","October","November","December"],ut=["Su","Mo","Tu","We","Th","Fr","Sa"];function ht({value:r,range:s=!1,timepicker:a=!1,onChange:i,style:f}){const d=new Date,p=r?new Date(Array.isArray(r)?r[0]:r):d,[u,y]=g.useState(p),[m,o]=g.useState(r??(s?[null,null]:null)),[b,C]=g.useState(null),[N,D]=g.useState({h:0,m:0});g.useEffect(R,[]);const c=u.getFullYear(),z=u.getMonth(),$=new Date(c,z,1).getDay(),I=new Date(c,z+1,0).getDate(),A=[];for(let h=0;h<$;h++)A.push(null);for(let h=1;h<=I;h++)A.push(new Date(c,z,h));const M=h=>h.toDateString()===d.toDateString(),L=h=>{if(!m)return!1;if(s&&Array.isArray(m)){const[W,l]=m;if(!W)return!1;const x=h.getTime();return l?x>=W.getTime()&&x<=l.getTime():h.toDateString()===W.toDateString()}return h.toDateString()===m.toDateString()},V=h=>{if(s){const[W,l]=Array.isArray(m)?m:[null,null];if(!W||l)o([h,null]);else{const x=h<W?[h,W]:[W,h];o(x),i==null||i(x)}}else o(h),i==null||i(h)};return e.jsxs("div",{className:"dhx",style:{background:t.surface,border:`1px solid ${t.border}`,borderRadius:t.rMd,padding:16,display:"inline-block",boxShadow:t.shadow,...f},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[e.jsx("button",{onClick:()=>y(h=>new Date(h.getFullYear(),h.getMonth()-1,1)),className:"dhx dhx-btn dhx-btn-ghost",style:{height:28,padding:"0 8px",fontSize:16},children:"‹"}),e.jsxs("div",{style:{fontWeight:700,fontSize:14},children:[pt[z]," ",c]}),e.jsx("button",{onClick:()=>y(h=>new Date(h.getFullYear(),h.getMonth()+1,1)),className:"dhx dhx-btn dhx-btn-ghost",style:{height:28,padding:"0 8px",fontSize:16},children:"›"})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(7, 32px)",gap:2},children:[ut.map(h=>e.jsx("div",{style:{textAlign:"center",fontSize:11,fontWeight:600,color:t.textMut,paddingBottom:4},children:h},h)),A.map((h,W)=>{const l=h?L(h):!1,x=h&&b&&h.toDateString()===b.toDateString();return e.jsx("div",{onClick:()=>h&&V(h),onMouseEnter:()=>h&&C(h),onMouseLeave:()=>C(null),style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:t.r,cursor:h?"pointer":"default",fontSize:12,fontWeight:h&&M(h)?700:400,background:l?t.primary:x?t.bg:"transparent",color:l?"#fff":h&&M(h)?t.primary:h?t.text:"transparent",border:h&&M(h)&&!l?`1px solid ${t.primary}`:"1px solid transparent",transition:"all .1s"},children:h==null?void 0:h.getDate()},W)})]}),a&&e.jsxs("div",{style:{borderTop:`1px solid ${t.border}`,marginTop:12,paddingTop:12,display:"flex",alignItems:"center",justifyContent:"center",gap:8},children:[e.jsx("input",{type:"number",min:0,max:23,value:N.h,onChange:h=>D(W=>({...W,h:+h.target.value})),className:"dhx dhx-input",style:{width:50,textAlign:"center"}}),e.jsx("span",{style:{fontWeight:700,color:t.textSec},children:":"}),e.jsx("input",{type:"number",min:0,max:59,value:N.m,onChange:h=>D(W=>({...W,m:+h.target.value})),className:"dhx dhx-input",style:{width:50,textAlign:"center"}})]})]})}function We({value:r,onChange:s,timeFormat:a=12,controls:i=!1,minuteStep:f=5,style:d}){const[p,u]=g.useState((r==null?void 0:r.h)??(a===24?0:12)),[y,m]=g.useState((r==null?void 0:r.m)??0),[o,b]=g.useState((r==null?void 0:r.ampm)??"AM"),[C,N]=g.useState(null);g.useEffect(R,[]);const D=a===24?Array.from({length:24},(M,L)=>L):Array.from({length:12},(M,L)=>L+1),c=Array.from({length:Math.ceil(60/f)},(M,L)=>L*f),z=(M,L,V)=>{const h=a===24?{h:M,m:L}:{h:M,m:L,ampm:V};i?N(h):s==null||s(h)},$=()=>{N(null),u((r==null?void 0:r.h)??(a===24?0:12)),m((r==null?void 0:r.m)??0),b((r==null?void 0:r.ampm)??"AM")},I={display:"flex",flexDirection:"column",alignItems:"center",gap:4},A=M=>({height:32,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:13,fontWeight:M?700:400,background:M?t.primaryLt:"transparent",color:M?t.primary:t.text});return e.jsxs("div",{className:"dhx",style:{background:t.surface,border:`1px solid ${t.border}`,borderRadius:t.rMd,padding:16,display:"inline-block",boxShadow:t.shadow,...d},children:[e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"stretch"},children:[e.jsxs("div",{style:I,children:[e.jsx("span",{style:{fontSize:11,fontWeight:600,color:t.textMut},children:"Hours"}),e.jsx("div",{className:"dhx-scroll",style:{height:160,overflowY:"auto",width:48,border:`1px solid ${t.border}`,borderRadius:t.r},children:D.map(M=>e.jsx("div",{onClick:()=>{u(M),z(M,y,o)},style:A(p===M),onMouseEnter:L=>p!==M&&(L.currentTarget.style.background=t.bg),onMouseLeave:L=>p!==M&&(L.currentTarget.style.background="transparent"),children:String(M).padStart(2,"0")},M))})]}),e.jsxs("div",{style:I,children:[e.jsx("span",{style:{fontSize:11,fontWeight:600,color:t.textMut},children:"Minutes"}),e.jsx("div",{className:"dhx-scroll",style:{height:160,overflowY:"auto",width:48,border:`1px solid ${t.border}`,borderRadius:t.r},children:c.map(M=>e.jsx("div",{onClick:()=>{m(M),z(p,M,o)},style:A(y===M),onMouseEnter:L=>y!==M&&(L.currentTarget.style.background=t.bg),onMouseLeave:L=>y!==M&&(L.currentTarget.style.background="transparent"),children:String(M).padStart(2,"0")},M))})]}),a===12&&e.jsxs("div",{style:I,children:[e.jsx("span",{style:{fontSize:11,fontWeight:600,color:t.textMut},children:"AM/PM"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",border:`1px solid ${t.border}`,borderRadius:t.r,overflow:"hidden"},children:["AM","PM"].map(M=>e.jsx("div",{onClick:()=>{b(M),z(p,y,M)},style:{height:40,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:"0 12px",fontSize:13,fontWeight:o===M?700:400,background:o===M?t.primary:t.surface,color:o===M?"#fff":t.text},children:M},M))})]})]}),e.jsxs("div",{style:{textAlign:"center",marginTop:12,fontSize:22,fontWeight:700,color:t.primary,letterSpacing:2},children:[String(p).padStart(2,"0"),":",String(y).padStart(2,"0"),a===12?` ${o}`:""]}),i&&e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:12},children:[e.jsx("button",{className:"dhx dhx-btn dhx-btn-secondary",onClick:$,children:"Cancel"}),e.jsx("button",{className:"dhx dhx-btn dhx-btn-primary",onClick:()=>{const M=C??(a===24?{h:p,m:y}:{h:p,m:y,ampm:o});s==null||s(M)},children:"Apply"})]})]})}const ft=({open:r})=>e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",style:{flexShrink:0,transition:"transform .15s",transform:r?"rotate(180deg)":"rotate(0deg)"},children:e.jsx("path",{d:"M2 4l4 4 4-4",stroke:t.textMut,strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})});function be({data:r=[],value:s,placeholder:a="Select or type...",multiselection:i=!1,label:f,onChange:d,style:p}){var V;const[u,y]=g.useState(!1),[m,o]=g.useState(""),[b,C]=g.useState(i?s?[].concat(s):[]:s||null),N=g.useRef(null),D=g.useRef(null);g.useEffect(R,[]),ce(N,g.useCallback(()=>{y(!1),o("")},[]));const c=g.useMemo(()=>r.filter(h=>!m||h.value.toLowerCase().includes(m.toLowerCase())),[r,m]),z=h=>i?(b||[]).includes(h):b===h,$=h=>{const W=h.id||h.value;if(i){const l=z(W)?b.filter(x=>x!==W):[...b||[],W];C(l),d==null||d(l)}else C(W),o(""),y(!1),d==null||d(W)},I=h=>{const W=b.filter(l=>l!==h);C(W),d==null||d(W)},A=()=>{y(!0),setTimeout(()=>{var h;return(h=D.current)==null?void 0:h.focus()},0)},M=((V=r.find(h=>(h.id||h.value)===b))==null?void 0:V.value)||"",L=i?b||[]:[];return e.jsxs("div",{ref:N,className:"dhx",style:{position:"relative",...p},children:[f&&e.jsx("label",{className:"dhx dhx-label",children:f}),e.jsxs("div",{onClick:A,style:{display:"flex",alignItems:"center",flexWrap:i?"wrap":"nowrap",border:`1px solid ${u?t.primary:t.border}`,borderRadius:t.r,minHeight:34,padding:"4px 8px",cursor:"text",background:t.surface,gap:4,transition:"border-color .15s",boxShadow:u?`0 0 0 3px ${t.primary}22`:"none"},children:[i&&e.jsxs(e.Fragment,{children:[L.map(h=>{var W;return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,background:t.primary,color:"#fff",borderRadius:12,padding:"2px 10px 2px 8px",fontSize:12,lineHeight:1.5,whiteSpace:"nowrap"},children:[((W=r.find(l=>(l.id||l.value)===h))==null?void 0:W.value)||h,e.jsx("span",{onClick:l=>{l.stopPropagation(),I(h)},style:{cursor:"pointer",fontSize:15,lineHeight:1,opacity:.75,marginLeft:2},children:"×"})]},h)}),e.jsx("input",{ref:D,value:m,onChange:h=>{o(h.target.value),y(!0)},onFocus:()=>y(!0),onClick:h=>h.stopPropagation(),placeholder:L.length?"":a,style:{flex:1,minWidth:60,border:"none",outline:"none",fontSize:13,background:"transparent",color:t.text,padding:0}})]}),!i&&e.jsx("input",{ref:D,value:u?m:M,onChange:h=>{o(h.target.value),y(!0)},onFocus:()=>{y(!0),o("")},onClick:h=>h.stopPropagation(),placeholder:a,style:{flex:1,border:"none",outline:"none",fontSize:13,background:"transparent",color:t.text,padding:0}}),e.jsx(ft,{open:u})]}),u&&e.jsx("div",{className:"dhx dhx-anim-fade",style:{position:"absolute",top:"calc(100% + 4px)",left:0,right:0,background:t.surface,border:`1px solid ${t.border}`,borderRadius:t.r,boxShadow:t.shadowLg,zIndex:100},children:e.jsxs("div",{className:"dhx-scroll",style:{maxHeight:220,overflowY:"auto"},children:[c.map(h=>{const W=h.id||h.value,l=z(W);return e.jsxs("div",{onClick:()=>$(h),style:{padding:"8px 12px",cursor:"pointer",display:"flex",alignItems:"center",gap:8,fontSize:13,background:l?t.primaryLt:"transparent",color:l?t.primary:t.text},onMouseEnter:x=>!l&&(x.currentTarget.style.background=t.bg),onMouseLeave:x=>!l&&(x.currentTarget.style.background="transparent"),children:[i&&e.jsx("span",{style:{width:14,height:14,flexShrink:0,border:`2px solid ${l?t.primary:t.borderDk}`,borderRadius:3,display:"flex",alignItems:"center",justifyContent:"center",background:l?t.primary:"transparent"},children:l&&e.jsx("span",{style:{color:"#fff",fontSize:9,lineHeight:1},children:"✓"})}),e.jsx("span",{style:{flex:1},children:h.value}),!i&&l&&e.jsx("span",{style:{color:t.primary,fontSize:12,fontWeight:700},children:"✓"}),h.count!==void 0&&e.jsxs("span",{style:{fontSize:11,color:t.textMut},children:["(",h.count,")"]})]},W)}),c.length===0&&e.jsx("div",{style:{padding:16,textAlign:"center",color:t.textMut,fontSize:13},children:"No matches"})]})})]})}function ve({min:r=0,max:s=100,step:a=1,value:i,range:f=!1,label:d,tick:p,disabled:u=!1,onChange:y,style:m}){const[o,b]=g.useState(i??(f?[r,s]:r));g.useEffect(R,[]);const C=($,I)=>{if(!u)if(f){const A=[...o];A[$]=I,b(A),y==null||y(A)}else b(I),y==null||y(I)},N=$=>($-r)/(s-r)*100,D=f?o:[o],c=f?{left:`${N(D[0])}%`,width:`${N(D[1])-N(D[0])}%`}:{left:0,width:`${N(D[0])}%`},z=u?t.border:t.primary;return e.jsxs("div",{className:"dhx",style:{width:"100%",opacity:u?.5:1,...m},children:[d&&e.jsx("label",{className:"dhx dhx-label",children:d}),e.jsx("div",{style:{position:"relative",height:36,display:"flex",alignItems:"center"},children:e.jsxs("div",{style:{position:"relative",flex:1,height:4,background:t.border,borderRadius:2},children:[e.jsx("div",{style:{position:"absolute",...c,height:"100%",background:z,borderRadius:2}}),D.map(($,I)=>e.jsx("input",{type:"range",min:r,max:s,step:a,value:$,disabled:u,onChange:A=>{const M=+A.target.value;f&&I===0&&M>=o[1]||f&&I===1&&M<=o[0]||C(I,M)},style:{position:"absolute",width:"100%",height:"100%",opacity:0,cursor:u?"not-allowed":"pointer",top:0,left:0,margin:0}},I)),D.map(($,I)=>e.jsx("div",{style:{position:"absolute",left:`${N($)}%`,top:"50%",transform:"translate(-50%, -50%)",width:16,height:16,borderRadius:"50%",background:t.surface,border:`2px solid ${z}`,boxShadow:"0 1px 4px rgba(0,0,0,.2)",pointerEvents:"none"},children:e.jsx("div",{style:{position:"absolute",bottom:"calc(100% + 6px)",left:"50%",transform:"translateX(-50%)",background:u?t.textMut:t.primaryDk,color:"#fff",padding:"2px 6px",borderRadius:t.r,fontSize:11,fontWeight:700,whiteSpace:"nowrap"},children:$})},I))]})}),p&&e.jsx("div",{style:{display:"flex",justifyContent:"space-between",marginTop:2},children:[r,Math.round((s+r)/2),s].map($=>e.jsx("span",{style:{fontSize:10,color:t.textMut},children:$},$))})]})}const gt=["#f44336","#e91e63","#9c27b0","#673ab7","#3f51b5","#2196f3","#03a9f4","#00bcd4","#009688","#4caf50","#8bc34a","#cddc39","#ffeb3b","#ffc107","#ff9800","#ff5722","#795548","#607d8b","#9e9e9e","#000000","#ffffff","#0288d1","#01579b","#43a047","#e53935","#f57c00"];function Se(r){const s=parseInt(r.slice(1,3),16)/255,a=parseInt(r.slice(3,5),16)/255,i=parseInt(r.slice(5,7),16)/255,f=Math.max(s,a,i),d=Math.min(s,a,i);let p=0,u=0;const y=(f+d)/2;if(f!==d){const m=f-d;u=y>.5?m/(2-f-d):m/(f+d),p=f===s?((a-i)/m+(a<i?6:0))/6:f===a?((i-s)/m+2)/6:((s-a)/m+4)/6}return[Math.round(p*360),Math.round(u*100),Math.round(y*100)]}function Be(r,s,a){s/=100,a/=100;const i=s*Math.min(a,1-a),f=d=>{const p=(d+r/30)%12,u=a-i*Math.max(Math.min(p-3,9-p,1),-1);return Math.round(255*u).toString(16).padStart(2,"0")};return"#"+f(0)+f(8)+f(4)}function xt({value:r="#0288d1",onChange:s,style:a}){const[i,f]=g.useState(()=>Se(r)),d=Be(...i);g.useEffect(R,[]);const p=u=>{f(u),s==null||s(Be(...u))};return e.jsxs("div",{className:"dhx",style:{background:t.surface,border:`1px solid ${t.border}`,borderRadius:t.rMd,padding:16,display:"inline-block",boxShadow:t.shadow,...a},children:[e.jsx("div",{style:{width:200,height:120,borderRadius:t.r,marginBottom:12,background:`linear-gradient(to bottom, transparent, black), linear-gradient(to right, white, hsl(${i[0]},100%,50%))`,cursor:"crosshair"}}),[["Hue",0,360,i[0]],["Saturation",0,100,i[1]],["Lightness",0,100,i[2]]].map(([u,y,m,o],b)=>e.jsxs("div",{style:{marginBottom:b<2?8:12},children:[e.jsxs("div",{className:"dhx dhx-label",children:[u,b>0?` (${o}%)`:""]}),e.jsx("input",{type:"range",min:y,max:m,value:o,onChange:C=>{const N=[...i];N[b]=+C.target.value,p(N)},style:{width:"100%",accentColor:t.primary}})]},u)),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[e.jsx("div",{style:{width:36,height:36,borderRadius:t.r,background:d,border:`1px solid ${t.border}`,flexShrink:0}}),e.jsx("input",{className:"dhx dhx-input",style:{flex:1,fontFamily:"monospace",fontSize:12},value:d,onChange:u=>{try{p(Se(u.target.value)),s==null||s(u.target.value)}catch{}}})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(13, 1fr)",gap:3},children:gt.map(u=>e.jsx("div",{onClick:()=>{f(Se(u)),s==null||s(u)},style:{width:14,height:14,borderRadius:2,background:u,cursor:"pointer",border:d===u?`2px solid ${t.text}`:"1px solid rgba(0,0,0,.15)",transition:"transform .1s"},onMouseEnter:y=>y.currentTarget.style.transform="scale(1.3)",onMouseLeave:y=>y.currentTarget.style.transform="scale(1)"},u))})]})}function yt({trigger:r,children:s,placement:a="bottom-start",style:i}){const[f,d]=g.useState(!1),[p,u]=g.useState({top:"100%",left:0}),y=g.useRef(null),m=g.useRef(null);g.useEffect(R,[]),ce(y,g.useCallback(()=>d(!1),[]));const o=()=>{d(b=>{if(!b&&m.current){const C=m.current.getBoundingClientRect(),N={"bottom-start":{top:C.height+4,left:0},"bottom-end":{top:C.height+4,right:0,left:"auto"},"top-start":{bottom:C.height+4,top:"auto",left:0}};u(N[a]||N["bottom-start"])}return!b})};return e.jsxs("div",{ref:y,className:"dhx",style:{position:"relative",display:"inline-block"},children:[e.jsx("div",{ref:m,onClick:o,children:r}),f&&e.jsx("div",{className:"dhx dhx-anim-fade",style:{position:"absolute",...p,zIndex:200,background:t.surface,border:`1px solid ${t.border}`,borderRadius:t.rMd,boxShadow:t.shadowLg,...i},children:s})]})}function bt({title:r,children:s,width:a=480,height:i,closable:f=!0,movable:d=!0,modal:p=!1,defaultOpen:u=!0,footer:y,onClose:m,style:o}){const[b,C]=g.useState(u),[N,D]=g.useState({x:0,y:0});g.useEffect(R,[]);const c=Ee(g.useCallback(($,I)=>d&&D({x:$,y:I}),[d])),z=()=>{C(!1),m==null||m()};return b?e.jsxs(e.Fragment,{children:[p&&e.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,.45)",zIndex:900},onClick:f?z:void 0}),e.jsxs("div",{className:"dhx",style:{position:p?"fixed":"absolute",left:"50%",top:"50%",transform:`translate(calc(-50% + ${N.x}px), calc(-50% + ${N.y}px))`,width:a,...i?{height:i}:{},background:t.surface,borderRadius:t.rMd,boxShadow:t.shadowLg,zIndex:901,display:"flex",flexDirection:"column",overflow:"hidden",...o},children:[e.jsxs("div",{onMouseDown:$=>c($,N.x,N.y),style:{display:"flex",alignItems:"center",padding:"12px 16px",borderBottom:`1px solid ${t.border}`,cursor:d?"grab":"default",background:t.bg,gap:8,userSelect:"none"},children:[e.jsx("span",{style:{flex:1,fontWeight:700,fontSize:15},children:r}),f&&e.jsx("button",{onClick:z,style:{background:"none",border:"none",cursor:"pointer",width:28,height:28,borderRadius:t.r,display:"flex",alignItems:"center",justifyContent:"center",fontSize:18,color:t.textSec},onMouseEnter:$=>$.currentTarget.style.background=t.border,onMouseLeave:$=>$.currentTarget.style.background="none",children:"×"})]}),e.jsx("div",{className:"dhx-scroll",style:{flex:1,minHeight:0,padding:20,overflowY:"auto"},children:s}),y&&e.jsx("div",{style:{padding:"12px 16px",borderTop:`1px solid ${t.border}`,display:"flex",justifyContent:"flex-end",gap:8,background:t.bg},children:y})]})]}):null}const ke=g.createContext(null),vt={success:"✓",error:"✕",warning:"⚠",info:"ℹ"},He={success:t.success,error:t.danger,warning:t.warning,info:t.primary};function St({children:r}){const[s,a]=g.useState([]);g.useEffect(R,[]);const i=g.useCallback(p=>a(u=>u.filter(y=>y.id!==p)),[]),f=g.useCallback(p=>{const u=Date.now();return a(y=>[...y,{id:u,...p}]),p.duration!==0&&setTimeout(()=>i(u),p.duration||4e3),u},[i]),d={message:f,alert:(p,u)=>f({type:"info",title:p,...u}),confirm:(p,u,y)=>f({type:"warning",title:p,confirm:u,...y})};return e.jsxs(ke.Provider,{value:d,children:[r,e.jsx("div",{style:{position:"fixed",top:20,right:20,zIndex:9999,display:"flex",flexDirection:"column",gap:8,pointerEvents:"none"},children:s.map(p=>{const u=p.type||"info";return e.jsxs("div",{style:{background:t.surface,border:`1px solid ${t.border}`,borderLeft:`4px solid ${He[u]}`,borderRadius:t.r,boxShadow:t.shadowLg,padding:"12px 16px",minWidth:280,maxWidth:380,pointerEvents:"all",display:"flex",gap:10,alignItems:"flex-start",animation:"dhx-toast .3s ease"},children:[e.jsx("span",{style:{fontSize:18,color:He[u],lineHeight:1},children:vt[u]}),e.jsxs("div",{style:{flex:1},children:[p.title&&e.jsx("div",{style:{fontWeight:600,fontSize:13,marginBottom:p.text?3:0},children:p.title}),p.text&&e.jsx("div",{style:{fontSize:12,color:t.textSec,lineHeight:1.5},children:p.text}),p.confirm&&e.jsxs("div",{style:{display:"flex",gap:6,marginTop:8},children:[e.jsx("button",{className:"dhx dhx-btn dhx-btn-primary",style:{height:26,fontSize:12},onClick:()=>{p.confirm(!0),i(p.id)},children:"Confirm"}),e.jsx("button",{className:"dhx dhx-btn dhx-btn-secondary",style:{height:26,fontSize:12},onClick:()=>{p.confirm(!1),i(p.id)},children:"Cancel"})]})]}),e.jsx("button",{onClick:()=>i(p.id),style:{background:"none",border:"none",cursor:"pointer",color:t.textMut,fontSize:14,lineHeight:1,padding:0},children:"×"})]},p.id)})})]})}function kt(){const r=g.useContext(ke);if(!r)throw new Error("useMessage must be used inside <MessageProvider>");return r}function wt({data:r=[],template:s,keyNavigation:a=!0,multiselection:i=!1,editable:f=!1,height:d=400,onSelect:p,onEdit:u,style:y}){const[m,o]=g.useState(new Set),[b,C]=g.useState(null),[N,D]=g.useState(""),[c,z]=g.useState(null);g.useEffect(R,[]);const $=(A,M)=>{const L=A.id??M;o(V=>{const h=i?new Set(V):new Set;return h.has(L)?h.delete(L):h.add(L),h}),z(M),p==null||p(A)},I=(A,M)=>{u==null||u({...A,value:N},M),C(null)};return e.jsxs("div",{className:"dhx dhx-scroll",style:{height:d,overflowY:"auto",border:`1px solid ${t.border}`,borderRadius:t.r,background:t.surface,...y},tabIndex:0,onKeyDown:A=>{a&&(A.key==="ArrowDown"&&z(M=>Math.min((M??-1)+1,r.length-1)),A.key==="ArrowUp"&&z(M=>Math.max((M??1)-1,0)))},children:[r.map((A,M)=>{const L=A.id??M,V=m.has(L),h=c===M;return e.jsx("div",{onClick:()=>$(A,M),onDoubleClick:()=>f&&(C(M),D(String(A.value||""))),style:{display:"flex",alignItems:"center",padding:"0 12px",height:40,cursor:"pointer",fontSize:13,borderBottom:`1px solid ${t.border}`,background:V?t.primaryLt:h?t.bg:t.surface,color:V?t.primary:t.text,outline:h?`2px solid ${t.primary}44`:"none",transition:"background .1s"},children:b===M?e.jsx("input",{autoFocus:!0,className:"dhx dhx-input",style:{height:28,flex:1},value:N,onChange:W=>D(W.target.value),onBlur:()=>I(A,M),onKeyDown:W=>{W.key==="Enter"&&I(A,M),W.key==="Escape"&&C(null)},onClick:W=>W.stopPropagation()}):s?e.jsx("div",{dangerouslySetInnerHTML:{__html:s(A)},style:{flex:1}}):e.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:String(A.value??"")})},String(L))}),r.length===0&&e.jsx("div",{style:{padding:24,textAlign:"center",color:t.textMut},children:"No items"})]})}function zt({data:r=[],template:s,itemsInRow:a=3,gap:i=12,multiselection:f=!1,onSelect:d,style:p}){const[u,y]=g.useState(new Set);g.useEffect(R,[]);const m=o=>{const b=o.id??String(o.title);y(C=>{const N=f?new Set(C):new Set;return N.has(b)?N.delete(b):N.add(b),N}),d==null||d(o)};return e.jsx("div",{className:"dhx",style:{display:"grid",gridTemplateColumns:`repeat(${a}, 1fr)`,gap:i,padding:i,...p},children:r.map((o,b)=>{const C=o.id??b,N=u.has(C);return e.jsx("div",{onClick:()=>m(o),style:{background:t.surface,border:`2px solid ${N?t.primary:t.border}`,borderRadius:t.rMd,overflow:"hidden",cursor:"pointer",transition:"all .15s",boxShadow:N?`0 0 0 3px ${t.primary}33`:t.shadow,transform:N?"translateY(-2px)":"none"},onMouseEnter:D=>{D.currentTarget.style.boxShadow=t.shadowLg,D.currentTarget.style.transform="translateY(-2px)"},onMouseLeave:D=>{D.currentTarget.style.boxShadow=N?`0 0 0 3px ${t.primary}33`:t.shadow,D.currentTarget.style.transform=N?"translateY(-2px)":"none"},children:s?e.jsx("div",{dangerouslySetInnerHTML:{__html:s(o)}}):e.jsxs("div",{style:{padding:16},children:[o.img&&e.jsx("img",{src:o.img,alt:o.title||"",style:{width:"100%",borderRadius:t.r,marginBottom:8,display:"block"}}),e.jsx("div",{style:{fontWeight:600,fontSize:14,marginBottom:4},children:o.title||o.value}),o.subtitle&&e.jsx("div",{style:{fontSize:12,color:t.textSec},children:o.subtitle})]})},String(C))})})}function we(r){return r.map(s=>({...s,items:s.items?we(s.items):void 0}))}function ze(r,s={}){return r.forEach(a=>{a.opened&&(s[a.id]=!0),a.items&&ze(a.items,s)}),s}function Ae(r,s){let a=null;return[r.filter(f=>f.id===s?(a=f,!1):!0).map(f=>{if(f.items){const[d,p]=Ae(f.items,s);return p&&(a=p),{...f,items:d}}return f}),a]}function Me(r,s,a,i){if(i==="inside")return r.map(d=>d.id===s?{...d,items:[...d.items||[],a]}:d.items?{...d,items:Me(d.items,s,a,i)}:d);if(r.some(d=>d.id===s)){const d=[];for(const p of r)p.id===s?i==="before"?(d.push(a),d.push(p)):(d.push(p),d.push(a)):d.push(p);return d}return r.map(d=>d.items?{...d,items:Me(d.items,s,a,i)}:d)}function Mt(r,s,a){function i(f){var d,p;if(f.id===s){const u=y=>{var m;return y.id===a||(((m=y.items)==null?void 0:m.some(u))??!1)};return((d=f.items)==null?void 0:d.some(u))??!1}return((p=f.items)==null?void 0:p.some(i))??!1}return r.some(i)}function je(r,s,a){return r.map(i=>i.id===s?{...i,value:a}:{...i,items:i.items?je(i.items,s,a):void 0})}function mt(r,s){var d;let a=0,i=0;const f=p=>{var u;a++,s[p.id]&&i++,(u=p.items)==null||u.forEach(f)};return(d=r.items)==null||d.forEach(f),{total:a,checkedCount:i}}function Ct({data:r=[],checkbox:s=!1,editable:a=!1,dragMode:i,tooltip:f,onSelect:d,onCheck:p,onChange:u,style:y}){const[m,o]=g.useState(()=>we(r)),[b,C]=g.useState(()=>ze(r)),[N,D]=g.useState(null),[c,z]=g.useState({}),[$,I]=g.useState(null),[A,M]=g.useState(""),[L,V]=g.useState(null),[h,W]=g.useState(null);g.useEffect(R,[]),g.useEffect(()=>{o(we(r)),C(k=>({...ze(r),...k}))},[r]);const l=k=>C(T=>({...T,[k]:!T[k]})),x=(k,T)=>{z(S=>({...S,[k]:T})),p==null||p(k,T)},K=()=>{if(!$)return;const k=$,T=A;I(null),o(S=>{const j=je(S,k,T);return u==null||u(j),j})},P=(k,T)=>{k.dataTransfer.effectAllowed="move",V(T)},n=(k,T)=>{if(!L||L===T||Mt(m,L,T))return;k.preventDefault();const S=k.currentTarget.getBoundingClientRect(),j=k.clientY-S.top,X=S.height,Q=j<X*.25?"before":j>X*.75?"after":"inside";W(G=>(G==null?void 0:G.id)===T&&(G==null?void 0:G.pos)===Q?G:{id:T,pos:Q})},E=(k,T)=>{if(k.preventDefault(),!L||!h||L===T){W(null),V(null);return}o(S=>{const[j,X]=Ae(S,L);if(!X)return S;const Q=Me(j,T,X,h.pos);return u==null||u(Q),Q}),h.pos==="inside"&&C(S=>({...S,[T]:!0})),W(null),V(null)},F=()=>{V(null),W(null)},w=(k,T=0)=>{var re;const S=(((re=k.items)==null?void 0:re.length)??0)>0,j=b[k.id],X=N===k.id,Q=L===k.id,G=(h==null?void 0:h.id)===k.id;let U=!!c[k.id],ee=!1;if(s&&S){const{total:O,checkedCount:de}=mt(k,c);de>0&&de<O?ee=!0:O>0&&de===O&&(U=!0)}const te=G&&h.pos!=="inside"?{boxShadow:h.pos==="before"?`inset 0 2px 0 0 ${t.primary}`:`inset 0 -2px 0 0 ${t.primary}`}:{},pe=G&&h.pos==="inside"||X?t.primaryLt:"transparent";return e.jsxs("div",{style:{opacity:Q?.4:1},children:[e.jsxs("div",{draggable:!!i,onDragStart:i?O=>P(O,k.id):void 0,onDragOver:i?O=>n(O,k.id):void 0,onDrop:i?O=>E(O,k.id):void 0,onDragEnd:i?F:void 0,title:f==null?void 0:f(k),onClick:()=>{D(k.id),d==null||d(k),S&&l(k.id)},onDoubleClick:()=>{a&&(I(k.id),M(k.value||""))},style:{display:"flex",alignItems:"center",gap:4,padding:`5px 8px 5px ${12+T*18}px`,cursor:i?"grab":"pointer",borderRadius:t.r,margin:"1px 4px",background:pe,color:X?t.primary:t.text,userSelect:"none",fontSize:13,...te},onMouseEnter:O=>!X&&!G&&(O.currentTarget.style.background=t.bg),onMouseLeave:O=>!X&&!G&&(O.currentTarget.style.background="transparent"),children:[e.jsx("span",{style:{width:16,textAlign:"center",fontSize:11,color:t.textMut,flexShrink:0},onClick:O=>{O.stopPropagation(),S&&l(k.id)},children:S?j?"▾":"▸":""}),e.jsx("span",{style:{fontSize:15,flexShrink:0},children:S?j?"📂":"📁":"📄"}),s&&e.jsx("input",{ref:O=>{O&&(O.indeterminate=ee)},type:"checkbox",checked:U,onChange:O=>{O.stopPropagation(),x(k.id,O.target.checked)},style:{cursor:"pointer",accentColor:t.primary,flexShrink:0},onClick:O=>O.stopPropagation()}),$===k.id?e.jsx("input",{autoFocus:!0,className:"dhx dhx-input",style:{height:24,fontSize:12,flex:1},value:A,onChange:O=>M(O.target.value),onBlur:K,onKeyDown:O=>{O.key==="Enter"&&K(),O.key==="Escape"&&I(null)},onClick:O=>O.stopPropagation()}):e.jsx("span",{style:{flex:1},children:k.value}),k.count!==void 0&&e.jsxs("span",{style:{fontSize:11,color:t.textMut},children:["(",k.count,")"]})]}),S&&j&&e.jsx("div",{children:k.items.map(O=>w(O,T+1))})]},k.id)};return e.jsx("div",{className:"dhx dhx-scroll",style:{overflowY:"auto",...y},onDragOver:i?k=>k.preventDefault():void 0,onDrop:i?k=>{k.preventDefault(),W(null),V(null)}:void 0,children:m.map(k=>w(k))})}function $t({total:r,pageSize:s=10,page:a,onChange:i,style:f}){const[d,p]=g.useState(a||1),u=Math.ceil(r/s);g.useEffect(R,[]);const y=o=>{const b=Math.min(Math.max(1,o),u);p(b),i==null||i(b)},m=g.useMemo(()=>{const o=[];for(let C=Math.max(1,d-2);C<=Math.min(u,d+2);C++)o.push(C);return o[0]>1&&(o[0]>2&&o.unshift("..."),o.unshift(1)),o[o.length-1]<u&&(o[o.length-1]<u-1&&o.push("..."),o.push(u)),o},[d,u]);return e.jsxs("div",{className:"dhx",style:{display:"flex",alignItems:"center",gap:4,padding:"8px 12px",...f},children:[e.jsxs("span",{style:{fontSize:12,color:t.textSec,marginRight:8},children:[(d-1)*s+1,"–",Math.min(d*s,r)," of ",r]}),[["«",1],["‹",d-1]].map(([o,b])=>e.jsx("button",{className:"dhx dhx-btn dhx-btn-ghost",style:{height:30,padding:"0 8px",fontSize:14},disabled:d===1,onClick:()=>y(b),children:o},o)),m.map((o,b)=>e.jsx("button",{onClick:()=>typeof o=="number"&&y(o),className:`dhx dhx-btn ${o===d?"dhx-btn-primary":"dhx-btn-ghost"}`,style:{height:30,minWidth:30,padding:"0 8px",fontSize:13},disabled:o==="...",children:o},b)),[["›",d+1],["»",u]].map(([o,b])=>e.jsx("button",{className:"dhx dhx-btn dhx-btn-ghost",style:{height:30,padding:"0 8px",fontSize:14},disabled:d===u,onClick:()=>y(b),children:o},o))]})}function Dt({config:r={},defaultValues:s={},onSubmit:a,style:i}){const[f,d]=g.useState(s),[p,u]=g.useState({}),[y,m]=g.useState(null);g.useEffect(R,[]);const o=(c,z)=>{d($=>({...$,[c]:z})),u($=>({...$,[c]:null}))},b=c=>{const z=[];return c.flat().forEach($=>{!$||typeof $!="object"||!("name"in $)||(z.push($),$.type==="fieldset"&&$.rows&&z.push(...b($.rows)))}),z},C=()=>{const c={};return b(r.rows||[]).forEach(z=>{z.required&&!f[z.name]&&(c[z.name]=`${z.label||z.name} is required`)}),u(c),Object.keys(c).length===0},N=c=>{const z=f[c.name]??c.value??"",$=p[c.name],I=c.labelWidth??r.labelWidth,A=I!==void 0||c.labelPosition==="left";if(c.type==="fieldset")return e.jsxs("fieldset",{style:{border:`1px solid ${t.border}`,borderRadius:t.r,padding:"12px 16px",marginBottom:14},children:[e.jsx("legend",{style:{fontSize:12,fontWeight:700,color:t.textSec,padding:"0 6px"},children:c.label}),(c.rows||[]).map(x=>N(x))]},c.name);if(c.type==="spacer")return e.jsx("div",{style:{height:c.height||16}},c.name);const M=I?{minWidth:I,width:I,flexShrink:0,paddingTop:8,boxSizing:"border-box"}:{},L=c.label?e.jsxs("label",{className:"dhx dhx-label",style:{display:"flex",gap:4,...M},children:[c.label,c.required&&e.jsx("span",{style:{color:t.danger},children:"*"})]},"lbl"):null,V=$?e.jsx("div",{style:{fontSize:11,color:t.danger,marginTop:3},children:$}):null,h=c.helpMessage?e.jsxs("div",{style:{fontSize:11,color:t.textMut,marginTop:3},children:["ⓘ ",c.helpMessage]}):null,W={key:c.name,className:"dhx-form-group"},l=x=>A?e.jsxs("div",{...W,style:{display:"flex",alignItems:"flex-start",gap:8},children:[L,e.jsxs("div",{style:{flex:1,minWidth:0},children:[x,V,h]})]}):e.jsxs("div",{...W,children:[L,x,V,h]});if(!c.type||c.type==="input")return l(e.jsxs("div",{className:"dhx-input-wrap",children:[c.icon&&e.jsx("span",{className:"dhx-input-icon",children:c.icon}),e.jsx("input",{className:`dhx dhx-input${c.icon?" dhx-input--with-icon":""}`,style:{borderColor:$?t.danger:void 0},type:c.inputType||"text",placeholder:c.placeholder,value:z,onChange:x=>o(c.name,x.target.value),disabled:c.disabled})]}));if(c.type==="textarea")return l(e.jsx("textarea",{className:"dhx dhx-input",style:{height:80,resize:"vertical",padding:"8px 10px"},placeholder:c.placeholder,value:z,onChange:x=>o(c.name,x.target.value)}));if(c.type==="select")return l(e.jsxs("select",{className:"dhx dhx-input",value:z,onChange:x=>o(c.name,x.target.value),style:{cursor:"pointer"},children:[e.jsx("option",{value:"",children:"— Select —"}),(c.options||[]).map(x=>e.jsx("option",{value:x.value,children:x.label||x.value},x.value))]}));if(c.type==="datepicker")return l(e.jsx("input",{type:"date",className:"dhx dhx-input",value:z,onChange:x=>o(c.name,x.target.value)}));if(c.type==="timepicker"){const x=f[c.name]??{h:12,m:0,ampm:"AM"},K=!!f[c.name],P=K?`${String(x.h).padStart(2,"0")}:${String(x.m).padStart(2,"0")}${x.ampm?" "+x.ampm:""}`:c.placeholder||"Click to select",n=e.jsxs("div",{style:{position:"relative"},children:[e.jsxs("div",{className:"dhx dhx-input",style:{cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"space-between"},onClick:()=>m(y===c.name?null:c.name),children:[e.jsx("span",{style:{color:K?t.text:t.textMut},children:P}),e.jsx("span",{style:{fontSize:13,color:t.textSec},children:"🕐"})]}),y===c.name&&e.jsx("div",{style:{position:"absolute",zIndex:100,top:"calc(100% + 4px)",left:0},children:e.jsx(We,{value:x,controls:!0,onChange:E=>{o(c.name,E),m(null)}})})]});return l(n)}if(c.type==="colorpicker")return l(e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("input",{type:"color",value:z||"#000000",onChange:x=>o(c.name,x.target.value),style:{width:36,height:36,padding:2,border:`1px solid ${t.border}`,borderRadius:t.r,cursor:"pointer",background:"none"}}),e.jsx("span",{style:{fontSize:12,color:t.textSec,fontFamily:"monospace"},children:z||"#000000"})]}));if(c.type==="text")return l(e.jsx("p",{style:{margin:"6px 0",fontSize:13,color:t.text},children:c.value}));if(c.type==="checkbox")return e.jsxs("div",{...W,children:[A?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[I&&e.jsx("div",{style:{width:I,flexShrink:0}}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:!!z,onChange:x=>o(c.name,x.target.checked),style:{width:16,height:16,accentColor:t.primary,cursor:"pointer"}}),e.jsx("span",{style:{fontSize:13},children:c.label})]})]}):e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:!!z,onChange:x=>o(c.name,x.target.checked),style:{width:16,height:16,accentColor:t.primary,cursor:"pointer"}}),e.jsx("span",{style:{fontSize:13},children:c.label})]}),h]});if(c.type==="radio"){const x=(c.options||[]).map(K=>e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,cursor:"pointer",fontSize:13},children:[e.jsx("input",{type:"radio",name:c.name,value:K.value,checked:z===K.value,onChange:()=>o(c.name,K.value),style:{accentColor:t.primary,cursor:"pointer"}}),K.label||K.value]},K.value));return l(e.jsx("div",{style:{display:"flex",gap:16,flexWrap:"wrap",paddingTop:8},children:x}))}if(c.type==="slider")return A?e.jsxs("div",{...W,style:{display:"flex",alignItems:"flex-start",gap:8},children:[L,e.jsxs("div",{style:{flex:1},children:[e.jsx(ve,{min:c.min,max:c.max,step:c.step,value:z||c.min,range:c.range,onChange:x=>o(c.name,x)}),h]})]}):e.jsxs("div",{...W,children:[e.jsx(ve,{label:c.label,min:c.min,max:c.max,step:c.step,value:z||c.min,range:c.range,onChange:x=>o(c.name,x)}),h]});if(c.type==="combo")return A?e.jsxs("div",{...W,style:{display:"flex",alignItems:"flex-start",gap:8},children:[L,e.jsxs("div",{style:{flex:1},children:[e.jsx(be,{data:c.data||[],multiselection:c.multiselection,placeholder:c.placeholder||"Select...",value:z||(c.multiselection?[]:null),onChange:x=>o(c.name,x)}),V,h]})]}):e.jsxs("div",{...W,children:[e.jsx(be,{label:c.label,data:c.data||[],multiselection:c.multiselection,placeholder:c.placeholder||"Select...",value:z||(c.multiselection?[]:null),onChange:x=>o(c.name,x)}),V,h]});if(c.type==="toggle"){const x=!!z,K=x?c.icon:c.offIcon||c.icon,P=x?c.text||c.label:c.offText||c.text||c.label;return e.jsxs("div",{...W,children:[A&&I&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("div",{style:{width:I,flexShrink:0}}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx(Pe,{on:x,onClick:()=>o(c.name,!z)}),K&&e.jsx("span",{style:{fontSize:16},children:K}),P&&e.jsx("span",{style:{fontSize:13},children:P})]})]}),!A&&e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:10,cursor:"pointer"},children:[e.jsx(Pe,{on:x,onClick:()=>o(c.name,!z)}),K&&e.jsx("span",{style:{fontSize:16},children:K}),P&&e.jsx("span",{style:{fontSize:13},children:P})]}),h]})}return null},D=c=>c.map((z,$)=>Array.isArray(z)?e.jsx("div",{style:{display:"flex",gap:12,alignItems:"flex-start"},children:z.map(N)},$):N(z));return e.jsxs("div",{className:"dhx",style:{padding:r.padding||0,width:r.width||"100%",...i},children:[D(r.rows||[]),(r.buttons||a)&&e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:r.buttonAlign||"flex-start",marginTop:8},children:[e.jsx("button",{className:"dhx dhx-btn dhx-btn-primary",onClick:()=>C()&&(a==null?void 0:a(f)),children:r.submitText||"Submit"}),r.resetButton!==!1&&e.jsx("button",{className:"dhx dhx-btn dhx-btn-secondary",onClick:()=>{d(s),u({})},children:r.resetText||"Reset"})]})]})}function Pe({on:r,onClick:s}){return e.jsxs("div",{style:{position:"relative",width:40,height:22,flexShrink:0},onClick:s,children:[e.jsx("div",{style:{width:40,height:22,borderRadius:11,background:r?t.primary:t.border,transition:"background 0.2s"}}),e.jsx("div",{style:{position:"absolute",top:3,left:r?21:3,width:16,height:16,borderRadius:"50%",background:"#fff",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,.3)"}})]})}function xe(r){const s=[];for(const a of r)a.type==="block"?s.push(...xe(a.items||[])):s.push(a);return s}function Lt(r){return r==="primary"?t.primary:r==="success"?t.success:r==="secondary"?t.borderDk:t.danger}function Tt(r,s){switch(r){case"primary":return{background:t.primary,color:"#fff",borderColor:t.primary};case"danger":return{background:t.danger,color:"#fff",borderColor:t.danger};case"success":return{background:t.success,color:"#fff",borderColor:t.success};case"secondary":return{background:t.bg,color:t.text,borderColor:t.border};default:return s?{background:t.primaryLt,color:t.primary}:{}}}function Et({items:r=[],css:s,menuCss:a,style:i,onAction:f,onInputChange:d,onInputBlur:p,onInputFocus:u,onOpenMenu:y}){g.useEffect(R,[]);const[m,o]=g.useState(()=>{const n={};for(const E of xe(r))E.id&&(n[E.id]=!!E.active);return n}),[b,C]=g.useState(null),[N,D]=g.useState(()=>{const n={};for(const E of xe(r))E.type==="selectButton"&&E.id&&E.value&&(n[E.id]=E.value);return n}),c=xe(r),z=g.useRef(null);ce(z,g.useCallback(()=>C(null),[]));const $=n=>{var E,F;if(!n.disabled){if(n.id){if(n.group){const w=c.filter(k=>k.group===n.group&&k.id);o(k=>{const T={...k};for(const S of w)T[S.id]=!1;return T[n.id]=!0,T})}else n.twoState&&o(w=>({...w,[n.id]:!w[n.id]}));if((E=n.items)!=null&&E.length){const w=n.id;C(k=>k===w?null:w),y==null||y(n.id);return}}(F=n.onClick)==null||F.call(n,n),n.id&&(f==null||f(n.id,n))}},I=({count:n,color:E})=>e.jsx("span",{style:{position:"absolute",top:2,right:2,minWidth:14,height:14,background:Lt(E),color:"#fff",borderRadius:7,fontSize:9,fontWeight:700,display:"flex",alignItems:"center",justifyContent:"center",padding:"0 2px",pointerEvents:"none"},children:n>99?"99+":n}),A=(n,E)=>{var re;const F=n.id!==void 0?m[n.id]??!!n.active:!!n.active,w=n.value??n.text,k=n.size??"medium",T=k==="auto",S=k==="small",j=!!((re=n.items)!=null&&re.length),X=n.id!==void 0&&b===n.id,Q=Tt(n.color,F&&!n.color),G=T?void 0:S?26:32,U=T?22:S?13:16,ee=[n.tooltip,n.hotkey?`(${n.hotkey})`:""].filter(Boolean).join(" "),te=n.circle?{borderRadius:"50%",padding:T?"8px":"0",aspectRatio:"1",justifyContent:"center"}:{},pe=n.view==="link"?{background:"transparent",border:"none",textDecoration:"underline",padding:"0 4px"}:n.view==="flat"?{borderRadius:0}:{};return e.jsxs("div",{style:{position:"relative",display:"flex"},children:[e.jsxs("button",{title:ee||void 0,disabled:n.disabled,className:"dhx dhx-btn dhx-btn-ghost",style:{flexDirection:T?"column":"row",alignSelf:T?"stretch":"center",justifyContent:"center",minHeight:T?56:G,height:T?void 0:G,padding:T?"6px 10px":S?"0 6px":"0 8px",gap:4,position:"relative",background:F&&!n.color?t.primaryLt:"transparent",color:F&&!n.color?t.primary:n.disabled?t.textMut:t.text,opacity:n.disabled?.55:1,cursor:n.disabled?"not-allowed":"pointer",borderColor:X?t.primary:void 0,...Q,...te,...pe},onClick:()=>$(n),children:[n.loading?e.jsx("span",{style:{fontSize:U,lineHeight:1,flexShrink:0,display:"inline-block",animation:"dhx-spin 1s linear infinite"},children:"⟳"}):n.icon&&e.jsx("span",{style:{fontSize:U,lineHeight:1,flexShrink:0},children:n.icon}),w&&!n.html&&e.jsx("span",{style:{fontSize:T?10:S?11:12,maxWidth:T?64:void 0,textAlign:T?"center":"left",lineHeight:T?1.2:1,whiteSpace:T?"normal":"nowrap"},children:w}),n.html&&e.jsx("span",{dangerouslySetInnerHTML:{__html:n.html}}),j&&e.jsx("span",{style:{fontSize:8,opacity:.6,marginLeft:1},children:"▼"}),n.hotkey&&T&&e.jsx("span",{style:{fontSize:9,color:t.textMut,lineHeight:1},children:n.hotkey}),n.count!==void 0&&e.jsx(I,{count:n.count,color:n.countColor})]}),j&&X&&e.jsx(ie,{items:n.items,onSelect:O=>{C(null),O.id&&(f==null||f(String(O.id),n))},style:{top:"100%",left:0,minWidth:160}})]},E)},M=(n,E)=>{const F=n.size??"medium",w=F==="auto"?48:F==="small"?28:36,k=n.id!==void 0?m[n.id]??!!n.active:!!n.active;return e.jsx("div",{style:{position:"relative",display:"flex",alignSelf:"center"},children:e.jsxs("button",{title:n.tooltip,disabled:n.disabled,style:{width:w,height:w,padding:2,border:k?`2px solid ${t.primary}`:"2px solid transparent",borderRadius:"50%",overflow:"hidden",cursor:n.disabled?"not-allowed":"pointer",background:"transparent",flexShrink:0,opacity:n.disabled?.55:1},onClick:()=>$(n),children:[n.src&&e.jsx("img",{src:n.src,alt:n.value||"",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}),n.count!==void 0&&e.jsx(I,{count:n.count,color:n.countColor})]})},E)},L=(n,E)=>{var T,S;const F=n.id!==void 0&&b===`sel:${n.id}`,w=(n.id&&N[n.id])??n.value??((S=(T=n.items)==null?void 0:T[0])==null?void 0:S.value)??"",k=(n.items??[]).map(j=>({id:j.value,value:j.value,icon:j.icon}));return e.jsxs("div",{style:{position:"relative",alignSelf:"center"},children:[e.jsxs("button",{title:n.tooltip,disabled:n.disabled,className:"dhx dhx-btn dhx-btn-ghost",style:{height:28,gap:4,padding:"0 8px",opacity:n.disabled?.55:1,cursor:n.disabled?"not-allowed":"pointer",borderColor:F?t.primary:void 0},onClick:()=>{if(n.disabled||!n.id)return;const j=`sel:${n.id}`;C(X=>X===j?null:j)},children:[n.icon&&e.jsx("span",{style:{fontSize:14},children:n.icon}),e.jsx("span",{style:{fontSize:12},children:w}),e.jsx("span",{style:{fontSize:8,opacity:.6},children:"▼"})]}),F&&e.jsx(ie,{items:k,onSelect:j=>{var Q;const X=String(j.value??j.id??"");n.id&&D(G=>({...G,[n.id]:X})),C(null),(Q=n.onChange)==null||Q.call(n,X),n.id&&(f==null||f(n.id,n))},style:{top:"100%",left:0,minWidth:100}})]},E)},V=(n,E)=>e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start",justifyContent:"center",padding:"2px 4px",gap:2},children:[n.label&&e.jsx("span",{style:{fontSize:10,color:t.textMut},children:n.label}),e.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center"},children:[n.icon&&e.jsx("span",{style:{position:"absolute",left:6,fontSize:13,color:t.textMut,pointerEvents:"none",zIndex:1},children:n.icon}),e.jsx("input",{className:"dhx dhx-input",disabled:n.disabled,style:{width:n.width||110,height:26,fontSize:12,paddingLeft:n.icon?24:void 0},placeholder:n.placeholder,defaultValue:n.value,onChange:F=>{var w;(w=n.onChange)==null||w.call(n,F.target.value),n.id&&(d==null||d(n.id,F.target.value))},onBlur:F=>{var w;(w=n.onBlur)==null||w.call(n,F.target.value),n.id&&(p==null||p(n.id,F.target.value))},onFocus:F=>{var w;(w=n.onFocus)==null||w.call(n,F.target.value),n.id&&(u==null||u(n.id,F.target.value))}})]})]},E),h=(n,E)=>n.hidden?null:e.jsx("div",{title:n.tooltip,style:{padding:"2px 6px",fontSize:11,color:n.disabled?t.textMut:t.textSec,display:"flex",alignItems:"center",alignSelf:"center",userSelect:"none",opacity:n.disabled?.5:1},children:n.html?e.jsx("span",{dangerouslySetInnerHTML:{__html:n.html}}):n.value},E),W=(n,E)=>n.hidden?null:e.jsx("div",{style:{display:"flex",alignItems:"center",alignSelf:"center",padding:"0 4px"},dangerouslySetInnerHTML:{__html:n.html??""}},E),l=(n,E)=>n.hidden?null:n.type==="separator"||n.type==="sep"?e.jsx("div",{style:{width:1,background:t.border,margin:"4px 2px",alignSelf:"stretch"}},E):n.type==="spacer"?e.jsx("div",{style:{flex:1}},E):n.type==="title"?h(n,E):n.type==="customHTML"?W(n,E):n.type==="imageButton"?M(n,E):n.type==="input"?V(n,E):n.type==="selectButton"?L(n,E):A(n,E),x=(n,E,F)=>{var k;if(n.hidden)return null;const w=F||n.disabled;return e.jsx("div",{style:{display:"flex",flexDirection:n.direction==="col"?"column":"row",alignItems:n.direction==="col"?"flex-start":"center",gap:2,opacity:n.disabled&&!F?.55:1,pointerEvents:w?"none":void 0},children:(k=n.items)==null?void 0:k.map((T,S)=>T.type==="block"?x(T,`${E}-${S}`,w):l(T,`${E}-${S}`))},E)},K=(n,E)=>{var w;if(n.hidden)return null;const F=n.title||n.label;return e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"stretch",borderRight:`1px solid ${t.border}`,padding:"4px 6px 0",minWidth:40,opacity:n.disabled?.55:1,pointerEvents:n.disabled?"none":void 0},children:[e.jsx("div",{style:{display:"flex",flexDirection:n.direction==="col"?"column":"row",alignItems:n.direction==="col"?"stretch":"center",gap:2,flex:1},children:(w=n.items)==null?void 0:w.map((k,T)=>k.type==="block"?x(k,T,n.disabled):l(k,T))}),F&&e.jsx("div",{style:{fontSize:10,color:t.textMut,textAlign:"center",padding:"3px 0 4px",marginTop:2,borderTop:`1px solid ${t.border}`},children:F})]},E)},P=(n,E)=>n.type==="block"?K(n,E):l(n,E);return e.jsx("div",{ref:z,className:["dhx",s].filter(Boolean).join(" "),style:{display:"flex",alignItems:"stretch",background:t.surface,borderBottom:`1px solid ${t.border}`,overflowX:"auto",gap:0,minHeight:72,...i},children:r.map(P)})}function me(r){return r==="primary"?t.primary:r==="success"?t.success:r==="secondary"?t.borderDk:t.danger}function Nt(r,s,a){if(!r&&!s)return a?{background:t.primaryLt,color:t.primary}:{};const i=r==="primary"?t.primary:r==="danger"?t.danger:r==="success"?t.success:t.borderDk;return s==="link"?{background:"transparent",color:i,border:"none",boxShadow:"none"}:s==="flat"?{background:i,color:"#fff",border:"none",boxShadow:"none"}:{color:i}}function Ce({count:r,bg:s}){return e.jsx("span",{style:{position:"absolute",top:3,right:3,minWidth:16,height:16,background:s??t.danger,color:"#fff",borderRadius:8,fontSize:10,fontWeight:700,display:"flex",alignItems:"center",justifyContent:"center",padding:"0 3px",lineHeight:1,pointerEvents:"none"},children:r})}function It({logo:r,items:s=[],vertical:a=!1,css:i,menuCss:f,onAction:d,onInputChange:p,onInputBlur:u,onInputFocus:y,style:m}){const[o,b]=g.useState(null),[C,N]=g.useState(()=>{const l={};return s.forEach(x=>{x.id&&(x.twoState||x.group)&&x.active&&(l[x.id]=!0)}),l}),[D,c]=g.useState(()=>{const l={};return s.forEach(x=>{x.type==="selectButton"&&x.id&&x.value&&(l[x.id]=x.value)}),l}),z=g.useRef(null);g.useEffect(R,[]),ce(z,g.useCallback(()=>b(null),[]));const $=l=>{var x,K;if(!l.disabled){if(l.twoState&&l.id&&N(P=>({...P,[l.id]:!P[l.id]})),l.group&&l.id&&N(P=>{const n={...P};return s.forEach(E=>{E.group===l.group&&E.id&&(n[E.id]=!1)}),n[l.id]=!0,n}),(x=l.items)!=null&&x.length||l.type==="selectButton"){const P=l.id;b(n=>n===P?null:P);return}(K=l.onClick)==null||K.call(l,l.id||""),d==null||d(l.id||"")}},I=(l,x)=>e.jsx("span",{style:{fontSize:12,color:t.textSec,padding:"0 8px",fontWeight:500,whiteSpace:"nowrap",alignSelf:"center"},children:l.value??l.text},l.id??x),A=(l,x)=>e.jsx("div",{dangerouslySetInnerHTML:{__html:l.html??""}},l.id??x),M=(l,x)=>e.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center",margin:"0 4px",gap:4},children:[l.label&&e.jsx("span",{style:{fontSize:12,color:t.textSec,whiteSpace:"nowrap"},children:l.label}),e.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center"},children:[l.icon&&e.jsx("span",{style:{position:"absolute",left:8,color:t.textMut,fontSize:15,pointerEvents:"none",zIndex:1},children:l.icon}),e.jsx("input",{className:"dhx dhx-input",style:{width:l.width||200,height:28,paddingLeft:l.icon?30:void 0},placeholder:l.placeholder,defaultValue:l.value,onChange:K=>{var P;(P=l.onChange)==null||P.call(l,K.target.value),p==null||p(l.id||"",K.target.value)},onBlur:K=>{var P;(P=l.onBlur)==null||P.call(l,K.target.value),u==null||u(l.id||"",K.target.value)},onFocus:K=>{var P;(P=l.onFocus)==null||P.call(l,K.target.value),y==null||y(l.id||"",K.target.value)}})]})]},l.id??x),L=(l,x)=>e.jsxs("button",{title:l.tooltip,disabled:l.disabled,style:{position:"relative",width:36,height:36,padding:2,border:"none",borderRadius:"50%",overflow:"hidden",cursor:l.disabled?"not-allowed":"pointer",background:"transparent",flexShrink:0},onClick:()=>$(l),children:[l.src&&e.jsx("img",{src:l.src,alt:l.value||"",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}),l.count!==void 0&&e.jsx(Ce,{count:l.count,bg:me(l.countColor)})]},l.id??x),V=(l,x)=>{var P;const K=o===l.id;return e.jsxs("div",{style:{position:"relative"},children:[e.jsxs("button",{className:"dhx dhx-btn dhx-btn-ghost",title:l.tooltip,disabled:l.disabled,style:{position:"relative",height:a?40:36,gap:4,cursor:l.disabled?"not-allowed":"pointer",...a?{width:"100%",justifyContent:"flex-start",padding:"0 16px",borderRadius:0}:{}},onClick:()=>$(l),children:[l.icon&&e.jsx("span",{style:{fontSize:16,flexShrink:0},children:l.icon}),e.jsx("span",{style:{fontSize:13},children:D[l.id]??l.value??l.text}),e.jsx("span",{style:{fontSize:9,opacity:.55},children:"▼"}),l.count!==void 0&&e.jsx(Ce,{count:l.count,bg:me(l.countColor)})]}),K&&((P=l.items)==null?void 0:P.length)&&e.jsx(ie,{items:l.items,onSelect:n=>{var E;if(b(null),n.id!==void 0){const F=String(n.value??n.id);c(w=>({...w,[l.id]:F})),(E=l.onChange)==null||E.call(l,F),p==null||p(l.id,F)}},style:a?{left:"100%",top:0}:{top:"100%",left:0}})]},l.id??x)},h=(l,x)=>{var T;const K=!!(l.id&&(l.twoState||l.group)&&C[l.id]),P=!!((T=l.items)!=null&&T.length),n=!!l.circle,E=!!l.loading,F=Nt(l.color,l.view,K),w={position:"relative",height:a?40:36,gap:6,background:K?t.primaryLt:"transparent",color:K?t.primary:l.disabled?t.textMut:t.text,opacity:l.disabled?.55:1,cursor:l.disabled?"not-allowed":"pointer",...a?{width:"100%",justifyContent:"flex-start",padding:"0 16px",borderRadius:0}:{},...n?{borderRadius:"50%",width:36,height:36,padding:0,minWidth:0,justifyContent:"center"}:{},...F},k=l.value??l.text;return e.jsxs("div",{style:{position:"relative"},children:[e.jsxs("button",{className:"dhx dhx-btn dhx-btn-ghost",title:l.tooltip,disabled:l.disabled,style:w,onClick:()=>$(l),children:[E?e.jsx("span",{style:{fontSize:16,animation:"dhx-spin 1s linear infinite",display:"inline-block"},children:"⟳"}):l.icon&&e.jsx("span",{style:{fontSize:16,flexShrink:0},children:l.icon}),!n&&k&&e.jsx("span",{style:{fontSize:13},children:k}),!n&&l.hotkey&&e.jsx("span",{style:{fontSize:10,opacity:.45,marginLeft:4},children:l.hotkey}),P&&!n&&e.jsx("span",{style:{fontSize:9,opacity:.55,marginLeft:2},children:"▼"}),l.count!==void 0&&e.jsx(Ce,{count:l.count,bg:me(l.countColor)})]}),P&&o===l.id&&e.jsx(ie,{items:l.items,onSelect:S=>{var j;b(null),S.id&&((j=l.onClick)==null||j.call(l,S.id),d==null||d(S.id))},style:a?{left:"100%",top:0}:{top:"100%"}})]},l.id??x)},W=(l,x)=>l.hidden?null:l.type==="separator"?e.jsx("div",{style:{[a?"height":"width"]:1,background:t.border,margin:a?"4px 8px":"0 6px",alignSelf:"stretch"}},l.id??x):l.type==="spacer"?e.jsx("div",{style:{flex:1}},l.id??x):l.type==="title"?I(l,x):l.type==="customHTML"?A(l,x):l.type==="input"?M(l,x):l.type==="selectButton"?V(l,x):l.type==="imageButton"?L(l,x):h(l,x);return e.jsxs("nav",{ref:z,className:["dhx",i].filter(Boolean).join(" "),style:{display:"flex",flexDirection:a?"column":"row",alignItems:a?"stretch":"center",background:t.surface,borderBottom:a?"none":`1px solid ${t.border}`,borderRight:a?`1px solid ${t.border}`:"none",padding:a?"8px 0":"0 12px",minHeight:a?void 0:48,gap:2,...m},children:[r&&e.jsx("div",{style:{color:t.text,fontWeight:800,fontSize:16,padding:a?"8px 16px 12px":"0 12px 0 4px",borderBottom:a?`1px solid ${t.border}`:"none",borderRight:a?"none":`1px solid ${t.border}`,marginRight:a?0:8,marginBottom:a?4:0,flexShrink:0},children:r}),s.map(W)]})}function Wt({value:r,toolbar:s,menubar:a,fullscreenMode:i,layoutMode:f,imageUploadUrl:d,locale:p,defaultStyles:u,onChange:y,style:m,className:o}){const b=g.useRef(null),C=g.useRef(null),N=g.useRef(y);return N.current=y,g.useEffect(()=>{if(!b.current)return;const D={};r!==void 0&&(D.value=r),s!==void 0&&(D.toolbar=s),a!==void 0&&(D.menubar=a),i!==void 0&&(D.fullscreenMode=i),f!==void 0&&(D.layoutMode=f),d!==void 0&&(D.imageUploadUrl=d),p!==void 0&&(D.locale=p),u!==void 0&&(D.defaultStyles=u);const c=new Ve.Richtext(b.current,D);C.current=c;let z=c.getValue(),$;const I=new MutationObserver(()=>{clearTimeout($),$=setTimeout(()=>{var M;const A=c.getValue();A!==z&&(z=A,(M=N.current)==null||M.call(N,A))},150)});return I.observe(b.current,{childList:!0,subtree:!0,characterData:!0}),()=>{clearTimeout($),I.disconnect(),c.destructor(),b.current&&(b.current.innerHTML=""),C.current=null}},[]),g.useEffect(()=>{const D=C.current;!D||r===void 0||D.getValue()!==r&&D.setValue(r)},[r]),g.useEffect(()=>{C.current&&p&&C.current.setLocale(p)},[p]),e.jsx("div",{ref:b,className:o,style:{display:"flex",flexDirection:"column",height:500,...m}})}q.Button=qe,q.Calendar=ht,q.Chart=ct,q.Colorpicker=xt,q.Combobox=be,q.ContextMenu=Je,q.DataView=zt,q.Form=Dt,q.Grid=dt,q.Layout=Ie,q.List=wt,q.Menu=Ge,q.MenuDropdown=ie,q.MessageContext=ke,q.MessageProvider=St,q.Navbar=It,q.Pagination=$t,q.Popup=yt,q.Ribbon=Et,q.Richtext=Wt,q.Sidebar=et,q.Slider=ve,q.Tabbar=rt,q.Timepicker=We,q.Toolbar=Ue,q.Tree=Ct,q.Window=bt,q.tokens=t,q.useClickOutside=ce,q.useDrag=Ee,q.useMessage=kt,Object.defineProperty(q,Symbol.toStringTag,{value:"Module"})});
41
+ `,document.head.appendChild(r)}const et={sm:{height:24,padding:"0 8px",fontSize:12},md:{},lg:{height:38,padding:"0 18px",fontSize:14}};function tt({children:r,variant:n="primary",size:d="md",icon:i,disabled:h,onClick:a,style:u,className:f=""}){return p.useEffect(ne,[]),e.jsxs("button",{className:`dhx dhx-btn dhx-btn-${n} ${f}`,style:{...et[d],...u},disabled:h,onClick:a,children:[i&&e.jsx("span",{style:{fontSize:16},children:i}),r]})}function ge(r,n){p.useEffect(()=>{const d=i=>{r.current&&!r.current.contains(i.target)&&n(i)};return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[r,n])}function Be(r){const n=p.useRef(!1),d=p.useRef({x:0,y:0,ox:0,oy:0});return p.useCallback((i,h=0,a=0)=>{n.current=!0,d.current={x:i.clientX,y:i.clientY,ox:h,oy:a};const u=y=>{if(!n.current)return;const{x:S,y:o,ox:v,oy:T}=d.current;r(v+y.clientX-S,T+y.clientY-o)},f=()=>{n.current=!1,document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",f)};document.addEventListener("mousemove",u),document.addEventListener("mouseup",f),i.preventDefault()},[r])}function fe({items:r,onSelect:n,style:d}){const[i,h]=p.useState(null);return e.jsx("div",{className:"dhx dhx-anim-fade",style:{position:"absolute",top:"calc(100% + 4px)",left:0,minWidth:180,background:t.surface,border:`1px solid ${t.border}`,borderRadius:t.r,boxShadow:t.shadowLg,zIndex:200,padding:"4px 0",...d},children:r.map((a,u)=>{var y,S;if(a.type==="separator")return e.jsx("div",{style:{height:1,background:t.border,margin:"4px 0"}},u);const f=i===u;return e.jsxs("div",{style:{position:"relative"},onMouseEnter:()=>h(u),onMouseLeave:()=>h(null),children:[e.jsxs("div",{onClick:()=>{var o;return!a.disabled&&!((o=a.items)!=null&&o.length)&&n(a)},style:{display:"flex",alignItems:"center",gap:8,padding:"8px 14px",cursor:a.disabled?"not-allowed":"pointer",fontSize:13,color:a.disabled?t.textMut:t.text,background:f&&!a.disabled?t.bg:"transparent",opacity:a.disabled?.5:1},children:[a.icon&&e.jsx("span",{style:{fontSize:15,width:18,textAlign:"center"},children:a.icon}),e.jsx("span",{style:{flex:1},children:a.value||a.id}),a.hotkey&&e.jsx("span",{style:{fontSize:11,color:t.textMut},children:a.hotkey}),(y=a.items)!=null&&y.length?e.jsx("span",{style:{fontSize:10,color:t.textMut},children:"▶"}):null]}),f&&((S=a.items)!=null&&S.length)?e.jsx(fe,{items:a.items,onSelect:n,style:{position:"absolute",left:"100%",top:-4}}):null]},a.id||u)})})}function rt({items:r=[],label:n="Menu",onSelect:d,style:i}){const[h,a]=p.useState(!1),u=p.useRef(null);return p.useEffect(ne,[]),ge(u,p.useCallback(()=>a(!1),[])),e.jsxs("div",{ref:u,className:"dhx",style:{position:"relative",display:"inline-block",...i},children:[e.jsxs("button",{className:"dhx dhx-btn dhx-btn-secondary",onClick:()=>a(f=>!f),children:[n," ",e.jsx("span",{style:{fontSize:10},children:h?"▲":"▼"})]}),h&&e.jsx(fe,{items:r,onSelect:f=>{d==null||d(f),a(!1)}})]})}function nt({items:r=[],onSelect:n,children:d}){const[i,h]=p.useState(null),a=p.useRef(null);p.useEffect(ne,[]),ge(a,p.useCallback(()=>h(null),[]));const u=f=>{f.preventDefault(),h({x:f.clientX,y:f.clientY})};return e.jsxs("div",{ref:a,onContextMenu:u,style:{position:"relative",display:"contents"},children:[d,i&&e.jsx("div",{style:{position:"fixed",left:i.x,top:i.y,zIndex:9999},children:e.jsx(fe,{items:r,onSelect:f=>{n==null||n(f),h(null)}})})]})}function Fe({count:r}){return e.jsx("span",{style:{position:"absolute",top:2,right:2,minWidth:16,height:16,background:t.danger,color:"#fff",borderRadius:8,fontSize:10,fontWeight:700,display:"flex",alignItems:"center",justifyContent:"center",padding:"0 3px",lineHeight:1,pointerEvents:"none"},children:r})}function ot({items:r=[],onAction:n,style:d}){const[i,h]=p.useState(null),[a,u]=p.useState(()=>{const o={};return r.forEach(v=>{v.id&&(v.twoState||v.group)&&v.active&&(o[v.id]=!0)}),o}),f=p.useRef(null);p.useEffect(ne,[]),ge(f,p.useCallback(()=>h(null),[]));const y=(o,v)=>{var T,$;if(!o.disabled){if(o.twoState&&o.id&&u(F=>({...F,[o.id]:!F[o.id]})),o.group&&o.id&&u(F=>{const c={...F};return r.forEach(m=>{m.group===o.group&&m.id&&(c[m.id]=!1)}),c[o.id]=!0,c}),(T=o.items)!=null&&T.length){h(F=>F===v?null:v);return}($=o.onClick)==null||$.call(o,o.id||""),n==null||n(o.id||"")}},S=(o,v)=>{var c,m;if(o.hidden)return null;if(o.type==="separator")return e.jsx("div",{style:{width:1,background:t.border,margin:"6px 4px",alignSelf:"stretch"}},v);if(o.type==="spacer")return e.jsx("div",{style:{flex:1}},v);if(o.type==="input")return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[o.label&&e.jsx("span",{style:{fontSize:12,color:t.textSec,fontWeight:500},children:o.label}),e.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center"},children:[o.icon&&e.jsx("span",{style:{position:"absolute",left:8,color:t.textMut,fontSize:15,pointerEvents:"none",zIndex:1},children:o.icon}),e.jsx("input",{className:"dhx dhx-input",style:{width:o.width||140,height:28,paddingLeft:o.icon?30:void 0},placeholder:o.placeholder,defaultValue:o.value,onChange:C=>{var E;return(E=o.onChange)==null?void 0:E.call(o,C.target.value)}})]})]},v);if(o.type==="select")return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[o.label&&e.jsx("span",{style:{fontSize:12,color:t.textSec,fontWeight:500},children:o.label}),e.jsx("select",{className:"dhx dhx-input",style:{width:o.width||100,height:28,cursor:"pointer"},defaultValue:o.value,onChange:C=>{var E;return(E=o.onChange)==null?void 0:E.call(o,C.target.value)},children:(c=o.options)==null?void 0:c.map(C=>e.jsx("option",{value:C.value,children:C.label},C.value))})]},v);if(o.type==="imageButton")return e.jsxs("button",{title:o.tooltip,disabled:o.disabled,style:{position:"relative",width:32,height:32,padding:2,border:"none",borderRadius:"50%",overflow:"hidden",cursor:o.disabled?"not-allowed":"pointer",background:"transparent",flexShrink:0},onClick:()=>y(o,v),children:[o.src&&e.jsx("img",{src:o.src,alt:o.value||"",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}),o.count!==void 0&&e.jsx(Fe,{count:o.count})]},v);const T=!!(o.id&&a[o.id]),$=o.value??o.text,F=!!((m=o.items)!=null&&m.length);return e.jsxs("div",{style:{position:"relative"},children:[e.jsxs("button",{className:"dhx dhx-btn dhx-btn-ghost",title:o.tooltip,disabled:o.disabled,style:{height:32,gap:4,position:"relative",background:T?t.primaryLt:"transparent",color:T?t.primary:o.disabled?t.textMut:t.text,opacity:o.disabled?.55:1,cursor:o.disabled?"not-allowed":"pointer"},onClick:()=>y(o,v),children:[o.icon&&e.jsx("span",{style:{fontSize:16},children:o.icon}),$&&e.jsx("span",{style:{fontSize:13},children:$}),F&&e.jsx("span",{style:{fontSize:9,opacity:.55,marginLeft:2},children:"▼"}),o.count!==void 0&&e.jsx(Fe,{count:o.count})]}),F&&i===v&&e.jsx(fe,{items:o.items,onSelect:()=>h(null),style:{top:"100%",left:0}})]},v)};return e.jsx("div",{ref:f,className:"dhx",style:{display:"flex",alignItems:"center",gap:2,padding:"4px 8px",background:t.surface,borderBottom:`1px solid ${t.border}`,minHeight:44,flexWrap:"wrap",...d},children:r.map(S)})}function lt(r){return r==="primary"?t.primary:r==="success"?"#43a047":r==="secondary"?"#9e9e9e":"#e53935"}function st(r,n){const d=[],i=h=>{var a;h.id&&h.group===n&&d.push(h.id),(a=h.items)==null||a.forEach(i)};return r.forEach(i),d}function it(r){const n={},d=i=>{var h;i.id&&i.twoState&&i.active&&(n[i.id]=!0),(h=i.items)==null||h.forEach(d)};return r.forEach(d),n}function dt({items:r=[],width:n=240,minWidth:d=64,header:i,footer:h,collapsed:a,defaultCollapsed:u,selected:f,defaultSelected:y,onSelect:S,onCollapse:o,onExpand:v,onBeforeCollapse:T,onBeforeExpand:$,onToggleItem:F,style:c}){const m=a!==void 0,C=f!==void 0,[E,A]=p.useState(u??!1),[M,H]=p.useState(y??null),[U,g]=p.useState({}),[I,s]=p.useState(()=>it(r));p.useEffect(ne,[]);const x=m?a:E,_=C?f??null:M,P=x?d:n,l=()=>{if(x){if(($==null?void 0:$())===!1)return;m||A(!1),v==null||v()}else{if((T==null?void 0:T())===!1)return;m||A(!0),o==null||o()}},D=w=>{C||H(w.id??null),S==null||S(w),w.id&&w.onClick&&w.onClick(w.id)},K=w=>{if(!w.id)return;const O=!I[w.id];let X={...I,[w.id]:O};w.group&&O&&st(r,w.group).forEach(ee=>{ee!==w.id&&(X[ee]=!1)}),s(X),F==null||F(w.id,O)},b=(w,O)=>{if(w.count===void 0)return null;const X=lt(w.countColor),ee=w.count>99?"99+":String(w.count);return O?e.jsx("span",{style:{position:"absolute",top:1,right:1,background:X,color:"#fff",borderRadius:8,fontSize:9,fontWeight:700,padding:"0 3px",minWidth:14,textAlign:"center",lineHeight:"14px",pointerEvents:"none"},children:ee}):e.jsx("span",{style:{background:X,color:"#fff",borderRadius:10,padding:"1px 6px",fontSize:11,fontWeight:700,flexShrink:0},children:ee})},z=(w,O,X)=>{var de;if(w.hidden)return null;const ee=w.id??`${w.type??"navItem"}-${O}-${X}`,J=w.type??"navItem";if(J==="separator")return e.jsx("div",{style:{height:1,background:t.border,margin:"6px 8px",flexShrink:0}},ee);if(J==="spacer")return e.jsx("div",{style:{flex:1}},ee);if(J==="title")return x?null:e.jsx("div",{style:{padding:"10px 14px 4px",fontSize:10,fontWeight:700,textTransform:"uppercase",letterSpacing:1,color:t.textMut,flexShrink:0},children:w.value},ee);if(J==="customHTML")return e.jsx("div",{dangerouslySetInnerHTML:{__html:w.html??""},style:{padding:"8px 12px",flexShrink:0}},ee);const Q=(((de=w.items)==null?void 0:de.length)??0)>0,se=!!U[w.id??""],ie=w.twoState?!!I[w.id??""]:!1,B=!w.twoState&&_===w.id||ie,N=!!w.disabled,Z=x?0:12+O*16,j=()=>{N||(w.twoState?(K(w),D(w)):(Q&&g(pe=>({...pe,[w.id??""]:!pe[w.id??""]})),D(w)))};return e.jsxs("div",{style:{flexShrink:0},children:[e.jsxs("div",{title:w.tooltip,onClick:j,style:{display:"flex",alignItems:"center",gap:x?0:8,justifyContent:x?"center":"flex-start",paddingTop:8,paddingBottom:8,paddingLeft:x?0:Z,paddingRight:x?0:10,borderRadius:t.r,margin:"1px 6px",cursor:N?"not-allowed":"pointer",userSelect:"none",transition:"background .15s",background:B?t.primaryLt:"transparent",color:N?t.textMut:B?t.primary:t.text,opacity:N?.55:1},onMouseEnter:pe=>{!B&&!N&&(pe.currentTarget.style.background=t.bg)},onMouseLeave:pe=>{!B&&!N&&(pe.currentTarget.style.background="transparent")},children:[e.jsxs("span",{style:{position:"relative",minWidth:22,textAlign:"center",fontSize:18,flexShrink:0,lineHeight:1},children:[w.icon??(w.value&&!w.icon,null),x&&b(w,!0)]}),!x&&e.jsx("span",{style:{flex:1,fontSize:13,fontWeight:B?600:400,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:w.value}),!x&&b(w,!1),!x&&w.twoState&&e.jsx("span",{style:{width:14,height:14,borderRadius:2,border:`2px solid ${B?t.primary:t.borderDk}`,background:B?t.primary:"transparent",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:B&&e.jsx("span",{style:{color:"#fff",fontSize:8,fontWeight:700,lineHeight:1},children:"✓"})}),!x&&Q&&!w.twoState&&e.jsx("span",{style:{fontSize:11,color:t.textMut,flexShrink:0,transition:"transform .2s",transform:se?"rotate(90deg)":"rotate(0deg)",display:"inline-block"},children:"▶"})]}),Q&&se&&!x&&e.jsx("div",{children:w.items.map((pe,ye)=>z(pe,O+1,ye))})]},ee)},L=e.jsxs("div",{onClick:l,style:{display:"flex",alignItems:"center",justifyContent:x?"center":"flex-start",gap:8,padding:x?"8px 0":"8px 14px",margin:"4px 6px",borderRadius:t.r,cursor:"pointer",color:t.textMut,fontSize:13,userSelect:"none",transition:"background .15s",flexShrink:0},onMouseEnter:w=>w.currentTarget.style.background=t.bg,onMouseLeave:w=>w.currentTarget.style.background="transparent",children:[e.jsx("span",{style:{fontSize:16,fontWeight:700,lineHeight:1},children:x?"›":"‹"}),!x&&e.jsx("span",{children:"Collapse"})]});return e.jsxs("div",{className:"dhx",style:{width:P,minWidth:P,background:t.surface,borderRight:`1px solid ${t.border}`,display:"flex",flexDirection:"column",transition:"width .2s ease, min-width .2s ease",overflow:"hidden",...c},children:[i&&e.jsx("div",{style:{padding:x?"12px 0":"12px 14px",borderBottom:`1px solid ${t.border}`,fontWeight:700,fontSize:15,display:"flex",alignItems:"center",justifyContent:x?"center":"flex-start",overflow:"hidden",flexShrink:0},children:i}),e.jsx("div",{className:"dhx-scroll",style:{flex:1,overflowY:"auto",overflowX:"hidden",display:"flex",flexDirection:"column"},children:r.map((w,O)=>z(w,0,O))}),L,h&&!x&&e.jsx("div",{style:{padding:"10px 14px",borderTop:`1px solid ${t.border}`,flexShrink:0},children:h})]})}function at({config:r}){const[n,d]=p.useState(!1),i={position:"relative",background:t.surface,border:`1px solid ${t.border}`,borderRadius:t.r,overflow:"hidden",...r.width?{width:r.width,minWidth:r.width}:{flex:1},...r.height?{height:r.height,minHeight:r.height}:{minHeight:40},...n?{flex:"0 0 auto"}:{}};return e.jsxs("div",{style:i,children:[r.header&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 12px",background:t.bg,borderBottom:`1px solid ${t.border}`,fontSize:12,fontWeight:600,color:t.textSec,userSelect:"none"},children:[e.jsx("span",{children:r.header}),r.collapsable&&e.jsx("button",{onClick:()=>d(h=>!h),style:{background:"none",border:"none",cursor:"pointer",color:t.textMut,fontSize:16,lineHeight:1},children:n?"▼":"▲"})]}),!n&&e.jsxs("div",{style:{padding:r.padding||0,height:r.header?"calc(100% - 33px)":"100%",overflow:"auto"},children:[r.html?e.jsx("div",{dangerouslySetInnerHTML:{__html:r.html}}):r.content,(r.rows||r.cols)&&e.jsx(Ve,{rows:r.rows,cols:r.cols,style:{height:"100%"}})]})]})}function Ve({rows:r,cols:n,type:d="line",style:i,children:h}){p.useEffect(ne,[]);const a=d==="space"?12:d==="wide"?8:1,u=r||n,f=!!r;return u?e.jsx("div",{className:"dhx",style:{display:"flex",flexDirection:f?"column":"row",gap:a,width:"100%",height:"100%",...i},children:u.map((y,S)=>e.jsx(at,{config:y},y.id||S))}):e.jsx("div",{className:"dhx",style:{width:"100%",height:"100%",...i},children:h})}function ct({views:r=[],mode:n="top",tabAlign:d="left",closable:i=[],disabled:h=[],defaultActive:a,onBeforeChange:u,onChange:f,style:y}){var M;const[S,o]=p.useState(a||((M=r[0])==null?void 0:M.id)),[v,T]=p.useState(r.map(H=>H.id));p.useEffect(ne,[]);const $=(H,U)=>{H.stopPropagation(),T(g=>g.filter(I=>I!==U)),S===U&&o(v.find(g=>g!==U)??"")},F=H=>{h.includes(H)||u&&u(H)===!1||(o(H),f==null||f(H))},c=n==="left"||n==="right",m=r.filter(H=>v.includes(H.id)),C=e.jsx("div",{style:{display:"flex",flexDirection:c?"column":"row",justifyContent:d==="center"?"center":d==="right"?"flex-end":"flex-start",background:t.surface,borderBottom:!c&&n!=="bottom"?`2px solid ${t.border}`:"none",borderTop:n==="bottom"?`2px solid ${t.border}`:"none",borderRight:n==="left"?`2px solid ${t.border}`:"none",borderLeft:n==="right"?`2px solid ${t.border}`:"none",overflowX:"auto",flexShrink:0},children:m.map(H=>{const U=S===H.id,g=h.includes(H.id),I=n==="bottom"?{borderTop:`2px solid ${t.primary}`,color:t.primary,fontWeight:600}:c?{color:t.primary,fontWeight:600,background:t.primaryLt,[n==="left"?"borderRight":"borderLeft"]:`2px solid ${t.primary}`}:{borderBottom:`2px solid ${t.primary}`,color:t.primary,fontWeight:600};return e.jsxs("div",{onClick:()=>F(H.id),style:{display:"flex",alignItems:"center",gap:6,padding:"10px 16px",cursor:g?"not-allowed":"pointer",whiteSpace:"nowrap",fontSize:13,transition:"color .15s",userSelect:"none",minWidth:c?120:"auto",...U?I:{color:g?t.textMut:t.textSec}},children:[H.icon&&e.jsx("span",{style:{fontSize:16},children:H.icon}),e.jsx("span",{children:H.tab}),i.includes(H.id)&&e.jsx("span",{onClick:s=>$(s,H.id),style:{marginLeft:4,opacity:.6,fontSize:12,cursor:"pointer"},children:"✕"})]},H.id)})}),E=m.find(H=>H.id===S),A=e.jsxs("div",{className:"dhx-scroll",style:{flex:1,overflow:"auto"},children:[E==null?void 0:E.content,(E==null?void 0:E.html)&&e.jsx("div",{dangerouslySetInnerHTML:{__html:E.html},style:{padding:16}})]});return e.jsxs("div",{className:"dhx",style:{display:"flex",flexDirection:n==="top"?"column":n==="bottom"?"column-reverse":n==="left"?"row":"row-reverse",width:"100%",height:"100%",background:t.surface,border:`1px solid ${t.border}`,borderRadius:t.r,overflow:"hidden",...y},children:[C,A]})}const be=`1px solid ${t.border}`;function pt({active:r,dir:n}){return e.jsxs("span",{style:{display:"inline-flex",flexDirection:"column",gap:1,flexShrink:0,marginLeft:4},children:[e.jsx("svg",{width:"7",height:"4",viewBox:"0 0 7 4",children:e.jsx("path",{d:"M3.5 0L7 4H0z",fill:r&&n==="asc"?t.primary:t.borderDk})}),e.jsx("svg",{width:"7",height:"4",viewBox:"0 0 7 4",children:e.jsx("path",{d:"M3.5 4L0 0H7z",fill:r&&n==="desc"?t.primary:t.borderDk})})]})}function ht({options:r,value:n,onChange:d,onCommit:i,onCancel:h}){const[a,u]=p.useState(n),[f,y]=p.useState(!0),S=p.useRef(null);p.useEffect(()=>{const v=T=>{S.current&&!S.current.contains(T.target)&&i()};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[i]);const o=r.filter(v=>!a||v.toLowerCase().includes(a.toLowerCase()));return e.jsxs("div",{ref:S,style:{width:"100%",position:"relative"},children:[e.jsx("input",{autoFocus:!0,value:a,onChange:v=>{u(v.target.value),d(v.target.value),y(!0)},onKeyDown:v=>{v.key==="Enter"&&i(),v.key==="Escape"&&h()},onClick:v=>v.stopPropagation(),style:{width:"100%",border:"none",outline:`2px solid ${t.primary}`,borderRadius:2,fontSize:13,padding:"2px 4px",background:t.surface,color:t.text}}),f&&o.length>0&&e.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,zIndex:50,background:t.surface,border:`1px solid ${t.border}`,borderRadius:t.r,boxShadow:t.shadowLg,maxHeight:160,overflowY:"auto"},children:o.map(v=>e.jsx("div",{onMouseDown:T=>{T.preventDefault(),d(v),u(v),y(!1),i()},style:{padding:"6px 10px",cursor:"pointer",fontSize:13,color:t.text},onMouseEnter:T=>T.currentTarget.style.background=t.bg,onMouseLeave:T=>T.currentTarget.style.background=t.surface,children:v},v))})]})}function ut(r,n){if(r==null)return"";if(n==="number")return typeof r=="number"?r.toLocaleString():String(r);if(n==="date"){const d=r instanceof Date?r:new Date(String(r));return isNaN(d.getTime())?String(r):d.toLocaleDateString()}return String(r)}function ft(r,n,d){return r==null?1:n==null?-1:d==="date"?new Date(String(r)).getTime()-new Date(String(n)).getTime():d==="number"?Number(r)-Number(n):String(r)<String(n)?-1:String(r)>String(n)?1:0}function ze(r){var n;return Array.isArray(r.header)&&((n=r.header[1])==null?void 0:n.content)!=null?r.header[1].content:r.filterable?r.filterType==="select"?"selectFilter":"inputFilter":null}function gt(r,n,d,i,h){const a={width:"100%",border:"none",outline:`2px solid ${t.primary}`,borderRadius:2,fontSize:13,padding:"2px 4px",background:t.surface,color:t.text},u=r.editorType??"input";if(u==="select")return e.jsx("select",{autoFocus:!0,value:n,onChange:y=>d(y.target.value),onBlur:i,onKeyDown:y=>{y.key==="Enter"&&i(),y.key==="Escape"&&h()},onClick:y=>y.stopPropagation(),style:{...a,cursor:"pointer"},children:(r.options??[]).map(y=>e.jsx("option",{value:y,children:y},y))});if(u==="combobox")return e.jsx(ht,{options:r.options??[],value:n,onChange:d,onCommit:i,onCancel:h});const f=r.type==="number"?"number":r.type==="date"?"date":"text";return e.jsx("input",{autoFocus:!0,type:f,value:n,onChange:y=>d(y.target.value),onBlur:i,onKeyDown:y=>{y.key==="Enter"&&i(),y.key==="Escape"&&h()},onClick:y=>y.stopPropagation(),style:a})}function yt({columns:r,data:n=[],height:d=400,rowHeight:i=40,headerRowHeight:h=40,footerRowHeight:a=40,sortable:u=!0,resizable:f=!0,editable:y=!1,stripe:S=!1,autoWidth:o=!1,keyNavigation:v=!1,selection:T,multiselect:$,leftSplit:F=0,onSelect:c,onChange:m,style:C}){var Ge;const[E,A]=p.useState(null),[M,H]=p.useState("asc"),[U,g]=p.useState({}),[I,s]=p.useState(new Set),[x,_]=p.useState(-1),[P,l]=p.useState(()=>Object.fromEntries(r.map(k=>[k.id,k.width??k.minWidth??150]))),[D,K]=p.useState(null),[b,z]=p.useState(""),[L,w]=p.useState({}),O=p.useRef(null),[X,ee]=p.useState(0);p.useEffect(ne,[]),p.useEffect(()=>{if(!o||!O.current)return;const k=new ResizeObserver(()=>{var W;return ee(((W=O.current)==null?void 0:W.offsetWidth)??0)});return k.observe(O.current),()=>k.disconnect()},[o]);const J=p.useMemo(()=>r.map(k=>k.summary&&(!k.footer||k.footer.length===0)?{...k,footer:[{summary:k.summary}]}:k),[r]),Q=p.useMemo(()=>J.filter(k=>!k.hidden),[J]),se=p.useMemo(()=>{if(!o||X===0)return P;const k=Q.reduce((V,Y)=>V+(P[Y.id]??150),0);if(X<=k)return P;const W=(X-k)/Q.length;return Object.fromEntries(Q.map(V=>[V.id,(P[V.id]??150)+W]))},[o,X,P,Q]),ie=p.useMemo(()=>{let k=n.map((W,V)=>{const Y=String(W.id??V);return L[Y]?{...W,...L[Y]}:W}).filter(W=>Object.entries(U).every(([V,Y])=>!Y||String(W[V]??"").toLowerCase().includes(Y.toLowerCase())));if(E){const W=J.find(V=>V.id===E);k=[...k].sort((V,Y)=>{const R=ft(V[E],Y[E],W==null?void 0:W.type);return M==="asc"?R:-R})}return k},[n,E,M,U,L,J]),ue=p.useMemo(()=>{const k={};return J.forEach(W=>{var V;if((V=W.footer)!=null&&V.some(Y=>Y.summary)){const Y=ie.map(q=>Number(q[W.id])).filter(q=>!isNaN(q)),R=Y.reduce((q,ae)=>q+ae,0);k[W.id]={sum:R,avg:Y.length?R/Y.length:0,count:ie.length,min:Y.length?Math.min(...Y):0,max:Y.length?Math.max(...Y):0}}}),k},[ie,J]),B=p.useMemo(()=>{const k={};return Q.filter(W=>{const V=ze(W);return V==="selectFilter"||V==="comboFilter"}).forEach(W=>{k[W.id]=[...new Set(n.map(V=>String(V[W.id]??"")))].sort()}),k},[n,Q]),N=Q.some(k=>ze(k)!==null),Z=J.some(k=>{var W;return(W=k.footer)==null?void 0:W.length}),j=Q.reduce((k,W)=>k+(se[W.id]??150),0),de=p.useMemo(()=>{if(!F)return{};let k=0;const W={};return Q.forEach((V,Y)=>{Y<F&&(W[V.id]=k,k+=se[V.id]??150)}),W},[F,Q,se]),pe=F>0?(Ge=Q[F-1])==null?void 0:Ge.id:null,ye=(k,W)=>k.id??W,Zt=k=>{!u||k.sortable===!1||(H(W=>E===k.id&&W==="asc"?"desc":"asc"),A(k.id))},Ie=(k,W)=>{if(!T)return;const V=ye(k,W);_(W),s(Y=>{const R=$?new Set(Y):new Set;return R.has(V)?R.delete(V):R.add(V),R}),c==null||c(k)},Qt=()=>{if(!D)return;const{key:k,colId:W}=D;w(Y=>({...Y,[String(k)]:{...Y[String(k)]||{},[W]:b}}));const V=ie.find((Y,R)=>ye(Y,R)===k);V&&(m==null||m(V,W,b)),K(null)},Rt=k=>{if(D&&k.key==="Escape"){K(null);return}if(!(!v||!T)){if(k.key==="ArrowDown"){k.preventDefault();const W=Math.min(x+1,ie.length-1);W>=0&&Ie(ie[W],W)}else if(k.key==="ArrowUp"){k.preventDefault();const W=Math.max(x-1,0);W>=0&&Ie(ie[W],W)}}},er=(k,W)=>{k.preventDefault(),k.stopPropagation();const V=k.clientX,Y=P[W]??150,R=r.find(ce=>ce.id===W),q=ce=>l(xe=>({...xe,[W]:Math.max((R==null?void 0:R.minWidth)||50,Y+ce.clientX-V)})),ae=()=>{document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",ae)};document.addEventListener("mousemove",q),document.addEventListener("mouseup",ae)},Ne=(k,W,V,Y,R,q="hidden")=>{const ae=k in de;return{width:W,minWidth:W,flexShrink:0,boxSizing:"border-box",padding:"0 12px",height:R,display:"flex",alignItems:"center",overflow:q,textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:13,textAlign:V,justifyContent:V==="center"?"center":V==="right"?"flex-end":"flex-start",borderLeft:Y?"none":be,position:ae?"sticky":"relative",...ae?{left:de[k],zIndex:1,boxShadow:k===pe?"2px 0 6px rgba(0,0,0,0.1)":void 0}:{}}};return e.jsx("div",{ref:O,className:"dhx",tabIndex:v?0:void 0,onKeyDown:Rt,style:{width:"100%",height:d,display:"flex",flexDirection:"column",border:be,borderRadius:t.r,overflow:"hidden",outline:"none",...C},children:e.jsx("div",{className:"dhx-scroll",style:{overflow:"auto",flex:1},children:e.jsxs("div",{style:{minWidth:j,display:"flex",flexDirection:"column",minHeight:"100%"},children:[e.jsx("div",{style:{display:"flex",background:t.bg,borderBottom:be,flexShrink:0,position:"sticky",top:0,zIndex:3},children:Q.map((k,W)=>{const V=Array.isArray(k.header)?k.header[0]:null,Y=(V==null?void 0:V.text)??(typeof k.header=="string"?k.header:k.id),R=(V==null?void 0:V.align)??k.align,q=se[k.id]??150,ae=k.id in de;return e.jsxs("div",{onClick:()=>Zt(k),style:{...Ne(k.id,q,R,W===0,h),fontWeight:500,color:t.text,background:t.bg,cursor:u&&k.sortable!==!1?"pointer":"default",userSelect:"none",...ae?{zIndex:4}:{}},children:[V!=null&&V.htmlEnable?e.jsx("span",{style:{flex:1,overflow:"hidden"},dangerouslySetInnerHTML:{__html:Y}}):e.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Y}),u&&k.sortable!==!1&&e.jsx(pt,{active:E===k.id,dir:M}),f&&k.resizable!==!1&&W<Q.length-1&&e.jsx("div",{onMouseDown:ce=>er(ce,k.id),onClick:ce=>ce.stopPropagation(),style:{position:"absolute",right:0,top:0,bottom:0,width:4,cursor:"col-resize",zIndex:1},onMouseEnter:ce=>ce.currentTarget.style.background=t.primary+"55",onMouseLeave:ce=>ce.currentTarget.style.background="transparent"})]},k.id)})}),N&&e.jsx("div",{style:{display:"flex",borderBottom:be,background:t.surface,flexShrink:0,...F?{position:"sticky",top:h,zIndex:3}:{}},children:Q.map((k,W)=>{const V=ze(k),Y=se[k.id]??150,R=k.id in de;return e.jsx("div",{style:{width:Y,minWidth:Y,flexShrink:0,padding:"4px 6px",boxSizing:"border-box",borderLeft:W===0?"none":be,background:t.surface,...R?{position:"sticky",left:de[k.id],zIndex:4,boxShadow:k.id===pe?"2px 0 6px rgba(0,0,0,0.1)":void 0}:{}},children:V==="selectFilter"||V==="comboFilter"?e.jsxs("select",{className:"dhx dhx-input",style:{height:26,fontSize:12,padding:"0 4px"},value:U[k.id]||"",onChange:q=>g(ae=>({...ae,[k.id]:q.target.value})),children:[e.jsx("option",{value:"",children:"All"}),(B[k.id]||[]).map(q=>e.jsx("option",{value:q,children:q},q))]}):V==="inputFilter"?e.jsx("input",{className:"dhx dhx-input",style:{height:26,fontSize:12},placeholder:"Filter...",value:U[k.id]||"",onChange:q=>g(ae=>({...ae,[k.id]:q.target.value}))}):null},k.id)})}),e.jsxs("div",{style:{flex:1},children:[ie.map((k,W)=>{const V=ye(k,W),Y=I.has(V),R=Y?t.primaryLt:S&&W%2!==0?t.bg:t.surface;return e.jsx("div",{style:{display:"flex",height:i,borderBottom:be,flexShrink:0,background:R,transition:"background .1s",cursor:T?"pointer":"default"},onMouseEnter:q=>!Y&&(q.currentTarget.style.background=t.primaryLt+"80"),onMouseLeave:q=>!Y&&(q.currentTarget.style.background=R),children:Q.map((q,ae)=>{const ce=(D==null?void 0:D.key)===V&&(D==null?void 0:D.colId)===q.id,xe=k[q.id],tr=se[q.id]??150,Je=(y||q.editable)&&q.editable!==!1;let ve;return ce?ve=gt(q,b,z,Qt,()=>K(null)):q.template?ve=q.template(xe,k):q.htmlEnable?ve=e.jsx("span",{dangerouslySetInnerHTML:{__html:String(xe??"")}}):q.type==="boolean"?ve=e.jsx("input",{type:"checkbox",readOnly:!0,checked:!!xe,style:{width:16,height:16,accentColor:t.primary,cursor:Je?"pointer":"default"}}):ve=ut(xe,q.type),e.jsx("div",{onClick:()=>{if(Ie(k,W),!!Je)if(q.type==="boolean"){const Ze=!xe,Qe=String(V);w(Re=>({...Re,[Qe]:{...Re[Qe]||{},[q.id]:Ze}})),m==null||m(k,q.id,Ze)}else K({key:V,colId:q.id}),z(String(xe??""))},style:{...Ne(q.id,tr,q.align,ae===0,i,ce?"visible":"hidden"),background:R},children:ve},q.id)})},String(V))}),ie.length===0&&e.jsx("div",{style:{textAlign:"center",padding:40,color:t.textMut,fontSize:13},children:"No data"})]}),Z&&e.jsx("div",{style:{display:"flex",borderTop:be,background:t.bg,flexShrink:0,position:"sticky",bottom:0,zIndex:2},children:Q.map((k,W)=>{var ce;const V=(ce=k.footer)==null?void 0:ce[0],Y=ue[k.id]??{sum:0,avg:0,count:0,min:0,max:0};let R="";V&&(typeof V.text=="function"?R=V.text(Y):V.text?R=V.text:V.summary&&(R=String(Math.round(Y[V.summary]*100)/100)));const q=se[k.id]??150,ae=k.id in de;return e.jsx("div",{style:{...Ne(k.id,q,k.align,W===0,a),fontWeight:600,color:t.text,background:t.bg,...ae?{zIndex:3}:{}},children:R},k.id)})})]})})})}const he=["#0288d1","#43a047","#f57c00","#e53935","#8e24aa","#00838f","#ef6c00","#2e7d32"];function xt(r,n,d){const i=r.filter(a=>!a.parent),h=r.filter(a=>!!a.parent);return i.map(a=>({name:a[d],children:h.filter(u=>u.parent===a.id).map(u=>({name:u[d],value:Number(u[n]??0)}))}))}function bt({type:r="bar",data:n=[],series:d=[],scales:i={},legend:h,height:a=280,style:u}){var m,C,E,A,M,H,U,g,I,s,x,_,P,l,D,K;p.useEffect(ne,[]);const f=((m=i.bottom)==null?void 0:m.text)||n[0]&&Object.keys(n[0])[0]||"x",y=e.jsx(re.Tooltip,{contentStyle:{fontSize:12,borderRadius:t.r,border:`1px solid ${t.border}`}}),S=h?e.jsx(re.Legend,{iconSize:10,wrapperStyle:{fontSize:12},verticalAlign:h.valign==="bottom"?"bottom":h.valign==="middle"?"middle":"top",align:h.halign??"center"}):null,o=e.jsx(re.CartesianGrid,{strokeDasharray:"3 3",stroke:t.border}),v=e.jsx(re.XAxis,{dataKey:f,tick:{fontSize:11,fill:t.textSec},axisLine:{stroke:t.border},tickLine:!1,label:(C=i.bottom)!=null&&C.title?{value:i.bottom.title,position:"insideBottom",offset:-4,fontSize:11}:void 0}),T=e.jsx(re.YAxis,{tick:{fontSize:11,fill:t.textSec},axisLine:!1,tickLine:!1,domain:[((E=i.left)==null?void 0:E.min)??"auto",((A=i.left)==null?void 0:A.max)??"auto"],tickCount:(M=i.left)==null?void 0:M.maxTicks,label:(H=i.left)!=null&&H.title?{value:i.left.title,angle:-90,position:"insideLeft",fontSize:11}:void 0}),$={top:10,right:20,left:0,bottom:(U=i.bottom)!=null&&U.title?20:0},F={data:n,margin:$};let c;if(r==="bar")c=e.jsxs(re.BarChart,{...F,children:[o,v,T,y,S,d.map((b,z)=>e.jsx(re.Bar,{dataKey:b.value||b.id||"",name:b.label||b.id,fill:b.fill||b.color||he[z%he.length],radius:[3,3,0,0]},b.id??z))]});else if(r==="line")c=e.jsxs(re.LineChart,{...F,children:[o,v,T,y,S,d.map((b,z)=>{const L=b.color||he[z%he.length];return e.jsx(re.Line,{type:"monotone",dataKey:b.value||b.id||"",name:b.label||b.id,stroke:L,strokeWidth:b.strokeWidth??2,dot:{r:3,fill:L}},b.id??z)})]});else if(r==="area")c=e.jsxs(re.AreaChart,{...F,children:[o,v,T,y,S,d.map((b,z)=>{const L=b.color||he[z%he.length];return e.jsx(re.Area,{type:"monotone",dataKey:b.value||b.id||"",name:b.label||b.id,stroke:L,fill:(b.fill||L)+"33",strokeWidth:b.strokeWidth??2},b.id??z)})]});else if(r==="pie"||r==="donut"){const b=d[0]||{},z=b.value||"value",L=b.text||"name",w=b.color&&n[0]&&b.color in n[0]?b.color:null;c=e.jsxs(re.PieChart,{children:[e.jsx(re.Pie,{data:n,cx:"50%",cy:"50%",outerRadius:r==="donut"?"70%":"80%",innerRadius:r==="donut"?"40%":0,dataKey:z,nameKey:L,stroke:b.stroke||"none",strokeWidth:b.strokeWidth??0,label:({name:O,percent:X})=>`${O??""} ${((X??0)*100).toFixed(0)}%`,labelLine:!0,paddingAngle:2,children:n.map((O,X)=>e.jsx(re.Cell,{fill:w?O[w]:he[X%he.length]},X))}),y,S]})}else if(r==="radar"){const b=((g=i.radial)==null?void 0:g.value)||f;c=e.jsxs(re.RadarChart,{...F,cx:"50%",cy:"50%",children:[e.jsx(re.PolarGrid,{}),e.jsx(re.PolarAngleAxis,{dataKey:b,tick:{fontSize:11}}),e.jsx(re.PolarRadiusAxis,{tick:{fontSize:9,fill:t.textMut},axisLine:!1}),d.map((z,L)=>{const w=z.color||z.pointColor||he[L%he.length];return e.jsx(re.Radar,{dataKey:z.value||z.id||"",name:z.label||z.id,stroke:w,fill:w+"44"},z.id??L)}),y,S]})}else if(r==="scatter")c=e.jsxs(re.ScatterChart,{margin:$,children:[o,e.jsx(re.XAxis,{type:"number",dataKey:"x",name:((I=i.bottom)==null?void 0:I.title)||"x",tick:{fontSize:11,fill:t.textSec},tickLine:!1,domain:[((s=i.bottom)==null?void 0:s.min)??"auto",((x=i.bottom)==null?void 0:x.max)??"auto"],label:(_=i.bottom)!=null&&_.title?{value:i.bottom.title,position:"insideBottom",offset:-4,fontSize:11}:void 0}),e.jsx(re.YAxis,{type:"number",dataKey:"y",name:((P=i.left)==null?void 0:P.title)||"y",tick:{fontSize:11,fill:t.textSec},tickLine:!1,axisLine:!1,domain:[((l=i.left)==null?void 0:l.min)??"auto",((D=i.left)==null?void 0:D.max)??"auto"],label:(K=i.left)!=null&&K.title?{value:i.left.title,angle:-90,position:"insideLeft",fontSize:11}:void 0}),y,S,d.map((b,z)=>{const L=b.value||"x",w=b.valueY||"y",O=(b.data||n).map(X=>({x:X[L],y:X[w]}));return e.jsx(re.Scatter,{data:O,name:b.label||b.id,fill:b.color||he[z%he.length]},b.id??z)})]});else if(r==="treeMap"){const b=d[0]||{},z=b.value||"value",L=b.text||"name",w=xt(n,z,L),O=b.stroke||t.surface,X=b.strokeWidth??2;c=e.jsx(re.Treemap,{data:w,dataKey:"value",aspectRatio:4/3,stroke:O,content:ee=>{const{x:J,y:Q,width:se,height:ie,depth:ue,index:B,name:N}=ee;if(ue===0)return null;const Z=he[B%he.length];return e.jsxs("g",{children:[e.jsx("rect",{x:J,y:Q,width:se,height:ie,fill:Z,stroke:O,strokeWidth:X,style:{borderRadius:3}}),se>40&&ie>20&&e.jsx("text",{x:J+se/2,y:Q+ie/2,textAnchor:"middle",dominantBaseline:"middle",fill:"#fff",fontSize:11,pointerEvents:"none",children:N})]})}})}return e.jsx("div",{className:"dhx",style:{width:"100%",height:a,padding:12,background:t.surface,borderRadius:t.rMd,...u},children:e.jsx(re.ResponsiveContainer,{width:"100%",height:"100%",children:c})})}const vt=["January","February","March","April","May","June","July","August","September","October","November","December"],St=["Su","Mo","Tu","We","Th","Fr","Sa"];function kt({value:r,range:n=!1,timepicker:d=!1,onChange:i,style:h}){const a=new Date,u=r?new Date(Array.isArray(r)?r[0]:r):a,[f,y]=p.useState(u),[S,o]=p.useState(r??(n?[null,null]:null)),[v,T]=p.useState(null),[$,F]=p.useState({h:0,m:0});p.useEffect(ne,[]);const c=f.getFullYear(),m=f.getMonth(),C=new Date(c,m,1).getDay(),E=new Date(c,m+1,0).getDate(),A=[];for(let g=0;g<C;g++)A.push(null);for(let g=1;g<=E;g++)A.push(new Date(c,m,g));const M=g=>g.toDateString()===a.toDateString(),H=g=>{if(!S)return!1;if(n&&Array.isArray(S)){const[I,s]=S;if(!I)return!1;const x=g.getTime();return s?x>=I.getTime()&&x<=s.getTime():g.toDateString()===I.toDateString()}return g.toDateString()===S.toDateString()},U=g=>{if(n){const[I,s]=Array.isArray(S)?S:[null,null];if(!I||s)o([g,null]);else{const x=g<I?[g,I]:[I,g];o(x),i==null||i(x)}}else o(g),i==null||i(g)};return e.jsxs("div",{className:"dhx",style:{background:t.surface,border:`1px solid ${t.border}`,borderRadius:t.rMd,padding:16,display:"inline-block",boxShadow:t.shadow,...h},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[e.jsx("button",{onClick:()=>y(g=>new Date(g.getFullYear(),g.getMonth()-1,1)),className:"dhx dhx-btn dhx-btn-ghost",style:{height:28,padding:"0 8px",fontSize:16},children:"‹"}),e.jsxs("div",{style:{fontWeight:700,fontSize:14},children:[vt[m]," ",c]}),e.jsx("button",{onClick:()=>y(g=>new Date(g.getFullYear(),g.getMonth()+1,1)),className:"dhx dhx-btn dhx-btn-ghost",style:{height:28,padding:"0 8px",fontSize:16},children:"›"})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(7, 32px)",gap:2},children:[St.map(g=>e.jsx("div",{style:{textAlign:"center",fontSize:11,fontWeight:600,color:t.textMut,paddingBottom:4},children:g},g)),A.map((g,I)=>{const s=g?H(g):!1,x=g&&v&&g.toDateString()===v.toDateString();return e.jsx("div",{onClick:()=>g&&U(g),onMouseEnter:()=>g&&T(g),onMouseLeave:()=>T(null),style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:t.r,cursor:g?"pointer":"default",fontSize:12,fontWeight:g&&M(g)?700:400,background:s?t.primary:x?t.bg:"transparent",color:s?"#fff":g&&M(g)?t.primary:g?t.text:"transparent",border:g&&M(g)&&!s?`1px solid ${t.primary}`:"1px solid transparent",transition:"all .1s"},children:g==null?void 0:g.getDate()},I)})]}),d&&e.jsxs("div",{style:{borderTop:`1px solid ${t.border}`,marginTop:12,paddingTop:12,display:"flex",alignItems:"center",justifyContent:"center",gap:8},children:[e.jsx("input",{type:"number",min:0,max:23,value:$.h,onChange:g=>F(I=>({...I,h:+g.target.value})),className:"dhx dhx-input",style:{width:50,textAlign:"center"}}),e.jsx("span",{style:{fontWeight:700,color:t.textSec},children:":"}),e.jsx("input",{type:"number",min:0,max:59,value:$.m,onChange:g=>F(I=>({...I,m:+g.target.value})),className:"dhx dhx-input",style:{width:50,textAlign:"center"}})]})]})}function je({value:r,onChange:n,timeFormat:d=12,controls:i=!1,minuteStep:h=5,style:a}){const[u,f]=p.useState((r==null?void 0:r.h)??(d===24?0:12)),[y,S]=p.useState((r==null?void 0:r.m)??0),[o,v]=p.useState((r==null?void 0:r.ampm)??"AM"),[T,$]=p.useState(null);p.useEffect(ne,[]);const F=d===24?Array.from({length:24},(M,H)=>H):Array.from({length:12},(M,H)=>H+1),c=Array.from({length:Math.ceil(60/h)},(M,H)=>H*h),m=(M,H,U)=>{const g=d===24?{h:M,m:H}:{h:M,m:H,ampm:U};i?$(g):n==null||n(g)},C=()=>{$(null),f((r==null?void 0:r.h)??(d===24?0:12)),S((r==null?void 0:r.m)??0),v((r==null?void 0:r.ampm)??"AM")},E={display:"flex",flexDirection:"column",alignItems:"center",gap:4},A=M=>({height:32,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:13,fontWeight:M?700:400,background:M?t.primaryLt:"transparent",color:M?t.primary:t.text});return e.jsxs("div",{className:"dhx",style:{background:t.surface,border:`1px solid ${t.border}`,borderRadius:t.rMd,padding:16,display:"inline-block",boxShadow:t.shadow,...a},children:[e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"stretch"},children:[e.jsxs("div",{style:E,children:[e.jsx("span",{style:{fontSize:11,fontWeight:600,color:t.textMut},children:"Hours"}),e.jsx("div",{className:"dhx-scroll",style:{height:160,overflowY:"auto",width:48,border:`1px solid ${t.border}`,borderRadius:t.r},children:F.map(M=>e.jsx("div",{onClick:()=>{f(M),m(M,y,o)},style:A(u===M),onMouseEnter:H=>u!==M&&(H.currentTarget.style.background=t.bg),onMouseLeave:H=>u!==M&&(H.currentTarget.style.background="transparent"),children:String(M).padStart(2,"0")},M))})]}),e.jsxs("div",{style:E,children:[e.jsx("span",{style:{fontSize:11,fontWeight:600,color:t.textMut},children:"Minutes"}),e.jsx("div",{className:"dhx-scroll",style:{height:160,overflowY:"auto",width:48,border:`1px solid ${t.border}`,borderRadius:t.r},children:c.map(M=>e.jsx("div",{onClick:()=>{S(M),m(u,M,o)},style:A(y===M),onMouseEnter:H=>y!==M&&(H.currentTarget.style.background=t.bg),onMouseLeave:H=>y!==M&&(H.currentTarget.style.background="transparent"),children:String(M).padStart(2,"0")},M))})]}),d===12&&e.jsxs("div",{style:E,children:[e.jsx("span",{style:{fontSize:11,fontWeight:600,color:t.textMut},children:"AM/PM"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",border:`1px solid ${t.border}`,borderRadius:t.r,overflow:"hidden"},children:["AM","PM"].map(M=>e.jsx("div",{onClick:()=>{v(M),m(u,y,M)},style:{height:40,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:"0 12px",fontSize:13,fontWeight:o===M?700:400,background:o===M?t.primary:t.surface,color:o===M?"#fff":t.text},children:M},M))})]})]}),e.jsxs("div",{style:{textAlign:"center",marginTop:12,fontSize:22,fontWeight:700,color:t.primary,letterSpacing:2},children:[String(u).padStart(2,"0"),":",String(y).padStart(2,"0"),d===12?` ${o}`:""]}),i&&e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:12},children:[e.jsx("button",{className:"dhx dhx-btn dhx-btn-secondary",onClick:C,children:"Cancel"}),e.jsx("button",{className:"dhx dhx-btn dhx-btn-primary",onClick:()=>{const M=T??(d===24?{h:u,m:y}:{h:u,m:y,ampm:o});n==null||n(M)},children:"Apply"})]})]})}const wt=({open:r})=>e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",style:{flexShrink:0,transition:"transform .15s",transform:r?"rotate(180deg)":"rotate(0deg)"},children:e.jsx("path",{d:"M2 4l4 4 4-4",stroke:t.textMut,strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})});function me({data:r=[],value:n,placeholder:d="Select or type...",multiselection:i=!1,label:h,onChange:a,style:u}){var U;const[f,y]=p.useState(!1),[S,o]=p.useState(""),[v,T]=p.useState(i?n?[].concat(n):[]:n||null),$=p.useRef(null),F=p.useRef(null);p.useEffect(ne,[]),ge($,p.useCallback(()=>{y(!1),o("")},[]));const c=p.useMemo(()=>r.filter(g=>!S||g.value.toLowerCase().includes(S.toLowerCase())),[r,S]),m=g=>i?(v||[]).includes(g):v===g,C=g=>{const I=g.id||g.value;if(i){const s=m(I)?v.filter(x=>x!==I):[...v||[],I];T(s),a==null||a(s)}else T(I),o(""),y(!1),a==null||a(I)},E=g=>{const I=v.filter(s=>s!==g);T(I),a==null||a(I)},A=()=>{y(!0),setTimeout(()=>{var g;return(g=F.current)==null?void 0:g.focus()},0)},M=((U=r.find(g=>(g.id||g.value)===v))==null?void 0:U.value)||"",H=i?v||[]:[];return e.jsxs("div",{ref:$,className:"dhx",style:{position:"relative",...u},children:[h&&e.jsx("label",{className:"dhx dhx-label",children:h}),e.jsxs("div",{onClick:A,style:{display:"flex",alignItems:"center",flexWrap:i?"wrap":"nowrap",border:`1px solid ${f?t.primary:t.border}`,borderRadius:t.r,minHeight:34,padding:"4px 8px",cursor:"text",background:t.surface,gap:4,transition:"border-color .15s",boxShadow:f?`0 0 0 3px ${t.primary}22`:"none"},children:[i&&e.jsxs(e.Fragment,{children:[H.map(g=>{var I;return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,background:t.primary,color:"#fff",borderRadius:12,padding:"2px 10px 2px 8px",fontSize:12,lineHeight:1.5,whiteSpace:"nowrap"},children:[((I=r.find(s=>(s.id||s.value)===g))==null?void 0:I.value)||g,e.jsx("span",{onClick:s=>{s.stopPropagation(),E(g)},style:{cursor:"pointer",fontSize:15,lineHeight:1,opacity:.75,marginLeft:2},children:"×"})]},g)}),e.jsx("input",{ref:F,value:S,onChange:g=>{o(g.target.value),y(!0)},onFocus:()=>y(!0),onClick:g=>g.stopPropagation(),placeholder:H.length?"":d,style:{flex:1,minWidth:60,border:"none",outline:"none",fontSize:13,background:"transparent",color:t.text,padding:0}})]}),!i&&e.jsx("input",{ref:F,value:f?S:M,onChange:g=>{o(g.target.value),y(!0)},onFocus:()=>{y(!0),o("")},onClick:g=>g.stopPropagation(),placeholder:d,style:{flex:1,border:"none",outline:"none",fontSize:13,background:"transparent",color:t.text,padding:0}}),e.jsx(wt,{open:f})]}),f&&e.jsx("div",{className:"dhx dhx-anim-fade",style:{position:"absolute",top:"calc(100% + 4px)",left:0,right:0,background:t.surface,border:`1px solid ${t.border}`,borderRadius:t.r,boxShadow:t.shadowLg,zIndex:100},children:e.jsxs("div",{className:"dhx-scroll",style:{maxHeight:220,overflowY:"auto"},children:[c.map(g=>{const I=g.id||g.value,s=m(I);return e.jsxs("div",{onClick:()=>C(g),style:{padding:"8px 12px",cursor:"pointer",display:"flex",alignItems:"center",gap:8,fontSize:13,background:s?t.primaryLt:"transparent",color:s?t.primary:t.text},onMouseEnter:x=>!s&&(x.currentTarget.style.background=t.bg),onMouseLeave:x=>!s&&(x.currentTarget.style.background="transparent"),children:[i&&e.jsx("span",{style:{width:14,height:14,flexShrink:0,border:`2px solid ${s?t.primary:t.borderDk}`,borderRadius:3,display:"flex",alignItems:"center",justifyContent:"center",background:s?t.primary:"transparent"},children:s&&e.jsx("span",{style:{color:"#fff",fontSize:9,lineHeight:1},children:"✓"})}),e.jsx("span",{style:{flex:1},children:g.value}),!i&&s&&e.jsx("span",{style:{color:t.primary,fontSize:12,fontWeight:700},children:"✓"}),g.count!==void 0&&e.jsxs("span",{style:{fontSize:11,color:t.textMut},children:["(",g.count,")"]})]},I)}),c.length===0&&e.jsx("div",{style:{padding:16,textAlign:"center",color:t.textMut,fontSize:13},children:"No matches"})]})})]})}function Ce({min:r=0,max:n=100,step:d=1,value:i,range:h=!1,label:a,tick:u,disabled:f=!1,onChange:y,style:S}){const[o,v]=p.useState(i??(h?[r,n]:r));p.useEffect(ne,[]);const T=(C,E)=>{if(!f)if(h){const A=[...o];A[C]=E,v(A),y==null||y(A)}else v(E),y==null||y(E)},$=C=>(C-r)/(n-r)*100,F=h?o:[o],c=h?{left:`${$(F[0])}%`,width:`${$(F[1])-$(F[0])}%`}:{left:0,width:`${$(F[0])}%`},m=f?t.border:t.primary;return e.jsxs("div",{className:"dhx",style:{width:"100%",opacity:f?.5:1,...S},children:[a&&e.jsx("label",{className:"dhx dhx-label",children:a}),e.jsx("div",{style:{position:"relative",height:36,display:"flex",alignItems:"center"},children:e.jsxs("div",{style:{position:"relative",flex:1,height:4,background:t.border,borderRadius:2},children:[e.jsx("div",{style:{position:"absolute",...c,height:"100%",background:m,borderRadius:2}}),F.map((C,E)=>e.jsx("input",{type:"range",min:r,max:n,step:d,value:C,disabled:f,onChange:A=>{const M=+A.target.value;h&&E===0&&M>=o[1]||h&&E===1&&M<=o[0]||T(E,M)},style:{position:"absolute",width:"100%",height:"100%",opacity:0,cursor:f?"not-allowed":"pointer",top:0,left:0,margin:0}},E)),F.map((C,E)=>e.jsx("div",{style:{position:"absolute",left:`${$(C)}%`,top:"50%",transform:"translate(-50%, -50%)",width:16,height:16,borderRadius:"50%",background:t.surface,border:`2px solid ${m}`,boxShadow:"0 1px 4px rgba(0,0,0,.2)",pointerEvents:"none"},children:e.jsx("div",{style:{position:"absolute",bottom:"calc(100% + 6px)",left:"50%",transform:"translateX(-50%)",background:f?t.textMut:t.primaryDk,color:"#fff",padding:"2px 6px",borderRadius:t.r,fontSize:11,fontWeight:700,whiteSpace:"nowrap"},children:C})},E))]})}),u&&e.jsx("div",{style:{display:"flex",justifyContent:"space-between",marginTop:2},children:[r,Math.round((n+r)/2),n].map(C=>e.jsx("span",{style:{fontSize:10,color:t.textMut},children:C},C))})]})}const zt=["#f44336","#e91e63","#9c27b0","#673ab7","#3f51b5","#2196f3","#03a9f4","#00bcd4","#009688","#4caf50","#8bc34a","#cddc39","#ffeb3b","#ffc107","#ff9800","#ff5722","#795548","#607d8b","#9e9e9e","#000000","#ffffff","#0288d1","#01579b","#43a047","#e53935","#f57c00"];function Me(r){const n=parseInt(r.slice(1,3),16)/255,d=parseInt(r.slice(3,5),16)/255,i=parseInt(r.slice(5,7),16)/255,h=Math.max(n,d,i),a=Math.min(n,d,i);let u=0,f=0;const y=(h+a)/2;if(h!==a){const S=h-a;f=y>.5?S/(2-h-a):S/(h+a),u=h===n?((d-i)/S+(d<i?6:0))/6:h===d?((i-n)/S+2)/6:((n-d)/S+4)/6}return[Math.round(u*360),Math.round(f*100),Math.round(y*100)]}function Ae(r,n,d){n/=100,d/=100;const i=n*Math.min(d,1-d),h=a=>{const u=(a+r/30)%12,f=d-i*Math.max(Math.min(u-3,9-u,1),-1);return Math.round(255*f).toString(16).padStart(2,"0")};return"#"+h(0)+h(8)+h(4)}function mt({value:r="#0288d1",onChange:n,style:d}){const[i,h]=p.useState(()=>Me(r)),a=Ae(...i);p.useEffect(ne,[]);const u=f=>{h(f),n==null||n(Ae(...f))};return e.jsxs("div",{className:"dhx",style:{background:t.surface,border:`1px solid ${t.border}`,borderRadius:t.rMd,padding:16,display:"inline-block",boxShadow:t.shadow,...d},children:[e.jsx("div",{style:{width:200,height:120,borderRadius:t.r,marginBottom:12,background:`linear-gradient(to bottom, transparent, black), linear-gradient(to right, white, hsl(${i[0]},100%,50%))`,cursor:"crosshair"}}),[["Hue",0,360,i[0]],["Saturation",0,100,i[1]],["Lightness",0,100,i[2]]].map(([f,y,S,o],v)=>e.jsxs("div",{style:{marginBottom:v<2?8:12},children:[e.jsxs("div",{className:"dhx dhx-label",children:[f,v>0?` (${o}%)`:""]}),e.jsx("input",{type:"range",min:y,max:S,value:o,onChange:T=>{const $=[...i];$[v]=+T.target.value,u($)},style:{width:"100%",accentColor:t.primary}})]},f)),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[e.jsx("div",{style:{width:36,height:36,borderRadius:t.r,background:a,border:`1px solid ${t.border}`,flexShrink:0}}),e.jsx("input",{className:"dhx dhx-input",style:{flex:1,fontFamily:"monospace",fontSize:12},value:a,onChange:f=>{try{u(Me(f.target.value)),n==null||n(f.target.value)}catch{}}})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(13, 1fr)",gap:3},children:zt.map(f=>e.jsx("div",{onClick:()=>{h(Me(f)),n==null||n(f)},style:{width:14,height:14,borderRadius:2,background:f,cursor:"pointer",border:a===f?`2px solid ${t.text}`:"1px solid rgba(0,0,0,.15)",transition:"transform .1s"},onMouseEnter:y=>y.currentTarget.style.transform="scale(1.3)",onMouseLeave:y=>y.currentTarget.style.transform="scale(1)"},f))})]})}function Ct({trigger:r,children:n,placement:d="bottom-start",style:i}){const[h,a]=p.useState(!1),[u,f]=p.useState({top:"100%",left:0}),y=p.useRef(null),S=p.useRef(null);p.useEffect(ne,[]),ge(y,p.useCallback(()=>a(!1),[]));const o=()=>{a(v=>{if(!v&&S.current){const T=S.current.getBoundingClientRect(),$={"bottom-start":{top:T.height+4,left:0},"bottom-end":{top:T.height+4,right:0,left:"auto"},"top-start":{bottom:T.height+4,top:"auto",left:0}};f($[d]||$["bottom-start"])}return!v})};return e.jsxs("div",{ref:y,className:"dhx",style:{position:"relative",display:"inline-block"},children:[e.jsx("div",{ref:S,onClick:o,children:r}),h&&e.jsx("div",{className:"dhx dhx-anim-fade",style:{position:"absolute",...u,zIndex:200,background:t.surface,border:`1px solid ${t.border}`,borderRadius:t.rMd,boxShadow:t.shadowLg,...i},children:n})]})}function Mt({title:r,children:n,width:d=480,height:i,closable:h=!0,movable:a=!0,modal:u=!1,defaultOpen:f=!0,footer:y,onClose:S,style:o}){const[v,T]=p.useState(f),[$,F]=p.useState({x:0,y:0});p.useEffect(ne,[]);const c=Be(p.useCallback((C,E)=>a&&F({x:C,y:E}),[a])),m=()=>{T(!1),S==null||S()};return v?e.jsxs(e.Fragment,{children:[u&&e.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,.45)",zIndex:900},onClick:h?m:void 0}),e.jsxs("div",{className:"dhx",style:{position:u?"fixed":"absolute",left:"50%",top:"50%",transform:`translate(calc(-50% + ${$.x}px), calc(-50% + ${$.y}px))`,width:d,...i?{height:i}:{},background:t.surface,borderRadius:t.rMd,boxShadow:t.shadowLg,zIndex:901,display:"flex",flexDirection:"column",overflow:"hidden",...o},children:[e.jsxs("div",{onMouseDown:C=>c(C,$.x,$.y),style:{display:"flex",alignItems:"center",padding:"12px 16px",borderBottom:`1px solid ${t.border}`,cursor:a?"grab":"default",background:t.bg,gap:8,userSelect:"none"},children:[e.jsx("span",{style:{flex:1,fontWeight:700,fontSize:15},children:r}),h&&e.jsx("button",{onClick:m,style:{background:"none",border:"none",cursor:"pointer",width:28,height:28,borderRadius:t.r,display:"flex",alignItems:"center",justifyContent:"center",fontSize:18,color:t.textSec},onMouseEnter:C=>C.currentTarget.style.background=t.border,onMouseLeave:C=>C.currentTarget.style.background="none",children:"×"})]}),e.jsx("div",{className:"dhx-scroll",style:{flex:1,minHeight:0,padding:20,overflowY:"auto"},children:n}),y&&e.jsx("div",{style:{padding:"12px 16px",borderTop:`1px solid ${t.border}`,display:"flex",justifyContent:"flex-end",gap:8,background:t.bg},children:y})]})]}):null}const Le=p.createContext(null),Lt={success:"✓",error:"✕",warning:"⚠",info:"ℹ"},Oe={success:t.success,error:t.danger,warning:t.warning,info:t.primary};function Tt({children:r}){const[n,d]=p.useState([]);p.useEffect(ne,[]);const i=p.useCallback(u=>d(f=>f.filter(y=>y.id!==u)),[]),h=p.useCallback(u=>{const f=Date.now();return d(y=>[...y,{id:f,...u}]),u.duration!==0&&setTimeout(()=>i(f),u.duration||4e3),f},[i]),a={message:h,alert:(u,f)=>h({type:"info",title:u,...f}),confirm:(u,f,y)=>h({type:"warning",title:u,confirm:f,...y})};return e.jsxs(Le.Provider,{value:a,children:[r,e.jsx("div",{style:{position:"fixed",top:20,right:20,zIndex:9999,display:"flex",flexDirection:"column",gap:8,pointerEvents:"none"},children:n.map(u=>{const f=u.type||"info";return e.jsxs("div",{style:{background:t.surface,border:`1px solid ${t.border}`,borderLeft:`4px solid ${Oe[f]}`,borderRadius:t.r,boxShadow:t.shadowLg,padding:"12px 16px",minWidth:280,maxWidth:380,pointerEvents:"all",display:"flex",gap:10,alignItems:"flex-start",animation:"dhx-toast .3s ease"},children:[e.jsx("span",{style:{fontSize:18,color:Oe[f],lineHeight:1},children:Lt[f]}),e.jsxs("div",{style:{flex:1},children:[u.title&&e.jsx("div",{style:{fontWeight:600,fontSize:13,marginBottom:u.text?3:0},children:u.title}),u.text&&e.jsx("div",{style:{fontSize:12,color:t.textSec,lineHeight:1.5},children:u.text}),u.confirm&&e.jsxs("div",{style:{display:"flex",gap:6,marginTop:8},children:[e.jsx("button",{className:"dhx dhx-btn dhx-btn-primary",style:{height:26,fontSize:12},onClick:()=>{u.confirm(!0),i(u.id)},children:"Confirm"}),e.jsx("button",{className:"dhx dhx-btn dhx-btn-secondary",style:{height:26,fontSize:12},onClick:()=>{u.confirm(!1),i(u.id)},children:"Cancel"})]})]}),e.jsx("button",{onClick:()=>i(u.id),style:{background:"none",border:"none",cursor:"pointer",color:t.textMut,fontSize:14,lineHeight:1,padding:0},children:"×"})]},u.id)})})]})}function Ht(){const r=p.useContext(Le);if(!r)throw new Error("useMessage must be used inside <MessageProvider>");return r}function Dt({data:r=[],template:n,keyNavigation:d=!0,multiselection:i=!1,editable:h=!1,height:a=400,onSelect:u,onEdit:f,style:y}){const[S,o]=p.useState(new Set),[v,T]=p.useState(null),[$,F]=p.useState(""),[c,m]=p.useState(null);p.useEffect(ne,[]);const C=(A,M)=>{const H=A.id??M;o(U=>{const g=i?new Set(U):new Set;return g.has(H)?g.delete(H):g.add(H),g}),m(M),u==null||u(A)},E=(A,M)=>{f==null||f({...A,value:$},M),T(null)};return e.jsxs("div",{className:"dhx dhx-scroll",style:{height:a,overflowY:"auto",border:`1px solid ${t.border}`,borderRadius:t.r,background:t.surface,...y},tabIndex:0,onKeyDown:A=>{d&&(A.key==="ArrowDown"&&m(M=>Math.min((M??-1)+1,r.length-1)),A.key==="ArrowUp"&&m(M=>Math.max((M??1)-1,0)))},children:[r.map((A,M)=>{const H=A.id??M,U=S.has(H),g=c===M;return e.jsx("div",{onClick:()=>C(A,M),onDoubleClick:()=>h&&(T(M),F(String(A.value||""))),style:{display:"flex",alignItems:"center",padding:"0 12px",height:40,cursor:"pointer",fontSize:13,borderBottom:`1px solid ${t.border}`,background:U?t.primaryLt:g?t.bg:t.surface,color:U?t.primary:t.text,outline:g?`2px solid ${t.primary}44`:"none",transition:"background .1s"},children:v===M?e.jsx("input",{autoFocus:!0,className:"dhx dhx-input",style:{height:28,flex:1},value:$,onChange:I=>F(I.target.value),onBlur:()=>E(A,M),onKeyDown:I=>{I.key==="Enter"&&E(A,M),I.key==="Escape"&&T(null)},onClick:I=>I.stopPropagation()}):n?e.jsx("div",{dangerouslySetInnerHTML:{__html:n(A)},style:{flex:1}}):e.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:String(A.value??"")})},String(H))}),r.length===0&&e.jsx("div",{style:{padding:24,textAlign:"center",color:t.textMut},children:"No items"})]})}function $t({data:r=[],template:n,itemsInRow:d=3,gap:i=12,multiselection:h=!1,onSelect:a,style:u}){const[f,y]=p.useState(new Set);p.useEffect(ne,[]);const S=o=>{const v=o.id??String(o.title);y(T=>{const $=h?new Set(T):new Set;return $.has(v)?$.delete(v):$.add(v),$}),a==null||a(o)};return e.jsx("div",{className:"dhx",style:{display:"grid",gridTemplateColumns:`repeat(${d}, 1fr)`,gap:i,padding:i,...u},children:r.map((o,v)=>{const T=o.id??v,$=f.has(T);return e.jsx("div",{onClick:()=>S(o),style:{background:t.surface,border:`2px solid ${$?t.primary:t.border}`,borderRadius:t.rMd,overflow:"hidden",cursor:"pointer",transition:"all .15s",boxShadow:$?`0 0 0 3px ${t.primary}33`:t.shadow,transform:$?"translateY(-2px)":"none"},onMouseEnter:F=>{F.currentTarget.style.boxShadow=t.shadowLg,F.currentTarget.style.transform="translateY(-2px)"},onMouseLeave:F=>{F.currentTarget.style.boxShadow=$?`0 0 0 3px ${t.primary}33`:t.shadow,F.currentTarget.style.transform=$?"translateY(-2px)":"none"},children:n?e.jsx("div",{dangerouslySetInnerHTML:{__html:n(o)}}):e.jsxs("div",{style:{padding:16},children:[o.img&&e.jsx("img",{src:o.img,alt:o.title||"",style:{width:"100%",borderRadius:t.r,marginBottom:8,display:"block"}}),e.jsx("div",{style:{fontWeight:600,fontSize:14,marginBottom:4},children:o.title||o.value}),o.subtitle&&e.jsx("div",{style:{fontSize:12,color:t.textSec},children:o.subtitle})]})},String(T))})})}function Te(r){return r.map(n=>({...n,items:n.items?Te(n.items):void 0}))}function He(r,n={}){return r.forEach(d=>{d.opened&&(n[d.id]=!0),d.items&&He(d.items,n)}),n}function Pe(r,n){let d=null;return[r.filter(h=>h.id===n?(d=h,!1):!0).map(h=>{if(h.items){const[a,u]=Pe(h.items,n);return u&&(d=u),{...h,items:a}}return h}),d]}function De(r,n,d,i){if(i==="inside")return r.map(a=>a.id===n?{...a,items:[...a.items||[],d]}:a.items?{...a,items:De(a.items,n,d,i)}:a);if(r.some(a=>a.id===n)){const a=[];for(const u of r)u.id===n?i==="before"?(a.push(d),a.push(u)):(a.push(u),a.push(d)):a.push(u);return a}return r.map(a=>a.items?{...a,items:De(a.items,n,d,i)}:a)}function Et(r,n,d){function i(h){var a,u;if(h.id===n){const f=y=>{var S;return y.id===d||(((S=y.items)==null?void 0:S.some(f))??!1)};return((a=h.items)==null?void 0:a.some(f))??!1}return((u=h.items)==null?void 0:u.some(i))??!1}return r.some(i)}function Ke(r,n,d){return r.map(i=>i.id===n?{...i,value:d}:{...i,items:i.items?Ke(i.items,n,d):void 0})}function It(r,n){var a;let d=0,i=0;const h=u=>{var f;d++,n[u.id]&&i++,(f=u.items)==null||f.forEach(h)};return(a=r.items)==null||a.forEach(h),{total:d,checkedCount:i}}function Nt({data:r=[],checkbox:n=!1,editable:d=!1,dragMode:i,tooltip:h,onSelect:a,onCheck:u,onChange:f,style:y}){const[S,o]=p.useState(()=>Te(r)),[v,T]=p.useState(()=>He(r)),[$,F]=p.useState(null),[c,m]=p.useState({}),[C,E]=p.useState(null),[A,M]=p.useState(""),[H,U]=p.useState(null),[g,I]=p.useState(null);p.useEffect(ne,[]),p.useEffect(()=>{o(Te(r)),T(z=>({...He(r),...z}))},[r]);const s=z=>T(L=>({...L,[z]:!L[z]})),x=(z,L)=>{m(w=>({...w,[z]:L})),u==null||u(z,L)},_=()=>{if(!C)return;const z=C,L=A;E(null),o(w=>{const O=Ke(w,z,L);return f==null||f(O),O})},P=(z,L)=>{z.dataTransfer.effectAllowed="move",U(L)},l=(z,L)=>{if(!H||H===L||Et(S,H,L))return;z.preventDefault();const w=z.currentTarget.getBoundingClientRect(),O=z.clientY-w.top,X=w.height,ee=O<X*.25?"before":O>X*.75?"after":"inside";I(J=>(J==null?void 0:J.id)===L&&(J==null?void 0:J.pos)===ee?J:{id:L,pos:ee})},D=(z,L)=>{if(z.preventDefault(),!H||!g||H===L){I(null),U(null);return}o(w=>{const[O,X]=Pe(w,H);if(!X)return w;const ee=De(O,L,X,g.pos);return f==null||f(ee),ee}),g.pos==="inside"&&T(w=>({...w,[L]:!0})),I(null),U(null)},K=()=>{U(null),I(null)},b=(z,L=0)=>{var B;const w=(((B=z.items)==null?void 0:B.length)??0)>0,O=v[z.id],X=$===z.id,ee=H===z.id,J=(g==null?void 0:g.id)===z.id;let Q=!!c[z.id],se=!1;if(n&&w){const{total:N,checkedCount:Z}=It(z,c);Z>0&&Z<N?se=!0:N>0&&Z===N&&(Q=!0)}const ie=J&&g.pos!=="inside"?{boxShadow:g.pos==="before"?`inset 0 2px 0 0 ${t.primary}`:`inset 0 -2px 0 0 ${t.primary}`}:{},ue=J&&g.pos==="inside"||X?t.primaryLt:"transparent";return e.jsxs("div",{style:{opacity:ee?.4:1},children:[e.jsxs("div",{draggable:!!i,onDragStart:i?N=>P(N,z.id):void 0,onDragOver:i?N=>l(N,z.id):void 0,onDrop:i?N=>D(N,z.id):void 0,onDragEnd:i?K:void 0,title:h==null?void 0:h(z),onClick:()=>{F(z.id),a==null||a(z),w&&s(z.id)},onDoubleClick:()=>{d&&(E(z.id),M(z.value||""))},style:{display:"flex",alignItems:"center",gap:4,padding:`5px 8px 5px ${12+L*18}px`,cursor:i?"grab":"pointer",borderRadius:t.r,margin:"1px 4px",background:ue,color:X?t.primary:t.text,userSelect:"none",fontSize:13,...ie},onMouseEnter:N=>!X&&!J&&(N.currentTarget.style.background=t.bg),onMouseLeave:N=>!X&&!J&&(N.currentTarget.style.background="transparent"),children:[e.jsx("span",{style:{width:16,textAlign:"center",fontSize:11,color:t.textMut,flexShrink:0},onClick:N=>{N.stopPropagation(),w&&s(z.id)},children:w?O?"▾":"▸":""}),e.jsx("span",{style:{fontSize:15,flexShrink:0},children:w?O?"📂":"📁":"📄"}),n&&e.jsx("input",{ref:N=>{N&&(N.indeterminate=se)},type:"checkbox",checked:Q,onChange:N=>{N.stopPropagation(),x(z.id,N.target.checked)},style:{cursor:"pointer",accentColor:t.primary,flexShrink:0},onClick:N=>N.stopPropagation()}),C===z.id?e.jsx("input",{autoFocus:!0,className:"dhx dhx-input",style:{height:24,fontSize:12,flex:1},value:A,onChange:N=>M(N.target.value),onBlur:_,onKeyDown:N=>{N.key==="Enter"&&_(),N.key==="Escape"&&E(null)},onClick:N=>N.stopPropagation()}):e.jsx("span",{style:{flex:1},children:z.value}),z.count!==void 0&&e.jsxs("span",{style:{fontSize:11,color:t.textMut},children:["(",z.count,")"]})]}),w&&O&&e.jsx("div",{children:z.items.map(N=>b(N,L+1))})]},z.id)};return e.jsx("div",{className:"dhx dhx-scroll",style:{overflowY:"auto",...y},onDragOver:i?z=>z.preventDefault():void 0,onDrop:i?z=>{z.preventDefault(),I(null),U(null)}:void 0,children:S.map(z=>b(z))})}function Wt({total:r,pageSize:n=10,page:d,onChange:i,style:h}){const[a,u]=p.useState(d||1),f=Math.ceil(r/n);p.useEffect(ne,[]);const y=o=>{const v=Math.min(Math.max(1,o),f);u(v),i==null||i(v)},S=p.useMemo(()=>{const o=[];for(let T=Math.max(1,a-2);T<=Math.min(f,a+2);T++)o.push(T);return o[0]>1&&(o[0]>2&&o.unshift("..."),o.unshift(1)),o[o.length-1]<f&&(o[o.length-1]<f-1&&o.push("..."),o.push(f)),o},[a,f]);return e.jsxs("div",{className:"dhx",style:{display:"flex",alignItems:"center",gap:4,padding:"8px 12px",...h},children:[e.jsxs("span",{style:{fontSize:12,color:t.textSec,marginRight:8},children:[(a-1)*n+1,"–",Math.min(a*n,r)," of ",r]}),[["«",1],["‹",a-1]].map(([o,v])=>e.jsx("button",{className:"dhx dhx-btn dhx-btn-ghost",style:{height:30,padding:"0 8px",fontSize:14},disabled:a===1,onClick:()=>y(v),children:o},o)),S.map((o,v)=>e.jsx("button",{onClick:()=>typeof o=="number"&&y(o),className:`dhx dhx-btn ${o===a?"dhx-btn-primary":"dhx-btn-ghost"}`,style:{height:30,minWidth:30,padding:"0 8px",fontSize:13},disabled:o==="...",children:o},v)),[["›",a+1],["»",f]].map(([o,v])=>e.jsx("button",{className:"dhx dhx-btn dhx-btn-ghost",style:{height:30,padding:"0 8px",fontSize:14},disabled:a===f,onClick:()=>y(v),children:o},o))]})}function Bt({config:r={},defaultValues:n={},onSubmit:d,style:i}){const[h,a]=p.useState(n),[u,f]=p.useState({}),[y,S]=p.useState(null);p.useEffect(ne,[]);const o=(c,m)=>{a(C=>({...C,[c]:m})),f(C=>({...C,[c]:null}))},v=c=>{const m=[];return c.flat().forEach(C=>{!C||typeof C!="object"||!("name"in C)||(m.push(C),C.type==="fieldset"&&C.rows&&m.push(...v(C.rows)))}),m},T=()=>{const c={};return v(r.rows||[]).forEach(m=>{m.required&&!h[m.name]&&(c[m.name]=`${m.label||m.name} is required`)}),f(c),Object.keys(c).length===0},$=c=>{const m=h[c.name]??c.value??"",C=u[c.name],E=c.labelWidth??r.labelWidth,A=E!==void 0||c.labelPosition==="left";if(c.type==="fieldset")return e.jsxs("fieldset",{style:{border:`1px solid ${t.border}`,borderRadius:t.r,padding:"12px 16px",marginBottom:14},children:[e.jsx("legend",{style:{fontSize:12,fontWeight:700,color:t.textSec,padding:"0 6px"},children:c.label}),(c.rows||[]).map(x=>$(x))]},c.name);if(c.type==="spacer")return e.jsx("div",{style:{height:c.height||16}},c.name);const M=E?{minWidth:E,width:E,flexShrink:0,paddingTop:8,boxSizing:"border-box"}:{},H=c.label?e.jsxs("label",{className:"dhx dhx-label",style:{display:"flex",gap:4,...M},children:[c.label,c.required&&e.jsx("span",{style:{color:t.danger},children:"*"})]},"lbl"):null,U=C?e.jsx("div",{style:{fontSize:11,color:t.danger,marginTop:3},children:C}):null,g=c.helpMessage?e.jsxs("div",{style:{fontSize:11,color:t.textMut,marginTop:3},children:["ⓘ ",c.helpMessage]}):null,I={key:c.name,className:"dhx-form-group"},s=x=>A?e.jsxs("div",{...I,style:{display:"flex",alignItems:"flex-start",gap:8},children:[H,e.jsxs("div",{style:{flex:1,minWidth:0},children:[x,U,g]})]}):e.jsxs("div",{...I,children:[H,x,U,g]});if(!c.type||c.type==="input")return s(e.jsxs("div",{className:"dhx-input-wrap",children:[c.icon&&e.jsx("span",{className:"dhx-input-icon",children:c.icon}),e.jsx("input",{className:`dhx dhx-input${c.icon?" dhx-input--with-icon":""}`,style:{borderColor:C?t.danger:void 0},type:c.inputType||"text",placeholder:c.placeholder,value:m,onChange:x=>o(c.name,x.target.value),disabled:c.disabled})]}));if(c.type==="textarea")return s(e.jsx("textarea",{className:"dhx dhx-input",style:{height:80,resize:"vertical",padding:"8px 10px"},placeholder:c.placeholder,value:m,onChange:x=>o(c.name,x.target.value)}));if(c.type==="select")return s(e.jsxs("select",{className:"dhx dhx-input",value:m,onChange:x=>o(c.name,x.target.value),style:{cursor:"pointer"},children:[e.jsx("option",{value:"",children:"— Select —"}),(c.options||[]).map(x=>e.jsx("option",{value:x.value,children:x.label||x.value},x.value))]}));if(c.type==="datepicker")return s(e.jsx("input",{type:"date",className:"dhx dhx-input",value:m,onChange:x=>o(c.name,x.target.value)}));if(c.type==="timepicker"){const x=h[c.name]??{h:12,m:0,ampm:"AM"},_=!!h[c.name],P=_?`${String(x.h).padStart(2,"0")}:${String(x.m).padStart(2,"0")}${x.ampm?" "+x.ampm:""}`:c.placeholder||"Click to select",l=e.jsxs("div",{style:{position:"relative"},children:[e.jsxs("div",{className:"dhx dhx-input",style:{cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"space-between"},onClick:()=>S(y===c.name?null:c.name),children:[e.jsx("span",{style:{color:_?t.text:t.textMut},children:P}),e.jsx("span",{style:{fontSize:13,color:t.textSec},children:"🕐"})]}),y===c.name&&e.jsx("div",{style:{position:"absolute",zIndex:100,top:"calc(100% + 4px)",left:0},children:e.jsx(je,{value:x,controls:!0,onChange:D=>{o(c.name,D),S(null)}})})]});return s(l)}if(c.type==="colorpicker")return s(e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("input",{type:"color",value:m||"#000000",onChange:x=>o(c.name,x.target.value),style:{width:36,height:36,padding:2,border:`1px solid ${t.border}`,borderRadius:t.r,cursor:"pointer",background:"none"}}),e.jsx("span",{style:{fontSize:12,color:t.textSec,fontFamily:"monospace"},children:m||"#000000"})]}));if(c.type==="text")return s(e.jsx("p",{style:{margin:"6px 0",fontSize:13,color:t.text},children:c.value}));if(c.type==="checkbox")return e.jsxs("div",{...I,children:[A?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[E&&e.jsx("div",{style:{width:E,flexShrink:0}}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:!!m,onChange:x=>o(c.name,x.target.checked),style:{width:16,height:16,accentColor:t.primary,cursor:"pointer"}}),e.jsx("span",{style:{fontSize:13},children:c.label})]})]}):e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:!!m,onChange:x=>o(c.name,x.target.checked),style:{width:16,height:16,accentColor:t.primary,cursor:"pointer"}}),e.jsx("span",{style:{fontSize:13},children:c.label})]}),g]});if(c.type==="radio"){const x=(c.options||[]).map(_=>e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,cursor:"pointer",fontSize:13},children:[e.jsx("input",{type:"radio",name:c.name,value:_.value,checked:m===_.value,onChange:()=>o(c.name,_.value),style:{accentColor:t.primary,cursor:"pointer"}}),_.label||_.value]},_.value));return s(e.jsx("div",{style:{display:"flex",gap:16,flexWrap:"wrap",paddingTop:8},children:x}))}if(c.type==="slider")return A?e.jsxs("div",{...I,style:{display:"flex",alignItems:"flex-start",gap:8},children:[H,e.jsxs("div",{style:{flex:1},children:[e.jsx(Ce,{min:c.min,max:c.max,step:c.step,value:m||c.min,range:c.range,onChange:x=>o(c.name,x)}),g]})]}):e.jsxs("div",{...I,children:[e.jsx(Ce,{label:c.label,min:c.min,max:c.max,step:c.step,value:m||c.min,range:c.range,onChange:x=>o(c.name,x)}),g]});if(c.type==="combo")return A?e.jsxs("div",{...I,style:{display:"flex",alignItems:"flex-start",gap:8},children:[H,e.jsxs("div",{style:{flex:1},children:[e.jsx(me,{data:c.data||[],multiselection:c.multiselection,placeholder:c.placeholder||"Select...",value:m||(c.multiselection?[]:null),onChange:x=>o(c.name,x)}),U,g]})]}):e.jsxs("div",{...I,children:[e.jsx(me,{label:c.label,data:c.data||[],multiselection:c.multiselection,placeholder:c.placeholder||"Select...",value:m||(c.multiselection?[]:null),onChange:x=>o(c.name,x)}),U,g]});if(c.type==="toggle"){const x=!!m,_=x?c.icon:c.offIcon||c.icon,P=x?c.text||c.label:c.offText||c.text||c.label;return e.jsxs("div",{...I,children:[A&&E&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("div",{style:{width:E,flexShrink:0}}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx(_e,{on:x,onClick:()=>o(c.name,!m)}),_&&e.jsx("span",{style:{fontSize:16},children:_}),P&&e.jsx("span",{style:{fontSize:13},children:P})]})]}),!A&&e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:10,cursor:"pointer"},children:[e.jsx(_e,{on:x,onClick:()=>o(c.name,!m)}),_&&e.jsx("span",{style:{fontSize:16},children:_}),P&&e.jsx("span",{style:{fontSize:13},children:P})]}),g]})}return null},F=c=>c.map((m,C)=>Array.isArray(m)?e.jsx("div",{style:{display:"flex",gap:12,alignItems:"flex-start"},children:m.map($)},C):$(m));return e.jsxs("div",{className:"dhx",style:{padding:r.padding||0,width:r.width||"100%",...i},children:[F(r.rows||[]),(r.buttons||d)&&e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:r.buttonAlign||"flex-start",marginTop:8},children:[e.jsx("button",{className:"dhx dhx-btn dhx-btn-primary",onClick:()=>T()&&(d==null?void 0:d(h)),children:r.submitText||"Submit"}),r.resetButton!==!1&&e.jsx("button",{className:"dhx dhx-btn dhx-btn-secondary",onClick:()=>{a(n),f({})},children:r.resetText||"Reset"})]})]})}function _e({on:r,onClick:n}){return e.jsxs("div",{style:{position:"relative",width:40,height:22,flexShrink:0},onClick:n,children:[e.jsx("div",{style:{width:40,height:22,borderRadius:11,background:r?t.primary:t.border,transition:"background 0.2s"}}),e.jsx("div",{style:{position:"absolute",top:3,left:r?21:3,width:16,height:16,borderRadius:"50%",background:"#fff",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,.3)"}})]})}function we(r){const n=[];for(const d of r)d.type==="block"?n.push(...we(d.items||[])):n.push(d);return n}function Ft(r){return r==="primary"?t.primary:r==="success"?t.success:r==="secondary"?t.borderDk:t.danger}function Vt(r,n){switch(r){case"primary":return{background:t.primary,color:"#fff",borderColor:t.primary};case"danger":return{background:t.danger,color:"#fff",borderColor:t.danger};case"success":return{background:t.success,color:"#fff",borderColor:t.success};case"secondary":return{background:t.bg,color:t.text,borderColor:t.border};default:return n?{background:t.primaryLt,color:t.primary}:{}}}function jt({items:r=[],css:n,menuCss:d,style:i,onAction:h,onInputChange:a,onInputBlur:u,onInputFocus:f,onOpenMenu:y}){p.useEffect(ne,[]);const[S,o]=p.useState(()=>{const l={};for(const D of we(r))D.id&&(l[D.id]=!!D.active);return l}),[v,T]=p.useState(null),[$,F]=p.useState(()=>{const l={};for(const D of we(r))D.type==="selectButton"&&D.id&&D.value&&(l[D.id]=D.value);return l}),c=we(r),m=p.useRef(null);ge(m,p.useCallback(()=>T(null),[]));const C=l=>{var D,K;if(!l.disabled){if(l.id){if(l.group){const b=c.filter(z=>z.group===l.group&&z.id);o(z=>{const L={...z};for(const w of b)L[w.id]=!1;return L[l.id]=!0,L})}else l.twoState&&o(b=>({...b,[l.id]:!b[l.id]}));if((D=l.items)!=null&&D.length){const b=l.id;T(z=>z===b?null:b),y==null||y(l.id);return}}(K=l.onClick)==null||K.call(l,l),l.id&&(h==null||h(l.id,l))}},E=({count:l,color:D})=>e.jsx("span",{style:{position:"absolute",top:2,right:2,minWidth:14,height:14,background:Ft(D),color:"#fff",borderRadius:7,fontSize:9,fontWeight:700,display:"flex",alignItems:"center",justifyContent:"center",padding:"0 2px",pointerEvents:"none"},children:l>99?"99+":l}),A=(l,D)=>{var B;const K=l.id!==void 0?S[l.id]??!!l.active:!!l.active,b=l.value??l.text,z=l.size??"medium",L=z==="auto",w=z==="small",O=!!((B=l.items)!=null&&B.length),X=l.id!==void 0&&v===l.id,ee=Vt(l.color,K&&!l.color),J=L?void 0:w?26:32,Q=L?22:w?13:16,se=[l.tooltip,l.hotkey?`(${l.hotkey})`:""].filter(Boolean).join(" "),ie=l.circle?{borderRadius:"50%",padding:L?"8px":"0",aspectRatio:"1",justifyContent:"center"}:{},ue=l.view==="link"?{background:"transparent",border:"none",textDecoration:"underline",padding:"0 4px"}:l.view==="flat"?{borderRadius:0}:{};return e.jsxs("div",{style:{position:"relative",display:"flex"},children:[e.jsxs("button",{title:se||void 0,disabled:l.disabled,className:"dhx dhx-btn dhx-btn-ghost",style:{flexDirection:L?"column":"row",alignSelf:L?"stretch":"center",justifyContent:"center",minHeight:L?56:J,height:L?void 0:J,padding:L?"6px 10px":w?"0 6px":"0 8px",gap:4,position:"relative",background:K&&!l.color?t.primaryLt:"transparent",color:K&&!l.color?t.primary:l.disabled?t.textMut:t.text,opacity:l.disabled?.55:1,cursor:l.disabled?"not-allowed":"pointer",borderColor:X?t.primary:void 0,...ee,...ie,...ue},onClick:()=>C(l),children:[l.loading?e.jsx("span",{style:{fontSize:Q,lineHeight:1,flexShrink:0,display:"inline-block",animation:"dhx-spin 1s linear infinite"},children:"⟳"}):l.icon&&e.jsx("span",{style:{fontSize:Q,lineHeight:1,flexShrink:0},children:l.icon}),b&&!l.html&&e.jsx("span",{style:{fontSize:L?10:w?11:12,maxWidth:L?64:void 0,textAlign:L?"center":"left",lineHeight:L?1.2:1,whiteSpace:L?"normal":"nowrap"},children:b}),l.html&&e.jsx("span",{dangerouslySetInnerHTML:{__html:l.html}}),O&&e.jsx("span",{style:{fontSize:8,opacity:.6,marginLeft:1},children:"▼"}),l.hotkey&&L&&e.jsx("span",{style:{fontSize:9,color:t.textMut,lineHeight:1},children:l.hotkey}),l.count!==void 0&&e.jsx(E,{count:l.count,color:l.countColor})]}),O&&X&&e.jsx(fe,{items:l.items,onSelect:N=>{T(null),N.id&&(h==null||h(String(N.id),l))},style:{top:"100%",left:0,minWidth:160}})]},D)},M=(l,D)=>{const K=l.size??"medium",b=K==="auto"?48:K==="small"?28:36,z=l.id!==void 0?S[l.id]??!!l.active:!!l.active;return e.jsx("div",{style:{position:"relative",display:"flex",alignSelf:"center"},children:e.jsxs("button",{title:l.tooltip,disabled:l.disabled,style:{width:b,height:b,padding:2,border:z?`2px solid ${t.primary}`:"2px solid transparent",borderRadius:"50%",overflow:"hidden",cursor:l.disabled?"not-allowed":"pointer",background:"transparent",flexShrink:0,opacity:l.disabled?.55:1},onClick:()=>C(l),children:[l.src&&e.jsx("img",{src:l.src,alt:l.value||"",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}),l.count!==void 0&&e.jsx(E,{count:l.count,color:l.countColor})]})},D)},H=(l,D)=>{var L,w;const K=l.id!==void 0&&v===`sel:${l.id}`,b=(l.id&&$[l.id])??l.value??((w=(L=l.items)==null?void 0:L[0])==null?void 0:w.value)??"",z=(l.items??[]).map(O=>({id:O.value,value:O.value,icon:O.icon}));return e.jsxs("div",{style:{position:"relative",alignSelf:"center"},children:[e.jsxs("button",{title:l.tooltip,disabled:l.disabled,className:"dhx dhx-btn dhx-btn-ghost",style:{height:28,gap:4,padding:"0 8px",opacity:l.disabled?.55:1,cursor:l.disabled?"not-allowed":"pointer",borderColor:K?t.primary:void 0},onClick:()=>{if(l.disabled||!l.id)return;const O=`sel:${l.id}`;T(X=>X===O?null:O)},children:[l.icon&&e.jsx("span",{style:{fontSize:14},children:l.icon}),e.jsx("span",{style:{fontSize:12},children:b}),e.jsx("span",{style:{fontSize:8,opacity:.6},children:"▼"})]}),K&&e.jsx(fe,{items:z,onSelect:O=>{var ee;const X=String(O.value??O.id??"");l.id&&F(J=>({...J,[l.id]:X})),T(null),(ee=l.onChange)==null||ee.call(l,X),l.id&&(h==null||h(l.id,l))},style:{top:"100%",left:0,minWidth:100}})]},D)},U=(l,D)=>e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start",justifyContent:"center",padding:"2px 4px",gap:2},children:[l.label&&e.jsx("span",{style:{fontSize:10,color:t.textMut},children:l.label}),e.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center"},children:[l.icon&&e.jsx("span",{style:{position:"absolute",left:6,fontSize:13,color:t.textMut,pointerEvents:"none",zIndex:1},children:l.icon}),e.jsx("input",{className:"dhx dhx-input",disabled:l.disabled,style:{width:l.width||110,height:26,fontSize:12,paddingLeft:l.icon?24:void 0},placeholder:l.placeholder,defaultValue:l.value,onChange:K=>{var b;(b=l.onChange)==null||b.call(l,K.target.value),l.id&&(a==null||a(l.id,K.target.value))},onBlur:K=>{var b;(b=l.onBlur)==null||b.call(l,K.target.value),l.id&&(u==null||u(l.id,K.target.value))},onFocus:K=>{var b;(b=l.onFocus)==null||b.call(l,K.target.value),l.id&&(f==null||f(l.id,K.target.value))}})]})]},D),g=(l,D)=>l.hidden?null:e.jsx("div",{title:l.tooltip,style:{padding:"2px 6px",fontSize:11,color:l.disabled?t.textMut:t.textSec,display:"flex",alignItems:"center",alignSelf:"center",userSelect:"none",opacity:l.disabled?.5:1},children:l.html?e.jsx("span",{dangerouslySetInnerHTML:{__html:l.html}}):l.value},D),I=(l,D)=>l.hidden?null:e.jsx("div",{style:{display:"flex",alignItems:"center",alignSelf:"center",padding:"0 4px"},dangerouslySetInnerHTML:{__html:l.html??""}},D),s=(l,D)=>l.hidden?null:l.type==="separator"||l.type==="sep"?e.jsx("div",{style:{width:1,background:t.border,margin:"4px 2px",alignSelf:"stretch"}},D):l.type==="spacer"?e.jsx("div",{style:{flex:1}},D):l.type==="title"?g(l,D):l.type==="customHTML"?I(l,D):l.type==="imageButton"?M(l,D):l.type==="input"?U(l,D):l.type==="selectButton"?H(l,D):A(l,D),x=(l,D,K)=>{var z;if(l.hidden)return null;const b=K||l.disabled;return e.jsx("div",{style:{display:"flex",flexDirection:l.direction==="col"?"column":"row",alignItems:l.direction==="col"?"flex-start":"center",gap:2,opacity:l.disabled&&!K?.55:1,pointerEvents:b?"none":void 0},children:(z=l.items)==null?void 0:z.map((L,w)=>L.type==="block"?x(L,`${D}-${w}`,b):s(L,`${D}-${w}`))},D)},_=(l,D)=>{var b;if(l.hidden)return null;const K=l.title||l.label;return e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"stretch",borderRight:`1px solid ${t.border}`,padding:"4px 6px 0",minWidth:40,opacity:l.disabled?.55:1,pointerEvents:l.disabled?"none":void 0},children:[e.jsx("div",{style:{display:"flex",flexDirection:l.direction==="col"?"column":"row",alignItems:l.direction==="col"?"stretch":"center",gap:2,flex:1},children:(b=l.items)==null?void 0:b.map((z,L)=>z.type==="block"?x(z,L,l.disabled):s(z,L))}),K&&e.jsx("div",{style:{fontSize:10,color:t.textMut,textAlign:"center",padding:"3px 0 4px",marginTop:2,borderTop:`1px solid ${t.border}`},children:K})]},D)},P=(l,D)=>l.type==="block"?_(l,D):s(l,D);return e.jsx("div",{ref:m,className:["dhx",n].filter(Boolean).join(" "),style:{display:"flex",alignItems:"stretch",background:t.surface,borderBottom:`1px solid ${t.border}`,overflowX:"auto",gap:0,minHeight:72,...i},children:r.map(P)})}function $e(r){return r==="primary"?t.primary:r==="success"?t.success:r==="secondary"?t.borderDk:t.danger}function At(r,n,d){if(!r&&!n)return d?{background:t.primaryLt,color:t.primary}:{};const i=r==="primary"?t.primary:r==="danger"?t.danger:r==="success"?t.success:t.borderDk;return n==="link"?{background:"transparent",color:i,border:"none",boxShadow:"none"}:n==="flat"?{background:i,color:"#fff",border:"none",boxShadow:"none"}:{color:i}}function Ee({count:r,bg:n}){return e.jsx("span",{style:{position:"absolute",top:3,right:3,minWidth:16,height:16,background:n??t.danger,color:"#fff",borderRadius:8,fontSize:10,fontWeight:700,display:"flex",alignItems:"center",justifyContent:"center",padding:"0 3px",lineHeight:1,pointerEvents:"none"},children:r})}function Ot({logo:r,items:n=[],vertical:d=!1,css:i,menuCss:h,onAction:a,onInputChange:u,onInputBlur:f,onInputFocus:y,style:S}){const[o,v]=p.useState(null),[T,$]=p.useState(()=>{const s={};return n.forEach(x=>{x.id&&(x.twoState||x.group)&&x.active&&(s[x.id]=!0)}),s}),[F,c]=p.useState(()=>{const s={};return n.forEach(x=>{x.type==="selectButton"&&x.id&&x.value&&(s[x.id]=x.value)}),s}),m=p.useRef(null);p.useEffect(ne,[]),ge(m,p.useCallback(()=>v(null),[]));const C=s=>{var x,_;if(!s.disabled){if(s.twoState&&s.id&&$(P=>({...P,[s.id]:!P[s.id]})),s.group&&s.id&&$(P=>{const l={...P};return n.forEach(D=>{D.group===s.group&&D.id&&(l[D.id]=!1)}),l[s.id]=!0,l}),(x=s.items)!=null&&x.length||s.type==="selectButton"){const P=s.id;v(l=>l===P?null:P);return}(_=s.onClick)==null||_.call(s,s.id||""),a==null||a(s.id||"")}},E=(s,x)=>e.jsx("span",{style:{fontSize:12,color:t.textSec,padding:"0 8px",fontWeight:500,whiteSpace:"nowrap",alignSelf:"center"},children:s.value??s.text},s.id??x),A=(s,x)=>e.jsx("div",{dangerouslySetInnerHTML:{__html:s.html??""}},s.id??x),M=(s,x)=>e.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center",margin:"0 4px",gap:4},children:[s.label&&e.jsx("span",{style:{fontSize:12,color:t.textSec,whiteSpace:"nowrap"},children:s.label}),e.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center"},children:[s.icon&&e.jsx("span",{style:{position:"absolute",left:8,color:t.textMut,fontSize:15,pointerEvents:"none",zIndex:1},children:s.icon}),e.jsx("input",{className:"dhx dhx-input",style:{width:s.width||200,height:28,paddingLeft:s.icon?30:void 0},placeholder:s.placeholder,defaultValue:s.value,onChange:_=>{var P;(P=s.onChange)==null||P.call(s,_.target.value),u==null||u(s.id||"",_.target.value)},onBlur:_=>{var P;(P=s.onBlur)==null||P.call(s,_.target.value),f==null||f(s.id||"",_.target.value)},onFocus:_=>{var P;(P=s.onFocus)==null||P.call(s,_.target.value),y==null||y(s.id||"",_.target.value)}})]})]},s.id??x),H=(s,x)=>e.jsxs("button",{title:s.tooltip,disabled:s.disabled,style:{position:"relative",width:36,height:36,padding:2,border:"none",borderRadius:"50%",overflow:"hidden",cursor:s.disabled?"not-allowed":"pointer",background:"transparent",flexShrink:0},onClick:()=>C(s),children:[s.src&&e.jsx("img",{src:s.src,alt:s.value||"",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}),s.count!==void 0&&e.jsx(Ee,{count:s.count,bg:$e(s.countColor)})]},s.id??x),U=(s,x)=>{var P;const _=o===s.id;return e.jsxs("div",{style:{position:"relative"},children:[e.jsxs("button",{className:"dhx dhx-btn dhx-btn-ghost",title:s.tooltip,disabled:s.disabled,style:{position:"relative",height:d?40:36,gap:4,cursor:s.disabled?"not-allowed":"pointer",...d?{width:"100%",justifyContent:"flex-start",padding:"0 16px",borderRadius:0}:{}},onClick:()=>C(s),children:[s.icon&&e.jsx("span",{style:{fontSize:16,flexShrink:0},children:s.icon}),e.jsx("span",{style:{fontSize:13},children:F[s.id]??s.value??s.text}),e.jsx("span",{style:{fontSize:9,opacity:.55},children:"▼"}),s.count!==void 0&&e.jsx(Ee,{count:s.count,bg:$e(s.countColor)})]}),_&&((P=s.items)==null?void 0:P.length)&&e.jsx(fe,{items:s.items,onSelect:l=>{var D;if(v(null),l.id!==void 0){const K=String(l.value??l.id);c(b=>({...b,[s.id]:K})),(D=s.onChange)==null||D.call(s,K),u==null||u(s.id,K)}},style:d?{left:"100%",top:0}:{top:"100%",left:0}})]},s.id??x)},g=(s,x)=>{var L;const _=!!(s.id&&(s.twoState||s.group)&&T[s.id]),P=!!((L=s.items)!=null&&L.length),l=!!s.circle,D=!!s.loading,K=At(s.color,s.view,_),b={position:"relative",height:d?40:36,gap:6,background:_?t.primaryLt:"transparent",color:_?t.primary:s.disabled?t.textMut:t.text,opacity:s.disabled?.55:1,cursor:s.disabled?"not-allowed":"pointer",...d?{width:"100%",justifyContent:"flex-start",padding:"0 16px",borderRadius:0}:{},...l?{borderRadius:"50%",width:36,height:36,padding:0,minWidth:0,justifyContent:"center"}:{},...K},z=s.value??s.text;return e.jsxs("div",{style:{position:"relative"},children:[e.jsxs("button",{className:"dhx dhx-btn dhx-btn-ghost",title:s.tooltip,disabled:s.disabled,style:b,onClick:()=>C(s),children:[D?e.jsx("span",{style:{fontSize:16,animation:"dhx-spin 1s linear infinite",display:"inline-block"},children:"⟳"}):s.icon&&e.jsx("span",{style:{fontSize:16,flexShrink:0},children:s.icon}),!l&&z&&e.jsx("span",{style:{fontSize:13},children:z}),!l&&s.hotkey&&e.jsx("span",{style:{fontSize:10,opacity:.45,marginLeft:4},children:s.hotkey}),P&&!l&&e.jsx("span",{style:{fontSize:9,opacity:.55,marginLeft:2},children:"▼"}),s.count!==void 0&&e.jsx(Ee,{count:s.count,bg:$e(s.countColor)})]}),P&&o===s.id&&e.jsx(fe,{items:s.items,onSelect:w=>{var O;v(null),w.id&&((O=s.onClick)==null||O.call(s,w.id),a==null||a(w.id))},style:d?{left:"100%",top:0}:{top:"100%"}})]},s.id??x)},I=(s,x)=>s.hidden?null:s.type==="separator"?e.jsx("div",{style:{[d?"height":"width"]:1,background:t.border,margin:d?"4px 8px":"0 6px",alignSelf:"stretch"}},s.id??x):s.type==="spacer"?e.jsx("div",{style:{flex:1}},s.id??x):s.type==="title"?E(s,x):s.type==="customHTML"?A(s,x):s.type==="input"?M(s,x):s.type==="selectButton"?U(s,x):s.type==="imageButton"?H(s,x):g(s,x);return e.jsxs("nav",{ref:m,className:["dhx",i].filter(Boolean).join(" "),style:{display:"flex",flexDirection:d?"column":"row",alignItems:d?"stretch":"center",background:t.surface,borderBottom:d?"none":`1px solid ${t.border}`,borderRight:d?`1px solid ${t.border}`:"none",padding:d?"8px 0":"0 12px",minHeight:d?void 0:48,gap:2,...S},children:[r&&e.jsx("div",{style:{color:t.text,fontWeight:800,fontSize:16,padding:d?"8px 16px 12px":"0 12px 0 4px",borderBottom:d?`1px solid ${t.border}`:"none",borderRight:d?"none":`1px solid ${t.border}`,marginRight:d?0:8,marginBottom:d?4:0,flexShrink:0},children:r}),n.map(I)]})}const Pt=["undo","redo","separator","style","font-family","font-size","separator","bold","italic","underline","strike","separator","subscript","superscript","separator","text-color","background-color","separator","align","indent","outdent","line-height","separator","quote","bulleted-list","numbered-list","separator","link","image","line","separator","clear","print","fullscreen","mode","shortcuts"],Kt=["Arial","Georgia","Times New Roman","Courier New","Verdana","Trebuchet MS","Impact","Comic Sans MS"],_t=["8","10","12","14","16","18","20","24","28","32","36","48","72"],Yt=["1","1.15","1.5","2","2.5","3"],Ye=[{value:"p",label:"Normal"},{value:"h1",label:"Heading 1"},{value:"h2",label:"Heading 2"},{value:"h3",label:"Heading 3"},{value:"h4",label:"Heading 4"},{value:"h5",label:"Heading 5"},{value:"h6",label:"Heading 6"},{value:"blockquote",label:"Quote"}],qt=["#000000","#434343","#666666","#999999","#b7b7b7","#cccccc","#d9d9d9","#ffffff","#ff0000","#ff9900","#ffff00","#00ff00","#00ffff","#0000ff","#9900ff","#ff00ff","#f4cccc","#fce5cd","#fff2cc","#d9ead3","#d0e0e3","#c9daf8","#d9d2e9","#ead1dc","#ea9999","#f9cb9c","#ffe599","#b6d7a8","#a2c4c9","#a4c2f4","#b4a7d6","#d5a6bd","#e06666","#f6b26b","#ffd966","#93c47d","#76a5af","#6d9eeb","#8e7cc3","#c27ba0","#cc0000","#e69138","#f1c232","#6aa84f","#45818e","#3c78d8","#674ea7","#a64d79","#990000","#b45f06","#bf9000","#38761d","#134f5c","#1155cc","#351c75","#741b47","#660000","#783f04","#7f6000","#274e13","#0c343d","#1c4587","#20124d","#4c1130"],Ut=[{key:"Ctrl+B",desc:"Bold"},{key:"Ctrl+I",desc:"Italic"},{key:"Ctrl+U",desc:"Underline"},{key:"Ctrl+Z",desc:"Undo"},{key:"Ctrl+Y",desc:"Redo"},{key:"Ctrl+A",desc:"Select All"},{key:"Ctrl+C",desc:"Copy"},{key:"Ctrl+X",desc:"Cut"},{key:"Ctrl+V",desc:"Paste"},{key:"Tab",desc:"Indent"},{key:"Shift+Tab",desc:"Outdent"}],le=({d:r,w:n=14})=>e.jsx("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"currentColor",style:{flexShrink:0},children:e.jsx("path",{d:r})}),te={undo:"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z",redo:"M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 15.7c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 15.5h9v-9l-3.6 3.1z",indent:"M3 21h18v-2H3v2zM3 8v8l4-4-4-4zm8 9h10v-2H11v2zM3 3v2h18V3H3zm8 6h10V7H11v2zm0 4h10v-2H11v2z",outdent:"M11 17h10v-2H11v2zM3 12l4 4V8l-4 4zM3 3v2h18V3H3zm8 6h10V7H11v2zm0 4h10v-2H11v2zm0 6h10v-2H11v2z",lh:"M6 7h2.5L5 3.5 1.5 7H4v10H1.5L5 20.5 8.5 17H6V7zm4 1v2h12V8H10zm0 6v2h12v-2H10z",ulist:"M4 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-6c-.83 0-1.5.67-1.5 1.5S3.17 7.5 4 7.5 5.5 6.83 5.5 6 4.83 4.5 4 4.5zm0 12c-.83 0-1.5.68-1.5 1.5s.68 1.5 1.5 1.5 1.5-.68 1.5-1.5-.67-1.5-1.5-1.5zM7 19h14v-2H7v2zm0-6h14v-2H7v2zm0-8v2h14V5H7z",olist:"M2 17h2v.5H3v1h1v.5H2v1h3v-4H2v1zm1-9h1V4H2v1h1v3zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2v1zm5-6v2h14V5H7zm0 14h14v-2H7v2zm0-6h14v-2H7v2z",link:"M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z",image:"M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z",line:"M19 13H5v-2h14v2z",clear:"M3.27 5L2 6.27l6.97 6.97L6.5 19h3l1.57-3.66L16.73 21 18 19.73 3.27 5zm15.73-2H9.15L11 5h6l-1.72 4-1.03-1.03L15.5 5h1.28L19 5V3zm0 9.99L16.28 10H19v2.99z",print:"M19 8H5c-1.66 0-3 1.34-3 3v6h4v4h12v-4h4v-6c0-1.66-1.34-3-3-3zm-3 11H8v-5h8v5zm3-7c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-1-9H6v4h12V3z",fullsc:"M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z",exitfs:"M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z",mode:"M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 16H8v-2h8v2zm0-4H8v-2h8v2zm-3-5V3.5L18.5 9H13z",shortcuts:"M20 5H4c-1.1 0-1.99.9-1.99 2L2 17c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm-9 3h2v2h-2V8zm0 3h2v2h-2v-2zM8 8h2v2H8V8zm0 3h2v2H8v-2zm-1 5H5v-2h2v2zm0-3H5v-2h2v2zm0-3H5V8h2v2zm9 6h-6v-2h6v2zm0-3h-2v-2h2v2zm0-3h-2V8h2v2zm3 6h-2v-2h2v2zm0-3h-2v-2h2v2zm0-3h-2V8h2v2z",quote:"M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z",alL:"M15 15H3v2h12v-2zm0-8H3v2h12V7zM3 13h18v-2H3v2zm0 8h18v-2H3v2zM3 3v2h18V3H3z",alC:"M7 15v2h10v-2H7zm-4 6h18v-2H3v2zm0-8h18v-2H3v2zm4-6v2h10V7H7zM3 3v2h18V3H3z",alR:"M3 21h18v-2H3v2zm6-4h12v-2H9v2zm-6-4h18v-2H3v2zm6-4h12V7H9v2zM3 3v2h18V3H3z",alJ:"M3 21h18v-2H3v2zm0-4h18v-2H3v2zm0-4h18v-2H3v2zm0-4h18V7H3v2zm0-6v2h18V3H3z",paint:"M16.56 8.94L7.62 0 6.21 1.41l2.38 2.38-5.15 5.15c-.59.56-.59 1.53 0 2.12l5.5 5.5c.29.29.68.44 1.06.44s.77-.15 1.06-.44l5.5-5.5c.59-.59.59-1.56 0-2.12zM5.21 10L10 5.21 14.79 10H5.21zM19 11.5s-2 2.17-2 3.5c0 1.1.9 2 2 2s2-.9 2-2c0-1.33-2-3.5-2-3.5z",chevron:"M7 10l5 5 5-5z"};function oe({active:r,disabled:n,title:d,onClick:i,children:h}){const[a,u]=p.useState(!1);return e.jsx("button",{title:d,disabled:n,onMouseDown:f=>f.preventDefault(),onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),onClick:i,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:2,padding:"0 6px",height:28,minWidth:28,border:"none",borderRadius:t.r,flexShrink:0,background:r?t.primaryLt:a?t.border:"transparent",color:r?t.primary:n?t.textMut:t.text,cursor:n?"default":"pointer",fontSize:12,fontFamily:t.font,outline:"none",transition:"background .1s"},children:h})}function Xt(){return e.jsx("div",{style:{width:1,height:20,background:t.border,margin:"0 2px",flexShrink:0}})}function Se({label:r,title:n,open:d,onToggle:i,children:h,width:a=160}){const[u,f]=p.useState(!1);return e.jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[e.jsxs("button",{title:n,onMouseDown:y=>y.preventDefault(),onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),onClick:i,style:{display:"inline-flex",alignItems:"center",gap:2,padding:"0 6px",height:28,border:"none",borderRadius:t.r,flexShrink:0,background:d?t.primaryLt:u?t.border:"transparent",color:d?t.primary:t.text,cursor:"pointer",fontSize:12,fontFamily:t.font,outline:"none",whiteSpace:"nowrap",transition:"background .1s"},children:[r,e.jsx(le,{d:te.chevron,w:12})]}),d&&e.jsx("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,zIndex:100,background:t.surface,border:`1px solid ${t.border}`,borderRadius:t.r,boxShadow:t.shadowLg,width:a,maxHeight:240,overflowY:"auto"},children:h})]})}function ke({onClick:r,active:n,children:d}){const[i,h]=p.useState(!1);return e.jsx("div",{onMouseDown:a=>a.preventDefault(),onClick:r,onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),style:{padding:"6px 10px",cursor:"pointer",fontSize:12,color:n?t.primary:t.text,fontWeight:n?600:400,background:n?t.primaryLt:i?t.bg:t.surface},children:d})}function qe({onSelect:r,onClose:n}){return e.jsx("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,zIndex:200,background:t.surface,border:`1px solid ${t.border}`,borderRadius:t.r,boxShadow:t.shadowLg,padding:6},children:e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(8, 20px)",gap:2},children:qt.map(d=>e.jsx("button",{title:d,onMouseDown:i=>i.preventDefault(),onClick:()=>{r(d),n()},style:{width:20,height:20,background:d,padding:0,border:`1px solid ${t.border}`,borderRadius:2,cursor:"pointer"}},d))})})}function Ue({title:r,placeholder:n,onConfirm:d,onClose:i}){const[h,a]=p.useState(""),u=p.useRef(null);p.useEffect(()=>{var y;return(y=u.current)==null?void 0:y.focus()},[]);const f=()=>{h.trim()&&d(h.trim()),i()};return e.jsx("div",{style:{position:"fixed",inset:0,zIndex:500,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,.35)"},onMouseDown:y=>{y.target===y.currentTarget&&i()},children:e.jsxs("div",{style:{background:t.surface,border:`1px solid ${t.border}`,borderRadius:t.rMd,boxShadow:t.shadowLg,padding:24,minWidth:340},children:[e.jsx("div",{style:{fontSize:15,fontWeight:600,color:t.text,marginBottom:14},children:r}),e.jsx("input",{ref:u,value:h,placeholder:n,onChange:y=>a(y.target.value),onKeyDown:y=>{y.key==="Enter"&&f(),y.key==="Escape"&&i()},style:{width:"100%",padding:"7px 10px",boxSizing:"border-box",border:`1px solid ${t.border}`,borderRadius:t.r,fontSize:13,color:t.text,fontFamily:t.font,outline:`2px solid ${t.primary}`}}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:14},children:[e.jsx("button",{onClick:i,style:{padding:"6px 16px",border:`1px solid ${t.border}`,borderRadius:t.r,background:t.surface,color:t.text,cursor:"pointer",fontSize:13,fontFamily:t.font},children:"Cancel"}),e.jsx("button",{onClick:f,style:{padding:"6px 16px",border:"none",borderRadius:t.r,background:t.primary,color:"#fff",cursor:"pointer",fontSize:13,fontFamily:t.font},children:"OK"})]})]})})}function Gt({onClose:r}){return e.jsx("div",{style:{position:"fixed",inset:0,zIndex:500,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,.35)"},onMouseDown:n=>{n.target===n.currentTarget&&r()},children:e.jsxs("div",{style:{background:t.surface,border:`1px solid ${t.border}`,borderRadius:t.rMd,boxShadow:t.shadowLg,padding:24,minWidth:340,maxWidth:420},children:[e.jsx("div",{style:{fontSize:15,fontWeight:600,color:t.text,marginBottom:16},children:"Keyboard Shortcuts"}),e.jsx("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:e.jsx("tbody",{children:Ut.map(n=>e.jsxs("tr",{style:{borderBottom:`1px solid ${t.border}`},children:[e.jsx("td",{style:{padding:"6px 0",color:t.text},children:n.desc}),e.jsx("td",{style:{padding:"6px 0",textAlign:"right"},children:e.jsx("kbd",{style:{background:t.bg,border:`1px solid ${t.borderDk}`,borderRadius:t.r,padding:"1px 7px",fontSize:11,fontFamily:"monospace",color:t.textSec},children:n.key})})]},n.key))})}),e.jsx("button",{onClick:r,style:{marginTop:16,width:"100%",padding:8,border:"none",borderRadius:t.r,background:t.primary,color:"#fff",cursor:"pointer",fontSize:13,fontFamily:t.font},children:"Close"})]})})}function Jt(){var d,i;const r=(d=window.getSelection)==null?void 0:d.call(window);if(!r)return"Normal";let n=r.focusNode;for(;n;){const h=(i=n.tagName)==null?void 0:i.toLowerCase();if(h){const a=Ye.find(u=>u.value===h);if(a)return a.label}n=n.parentNode}return"Normal"}const Xe=p.forwardRef(function({value:n="",toolbar:d=!0,fullscreenMode:i=!1,layoutMode:h="classic",onChange:a,style:u,className:f},y){const S=p.useRef(null),o=p.useRef(a);o.current=a;const[v,T]=p.useState(i),[$,F]=p.useState(h??"classic"),[c,m]=p.useState(null),[C,E]=p.useState({}),[A,M]=p.useState("Normal"),[H,U]=p.useState("#000000"),[g,I]=p.useState("#ffff00"),[s,x]=p.useState(!1),[_,P]=p.useState(!1),[l,D]=p.useState(!1),K=d===!1?[]:d===!0||d===void 0?Pt:d;p.useEffect(()=>{S.current&&(S.current.innerHTML=n)},[]),p.useEffect(()=>{!S.current||n===void 0||S.current.innerHTML!==n&&(S.current.innerHTML=n)},[n]),p.useEffect(()=>{const B=()=>{try{E({bold:document.queryCommandState("bold"),italic:document.queryCommandState("italic"),underline:document.queryCommandState("underline"),strikeThrough:document.queryCommandState("strikeThrough"),subscript:document.queryCommandState("subscript"),superscript:document.queryCommandState("superscript"),justifyLeft:document.queryCommandState("justifyLeft"),justifyCenter:document.queryCommandState("justifyCenter"),justifyRight:document.queryCommandState("justifyRight"),justifyFull:document.queryCommandState("justifyFull"),insertOrderedList:document.queryCommandState("insertOrderedList"),insertUnorderedList:document.queryCommandState("insertUnorderedList")}),M(Jt())}catch{}};return document.addEventListener("selectionchange",B),()=>document.removeEventListener("selectionchange",B)},[]),p.useEffect(()=>{if(!c)return;const B=()=>m(null),N=setTimeout(()=>document.addEventListener("mousedown",B),0);return()=>{clearTimeout(N),document.removeEventListener("mousedown",B)}},[c]);const b=p.useCallback((B,N)=>{var Z,j;(Z=S.current)==null||Z.focus(),document.execCommand(B,!1,N),S.current&&((j=o.current)==null||j.call(o,S.current.innerHTML))},[]),z=p.useCallback(B=>{var N,Z,j;(N=S.current)==null||N.focus(),document.execCommand("styleWithCSS",!1,"true"),document.execCommand("fontSize",!1,"3"),(Z=S.current)==null||Z.querySelectorAll('font[size="3"]').forEach(de=>{var ye;const pe=document.createElement("span");pe.style.fontSize=`${B}px`,pe.innerHTML=de.innerHTML,(ye=de.parentNode)==null||ye.replaceChild(pe,de)}),S.current&&((j=o.current)==null||j.call(o,S.current.innerHTML)),document.execCommand("styleWithCSS",!1,"false")},[]),L=p.useCallback(B=>{var N,Z;(N=S.current)==null||N.focus(),document.execCommand("formatBlock",!1,B),S.current&&((Z=o.current)==null||Z.call(o,S.current.innerHTML))},[]),w=p.useCallback(B=>{var j,de;(j=S.current)==null||j.focus();const N=window.getSelection();if(!N||N.rangeCount===0)return;let Z=N.getRangeAt(0).startContainer;for(;Z&&Z!==S.current;){if(Z.style){Z.style.lineHeight=B;break}Z=Z.parentNode}S.current&&((de=o.current)==null||de.call(o,S.current.innerHTML))},[]),O=p.useCallback(B=>{const N=/^https?:\/\//i.test(B)?B:`https://${B}`;b("createLink",N)},[b]),X=p.useCallback(B=>{b("insertImage",B)},[b]);p.useImperativeHandle(y,()=>({getValue:()=>{var B;return((B=S.current)==null?void 0:B.innerHTML)??""},setValue:B=>{S.current&&(S.current.innerHTML=B)},focus:()=>{var B;return(B=S.current)==null?void 0:B.focus()}}),[]);const ee=p.useCallback(B=>{B.key==="Tab"&&(B.preventDefault(),B.shiftKey?b("outdent"):b("indent"))},[b]),J=p.useCallback(()=>{var B;S.current&&((B=o.current)==null||B.call(o,S.current.innerHTML))},[]),Q=(B,N)=>{if(typeof B=="object")return e.jsx(oe,{title:B.tooltip,onClick:()=>{var j;return(j=B.handler)==null?void 0:j.call(B)},children:B.icon??B.label??"?"},B.id??N);const Z=j=>m(de=>de===j?null:j);switch(B){case"separator":return e.jsx(Xt,{},N);case"undo":return e.jsx(oe,{title:"Undo (Ctrl+Z)",onClick:()=>b("undo"),children:e.jsx(le,{d:te.undo})},"undo");case"redo":return e.jsx(oe,{title:"Redo (Ctrl+Y)",onClick:()=>b("redo"),children:e.jsx(le,{d:te.redo})},"redo");case"bold":return e.jsx(oe,{title:"Bold (Ctrl+B)",active:C.bold,onClick:()=>b("bold"),children:e.jsx("b",{style:{fontSize:13,fontFamily:"serif",fontStyle:"normal"},children:"B"})},"bold");case"italic":return e.jsx(oe,{title:"Italic (Ctrl+I)",active:C.italic,onClick:()=>b("italic"),children:e.jsx("i",{style:{fontSize:13,fontFamily:"serif"},children:"I"})},"ital");case"underline":return e.jsx(oe,{title:"Underline (Ctrl+U)",active:C.underline,onClick:()=>b("underline"),children:e.jsx("u",{style:{fontSize:13,fontFamily:"serif",textDecorationThickness:1},children:"U"})},"ul");case"strike":return e.jsx(oe,{title:"Strikethrough",active:C.strikeThrough,onClick:()=>b("strikeThrough"),children:e.jsx("s",{style:{fontSize:13,fontFamily:"serif"},children:"S"})},"st");case"subscript":return e.jsx(oe,{title:"Subscript",active:C.subscript,onClick:()=>b("subscript"),children:e.jsxs("span",{style:{fontSize:12},children:["x",e.jsx("sub",{style:{fontSize:9},children:"2"})]})},"sub");case"superscript":return e.jsx(oe,{title:"Superscript",active:C.superscript,onClick:()=>b("superscript"),children:e.jsxs("span",{style:{fontSize:12},children:["x",e.jsx("sup",{style:{fontSize:9},children:"2"})]})},"sup");case"text-color":return e.jsxs("div",{style:{position:"relative"},children:[e.jsx(oe,{title:"Text Color",active:c==="tc",onClick:()=>Z("tc"),children:e.jsxs("span",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:1},children:[e.jsx("span",{style:{fontSize:13,fontWeight:700,fontFamily:"serif",lineHeight:1},children:"A"}),e.jsx("span",{style:{width:14,height:3,background:H,borderRadius:1}})]})}),c==="tc"&&e.jsx(qe,{onSelect:j=>{U(j),b("foreColor",j)},onClose:()=>m(null)})]},"tc");case"background-color":return e.jsxs("div",{style:{position:"relative"},children:[e.jsx(oe,{title:"Background Color",active:c==="bc",onClick:()=>Z("bc"),children:e.jsxs("span",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:1},children:[e.jsx(le,{d:te.paint}),e.jsx("span",{style:{width:14,height:3,background:g,borderRadius:1}})]})}),c==="bc"&&e.jsx(qe,{onSelect:j=>{I(j),b("styleWithCSS","true"),b("hiliteColor",j),b("styleWithCSS","false")},onClose:()=>m(null)})]},"bc");case"style":return e.jsx(Se,{label:A,title:"Block Style",width:160,open:c==="sty",onToggle:()=>Z("sty"),children:Ye.map(j=>e.jsx(ke,{onClick:()=>{L(j.value),m(null)},children:j.value==="h1"?e.jsx("span",{style:{fontWeight:700,fontSize:16},children:j.label}):j.value==="h2"?e.jsx("span",{style:{fontWeight:700,fontSize:15},children:j.label}):j.value==="h3"?e.jsx("span",{style:{fontWeight:700,fontSize:14},children:j.label}):j.value.startsWith("h")?e.jsx("span",{style:{fontWeight:700},children:j.label}):j.value==="blockquote"?e.jsx("span",{style:{borderLeft:`3px solid ${t.border}`,paddingLeft:6,fontStyle:"italic",color:t.textSec},children:j.label}):j.label},j.value))},"sty");case"font-family":return e.jsx(Se,{label:"Font",title:"Font Family",width:180,open:c==="ff",onToggle:()=>Z("ff"),children:Kt.map(j=>e.jsx(ke,{onClick:()=>{b("fontName",j),m(null)},children:e.jsx("span",{style:{fontFamily:j},children:j})},j))},"ff");case"font-size":return e.jsx(Se,{label:"Size",title:"Font Size",width:90,open:c==="fs",onToggle:()=>Z("fs"),children:_t.map(j=>e.jsx(ke,{onClick:()=>{z(j),m(null)},children:e.jsxs("span",{style:{fontSize:Math.min(Number(j),18)},children:[j,"px"]})},j))},"fs");case"align":return e.jsx(Se,{label:C.justifyCenter?e.jsx(le,{d:te.alC}):C.justifyRight?e.jsx(le,{d:te.alR}):C.justifyFull?e.jsx(le,{d:te.alJ}):e.jsx(le,{d:te.alL}),title:"Text Alignment",width:130,open:c==="al",onToggle:()=>Z("al"),children:[{cmd:"justifyLeft",label:"Left",icon:te.alL},{cmd:"justifyCenter",label:"Center",icon:te.alC},{cmd:"justifyRight",label:"Right",icon:te.alR},{cmd:"justifyFull",label:"Justify",icon:te.alJ}].map(j=>e.jsx(ke,{active:!!C[j.cmd],onClick:()=>{b(j.cmd),m(null)},children:e.jsxs("span",{style:{display:"flex",gap:7,alignItems:"center"},children:[e.jsx(le,{d:j.icon}),j.label]})},j.cmd))},"al");case"line-height":return e.jsx(Se,{label:e.jsx(le,{d:te.lh}),title:"Line Height",width:80,open:c==="lh",onToggle:()=>Z("lh"),children:Yt.map(j=>e.jsxs(ke,{onClick:()=>{w(j),m(null)},children:[j,"×"]},j))},"lh");case"indent":return e.jsx(oe,{title:"Indent",onClick:()=>b("indent"),children:e.jsx(le,{d:te.indent})},"in");case"outdent":return e.jsx(oe,{title:"Outdent",onClick:()=>b("outdent"),children:e.jsx(le,{d:te.outdent})},"out");case"quote":return e.jsx(oe,{title:"Blockquote",onClick:()=>L("blockquote"),children:e.jsx(le,{d:te.quote})},"qt");case"bulleted-list":return e.jsx(oe,{title:"Bulleted List",active:C.insertUnorderedList,onClick:()=>b("insertUnorderedList"),children:e.jsx(le,{d:te.ulist})},"bl");case"numbered-list":return e.jsx(oe,{title:"Numbered List",active:C.insertOrderedList,onClick:()=>b("insertOrderedList"),children:e.jsx(le,{d:te.olist})},"nl");case"link":return e.jsx(oe,{title:"Insert Link",onClick:()=>x(!0),children:e.jsx(le,{d:te.link})},"lk");case"image":return e.jsx(oe,{title:"Insert Image",onClick:()=>P(!0),children:e.jsx(le,{d:te.image})},"img");case"line":return e.jsx(oe,{title:"Horizontal Line",onClick:()=>b("insertHorizontalRule"),children:e.jsx(le,{d:te.line})},"hr");case"clear":return e.jsx(oe,{title:"Clear Formatting",onClick:()=>b("removeFormat"),children:e.jsx(le,{d:te.clear})},"cl");case"print":return e.jsx(oe,{title:"Print",onClick:()=>window.print(),children:e.jsx(le,{d:te.print})},"pr");case"fullscreen":return e.jsx(oe,{title:v?"Exit Fullscreen":"Fullscreen",active:v,onClick:()=>T(j=>!j),children:e.jsx(le,{d:v?te.exitfs:te.fullsc})},"fs2");case"mode":return e.jsx(oe,{title:$==="document"?"Classic Mode":"Document Mode",active:$==="document",onClick:()=>F(j=>j==="document"?"classic":"document"),children:e.jsx(le,{d:te.mode})},"md");case"shortcuts":return e.jsx(oe,{title:"Keyboard Shortcuts",onClick:()=>D(!0),children:e.jsx(le,{d:te.shortcuts})},"sc");default:return null}},se=v?{position:"fixed",inset:0,zIndex:1e3,display:"flex",flexDirection:"column",border:"none",borderRadius:0,background:t.surface,fontFamily:t.font,color:t.text}:{display:"flex",flexDirection:"column",border:`1px solid ${t.border}`,borderRadius:t.r,overflow:"hidden",background:t.surface,fontFamily:t.font,color:t.text,height:500,...u},ie={flex:1,overflow:"auto",background:$==="document"?"#e0e0e0":t.surface},ue=$==="document"?{maxWidth:794,margin:"24px auto",background:t.surface,boxShadow:t.shadowLg,padding:"60px 72px",boxSizing:"border-box",minHeight:"calc(100% - 48px)"}:{padding:"14px 18px",minHeight:"100%"};return e.jsxs("div",{className:v?void 0:f,style:void 0,children:[e.jsxs("div",{className:v?f:void 0,style:se,children:[K.length>0&&e.jsx("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:1,padding:"3px 6px",borderBottom:`1px solid ${t.border}`,background:t.bg,flexShrink:0},children:K.map((B,N)=>Q(B,N))}),e.jsx("div",{style:ie,children:e.jsx("div",{style:ue,children:e.jsx("div",{ref:S,contentEditable:!0,suppressContentEditableWarning:!0,onInput:J,onKeyDown:ee,style:{outline:"none",minHeight:200,fontSize:14,lineHeight:1.6,color:t.text,wordBreak:"break-word"}})})})]}),s&&e.jsx(Ue,{title:"Insert Link",placeholder:"https://example.com",onConfirm:O,onClose:()=>x(!1)}),_&&e.jsx(Ue,{title:"Insert Image",placeholder:"https://example.com/image.png",onConfirm:X,onClose:()=>P(!1)}),l&&e.jsx(Gt,{onClose:()=>D(!1)})]})});Xe.displayName="Richtext",G.Button=tt,G.Calendar=kt,G.Chart=bt,G.Colorpicker=mt,G.Combobox=me,G.ContextMenu=nt,G.DataView=$t,G.Form=Bt,G.Grid=yt,G.Layout=Ve,G.List=Dt,G.Menu=rt,G.MenuDropdown=fe,G.MessageContext=Le,G.MessageProvider=Tt,G.Navbar=Ot,G.Pagination=Wt,G.Popup=Ct,G.Ribbon=jt,G.Richtext=Xe,G.Sidebar=dt,G.Slider=Ce,G.Tabbar=ct,G.Timepicker=je,G.Toolbar=ot,G.Tree=Nt,G.Window=Mt,G.tokens=t,G.useClickOutside=ge,G.useDrag=Be,G.useMessage=Ht,Object.defineProperty(G,Symbol.toStringTag,{value:"Module"})});