@thebuoyant-tsdev/mui-ts-library 3.33.0 → 3.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`@dnd-kit/core`),l=require(`@dnd-kit/sortable`),u=require(`@mui/material`),d=require(`react`),f=require(`@dnd-kit/utilities`),p=require(`@mui/icons-material/CalendarToday`);p=s(p,1);let m=require(`@mui/icons-material/Person`);m=s(m,1);let h=require(`@mui/material/styles`),g=require(`react/jsx-runtime`),_=require(`@mui/icons-material/Delete`);_=s(_,1);let v=require(`@mui/icons-material/Add`);v=s(v,1);let y=require(`@mui/icons-material/Colorize`);y=s(y,1);let b=require(`@codemirror/view`),x=require(`@codemirror/state`),S=require(`@codemirror/lang-json`),C=require(`@codemirror/commands`),w=require(`@codemirror/language`),T=require(`@codemirror/lint`),E=require(`@lezer/highlight`),D=require(`@replit/codemirror-minimap`),O=require(`@mui/icons-material/ContentCopy`);O=s(O,1);let k=require(`@mui/icons-material/Download`);k=s(k,1);let A=require(`@mui/icons-material/Check`);A=s(A,1);let j=require(`@mui/icons-material/Undo`);j=s(j,1);let M=require(`@mui/icons-material/Redo`);M=s(M,1);let N=require(`@mui/icons-material/AutoFixHigh`);N=s(N,1);let P=require(`@mui/icons-material/Compress`);P=s(P,1);let F=require(`@mui/icons-material/CheckCircleOutlined`);F=s(F,1);let I=require(`@mui/icons-material/ErrorOutlined`);I=s(I,1);let L=require(`zustand`),R=require(`zustand/vanilla`),z=require(`@tanstack/react-virtual`),B=require(`@mui/icons-material/Edit`);B=s(B,1);let V=require(`@mui/icons-material/RestartAlt`);V=s(V,1);let H=require(`@mui/icons-material/Restore`);H=s(H,1);let U=require(`@mui/icons-material/Today`);U=s(U,1);let W=require(`@mui/icons-material/UnfoldLess`);W=s(W,1);let G=require(`@mui/icons-material/UnfoldMore`);G=s(G,1);let K=require(`@mui/icons-material/CheckCircle`);K=s(K,1);let q=require(`@mui/icons-material/Cancel`);q=s(q,1);let J=require(`@mui/icons-material/Visibility`);J=s(J,1);let ee=require(`@mui/icons-material/VisibilityOff`);ee=s(ee,1);let te=require(`@mui/icons-material/Close`);te=s(te,1);let Y=require(`@tiptap/react`),X=require(`@tiptap/extension-mention`),ne=require(`@tiptap/starter-kit`),re=require(`@tiptap/extension-text-style`),ie=require(`@tiptap/extension-color`),ae=require(`@tiptap/extension-highlight`),oe=require(`@tiptap/extension-placeholder`),se=require(`@tiptap/extension-character-count`),ce=require(`@tiptap/extension-table`),le=require(`@tiptap/extension-image`),ue=require(`tiptap-markdown`),de=require(`@mui/icons-material/Fullscreen`);de=s(de,1);let fe=require(`@mui/icons-material/FullscreenExit`);fe=s(fe,1);let pe=require(`@mui/icons-material/Image`);pe=s(pe,1);let me=require(`@mui/icons-material/EmojiEmotions`);me=s(me,1);let he=require(`@mui/icons-material/FormatBold`);he=s(he,1);let ge=require(`@mui/icons-material/FormatItalic`);ge=s(ge,1);let _e=require(`@mui/icons-material/FormatUnderlined`);_e=s(_e,1);let ve=require(`@mui/icons-material/StrikethroughS`);ve=s(ve,1);let ye=require(`@mui/icons-material/FormatListBulleted`);ye=s(ye,1);let be=require(`@mui/icons-material/FormatListNumbered`);be=s(be,1);let xe=require(`@mui/icons-material/FormatQuote`);xe=s(xe,1);let Se=require(`@mui/icons-material/Code`);Se=s(Se,1);let Ce=require(`@mui/icons-material/InsertLink`);Ce=s(Ce,1);let we=require(`@mui/icons-material/HorizontalRule`);we=s(we,1);let Te=require(`@mui/icons-material/FormatColorText`);Te=s(Te,1);let Ee=require(`@mui/icons-material/BorderColor`);Ee=s(Ee,1);let De=require(`@mui/icons-material/FormatClear`);De=s(De,1);let Oe=require(`@mui/icons-material/ContentPaste`);Oe=s(Oe,1);let ke=require(`@mui/icons-material/ContentPasteOff`);ke=s(ke,1);let Ae=require(`@mui/icons-material/FormatColorReset`);Ae=s(Ae,1);let je=require(`@mui/icons-material/TableChart`);je=s(je,1);let Me=require(`@mui/icons-material/Search`);Me=s(Me,1);let Ne=require(`sql-formatter`),Pe=require(`@codemirror/lang-sql`),Fe=require(`@codemirror/autocomplete`),Ie=require(`@mui/icons-material/PlayArrow`);Ie=s(Ie,1);let Le=require(`@mui/icons-material/History`);Le=s(Le,1);let Re=require(`@mui/icons-material/DeleteSweep`);Re=s(Re,1);let ze=require(`@mui/icons-material/WarningAmber`);ze=s(ze,1);let Z=require(`d3`);Z=s(Z,1);var Be={disabled:`MuiTs-disabled`,selected:`MuiTs-selected`,focused:`MuiTs-focused`,error:`MuiTs-error`},Ve={root:`MuiTsKanbanBoard-root`,columns:`MuiTsKanbanBoard-columns`,column:`MuiTsKanbanBoard-column`,columnHeader:`MuiTsKanbanBoard-columnHeader`,columnTitle:`MuiTsKanbanBoard-columnTitle`,columnCount:`MuiTsKanbanBoard-columnCount`,columnBody:`MuiTsKanbanBoard-columnBody`,card:`MuiTsKanbanBoard-card`,cardTitle:`MuiTsKanbanBoard-cardTitle`,cardMeta:`MuiTsKanbanBoard-cardMeta`,cardAssignee:`MuiTsKanbanBoard-cardAssignee`,cardDueDate:`MuiTsKanbanBoard-cardDueDate`,cardPriorityDot:`MuiTsKanbanBoard-cardPriorityDot`,addButton:`MuiTsKanbanBoard-addButton`},He={addCardLabel:`Add card`,dialogAddTitle:`Add card`,dialogEditTitle:`Edit card`,dialogDeleteTitle:`Delete card`,dialogSave:`Save`,dialogCancel:`Cancel`,dialogDelete:`Delete`,dialogDeleteConfirm:`Delete "{title}"?`,dialogFieldTitle:`Title`,dialogFieldDescription:`Description`,dialogFieldAssignee:`Assignee`,dialogFieldDueDate:`Due date`,dialogFieldStatus:`Status`,noCardsLabel:`No cards`},Ue={low:`#4caf50`,medium:`#ff9800`,high:`#f44336`,critical:`#9c27b0`},We={fontSize:`0.7rem`,height:22,"& .MuiChip-icon":{fontSize:`0.75rem`,width:`0.75rem`,height:`0.75rem`,ml:`8px`,mr:`4px`},"& .MuiChip-label":{pl:`2px`,pr:`10px`}};function Ge({task:e,showPriority:t,showAssignee:n,showDueDate:r,showDueDateWarning:i,chipVariant:a,t:o,onCardClick:s,isOverlay:c=!1}){let{attributes:d,listeners:_,setNodeRef:v,transform:y,transition:b,isDragging:x}=(0,l.useSortable)({id:e.id,disabled:c}),S=c?void 0:{transform:f.CSS.Transform.toString(y),transition:b,opacity:+!x},C=n&&!!e.assignee||r&&!!e.dueDate,w=e.dueDate?e.dueDate.toLocaleDateString(void 0,{day:`2-digit`,month:`short`,year:`numeric`}):null,T=new Date;T.setHours(0,0,0,0);let E=i&&!!e.dueDate&&e.dueDate<T;return(0,g.jsx)(u.Card,{ref:c?void 0:v,style:S,elevation:0,className:[Ve.card,x&&Be.selected].filter(Boolean).join(` `),sx:{mb:1,border:`1px solid`,borderColor:E&&!e.color?`error.light`:`divider`,borderLeft:e.color?`4px solid ${e.color}`:E?e=>`4px solid ${e.palette.error.main}`:void 0,userSelect:`none`,cursor:c?`grabbing`:`grab`,bgcolor:e=>E?e.palette.mode===`dark`?(0,h.alpha)(e.palette.error.main,.12):(0,h.alpha)(e.palette.error.main,.04):e.palette.mode===`dark`?e.palette.grey[800]:e.palette.background.paper,boxShadow:e=>e.palette.mode===`dark`?`0 1px 3px rgba(0,0,0,0.4)`:`0 1px 3px rgba(0,0,0,0.08)`,transition:`box-shadow 0.15s ease, transform 0.15s ease`,...!x&&!c&&{"&:hover":{boxShadow:e=>e.palette.mode===`dark`?`0 4px 14px rgba(0,0,0,0.5)`:`0 4px 14px rgba(0,0,0,0.12)`,transform:`translateY(-1px)`}},"&:active":{cursor:`grabbing`}},...c?{}:{...d,..._},onClick:()=>!x&&s(e),"aria-label":e.title,children:(0,g.jsx)(u.CardActionArea,{component:`div`,sx:{cursor:`inherit`},children:(0,g.jsxs)(u.CardContent,{sx:{p:1.5,"&:last-child":{pb:1.5}},children:[(0,g.jsxs)(u.Box,{sx:{display:`flex`,alignItems:`flex-start`,gap:.75,mb:+!!C},children:[t&&e.priority&&(0,g.jsx)(u.Box,{className:Ve.cardPriorityDot,role:`img`,"aria-label":`Priority: ${e.priority}`,sx:{width:8,height:8,minWidth:8,borderRadius:`50%`,bgcolor:Ue[e.priority],mt:`5px`,flexShrink:0}}),(0,g.jsx)(u.Typography,{className:Ve.cardTitle,variant:`body2`,sx:{lineHeight:1.4,fontWeight:700,letterSpacing:`-0.01em`},children:e.title})]}),C&&(0,g.jsxs)(u.Box,{className:Ve.cardMeta,sx:{display:`flex`,gap:1,flexWrap:`wrap`,alignItems:`center`},children:[n&&e.assignee&&(0,g.jsx)(u.Chip,{className:Ve.cardAssignee,icon:(0,g.jsx)(m.default,{}),label:e.assignee,size:`small`,variant:a,"aria-label":`${o.dialogFieldAssignee}: ${e.assignee}`,sx:We}),r&&w&&(0,g.jsx)(u.Chip,{className:Ve.cardDueDate,icon:(0,g.jsx)(p.default,{}),label:w,size:`small`,variant:a,color:E?`error`:`default`,"aria-label":`${o.dialogFieldDueDate}: ${w}`,sx:We})]})]})})})}function Ke({state:e,columns:t,t:n,onSave:r,onDelete:i,onClose:a,onRequestDelete:o}){let s=e?.mode===`add`,c=e?.mode===`edit`,l=e?.mode===`delete`,f=c?e.task:null,p=l?e.task:null,m=s?e.columnId:null,[h,v]=(0,d.useState)(()=>c&&f?{...f}:s&&m?{id:``,title:``,status:m}:{id:``,title:``,status:t[0]?.id??``});function y(){let e=h.title.trim();e&&r({...h,title:e,id:c?h.id:crypto.randomUUID()})}function b(e,t){v(n=>({...n,[e]:t}))}let x=s?n.dialogAddTitle:c?n.dialogEditTitle:n.dialogDeleteTitle;return(0,g.jsxs)(u.Dialog,{open:!!e,onClose:a,maxWidth:`xs`,fullWidth:!0,children:[(0,g.jsx)(u.DialogTitle,{children:x}),l&&p?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(u.DialogContent,{children:(0,g.jsx)(u.DialogContentText,{children:n.dialogDeleteConfirm.replace(`{title}`,p.title)})}),(0,g.jsxs)(u.DialogActions,{children:[(0,g.jsx)(u.Button,{onClick:a,children:n.dialogCancel}),(0,g.jsx)(u.Button,{color:`error`,startIcon:(0,g.jsx)(_.default,{}),onClick:()=>i(p.id),children:n.dialogDelete})]})]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(u.DialogContent,{children:(0,g.jsxs)(u.Stack,{spacing:2,sx:{pt:.5},children:[(0,g.jsx)(u.TextField,{label:n.dialogFieldTitle,value:h.title,onChange:e=>b(`title`,e.target.value),required:!0,fullWidth:!0,size:`small`,autoFocus:!0,onKeyDown:e=>e.key===`Enter`&&y()}),(0,g.jsx)(u.TextField,{label:n.dialogFieldDescription,value:h.description??``,onChange:e=>b(`description`,e.target.value||void 0),fullWidth:!0,size:`small`,multiline:!0,rows:3}),(0,g.jsx)(u.TextField,{label:n.dialogFieldAssignee,value:h.assignee??``,onChange:e=>b(`assignee`,e.target.value||void 0),fullWidth:!0,size:`small`}),(0,g.jsx)(u.TextField,{label:n.dialogFieldDueDate,type:`date`,value:h.dueDate?h.dueDate.toISOString().split(`T`)[0]:``,onChange:e=>b(`dueDate`,e.target.value?new Date(e.target.value+`T00:00:00`):void 0),fullWidth:!0,size:`small`,slotProps:{inputLabel:{shrink:!0}}}),(0,g.jsx)(u.TextField,{select:!0,label:n.dialogFieldStatus,value:h.status,onChange:e=>b(`status`,e.target.value),fullWidth:!0,size:`small`,children:t.map(e=>(0,g.jsx)(u.MenuItem,{value:e.id,children:e.label},e.id))})]})}),(0,g.jsxs)(u.DialogActions,{sx:{justifyContent:c?`space-between`:`flex-end`},children:[c&&f&&(0,g.jsx)(u.Button,{color:`error`,startIcon:(0,g.jsx)(_.default,{}),onClick:()=>o(f),children:n.dialogDelete}),(0,g.jsxs)(u.Stack,{direction:`row`,spacing:1,children:[(0,g.jsx)(u.Button,{onClick:a,children:n.dialogCancel}),(0,g.jsx)(u.Button,{variant:`contained`,onClick:y,disabled:!h.title.trim(),children:n.dialogSave})]})]})]})]})}function qe({column:e,tasks:t,totalCount:n,showPriority:r,showAssignee:i,showDueDate:a,showDueDateWarning:o,chipVariant:s,t:d,enableBuiltinDialogs:f,onCardClick:p,onAddClick:m}){let{setNodeRef:h,isOver:_}=(0,c.useDroppable)({id:e.id}),y=e.wipLimit!==void 0&&n>e.wipLimit,b=e.wipLimit===void 0?`${t.length}`:`${t.length} / ${e.wipLimit}`,x=e.color??`primary.main`;return(0,g.jsxs)(u.Box,{className:Ve.column,sx:{display:`flex`,flexDirection:`column`,minWidth:240,maxWidth:320,flex:`1 1 240px`,bgcolor:`background.paper`,borderRadius:2,overflow:`hidden`,border:`1px solid`,borderColor:`divider`},children:[(0,g.jsxs)(u.Box,{className:Ve.columnHeader,sx:{px:2,py:1.25,display:`flex`,alignItems:`center`,gap:1,borderBottom:`1px solid`,borderColor:`divider`,borderTop:`3px solid ${e.color??`transparent`}`,bgcolor:e=>e.palette.mode===`dark`?`grey.800`:`grey.300`},children:[(0,g.jsx)(u.Typography,{className:Ve.columnTitle,variant:`subtitle2`,sx:{flex:1,fontWeight:700},children:e.label}),(0,g.jsx)(u.Chip,{className:Ve.columnCount,label:b,size:`small`,color:y?`error`:`default`,sx:{height:20,fontSize:`0.7rem`,...!y&&e.color&&{bgcolor:e.color,color:`#fff`}},"aria-label":`${t.length} cards${e.wipLimit?` of ${e.wipLimit} limit`:``}${t.length===n?``:` (${n} total)`}`})]}),(0,g.jsx)(l.SortableContext,{items:t.map(e=>e.id),strategy:l.verticalListSortingStrategy,children:(0,g.jsxs)(u.Box,{ref:h,className:Ve.columnBody,sx:{flex:1,overflowY:`auto`,scrollbarWidth:`none`,"&::-webkit-scrollbar":{display:`none`},p:1,minHeight:80,bgcolor:e=>_?e.palette.action.selected:e.palette.mode===`dark`?e.palette.grey[900]:e.palette.grey[100],transition:`background-color 0.15s`},children:[t.length===0&&!_&&(0,g.jsx)(u.Typography,{variant:`caption`,color:`text.disabled`,sx:{display:`block`,textAlign:`center`,mt:2},children:d.noCardsLabel}),t.map(e=>(0,g.jsx)(Ge,{task:e,showPriority:r,showAssignee:i,showDueDate:a,showDueDateWarning:o,chipVariant:s,t:d,onCardClick:p},e.id))]})}),f&&(0,g.jsx)(u.Box,{sx:{p:1,borderTop:`1px solid`,borderColor:`divider`},children:(0,g.jsx)(u.Button,{className:Ve.addButton,startIcon:(0,g.jsx)(v.default,{}),size:`small`,fullWidth:!0,onClick:()=>m(e.id),sx:{justifyContent:`flex-start`,color:x,border:`1px dashed`,borderColor:x,borderRadius:1,py:.75,fontWeight:600,letterSpacing:.5,"&:hover":{bgcolor:`action.hover`,borderStyle:`dashed`}},children:d.addCardLabel})})]})}function Je({tasks:e,columns:t,onTasksChange:n,onCardClick:r,enableBuiltinDialogs:i=!0,onTaskCreated:a,onTaskUpdated:o,onTaskDeleted:s,onTaskMoved:f,showPriority:p=!0,showAssignee:m=!0,showDueDate:h=!0,showDueDateWarning:_=!0,chipVariant:v=`outlined`,filterText:y=``,width:b=`100%`,height:x=`100%`,translation:S}){let C={...He,...S},[w,T]=(0,d.useState)(e);(0,d.useEffect)(()=>{T(e)},[e]);let[E,D]=(0,d.useState)(null),[O,k]=(0,d.useState)(null),A=(0,c.useSensors)((0,c.useSensor)(c.PointerSensor,{activationConstraint:{distance:8}}),(0,c.useSensor)(c.KeyboardSensor,{coordinateGetter:l.sortableKeyboardCoordinates}));function j({active:e}){D(w.find(t=>t.id===e.id)??null)}function M({active:e,over:n}){if(!n)return;let r=e.id,i=n.id,a=w.find(e=>e.id===r);if(!a)return;let o=t.find(e=>e.id===i),s=w.find(e=>e.id===i),c=o?.id??s?.status;!c||a.status===c||T(e=>e.map(e=>e.id===r?{...e,status:c}:e))}function N({active:t,over:r}){let i=E?.status;if(D(null),!r){T(e);return}let a=t.id,o=r.id,s=w.findIndex(e=>e.id===a),c=w.findIndex(e=>e.id===o),u;if(u=s!==-1&&c!==-1&&s!==c?(0,l.arrayMove)(w,s,c):[...w],T(u),n?.(u),i){let e=u.find(e=>e.id===a);e&&e.status!==i&&f?.(e,i,e.status)}}function P(e){i?k({mode:`edit`,task:e}):r?.(e)}function F(e){k({mode:`add`,columnId:e})}function I(e){let t=!w.find(t=>t.id===e.id),r=t?[...w,e]:w.map(t=>t.id===e.id?e:t);T(r),n?.(r),t?a?.(e):o?.(e),k(null)}function L(e){let t=w.filter(t=>t.id!==e);T(t),n?.(t),s?.(e),k(null)}function R(e){k({mode:`delete`,task:e})}let z=y.trim().toLowerCase();function B(e){return z?e.title.toLowerCase().includes(z)||(e.assignee?.toLowerCase().includes(z)??!1):!0}return(0,g.jsxs)(u.Box,{className:Ve.root,sx:{width:b,height:x,display:`flex`,flexDirection:`column`,overflow:`hidden`},children:[(0,g.jsxs)(c.DndContext,{sensors:A,collisionDetection:c.closestCorners,onDragStart:j,onDragOver:M,onDragEnd:N,children:[(0,g.jsx)(u.Box,{className:Ve.columns,sx:{flex:1,display:`flex`,gap:2,p:2,overflowX:`auto`,overflowY:`hidden`,alignItems:`stretch`},children:t.map(e=>{let t=w.filter(t=>t.status===e.id);return(0,g.jsx)(qe,{column:e,tasks:t.filter(B),totalCount:t.length,showPriority:p,showAssignee:m,showDueDate:h,showDueDateWarning:_,chipVariant:v,t:C,enableBuiltinDialogs:i,onCardClick:P,onAddClick:F},e.id)})}),(0,g.jsx)(c.DragOverlay,{children:E&&(0,g.jsx)(Ge,{task:E,showPriority:p,showAssignee:m,showDueDate:h,showDueDateWarning:_,chipVariant:v,t:C,onCardClick:()=>{},isOverlay:!0})})]}),i&&(0,g.jsx)(Ke,{state:O,columns:t,t:C,onSave:I,onDelete:L,onRequestDelete:R,onClose:()=>k(null)},O?`${O.mode}-${O.mode===`add`?O.columnId:O.task.id}`:`closed`)]})}var Ye={root:`MuiTsDateRangePicker-root`,inputs:`MuiTsDateRangePicker-inputs`,startInput:`MuiTsDateRangePicker-startInput`,separator:`MuiTsDateRangePicker-separator`,endInput:`MuiTsDateRangePicker-endInput`,helperText:`MuiTsDateRangePicker-helperText`},Xe={fromLabel:`From`,toLabel:`To`,endBeforeStartError:`End date must be after start date`,startRequiredError:`Start date is required`,endRequiredError:`End date is required`};function Ze(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function Qe(e){if(!e)return null;let t=new Date(`${e}T00:00:00`);return isNaN(t.getTime())?null:t}function $e(e){return e?{date:e,iso:Ze(e)}:null}function et(e,t,n,r){let i=``,a=``;return e.start&&e.end&&e.end<e.start&&(a=r.endBeforeStartError),n&&!e.start&&t.start&&(i=r.startRequiredError),n&&!e.end&&t.end&&!a&&(a=r.endRequiredError),{startError:i,endError:a}}var tt={start:null,end:null};function nt({value:e,defaultValue:t,onChange:n,minDate:r,maxDate:i,disabled:a=!1,required:o=!1,error:s=!1,helperText:c,inputSize:l=`small`,inputMinWidth:f=170,translation:p}){let m={...Xe,...p},h=e!==void 0,[_,v]=(0,d.useState)(t??tt),[y,b]=(0,d.useState)({start:!1,end:!1}),x=h?e:_,{startError:S,endError:C}=et(x,y,o,m);function w(e,t){h||v({start:e,end:t}),n?.({start:$e(e),end:$e(t)})}function T(e){b(e=>({...e,start:!0})),w(Qe(e.target.value),x.end)}function E(e){b(e=>({...e,end:!0})),w(x.start,Qe(e.target.value))}function D(){b(e=>({...e,start:!0}))}function O(){b(e=>({...e,end:!0}))}let k=r?Ze(r):void 0,A=i?Ze(i):void 0,j=x.start?Ze(x.start):k,M=s||!!S||!!C;return(0,g.jsxs)(u.Box,{className:[Ye.root,a&&Be.disabled,M&&Be.error].filter(Boolean).join(` `),sx:{display:`inline-flex`,flexDirection:`column`,gap:.25},children:[(0,g.jsxs)(u.Box,{className:Ye.inputs,sx:{display:`inline-flex`,alignItems:`flex-start`,gap:1},children:[(0,g.jsx)(u.TextField,{className:Ye.startInput,type:`date`,label:m.fromLabel,value:x.start?Ze(x.start):``,onChange:T,onBlur:D,disabled:a,required:o,error:!!S||s,helperText:S||` `,size:l,sx:{width:f},slotProps:{inputLabel:{shrink:!0},htmlInput:{min:k,max:A,"data-testid":`date-range-start`}}}),(0,g.jsx)(u.Box,{component:`span`,className:Ye.separator,"aria-hidden":!0,sx:{color:`text.disabled`,userSelect:`none`,flexShrink:0,lineHeight:1,mt:l===`small`?`12px`:`20px`},children:`–`}),(0,g.jsx)(u.TextField,{className:Ye.endInput,type:`date`,label:m.toLabel,value:x.end?Ze(x.end):``,onChange:E,onBlur:O,disabled:a,required:o,error:!!C||s,helperText:C||` `,size:l,sx:{width:f},slotProps:{inputLabel:{shrink:!0},htmlInput:{min:j,max:A,"data-testid":`date-range-end`}}})]}),c&&(0,g.jsx)(u.FormHelperText,{className:Ye.helperText,error:s,sx:{mx:`14px`},children:c})]})}var rt={root:`MuiTsTagSelection-root`,selectedTags:`MuiTsTagSelection-selectedTags`,selectedTagsLabel:`MuiTsTagSelection-selectedTagsLabel`,chipsStack:`MuiTsTagSelection-chipsStack`,chip:`MuiTsTagSelection-chip`,overflowChip:`MuiTsTagSelection-overflowChip`,overflowPopover:`MuiTsTagSelection-overflowPopover`,autocomplete:`MuiTsTagSelection-autocomplete`,option:`MuiTsTagSelection-option`,createPanel:`MuiTsTagSelection-createPanel`},it={root:`MuiTsPasswordStrengthMeter-root`,input:`MuiTsPasswordStrengthMeter-input`,generatorButton:`MuiTsPasswordStrengthMeter-generatorButton`,confirmInput:`MuiTsPasswordStrengthMeter-confirmInput`,strengthBar:`MuiTsPasswordStrengthMeter-strengthBar`,strengthBarWeak:`MuiTsPasswordStrengthMeter-strengthBarWeak`,strengthBarOk:`MuiTsPasswordStrengthMeter-strengthBarOk`,strengthBarGood:`MuiTsPasswordStrengthMeter-strengthBarGood`,strengthBarVeryGood:`MuiTsPasswordStrengthMeter-strengthBarVeryGood`,summary:`MuiTsPasswordStrengthMeter-summary`,requirementItem:`MuiTsPasswordStrengthMeter-requirementItem`},at={root:`MuiTsColorPicker-root`,gradientArea:`MuiTsColorPicker-gradientArea`,gradientThumb:`MuiTsColorPicker-gradientThumb`,sliderSection:`MuiTsColorPicker-sliderSection`,hueSlider:`MuiTsColorPicker-hueSlider`,alphaSlider:`MuiTsColorPicker-alphaSlider`,inputSection:`MuiTsColorPicker-inputSection`,savedColors:`MuiTsColorPicker-savedColors`,swatchList:`MuiTsColorPicker-swatchList`,swatch:`MuiTsColorPicker-swatch`},ot={root:`MuiTsPopoverColorPicker-root`,swatch:`MuiTsPopoverColorPicker-swatch`};function st(e,t,n){return Math.min(n,Math.max(t,e))}function ct(e){return st(Math.round(e),0,255).toString(16).padStart(2,`0`)}function lt({r:e,g:t,b:n,a:r}){let i=`#${ct(e)}${ct(t)}${ct(n)}`;return r<1?`${i}${ct(r*255)}`:i}function ut(e){let t=e.trim().replace(/^#/,``),n,r,i,a=1;if(t.length===3||t.length===4)n=parseInt(t[0]+t[0],16),r=parseInt(t[1]+t[1],16),i=parseInt(t[2]+t[2],16),t.length===4&&(a=parseInt(t[3]+t[3],16)/255);else if(t.length===6||t.length===8)n=parseInt(t.slice(0,2),16),r=parseInt(t.slice(2,4),16),i=parseInt(t.slice(4,6),16),t.length===8&&(a=parseInt(t.slice(6,8),16)/255);else return null;return[n,r,i,a].some(e=>Number.isNaN(e))?null:{r:n,g:r,b:i,a}}function dt(e,t,n){let r=t/100,i=n/100,a=i*r,o=a*(1-Math.abs(e/60%2-1)),s=i-a,[c,l,u]=e<60?[a,o,0]:e<120?[o,a,0]:e<180?[0,a,o]:e<240?[0,o,a]:e<300?[o,0,a]:[a,0,o];return{r:(c+s)*255,g:(l+s)*255,b:(u+s)*255}}function ft(e,t,n){let r=e/255,i=t/255,a=n/255,o=Math.max(r,i,a),s=o-Math.min(r,i,a),c=0;s!==0&&(c=o===r?60*((i-a)/s%6):o===i?60*((a-r)/s+2):60*((r-i)/s+4)),c<0&&(c+=360);let l=o===0?0:s/o;return{h:c,s:l*100,v:o*100}}function pt(e,t,n){let r=t/100,i=n/100,a=(1-Math.abs(2*i-1))*r,o=a*(1-Math.abs(e/60%2-1)),s=i-a/2,[c,l,u]=e<60?[a,o,0]:e<120?[o,a,0]:e<180?[0,a,o]:e<240?[0,o,a]:e<300?[o,0,a]:[a,0,o];return{r:(c+s)*255,g:(l+s)*255,b:(u+s)*255}}function mt(e,t,n){let r=e/255,i=t/255,a=n/255,o=Math.max(r,i,a),s=Math.min(r,i,a),c=(o+s)/2,l=o-s,u=0,d=0;return l!==0&&(d=c>.5?l/(2-o-s):l/(o+s),u=o===r?60*((i-a)/l%6):o===i?60*((a-r)/l+2):60*((r-i)/l+4)),u<0&&(u+=360),{h:u,s:d*100,l:c*100}}function ht({h:e,s:t,v:n,a:r}){let{r:i,g:a,b:o}=dt(e,t,n);return{r:i,g:a,b:o,a:r}}function gt({r:e,g:t,b:n,a:r}){let{h:i,s:a,v:o}=ft(e,t,n);return{h:i,s:a,v:o,a:r}}function _t({h:e,s:t,v:n,a:r}){let{r:i,g:a,b:o}=dt(e,t,n);return{...mt(i,a,o),a:r}}function vt({h:e,s:t,l:n,a:r}){let{r:i,g:a,b:o}=pt(e,t,n);return{...ft(i,a,o),a:r}}function yt(e){let t=e.trim();if(t.startsWith(`#`))return ut(t);let n=t.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)$/i);if(n)return{r:Number(n[1]),g:Number(n[2]),b:Number(n[3]),a:n[4]===void 0?1:Number(n[4])};let r=t.match(/^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%\s*(?:,\s*([\d.]+)\s*)?\)$/i);if(r){let{r:e,g:t,b:n}=pt(Number(r[1]),Number(r[2]),Number(r[3]));return{r:e,g:t,b:n,a:r[4]===void 0?1:Number(r[4])}}return null}var bt={formatLabel:`Color format`,hexFieldLabel:`Hex value`,redLabel:`Red`,greenLabel:`Green`,blueLabel:`Blue`,hueFieldLabel:`Hue`,saturationFieldLabel:`Saturation`,lightnessFieldLabel:`Lightness`,alphaFieldLabel:`Alpha`,eyeDropperLabel:`Pick color from screen`,savedColorsLabel:`Saved colors`,gradientAreaLabel:`Saturation and brightness`,hueSliderLabel:`Hue`},xt={openLabel:`Open color picker`};function St(e,t){let n=st(e,0,100);return`calc(${t/2}px + (100% - ${t}px) * ${n/100})`}function Ct(e){let t=ht(e),n=_t(e),r=lt(t);return{hex:r,info:{hex:r,rgb:{r:Math.round(t.r),g:Math.round(t.g),b:Math.round(t.b),a:t.a},hsl:{h:Math.round(n.h),s:Math.round(n.s),l:Math.round(n.l),a:n.a}}}}function wt({value:e,onCommit:t,min:n,max:r,label:i,disabled:a,size:o,onBlurExtra:s,fullWidth:c}){let[l,f]=(0,d.useState)(String(Math.round(e)));return(0,d.useEffect)(()=>{f(String(Math.round(e)))},[e]),(0,g.jsx)(u.TextField,{size:o,value:l,disabled:a,onChange:e=>{let i=e.target.value;f(i);let a=Number(i);i.trim()!==``&&!Number.isNaN(a)&&t(st(a,n,r))},onBlur:()=>{f(String(Math.round(e))),s?.()},slotProps:{htmlInput:{"aria-label":i,style:{textAlign:`center`}}},sx:c?{flex:1,minWidth:0}:{width:64,flexShrink:0}})}function Tt({value:e,onChange:t,onChangeCommitted:n,defaultFormat:r=`hex`,format:i,onFormatChange:a,showAlpha:o=!0,showEyeDropper:s=!0,showSliderSection:c=!0,showInputSection:l=!0,savedColors:f,disabled:p=!1,colorGradientSize:m=`medium`,inputSize:h=`medium`,width:_=280,name:v,translation:b}){let x=(0,u.useTheme)(),S={...bt,...b},[C,w]=(0,d.useState)(()=>{let t=yt(e);return t?gt(t):{h:0,s:0,v:0,a:1}}),[T,E]=(0,d.useState)(r),D=i??T,[O,k]=(0,d.useState)(e);if(O!==e){k(e);let t=yt(e);t&&w(gt(t))}let{hex:A,info:j}=Ct(C),M=A.slice(0,7),[N,P]=(0,d.useState)(M);(0,d.useEffect)(()=>{P(M)},[M]);let F=(0,d.useRef)(null),I=(0,d.useRef)(null),L=(0,d.useRef)(null),R=e=>{w(e);let n=Ct(e);k(n.hex),t(n.hex,n.info)},z=e=>{if(R(e),n){let t=Ct(e);n(t.hex,t.info)}},B=()=>{if(!n)return;let e=Ct(C);n(e.hex,e.info)},V=m===`small`?130:160,H=m===`small`?20:24,U=m===`small`?10:12,W=m===`small`?13:16,G=e=>{if(p||!F.current)return;let t=F.current.getBoundingClientRect(),n=st(e.clientX-t.left,0,t.width),r=st(e.clientY-t.top,0,t.height);R({...C,s:n/t.width*100,v:100-r/t.height*100})},K=e=>{if(p||!I.current)return;let t=I.current.getBoundingClientRect(),n=st(e.clientX-t.left,0,t.width);R({...C,h:n/t.width*360})},q=e=>{if(p||!L.current)return;let t=L.current.getBoundingClientRect(),n=st(e.clientX-t.left,0,t.width);R({...C,a:n/t.width})},J=typeof window<`u`&&!!window.EyeDropper,ee=async()=>{if(!(p||!window.EyeDropper))try{let e=ut((await new window.EyeDropper().open()).sRGBHex);e&&z(gt({...e,a:C.a}))}catch{}},te=e=>{i===void 0&&E(e),a?.(e)},Y=ht(C),X=_t(C),ne=M,re={backgroundImage:`linear-gradient(45deg, #ccc 25%, transparent 25%), linear-gradient(-45deg, #ccc 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #ccc 75%), linear-gradient(-45deg, transparent 75%, #ccc 75%)`,backgroundSize:`8px 8px`,backgroundPosition:`0 0, 0 4px, 4px -4px, -4px 0px`};return(0,g.jsxs)(u.Box,{sx:{width:_,opacity:p?.6:1,display:`flex`,flexDirection:`column`,gap:1},className:[at.root,p&&Be.disabled].filter(Boolean).join(` `),children:[(0,g.jsx)(u.Box,{ref:F,role:`slider`,tabIndex:p?-1:0,"aria-label":S.gradientAreaLabel,"aria-valuetext":`${Math.round(C.s)}, ${Math.round(C.v)}`,onPointerDown:e=>{e.currentTarget.setPointerCapture?.(e.pointerId),G(e)},onPointerMove:e=>{e.buttons===1&&G(e)},onPointerUp:B,className:at.gradientArea,sx:{position:`relative`,width:`100%`,height:V,borderRadius:`${x.shape.borderRadius}px`,border:`1px solid ${x.palette.divider}`,cursor:p?`default`:`crosshair`,touchAction:`none`,background:`linear-gradient(to top, #000, rgba(0,0,0,0)), linear-gradient(to right, #fff, hsl(${C.h}, 100%, 50%))`},children:(0,g.jsx)(u.Box,{className:at.gradientThumb,sx:{position:`absolute`,left:St(C.s,W),top:St(100-C.v,W),width:W,height:W,borderRadius:`50%`,border:`2px solid #fff`,boxShadow:`0 0 0 1px rgba(0,0,0,0.3)`,transform:`translate(-50%, -50%)`,pointerEvents:`none`,backgroundColor:ne}})}),c&&(0,g.jsxs)(u.Box,{sx:{display:`flex`,gap:1,alignItems:`center`},className:at.sliderSection,children:[s&&J&&(0,g.jsx)(u.Tooltip,{title:S.eyeDropperLabel,children:(0,g.jsx)(`span`,{children:(0,g.jsx)(u.IconButton,{size:`small`,onClick:ee,disabled:p,"aria-label":S.eyeDropperLabel,children:(0,g.jsx)(y.default,{fontSize:`small`})})})}),(0,g.jsxs)(u.Box,{sx:{flex:1,display:`flex`,flexDirection:`column`,gap:.75},children:[(0,g.jsx)(u.Box,{ref:I,role:`slider`,tabIndex:p?-1:0,"aria-label":S.hueSliderLabel,"aria-valuemin":0,"aria-valuemax":360,"aria-valuenow":Math.round(C.h),onPointerDown:e=>{e.currentTarget.setPointerCapture?.(e.pointerId),K(e)},onPointerMove:e=>{e.buttons===1&&K(e)},onPointerUp:B,className:at.hueSlider,sx:{position:`relative`,width:`100%`,height:U,borderRadius:U,cursor:p?`default`:`pointer`,touchAction:`none`,background:`linear-gradient(to right, red, yellow, lime, cyan, blue, magenta, red)`},children:(0,g.jsx)(u.Box,{sx:{position:`absolute`,left:St(C.h/360*100,W),top:`50%`,width:W,height:W,borderRadius:`50%`,border:`2px solid #fff`,boxShadow:`0 0 0 1px rgba(0,0,0,0.3)`,transform:`translate(-50%, -50%)`,pointerEvents:`none`,backgroundColor:`hsl(${C.h}, 100%, 50%)`}})}),o&&(0,g.jsxs)(u.Box,{ref:L,role:`slider`,tabIndex:p?-1:0,"aria-label":S.alphaFieldLabel,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(C.a*100),onPointerDown:e=>{e.currentTarget.setPointerCapture?.(e.pointerId),q(e)},onPointerMove:e=>{e.buttons===1&&q(e)},onPointerUp:B,className:at.alphaSlider,sx:{position:`relative`,width:`100%`,height:U,borderRadius:U,cursor:p?`default`:`pointer`,touchAction:`none`,...re},children:[(0,g.jsx)(u.Box,{sx:{position:`absolute`,inset:0,borderRadius:U,background:`linear-gradient(to right, transparent, ${ne})`}}),(0,g.jsx)(u.Box,{sx:{position:`absolute`,left:St(C.a*100,W),top:`50%`,width:W,height:W,borderRadius:`50%`,border:`2px solid #fff`,boxShadow:`0 0 0 1px rgba(0,0,0,0.3)`,transform:`translate(-50%, -50%)`,pointerEvents:`none`,backgroundColor:ne}})]})]})]}),l&&(0,g.jsxs)(u.Box,{sx:{display:`flex`,flexDirection:`column`,gap:.75},className:at.inputSection,children:[(0,g.jsxs)(u.Box,{sx:{display:`flex`,gap:.75,alignItems:`center`},children:[(0,g.jsxs)(u.Select,{size:h,value:D,"aria-label":S.formatLabel,disabled:p,onChange:e=>te(e.target.value),sx:{minWidth:80,flexShrink:0},children:[(0,g.jsx)(u.MenuItem,{value:`hex`,children:`HEX`}),(0,g.jsx)(u.MenuItem,{value:`rgb`,children:`RGB`}),(0,g.jsx)(u.MenuItem,{value:`hsl`,children:`HSL`})]}),D===`hex`&&(0,g.jsx)(u.TextField,{size:h,value:N,disabled:p,onChange:e=>{let t=e.target.value;P(t);let n=ut(t);n&&R(gt({...n,a:C.a}))},onBlur:()=>{P(M),B()},slotProps:{htmlInput:{"aria-label":S.hexFieldLabel}},sx:{flex:1,minWidth:0}}),D!==`hex`&&(0,g.jsx)(u.Box,{sx:{flex:1}}),o&&(0,g.jsx)(wt,{label:S.alphaFieldLabel,value:Math.round(C.a*100),min:0,max:100,disabled:p,size:h,onBlurExtra:B,onCommit:e=>R({...C,a:e/100})})]}),D===`rgb`&&(0,g.jsxs)(u.Box,{sx:{display:`flex`,gap:.75},children:[(0,g.jsx)(wt,{label:S.redLabel,value:Y.r,min:0,max:255,disabled:p,size:h,onBlurExtra:B,fullWidth:!0,onCommit:e=>R(gt({r:e,g:Y.g,b:Y.b,a:C.a}))}),(0,g.jsx)(wt,{label:S.greenLabel,value:Y.g,min:0,max:255,disabled:p,size:h,onBlurExtra:B,fullWidth:!0,onCommit:e=>R(gt({r:Y.r,g:e,b:Y.b,a:C.a}))}),(0,g.jsx)(wt,{label:S.blueLabel,value:Y.b,min:0,max:255,disabled:p,size:h,onBlurExtra:B,fullWidth:!0,onCommit:e=>R(gt({r:Y.r,g:Y.g,b:e,a:C.a}))})]}),D===`hsl`&&(0,g.jsxs)(u.Box,{sx:{display:`flex`,gap:.75},children:[(0,g.jsx)(wt,{label:S.hueFieldLabel,value:X.h,min:0,max:360,disabled:p,size:h,onBlurExtra:B,fullWidth:!0,onCommit:e=>R({...C,h:e})}),(0,g.jsx)(wt,{label:S.saturationFieldLabel,value:X.s,min:0,max:100,disabled:p,size:h,onBlurExtra:B,fullWidth:!0,onCommit:e=>R(vt({h:X.h,s:e,l:X.l,a:X.a}))}),(0,g.jsx)(wt,{label:S.lightnessFieldLabel,value:X.l,min:0,max:100,disabled:p,size:h,onBlurExtra:B,fullWidth:!0,onCommit:e=>R(vt({h:X.h,s:X.s,l:e,a:X.a}))})]})]}),f&&f.length>0&&(0,g.jsxs)(u.Box,{className:at.savedColors,children:[(0,g.jsx)(u.Typography,{variant:`caption`,sx:{color:`text.secondary`,display:`block`,mb:.5},children:S.savedColorsLabel}),(0,g.jsx)(u.Box,{sx:{display:`flex`,flexWrap:`wrap`,gap:.75},className:at.swatchList,children:f.map((e,t)=>(0,g.jsx)(u.Box,{component:`button`,type:`button`,disabled:p,"aria-label":e,onClick:()=>{let t=yt(e);t&&z(gt(t))},className:at.swatch,sx:{width:H,height:H,p:0,borderRadius:.5,border:`1px solid ${x.palette.divider}`,cursor:p?`default`:`pointer`,flexShrink:0,...re,backgroundSize:`6px 6px`,"&:hover":p?void 0:{borderColor:x.palette.primary.main}},children:(0,g.jsx)(u.Box,{sx:{width:`100%`,height:`100%`,borderRadius:.5,backgroundColor:e}})},`${e}-${t}`))})]}),v&&(0,g.jsx)(`input`,{type:`hidden`,name:v,value:j.hex})]})}var Et={backgroundImage:`linear-gradient(45deg, #ccc 25%, transparent 25%), linear-gradient(-45deg, #ccc 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #ccc 75%), linear-gradient(-45deg, transparent 75%, #ccc 75%)`,backgroundSize:`8px 8px`,backgroundPosition:`0 0, 0 4px, 4px -4px, -4px 0px`};function Dt({value:e,onChange:t,onChangeCommitted:n,swatchSize:r=28,swatchShape:i=`square`,disabled:a=!1,translation:o,...s}){let c=(0,u.useTheme)(),l={...xt,...o},[f,p]=(0,d.useState)(null),m=!!f,h=i===`circle`?`50%`:`${c.shape.borderRadius}px`;return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(u.Box,{component:`button`,type:`button`,disabled:a,"aria-label":l.openLabel,"aria-expanded":m,"aria-haspopup":`dialog`,onClick:e=>p(e.currentTarget),className:[ot.root,a?Be.disabled:void 0].filter(Boolean).join(` `),sx:{width:r,height:r,minWidth:r,p:0,borderRadius:h,border:`1px solid ${c.palette.divider}`,cursor:a?`default`:`pointer`,overflow:`hidden`,flexShrink:0,...Et,"&:hover:not(:disabled)":{borderColor:c.palette.primary.main},"&:focus-visible":{outline:`2px solid ${c.palette.primary.main}`,outlineOffset:2}},children:(0,g.jsx)(u.Box,{className:ot.swatch,sx:{width:`100%`,height:`100%`,borderRadius:`inherit`,backgroundColor:e}})}),(0,g.jsx)(u.Popover,{open:m,anchorEl:f,onClose:()=>p(null),anchorOrigin:{vertical:`bottom`,horizontal:`left`},transformOrigin:{vertical:`top`,horizontal:`left`},slotProps:{paper:{sx:{p:1.5},"data-testid":`popover-color-picker`}},children:(0,g.jsx)(Tt,{value:e,onChange:t,onChangeCommitted:n,disabled:a,translation:o,...s})})]})}var Ot={showFormat:!0,showCompact:!0,showCopy:!0,showDownload:!0,showClear:!0,showUndoRedo:!0},kt={format:`Format JSON`,compact:`Compact JSON`,copy:`Copy`,copySuccess:`Copied!`,download:`Download`,downloadSuccess:`Downloaded!`,clear:`Clear`,undo:`Undo`,redo:`Redo`,lineColumn:`Ln {line}, Col {col}`,validJson:`Valid JSON`,invalidJson:`Invalid JSON`},At=/^[A-Za-z_$][A-Za-z0-9_$]*$/,jt=new Set([`Object`,`Array`,`String`,`Number`,`True`,`False`,`Null`]);function Mt(e){return At.test(e)?`.${e}`:`[${JSON.stringify(e)}]`}function Nt(e,t){if(e.doc.length===0)return null;let n=(0,w.syntaxTree)(e).resolveInner(t,1);if(!n)return null;let r=[];for(;n;){let t=n.parent;if(!t)break;if(t.name===`Property`){let i=t.getChild(`PropertyName`);if(i){let t=e.sliceDoc(i.from,i.to);try{r.unshift(Mt(JSON.parse(t)))}catch{}}n=t.parent??t;continue}if(t.name===`Array`){let e=0,i=t.firstChild;for(;i&&i.from<n.from;)jt.has(i.name)&&e++,i=i.nextSibling;r.unshift(`[${e}]`),n=t;continue}n=t}return r.length>0?`$${r.join(``)}`:`$`}var Pt=new Set([`Object`,`Array`,`String`,`Number`,`True`,`False`,`Null`]),Ft=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function It(e){return Ft.test(e)?`.${e}`:`[${JSON.stringify(e)}]`}function Lt(e){return e===null?`null`:Array.isArray(e)?`array`:typeof e==`number`?Number.isInteger(e)?`integer`:`number`:typeof e==`string`?`string`:typeof e==`boolean`?`boolean`:`object`}function Rt(e,t){let n=Lt(e);return n===t||t===`number`&&n===`integer`}function zt(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,n)=>zt(e,t[n]));if(e&&t&&typeof e==`object`&&typeof t==`object`){let n=Object.keys(e),r=Object.keys(t);return n.length===r.length?n.every(n=>zt(e[n],t[n])):!1}return!1}function Bt(e,t,n=`$`){let r=[];if(t.type){let i=Array.isArray(t.type)?t.type:[t.type];if(!i.some(t=>Rt(e,t)))return r.push({path:n,message:`Expected type ${i.join(` | `)}, got ${Lt(e)}.`}),r}if(t.enum&&!t.enum.some(t=>zt(t,e))&&r.push({path:n,message:`Value must be one of: ${t.enum.map(e=>JSON.stringify(e)).join(`, `)}.`}),Lt(e)===`object`&&e!==null){let i=e;for(let e of t.required??[])e in i||r.push({path:n,message:`Missing required property "${e}".`});if(t.properties)for(let[e,a]of Object.entries(t.properties))e in i&&r.push(...Bt(i[e],a,`${n}${It(e)}`))}return t.items&&Array.isArray(e)&&e.forEach((e,i)=>{r.push(...Bt(e,t.items,`${n}[${i}]`))}),r}var Vt=/\.([A-Za-z_$][A-Za-z0-9_$]*)|\[(\d+)\]|\["((?:[^"\\]|\\.)*)"\]/g;function Ht(e){let t=[];for(let n of e.matchAll(Vt))n[1]===void 0?n[2]===void 0?n[3]!==void 0&&t.push({type:`key`,value:JSON.parse(`"${n[3]}"`)}):t.push({type:`index`,value:Number(n[2])}):t.push({type:`key`,value:n[1]});return t}function Ut(e){let t=e.topNode;for(;t&&!Pt.has(t.name);){let e=t.firstChild;if(!e)return null;t=e}return t}function Wt(e,t){let n=Ut((0,w.syntaxTree)(e));if(!n)return null;for(let r of Ht(t))if(r.type===`key`){if(n.name!==`Object`)return null;let t=null;for(let i=n.firstChild;i;i=i.nextSibling){if(i.name!==`Property`)continue;let n=i.getChild(`PropertyName`);if(n)try{if(JSON.parse(e.sliceDoc(n.from,n.to))===r.value){t=i.lastChild;break}}catch{}}if(!t)return null;n=t}else{if(n.name!==`Array`)return null;let e=0,t=null;for(let i=n.firstChild;i;i=i.nextSibling)if(Pt.has(i.name)){if(e===r.value){t=i;break}e++}if(!t)return null;n=t}return{from:n.from,to:n.to}}function Gt(e){return e?[(0,b.lineNumbers)(),(0,b.highlightActiveLineGutter)()]:[]}function Kt(e){return e?[(0,w.foldGutter)()]:[]}function qt(e){return e?[(0,b.placeholder)(e)]:[]}function Jt({value:e,onChange:t,placeholder:n,disabled:r=!1,readonly:i=!1,schema:a,showLineNumbers:o=!0,showMinimap:s=!1,showFolding:c=!0,enablePathFinder:l=!0,highlightColors:f,onViewReady:p,onCursorChange:m,onBlur:h,onFocus:_,onPathCopy:v}){let y=(0,d.useRef)(null),O=(0,d.useRef)(null),k=(0,d.useRef)(null),A=(0,d.useRef)(t),j=(0,d.useRef)(m),M=(0,d.useRef)(h),N=(0,d.useRef)(_),P=(0,d.useRef)(p),F=(0,d.useRef)(v),I=(0,d.useRef)(l),L=(0,d.useRef)(a),[R,z]=(0,d.useState)(null),B=(0,d.useRef)(new x.Compartment),V=(0,d.useRef)(new x.Compartment),H=(0,d.useRef)(new x.Compartment),U=(0,d.useRef)(new x.Compartment),W=(0,d.useRef)(new x.Compartment),G=(0,u.useTheme)(),K=G.palette.mode===`dark`,q=f?.propertyName??G.palette.primary.main,J=f?.string??G.palette.success.main,ee=f?.number??G.palette.warning.main,te=f?.boolean??G.palette.info.main,Y=f?.null??G.palette.text.secondary;return(0,d.useEffect)(()=>{A.current=t},[t]),(0,d.useEffect)(()=>{j.current=m},[m]),(0,d.useEffect)(()=>{M.current=h},[h]),(0,d.useEffect)(()=>{N.current=_},[_]),(0,d.useEffect)(()=>{P.current=p},[p]),(0,d.useEffect)(()=>{F.current=v},[v]),(0,d.useEffect)(()=>{I.current=l},[l]),(0,d.useEffect)(()=>{L.current=a,k.current&&(0,T.forceLinting)(k.current)},[a]),(0,d.useEffect)(()=>{if(!O.current)return;let t=k.current?.state.doc.toString()??e??``,a=w.HighlightStyle.define([{tag:E.tags.propertyName,color:q,fontWeight:`bold`},{tag:E.tags.string,color:J},{tag:E.tags.number,color:ee},{tag:E.tags.bool,color:te,fontWeight:`bold`},{tag:E.tags.null,color:Y,fontStyle:`italic`},{tag:E.tags.bracket,color:G.palette.text.secondary},{tag:E.tags.punctuation,color:G.palette.text.disabled},{tag:E.tags.invalid,color:G.palette.error.main,textDecoration:`underline wavy`}]),l=b.EditorView.theme({"&":{height:`100%`,fontFamily:`'Fira Code', 'JetBrains Mono', 'Consolas', monospace`,fontSize:`0.875rem`},".cm-scroller":{overflow:`auto`},".cm-content":{padding:`8px 4px`,caretColor:G.palette.text.primary},".cm-gutters":{backgroundColor:K?G.palette.grey[900]:G.palette.grey[50],color:G.palette.text.disabled,border:`none`,borderRight:`1px solid ${G.palette.divider}`},".cm-lineNumbers .cm-gutterElement":{paddingLeft:`4px`,paddingRight:`8px`},".cm-activeLineGutter":{backgroundColor:G.palette.action.selected},".cm-activeLine":{backgroundColor:G.palette.action.hover},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground":{backgroundColor:G.palette.primary.main+`40`},".cm-cursor, .cm-dropCursor":{borderLeftColor:G.palette.text.primary},"&.cm-focused":{outline:`none`},".cm-placeholder":{color:G.palette.text.disabled,fontStyle:`italic`},".cm-gutter-lint":{width:`16px`},".cm-lint-marker-error":{color:G.palette.error.main},".cm-lint-marker-warning":{color:G.palette.warning.main},".cm-foldGutter .cm-gutterElement":{cursor:`pointer`,color:G.palette.text.disabled},".cm-foldPlaceholder":{backgroundColor:G.palette.action.selected,border:`1px solid ${G.palette.divider}`,borderRadius:`3px`,color:G.palette.text.secondary,padding:`0 4px`},".cm-tooltip.cm-tooltip-lint":{backgroundColor:G.palette.background.paper,border:`1px solid ${G.palette.divider}`,borderRadius:`4px`},".cm-diagnostic-error":{borderLeft:`3px solid ${G.palette.error.main}`},".cm-diagnostic-warning":{borderLeft:`3px solid ${G.palette.warning.main}`}},{dark:K}),u=s?[D.showMinimap.of({create:()=>{let e=document.createElement(`div`);return e.style.width=`80px`,e.style.overflow=`hidden`,e.style.borderLeft=`1px solid ${G.palette.divider}`,e.style.backgroundColor=K?G.palette.grey[900]:G.palette.grey[50],{dom:e}},displayText:`blocks`,showOverlay:`always`})]:[],d=[l,(0,w.syntaxHighlighting)(a),(0,S.json)(),(0,T.lintGutter)(),(0,T.linter)((0,S.jsonParseLinter)()),(0,T.linter)(e=>{let t=L.current;if(!t)return[];let n;try{n=JSON.parse(e.state.doc.toString())}catch{return[]}let r=[];for(let i of Bt(n,t)){let t=Wt(e.state,i.path);t&&r.push({from:t.from,to:t.to,severity:`error`,message:i.message})}return r}),(0,C.history)(),b.keymap.of([...C.defaultKeymap,...C.historyKeymap,...w.foldKeymap]),B.current.of(b.EditorView.editable.of(!r&&!i)),V.current.of(x.EditorState.readOnly.of(i)),(0,b.highlightActiveLine)(),U.current.of(Gt(o)),H.current.of(Kt(c)),W.current.of(qt(n)),...u,b.EditorView.updateListener.of(e=>{e.docChanged&&A.current?.(e.state.doc.toString());let t=e.state.selection.main.head,n=e.state.doc.lineAt(t);j.current(n.number,t-n.from+1)}),b.EditorView.domEventHandlers({blur:()=>{M.current?.()},focus:()=>{N.current?.()},click:(e,t)=>{if(!I.current||!(e.ctrlKey||e.metaKey))return!1;let n;try{n=t.posAtCoords({x:e.clientX,y:e.clientY})}catch{return!1}if(n===null)return!1;let r=Nt(t.state,n);return r?(navigator.clipboard.writeText(r).then(()=>{let t=y.current?.getBoundingClientRect();z({x:e.clientX-(t?.left??0),y:e.clientY-(t?.top??0),path:r}),F.current?.(r)}),!0):!1}})],f=new b.EditorView({state:x.EditorState.create({doc:t,extensions:d}),parent:O.current});return k.current=f,P.current(f),()=>{P.current(null),f.destroy(),k.current=null}},[K,q,J,ee,te,Y,s]),(0,d.useEffect)(()=>{let t=k.current;if(!t)return;let n=t.state.doc.toString();n!==(e??``)&&t.dispatch({changes:{from:0,to:n.length,insert:e??``}})},[e]),(0,d.useEffect)(()=>{k.current?.dispatch({effects:[B.current.reconfigure(b.EditorView.editable.of(!r&&!i)),V.current.reconfigure(x.EditorState.readOnly.of(i))]})},[r,i]),(0,d.useEffect)(()=>{k.current?.dispatch({effects:U.current.reconfigure(Gt(o))})},[o]),(0,d.useEffect)(()=>{k.current?.dispatch({effects:H.current.reconfigure(Kt(c))})},[c]),(0,d.useEffect)(()=>{k.current?.dispatch({effects:W.current.reconfigure(qt(n))})},[n]),(0,d.useEffect)(()=>{if(!R)return;let e=setTimeout(()=>z(null),1500);return()=>clearTimeout(e)},[R]),(0,g.jsxs)(u.Box,{ref:y,sx:{position:`relative`,flex:1,overflow:`hidden`,display:`flex`},children:[(0,g.jsx)(u.Box,{ref:O,sx:{flex:1,overflow:`hidden`,display:`flex`,flexDirection:`column`,opacity:r?.5:1,backgroundColor:G.palette.background.paper,"& .cm-editor":{flex:1,display:`flex`,flexDirection:`column`}}}),R&&(0,g.jsx)(u.Fade,{in:!0,children:(0,g.jsx)(u.Paper,{elevation:3,sx:{position:`absolute`,left:R.x,top:R.y,transform:`translate(-50%, -130%)`,px:1,py:.5,pointerEvents:`none`,zIndex:10,bgcolor:`grey.900`,color:`common.white`},children:(0,g.jsxs)(u.Typography,{variant:`caption`,sx:{fontFamily:`monospace`},children:[`Copied: `,R.path]})})})]})}function Q({label:e,icon:t,onClick:n,active:r,disabled:i}){return(0,g.jsx)(u.Tooltip,{title:e,arrow:!0,children:(0,g.jsx)(`span`,{children:(0,g.jsx)(u.IconButton,{size:`small`,onMouseDown:e=>e.preventDefault(),onClick:n,disabled:i,color:r?`primary`:`default`,sx:{borderRadius:1},"aria-label":e,"aria-pressed":r,children:t})})})}function Yt(e=2e3){let[t,n]=(0,d.useState)(!1),r=(0,d.useRef)(null),i=(0,d.useCallback)(()=>{r.current&&clearTimeout(r.current),n(!0),r.current=setTimeout(()=>{n(!1),r.current=null},e)},[e]);return(0,d.useEffect)(()=>()=>{r.current&&clearTimeout(r.current)},[]),[t,i]}function Xt({editorView:e,toolbarConfig:t,translation:n,indent:r,downloadFilename:i,disabled:a}){let[o,s]=Yt(),[c,l]=Yt(),d=a||!e;function f(){let t=e;if(!t)return;let n=t.state.doc.toString();try{let e=JSON.stringify(JSON.parse(n),null,r);t.dispatch({changes:{from:0,to:t.state.doc.length,insert:e}})}catch{}t.focus()}function p(){let t=e;if(!t)return;let n=t.state.doc.toString();try{let e=JSON.stringify(JSON.parse(n));t.dispatch({changes:{from:0,to:t.state.doc.length,insert:e}})}catch{}t.focus()}function m(){let t=e?.state.doc.toString()??``;navigator.clipboard.writeText(t).then(()=>{s()})}function h(){let t=e?.state.doc.toString()??``,n=new Blob([t],{type:`application/json`}),r=URL.createObjectURL(n),a=document.createElement(`a`);a.href=r,a.download=i,a.click(),URL.revokeObjectURL(r),l()}function v(){let t=e;t&&(t.dispatch({changes:{from:0,to:t.state.doc.length,insert:``}}),t.focus())}function y(){let t=e;t&&((0,C.undo)(t),t.focus())}function b(){let t=e;t&&((0,C.redo)(t),t.focus())}let x=t.showFormat||t.showCompact,S=t.showCopy||t.showDownload||t.showClear,w=t.showUndoRedo;return(0,g.jsxs)(u.Box,{sx:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:.25,px:1,py:.5},role:`toolbar`,"aria-label":`JSON editor actions`,children:[x&&(0,g.jsxs)(u.Box,{sx:{display:`flex`,gap:.25},children:[t.showFormat&&(0,g.jsx)(Q,{label:n.format,icon:(0,g.jsx)(N.default,{fontSize:`small`}),onClick:f,disabled:d}),t.showCompact&&(0,g.jsx)(Q,{label:n.compact,icon:(0,g.jsx)(P.default,{fontSize:`small`}),onClick:p,disabled:d})]}),x&&(S||w)&&(0,g.jsx)(u.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),S&&(0,g.jsxs)(u.Box,{sx:{display:`flex`,gap:.25},children:[t.showCopy&&(0,g.jsx)(Q,{label:o?n.copySuccess:n.copy,icon:o?(0,g.jsx)(A.default,{fontSize:`small`,color:`success`}):(0,g.jsx)(O.default,{fontSize:`small`}),onClick:m,disabled:d}),t.showDownload&&(0,g.jsx)(Q,{label:c?n.downloadSuccess:n.download,icon:c?(0,g.jsx)(A.default,{fontSize:`small`,color:`success`}):(0,g.jsx)(k.default,{fontSize:`small`}),onClick:h,disabled:d}),t.showClear&&(0,g.jsx)(Q,{label:n.clear,icon:(0,g.jsx)(_.default,{fontSize:`small`}),onClick:v,disabled:d})]}),S&&w&&(0,g.jsx)(u.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),w&&(0,g.jsxs)(u.Box,{sx:{display:`flex`,gap:.25},children:[(0,g.jsx)(Q,{label:n.undo,icon:(0,g.jsx)(j.default,{fontSize:`small`}),onClick:y,disabled:d}),(0,g.jsx)(Q,{label:n.redo,icon:(0,g.jsx)(M.default,{fontSize:`small`}),onClick:b,disabled:d})]}),!x&&!S&&!w&&(0,g.jsx)(u.Box,{sx:{height:32}})]})}function Zt({helperText:e,error:t,showLineColumn:n,showValidation:r,isValid:i,cursorLine:a,cursorCol:o,translation:s}){let c=s.lineColumn.replace(`{line}`,String(a)).replace(`{col}`,String(o));return(0,g.jsxs)(u.Box,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,mt:.5,px:.5},children:[(0,g.jsxs)(u.Box,{children:[r&&(0,g.jsxs)(u.Box,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[i?(0,g.jsx)(F.default,{sx:{fontSize:`0.875rem`,color:`success.main`},"data-testid":`json-valid-icon`}):(0,g.jsx)(I.default,{sx:{fontSize:`0.875rem`,color:`error.main`},"data-testid":`json-invalid-icon`}),(0,g.jsx)(u.FormHelperText,{sx:{color:i?`success.main`:`error.main`,m:0},children:i?s.validJson:s.invalidJson})]}),(0,g.jsx)(u.FormHelperText,{error:t,children:e??``})]}),n&&(0,g.jsx)(u.FormHelperText,{sx:{color:`text.disabled`,fontFamily:`monospace`,whiteSpace:`nowrap`},children:c})]})}function Qt(e){if(!(e===``||e===void 0))return typeof e==`string`&&e!==`auto`&&!isNaN(Number(e))?Number(e):e}function $t(e){if(!e.trim())return!1;try{return JSON.parse(e),!0}catch{return!1}}function en({value:e,onChange:t,onValidChange:n,placeholder:r,height:i,width:a,disabled:o=!1,readonly:s=!1,error:c=!1,helperText:l,name:f,indent:p=2,schema:m,showLineNumbers:h=!0,showLineColumn:_=!0,showMinimap:v=!1,showFolding:y=!0,showValidation:b=!1,enablePathFinder:x=!0,downloadFilename:S=`file.json`,toolbarConfig:C,translation:w,highlightColors:T,onBlur:E,onFocus:D,onPathCopy:O}){let k={...kt,...w},A={...Ot,...C},j=Qt(i),M=Qt(a),N=j===`auto`,P=N?void 0:j??300,F=(0,d.useRef)(null),[I,L]=(0,d.useState)(null),[R,z]=(0,d.useState)({line:1,col:1}),[B,V]=(0,d.useState)(()=>$t(e??``)),H=(0,d.useCallback)(e=>{F.current=e,L(e)},[]),U=(0,d.useCallback)((e,t)=>{z({line:e,col:t})},[]),W=(0,d.useCallback)(e=>{let r=$t(e);V(r),n?.(r),t?.(e)},[t,n]),G=_||b||!!l;return(0,g.jsxs)(u.Box,{sx:{width:M??`100%`,...N?{display:`flex`,flexDirection:`column`,flex:1}:{}},children:[(0,g.jsxs)(u.Paper,{variant:`outlined`,sx:{display:`flex`,flexDirection:`column`,overflow:`hidden`,...N?{flex:1}:{height:P},borderColor:c?`error.main`:void 0,"&:focus-within":{borderColor:c?`error.main`:`primary.main`,borderWidth:2}},children:[!s&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Xt,{editorView:I,toolbarConfig:A,translation:k,indent:p,downloadFilename:S,disabled:o}),(0,g.jsx)(u.Divider,{})]}),(0,g.jsx)(Jt,{value:e,onChange:W,placeholder:r,disabled:o,readonly:s,schema:m,showLineNumbers:h,showMinimap:v,showFolding:y,enablePathFinder:x,highlightColors:T,onViewReady:H,onCursorChange:U,onBlur:E,onFocus:D,onPathCopy:O})]}),G&&(0,g.jsx)(Zt,{helperText:l,error:c,showLineColumn:_,showValidation:b,isValid:B,cursorLine:R.line,cursorCol:R.col,translation:k}),f&&(0,g.jsx)(`input`,{type:`hidden`,name:f,value:e??``})]})}function tn(e){let t=new Date,n=xn(t),r=Sn(t);if(e.length===0)return{start:n,end:r};let i=e.map(e=>e.startDate.getTime()),a=e.map(e=>e.endDate.getTime()),o=ln(dn(new Date(Math.min(...i)),-1)),s=un(dn(new Date(Math.max(...a)),1));return{start:o<n?o:n,end:s>r?s:r}}function nn(e,t){return t===`weeks`?{start:_n(e.start),end:e.end}:t===`quarters`?{start:xn(e.start),end:Sn(e.end)}:e}function rn(e,t){let n=t.end.getTime()-t.start.getTime();if(n<=0)return{left:0,width:0};let r=(e.startDate.getTime()-t.start.getTime())/n*100,i=(e.endDate.getTime()-e.startDate.getTime())/n*100;return{left:Math.max(0,r),width:Math.max(0,i)}}function an(e){let t=new Map;for(let n of e)t.set(n.id,{...n,children:[],depth:0});let n=[];for(let e of t.values())e.parentId&&t.has(e.parentId)?t.get(e.parentId).children.push(e):n.push(e);return on(n,0),n}function on(e,t){for(let n of e)n.depth=t,on(n.children,t+1)}function sn(e,t){let n=[];function r(e){for(let i of e)n.push(i),i.children.length>0&&t.has(i.id)&&r(i.children)}return r(e),n}function cn(e,t){function n(e){return e.assignee===t?!0:e.children.some(n)}return e.filter(n)}function ln(e){return new Date(e.getFullYear(),e.getMonth(),1,0,0,0,0)}function un(e){return new Date(e.getFullYear(),e.getMonth()+1,0,23,59,59,999)}function dn(e,t){return new Date(e.getFullYear(),e.getMonth()+t,e.getDate())}function fn(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+t,0,0,0,0)}function pn(e){let t=new Map;for(let n of e)for(let e of n.dependencies??[])t.has(e)||t.set(e,[]),t.get(e).push(n.id);return t}function mn(e,t,n){if(n===0)return e;let r=pn(e),i=new Map(e.map(e=>[e.id,e])),a=[...r.get(t)??[]],o=new Set;for(;a.length>0;){let e=a.shift();if(o.has(e))continue;o.add(e);let t=i.get(e);i.set(e,{...t,startDate:new Date(t.startDate.getTime()+n),endDate:new Date(t.endDate.getTime()+n)}),a.push(...r.get(e)??[])}return e.map(e=>i.get(e.id))}function hn(e,t){let n=pn(e),r=new Set,i=[...n.get(t)??[]];for(;i.length>0;){let e=i.shift();r.has(e)||(r.add(e),i.push(...n.get(e)??[]))}return r}function gn(e){let t=[],n=ln(e.start);for(;n<=e.end;)t.push(n),n=dn(n,1);return t}function _n(e){let t=new Date(e),n=t.getDay(),r=n===0?-6:1-n;return t.setDate(t.getDate()+r),t.setHours(0,0,0,0),t}function vn(e){let t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())),n=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-n);let r=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-r.getTime())/864e5+1)/7)}function yn(e){let t=[],n=_n(e.start);for(;n<=e.end;)t.push(new Date(n)),n=new Date(n.getFullYear(),n.getMonth(),n.getDate()+7);return t}function bn(e){let t=[],n=new Date(e.start.getFullYear(),e.start.getMonth(),e.start.getDate(),0,0,0,0),r=new Date(e.end.getFullYear(),e.end.getMonth(),e.end.getDate(),0,0,0,0).getTime();for(;n.getTime()<=r;)t.push(new Date(n)),n=new Date(n.getFullYear(),n.getMonth(),n.getDate()+1,0,0,0,0);return t}function xn(e){let t=Math.floor(e.getMonth()/3)*3;return new Date(e.getFullYear(),t,1,0,0,0,0)}function Sn(e){let t=Math.floor(e.getMonth()/3)*3+2;return un(new Date(e.getFullYear(),t,1))}function Cn(e){let t=[],n=xn(e.start);for(;n<=e.end;){let e=Math.floor(n.getMonth()/3)+1;t.push({key:`${n.getFullYear()}-Q${e}`,label:`Q${e} ${n.getFullYear()}`,start:new Date(n)}),n=new Date(n.getFullYear(),n.getMonth()+3,1)}return t}function wn(e){if(e.length===0)return new Set;let t=new Map;for(let n of e)for(let e of n.dependencies??[])t.has(e)||t.set(e,[]),t.get(e).push(n.id);let n=new Map(e.map(e=>[e.id,e])),r=new Map,i=new Set;function a(e){if(r.has(e))return r.get(e);if(i.has(e))return n.get(e)?.endDate.getTime()??0;i.add(e);let o=n.get(e)?.endDate.getTime()??0;for(let n of t.get(e)??[])o=Math.max(o,a(n));return i.delete(e),r.set(e,o),o}for(let t of e)a(t.id);let o=Math.max(...r.values()),s=new Set;for(let t of e)a(t.id)===o&&s.add(t.id);return s}function Tn(e,t){let n=t.startDate<e.start?ln(dn(t.startDate,-1)):e.start,r=t.endDate>e.end?un(dn(t.endDate,1)):e.end;return n===e.start&&r===e.end?e:{start:n,end:r}}function En(e,t=`months`,n=!1,r,i=!1){let a=tn(e);return(0,R.createStore)((o,s)=>({tasks:e,taskTree:an(e),expandedIds:n?new Set(e.map(e=>e.id)):new Set(e.filter(e=>!e.parentId).map(e=>e.id)),timeScale:t,timelineRange:r??a,isRangeCustomized:r!==void 0,cascadeDependencies:i,defaultTimeScale:t,initialExpandAll:n,isExpandedCustomized:!1,assigneeFilter:``,setAssigneeFilter:e=>o({assigneeFilter:e}),setTasks:e=>{o(t=>({tasks:e,taskTree:an(e),...t.isRangeCustomized?{}:{timelineRange:tn(e)}}))},addTask:e=>{o(t=>{let n=[...t.tasks,e];return{tasks:n,taskTree:an(n),timelineRange:Tn(t.timelineRange,e)}})},updateTask:e=>{o(t=>{let n=t.tasks.find(t=>t.id===e.id),r=t.tasks.map(t=>t.id===e.id?e:t);if(t.cascadeDependencies&&n){let t=e.endDate.getTime()-n.endDate.getTime();r=mn(r,e.id,t)}let i=Tn(t.timelineRange,e);for(let e of r)i=Tn(i,e);return{tasks:r,taskTree:an(r),timelineRange:i}})},deleteTask:e=>{o(t=>{let n=new Set,r=e=>{n.add(e),t.tasks.filter(t=>t.parentId===e).forEach(e=>r(e.id))};r(e);let i=t.tasks.filter(e=>!n.has(e.id));return{tasks:i,taskTree:an(i)}})},toggleExpand:e=>{o(t=>{let n=new Set(t.expandedIds);return n.has(e)?n.delete(e):n.add(e),{expandedIds:n}})},expandAll:()=>{o(e=>({expandedIds:new Set(e.tasks.map(e=>e.id)),isExpandedCustomized:!0}))},collapseAll:()=>{o({expandedIds:new Set,isExpandedCustomized:!0})},setTimeScale:e=>{o({timeScale:e})},setTimelineRange:e=>{o({timelineRange:e,isRangeCustomized:!0})},resetTimelineRange:()=>{o(e=>({timelineRange:tn(e.tasks),isRangeCustomized:!1}))},resetView:()=>{o(e=>({timeScale:e.defaultTimeScale,timelineRange:tn(e.tasks),isRangeCustomized:!1,isExpandedCustomized:!1,assigneeFilter:``,expandedIds:e.initialExpandAll?new Set(e.tasks.map(e=>e.id)):new Set(e.tasks.filter(e=>!e.parentId).map(e=>e.id))}))},getVisibleTasks:()=>{let{taskTree:e,expandedIds:t}=s();return sn(e,t)}}))}var Dn={scaleDays:`Tage`,scaleWeeks:`Wochen`,scaleMonths:`Monate`,scaleQuarters:`Quartale`,rangeFrom:`Von`,rangeTo:`Bis`,rangeResetTooltip:`Bereich zurücksetzen`,columnName:`Name`,columnStatus:`Status`,statusPlanned:`Planned`,statusInProgress:`In Progress`,statusDone:`Done`,statusBlocked:`Blocked`,weekColumnPrefix:`KW`,todayLabel:`Heute`,dateLocale:`de-DE`,dialogAddTitle:`Aufgabe hinzufügen`,dialogEditTitle:`Aufgabe bearbeiten`,dialogDeleteTitle:`Aufgabe löschen`,dialogSave:`Speichern`,dialogCancel:`Abbrechen`,dialogDelete:`Löschen`,dialogFieldName:`Name`,dialogFieldStartDate:`Startdatum`,dialogFieldEndDate:`Enddatum`,dialogFieldStatus:`Status`,dialogFieldMilestone:`Ist Meilenstein`,dialogFieldParent:`Übergeordnete Aufgabe`,dialogFieldParentNone:`— Keine —`,dialogDeleteConfirm:`Soll die Aufgabe "{name}" wirklich gelöscht werden?`,dialogFieldDependencies:`Vorgänger`,dialogFieldDependenciesNone:`— Keine —`,dialogFieldProgress:`Fortschritt (%)`,filterAssigneeAll:`Alle`,filterAssigneeLabel:`Assignee`,scrollToTodayTooltip:`Zum heutigen Tag`,expandAllTooltip:`Alle aufklappen`,collapseAllTooltip:`Alle zuklappen`,resetViewTooltip:`Ansicht zurücksetzen`,columnActions:`Aktionen`,columnAssignee:`Assignee`,exportCsvTooltip:`Als CSV exportieren`,addTaskTooltip:`Aufgabe hinzufügen`,editTaskTooltip:`Aufgabe bearbeiten`,deleteTaskTooltip:`Aufgabe löschen`},On={planned:`warning.light`,"in-progress":`info.main`,done:`success.main`,blocked:`error.main`},kn={planned:`warning`,"in-progress":`info`,done:`success`,blocked:`error`};function An(e){return e.toISOString().slice(0,10)}function jn(e,t,n){return e<t?t:e>n?n:e}function Mn(e){return e.flatMap(e=>[e,...Mn(e.children)])}function Nn({label:e}){let t=(0,d.useRef)(null),[n,r]=(0,d.useState)(!1);return(0,g.jsx)(u.Tooltip,{title:e,disableHoverListener:!n,children:(0,g.jsx)(u.Typography,{ref:t,component:`span`,variant:`body2`,noWrap:!0,sx:{display:`block`,overflow:`hidden`,textOverflow:`ellipsis`,minWidth:0},onMouseEnter:()=>{t.current&&r(t.current.scrollWidth>t.current.clientWidth)},children:e})})}function Pn({open:e,mode:t,initialTask:n,defaultParentId:r,onSave:i,onClose:a}){let o=ir(),s=$(e=>e.taskTree),c=$(e=>e.timelineRange),l=(0,d.useMemo)(()=>Mn(s),[s]),f=(0,d.useMemo)(()=>{if(t===`add`||!n)return new Set;let e=t=>[t.id,...t.children.flatMap(e)],r=l.find(e=>e.id===n.id);return new Set(r?e(r):[n.id])},[t,n,l]),p=l.filter(e=>!f.has(e.id)),m=(0,d.useMemo)(()=>t===`add`||!n?new Set:hn(l,n.id),[t,n,l]),h=p.filter(e=>!m.has(e.id)),_=An(jn(new Date,c.start,c.end)),[v,y]=(0,d.useState)({name:``,startDate:_,endDate:_,status:`planned`,isMilestone:!1,progress:0,parentId:``,dependencies:[],assignee:``});(0,d.useEffect)(()=>{if(!e)return;let i=An(jn(new Date,c.start,c.end));y(t===`edit`&&n?{name:n.name,startDate:An(n.startDate),endDate:An(n.endDate),status:n.status,isMilestone:n.isMilestone??!1,progress:n.progress??0,parentId:n.parentId??``,dependencies:n.dependencies??[],assignee:n.assignee??``}:{name:``,startDate:i,endDate:i,status:`planned`,isMilestone:!1,progress:0,parentId:r??``,dependencies:[],assignee:``})},[e,t,n,r,c]);let b=e=>{y(t=>({...t,startDate:e,endDate:t.isMilestone||t.endDate<e?e:t.endDate}))},x=e=>{y(t=>({...t,endDate:e<t.startDate?t.startDate:e}))},S=e=>{y(t=>({...t,isMilestone:e,endDate:e?t.startDate:t.endDate,progress:e?0:t.progress}))},C=v.name.trim()!==``&&v.startDate!==``&&v.endDate!==``&&v.endDate>=v.startDate,w=()=>{C&&i({name:v.name.trim(),startDate:new Date(v.startDate),endDate:new Date(v.endDate),status:v.status,isMilestone:v.isMilestone||void 0,progress:v.progress>0?v.progress:void 0,parentId:v.parentId||void 0,dependencies:v.dependencies.length>0?v.dependencies:void 0,assignee:v.assignee.trim()||void 0})},T=[`planned`,`in-progress`,`done`,`blocked`],E={planned:o.statusPlanned,"in-progress":o.statusInProgress,done:o.statusDone,blocked:o.statusBlocked};return(0,g.jsxs)(u.Dialog,{open:e,onClose:a,maxWidth:`xs`,fullWidth:!0,"data-testid":`gantt-task-dialog`,children:[(0,g.jsx)(u.DialogTitle,{children:t===`add`?o.dialogAddTitle:o.dialogEditTitle}),(0,g.jsxs)(u.DialogContent,{sx:{display:`flex`,flexDirection:`column`,gap:2,pt:`16px !important`},children:[(0,g.jsx)(u.TextField,{label:o.dialogFieldName,value:v.name,onChange:e=>y(t=>({...t,name:e.target.value})),required:!0,fullWidth:!0,size:`small`,autoFocus:!0,slotProps:{htmlInput:{"data-testid":`gantt-dialog-field-name`}}}),(0,g.jsx)(u.TextField,{label:o.columnAssignee,value:v.assignee,onChange:e=>y(t=>({...t,assignee:e.target.value})),fullWidth:!0,size:`small`,placeholder:`e.g. Jane Smith`,slotProps:{htmlInput:{"data-testid":`gantt-dialog-field-assignee`}}}),(0,g.jsx)(u.TextField,{label:o.dialogFieldStartDate,type:`date`,value:v.startDate,onChange:e=>b(e.target.value),required:!0,fullWidth:!0,size:`small`,slotProps:{inputLabel:{shrink:!0},htmlInput:{"data-testid":`gantt-dialog-field-start`}}}),(0,g.jsx)(u.TextField,{label:o.dialogFieldEndDate,type:`date`,value:v.endDate,onChange:e=>x(e.target.value),required:!0,fullWidth:!0,size:`small`,disabled:v.isMilestone,slotProps:{inputLabel:{shrink:!0},htmlInput:{"data-testid":`gantt-dialog-field-end`,min:v.startDate}}}),(0,g.jsxs)(u.FormControl,{size:`small`,fullWidth:!0,children:[(0,g.jsx)(u.InputLabel,{children:o.dialogFieldStatus}),(0,g.jsx)(u.Select,{value:v.status,label:o.dialogFieldStatus,onChange:e=>y(t=>({...t,status:e.target.value})),inputProps:{"data-testid":`gantt-dialog-field-status`},children:T.map(e=>(0,g.jsx)(u.MenuItem,{value:e,children:E[e]},e))})]}),(0,g.jsxs)(u.Box,{"data-testid":`gantt-dialog-field-progress-wrapper`,children:[(0,g.jsxs)(u.Box,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`baseline`,mb:.25},children:[(0,g.jsx)(u.Typography,{variant:`caption`,color:v.isMilestone?`text.disabled`:`text.secondary`,children:o.dialogFieldProgress??`Fortschritt (%)`}),(0,g.jsxs)(u.Typography,{variant:`caption`,sx:{fontWeight:600},color:v.isMilestone?`text.disabled`:`text.primary`,children:[v.progress,` %`]})]}),(0,g.jsx)(u.Slider,{value:v.progress,onChange:(e,t)=>y(e=>({...e,progress:t})),min:0,max:100,step:1,disabled:v.isMilestone,size:`small`,marks:[{value:0},{value:25},{value:50},{value:75},{value:100}],"aria-label":o.dialogFieldProgress??`Fortschritt (%)`,"data-testid":`gantt-dialog-field-progress`})]}),(0,g.jsx)(u.FormControlLabel,{control:(0,g.jsx)(u.Checkbox,{checked:v.isMilestone,onChange:e=>S(e.target.checked),size:`small`,"data-testid":`gantt-dialog-field-milestone`}),label:o.dialogFieldMilestone}),(0,g.jsxs)(u.FormControl,{size:`small`,fullWidth:!0,children:[(0,g.jsx)(u.InputLabel,{children:o.dialogFieldParent}),(0,g.jsxs)(u.Select,{value:v.parentId,label:o.dialogFieldParent,onChange:e=>y(t=>({...t,parentId:e.target.value})),inputProps:{"data-testid":`gantt-dialog-field-parent`},MenuProps:{slotProps:{paper:{sx:{maxHeight:280}}}},children:[(0,g.jsx)(u.MenuItem,{value:``,children:o.dialogFieldParentNone}),p.map(e=>(0,g.jsx)(u.MenuItem,{value:e.id,sx:{minWidth:0},children:(0,g.jsxs)(u.Box,{sx:{display:`flex`,alignItems:`center`,pl:e.depth*2,gap:.75,minWidth:0,width:`100%`,overflow:`hidden`},children:[e.depth>0&&(0,g.jsx)(u.Typography,{component:`span`,variant:`caption`,sx:{color:`text.disabled`,lineHeight:1,flexShrink:0},children:`└`}),(0,g.jsx)(Nn,{label:e.name})]})},e.id))]})]}),(0,g.jsxs)(u.FormControl,{size:`small`,fullWidth:!0,children:[(0,g.jsx)(u.InputLabel,{children:o.dialogFieldDependencies}),(0,g.jsx)(u.Select,{multiple:!0,value:v.dependencies,label:o.dialogFieldDependencies,onChange:e=>{let t=e.target.value;y(e=>({...e,dependencies:typeof t==`string`?t.split(`,`):t}))},inputProps:{"data-testid":`gantt-dialog-field-dependencies`},renderValue:e=>e.length===0?o.dialogFieldDependenciesNone:e.map(e=>l.find(t=>t.id===e)?.name??e).join(`, `),MenuProps:{slotProps:{paper:{sx:{maxHeight:280}}}},children:h.map(e=>(0,g.jsx)(u.MenuItem,{value:e.id,sx:{minWidth:0},children:(0,g.jsxs)(u.Box,{sx:{display:`flex`,alignItems:`center`,pl:e.depth*2,gap:.75,minWidth:0,width:`100%`,overflow:`hidden`},children:[e.depth>0&&(0,g.jsx)(u.Typography,{component:`span`,variant:`caption`,sx:{color:`text.disabled`,lineHeight:1,flexShrink:0},children:`└`}),(0,g.jsx)(Nn,{label:e.name})]})},e.id))})]})]}),(0,g.jsxs)(u.DialogActions,{children:[(0,g.jsx)(u.Button,{onClick:a,children:o.dialogCancel}),(0,g.jsx)(u.Button,{onClick:w,variant:`contained`,disabled:!C,"data-testid":`gantt-dialog-save`,children:o.dialogSave})]})]})}function Fn({open:e,task:t,onConfirm:n,onClose:r}){let i=ir(),a=i.dialogDeleteConfirm.replace(`{name}`,t?.name??``);return(0,g.jsxs)(u.Dialog,{open:e,onClose:r,maxWidth:`xs`,fullWidth:!0,"data-testid":`gantt-delete-dialog`,children:[(0,g.jsx)(u.DialogTitle,{children:i.dialogDeleteTitle}),(0,g.jsx)(u.DialogContent,{children:(0,g.jsx)(u.DialogContentText,{children:a})}),(0,g.jsxs)(u.DialogActions,{children:[(0,g.jsx)(u.Button,{onClick:r,children:i.dialogCancel}),(0,g.jsx)(u.Button,{onClick:n,variant:`contained`,color:`error`,"data-testid":`gantt-dialog-delete-confirm`,children:i.dialogDelete})]})]})}function In(e,t){return{planned:t.statusPlanned,"in-progress":t.statusInProgress,done:t.statusDone,blocked:t.statusBlocked}[e]}function Ln({task:e,expandedIds:t,toggleExpand:n,hasActionsColumn:r,showAssigneeColumn:i,onTaskClick:a,onAddTask:o,onEditTask:s,onDeleteTask:c,onStatusChange:l,inlineEdit:f,onInlineRename:p,isSelected:m,onSelect:h}){let[y,b]=(0,d.useState)(null),[x,S]=(0,d.useState)(null),C=ir(),{statusColors:w}=or(),T=()=>{x!==null&&x.trim()&&p?.(e,x.trim()),S(null)};return(0,g.jsxs)(u.Box,{className:`gantt-task-row`,"data-testid":`gantt-task-row-${e.id}`,"aria-selected":m??!1,sx:{height:40,display:`flex`,alignItems:`center`,overflow:`hidden`,borderBottom:`1px solid`,borderRight:`1px solid`,borderColor:`divider`,cursor:a?`pointer`:`default`,bgcolor:m?`action.selected`:void 0,boxShadow:m?e=>`inset 3px 0 0 ${e.palette.primary.main}`:void 0,"&:hover":{bgcolor:m?`action.selected`:a?`action.hover`:void 0}},onClick:()=>{h?.(),a?.(e)},children:[(0,g.jsxs)(u.Box,{sx:{flex:1,minWidth:0,display:`flex`,alignItems:`center`,gap:.75,pl:1+e.depth*2,pr:.5,height:`100%`},children:[(0,g.jsx)(u.Box,{sx:{width:16,flexShrink:0,display:`flex`,justifyContent:`center`},children:e.children.length>0&&(0,g.jsx)(u.Box,{component:`span`,sx:{fontSize:9,userSelect:`none`,cursor:`pointer`},onClick:t=>{t.stopPropagation(),n(e.id)},children:t.has(e.id)?`▼`:`▶`})}),(0,g.jsx)(u.Box,{sx:{width:8,height:8,borderRadius:e.isMilestone?0:`50%`,transform:e.isMilestone?`rotate(45deg)`:void 0,flexShrink:0,bgcolor:e.color??w?.[e.status]??On[e.status]??`grey.400`}}),x===null?(0,g.jsx)(u.Typography,{variant:`body2`,noWrap:!0,sx:{flex:1,minWidth:0,cursor:f?`text`:`inherit`},onDoubleClick:f?t=>{t.stopPropagation(),S(e.name)}:void 0,children:e.name}):(0,g.jsx)(u.TextField,{size:`small`,variant:`standard`,value:x,autoFocus:!0,onChange:e=>S(e.target.value),onBlur:T,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),T()),e.key===`Escape`&&(e.stopPropagation(),S(null))},onClick:e=>e.stopPropagation(),sx:{flex:1,minWidth:0},slotProps:{htmlInput:{"data-testid":`gantt-inline-edit-${e.id}`}}})]}),i&&(0,g.jsx)(u.Box,{sx:{width:110,flexShrink:0,display:`flex`,alignItems:`center`,px:1,overflow:`hidden`},children:(0,g.jsx)(u.Typography,{variant:`caption`,noWrap:!0,color:e.assignee?`text.primary`:`text.disabled`,children:e.assignee??`—`})}),r&&(0,g.jsxs)(u.Box,{className:`gantt-row-actions`,sx:{width:96,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`flex-end`,pr:.5},children:[s&&(0,g.jsx)(u.Tooltip,{title:C.editTaskTooltip,children:(0,g.jsx)(u.IconButton,{size:`small`,"aria-label":C.editTaskTooltip,"data-testid":`gantt-edit-task-${e.id}`,onClick:t=>{t.stopPropagation(),s(e)},children:(0,g.jsx)(B.default,{fontSize:`inherit`})})}),o&&(0,g.jsx)(u.Tooltip,{title:C.addTaskTooltip,children:(0,g.jsx)(u.IconButton,{size:`small`,"aria-label":C.addTaskTooltip,"data-testid":`gantt-add-task-${e.id}`,onClick:t=>{t.stopPropagation(),o(e)},children:(0,g.jsx)(v.default,{fontSize:`inherit`})})}),c&&(0,g.jsx)(u.Tooltip,{title:C.deleteTaskTooltip,children:(0,g.jsx)(u.IconButton,{size:`small`,"aria-label":C.deleteTaskTooltip,"data-testid":`gantt-delete-task-${e.id}`,onClick:t=>{t.stopPropagation(),c(e)},children:(0,g.jsx)(_.default,{fontSize:`inherit`})})})]}),(0,g.jsxs)(u.Box,{sx:{width:90,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`},children:[(0,g.jsx)(u.Chip,{label:In(e.status,C),size:`small`,variant:`outlined`,color:e.color??w?.[e.status]?`default`:kn[e.status]??`default`,sx:{height:20,fontSize:10,cursor:l?`pointer`:`default`,...(e.color??w?.[e.status])&&{borderColor:e.color??w?.[e.status],color:e.color??w?.[e.status]}},onClick:l?e=>{e.stopPropagation(),b(e.currentTarget)}:void 0}),l&&(0,g.jsx)(u.Menu,{anchorEl:y,open:!!y,onClose:()=>b(null),children:[`planned`,`in-progress`,`done`,`blocked`].map(t=>(0,g.jsx)(u.MenuItem,{selected:e.status===t,onClick:()=>{l(e,t),b(null)},children:In(t,C)},t))})]})]})}function Rn({scrollRef:e,onScroll:t,panelWidth:n,onTaskClick:r,onAddTask:i,onEditTask:a,onDeleteTask:o,onStatusChange:s,onTasksChange:c,enableBuiltinDialogs:l,onTaskCreated:f,onTaskUpdated:p,onTaskDeleted:m,inlineEdit:h,virtualizeRows:_=!1,showAssigneeColumn:v=!1}){let y=ir(),b=nr(),x=$(e=>e.taskTree),S=$(e=>e.expandedIds),C=$(e=>e.toggleExpand),w=$(e=>e.timeScale),T=$(e=>e.addTask),E=$(e=>e.updateTask),D=$(e=>e.deleteTask),O=$(e=>e.assigneeFilter),k=(0,d.useMemo)(()=>{let e=sn(x,S);return O?cn(e,O):e},[x,S,O]),A=(0,z.useVirtualizer)({count:k.length,getScrollElement:()=>e.current,estimateSize:()=>40,overscan:5}),[j,M]=(0,d.useState)(!1),[N,P]=(0,d.useState)(!1),[F,I]=(0,d.useState)(!1),[L,R]=(0,d.useState)(null),B=e=>{let t={...e,id:crypto.randomUUID()};T(t),c?.(b.getState().tasks),f?.(t),M(!1)},V=e=>{if(!L)return;let t={...e,id:L.id};E(t),c?.(b.getState().tasks),p?.(t),P(!1)},H=()=>{L&&(D(L.id),c?.(b.getState().tasks),m?.(L.id),I(!1))},U=(e,t)=>{let n={...e,name:t};E(n),c?.(b.getState().tasks),p?.(n)},W=l?e=>{R(e),M(!0)}:i,G=l?e=>{R(e),P(!0)}:a,K=l?e=>{R(e),I(!0)}:o,q=!!(W||G||K),J=w===`days`?80:40,[ee,te]=(0,d.useState)(null),Y=ee?k.findIndex(e=>e.id===ee):-1;(0,d.useEffect)(()=>{if(Y<0||!e.current)return;let t=e.current,n=J+Y*40,r=n+40;n<t.scrollTop?t.scrollTop=n:r>t.scrollTop+t.clientHeight&&(t.scrollTop=r-t.clientHeight)},[Y,J,e]);function X(e){if(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement)return;let t=k.length;t!==0&&(e.key===`ArrowDown`?(e.preventDefault(),te(k[Math.min(Y<0?0:Y+1,t-1)].id)):e.key===`ArrowUp`?(e.preventDefault(),te(k[Math.max(Y<=0?0:Y-1,0)].id)):e.key===`Enter`&&Y>=0?(e.preventDefault(),G?.(k[Y])):e.key===`Escape`&&te(null))}return(0,g.jsxs)(u.Box,{ref:e,onScroll:t,tabIndex:0,"data-testid":`gantt-task-panel`,onKeyDown:X,sx:{width:n,flexShrink:0,overflowY:`auto`,overflowX:`hidden`,outline:`none`},children:[(0,g.jsxs)(u.Box,{sx:{height:J,position:`sticky`,top:0,bgcolor:`background.paper`,zIndex:1,borderBottom:`1px solid`,borderRight:`1px solid`,borderColor:`divider`,display:`flex`,flexDirection:`column`},children:[(0,g.jsxs)(u.Box,{sx:{height:40,display:`flex`,alignItems:`center`,overflow:`hidden`,borderBottom:w===`days`?`1px solid`:void 0,borderColor:w===`days`?`divider`:void 0},children:[(0,g.jsx)(u.Box,{sx:{flex:1,minWidth:0,pl:2},children:(0,g.jsx)(u.Typography,{variant:`caption`,color:`text.secondary`,children:y.columnName})}),v&&(0,g.jsx)(u.Box,{sx:{width:110,flexShrink:0,display:`flex`,alignItems:`center`,px:1},children:(0,g.jsx)(u.Typography,{variant:`caption`,color:`text.secondary`,children:y.columnAssignee})}),q&&(0,g.jsx)(u.Box,{sx:{width:96,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,g.jsx)(u.Typography,{variant:`caption`,color:`text.secondary`,children:y.columnActions})}),(0,g.jsx)(u.Box,{sx:{width:90,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,g.jsx)(u.Typography,{variant:`caption`,color:`text.secondary`,children:y.columnStatus})})]}),w===`days`&&(0,g.jsx)(u.Box,{sx:{flex:1}})]}),_?(0,g.jsx)(u.Box,{sx:{position:`relative`,height:A.getTotalSize()},children:A.getVirtualItems().map(e=>(0,g.jsx)(u.Box,{style:{position:`absolute`,top:0,left:0,width:`100%`,height:40,transform:`translateY(${e.start}px)`},children:(0,g.jsx)(Ln,{task:k[e.index],expandedIds:S,toggleExpand:C,hasActionsColumn:q,showAssigneeColumn:v,onTaskClick:r,onAddTask:W,onEditTask:G,onDeleteTask:K,onStatusChange:s,inlineEdit:h,onInlineRename:h?U:void 0,isSelected:k[e.index].id===ee,onSelect:()=>te(k[e.index].id)})},e.key))}):k.map(e=>(0,g.jsx)(Ln,{task:e,expandedIds:S,toggleExpand:C,hasActionsColumn:q,showAssigneeColumn:v,onTaskClick:r,onAddTask:W,onEditTask:G,onDeleteTask:K,onStatusChange:s,inlineEdit:h,onInlineRename:h?U:void 0,isSelected:e.id===ee,onSelect:()=>te(e.id)},e.id)),l&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Pn,{open:j,mode:`add`,defaultParentId:L?.id,onSave:B,onClose:()=>M(!1)}),(0,g.jsx)(Pn,{open:N,mode:`edit`,initialTask:L??void 0,onSave:V,onClose:()=>P(!1)}),(0,g.jsx)(Fn,{open:F,task:L,onConfirm:H,onClose:()=>I(!1)})]})]})}var zn=864e5;function Bn({totalWidth:e,displayRange:t,onDragStart:n,onTaskMoved:r,onTaskResized:i,onTasksChange:a}){let o=$(e=>e.updateTask),s=nr(),c=ir(),l=(0,d.useRef)(1),u=(0,d.useRef)(n),f=(0,d.useRef)(r),p=(0,d.useRef)(i),m=(0,d.useRef)(a);(0,d.useLayoutEffect)(()=>{l.current=e>0?e/((t.end.getTime()-t.start.getTime())/zn):1,u.current=n,f.current=r,p.current=i,m.current=a});let h=(0,d.useRef)(null),g=(0,d.useRef)(null),[_,v]=(0,d.useState)(null),y=(0,d.useRef)(!1),b=(0,d.useRef)(null);return(0,d.useEffect)(()=>()=>{b.current?.()},[]),{activeDrag:_,suppressClickRef:y,handleBarMouseDown:(e,t,n)=>{e.stopPropagation(),y.current=!1,h.current={type:n,taskId:t.id,startX:e.clientX,originalStart:t.startDate,originalEnd:t.endDate},n!==`progress`&&u.current?.(t,n),document.body.style.cursor=n===`resize`?`ew-resize`:`grabbing`;let r=e=>{let t=h.current;if(!t||t.type===`progress`)return;let n=e.clientX-t.startX,r=Math.round(n/l.current);Math.abs(n)>=5&&(y.current=!0);let i={taskId:t.taskId,type:t.type,deltaDays:r};g.current=i,v(i)},i=()=>{document.body.style.cursor=``;let e=h.current,t=g.current;if(e&&t&&y.current&&t.deltaDays!==0){let n=s.getState().tasks.find(t=>t.id===e.taskId);if(n){if(t.type===`move`){let r=fn(e.originalStart,t.deltaDays),i=fn(e.originalEnd,t.deltaDays);o({...n,startDate:r,endDate:i}),f.current?.(n,r,i)}else{let r=fn(e.originalEnd,t.deltaDays),i=r>e.originalStart?r:fn(e.originalStart,1);o({...n,endDate:i}),p.current?.(n,i)}m.current?.(s.getState().tasks)}}h.current=null,g.current=null,v(null),document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i),b.current=null};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i),b.current=()=>{document.body.style.cursor=``,document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i)}},handleProgressMouseDown:(e,t,n,r)=>{e.stopPropagation(),y.current=!1,h.current={type:`progress`,taskId:t.id,startX:e.clientX,originalStart:t.startDate,originalEnd:t.endDate,initialProgress:n,barWidthPx:r},document.body.style.cursor=`ew-resize`;let i=e=>{let t=h.current;if(!t||t.type!==`progress`)return;let n=e.clientX-t.startX;Math.abs(n)>=5&&(y.current=!0);let r=n/(t.barWidthPx??1)*100,i=Math.round(Math.max(0,Math.min(100,(t.initialProgress??0)+r))),a={taskId:t.taskId,type:`progress`,deltaDays:0,newProgress:i};g.current=a,v(a)},a=()=>{document.body.style.cursor=``;let e=h.current,t=g.current;if(e&&t&&t.type===`progress`&&t.newProgress!==void 0&&y.current){let n=s.getState().tasks.find(t=>t.id===e.taskId);n&&(o({...n,progress:t.newProgress}),m.current?.(s.getState().tasks))}h.current=null,g.current=null,v(null),document.removeEventListener(`mousemove`,i),document.removeEventListener(`mouseup`,a),b.current=null};document.addEventListener(`mousemove`,i),document.addEventListener(`mouseup`,a),b.current=()=>{document.body.style.cursor=``,document.removeEventListener(`mousemove`,i),document.removeEventListener(`mouseup`,a)}},formatDragDate:e=>e.toLocaleDateString(c.dateLocale,{day:`2-digit`,month:`short`})}}function Vn({items:e}){return(0,g.jsx)(u.Box,{sx:{display:`flex`},children:e.map(e=>(0,g.jsx)(u.Box,{sx:{width:e.width,flexShrink:0,height:40,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRight:`1px solid`,borderColor:`divider`,bgcolor:e.isWeekend?`action.hover`:`transparent`},children:(0,g.jsx)(u.Typography,{variant:`caption`,color:e.isWeekend?`text.disabled`:`text.secondary`,children:e.label})},e.key))})}function Hn({columns:e,groups:t,todayX:n,todayLabel:r,todayTooltip:i,todayColor:a}){let o=(0,u.useTheme)(),s=t?80:40,c=a||o.palette.primary.main,l=o.palette.getContrastText(c);return(0,g.jsxs)(u.Box,{sx:{position:`sticky`,top:0,bgcolor:`background.paper`,zIndex:1,borderBottom:`1px solid`,borderColor:`divider`,height:s,overflow:`visible`},children:[t&&(0,g.jsx)(u.Box,{sx:{height:40,borderBottom:`1px solid`,borderColor:`divider`,overflow:`visible`},children:(0,g.jsx)(Vn,{items:t})}),(0,g.jsx)(Vn,{items:e}),n!=null&&r&&(0,g.jsx)(u.Tooltip,{title:i??``,placement:`top`,arrow:!0,children:(0,g.jsx)(u.Chip,{"data-testid":`gantt-today-chip`,size:`small`,label:r,sx:{position:`absolute`,bottom:0,left:n,transform:`translateX(-50%) translateY(50%)`,zIndex:3,height:20,fontSize:`0.65rem`,fontWeight:700,letterSpacing:`0.03em`,backgroundColor:c,color:l,border:`1.5px solid ${c}`,boxShadow:o.shadows[2],cursor:`default`,userSelect:`none`,"& .MuiChip-label":{px:`6px`,py:0},"&:hover":{backgroundColor:c,opacity:.9}}})})]})}function Un({task:e,virtualTop:t,activeDrag:n,displayRange:r,totalWidth:i,gridColumnWidth:a,criticalTaskIds:o,draggable:s=!1,resizable:c=!1,progressDraggable:l=!1,onTaskClick:d,onMilestoneClick:f,onContextMenu:p,suppressClickRef:m,handleBarMouseDown:h,handleProgressMouseDown:_,formatDragDate:v}){let y=(0,u.useTheme)(),{statusColors:b,criticalPathColor:x,milestoneColor:S,barBorderRadius:C}=or(),w=n?.taskId===e.id,T=e;if(w&&n)if(n.type===`move`)T={...e,startDate:fn(e.startDate,n.deltaDays),endDate:fn(e.endDate,n.deltaDays)};else if(n.type===`resize`){let t=fn(e.endDate,n.deltaDays);T={...e,endDate:t>e.startDate?t:fn(e.startDate,1)}}else n.type===`progress`&&n.newProgress!==void 0&&(T={...e,progress:n.newProgress});let{left:E,width:D}=rn(T,r);return(0,g.jsx)(u.Box,{"data-testid":`gantt-bar-row-${e.id}`,style:t===void 0?void 0:{position:`absolute`,top:t,left:0,width:`100%`},sx:{height:40,position:`relative`,borderBottom:`1px solid`,borderColor:`divider`,backgroundImage:e=>`linear-gradient(to right, transparent calc(${a}px - 1px), ${e.palette.divider} calc(${a}px - 1px), ${e.palette.divider} ${a}px)`,backgroundSize:`${a}px 100%`,backgroundRepeat:`repeat-x`},children:e.isMilestone?(0,g.jsx)(Wn,{task:e,left:E,milestoneColor:S,criticalPathColor:x,isCritical:o.has(e.id),onMilestoneClick:f,theme:y}):(0,g.jsx)(Gn,{task:e,effectiveTask:T,left:E,width:D,totalWidth:i,isDragging:w,activeDrag:n,draggable:s,resizable:c,progressDraggable:l,isCritical:o.has(e.id),statusColors:b,criticalPathColor:x,barBorderRadius:C,onTaskClick:d,onContextMenu:p,suppressClickRef:m,handleBarMouseDown:h,handleProgressMouseDown:_,formatDragDate:v,theme:y})})}function Wn({task:e,left:t,milestoneColor:n,criticalPathColor:r,isCritical:i,onMilestoneClick:a,theme:o}){return t<0||t>100?null:(0,g.jsx)(u.Box,{"data-testid":`gantt-milestone-${e.id}`,sx:{position:`absolute`,left:`${t}%`,top:`50%`,width:12,height:12,bgcolor:n||`warning.main`,transform:`translate(-50%, -50%) rotate(45deg)`,cursor:a?`pointer`:`default`,boxShadow:i?`0 0 0 2.5px ${r||o.palette.error.main}`:void 0,"&:hover":a?{opacity:.8}:void 0},onClick:()=>a?.(e)})}function Gn({task:e,effectiveTask:t,left:n,width:r,totalWidth:i,isDragging:a,activeDrag:o,draggable:s,resizable:c,progressDraggable:l,isCritical:d,statusColors:f,criticalPathColor:p,barBorderRadius:m,onTaskClick:h,onContextMenu:_,suppressClickRef:v,handleBarMouseDown:y,handleProgressMouseDown:b,formatDragDate:x,theme:S}){let C=Math.max(0,n),w=Math.min(100,n+Math.max(r,.5))-C;return w<=0?null:(0,g.jsxs)(g.Fragment,{children:[a&&o&&o.type!==`progress`&&o.deltaDays!==0&&(0,g.jsx)(Kn,{left:C,children:o.type===`move`?`${x(t.startDate)} – ${x(t.endDate)}`:`→ ${x(t.endDate)}`}),a&&o?.type===`progress`&&o.newProgress!==void 0&&(0,g.jsxs)(Kn,{left:C,children:[o.newProgress,`%`]}),(0,g.jsxs)(u.Box,{"data-testid":`gantt-bar-${e.id}`,sx:{position:`absolute`,left:`${C}%`,width:`${w}%`,height:16,top:`50%`,transform:`translateY(-50%)`,bgcolor:e.color??f?.[e.status]??On[e.status]??`grey.300`,borderRadius:m===void 0?1:`${m}px`,overflow:`hidden`,opacity:a?.75:1,boxShadow:d?`inset 0 0 0 2.5px ${p||S.palette.error.main}`:void 0,cursor:a?`grabbing`:s?`grab`:h?`pointer`:`default`,userSelect:`none`,"&:hover":s||h?{opacity:a?.75:.8}:void 0},onMouseDown:s?t=>y(t,e,`move`):void 0,onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),_(e,t.clientX,t.clientY)},onClick:()=>{if(v.current){v.current=!1;return}h?.(e)},children:[t.progress!==void 0&&t.progress>0&&(0,g.jsx)(u.Box,{"data-testid":`gantt-progress-${e.id}`,sx:{position:`absolute`,left:0,top:0,width:`${Math.min(t.progress,100)}%`,height:`100%`,bgcolor:`currentColor`,opacity:.4}}),l&&(0,g.jsx)(u.Box,{"data-testid":`gantt-progress-handle-${e.id}`,sx:{position:`absolute`,left:`${Math.min(t.progress??0,100)}%`,top:0,width:6,height:`100%`,transform:`translateX(-50%)`,cursor:`ew-resize`,bgcolor:`rgba(255,255,255,0.35)`},onMouseDown:n=>{n.stopPropagation();let r=w/100*i;b(n,e,t.progress??0,r)}}),c&&(0,g.jsx)(u.Box,{"data-testid":`gantt-resize-handle-${e.id}`,sx:{position:`absolute`,right:0,top:0,width:6,height:`100%`,cursor:`ew-resize`},onMouseDown:t=>{t.stopPropagation(),y(t,e,`resize`)}})]})]})}function Kn({left:e,children:t}){return(0,g.jsx)(u.Box,{sx:{position:`absolute`,left:`${e}%`,top:2,bgcolor:`grey.800`,color:`common.white`,borderRadius:.5,px:.75,lineHeight:`18px`,fontSize:`0.65rem`,whiteSpace:`nowrap`,pointerEvents:`none`,zIndex:100},children:t})}function qn({strips:e,totalWidth:t,height:n,top:r}){let{weekendColor:i}=or();return e.length===0?null:(0,g.jsx)(u.Box,{"aria-hidden":!0,"data-testid":`gantt-weekend-strips`,sx:{position:`absolute`,top:r,left:0,width:t,height:n,pointerEvents:`none`},children:e.map(e=>(0,g.jsx)(u.Box,{sx:{position:`absolute`,left:e.left,width:20,top:0,height:`100%`,bgcolor:i||`action.hover`}},e.key))})}function Jn({contextMenu:e,onClose:t,onSelect:n}){let r=ir(),i={planned:r.statusPlanned,"in-progress":r.statusInProgress,done:r.statusDone,blocked:r.statusBlocked};return(0,g.jsx)(u.Menu,{open:e!==null,onClose:t,anchorReference:`anchorPosition`,anchorPosition:e===null?void 0:{top:e.mouseY,left:e.mouseX},children:[`planned`,`in-progress`,`done`,`blocked`].map(t=>(0,g.jsx)(u.MenuItem,{selected:e?.task.status===t,"data-testid":`gantt-status-menu-${t}`,onClick:()=>{e&&n(e.task,t)},children:i[t]},t))})}function Yn({dependencyLines:e,todayX:t,totalWidth:n,height:r,top:i,arrowMarkerId:a}){let o=(0,u.useTheme)(),{todayLineColor:s}=or();return e.length===0&&t===null?null:(0,g.jsxs)(`svg`,{"data-testid":`gantt-dependency-arrows`,style:{position:`absolute`,top:i,left:0,width:n,height:r,pointerEvents:`none`,overflow:`visible`},children:[e.length>0&&(0,g.jsx)(`defs`,{children:(0,g.jsx)(`marker`,{id:a,markerWidth:`6`,markerHeight:`4`,refX:`5`,refY:`2`,orient:`auto`,children:(0,g.jsx)(`polygon`,{points:`0 0, 6 2, 0 4`,fill:`currentColor`})})}),e.map(e=>(0,g.jsx)(`path`,{"data-testid":`gantt-dep-${e.key}`,d:e.d,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeOpacity:.4,markerEnd:`url(#${a})`},e.key)),t!==null&&(0,g.jsx)(`line`,{"data-testid":`gantt-today-line`,x1:t,y1:0,x2:t,y2:r,stroke:s||o.palette.primary.main,strokeWidth:1.5,strokeDasharray:`4 2`})]})}function Xn(e,t,n){if(n===0)return[];let r=[],i=new Map(e.map((e,t)=>[e.id,t]));for(let a of e){if(!a.dependencies?.length)continue;let o=i.get(a.id),s=rn(a,t).left/100*n,c=o*40+40/2;for(let o of a.dependencies){let l=i.get(o);if(l===void 0)continue;let u=e[l],d=rn(u,t),f=(d.left+d.width)/100*n,p=l*40+40/2,m;m=s>=f+48?(f+s)/2:f+24<=n-8?f+24:Math.max(s-24,8),r.push({key:`${o}-${a.id}`,d:`M ${f} ${p} H ${m} V ${c} H ${s}`})}}return r}function Zn({scrollRef:e,onScroll:t,onTaskClick:n,onMilestoneClick:r,draggable:i=!1,resizable:a=!1,progressDraggable:o=!1,showCriticalPath:s=!1,virtualizeRows:c=!1,onDragStart:l,onTaskMoved:f,onTaskResized:p,onTasksChange:m,onStatusChange:h}){let _=$(e=>e.taskTree),v=$(e=>e.tasks),y=$(e=>e.expandedIds),b=$(e=>e.timelineRange),x=$(e=>e.timeScale),S=$(e=>e.updateTask),C=nr(),w=ir(),T=(0,u.useTheme)(),{todayLineColor:E}=or(),D=`gantt-arrow-${(0,d.useId)().replace(/:/g,``)}`,O=$(e=>e.assigneeFilter),k=(0,d.useMemo)(()=>{let e=sn(_,y);return O?cn(e,O):e},[_,y,O]),A=(0,d.useMemo)(()=>nn(b,x),[b,x]),j=(0,d.useMemo)(()=>x===`days`?bn(A).map(e=>({key:e.toISOString(),label:String(e.getDate()),width:20,isWeekend:e.getDay()===0||e.getDay()===6})):x===`weeks`?yn(A).map(e=>({key:e.toISOString(),label:`${w.weekColumnPrefix}${vn(e)}`,width:40})):x===`quarters`?Cn(A).map(e=>({key:e.key,label:e.label,width:360})):gn(A).map(e=>({key:e.toISOString(),label:e.toLocaleString(w.dateLocale,{month:`short`,year:`2-digit`}),width:120})),[x,A,w.weekColumnPrefix,w.dateLocale]),M=(0,d.useMemo)(()=>j.reduce((e,t)=>e+t.width,0),[j]),N=(0,d.useMemo)(()=>{if(x!==`days`)return;let e=new Map;for(let t of j){let n=new Date(t.key),r=`${n.getFullYear()}-${n.getMonth()}`;e.has(r)||e.set(r,{label:n.toLocaleString(w.dateLocale,{month:`short`,year:`2-digit`}),width:0}),e.get(r).width+=20}return Array.from(e.entries()).map(([e,t])=>({key:e,...t}))},[x,j,w.dateLocale]),P=(0,d.useMemo)(()=>Xn(k,A,M),[k,A,M]),F=(0,d.useMemo)(()=>s?wn(v):new Set,[s,v]),I=(0,z.useVirtualizer)({count:k.length,getScrollElement:()=>e.current,estimateSize:()=>40,overscan:5}),L=(0,d.useMemo)(()=>{if(x!==`days`)return[];let e=0;return j.flatMap(t=>{let n=t.isWeekend?[{key:t.key,left:e}]:[];return e+=t.width,n})},[x,j]),R=(0,d.useMemo)(()=>{let e=Date.now(),t=A.start.getTime(),n=A.end.getTime();return e<t||e>n?null:(e-t)/(n-t)*M},[A,M]),B=(0,d.useMemo)(()=>new Date().toLocaleDateString(w.dateLocale,{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`}),[w.dateLocale]),V=E||T.palette.primary.main;(0,d.useEffect)(()=>{if(R===null||!e.current)return;let t=e.current.clientWidth;e.current.scrollLeft=Math.max(0,R-t/2)},[]);let H=x===`days`?20:x===`weeks`?40:x===`quarters`?360:120,U=N?80:40,{activeDrag:W,suppressClickRef:G,handleBarMouseDown:K,handleProgressMouseDown:q,formatDragDate:J}=Bn({totalWidth:M,displayRange:A,onDragStart:l,onTaskMoved:f,onTaskResized:p,onTasksChange:m}),[ee,te]=(0,d.useState)(null),Y=(0,d.useRef)(h);Y.current=h;let X=(0,d.useRef)(m);return X.current=m,(0,g.jsx)(u.Box,{ref:e,onScroll:t,"data-testid":`gantt-timeline-scroll`,sx:{flex:1,overflow:`auto`},children:(0,g.jsxs)(u.Box,{sx:{minWidth:M,position:`relative`},children:[(0,g.jsx)(Hn,{columns:j,groups:N,todayX:R,todayLabel:w.todayLabel,todayTooltip:B,todayColor:V}),(0,g.jsx)(qn,{strips:L,totalWidth:M,height:k.length*40,top:U}),c?(0,g.jsx)(u.Box,{sx:{position:`relative`,height:I.getTotalSize()},children:I.getVirtualItems().map(e=>(0,g.jsx)(Un,{task:k[e.index],virtualTop:e.start,activeDrag:W,displayRange:A,totalWidth:M,gridColumnWidth:H,criticalTaskIds:F,draggable:i,resizable:a,progressDraggable:o,onTaskClick:n,onMilestoneClick:r,onContextMenu:(e,t,n)=>te({task:e,mouseX:t,mouseY:n}),suppressClickRef:G,handleBarMouseDown:K,handleProgressMouseDown:q,formatDragDate:J},e.key))}):(0,g.jsx)(g.Fragment,{children:k.map(e=>(0,g.jsx)(Un,{task:e,activeDrag:W,displayRange:A,totalWidth:M,gridColumnWidth:H,criticalTaskIds:F,draggable:i,resizable:a,progressDraggable:o,onTaskClick:n,onMilestoneClick:r,onContextMenu:(e,t,n)=>te({task:e,mouseX:t,mouseY:n}),suppressClickRef:G,handleBarMouseDown:K,handleProgressMouseDown:q,formatDragDate:J},e.id))}),(0,g.jsx)(Jn,{contextMenu:ee,onClose:()=>te(null),onSelect:(e,t)=>{let n=C.getState().tasks.find(t=>t.id===e.id)??e;S({...n,status:t}),Y.current?.(n,t),X.current?.(C.getState().tasks),te(null)}}),(0,g.jsx)(Yn,{dependencyLines:P,todayX:R,totalWidth:M,height:k.length*40,top:U,arrowMarkerId:D})]})})}function Qn(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function $n(e){let[t,n,r]=e.split(`-`).map(Number);return!t||!n||!r?null:new Date(t,n-1,r,0,0,0,0)}function er({onScrollToToday:e,config:t,onExportCSV:n}){let r=ir(),i=$(e=>e.timeScale),a=$(e=>e.defaultTimeScale),o=$(e=>e.setTimeScale),s=$(e=>e.timelineRange),c=$(e=>e.isRangeCustomized),l=$(e=>e.isExpandedCustomized),f=$(e=>e.setTimelineRange),p=$(e=>e.resetTimelineRange),m=$(e=>e.resetView),h=$(e=>e.tasks),_=$(e=>e.expandedIds),v=$(e=>e.expandAll),y=$(e=>e.collapseAll),b=$(e=>e.assigneeFilter),x=$(e=>e.setAssigneeFilter),S=(0,d.useMemo)(()=>[...new Set(h.flatMap(e=>e.assignee?[e.assignee]:[]))].sort(),[h]),C=h.length>0&&h.every(e=>_.has(e.id)),w=i!==a||c||l||b!==``,T=(0,d.useMemo)(()=>Date.now(),[]),E=T>=s.start.getTime()&&T<=s.end.getTime(),D={days:r.scaleDays,weeks:r.scaleWeeks,months:r.scaleMonths,quarters:r.scaleQuarters},O={days:t.showScaleDays,weeks:t.showScaleWeeks,months:t.showScaleMonths,quarters:t.showScaleQuarters},A=Object.keys(D).filter(e=>O[e]);return(0,g.jsxs)(u.Box,{"data-testid":`gantt-toolbar`,sx:{display:`flex`,alignItems:`center`,flexWrap:`wrap`,gap:1,px:1.5,py:.75,borderBottom:`1px solid`,borderColor:`divider`,bgcolor:`background.paper`},children:[A.length>0&&(0,g.jsx)(u.ToggleButtonGroup,{value:i,exclusive:!0,onChange:(e,t)=>{t&&o(t)},size:`small`,"aria-label":r.scaleMonths,children:A.map(e=>(0,g.jsx)(u.ToggleButton,{value:e,"data-testid":`gantt-scale-${e}`,children:D[e]},e))}),t.showAssigneeFilter&&S.length>0&&(0,g.jsxs)(u.FormControl,{size:`small`,sx:{minWidth:140},children:[(0,g.jsx)(u.InputLabel,{id:`gantt-assignee-filter-label`,children:r.filterAssigneeLabel??`Assignee`}),(0,g.jsxs)(u.Select,{labelId:`gantt-assignee-filter-label`,value:b,label:r.filterAssigneeLabel??`Assignee`,onChange:e=>x(e.target.value),inputProps:{"data-testid":`gantt-assignee-filter`},children:[(0,g.jsx)(u.MenuItem,{value:``,children:r.filterAssigneeAll??`Alle`}),S.map(e=>(0,g.jsx)(u.MenuItem,{value:e,children:e},e))]})]}),(0,g.jsxs)(u.Box,{sx:{ml:`auto`,display:`flex`,alignItems:`center`,gap:1},children:[t.showExpandCollapseAll&&(0,g.jsx)(u.Tooltip,{title:C?r.collapseAllTooltip:r.expandAllTooltip,children:(0,g.jsx)(u.IconButton,{size:`small`,onClick:C?y:v,"aria-label":C?r.collapseAllTooltip:r.expandAllTooltip,"data-testid":`gantt-expand-collapse-all`,children:C?(0,g.jsx)(W.default,{fontSize:`small`}):(0,g.jsx)(G.default,{fontSize:`small`})})}),t.showScrollToToday&&e&&(0,g.jsx)(u.Tooltip,{title:r.scrollToTodayTooltip,children:(0,g.jsx)(`span`,{children:(0,g.jsx)(u.IconButton,{size:`small`,onClick:e,disabled:!E,"aria-label":r.scrollToTodayTooltip,"data-testid":`gantt-scroll-to-today`,children:(0,g.jsx)(U.default,{fontSize:`small`})})})}),t.showDateRange&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(u.TextField,{type:`date`,size:`small`,label:r.rangeFrom,value:Qn(s.start),onChange:e=>{let t=$n(e.target.value);t&&f({start:t,end:s.end})},slotProps:{inputLabel:{shrink:!0},htmlInput:{"data-testid":`gantt-range-start`}},sx:{width:148}}),(0,g.jsx)(u.TextField,{type:`date`,size:`small`,label:r.rangeTo,value:Qn(s.end),onChange:e=>{let t=$n(e.target.value);t&&f({start:s.start,end:t})},slotProps:{inputLabel:{shrink:!0},htmlInput:{"data-testid":`gantt-range-end`}},sx:{width:148}})]}),t.showRangeReset&&c&&(0,g.jsx)(u.Tooltip,{title:r.rangeResetTooltip,children:(0,g.jsx)(u.IconButton,{size:`small`,onClick:p,"aria-label":r.rangeResetTooltip,"data-testid":`gantt-range-reset`,children:(0,g.jsx)(H.default,{fontSize:`small`})})}),t.showExportCSV&&n&&(0,g.jsx)(u.Tooltip,{title:r.exportCsvTooltip,children:(0,g.jsx)(u.IconButton,{size:`small`,onClick:n,"aria-label":r.exportCsvTooltip,"data-testid":`gantt-export-csv`,children:(0,g.jsx)(k.default,{fontSize:`small`})})}),t.showResetView&&(0,g.jsx)(u.Tooltip,{title:r.resetViewTooltip,children:(0,g.jsx)(`span`,{children:(0,g.jsx)(u.IconButton,{size:`small`,onClick:m,disabled:!w,"aria-label":r.resetViewTooltip,"data-testid":`gantt-reset-view`,children:(0,g.jsx)(V.default,{fontSize:`small`})})})})]})]})}var tr=(0,d.createContext)(null);function $(e){let t=(0,d.useContext)(tr);if(!t)throw Error(`GanttChartStoreContext is missing.`);return(0,L.useStore)(t,e)}function nr(){let e=(0,d.useContext)(tr);if(!e)throw Error(`GanttChartStoreContext is missing.`);return e}var rr=(0,d.createContext)(Dn);function ir(){return(0,d.useContext)(rr)}var ar=(0,d.createContext)({});function or(){return(0,d.useContext)(ar)}function sr(e,t){return e===void 0?t:e===`auto`?`100%`:typeof e==`string`&&/^\d+$/.test(e)?Number(e):e}var cr=[`days`,`weeks`,`months`,`quarters`],lr={showScaleDays:!0,showScaleWeeks:!0,showScaleMonths:!0,showScaleQuarters:!0,showExpandCollapseAll:!0,showScrollToToday:!0,showDateRange:!0,showRangeReset:!0,showResetView:!0,showExportCSV:!1,showAssigneeFilter:!1};function ur({tasks:e,onTaskClick:t,onMilestoneClick:n,onAddTask:r,onEditTask:i,onDeleteTask:a,onStatusChange:o,onTasksChange:s,enableBuiltinDialogs:c=!0,onTaskCreated:l,onTaskUpdated:f,onTaskDeleted:p,showToolbar:m=!0,toolbarConfig:h,height:_,width:v,minPanelWidth:y=200,maxPanelWidth:b=600,zoomable:x=!1,draggable:S=!1,resizable:C=!1,inlineEdit:w=!1,progressDraggable:T=!1,showCriticalPath:E=!1,virtualizeRows:D=!1,showAssigneeColumn:O=!1,onExportCSV:k,onDragStart:A,onTaskMoved:j,onTaskResized:M}){let N=sr(_,400),P=(0,d.useMemo)(()=>({...lr,...h}),[h]),F=sr(v,`100%`),I=$(e=>e.setTasks),L=$(e=>e.timeScale),R=$(e=>e.setTimeScale),z=$(e=>e.timelineRange),B=(0,d.useRef)(null),V=(0,d.useRef)(null),H=(0,d.useRef)(!1),[U,W]=(0,d.useState)(320+(O?110:0)),G=Math.max(y,90+(c||r||i||a?96:0)+(O?110:0)+80),K=nr(),q=(0,d.useCallback)(()=>{let e=K.getState().tasks,t=[[`id`,`name`,`status`,`startDate`,`endDate`,`progress`,`assignee`,`parentId`,`isMilestone`,`dependencies`,`color`].join(`,`),...e.map(e=>[e.id,`"${e.name.replace(/"/g,`""`)}"`,e.status,e.startDate.toISOString().split(`T`)[0],e.endDate.toISOString().split(`T`)[0],e.progress??``,e.assignee?`"${e.assignee.replace(/"/g,`""`)}"`:``,e.parentId??``,e.isMilestone?`true`:`false`,(e.dependencies??[]).join(`;`),e.color??``].join(`,`))].join(`
2
- `);if(k)k(t,e);else{let e=new Blob([t],{type:`text/csv;charset=utf-8;`}),n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=`gantt-tasks.csv`,r.click(),URL.revokeObjectURL(n)}},[K,k]);(0,d.useEffect)(()=>{I(e)},[e,I]);let J=()=>{H.current||=(H.current=!0,V.current&&B.current&&(V.current.scrollTop=B.current.scrollTop),!1)},ee=()=>{H.current||=(H.current=!0,B.current&&V.current&&(B.current.scrollTop=V.current.scrollTop),!1)},te=(0,d.useCallback)(()=>{if(!V.current)return;let e=nn(z,L),t=Date.now(),n=e.start.getTime(),r=e.end.getTime(),i=(t-n)/(r-n)*V.current.scrollWidth;V.current.scrollLeft=Math.max(0,i-V.current.clientWidth/2)},[z,L]);(0,d.useEffect)(()=>{if(!x||!V.current)return;let e=V.current,t=e=>{if(!e.ctrlKey)return;e.preventDefault();let t=cr.indexOf(L);e.deltaY<0&&t>0?R(cr[t-1]):e.deltaY>0&&t<cr.length-1&&R(cr[t+1])};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[x,L,R]);let Y=(0,d.useCallback)(e=>{e.preventDefault();let t=e.clientX,n=U,r=e=>{let r=e.clientX-t;W(Math.max(G,Math.min(b,n+r)))},i=()=>{document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i)};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i)},[U,G,b]);return(0,g.jsxs)(u.Box,{sx:{display:`flex`,flexDirection:`column`,height:N,width:F,border:`1px solid`,borderColor:`divider`,borderRadius:1,overflow:`hidden`},children:[m&&(0,g.jsx)(er,{onScrollToToday:te,config:P,onExportCSV:P.showExportCSV?q:void 0}),(0,g.jsxs)(u.Box,{sx:{display:`flex`,flex:1,overflow:`hidden`},children:[(0,g.jsx)(Rn,{scrollRef:B,onScroll:J,panelWidth:U,onTaskClick:t,onAddTask:r,onEditTask:i,onDeleteTask:a,onStatusChange:o,onTasksChange:s,enableBuiltinDialogs:c,onTaskCreated:l,onTaskUpdated:f,onTaskDeleted:p,inlineEdit:w,virtualizeRows:D,showAssigneeColumn:O}),(0,g.jsx)(u.Box,{"data-testid":`gantt-panel-divider`,sx:{width:4,flexShrink:0,bgcolor:`divider`,cursor:`col-resize`,"&:hover":{bgcolor:`action.hover`}},onMouseDown:Y}),(0,g.jsx)(Zn,{scrollRef:V,onScroll:ee,onTaskClick:t,onMilestoneClick:n,draggable:S,resizable:C,progressDraggable:T,showCriticalPath:E,virtualizeRows:D,onDragStart:A,onTaskMoved:j,onTaskResized:M,onTasksChange:s,onStatusChange:o})]})]})}function dr({tasks:e,timeScale:t=`months`,initialExpandAll:n=!1,showToolbar:r=!0,defaultRangeStart:i,defaultRangeEnd:a,translations:o,enableBuiltinDialogs:s=!0,toolbarConfig:c,zoomable:l=!1,draggable:u=!1,resizable:f=!1,inlineEdit:p=!1,progressDraggable:m=!1,showCriticalPath:h=!1,virtualizeRows:_=!1,showAssigneeColumn:v=!1,cascadeDependencies:y=!1,statusColors:b,ganttTheme:x,onExportCSV:S,onDragStart:C,onTaskClick:w,onMilestoneClick:T,onAddTask:E,onEditTask:D,onDeleteTask:O,onStatusChange:k,onTasksChange:A,onTaskMoved:j,onTaskResized:M,onTaskCreated:N,onTaskUpdated:P,onTaskDeleted:F,height:I,width:L,minPanelWidth:R,maxPanelWidth:z}){let B=(0,d.useMemo)(()=>({...Dn,...o}),[o]),[V]=(0,d.useState)(()=>{if(!(i!==void 0||a!==void 0))return En(e,t,n,void 0,y);let r=tn(e);return En(e,t,n,{start:i??r.start,end:a??r.end},y)}),H=(0,d.useMemo)(()=>({...x,statusColors:{...b,...x?.statusColors}}),[b,x]);return(0,g.jsx)(rr.Provider,{value:B,children:(0,g.jsx)(ar.Provider,{value:H,children:(0,g.jsx)(tr.Provider,{value:V,children:(0,g.jsx)(ur,{tasks:e,timeScale:t,enableBuiltinDialogs:s,showToolbar:r,toolbarConfig:c,zoomable:l,draggable:u,resizable:f,inlineEdit:p,progressDraggable:m,showCriticalPath:h,virtualizeRows:_,showAssigneeColumn:v,onExportCSV:S,onDragStart:C,onTaskClick:w,onMilestoneClick:T,onAddTask:E,onEditTask:D,onDeleteTask:O,onStatusChange:k,onTasksChange:A,onTaskMoved:j,onTaskResized:M,onTaskCreated:N,onTaskUpdated:P,onTaskDeleted:F,height:I,width:L,minPanelWidth:R,maxPanelWidth:z})})})})}var fr=e=>Math.max(0,Math.min(4,Math.round(e)));function pr(e,t){let n=e??``,r=n.length,i=/[a-z]/.test(n),a=/[A-Z]/.test(n),o=/\d/.test(n),s=/[^A-Za-z0-9]/.test(n),c=[i,a,o,s].filter(Boolean).length;if(r<t){let e=r===0?0:1;return{score:e,percent:e*25,meterStatus:`weak`,length:r,hasLower:i,hasUpper:a,hasDigit:o,hasSymbol:s}}let l=0;l+=1,r>=t+4&&(l+=1),c>=2&&(l+=1),c>=3&&(l+=1),/^(.)\1+$/.test(n)&&(l-=2),/1234|abcd|qwer|password|passwort|admin/i.test(n)&&(l-=2);let u=fr(l),d=u<=1?`weak`:u===2?`ok`:u===3?`good`:`very good`;return{score:u,percent:u*25,meterStatus:d,length:r,hasLower:i,hasUpper:a,hasDigit:o,hasSymbol:s}}function mr({percent:e,color:t,ariaLabel:n,segments:r=!1,className:i}){if(r){let r=Math.round(e/25);return(0,g.jsx)(u.Box,{role:`progressbar`,"aria-label":n,"aria-valuenow":e,"aria-valuemin":0,"aria-valuemax":100,className:i,sx:{width:`100%`,display:`flex`,gap:`3px`,mt:.5},children:[0,1,2,3].map(e=>(0,g.jsx)(u.Box,{"data-testid":e<r?`psm-meter-segment-active`:`psm-meter-segment`,sx:{flex:1,height:`8px`,borderRadius:`3px`,border:`1px solid`,borderColor:`divider`,backgroundColor:e<r?t:`transparent`,transition:`background-color 0.3s ease-in-out`}},e))})}return(0,g.jsx)(u.Box,{role:`progressbar`,"aria-label":n,"aria-valuenow":e,"aria-valuemin":0,"aria-valuemax":100,className:i,sx:{width:`100%`,height:`8px`,border:`1px solid`,borderColor:`divider`,borderRadius:`6px`,mt:.5,display:`flex`},children:(0,g.jsx)(u.Box,{"data-testid":`psm-meter`,sx:{height:`100%`,width:`${e}%`,backgroundColor:t,borderRadius:`6px`,transition:`width 0.2s ease-in-out`}})})}var hr={label:`Password`,summaryHeaderLabel:`Requirements for your password`,summaryMinChars:`At least {n} characters`,summaryCapitalLetter:`At least 1 capital letter`,summaryLowerCaseLetter:`At least 1 lowercase letter`,summaryNumber:`At least 1 number`,summarySpecialChar:`At least 1 special character`,showPasswordLabel:`Show password`,hidePasswordLabel:`Hide password`,meterAriaLabel:`Password strength`,generatePasswordLabel:`Generate secure password`,confirmLabel:`Confirm password`,confirmMatchLabel:`Passwords match`,confirmMismatchLabel:`Passwords do not match`,copyPasswordLabel:`Copy password`,copiedLabel:`Copied!`},gr={weak:`#cc0000`,ok:`#fdc010`,good:`#8bc34a`,veryGood:`#43a047`},_r={failure:`#cc0000`,success:`#43a047`};function vr(e){let t=[];e.upper&&t.push(`ABCDEFGHIJKLMNOPQRSTUVWXYZ`),e.lower&&t.push(`abcdefghijklmnopqrstuvwxyz`),e.numbers&&t.push(`0123456789`),e.symbols&&t.push(`!@#$%^&*()-_=+[]{}|;:,.<>?`),t.length===0&&t.push(`abcdefghijklmnopqrstuvwxyz`);let n=t.join(``),r=Math.max(e.length,t.length),i=new Uint32Array(Math.max(0,r-t.length));crypto.getRandomValues(i);let a=t.map(e=>e[crypto.getRandomValues(new Uint32Array(1))[0]%e.length]),o=Array.from(i).map(e=>n[e%n.length]),s=[...a,...o];for(let e=s.length-1;e>0;e--){let t=crypto.getRandomValues(new Uint32Array(1))[0]%(e+1);[s[e],s[t]]=[s[t],s[e]]}return s.join(``)}function yr({label:e,fulfilled:t,checkColors:n}){return(0,g.jsxs)(u.Stack,{direction:`row`,sx:{alignItems:`center`,mb:.25},spacing:.5,className:it.requirementItem,children:[(0,g.jsx)(u.Typography,{variant:`caption`,children:e}),t?(0,g.jsx)(F.default,{"data-testid":`psm-req-success`,style:{fontSize:16,color:n.success}}):(0,g.jsx)(I.default,{"data-testid":`psm-req-failure`,style:{fontSize:16,color:n.failure}})]})}function br({value:e,confirmValue:t,name:n,inputRef:r,disabled:i=!1,error:a=!1,helperText:o,autoComplete:s,customRequirements:c,generatorOptions:l,showConfirmField:f=!1,showPasswordAdornment:p=!0,showMeter:m=!0,showPasswordGenerator:h=!1,showSegmentedBar:_=!1,showSummary:v=!0,showCopyButton:y=!1,inputSize:b=`medium`,translation:x,meterColors:S,passwordMinLength:C=8,checkColors:w=_r,onPasswordChange:T,onConfirmChange:E,onPasswordGenerated:D}){let k={...hr,...x},j={...gr,...S},M=(0,d.useId)(),P=`${M}-password`,[F,I]=(0,d.useState)(!1),[L,R]=(0,d.useState)(!1),[z,B]=(0,d.useState)(``),[V,H]=(0,d.useState)(``),[U,W]=Yt(),G=e===void 0?z:e,te=t===void 0?V:t,Y=f&&te.length>0,X=Y&&G===te,ne=(0,d.useMemo)(()=>pr(G,C),[G,C]),re=()=>{I(e=>!e)},ie=e=>{e.preventDefault()},ae=e=>{e.preventDefault()},oe=t=>{let n=t.target.value;e===void 0&&B(n),T&&T(n,pr(n,C))},se=e=>{let n=e.target.value;t===void 0&&H(n),E?.(n,n===G)},ce=()=>{let n=vr({length:l?.length??Math.max(16,C),upper:l?.upper??!0,lower:l?.lower??!0,numbers:l?.numbers??!0,symbols:l?.symbols??!0});e===void 0&&B(n),t===void 0&&H(``),T?.(n,pr(n,C)),D?.(n),I(!0)},le=()=>{navigator.clipboard.writeText(G).then(()=>{W()})},ue=e=>{switch(e.meterStatus){case`weak`:return j.weak;case`ok`:return j.ok;case`good`:return j.good;case`very good`:return j.veryGood;default:return`transparent`}},de=[it.strengthBar,ne.meterStatus===`weak`&&it.strengthBarWeak,ne.meterStatus===`ok`&&it.strengthBarOk,ne.meterStatus===`good`&&it.strengthBarGood,ne.meterStatus===`very good`&&it.strengthBarVeryGood].filter(Boolean).join(` `);return(0,g.jsxs)(u.Stack,{className:[it.root,i&&Be.disabled,a&&Be.error].filter(Boolean).join(` `),children:[(0,g.jsxs)(u.FormControl,{variant:`outlined`,fullWidth:!0,error:a,className:it.input,children:[(0,g.jsx)(u.InputLabel,{htmlFor:P,size:b,children:k.label}),(0,g.jsx)(u.OutlinedInput,{id:P,type:F?`text`:`password`,fullWidth:!0,size:b,value:G,onChange:oe,disabled:i,inputRef:r,inputProps:{"data-testid":`psm-input`,name:n,autoComplete:s},endAdornment:p||y&&G.length>0?(0,g.jsxs)(u.InputAdornment,{position:`end`,children:[y&&G.length>0&&(0,g.jsx)(u.Tooltip,{title:U?k.copiedLabel:k.copyPasswordLabel,arrow:!0,children:(0,g.jsx)(`span`,{children:(0,g.jsx)(u.IconButton,{"data-testid":`psm-copy`,disabled:i,"aria-label":U?k.copiedLabel:k.copyPasswordLabel,onClick:le,onMouseDown:ie,onMouseUp:ae,edge:p?!1:`end`,children:U?(0,g.jsx)(A.default,{fontSize:`small`,color:`success`}):(0,g.jsx)(O.default,{fontSize:`small`})})})}),p&&(0,g.jsx)(u.IconButton,{"data-testid":`psm-toggle`,disabled:i,"aria-label":F?k.hidePasswordLabel:k.showPasswordLabel,onClick:re,onMouseDown:ie,onMouseUp:ae,edge:`end`,children:F?(0,g.jsx)(ee.default,{}):(0,g.jsx)(J.default,{})})]}):null,label:k.label}),o&&(0,g.jsx)(u.FormHelperText,{children:o})]}),h&&(0,g.jsx)(u.Tooltip,{title:k.generatePasswordLabel,arrow:!0,children:(0,g.jsx)(`span`,{children:(0,g.jsx)(u.Button,{"data-testid":`psm-generate`,size:`small`,variant:`text`,startIcon:(0,g.jsx)(N.default,{fontSize:`small`}),disabled:i,onClick:ce,className:it.generatorButton,sx:{mt:.5,alignSelf:`flex-start`,textTransform:`none`},children:k.generatePasswordLabel})})}),f&&(0,g.jsxs)(u.FormControl,{variant:`outlined`,fullWidth:!0,error:Y&&!X,sx:{mt:1},className:it.confirmInput,children:[(0,g.jsx)(u.InputLabel,{htmlFor:`${M}-confirm`,size:b,children:k.confirmLabel}),(0,g.jsx)(u.OutlinedInput,{id:`${M}-confirm`,type:L?`text`:`password`,fullWidth:!0,size:b,value:te,onChange:se,disabled:i,inputProps:{"data-testid":`psm-confirm-input`},endAdornment:(0,g.jsxs)(u.InputAdornment,{position:`end`,children:[Y&&(X?(0,g.jsx)(K.default,{"data-testid":`psm-confirm-match`,sx:{color:w.success,mr:.5},fontSize:`small`}):(0,g.jsx)(q.default,{"data-testid":`psm-confirm-mismatch`,sx:{color:w.failure,mr:.5},fontSize:`small`})),(0,g.jsx)(u.IconButton,{size:`small`,disabled:i,onClick:()=>R(e=>!e),onMouseDown:e=>e.preventDefault(),edge:`end`,"aria-label":L?k.hidePasswordLabel:k.showPasswordLabel,children:L?(0,g.jsx)(ee.default,{}):(0,g.jsx)(J.default,{})})]}),label:k.confirmLabel}),Y&&(0,g.jsx)(u.FormHelperText,{sx:{color:X?w.success:w.failure},children:X?k.confirmMatchLabel:k.confirmMismatchLabel})]}),m&&(0,g.jsx)(mr,{percent:ne.percent,color:ue(ne),ariaLabel:k.meterAriaLabel,segments:_,className:de}),v&&(0,g.jsxs)(u.Box,{"data-testid":`psm-summary`,sx:{mt:.5,p:.5},className:it.summary,children:[(0,g.jsx)(u.Typography,{variant:`caption`,gutterBottom:!0,sx:{display:`block`,fontSize:14},children:k.summaryHeaderLabel}),(0,g.jsxs)(u.Stack,{direction:`row`,spacing:6,children:[(0,g.jsxs)(u.Stack,{direction:`column`,children:[(0,g.jsx)(yr,{label:k.summaryMinChars.replace(`{n}`,String(C)),fulfilled:ne.length>=C,checkColors:w}),(0,g.jsx)(yr,{label:k.summaryCapitalLetter,fulfilled:ne.hasUpper,checkColors:w}),(0,g.jsx)(yr,{label:k.summaryLowerCaseLetter,fulfilled:ne.hasLower,checkColors:w})]}),(0,g.jsxs)(u.Stack,{direction:`column`,children:[(0,g.jsx)(yr,{label:k.summaryNumber,fulfilled:ne.hasDigit,checkColors:w}),(0,g.jsx)(yr,{label:k.summarySpecialChar,fulfilled:ne.hasSymbol,checkColors:w}),c?.map((e,t)=>(0,g.jsx)(yr,{label:e.label,fulfilled:typeof e.fulfilled==`function`?e.fulfilled(G):e.fulfilled,checkColors:w},t))]})]})]})]})}function xr(e){return(0,R.createStore)(t=>({tags:e,searchValue:``,setTags:e=>{t({tags:e})},setSearchValue:e=>{t({searchValue:e})},selectTag:e=>{t(t=>({tags:t.tags.map(t=>t.id===e&&!t.disabled?{...t,selected:!0}:t),searchValue:``}))},deleteTag:e=>{t(t=>({tags:t.tags.map(t=>t.id===e?{...t,selected:!1}:t)}))},addTag:e=>{t(t=>({tags:[...t.tags,{...e,selected:!0}],searchValue:``}))}}))}var Sr=[`default`,`primary`,`secondary`,`error`,`info`,`success`,`warning`],Cr=[`#f44336`,`#e91e63`,`#9c27b0`,`#673ab7`,`#3f51b5`,`#2196f3`,`#03a9f4`,`#00bcd4`,`#009688`,`#4caf50`,`#8bc34a`,`#cddc39`,`#ffeb3b`,`#ffc107`,`#ff9800`,`#ff5722`,`#795548`,`#9e9e9e`,`#607d8b`,`#000000`];function wr(e){return/^#[0-9A-Fa-f]{6}$/.test(e)}function Tr(e){let t=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),r=parseInt(e.slice(5,7),16);return(.299*t+.587*n+.114*r)/255>.5?`#000000`:`#ffffff`}function Er(e,t){let n=t.trim();if(!n)return e;let r=e.toLowerCase().indexOf(n.toLowerCase());return r===-1?e:(0,g.jsxs)(g.Fragment,{children:[e.slice(0,r),(0,g.jsx)(`strong`,{children:e.slice(r,r+n.length)}),e.slice(r+n.length)]})}function Dr({color:e,selected:t,onClick:n}){return(0,g.jsx)(u.Box,{onClick:n,sx:{width:24,height:24,borderRadius:.5,backgroundColor:e,cursor:`pointer`,border:`2px solid`,borderColor:t?`primary.main`:`transparent`,outline:t?`1px solid`:`none`,outlineColor:`primary.main`,outlineOffset:1,flexShrink:0,"&:hover":{transform:`scale(1.2)`,borderColor:`primary.main`},transition:`transform 0.1s`}})}function Or({value:e,onChange:t,disabled:n=!1}){return(0,g.jsx)(u.TextField,{size:`small`,fullWidth:!0,value:e,onChange:e=>t(e.target.value),placeholder:`#rrggbb`,disabled:n,error:!n&&e.length>1&&!wr(e),sx:{"& .MuiInputBase-root":{height:28},"& .MuiInputBase-input":{py:0,px:.5,fontSize:`0.72rem`,fontFamily:`monospace`}},slotProps:{input:{startAdornment:(0,g.jsx)(u.Box,{sx:{width:12,height:12,borderRadius:.25,flexShrink:0,mr:.5,backgroundColor:wr(e)?e:`action.disabledBackground`,border:`1px solid`,borderColor:`divider`}})}}})}function kr({availableTags:e,searchValue:t,translation:n,onSearchChange:r,onTagSelect:i,onTagCreate:a,inputSize:o=`medium`,chipSize:s=`medium`,chipVariant:c=`filled`,disabled:l=!1,loading:f=!1,isMaxReached:p=!1,allowCreate:m=!1,listboxMaxHeight:h,serverSideFilter:_=!1}){let[v,y]=(0,d.useState)(`default`),[b,x]=(0,d.useState)(null),[S,C]=(0,d.useState)(null),[w,T]=(0,d.useState)(!0),[E,D]=(0,d.useState)(!1),[O,k]=(0,d.useState)(!1),[j,M]=(0,d.useState)(`#1976d2`),[N,P]=(0,d.useState)(`#ffffff`),F=l||p,I=b!==null,L=_?e:e.filter(e=>e.label.toLowerCase().includes(t.trim().toLowerCase())),R=m&&t.trim()!==``&&L.length===0,z=O&&!R,B=I?w?Tr(b):S??`#000000`:void 0,V=()=>{if(F)return;let e=t.trim(),n=e.toLowerCase().replace(/\s+/g,`-`);a?.(I&&b?{id:n,label:e,selected:!0,color:`default`,backgroundColor:b,foregroundColor:B}:{id:n,label:e,selected:!0,color:v}),y(`default`),x(null),C(null),T(!0),D(!1),r(``)},H=()=>{r(``),y(`default`),x(null),C(null),T(!0),D(!1)},U=e=>{x(e),M(e),y(`default`)},W=e=>{M(e),wr(e)&&(x(e),y(`default`))},G=e=>{C(e),P(e)},K=e=>{P(e),wr(e)&&C(e)},q=e=>{if(T(e),e)C(null);else if(b){let e=Tr(b);C(e),P(e)}},J=e=>e.preventDefault();return(0,g.jsxs)(u.Box,{sx:{mb:2},className:rt.autocomplete,children:[(0,g.jsx)(u.Autocomplete,{options:e,filterOptions:_?e=>e:void 0,value:null,open:z,onOpen:()=>{R||k(!0)},onClose:()=>k(!1),size:o,disabled:F,loading:f,getOptionLabel:e=>e.label,inputValue:t,onInputChange:(e,t,n)=>{n===`input`&&r(t)},onChange:(e,t)=>{t&&i(t)},slotProps:{listbox:{sx:{display:`flex`,flexWrap:`wrap`,gap:1,padding:1,...h!==void 0&&{maxHeight:h,overflowY:`auto`}}}},renderInput:e=>(0,g.jsx)(u.TextField,{...e,label:n.autoCompleteLabel,placeholder:n.placeholder,helperText:p&&!l?n.maxTagsReachedText:void 0,onKeyDown:e=>{R&&!F&&e.key===`Enter`&&(e.preventDefault(),V())},slotProps:{...e.slotProps,input:{...e.slotProps?.input,endAdornment:(0,g.jsxs)(g.Fragment,{children:[R&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(u.IconButton,{size:`small`,sx:{color:`success.main`},onMouseDown:J,onClick:V,disabled:F,"aria-label":n.confirmCreateLabel,children:(0,g.jsx)(A.default,{fontSize:`small`})}),(0,g.jsx)(u.IconButton,{size:`small`,onMouseDown:J,onClick:H,"aria-label":n.cancelCreateLabel,children:(0,g.jsx)(te.default,{fontSize:`small`})})]}),e.slotProps?.input?.endAdornment]})}}}),renderOption:({key:e,...n},r)=>{let i=!!(r.foregroundColor||r.backgroundColor);return(0,g.jsx)(`li`,{...n,style:{width:`auto`,padding:0,margin:0},children:(0,g.jsx)(u.Chip,{size:s,variant:c,label:Er(r.label,t),color:i?void 0:r.color??`default`,className:rt.option,sx:i?{color:r.foregroundColor??`inherit`,backgroundColor:r.backgroundColor??`transparent`}:void 0})},e)},isOptionEqualToValue:(e,t)=>e.id===t.id,noOptionsText:n.noAvailableTagsText,loadingText:n.loadingText}),R&&(0,g.jsxs)(u.Box,{sx:{position:`relative`},onMouseDown:J,className:rt.createPanel,children:[(0,g.jsxs)(u.Stack,{direction:`row`,sx:{mt:.5,flexWrap:`wrap`,gap:.5,alignItems:`center`},children:[Sr.map(e=>(0,g.jsx)(u.Chip,{size:s,color:e,label:e,variant:!I&&v===e?`filled`:`outlined`,onClick:()=>{y(e),x(null),C(null),D(!1)},clickable:!0},e)),(0,g.jsx)(u.Tooltip,{title:n.colorPickerLabel,children:(0,g.jsx)(u.Chip,{size:s,label:I?b:`···`,variant:`outlined`,onClick:()=>{D(e=>!e),b&&M(b),S&&P(S)},sx:e=>({cursor:`pointer`,fontFamily:`monospace`,fontSize:`0.7rem`,...I?{backgroundColor:b,color:B,border:`1.5px solid transparent`,backgroundImage:`linear-gradient(${b}, ${b}), linear-gradient(90deg, #f44336, #ff9800, #ffeb3b, #4caf50, #2196f3, #9c27b0)`,backgroundOrigin:`border-box`,backgroundClip:`padding-box, border-box`}:{border:`1.5px solid transparent`,backgroundImage:`linear-gradient(${e.palette.background.paper}, ${e.palette.background.paper}), linear-gradient(90deg, #f44336, #ff9800, #ffeb3b, #4caf50, #2196f3, #9c27b0)`,backgroundOrigin:`border-box`,backgroundClip:`padding-box, border-box`}}),clickable:!0})})]}),E&&(0,g.jsx)(u.Box,{sx:{position:`absolute`,top:`calc(100% + 4px)`,left:0,zIndex:1400,backgroundColor:`background.paper`,border:`1px solid`,borderColor:`divider`,borderRadius:1,boxShadow:8,p:1.25,width:`max-content`},children:(0,g.jsxs)(u.Box,{sx:{display:`grid`,gridTemplateColumns:`auto auto`,gap:2},children:[(0,g.jsxs)(u.Box,{children:[(0,g.jsx)(u.Typography,{variant:`caption`,sx:{fontWeight:700,color:`text.primary`,display:`block`,mb:.5},children:n.backgroundColorLabel}),(0,g.jsxs)(u.Box,{sx:{display:`grid`,gridTemplateColumns:`repeat(5, 24px)`,gap:.5},children:[Cr.map(e=>(0,g.jsx)(Dr,{color:e,selected:b===e,onClick:()=>U(e)},e)),(0,g.jsx)(u.Box,{sx:{gridColumn:`span 5`,mt:.25},children:(0,g.jsx)(Or,{value:j,onChange:W})})]})]}),(0,g.jsxs)(u.Box,{children:[(0,g.jsx)(u.Typography,{variant:`caption`,sx:{fontWeight:700,color:`text.primary`,display:`block`,mb:.5},children:n.textColorLabel}),(0,g.jsxs)(u.Box,{sx:{display:`grid`,gridTemplateColumns:`repeat(5, 24px)`,gap:.5,opacity:w?.3:1,pointerEvents:w?`none`:`auto`,transition:`opacity 0.15s`},children:[Cr.map(e=>(0,g.jsx)(Dr,{color:e,selected:S===e,onClick:()=>G(e)},e)),(0,g.jsx)(u.Box,{sx:{gridColumn:`span 5`,mt:.25},children:(0,g.jsx)(Or,{value:w?B??`#000000`:N,onChange:K,disabled:w})})]}),(0,g.jsxs)(u.Stack,{direction:`row`,sx:{width:`100%`,alignItems:`center`,justifyContent:`flex-end`,gap:.5,mt:.25},children:[(0,g.jsx)(u.Typography,{variant:`caption`,color:`text.secondary`,children:n.autoTextColorLabel}),(0,g.jsx)(u.Switch,{size:`small`,checked:w,onChange:e=>q(e.target.checked)})]})]})]})})]})]})}function Ar({tag:e,onDelete:t,onClick:n,chipSize:r=`medium`,chipVariant:i=`filled`,disabled:a=!1}){let o=!!(e.foregroundColor||e.backgroundColor),s=a||e.disabled;return(0,g.jsx)(u.Chip,{size:r,label:e.label,onDelete:t?()=>t(e):void 0,onClick:n?()=>n(e):void 0,clickable:!!n&&!e.disabled&&!a,disabled:s,variant:i,color:o?void 0:e.color??`default`,className:[rt.chip,s&&Be.disabled].filter(Boolean).join(` `),sx:{...o&&{color:e.foregroundColor??`inherit`,backgroundColor:e.backgroundColor??`transparent`,borderColor:e.backgroundColor??void 0,"& .MuiChip-deleteIcon":{color:e.foregroundColor?`${e.foregroundColor}99`:`inherit`,"&:hover":{color:e.foregroundColor??`inherit`}}},cursor:n&&!e.disabled&&!s?`pointer`:`default`}})}function jr({selectedTags:e,translation:t,onTagDelete:n,showSelectedTagsLabel:r,chipSize:i=`medium`,chipVariant:a=`filled`,disabled:o=!1,maxVisibleChips:s,popoverPlacement:c=`bottom`}){let[l,f]=(0,d.useState)(null),p=s===void 0?e:e.slice(0,s),m=s===void 0?[]:e.slice(s),h=!!l&&m.length>0,_=c===`top`?{vertical:`top`,horizontal:`left`}:{vertical:`bottom`,horizontal:`left`},v=c===`top`?{vertical:`bottom`,horizontal:`left`}:{vertical:`top`,horizontal:`left`};return(0,g.jsxs)(u.Box,{sx:{mb:2},className:rt.selectedTags,children:[r&&(0,g.jsx)(u.Typography,{variant:`subtitle2`,gutterBottom:!0,className:rt.selectedTagsLabel,children:t.selectedTagsLabel}),e.length===0?(0,g.jsx)(u.Typography,{variant:`body2`,color:`text.secondary`,children:t.noSelectedTagsText}):(0,g.jsxs)(u.Stack,{direction:`row`,sx:{flexWrap:`wrap`,gap:1},className:rt.chipsStack,children:[p.map(e=>(0,g.jsx)(Ar,{tag:e,onDelete:n,chipSize:i,chipVariant:a,disabled:o},e.id)),m.length>0&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(u.Chip,{size:i,label:`+${m.length}`,variant:`outlined`,clickable:!0,onClick:e=>f(e.currentTarget),className:rt.overflowChip}),(0,g.jsx)(u.Popover,{open:h,anchorEl:l,onClose:()=>f(null),anchorOrigin:_,transformOrigin:v,children:(0,g.jsx)(u.Box,{sx:{p:1,display:`flex`,flexWrap:`wrap`,gap:.5,maxWidth:320},className:rt.overflowPopover,children:m.map(e=>(0,g.jsx)(Ar,{tag:e,onDelete:o?void 0:n,chipSize:i,chipVariant:a,disabled:o},e.id))})})]})]})]})}var Mr={selectedTagsLabel:`Selected tags`,autoCompleteLabel:`Search and add tags`,noSelectedTagsText:`No tags selected.`,noAvailableTagsText:`No tags available.`,placeholder:`Type to search...`,loadingText:`Loading...`,maxTagsReachedText:`Maximum number of tags reached.`,colorPickerLabel:`Custom color`,backgroundColorLabel:`Background color`,textColorLabel:`Text color`,autoTextColorLabel:`Auto`,confirmCreateLabel:`Confirm new tag`,cancelCreateLabel:`Cancel new tag`},Nr=(0,d.createContext)(null);function Pr(e){let t=(0,d.useContext)(Nr);if(!t)throw Error(`TagSelectionStoreContext is missing.`);return(0,L.useStore)(t,e)}function Fr({tags:e,showSelectedTags:t=!0,showSelectedTagsLabel:n=!0,showAutoComplete:r=!0,inputSize:i=`medium`,chipSize:a=`small`,chipVariant:o=`filled`,disabled:s=!1,loading:c=!1,maxTags:l,allowCreate:f=!1,maxVisibleChips:p,popoverPlacement:m=`bottom`,listboxMaxHeight:h,searchDebounceMs:_,serverSideFilter:v=!1,translation:y,onTagSelect:b,onTagDelete:x,onTagsChange:S,onSearchChange:C,onTagCreate:w}){let T=Pr(e=>e.tags),E=Pr(e=>e.searchValue),D=Pr(e=>e.setTags),O=Pr(e=>e.setSearchValue),k=Pr(e=>e.selectTag),A=Pr(e=>e.deleteTag),j=Pr(e=>e.addTag);(0,d.useEffect)(()=>{D(e)},[e,D]);let M=(0,d.useMemo)(()=>T.filter(e=>e.selected).sort((e,t)=>e.label.localeCompare(t.label)),[T]),N=(0,d.useMemo)(()=>T.filter(e=>!e.selected&&!e.disabled).sort((e,t)=>e.label.localeCompare(t.label)),[T]),P=l!==void 0&&M.length>=l,F=e=>{S&&S(e.filter(e=>e.selected),e)},I=e=>{if(e.disabled||e.selected)return;k(e.id);let t=T.map(t=>t.id===e.id?{...t,selected:!0}:t),n=t.filter(e=>e.selected),r=t.find(t=>t.id===e.id);r&&b&&b(r,n,t),F(t)},L=e=>{A(e.id);let t=T.map(t=>t.id===e.id?{...t,selected:!1}:t),n=t.filter(e=>e.selected),r=t.find(t=>t.id===e.id);r&&x&&x(r,n,t),F(t)},R=(0,d.useRef)(null);return(0,d.useEffect)(()=>()=>{R.current&&clearTimeout(R.current)},[]),(0,g.jsx)(u.Box,{sx:{width:`100%`},className:[rt.root,s&&Be.disabled].filter(Boolean).join(` `),children:(0,g.jsxs)(u.Stack,{children:[t&&(0,g.jsx)(jr,{selectedTags:M,translation:y,onTagDelete:L,showSelectedTagsLabel:n,chipSize:a,chipVariant:o,disabled:s,maxVisibleChips:p,popoverPlacement:m}),r&&(0,g.jsx)(kr,{availableTags:N,searchValue:E,translation:y,onSearchChange:e=>{if(O(e),C){if(R.current&&=(clearTimeout(R.current),null),!_){C(e);return}R.current=setTimeout(()=>{C(e),R.current=null},_)}},onTagSelect:I,onTagCreate:e=>{j(e),F([...T,e]),w&&w(e)},inputSize:i,chipSize:a,chipVariant:o,disabled:s,loading:c,isMaxReached:P,allowCreate:f,listboxMaxHeight:h,serverSideFilter:v})]})})}function Ir({tags:e,showSelectedTags:t=!0,showSelectedTagsLabel:n=!0,showAutoComplete:r=!0,translation:i,inputSize:a=`medium`,chipSize:o=`small`,chipVariant:s=`filled`,disabled:c=!1,loading:l=!1,maxTags:u,allowCreate:f=!1,maxVisibleChips:p,popoverPlacement:m=`bottom`,listboxMaxHeight:h,searchDebounceMs:_,serverSideFilter:v=!1,onTagSelect:y,onTagDelete:b,onTagsChange:x,onSearchChange:S,onTagCreate:C}){let w={...Mr,...i},[T]=(0,d.useState)(()=>xr(e));return(0,g.jsx)(Nr.Provider,{value:T,children:(0,g.jsx)(Fr,{tags:e,showSelectedTags:t,showSelectedTagsLabel:n,showAutoComplete:r,translation:w,inputSize:a,chipSize:o,chipVariant:s,disabled:c,loading:l,maxTags:u,allowCreate:f,maxVisibleChips:p,popoverPlacement:m,listboxMaxHeight:h,searchDebounceMs:_,serverSideFilter:v,onTagSelect:y,onTagDelete:b,onTagsChange:x,onSearchChange:S,onTagCreate:C})})}var Lr={showBold:!0,showItalic:!0,showUnderline:!0,showStrike:!0,showHeading1:!0,showHeading2:!0,showHeading3:!0,showBulletList:!0,showOrderedList:!0,showBlockquote:!0,showCodeBlock:!0,showLink:!0,showHorizontalRule:!0,showTextColor:!0,showHighlight:!0,showUndoRedo:!0,showClearFormat:!0,showFullscreenButton:!1,showTableButton:!1,showImageButton:!1,showEmojiButton:!1,showPasteAsPlainTextButton:!1,showMarkdownButton:!1},Rr={bold:`Bold`,italic:`Italic`,underline:`Underline`,strike:`Strikethrough`,heading1:`Heading 1`,heading2:`Heading 2`,heading3:`Heading 3`,bulletList:`Bullet list`,orderedList:`Numbered list`,blockquote:`Blockquote`,codeBlock:`Code block`,link:`Insert link`,horizontalRule:`Horizontal rule`,textColor:`Text color`,removeTextColor:`Remove text color`,highlight:`Highlight`,removeHighlight:`Remove highlight`,undo:`Undo`,redo:`Redo`,clearFormat:`Clear formatting`,linkDialogTitle:`Insert link`,linkDialogUrlLabel:`URL`,linkDialogSave:`Save`,linkDialogCancel:`Cancel`,linkDialogRemove:`Remove link`,characterCount:`{count} characters`,characterCountMax:`{count} / {max} characters`,wordCount:`{count} words`,fullscreen:`Full screen`,exitFullscreen:`Exit full screen`,table:`Table`,insertTable:`Insert 3×3 table`,addRowBefore:`Add row before`,addRowAfter:`Add row after`,deleteRow:`Delete row`,addColumnBefore:`Add column before`,addColumnAfter:`Add column after`,deleteColumn:`Delete column`,deleteTable:`Delete table`,image:`Insert image`,imageDialogTitle:`Insert image`,imageDialogUrlLabel:`Image URL`,imageDialogAltLabel:`Alt text (optional)`,imageDialogSave:`Insert`,imageDialogCancel:`Cancel`,emoji:`Emoji`,emojiSearchPlaceholder:`Search emoji…`,pasteAsPlainText:`Paste as plain text`,pasteAsHtml:`Paste with formatting`,markdown:`Markdown`,markdownDialogTitle:`Markdown`,markdownDialogDescription:`Edit as Markdown, then apply to replace the editor content. Copy to export.`,markdownDialogApply:`Apply`,markdownDialogCancel:`Cancel`,markdownDialogCopy:`Copy`,markdownDialogCopied:`Copied!`,mentionNoResults:`No results`},zr=(0,d.forwardRef)(function({items:e,noResultsLabel:t,clientRect:n,onSelect:r},i){let[a,o]=(0,d.useState)(0),[s,c]=(0,d.useState)(e),l=(0,d.useRef)(null);e!==s&&(c(e),o(0)),(0,d.useEffect)(()=>{(l.current?.children[a])?.scrollIntoView({block:`nearest`})},[a]),(0,d.useImperativeHandle)(i,()=>({onKeyDown(t){return t.key===`ArrowUp`?(o(t=>(t-1+e.length)%e.length),!0):t.key===`ArrowDown`?(o(t=>(t+1)%e.length),!0):t.key===`Enter`?(e[a]&&r(e[a]),!0):!1}}));let f=n?{getBoundingClientRect:n}:null;return(0,g.jsx)(u.Popper,{open:!!f,anchorEl:f,placement:`bottom-start`,modifiers:[{name:`offset`,options:{offset:[0,4]}}],style:{zIndex:1400},children:(0,g.jsx)(u.Paper,{elevation:4,sx:{maxHeight:240,overflow:`auto`,minWidth:180},children:e.length===0?(0,g.jsx)(u.Typography,{variant:`body2`,sx:{px:2,py:1,color:`text.secondary`},children:t}):(0,g.jsx)(u.List,{ref:l,dense:!0,disablePadding:!0,children:e.map((e,t)=>(0,g.jsx)(u.ListItemButton,{selected:t===a,onMouseDown:t=>{t.preventDefault(),r(e)},onMouseEnter:()=>o(t),children:e.label},e.id))})})})});function Br(e,t){return n=>{e({id:n.id,label:n.label}),t?.(n)}}function Vr({getItems:e,onMentionSearch:t,onMentionInserted:n,noResultsLabel:r}){return{items:async({query:n})=>{if(t)return t(n);let r=e(),i=n.toLowerCase();return r.filter(e=>e.label.toLowerCase().includes(i))},render(){let e=null;return{onStart(t){e=new Y.ReactRenderer(zr,{props:{items:t.items,noResultsLabel:r,clientRect:t.clientRect,onSelect:Br(t.command,n)},editor:t.editor}),document.body.appendChild(e.element)},onUpdate(t){e?.updateProps({items:t.items,clientRect:t.clientRect})},onKeyDown(t){return t.event.key===`Escape`?(e?.destroy(),e=null,!0):e?.ref?.onKeyDown(t.event)??!1},onExit(){e?.element.remove(),e?.destroy(),e=null}}}}}function Hr({editor:e,error:t,disabled:n,readonly:r}){return(0,g.jsx)(u.Box,{sx:{flex:1,minHeight:0,display:`flex`,flexDirection:`column`,px:1.5,py:1,cursor:n||r?`default`:`text`,opacity:n?.5:1,"& > div":{flex:1,display:`flex`,flexDirection:`column`,minHeight:0},"& .ProseMirror":{flex:1,minHeight:0,overflowY:`auto`,overflowX:`hidden`,wordBreak:`break-word`,overflowWrap:`break-word`,outline:`none`,"& p.is-editor-empty:first-of-type::before":{content:`attr(data-placeholder)`,color:`text.disabled`,pointerEvents:`none`,float:`left`,height:0},"& h1":{typography:`h4`,mb:1},"& h2":{typography:`h5`,mb:1},"& h3":{typography:`h6`,mb:1},"& p":{my:.5},"& ul, & ol":{pl:3},"& blockquote":{borderLeft:`4px solid`,borderColor:t?`error.main`:`divider`,pl:2,color:`text.secondary`,my:1},"& code":{bgcolor:`action.hover`,px:.5,borderRadius:.5,fontFamily:`monospace`,fontSize:`0.875em`},"& pre":{bgcolor:`action.hover`,p:1.5,borderRadius:1,overflowX:`auto`,"& code":{bgcolor:`transparent`,px:0}},"& a":{color:`primary.main`,cursor:`pointer`},"& mark":{borderRadius:.5,px:.25},"& hr":{borderColor:`divider`,my:2},"& table":{borderCollapse:`collapse`,tableLayout:`fixed`,width:`100%`,margin:`8px 0`,overflowX:`auto`},"& table td, & table th":{border:`1px solid`,borderColor:`divider`,padding:`6px 8px`,verticalAlign:`top`,boxSizing:`border-box`,minWidth:`2em`,position:`relative`},"& table th":{fontWeight:`bold`,bgcolor:`action.hover`},"& table .selectedCell::after":{content:`""`,position:`absolute`,inset:0,bgcolor:`primary.main`,opacity:.12,pointerEvents:`none`,zIndex:2},"& img":{maxWidth:`100%`,height:`auto`,borderRadius:`4px`,display:`block`,my:1}}},children:(0,g.jsx)(Y.EditorContent,{editor:e})})}function Ur({open:e,onClose:t,editor:n,translation:r}){let[i,a]=(0,d.useState)(``);(0,d.useEffect)(()=>{if(e){let e=n.getAttributes(`link`).href;a(e??``)}},[e,n]);let o=n.isActive(`link`);function s(){i.trim()?n.chain().focus().extendMarkRange(`link`).setLink({href:i.trim()}).run():n.chain().focus().extendMarkRange(`link`).unsetLink().run(),t()}function c(){n.chain().focus().extendMarkRange(`link`).unsetLink().run(),t()}function l(e){e.key===`Enter`&&s()}return(0,g.jsxs)(u.Dialog,{open:e,onClose:t,maxWidth:`sm`,fullWidth:!0,children:[(0,g.jsx)(u.DialogTitle,{children:r.linkDialogTitle}),(0,g.jsx)(u.DialogContent,{children:(0,g.jsx)(u.TextField,{autoFocus:!0,fullWidth:!0,label:r.linkDialogUrlLabel,value:i,onChange:e=>a(e.target.value),onKeyDown:l,variant:`outlined`,size:`small`,sx:{mt:1},placeholder:`https://`})}),(0,g.jsxs)(u.DialogActions,{sx:{px:3,pb:2,gap:1},children:[o&&(0,g.jsx)(u.Button,{onClick:c,color:`error`,sx:{mr:`auto`},children:r.linkDialogRemove}),(0,g.jsx)(u.Button,{onClick:t,children:r.linkDialogCancel}),(0,g.jsx)(u.Button,{onClick:s,variant:`contained`,children:r.linkDialogSave})]})]})}var Wr=[`#000000`,`#434343`,`#666666`,`#999999`,`#b7b7b7`,`#ffffff`,`#ff0000`,`#ff4500`,`#ff8c00`,`#ffd700`,`#9acd32`,`#008000`,`#00ced1`,`#1e90ff`,`#0000ff`,`#8a2be2`,`#ff1493`,`#a52a2a`],Gr=[`#ffff00`,`#ffd700`,`#ffa500`,`#ff69b4`,`#ff6347`,`#fa8072`,`#adff2f`,`#90ee90`,`#00fa9a`,`#00ffff`,`#87ceeb`,`#add8e6`,`#dda0dd`,`#ee82ee`,`#d2b48c`,`#f5f5dc`,`#ffffff`,`#000000`];function Kr({color:e,active:t,onClick:n}){return(0,g.jsx)(u.Tooltip,{title:e,placement:`top`,arrow:!0,children:(0,g.jsx)(u.Box,{component:`button`,type:`button`,onClick:()=>n(e),"aria-label":e,"aria-pressed":t,sx:{width:22,height:22,bgcolor:e,border:t?`2px solid`:`1px solid`,borderColor:t?`primary.main`:e===`#ffffff`||e===`#f5f5dc`?`divider`:`transparent`,borderRadius:.5,cursor:`pointer`,p:0,display:`flex`,alignItems:`center`,justifyContent:`center`,transition:`transform 0.1s`,"&:hover":{transform:`scale(1.2)`,zIndex:1}},children:t&&(0,g.jsx)(u.Box,{component:`span`,sx:{width:10,height:6,borderLeft:`2px solid`,borderBottom:`2px solid`,borderColor:e===`#ffffff`||e===`#f5f5dc`||e===`#ffd700`||e===`#ffff00`||e===`#adff2f`||e===`#ffa500`||e===`#b7b7b7`||e===`#d2b48c`?`#000`:`#fff`,transform:`rotate(-45deg) translateY(-1px)`,display:`block`}})})})}function qr({anchorEl:e,open:t,onClose:n,mode:r,activeColor:i,onSelectColor:a,onRemoveColor:o,removeLabel:s}){let c=(0,d.useRef)(null),l=r===`highlight`?Gr:Wr;function f(e){a(e.target.value)}return(0,g.jsxs)(u.Popover,{open:t,anchorEl:e,onClose:n,anchorOrigin:{vertical:`bottom`,horizontal:`left`},transformOrigin:{vertical:`top`,horizontal:`left`},slotProps:{paper:{sx:{p:1.5}}},children:[(0,g.jsx)(u.Box,{sx:{display:`grid`,gridTemplateColumns:`repeat(6, 22px)`,gap:.5,mb:1},children:l.map(e=>(0,g.jsx)(Kr,{color:e,active:i?.toLowerCase()===e.toLowerCase(),onClick:e=>{a(e),n()}},e))}),(0,g.jsxs)(u.Box,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,g.jsx)(u.Tooltip,{title:`Custom color`,arrow:!0,children:(0,g.jsx)(u.Box,{component:`button`,type:`button`,onClick:()=>c.current?.click(),"aria-label":`Custom color`,sx:{width:22,height:22,background:`conic-gradient(red, yellow, lime, cyan, blue, magenta, red)`,border:`1px solid`,borderColor:`divider`,borderRadius:.5,cursor:`pointer`,p:0,flexShrink:0,"&:hover":{transform:`scale(1.2)`},transition:`transform 0.1s`}})}),(0,g.jsx)(`input`,{ref:c,type:`color`,defaultValue:i??`#000000`,onChange:f,onBlur:n,style:{visibility:`hidden`,width:0,height:0,position:`absolute`}}),(0,g.jsx)(u.Tooltip,{title:s,arrow:!0,children:(0,g.jsx)(u.IconButton,{size:`small`,onClick:()=>{o(),n()},"aria-label":s,sx:{borderRadius:1,ml:`auto`},children:(0,g.jsx)(Ae.default,{fontSize:`small`})})})]})]})}function Jr({editor:e,translation:t,disabled:n}){let[r,i]=(0,d.useState)(null),a=n||!e,o=e?.isActive(`table`)??!1;function s(){i(null)}function c(e){e(),s()}return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(u.Tooltip,{title:t.table,arrow:!0,children:(0,g.jsx)(`span`,{children:(0,g.jsx)(u.IconButton,{size:`small`,onMouseDown:e=>e.preventDefault(),onClick:e=>i(e.currentTarget),disabled:a,color:o?`primary`:`default`,sx:{borderRadius:1},"aria-label":t.table,"aria-pressed":o,children:(0,g.jsx)(je.default,{fontSize:`small`})})})}),(0,g.jsxs)(u.Menu,{anchorEl:r,open:!!r,onClose:s,slotProps:{paper:{sx:{minWidth:220}}},children:[(0,g.jsxs)(u.MenuItem,{onClick:()=>c(()=>e?.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()),children:[(0,g.jsx)(u.ListItemIcon,{children:(0,g.jsx)(je.default,{fontSize:`small`})}),(0,g.jsx)(u.ListItemText,{children:t.insertTable})]}),o&&(0,g.jsx)(u.Divider,{}),o&&(0,g.jsxs)(u.MenuItem,{onClick:()=>c(()=>e?.chain().focus().addRowBefore().run()),children:[(0,g.jsx)(u.ListItemIcon,{children:(0,g.jsx)(v.default,{fontSize:`small`})}),(0,g.jsx)(u.ListItemText,{children:t.addRowBefore})]}),o&&(0,g.jsxs)(u.MenuItem,{onClick:()=>c(()=>e?.chain().focus().addRowAfter().run()),children:[(0,g.jsx)(u.ListItemIcon,{children:(0,g.jsx)(v.default,{fontSize:`small`})}),(0,g.jsx)(u.ListItemText,{children:t.addRowAfter})]}),o&&(0,g.jsxs)(u.MenuItem,{onClick:()=>c(()=>e?.chain().focus().deleteRow().run()),children:[(0,g.jsx)(u.ListItemIcon,{children:(0,g.jsx)(_.default,{fontSize:`small`,color:`error`})}),(0,g.jsx)(u.ListItemText,{sx:{color:`error.main`},children:t.deleteRow})]}),o&&(0,g.jsx)(u.Divider,{}),o&&(0,g.jsxs)(u.MenuItem,{onClick:()=>c(()=>e?.chain().focus().addColumnBefore().run()),children:[(0,g.jsx)(u.ListItemIcon,{children:(0,g.jsx)(v.default,{fontSize:`small`})}),(0,g.jsx)(u.ListItemText,{children:t.addColumnBefore})]}),o&&(0,g.jsxs)(u.MenuItem,{onClick:()=>c(()=>e?.chain().focus().addColumnAfter().run()),children:[(0,g.jsx)(u.ListItemIcon,{children:(0,g.jsx)(v.default,{fontSize:`small`})}),(0,g.jsx)(u.ListItemText,{children:t.addColumnAfter})]}),o&&(0,g.jsxs)(u.MenuItem,{onClick:()=>c(()=>e?.chain().focus().deleteColumn().run()),children:[(0,g.jsx)(u.ListItemIcon,{children:(0,g.jsx)(_.default,{fontSize:`small`,color:`error`})}),(0,g.jsx)(u.ListItemText,{sx:{color:`error.main`},children:t.deleteColumn})]}),o&&(0,g.jsx)(u.Divider,{}),o&&(0,g.jsxs)(u.MenuItem,{onClick:()=>c(()=>e?.chain().focus().deleteTable().run()),children:[(0,g.jsx)(u.ListItemIcon,{children:(0,g.jsx)(_.default,{fontSize:`small`,color:`error`})}),(0,g.jsx)(u.ListItemText,{sx:{color:`error.main`},children:t.deleteTable})]})]})]})}function Yr({open:e,onClose:t,editor:n,translation:r}){let[i,a]=(0,d.useState)(``),[o,s]=(0,d.useState)(``);function c(){let e=i.trim();e&&(n.chain().focus().setImage({src:e,alt:o.trim()||void 0}).run(),a(``),s(``),t())}function l(){a(``),s(``),t()}function f(e){e.key===`Enter`&&c()}return(0,g.jsxs)(u.Dialog,{open:e,onClose:l,maxWidth:`sm`,fullWidth:!0,children:[(0,g.jsx)(u.DialogTitle,{children:r.imageDialogTitle}),(0,g.jsxs)(u.DialogContent,{sx:{display:`flex`,flexDirection:`column`,gap:2,pt:`16px !important`},children:[(0,g.jsx)(u.TextField,{autoFocus:!0,fullWidth:!0,label:r.imageDialogUrlLabel,value:i,onChange:e=>a(e.target.value),onKeyDown:f,variant:`outlined`,size:`small`,placeholder:`https://example.com/image.png`}),(0,g.jsx)(u.TextField,{fullWidth:!0,label:r.imageDialogAltLabel,value:o,onChange:e=>s(e.target.value),onKeyDown:f,variant:`outlined`,size:`small`})]}),(0,g.jsxs)(u.DialogActions,{sx:{px:3,pb:2,gap:1},children:[(0,g.jsx)(u.Button,{onClick:l,children:r.imageDialogCancel}),(0,g.jsx)(u.Button,{onClick:c,variant:`contained`,disabled:!i.trim(),children:r.imageDialogSave})]})]})}var Xr=[{label:`Smileys`,emojis:[{emoji:`😀`,name:`grinning face`},{emoji:`😃`,name:`grinning face with big eyes`},{emoji:`😄`,name:`grinning face with smiling eyes`},{emoji:`😁`,name:`beaming face with smiling eyes`},{emoji:`😆`,name:`grinning squinting face`},{emoji:`😅`,name:`grinning face with sweat`},{emoji:`😂`,name:`face with tears of joy`},{emoji:`🤣`,name:`rolling on the floor laughing`},{emoji:`😊`,name:`smiling face with smiling eyes`},{emoji:`😇`,name:`smiling face with halo`},{emoji:`🙂`,name:`slightly smiling face`},{emoji:`😉`,name:`winking face`},{emoji:`😍`,name:`smiling face with heart eyes`},{emoji:`🥰`,name:`smiling face with hearts`},{emoji:`😘`,name:`face blowing a kiss`},{emoji:`😋`,name:`face savoring food`},{emoji:`😎`,name:`smiling face with sunglasses`},{emoji:`🤩`,name:`star struck`},{emoji:`🥳`,name:`partying face`},{emoji:`😏`,name:`smirking face`},{emoji:`😒`,name:`unamused face`},{emoji:`😔`,name:`pensive face`},{emoji:`😢`,name:`crying face`},{emoji:`😭`,name:`loudly crying face`},{emoji:`😤`,name:`face with steam from nose`},{emoji:`😠`,name:`angry face`},{emoji:`🤬`,name:`face with symbols on mouth`},{emoji:`😱`,name:`face screaming in fear`},{emoji:`😳`,name:`flushed face`},{emoji:`🤔`,name:`thinking face`},{emoji:`🙄`,name:`face with rolling eyes`},{emoji:`😴`,name:`sleeping face`},{emoji:`🤢`,name:`nauseated face`},{emoji:`🤧`,name:`sneezing face`},{emoji:`😷`,name:`face with medical mask`}]},{label:`Gestures`,emojis:[{emoji:`👋`,name:`waving hand`},{emoji:`🤚`,name:`raised back of hand`},{emoji:`✋`,name:`raised hand`},{emoji:`🖐️`,name:`hand with fingers splayed`},{emoji:`👌`,name:`ok hand`},{emoji:`✌️`,name:`victory hand`},{emoji:`🤞`,name:`crossed fingers`},{emoji:`🤙`,name:`call me hand`},{emoji:`👈`,name:`backhand index pointing left`},{emoji:`👉`,name:`backhand index pointing right`},{emoji:`👆`,name:`backhand index pointing up`},{emoji:`👇`,name:`backhand index pointing down`},{emoji:`☝️`,name:`index pointing up`},{emoji:`👍`,name:`thumbs up`},{emoji:`👎`,name:`thumbs down`},{emoji:`✊`,name:`raised fist`},{emoji:`👊`,name:`oncoming fist`},{emoji:`👏`,name:`clapping hands`},{emoji:`🙌`,name:`raising hands`},{emoji:`🤝`,name:`handshake`},{emoji:`🙏`,name:`folded hands`},{emoji:`💪`,name:`flexed biceps`},{emoji:`🦾`,name:`mechanical arm`},{emoji:`👀`,name:`eyes`},{emoji:`👁️`,name:`eye`},{emoji:`👅`,name:`tongue`},{emoji:`💋`,name:`kiss mark`}]},{label:`Hearts & Symbols`,emojis:[{emoji:`❤️`,name:`red heart`},{emoji:`🧡`,name:`orange heart`},{emoji:`💛`,name:`yellow heart`},{emoji:`💚`,name:`green heart`},{emoji:`💙`,name:`blue heart`},{emoji:`💜`,name:`purple heart`},{emoji:`🖤`,name:`black heart`},{emoji:`🤍`,name:`white heart`},{emoji:`💔`,name:`broken heart`},{emoji:`💕`,name:`two hearts`},{emoji:`💞`,name:`revolving hearts`},{emoji:`💖`,name:`sparkling heart`},{emoji:`💘`,name:`heart with arrow`},{emoji:`💝`,name:`heart with ribbon`},{emoji:`✨`,name:`sparkles`},{emoji:`⭐`,name:`star`},{emoji:`🌟`,name:`glowing star`},{emoji:`💫`,name:`dizzy`},{emoji:`🔥`,name:`fire`},{emoji:`💧`,name:`droplet`},{emoji:`💯`,name:`hundred points`},{emoji:`✅`,name:`check mark button`},{emoji:`❌`,name:`cross mark`},{emoji:`⚠️`,name:`warning`},{emoji:`🎉`,name:`party popper`},{emoji:`🎊`,name:`confetti ball`},{emoji:`🏆`,name:`trophy`},{emoji:`🥇`,name:`first place medal`}]},{label:`Nature`,emojis:[{emoji:`🐶`,name:`dog face`},{emoji:`🐱`,name:`cat face`},{emoji:`🐭`,name:`mouse face`},{emoji:`🐹`,name:`hamster`},{emoji:`🐰`,name:`rabbit face`},{emoji:`🦊`,name:`fox`},{emoji:`🐻`,name:`bear`},{emoji:`🐼`,name:`panda`},{emoji:`🐨`,name:`koala`},{emoji:`🐯`,name:`tiger face`},{emoji:`🦁`,name:`lion`},{emoji:`🐸`,name:`frog`},{emoji:`🐧`,name:`penguin`},{emoji:`🐦`,name:`bird`},{emoji:`🦋`,name:`butterfly`},{emoji:`🌸`,name:`cherry blossom`},{emoji:`🌺`,name:`hibiscus`},{emoji:`🌻`,name:`sunflower`},{emoji:`🌹`,name:`rose`},{emoji:`🌿`,name:`herb`},{emoji:`🍀`,name:`four leaf clover`},{emoji:`🌲`,name:`evergreen tree`},{emoji:`🌴`,name:`palm tree`},{emoji:`🌊`,name:`water wave`},{emoji:`🌈`,name:`rainbow`},{emoji:`☀️`,name:`sun`},{emoji:`🌙`,name:`crescent moon`},{emoji:`❄️`,name:`snowflake`},{emoji:`⚡`,name:`lightning`},{emoji:`🌪️`,name:`tornado`}]},{label:`Food`,emojis:[{emoji:`🍎`,name:`red apple`},{emoji:`🍊`,name:`tangerine`},{emoji:`🍋`,name:`lemon`},{emoji:`🍇`,name:`grapes`},{emoji:`🍓`,name:`strawberry`},{emoji:`🍒`,name:`cherries`},{emoji:`🍑`,name:`peach`},{emoji:`🥭`,name:`mango`},{emoji:`🍍`,name:`pineapple`},{emoji:`🥥`,name:`coconut`},{emoji:`🥝`,name:`kiwi fruit`},{emoji:`🍅`,name:`tomato`},{emoji:`🥑`,name:`avocado`},{emoji:`🌽`,name:`ear of corn`},{emoji:`🍕`,name:`pizza`},{emoji:`🍔`,name:`hamburger`},{emoji:`🌮`,name:`taco`},{emoji:`🍜`,name:`steaming bowl`},{emoji:`🍣`,name:`sushi`},{emoji:`🍩`,name:`doughnut`},{emoji:`🎂`,name:`birthday cake`},{emoji:`🍰`,name:`shortcake`},{emoji:`🍦`,name:`soft ice cream`},{emoji:`🍫`,name:`chocolate bar`},{emoji:`☕`,name:`hot beverage`},{emoji:`🧃`,name:`beverage box`},{emoji:`🍺`,name:`beer mug`},{emoji:`🥂`,name:`clinking glasses`}]},{label:`Objects & Travel`,emojis:[{emoji:`📱`,name:`mobile phone`},{emoji:`💻`,name:`laptop`},{emoji:`🖥️`,name:`desktop computer`},{emoji:`⌨️`,name:`keyboard`},{emoji:`📷`,name:`camera`},{emoji:`📺`,name:`television`},{emoji:`🎮`,name:`video game`},{emoji:`🎸`,name:`guitar`},{emoji:`🎹`,name:`musical keyboard`},{emoji:`📚`,name:`books`},{emoji:`📝`,name:`memo`},{emoji:`✏️`,name:`pencil`},{emoji:`🔍`,name:`magnifying glass tilted left`},{emoji:`💡`,name:`light bulb`},{emoji:`🔑`,name:`key`},{emoji:`🔒`,name:`locked`},{emoji:`⚙️`,name:`gear`},{emoji:`🔧`,name:`wrench`},{emoji:`🏠`,name:`house`},{emoji:`🏢`,name:`office building`},{emoji:`✈️`,name:`airplane`},{emoji:`🚀`,name:`rocket`},{emoji:`🚗`,name:`automobile`},{emoji:`🚲`,name:`bicycle`},{emoji:`⛵`,name:`sailboat`},{emoji:`🗺️`,name:`world map`},{emoji:`🏔️`,name:`snow capped mountain`},{emoji:`🏖️`,name:`beach with umbrella`}]}];function Zr({anchorEl:e,open:t,onClose:n,onSelect:r,translation:i}){let[a,o]=(0,d.useState)(``),s=(0,d.useMemo)(()=>{let e=a.trim().toLowerCase();return e?Xr.map(t=>({...t,emojis:t.emojis.filter(t=>t.name.includes(e)||t.emoji===e)})).filter(e=>e.emojis.length>0):Xr},[a]);function c(e){r(e),n(),o(``)}function l(){n(),o(``)}return(0,g.jsxs)(u.Popover,{open:t,anchorEl:e,onClose:l,anchorOrigin:{vertical:`bottom`,horizontal:`left`},transformOrigin:{vertical:`top`,horizontal:`left`},slotProps:{paper:{sx:{width:320,maxHeight:380,display:`flex`,flexDirection:`column`}}},children:[(0,g.jsx)(u.Box,{sx:{p:1,borderBottom:1,borderColor:`divider`},children:(0,g.jsx)(u.TextField,{autoFocus:!0,fullWidth:!0,size:`small`,placeholder:i.emojiSearchPlaceholder,value:a,onChange:e=>o(e.target.value),slotProps:{input:{startAdornment:(0,g.jsx)(u.InputAdornment,{position:`start`,children:(0,g.jsx)(Me.default,{fontSize:`small`})})}}})}),(0,g.jsxs)(u.Box,{sx:{overflowY:`auto`,flex:1,px:1,pb:1},children:[s.map(e=>(0,g.jsxs)(u.Box,{children:[(0,g.jsx)(u.Typography,{variant:`caption`,sx:{display:`block`,color:`text.secondary`,mt:1,mb:.5,px:.5},children:e.label}),(0,g.jsx)(u.Box,{sx:{display:`flex`,flexWrap:`wrap`,gap:.25},children:e.emojis.map(e=>(0,g.jsx)(u.Box,{component:`button`,title:e.name,"aria-label":e.name,onClick:()=>c(e.emoji),sx:{border:`none`,background:`none`,cursor:`pointer`,fontSize:`1.375rem`,lineHeight:1,p:.5,borderRadius:1,"&:hover":{bgcolor:`action.hover`}},children:e.emoji},e.emoji))})]},e.label)),s.length===0&&(0,g.jsx)(u.Typography,{variant:`body2`,color:`text.secondary`,sx:{p:2,textAlign:`center`},children:`No emoji found`})]})]})}function Qr({open:e,onClose:t,editor:n,translation:r}){let[i,a]=(0,d.useState)(``),[o,s]=Yt();(0,d.useEffect)(()=>{e&&a(n.storage.markdown.getMarkdown())},[e,n]);function c(){n.commands.setContent(i),t()}function l(){navigator.clipboard.writeText(i).then(()=>{s()})}return(0,g.jsxs)(u.Dialog,{open:e,onClose:t,maxWidth:`sm`,fullWidth:!0,children:[(0,g.jsx)(u.DialogTitle,{children:r.markdownDialogTitle}),(0,g.jsxs)(u.DialogContent,{sx:{display:`flex`,flexDirection:`column`,gap:1.5,pt:`16px !important`},children:[(0,g.jsx)(u.Typography,{variant:`body2`,color:`text.secondary`,children:r.markdownDialogDescription}),(0,g.jsx)(u.TextField,{autoFocus:!0,fullWidth:!0,multiline:!0,minRows:8,maxRows:16,value:i,onChange:e=>a(e.target.value),variant:`outlined`,size:`small`,sx:{fontFamily:`monospace`},slotProps:{htmlInput:{style:{fontFamily:`monospace`,fontSize:`0.8125rem`}}}})]}),(0,g.jsxs)(u.DialogActions,{sx:{px:3,pb:2,gap:1},children:[(0,g.jsx)(u.Box,{sx:{flex:1},children:(0,g.jsx)(u.Button,{onClick:l,startIcon:o?(0,g.jsx)(A.default,{fontSize:`small`,color:`success`}):(0,g.jsx)(O.default,{fontSize:`small`}),children:o?r.markdownDialogCopied:r.markdownDialogCopy})}),(0,g.jsx)(u.Button,{onClick:t,children:r.markdownDialogCancel}),(0,g.jsx)(u.Button,{onClick:c,variant:`contained`,children:r.markdownDialogApply})]})]})}function $r({label:e,icon:t,activeColor:n,disabled:r,onClick:i}){return(0,g.jsx)(u.Tooltip,{title:e,arrow:!0,children:(0,g.jsx)(`span`,{children:(0,g.jsxs)(u.IconButton,{size:`small`,onMouseDown:e=>e.preventDefault(),onClick:i,disabled:r,sx:{borderRadius:1,flexDirection:`column`,gap:0,pb:.25},"aria-label":e,children:[(0,g.jsx)(u.Box,{sx:{display:`flex`,alignItems:`center`},children:t}),(0,g.jsx)(u.Box,{sx:{width:`80%`,height:3,bgcolor:n??`text.primary`,borderRadius:.5,mt:`1px`}})]})})})}function ei({text:e}){return(0,g.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 20 20`,"aria-hidden":`true`,style:{display:`block`},children:(0,g.jsx)(`text`,{x:`10`,y:`10`,dominantBaseline:`central`,textAnchor:`middle`,fontSize:`10`,fontWeight:`500`,fontFamily:`inherit`,fill:`currentColor`,children:e})})}function ti({level:e}){return(0,g.jsx)(ei,{text:`H${e}`})}function ni({editor:e,toolbarConfig:t,translation:n,disabled:r,isFullscreen:i,onToggleFullscreen:a,pasteAsPlainText:o,onTogglePasteAsPlainText:s}){let[c,l]=(0,d.useState)(!1),[f,p]=(0,d.useState)(!1),[m,h]=(0,d.useState)(!1),[_,v]=(0,d.useState)(null),[y,b]=(0,d.useState)(null),[x,S]=(0,d.useState)(null),C=r||!e,w=e?.getAttributes(`textStyle`)?.color,T=e?.getAttributes(`highlight`)?.color,E=t.showBold||t.showItalic||t.showUnderline||t.showStrike,D=t.showHeading1||t.showHeading2||t.showHeading3,O=t.showBulletList||t.showOrderedList,k=t.showBlockquote||t.showCodeBlock||t.showLink||t.showHorizontalRule,A=t.showTextColor||t.showHighlight,N=t.showUndoRedo||t.showClearFormat,P=t.showTableButton||t.showImageButton||t.showEmojiButton,F=[E,D,O,k,A,N,P],I=F.filter(Boolean).length;function L(e,t){return!e||F.slice(t+1).findIndex(Boolean)===-1?null:(0,g.jsx)(u.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}},`div-${t}`)}return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(u.Box,{sx:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:.25,px:1,py:.5},role:`toolbar`,"aria-label":`Text formatting`,children:[E&&(0,g.jsxs)(u.Box,{sx:{display:`flex`,gap:.25},children:[t.showBold&&(0,g.jsx)(Q,{label:n.bold,icon:(0,g.jsx)(he.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleBold().run(),active:e?.isActive(`bold`),disabled:C}),t.showItalic&&(0,g.jsx)(Q,{label:n.italic,icon:(0,g.jsx)(ge.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleItalic().run(),active:e?.isActive(`italic`),disabled:C}),t.showUnderline&&(0,g.jsx)(Q,{label:n.underline,icon:(0,g.jsx)(_e.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleUnderline().run(),active:e?.isActive(`underline`),disabled:C}),t.showStrike&&(0,g.jsx)(Q,{label:n.strike,icon:(0,g.jsx)(ve.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleStrike().run(),active:e?.isActive(`strike`),disabled:C})]}),L(E,0),D&&(0,g.jsxs)(u.Box,{sx:{display:`flex`,gap:.25},children:[t.showHeading1&&(0,g.jsx)(Q,{label:n.heading1,icon:(0,g.jsx)(ti,{level:1}),onClick:()=>e?.chain().focus().toggleHeading({level:1}).run(),active:e?.isActive(`heading`,{level:1}),disabled:C}),t.showHeading2&&(0,g.jsx)(Q,{label:n.heading2,icon:(0,g.jsx)(ti,{level:2}),onClick:()=>e?.chain().focus().toggleHeading({level:2}).run(),active:e?.isActive(`heading`,{level:2}),disabled:C}),t.showHeading3&&(0,g.jsx)(Q,{label:n.heading3,icon:(0,g.jsx)(ti,{level:3}),onClick:()=>e?.chain().focus().toggleHeading({level:3}).run(),active:e?.isActive(`heading`,{level:3}),disabled:C})]}),L(D,1),O&&(0,g.jsxs)(u.Box,{sx:{display:`flex`,gap:.25},children:[t.showBulletList&&(0,g.jsx)(Q,{label:n.bulletList,icon:(0,g.jsx)(ye.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleBulletList().run(),active:e?.isActive(`bulletList`),disabled:C}),t.showOrderedList&&(0,g.jsx)(Q,{label:n.orderedList,icon:(0,g.jsx)(be.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleOrderedList().run(),active:e?.isActive(`orderedList`),disabled:C})]}),L(O,2),k&&(0,g.jsxs)(u.Box,{sx:{display:`flex`,gap:.25},children:[t.showBlockquote&&(0,g.jsx)(Q,{label:n.blockquote,icon:(0,g.jsx)(xe.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleBlockquote().run(),active:e?.isActive(`blockquote`),disabled:C}),t.showCodeBlock&&(0,g.jsx)(Q,{label:n.codeBlock,icon:(0,g.jsx)(Se.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleCodeBlock().run(),active:e?.isActive(`codeBlock`),disabled:C}),t.showLink&&(0,g.jsx)(Q,{label:n.link,icon:(0,g.jsx)(Ce.default,{fontSize:`small`}),onClick:()=>l(!0),active:e?.isActive(`link`),disabled:C}),t.showHorizontalRule&&(0,g.jsx)(Q,{label:n.horizontalRule,icon:(0,g.jsx)(we.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().setHorizontalRule().run(),disabled:C})]}),L(k,3),A&&(0,g.jsxs)(u.Box,{sx:{display:`flex`,gap:.25},children:[t.showTextColor&&(0,g.jsx)($r,{label:n.textColor,icon:(0,g.jsx)(Te.default,{fontSize:`small`}),activeColor:w,disabled:C,onClick:e=>b(e.currentTarget)}),t.showHighlight&&(0,g.jsx)($r,{label:n.highlight,icon:(0,g.jsx)(Ee.default,{fontSize:`small`}),activeColor:T,disabled:C,onClick:e=>S(e.currentTarget)})]}),L(A,4),N&&(0,g.jsxs)(u.Box,{sx:{display:`flex`,gap:.25},children:[t.showUndoRedo&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Q,{label:n.undo,icon:(0,g.jsx)(j.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().undo().run(),disabled:C||!e?.can().undo()}),(0,g.jsx)(Q,{label:n.redo,icon:(0,g.jsx)(M.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().redo().run(),disabled:C||!e?.can().redo()})]}),t.showClearFormat&&(0,g.jsx)(Q,{label:n.clearFormat,icon:(0,g.jsx)(De.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().clearNodes().unsetAllMarks().run(),disabled:C})]}),L(N,5),P&&(0,g.jsxs)(u.Box,{sx:{display:`flex`,gap:.25},children:[t.showTableButton&&(0,g.jsx)(Jr,{editor:e,translation:n,disabled:C}),t.showImageButton&&(0,g.jsx)(Q,{label:n.image,icon:(0,g.jsx)(pe.default,{fontSize:`small`}),onClick:()=>p(!0),disabled:C}),t.showEmojiButton&&(0,g.jsx)(u.Tooltip,{title:n.emoji,arrow:!0,children:(0,g.jsx)(`span`,{children:(0,g.jsx)(u.IconButton,{size:`small`,onMouseDown:e=>e.preventDefault(),onClick:e=>v(e.currentTarget),disabled:C,sx:{borderRadius:1},"aria-label":n.emoji,children:(0,g.jsx)(me.default,{fontSize:`small`})})})})]}),I===0&&(0,g.jsx)(u.Box,{sx:{height:32}}),(t.showPasteAsPlainTextButton||t.showMarkdownButton||t.showFullscreenButton)&&(0,g.jsxs)(u.Box,{sx:{ml:`auto`,display:`flex`,gap:.25},children:[t.showPasteAsPlainTextButton&&(0,g.jsx)(Q,{label:o?n.pasteAsHtml:n.pasteAsPlainText,icon:o?(0,g.jsx)(ke.default,{fontSize:`small`}):(0,g.jsx)(Oe.default,{fontSize:`small`}),onClick:s,active:o,disabled:r||!e}),t.showMarkdownButton&&(0,g.jsx)(Q,{label:n.markdown,icon:(0,g.jsx)(ei,{text:`MD`}),onClick:()=>h(!0),disabled:r||!e}),t.showFullscreenButton&&(0,g.jsx)(u.Tooltip,{title:i?n.exitFullscreen:n.fullscreen,arrow:!0,children:(0,g.jsx)(`span`,{children:(0,g.jsx)(u.IconButton,{size:`small`,onMouseDown:e=>e.preventDefault(),onClick:a,disabled:r||!e,sx:{borderRadius:1},"aria-label":i?n.exitFullscreen:n.fullscreen,children:i?(0,g.jsx)(fe.default,{fontSize:`small`}):(0,g.jsx)(de.default,{fontSize:`small`})})})})]})]}),t.showLink&&e&&(0,g.jsx)(Ur,{open:c,onClose:()=>l(!1),editor:e,translation:n}),t.showTextColor&&(0,g.jsx)(qr,{anchorEl:y,open:!!y,onClose:()=>b(null),mode:`textColor`,activeColor:w,onSelectColor:t=>e?.chain().focus().setColor(t).run(),onRemoveColor:()=>e?.chain().focus().unsetColor().run(),removeLabel:n.removeTextColor}),t.showHighlight&&(0,g.jsx)(qr,{anchorEl:x,open:!!x,onClose:()=>S(null),mode:`highlight`,activeColor:T,onSelectColor:t=>e?.chain().focus().setHighlight({color:t}).run(),onRemoveColor:()=>e?.chain().focus().unsetHighlight().run(),removeLabel:n.removeHighlight}),t.showImageButton&&e&&(0,g.jsx)(Yr,{open:f,onClose:()=>p(!1),editor:e,translation:n}),t.showMarkdownButton&&e&&(0,g.jsx)(Qr,{open:m,onClose:()=>h(!1),editor:e,translation:n}),t.showEmojiButton&&(0,g.jsx)(Zr,{anchorEl:_,open:!!_,onClose:()=>v(null),onSelect:t=>e?.chain().focus().insertContent(t).run(),translation:n})]})}function ri({helperText:e,error:t,showCharacterCount:n,charCount:r,maxCharacters:i,showWordCount:a,wordCount:o,translation:s}){let c=i===void 0?s.characterCount.replace(`{count}`,String(r)):s.characterCountMax.replace(`{count}`,String(r)).replace(`{max}`,String(i)),l=i!==void 0&&r>=i?`error`:`text.secondary`,d=s.wordCount.replace(`{count}`,String(o));return(0,g.jsxs)(u.Box,{sx:{display:`flex`,justifyContent:`space-between`,mt:.5,px:.5},children:[(0,g.jsx)(u.FormHelperText,{error:t,children:e??``}),(n||a)&&(0,g.jsxs)(u.Box,{sx:{display:`flex`,gap:1.5,alignItems:`center`},children:[a&&(0,g.jsx)(u.FormHelperText,{sx:{color:`text.secondary`},children:d}),n&&(0,g.jsx)(u.FormHelperText,{sx:{color:l},children:c})]})]})}function ii({defaultValue:e,disabled:t=!1,error:n=!1,height:r,helperText:i,maxCharacters:a,mentionItems:o,mentionTriggerChar:s=`@`,name:c,onMentionInserted:l,onMentionSearch:f,placeholder:p,readonly:m=!1,showCharacterCount:h=!1,showToolbar:_=!0,showWordCount:v=!1,toolbarConfig:y,translation:b,value:x,width:S,onBlur:C,onChange:w,onFocus:T,onMarkdownChange:E,onSave:D}){let O={...Rr,...b},k={...Lr,...y},[A,j]=(0,d.useState)(!1),[M,N]=(0,d.useState)(!1),P=(0,d.useRef)(M),F=(0,d.useRef)(D),I=(0,d.useRef)(o??[]);(0,d.useEffect)(()=>{I.current=o??[]},[o]);let L=(0,d.useRef)(l);(0,d.useEffect)(()=>{L.current=l},[l]),(0,d.useEffect)(()=>{P.current=M},[M]),(0,d.useEffect)(()=>{F.current=D},[D]);let R=Qt(r),z=Qt(S),B=R===`auto`,V=B?void 0:R??200,H=o!==void 0||f!==void 0,U=(0,d.useMemo)(()=>H?X.Mention.configure({HTMLAttributes:{class:`rte-mention`},renderHTML({options:e,node:t}){return[`span`,{...e.HTMLAttributes,"data-id":t.attrs.id,"data-label":t.attrs.label},`${s}${t.attrs.label}`]},suggestion:Vr({getItems:()=>I.current,onMentionSearch:f,onMentionInserted:e=>L.current?.(e),noResultsLabel:O.mentionNoResults??`No results`})}):null,[H,s,f]),W=a!==void 0&&a>0||h||v,G=(0,Y.useEditor)({shouldRerenderOnTransaction:!0,extensions:[ne.StarterKit.configure({link:{openOnClick:!1}}),re.TextStyle,ie.Color,ae.Highlight.configure({multicolor:!0}),ue.Markdown.configure({transformPastedText:!0,transformCopiedText:!1}),oe.Placeholder.configure({placeholder:p??``}),...k.showTableButton?[ce.TableKit]:[],...k.showImageButton?[le.Image.configure({inline:!1,allowBase64:!0})]:[],...U?[U]:[],...W?a!==void 0&&a>0?[se.CharacterCount.configure({limit:a})]:[se.CharacterCount]:[]],content:x??e??``,editable:!t&&!m,editorProps:{handlePaste(e,t){if(!P.current)return!1;let n=t.clipboardData?.getData(`text/plain`);if(!n)return!1;t.preventDefault();let{state:r}=e;return e.dispatch(r.tr.insertText(n,r.selection.from,r.selection.to)),!0},handleKeyDown(e,t){return(t.ctrlKey||t.metaKey)&&t.key===`s`?(t.preventDefault(),F.current?.(),!0):!1}},onUpdate({editor:e}){w?.(e.getHTML()),E?.(e.storage.markdown.getMarkdown())},onBlur(){C?.()},onFocus(){T?.()}});(0,d.useEffect)(()=>{!G||x===void 0||G.getHTML()!==x&&G.commands.setContent(x,{emitUpdate:!1})},[G,x]),(0,d.useEffect)(()=>{G&&G.setEditable(!t&&!m)},[G,t,m]);let K=G?.storage.characterCount?.characters?.()??0,q=G?.storage.characterCount?.words?.()??0,J=h||a!==void 0&&a>0||v||!!i;return(0,g.jsxs)(u.Box,{sx:A?{position:`fixed`,top:0,left:0,width:`100vw`,height:`100vh`,zIndex:1300,display:`flex`,flexDirection:`column`,bgcolor:`background.default`,p:1}:{width:z??`100%`,...B?{display:`flex`,flexDirection:`column`,flex:1}:{}},children:[(0,g.jsxs)(u.Paper,{variant:`outlined`,sx:{display:`flex`,flexDirection:`column`,overflow:`hidden`,...A||B?{flex:1}:{height:V},borderColor:n?`error.main`:void 0,"&:focus-within":{borderColor:n?`error.main`:`primary.main`,borderWidth:2}},children:[_&&!m&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ni,{editor:G,toolbarConfig:k,translation:O,disabled:t,isFullscreen:A,onToggleFullscreen:()=>j(e=>!e),pasteAsPlainText:M,onTogglePasteAsPlainText:()=>N(e=>!e)}),(0,g.jsx)(u.Divider,{})]}),(0,g.jsx)(Hr,{editor:G,error:n,disabled:t,readonly:m})]}),J&&(0,g.jsx)(ri,{helperText:i,error:n,showCharacterCount:h||a!==void 0&&a>0,charCount:K,maxCharacters:a&&a>0?a:void 0,showWordCount:v,wordCount:q,translation:O}),c&&(0,g.jsx)(`input`,{type:`hidden`,name:c,value:G?G.getHTML():``})]})}var ai={showFormat:!0,showCopy:!0,showClear:!0,showExecute:!1,showUndoRedo:!0,showHistory:!1},oi={format:`Format SQL`,copy:`Copy`,copySuccess:`Copied!`,clear:`Clear`,execute:`Execute`,undo:`Undo`,redo:`Redo`,lineColumn:`Ln {line}, Col {col}`,errorCount:`{count} error(s)`,history:`Query history`,historyEmpty:`No queries yet`,clearHistory:`Clear history`},si={standard:Pe.StandardSQL,mysql:Pe.MySQL,postgresql:Pe.PostgreSQL,sqlite:Pe.SQLite,mssql:Pe.MSSQL};function ci({value:e,onChange:t,placeholder:n,disabled:r=!1,readonly:i=!1,showLineNumbers:a=!0,dialect:o=`standard`,keywordColor:s,stringColor:c,identifierColor:l,schema:f,onExecute:p,onFormat:m,onLint:h,onDiagnosticsChange:_,onViewReady:v,onCursorChange:y,onBlur:S,onFocus:D}){let O=(0,d.useRef)(null),k=(0,d.useRef)(null),A=(0,d.useRef)(t),j=(0,d.useRef)(y),M=(0,d.useRef)(S),N=(0,d.useRef)(D),P=(0,d.useRef)(v),F=(0,d.useRef)(p),I=(0,d.useRef)(m),L=(0,d.useRef)(h),R=(0,d.useRef)(_),z=(0,d.useRef)(new x.Compartment),B=(0,d.useRef)(new x.Compartment),V=(0,u.useTheme)(),H=V.palette.mode===`dark`,U=!!h,W=JSON.stringify(f);return(0,d.useEffect)(()=>{A.current=t},[t]),(0,d.useEffect)(()=>{j.current=y},[y]),(0,d.useEffect)(()=>{M.current=S},[S]),(0,d.useEffect)(()=>{N.current=D},[D]),(0,d.useEffect)(()=>{P.current=v},[v]),(0,d.useEffect)(()=>{F.current=p},[p]),(0,d.useEffect)(()=>{I.current=m},[m]),(0,d.useEffect)(()=>{L.current=h},[h]),(0,d.useEffect)(()=>{R.current=_},[_]),(0,d.useEffect)(()=>{if(!O.current)return;let t=k.current?.state.doc.toString()??e??``,u=s??V.palette.primary.main,d=c??V.palette.success.main,p=l??V.palette.info.main,m=w.HighlightStyle.define([{tag:E.tags.keyword,color:u,fontWeight:`bold`},{tag:E.tags.name,color:p},{tag:[E.tags.string,E.tags.special(E.tags.string)],color:d,fontWeight:`bold`},{tag:E.tags.number,color:V.palette.warning.main},{tag:[E.tags.lineComment,E.tags.blockComment],color:V.palette.text.disabled,fontStyle:`italic`},{tag:E.tags.operator,color:V.palette.text.secondary},{tag:[E.tags.function(E.tags.variableName),E.tags.function(E.tags.name)],color:V.palette.secondary.main},{tag:E.tags.typeName,color:V.palette.info.main},{tag:E.tags.invalid,color:V.palette.error.main,textDecoration:`underline wavy`}]),h=b.EditorView.theme({"&":{height:`100%`,fontFamily:`'Fira Code', 'JetBrains Mono', 'Consolas', monospace`,fontSize:`0.875rem`},".cm-scroller":{overflow:`auto`},".cm-content":{padding:`8px 4px`,caretColor:V.palette.text.primary},".cm-gutters":{backgroundColor:H?V.palette.grey[900]:V.palette.grey[50],color:V.palette.text.disabled,border:`none`,borderRight:`1px solid ${V.palette.divider}`},".cm-lineNumbers .cm-gutterElement":{paddingLeft:`4px`,paddingRight:`8px`},".cm-activeLineGutter":{backgroundColor:V.palette.action.selected},".cm-activeLine":{backgroundColor:V.palette.action.hover},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground":{backgroundColor:V.palette.primary.main+`40`},".cm-cursor, .cm-dropCursor":{borderLeftColor:V.palette.text.primary},"&.cm-focused":{outline:`none`},".cm-placeholder":{color:V.palette.text.disabled,fontStyle:`italic`},".cm-tooltip":{backgroundColor:V.palette.background.paper,border:`1px solid ${V.palette.divider}`,borderRadius:`4px`,boxShadow:V.shadows[4]},".cm-tooltip-autocomplete > ul > li":{color:V.palette.text.primary},".cm-tooltip-autocomplete > ul > li[aria-selected]":{backgroundColor:V.palette.primary.main+`20`,color:V.palette.primary.main},".cm-completionMatchedText":{color:V.palette.primary.main,textDecoration:`none`,fontWeight:`bold`},".cm-completionDetail":{color:V.palette.text.secondary,fontStyle:`italic`},".cm-gutter-lint":{width:`16px`},".cm-lint-marker-error":{color:V.palette.error.main},".cm-lint-marker-warning":{color:V.palette.warning.main},".cm-tooltip.cm-tooltip-lint":{backgroundColor:V.palette.background.paper,border:`1px solid ${V.palette.divider}`,borderRadius:`4px`},".cm-diagnostic-error":{borderLeft:`3px solid ${V.palette.error.main}`},".cm-diagnostic-warning":{borderLeft:`3px solid ${V.palette.warning.main}`},".cm-diagnostic-info":{borderLeft:`3px solid ${V.palette.info.main}`}},{dark:H}),g=f?Object.fromEntries(f.tables.map(e=>[e.name,(e.columns??[]).map(e=>({label:e.name,detail:e.type,type:`property`}))])):void 0,_=async e=>{let t=L.current;if(!t)return[];let n=e.state.doc.toString();try{let r=(await t(n)).map(t=>{let n=Math.max(1,Math.min(t.line,e.state.doc.lines)),r=e.state.doc.line(n);return{from:r.from+Math.max(0,(t.col??1)-1),to:r.to,severity:t.severity??`error`,message:t.message}});return R.current?.(r.length),r}catch{return[]}},v=b.keymap.of([{key:`Mod-Enter`,run:e=>(F.current?.(e.state.doc.toString()),!0)}]),y=b.keymap.of([{key:`Shift-Alt-f`,run:()=>(I.current?.(),!0)}]),S=[h,(0,w.syntaxHighlighting)(m),(0,Pe.sql)({dialect:si[o],schema:g}),(0,C.history)(),(0,Fe.autocompletion)(),v,y,b.keymap.of([...C.defaultKeymap,...C.historyKeymap,...Fe.completionKeymap]),z.current.of(b.EditorView.editable.of(!r&&!i)),B.current.of(x.EditorState.readOnly.of(i)),(0,b.highlightActiveLine)(),...a?[(0,b.lineNumbers)(),(0,b.highlightActiveLineGutter)()]:[],...n?[(0,b.placeholder)(n)]:[],...U?[(0,T.lintGutter)(),(0,T.linter)(_,{delay:600})]:[],b.EditorView.updateListener.of(e=>{e.docChanged&&A.current?.(e.state.doc.toString());let t=e.state.selection.main.head,n=e.state.doc.lineAt(t);j.current(n.number,t-n.from+1)}),b.EditorView.domEventHandlers({blur:()=>{M.current?.()},focus:()=>{N.current?.()}})],D=new b.EditorView({state:x.EditorState.create({doc:t,extensions:S}),parent:O.current});return k.current=D,P.current(D),()=>{P.current(null),D.destroy(),k.current=null}},[H,o,U,s,c,l,W]),(0,d.useEffect)(()=>{let t=k.current;if(!t)return;let n=t.state.doc.toString();n!==(e??``)&&t.dispatch({changes:{from:0,to:n.length,insert:e??``}})},[e]),(0,d.useEffect)(()=>{k.current?.dispatch({effects:[z.current.reconfigure(b.EditorView.editable.of(!r&&!i)),B.current.reconfigure(x.EditorState.readOnly.of(i))]})},[r,i]),(0,g.jsx)(u.Box,{ref:O,sx:{flex:1,overflow:`hidden`,display:`flex`,flexDirection:`column`,opacity:r?.5:1,backgroundColor:V.palette.background.paper,"& .cm-editor":{flex:1,display:`flex`,flexDirection:`column`}}})}function li(e,t=60){let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t)}…`:n}function ui({history:e,onSelect:t,onClear:n,translation:r,disabled:i}){let[a,o]=(0,d.useState)(null);function s(){o(null)}function c(e){t(e),s()}function l(){n(),s()}return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(u.Tooltip,{title:r.history,arrow:!0,children:(0,g.jsx)(`span`,{children:(0,g.jsx)(u.IconButton,{size:`small`,onClick:e=>o(e.currentTarget),disabled:i,"aria-label":r.history,children:(0,g.jsx)(Le.default,{fontSize:`small`})})})}),(0,g.jsxs)(u.Menu,{anchorEl:a,open:!!a,onClose:s,slotProps:{paper:{sx:{minWidth:280,maxWidth:400}}},children:[e.length===0&&(0,g.jsx)(u.MenuItem,{disabled:!0,children:(0,g.jsx)(u.ListItemText,{children:r.historyEmpty})}),e.map(e=>(0,g.jsx)(u.MenuItem,{onClick:()=>c(e.sql),children:(0,g.jsx)(u.ListItemText,{primary:li(e.sql),secondary:(0,g.jsx)(u.Typography,{variant:`caption`,color:`text.secondary`,children:new Date(e.timestamp).toLocaleString()}),slotProps:{primary:{sx:{fontFamily:`monospace`,fontSize:`0.8125rem`}}}})},e.id)),e.length>0&&(0,g.jsx)(u.Divider,{}),e.length>0&&(0,g.jsxs)(u.MenuItem,{onClick:l,children:[(0,g.jsx)(u.ListItemIcon,{children:(0,g.jsx)(Re.default,{fontSize:`small`,color:`error`})}),(0,g.jsx)(u.ListItemText,{sx:{color:`error.main`},children:r.clearHistory})]})]})]})}var di={standard:`sql`,mysql:`mysql`,postgresql:`postgresql`,sqlite:`sqlite`,mssql:`tsql`};function fi({editorView:e,toolbarConfig:t,translation:n,dialect:r,disabled:i,onExecute:a,queryHistory:o=[],onSelectHistoryEntry:s,onClearHistory:c}){let[l,f]=(0,d.useState)(!1),p=i||!e;function m(){let t=e?.state.doc.toString()??``;navigator.clipboard.writeText(t).then(()=>{f(!0),setTimeout(()=>f(!1),2e3)})}function h(){let t=e;t&&(t.dispatch({changes:{from:0,to:t.state.doc.length,insert:``}}),t.focus())}function v(){let t=e;t&&((0,C.undo)(t),t.focus())}function y(){let t=e;t&&((0,C.redo)(t),t.focus())}function b(){let t=e;if(!t)return;let n=t.state.doc.toString();try{let e=(0,Ne.format)(n,{language:di[r]});t.dispatch({changes:{from:0,to:t.state.doc.length,insert:e}})}catch{}t.focus()}function x(){let t=e;!t||!a||a(t.state.doc.toString())}let S=t.showFormat,w=t.showCopy||t.showClear,T=t.showUndoRedo,E=t.showExecute&&!!a,D=t.showHistory&&!!a&&!!s&&!!c;return(0,g.jsxs)(u.Box,{sx:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:.25,px:1,py:.5},role:`toolbar`,"aria-label":`SQL editor actions`,children:[S&&(0,g.jsx)(u.Box,{sx:{display:`flex`,gap:.25},children:(0,g.jsx)(Q,{label:n.format,icon:(0,g.jsx)(N.default,{fontSize:`small`}),onClick:b,disabled:p})}),S&&(w||T)&&(0,g.jsx)(u.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),w&&(0,g.jsxs)(u.Box,{sx:{display:`flex`,gap:.25},children:[t.showCopy&&(0,g.jsx)(Q,{label:l?n.copySuccess:n.copy,icon:l?(0,g.jsx)(A.default,{fontSize:`small`,color:`success`}):(0,g.jsx)(O.default,{fontSize:`small`}),onClick:m,disabled:p}),t.showClear&&(0,g.jsx)(Q,{label:n.clear,icon:(0,g.jsx)(_.default,{fontSize:`small`}),onClick:h,disabled:p})]}),w&&T&&(0,g.jsx)(u.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),T&&(0,g.jsxs)(u.Box,{sx:{display:`flex`,gap:.25},children:[(0,g.jsx)(Q,{label:n.undo,icon:(0,g.jsx)(j.default,{fontSize:`small`}),onClick:v,disabled:p}),(0,g.jsx)(Q,{label:n.redo,icon:(0,g.jsx)(M.default,{fontSize:`small`}),onClick:y,disabled:p})]}),D&&(0,g.jsxs)(g.Fragment,{children:[(w||T)&&(0,g.jsx)(u.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),(0,g.jsx)(ui,{history:o,onSelect:s,onClear:c,translation:n,disabled:i})]}),E&&(0,g.jsxs)(g.Fragment,{children:[(w||T||D)&&(0,g.jsx)(u.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),(0,g.jsx)(Q,{label:n.execute,icon:(0,g.jsx)(Ie.default,{fontSize:`small`}),onClick:x,disabled:p})]}),!S&&!w&&!T&&!D&&!E&&(0,g.jsx)(u.Box,{sx:{height:32}})]})}function pi({helperText:e,error:t,showLineColumn:n,showErrorCount:r,diagnosticsCount:i,cursorLine:a,cursorCol:o,translation:s}){let c=s.lineColumn.replace(`{line}`,String(a)).replace(`{col}`,String(o)),l=s.errorCount.replace(`{count}`,String(i));return(0,g.jsxs)(u.Box,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,mt:.5,px:.5},children:[(0,g.jsxs)(u.Box,{children:[r&&i>0&&(0,g.jsxs)(u.Box,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,g.jsx)(ze.default,{sx:{fontSize:`0.875rem`,color:`error.main`}}),(0,g.jsx)(u.FormHelperText,{sx:{color:`error.main`,m:0},children:l})]}),(0,g.jsx)(u.FormHelperText,{error:t,children:e??``})]}),n&&(0,g.jsx)(u.FormHelperText,{sx:{color:`text.disabled`,fontFamily:`monospace`,whiteSpace:`nowrap`},children:c})]})}var mi=0;function hi(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():(mi+=1,`${Date.now()}-${mi}`)}function gi(e){if(typeof window>`u`)return[];try{let t=window.localStorage.getItem(e);if(!t)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(e=>typeof e?.sql==`string`&&typeof e?.timestamp==`number`).map(e=>({...e,id:typeof e.id==`string`?e.id:hi()})):[]}catch{return[]}}function _i(e,t){if(!(typeof window>`u`))try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}}function vi(e,t,n){let r=t.trim();if(!r)return e;let i=e.filter(e=>e.sql!==r);return[{id:hi(),sql:r,timestamp:Date.now()},...i].slice(0,Math.max(0,n))}function yi(e,t){let[n,r]=(0,d.useState)(()=>gi(e));return(0,d.useEffect)(()=>{r(gi(e))},[e]),{history:n,addEntry:(0,d.useCallback)(n=>{r(r=>{let i=vi(r,n,t);return _i(e,i),i})},[e,t]),clearHistory:(0,d.useCallback)(()=>{r([]),_i(e,[])},[e])}}var bi={standard:`sql`,mysql:`mysql`,postgresql:`postgresql`,sqlite:`sqlite`,mssql:`tsql`};function xi({value:e,onChange:t,placeholder:n,height:r,width:i,disabled:a=!1,readonly:o=!1,error:s=!1,helperText:c,name:l,dialect:f=`standard`,showLineNumbers:p=!0,showLineColumn:m=!0,showErrorCount:h=!1,toolbarConfig:_,translation:v,highlightColors:y,schema:b,queryHistoryKey:x=`sql-editor-query-history`,queryHistoryMaxEntries:S=20,onExecute:C,onLint:w,onBlur:T,onFocus:E}){let D={...oi,...v},O={...ai,..._},{history:k,addEntry:A,clearHistory:j}=yi(x,S),M=Qt(r),N=Qt(i),P=M===`auto`,F=P?void 0:M??300,I=(0,d.useRef)(null),[L,R]=(0,d.useState)(null),[z,B]=(0,d.useState)({line:1,col:1}),[V,H]=(0,d.useState)(0),U=(0,d.useCallback)(e=>{I.current=e,R(e)},[]),W=(0,d.useCallback)((e,t)=>{B({line:e,col:t})},[]),G=(0,d.useCallback)(e=>{H(e)},[]),K=C?e=>{A(e),C(e)}:void 0,q=(0,d.useMemo)(()=>{if(!(o||!O.showFormat))return()=>{let e=I.current;if(!e)return;let t=e.state.doc.toString();try{let n=(0,Ne.format)(t,{language:bi[f]});e.dispatch({changes:{from:0,to:e.state.doc.length,insert:n}})}catch{}e.focus()}},[f,o,O.showFormat]),J=(0,d.useCallback)(e=>{let n=I.current;n&&(n.dispatch({changes:{from:0,to:n.state.doc.length,insert:e}}),n.focus()),t?.(e)},[t]),ee=m||h||!!c;return(0,g.jsxs)(u.Box,{sx:{width:N??`100%`,...P?{display:`flex`,flexDirection:`column`,flex:1}:{}},children:[(0,g.jsxs)(u.Paper,{variant:`outlined`,sx:{display:`flex`,flexDirection:`column`,overflow:`hidden`,...P?{flex:1}:{height:F},borderColor:s?`error.main`:void 0,"&:focus-within":{borderColor:s?`error.main`:`primary.main`,borderWidth:2}},children:[!o&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(fi,{editorView:L,toolbarConfig:O,translation:D,dialect:f,disabled:a,onExecute:K,queryHistory:k,onSelectHistoryEntry:J,onClearHistory:j}),(0,g.jsx)(u.Divider,{})]}),(0,g.jsx)(ci,{value:e,onChange:t,placeholder:n,disabled:a,readonly:o,showLineNumbers:p,dialect:f,keywordColor:y?.keyword,stringColor:y?.string,identifierColor:y?.identifier,schema:b,onExecute:K,onFormat:q,onLint:w,onDiagnosticsChange:w?G:void 0,onViewReady:U,onCursorChange:W,onBlur:T,onFocus:E})]}),ee&&(0,g.jsx)(pi,{helperText:c,error:s,showLineColumn:m,showErrorCount:h,diagnosticsCount:V,cursorLine:z.line,cursorCol:z.col,translation:D}),l&&(0,g.jsx)(`input`,{type:`hidden`,name:l,value:e??``})]})}var Si={noData:`No data`},Ci=2*Math.PI,wi=11,Ti=wi*.5,Ei=5;function Di(e,t=0,n=`.`,r=`,`){if(e==null||!isFinite(e))return`0`;let[i,a]=e.toFixed(Math.max(0,t)).split(`.`),o=i.replace(/\B(?=(\d{3})+(?!\d))/g,r);return a?`${o}${n}${a}`:o}function Oi(e,t){let n=Math.floor(t/Ti);return n<=0?``:e.length<=n?e:n<Ei?``:e.slice(0,n-1)+`…`}function ki({node:e,valueDecimalCount:t,valueDecimalSep:n,valueThousandsSep:r,valueFormatter:i}){let a=(e.value??0)>0,o=e.ancestors().map(e=>e.data.name).reverse().join(` › `);return(0,g.jsxs)(u.Box,{sx:{py:.25},children:[(0,g.jsx)(u.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`},children:e.data.name}),a&&(0,g.jsx)(u.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:(e=>i?i(e):Di(e,t,n,r))(e.value??0)}),e.depth>0&&(0,g.jsx)(u.Typography,{variant:`caption`,sx:{display:`block`,opacity:.65,mt:.25},children:o})]})}function Ai({data:e,size:t=500,showSegmentLabels:n=!0,innerRadius:r=0,sortBy:i=`value`,chartColors:a,showRootLabel:o=!0,onSegmentClick:s,onSegmentHover:c,onZoomChange:l,valueDecimalCount:f=0,valueDecimalSeparator:p=`.`,valueThousandsSeparator:m=`,`,valueFormatter:h,zoomable:_=!1,duration:v=750,disabled:y=!1,translation:b}){let x=(0,u.useTheme)(),S={...Si,...b},C=!e.children?.length&&!e.value,w=(0,d.useRef)(null),[T,E]=(0,d.useState)(`-${t/2} -${t/2} ${t} ${t}`),[D,O]=(0,d.useState)(1),k=(0,d.useMemo)(()=>{if(D===1)return T;let[e,t,n,r]=T.split(` `).map(Number),i=n/D,a=r/D;return`${e+(n-i)/2} ${t+(r-a)/2} ${i} ${a}`},[T,D]),A=t/2,j=Math.max(0,Math.min(r,Math.max(0,A-1))),M=Math.max(1,A-j),N=[x.palette.primary.main,x.palette.secondary.main,x.palette.error.main,x.palette.warning.main,x.palette.success.main,x.palette.info.main],P=a&&a.length>0?a:N,{root:F,ringThickness:I}=(0,d.useMemo)(()=>{let t=Z.hierarchy(e).sum(e=>e.value??0);i===`value`?t.sort((e,t)=>(t.value??0)-(e.value??0)):t.sort((e,t)=>String(e.data.name).localeCompare(String(t.data.name),void 0,{numeric:!0,sensitivity:`base`}));let n=Z.partition().size([Ci,M])(t),r=Z.max(n.descendants(),e=>e.depth)??0,a=r>0?M/r:M;return r>0&&n.descendants().forEach(e=>{e.depth===0?(e.y0=0,e.y1=0):(e.y0=(e.depth-1)*a,e.y1=e.depth*a)}),{root:n,ringThickness:a}},[e,M,i]),[L,R]=(0,d.useState)(F),[z,B]=(0,d.useState)(F),V=e=>({x0:e.x0,x1:e.x1,yShift:e.depth===0?0:(e.depth-1)*I}),[H,U]=(0,d.useState)(()=>V(F)),W=(0,d.useRef)(H);if(z!==F){B(F),R(F);let e=V(F);W.current=e,U(e)}let G=(0,d.useMemo)(()=>F.children?.map(e=>e.data.name)??[F.data.name],[F]),K=(0,d.useMemo)(()=>Z.scaleOrdinal().domain(G).range(P),[P,G]),q=e=>{if(e.data.colorConfig?.fill)return e.data.colorConfig.fill;let t=e;for(;t.depth>1;)t=t.parent;return K(t.data.name)},J=(0,d.useMemo)(()=>Z.arc().startAngle(e=>e.x0).endAngle(e=>e.x1).padAngle(e=>Math.min((e.x1-e.x0)/2,.005)).padRadius(A/2).innerRadius(e=>j+e.y0).outerRadius(e=>j+e.y1-1),[A,j]),ee=(0,d.useCallback)(e=>{let t=Ci/(H.x1-H.x0);return{x0:Math.max(0,Math.min(Ci,(e.x0-H.x0)*t)),x1:Math.max(0,Math.min(Ci,(e.x1-H.x0)*t)),y0:Math.max(0,e.y0-H.yShift),y1:Math.max(0,e.y1-H.yShift)}},[H]);(0,d.useEffect)(()=>{let e=V(L),t=W.current;if(t.x0===e.x0&&t.x1===e.x1&&t.yShift===e.yShift)return;if(v<=0){W.current=e,U(e);return}let n=null,r=Z.interpolateNumber(t.x0,e.x0),i=Z.interpolateNumber(t.x1,e.x1),a=Z.interpolateNumber(t.yShift,e.yShift),o=performance.now(),s=e=>{let t=Math.min(1,(e-o)/v),c=Z.easeCubic(t),l={x0:r(c),x1:i(c),yShift:a(c)};W.current=l,U(l),n=t<1?requestAnimationFrame(s):null};return n=requestAnimationFrame(s),()=>{n!=null&&cancelAnimationFrame(n)}},[L,I,v]);let te=e=>e.x1>e.x0&&e.y1>e.y0,Y=e=>(j+(e.y0+e.y1)/2)*(e.x1-e.x0)>12,X=e=>{let t=(e.x0+e.x1)/2*180/Math.PI,n=j+(e.y0+e.y1)/2,r=t<180?0:180;return`rotate(${t-90}) translate(${n},0) rotate(${r})`},ne=(0,d.useCallback)(e=>e.ancestors().includes(L),[L]),re=(0,d.useCallback)(e=>{let t=e.ancestors().reverse(),n=e.value??0,r=F.value??0;return{id:e.data.id,name:e.data.name,value:n||null,percentage:r>0?Math.round(n/r*1e4)/100:0,depth:e.depth,path:t.map(e=>e.data.name),pathIds:t.map(e=>e.data.id),childrenCount:e.children?.length??0,data:e.data}},[F]),ie=(0,d.useCallback)(e=>{R(e),l&&l({focusNode:re(e),isRoot:e===F})},[F,re,l]);(0,d.useLayoutEffect)(()=>{let e=w.current;if(!e)return;let n=requestAnimationFrame(()=>{try{let t=e.getBBox();E(`${t.x-8} ${t.y-8} ${t.width+16} ${t.height+16}`)}catch{E(`-${t/2} -${t/2} ${t} ${t}`)}});return()=>cancelAnimationFrame(n)},[t,F,L,j,I,o]);let ae=(0,d.useRef)(null),oe=e=>{ae.current&&=(clearTimeout(ae.current),null),ae.current=setTimeout(()=>{e(),ae.current=null},250)},se=()=>{ae.current&&=(clearTimeout(ae.current),null)};(0,d.useLayoutEffect)(()=>{if(y)return;let e=e=>{e.key===`Escape`&&(se(),ie(F),O(1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[y,F,ie]);let ce=(0,d.useCallback)(e=>{if(!_||y||!e.ctrlKey)return;e.preventDefault();let t=e.deltaY<0?1.15:1/1.15;O(e=>Math.max(.25,Math.min(8,e*t)))},[_,y]),le=F.descendants().filter(e=>e.depth>0),ue=e=>{if(y)return;let t=le[Number(e.currentTarget.getAttribute(`data-idx`))];if(t){if(e.ctrlKey||e.metaKey){t.children&&oe(()=>ie(t));return}s?.(re(t),e)}},de=e=>{y||(e.ctrlKey||e.metaKey)&&(se(),ie(L.parent??F))},fe=e=>{if(!y){if(e.ctrlKey||e.metaKey){se(),ie(L.parent??F);return}s?.(re(L.parent??F),e)}},pe={followCursor:!0,enterDelay:50,enterNextDelay:0,disableHoverListener:y,slotProps:{tooltip:{sx:{maxWidth:260}}}},me=x.palette.text.primary,he=x.typography.fontFamily;return(0,g.jsx)(u.Box,{sx:{display:`inline-flex`,opacity:y?.5:1,cursor:y?`not-allowed`:`default`,userSelect:`none`},children:(0,g.jsx)(`svg`,{width:t,height:t,viewBox:k,onWheel:ce,style:{fontFamily:he??`sans-serif`,overflow:_&&D>1?`hidden`:`visible`},role:`img`,"aria-label":e.name,children:(0,g.jsxs)(`g`,{ref:w,children:[C&&(0,g.jsx)(`text`,{textAnchor:`middle`,dy:`0.35em`,fontSize:13,fill:x.palette.text.secondary,children:S.noData}),j>0&&(0,g.jsx)(u.Tooltip,{...pe,title:L.data.name,placement:`top`,children:(0,g.jsx)(`circle`,{cx:0,cy:0,r:j,fill:`transparent`,pointerEvents:y?`none`:`auto`,onClick:fe,style:{cursor:y?`not-allowed`:`pointer`},onMouseEnter:e=>{y||c?.(re(L.parent??F),e)},onMouseLeave:e=>{c?.(null,e)}})}),(0,g.jsx)(`g`,{children:le.map((e,t)=>{let n=ee(e),r=te(n),i=!!e.children;return(0,g.jsx)(u.Tooltip,{...pe,placement:`top`,title:r?(0,g.jsx)(ki,{node:e,valueDecimalCount:f,valueDecimalSep:p,valueThousandsSep:m,valueFormatter:h}):``,children:(0,g.jsx)(`path`,{"data-idx":t,d:J(n)||``,fill:q(e),fillOpacity:r?i?.75:.5:0,style:{pointerEvents:r&&!y?`auto`:`none`,cursor:i&&!y?`pointer`:`default`,transition:`fill-opacity 0.15s`},onClick:ue,onDoubleClick:de,onMouseEnter:e=>{if(y||!r)return;let t=le[Number(e.currentTarget.getAttribute(`data-idx`))];t&&c?.(re(t),e)},onMouseLeave:e=>{r&&c?.(null,e)}})},`tt-${e.data.id}-${t}`)})}),n&&(0,g.jsx)(`g`,{pointerEvents:`none`,textAnchor:`middle`,fill:me,children:le.map((e,t)=>{if(!ne(e))return null;let n=ee(e);if(!Y(n))return null;let r=(j+(n.y0+n.y1)/2)*(n.x1-n.x0)*.88,i=Oi(e.data.name,r);return i?(0,g.jsx)(`text`,{transform:X(n),dy:`0.35em`,fontSize:wi,children:i},`lbl-${e.data.id}-${t}`):null})}),o&&!C&&(0,g.jsx)(u.Tooltip,{...pe,placement:`top`,title:``,children:(0,g.jsx)(`g`,{textAnchor:`middle`,fill:me,pointerEvents:y?`none`:`auto`,onClick:fe,style:{cursor:L!==F&&!y?`pointer`:`default`},children:(0,g.jsx)(`text`,{fontSize:13,dy:`0.35em`,fontWeight:`bold`,children:L.data.name})})})]})})})}Ai.displayName=`SunburstChart`;var ji={noData:`No data`};function Mi(e,t=0,n=`.`,r=`,`){if(!isFinite(e))return String(e);let[i,a]=e.toFixed(Math.max(0,t)).split(`.`),o=i.replace(/\B(?=(\d{3})+(?!\d))/g,r);return a?`${o}${n}${a}`:o}function Ni({name:e,valueOut:t,valueIn:n,fmt:r}){return(0,g.jsxs)(u.Box,{sx:{py:.25},children:[(0,g.jsx)(u.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`},children:e}),(0,g.jsxs)(u.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:[r(t),` outgoing →`]}),(0,g.jsxs)(u.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:[r(n),` incoming ←`]})]})}function Pi({sourceName:e,targetName:t,sourceValue:n,targetValue:r,directed:i,fmt:a}){return(0,g.jsxs)(u.Box,{sx:{py:.25},children:[(0,g.jsxs)(u.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`},children:[e,` → `,t]}),(0,g.jsx)(u.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:a(n)}),i&&r>0&&r!==n&&(0,g.jsxs)(u.Typography,{variant:`caption`,sx:{display:`block`,opacity:.7,mt:.25},children:[t,` → `,e,`: `,a(r)]})]})}function Fi({data:e,size:t=500,innerRadius:n,ringThickness:r=20,padAngle:i,ribbonPadAngle:a,sortSubgroups:o=`descending`,sortChords:s=`descending`,chartColors:c,groupColorConfigs:l,showGroupLabels:f=!0,labelOffset:p=8,ribbonOpacity:m=.75,ribbonBlendMode:h,directed:_=!0,valueDecimalCount:v=0,valueDecimalSeparator:y=`.`,valueThousandsSeparator:b=`,`,valueFormatter:x,onGroupClick:S,onGroupHover:C,onChordClick:w,onChordHover:T,zoomable:E=!1,disabled:D=!1,translation:O}){let k=(0,u.useTheme)(),A={...ji,...O},j=e.length===0,M=h??(k.palette.mode===`dark`?`normal`:`multiply`),N=[k.palette.primary.main,k.palette.secondary.main,k.palette.error.main,k.palette.warning.main,k.palette.success.main,k.palette.info.main],P=c&&c.length>0?c:N,F=n??Math.min(t,t)*.5-90,I=Math.max(10,F),L=I+Math.max(1,r),R=i??10/I,z=a??1/I,B=(0,d.useCallback)(e=>x?x(e):Mi(e,v,y,b),[x,v,y,b]),{names:V,matrix:H}=(0,d.useMemo)(()=>{let t=Z.sort(Z.union(e.map(e=>e.source),e.map(e=>e.target))),n=new Map(t.map((e,t)=>[e,t])),r=Array.from({length:t.length},()=>Array(t.length).fill(0));for(let{source:t,target:i,value:a}of e){let e=n.get(t),o=n.get(i);e==null||o==null||(r[e][o]+=a)}return{names:t,matrix:r}},[e]),U=(0,d.useMemo)(()=>{let e=(_?Z.chordDirected():Z.chord()).padAngle(R);return o===`ascending`&&(e=e.sortSubgroups(Z.ascending)),o===`descending`&&(e=e.sortSubgroups(Z.descending)),s===`ascending`&&(e=e.sortChords(Z.ascending)),s===`descending`&&(e=e.sortChords(Z.descending)),e(H)},[H,R,_,o,s]),W=(0,d.useMemo)(()=>Z.arc().innerRadius(I).outerRadius(L),[I,L]),G=(0,d.useMemo)(()=>(_?Z.ribbonArrow():Z.ribbon()).radius(I-1).padAngle(z),[I,z,_]),K=(0,d.useCallback)(e=>G({source:{startAngle:e.source.startAngle,endAngle:e.source.endAngle,radius:I-1},target:{startAngle:e.target.startAngle,endAngle:e.target.endAngle,radius:I-1}})??``,[G,I]),q=(0,d.useMemo)(()=>Z.scaleOrdinal().domain(Z.range(V.length)).range(P.length>=V.length?P:[...Array(Math.ceil(V.length/P.length))].flatMap(()=>P).slice(0,V.length)),[P,V.length]),J=(0,d.useCallback)(e=>l?.[V[e]]?.fill??q(e),[l,V,q]),ee=(0,d.useRef)(null),[te,Y]=(0,d.useState)(`-${t/2} -${t/2} ${t} ${t}`),[X,ne]=(0,d.useState)(1),re=(0,d.useMemo)(()=>{if(X===1)return te;let[e,t,n,r]=te.split(` `).map(Number),i=n/X,a=r/X;return`${e+(n-i)/2} ${t+(r-a)/2} ${i} ${a}`},[te,X]);(0,d.useLayoutEffect)(()=>{let e=ee.current;if(!e)return;let n=requestAnimationFrame(()=>{try{let t=e.getBBox();Y(`${t.x-8} ${t.y-8} ${t.width+16} ${t.height+16}`)}catch{Y(`-${t/2} -${t/2} ${t} ${t}`)}});return()=>cancelAnimationFrame(n)},[t,I,L,V.length,U]);let[ie,ae]=(0,d.useState)(null),oe=(0,d.useCallback)(e=>({name:V[e.index],index:e.index,valueOut:Z.sum(U,t=>(t.source.index===e.index?t.source.value:0)+(!_&&t.target.index===e.index?t.target.value:0)),valueIn:Z.sum(U,t=>(t.target.index===e.index?t.source.value:0)+(!_&&t.source.index===e.index?t.target.value:0))}),[V,U,_]),se=(0,d.useCallback)(e=>({source:{name:V[e.source.index],index:e.source.index,value:e.source.value},target:{name:V[e.target.index],index:e.target.index,value:e.target.value}}),[V]),ce=e=>{let t=(e.startAngle+e.endAngle)/2,n=t*180/Math.PI-90,r=t>Math.PI?` rotate(180)`:``;return`rotate(${n}) translate(${L+p})${r}`},le=e=>(e.startAngle+e.endAngle)/2>Math.PI?`end`:`start`,ue=(0,d.useCallback)(e=>{if(!E||D||!e.ctrlKey)return;e.preventDefault();let t=e.deltaY<0?1.15:1/1.15;ne(e=>Math.max(.25,Math.min(8,e*t)))},[E,D]);(0,d.useLayoutEffect)(()=>{if(!E)return;let e=e=>{e.key===`Escape`&&ne(1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[E]);let de={followCursor:!0,enterDelay:50,enterNextDelay:0,disableHoverListener:D,slotProps:{tooltip:{sx:{maxWidth:240}}}},fe=k.palette.text.primary,pe=k.typography.fontFamily;return(0,g.jsx)(u.Box,{sx:{display:`inline-flex`,opacity:D?.5:1,cursor:D?`not-allowed`:`default`,userSelect:`none`},children:(0,g.jsx)(`svg`,{width:t,height:t,viewBox:re,onWheel:ue,style:{fontFamily:pe??`sans-serif`,overflow:E&&X>1?`hidden`:`visible`},role:`img`,"aria-label":`Chord chart`,children:(0,g.jsxs)(`g`,{ref:ee,children:[j&&(0,g.jsx)(`text`,{textAnchor:`middle`,dy:`0.35em`,fontSize:13,fill:k.palette.text.secondary,children:A.noData}),(0,g.jsx)(`g`,{children:U.groups.map(e=>{let t=oe(e),n=ie===e.index,r=ie!==null&&!n;return(0,g.jsx)(u.Tooltip,{...de,title:(0,g.jsx)(Ni,{name:t.name,valueOut:t.valueOut,valueIn:t.valueIn,fmt:B}),children:(0,g.jsxs)(`g`,{style:{cursor:D?`not-allowed`:`pointer`},onMouseEnter:n=>{D||(ae(e.index),C?.(t,n))},onMouseLeave:e=>{ae(null),C?.(null,e)},onClick:e=>!D&&S?.(t,e),children:[(0,g.jsx)(`path`,{d:W(e)||``,fill:J(e.index),stroke:k.palette.divider,opacity:r?.35:1,style:{transition:`opacity 0.15s`}}),f&&(0,g.jsx)(`text`,{dy:`0.35em`,fontSize:11,fill:fe,transform:ce(e),textAnchor:le(e),pointerEvents:`none`,children:V[e.index]})]})},`grp-tt-${e.index}`)})}),(0,g.jsx)(`g`,{fillOpacity:m,style:{mixBlendMode:M},children:U.map((e,t)=>{let n=se(e),r=ie===null||e.source.index===ie||e.target.index===ie;return(0,g.jsx)(u.Tooltip,{...de,title:(0,g.jsx)(Pi,{sourceName:n.source.name,targetName:n.target.name,sourceValue:n.source.value,targetValue:n.target.value,directed:_,fmt:B}),children:(0,g.jsx)(`path`,{d:K(e),fill:J(e.target.index),stroke:`none`,opacity:r?1:.12,style:{cursor:D?`not-allowed`:`pointer`,transition:`opacity 0.15s`},onMouseEnter:e=>{D||T?.(n,e)},onMouseLeave:e=>{T?.(null,e)},onClick:e=>!D&&w?.(n,e)})},`chord-tt-${t}`)})})]})})})}Fi.displayName=`ChordChart`;var Ii={noData:`No data`,specialValueA:`Value A`,specialValueB:`Value B`},Li={folder:`M20 6h-8l-2-2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 12H4V8h16v10z`,person:`M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z`};function Ri({path:e,size:t}){let n=t/2;return(0,g.jsx)(`g`,{transform:`translate(${-n},${-n})`,pointerEvents:`none`,children:(0,g.jsx)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,overflow:`visible`,children:(0,g.jsx)(`path`,{d:e,fill:`white`})})})}function zi({info:e,labelA:t,labelB:n}){return(0,g.jsxs)(u.Box,{sx:{p:2,minWidth:200,maxWidth:280},children:[(0,g.jsxs)(u.Box,{sx:{display:`flex`,alignItems:`center`,gap:1.5,mb:1.5},children:[(0,g.jsx)(u.Avatar,{sx:{bgcolor:`primary.main`,width:40,height:40},children:e.name.charAt(0).toUpperCase()}),(0,g.jsxs)(u.Box,{children:[(0,g.jsx)(u.Typography,{variant:`body2`,sx:{fontWeight:`bold`},children:e.name}),e.subname&&(0,g.jsx)(u.Typography,{variant:`caption`,color:`text.secondary`,children:e.subname})]})]}),(e.specialValueA!=null||e.specialValueB!=null)&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(u.Divider,{sx:{mb:1.5}}),e.specialValueA!=null&&(0,g.jsxs)(u.Box,{sx:{display:`flex`,justifyContent:`space-between`,mb:.5},children:[(0,g.jsx)(u.Typography,{variant:`caption`,color:`text.secondary`,children:t}),(0,g.jsx)(u.Typography,{variant:`caption`,children:String(e.specialValueA)})]}),e.specialValueB!=null&&(0,g.jsxs)(u.Box,{sx:{display:`flex`,justifyContent:`space-between`},children:[(0,g.jsx)(u.Typography,{variant:`caption`,color:`text.secondary`,children:n}),(0,g.jsx)(u.Typography,{variant:`caption`,children:String(e.specialValueB)})]})]})]})}function Bi({data:e,size:t=600,autoFit:n=!0,sortBy:r=`name`,showLabels:i=!0,showIcons:a=!0,chartColors:o,rootNodeRadius:s=22,branchNodeRadius:c=16,leafNodeRadius:l=11,linkColor:f,linkStrokeOpacity:p=1,linkStrokeWidth:m=1.5,labelFontSize:h=12,labelColor:_,separationSibling:v=1,separationCousin:y=2,zoomable:b=!1,drillable:x=!1,onFocusChange:S,duration:C=750,showNodePopover:w=!1,renderNodePopoverContent:T,onNodeClick:E,onNodeHover:D,disabled:O=!1,translation:k}){let A=(0,u.useTheme)(),j={...Ii,...k},M=[A.palette.primary.main,A.palette.secondary.main,A.palette.info.main,A.palette.success.main,A.palette.warning.main,A.palette.error.main],N=o&&o.length>0?o:M,P=(0,d.useCallback)(e=>e.depth===0?s:e.children?c:l,[s,c,l]),F=(0,d.useCallback)(e=>e.data.colorConfig?.fill??N[e.depth%N.length],[N]),[I,L]=(0,d.useState)([e]),R=I[I.length-1],[z,B]=(0,d.useState)(e),[V,H]=(0,d.useState)(!1);z!==e&&(B(e),L([e]),H(!0));let U=!e.children?.length&&!e.value,W=Math.max(1,t/2-70),G=(0,d.useMemo)(()=>{let e=Z.hierarchy(R);return r===`value`?(e.sum(e=>e.value??0),e.sort((e,t)=>(t.value??0)-(e.value??0))):e.sort((e,t)=>Z.ascending(e.data.name,t.data.name)),Z.tree().size([2*Math.PI,W]).separation((e,t)=>(e.parent===t.parent?v:y)*1.4/Math.max(1,e.depth))(e)},[R,r,W,v,y]),K=G.links(),q=G.descendants(),J=(0,d.useRef)(G),ee=(0,d.useRef)(null),[te,Y]=(0,d.useState)(null),[X,ne]=(0,d.useState)(0);(0,d.useEffect)(()=>{let e=J.current;if(J.current=G,e===G)return;if(ee.current!=null&&(cancelAnimationFrame(ee.current),ee.current=null),V||C<=0){H(!1),Y(null);return}Y(e),ne(1);let t=performance.now(),n=e=>{let r=Math.min(1,(e-t)/C);ne(1-Z.easeCubic(r)),r<1?ee.current=requestAnimationFrame(n):(ee.current=null,Y(null))};return ee.current=requestAnimationFrame(n),()=>{ee.current!=null&&cancelAnimationFrame(ee.current)}},[G,C,V]);let re=(0,d.useMemo)(()=>Z.linkRadial().angle(e=>e.x).radius(e=>e.y),[]),ie=(0,d.useCallback)(e=>({id:e.data.id,name:e.data.name,subname:e.data.subname??null,value:(typeof e.value==`number`?e.value:null)??e.data.value??null,specialValueA:e.data.specialValueA??null,specialValueB:e.data.specialValueB??null,depth:e.depth,path:e.ancestors().map(e=>e.data.name).reverse(),childrenCount:e.children?.length??0,data:e.data}),[]),ae=(0,d.useRef)(null),[oe,se]=(0,d.useState)(`-${t/2} -${t/2} ${t} ${t}`),[ce,le]=(0,d.useState)(1);(0,d.useLayoutEffect)(()=>{if(!n){se(`-${t/2} -${t/2} ${t} ${t}`);return}let e=ae.current;if(!e)return;let r=requestAnimationFrame(()=>{try{let t=e.getBBox();se(`${t.x-20} ${t.y-20} ${t.width+40} ${t.height+40}`)}catch{se(`-${t/2} -${t/2} ${t} ${t}`)}});return()=>cancelAnimationFrame(r)},[t,G,i,n]);let ue=(0,d.useMemo)(()=>{if(ce===1)return oe;let[e,t,n,r]=oe.split(` `).map(Number),i=n/ce,a=r/ce;return`${e+(n-i)/2} ${t+(r-a)/2} ${i} ${a}`},[oe,ce]),de=(0,d.useCallback)(e=>{if(!b||O||!e.ctrlKey)return;e.preventDefault();let t=e.deltaY<0?1.15:1/1.15;le(e=>Math.max(.25,Math.min(8,e*t)))},[b,O]),fe=(0,d.useRef)(null),pe=e=>{fe.current&&=(clearTimeout(fe.current),null),fe.current=setTimeout(()=>{e(),fe.current=null},250)},me=()=>{fe.current&&=(clearTimeout(fe.current),null)};(0,d.useEffect)(()=>()=>me(),[]),(0,d.useLayoutEffect)(()=>{if(!b&&!x)return;let t=t=>{t.key===`Escape`&&(b&&le(1),x&&(me(),L([e]),S?.(null)))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[b,x,e,S]);let[he,ge]=(0,d.useState)(null),_e=(0,d.useRef)(null),ve=(0,d.useRef)(null),[ye,be]=(0,d.useState)(!1),[xe,Se]=(0,d.useState)(null),[Ce,we]=(0,d.useState)({left:0,top:0}),[Te,Ee]=(0,d.useState)(null),De=(0,d.useCallback)(()=>{L(e=>{if(e.length<=1)return e;let t=e.slice(0,-1);return S?.(t.length<=1?null:{id:t[t.length-1].id,name:t[t.length-1].name,subname:t[t.length-1].subname??null,value:null,specialValueA:null,specialValueB:null,depth:t.length-1,path:t.map(e=>e.name),childrenCount:t[t.length-1].children?.length??0,data:t[t.length-1]}),t})},[S]),Oe=e=>{O||!x||(e.ctrlKey||e.metaKey)&&(me(),De())},ke=e=>{if(O)return;let t=q[Number(e.currentTarget.getAttribute(`data-idx`))];if(!t)return;let n=ie(t);if((e.ctrlKey||e.metaKey)&&x&&t.children){pe(()=>{L(e=>[...e,t.data]),S?.(n)});return}if(w){let t=_e.current?.getBoundingClientRect();we({left:t?e.clientX-t.left:e.clientX,top:t?e.clientY-t.top:e.clientY}),Se(ve.current),Ee(n),be(!0)}E?.(n,e)},Ae=_||A.palette.text.primary,je=f||A.palette.text.secondary,Me=A.palette.background.paper,Ne=A.typography.fontFamily;return(0,g.jsxs)(u.Box,{ref:_e,sx:{display:`inline-flex`,position:`relative`,opacity:O?.5:1,cursor:O?`not-allowed`:`default`,userSelect:`none`},children:[x&&I.length>1&&(0,g.jsx)(u.Box,{sx:{position:`absolute`,top:4,left:0,right:0,display:`flex`,justifyContent:`center`,gap:.5,pointerEvents:`none`,zIndex:1},children:(0,g.jsx)(u.Typography,{variant:`caption`,sx:{bgcolor:`action.hover`,borderRadius:1,px:1,py:.25,color:`text.secondary`,fontSize:`0.7rem`},children:I.map(e=>e.name).join(` › `)})}),(0,g.jsx)(u.Box,{ref:ve,sx:{position:`absolute`,left:Ce.left,top:Ce.top,width:0,height:0}}),(0,g.jsx)(`svg`,{width:t,height:t,viewBox:ue,onWheel:de,style:{fontFamily:Ne??`sans-serif`,overflow:b&&ce>1?`hidden`:`visible`},role:`img`,"aria-label":e.name,children:(0,g.jsxs)(`g`,{ref:ae,children:[U&&(0,g.jsx)(`text`,{textAnchor:`middle`,dy:`0.35em`,fontSize:13,fill:Ae,children:j.noData}),(0,g.jsx)(`g`,{fill:`none`,stroke:je,strokeOpacity:p,strokeWidth:m,children:K.map((e,t)=>(0,g.jsx)(`path`,{d:re(e)},`link-${t}`))}),(0,g.jsx)(`g`,{children:q.map((e,t)=>{let n=P(e),r=F(e),i=ie(e),o=he===t,s=e.children?Li.folder:Li.person,c=Math.round(n*1.3);return(0,g.jsx)(u.Tooltip,{title:(0,g.jsxs)(u.Box,{sx:{py:.5,minWidth:160},children:[(0,g.jsx)(u.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`,fontSize:`0.8rem`},children:e.data.name}),e.data.subname&&(0,g.jsx)(u.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:e.data.subname}),(i.specialValueA!=null||i.specialValueB!=null||e.children)&&(0,g.jsxs)(u.Box,{sx:{mt:.75,borderTop:`1px solid rgba(255,255,255,0.2)`,pt:.75},children:[i.specialValueA!=null&&(0,g.jsxs)(u.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,g.jsx)(u.Typography,{variant:`caption`,sx:{opacity:.6},children:j.specialValueA??`A`}),(0,g.jsx)(u.Typography,{variant:`caption`,children:String(i.specialValueA)})]}),i.specialValueB!=null&&(0,g.jsxs)(u.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,g.jsx)(u.Typography,{variant:`caption`,sx:{opacity:.6},children:j.specialValueB??`B`}),(0,g.jsx)(u.Typography,{variant:`caption`,children:String(i.specialValueB)})]}),e.children&&(0,g.jsxs)(u.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,g.jsx)(u.Typography,{variant:`caption`,sx:{opacity:.6},children:`Reports`}),(0,g.jsx)(u.Typography,{variant:`caption`,children:e.children.length})]})]})]}),followCursor:!0,enterDelay:50,enterNextDelay:0,disableHoverListener:O,slotProps:{tooltip:{sx:{maxWidth:260}}},children:(0,g.jsxs)(`g`,{"data-idx":t,transform:`rotate(${e.x*180/Math.PI-90}) translate(${e.y},0)`,onClick:ke,onDoubleClick:Oe,onMouseEnter:e=>{O||(ge(t),D?.(i,e))},onMouseLeave:e=>{ge(null),D?.(null,e)},style:{cursor:O?`not-allowed`:`pointer`},children:[(0,g.jsx)(`circle`,{r:Math.max(n+8,24),fill:`transparent`}),(0,g.jsx)(`circle`,{r:n+2,fill:r,fillOpacity:.15}),(0,g.jsx)(`circle`,{r:n,fill:r,fillOpacity:o?.85:1,style:{transition:`fill-opacity 0.15s`}}),a&&(0,g.jsx)(Ri,{path:s,size:c})]})},`node-${e.data.id}-${t}`)})}),te&&((e,t)=>(0,g.jsxs)(`g`,{"data-testid":`drill-ghost-layer`,opacity:t,pointerEvents:`none`,children:[(0,g.jsx)(`g`,{fill:`none`,stroke:je,strokeOpacity:p,strokeWidth:m,children:e.links().map((e,t)=>(0,g.jsx)(`path`,{d:re(e)},`ghost-link-${t}`))}),(0,g.jsx)(`g`,{children:e.descendants().map((e,t)=>(0,g.jsxs)(`g`,{transform:`rotate(${e.x*180/Math.PI-90}) translate(${e.y},0)`,children:[(0,g.jsx)(`circle`,{r:P(e)+2,fill:F(e),fillOpacity:.15}),(0,g.jsx)(`circle`,{r:P(e),fill:F(e)}),a&&(0,g.jsx)(Ri,{path:e.children?Li.folder:Li.person,size:Math.round(P(e)*1.3)})]},`ghost-node-${t}`))})]}))(te,X),i&&(0,g.jsx)(`g`,{children:q.map((e,t)=>{let n=P(e),r=e.x<Math.PI==!e.children,i=n+6,a=r?i:-i,o=r?`start`:`end`;return(0,g.jsx)(`text`,{transform:`rotate(${e.x*180/Math.PI-90}) translate(${e.y},0) rotate(${e.x>=Math.PI?180:0})`,dy:`0.35em`,x:a,textAnchor:o,paintOrder:`stroke`,stroke:Me,strokeWidth:3,fill:Ae,fontSize:h,fontWeight:e.depth===0?`bold`:`normal`,pointerEvents:`none`,children:e.data.name},`lbl-${e.data.id}-${t}`)})})]})}),w&&(0,g.jsx)(u.Popover,{open:ye,anchorEl:xe,onClose:()=>be(!1),anchorOrigin:{vertical:`top`,horizontal:`right`},transformOrigin:{vertical:`top`,horizontal:`left`},slotProps:{paper:{elevation:4}},children:Te&&(T?T(Te):(0,g.jsx)(zi,{info:Te,labelA:j.specialValueA??`Value A`,labelB:j.specialValueB??`Value B`}))})]})}Bi.displayName=`RadialTreeChart`;var Vi={noData:`No data`},Hi=.56;function Ui(e,t,n){return e.length*n*Hi<=t?e:t>=3*n*Hi+n*2?`…`:``}function Wi({data:e,size:t=600,padding:n=3,sortBy:r=`value`,showLabels:i=!0,showAllLabels:a=!1,labelFontSize:o=13,innerLabelFontSize:s=9,labelColor:c,chartColors:l,depthColorStart:f,depthColorEnd:p,background:m,duration:h=750,zoomable:_=!1,disabled:v=!1,onCircleClick:y,onCircleHover:b,onZoomChange:x,valueFormatter:S,translation:C}){let w=(0,u.useTheme)(),T={...Vi,...C},E=!e.children?.length&&!e.value,D=[w.palette.primary.main,w.palette.secondary.main,w.palette.error.main,w.palette.warning.main,w.palette.success.main,w.palette.info.main],O=c||w.palette.text.primary,k=m||w.palette.background.default,A=w.typography.fontFamily,j=(0,d.useMemo)(()=>{let i=Z.hierarchy(e).sum(e=>e.value??0);return r===`value`?i.sort((e,t)=>(t.value??0)-(e.value??0)):i.sort((e,t)=>String(e.data.name).localeCompare(String(t.data.name),void 0,{numeric:!0,sensitivity:`base`})),Z.pack().size([t,t]).padding(n)(i)},[e,t,n,r]),M=j.descendants(),N=(0,d.useMemo)(()=>Z.max(M,e=>e.depth)??0,[M]),P=!!(f&&p),F=(0,d.useMemo)(()=>P?Z.scaleSequential(Z.interpolateHcl(f,p)).domain([0,Math.max(1,N)]):null,[P,f,p,N]),I=l&&l.length>0?l:D,L=(0,d.useCallback)(e=>e.data.colorConfig?.fill?e.data.colorConfig.fill:P&&F?e.children?F(e.depth):w.palette.background.paper:I[e.depth%I.length],[P,F,I,w]),[R,z]=(0,d.useState)(1),B=(0,d.useCallback)(e=>{if(!_||v||!e.ctrlKey)return;e.preventDefault();let t=e.deltaY<0?1.15:1/1.15;z(e=>Math.max(.25,Math.min(8,e*t)))},[_,v]);(0,d.useLayoutEffect)(()=>{if(!_)return;let e=e=>{e.key===`Escape`&&z(1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[_]);let V=(0,d.useMemo)(()=>{let e=`${-t/2} ${-t/2} ${t} ${t}`;if(R===1)return e;let n=t/R,r=(t-n)/2;return`${-t/2+r} ${-t/2+r} ${n} ${n}`},[t,R]),H=(0,d.useCallback)(e=>{let t=e.value??0,n=j.value??0;return{id:e.data.id??null,name:e.data.name,value:t||null,percentage:n>0?Math.round(t/n*1e4)/100:0,depth:e.depth,path:e.ancestors().map(e=>e.data.name).reverse(),childrenCount:e.children?.length??0,data:e.data}},[j]),U=(0,d.useRef)(null),W=(0,d.useRef)([j.x,j.y,j.r*2]),G=(0,d.useRef)(j),[K,q]=(0,d.useState)(j),J=(0,d.useCallback)(e=>{G.current=e,q(e)},[]),[ee,te]=(0,d.useState)(j);ee!==j&&(te(j),J(j),G.current=j);let Y=(0,d.useCallback)(e=>{let n=U.current;if(!n)return;W.current=e;let r=t/e[2],o=G.current,c=n.querySelectorAll(`g[data-role='nodes'] > g`),l=n.querySelectorAll(`g[data-role='nodes'] > g > circle`);for(let t=0;t<M.length;t++){let n=M[t],i=c[t];i&&i.setAttribute(`transform`,`translate(${(n.x-e[0])*r},${(n.y-e[1])*r})`);let a=t-1;a>=0&&l[a]&&l[a].setAttribute(`r`,String(n.r*r))}if(i){let t=n.querySelectorAll(`g[data-role='labels'] > text`);for(let n=0;n<M.length;n++){let i=M[n],a=t[n];a&&(a.setAttribute(`transform`,`translate(${(i.x-e[0])*r},${(i.y-e[1])*r})`),a.setAttribute(`font-weight`,i.children?`bold`:`normal`))}}if(a){let t=n.querySelectorAll(`g[data-role='inner-labels'] > text`);for(let n=0;n<M.length;n++){let i=M[n],a=t[n];if(!a)continue;let c=i.r*r,l=c*1.6,u=o===j?i!==j:i.ancestors().includes(o),d=i.parent===o;if(u&&!d&&c>=14){let t=Ui(i.data.name,l,s);t?(a.textContent=t,a.setAttribute(`transform`,`translate(${(i.x-e[0])*r},${(i.y-e[1])*r})`),a.setAttribute(`font-weight`,i.children?`bold`:`normal`),a.style.display=`inline`):a.style.display=`none`}else a.style.display=`none`}}},[M,t,i,a,s,j]);(0,d.useLayoutEffect)(()=>{Y([K.x,K.y,K.r*2])},[j,t,K,Y]);let X=(0,d.useCallback)((e,t)=>{let n=U.current;if(!n)return;let r=K,i=W.current,a=[e.x,e.y,e.r*2];J(e),Z.select(n).transition().duration(t).ease(Z.easeCubic).tween(`zoom`,()=>{let e=Z.interpolateZoom(i,a);return t=>Y(e(t))});let o=n.querySelectorAll(`g[data-role='labels'] > text`);Z.selectAll(o).transition().duration(t).ease(Z.easeCubic).style(`fill-opacity`,(t,n)=>+(M[n].parent===e)).on(`start`,function(t,n){M[n].parent===e&&(this.style.display=`inline`)}).on(`end`,function(t,n){M[n].parent!==e&&(this.style.display=`none`)}),x?.({previousName:r.data.name,currentName:e.data.name,currentDepth:e.depth,isRoot:e===j})},[K,M,j,Y,x,J]),ne=(0,d.useRef)(null),re=e=>{ne.current&&=(clearTimeout(ne.current),null),ne.current=setTimeout(()=>{e(),ne.current=null},250)},ie=()=>{ne.current&&=(clearTimeout(ne.current),null)},ae=(0,d.useRef)(X);(0,d.useEffect)(()=>{ae.current=X},[X]),(0,d.useLayoutEffect)(()=>{if(v)return;let e=e=>{e.key===`Escape`&&(ie(),ae.current(j,h))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[v,j,h]);let oe=e=>{if(v||!(e.ctrlKey||e.metaKey))return;ie(),e.preventDefault();let t=K.parent??j;t!==K&&X(t,e.altKey?Math.max(250,h*10):h)},se={followCursor:!0,enterDelay:50,enterNextDelay:0,disableHoverListener:v,slotProps:{tooltip:{sx:{maxWidth:220}}}};return(0,g.jsxs)(u.Box,{sx:{display:`inline-flex`,position:`relative`,opacity:v?.5:1,cursor:v?`not-allowed`:`default`,userSelect:`none`},children:[(0,g.jsxs)(`svg`,{ref:U,width:t,height:t,viewBox:V,onWheel:B,style:{display:`block`,background:k,fontFamily:A??`sans-serif`,overflow:_&&R>1?`hidden`:`visible`},role:`img`,"aria-label":e.name,onDoubleClick:oe,children:[E&&(0,g.jsx)(`text`,{textAnchor:`middle`,dy:`0.35em`,fontSize:13,fill:w.palette.text.secondary,children:T.noData}),(0,g.jsx)(`g`,{"data-role":`nodes`,children:M.map((e,n)=>{let r=H(e),i=(0,g.jsxs)(u.Box,{sx:{py:.5,minWidth:160},children:[(0,g.jsx)(u.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`,fontSize:`0.8rem`},children:e.data.name}),(e.value??0)>0&&(0,g.jsxs)(u.Box,{sx:{mt:.75,borderTop:`1px solid rgba(255,255,255,0.2)`,pt:.75},children:[(0,g.jsxs)(u.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,g.jsx)(u.Typography,{variant:`caption`,sx:{opacity:.6},children:`Value`}),(0,g.jsx)(u.Typography,{variant:`caption`,children:S?S(e.value??0):(e.value??0).toLocaleString()})]}),(0,g.jsxs)(u.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,g.jsx)(u.Typography,{variant:`caption`,sx:{opacity:.6},children:`Share`}),(0,g.jsxs)(u.Typography,{variant:`caption`,children:[r.percentage,`%`]})]}),e.children&&(0,g.jsxs)(u.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,g.jsx)(u.Typography,{variant:`caption`,sx:{opacity:.6},children:`Children`}),(0,g.jsx)(u.Typography,{variant:`caption`,children:e.children.length})]})]})]});return(0,g.jsx)(`g`,{transform:`translate(${e.x-t/2},${e.y-t/2})`,children:n===0?null:(0,g.jsx)(u.Tooltip,{...se,title:i,children:(0,g.jsx)(`circle`,{r:e.r,fill:L(e),stroke:e.data.colorConfig?.stroke??w.palette.background.paper,strokeWidth:.75,style:{cursor:v?`not-allowed`:e.children?`pointer`:`default`,transition:`stroke-width 0.1s`},onMouseEnter:e=>{v||(e.currentTarget.style.strokeWidth=`2`,b?.(r,e))},onMouseLeave:e=>{e.currentTarget.style.strokeWidth=`0.75`,b?.(null,e)},onClick:t=>{if(!v){if(t.ctrlKey||t.metaKey){if(e.children){let n=t.altKey?Math.max(250,h*10):h;re(()=>X(e,n))}return}y?.(r,t)}},onDoubleClick:e=>{if(!v&&(e.ctrlKey||e.metaKey)){ie(),e.preventDefault(),e.stopPropagation();let t=K.parent??j;t!==K&&X(t,e.altKey?Math.max(250,h*10):h)}}})})},`n-${n}`)})}),i&&(0,g.jsx)(`g`,{"data-role":`labels`,textAnchor:`middle`,dominantBaseline:`middle`,pointerEvents:`none`,fontSize:o,fill:O,children:M.map((e,n)=>(0,g.jsx)(`text`,{transform:`translate(${e.x-t/2},${e.y-t/2})`,style:{display:e.parent===j?`inline`:`none`,fillOpacity:+(e.parent===j)},children:e.data.name},`lbl-${n}`))}),a&&(0,g.jsx)(`g`,{"data-role":`inner-labels`,textAnchor:`middle`,dominantBaseline:`middle`,pointerEvents:`none`,fontSize:s,fill:O,children:M.map((e,n)=>(0,g.jsx)(`text`,{transform:`translate(${e.x-t/2},${e.y-t/2})`,style:{display:`none`}},`inner-lbl-${n}`))})]}),K!==j&&!v&&(0,g.jsx)(u.Box,{sx:{position:`absolute`,bottom:6,left:0,right:0,display:`flex`,justifyContent:`center`,pointerEvents:`none`},children:(0,g.jsxs)(u.Typography,{variant:`caption`,sx:{bgcolor:`action.hover`,borderRadius:1,px:1,py:.25,color:`text.secondary`,fontSize:`0.7rem`},children:[K.ancestors().map(e=>e.data.name).reverse().join(` › `),` · Ctrl / Cmd ⌘+DblClick to zoom out · Escape to reset`]})})]})}Wi.displayName=`CirclePackingChart`;var Gi={noData:`No data`,specialValueA:`Value A`,specialValueB:`Value B`},Ki={folder:`M20 6h-8l-2-2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 12H4V8h16v10z`,person:`M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z`};function qi({path:e,size:t}){let n=t/2;return(0,g.jsx)(`g`,{transform:`translate(${-n},${-n})`,pointerEvents:`none`,children:(0,g.jsx)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,overflow:`visible`,children:(0,g.jsx)(`path`,{d:e,fill:`white`})})})}function Ji({info:e,labelA:t,labelB:n}){return(0,g.jsxs)(u.Box,{sx:{p:2,minWidth:200,maxWidth:280},children:[(0,g.jsxs)(u.Box,{sx:{display:`flex`,alignItems:`center`,gap:1.5,mb:1.5},children:[(0,g.jsx)(u.Avatar,{sx:{bgcolor:`primary.main`,width:40,height:40},children:e.name.charAt(0).toUpperCase()}),(0,g.jsxs)(u.Box,{children:[(0,g.jsx)(u.Typography,{variant:`body2`,sx:{fontWeight:`bold`},children:e.name}),e.subname&&(0,g.jsx)(u.Typography,{variant:`caption`,color:`text.secondary`,children:e.subname})]})]}),(e.specialValueA!=null||e.specialValueB!=null)&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(u.Divider,{sx:{mb:1.5}}),e.specialValueA!=null&&(0,g.jsxs)(u.Box,{sx:{display:`flex`,justifyContent:`space-between`,mb:.5},children:[(0,g.jsx)(u.Typography,{variant:`caption`,color:`text.secondary`,children:t}),(0,g.jsx)(u.Typography,{variant:`caption`,children:String(e.specialValueA)})]}),e.specialValueB!=null&&(0,g.jsxs)(u.Box,{sx:{display:`flex`,justifyContent:`space-between`},children:[(0,g.jsx)(u.Typography,{variant:`caption`,color:`text.secondary`,children:n}),(0,g.jsx)(u.Typography,{variant:`caption`,children:String(e.specialValueB)})]})]})]})}function Yi({data:e,orientation:t=`LR`,width:n=800,height:r=500,levelSpacing:i=200,nodeRadius:a=10,sortBy:o=`name`,showLabels:s=!0,labelFontSize:c=12,labelColor:l,showIcons:f=!0,chartColors:p,linkStrokeOpacity:m=1,linkStrokeWidth:h=1.5,linkColor:_,zoomable:v=!1,drillable:y=!1,onFocusChange:b,showNodePopover:x=!1,renderNodePopoverContent:S,onNodeClick:C,onNodeHover:w,duration:T=750,disabled:E=!1,translation:D}){let O=(0,u.useTheme)(),k={...Gi,...D},A=[O.palette.primary.main,O.palette.secondary.main,O.palette.error.main,O.palette.warning.main,O.palette.success.main,O.palette.info.main],j=p&&p.length>0?p:A,M=l||O.palette.text.primary,N=_||O.palette.text.secondary,P=O.palette.background.paper,F=O.typography.fontFamily,I=!e.children?.length&&!e.value,L=t===`TB`||t===`BT`,R=L?r:n,z=L?n:r,[B,V]=(0,d.useState)([e]),H=B[B.length-1],[U,W]=(0,d.useState)(e),[G,K]=(0,d.useState)(!1);U!==e&&(W(e),V([e]),K(!0));let q=(0,d.useMemo)(()=>{let e=Z.hierarchy(H);o===`value`?(e.sum(e=>e.value??0),e.sort((e,t)=>(t.value??0)-(e.value??0))):e.sort((e,t)=>Z.ascending(String(e.data.name),String(t.data.name)));let t=Z.max(e.descendants(),e=>e.depth)??1;return Z.tree().size([R*.8,Math.min(t*i,z*.85)])(e)},[H,o,R,z,i]),J=(0,d.useMemo)(()=>{let e=Z.max(Z.hierarchy(H).descendants(),e=>e.depth)??1;return Math.min(e*i,z*.85)},[H,i,z]),ee=q.descendants(),te=q.links(),Y=(0,d.useRef)(q),X=(0,d.useRef)(null),[ne,re]=(0,d.useState)(null),[ie,ae]=(0,d.useState)(0);(0,d.useEffect)(()=>{let e=Y.current;if(Y.current=q,e===q)return;if(X.current!=null&&(cancelAnimationFrame(X.current),X.current=null),G||T<=0){K(!1),re(null);return}re(e),ae(1);let t=performance.now(),n=e=>{let r=Math.min(1,(e-t)/T);ae(1-Z.easeCubic(r)),r<1?X.current=requestAnimationFrame(n):(X.current=null,re(null))};return X.current=requestAnimationFrame(n),()=>{X.current!=null&&cancelAnimationFrame(X.current)}},[q,T,G]);let oe=(0,d.useCallback)(e=>e.data.colorConfig?.fill??j[e.depth%j.length],[j]),se=(0,d.useCallback)(e=>{switch(t){case`LR`:return{x:e.y,y:e.x-R*.4};case`RL`:return{x:J-e.y,y:e.x-R*.4};case`TB`:return{x:e.x-R*.4,y:e.y};case`BT`:return{x:e.x-R*.4,y:J-e.y}}},[t,R,J]),ce=(0,d.useCallback)(e=>{let n=se(e.source),r=se(e.target);if(t===`LR`||t===`RL`){let e=(n.x+r.x)/2;return`M${n.x},${n.y} C${e},${n.y} ${e},${r.y} ${r.x},${r.y}`}let i=(n.y+r.y)/2;return`M${n.x},${n.y} C${n.x},${i} ${r.x},${i} ${r.x},${r.y}`},[se,t]),le=(0,d.useCallback)(e=>({id:e.data.id??null,name:e.data.name,subname:e.data.subname??null,value:e.value??e.data.value??null,specialValueA:e.data.specialValueA??null,specialValueB:e.data.specialValueB??null,depth:e.depth,path:e.ancestors().map(e=>e.data.name).reverse(),childrenCount:e.children?.length??0,data:e.data}),[]),[ue,de]=(0,d.useState)(`0 -${r/2} ${n} ${r}`),[fe,pe]=(0,d.useState)(1),me=(0,d.useRef)(null),he=(0,d.useMemo)(()=>{if(fe===1)return ue;let[e,t,n,r]=ue.split(` `).map(Number),i=n/fe,a=r/fe;return`${e+(n-i)/2} ${t+(r-a)/2} ${i} ${a}`},[ue,fe]);(0,d.useLayoutEffect)(()=>{let e=me.current;if(!e)return;let t=requestAnimationFrame(()=>{try{let t=e.getBBox();de(`${t.x-24} ${t.y-24} ${t.width+48} ${t.height+48}`)}catch{de(`0 -${r/2} ${n} ${r}`)}});return()=>cancelAnimationFrame(t)},[q,n,r,t]);let ge=(0,d.useCallback)(e=>{if(!v||E||!e.ctrlKey)return;e.preventDefault();let t=e.deltaY<0?1.15:1/1.15;pe(e=>Math.max(.25,Math.min(8,e*t)))},[v,E]),_e=(0,d.useRef)(null),ve=e=>{_e.current&&=(clearTimeout(_e.current),null),_e.current=setTimeout(()=>{e(),_e.current=null},250)},ye=()=>{_e.current&&=(clearTimeout(_e.current),null)};(0,d.useEffect)(()=>()=>ye(),[]);let be=(0,d.useCallback)(()=>{V(e=>{if(e.length<=1)return e;let t=e.slice(0,-1);return b?.({focusedNode:{id:t[t.length-1].id??null,name:t[t.length-1].name,subname:t[t.length-1].subname??null,value:null,specialValueA:null,specialValueB:null,depth:t.length-1,path:t.map(e=>e.name),childrenCount:t[t.length-1].children?.length??0,data:t[t.length-1]},isRoot:t.length<=1}),t})},[b]);(0,d.useLayoutEffect)(()=>{if(!v&&!y)return;let t=t=>{t.key===`Escape`&&(v&&pe(1),y&&(ye(),V([e]),b?.({focusedNode:{id:e.id??null,name:e.name,subname:e.subname??null,value:null,specialValueA:null,specialValueB:null,depth:0,path:[e.name],childrenCount:e.children?.length??0,data:e},isRoot:!0})))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[v,y,e,b]);let xe=(0,d.useRef)(null),Se=(0,d.useRef)(null),[Ce,we]=(0,d.useState)(!1),[Te,Ee]=(0,d.useState)(null),[De,Oe]=(0,d.useState)({left:0,top:0}),[ke,Ae]=(0,d.useState)(null),je=(e,t)=>{if(E)return;let n=le(e);if((t.ctrlKey||t.metaKey)&&y&&e.children){ve(()=>{V(t=>[...t,e.data]),b?.({focusedNode:n,isRoot:!1})});return}if((t.ctrlKey||t.metaKey)&&y){ye(),be();return}if(x){let e=xe.current?.getBoundingClientRect();Oe({left:e?t.clientX-e.left:t.clientX,top:e?t.clientY-e.top:t.clientY}),Ee(Se.current),Ae(n),we(!0)}C?.(n,t)},Me=(e,t)=>{E||!y||(t.ctrlKey||t.metaKey)&&(ye(),be())},Ne={followCursor:!0,enterDelay:50,enterNextDelay:0,disableHoverListener:E,slotProps:{tooltip:{sx:{maxWidth:240}}}},Pe=Math.round(a*1.3);return(0,g.jsxs)(u.Box,{ref:xe,sx:{display:`inline-flex`,position:`relative`,opacity:E?.5:1,cursor:E?`not-allowed`:`default`,userSelect:`none`},children:[(0,g.jsx)(u.Box,{ref:Se,sx:{position:`absolute`,left:De.left,top:De.top,width:0,height:0}}),y&&B.length>1&&(0,g.jsx)(u.Box,{sx:{position:`absolute`,top:4,left:0,right:0,display:`flex`,justifyContent:`center`,pointerEvents:`none`,zIndex:1},children:(0,g.jsx)(u.Typography,{variant:`caption`,sx:{bgcolor:`action.hover`,borderRadius:1,px:1,py:.25,color:`text.secondary`,fontSize:`0.7rem`},children:B.map(e=>e.name).join(` › `)})}),(0,g.jsx)(`svg`,{width:n,height:r,viewBox:he,onWheel:ge,style:{fontFamily:F??`sans-serif`,overflow:v&&fe>1?`hidden`:`visible`},role:`img`,"aria-label":e.name,children:(0,g.jsxs)(`g`,{ref:me,children:[I&&(0,g.jsx)(`text`,{textAnchor:`middle`,dy:`0.35em`,fontSize:13,fill:M,children:k.noData}),(0,g.jsx)(`g`,{fill:`none`,stroke:N,strokeOpacity:m,strokeWidth:h,children:te.map((e,t)=>(0,g.jsx)(`path`,{d:ce(e)},`link-${t}`))}),ee.map((e,n)=>{let r=se(e),i=oe(e),o=le(e),l=e.children?Ki.folder:Ki.person,d=t===`LR`,p=t===`RL`,m=d?a+6:p?-(a+6):0,h=!d&&!p?t===`TB`?a+16:-(a+6):0,_=d?`start`:p?`end`:`middle`,v=(0,g.jsxs)(u.Box,{sx:{py:.5,minWidth:140},children:[(0,g.jsx)(u.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`,fontSize:`0.8rem`},children:e.data.name}),e.data.subname&&(0,g.jsx)(u.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:e.data.subname}),(o.specialValueA!=null||o.specialValueB!=null||e.children)&&(0,g.jsxs)(u.Box,{sx:{mt:.75,borderTop:`1px solid rgba(255,255,255,0.2)`,pt:.75},children:[o.specialValueA!=null&&(0,g.jsxs)(u.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,g.jsx)(u.Typography,{variant:`caption`,sx:{opacity:.6},children:k.specialValueA??`A`}),(0,g.jsx)(u.Typography,{variant:`caption`,children:String(o.specialValueA)})]}),o.specialValueB!=null&&(0,g.jsxs)(u.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,g.jsx)(u.Typography,{variant:`caption`,sx:{opacity:.6},children:k.specialValueB??`B`}),(0,g.jsx)(u.Typography,{variant:`caption`,children:String(o.specialValueB)})]}),e.children&&(0,g.jsxs)(u.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,g.jsx)(u.Typography,{variant:`caption`,sx:{opacity:.6},children:`Reports`}),(0,g.jsx)(u.Typography,{variant:`caption`,children:e.children.length})]})]})]});return(0,g.jsx)(u.Tooltip,{...Ne,title:v,children:(0,g.jsxs)(`g`,{transform:`translate(${r.x},${r.y})`,onClick:t=>je(e,t),onDoubleClick:t=>Me(e,t),onMouseEnter:t=>{E||w?.(le(e),t)},onMouseLeave:e=>{w?.(null,e)},style:{cursor:E?`not-allowed`:`pointer`},children:[(0,g.jsx)(`circle`,{r:a+8,fill:`transparent`}),(0,g.jsx)(`circle`,{r:a+2,fill:i,fillOpacity:.15}),(0,g.jsx)(`circle`,{r:a,fill:i}),f&&(0,g.jsx)(qi,{path:l,size:Pe}),s&&(0,g.jsx)(`text`,{x:m,y:h,dy:`0.35em`,textAnchor:_,fontSize:c,fontWeight:e.children?`bold`:`normal`,fill:e.data.colorConfig?.textColor??M,paintOrder:`stroke`,stroke:P,strokeWidth:3,pointerEvents:`none`,children:e.data.name})]})},`node-${n}`)}),ne&&((e,t)=>(0,g.jsxs)(`g`,{"data-testid":`drill-ghost-layer`,opacity:t,pointerEvents:`none`,children:[(0,g.jsx)(`g`,{fill:`none`,stroke:N,strokeOpacity:m,strokeWidth:h,children:e.links().map((e,t)=>(0,g.jsx)(`path`,{d:ce(e)},`ghost-link-${t}`))}),(0,g.jsx)(`g`,{children:e.descendants().map((e,t)=>{let n=se(e);return(0,g.jsxs)(`g`,{transform:`translate(${n.x},${n.y})`,children:[(0,g.jsx)(`circle`,{r:a+2,fill:oe(e),fillOpacity:.15}),(0,g.jsx)(`circle`,{r:a,fill:oe(e)}),f&&(0,g.jsx)(qi,{path:e.children?Ki.folder:Ki.person,size:Pe})]},`ghost-node-${t}`)})})]}))(ne,ie)]})}),x&&(0,g.jsx)(u.Popover,{open:Ce,anchorEl:Te,onClose:()=>we(!1),anchorOrigin:{vertical:`top`,horizontal:`right`},transformOrigin:{vertical:`top`,horizontal:`left`},slotProps:{paper:{elevation:4}},children:ke&&(S?S(ke):(0,g.jsx)(Ji,{info:ke,labelA:k.specialValueA??`Value A`,labelB:k.specialValueB??`Value B`}))})]})}Yi.displayName=`HorizontalTreeChart`;var Xi={noData:`No data`};function Zi(e,t=0,n=`.`,r=`,`){let[i,a]=e.toFixed(Math.max(0,t)).split(`.`),o=i.replace(/\B(?=(\d{3})+(?!\d))/g,r);return a?`${o}${n}${a}`:o}function Qi(e){return Math.abs(e)>=1e9?`${(e/1e9).toFixed(1).replace(/\.0$/,``)}B`:Math.abs(e)>=1e6?`${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`:Math.abs(e)>=1e3?`${(e/1e3).toFixed(1).replace(/\.0$/,``)}k`:String(e)}function $i(e){return e.map(e=>typeof e==`string`?{key:e,label:e}:e)}function ea({barData:e,seriesKey:t,seriesLabel:n,decimals:r,decimalSep:i,thousandSep:a,valueFormatter:o}){let s=e.values[t]??0,c=Z.sum(Object.values(e.values)),l=c>0?Math.round(s/c*1e3)/10:0,d=(e,t)=>o?o(e,t):Zi(e,r,i,a);return(0,g.jsxs)(u.Box,{sx:{py:.25},children:[(0,g.jsx)(u.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`},children:e.label}),(0,g.jsxs)(u.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:[n,`: `,d(s,t)]}),(0,g.jsxs)(u.Typography,{variant:`caption`,sx:{display:`block`,opacity:.65,mt:.25},children:[l,`% · Total: `,d(c,``)]})]})}function ta({data:e,keys:t,size:n=500,innerRadius:r,barPadding:i=.12,chartColors:a,colorConfig:o,showLabels:s=!0,showGridLines:c=!0,gridLineCount:l=3,showGridValues:f=!0,showLegend:p=!0,sortBy:m=`none`,valueDecimalCount:h=0,valueDecimalSeparator:_=`.`,valueThousandsSeparator:v=`,`,valueFormatter:y,gridValueFormatter:b,zoomable:x=!1,onBarClick:S,onBarHover:C,disabled:w=!1,translation:T}){let E=(0,u.useTheme)(),D={...Xi,...T},O=(0,d.useMemo)(()=>$i(t),[t]),k=(0,d.useMemo)(()=>O.map(e=>e.key),[O]),A=e.length===0||O.length===0,j=s?63:16,M=n/2-j,N=r==null?Math.round(n*.18):Math.max(0,Math.min(r,M-1)),P=[E.palette.primary.main,E.palette.secondary.main,E.palette.success.main,E.palette.warning.main,E.palette.error.main,E.palette.info.main,`#8e24aa`,`#00897b`,`#f06292`,`#a1887f`],F=a&&a.length>0?a:P,I=(0,d.useCallback)((e,t)=>{let n=o?.[e];return n?.fill?n.fill:F[t%F.length]},[o,F]),L=(0,d.useMemo)(()=>m===`value`?[...e].sort((e,t)=>Z.sum(k,e=>t.values[e]??0)-Z.sum(k,t=>e.values[t]??0)):m===`label`?[...e].sort((e,t)=>e.label.localeCompare(t.label,void 0,{numeric:!0,sensitivity:`base`})):e,[e,m,k]),R=(0,d.useMemo)(()=>Z.max(L,e=>Z.sum(k,t=>e.values[t]??0))??0,[L,k]),z=(0,d.useMemo)(()=>Z.scaleBand().domain(L.map(e=>e.id)).range([0,2*Math.PI]).padding(i),[L,i]),B=(0,d.useMemo)(()=>Z.scaleLinear().domain([0,R]).range([N,M]),[N,M,R]),V=(0,d.useMemo)(()=>A?[]:Z.stack().keys(k).value((e,t)=>e.values[t]??0).order(Z.stackOrderNone).offset(Z.stackOffsetNone)(L),[A,L,k]),H=(0,d.useMemo)(()=>Z.arc().startAngle(e=>e.x0).endAngle(e=>e.x1).innerRadius(e=>e.y0).outerRadius(e=>e.y1).padAngle(.008).padRadius(N+10),[N]),U=(0,d.useMemo)(()=>R>0?Z.ticks(0,R,l).filter(e=>e>0):[],[R,l]),W=b??Qi,[G,K]=(0,d.useState)(1),q=(0,d.useRef)(null),[J,ee]=(0,d.useState)(`-${n/2} -${n/2} ${n} ${n}`),te=(0,d.useMemo)(()=>{if(G===1)return J;let[e,t,n,r]=J.split(` `).map(Number),i=n/G,a=r/G;return`${e+(n-i)/2} ${t+(r-a)/2} ${i} ${a}`},[J,G]);(0,d.useLayoutEffect)(()=>{let e=q.current;if(!e)return;let t=requestAnimationFrame(()=>{try{let t=e.getBBox();ee(`${t.x-4} ${t.y-4} ${t.width+8} ${t.height+8}`)}catch{ee(`-${n/2} -${n/2} ${n} ${n}`)}});return()=>cancelAnimationFrame(t)},[n,e,t,N,M,s,c]),(0,d.useLayoutEffect)(()=>{if(w)return;let e=e=>{e.key===`Escape`&&K(1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[w]);let Y=(0,d.useCallback)(e=>{if(!x||w||!e.ctrlKey)return;e.preventDefault();let t=e.deltaY<0?1.15:1/1.15;K(e=>Math.max(.25,Math.min(8,e*t)))},[x,w]),X=-(O.length*16)/2,ne=Math.max(0,N*2-10-5-10),re=9*.57,ie=O.reduce((e,t)=>Math.max(e,(t.label??t.key).length),0),ae=-((15+Math.min(ie*re,ne))/2),oe=Math.max(1,Math.floor(ne/re)),se=e=>e.length<=oe?e:`${e.slice(0,oe-1)}…`,ce={followCursor:!0,enterDelay:50,enterNextDelay:0,disableHoverListener:w,slotProps:{tooltip:{sx:{maxWidth:240}}}},le=E.palette.text.primary,ue=E.palette.divider,de=E.typography.fontFamily;return(0,g.jsx)(u.Box,{style:{opacity:w?.5:1},sx:{display:`inline-flex`,cursor:w?`not-allowed`:`default`,userSelect:`none`},children:(0,g.jsx)(`svg`,{width:n,height:n,viewBox:te,onWheel:Y,style:{fontFamily:de??`sans-serif`,overflow:x&&G>1?`hidden`:`visible`},role:`img`,"aria-label":`Radial stacked bar chart`,children:(0,g.jsxs)(`g`,{ref:q,children:[A&&(0,g.jsx)(`text`,{textAnchor:`middle`,dy:`0.35em`,fontSize:13,fill:E.palette.text.secondary,children:D.noData}),!A&&(0,g.jsxs)(g.Fragment,{children:[c&&U.map(e=>(0,g.jsx)(`circle`,{r:B(e),fill:`none`,stroke:ue,strokeWidth:.5,strokeDasharray:`3 2`},`grid-${e}`)),c&&(0,g.jsx)(`circle`,{r:N,fill:`none`,stroke:ue,strokeWidth:.75}),c&&f&&U.map(e=>(0,g.jsx)(`text`,{x:0,y:-B(e),textAnchor:`middle`,dy:`-3`,fontSize:9,fill:E.palette.text.secondary,pointerEvents:`none`,children:W(e)},`gv-${e}`)),V.map((e,t)=>{let n=e.key,r=O[t]?.label??n,i=I(n,t);return e.map((e,t)=>{let a=e.data,o=z(a.id)??0,s=o+z.bandwidth(),c=B(e[0]),l=B(e[1]);if(l-c<.5)return null;let d=H({x0:o,x1:s,y0:c,y1:l})??``;return(0,g.jsx)(u.Tooltip,{...ce,placement:`top`,title:(0,g.jsx)(ea,{barData:a,seriesKey:n,seriesLabel:r,decimals:h,decimalSep:_,thousandSep:v,valueFormatter:y}),children:(0,g.jsx)(`path`,{d,fill:i,style:{cursor:w?`not-allowed`:`pointer`,transition:`opacity 0.15s`},onMouseEnter:e=>{if(w)return;e.currentTarget.style.opacity=`0.75`;let t=Z.sum(k,e=>a.values[e]??0),r={id:a.id,label:a.label,seriesKey:n,value:a.values[n]??0,total:t,values:a.values};C?.(r,e)},onMouseLeave:e=>{e.currentTarget.style.opacity=`1`,C?.(null,e)},onClick:e=>{if(w)return;let t=Z.sum(k,e=>a.values[e]??0),r={id:a.id,label:a.label,seriesKey:n,value:a.values[n]??0,total:t,values:a.values};S?.(r,e)}})},`${n}-${t}`)})}),s&&L.map(e=>{let t=(z(e.id)??0)+z.bandwidth()/2,n=M+8,r=n*Math.sin(t),i=-n*Math.cos(t),a=t*180/Math.PI;return(0,g.jsx)(`text`,{x:r,y:i,transform:`rotate(${a<180?a-90:a+90},${r},${i})`,textAnchor:`middle`,dominantBaseline:`central`,fontSize:11,fill:le,pointerEvents:`none`,children:e.label},`lbl-${e.id}`)}),p&&(0,g.jsx)(`g`,{pointerEvents:`none`,transform:`translate(${ae},0)`,children:O.map((e,t)=>{let n=I(e.key,t),r=X+t*16,i=se(e.label??e.key);return(0,g.jsxs)(`g`,{transform:`translate(0,${r})`,children:[(0,g.jsx)(`rect`,{x:0,y:0,width:10,height:10,fill:n,rx:2}),(0,g.jsx)(`text`,{x:15,y:10/2,dominantBaseline:`central`,fontSize:9,fill:le,children:i})]},`leg-${e.key}`)})})]})]})})})}ta.displayName=`RadialStackedBarChart`,exports.ChordChart=Fi,exports.CirclePackingChart=Wi,exports.ColorPicker=Tt,exports.DEFAULT_CHECK_COLORS=_r,exports.DEFAULT_CHORD_CHART_TRANSLATION=ji,exports.DEFAULT_CIRCLE_PACKING_TRANSLATION=Vi,exports.DEFAULT_COLOR_PICKER_TRANSLATION=bt,exports.DEFAULT_DATE_RANGE_PICKER_TRANSLATION=Xe,exports.DEFAULT_GANTT_TRANSLATIONS=Dn,exports.DEFAULT_HORIZONTAL_TREE_TRANSLATION=Gi,exports.DEFAULT_JSON_EDITOR_TOOLBAR_CONFIG=Ot,exports.DEFAULT_JSON_EDITOR_TRANSLATION=kt,exports.DEFAULT_KANBAN_BOARD_TRANSLATION=He,exports.DEFAULT_METER_COLORS=gr,exports.DEFAULT_PASSWORD_TRANSLATIONS=hr,exports.DEFAULT_POPOVER_COLOR_PICKER_TRANSLATION=xt,exports.DEFAULT_RADIAL_STACKED_BAR_CHART_TRANSLATION=Xi,exports.DEFAULT_RADIAL_TREE_CHART_TRANSLATION=Ii,exports.DEFAULT_RICH_TEXT_EDITOR_TOOLBAR_CONFIG=Lr,exports.DEFAULT_RICH_TEXT_EDITOR_TRANSLATION=Rr,exports.DEFAULT_SQL_EDITOR_TOOLBAR_CONFIG=ai,exports.DEFAULT_SQL_EDITOR_TRANSLATION=oi,exports.DEFAULT_SUNBURST_CHART_TRANSLATION=Si,exports.DEFAULT_TAG_SELECTION_TRANSLATION=Mr,exports.DateRangePicker=nt,exports.GanttChart=dr,exports.HorizontalTreeChart=Yi,exports.JsonEditor=en,exports.KanbanBoard=Je,exports.PasswordStrengthMeter=br,exports.PopoverColorPicker=Dt,exports.RadialStackedBarChart=ta,exports.RadialTreeChart=Bi,exports.RichTextEditor=ii,exports.SqlEditor=xi,exports.SunburstChart=Ai,exports.TagSelection=Ir,exports.colorPickerClasses=at,exports.dateRangePickerClasses=Ye,exports.kanbanBoardClasses=Ve,exports.muiTsStateClasses=Be,exports.passwordStrengthMeterClasses=it,exports.popoverColorPickerClasses=ot,exports.tagSelectionClasses=rt,exports.useGanttChartStore=$,exports.useGanttTheme=or,exports.useGanttTranslations=ir,exports.useRawGanttChartStore=nr;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`@dnd-kit/core`),l=require(`@dnd-kit/sortable`),u=require(`@mui/icons-material/Search`);u=s(u,1);let d=require(`@mui/material`),f=require(`react`),p=require(`@dnd-kit/utilities`),m=require(`@mui/icons-material/CalendarToday`);m=s(m,1);let h=require(`@mui/icons-material/Person`);h=s(h,1);let g=require(`@mui/material/styles`),_=require(`react/jsx-runtime`),v=require(`@mui/icons-material/Delete`);v=s(v,1);let y=require(`@mui/icons-material/Add`);y=s(y,1);let b=require(`@mui/icons-material/Colorize`);b=s(b,1);let x=require(`@codemirror/view`),S=require(`@codemirror/state`),C=require(`@codemirror/lang-json`),w=require(`@codemirror/commands`),T=require(`@codemirror/language`),E=require(`@codemirror/lint`),D=require(`@lezer/highlight`),O=require(`@replit/codemirror-minimap`),k=require(`@mui/icons-material/ContentCopy`);k=s(k,1);let A=require(`@mui/icons-material/Download`);A=s(A,1);let j=require(`@mui/icons-material/Check`);j=s(j,1);let M=require(`@mui/icons-material/Undo`);M=s(M,1);let N=require(`@mui/icons-material/Redo`);N=s(N,1);let P=require(`@mui/icons-material/AutoFixHigh`);P=s(P,1);let F=require(`@mui/icons-material/Compress`);F=s(F,1);let I=require(`@mui/icons-material/CheckCircleOutlined`);I=s(I,1);let L=require(`@mui/icons-material/ErrorOutlined`);L=s(L,1);let R=require(`zustand`),z=require(`zustand/vanilla`),B=require(`@tanstack/react-virtual`),V=require(`@mui/icons-material/Edit`);V=s(V,1);let H=require(`@mui/icons-material/RestartAlt`);H=s(H,1);let U=require(`@mui/icons-material/Restore`);U=s(U,1);let W=require(`@mui/icons-material/Today`);W=s(W,1);let G=require(`@mui/icons-material/UnfoldLess`);G=s(G,1);let K=require(`@mui/icons-material/UnfoldMore`);K=s(K,1);let q=require(`@mui/icons-material/CheckCircle`);q=s(q,1);let J=require(`@mui/icons-material/Cancel`);J=s(J,1);let ee=require(`@mui/icons-material/Visibility`);ee=s(ee,1);let te=require(`@mui/icons-material/VisibilityOff`);te=s(te,1);let Y=require(`@mui/icons-material/Close`);Y=s(Y,1);let X=require(`@tiptap/react`),ne=require(`@tiptap/extension-mention`),re=require(`@tiptap/starter-kit`),ie=require(`@tiptap/extension-text-style`),ae=require(`@tiptap/extension-color`),oe=require(`@tiptap/extension-highlight`),se=require(`@tiptap/extension-placeholder`),ce=require(`@tiptap/extension-character-count`),le=require(`@tiptap/extension-table`),ue=require(`@tiptap/extension-image`),de=require(`tiptap-markdown`),fe=require(`@mui/icons-material/Fullscreen`);fe=s(fe,1);let pe=require(`@mui/icons-material/FullscreenExit`);pe=s(pe,1);let me=require(`@mui/icons-material/Image`);me=s(me,1);let he=require(`@mui/icons-material/EmojiEmotions`);he=s(he,1);let ge=require(`@mui/icons-material/FormatBold`);ge=s(ge,1);let _e=require(`@mui/icons-material/FormatItalic`);_e=s(_e,1);let ve=require(`@mui/icons-material/FormatUnderlined`);ve=s(ve,1);let ye=require(`@mui/icons-material/StrikethroughS`);ye=s(ye,1);let be=require(`@mui/icons-material/FormatListBulleted`);be=s(be,1);let xe=require(`@mui/icons-material/FormatListNumbered`);xe=s(xe,1);let Se=require(`@mui/icons-material/FormatQuote`);Se=s(Se,1);let Ce=require(`@mui/icons-material/Code`);Ce=s(Ce,1);let we=require(`@mui/icons-material/InsertLink`);we=s(we,1);let Te=require(`@mui/icons-material/HorizontalRule`);Te=s(Te,1);let Ee=require(`@mui/icons-material/FormatColorText`);Ee=s(Ee,1);let De=require(`@mui/icons-material/BorderColor`);De=s(De,1);let Oe=require(`@mui/icons-material/FormatClear`);Oe=s(Oe,1);let ke=require(`@mui/icons-material/ContentPaste`);ke=s(ke,1);let Ae=require(`@mui/icons-material/ContentPasteOff`);Ae=s(Ae,1);let je=require(`@mui/icons-material/FormatColorReset`);je=s(je,1);let Me=require(`@mui/icons-material/TableChart`);Me=s(Me,1);let Ne=require(`sql-formatter`),Pe=require(`@codemirror/lang-sql`),Fe=require(`@codemirror/autocomplete`),Ie=require(`@mui/icons-material/PlayArrow`);Ie=s(Ie,1);let Le=require(`@mui/icons-material/History`);Le=s(Le,1);let Re=require(`@mui/icons-material/DeleteSweep`);Re=s(Re,1);let ze=require(`@mui/icons-material/WarningAmber`);ze=s(ze,1);let Z=require(`d3`);Z=s(Z,1);var Be={disabled:`MuiTs-disabled`,selected:`MuiTs-selected`,focused:`MuiTs-focused`,error:`MuiTs-error`},Ve={root:`MuiTsKanbanBoard-root`,columns:`MuiTsKanbanBoard-columns`,column:`MuiTsKanbanBoard-column`,columnHeader:`MuiTsKanbanBoard-columnHeader`,columnTitle:`MuiTsKanbanBoard-columnTitle`,columnCount:`MuiTsKanbanBoard-columnCount`,columnBody:`MuiTsKanbanBoard-columnBody`,card:`MuiTsKanbanBoard-card`,cardTitle:`MuiTsKanbanBoard-cardTitle`,cardMeta:`MuiTsKanbanBoard-cardMeta`,cardAssignee:`MuiTsKanbanBoard-cardAssignee`,cardDueDate:`MuiTsKanbanBoard-cardDueDate`,cardPriorityDot:`MuiTsKanbanBoard-cardPriorityDot`,addButton:`MuiTsKanbanBoard-addButton`,searchFieldWrapper:`MuiTsKanbanBoard-searchFieldWrapper`,searchField:`MuiTsKanbanBoard-searchField`},He={addCardLabel:`Add card`,dialogAddTitle:`Add card`,dialogEditTitle:`Edit card`,dialogDeleteTitle:`Delete card`,dialogSave:`Save`,dialogCancel:`Cancel`,dialogDelete:`Delete`,dialogDeleteConfirm:`Delete "{title}"?`,dialogFieldTitle:`Title`,dialogFieldDescription:`Description`,dialogFieldAssignee:`Assignee`,dialogFieldDueDate:`Due date`,dialogFieldStatus:`Status`,noCardsLabel:`No cards`,searchFieldPlaceholder:`Search by title or assignee…`},Ue={low:`#4caf50`,medium:`#ff9800`,high:`#f44336`,critical:`#9c27b0`},We={fontSize:`0.7rem`,height:22,"& .MuiChip-icon":{fontSize:`0.75rem`,width:`0.75rem`,height:`0.75rem`,ml:`8px`,mr:`4px`},"& .MuiChip-label":{pl:`2px`,pr:`10px`}};function Ge({task:e,showPriority:t,showAssignee:n,showDueDate:r,showDueDateWarning:i,chipVariant:a,t:o,onCardClick:s,isOverlay:c=!1}){let{attributes:u,listeners:f,setNodeRef:v,transform:y,transition:b,isDragging:x}=(0,l.useSortable)({id:e.id,disabled:c}),S=c?void 0:{transform:p.CSS.Transform.toString(y),transition:b,opacity:+!x},C=n&&!!e.assignee||r&&!!e.dueDate,w=e.dueDate?e.dueDate.toLocaleDateString(void 0,{day:`2-digit`,month:`short`,year:`numeric`}):null,T=new Date;T.setHours(0,0,0,0);let E=i&&!!e.dueDate&&e.dueDate<T;return(0,_.jsx)(d.Card,{ref:c?void 0:v,style:S,elevation:0,className:[Ve.card,x&&Be.selected].filter(Boolean).join(` `),sx:{mb:1,border:`1px solid`,borderColor:E&&!e.color?`error.light`:`divider`,borderLeft:e.color?`4px solid ${e.color}`:E?e=>`4px solid ${e.palette.error.main}`:void 0,userSelect:`none`,cursor:c?`grabbing`:`grab`,bgcolor:e=>E?e.palette.mode===`dark`?(0,g.alpha)(e.palette.error.main,.12):(0,g.alpha)(e.palette.error.main,.04):e.palette.mode===`dark`?e.palette.grey[800]:e.palette.background.paper,boxShadow:e=>e.palette.mode===`dark`?`0 1px 3px rgba(0,0,0,0.4)`:`0 1px 3px rgba(0,0,0,0.08)`,transition:`box-shadow 0.15s ease, transform 0.15s ease`,...!x&&!c&&{"&:hover":{boxShadow:e=>e.palette.mode===`dark`?`0 4px 14px rgba(0,0,0,0.5)`:`0 4px 14px rgba(0,0,0,0.12)`,transform:`translateY(-1px)`}},"&:active":{cursor:`grabbing`}},...c?{}:{...u,...f},onClick:()=>!x&&s(e),"aria-label":e.title,children:(0,_.jsx)(d.CardActionArea,{component:`div`,sx:{cursor:`inherit`},children:(0,_.jsxs)(d.CardContent,{sx:{p:1.5,"&:last-child":{pb:1.5}},children:[(0,_.jsxs)(d.Box,{sx:{display:`flex`,alignItems:`flex-start`,gap:.75,mb:+!!C},children:[t&&e.priority&&(0,_.jsx)(d.Box,{className:Ve.cardPriorityDot,role:`img`,"aria-label":`Priority: ${e.priority}`,sx:{width:8,height:8,minWidth:8,borderRadius:`50%`,bgcolor:Ue[e.priority],mt:`5px`,flexShrink:0}}),(0,_.jsx)(d.Typography,{className:Ve.cardTitle,variant:`body2`,sx:{lineHeight:1.4,fontWeight:700,letterSpacing:`-0.01em`},children:e.title})]}),C&&(0,_.jsxs)(d.Box,{className:Ve.cardMeta,sx:{display:`flex`,gap:1,flexWrap:`wrap`,alignItems:`center`},children:[n&&e.assignee&&(0,_.jsx)(d.Chip,{className:Ve.cardAssignee,icon:(0,_.jsx)(h.default,{}),label:e.assignee,size:`small`,variant:a,"aria-label":`${o.dialogFieldAssignee}: ${e.assignee}`,sx:We}),r&&w&&(0,_.jsx)(d.Chip,{className:Ve.cardDueDate,icon:(0,_.jsx)(m.default,{}),label:w,size:`small`,variant:a,color:E?`error`:`default`,"aria-label":`${o.dialogFieldDueDate}: ${w}`,sx:We})]})]})})})}function Ke({state:e,columns:t,t:n,onSave:r,onDelete:i,onClose:a,onRequestDelete:o}){let s=e?.mode===`add`,c=e?.mode===`edit`,l=e?.mode===`delete`,u=c?e.task:null,p=l?e.task:null,m=s?e.columnId:null,[h,g]=(0,f.useState)(()=>c&&u?{...u}:s&&m?{id:``,title:``,status:m}:{id:``,title:``,status:t[0]?.id??``});function y(){let e=h.title.trim();e&&r({...h,title:e,id:c?h.id:crypto.randomUUID()})}function b(e,t){g(n=>({...n,[e]:t}))}let x=s?n.dialogAddTitle:c?n.dialogEditTitle:n.dialogDeleteTitle;return(0,_.jsxs)(d.Dialog,{open:!!e,onClose:a,maxWidth:`xs`,fullWidth:!0,children:[(0,_.jsx)(d.DialogTitle,{children:x}),l&&p?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(d.DialogContent,{children:(0,_.jsx)(d.DialogContentText,{children:n.dialogDeleteConfirm.replace(`{title}`,p.title)})}),(0,_.jsxs)(d.DialogActions,{children:[(0,_.jsx)(d.Button,{onClick:a,children:n.dialogCancel}),(0,_.jsx)(d.Button,{color:`error`,startIcon:(0,_.jsx)(v.default,{}),onClick:()=>i(p.id),children:n.dialogDelete})]})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(d.DialogContent,{children:(0,_.jsxs)(d.Stack,{spacing:2,sx:{pt:.5},children:[(0,_.jsx)(d.TextField,{label:n.dialogFieldTitle,value:h.title,onChange:e=>b(`title`,e.target.value),required:!0,fullWidth:!0,size:`small`,autoFocus:!0,onKeyDown:e=>e.key===`Enter`&&y()}),(0,_.jsx)(d.TextField,{label:n.dialogFieldDescription,value:h.description??``,onChange:e=>b(`description`,e.target.value||void 0),fullWidth:!0,size:`small`,multiline:!0,rows:3}),(0,_.jsx)(d.TextField,{label:n.dialogFieldAssignee,value:h.assignee??``,onChange:e=>b(`assignee`,e.target.value||void 0),fullWidth:!0,size:`small`}),(0,_.jsx)(d.TextField,{label:n.dialogFieldDueDate,type:`date`,value:h.dueDate?h.dueDate.toISOString().split(`T`)[0]:``,onChange:e=>b(`dueDate`,e.target.value?new Date(e.target.value+`T00:00:00`):void 0),fullWidth:!0,size:`small`,slotProps:{inputLabel:{shrink:!0}}}),(0,_.jsx)(d.TextField,{select:!0,label:n.dialogFieldStatus,value:h.status,onChange:e=>b(`status`,e.target.value),fullWidth:!0,size:`small`,children:t.map(e=>(0,_.jsx)(d.MenuItem,{value:e.id,children:e.label},e.id))})]})}),(0,_.jsxs)(d.DialogActions,{sx:{justifyContent:c?`space-between`:`flex-end`},children:[c&&u&&(0,_.jsx)(d.Button,{color:`error`,startIcon:(0,_.jsx)(v.default,{}),onClick:()=>o(u),children:n.dialogDelete}),(0,_.jsxs)(d.Stack,{direction:`row`,spacing:1,children:[(0,_.jsx)(d.Button,{onClick:a,children:n.dialogCancel}),(0,_.jsx)(d.Button,{variant:`contained`,onClick:y,disabled:!h.title.trim(),children:n.dialogSave})]})]})]})]})}function qe({column:e,tasks:t,totalCount:n,showPriority:r,showAssignee:i,showDueDate:a,showDueDateWarning:o,chipVariant:s,t:u,enableBuiltinDialogs:f,onCardClick:p,onAddClick:m}){let{setNodeRef:h,isOver:g}=(0,c.useDroppable)({id:e.id}),v=e.wipLimit!==void 0&&n>e.wipLimit,b=e.wipLimit===void 0?`${t.length}`:`${t.length} / ${e.wipLimit}`,x=e.color??`primary.main`;return(0,_.jsxs)(d.Box,{className:Ve.column,sx:{display:`flex`,flexDirection:`column`,minWidth:240,maxWidth:320,flex:`1 1 240px`,bgcolor:`background.paper`,borderRadius:2,overflow:`hidden`,border:`1px solid`,borderColor:`divider`},children:[(0,_.jsxs)(d.Box,{className:Ve.columnHeader,sx:{px:2,py:1.25,display:`flex`,alignItems:`center`,gap:1,borderBottom:`1px solid`,borderColor:`divider`,borderTop:`3px solid ${e.color??`transparent`}`,bgcolor:e=>e.palette.mode===`dark`?`grey.800`:`grey.300`},children:[(0,_.jsx)(d.Typography,{className:Ve.columnTitle,variant:`subtitle2`,sx:{flex:1,fontWeight:700},children:e.label}),(0,_.jsx)(d.Chip,{className:Ve.columnCount,label:b,size:`small`,color:v?`error`:`default`,sx:{height:20,fontSize:`0.7rem`,...!v&&e.color&&{bgcolor:e.color,color:`#fff`}},"aria-label":`${t.length} cards${e.wipLimit?` of ${e.wipLimit} limit`:``}${t.length===n?``:` (${n} total)`}`})]}),(0,_.jsx)(l.SortableContext,{items:t.map(e=>e.id),strategy:l.verticalListSortingStrategy,children:(0,_.jsxs)(d.Box,{ref:h,className:Ve.columnBody,sx:{flex:1,overflowY:`auto`,scrollbarWidth:`none`,"&::-webkit-scrollbar":{display:`none`},p:1,minHeight:80,bgcolor:e=>g?e.palette.action.selected:e.palette.mode===`dark`?e.palette.grey[900]:e.palette.grey[100],transition:`background-color 0.15s`},children:[t.length===0&&!g&&(0,_.jsx)(d.Typography,{variant:`caption`,color:`text.disabled`,sx:{display:`block`,textAlign:`center`,mt:2},children:u.noCardsLabel}),t.map(e=>(0,_.jsx)(Ge,{task:e,showPriority:r,showAssignee:i,showDueDate:a,showDueDateWarning:o,chipVariant:s,t:u,onCardClick:p},e.id))]})}),f&&(0,_.jsx)(d.Box,{sx:{p:1,borderTop:`1px solid`,borderColor:`divider`},children:(0,_.jsx)(d.Button,{className:Ve.addButton,startIcon:(0,_.jsx)(y.default,{}),size:`small`,fullWidth:!0,onClick:()=>m(e.id),sx:{justifyContent:`flex-start`,color:x,border:`1px dashed`,borderColor:x,borderRadius:1,py:.75,fontWeight:600,letterSpacing:.5,"&:hover":{bgcolor:`action.hover`,borderStyle:`dashed`}},children:u.addCardLabel})})]})}function Je({tasks:e,columns:t,onTasksChange:n,onCardClick:r,enableBuiltinDialogs:i=!0,onTaskCreated:a,onTaskUpdated:o,onTaskDeleted:s,onTaskMoved:p,showPriority:m=!0,showAssignee:h=!0,showDueDate:g=!0,showDueDateWarning:v=!0,chipVariant:y=`outlined`,showSearchField:b=!1,filterText:x=``,width:S=`100%`,height:C=`100%`,translation:w}){let T={...He,...w},[E,D]=(0,f.useState)(e);(0,f.useEffect)(()=>{D(e)},[e]);let[O,k]=(0,f.useState)(null),[A,j]=(0,f.useState)(null),[M,N]=(0,f.useState)(``),P=(0,c.useSensors)((0,c.useSensor)(c.PointerSensor,{activationConstraint:{distance:8}}),(0,c.useSensor)(c.KeyboardSensor,{coordinateGetter:l.sortableKeyboardCoordinates}));function F({active:e}){k(E.find(t=>t.id===e.id)??null)}function I({active:e,over:n}){if(!n)return;let r=e.id,i=n.id,a=E.find(e=>e.id===r);if(!a)return;let o=t.find(e=>e.id===i),s=E.find(e=>e.id===i),c=o?.id??s?.status;!c||a.status===c||D(e=>e.map(e=>e.id===r?{...e,status:c}:e))}function L({active:t,over:r}){let i=O?.status;if(k(null),!r){D(e);return}let a=t.id,o=r.id,s=E.findIndex(e=>e.id===a),c=E.findIndex(e=>e.id===o),u;if(u=s!==-1&&c!==-1&&s!==c?(0,l.arrayMove)(E,s,c):[...E],D(u),n?.(u),i){let e=u.find(e=>e.id===a);e&&e.status!==i&&p?.(e,i,e.status)}}function R(e){i?j({mode:`edit`,task:e}):r?.(e)}function z(e){j({mode:`add`,columnId:e})}function B(e){let t=!E.find(t=>t.id===e.id),r=t?[...E,e]:E.map(t=>t.id===e.id?e:t);D(r),n?.(r),t?a?.(e):o?.(e),j(null)}function V(e){let t=E.filter(t=>t.id!==e);D(t),n?.(t),s?.(e),j(null)}function H(e){j({mode:`delete`,task:e})}let U=(x||M).trim().toLowerCase();function W(e){return U?e.title.toLowerCase().includes(U)||(e.assignee?.toLowerCase().includes(U)??!1):!0}return(0,_.jsxs)(d.Box,{className:Ve.root,sx:{width:S,height:C,display:`flex`,flexDirection:`column`,overflow:`hidden`},children:[b&&(0,_.jsx)(d.Box,{className:Ve.searchFieldWrapper,sx:{px:2,pt:1.5,pb:.5},children:(0,_.jsx)(d.TextField,{className:Ve.searchField,size:`small`,placeholder:T.searchFieldPlaceholder,value:M,onChange:e=>N(e.target.value),slotProps:{input:{startAdornment:(0,_.jsx)(d.InputAdornment,{position:`start`,children:(0,_.jsx)(u.default,{fontSize:`small`,sx:{color:`text.disabled`}})})},htmlInput:{"aria-label":T.searchFieldPlaceholder}},sx:{width:280}})}),(0,_.jsxs)(c.DndContext,{sensors:P,collisionDetection:c.closestCorners,onDragStart:F,onDragOver:I,onDragEnd:L,children:[(0,_.jsx)(d.Box,{className:Ve.columns,sx:{flex:1,display:`flex`,gap:2,p:2,overflowX:`auto`,overflowY:`hidden`,alignItems:`stretch`},children:t.map(e=>{let t=E.filter(t=>t.status===e.id);return(0,_.jsx)(qe,{column:e,tasks:t.filter(W),totalCount:t.length,showPriority:m,showAssignee:h,showDueDate:g,showDueDateWarning:v,chipVariant:y,t:T,enableBuiltinDialogs:i,onCardClick:R,onAddClick:z},e.id)})}),(0,_.jsx)(c.DragOverlay,{children:O&&(0,_.jsx)(Ge,{task:O,showPriority:m,showAssignee:h,showDueDate:g,showDueDateWarning:v,chipVariant:y,t:T,onCardClick:()=>{},isOverlay:!0})})]}),i&&(0,_.jsx)(Ke,{state:A,columns:t,t:T,onSave:B,onDelete:V,onRequestDelete:H,onClose:()=>j(null)},A?`${A.mode}-${A.mode===`add`?A.columnId:A.task.id}`:`closed`)]})}var Ye={root:`MuiTsDateRangePicker-root`,inputs:`MuiTsDateRangePicker-inputs`,startInput:`MuiTsDateRangePicker-startInput`,separator:`MuiTsDateRangePicker-separator`,endInput:`MuiTsDateRangePicker-endInput`,helperText:`MuiTsDateRangePicker-helperText`},Xe={fromLabel:`From`,toLabel:`To`,endBeforeStartError:`End date must be after start date`,startRequiredError:`Start date is required`,endRequiredError:`End date is required`};function Ze(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function Qe(e){if(!e)return null;let t=new Date(`${e}T00:00:00`);return isNaN(t.getTime())?null:t}function $e(e){return e?{date:e,iso:Ze(e)}:null}function et(e,t,n,r){let i=``,a=``;return e.start&&e.end&&e.end<e.start&&(a=r.endBeforeStartError),n&&!e.start&&t.start&&(i=r.startRequiredError),n&&!e.end&&t.end&&!a&&(a=r.endRequiredError),{startError:i,endError:a}}var tt={start:null,end:null};function nt({value:e,defaultValue:t,onChange:n,minDate:r,maxDate:i,disabled:a=!1,required:o=!1,error:s=!1,helperText:c,inputSize:l=`small`,inputMinWidth:u=170,translation:p}){let m={...Xe,...p},h=e!==void 0,[g,v]=(0,f.useState)(t??tt),[y,b]=(0,f.useState)({start:!1,end:!1}),x=h?e:g,{startError:S,endError:C}=et(x,y,o,m);function w(e,t){h||v({start:e,end:t}),n?.({start:$e(e),end:$e(t)})}function T(e){b(e=>({...e,start:!0})),w(Qe(e.target.value),x.end)}function E(e){b(e=>({...e,end:!0})),w(x.start,Qe(e.target.value))}function D(){b(e=>({...e,start:!0}))}function O(){b(e=>({...e,end:!0}))}let k=r?Ze(r):void 0,A=i?Ze(i):void 0,j=x.start?Ze(x.start):k,M=s||!!S||!!C;return(0,_.jsxs)(d.Box,{className:[Ye.root,a&&Be.disabled,M&&Be.error].filter(Boolean).join(` `),sx:{display:`inline-flex`,flexDirection:`column`,gap:.25},children:[(0,_.jsxs)(d.Box,{className:Ye.inputs,sx:{display:`inline-flex`,alignItems:`flex-start`,gap:1},children:[(0,_.jsx)(d.TextField,{className:Ye.startInput,type:`date`,label:m.fromLabel,value:x.start?Ze(x.start):``,onChange:T,onBlur:D,disabled:a,required:o,error:!!S||s,helperText:S||` `,size:l,sx:{width:u},slotProps:{inputLabel:{shrink:!0},htmlInput:{min:k,max:A,"data-testid":`date-range-start`}}}),(0,_.jsx)(d.Box,{component:`span`,className:Ye.separator,"aria-hidden":!0,sx:{color:`text.disabled`,userSelect:`none`,flexShrink:0,lineHeight:1,mt:l===`small`?`12px`:`20px`},children:`–`}),(0,_.jsx)(d.TextField,{className:Ye.endInput,type:`date`,label:m.toLabel,value:x.end?Ze(x.end):``,onChange:E,onBlur:O,disabled:a,required:o,error:!!C||s,helperText:C||` `,size:l,sx:{width:u},slotProps:{inputLabel:{shrink:!0},htmlInput:{min:j,max:A,"data-testid":`date-range-end`}}})]}),c&&(0,_.jsx)(d.FormHelperText,{className:Ye.helperText,error:s,sx:{mx:`14px`},children:c})]})}var rt={root:`MuiTsTagSelection-root`,selectedTags:`MuiTsTagSelection-selectedTags`,selectedTagsLabel:`MuiTsTagSelection-selectedTagsLabel`,chipsStack:`MuiTsTagSelection-chipsStack`,chip:`MuiTsTagSelection-chip`,overflowChip:`MuiTsTagSelection-overflowChip`,overflowPopover:`MuiTsTagSelection-overflowPopover`,autocomplete:`MuiTsTagSelection-autocomplete`,option:`MuiTsTagSelection-option`,createPanel:`MuiTsTagSelection-createPanel`},it={root:`MuiTsPasswordStrengthMeter-root`,input:`MuiTsPasswordStrengthMeter-input`,generatorButton:`MuiTsPasswordStrengthMeter-generatorButton`,confirmInput:`MuiTsPasswordStrengthMeter-confirmInput`,strengthBar:`MuiTsPasswordStrengthMeter-strengthBar`,strengthBarWeak:`MuiTsPasswordStrengthMeter-strengthBarWeak`,strengthBarOk:`MuiTsPasswordStrengthMeter-strengthBarOk`,strengthBarGood:`MuiTsPasswordStrengthMeter-strengthBarGood`,strengthBarVeryGood:`MuiTsPasswordStrengthMeter-strengthBarVeryGood`,summary:`MuiTsPasswordStrengthMeter-summary`,requirementItem:`MuiTsPasswordStrengthMeter-requirementItem`},at={root:`MuiTsColorPicker-root`,gradientArea:`MuiTsColorPicker-gradientArea`,gradientThumb:`MuiTsColorPicker-gradientThumb`,sliderSection:`MuiTsColorPicker-sliderSection`,hueSlider:`MuiTsColorPicker-hueSlider`,alphaSlider:`MuiTsColorPicker-alphaSlider`,inputSection:`MuiTsColorPicker-inputSection`,savedColors:`MuiTsColorPicker-savedColors`,swatchList:`MuiTsColorPicker-swatchList`,swatch:`MuiTsColorPicker-swatch`},ot={root:`MuiTsPopoverColorPicker-root`,swatch:`MuiTsPopoverColorPicker-swatch`};function st(e,t,n){return Math.min(n,Math.max(t,e))}function ct(e){return st(Math.round(e),0,255).toString(16).padStart(2,`0`)}function lt({r:e,g:t,b:n,a:r}){let i=`#${ct(e)}${ct(t)}${ct(n)}`;return r<1?`${i}${ct(r*255)}`:i}function ut(e){let t=e.trim().replace(/^#/,``),n,r,i,a=1;if(t.length===3||t.length===4)n=parseInt(t[0]+t[0],16),r=parseInt(t[1]+t[1],16),i=parseInt(t[2]+t[2],16),t.length===4&&(a=parseInt(t[3]+t[3],16)/255);else if(t.length===6||t.length===8)n=parseInt(t.slice(0,2),16),r=parseInt(t.slice(2,4),16),i=parseInt(t.slice(4,6),16),t.length===8&&(a=parseInt(t.slice(6,8),16)/255);else return null;return[n,r,i,a].some(e=>Number.isNaN(e))?null:{r:n,g:r,b:i,a}}function dt(e,t,n){let r=t/100,i=n/100,a=i*r,o=a*(1-Math.abs(e/60%2-1)),s=i-a,[c,l,u]=e<60?[a,o,0]:e<120?[o,a,0]:e<180?[0,a,o]:e<240?[0,o,a]:e<300?[o,0,a]:[a,0,o];return{r:(c+s)*255,g:(l+s)*255,b:(u+s)*255}}function ft(e,t,n){let r=e/255,i=t/255,a=n/255,o=Math.max(r,i,a),s=o-Math.min(r,i,a),c=0;s!==0&&(c=o===r?60*((i-a)/s%6):o===i?60*((a-r)/s+2):60*((r-i)/s+4)),c<0&&(c+=360);let l=o===0?0:s/o;return{h:c,s:l*100,v:o*100}}function pt(e,t,n){let r=t/100,i=n/100,a=(1-Math.abs(2*i-1))*r,o=a*(1-Math.abs(e/60%2-1)),s=i-a/2,[c,l,u]=e<60?[a,o,0]:e<120?[o,a,0]:e<180?[0,a,o]:e<240?[0,o,a]:e<300?[o,0,a]:[a,0,o];return{r:(c+s)*255,g:(l+s)*255,b:(u+s)*255}}function mt(e,t,n){let r=e/255,i=t/255,a=n/255,o=Math.max(r,i,a),s=Math.min(r,i,a),c=(o+s)/2,l=o-s,u=0,d=0;return l!==0&&(d=c>.5?l/(2-o-s):l/(o+s),u=o===r?60*((i-a)/l%6):o===i?60*((a-r)/l+2):60*((r-i)/l+4)),u<0&&(u+=360),{h:u,s:d*100,l:c*100}}function ht({h:e,s:t,v:n,a:r}){let{r:i,g:a,b:o}=dt(e,t,n);return{r:i,g:a,b:o,a:r}}function gt({r:e,g:t,b:n,a:r}){let{h:i,s:a,v:o}=ft(e,t,n);return{h:i,s:a,v:o,a:r}}function _t({h:e,s:t,v:n,a:r}){let{r:i,g:a,b:o}=dt(e,t,n);return{...mt(i,a,o),a:r}}function vt({h:e,s:t,l:n,a:r}){let{r:i,g:a,b:o}=pt(e,t,n);return{...ft(i,a,o),a:r}}function yt(e){let t=e.trim();if(t.startsWith(`#`))return ut(t);let n=t.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)$/i);if(n)return{r:Number(n[1]),g:Number(n[2]),b:Number(n[3]),a:n[4]===void 0?1:Number(n[4])};let r=t.match(/^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%\s*(?:,\s*([\d.]+)\s*)?\)$/i);if(r){let{r:e,g:t,b:n}=pt(Number(r[1]),Number(r[2]),Number(r[3]));return{r:e,g:t,b:n,a:r[4]===void 0?1:Number(r[4])}}return null}var bt={formatLabel:`Color format`,hexFieldLabel:`Hex value`,redLabel:`Red`,greenLabel:`Green`,blueLabel:`Blue`,hueFieldLabel:`Hue`,saturationFieldLabel:`Saturation`,lightnessFieldLabel:`Lightness`,alphaFieldLabel:`Alpha`,eyeDropperLabel:`Pick color from screen`,savedColorsLabel:`Saved colors`,gradientAreaLabel:`Saturation and brightness`,hueSliderLabel:`Hue`},xt={openLabel:`Open color picker`};function St(e,t){let n=st(e,0,100);return`calc(${t/2}px + (100% - ${t}px) * ${n/100})`}function Ct(e){let t=ht(e),n=_t(e),r=lt(t);return{hex:r,info:{hex:r,rgb:{r:Math.round(t.r),g:Math.round(t.g),b:Math.round(t.b),a:t.a},hsl:{h:Math.round(n.h),s:Math.round(n.s),l:Math.round(n.l),a:n.a}}}}function wt({value:e,onCommit:t,min:n,max:r,label:i,disabled:a,size:o,onBlurExtra:s,fullWidth:c}){let[l,u]=(0,f.useState)(String(Math.round(e)));return(0,f.useEffect)(()=>{u(String(Math.round(e)))},[e]),(0,_.jsx)(d.TextField,{size:o,value:l,disabled:a,onChange:e=>{let i=e.target.value;u(i);let a=Number(i);i.trim()!==``&&!Number.isNaN(a)&&t(st(a,n,r))},onBlur:()=>{u(String(Math.round(e))),s?.()},slotProps:{htmlInput:{"aria-label":i,style:{textAlign:`center`}}},sx:c?{flex:1,minWidth:0}:{width:64,flexShrink:0}})}function Tt({value:e,onChange:t,onChangeCommitted:n,defaultFormat:r=`hex`,format:i,onFormatChange:a,showAlpha:o=!0,showEyeDropper:s=!0,showSliderSection:c=!0,showInputSection:l=!0,savedColors:u,disabled:p=!1,colorGradientSize:m=`medium`,inputSize:h=`medium`,width:g=280,name:v,translation:y}){let x=(0,d.useTheme)(),S={...bt,...y},[C,w]=(0,f.useState)(()=>{let t=yt(e);return t?gt(t):{h:0,s:0,v:0,a:1}}),[T,E]=(0,f.useState)(r),D=i??T,[O,k]=(0,f.useState)(e);if(O!==e){k(e);let t=yt(e);t&&w(gt(t))}let{hex:A,info:j}=Ct(C),M=A.slice(0,7),[N,P]=(0,f.useState)(M);(0,f.useEffect)(()=>{P(M)},[M]);let F=(0,f.useRef)(null),I=(0,f.useRef)(null),L=(0,f.useRef)(null),R=e=>{w(e);let n=Ct(e);k(n.hex),t(n.hex,n.info)},z=e=>{if(R(e),n){let t=Ct(e);n(t.hex,t.info)}},B=()=>{if(!n)return;let e=Ct(C);n(e.hex,e.info)},V=m===`small`?130:160,H=m===`small`?20:24,U=m===`small`?10:12,W=m===`small`?13:16,G=e=>{if(p||!F.current)return;let t=F.current.getBoundingClientRect(),n=st(e.clientX-t.left,0,t.width),r=st(e.clientY-t.top,0,t.height);R({...C,s:n/t.width*100,v:100-r/t.height*100})},K=e=>{if(p||!I.current)return;let t=I.current.getBoundingClientRect(),n=st(e.clientX-t.left,0,t.width);R({...C,h:n/t.width*360})},q=e=>{if(p||!L.current)return;let t=L.current.getBoundingClientRect(),n=st(e.clientX-t.left,0,t.width);R({...C,a:n/t.width})},J=typeof window<`u`&&!!window.EyeDropper,ee=async()=>{if(!(p||!window.EyeDropper))try{let e=ut((await new window.EyeDropper().open()).sRGBHex);e&&z(gt({...e,a:C.a}))}catch{}},te=e=>{i===void 0&&E(e),a?.(e)},Y=ht(C),X=_t(C),ne=M,re={backgroundImage:`linear-gradient(45deg, #ccc 25%, transparent 25%), linear-gradient(-45deg, #ccc 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #ccc 75%), linear-gradient(-45deg, transparent 75%, #ccc 75%)`,backgroundSize:`8px 8px`,backgroundPosition:`0 0, 0 4px, 4px -4px, -4px 0px`};return(0,_.jsxs)(d.Box,{sx:{width:g,opacity:p?.6:1,display:`flex`,flexDirection:`column`,gap:1},className:[at.root,p&&Be.disabled].filter(Boolean).join(` `),children:[(0,_.jsx)(d.Box,{ref:F,role:`slider`,tabIndex:p?-1:0,"aria-label":S.gradientAreaLabel,"aria-valuetext":`${Math.round(C.s)}, ${Math.round(C.v)}`,onPointerDown:e=>{e.currentTarget.setPointerCapture?.(e.pointerId),G(e)},onPointerMove:e=>{e.buttons===1&&G(e)},onPointerUp:B,className:at.gradientArea,sx:{position:`relative`,width:`100%`,height:V,borderRadius:`${x.shape.borderRadius}px`,border:`1px solid ${x.palette.divider}`,cursor:p?`default`:`crosshair`,touchAction:`none`,background:`linear-gradient(to top, #000, rgba(0,0,0,0)), linear-gradient(to right, #fff, hsl(${C.h}, 100%, 50%))`},children:(0,_.jsx)(d.Box,{className:at.gradientThumb,sx:{position:`absolute`,left:St(C.s,W),top:St(100-C.v,W),width:W,height:W,borderRadius:`50%`,border:`2px solid #fff`,boxShadow:`0 0 0 1px rgba(0,0,0,0.3)`,transform:`translate(-50%, -50%)`,pointerEvents:`none`,backgroundColor:ne}})}),c&&(0,_.jsxs)(d.Box,{sx:{display:`flex`,gap:1,alignItems:`center`},className:at.sliderSection,children:[s&&J&&(0,_.jsx)(d.Tooltip,{title:S.eyeDropperLabel,children:(0,_.jsx)(`span`,{children:(0,_.jsx)(d.IconButton,{size:`small`,onClick:ee,disabled:p,"aria-label":S.eyeDropperLabel,children:(0,_.jsx)(b.default,{fontSize:`small`})})})}),(0,_.jsxs)(d.Box,{sx:{flex:1,display:`flex`,flexDirection:`column`,gap:.75},children:[(0,_.jsx)(d.Box,{ref:I,role:`slider`,tabIndex:p?-1:0,"aria-label":S.hueSliderLabel,"aria-valuemin":0,"aria-valuemax":360,"aria-valuenow":Math.round(C.h),onPointerDown:e=>{e.currentTarget.setPointerCapture?.(e.pointerId),K(e)},onPointerMove:e=>{e.buttons===1&&K(e)},onPointerUp:B,className:at.hueSlider,sx:{position:`relative`,width:`100%`,height:U,borderRadius:U,cursor:p?`default`:`pointer`,touchAction:`none`,background:`linear-gradient(to right, red, yellow, lime, cyan, blue, magenta, red)`},children:(0,_.jsx)(d.Box,{sx:{position:`absolute`,left:St(C.h/360*100,W),top:`50%`,width:W,height:W,borderRadius:`50%`,border:`2px solid #fff`,boxShadow:`0 0 0 1px rgba(0,0,0,0.3)`,transform:`translate(-50%, -50%)`,pointerEvents:`none`,backgroundColor:`hsl(${C.h}, 100%, 50%)`}})}),o&&(0,_.jsxs)(d.Box,{ref:L,role:`slider`,tabIndex:p?-1:0,"aria-label":S.alphaFieldLabel,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(C.a*100),onPointerDown:e=>{e.currentTarget.setPointerCapture?.(e.pointerId),q(e)},onPointerMove:e=>{e.buttons===1&&q(e)},onPointerUp:B,className:at.alphaSlider,sx:{position:`relative`,width:`100%`,height:U,borderRadius:U,cursor:p?`default`:`pointer`,touchAction:`none`,...re},children:[(0,_.jsx)(d.Box,{sx:{position:`absolute`,inset:0,borderRadius:U,background:`linear-gradient(to right, transparent, ${ne})`}}),(0,_.jsx)(d.Box,{sx:{position:`absolute`,left:St(C.a*100,W),top:`50%`,width:W,height:W,borderRadius:`50%`,border:`2px solid #fff`,boxShadow:`0 0 0 1px rgba(0,0,0,0.3)`,transform:`translate(-50%, -50%)`,pointerEvents:`none`,backgroundColor:ne}})]})]})]}),l&&(0,_.jsxs)(d.Box,{sx:{display:`flex`,flexDirection:`column`,gap:.75},className:at.inputSection,children:[(0,_.jsxs)(d.Box,{sx:{display:`flex`,gap:.75,alignItems:`center`},children:[(0,_.jsxs)(d.Select,{size:h,value:D,"aria-label":S.formatLabel,disabled:p,onChange:e=>te(e.target.value),sx:{minWidth:80,flexShrink:0},children:[(0,_.jsx)(d.MenuItem,{value:`hex`,children:`HEX`}),(0,_.jsx)(d.MenuItem,{value:`rgb`,children:`RGB`}),(0,_.jsx)(d.MenuItem,{value:`hsl`,children:`HSL`})]}),D===`hex`&&(0,_.jsx)(d.TextField,{size:h,value:N,disabled:p,onChange:e=>{let t=e.target.value;P(t);let n=ut(t);n&&R(gt({...n,a:C.a}))},onBlur:()=>{P(M),B()},slotProps:{htmlInput:{"aria-label":S.hexFieldLabel}},sx:{flex:1,minWidth:0}}),D!==`hex`&&(0,_.jsx)(d.Box,{sx:{flex:1}}),o&&(0,_.jsx)(wt,{label:S.alphaFieldLabel,value:Math.round(C.a*100),min:0,max:100,disabled:p,size:h,onBlurExtra:B,onCommit:e=>R({...C,a:e/100})})]}),D===`rgb`&&(0,_.jsxs)(d.Box,{sx:{display:`flex`,gap:.75},children:[(0,_.jsx)(wt,{label:S.redLabel,value:Y.r,min:0,max:255,disabled:p,size:h,onBlurExtra:B,fullWidth:!0,onCommit:e=>R(gt({r:e,g:Y.g,b:Y.b,a:C.a}))}),(0,_.jsx)(wt,{label:S.greenLabel,value:Y.g,min:0,max:255,disabled:p,size:h,onBlurExtra:B,fullWidth:!0,onCommit:e=>R(gt({r:Y.r,g:e,b:Y.b,a:C.a}))}),(0,_.jsx)(wt,{label:S.blueLabel,value:Y.b,min:0,max:255,disabled:p,size:h,onBlurExtra:B,fullWidth:!0,onCommit:e=>R(gt({r:Y.r,g:Y.g,b:e,a:C.a}))})]}),D===`hsl`&&(0,_.jsxs)(d.Box,{sx:{display:`flex`,gap:.75},children:[(0,_.jsx)(wt,{label:S.hueFieldLabel,value:X.h,min:0,max:360,disabled:p,size:h,onBlurExtra:B,fullWidth:!0,onCommit:e=>R({...C,h:e})}),(0,_.jsx)(wt,{label:S.saturationFieldLabel,value:X.s,min:0,max:100,disabled:p,size:h,onBlurExtra:B,fullWidth:!0,onCommit:e=>R(vt({h:X.h,s:e,l:X.l,a:X.a}))}),(0,_.jsx)(wt,{label:S.lightnessFieldLabel,value:X.l,min:0,max:100,disabled:p,size:h,onBlurExtra:B,fullWidth:!0,onCommit:e=>R(vt({h:X.h,s:X.s,l:e,a:X.a}))})]})]}),u&&u.length>0&&(0,_.jsxs)(d.Box,{className:at.savedColors,children:[(0,_.jsx)(d.Typography,{variant:`caption`,sx:{color:`text.secondary`,display:`block`,mb:.5},children:S.savedColorsLabel}),(0,_.jsx)(d.Box,{sx:{display:`flex`,flexWrap:`wrap`,gap:.75},className:at.swatchList,children:u.map((e,t)=>(0,_.jsx)(d.Box,{component:`button`,type:`button`,disabled:p,"aria-label":e,onClick:()=>{let t=yt(e);t&&z(gt(t))},className:at.swatch,sx:{width:H,height:H,p:0,borderRadius:.5,border:`1px solid ${x.palette.divider}`,cursor:p?`default`:`pointer`,flexShrink:0,...re,backgroundSize:`6px 6px`,"&:hover":p?void 0:{borderColor:x.palette.primary.main}},children:(0,_.jsx)(d.Box,{sx:{width:`100%`,height:`100%`,borderRadius:.5,backgroundColor:e}})},`${e}-${t}`))})]}),v&&(0,_.jsx)(`input`,{type:`hidden`,name:v,value:j.hex})]})}var Et={backgroundImage:`linear-gradient(45deg, #ccc 25%, transparent 25%), linear-gradient(-45deg, #ccc 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #ccc 75%), linear-gradient(-45deg, transparent 75%, #ccc 75%)`,backgroundSize:`8px 8px`,backgroundPosition:`0 0, 0 4px, 4px -4px, -4px 0px`};function Dt({value:e,onChange:t,onChangeCommitted:n,swatchSize:r=28,swatchShape:i=`square`,disabled:a=!1,translation:o,...s}){let c=(0,d.useTheme)(),l={...xt,...o},[u,p]=(0,f.useState)(null),m=!!u,h=i===`circle`?`50%`:`${c.shape.borderRadius}px`;return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(d.Box,{component:`button`,type:`button`,disabled:a,"aria-label":l.openLabel,"aria-expanded":m,"aria-haspopup":`dialog`,onClick:e=>p(e.currentTarget),className:[ot.root,a?Be.disabled:void 0].filter(Boolean).join(` `),sx:{width:r,height:r,minWidth:r,p:0,borderRadius:h,border:`1px solid ${c.palette.divider}`,cursor:a?`default`:`pointer`,overflow:`hidden`,flexShrink:0,...Et,"&:hover:not(:disabled)":{borderColor:c.palette.primary.main},"&:focus-visible":{outline:`2px solid ${c.palette.primary.main}`,outlineOffset:2}},children:(0,_.jsx)(d.Box,{className:ot.swatch,sx:{width:`100%`,height:`100%`,borderRadius:`inherit`,backgroundColor:e}})}),(0,_.jsx)(d.Popover,{open:m,anchorEl:u,onClose:()=>p(null),anchorOrigin:{vertical:`bottom`,horizontal:`left`},transformOrigin:{vertical:`top`,horizontal:`left`},slotProps:{paper:{sx:{p:1.5},"data-testid":`popover-color-picker`}},children:(0,_.jsx)(Tt,{value:e,onChange:t,onChangeCommitted:n,disabled:a,translation:o,...s})})]})}var Ot={showFormat:!0,showCompact:!0,showCopy:!0,showDownload:!0,showClear:!0,showUndoRedo:!0},kt={format:`Format JSON`,compact:`Compact JSON`,copy:`Copy`,copySuccess:`Copied!`,download:`Download`,downloadSuccess:`Downloaded!`,clear:`Clear`,undo:`Undo`,redo:`Redo`,lineColumn:`Ln {line}, Col {col}`,validJson:`Valid JSON`,invalidJson:`Invalid JSON`},At=/^[A-Za-z_$][A-Za-z0-9_$]*$/,jt=new Set([`Object`,`Array`,`String`,`Number`,`True`,`False`,`Null`]);function Mt(e){return At.test(e)?`.${e}`:`[${JSON.stringify(e)}]`}function Nt(e,t){if(e.doc.length===0)return null;let n=(0,T.syntaxTree)(e).resolveInner(t,1);if(!n)return null;let r=[];for(;n;){let t=n.parent;if(!t)break;if(t.name===`Property`){let i=t.getChild(`PropertyName`);if(i){let t=e.sliceDoc(i.from,i.to);try{r.unshift(Mt(JSON.parse(t)))}catch{}}n=t.parent??t;continue}if(t.name===`Array`){let e=0,i=t.firstChild;for(;i&&i.from<n.from;)jt.has(i.name)&&e++,i=i.nextSibling;r.unshift(`[${e}]`),n=t;continue}n=t}return r.length>0?`$${r.join(``)}`:`$`}var Pt=new Set([`Object`,`Array`,`String`,`Number`,`True`,`False`,`Null`]),Ft=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function It(e){return Ft.test(e)?`.${e}`:`[${JSON.stringify(e)}]`}function Lt(e){return e===null?`null`:Array.isArray(e)?`array`:typeof e==`number`?Number.isInteger(e)?`integer`:`number`:typeof e==`string`?`string`:typeof e==`boolean`?`boolean`:`object`}function Rt(e,t){let n=Lt(e);return n===t||t===`number`&&n===`integer`}function zt(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,n)=>zt(e,t[n]));if(e&&t&&typeof e==`object`&&typeof t==`object`){let n=Object.keys(e),r=Object.keys(t);return n.length===r.length?n.every(n=>zt(e[n],t[n])):!1}return!1}function Bt(e,t,n=`$`){let r=[];if(t.type){let i=Array.isArray(t.type)?t.type:[t.type];if(!i.some(t=>Rt(e,t)))return r.push({path:n,message:`Expected type ${i.join(` | `)}, got ${Lt(e)}.`}),r}if(t.enum&&!t.enum.some(t=>zt(t,e))&&r.push({path:n,message:`Value must be one of: ${t.enum.map(e=>JSON.stringify(e)).join(`, `)}.`}),Lt(e)===`object`&&e!==null){let i=e;for(let e of t.required??[])e in i||r.push({path:n,message:`Missing required property "${e}".`});if(t.properties)for(let[e,a]of Object.entries(t.properties))e in i&&r.push(...Bt(i[e],a,`${n}${It(e)}`))}return t.items&&Array.isArray(e)&&e.forEach((e,i)=>{r.push(...Bt(e,t.items,`${n}[${i}]`))}),r}var Vt=/\.([A-Za-z_$][A-Za-z0-9_$]*)|\[(\d+)\]|\["((?:[^"\\]|\\.)*)"\]/g;function Ht(e){let t=[];for(let n of e.matchAll(Vt))n[1]===void 0?n[2]===void 0?n[3]!==void 0&&t.push({type:`key`,value:JSON.parse(`"${n[3]}"`)}):t.push({type:`index`,value:Number(n[2])}):t.push({type:`key`,value:n[1]});return t}function Ut(e){let t=e.topNode;for(;t&&!Pt.has(t.name);){let e=t.firstChild;if(!e)return null;t=e}return t}function Wt(e,t){let n=Ut((0,T.syntaxTree)(e));if(!n)return null;for(let r of Ht(t))if(r.type===`key`){if(n.name!==`Object`)return null;let t=null;for(let i=n.firstChild;i;i=i.nextSibling){if(i.name!==`Property`)continue;let n=i.getChild(`PropertyName`);if(n)try{if(JSON.parse(e.sliceDoc(n.from,n.to))===r.value){t=i.lastChild;break}}catch{}}if(!t)return null;n=t}else{if(n.name!==`Array`)return null;let e=0,t=null;for(let i=n.firstChild;i;i=i.nextSibling)if(Pt.has(i.name)){if(e===r.value){t=i;break}e++}if(!t)return null;n=t}return{from:n.from,to:n.to}}function Gt(e){return e?[(0,x.lineNumbers)(),(0,x.highlightActiveLineGutter)()]:[]}function Kt(e){return e?[(0,T.foldGutter)()]:[]}function qt(e){return e?[(0,x.placeholder)(e)]:[]}function Jt({value:e,onChange:t,placeholder:n,disabled:r=!1,readonly:i=!1,schema:a,showLineNumbers:o=!0,showMinimap:s=!1,showFolding:c=!0,enablePathFinder:l=!0,highlightColors:u,onViewReady:p,onCursorChange:m,onBlur:h,onFocus:g,onPathCopy:v}){let y=(0,f.useRef)(null),b=(0,f.useRef)(null),k=(0,f.useRef)(null),A=(0,f.useRef)(t),j=(0,f.useRef)(m),M=(0,f.useRef)(h),N=(0,f.useRef)(g),P=(0,f.useRef)(p),F=(0,f.useRef)(v),I=(0,f.useRef)(l),L=(0,f.useRef)(a),[R,z]=(0,f.useState)(null),B=(0,f.useRef)(new S.Compartment),V=(0,f.useRef)(new S.Compartment),H=(0,f.useRef)(new S.Compartment),U=(0,f.useRef)(new S.Compartment),W=(0,f.useRef)(new S.Compartment),G=(0,d.useTheme)(),K=G.palette.mode===`dark`,q=u?.propertyName??G.palette.primary.main,J=u?.string??G.palette.success.main,ee=u?.number??G.palette.warning.main,te=u?.boolean??G.palette.info.main,Y=u?.null??G.palette.text.secondary;return(0,f.useEffect)(()=>{A.current=t},[t]),(0,f.useEffect)(()=>{j.current=m},[m]),(0,f.useEffect)(()=>{M.current=h},[h]),(0,f.useEffect)(()=>{N.current=g},[g]),(0,f.useEffect)(()=>{P.current=p},[p]),(0,f.useEffect)(()=>{F.current=v},[v]),(0,f.useEffect)(()=>{I.current=l},[l]),(0,f.useEffect)(()=>{L.current=a,k.current&&(0,E.forceLinting)(k.current)},[a]),(0,f.useEffect)(()=>{if(!b.current)return;let t=k.current?.state.doc.toString()??e??``,a=T.HighlightStyle.define([{tag:D.tags.propertyName,color:q,fontWeight:`bold`},{tag:D.tags.string,color:J},{tag:D.tags.number,color:ee},{tag:D.tags.bool,color:te,fontWeight:`bold`},{tag:D.tags.null,color:Y,fontStyle:`italic`},{tag:D.tags.bracket,color:G.palette.text.secondary},{tag:D.tags.punctuation,color:G.palette.text.disabled},{tag:D.tags.invalid,color:G.palette.error.main,textDecoration:`underline wavy`}]),l=x.EditorView.theme({"&":{height:`100%`,fontFamily:`'Fira Code', 'JetBrains Mono', 'Consolas', monospace`,fontSize:`0.875rem`},".cm-scroller":{overflow:`auto`},".cm-content":{padding:`8px 4px`,caretColor:G.palette.text.primary},".cm-gutters":{backgroundColor:K?G.palette.grey[900]:G.palette.grey[50],color:G.palette.text.disabled,border:`none`,borderRight:`1px solid ${G.palette.divider}`},".cm-lineNumbers .cm-gutterElement":{paddingLeft:`4px`,paddingRight:`8px`},".cm-activeLineGutter":{backgroundColor:G.palette.action.selected},".cm-activeLine":{backgroundColor:G.palette.action.hover},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground":{backgroundColor:G.palette.primary.main+`40`},".cm-cursor, .cm-dropCursor":{borderLeftColor:G.palette.text.primary},"&.cm-focused":{outline:`none`},".cm-placeholder":{color:G.palette.text.disabled,fontStyle:`italic`},".cm-gutter-lint":{width:`16px`},".cm-lint-marker-error":{color:G.palette.error.main},".cm-lint-marker-warning":{color:G.palette.warning.main},".cm-foldGutter .cm-gutterElement":{cursor:`pointer`,color:G.palette.text.disabled},".cm-foldPlaceholder":{backgroundColor:G.palette.action.selected,border:`1px solid ${G.palette.divider}`,borderRadius:`3px`,color:G.palette.text.secondary,padding:`0 4px`},".cm-tooltip.cm-tooltip-lint":{backgroundColor:G.palette.background.paper,border:`1px solid ${G.palette.divider}`,borderRadius:`4px`},".cm-diagnostic-error":{borderLeft:`3px solid ${G.palette.error.main}`},".cm-diagnostic-warning":{borderLeft:`3px solid ${G.palette.warning.main}`}},{dark:K}),u=s?[O.showMinimap.of({create:()=>{let e=document.createElement(`div`);return e.style.width=`80px`,e.style.overflow=`hidden`,e.style.borderLeft=`1px solid ${G.palette.divider}`,e.style.backgroundColor=K?G.palette.grey[900]:G.palette.grey[50],{dom:e}},displayText:`blocks`,showOverlay:`always`})]:[],d=[l,(0,T.syntaxHighlighting)(a),(0,C.json)(),(0,E.lintGutter)(),(0,E.linter)((0,C.jsonParseLinter)()),(0,E.linter)(e=>{let t=L.current;if(!t)return[];let n;try{n=JSON.parse(e.state.doc.toString())}catch{return[]}let r=[];for(let i of Bt(n,t)){let t=Wt(e.state,i.path);t&&r.push({from:t.from,to:t.to,severity:`error`,message:i.message})}return r}),(0,w.history)(),x.keymap.of([...w.defaultKeymap,...w.historyKeymap,...T.foldKeymap]),B.current.of(x.EditorView.editable.of(!r&&!i)),V.current.of(S.EditorState.readOnly.of(i)),(0,x.highlightActiveLine)(),U.current.of(Gt(o)),H.current.of(Kt(c)),W.current.of(qt(n)),...u,x.EditorView.updateListener.of(e=>{e.docChanged&&A.current?.(e.state.doc.toString());let t=e.state.selection.main.head,n=e.state.doc.lineAt(t);j.current(n.number,t-n.from+1)}),x.EditorView.domEventHandlers({blur:()=>{M.current?.()},focus:()=>{N.current?.()},click:(e,t)=>{if(!I.current||!(e.ctrlKey||e.metaKey))return!1;let n;try{n=t.posAtCoords({x:e.clientX,y:e.clientY})}catch{return!1}if(n===null)return!1;let r=Nt(t.state,n);return r?(navigator.clipboard.writeText(r).then(()=>{let t=y.current?.getBoundingClientRect();z({x:e.clientX-(t?.left??0),y:e.clientY-(t?.top??0),path:r}),F.current?.(r)}),!0):!1}})],f=new x.EditorView({state:S.EditorState.create({doc:t,extensions:d}),parent:b.current});return k.current=f,P.current(f),()=>{P.current(null),f.destroy(),k.current=null}},[K,q,J,ee,te,Y,s]),(0,f.useEffect)(()=>{let t=k.current;if(!t)return;let n=t.state.doc.toString();n!==(e??``)&&t.dispatch({changes:{from:0,to:n.length,insert:e??``}})},[e]),(0,f.useEffect)(()=>{k.current?.dispatch({effects:[B.current.reconfigure(x.EditorView.editable.of(!r&&!i)),V.current.reconfigure(S.EditorState.readOnly.of(i))]})},[r,i]),(0,f.useEffect)(()=>{k.current?.dispatch({effects:U.current.reconfigure(Gt(o))})},[o]),(0,f.useEffect)(()=>{k.current?.dispatch({effects:H.current.reconfigure(Kt(c))})},[c]),(0,f.useEffect)(()=>{k.current?.dispatch({effects:W.current.reconfigure(qt(n))})},[n]),(0,f.useEffect)(()=>{if(!R)return;let e=setTimeout(()=>z(null),1500);return()=>clearTimeout(e)},[R]),(0,_.jsxs)(d.Box,{ref:y,sx:{position:`relative`,flex:1,overflow:`hidden`,display:`flex`},children:[(0,_.jsx)(d.Box,{ref:b,sx:{flex:1,overflow:`hidden`,display:`flex`,flexDirection:`column`,opacity:r?.5:1,backgroundColor:G.palette.background.paper,"& .cm-editor":{flex:1,display:`flex`,flexDirection:`column`}}}),R&&(0,_.jsx)(d.Fade,{in:!0,children:(0,_.jsx)(d.Paper,{elevation:3,sx:{position:`absolute`,left:R.x,top:R.y,transform:`translate(-50%, -130%)`,px:1,py:.5,pointerEvents:`none`,zIndex:10,bgcolor:`grey.900`,color:`common.white`},children:(0,_.jsxs)(d.Typography,{variant:`caption`,sx:{fontFamily:`monospace`},children:[`Copied: `,R.path]})})})]})}function Q({label:e,icon:t,onClick:n,active:r,disabled:i}){return(0,_.jsx)(d.Tooltip,{title:e,arrow:!0,children:(0,_.jsx)(`span`,{children:(0,_.jsx)(d.IconButton,{size:`small`,onMouseDown:e=>e.preventDefault(),onClick:n,disabled:i,color:r?`primary`:`default`,sx:{borderRadius:1},"aria-label":e,"aria-pressed":r,children:t})})})}function Yt(e=2e3){let[t,n]=(0,f.useState)(!1),r=(0,f.useRef)(null),i=(0,f.useCallback)(()=>{r.current&&clearTimeout(r.current),n(!0),r.current=setTimeout(()=>{n(!1),r.current=null},e)},[e]);return(0,f.useEffect)(()=>()=>{r.current&&clearTimeout(r.current)},[]),[t,i]}function Xt({editorView:e,toolbarConfig:t,translation:n,indent:r,downloadFilename:i,disabled:a}){let[o,s]=Yt(),[c,l]=Yt(),u=a||!e;function f(){let t=e;if(!t)return;let n=t.state.doc.toString();try{let e=JSON.stringify(JSON.parse(n),null,r);t.dispatch({changes:{from:0,to:t.state.doc.length,insert:e}})}catch{}t.focus()}function p(){let t=e;if(!t)return;let n=t.state.doc.toString();try{let e=JSON.stringify(JSON.parse(n));t.dispatch({changes:{from:0,to:t.state.doc.length,insert:e}})}catch{}t.focus()}function m(){let t=e?.state.doc.toString()??``;navigator.clipboard.writeText(t).then(()=>{s()})}function h(){let t=e?.state.doc.toString()??``,n=new Blob([t],{type:`application/json`}),r=URL.createObjectURL(n),a=document.createElement(`a`);a.href=r,a.download=i,a.click(),URL.revokeObjectURL(r),l()}function g(){let t=e;t&&(t.dispatch({changes:{from:0,to:t.state.doc.length,insert:``}}),t.focus())}function y(){let t=e;t&&((0,w.undo)(t),t.focus())}function b(){let t=e;t&&((0,w.redo)(t),t.focus())}let x=t.showFormat||t.showCompact,S=t.showCopy||t.showDownload||t.showClear,C=t.showUndoRedo;return(0,_.jsxs)(d.Box,{sx:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:.25,px:1,py:.5},role:`toolbar`,"aria-label":`JSON editor actions`,children:[x&&(0,_.jsxs)(d.Box,{sx:{display:`flex`,gap:.25},children:[t.showFormat&&(0,_.jsx)(Q,{label:n.format,icon:(0,_.jsx)(P.default,{fontSize:`small`}),onClick:f,disabled:u}),t.showCompact&&(0,_.jsx)(Q,{label:n.compact,icon:(0,_.jsx)(F.default,{fontSize:`small`}),onClick:p,disabled:u})]}),x&&(S||C)&&(0,_.jsx)(d.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),S&&(0,_.jsxs)(d.Box,{sx:{display:`flex`,gap:.25},children:[t.showCopy&&(0,_.jsx)(Q,{label:o?n.copySuccess:n.copy,icon:o?(0,_.jsx)(j.default,{fontSize:`small`,color:`success`}):(0,_.jsx)(k.default,{fontSize:`small`}),onClick:m,disabled:u}),t.showDownload&&(0,_.jsx)(Q,{label:c?n.downloadSuccess:n.download,icon:c?(0,_.jsx)(j.default,{fontSize:`small`,color:`success`}):(0,_.jsx)(A.default,{fontSize:`small`}),onClick:h,disabled:u}),t.showClear&&(0,_.jsx)(Q,{label:n.clear,icon:(0,_.jsx)(v.default,{fontSize:`small`}),onClick:g,disabled:u})]}),S&&C&&(0,_.jsx)(d.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),C&&(0,_.jsxs)(d.Box,{sx:{display:`flex`,gap:.25},children:[(0,_.jsx)(Q,{label:n.undo,icon:(0,_.jsx)(M.default,{fontSize:`small`}),onClick:y,disabled:u}),(0,_.jsx)(Q,{label:n.redo,icon:(0,_.jsx)(N.default,{fontSize:`small`}),onClick:b,disabled:u})]}),!x&&!S&&!C&&(0,_.jsx)(d.Box,{sx:{height:32}})]})}function Zt({helperText:e,error:t,showLineColumn:n,showValidation:r,isValid:i,cursorLine:a,cursorCol:o,translation:s}){let c=s.lineColumn.replace(`{line}`,String(a)).replace(`{col}`,String(o));return(0,_.jsxs)(d.Box,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,mt:.5,px:.5},children:[(0,_.jsxs)(d.Box,{children:[r&&(0,_.jsxs)(d.Box,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[i?(0,_.jsx)(I.default,{sx:{fontSize:`0.875rem`,color:`success.main`},"data-testid":`json-valid-icon`}):(0,_.jsx)(L.default,{sx:{fontSize:`0.875rem`,color:`error.main`},"data-testid":`json-invalid-icon`}),(0,_.jsx)(d.FormHelperText,{sx:{color:i?`success.main`:`error.main`,m:0},children:i?s.validJson:s.invalidJson})]}),(0,_.jsx)(d.FormHelperText,{error:t,children:e??``})]}),n&&(0,_.jsx)(d.FormHelperText,{sx:{color:`text.disabled`,fontFamily:`monospace`,whiteSpace:`nowrap`},children:c})]})}function Qt(e){if(!(e===``||e===void 0))return typeof e==`string`&&e!==`auto`&&!isNaN(Number(e))?Number(e):e}function $t(e){if(!e.trim())return!1;try{return JSON.parse(e),!0}catch{return!1}}function en({value:e,onChange:t,onValidChange:n,placeholder:r,height:i,width:a,disabled:o=!1,readonly:s=!1,error:c=!1,helperText:l,name:u,indent:p=2,schema:m,showLineNumbers:h=!0,showLineColumn:g=!0,showMinimap:v=!1,showFolding:y=!0,showValidation:b=!1,enablePathFinder:x=!0,downloadFilename:S=`file.json`,toolbarConfig:C,translation:w,highlightColors:T,onBlur:E,onFocus:D,onPathCopy:O}){let k={...kt,...w},A={...Ot,...C},j=Qt(i),M=Qt(a),N=j===`auto`,P=N?void 0:j??300,F=(0,f.useRef)(null),[I,L]=(0,f.useState)(null),[R,z]=(0,f.useState)({line:1,col:1}),[B,V]=(0,f.useState)(()=>$t(e??``)),H=(0,f.useCallback)(e=>{F.current=e,L(e)},[]),U=(0,f.useCallback)((e,t)=>{z({line:e,col:t})},[]),W=(0,f.useCallback)(e=>{let r=$t(e);V(r),n?.(r),t?.(e)},[t,n]),G=g||b||!!l;return(0,_.jsxs)(d.Box,{sx:{width:M??`100%`,...N?{display:`flex`,flexDirection:`column`,flex:1}:{}},children:[(0,_.jsxs)(d.Paper,{variant:`outlined`,sx:{display:`flex`,flexDirection:`column`,overflow:`hidden`,...N?{flex:1}:{height:P},borderColor:c?`error.main`:void 0,"&:focus-within":{borderColor:c?`error.main`:`primary.main`,borderWidth:2}},children:[!s&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(Xt,{editorView:I,toolbarConfig:A,translation:k,indent:p,downloadFilename:S,disabled:o}),(0,_.jsx)(d.Divider,{})]}),(0,_.jsx)(Jt,{value:e,onChange:W,placeholder:r,disabled:o,readonly:s,schema:m,showLineNumbers:h,showMinimap:v,showFolding:y,enablePathFinder:x,highlightColors:T,onViewReady:H,onCursorChange:U,onBlur:E,onFocus:D,onPathCopy:O})]}),G&&(0,_.jsx)(Zt,{helperText:l,error:c,showLineColumn:g,showValidation:b,isValid:B,cursorLine:R.line,cursorCol:R.col,translation:k}),u&&(0,_.jsx)(`input`,{type:`hidden`,name:u,value:e??``})]})}function tn(e){let t=new Date,n=xn(t),r=Sn(t);if(e.length===0)return{start:n,end:r};let i=e.map(e=>e.startDate.getTime()),a=e.map(e=>e.endDate.getTime()),o=ln(dn(new Date(Math.min(...i)),-1)),s=un(dn(new Date(Math.max(...a)),1));return{start:o<n?o:n,end:s>r?s:r}}function nn(e,t){return t===`weeks`?{start:_n(e.start),end:e.end}:t===`quarters`?{start:xn(e.start),end:Sn(e.end)}:e}function rn(e,t){let n=t.end.getTime()-t.start.getTime();if(n<=0)return{left:0,width:0};let r=(e.startDate.getTime()-t.start.getTime())/n*100,i=(e.endDate.getTime()-e.startDate.getTime())/n*100;return{left:Math.max(0,r),width:Math.max(0,i)}}function an(e){let t=new Map;for(let n of e)t.set(n.id,{...n,children:[],depth:0});let n=[];for(let e of t.values())e.parentId&&t.has(e.parentId)?t.get(e.parentId).children.push(e):n.push(e);return on(n,0),n}function on(e,t){for(let n of e)n.depth=t,on(n.children,t+1)}function sn(e,t){let n=[];function r(e){for(let i of e)n.push(i),i.children.length>0&&t.has(i.id)&&r(i.children)}return r(e),n}function cn(e,t){function n(e){return e.assignee===t?!0:e.children.some(n)}return e.filter(n)}function ln(e){return new Date(e.getFullYear(),e.getMonth(),1,0,0,0,0)}function un(e){return new Date(e.getFullYear(),e.getMonth()+1,0,23,59,59,999)}function dn(e,t){return new Date(e.getFullYear(),e.getMonth()+t,e.getDate())}function fn(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+t,0,0,0,0)}function pn(e){let t=new Map;for(let n of e)for(let e of n.dependencies??[])t.has(e)||t.set(e,[]),t.get(e).push(n.id);return t}function mn(e,t,n){if(n===0)return e;let r=pn(e),i=new Map(e.map(e=>[e.id,e])),a=[...r.get(t)??[]],o=new Set;for(;a.length>0;){let e=a.shift();if(o.has(e))continue;o.add(e);let t=i.get(e);i.set(e,{...t,startDate:new Date(t.startDate.getTime()+n),endDate:new Date(t.endDate.getTime()+n)}),a.push(...r.get(e)??[])}return e.map(e=>i.get(e.id))}function hn(e,t){let n=pn(e),r=new Set,i=[...n.get(t)??[]];for(;i.length>0;){let e=i.shift();r.has(e)||(r.add(e),i.push(...n.get(e)??[]))}return r}function gn(e){let t=[],n=ln(e.start);for(;n<=e.end;)t.push(n),n=dn(n,1);return t}function _n(e){let t=new Date(e),n=t.getDay(),r=n===0?-6:1-n;return t.setDate(t.getDate()+r),t.setHours(0,0,0,0),t}function vn(e){let t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())),n=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-n);let r=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-r.getTime())/864e5+1)/7)}function yn(e){let t=[],n=_n(e.start);for(;n<=e.end;)t.push(new Date(n)),n=new Date(n.getFullYear(),n.getMonth(),n.getDate()+7);return t}function bn(e){let t=[],n=new Date(e.start.getFullYear(),e.start.getMonth(),e.start.getDate(),0,0,0,0),r=new Date(e.end.getFullYear(),e.end.getMonth(),e.end.getDate(),0,0,0,0).getTime();for(;n.getTime()<=r;)t.push(new Date(n)),n=new Date(n.getFullYear(),n.getMonth(),n.getDate()+1,0,0,0,0);return t}function xn(e){let t=Math.floor(e.getMonth()/3)*3;return new Date(e.getFullYear(),t,1,0,0,0,0)}function Sn(e){let t=Math.floor(e.getMonth()/3)*3+2;return un(new Date(e.getFullYear(),t,1))}function Cn(e){let t=[],n=xn(e.start);for(;n<=e.end;){let e=Math.floor(n.getMonth()/3)+1;t.push({key:`${n.getFullYear()}-Q${e}`,label:`Q${e} ${n.getFullYear()}`,start:new Date(n)}),n=new Date(n.getFullYear(),n.getMonth()+3,1)}return t}function wn(e){if(e.length===0)return new Set;let t=new Map;for(let n of e)for(let e of n.dependencies??[])t.has(e)||t.set(e,[]),t.get(e).push(n.id);let n=new Map(e.map(e=>[e.id,e])),r=new Map,i=new Set;function a(e){if(r.has(e))return r.get(e);if(i.has(e))return n.get(e)?.endDate.getTime()??0;i.add(e);let o=n.get(e)?.endDate.getTime()??0;for(let n of t.get(e)??[])o=Math.max(o,a(n));return i.delete(e),r.set(e,o),o}for(let t of e)a(t.id);let o=Math.max(...r.values()),s=new Set;for(let t of e)a(t.id)===o&&s.add(t.id);return s}function Tn(e,t){let n=t.startDate<e.start?ln(dn(t.startDate,-1)):e.start,r=t.endDate>e.end?un(dn(t.endDate,1)):e.end;return n===e.start&&r===e.end?e:{start:n,end:r}}function En(e,t=`months`,n=!1,r,i=!1){let a=tn(e);return(0,z.createStore)((o,s)=>({tasks:e,taskTree:an(e),expandedIds:n?new Set(e.map(e=>e.id)):new Set(e.filter(e=>!e.parentId).map(e=>e.id)),timeScale:t,timelineRange:r??a,isRangeCustomized:r!==void 0,cascadeDependencies:i,defaultTimeScale:t,initialExpandAll:n,isExpandedCustomized:!1,assigneeFilter:``,setAssigneeFilter:e=>o({assigneeFilter:e}),setTasks:e=>{o(t=>({tasks:e,taskTree:an(e),...t.isRangeCustomized?{}:{timelineRange:tn(e)}}))},addTask:e=>{o(t=>{let n=[...t.tasks,e];return{tasks:n,taskTree:an(n),timelineRange:Tn(t.timelineRange,e)}})},updateTask:e=>{o(t=>{let n=t.tasks.find(t=>t.id===e.id),r=t.tasks.map(t=>t.id===e.id?e:t);if(t.cascadeDependencies&&n){let t=e.endDate.getTime()-n.endDate.getTime();r=mn(r,e.id,t)}let i=Tn(t.timelineRange,e);for(let e of r)i=Tn(i,e);return{tasks:r,taskTree:an(r),timelineRange:i}})},deleteTask:e=>{o(t=>{let n=new Set,r=e=>{n.add(e),t.tasks.filter(t=>t.parentId===e).forEach(e=>r(e.id))};r(e);let i=t.tasks.filter(e=>!n.has(e.id));return{tasks:i,taskTree:an(i)}})},toggleExpand:e=>{o(t=>{let n=new Set(t.expandedIds);return n.has(e)?n.delete(e):n.add(e),{expandedIds:n}})},expandAll:()=>{o(e=>({expandedIds:new Set(e.tasks.map(e=>e.id)),isExpandedCustomized:!0}))},collapseAll:()=>{o({expandedIds:new Set,isExpandedCustomized:!0})},setTimeScale:e=>{o({timeScale:e})},setTimelineRange:e=>{o({timelineRange:e,isRangeCustomized:!0})},resetTimelineRange:()=>{o(e=>({timelineRange:tn(e.tasks),isRangeCustomized:!1}))},resetView:()=>{o(e=>({timeScale:e.defaultTimeScale,timelineRange:tn(e.tasks),isRangeCustomized:!1,isExpandedCustomized:!1,assigneeFilter:``,expandedIds:e.initialExpandAll?new Set(e.tasks.map(e=>e.id)):new Set(e.tasks.filter(e=>!e.parentId).map(e=>e.id))}))},getVisibleTasks:()=>{let{taskTree:e,expandedIds:t}=s();return sn(e,t)}}))}var Dn={scaleDays:`Tage`,scaleWeeks:`Wochen`,scaleMonths:`Monate`,scaleQuarters:`Quartale`,rangeFrom:`Von`,rangeTo:`Bis`,rangeResetTooltip:`Bereich zurücksetzen`,columnName:`Name`,columnStatus:`Status`,statusPlanned:`Planned`,statusInProgress:`In Progress`,statusDone:`Done`,statusBlocked:`Blocked`,weekColumnPrefix:`KW`,todayLabel:`Heute`,dateLocale:`de-DE`,dialogAddTitle:`Aufgabe hinzufügen`,dialogEditTitle:`Aufgabe bearbeiten`,dialogDeleteTitle:`Aufgabe löschen`,dialogSave:`Speichern`,dialogCancel:`Abbrechen`,dialogDelete:`Löschen`,dialogFieldName:`Name`,dialogFieldStartDate:`Startdatum`,dialogFieldEndDate:`Enddatum`,dialogFieldStatus:`Status`,dialogFieldMilestone:`Ist Meilenstein`,dialogFieldParent:`Übergeordnete Aufgabe`,dialogFieldParentNone:`— Keine —`,dialogDeleteConfirm:`Soll die Aufgabe "{name}" wirklich gelöscht werden?`,dialogFieldDependencies:`Vorgänger`,dialogFieldDependenciesNone:`— Keine —`,dialogFieldProgress:`Fortschritt (%)`,filterAssigneeAll:`Alle`,filterAssigneeLabel:`Assignee`,scrollToTodayTooltip:`Zum heutigen Tag`,expandAllTooltip:`Alle aufklappen`,collapseAllTooltip:`Alle zuklappen`,resetViewTooltip:`Ansicht zurücksetzen`,columnActions:`Aktionen`,columnAssignee:`Assignee`,exportCsvTooltip:`Als CSV exportieren`,addTaskTooltip:`Aufgabe hinzufügen`,editTaskTooltip:`Aufgabe bearbeiten`,deleteTaskTooltip:`Aufgabe löschen`},On={planned:`warning.light`,"in-progress":`info.main`,done:`success.main`,blocked:`error.main`},kn={planned:`warning`,"in-progress":`info`,done:`success`,blocked:`error`};function An(e){return e.toISOString().slice(0,10)}function jn(e,t,n){return e<t?t:e>n?n:e}function Mn(e){return e.flatMap(e=>[e,...Mn(e.children)])}function Nn({label:e}){let t=(0,f.useRef)(null),[n,r]=(0,f.useState)(!1);return(0,_.jsx)(d.Tooltip,{title:e,disableHoverListener:!n,children:(0,_.jsx)(d.Typography,{ref:t,component:`span`,variant:`body2`,noWrap:!0,sx:{display:`block`,overflow:`hidden`,textOverflow:`ellipsis`,minWidth:0},onMouseEnter:()=>{t.current&&r(t.current.scrollWidth>t.current.clientWidth)},children:e})})}function Pn({open:e,mode:t,initialTask:n,defaultParentId:r,onSave:i,onClose:a}){let o=ir(),s=$(e=>e.taskTree),c=$(e=>e.timelineRange),l=(0,f.useMemo)(()=>Mn(s),[s]),u=(0,f.useMemo)(()=>{if(t===`add`||!n)return new Set;let e=t=>[t.id,...t.children.flatMap(e)],r=l.find(e=>e.id===n.id);return new Set(r?e(r):[n.id])},[t,n,l]),p=l.filter(e=>!u.has(e.id)),m=(0,f.useMemo)(()=>t===`add`||!n?new Set:hn(l,n.id),[t,n,l]),h=p.filter(e=>!m.has(e.id)),g=An(jn(new Date,c.start,c.end)),[v,y]=(0,f.useState)({name:``,startDate:g,endDate:g,status:`planned`,isMilestone:!1,progress:0,parentId:``,dependencies:[],assignee:``});(0,f.useEffect)(()=>{if(!e)return;let i=An(jn(new Date,c.start,c.end));y(t===`edit`&&n?{name:n.name,startDate:An(n.startDate),endDate:An(n.endDate),status:n.status,isMilestone:n.isMilestone??!1,progress:n.progress??0,parentId:n.parentId??``,dependencies:n.dependencies??[],assignee:n.assignee??``}:{name:``,startDate:i,endDate:i,status:`planned`,isMilestone:!1,progress:0,parentId:r??``,dependencies:[],assignee:``})},[e,t,n,r,c]);let b=e=>{y(t=>({...t,startDate:e,endDate:t.isMilestone||t.endDate<e?e:t.endDate}))},x=e=>{y(t=>({...t,endDate:e<t.startDate?t.startDate:e}))},S=e=>{y(t=>({...t,isMilestone:e,endDate:e?t.startDate:t.endDate,progress:e?0:t.progress}))},C=v.name.trim()!==``&&v.startDate!==``&&v.endDate!==``&&v.endDate>=v.startDate,w=()=>{C&&i({name:v.name.trim(),startDate:new Date(v.startDate),endDate:new Date(v.endDate),status:v.status,isMilestone:v.isMilestone||void 0,progress:v.progress>0?v.progress:void 0,parentId:v.parentId||void 0,dependencies:v.dependencies.length>0?v.dependencies:void 0,assignee:v.assignee.trim()||void 0})},T=[`planned`,`in-progress`,`done`,`blocked`],E={planned:o.statusPlanned,"in-progress":o.statusInProgress,done:o.statusDone,blocked:o.statusBlocked};return(0,_.jsxs)(d.Dialog,{open:e,onClose:a,maxWidth:`xs`,fullWidth:!0,"data-testid":`gantt-task-dialog`,children:[(0,_.jsx)(d.DialogTitle,{children:t===`add`?o.dialogAddTitle:o.dialogEditTitle}),(0,_.jsxs)(d.DialogContent,{sx:{display:`flex`,flexDirection:`column`,gap:2,pt:`16px !important`},children:[(0,_.jsx)(d.TextField,{label:o.dialogFieldName,value:v.name,onChange:e=>y(t=>({...t,name:e.target.value})),required:!0,fullWidth:!0,size:`small`,autoFocus:!0,slotProps:{htmlInput:{"data-testid":`gantt-dialog-field-name`}}}),(0,_.jsx)(d.TextField,{label:o.columnAssignee,value:v.assignee,onChange:e=>y(t=>({...t,assignee:e.target.value})),fullWidth:!0,size:`small`,placeholder:`e.g. Jane Smith`,slotProps:{htmlInput:{"data-testid":`gantt-dialog-field-assignee`}}}),(0,_.jsx)(d.TextField,{label:o.dialogFieldStartDate,type:`date`,value:v.startDate,onChange:e=>b(e.target.value),required:!0,fullWidth:!0,size:`small`,slotProps:{inputLabel:{shrink:!0},htmlInput:{"data-testid":`gantt-dialog-field-start`}}}),(0,_.jsx)(d.TextField,{label:o.dialogFieldEndDate,type:`date`,value:v.endDate,onChange:e=>x(e.target.value),required:!0,fullWidth:!0,size:`small`,disabled:v.isMilestone,slotProps:{inputLabel:{shrink:!0},htmlInput:{"data-testid":`gantt-dialog-field-end`,min:v.startDate}}}),(0,_.jsxs)(d.FormControl,{size:`small`,fullWidth:!0,children:[(0,_.jsx)(d.InputLabel,{children:o.dialogFieldStatus}),(0,_.jsx)(d.Select,{value:v.status,label:o.dialogFieldStatus,onChange:e=>y(t=>({...t,status:e.target.value})),inputProps:{"data-testid":`gantt-dialog-field-status`},children:T.map(e=>(0,_.jsx)(d.MenuItem,{value:e,children:E[e]},e))})]}),(0,_.jsxs)(d.Box,{"data-testid":`gantt-dialog-field-progress-wrapper`,children:[(0,_.jsxs)(d.Box,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`baseline`,mb:.25},children:[(0,_.jsx)(d.Typography,{variant:`caption`,color:v.isMilestone?`text.disabled`:`text.secondary`,children:o.dialogFieldProgress??`Fortschritt (%)`}),(0,_.jsxs)(d.Typography,{variant:`caption`,sx:{fontWeight:600},color:v.isMilestone?`text.disabled`:`text.primary`,children:[v.progress,` %`]})]}),(0,_.jsx)(d.Slider,{value:v.progress,onChange:(e,t)=>y(e=>({...e,progress:t})),min:0,max:100,step:1,disabled:v.isMilestone,size:`small`,marks:[{value:0},{value:25},{value:50},{value:75},{value:100}],"aria-label":o.dialogFieldProgress??`Fortschritt (%)`,"data-testid":`gantt-dialog-field-progress`})]}),(0,_.jsx)(d.FormControlLabel,{control:(0,_.jsx)(d.Checkbox,{checked:v.isMilestone,onChange:e=>S(e.target.checked),size:`small`,"data-testid":`gantt-dialog-field-milestone`}),label:o.dialogFieldMilestone}),(0,_.jsxs)(d.FormControl,{size:`small`,fullWidth:!0,children:[(0,_.jsx)(d.InputLabel,{children:o.dialogFieldParent}),(0,_.jsxs)(d.Select,{value:v.parentId,label:o.dialogFieldParent,onChange:e=>y(t=>({...t,parentId:e.target.value})),inputProps:{"data-testid":`gantt-dialog-field-parent`},MenuProps:{slotProps:{paper:{sx:{maxHeight:280}}}},children:[(0,_.jsx)(d.MenuItem,{value:``,children:o.dialogFieldParentNone}),p.map(e=>(0,_.jsx)(d.MenuItem,{value:e.id,sx:{minWidth:0},children:(0,_.jsxs)(d.Box,{sx:{display:`flex`,alignItems:`center`,pl:e.depth*2,gap:.75,minWidth:0,width:`100%`,overflow:`hidden`},children:[e.depth>0&&(0,_.jsx)(d.Typography,{component:`span`,variant:`caption`,sx:{color:`text.disabled`,lineHeight:1,flexShrink:0},children:`└`}),(0,_.jsx)(Nn,{label:e.name})]})},e.id))]})]}),(0,_.jsxs)(d.FormControl,{size:`small`,fullWidth:!0,children:[(0,_.jsx)(d.InputLabel,{children:o.dialogFieldDependencies}),(0,_.jsx)(d.Select,{multiple:!0,value:v.dependencies,label:o.dialogFieldDependencies,onChange:e=>{let t=e.target.value;y(e=>({...e,dependencies:typeof t==`string`?t.split(`,`):t}))},inputProps:{"data-testid":`gantt-dialog-field-dependencies`},renderValue:e=>e.length===0?o.dialogFieldDependenciesNone:e.map(e=>l.find(t=>t.id===e)?.name??e).join(`, `),MenuProps:{slotProps:{paper:{sx:{maxHeight:280}}}},children:h.map(e=>(0,_.jsx)(d.MenuItem,{value:e.id,sx:{minWidth:0},children:(0,_.jsxs)(d.Box,{sx:{display:`flex`,alignItems:`center`,pl:e.depth*2,gap:.75,minWidth:0,width:`100%`,overflow:`hidden`},children:[e.depth>0&&(0,_.jsx)(d.Typography,{component:`span`,variant:`caption`,sx:{color:`text.disabled`,lineHeight:1,flexShrink:0},children:`└`}),(0,_.jsx)(Nn,{label:e.name})]})},e.id))})]})]}),(0,_.jsxs)(d.DialogActions,{children:[(0,_.jsx)(d.Button,{onClick:a,children:o.dialogCancel}),(0,_.jsx)(d.Button,{onClick:w,variant:`contained`,disabled:!C,"data-testid":`gantt-dialog-save`,children:o.dialogSave})]})]})}function Fn({open:e,task:t,onConfirm:n,onClose:r}){let i=ir(),a=i.dialogDeleteConfirm.replace(`{name}`,t?.name??``);return(0,_.jsxs)(d.Dialog,{open:e,onClose:r,maxWidth:`xs`,fullWidth:!0,"data-testid":`gantt-delete-dialog`,children:[(0,_.jsx)(d.DialogTitle,{children:i.dialogDeleteTitle}),(0,_.jsx)(d.DialogContent,{children:(0,_.jsx)(d.DialogContentText,{children:a})}),(0,_.jsxs)(d.DialogActions,{children:[(0,_.jsx)(d.Button,{onClick:r,children:i.dialogCancel}),(0,_.jsx)(d.Button,{onClick:n,variant:`contained`,color:`error`,"data-testid":`gantt-dialog-delete-confirm`,children:i.dialogDelete})]})]})}function In(e,t){return{planned:t.statusPlanned,"in-progress":t.statusInProgress,done:t.statusDone,blocked:t.statusBlocked}[e]}function Ln({task:e,expandedIds:t,toggleExpand:n,hasActionsColumn:r,showAssigneeColumn:i,onTaskClick:a,onAddTask:o,onEditTask:s,onDeleteTask:c,onStatusChange:l,inlineEdit:u,onInlineRename:p,isSelected:m,onSelect:h}){let[g,b]=(0,f.useState)(null),[x,S]=(0,f.useState)(null),C=ir(),{statusColors:w}=or(),T=()=>{x!==null&&x.trim()&&p?.(e,x.trim()),S(null)};return(0,_.jsxs)(d.Box,{className:`gantt-task-row`,"data-testid":`gantt-task-row-${e.id}`,"aria-selected":m??!1,sx:{height:40,display:`flex`,alignItems:`center`,overflow:`hidden`,borderBottom:`1px solid`,borderRight:`1px solid`,borderColor:`divider`,cursor:a?`pointer`:`default`,bgcolor:m?`action.selected`:void 0,boxShadow:m?e=>`inset 3px 0 0 ${e.palette.primary.main}`:void 0,"&:hover":{bgcolor:m?`action.selected`:a?`action.hover`:void 0}},onClick:()=>{h?.(),a?.(e)},children:[(0,_.jsxs)(d.Box,{sx:{flex:1,minWidth:0,display:`flex`,alignItems:`center`,gap:.75,pl:1+e.depth*2,pr:.5,height:`100%`},children:[(0,_.jsx)(d.Box,{sx:{width:16,flexShrink:0,display:`flex`,justifyContent:`center`},children:e.children.length>0&&(0,_.jsx)(d.Box,{component:`span`,sx:{fontSize:9,userSelect:`none`,cursor:`pointer`},onClick:t=>{t.stopPropagation(),n(e.id)},children:t.has(e.id)?`▼`:`▶`})}),(0,_.jsx)(d.Box,{sx:{width:8,height:8,borderRadius:e.isMilestone?0:`50%`,transform:e.isMilestone?`rotate(45deg)`:void 0,flexShrink:0,bgcolor:e.color??w?.[e.status]??On[e.status]??`grey.400`}}),x===null?(0,_.jsx)(d.Typography,{variant:`body2`,noWrap:!0,sx:{flex:1,minWidth:0,cursor:u?`text`:`inherit`},onDoubleClick:u?t=>{t.stopPropagation(),S(e.name)}:void 0,children:e.name}):(0,_.jsx)(d.TextField,{size:`small`,variant:`standard`,value:x,autoFocus:!0,onChange:e=>S(e.target.value),onBlur:T,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),T()),e.key===`Escape`&&(e.stopPropagation(),S(null))},onClick:e=>e.stopPropagation(),sx:{flex:1,minWidth:0},slotProps:{htmlInput:{"data-testid":`gantt-inline-edit-${e.id}`}}})]}),i&&(0,_.jsx)(d.Box,{sx:{width:110,flexShrink:0,display:`flex`,alignItems:`center`,px:1,overflow:`hidden`},children:(0,_.jsx)(d.Typography,{variant:`caption`,noWrap:!0,color:e.assignee?`text.primary`:`text.disabled`,children:e.assignee??`—`})}),r&&(0,_.jsxs)(d.Box,{className:`gantt-row-actions`,sx:{width:96,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`flex-end`,pr:.5},children:[s&&(0,_.jsx)(d.Tooltip,{title:C.editTaskTooltip,children:(0,_.jsx)(d.IconButton,{size:`small`,"aria-label":C.editTaskTooltip,"data-testid":`gantt-edit-task-${e.id}`,onClick:t=>{t.stopPropagation(),s(e)},children:(0,_.jsx)(V.default,{fontSize:`inherit`})})}),o&&(0,_.jsx)(d.Tooltip,{title:C.addTaskTooltip,children:(0,_.jsx)(d.IconButton,{size:`small`,"aria-label":C.addTaskTooltip,"data-testid":`gantt-add-task-${e.id}`,onClick:t=>{t.stopPropagation(),o(e)},children:(0,_.jsx)(y.default,{fontSize:`inherit`})})}),c&&(0,_.jsx)(d.Tooltip,{title:C.deleteTaskTooltip,children:(0,_.jsx)(d.IconButton,{size:`small`,"aria-label":C.deleteTaskTooltip,"data-testid":`gantt-delete-task-${e.id}`,onClick:t=>{t.stopPropagation(),c(e)},children:(0,_.jsx)(v.default,{fontSize:`inherit`})})})]}),(0,_.jsxs)(d.Box,{sx:{width:90,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`},children:[(0,_.jsx)(d.Chip,{label:In(e.status,C),size:`small`,variant:`outlined`,color:e.color??w?.[e.status]?`default`:kn[e.status]??`default`,sx:{height:20,fontSize:10,cursor:l?`pointer`:`default`,...(e.color??w?.[e.status])&&{borderColor:e.color??w?.[e.status],color:e.color??w?.[e.status]}},onClick:l?e=>{e.stopPropagation(),b(e.currentTarget)}:void 0}),l&&(0,_.jsx)(d.Menu,{anchorEl:g,open:!!g,onClose:()=>b(null),children:[`planned`,`in-progress`,`done`,`blocked`].map(t=>(0,_.jsx)(d.MenuItem,{selected:e.status===t,onClick:()=>{l(e,t),b(null)},children:In(t,C)},t))})]})]})}function Rn({scrollRef:e,onScroll:t,panelWidth:n,onTaskClick:r,onAddTask:i,onEditTask:a,onDeleteTask:o,onStatusChange:s,onTasksChange:c,enableBuiltinDialogs:l,onTaskCreated:u,onTaskUpdated:p,onTaskDeleted:m,inlineEdit:h,virtualizeRows:g=!1,showAssigneeColumn:v=!1}){let y=ir(),b=nr(),x=$(e=>e.taskTree),S=$(e=>e.expandedIds),C=$(e=>e.toggleExpand),w=$(e=>e.timeScale),T=$(e=>e.addTask),E=$(e=>e.updateTask),D=$(e=>e.deleteTask),O=$(e=>e.assigneeFilter),k=(0,f.useMemo)(()=>{let e=sn(x,S);return O?cn(e,O):e},[x,S,O]),A=(0,B.useVirtualizer)({count:k.length,getScrollElement:()=>e.current,estimateSize:()=>40,overscan:5}),[j,M]=(0,f.useState)(!1),[N,P]=(0,f.useState)(!1),[F,I]=(0,f.useState)(!1),[L,R]=(0,f.useState)(null),z=e=>{let t={...e,id:crypto.randomUUID()};T(t),c?.(b.getState().tasks),u?.(t),M(!1)},V=e=>{if(!L)return;let t={...e,id:L.id};E(t),c?.(b.getState().tasks),p?.(t),P(!1)},H=()=>{L&&(D(L.id),c?.(b.getState().tasks),m?.(L.id),I(!1))},U=(e,t)=>{let n={...e,name:t};E(n),c?.(b.getState().tasks),p?.(n)},W=l?e=>{R(e),M(!0)}:i,G=l?e=>{R(e),P(!0)}:a,K=l?e=>{R(e),I(!0)}:o,q=!!(W||G||K),J=w===`days`?80:40,[ee,te]=(0,f.useState)(null),Y=ee?k.findIndex(e=>e.id===ee):-1;(0,f.useEffect)(()=>{if(Y<0||!e.current)return;let t=e.current,n=J+Y*40,r=n+40;n<t.scrollTop?t.scrollTop=n:r>t.scrollTop+t.clientHeight&&(t.scrollTop=r-t.clientHeight)},[Y,J,e]);function X(e){if(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement)return;let t=k.length;t!==0&&(e.key===`ArrowDown`?(e.preventDefault(),te(k[Math.min(Y<0?0:Y+1,t-1)].id)):e.key===`ArrowUp`?(e.preventDefault(),te(k[Math.max(Y<=0?0:Y-1,0)].id)):e.key===`Enter`&&Y>=0?(e.preventDefault(),G?.(k[Y])):e.key===`Escape`&&te(null))}return(0,_.jsxs)(d.Box,{ref:e,onScroll:t,tabIndex:0,"data-testid":`gantt-task-panel`,onKeyDown:X,sx:{width:n,flexShrink:0,overflowY:`auto`,overflowX:`hidden`,outline:`none`},children:[(0,_.jsxs)(d.Box,{sx:{height:J,position:`sticky`,top:0,bgcolor:`background.paper`,zIndex:1,borderBottom:`1px solid`,borderRight:`1px solid`,borderColor:`divider`,display:`flex`,flexDirection:`column`},children:[(0,_.jsxs)(d.Box,{sx:{height:40,display:`flex`,alignItems:`center`,overflow:`hidden`,borderBottom:w===`days`?`1px solid`:void 0,borderColor:w===`days`?`divider`:void 0},children:[(0,_.jsx)(d.Box,{sx:{flex:1,minWidth:0,pl:2},children:(0,_.jsx)(d.Typography,{variant:`caption`,color:`text.secondary`,children:y.columnName})}),v&&(0,_.jsx)(d.Box,{sx:{width:110,flexShrink:0,display:`flex`,alignItems:`center`,px:1},children:(0,_.jsx)(d.Typography,{variant:`caption`,color:`text.secondary`,children:y.columnAssignee})}),q&&(0,_.jsx)(d.Box,{sx:{width:96,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,_.jsx)(d.Typography,{variant:`caption`,color:`text.secondary`,children:y.columnActions})}),(0,_.jsx)(d.Box,{sx:{width:90,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,_.jsx)(d.Typography,{variant:`caption`,color:`text.secondary`,children:y.columnStatus})})]}),w===`days`&&(0,_.jsx)(d.Box,{sx:{flex:1}})]}),g?(0,_.jsx)(d.Box,{sx:{position:`relative`,height:A.getTotalSize()},children:A.getVirtualItems().map(e=>(0,_.jsx)(d.Box,{style:{position:`absolute`,top:0,left:0,width:`100%`,height:40,transform:`translateY(${e.start}px)`},children:(0,_.jsx)(Ln,{task:k[e.index],expandedIds:S,toggleExpand:C,hasActionsColumn:q,showAssigneeColumn:v,onTaskClick:r,onAddTask:W,onEditTask:G,onDeleteTask:K,onStatusChange:s,inlineEdit:h,onInlineRename:h?U:void 0,isSelected:k[e.index].id===ee,onSelect:()=>te(k[e.index].id)})},e.key))}):k.map(e=>(0,_.jsx)(Ln,{task:e,expandedIds:S,toggleExpand:C,hasActionsColumn:q,showAssigneeColumn:v,onTaskClick:r,onAddTask:W,onEditTask:G,onDeleteTask:K,onStatusChange:s,inlineEdit:h,onInlineRename:h?U:void 0,isSelected:e.id===ee,onSelect:()=>te(e.id)},e.id)),l&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(Pn,{open:j,mode:`add`,defaultParentId:L?.id,onSave:z,onClose:()=>M(!1)}),(0,_.jsx)(Pn,{open:N,mode:`edit`,initialTask:L??void 0,onSave:V,onClose:()=>P(!1)}),(0,_.jsx)(Fn,{open:F,task:L,onConfirm:H,onClose:()=>I(!1)})]})]})}var zn=864e5;function Bn({totalWidth:e,displayRange:t,onDragStart:n,onTaskMoved:r,onTaskResized:i,onTasksChange:a}){let o=$(e=>e.updateTask),s=nr(),c=ir(),l=(0,f.useRef)(1),u=(0,f.useRef)(n),d=(0,f.useRef)(r),p=(0,f.useRef)(i),m=(0,f.useRef)(a);(0,f.useLayoutEffect)(()=>{l.current=e>0?e/((t.end.getTime()-t.start.getTime())/zn):1,u.current=n,d.current=r,p.current=i,m.current=a});let h=(0,f.useRef)(null),g=(0,f.useRef)(null),[_,v]=(0,f.useState)(null),y=(0,f.useRef)(!1),b=(0,f.useRef)(null);return(0,f.useEffect)(()=>()=>{b.current?.()},[]),{activeDrag:_,suppressClickRef:y,handleBarMouseDown:(e,t,n)=>{e.stopPropagation(),y.current=!1,h.current={type:n,taskId:t.id,startX:e.clientX,originalStart:t.startDate,originalEnd:t.endDate},n!==`progress`&&u.current?.(t,n),document.body.style.cursor=n===`resize`?`ew-resize`:`grabbing`;let r=e=>{let t=h.current;if(!t||t.type===`progress`)return;let n=e.clientX-t.startX,r=Math.round(n/l.current);Math.abs(n)>=5&&(y.current=!0);let i={taskId:t.taskId,type:t.type,deltaDays:r};g.current=i,v(i)},i=()=>{document.body.style.cursor=``;let e=h.current,t=g.current;if(e&&t&&y.current&&t.deltaDays!==0){let n=s.getState().tasks.find(t=>t.id===e.taskId);if(n){if(t.type===`move`){let r=fn(e.originalStart,t.deltaDays),i=fn(e.originalEnd,t.deltaDays);o({...n,startDate:r,endDate:i}),d.current?.(n,r,i)}else{let r=fn(e.originalEnd,t.deltaDays),i=r>e.originalStart?r:fn(e.originalStart,1);o({...n,endDate:i}),p.current?.(n,i)}m.current?.(s.getState().tasks)}}h.current=null,g.current=null,v(null),document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i),b.current=null};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i),b.current=()=>{document.body.style.cursor=``,document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i)}},handleProgressMouseDown:(e,t,n,r)=>{e.stopPropagation(),y.current=!1,h.current={type:`progress`,taskId:t.id,startX:e.clientX,originalStart:t.startDate,originalEnd:t.endDate,initialProgress:n,barWidthPx:r},document.body.style.cursor=`ew-resize`;let i=e=>{let t=h.current;if(!t||t.type!==`progress`)return;let n=e.clientX-t.startX;Math.abs(n)>=5&&(y.current=!0);let r=n/(t.barWidthPx??1)*100,i=Math.round(Math.max(0,Math.min(100,(t.initialProgress??0)+r))),a={taskId:t.taskId,type:`progress`,deltaDays:0,newProgress:i};g.current=a,v(a)},a=()=>{document.body.style.cursor=``;let e=h.current,t=g.current;if(e&&t&&t.type===`progress`&&t.newProgress!==void 0&&y.current){let n=s.getState().tasks.find(t=>t.id===e.taskId);n&&(o({...n,progress:t.newProgress}),m.current?.(s.getState().tasks))}h.current=null,g.current=null,v(null),document.removeEventListener(`mousemove`,i),document.removeEventListener(`mouseup`,a),b.current=null};document.addEventListener(`mousemove`,i),document.addEventListener(`mouseup`,a),b.current=()=>{document.body.style.cursor=``,document.removeEventListener(`mousemove`,i),document.removeEventListener(`mouseup`,a)}},formatDragDate:e=>e.toLocaleDateString(c.dateLocale,{day:`2-digit`,month:`short`})}}function Vn({items:e}){return(0,_.jsx)(d.Box,{sx:{display:`flex`},children:e.map(e=>(0,_.jsx)(d.Box,{sx:{width:e.width,flexShrink:0,height:40,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRight:`1px solid`,borderColor:`divider`,bgcolor:e.isWeekend?`action.hover`:`transparent`},children:(0,_.jsx)(d.Typography,{variant:`caption`,color:e.isWeekend?`text.disabled`:`text.secondary`,children:e.label})},e.key))})}function Hn({columns:e,groups:t,todayX:n,todayLabel:r,todayTooltip:i,todayColor:a}){let o=(0,d.useTheme)(),s=t?80:40,c=a||o.palette.primary.main,l=o.palette.getContrastText(c);return(0,_.jsxs)(d.Box,{sx:{position:`sticky`,top:0,bgcolor:`background.paper`,zIndex:1,borderBottom:`1px solid`,borderColor:`divider`,height:s,overflow:`visible`},children:[t&&(0,_.jsx)(d.Box,{sx:{height:40,borderBottom:`1px solid`,borderColor:`divider`,overflow:`visible`},children:(0,_.jsx)(Vn,{items:t})}),(0,_.jsx)(Vn,{items:e}),n!=null&&r&&(0,_.jsx)(d.Tooltip,{title:i??``,placement:`top`,arrow:!0,children:(0,_.jsx)(d.Chip,{"data-testid":`gantt-today-chip`,size:`small`,label:r,sx:{position:`absolute`,bottom:0,left:n,transform:`translateX(-50%) translateY(50%)`,zIndex:3,height:20,fontSize:`0.65rem`,fontWeight:700,letterSpacing:`0.03em`,backgroundColor:c,color:l,border:`1.5px solid ${c}`,boxShadow:o.shadows[2],cursor:`default`,userSelect:`none`,"& .MuiChip-label":{px:`6px`,py:0},"&:hover":{backgroundColor:c,opacity:.9}}})})]})}function Un({task:e,virtualTop:t,activeDrag:n,displayRange:r,totalWidth:i,gridColumnWidth:a,criticalTaskIds:o,draggable:s=!1,resizable:c=!1,progressDraggable:l=!1,onTaskClick:u,onMilestoneClick:f,onContextMenu:p,suppressClickRef:m,handleBarMouseDown:h,handleProgressMouseDown:g,formatDragDate:v}){let y=(0,d.useTheme)(),{statusColors:b,criticalPathColor:x,milestoneColor:S,barBorderRadius:C}=or(),w=n?.taskId===e.id,T=e;if(w&&n)if(n.type===`move`)T={...e,startDate:fn(e.startDate,n.deltaDays),endDate:fn(e.endDate,n.deltaDays)};else if(n.type===`resize`){let t=fn(e.endDate,n.deltaDays);T={...e,endDate:t>e.startDate?t:fn(e.startDate,1)}}else n.type===`progress`&&n.newProgress!==void 0&&(T={...e,progress:n.newProgress});let{left:E,width:D}=rn(T,r);return(0,_.jsx)(d.Box,{"data-testid":`gantt-bar-row-${e.id}`,style:t===void 0?void 0:{position:`absolute`,top:t,left:0,width:`100%`},sx:{height:40,position:`relative`,borderBottom:`1px solid`,borderColor:`divider`,backgroundImage:e=>`linear-gradient(to right, transparent calc(${a}px - 1px), ${e.palette.divider} calc(${a}px - 1px), ${e.palette.divider} ${a}px)`,backgroundSize:`${a}px 100%`,backgroundRepeat:`repeat-x`},children:e.isMilestone?(0,_.jsx)(Wn,{task:e,left:E,milestoneColor:S,criticalPathColor:x,isCritical:o.has(e.id),onMilestoneClick:f,theme:y}):(0,_.jsx)(Gn,{task:e,effectiveTask:T,left:E,width:D,totalWidth:i,isDragging:w,activeDrag:n,draggable:s,resizable:c,progressDraggable:l,isCritical:o.has(e.id),statusColors:b,criticalPathColor:x,barBorderRadius:C,onTaskClick:u,onContextMenu:p,suppressClickRef:m,handleBarMouseDown:h,handleProgressMouseDown:g,formatDragDate:v,theme:y})})}function Wn({task:e,left:t,milestoneColor:n,criticalPathColor:r,isCritical:i,onMilestoneClick:a,theme:o}){return t<0||t>100?null:(0,_.jsx)(d.Box,{"data-testid":`gantt-milestone-${e.id}`,sx:{position:`absolute`,left:`${t}%`,top:`50%`,width:12,height:12,bgcolor:n||`warning.main`,transform:`translate(-50%, -50%) rotate(45deg)`,cursor:a?`pointer`:`default`,boxShadow:i?`0 0 0 2.5px ${r||o.palette.error.main}`:void 0,"&:hover":a?{opacity:.8}:void 0},onClick:()=>a?.(e)})}function Gn({task:e,effectiveTask:t,left:n,width:r,totalWidth:i,isDragging:a,activeDrag:o,draggable:s,resizable:c,progressDraggable:l,isCritical:u,statusColors:f,criticalPathColor:p,barBorderRadius:m,onTaskClick:h,onContextMenu:g,suppressClickRef:v,handleBarMouseDown:y,handleProgressMouseDown:b,formatDragDate:x,theme:S}){let C=Math.max(0,n),w=Math.min(100,n+Math.max(r,.5))-C;return w<=0?null:(0,_.jsxs)(_.Fragment,{children:[a&&o&&o.type!==`progress`&&o.deltaDays!==0&&(0,_.jsx)(Kn,{left:C,children:o.type===`move`?`${x(t.startDate)} – ${x(t.endDate)}`:`→ ${x(t.endDate)}`}),a&&o?.type===`progress`&&o.newProgress!==void 0&&(0,_.jsxs)(Kn,{left:C,children:[o.newProgress,`%`]}),(0,_.jsxs)(d.Box,{"data-testid":`gantt-bar-${e.id}`,sx:{position:`absolute`,left:`${C}%`,width:`${w}%`,height:16,top:`50%`,transform:`translateY(-50%)`,bgcolor:e.color??f?.[e.status]??On[e.status]??`grey.300`,borderRadius:m===void 0?1:`${m}px`,overflow:`hidden`,opacity:a?.75:1,boxShadow:u?`inset 0 0 0 2.5px ${p||S.palette.error.main}`:void 0,cursor:a?`grabbing`:s?`grab`:h?`pointer`:`default`,userSelect:`none`,"&:hover":s||h?{opacity:a?.75:.8}:void 0},onMouseDown:s?t=>y(t,e,`move`):void 0,onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),g(e,t.clientX,t.clientY)},onClick:()=>{if(v.current){v.current=!1;return}h?.(e)},children:[t.progress!==void 0&&t.progress>0&&(0,_.jsx)(d.Box,{"data-testid":`gantt-progress-${e.id}`,sx:{position:`absolute`,left:0,top:0,width:`${Math.min(t.progress,100)}%`,height:`100%`,bgcolor:`currentColor`,opacity:.4}}),l&&(0,_.jsx)(d.Box,{"data-testid":`gantt-progress-handle-${e.id}`,sx:{position:`absolute`,left:`${Math.min(t.progress??0,100)}%`,top:0,width:6,height:`100%`,transform:`translateX(-50%)`,cursor:`ew-resize`,bgcolor:`rgba(255,255,255,0.35)`},onMouseDown:n=>{n.stopPropagation();let r=w/100*i;b(n,e,t.progress??0,r)}}),c&&(0,_.jsx)(d.Box,{"data-testid":`gantt-resize-handle-${e.id}`,sx:{position:`absolute`,right:0,top:0,width:6,height:`100%`,cursor:`ew-resize`},onMouseDown:t=>{t.stopPropagation(),y(t,e,`resize`)}})]})]})}function Kn({left:e,children:t}){return(0,_.jsx)(d.Box,{sx:{position:`absolute`,left:`${e}%`,top:2,bgcolor:`grey.800`,color:`common.white`,borderRadius:.5,px:.75,lineHeight:`18px`,fontSize:`0.65rem`,whiteSpace:`nowrap`,pointerEvents:`none`,zIndex:100},children:t})}function qn({strips:e,totalWidth:t,height:n,top:r}){let{weekendColor:i}=or();return e.length===0?null:(0,_.jsx)(d.Box,{"aria-hidden":!0,"data-testid":`gantt-weekend-strips`,sx:{position:`absolute`,top:r,left:0,width:t,height:n,pointerEvents:`none`},children:e.map(e=>(0,_.jsx)(d.Box,{sx:{position:`absolute`,left:e.left,width:20,top:0,height:`100%`,bgcolor:i||`action.hover`}},e.key))})}function Jn({contextMenu:e,onClose:t,onSelect:n}){let r=ir(),i={planned:r.statusPlanned,"in-progress":r.statusInProgress,done:r.statusDone,blocked:r.statusBlocked};return(0,_.jsx)(d.Menu,{open:e!==null,onClose:t,anchorReference:`anchorPosition`,anchorPosition:e===null?void 0:{top:e.mouseY,left:e.mouseX},children:[`planned`,`in-progress`,`done`,`blocked`].map(t=>(0,_.jsx)(d.MenuItem,{selected:e?.task.status===t,"data-testid":`gantt-status-menu-${t}`,onClick:()=>{e&&n(e.task,t)},children:i[t]},t))})}function Yn({dependencyLines:e,todayX:t,totalWidth:n,height:r,top:i,arrowMarkerId:a}){let o=(0,d.useTheme)(),{todayLineColor:s}=or();return e.length===0&&t===null?null:(0,_.jsxs)(`svg`,{"data-testid":`gantt-dependency-arrows`,style:{position:`absolute`,top:i,left:0,width:n,height:r,pointerEvents:`none`,overflow:`visible`},children:[e.length>0&&(0,_.jsx)(`defs`,{children:(0,_.jsx)(`marker`,{id:a,markerWidth:`6`,markerHeight:`4`,refX:`5`,refY:`2`,orient:`auto`,children:(0,_.jsx)(`polygon`,{points:`0 0, 6 2, 0 4`,fill:`currentColor`})})}),e.map(e=>(0,_.jsx)(`path`,{"data-testid":`gantt-dep-${e.key}`,d:e.d,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeOpacity:.4,markerEnd:`url(#${a})`},e.key)),t!==null&&(0,_.jsx)(`line`,{"data-testid":`gantt-today-line`,x1:t,y1:0,x2:t,y2:r,stroke:s||o.palette.primary.main,strokeWidth:1.5,strokeDasharray:`4 2`})]})}function Xn(e,t,n){if(n===0)return[];let r=[],i=new Map(e.map((e,t)=>[e.id,t]));for(let a of e){if(!a.dependencies?.length)continue;let o=i.get(a.id),s=rn(a,t).left/100*n,c=o*40+40/2;for(let o of a.dependencies){let l=i.get(o);if(l===void 0)continue;let u=e[l],d=rn(u,t),f=(d.left+d.width)/100*n,p=l*40+40/2,m;m=s>=f+48?(f+s)/2:f+24<=n-8?f+24:Math.max(s-24,8),r.push({key:`${o}-${a.id}`,d:`M ${f} ${p} H ${m} V ${c} H ${s}`})}}return r}function Zn({scrollRef:e,onScroll:t,onTaskClick:n,onMilestoneClick:r,draggable:i=!1,resizable:a=!1,progressDraggable:o=!1,showCriticalPath:s=!1,virtualizeRows:c=!1,onDragStart:l,onTaskMoved:u,onTaskResized:p,onTasksChange:m,onStatusChange:h}){let g=$(e=>e.taskTree),v=$(e=>e.tasks),y=$(e=>e.expandedIds),b=$(e=>e.timelineRange),x=$(e=>e.timeScale),S=$(e=>e.updateTask),C=nr(),w=ir(),T=(0,d.useTheme)(),{todayLineColor:E}=or(),D=`gantt-arrow-${(0,f.useId)().replace(/:/g,``)}`,O=$(e=>e.assigneeFilter),k=(0,f.useMemo)(()=>{let e=sn(g,y);return O?cn(e,O):e},[g,y,O]),A=(0,f.useMemo)(()=>nn(b,x),[b,x]),j=(0,f.useMemo)(()=>x===`days`?bn(A).map(e=>({key:e.toISOString(),label:String(e.getDate()),width:20,isWeekend:e.getDay()===0||e.getDay()===6})):x===`weeks`?yn(A).map(e=>({key:e.toISOString(),label:`${w.weekColumnPrefix}${vn(e)}`,width:40})):x===`quarters`?Cn(A).map(e=>({key:e.key,label:e.label,width:360})):gn(A).map(e=>({key:e.toISOString(),label:e.toLocaleString(w.dateLocale,{month:`short`,year:`2-digit`}),width:120})),[x,A,w.weekColumnPrefix,w.dateLocale]),M=(0,f.useMemo)(()=>j.reduce((e,t)=>e+t.width,0),[j]),N=(0,f.useMemo)(()=>{if(x!==`days`)return;let e=new Map;for(let t of j){let n=new Date(t.key),r=`${n.getFullYear()}-${n.getMonth()}`;e.has(r)||e.set(r,{label:n.toLocaleString(w.dateLocale,{month:`short`,year:`2-digit`}),width:0}),e.get(r).width+=20}return Array.from(e.entries()).map(([e,t])=>({key:e,...t}))},[x,j,w.dateLocale]),P=(0,f.useMemo)(()=>Xn(k,A,M),[k,A,M]),F=(0,f.useMemo)(()=>s?wn(v):new Set,[s,v]),I=(0,B.useVirtualizer)({count:k.length,getScrollElement:()=>e.current,estimateSize:()=>40,overscan:5}),L=(0,f.useMemo)(()=>{if(x!==`days`)return[];let e=0;return j.flatMap(t=>{let n=t.isWeekend?[{key:t.key,left:e}]:[];return e+=t.width,n})},[x,j]),R=(0,f.useMemo)(()=>{let e=Date.now(),t=A.start.getTime(),n=A.end.getTime();return e<t||e>n?null:(e-t)/(n-t)*M},[A,M]),z=(0,f.useMemo)(()=>new Date().toLocaleDateString(w.dateLocale,{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`}),[w.dateLocale]),V=E||T.palette.primary.main;(0,f.useEffect)(()=>{if(R===null||!e.current)return;let t=e.current.clientWidth;e.current.scrollLeft=Math.max(0,R-t/2)},[]);let H=x===`days`?20:x===`weeks`?40:x===`quarters`?360:120,U=N?80:40,{activeDrag:W,suppressClickRef:G,handleBarMouseDown:K,handleProgressMouseDown:q,formatDragDate:J}=Bn({totalWidth:M,displayRange:A,onDragStart:l,onTaskMoved:u,onTaskResized:p,onTasksChange:m}),[ee,te]=(0,f.useState)(null),Y=(0,f.useRef)(h);Y.current=h;let X=(0,f.useRef)(m);return X.current=m,(0,_.jsx)(d.Box,{ref:e,onScroll:t,"data-testid":`gantt-timeline-scroll`,sx:{flex:1,overflow:`auto`},children:(0,_.jsxs)(d.Box,{sx:{minWidth:M,position:`relative`},children:[(0,_.jsx)(Hn,{columns:j,groups:N,todayX:R,todayLabel:w.todayLabel,todayTooltip:z,todayColor:V}),(0,_.jsx)(qn,{strips:L,totalWidth:M,height:k.length*40,top:U}),c?(0,_.jsx)(d.Box,{sx:{position:`relative`,height:I.getTotalSize()},children:I.getVirtualItems().map(e=>(0,_.jsx)(Un,{task:k[e.index],virtualTop:e.start,activeDrag:W,displayRange:A,totalWidth:M,gridColumnWidth:H,criticalTaskIds:F,draggable:i,resizable:a,progressDraggable:o,onTaskClick:n,onMilestoneClick:r,onContextMenu:(e,t,n)=>te({task:e,mouseX:t,mouseY:n}),suppressClickRef:G,handleBarMouseDown:K,handleProgressMouseDown:q,formatDragDate:J},e.key))}):(0,_.jsx)(_.Fragment,{children:k.map(e=>(0,_.jsx)(Un,{task:e,activeDrag:W,displayRange:A,totalWidth:M,gridColumnWidth:H,criticalTaskIds:F,draggable:i,resizable:a,progressDraggable:o,onTaskClick:n,onMilestoneClick:r,onContextMenu:(e,t,n)=>te({task:e,mouseX:t,mouseY:n}),suppressClickRef:G,handleBarMouseDown:K,handleProgressMouseDown:q,formatDragDate:J},e.id))}),(0,_.jsx)(Jn,{contextMenu:ee,onClose:()=>te(null),onSelect:(e,t)=>{let n=C.getState().tasks.find(t=>t.id===e.id)??e;S({...n,status:t}),Y.current?.(n,t),X.current?.(C.getState().tasks),te(null)}}),(0,_.jsx)(Yn,{dependencyLines:P,todayX:R,totalWidth:M,height:k.length*40,top:U,arrowMarkerId:D})]})})}function Qn(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function $n(e){let[t,n,r]=e.split(`-`).map(Number);return!t||!n||!r?null:new Date(t,n-1,r,0,0,0,0)}function er({onScrollToToday:e,config:t,onExportCSV:n}){let r=ir(),i=$(e=>e.timeScale),a=$(e=>e.defaultTimeScale),o=$(e=>e.setTimeScale),s=$(e=>e.timelineRange),c=$(e=>e.isRangeCustomized),l=$(e=>e.isExpandedCustomized),u=$(e=>e.setTimelineRange),p=$(e=>e.resetTimelineRange),m=$(e=>e.resetView),h=$(e=>e.tasks),g=$(e=>e.expandedIds),v=$(e=>e.expandAll),y=$(e=>e.collapseAll),b=$(e=>e.assigneeFilter),x=$(e=>e.setAssigneeFilter),S=(0,f.useMemo)(()=>[...new Set(h.flatMap(e=>e.assignee?[e.assignee]:[]))].sort(),[h]),C=h.length>0&&h.every(e=>g.has(e.id)),w=i!==a||c||l||b!==``,T=(0,f.useMemo)(()=>Date.now(),[]),E=T>=s.start.getTime()&&T<=s.end.getTime(),D={days:r.scaleDays,weeks:r.scaleWeeks,months:r.scaleMonths,quarters:r.scaleQuarters},O={days:t.showScaleDays,weeks:t.showScaleWeeks,months:t.showScaleMonths,quarters:t.showScaleQuarters},k=Object.keys(D).filter(e=>O[e]);return(0,_.jsxs)(d.Box,{"data-testid":`gantt-toolbar`,sx:{display:`flex`,alignItems:`center`,flexWrap:`wrap`,gap:1,px:1.5,py:.75,borderBottom:`1px solid`,borderColor:`divider`,bgcolor:`background.paper`},children:[k.length>0&&(0,_.jsx)(d.ToggleButtonGroup,{value:i,exclusive:!0,onChange:(e,t)=>{t&&o(t)},size:`small`,"aria-label":r.scaleMonths,children:k.map(e=>(0,_.jsx)(d.ToggleButton,{value:e,"data-testid":`gantt-scale-${e}`,children:D[e]},e))}),t.showAssigneeFilter&&S.length>0&&(0,_.jsxs)(d.FormControl,{size:`small`,sx:{minWidth:140},children:[(0,_.jsx)(d.InputLabel,{id:`gantt-assignee-filter-label`,children:r.filterAssigneeLabel??`Assignee`}),(0,_.jsxs)(d.Select,{labelId:`gantt-assignee-filter-label`,value:b,label:r.filterAssigneeLabel??`Assignee`,onChange:e=>x(e.target.value),inputProps:{"data-testid":`gantt-assignee-filter`},children:[(0,_.jsx)(d.MenuItem,{value:``,children:r.filterAssigneeAll??`Alle`}),S.map(e=>(0,_.jsx)(d.MenuItem,{value:e,children:e},e))]})]}),(0,_.jsxs)(d.Box,{sx:{ml:`auto`,display:`flex`,alignItems:`center`,gap:1},children:[t.showExpandCollapseAll&&(0,_.jsx)(d.Tooltip,{title:C?r.collapseAllTooltip:r.expandAllTooltip,children:(0,_.jsx)(d.IconButton,{size:`small`,onClick:C?y:v,"aria-label":C?r.collapseAllTooltip:r.expandAllTooltip,"data-testid":`gantt-expand-collapse-all`,children:C?(0,_.jsx)(G.default,{fontSize:`small`}):(0,_.jsx)(K.default,{fontSize:`small`})})}),t.showScrollToToday&&e&&(0,_.jsx)(d.Tooltip,{title:r.scrollToTodayTooltip,children:(0,_.jsx)(`span`,{children:(0,_.jsx)(d.IconButton,{size:`small`,onClick:e,disabled:!E,"aria-label":r.scrollToTodayTooltip,"data-testid":`gantt-scroll-to-today`,children:(0,_.jsx)(W.default,{fontSize:`small`})})})}),t.showDateRange&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(d.TextField,{type:`date`,size:`small`,label:r.rangeFrom,value:Qn(s.start),onChange:e=>{let t=$n(e.target.value);t&&u({start:t,end:s.end})},slotProps:{inputLabel:{shrink:!0},htmlInput:{"data-testid":`gantt-range-start`}},sx:{width:148}}),(0,_.jsx)(d.TextField,{type:`date`,size:`small`,label:r.rangeTo,value:Qn(s.end),onChange:e=>{let t=$n(e.target.value);t&&u({start:s.start,end:t})},slotProps:{inputLabel:{shrink:!0},htmlInput:{"data-testid":`gantt-range-end`}},sx:{width:148}})]}),t.showRangeReset&&c&&(0,_.jsx)(d.Tooltip,{title:r.rangeResetTooltip,children:(0,_.jsx)(d.IconButton,{size:`small`,onClick:p,"aria-label":r.rangeResetTooltip,"data-testid":`gantt-range-reset`,children:(0,_.jsx)(U.default,{fontSize:`small`})})}),t.showExportCSV&&n&&(0,_.jsx)(d.Tooltip,{title:r.exportCsvTooltip,children:(0,_.jsx)(d.IconButton,{size:`small`,onClick:n,"aria-label":r.exportCsvTooltip,"data-testid":`gantt-export-csv`,children:(0,_.jsx)(A.default,{fontSize:`small`})})}),t.showResetView&&(0,_.jsx)(d.Tooltip,{title:r.resetViewTooltip,children:(0,_.jsx)(`span`,{children:(0,_.jsx)(d.IconButton,{size:`small`,onClick:m,disabled:!w,"aria-label":r.resetViewTooltip,"data-testid":`gantt-reset-view`,children:(0,_.jsx)(H.default,{fontSize:`small`})})})})]})]})}var tr=(0,f.createContext)(null);function $(e){let t=(0,f.useContext)(tr);if(!t)throw Error(`GanttChartStoreContext is missing.`);return(0,R.useStore)(t,e)}function nr(){let e=(0,f.useContext)(tr);if(!e)throw Error(`GanttChartStoreContext is missing.`);return e}var rr=(0,f.createContext)(Dn);function ir(){return(0,f.useContext)(rr)}var ar=(0,f.createContext)({});function or(){return(0,f.useContext)(ar)}function sr(e,t){return e===void 0?t:e===`auto`?`100%`:typeof e==`string`&&/^\d+$/.test(e)?Number(e):e}var cr=[`days`,`weeks`,`months`,`quarters`],lr={showScaleDays:!0,showScaleWeeks:!0,showScaleMonths:!0,showScaleQuarters:!0,showExpandCollapseAll:!0,showScrollToToday:!0,showDateRange:!0,showRangeReset:!0,showResetView:!0,showExportCSV:!1,showAssigneeFilter:!1};function ur({tasks:e,onTaskClick:t,onMilestoneClick:n,onAddTask:r,onEditTask:i,onDeleteTask:a,onStatusChange:o,onTasksChange:s,enableBuiltinDialogs:c=!0,onTaskCreated:l,onTaskUpdated:u,onTaskDeleted:p,showToolbar:m=!0,toolbarConfig:h,height:g,width:v,minPanelWidth:y=200,maxPanelWidth:b=600,zoomable:x=!1,draggable:S=!1,resizable:C=!1,inlineEdit:w=!1,progressDraggable:T=!1,showCriticalPath:E=!1,virtualizeRows:D=!1,showAssigneeColumn:O=!1,onExportCSV:k,onDragStart:A,onTaskMoved:j,onTaskResized:M}){let N=sr(g,400),P=(0,f.useMemo)(()=>({...lr,...h}),[h]),F=sr(v,`100%`),I=$(e=>e.setTasks),L=$(e=>e.timeScale),R=$(e=>e.setTimeScale),z=$(e=>e.timelineRange),B=(0,f.useRef)(null),V=(0,f.useRef)(null),H=(0,f.useRef)(!1),[U,W]=(0,f.useState)(320+(O?110:0)),G=Math.max(y,90+(c||r||i||a?96:0)+(O?110:0)+80),K=nr(),q=(0,f.useCallback)(()=>{let e=K.getState().tasks,t=[[`id`,`name`,`status`,`startDate`,`endDate`,`progress`,`assignee`,`parentId`,`isMilestone`,`dependencies`,`color`].join(`,`),...e.map(e=>[e.id,`"${e.name.replace(/"/g,`""`)}"`,e.status,e.startDate.toISOString().split(`T`)[0],e.endDate.toISOString().split(`T`)[0],e.progress??``,e.assignee?`"${e.assignee.replace(/"/g,`""`)}"`:``,e.parentId??``,e.isMilestone?`true`:`false`,(e.dependencies??[]).join(`;`),e.color??``].join(`,`))].join(`
2
+ `);if(k)k(t,e);else{let e=new Blob([t],{type:`text/csv;charset=utf-8;`}),n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=`gantt-tasks.csv`,r.click(),URL.revokeObjectURL(n)}},[K,k]);(0,f.useEffect)(()=>{I(e)},[e,I]);let J=()=>{H.current||=(H.current=!0,V.current&&B.current&&(V.current.scrollTop=B.current.scrollTop),!1)},ee=()=>{H.current||=(H.current=!0,B.current&&V.current&&(B.current.scrollTop=V.current.scrollTop),!1)},te=(0,f.useCallback)(()=>{if(!V.current)return;let e=nn(z,L),t=Date.now(),n=e.start.getTime(),r=e.end.getTime(),i=(t-n)/(r-n)*V.current.scrollWidth;V.current.scrollLeft=Math.max(0,i-V.current.clientWidth/2)},[z,L]);(0,f.useEffect)(()=>{if(!x||!V.current)return;let e=V.current,t=e=>{if(!e.ctrlKey)return;e.preventDefault();let t=cr.indexOf(L);e.deltaY<0&&t>0?R(cr[t-1]):e.deltaY>0&&t<cr.length-1&&R(cr[t+1])};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[x,L,R]);let Y=(0,f.useCallback)(e=>{e.preventDefault();let t=e.clientX,n=U,r=e=>{let r=e.clientX-t;W(Math.max(G,Math.min(b,n+r)))},i=()=>{document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i)};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i)},[U,G,b]);return(0,_.jsxs)(d.Box,{sx:{display:`flex`,flexDirection:`column`,height:N,width:F,border:`1px solid`,borderColor:`divider`,borderRadius:1,overflow:`hidden`},children:[m&&(0,_.jsx)(er,{onScrollToToday:te,config:P,onExportCSV:P.showExportCSV?q:void 0}),(0,_.jsxs)(d.Box,{sx:{display:`flex`,flex:1,overflow:`hidden`},children:[(0,_.jsx)(Rn,{scrollRef:B,onScroll:J,panelWidth:U,onTaskClick:t,onAddTask:r,onEditTask:i,onDeleteTask:a,onStatusChange:o,onTasksChange:s,enableBuiltinDialogs:c,onTaskCreated:l,onTaskUpdated:u,onTaskDeleted:p,inlineEdit:w,virtualizeRows:D,showAssigneeColumn:O}),(0,_.jsx)(d.Box,{"data-testid":`gantt-panel-divider`,sx:{width:4,flexShrink:0,bgcolor:`divider`,cursor:`col-resize`,"&:hover":{bgcolor:`action.hover`}},onMouseDown:Y}),(0,_.jsx)(Zn,{scrollRef:V,onScroll:ee,onTaskClick:t,onMilestoneClick:n,draggable:S,resizable:C,progressDraggable:T,showCriticalPath:E,virtualizeRows:D,onDragStart:A,onTaskMoved:j,onTaskResized:M,onTasksChange:s,onStatusChange:o})]})]})}function dr({tasks:e,timeScale:t=`months`,initialExpandAll:n=!1,showToolbar:r=!0,defaultRangeStart:i,defaultRangeEnd:a,translations:o,enableBuiltinDialogs:s=!0,toolbarConfig:c,zoomable:l=!1,draggable:u=!1,resizable:d=!1,inlineEdit:p=!1,progressDraggable:m=!1,showCriticalPath:h=!1,virtualizeRows:g=!1,showAssigneeColumn:v=!1,cascadeDependencies:y=!1,statusColors:b,ganttTheme:x,onExportCSV:S,onDragStart:C,onTaskClick:w,onMilestoneClick:T,onAddTask:E,onEditTask:D,onDeleteTask:O,onStatusChange:k,onTasksChange:A,onTaskMoved:j,onTaskResized:M,onTaskCreated:N,onTaskUpdated:P,onTaskDeleted:F,height:I,width:L,minPanelWidth:R,maxPanelWidth:z}){let B=(0,f.useMemo)(()=>({...Dn,...o}),[o]),[V]=(0,f.useState)(()=>{if(!(i!==void 0||a!==void 0))return En(e,t,n,void 0,y);let r=tn(e);return En(e,t,n,{start:i??r.start,end:a??r.end},y)}),H=(0,f.useMemo)(()=>({...x,statusColors:{...b,...x?.statusColors}}),[b,x]);return(0,_.jsx)(rr.Provider,{value:B,children:(0,_.jsx)(ar.Provider,{value:H,children:(0,_.jsx)(tr.Provider,{value:V,children:(0,_.jsx)(ur,{tasks:e,timeScale:t,enableBuiltinDialogs:s,showToolbar:r,toolbarConfig:c,zoomable:l,draggable:u,resizable:d,inlineEdit:p,progressDraggable:m,showCriticalPath:h,virtualizeRows:g,showAssigneeColumn:v,onExportCSV:S,onDragStart:C,onTaskClick:w,onMilestoneClick:T,onAddTask:E,onEditTask:D,onDeleteTask:O,onStatusChange:k,onTasksChange:A,onTaskMoved:j,onTaskResized:M,onTaskCreated:N,onTaskUpdated:P,onTaskDeleted:F,height:I,width:L,minPanelWidth:R,maxPanelWidth:z})})})})}var fr=e=>Math.max(0,Math.min(4,Math.round(e)));function pr(e,t){let n=e??``,r=n.length,i=/[a-z]/.test(n),a=/[A-Z]/.test(n),o=/\d/.test(n),s=/[^A-Za-z0-9]/.test(n),c=[i,a,o,s].filter(Boolean).length;if(r<t){let e=r===0?0:1;return{score:e,percent:e*25,meterStatus:`weak`,length:r,hasLower:i,hasUpper:a,hasDigit:o,hasSymbol:s}}let l=0;l+=1,r>=t+4&&(l+=1),c>=2&&(l+=1),c>=3&&(l+=1),/^(.)\1+$/.test(n)&&(l-=2),/1234|abcd|qwer|password|passwort|admin/i.test(n)&&(l-=2);let u=fr(l),d=u<=1?`weak`:u===2?`ok`:u===3?`good`:`very good`;return{score:u,percent:u*25,meterStatus:d,length:r,hasLower:i,hasUpper:a,hasDigit:o,hasSymbol:s}}function mr({percent:e,color:t,ariaLabel:n,segments:r=!1,className:i}){if(r){let r=Math.round(e/25);return(0,_.jsx)(d.Box,{role:`progressbar`,"aria-label":n,"aria-valuenow":e,"aria-valuemin":0,"aria-valuemax":100,className:i,sx:{width:`100%`,display:`flex`,gap:`3px`,mt:.5},children:[0,1,2,3].map(e=>(0,_.jsx)(d.Box,{"data-testid":e<r?`psm-meter-segment-active`:`psm-meter-segment`,sx:{flex:1,height:`8px`,borderRadius:`3px`,border:`1px solid`,borderColor:`divider`,backgroundColor:e<r?t:`transparent`,transition:`background-color 0.3s ease-in-out`}},e))})}return(0,_.jsx)(d.Box,{role:`progressbar`,"aria-label":n,"aria-valuenow":e,"aria-valuemin":0,"aria-valuemax":100,className:i,sx:{width:`100%`,height:`8px`,border:`1px solid`,borderColor:`divider`,borderRadius:`6px`,mt:.5,display:`flex`},children:(0,_.jsx)(d.Box,{"data-testid":`psm-meter`,sx:{height:`100%`,width:`${e}%`,backgroundColor:t,borderRadius:`6px`,transition:`width 0.2s ease-in-out`}})})}var hr={label:`Password`,summaryHeaderLabel:`Requirements for your password`,summaryMinChars:`At least {n} characters`,summaryCapitalLetter:`At least 1 capital letter`,summaryLowerCaseLetter:`At least 1 lowercase letter`,summaryNumber:`At least 1 number`,summarySpecialChar:`At least 1 special character`,showPasswordLabel:`Show password`,hidePasswordLabel:`Hide password`,meterAriaLabel:`Password strength`,generatePasswordLabel:`Generate secure password`,confirmLabel:`Confirm password`,confirmMatchLabel:`Passwords match`,confirmMismatchLabel:`Passwords do not match`,copyPasswordLabel:`Copy password`,copiedLabel:`Copied!`},gr={weak:`#cc0000`,ok:`#fdc010`,good:`#8bc34a`,veryGood:`#43a047`},_r={failure:`#cc0000`,success:`#43a047`};function vr(e){let t=[];e.upper&&t.push(`ABCDEFGHIJKLMNOPQRSTUVWXYZ`),e.lower&&t.push(`abcdefghijklmnopqrstuvwxyz`),e.numbers&&t.push(`0123456789`),e.symbols&&t.push(`!@#$%^&*()-_=+[]{}|;:,.<>?`),t.length===0&&t.push(`abcdefghijklmnopqrstuvwxyz`);let n=t.join(``),r=Math.max(e.length,t.length),i=new Uint32Array(Math.max(0,r-t.length));crypto.getRandomValues(i);let a=t.map(e=>e[crypto.getRandomValues(new Uint32Array(1))[0]%e.length]),o=Array.from(i).map(e=>n[e%n.length]),s=[...a,...o];for(let e=s.length-1;e>0;e--){let t=crypto.getRandomValues(new Uint32Array(1))[0]%(e+1);[s[e],s[t]]=[s[t],s[e]]}return s.join(``)}function yr({label:e,fulfilled:t,checkColors:n}){return(0,_.jsxs)(d.Stack,{direction:`row`,sx:{alignItems:`center`,mb:.25},spacing:.5,className:it.requirementItem,children:[(0,_.jsx)(d.Typography,{variant:`caption`,children:e}),t?(0,_.jsx)(I.default,{"data-testid":`psm-req-success`,style:{fontSize:16,color:n.success}}):(0,_.jsx)(L.default,{"data-testid":`psm-req-failure`,style:{fontSize:16,color:n.failure}})]})}function br({value:e,confirmValue:t,name:n,inputRef:r,disabled:i=!1,error:a=!1,helperText:o,autoComplete:s,customRequirements:c,generatorOptions:l,showConfirmField:u=!1,showPasswordAdornment:p=!0,showMeter:m=!0,showPasswordGenerator:h=!1,showSegmentedBar:g=!1,showSummary:v=!0,showCopyButton:y=!1,inputSize:b=`medium`,translation:x,meterColors:S,passwordMinLength:C=8,checkColors:w=_r,onPasswordChange:T,onConfirmChange:E,onPasswordGenerated:D}){let O={...hr,...x},A={...gr,...S},M=(0,f.useId)(),N=`${M}-password`,[F,I]=(0,f.useState)(!1),[L,R]=(0,f.useState)(!1),[z,B]=(0,f.useState)(``),[V,H]=(0,f.useState)(``),[U,W]=Yt(),G=e===void 0?z:e,K=t===void 0?V:t,Y=u&&K.length>0,X=Y&&G===K,ne=(0,f.useMemo)(()=>pr(G,C),[G,C]),re=()=>{I(e=>!e)},ie=e=>{e.preventDefault()},ae=e=>{e.preventDefault()},oe=t=>{let n=t.target.value;e===void 0&&B(n),T&&T(n,pr(n,C))},se=e=>{let n=e.target.value;t===void 0&&H(n),E?.(n,n===G)},ce=()=>{let n=vr({length:l?.length??Math.max(16,C),upper:l?.upper??!0,lower:l?.lower??!0,numbers:l?.numbers??!0,symbols:l?.symbols??!0});e===void 0&&B(n),t===void 0&&H(``),T?.(n,pr(n,C)),D?.(n),I(!0)},le=()=>{navigator.clipboard.writeText(G).then(()=>{W()})},ue=e=>{switch(e.meterStatus){case`weak`:return A.weak;case`ok`:return A.ok;case`good`:return A.good;case`very good`:return A.veryGood;default:return`transparent`}},de=[it.strengthBar,ne.meterStatus===`weak`&&it.strengthBarWeak,ne.meterStatus===`ok`&&it.strengthBarOk,ne.meterStatus===`good`&&it.strengthBarGood,ne.meterStatus===`very good`&&it.strengthBarVeryGood].filter(Boolean).join(` `);return(0,_.jsxs)(d.Stack,{className:[it.root,i&&Be.disabled,a&&Be.error].filter(Boolean).join(` `),children:[(0,_.jsxs)(d.FormControl,{variant:`outlined`,fullWidth:!0,error:a,className:it.input,children:[(0,_.jsx)(d.InputLabel,{htmlFor:N,size:b,children:O.label}),(0,_.jsx)(d.OutlinedInput,{id:N,type:F?`text`:`password`,fullWidth:!0,size:b,value:G,onChange:oe,disabled:i,inputRef:r,inputProps:{"data-testid":`psm-input`,name:n,autoComplete:s},endAdornment:p||y&&G.length>0?(0,_.jsxs)(d.InputAdornment,{position:`end`,children:[y&&G.length>0&&(0,_.jsx)(d.Tooltip,{title:U?O.copiedLabel:O.copyPasswordLabel,arrow:!0,children:(0,_.jsx)(`span`,{children:(0,_.jsx)(d.IconButton,{"data-testid":`psm-copy`,disabled:i,"aria-label":U?O.copiedLabel:O.copyPasswordLabel,onClick:le,onMouseDown:ie,onMouseUp:ae,edge:p?!1:`end`,children:U?(0,_.jsx)(j.default,{fontSize:`small`,color:`success`}):(0,_.jsx)(k.default,{fontSize:`small`})})})}),p&&(0,_.jsx)(d.IconButton,{"data-testid":`psm-toggle`,disabled:i,"aria-label":F?O.hidePasswordLabel:O.showPasswordLabel,onClick:re,onMouseDown:ie,onMouseUp:ae,edge:`end`,children:F?(0,_.jsx)(te.default,{}):(0,_.jsx)(ee.default,{})})]}):null,label:O.label}),o&&(0,_.jsx)(d.FormHelperText,{children:o})]}),h&&(0,_.jsx)(d.Tooltip,{title:O.generatePasswordLabel,arrow:!0,children:(0,_.jsx)(`span`,{children:(0,_.jsx)(d.Button,{"data-testid":`psm-generate`,size:`small`,variant:`text`,startIcon:(0,_.jsx)(P.default,{fontSize:`small`}),disabled:i,onClick:ce,className:it.generatorButton,sx:{mt:.5,alignSelf:`flex-start`,textTransform:`none`},children:O.generatePasswordLabel})})}),u&&(0,_.jsxs)(d.FormControl,{variant:`outlined`,fullWidth:!0,error:Y&&!X,sx:{mt:1},className:it.confirmInput,children:[(0,_.jsx)(d.InputLabel,{htmlFor:`${M}-confirm`,size:b,children:O.confirmLabel}),(0,_.jsx)(d.OutlinedInput,{id:`${M}-confirm`,type:L?`text`:`password`,fullWidth:!0,size:b,value:K,onChange:se,disabled:i,inputProps:{"data-testid":`psm-confirm-input`},endAdornment:(0,_.jsxs)(d.InputAdornment,{position:`end`,children:[Y&&(X?(0,_.jsx)(q.default,{"data-testid":`psm-confirm-match`,sx:{color:w.success,mr:.5},fontSize:`small`}):(0,_.jsx)(J.default,{"data-testid":`psm-confirm-mismatch`,sx:{color:w.failure,mr:.5},fontSize:`small`})),(0,_.jsx)(d.IconButton,{size:`small`,disabled:i,onClick:()=>R(e=>!e),onMouseDown:e=>e.preventDefault(),edge:`end`,"aria-label":L?O.hidePasswordLabel:O.showPasswordLabel,children:L?(0,_.jsx)(te.default,{}):(0,_.jsx)(ee.default,{})})]}),label:O.confirmLabel}),Y&&(0,_.jsx)(d.FormHelperText,{sx:{color:X?w.success:w.failure},children:X?O.confirmMatchLabel:O.confirmMismatchLabel})]}),m&&(0,_.jsx)(mr,{percent:ne.percent,color:ue(ne),ariaLabel:O.meterAriaLabel,segments:g,className:de}),v&&(0,_.jsxs)(d.Box,{"data-testid":`psm-summary`,sx:{mt:.5,p:.5},className:it.summary,children:[(0,_.jsx)(d.Typography,{variant:`caption`,gutterBottom:!0,sx:{display:`block`,fontSize:14},children:O.summaryHeaderLabel}),(0,_.jsxs)(d.Stack,{direction:`row`,spacing:6,children:[(0,_.jsxs)(d.Stack,{direction:`column`,children:[(0,_.jsx)(yr,{label:O.summaryMinChars.replace(`{n}`,String(C)),fulfilled:ne.length>=C,checkColors:w}),(0,_.jsx)(yr,{label:O.summaryCapitalLetter,fulfilled:ne.hasUpper,checkColors:w}),(0,_.jsx)(yr,{label:O.summaryLowerCaseLetter,fulfilled:ne.hasLower,checkColors:w})]}),(0,_.jsxs)(d.Stack,{direction:`column`,children:[(0,_.jsx)(yr,{label:O.summaryNumber,fulfilled:ne.hasDigit,checkColors:w}),(0,_.jsx)(yr,{label:O.summarySpecialChar,fulfilled:ne.hasSymbol,checkColors:w}),c?.map((e,t)=>(0,_.jsx)(yr,{label:e.label,fulfilled:typeof e.fulfilled==`function`?e.fulfilled(G):e.fulfilled,checkColors:w},t))]})]})]})]})}function xr(e){return(0,z.createStore)(t=>({tags:e,searchValue:``,setTags:e=>{t({tags:e})},setSearchValue:e=>{t({searchValue:e})},selectTag:e=>{t(t=>({tags:t.tags.map(t=>t.id===e&&!t.disabled?{...t,selected:!0}:t),searchValue:``}))},deleteTag:e=>{t(t=>({tags:t.tags.map(t=>t.id===e?{...t,selected:!1}:t)}))},addTag:e=>{t(t=>({tags:[...t.tags,{...e,selected:!0}],searchValue:``}))}}))}var Sr=[`default`,`primary`,`secondary`,`error`,`info`,`success`,`warning`],Cr=[`#f44336`,`#e91e63`,`#9c27b0`,`#673ab7`,`#3f51b5`,`#2196f3`,`#03a9f4`,`#00bcd4`,`#009688`,`#4caf50`,`#8bc34a`,`#cddc39`,`#ffeb3b`,`#ffc107`,`#ff9800`,`#ff5722`,`#795548`,`#9e9e9e`,`#607d8b`,`#000000`];function wr(e){return/^#[0-9A-Fa-f]{6}$/.test(e)}function Tr(e){let t=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),r=parseInt(e.slice(5,7),16);return(.299*t+.587*n+.114*r)/255>.5?`#000000`:`#ffffff`}function Er(e,t){let n=t.trim();if(!n)return e;let r=e.toLowerCase().indexOf(n.toLowerCase());return r===-1?e:(0,_.jsxs)(_.Fragment,{children:[e.slice(0,r),(0,_.jsx)(`strong`,{children:e.slice(r,r+n.length)}),e.slice(r+n.length)]})}function Dr({color:e,selected:t,onClick:n}){return(0,_.jsx)(d.Box,{onClick:n,sx:{width:24,height:24,borderRadius:.5,backgroundColor:e,cursor:`pointer`,border:`2px solid`,borderColor:t?`primary.main`:`transparent`,outline:t?`1px solid`:`none`,outlineColor:`primary.main`,outlineOffset:1,flexShrink:0,"&:hover":{transform:`scale(1.2)`,borderColor:`primary.main`},transition:`transform 0.1s`}})}function Or({value:e,onChange:t,disabled:n=!1}){return(0,_.jsx)(d.TextField,{size:`small`,fullWidth:!0,value:e,onChange:e=>t(e.target.value),placeholder:`#rrggbb`,disabled:n,error:!n&&e.length>1&&!wr(e),sx:{"& .MuiInputBase-root":{height:28},"& .MuiInputBase-input":{py:0,px:.5,fontSize:`0.72rem`,fontFamily:`monospace`}},slotProps:{input:{startAdornment:(0,_.jsx)(d.Box,{sx:{width:12,height:12,borderRadius:.25,flexShrink:0,mr:.5,backgroundColor:wr(e)?e:`action.disabledBackground`,border:`1px solid`,borderColor:`divider`}})}}})}function kr({availableTags:e,searchValue:t,translation:n,onSearchChange:r,onTagSelect:i,onTagCreate:a,inputSize:o=`medium`,chipSize:s=`medium`,chipVariant:c=`filled`,disabled:l=!1,loading:u=!1,isMaxReached:p=!1,allowCreate:m=!1,listboxMaxHeight:h,serverSideFilter:g=!1}){let[v,y]=(0,f.useState)(`default`),[b,x]=(0,f.useState)(null),[S,C]=(0,f.useState)(null),[w,T]=(0,f.useState)(!0),[E,D]=(0,f.useState)(!1),[O,k]=(0,f.useState)(!1),[A,M]=(0,f.useState)(`#1976d2`),[N,P]=(0,f.useState)(`#ffffff`),F=l||p,I=b!==null,L=g?e:e.filter(e=>e.label.toLowerCase().includes(t.trim().toLowerCase())),R=m&&t.trim()!==``&&L.length===0,z=O&&!R,B=I?w?Tr(b):S??`#000000`:void 0,V=()=>{if(F)return;let e=t.trim(),n=e.toLowerCase().replace(/\s+/g,`-`);a?.(I&&b?{id:n,label:e,selected:!0,color:`default`,backgroundColor:b,foregroundColor:B}:{id:n,label:e,selected:!0,color:v}),y(`default`),x(null),C(null),T(!0),D(!1),r(``)},H=()=>{r(``),y(`default`),x(null),C(null),T(!0),D(!1)},U=e=>{x(e),M(e),y(`default`)},W=e=>{M(e),wr(e)&&(x(e),y(`default`))},G=e=>{C(e),P(e)},K=e=>{P(e),wr(e)&&C(e)},q=e=>{if(T(e),e)C(null);else if(b){let e=Tr(b);C(e),P(e)}},J=e=>e.preventDefault();return(0,_.jsxs)(d.Box,{sx:{mb:2},className:rt.autocomplete,children:[(0,_.jsx)(d.Autocomplete,{options:e,filterOptions:g?e=>e:void 0,value:null,open:z,onOpen:()=>{R||k(!0)},onClose:()=>k(!1),size:o,disabled:F,loading:u,getOptionLabel:e=>e.label,inputValue:t,onInputChange:(e,t,n)=>{n===`input`&&r(t)},onChange:(e,t)=>{t&&i(t)},slotProps:{listbox:{sx:{display:`flex`,flexWrap:`wrap`,gap:1,padding:1,...h!==void 0&&{maxHeight:h,overflowY:`auto`}}}},renderInput:e=>(0,_.jsx)(d.TextField,{...e,label:n.autoCompleteLabel,placeholder:n.placeholder,helperText:p&&!l?n.maxTagsReachedText:void 0,onKeyDown:e=>{R&&!F&&e.key===`Enter`&&(e.preventDefault(),V())},slotProps:{...e.slotProps,input:{...e.slotProps?.input,endAdornment:(0,_.jsxs)(_.Fragment,{children:[R&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(d.IconButton,{size:`small`,sx:{color:`success.main`},onMouseDown:J,onClick:V,disabled:F,"aria-label":n.confirmCreateLabel,children:(0,_.jsx)(j.default,{fontSize:`small`})}),(0,_.jsx)(d.IconButton,{size:`small`,onMouseDown:J,onClick:H,"aria-label":n.cancelCreateLabel,children:(0,_.jsx)(Y.default,{fontSize:`small`})})]}),e.slotProps?.input?.endAdornment]})}}}),renderOption:({key:e,...n},r)=>{let i=!!(r.foregroundColor||r.backgroundColor);return(0,_.jsx)(`li`,{...n,style:{width:`auto`,padding:0,margin:0},children:(0,_.jsx)(d.Chip,{size:s,variant:c,label:Er(r.label,t),color:i?void 0:r.color??`default`,className:rt.option,sx:i?{color:r.foregroundColor??`inherit`,backgroundColor:r.backgroundColor??`transparent`}:void 0})},e)},isOptionEqualToValue:(e,t)=>e.id===t.id,noOptionsText:n.noAvailableTagsText,loadingText:n.loadingText}),R&&(0,_.jsxs)(d.Box,{sx:{position:`relative`},onMouseDown:J,className:rt.createPanel,children:[(0,_.jsxs)(d.Stack,{direction:`row`,sx:{mt:.5,flexWrap:`wrap`,gap:.5,alignItems:`center`},children:[Sr.map(e=>(0,_.jsx)(d.Chip,{size:s,color:e,label:e,variant:!I&&v===e?`filled`:`outlined`,onClick:()=>{y(e),x(null),C(null),D(!1)},clickable:!0},e)),(0,_.jsx)(d.Tooltip,{title:n.colorPickerLabel,children:(0,_.jsx)(d.Chip,{size:s,label:I?b:`···`,variant:`outlined`,onClick:()=>{D(e=>!e),b&&M(b),S&&P(S)},sx:e=>({cursor:`pointer`,fontFamily:`monospace`,fontSize:`0.7rem`,...I?{backgroundColor:b,color:B,border:`1.5px solid transparent`,backgroundImage:`linear-gradient(${b}, ${b}), linear-gradient(90deg, #f44336, #ff9800, #ffeb3b, #4caf50, #2196f3, #9c27b0)`,backgroundOrigin:`border-box`,backgroundClip:`padding-box, border-box`}:{border:`1.5px solid transparent`,backgroundImage:`linear-gradient(${e.palette.background.paper}, ${e.palette.background.paper}), linear-gradient(90deg, #f44336, #ff9800, #ffeb3b, #4caf50, #2196f3, #9c27b0)`,backgroundOrigin:`border-box`,backgroundClip:`padding-box, border-box`}}),clickable:!0})})]}),E&&(0,_.jsx)(d.Box,{sx:{position:`absolute`,top:`calc(100% + 4px)`,left:0,zIndex:1400,backgroundColor:`background.paper`,border:`1px solid`,borderColor:`divider`,borderRadius:1,boxShadow:8,p:1.25,width:`max-content`},children:(0,_.jsxs)(d.Box,{sx:{display:`grid`,gridTemplateColumns:`auto auto`,gap:2},children:[(0,_.jsxs)(d.Box,{children:[(0,_.jsx)(d.Typography,{variant:`caption`,sx:{fontWeight:700,color:`text.primary`,display:`block`,mb:.5},children:n.backgroundColorLabel}),(0,_.jsxs)(d.Box,{sx:{display:`grid`,gridTemplateColumns:`repeat(5, 24px)`,gap:.5},children:[Cr.map(e=>(0,_.jsx)(Dr,{color:e,selected:b===e,onClick:()=>U(e)},e)),(0,_.jsx)(d.Box,{sx:{gridColumn:`span 5`,mt:.25},children:(0,_.jsx)(Or,{value:A,onChange:W})})]})]}),(0,_.jsxs)(d.Box,{children:[(0,_.jsx)(d.Typography,{variant:`caption`,sx:{fontWeight:700,color:`text.primary`,display:`block`,mb:.5},children:n.textColorLabel}),(0,_.jsxs)(d.Box,{sx:{display:`grid`,gridTemplateColumns:`repeat(5, 24px)`,gap:.5,opacity:w?.3:1,pointerEvents:w?`none`:`auto`,transition:`opacity 0.15s`},children:[Cr.map(e=>(0,_.jsx)(Dr,{color:e,selected:S===e,onClick:()=>G(e)},e)),(0,_.jsx)(d.Box,{sx:{gridColumn:`span 5`,mt:.25},children:(0,_.jsx)(Or,{value:w?B??`#000000`:N,onChange:K,disabled:w})})]}),(0,_.jsxs)(d.Stack,{direction:`row`,sx:{width:`100%`,alignItems:`center`,justifyContent:`flex-end`,gap:.5,mt:.25},children:[(0,_.jsx)(d.Typography,{variant:`caption`,color:`text.secondary`,children:n.autoTextColorLabel}),(0,_.jsx)(d.Switch,{size:`small`,checked:w,onChange:e=>q(e.target.checked)})]})]})]})})]})]})}function Ar({tag:e,onDelete:t,onClick:n,chipSize:r=`medium`,chipVariant:i=`filled`,disabled:a=!1}){let o=!!(e.foregroundColor||e.backgroundColor),s=a||e.disabled;return(0,_.jsx)(d.Chip,{size:r,label:e.label,onDelete:t?()=>t(e):void 0,onClick:n?()=>n(e):void 0,clickable:!!n&&!e.disabled&&!a,disabled:s,variant:i,color:o?void 0:e.color??`default`,className:[rt.chip,s&&Be.disabled].filter(Boolean).join(` `),sx:{...o&&{color:e.foregroundColor??`inherit`,backgroundColor:e.backgroundColor??`transparent`,borderColor:e.backgroundColor??void 0,"& .MuiChip-deleteIcon":{color:e.foregroundColor?`${e.foregroundColor}99`:`inherit`,"&:hover":{color:e.foregroundColor??`inherit`}}},cursor:n&&!e.disabled&&!s?`pointer`:`default`}})}function jr({selectedTags:e,translation:t,onTagDelete:n,showSelectedTagsLabel:r,chipSize:i=`medium`,chipVariant:a=`filled`,disabled:o=!1,maxVisibleChips:s,popoverPlacement:c=`bottom`}){let[l,u]=(0,f.useState)(null),p=s===void 0?e:e.slice(0,s),m=s===void 0?[]:e.slice(s),h=!!l&&m.length>0,g=c===`top`?{vertical:`top`,horizontal:`left`}:{vertical:`bottom`,horizontal:`left`},v=c===`top`?{vertical:`bottom`,horizontal:`left`}:{vertical:`top`,horizontal:`left`};return(0,_.jsxs)(d.Box,{sx:{mb:2},className:rt.selectedTags,children:[r&&(0,_.jsx)(d.Typography,{variant:`subtitle2`,gutterBottom:!0,className:rt.selectedTagsLabel,children:t.selectedTagsLabel}),e.length===0?(0,_.jsx)(d.Typography,{variant:`body2`,color:`text.secondary`,children:t.noSelectedTagsText}):(0,_.jsxs)(d.Stack,{direction:`row`,sx:{flexWrap:`wrap`,gap:1},className:rt.chipsStack,children:[p.map(e=>(0,_.jsx)(Ar,{tag:e,onDelete:n,chipSize:i,chipVariant:a,disabled:o},e.id)),m.length>0&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(d.Chip,{size:i,label:`+${m.length}`,variant:`outlined`,clickable:!0,onClick:e=>u(e.currentTarget),className:rt.overflowChip}),(0,_.jsx)(d.Popover,{open:h,anchorEl:l,onClose:()=>u(null),anchorOrigin:g,transformOrigin:v,children:(0,_.jsx)(d.Box,{sx:{p:1,display:`flex`,flexWrap:`wrap`,gap:.5,maxWidth:320},className:rt.overflowPopover,children:m.map(e=>(0,_.jsx)(Ar,{tag:e,onDelete:o?void 0:n,chipSize:i,chipVariant:a,disabled:o},e.id))})})]})]})]})}var Mr={selectedTagsLabel:`Selected tags`,autoCompleteLabel:`Search and add tags`,noSelectedTagsText:`No tags selected.`,noAvailableTagsText:`No tags available.`,placeholder:`Type to search...`,loadingText:`Loading...`,maxTagsReachedText:`Maximum number of tags reached.`,colorPickerLabel:`Custom color`,backgroundColorLabel:`Background color`,textColorLabel:`Text color`,autoTextColorLabel:`Auto`,confirmCreateLabel:`Confirm new tag`,cancelCreateLabel:`Cancel new tag`},Nr=(0,f.createContext)(null);function Pr(e){let t=(0,f.useContext)(Nr);if(!t)throw Error(`TagSelectionStoreContext is missing.`);return(0,R.useStore)(t,e)}function Fr({tags:e,showSelectedTags:t=!0,showSelectedTagsLabel:n=!0,showAutoComplete:r=!0,inputSize:i=`medium`,chipSize:a=`small`,chipVariant:o=`filled`,disabled:s=!1,loading:c=!1,maxTags:l,allowCreate:u=!1,maxVisibleChips:p,popoverPlacement:m=`bottom`,listboxMaxHeight:h,searchDebounceMs:g,serverSideFilter:v=!1,translation:y,onTagSelect:b,onTagDelete:x,onTagsChange:S,onSearchChange:C,onTagCreate:w}){let T=Pr(e=>e.tags),E=Pr(e=>e.searchValue),D=Pr(e=>e.setTags),O=Pr(e=>e.setSearchValue),k=Pr(e=>e.selectTag),A=Pr(e=>e.deleteTag),j=Pr(e=>e.addTag);(0,f.useEffect)(()=>{D(e)},[e,D]);let M=(0,f.useMemo)(()=>T.filter(e=>e.selected).sort((e,t)=>e.label.localeCompare(t.label)),[T]),N=(0,f.useMemo)(()=>T.filter(e=>!e.selected&&!e.disabled).sort((e,t)=>e.label.localeCompare(t.label)),[T]),P=l!==void 0&&M.length>=l,F=e=>{S&&S(e.filter(e=>e.selected),e)},I=e=>{if(e.disabled||e.selected)return;k(e.id);let t=T.map(t=>t.id===e.id?{...t,selected:!0}:t),n=t.filter(e=>e.selected),r=t.find(t=>t.id===e.id);r&&b&&b(r,n,t),F(t)},L=e=>{A(e.id);let t=T.map(t=>t.id===e.id?{...t,selected:!1}:t),n=t.filter(e=>e.selected),r=t.find(t=>t.id===e.id);r&&x&&x(r,n,t),F(t)},R=(0,f.useRef)(null);return(0,f.useEffect)(()=>()=>{R.current&&clearTimeout(R.current)},[]),(0,_.jsx)(d.Box,{sx:{width:`100%`},className:[rt.root,s&&Be.disabled].filter(Boolean).join(` `),children:(0,_.jsxs)(d.Stack,{children:[t&&(0,_.jsx)(jr,{selectedTags:M,translation:y,onTagDelete:L,showSelectedTagsLabel:n,chipSize:a,chipVariant:o,disabled:s,maxVisibleChips:p,popoverPlacement:m}),r&&(0,_.jsx)(kr,{availableTags:N,searchValue:E,translation:y,onSearchChange:e=>{if(O(e),C){if(R.current&&=(clearTimeout(R.current),null),!g){C(e);return}R.current=setTimeout(()=>{C(e),R.current=null},g)}},onTagSelect:I,onTagCreate:e=>{j(e),F([...T,e]),w&&w(e)},inputSize:i,chipSize:a,chipVariant:o,disabled:s,loading:c,isMaxReached:P,allowCreate:u,listboxMaxHeight:h,serverSideFilter:v})]})})}function Ir({tags:e,showSelectedTags:t=!0,showSelectedTagsLabel:n=!0,showAutoComplete:r=!0,translation:i,inputSize:a=`medium`,chipSize:o=`small`,chipVariant:s=`filled`,disabled:c=!1,loading:l=!1,maxTags:u,allowCreate:d=!1,maxVisibleChips:p,popoverPlacement:m=`bottom`,listboxMaxHeight:h,searchDebounceMs:g,serverSideFilter:v=!1,onTagSelect:y,onTagDelete:b,onTagsChange:x,onSearchChange:S,onTagCreate:C}){let w={...Mr,...i},[T]=(0,f.useState)(()=>xr(e));return(0,_.jsx)(Nr.Provider,{value:T,children:(0,_.jsx)(Fr,{tags:e,showSelectedTags:t,showSelectedTagsLabel:n,showAutoComplete:r,translation:w,inputSize:a,chipSize:o,chipVariant:s,disabled:c,loading:l,maxTags:u,allowCreate:d,maxVisibleChips:p,popoverPlacement:m,listboxMaxHeight:h,searchDebounceMs:g,serverSideFilter:v,onTagSelect:y,onTagDelete:b,onTagsChange:x,onSearchChange:S,onTagCreate:C})})}var Lr={showBold:!0,showItalic:!0,showUnderline:!0,showStrike:!0,showHeading1:!0,showHeading2:!0,showHeading3:!0,showBulletList:!0,showOrderedList:!0,showBlockquote:!0,showCodeBlock:!0,showLink:!0,showHorizontalRule:!0,showTextColor:!0,showHighlight:!0,showUndoRedo:!0,showClearFormat:!0,showFullscreenButton:!1,showTableButton:!1,showImageButton:!1,showEmojiButton:!1,showPasteAsPlainTextButton:!1,showMarkdownButton:!1},Rr={bold:`Bold`,italic:`Italic`,underline:`Underline`,strike:`Strikethrough`,heading1:`Heading 1`,heading2:`Heading 2`,heading3:`Heading 3`,bulletList:`Bullet list`,orderedList:`Numbered list`,blockquote:`Blockquote`,codeBlock:`Code block`,link:`Insert link`,horizontalRule:`Horizontal rule`,textColor:`Text color`,removeTextColor:`Remove text color`,highlight:`Highlight`,removeHighlight:`Remove highlight`,undo:`Undo`,redo:`Redo`,clearFormat:`Clear formatting`,linkDialogTitle:`Insert link`,linkDialogUrlLabel:`URL`,linkDialogSave:`Save`,linkDialogCancel:`Cancel`,linkDialogRemove:`Remove link`,characterCount:`{count} characters`,characterCountMax:`{count} / {max} characters`,wordCount:`{count} words`,fullscreen:`Full screen`,exitFullscreen:`Exit full screen`,table:`Table`,insertTable:`Insert 3×3 table`,addRowBefore:`Add row before`,addRowAfter:`Add row after`,deleteRow:`Delete row`,addColumnBefore:`Add column before`,addColumnAfter:`Add column after`,deleteColumn:`Delete column`,deleteTable:`Delete table`,image:`Insert image`,imageDialogTitle:`Insert image`,imageDialogUrlLabel:`Image URL`,imageDialogAltLabel:`Alt text (optional)`,imageDialogSave:`Insert`,imageDialogCancel:`Cancel`,emoji:`Emoji`,emojiSearchPlaceholder:`Search emoji…`,pasteAsPlainText:`Paste as plain text`,pasteAsHtml:`Paste with formatting`,markdown:`Markdown`,markdownDialogTitle:`Markdown`,markdownDialogDescription:`Edit as Markdown, then apply to replace the editor content. Copy to export.`,markdownDialogApply:`Apply`,markdownDialogCancel:`Cancel`,markdownDialogCopy:`Copy`,markdownDialogCopied:`Copied!`,mentionNoResults:`No results`},zr=(0,f.forwardRef)(function({items:e,noResultsLabel:t,clientRect:n,onSelect:r},i){let[a,o]=(0,f.useState)(0),[s,c]=(0,f.useState)(e),l=(0,f.useRef)(null);e!==s&&(c(e),o(0)),(0,f.useEffect)(()=>{(l.current?.children[a])?.scrollIntoView({block:`nearest`})},[a]),(0,f.useImperativeHandle)(i,()=>({onKeyDown(t){return t.key===`ArrowUp`?(o(t=>(t-1+e.length)%e.length),!0):t.key===`ArrowDown`?(o(t=>(t+1)%e.length),!0):t.key===`Enter`?(e[a]&&r(e[a]),!0):!1}}));let u=n?{getBoundingClientRect:n}:null;return(0,_.jsx)(d.Popper,{open:!!u,anchorEl:u,placement:`bottom-start`,modifiers:[{name:`offset`,options:{offset:[0,4]}}],style:{zIndex:1400},children:(0,_.jsx)(d.Paper,{elevation:4,sx:{maxHeight:240,overflow:`auto`,minWidth:180},children:e.length===0?(0,_.jsx)(d.Typography,{variant:`body2`,sx:{px:2,py:1,color:`text.secondary`},children:t}):(0,_.jsx)(d.List,{ref:l,dense:!0,disablePadding:!0,children:e.map((e,t)=>(0,_.jsx)(d.ListItemButton,{selected:t===a,onMouseDown:t=>{t.preventDefault(),r(e)},onMouseEnter:()=>o(t),children:e.label},e.id))})})})});function Br(e,t){return n=>{e({id:n.id,label:n.label}),t?.(n)}}function Vr({getItems:e,onMentionSearch:t,onMentionInserted:n,noResultsLabel:r}){return{items:async({query:n})=>{if(t)return t(n);let r=e(),i=n.toLowerCase();return r.filter(e=>e.label.toLowerCase().includes(i))},render(){let e=null;return{onStart(t){e=new X.ReactRenderer(zr,{props:{items:t.items,noResultsLabel:r,clientRect:t.clientRect,onSelect:Br(t.command,n)},editor:t.editor}),document.body.appendChild(e.element)},onUpdate(t){e?.updateProps({items:t.items,clientRect:t.clientRect})},onKeyDown(t){return t.event.key===`Escape`?(e?.destroy(),e=null,!0):e?.ref?.onKeyDown(t.event)??!1},onExit(){e?.element.remove(),e?.destroy(),e=null}}}}}function Hr({editor:e,error:t,disabled:n,readonly:r}){return(0,_.jsx)(d.Box,{sx:{flex:1,minHeight:0,display:`flex`,flexDirection:`column`,px:1.5,py:1,cursor:n||r?`default`:`text`,opacity:n?.5:1,"& > div":{flex:1,display:`flex`,flexDirection:`column`,minHeight:0},"& .ProseMirror":{flex:1,minHeight:0,overflowY:`auto`,overflowX:`hidden`,wordBreak:`break-word`,overflowWrap:`break-word`,outline:`none`,"& p.is-editor-empty:first-of-type::before":{content:`attr(data-placeholder)`,color:`text.disabled`,pointerEvents:`none`,float:`left`,height:0},"& h1":{typography:`h4`,mb:1},"& h2":{typography:`h5`,mb:1},"& h3":{typography:`h6`,mb:1},"& p":{my:.5},"& ul, & ol":{pl:3},"& blockquote":{borderLeft:`4px solid`,borderColor:t?`error.main`:`divider`,pl:2,color:`text.secondary`,my:1},"& code":{bgcolor:`action.hover`,px:.5,borderRadius:.5,fontFamily:`monospace`,fontSize:`0.875em`},"& pre":{bgcolor:`action.hover`,p:1.5,borderRadius:1,overflowX:`auto`,"& code":{bgcolor:`transparent`,px:0}},"& a":{color:`primary.main`,cursor:`pointer`},"& mark":{borderRadius:.5,px:.25},"& hr":{borderColor:`divider`,my:2},"& table":{borderCollapse:`collapse`,tableLayout:`fixed`,width:`100%`,margin:`8px 0`,overflowX:`auto`},"& table td, & table th":{border:`1px solid`,borderColor:`divider`,padding:`6px 8px`,verticalAlign:`top`,boxSizing:`border-box`,minWidth:`2em`,position:`relative`},"& table th":{fontWeight:`bold`,bgcolor:`action.hover`},"& table .selectedCell::after":{content:`""`,position:`absolute`,inset:0,bgcolor:`primary.main`,opacity:.12,pointerEvents:`none`,zIndex:2},"& img":{maxWidth:`100%`,height:`auto`,borderRadius:`4px`,display:`block`,my:1}}},children:(0,_.jsx)(X.EditorContent,{editor:e})})}function Ur({open:e,onClose:t,editor:n,translation:r}){let[i,a]=(0,f.useState)(``);(0,f.useEffect)(()=>{if(e){let e=n.getAttributes(`link`).href;a(e??``)}},[e,n]);let o=n.isActive(`link`);function s(){i.trim()?n.chain().focus().extendMarkRange(`link`).setLink({href:i.trim()}).run():n.chain().focus().extendMarkRange(`link`).unsetLink().run(),t()}function c(){n.chain().focus().extendMarkRange(`link`).unsetLink().run(),t()}function l(e){e.key===`Enter`&&s()}return(0,_.jsxs)(d.Dialog,{open:e,onClose:t,maxWidth:`sm`,fullWidth:!0,children:[(0,_.jsx)(d.DialogTitle,{children:r.linkDialogTitle}),(0,_.jsx)(d.DialogContent,{children:(0,_.jsx)(d.TextField,{autoFocus:!0,fullWidth:!0,label:r.linkDialogUrlLabel,value:i,onChange:e=>a(e.target.value),onKeyDown:l,variant:`outlined`,size:`small`,sx:{mt:1},placeholder:`https://`})}),(0,_.jsxs)(d.DialogActions,{sx:{px:3,pb:2,gap:1},children:[o&&(0,_.jsx)(d.Button,{onClick:c,color:`error`,sx:{mr:`auto`},children:r.linkDialogRemove}),(0,_.jsx)(d.Button,{onClick:t,children:r.linkDialogCancel}),(0,_.jsx)(d.Button,{onClick:s,variant:`contained`,children:r.linkDialogSave})]})]})}var Wr=[`#000000`,`#434343`,`#666666`,`#999999`,`#b7b7b7`,`#ffffff`,`#ff0000`,`#ff4500`,`#ff8c00`,`#ffd700`,`#9acd32`,`#008000`,`#00ced1`,`#1e90ff`,`#0000ff`,`#8a2be2`,`#ff1493`,`#a52a2a`],Gr=[`#ffff00`,`#ffd700`,`#ffa500`,`#ff69b4`,`#ff6347`,`#fa8072`,`#adff2f`,`#90ee90`,`#00fa9a`,`#00ffff`,`#87ceeb`,`#add8e6`,`#dda0dd`,`#ee82ee`,`#d2b48c`,`#f5f5dc`,`#ffffff`,`#000000`];function Kr({color:e,active:t,onClick:n}){return(0,_.jsx)(d.Tooltip,{title:e,placement:`top`,arrow:!0,children:(0,_.jsx)(d.Box,{component:`button`,type:`button`,onClick:()=>n(e),"aria-label":e,"aria-pressed":t,sx:{width:22,height:22,bgcolor:e,border:t?`2px solid`:`1px solid`,borderColor:t?`primary.main`:e===`#ffffff`||e===`#f5f5dc`?`divider`:`transparent`,borderRadius:.5,cursor:`pointer`,p:0,display:`flex`,alignItems:`center`,justifyContent:`center`,transition:`transform 0.1s`,"&:hover":{transform:`scale(1.2)`,zIndex:1}},children:t&&(0,_.jsx)(d.Box,{component:`span`,sx:{width:10,height:6,borderLeft:`2px solid`,borderBottom:`2px solid`,borderColor:e===`#ffffff`||e===`#f5f5dc`||e===`#ffd700`||e===`#ffff00`||e===`#adff2f`||e===`#ffa500`||e===`#b7b7b7`||e===`#d2b48c`?`#000`:`#fff`,transform:`rotate(-45deg) translateY(-1px)`,display:`block`}})})})}function qr({anchorEl:e,open:t,onClose:n,mode:r,activeColor:i,onSelectColor:a,onRemoveColor:o,removeLabel:s}){let c=(0,f.useRef)(null),l=r===`highlight`?Gr:Wr;function u(e){a(e.target.value)}return(0,_.jsxs)(d.Popover,{open:t,anchorEl:e,onClose:n,anchorOrigin:{vertical:`bottom`,horizontal:`left`},transformOrigin:{vertical:`top`,horizontal:`left`},slotProps:{paper:{sx:{p:1.5}}},children:[(0,_.jsx)(d.Box,{sx:{display:`grid`,gridTemplateColumns:`repeat(6, 22px)`,gap:.5,mb:1},children:l.map(e=>(0,_.jsx)(Kr,{color:e,active:i?.toLowerCase()===e.toLowerCase(),onClick:e=>{a(e),n()}},e))}),(0,_.jsxs)(d.Box,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,_.jsx)(d.Tooltip,{title:`Custom color`,arrow:!0,children:(0,_.jsx)(d.Box,{component:`button`,type:`button`,onClick:()=>c.current?.click(),"aria-label":`Custom color`,sx:{width:22,height:22,background:`conic-gradient(red, yellow, lime, cyan, blue, magenta, red)`,border:`1px solid`,borderColor:`divider`,borderRadius:.5,cursor:`pointer`,p:0,flexShrink:0,"&:hover":{transform:`scale(1.2)`},transition:`transform 0.1s`}})}),(0,_.jsx)(`input`,{ref:c,type:`color`,defaultValue:i??`#000000`,onChange:u,onBlur:n,style:{visibility:`hidden`,width:0,height:0,position:`absolute`}}),(0,_.jsx)(d.Tooltip,{title:s,arrow:!0,children:(0,_.jsx)(d.IconButton,{size:`small`,onClick:()=>{o(),n()},"aria-label":s,sx:{borderRadius:1,ml:`auto`},children:(0,_.jsx)(je.default,{fontSize:`small`})})})]})]})}function Jr({editor:e,translation:t,disabled:n}){let[r,i]=(0,f.useState)(null),a=n||!e,o=e?.isActive(`table`)??!1;function s(){i(null)}function c(e){e(),s()}return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(d.Tooltip,{title:t.table,arrow:!0,children:(0,_.jsx)(`span`,{children:(0,_.jsx)(d.IconButton,{size:`small`,onMouseDown:e=>e.preventDefault(),onClick:e=>i(e.currentTarget),disabled:a,color:o?`primary`:`default`,sx:{borderRadius:1},"aria-label":t.table,"aria-pressed":o,children:(0,_.jsx)(Me.default,{fontSize:`small`})})})}),(0,_.jsxs)(d.Menu,{anchorEl:r,open:!!r,onClose:s,slotProps:{paper:{sx:{minWidth:220}}},children:[(0,_.jsxs)(d.MenuItem,{onClick:()=>c(()=>e?.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()),children:[(0,_.jsx)(d.ListItemIcon,{children:(0,_.jsx)(Me.default,{fontSize:`small`})}),(0,_.jsx)(d.ListItemText,{children:t.insertTable})]}),o&&(0,_.jsx)(d.Divider,{}),o&&(0,_.jsxs)(d.MenuItem,{onClick:()=>c(()=>e?.chain().focus().addRowBefore().run()),children:[(0,_.jsx)(d.ListItemIcon,{children:(0,_.jsx)(y.default,{fontSize:`small`})}),(0,_.jsx)(d.ListItemText,{children:t.addRowBefore})]}),o&&(0,_.jsxs)(d.MenuItem,{onClick:()=>c(()=>e?.chain().focus().addRowAfter().run()),children:[(0,_.jsx)(d.ListItemIcon,{children:(0,_.jsx)(y.default,{fontSize:`small`})}),(0,_.jsx)(d.ListItemText,{children:t.addRowAfter})]}),o&&(0,_.jsxs)(d.MenuItem,{onClick:()=>c(()=>e?.chain().focus().deleteRow().run()),children:[(0,_.jsx)(d.ListItemIcon,{children:(0,_.jsx)(v.default,{fontSize:`small`,color:`error`})}),(0,_.jsx)(d.ListItemText,{sx:{color:`error.main`},children:t.deleteRow})]}),o&&(0,_.jsx)(d.Divider,{}),o&&(0,_.jsxs)(d.MenuItem,{onClick:()=>c(()=>e?.chain().focus().addColumnBefore().run()),children:[(0,_.jsx)(d.ListItemIcon,{children:(0,_.jsx)(y.default,{fontSize:`small`})}),(0,_.jsx)(d.ListItemText,{children:t.addColumnBefore})]}),o&&(0,_.jsxs)(d.MenuItem,{onClick:()=>c(()=>e?.chain().focus().addColumnAfter().run()),children:[(0,_.jsx)(d.ListItemIcon,{children:(0,_.jsx)(y.default,{fontSize:`small`})}),(0,_.jsx)(d.ListItemText,{children:t.addColumnAfter})]}),o&&(0,_.jsxs)(d.MenuItem,{onClick:()=>c(()=>e?.chain().focus().deleteColumn().run()),children:[(0,_.jsx)(d.ListItemIcon,{children:(0,_.jsx)(v.default,{fontSize:`small`,color:`error`})}),(0,_.jsx)(d.ListItemText,{sx:{color:`error.main`},children:t.deleteColumn})]}),o&&(0,_.jsx)(d.Divider,{}),o&&(0,_.jsxs)(d.MenuItem,{onClick:()=>c(()=>e?.chain().focus().deleteTable().run()),children:[(0,_.jsx)(d.ListItemIcon,{children:(0,_.jsx)(v.default,{fontSize:`small`,color:`error`})}),(0,_.jsx)(d.ListItemText,{sx:{color:`error.main`},children:t.deleteTable})]})]})]})}function Yr({open:e,onClose:t,editor:n,translation:r}){let[i,a]=(0,f.useState)(``),[o,s]=(0,f.useState)(``);function c(){let e=i.trim();e&&(n.chain().focus().setImage({src:e,alt:o.trim()||void 0}).run(),a(``),s(``),t())}function l(){a(``),s(``),t()}function u(e){e.key===`Enter`&&c()}return(0,_.jsxs)(d.Dialog,{open:e,onClose:l,maxWidth:`sm`,fullWidth:!0,children:[(0,_.jsx)(d.DialogTitle,{children:r.imageDialogTitle}),(0,_.jsxs)(d.DialogContent,{sx:{display:`flex`,flexDirection:`column`,gap:2,pt:`16px !important`},children:[(0,_.jsx)(d.TextField,{autoFocus:!0,fullWidth:!0,label:r.imageDialogUrlLabel,value:i,onChange:e=>a(e.target.value),onKeyDown:u,variant:`outlined`,size:`small`,placeholder:`https://example.com/image.png`}),(0,_.jsx)(d.TextField,{fullWidth:!0,label:r.imageDialogAltLabel,value:o,onChange:e=>s(e.target.value),onKeyDown:u,variant:`outlined`,size:`small`})]}),(0,_.jsxs)(d.DialogActions,{sx:{px:3,pb:2,gap:1},children:[(0,_.jsx)(d.Button,{onClick:l,children:r.imageDialogCancel}),(0,_.jsx)(d.Button,{onClick:c,variant:`contained`,disabled:!i.trim(),children:r.imageDialogSave})]})]})}var Xr=[{label:`Smileys`,emojis:[{emoji:`😀`,name:`grinning face`},{emoji:`😃`,name:`grinning face with big eyes`},{emoji:`😄`,name:`grinning face with smiling eyes`},{emoji:`😁`,name:`beaming face with smiling eyes`},{emoji:`😆`,name:`grinning squinting face`},{emoji:`😅`,name:`grinning face with sweat`},{emoji:`😂`,name:`face with tears of joy`},{emoji:`🤣`,name:`rolling on the floor laughing`},{emoji:`😊`,name:`smiling face with smiling eyes`},{emoji:`😇`,name:`smiling face with halo`},{emoji:`🙂`,name:`slightly smiling face`},{emoji:`😉`,name:`winking face`},{emoji:`😍`,name:`smiling face with heart eyes`},{emoji:`🥰`,name:`smiling face with hearts`},{emoji:`😘`,name:`face blowing a kiss`},{emoji:`😋`,name:`face savoring food`},{emoji:`😎`,name:`smiling face with sunglasses`},{emoji:`🤩`,name:`star struck`},{emoji:`🥳`,name:`partying face`},{emoji:`😏`,name:`smirking face`},{emoji:`😒`,name:`unamused face`},{emoji:`😔`,name:`pensive face`},{emoji:`😢`,name:`crying face`},{emoji:`😭`,name:`loudly crying face`},{emoji:`😤`,name:`face with steam from nose`},{emoji:`😠`,name:`angry face`},{emoji:`🤬`,name:`face with symbols on mouth`},{emoji:`😱`,name:`face screaming in fear`},{emoji:`😳`,name:`flushed face`},{emoji:`🤔`,name:`thinking face`},{emoji:`🙄`,name:`face with rolling eyes`},{emoji:`😴`,name:`sleeping face`},{emoji:`🤢`,name:`nauseated face`},{emoji:`🤧`,name:`sneezing face`},{emoji:`😷`,name:`face with medical mask`}]},{label:`Gestures`,emojis:[{emoji:`👋`,name:`waving hand`},{emoji:`🤚`,name:`raised back of hand`},{emoji:`✋`,name:`raised hand`},{emoji:`🖐️`,name:`hand with fingers splayed`},{emoji:`👌`,name:`ok hand`},{emoji:`✌️`,name:`victory hand`},{emoji:`🤞`,name:`crossed fingers`},{emoji:`🤙`,name:`call me hand`},{emoji:`👈`,name:`backhand index pointing left`},{emoji:`👉`,name:`backhand index pointing right`},{emoji:`👆`,name:`backhand index pointing up`},{emoji:`👇`,name:`backhand index pointing down`},{emoji:`☝️`,name:`index pointing up`},{emoji:`👍`,name:`thumbs up`},{emoji:`👎`,name:`thumbs down`},{emoji:`✊`,name:`raised fist`},{emoji:`👊`,name:`oncoming fist`},{emoji:`👏`,name:`clapping hands`},{emoji:`🙌`,name:`raising hands`},{emoji:`🤝`,name:`handshake`},{emoji:`🙏`,name:`folded hands`},{emoji:`💪`,name:`flexed biceps`},{emoji:`🦾`,name:`mechanical arm`},{emoji:`👀`,name:`eyes`},{emoji:`👁️`,name:`eye`},{emoji:`👅`,name:`tongue`},{emoji:`💋`,name:`kiss mark`}]},{label:`Hearts & Symbols`,emojis:[{emoji:`❤️`,name:`red heart`},{emoji:`🧡`,name:`orange heart`},{emoji:`💛`,name:`yellow heart`},{emoji:`💚`,name:`green heart`},{emoji:`💙`,name:`blue heart`},{emoji:`💜`,name:`purple heart`},{emoji:`🖤`,name:`black heart`},{emoji:`🤍`,name:`white heart`},{emoji:`💔`,name:`broken heart`},{emoji:`💕`,name:`two hearts`},{emoji:`💞`,name:`revolving hearts`},{emoji:`💖`,name:`sparkling heart`},{emoji:`💘`,name:`heart with arrow`},{emoji:`💝`,name:`heart with ribbon`},{emoji:`✨`,name:`sparkles`},{emoji:`⭐`,name:`star`},{emoji:`🌟`,name:`glowing star`},{emoji:`💫`,name:`dizzy`},{emoji:`🔥`,name:`fire`},{emoji:`💧`,name:`droplet`},{emoji:`💯`,name:`hundred points`},{emoji:`✅`,name:`check mark button`},{emoji:`❌`,name:`cross mark`},{emoji:`⚠️`,name:`warning`},{emoji:`🎉`,name:`party popper`},{emoji:`🎊`,name:`confetti ball`},{emoji:`🏆`,name:`trophy`},{emoji:`🥇`,name:`first place medal`}]},{label:`Nature`,emojis:[{emoji:`🐶`,name:`dog face`},{emoji:`🐱`,name:`cat face`},{emoji:`🐭`,name:`mouse face`},{emoji:`🐹`,name:`hamster`},{emoji:`🐰`,name:`rabbit face`},{emoji:`🦊`,name:`fox`},{emoji:`🐻`,name:`bear`},{emoji:`🐼`,name:`panda`},{emoji:`🐨`,name:`koala`},{emoji:`🐯`,name:`tiger face`},{emoji:`🦁`,name:`lion`},{emoji:`🐸`,name:`frog`},{emoji:`🐧`,name:`penguin`},{emoji:`🐦`,name:`bird`},{emoji:`🦋`,name:`butterfly`},{emoji:`🌸`,name:`cherry blossom`},{emoji:`🌺`,name:`hibiscus`},{emoji:`🌻`,name:`sunflower`},{emoji:`🌹`,name:`rose`},{emoji:`🌿`,name:`herb`},{emoji:`🍀`,name:`four leaf clover`},{emoji:`🌲`,name:`evergreen tree`},{emoji:`🌴`,name:`palm tree`},{emoji:`🌊`,name:`water wave`},{emoji:`🌈`,name:`rainbow`},{emoji:`☀️`,name:`sun`},{emoji:`🌙`,name:`crescent moon`},{emoji:`❄️`,name:`snowflake`},{emoji:`⚡`,name:`lightning`},{emoji:`🌪️`,name:`tornado`}]},{label:`Food`,emojis:[{emoji:`🍎`,name:`red apple`},{emoji:`🍊`,name:`tangerine`},{emoji:`🍋`,name:`lemon`},{emoji:`🍇`,name:`grapes`},{emoji:`🍓`,name:`strawberry`},{emoji:`🍒`,name:`cherries`},{emoji:`🍑`,name:`peach`},{emoji:`🥭`,name:`mango`},{emoji:`🍍`,name:`pineapple`},{emoji:`🥥`,name:`coconut`},{emoji:`🥝`,name:`kiwi fruit`},{emoji:`🍅`,name:`tomato`},{emoji:`🥑`,name:`avocado`},{emoji:`🌽`,name:`ear of corn`},{emoji:`🍕`,name:`pizza`},{emoji:`🍔`,name:`hamburger`},{emoji:`🌮`,name:`taco`},{emoji:`🍜`,name:`steaming bowl`},{emoji:`🍣`,name:`sushi`},{emoji:`🍩`,name:`doughnut`},{emoji:`🎂`,name:`birthday cake`},{emoji:`🍰`,name:`shortcake`},{emoji:`🍦`,name:`soft ice cream`},{emoji:`🍫`,name:`chocolate bar`},{emoji:`☕`,name:`hot beverage`},{emoji:`🧃`,name:`beverage box`},{emoji:`🍺`,name:`beer mug`},{emoji:`🥂`,name:`clinking glasses`}]},{label:`Objects & Travel`,emojis:[{emoji:`📱`,name:`mobile phone`},{emoji:`💻`,name:`laptop`},{emoji:`🖥️`,name:`desktop computer`},{emoji:`⌨️`,name:`keyboard`},{emoji:`📷`,name:`camera`},{emoji:`📺`,name:`television`},{emoji:`🎮`,name:`video game`},{emoji:`🎸`,name:`guitar`},{emoji:`🎹`,name:`musical keyboard`},{emoji:`📚`,name:`books`},{emoji:`📝`,name:`memo`},{emoji:`✏️`,name:`pencil`},{emoji:`🔍`,name:`magnifying glass tilted left`},{emoji:`💡`,name:`light bulb`},{emoji:`🔑`,name:`key`},{emoji:`🔒`,name:`locked`},{emoji:`⚙️`,name:`gear`},{emoji:`🔧`,name:`wrench`},{emoji:`🏠`,name:`house`},{emoji:`🏢`,name:`office building`},{emoji:`✈️`,name:`airplane`},{emoji:`🚀`,name:`rocket`},{emoji:`🚗`,name:`automobile`},{emoji:`🚲`,name:`bicycle`},{emoji:`⛵`,name:`sailboat`},{emoji:`🗺️`,name:`world map`},{emoji:`🏔️`,name:`snow capped mountain`},{emoji:`🏖️`,name:`beach with umbrella`}]}];function Zr({anchorEl:e,open:t,onClose:n,onSelect:r,translation:i}){let[a,o]=(0,f.useState)(``),s=(0,f.useMemo)(()=>{let e=a.trim().toLowerCase();return e?Xr.map(t=>({...t,emojis:t.emojis.filter(t=>t.name.includes(e)||t.emoji===e)})).filter(e=>e.emojis.length>0):Xr},[a]);function c(e){r(e),n(),o(``)}function l(){n(),o(``)}return(0,_.jsxs)(d.Popover,{open:t,anchorEl:e,onClose:l,anchorOrigin:{vertical:`bottom`,horizontal:`left`},transformOrigin:{vertical:`top`,horizontal:`left`},slotProps:{paper:{sx:{width:320,maxHeight:380,display:`flex`,flexDirection:`column`}}},children:[(0,_.jsx)(d.Box,{sx:{p:1,borderBottom:1,borderColor:`divider`},children:(0,_.jsx)(d.TextField,{autoFocus:!0,fullWidth:!0,size:`small`,placeholder:i.emojiSearchPlaceholder,value:a,onChange:e=>o(e.target.value),slotProps:{input:{startAdornment:(0,_.jsx)(d.InputAdornment,{position:`start`,children:(0,_.jsx)(u.default,{fontSize:`small`})})}}})}),(0,_.jsxs)(d.Box,{sx:{overflowY:`auto`,flex:1,px:1,pb:1},children:[s.map(e=>(0,_.jsxs)(d.Box,{children:[(0,_.jsx)(d.Typography,{variant:`caption`,sx:{display:`block`,color:`text.secondary`,mt:1,mb:.5,px:.5},children:e.label}),(0,_.jsx)(d.Box,{sx:{display:`flex`,flexWrap:`wrap`,gap:.25},children:e.emojis.map(e=>(0,_.jsx)(d.Box,{component:`button`,title:e.name,"aria-label":e.name,onClick:()=>c(e.emoji),sx:{border:`none`,background:`none`,cursor:`pointer`,fontSize:`1.375rem`,lineHeight:1,p:.5,borderRadius:1,"&:hover":{bgcolor:`action.hover`}},children:e.emoji},e.emoji))})]},e.label)),s.length===0&&(0,_.jsx)(d.Typography,{variant:`body2`,color:`text.secondary`,sx:{p:2,textAlign:`center`},children:`No emoji found`})]})]})}function Qr({open:e,onClose:t,editor:n,translation:r}){let[i,a]=(0,f.useState)(``),[o,s]=Yt();(0,f.useEffect)(()=>{e&&a(n.storage.markdown.getMarkdown())},[e,n]);function c(){n.commands.setContent(i),t()}function l(){navigator.clipboard.writeText(i).then(()=>{s()})}return(0,_.jsxs)(d.Dialog,{open:e,onClose:t,maxWidth:`sm`,fullWidth:!0,children:[(0,_.jsx)(d.DialogTitle,{children:r.markdownDialogTitle}),(0,_.jsxs)(d.DialogContent,{sx:{display:`flex`,flexDirection:`column`,gap:1.5,pt:`16px !important`},children:[(0,_.jsx)(d.Typography,{variant:`body2`,color:`text.secondary`,children:r.markdownDialogDescription}),(0,_.jsx)(d.TextField,{autoFocus:!0,fullWidth:!0,multiline:!0,minRows:8,maxRows:16,value:i,onChange:e=>a(e.target.value),variant:`outlined`,size:`small`,sx:{fontFamily:`monospace`},slotProps:{htmlInput:{style:{fontFamily:`monospace`,fontSize:`0.8125rem`}}}})]}),(0,_.jsxs)(d.DialogActions,{sx:{px:3,pb:2,gap:1},children:[(0,_.jsx)(d.Box,{sx:{flex:1},children:(0,_.jsx)(d.Button,{onClick:l,startIcon:o?(0,_.jsx)(j.default,{fontSize:`small`,color:`success`}):(0,_.jsx)(k.default,{fontSize:`small`}),children:o?r.markdownDialogCopied:r.markdownDialogCopy})}),(0,_.jsx)(d.Button,{onClick:t,children:r.markdownDialogCancel}),(0,_.jsx)(d.Button,{onClick:c,variant:`contained`,children:r.markdownDialogApply})]})]})}function $r({label:e,icon:t,activeColor:n,disabled:r,onClick:i}){return(0,_.jsx)(d.Tooltip,{title:e,arrow:!0,children:(0,_.jsx)(`span`,{children:(0,_.jsxs)(d.IconButton,{size:`small`,onMouseDown:e=>e.preventDefault(),onClick:i,disabled:r,sx:{borderRadius:1,flexDirection:`column`,gap:0,pb:.25},"aria-label":e,children:[(0,_.jsx)(d.Box,{sx:{display:`flex`,alignItems:`center`},children:t}),(0,_.jsx)(d.Box,{sx:{width:`80%`,height:3,bgcolor:n??`text.primary`,borderRadius:.5,mt:`1px`}})]})})})}function ei({text:e}){return(0,_.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 20 20`,"aria-hidden":`true`,style:{display:`block`},children:(0,_.jsx)(`text`,{x:`10`,y:`10`,dominantBaseline:`central`,textAnchor:`middle`,fontSize:`10`,fontWeight:`500`,fontFamily:`inherit`,fill:`currentColor`,children:e})})}function ti({level:e}){return(0,_.jsx)(ei,{text:`H${e}`})}function ni({editor:e,toolbarConfig:t,translation:n,disabled:r,isFullscreen:i,onToggleFullscreen:a,pasteAsPlainText:o,onTogglePasteAsPlainText:s}){let[c,l]=(0,f.useState)(!1),[u,p]=(0,f.useState)(!1),[m,h]=(0,f.useState)(!1),[g,v]=(0,f.useState)(null),[y,b]=(0,f.useState)(null),[x,S]=(0,f.useState)(null),C=r||!e,w=e?.getAttributes(`textStyle`)?.color,T=e?.getAttributes(`highlight`)?.color,E=t.showBold||t.showItalic||t.showUnderline||t.showStrike,D=t.showHeading1||t.showHeading2||t.showHeading3,O=t.showBulletList||t.showOrderedList,k=t.showBlockquote||t.showCodeBlock||t.showLink||t.showHorizontalRule,A=t.showTextColor||t.showHighlight,j=t.showUndoRedo||t.showClearFormat,P=t.showTableButton||t.showImageButton||t.showEmojiButton,F=[E,D,O,k,A,j,P],I=F.filter(Boolean).length;function L(e,t){return!e||F.slice(t+1).findIndex(Boolean)===-1?null:(0,_.jsx)(d.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}},`div-${t}`)}return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(d.Box,{sx:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:.25,px:1,py:.5},role:`toolbar`,"aria-label":`Text formatting`,children:[E&&(0,_.jsxs)(d.Box,{sx:{display:`flex`,gap:.25},children:[t.showBold&&(0,_.jsx)(Q,{label:n.bold,icon:(0,_.jsx)(ge.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleBold().run(),active:e?.isActive(`bold`),disabled:C}),t.showItalic&&(0,_.jsx)(Q,{label:n.italic,icon:(0,_.jsx)(_e.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleItalic().run(),active:e?.isActive(`italic`),disabled:C}),t.showUnderline&&(0,_.jsx)(Q,{label:n.underline,icon:(0,_.jsx)(ve.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleUnderline().run(),active:e?.isActive(`underline`),disabled:C}),t.showStrike&&(0,_.jsx)(Q,{label:n.strike,icon:(0,_.jsx)(ye.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleStrike().run(),active:e?.isActive(`strike`),disabled:C})]}),L(E,0),D&&(0,_.jsxs)(d.Box,{sx:{display:`flex`,gap:.25},children:[t.showHeading1&&(0,_.jsx)(Q,{label:n.heading1,icon:(0,_.jsx)(ti,{level:1}),onClick:()=>e?.chain().focus().toggleHeading({level:1}).run(),active:e?.isActive(`heading`,{level:1}),disabled:C}),t.showHeading2&&(0,_.jsx)(Q,{label:n.heading2,icon:(0,_.jsx)(ti,{level:2}),onClick:()=>e?.chain().focus().toggleHeading({level:2}).run(),active:e?.isActive(`heading`,{level:2}),disabled:C}),t.showHeading3&&(0,_.jsx)(Q,{label:n.heading3,icon:(0,_.jsx)(ti,{level:3}),onClick:()=>e?.chain().focus().toggleHeading({level:3}).run(),active:e?.isActive(`heading`,{level:3}),disabled:C})]}),L(D,1),O&&(0,_.jsxs)(d.Box,{sx:{display:`flex`,gap:.25},children:[t.showBulletList&&(0,_.jsx)(Q,{label:n.bulletList,icon:(0,_.jsx)(be.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleBulletList().run(),active:e?.isActive(`bulletList`),disabled:C}),t.showOrderedList&&(0,_.jsx)(Q,{label:n.orderedList,icon:(0,_.jsx)(xe.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleOrderedList().run(),active:e?.isActive(`orderedList`),disabled:C})]}),L(O,2),k&&(0,_.jsxs)(d.Box,{sx:{display:`flex`,gap:.25},children:[t.showBlockquote&&(0,_.jsx)(Q,{label:n.blockquote,icon:(0,_.jsx)(Se.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleBlockquote().run(),active:e?.isActive(`blockquote`),disabled:C}),t.showCodeBlock&&(0,_.jsx)(Q,{label:n.codeBlock,icon:(0,_.jsx)(Ce.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleCodeBlock().run(),active:e?.isActive(`codeBlock`),disabled:C}),t.showLink&&(0,_.jsx)(Q,{label:n.link,icon:(0,_.jsx)(we.default,{fontSize:`small`}),onClick:()=>l(!0),active:e?.isActive(`link`),disabled:C}),t.showHorizontalRule&&(0,_.jsx)(Q,{label:n.horizontalRule,icon:(0,_.jsx)(Te.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().setHorizontalRule().run(),disabled:C})]}),L(k,3),A&&(0,_.jsxs)(d.Box,{sx:{display:`flex`,gap:.25},children:[t.showTextColor&&(0,_.jsx)($r,{label:n.textColor,icon:(0,_.jsx)(Ee.default,{fontSize:`small`}),activeColor:w,disabled:C,onClick:e=>b(e.currentTarget)}),t.showHighlight&&(0,_.jsx)($r,{label:n.highlight,icon:(0,_.jsx)(De.default,{fontSize:`small`}),activeColor:T,disabled:C,onClick:e=>S(e.currentTarget)})]}),L(A,4),j&&(0,_.jsxs)(d.Box,{sx:{display:`flex`,gap:.25},children:[t.showUndoRedo&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(Q,{label:n.undo,icon:(0,_.jsx)(M.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().undo().run(),disabled:C||!e?.can().undo()}),(0,_.jsx)(Q,{label:n.redo,icon:(0,_.jsx)(N.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().redo().run(),disabled:C||!e?.can().redo()})]}),t.showClearFormat&&(0,_.jsx)(Q,{label:n.clearFormat,icon:(0,_.jsx)(Oe.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().clearNodes().unsetAllMarks().run(),disabled:C})]}),L(j,5),P&&(0,_.jsxs)(d.Box,{sx:{display:`flex`,gap:.25},children:[t.showTableButton&&(0,_.jsx)(Jr,{editor:e,translation:n,disabled:C}),t.showImageButton&&(0,_.jsx)(Q,{label:n.image,icon:(0,_.jsx)(me.default,{fontSize:`small`}),onClick:()=>p(!0),disabled:C}),t.showEmojiButton&&(0,_.jsx)(d.Tooltip,{title:n.emoji,arrow:!0,children:(0,_.jsx)(`span`,{children:(0,_.jsx)(d.IconButton,{size:`small`,onMouseDown:e=>e.preventDefault(),onClick:e=>v(e.currentTarget),disabled:C,sx:{borderRadius:1},"aria-label":n.emoji,children:(0,_.jsx)(he.default,{fontSize:`small`})})})})]}),I===0&&(0,_.jsx)(d.Box,{sx:{height:32}}),(t.showPasteAsPlainTextButton||t.showMarkdownButton||t.showFullscreenButton)&&(0,_.jsxs)(d.Box,{sx:{ml:`auto`,display:`flex`,gap:.25},children:[t.showPasteAsPlainTextButton&&(0,_.jsx)(Q,{label:o?n.pasteAsHtml:n.pasteAsPlainText,icon:o?(0,_.jsx)(Ae.default,{fontSize:`small`}):(0,_.jsx)(ke.default,{fontSize:`small`}),onClick:s,active:o,disabled:r||!e}),t.showMarkdownButton&&(0,_.jsx)(Q,{label:n.markdown,icon:(0,_.jsx)(ei,{text:`MD`}),onClick:()=>h(!0),disabled:r||!e}),t.showFullscreenButton&&(0,_.jsx)(d.Tooltip,{title:i?n.exitFullscreen:n.fullscreen,arrow:!0,children:(0,_.jsx)(`span`,{children:(0,_.jsx)(d.IconButton,{size:`small`,onMouseDown:e=>e.preventDefault(),onClick:a,disabled:r||!e,sx:{borderRadius:1},"aria-label":i?n.exitFullscreen:n.fullscreen,children:i?(0,_.jsx)(pe.default,{fontSize:`small`}):(0,_.jsx)(fe.default,{fontSize:`small`})})})})]})]}),t.showLink&&e&&(0,_.jsx)(Ur,{open:c,onClose:()=>l(!1),editor:e,translation:n}),t.showTextColor&&(0,_.jsx)(qr,{anchorEl:y,open:!!y,onClose:()=>b(null),mode:`textColor`,activeColor:w,onSelectColor:t=>e?.chain().focus().setColor(t).run(),onRemoveColor:()=>e?.chain().focus().unsetColor().run(),removeLabel:n.removeTextColor}),t.showHighlight&&(0,_.jsx)(qr,{anchorEl:x,open:!!x,onClose:()=>S(null),mode:`highlight`,activeColor:T,onSelectColor:t=>e?.chain().focus().setHighlight({color:t}).run(),onRemoveColor:()=>e?.chain().focus().unsetHighlight().run(),removeLabel:n.removeHighlight}),t.showImageButton&&e&&(0,_.jsx)(Yr,{open:u,onClose:()=>p(!1),editor:e,translation:n}),t.showMarkdownButton&&e&&(0,_.jsx)(Qr,{open:m,onClose:()=>h(!1),editor:e,translation:n}),t.showEmojiButton&&(0,_.jsx)(Zr,{anchorEl:g,open:!!g,onClose:()=>v(null),onSelect:t=>e?.chain().focus().insertContent(t).run(),translation:n})]})}function ri({helperText:e,error:t,showCharacterCount:n,charCount:r,maxCharacters:i,showWordCount:a,wordCount:o,translation:s}){let c=i===void 0?s.characterCount.replace(`{count}`,String(r)):s.characterCountMax.replace(`{count}`,String(r)).replace(`{max}`,String(i)),l=i!==void 0&&r>=i?`error`:`text.secondary`,u=s.wordCount.replace(`{count}`,String(o));return(0,_.jsxs)(d.Box,{sx:{display:`flex`,justifyContent:`space-between`,mt:.5,px:.5},children:[(0,_.jsx)(d.FormHelperText,{error:t,children:e??``}),(n||a)&&(0,_.jsxs)(d.Box,{sx:{display:`flex`,gap:1.5,alignItems:`center`},children:[a&&(0,_.jsx)(d.FormHelperText,{sx:{color:`text.secondary`},children:u}),n&&(0,_.jsx)(d.FormHelperText,{sx:{color:l},children:c})]})]})}function ii({defaultValue:e,disabled:t=!1,error:n=!1,height:r,helperText:i,maxCharacters:a,mentionItems:o,mentionTriggerChar:s=`@`,name:c,onMentionInserted:l,onMentionSearch:u,placeholder:p,readonly:m=!1,showCharacterCount:h=!1,showToolbar:g=!0,showWordCount:v=!1,toolbarConfig:y,translation:b,value:x,width:S,onBlur:C,onChange:w,onFocus:T,onMarkdownChange:E,onSave:D}){let O={...Rr,...b},k={...Lr,...y},[A,j]=(0,f.useState)(!1),[M,N]=(0,f.useState)(!1),P=(0,f.useRef)(M),F=(0,f.useRef)(D),I=(0,f.useRef)(o??[]);(0,f.useEffect)(()=>{I.current=o??[]},[o]);let L=(0,f.useRef)(l);(0,f.useEffect)(()=>{L.current=l},[l]),(0,f.useEffect)(()=>{P.current=M},[M]),(0,f.useEffect)(()=>{F.current=D},[D]);let R=Qt(r),z=Qt(S),B=R===`auto`,V=B?void 0:R??200,H=o!==void 0||u!==void 0,U=(0,f.useMemo)(()=>H?ne.Mention.configure({HTMLAttributes:{class:`rte-mention`},renderHTML({options:e,node:t}){return[`span`,{...e.HTMLAttributes,"data-id":t.attrs.id,"data-label":t.attrs.label},`${s}${t.attrs.label}`]},suggestion:Vr({getItems:()=>I.current,onMentionSearch:u,onMentionInserted:e=>L.current?.(e),noResultsLabel:O.mentionNoResults??`No results`})}):null,[H,s,u]),W=a!==void 0&&a>0||h||v,G=(0,X.useEditor)({shouldRerenderOnTransaction:!0,extensions:[re.StarterKit.configure({link:{openOnClick:!1}}),ie.TextStyle,ae.Color,oe.Highlight.configure({multicolor:!0}),de.Markdown.configure({transformPastedText:!0,transformCopiedText:!1}),se.Placeholder.configure({placeholder:p??``}),...k.showTableButton?[le.TableKit]:[],...k.showImageButton?[ue.Image.configure({inline:!1,allowBase64:!0})]:[],...U?[U]:[],...W?a!==void 0&&a>0?[ce.CharacterCount.configure({limit:a})]:[ce.CharacterCount]:[]],content:x??e??``,editable:!t&&!m,editorProps:{handlePaste(e,t){if(!P.current)return!1;let n=t.clipboardData?.getData(`text/plain`);if(!n)return!1;t.preventDefault();let{state:r}=e;return e.dispatch(r.tr.insertText(n,r.selection.from,r.selection.to)),!0},handleKeyDown(e,t){return(t.ctrlKey||t.metaKey)&&t.key===`s`?(t.preventDefault(),F.current?.(),!0):!1}},onUpdate({editor:e}){w?.(e.getHTML()),E?.(e.storage.markdown.getMarkdown())},onBlur(){C?.()},onFocus(){T?.()}});(0,f.useEffect)(()=>{!G||x===void 0||G.getHTML()!==x&&G.commands.setContent(x,{emitUpdate:!1})},[G,x]),(0,f.useEffect)(()=>{G&&G.setEditable(!t&&!m)},[G,t,m]);let K=G?.storage.characterCount?.characters?.()??0,q=G?.storage.characterCount?.words?.()??0,J=h||a!==void 0&&a>0||v||!!i;return(0,_.jsxs)(d.Box,{sx:A?{position:`fixed`,top:0,left:0,width:`100vw`,height:`100vh`,zIndex:1300,display:`flex`,flexDirection:`column`,bgcolor:`background.default`,p:1}:{width:z??`100%`,...B?{display:`flex`,flexDirection:`column`,flex:1}:{}},children:[(0,_.jsxs)(d.Paper,{variant:`outlined`,sx:{display:`flex`,flexDirection:`column`,overflow:`hidden`,...A||B?{flex:1}:{height:V},borderColor:n?`error.main`:void 0,"&:focus-within":{borderColor:n?`error.main`:`primary.main`,borderWidth:2}},children:[g&&!m&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(ni,{editor:G,toolbarConfig:k,translation:O,disabled:t,isFullscreen:A,onToggleFullscreen:()=>j(e=>!e),pasteAsPlainText:M,onTogglePasteAsPlainText:()=>N(e=>!e)}),(0,_.jsx)(d.Divider,{})]}),(0,_.jsx)(Hr,{editor:G,error:n,disabled:t,readonly:m})]}),J&&(0,_.jsx)(ri,{helperText:i,error:n,showCharacterCount:h||a!==void 0&&a>0,charCount:K,maxCharacters:a&&a>0?a:void 0,showWordCount:v,wordCount:q,translation:O}),c&&(0,_.jsx)(`input`,{type:`hidden`,name:c,value:G?G.getHTML():``})]})}var ai={showFormat:!0,showCopy:!0,showClear:!0,showExecute:!1,showUndoRedo:!0,showHistory:!1},oi={format:`Format SQL`,copy:`Copy`,copySuccess:`Copied!`,clear:`Clear`,execute:`Execute`,undo:`Undo`,redo:`Redo`,lineColumn:`Ln {line}, Col {col}`,errorCount:`{count} error(s)`,history:`Query history`,historyEmpty:`No queries yet`,clearHistory:`Clear history`},si={standard:Pe.StandardSQL,mysql:Pe.MySQL,postgresql:Pe.PostgreSQL,sqlite:Pe.SQLite,mssql:Pe.MSSQL};function ci({value:e,onChange:t,placeholder:n,disabled:r=!1,readonly:i=!1,showLineNumbers:a=!0,dialect:o=`standard`,keywordColor:s,stringColor:c,identifierColor:l,schema:u,onExecute:p,onFormat:m,onLint:h,onDiagnosticsChange:g,onViewReady:v,onCursorChange:y,onBlur:b,onFocus:C}){let O=(0,f.useRef)(null),k=(0,f.useRef)(null),A=(0,f.useRef)(t),j=(0,f.useRef)(y),M=(0,f.useRef)(b),N=(0,f.useRef)(C),P=(0,f.useRef)(v),F=(0,f.useRef)(p),I=(0,f.useRef)(m),L=(0,f.useRef)(h),R=(0,f.useRef)(g),z=(0,f.useRef)(new S.Compartment),B=(0,f.useRef)(new S.Compartment),V=(0,d.useTheme)(),H=V.palette.mode===`dark`,U=!!h,W=JSON.stringify(u);return(0,f.useEffect)(()=>{A.current=t},[t]),(0,f.useEffect)(()=>{j.current=y},[y]),(0,f.useEffect)(()=>{M.current=b},[b]),(0,f.useEffect)(()=>{N.current=C},[C]),(0,f.useEffect)(()=>{P.current=v},[v]),(0,f.useEffect)(()=>{F.current=p},[p]),(0,f.useEffect)(()=>{I.current=m},[m]),(0,f.useEffect)(()=>{L.current=h},[h]),(0,f.useEffect)(()=>{R.current=g},[g]),(0,f.useEffect)(()=>{if(!O.current)return;let t=k.current?.state.doc.toString()??e??``,d=s??V.palette.primary.main,f=c??V.palette.success.main,p=l??V.palette.info.main,m=T.HighlightStyle.define([{tag:D.tags.keyword,color:d,fontWeight:`bold`},{tag:D.tags.name,color:p},{tag:[D.tags.string,D.tags.special(D.tags.string)],color:f,fontWeight:`bold`},{tag:D.tags.number,color:V.palette.warning.main},{tag:[D.tags.lineComment,D.tags.blockComment],color:V.palette.text.disabled,fontStyle:`italic`},{tag:D.tags.operator,color:V.palette.text.secondary},{tag:[D.tags.function(D.tags.variableName),D.tags.function(D.tags.name)],color:V.palette.secondary.main},{tag:D.tags.typeName,color:V.palette.info.main},{tag:D.tags.invalid,color:V.palette.error.main,textDecoration:`underline wavy`}]),h=x.EditorView.theme({"&":{height:`100%`,fontFamily:`'Fira Code', 'JetBrains Mono', 'Consolas', monospace`,fontSize:`0.875rem`},".cm-scroller":{overflow:`auto`},".cm-content":{padding:`8px 4px`,caretColor:V.palette.text.primary},".cm-gutters":{backgroundColor:H?V.palette.grey[900]:V.palette.grey[50],color:V.palette.text.disabled,border:`none`,borderRight:`1px solid ${V.palette.divider}`},".cm-lineNumbers .cm-gutterElement":{paddingLeft:`4px`,paddingRight:`8px`},".cm-activeLineGutter":{backgroundColor:V.palette.action.selected},".cm-activeLine":{backgroundColor:V.palette.action.hover},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground":{backgroundColor:V.palette.primary.main+`40`},".cm-cursor, .cm-dropCursor":{borderLeftColor:V.palette.text.primary},"&.cm-focused":{outline:`none`},".cm-placeholder":{color:V.palette.text.disabled,fontStyle:`italic`},".cm-tooltip":{backgroundColor:V.palette.background.paper,border:`1px solid ${V.palette.divider}`,borderRadius:`4px`,boxShadow:V.shadows[4]},".cm-tooltip-autocomplete > ul > li":{color:V.palette.text.primary},".cm-tooltip-autocomplete > ul > li[aria-selected]":{backgroundColor:V.palette.primary.main+`20`,color:V.palette.primary.main},".cm-completionMatchedText":{color:V.palette.primary.main,textDecoration:`none`,fontWeight:`bold`},".cm-completionDetail":{color:V.palette.text.secondary,fontStyle:`italic`},".cm-gutter-lint":{width:`16px`},".cm-lint-marker-error":{color:V.palette.error.main},".cm-lint-marker-warning":{color:V.palette.warning.main},".cm-tooltip.cm-tooltip-lint":{backgroundColor:V.palette.background.paper,border:`1px solid ${V.palette.divider}`,borderRadius:`4px`},".cm-diagnostic-error":{borderLeft:`3px solid ${V.palette.error.main}`},".cm-diagnostic-warning":{borderLeft:`3px solid ${V.palette.warning.main}`},".cm-diagnostic-info":{borderLeft:`3px solid ${V.palette.info.main}`}},{dark:H}),g=u?Object.fromEntries(u.tables.map(e=>[e.name,(e.columns??[]).map(e=>({label:e.name,detail:e.type,type:`property`}))])):void 0,_=async e=>{let t=L.current;if(!t)return[];let n=e.state.doc.toString();try{let r=(await t(n)).map(t=>{let n=Math.max(1,Math.min(t.line,e.state.doc.lines)),r=e.state.doc.line(n);return{from:r.from+Math.max(0,(t.col??1)-1),to:r.to,severity:t.severity??`error`,message:t.message}});return R.current?.(r.length),r}catch{return[]}},v=x.keymap.of([{key:`Mod-Enter`,run:e=>(F.current?.(e.state.doc.toString()),!0)}]),y=x.keymap.of([{key:`Shift-Alt-f`,run:()=>(I.current?.(),!0)}]),b=[h,(0,T.syntaxHighlighting)(m),(0,Pe.sql)({dialect:si[o],schema:g}),(0,w.history)(),(0,Fe.autocompletion)(),v,y,x.keymap.of([...w.defaultKeymap,...w.historyKeymap,...Fe.completionKeymap]),z.current.of(x.EditorView.editable.of(!r&&!i)),B.current.of(S.EditorState.readOnly.of(i)),(0,x.highlightActiveLine)(),...a?[(0,x.lineNumbers)(),(0,x.highlightActiveLineGutter)()]:[],...n?[(0,x.placeholder)(n)]:[],...U?[(0,E.lintGutter)(),(0,E.linter)(_,{delay:600})]:[],x.EditorView.updateListener.of(e=>{e.docChanged&&A.current?.(e.state.doc.toString());let t=e.state.selection.main.head,n=e.state.doc.lineAt(t);j.current(n.number,t-n.from+1)}),x.EditorView.domEventHandlers({blur:()=>{M.current?.()},focus:()=>{N.current?.()}})],C=new x.EditorView({state:S.EditorState.create({doc:t,extensions:b}),parent:O.current});return k.current=C,P.current(C),()=>{P.current(null),C.destroy(),k.current=null}},[H,o,U,s,c,l,W]),(0,f.useEffect)(()=>{let t=k.current;if(!t)return;let n=t.state.doc.toString();n!==(e??``)&&t.dispatch({changes:{from:0,to:n.length,insert:e??``}})},[e]),(0,f.useEffect)(()=>{k.current?.dispatch({effects:[z.current.reconfigure(x.EditorView.editable.of(!r&&!i)),B.current.reconfigure(S.EditorState.readOnly.of(i))]})},[r,i]),(0,_.jsx)(d.Box,{ref:O,sx:{flex:1,overflow:`hidden`,display:`flex`,flexDirection:`column`,opacity:r?.5:1,backgroundColor:V.palette.background.paper,"& .cm-editor":{flex:1,display:`flex`,flexDirection:`column`}}})}function li(e,t=60){let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t)}…`:n}function ui({history:e,onSelect:t,onClear:n,translation:r,disabled:i}){let[a,o]=(0,f.useState)(null);function s(){o(null)}function c(e){t(e),s()}function l(){n(),s()}return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(d.Tooltip,{title:r.history,arrow:!0,children:(0,_.jsx)(`span`,{children:(0,_.jsx)(d.IconButton,{size:`small`,onClick:e=>o(e.currentTarget),disabled:i,"aria-label":r.history,children:(0,_.jsx)(Le.default,{fontSize:`small`})})})}),(0,_.jsxs)(d.Menu,{anchorEl:a,open:!!a,onClose:s,slotProps:{paper:{sx:{minWidth:280,maxWidth:400}}},children:[e.length===0&&(0,_.jsx)(d.MenuItem,{disabled:!0,children:(0,_.jsx)(d.ListItemText,{children:r.historyEmpty})}),e.map(e=>(0,_.jsx)(d.MenuItem,{onClick:()=>c(e.sql),children:(0,_.jsx)(d.ListItemText,{primary:li(e.sql),secondary:(0,_.jsx)(d.Typography,{variant:`caption`,color:`text.secondary`,children:new Date(e.timestamp).toLocaleString()}),slotProps:{primary:{sx:{fontFamily:`monospace`,fontSize:`0.8125rem`}}}})},e.id)),e.length>0&&(0,_.jsx)(d.Divider,{}),e.length>0&&(0,_.jsxs)(d.MenuItem,{onClick:l,children:[(0,_.jsx)(d.ListItemIcon,{children:(0,_.jsx)(Re.default,{fontSize:`small`,color:`error`})}),(0,_.jsx)(d.ListItemText,{sx:{color:`error.main`},children:r.clearHistory})]})]})]})}var di={standard:`sql`,mysql:`mysql`,postgresql:`postgresql`,sqlite:`sqlite`,mssql:`tsql`};function fi({editorView:e,toolbarConfig:t,translation:n,dialect:r,disabled:i,onExecute:a,queryHistory:o=[],onSelectHistoryEntry:s,onClearHistory:c}){let[l,u]=(0,f.useState)(!1),p=i||!e;function m(){let t=e?.state.doc.toString()??``;navigator.clipboard.writeText(t).then(()=>{u(!0),setTimeout(()=>u(!1),2e3)})}function h(){let t=e;t&&(t.dispatch({changes:{from:0,to:t.state.doc.length,insert:``}}),t.focus())}function g(){let t=e;t&&((0,w.undo)(t),t.focus())}function y(){let t=e;t&&((0,w.redo)(t),t.focus())}function b(){let t=e;if(!t)return;let n=t.state.doc.toString();try{let e=(0,Ne.format)(n,{language:di[r]});t.dispatch({changes:{from:0,to:t.state.doc.length,insert:e}})}catch{}t.focus()}function x(){let t=e;!t||!a||a(t.state.doc.toString())}let S=t.showFormat,C=t.showCopy||t.showClear,T=t.showUndoRedo,E=t.showExecute&&!!a,D=t.showHistory&&!!a&&!!s&&!!c;return(0,_.jsxs)(d.Box,{sx:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:.25,px:1,py:.5},role:`toolbar`,"aria-label":`SQL editor actions`,children:[S&&(0,_.jsx)(d.Box,{sx:{display:`flex`,gap:.25},children:(0,_.jsx)(Q,{label:n.format,icon:(0,_.jsx)(P.default,{fontSize:`small`}),onClick:b,disabled:p})}),S&&(C||T)&&(0,_.jsx)(d.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),C&&(0,_.jsxs)(d.Box,{sx:{display:`flex`,gap:.25},children:[t.showCopy&&(0,_.jsx)(Q,{label:l?n.copySuccess:n.copy,icon:l?(0,_.jsx)(j.default,{fontSize:`small`,color:`success`}):(0,_.jsx)(k.default,{fontSize:`small`}),onClick:m,disabled:p}),t.showClear&&(0,_.jsx)(Q,{label:n.clear,icon:(0,_.jsx)(v.default,{fontSize:`small`}),onClick:h,disabled:p})]}),C&&T&&(0,_.jsx)(d.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),T&&(0,_.jsxs)(d.Box,{sx:{display:`flex`,gap:.25},children:[(0,_.jsx)(Q,{label:n.undo,icon:(0,_.jsx)(M.default,{fontSize:`small`}),onClick:g,disabled:p}),(0,_.jsx)(Q,{label:n.redo,icon:(0,_.jsx)(N.default,{fontSize:`small`}),onClick:y,disabled:p})]}),D&&(0,_.jsxs)(_.Fragment,{children:[(C||T)&&(0,_.jsx)(d.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),(0,_.jsx)(ui,{history:o,onSelect:s,onClear:c,translation:n,disabled:i})]}),E&&(0,_.jsxs)(_.Fragment,{children:[(C||T||D)&&(0,_.jsx)(d.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),(0,_.jsx)(Q,{label:n.execute,icon:(0,_.jsx)(Ie.default,{fontSize:`small`}),onClick:x,disabled:p})]}),!S&&!C&&!T&&!D&&!E&&(0,_.jsx)(d.Box,{sx:{height:32}})]})}function pi({helperText:e,error:t,showLineColumn:n,showErrorCount:r,diagnosticsCount:i,cursorLine:a,cursorCol:o,translation:s}){let c=s.lineColumn.replace(`{line}`,String(a)).replace(`{col}`,String(o)),l=s.errorCount.replace(`{count}`,String(i));return(0,_.jsxs)(d.Box,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,mt:.5,px:.5},children:[(0,_.jsxs)(d.Box,{children:[r&&i>0&&(0,_.jsxs)(d.Box,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,_.jsx)(ze.default,{sx:{fontSize:`0.875rem`,color:`error.main`}}),(0,_.jsx)(d.FormHelperText,{sx:{color:`error.main`,m:0},children:l})]}),(0,_.jsx)(d.FormHelperText,{error:t,children:e??``})]}),n&&(0,_.jsx)(d.FormHelperText,{sx:{color:`text.disabled`,fontFamily:`monospace`,whiteSpace:`nowrap`},children:c})]})}var mi=0;function hi(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():(mi+=1,`${Date.now()}-${mi}`)}function gi(e){if(typeof window>`u`)return[];try{let t=window.localStorage.getItem(e);if(!t)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(e=>typeof e?.sql==`string`&&typeof e?.timestamp==`number`).map(e=>({...e,id:typeof e.id==`string`?e.id:hi()})):[]}catch{return[]}}function _i(e,t){if(!(typeof window>`u`))try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}}function vi(e,t,n){let r=t.trim();if(!r)return e;let i=e.filter(e=>e.sql!==r);return[{id:hi(),sql:r,timestamp:Date.now()},...i].slice(0,Math.max(0,n))}function yi(e,t){let[n,r]=(0,f.useState)(()=>gi(e));return(0,f.useEffect)(()=>{r(gi(e))},[e]),{history:n,addEntry:(0,f.useCallback)(n=>{r(r=>{let i=vi(r,n,t);return _i(e,i),i})},[e,t]),clearHistory:(0,f.useCallback)(()=>{r([]),_i(e,[])},[e])}}var bi={standard:`sql`,mysql:`mysql`,postgresql:`postgresql`,sqlite:`sqlite`,mssql:`tsql`};function xi({value:e,onChange:t,placeholder:n,height:r,width:i,disabled:a=!1,readonly:o=!1,error:s=!1,helperText:c,name:l,dialect:u=`standard`,showLineNumbers:p=!0,showLineColumn:m=!0,showErrorCount:h=!1,toolbarConfig:g,translation:v,highlightColors:y,schema:b,queryHistoryKey:x=`sql-editor-query-history`,queryHistoryMaxEntries:S=20,onExecute:C,onLint:w,onBlur:T,onFocus:E}){let D={...oi,...v},O={...ai,...g},{history:k,addEntry:A,clearHistory:j}=yi(x,S),M=Qt(r),N=Qt(i),P=M===`auto`,F=P?void 0:M??300,I=(0,f.useRef)(null),[L,R]=(0,f.useState)(null),[z,B]=(0,f.useState)({line:1,col:1}),[V,H]=(0,f.useState)(0),U=(0,f.useCallback)(e=>{I.current=e,R(e)},[]),W=(0,f.useCallback)((e,t)=>{B({line:e,col:t})},[]),G=(0,f.useCallback)(e=>{H(e)},[]),K=C?e=>{A(e),C(e)}:void 0,q=(0,f.useMemo)(()=>{if(!(o||!O.showFormat))return()=>{let e=I.current;if(!e)return;let t=e.state.doc.toString();try{let n=(0,Ne.format)(t,{language:bi[u]});e.dispatch({changes:{from:0,to:e.state.doc.length,insert:n}})}catch{}e.focus()}},[u,o,O.showFormat]),J=(0,f.useCallback)(e=>{let n=I.current;n&&(n.dispatch({changes:{from:0,to:n.state.doc.length,insert:e}}),n.focus()),t?.(e)},[t]),ee=m||h||!!c;return(0,_.jsxs)(d.Box,{sx:{width:N??`100%`,...P?{display:`flex`,flexDirection:`column`,flex:1}:{}},children:[(0,_.jsxs)(d.Paper,{variant:`outlined`,sx:{display:`flex`,flexDirection:`column`,overflow:`hidden`,...P?{flex:1}:{height:F},borderColor:s?`error.main`:void 0,"&:focus-within":{borderColor:s?`error.main`:`primary.main`,borderWidth:2}},children:[!o&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(fi,{editorView:L,toolbarConfig:O,translation:D,dialect:u,disabled:a,onExecute:K,queryHistory:k,onSelectHistoryEntry:J,onClearHistory:j}),(0,_.jsx)(d.Divider,{})]}),(0,_.jsx)(ci,{value:e,onChange:t,placeholder:n,disabled:a,readonly:o,showLineNumbers:p,dialect:u,keywordColor:y?.keyword,stringColor:y?.string,identifierColor:y?.identifier,schema:b,onExecute:K,onFormat:q,onLint:w,onDiagnosticsChange:w?G:void 0,onViewReady:U,onCursorChange:W,onBlur:T,onFocus:E})]}),ee&&(0,_.jsx)(pi,{helperText:c,error:s,showLineColumn:m,showErrorCount:h,diagnosticsCount:V,cursorLine:z.line,cursorCol:z.col,translation:D}),l&&(0,_.jsx)(`input`,{type:`hidden`,name:l,value:e??``})]})}var Si={noData:`No data`},Ci=2*Math.PI,wi=11,Ti=wi*.5,Ei=5;function Di(e,t=0,n=`.`,r=`,`){if(e==null||!isFinite(e))return`0`;let[i,a]=e.toFixed(Math.max(0,t)).split(`.`),o=i.replace(/\B(?=(\d{3})+(?!\d))/g,r);return a?`${o}${n}${a}`:o}function Oi(e,t){let n=Math.floor(t/Ti);return n<=0?``:e.length<=n?e:n<Ei?``:e.slice(0,n-1)+`…`}function ki({node:e,valueDecimalCount:t,valueDecimalSep:n,valueThousandsSep:r,valueFormatter:i}){let a=(e.value??0)>0,o=e.ancestors().map(e=>e.data.name).reverse().join(` › `);return(0,_.jsxs)(d.Box,{sx:{py:.25},children:[(0,_.jsx)(d.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`},children:e.data.name}),a&&(0,_.jsx)(d.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:(e=>i?i(e):Di(e,t,n,r))(e.value??0)}),e.depth>0&&(0,_.jsx)(d.Typography,{variant:`caption`,sx:{display:`block`,opacity:.65,mt:.25},children:o})]})}function Ai({data:e,size:t=500,showSegmentLabels:n=!0,innerRadius:r=0,sortBy:i=`value`,chartColors:a,showRootLabel:o=!0,onSegmentClick:s,onSegmentHover:c,onZoomChange:l,valueDecimalCount:u=0,valueDecimalSeparator:p=`.`,valueThousandsSeparator:m=`,`,valueFormatter:h,zoomable:g=!1,duration:v=750,disabled:y=!1,translation:b}){let x=(0,d.useTheme)(),S={...Si,...b},C=!e.children?.length&&!e.value,w=(0,f.useRef)(null),[T,E]=(0,f.useState)(`-${t/2} -${t/2} ${t} ${t}`),[D,O]=(0,f.useState)(1),k=(0,f.useMemo)(()=>{if(D===1)return T;let[e,t,n,r]=T.split(` `).map(Number),i=n/D,a=r/D;return`${e+(n-i)/2} ${t+(r-a)/2} ${i} ${a}`},[T,D]),A=t/2,j=Math.max(0,Math.min(r,Math.max(0,A-1))),M=Math.max(1,A-j),N=[x.palette.primary.main,x.palette.secondary.main,x.palette.error.main,x.palette.warning.main,x.palette.success.main,x.palette.info.main],P=a&&a.length>0?a:N,{root:F,ringThickness:I}=(0,f.useMemo)(()=>{let t=Z.hierarchy(e).sum(e=>e.value??0);i===`value`?t.sort((e,t)=>(t.value??0)-(e.value??0)):t.sort((e,t)=>String(e.data.name).localeCompare(String(t.data.name),void 0,{numeric:!0,sensitivity:`base`}));let n=Z.partition().size([Ci,M])(t),r=Z.max(n.descendants(),e=>e.depth)??0,a=r>0?M/r:M;return r>0&&n.descendants().forEach(e=>{e.depth===0?(e.y0=0,e.y1=0):(e.y0=(e.depth-1)*a,e.y1=e.depth*a)}),{root:n,ringThickness:a}},[e,M,i]),[L,R]=(0,f.useState)(F),[z,B]=(0,f.useState)(F),V=e=>({x0:e.x0,x1:e.x1,yShift:e.depth===0?0:(e.depth-1)*I}),[H,U]=(0,f.useState)(()=>V(F)),W=(0,f.useRef)(H);if(z!==F){B(F),R(F);let e=V(F);W.current=e,U(e)}let G=(0,f.useMemo)(()=>F.children?.map(e=>e.data.name)??[F.data.name],[F]),K=(0,f.useMemo)(()=>Z.scaleOrdinal().domain(G).range(P),[P,G]),q=e=>{if(e.data.colorConfig?.fill)return e.data.colorConfig.fill;let t=e;for(;t.depth>1;)t=t.parent;return K(t.data.name)},J=(0,f.useMemo)(()=>Z.arc().startAngle(e=>e.x0).endAngle(e=>e.x1).padAngle(e=>Math.min((e.x1-e.x0)/2,.005)).padRadius(A/2).innerRadius(e=>j+e.y0).outerRadius(e=>j+e.y1-1),[A,j]),ee=(0,f.useCallback)(e=>{let t=Ci/(H.x1-H.x0);return{x0:Math.max(0,Math.min(Ci,(e.x0-H.x0)*t)),x1:Math.max(0,Math.min(Ci,(e.x1-H.x0)*t)),y0:Math.max(0,e.y0-H.yShift),y1:Math.max(0,e.y1-H.yShift)}},[H]);(0,f.useEffect)(()=>{let e=V(L),t=W.current;if(t.x0===e.x0&&t.x1===e.x1&&t.yShift===e.yShift)return;if(v<=0){W.current=e,U(e);return}let n=null,r=Z.interpolateNumber(t.x0,e.x0),i=Z.interpolateNumber(t.x1,e.x1),a=Z.interpolateNumber(t.yShift,e.yShift),o=performance.now(),s=e=>{let t=Math.min(1,(e-o)/v),c=Z.easeCubic(t),l={x0:r(c),x1:i(c),yShift:a(c)};W.current=l,U(l),n=t<1?requestAnimationFrame(s):null};return n=requestAnimationFrame(s),()=>{n!=null&&cancelAnimationFrame(n)}},[L,I,v]);let te=e=>e.x1>e.x0&&e.y1>e.y0,Y=e=>(j+(e.y0+e.y1)/2)*(e.x1-e.x0)>12,X=e=>{let t=(e.x0+e.x1)/2*180/Math.PI,n=j+(e.y0+e.y1)/2,r=t<180?0:180;return`rotate(${t-90}) translate(${n},0) rotate(${r})`},ne=(0,f.useCallback)(e=>e.ancestors().includes(L),[L]),re=(0,f.useCallback)(e=>{let t=e.ancestors().reverse(),n=e.value??0,r=F.value??0;return{id:e.data.id,name:e.data.name,value:n||null,percentage:r>0?Math.round(n/r*1e4)/100:0,depth:e.depth,path:t.map(e=>e.data.name),pathIds:t.map(e=>e.data.id),childrenCount:e.children?.length??0,data:e.data}},[F]),ie=(0,f.useCallback)(e=>{R(e),l&&l({focusNode:re(e),isRoot:e===F})},[F,re,l]);(0,f.useLayoutEffect)(()=>{let e=w.current;if(!e)return;let n=requestAnimationFrame(()=>{try{let t=e.getBBox();E(`${t.x-8} ${t.y-8} ${t.width+16} ${t.height+16}`)}catch{E(`-${t/2} -${t/2} ${t} ${t}`)}});return()=>cancelAnimationFrame(n)},[t,F,L,j,I,o]);let ae=(0,f.useRef)(null),oe=e=>{ae.current&&=(clearTimeout(ae.current),null),ae.current=setTimeout(()=>{e(),ae.current=null},250)},se=()=>{ae.current&&=(clearTimeout(ae.current),null)};(0,f.useLayoutEffect)(()=>{if(y)return;let e=e=>{e.key===`Escape`&&(se(),ie(F),O(1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[y,F,ie]);let ce=(0,f.useCallback)(e=>{if(!g||y||!e.ctrlKey)return;e.preventDefault();let t=e.deltaY<0?1.15:1/1.15;O(e=>Math.max(.25,Math.min(8,e*t)))},[g,y]),le=F.descendants().filter(e=>e.depth>0),ue=e=>{if(y)return;let t=le[Number(e.currentTarget.getAttribute(`data-idx`))];if(t){if(e.ctrlKey||e.metaKey){t.children&&oe(()=>ie(t));return}s?.(re(t),e)}},de=e=>{y||(e.ctrlKey||e.metaKey)&&(se(),ie(L.parent??F))},fe=e=>{if(!y){if(e.ctrlKey||e.metaKey){se(),ie(L.parent??F);return}s?.(re(L.parent??F),e)}},pe={followCursor:!0,enterDelay:50,enterNextDelay:0,disableHoverListener:y,slotProps:{tooltip:{sx:{maxWidth:260}}}},me=x.palette.text.primary,he=x.typography.fontFamily;return(0,_.jsx)(d.Box,{sx:{display:`inline-flex`,opacity:y?.5:1,cursor:y?`not-allowed`:`default`,userSelect:`none`},children:(0,_.jsx)(`svg`,{width:t,height:t,viewBox:k,onWheel:ce,style:{fontFamily:he??`sans-serif`,overflow:g&&D>1?`hidden`:`visible`},role:`img`,"aria-label":e.name,children:(0,_.jsxs)(`g`,{ref:w,children:[C&&(0,_.jsx)(`text`,{textAnchor:`middle`,dy:`0.35em`,fontSize:13,fill:x.palette.text.secondary,children:S.noData}),j>0&&(0,_.jsx)(d.Tooltip,{...pe,title:L.data.name,placement:`top`,children:(0,_.jsx)(`circle`,{cx:0,cy:0,r:j,fill:`transparent`,pointerEvents:y?`none`:`auto`,onClick:fe,style:{cursor:y?`not-allowed`:`pointer`},onMouseEnter:e=>{y||c?.(re(L.parent??F),e)},onMouseLeave:e=>{c?.(null,e)}})}),(0,_.jsx)(`g`,{children:le.map((e,t)=>{let n=ee(e),r=te(n),i=!!e.children;return(0,_.jsx)(d.Tooltip,{...pe,placement:`top`,title:r?(0,_.jsx)(ki,{node:e,valueDecimalCount:u,valueDecimalSep:p,valueThousandsSep:m,valueFormatter:h}):``,children:(0,_.jsx)(`path`,{"data-idx":t,d:J(n)||``,fill:q(e),fillOpacity:r?i?.75:.5:0,style:{pointerEvents:r&&!y?`auto`:`none`,cursor:i&&!y?`pointer`:`default`,transition:`fill-opacity 0.15s`},onClick:ue,onDoubleClick:de,onMouseEnter:e=>{if(y||!r)return;let t=le[Number(e.currentTarget.getAttribute(`data-idx`))];t&&c?.(re(t),e)},onMouseLeave:e=>{r&&c?.(null,e)}})},`tt-${e.data.id}-${t}`)})}),n&&(0,_.jsx)(`g`,{pointerEvents:`none`,textAnchor:`middle`,fill:me,children:le.map((e,t)=>{if(!ne(e))return null;let n=ee(e);if(!Y(n))return null;let r=(j+(n.y0+n.y1)/2)*(n.x1-n.x0)*.88,i=Oi(e.data.name,r);return i?(0,_.jsx)(`text`,{transform:X(n),dy:`0.35em`,fontSize:wi,children:i},`lbl-${e.data.id}-${t}`):null})}),o&&!C&&(0,_.jsx)(d.Tooltip,{...pe,placement:`top`,title:``,children:(0,_.jsx)(`g`,{textAnchor:`middle`,fill:me,pointerEvents:y?`none`:`auto`,onClick:fe,style:{cursor:L!==F&&!y?`pointer`:`default`},children:(0,_.jsx)(`text`,{fontSize:13,dy:`0.35em`,fontWeight:`bold`,children:L.data.name})})})]})})})}Ai.displayName=`SunburstChart`;var ji={noData:`No data`};function Mi(e,t=0,n=`.`,r=`,`){if(!isFinite(e))return String(e);let[i,a]=e.toFixed(Math.max(0,t)).split(`.`),o=i.replace(/\B(?=(\d{3})+(?!\d))/g,r);return a?`${o}${n}${a}`:o}function Ni({name:e,valueOut:t,valueIn:n,fmt:r}){return(0,_.jsxs)(d.Box,{sx:{py:.25},children:[(0,_.jsx)(d.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`},children:e}),(0,_.jsxs)(d.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:[r(t),` outgoing →`]}),(0,_.jsxs)(d.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:[r(n),` incoming ←`]})]})}function Pi({sourceName:e,targetName:t,sourceValue:n,targetValue:r,directed:i,fmt:a}){return(0,_.jsxs)(d.Box,{sx:{py:.25},children:[(0,_.jsxs)(d.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`},children:[e,` → `,t]}),(0,_.jsx)(d.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:a(n)}),i&&r>0&&r!==n&&(0,_.jsxs)(d.Typography,{variant:`caption`,sx:{display:`block`,opacity:.7,mt:.25},children:[t,` → `,e,`: `,a(r)]})]})}function Fi({data:e,size:t=500,innerRadius:n,ringThickness:r=20,padAngle:i,ribbonPadAngle:a,sortSubgroups:o=`descending`,sortChords:s=`descending`,chartColors:c,groupColorConfigs:l,showGroupLabels:u=!0,labelOffset:p=8,ribbonOpacity:m=.75,ribbonBlendMode:h,directed:g=!0,valueDecimalCount:v=0,valueDecimalSeparator:y=`.`,valueThousandsSeparator:b=`,`,valueFormatter:x,onGroupClick:S,onGroupHover:C,onChordClick:w,onChordHover:T,zoomable:E=!1,disabled:D=!1,translation:O}){let k=(0,d.useTheme)(),A={...ji,...O},j=e.length===0,M=h??(k.palette.mode===`dark`?`normal`:`multiply`),N=[k.palette.primary.main,k.palette.secondary.main,k.palette.error.main,k.palette.warning.main,k.palette.success.main,k.palette.info.main],P=c&&c.length>0?c:N,F=n??Math.min(t,t)*.5-90,I=Math.max(10,F),L=I+Math.max(1,r),R=i??10/I,z=a??1/I,B=(0,f.useCallback)(e=>x?x(e):Mi(e,v,y,b),[x,v,y,b]),{names:V,matrix:H}=(0,f.useMemo)(()=>{let t=Z.sort(Z.union(e.map(e=>e.source),e.map(e=>e.target))),n=new Map(t.map((e,t)=>[e,t])),r=Array.from({length:t.length},()=>Array(t.length).fill(0));for(let{source:t,target:i,value:a}of e){let e=n.get(t),o=n.get(i);e==null||o==null||(r[e][o]+=a)}return{names:t,matrix:r}},[e]),U=(0,f.useMemo)(()=>{let e=(g?Z.chordDirected():Z.chord()).padAngle(R);return o===`ascending`&&(e=e.sortSubgroups(Z.ascending)),o===`descending`&&(e=e.sortSubgroups(Z.descending)),s===`ascending`&&(e=e.sortChords(Z.ascending)),s===`descending`&&(e=e.sortChords(Z.descending)),e(H)},[H,R,g,o,s]),W=(0,f.useMemo)(()=>Z.arc().innerRadius(I).outerRadius(L),[I,L]),G=(0,f.useMemo)(()=>(g?Z.ribbonArrow():Z.ribbon()).radius(I-1).padAngle(z),[I,z,g]),K=(0,f.useCallback)(e=>G({source:{startAngle:e.source.startAngle,endAngle:e.source.endAngle,radius:I-1},target:{startAngle:e.target.startAngle,endAngle:e.target.endAngle,radius:I-1}})??``,[G,I]),q=(0,f.useMemo)(()=>Z.scaleOrdinal().domain(Z.range(V.length)).range(P.length>=V.length?P:[...Array(Math.ceil(V.length/P.length))].flatMap(()=>P).slice(0,V.length)),[P,V.length]),J=(0,f.useCallback)(e=>l?.[V[e]]?.fill??q(e),[l,V,q]),ee=(0,f.useRef)(null),[te,Y]=(0,f.useState)(`-${t/2} -${t/2} ${t} ${t}`),[X,ne]=(0,f.useState)(1),re=(0,f.useMemo)(()=>{if(X===1)return te;let[e,t,n,r]=te.split(` `).map(Number),i=n/X,a=r/X;return`${e+(n-i)/2} ${t+(r-a)/2} ${i} ${a}`},[te,X]);(0,f.useLayoutEffect)(()=>{let e=ee.current;if(!e)return;let n=requestAnimationFrame(()=>{try{let t=e.getBBox();Y(`${t.x-8} ${t.y-8} ${t.width+16} ${t.height+16}`)}catch{Y(`-${t/2} -${t/2} ${t} ${t}`)}});return()=>cancelAnimationFrame(n)},[t,I,L,V.length,U]);let[ie,ae]=(0,f.useState)(null),oe=(0,f.useCallback)(e=>({name:V[e.index],index:e.index,valueOut:Z.sum(U,t=>(t.source.index===e.index?t.source.value:0)+(!g&&t.target.index===e.index?t.target.value:0)),valueIn:Z.sum(U,t=>(t.target.index===e.index?t.source.value:0)+(!g&&t.source.index===e.index?t.target.value:0))}),[V,U,g]),se=(0,f.useCallback)(e=>({source:{name:V[e.source.index],index:e.source.index,value:e.source.value},target:{name:V[e.target.index],index:e.target.index,value:e.target.value}}),[V]),ce=e=>{let t=(e.startAngle+e.endAngle)/2,n=t*180/Math.PI-90,r=t>Math.PI?` rotate(180)`:``;return`rotate(${n}) translate(${L+p})${r}`},le=e=>(e.startAngle+e.endAngle)/2>Math.PI?`end`:`start`,ue=(0,f.useCallback)(e=>{if(!E||D||!e.ctrlKey)return;e.preventDefault();let t=e.deltaY<0?1.15:1/1.15;ne(e=>Math.max(.25,Math.min(8,e*t)))},[E,D]);(0,f.useLayoutEffect)(()=>{if(!E)return;let e=e=>{e.key===`Escape`&&ne(1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[E]);let de={followCursor:!0,enterDelay:50,enterNextDelay:0,disableHoverListener:D,slotProps:{tooltip:{sx:{maxWidth:240}}}},fe=k.palette.text.primary,pe=k.typography.fontFamily;return(0,_.jsx)(d.Box,{sx:{display:`inline-flex`,opacity:D?.5:1,cursor:D?`not-allowed`:`default`,userSelect:`none`},children:(0,_.jsx)(`svg`,{width:t,height:t,viewBox:re,onWheel:ue,style:{fontFamily:pe??`sans-serif`,overflow:E&&X>1?`hidden`:`visible`},role:`img`,"aria-label":`Chord chart`,children:(0,_.jsxs)(`g`,{ref:ee,children:[j&&(0,_.jsx)(`text`,{textAnchor:`middle`,dy:`0.35em`,fontSize:13,fill:k.palette.text.secondary,children:A.noData}),(0,_.jsx)(`g`,{children:U.groups.map(e=>{let t=oe(e),n=ie===e.index,r=ie!==null&&!n;return(0,_.jsx)(d.Tooltip,{...de,title:(0,_.jsx)(Ni,{name:t.name,valueOut:t.valueOut,valueIn:t.valueIn,fmt:B}),children:(0,_.jsxs)(`g`,{style:{cursor:D?`not-allowed`:`pointer`},onMouseEnter:n=>{D||(ae(e.index),C?.(t,n))},onMouseLeave:e=>{ae(null),C?.(null,e)},onClick:e=>!D&&S?.(t,e),children:[(0,_.jsx)(`path`,{d:W(e)||``,fill:J(e.index),stroke:k.palette.divider,opacity:r?.35:1,style:{transition:`opacity 0.15s`}}),u&&(0,_.jsx)(`text`,{dy:`0.35em`,fontSize:11,fill:fe,transform:ce(e),textAnchor:le(e),pointerEvents:`none`,children:V[e.index]})]})},`grp-tt-${e.index}`)})}),(0,_.jsx)(`g`,{fillOpacity:m,style:{mixBlendMode:M},children:U.map((e,t)=>{let n=se(e),r=ie===null||e.source.index===ie||e.target.index===ie;return(0,_.jsx)(d.Tooltip,{...de,title:(0,_.jsx)(Pi,{sourceName:n.source.name,targetName:n.target.name,sourceValue:n.source.value,targetValue:n.target.value,directed:g,fmt:B}),children:(0,_.jsx)(`path`,{d:K(e),fill:J(e.target.index),stroke:`none`,opacity:r?1:.12,style:{cursor:D?`not-allowed`:`pointer`,transition:`opacity 0.15s`},onMouseEnter:e=>{D||T?.(n,e)},onMouseLeave:e=>{T?.(null,e)},onClick:e=>!D&&w?.(n,e)})},`chord-tt-${t}`)})})]})})})}Fi.displayName=`ChordChart`;var Ii={noData:`No data`,specialValueA:`Value A`,specialValueB:`Value B`},Li={folder:`M20 6h-8l-2-2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 12H4V8h16v10z`,person:`M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z`};function Ri({path:e,size:t}){let n=t/2;return(0,_.jsx)(`g`,{transform:`translate(${-n},${-n})`,pointerEvents:`none`,children:(0,_.jsx)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,overflow:`visible`,children:(0,_.jsx)(`path`,{d:e,fill:`white`})})})}function zi({info:e,labelA:t,labelB:n}){return(0,_.jsxs)(d.Box,{sx:{p:2,minWidth:200,maxWidth:280},children:[(0,_.jsxs)(d.Box,{sx:{display:`flex`,alignItems:`center`,gap:1.5,mb:1.5},children:[(0,_.jsx)(d.Avatar,{sx:{bgcolor:`primary.main`,width:40,height:40},children:e.name.charAt(0).toUpperCase()}),(0,_.jsxs)(d.Box,{children:[(0,_.jsx)(d.Typography,{variant:`body2`,sx:{fontWeight:`bold`},children:e.name}),e.subname&&(0,_.jsx)(d.Typography,{variant:`caption`,color:`text.secondary`,children:e.subname})]})]}),(e.specialValueA!=null||e.specialValueB!=null)&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(d.Divider,{sx:{mb:1.5}}),e.specialValueA!=null&&(0,_.jsxs)(d.Box,{sx:{display:`flex`,justifyContent:`space-between`,mb:.5},children:[(0,_.jsx)(d.Typography,{variant:`caption`,color:`text.secondary`,children:t}),(0,_.jsx)(d.Typography,{variant:`caption`,children:String(e.specialValueA)})]}),e.specialValueB!=null&&(0,_.jsxs)(d.Box,{sx:{display:`flex`,justifyContent:`space-between`},children:[(0,_.jsx)(d.Typography,{variant:`caption`,color:`text.secondary`,children:n}),(0,_.jsx)(d.Typography,{variant:`caption`,children:String(e.specialValueB)})]})]})]})}function Bi({data:e,size:t=600,autoFit:n=!0,sortBy:r=`name`,showLabels:i=!0,showIcons:a=!0,chartColors:o,rootNodeRadius:s=22,branchNodeRadius:c=16,leafNodeRadius:l=11,linkColor:u,linkStrokeOpacity:p=1,linkStrokeWidth:m=1.5,labelFontSize:h=12,labelColor:g,separationSibling:v=1,separationCousin:y=2,zoomable:b=!1,drillable:x=!1,onFocusChange:S,duration:C=750,showNodePopover:w=!1,renderNodePopoverContent:T,onNodeClick:E,onNodeHover:D,disabled:O=!1,translation:k}){let A=(0,d.useTheme)(),j={...Ii,...k},M=[A.palette.primary.main,A.palette.secondary.main,A.palette.info.main,A.palette.success.main,A.palette.warning.main,A.palette.error.main],N=o&&o.length>0?o:M,P=(0,f.useCallback)(e=>e.depth===0?s:e.children?c:l,[s,c,l]),F=(0,f.useCallback)(e=>e.data.colorConfig?.fill??N[e.depth%N.length],[N]),[I,L]=(0,f.useState)([e]),R=I[I.length-1],[z,B]=(0,f.useState)(e),[V,H]=(0,f.useState)(!1);z!==e&&(B(e),L([e]),H(!0));let U=!e.children?.length&&!e.value,W=Math.max(1,t/2-70),G=(0,f.useMemo)(()=>{let e=Z.hierarchy(R);return r===`value`?(e.sum(e=>e.value??0),e.sort((e,t)=>(t.value??0)-(e.value??0))):e.sort((e,t)=>Z.ascending(e.data.name,t.data.name)),Z.tree().size([2*Math.PI,W]).separation((e,t)=>(e.parent===t.parent?v:y)*1.4/Math.max(1,e.depth))(e)},[R,r,W,v,y]),K=G.links(),q=G.descendants(),J=(0,f.useRef)(G),ee=(0,f.useRef)(null),[te,Y]=(0,f.useState)(null),[X,ne]=(0,f.useState)(0);(0,f.useEffect)(()=>{let e=J.current;if(J.current=G,e===G)return;if(ee.current!=null&&(cancelAnimationFrame(ee.current),ee.current=null),V||C<=0){H(!1),Y(null);return}Y(e),ne(1);let t=performance.now(),n=e=>{let r=Math.min(1,(e-t)/C);ne(1-Z.easeCubic(r)),r<1?ee.current=requestAnimationFrame(n):(ee.current=null,Y(null))};return ee.current=requestAnimationFrame(n),()=>{ee.current!=null&&cancelAnimationFrame(ee.current)}},[G,C,V]);let re=(0,f.useMemo)(()=>Z.linkRadial().angle(e=>e.x).radius(e=>e.y),[]),ie=(0,f.useCallback)(e=>({id:e.data.id,name:e.data.name,subname:e.data.subname??null,value:(typeof e.value==`number`?e.value:null)??e.data.value??null,specialValueA:e.data.specialValueA??null,specialValueB:e.data.specialValueB??null,depth:e.depth,path:e.ancestors().map(e=>e.data.name).reverse(),childrenCount:e.children?.length??0,data:e.data}),[]),ae=(0,f.useRef)(null),[oe,se]=(0,f.useState)(`-${t/2} -${t/2} ${t} ${t}`),[ce,le]=(0,f.useState)(1);(0,f.useLayoutEffect)(()=>{if(!n){se(`-${t/2} -${t/2} ${t} ${t}`);return}let e=ae.current;if(!e)return;let r=requestAnimationFrame(()=>{try{let t=e.getBBox();se(`${t.x-20} ${t.y-20} ${t.width+40} ${t.height+40}`)}catch{se(`-${t/2} -${t/2} ${t} ${t}`)}});return()=>cancelAnimationFrame(r)},[t,G,i,n]);let ue=(0,f.useMemo)(()=>{if(ce===1)return oe;let[e,t,n,r]=oe.split(` `).map(Number),i=n/ce,a=r/ce;return`${e+(n-i)/2} ${t+(r-a)/2} ${i} ${a}`},[oe,ce]),de=(0,f.useCallback)(e=>{if(!b||O||!e.ctrlKey)return;e.preventDefault();let t=e.deltaY<0?1.15:1/1.15;le(e=>Math.max(.25,Math.min(8,e*t)))},[b,O]),fe=(0,f.useRef)(null),pe=e=>{fe.current&&=(clearTimeout(fe.current),null),fe.current=setTimeout(()=>{e(),fe.current=null},250)},me=()=>{fe.current&&=(clearTimeout(fe.current),null)};(0,f.useEffect)(()=>()=>me(),[]),(0,f.useLayoutEffect)(()=>{if(!b&&!x)return;let t=t=>{t.key===`Escape`&&(b&&le(1),x&&(me(),L([e]),S?.(null)))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[b,x,e,S]);let[he,ge]=(0,f.useState)(null),_e=(0,f.useRef)(null),ve=(0,f.useRef)(null),[ye,be]=(0,f.useState)(!1),[xe,Se]=(0,f.useState)(null),[Ce,we]=(0,f.useState)({left:0,top:0}),[Te,Ee]=(0,f.useState)(null),De=(0,f.useCallback)(()=>{L(e=>{if(e.length<=1)return e;let t=e.slice(0,-1);return S?.(t.length<=1?null:{id:t[t.length-1].id,name:t[t.length-1].name,subname:t[t.length-1].subname??null,value:null,specialValueA:null,specialValueB:null,depth:t.length-1,path:t.map(e=>e.name),childrenCount:t[t.length-1].children?.length??0,data:t[t.length-1]}),t})},[S]),Oe=e=>{O||!x||(e.ctrlKey||e.metaKey)&&(me(),De())},ke=e=>{if(O)return;let t=q[Number(e.currentTarget.getAttribute(`data-idx`))];if(!t)return;let n=ie(t);if((e.ctrlKey||e.metaKey)&&x&&t.children){pe(()=>{L(e=>[...e,t.data]),S?.(n)});return}if(w){let t=_e.current?.getBoundingClientRect();we({left:t?e.clientX-t.left:e.clientX,top:t?e.clientY-t.top:e.clientY}),Se(ve.current),Ee(n),be(!0)}E?.(n,e)},Ae=g||A.palette.text.primary,je=u||A.palette.text.secondary,Me=A.palette.background.paper,Ne=A.typography.fontFamily;return(0,_.jsxs)(d.Box,{ref:_e,sx:{display:`inline-flex`,position:`relative`,opacity:O?.5:1,cursor:O?`not-allowed`:`default`,userSelect:`none`},children:[x&&I.length>1&&(0,_.jsx)(d.Box,{sx:{position:`absolute`,top:4,left:0,right:0,display:`flex`,justifyContent:`center`,gap:.5,pointerEvents:`none`,zIndex:1},children:(0,_.jsx)(d.Typography,{variant:`caption`,sx:{bgcolor:`action.hover`,borderRadius:1,px:1,py:.25,color:`text.secondary`,fontSize:`0.7rem`},children:I.map(e=>e.name).join(` › `)})}),(0,_.jsx)(d.Box,{ref:ve,sx:{position:`absolute`,left:Ce.left,top:Ce.top,width:0,height:0}}),(0,_.jsx)(`svg`,{width:t,height:t,viewBox:ue,onWheel:de,style:{fontFamily:Ne??`sans-serif`,overflow:b&&ce>1?`hidden`:`visible`},role:`img`,"aria-label":e.name,children:(0,_.jsxs)(`g`,{ref:ae,children:[U&&(0,_.jsx)(`text`,{textAnchor:`middle`,dy:`0.35em`,fontSize:13,fill:Ae,children:j.noData}),(0,_.jsx)(`g`,{fill:`none`,stroke:je,strokeOpacity:p,strokeWidth:m,children:K.map((e,t)=>(0,_.jsx)(`path`,{d:re(e)},`link-${t}`))}),(0,_.jsx)(`g`,{children:q.map((e,t)=>{let n=P(e),r=F(e),i=ie(e),o=he===t,s=e.children?Li.folder:Li.person,c=Math.round(n*1.3);return(0,_.jsx)(d.Tooltip,{title:(0,_.jsxs)(d.Box,{sx:{py:.5,minWidth:160},children:[(0,_.jsx)(d.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`,fontSize:`0.8rem`},children:e.data.name}),e.data.subname&&(0,_.jsx)(d.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:e.data.subname}),(i.specialValueA!=null||i.specialValueB!=null||e.children)&&(0,_.jsxs)(d.Box,{sx:{mt:.75,borderTop:`1px solid rgba(255,255,255,0.2)`,pt:.75},children:[i.specialValueA!=null&&(0,_.jsxs)(d.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,_.jsx)(d.Typography,{variant:`caption`,sx:{opacity:.6},children:j.specialValueA??`A`}),(0,_.jsx)(d.Typography,{variant:`caption`,children:String(i.specialValueA)})]}),i.specialValueB!=null&&(0,_.jsxs)(d.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,_.jsx)(d.Typography,{variant:`caption`,sx:{opacity:.6},children:j.specialValueB??`B`}),(0,_.jsx)(d.Typography,{variant:`caption`,children:String(i.specialValueB)})]}),e.children&&(0,_.jsxs)(d.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,_.jsx)(d.Typography,{variant:`caption`,sx:{opacity:.6},children:`Reports`}),(0,_.jsx)(d.Typography,{variant:`caption`,children:e.children.length})]})]})]}),followCursor:!0,enterDelay:50,enterNextDelay:0,disableHoverListener:O,slotProps:{tooltip:{sx:{maxWidth:260}}},children:(0,_.jsxs)(`g`,{"data-idx":t,transform:`rotate(${e.x*180/Math.PI-90}) translate(${e.y},0)`,onClick:ke,onDoubleClick:Oe,onMouseEnter:e=>{O||(ge(t),D?.(i,e))},onMouseLeave:e=>{ge(null),D?.(null,e)},style:{cursor:O?`not-allowed`:`pointer`},children:[(0,_.jsx)(`circle`,{r:Math.max(n+8,24),fill:`transparent`}),(0,_.jsx)(`circle`,{r:n+2,fill:r,fillOpacity:.15}),(0,_.jsx)(`circle`,{r:n,fill:r,fillOpacity:o?.85:1,style:{transition:`fill-opacity 0.15s`}}),a&&(0,_.jsx)(Ri,{path:s,size:c})]})},`node-${e.data.id}-${t}`)})}),te&&((e,t)=>(0,_.jsxs)(`g`,{"data-testid":`drill-ghost-layer`,opacity:t,pointerEvents:`none`,children:[(0,_.jsx)(`g`,{fill:`none`,stroke:je,strokeOpacity:p,strokeWidth:m,children:e.links().map((e,t)=>(0,_.jsx)(`path`,{d:re(e)},`ghost-link-${t}`))}),(0,_.jsx)(`g`,{children:e.descendants().map((e,t)=>(0,_.jsxs)(`g`,{transform:`rotate(${e.x*180/Math.PI-90}) translate(${e.y},0)`,children:[(0,_.jsx)(`circle`,{r:P(e)+2,fill:F(e),fillOpacity:.15}),(0,_.jsx)(`circle`,{r:P(e),fill:F(e)}),a&&(0,_.jsx)(Ri,{path:e.children?Li.folder:Li.person,size:Math.round(P(e)*1.3)})]},`ghost-node-${t}`))})]}))(te,X),i&&(0,_.jsx)(`g`,{children:q.map((e,t)=>{let n=P(e),r=e.x<Math.PI==!e.children,i=n+6,a=r?i:-i,o=r?`start`:`end`;return(0,_.jsx)(`text`,{transform:`rotate(${e.x*180/Math.PI-90}) translate(${e.y},0) rotate(${e.x>=Math.PI?180:0})`,dy:`0.35em`,x:a,textAnchor:o,paintOrder:`stroke`,stroke:Me,strokeWidth:3,fill:Ae,fontSize:h,fontWeight:e.depth===0?`bold`:`normal`,pointerEvents:`none`,children:e.data.name},`lbl-${e.data.id}-${t}`)})})]})}),w&&(0,_.jsx)(d.Popover,{open:ye,anchorEl:xe,onClose:()=>be(!1),anchorOrigin:{vertical:`top`,horizontal:`right`},transformOrigin:{vertical:`top`,horizontal:`left`},slotProps:{paper:{elevation:4}},children:Te&&(T?T(Te):(0,_.jsx)(zi,{info:Te,labelA:j.specialValueA??`Value A`,labelB:j.specialValueB??`Value B`}))})]})}Bi.displayName=`RadialTreeChart`;var Vi={noData:`No data`},Hi=.56;function Ui(e,t,n){return e.length*n*Hi<=t?e:t>=3*n*Hi+n*2?`…`:``}function Wi({data:e,size:t=600,padding:n=3,sortBy:r=`value`,showLabels:i=!0,showAllLabels:a=!1,labelFontSize:o=13,innerLabelFontSize:s=9,labelColor:c,chartColors:l,depthColorStart:u,depthColorEnd:p,background:m,duration:h=750,zoomable:g=!1,disabled:v=!1,onCircleClick:y,onCircleHover:b,onZoomChange:x,valueFormatter:S,translation:C}){let w=(0,d.useTheme)(),T={...Vi,...C},E=!e.children?.length&&!e.value,D=[w.palette.primary.main,w.palette.secondary.main,w.palette.error.main,w.palette.warning.main,w.palette.success.main,w.palette.info.main],O=c||w.palette.text.primary,k=m||w.palette.background.default,A=w.typography.fontFamily,j=(0,f.useMemo)(()=>{let i=Z.hierarchy(e).sum(e=>e.value??0);return r===`value`?i.sort((e,t)=>(t.value??0)-(e.value??0)):i.sort((e,t)=>String(e.data.name).localeCompare(String(t.data.name),void 0,{numeric:!0,sensitivity:`base`})),Z.pack().size([t,t]).padding(n)(i)},[e,t,n,r]),M=j.descendants(),N=(0,f.useMemo)(()=>Z.max(M,e=>e.depth)??0,[M]),P=!!(u&&p),F=(0,f.useMemo)(()=>P?Z.scaleSequential(Z.interpolateHcl(u,p)).domain([0,Math.max(1,N)]):null,[P,u,p,N]),I=l&&l.length>0?l:D,L=(0,f.useCallback)(e=>e.data.colorConfig?.fill?e.data.colorConfig.fill:P&&F?e.children?F(e.depth):w.palette.background.paper:I[e.depth%I.length],[P,F,I,w]),[R,z]=(0,f.useState)(1),B=(0,f.useCallback)(e=>{if(!g||v||!e.ctrlKey)return;e.preventDefault();let t=e.deltaY<0?1.15:1/1.15;z(e=>Math.max(.25,Math.min(8,e*t)))},[g,v]);(0,f.useLayoutEffect)(()=>{if(!g)return;let e=e=>{e.key===`Escape`&&z(1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[g]);let V=(0,f.useMemo)(()=>{let e=`${-t/2} ${-t/2} ${t} ${t}`;if(R===1)return e;let n=t/R,r=(t-n)/2;return`${-t/2+r} ${-t/2+r} ${n} ${n}`},[t,R]),H=(0,f.useCallback)(e=>{let t=e.value??0,n=j.value??0;return{id:e.data.id??null,name:e.data.name,value:t||null,percentage:n>0?Math.round(t/n*1e4)/100:0,depth:e.depth,path:e.ancestors().map(e=>e.data.name).reverse(),childrenCount:e.children?.length??0,data:e.data}},[j]),U=(0,f.useRef)(null),W=(0,f.useRef)([j.x,j.y,j.r*2]),G=(0,f.useRef)(j),[K,q]=(0,f.useState)(j),J=(0,f.useCallback)(e=>{G.current=e,q(e)},[]),[ee,te]=(0,f.useState)(j);ee!==j&&(te(j),J(j),G.current=j);let Y=(0,f.useCallback)(e=>{let n=U.current;if(!n)return;W.current=e;let r=t/e[2],o=G.current,c=n.querySelectorAll(`g[data-role='nodes'] > g`),l=n.querySelectorAll(`g[data-role='nodes'] > g > circle`);for(let t=0;t<M.length;t++){let n=M[t],i=c[t];i&&i.setAttribute(`transform`,`translate(${(n.x-e[0])*r},${(n.y-e[1])*r})`);let a=t-1;a>=0&&l[a]&&l[a].setAttribute(`r`,String(n.r*r))}if(i){let t=n.querySelectorAll(`g[data-role='labels'] > text`);for(let n=0;n<M.length;n++){let i=M[n],a=t[n];a&&(a.setAttribute(`transform`,`translate(${(i.x-e[0])*r},${(i.y-e[1])*r})`),a.setAttribute(`font-weight`,i.children?`bold`:`normal`))}}if(a){let t=n.querySelectorAll(`g[data-role='inner-labels'] > text`);for(let n=0;n<M.length;n++){let i=M[n],a=t[n];if(!a)continue;let c=i.r*r,l=c*1.6,u=o===j?i!==j:i.ancestors().includes(o),d=i.parent===o;if(u&&!d&&c>=14){let t=Ui(i.data.name,l,s);t?(a.textContent=t,a.setAttribute(`transform`,`translate(${(i.x-e[0])*r},${(i.y-e[1])*r})`),a.setAttribute(`font-weight`,i.children?`bold`:`normal`),a.style.display=`inline`):a.style.display=`none`}else a.style.display=`none`}}},[M,t,i,a,s,j]);(0,f.useLayoutEffect)(()=>{Y([K.x,K.y,K.r*2])},[j,t,K,Y]);let X=(0,f.useCallback)((e,t)=>{let n=U.current;if(!n)return;let r=K,i=W.current,a=[e.x,e.y,e.r*2];J(e),Z.select(n).transition().duration(t).ease(Z.easeCubic).tween(`zoom`,()=>{let e=Z.interpolateZoom(i,a);return t=>Y(e(t))});let o=n.querySelectorAll(`g[data-role='labels'] > text`);Z.selectAll(o).transition().duration(t).ease(Z.easeCubic).style(`fill-opacity`,(t,n)=>+(M[n].parent===e)).on(`start`,function(t,n){M[n].parent===e&&(this.style.display=`inline`)}).on(`end`,function(t,n){M[n].parent!==e&&(this.style.display=`none`)}),x?.({previousName:r.data.name,currentName:e.data.name,currentDepth:e.depth,isRoot:e===j})},[K,M,j,Y,x,J]),ne=(0,f.useRef)(null),re=e=>{ne.current&&=(clearTimeout(ne.current),null),ne.current=setTimeout(()=>{e(),ne.current=null},250)},ie=()=>{ne.current&&=(clearTimeout(ne.current),null)},ae=(0,f.useRef)(X);(0,f.useEffect)(()=>{ae.current=X},[X]),(0,f.useLayoutEffect)(()=>{if(v)return;let e=e=>{e.key===`Escape`&&(ie(),ae.current(j,h))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[v,j,h]);let oe=e=>{if(v||!(e.ctrlKey||e.metaKey))return;ie(),e.preventDefault();let t=K.parent??j;t!==K&&X(t,e.altKey?Math.max(250,h*10):h)},se={followCursor:!0,enterDelay:50,enterNextDelay:0,disableHoverListener:v,slotProps:{tooltip:{sx:{maxWidth:220}}}};return(0,_.jsxs)(d.Box,{sx:{display:`inline-flex`,position:`relative`,opacity:v?.5:1,cursor:v?`not-allowed`:`default`,userSelect:`none`},children:[(0,_.jsxs)(`svg`,{ref:U,width:t,height:t,viewBox:V,onWheel:B,style:{display:`block`,background:k,fontFamily:A??`sans-serif`,overflow:g&&R>1?`hidden`:`visible`},role:`img`,"aria-label":e.name,onDoubleClick:oe,children:[E&&(0,_.jsx)(`text`,{textAnchor:`middle`,dy:`0.35em`,fontSize:13,fill:w.palette.text.secondary,children:T.noData}),(0,_.jsx)(`g`,{"data-role":`nodes`,children:M.map((e,n)=>{let r=H(e),i=(0,_.jsxs)(d.Box,{sx:{py:.5,minWidth:160},children:[(0,_.jsx)(d.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`,fontSize:`0.8rem`},children:e.data.name}),(e.value??0)>0&&(0,_.jsxs)(d.Box,{sx:{mt:.75,borderTop:`1px solid rgba(255,255,255,0.2)`,pt:.75},children:[(0,_.jsxs)(d.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,_.jsx)(d.Typography,{variant:`caption`,sx:{opacity:.6},children:`Value`}),(0,_.jsx)(d.Typography,{variant:`caption`,children:S?S(e.value??0):(e.value??0).toLocaleString()})]}),(0,_.jsxs)(d.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,_.jsx)(d.Typography,{variant:`caption`,sx:{opacity:.6},children:`Share`}),(0,_.jsxs)(d.Typography,{variant:`caption`,children:[r.percentage,`%`]})]}),e.children&&(0,_.jsxs)(d.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,_.jsx)(d.Typography,{variant:`caption`,sx:{opacity:.6},children:`Children`}),(0,_.jsx)(d.Typography,{variant:`caption`,children:e.children.length})]})]})]});return(0,_.jsx)(`g`,{transform:`translate(${e.x-t/2},${e.y-t/2})`,children:n===0?null:(0,_.jsx)(d.Tooltip,{...se,title:i,children:(0,_.jsx)(`circle`,{r:e.r,fill:L(e),stroke:e.data.colorConfig?.stroke??w.palette.background.paper,strokeWidth:.75,style:{cursor:v?`not-allowed`:e.children?`pointer`:`default`,transition:`stroke-width 0.1s`},onMouseEnter:e=>{v||(e.currentTarget.style.strokeWidth=`2`,b?.(r,e))},onMouseLeave:e=>{e.currentTarget.style.strokeWidth=`0.75`,b?.(null,e)},onClick:t=>{if(!v){if(t.ctrlKey||t.metaKey){if(e.children){let n=t.altKey?Math.max(250,h*10):h;re(()=>X(e,n))}return}y?.(r,t)}},onDoubleClick:e=>{if(!v&&(e.ctrlKey||e.metaKey)){ie(),e.preventDefault(),e.stopPropagation();let t=K.parent??j;t!==K&&X(t,e.altKey?Math.max(250,h*10):h)}}})})},`n-${n}`)})}),i&&(0,_.jsx)(`g`,{"data-role":`labels`,textAnchor:`middle`,dominantBaseline:`middle`,pointerEvents:`none`,fontSize:o,fill:O,children:M.map((e,n)=>(0,_.jsx)(`text`,{transform:`translate(${e.x-t/2},${e.y-t/2})`,style:{display:e.parent===j?`inline`:`none`,fillOpacity:+(e.parent===j)},children:e.data.name},`lbl-${n}`))}),a&&(0,_.jsx)(`g`,{"data-role":`inner-labels`,textAnchor:`middle`,dominantBaseline:`middle`,pointerEvents:`none`,fontSize:s,fill:O,children:M.map((e,n)=>(0,_.jsx)(`text`,{transform:`translate(${e.x-t/2},${e.y-t/2})`,style:{display:`none`}},`inner-lbl-${n}`))})]}),K!==j&&!v&&(0,_.jsx)(d.Box,{sx:{position:`absolute`,bottom:6,left:0,right:0,display:`flex`,justifyContent:`center`,pointerEvents:`none`},children:(0,_.jsxs)(d.Typography,{variant:`caption`,sx:{bgcolor:`action.hover`,borderRadius:1,px:1,py:.25,color:`text.secondary`,fontSize:`0.7rem`},children:[K.ancestors().map(e=>e.data.name).reverse().join(` › `),` · Ctrl / Cmd ⌘+DblClick to zoom out · Escape to reset`]})})]})}Wi.displayName=`CirclePackingChart`;var Gi={noData:`No data`,specialValueA:`Value A`,specialValueB:`Value B`},Ki={folder:`M20 6h-8l-2-2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 12H4V8h16v10z`,person:`M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z`};function qi({path:e,size:t}){let n=t/2;return(0,_.jsx)(`g`,{transform:`translate(${-n},${-n})`,pointerEvents:`none`,children:(0,_.jsx)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,overflow:`visible`,children:(0,_.jsx)(`path`,{d:e,fill:`white`})})})}function Ji({info:e,labelA:t,labelB:n}){return(0,_.jsxs)(d.Box,{sx:{p:2,minWidth:200,maxWidth:280},children:[(0,_.jsxs)(d.Box,{sx:{display:`flex`,alignItems:`center`,gap:1.5,mb:1.5},children:[(0,_.jsx)(d.Avatar,{sx:{bgcolor:`primary.main`,width:40,height:40},children:e.name.charAt(0).toUpperCase()}),(0,_.jsxs)(d.Box,{children:[(0,_.jsx)(d.Typography,{variant:`body2`,sx:{fontWeight:`bold`},children:e.name}),e.subname&&(0,_.jsx)(d.Typography,{variant:`caption`,color:`text.secondary`,children:e.subname})]})]}),(e.specialValueA!=null||e.specialValueB!=null)&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(d.Divider,{sx:{mb:1.5}}),e.specialValueA!=null&&(0,_.jsxs)(d.Box,{sx:{display:`flex`,justifyContent:`space-between`,mb:.5},children:[(0,_.jsx)(d.Typography,{variant:`caption`,color:`text.secondary`,children:t}),(0,_.jsx)(d.Typography,{variant:`caption`,children:String(e.specialValueA)})]}),e.specialValueB!=null&&(0,_.jsxs)(d.Box,{sx:{display:`flex`,justifyContent:`space-between`},children:[(0,_.jsx)(d.Typography,{variant:`caption`,color:`text.secondary`,children:n}),(0,_.jsx)(d.Typography,{variant:`caption`,children:String(e.specialValueB)})]})]})]})}function Yi({data:e,orientation:t=`LR`,width:n=800,height:r=500,levelSpacing:i=200,nodeRadius:a=10,sortBy:o=`name`,showLabels:s=!0,labelFontSize:c=12,labelColor:l,showIcons:u=!0,chartColors:p,linkStrokeOpacity:m=1,linkStrokeWidth:h=1.5,linkColor:g,zoomable:v=!1,drillable:y=!1,onFocusChange:b,showNodePopover:x=!1,renderNodePopoverContent:S,onNodeClick:C,onNodeHover:w,duration:T=750,disabled:E=!1,translation:D}){let O=(0,d.useTheme)(),k={...Gi,...D},A=[O.palette.primary.main,O.palette.secondary.main,O.palette.error.main,O.palette.warning.main,O.palette.success.main,O.palette.info.main],j=p&&p.length>0?p:A,M=l||O.palette.text.primary,N=g||O.palette.text.secondary,P=O.palette.background.paper,F=O.typography.fontFamily,I=!e.children?.length&&!e.value,L=t===`TB`||t===`BT`,R=L?r:n,z=L?n:r,[B,V]=(0,f.useState)([e]),H=B[B.length-1],[U,W]=(0,f.useState)(e),[G,K]=(0,f.useState)(!1);U!==e&&(W(e),V([e]),K(!0));let q=(0,f.useMemo)(()=>{let e=Z.hierarchy(H);o===`value`?(e.sum(e=>e.value??0),e.sort((e,t)=>(t.value??0)-(e.value??0))):e.sort((e,t)=>Z.ascending(String(e.data.name),String(t.data.name)));let t=Z.max(e.descendants(),e=>e.depth)??1;return Z.tree().size([R*.8,Math.min(t*i,z*.85)])(e)},[H,o,R,z,i]),J=(0,f.useMemo)(()=>{let e=Z.max(Z.hierarchy(H).descendants(),e=>e.depth)??1;return Math.min(e*i,z*.85)},[H,i,z]),ee=q.descendants(),te=q.links(),Y=(0,f.useRef)(q),X=(0,f.useRef)(null),[ne,re]=(0,f.useState)(null),[ie,ae]=(0,f.useState)(0);(0,f.useEffect)(()=>{let e=Y.current;if(Y.current=q,e===q)return;if(X.current!=null&&(cancelAnimationFrame(X.current),X.current=null),G||T<=0){K(!1),re(null);return}re(e),ae(1);let t=performance.now(),n=e=>{let r=Math.min(1,(e-t)/T);ae(1-Z.easeCubic(r)),r<1?X.current=requestAnimationFrame(n):(X.current=null,re(null))};return X.current=requestAnimationFrame(n),()=>{X.current!=null&&cancelAnimationFrame(X.current)}},[q,T,G]);let oe=(0,f.useCallback)(e=>e.data.colorConfig?.fill??j[e.depth%j.length],[j]),se=(0,f.useCallback)(e=>{switch(t){case`LR`:return{x:e.y,y:e.x-R*.4};case`RL`:return{x:J-e.y,y:e.x-R*.4};case`TB`:return{x:e.x-R*.4,y:e.y};case`BT`:return{x:e.x-R*.4,y:J-e.y}}},[t,R,J]),ce=(0,f.useCallback)(e=>{let n=se(e.source),r=se(e.target);if(t===`LR`||t===`RL`){let e=(n.x+r.x)/2;return`M${n.x},${n.y} C${e},${n.y} ${e},${r.y} ${r.x},${r.y}`}let i=(n.y+r.y)/2;return`M${n.x},${n.y} C${n.x},${i} ${r.x},${i} ${r.x},${r.y}`},[se,t]),le=(0,f.useCallback)(e=>({id:e.data.id??null,name:e.data.name,subname:e.data.subname??null,value:e.value??e.data.value??null,specialValueA:e.data.specialValueA??null,specialValueB:e.data.specialValueB??null,depth:e.depth,path:e.ancestors().map(e=>e.data.name).reverse(),childrenCount:e.children?.length??0,data:e.data}),[]),[ue,de]=(0,f.useState)(`0 -${r/2} ${n} ${r}`),[fe,pe]=(0,f.useState)(1),me=(0,f.useRef)(null),he=(0,f.useMemo)(()=>{if(fe===1)return ue;let[e,t,n,r]=ue.split(` `).map(Number),i=n/fe,a=r/fe;return`${e+(n-i)/2} ${t+(r-a)/2} ${i} ${a}`},[ue,fe]);(0,f.useLayoutEffect)(()=>{let e=me.current;if(!e)return;let t=requestAnimationFrame(()=>{try{let t=e.getBBox();de(`${t.x-24} ${t.y-24} ${t.width+48} ${t.height+48}`)}catch{de(`0 -${r/2} ${n} ${r}`)}});return()=>cancelAnimationFrame(t)},[q,n,r,t]);let ge=(0,f.useCallback)(e=>{if(!v||E||!e.ctrlKey)return;e.preventDefault();let t=e.deltaY<0?1.15:1/1.15;pe(e=>Math.max(.25,Math.min(8,e*t)))},[v,E]),_e=(0,f.useRef)(null),ve=e=>{_e.current&&=(clearTimeout(_e.current),null),_e.current=setTimeout(()=>{e(),_e.current=null},250)},ye=()=>{_e.current&&=(clearTimeout(_e.current),null)};(0,f.useEffect)(()=>()=>ye(),[]);let be=(0,f.useCallback)(()=>{V(e=>{if(e.length<=1)return e;let t=e.slice(0,-1);return b?.({focusedNode:{id:t[t.length-1].id??null,name:t[t.length-1].name,subname:t[t.length-1].subname??null,value:null,specialValueA:null,specialValueB:null,depth:t.length-1,path:t.map(e=>e.name),childrenCount:t[t.length-1].children?.length??0,data:t[t.length-1]},isRoot:t.length<=1}),t})},[b]);(0,f.useLayoutEffect)(()=>{if(!v&&!y)return;let t=t=>{t.key===`Escape`&&(v&&pe(1),y&&(ye(),V([e]),b?.({focusedNode:{id:e.id??null,name:e.name,subname:e.subname??null,value:null,specialValueA:null,specialValueB:null,depth:0,path:[e.name],childrenCount:e.children?.length??0,data:e},isRoot:!0})))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[v,y,e,b]);let xe=(0,f.useRef)(null),Se=(0,f.useRef)(null),[Ce,we]=(0,f.useState)(!1),[Te,Ee]=(0,f.useState)(null),[De,Oe]=(0,f.useState)({left:0,top:0}),[ke,Ae]=(0,f.useState)(null),je=(e,t)=>{if(E)return;let n=le(e);if((t.ctrlKey||t.metaKey)&&y&&e.children){ve(()=>{V(t=>[...t,e.data]),b?.({focusedNode:n,isRoot:!1})});return}if((t.ctrlKey||t.metaKey)&&y){ye(),be();return}if(x){let e=xe.current?.getBoundingClientRect();Oe({left:e?t.clientX-e.left:t.clientX,top:e?t.clientY-e.top:t.clientY}),Ee(Se.current),Ae(n),we(!0)}C?.(n,t)},Me=(e,t)=>{E||!y||(t.ctrlKey||t.metaKey)&&(ye(),be())},Ne={followCursor:!0,enterDelay:50,enterNextDelay:0,disableHoverListener:E,slotProps:{tooltip:{sx:{maxWidth:240}}}},Pe=Math.round(a*1.3);return(0,_.jsxs)(d.Box,{ref:xe,sx:{display:`inline-flex`,position:`relative`,opacity:E?.5:1,cursor:E?`not-allowed`:`default`,userSelect:`none`},children:[(0,_.jsx)(d.Box,{ref:Se,sx:{position:`absolute`,left:De.left,top:De.top,width:0,height:0}}),y&&B.length>1&&(0,_.jsx)(d.Box,{sx:{position:`absolute`,top:4,left:0,right:0,display:`flex`,justifyContent:`center`,pointerEvents:`none`,zIndex:1},children:(0,_.jsx)(d.Typography,{variant:`caption`,sx:{bgcolor:`action.hover`,borderRadius:1,px:1,py:.25,color:`text.secondary`,fontSize:`0.7rem`},children:B.map(e=>e.name).join(` › `)})}),(0,_.jsx)(`svg`,{width:n,height:r,viewBox:he,onWheel:ge,style:{fontFamily:F??`sans-serif`,overflow:v&&fe>1?`hidden`:`visible`},role:`img`,"aria-label":e.name,children:(0,_.jsxs)(`g`,{ref:me,children:[I&&(0,_.jsx)(`text`,{textAnchor:`middle`,dy:`0.35em`,fontSize:13,fill:M,children:k.noData}),(0,_.jsx)(`g`,{fill:`none`,stroke:N,strokeOpacity:m,strokeWidth:h,children:te.map((e,t)=>(0,_.jsx)(`path`,{d:ce(e)},`link-${t}`))}),ee.map((e,n)=>{let r=se(e),i=oe(e),o=le(e),l=e.children?Ki.folder:Ki.person,f=t===`LR`,p=t===`RL`,m=f?a+6:p?-(a+6):0,h=!f&&!p?t===`TB`?a+16:-(a+6):0,g=f?`start`:p?`end`:`middle`,v=(0,_.jsxs)(d.Box,{sx:{py:.5,minWidth:140},children:[(0,_.jsx)(d.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`,fontSize:`0.8rem`},children:e.data.name}),e.data.subname&&(0,_.jsx)(d.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:e.data.subname}),(o.specialValueA!=null||o.specialValueB!=null||e.children)&&(0,_.jsxs)(d.Box,{sx:{mt:.75,borderTop:`1px solid rgba(255,255,255,0.2)`,pt:.75},children:[o.specialValueA!=null&&(0,_.jsxs)(d.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,_.jsx)(d.Typography,{variant:`caption`,sx:{opacity:.6},children:k.specialValueA??`A`}),(0,_.jsx)(d.Typography,{variant:`caption`,children:String(o.specialValueA)})]}),o.specialValueB!=null&&(0,_.jsxs)(d.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,_.jsx)(d.Typography,{variant:`caption`,sx:{opacity:.6},children:k.specialValueB??`B`}),(0,_.jsx)(d.Typography,{variant:`caption`,children:String(o.specialValueB)})]}),e.children&&(0,_.jsxs)(d.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,_.jsx)(d.Typography,{variant:`caption`,sx:{opacity:.6},children:`Reports`}),(0,_.jsx)(d.Typography,{variant:`caption`,children:e.children.length})]})]})]});return(0,_.jsx)(d.Tooltip,{...Ne,title:v,children:(0,_.jsxs)(`g`,{transform:`translate(${r.x},${r.y})`,onClick:t=>je(e,t),onDoubleClick:t=>Me(e,t),onMouseEnter:t=>{E||w?.(le(e),t)},onMouseLeave:e=>{w?.(null,e)},style:{cursor:E?`not-allowed`:`pointer`},children:[(0,_.jsx)(`circle`,{r:a+8,fill:`transparent`}),(0,_.jsx)(`circle`,{r:a+2,fill:i,fillOpacity:.15}),(0,_.jsx)(`circle`,{r:a,fill:i}),u&&(0,_.jsx)(qi,{path:l,size:Pe}),s&&(0,_.jsx)(`text`,{x:m,y:h,dy:`0.35em`,textAnchor:g,fontSize:c,fontWeight:e.children?`bold`:`normal`,fill:e.data.colorConfig?.textColor??M,paintOrder:`stroke`,stroke:P,strokeWidth:3,pointerEvents:`none`,children:e.data.name})]})},`node-${n}`)}),ne&&((e,t)=>(0,_.jsxs)(`g`,{"data-testid":`drill-ghost-layer`,opacity:t,pointerEvents:`none`,children:[(0,_.jsx)(`g`,{fill:`none`,stroke:N,strokeOpacity:m,strokeWidth:h,children:e.links().map((e,t)=>(0,_.jsx)(`path`,{d:ce(e)},`ghost-link-${t}`))}),(0,_.jsx)(`g`,{children:e.descendants().map((e,t)=>{let n=se(e);return(0,_.jsxs)(`g`,{transform:`translate(${n.x},${n.y})`,children:[(0,_.jsx)(`circle`,{r:a+2,fill:oe(e),fillOpacity:.15}),(0,_.jsx)(`circle`,{r:a,fill:oe(e)}),u&&(0,_.jsx)(qi,{path:e.children?Ki.folder:Ki.person,size:Pe})]},`ghost-node-${t}`)})})]}))(ne,ie)]})}),x&&(0,_.jsx)(d.Popover,{open:Ce,anchorEl:Te,onClose:()=>we(!1),anchorOrigin:{vertical:`top`,horizontal:`right`},transformOrigin:{vertical:`top`,horizontal:`left`},slotProps:{paper:{elevation:4}},children:ke&&(S?S(ke):(0,_.jsx)(Ji,{info:ke,labelA:k.specialValueA??`Value A`,labelB:k.specialValueB??`Value B`}))})]})}Yi.displayName=`HorizontalTreeChart`;var Xi={noData:`No data`};function Zi(e,t=0,n=`.`,r=`,`){let[i,a]=e.toFixed(Math.max(0,t)).split(`.`),o=i.replace(/\B(?=(\d{3})+(?!\d))/g,r);return a?`${o}${n}${a}`:o}function Qi(e){return Math.abs(e)>=1e9?`${(e/1e9).toFixed(1).replace(/\.0$/,``)}B`:Math.abs(e)>=1e6?`${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`:Math.abs(e)>=1e3?`${(e/1e3).toFixed(1).replace(/\.0$/,``)}k`:String(e)}function $i(e){return e.map(e=>typeof e==`string`?{key:e,label:e}:e)}function ea({barData:e,seriesKey:t,seriesLabel:n,decimals:r,decimalSep:i,thousandSep:a,valueFormatter:o}){let s=e.values[t]??0,c=Z.sum(Object.values(e.values)),l=c>0?Math.round(s/c*1e3)/10:0,u=(e,t)=>o?o(e,t):Zi(e,r,i,a);return(0,_.jsxs)(d.Box,{sx:{py:.25},children:[(0,_.jsx)(d.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`},children:e.label}),(0,_.jsxs)(d.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:[n,`: `,u(s,t)]}),(0,_.jsxs)(d.Typography,{variant:`caption`,sx:{display:`block`,opacity:.65,mt:.25},children:[l,`% · Total: `,u(c,``)]})]})}function ta({data:e,keys:t,size:n=500,innerRadius:r,barPadding:i=.12,chartColors:a,colorConfig:o,showLabels:s=!0,showGridLines:c=!0,gridLineCount:l=3,showGridValues:u=!0,showLegend:p=!0,sortBy:m=`none`,valueDecimalCount:h=0,valueDecimalSeparator:g=`.`,valueThousandsSeparator:v=`,`,valueFormatter:y,gridValueFormatter:b,zoomable:x=!1,onBarClick:S,onBarHover:C,disabled:w=!1,translation:T}){let E=(0,d.useTheme)(),D={...Xi,...T},O=(0,f.useMemo)(()=>$i(t),[t]),k=(0,f.useMemo)(()=>O.map(e=>e.key),[O]),A=e.length===0||O.length===0,j=s?63:16,M=n/2-j,N=r==null?Math.round(n*.18):Math.max(0,Math.min(r,M-1)),P=[E.palette.primary.main,E.palette.secondary.main,E.palette.success.main,E.palette.warning.main,E.palette.error.main,E.palette.info.main,`#8e24aa`,`#00897b`,`#f06292`,`#a1887f`],F=a&&a.length>0?a:P,I=(0,f.useCallback)((e,t)=>{let n=o?.[e];return n?.fill?n.fill:F[t%F.length]},[o,F]),L=(0,f.useMemo)(()=>m===`value`?[...e].sort((e,t)=>Z.sum(k,e=>t.values[e]??0)-Z.sum(k,t=>e.values[t]??0)):m===`label`?[...e].sort((e,t)=>e.label.localeCompare(t.label,void 0,{numeric:!0,sensitivity:`base`})):e,[e,m,k]),R=(0,f.useMemo)(()=>Z.max(L,e=>Z.sum(k,t=>e.values[t]??0))??0,[L,k]),z=(0,f.useMemo)(()=>Z.scaleBand().domain(L.map(e=>e.id)).range([0,2*Math.PI]).padding(i),[L,i]),B=(0,f.useMemo)(()=>Z.scaleLinear().domain([0,R]).range([N,M]),[N,M,R]),V=(0,f.useMemo)(()=>A?[]:Z.stack().keys(k).value((e,t)=>e.values[t]??0).order(Z.stackOrderNone).offset(Z.stackOffsetNone)(L),[A,L,k]),H=(0,f.useMemo)(()=>Z.arc().startAngle(e=>e.x0).endAngle(e=>e.x1).innerRadius(e=>e.y0).outerRadius(e=>e.y1).padAngle(.008).padRadius(N+10),[N]),U=(0,f.useMemo)(()=>R>0?Z.ticks(0,R,l).filter(e=>e>0):[],[R,l]),W=b??Qi,[G,K]=(0,f.useState)(1),q=(0,f.useRef)(null),[J,ee]=(0,f.useState)(`-${n/2} -${n/2} ${n} ${n}`),te=(0,f.useMemo)(()=>{if(G===1)return J;let[e,t,n,r]=J.split(` `).map(Number),i=n/G,a=r/G;return`${e+(n-i)/2} ${t+(r-a)/2} ${i} ${a}`},[J,G]);(0,f.useLayoutEffect)(()=>{let e=q.current;if(!e)return;let t=requestAnimationFrame(()=>{try{let t=e.getBBox();ee(`${t.x-4} ${t.y-4} ${t.width+8} ${t.height+8}`)}catch{ee(`-${n/2} -${n/2} ${n} ${n}`)}});return()=>cancelAnimationFrame(t)},[n,e,t,N,M,s,c]),(0,f.useLayoutEffect)(()=>{if(w)return;let e=e=>{e.key===`Escape`&&K(1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[w]);let Y=(0,f.useCallback)(e=>{if(!x||w||!e.ctrlKey)return;e.preventDefault();let t=e.deltaY<0?1.15:1/1.15;K(e=>Math.max(.25,Math.min(8,e*t)))},[x,w]),X=-(O.length*16)/2,ne=Math.max(0,N*2-10-5-10),re=9*.57,ie=O.reduce((e,t)=>Math.max(e,(t.label??t.key).length),0),ae=-((15+Math.min(ie*re,ne))/2),oe=Math.max(1,Math.floor(ne/re)),se=e=>e.length<=oe?e:`${e.slice(0,oe-1)}…`,ce={followCursor:!0,enterDelay:50,enterNextDelay:0,disableHoverListener:w,slotProps:{tooltip:{sx:{maxWidth:240}}}},le=E.palette.text.primary,ue=E.palette.divider,de=E.typography.fontFamily;return(0,_.jsx)(d.Box,{style:{opacity:w?.5:1},sx:{display:`inline-flex`,cursor:w?`not-allowed`:`default`,userSelect:`none`},children:(0,_.jsx)(`svg`,{width:n,height:n,viewBox:te,onWheel:Y,style:{fontFamily:de??`sans-serif`,overflow:x&&G>1?`hidden`:`visible`},role:`img`,"aria-label":`Radial stacked bar chart`,children:(0,_.jsxs)(`g`,{ref:q,children:[A&&(0,_.jsx)(`text`,{textAnchor:`middle`,dy:`0.35em`,fontSize:13,fill:E.palette.text.secondary,children:D.noData}),!A&&(0,_.jsxs)(_.Fragment,{children:[c&&U.map(e=>(0,_.jsx)(`circle`,{r:B(e),fill:`none`,stroke:ue,strokeWidth:.5,strokeDasharray:`3 2`},`grid-${e}`)),c&&(0,_.jsx)(`circle`,{r:N,fill:`none`,stroke:ue,strokeWidth:.75}),c&&u&&U.map(e=>(0,_.jsx)(`text`,{x:0,y:-B(e),textAnchor:`middle`,dy:`-3`,fontSize:9,fill:E.palette.text.secondary,pointerEvents:`none`,children:W(e)},`gv-${e}`)),V.map((e,t)=>{let n=e.key,r=O[t]?.label??n,i=I(n,t);return e.map((e,t)=>{let a=e.data,o=z(a.id)??0,s=o+z.bandwidth(),c=B(e[0]),l=B(e[1]);if(l-c<.5)return null;let u=H({x0:o,x1:s,y0:c,y1:l})??``;return(0,_.jsx)(d.Tooltip,{...ce,placement:`top`,title:(0,_.jsx)(ea,{barData:a,seriesKey:n,seriesLabel:r,decimals:h,decimalSep:g,thousandSep:v,valueFormatter:y}),children:(0,_.jsx)(`path`,{d:u,fill:i,style:{cursor:w?`not-allowed`:`pointer`,transition:`opacity 0.15s`},onMouseEnter:e=>{if(w)return;e.currentTarget.style.opacity=`0.75`;let t=Z.sum(k,e=>a.values[e]??0),r={id:a.id,label:a.label,seriesKey:n,value:a.values[n]??0,total:t,values:a.values};C?.(r,e)},onMouseLeave:e=>{e.currentTarget.style.opacity=`1`,C?.(null,e)},onClick:e=>{if(w)return;let t=Z.sum(k,e=>a.values[e]??0),r={id:a.id,label:a.label,seriesKey:n,value:a.values[n]??0,total:t,values:a.values};S?.(r,e)}})},`${n}-${t}`)})}),s&&L.map(e=>{let t=(z(e.id)??0)+z.bandwidth()/2,n=M+8,r=n*Math.sin(t),i=-n*Math.cos(t),a=t*180/Math.PI;return(0,_.jsx)(`text`,{x:r,y:i,transform:`rotate(${a<180?a-90:a+90},${r},${i})`,textAnchor:`middle`,dominantBaseline:`central`,fontSize:11,fill:le,pointerEvents:`none`,children:e.label},`lbl-${e.id}`)}),p&&(0,_.jsx)(`g`,{pointerEvents:`none`,transform:`translate(${ae},0)`,children:O.map((e,t)=>{let n=I(e.key,t),r=X+t*16,i=se(e.label??e.key);return(0,_.jsxs)(`g`,{transform:`translate(0,${r})`,children:[(0,_.jsx)(`rect`,{x:0,y:0,width:10,height:10,fill:n,rx:2}),(0,_.jsx)(`text`,{x:15,y:10/2,dominantBaseline:`central`,fontSize:9,fill:le,children:i})]},`leg-${e.key}`)})})]})]})})})}ta.displayName=`RadialStackedBarChart`,exports.ChordChart=Fi,exports.CirclePackingChart=Wi,exports.ColorPicker=Tt,exports.DEFAULT_CHECK_COLORS=_r,exports.DEFAULT_CHORD_CHART_TRANSLATION=ji,exports.DEFAULT_CIRCLE_PACKING_TRANSLATION=Vi,exports.DEFAULT_COLOR_PICKER_TRANSLATION=bt,exports.DEFAULT_DATE_RANGE_PICKER_TRANSLATION=Xe,exports.DEFAULT_GANTT_TRANSLATIONS=Dn,exports.DEFAULT_HORIZONTAL_TREE_TRANSLATION=Gi,exports.DEFAULT_JSON_EDITOR_TOOLBAR_CONFIG=Ot,exports.DEFAULT_JSON_EDITOR_TRANSLATION=kt,exports.DEFAULT_KANBAN_BOARD_TRANSLATION=He,exports.DEFAULT_METER_COLORS=gr,exports.DEFAULT_PASSWORD_TRANSLATIONS=hr,exports.DEFAULT_POPOVER_COLOR_PICKER_TRANSLATION=xt,exports.DEFAULT_RADIAL_STACKED_BAR_CHART_TRANSLATION=Xi,exports.DEFAULT_RADIAL_TREE_CHART_TRANSLATION=Ii,exports.DEFAULT_RICH_TEXT_EDITOR_TOOLBAR_CONFIG=Lr,exports.DEFAULT_RICH_TEXT_EDITOR_TRANSLATION=Rr,exports.DEFAULT_SQL_EDITOR_TOOLBAR_CONFIG=ai,exports.DEFAULT_SQL_EDITOR_TRANSLATION=oi,exports.DEFAULT_SUNBURST_CHART_TRANSLATION=Si,exports.DEFAULT_TAG_SELECTION_TRANSLATION=Mr,exports.DateRangePicker=nt,exports.GanttChart=dr,exports.HorizontalTreeChart=Yi,exports.JsonEditor=en,exports.KanbanBoard=Je,exports.PasswordStrengthMeter=br,exports.PopoverColorPicker=Dt,exports.RadialStackedBarChart=ta,exports.RadialTreeChart=Bi,exports.RichTextEditor=ii,exports.SqlEditor=xi,exports.SunburstChart=Ai,exports.TagSelection=Ir,exports.colorPickerClasses=at,exports.dateRangePickerClasses=Ye,exports.kanbanBoardClasses=Ve,exports.muiTsStateClasses=Be,exports.passwordStrengthMeterClasses=it,exports.popoverColorPickerClasses=ot,exports.tagSelectionClasses=rt,exports.useGanttChartStore=$,exports.useGanttTheme=or,exports.useGanttTranslations=ir,exports.useRawGanttChartStore=nr;