@trii/components 3.1.5 → 3.1.7

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/esm/theme.js CHANGED
@@ -1,2 +1,605 @@
1
- import{createTheme as s}from"@mui/material";import{alpha as i,createTheme as B}from"@mui/material/styles";import{createAsyncThunk as E,createSlice as f}from"@reduxjs/toolkit";import O from"axios";const w=r=>{if(r.palette.mode!=="dark")return r;const{palette:e}=r,o=i(e.text.secondary,.5),a=i(e.text.secondary,.72);return B(r,{components:{MuiSelect:{defaultProps:{MenuProps:{PaperProps:{sx:{backgroundColor:e.background.dropdownMenu,backgroundImage:"none"}}}}},MuiTypography:{styleOverrides:{root:{color:e.text.primary}}},MuiPaper:{styleOverrides:{root:{backgroundColor:e.background.paper,backgroundImage:"none"},outlined:{borderColor:e.divider}}},MuiCard:{styleOverrides:{root:{backgroundColor:e.background.paper,backgroundImage:"none",borderColor:e.divider}}},MuiDialog:{styleOverrides:{paper:{backgroundColor:e.background.dropdownMenu,backgroundImage:"none",border:`1px solid ${e.divider}`}}},MuiDrawer:{styleOverrides:{paper:{backgroundColor:e.background.dropdownMenu,backgroundImage:"none",borderColor:e.divider}}},MuiPopover:{styleOverrides:{paper:{backgroundColor:e.background.dropdownMenu,backgroundImage:"none",border:`1px solid ${e.divider}`}}},MuiMenu:{styleOverrides:{paper:{backgroundColor:e.background.dropdownMenu,backgroundImage:"none",border:`1px solid ${e.divider}`}}},MuiOutlinedInput:{styleOverrides:{root:{backgroundColor:i(e.background.default,.34),"& .MuiOutlinedInput-notchedOutline":{borderColor:o},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:a},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:e.primary.light,borderWidth:2},"&.Mui-disabled .MuiOutlinedInput-notchedOutline":{borderColor:i(e.text.disabled,.36)}},input:{"&::placeholder":{color:e.text.disabled,opacity:1}}}},MuiInputLabel:{styleOverrides:{root:{color:e.text.secondary,"&.Mui-focused":{color:e.primary.light},"&.Mui-disabled":{color:e.text.disabled}}}},MuiButton:{styleOverrides:{root:{"&.Mui-disabled":{color:e.text.disabled,borderColor:i(e.text.disabled,.38)}},containedPrimary:{backgroundColor:e.primary.main,color:e.primary.contrastText,"&:hover":{backgroundColor:e.primary.dark}},outlined:{color:e.primary.light,borderColor:i(e.primary.light,.72),"&:hover":{color:e.primary.light,borderColor:e.primary.light,backgroundColor:i(e.primary.light,.1)}},textPrimary:{color:e.primary.light,"&:hover":{backgroundColor:i(e.primary.light,.1)}}}},MuiIconButton:{styleOverrides:{root:{color:e.text.secondary,"&:hover":{color:e.text.primary,backgroundColor:e.action.hover},"&.MuiIconButton-colorPrimary":{color:e.primary.light},"&.MuiIconButton-colorError":{color:e.error.light},"&.Mui-disabled":{color:e.text.disabled}}}},MuiChip:{styleOverrides:{root:{color:e.text.primary,backgroundColor:i(e.text.primary,.07),borderColor:o,"& .MuiChip-icon":{color:"inherit"},"&.MuiChip-colorSuccess":{color:e.success.light,backgroundColor:e.success.dark,borderColor:i(e.success.light,.46)},"&.MuiChip-colorWarning":{color:e.warning.light,backgroundColor:e.warning.dark,borderColor:i(e.warning.light,.46)},"&.MuiChip-colorError":{color:e.error.light,backgroundColor:e.error.dark,borderColor:i(e.error.light,.46)},"&.MuiChip-colorInfo":{color:e.info.light,backgroundColor:e.info.dark,borderColor:i(e.info.light,.46)}}}},MuiAlert:{styleOverrides:{root:{border:"1px solid currentColor"},standardSuccess:{color:e.success.light,backgroundColor:e.success.dark},standardWarning:{color:e.warning.light,backgroundColor:e.warning.dark},standardError:{color:e.error.light,backgroundColor:e.error.dark},standardInfo:{color:e.info.light,backgroundColor:e.info.dark}}},MuiTableHead:{styleOverrides:{root:{backgroundColor:e.cellHeader}}},MuiTableCell:{styleOverrides:{root:{borderColor:e.divider},head:{color:e.text.primary,fontWeight:700}}},MuiTableRow:{styleOverrides:{root:{"&:hover":{backgroundColor:e.action.hover},"&.Mui-selected":{backgroundColor:e.action.selected,"&:hover":{backgroundColor:e.action.selected}}}}},MuiTabs:{styleOverrides:{indicator:{backgroundColor:e.primary.light}}},MuiTab:{styleOverrides:{root:{color:e.text.secondary,"&.Mui-selected":{color:e.primary.light}}}},MuiSwitch:{styleOverrides:{switchBase:{color:e.text.disabled,"&.Mui-checked":{color:e.primary.light,"& + .MuiSwitch-track":{backgroundColor:e.primary.light,opacity:.5}}},track:{backgroundColor:e.text.disabled,opacity:.34}}},MuiTooltip:{styleOverrides:{tooltip:{color:e.text.primary,backgroundColor:e.background.tooltip,border:`1px solid ${o}`},arrow:{color:e.background.tooltip}}},MuiDivider:{styleOverrides:{root:{borderColor:e.divider}}},MuiLink:{styleOverrides:{root:{color:e.primary.light}}}}})},A=(r,e={})=>{const{transparentModal:o=!1,autocompleteZIndex:a=11}=e,l=r.palette.background,d=s({...r,components:{MuiSelect:{defaultProps:{MenuProps:{PaperProps:{sx:{backgroundColor:l.panel,backgroundImage:"linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.05))"}}}}},MuiAutocomplete:{styleOverrides:{popper:{zIndex:a,"& div":{backgroundColor:l.panel}}}},MuiPaper:{styleOverrides:{root:{backgroundColor:l.panel,backgroundImage:"linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.05))"}}},MuiMenu:{styleOverrides:{paper:{backgroundColor:l.panel,backgroundImage:"linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.05))"}}},MuiList:{styleOverrides:{root:{padding:0}}},MuiModal:{styleOverrides:{root:o?{background:"transparent","& .MuiBackdrop-root":{background:"transparent",border:"none"}}:{}}},MuiTypography:{styleOverrides:{root:{color:r.palette.text.primary}}},MuiChip:{styleOverrides:{root:{color:r.palette.text.primary,border:"1px solid rgba(0, 0, 0, 0.1)",borderRadius:"4px",height:"20px",fontSize:"0.7125rem"}}},MuiListSubheader:{styleOverrides:{root:{backgroundColor:l.accordionHeader}}},MuiButton:{styleOverrides:{outlined:{color:r.palette.mode==="light"?r.palette.primary.dark:r.palette.primary.light,borderColor:r.palette.mode==="light"?r.palette.primary.dark:r.palette.primary.light,"&:hover":{borderColor:r.palette.mode==="light"?r.palette.primary.main:r.palette.primary.light,color:r.palette.mode==="light"?r.palette.primary.main:r.palette.primary.light}}}}}});return w(d)},h={main:"#246FB5",light:"#78B7F2",dark:"#195A96",contrastText:"#FFFFFF"},t=s({name:"light",palette:{mode:"light",contrastThreshold:4.5,primary:h,secondary:{main:"#526078",light:"#728099",dark:"#38445A",contrastText:"#FFFFFF"},error:{main:"#BD3446",light:"#FCECEF",dark:"#932536",contrastText:"#FFFFFF"},warning:{main:"#946000",light:"#FFF5DF",dark:"#704800",contrastText:"#FFFFFF"},info:{main:"#176B9B",light:"#EAF4FC",dark:"#125174",contrastText:"#FFFFFF"},success:{main:"#237547",light:"#EAF6EE",dark:"#185935",contrastText:"#FFFFFF"},background:{default:"#F4F6FA",paper:"#FFFFFF",mainCenter:"#F4F6FA",mainGradient:"linear-gradient(120deg, #195A96, #246FB5)",navMenu:"#EDF1F7",dropdownMenu:"#FFFFFF",panel:"#FFFFFF",tooltip:"#EDF1F7",accordionHeader:"#EDF1F7",panelHeader:"#EDF1F7",panelCenter:"#F8FAFD",panelGradient:"#EDF1F7",selectedItem:"#E5EFFA"},text:{primary:"#202C3E",secondary:"#526078",disabled:"#7C8798",colorMain:"#202C3E"},action:{active:"#526078",hover:"rgba(36, 111, 181, 0.06)",selected:"rgba(36, 111, 181, 0.12)",disabled:"#8893A3",disabledBackground:"#E8ECF2"},divider:"#D7DEE9",containerBox:{default:"#FFFFFF",main:"#F8FAFD"},dropdownBox:"#FFFFFF",color:{icons:"#526078"},cellHeader:"#EDF1F7",Skeleton:{bg:"#E4EAF2"},messageBox:"#E5EFFA",boxShadow:"rgba(25, 42, 66, 0.12)",disabled:"#8893A3"}}),n=s({name:"dark",palette:{mode:"dark",contrastThreshold:4.5,primary:h,secondary:{main:"#B7B5D9",light:"#D6D4EF",dark:"#46415F",contrastText:"#171824"},error:{main:"#F06B7A",light:"#FF9AA8",dark:"#4A1D24",contrastText:"#2B0D12"},warning:{main:"#E5A93B",light:"#FFD27A",dark:"#493515",contrastText:"#2A1B05"},info:{main:"#4FAFE8",light:"#7CCBFF",dark:"#123955",contrastText:"#082033"},success:{main:"#43C17A",light:"#75E0A7",dark:"#143D2B",contrastText:"#092116"},background:{default:"#111520",paper:"#1B2333",mainCenter:"#151C2A",mainGradient:"linear-gradient(120deg, #131B2B, #242237)",navMenu:"#0E121C",dropdownMenu:"#252D40",panel:"#1B2333",tooltip:"#30384F",accordionHeader:"#20283A",panelHeader:"#20283A",panelCenter:"#222B3E",panelGradient:"#2C2B40",selectedItem:"#293E59"},text:{primary:"#F1F4FA",secondary:"#BBC6D8",disabled:"#8793A6",colorMain:"#F1F4FA"},action:{active:"#BBC6D8",hover:"rgba(241, 244, 250, 0.07)",selected:"rgba(120, 183, 242, 0.16)",disabled:"rgba(187, 198, 216, 0.45)",disabledBackground:"rgba(187, 198, 216, 0.10)"},divider:"rgba(187, 198, 216, 0.22)",containerBox:{default:"#1B2333",main:"#222B3E"},dropdownBox:"#252D40",color:{icons:"#BBC6D8"},cellHeader:"#20283A",Skeleton:{bg:"#30384F"},messageBox:"#203953",boxShadow:"rgba(0, 0, 0, 0.40)",disabled:"rgba(187, 198, 216, 0.45)"}}),I={...t,name:"lightBlueIndigo"},S={...t,name:"lightBlue"},D={...t,name:"lightRed"},P={...t,name:"lightGreen"},L={...t,name:"lightPink"},G={...t,name:"lightPurple"},H={...t,name:"lightTeal"},R={...t,name:"lightLime"},$={...t,name:"lightYellow"},W={...t,name:"lightAmber"},N={...t,name:"lightOrange"},Y={...t,name:"lightBrown"},j={...t,name:"lightGray"},z={...n,name:"darkBlue"},_={...n,name:"darkBlack"},p=["light","dark","system"],m=["lightBlueIndigo","lightBlue","lightRed","lightGreen","lightPink","lightPurple","lightTeal","lightLime","lightYellow","lightAmber","lightOrange","lightBrown","lightGray","darkBlue","darkBlack"],b=r=>p.includes(r)||m.includes(r),g=r=>r==="light"||r==="dark"||r==="system"?r:r&&m.includes(r)?r.startsWith("dark")?"dark":"light":"system",k=()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(prefers-color-scheme: dark)"):void 0,c=(r,e=k()?.matches??!1)=>r==="system"?e?"dark":"light":r,J=(r,e)=>{if(r!=="system")return e(r),()=>{};const o=k();if(e(c(r,o?.matches??!1)),!o)return()=>{};const a=l=>e(l.matches?"dark":"light");return typeof o.addEventListener=="function"?(o.addEventListener("change",a),()=>o.removeEventListener("change",a)):(o.addListener(a),()=>o.removeListener(a))},F="trii-theme",U=r=>`https://agent-api.trii.app/api/v1/settings/${r}/user/setTheme`,V=()=>{try{return g(localStorage.getItem(F))}catch{return"system"}},Z=r=>{try{localStorage.setItem(F,r)}catch{}},y=V(),C=c(y),q={themeSelected:C==="dark"?n:t,preference:y,darkMode:C==="dark",toggleStatus:"idle"},M=E("Theme/updateTheme",async(r,{getState:e})=>{const{uid:o="",spaceId:a=""}=e().User.user??{},l=JSON.stringify({theme:r,uid:o}),d=await O.put(U(a),l,{headers:{"Content-Type":"application/json"}});if(!b(d.data.theme))throw new Error("Invalid theme response");return d.data}),v=f({name:"Theme",initialState:q,reducers:{toggleTheme:(r,e)=>{u(r,e.payload)},systemThemeChanged:(r,e)=>{r.preference==="system"&&Object.assign(r,{themeSelected:e.payload==="dark"?n:t,darkMode:e.payload==="dark",toggleStatus:"toggled"})},toggleModeTheme:r=>{u(r,r.darkMode?"light":"dark")}},extraReducers:r=>{r.addCase(M.fulfilled,(e,o)=>{u(e,o.payload.theme)})}});function u(r,e){const o=g(e),a=c(o);Z(e);const l=a==="dark"?n:t,d=e==="system"||e==="light"||e==="dark"?l:{...l,name:e};Object.assign(r,{preference:o,themeSelected:d,darkMode:a==="dark",toggleStatus:"toggled"})}const K=r=>r.Theme.preference,{toggleTheme:Q,toggleModeTheme:X,systemThemeChanged:ee}=v.actions,re=r=>r.Theme.toggleStatus,T=r=>r.Theme.themeSelected,x=r=>r.Theme.darkMode,oe=T,te=x;var ae=v.reducer;export{A as MuiComponentsConfig,p as THEME_PREFERENCES,_ as darkBlack,z as darkBlue,n as darkTheme,b as isValidThemeName,W as lightAmber,S as lightBlue,I as lightBlueIndigo,Y as lightBrown,j as lightGray,P as lightGreen,R as lightLime,N as lightOrange,L as lightPink,G as lightPurple,D as lightRed,H as lightTeal,t as lightTheme,$ as lightYellow,g as normalizeThemePreference,J as observeThemePreference,c as resolveThemePreference,x as selectDarkTheme,T as selectTheme,K as selectThemePreference,re as selectThemeToggleStatus,te as selectedDarkTheme,oe as selectedTheme,ee as systemThemeChanged,ae as themeReducer,X as toggleModeTheme,Q as toggleTheme,M as updateTheme};
1
+ import { createTheme as createTheme$1 } from '@mui/material';
2
+ import { alpha, createTheme } from '@mui/material/styles';
3
+ import { createAction, createAsyncThunk, createSlice } from '@reduxjs/toolkit';
4
+ import axios from 'axios';
5
+
6
+ const applyDarkThemeComponents = (sharedTheme) => {
7
+ if (sharedTheme.palette.mode !== "dark") return sharedTheme;
8
+ const { palette } = sharedTheme;
9
+ const strongOutline = alpha(palette.text.secondary, 0.5);
10
+ const hoverOutline = alpha(palette.text.secondary, 0.72);
11
+ return createTheme(sharedTheme, {
12
+ components: {
13
+ MuiSelect: {
14
+ defaultProps: {
15
+ MenuProps: {
16
+ PaperProps: {
17
+ sx: {
18
+ backgroundColor: palette.background.dropdownMenu,
19
+ backgroundImage: "none"
20
+ }
21
+ }
22
+ }
23
+ }
24
+ },
25
+ MuiTypography: {
26
+ styleOverrides: {
27
+ // El microfrontend no controla el color del body de root. Mantener
28
+ // un foreground explícito evita heredar texto oscuro del shell.
29
+ root: { color: palette.text.primary }
30
+ }
31
+ },
32
+ MuiPaper: {
33
+ styleOverrides: {
34
+ root: {
35
+ backgroundColor: palette.background.paper,
36
+ backgroundImage: "none"
37
+ },
38
+ outlined: {
39
+ borderColor: palette.divider
40
+ }
41
+ }
42
+ },
43
+ MuiCard: {
44
+ styleOverrides: {
45
+ root: {
46
+ backgroundColor: palette.background.paper,
47
+ backgroundImage: "none",
48
+ borderColor: palette.divider
49
+ }
50
+ }
51
+ },
52
+ MuiDialog: {
53
+ styleOverrides: {
54
+ paper: {
55
+ backgroundColor: palette.background.dropdownMenu,
56
+ backgroundImage: "none",
57
+ border: `1px solid ${palette.divider}`
58
+ }
59
+ }
60
+ },
61
+ MuiDrawer: {
62
+ styleOverrides: {
63
+ paper: {
64
+ backgroundColor: palette.background.dropdownMenu,
65
+ backgroundImage: "none",
66
+ borderColor: palette.divider
67
+ }
68
+ }
69
+ },
70
+ MuiPopover: {
71
+ styleOverrides: {
72
+ paper: {
73
+ backgroundColor: palette.background.dropdownMenu,
74
+ backgroundImage: "none",
75
+ border: `1px solid ${palette.divider}`
76
+ }
77
+ }
78
+ },
79
+ MuiMenu: {
80
+ styleOverrides: {
81
+ paper: {
82
+ backgroundColor: palette.background.dropdownMenu,
83
+ backgroundImage: "none",
84
+ border: `1px solid ${palette.divider}`
85
+ }
86
+ }
87
+ },
88
+ MuiOutlinedInput: {
89
+ styleOverrides: {
90
+ root: {
91
+ backgroundColor: alpha(palette.background.default, 0.34),
92
+ "& .MuiOutlinedInput-notchedOutline": {
93
+ borderColor: strongOutline
94
+ },
95
+ "&:hover .MuiOutlinedInput-notchedOutline": {
96
+ borderColor: hoverOutline
97
+ },
98
+ "&.Mui-focused .MuiOutlinedInput-notchedOutline": {
99
+ borderColor: palette.primary.light,
100
+ borderWidth: 2
101
+ },
102
+ "&.Mui-disabled .MuiOutlinedInput-notchedOutline": {
103
+ borderColor: alpha(palette.text.disabled, 0.36)
104
+ }
105
+ },
106
+ input: {
107
+ "&::placeholder": {
108
+ color: palette.text.disabled,
109
+ opacity: 1
110
+ }
111
+ }
112
+ }
113
+ },
114
+ MuiInputLabel: {
115
+ styleOverrides: {
116
+ root: {
117
+ color: palette.text.secondary,
118
+ "&.Mui-focused": { color: palette.primary.light },
119
+ "&.Mui-disabled": { color: palette.text.disabled }
120
+ }
121
+ }
122
+ },
123
+ MuiButton: {
124
+ styleOverrides: {
125
+ root: {
126
+ "&.Mui-disabled": {
127
+ color: palette.text.disabled,
128
+ borderColor: alpha(palette.text.disabled, 0.38)
129
+ }
130
+ },
131
+ containedPrimary: {
132
+ backgroundColor: palette.primary.main,
133
+ color: palette.primary.contrastText,
134
+ "&:hover": { backgroundColor: palette.primary.dark }
135
+ },
136
+ outlined: {
137
+ color: palette.primary.light,
138
+ borderColor: alpha(palette.primary.light, 0.72),
139
+ "&:hover": {
140
+ color: palette.primary.light,
141
+ borderColor: palette.primary.light,
142
+ backgroundColor: alpha(palette.primary.light, 0.1)
143
+ }
144
+ },
145
+ textPrimary: {
146
+ color: palette.primary.light,
147
+ "&:hover": {
148
+ backgroundColor: alpha(palette.primary.light, 0.1)
149
+ }
150
+ }
151
+ }
152
+ },
153
+ MuiIconButton: {
154
+ styleOverrides: {
155
+ root: {
156
+ color: palette.text.secondary,
157
+ "&:hover": {
158
+ color: palette.text.primary,
159
+ backgroundColor: palette.action.hover
160
+ },
161
+ "&.MuiIconButton-colorPrimary": { color: palette.primary.light },
162
+ "&.MuiIconButton-colorError": { color: palette.error.light },
163
+ "&.Mui-disabled": { color: palette.text.disabled }
164
+ }
165
+ }
166
+ },
167
+ MuiChip: {
168
+ styleOverrides: {
169
+ root: {
170
+ color: palette.text.primary,
171
+ backgroundColor: alpha(palette.text.primary, 0.07),
172
+ borderColor: strongOutline,
173
+ "& .MuiChip-icon": { color: "inherit" },
174
+ "&.MuiChip-colorSuccess": {
175
+ color: palette.success.light,
176
+ backgroundColor: palette.success.dark,
177
+ borderColor: alpha(palette.success.light, 0.46)
178
+ },
179
+ "&.MuiChip-colorWarning": {
180
+ color: palette.warning.light,
181
+ backgroundColor: palette.warning.dark,
182
+ borderColor: alpha(palette.warning.light, 0.46)
183
+ },
184
+ "&.MuiChip-colorError": {
185
+ color: palette.error.light,
186
+ backgroundColor: palette.error.dark,
187
+ borderColor: alpha(palette.error.light, 0.46)
188
+ },
189
+ "&.MuiChip-colorInfo": {
190
+ color: palette.info.light,
191
+ backgroundColor: palette.info.dark,
192
+ borderColor: alpha(palette.info.light, 0.46)
193
+ }
194
+ }
195
+ }
196
+ },
197
+ MuiAlert: {
198
+ styleOverrides: {
199
+ root: { border: "1px solid currentColor" },
200
+ standardSuccess: {
201
+ color: palette.success.light,
202
+ backgroundColor: palette.success.dark
203
+ },
204
+ standardWarning: {
205
+ color: palette.warning.light,
206
+ backgroundColor: palette.warning.dark
207
+ },
208
+ standardError: {
209
+ color: palette.error.light,
210
+ backgroundColor: palette.error.dark
211
+ },
212
+ standardInfo: {
213
+ color: palette.info.light,
214
+ backgroundColor: palette.info.dark
215
+ }
216
+ }
217
+ },
218
+ MuiTableHead: {
219
+ styleOverrides: {
220
+ root: { backgroundColor: palette.cellHeader }
221
+ }
222
+ },
223
+ MuiTableCell: {
224
+ styleOverrides: {
225
+ root: { borderColor: palette.divider },
226
+ head: { color: palette.text.primary, fontWeight: 700 }
227
+ }
228
+ },
229
+ MuiTableRow: {
230
+ styleOverrides: {
231
+ root: {
232
+ "&:hover": { backgroundColor: palette.action.hover },
233
+ "&.Mui-selected": {
234
+ backgroundColor: palette.action.selected,
235
+ "&:hover": { backgroundColor: palette.action.selected }
236
+ }
237
+ }
238
+ }
239
+ },
240
+ MuiTabs: {
241
+ styleOverrides: {
242
+ indicator: { backgroundColor: palette.primary.light }
243
+ }
244
+ },
245
+ MuiTab: {
246
+ styleOverrides: {
247
+ root: {
248
+ color: palette.text.secondary,
249
+ "&.Mui-selected": { color: palette.primary.light }
250
+ }
251
+ }
252
+ },
253
+ MuiSwitch: {
254
+ styleOverrides: {
255
+ switchBase: {
256
+ color: palette.text.disabled,
257
+ "&.Mui-checked": {
258
+ color: palette.primary.light,
259
+ "& + .MuiSwitch-track": {
260
+ backgroundColor: palette.primary.light,
261
+ opacity: 0.5
262
+ }
263
+ }
264
+ },
265
+ track: {
266
+ backgroundColor: palette.text.disabled,
267
+ opacity: 0.34
268
+ }
269
+ }
270
+ },
271
+ MuiTooltip: {
272
+ styleOverrides: {
273
+ tooltip: {
274
+ color: palette.text.primary,
275
+ backgroundColor: palette.background.tooltip,
276
+ border: `1px solid ${strongOutline}`
277
+ },
278
+ arrow: { color: palette.background.tooltip }
279
+ }
280
+ },
281
+ MuiDivider: {
282
+ styleOverrides: {
283
+ root: { borderColor: palette.divider }
284
+ }
285
+ },
286
+ MuiLink: {
287
+ styleOverrides: {
288
+ root: { color: palette.primary.light }
289
+ }
290
+ }
291
+ }
292
+ });
293
+ };
294
+
295
+ const MuiComponentsConfig = (themeRedux, options = {}) => {
296
+ const { transparentModal = false, autocompleteZIndex = 11 } = options;
297
+ const bg = themeRedux.palette.background;
298
+ const sharedTheme = createTheme$1({
299
+ ...themeRedux,
300
+ components: {
301
+ MuiSelect: {
302
+ defaultProps: {
303
+ MenuProps: {
304
+ PaperProps: {
305
+ sx: {
306
+ backgroundColor: bg.panel,
307
+ backgroundImage: "linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.05))"
308
+ }
309
+ }
310
+ }
311
+ }
312
+ },
313
+ MuiAutocomplete: {
314
+ styleOverrides: {
315
+ popper: {
316
+ zIndex: autocompleteZIndex,
317
+ "& div": {
318
+ backgroundColor: bg.panel
319
+ }
320
+ }
321
+ }
322
+ },
323
+ MuiPaper: {
324
+ styleOverrides: {
325
+ root: {
326
+ backgroundColor: bg.panel,
327
+ backgroundImage: "linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.05))"
328
+ }
329
+ }
330
+ },
331
+ MuiMenu: {
332
+ styleOverrides: {
333
+ paper: {
334
+ backgroundColor: bg.panel,
335
+ backgroundImage: "linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.05))"
336
+ }
337
+ }
338
+ },
339
+ MuiList: {
340
+ styleOverrides: {
341
+ root: {
342
+ padding: 0
343
+ }
344
+ }
345
+ },
346
+ MuiModal: {
347
+ styleOverrides: {
348
+ root: transparentModal ? {
349
+ background: "transparent",
350
+ "& .MuiBackdrop-root": {
351
+ background: "transparent",
352
+ border: "none"
353
+ }
354
+ } : {}
355
+ }
356
+ },
357
+ MuiTypography: {
358
+ styleOverrides: {
359
+ root: {
360
+ color: themeRedux.palette.text.primary
361
+ }
362
+ }
363
+ },
364
+ MuiChip: {
365
+ styleOverrides: {
366
+ root: {
367
+ color: themeRedux.palette.text.primary,
368
+ border: "1px solid rgba(0, 0, 0, 0.1)",
369
+ borderRadius: "4px",
370
+ height: "20px",
371
+ fontSize: "0.7125rem"
372
+ }
373
+ }
374
+ },
375
+ MuiListSubheader: {
376
+ styleOverrides: {
377
+ root: {
378
+ backgroundColor: bg.accordionHeader
379
+ }
380
+ }
381
+ },
382
+ MuiButton: {
383
+ styleOverrides: {
384
+ outlined: {
385
+ color: themeRedux.palette.mode === "light" ? themeRedux.palette.primary.dark : themeRedux.palette.primary.light,
386
+ borderColor: themeRedux.palette.mode === "light" ? themeRedux.palette.primary.dark : themeRedux.palette.primary.light,
387
+ "&:hover": {
388
+ borderColor: themeRedux.palette.mode === "light" ? themeRedux.palette.primary.main : themeRedux.palette.primary.light,
389
+ color: themeRedux.palette.mode === "light" ? themeRedux.palette.primary.main : themeRedux.palette.primary.light
390
+ }
391
+ }
392
+ }
393
+ }
394
+ }
395
+ });
396
+ return applyDarkThemeComponents(sharedTheme);
397
+ };
398
+
399
+ const UPDATE_THEME_TYPE = "Theme/updateTheme";
400
+ const themeUpdateFulfilled = /* @__PURE__ */ createAction(
401
+ `${UPDATE_THEME_TYPE}/fulfilled`
402
+ );
403
+
404
+ const THEME_PREFERENCES = ["light", "dark", "system"];
405
+ const LEGACY_THEME_NAMES = ["lightBlueIndigo", "lightBlue", "lightRed", "lightGreen", "lightPink", "lightPurple", "lightTeal", "lightLime", "lightYellow", "lightAmber", "lightOrange", "lightBrown", "lightGray", "darkBlue", "darkBlack"];
406
+ const isValidThemeName = (name) => THEME_PREFERENCES.includes(name) || LEGACY_THEME_NAMES.includes(name);
407
+ const normalizeThemePreference = (name) => {
408
+ if (name === "light" || name === "dark" || name === "system") return name;
409
+ if (name && LEGACY_THEME_NAMES.includes(name)) return name.startsWith("dark") ? "dark" : "light";
410
+ return "system";
411
+ };
412
+ const systemMedia = () => typeof window !== "undefined" && typeof window.matchMedia === "function" ? window.matchMedia("(prefers-color-scheme: dark)") : void 0;
413
+ const resolveThemePreference = (preference, systemDark = systemMedia()?.matches ?? false) => preference === "system" ? systemDark ? "dark" : "light" : preference;
414
+ const observeThemePreference = (preference, listener) => {
415
+ if (preference !== "system") {
416
+ listener(preference);
417
+ return () => {
418
+ };
419
+ }
420
+ const media = systemMedia();
421
+ listener(resolveThemePreference(preference, media?.matches ?? false));
422
+ if (!media) return () => {
423
+ };
424
+ const change = (event) => listener(event.matches ? "dark" : "light");
425
+ if (typeof media.addEventListener === "function") {
426
+ media.addEventListener("change", change);
427
+ return () => media.removeEventListener("change", change);
428
+ }
429
+ media.addListener(change);
430
+ return () => media.removeListener(change);
431
+ };
432
+
433
+ const themeUrl = (spaceId) => `https://agent-api.trii.app/api/v1/settings/${spaceId}/user/setTheme`;
434
+ const updateTheme = /* @__PURE__ */ createAsyncThunk(UPDATE_THEME_TYPE, async (theme, { getState }) => {
435
+ const { uid = "", spaceId = "" } = getState().User.user ?? {};
436
+ const themeJson = JSON.stringify({ theme, uid });
437
+ const response = await axios.put(
438
+ themeUrl(spaceId),
439
+ themeJson,
440
+ { headers: { "Content-Type": "application/json" } }
441
+ );
442
+ if (!isValidThemeName(response.data.theme)) throw new Error("Invalid theme response");
443
+ return response.data;
444
+ });
445
+
446
+ const primary = { main: "#246FB5", light: "#78B7F2", dark: "#195A96", contrastText: "#FFFFFF" };
447
+ const lightTheme = createTheme$1({
448
+ name: "light",
449
+ palette: {
450
+ mode: "light",
451
+ contrastThreshold: 4.5,
452
+ primary,
453
+ secondary: { main: "#526078", light: "#728099", dark: "#38445A", contrastText: "#FFFFFF" },
454
+ error: { main: "#BD3446", light: "#FCECEF", dark: "#932536", contrastText: "#FFFFFF" },
455
+ warning: { main: "#946000", light: "#FFF5DF", dark: "#704800", contrastText: "#FFFFFF" },
456
+ info: { main: "#176B9B", light: "#EAF4FC", dark: "#125174", contrastText: "#FFFFFF" },
457
+ success: { main: "#237547", light: "#EAF6EE", dark: "#185935", contrastText: "#FFFFFF" },
458
+ background: {
459
+ default: "#F4F6FA",
460
+ paper: "#FFFFFF",
461
+ mainCenter: "#F4F6FA",
462
+ mainGradient: "linear-gradient(120deg, #195A96, #246FB5)",
463
+ navMenu: "#EDF1F7",
464
+ dropdownMenu: "#FFFFFF",
465
+ panel: "#FFFFFF",
466
+ tooltip: "#EDF1F7",
467
+ accordionHeader: "#EDF1F7",
468
+ panelHeader: "#EDF1F7",
469
+ panelCenter: "#F8FAFD",
470
+ panelGradient: "#EDF1F7",
471
+ selectedItem: "#E5EFFA"
472
+ },
473
+ text: { primary: "#202C3E", secondary: "#526078", disabled: "#7C8798", colorMain: "#202C3E" },
474
+ action: { active: "#526078", hover: "rgba(36, 111, 181, 0.06)", selected: "rgba(36, 111, 181, 0.12)", disabled: "#8893A3", disabledBackground: "#E8ECF2" },
475
+ divider: "#D7DEE9",
476
+ containerBox: { default: "#FFFFFF", main: "#F8FAFD" },
477
+ dropdownBox: "#FFFFFF",
478
+ color: { icons: "#526078" },
479
+ cellHeader: "#EDF1F7",
480
+ Skeleton: { bg: "#E4EAF2" },
481
+ messageBox: "#E5EFFA",
482
+ boxShadow: "rgba(25, 42, 66, 0.12)",
483
+ disabled: "#8893A3"
484
+ }
485
+ });
486
+ const darkTheme = createTheme$1({
487
+ name: "dark",
488
+ palette: {
489
+ mode: "dark",
490
+ contrastThreshold: 4.5,
491
+ primary,
492
+ secondary: { main: "#B7B5D9", light: "#D6D4EF", dark: "#46415F", contrastText: "#171824" },
493
+ error: { main: "#F06B7A", light: "#FF9AA8", dark: "#4A1D24", contrastText: "#2B0D12" },
494
+ warning: { main: "#E5A93B", light: "#FFD27A", dark: "#493515", contrastText: "#2A1B05" },
495
+ info: { main: "#4FAFE8", light: "#7CCBFF", dark: "#123955", contrastText: "#082033" },
496
+ success: { main: "#43C17A", light: "#75E0A7", dark: "#143D2B", contrastText: "#092116" },
497
+ background: {
498
+ default: "#111520",
499
+ paper: "#1B2333",
500
+ mainCenter: "#151C2A",
501
+ mainGradient: "linear-gradient(120deg, #131B2B, #242237)",
502
+ navMenu: "#0E121C",
503
+ dropdownMenu: "#252D40",
504
+ panel: "#1B2333",
505
+ tooltip: "#30384F",
506
+ accordionHeader: "#20283A",
507
+ panelHeader: "#20283A",
508
+ panelCenter: "#222B3E",
509
+ panelGradient: "#2C2B40",
510
+ selectedItem: "#293E59"
511
+ },
512
+ text: { primary: "#F1F4FA", secondary: "#BBC6D8", disabled: "#8793A6", colorMain: "#F1F4FA" },
513
+ action: { active: "#BBC6D8", hover: "rgba(241, 244, 250, 0.07)", selected: "rgba(120, 183, 242, 0.16)", disabled: "rgba(187, 198, 216, 0.45)", disabledBackground: "rgba(187, 198, 216, 0.10)" },
514
+ divider: "rgba(187, 198, 216, 0.22)",
515
+ containerBox: { default: "#1B2333", main: "#222B3E" },
516
+ dropdownBox: "#252D40",
517
+ color: { icons: "#BBC6D8" },
518
+ cellHeader: "#20283A",
519
+ Skeleton: { bg: "#30384F" },
520
+ messageBox: "#203953",
521
+ boxShadow: "rgba(0, 0, 0, 0.40)",
522
+ disabled: "rgba(187, 198, 216, 0.45)"
523
+ }
524
+ });
525
+ const lightBlueIndigo = { ...lightTheme, name: "lightBlueIndigo" };
526
+ const lightBlue = { ...lightTheme, name: "lightBlue" };
527
+ const lightRed = { ...lightTheme, name: "lightRed" };
528
+ const lightGreen = { ...lightTheme, name: "lightGreen" };
529
+ const lightPink = { ...lightTheme, name: "lightPink" };
530
+ const lightPurple = { ...lightTheme, name: "lightPurple" };
531
+ const lightTeal = { ...lightTheme, name: "lightTeal" };
532
+ const lightLime = { ...lightTheme, name: "lightLime" };
533
+ const lightYellow = { ...lightTheme, name: "lightYellow" };
534
+ const lightAmber = { ...lightTheme, name: "lightAmber" };
535
+ const lightOrange = { ...lightTheme, name: "lightOrange" };
536
+ const lightBrown = { ...lightTheme, name: "lightBrown" };
537
+ const lightGray = { ...lightTheme, name: "lightGray" };
538
+ const darkBlue = { ...darkTheme, name: "darkBlue" };
539
+ const darkBlack = { ...darkTheme, name: "darkBlack" };
540
+
541
+ const THEME_STORAGE_KEY = "trii-theme";
542
+ const getSavedPreference = () => {
543
+ try {
544
+ return normalizeThemePreference(localStorage.getItem(THEME_STORAGE_KEY));
545
+ } catch {
546
+ return "system";
547
+ }
548
+ };
549
+ const saveTheme = (theme) => {
550
+ try {
551
+ localStorage.setItem(THEME_STORAGE_KEY, theme);
552
+ } catch {
553
+ }
554
+ };
555
+ const savedPreference = getSavedPreference();
556
+ const savedMode = resolveThemePreference(savedPreference);
557
+ const initialState = {
558
+ themeSelected: savedMode === "dark" ? darkTheme : lightTheme,
559
+ preference: savedPreference,
560
+ darkMode: savedMode === "dark",
561
+ toggleStatus: "idle"
562
+ };
563
+ const themeSlice = createSlice({
564
+ name: "Theme",
565
+ initialState,
566
+ reducers: {
567
+ /** Cambia el tema por nombre. */
568
+ toggleTheme: (state, action) => {
569
+ applyPreference(state, action.payload);
570
+ },
571
+ /** Local update from observeThemePreference; never overwrite the saved system choice. */
572
+ systemThemeChanged: (state, action) => {
573
+ if (state.preference !== "system") return;
574
+ Object.assign(state, { themeSelected: action.payload === "dark" ? darkTheme : lightTheme, darkMode: action.payload === "dark", toggleStatus: "toggled" });
575
+ },
576
+ /** Alterna el modo oscuro. */
577
+ toggleModeTheme: (state) => {
578
+ applyPreference(state, state.darkMode ? "light" : "dark");
579
+ }
580
+ },
581
+ extraReducers: (builder) => {
582
+ builder.addCase(themeUpdateFulfilled, (state, action) => {
583
+ applyPreference(state, action.payload.theme);
584
+ });
585
+ }
586
+ });
587
+ function applyPreference(state, name) {
588
+ const preference = normalizeThemePreference(name);
589
+ const mode = resolveThemePreference(preference);
590
+ saveTheme(name);
591
+ const base = mode === "dark" ? darkTheme : lightTheme;
592
+ const themeSelected = name === "system" || name === "light" || name === "dark" ? base : { ...base, name };
593
+ Object.assign(state, { preference, themeSelected, darkMode: mode === "dark", toggleStatus: "toggled" });
594
+ }
595
+ const selectThemePreference = (state) => state.Theme.preference;
596
+ const { toggleTheme, toggleModeTheme, systemThemeChanged } = themeSlice.actions;
597
+ const selectThemeToggleStatus = (state) => state.Theme.toggleStatus;
598
+ const selectTheme = (state) => state.Theme.themeSelected;
599
+ const selectDarkTheme = (state) => state.Theme.darkMode;
600
+ const selectedTheme = selectTheme;
601
+ const selectedDarkTheme = selectDarkTheme;
602
+ var themeSlice$1 = themeSlice.reducer;
603
+
604
+ export { MuiComponentsConfig, THEME_PREFERENCES, darkBlack, darkBlue, darkTheme, isValidThemeName, lightAmber, lightBlue, lightBlueIndigo, lightBrown, lightGray, lightGreen, lightLime, lightOrange, lightPink, lightPurple, lightRed, lightTeal, lightTheme, lightYellow, normalizeThemePreference, observeThemePreference, resolveThemePreference, selectDarkTheme, selectTheme, selectThemePreference, selectThemeToggleStatus, selectedDarkTheme, selectedTheme, systemThemeChanged, themeSlice$1 as themeReducer, toggleModeTheme, toggleTheme, updateTheme };
2
605
  //# sourceMappingURL=theme.js.map