@thebuoyant-tsdev/mui-ts-library 3.4.0 → 3.6.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(`react`),l=require(`@mui/material`),u=require(`@codemirror/view`),d=require(`@codemirror/state`),f=require(`@codemirror/lang-json`),p=require(`@codemirror/commands`),m=require(`@codemirror/language`),h=require(`@codemirror/lint`),g=require(`@lezer/highlight`),_=require(`@replit/codemirror-minimap`),v=require(`react/jsx-runtime`),y=require(`@mui/icons-material/ContentCopy`);y=s(y,1);let b=require(`@mui/icons-material/Check`);b=s(b,1);let x=require(`@mui/icons-material/Delete`);x=s(x,1);let S=require(`@mui/icons-material/Undo`);S=s(S,1);let C=require(`@mui/icons-material/Redo`);C=s(C,1);let w=require(`@mui/icons-material/AutoFixHigh`);w=s(w,1);let T=require(`@mui/icons-material/Compress`);T=s(T,1);let E=require(`@mui/icons-material/CheckCircleOutlined`);E=s(E,1);let D=require(`@mui/icons-material/ErrorOutlined`);D=s(D,1);let O=require(`zustand`),k=require(`zustand/vanilla`),A=require(`@tanstack/react-virtual`),j=require(`@mui/icons-material/Add`);j=s(j,1);let M=require(`@mui/icons-material/Edit`);M=s(M,1);let N=require(`@mui/icons-material/Download`);N=s(N,1);let P=require(`@mui/icons-material/RestartAlt`);P=s(P,1);let F=require(`@mui/icons-material/Restore`);F=s(F,1);let I=require(`@mui/icons-material/Today`);I=s(I,1);let L=require(`@mui/icons-material/UnfoldLess`);L=s(L,1);let R=require(`@mui/icons-material/UnfoldMore`);R=s(R,1);let z=require(`@mui/icons-material/CheckCircle`);z=s(z,1);let B=require(`@mui/icons-material/Cancel`);B=s(B,1);let V=require(`@mui/icons-material/Visibility`);V=s(V,1);let H=require(`@mui/icons-material/VisibilityOff`);H=s(H,1);let U=require(`@mui/icons-material/Close`);U=s(U,1);let W=require(`@tiptap/react`),G=require(`@tiptap/starter-kit`),K=require(`@tiptap/extension-text-style`),q=require(`@tiptap/extension-color`),J=require(`@tiptap/extension-highlight`),Y=require(`@tiptap/extension-placeholder`),X=require(`@tiptap/extension-character-count`),ee=require(`@tiptap/extension-table`),te=require(`@tiptap/extension-image`),ne=require(`tiptap-markdown`),re=require(`@mui/icons-material/Fullscreen`);re=s(re,1);let ie=require(`@mui/icons-material/FullscreenExit`);ie=s(ie,1);let ae=require(`@mui/icons-material/Image`);ae=s(ae,1);let oe=require(`@mui/icons-material/EmojiEmotions`);oe=s(oe,1);let se=require(`@mui/icons-material/FormatBold`);se=s(se,1);let ce=require(`@mui/icons-material/FormatItalic`);ce=s(ce,1);let le=require(`@mui/icons-material/FormatUnderlined`);le=s(le,1);let ue=require(`@mui/icons-material/StrikethroughS`);ue=s(ue,1);let de=require(`@mui/icons-material/FormatListBulleted`);de=s(de,1);let fe=require(`@mui/icons-material/FormatListNumbered`);fe=s(fe,1);let pe=require(`@mui/icons-material/FormatQuote`);pe=s(pe,1);let me=require(`@mui/icons-material/Code`);me=s(me,1);let he=require(`@mui/icons-material/InsertLink`);he=s(he,1);let ge=require(`@mui/icons-material/HorizontalRule`);ge=s(ge,1);let _e=require(`@mui/icons-material/FormatColorText`);_e=s(_e,1);let ve=require(`@mui/icons-material/BorderColor`);ve=s(ve,1);let ye=require(`@mui/icons-material/FormatClear`);ye=s(ye,1);let be=require(`@mui/icons-material/FormatColorReset`);be=s(be,1);let xe=require(`@mui/icons-material/TableChart`);xe=s(xe,1);let Se=require(`@mui/icons-material/Search`);Se=s(Se,1);let Ce=require(`@codemirror/lang-sql`),we=require(`@codemirror/autocomplete`),Te=require(`@mui/icons-material/PlayArrow`);Te=s(Te,1);let Ee=require(`sql-formatter`),De=require(`@mui/icons-material/WarningAmber`);De=s(De,1);let Z=require(`d3`);Z=s(Z,1);var Oe={showFormat:!0,showCompact:!0,showCopy:!0,showClear:!0,showUndoRedo:!0},ke={format:`Format JSON`,compact:`Compact JSON`,copy:`Copy`,copySuccess:`Copied!`,clear:`Clear`,undo:`Undo`,redo:`Redo`,lineColumn:`Ln {line}, Col {col}`,validJson:`Valid JSON`,invalidJson:`Invalid JSON`};function Ae({value:e,onChange:t,placeholder:n,disabled:r=!1,readonly:i=!1,showLineNumbers:a=!0,showMinimap:o=!1,highlightColors:s,onViewReady:y,onCursorChange:b,onBlur:x,onFocus:S}){let C=(0,c.useRef)(null),w=(0,c.useRef)(null),T=(0,c.useRef)(t),E=(0,c.useRef)(b),D=(0,c.useRef)(x),O=(0,c.useRef)(S),k=(0,c.useRef)(y),A=(0,c.useRef)(new d.Compartment),j=(0,c.useRef)(new d.Compartment),M=(0,l.useTheme)(),N=M.palette.mode===`dark`,P=s?.propertyName??M.palette.primary.main,F=s?.string??M.palette.success.main,I=s?.number??M.palette.warning.main,L=s?.boolean??M.palette.info.main,R=s?.null??M.palette.text.secondary;return(0,c.useEffect)(()=>{T.current=t},[t]),(0,c.useEffect)(()=>{E.current=b},[b]),(0,c.useEffect)(()=>{D.current=x},[x]),(0,c.useEffect)(()=>{O.current=S},[S]),(0,c.useEffect)(()=>{k.current=y},[y]),(0,c.useEffect)(()=>{if(!C.current)return;let t=w.current?.state.doc.toString()??e??``,s=m.HighlightStyle.define([{tag:g.tags.propertyName,color:P,fontWeight:`bold`},{tag:g.tags.string,color:F},{tag:g.tags.number,color:I},{tag:g.tags.bool,color:L,fontWeight:`bold`},{tag:g.tags.null,color:R,fontStyle:`italic`},{tag:g.tags.bracket,color:M.palette.text.secondary},{tag:g.tags.punctuation,color:M.palette.text.disabled},{tag:g.tags.invalid,color:M.palette.error.main,textDecoration:`underline wavy`}]),c=u.EditorView.theme({"&":{height:`100%`,fontFamily:`'Fira Code', 'JetBrains Mono', 'Consolas', monospace`,fontSize:`0.875rem`},".cm-scroller":{overflow:`auto`},".cm-content":{padding:`8px 4px`,caretColor:M.palette.text.primary},".cm-gutters":{backgroundColor:N?M.palette.grey[900]:M.palette.grey[50],color:M.palette.text.disabled,border:`none`,borderRight:`1px solid ${M.palette.divider}`},".cm-lineNumbers .cm-gutterElement":{paddingLeft:`4px`,paddingRight:`8px`},".cm-activeLineGutter":{backgroundColor:M.palette.action.selected},".cm-activeLine":{backgroundColor:M.palette.action.hover},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground":{backgroundColor:M.palette.primary.main+`40`},".cm-cursor, .cm-dropCursor":{borderLeftColor:M.palette.text.primary},"&.cm-focused":{outline:`none`},".cm-placeholder":{color:M.palette.text.disabled,fontStyle:`italic`},".cm-gutter-lint":{width:`16px`},".cm-lint-marker-error":{color:M.palette.error.main},".cm-lint-marker-warning":{color:M.palette.warning.main},".cm-tooltip.cm-tooltip-lint":{backgroundColor:M.palette.background.paper,border:`1px solid ${M.palette.divider}`,borderRadius:`4px`},".cm-diagnostic-error":{borderLeft:`3px solid ${M.palette.error.main}`},".cm-diagnostic-warning":{borderLeft:`3px solid ${M.palette.warning.main}`}},{dark:N}),l=o?[_.showMinimap.of({create:()=>{let e=document.createElement(`div`);return e.style.width=`80px`,e.style.overflow=`hidden`,e.style.borderLeft=`1px solid ${M.palette.divider}`,e.style.backgroundColor=N?M.palette.grey[900]:M.palette.grey[50],{dom:e}},displayText:`blocks`,showOverlay:`always`})]:[],v=[c,(0,m.syntaxHighlighting)(s),(0,f.json)(),(0,h.lintGutter)(),(0,h.linter)((0,f.jsonParseLinter)()),(0,p.history)(),u.keymap.of([...p.defaultKeymap,...p.historyKeymap]),A.current.of(u.EditorView.editable.of(!r&&!i)),j.current.of(d.EditorState.readOnly.of(i)),(0,u.highlightActiveLine)(),...a?[(0,u.lineNumbers)(),(0,u.highlightActiveLineGutter)()]:[],...n?[(0,u.placeholder)(n)]:[],...l,u.EditorView.updateListener.of(e=>{e.docChanged&&T.current?.(e.state.doc.toString());let t=e.state.selection.main.head,n=e.state.doc.lineAt(t);E.current(n.number,t-n.from+1)}),u.EditorView.domEventHandlers({blur:()=>{D.current?.()},focus:()=>{O.current?.()}})],y=new u.EditorView({state:d.EditorState.create({doc:t,extensions:v}),parent:C.current});return w.current=y,k.current(y),()=>{k.current(null),y.destroy(),w.current=null}},[N,P,F,I,L,R,o]),(0,c.useEffect)(()=>{let t=w.current;if(!t)return;let n=t.state.doc.toString();n!==(e??``)&&t.dispatch({changes:{from:0,to:n.length,insert:e??``}})},[e]),(0,c.useEffect)(()=>{w.current?.dispatch({effects:[A.current.reconfigure(u.EditorView.editable.of(!r&&!i)),j.current.reconfigure(d.EditorState.readOnly.of(i))]})},[r,i]),(0,v.jsx)(l.Box,{ref:C,sx:{flex:1,overflow:`hidden`,display:`flex`,flexDirection:`column`,opacity:r?.5:1,backgroundColor:M.palette.background.paper,"& .cm-editor":{flex:1,display:`flex`,flexDirection:`column`}}})}function Q({label:e,icon:t,onClick:n,active:r,disabled:i}){return(0,v.jsx)(l.Tooltip,{title:e,arrow:!0,children:(0,v.jsx)(`span`,{children:(0,v.jsx)(l.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 je({editorView:e,toolbarConfig:t,translation:n,indent:r,disabled:i}){let[a,o]=(0,c.useState)(!1),s=i||!e;function u(){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 d(){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 f(){let t=e?.state.doc.toString()??``;navigator.clipboard.writeText(t).then(()=>{o(!0),setTimeout(()=>o(!1),2e3)})}function m(){let t=e;t&&(t.dispatch({changes:{from:0,to:t.state.doc.length,insert:``}}),t.focus())}function h(){let t=e;t&&((0,p.undo)(t),t.focus())}function g(){let t=e;t&&((0,p.redo)(t),t.focus())}let _=t.showFormat||t.showCompact,E=t.showCopy||t.showClear,D=t.showUndoRedo;return(0,v.jsxs)(l.Box,{sx:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:.25,px:1,py:.5},role:`toolbar`,"aria-label":`JSON editor actions`,children:[_&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showFormat&&(0,v.jsx)(Q,{label:n.format,icon:(0,v.jsx)(w.default,{fontSize:`small`}),onClick:u,disabled:s}),t.showCompact&&(0,v.jsx)(Q,{label:n.compact,icon:(0,v.jsx)(T.default,{fontSize:`small`}),onClick:d,disabled:s})]}),_&&(E||D)&&(0,v.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),E&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showCopy&&(0,v.jsx)(Q,{label:a?n.copySuccess:n.copy,icon:a?(0,v.jsx)(b.default,{fontSize:`small`,color:`success`}):(0,v.jsx)(y.default,{fontSize:`small`}),onClick:f,disabled:s}),t.showClear&&(0,v.jsx)(Q,{label:n.clear,icon:(0,v.jsx)(x.default,{fontSize:`small`}),onClick:m,disabled:s})]}),E&&D&&(0,v.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),D&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[(0,v.jsx)(Q,{label:n.undo,icon:(0,v.jsx)(S.default,{fontSize:`small`}),onClick:h,disabled:s}),(0,v.jsx)(Q,{label:n.redo,icon:(0,v.jsx)(C.default,{fontSize:`small`}),onClick:g,disabled:s})]}),!_&&!E&&!D&&(0,v.jsx)(l.Box,{sx:{height:32}})]})}function Me({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,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,mt:.5,px:.5},children:[(0,v.jsxs)(l.Box,{children:[r&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[i?(0,v.jsx)(E.default,{sx:{fontSize:`0.875rem`,color:`success.main`},"data-testid":`json-valid-icon`}):(0,v.jsx)(D.default,{sx:{fontSize:`0.875rem`,color:`error.main`},"data-testid":`json-invalid-icon`}),(0,v.jsx)(l.FormHelperText,{sx:{color:i?`success.main`:`error.main`,m:0},children:i?s.validJson:s.invalidJson})]}),(0,v.jsx)(l.FormHelperText,{error:t,children:e??``})]}),n&&(0,v.jsx)(l.FormHelperText,{sx:{color:`text.disabled`,fontFamily:`monospace`,whiteSpace:`nowrap`},children:c})]})}function Ne(e){if(!(e===``||e===void 0))return typeof e==`string`&&e!==`auto`&&!isNaN(Number(e))?Number(e):e}function Pe(e){if(!e.trim())return!1;try{return JSON.parse(e),!0}catch{return!1}}function Fe({value:e,onChange:t,onValidChange:n,placeholder:r,height:i,width:a,disabled:o=!1,readonly:s=!1,error:u=!1,helperText:d,name:f,indent:p=2,showLineNumbers:m=!0,showLineColumn:h=!0,showMinimap:g=!1,showValidation:_=!1,toolbarConfig:y,translation:b,highlightColors:x,onBlur:S,onFocus:C}){let w={...ke,...b},T={...Oe,...y},E=Ne(i),D=Ne(a),O=E===`auto`,k=O?void 0:E??300,A=(0,c.useRef)(null),[j,M]=(0,c.useState)(null),[N,P]=(0,c.useState)({line:1,col:1}),[F,I]=(0,c.useState)(()=>Pe(e??``)),L=(0,c.useCallback)(e=>{A.current=e,M(e)},[]),R=(0,c.useCallback)((e,t)=>{P({line:e,col:t})},[]),z=(0,c.useCallback)(e=>{let r=Pe(e);I(r),n?.(r),t?.(e)},[t,n]),B=h||_||!!d;return(0,v.jsxs)(l.Box,{sx:{width:D??`100%`,...O?{display:`flex`,flexDirection:`column`,flex:1}:{}},children:[(0,v.jsxs)(l.Paper,{variant:`outlined`,sx:{display:`flex`,flexDirection:`column`,overflow:`hidden`,...O?{flex:1}:{height:k},borderColor:u?`error.main`:void 0,"&:focus-within":{borderColor:u?`error.main`:`primary.main`,borderWidth:2}},children:[!s&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(je,{editorView:j,toolbarConfig:T,translation:w,indent:p,disabled:o}),(0,v.jsx)(l.Divider,{})]}),(0,v.jsx)(Ae,{value:e,onChange:z,placeholder:r,disabled:o,readonly:s,showLineNumbers:m,showMinimap:g,highlightColors:x,onViewReady:L,onCursorChange:R,onBlur:S,onFocus:C})]}),B&&(0,v.jsx)(Me,{helperText:d,error:u,showLineColumn:h,showValidation:_,isValid:F,cursorLine:N.line,cursorCol:N.col,translation:w}),f&&(0,v.jsx)(`input`,{type:`hidden`,name:f,value:e??``})]})}function Ie(e){let t=new Date,n=Qe(t),r=$e(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=He(We(new Date(Math.min(...i)),-1)),s=Ue(We(new Date(Math.max(...a)),1));return{start:o<n?o:n,end:s>r?s:r}}function Le(e,t){return t===`weeks`?{start:Je(e.start),end:e.end}:t===`quarters`?{start:Qe(e.start),end:$e(e.end)}:e}function Re(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 ze(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 Be(n,0),n}function Be(e,t){for(let n of e)n.depth=t,Be(n.children,t+1)}function Ve(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 He(e){return new Date(e.getFullYear(),e.getMonth(),1,0,0,0,0)}function Ue(e){return new Date(e.getFullYear(),e.getMonth()+1,0,23,59,59,999)}function We(e,t){return new Date(e.getFullYear(),e.getMonth()+t,e.getDate())}function Ge(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+t,0,0,0,0)}function Ke(e,t,n){if(n===0)return e;let r=new Map;for(let t of e)for(let e of t.dependencies??[])r.has(e)||r.set(e,[]),r.get(e).push(t.id);let 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 qe(e){let t=[],n=He(e.start);for(;n<=e.end;)t.push(n),n=We(n,1);return t}function Je(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 Ye(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 Xe(e){let t=[],n=Je(e.start);for(;n<=e.end;)t.push(new Date(n)),n=new Date(n.getFullYear(),n.getMonth(),n.getDate()+7);return t}function Ze(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 Qe(e){let t=Math.floor(e.getMonth()/3)*3;return new Date(e.getFullYear(),t,1,0,0,0,0)}function $e(e){let t=Math.floor(e.getMonth()/3)*3+2;return Ue(new Date(e.getFullYear(),t,1))}function et(e){let t=[],n=Qe(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 tt(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 nt(e,t){let n=t.startDate<e.start?He(We(t.startDate,-1)):e.start,r=t.endDate>e.end?Ue(We(t.endDate,1)):e.end;return n===e.start&&r===e.end?e:{start:n,end:r}}function rt(e,t=`months`,n=!1,r,i=!1){let a=Ie(e);return(0,k.createStore)((o,s)=>({tasks:e,taskTree:ze(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,setTasks:e=>{o(t=>({tasks:e,taskTree:ze(e),...t.isRangeCustomized?{}:{timelineRange:Ie(e)}}))},addTask:e=>{o(t=>{let n=[...t.tasks,e];return{tasks:n,taskTree:ze(n),timelineRange:nt(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=Ke(r,e.id,t)}let i=nt(t.timelineRange,e);for(let e of r)i=nt(i,e);return{tasks:r,taskTree:ze(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:ze(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:Ie(e.tasks),isRangeCustomized:!1}))},resetView:()=>{o(e=>({timeScale:e.defaultTimeScale,timelineRange:Ie(e.tasks),isRangeCustomized:!1,isExpandedCustomized:!1,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 Ve(e,t)}}))}var it={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 —`,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`},at={planned:`warning.light`,"in-progress":`info.main`,done:`success.main`,blocked:`error.main`},ot={planned:`warning`,"in-progress":`info`,done:`success`,blocked:`error`};function st(e){return e.toISOString().slice(0,10)}function ct(e,t,n){return e<t?t:e>n?n:e}function lt(e){return e.flatMap(e=>[e,...lt(e.children)])}function ut({label:e}){let t=(0,c.useRef)(null),[n,r]=(0,c.useState)(!1);return(0,v.jsx)(l.Tooltip,{title:e,disableHoverListener:!n,children:(0,v.jsx)(l.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 dt({open:e,mode:t,initialTask:n,defaultParentId:r,onSave:i,onClose:a}){let o=Ft(),s=$(e=>e.taskTree),u=$(e=>e.timelineRange),d=(0,c.useMemo)(()=>lt(s),[s]),f=(0,c.useMemo)(()=>{if(t===`add`||!n)return new Set;let e=t=>[t.id,...t.children.flatMap(e)],r=d.find(e=>e.id===n.id);return new Set(r?e(r):[n.id])},[t,n,d]),p=d.filter(e=>!f.has(e.id)),m=p,h=st(ct(new Date,u.start,u.end)),[g,_]=(0,c.useState)({name:``,startDate:h,endDate:h,status:`planned`,isMilestone:!1,parentId:``,dependencies:[],assignee:``});(0,c.useEffect)(()=>{if(!e)return;let i=st(ct(new Date,u.start,u.end));_(t===`edit`&&n?{name:n.name,startDate:st(n.startDate),endDate:st(n.endDate),status:n.status,isMilestone:n.isMilestone??!1,parentId:n.parentId??``,dependencies:n.dependencies??[],assignee:n.assignee??``}:{name:``,startDate:i,endDate:i,status:`planned`,isMilestone:!1,parentId:r??``,dependencies:[],assignee:``})},[e,t,n,r,u]);let y=e=>{_(t=>({...t,startDate:e,endDate:t.isMilestone||t.endDate<e?e:t.endDate}))},b=e=>{_(t=>({...t,endDate:e<t.startDate?t.startDate:e}))},x=e=>{_(t=>({...t,isMilestone:e,endDate:e?t.startDate:t.endDate}))},S=g.name.trim()!==``&&g.startDate!==``&&g.endDate!==``&&g.endDate>=g.startDate,C=()=>{S&&i({name:g.name.trim(),startDate:new Date(g.startDate),endDate:new Date(g.endDate),status:g.status,isMilestone:g.isMilestone||void 0,parentId:g.parentId||void 0,dependencies:g.dependencies.length>0?g.dependencies:void 0,assignee:g.assignee.trim()||void 0})},w=[`planned`,`in-progress`,`done`,`blocked`],T={planned:o.statusPlanned,"in-progress":o.statusInProgress,done:o.statusDone,blocked:o.statusBlocked};return(0,v.jsxs)(l.Dialog,{open:e,onClose:a,maxWidth:`xs`,fullWidth:!0,"data-testid":`gantt-task-dialog`,children:[(0,v.jsx)(l.DialogTitle,{children:t===`add`?o.dialogAddTitle:o.dialogEditTitle}),(0,v.jsxs)(l.DialogContent,{sx:{display:`flex`,flexDirection:`column`,gap:2,pt:`16px !important`},children:[(0,v.jsx)(l.TextField,{label:o.dialogFieldName,value:g.name,onChange:e=>_(t=>({...t,name:e.target.value})),required:!0,fullWidth:!0,size:`small`,autoFocus:!0,slotProps:{htmlInput:{"data-testid":`gantt-dialog-field-name`}}}),(0,v.jsx)(l.TextField,{label:o.columnAssignee,value:g.assignee,onChange:e=>_(t=>({...t,assignee:e.target.value})),fullWidth:!0,size:`small`,placeholder:`e.g. Jane Smith`,slotProps:{htmlInput:{"data-testid":`gantt-dialog-field-assignee`}}}),(0,v.jsx)(l.TextField,{label:o.dialogFieldStartDate,type:`date`,value:g.startDate,onChange:e=>y(e.target.value),required:!0,fullWidth:!0,size:`small`,slotProps:{inputLabel:{shrink:!0},htmlInput:{"data-testid":`gantt-dialog-field-start`}}}),(0,v.jsx)(l.TextField,{label:o.dialogFieldEndDate,type:`date`,value:g.endDate,onChange:e=>b(e.target.value),required:!0,fullWidth:!0,size:`small`,disabled:g.isMilestone,slotProps:{inputLabel:{shrink:!0},htmlInput:{"data-testid":`gantt-dialog-field-end`,min:g.startDate}}}),(0,v.jsxs)(l.FormControl,{size:`small`,fullWidth:!0,children:[(0,v.jsx)(l.InputLabel,{children:o.dialogFieldStatus}),(0,v.jsx)(l.Select,{value:g.status,label:o.dialogFieldStatus,onChange:e=>_(t=>({...t,status:e.target.value})),inputProps:{"data-testid":`gantt-dialog-field-status`},children:w.map(e=>(0,v.jsx)(l.MenuItem,{value:e,children:T[e]},e))})]}),(0,v.jsx)(l.FormControlLabel,{control:(0,v.jsx)(l.Checkbox,{checked:g.isMilestone,onChange:e=>x(e.target.checked),size:`small`,"data-testid":`gantt-dialog-field-milestone`}),label:o.dialogFieldMilestone}),(0,v.jsxs)(l.FormControl,{size:`small`,fullWidth:!0,children:[(0,v.jsx)(l.InputLabel,{children:o.dialogFieldParent}),(0,v.jsxs)(l.Select,{value:g.parentId,label:o.dialogFieldParent,onChange:e=>_(t=>({...t,parentId:e.target.value})),inputProps:{"data-testid":`gantt-dialog-field-parent`},MenuProps:{slotProps:{paper:{sx:{maxHeight:280}}}},children:[(0,v.jsx)(l.MenuItem,{value:``,children:o.dialogFieldParentNone}),p.map(e=>(0,v.jsx)(l.MenuItem,{value:e.id,sx:{minWidth:0},children:(0,v.jsxs)(l.Box,{sx:{display:`flex`,alignItems:`center`,pl:e.depth*2,gap:.75,minWidth:0,width:`100%`,overflow:`hidden`},children:[e.depth>0&&(0,v.jsx)(l.Typography,{component:`span`,variant:`caption`,sx:{color:`text.disabled`,lineHeight:1,flexShrink:0},children:`└`}),(0,v.jsx)(ut,{label:e.name})]})},e.id))]})]}),(0,v.jsxs)(l.FormControl,{size:`small`,fullWidth:!0,children:[(0,v.jsx)(l.InputLabel,{children:o.dialogFieldDependencies}),(0,v.jsx)(l.Select,{multiple:!0,value:g.dependencies,label:o.dialogFieldDependencies,onChange:e=>{let t=e.target.value;_(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=>d.find(t=>t.id===e)?.name??e).join(`, `),MenuProps:{slotProps:{paper:{sx:{maxHeight:280}}}},children:m.map(e=>(0,v.jsx)(l.MenuItem,{value:e.id,sx:{minWidth:0},children:(0,v.jsxs)(l.Box,{sx:{display:`flex`,alignItems:`center`,pl:e.depth*2,gap:.75,minWidth:0,width:`100%`,overflow:`hidden`},children:[e.depth>0&&(0,v.jsx)(l.Typography,{component:`span`,variant:`caption`,sx:{color:`text.disabled`,lineHeight:1,flexShrink:0},children:`└`}),(0,v.jsx)(ut,{label:e.name})]})},e.id))})]})]}),(0,v.jsxs)(l.DialogActions,{children:[(0,v.jsx)(l.Button,{onClick:a,children:o.dialogCancel}),(0,v.jsx)(l.Button,{onClick:C,variant:`contained`,disabled:!S,"data-testid":`gantt-dialog-save`,children:o.dialogSave})]})]})}function ft({open:e,task:t,onConfirm:n,onClose:r}){let i=Ft(),a=i.dialogDeleteConfirm.replace(`{name}`,t?.name??``);return(0,v.jsxs)(l.Dialog,{open:e,onClose:r,maxWidth:`xs`,fullWidth:!0,"data-testid":`gantt-delete-dialog`,children:[(0,v.jsx)(l.DialogTitle,{children:i.dialogDeleteTitle}),(0,v.jsx)(l.DialogContent,{children:(0,v.jsx)(l.DialogContentText,{children:a})}),(0,v.jsxs)(l.DialogActions,{children:[(0,v.jsx)(l.Button,{onClick:r,children:i.dialogCancel}),(0,v.jsx)(l.Button,{onClick:n,variant:`contained`,color:`error`,"data-testid":`gantt-dialog-delete-confirm`,children:i.dialogDelete})]})]})}function pt(e,t){return{planned:t.statusPlanned,"in-progress":t.statusInProgress,done:t.statusDone,blocked:t.statusBlocked}[e]}function mt({task:e,expandedIds:t,toggleExpand:n,hasActionsColumn:r,showAssigneeColumn:i,onTaskClick:a,onAddTask:o,onEditTask:s,onDeleteTask:u,onStatusChange:d,inlineEdit:f,onInlineRename:p}){let[m,h]=(0,c.useState)(null),[g,_]=(0,c.useState)(null),y=Ft(),{statusColors:b}=Lt(),S=()=>{g!==null&&g.trim()&&p?.(e,g.trim()),_(null)};return(0,v.jsxs)(l.Box,{className:`gantt-task-row`,"data-testid":`gantt-task-row-${e.id}`,sx:{height:40,display:`flex`,alignItems:`center`,borderBottom:`1px solid`,borderRight:`1px solid`,borderColor:`divider`,cursor:a?`pointer`:`default`,"&:hover":a?{bgcolor:`action.hover`}:void 0},onClick:()=>a?.(e),children:[(0,v.jsxs)(l.Box,{sx:{flex:1,minWidth:0,display:`flex`,alignItems:`center`,gap:.75,pl:1+e.depth*2,pr:.5,height:`100%`},children:[(0,v.jsx)(l.Box,{sx:{width:16,flexShrink:0,display:`flex`,justifyContent:`center`},children:e.children.length>0&&(0,v.jsx)(l.Box,{component:`span`,sx:{fontSize:9,userSelect:`none`,cursor:`pointer`},onClick:t=>{t.stopPropagation(),n(e.id)},children:t.has(e.id)?`▼`:`▶`})}),(0,v.jsx)(l.Box,{sx:{width:8,height:8,borderRadius:e.isMilestone?0:`50%`,transform:e.isMilestone?`rotate(45deg)`:void 0,flexShrink:0,bgcolor:e.color??b?.[e.status]??at[e.status]??`grey.400`}}),g===null?(0,v.jsx)(l.Typography,{variant:`body2`,noWrap:!0,sx:{flex:1,minWidth:0,cursor:f?`text`:`inherit`},onDoubleClick:f?t=>{t.stopPropagation(),_(e.name)}:void 0,children:e.name}):(0,v.jsx)(l.TextField,{size:`small`,variant:`standard`,value:g,autoFocus:!0,onChange:e=>_(e.target.value),onBlur:S,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),S()),e.key===`Escape`&&(e.stopPropagation(),_(null))},onClick:e=>e.stopPropagation(),sx:{flex:1,minWidth:0},slotProps:{htmlInput:{"data-testid":`gantt-inline-edit-${e.id}`}}})]}),i&&(0,v.jsx)(l.Box,{sx:{width:110,flexShrink:0,display:`flex`,alignItems:`center`,px:1,overflow:`hidden`},children:(0,v.jsx)(l.Typography,{variant:`caption`,noWrap:!0,color:e.assignee?`text.primary`:`text.disabled`,children:e.assignee??`—`})}),r&&(0,v.jsxs)(l.Box,{className:`gantt-row-actions`,sx:{width:96,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`flex-end`,pr:.5},children:[s&&(0,v.jsx)(l.Tooltip,{title:y.editTaskTooltip,children:(0,v.jsx)(l.IconButton,{size:`small`,"aria-label":y.editTaskTooltip,"data-testid":`gantt-edit-task-${e.id}`,onClick:t=>{t.stopPropagation(),s(e)},children:(0,v.jsx)(M.default,{fontSize:`inherit`})})}),o&&(0,v.jsx)(l.Tooltip,{title:y.addTaskTooltip,children:(0,v.jsx)(l.IconButton,{size:`small`,"aria-label":y.addTaskTooltip,"data-testid":`gantt-add-task-${e.id}`,onClick:t=>{t.stopPropagation(),o(e)},children:(0,v.jsx)(j.default,{fontSize:`inherit`})})}),u&&(0,v.jsx)(l.Tooltip,{title:y.deleteTaskTooltip,children:(0,v.jsx)(l.IconButton,{size:`small`,"aria-label":y.deleteTaskTooltip,"data-testid":`gantt-delete-task-${e.id}`,onClick:t=>{t.stopPropagation(),u(e)},children:(0,v.jsx)(x.default,{fontSize:`inherit`})})})]}),(0,v.jsxs)(l.Box,{sx:{width:90,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`},children:[(0,v.jsx)(l.Chip,{label:pt(e.status,y),size:`small`,variant:`outlined`,color:e.color??b?.[e.status]?`default`:ot[e.status]??`default`,sx:{height:20,fontSize:10,cursor:d?`pointer`:`default`,...(e.color??b?.[e.status])&&{borderColor:e.color??b?.[e.status],color:e.color??b?.[e.status]}},onClick:d?e=>{e.stopPropagation(),h(e.currentTarget)}:void 0}),d&&(0,v.jsx)(l.Menu,{anchorEl:m,open:!!m,onClose:()=>h(null),children:[`planned`,`in-progress`,`done`,`blocked`].map(t=>(0,v.jsx)(l.MenuItem,{selected:e.status===t,onClick:()=>{d(e,t),h(null)},children:pt(t,y)},t))})]})]})}function ht({scrollRef:e,onScroll:t,panelWidth:n,onTaskClick:r,onAddTask:i,onEditTask:a,onDeleteTask:o,onStatusChange:s,onTasksChange:u,enableBuiltinDialogs:d,onTaskCreated:f,onTaskUpdated:p,onTaskDeleted:m,inlineEdit:h,virtualizeRows:g=!1,showAssigneeColumn:_=!1}){let y=Ft(),b=Nt(),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=(0,c.useMemo)(()=>Ve(x,S),[x,S]),k=(0,A.useVirtualizer)({count:O.length,getScrollElement:()=>e.current,estimateSize:()=>40,overscan:5}),[j,M]=(0,c.useState)(!1),[N,P]=(0,c.useState)(!1),[F,I]=(0,c.useState)(!1),[L,R]=(0,c.useState)(null),z=e=>{let t={...e,id:crypto.randomUUID()};T(t),u?.(b.getState().tasks),f?.(t),M(!1)},B=e=>{if(!L)return;let t={...e,id:L.id};E(t),u?.(b.getState().tasks),p?.(t),P(!1)},V=()=>{L&&(D(L.id),u?.(b.getState().tasks),m?.(L.id),I(!1))},H=(e,t)=>{let n={...e,name:t};E(n),u?.(b.getState().tasks),p?.(n)},U=d?e=>{R(e),M(!0)}:i,W=d?e=>{R(e),P(!0)}:a,G=d?e=>{R(e),I(!0)}:o,K=!!(U||W||G),q=w===`days`?80:40;return(0,v.jsxs)(l.Box,{ref:e,onScroll:t,sx:{width:n,flexShrink:0,overflowY:`auto`,overflowX:`hidden`},children:[(0,v.jsxs)(l.Box,{sx:{height:q,position:`sticky`,top:0,bgcolor:`background.paper`,zIndex:1,borderBottom:`1px solid`,borderRight:`1px solid`,borderColor:`divider`,display:`flex`,flexDirection:`column`},children:[(0,v.jsxs)(l.Box,{sx:{height:40,display:`flex`,alignItems:`center`,borderBottom:w===`days`?`1px solid`:void 0,borderColor:w===`days`?`divider`:void 0},children:[(0,v.jsx)(l.Box,{sx:{flex:1,minWidth:0,pl:2},children:(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:y.columnName})}),_&&(0,v.jsx)(l.Box,{sx:{width:110,flexShrink:0,display:`flex`,alignItems:`center`,px:1},children:(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:y.columnAssignee})}),K&&(0,v.jsx)(l.Box,{sx:{width:96,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:y.columnActions})}),(0,v.jsx)(l.Box,{sx:{width:90,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:y.columnStatus})})]}),w===`days`&&(0,v.jsx)(l.Box,{sx:{flex:1}})]}),g?(0,v.jsx)(l.Box,{sx:{position:`relative`,height:k.getTotalSize()},children:k.getVirtualItems().map(e=>(0,v.jsx)(l.Box,{style:{position:`absolute`,top:0,left:0,width:`100%`,height:40,transform:`translateY(${e.start}px)`},children:(0,v.jsx)(mt,{task:O[e.index],expandedIds:S,toggleExpand:C,hasActionsColumn:K,showAssigneeColumn:_,onTaskClick:r,onAddTask:U,onEditTask:W,onDeleteTask:G,onStatusChange:s,inlineEdit:h,onInlineRename:h?H:void 0})},e.key))}):O.map(e=>(0,v.jsx)(mt,{task:e,expandedIds:S,toggleExpand:C,hasActionsColumn:K,showAssigneeColumn:_,onTaskClick:r,onAddTask:U,onEditTask:W,onDeleteTask:G,onStatusChange:s,inlineEdit:h,onInlineRename:h?H:void 0},e.id)),d&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(dt,{open:j,mode:`add`,defaultParentId:L?.id,onSave:z,onClose:()=>M(!1)}),(0,v.jsx)(dt,{open:N,mode:`edit`,initialTask:L??void 0,onSave:B,onClose:()=>P(!1)}),(0,v.jsx)(ft,{open:F,task:L,onConfirm:V,onClose:()=>I(!1)})]})]})}var gt=864e5;function _t({totalWidth:e,displayRange:t,onTaskMoved:n,onTaskResized:r,onTasksChange:i}){let a=$(e=>e.updateTask),o=Nt(),s=Ft(),l=(0,c.useRef)(1),u=(0,c.useRef)(n),d=(0,c.useRef)(r),f=(0,c.useRef)(i);(0,c.useLayoutEffect)(()=>{l.current=e>0?e/((t.end.getTime()-t.start.getTime())/gt):1,u.current=n,d.current=r,f.current=i});let p=(0,c.useRef)(null),m=(0,c.useRef)(null),[h,g]=(0,c.useState)(null),_=(0,c.useRef)(!1);return{activeDrag:h,suppressClickRef:_,handleBarMouseDown:(e,t,n)=>{e.stopPropagation(),_.current=!1,p.current={type:n,taskId:t.id,startX:e.clientX,originalStart:t.startDate,originalEnd:t.endDate},document.body.style.cursor=n===`resize`?`ew-resize`:`grabbing`;let r=e=>{let t=p.current;if(!t||t.type===`progress`)return;let n=e.clientX-t.startX,r=Math.round(n/l.current);Math.abs(n)>=5&&(_.current=!0);let i={taskId:t.taskId,type:t.type,deltaDays:r};m.current=i,g(i)},i=()=>{document.body.style.cursor=``;let e=p.current,t=m.current;if(e&&t&&_.current&&t.deltaDays!==0){let n=o.getState().tasks.find(t=>t.id===e.taskId);if(n){if(t.type===`move`){let r=Ge(e.originalStart,t.deltaDays),i=Ge(e.originalEnd,t.deltaDays);a({...n,startDate:r,endDate:i}),u.current?.(n,r,i)}else{let r=Ge(e.originalEnd,t.deltaDays),i=r>e.originalStart?r:Ge(e.originalStart,1);a({...n,endDate:i}),d.current?.(n,i)}f.current?.(o.getState().tasks)}}p.current=null,m.current=null,g(null),document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i)};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i)},handleProgressMouseDown:(e,t,n,r)=>{e.stopPropagation(),_.current=!1,p.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=p.current;if(!t||t.type!==`progress`)return;let n=e.clientX-t.startX;Math.abs(n)>=5&&(_.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};m.current=a,g(a)},s=()=>{document.body.style.cursor=``;let e=p.current,t=m.current;if(e&&t&&t.type===`progress`&&t.newProgress!==void 0&&_.current){let n=o.getState().tasks.find(t=>t.id===e.taskId);n&&(a({...n,progress:t.newProgress}),f.current?.(o.getState().tasks))}p.current=null,m.current=null,g(null),document.removeEventListener(`mousemove`,i),document.removeEventListener(`mouseup`,s)};document.addEventListener(`mousemove`,i),document.addEventListener(`mouseup`,s)},formatDragDate:e=>e.toLocaleDateString(s.dateLocale,{day:`2-digit`,month:`short`})}}function vt({items:e}){return(0,v.jsx)(l.Box,{sx:{display:`flex`},children:e.map(e=>(0,v.jsx)(l.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,v.jsx)(l.Typography,{variant:`caption`,color:e.isWeekend?`text.disabled`:`text.secondary`,children:e.label})},e.key))})}function yt({columns:e,groups:t,todayX:n,todayLabel:r,todayTooltip:i,todayColor:a}){let o=(0,l.useTheme)(),s=t?80:40,c=a||o.palette.primary.main,u=o.palette.getContrastText(c);return(0,v.jsxs)(l.Box,{sx:{position:`sticky`,top:0,bgcolor:`background.paper`,zIndex:1,borderBottom:`1px solid`,borderColor:`divider`,height:s,overflow:`visible`},children:[t&&(0,v.jsx)(l.Box,{sx:{height:40,borderBottom:`1px solid`,borderColor:`divider`,overflow:`visible`},children:(0,v.jsx)(vt,{items:t})}),(0,v.jsx)(vt,{items:e}),n!=null&&r&&(0,v.jsx)(l.Tooltip,{title:i??``,placement:`top`,arrow:!0,children:(0,v.jsx)(l.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:u,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 bt({task:e,virtualTop:t,activeDrag:n,displayRange:r,totalWidth:i,gridColumnWidth:a,criticalTaskIds:o,draggable:s=!1,resizable:c=!1,progressDraggable:u=!1,onTaskClick:d,onMilestoneClick:f,onContextMenu:p,suppressClickRef:m,handleBarMouseDown:h,handleProgressMouseDown:g,formatDragDate:_}){let y=(0,l.useTheme)(),{statusColors:b,criticalPathColor:x,milestoneColor:S,barBorderRadius:C}=Lt(),w=n?.taskId===e.id,T=e;if(w&&n)if(n.type===`move`)T={...e,startDate:Ge(e.startDate,n.deltaDays),endDate:Ge(e.endDate,n.deltaDays)};else if(n.type===`resize`){let t=Ge(e.endDate,n.deltaDays);T={...e,endDate:t>e.startDate?t:Ge(e.startDate,1)}}else n.type===`progress`&&n.newProgress!==void 0&&(T={...e,progress:n.newProgress});let{left:E,width:D}=Re(T,r);return(0,v.jsx)(l.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,v.jsx)(xt,{task:e,left:E,milestoneColor:S,criticalPathColor:x,isCritical:o.has(e.id),onMilestoneClick:f,theme:y}):(0,v.jsx)(St,{task:e,effectiveTask:T,left:E,width:D,totalWidth:i,isDragging:w,activeDrag:n,draggable:s,resizable:c,progressDraggable:u,isCritical:o.has(e.id),statusColors:b,criticalPathColor:x,barBorderRadius:C,onTaskClick:d,onContextMenu:p,suppressClickRef:m,handleBarMouseDown:h,handleProgressMouseDown:g,formatDragDate:_,theme:y})})}function xt({task:e,left:t,milestoneColor:n,criticalPathColor:r,isCritical:i,onMilestoneClick:a,theme:o}){return t<0||t>100?null:(0,v.jsx)(l.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 St({task:e,effectiveTask:t,left:n,width:r,totalWidth:i,isDragging:a,activeDrag:o,draggable:s,resizable:c,progressDraggable:u,isCritical:d,statusColors:f,criticalPathColor:p,barBorderRadius:m,onTaskClick:h,onContextMenu:g,suppressClickRef:_,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,v.jsxs)(v.Fragment,{children:[a&&o&&o.type!==`progress`&&o.deltaDays!==0&&(0,v.jsx)(Ct,{left:C,children:o.type===`move`?`${x(t.startDate)} – ${x(t.endDate)}`:`→ ${x(t.endDate)}`}),a&&o?.type===`progress`&&o.newProgress!==void 0&&(0,v.jsxs)(Ct,{left:C,children:[o.newProgress,`%`]}),(0,v.jsxs)(l.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]??at[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(),g(e,t.clientX,t.clientY)},onClick:()=>{if(_.current){_.current=!1;return}h?.(e)},children:[t.progress!==void 0&&t.progress>0&&(0,v.jsx)(l.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}}),u&&(0,v.jsx)(l.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,v.jsx)(l.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 Ct({left:e,children:t}){return(0,v.jsx)(l.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 wt({strips:e,totalWidth:t,height:n,top:r}){let{weekendColor:i}=Lt();return e.length===0?null:(0,v.jsx)(l.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,v.jsx)(l.Box,{sx:{position:`absolute`,left:e.left,width:20,top:0,height:`100%`,bgcolor:i||`action.hover`}},e.key))})}function Tt({contextMenu:e,onClose:t,onSelect:n}){let r=Ft(),i={planned:r.statusPlanned,"in-progress":r.statusInProgress,done:r.statusDone,blocked:r.statusBlocked};return(0,v.jsx)(l.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,v.jsx)(l.MenuItem,{selected:e?.task.status===t,"data-testid":`gantt-status-menu-${t}`,onClick:()=>{e&&n(e.task,t)},children:i[t]},t))})}function Et({dependencyLines:e,todayX:t,totalWidth:n,height:r,top:i,arrowMarkerId:a}){let o=(0,l.useTheme)(),{todayLineColor:s}=Lt();return e.length===0&&t===null?null:(0,v.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,v.jsx)(`defs`,{children:(0,v.jsx)(`marker`,{id:a,markerWidth:`6`,markerHeight:`4`,refX:`5`,refY:`2`,orient:`auto`,children:(0,v.jsx)(`polygon`,{points:`0 0, 6 2, 0 4`,fill:`currentColor`})})}),e.map(e=>(0,v.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,v.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 Dt(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=Re(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=Re(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 Ot({scrollRef:e,onScroll:t,onTaskClick:n,onMilestoneClick:r,draggable:i=!1,resizable:a=!1,progressDraggable:o=!1,showCriticalPath:s=!1,virtualizeRows:u=!1,onTaskMoved:d,onTaskResized:f,onTasksChange:p,onStatusChange:m}){let h=$(e=>e.taskTree),g=$(e=>e.tasks),_=$(e=>e.expandedIds),y=$(e=>e.timelineRange),b=$(e=>e.timeScale),x=$(e=>e.updateTask),S=Nt(),C=Ft(),w=(0,l.useTheme)(),{todayLineColor:T}=Lt(),E=`gantt-arrow-${(0,c.useId)().replace(/:/g,``)}`,D=(0,c.useMemo)(()=>Ve(h,_),[h,_]),O=(0,c.useMemo)(()=>Le(y,b),[y,b]),k=(0,c.useMemo)(()=>b===`days`?Ze(O).map(e=>({key:e.toISOString(),label:String(e.getDate()),width:20,isWeekend:e.getDay()===0||e.getDay()===6})):b===`weeks`?Xe(O).map(e=>({key:e.toISOString(),label:`${C.weekColumnPrefix}${Ye(e)}`,width:40})):b===`quarters`?et(O).map(e=>({key:e.key,label:e.label,width:360})):qe(O).map(e=>({key:e.toISOString(),label:e.toLocaleString(C.dateLocale,{month:`short`,year:`2-digit`}),width:120})),[b,O,C.weekColumnPrefix,C.dateLocale]),j=(0,c.useMemo)(()=>k.reduce((e,t)=>e+t.width,0),[k]),M=(0,c.useMemo)(()=>{if(b!==`days`)return;let e=new Map;for(let t of k){let n=new Date(t.key),r=`${n.getFullYear()}-${n.getMonth()}`;e.has(r)||e.set(r,{label:n.toLocaleString(C.dateLocale,{month:`short`,year:`2-digit`}),width:0}),e.get(r).width+=20}return Array.from(e.entries()).map(([e,t])=>({key:e,...t}))},[b,k,C.dateLocale]),N=(0,c.useMemo)(()=>Dt(D,O,j),[D,O,j]),P=(0,c.useMemo)(()=>s?tt(g):new Set,[s,g]),F=(0,A.useVirtualizer)({count:D.length,getScrollElement:()=>e.current,estimateSize:()=>40,overscan:5}),I=(0,c.useMemo)(()=>{if(b!==`days`)return[];let e=0;return k.flatMap(t=>{let n=t.isWeekend?[{key:t.key,left:e}]:[];return e+=t.width,n})},[b,k]),L=(0,c.useMemo)(()=>{let e=Date.now(),t=O.start.getTime(),n=O.end.getTime();return e<t||e>n?null:(e-t)/(n-t)*j},[O,j]),R=(0,c.useMemo)(()=>new Date().toLocaleDateString(C.dateLocale,{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`}),[C.dateLocale]),z=T||w.palette.primary.main;(0,c.useEffect)(()=>{if(L===null||!e.current)return;let t=e.current.clientWidth;e.current.scrollLeft=Math.max(0,L-t/2)},[]);let B=b===`days`?20:b===`weeks`?40:b===`quarters`?360:120,V=M?80:40,{activeDrag:H,suppressClickRef:U,handleBarMouseDown:W,handleProgressMouseDown:G,formatDragDate:K}=_t({totalWidth:j,displayRange:O,onTaskMoved:d,onTaskResized:f,onTasksChange:p}),[q,J]=(0,c.useState)(null),Y=(0,c.useRef)(m);Y.current=m;let X=(0,c.useRef)(p);return X.current=p,(0,v.jsx)(l.Box,{ref:e,onScroll:t,"data-testid":`gantt-timeline-scroll`,sx:{flex:1,overflow:`auto`},children:(0,v.jsxs)(l.Box,{sx:{minWidth:j,position:`relative`},children:[(0,v.jsx)(yt,{columns:k,groups:M,todayX:L,todayLabel:C.todayLabel,todayTooltip:R,todayColor:z}),(0,v.jsx)(wt,{strips:I,totalWidth:j,height:D.length*40,top:V}),u?(0,v.jsx)(l.Box,{sx:{position:`relative`,height:F.getTotalSize()},children:F.getVirtualItems().map(e=>(0,v.jsx)(bt,{task:D[e.index],virtualTop:e.start,activeDrag:H,displayRange:O,totalWidth:j,gridColumnWidth:B,criticalTaskIds:P,draggable:i,resizable:a,progressDraggable:o,onTaskClick:n,onMilestoneClick:r,onContextMenu:(e,t,n)=>J({task:e,mouseX:t,mouseY:n}),suppressClickRef:U,handleBarMouseDown:W,handleProgressMouseDown:G,formatDragDate:K},e.key))}):(0,v.jsx)(v.Fragment,{children:D.map(e=>(0,v.jsx)(bt,{task:e,activeDrag:H,displayRange:O,totalWidth:j,gridColumnWidth:B,criticalTaskIds:P,draggable:i,resizable:a,progressDraggable:o,onTaskClick:n,onMilestoneClick:r,onContextMenu:(e,t,n)=>J({task:e,mouseX:t,mouseY:n}),suppressClickRef:U,handleBarMouseDown:W,handleProgressMouseDown:G,formatDragDate:K},e.id))}),(0,v.jsx)(Tt,{contextMenu:q,onClose:()=>J(null),onSelect:(e,t)=>{let n=S.getState().tasks.find(t=>t.id===e.id)??e;x({...n,status:t}),Y.current?.(n,t),X.current?.(S.getState().tasks),J(null)}}),(0,v.jsx)(Et,{dependencyLines:N,todayX:L,totalWidth:j,height:D.length*40,top:V,arrowMarkerId:E})]})})}function kt(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function At(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 jt({onScrollToToday:e,config:t,onExportCSV:n}){let r=Ft(),i=$(e=>e.timeScale),a=$(e=>e.defaultTimeScale),o=$(e=>e.setTimeScale),s=$(e=>e.timelineRange),u=$(e=>e.isRangeCustomized),d=$(e=>e.isExpandedCustomized),f=$(e=>e.setTimelineRange),p=$(e=>e.resetTimelineRange),m=$(e=>e.resetView),h=$(e=>e.tasks),g=$(e=>e.expandedIds),_=$(e=>e.expandAll),y=$(e=>e.collapseAll),b=h.length>0&&h.every(e=>g.has(e.id)),x=i!==a||u||d,S=(0,c.useMemo)(()=>Date.now(),[]),C=S>=s.start.getTime()&&S<=s.end.getTime(),w={days:r.scaleDays,weeks:r.scaleWeeks,months:r.scaleMonths,quarters:r.scaleQuarters},T={days:t.showScaleDays,weeks:t.showScaleWeeks,months:t.showScaleMonths,quarters:t.showScaleQuarters},E=Object.keys(w).filter(e=>T[e]);return(0,v.jsxs)(l.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:[E.length>0&&(0,v.jsx)(l.ToggleButtonGroup,{value:i,exclusive:!0,onChange:(e,t)=>{t&&o(t)},size:`small`,"aria-label":r.scaleMonths,children:E.map(e=>(0,v.jsx)(l.ToggleButton,{value:e,"data-testid":`gantt-scale-${e}`,children:w[e]},e))}),(0,v.jsxs)(l.Box,{sx:{ml:`auto`,display:`flex`,alignItems:`center`,gap:1},children:[t.showExpandCollapseAll&&(0,v.jsx)(l.Tooltip,{title:b?r.collapseAllTooltip:r.expandAllTooltip,children:(0,v.jsx)(l.IconButton,{size:`small`,onClick:b?y:_,"aria-label":b?r.collapseAllTooltip:r.expandAllTooltip,"data-testid":`gantt-expand-collapse-all`,children:b?(0,v.jsx)(L.default,{fontSize:`small`}):(0,v.jsx)(R.default,{fontSize:`small`})})}),t.showScrollToToday&&e&&(0,v.jsx)(l.Tooltip,{title:r.scrollToTodayTooltip,children:(0,v.jsx)(`span`,{children:(0,v.jsx)(l.IconButton,{size:`small`,onClick:e,disabled:!C,"aria-label":r.scrollToTodayTooltip,"data-testid":`gantt-scroll-to-today`,children:(0,v.jsx)(I.default,{fontSize:`small`})})})}),t.showDateRange&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(l.TextField,{type:`date`,size:`small`,label:r.rangeFrom,value:kt(s.start),onChange:e=>{let t=At(e.target.value);t&&f({start:t,end:s.end})},slotProps:{inputLabel:{shrink:!0},htmlInput:{"data-testid":`gantt-range-start`}},sx:{width:148}}),(0,v.jsx)(l.TextField,{type:`date`,size:`small`,label:r.rangeTo,value:kt(s.end),onChange:e=>{let t=At(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&&u&&(0,v.jsx)(l.Tooltip,{title:r.rangeResetTooltip,children:(0,v.jsx)(l.IconButton,{size:`small`,onClick:p,"aria-label":r.rangeResetTooltip,"data-testid":`gantt-range-reset`,children:(0,v.jsx)(F.default,{fontSize:`small`})})}),t.showExportCSV&&n&&(0,v.jsx)(l.Tooltip,{title:r.exportCsvTooltip,children:(0,v.jsx)(l.IconButton,{size:`small`,onClick:n,"aria-label":r.exportCsvTooltip,"data-testid":`gantt-export-csv`,children:(0,v.jsx)(N.default,{fontSize:`small`})})}),t.showResetView&&(0,v.jsx)(l.Tooltip,{title:r.resetViewTooltip,children:(0,v.jsx)(`span`,{children:(0,v.jsx)(l.IconButton,{size:`small`,onClick:m,disabled:!x,"aria-label":r.resetViewTooltip,"data-testid":`gantt-reset-view`,children:(0,v.jsx)(P.default,{fontSize:`small`})})})})]})]})}var Mt=(0,c.createContext)(null);function $(e){let t=(0,c.useContext)(Mt);if(!t)throw Error(`GanttChartStoreContext is missing.`);return(0,O.useStore)(t,e)}function Nt(){let e=(0,c.useContext)(Mt);if(!e)throw Error(`GanttChartStoreContext is missing.`);return e}var Pt=(0,c.createContext)(it);function Ft(){return(0,c.useContext)(Pt)}var It=(0,c.createContext)({});function Lt(){return(0,c.useContext)(It)}function Rt(e,t){return e===void 0?t:e===`auto`?`100%`:typeof e==`string`&&/^\d+$/.test(e)?Number(e):e}var zt=[`days`,`weeks`,`months`,`quarters`],Bt={showScaleDays:!0,showScaleWeeks:!0,showScaleMonths:!0,showScaleQuarters:!0,showExpandCollapseAll:!0,showScrollToToday:!0,showDateRange:!0,showRangeReset:!0,showResetView:!0,showExportCSV:!1};function Vt({tasks:e,onTaskClick:t,onMilestoneClick:n,onAddTask:r,onEditTask:i,onDeleteTask:a,onStatusChange:o,onTasksChange:s,enableBuiltinDialogs:u=!0,onTaskCreated:d,onTaskUpdated:f,onTaskDeleted:p,showToolbar:m=!0,toolbarConfig:h,height:g,width:_,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,onTaskMoved:A,onTaskResized:j}){let M=Rt(g,400),N=(0,c.useMemo)(()=>({...Bt,...h}),[h]),P=Rt(_,`100%`),F=$(e=>e.setTasks),I=$(e=>e.timeScale),L=$(e=>e.setTimeScale),R=$(e=>e.timelineRange),z=(0,c.useRef)(null),B=(0,c.useRef)(null),V=(0,c.useRef)(!1),[H,U]=(0,c.useState)(320),W=Nt(),G=(0,c.useCallback)(()=>{let e=W.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)}},[W,k]);(0,c.useEffect)(()=>{F(e)},[e,F]);let K=()=>{V.current||=(V.current=!0,B.current&&z.current&&(B.current.scrollTop=z.current.scrollTop),!1)},q=()=>{V.current||=(V.current=!0,z.current&&B.current&&(z.current.scrollTop=B.current.scrollTop),!1)},J=(0,c.useCallback)(()=>{if(!B.current)return;let e=Le(R,I),t=Date.now(),n=e.start.getTime(),r=e.end.getTime(),i=(t-n)/(r-n)*B.current.scrollWidth;B.current.scrollLeft=Math.max(0,i-B.current.clientWidth/2)},[R,I]);(0,c.useEffect)(()=>{if(!x||!B.current)return;let e=B.current,t=e=>{if(!e.ctrlKey)return;e.preventDefault();let t=zt.indexOf(I);e.deltaY<0&&t>0?L(zt[t-1]):e.deltaY>0&&t<zt.length-1&&L(zt[t+1])};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[x,I,L]);let Y=(0,c.useCallback)(e=>{e.preventDefault();let t=e.clientX,n=H,r=e=>{let r=e.clientX-t;U(Math.max(y,Math.min(b,n+r)))},i=()=>{document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i)};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i)},[H,y,b]);return(0,v.jsxs)(l.Box,{sx:{display:`flex`,flexDirection:`column`,height:M,width:P,border:`1px solid`,borderColor:`divider`,borderRadius:1,overflow:`hidden`},children:[m&&(0,v.jsx)(jt,{onScrollToToday:J,config:N,onExportCSV:N.showExportCSV?G:void 0}),(0,v.jsxs)(l.Box,{sx:{display:`flex`,flex:1,overflow:`hidden`},children:[(0,v.jsx)(ht,{scrollRef:z,onScroll:K,panelWidth:H,onTaskClick:t,onAddTask:r,onEditTask:i,onDeleteTask:a,onStatusChange:o,onTasksChange:s,enableBuiltinDialogs:u,onTaskCreated:d,onTaskUpdated:f,onTaskDeleted:p,inlineEdit:w,virtualizeRows:D,showAssigneeColumn:O}),(0,v.jsx)(l.Box,{"data-testid":`gantt-panel-divider`,sx:{width:4,flexShrink:0,bgcolor:`divider`,cursor:`col-resize`,"&:hover":{bgcolor:`action.hover`}},onMouseDown:Y}),(0,v.jsx)(Ot,{scrollRef:B,onScroll:q,onTaskClick:t,onMilestoneClick:n,draggable:S,resizable:C,progressDraggable:T,showCriticalPath:E,virtualizeRows:D,onTaskMoved:A,onTaskResized:j,onTasksChange:s,onStatusChange:o})]})]})}function Ht({tasks:e,timeScale:t=`months`,initialExpandAll:n=!1,showToolbar:r=!0,defaultRangeStart:i,defaultRangeEnd:a,translations:o,enableBuiltinDialogs:s=!0,toolbarConfig:l,zoomable:u=!1,draggable:d=!1,resizable:f=!1,inlineEdit:p=!1,progressDraggable:m=!1,showCriticalPath:h=!1,virtualizeRows:g=!1,showAssigneeColumn:_=!1,cascadeDependencies:y=!1,statusColors:b,ganttTheme:x,onExportCSV:S,onTaskClick:C,onMilestoneClick:w,onAddTask:T,onEditTask:E,onDeleteTask:D,onStatusChange:O,onTasksChange:k,onTaskMoved:A,onTaskResized:j,onTaskCreated:M,onTaskUpdated:N,onTaskDeleted:P,height:F,width:I,minPanelWidth:L,maxPanelWidth:R}){let z=(0,c.useMemo)(()=>({...it,...o}),[o]),[B]=(0,c.useState)(()=>{if(!(i!==void 0||a!==void 0))return rt(e,t,n,void 0,y);let r=Ie(e);return rt(e,t,n,{start:i??r.start,end:a??r.end},y)}),V=(0,c.useMemo)(()=>({...x,statusColors:{...b,...x?.statusColors}}),[b,x]);return(0,v.jsx)(Pt.Provider,{value:z,children:(0,v.jsx)(It.Provider,{value:V,children:(0,v.jsx)(Mt.Provider,{value:B,children:(0,v.jsx)(Vt,{tasks:e,timeScale:t,enableBuiltinDialogs:s,showToolbar:r,toolbarConfig:l,zoomable:u,draggable:d,resizable:f,inlineEdit:p,progressDraggable:m,showCriticalPath:h,virtualizeRows:g,showAssigneeColumn:_,onExportCSV:S,onTaskClick:C,onMilestoneClick:w,onAddTask:T,onEditTask:E,onDeleteTask:D,onStatusChange:O,onTasksChange:k,onTaskMoved:A,onTaskResized:j,onTaskCreated:M,onTaskUpdated:N,onTaskDeleted:P,height:F,width:I,minPanelWidth:L,maxPanelWidth:R})})})})}var Ut=e=>Math.max(0,Math.min(4,Math.round(e)));function Wt(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=Ut(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 Gt({percent:e,color:t,ariaLabel:n,segments:r=!1}){if(r){let r=Math.round(e/25);return(0,v.jsx)(l.Box,{role:`progressbar`,"aria-label":n,"aria-valuenow":e,"aria-valuemin":0,"aria-valuemax":100,sx:{width:`100%`,display:`flex`,gap:`3px`,mt:.5},children:[0,1,2,3].map(e=>(0,v.jsx)(l.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,v.jsx)(l.Box,{role:`progressbar`,"aria-label":n,"aria-valuenow":e,"aria-valuemin":0,"aria-valuemax":100,sx:{width:`100%`,height:`8px`,border:`1px solid`,borderColor:`divider`,borderRadius:`6px`,mt:.5,display:`flex`},children:(0,v.jsx)(l.Box,{"data-testid":`psm-meter`,sx:{height:`100%`,width:`${e}%`,backgroundColor:t,borderRadius:`6px`,transition:`width 0.2s ease-in-out`}})})}var Kt={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`},qt={weak:`#cc0000`,ok:`#fdc010`,good:`#8bc34a`,veryGood:`#43a047`},Jt={failure:`#cc0000`,success:`#43a047`};function Yt(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=new Uint32Array(e.length);crypto.getRandomValues(r);let i=t.map(e=>e[crypto.getRandomValues(new Uint32Array(1))[0]%e.length]),a=Array.from(r.slice(i.length)).map(e=>n[e%n.length]),o=[...i,...a];for(let e=o.length-1;e>0;e--){let t=crypto.getRandomValues(new Uint32Array(1))[0]%(e+1);[o[e],o[t]]=[o[t],o[e]]}return o.join(``)}function Xt({label:e,fulfilled:t,checkColors:n}){return(0,v.jsxs)(l.Stack,{direction:`row`,sx:{alignItems:`center`,mb:.25},spacing:.5,children:[(0,v.jsx)(l.Typography,{variant:`caption`,children:e}),t?(0,v.jsx)(E.default,{"data-testid":`psm-req-success`,style:{fontSize:16,color:n.success}}):(0,v.jsx)(D.default,{"data-testid":`psm-req-failure`,style:{fontSize:16,color:n.failure}})]})}function Zt({value:e,confirmValue:t,name:n,inputRef:r,disabled:i=!1,error:a=!1,helperText:o,autoComplete:s,customRequirements:u,generatorOptions:d,showConfirmField:f=!1,showPasswordAdornment:p=!0,showMeter:m=!0,showPasswordGenerator:h=!1,showSegmentedBar:g=!1,showSummary:_=!0,inputSize:y=`medium`,translation:b,meterColors:x,passwordMinLength:S=8,checkColors:C=Jt,onPasswordChange:T,onConfirmChange:E,onPasswordGenerated:D}){let O={...Kt,...b},k={...qt,...x},A=(0,c.useId)(),j=`${A}-password`,[M,N]=(0,c.useState)(!1),[P,F]=(0,c.useState)(!1),[I,L]=(0,c.useState)(``),[R,U]=(0,c.useState)(``),W=e===void 0?I:e,G=t===void 0?R:t,K=f&&G.length>0,q=K&&W===G,J=(0,c.useMemo)(()=>Wt(W,S),[W,S]);return(0,v.jsxs)(l.Stack,{children:[(0,v.jsxs)(l.FormControl,{variant:`outlined`,fullWidth:!0,error:a,children:[(0,v.jsx)(l.InputLabel,{htmlFor:j,size:y,children:O.label}),(0,v.jsx)(l.OutlinedInput,{id:j,type:M?`text`:`password`,fullWidth:!0,size:y,value:W,onChange:t=>{let n=t.target.value;e===void 0&&L(n),T&&T(n,Wt(n,S))},disabled:i,inputRef:r,inputProps:{"data-testid":`psm-input`,name:n,autoComplete:s},endAdornment:p?(0,v.jsx)(l.InputAdornment,{position:`end`,children:(0,v.jsx)(l.IconButton,{"data-testid":`psm-toggle`,disabled:i,"aria-label":M?O.hidePasswordLabel:O.showPasswordLabel,onClick:()=>{N(e=>!e)},onMouseDown:e=>{e.preventDefault()},onMouseUp:e=>{e.preventDefault()},edge:`end`,children:M?(0,v.jsx)(H.default,{}):(0,v.jsx)(V.default,{})})}):null,label:O.label}),o&&(0,v.jsx)(l.FormHelperText,{children:o})]}),h&&(0,v.jsx)(l.Tooltip,{title:O.generatePasswordLabel,arrow:!0,children:(0,v.jsx)(`span`,{children:(0,v.jsx)(l.Button,{"data-testid":`psm-generate`,size:`small`,variant:`text`,startIcon:(0,v.jsx)(w.default,{fontSize:`small`}),disabled:i,onClick:()=>{let n=Yt({length:d?.length??Math.max(16,S),upper:d?.upper??!0,lower:d?.lower??!0,numbers:d?.numbers??!0,symbols:d?.symbols??!0});e===void 0&&L(n),t===void 0&&U(``),T?.(n,Wt(n,S)),D?.(n),N(!0)},sx:{mt:.5,alignSelf:`flex-start`,textTransform:`none`},children:O.generatePasswordLabel})})}),f&&(0,v.jsxs)(l.FormControl,{variant:`outlined`,fullWidth:!0,error:K&&!q,sx:{mt:1},children:[(0,v.jsx)(l.InputLabel,{htmlFor:`${A}-confirm`,size:y,children:O.confirmLabel}),(0,v.jsx)(l.OutlinedInput,{id:`${A}-confirm`,type:P?`text`:`password`,fullWidth:!0,size:y,value:G,onChange:e=>{let n=e.target.value;t===void 0&&U(n),E?.(n,n===W)},disabled:i,inputProps:{"data-testid":`psm-confirm-input`},endAdornment:(0,v.jsxs)(l.InputAdornment,{position:`end`,children:[K&&(q?(0,v.jsx)(z.default,{"data-testid":`psm-confirm-match`,sx:{color:C.success,mr:.5},fontSize:`small`}):(0,v.jsx)(B.default,{"data-testid":`psm-confirm-mismatch`,sx:{color:C.failure,mr:.5},fontSize:`small`})),(0,v.jsx)(l.IconButton,{size:`small`,disabled:i,onClick:()=>F(e=>!e),onMouseDown:e=>e.preventDefault(),edge:`end`,"aria-label":P?O.hidePasswordLabel:O.showPasswordLabel,children:P?(0,v.jsx)(H.default,{}):(0,v.jsx)(V.default,{})})]}),label:O.confirmLabel}),K&&(0,v.jsx)(l.FormHelperText,{sx:{color:q?C.success:C.failure},children:q?O.confirmMatchLabel:O.confirmMismatchLabel})]}),m&&(0,v.jsx)(Gt,{percent:J.percent,color:(e=>{switch(e.meterStatus){case`weak`:return k.weak;case`ok`:return k.ok;case`good`:return k.good;case`very good`:return k.veryGood;default:return`transparent`}})(J),ariaLabel:O.meterAriaLabel,segments:g}),_&&(0,v.jsxs)(l.Box,{"data-testid":`psm-summary`,sx:{mt:.5,p:.5},children:[(0,v.jsx)(l.Typography,{variant:`caption`,gutterBottom:!0,sx:{display:`block`,fontSize:14},children:O.summaryHeaderLabel}),(0,v.jsxs)(l.Stack,{direction:`row`,spacing:6,children:[(0,v.jsxs)(l.Stack,{direction:`column`,children:[(0,v.jsx)(Xt,{label:O.summaryMinChars.replace(`{n}`,String(S)),fulfilled:J.length>=S,checkColors:C}),(0,v.jsx)(Xt,{label:O.summaryCapitalLetter,fulfilled:J.hasUpper,checkColors:C}),(0,v.jsx)(Xt,{label:O.summaryLowerCaseLetter,fulfilled:J.hasLower,checkColors:C})]}),(0,v.jsxs)(l.Stack,{direction:`column`,children:[(0,v.jsx)(Xt,{label:O.summaryNumber,fulfilled:J.hasDigit,checkColors:C}),(0,v.jsx)(Xt,{label:O.summarySpecialChar,fulfilled:J.hasSymbol,checkColors:C}),u?.map((e,t)=>(0,v.jsx)(Xt,{label:e.label,fulfilled:typeof e.fulfilled==`function`?e.fulfilled(W):e.fulfilled,checkColors:C},t))]})]})]})]})}function Qt(e){return(0,k.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 $t=[`default`,`primary`,`secondary`,`error`,`info`,`success`,`warning`],en=[`#f44336`,`#e91e63`,`#9c27b0`,`#673ab7`,`#3f51b5`,`#2196f3`,`#03a9f4`,`#00bcd4`,`#009688`,`#4caf50`,`#8bc34a`,`#cddc39`,`#ffeb3b`,`#ffc107`,`#ff9800`,`#ff5722`,`#795548`,`#9e9e9e`,`#607d8b`,`#000000`];function tn(e){return/^#[0-9A-Fa-f]{6}$/.test(e)}function nn(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 rn(e,t){let n=t.trim();if(!n)return e;let r=e.toLowerCase().indexOf(n.toLowerCase());return r===-1?e:(0,v.jsxs)(v.Fragment,{children:[e.slice(0,r),(0,v.jsx)(`strong`,{children:e.slice(r,r+n.length)}),e.slice(r+n.length)]})}function an({color:e,selected:t,onClick:n}){return(0,v.jsx)(l.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 on({value:e,onChange:t,disabled:n=!1}){return(0,v.jsx)(l.TextField,{size:`small`,fullWidth:!0,value:e,onChange:e=>t(e.target.value),placeholder:`#rrggbb`,disabled:n,error:!n&&e.length>1&&!tn(e),sx:{"& .MuiInputBase-root":{height:28},"& .MuiInputBase-input":{py:0,px:.5,fontSize:`0.72rem`,fontFamily:`monospace`}},slotProps:{input:{startAdornment:(0,v.jsx)(l.Box,{sx:{width:12,height:12,borderRadius:.25,flexShrink:0,mr:.5,backgroundColor:tn(e)?e:`action.disabledBackground`,border:`1px solid`,borderColor:`divider`}})}}})}function sn({availableTags:e,searchValue:t,translation:n,onSearchChange:r,onTagSelect:i,onTagCreate:a,inputSize:o=`medium`,chipSize:s=`medium`,disabled:u=!1,loading:d=!1,isMaxReached:f=!1,allowCreate:p=!1,listboxMaxHeight:m}){let[h,g]=(0,c.useState)(`default`),[_,y]=(0,c.useState)(null),[x,S]=(0,c.useState)(null),[C,w]=(0,c.useState)(!0),[T,E]=(0,c.useState)(!1),[D,O]=(0,c.useState)(!1),[k,A]=(0,c.useState)(`#1976d2`),[j,M]=(0,c.useState)(`#ffffff`),N=u||f,P=_!==null,F=e.filter(e=>e.label.toLowerCase().includes(t.trim().toLowerCase())),I=p&&t.trim()!==``&&F.length===0,L=D&&!I,R=P?C?nn(_):x??`#000000`:void 0,z=()=>{let e=t.trim(),n=e.toLowerCase().replace(/\s+/g,`-`);a?.(P&&_?{id:n,label:e,selected:!0,color:`default`,backgroundColor:_,foregroundColor:R}:{id:n,label:e,selected:!0,color:h}),g(`default`),y(null),S(null),w(!0),E(!1),r(``)},B=()=>{r(``),g(`default`),y(null),S(null),w(!0),E(!1)},V=e=>{y(e),A(e),g(`default`)},H=e=>{A(e),tn(e)&&(y(e),g(`default`))},W=e=>{S(e),M(e)},G=e=>{M(e),tn(e)&&S(e)},K=e=>{if(w(e),e)S(null);else if(_){let e=nn(_);S(e),M(e)}},q=e=>e.preventDefault();return(0,v.jsxs)(l.Box,{sx:{mb:2},children:[(0,v.jsx)(l.Autocomplete,{options:e,value:null,open:L,onOpen:()=>{I||O(!0)},onClose:()=>O(!1),size:o,disabled:N,loading:d,getOptionLabel:e=>e.label,inputValue:t,onInputChange:(e,t)=>r(t),onChange:(e,t)=>{t&&i(t)},slotProps:{listbox:{sx:{display:`flex`,flexWrap:`wrap`,gap:1,padding:1,...m!==void 0&&{maxHeight:m,overflowY:`auto`}}}},renderInput:e=>(0,v.jsx)(l.TextField,{...e,label:n.autoCompleteLabel,placeholder:n.placeholder,helperText:f&&!u?n.maxTagsReachedText:void 0,onKeyDown:e=>{I&&e.key===`Enter`&&(e.preventDefault(),z())},slotProps:{...e.slotProps,input:{...e.slotProps?.input,endAdornment:(0,v.jsxs)(v.Fragment,{children:[I&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(l.IconButton,{size:`small`,sx:{color:`success.main`},onMouseDown:q,onClick:z,"aria-label":n.confirmCreateLabel,children:(0,v.jsx)(b.default,{fontSize:`small`})}),(0,v.jsx)(l.IconButton,{size:`small`,onMouseDown:q,onClick:B,"aria-label":n.cancelCreateLabel,children:(0,v.jsx)(U.default,{fontSize:`small`})})]}),e.slotProps?.input?.endAdornment]})}}}),renderOption:({key:e,...n},r)=>{let i=!!(r.foregroundColor||r.backgroundColor);return(0,v.jsx)(`li`,{...n,style:{width:`auto`,padding:0,margin:0},children:(0,v.jsx)(l.Chip,{size:s,label:rn(r.label,t),color:i?void 0:r.color??`default`,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}),I&&(0,v.jsxs)(l.Box,{sx:{position:`relative`},onMouseDown:q,children:[(0,v.jsxs)(l.Stack,{direction:`row`,sx:{mt:.5,flexWrap:`wrap`,gap:.5,alignItems:`center`},children:[$t.map(e=>(0,v.jsx)(l.Chip,{size:s,color:e,label:e,variant:!P&&h===e?`filled`:`outlined`,onClick:()=>{g(e),y(null),S(null),E(!1)},clickable:!0},e)),(0,v.jsx)(l.Tooltip,{title:n.colorPickerLabel,children:(0,v.jsx)(l.Chip,{size:s,label:P?_:`···`,variant:`outlined`,onClick:()=>{E(e=>!e),_&&A(_),x&&M(x)},sx:e=>({cursor:`pointer`,fontFamily:`monospace`,fontSize:`0.7rem`,...P?{backgroundColor:_,color:R,border:`1.5px solid transparent`,backgroundImage:`linear-gradient(${_}, ${_}), 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})})]}),T&&(0,v.jsx)(l.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,v.jsxs)(l.Box,{sx:{display:`grid`,gridTemplateColumns:`auto auto`,gap:2},children:[(0,v.jsxs)(l.Box,{children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{fontWeight:700,color:`text.primary`,display:`block`,mb:.5},children:n.backgroundColorLabel}),(0,v.jsxs)(l.Box,{sx:{display:`grid`,gridTemplateColumns:`repeat(5, 24px)`,gap:.5},children:[en.map(e=>(0,v.jsx)(an,{color:e,selected:_===e,onClick:()=>V(e)},e)),(0,v.jsx)(l.Box,{sx:{gridColumn:`span 5`,mt:.25},children:(0,v.jsx)(on,{value:k,onChange:H})})]})]}),(0,v.jsxs)(l.Box,{children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{fontWeight:700,color:`text.primary`,display:`block`,mb:.5},children:n.textColorLabel}),(0,v.jsxs)(l.Box,{sx:{display:`grid`,gridTemplateColumns:`repeat(5, 24px)`,gap:.5,opacity:C?.3:1,pointerEvents:C?`none`:`auto`,transition:`opacity 0.15s`},children:[en.map(e=>(0,v.jsx)(an,{color:e,selected:x===e,onClick:()=>W(e)},e)),(0,v.jsx)(l.Box,{sx:{gridColumn:`span 5`,mt:.25},children:(0,v.jsx)(on,{value:C?R??`#000000`:j,onChange:G,disabled:C})})]}),(0,v.jsxs)(l.Stack,{direction:`row`,sx:{width:`100%`,alignItems:`center`,justifyContent:`flex-end`,gap:.5,mt:.25},children:[(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:n.autoTextColorLabel}),(0,v.jsx)(l.Switch,{size:`small`,checked:C,onChange:e=>K(e.target.checked)})]})]})]})})]})]})}function cn({tag:e,onDelete:t,onClick:n,chipSize:r=`medium`,disabled:i=!1}){let a=!!(e.foregroundColor||e.backgroundColor);return(0,v.jsx)(l.Chip,{size:r,label:e.label,onDelete:t?()=>t(e):void 0,onClick:n?()=>n(e):void 0,clickable:!!n&&!e.disabled&&!i,disabled:i||e.disabled,variant:e.selected?`filled`:`outlined`,color:a?void 0:e.color??`default`,sx:{...a&&{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&&!i?`pointer`:`default`}})}function ln({selectedTags:e,translation:t,onTagDelete:n,showSelectedTagsLabel:r,chipSize:i=`medium`,disabled:a=!1,maxVisibleChips:o,popoverPlacement:s=`bottom`}){let[u,d]=(0,c.useState)(null),f=o===void 0?e:e.slice(0,o),p=o===void 0?[]:e.slice(o),m=!!u&&p.length>0,h=s===`top`?{vertical:`top`,horizontal:`left`}:{vertical:`bottom`,horizontal:`left`},g=s===`top`?{vertical:`bottom`,horizontal:`left`}:{vertical:`top`,horizontal:`left`};return(0,v.jsxs)(l.Box,{sx:{mb:2},children:[r&&(0,v.jsx)(l.Typography,{variant:`subtitle2`,gutterBottom:!0,children:t.selectedTagsLabel}),e.length===0?(0,v.jsx)(l.Typography,{variant:`body2`,color:`text.secondary`,children:t.noSelectedTagsText}):(0,v.jsxs)(l.Stack,{direction:`row`,sx:{flexWrap:`wrap`,gap:1},children:[f.map(e=>(0,v.jsx)(cn,{tag:e,onDelete:n,chipSize:i,disabled:a},e.id)),p.length>0&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(l.Chip,{size:i,label:`+${p.length}`,variant:`outlined`,clickable:!0,onClick:e=>d(e.currentTarget)}),(0,v.jsx)(l.Popover,{open:m,anchorEl:u,onClose:()=>d(null),anchorOrigin:h,transformOrigin:g,children:(0,v.jsx)(l.Box,{sx:{p:1,display:`flex`,flexWrap:`wrap`,gap:.5,maxWidth:320},children:p.map(e=>(0,v.jsx)(cn,{tag:e,onDelete:a?void 0:n,chipSize:i,disabled:a},e.id))})})]})]})]})}var un={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`},dn=(0,c.createContext)(null);function fn(e){let t=(0,c.useContext)(dn);if(!t)throw Error(`TagSelectionStoreContext is missing.`);return(0,O.useStore)(t,e)}function pn({tags:e,showSelectedTags:t=!0,showSelectedTagsLabel:n=!0,showAutoComplete:r=!0,inputSize:i=`medium`,chipSize:a=`small`,disabled:o=!1,loading:s=!1,maxTags:u,allowCreate:d=!1,maxVisibleChips:f,popoverPlacement:p=`bottom`,listboxMaxHeight:m,translation:h,onTagSelect:g,onTagDelete:_,onTagsChange:y,onSearchChange:b,onTagCreate:x}){let S=fn(e=>e.tags),C=fn(e=>e.searchValue),w=fn(e=>e.setTags),T=fn(e=>e.setSearchValue),E=fn(e=>e.selectTag),D=fn(e=>e.deleteTag),O=fn(e=>e.addTag);(0,c.useEffect)(()=>{w(e)},[e,w]);let k=(0,c.useMemo)(()=>S.filter(e=>e.selected).sort((e,t)=>e.label.localeCompare(t.label)),[S]),A=(0,c.useMemo)(()=>S.filter(e=>!e.selected&&!e.disabled).sort((e,t)=>e.label.localeCompare(t.label)),[S]),j=u!==void 0&&k.length>=u,M=e=>{y&&y(e.filter(e=>e.selected),e)};return(0,v.jsx)(l.Box,{sx:{width:`100%`},children:(0,v.jsxs)(l.Stack,{children:[t&&(0,v.jsx)(ln,{selectedTags:k,translation:h,onTagDelete:e=>{D(e.id);let t=S.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&&_&&_(r,n,t),M(t)},showSelectedTagsLabel:n,chipSize:a,disabled:o,maxVisibleChips:f,popoverPlacement:p}),r&&(0,v.jsx)(sn,{availableTags:A,searchValue:C,translation:h,onSearchChange:e=>{T(e),b&&b(e)},onTagSelect:e=>{if(e.disabled||e.selected)return;E(e.id);let t=S.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&&g&&g(r,n,t),M(t)},onTagCreate:e=>{O(e),M([...S,e]),x&&x(e)},inputSize:i,chipSize:a,disabled:o,loading:s,isMaxReached:j,allowCreate:d,listboxMaxHeight:m})]})})}function mn({tags:e,showSelectedTags:t=!0,showSelectedTagsLabel:n=!0,showAutoComplete:r=!0,translation:i,inputSize:a=`medium`,chipSize:o=`small`,disabled:s=!1,loading:l=!1,maxTags:u,allowCreate:d=!1,maxVisibleChips:f,popoverPlacement:p=`bottom`,listboxMaxHeight:m,onTagSelect:h,onTagDelete:g,onTagsChange:_,onSearchChange:y,onTagCreate:b}){let x={...un,...i},[S]=(0,c.useState)(()=>Qt(e));return(0,v.jsx)(dn.Provider,{value:S,children:(0,v.jsx)(pn,{tags:e,showSelectedTags:t,showSelectedTagsLabel:n,showAutoComplete:r,translation:x,inputSize:a,chipSize:o,disabled:s,loading:l,maxTags:u,allowCreate:d,maxVisibleChips:f,popoverPlacement:p,listboxMaxHeight:m,onTagSelect:h,onTagDelete:g,onTagsChange:_,onSearchChange:y,onTagCreate:b})})}var hn={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},gn={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…`};function _n({editor:e,error:t,disabled:n,readonly:r}){return(0,v.jsx)(l.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,v.jsx)(W.EditorContent,{editor:e})})}function vn({open:e,onClose:t,editor:n,translation:r}){let[i,a]=(0,c.useState)(``);(0,c.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 u(){n.chain().focus().extendMarkRange(`link`).unsetLink().run(),t()}function d(e){e.key===`Enter`&&s()}return(0,v.jsxs)(l.Dialog,{open:e,onClose:t,maxWidth:`sm`,fullWidth:!0,children:[(0,v.jsx)(l.DialogTitle,{children:r.linkDialogTitle}),(0,v.jsx)(l.DialogContent,{children:(0,v.jsx)(l.TextField,{autoFocus:!0,fullWidth:!0,label:r.linkDialogUrlLabel,value:i,onChange:e=>a(e.target.value),onKeyDown:d,variant:`outlined`,size:`small`,sx:{mt:1},placeholder:`https://`})}),(0,v.jsxs)(l.DialogActions,{sx:{px:3,pb:2,gap:1},children:[o&&(0,v.jsx)(l.Button,{onClick:u,color:`error`,sx:{mr:`auto`},children:r.linkDialogRemove}),(0,v.jsx)(l.Button,{onClick:t,children:r.linkDialogCancel}),(0,v.jsx)(l.Button,{onClick:s,variant:`contained`,children:r.linkDialogSave})]})]})}var yn=[`#000000`,`#434343`,`#666666`,`#999999`,`#b7b7b7`,`#ffffff`,`#ff0000`,`#ff4500`,`#ff8c00`,`#ffd700`,`#9acd32`,`#008000`,`#00ced1`,`#1e90ff`,`#0000ff`,`#8a2be2`,`#ff1493`,`#a52a2a`],bn=[`#ffff00`,`#ffd700`,`#ffa500`,`#ff69b4`,`#ff6347`,`#fa8072`,`#adff2f`,`#90ee90`,`#00fa9a`,`#00ffff`,`#87ceeb`,`#add8e6`,`#dda0dd`,`#ee82ee`,`#d2b48c`,`#f5f5dc`,`#ffffff`,`#000000`];function xn({color:e,active:t,onClick:n}){return(0,v.jsx)(l.Tooltip,{title:e,placement:`top`,arrow:!0,children:(0,v.jsx)(l.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,v.jsx)(l.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 Sn({anchorEl:e,open:t,onClose:n,mode:r,activeColor:i,onSelectColor:a,onRemoveColor:o,removeLabel:s}){let u=(0,c.useRef)(null),d=r===`highlight`?bn:yn;function f(e){a(e.target.value)}return(0,v.jsxs)(l.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,v.jsx)(l.Box,{sx:{display:`grid`,gridTemplateColumns:`repeat(6, 22px)`,gap:.5,mb:1},children:d.map(e=>(0,v.jsx)(xn,{color:e,active:i?.toLowerCase()===e.toLowerCase(),onClick:e=>{a(e),n()}},e))}),(0,v.jsxs)(l.Box,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,v.jsx)(l.Tooltip,{title:`Custom color`,arrow:!0,children:(0,v.jsx)(l.Box,{component:`button`,type:`button`,onClick:()=>u.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,v.jsx)(`input`,{ref:u,type:`color`,defaultValue:i??`#000000`,onChange:f,onBlur:n,style:{visibility:`hidden`,width:0,height:0,position:`absolute`}}),(0,v.jsx)(l.Tooltip,{title:s,arrow:!0,children:(0,v.jsx)(l.IconButton,{size:`small`,onClick:()=>{o(),n()},"aria-label":s,sx:{borderRadius:1,ml:`auto`},children:(0,v.jsx)(be.default,{fontSize:`small`})})})]})]})}function Cn({editor:e,translation:t,disabled:n}){let[r,i]=(0,c.useState)(null),a=n||!e,o=e?.isActive(`table`)??!1;function s(){i(null)}function u(e){e(),s()}return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(l.Tooltip,{title:t.table,arrow:!0,children:(0,v.jsx)(`span`,{children:(0,v.jsx)(l.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,v.jsx)(xe.default,{fontSize:`small`})})})}),(0,v.jsxs)(l.Menu,{anchorEl:r,open:!!r,onClose:s,slotProps:{paper:{sx:{minWidth:220}}},children:[(0,v.jsxs)(l.MenuItem,{onClick:()=>u(()=>e?.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()),children:[(0,v.jsx)(l.ListItemIcon,{children:(0,v.jsx)(xe.default,{fontSize:`small`})}),(0,v.jsx)(l.ListItemText,{children:t.insertTable})]}),o&&(0,v.jsx)(l.Divider,{}),o&&(0,v.jsxs)(l.MenuItem,{onClick:()=>u(()=>e?.chain().focus().addRowBefore().run()),children:[(0,v.jsx)(l.ListItemIcon,{children:(0,v.jsx)(j.default,{fontSize:`small`})}),(0,v.jsx)(l.ListItemText,{children:t.addRowBefore})]}),o&&(0,v.jsxs)(l.MenuItem,{onClick:()=>u(()=>e?.chain().focus().addRowAfter().run()),children:[(0,v.jsx)(l.ListItemIcon,{children:(0,v.jsx)(j.default,{fontSize:`small`})}),(0,v.jsx)(l.ListItemText,{children:t.addRowAfter})]}),o&&(0,v.jsxs)(l.MenuItem,{onClick:()=>u(()=>e?.chain().focus().deleteRow().run()),children:[(0,v.jsx)(l.ListItemIcon,{children:(0,v.jsx)(x.default,{fontSize:`small`,color:`error`})}),(0,v.jsx)(l.ListItemText,{sx:{color:`error.main`},children:t.deleteRow})]}),o&&(0,v.jsx)(l.Divider,{}),o&&(0,v.jsxs)(l.MenuItem,{onClick:()=>u(()=>e?.chain().focus().addColumnBefore().run()),children:[(0,v.jsx)(l.ListItemIcon,{children:(0,v.jsx)(j.default,{fontSize:`small`})}),(0,v.jsx)(l.ListItemText,{children:t.addColumnBefore})]}),o&&(0,v.jsxs)(l.MenuItem,{onClick:()=>u(()=>e?.chain().focus().addColumnAfter().run()),children:[(0,v.jsx)(l.ListItemIcon,{children:(0,v.jsx)(j.default,{fontSize:`small`})}),(0,v.jsx)(l.ListItemText,{children:t.addColumnAfter})]}),o&&(0,v.jsxs)(l.MenuItem,{onClick:()=>u(()=>e?.chain().focus().deleteColumn().run()),children:[(0,v.jsx)(l.ListItemIcon,{children:(0,v.jsx)(x.default,{fontSize:`small`,color:`error`})}),(0,v.jsx)(l.ListItemText,{sx:{color:`error.main`},children:t.deleteColumn})]}),o&&(0,v.jsx)(l.Divider,{}),o&&(0,v.jsxs)(l.MenuItem,{onClick:()=>u(()=>e?.chain().focus().deleteTable().run()),children:[(0,v.jsx)(l.ListItemIcon,{children:(0,v.jsx)(x.default,{fontSize:`small`,color:`error`})}),(0,v.jsx)(l.ListItemText,{sx:{color:`error.main`},children:t.deleteTable})]})]})]})}function wn({open:e,onClose:t,editor:n,translation:r}){let[i,a]=(0,c.useState)(``),[o,s]=(0,c.useState)(``);function u(){let e=i.trim();e&&(n.chain().focus().setImage({src:e,alt:o.trim()||void 0}).run(),a(``),s(``),t())}function d(){a(``),s(``),t()}function f(e){e.key===`Enter`&&u()}return(0,v.jsxs)(l.Dialog,{open:e,onClose:d,maxWidth:`sm`,fullWidth:!0,children:[(0,v.jsx)(l.DialogTitle,{children:r.imageDialogTitle}),(0,v.jsxs)(l.DialogContent,{sx:{display:`flex`,flexDirection:`column`,gap:2,pt:`16px !important`},children:[(0,v.jsx)(l.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,v.jsx)(l.TextField,{fullWidth:!0,label:r.imageDialogAltLabel,value:o,onChange:e=>s(e.target.value),onKeyDown:f,variant:`outlined`,size:`small`})]}),(0,v.jsxs)(l.DialogActions,{sx:{px:3,pb:2,gap:1},children:[(0,v.jsx)(l.Button,{onClick:d,children:r.imageDialogCancel}),(0,v.jsx)(l.Button,{onClick:u,variant:`contained`,disabled:!i.trim(),children:r.imageDialogSave})]})]})}var Tn=[{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 En({anchorEl:e,open:t,onClose:n,onSelect:r,translation:i}){let[a,o]=(0,c.useState)(``),s=(0,c.useMemo)(()=>{let e=a.trim().toLowerCase();return e?Tn.map(t=>({...t,emojis:t.emojis.filter(t=>t.name.includes(e)||t.emoji===e)})).filter(e=>e.emojis.length>0):Tn},[a]);function u(e){r(e),n(),o(``)}function d(){n(),o(``)}return(0,v.jsxs)(l.Popover,{open:t,anchorEl:e,onClose:d,anchorOrigin:{vertical:`bottom`,horizontal:`left`},transformOrigin:{vertical:`top`,horizontal:`left`},slotProps:{paper:{sx:{width:320,maxHeight:380,display:`flex`,flexDirection:`column`}}},children:[(0,v.jsx)(l.Box,{sx:{p:1,borderBottom:1,borderColor:`divider`},children:(0,v.jsx)(l.TextField,{autoFocus:!0,fullWidth:!0,size:`small`,placeholder:i.emojiSearchPlaceholder,value:a,onChange:e=>o(e.target.value),slotProps:{input:{startAdornment:(0,v.jsx)(l.InputAdornment,{position:`start`,children:(0,v.jsx)(Se.default,{fontSize:`small`})})}}})}),(0,v.jsxs)(l.Box,{sx:{overflowY:`auto`,flex:1,px:1,pb:1},children:[s.map(e=>(0,v.jsxs)(l.Box,{children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{display:`block`,color:`text.secondary`,mt:1,mb:.5,px:.5},children:e.label}),(0,v.jsx)(l.Box,{sx:{display:`flex`,flexWrap:`wrap`,gap:.25},children:e.emojis.map(e=>(0,v.jsx)(l.Box,{component:`button`,title:e.name,"aria-label":e.name,onClick:()=>u(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,v.jsx)(l.Typography,{variant:`body2`,color:`text.secondary`,sx:{p:2,textAlign:`center`},children:`No emoji found`})]})]})}function Dn({label:e,icon:t,activeColor:n,disabled:r,onClick:i}){return(0,v.jsx)(l.Tooltip,{title:e,arrow:!0,children:(0,v.jsx)(`span`,{children:(0,v.jsxs)(l.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,v.jsx)(l.Box,{sx:{display:`flex`,alignItems:`center`},children:t}),(0,v.jsx)(l.Box,{sx:{width:`80%`,height:3,bgcolor:n??`text.primary`,borderRadius:.5,mt:`1px`}})]})})})}function On({level:e}){return(0,v.jsxs)(l.Box,{component:`span`,sx:{fontWeight:`bold`,fontSize:`0.875rem`,lineHeight:1},children:[`H`,e]})}function kn({editor:e,toolbarConfig:t,translation:n,disabled:r,isFullscreen:i,onToggleFullscreen:a}){let[o,s]=(0,c.useState)(!1),[u,d]=(0,c.useState)(!1),[f,p]=(0,c.useState)(null),[m,h]=(0,c.useState)(null),[g,_]=(0,c.useState)(null),y=r||!e,b=e?.getAttributes(`textStyle`)?.color,x=e?.getAttributes(`highlight`)?.color,w=t.showBold||t.showItalic||t.showUnderline||t.showStrike,T=t.showHeading1||t.showHeading2||t.showHeading3,E=t.showBulletList||t.showOrderedList,D=t.showBlockquote||t.showCodeBlock||t.showLink||t.showHorizontalRule,O=t.showTextColor||t.showHighlight,k=t.showUndoRedo||t.showClearFormat,A=t.showTableButton||t.showImageButton||t.showEmojiButton,j=[w,T,E,D,O,k,A],M=j.filter(Boolean).length;function N(e,t){return!e||j.slice(t+1).findIndex(Boolean)===-1?null:(0,v.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}},`div-${t}`)}return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(l.Box,{sx:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:.25,px:1,py:.5},role:`toolbar`,"aria-label":`Text formatting`,children:[w&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showBold&&(0,v.jsx)(Q,{label:n.bold,icon:(0,v.jsx)(se.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleBold().run(),active:e?.isActive(`bold`),disabled:y}),t.showItalic&&(0,v.jsx)(Q,{label:n.italic,icon:(0,v.jsx)(ce.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleItalic().run(),active:e?.isActive(`italic`),disabled:y}),t.showUnderline&&(0,v.jsx)(Q,{label:n.underline,icon:(0,v.jsx)(le.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleUnderline().run(),active:e?.isActive(`underline`),disabled:y}),t.showStrike&&(0,v.jsx)(Q,{label:n.strike,icon:(0,v.jsx)(ue.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleStrike().run(),active:e?.isActive(`strike`),disabled:y})]}),N(w,0),T&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showHeading1&&(0,v.jsx)(Q,{label:n.heading1,icon:(0,v.jsx)(On,{level:1}),onClick:()=>e?.chain().focus().toggleHeading({level:1}).run(),active:e?.isActive(`heading`,{level:1}),disabled:y}),t.showHeading2&&(0,v.jsx)(Q,{label:n.heading2,icon:(0,v.jsx)(On,{level:2}),onClick:()=>e?.chain().focus().toggleHeading({level:2}).run(),active:e?.isActive(`heading`,{level:2}),disabled:y}),t.showHeading3&&(0,v.jsx)(Q,{label:n.heading3,icon:(0,v.jsx)(On,{level:3}),onClick:()=>e?.chain().focus().toggleHeading({level:3}).run(),active:e?.isActive(`heading`,{level:3}),disabled:y})]}),N(T,1),E&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showBulletList&&(0,v.jsx)(Q,{label:n.bulletList,icon:(0,v.jsx)(de.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleBulletList().run(),active:e?.isActive(`bulletList`),disabled:y}),t.showOrderedList&&(0,v.jsx)(Q,{label:n.orderedList,icon:(0,v.jsx)(fe.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleOrderedList().run(),active:e?.isActive(`orderedList`),disabled:y})]}),N(E,2),D&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showBlockquote&&(0,v.jsx)(Q,{label:n.blockquote,icon:(0,v.jsx)(pe.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleBlockquote().run(),active:e?.isActive(`blockquote`),disabled:y}),t.showCodeBlock&&(0,v.jsx)(Q,{label:n.codeBlock,icon:(0,v.jsx)(me.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleCodeBlock().run(),active:e?.isActive(`codeBlock`),disabled:y}),t.showLink&&(0,v.jsx)(Q,{label:n.link,icon:(0,v.jsx)(he.default,{fontSize:`small`}),onClick:()=>s(!0),active:e?.isActive(`link`),disabled:y}),t.showHorizontalRule&&(0,v.jsx)(Q,{label:n.horizontalRule,icon:(0,v.jsx)(ge.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().setHorizontalRule().run(),disabled:y})]}),N(D,3),O&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showTextColor&&(0,v.jsx)(Dn,{label:n.textColor,icon:(0,v.jsx)(_e.default,{fontSize:`small`}),activeColor:b,disabled:y,onClick:e=>h(e.currentTarget)}),t.showHighlight&&(0,v.jsx)(Dn,{label:n.highlight,icon:(0,v.jsx)(ve.default,{fontSize:`small`}),activeColor:x,disabled:y,onClick:e=>_(e.currentTarget)})]}),N(O,4),k&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showUndoRedo&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(Q,{label:n.undo,icon:(0,v.jsx)(S.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().undo().run(),disabled:y||!e?.can().undo()}),(0,v.jsx)(Q,{label:n.redo,icon:(0,v.jsx)(C.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().redo().run(),disabled:y||!e?.can().redo()})]}),t.showClearFormat&&(0,v.jsx)(Q,{label:n.clearFormat,icon:(0,v.jsx)(ye.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().clearNodes().unsetAllMarks().run(),disabled:y})]}),N(k,5),A&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showTableButton&&(0,v.jsx)(Cn,{editor:e,translation:n,disabled:y}),t.showImageButton&&(0,v.jsx)(Q,{label:n.image,icon:(0,v.jsx)(ae.default,{fontSize:`small`}),onClick:()=>d(!0),disabled:y}),t.showEmojiButton&&(0,v.jsx)(l.Tooltip,{title:n.emoji,arrow:!0,children:(0,v.jsx)(`span`,{children:(0,v.jsx)(l.IconButton,{size:`small`,onMouseDown:e=>e.preventDefault(),onClick:e=>p(e.currentTarget),disabled:y,sx:{borderRadius:1},"aria-label":n.emoji,children:(0,v.jsx)(oe.default,{fontSize:`small`})})})})]}),M===0&&(0,v.jsx)(l.Box,{sx:{height:32}}),t.showFullscreenButton&&(0,v.jsx)(l.Box,{sx:{ml:`auto`},children:(0,v.jsx)(l.Tooltip,{title:i?n.exitFullscreen:n.fullscreen,arrow:!0,children:(0,v.jsx)(`span`,{children:(0,v.jsx)(l.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,v.jsx)(ie.default,{fontSize:`small`}):(0,v.jsx)(re.default,{fontSize:`small`})})})})})]}),t.showLink&&e&&(0,v.jsx)(vn,{open:o,onClose:()=>s(!1),editor:e,translation:n}),t.showTextColor&&(0,v.jsx)(Sn,{anchorEl:m,open:!!m,onClose:()=>h(null),mode:`textColor`,activeColor:b,onSelectColor:t=>e?.chain().focus().setColor(t).run(),onRemoveColor:()=>e?.chain().focus().unsetColor().run(),removeLabel:n.removeTextColor}),t.showHighlight&&(0,v.jsx)(Sn,{anchorEl:g,open:!!g,onClose:()=>_(null),mode:`highlight`,activeColor:x,onSelectColor:t=>e?.chain().focus().setHighlight({color:t}).run(),onRemoveColor:()=>e?.chain().focus().unsetHighlight().run(),removeLabel:n.removeHighlight}),t.showImageButton&&e&&(0,v.jsx)(wn,{open:u,onClose:()=>d(!1),editor:e,translation:n}),t.showEmojiButton&&(0,v.jsx)(En,{anchorEl:f,open:!!f,onClose:()=>p(null),onSelect:t=>e?.chain().focus().insertContent(t).run(),translation:n})]})}function An({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)),u=i!==void 0&&r>=i?`error`:`text.secondary`,d=s.wordCount.replace(`{count}`,String(o));return(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,mt:.5,px:.5},children:[(0,v.jsx)(l.FormHelperText,{error:t,children:e??``}),(n||a)&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:1.5,alignItems:`center`},children:[a&&(0,v.jsx)(l.FormHelperText,{sx:{color:`text.secondary`},children:d}),n&&(0,v.jsx)(l.FormHelperText,{sx:{color:u},children:c})]})]})}function jn({disabled:e=!1,error:t=!1,height:n,helperText:r,maxCharacters:i,name:a,placeholder:o,readonly:s=!1,showCharacterCount:u=!1,showToolbar:d=!0,showWordCount:f=!1,toolbarConfig:p,translation:m,value:h,width:g,onBlur:_,onChange:y,onFocus:b}){let x={...gn,...m},S={...hn,...p},[C,w]=(0,c.useState)(!1),T=Ne(n),E=Ne(g),D=T===`auto`,O=D?void 0:T??200,k=i!==void 0&&i>0||u||f,A=(0,W.useEditor)({shouldRerenderOnTransaction:!0,extensions:[G.StarterKit.configure({link:{openOnClick:!1}}),K.TextStyle,q.Color,J.Highlight.configure({multicolor:!0}),ne.Markdown.configure({transformPastedText:!0,transformCopiedText:!1}),Y.Placeholder.configure({placeholder:o??``}),...S.showTableButton?[ee.TableKit]:[],...S.showImageButton?[te.Image.configure({inline:!1,allowBase64:!0})]:[],...k?i!==void 0&&i>0?[X.CharacterCount.configure({limit:i})]:[X.CharacterCount]:[]],content:h??``,editable:!e&&!s,onUpdate({editor:e}){y?.(e.getHTML())},onBlur(){_?.()},onFocus(){b?.()}});(0,c.useEffect)(()=>{!A||h===void 0||A.getHTML()!==h&&A.commands.setContent(h,{emitUpdate:!1})},[A,h]),(0,c.useEffect)(()=>{A&&A.setEditable(!e&&!s)},[A,e,s]);let j=A?.storage.characterCount?.characters?.()??0,M=A?.storage.characterCount?.words?.()??0,N=u||i!==void 0&&i>0||f||!!r;return(0,v.jsxs)(l.Box,{sx:C?{position:`fixed`,top:0,left:0,width:`100vw`,height:`100vh`,zIndex:1300,display:`flex`,flexDirection:`column`,bgcolor:`background.default`,p:1}:{width:E??`100%`,...D?{display:`flex`,flexDirection:`column`,flex:1}:{}},children:[(0,v.jsxs)(l.Paper,{variant:`outlined`,sx:{display:`flex`,flexDirection:`column`,overflow:`hidden`,...C||D?{flex:1}:{height:O},borderColor:t?`error.main`:void 0,"&:focus-within":{borderColor:t?`error.main`:`primary.main`,borderWidth:2}},children:[d&&!s&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(kn,{editor:A,toolbarConfig:S,translation:x,disabled:e,isFullscreen:C,onToggleFullscreen:()=>w(e=>!e)}),(0,v.jsx)(l.Divider,{})]}),(0,v.jsx)(_n,{editor:A,error:t,disabled:e,readonly:s})]}),N&&(0,v.jsx)(An,{helperText:r,error:t,showCharacterCount:u||i!==void 0&&i>0,charCount:j,maxCharacters:i&&i>0?i:void 0,showWordCount:f,wordCount:M,translation:x}),a&&(0,v.jsx)(`input`,{type:`hidden`,name:a,value:A?A.getHTML():``})]})}var Mn={showFormat:!0,showCopy:!0,showClear:!0,showExecute:!1,showUndoRedo:!0},Nn={format:`Format SQL`,copy:`Copy`,copySuccess:`Copied!`,clear:`Clear`,execute:`Execute`,undo:`Undo`,redo:`Redo`,lineColumn:`Ln {line}, Col {col}`,errorCount:`{count} error(s)`},Pn={standard:Ce.StandardSQL,mysql:Ce.MySQL,postgresql:Ce.PostgreSQL,sqlite:Ce.SQLite,mssql:Ce.MSSQL};function Fn({value:e,onChange:t,placeholder:n,disabled:r=!1,readonly:i=!1,showLineNumbers:a=!0,dialect:o=`standard`,keywordColor:s,stringColor:f,identifierColor:_,schema:y,onExecute:b,onLint:x,onDiagnosticsChange:S,onViewReady:C,onCursorChange:w,onBlur:T,onFocus:E}){let D=(0,c.useRef)(null),O=(0,c.useRef)(null),k=(0,c.useRef)(t),A=(0,c.useRef)(w),j=(0,c.useRef)(T),M=(0,c.useRef)(E),N=(0,c.useRef)(C),P=(0,c.useRef)(b),F=(0,c.useRef)(x),I=(0,c.useRef)(S),L=(0,c.useRef)(new d.Compartment),R=(0,c.useRef)(new d.Compartment),z=(0,l.useTheme)(),B=z.palette.mode===`dark`,V=!!x,H=JSON.stringify(y);return(0,c.useEffect)(()=>{k.current=t},[t]),(0,c.useEffect)(()=>{A.current=w},[w]),(0,c.useEffect)(()=>{j.current=T},[T]),(0,c.useEffect)(()=>{M.current=E},[E]),(0,c.useEffect)(()=>{N.current=C},[C]),(0,c.useEffect)(()=>{P.current=b},[b]),(0,c.useEffect)(()=>{F.current=x},[x]),(0,c.useEffect)(()=>{I.current=S},[S]),(0,c.useEffect)(()=>{if(!D.current)return;let t=O.current?.state.doc.toString()??e??``,c=s??z.palette.primary.main,l=f??z.palette.success.main,v=_??z.palette.info.main,b=m.HighlightStyle.define([{tag:g.tags.keyword,color:c,fontWeight:`bold`},{tag:g.tags.name,color:v},{tag:[g.tags.string,g.tags.special(g.tags.string)],color:l,fontWeight:`bold`},{tag:g.tags.number,color:z.palette.warning.main},{tag:[g.tags.lineComment,g.tags.blockComment],color:z.palette.text.disabled,fontStyle:`italic`},{tag:g.tags.operator,color:z.palette.text.secondary},{tag:[g.tags.function(g.tags.variableName),g.tags.function(g.tags.name)],color:z.palette.secondary.main},{tag:g.tags.typeName,color:z.palette.info.main},{tag:g.tags.invalid,color:z.palette.error.main,textDecoration:`underline wavy`}]),x=u.EditorView.theme({"&":{height:`100%`,fontFamily:`'Fira Code', 'JetBrains Mono', 'Consolas', monospace`,fontSize:`0.875rem`},".cm-scroller":{overflow:`auto`},".cm-content":{padding:`8px 4px`,caretColor:z.palette.text.primary},".cm-gutters":{backgroundColor:B?z.palette.grey[900]:z.palette.grey[50],color:z.palette.text.disabled,border:`none`,borderRight:`1px solid ${z.palette.divider}`},".cm-lineNumbers .cm-gutterElement":{paddingLeft:`4px`,paddingRight:`8px`},".cm-activeLineGutter":{backgroundColor:z.palette.action.selected},".cm-activeLine":{backgroundColor:z.palette.action.hover},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground":{backgroundColor:z.palette.primary.main+`40`},".cm-cursor, .cm-dropCursor":{borderLeftColor:z.palette.text.primary},"&.cm-focused":{outline:`none`},".cm-placeholder":{color:z.palette.text.disabled,fontStyle:`italic`},".cm-tooltip":{backgroundColor:z.palette.background.paper,border:`1px solid ${z.palette.divider}`,borderRadius:`4px`,boxShadow:z.shadows[4]},".cm-tooltip-autocomplete > ul > li":{color:z.palette.text.primary},".cm-tooltip-autocomplete > ul > li[aria-selected]":{backgroundColor:z.palette.primary.main+`20`,color:z.palette.primary.main},".cm-completionMatchedText":{color:z.palette.primary.main,textDecoration:`none`,fontWeight:`bold`},".cm-completionDetail":{color:z.palette.text.secondary,fontStyle:`italic`},".cm-gutter-lint":{width:`16px`},".cm-lint-marker-error":{color:z.palette.error.main},".cm-lint-marker-warning":{color:z.palette.warning.main},".cm-tooltip.cm-tooltip-lint":{backgroundColor:z.palette.background.paper,border:`1px solid ${z.palette.divider}`,borderRadius:`4px`},".cm-diagnostic-error":{borderLeft:`3px solid ${z.palette.error.main}`},".cm-diagnostic-warning":{borderLeft:`3px solid ${z.palette.warning.main}`},".cm-diagnostic-info":{borderLeft:`3px solid ${z.palette.info.main}`}},{dark:B}),S=y?Object.fromEntries(y.tables.map(e=>[e.name,(e.columns??[]).map(e=>({label:e.name,detail:e.type,type:`property`}))])):void 0,C=async e=>{let t=F.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 I.current?.(r.length),r}catch{return[]}},w=u.keymap.of([{key:`Mod-Enter`,run:e=>(P.current?.(e.state.doc.toString()),!0)}]),T=[x,(0,m.syntaxHighlighting)(b),(0,Ce.sql)({dialect:Pn[o],schema:S}),(0,p.history)(),(0,we.autocompletion)(),w,u.keymap.of([...p.defaultKeymap,...p.historyKeymap,...we.completionKeymap]),L.current.of(u.EditorView.editable.of(!r&&!i)),R.current.of(d.EditorState.readOnly.of(i)),(0,u.highlightActiveLine)(),...a?[(0,u.lineNumbers)(),(0,u.highlightActiveLineGutter)()]:[],...n?[(0,u.placeholder)(n)]:[],...V?[(0,h.lintGutter)(),(0,h.linter)(C,{delay:600})]:[],u.EditorView.updateListener.of(e=>{e.docChanged&&k.current?.(e.state.doc.toString());let t=e.state.selection.main.head,n=e.state.doc.lineAt(t);A.current(n.number,t-n.from+1)}),u.EditorView.domEventHandlers({blur:()=>{j.current?.()},focus:()=>{M.current?.()}})],E=new u.EditorView({state:d.EditorState.create({doc:t,extensions:T}),parent:D.current});return O.current=E,N.current(E),()=>{N.current(null),E.destroy(),O.current=null}},[B,o,V,s,f,_,H]),(0,c.useEffect)(()=>{let t=O.current;if(!t)return;let n=t.state.doc.toString();n!==(e??``)&&t.dispatch({changes:{from:0,to:n.length,insert:e??``}})},[e]),(0,c.useEffect)(()=>{O.current?.dispatch({effects:[L.current.reconfigure(u.EditorView.editable.of(!r&&!i)),R.current.reconfigure(d.EditorState.readOnly.of(i))]})},[r,i]),(0,v.jsx)(l.Box,{ref:D,sx:{flex:1,overflow:`hidden`,display:`flex`,flexDirection:`column`,opacity:r?.5:1,backgroundColor:z.palette.background.paper,"& .cm-editor":{flex:1,display:`flex`,flexDirection:`column`}}})}var In={standard:`sql`,mysql:`mysql`,postgresql:`postgresql`,sqlite:`sqlite`,mssql:`tsql`};function Ln({editorView:e,toolbarConfig:t,translation:n,dialect:r,disabled:i,onExecute:a}){let[o,s]=(0,c.useState)(!1),u=i||!e;function d(){let t=e?.state.doc.toString()??``;navigator.clipboard.writeText(t).then(()=>{s(!0),setTimeout(()=>s(!1),2e3)})}function f(){let t=e;t&&(t.dispatch({changes:{from:0,to:t.state.doc.length,insert:``}}),t.focus())}function m(){let t=e;t&&((0,p.undo)(t),t.focus())}function h(){let t=e;t&&((0,p.redo)(t),t.focus())}function g(){let t=e;if(!t)return;let n=t.state.doc.toString();try{let e=(0,Ee.format)(n,{language:In[r]});t.dispatch({changes:{from:0,to:t.state.doc.length,insert:e}})}catch{}t.focus()}function _(){let t=e;!t||!a||a(t.state.doc.toString())}let T=t.showFormat,E=t.showCopy||t.showClear,D=t.showUndoRedo,O=t.showExecute&&!!a;return(0,v.jsxs)(l.Box,{sx:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:.25,px:1,py:.5},role:`toolbar`,"aria-label":`SQL editor actions`,children:[T&&(0,v.jsx)(l.Box,{sx:{display:`flex`,gap:.25},children:(0,v.jsx)(Q,{label:n.format,icon:(0,v.jsx)(w.default,{fontSize:`small`}),onClick:g,disabled:u})}),T&&(E||D)&&(0,v.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),E&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showCopy&&(0,v.jsx)(Q,{label:o?n.copySuccess:n.copy,icon:o?(0,v.jsx)(b.default,{fontSize:`small`,color:`success`}):(0,v.jsx)(y.default,{fontSize:`small`}),onClick:d,disabled:u}),t.showClear&&(0,v.jsx)(Q,{label:n.clear,icon:(0,v.jsx)(x.default,{fontSize:`small`}),onClick:f,disabled:u})]}),E&&D&&(0,v.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),D&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[(0,v.jsx)(Q,{label:n.undo,icon:(0,v.jsx)(S.default,{fontSize:`small`}),onClick:m,disabled:u}),(0,v.jsx)(Q,{label:n.redo,icon:(0,v.jsx)(C.default,{fontSize:`small`}),onClick:h,disabled:u})]}),O&&(0,v.jsxs)(v.Fragment,{children:[(E||D)&&(0,v.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),(0,v.jsx)(Q,{label:n.execute,icon:(0,v.jsx)(Te.default,{fontSize:`small`}),onClick:_,disabled:u})]}),!T&&!E&&!D&&!O&&(0,v.jsx)(l.Box,{sx:{height:32}})]})}function Rn({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)),u=s.errorCount.replace(`{count}`,String(i));return(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,mt:.5,px:.5},children:[(0,v.jsxs)(l.Box,{children:[r&&i>0&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,v.jsx)(De.default,{sx:{fontSize:`0.875rem`,color:`error.main`}}),(0,v.jsx)(l.FormHelperText,{sx:{color:`error.main`,m:0},children:u})]}),(0,v.jsx)(l.FormHelperText,{error:t,children:e??``})]}),n&&(0,v.jsx)(l.FormHelperText,{sx:{color:`text.disabled`,fontFamily:`monospace`,whiteSpace:`nowrap`},children:c})]})}function zn({value:e,onChange:t,placeholder:n,height:r,width:i,disabled:a=!1,readonly:o=!1,error:s=!1,helperText:u,name:d,dialect:f=`standard`,showLineNumbers:p=!0,showLineColumn:m=!0,showErrorCount:h=!1,toolbarConfig:g,translation:_,highlightColors:y,schema:b,onExecute:x,onLint:S,onBlur:C,onFocus:w}){let T={...Nn,..._},E={...Mn,...g},D=Ne(r),O=Ne(i),k=D===`auto`,A=k?void 0:D??300,j=(0,c.useRef)(null),[M,N]=(0,c.useState)(null),[P,F]=(0,c.useState)({line:1,col:1}),[I,L]=(0,c.useState)(0),R=(0,c.useCallback)(e=>{j.current=e,N(e)},[]),z=(0,c.useCallback)((e,t)=>{F({line:e,col:t})},[]),B=(0,c.useCallback)(e=>{L(e)},[]),V=m||h||!!u;return(0,v.jsxs)(l.Box,{sx:{width:O??`100%`,...k?{display:`flex`,flexDirection:`column`,flex:1}:{}},children:[(0,v.jsxs)(l.Paper,{variant:`outlined`,sx:{display:`flex`,flexDirection:`column`,overflow:`hidden`,...k?{flex:1}:{height:A},borderColor:s?`error.main`:void 0,"&:focus-within":{borderColor:s?`error.main`:`primary.main`,borderWidth:2}},children:[!o&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(Ln,{editorView:M,toolbarConfig:E,translation:T,dialect:f,disabled:a,onExecute:x}),(0,v.jsx)(l.Divider,{})]}),(0,v.jsx)(Fn,{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:x,onLint:S,onDiagnosticsChange:S?B:void 0,onViewReady:R,onCursorChange:z,onBlur:C,onFocus:w})]}),V&&(0,v.jsx)(Rn,{helperText:u,error:s,showLineColumn:m,showErrorCount:h,diagnosticsCount:I,cursorLine:P.line,cursorCol:P.col,translation:T}),d&&(0,v.jsx)(`input`,{type:`hidden`,name:d,value:e??``})]})}var Bn=2*Math.PI,Vn=11,Hn=Vn*.5,Un=5;function Wn(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 Gn(e,t){let n=Math.floor(t/Hn);return n<=0?``:e.length<=n?e:n<Un?``:e.slice(0,n-1)+`…`}function Kn({node:e,valueDecimalCount:t,valueDecimalSep:n,valueThousandsSep:r}){let i=(e.value??0)>0,a=e.ancestors().map(e=>e.data.name).reverse().join(` › `);return(0,v.jsxs)(l.Box,{sx:{py:.25},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`},children:e.data.name}),i&&(0,v.jsx)(l.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:Wn(e.value??0,t,n,r)}),e.depth>0&&(0,v.jsx)(l.Typography,{variant:`caption`,sx:{display:`block`,opacity:.65,mt:.25},children:a})]})}function qn({data:e,size:t=500,showSegmentLabels:n=!0,innerRadius:r=0,sortBy:i=`value`,chartColors:a,showRootLabel:o=!0,onSegmentClick:s,onZoomChange:u,valueDecimalCount:d=0,valueDecimalSeparator:f=`.`,valueThousandsSeparator:p=`,`,zoomable:m=!1,disabled:h=!1}){let g=(0,l.useTheme)(),_=(0,c.useRef)(null),[y,b]=(0,c.useState)(`-${t/2} -${t/2} ${t} ${t}`),[x,S]=(0,c.useState)(1),C=(0,c.useMemo)(()=>{if(x===1)return y;let[e,t,n,r]=y.split(` `).map(Number),i=n/x,a=r/x;return`${e+(n-i)/2} ${t+(r-a)/2} ${i} ${a}`},[y,x]),w=t/2,T=Math.max(0,Math.min(r,Math.max(0,w-1))),E=Math.max(1,w-T),D=[g.palette.primary.main,g.palette.secondary.main,g.palette.error.main,g.palette.warning.main,g.palette.success.main,g.palette.info.main],O=a&&a.length>0?a:D,{root:k,ringThickness:A}=(0,c.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([Bn,E])(t),r=Z.max(n.descendants(),e=>e.depth)??0,a=r>0?E/r:E;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,E,i]),[j,M]=(0,c.useState)(k),[N,P]=(0,c.useState)(k);N!==k&&(P(k),M(k));let F=(0,c.useMemo)(()=>k.children?.map(e=>e.data.name)??[k.data.name],[k]),I=(0,c.useMemo)(()=>Z.scaleOrdinal().domain(F).range(O),[O,F]),L=e=>{if(e.data.colorConfig?.fill)return e.data.colorConfig.fill;let t=e;for(;t.depth>1;)t=t.parent;return I(t.data.name)},R=(0,c.useMemo)(()=>Z.arc().startAngle(e=>e.x0).endAngle(e=>e.x1).padAngle(e=>Math.min((e.x1-e.x0)/2,.005)).padRadius(w/2).innerRadius(e=>T+e.y0).outerRadius(e=>T+e.y1-1),[w,T]),z=(0,c.useCallback)(e=>{let t=Bn/(j.x1-j.x0),n=Math.max(0,Math.min(Bn,(e.x0-j.x0)*t)),r=Math.max(0,Math.min(Bn,(e.x1-j.x0)*t)),i=j.depth===0?0:(j.depth-1)*A;return{x0:n,x1:r,y0:Math.max(0,e.y0-i),y1:Math.max(0,e.y1-i)}},[j,A]),B=e=>e.x1>e.x0&&e.y1>e.y0,V=e=>(T+(e.y0+e.y1)/2)*(e.x1-e.x0)>12,H=e=>{let t=(e.x0+e.x1)/2*180/Math.PI,n=T+(e.y0+e.y1)/2,r=t<180?0:180;return`rotate(${t-90}) translate(${n},0) rotate(${r})`},U=(0,c.useCallback)(e=>e.ancestors().includes(j),[j]),W=(0,c.useCallback)(e=>{let t=e.ancestors().reverse(),n=e.value??0,r=k.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}},[k]),G=(0,c.useCallback)(e=>{M(e),u&&u({focusNode:W(e),isRoot:e===k})},[k,W,u]);(0,c.useLayoutEffect)(()=>{let e=_.current;if(!e)return;let n=requestAnimationFrame(()=>{try{let t=e.getBBox();b(`${t.x-8} ${t.y-8} ${t.width+16} ${t.height+16}`)}catch{b(`-${t/2} -${t/2} ${t} ${t}`)}});return()=>cancelAnimationFrame(n)},[t,k,j,T,A,o]);let K=(0,c.useRef)(null),q=e=>{K.current&&=(clearTimeout(K.current),null),K.current=setTimeout(()=>{e(),K.current=null},250)},J=()=>{K.current&&=(clearTimeout(K.current),null)};(0,c.useLayoutEffect)(()=>{if(h)return;let e=e=>{e.key===`Escape`&&(J(),G(k),S(1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[h,k,G]);let Y=(0,c.useCallback)(e=>{if(!m||h||!e.ctrlKey)return;e.preventDefault();let t=e.deltaY<0?1.15:1/1.15;S(e=>Math.max(.25,Math.min(8,e*t)))},[m,h]),X=k.descendants().filter(e=>e.depth>0),ee=e=>{if(h)return;let t=X[Number(e.currentTarget.getAttribute(`data-idx`))];if(t){if(e.ctrlKey||e.metaKey){t.children&&q(()=>G(t));return}s?.(W(t),e)}},te=e=>{h||(e.ctrlKey||e.metaKey)&&(J(),G(j.parent??k))},ne=e=>{if(!h){if(e.ctrlKey||e.metaKey){J(),G(j.parent??k);return}s?.(W(j.parent??k),e)}},re={followCursor:!0,enterDelay:50,enterNextDelay:0,disableHoverListener:h,slotProps:{tooltip:{sx:{maxWidth:260}}}},ie=g.palette.text.primary,ae=g.typography.fontFamily;return(0,v.jsx)(l.Box,{sx:{display:`inline-flex`,opacity:h?.5:1,cursor:h?`not-allowed`:`default`,userSelect:`none`},children:(0,v.jsx)(`svg`,{width:t,height:t,viewBox:C,onWheel:Y,style:{fontFamily:ae??`sans-serif`,overflow:m&&x>1?`hidden`:`visible`},role:`img`,"aria-label":e.name,children:(0,v.jsxs)(`g`,{ref:_,children:[T>0&&(0,v.jsx)(l.Tooltip,{...re,title:j.data.name,placement:`top`,children:(0,v.jsx)(`circle`,{cx:0,cy:0,r:T,fill:`transparent`,pointerEvents:h?`none`:`auto`,onClick:ne,style:{cursor:h?`not-allowed`:`pointer`}})}),(0,v.jsx)(`g`,{children:X.map((e,t)=>{let n=z(e),r=B(n),i=!!e.children;return(0,v.jsx)(l.Tooltip,{...re,placement:`top`,title:r?(0,v.jsx)(Kn,{node:e,valueDecimalCount:d,valueDecimalSep:f,valueThousandsSep:p}):``,children:(0,v.jsx)(`path`,{"data-idx":t,d:R(n)||``,fill:L(e),fillOpacity:r?i?.75:.5:0,style:{pointerEvents:r&&!h?`auto`:`none`,cursor:i&&!h?`pointer`:`default`,transition:`fill-opacity 0.15s`},onClick:ee,onDoubleClick:te})},`tt-${e.data.id}-${t}`)})}),n&&(0,v.jsx)(`g`,{pointerEvents:`none`,textAnchor:`middle`,fill:ie,children:X.map((e,t)=>{if(!U(e))return null;let n=z(e);if(!V(n))return null;let r=(T+(n.y0+n.y1)/2)*(n.x1-n.x0)*.88,i=Gn(e.data.name,r);return i?(0,v.jsx)(`text`,{transform:H(n),dy:`0.35em`,fontSize:Vn,children:i},`lbl-${e.data.id}-${t}`):null})}),o&&(0,v.jsx)(l.Tooltip,{...re,placement:`top`,title:``,children:(0,v.jsx)(`g`,{textAnchor:`middle`,fill:ie,pointerEvents:h?`none`:`auto`,onClick:ne,style:{cursor:j!==k&&!h?`pointer`:`default`},children:(0,v.jsx)(`text`,{fontSize:13,dy:`0.35em`,fontWeight:`bold`,children:j.data.name})})})]})})})}qn.displayName=`SunburstChart`;var Jn={noData:`No data`};function Yn(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 Xn({name:e,valueOut:t,valueIn:n,fmt:r}){return(0,v.jsxs)(l.Box,{sx:{py:.25},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`},children:e}),(0,v.jsxs)(l.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:[r(t),` outgoing →`]}),(0,v.jsxs)(l.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:[r(n),` incoming ←`]})]})}function Zn({sourceName:e,targetName:t,sourceValue:n,targetValue:r,directed:i,fmt:a}){return(0,v.jsxs)(l.Box,{sx:{py:.25},children:[(0,v.jsxs)(l.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`},children:[e,` → `,t]}),(0,v.jsx)(l.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:a(n)}),i&&r>0&&r!==n&&(0,v.jsxs)(l.Typography,{variant:`caption`,sx:{display:`block`,opacity:.7,mt:.25},children:[t,` → `,e,`: `,a(r)]})]})}function Qn({data:e,size:t=500,innerRadius:n,ringThickness:r=20,padAngle:i,ribbonPadAngle:a,sortSubgroups:o=`descending`,sortChords:s=`descending`,chartColors:u,groupColorConfigs:d,showGroupLabels:f=!0,labelOffset:p=8,ribbonOpacity:m=.75,ribbonBlendMode:h,directed:g=!0,valueDecimalCount:_=0,valueDecimalSeparator:y=`.`,valueThousandsSeparator:b=`,`,onGroupClick:x,onChordClick:S,zoomable:C=!1,disabled:w=!1}){let T=(0,l.useTheme)(),E=h??(T.palette.mode===`dark`?`normal`:`multiply`),D=[T.palette.primary.main,T.palette.secondary.main,T.palette.error.main,T.palette.warning.main,T.palette.success.main,T.palette.info.main],O=u&&u.length>0?u:D,k=n??Math.min(t,t)*.5-90,A=Math.max(10,k),j=A+Math.max(1,r),M=i??10/A,N=a??1/A,P=(0,c.useCallback)(e=>Yn(e,_,y,b),[_,y,b]),{names:F,matrix:I}=(0,c.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]),L=(0,c.useMemo)(()=>{let e=(g?Z.chordDirected():Z.chord()).padAngle(M);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(I)},[I,M,g,o,s]),R=(0,c.useMemo)(()=>Z.arc().innerRadius(A).outerRadius(j),[A,j]),z=(0,c.useMemo)(()=>(g?Z.ribbonArrow():Z.ribbon()).radius(A-1).padAngle(N),[A,N,g]),B=(0,c.useCallback)(e=>z({source:{startAngle:e.source.startAngle,endAngle:e.source.endAngle,radius:A-1},target:{startAngle:e.target.startAngle,endAngle:e.target.endAngle,radius:A-1}})??``,[z,A]),V=(0,c.useMemo)(()=>Z.scaleOrdinal().domain(Z.range(F.length)).range(O.length>=F.length?O:[...Array(Math.ceil(F.length/O.length))].flatMap(()=>O).slice(0,F.length)),[O,F.length]),H=(0,c.useCallback)(e=>d?.[F[e]]?.fill??V(e),[d,F,V]),U=(0,c.useRef)(null),[W,G]=(0,c.useState)(`-${t/2} -${t/2} ${t} ${t}`),[K,q]=(0,c.useState)(1),J=(0,c.useMemo)(()=>{if(K===1)return W;let[e,t,n,r]=W.split(` `).map(Number),i=n/K,a=r/K;return`${e+(n-i)/2} ${t+(r-a)/2} ${i} ${a}`},[W,K]);(0,c.useLayoutEffect)(()=>{let e=U.current;if(!e)return;let n=requestAnimationFrame(()=>{try{let t=e.getBBox();G(`${t.x-8} ${t.y-8} ${t.width+16} ${t.height+16}`)}catch{G(`-${t/2} -${t/2} ${t} ${t}`)}});return()=>cancelAnimationFrame(n)},[t,A,j,F.length,L]);let[Y,X]=(0,c.useState)(null),ee=(0,c.useCallback)(e=>({name:F[e.index],index:e.index,valueOut:Z.sum(L,t=>t.source.index===e.index?t.source.value:0),valueIn:Z.sum(L,t=>t.target.index===e.index?t.source.value:0)}),[F,L]),te=(0,c.useCallback)(e=>({source:{name:F[e.source.index],index:e.source.index,value:e.source.value},target:{name:F[e.target.index],index:e.target.index,value:e.target.value}}),[F]),ne=e=>{let t=(e.startAngle+e.endAngle)/2,n=t*180/Math.PI-90,r=t>Math.PI?` rotate(180)`:``;return`rotate(${n}) translate(${j+p})${r}`},re=e=>(e.startAngle+e.endAngle)/2>Math.PI?`end`:`start`,ie=(0,c.useCallback)(e=>{if(!C||w||!e.ctrlKey)return;e.preventDefault();let t=e.deltaY<0?1.15:1/1.15;q(e=>Math.max(.25,Math.min(8,e*t)))},[C,w]);(0,c.useLayoutEffect)(()=>{if(!C)return;let e=e=>{e.key===`Escape`&&q(1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[C]);let ae={followCursor:!0,enterDelay:50,enterNextDelay:0,disableHoverListener:w,slotProps:{tooltip:{sx:{maxWidth:240}}}},oe=T.palette.text.primary,se=T.typography.fontFamily;return(0,v.jsx)(l.Box,{sx:{display:`inline-flex`,opacity:w?.5:1,cursor:w?`not-allowed`:`default`,userSelect:`none`},children:(0,v.jsx)(`svg`,{width:t,height:t,viewBox:J,onWheel:ie,style:{fontFamily:se??`sans-serif`,overflow:C&&K>1?`hidden`:`visible`},role:`img`,"aria-label":`Chord chart`,children:(0,v.jsxs)(`g`,{ref:U,children:[(0,v.jsx)(`g`,{children:L.groups.map(e=>{let t=ee(e),n=Y===e.index,r=Y!==null&&!n;return(0,v.jsx)(l.Tooltip,{...ae,title:(0,v.jsx)(Xn,{name:t.name,valueOut:t.valueOut,valueIn:t.valueIn,fmt:P}),children:(0,v.jsxs)(`g`,{style:{cursor:w?`not-allowed`:`pointer`},onMouseEnter:()=>!w&&X(e.index),onMouseLeave:()=>X(null),onClick:e=>!w&&x?.(t,e),children:[(0,v.jsx)(`path`,{d:R(e)||``,fill:H(e.index),stroke:T.palette.divider,opacity:r?.35:1,style:{transition:`opacity 0.15s`}}),f&&(0,v.jsx)(`text`,{dy:`0.35em`,fontSize:11,fill:oe,transform:ne(e),textAnchor:re(e),pointerEvents:`none`,children:F[e.index]})]})},`grp-tt-${e.index}`)})}),(0,v.jsx)(`g`,{fillOpacity:m,style:{mixBlendMode:E},children:L.map((e,t)=>{let n=te(e),r=Y===null||e.source.index===Y||e.target.index===Y;return(0,v.jsx)(l.Tooltip,{...ae,title:(0,v.jsx)(Zn,{sourceName:n.source.name,targetName:n.target.name,sourceValue:n.source.value,targetValue:n.target.value,directed:g,fmt:P}),children:(0,v.jsx)(`path`,{d:B(e),fill:H(e.target.index),stroke:`none`,opacity:r?1:.12,style:{cursor:w?`not-allowed`:`pointer`,transition:`opacity 0.15s`},onClick:e=>!w&&S?.(n,e)})},`chord-tt-${t}`)})})]})})})}Qn.displayName=`ChordChart`;var $n={noData:`No data`},er={noData:`No data`,specialValueA:`Value A`,specialValueB:`Value B`},tr={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 nr({path:e,size:t}){let n=t/2;return(0,v.jsx)(`g`,{transform:`translate(${-n},${-n})`,pointerEvents:`none`,children:(0,v.jsx)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,overflow:`visible`,children:(0,v.jsx)(`path`,{d:e,fill:`white`})})})}function rr({info:e,labelA:t,labelB:n}){return(0,v.jsxs)(l.Box,{sx:{p:2,minWidth:200,maxWidth:280},children:[(0,v.jsxs)(l.Box,{sx:{display:`flex`,alignItems:`center`,gap:1.5,mb:1.5},children:[(0,v.jsx)(l.Avatar,{sx:{bgcolor:`primary.main`,width:40,height:40},children:e.name.charAt(0).toUpperCase()}),(0,v.jsxs)(l.Box,{children:[(0,v.jsx)(l.Typography,{variant:`body2`,sx:{fontWeight:`bold`},children:e.name}),e.subname&&(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:e.subname})]})]}),(e.specialValueA!=null||e.specialValueB!=null)&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(l.Divider,{sx:{mb:1.5}}),e.specialValueA!=null&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,mb:.5},children:[(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:t}),(0,v.jsx)(l.Typography,{variant:`caption`,children:String(e.specialValueA)})]}),e.specialValueB!=null&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`},children:[(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:n}),(0,v.jsx)(l.Typography,{variant:`caption`,children:String(e.specialValueB)})]})]})]})}function ir({data:e,size:t=600,autoFit:n=!0,sortBy:r=`name`,showLabels:i=!0,showIcons:a=!0,chartColors:o,rootNodeRadius:s=22,branchNodeRadius:u=16,leafNodeRadius:d=11,linkColor:f,linkStrokeOpacity:p=1,linkStrokeWidth:m=1.5,labelFontSize:h=12,labelColor:g,separationSibling:_=1,separationCousin:y=2,zoomable:b=!1,drillable:x=!1,onFocusChange:S,showNodePopover:C=!1,renderNodePopoverContent:w,onNodeClick:T,disabled:E=!1,translation:D}){let O=(0,l.useTheme)(),k={...er,...D},A=[O.palette.primary.main,O.palette.secondary.main,O.palette.info.main,O.palette.success.main,O.palette.warning.main,O.palette.error.main],j=o&&o.length>0?o:A,M=(0,c.useCallback)(e=>e.depth===0?s:e.children?u:d,[s,u,d]),N=(0,c.useCallback)(e=>e.data.colorConfig?.fill??j[e.depth%j.length],[j]),[P,F]=(0,c.useState)([e]),I=P[P.length-1],[L,R]=(0,c.useState)(e);L!==e&&(R(e),F([e]));let z=Math.max(1,t/2-70),B=(0,c.useMemo)(()=>{let e=Z.hierarchy(I);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,z]).separation((e,t)=>(e.parent===t.parent?_:y)*1.4/Math.max(1,e.depth))(e)},[I,r,z,_,y]),V=B.links(),H=B.descendants(),U=(0,c.useMemo)(()=>Z.linkRadial().angle(e=>e.x).radius(e=>e.y),[]),W=(0,c.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}),[]),G=(0,c.useRef)(null),[K,q]=(0,c.useState)(`-${t/2} -${t/2} ${t} ${t}`),[J,Y]=(0,c.useState)(1);(0,c.useLayoutEffect)(()=>{let e=G.current;if(!e)return;let n=requestAnimationFrame(()=>{try{let t=e.getBBox();q(`${t.x-20} ${t.y-20} ${t.width+40} ${t.height+40}`)}catch{q(`-${t/2} -${t/2} ${t} ${t}`)}});return()=>cancelAnimationFrame(n)},[t,B,i,n]);let X=(0,c.useMemo)(()=>{if(J===1)return K;let[e,t,n,r]=K.split(` `).map(Number),i=n/J,a=r/J;return`${e+(n-i)/2} ${t+(r-a)/2} ${i} ${a}`},[K,J]),ee=(0,c.useCallback)(e=>{if(!b||E||!e.ctrlKey)return;e.preventDefault();let t=e.deltaY<0?1.15:1/1.15;Y(e=>Math.max(.25,Math.min(8,e*t)))},[b,E]);(0,c.useLayoutEffect)(()=>{if(!b&&!x)return;let t=t=>{t.key===`Escape`&&(b&&Y(1),x&&(F([e]),S?.(null)))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[b,x,e,S]);let te=(0,c.useRef)(null),ne=e=>{te.current&&=(clearTimeout(te.current),null),te.current=setTimeout(()=>{e(),te.current=null},250)},re=()=>{te.current&&=(clearTimeout(te.current),null)},[ie,ae]=(0,c.useState)(null),oe=(0,c.useRef)(null),se=(0,c.useRef)(null),[ce,le]=(0,c.useState)(!1),[ue,de]=(0,c.useState)(null),[fe,pe]=(0,c.useState)({left:0,top:0}),[me,he]=(0,c.useState)(null),ge=(0,c.useCallback)(()=>{F(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]),_e=e=>{E||!x||(e.ctrlKey||e.metaKey)&&(re(),ge())},ve=e=>{if(E)return;let t=H[Number(e.currentTarget.getAttribute(`data-idx`))];if(!t)return;let n=W(t);if((e.ctrlKey||e.metaKey)&&x&&t.children){ne(()=>{F(e=>[...e,t.data]),S?.(n)});return}if(C){let t=oe.current?.getBoundingClientRect();pe({left:t?e.clientX-t.left:e.clientX,top:t?e.clientY-t.top:e.clientY}),de(se.current),he(n),le(!0)}T?.(n,e)},ye=g||O.palette.text.primary,be=f||O.palette.text.secondary,xe=O.palette.background.paper,Se=O.typography.fontFamily;return(0,v.jsxs)(l.Box,{ref:oe,sx:{display:`inline-flex`,position:`relative`,opacity:E?.5:1,cursor:E?`not-allowed`:`default`,userSelect:`none`},children:[x&&P.length>1&&(0,v.jsx)(l.Box,{sx:{position:`absolute`,top:4,left:0,right:0,display:`flex`,justifyContent:`center`,gap:.5,pointerEvents:`none`,zIndex:1},children:(0,v.jsx)(l.Typography,{variant:`caption`,sx:{bgcolor:`action.hover`,borderRadius:1,px:1,py:.25,color:`text.secondary`,fontSize:`0.7rem`},children:P.map(e=>e.name).join(` › `)})}),(0,v.jsx)(l.Box,{ref:se,sx:{position:`absolute`,left:fe.left,top:fe.top,width:0,height:0}}),(0,v.jsx)(`svg`,{width:t,height:t,viewBox:X,onWheel:ee,style:{fontFamily:Se??`sans-serif`,overflow:b&&J>1?`hidden`:`visible`},role:`img`,"aria-label":e.name,children:(0,v.jsxs)(`g`,{ref:G,children:[(0,v.jsx)(`g`,{fill:`none`,stroke:be,strokeOpacity:p,strokeWidth:m,children:V.map((e,t)=>(0,v.jsx)(`path`,{d:U(e)},`link-${t}`))}),(0,v.jsx)(`g`,{children:H.map((e,t)=>{let n=M(e),r=N(e),i=W(e),o=ie===t,s=e.children?tr.folder:tr.person,c=Math.round(n*1.3);return(0,v.jsx)(l.Tooltip,{title:(0,v.jsxs)(l.Box,{sx:{py:.5,minWidth:160},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`,fontSize:`0.8rem`},children:e.data.name}),e.data.subname&&(0,v.jsx)(l.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:e.data.subname}),(i.specialValueA!=null||i.specialValueB!=null||e.children)&&(0,v.jsxs)(l.Box,{sx:{mt:.75,borderTop:`1px solid rgba(255,255,255,0.2)`,pt:.75},children:[i.specialValueA!=null&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{opacity:.6},children:k.specialValueA??`A`}),(0,v.jsx)(l.Typography,{variant:`caption`,children:String(i.specialValueA)})]}),i.specialValueB!=null&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{opacity:.6},children:k.specialValueB??`B`}),(0,v.jsx)(l.Typography,{variant:`caption`,children:String(i.specialValueB)})]}),e.children&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{opacity:.6},children:`Reports`}),(0,v.jsx)(l.Typography,{variant:`caption`,children:e.children.length})]})]})]}),followCursor:!0,enterDelay:50,enterNextDelay:0,disableHoverListener:E,slotProps:{tooltip:{sx:{maxWidth:260}}},children:(0,v.jsxs)(`g`,{"data-idx":t,transform:`rotate(${e.x*180/Math.PI-90}) translate(${e.y},0)`,onClick:ve,onDoubleClick:_e,onMouseEnter:()=>!E&&ae(t),onMouseLeave:()=>ae(null),style:{cursor:E?`not-allowed`:`pointer`},children:[(0,v.jsx)(`circle`,{r:Math.max(n+8,24),fill:`transparent`}),(0,v.jsx)(`circle`,{r:n+2,fill:r,fillOpacity:.15}),(0,v.jsx)(`circle`,{r:n,fill:r,fillOpacity:o?.85:1,style:{transition:`fill-opacity 0.15s`}}),a&&(0,v.jsx)(nr,{path:s,size:c})]})},`node-${e.data.id}-${t}`)})}),i&&(0,v.jsx)(`g`,{children:H.map((e,t)=>{let n=M(e),r=e.x<Math.PI==!e.children,i=n+6,a=r?i:-i,o=r?`start`:`end`;return(0,v.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:xe,strokeWidth:3,fill:ye,fontSize:h,fontWeight:e.depth===0?`bold`:`normal`,pointerEvents:`none`,children:e.data.name},`lbl-${e.data.id}-${t}`)})})]})}),C&&(0,v.jsx)(l.Popover,{open:ce,anchorEl:ue,onClose:()=>le(!1),anchorOrigin:{vertical:`top`,horizontal:`right`},transformOrigin:{vertical:`top`,horizontal:`left`},slotProps:{paper:{elevation:4}},children:me&&(w?w(me):(0,v.jsx)(rr,{info:me,labelA:k.specialValueA??`Value A`,labelB:k.specialValueB??`Value B`}))})]})}ir.displayName=`RadialTreeChart`;var ar=.56;function or(e,t,n){return e.length*n*ar<=t?e:t>=3*n*ar+n*2?`…`:``}function sr({data:e,size:t=600,padding:n=3,sortBy:r=`value`,showLabels:i=!0,showAllLabels:a=!1,labelFontSize:o=13,innerLabelFontSize:s=9,labelColor:u,chartColors:d,depthColorStart:f,depthColorEnd:p,background:m,duration:h=750,zoomable:g=!1,disabled:_=!1,onCircleClick:y,onZoomChange:b}){let x=(0,l.useTheme)(),S=[x.palette.primary.main,x.palette.secondary.main,x.palette.error.main,x.palette.warning.main,x.palette.success.main,x.palette.info.main],C=u||x.palette.text.primary,w=m||x.palette.background.default,T=x.typography.fontFamily,E=(0,c.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]),D=E.descendants(),O=(0,c.useMemo)(()=>Z.max(D,e=>e.depth)??0,[D]),k=!!(f&&p),A=(0,c.useMemo)(()=>k?Z.scaleSequential(Z.interpolateHcl(f,p)).domain([0,Math.max(1,O)]):null,[k,f,p,O]),j=d&&d.length>0?d:S,M=(0,c.useCallback)(e=>e.data.colorConfig?.fill?e.data.colorConfig.fill:k&&A?e.children?A(e.depth):x.palette.background.paper:j[e.depth%j.length],[k,A,j,x]),[N,P]=(0,c.useState)(1),F=(0,c.useCallback)(e=>{if(!g||_||!e.ctrlKey)return;e.preventDefault();let t=e.deltaY<0?1.15:1/1.15;P(e=>Math.max(.25,Math.min(8,e*t)))},[g,_]);(0,c.useLayoutEffect)(()=>{if(!g)return;let e=e=>{e.key===`Escape`&&P(1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[g]);let I=(0,c.useMemo)(()=>{let e=`${-t/2} ${-t/2} ${t} ${t}`;if(N===1)return e;let n=t/N,r=(t-n)/2;return`${-t/2+r} ${-t/2+r} ${n} ${n}`},[t,N]),L=(0,c.useCallback)(e=>{let t=e.value??0,n=E.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}},[E]),R=(0,c.useRef)(null),z=(0,c.useRef)([E.x,E.y,E.r*2]),B=(0,c.useRef)(E),[V,H]=(0,c.useState)(E),U=(0,c.useCallback)(e=>{B.current=e,H(e)},[]),[W,G]=(0,c.useState)(e);W!==e&&(G(e),U(E),B.current=E);let K=(0,c.useCallback)(e=>{let n=R.current;if(!n)return;z.current=e;let r=t/e[2],o=B.current,c=n.querySelectorAll(`g[data-role='nodes'] > g`),l=n.querySelectorAll(`g[data-role='nodes'] > g > circle`);for(let t=0;t<D.length;t++){let n=D[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<D.length;n++){let i=D[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<D.length;n++){let i=D[n],a=t[n];if(!a)continue;let c=i.r*r,l=c*1.6,u=o===E?i!==E:i.ancestors().includes(o),d=i.parent===o;if(u&&!d&&c>=14){let t=or(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`}}},[D,t,i,a,s,E]);(0,c.useLayoutEffect)(()=>{K([V.x,V.y,V.r*2])},[E,t,V,K]);let q=(0,c.useCallback)((e,t)=>{let n=R.current;if(!n)return;let r=V,i=z.current,a=[e.x,e.y,e.r*2];U(e),Z.select(n).transition().duration(t).ease(Z.easeCubic).tween(`zoom`,()=>{let e=Z.interpolateZoom(i,a);return t=>K(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)=>+(D[n].parent===e)).on(`start`,function(t,n){D[n].parent===e&&(this.style.display=`inline`)}).on(`end`,function(t,n){D[n].parent!==e&&(this.style.display=`none`)}),b?.({previousName:r.data.name,currentName:e.data.name,currentDepth:e.depth,isRoot:e===E})},[V,D,E,K,b,U]),J=(0,c.useRef)(null),Y=e=>{J.current&&=(clearTimeout(J.current),null),J.current=setTimeout(()=>{e(),J.current=null},250)},X=()=>{J.current&&=(clearTimeout(J.current),null)};(0,c.useLayoutEffect)(()=>{if(_)return;let e=e=>{e.key===`Escape`&&(X(),q(E,h))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[_,E,h]);let ee=e=>{if(_||!(e.ctrlKey||e.metaKey))return;X(),e.preventDefault();let t=V.parent??E;t!==V&&q(t,e.altKey?Math.max(250,h*10):h)},te={followCursor:!0,enterDelay:50,enterNextDelay:0,disableHoverListener:_,slotProps:{tooltip:{sx:{maxWidth:220}}}};return(0,v.jsxs)(l.Box,{sx:{display:`inline-flex`,position:`relative`,opacity:_?.5:1,cursor:_?`not-allowed`:`default`,userSelect:`none`},children:[(0,v.jsxs)(`svg`,{ref:R,width:t,height:t,viewBox:I,onWheel:F,style:{display:`block`,background:w,fontFamily:T??`sans-serif`,overflow:g&&N>1?`hidden`:`visible`},role:`img`,"aria-label":e.name,onDoubleClick:ee,children:[(0,v.jsx)(`g`,{"data-role":`nodes`,children:D.map((e,n)=>{let r=L(e),i=(0,v.jsxs)(l.Box,{sx:{py:.5,minWidth:160},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`,fontSize:`0.8rem`},children:e.data.name}),(e.value??0)>0&&(0,v.jsxs)(l.Box,{sx:{mt:.75,borderTop:`1px solid rgba(255,255,255,0.2)`,pt:.75},children:[(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{opacity:.6},children:`Value`}),(0,v.jsx)(l.Typography,{variant:`caption`,children:e.value?.toLocaleString()})]}),(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{opacity:.6},children:`Share`}),(0,v.jsxs)(l.Typography,{variant:`caption`,children:[r.percentage,`%`]})]}),e.children&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{opacity:.6},children:`Children`}),(0,v.jsx)(l.Typography,{variant:`caption`,children:e.children.length})]})]})]});return(0,v.jsx)(`g`,{transform:`translate(${e.x-t/2},${e.y-t/2})`,children:n===0?null:(0,v.jsx)(l.Tooltip,{...te,title:i,children:(0,v.jsx)(`circle`,{r:e.r,fill:M(e),stroke:e.data.colorConfig?.stroke??x.palette.background.paper,strokeWidth:.75,style:{cursor:_?`not-allowed`:e.children?`pointer`:`default`,transition:`stroke-width 0.1s`},onMouseEnter:e=>{_||(e.currentTarget.style.strokeWidth=`2`)},onMouseLeave:e=>{e.currentTarget.style.strokeWidth=`0.75`},onClick:t=>{if(!_){if(t.ctrlKey||t.metaKey){if(e.children){let n=t.altKey?Math.max(250,h*10):h;Y(()=>q(e,n))}return}y?.(r,t)}},onDoubleClick:e=>{if(!_&&(e.ctrlKey||e.metaKey)){X(),e.preventDefault(),e.stopPropagation();let t=V.parent??E;t!==V&&q(t,e.altKey?Math.max(250,h*10):h)}}})})},`n-${n}`)})}),i&&(0,v.jsx)(`g`,{"data-role":`labels`,textAnchor:`middle`,dominantBaseline:`middle`,pointerEvents:`none`,fontSize:o,fill:C,children:D.map((e,n)=>(0,v.jsx)(`text`,{transform:`translate(${e.x-t/2},${e.y-t/2})`,style:{display:e.parent===E?`inline`:`none`,fillOpacity:+(e.parent===E)},children:e.data.name},`lbl-${n}`))}),a&&(0,v.jsx)(`g`,{"data-role":`inner-labels`,textAnchor:`middle`,dominantBaseline:`middle`,pointerEvents:`none`,fontSize:s,fill:C,children:D.map((e,n)=>(0,v.jsx)(`text`,{transform:`translate(${e.x-t/2},${e.y-t/2})`,style:{display:`none`}},`inner-lbl-${n}`))})]}),V!==E&&!_&&(0,v.jsx)(l.Box,{sx:{position:`absolute`,bottom:6,left:0,right:0,display:`flex`,justifyContent:`center`,pointerEvents:`none`},children:(0,v.jsxs)(l.Typography,{variant:`caption`,sx:{bgcolor:`action.hover`,borderRadius:1,px:1,py:.25,color:`text.secondary`,fontSize:`0.7rem`},children:[V.ancestors().map(e=>e.data.name).reverse().join(` › `),` · Ctrl / Cmd ⌘+DblClick to zoom out · Escape to reset`]})})]})}sr.displayName=`CirclePackingChart`;var cr={noData:`No data`},lr={noData:`No data`,specialValueA:`Value A`,specialValueB:`Value B`},ur={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 dr({path:e,size:t}){let n=t/2;return(0,v.jsx)(`g`,{transform:`translate(${-n},${-n})`,pointerEvents:`none`,children:(0,v.jsx)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,overflow:`visible`,children:(0,v.jsx)(`path`,{d:e,fill:`white`})})})}function fr({info:e,labelA:t,labelB:n}){return(0,v.jsxs)(l.Box,{sx:{p:2,minWidth:200,maxWidth:280},children:[(0,v.jsxs)(l.Box,{sx:{display:`flex`,alignItems:`center`,gap:1.5,mb:1.5},children:[(0,v.jsx)(l.Avatar,{sx:{bgcolor:`primary.main`,width:40,height:40},children:e.name.charAt(0).toUpperCase()}),(0,v.jsxs)(l.Box,{children:[(0,v.jsx)(l.Typography,{variant:`body2`,sx:{fontWeight:`bold`},children:e.name}),e.subname&&(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:e.subname})]})]}),(e.specialValueA!=null||e.specialValueB!=null)&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(l.Divider,{sx:{mb:1.5}}),e.specialValueA!=null&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,mb:.5},children:[(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:t}),(0,v.jsx)(l.Typography,{variant:`caption`,children:String(e.specialValueA)})]}),e.specialValueB!=null&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`},children:[(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:n}),(0,v.jsx)(l.Typography,{variant:`caption`,children:String(e.specialValueB)})]})]})]})}function pr({data:e,orientation:t=`LR`,width:n=800,height:r=500,levelSpacing:i=200,nodeRadius:a=10,sortBy:o=`name`,showLabels:s=!0,labelFontSize:u=12,labelColor:d,showIcons:f=!0,chartColors:p,linkStrokeOpacity:m=1,linkStrokeWidth:h=1.5,linkColor:g,zoomable:_=!1,drillable:y=!1,onFocusChange:b,showNodePopover:x=!1,renderNodePopoverContent:S,onNodeClick:C,disabled:w=!1,translation:T}){let E=(0,l.useTheme)(),D={...lr,...T},O=[E.palette.primary.main,E.palette.secondary.main,E.palette.error.main,E.palette.warning.main,E.palette.success.main,E.palette.info.main],k=p&&p.length>0?p:O,A=d||E.palette.text.primary,j=g||E.palette.text.secondary,M=E.palette.background.paper,N=E.typography.fontFamily,P=t===`TB`||t===`BT`,F=P?r:n,I=P?n:r,[L,R]=(0,c.useState)([e]),z=L[L.length-1],[B,V]=(0,c.useState)(e);B!==e&&(V(e),R([e]));let H=(0,c.useMemo)(()=>{let e=Z.hierarchy(z);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([F*.8,Math.min(t*i,I*.85)])(e)},[z,o,F,I,i]),U=H.descendants(),W=H.links(),G=(0,c.useCallback)(e=>e.data.colorConfig?.fill??k[e.depth%k.length],[k]),K=(0,c.useCallback)(e=>{switch(t){case`LR`:return{x:e.y,y:e.x-F*.4};case`RL`:return{x:I*.85-e.y,y:e.x-F*.4};case`TB`:return{x:e.x-F*.4,y:e.y};case`BT`:return{x:e.x-F*.4,y:I*.85-e.y}}},[t,F,I]),q=(0,c.useCallback)(e=>{let n=K(e.source),r=K(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}`},[K,t]),J=(0,c.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}),[]),[Y,X]=(0,c.useState)(`0 -${r/2} ${n} ${r}`),[ee,te]=(0,c.useState)(1),ne=(0,c.useRef)(null),re=(0,c.useMemo)(()=>{if(ee===1)return Y;let[e,t,n,r]=Y.split(` `).map(Number),i=n/ee,a=r/ee;return`${e+(n-i)/2} ${t+(r-a)/2} ${i} ${a}`},[Y,ee]);(0,c.useLayoutEffect)(()=>{let e=ne.current;if(!e)return;let t=requestAnimationFrame(()=>{try{let t=e.getBBox();X(`${t.x-24} ${t.y-24} ${t.width+48} ${t.height+48}`)}catch{X(`0 -${r/2} ${n} ${r}`)}});return()=>cancelAnimationFrame(t)},[H,n,r,t]);let ie=(0,c.useCallback)(e=>{if(!_||w||!e.ctrlKey)return;e.preventDefault();let t=e.deltaY<0?1.15:1/1.15;te(e=>Math.max(.25,Math.min(8,e*t)))},[_,w]),ae=(0,c.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)},ce=(0,c.useCallback)(()=>{R(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,c.useLayoutEffect)(()=>{if(!_&&!y)return;let t=t=>{t.key===`Escape`&&(_&&te(1),y&&(R([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)},[_,y,e,b]);let le=(0,c.useRef)(null),ue=(0,c.useRef)(null),[de,fe]=(0,c.useState)(!1),[pe,me]=(0,c.useState)(null),[he,ge]=(0,c.useState)({left:0,top:0}),[_e,ve]=(0,c.useState)(null),ye=(e,t)=>{if(w)return;let n=J(e);if((t.ctrlKey||t.metaKey)&&y&&e.children){oe(()=>{R(t=>[...t,e.data]),b?.({focusedNode:n,isRoot:!1})});return}if((t.ctrlKey||t.metaKey)&&y){se(),ce();return}if(x){let e=le.current?.getBoundingClientRect();ge({left:e?t.clientX-e.left:t.clientX,top:e?t.clientY-e.top:t.clientY}),me(ue.current),ve(n),fe(!0)}C?.(n,t)},be=(e,t)=>{w||!y||(t.ctrlKey||t.metaKey)&&(se(),ce())},xe={followCursor:!0,enterDelay:50,enterNextDelay:0,disableHoverListener:w,slotProps:{tooltip:{sx:{maxWidth:240}}}},Se=Math.round(a*1.3);return(0,v.jsxs)(l.Box,{ref:le,sx:{display:`inline-flex`,position:`relative`,opacity:w?.5:1,cursor:w?`not-allowed`:`default`,userSelect:`none`},children:[(0,v.jsx)(l.Box,{ref:ue,sx:{position:`absolute`,left:he.left,top:he.top,width:0,height:0}}),y&&L.length>1&&(0,v.jsx)(l.Box,{sx:{position:`absolute`,top:4,left:0,right:0,display:`flex`,justifyContent:`center`,pointerEvents:`none`,zIndex:1},children:(0,v.jsx)(l.Typography,{variant:`caption`,sx:{bgcolor:`action.hover`,borderRadius:1,px:1,py:.25,color:`text.secondary`,fontSize:`0.7rem`},children:L.map(e=>e.name).join(` › `)})}),(0,v.jsx)(`svg`,{width:n,height:r,viewBox:re,onWheel:ie,style:{fontFamily:N??`sans-serif`,overflow:_&&ee>1?`hidden`:`visible`},role:`img`,"aria-label":e.name,children:(0,v.jsxs)(`g`,{ref:ne,children:[(0,v.jsx)(`g`,{fill:`none`,stroke:j,strokeOpacity:m,strokeWidth:h,children:W.map((e,t)=>(0,v.jsx)(`path`,{d:q(e)},`link-${t}`))}),U.map((e,n)=>{let r=K(e),i=G(e),o=J(e),c=e.children?ur.folder:ur.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,g=d?`start`:p?`end`:`middle`,_=(0,v.jsxs)(l.Box,{sx:{py:.5,minWidth:140},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`,fontSize:`0.8rem`},children:e.data.name}),e.data.subname&&(0,v.jsx)(l.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:e.data.subname}),(o.specialValueA!=null||o.specialValueB!=null||e.children)&&(0,v.jsxs)(l.Box,{sx:{mt:.75,borderTop:`1px solid rgba(255,255,255,0.2)`,pt:.75},children:[o.specialValueA!=null&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{opacity:.6},children:D.specialValueA??`A`}),(0,v.jsx)(l.Typography,{variant:`caption`,children:String(o.specialValueA)})]}),o.specialValueB!=null&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{opacity:.6},children:D.specialValueB??`B`}),(0,v.jsx)(l.Typography,{variant:`caption`,children:String(o.specialValueB)})]}),e.children&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{opacity:.6},children:`Reports`}),(0,v.jsx)(l.Typography,{variant:`caption`,children:e.children.length})]})]})]});return(0,v.jsx)(l.Tooltip,{...xe,title:_,children:(0,v.jsxs)(`g`,{transform:`translate(${r.x},${r.y})`,onClick:t=>ye(e,t),onDoubleClick:t=>be(e,t),style:{cursor:w?`not-allowed`:`pointer`},children:[(0,v.jsx)(`circle`,{r:a+8,fill:`transparent`}),(0,v.jsx)(`circle`,{r:a+2,fill:i,fillOpacity:.15}),(0,v.jsx)(`circle`,{r:a,fill:i}),f&&(0,v.jsx)(dr,{path:c,size:Se}),s&&(0,v.jsx)(`text`,{x:m,y:h,dy:`0.35em`,textAnchor:g,fontSize:u,fontWeight:e.children?`bold`:`normal`,fill:e.data.colorConfig?.textColor??A,paintOrder:`stroke`,stroke:M,strokeWidth:3,pointerEvents:`none`,children:e.data.name})]})},`node-${n}`)})]})}),x&&(0,v.jsx)(l.Popover,{open:de,anchorEl:pe,onClose:()=>fe(!1),anchorOrigin:{vertical:`top`,horizontal:`right`},transformOrigin:{vertical:`top`,horizontal:`left`},slotProps:{paper:{elevation:4}},children:_e&&(S?S(_e):(0,v.jsx)(fr,{info:_e,labelA:D.specialValueA??`Value A`,labelB:D.specialValueB??`Value B`}))})]})}pr.displayName=`HorizontalTreeChart`,exports.ChordChart=Qn,exports.CirclePackingChart=sr,exports.DEFAULT_CHECK_COLORS=Jt,exports.DEFAULT_CHORD_CHART_TRANSLATION=$n,exports.DEFAULT_CIRCLE_PACKING_TRANSLATION=cr,exports.DEFAULT_GANTT_TRANSLATIONS=it,exports.DEFAULT_HORIZONTAL_TREE_TRANSLATION=lr,exports.DEFAULT_JSON_EDITOR_TOOLBAR_CONFIG=Oe,exports.DEFAULT_JSON_EDITOR_TRANSLATION=ke,exports.DEFAULT_METER_COLORS=qt,exports.DEFAULT_PASSWORD_TRANSLATIONS=Kt,exports.DEFAULT_RADIAL_TREE_CHART_TRANSLATION=er,exports.DEFAULT_RICH_TEXT_EDITOR_TOOLBAR_CONFIG=hn,exports.DEFAULT_RICH_TEXT_EDITOR_TRANSLATION=gn,exports.DEFAULT_SQL_EDITOR_TOOLBAR_CONFIG=Mn,exports.DEFAULT_SQL_EDITOR_TRANSLATION=Nn,exports.DEFAULT_SUNBURST_CHART_TRANSLATION=Jn,exports.DEFAULT_TAG_SELECTION_TRANSLATION=un,exports.GanttChart=Ht,exports.HorizontalTreeChart=pr,exports.JsonEditor=Fe,exports.PasswordStrengthMeter=Zt,exports.RadialTreeChart=ir,exports.RichTextEditor=jn,exports.SqlEditor=zn,exports.SunburstChart=qn,exports.TagSelection=mn,exports.useGanttChartStore=$,exports.useGanttTheme=Lt,exports.useGanttTranslations=Ft,exports.useRawGanttChartStore=Nt;
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(`react`),l=require(`@mui/material`),u=require(`@codemirror/view`),d=require(`@codemirror/state`),f=require(`@codemirror/lang-json`),p=require(`@codemirror/commands`),m=require(`@codemirror/language`),h=require(`@codemirror/lint`),g=require(`@lezer/highlight`),_=require(`@replit/codemirror-minimap`),v=require(`react/jsx-runtime`),y=require(`@mui/icons-material/ContentCopy`);y=s(y,1);let b=require(`@mui/icons-material/Check`);b=s(b,1);let x=require(`@mui/icons-material/Delete`);x=s(x,1);let S=require(`@mui/icons-material/Undo`);S=s(S,1);let C=require(`@mui/icons-material/Redo`);C=s(C,1);let w=require(`@mui/icons-material/AutoFixHigh`);w=s(w,1);let T=require(`@mui/icons-material/Compress`);T=s(T,1);let E=require(`@mui/icons-material/CheckCircleOutlined`);E=s(E,1);let D=require(`@mui/icons-material/ErrorOutlined`);D=s(D,1);let O=require(`zustand`),k=require(`zustand/vanilla`),A=require(`@tanstack/react-virtual`),j=require(`@mui/icons-material/Add`);j=s(j,1);let M=require(`@mui/icons-material/Edit`);M=s(M,1);let N=require(`@mui/icons-material/Download`);N=s(N,1);let P=require(`@mui/icons-material/RestartAlt`);P=s(P,1);let F=require(`@mui/icons-material/Restore`);F=s(F,1);let I=require(`@mui/icons-material/Today`);I=s(I,1);let L=require(`@mui/icons-material/UnfoldLess`);L=s(L,1);let R=require(`@mui/icons-material/UnfoldMore`);R=s(R,1);let z=require(`@mui/icons-material/CheckCircle`);z=s(z,1);let B=require(`@mui/icons-material/Cancel`);B=s(B,1);let V=require(`@mui/icons-material/Visibility`);V=s(V,1);let H=require(`@mui/icons-material/VisibilityOff`);H=s(H,1);let U=require(`@mui/icons-material/Close`);U=s(U,1);let W=require(`@tiptap/react`),G=require(`@tiptap/starter-kit`),K=require(`@tiptap/extension-text-style`),q=require(`@tiptap/extension-color`),J=require(`@tiptap/extension-highlight`),Y=require(`@tiptap/extension-placeholder`),X=require(`@tiptap/extension-character-count`),ee=require(`@tiptap/extension-table`),te=require(`@tiptap/extension-image`),ne=require(`tiptap-markdown`),re=require(`@mui/icons-material/Fullscreen`);re=s(re,1);let ie=require(`@mui/icons-material/FullscreenExit`);ie=s(ie,1);let ae=require(`@mui/icons-material/Image`);ae=s(ae,1);let oe=require(`@mui/icons-material/EmojiEmotions`);oe=s(oe,1);let se=require(`@mui/icons-material/FormatBold`);se=s(se,1);let ce=require(`@mui/icons-material/FormatItalic`);ce=s(ce,1);let le=require(`@mui/icons-material/FormatUnderlined`);le=s(le,1);let ue=require(`@mui/icons-material/StrikethroughS`);ue=s(ue,1);let de=require(`@mui/icons-material/FormatListBulleted`);de=s(de,1);let fe=require(`@mui/icons-material/FormatListNumbered`);fe=s(fe,1);let pe=require(`@mui/icons-material/FormatQuote`);pe=s(pe,1);let me=require(`@mui/icons-material/Code`);me=s(me,1);let he=require(`@mui/icons-material/InsertLink`);he=s(he,1);let ge=require(`@mui/icons-material/HorizontalRule`);ge=s(ge,1);let _e=require(`@mui/icons-material/FormatColorText`);_e=s(_e,1);let ve=require(`@mui/icons-material/BorderColor`);ve=s(ve,1);let ye=require(`@mui/icons-material/FormatClear`);ye=s(ye,1);let be=require(`@mui/icons-material/FormatColorReset`);be=s(be,1);let xe=require(`@mui/icons-material/TableChart`);xe=s(xe,1);let Se=require(`@mui/icons-material/Search`);Se=s(Se,1);let Ce=require(`@codemirror/lang-sql`),we=require(`@codemirror/autocomplete`),Te=require(`@mui/icons-material/PlayArrow`);Te=s(Te,1);let Ee=require(`sql-formatter`),De=require(`@mui/icons-material/History`);De=s(De,1);let Oe=require(`@mui/icons-material/DeleteSweep`);Oe=s(Oe,1);let ke=require(`@mui/icons-material/WarningAmber`);ke=s(ke,1);let Z=require(`d3`);Z=s(Z,1);var Ae={showFormat:!0,showCompact:!0,showCopy:!0,showClear:!0,showUndoRedo:!0},je={format:`Format JSON`,compact:`Compact JSON`,copy:`Copy`,copySuccess:`Copied!`,clear:`Clear`,undo:`Undo`,redo:`Redo`,lineColumn:`Ln {line}, Col {col}`,validJson:`Valid JSON`,invalidJson:`Invalid JSON`};function Me({value:e,onChange:t,placeholder:n,disabled:r=!1,readonly:i=!1,showLineNumbers:a=!0,showMinimap:o=!1,highlightColors:s,onViewReady:y,onCursorChange:b,onBlur:x,onFocus:S}){let C=(0,c.useRef)(null),w=(0,c.useRef)(null),T=(0,c.useRef)(t),E=(0,c.useRef)(b),D=(0,c.useRef)(x),O=(0,c.useRef)(S),k=(0,c.useRef)(y),A=(0,c.useRef)(new d.Compartment),j=(0,c.useRef)(new d.Compartment),M=(0,l.useTheme)(),N=M.palette.mode===`dark`,P=s?.propertyName??M.palette.primary.main,F=s?.string??M.palette.success.main,I=s?.number??M.palette.warning.main,L=s?.boolean??M.palette.info.main,R=s?.null??M.palette.text.secondary;return(0,c.useEffect)(()=>{T.current=t},[t]),(0,c.useEffect)(()=>{E.current=b},[b]),(0,c.useEffect)(()=>{D.current=x},[x]),(0,c.useEffect)(()=>{O.current=S},[S]),(0,c.useEffect)(()=>{k.current=y},[y]),(0,c.useEffect)(()=>{if(!C.current)return;let t=w.current?.state.doc.toString()??e??``,s=m.HighlightStyle.define([{tag:g.tags.propertyName,color:P,fontWeight:`bold`},{tag:g.tags.string,color:F},{tag:g.tags.number,color:I},{tag:g.tags.bool,color:L,fontWeight:`bold`},{tag:g.tags.null,color:R,fontStyle:`italic`},{tag:g.tags.bracket,color:M.palette.text.secondary},{tag:g.tags.punctuation,color:M.palette.text.disabled},{tag:g.tags.invalid,color:M.palette.error.main,textDecoration:`underline wavy`}]),c=u.EditorView.theme({"&":{height:`100%`,fontFamily:`'Fira Code', 'JetBrains Mono', 'Consolas', monospace`,fontSize:`0.875rem`},".cm-scroller":{overflow:`auto`},".cm-content":{padding:`8px 4px`,caretColor:M.palette.text.primary},".cm-gutters":{backgroundColor:N?M.palette.grey[900]:M.palette.grey[50],color:M.palette.text.disabled,border:`none`,borderRight:`1px solid ${M.palette.divider}`},".cm-lineNumbers .cm-gutterElement":{paddingLeft:`4px`,paddingRight:`8px`},".cm-activeLineGutter":{backgroundColor:M.palette.action.selected},".cm-activeLine":{backgroundColor:M.palette.action.hover},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground":{backgroundColor:M.palette.primary.main+`40`},".cm-cursor, .cm-dropCursor":{borderLeftColor:M.palette.text.primary},"&.cm-focused":{outline:`none`},".cm-placeholder":{color:M.palette.text.disabled,fontStyle:`italic`},".cm-gutter-lint":{width:`16px`},".cm-lint-marker-error":{color:M.palette.error.main},".cm-lint-marker-warning":{color:M.palette.warning.main},".cm-tooltip.cm-tooltip-lint":{backgroundColor:M.palette.background.paper,border:`1px solid ${M.palette.divider}`,borderRadius:`4px`},".cm-diagnostic-error":{borderLeft:`3px solid ${M.palette.error.main}`},".cm-diagnostic-warning":{borderLeft:`3px solid ${M.palette.warning.main}`}},{dark:N}),l=o?[_.showMinimap.of({create:()=>{let e=document.createElement(`div`);return e.style.width=`80px`,e.style.overflow=`hidden`,e.style.borderLeft=`1px solid ${M.palette.divider}`,e.style.backgroundColor=N?M.palette.grey[900]:M.palette.grey[50],{dom:e}},displayText:`blocks`,showOverlay:`always`})]:[],v=[c,(0,m.syntaxHighlighting)(s),(0,f.json)(),(0,h.lintGutter)(),(0,h.linter)((0,f.jsonParseLinter)()),(0,p.history)(),u.keymap.of([...p.defaultKeymap,...p.historyKeymap]),A.current.of(u.EditorView.editable.of(!r&&!i)),j.current.of(d.EditorState.readOnly.of(i)),(0,u.highlightActiveLine)(),...a?[(0,u.lineNumbers)(),(0,u.highlightActiveLineGutter)()]:[],...n?[(0,u.placeholder)(n)]:[],...l,u.EditorView.updateListener.of(e=>{e.docChanged&&T.current?.(e.state.doc.toString());let t=e.state.selection.main.head,n=e.state.doc.lineAt(t);E.current(n.number,t-n.from+1)}),u.EditorView.domEventHandlers({blur:()=>{D.current?.()},focus:()=>{O.current?.()}})],y=new u.EditorView({state:d.EditorState.create({doc:t,extensions:v}),parent:C.current});return w.current=y,k.current(y),()=>{k.current(null),y.destroy(),w.current=null}},[N,P,F,I,L,R,o]),(0,c.useEffect)(()=>{let t=w.current;if(!t)return;let n=t.state.doc.toString();n!==(e??``)&&t.dispatch({changes:{from:0,to:n.length,insert:e??``}})},[e]),(0,c.useEffect)(()=>{w.current?.dispatch({effects:[A.current.reconfigure(u.EditorView.editable.of(!r&&!i)),j.current.reconfigure(d.EditorState.readOnly.of(i))]})},[r,i]),(0,v.jsx)(l.Box,{ref:C,sx:{flex:1,overflow:`hidden`,display:`flex`,flexDirection:`column`,opacity:r?.5:1,backgroundColor:M.palette.background.paper,"& .cm-editor":{flex:1,display:`flex`,flexDirection:`column`}}})}function Q({label:e,icon:t,onClick:n,active:r,disabled:i}){return(0,v.jsx)(l.Tooltip,{title:e,arrow:!0,children:(0,v.jsx)(`span`,{children:(0,v.jsx)(l.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 Ne({editorView:e,toolbarConfig:t,translation:n,indent:r,disabled:i}){let[a,o]=(0,c.useState)(!1),s=i||!e;function u(){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 d(){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 f(){let t=e?.state.doc.toString()??``;navigator.clipboard.writeText(t).then(()=>{o(!0),setTimeout(()=>o(!1),2e3)})}function m(){let t=e;t&&(t.dispatch({changes:{from:0,to:t.state.doc.length,insert:``}}),t.focus())}function h(){let t=e;t&&((0,p.undo)(t),t.focus())}function g(){let t=e;t&&((0,p.redo)(t),t.focus())}let _=t.showFormat||t.showCompact,E=t.showCopy||t.showClear,D=t.showUndoRedo;return(0,v.jsxs)(l.Box,{sx:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:.25,px:1,py:.5},role:`toolbar`,"aria-label":`JSON editor actions`,children:[_&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showFormat&&(0,v.jsx)(Q,{label:n.format,icon:(0,v.jsx)(w.default,{fontSize:`small`}),onClick:u,disabled:s}),t.showCompact&&(0,v.jsx)(Q,{label:n.compact,icon:(0,v.jsx)(T.default,{fontSize:`small`}),onClick:d,disabled:s})]}),_&&(E||D)&&(0,v.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),E&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showCopy&&(0,v.jsx)(Q,{label:a?n.copySuccess:n.copy,icon:a?(0,v.jsx)(b.default,{fontSize:`small`,color:`success`}):(0,v.jsx)(y.default,{fontSize:`small`}),onClick:f,disabled:s}),t.showClear&&(0,v.jsx)(Q,{label:n.clear,icon:(0,v.jsx)(x.default,{fontSize:`small`}),onClick:m,disabled:s})]}),E&&D&&(0,v.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),D&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[(0,v.jsx)(Q,{label:n.undo,icon:(0,v.jsx)(S.default,{fontSize:`small`}),onClick:h,disabled:s}),(0,v.jsx)(Q,{label:n.redo,icon:(0,v.jsx)(C.default,{fontSize:`small`}),onClick:g,disabled:s})]}),!_&&!E&&!D&&(0,v.jsx)(l.Box,{sx:{height:32}})]})}function Pe({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,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,mt:.5,px:.5},children:[(0,v.jsxs)(l.Box,{children:[r&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[i?(0,v.jsx)(E.default,{sx:{fontSize:`0.875rem`,color:`success.main`},"data-testid":`json-valid-icon`}):(0,v.jsx)(D.default,{sx:{fontSize:`0.875rem`,color:`error.main`},"data-testid":`json-invalid-icon`}),(0,v.jsx)(l.FormHelperText,{sx:{color:i?`success.main`:`error.main`,m:0},children:i?s.validJson:s.invalidJson})]}),(0,v.jsx)(l.FormHelperText,{error:t,children:e??``})]}),n&&(0,v.jsx)(l.FormHelperText,{sx:{color:`text.disabled`,fontFamily:`monospace`,whiteSpace:`nowrap`},children:c})]})}function Fe(e){if(!(e===``||e===void 0))return typeof e==`string`&&e!==`auto`&&!isNaN(Number(e))?Number(e):e}function Ie(e){if(!e.trim())return!1;try{return JSON.parse(e),!0}catch{return!1}}function Le({value:e,onChange:t,onValidChange:n,placeholder:r,height:i,width:a,disabled:o=!1,readonly:s=!1,error:u=!1,helperText:d,name:f,indent:p=2,showLineNumbers:m=!0,showLineColumn:h=!0,showMinimap:g=!1,showValidation:_=!1,toolbarConfig:y,translation:b,highlightColors:x,onBlur:S,onFocus:C}){let w={...je,...b},T={...Ae,...y},E=Fe(i),D=Fe(a),O=E===`auto`,k=O?void 0:E??300,A=(0,c.useRef)(null),[j,M]=(0,c.useState)(null),[N,P]=(0,c.useState)({line:1,col:1}),[F,I]=(0,c.useState)(()=>Ie(e??``)),L=(0,c.useCallback)(e=>{A.current=e,M(e)},[]),R=(0,c.useCallback)((e,t)=>{P({line:e,col:t})},[]),z=(0,c.useCallback)(e=>{let r=Ie(e);I(r),n?.(r),t?.(e)},[t,n]),B=h||_||!!d;return(0,v.jsxs)(l.Box,{sx:{width:D??`100%`,...O?{display:`flex`,flexDirection:`column`,flex:1}:{}},children:[(0,v.jsxs)(l.Paper,{variant:`outlined`,sx:{display:`flex`,flexDirection:`column`,overflow:`hidden`,...O?{flex:1}:{height:k},borderColor:u?`error.main`:void 0,"&:focus-within":{borderColor:u?`error.main`:`primary.main`,borderWidth:2}},children:[!s&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(Ne,{editorView:j,toolbarConfig:T,translation:w,indent:p,disabled:o}),(0,v.jsx)(l.Divider,{})]}),(0,v.jsx)(Me,{value:e,onChange:z,placeholder:r,disabled:o,readonly:s,showLineNumbers:m,showMinimap:g,highlightColors:x,onViewReady:L,onCursorChange:R,onBlur:S,onFocus:C})]}),B&&(0,v.jsx)(Pe,{helperText:d,error:u,showLineColumn:h,showValidation:_,isValid:F,cursorLine:N.line,cursorCol:N.col,translation:w}),f&&(0,v.jsx)(`input`,{type:`hidden`,name:f,value:e??``})]})}function Re(e){let t=new Date,n=et(t),r=tt(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=We(Ke(new Date(Math.min(...i)),-1)),s=Ge(Ke(new Date(Math.max(...a)),1));return{start:o<n?o:n,end:s>r?s:r}}function ze(e,t){return t===`weeks`?{start:Xe(e.start),end:e.end}:t===`quarters`?{start:et(e.start),end:tt(e.end)}:e}function Be(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 Ve(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 He(n,0),n}function He(e,t){for(let n of e)n.depth=t,He(n.children,t+1)}function Ue(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 We(e){return new Date(e.getFullYear(),e.getMonth(),1,0,0,0,0)}function Ge(e){return new Date(e.getFullYear(),e.getMonth()+1,0,23,59,59,999)}function Ke(e,t){return new Date(e.getFullYear(),e.getMonth()+t,e.getDate())}function qe(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+t,0,0,0,0)}function Je(e,t,n){if(n===0)return e;let r=new Map;for(let t of e)for(let e of t.dependencies??[])r.has(e)||r.set(e,[]),r.get(e).push(t.id);let 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 Ye(e){let t=[],n=We(e.start);for(;n<=e.end;)t.push(n),n=Ke(n,1);return t}function Xe(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 Ze(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 Qe(e){let t=[],n=Xe(e.start);for(;n<=e.end;)t.push(new Date(n)),n=new Date(n.getFullYear(),n.getMonth(),n.getDate()+7);return t}function $e(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 et(e){let t=Math.floor(e.getMonth()/3)*3;return new Date(e.getFullYear(),t,1,0,0,0,0)}function tt(e){let t=Math.floor(e.getMonth()/3)*3+2;return Ge(new Date(e.getFullYear(),t,1))}function nt(e){let t=[],n=et(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 rt(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 it(e,t){let n=t.startDate<e.start?We(Ke(t.startDate,-1)):e.start,r=t.endDate>e.end?Ge(Ke(t.endDate,1)):e.end;return n===e.start&&r===e.end?e:{start:n,end:r}}function at(e,t=`months`,n=!1,r,i=!1){let a=Re(e);return(0,k.createStore)((o,s)=>({tasks:e,taskTree:Ve(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,setTasks:e=>{o(t=>({tasks:e,taskTree:Ve(e),...t.isRangeCustomized?{}:{timelineRange:Re(e)}}))},addTask:e=>{o(t=>{let n=[...t.tasks,e];return{tasks:n,taskTree:Ve(n),timelineRange:it(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=Je(r,e.id,t)}let i=it(t.timelineRange,e);for(let e of r)i=it(i,e);return{tasks:r,taskTree:Ve(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:Ve(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:Re(e.tasks),isRangeCustomized:!1}))},resetView:()=>{o(e=>({timeScale:e.defaultTimeScale,timelineRange:Re(e.tasks),isRangeCustomized:!1,isExpandedCustomized:!1,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 Ue(e,t)}}))}var ot={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 —`,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`},st={planned:`warning.light`,"in-progress":`info.main`,done:`success.main`,blocked:`error.main`},ct={planned:`warning`,"in-progress":`info`,done:`success`,blocked:`error`};function lt(e){return e.toISOString().slice(0,10)}function ut(e,t,n){return e<t?t:e>n?n:e}function dt(e){return e.flatMap(e=>[e,...dt(e.children)])}function ft({label:e}){let t=(0,c.useRef)(null),[n,r]=(0,c.useState)(!1);return(0,v.jsx)(l.Tooltip,{title:e,disableHoverListener:!n,children:(0,v.jsx)(l.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 pt({open:e,mode:t,initialTask:n,defaultParentId:r,onSave:i,onClose:a}){let o=Lt(),s=$(e=>e.taskTree),u=$(e=>e.timelineRange),d=(0,c.useMemo)(()=>dt(s),[s]),f=(0,c.useMemo)(()=>{if(t===`add`||!n)return new Set;let e=t=>[t.id,...t.children.flatMap(e)],r=d.find(e=>e.id===n.id);return new Set(r?e(r):[n.id])},[t,n,d]),p=d.filter(e=>!f.has(e.id)),m=p,h=lt(ut(new Date,u.start,u.end)),[g,_]=(0,c.useState)({name:``,startDate:h,endDate:h,status:`planned`,isMilestone:!1,parentId:``,dependencies:[],assignee:``});(0,c.useEffect)(()=>{if(!e)return;let i=lt(ut(new Date,u.start,u.end));_(t===`edit`&&n?{name:n.name,startDate:lt(n.startDate),endDate:lt(n.endDate),status:n.status,isMilestone:n.isMilestone??!1,parentId:n.parentId??``,dependencies:n.dependencies??[],assignee:n.assignee??``}:{name:``,startDate:i,endDate:i,status:`planned`,isMilestone:!1,parentId:r??``,dependencies:[],assignee:``})},[e,t,n,r,u]);let y=e=>{_(t=>({...t,startDate:e,endDate:t.isMilestone||t.endDate<e?e:t.endDate}))},b=e=>{_(t=>({...t,endDate:e<t.startDate?t.startDate:e}))},x=e=>{_(t=>({...t,isMilestone:e,endDate:e?t.startDate:t.endDate}))},S=g.name.trim()!==``&&g.startDate!==``&&g.endDate!==``&&g.endDate>=g.startDate,C=()=>{S&&i({name:g.name.trim(),startDate:new Date(g.startDate),endDate:new Date(g.endDate),status:g.status,isMilestone:g.isMilestone||void 0,parentId:g.parentId||void 0,dependencies:g.dependencies.length>0?g.dependencies:void 0,assignee:g.assignee.trim()||void 0})},w=[`planned`,`in-progress`,`done`,`blocked`],T={planned:o.statusPlanned,"in-progress":o.statusInProgress,done:o.statusDone,blocked:o.statusBlocked};return(0,v.jsxs)(l.Dialog,{open:e,onClose:a,maxWidth:`xs`,fullWidth:!0,"data-testid":`gantt-task-dialog`,children:[(0,v.jsx)(l.DialogTitle,{children:t===`add`?o.dialogAddTitle:o.dialogEditTitle}),(0,v.jsxs)(l.DialogContent,{sx:{display:`flex`,flexDirection:`column`,gap:2,pt:`16px !important`},children:[(0,v.jsx)(l.TextField,{label:o.dialogFieldName,value:g.name,onChange:e=>_(t=>({...t,name:e.target.value})),required:!0,fullWidth:!0,size:`small`,autoFocus:!0,slotProps:{htmlInput:{"data-testid":`gantt-dialog-field-name`}}}),(0,v.jsx)(l.TextField,{label:o.columnAssignee,value:g.assignee,onChange:e=>_(t=>({...t,assignee:e.target.value})),fullWidth:!0,size:`small`,placeholder:`e.g. Jane Smith`,slotProps:{htmlInput:{"data-testid":`gantt-dialog-field-assignee`}}}),(0,v.jsx)(l.TextField,{label:o.dialogFieldStartDate,type:`date`,value:g.startDate,onChange:e=>y(e.target.value),required:!0,fullWidth:!0,size:`small`,slotProps:{inputLabel:{shrink:!0},htmlInput:{"data-testid":`gantt-dialog-field-start`}}}),(0,v.jsx)(l.TextField,{label:o.dialogFieldEndDate,type:`date`,value:g.endDate,onChange:e=>b(e.target.value),required:!0,fullWidth:!0,size:`small`,disabled:g.isMilestone,slotProps:{inputLabel:{shrink:!0},htmlInput:{"data-testid":`gantt-dialog-field-end`,min:g.startDate}}}),(0,v.jsxs)(l.FormControl,{size:`small`,fullWidth:!0,children:[(0,v.jsx)(l.InputLabel,{children:o.dialogFieldStatus}),(0,v.jsx)(l.Select,{value:g.status,label:o.dialogFieldStatus,onChange:e=>_(t=>({...t,status:e.target.value})),inputProps:{"data-testid":`gantt-dialog-field-status`},children:w.map(e=>(0,v.jsx)(l.MenuItem,{value:e,children:T[e]},e))})]}),(0,v.jsx)(l.FormControlLabel,{control:(0,v.jsx)(l.Checkbox,{checked:g.isMilestone,onChange:e=>x(e.target.checked),size:`small`,"data-testid":`gantt-dialog-field-milestone`}),label:o.dialogFieldMilestone}),(0,v.jsxs)(l.FormControl,{size:`small`,fullWidth:!0,children:[(0,v.jsx)(l.InputLabel,{children:o.dialogFieldParent}),(0,v.jsxs)(l.Select,{value:g.parentId,label:o.dialogFieldParent,onChange:e=>_(t=>({...t,parentId:e.target.value})),inputProps:{"data-testid":`gantt-dialog-field-parent`},MenuProps:{slotProps:{paper:{sx:{maxHeight:280}}}},children:[(0,v.jsx)(l.MenuItem,{value:``,children:o.dialogFieldParentNone}),p.map(e=>(0,v.jsx)(l.MenuItem,{value:e.id,sx:{minWidth:0},children:(0,v.jsxs)(l.Box,{sx:{display:`flex`,alignItems:`center`,pl:e.depth*2,gap:.75,minWidth:0,width:`100%`,overflow:`hidden`},children:[e.depth>0&&(0,v.jsx)(l.Typography,{component:`span`,variant:`caption`,sx:{color:`text.disabled`,lineHeight:1,flexShrink:0},children:`└`}),(0,v.jsx)(ft,{label:e.name})]})},e.id))]})]}),(0,v.jsxs)(l.FormControl,{size:`small`,fullWidth:!0,children:[(0,v.jsx)(l.InputLabel,{children:o.dialogFieldDependencies}),(0,v.jsx)(l.Select,{multiple:!0,value:g.dependencies,label:o.dialogFieldDependencies,onChange:e=>{let t=e.target.value;_(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=>d.find(t=>t.id===e)?.name??e).join(`, `),MenuProps:{slotProps:{paper:{sx:{maxHeight:280}}}},children:m.map(e=>(0,v.jsx)(l.MenuItem,{value:e.id,sx:{minWidth:0},children:(0,v.jsxs)(l.Box,{sx:{display:`flex`,alignItems:`center`,pl:e.depth*2,gap:.75,minWidth:0,width:`100%`,overflow:`hidden`},children:[e.depth>0&&(0,v.jsx)(l.Typography,{component:`span`,variant:`caption`,sx:{color:`text.disabled`,lineHeight:1,flexShrink:0},children:`└`}),(0,v.jsx)(ft,{label:e.name})]})},e.id))})]})]}),(0,v.jsxs)(l.DialogActions,{children:[(0,v.jsx)(l.Button,{onClick:a,children:o.dialogCancel}),(0,v.jsx)(l.Button,{onClick:C,variant:`contained`,disabled:!S,"data-testid":`gantt-dialog-save`,children:o.dialogSave})]})]})}function mt({open:e,task:t,onConfirm:n,onClose:r}){let i=Lt(),a=i.dialogDeleteConfirm.replace(`{name}`,t?.name??``);return(0,v.jsxs)(l.Dialog,{open:e,onClose:r,maxWidth:`xs`,fullWidth:!0,"data-testid":`gantt-delete-dialog`,children:[(0,v.jsx)(l.DialogTitle,{children:i.dialogDeleteTitle}),(0,v.jsx)(l.DialogContent,{children:(0,v.jsx)(l.DialogContentText,{children:a})}),(0,v.jsxs)(l.DialogActions,{children:[(0,v.jsx)(l.Button,{onClick:r,children:i.dialogCancel}),(0,v.jsx)(l.Button,{onClick:n,variant:`contained`,color:`error`,"data-testid":`gantt-dialog-delete-confirm`,children:i.dialogDelete})]})]})}function ht(e,t){return{planned:t.statusPlanned,"in-progress":t.statusInProgress,done:t.statusDone,blocked:t.statusBlocked}[e]}function gt({task:e,expandedIds:t,toggleExpand:n,hasActionsColumn:r,showAssigneeColumn:i,onTaskClick:a,onAddTask:o,onEditTask:s,onDeleteTask:u,onStatusChange:d,inlineEdit:f,onInlineRename:p}){let[m,h]=(0,c.useState)(null),[g,_]=(0,c.useState)(null),y=Lt(),{statusColors:b}=zt(),S=()=>{g!==null&&g.trim()&&p?.(e,g.trim()),_(null)};return(0,v.jsxs)(l.Box,{className:`gantt-task-row`,"data-testid":`gantt-task-row-${e.id}`,sx:{height:40,display:`flex`,alignItems:`center`,borderBottom:`1px solid`,borderRight:`1px solid`,borderColor:`divider`,cursor:a?`pointer`:`default`,"&:hover":a?{bgcolor:`action.hover`}:void 0},onClick:()=>a?.(e),children:[(0,v.jsxs)(l.Box,{sx:{flex:1,minWidth:0,display:`flex`,alignItems:`center`,gap:.75,pl:1+e.depth*2,pr:.5,height:`100%`},children:[(0,v.jsx)(l.Box,{sx:{width:16,flexShrink:0,display:`flex`,justifyContent:`center`},children:e.children.length>0&&(0,v.jsx)(l.Box,{component:`span`,sx:{fontSize:9,userSelect:`none`,cursor:`pointer`},onClick:t=>{t.stopPropagation(),n(e.id)},children:t.has(e.id)?`▼`:`▶`})}),(0,v.jsx)(l.Box,{sx:{width:8,height:8,borderRadius:e.isMilestone?0:`50%`,transform:e.isMilestone?`rotate(45deg)`:void 0,flexShrink:0,bgcolor:e.color??b?.[e.status]??st[e.status]??`grey.400`}}),g===null?(0,v.jsx)(l.Typography,{variant:`body2`,noWrap:!0,sx:{flex:1,minWidth:0,cursor:f?`text`:`inherit`},onDoubleClick:f?t=>{t.stopPropagation(),_(e.name)}:void 0,children:e.name}):(0,v.jsx)(l.TextField,{size:`small`,variant:`standard`,value:g,autoFocus:!0,onChange:e=>_(e.target.value),onBlur:S,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),S()),e.key===`Escape`&&(e.stopPropagation(),_(null))},onClick:e=>e.stopPropagation(),sx:{flex:1,minWidth:0},slotProps:{htmlInput:{"data-testid":`gantt-inline-edit-${e.id}`}}})]}),i&&(0,v.jsx)(l.Box,{sx:{width:110,flexShrink:0,display:`flex`,alignItems:`center`,px:1,overflow:`hidden`},children:(0,v.jsx)(l.Typography,{variant:`caption`,noWrap:!0,color:e.assignee?`text.primary`:`text.disabled`,children:e.assignee??`—`})}),r&&(0,v.jsxs)(l.Box,{className:`gantt-row-actions`,sx:{width:96,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`flex-end`,pr:.5},children:[s&&(0,v.jsx)(l.Tooltip,{title:y.editTaskTooltip,children:(0,v.jsx)(l.IconButton,{size:`small`,"aria-label":y.editTaskTooltip,"data-testid":`gantt-edit-task-${e.id}`,onClick:t=>{t.stopPropagation(),s(e)},children:(0,v.jsx)(M.default,{fontSize:`inherit`})})}),o&&(0,v.jsx)(l.Tooltip,{title:y.addTaskTooltip,children:(0,v.jsx)(l.IconButton,{size:`small`,"aria-label":y.addTaskTooltip,"data-testid":`gantt-add-task-${e.id}`,onClick:t=>{t.stopPropagation(),o(e)},children:(0,v.jsx)(j.default,{fontSize:`inherit`})})}),u&&(0,v.jsx)(l.Tooltip,{title:y.deleteTaskTooltip,children:(0,v.jsx)(l.IconButton,{size:`small`,"aria-label":y.deleteTaskTooltip,"data-testid":`gantt-delete-task-${e.id}`,onClick:t=>{t.stopPropagation(),u(e)},children:(0,v.jsx)(x.default,{fontSize:`inherit`})})})]}),(0,v.jsxs)(l.Box,{sx:{width:90,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`},children:[(0,v.jsx)(l.Chip,{label:ht(e.status,y),size:`small`,variant:`outlined`,color:e.color??b?.[e.status]?`default`:ct[e.status]??`default`,sx:{height:20,fontSize:10,cursor:d?`pointer`:`default`,...(e.color??b?.[e.status])&&{borderColor:e.color??b?.[e.status],color:e.color??b?.[e.status]}},onClick:d?e=>{e.stopPropagation(),h(e.currentTarget)}:void 0}),d&&(0,v.jsx)(l.Menu,{anchorEl:m,open:!!m,onClose:()=>h(null),children:[`planned`,`in-progress`,`done`,`blocked`].map(t=>(0,v.jsx)(l.MenuItem,{selected:e.status===t,onClick:()=>{d(e,t),h(null)},children:ht(t,y)},t))})]})]})}function _t({scrollRef:e,onScroll:t,panelWidth:n,onTaskClick:r,onAddTask:i,onEditTask:a,onDeleteTask:o,onStatusChange:s,onTasksChange:u,enableBuiltinDialogs:d,onTaskCreated:f,onTaskUpdated:p,onTaskDeleted:m,inlineEdit:h,virtualizeRows:g=!1,showAssigneeColumn:_=!1}){let y=Lt(),b=Ft(),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=(0,c.useMemo)(()=>Ue(x,S),[x,S]),k=(0,A.useVirtualizer)({count:O.length,getScrollElement:()=>e.current,estimateSize:()=>40,overscan:5}),[j,M]=(0,c.useState)(!1),[N,P]=(0,c.useState)(!1),[F,I]=(0,c.useState)(!1),[L,R]=(0,c.useState)(null),z=e=>{let t={...e,id:crypto.randomUUID()};T(t),u?.(b.getState().tasks),f?.(t),M(!1)},B=e=>{if(!L)return;let t={...e,id:L.id};E(t),u?.(b.getState().tasks),p?.(t),P(!1)},V=()=>{L&&(D(L.id),u?.(b.getState().tasks),m?.(L.id),I(!1))},H=(e,t)=>{let n={...e,name:t};E(n),u?.(b.getState().tasks),p?.(n)},U=d?e=>{R(e),M(!0)}:i,W=d?e=>{R(e),P(!0)}:a,G=d?e=>{R(e),I(!0)}:o,K=!!(U||W||G),q=w===`days`?80:40;return(0,v.jsxs)(l.Box,{ref:e,onScroll:t,sx:{width:n,flexShrink:0,overflowY:`auto`,overflowX:`hidden`},children:[(0,v.jsxs)(l.Box,{sx:{height:q,position:`sticky`,top:0,bgcolor:`background.paper`,zIndex:1,borderBottom:`1px solid`,borderRight:`1px solid`,borderColor:`divider`,display:`flex`,flexDirection:`column`},children:[(0,v.jsxs)(l.Box,{sx:{height:40,display:`flex`,alignItems:`center`,borderBottom:w===`days`?`1px solid`:void 0,borderColor:w===`days`?`divider`:void 0},children:[(0,v.jsx)(l.Box,{sx:{flex:1,minWidth:0,pl:2},children:(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:y.columnName})}),_&&(0,v.jsx)(l.Box,{sx:{width:110,flexShrink:0,display:`flex`,alignItems:`center`,px:1},children:(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:y.columnAssignee})}),K&&(0,v.jsx)(l.Box,{sx:{width:96,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:y.columnActions})}),(0,v.jsx)(l.Box,{sx:{width:90,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:y.columnStatus})})]}),w===`days`&&(0,v.jsx)(l.Box,{sx:{flex:1}})]}),g?(0,v.jsx)(l.Box,{sx:{position:`relative`,height:k.getTotalSize()},children:k.getVirtualItems().map(e=>(0,v.jsx)(l.Box,{style:{position:`absolute`,top:0,left:0,width:`100%`,height:40,transform:`translateY(${e.start}px)`},children:(0,v.jsx)(gt,{task:O[e.index],expandedIds:S,toggleExpand:C,hasActionsColumn:K,showAssigneeColumn:_,onTaskClick:r,onAddTask:U,onEditTask:W,onDeleteTask:G,onStatusChange:s,inlineEdit:h,onInlineRename:h?H:void 0})},e.key))}):O.map(e=>(0,v.jsx)(gt,{task:e,expandedIds:S,toggleExpand:C,hasActionsColumn:K,showAssigneeColumn:_,onTaskClick:r,onAddTask:U,onEditTask:W,onDeleteTask:G,onStatusChange:s,inlineEdit:h,onInlineRename:h?H:void 0},e.id)),d&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(pt,{open:j,mode:`add`,defaultParentId:L?.id,onSave:z,onClose:()=>M(!1)}),(0,v.jsx)(pt,{open:N,mode:`edit`,initialTask:L??void 0,onSave:B,onClose:()=>P(!1)}),(0,v.jsx)(mt,{open:F,task:L,onConfirm:V,onClose:()=>I(!1)})]})]})}var vt=864e5;function yt({totalWidth:e,displayRange:t,onTaskMoved:n,onTaskResized:r,onTasksChange:i}){let a=$(e=>e.updateTask),o=Ft(),s=Lt(),l=(0,c.useRef)(1),u=(0,c.useRef)(n),d=(0,c.useRef)(r),f=(0,c.useRef)(i);(0,c.useLayoutEffect)(()=>{l.current=e>0?e/((t.end.getTime()-t.start.getTime())/vt):1,u.current=n,d.current=r,f.current=i});let p=(0,c.useRef)(null),m=(0,c.useRef)(null),[h,g]=(0,c.useState)(null),_=(0,c.useRef)(!1);return{activeDrag:h,suppressClickRef:_,handleBarMouseDown:(e,t,n)=>{e.stopPropagation(),_.current=!1,p.current={type:n,taskId:t.id,startX:e.clientX,originalStart:t.startDate,originalEnd:t.endDate},document.body.style.cursor=n===`resize`?`ew-resize`:`grabbing`;let r=e=>{let t=p.current;if(!t||t.type===`progress`)return;let n=e.clientX-t.startX,r=Math.round(n/l.current);Math.abs(n)>=5&&(_.current=!0);let i={taskId:t.taskId,type:t.type,deltaDays:r};m.current=i,g(i)},i=()=>{document.body.style.cursor=``;let e=p.current,t=m.current;if(e&&t&&_.current&&t.deltaDays!==0){let n=o.getState().tasks.find(t=>t.id===e.taskId);if(n){if(t.type===`move`){let r=qe(e.originalStart,t.deltaDays),i=qe(e.originalEnd,t.deltaDays);a({...n,startDate:r,endDate:i}),u.current?.(n,r,i)}else{let r=qe(e.originalEnd,t.deltaDays),i=r>e.originalStart?r:qe(e.originalStart,1);a({...n,endDate:i}),d.current?.(n,i)}f.current?.(o.getState().tasks)}}p.current=null,m.current=null,g(null),document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i)};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i)},handleProgressMouseDown:(e,t,n,r)=>{e.stopPropagation(),_.current=!1,p.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=p.current;if(!t||t.type!==`progress`)return;let n=e.clientX-t.startX;Math.abs(n)>=5&&(_.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};m.current=a,g(a)},s=()=>{document.body.style.cursor=``;let e=p.current,t=m.current;if(e&&t&&t.type===`progress`&&t.newProgress!==void 0&&_.current){let n=o.getState().tasks.find(t=>t.id===e.taskId);n&&(a({...n,progress:t.newProgress}),f.current?.(o.getState().tasks))}p.current=null,m.current=null,g(null),document.removeEventListener(`mousemove`,i),document.removeEventListener(`mouseup`,s)};document.addEventListener(`mousemove`,i),document.addEventListener(`mouseup`,s)},formatDragDate:e=>e.toLocaleDateString(s.dateLocale,{day:`2-digit`,month:`short`})}}function bt({items:e}){return(0,v.jsx)(l.Box,{sx:{display:`flex`},children:e.map(e=>(0,v.jsx)(l.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,v.jsx)(l.Typography,{variant:`caption`,color:e.isWeekend?`text.disabled`:`text.secondary`,children:e.label})},e.key))})}function xt({columns:e,groups:t,todayX:n,todayLabel:r,todayTooltip:i,todayColor:a}){let o=(0,l.useTheme)(),s=t?80:40,c=a||o.palette.primary.main,u=o.palette.getContrastText(c);return(0,v.jsxs)(l.Box,{sx:{position:`sticky`,top:0,bgcolor:`background.paper`,zIndex:1,borderBottom:`1px solid`,borderColor:`divider`,height:s,overflow:`visible`},children:[t&&(0,v.jsx)(l.Box,{sx:{height:40,borderBottom:`1px solid`,borderColor:`divider`,overflow:`visible`},children:(0,v.jsx)(bt,{items:t})}),(0,v.jsx)(bt,{items:e}),n!=null&&r&&(0,v.jsx)(l.Tooltip,{title:i??``,placement:`top`,arrow:!0,children:(0,v.jsx)(l.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:u,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 St({task:e,virtualTop:t,activeDrag:n,displayRange:r,totalWidth:i,gridColumnWidth:a,criticalTaskIds:o,draggable:s=!1,resizable:c=!1,progressDraggable:u=!1,onTaskClick:d,onMilestoneClick:f,onContextMenu:p,suppressClickRef:m,handleBarMouseDown:h,handleProgressMouseDown:g,formatDragDate:_}){let y=(0,l.useTheme)(),{statusColors:b,criticalPathColor:x,milestoneColor:S,barBorderRadius:C}=zt(),w=n?.taskId===e.id,T=e;if(w&&n)if(n.type===`move`)T={...e,startDate:qe(e.startDate,n.deltaDays),endDate:qe(e.endDate,n.deltaDays)};else if(n.type===`resize`){let t=qe(e.endDate,n.deltaDays);T={...e,endDate:t>e.startDate?t:qe(e.startDate,1)}}else n.type===`progress`&&n.newProgress!==void 0&&(T={...e,progress:n.newProgress});let{left:E,width:D}=Be(T,r);return(0,v.jsx)(l.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,v.jsx)(Ct,{task:e,left:E,milestoneColor:S,criticalPathColor:x,isCritical:o.has(e.id),onMilestoneClick:f,theme:y}):(0,v.jsx)(wt,{task:e,effectiveTask:T,left:E,width:D,totalWidth:i,isDragging:w,activeDrag:n,draggable:s,resizable:c,progressDraggable:u,isCritical:o.has(e.id),statusColors:b,criticalPathColor:x,barBorderRadius:C,onTaskClick:d,onContextMenu:p,suppressClickRef:m,handleBarMouseDown:h,handleProgressMouseDown:g,formatDragDate:_,theme:y})})}function Ct({task:e,left:t,milestoneColor:n,criticalPathColor:r,isCritical:i,onMilestoneClick:a,theme:o}){return t<0||t>100?null:(0,v.jsx)(l.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 wt({task:e,effectiveTask:t,left:n,width:r,totalWidth:i,isDragging:a,activeDrag:o,draggable:s,resizable:c,progressDraggable:u,isCritical:d,statusColors:f,criticalPathColor:p,barBorderRadius:m,onTaskClick:h,onContextMenu:g,suppressClickRef:_,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,v.jsxs)(v.Fragment,{children:[a&&o&&o.type!==`progress`&&o.deltaDays!==0&&(0,v.jsx)(Tt,{left:C,children:o.type===`move`?`${x(t.startDate)} – ${x(t.endDate)}`:`→ ${x(t.endDate)}`}),a&&o?.type===`progress`&&o.newProgress!==void 0&&(0,v.jsxs)(Tt,{left:C,children:[o.newProgress,`%`]}),(0,v.jsxs)(l.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]??st[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(),g(e,t.clientX,t.clientY)},onClick:()=>{if(_.current){_.current=!1;return}h?.(e)},children:[t.progress!==void 0&&t.progress>0&&(0,v.jsx)(l.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}}),u&&(0,v.jsx)(l.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,v.jsx)(l.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 Tt({left:e,children:t}){return(0,v.jsx)(l.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 Et({strips:e,totalWidth:t,height:n,top:r}){let{weekendColor:i}=zt();return e.length===0?null:(0,v.jsx)(l.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,v.jsx)(l.Box,{sx:{position:`absolute`,left:e.left,width:20,top:0,height:`100%`,bgcolor:i||`action.hover`}},e.key))})}function Dt({contextMenu:e,onClose:t,onSelect:n}){let r=Lt(),i={planned:r.statusPlanned,"in-progress":r.statusInProgress,done:r.statusDone,blocked:r.statusBlocked};return(0,v.jsx)(l.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,v.jsx)(l.MenuItem,{selected:e?.task.status===t,"data-testid":`gantt-status-menu-${t}`,onClick:()=>{e&&n(e.task,t)},children:i[t]},t))})}function Ot({dependencyLines:e,todayX:t,totalWidth:n,height:r,top:i,arrowMarkerId:a}){let o=(0,l.useTheme)(),{todayLineColor:s}=zt();return e.length===0&&t===null?null:(0,v.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,v.jsx)(`defs`,{children:(0,v.jsx)(`marker`,{id:a,markerWidth:`6`,markerHeight:`4`,refX:`5`,refY:`2`,orient:`auto`,children:(0,v.jsx)(`polygon`,{points:`0 0, 6 2, 0 4`,fill:`currentColor`})})}),e.map(e=>(0,v.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,v.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 kt(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=Be(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=Be(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 At({scrollRef:e,onScroll:t,onTaskClick:n,onMilestoneClick:r,draggable:i=!1,resizable:a=!1,progressDraggable:o=!1,showCriticalPath:s=!1,virtualizeRows:u=!1,onTaskMoved:d,onTaskResized:f,onTasksChange:p,onStatusChange:m}){let h=$(e=>e.taskTree),g=$(e=>e.tasks),_=$(e=>e.expandedIds),y=$(e=>e.timelineRange),b=$(e=>e.timeScale),x=$(e=>e.updateTask),S=Ft(),C=Lt(),w=(0,l.useTheme)(),{todayLineColor:T}=zt(),E=`gantt-arrow-${(0,c.useId)().replace(/:/g,``)}`,D=(0,c.useMemo)(()=>Ue(h,_),[h,_]),O=(0,c.useMemo)(()=>ze(y,b),[y,b]),k=(0,c.useMemo)(()=>b===`days`?$e(O).map(e=>({key:e.toISOString(),label:String(e.getDate()),width:20,isWeekend:e.getDay()===0||e.getDay()===6})):b===`weeks`?Qe(O).map(e=>({key:e.toISOString(),label:`${C.weekColumnPrefix}${Ze(e)}`,width:40})):b===`quarters`?nt(O).map(e=>({key:e.key,label:e.label,width:360})):Ye(O).map(e=>({key:e.toISOString(),label:e.toLocaleString(C.dateLocale,{month:`short`,year:`2-digit`}),width:120})),[b,O,C.weekColumnPrefix,C.dateLocale]),j=(0,c.useMemo)(()=>k.reduce((e,t)=>e+t.width,0),[k]),M=(0,c.useMemo)(()=>{if(b!==`days`)return;let e=new Map;for(let t of k){let n=new Date(t.key),r=`${n.getFullYear()}-${n.getMonth()}`;e.has(r)||e.set(r,{label:n.toLocaleString(C.dateLocale,{month:`short`,year:`2-digit`}),width:0}),e.get(r).width+=20}return Array.from(e.entries()).map(([e,t])=>({key:e,...t}))},[b,k,C.dateLocale]),N=(0,c.useMemo)(()=>kt(D,O,j),[D,O,j]),P=(0,c.useMemo)(()=>s?rt(g):new Set,[s,g]),F=(0,A.useVirtualizer)({count:D.length,getScrollElement:()=>e.current,estimateSize:()=>40,overscan:5}),I=(0,c.useMemo)(()=>{if(b!==`days`)return[];let e=0;return k.flatMap(t=>{let n=t.isWeekend?[{key:t.key,left:e}]:[];return e+=t.width,n})},[b,k]),L=(0,c.useMemo)(()=>{let e=Date.now(),t=O.start.getTime(),n=O.end.getTime();return e<t||e>n?null:(e-t)/(n-t)*j},[O,j]),R=(0,c.useMemo)(()=>new Date().toLocaleDateString(C.dateLocale,{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`}),[C.dateLocale]),z=T||w.palette.primary.main;(0,c.useEffect)(()=>{if(L===null||!e.current)return;let t=e.current.clientWidth;e.current.scrollLeft=Math.max(0,L-t/2)},[]);let B=b===`days`?20:b===`weeks`?40:b===`quarters`?360:120,V=M?80:40,{activeDrag:H,suppressClickRef:U,handleBarMouseDown:W,handleProgressMouseDown:G,formatDragDate:K}=yt({totalWidth:j,displayRange:O,onTaskMoved:d,onTaskResized:f,onTasksChange:p}),[q,J]=(0,c.useState)(null),Y=(0,c.useRef)(m);Y.current=m;let X=(0,c.useRef)(p);return X.current=p,(0,v.jsx)(l.Box,{ref:e,onScroll:t,"data-testid":`gantt-timeline-scroll`,sx:{flex:1,overflow:`auto`},children:(0,v.jsxs)(l.Box,{sx:{minWidth:j,position:`relative`},children:[(0,v.jsx)(xt,{columns:k,groups:M,todayX:L,todayLabel:C.todayLabel,todayTooltip:R,todayColor:z}),(0,v.jsx)(Et,{strips:I,totalWidth:j,height:D.length*40,top:V}),u?(0,v.jsx)(l.Box,{sx:{position:`relative`,height:F.getTotalSize()},children:F.getVirtualItems().map(e=>(0,v.jsx)(St,{task:D[e.index],virtualTop:e.start,activeDrag:H,displayRange:O,totalWidth:j,gridColumnWidth:B,criticalTaskIds:P,draggable:i,resizable:a,progressDraggable:o,onTaskClick:n,onMilestoneClick:r,onContextMenu:(e,t,n)=>J({task:e,mouseX:t,mouseY:n}),suppressClickRef:U,handleBarMouseDown:W,handleProgressMouseDown:G,formatDragDate:K},e.key))}):(0,v.jsx)(v.Fragment,{children:D.map(e=>(0,v.jsx)(St,{task:e,activeDrag:H,displayRange:O,totalWidth:j,gridColumnWidth:B,criticalTaskIds:P,draggable:i,resizable:a,progressDraggable:o,onTaskClick:n,onMilestoneClick:r,onContextMenu:(e,t,n)=>J({task:e,mouseX:t,mouseY:n}),suppressClickRef:U,handleBarMouseDown:W,handleProgressMouseDown:G,formatDragDate:K},e.id))}),(0,v.jsx)(Dt,{contextMenu:q,onClose:()=>J(null),onSelect:(e,t)=>{let n=S.getState().tasks.find(t=>t.id===e.id)??e;x({...n,status:t}),Y.current?.(n,t),X.current?.(S.getState().tasks),J(null)}}),(0,v.jsx)(Ot,{dependencyLines:N,todayX:L,totalWidth:j,height:D.length*40,top:V,arrowMarkerId:E})]})})}function jt(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function Mt(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 Nt({onScrollToToday:e,config:t,onExportCSV:n}){let r=Lt(),i=$(e=>e.timeScale),a=$(e=>e.defaultTimeScale),o=$(e=>e.setTimeScale),s=$(e=>e.timelineRange),u=$(e=>e.isRangeCustomized),d=$(e=>e.isExpandedCustomized),f=$(e=>e.setTimelineRange),p=$(e=>e.resetTimelineRange),m=$(e=>e.resetView),h=$(e=>e.tasks),g=$(e=>e.expandedIds),_=$(e=>e.expandAll),y=$(e=>e.collapseAll),b=h.length>0&&h.every(e=>g.has(e.id)),x=i!==a||u||d,S=(0,c.useMemo)(()=>Date.now(),[]),C=S>=s.start.getTime()&&S<=s.end.getTime(),w={days:r.scaleDays,weeks:r.scaleWeeks,months:r.scaleMonths,quarters:r.scaleQuarters},T={days:t.showScaleDays,weeks:t.showScaleWeeks,months:t.showScaleMonths,quarters:t.showScaleQuarters},E=Object.keys(w).filter(e=>T[e]);return(0,v.jsxs)(l.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:[E.length>0&&(0,v.jsx)(l.ToggleButtonGroup,{value:i,exclusive:!0,onChange:(e,t)=>{t&&o(t)},size:`small`,"aria-label":r.scaleMonths,children:E.map(e=>(0,v.jsx)(l.ToggleButton,{value:e,"data-testid":`gantt-scale-${e}`,children:w[e]},e))}),(0,v.jsxs)(l.Box,{sx:{ml:`auto`,display:`flex`,alignItems:`center`,gap:1},children:[t.showExpandCollapseAll&&(0,v.jsx)(l.Tooltip,{title:b?r.collapseAllTooltip:r.expandAllTooltip,children:(0,v.jsx)(l.IconButton,{size:`small`,onClick:b?y:_,"aria-label":b?r.collapseAllTooltip:r.expandAllTooltip,"data-testid":`gantt-expand-collapse-all`,children:b?(0,v.jsx)(L.default,{fontSize:`small`}):(0,v.jsx)(R.default,{fontSize:`small`})})}),t.showScrollToToday&&e&&(0,v.jsx)(l.Tooltip,{title:r.scrollToTodayTooltip,children:(0,v.jsx)(`span`,{children:(0,v.jsx)(l.IconButton,{size:`small`,onClick:e,disabled:!C,"aria-label":r.scrollToTodayTooltip,"data-testid":`gantt-scroll-to-today`,children:(0,v.jsx)(I.default,{fontSize:`small`})})})}),t.showDateRange&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(l.TextField,{type:`date`,size:`small`,label:r.rangeFrom,value:jt(s.start),onChange:e=>{let t=Mt(e.target.value);t&&f({start:t,end:s.end})},slotProps:{inputLabel:{shrink:!0},htmlInput:{"data-testid":`gantt-range-start`}},sx:{width:148}}),(0,v.jsx)(l.TextField,{type:`date`,size:`small`,label:r.rangeTo,value:jt(s.end),onChange:e=>{let t=Mt(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&&u&&(0,v.jsx)(l.Tooltip,{title:r.rangeResetTooltip,children:(0,v.jsx)(l.IconButton,{size:`small`,onClick:p,"aria-label":r.rangeResetTooltip,"data-testid":`gantt-range-reset`,children:(0,v.jsx)(F.default,{fontSize:`small`})})}),t.showExportCSV&&n&&(0,v.jsx)(l.Tooltip,{title:r.exportCsvTooltip,children:(0,v.jsx)(l.IconButton,{size:`small`,onClick:n,"aria-label":r.exportCsvTooltip,"data-testid":`gantt-export-csv`,children:(0,v.jsx)(N.default,{fontSize:`small`})})}),t.showResetView&&(0,v.jsx)(l.Tooltip,{title:r.resetViewTooltip,children:(0,v.jsx)(`span`,{children:(0,v.jsx)(l.IconButton,{size:`small`,onClick:m,disabled:!x,"aria-label":r.resetViewTooltip,"data-testid":`gantt-reset-view`,children:(0,v.jsx)(P.default,{fontSize:`small`})})})})]})]})}var Pt=(0,c.createContext)(null);function $(e){let t=(0,c.useContext)(Pt);if(!t)throw Error(`GanttChartStoreContext is missing.`);return(0,O.useStore)(t,e)}function Ft(){let e=(0,c.useContext)(Pt);if(!e)throw Error(`GanttChartStoreContext is missing.`);return e}var It=(0,c.createContext)(ot);function Lt(){return(0,c.useContext)(It)}var Rt=(0,c.createContext)({});function zt(){return(0,c.useContext)(Rt)}function Bt(e,t){return e===void 0?t:e===`auto`?`100%`:typeof e==`string`&&/^\d+$/.test(e)?Number(e):e}var Vt=[`days`,`weeks`,`months`,`quarters`],Ht={showScaleDays:!0,showScaleWeeks:!0,showScaleMonths:!0,showScaleQuarters:!0,showExpandCollapseAll:!0,showScrollToToday:!0,showDateRange:!0,showRangeReset:!0,showResetView:!0,showExportCSV:!1};function Ut({tasks:e,onTaskClick:t,onMilestoneClick:n,onAddTask:r,onEditTask:i,onDeleteTask:a,onStatusChange:o,onTasksChange:s,enableBuiltinDialogs:u=!0,onTaskCreated:d,onTaskUpdated:f,onTaskDeleted:p,showToolbar:m=!0,toolbarConfig:h,height:g,width:_,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,onTaskMoved:A,onTaskResized:j}){let M=Bt(g,400),N=(0,c.useMemo)(()=>({...Ht,...h}),[h]),P=Bt(_,`100%`),F=$(e=>e.setTasks),I=$(e=>e.timeScale),L=$(e=>e.setTimeScale),R=$(e=>e.timelineRange),z=(0,c.useRef)(null),B=(0,c.useRef)(null),V=(0,c.useRef)(!1),[H,U]=(0,c.useState)(320),W=Ft(),G=(0,c.useCallback)(()=>{let e=W.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)}},[W,k]);(0,c.useEffect)(()=>{F(e)},[e,F]);let K=()=>{V.current||=(V.current=!0,B.current&&z.current&&(B.current.scrollTop=z.current.scrollTop),!1)},q=()=>{V.current||=(V.current=!0,z.current&&B.current&&(z.current.scrollTop=B.current.scrollTop),!1)},J=(0,c.useCallback)(()=>{if(!B.current)return;let e=ze(R,I),t=Date.now(),n=e.start.getTime(),r=e.end.getTime(),i=(t-n)/(r-n)*B.current.scrollWidth;B.current.scrollLeft=Math.max(0,i-B.current.clientWidth/2)},[R,I]);(0,c.useEffect)(()=>{if(!x||!B.current)return;let e=B.current,t=e=>{if(!e.ctrlKey)return;e.preventDefault();let t=Vt.indexOf(I);e.deltaY<0&&t>0?L(Vt[t-1]):e.deltaY>0&&t<Vt.length-1&&L(Vt[t+1])};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[x,I,L]);let Y=(0,c.useCallback)(e=>{e.preventDefault();let t=e.clientX,n=H,r=e=>{let r=e.clientX-t;U(Math.max(y,Math.min(b,n+r)))},i=()=>{document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i)};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i)},[H,y,b]);return(0,v.jsxs)(l.Box,{sx:{display:`flex`,flexDirection:`column`,height:M,width:P,border:`1px solid`,borderColor:`divider`,borderRadius:1,overflow:`hidden`},children:[m&&(0,v.jsx)(Nt,{onScrollToToday:J,config:N,onExportCSV:N.showExportCSV?G:void 0}),(0,v.jsxs)(l.Box,{sx:{display:`flex`,flex:1,overflow:`hidden`},children:[(0,v.jsx)(_t,{scrollRef:z,onScroll:K,panelWidth:H,onTaskClick:t,onAddTask:r,onEditTask:i,onDeleteTask:a,onStatusChange:o,onTasksChange:s,enableBuiltinDialogs:u,onTaskCreated:d,onTaskUpdated:f,onTaskDeleted:p,inlineEdit:w,virtualizeRows:D,showAssigneeColumn:O}),(0,v.jsx)(l.Box,{"data-testid":`gantt-panel-divider`,sx:{width:4,flexShrink:0,bgcolor:`divider`,cursor:`col-resize`,"&:hover":{bgcolor:`action.hover`}},onMouseDown:Y}),(0,v.jsx)(At,{scrollRef:B,onScroll:q,onTaskClick:t,onMilestoneClick:n,draggable:S,resizable:C,progressDraggable:T,showCriticalPath:E,virtualizeRows:D,onTaskMoved:A,onTaskResized:j,onTasksChange:s,onStatusChange:o})]})]})}function Wt({tasks:e,timeScale:t=`months`,initialExpandAll:n=!1,showToolbar:r=!0,defaultRangeStart:i,defaultRangeEnd:a,translations:o,enableBuiltinDialogs:s=!0,toolbarConfig:l,zoomable:u=!1,draggable:d=!1,resizable:f=!1,inlineEdit:p=!1,progressDraggable:m=!1,showCriticalPath:h=!1,virtualizeRows:g=!1,showAssigneeColumn:_=!1,cascadeDependencies:y=!1,statusColors:b,ganttTheme:x,onExportCSV:S,onTaskClick:C,onMilestoneClick:w,onAddTask:T,onEditTask:E,onDeleteTask:D,onStatusChange:O,onTasksChange:k,onTaskMoved:A,onTaskResized:j,onTaskCreated:M,onTaskUpdated:N,onTaskDeleted:P,height:F,width:I,minPanelWidth:L,maxPanelWidth:R}){let z=(0,c.useMemo)(()=>({...ot,...o}),[o]),[B]=(0,c.useState)(()=>{if(!(i!==void 0||a!==void 0))return at(e,t,n,void 0,y);let r=Re(e);return at(e,t,n,{start:i??r.start,end:a??r.end},y)}),V=(0,c.useMemo)(()=>({...x,statusColors:{...b,...x?.statusColors}}),[b,x]);return(0,v.jsx)(It.Provider,{value:z,children:(0,v.jsx)(Rt.Provider,{value:V,children:(0,v.jsx)(Pt.Provider,{value:B,children:(0,v.jsx)(Ut,{tasks:e,timeScale:t,enableBuiltinDialogs:s,showToolbar:r,toolbarConfig:l,zoomable:u,draggable:d,resizable:f,inlineEdit:p,progressDraggable:m,showCriticalPath:h,virtualizeRows:g,showAssigneeColumn:_,onExportCSV:S,onTaskClick:C,onMilestoneClick:w,onAddTask:T,onEditTask:E,onDeleteTask:D,onStatusChange:O,onTasksChange:k,onTaskMoved:A,onTaskResized:j,onTaskCreated:M,onTaskUpdated:N,onTaskDeleted:P,height:F,width:I,minPanelWidth:L,maxPanelWidth:R})})})})}var Gt=e=>Math.max(0,Math.min(4,Math.round(e)));function Kt(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=Gt(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 qt({percent:e,color:t,ariaLabel:n,segments:r=!1}){if(r){let r=Math.round(e/25);return(0,v.jsx)(l.Box,{role:`progressbar`,"aria-label":n,"aria-valuenow":e,"aria-valuemin":0,"aria-valuemax":100,sx:{width:`100%`,display:`flex`,gap:`3px`,mt:.5},children:[0,1,2,3].map(e=>(0,v.jsx)(l.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,v.jsx)(l.Box,{role:`progressbar`,"aria-label":n,"aria-valuenow":e,"aria-valuemin":0,"aria-valuemax":100,sx:{width:`100%`,height:`8px`,border:`1px solid`,borderColor:`divider`,borderRadius:`6px`,mt:.5,display:`flex`},children:(0,v.jsx)(l.Box,{"data-testid":`psm-meter`,sx:{height:`100%`,width:`${e}%`,backgroundColor:t,borderRadius:`6px`,transition:`width 0.2s ease-in-out`}})})}var Jt={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`},Yt={weak:`#cc0000`,ok:`#fdc010`,good:`#8bc34a`,veryGood:`#43a047`},Xt={failure:`#cc0000`,success:`#43a047`};function Zt(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=new Uint32Array(e.length);crypto.getRandomValues(r);let i=t.map(e=>e[crypto.getRandomValues(new Uint32Array(1))[0]%e.length]),a=Array.from(r.slice(i.length)).map(e=>n[e%n.length]),o=[...i,...a];for(let e=o.length-1;e>0;e--){let t=crypto.getRandomValues(new Uint32Array(1))[0]%(e+1);[o[e],o[t]]=[o[t],o[e]]}return o.join(``)}function Qt({label:e,fulfilled:t,checkColors:n}){return(0,v.jsxs)(l.Stack,{direction:`row`,sx:{alignItems:`center`,mb:.25},spacing:.5,children:[(0,v.jsx)(l.Typography,{variant:`caption`,children:e}),t?(0,v.jsx)(E.default,{"data-testid":`psm-req-success`,style:{fontSize:16,color:n.success}}):(0,v.jsx)(D.default,{"data-testid":`psm-req-failure`,style:{fontSize:16,color:n.failure}})]})}function $t({value:e,confirmValue:t,name:n,inputRef:r,disabled:i=!1,error:a=!1,helperText:o,autoComplete:s,customRequirements:u,generatorOptions:d,showConfirmField:f=!1,showPasswordAdornment:p=!0,showMeter:m=!0,showPasswordGenerator:h=!1,showSegmentedBar:g=!1,showSummary:_=!0,inputSize:y=`medium`,translation:b,meterColors:x,passwordMinLength:S=8,checkColors:C=Xt,onPasswordChange:T,onConfirmChange:E,onPasswordGenerated:D}){let O={...Jt,...b},k={...Yt,...x},A=(0,c.useId)(),j=`${A}-password`,[M,N]=(0,c.useState)(!1),[P,F]=(0,c.useState)(!1),[I,L]=(0,c.useState)(``),[R,U]=(0,c.useState)(``),W=e===void 0?I:e,G=t===void 0?R:t,K=f&&G.length>0,q=K&&W===G,J=(0,c.useMemo)(()=>Kt(W,S),[W,S]);return(0,v.jsxs)(l.Stack,{children:[(0,v.jsxs)(l.FormControl,{variant:`outlined`,fullWidth:!0,error:a,children:[(0,v.jsx)(l.InputLabel,{htmlFor:j,size:y,children:O.label}),(0,v.jsx)(l.OutlinedInput,{id:j,type:M?`text`:`password`,fullWidth:!0,size:y,value:W,onChange:t=>{let n=t.target.value;e===void 0&&L(n),T&&T(n,Kt(n,S))},disabled:i,inputRef:r,inputProps:{"data-testid":`psm-input`,name:n,autoComplete:s},endAdornment:p?(0,v.jsx)(l.InputAdornment,{position:`end`,children:(0,v.jsx)(l.IconButton,{"data-testid":`psm-toggle`,disabled:i,"aria-label":M?O.hidePasswordLabel:O.showPasswordLabel,onClick:()=>{N(e=>!e)},onMouseDown:e=>{e.preventDefault()},onMouseUp:e=>{e.preventDefault()},edge:`end`,children:M?(0,v.jsx)(H.default,{}):(0,v.jsx)(V.default,{})})}):null,label:O.label}),o&&(0,v.jsx)(l.FormHelperText,{children:o})]}),h&&(0,v.jsx)(l.Tooltip,{title:O.generatePasswordLabel,arrow:!0,children:(0,v.jsx)(`span`,{children:(0,v.jsx)(l.Button,{"data-testid":`psm-generate`,size:`small`,variant:`text`,startIcon:(0,v.jsx)(w.default,{fontSize:`small`}),disabled:i,onClick:()=>{let n=Zt({length:d?.length??Math.max(16,S),upper:d?.upper??!0,lower:d?.lower??!0,numbers:d?.numbers??!0,symbols:d?.symbols??!0});e===void 0&&L(n),t===void 0&&U(``),T?.(n,Kt(n,S)),D?.(n),N(!0)},sx:{mt:.5,alignSelf:`flex-start`,textTransform:`none`},children:O.generatePasswordLabel})})}),f&&(0,v.jsxs)(l.FormControl,{variant:`outlined`,fullWidth:!0,error:K&&!q,sx:{mt:1},children:[(0,v.jsx)(l.InputLabel,{htmlFor:`${A}-confirm`,size:y,children:O.confirmLabel}),(0,v.jsx)(l.OutlinedInput,{id:`${A}-confirm`,type:P?`text`:`password`,fullWidth:!0,size:y,value:G,onChange:e=>{let n=e.target.value;t===void 0&&U(n),E?.(n,n===W)},disabled:i,inputProps:{"data-testid":`psm-confirm-input`},endAdornment:(0,v.jsxs)(l.InputAdornment,{position:`end`,children:[K&&(q?(0,v.jsx)(z.default,{"data-testid":`psm-confirm-match`,sx:{color:C.success,mr:.5},fontSize:`small`}):(0,v.jsx)(B.default,{"data-testid":`psm-confirm-mismatch`,sx:{color:C.failure,mr:.5},fontSize:`small`})),(0,v.jsx)(l.IconButton,{size:`small`,disabled:i,onClick:()=>F(e=>!e),onMouseDown:e=>e.preventDefault(),edge:`end`,"aria-label":P?O.hidePasswordLabel:O.showPasswordLabel,children:P?(0,v.jsx)(H.default,{}):(0,v.jsx)(V.default,{})})]}),label:O.confirmLabel}),K&&(0,v.jsx)(l.FormHelperText,{sx:{color:q?C.success:C.failure},children:q?O.confirmMatchLabel:O.confirmMismatchLabel})]}),m&&(0,v.jsx)(qt,{percent:J.percent,color:(e=>{switch(e.meterStatus){case`weak`:return k.weak;case`ok`:return k.ok;case`good`:return k.good;case`very good`:return k.veryGood;default:return`transparent`}})(J),ariaLabel:O.meterAriaLabel,segments:g}),_&&(0,v.jsxs)(l.Box,{"data-testid":`psm-summary`,sx:{mt:.5,p:.5},children:[(0,v.jsx)(l.Typography,{variant:`caption`,gutterBottom:!0,sx:{display:`block`,fontSize:14},children:O.summaryHeaderLabel}),(0,v.jsxs)(l.Stack,{direction:`row`,spacing:6,children:[(0,v.jsxs)(l.Stack,{direction:`column`,children:[(0,v.jsx)(Qt,{label:O.summaryMinChars.replace(`{n}`,String(S)),fulfilled:J.length>=S,checkColors:C}),(0,v.jsx)(Qt,{label:O.summaryCapitalLetter,fulfilled:J.hasUpper,checkColors:C}),(0,v.jsx)(Qt,{label:O.summaryLowerCaseLetter,fulfilled:J.hasLower,checkColors:C})]}),(0,v.jsxs)(l.Stack,{direction:`column`,children:[(0,v.jsx)(Qt,{label:O.summaryNumber,fulfilled:J.hasDigit,checkColors:C}),(0,v.jsx)(Qt,{label:O.summarySpecialChar,fulfilled:J.hasSymbol,checkColors:C}),u?.map((e,t)=>(0,v.jsx)(Qt,{label:e.label,fulfilled:typeof e.fulfilled==`function`?e.fulfilled(W):e.fulfilled,checkColors:C},t))]})]})]})]})}function en(e){return(0,k.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 tn=[`default`,`primary`,`secondary`,`error`,`info`,`success`,`warning`],nn=[`#f44336`,`#e91e63`,`#9c27b0`,`#673ab7`,`#3f51b5`,`#2196f3`,`#03a9f4`,`#00bcd4`,`#009688`,`#4caf50`,`#8bc34a`,`#cddc39`,`#ffeb3b`,`#ffc107`,`#ff9800`,`#ff5722`,`#795548`,`#9e9e9e`,`#607d8b`,`#000000`];function rn(e){return/^#[0-9A-Fa-f]{6}$/.test(e)}function an(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 on(e,t){let n=t.trim();if(!n)return e;let r=e.toLowerCase().indexOf(n.toLowerCase());return r===-1?e:(0,v.jsxs)(v.Fragment,{children:[e.slice(0,r),(0,v.jsx)(`strong`,{children:e.slice(r,r+n.length)}),e.slice(r+n.length)]})}function sn({color:e,selected:t,onClick:n}){return(0,v.jsx)(l.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 cn({value:e,onChange:t,disabled:n=!1}){return(0,v.jsx)(l.TextField,{size:`small`,fullWidth:!0,value:e,onChange:e=>t(e.target.value),placeholder:`#rrggbb`,disabled:n,error:!n&&e.length>1&&!rn(e),sx:{"& .MuiInputBase-root":{height:28},"& .MuiInputBase-input":{py:0,px:.5,fontSize:`0.72rem`,fontFamily:`monospace`}},slotProps:{input:{startAdornment:(0,v.jsx)(l.Box,{sx:{width:12,height:12,borderRadius:.25,flexShrink:0,mr:.5,backgroundColor:rn(e)?e:`action.disabledBackground`,border:`1px solid`,borderColor:`divider`}})}}})}function ln({availableTags:e,searchValue:t,translation:n,onSearchChange:r,onTagSelect:i,onTagCreate:a,inputSize:o=`medium`,chipSize:s=`medium`,disabled:u=!1,loading:d=!1,isMaxReached:f=!1,allowCreate:p=!1,listboxMaxHeight:m}){let[h,g]=(0,c.useState)(`default`),[_,y]=(0,c.useState)(null),[x,S]=(0,c.useState)(null),[C,w]=(0,c.useState)(!0),[T,E]=(0,c.useState)(!1),[D,O]=(0,c.useState)(!1),[k,A]=(0,c.useState)(`#1976d2`),[j,M]=(0,c.useState)(`#ffffff`),N=u||f,P=_!==null,F=e.filter(e=>e.label.toLowerCase().includes(t.trim().toLowerCase())),I=p&&t.trim()!==``&&F.length===0,L=D&&!I,R=P?C?an(_):x??`#000000`:void 0,z=()=>{let e=t.trim(),n=e.toLowerCase().replace(/\s+/g,`-`);a?.(P&&_?{id:n,label:e,selected:!0,color:`default`,backgroundColor:_,foregroundColor:R}:{id:n,label:e,selected:!0,color:h}),g(`default`),y(null),S(null),w(!0),E(!1),r(``)},B=()=>{r(``),g(`default`),y(null),S(null),w(!0),E(!1)},V=e=>{y(e),A(e),g(`default`)},H=e=>{A(e),rn(e)&&(y(e),g(`default`))},W=e=>{S(e),M(e)},G=e=>{M(e),rn(e)&&S(e)},K=e=>{if(w(e),e)S(null);else if(_){let e=an(_);S(e),M(e)}},q=e=>e.preventDefault();return(0,v.jsxs)(l.Box,{sx:{mb:2},children:[(0,v.jsx)(l.Autocomplete,{options:e,value:null,open:L,onOpen:()=>{I||O(!0)},onClose:()=>O(!1),size:o,disabled:N,loading:d,getOptionLabel:e=>e.label,inputValue:t,onInputChange:(e,t)=>r(t),onChange:(e,t)=>{t&&i(t)},slotProps:{listbox:{sx:{display:`flex`,flexWrap:`wrap`,gap:1,padding:1,...m!==void 0&&{maxHeight:m,overflowY:`auto`}}}},renderInput:e=>(0,v.jsx)(l.TextField,{...e,label:n.autoCompleteLabel,placeholder:n.placeholder,helperText:f&&!u?n.maxTagsReachedText:void 0,onKeyDown:e=>{I&&e.key===`Enter`&&(e.preventDefault(),z())},slotProps:{...e.slotProps,input:{...e.slotProps?.input,endAdornment:(0,v.jsxs)(v.Fragment,{children:[I&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(l.IconButton,{size:`small`,sx:{color:`success.main`},onMouseDown:q,onClick:z,"aria-label":n.confirmCreateLabel,children:(0,v.jsx)(b.default,{fontSize:`small`})}),(0,v.jsx)(l.IconButton,{size:`small`,onMouseDown:q,onClick:B,"aria-label":n.cancelCreateLabel,children:(0,v.jsx)(U.default,{fontSize:`small`})})]}),e.slotProps?.input?.endAdornment]})}}}),renderOption:({key:e,...n},r)=>{let i=!!(r.foregroundColor||r.backgroundColor);return(0,v.jsx)(`li`,{...n,style:{width:`auto`,padding:0,margin:0},children:(0,v.jsx)(l.Chip,{size:s,label:on(r.label,t),color:i?void 0:r.color??`default`,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}),I&&(0,v.jsxs)(l.Box,{sx:{position:`relative`},onMouseDown:q,children:[(0,v.jsxs)(l.Stack,{direction:`row`,sx:{mt:.5,flexWrap:`wrap`,gap:.5,alignItems:`center`},children:[tn.map(e=>(0,v.jsx)(l.Chip,{size:s,color:e,label:e,variant:!P&&h===e?`filled`:`outlined`,onClick:()=>{g(e),y(null),S(null),E(!1)},clickable:!0},e)),(0,v.jsx)(l.Tooltip,{title:n.colorPickerLabel,children:(0,v.jsx)(l.Chip,{size:s,label:P?_:`···`,variant:`outlined`,onClick:()=>{E(e=>!e),_&&A(_),x&&M(x)},sx:e=>({cursor:`pointer`,fontFamily:`monospace`,fontSize:`0.7rem`,...P?{backgroundColor:_,color:R,border:`1.5px solid transparent`,backgroundImage:`linear-gradient(${_}, ${_}), 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})})]}),T&&(0,v.jsx)(l.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,v.jsxs)(l.Box,{sx:{display:`grid`,gridTemplateColumns:`auto auto`,gap:2},children:[(0,v.jsxs)(l.Box,{children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{fontWeight:700,color:`text.primary`,display:`block`,mb:.5},children:n.backgroundColorLabel}),(0,v.jsxs)(l.Box,{sx:{display:`grid`,gridTemplateColumns:`repeat(5, 24px)`,gap:.5},children:[nn.map(e=>(0,v.jsx)(sn,{color:e,selected:_===e,onClick:()=>V(e)},e)),(0,v.jsx)(l.Box,{sx:{gridColumn:`span 5`,mt:.25},children:(0,v.jsx)(cn,{value:k,onChange:H})})]})]}),(0,v.jsxs)(l.Box,{children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{fontWeight:700,color:`text.primary`,display:`block`,mb:.5},children:n.textColorLabel}),(0,v.jsxs)(l.Box,{sx:{display:`grid`,gridTemplateColumns:`repeat(5, 24px)`,gap:.5,opacity:C?.3:1,pointerEvents:C?`none`:`auto`,transition:`opacity 0.15s`},children:[nn.map(e=>(0,v.jsx)(sn,{color:e,selected:x===e,onClick:()=>W(e)},e)),(0,v.jsx)(l.Box,{sx:{gridColumn:`span 5`,mt:.25},children:(0,v.jsx)(cn,{value:C?R??`#000000`:j,onChange:G,disabled:C})})]}),(0,v.jsxs)(l.Stack,{direction:`row`,sx:{width:`100%`,alignItems:`center`,justifyContent:`flex-end`,gap:.5,mt:.25},children:[(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:n.autoTextColorLabel}),(0,v.jsx)(l.Switch,{size:`small`,checked:C,onChange:e=>K(e.target.checked)})]})]})]})})]})]})}function un({tag:e,onDelete:t,onClick:n,chipSize:r=`medium`,disabled:i=!1}){let a=!!(e.foregroundColor||e.backgroundColor);return(0,v.jsx)(l.Chip,{size:r,label:e.label,onDelete:t?()=>t(e):void 0,onClick:n?()=>n(e):void 0,clickable:!!n&&!e.disabled&&!i,disabled:i||e.disabled,variant:e.selected?`filled`:`outlined`,color:a?void 0:e.color??`default`,sx:{...a&&{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&&!i?`pointer`:`default`}})}function dn({selectedTags:e,translation:t,onTagDelete:n,showSelectedTagsLabel:r,chipSize:i=`medium`,disabled:a=!1,maxVisibleChips:o,popoverPlacement:s=`bottom`}){let[u,d]=(0,c.useState)(null),f=o===void 0?e:e.slice(0,o),p=o===void 0?[]:e.slice(o),m=!!u&&p.length>0,h=s===`top`?{vertical:`top`,horizontal:`left`}:{vertical:`bottom`,horizontal:`left`},g=s===`top`?{vertical:`bottom`,horizontal:`left`}:{vertical:`top`,horizontal:`left`};return(0,v.jsxs)(l.Box,{sx:{mb:2},children:[r&&(0,v.jsx)(l.Typography,{variant:`subtitle2`,gutterBottom:!0,children:t.selectedTagsLabel}),e.length===0?(0,v.jsx)(l.Typography,{variant:`body2`,color:`text.secondary`,children:t.noSelectedTagsText}):(0,v.jsxs)(l.Stack,{direction:`row`,sx:{flexWrap:`wrap`,gap:1},children:[f.map(e=>(0,v.jsx)(un,{tag:e,onDelete:n,chipSize:i,disabled:a},e.id)),p.length>0&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(l.Chip,{size:i,label:`+${p.length}`,variant:`outlined`,clickable:!0,onClick:e=>d(e.currentTarget)}),(0,v.jsx)(l.Popover,{open:m,anchorEl:u,onClose:()=>d(null),anchorOrigin:h,transformOrigin:g,children:(0,v.jsx)(l.Box,{sx:{p:1,display:`flex`,flexWrap:`wrap`,gap:.5,maxWidth:320},children:p.map(e=>(0,v.jsx)(un,{tag:e,onDelete:a?void 0:n,chipSize:i,disabled:a},e.id))})})]})]})]})}var fn={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`},pn=(0,c.createContext)(null);function mn(e){let t=(0,c.useContext)(pn);if(!t)throw Error(`TagSelectionStoreContext is missing.`);return(0,O.useStore)(t,e)}function hn({tags:e,showSelectedTags:t=!0,showSelectedTagsLabel:n=!0,showAutoComplete:r=!0,inputSize:i=`medium`,chipSize:a=`small`,disabled:o=!1,loading:s=!1,maxTags:u,allowCreate:d=!1,maxVisibleChips:f,popoverPlacement:p=`bottom`,listboxMaxHeight:m,translation:h,onTagSelect:g,onTagDelete:_,onTagsChange:y,onSearchChange:b,onTagCreate:x}){let S=mn(e=>e.tags),C=mn(e=>e.searchValue),w=mn(e=>e.setTags),T=mn(e=>e.setSearchValue),E=mn(e=>e.selectTag),D=mn(e=>e.deleteTag),O=mn(e=>e.addTag);(0,c.useEffect)(()=>{w(e)},[e,w]);let k=(0,c.useMemo)(()=>S.filter(e=>e.selected).sort((e,t)=>e.label.localeCompare(t.label)),[S]),A=(0,c.useMemo)(()=>S.filter(e=>!e.selected&&!e.disabled).sort((e,t)=>e.label.localeCompare(t.label)),[S]),j=u!==void 0&&k.length>=u,M=e=>{y&&y(e.filter(e=>e.selected),e)};return(0,v.jsx)(l.Box,{sx:{width:`100%`},children:(0,v.jsxs)(l.Stack,{children:[t&&(0,v.jsx)(dn,{selectedTags:k,translation:h,onTagDelete:e=>{D(e.id);let t=S.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&&_&&_(r,n,t),M(t)},showSelectedTagsLabel:n,chipSize:a,disabled:o,maxVisibleChips:f,popoverPlacement:p}),r&&(0,v.jsx)(ln,{availableTags:A,searchValue:C,translation:h,onSearchChange:e=>{T(e),b&&b(e)},onTagSelect:e=>{if(e.disabled||e.selected)return;E(e.id);let t=S.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&&g&&g(r,n,t),M(t)},onTagCreate:e=>{O(e),M([...S,e]),x&&x(e)},inputSize:i,chipSize:a,disabled:o,loading:s,isMaxReached:j,allowCreate:d,listboxMaxHeight:m})]})})}function gn({tags:e,showSelectedTags:t=!0,showSelectedTagsLabel:n=!0,showAutoComplete:r=!0,translation:i,inputSize:a=`medium`,chipSize:o=`small`,disabled:s=!1,loading:l=!1,maxTags:u,allowCreate:d=!1,maxVisibleChips:f,popoverPlacement:p=`bottom`,listboxMaxHeight:m,onTagSelect:h,onTagDelete:g,onTagsChange:_,onSearchChange:y,onTagCreate:b}){let x={...fn,...i},[S]=(0,c.useState)(()=>en(e));return(0,v.jsx)(pn.Provider,{value:S,children:(0,v.jsx)(hn,{tags:e,showSelectedTags:t,showSelectedTagsLabel:n,showAutoComplete:r,translation:x,inputSize:a,chipSize:o,disabled:s,loading:l,maxTags:u,allowCreate:d,maxVisibleChips:f,popoverPlacement:p,listboxMaxHeight:m,onTagSelect:h,onTagDelete:g,onTagsChange:_,onSearchChange:y,onTagCreate:b})})}var _n={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},vn={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…`};function yn({editor:e,error:t,disabled:n,readonly:r}){return(0,v.jsx)(l.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,v.jsx)(W.EditorContent,{editor:e})})}function bn({open:e,onClose:t,editor:n,translation:r}){let[i,a]=(0,c.useState)(``);(0,c.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 u(){n.chain().focus().extendMarkRange(`link`).unsetLink().run(),t()}function d(e){e.key===`Enter`&&s()}return(0,v.jsxs)(l.Dialog,{open:e,onClose:t,maxWidth:`sm`,fullWidth:!0,children:[(0,v.jsx)(l.DialogTitle,{children:r.linkDialogTitle}),(0,v.jsx)(l.DialogContent,{children:(0,v.jsx)(l.TextField,{autoFocus:!0,fullWidth:!0,label:r.linkDialogUrlLabel,value:i,onChange:e=>a(e.target.value),onKeyDown:d,variant:`outlined`,size:`small`,sx:{mt:1},placeholder:`https://`})}),(0,v.jsxs)(l.DialogActions,{sx:{px:3,pb:2,gap:1},children:[o&&(0,v.jsx)(l.Button,{onClick:u,color:`error`,sx:{mr:`auto`},children:r.linkDialogRemove}),(0,v.jsx)(l.Button,{onClick:t,children:r.linkDialogCancel}),(0,v.jsx)(l.Button,{onClick:s,variant:`contained`,children:r.linkDialogSave})]})]})}var xn=[`#000000`,`#434343`,`#666666`,`#999999`,`#b7b7b7`,`#ffffff`,`#ff0000`,`#ff4500`,`#ff8c00`,`#ffd700`,`#9acd32`,`#008000`,`#00ced1`,`#1e90ff`,`#0000ff`,`#8a2be2`,`#ff1493`,`#a52a2a`],Sn=[`#ffff00`,`#ffd700`,`#ffa500`,`#ff69b4`,`#ff6347`,`#fa8072`,`#adff2f`,`#90ee90`,`#00fa9a`,`#00ffff`,`#87ceeb`,`#add8e6`,`#dda0dd`,`#ee82ee`,`#d2b48c`,`#f5f5dc`,`#ffffff`,`#000000`];function Cn({color:e,active:t,onClick:n}){return(0,v.jsx)(l.Tooltip,{title:e,placement:`top`,arrow:!0,children:(0,v.jsx)(l.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,v.jsx)(l.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 wn({anchorEl:e,open:t,onClose:n,mode:r,activeColor:i,onSelectColor:a,onRemoveColor:o,removeLabel:s}){let u=(0,c.useRef)(null),d=r===`highlight`?Sn:xn;function f(e){a(e.target.value)}return(0,v.jsxs)(l.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,v.jsx)(l.Box,{sx:{display:`grid`,gridTemplateColumns:`repeat(6, 22px)`,gap:.5,mb:1},children:d.map(e=>(0,v.jsx)(Cn,{color:e,active:i?.toLowerCase()===e.toLowerCase(),onClick:e=>{a(e),n()}},e))}),(0,v.jsxs)(l.Box,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,v.jsx)(l.Tooltip,{title:`Custom color`,arrow:!0,children:(0,v.jsx)(l.Box,{component:`button`,type:`button`,onClick:()=>u.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,v.jsx)(`input`,{ref:u,type:`color`,defaultValue:i??`#000000`,onChange:f,onBlur:n,style:{visibility:`hidden`,width:0,height:0,position:`absolute`}}),(0,v.jsx)(l.Tooltip,{title:s,arrow:!0,children:(0,v.jsx)(l.IconButton,{size:`small`,onClick:()=>{o(),n()},"aria-label":s,sx:{borderRadius:1,ml:`auto`},children:(0,v.jsx)(be.default,{fontSize:`small`})})})]})]})}function Tn({editor:e,translation:t,disabled:n}){let[r,i]=(0,c.useState)(null),a=n||!e,o=e?.isActive(`table`)??!1;function s(){i(null)}function u(e){e(),s()}return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(l.Tooltip,{title:t.table,arrow:!0,children:(0,v.jsx)(`span`,{children:(0,v.jsx)(l.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,v.jsx)(xe.default,{fontSize:`small`})})})}),(0,v.jsxs)(l.Menu,{anchorEl:r,open:!!r,onClose:s,slotProps:{paper:{sx:{minWidth:220}}},children:[(0,v.jsxs)(l.MenuItem,{onClick:()=>u(()=>e?.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()),children:[(0,v.jsx)(l.ListItemIcon,{children:(0,v.jsx)(xe.default,{fontSize:`small`})}),(0,v.jsx)(l.ListItemText,{children:t.insertTable})]}),o&&(0,v.jsx)(l.Divider,{}),o&&(0,v.jsxs)(l.MenuItem,{onClick:()=>u(()=>e?.chain().focus().addRowBefore().run()),children:[(0,v.jsx)(l.ListItemIcon,{children:(0,v.jsx)(j.default,{fontSize:`small`})}),(0,v.jsx)(l.ListItemText,{children:t.addRowBefore})]}),o&&(0,v.jsxs)(l.MenuItem,{onClick:()=>u(()=>e?.chain().focus().addRowAfter().run()),children:[(0,v.jsx)(l.ListItemIcon,{children:(0,v.jsx)(j.default,{fontSize:`small`})}),(0,v.jsx)(l.ListItemText,{children:t.addRowAfter})]}),o&&(0,v.jsxs)(l.MenuItem,{onClick:()=>u(()=>e?.chain().focus().deleteRow().run()),children:[(0,v.jsx)(l.ListItemIcon,{children:(0,v.jsx)(x.default,{fontSize:`small`,color:`error`})}),(0,v.jsx)(l.ListItemText,{sx:{color:`error.main`},children:t.deleteRow})]}),o&&(0,v.jsx)(l.Divider,{}),o&&(0,v.jsxs)(l.MenuItem,{onClick:()=>u(()=>e?.chain().focus().addColumnBefore().run()),children:[(0,v.jsx)(l.ListItemIcon,{children:(0,v.jsx)(j.default,{fontSize:`small`})}),(0,v.jsx)(l.ListItemText,{children:t.addColumnBefore})]}),o&&(0,v.jsxs)(l.MenuItem,{onClick:()=>u(()=>e?.chain().focus().addColumnAfter().run()),children:[(0,v.jsx)(l.ListItemIcon,{children:(0,v.jsx)(j.default,{fontSize:`small`})}),(0,v.jsx)(l.ListItemText,{children:t.addColumnAfter})]}),o&&(0,v.jsxs)(l.MenuItem,{onClick:()=>u(()=>e?.chain().focus().deleteColumn().run()),children:[(0,v.jsx)(l.ListItemIcon,{children:(0,v.jsx)(x.default,{fontSize:`small`,color:`error`})}),(0,v.jsx)(l.ListItemText,{sx:{color:`error.main`},children:t.deleteColumn})]}),o&&(0,v.jsx)(l.Divider,{}),o&&(0,v.jsxs)(l.MenuItem,{onClick:()=>u(()=>e?.chain().focus().deleteTable().run()),children:[(0,v.jsx)(l.ListItemIcon,{children:(0,v.jsx)(x.default,{fontSize:`small`,color:`error`})}),(0,v.jsx)(l.ListItemText,{sx:{color:`error.main`},children:t.deleteTable})]})]})]})}function En({open:e,onClose:t,editor:n,translation:r}){let[i,a]=(0,c.useState)(``),[o,s]=(0,c.useState)(``);function u(){let e=i.trim();e&&(n.chain().focus().setImage({src:e,alt:o.trim()||void 0}).run(),a(``),s(``),t())}function d(){a(``),s(``),t()}function f(e){e.key===`Enter`&&u()}return(0,v.jsxs)(l.Dialog,{open:e,onClose:d,maxWidth:`sm`,fullWidth:!0,children:[(0,v.jsx)(l.DialogTitle,{children:r.imageDialogTitle}),(0,v.jsxs)(l.DialogContent,{sx:{display:`flex`,flexDirection:`column`,gap:2,pt:`16px !important`},children:[(0,v.jsx)(l.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,v.jsx)(l.TextField,{fullWidth:!0,label:r.imageDialogAltLabel,value:o,onChange:e=>s(e.target.value),onKeyDown:f,variant:`outlined`,size:`small`})]}),(0,v.jsxs)(l.DialogActions,{sx:{px:3,pb:2,gap:1},children:[(0,v.jsx)(l.Button,{onClick:d,children:r.imageDialogCancel}),(0,v.jsx)(l.Button,{onClick:u,variant:`contained`,disabled:!i.trim(),children:r.imageDialogSave})]})]})}var Dn=[{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 On({anchorEl:e,open:t,onClose:n,onSelect:r,translation:i}){let[a,o]=(0,c.useState)(``),s=(0,c.useMemo)(()=>{let e=a.trim().toLowerCase();return e?Dn.map(t=>({...t,emojis:t.emojis.filter(t=>t.name.includes(e)||t.emoji===e)})).filter(e=>e.emojis.length>0):Dn},[a]);function u(e){r(e),n(),o(``)}function d(){n(),o(``)}return(0,v.jsxs)(l.Popover,{open:t,anchorEl:e,onClose:d,anchorOrigin:{vertical:`bottom`,horizontal:`left`},transformOrigin:{vertical:`top`,horizontal:`left`},slotProps:{paper:{sx:{width:320,maxHeight:380,display:`flex`,flexDirection:`column`}}},children:[(0,v.jsx)(l.Box,{sx:{p:1,borderBottom:1,borderColor:`divider`},children:(0,v.jsx)(l.TextField,{autoFocus:!0,fullWidth:!0,size:`small`,placeholder:i.emojiSearchPlaceholder,value:a,onChange:e=>o(e.target.value),slotProps:{input:{startAdornment:(0,v.jsx)(l.InputAdornment,{position:`start`,children:(0,v.jsx)(Se.default,{fontSize:`small`})})}}})}),(0,v.jsxs)(l.Box,{sx:{overflowY:`auto`,flex:1,px:1,pb:1},children:[s.map(e=>(0,v.jsxs)(l.Box,{children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{display:`block`,color:`text.secondary`,mt:1,mb:.5,px:.5},children:e.label}),(0,v.jsx)(l.Box,{sx:{display:`flex`,flexWrap:`wrap`,gap:.25},children:e.emojis.map(e=>(0,v.jsx)(l.Box,{component:`button`,title:e.name,"aria-label":e.name,onClick:()=>u(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,v.jsx)(l.Typography,{variant:`body2`,color:`text.secondary`,sx:{p:2,textAlign:`center`},children:`No emoji found`})]})]})}function kn({label:e,icon:t,activeColor:n,disabled:r,onClick:i}){return(0,v.jsx)(l.Tooltip,{title:e,arrow:!0,children:(0,v.jsx)(`span`,{children:(0,v.jsxs)(l.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,v.jsx)(l.Box,{sx:{display:`flex`,alignItems:`center`},children:t}),(0,v.jsx)(l.Box,{sx:{width:`80%`,height:3,bgcolor:n??`text.primary`,borderRadius:.5,mt:`1px`}})]})})})}function An({level:e}){return(0,v.jsxs)(l.Box,{component:`span`,sx:{fontWeight:`bold`,fontSize:`0.875rem`,lineHeight:1},children:[`H`,e]})}function jn({editor:e,toolbarConfig:t,translation:n,disabled:r,isFullscreen:i,onToggleFullscreen:a}){let[o,s]=(0,c.useState)(!1),[u,d]=(0,c.useState)(!1),[f,p]=(0,c.useState)(null),[m,h]=(0,c.useState)(null),[g,_]=(0,c.useState)(null),y=r||!e,b=e?.getAttributes(`textStyle`)?.color,x=e?.getAttributes(`highlight`)?.color,w=t.showBold||t.showItalic||t.showUnderline||t.showStrike,T=t.showHeading1||t.showHeading2||t.showHeading3,E=t.showBulletList||t.showOrderedList,D=t.showBlockquote||t.showCodeBlock||t.showLink||t.showHorizontalRule,O=t.showTextColor||t.showHighlight,k=t.showUndoRedo||t.showClearFormat,A=t.showTableButton||t.showImageButton||t.showEmojiButton,j=[w,T,E,D,O,k,A],M=j.filter(Boolean).length;function N(e,t){return!e||j.slice(t+1).findIndex(Boolean)===-1?null:(0,v.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}},`div-${t}`)}return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(l.Box,{sx:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:.25,px:1,py:.5},role:`toolbar`,"aria-label":`Text formatting`,children:[w&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showBold&&(0,v.jsx)(Q,{label:n.bold,icon:(0,v.jsx)(se.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleBold().run(),active:e?.isActive(`bold`),disabled:y}),t.showItalic&&(0,v.jsx)(Q,{label:n.italic,icon:(0,v.jsx)(ce.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleItalic().run(),active:e?.isActive(`italic`),disabled:y}),t.showUnderline&&(0,v.jsx)(Q,{label:n.underline,icon:(0,v.jsx)(le.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleUnderline().run(),active:e?.isActive(`underline`),disabled:y}),t.showStrike&&(0,v.jsx)(Q,{label:n.strike,icon:(0,v.jsx)(ue.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleStrike().run(),active:e?.isActive(`strike`),disabled:y})]}),N(w,0),T&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showHeading1&&(0,v.jsx)(Q,{label:n.heading1,icon:(0,v.jsx)(An,{level:1}),onClick:()=>e?.chain().focus().toggleHeading({level:1}).run(),active:e?.isActive(`heading`,{level:1}),disabled:y}),t.showHeading2&&(0,v.jsx)(Q,{label:n.heading2,icon:(0,v.jsx)(An,{level:2}),onClick:()=>e?.chain().focus().toggleHeading({level:2}).run(),active:e?.isActive(`heading`,{level:2}),disabled:y}),t.showHeading3&&(0,v.jsx)(Q,{label:n.heading3,icon:(0,v.jsx)(An,{level:3}),onClick:()=>e?.chain().focus().toggleHeading({level:3}).run(),active:e?.isActive(`heading`,{level:3}),disabled:y})]}),N(T,1),E&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showBulletList&&(0,v.jsx)(Q,{label:n.bulletList,icon:(0,v.jsx)(de.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleBulletList().run(),active:e?.isActive(`bulletList`),disabled:y}),t.showOrderedList&&(0,v.jsx)(Q,{label:n.orderedList,icon:(0,v.jsx)(fe.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleOrderedList().run(),active:e?.isActive(`orderedList`),disabled:y})]}),N(E,2),D&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showBlockquote&&(0,v.jsx)(Q,{label:n.blockquote,icon:(0,v.jsx)(pe.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleBlockquote().run(),active:e?.isActive(`blockquote`),disabled:y}),t.showCodeBlock&&(0,v.jsx)(Q,{label:n.codeBlock,icon:(0,v.jsx)(me.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleCodeBlock().run(),active:e?.isActive(`codeBlock`),disabled:y}),t.showLink&&(0,v.jsx)(Q,{label:n.link,icon:(0,v.jsx)(he.default,{fontSize:`small`}),onClick:()=>s(!0),active:e?.isActive(`link`),disabled:y}),t.showHorizontalRule&&(0,v.jsx)(Q,{label:n.horizontalRule,icon:(0,v.jsx)(ge.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().setHorizontalRule().run(),disabled:y})]}),N(D,3),O&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showTextColor&&(0,v.jsx)(kn,{label:n.textColor,icon:(0,v.jsx)(_e.default,{fontSize:`small`}),activeColor:b,disabled:y,onClick:e=>h(e.currentTarget)}),t.showHighlight&&(0,v.jsx)(kn,{label:n.highlight,icon:(0,v.jsx)(ve.default,{fontSize:`small`}),activeColor:x,disabled:y,onClick:e=>_(e.currentTarget)})]}),N(O,4),k&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showUndoRedo&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(Q,{label:n.undo,icon:(0,v.jsx)(S.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().undo().run(),disabled:y||!e?.can().undo()}),(0,v.jsx)(Q,{label:n.redo,icon:(0,v.jsx)(C.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().redo().run(),disabled:y||!e?.can().redo()})]}),t.showClearFormat&&(0,v.jsx)(Q,{label:n.clearFormat,icon:(0,v.jsx)(ye.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().clearNodes().unsetAllMarks().run(),disabled:y})]}),N(k,5),A&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showTableButton&&(0,v.jsx)(Tn,{editor:e,translation:n,disabled:y}),t.showImageButton&&(0,v.jsx)(Q,{label:n.image,icon:(0,v.jsx)(ae.default,{fontSize:`small`}),onClick:()=>d(!0),disabled:y}),t.showEmojiButton&&(0,v.jsx)(l.Tooltip,{title:n.emoji,arrow:!0,children:(0,v.jsx)(`span`,{children:(0,v.jsx)(l.IconButton,{size:`small`,onMouseDown:e=>e.preventDefault(),onClick:e=>p(e.currentTarget),disabled:y,sx:{borderRadius:1},"aria-label":n.emoji,children:(0,v.jsx)(oe.default,{fontSize:`small`})})})})]}),M===0&&(0,v.jsx)(l.Box,{sx:{height:32}}),t.showFullscreenButton&&(0,v.jsx)(l.Box,{sx:{ml:`auto`},children:(0,v.jsx)(l.Tooltip,{title:i?n.exitFullscreen:n.fullscreen,arrow:!0,children:(0,v.jsx)(`span`,{children:(0,v.jsx)(l.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,v.jsx)(ie.default,{fontSize:`small`}):(0,v.jsx)(re.default,{fontSize:`small`})})})})})]}),t.showLink&&e&&(0,v.jsx)(bn,{open:o,onClose:()=>s(!1),editor:e,translation:n}),t.showTextColor&&(0,v.jsx)(wn,{anchorEl:m,open:!!m,onClose:()=>h(null),mode:`textColor`,activeColor:b,onSelectColor:t=>e?.chain().focus().setColor(t).run(),onRemoveColor:()=>e?.chain().focus().unsetColor().run(),removeLabel:n.removeTextColor}),t.showHighlight&&(0,v.jsx)(wn,{anchorEl:g,open:!!g,onClose:()=>_(null),mode:`highlight`,activeColor:x,onSelectColor:t=>e?.chain().focus().setHighlight({color:t}).run(),onRemoveColor:()=>e?.chain().focus().unsetHighlight().run(),removeLabel:n.removeHighlight}),t.showImageButton&&e&&(0,v.jsx)(En,{open:u,onClose:()=>d(!1),editor:e,translation:n}),t.showEmojiButton&&(0,v.jsx)(On,{anchorEl:f,open:!!f,onClose:()=>p(null),onSelect:t=>e?.chain().focus().insertContent(t).run(),translation:n})]})}function Mn({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)),u=i!==void 0&&r>=i?`error`:`text.secondary`,d=s.wordCount.replace(`{count}`,String(o));return(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,mt:.5,px:.5},children:[(0,v.jsx)(l.FormHelperText,{error:t,children:e??``}),(n||a)&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:1.5,alignItems:`center`},children:[a&&(0,v.jsx)(l.FormHelperText,{sx:{color:`text.secondary`},children:d}),n&&(0,v.jsx)(l.FormHelperText,{sx:{color:u},children:c})]})]})}function Nn({disabled:e=!1,error:t=!1,height:n,helperText:r,maxCharacters:i,name:a,placeholder:o,readonly:s=!1,showCharacterCount:u=!1,showToolbar:d=!0,showWordCount:f=!1,toolbarConfig:p,translation:m,value:h,width:g,onBlur:_,onChange:y,onFocus:b}){let x={...vn,...m},S={..._n,...p},[C,w]=(0,c.useState)(!1),T=Fe(n),E=Fe(g),D=T===`auto`,O=D?void 0:T??200,k=i!==void 0&&i>0||u||f,A=(0,W.useEditor)({shouldRerenderOnTransaction:!0,extensions:[G.StarterKit.configure({link:{openOnClick:!1}}),K.TextStyle,q.Color,J.Highlight.configure({multicolor:!0}),ne.Markdown.configure({transformPastedText:!0,transformCopiedText:!1}),Y.Placeholder.configure({placeholder:o??``}),...S.showTableButton?[ee.TableKit]:[],...S.showImageButton?[te.Image.configure({inline:!1,allowBase64:!0})]:[],...k?i!==void 0&&i>0?[X.CharacterCount.configure({limit:i})]:[X.CharacterCount]:[]],content:h??``,editable:!e&&!s,onUpdate({editor:e}){y?.(e.getHTML())},onBlur(){_?.()},onFocus(){b?.()}});(0,c.useEffect)(()=>{!A||h===void 0||A.getHTML()!==h&&A.commands.setContent(h,{emitUpdate:!1})},[A,h]),(0,c.useEffect)(()=>{A&&A.setEditable(!e&&!s)},[A,e,s]);let j=A?.storage.characterCount?.characters?.()??0,M=A?.storage.characterCount?.words?.()??0,N=u||i!==void 0&&i>0||f||!!r;return(0,v.jsxs)(l.Box,{sx:C?{position:`fixed`,top:0,left:0,width:`100vw`,height:`100vh`,zIndex:1300,display:`flex`,flexDirection:`column`,bgcolor:`background.default`,p:1}:{width:E??`100%`,...D?{display:`flex`,flexDirection:`column`,flex:1}:{}},children:[(0,v.jsxs)(l.Paper,{variant:`outlined`,sx:{display:`flex`,flexDirection:`column`,overflow:`hidden`,...C||D?{flex:1}:{height:O},borderColor:t?`error.main`:void 0,"&:focus-within":{borderColor:t?`error.main`:`primary.main`,borderWidth:2}},children:[d&&!s&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(jn,{editor:A,toolbarConfig:S,translation:x,disabled:e,isFullscreen:C,onToggleFullscreen:()=>w(e=>!e)}),(0,v.jsx)(l.Divider,{})]}),(0,v.jsx)(yn,{editor:A,error:t,disabled:e,readonly:s})]}),N&&(0,v.jsx)(Mn,{helperText:r,error:t,showCharacterCount:u||i!==void 0&&i>0,charCount:j,maxCharacters:i&&i>0?i:void 0,showWordCount:f,wordCount:M,translation:x}),a&&(0,v.jsx)(`input`,{type:`hidden`,name:a,value:A?A.getHTML():``})]})}var Pn={showFormat:!0,showCopy:!0,showClear:!0,showExecute:!1,showUndoRedo:!0,showHistory:!1},Fn={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`},In={standard:Ce.StandardSQL,mysql:Ce.MySQL,postgresql:Ce.PostgreSQL,sqlite:Ce.SQLite,mssql:Ce.MSSQL};function Ln({value:e,onChange:t,placeholder:n,disabled:r=!1,readonly:i=!1,showLineNumbers:a=!0,dialect:o=`standard`,keywordColor:s,stringColor:f,identifierColor:_,schema:y,onExecute:b,onLint:x,onDiagnosticsChange:S,onViewReady:C,onCursorChange:w,onBlur:T,onFocus:E}){let D=(0,c.useRef)(null),O=(0,c.useRef)(null),k=(0,c.useRef)(t),A=(0,c.useRef)(w),j=(0,c.useRef)(T),M=(0,c.useRef)(E),N=(0,c.useRef)(C),P=(0,c.useRef)(b),F=(0,c.useRef)(x),I=(0,c.useRef)(S),L=(0,c.useRef)(new d.Compartment),R=(0,c.useRef)(new d.Compartment),z=(0,l.useTheme)(),B=z.palette.mode===`dark`,V=!!x,H=JSON.stringify(y);return(0,c.useEffect)(()=>{k.current=t},[t]),(0,c.useEffect)(()=>{A.current=w},[w]),(0,c.useEffect)(()=>{j.current=T},[T]),(0,c.useEffect)(()=>{M.current=E},[E]),(0,c.useEffect)(()=>{N.current=C},[C]),(0,c.useEffect)(()=>{P.current=b},[b]),(0,c.useEffect)(()=>{F.current=x},[x]),(0,c.useEffect)(()=>{I.current=S},[S]),(0,c.useEffect)(()=>{if(!D.current)return;let t=O.current?.state.doc.toString()??e??``,c=s??z.palette.primary.main,l=f??z.palette.success.main,v=_??z.palette.info.main,b=m.HighlightStyle.define([{tag:g.tags.keyword,color:c,fontWeight:`bold`},{tag:g.tags.name,color:v},{tag:[g.tags.string,g.tags.special(g.tags.string)],color:l,fontWeight:`bold`},{tag:g.tags.number,color:z.palette.warning.main},{tag:[g.tags.lineComment,g.tags.blockComment],color:z.palette.text.disabled,fontStyle:`italic`},{tag:g.tags.operator,color:z.palette.text.secondary},{tag:[g.tags.function(g.tags.variableName),g.tags.function(g.tags.name)],color:z.palette.secondary.main},{tag:g.tags.typeName,color:z.palette.info.main},{tag:g.tags.invalid,color:z.palette.error.main,textDecoration:`underline wavy`}]),x=u.EditorView.theme({"&":{height:`100%`,fontFamily:`'Fira Code', 'JetBrains Mono', 'Consolas', monospace`,fontSize:`0.875rem`},".cm-scroller":{overflow:`auto`},".cm-content":{padding:`8px 4px`,caretColor:z.palette.text.primary},".cm-gutters":{backgroundColor:B?z.palette.grey[900]:z.palette.grey[50],color:z.palette.text.disabled,border:`none`,borderRight:`1px solid ${z.palette.divider}`},".cm-lineNumbers .cm-gutterElement":{paddingLeft:`4px`,paddingRight:`8px`},".cm-activeLineGutter":{backgroundColor:z.palette.action.selected},".cm-activeLine":{backgroundColor:z.palette.action.hover},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground":{backgroundColor:z.palette.primary.main+`40`},".cm-cursor, .cm-dropCursor":{borderLeftColor:z.palette.text.primary},"&.cm-focused":{outline:`none`},".cm-placeholder":{color:z.palette.text.disabled,fontStyle:`italic`},".cm-tooltip":{backgroundColor:z.palette.background.paper,border:`1px solid ${z.palette.divider}`,borderRadius:`4px`,boxShadow:z.shadows[4]},".cm-tooltip-autocomplete > ul > li":{color:z.palette.text.primary},".cm-tooltip-autocomplete > ul > li[aria-selected]":{backgroundColor:z.palette.primary.main+`20`,color:z.palette.primary.main},".cm-completionMatchedText":{color:z.palette.primary.main,textDecoration:`none`,fontWeight:`bold`},".cm-completionDetail":{color:z.palette.text.secondary,fontStyle:`italic`},".cm-gutter-lint":{width:`16px`},".cm-lint-marker-error":{color:z.palette.error.main},".cm-lint-marker-warning":{color:z.palette.warning.main},".cm-tooltip.cm-tooltip-lint":{backgroundColor:z.palette.background.paper,border:`1px solid ${z.palette.divider}`,borderRadius:`4px`},".cm-diagnostic-error":{borderLeft:`3px solid ${z.palette.error.main}`},".cm-diagnostic-warning":{borderLeft:`3px solid ${z.palette.warning.main}`},".cm-diagnostic-info":{borderLeft:`3px solid ${z.palette.info.main}`}},{dark:B}),S=y?Object.fromEntries(y.tables.map(e=>[e.name,(e.columns??[]).map(e=>({label:e.name,detail:e.type,type:`property`}))])):void 0,C=async e=>{let t=F.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 I.current?.(r.length),r}catch{return[]}},w=u.keymap.of([{key:`Mod-Enter`,run:e=>(P.current?.(e.state.doc.toString()),!0)}]),T=[x,(0,m.syntaxHighlighting)(b),(0,Ce.sql)({dialect:In[o],schema:S}),(0,p.history)(),(0,we.autocompletion)(),w,u.keymap.of([...p.defaultKeymap,...p.historyKeymap,...we.completionKeymap]),L.current.of(u.EditorView.editable.of(!r&&!i)),R.current.of(d.EditorState.readOnly.of(i)),(0,u.highlightActiveLine)(),...a?[(0,u.lineNumbers)(),(0,u.highlightActiveLineGutter)()]:[],...n?[(0,u.placeholder)(n)]:[],...V?[(0,h.lintGutter)(),(0,h.linter)(C,{delay:600})]:[],u.EditorView.updateListener.of(e=>{e.docChanged&&k.current?.(e.state.doc.toString());let t=e.state.selection.main.head,n=e.state.doc.lineAt(t);A.current(n.number,t-n.from+1)}),u.EditorView.domEventHandlers({blur:()=>{j.current?.()},focus:()=>{M.current?.()}})],E=new u.EditorView({state:d.EditorState.create({doc:t,extensions:T}),parent:D.current});return O.current=E,N.current(E),()=>{N.current(null),E.destroy(),O.current=null}},[B,o,V,s,f,_,H]),(0,c.useEffect)(()=>{let t=O.current;if(!t)return;let n=t.state.doc.toString();n!==(e??``)&&t.dispatch({changes:{from:0,to:n.length,insert:e??``}})},[e]),(0,c.useEffect)(()=>{O.current?.dispatch({effects:[L.current.reconfigure(u.EditorView.editable.of(!r&&!i)),R.current.reconfigure(d.EditorState.readOnly.of(i))]})},[r,i]),(0,v.jsx)(l.Box,{ref:D,sx:{flex:1,overflow:`hidden`,display:`flex`,flexDirection:`column`,opacity:r?.5:1,backgroundColor:z.palette.background.paper,"& .cm-editor":{flex:1,display:`flex`,flexDirection:`column`}}})}function Rn(e,t=60){let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t)}…`:n}function zn({history:e,onSelect:t,onClear:n,translation:r,disabled:i}){let[a,o]=(0,c.useState)(null);function s(){o(null)}function u(e){t(e),s()}function d(){n(),s()}return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(l.Tooltip,{title:r.history,arrow:!0,children:(0,v.jsx)(`span`,{children:(0,v.jsx)(l.IconButton,{size:`small`,onClick:e=>o(e.currentTarget),disabled:i,"aria-label":r.history,children:(0,v.jsx)(De.default,{fontSize:`small`})})})}),(0,v.jsxs)(l.Menu,{anchorEl:a,open:!!a,onClose:s,slotProps:{paper:{sx:{minWidth:280,maxWidth:400}}},children:[e.length===0&&(0,v.jsx)(l.MenuItem,{disabled:!0,children:(0,v.jsx)(l.ListItemText,{children:r.historyEmpty})}),e.map(e=>(0,v.jsx)(l.MenuItem,{onClick:()=>u(e.sql),children:(0,v.jsx)(l.ListItemText,{primary:Rn(e.sql),secondary:(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:new Date(e.timestamp).toLocaleString()}),slotProps:{primary:{sx:{fontFamily:`monospace`,fontSize:`0.8125rem`}}}})},e.timestamp)),e.length>0&&(0,v.jsx)(l.Divider,{}),e.length>0&&(0,v.jsxs)(l.MenuItem,{onClick:d,children:[(0,v.jsx)(l.ListItemIcon,{children:(0,v.jsx)(Oe.default,{fontSize:`small`,color:`error`})}),(0,v.jsx)(l.ListItemText,{sx:{color:`error.main`},children:r.clearHistory})]})]})]})}var Bn={standard:`sql`,mysql:`mysql`,postgresql:`postgresql`,sqlite:`sqlite`,mssql:`tsql`};function Vn({editorView:e,toolbarConfig:t,translation:n,dialect:r,disabled:i,onExecute:a,queryHistory:o=[],onSelectHistoryEntry:s,onClearHistory:u}){let[d,f]=(0,c.useState)(!1),m=i||!e;function h(){let t=e?.state.doc.toString()??``;navigator.clipboard.writeText(t).then(()=>{f(!0),setTimeout(()=>f(!1),2e3)})}function g(){let t=e;t&&(t.dispatch({changes:{from:0,to:t.state.doc.length,insert:``}}),t.focus())}function _(){let t=e;t&&((0,p.undo)(t),t.focus())}function T(){let t=e;t&&((0,p.redo)(t),t.focus())}function E(){let t=e;if(!t)return;let n=t.state.doc.toString();try{let e=(0,Ee.format)(n,{language:Bn[r]});t.dispatch({changes:{from:0,to:t.state.doc.length,insert:e}})}catch{}t.focus()}function D(){let t=e;!t||!a||a(t.state.doc.toString())}let O=t.showFormat,k=t.showCopy||t.showClear,A=t.showUndoRedo,j=t.showExecute&&!!a,M=t.showHistory&&!!a&&!!s&&!!u;return(0,v.jsxs)(l.Box,{sx:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:.25,px:1,py:.5},role:`toolbar`,"aria-label":`SQL editor actions`,children:[O&&(0,v.jsx)(l.Box,{sx:{display:`flex`,gap:.25},children:(0,v.jsx)(Q,{label:n.format,icon:(0,v.jsx)(w.default,{fontSize:`small`}),onClick:E,disabled:m})}),O&&(k||A)&&(0,v.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),k&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showCopy&&(0,v.jsx)(Q,{label:d?n.copySuccess:n.copy,icon:d?(0,v.jsx)(b.default,{fontSize:`small`,color:`success`}):(0,v.jsx)(y.default,{fontSize:`small`}),onClick:h,disabled:m}),t.showClear&&(0,v.jsx)(Q,{label:n.clear,icon:(0,v.jsx)(x.default,{fontSize:`small`}),onClick:g,disabled:m})]}),k&&A&&(0,v.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),A&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[(0,v.jsx)(Q,{label:n.undo,icon:(0,v.jsx)(S.default,{fontSize:`small`}),onClick:_,disabled:m}),(0,v.jsx)(Q,{label:n.redo,icon:(0,v.jsx)(C.default,{fontSize:`small`}),onClick:T,disabled:m})]}),M&&(0,v.jsxs)(v.Fragment,{children:[(k||A)&&(0,v.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),(0,v.jsx)(zn,{history:o,onSelect:s,onClear:u,translation:n,disabled:i})]}),j&&(0,v.jsxs)(v.Fragment,{children:[(k||A||M)&&(0,v.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),(0,v.jsx)(Q,{label:n.execute,icon:(0,v.jsx)(Te.default,{fontSize:`small`}),onClick:D,disabled:m})]}),!O&&!k&&!A&&!M&&!j&&(0,v.jsx)(l.Box,{sx:{height:32}})]})}function Hn({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)),u=s.errorCount.replace(`{count}`,String(i));return(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,mt:.5,px:.5},children:[(0,v.jsxs)(l.Box,{children:[r&&i>0&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,v.jsx)(ke.default,{sx:{fontSize:`0.875rem`,color:`error.main`}}),(0,v.jsx)(l.FormHelperText,{sx:{color:`error.main`,m:0},children:u})]}),(0,v.jsx)(l.FormHelperText,{error:t,children:e??``})]}),n&&(0,v.jsx)(l.FormHelperText,{sx:{color:`text.disabled`,fontFamily:`monospace`,whiteSpace:`nowrap`},children:c})]})}function Un(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`):[]}catch{return[]}}function Wn(e,t){if(!(typeof window>`u`))try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}}function Gn(e,t,n){let r=t.trim();if(!r)return e;let i=e.filter(e=>e.sql!==r);return[{sql:r,timestamp:Date.now()},...i].slice(0,Math.max(0,n))}function Kn(e,t){let[n,r]=(0,c.useState)(()=>Un(e));return{history:n,addEntry:(0,c.useCallback)(n=>{r(r=>{let i=Gn(r,n,t);return Wn(e,i),i})},[e,t]),clearHistory:(0,c.useCallback)(()=>{r([]),Wn(e,[])},[e])}}function qn({value:e,onChange:t,placeholder:n,height:r,width:i,disabled:a=!1,readonly:o=!1,error:s=!1,helperText:u,name:d,dialect:f=`standard`,showLineNumbers:p=!0,showLineColumn:m=!0,showErrorCount:h=!1,toolbarConfig:g,translation:_,highlightColors:y,schema:b,queryHistoryKey:x=`sql-editor-query-history`,queryHistoryMaxEntries:S=20,onExecute:C,onLint:w,onBlur:T,onFocus:E}){let D={...Fn,..._},O={...Pn,...g},{history:k,addEntry:A,clearHistory:j}=Kn(x,S),M=Fe(r),N=Fe(i),P=M===`auto`,F=P?void 0:M??300,I=(0,c.useRef)(null),[L,R]=(0,c.useState)(null),[z,B]=(0,c.useState)({line:1,col:1}),[V,H]=(0,c.useState)(0),U=(0,c.useCallback)(e=>{I.current=e,R(e)},[]),W=(0,c.useCallback)((e,t)=>{B({line:e,col:t})},[]),G=(0,c.useCallback)(e=>{H(e)},[]),K=C?e=>{A(e),C(e)}:void 0,q=(0,c.useCallback)(e=>{let n=I.current;n&&(n.dispatch({changes:{from:0,to:n.state.doc.length,insert:e}}),n.focus()),t?.(e)},[t]),J=m||h||!!u;return(0,v.jsxs)(l.Box,{sx:{width:N??`100%`,...P?{display:`flex`,flexDirection:`column`,flex:1}:{}},children:[(0,v.jsxs)(l.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,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(Vn,{editorView:L,toolbarConfig:O,translation:D,dialect:f,disabled:a,onExecute:K,queryHistory:k,onSelectHistoryEntry:q,onClearHistory:j}),(0,v.jsx)(l.Divider,{})]}),(0,v.jsx)(Ln,{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,onLint:w,onDiagnosticsChange:w?G:void 0,onViewReady:U,onCursorChange:W,onBlur:T,onFocus:E})]}),J&&(0,v.jsx)(Hn,{helperText:u,error:s,showLineColumn:m,showErrorCount:h,diagnosticsCount:V,cursorLine:z.line,cursorCol:z.col,translation:D}),d&&(0,v.jsx)(`input`,{type:`hidden`,name:d,value:e??``})]})}var Jn=2*Math.PI,Yn=11,Xn=Yn*.5,Zn=5;function Qn(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 $n(e,t){let n=Math.floor(t/Xn);return n<=0?``:e.length<=n?e:n<Zn?``:e.slice(0,n-1)+`…`}function er({node:e,valueDecimalCount:t,valueDecimalSep:n,valueThousandsSep:r}){let i=(e.value??0)>0,a=e.ancestors().map(e=>e.data.name).reverse().join(` › `);return(0,v.jsxs)(l.Box,{sx:{py:.25},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`},children:e.data.name}),i&&(0,v.jsx)(l.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:Qn(e.value??0,t,n,r)}),e.depth>0&&(0,v.jsx)(l.Typography,{variant:`caption`,sx:{display:`block`,opacity:.65,mt:.25},children:a})]})}function tr({data:e,size:t=500,showSegmentLabels:n=!0,innerRadius:r=0,sortBy:i=`value`,chartColors:a,showRootLabel:o=!0,onSegmentClick:s,onZoomChange:u,valueDecimalCount:d=0,valueDecimalSeparator:f=`.`,valueThousandsSeparator:p=`,`,zoomable:m=!1,disabled:h=!1}){let g=(0,l.useTheme)(),_=(0,c.useRef)(null),[y,b]=(0,c.useState)(`-${t/2} -${t/2} ${t} ${t}`),[x,S]=(0,c.useState)(1),C=(0,c.useMemo)(()=>{if(x===1)return y;let[e,t,n,r]=y.split(` `).map(Number),i=n/x,a=r/x;return`${e+(n-i)/2} ${t+(r-a)/2} ${i} ${a}`},[y,x]),w=t/2,T=Math.max(0,Math.min(r,Math.max(0,w-1))),E=Math.max(1,w-T),D=[g.palette.primary.main,g.palette.secondary.main,g.palette.error.main,g.palette.warning.main,g.palette.success.main,g.palette.info.main],O=a&&a.length>0?a:D,{root:k,ringThickness:A}=(0,c.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([Jn,E])(t),r=Z.max(n.descendants(),e=>e.depth)??0,a=r>0?E/r:E;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,E,i]),[j,M]=(0,c.useState)(k),[N,P]=(0,c.useState)(k);N!==k&&(P(k),M(k));let F=(0,c.useMemo)(()=>k.children?.map(e=>e.data.name)??[k.data.name],[k]),I=(0,c.useMemo)(()=>Z.scaleOrdinal().domain(F).range(O),[O,F]),L=e=>{if(e.data.colorConfig?.fill)return e.data.colorConfig.fill;let t=e;for(;t.depth>1;)t=t.parent;return I(t.data.name)},R=(0,c.useMemo)(()=>Z.arc().startAngle(e=>e.x0).endAngle(e=>e.x1).padAngle(e=>Math.min((e.x1-e.x0)/2,.005)).padRadius(w/2).innerRadius(e=>T+e.y0).outerRadius(e=>T+e.y1-1),[w,T]),z=(0,c.useCallback)(e=>{let t=Jn/(j.x1-j.x0),n=Math.max(0,Math.min(Jn,(e.x0-j.x0)*t)),r=Math.max(0,Math.min(Jn,(e.x1-j.x0)*t)),i=j.depth===0?0:(j.depth-1)*A;return{x0:n,x1:r,y0:Math.max(0,e.y0-i),y1:Math.max(0,e.y1-i)}},[j,A]),B=e=>e.x1>e.x0&&e.y1>e.y0,V=e=>(T+(e.y0+e.y1)/2)*(e.x1-e.x0)>12,H=e=>{let t=(e.x0+e.x1)/2*180/Math.PI,n=T+(e.y0+e.y1)/2,r=t<180?0:180;return`rotate(${t-90}) translate(${n},0) rotate(${r})`},U=(0,c.useCallback)(e=>e.ancestors().includes(j),[j]),W=(0,c.useCallback)(e=>{let t=e.ancestors().reverse(),n=e.value??0,r=k.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}},[k]),G=(0,c.useCallback)(e=>{M(e),u&&u({focusNode:W(e),isRoot:e===k})},[k,W,u]);(0,c.useLayoutEffect)(()=>{let e=_.current;if(!e)return;let n=requestAnimationFrame(()=>{try{let t=e.getBBox();b(`${t.x-8} ${t.y-8} ${t.width+16} ${t.height+16}`)}catch{b(`-${t/2} -${t/2} ${t} ${t}`)}});return()=>cancelAnimationFrame(n)},[t,k,j,T,A,o]);let K=(0,c.useRef)(null),q=e=>{K.current&&=(clearTimeout(K.current),null),K.current=setTimeout(()=>{e(),K.current=null},250)},J=()=>{K.current&&=(clearTimeout(K.current),null)};(0,c.useLayoutEffect)(()=>{if(h)return;let e=e=>{e.key===`Escape`&&(J(),G(k),S(1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[h,k,G]);let Y=(0,c.useCallback)(e=>{if(!m||h||!e.ctrlKey)return;e.preventDefault();let t=e.deltaY<0?1.15:1/1.15;S(e=>Math.max(.25,Math.min(8,e*t)))},[m,h]),X=k.descendants().filter(e=>e.depth>0),ee=e=>{if(h)return;let t=X[Number(e.currentTarget.getAttribute(`data-idx`))];if(t){if(e.ctrlKey||e.metaKey){t.children&&q(()=>G(t));return}s?.(W(t),e)}},te=e=>{h||(e.ctrlKey||e.metaKey)&&(J(),G(j.parent??k))},ne=e=>{if(!h){if(e.ctrlKey||e.metaKey){J(),G(j.parent??k);return}s?.(W(j.parent??k),e)}},re={followCursor:!0,enterDelay:50,enterNextDelay:0,disableHoverListener:h,slotProps:{tooltip:{sx:{maxWidth:260}}}},ie=g.palette.text.primary,ae=g.typography.fontFamily;return(0,v.jsx)(l.Box,{sx:{display:`inline-flex`,opacity:h?.5:1,cursor:h?`not-allowed`:`default`,userSelect:`none`},children:(0,v.jsx)(`svg`,{width:t,height:t,viewBox:C,onWheel:Y,style:{fontFamily:ae??`sans-serif`,overflow:m&&x>1?`hidden`:`visible`},role:`img`,"aria-label":e.name,children:(0,v.jsxs)(`g`,{ref:_,children:[T>0&&(0,v.jsx)(l.Tooltip,{...re,title:j.data.name,placement:`top`,children:(0,v.jsx)(`circle`,{cx:0,cy:0,r:T,fill:`transparent`,pointerEvents:h?`none`:`auto`,onClick:ne,style:{cursor:h?`not-allowed`:`pointer`}})}),(0,v.jsx)(`g`,{children:X.map((e,t)=>{let n=z(e),r=B(n),i=!!e.children;return(0,v.jsx)(l.Tooltip,{...re,placement:`top`,title:r?(0,v.jsx)(er,{node:e,valueDecimalCount:d,valueDecimalSep:f,valueThousandsSep:p}):``,children:(0,v.jsx)(`path`,{"data-idx":t,d:R(n)||``,fill:L(e),fillOpacity:r?i?.75:.5:0,style:{pointerEvents:r&&!h?`auto`:`none`,cursor:i&&!h?`pointer`:`default`,transition:`fill-opacity 0.15s`},onClick:ee,onDoubleClick:te})},`tt-${e.data.id}-${t}`)})}),n&&(0,v.jsx)(`g`,{pointerEvents:`none`,textAnchor:`middle`,fill:ie,children:X.map((e,t)=>{if(!U(e))return null;let n=z(e);if(!V(n))return null;let r=(T+(n.y0+n.y1)/2)*(n.x1-n.x0)*.88,i=$n(e.data.name,r);return i?(0,v.jsx)(`text`,{transform:H(n),dy:`0.35em`,fontSize:Yn,children:i},`lbl-${e.data.id}-${t}`):null})}),o&&(0,v.jsx)(l.Tooltip,{...re,placement:`top`,title:``,children:(0,v.jsx)(`g`,{textAnchor:`middle`,fill:ie,pointerEvents:h?`none`:`auto`,onClick:ne,style:{cursor:j!==k&&!h?`pointer`:`default`},children:(0,v.jsx)(`text`,{fontSize:13,dy:`0.35em`,fontWeight:`bold`,children:j.data.name})})})]})})})}tr.displayName=`SunburstChart`;var nr={noData:`No data`};function rr(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 ir({name:e,valueOut:t,valueIn:n,fmt:r}){return(0,v.jsxs)(l.Box,{sx:{py:.25},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`},children:e}),(0,v.jsxs)(l.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:[r(t),` outgoing →`]}),(0,v.jsxs)(l.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:[r(n),` incoming ←`]})]})}function ar({sourceName:e,targetName:t,sourceValue:n,targetValue:r,directed:i,fmt:a}){return(0,v.jsxs)(l.Box,{sx:{py:.25},children:[(0,v.jsxs)(l.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`},children:[e,` → `,t]}),(0,v.jsx)(l.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:a(n)}),i&&r>0&&r!==n&&(0,v.jsxs)(l.Typography,{variant:`caption`,sx:{display:`block`,opacity:.7,mt:.25},children:[t,` → `,e,`: `,a(r)]})]})}function or({data:e,size:t=500,innerRadius:n,ringThickness:r=20,padAngle:i,ribbonPadAngle:a,sortSubgroups:o=`descending`,sortChords:s=`descending`,chartColors:u,groupColorConfigs:d,showGroupLabels:f=!0,labelOffset:p=8,ribbonOpacity:m=.75,ribbonBlendMode:h,directed:g=!0,valueDecimalCount:_=0,valueDecimalSeparator:y=`.`,valueThousandsSeparator:b=`,`,onGroupClick:x,onChordClick:S,zoomable:C=!1,disabled:w=!1}){let T=(0,l.useTheme)(),E=h??(T.palette.mode===`dark`?`normal`:`multiply`),D=[T.palette.primary.main,T.palette.secondary.main,T.palette.error.main,T.palette.warning.main,T.palette.success.main,T.palette.info.main],O=u&&u.length>0?u:D,k=n??Math.min(t,t)*.5-90,A=Math.max(10,k),j=A+Math.max(1,r),M=i??10/A,N=a??1/A,P=(0,c.useCallback)(e=>rr(e,_,y,b),[_,y,b]),{names:F,matrix:I}=(0,c.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]),L=(0,c.useMemo)(()=>{let e=(g?Z.chordDirected():Z.chord()).padAngle(M);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(I)},[I,M,g,o,s]),R=(0,c.useMemo)(()=>Z.arc().innerRadius(A).outerRadius(j),[A,j]),z=(0,c.useMemo)(()=>(g?Z.ribbonArrow():Z.ribbon()).radius(A-1).padAngle(N),[A,N,g]),B=(0,c.useCallback)(e=>z({source:{startAngle:e.source.startAngle,endAngle:e.source.endAngle,radius:A-1},target:{startAngle:e.target.startAngle,endAngle:e.target.endAngle,radius:A-1}})??``,[z,A]),V=(0,c.useMemo)(()=>Z.scaleOrdinal().domain(Z.range(F.length)).range(O.length>=F.length?O:[...Array(Math.ceil(F.length/O.length))].flatMap(()=>O).slice(0,F.length)),[O,F.length]),H=(0,c.useCallback)(e=>d?.[F[e]]?.fill??V(e),[d,F,V]),U=(0,c.useRef)(null),[W,G]=(0,c.useState)(`-${t/2} -${t/2} ${t} ${t}`),[K,q]=(0,c.useState)(1),J=(0,c.useMemo)(()=>{if(K===1)return W;let[e,t,n,r]=W.split(` `).map(Number),i=n/K,a=r/K;return`${e+(n-i)/2} ${t+(r-a)/2} ${i} ${a}`},[W,K]);(0,c.useLayoutEffect)(()=>{let e=U.current;if(!e)return;let n=requestAnimationFrame(()=>{try{let t=e.getBBox();G(`${t.x-8} ${t.y-8} ${t.width+16} ${t.height+16}`)}catch{G(`-${t/2} -${t/2} ${t} ${t}`)}});return()=>cancelAnimationFrame(n)},[t,A,j,F.length,L]);let[Y,X]=(0,c.useState)(null),ee=(0,c.useCallback)(e=>({name:F[e.index],index:e.index,valueOut:Z.sum(L,t=>t.source.index===e.index?t.source.value:0),valueIn:Z.sum(L,t=>t.target.index===e.index?t.source.value:0)}),[F,L]),te=(0,c.useCallback)(e=>({source:{name:F[e.source.index],index:e.source.index,value:e.source.value},target:{name:F[e.target.index],index:e.target.index,value:e.target.value}}),[F]),ne=e=>{let t=(e.startAngle+e.endAngle)/2,n=t*180/Math.PI-90,r=t>Math.PI?` rotate(180)`:``;return`rotate(${n}) translate(${j+p})${r}`},re=e=>(e.startAngle+e.endAngle)/2>Math.PI?`end`:`start`,ie=(0,c.useCallback)(e=>{if(!C||w||!e.ctrlKey)return;e.preventDefault();let t=e.deltaY<0?1.15:1/1.15;q(e=>Math.max(.25,Math.min(8,e*t)))},[C,w]);(0,c.useLayoutEffect)(()=>{if(!C)return;let e=e=>{e.key===`Escape`&&q(1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[C]);let ae={followCursor:!0,enterDelay:50,enterNextDelay:0,disableHoverListener:w,slotProps:{tooltip:{sx:{maxWidth:240}}}},oe=T.palette.text.primary,se=T.typography.fontFamily;return(0,v.jsx)(l.Box,{sx:{display:`inline-flex`,opacity:w?.5:1,cursor:w?`not-allowed`:`default`,userSelect:`none`},children:(0,v.jsx)(`svg`,{width:t,height:t,viewBox:J,onWheel:ie,style:{fontFamily:se??`sans-serif`,overflow:C&&K>1?`hidden`:`visible`},role:`img`,"aria-label":`Chord chart`,children:(0,v.jsxs)(`g`,{ref:U,children:[(0,v.jsx)(`g`,{children:L.groups.map(e=>{let t=ee(e),n=Y===e.index,r=Y!==null&&!n;return(0,v.jsx)(l.Tooltip,{...ae,title:(0,v.jsx)(ir,{name:t.name,valueOut:t.valueOut,valueIn:t.valueIn,fmt:P}),children:(0,v.jsxs)(`g`,{style:{cursor:w?`not-allowed`:`pointer`},onMouseEnter:()=>!w&&X(e.index),onMouseLeave:()=>X(null),onClick:e=>!w&&x?.(t,e),children:[(0,v.jsx)(`path`,{d:R(e)||``,fill:H(e.index),stroke:T.palette.divider,opacity:r?.35:1,style:{transition:`opacity 0.15s`}}),f&&(0,v.jsx)(`text`,{dy:`0.35em`,fontSize:11,fill:oe,transform:ne(e),textAnchor:re(e),pointerEvents:`none`,children:F[e.index]})]})},`grp-tt-${e.index}`)})}),(0,v.jsx)(`g`,{fillOpacity:m,style:{mixBlendMode:E},children:L.map((e,t)=>{let n=te(e),r=Y===null||e.source.index===Y||e.target.index===Y;return(0,v.jsx)(l.Tooltip,{...ae,title:(0,v.jsx)(ar,{sourceName:n.source.name,targetName:n.target.name,sourceValue:n.source.value,targetValue:n.target.value,directed:g,fmt:P}),children:(0,v.jsx)(`path`,{d:B(e),fill:H(e.target.index),stroke:`none`,opacity:r?1:.12,style:{cursor:w?`not-allowed`:`pointer`,transition:`opacity 0.15s`},onClick:e=>!w&&S?.(n,e)})},`chord-tt-${t}`)})})]})})})}or.displayName=`ChordChart`;var sr={noData:`No data`},cr={noData:`No data`,specialValueA:`Value A`,specialValueB:`Value B`},lr={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 ur({path:e,size:t}){let n=t/2;return(0,v.jsx)(`g`,{transform:`translate(${-n},${-n})`,pointerEvents:`none`,children:(0,v.jsx)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,overflow:`visible`,children:(0,v.jsx)(`path`,{d:e,fill:`white`})})})}function dr({info:e,labelA:t,labelB:n}){return(0,v.jsxs)(l.Box,{sx:{p:2,minWidth:200,maxWidth:280},children:[(0,v.jsxs)(l.Box,{sx:{display:`flex`,alignItems:`center`,gap:1.5,mb:1.5},children:[(0,v.jsx)(l.Avatar,{sx:{bgcolor:`primary.main`,width:40,height:40},children:e.name.charAt(0).toUpperCase()}),(0,v.jsxs)(l.Box,{children:[(0,v.jsx)(l.Typography,{variant:`body2`,sx:{fontWeight:`bold`},children:e.name}),e.subname&&(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:e.subname})]})]}),(e.specialValueA!=null||e.specialValueB!=null)&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(l.Divider,{sx:{mb:1.5}}),e.specialValueA!=null&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,mb:.5},children:[(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:t}),(0,v.jsx)(l.Typography,{variant:`caption`,children:String(e.specialValueA)})]}),e.specialValueB!=null&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`},children:[(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:n}),(0,v.jsx)(l.Typography,{variant:`caption`,children:String(e.specialValueB)})]})]})]})}function fr({data:e,size:t=600,autoFit:n=!0,sortBy:r=`name`,showLabels:i=!0,showIcons:a=!0,chartColors:o,rootNodeRadius:s=22,branchNodeRadius:u=16,leafNodeRadius:d=11,linkColor:f,linkStrokeOpacity:p=1,linkStrokeWidth:m=1.5,labelFontSize:h=12,labelColor:g,separationSibling:_=1,separationCousin:y=2,zoomable:b=!1,drillable:x=!1,onFocusChange:S,showNodePopover:C=!1,renderNodePopoverContent:w,onNodeClick:T,disabled:E=!1,translation:D}){let O=(0,l.useTheme)(),k={...cr,...D},A=[O.palette.primary.main,O.palette.secondary.main,O.palette.info.main,O.palette.success.main,O.palette.warning.main,O.palette.error.main],j=o&&o.length>0?o:A,M=(0,c.useCallback)(e=>e.depth===0?s:e.children?u:d,[s,u,d]),N=(0,c.useCallback)(e=>e.data.colorConfig?.fill??j[e.depth%j.length],[j]),[P,F]=(0,c.useState)([e]),I=P[P.length-1],[L,R]=(0,c.useState)(e);L!==e&&(R(e),F([e]));let z=Math.max(1,t/2-70),B=(0,c.useMemo)(()=>{let e=Z.hierarchy(I);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,z]).separation((e,t)=>(e.parent===t.parent?_:y)*1.4/Math.max(1,e.depth))(e)},[I,r,z,_,y]),V=B.links(),H=B.descendants(),U=(0,c.useMemo)(()=>Z.linkRadial().angle(e=>e.x).radius(e=>e.y),[]),W=(0,c.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}),[]),G=(0,c.useRef)(null),[K,q]=(0,c.useState)(`-${t/2} -${t/2} ${t} ${t}`),[J,Y]=(0,c.useState)(1);(0,c.useLayoutEffect)(()=>{let e=G.current;if(!e)return;let n=requestAnimationFrame(()=>{try{let t=e.getBBox();q(`${t.x-20} ${t.y-20} ${t.width+40} ${t.height+40}`)}catch{q(`-${t/2} -${t/2} ${t} ${t}`)}});return()=>cancelAnimationFrame(n)},[t,B,i,n]);let X=(0,c.useMemo)(()=>{if(J===1)return K;let[e,t,n,r]=K.split(` `).map(Number),i=n/J,a=r/J;return`${e+(n-i)/2} ${t+(r-a)/2} ${i} ${a}`},[K,J]),ee=(0,c.useCallback)(e=>{if(!b||E||!e.ctrlKey)return;e.preventDefault();let t=e.deltaY<0?1.15:1/1.15;Y(e=>Math.max(.25,Math.min(8,e*t)))},[b,E]);(0,c.useLayoutEffect)(()=>{if(!b&&!x)return;let t=t=>{t.key===`Escape`&&(b&&Y(1),x&&(F([e]),S?.(null)))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[b,x,e,S]);let te=(0,c.useRef)(null),ne=e=>{te.current&&=(clearTimeout(te.current),null),te.current=setTimeout(()=>{e(),te.current=null},250)},re=()=>{te.current&&=(clearTimeout(te.current),null)},[ie,ae]=(0,c.useState)(null),oe=(0,c.useRef)(null),se=(0,c.useRef)(null),[ce,le]=(0,c.useState)(!1),[ue,de]=(0,c.useState)(null),[fe,pe]=(0,c.useState)({left:0,top:0}),[me,he]=(0,c.useState)(null),ge=(0,c.useCallback)(()=>{F(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]),_e=e=>{E||!x||(e.ctrlKey||e.metaKey)&&(re(),ge())},ve=e=>{if(E)return;let t=H[Number(e.currentTarget.getAttribute(`data-idx`))];if(!t)return;let n=W(t);if((e.ctrlKey||e.metaKey)&&x&&t.children){ne(()=>{F(e=>[...e,t.data]),S?.(n)});return}if(C){let t=oe.current?.getBoundingClientRect();pe({left:t?e.clientX-t.left:e.clientX,top:t?e.clientY-t.top:e.clientY}),de(se.current),he(n),le(!0)}T?.(n,e)},ye=g||O.palette.text.primary,be=f||O.palette.text.secondary,xe=O.palette.background.paper,Se=O.typography.fontFamily;return(0,v.jsxs)(l.Box,{ref:oe,sx:{display:`inline-flex`,position:`relative`,opacity:E?.5:1,cursor:E?`not-allowed`:`default`,userSelect:`none`},children:[x&&P.length>1&&(0,v.jsx)(l.Box,{sx:{position:`absolute`,top:4,left:0,right:0,display:`flex`,justifyContent:`center`,gap:.5,pointerEvents:`none`,zIndex:1},children:(0,v.jsx)(l.Typography,{variant:`caption`,sx:{bgcolor:`action.hover`,borderRadius:1,px:1,py:.25,color:`text.secondary`,fontSize:`0.7rem`},children:P.map(e=>e.name).join(` › `)})}),(0,v.jsx)(l.Box,{ref:se,sx:{position:`absolute`,left:fe.left,top:fe.top,width:0,height:0}}),(0,v.jsx)(`svg`,{width:t,height:t,viewBox:X,onWheel:ee,style:{fontFamily:Se??`sans-serif`,overflow:b&&J>1?`hidden`:`visible`},role:`img`,"aria-label":e.name,children:(0,v.jsxs)(`g`,{ref:G,children:[(0,v.jsx)(`g`,{fill:`none`,stroke:be,strokeOpacity:p,strokeWidth:m,children:V.map((e,t)=>(0,v.jsx)(`path`,{d:U(e)},`link-${t}`))}),(0,v.jsx)(`g`,{children:H.map((e,t)=>{let n=M(e),r=N(e),i=W(e),o=ie===t,s=e.children?lr.folder:lr.person,c=Math.round(n*1.3);return(0,v.jsx)(l.Tooltip,{title:(0,v.jsxs)(l.Box,{sx:{py:.5,minWidth:160},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`,fontSize:`0.8rem`},children:e.data.name}),e.data.subname&&(0,v.jsx)(l.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:e.data.subname}),(i.specialValueA!=null||i.specialValueB!=null||e.children)&&(0,v.jsxs)(l.Box,{sx:{mt:.75,borderTop:`1px solid rgba(255,255,255,0.2)`,pt:.75},children:[i.specialValueA!=null&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{opacity:.6},children:k.specialValueA??`A`}),(0,v.jsx)(l.Typography,{variant:`caption`,children:String(i.specialValueA)})]}),i.specialValueB!=null&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{opacity:.6},children:k.specialValueB??`B`}),(0,v.jsx)(l.Typography,{variant:`caption`,children:String(i.specialValueB)})]}),e.children&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{opacity:.6},children:`Reports`}),(0,v.jsx)(l.Typography,{variant:`caption`,children:e.children.length})]})]})]}),followCursor:!0,enterDelay:50,enterNextDelay:0,disableHoverListener:E,slotProps:{tooltip:{sx:{maxWidth:260}}},children:(0,v.jsxs)(`g`,{"data-idx":t,transform:`rotate(${e.x*180/Math.PI-90}) translate(${e.y},0)`,onClick:ve,onDoubleClick:_e,onMouseEnter:()=>!E&&ae(t),onMouseLeave:()=>ae(null),style:{cursor:E?`not-allowed`:`pointer`},children:[(0,v.jsx)(`circle`,{r:Math.max(n+8,24),fill:`transparent`}),(0,v.jsx)(`circle`,{r:n+2,fill:r,fillOpacity:.15}),(0,v.jsx)(`circle`,{r:n,fill:r,fillOpacity:o?.85:1,style:{transition:`fill-opacity 0.15s`}}),a&&(0,v.jsx)(ur,{path:s,size:c})]})},`node-${e.data.id}-${t}`)})}),i&&(0,v.jsx)(`g`,{children:H.map((e,t)=>{let n=M(e),r=e.x<Math.PI==!e.children,i=n+6,a=r?i:-i,o=r?`start`:`end`;return(0,v.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:xe,strokeWidth:3,fill:ye,fontSize:h,fontWeight:e.depth===0?`bold`:`normal`,pointerEvents:`none`,children:e.data.name},`lbl-${e.data.id}-${t}`)})})]})}),C&&(0,v.jsx)(l.Popover,{open:ce,anchorEl:ue,onClose:()=>le(!1),anchorOrigin:{vertical:`top`,horizontal:`right`},transformOrigin:{vertical:`top`,horizontal:`left`},slotProps:{paper:{elevation:4}},children:me&&(w?w(me):(0,v.jsx)(dr,{info:me,labelA:k.specialValueA??`Value A`,labelB:k.specialValueB??`Value B`}))})]})}fr.displayName=`RadialTreeChart`;var pr=.56;function mr(e,t,n){return e.length*n*pr<=t?e:t>=3*n*pr+n*2?`…`:``}function hr({data:e,size:t=600,padding:n=3,sortBy:r=`value`,showLabels:i=!0,showAllLabels:a=!1,labelFontSize:o=13,innerLabelFontSize:s=9,labelColor:u,chartColors:d,depthColorStart:f,depthColorEnd:p,background:m,duration:h=750,zoomable:g=!1,disabled:_=!1,onCircleClick:y,onZoomChange:b}){let x=(0,l.useTheme)(),S=[x.palette.primary.main,x.palette.secondary.main,x.palette.error.main,x.palette.warning.main,x.palette.success.main,x.palette.info.main],C=u||x.palette.text.primary,w=m||x.palette.background.default,T=x.typography.fontFamily,E=(0,c.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]),D=E.descendants(),O=(0,c.useMemo)(()=>Z.max(D,e=>e.depth)??0,[D]),k=!!(f&&p),A=(0,c.useMemo)(()=>k?Z.scaleSequential(Z.interpolateHcl(f,p)).domain([0,Math.max(1,O)]):null,[k,f,p,O]),j=d&&d.length>0?d:S,M=(0,c.useCallback)(e=>e.data.colorConfig?.fill?e.data.colorConfig.fill:k&&A?e.children?A(e.depth):x.palette.background.paper:j[e.depth%j.length],[k,A,j,x]),[N,P]=(0,c.useState)(1),F=(0,c.useCallback)(e=>{if(!g||_||!e.ctrlKey)return;e.preventDefault();let t=e.deltaY<0?1.15:1/1.15;P(e=>Math.max(.25,Math.min(8,e*t)))},[g,_]);(0,c.useLayoutEffect)(()=>{if(!g)return;let e=e=>{e.key===`Escape`&&P(1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[g]);let I=(0,c.useMemo)(()=>{let e=`${-t/2} ${-t/2} ${t} ${t}`;if(N===1)return e;let n=t/N,r=(t-n)/2;return`${-t/2+r} ${-t/2+r} ${n} ${n}`},[t,N]),L=(0,c.useCallback)(e=>{let t=e.value??0,n=E.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}},[E]),R=(0,c.useRef)(null),z=(0,c.useRef)([E.x,E.y,E.r*2]),B=(0,c.useRef)(E),[V,H]=(0,c.useState)(E),U=(0,c.useCallback)(e=>{B.current=e,H(e)},[]),[W,G]=(0,c.useState)(e);W!==e&&(G(e),U(E),B.current=E);let K=(0,c.useCallback)(e=>{let n=R.current;if(!n)return;z.current=e;let r=t/e[2],o=B.current,c=n.querySelectorAll(`g[data-role='nodes'] > g`),l=n.querySelectorAll(`g[data-role='nodes'] > g > circle`);for(let t=0;t<D.length;t++){let n=D[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<D.length;n++){let i=D[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<D.length;n++){let i=D[n],a=t[n];if(!a)continue;let c=i.r*r,l=c*1.6,u=o===E?i!==E:i.ancestors().includes(o),d=i.parent===o;if(u&&!d&&c>=14){let t=mr(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`}}},[D,t,i,a,s,E]);(0,c.useLayoutEffect)(()=>{K([V.x,V.y,V.r*2])},[E,t,V,K]);let q=(0,c.useCallback)((e,t)=>{let n=R.current;if(!n)return;let r=V,i=z.current,a=[e.x,e.y,e.r*2];U(e),Z.select(n).transition().duration(t).ease(Z.easeCubic).tween(`zoom`,()=>{let e=Z.interpolateZoom(i,a);return t=>K(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)=>+(D[n].parent===e)).on(`start`,function(t,n){D[n].parent===e&&(this.style.display=`inline`)}).on(`end`,function(t,n){D[n].parent!==e&&(this.style.display=`none`)}),b?.({previousName:r.data.name,currentName:e.data.name,currentDepth:e.depth,isRoot:e===E})},[V,D,E,K,b,U]),J=(0,c.useRef)(null),Y=e=>{J.current&&=(clearTimeout(J.current),null),J.current=setTimeout(()=>{e(),J.current=null},250)},X=()=>{J.current&&=(clearTimeout(J.current),null)};(0,c.useLayoutEffect)(()=>{if(_)return;let e=e=>{e.key===`Escape`&&(X(),q(E,h))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[_,E,h]);let ee=e=>{if(_||!(e.ctrlKey||e.metaKey))return;X(),e.preventDefault();let t=V.parent??E;t!==V&&q(t,e.altKey?Math.max(250,h*10):h)},te={followCursor:!0,enterDelay:50,enterNextDelay:0,disableHoverListener:_,slotProps:{tooltip:{sx:{maxWidth:220}}}};return(0,v.jsxs)(l.Box,{sx:{display:`inline-flex`,position:`relative`,opacity:_?.5:1,cursor:_?`not-allowed`:`default`,userSelect:`none`},children:[(0,v.jsxs)(`svg`,{ref:R,width:t,height:t,viewBox:I,onWheel:F,style:{display:`block`,background:w,fontFamily:T??`sans-serif`,overflow:g&&N>1?`hidden`:`visible`},role:`img`,"aria-label":e.name,onDoubleClick:ee,children:[(0,v.jsx)(`g`,{"data-role":`nodes`,children:D.map((e,n)=>{let r=L(e),i=(0,v.jsxs)(l.Box,{sx:{py:.5,minWidth:160},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`,fontSize:`0.8rem`},children:e.data.name}),(e.value??0)>0&&(0,v.jsxs)(l.Box,{sx:{mt:.75,borderTop:`1px solid rgba(255,255,255,0.2)`,pt:.75},children:[(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{opacity:.6},children:`Value`}),(0,v.jsx)(l.Typography,{variant:`caption`,children:e.value?.toLocaleString()})]}),(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{opacity:.6},children:`Share`}),(0,v.jsxs)(l.Typography,{variant:`caption`,children:[r.percentage,`%`]})]}),e.children&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{opacity:.6},children:`Children`}),(0,v.jsx)(l.Typography,{variant:`caption`,children:e.children.length})]})]})]});return(0,v.jsx)(`g`,{transform:`translate(${e.x-t/2},${e.y-t/2})`,children:n===0?null:(0,v.jsx)(l.Tooltip,{...te,title:i,children:(0,v.jsx)(`circle`,{r:e.r,fill:M(e),stroke:e.data.colorConfig?.stroke??x.palette.background.paper,strokeWidth:.75,style:{cursor:_?`not-allowed`:e.children?`pointer`:`default`,transition:`stroke-width 0.1s`},onMouseEnter:e=>{_||(e.currentTarget.style.strokeWidth=`2`)},onMouseLeave:e=>{e.currentTarget.style.strokeWidth=`0.75`},onClick:t=>{if(!_){if(t.ctrlKey||t.metaKey){if(e.children){let n=t.altKey?Math.max(250,h*10):h;Y(()=>q(e,n))}return}y?.(r,t)}},onDoubleClick:e=>{if(!_&&(e.ctrlKey||e.metaKey)){X(),e.preventDefault(),e.stopPropagation();let t=V.parent??E;t!==V&&q(t,e.altKey?Math.max(250,h*10):h)}}})})},`n-${n}`)})}),i&&(0,v.jsx)(`g`,{"data-role":`labels`,textAnchor:`middle`,dominantBaseline:`middle`,pointerEvents:`none`,fontSize:o,fill:C,children:D.map((e,n)=>(0,v.jsx)(`text`,{transform:`translate(${e.x-t/2},${e.y-t/2})`,style:{display:e.parent===E?`inline`:`none`,fillOpacity:+(e.parent===E)},children:e.data.name},`lbl-${n}`))}),a&&(0,v.jsx)(`g`,{"data-role":`inner-labels`,textAnchor:`middle`,dominantBaseline:`middle`,pointerEvents:`none`,fontSize:s,fill:C,children:D.map((e,n)=>(0,v.jsx)(`text`,{transform:`translate(${e.x-t/2},${e.y-t/2})`,style:{display:`none`}},`inner-lbl-${n}`))})]}),V!==E&&!_&&(0,v.jsx)(l.Box,{sx:{position:`absolute`,bottom:6,left:0,right:0,display:`flex`,justifyContent:`center`,pointerEvents:`none`},children:(0,v.jsxs)(l.Typography,{variant:`caption`,sx:{bgcolor:`action.hover`,borderRadius:1,px:1,py:.25,color:`text.secondary`,fontSize:`0.7rem`},children:[V.ancestors().map(e=>e.data.name).reverse().join(` › `),` · Ctrl / Cmd ⌘+DblClick to zoom out · Escape to reset`]})})]})}hr.displayName=`CirclePackingChart`;var gr={noData:`No data`},_r={noData:`No data`,specialValueA:`Value A`,specialValueB:`Value B`},vr={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 yr({path:e,size:t}){let n=t/2;return(0,v.jsx)(`g`,{transform:`translate(${-n},${-n})`,pointerEvents:`none`,children:(0,v.jsx)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,overflow:`visible`,children:(0,v.jsx)(`path`,{d:e,fill:`white`})})})}function br({info:e,labelA:t,labelB:n}){return(0,v.jsxs)(l.Box,{sx:{p:2,minWidth:200,maxWidth:280},children:[(0,v.jsxs)(l.Box,{sx:{display:`flex`,alignItems:`center`,gap:1.5,mb:1.5},children:[(0,v.jsx)(l.Avatar,{sx:{bgcolor:`primary.main`,width:40,height:40},children:e.name.charAt(0).toUpperCase()}),(0,v.jsxs)(l.Box,{children:[(0,v.jsx)(l.Typography,{variant:`body2`,sx:{fontWeight:`bold`},children:e.name}),e.subname&&(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:e.subname})]})]}),(e.specialValueA!=null||e.specialValueB!=null)&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(l.Divider,{sx:{mb:1.5}}),e.specialValueA!=null&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,mb:.5},children:[(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:t}),(0,v.jsx)(l.Typography,{variant:`caption`,children:String(e.specialValueA)})]}),e.specialValueB!=null&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`},children:[(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:n}),(0,v.jsx)(l.Typography,{variant:`caption`,children:String(e.specialValueB)})]})]})]})}function xr({data:e,orientation:t=`LR`,width:n=800,height:r=500,levelSpacing:i=200,nodeRadius:a=10,sortBy:o=`name`,showLabels:s=!0,labelFontSize:u=12,labelColor:d,showIcons:f=!0,chartColors:p,linkStrokeOpacity:m=1,linkStrokeWidth:h=1.5,linkColor:g,zoomable:_=!1,drillable:y=!1,onFocusChange:b,showNodePopover:x=!1,renderNodePopoverContent:S,onNodeClick:C,disabled:w=!1,translation:T}){let E=(0,l.useTheme)(),D={..._r,...T},O=[E.palette.primary.main,E.palette.secondary.main,E.palette.error.main,E.palette.warning.main,E.palette.success.main,E.palette.info.main],k=p&&p.length>0?p:O,A=d||E.palette.text.primary,j=g||E.palette.text.secondary,M=E.palette.background.paper,N=E.typography.fontFamily,P=t===`TB`||t===`BT`,F=P?r:n,I=P?n:r,[L,R]=(0,c.useState)([e]),z=L[L.length-1],[B,V]=(0,c.useState)(e);B!==e&&(V(e),R([e]));let H=(0,c.useMemo)(()=>{let e=Z.hierarchy(z);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([F*.8,Math.min(t*i,I*.85)])(e)},[z,o,F,I,i]),U=H.descendants(),W=H.links(),G=(0,c.useCallback)(e=>e.data.colorConfig?.fill??k[e.depth%k.length],[k]),K=(0,c.useCallback)(e=>{switch(t){case`LR`:return{x:e.y,y:e.x-F*.4};case`RL`:return{x:I*.85-e.y,y:e.x-F*.4};case`TB`:return{x:e.x-F*.4,y:e.y};case`BT`:return{x:e.x-F*.4,y:I*.85-e.y}}},[t,F,I]),q=(0,c.useCallback)(e=>{let n=K(e.source),r=K(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}`},[K,t]),J=(0,c.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}),[]),[Y,X]=(0,c.useState)(`0 -${r/2} ${n} ${r}`),[ee,te]=(0,c.useState)(1),ne=(0,c.useRef)(null),re=(0,c.useMemo)(()=>{if(ee===1)return Y;let[e,t,n,r]=Y.split(` `).map(Number),i=n/ee,a=r/ee;return`${e+(n-i)/2} ${t+(r-a)/2} ${i} ${a}`},[Y,ee]);(0,c.useLayoutEffect)(()=>{let e=ne.current;if(!e)return;let t=requestAnimationFrame(()=>{try{let t=e.getBBox();X(`${t.x-24} ${t.y-24} ${t.width+48} ${t.height+48}`)}catch{X(`0 -${r/2} ${n} ${r}`)}});return()=>cancelAnimationFrame(t)},[H,n,r,t]);let ie=(0,c.useCallback)(e=>{if(!_||w||!e.ctrlKey)return;e.preventDefault();let t=e.deltaY<0?1.15:1/1.15;te(e=>Math.max(.25,Math.min(8,e*t)))},[_,w]),ae=(0,c.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)},ce=(0,c.useCallback)(()=>{R(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,c.useLayoutEffect)(()=>{if(!_&&!y)return;let t=t=>{t.key===`Escape`&&(_&&te(1),y&&(R([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)},[_,y,e,b]);let le=(0,c.useRef)(null),ue=(0,c.useRef)(null),[de,fe]=(0,c.useState)(!1),[pe,me]=(0,c.useState)(null),[he,ge]=(0,c.useState)({left:0,top:0}),[_e,ve]=(0,c.useState)(null),ye=(e,t)=>{if(w)return;let n=J(e);if((t.ctrlKey||t.metaKey)&&y&&e.children){oe(()=>{R(t=>[...t,e.data]),b?.({focusedNode:n,isRoot:!1})});return}if((t.ctrlKey||t.metaKey)&&y){se(),ce();return}if(x){let e=le.current?.getBoundingClientRect();ge({left:e?t.clientX-e.left:t.clientX,top:e?t.clientY-e.top:t.clientY}),me(ue.current),ve(n),fe(!0)}C?.(n,t)},be=(e,t)=>{w||!y||(t.ctrlKey||t.metaKey)&&(se(),ce())},xe={followCursor:!0,enterDelay:50,enterNextDelay:0,disableHoverListener:w,slotProps:{tooltip:{sx:{maxWidth:240}}}},Se=Math.round(a*1.3);return(0,v.jsxs)(l.Box,{ref:le,sx:{display:`inline-flex`,position:`relative`,opacity:w?.5:1,cursor:w?`not-allowed`:`default`,userSelect:`none`},children:[(0,v.jsx)(l.Box,{ref:ue,sx:{position:`absolute`,left:he.left,top:he.top,width:0,height:0}}),y&&L.length>1&&(0,v.jsx)(l.Box,{sx:{position:`absolute`,top:4,left:0,right:0,display:`flex`,justifyContent:`center`,pointerEvents:`none`,zIndex:1},children:(0,v.jsx)(l.Typography,{variant:`caption`,sx:{bgcolor:`action.hover`,borderRadius:1,px:1,py:.25,color:`text.secondary`,fontSize:`0.7rem`},children:L.map(e=>e.name).join(` › `)})}),(0,v.jsx)(`svg`,{width:n,height:r,viewBox:re,onWheel:ie,style:{fontFamily:N??`sans-serif`,overflow:_&&ee>1?`hidden`:`visible`},role:`img`,"aria-label":e.name,children:(0,v.jsxs)(`g`,{ref:ne,children:[(0,v.jsx)(`g`,{fill:`none`,stroke:j,strokeOpacity:m,strokeWidth:h,children:W.map((e,t)=>(0,v.jsx)(`path`,{d:q(e)},`link-${t}`))}),U.map((e,n)=>{let r=K(e),i=G(e),o=J(e),c=e.children?vr.folder:vr.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,g=d?`start`:p?`end`:`middle`,_=(0,v.jsxs)(l.Box,{sx:{py:.5,minWidth:140},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`,fontSize:`0.8rem`},children:e.data.name}),e.data.subname&&(0,v.jsx)(l.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:e.data.subname}),(o.specialValueA!=null||o.specialValueB!=null||e.children)&&(0,v.jsxs)(l.Box,{sx:{mt:.75,borderTop:`1px solid rgba(255,255,255,0.2)`,pt:.75},children:[o.specialValueA!=null&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{opacity:.6},children:D.specialValueA??`A`}),(0,v.jsx)(l.Typography,{variant:`caption`,children:String(o.specialValueA)})]}),o.specialValueB!=null&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{opacity:.6},children:D.specialValueB??`B`}),(0,v.jsx)(l.Typography,{variant:`caption`,children:String(o.specialValueB)})]}),e.children&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{opacity:.6},children:`Reports`}),(0,v.jsx)(l.Typography,{variant:`caption`,children:e.children.length})]})]})]});return(0,v.jsx)(l.Tooltip,{...xe,title:_,children:(0,v.jsxs)(`g`,{transform:`translate(${r.x},${r.y})`,onClick:t=>ye(e,t),onDoubleClick:t=>be(e,t),style:{cursor:w?`not-allowed`:`pointer`},children:[(0,v.jsx)(`circle`,{r:a+8,fill:`transparent`}),(0,v.jsx)(`circle`,{r:a+2,fill:i,fillOpacity:.15}),(0,v.jsx)(`circle`,{r:a,fill:i}),f&&(0,v.jsx)(yr,{path:c,size:Se}),s&&(0,v.jsx)(`text`,{x:m,y:h,dy:`0.35em`,textAnchor:g,fontSize:u,fontWeight:e.children?`bold`:`normal`,fill:e.data.colorConfig?.textColor??A,paintOrder:`stroke`,stroke:M,strokeWidth:3,pointerEvents:`none`,children:e.data.name})]})},`node-${n}`)})]})}),x&&(0,v.jsx)(l.Popover,{open:de,anchorEl:pe,onClose:()=>fe(!1),anchorOrigin:{vertical:`top`,horizontal:`right`},transformOrigin:{vertical:`top`,horizontal:`left`},slotProps:{paper:{elevation:4}},children:_e&&(S?S(_e):(0,v.jsx)(br,{info:_e,labelA:D.specialValueA??`Value A`,labelB:D.specialValueB??`Value B`}))})]})}xr.displayName=`HorizontalTreeChart`,exports.ChordChart=or,exports.CirclePackingChart=hr,exports.DEFAULT_CHECK_COLORS=Xt,exports.DEFAULT_CHORD_CHART_TRANSLATION=sr,exports.DEFAULT_CIRCLE_PACKING_TRANSLATION=gr,exports.DEFAULT_GANTT_TRANSLATIONS=ot,exports.DEFAULT_HORIZONTAL_TREE_TRANSLATION=_r,exports.DEFAULT_JSON_EDITOR_TOOLBAR_CONFIG=Ae,exports.DEFAULT_JSON_EDITOR_TRANSLATION=je,exports.DEFAULT_METER_COLORS=Yt,exports.DEFAULT_PASSWORD_TRANSLATIONS=Jt,exports.DEFAULT_RADIAL_TREE_CHART_TRANSLATION=cr,exports.DEFAULT_RICH_TEXT_EDITOR_TOOLBAR_CONFIG=_n,exports.DEFAULT_RICH_TEXT_EDITOR_TRANSLATION=vn,exports.DEFAULT_SQL_EDITOR_TOOLBAR_CONFIG=Pn,exports.DEFAULT_SQL_EDITOR_TRANSLATION=Fn,exports.DEFAULT_SUNBURST_CHART_TRANSLATION=nr,exports.DEFAULT_TAG_SELECTION_TRANSLATION=fn,exports.GanttChart=Wt,exports.HorizontalTreeChart=xr,exports.JsonEditor=Le,exports.PasswordStrengthMeter=$t,exports.RadialTreeChart=fr,exports.RichTextEditor=Nn,exports.SqlEditor=qn,exports.SunburstChart=tr,exports.TagSelection=gn,exports.useGanttChartStore=$,exports.useGanttTheme=zt,exports.useGanttTranslations=Lt,exports.useRawGanttChartStore=Ft;