dts-universal-report-module 1.0.0 → 1.0.1
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.esm.js +7851 -6356
- package/dist/index.js +28 -28
- package/package.json +3 -24
package/dist/index.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),u=require("react"),_i=require("xlsx"),w=require("@mui/icons-material"),o=require("@mui/material"),gn=require("react-dom"),$i=require("@emotion/react"),dt=require("react-dnd"),io=require("react-dnd-html5-backend");function bn(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:()=>e[n]})}}return r.default=e,Object.freeze(r)}const zr=bn(u),yr=bn(_i);function Fi(e){return e==null?"null":Array.isArray(e)?"array":typeof e=="object"?"object":typeof e=="number"?"number":typeof e=="boolean"?"boolean":typeof e=="string"?"string":"mixed"}function Ur(e){if(!Array.isArray(e)||e.length===0)return[];const r=new Set;e.forEach(i=>{typeof i=="object"&&i!==null&&Object.keys(i).forEach(a=>r.add(a))});const n=[];return r.forEach(i=>{const a=new Set;let l=0;e.forEach(x=>{typeof x=="object"&&x!==null&&i in x&&(l++,a.add(Fi(x[i])))});const c=l===e.length,d=a.size>1&&!a.has("null");let f="mixed";if(a.size===1)f=Array.from(a)[0];else if(a.size===2&&a.has("null")){const x=Array.from(a).filter(m=>m!=="null");x.length===1&&(f=x[0])}n.push({name:i,type:f,required:c,hasConflict:d})}),n.sort((i,a)=>i.name.localeCompare(a.name))}function Vi(e){return e.some(r=>r.hasConflict)}function Ct(e){if(!e)return"";const n=e.replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2");return n.charAt(0).toUpperCase()+n.slice(1)}function Co(e){return e==null}function Ni(e){return(r,n,i)=>{const a=Co(r),l=Co(n);if(a&&l)return 0;if(a)return 1;if(l)return-1;let c=0;switch(e){case"number":const d=Number(r),f=Number(n);c=d-f;break;case"boolean":c=(r?1:0)-(n?1:0);break;case"string":c=String(r).localeCompare(String(n));break;case"array":case"object":c=JSON.stringify(r).localeCompare(JSON.stringify(n));break;case"mixed":case"null":default:c=String(r).localeCompare(String(n));break}return i==="asc"?c:-c}}function Li(e,r,n){if(!n||n.length===0)return e;const i=[...n].sort((a,l)=>a.priority-l.priority);return[...e].sort((a,l)=>{for(const c of i){const d=r.find(m=>m.name===c.column);if(!d)continue;const x=Ni(d.type)(a[c.column],l[c.column],c.direction);if(x!==0)return x}return 0})}function Hi(e){return e===null?"asc":e==="asc"?"desc":null}function Ui(e){return e==="string"||e==="boolean"}function Gi(e){return e.filter(r=>Ui(r.type))}function Yi(e,r){const n={};return r.forEach(i=>{if(i.type==="number"){const a=e.map(l=>l[i.name]).filter(l=>typeof l=="number");a.length>0&&(n[i.name]=a.reduce((l,c)=>l+c,0))}}),n}function qi(e,r,n){if(!n.enabled||n.levels.length===0)return e;const i=yn(e,n.levels,r);return Sn(i,n.collapsedGroups||[])}function yn(e,r,n,i="",a=0){if(a>=r.length)return e;const l=r[a].column,c=new Map;e.forEach(x=>{const m=x[l],b=m==null?"(empty)":String(m);c.has(b)||c.set(b,[]),c.get(b).push(x)});const d=[];return Array.from(c.keys()).sort().forEach(x=>{const m=c.get(x),b=`${l}:${x}`,g=i?`${i}|${b}`:b,v=Yi(m,n),C=a<r.length-1?yn(m,r,n,g,a+1):m,p={key:g,level:a,column:l,value:x,rowCount:m.length,aggregates:v,children:C};d.push(p)}),d}function Sn(e,r,n=[]){for(const i of e)if("key"in i&&"level"in i&&"children"in i){const a=r.includes(i.key);n.push({isGroupHeader:!0,groupKey:i.key,groupLevel:i.level,groupColumn:i.column,groupValue:i.value,rowCount:i.rowCount,aggregates:i.aggregates,isCollapsed:a}),!a&&i.children&&Sn(i.children,r,n)}else n.push(i);return n}function Ji(e,r){const n=e.collapsedGroups||[],i=n.includes(r)?n.filter(a=>a!==r):[...n,r];return{...e,collapsedGroups:i}}function Ki(e,r){return e==null?"":typeof e=="number"?`Σ ${e.toLocaleString()}`:String(e)}function Xi(e,r,n){return`${r}: ${n}`}function lr(e,r){if(!r||!r.enabled||!r.levels||r.levels.length===0)return[...e];const n=r.levels.map(a=>a.column),i=e.filter(a=>!n.includes(a));return[...n,...i]}function vn(e,r,n){if(!r||!r.enabled||!r.levels||r.levels.length===0)return[...e];const i=r.levels.map(l=>l.column),a=e.filter(l=>!i.includes(l));if(n){const l=[],c=new Set(i),d=new Set(a);let f=0;for(const x of n)c.has(x)?l.push(x):d.has(x)&&f<a.length?(l.push(a[f]),f++):d.has(x)||l.push(x);for(let x=f;x<a.length;x++)l.includes(a[x])||l.push(a[x]);return l}return[...e]}function Gr(e){const r={},n=[],i={};return e.forEach(a=>{r[a.name]=!0,n.push(a.name),i[a.name]=150}),{id:"default-view",name:"Default View",description:"Unfiltered, unsorted baseline view",isDefault:!0,snapshot:{filters:[],sortStack:[],columnVisibility:r,columnOrder:n,columnWidths:i,grouping:null}}}function Qi(e,r,n,i,a,l,c,d){const f={},x=[],m={};n.forEach(v=>{f[v.name]=!0,x.push(v.name),m[v.name]=150});const g=vn(a||x,c||null,d||x);return{filters:e||[],sortStack:r||[],columnVisibility:i||f,columnOrder:g,columnWidths:l||m,grouping:c||null}}function Zi(e,r){const n=f=>{if(f==null)return f;if(Array.isArray(f))return f.map(x=>n(x));if(typeof f=="object"){const x={};return Object.keys(f).sort().forEach(m=>{x[m]=n(f[m])}),x}return f},i=f=>JSON.stringify(n(f));if(i(e.filters)!==i(r.filters)||i(e.sortStack)!==i(r.sortStack)||i(e.columnVisibility)!==i(r.columnVisibility))return!0;const a=[...e.columnOrder||[]].sort().join(","),l=[...r.columnOrder||[]].sort().join(",");if(a!==l)return!1;const c=[...r.columnOrder||[]].sort().join(",");if((r.columnOrder||[]).join(",")!==c){if((e.columnOrder||[]).join(",")!==(r.columnOrder||[]).join(","))return!0}else{const f=[...e.columnOrder||[]].sort().join(",");if((e.columnOrder||[]).join(",")!==f)return!0}return i(e.columnWidths)!==i(r.columnWidths)||i(e.grouping)!==i(r.grouping)}function es(e){return!e||e.length===0?"None":e.sort((r,n)=>r.priority-n.priority).map(r=>`${r.column} ${r.direction==="asc"?"↑":"↓"}`).join(", ")}function ts(e,r){var p,T,s;const n=[],i=JSON.stringify(e.filters),a=JSON.stringify(r.filters);if(i!==a){const k=e.filters.length,D=r.filters.length;k>D?n.push({category:"filters",label:"Filters Added",description:`${k-D} new filter${k-D>1?"s":""} added`}):k<D?n.push({category:"filters",label:"Filters Removed",description:`${D-k} filter${D-k>1?"s":""} removed`}):n.push({category:"filters",label:"Filters Modified",description:"Filter conditions have been changed"})}const l=JSON.stringify(e.sortStack),c=JSON.stringify(r.sortStack);if(l!==c){const k=e.sortStack.length,D=r.sortStack.length;k>D?n.push({category:"sorting",label:"Sorting Added",description:`${k-D} new sort rule${k-D>1?"s":""} added`}):k<D?n.push({category:"sorting",label:"Sorting Removed",description:`${D-k} sort rule${D-k>1?"s":""} removed`}):n.push({category:"sorting",label:"Sorting Modified",description:"Sort rules or order have been changed"})}const d=JSON.stringify(e.columnVisibility),f=JSON.stringify(r.columnVisibility);if(d!==f){const k=Object.values(e.columnVisibility).filter(A=>A).length,D=Object.values(r.columnVisibility).filter(A=>A).length;k>D?n.push({category:"visibility",label:"Columns Shown",description:`${k-D} column${k-D>1?"s":""} made visible`}):k<D?n.push({category:"visibility",label:"Columns Hidden",description:`${D-k} column${D-k>1?"s":""} hidden`}):n.push({category:"visibility",label:"Column Visibility Changed",description:"Column visibility settings have been modified"})}const x=JSON.stringify(e.columnOrder),m=JSON.stringify(r.columnOrder);x!==m&&n.push({category:"order",label:"Column Order Changed",description:"Columns have been reordered"});const b=JSON.stringify(e.columnWidths),g=JSON.stringify(r.columnWidths);if(b!==g){const k=Object.keys(e.columnWidths).filter(D=>e.columnWidths[D]!==r.columnWidths[D]).length;n.push({category:"widths",label:"Column Widths Adjusted",description:`${k} column width${k>1?"s":""} modified`})}const v=JSON.stringify(e.grouping),C=JSON.stringify(r.grouping);if(v!==C){const k=(p=e.grouping)==null?void 0:p.enabled,D=(T=r.grouping)==null?void 0:T.enabled;if(k&&!D){const A=((s=e.grouping)==null?void 0:s.levels.length)||0;n.push({category:"grouping",label:"Grouping Applied",description:`${A} grouping level${A>1?"s":""} added`})}else!k&&D?n.push({category:"grouping",label:"Grouping Removed",description:"All grouping has been cleared"}):n.push({category:"grouping",label:"Grouping Modified",description:"Grouping configuration has been changed"})}return n}const Cn="urm_report_";function rs(e,r){try{const n=`${Cn}${e}`;localStorage.setItem(n,JSON.stringify(r))}catch(n){console.error("Failed to save report state:",n)}}function os(e){try{const r=`${Cn}${e}`,n=localStorage.getItem(r);return n?JSON.parse(n):null}catch(r){return console.error("Failed to load report state:",r),null}}function Er(e,r,n=0){const i=[];for(const a of e){const l=r.includes(a.key);if(i.push({type:"group",key:a.key,level:n,column:a.column,value:a.value,rowCount:a.rowCount,aggregates:a.aggregates,collapsed:l}),!l&&a.children&&a.children.length>0){const c=a.children[0];if(ns(c)){const d=a.children,f=Er(d,r,n+1);i.push(...f)}else{const d=a.children;for(const f of d)i.push({type:"row",parentGroupKey:a.key,level:n+1,data:f})}}}return i}function ns(e){return e&&typeof e=="object"&&"key"in e&&"level"in e&&"column"in e&&"value"in e&&"rowCount"in e&&"aggregates"in e&&"children"in e}function so(e){return e.filter(r=>r.type==="row").map(r=>r.type==="row"?r.data:null).filter(r=>r!==null)}function ao(e,r){const n=new Date,i=n.getFullYear(),a=String(n.getMonth()+1).padStart(2,"0"),l=String(n.getDate()).padStart(2,"0"),c=`${i}-${a}-${l}`;return`${e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}_${c}.${r}`}function jo(e,r,n,i,a,l,c){let d,f;l?(d={...l},f=c||r.map(m=>m.name)):a?(d={...a.snapshot.columnVisibility},f=c||[...a.snapshot.columnOrder]):(d={},f=[],r.forEach(m=>{d[m.name]=!0,f.push(m.name)}));const x=Object.entries(d).filter(([m,b])=>!b).map(([m,b])=>m);return{data:e,schema:r,appliedFilters:n,appliedSortStack:i,columnVisibility:d,columnOrder:f,grouping:(a==null?void 0:a.snapshot.grouping)??null,hiddenColumns:x,viewMeta:a?{id:a.id,name:a.name,isDefault:a.isDefault}:void 0}}function wo(e,r="export",n){const{data:i,columnOrder:a,grouping:l}=e,c=a.filter(b=>e.columnVisibility[b]);let d;if(l&&l.enabled){const b=Er(i);d=so(b)}else d=i;const f=c.join(","),x=d.map(b=>c.map(g=>{const v=b[g];if(v==null)return"";const C=String(v);return C.includes(",")||C.includes('"')||C.includes(`
|
|
2
|
-
`)?`"${C.replace(/"/g,'""')}"`:C}).join(",")),m=[f,...
|
|
3
|
-
`);
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("react"),is=require("xlsx"),j=require("@mui/icons-material"),o=require("@mui/material"),_n=require("react-dom"),ss=require("@emotion/react"),vt=require("react-dnd"),zo=require("react-dnd-html5-backend");function $n(t){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:()=>t[n]})}}return r.default=t,Object.freeze(r)}const Jr=$n(u),Fr=$n(is);function as(t){return t==null?"null":Array.isArray(t)?"array":typeof t=="object"?"object":typeof t=="number"?"number":typeof t=="boolean"?"boolean":typeof t=="string"?"string":"mixed"}function fo(t){if(!Array.isArray(t)||t.length===0)return[];const r=new Set;t.forEach(i=>{typeof i=="object"&&i!==null&&Object.keys(i).forEach(a=>r.add(a))});const n=[];return r.forEach(i=>{const a=new Set;let c=0;t.forEach(h=>{typeof h=="object"&&h!==null&&i in h&&(c++,a.add(as(h[i])))});const l=c===t.length,d=a.size>1&&!a.has("null");let f="mixed";if(a.size===1)f=Array.from(a)[0];else if(a.size===2&&a.has("null")){const h=Array.from(a).filter(m=>m!=="null");h.length===1&&(f=h[0])}n.push({name:i,type:f,required:l,hasConflict:d})}),n}function ls(t){return t.some(r=>r.hasConflict)}function St(t){if(!t)return"";const n=t.replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2");return n.charAt(0).toUpperCase()+n.slice(1)}function No(t){return t==null}function cs(t){return(r,n,i)=>{const a=No(r),c=No(n);if(a&&c)return 0;if(a)return 1;if(c)return-1;let l=0;switch(t){case"number":const d=Number(r),f=Number(n);l=d-f;break;case"boolean":l=(r?1:0)-(n?1:0);break;case"string":l=String(r).localeCompare(String(n));break;case"array":case"object":l=JSON.stringify(r).localeCompare(JSON.stringify(n));break;case"mixed":case"null":default:l=String(r).localeCompare(String(n));break}return i==="asc"?l:-l}}function ds(t,r,n){if(!n||n.length===0)return t;const i=[...n].sort((a,c)=>a.priority-c.priority);return[...t].sort((a,c)=>{for(const l of i){const d=r.find(m=>m.name===l.column);if(!d)continue;const h=cs(d.type)(a[l.column],c[l.column],l.direction);if(h!==0)return h}return 0})}function us(t){return t===null?"asc":t==="asc"?"desc":null}function ps(t){return t==="string"||t==="boolean"}function fs(t){return t.filter(r=>ps(r.type))}function xs(t,r){const n={};return r.forEach(i=>{if(i.type==="number"){const a=t.map(c=>c[i.name]).filter(c=>typeof c=="number");a.length>0&&(n[i.name]=a.reduce((c,l)=>c+l,0))}}),n}function hs(t,r,n){if(!n.enabled||n.levels.length===0)return t;const i=Fn(t,n.levels,r);return Ln(i,n.collapsedGroups||[])}function Fn(t,r,n,i="",a=0){if(a>=r.length)return t;const c=r[a].column,l=new Map;t.forEach(h=>{const m=h[c],g=m==null?"(empty)":String(m);l.has(g)||l.set(g,[]),l.get(g).push(h)});const d=[];return Array.from(l.keys()).sort().forEach(h=>{const m=l.get(h),g=`${c}:${h}`,y=i?`${i}|${g}`:g,S=xs(m,n),C=a<r.length-1?Fn(m,r,n,y,a+1):m,x={key:y,level:a,column:c,value:h,rowCount:m.length,aggregates:S,children:C};d.push(x)}),d}function Ln(t,r,n=[]){for(const i of t)if("key"in i&&"level"in i&&"children"in i){const a=r.includes(i.key);n.push({isGroupHeader:!0,groupKey:i.key,groupLevel:i.level,groupColumn:i.column,groupValue:i.value,rowCount:i.rowCount,aggregates:i.aggregates,isCollapsed:a}),!a&&i.children&&Ln(i.children,r,n)}else n.push(i);return n}function ms(t,r){const n=t.collapsedGroups||[],i=n.includes(r)?n.filter(a=>a!==r):[...n,r];return{...t,collapsedGroups:i}}function Nn(t,r){return t==null?"":typeof t=="number"?`Σ ${t.toLocaleString()}`:String(t)}function Vn(t,r,n){return`${r}: ${n}`}function Er(t,r){if(!r||!r.enabled||!r.levels||r.levels.length===0)return[...t];const n=r.levels.map(a=>a.column),i=t.filter(a=>!n.includes(a));return[...n,...i]}function Hn(t,r,n){if(!r||!r.enabled||!r.levels||r.levels.length===0)return[...t];const i=r.levels.map(c=>c.column),a=t.filter(c=>!i.includes(c));if(n){const c=[],l=new Set(i),d=new Set(a);let f=0;for(const h of n)l.has(h)?c.push(h):d.has(h)&&f<a.length?(c.push(a[f]),f++):d.has(h)||c.push(h);for(let h=f;h<a.length;h++)c.includes(a[h])||c.push(a[h]);return c}return[...t]}function xo(t){const r={},n=[],i={};return t.forEach(a=>{r[a.name]=!0,n.push(a.name),i[a.name]=150}),{id:"default-view",name:"Default View",description:"Unfiltered, unsorted baseline view",isDefault:!0,snapshot:{filters:[],sortStack:[],columnVisibility:r,columnOrder:n,columnWidths:i,grouping:null}}}function gs(t,r,n,i,a,c,l,d){const f={},h=[],m={};n.forEach(S=>{f[S.name]=!0,h.push(S.name),m[S.name]=150});const y=Hn(a||h,l||null,d||h);return{filters:t||[],sortStack:r||[],columnVisibility:i||f,columnOrder:y,columnWidths:c||m,grouping:l||null}}function ys(t,r){const n=f=>{if(f==null)return f;if(Array.isArray(f))return f.map(h=>n(h));if(typeof f=="object"){const h={};return Object.keys(f).sort().forEach(m=>{h[m]=n(f[m])}),h}return f},i=f=>JSON.stringify(n(f));if(i(t.filters)!==i(r.filters)||i(t.sortStack)!==i(r.sortStack)||i(t.columnVisibility)!==i(r.columnVisibility))return!0;const a=[...t.columnOrder||[]].sort().join(","),c=[...r.columnOrder||[]].sort().join(",");if(a!==c)return!1;const l=[...r.columnOrder||[]].sort().join(",");if((r.columnOrder||[]).join(",")!==l){if((t.columnOrder||[]).join(",")!==(r.columnOrder||[]).join(","))return!0}else{const f=[...t.columnOrder||[]].sort().join(",");if((t.columnOrder||[]).join(",")!==f)return!0}return i(t.columnWidths)!==i(r.columnWidths)||i(t.grouping)!==i(r.grouping)}function bs(t){return!t||t.length===0?"None":t.sort((r,n)=>r.priority-n.priority).map(r=>`${r.column} ${r.direction==="asc"?"↑":"↓"}`).join(", ")}function vs(t,r){var x,E,s;const n=[],i=JSON.stringify(t.filters),a=JSON.stringify(r.filters);if(i!==a){const T=t.filters.length,I=r.filters.length;T>I?n.push({category:"filters",label:"Filters Added",description:`${T-I} new filter${T-I>1?"s":""} added`}):T<I?n.push({category:"filters",label:"Filters Removed",description:`${I-T} filter${I-T>1?"s":""} removed`}):n.push({category:"filters",label:"Filters Modified",description:"Filter conditions have been changed"})}const c=JSON.stringify(t.sortStack),l=JSON.stringify(r.sortStack);if(c!==l){const T=t.sortStack.length,I=r.sortStack.length;T>I?n.push({category:"sorting",label:"Sorting Added",description:`${T-I} new sort rule${T-I>1?"s":""} added`}):T<I?n.push({category:"sorting",label:"Sorting Removed",description:`${I-T} sort rule${I-T>1?"s":""} removed`}):n.push({category:"sorting",label:"Sorting Modified",description:"Sort rules or order have been changed"})}const d=JSON.stringify(t.columnVisibility),f=JSON.stringify(r.columnVisibility);if(d!==f){const T=Object.values(t.columnVisibility).filter(A=>A).length,I=Object.values(r.columnVisibility).filter(A=>A).length;T>I?n.push({category:"visibility",label:"Columns Shown",description:`${T-I} column${T-I>1?"s":""} made visible`}):T<I?n.push({category:"visibility",label:"Columns Hidden",description:`${I-T} column${I-T>1?"s":""} hidden`}):n.push({category:"visibility",label:"Column Visibility Changed",description:"Column visibility settings have been modified"})}const h=JSON.stringify(t.columnOrder),m=JSON.stringify(r.columnOrder);h!==m&&n.push({category:"order",label:"Column Order Changed",description:"Columns have been reordered"});const g=JSON.stringify(t.columnWidths),y=JSON.stringify(r.columnWidths);if(g!==y){const T=Object.keys(t.columnWidths).filter(I=>t.columnWidths[I]!==r.columnWidths[I]).length;n.push({category:"widths",label:"Column Widths Adjusted",description:`${T} column width${T>1?"s":""} modified`})}const S=JSON.stringify(t.grouping),C=JSON.stringify(r.grouping);if(S!==C){const T=(x=t.grouping)==null?void 0:x.enabled,I=(E=r.grouping)==null?void 0:E.enabled;if(T&&!I){const A=((s=t.grouping)==null?void 0:s.levels.length)||0;n.push({category:"grouping",label:"Grouping Applied",description:`${A} grouping level${A>1?"s":""} added`})}else!T&&I?n.push({category:"grouping",label:"Grouping Removed",description:"All grouping has been cleared"}):n.push({category:"grouping",label:"Grouping Modified",description:"Grouping configuration has been changed"})}return n}const Un="urm_report_";function Ss(t,r){try{const n=`${Un}${t}`;localStorage.setItem(n,JSON.stringify(r))}catch(n){console.error("Failed to save report state:",n)}}function Cs(t){try{const r=`${Un}${t}`,n=localStorage.getItem(r);return n?JSON.parse(n):null}catch(r){return console.error("Failed to load report state:",r),null}}function qr(t,r,n=0){const i=[];for(const a of t){const c=r.includes(a.key);if(i.push({type:"group",key:a.key,level:n,column:a.column,value:a.value,rowCount:a.rowCount,aggregates:a.aggregates,collapsed:c}),!c&&a.children&&a.children.length>0){const l=a.children[0];if(js(l)){const d=a.children,f=qr(d,r,n+1);i.push(...f)}else{const d=a.children;for(const f of d)i.push({type:"row",parentGroupKey:a.key,level:n+1,data:f})}}}return i}function js(t){return t&&typeof t=="object"&&"key"in t&&"level"in t&&"column"in t&&"value"in t&&"rowCount"in t&&"aggregates"in t&&"children"in t}function Io(t){return t.filter(r=>r.type==="row").map(r=>r.type==="row"?r.data:null).filter(r=>r!==null)}function Eo(t,r){const n=new Date,i=n.getFullYear(),a=String(n.getMonth()+1).padStart(2,"0"),c=String(n.getDate()).padStart(2,"0"),l=`${i}-${a}-${c}`;return`${t.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}_${l}.${r}`}function Vo(t,r,n,i,a,c,l){let d,f;c?(d={...c},f=l||r.map(m=>m.name)):a?(d={...a.snapshot.columnVisibility},f=l||[...a.snapshot.columnOrder]):(d={},f=[],r.forEach(m=>{d[m.name]=!0,f.push(m.name)}));const h=Object.entries(d).filter(([m,g])=>!g).map(([m,g])=>m);return{data:t,schema:r,appliedFilters:n,appliedSortStack:i,columnVisibility:d,columnOrder:f,grouping:(a==null?void 0:a.snapshot.grouping)??null,hiddenColumns:h,viewMeta:a?{id:a.id,name:a.name,isDefault:a.isDefault}:void 0}}function Ho(t,r="export",n){const{data:i,columnOrder:a,grouping:c}=t,l=a.filter(g=>t.columnVisibility[g]);let d;if(c&&c.enabled){const g=qr(i);d=Io(g)}else d=i;const f=l.join(","),h=d.map(g=>l.map(y=>{const S=g[y];if(S==null)return"";const C=String(S);return C.includes(",")||C.includes('"')||C.includes(`
|
|
2
|
+
`)?`"${C.replace(/"/g,'""')}"`:C}).join(",")),m=[f,...h].join(`
|
|
3
|
+
`);Gn(m,Eo(r,"csv"),"text/csv;charset=utf-8;")}function Uo(t,r="export",n){const{data:i,columnOrder:a,grouping:c}=t,l=a.filter(g=>t.columnVisibility[g]);let d;if(c&&c.enabled){const g=qr(i);d=Io(g)}else d=i;const f=[l,...d.map(g=>l.map(y=>g[y]??""))],h=Fr.utils.aoa_to_sheet(f),m=Fr.utils.book_new();Fr.utils.book_append_sheet(m,h,"Data"),Fr.writeFile(m,Eo(r,"xlsx"))}function Go(t,r="export",n){const{data:i,appliedFilters:a,appliedSortStack:c,viewMeta:l,hiddenColumns:d,columnOrder:f,grouping:h}=t;let m;if(h&&h.enabled){const S=qr(i);m=Io(S)}else m=i;const g={meta:{exportedAt:new Date().toISOString(),reportName:r,view:(l==null?void 0:l.name)||"Default View",filters:a.map(S=>({field:S.column,operator:S.operator,value:S.value})),sortStack:c.map(S=>({field:S.column,direction:S.direction,priority:S.priority})),grouping:h||{},hiddenColumns:d,columnOrder:f,exportConfig:n||{scope:"visible"}},data:m},y=JSON.stringify(g,null,2);Gn(y,Eo(r,"json"),"application/json;charset=utf-8;")}function Gn(t,r,n){const i=new Blob([t],{type:n}),a=URL.createObjectURL(i),c=document.createElement("a");c.href=a,c.download=r,document.body.appendChild(c),c.click(),document.body.removeChild(c),URL.revokeObjectURL(a)}const Yo=10;function ws(t,r){const n=r.trim();if(!n)return t;const i=t.findIndex(c=>c.query.toLowerCase()===n.toLowerCase());let a;return i!==-1?a=[{...t[i],lastUsed:Date.now()},...t.slice(0,i),...t.slice(i+1)]:a=[{query:n,isFavourite:!1,lastUsed:Date.now()},...t],a.length>Yo&&(a=[...a].sort((l,d)=>l.isFavourite&&!d.isFavourite?-1:!l.isFavourite&&d.isFavourite?1:d.lastUsed-l.lastUsed).slice(0,Yo)),a}function ks(t,r){return t.map(n=>n.query===r?{...n,isFavourite:!n.isFavourite}:n)}function Ts(t,r){return t.filter(n=>n.query!==r)}function zs(t){const r=t.filter(i=>i.isFavourite).sort((i,a)=>a.lastUsed-i.lastUsed),n=t.filter(i=>!i.isFavourite).sort((i,a)=>a.lastUsed-i.lastUsed);return[...r,...n]}const Is={owner:["view_report","edit_columns","edit_filters","edit_sorting","edit_views","create_views","delete_views","delete_report","export_data"],editor:["view_report","edit_columns","edit_filters","edit_sorting","edit_views","create_views","delete_views","export_data"],viewer:["view_report","export_data"]};function Es(t,r){return!t||t.owner===r?"owner":t.editors.includes(r)?"editor":(t.viewers.includes(r),"viewer")}function ct(t,r){return Is[r].includes(t)}function dt(t){return`You do not have permission to ${{view_report:"view this report",edit_columns:"modify columns",edit_filters:"modify filters",edit_sorting:"modify sorting",edit_views:"edit views",create_views:"create views",delete_views:"delete views",delete_report:"delete this report",export_data:"export data"}[t]||"perform this action"}.`}function Bs(t){return t==="viewer"}const Jo=1e3;function Ds(){return`EVT_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Yn(t,r,n,i,a,c){return{id:Ds(),user:r,reportId:t,feature:n,action:i,timestamp:new Date().toISOString(),previousState:a,newState:c}}function Jn(t,r){const n=[r,...t];return n.length>Jo?n.slice(0,Jo):n}function Os(t){return{filter_added:"Filter Added",filter_removed:"Filter Removed",filter_updated:"Filter Updated",filter_cleared:"All Filters Cleared",sort_level_added:"Sort Level Added",sort_level_removed:"Sort Level Removed",sort_reordered:"Sort Reordered",sort_cleared:"All Sorting Cleared",group_level_added:"Group Level Added",group_level_removed:"Group Level Removed",group_reordered:"Group Reordered",group_cleared:"All Grouping Cleared",column_hidden:"Column Hidden",column_shown:"Column Shown",column_reordered:"Columns Reordered",column_resized:"Column Resized",view_created:"View Created",view_updated:"View Updated",view_deleted:"View Deleted",view_set_default:"View Set as Default",view_switched:"View Switched",theme_changed:"Theme Changed",export_triggered:"Export Triggered",export_csv:"Exported as CSV",export_excel:"Exported as Excel",export_json:"Exported as JSON",preset_created:"Preset Created",preset_applied:"Preset Applied",preset_deleted:"Preset Deleted",preset_link_copied:"Preset Link Copied",error_occurred:"Error Occurred"}[t]||t}function As(t){return{filters:"Filters",sorting:"Sorting",grouping:"Grouping",columns:"Columns",views:"Views",theme:"Theme",export:"Export",presets:"Presets",system:"System"}[t]||t}function Ms(t){return{filters:"bg-blue-100 text-blue-800 border-blue-200",sorting:"bg-purple-100 text-purple-800 border-purple-200",grouping:"bg-green-100 text-green-800 border-green-200",columns:"bg-orange-100 text-orange-800 border-orange-200",views:"bg-pink-100 text-pink-800 border-pink-200",theme:"bg-gray-100 text-gray-800 border-gray-200",export:"bg-cyan-100 text-cyan-800 border-cyan-200",presets:"bg-indigo-100 text-indigo-800 border-indigo-200",system:"bg-red-100 text-red-800 border-red-200"}[t]||"bg-gray-100 text-gray-800 border-gray-200"}function Rs(t){const r=new Date(t),i=new Date().getTime()-r.getTime(),a=Math.floor(i/6e4),c=Math.floor(i/36e5),l=Math.floor(i/864e5);return a<1?"Just now":a<60?`${a} minute${a>1?"s":""} ago`:c<24?`${c} hour${c>1?"s":""} ago`:l<7?`${l} day${l>1?"s":""} ago`:r.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}function qo(t){return t==null?"None":typeof t=="string"||typeof t=="number"||typeof t=="boolean"?String(t):JSON.stringify(t,null,2)}const Ko=100;function Ws(){return`preset_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Ps(t){var c;const r=(c=t.views)==null?void 0:c.find(l=>l.id===t.activeViewId),n=r==null?void 0:r.snapshot.columnOrder,i=t.columnOrder||[],a=Hn(i,t.grouping||null,n);return{filters:t.filters?[...t.filters]:[],sortStack:t.sortStack?[...t.sortStack]:[],columnVisibility:t.columnVisibility?{...t.columnVisibility}:{},columnOrder:a,columnWidths:t.columnWidths?{...t.columnWidths}:{},grouping:t.grouping?{...t.grouping}:null,activeViewId:t.activeViewId}}function _s(t,r,n,i){return{id:Ws(),name:t,description:r,createdBy:n,createdAt:Date.now(),config:i}}function $s(t,r){const n=t||[];if(n.length>=Ko)throw new Error(`Maximum of ${Ko} presets reached. Please delete old presets first.`);return[...n,r]}function Xo(t,r){return(t||[]).filter(i=>i.id!==r)}function Qo(t,r){if(t)return t.find(n=>n.id===r)}function ho(t,r){return`${window.location.origin+window.location.pathname}?mode=viewer&reportId=${t}&preset=${r}`}function Zo(t){window.open(t,"_blank","noopener,noreferrer")}function Fs(t,r,n,i){const a=encodeURIComponent(`Shared Report Preset: ${r}`);let c=`I'm sharing a report preset with you:
|
|
4
4
|
|
|
5
|
-
`;
|
|
6
|
-
`,i&&(
|
|
7
|
-
`),
|
|
5
|
+
`;c+=`Preset Name: ${r}
|
|
6
|
+
`,i&&(c+=`Description: ${i}
|
|
7
|
+
`),c+=`
|
|
8
8
|
Click the link below to view the report with this configuration:
|
|
9
9
|
${n}
|
|
10
10
|
|
|
11
|
-
`,l+="This link will load the report with pre-configured filters, sorting, and column settings.";const c=encodeURIComponent(l);return`mailto:${e.join(",")}?subject=${a}&body=${c}`}function Cs(){return typeof window>"u"?null:new URLSearchParams(window.location.search).get("preset")}function js(e){const r=e.columnOrder,n=lr(r,e.grouping);return{filters:e.filters.length>0?[...e.filters]:void 0,sortStack:e.sortStack.length>0?[...e.sortStack]:void 0,columnVisibility:{...e.columnVisibility},columnOrder:n,columnWidths:{...e.columnWidths},grouping:e.grouping?{...e.grouping}:null,activeViewId:e.activeViewId}}async function Ro(e){try{if(navigator.clipboard&&navigator.clipboard.writeText)return await navigator.clipboard.writeText(e),!0}catch(r){console.warn("Clipboard API blocked, using fallback method:",r)}try{const r=document.createElement("textarea");r.value=e,r.style.position="fixed",r.style.top="0",r.style.left="0",r.style.width="2em",r.style.height="2em",r.style.padding="0",r.style.border="none",r.style.outline="none",r.style.boxShadow="none",r.style.background="transparent",r.style.opacity="0",document.body.appendChild(r),r.focus(),r.select();let n=!1;try{n=document.execCommand("copy")}catch(i){console.error("execCommand copy failed:",i)}return document.body.removeChild(r),n}catch(r){return console.error("Fallback copy method failed:",r),!1}}function ws(e,r){return{totalRows:e.length,totalColumns:r.length}}const ks={MAX_CACHE_ENTRIES:3};function Ts(e,r){let n=null;return function(...a){const l=()=>{n=null,e(...a)};n&&clearTimeout(n),n=setTimeout(l,r)}}class Sr{constructor(r=ks.MAX_CACHE_ENTRIES){this.cache=new Map,this.maxEntries=r}get(r){const n=this.cache.get(r);return n?n.value:null}set(r,n){var i;if(this.cache.size>=this.maxEntries&&!this.cache.has(r)){const a=(i=Array.from(this.cache.entries()).sort((l,c)=>l[1].timestamp-c[1].timestamp)[0])==null?void 0:i[0];a&&this.cache.delete(a)}this.cache.set(r,{key:r,value:n,timestamp:Date.now()})}has(r){return this.cache.has(r)}clear(){this.cache.clear()}size(){return this.cache.size}}class zs{constructor(){this.metrics=new Map}start(r){this.metrics.set(r,performance.now())}end(r){const n=this.metrics.get(r);if(!n)return 0;const i=performance.now()-n;return this.metrics.delete(r),i}measure(r,n){this.start(r);const i=n(),a=this.end(r);return{result:i,duration:a}}async measureAsync(r,n){this.start(r);const i=await n(),a=this.end(r);return{result:i,duration:a}}}function ct(e,r,n,i){const a=n instanceof Error?n.message:n,l={type:e,context:r,message:a,details:i,timestamp:Date.now(),recoverable:Es(e,r)};return process.env.NODE_ENV==="development"&&console.error("[Report Error]",{type:e,context:r,message:a,details:i}),l}function Es(e,r){return e==="ui"||e==="processing"&&["filters","sorting","grouping","columns"].includes(r)?!0:e!=="system"}function Is(e){const n={filters:"There was an issue applying filters",sorting:"Sorting could not be applied",grouping:"Grouping configuration failed",columns:"Column configuration could not be updated",views:"View operation failed",presets:"Preset could not be applied",export:"Export failed",upload:"File upload failed",search:"Search operation failed"}[e.context]||"An error occurred";return e.recoverable?`${n}. Your previous state has been restored.`:`${n}. Please refresh the page.`}function Bs(e){return{filters:e.filters?[...e.filters]:void 0,sortStack:e.sortStack?[...e.sortStack]:void 0,grouping:e.grouping?{...e.grouping}:void 0,columnVisibility:e.columnVisibility?{...e.columnVisibility}:void 0,columnOrder:e.columnOrder?[...e.columnOrder]:void 0,columnWidths:e.columnWidths?{...e.columnWidths}:void 0,activeViewId:e.activeViewId}}function Ds(e,r,n){n(e.id,{filters:r.filters,sortStack:r.sortStack,grouping:r.grouping,columnVisibility:r.columnVisibility,columnOrder:r.columnOrder,columnWidths:r.columnWidths,activeViewId:r.activeViewId})}function Os(e,r,n){return["equals","contains","starts_with","ends_with","gt","gte","lt","lte"].includes(r)&&(n==null||n==="")?{isValid:!1,errorMessage:"Value is required for this operator"}:e==="number"&&["gt","gte","lt","lte","equals"].includes(r)&&isNaN(Number(n))?{isValid:!1,errorMessage:"Value must be a valid number"}:e==="date"&&n&&isNaN(Date.parse(n))?{isValid:!1,errorMessage:"Value must be a valid date"}:{isValid:!0}}function Tn(e,r){const n=[],i=[],a=new Set(r.map(l=>l.name));return e.forEach(l=>{a.has(l.column)?n.push(l):i.push(l.column)}),{validRules:n,invalidColumns:i}}function zn(e,r){if(!e||!e.levels||e.levels.length===0)return{validGrouping:null,invalidColumns:[]};const n=new Set(r.map(l=>l.name)),i=[],a=[];return e.levels.forEach(l=>{n.has(l.column)?i.push(l):a.push(l.column)}),i.length===0?{validGrouping:null,invalidColumns:a}:{validGrouping:{...e,levels:i},invalidColumns:a}}function As(e,r){const n=[],i=new Set(r.map(l=>l.name)),a={...e};if(a.filters&&Array.isArray(a.filters)){const l=a.filters.filter(c=>{const d=i.has(c.column);return d||n.push(`Filter for column "${c.column}" ignored (column not found)`),d});a.filters=l.length>0?l:void 0}if(a.sortStack&&Array.isArray(a.sortStack)){const{validRules:l,invalidColumns:c}=Tn(a.sortStack,r);c.length>0&&n.push(`Sort rules for columns ignored: ${c.join(", ")}`),a.sortStack=l.length>0?l:void 0}if(a.grouping){const{validGrouping:l,invalidColumns:c}=zn(a.grouping,r);c.length>0&&n.push(`Grouping for columns ignored: ${c.join(", ")}`),a.grouping=l}if(a.columnVisibility){const l={};Object.entries(a.columnVisibility).forEach(([c,d])=>{i.has(c)?l[c]=d:n.push(`Column visibility for "${c}" ignored (column not found)`)}),a.columnVisibility=Object.keys(l).length>0?l:void 0}if(a.columnOrder&&Array.isArray(a.columnOrder)){const l=a.columnOrder.filter(c=>{const d=i.has(c);return d||n.push(`Column "${c}" in order ignored (column not found)`),d});a.columnOrder=l.length>0?l:void 0}if(a.columnWidths){const l={};Object.entries(a.columnWidths).forEach(([c,d])=>{i.has(c)?l[c]=d:n.push(`Column width for "${c}" ignored (column not found)`)}),a.columnWidths=Object.keys(l).length>0?l:void 0}return{sanitizedConfig:a,warnings:n}}function Rs(e,r){return ct("processing","export",e,{retryAvailable:!!(r!=null&&r.onRetry)})}function Mo(e,r,n,i){const a=wn(e,r,"system","error_occurred",null,{errorType:n.type,errorContext:n.context,errorMessage:n.message,recoverable:n.recoverable,timestamp:n.timestamp});return kn(i||[],a)}function Ms(e){return e==null}function Ps(e,r){const{operator:n,value:i}=r;if(n==="NULL")return e==null;if(n==="NOT_NULL")return e!=null;if(Ms(e))return!1;switch(n){case"equals":return String(e)===String(i);case"contains":return String(e).toLowerCase().includes(String(i).toLowerCase());case"startsWith":return String(e).toLowerCase().startsWith(String(i).toLowerCase());case"endsWith":return String(e).toLowerCase().endsWith(String(i).toLowerCase());case"gt":return Number(e)>Number(i);case"lt":return Number(e)<Number(i);case"gte":return Number(e)>=Number(i);case"lte":return Number(e)<=Number(i);case"isTrue":return e===!0;case"isFalse":return e===!1;default:return!0}}function Ws(e,r){return!r||r.length===0?e:e.filter(n=>r.every(i=>Ps(n[i.column],i)))}function Po(e){switch(e){case"string":return[{value:"equals",label:"Equals"},{value:"contains",label:"Contains"},{value:"startsWith",label:"Starts with"},{value:"endsWith",label:"Ends with"},{value:"NULL",label:"Is NULL"},{value:"NOT_NULL",label:"Is NOT NULL"}];case"number":return[{value:"equals",label:"="},{value:"gt",label:">"},{value:"lt",label:"<"},{value:"gte",label:"≥"},{value:"lte",label:"≤"}];case"boolean":return[{value:"isTrue",label:"Is true"},{value:"isFalse",label:"Is false"},{value:"NULL",label:"Is NULL"},{value:"NOT_NULL",label:"Is NOT NULL"}];case"mixed":case"null":case"array":case"object":default:return[]}}function vr(e){return e!=="isTrue"&&e!=="isFalse"&&e!=="NULL"&&e!=="NOT_NULL"}function _s({data:e,filters:r}){return{filteredData:u.useMemo(()=>!r||r.length===0?e:Ws(e,r),[e,r])}}function En(e,r,n,i){if(!n||n.trim()==="")return e;const a=n.toLowerCase().trim(),l=r.filter(c=>i.includes(c.name));return e.filter(c=>l.some(d=>{const f=c[d.name];return f==null?!1:String(f).toLowerCase().includes(a)}))}function $s({data:e,searchQuery:r,schema:n,visibleColumns:i}){return{searchedData:u.useMemo(()=>!r||r.trim()===""?e:En(e,n,r,i),[e,r,n,i])}}function Fs({data:e,sortStack:r,schema:n}){return{sortedData:u.useMemo(()=>!r||r.length===0?e:Li(e,n,r),[e,r,n])}}function Vs({data:e,grouping:r,schema:n}){const i=u.useMemo(()=>!r||!r.enabled||r.levels.length===0?e:qi(e,n,r),[e,r,n]),a=(r==null?void 0:r.enabled)&&((r==null?void 0:r.levels.length)||0)>0;return{groupedData:i,isGrouped:a}}function Ns({schema:e,columnVisibility:r,columnOrder:n}){const i=u.useMemo(()=>n.filter(d=>r[d]!==!1),[n,r]),a=u.useMemo(()=>Object.entries(r).filter(([d,f])=>!f).map(([d,f])=>d),[r]),l=u.useMemo(()=>n.map(d=>e.find(x=>x.name===d)||{name:d,type:"string"}),[n,e]),c=u.useMemo(()=>i.map(d=>e.find(x=>x.name===d)||{name:d,type:"string"}),[i,e]);return{visibleColumns:i,hiddenColumns:a,allColumns:l,visibleColumnSchemas:c,hiddenCount:a.length}}function Ls({views:e,activeViewId:r,currentState:n}){const i=u.useMemo(()=>e.find(x=>x.id===r),[e,r]),a=u.useMemo(()=>i?Zi(n,i.snapshot):!1,[i,n]),l=u.useMemo(()=>e.find(x=>x.isDefault),[e]),c=u.useMemo(()=>e.filter(x=>!x.isDefault&&!x.isDeleted),[e]),d=u.useMemo(()=>e.filter(x=>x.isFavorite&&!x.isDeleted),[e]),f=u.useMemo(()=>e.filter(x=>x.isDeleted),[e]);return{activeView:i,isDirty:a,defaultView:l,customViews:c,favoriteViews:d,deletedViews:f,isDefaultView:(i==null?void 0:i.isDefault)||!1}}function Hs({data:e,enabled:r=!1,pageSize:n=100,initialPage:i=1}){const[a,l]=u.useState(i),c=e.length,d=Math.ceil(c/n),f=u.useMemo(()=>{if(!r)return e;const v=(a-1)*n,C=v+n;return e.slice(v,C)},[e,r,a,n]),x=u.useCallback(v=>{const C=Math.max(1,Math.min(v,d));l(C)},[d]),m=u.useCallback(()=>{a<d&&l(a+1)},[a,d]),b=u.useCallback(()=>{a>1&&l(a-1)},[a]),g=u.useCallback(()=>{l(1)},[]);return{paginatedData:f,currentPage:a,totalPages:d,pageSize:n,totalRows:c,goToPage:x,nextPage:m,prevPage:b,resetPage:g,hasNextPage:a<d,hasPrevPage:a>1}}function Us(e){const{rawData:r,schema:n,filters:i,sortStack:a,grouping:l,searchQuery:c,columnVisibility:d,columnOrder:f,columnWidths:x,views:m,activeViewId:b,pagination:g}=e,v=u.useMemo(()=>({filters:i,sortStack:a,grouping:l,columnVisibility:d,columnOrder:f,columnWidths:x}),[i,a,l,d,f,x]),C=Ls({views:m,activeViewId:b,currentState:v}),p=Ns({schema:n,columnVisibility:d,columnOrder:f}),{filteredData:T}=_s({data:r,filters:i}),{sortedData:s}=Fs({data:T,sortStack:a,schema:n}),{groupedData:k,isGrouped:D}=Vs({data:s,grouping:l,schema:n}),{searchedData:A}=$s({data:k,searchQuery:c,schema:n,visibleColumns:p.visibleColumns}),S=Hs({data:A,enabled:(g==null?void 0:g.enabled)||!1,pageSize:(g==null?void 0:g.pageSize)||100,initialPage:(g==null?void 0:g.currentPage)||1}),R=g!=null&&g.enabled?S.paginatedData:A,Y=u.useMemo(()=>({totalRows:r.length,filteredRows:T.length,sortedRows:s.length,groupedRows:D?k.length:s.length,searchedRows:A.length,visibleRows:R.length,hiddenColumns:p.hiddenCount,activeFilters:i.length,activeSorts:a.length,isGrouped:D}),[r.length,T.length,s.length,k.length,A.length,R.length,p.hiddenCount,i.length,a.length,D]);return{data:R,filteredData:T,sortedData:s,groupedData:k,searchedData:A,viewEngine:C,columnEngine:p,paginationEngine:S,metrics:Y,isGrouped:D,isPaginated:(g==null?void 0:g.enabled)||!1}}const St="user-demo-001";function Gs(e={}){var go,bo,yo,So,vo;const{mode:r="builder",autoLoad:n=!0,initialData:i,config:a={}}=e,[l,c]=u.useState([]),[d,f]=u.useState(""),[x,m]=u.useState(!1),[b,g]=u.useState(!1),[v,C]=u.useState({message:"",severity:"info",open:!1}),p=(y,j="info")=>{C({message:y,severity:j,open:!0})},T=()=>C(y=>({...y,open:!1})),s=l.find(y=>y.id===d),[k,D]=u.useState("idle"),[A,S]=u.useState(!1),[R,Y]=u.useState(!1),[_,K]=u.useState(!1),[V,te]=u.useState(!1),[h,F]=u.useState(!1),[W,E]=u.useState(!1),[H,de]=u.useState(void 0),[ue,Be]=u.useState(null),[O,N]=u.useState(null),[Q,X]=u.useState(!1),[Z,re]=u.useState(!1),[J,q]=u.useState(null),[oe,ie]=u.useState(!1),[se,ve]=u.useState(!1),[$,De]=u.useState({enabled:!1,levels:[],collapsedGroups:[]}),[Ae,et]=u.useState(""),[tt,Fe]=u.useState(new Set),[Le,Me]=u.useState(1),[ft,At]=u.useState(10),[pt,xt]=u.useState(!1),[ht,rt]=u.useState(!1),[Rt,ot]=u.useState(!1),[Gt,kt]=u.useState(!1),[Te,nt]=u.useState(null),[qe,it]=u.useState(null),[Mt,mt]=u.useState(!1),[Je,hr]=u.useState(null),[Tt,Yt]=u.useState(null);u.useRef(new zs),u.useRef(new Sr),u.useRef(new Sr),u.useRef(new Sr),u.useRef(new Sr);const[Pt,zt]=u.useState(null),gt=u.useRef(null),ye=u.useMemo(()=>s?ds(s.permissions,St):"owner",[s]),qt=us(ye),Jt=u.useMemo(()=>!(s!=null&&s.uploadedData)||!(s!=null&&s.schema)?{totalRows:0,totalColumns:0}:ws(s.uploadedData,s.schema),[s==null?void 0:s.uploadedData,s==null?void 0:s.schema]),Ke=u.useCallback(()=>{s&&(gt.current=Bs(s))},[s]),P=u.useCallback((y,j)=>{c(z=>z.map(I=>I.id===y?{...I,...j}:I))},[]),He=u.useCallback(y=>{if(!s)return;zt(y);const j=Mo(s.id,St,y,s.auditHistory||[]);P(s.id,{auditHistory:j}),p(y.message,"error"),y.recoverable&>.current&&setTimeout(()=>{Ds(s,gt.current,P),p("Previous state restored","success")},100)},[s,P]),le=u.useCallback((y,j,z,I)=>{if(!s)return;const G=wn(s.id,St,y,j,z,I),ee=s.auditHistory||[],Se=kn(ee,G);setTimeout(()=>{P(s.id,{auditHistory:Se})},0)},[s,P]);u.useEffect(()=>{if(s!=null&&s.schemaLocked&&s.schema&&(!s.views||s.views.length===0)){const y=Gr(s.schema);P(s.id,{views:[y],activeViewId:y.id,filters:y.snapshot.filters,sortStack:y.snapshot.sortStack,columnVisibility:y.snapshot.columnVisibility,columnOrder:y.snapshot.columnOrder,columnWidths:y.snapshot.columnWidths,grouping:y.snapshot.grouping})}},[s==null?void 0:s.schemaLocked,s==null?void 0:s.schema,s==null?void 0:s.id,P]),u.useEffect(()=>{if(i&&n&&!b&&l.length===0){const y={id:`auto-report-${Date.now()}`,name:r==="viewer"?"Data View":"Imported Data",description:"Auto-generated from external data",schemaLocked:!0,uploadedData:i,schema:Ur(i),permissions:{owner:St,editors:[],viewers:[]}};c([y]),f(y.id),g(!0),D("confirmed")}},[i,n,b,l.length,r]);const Oe=(go=s==null?void 0:s.views)==null?void 0:go.find(y=>y.id===s.activeViewId),fe=Us({rawData:(s==null?void 0:s.uploadedData)||[],schema:(s==null?void 0:s.schema)||[],filters:(s==null?void 0:s.filters)||[],sortStack:(s==null?void 0:s.sortStack)||[],grouping:(s==null?void 0:s.grouping)||null,searchQuery:Ae||"",columnVisibility:(s==null?void 0:s.columnVisibility)||(Oe==null?void 0:Oe.snapshot.columnVisibility)||{},columnOrder:(s==null?void 0:s.columnOrder)||(Oe==null?void 0:Oe.snapshot.columnOrder)||[],columnWidths:(s==null?void 0:s.columnWidths)||(Oe==null?void 0:Oe.snapshot.columnWidths)||{},views:(s==null?void 0:s.views)||[],activeViewId:(s==null?void 0:s.activeViewId)||"",pagination:{enabled:!0,pageSize:ft,currentPage:Le}}),{data:Ue=[],searchedData:bt=[],groupedData:Pe=[],metrics:Kt={totalRows:0,searchedRows:0,isGrouped:!1},isGrouped:Wt=!1,paginationEngine:je}=fe||{},U=((bo=fe.viewEngine)==null?void 0:bo.activeView)||Oe,st=((yo=fe.viewEngine)==null?void 0:yo.isDirty)||!1;u.useEffect(()=>{if(!(!U||!s)&&!s.columnOrder){const y=U.snapshot.columnOrder,j=lr(y,U.snapshot.grouping);P(s.id,{columnOrder:j})}},[s==null?void 0:s.activeViewId]);const We=u.useMemo(()=>!(s!=null&&s.schema)||!U?null:Qi(s.filters||[],s.sortStack||[],s.schema,s.columnVisibility,s.columnOrder,s.columnWidths,s.grouping,U.snapshot.columnOrder),[s==null?void 0:s.filters,s==null?void 0:s.sortStack,s==null?void 0:s.schema,s==null?void 0:s.columnVisibility,s==null?void 0:s.columnOrder,s==null?void 0:s.columnWidths,s==null?void 0:s.grouping,U]),Xt=u.useMemo(()=>!U||!We||!st?[]:ts(We,U.snapshot),[U,We,st]),Qt=u.useCallback((y,j,z)=>{const I={id:`report-${Date.now()}`,name:y,description:j,schemaLocked:!1,permissions:{owner:St,editors:[],viewers:[]}};if(z&&Array.isArray(z)&&z.length>0){const G=Ur(z),ee=Gr(G);I.uploadedData=z,I.schema=G,I.schemaLocked=!0,I.views=[ee],I.activeViewId=ee.id,I.sortStack=ee.snapshot.sortStack,I.filters=ee.snapshot.filters,I.columnVisibility=ee.snapshot.columnVisibility,I.columnOrder=ee.snapshot.columnOrder,I.columnWidths=ee.snapshot.columnWidths,I.grouping=ee.snapshot.grouping}c(G=>[...G,I]),f(I.id),m(!1),D("confirmed")},[]),Zt=u.useCallback(y=>{s&&(D("uploading"),setTimeout(()=>{const j=Ur(y);P(s.id,{uploadedData:y,schema:j,uploadError:void 0}),D("preview")},500))},[s,P]),er=u.useCallback(y=>{s&&(P(s.id,{uploadError:y}),D("idle"))},[s,P]),tr=u.useCallback(()=>{s&&(P(s.id,{uploadError:void 0,uploadedData:void 0,schema:void 0}),D("idle"))},[s,P]),rr=u.useCallback(()=>{s&&(P(s.id,{schemaLocked:!0}),D("confirmed"))},[s,P]),_t=u.useCallback(y=>{if(!s)return;if(!Xe("edit_sorting",ye)){p(Qe("edit_sorting"),"error");return}const j=s.sortStack??[],z=j.find(I=>I.column===y);if(z){const I=Hi(z.direction);if(I===null){const G=j.filter(ee=>ee.column!==y).map((ee,Se)=>({...ee,priority:Se+1}));P(s.id,{sortStack:G.length>0?G:void 0})}else{const G=j.map(ee=>ee.column===y?{...ee,direction:I}:ee);P(s.id,{sortStack:G})}}else{if(j.length>=3)return;const I={column:y,direction:"asc",priority:j.length+1};P(s.id,{sortStack:[...j,I]})}},[s,ye,P]),_e=u.useCallback(y=>{if(s)if(s.schema){const{validRules:j,invalidColumns:z}=Tn(y,s.schema);z.length>0&&p(`Removed invalid sort columns: ${z.join(", ")}`),Ke();try{P(s.id,{sortStack:j.length>0?j:void 0})}catch(I){const G=ct("processing","sorting",I);He(G)}}else P(s.id,{sortStack:y.length>0?y:void 0})},[s,P,Ke,He]),Et=u.useCallback(y=>{if(!s)return;const j=s.sortStack??[],z=j.find(I=>I.column===y);if(!(z&&z.direction==="asc"))if(z){const I=j.map(G=>G.column===y?{...G,direction:"asc"}:G);P(s.id,{sortStack:I})}else{if(j.length>=3)return;const I={column:y,direction:"asc",priority:j.length+1};P(s.id,{sortStack:[...j,I]})}},[s,P]),or=u.useCallback(y=>{if(!s)return;const j=s.sortStack??[],z=j.find(I=>I.column===y);if(!(z&&z.direction==="desc"))if(z){const I=j.map(G=>G.column===y?{...G,direction:"desc"}:G);P(s.id,{sortStack:I})}else{if(j.length>=3)return;const I={column:y,direction:"desc",priority:j.length+1};P(s.id,{sortStack:[...j,I]})}},[s,P]),at=u.useCallback(y=>{var z;if(!s)return;if(!Xe("edit_filters",ye)){p(Qe("edit_filters"),"error");return}const j=(z=s.schema)==null?void 0:z.find(I=>I.name===y.column);if(j&&y.value!==void 0){const I=Os(j.type,y.operator,y.value);if(!I.isValid){p(I.errorMessage||"Invalid filter value","error");return}}Ke();try{const I=s.filters??[];le("filters","filter_added",I,[...I,y]),P(s.id,{filters:[...I,y]})}catch(I){const G=ct("processing","filters",I);He(G)}},[s,ye,P,Ke,He,le]),nr=u.useCallback((y,j)=>{if(!s)return;if(!Xe("edit_filters",ye)){p(Qe("edit_filters"),"error");return}const z=s.filters??[],I=[...z];le("filters","filter_updated",z[y],j),I[y]=j,P(s.id,{filters:I})},[s,ye,P,le]),It=u.useCallback(y=>{if(!s)return;if(!Xe("edit_filters",ye)){p(Qe("edit_filters"),"error");return}const j=s.filters??[],z=j.filter((I,G)=>G!==y);le("filters","filter_removed",j[y],null),P(s.id,{filters:z.length>0?z:void 0})},[s,ye,P,le]),M=u.useCallback(()=>{if(!s)return;if(!Xe("edit_filters",ye)){p(Qe("edit_filters"),"error");return}const y=s.filters??[];le("filters","filter_cleared",y,null),P(s.id,{filters:void 0})},[s,ye,P,le]),L=u.useCallback(y=>{var G;if(!s)return;const j=(G=s.views)==null?void 0:G.find(ee=>ee.id===y);if(!j)return;const z=j.snapshot.columnOrder,I=lr(z,j.snapshot.grouping);P(s.id,{filters:j.snapshot.filters.length>0?[...j.snapshot.filters]:void 0,sortStack:j.snapshot.sortStack.length>0?[...j.snapshot.sortStack]:void 0,columnVisibility:{...j.snapshot.columnVisibility},columnOrder:I,columnWidths:{...j.snapshot.columnWidths},grouping:j.snapshot.grouping,activeViewId:y}),Fe(new Set),K(!1)},[s,P]),ae=u.useCallback((y,j,z)=>{if(!(s!=null&&s.schema)||!We)return;const I={id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:y,description:j||void 0,isDefault:z,isFavorite:!1,isDeleted:!1,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...We}},G=s.views??[],ee=z?G.map(Se=>({...Se,isDefault:!1})):G;P(s.id,{views:[...ee,I],activeViewId:I.id}),p(`"${y}" view created`,"success")},[s,We,P]),$e=u.useCallback(()=>{var j;if(!U||!We||U.isDefault||!s)return;const y=(j=s.views)==null?void 0:j.map(z=>z.id===U.id?{...z,snapshot:{...We}}:z);P(s.id,{views:y}),p(`"${U.name}" view updated`,"success")},[U,We,s,P]),ce=u.useCallback(()=>{te(!0)},[]),Bt=u.useCallback(()=>{if(!U||!s)return;const y=U.snapshot.columnOrder,j=lr(y,U.snapshot.grouping);P(s.id,{filters:U.snapshot.filters.length>0?[...U.snapshot.filters]:void 0,sortStack:U.snapshot.sortStack.length>0?[...U.snapshot.sortStack]:void 0,columnVisibility:{...U.snapshot.columnVisibility},columnOrder:j,columnWidths:{...U.snapshot.columnWidths},grouping:U.snapshot.grouping}),p("Changes reverted to last saved state","success")},[U,s,P]),Lr=u.useCallback(y=>{if(!(s!=null&&s.views))return;const j=s.views.map(I=>({...I,isDefault:I.id===y}));P(s.id,{views:j});const z=s.views.find(I=>I.id===y);z&&p(`"${z.name}" set as default view`,"success")},[s,P]),mr=u.useCallback(y=>{if(!(s!=null&&s.views))return;const j=s.views.map(I=>I.id===y?{...I,isFavorite:!I.isFavorite,updatedAt:Date.now()}:I);P(s.id,{views:j});const z=s.views.find(I=>I.id===y);z&&!z.isFavorite?p(`"${z.name}" added to favorites`,"success"):z&&p(`"${z.name}" removed from favorites`,"info")},[s,P]),gr=u.useCallback(y=>{if(!(s!=null&&s.views))return;const j=s.views.map(ee=>ee.id===y?{...ee,isDeleted:!0,updatedAt:Date.now()}:ee),z=s.activeViewId===y,I=j.find(ee=>ee.isDefault&&!ee.isDeleted);P(s.id,{views:j,activeViewId:z&&I?I.id:s.activeViewId,filters:z&&I?I.snapshot.filters.length>0?I.snapshot.filters:void 0:s.filters,sortStack:z&&I?I.snapshot.sortStack.length>0?I.snapshot.sortStack:void 0:s.sortStack});const G=s.views.find(ee=>ee.id===y);G&&p(`"${G.name}" moved to Recently Deleted`,"info")},[s,P]),ze=u.useCallback(y=>{if(!(s!=null&&s.views))return;const j=s.views.map(I=>I.id===y?{...I,isDeleted:!1,updatedAt:Date.now()}:I);P(s.id,{views:j});const z=s.views.find(I=>I.id===y);z&&p(`"${z.name}" restored`,"success")},[s,P]),Ie=u.useCallback(y=>{if(!(s!=null&&s.views))return;const j=s.views.find(Re=>Re.id===y),z=s.views.filter(Re=>!Re.isDeleted||Re.id===y);if((j==null?void 0:j.isDefault)&&z.filter(Re=>Re.isDefault).length===1){p("Cannot delete the last default view","error");return}const G=s.views.filter(Re=>Re.id!==y),ee=s.activeViewId===y,Se=G.find(Re=>Re.isDefault&&!Re.isDeleted);P(s.id,{views:G,activeViewId:ee&&Se?Se.id:s.activeViewId,filters:ee&&Se?Se.snapshot.filters.length>0?Se.snapshot.filters:void 0:s.filters,sortStack:ee&&Se?Se.snapshot.sortStack.length>0?Se.snapshot.sortStack:void 0:s.sortStack}),j&&p(`"${j.name}" permanently deleted`,"success")},[s,P]),yt=u.useCallback(y=>{Be(y),F(!0),K(!1)},[]),Hr=u.useCallback((y,j)=>{if(!ue||!(s!=null&&s.views))return;const z=s.views.map(I=>I.id===ue?{...I,name:y,description:j||void 0}:I);P(s.id,{views:z}),Be(null)},[ue,s,P]),Qn=u.useCallback(y=>{N(y),E(!0),K(!1)},[]),Zn=u.useCallback(()=>{if(!O||!(s!=null&&s.views))return;const y=s.views.filter(I=>I.id!==O),j=s.activeViewId===O,z=y.find(I=>I.isDefault);P(s.id,{views:y,activeViewId:j&&z?z.id:s.activeViewId,filters:j&&z?z.snapshot.filters.length>0?z.snapshot.filters:void 0:s.filters,sortStack:j&&z?z.snapshot.sortStack.length>0?z.snapshot.sortStack:void 0:s.sortStack}),N(null),E(!1)},[O,s,P]);u.useEffect(()=>{je!=null&&je.resetPage?je.resetPage():Me(1)},[s==null?void 0:s.filters,Ae,s==null?void 0:s.activeViewId]),u.useEffect(()=>{je&&je.currentPage!==Le&&Me(je.currentPage)},[je==null?void 0:je.currentPage]);const ei=u.useCallback(y=>{je!=null&&je.goToPage&&je.goToPage(y),Me(y)},[je]),ti=u.useCallback(y=>{const j=(Le-1)*ft,z=Math.floor(j/y)+1;At(y),Me(z)},[Le,ft]),ri=u.useCallback((y,j)=>{if(!s)return;if(!Xe("edit_columns",ye)){p(Qe("edit_columns"),"error");return}const I={...s.columnVisibility||(U==null?void 0:U.snapshot.columnVisibility)||{},[y]:j};P(s.id,{columnVisibility:I})},[s,U,ye,P]),oi=u.useCallback(y=>{if(s){if(!Xe("edit_columns",ye)){p(Qe("edit_columns"),"error");return}P(s.id,{columnOrder:y})}},[s,ye,P]),ni=u.useCallback((y,j)=>{if(!s)return;if(!Xe("edit_columns",ye)){p(Qe("edit_columns"),"error");return}const I={...s.columnWidths||(U==null?void 0:U.snapshot.columnWidths)||{},[y]:j};P(s.id,{columnWidths:I})},[s,U,ye,P]),ii=u.useCallback(y=>{if(!s)return;const z=(s.filters??[]).filter(I=>I.column!==y);P(s.id,{filters:z.length>0?z:void 0})},[s,P]),si=u.useCallback(()=>{if(!U||!(s!=null&&s.schema))return;const y={},j=[],z={};s.schema.forEach(I=>{y[I.name]=!0,j.push(I.name),z[I.name]=150}),P(s.id,{columnVisibility:y,columnOrder:j,columnWidths:z,filters:void 0,sortStack:void 0}),p("Reset to default layout - all filters and sorts cleared","success")},[U,s,P]),mo=u.useCallback(Ts(y=>{et(y)},300),[]),ai=u.useCallback(y=>{mo(y)},[mo]),li=u.useCallback(y=>{if(!y.trim()||!s)return;const j=s.searchHistory||[],z=is(j,y);P(s.id,{searchHistory:z})},[s,P]),ci=u.useCallback(y=>{if(!s)return;const j=s.searchHistory||[],z=ss(j,y);P(s.id,{searchHistory:z})},[s,P]),di=u.useCallback(y=>{if(!s)return;const j=s.searchHistory||[],z=as(j,y);P(s.id,{searchHistory:z})},[s,P]),ui=u.useCallback(y=>{Fe(j=>{const z=new Set(j);return z.has(y)?z.delete(y):z.add(y),z})},[]),fi=u.useCallback((y,j)=>{if(y){const z=new Set;for(let I=0;I<j;I++)z.add(I);Fe(z)}else Fe(new Set)},[]),pi=u.useCallback((y,j)=>{Fe(z=>{const I=new Set(z),G=Math.min(y,j),ee=Math.max(y,j);for(let Se=G;Se<=ee;Se++)I.add(Se);return I})},[]),xi=u.useCallback(()=>{Fe(new Set)},[]),hi=u.useCallback(y=>{if(s){if(!Xe("edit_columns",ye)){p(Qe("edit_columns"),"error");return}if(y&&s.schema){const{validGrouping:j,invalidColumns:z}=zn(y,s.schema);z.length>0&&p(`Removed invalid grouping columns: ${z.join(", ")}`,"warning"),Ke();try{const I=s.grouping;j===null?le("grouping","group_cleared",I,null):I?le("grouping","group_reordered",I,j):le("grouping","group_level_added",null,j);const G=(U==null?void 0:U.snapshot.columnOrder)||s.columnOrder||[],ee=lr(G,j);P(s.id,{grouping:j,columnOrder:ee}),JSON.stringify(ee)!==JSON.stringify(s.columnOrder)&&le("columns","column_reordered",s.columnOrder,ee),ve(!1)}catch(I){const G=ct("processing","grouping",I);He(G)}}else{const j=s.grouping;le("grouping","group_cleared",j,null);const z=(U==null?void 0:U.snapshot.columnOrder)||s.columnOrder||[];P(s.id,{grouping:y,columnOrder:[...z]}),JSON.stringify(z)!==JSON.stringify(s.columnOrder)&&le("columns","column_reordered",s.columnOrder,z),ve(!1)}}},[s,U,ye,P,Ke,He,le]),mi=u.useCallback(y=>{if(!s)return;const j=s.grouping;if(!j)return;const z=Ji(j,y);P(s.id,{grouping:z})},[s,P]),gi=u.useCallback(()=>{mt(!0)},[]),$t=u.useCallback(y=>{s!=null&&s.schema&&(X(!0),setTimeout(()=>{try{let j;y.scope==="visible"?j=bt:j=s.uploadedData||[];let z;y.columnScope==="all"?(z={},s.schema.forEach(Re=>{z[Re.name]=!0})):z=s.columnVisibility||(U==null?void 0:U.snapshot.columnVisibility)||{};const I=s.columnOrder||(U==null?void 0:U.snapshot.columnOrder),G=jo(j,s.schema,s.filters??[],s.sortStack??[],U,z,I),ee=s.name;let Se;switch(y.format){case"csv":wo(G,ee,y),Se="export_csv";break;case"excel":ko(G,ee,y),Se="export_excel";break;case"json":To(G,ee,y),Se="export_json";break}le("export",Se,null,{format:y.format,scope:y.scope,columnScope:y.columnScope,rowCount:j.length,viewName:(U==null?void 0:U.name)||"Default View"}),p(`Export completed successfully (${y.format.toUpperCase()})`,"success")}catch(j){const z=Rs(j,{onRetry:()=>$t(y)});p(`Export failed: ${z.message}`,{action:{label:"Retry",onClick:()=>$t(y)}});const I=Mo(s.id,St,z,s.auditHistory||[]);P(s.id,{auditHistory:I}),console.error("Export error:",j)}finally{X(!1)}},500))},[s,U,bt,P,le]),bi=u.useCallback(y=>{if(s!=null&&s.schema){if(st&&U&&!U.isDefault){q(y.format),re(!0),mt(!1);return}$t(y),mt(!1)}},[s,U,st,$t]),br=u.useCallback(y=>{$t({format:y,scope:"visible",columnScope:"visible"})},[$t]),yi=u.useCallback(()=>{J&&br(J),re(!1),q(null)},[J,br]),Si=u.useCallback(()=>{$e(),J&&br(J),re(!1),q(null)},[$e,J,br]),vi=u.useCallback(()=>{re(!1),q(null)},[]),Ci=u.useCallback(y=>{!(s!=null&&s.schema)||tt.size===0||(X(!0),setTimeout(()=>{try{const j=Array.from(tt).sort((G,ee)=>G-ee).map(G=>Pe[G]).filter(G=>G!==void 0),z=jo(j,s.schema,s.filters??[],s.sortStack??[],U),I=`${s.name.toLowerCase().replace(/\s+/g,"_")}_selected_export`;switch(y){case"csv":wo(z,I);break;case"excel":ko(z,I);break;case"json":To(z,I);break}p(`Exported ${j.length} selected rows`,"info")}catch(j){p("Export failed. Please try again.","error"),console.error("Export error:",j)}finally{X(!1)}},500))},[s,U,tt,Pe]),ji=u.useCallback(()=>{if(!Xe("edit_filters",ye)){p(Qe("edit_filters"),"error");return}rt(!0)},[ye]),wi=u.useCallback((y,j,z)=>{if(s)try{const I=bs(s),G=ys(y,j,St,I),ee=Ss(s.presets,G);P(s.id,{presets:ee});const Se=Yr(s.id,G.id);if(le("presets","preset_created",null,{presetId:G.id,name:G.name}),z&&z.length>0){const Re=vs(z,y,Se,j);window.location.href=Re,p(`Preset created! Opening email client to share with ${z.length} recipient${z.length>1?"s":""}...`,"success")}nt({preset:G,url:Se}),rt(!1),ot(!0),p(`Preset "${y}" created successfully`,"success")}catch(I){p(I instanceof Error?I.message:"Failed to create preset","error")}},[s,P,le]),ki=u.useCallback(async()=>{if(!Te)return;await Ro(Te.url)?(le("presets","preset_link_copied",null,{presetId:Te.preset.id}),p("Link copied to clipboard","success")):p("Failed to copy link","error")},[Te,le]),Ti=u.useCallback(()=>{Te&&(Ao(Te.url),le("presets","preset_link_opened",null,{presetId:Te.preset.id}),p("Opening preset in new tab...","info"))},[Te,le]),zi=u.useCallback(()=>{if(!Te||!s)return;const y=Te.preset.id,j=Te.preset.name,z=Do(s.presets,y);P(s.id,{presets:z}),le("presets","preset_deleted",{presetId:y,name:j},null),qe===y&&it(null),ot(!1),nt(null),p(`Preset "${j}" deleted`,"success")},[Te,s,qe,P,le]),Ei=u.useCallback(()=>{it(null),p("Exited preset view","info")},[]),Ii=u.useCallback(()=>{kt(!0)},[]),Bi=u.useCallback(y=>{if(!s)return;const j=Yr(s.id,y);Ao(j),le("presets","preset_link_opened",null,{presetId:y}),p("Opening preset in new tab...","info")},[s,le]),Di=u.useCallback(async(y,j)=>{if(!s)return;const z=Yr(s.id,y);await Ro(z)?(le("presets","preset_link_copied",null,{presetId:y}),p(`Link for "${j}" copied to clipboard`,"success")):p("Failed to copy link. Please try the manual copy method.","error")},[s,le]),Oi=u.useCallback((y,j)=>{if(!s)return;const z=Do(s.presets,y);P(s.id,{presets:z}),le("presets","preset_deleted",{presetId:y,name:j},null),qe===y&&it(null),(Te==null?void 0:Te.preset.id)===y&&(ot(!1),nt(null)),p(`Preset "${j}" deleted`,"success")},[s,qe,Te,P,le]);u.useEffect(()=>{if(!s)return;const y=Cs();if(y&&s.presets&&s.schemaLocked&&s.schema){const j=Oo(s.presets,y);if(j){const{sanitizedConfig:z,warnings:I}=As(j.config,s.schema);I.length>0&&I.forEach(ee=>p(ee,"warning"));const G=js(z);P(s.id,G),it(y),le("presets","preset_applied",null,{presetId:j.id,name:j.name}),p(`Loaded preset: ${j.name}`,"info")}else p("Preset not found","info")}},[s==null?void 0:s.schemaLocked]);const Ai=qe?Oo(s==null?void 0:s.presets,qe):void 0;u.useEffect(()=>{s!=null&&s.views&&s.views.length>0&&s.activeViewId&&rs(s.id,{views:s.views,activeViewId:s.activeViewId})},[s==null?void 0:s.views,s==null?void 0:s.activeViewId,s==null?void 0:s.id]),u.useEffect(()=>{if(s!=null&&s.schemaLocked&&s.schema&&(!s.views||s.views.length===0)){const y=os(s.id);if(y&&y.views.length>0){const j=y.views.find(z=>z.id===y.activeViewId);if(j)P(s.id,{views:y.views,activeViewId:y.activeViewId,filters:j.snapshot.filters.length>0?j.snapshot.filters:void 0,sortStack:j.snapshot.sortStack.length>0?j.snapshot.sortStack:void 0});else{const z=y.views.find(I=>I.isDefault)||Gr(s.schema);P(s.id,{views:y.views,activeViewId:z.id,filters:z.snapshot.filters.length>0?z.snapshot.filters:void 0,sortStack:z.snapshot.sortStack.length>0?z.snapshot.sortStack:void 0})}}}},[s==null?void 0:s.schemaLocked,s==null?void 0:s.schema,s==null?void 0:s.id]);const Ri=u.useCallback(y=>{de(y),S(!0)},[]),Mi=u.useCallback(()=>{S(!1),de(void 0)},[]),Pi=(So=s==null?void 0:s.views)==null?void 0:So.find(y=>y.id===ue),Wi=(vo=s==null?void 0:s.views)==null?void 0:vo.find(y=>y.id===O);return{reports:l,activeReport:s,activeReportId:d,setActiveReportId:f,isModalOpen:x,setIsModalOpen:m,createReport:Qt,updateReport:P,uploadState:k,handleFileUpload:Zt,handleUploadError:er,handleRetry:tr,handleConfirm:rr,paginatedData:Ue,processedData:bt,displayData:Pe,tableMetrics:Kt,isGrouped:Wt,tableEngine:fe,activeView:U,isDirty:st,currentTableState:We,viewChanges:Xt,filters:s==null?void 0:s.filters,showFilterPanel:A,setShowFilterPanel:S,filterFocusColumn:H,handleAddFilter:at,handleUpdateFilter:nr,handleRemoveFilter:It,handleClearAllFilters:M,handleOpenFilterForColumn:Ri,handleCloseFilterPanel:Mi,handleClearFiltersForColumn:ii,sortStack:s==null?void 0:s.sortStack,showSortPanel:R,setShowSortPanel:Y,handleSort:_t,handleUpdateSortStack:_e,handleSortAscending:Et,handleSortDescending:or,views:s==null?void 0:s.views,showManageViews:_,setShowManageViews:K,showCreateViewModal:V,setShowCreateViewModal:te,showEditViewModal:h,setShowEditViewModal:F,showDeleteConfirmation:W,setShowDeleteConfirmation:E,editingView:Pi,deletingView:Wi,editingViewId:ue,deletingViewId:O,handleSelectView:L,handleCreateView:ae,handleUpdateCurrentView:$e,handleSaveAsNewView:ce,handleRevertChanges:Bt,handleToggleDefault:Lr,handleToggleFavorite:mr,handleSoftDelete:gr,handleRestoreView:ze,handlePermanentDelete:Ie,handleEditView:yt,handleSaveEditView:Hr,handleDeleteView:Qn,handleConfirmDelete:Zn,showManageColumns:oe,setShowManageColumns:ie,columnVisibility:s==null?void 0:s.columnVisibility,columnOrder:s==null?void 0:s.columnOrder,columnWidths:s==null?void 0:s.columnWidths,handleUpdateColumnVisibility:ri,handleUpdateColumnOrder:oi,handleUpdateColumnWidth:ni,handleResetColumnLayout:si,showGroupPanel:se,setShowGroupPanel:ve,grouping:s==null?void 0:s.grouping,groupingState:$,handleGroup:hi,handleToggleGroupCollapse:mi,searchQuery:Ae,searchHistory:ls((s==null?void 0:s.searchHistory)||[]),handleSearchChange:ai,handleAddToSearchHistory:li,handleToggleSearchFavourite:ci,handleDeleteSearchHistory:di,selectedRowIds:tt,handleToggleRowSelection:ui,handleToggleAllRows:fi,handleRangeSelection:pi,handleClearSelection:xi,currentPage:Le,pageSize:ft,paginationEngine:je,handlePageChange:ei,handlePageSizeChange:ti,isExporting:Q,showExportModal:Mt,setShowExportModal:mt,showDirtyExportWarning:Z,handleExport:gi,handleExportWithConfig:bi,handleExportSelected:Ci,handleExportAnyway:yi,handleSaveAndExport:Si,handleCancelExport:vi,showAuditHistory:pt,setShowAuditHistory:xt,auditHistory:s==null?void 0:s.auditHistory,showCreatePreset:ht,setShowCreatePreset:rt,showShareLink:Rt,setShowShareLink:ot,showManagePresets:Gt,setShowManagePresets:kt,generatedPreset:Te,activePreset:Ai,activePresetId:qe,handleOpenSharePreset:ji,handleOpenManagePresets:Ii,handleCreatePreset:wi,handleCopyPresetLink:ki,handleOpenPreset:Ti,handleDeletePreset:zi,handleClearActivePreset:Ei,handleOpenPresetById:Bi,handleCopyPresetLinkById:Di,handleDeletePresetById:Oi,userRole:ye,isViewerRole:qt,currentUserId:St,featureLimitWarning:Tt,setFeatureLimitWarning:Yt,datasetMeta:Jt,reportError:Pt,setReportError:zt,handleError:He,schema:s==null?void 0:s.schema,hasSchemaConflicts:s!=null&&s.schema?Vi(s.schema):!1,snack:v,handleSnackClose:T,showSnack:p}}const In=u.createContext(void 0);function lo(e){const{children:r,initialData:n,data:i,mode:a="builder",autoLoad:l=!0,config:c}=e,f=Gs({mode:a,autoLoad:l,initialData:i||n,config:c});return t.jsx(In.Provider,{value:f,children:r})}function co(){const e=u.useContext(In);if(e===void 0)throw new Error("useReportContext must be used within a ReportProvider. Wrap your component tree with <ReportProvider>...</ReportProvider>");return e}function Ys({onCreateReport:e}){return t.jsx(o.Box,{component:"header",sx:{position:"sticky",top:0,zIndex:50,borderBottom:"1px solid",borderColor:"divider",bgcolor:"background.paper"},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,height:64},children:[t.jsx(o.Typography,{variant:"h6",component:"h1",sx:{fontWeight:500,fontSize:"1.375rem",color:"text.primary",letterSpacing:"-0.01em"},children:"Reports"}),t.jsx(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:t.jsx(o.Button,{variant:"contained",startIcon:t.jsx(w.Add,{sx:{fontSize:18}}),onClick:e,sx:{borderRadius:"20px",px:3,textTransform:"none",fontWeight:500,fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",py:.75,boxShadow:"none","&:hover":{bgcolor:"primary.dark",boxShadow:2},"&:active":{boxShadow:"none"}},children:"New Report"})})]})})}function qs({reports:e,activeReportId:r,onTabClick:n}){if(e.length===0)return null;const i=e.findIndex(a=>a.id===r);return t.jsx(o.Box,{sx:{position:"sticky",top:64,zIndex:40,borderBottom:1,borderColor:"divider",bgcolor:"background.paper",px:3,pt:.75},children:t.jsx(o.Tabs,{value:i>=0?i:0,onChange:(a,l)=>n(e[l].id),variant:"standard",sx:{minHeight:40,"& .MuiTabs-indicator":{height:3,bgcolor:"#0b57d0"},"& .MuiTabs-flexContainer":{gap:2.5}},children:e.map(a=>t.jsx(o.Tab,{label:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[a.name,t.jsx(o.Tooltip,{title:a.description||"No description",arrow:!0,placement:"top",children:t.jsx(w.InfoOutlined,{sx:{fontSize:16,opacity:.5,verticalAlign:"middle",flexShrink:0}})})]}),sx:{textTransform:"none",fontWeight:400,fontSize:"0.9375rem",minHeight:40,py:.5,px:0,minWidth:"auto",color:"#5f6368",transition:"color 0.15s ease","&.Mui-selected":{color:"#0b57d0",fontWeight:500},"&:hover":{color:"#202124"}}},a.id))})})}function Ot(e,...r){const n=new URL(`https://mui.com/production-error/?code=${e}`);return r.forEach(i=>n.searchParams.append("args[]",i)),`Minified MUI error #${e}; visit ${n} for the full message.`}const Js="$$material";function Ks(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Cr={exports:{}},jr={exports:{}},pe={};/** @license React v16.13.1
|
|
11
|
+
`,c+="This link will load the report with pre-configured filters, sorting, and column settings.";const l=encodeURIComponent(c);return`mailto:${t.join(",")}?subject=${a}&body=${l}`}function Ls(){return typeof window>"u"?null:new URLSearchParams(window.location.search).get("preset")}function Ns(t){const r=t.columnOrder,n=Er(r,t.grouping);return{filters:t.filters.length>0?[...t.filters]:void 0,sortStack:t.sortStack.length>0?[...t.sortStack]:void 0,columnVisibility:{...t.columnVisibility},columnOrder:n,columnWidths:{...t.columnWidths},grouping:t.grouping?{...t.grouping}:null,activeViewId:t.activeViewId}}async function en(t){try{if(navigator.clipboard&&navigator.clipboard.writeText)return await navigator.clipboard.writeText(t),!0}catch(r){console.warn("Clipboard API blocked, using fallback method:",r)}try{const r=document.createElement("textarea");r.value=t,r.style.position="fixed",r.style.top="0",r.style.left="0",r.style.width="2em",r.style.height="2em",r.style.padding="0",r.style.border="none",r.style.outline="none",r.style.boxShadow="none",r.style.background="transparent",r.style.opacity="0",document.body.appendChild(r),r.focus(),r.select();let n=!1;try{n=document.execCommand("copy")}catch(i){console.error("execCommand copy failed:",i)}return document.body.removeChild(r),n}catch(r){return console.error("Fallback copy method failed:",r),!1}}function Vs(t,r){return{totalRows:t.length,totalColumns:r.length}}const Hs={MAX_CACHE_ENTRIES:3};function Us(t,r){let n=null;return function(...a){const c=()=>{n=null,t(...a)};n&&clearTimeout(n),n=setTimeout(c,r)}}class Lr{constructor(r=Hs.MAX_CACHE_ENTRIES){this.cache=new Map,this.maxEntries=r}get(r){const n=this.cache.get(r);return n?n.value:null}set(r,n){var i;if(this.cache.size>=this.maxEntries&&!this.cache.has(r)){const a=(i=Array.from(this.cache.entries()).sort((c,l)=>c[1].timestamp-l[1].timestamp)[0])==null?void 0:i[0];a&&this.cache.delete(a)}this.cache.set(r,{key:r,value:n,timestamp:Date.now()})}has(r){return this.cache.has(r)}clear(){this.cache.clear()}size(){return this.cache.size}}class Gs{constructor(){this.metrics=new Map}start(r){this.metrics.set(r,performance.now())}end(r){const n=this.metrics.get(r);if(!n)return 0;const i=performance.now()-n;return this.metrics.delete(r),i}measure(r,n){this.start(r);const i=n(),a=this.end(r);return{result:i,duration:a}}async measureAsync(r,n){this.start(r);const i=await n(),a=this.end(r);return{result:i,duration:a}}}function bt(t,r,n,i){const a=n instanceof Error?n.message:n,c={type:t,context:r,message:a,details:i,timestamp:Date.now(),recoverable:Ys(t,r)};return process.env.NODE_ENV==="development"&&console.error("[Report Error]",{type:t,context:r,message:a,details:i}),c}function Ys(t,r){return t==="ui"||t==="processing"&&["filters","sorting","grouping","columns"].includes(r)?!0:t!=="system"}function Js(t){const n={filters:"There was an issue applying filters",sorting:"Sorting could not be applied",grouping:"Grouping configuration failed",columns:"Column configuration could not be updated",views:"View operation failed",presets:"Preset could not be applied",export:"Export failed",upload:"File upload failed",search:"Search operation failed"}[t.context]||"An error occurred";return t.recoverable?`${n}. Your previous state has been restored.`:`${n}. Please refresh the page.`}function qs(t){return{filters:t.filters?[...t.filters]:void 0,sortStack:t.sortStack?[...t.sortStack]:void 0,grouping:t.grouping?{...t.grouping}:void 0,columnVisibility:t.columnVisibility?{...t.columnVisibility}:void 0,columnOrder:t.columnOrder?[...t.columnOrder]:void 0,columnWidths:t.columnWidths?{...t.columnWidths}:void 0,activeViewId:t.activeViewId}}function Ks(t,r,n){n(t.id,{filters:r.filters,sortStack:r.sortStack,grouping:r.grouping,columnVisibility:r.columnVisibility,columnOrder:r.columnOrder,columnWidths:r.columnWidths,activeViewId:r.activeViewId})}function Xs(t,r,n){return["equals","contains","starts_with","ends_with","gt","gte","lt","lte"].includes(r)&&(n==null||n==="")?{isValid:!1,errorMessage:"Value is required for this operator"}:t==="number"&&["gt","gte","lt","lte","equals"].includes(r)&&isNaN(Number(n))?{isValid:!1,errorMessage:"Value must be a valid number"}:t==="date"&&n&&isNaN(Date.parse(n))?{isValid:!1,errorMessage:"Value must be a valid date"}:{isValid:!0}}function qn(t,r){const n=[],i=[],a=new Set(r.map(c=>c.name));return t.forEach(c=>{a.has(c.column)?n.push(c):i.push(c.column)}),{validRules:n,invalidColumns:i}}function Kn(t,r){if(!t||!t.levels||t.levels.length===0)return{validGrouping:null,invalidColumns:[]};const n=new Set(r.map(c=>c.name)),i=[],a=[];return t.levels.forEach(c=>{n.has(c.column)?i.push(c):a.push(c.column)}),i.length===0?{validGrouping:null,invalidColumns:a}:{validGrouping:{...t,levels:i},invalidColumns:a}}function Qs(t,r){const n=[],i=new Set(r.map(c=>c.name)),a={...t};if(a.filters&&Array.isArray(a.filters)){const c=a.filters.filter(l=>{const d=i.has(l.column);return d||n.push(`Filter for column "${l.column}" ignored (column not found)`),d});a.filters=c.length>0?c:void 0}if(a.sortStack&&Array.isArray(a.sortStack)){const{validRules:c,invalidColumns:l}=qn(a.sortStack,r);l.length>0&&n.push(`Sort rules for columns ignored: ${l.join(", ")}`),a.sortStack=c.length>0?c:void 0}if(a.grouping){const{validGrouping:c,invalidColumns:l}=Kn(a.grouping,r);l.length>0&&n.push(`Grouping for columns ignored: ${l.join(", ")}`),a.grouping=c}if(a.columnVisibility){const c={};Object.entries(a.columnVisibility).forEach(([l,d])=>{i.has(l)?c[l]=d:n.push(`Column visibility for "${l}" ignored (column not found)`)}),a.columnVisibility=Object.keys(c).length>0?c:void 0}if(a.columnOrder&&Array.isArray(a.columnOrder)){const c=a.columnOrder.filter(l=>{const d=i.has(l);return d||n.push(`Column "${l}" in order ignored (column not found)`),d});a.columnOrder=c.length>0?c:void 0}if(a.columnWidths){const c={};Object.entries(a.columnWidths).forEach(([l,d])=>{i.has(l)?c[l]=d:n.push(`Column width for "${l}" ignored (column not found)`)}),a.columnWidths=Object.keys(c).length>0?c:void 0}return{sanitizedConfig:a,warnings:n}}function Zs(t,r){return bt("processing","export",t,{retryAvailable:!!(r!=null&&r.onRetry)})}function tn(t,r,n,i){const a=Yn(t,r,"system","error_occurred",null,{errorType:n.type,errorContext:n.context,errorMessage:n.message,recoverable:n.recoverable,timestamp:n.timestamp});return Jn(i||[],a)}function ea(t){return t==null}function ta(t,r){const{operator:n,value:i}=r;if(n==="NULL")return t==null;if(n==="NOT_NULL")return t!=null;if(ea(t))return!1;switch(n){case"equals":return String(t)===String(i);case"contains":return String(t).toLowerCase().includes(String(i).toLowerCase());case"startsWith":return String(t).toLowerCase().startsWith(String(i).toLowerCase());case"endsWith":return String(t).toLowerCase().endsWith(String(i).toLowerCase());case"gt":return Number(t)>Number(i);case"lt":return Number(t)<Number(i);case"gte":return Number(t)>=Number(i);case"lte":return Number(t)<=Number(i);case"isTrue":return t===!0;case"isFalse":return t===!1;default:return!0}}function ra(t,r){return!r||r.length===0?t:t.filter(n=>r.every(i=>ta(n[i.column],i)))}function rn(t){switch(t){case"string":return[{value:"equals",label:"Equals"},{value:"contains",label:"Contains"},{value:"startsWith",label:"Starts with"},{value:"endsWith",label:"Ends with"},{value:"NULL",label:"Is NULL"},{value:"NOT_NULL",label:"Is NOT NULL"}];case"number":return[{value:"equals",label:"="},{value:"gt",label:">"},{value:"lt",label:"<"},{value:"gte",label:"≥"},{value:"lte",label:"≤"}];case"boolean":return[{value:"isTrue",label:"Is true"},{value:"isFalse",label:"Is false"},{value:"NULL",label:"Is NULL"},{value:"NOT_NULL",label:"Is NOT NULL"}];case"mixed":case"null":case"array":case"object":default:return[]}}function Nr(t){return t!=="isTrue"&&t!=="isFalse"&&t!=="NULL"&&t!=="NOT_NULL"}function oa({data:t,filters:r}){return{filteredData:u.useMemo(()=>!r||r.length===0?t:ra(t,r),[t,r])}}function Xn(t,r,n,i){if(!n||n.trim()==="")return t;const a=n.toLowerCase().trim(),c=r.filter(l=>i.includes(l.name));return t.filter(l=>c.some(d=>{const f=l[d.name];return f==null?!1:String(f).toLowerCase().includes(a)}))}function na({data:t,searchQuery:r,schema:n,visibleColumns:i}){return{searchedData:u.useMemo(()=>!r||r.trim()===""?t:Xn(t,n,r,i),[t,r,n,i])}}function ia({data:t,sortStack:r,schema:n}){return{sortedData:u.useMemo(()=>!r||r.length===0?t:ds(t,n,r),[t,r,n])}}function sa({data:t,grouping:r,schema:n}){const i=u.useMemo(()=>!r||!r.enabled||r.levels.length===0?t:hs(t,n,r),[t,r,n]),a=(r==null?void 0:r.enabled)&&((r==null?void 0:r.levels.length)||0)>0;return{groupedData:i,isGrouped:a}}function aa({schema:t,columnVisibility:r,columnOrder:n}){const i=u.useMemo(()=>n.filter(d=>r[d]!==!1),[n,r]),a=u.useMemo(()=>Object.entries(r).filter(([d,f])=>!f).map(([d,f])=>d),[r]),c=u.useMemo(()=>n.map(d=>t.find(h=>h.name===d)||{name:d,type:"string"}),[n,t]),l=u.useMemo(()=>i.map(d=>t.find(h=>h.name===d)||{name:d,type:"string"}),[i,t]);return{visibleColumns:i,hiddenColumns:a,allColumns:c,visibleColumnSchemas:l,hiddenCount:a.length}}function la({views:t,activeViewId:r,currentState:n}){const i=u.useMemo(()=>t.find(h=>h.id===r),[t,r]),a=u.useMemo(()=>i?ys(n,i.snapshot):!1,[i,n]),c=u.useMemo(()=>t.find(h=>h.isDefault),[t]),l=u.useMemo(()=>t.filter(h=>!h.isDefault&&!h.isDeleted),[t]),d=u.useMemo(()=>t.filter(h=>h.isFavorite&&!h.isDeleted),[t]),f=u.useMemo(()=>t.filter(h=>h.isDeleted),[t]);return{activeView:i,isDirty:a,defaultView:c,customViews:l,favoriteViews:d,deletedViews:f,isDefaultView:(i==null?void 0:i.isDefault)||!1}}function ca({data:t,enabled:r=!1,pageSize:n=100,initialPage:i=1}){const[a,c]=u.useState(i),l=t.length,d=Math.ceil(l/n),f=u.useMemo(()=>{if(!r)return t;const S=(a-1)*n,C=S+n;return t.slice(S,C)},[t,r,a,n]),h=u.useCallback(S=>{const C=Math.max(1,Math.min(S,d));c(C)},[d]),m=u.useCallback(()=>{a<d&&c(a+1)},[a,d]),g=u.useCallback(()=>{a>1&&c(a-1)},[a]),y=u.useCallback(()=>{c(1)},[]);return{paginatedData:f,currentPage:a,totalPages:d,pageSize:n,totalRows:l,goToPage:h,nextPage:m,prevPage:g,resetPage:y,hasNextPage:a<d,hasPrevPage:a>1}}function da(t){const{rawData:r,schema:n,filters:i,sortStack:a,grouping:c,searchQuery:l,columnVisibility:d,columnOrder:f,columnWidths:h,views:m,activeViewId:g,pagination:y}=t,S=u.useMemo(()=>({filters:i,sortStack:a,grouping:c,columnVisibility:d,columnOrder:f,columnWidths:h}),[i,a,c,d,f,h]),C=la({views:m,activeViewId:g,currentState:S}),x=aa({schema:n,columnVisibility:d,columnOrder:f}),{filteredData:E}=oa({data:r,filters:i}),{sortedData:s}=ia({data:E,sortStack:a,schema:n}),{groupedData:T,isGrouped:I}=sa({data:s,grouping:c,schema:n}),{searchedData:A}=na({data:T,searchQuery:l,schema:n,visibleColumns:x.visibleColumns}),v=ca({data:A,enabled:(y==null?void 0:y.enabled)||!1,pageSize:(y==null?void 0:y.pageSize)||100,initialPage:(y==null?void 0:y.currentPage)||1}),W=y!=null&&y.enabled?v.paginatedData:A,U=u.useMemo(()=>({totalRows:r.length,filteredRows:E.length,sortedRows:s.length,groupedRows:I?T.length:s.length,searchedRows:A.length,visibleRows:W.length,hiddenColumns:x.hiddenCount,activeFilters:i.length,activeSorts:a.length,isGrouped:I}),[r.length,E.length,s.length,T.length,A.length,W.length,x.hiddenCount,i.length,a.length,I]);return{data:W,filteredData:E,sortedData:s,groupedData:T,searchedData:A,viewEngine:C,columnEngine:x,paginationEngine:v,metrics:U,isGrouped:I,isPaginated:(y==null?void 0:y.enabled)||!1}}const Mt="user-demo-001";function ua(t={}){var Po,_o,$o,Fo,Lo;const{mode:r="builder",autoLoad:n=!0,initialData:i,config:a={}}=t,[c,l]=u.useState([]),[d,f]=u.useState(""),[h,m]=u.useState(!1),[g,y]=u.useState(!1),[S,C]=u.useState({message:"",severity:"info",open:!1}),x=(b,k="info")=>{C({message:b,severity:k,open:!0})},E=()=>C(b=>({...b,open:!1})),s=c.find(b=>b.id===d),[T,I]=u.useState("idle"),[A,v]=u.useState(!1),[W,U]=u.useState(!1),[w,O]=u.useState(!1),[V,X]=u.useState(!1),[p,L]=u.useState(!1),[$,_]=u.useState(!1),[F,oe]=u.useState(void 0),[ue,Ee]=u.useState(null),[R,q]=u.useState(null),[ee,te]=u.useState(!1),[re,ne]=u.useState(!1),[Z,Q]=u.useState(null),[ae,ce]=u.useState(!1),[le,je]=u.useState(!1),[G,Me]=u.useState({enabled:!1,levels:[],collapsedGroups:[]}),[Ye,jt]=u.useState(""),[tt,$e]=u.useState(new Set),[Je,Ae]=u.useState(1),[wt,Yt]=u.useState(15),[pt,rt]=u.useState(!1),[kt,Tt]=u.useState(!1),[ft,Fe]=u.useState(!1),[qe,Jt]=u.useState(!1),[Be,zt]=u.useState(null),[Ke,ot]=u.useState(null),[qt,xt]=u.useState(!1),[Pr,mr]=u.useState(null),[nt,_t]=u.useState(null);u.useRef(new Gs),u.useRef(new Lr),u.useRef(new Lr),u.useRef(new Lr),u.useRef(new Lr);const[gr,$t]=u.useState(null),It=u.useRef(null),Ce=u.useMemo(()=>s?Es(s.permissions,Mt):"owner",[s]),Et=Bs(Ce),yr=u.useMemo(()=>!(s!=null&&s.uploadedData)||!(s!=null&&s.schema)?{totalRows:0,totalColumns:0}:Vs(s.uploadedData,s.schema),[s==null?void 0:s.uploadedData,s==null?void 0:s.schema]),Ve=u.useCallback(()=>{s&&(It.current=qs(s))},[s]),P=u.useCallback((b,k)=>{l(z=>z.map(B=>B.id===b?{...B,...k}:B))},[]),He=u.useCallback(b=>{if(!s)return;$t(b);const k=tn(s.id,Mt,b,s.auditHistory||[]);P(s.id,{auditHistory:k}),x(b.message,"error"),b.recoverable&&It.current&&setTimeout(()=>{Ks(s,It.current,P),x("Previous state restored","success")},100)},[s,P]),de=u.useCallback((b,k,z,B)=>{if(!s)return;const J=Yn(s.id,Mt,b,k,z,B),K=s.auditHistory||[],ge=Jn(K,J);setTimeout(()=>{P(s.id,{auditHistory:ge})},0)},[s,P]);u.useEffect(()=>{var b,k,z,B,J;if(s!=null&&s.schemaLocked&&s.schema&&(!s.views||s.views.length===0)){const K=xo(s.schema),ge=(()=>{try{const fe=localStorage.getItem("urm_dev_config");return fe?JSON.parse(fe):null}catch{return null}})();if(ge){const fe=ge;if(Array.isArray((b=fe.sort)==null?void 0:b.defaultSortStack)&&fe.sort.defaultSortStack.length>0){const lt=s.schema.map(Oe=>Oe.name),Xe=fe.sort.defaultSortStack.filter(Oe=>Oe.column&<.includes(Oe.column)).map((Oe,Ht)=>({column:Oe.column,direction:Oe.direction==="desc"?"desc":"asc",priority:Ht+1}));Xe.length>0&&(K.snapshot.sortStack=Xe)}if(Array.isArray((k=fe.filter)==null?void 0:k.defaultFilters)&&fe.filter.defaultFilters.length>0){const lt=s.schema.map(Oe=>Oe.name),Xe=fe.filter.defaultFilters.filter(Oe=>Oe.column&&Oe.operator&<.includes(Oe.column));Xe.length>0&&(K.snapshot.filters=Xe)}if(Array.isArray((z=fe.columns)==null?void 0:z.defaultHiddenColumns)&&fe.columns.defaultHiddenColumns.length>0&&fe.columns.defaultHiddenColumns.forEach(lt=>{lt in K.snapshot.columnVisibility&&(K.snapshot.columnVisibility[lt]=!1)}),Array.isArray((B=fe.columns)==null?void 0:B.defaultColumnOrder)&&fe.columns.defaultColumnOrder.length>0){const lt=s.schema.map(Ht=>Ht.name),Xe=fe.columns.defaultColumnOrder.filter(Ht=>lt.includes(Ht)),Oe=K.snapshot.columnOrder.filter(Ht=>!Xe.includes(Ht));Xe.length>0&&(K.snapshot.columnOrder=[...Xe,...Oe])}if(Array.isArray((J=fe.grouping)==null?void 0:J.defaultGrouping)&&fe.grouping.defaultGrouping.length>0){const lt=s.schema.map(Oe=>Oe.name),Xe=fe.grouping.defaultGrouping.filter(Oe=>Oe.column&<.includes(Oe.column));Xe.length>0&&(K.snapshot.grouping={enabled:!0,levels:Xe,collapsedGroups:[]})}}P(s.id,{views:[K],activeViewId:K.id,filters:K.snapshot.filters,sortStack:K.snapshot.sortStack,columnVisibility:K.snapshot.columnVisibility,columnOrder:K.snapshot.columnOrder,columnWidths:K.snapshot.columnWidths,grouping:K.snapshot.grouping})}},[s==null?void 0:s.schemaLocked,s==null?void 0:s.schema,s==null?void 0:s.id,P]),u.useEffect(()=>{if(i&&n&&!g&&c.length===0){const b={id:`auto-report-${Date.now()}`,name:r==="viewer"?"Data View":"Imported Data",description:"Auto-generated from external data",schemaLocked:!0,uploadedData:i,schema:fo(i),permissions:{owner:Mt,editors:[],viewers:[]}};l([b]),f(b.id),y(!0),I("confirmed")}},[i,n,g,c.length,r]);const Re=(Po=s==null?void 0:s.views)==null?void 0:Po.find(b=>b.id===s.activeViewId),br=u.useMemo(()=>s!=null&&s.uploadedData?!s.showFavoritesOnly||!s.favoriteRowIndices||s.favoriteRowIndices.length===0?s.uploadedData:s.uploadedData.filter((b,k)=>s.favoriteRowIndices.includes(k)):[],[s==null?void 0:s.uploadedData,s==null?void 0:s.showFavoritesOnly,s==null?void 0:s.favoriteRowIndices]),Ft=u.useMemo(()=>{var k;if(!(s!=null&&s.uploadedData)||!((k=s==null?void 0:s.favoriteRowIndices)!=null&&k.length))return new Set;const b=new Set;return s.favoriteRowIndices.forEach(z=>{const B=s.uploadedData[z];B!==void 0&&b.add(B)}),b},[s==null?void 0:s.uploadedData,s==null?void 0:s.showFavoritesOnly,s==null?void 0:s.favoriteRowIndices]),Bt=da({rawData:br,schema:(s==null?void 0:s.schema)||[],filters:(s==null?void 0:s.filters)||[],sortStack:(s==null?void 0:s.sortStack)||[],grouping:(s==null?void 0:s.grouping)||null,searchQuery:Ye||"",columnVisibility:(s==null?void 0:s.columnVisibility)||(Re==null?void 0:Re.snapshot.columnVisibility)||{},columnOrder:(s==null?void 0:s.columnOrder)||(Re==null?void 0:Re.snapshot.columnOrder)||[],columnWidths:(s==null?void 0:s.columnWidths)||(Re==null?void 0:Re.snapshot.columnWidths)||{},views:(s==null?void 0:s.views)||[],activeViewId:(s==null?void 0:s.activeViewId)||"",pagination:{enabled:!0,pageSize:wt,currentPage:Je}}),{data:Lt=[],searchedData:Nt=[],groupedData:ht=[],metrics:Kt={totalRows:0,searchedRows:0,isGrouped:!1},isGrouped:Vt=!1,paginationEngine:ie}=Bt||{},H=((_o=Bt.viewEngine)==null?void 0:_o.activeView)||Re,it=(($o=Bt.viewEngine)==null?void 0:$o.isDirty)||!1;u.useEffect(()=>{if(!(!H||!s)&&!s.columnOrder){const b=H.snapshot.columnOrder,k=Er(b,H.snapshot.grouping);P(s.id,{columnOrder:k})}},[s==null?void 0:s.activeViewId]);const xe=u.useMemo(()=>!(s!=null&&s.schema)||!H?null:gs(s.filters||[],s.sortStack||[],s.schema,s.columnVisibility,s.columnOrder,s.columnWidths,s.grouping,H.snapshot.columnOrder),[s==null?void 0:s.filters,s==null?void 0:s.sortStack,s==null?void 0:s.schema,s==null?void 0:s.columnVisibility,s==null?void 0:s.columnOrder,s==null?void 0:s.columnWidths,s==null?void 0:s.grouping,H]),Le=u.useMemo(()=>!H||!xe||!it?[]:vs(xe,H.snapshot),[H,xe,it]),Xt=u.useCallback((b,k,z)=>{const B={id:`report-${Date.now()}`,name:b,description:k,schemaLocked:!1,permissions:{owner:Mt,editors:[],viewers:[]}};if(z&&Array.isArray(z)&&z.length>0){const J=fo(z),K=xo(J);B.uploadedData=z,B.schema=J,B.schemaLocked=!0,B.views=[K],B.activeViewId=K.id,B.sortStack=K.snapshot.sortStack,B.filters=K.snapshot.filters,B.columnVisibility=K.snapshot.columnVisibility,B.columnOrder=K.snapshot.columnOrder,B.columnWidths=K.snapshot.columnWidths,B.grouping=K.snapshot.grouping}l(J=>[...J,B]),f(B.id),m(!1),I("confirmed")},[]),vr=u.useCallback(b=>{s&&(I("uploading"),setTimeout(()=>{const k=fo(b);P(s.id,{uploadedData:b,schema:k,uploadError:void 0}),I("preview")},500))},[s,P]),Qt=u.useCallback(b=>{s&&(P(s.id,{uploadError:b}),I("idle"))},[s,P]),Zt=u.useCallback(()=>{s&&(P(s.id,{uploadError:void 0,uploadedData:void 0,schema:void 0}),I("idle"))},[s,P]),Ne=u.useCallback(()=>{s&&(P(s.id,{schemaLocked:!0}),I("confirmed"))},[s,P]),st=u.useCallback(b=>{if(!s)return;if(!ct("edit_sorting",Ce)){x(dt("edit_sorting"),"error");return}const k=s.sortStack??[],z=k.find(B=>B.column===b);if(z){const B=us(z.direction);if(B===null){const J=k.filter(K=>K.column!==b).map((K,ge)=>({...K,priority:ge+1}));P(s.id,{sortStack:J.length>0?J:void 0})}else{const J=k.map(K=>K.column===b?{...K,direction:B}:K);P(s.id,{sortStack:J})}}else{if(k.length>=3)return;const B={column:b,direction:"asc",priority:k.length+1};P(s.id,{sortStack:[...k,B]})}},[s,Ce,P]),er=u.useCallback(b=>{if(s)if(s.schema){const{validRules:k,invalidColumns:z}=qn(b,s.schema);z.length>0&&x(`Removed invalid sort columns: ${z.join(", ")}`),Ve();try{P(s.id,{sortStack:k.length>0?k:void 0})}catch(B){const J=bt("processing","sorting",B);He(J)}}else P(s.id,{sortStack:b.length>0?b:void 0})},[s,P,Ve,He]),mt=u.useCallback(b=>{if(!s)return;const k=s.sortStack??[],z=k.find(B=>B.column===b);if(!(z&&z.direction==="asc"))if(z){const B=k.map(J=>J.column===b?{...J,direction:"asc"}:J);P(s.id,{sortStack:B})}else{if(k.length>=3)return;const B={column:b,direction:"asc",priority:k.length+1};P(s.id,{sortStack:[...k,B]})}},[s,P]),Sr=u.useCallback(b=>{if(!s)return;const k=s.sortStack??[],z=k.find(B=>B.column===b);if(!(z&&z.direction==="desc"))if(z){const B=k.map(J=>J.column===b?{...J,direction:"desc"}:J);P(s.id,{sortStack:B})}else{if(k.length>=3)return;const B={column:b,direction:"desc",priority:k.length+1};P(s.id,{sortStack:[...k,B]})}},[s,P]),tr=u.useCallback(b=>{var z;if(!s)return;if(!ct("edit_filters",Ce)){x(dt("edit_filters"),"error");return}const k=(z=s.schema)==null?void 0:z.find(B=>B.name===b.column);if(k&&b.value!==void 0){const B=Xs(k.type,b.operator,b.value);if(!B.isValid){x(B.errorMessage||"Invalid filter value","error");return}}Ve();try{const B=s.filters??[];de("filters","filter_added",B,[...B,b]),P(s.id,{filters:[...B,b]})}catch(B){const J=bt("processing","filters",B);He(J)}},[s,Ce,P,Ve,He,de]),rr=u.useCallback((b,k)=>{if(!s)return;if(!ct("edit_filters",Ce)){x(dt("edit_filters"),"error");return}const z=s.filters??[],B=[...z];de("filters","filter_updated",z[b],k),B[b]=k,P(s.id,{filters:B})},[s,Ce,P,de]),or=u.useCallback(b=>{if(!s)return;if(!ct("edit_filters",Ce)){x(dt("edit_filters"),"error");return}const k=s.filters??[],z=k.filter((B,J)=>J!==b);de("filters","filter_removed",k[b],null),P(s.id,{filters:z.length>0?z:void 0})},[s,Ce,P,de]),Cr=u.useCallback(()=>{if(!s)return;if(!ct("edit_filters",Ce)){x(dt("edit_filters"),"error");return}const b=s.filters??[];de("filters","filter_cleared",b,null),P(s.id,{filters:void 0})},[s,Ce,P,de]),gt=u.useCallback(b=>{var J;if(!s)return;const k=(J=s.views)==null?void 0:J.find(K=>K.id===b);if(!k)return;const z=k.snapshot.columnOrder,B=Er(z,k.snapshot.grouping);P(s.id,{filters:k.snapshot.filters.length>0?[...k.snapshot.filters]:void 0,sortStack:k.snapshot.sortStack.length>0?[...k.snapshot.sortStack]:void 0,columnVisibility:{...k.snapshot.columnVisibility},columnOrder:B,columnWidths:{...k.snapshot.columnWidths},grouping:k.snapshot.grouping,activeViewId:b}),$e(new Set),O(!1)},[s,P]),at=u.useCallback((b,k,z)=>{if(!(s!=null&&s.schema)||!xe)return;const B={id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:b,description:k||void 0,isDefault:z,isFavorite:!1,isDeleted:!1,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...xe}},J=s.views??[],K=z?J.map(ge=>({...ge,isDefault:!1})):J;P(s.id,{views:[...K,B],activeViewId:B.id}),x(`"${b}" view created`,"success")},[s,xe,P]),nr=u.useCallback(()=>{var k;if(!H||!xe||H.isDefault||!s)return;const b=(k=s.views)==null?void 0:k.map(z=>z.id===H.id?{...z,snapshot:{...xe}}:z);P(s.id,{views:b}),x(`"${H.name}" view updated`,"success")},[H,xe,s,P]),ir=u.useCallback(()=>{var k;if(!H||!xe||!s)return;const b=(k=s.views)==null?void 0:k.map(z=>z.id===H.id?{...z,snapshot:{...z.snapshot,columnVisibility:xe.columnVisibility,columnOrder:xe.columnOrder,columnWidths:xe.columnWidths},updatedAt:Date.now()}:z);P(s.id,{views:b}),x(`Column configuration saved to "${H.name}"`,"success")},[H,xe,s,P]),sr=u.useCallback(()=>{var B,J;if(!xe||!s||!H)return;const b={...H,snapshot:{...H.snapshot,columnVisibility:xe.columnVisibility,columnOrder:xe.columnOrder,columnWidths:xe.columnWidths},updatedAt:Date.now()},k=(B=s.views)==null?void 0:B.map(K=>K.id===H.id?b:{...K,snapshot:{...K.snapshot,columnVisibility:xe.columnVisibility,columnOrder:xe.columnOrder,columnWidths:xe.columnWidths},updatedAt:Date.now()});P(s.id,{views:k});const z=(((J=s.views)==null?void 0:J.length)||0)-1;x(`Column configuration saved to current view and ${z} other view${z===1?"":"s"}`,"success")},[xe,s,H,P]),We=u.useCallback(()=>{X(!0)},[]),ar=u.useCallback(()=>{if(!H||!s)return;const b=H.snapshot.columnOrder,k=Er(b,H.snapshot.grouping);P(s.id,{filters:H.snapshot.filters.length>0?[...H.snapshot.filters]:void 0,sortStack:H.snapshot.sortStack.length>0?[...H.snapshot.sortStack]:void 0,columnVisibility:{...H.snapshot.columnVisibility},columnOrder:k,columnWidths:{...H.snapshot.columnWidths},grouping:H.snapshot.grouping}),x("Changes reverted to last saved state","success")},[H,s,P]),jr=u.useCallback(b=>{if(!(s!=null&&s.views))return;const k=s.views.map(B=>({...B,isDefault:B.id===b}));P(s.id,{views:k});const z=s.views.find(B=>B.id===b);z&&x(`"${z.name}" set as default view`,"success")},[s,P]),Dt=u.useCallback(b=>{if(!(s!=null&&s.views))return;const k=s.views.map(B=>B.id===b?{...B,isFavorite:!B.isFavorite,updatedAt:Date.now()}:B);P(s.id,{views:k});const z=s.views.find(B=>B.id===b);z&&!z.isFavorite?x(`"${z.name}" added to favorites`,"success"):z&&x(`"${z.name}" removed from favorites`,"info")},[s,P]),wr=u.useCallback(b=>{if(!(s!=null&&s.views))return;const k=s.views.map(K=>K.id===b?{...K,isDeleted:!0,updatedAt:Date.now()}:K),z=s.activeViewId===b,B=k.find(K=>K.isDefault&&!K.isDeleted);P(s.id,{views:k,activeViewId:z&&B?B.id:s.activeViewId,filters:z&&B?B.snapshot.filters.length>0?B.snapshot.filters:void 0:s.filters,sortStack:z&&B?B.snapshot.sortStack.length>0?B.snapshot.sortStack:void 0:s.sortStack});const J=s.views.find(K=>K.id===b);J&&x(`"${J.name}" moved to Recently Deleted`,"info")},[s,P]),lr=u.useCallback(b=>{if(!(s!=null&&s.views))return;const k=s.views.map(B=>B.id===b?{...B,isDeleted:!1,updatedAt:Date.now()}:B);P(s.id,{views:k});const z=s.views.find(B=>B.id===b);z&&x(`"${z.name}" restored`,"success")},[s,P]),D=u.useCallback(b=>{if(!(s!=null&&s.views))return;const k=s.views.find(fe=>fe.id===b),z=s.views.filter(fe=>!fe.isDeleted||fe.id===b);if((k==null?void 0:k.isDefault)&&z.filter(fe=>fe.isDefault).length===1){x("Cannot delete the last default view","error");return}const J=s.views.filter(fe=>fe.id!==b),K=s.activeViewId===b,ge=J.find(fe=>fe.isDefault&&!fe.isDeleted);P(s.id,{views:J,activeViewId:K&&ge?ge.id:s.activeViewId,filters:K&&ge?ge.snapshot.filters.length>0?ge.snapshot.filters:void 0:s.filters,sortStack:K&&ge?ge.snapshot.sortStack.length>0?ge.snapshot.sortStack:void 0:s.sortStack}),k&&x(`"${k.name}" permanently deleted`,"success")},[s,P]),Y=u.useCallback(b=>{Ee(b),L(!0),O(!1)},[]),pe=u.useCallback((b,k)=>{if(!ue||!(s!=null&&s.views))return;const z=s.views.map(B=>B.id===ue?{...B,name:b,description:k||void 0}:B);P(s.id,{views:z}),Ee(null)},[ue,s,P]),Pe=u.useCallback(b=>{q(b),_(!0),O(!1)},[]),se=u.useCallback(()=>{if(!R||!(s!=null&&s.views))return;const b=s.views.filter(B=>B.id!==R),k=s.activeViewId===R,z=b.find(B=>B.isDefault);P(s.id,{views:b,activeViewId:k&&z?z.id:s.activeViewId,filters:k&&z?z.snapshot.filters.length>0?z.snapshot.filters:void 0:s.filters,sortStack:k&&z?z.snapshot.sortStack.length>0?z.snapshot.sortStack:void 0:s.sortStack}),q(null),_(!1)},[R,s,P]);u.useEffect(()=>{ie!=null&&ie.resetPage?ie.resetPage():Ae(1)},[s==null?void 0:s.filters,Ye,s==null?void 0:s.activeViewId]),u.useEffect(()=>{ie&&ie.currentPage!==Je&&Ae(ie.currentPage)},[ie==null?void 0:ie.currentPage]);const Ot=u.useCallback(b=>{ie!=null&&ie.goToPage&&ie.goToPage(b),Ae(b)},[ie]),_r=u.useCallback(b=>{const k=(Je-1)*wt,z=Math.floor(k/b)+1;Yt(b),Ae(z)},[Je,wt]),ke=u.useCallback((b,k)=>{if(!s)return;if(!ct("edit_columns",Ce)){x(dt("edit_columns"),"error");return}const B={...s.columnVisibility||(H==null?void 0:H.snapshot.columnVisibility)||{},[b]:k};P(s.id,{columnVisibility:B})},[s,H,Ce,P]),Te=u.useCallback(b=>{if(s){if(!ct("edit_columns",Ce)){x(dt("edit_columns"),"error");return}P(s.id,{columnOrder:b})}},[s,Ce,P]),At=u.useCallback((b,k)=>{if(!s)return;if(!ct("edit_columns",Ce)){x(dt("edit_columns"),"error");return}const B={...s.columnWidths||(H==null?void 0:H.snapshot.columnWidths)||{},[b]:k};P(s.id,{columnWidths:B})},[s,H,Ce,P]),po=u.useCallback(b=>{if(!s)return;const z=(s.filters??[]).filter(B=>B.column!==b);P(s.id,{filters:z.length>0?z:void 0})},[s,P]),wi=u.useCallback(()=>{if(!H||!(s!=null&&s.schema))return;const b={},k=[],z={};s.schema.forEach(B=>{b[B.name]=!0,k.push(B.name),z[B.name]=150}),P(s.id,{columnVisibility:b,columnOrder:k,columnWidths:z,filters:void 0,sortStack:void 0}),x("Reset to default layout - all filters and sorts cleared","success")},[H,s,P]),Wo=u.useCallback(Us(b=>{jt(b)},300),[]),ki=u.useCallback(b=>{Wo(b)},[Wo]),Ti=u.useCallback(b=>{if(!b.trim()||!s)return;const k=s.searchHistory||[],z=ws(k,b);P(s.id,{searchHistory:z})},[s,P]),zi=u.useCallback(b=>{if(!s)return;const k=s.searchHistory||[],z=ks(k,b);P(s.id,{searchHistory:z})},[s,P]),Ii=u.useCallback(b=>{if(!s)return;const k=s.searchHistory||[],z=Ts(k,b);P(s.id,{searchHistory:z})},[s,P]),Ei=u.useCallback(b=>{$e(k=>{const z=new Set(k);return z.has(b)?z.delete(b):z.add(b),z})},[]),Bi=u.useCallback((b,k)=>{if(b){const z=new Set;for(let B=0;B<k;B++)z.add(B);$e(z)}else $e(new Set)},[]),Di=u.useCallback((b,k)=>{$e(z=>{const B=new Set(z),J=Math.min(b,k),K=Math.max(b,k);for(let ge=J;ge<=K;ge++)B.add(ge);return B})},[]),Oi=u.useCallback(()=>{$e(new Set)},[]),Ai=u.useCallback(b=>{if(!s)return;const k=s.favoriteRowIndices||[],B=k.includes(b)?k.filter(J=>J!==b):[...k,b];P(s.id,{favoriteRowIndices:B})},[s,P]),Mi=u.useCallback((b,k)=>{if(!s)return;const z=s.favoriteRowIndices||[],B=k?[...z,...b.filter(J=>!z.includes(J))]:z.filter(J=>!b.includes(J));P(s.id,{favoriteRowIndices:B})},[s,P]),Ri=u.useCallback(()=>{if(!s)return;const b=s.favoriteRowIndices||[],k=!s.showFavoritesOnly;if(k&&b.length===0){x("No rows marked as favorite","warning");return}P(s.id,{showFavoritesOnly:k}),$e(new Set),x(k?`Showing ${b.length} favorite row${b.length===1?"":"s"}`:"Showing all data","info")},[s,P]),Wi=u.useCallback(b=>{if(s){if(!ct("edit_columns",Ce)){x(dt("edit_columns"),"error");return}if(b&&s.schema){const{validGrouping:k,invalidColumns:z}=Kn(b,s.schema);z.length>0&&x(`Removed invalid grouping columns: ${z.join(", ")}`,"warning"),Ve();try{const B=s.grouping;k===null?de("grouping","group_cleared",B,null):B?de("grouping","group_reordered",B,k):de("grouping","group_level_added",null,k);const J=(H==null?void 0:H.snapshot.columnOrder)||s.columnOrder||[],K=Er(J,k);P(s.id,{grouping:k,columnOrder:K}),JSON.stringify(K)!==JSON.stringify(s.columnOrder)&&de("columns","column_reordered",s.columnOrder,K),je(!1)}catch(B){const J=bt("processing","grouping",B);He(J)}}else{const k=s.grouping;de("grouping","group_cleared",k,null);const z=(H==null?void 0:H.snapshot.columnOrder)||s.columnOrder||[];P(s.id,{grouping:b,columnOrder:[...z]}),JSON.stringify(z)!==JSON.stringify(s.columnOrder)&&de("columns","column_reordered",s.columnOrder,z),je(!1)}}},[s,H,Ce,P,Ve,He,de]),Pi=u.useCallback(b=>{if(!s)return;const k=s.grouping;if(!k)return;const z=ms(k,b);P(s.id,{grouping:z})},[s,P]),_i=u.useCallback(()=>{xt(!0)},[]),cr=u.useCallback(b=>{s!=null&&s.schema&&(te(!0),setTimeout(()=>{try{let k;b.scope==="visible"?k=Nt:k=s.uploadedData||[];let z;b.columnScope==="all"?(z={},s.schema.forEach(fe=>{z[fe.name]=!0})):z=s.columnVisibility||(H==null?void 0:H.snapshot.columnVisibility)||{};const B=s.columnOrder||(H==null?void 0:H.snapshot.columnOrder),J=Vo(k,s.schema,s.filters??[],s.sortStack??[],H,z,B),K=s.name;let ge;switch(b.format){case"csv":Ho(J,K,b),ge="export_csv";break;case"excel":Uo(J,K,b),ge="export_excel";break;case"json":Go(J,K,b),ge="export_json";break}de("export",ge,null,{format:b.format,scope:b.scope,columnScope:b.columnScope,rowCount:k.length,viewName:(H==null?void 0:H.name)||"Default View"}),x(`Export completed successfully (${b.format.toUpperCase()})`,"success")}catch(k){const z=Zs(k,{onRetry:()=>cr(b)});x(`Export failed: ${z.message}`,{action:{label:"Retry",onClick:()=>cr(b)}});const B=tn(s.id,Mt,z,s.auditHistory||[]);P(s.id,{auditHistory:B}),console.error("Export error:",k)}finally{te(!1)}},500))},[s,H,Nt,P,de]),$i=u.useCallback(b=>{if(s!=null&&s.schema){if(it&&H&&!H.isDefault){Q(b.format),ne(!0),xt(!1);return}cr(b),xt(!1)}},[s,H,it,cr]),$r=u.useCallback(b=>{cr({format:b,scope:"visible",columnScope:"visible"})},[cr]),Fi=u.useCallback(()=>{Z&&$r(Z),ne(!1),Q(null)},[Z,$r]),Li=u.useCallback(()=>{nr(),Z&&$r(Z),ne(!1),Q(null)},[nr,Z,$r]),Ni=u.useCallback(()=>{ne(!1),Q(null)},[]),Vi=u.useCallback(b=>{!(s!=null&&s.schema)||tt.size===0||(te(!0),setTimeout(()=>{try{const k=Array.from(tt).sort((J,K)=>J-K).map(J=>ht[J]).filter(J=>J!==void 0),z=Vo(k,s.schema,s.filters??[],s.sortStack??[],H),B=`${s.name.toLowerCase().replace(/\s+/g,"_")}_selected_export`;switch(b){case"csv":Ho(z,B);break;case"excel":Uo(z,B);break;case"json":Go(z,B);break}x(`Exported ${k.length} selected rows`,"info")}catch(k){x("Export failed. Please try again.","error"),console.error("Export error:",k)}finally{te(!1)}},500))},[s,H,tt,ht]),Hi=u.useCallback(()=>{if(!ct("edit_filters",Ce)){x(dt("edit_filters"),"error");return}Tt(!0)},[Ce]),Ui=u.useCallback((b,k,z)=>{if(s)try{const B=Ps(s),J=_s(b,k,Mt,B),K=$s(s.presets,J);P(s.id,{presets:K});const ge=ho(s.id,J.id);if(de("presets","preset_created",null,{presetId:J.id,name:J.name}),z&&z.length>0){const fe=Fs(z,b,ge,k);window.location.href=fe,x(`Preset created! Opening email client to share with ${z.length} recipient${z.length>1?"s":""}...`,"success")}zt({preset:J,url:ge}),Tt(!1),Fe(!0),x(`Preset "${b}" created successfully`,"success")}catch(B){x(B instanceof Error?B.message:"Failed to create preset","error")}},[s,P,de]),Gi=u.useCallback(async()=>{if(!Be)return;await en(Be.url)?(de("presets","preset_link_copied",null,{presetId:Be.preset.id}),x("Link copied to clipboard","success")):x("Failed to copy link","error")},[Be,de]),Yi=u.useCallback(()=>{Be&&(Zo(Be.url),de("presets","preset_link_opened",null,{presetId:Be.preset.id}),x("Opening preset in new tab...","info"))},[Be,de]),Ji=u.useCallback(()=>{if(!Be||!s)return;const b=Be.preset.id,k=Be.preset.name,z=Xo(s.presets,b);P(s.id,{presets:z}),de("presets","preset_deleted",{presetId:b,name:k},null),Ke===b&&ot(null),Fe(!1),zt(null),x(`Preset "${k}" deleted`,"success")},[Be,s,Ke,P,de]),qi=u.useCallback(()=>{ot(null),x("Exited preset view","info")},[]),Ki=u.useCallback(()=>{Jt(!0)},[]),Xi=u.useCallback(b=>{if(!s)return;const k=ho(s.id,b);Zo(k),de("presets","preset_link_opened",null,{presetId:b}),x("Opening preset in new tab...","info")},[s,de]),Qi=u.useCallback(async(b,k)=>{if(!s)return;const z=ho(s.id,b);await en(z)?(de("presets","preset_link_copied",null,{presetId:b}),x(`Link for "${k}" copied to clipboard`,"success")):x("Failed to copy link. Please try the manual copy method.","error")},[s,de]),Zi=u.useCallback((b,k)=>{if(!s)return;const z=Xo(s.presets,b);P(s.id,{presets:z}),de("presets","preset_deleted",{presetId:b,name:k},null),Ke===b&&ot(null),(Be==null?void 0:Be.preset.id)===b&&(Fe(!1),zt(null)),x(`Preset "${k}" deleted`,"success")},[s,Ke,Be,P,de]);u.useEffect(()=>{if(!s)return;const b=Ls();if(b&&s.presets&&s.schemaLocked&&s.schema){const k=Qo(s.presets,b);if(k){const{sanitizedConfig:z,warnings:B}=Qs(k.config,s.schema);B.length>0&&B.forEach(K=>x(K,"warning"));const J=Ns(z);P(s.id,J),ot(b),de("presets","preset_applied",null,{presetId:k.id,name:k.name}),x(`Loaded preset: ${k.name}`,"info")}else x("Preset not found","info")}},[s==null?void 0:s.schemaLocked]);const es=Ke?Qo(s==null?void 0:s.presets,Ke):void 0;u.useEffect(()=>{s!=null&&s.views&&s.views.length>0&&s.activeViewId&&Ss(s.id,{views:s.views,activeViewId:s.activeViewId})},[s==null?void 0:s.views,s==null?void 0:s.activeViewId,s==null?void 0:s.id]),u.useEffect(()=>{if(s!=null&&s.schemaLocked&&s.schema&&(!s.views||s.views.length===0)){const b=Cs(s.id);if(b&&b.views.length>0){const k=b.views.find(z=>z.id===b.activeViewId);if(k)P(s.id,{views:b.views,activeViewId:b.activeViewId,filters:k.snapshot.filters.length>0?k.snapshot.filters:void 0,sortStack:k.snapshot.sortStack.length>0?k.snapshot.sortStack:void 0});else{const z=b.views.find(B=>B.isDefault)||xo(s.schema);P(s.id,{views:b.views,activeViewId:z.id,filters:z.snapshot.filters.length>0?z.snapshot.filters:void 0,sortStack:z.snapshot.sortStack.length>0?z.snapshot.sortStack:void 0})}}}},[s==null?void 0:s.schemaLocked,s==null?void 0:s.schema,s==null?void 0:s.id]);const ts=u.useCallback(b=>{oe(b),v(!0)},[]),rs=u.useCallback(()=>{v(!1),oe(void 0)},[]),os=(Fo=s==null?void 0:s.views)==null?void 0:Fo.find(b=>b.id===ue),ns=(Lo=s==null?void 0:s.views)==null?void 0:Lo.find(b=>b.id===R);return{reports:c,activeReport:s,activeReportId:d,setActiveReportId:f,isModalOpen:h,setIsModalOpen:m,createReport:Xt,updateReport:P,uploadState:T,handleFileUpload:vr,handleUploadError:Qt,handleRetry:Zt,handleConfirm:Ne,paginatedData:Lt,processedData:Nt,displayData:ht,tableMetrics:Kt,isGrouped:Vt,tableEngine:Bt,activeView:H,isDirty:it,currentTableState:xe,viewChanges:Le,filters:s==null?void 0:s.filters,showFilterPanel:A,setShowFilterPanel:v,filterFocusColumn:F,handleAddFilter:tr,handleUpdateFilter:rr,handleRemoveFilter:or,handleClearAllFilters:Cr,handleOpenFilterForColumn:ts,handleCloseFilterPanel:rs,handleClearFiltersForColumn:po,sortStack:s==null?void 0:s.sortStack,showSortPanel:W,setShowSortPanel:U,handleSort:st,handleUpdateSortStack:er,handleSortAscending:mt,handleSortDescending:Sr,views:s==null?void 0:s.views,showManageViews:w,setShowManageViews:O,showCreateViewModal:V,setShowCreateViewModal:X,showEditViewModal:p,setShowEditViewModal:L,showDeleteConfirmation:$,setShowDeleteConfirmation:_,editingView:os,deletingView:ns,editingViewId:ue,deletingViewId:R,handleSelectView:gt,handleCreateView:at,handleUpdateCurrentView:nr,handleSaveColumnConfigToCurrentView:ir,handleSaveColumnConfigToAllViews:sr,handleSaveAsNewView:We,handleRevertChanges:ar,handleToggleDefault:jr,handleToggleFavorite:Dt,handleSoftDelete:wr,handleRestoreView:lr,handlePermanentDelete:D,handleEditView:Y,handleSaveEditView:pe,handleDeleteView:Pe,handleConfirmDelete:se,showManageColumns:ae,setShowManageColumns:ce,columnVisibility:s==null?void 0:s.columnVisibility,columnOrder:s==null?void 0:s.columnOrder,columnWidths:s==null?void 0:s.columnWidths,handleUpdateColumnVisibility:ke,handleUpdateColumnOrder:Te,handleUpdateColumnWidth:At,handleResetColumnLayout:wi,showGroupPanel:le,setShowGroupPanel:je,grouping:s==null?void 0:s.grouping,groupingState:G,handleGroup:Wi,handleToggleGroupCollapse:Pi,searchQuery:Ye,searchHistory:zs((s==null?void 0:s.searchHistory)||[]),handleSearchChange:ki,handleAddToSearchHistory:Ti,handleToggleSearchFavourite:zi,handleDeleteSearchHistory:Ii,selectedRowIds:tt,handleToggleRowSelection:Ei,handleToggleAllRows:Bi,handleRangeSelection:Di,handleClearSelection:Oi,favoriteRowIndices:(s==null?void 0:s.favoriteRowIndices)||[],resolvedFavoritesSet:Ft,showFavoritesOnly:(s==null?void 0:s.showFavoritesOnly)||!1,handleToggleRowFavorite:Ai,handleBulkSetFavorites:Mi,handleToggleFavoritesFilter:Ri,currentPage:Je,pageSize:wt,paginationEngine:ie,handlePageChange:Ot,handlePageSizeChange:_r,isExporting:ee,showExportModal:qt,setShowExportModal:xt,showDirtyExportWarning:re,handleExport:_i,handleExportWithConfig:$i,handleExportSelected:Vi,handleExportAnyway:Fi,handleSaveAndExport:Li,handleCancelExport:Ni,showAuditHistory:pt,setShowAuditHistory:rt,auditHistory:s==null?void 0:s.auditHistory,showCreatePreset:kt,setShowCreatePreset:Tt,showShareLink:ft,setShowShareLink:Fe,showManagePresets:qe,setShowManagePresets:Jt,generatedPreset:Be,activePreset:es,activePresetId:Ke,handleOpenSharePreset:Hi,handleOpenManagePresets:Ki,handleCreatePreset:Ui,handleCopyPresetLink:Gi,handleOpenPreset:Yi,handleDeletePreset:Ji,handleClearActivePreset:qi,handleOpenPresetById:Xi,handleCopyPresetLinkById:Qi,handleDeletePresetById:Zi,userRole:Ce,isViewerRole:Et,currentUserId:Mt,featureLimitWarning:nt,setFeatureLimitWarning:_t,datasetMeta:yr,reportError:gr,setReportError:$t,handleError:He,schema:s==null?void 0:s.schema,hasSchemaConflicts:s!=null&&s.schema?ls(s.schema):!1,snack:S,handleSnackClose:E,showSnack:x}}const _e={sort:{maxLevels:5,defaultSortStack:[]},filter:{maxConditions:10,allowedOperators:["equals","contains","startsWith","endsWith","gt","lt","gte","lte","isTrue","isFalse","NULL","NOT_NULL"],defaultFilters:[]},columns:{maxVisible:20,minColumnWidth:60,maxColumnWidth:800,defaultHiddenColumns:[],defaultColumnOrder:[],defaultColumnWidths:{}},grouping:{maxLevels:3,allowNested:!0,allowCollapse:!0,defaultGrouping:null},export:{allowedFormats:["csv","excel","json"]},display:{showDevPanel:!1}},Qn="urm_dev_config";function pa(){try{const t=localStorage.getItem(Qn);if(!t)return _e;const r=JSON.parse(t);return{sort:{..._e.sort,...r.sort},filter:{..._e.filter,...r.filter},columns:{..._e.columns,...r.columns},grouping:{..._e.grouping,...r.grouping},export:{..._e.export,...r.export},display:{..._e.display,...r.display}}}catch{return _e}}function fa(t){try{localStorage.setItem(Qn,JSON.stringify(t))}catch{}}function xa(t,r,n){return!n||!r?t:{sort:{...t.sort,...r.sort},filter:{...t.filter,...r.filter},columns:{...t.columns,...r.columns},grouping:{...t.grouping,...r.grouping},export:{...t.export,...r.export},display:{...t.display,...r.display}}}const Zn=u.createContext(_e);function Mr(){return u.useContext(Zn)}const ei=u.createContext(void 0);function Bo(t){const{children:r,initialData:n,data:i,mode:a="builder",autoLoad:c=!0,config:l,devConfig:d,showDevPanel:f=!1}=t,m=ua({mode:a,autoLoad:c,initialData:i||n,config:l}),[g,y]=u.useState(()=>pa()),S=(()=>{const s=xa(g,d,!!d);return{...s,display:{...s.display,showDevPanel:f||s.display.showDevPanel}}})(),C=u.useCallback(E=>{y(E),fa(E)},[]),x={...m,activeDevConfig:S,handleDevConfigChange:C};return e.jsx(Zn.Provider,{value:S,children:e.jsx(ei.Provider,{value:x,children:r})})}function Kr(){const t=u.useContext(ei);if(t===void 0)throw new Error("useReportContext must be used within a ReportProvider. Wrap your component tree with <ReportProvider>...</ReportProvider>");return t}function ha({onCreateReport:t,reports:r=[],activeReportId:n,onReportClick:i}){const a=r.find(c=>c.id===n);return e.jsx(o.Box,{component:"header",sx:{position:"sticky",top:0,zIndex:50,borderBottom:"1px solid",borderColor:"divider",bgcolor:"background.paper"},children:e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,height:64},children:[e.jsxs(o.Breadcrumbs,{separator:e.jsx(j.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}),sx:{display:"flex",alignItems:"center"},children:[e.jsx(o.Typography,{variant:"h6",component:"h1",sx:{fontWeight:500,fontSize:"1.375rem",color:"text.primary",letterSpacing:"-0.01em",cursor:r.length>0&&a?"pointer":"default","&:hover":r.length>0&&a?{color:"primary.main"}:{}},onClick:()=>{r.length>0},children:"Reports"}),a&&e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(o.Typography,{sx:{fontWeight:500,fontSize:"1.125rem",color:"primary.main",cursor:"pointer","&:hover":{textDecoration:"underline"}},onClick:()=>i==null?void 0:i(a.id),children:a.name}),e.jsx(o.Tooltip,{title:a.description||"No description",arrow:!0,placement:"bottom",children:e.jsx(j.InfoOutlined,{sx:{fontSize:18,color:"#5f6368",opacity:.7,cursor:"help","&:hover":{opacity:1}}})})]})]}),e.jsx(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:e.jsx(o.Button,{variant:"contained",startIcon:e.jsx(j.Add,{sx:{fontSize:18}}),onClick:t,sx:{borderRadius:"20px",px:3,textTransform:"none",fontWeight:500,fontSize:"0.875rem",py:.75},children:"New Report"})})]})})}function Gt(t,...r){const n=new URL(`https://mui.com/production-error/?code=${t}`);return r.forEach(i=>n.searchParams.append("args[]",i)),`Minified MUI error #${t}; visit ${n} for the full message.`}const ma="$$material";function ga(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Vr={exports:{}},Hr={exports:{}},he={};/** @license React v16.13.1
|
|
12
12
|
* react-is.production.min.js
|
|
13
13
|
*
|
|
14
14
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
15
15
|
*
|
|
16
16
|
* This source code is licensed under the MIT license found in the
|
|
17
17
|
* LICENSE file in the root directory of this source tree.
|
|
18
|
-
*/var
|
|
18
|
+
*/var on;function ya(){if(on)return he;on=1;var t=typeof Symbol=="function"&&Symbol.for,r=t?Symbol.for("react.element"):60103,n=t?Symbol.for("react.portal"):60106,i=t?Symbol.for("react.fragment"):60107,a=t?Symbol.for("react.strict_mode"):60108,c=t?Symbol.for("react.profiler"):60114,l=t?Symbol.for("react.provider"):60109,d=t?Symbol.for("react.context"):60110,f=t?Symbol.for("react.async_mode"):60111,h=t?Symbol.for("react.concurrent_mode"):60111,m=t?Symbol.for("react.forward_ref"):60112,g=t?Symbol.for("react.suspense"):60113,y=t?Symbol.for("react.suspense_list"):60120,S=t?Symbol.for("react.memo"):60115,C=t?Symbol.for("react.lazy"):60116,x=t?Symbol.for("react.block"):60121,E=t?Symbol.for("react.fundamental"):60117,s=t?Symbol.for("react.responder"):60118,T=t?Symbol.for("react.scope"):60119;function I(v){if(typeof v=="object"&&v!==null){var W=v.$$typeof;switch(W){case r:switch(v=v.type,v){case f:case h:case i:case c:case a:case g:return v;default:switch(v=v&&v.$$typeof,v){case d:case m:case C:case S:case l:return v;default:return W}}case n:return W}}}function A(v){return I(v)===h}return he.AsyncMode=f,he.ConcurrentMode=h,he.ContextConsumer=d,he.ContextProvider=l,he.Element=r,he.ForwardRef=m,he.Fragment=i,he.Lazy=C,he.Memo=S,he.Portal=n,he.Profiler=c,he.StrictMode=a,he.Suspense=g,he.isAsyncMode=function(v){return A(v)||I(v)===f},he.isConcurrentMode=A,he.isContextConsumer=function(v){return I(v)===d},he.isContextProvider=function(v){return I(v)===l},he.isElement=function(v){return typeof v=="object"&&v!==null&&v.$$typeof===r},he.isForwardRef=function(v){return I(v)===m},he.isFragment=function(v){return I(v)===i},he.isLazy=function(v){return I(v)===C},he.isMemo=function(v){return I(v)===S},he.isPortal=function(v){return I(v)===n},he.isProfiler=function(v){return I(v)===c},he.isStrictMode=function(v){return I(v)===a},he.isSuspense=function(v){return I(v)===g},he.isValidElementType=function(v){return typeof v=="string"||typeof v=="function"||v===i||v===h||v===c||v===a||v===g||v===y||typeof v=="object"&&v!==null&&(v.$$typeof===C||v.$$typeof===S||v.$$typeof===l||v.$$typeof===d||v.$$typeof===m||v.$$typeof===E||v.$$typeof===s||v.$$typeof===T||v.$$typeof===x)},he.typeOf=I,he}var me={};/** @license React v16.13.1
|
|
19
19
|
* react-is.development.js
|
|
20
20
|
*
|
|
21
21
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
22
22
|
*
|
|
23
23
|
* This source code is licensed under the MIT license found in the
|
|
24
24
|
* LICENSE file in the root directory of this source tree.
|
|
25
|
-
*/var
|
|
25
|
+
*/var nn;function ba(){return nn||(nn=1,process.env.NODE_ENV!=="production"&&(function(){var t=typeof Symbol=="function"&&Symbol.for,r=t?Symbol.for("react.element"):60103,n=t?Symbol.for("react.portal"):60106,i=t?Symbol.for("react.fragment"):60107,a=t?Symbol.for("react.strict_mode"):60108,c=t?Symbol.for("react.profiler"):60114,l=t?Symbol.for("react.provider"):60109,d=t?Symbol.for("react.context"):60110,f=t?Symbol.for("react.async_mode"):60111,h=t?Symbol.for("react.concurrent_mode"):60111,m=t?Symbol.for("react.forward_ref"):60112,g=t?Symbol.for("react.suspense"):60113,y=t?Symbol.for("react.suspense_list"):60120,S=t?Symbol.for("react.memo"):60115,C=t?Symbol.for("react.lazy"):60116,x=t?Symbol.for("react.block"):60121,E=t?Symbol.for("react.fundamental"):60117,s=t?Symbol.for("react.responder"):60118,T=t?Symbol.for("react.scope"):60119;function I(G){return typeof G=="string"||typeof G=="function"||G===i||G===h||G===c||G===a||G===g||G===y||typeof G=="object"&&G!==null&&(G.$$typeof===C||G.$$typeof===S||G.$$typeof===l||G.$$typeof===d||G.$$typeof===m||G.$$typeof===E||G.$$typeof===s||G.$$typeof===T||G.$$typeof===x)}function A(G){if(typeof G=="object"&&G!==null){var Me=G.$$typeof;switch(Me){case r:var Ye=G.type;switch(Ye){case f:case h:case i:case c:case a:case g:return Ye;default:var jt=Ye&&Ye.$$typeof;switch(jt){case d:case m:case C:case S:case l:return jt;default:return Me}}case n:return Me}}}var v=f,W=h,U=d,w=l,O=r,V=m,X=i,p=C,L=S,$=n,_=c,F=a,oe=g,ue=!1;function Ee(G){return ue||(ue=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),R(G)||A(G)===f}function R(G){return A(G)===h}function q(G){return A(G)===d}function ee(G){return A(G)===l}function te(G){return typeof G=="object"&&G!==null&&G.$$typeof===r}function re(G){return A(G)===m}function ne(G){return A(G)===i}function Z(G){return A(G)===C}function Q(G){return A(G)===S}function ae(G){return A(G)===n}function ce(G){return A(G)===c}function le(G){return A(G)===a}function je(G){return A(G)===g}me.AsyncMode=v,me.ConcurrentMode=W,me.ContextConsumer=U,me.ContextProvider=w,me.Element=O,me.ForwardRef=V,me.Fragment=X,me.Lazy=p,me.Memo=L,me.Portal=$,me.Profiler=_,me.StrictMode=F,me.Suspense=oe,me.isAsyncMode=Ee,me.isConcurrentMode=R,me.isContextConsumer=q,me.isContextProvider=ee,me.isElement=te,me.isForwardRef=re,me.isFragment=ne,me.isLazy=Z,me.isMemo=Q,me.isPortal=ae,me.isProfiler=ce,me.isStrictMode=le,me.isSuspense=je,me.isValidElementType=I,me.typeOf=A})()),me}var sn;function ti(){return sn||(sn=1,process.env.NODE_ENV==="production"?Hr.exports=ya():Hr.exports=ba()),Hr.exports}/*
|
|
26
26
|
object-assign
|
|
27
27
|
(c) Sindre Sorhus
|
|
28
28
|
@license MIT
|
|
29
|
-
*/var
|
|
30
|
-
Valid keys: `+JSON.stringify(Object.keys(
|
|
29
|
+
*/var mo,an;function va(){if(an)return mo;an=1;var t=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function i(c){if(c==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(c)}function a(){try{if(!Object.assign)return!1;var c=new String("abc");if(c[5]="de",Object.getOwnPropertyNames(c)[0]==="5")return!1;for(var l={},d=0;d<10;d++)l["_"+String.fromCharCode(d)]=d;var f=Object.getOwnPropertyNames(l).map(function(m){return l[m]});if(f.join("")!=="0123456789")return!1;var h={};return"abcdefghijklmnopqrst".split("").forEach(function(m){h[m]=m}),Object.keys(Object.assign({},h)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return mo=a()?Object.assign:function(c,l){for(var d,f=i(c),h,m=1;m<arguments.length;m++){d=Object(arguments[m]);for(var g in d)r.call(d,g)&&(f[g]=d[g]);if(t){h=t(d);for(var y=0;y<h.length;y++)n.call(d,h[y])&&(f[h[y]]=d[h[y]])}}return f},mo}var go,ln;function Do(){if(ln)return go;ln=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return go=t,go}var yo,cn;function ri(){return cn||(cn=1,yo=Function.call.bind(Object.prototype.hasOwnProperty)),yo}var bo,dn;function Sa(){if(dn)return bo;dn=1;var t=function(){};if(process.env.NODE_ENV!=="production"){var r=Do(),n={},i=ri();t=function(c){var l="Warning: "+c;typeof console<"u"&&console.error(l);try{throw new Error(l)}catch{}}}function a(c,l,d,f,h){if(process.env.NODE_ENV!=="production"){for(var m in c)if(i(c,m)){var g;try{if(typeof c[m]!="function"){var y=Error((f||"React class")+": "+d+" type `"+m+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof c[m]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw y.name="Invariant Violation",y}g=c[m](l,m,f,d,null,r)}catch(C){g=C}if(g&&!(g instanceof Error)&&t((f||"React class")+": type specification of "+d+" `"+m+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof g+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),g instanceof Error&&!(g.message in n)){n[g.message]=!0;var S=h?h():"";t("Failed "+d+" type: "+g.message+(S??""))}}}}return a.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},bo=a,bo}var vo,un;function Ca(){if(un)return vo;un=1;var t=ti(),r=va(),n=Do(),i=ri(),a=Sa(),c=function(){};process.env.NODE_ENV!=="production"&&(c=function(d){var f="Warning: "+d;typeof console<"u"&&console.error(f);try{throw new Error(f)}catch{}});function l(){return null}return vo=function(d,f){var h=typeof Symbol=="function"&&Symbol.iterator,m="@@iterator";function g(R){var q=R&&(h&&R[h]||R[m]);if(typeof q=="function")return q}var y="<<anonymous>>",S={array:s("array"),bigint:s("bigint"),bool:s("boolean"),func:s("function"),number:s("number"),object:s("object"),string:s("string"),symbol:s("symbol"),any:T(),arrayOf:I,element:A(),elementType:v(),instanceOf:W,node:V(),objectOf:w,oneOf:U,oneOfType:O,shape:p,exact:L};function C(R,q){return R===q?R!==0||1/R===1/q:R!==R&&q!==q}function x(R,q){this.message=R,this.data=q&&typeof q=="object"?q:{},this.stack=""}x.prototype=Error.prototype;function E(R){if(process.env.NODE_ENV!=="production")var q={},ee=0;function te(ne,Z,Q,ae,ce,le,je){if(ae=ae||y,le=le||Q,je!==n){if(f){var G=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw G.name="Invariant Violation",G}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var Me=ae+":"+Q;!q[Me]&&ee<3&&(c("You are manually calling a React.PropTypes validation function for the `"+le+"` prop on `"+ae+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),q[Me]=!0,ee++)}}return Z[Q]==null?ne?Z[Q]===null?new x("The "+ce+" `"+le+"` is marked as required "+("in `"+ae+"`, but its value is `null`.")):new x("The "+ce+" `"+le+"` is marked as required in "+("`"+ae+"`, but its value is `undefined`.")):null:R(Z,Q,ae,ce,le)}var re=te.bind(null,!1);return re.isRequired=te.bind(null,!0),re}function s(R){function q(ee,te,re,ne,Z,Q){var ae=ee[te],ce=F(ae);if(ce!==R){var le=oe(ae);return new x("Invalid "+ne+" `"+Z+"` of type "+("`"+le+"` supplied to `"+re+"`, expected ")+("`"+R+"`."),{expectedType:R})}return null}return E(q)}function T(){return E(l)}function I(R){function q(ee,te,re,ne,Z){if(typeof R!="function")return new x("Property `"+Z+"` of component `"+re+"` has invalid PropType notation inside arrayOf.");var Q=ee[te];if(!Array.isArray(Q)){var ae=F(Q);return new x("Invalid "+ne+" `"+Z+"` of type "+("`"+ae+"` supplied to `"+re+"`, expected an array."))}for(var ce=0;ce<Q.length;ce++){var le=R(Q,ce,re,ne,Z+"["+ce+"]",n);if(le instanceof Error)return le}return null}return E(q)}function A(){function R(q,ee,te,re,ne){var Z=q[ee];if(!d(Z)){var Q=F(Z);return new x("Invalid "+re+" `"+ne+"` of type "+("`"+Q+"` supplied to `"+te+"`, expected a single ReactElement."))}return null}return E(R)}function v(){function R(q,ee,te,re,ne){var Z=q[ee];if(!t.isValidElementType(Z)){var Q=F(Z);return new x("Invalid "+re+" `"+ne+"` of type "+("`"+Q+"` supplied to `"+te+"`, expected a single ReactElement type."))}return null}return E(R)}function W(R){function q(ee,te,re,ne,Z){if(!(ee[te]instanceof R)){var Q=R.name||y,ae=Ee(ee[te]);return new x("Invalid "+ne+" `"+Z+"` of type "+("`"+ae+"` supplied to `"+re+"`, expected ")+("instance of `"+Q+"`."))}return null}return E(q)}function U(R){if(!Array.isArray(R))return process.env.NODE_ENV!=="production"&&(arguments.length>1?c("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):c("Invalid argument supplied to oneOf, expected an array.")),l;function q(ee,te,re,ne,Z){for(var Q=ee[te],ae=0;ae<R.length;ae++)if(C(Q,R[ae]))return null;var ce=JSON.stringify(R,function(je,G){var Me=oe(G);return Me==="symbol"?String(G):G});return new x("Invalid "+ne+" `"+Z+"` of value `"+String(Q)+"` "+("supplied to `"+re+"`, expected one of "+ce+"."))}return E(q)}function w(R){function q(ee,te,re,ne,Z){if(typeof R!="function")return new x("Property `"+Z+"` of component `"+re+"` has invalid PropType notation inside objectOf.");var Q=ee[te],ae=F(Q);if(ae!=="object")return new x("Invalid "+ne+" `"+Z+"` of type "+("`"+ae+"` supplied to `"+re+"`, expected an object."));for(var ce in Q)if(i(Q,ce)){var le=R(Q,ce,re,ne,Z+"."+ce,n);if(le instanceof Error)return le}return null}return E(q)}function O(R){if(!Array.isArray(R))return process.env.NODE_ENV!=="production"&&c("Invalid argument supplied to oneOfType, expected an instance of array."),l;for(var q=0;q<R.length;q++){var ee=R[q];if(typeof ee!="function")return c("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+ue(ee)+" at index "+q+"."),l}function te(re,ne,Z,Q,ae){for(var ce=[],le=0;le<R.length;le++){var je=R[le],G=je(re,ne,Z,Q,ae,n);if(G==null)return null;G.data&&i(G.data,"expectedType")&&ce.push(G.data.expectedType)}var Me=ce.length>0?", expected one of type ["+ce.join(", ")+"]":"";return new x("Invalid "+Q+" `"+ae+"` supplied to "+("`"+Z+"`"+Me+"."))}return E(te)}function V(){function R(q,ee,te,re,ne){return $(q[ee])?null:new x("Invalid "+re+" `"+ne+"` supplied to "+("`"+te+"`, expected a ReactNode."))}return E(R)}function X(R,q,ee,te,re){return new x((R||"React class")+": "+q+" type `"+ee+"."+te+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+re+"`.")}function p(R){function q(ee,te,re,ne,Z){var Q=ee[te],ae=F(Q);if(ae!=="object")return new x("Invalid "+ne+" `"+Z+"` of type `"+ae+"` "+("supplied to `"+re+"`, expected `object`."));for(var ce in R){var le=R[ce];if(typeof le!="function")return X(re,ne,Z,ce,oe(le));var je=le(Q,ce,re,ne,Z+"."+ce,n);if(je)return je}return null}return E(q)}function L(R){function q(ee,te,re,ne,Z){var Q=ee[te],ae=F(Q);if(ae!=="object")return new x("Invalid "+ne+" `"+Z+"` of type `"+ae+"` "+("supplied to `"+re+"`, expected `object`."));var ce=r({},ee[te],R);for(var le in ce){var je=R[le];if(i(R,le)&&typeof je!="function")return X(re,ne,Z,le,oe(je));if(!je)return new x("Invalid "+ne+" `"+Z+"` key `"+le+"` supplied to `"+re+"`.\nBad object: "+JSON.stringify(ee[te],null," ")+`
|
|
30
|
+
Valid keys: `+JSON.stringify(Object.keys(R),null," "));var G=je(Q,le,re,ne,Z+"."+le,n);if(G)return G}return null}return E(q)}function $(R){switch(typeof R){case"number":case"string":case"undefined":return!0;case"boolean":return!R;case"object":if(Array.isArray(R))return R.every($);if(R===null||d(R))return!0;var q=g(R);if(q){var ee=q.call(R),te;if(q!==R.entries){for(;!(te=ee.next()).done;)if(!$(te.value))return!1}else for(;!(te=ee.next()).done;){var re=te.value;if(re&&!$(re[1]))return!1}}else return!1;return!0;default:return!1}}function _(R,q){return R==="symbol"?!0:q?q["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&q instanceof Symbol:!1}function F(R){var q=typeof R;return Array.isArray(R)?"array":R instanceof RegExp?"object":_(q,R)?"symbol":q}function oe(R){if(typeof R>"u"||R===null)return""+R;var q=F(R);if(q==="object"){if(R instanceof Date)return"date";if(R instanceof RegExp)return"regexp"}return q}function ue(R){var q=oe(R);switch(q){case"array":case"object":return"an "+q;case"boolean":case"date":case"regexp":return"a "+q;default:return q}}function Ee(R){return!R.constructor||!R.constructor.name?y:R.constructor.name}return S.checkPropTypes=a,S.resetWarningCache=a.resetWarningCache,S.PropTypes=S,S},vo}var So,pn;function ja(){if(pn)return So;pn=1;var t=Do();function r(){}function n(){}return n.resetWarningCache=r,So=function(){function i(l,d,f,h,m,g){if(g!==t){var y=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw y.name="Invariant Violation",y}}i.isRequired=i;function a(){return i}var c={array:i,bigint:i,bool:i,func:i,number:i,object:i,string:i,symbol:i,any:i,arrayOf:a,element:i,elementType:i,instanceOf:a,node:i,objectOf:a,oneOf:a,oneOfType:a,shape:a,exact:a,checkPropTypes:n,resetWarningCache:r};return c.PropTypes=c,c},So}var fn;function wa(){if(fn)return Vr.exports;if(fn=1,process.env.NODE_ENV!=="production"){var t=ti(),r=!0;Vr.exports=Ca()(t.isElement,r)}else Vr.exports=ja()();return Vr.exports}var ka=wa();const kr=ga(ka);var Ur={exports:{}},ve={};/**
|
|
31
31
|
* @license React
|
|
32
32
|
* react-is.production.js
|
|
33
33
|
*
|
|
@@ -35,7 +35,7 @@ Valid keys: `+JSON.stringify(Object.keys(O),null," "));var $=ve(q,se,Z,re,J+"."
|
|
|
35
35
|
*
|
|
36
36
|
* This source code is licensed under the MIT license found in the
|
|
37
37
|
* LICENSE file in the root directory of this source tree.
|
|
38
|
-
*/var
|
|
38
|
+
*/var xn;function Ta(){if(xn)return ve;xn=1;var t=Symbol.for("react.transitional.element"),r=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),l=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),y=Symbol.for("react.view_transition"),S=Symbol.for("react.client.reference");function C(x){if(typeof x=="object"&&x!==null){var E=x.$$typeof;switch(E){case t:switch(x=x.type,x){case n:case a:case i:case f:case h:case y:return x;default:switch(x=x&&x.$$typeof,x){case l:case d:case g:case m:return x;case c:return x;default:return E}}case r:return E}}}return ve.ContextConsumer=c,ve.ContextProvider=l,ve.Element=t,ve.ForwardRef=d,ve.Fragment=n,ve.Lazy=g,ve.Memo=m,ve.Portal=r,ve.Profiler=a,ve.StrictMode=i,ve.Suspense=f,ve.SuspenseList=h,ve.isContextConsumer=function(x){return C(x)===c},ve.isContextProvider=function(x){return C(x)===l},ve.isElement=function(x){return typeof x=="object"&&x!==null&&x.$$typeof===t},ve.isForwardRef=function(x){return C(x)===d},ve.isFragment=function(x){return C(x)===n},ve.isLazy=function(x){return C(x)===g},ve.isMemo=function(x){return C(x)===m},ve.isPortal=function(x){return C(x)===r},ve.isProfiler=function(x){return C(x)===a},ve.isStrictMode=function(x){return C(x)===i},ve.isSuspense=function(x){return C(x)===f},ve.isSuspenseList=function(x){return C(x)===h},ve.isValidElementType=function(x){return typeof x=="string"||typeof x=="function"||x===n||x===a||x===i||x===f||x===h||typeof x=="object"&&x!==null&&(x.$$typeof===g||x.$$typeof===m||x.$$typeof===l||x.$$typeof===c||x.$$typeof===d||x.$$typeof===S||x.getModuleId!==void 0)},ve.typeOf=C,ve}var Se={};/**
|
|
39
39
|
* @license React
|
|
40
40
|
* react-is.development.js
|
|
41
41
|
*
|
|
@@ -43,16 +43,16 @@ Valid keys: `+JSON.stringify(Object.keys(O),null," "));var $=ve(q,se,Z,re,J+"."
|
|
|
43
43
|
*
|
|
44
44
|
* This source code is licensed under the MIT license found in the
|
|
45
45
|
* LICENSE file in the root directory of this source tree.
|
|
46
|
-
*/var
|
|
47
|
-
For example, \`@sm\` or \`@600\` or \`@40rem/sidebar\`.`);return null}const[,i,a]=n,
|
|
46
|
+
*/var hn;function za(){return hn||(hn=1,process.env.NODE_ENV!=="production"&&(function(){function t(x){if(typeof x=="object"&&x!==null){var E=x.$$typeof;switch(E){case r:switch(x=x.type,x){case i:case c:case a:case h:case m:case S:return x;default:switch(x=x&&x.$$typeof,x){case d:case f:case y:case g:return x;case l:return x;default:return E}}case n:return E}}}var r=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),d=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),m=Symbol.for("react.suspense_list"),g=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),S=Symbol.for("react.view_transition"),C=Symbol.for("react.client.reference");Se.ContextConsumer=l,Se.ContextProvider=d,Se.Element=r,Se.ForwardRef=f,Se.Fragment=i,Se.Lazy=y,Se.Memo=g,Se.Portal=n,Se.Profiler=c,Se.StrictMode=a,Se.Suspense=h,Se.SuspenseList=m,Se.isContextConsumer=function(x){return t(x)===l},Se.isContextProvider=function(x){return t(x)===d},Se.isElement=function(x){return typeof x=="object"&&x!==null&&x.$$typeof===r},Se.isForwardRef=function(x){return t(x)===f},Se.isFragment=function(x){return t(x)===i},Se.isLazy=function(x){return t(x)===y},Se.isMemo=function(x){return t(x)===g},Se.isPortal=function(x){return t(x)===n},Se.isProfiler=function(x){return t(x)===c},Se.isStrictMode=function(x){return t(x)===a},Se.isSuspense=function(x){return t(x)===h},Se.isSuspenseList=function(x){return t(x)===m},Se.isValidElementType=function(x){return typeof x=="string"||typeof x=="function"||x===i||x===c||x===a||x===h||x===m||typeof x=="object"&&x!==null&&(x.$$typeof===y||x.$$typeof===g||x.$$typeof===d||x.$$typeof===l||x.$$typeof===f||x.$$typeof===C||x.getModuleId!==void 0)},Se.typeOf=t})()),Se}var mn;function Ia(){return mn||(mn=1,process.env.NODE_ENV==="production"?Ur.exports=Ta():Ur.exports=za()),Ur.exports}var oi=Ia();function Rt(t){if(typeof t!="object"||t===null)return!1;const r=Object.getPrototypeOf(t);return(r===null||r===Object.prototype||Object.getPrototypeOf(r)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)}function ni(t){if(Jr.isValidElement(t)||oi.isValidElementType(t)||!Rt(t))return t;const r={};return Object.keys(t).forEach(n=>{r[n]=ni(t[n])}),r}function Ge(t,r,n={clone:!0}){const i=n.clone?{...t}:t;return Rt(t)&&Rt(r)&&Object.keys(r).forEach(a=>{Jr.isValidElement(r[a])||oi.isValidElementType(r[a])?i[a]=r[a]:Rt(r[a])&&Object.prototype.hasOwnProperty.call(t,a)&&Rt(t[a])?i[a]=Ge(t[a],r[a],n):n.clone?i[a]=Rt(r[a])?ni(r[a]):r[a]:i[a]=r[a]}),i}const Ea=t=>{const r=Object.keys(t).map(n=>({key:n,val:t[n]}))||[];return r.sort((n,i)=>n.val-i.val),r.reduce((n,i)=>({...n,[i.key]:i.val}),{})};function Ba(t){const{values:r={xs:0,sm:600,md:900,lg:1200,xl:1536},unit:n="px",step:i=5,...a}=t,c=Ea(r),l=Object.keys(c);function d(y){return`@media (min-width:${typeof r[y]=="number"?r[y]:y}${n})`}function f(y){return`@media (max-width:${(typeof r[y]=="number"?r[y]:y)-i/100}${n})`}function h(y,S){const C=l.indexOf(S);return`@media (min-width:${typeof r[y]=="number"?r[y]:y}${n}) and (max-width:${(C!==-1&&typeof r[l[C]]=="number"?r[l[C]]:S)-i/100}${n})`}function m(y){return l.indexOf(y)+1<l.length?h(y,l[l.indexOf(y)+1]):d(y)}function g(y){const S=l.indexOf(y);return S===0?d(l[1]):S===l.length-1?f(l[S]):h(y,l[l.indexOf(y)+1]).replace("@media","@media not all and")}return{keys:l,values:c,up:d,down:f,between:h,only:m,not:g,unit:n,...a}}function gn(t,r){if(!t.containerQueries)return r;const n=Object.keys(r).filter(i=>i.startsWith("@container")).sort((i,a)=>{var l,d;const c=/min-width:\s*([0-9.]+)/;return+(((l=i.match(c))==null?void 0:l[1])||0)-+(((d=a.match(c))==null?void 0:d[1])||0)});return n.length?n.reduce((i,a)=>{const c=r[a];return delete i[a],i[a]=c,i},{...r}):r}function Da(t,r){return r==="@"||r.startsWith("@")&&(t.some(n=>r.startsWith(`@${n}`))||!!r.match(/^@\d/))}function Oa(t,r){const n=r.match(/^@([^/]+)?\/?(.+)?$/);if(!n){if(process.env.NODE_ENV!=="production")throw new Error(`MUI: The provided shorthand ${`(${r})`} is invalid. The format should be \`@<breakpoint | number>\` or \`@<breakpoint | number>/<container>\`.
|
|
47
|
+
For example, \`@sm\` or \`@600\` or \`@40rem/sidebar\`.`);return null}const[,i,a]=n,c=Number.isNaN(+i)?i||0:+i;return t.containerQueries(a).up(c)}function Aa(t){const r=(c,l)=>c.replace("@media",l?`@container ${l}`:"@container");function n(c,l){c.up=(...d)=>r(t.breakpoints.up(...d),l),c.down=(...d)=>r(t.breakpoints.down(...d),l),c.between=(...d)=>r(t.breakpoints.between(...d),l),c.only=(...d)=>r(t.breakpoints.only(...d),l),c.not=(...d)=>{const f=r(t.breakpoints.not(...d),l);return f.includes("not all and")?f.replace("not all and ","").replace("min-width:","width<").replace("max-width:","width>").replace("and","or"):f}}const i={},a=c=>(n(i,c),i);return n(a),{...t,containerQueries:a}}const Ma={borderRadius:4},Pt=process.env.NODE_ENV!=="production"?kr.oneOfType([kr.number,kr.string,kr.object,kr.array]):{};function Or(t,r){return r?Ge(t,r,{clone:!1}):t}const Xr={xs:0,sm:600,md:900,lg:1200,xl:1536},yn={keys:["xs","sm","md","lg","xl"],up:t=>`@media (min-width:${Xr[t]}px)`},Ra={containerQueries:t=>({up:r=>{let n=typeof r=="number"?r:Xr[r]||r;return typeof n=="number"&&(n=`${n}px`),t?`@container ${t} (min-width:${n})`:`@container (min-width:${n})`}})};function Ct(t,r,n){const i=t.theme||{};if(Array.isArray(r)){const c=i.breakpoints||yn;return r.reduce((l,d,f)=>(l[c.up(c.keys[f])]=n(r[f]),l),{})}if(typeof r=="object"){const c=i.breakpoints||yn;return Object.keys(r).reduce((l,d)=>{if(Da(c.keys,d)){const f=Oa(i.containerQueries?i:Ra,d);f&&(l[f]=n(r[d],d))}else if(Object.keys(c.values||Xr).includes(d)){const f=c.up(d);l[f]=n(r[d],d)}else{const f=d;l[f]=r[f]}return l},{})}return n(r)}function Wa(t={}){var n;return((n=t.keys)==null?void 0:n.reduce((i,a)=>{const c=t.up(a);return i[c]={},i},{}))||{}}function bn(t,r){return t.reduce((n,i)=>{const a=n[i];return(!a||Object.keys(a).length===0)&&delete n[i],n},r)}function ii(t){if(typeof t!="string")throw new Error(process.env.NODE_ENV!=="production"?"MUI: `capitalize(string)` expects a string argument.":Gt(7));return t.charAt(0).toUpperCase()+t.slice(1)}function Qr(t,r,n=!0){if(!r||typeof r!="string")return null;if(t&&t.vars&&n){const i=`vars.${r}`.split(".").reduce((a,c)=>a&&a[c]?a[c]:null,t);if(i!=null)return i}return r.split(".").reduce((i,a)=>i&&i[a]!=null?i[a]:null,t)}function Yr(t,r,n,i=n){let a;return typeof t=="function"?a=t(n):Array.isArray(t)?a=t[n]||i:a=Qr(t,n)||i,r&&(a=r(a,i,t)),a}function De(t){const{prop:r,cssProperty:n=t.prop,themeKey:i,transform:a}=t,c=l=>{if(l[r]==null)return null;const d=l[r],f=l.theme,h=Qr(f,i)||{};return Ct(l,d,g=>{let y=Yr(h,a,g);return g===y&&typeof g=="string"&&(y=Yr(h,a,`${r}${g==="default"?"":ii(g)}`,g)),n===!1?y:{[n]:y}})};return c.propTypes=process.env.NODE_ENV!=="production"?{[r]:Pt}:{},c.filterProps=[r],c}function Pa(t){const r={};return n=>(r[n]===void 0&&(r[n]=t(n)),r[n])}const _a={m:"margin",p:"padding"},$a={t:"Top",r:"Right",b:"Bottom",l:"Left",x:["Left","Right"],y:["Top","Bottom"]},vn={marginX:"mx",marginY:"my",paddingX:"px",paddingY:"py"},Fa=Pa(t=>{if(t.length>2)if(vn[t])t=vn[t];else return[t];const[r,n]=t.split(""),i=_a[r],a=$a[n]||"";return Array.isArray(a)?a.map(c=>i+c):[i+a]}),Zr=["m","mt","mr","mb","ml","mx","my","margin","marginTop","marginRight","marginBottom","marginLeft","marginX","marginY","marginInline","marginInlineStart","marginInlineEnd","marginBlock","marginBlockStart","marginBlockEnd"],eo=["p","pt","pr","pb","pl","px","py","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingX","paddingY","paddingInline","paddingInlineStart","paddingInlineEnd","paddingBlock","paddingBlockStart","paddingBlockEnd"],La=[...Zr,...eo];function Rr(t,r,n,i){const a=Qr(t,r,!0)??n;return typeof a=="number"||typeof a=="string"?c=>typeof c=="string"?c:(process.env.NODE_ENV!=="production"&&typeof c!="number"&&console.error(`MUI: Expected ${i} argument to be a number or a string, got ${c}.`),typeof a=="string"?a.startsWith("var(")&&c===0?0:a.startsWith("var(")&&c===1?a:`calc(${c} * ${a})`:a*c):Array.isArray(a)?c=>{if(typeof c=="string")return c;const l=Math.abs(c);process.env.NODE_ENV!=="production"&&(Number.isInteger(l)?l>a.length-1&&console.error([`MUI: The value provided (${l}) overflows.`,`The supported values are: ${JSON.stringify(a)}.`,`${l} > ${a.length-1}, you need to add the missing values.`].join(`
|
|
48
48
|
`)):console.error([`MUI: The \`theme.${r}\` array type cannot be combined with non integer values.You should either use an integer value that can be used as index, or define the \`theme.${r}\` as a number.`].join(`
|
|
49
|
-
`)));const d=a[
|
|
50
|
-
`)),()=>{})}function fo(e){return pr(e,"spacing",8,"spacing")}function xr(e,r){return typeof r=="string"||r==null?r:e(r)}function va(e,r){return n=>e.reduce((i,a)=>(i[a]=xr(r,n),i),{})}function Ca(e,r,n,i){if(!r.includes(n))return null;const a=ya(n),l=va(a,i),c=e[n];return ut(e,c,l)}function Mn(e,r){const n=fo(e.theme);return Object.keys(e).map(i=>Ca(e,r,i,n)).reduce(ur,{})}function we(e){return Mn(e,Dr)}we.propTypes=process.env.NODE_ENV!=="production"?Dr.reduce((e,r)=>(e[r]=wt,e),{}):{};we.filterProps=Dr;function ke(e){return Mn(e,Or)}ke.propTypes=process.env.NODE_ENV!=="production"?Or.reduce((e,r)=>(e[r]=wt,e),{}):{};ke.filterProps=Or;process.env.NODE_ENV!=="production"&&Sa.reduce((e,r)=>(e[r]=wt,e),{});function Pn(e=8,r=fo({spacing:e})){if(e.mui)return e;const n=(...i)=>(process.env.NODE_ENV!=="production"&&(i.length<=4||console.error(`MUI: Too many arguments provided, expected between 0 and 4, got ${i.length}`)),(i.length===0?[1]:i).map(l=>{const c=r(l);return typeof c=="number"?`${c}px`:c}).join(" "));return n.mui=!0,n}function Ar(...e){const r=e.reduce((i,a)=>(a.filterProps.forEach(l=>{i[l]=a}),i),{}),n=i=>Object.keys(i).reduce((a,l)=>r[l]?ur(a,r[l](i)):a,{});return n.propTypes=process.env.NODE_ENV!=="production"?e.reduce((i,a)=>Object.assign(i,a.propTypes),{}):{},n.filterProps=e.reduce((i,a)=>i.concat(a.filterProps),[]),n}function Ge(e){return typeof e!="number"?e:`${e}px solid`}function Ye(e,r){return Ee({prop:e,themeKey:"borders",transform:r})}const ja=Ye("border",Ge),wa=Ye("borderTop",Ge),ka=Ye("borderRight",Ge),Ta=Ye("borderBottom",Ge),za=Ye("borderLeft",Ge),Ea=Ye("borderColor"),Ia=Ye("borderTopColor"),Ba=Ye("borderRightColor"),Da=Ye("borderBottomColor"),Oa=Ye("borderLeftColor"),Aa=Ye("outline",Ge),Ra=Ye("outlineColor"),Rr=e=>{if(e.borderRadius!==void 0&&e.borderRadius!==null){const r=pr(e.theme,"shape.borderRadius",4,"borderRadius"),n=i=>({borderRadius:xr(r,i)});return ut(e,e.borderRadius,n)}return null};Rr.propTypes=process.env.NODE_ENV!=="production"?{borderRadius:wt}:{};Rr.filterProps=["borderRadius"];Ar(ja,wa,ka,Ta,za,Ea,Ia,Ba,Da,Oa,Rr,Aa,Ra);const Mr=e=>{if(e.gap!==void 0&&e.gap!==null){const r=pr(e.theme,"spacing",8,"gap"),n=i=>({gap:xr(r,i)});return ut(e,e.gap,n)}return null};Mr.propTypes=process.env.NODE_ENV!=="production"?{gap:wt}:{};Mr.filterProps=["gap"];const Pr=e=>{if(e.columnGap!==void 0&&e.columnGap!==null){const r=pr(e.theme,"spacing",8,"columnGap"),n=i=>({columnGap:xr(r,i)});return ut(e,e.columnGap,n)}return null};Pr.propTypes=process.env.NODE_ENV!=="production"?{columnGap:wt}:{};Pr.filterProps=["columnGap"];const Wr=e=>{if(e.rowGap!==void 0&&e.rowGap!==null){const r=pr(e.theme,"spacing",8,"rowGap"),n=i=>({rowGap:xr(r,i)});return ut(e,e.rowGap,n)}return null};Wr.propTypes=process.env.NODE_ENV!=="production"?{rowGap:wt}:{};Wr.filterProps=["rowGap"];const Ma=Ee({prop:"gridColumn"}),Pa=Ee({prop:"gridRow"}),Wa=Ee({prop:"gridAutoFlow"}),_a=Ee({prop:"gridAutoColumns"}),$a=Ee({prop:"gridAutoRows"}),Fa=Ee({prop:"gridTemplateColumns"}),Va=Ee({prop:"gridTemplateRows"}),Na=Ee({prop:"gridTemplateAreas"}),La=Ee({prop:"gridArea"});Ar(Mr,Pr,Wr,Ma,Pa,Wa,_a,$a,Fa,Va,Na,La);function Ut(e,r){return r==="grey"?r:e}const Ha=Ee({prop:"color",themeKey:"palette",transform:Ut}),Ua=Ee({prop:"bgcolor",cssProperty:"backgroundColor",themeKey:"palette",transform:Ut}),Ga=Ee({prop:"backgroundColor",themeKey:"palette",transform:Ut});Ar(Ha,Ua,Ga);function Ve(e){return e<=1&&e!==0?`${e*100}%`:e}const Ya=Ee({prop:"width",transform:Ve}),po=e=>{if(e.maxWidth!==void 0&&e.maxWidth!==null){const r=n=>{var a,l,c,d,f;const i=((c=(l=(a=e.theme)==null?void 0:a.breakpoints)==null?void 0:l.values)==null?void 0:c[n])||Ir[n];return i?((f=(d=e.theme)==null?void 0:d.breakpoints)==null?void 0:f.unit)!=="px"?{maxWidth:`${i}${e.theme.breakpoints.unit}`}:{maxWidth:i}:{maxWidth:Ve(n)}};return ut(e,e.maxWidth,r)}return null};po.filterProps=["maxWidth"];const qa=Ee({prop:"minWidth",transform:Ve}),Ja=Ee({prop:"height",transform:Ve}),Ka=Ee({prop:"maxHeight",transform:Ve}),Xa=Ee({prop:"minHeight",transform:Ve});Ee({prop:"size",cssProperty:"width",transform:Ve});Ee({prop:"size",cssProperty:"height",transform:Ve});const Qa=Ee({prop:"boxSizing"});Ar(Ya,po,qa,Ja,Ka,Xa,Qa);const _r={border:{themeKey:"borders",transform:Ge},borderTop:{themeKey:"borders",transform:Ge},borderRight:{themeKey:"borders",transform:Ge},borderBottom:{themeKey:"borders",transform:Ge},borderLeft:{themeKey:"borders",transform:Ge},borderColor:{themeKey:"palette"},borderTopColor:{themeKey:"palette"},borderRightColor:{themeKey:"palette"},borderBottomColor:{themeKey:"palette"},borderLeftColor:{themeKey:"palette"},outline:{themeKey:"borders",transform:Ge},outlineColor:{themeKey:"palette"},borderRadius:{themeKey:"shape.borderRadius",style:Rr},color:{themeKey:"palette",transform:Ut},bgcolor:{themeKey:"palette",cssProperty:"backgroundColor",transform:Ut},backgroundColor:{themeKey:"palette",transform:Ut},p:{style:ke},pt:{style:ke},pr:{style:ke},pb:{style:ke},pl:{style:ke},px:{style:ke},py:{style:ke},padding:{style:ke},paddingTop:{style:ke},paddingRight:{style:ke},paddingBottom:{style:ke},paddingLeft:{style:ke},paddingX:{style:ke},paddingY:{style:ke},paddingInline:{style:ke},paddingInlineStart:{style:ke},paddingInlineEnd:{style:ke},paddingBlock:{style:ke},paddingBlockStart:{style:ke},paddingBlockEnd:{style:ke},m:{style:we},mt:{style:we},mr:{style:we},mb:{style:we},ml:{style:we},mx:{style:we},my:{style:we},margin:{style:we},marginTop:{style:we},marginRight:{style:we},marginBottom:{style:we},marginLeft:{style:we},marginX:{style:we},marginY:{style:we},marginInline:{style:we},marginInlineStart:{style:we},marginInlineEnd:{style:we},marginBlock:{style:we},marginBlockStart:{style:we},marginBlockEnd:{style:we},displayPrint:{cssProperty:!1,transform:e=>({"@media print":{display:e}})},display:{},overflow:{},textOverflow:{},visibility:{},whiteSpace:{},flexBasis:{},flexDirection:{},flexWrap:{},justifyContent:{},alignItems:{},alignContent:{},order:{},flex:{},flexGrow:{},flexShrink:{},alignSelf:{},justifyItems:{},justifySelf:{},gap:{style:Mr},rowGap:{style:Wr},columnGap:{style:Pr},gridColumn:{},gridRow:{},gridAutoFlow:{},gridAutoColumns:{},gridAutoRows:{},gridTemplateColumns:{},gridTemplateRows:{},gridTemplateAreas:{},gridArea:{},position:{},zIndex:{themeKey:"zIndex"},top:{},right:{},bottom:{},left:{},boxShadow:{themeKey:"shadows"},width:{transform:Ve},maxWidth:{style:po},minWidth:{transform:Ve},height:{transform:Ve},maxHeight:{transform:Ve},minHeight:{transform:Ve},boxSizing:{},font:{themeKey:"font"},fontFamily:{themeKey:"typography"},fontSize:{themeKey:"typography"},fontStyle:{themeKey:"typography"},fontWeight:{themeKey:"typography"},letterSpacing:{},textTransform:{},lineHeight:{},textAlign:{},typography:{cssProperty:!1,themeKey:"typography"}};function Za(...e){const r=e.reduce((i,a)=>i.concat(Object.keys(a)),[]),n=new Set(r);return e.every(i=>n.size===Object.keys(i).length)}function el(e,r){return typeof e=="function"?e(r):e}function tl(){function e(n,i,a,l){const c={[n]:i,theme:a},d=l[n];if(!d)return{[n]:i};const{cssProperty:f=n,themeKey:x,transform:m,style:b}=d;if(i==null)return null;if(x==="typography"&&i==="inherit")return{[n]:i};const g=Br(a,x)||{};return b?b(c):ut(c,i,C=>{let p=Tr(g,m,C);return C===p&&typeof C=="string"&&(p=Tr(g,m,`${n}${C==="default"?"":Rn(C)}`,C)),f===!1?p:{[f]:p}})}function r(n){const{sx:i,theme:a={},nested:l}=n||{};if(!i)return null;const c=a.unstable_sxConfig??_r;function d(f){let x=f;if(typeof f=="function")x=f(a);else if(typeof f!="object")return f;if(!x)return null;const m=ha(a.breakpoints),b=Object.keys(m);let g=m;return Object.keys(x).forEach(v=>{const C=el(x[v],a);if(C!=null)if(typeof C=="object")if(c[v])g=ur(g,e(v,C,a,c));else{const p=ut({theme:a},C,T=>({[v]:T}));Za(p,C)?g[v]=r({sx:C,theme:a,nested:!0}):g=ur(g,p)}else g=ur(g,e(v,C,a,c))}),!l&&a.modularCssLayers?{"@layer sx":Ko(a,Qo(b,g))}:Ko(a,Qo(b,g))}return Array.isArray(i)?i.map(d):d(i)}return r}const $r=tl();$r.filterProps=["sx"];function rl(e,r){var i;const n=this;if(n.vars){if(!((i=n.colorSchemes)!=null&&i[e])||typeof n.getColorSchemeSelector!="function")return{};let a=n.getColorSchemeSelector(e);return a==="&"?r:((a.includes("data-")||a.includes("."))&&(a=`*:where(${a.replace(/\s*&$/,"")}) &`),{[a]:r})}return n.palette.mode===e?r:{}}function Wn(e={},...r){const{breakpoints:n={},palette:i={},spacing:a,shape:l={},...c}=e,d=ca(n),f=Pn(a);let x=Ne({breakpoints:d,direction:"ltr",components:{},palette:{mode:"light",...i},spacing:f,shape:{...pa,...l}},c);return x=fa(x),x.applyStyles=rl,x=r.reduce((m,b)=>Ne(m,b),x),x.unstable_sxConfig={..._r,...c==null?void 0:c.unstable_sxConfig},x.unstable_sx=function(b){return $r({sx:b,theme:this})},x}function ol(e){return Object.keys(e).length===0}function nl(e=null){const r=zr.useContext($i.ThemeContext);return!r||ol(r)?e:r}const il=Wn();function sl(e=il){return nl(e)}const en=e=>e,al=()=>{let e=en;return{configure(r){e=r},generate(r){return e(r)},reset(){e=en}}},ll=al(),cl={active:"active",checked:"checked",completed:"completed",disabled:"disabled",error:"error",expanded:"expanded",focused:"focused",focusVisible:"focusVisible",open:"open",readOnly:"readOnly",required:"required",selected:"selected"};function dl(e,r,n="Mui"){const i=cl[r];return i?`${n}-${i}`:`${ll.generate(e)}-${r}`}function ul(e,r=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(r,Math.min(e,n))}function xo(e,r=0,n=1){return process.env.NODE_ENV!=="production"&&(e<r||e>n)&&console.error(`MUI: The value provided ${e} is out of range [${r}, ${n}].`),ul(e,r,n)}function fl(e){e=e.slice(1);const r=new RegExp(`.{1,${e.length>=6?2:1}}`,"g");let n=e.match(r);return n&&n[0].length===1&&(n=n.map(i=>i+i)),process.env.NODE_ENV!=="production"&&e.length!==e.trim().length&&console.error(`MUI: The color: "${e}" is invalid. Make sure the color input doesn't contain leading/trailing space.`),n?`rgb${n.length===4?"a":""}(${n.map((i,a)=>a<3?parseInt(i,16):Math.round(parseInt(i,16)/255*1e3)/1e3).join(", ")})`:""}function jt(e){if(e.type)return e;if(e.charAt(0)==="#")return jt(fl(e));const r=e.indexOf("("),n=e.substring(0,r);if(!["rgb","rgba","hsl","hsla","color"].includes(n))throw new Error(process.env.NODE_ENV!=="production"?`MUI: Unsupported \`${e}\` color.
|
|
51
|
-
The following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().`:
|
|
52
|
-
The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rgb, rec-2020.`:
|
|
53
|
-
`))}return s}const
|
|
54
|
-
The color object needs to have a \`main\` property or a \`${
|
|
55
|
-
\`color.main\` should be a string, but \`${JSON.stringify(
|
|
49
|
+
`)));const d=a[l];return c>=0?d:typeof d=="number"?-d:typeof d=="string"&&d.startsWith("var(")?`calc(-1 * ${d})`:`-${d}`}:typeof a=="function"?a:(process.env.NODE_ENV!=="production"&&console.error([`MUI: The \`theme.${r}\` value (${a}) is invalid.`,"It should be a number, an array or a function."].join(`
|
|
50
|
+
`)),()=>{})}function Oo(t){return Rr(t,"spacing",8,"spacing")}function Wr(t,r){return typeof r=="string"||r==null?r:t(r)}function Na(t,r){return n=>t.reduce((i,a)=>(i[a]=Wr(r,n),i),{})}function Va(t,r,n,i){if(!r.includes(n))return null;const a=Fa(n),c=Na(a,i),l=t[n];return Ct(t,l,c)}function si(t,r){const n=Oo(t.theme);return Object.keys(t).map(i=>Va(t,r,i,n)).reduce(Or,{})}function ze(t){return si(t,Zr)}ze.propTypes=process.env.NODE_ENV!=="production"?Zr.reduce((t,r)=>(t[r]=Pt,t),{}):{};ze.filterProps=Zr;function Ie(t){return si(t,eo)}Ie.propTypes=process.env.NODE_ENV!=="production"?eo.reduce((t,r)=>(t[r]=Pt,t),{}):{};Ie.filterProps=eo;process.env.NODE_ENV!=="production"&&La.reduce((t,r)=>(t[r]=Pt,t),{});function ai(t=8,r=Oo({spacing:t})){if(t.mui)return t;const n=(...i)=>(process.env.NODE_ENV!=="production"&&(i.length<=4||console.error(`MUI: Too many arguments provided, expected between 0 and 4, got ${i.length}`)),(i.length===0?[1]:i).map(c=>{const l=r(c);return typeof l=="number"?`${l}px`:l}).join(" "));return n.mui=!0,n}function to(...t){const r=t.reduce((i,a)=>(a.filterProps.forEach(c=>{i[c]=a}),i),{}),n=i=>Object.keys(i).reduce((a,c)=>r[c]?Or(a,r[c](i)):a,{});return n.propTypes=process.env.NODE_ENV!=="production"?t.reduce((i,a)=>Object.assign(i,a.propTypes),{}):{},n.filterProps=t.reduce((i,a)=>i.concat(a.filterProps),[]),n}function Ze(t){return typeof t!="number"?t:`${t}px solid`}function et(t,r){return De({prop:t,themeKey:"borders",transform:r})}const Ha=et("border",Ze),Ua=et("borderTop",Ze),Ga=et("borderRight",Ze),Ya=et("borderBottom",Ze),Ja=et("borderLeft",Ze),qa=et("borderColor"),Ka=et("borderTopColor"),Xa=et("borderRightColor"),Qa=et("borderBottomColor"),Za=et("borderLeftColor"),el=et("outline",Ze),tl=et("outlineColor"),ro=t=>{if(t.borderRadius!==void 0&&t.borderRadius!==null){const r=Rr(t.theme,"shape.borderRadius",4,"borderRadius"),n=i=>({borderRadius:Wr(r,i)});return Ct(t,t.borderRadius,n)}return null};ro.propTypes=process.env.NODE_ENV!=="production"?{borderRadius:Pt}:{};ro.filterProps=["borderRadius"];to(Ha,Ua,Ga,Ya,Ja,qa,Ka,Xa,Qa,Za,ro,el,tl);const oo=t=>{if(t.gap!==void 0&&t.gap!==null){const r=Rr(t.theme,"spacing",8,"gap"),n=i=>({gap:Wr(r,i)});return Ct(t,t.gap,n)}return null};oo.propTypes=process.env.NODE_ENV!=="production"?{gap:Pt}:{};oo.filterProps=["gap"];const no=t=>{if(t.columnGap!==void 0&&t.columnGap!==null){const r=Rr(t.theme,"spacing",8,"columnGap"),n=i=>({columnGap:Wr(r,i)});return Ct(t,t.columnGap,n)}return null};no.propTypes=process.env.NODE_ENV!=="production"?{columnGap:Pt}:{};no.filterProps=["columnGap"];const io=t=>{if(t.rowGap!==void 0&&t.rowGap!==null){const r=Rr(t.theme,"spacing",8,"rowGap"),n=i=>({rowGap:Wr(r,i)});return Ct(t,t.rowGap,n)}return null};io.propTypes=process.env.NODE_ENV!=="production"?{rowGap:Pt}:{};io.filterProps=["rowGap"];const rl=De({prop:"gridColumn"}),ol=De({prop:"gridRow"}),nl=De({prop:"gridAutoFlow"}),il=De({prop:"gridAutoColumns"}),sl=De({prop:"gridAutoRows"}),al=De({prop:"gridTemplateColumns"}),ll=De({prop:"gridTemplateRows"}),cl=De({prop:"gridTemplateAreas"}),dl=De({prop:"gridArea"});to(oo,no,io,rl,ol,nl,il,sl,al,ll,cl,dl);function hr(t,r){return r==="grey"?r:t}const ul=De({prop:"color",themeKey:"palette",transform:hr}),pl=De({prop:"bgcolor",cssProperty:"backgroundColor",themeKey:"palette",transform:hr}),fl=De({prop:"backgroundColor",themeKey:"palette",transform:hr});to(ul,pl,fl);function Ue(t){return t<=1&&t!==0?`${t*100}%`:t}const xl=De({prop:"width",transform:Ue}),Ao=t=>{if(t.maxWidth!==void 0&&t.maxWidth!==null){const r=n=>{var a,c,l,d,f;const i=((l=(c=(a=t.theme)==null?void 0:a.breakpoints)==null?void 0:c.values)==null?void 0:l[n])||Xr[n];return i?((f=(d=t.theme)==null?void 0:d.breakpoints)==null?void 0:f.unit)!=="px"?{maxWidth:`${i}${t.theme.breakpoints.unit}`}:{maxWidth:i}:{maxWidth:Ue(n)}};return Ct(t,t.maxWidth,r)}return null};Ao.filterProps=["maxWidth"];const hl=De({prop:"minWidth",transform:Ue}),ml=De({prop:"height",transform:Ue}),gl=De({prop:"maxHeight",transform:Ue}),yl=De({prop:"minHeight",transform:Ue});De({prop:"size",cssProperty:"width",transform:Ue});De({prop:"size",cssProperty:"height",transform:Ue});const bl=De({prop:"boxSizing"});to(xl,Ao,hl,ml,gl,yl,bl);const so={border:{themeKey:"borders",transform:Ze},borderTop:{themeKey:"borders",transform:Ze},borderRight:{themeKey:"borders",transform:Ze},borderBottom:{themeKey:"borders",transform:Ze},borderLeft:{themeKey:"borders",transform:Ze},borderColor:{themeKey:"palette"},borderTopColor:{themeKey:"palette"},borderRightColor:{themeKey:"palette"},borderBottomColor:{themeKey:"palette"},borderLeftColor:{themeKey:"palette"},outline:{themeKey:"borders",transform:Ze},outlineColor:{themeKey:"palette"},borderRadius:{themeKey:"shape.borderRadius",style:ro},color:{themeKey:"palette",transform:hr},bgcolor:{themeKey:"palette",cssProperty:"backgroundColor",transform:hr},backgroundColor:{themeKey:"palette",transform:hr},p:{style:Ie},pt:{style:Ie},pr:{style:Ie},pb:{style:Ie},pl:{style:Ie},px:{style:Ie},py:{style:Ie},padding:{style:Ie},paddingTop:{style:Ie},paddingRight:{style:Ie},paddingBottom:{style:Ie},paddingLeft:{style:Ie},paddingX:{style:Ie},paddingY:{style:Ie},paddingInline:{style:Ie},paddingInlineStart:{style:Ie},paddingInlineEnd:{style:Ie},paddingBlock:{style:Ie},paddingBlockStart:{style:Ie},paddingBlockEnd:{style:Ie},m:{style:ze},mt:{style:ze},mr:{style:ze},mb:{style:ze},ml:{style:ze},mx:{style:ze},my:{style:ze},margin:{style:ze},marginTop:{style:ze},marginRight:{style:ze},marginBottom:{style:ze},marginLeft:{style:ze},marginX:{style:ze},marginY:{style:ze},marginInline:{style:ze},marginInlineStart:{style:ze},marginInlineEnd:{style:ze},marginBlock:{style:ze},marginBlockStart:{style:ze},marginBlockEnd:{style:ze},displayPrint:{cssProperty:!1,transform:t=>({"@media print":{display:t}})},display:{},overflow:{},textOverflow:{},visibility:{},whiteSpace:{},flexBasis:{},flexDirection:{},flexWrap:{},justifyContent:{},alignItems:{},alignContent:{},order:{},flex:{},flexGrow:{},flexShrink:{},alignSelf:{},justifyItems:{},justifySelf:{},gap:{style:oo},rowGap:{style:io},columnGap:{style:no},gridColumn:{},gridRow:{},gridAutoFlow:{},gridAutoColumns:{},gridAutoRows:{},gridTemplateColumns:{},gridTemplateRows:{},gridTemplateAreas:{},gridArea:{},position:{},zIndex:{themeKey:"zIndex"},top:{},right:{},bottom:{},left:{},boxShadow:{themeKey:"shadows"},width:{transform:Ue},maxWidth:{style:Ao},minWidth:{transform:Ue},height:{transform:Ue},maxHeight:{transform:Ue},minHeight:{transform:Ue},boxSizing:{},font:{themeKey:"font"},fontFamily:{themeKey:"typography"},fontSize:{themeKey:"typography"},fontStyle:{themeKey:"typography"},fontWeight:{themeKey:"typography"},letterSpacing:{},textTransform:{},lineHeight:{},textAlign:{},typography:{cssProperty:!1,themeKey:"typography"}};function vl(...t){const r=t.reduce((i,a)=>i.concat(Object.keys(a)),[]),n=new Set(r);return t.every(i=>n.size===Object.keys(i).length)}function Sl(t,r){return typeof t=="function"?t(r):t}function Cl(){function t(n,i,a,c){const l={[n]:i,theme:a},d=c[n];if(!d)return{[n]:i};const{cssProperty:f=n,themeKey:h,transform:m,style:g}=d;if(i==null)return null;if(h==="typography"&&i==="inherit")return{[n]:i};const y=Qr(a,h)||{};return g?g(l):Ct(l,i,C=>{let x=Yr(y,m,C);return C===x&&typeof C=="string"&&(x=Yr(y,m,`${n}${C==="default"?"":ii(C)}`,C)),f===!1?x:{[f]:x}})}function r(n){const{sx:i,theme:a={},nested:c}=n||{};if(!i)return null;const l=a.unstable_sxConfig??so;function d(f){let h=f;if(typeof f=="function")h=f(a);else if(typeof f!="object")return f;if(!h)return null;const m=Wa(a.breakpoints),g=Object.keys(m);let y=m;return Object.keys(h).forEach(S=>{const C=Sl(h[S],a);if(C!=null)if(typeof C=="object")if(l[S])y=Or(y,t(S,C,a,l));else{const x=Ct({theme:a},C,E=>({[S]:E}));vl(x,C)?y[S]=r({sx:C,theme:a,nested:!0}):y=Or(y,x)}else y=Or(y,t(S,C,a,l))}),!c&&a.modularCssLayers?{"@layer sx":gn(a,bn(g,y))}:gn(a,bn(g,y))}return Array.isArray(i)?i.map(d):d(i)}return r}const ao=Cl();ao.filterProps=["sx"];function jl(t,r){var i;const n=this;if(n.vars){if(!((i=n.colorSchemes)!=null&&i[t])||typeof n.getColorSchemeSelector!="function")return{};let a=n.getColorSchemeSelector(t);return a==="&"?r:((a.includes("data-")||a.includes("."))&&(a=`*:where(${a.replace(/\s*&$/,"")}) &`),{[a]:r})}return n.palette.mode===t?r:{}}function li(t={},...r){const{breakpoints:n={},palette:i={},spacing:a,shape:c={},...l}=t,d=Ba(n),f=ai(a);let h=Ge({breakpoints:d,direction:"ltr",components:{},palette:{mode:"light",...i},spacing:f,shape:{...Ma,...c}},l);return h=Aa(h),h.applyStyles=jl,h=r.reduce((m,g)=>Ge(m,g),h),h.unstable_sxConfig={...so,...l==null?void 0:l.unstable_sxConfig},h.unstable_sx=function(g){return ao({sx:g,theme:this})},h}function wl(t){return Object.keys(t).length===0}function kl(t=null){const r=Jr.useContext(ss.ThemeContext);return!r||wl(r)?t:r}const Tl=li();function zl(t=Tl){return kl(t)}const Sn=t=>t,Il=()=>{let t=Sn;return{configure(r){t=r},generate(r){return t(r)},reset(){t=Sn}}},El=Il(),Bl={active:"active",checked:"checked",completed:"completed",disabled:"disabled",error:"error",expanded:"expanded",focused:"focused",focusVisible:"focusVisible",open:"open",readOnly:"readOnly",required:"required",selected:"selected"};function Dl(t,r,n="Mui"){const i=Bl[r];return i?`${n}-${i}`:`${El.generate(t)}-${r}`}function Ol(t,r=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(r,Math.min(t,n))}function Mo(t,r=0,n=1){return process.env.NODE_ENV!=="production"&&(t<r||t>n)&&console.error(`MUI: The value provided ${t} is out of range [${r}, ${n}].`),Ol(t,r,n)}function Al(t){t=t.slice(1);const r=new RegExp(`.{1,${t.length>=6?2:1}}`,"g");let n=t.match(r);return n&&n[0].length===1&&(n=n.map(i=>i+i)),process.env.NODE_ENV!=="production"&&t.length!==t.trim().length&&console.error(`MUI: The color: "${t}" is invalid. Make sure the color input doesn't contain leading/trailing space.`),n?`rgb${n.length===4?"a":""}(${n.map((i,a)=>a<3?parseInt(i,16):Math.round(parseInt(i,16)/255*1e3)/1e3).join(", ")})`:""}function Wt(t){if(t.type)return t;if(t.charAt(0)==="#")return Wt(Al(t));const r=t.indexOf("("),n=t.substring(0,r);if(!["rgb","rgba","hsl","hsla","color"].includes(n))throw new Error(process.env.NODE_ENV!=="production"?`MUI: Unsupported \`${t}\` color.
|
|
51
|
+
The following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().`:Gt(9,t));let i=t.substring(r+1,t.length-1),a;if(n==="color"){if(i=i.split(" "),a=i.shift(),i.length===4&&i[3].charAt(0)==="/"&&(i[3]=i[3].slice(1)),!["srgb","display-p3","a98-rgb","prophoto-rgb","rec-2020"].includes(a))throw new Error(process.env.NODE_ENV!=="production"?`MUI: unsupported \`${a}\` color space.
|
|
52
|
+
The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rgb, rec-2020.`:Gt(10,a))}else i=i.split(",");return i=i.map(c=>parseFloat(c)),{type:n,values:i,colorSpace:a}}const Ml=t=>{const r=Wt(t);return r.values.slice(0,3).map((n,i)=>r.type.includes("hsl")&&i!==0?`${n}%`:n).join(" ")},Br=(t,r)=>{try{return Ml(t)}catch{return r&&process.env.NODE_ENV!=="production"&&console.warn(r),t}};function lo(t){const{type:r,colorSpace:n}=t;let{values:i}=t;return r.includes("rgb")?i=i.map((a,c)=>c<3?parseInt(a,10):a):r.includes("hsl")&&(i[1]=`${i[1]}%`,i[2]=`${i[2]}%`),r.includes("color")?i=`${n} ${i.join(" ")}`:i=`${i.join(", ")}`,`${r}(${i})`}function ci(t){t=Wt(t);const{values:r}=t,n=r[0],i=r[1]/100,a=r[2]/100,c=i*Math.min(a,1-a),l=(h,m=(h+n/30)%12)=>a-c*Math.max(Math.min(m-3,9-m,1),-1);let d="rgb";const f=[Math.round(l(0)*255),Math.round(l(8)*255),Math.round(l(4)*255)];return t.type==="hsla"&&(d+="a",f.push(r[3])),lo({type:d,values:f})}function wo(t){t=Wt(t);let r=t.type==="hsl"||t.type==="hsla"?Wt(ci(t)).values:t.values;return r=r.map(n=>(t.type!=="color"&&(n/=255),n<=.03928?n/12.92:((n+.055)/1.055)**2.4)),Number((.2126*r[0]+.7152*r[1]+.0722*r[2]).toFixed(3))}function Cn(t,r){const n=wo(t),i=wo(r);return(Math.max(n,i)+.05)/(Math.min(n,i)+.05)}function N(t,r){return t=Wt(t),r=Mo(r),(t.type==="rgb"||t.type==="hsl")&&(t.type+="a"),t.type==="color"?t.values[3]=`/${r}`:t.values[3]=r,lo(t)}function Ut(t,r,n){try{return N(t,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),t}}function co(t,r){if(t=Wt(t),r=Mo(r),t.type.includes("hsl"))t.values[2]*=1-r;else if(t.type.includes("rgb")||t.type.includes("color"))for(let n=0;n<3;n+=1)t.values[n]*=1-r;return lo(t)}function ye(t,r,n){try{return co(t,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),t}}function uo(t,r){if(t=Wt(t),r=Mo(r),t.type.includes("hsl"))t.values[2]+=(100-t.values[2])*r;else if(t.type.includes("rgb"))for(let n=0;n<3;n+=1)t.values[n]+=(255-t.values[n])*r;else if(t.type.includes("color"))for(let n=0;n<3;n+=1)t.values[n]+=(1-t.values[n])*r;return lo(t)}function be(t,r,n){try{return uo(t,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),t}}function Rl(t,r=.15){return wo(t)>.5?co(t,r):uo(t,r)}function Gr(t,r,n){try{return Rl(t,r)}catch{return t}}function Wl(t=""){function r(...i){if(!i.length)return"";const a=i[0];return typeof a=="string"&&!a.match(/(#|\(|\)|(-?(\d*\.)?\d+)(px|em|%|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc))|^(-?(\d*\.)?\d+)$|(\d+ \d+ \d+)/)?`, var(--${t?`${t}-`:""}${a}${r(...i.slice(1))})`:`, ${a}`}return(i,...a)=>`var(--${t?`${t}-`:""}${i}${r(...a)})`}const jn=(t,r,n,i=[])=>{let a=t;r.forEach((c,l)=>{l===r.length-1?Array.isArray(a)?a[Number(c)]=n:a&&typeof a=="object"&&(a[c]=n):a&&typeof a=="object"&&(a[c]||(a[c]=i.includes(c)?[]:{}),a=a[c])})},Pl=(t,r,n)=>{function i(a,c=[],l=[]){Object.entries(a).forEach(([d,f])=>{(!n||n&&!n([...c,d]))&&f!=null&&(typeof f=="object"&&Object.keys(f).length>0?i(f,[...c,d],Array.isArray(f)?[...l,d]:l):r([...c,d],f,l))})}i(t)},_l=(t,r)=>typeof r=="number"?["lineHeight","fontWeight","opacity","zIndex"].some(i=>t.includes(i))||t[t.length-1].toLowerCase().includes("opacity")?r:`${r}px`:r;function Co(t,r){const{prefix:n,shouldSkipGeneratingVar:i}=r||{},a={},c={},l={};return Pl(t,(d,f,h)=>{if((typeof f=="string"||typeof f=="number")&&(!i||!i(d,f))){const m=`--${n?`${n}-`:""}${d.join("-")}`,g=_l(d,f);Object.assign(a,{[m]:g}),jn(c,d,`var(${m})`,h),jn(l,d,`var(${m}, ${g})`,h)}},d=>d[0]==="vars"),{css:a,vars:c,varsWithDefaults:l}}function $l(t,r={}){const{getSelector:n=s,disableCssColorScheme:i,colorSchemeSelector:a,enableContrastVars:c}=r,{colorSchemes:l={},components:d,defaultColorScheme:f="light",...h}=t,{vars:m,css:g,varsWithDefaults:y}=Co(h,r);let S=y;const C={},{[f]:x,...E}=l;if(Object.entries(E||{}).forEach(([A,v])=>{const{vars:W,css:U,varsWithDefaults:w}=Co(v,r);S=Ge(S,w),C[A]={css:U,vars:W}}),x){const{css:A,vars:v,varsWithDefaults:W}=Co(x,r);S=Ge(S,W),C[f]={css:A,vars:v}}function s(A,v){var U,w;let W=a;if(a==="class"&&(W=".%s"),a==="data"&&(W="[data-%s]"),a!=null&&a.startsWith("data-")&&!a.includes("%s")&&(W=`[${a}="%s"]`),A){if(W==="media")return t.defaultColorScheme===A?":root":{[`@media (prefers-color-scheme: ${((w=(U=l[A])==null?void 0:U.palette)==null?void 0:w.mode)||A})`]:{":root":v}};if(W)return t.defaultColorScheme===A?`:root, ${W.replace("%s",String(A))}`:W.replace("%s",String(A))}return":root"}return{vars:S,generateThemeVars:()=>{let A={...m};return Object.entries(C).forEach(([,{vars:v}])=>{A=Ge(A,v)}),A},generateStyleSheets:()=>{var O,V;const A=[],v=t.defaultColorScheme||"light";function W(X,p){Object.keys(p).length&&A.push(typeof X=="string"?{[X]:{...p}}:X)}W(n(void 0,{...g}),g);const{[v]:U,...w}=C;if(U){const{css:X}=U,p=(V=(O=l[v])==null?void 0:O.palette)==null?void 0:V.mode,L=!i&&p?{colorScheme:p,...X}:{...X};W(n(v,{...L}),L)}return Object.entries(w).forEach(([X,{css:p}])=>{var _,F;const L=(F=(_=l[X])==null?void 0:_.palette)==null?void 0:F.mode,$=!i&&L?{colorScheme:L,...p}:{...p};W(n(X,{...$}),$)}),c&&A.push({":root":{"--__l-threshold":"0.7","--__l":"clamp(0, (l / var(--__l-threshold) - 1) * -infinity, 1)","--__a":"clamp(0.87, (l / var(--__l-threshold) - 1) * -infinity, 1)"}}),A}}}function Fl(t){return function(n){return t==="media"?(process.env.NODE_ENV!=="production"&&n!=="light"&&n!=="dark"&&console.error(`MUI: @media (prefers-color-scheme) supports only 'light' or 'dark', but receive '${n}'.`),`@media (prefers-color-scheme: ${n})`):t?t.startsWith("data-")&&!t.includes("%s")?`[${t}="${n}"] &`:t==="class"?`.${n} &`:t==="data"?`[data-${n}] &`:`${t.replace("%s",n)} &`:"&"}}const Ar={black:"#000",white:"#fff"},Ll={50:"#fafafa",100:"#f5f5f5",200:"#eeeeee",300:"#e0e0e0",400:"#bdbdbd",500:"#9e9e9e",600:"#757575",700:"#616161",800:"#424242",900:"#212121",A100:"#f5f5f5",A200:"#eeeeee",A400:"#bdbdbd",A700:"#616161"},dr={50:"#f3e5f5",200:"#ce93d8",300:"#ba68c8",400:"#ab47bc",500:"#9c27b0",700:"#7b1fa2"},ur={300:"#e57373",400:"#ef5350",500:"#f44336",700:"#d32f2f",800:"#c62828"},Tr={300:"#ffb74d",400:"#ffa726",500:"#ff9800",700:"#f57c00",900:"#e65100"},pr={50:"#e3f2fd",200:"#90caf9",400:"#42a5f5",700:"#1976d2",800:"#1565c0"},fr={300:"#4fc3f7",400:"#29b6f6",500:"#03a9f4",700:"#0288d1",900:"#01579b"},xr={300:"#81c784",400:"#66bb6a",500:"#4caf50",700:"#388e3c",800:"#2e7d32",900:"#1b5e20"};function di(){return{text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.38)"},divider:"rgba(0, 0, 0, 0.12)",background:{paper:Ar.white,default:Ar.white},action:{active:"rgba(0, 0, 0, 0.54)",hover:"rgba(0, 0, 0, 0.04)",hoverOpacity:.04,selected:"rgba(0, 0, 0, 0.08)",selectedOpacity:.08,disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(0, 0, 0, 0.12)",disabledOpacity:.38,focus:"rgba(0, 0, 0, 0.12)",focusOpacity:.12,activatedOpacity:.12}}}const ui=di();function pi(){return{text:{primary:Ar.white,secondary:"rgba(255, 255, 255, 0.7)",disabled:"rgba(255, 255, 255, 0.5)",icon:"rgba(255, 255, 255, 0.5)"},divider:"rgba(255, 255, 255, 0.12)",background:{paper:"#121212",default:"#121212"},action:{active:Ar.white,hover:"rgba(255, 255, 255, 0.08)",hoverOpacity:.08,selected:"rgba(255, 255, 255, 0.16)",selectedOpacity:.16,disabled:"rgba(255, 255, 255, 0.3)",disabledBackground:"rgba(255, 255, 255, 0.12)",disabledOpacity:.38,focus:"rgba(255, 255, 255, 0.12)",focusOpacity:.12,activatedOpacity:.24}}}const ko=pi();function wn(t,r,n,i){const a=i.light||i,c=i.dark||i*1.5;t[r]||(t.hasOwnProperty(n)?t[r]=t[n]:r==="light"?t.light=uo(t.main,a):r==="dark"&&(t.dark=co(t.main,c)))}function kn(t,r,n,i,a){const c=a.light||a,l=a.dark||a*1.5;r[n]||(r.hasOwnProperty(i)?r[n]=r[i]:n==="light"?r.light=`color-mix(in ${t}, ${r.main}, #fff ${(c*100).toFixed(0)}%)`:n==="dark"&&(r.dark=`color-mix(in ${t}, ${r.main}, #000 ${(l*100).toFixed(0)}%)`))}function Nl(t="light"){return t==="dark"?{main:pr[200],light:pr[50],dark:pr[400]}:{main:pr[700],light:pr[400],dark:pr[800]}}function Vl(t="light"){return t==="dark"?{main:dr[200],light:dr[50],dark:dr[400]}:{main:dr[500],light:dr[300],dark:dr[700]}}function Hl(t="light"){return t==="dark"?{main:ur[500],light:ur[300],dark:ur[700]}:{main:ur[700],light:ur[400],dark:ur[800]}}function Ul(t="light"){return t==="dark"?{main:fr[400],light:fr[300],dark:fr[700]}:{main:fr[700],light:fr[500],dark:fr[900]}}function Gl(t="light"){return t==="dark"?{main:xr[400],light:xr[300],dark:xr[700]}:{main:xr[800],light:xr[500],dark:xr[900]}}function Yl(t="light"){return t==="dark"?{main:Tr[400],light:Tr[300],dark:Tr[700]}:{main:"#ed6c02",light:Tr[500],dark:Tr[900]}}function Jl(t){return`oklch(from ${t} var(--__l) 0 h / var(--__a))`}function Ro(t){const{mode:r="light",contrastThreshold:n=3,tonalOffset:i=.2,colorSpace:a,...c}=t,l=t.primary||Nl(r),d=t.secondary||Vl(r),f=t.error||Hl(r),h=t.info||Ul(r),m=t.success||Gl(r),g=t.warning||Yl(r);function y(E){if(a)return Jl(E);const s=Cn(E,ko.text.primary)>=n?ko.text.primary:ui.text.primary;if(process.env.NODE_ENV!=="production"){const T=Cn(E,s);T<3&&console.error([`MUI: The contrast ratio of ${T}:1 for ${s} on ${E}`,"falls below the WCAG recommended absolute minimum contrast ratio of 3:1.","https://www.w3.org/TR/2008/REC-WCAG20-20081211/#visual-audio-contrast-contrast"].join(`
|
|
53
|
+
`))}return s}const S=({color:E,name:s,mainShade:T=500,lightShade:I=300,darkShade:A=700})=>{if(E={...E},!E.main&&E[T]&&(E.main=E[T]),!E.hasOwnProperty("main"))throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${s?` (${s})`:""} provided to augmentColor(color) is invalid.
|
|
54
|
+
The color object needs to have a \`main\` property or a \`${T}\` property.`:Gt(11,s?` (${s})`:"",T));if(typeof E.main!="string")throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${s?` (${s})`:""} provided to augmentColor(color) is invalid.
|
|
55
|
+
\`color.main\` should be a string, but \`${JSON.stringify(E.main)}\` was provided instead.
|
|
56
56
|
|
|
57
57
|
Did you intend to use one of the following approaches?
|
|
58
58
|
|
|
@@ -64,17 +64,17 @@ const theme1 = createTheme({ palette: {
|
|
|
64
64
|
|
|
65
65
|
const theme2 = createTheme({ palette: {
|
|
66
66
|
primary: { main: green[500] },
|
|
67
|
-
} });`:
|
|
68
|
-
`)),Object.keys(
|
|
67
|
+
} });`:Gt(12,s?` (${s})`:"",JSON.stringify(E.main)));return a?(kn(a,E,"light",I,i),kn(a,E,"dark",A,i)):(wn(E,"light",I,i),wn(E,"dark",A,i)),E.contrastText||(E.contrastText=y(E.main)),E};let C;return r==="light"?C=di():r==="dark"&&(C=pi()),process.env.NODE_ENV!=="production"&&(C||console.error(`MUI: The palette mode \`${r}\` is not supported.`)),Ge({common:{...Ar},mode:r,primary:S({color:l,name:"primary"}),secondary:S({color:d,name:"secondary",mainShade:"A400",lightShade:"A200",darkShade:"A700"}),error:S({color:f,name:"error"}),warning:S({color:g,name:"warning"}),info:S({color:h,name:"info"}),success:S({color:m,name:"success"}),grey:Ll,contrastThreshold:n,getContrastText:y,augmentColor:S,tonalOffset:i,...C},c)}function ql(t){const r={};return Object.entries(t).forEach(i=>{const[a,c]=i;typeof c=="object"&&(r[a]=`${c.fontStyle?`${c.fontStyle} `:""}${c.fontVariant?`${c.fontVariant} `:""}${c.fontWeight?`${c.fontWeight} `:""}${c.fontStretch?`${c.fontStretch} `:""}${c.fontSize||""}${c.lineHeight?`/${c.lineHeight} `:""}${c.fontFamily||""}`)}),r}function Kl(t,r){return{toolbar:{minHeight:56,[t.up("xs")]:{"@media (orientation: landscape)":{minHeight:48}},[t.up("sm")]:{minHeight:64}},...r}}function Xl(t){return Math.round(t*1e5)/1e5}const Tn={textTransform:"uppercase"},zn='"Roboto", "Helvetica", "Arial", sans-serif';function Ql(t,r){const{fontFamily:n=zn,fontSize:i=14,fontWeightLight:a=300,fontWeightRegular:c=400,fontWeightMedium:l=500,fontWeightBold:d=700,htmlFontSize:f=16,allVariants:h,pxToRem:m,...g}=typeof r=="function"?r(t):r;process.env.NODE_ENV!=="production"&&(typeof i!="number"&&console.error("MUI: `fontSize` is required to be a number."),typeof f!="number"&&console.error("MUI: `htmlFontSize` is required to be a number."));const y=i/14,S=m||(E=>`${E/f*y}rem`),C=(E,s,T,I,A)=>({fontFamily:n,fontWeight:E,fontSize:S(s),lineHeight:T,...n===zn?{letterSpacing:`${Xl(I/s)}em`}:{},...A,...h}),x={h1:C(a,96,1.167,-1.5),h2:C(a,60,1.2,-.5),h3:C(c,48,1.167,0),h4:C(c,34,1.235,.25),h5:C(c,24,1.334,0),h6:C(l,20,1.6,.15),subtitle1:C(c,16,1.75,.15),subtitle2:C(l,14,1.57,.1),body1:C(c,16,1.5,.15),body2:C(c,14,1.43,.15),button:C(l,14,1.75,.4,Tn),caption:C(c,12,1.66,.4),overline:C(c,12,2.66,1,Tn),inherit:{fontFamily:"inherit",fontWeight:"inherit",fontSize:"inherit",lineHeight:"inherit",letterSpacing:"inherit"}};return Ge({htmlFontSize:f,pxToRem:S,fontFamily:n,fontSize:i,fontWeightLight:a,fontWeightRegular:c,fontWeightMedium:l,fontWeightBold:d,...x},g,{clone:!1})}const Zl=.2,ec=.14,tc=.12;function we(...t){return[`${t[0]}px ${t[1]}px ${t[2]}px ${t[3]}px rgba(0,0,0,${Zl})`,`${t[4]}px ${t[5]}px ${t[6]}px ${t[7]}px rgba(0,0,0,${ec})`,`${t[8]}px ${t[9]}px ${t[10]}px ${t[11]}px rgba(0,0,0,${tc})`].join(",")}const rc=["none",we(0,2,1,-1,0,1,1,0,0,1,3,0),we(0,3,1,-2,0,2,2,0,0,1,5,0),we(0,3,3,-2,0,3,4,0,0,1,8,0),we(0,2,4,-1,0,4,5,0,0,1,10,0),we(0,3,5,-1,0,5,8,0,0,1,14,0),we(0,3,5,-1,0,6,10,0,0,1,18,0),we(0,4,5,-2,0,7,10,1,0,2,16,1),we(0,5,5,-3,0,8,10,1,0,3,14,2),we(0,5,6,-3,0,9,12,1,0,3,16,2),we(0,6,6,-3,0,10,14,1,0,4,18,3),we(0,6,7,-4,0,11,15,1,0,4,20,3),we(0,7,8,-4,0,12,17,2,0,5,22,4),we(0,7,8,-4,0,13,19,2,0,5,24,4),we(0,7,9,-4,0,14,21,2,0,5,26,4),we(0,8,9,-5,0,15,22,2,0,6,28,5),we(0,8,10,-5,0,16,24,2,0,6,30,5),we(0,8,11,-5,0,17,26,2,0,6,32,5),we(0,9,11,-5,0,18,28,2,0,7,34,6),we(0,9,12,-6,0,19,29,2,0,7,36,6),we(0,10,13,-6,0,20,31,3,0,8,38,7),we(0,10,13,-6,0,21,33,3,0,8,40,7),we(0,10,14,-6,0,22,35,3,0,8,42,7),we(0,11,14,-7,0,23,36,3,0,9,44,8),we(0,11,15,-7,0,24,38,3,0,9,46,8)],oc={easeInOut:"cubic-bezier(0.4, 0, 0.2, 1)",easeOut:"cubic-bezier(0.0, 0, 0.2, 1)",easeIn:"cubic-bezier(0.4, 0, 1, 1)",sharp:"cubic-bezier(0.4, 0, 0.6, 1)"},nc={shortest:150,shorter:200,short:250,standard:300,complex:375,enteringScreen:225,leavingScreen:195};function In(t){return`${Math.round(t)}ms`}function ic(t){if(!t)return 0;const r=t/36;return Math.min(Math.round((4+15*r**.25+r/5)*10),3e3)}function sc(t){const r={...oc,...t.easing},n={...nc,...t.duration};return{getAutoHeightDuration:ic,create:(a=["all"],c={})=>{const{duration:l=n.standard,easing:d=r.easeInOut,delay:f=0,...h}=c;if(process.env.NODE_ENV!=="production"){const m=y=>typeof y=="string",g=y=>!Number.isNaN(parseFloat(y));!m(a)&&!Array.isArray(a)&&console.error('MUI: Argument "props" must be a string or Array.'),!g(l)&&!m(l)&&console.error(`MUI: Argument "duration" must be a number or a string but found ${l}.`),m(d)||console.error('MUI: Argument "easing" must be a string.'),!g(f)&&!m(f)&&console.error('MUI: Argument "delay" must be a number or a string.'),typeof c!="object"&&console.error(["MUI: Secong argument of transition.create must be an object.","Arguments should be either `create('prop1', options)` or `create(['prop1', 'prop2'], options)`"].join(`
|
|
68
|
+
`)),Object.keys(h).length!==0&&console.error(`MUI: Unrecognized argument(s) [${Object.keys(h).join(",")}].`)}return(Array.isArray(a)?a:[a]).map(m=>`${m} ${typeof l=="string"?l:In(l)} ${d} ${typeof f=="string"?f:In(f)}`).join(",")},...t,easing:r,duration:n}}const ac={mobileStepper:1e3,fab:1050,speedDial:1050,appBar:1100,drawer:1200,modal:1300,snackbar:1400,tooltip:1500};function lc(t){return Rt(t)||typeof t>"u"||typeof t=="string"||typeof t=="boolean"||typeof t=="number"||Array.isArray(t)}function fi(t={}){const r={...t};function n(i){const a=Object.entries(i);for(let c=0;c<a.length;c++){const[l,d]=a[c];!lc(d)||l.startsWith("unstable_")?delete i[l]:Rt(d)&&(i[l]={...d},n(i[l]))}}return n(r),`import { unstable_createBreakpoints as createBreakpoints, createTransitions } from '@mui/material/styles';
|
|
69
69
|
|
|
70
70
|
const theme = ${JSON.stringify(r,null,2)};
|
|
71
71
|
|
|
72
72
|
theme.breakpoints = createBreakpoints(theme.breakpoints || {});
|
|
73
73
|
theme.transitions = createTransitions(theme.transitions || {});
|
|
74
74
|
|
|
75
|
-
export default theme;`}function
|
|
76
|
-
`))}T
|
|
77
|
-
To suppress this warning, you need to explicitly provide the \`palette.${r}Channel\` as a string (in rgb format, for example "12 12 12") or undefined if you want to remove the channel token.`))}function Xl(e){return typeof e=="number"?`${e}px`:typeof e=="string"||typeof e=="function"||Array.isArray(e)?e:"8px"}const Ze=e=>{try{return e()}catch{}},Ql=(e="mui")=>hl(e);function to(e,r,n,i,a){if(!n)return;n=n===!0?{}:n;const l=a==="dark"?"dark":"light";if(!i){r[a]=Gl({...n,palette:{mode:l,...n==null?void 0:n.palette},colorSpace:e});return}const{palette:c,...d}=no({...i,palette:{mode:l,...n==null?void 0:n.palette},colorSpace:e});return r[a]={...n,palette:c,opacity:{...Ln(l),...n==null?void 0:n.opacity},overlays:(n==null?void 0:n.overlays)||Hn(l)},d}function Zl(e={},...r){const{colorSchemes:n={light:!0},defaultColorScheme:i,disableCssColorScheme:a=!1,cssVarPrefix:l="mui",nativeColor:c=!1,shouldSkipGeneratingVar:d=Yl,colorSchemeSelector:f=n.light&&n.dark?"media":void 0,rootSelector:x=":root",...m}=e,b=Object.keys(n)[0],g=i||(n.light&&b!=="light"?"light":b),v=Ql(l),{[g]:C,light:p,dark:T,...s}=n,k={...s};let D=C;if((g==="dark"&&!("dark"in n)||g==="light"&&!("light"in n))&&(D=!0),!D)throw new Error(process.env.NODE_ENV!=="production"?`MUI: The \`colorSchemes.${g}\` option is either missing or invalid.`:Ot(21,g));let A;c&&(A="oklch");const S=to(A,k,D,m,g);p&&!k.light&&to(A,k,p,void 0,"light"),T&&!k.dark&&to(A,k,T,void 0,"dark");let R={defaultColorScheme:g,...S,cssVarPrefix:l,colorSchemeSelector:f,rootSelector:x,getCssVar:v,colorSchemes:k,font:{...El(S.typography),...S.font},spacing:Xl(m.spacing)};Object.keys(R.colorSchemes).forEach(te=>{const h=R.colorSchemes[te].palette,F=E=>{const H=E.split("-"),de=H[1],ue=H[2];return v(E,h[de][ue])};h.mode==="light"&&(B(h.common,"background","#fff"),B(h.common,"onBackground","#000")),h.mode==="dark"&&(B(h.common,"background","#000"),B(h.common,"onBackground","#fff"));function W(E,H,de){if(A){let ue;return E===Dt&&(ue=`transparent ${((1-de)*100).toFixed(0)}%`),E===he&&(ue=`#000 ${(de*100).toFixed(0)}%`),E===me&&(ue=`#fff ${(de*100).toFixed(0)}%`),`color-mix(in ${A}, ${H}, ${ue})`}return E(H,de)}if(Kl(h,["Alert","AppBar","Avatar","Button","Chip","FilledInput","LinearProgress","Skeleton","Slider","SnackbarContent","SpeedDialAction","StepConnector","StepContent","Switch","TableCell","Tooltip"]),h.mode==="light"){B(h.Alert,"errorColor",W(he,h.error.light,.6)),B(h.Alert,"infoColor",W(he,h.info.light,.6)),B(h.Alert,"successColor",W(he,h.success.light,.6)),B(h.Alert,"warningColor",W(he,h.warning.light,.6)),B(h.Alert,"errorFilledBg",F("palette-error-main")),B(h.Alert,"infoFilledBg",F("palette-info-main")),B(h.Alert,"successFilledBg",F("palette-success-main")),B(h.Alert,"warningFilledBg",F("palette-warning-main")),B(h.Alert,"errorFilledColor",Ze(()=>h.getContrastText(h.error.main))),B(h.Alert,"infoFilledColor",Ze(()=>h.getContrastText(h.info.main))),B(h.Alert,"successFilledColor",Ze(()=>h.getContrastText(h.success.main))),B(h.Alert,"warningFilledColor",Ze(()=>h.getContrastText(h.warning.main))),B(h.Alert,"errorStandardBg",W(me,h.error.light,.9)),B(h.Alert,"infoStandardBg",W(me,h.info.light,.9)),B(h.Alert,"successStandardBg",W(me,h.success.light,.9)),B(h.Alert,"warningStandardBg",W(me,h.warning.light,.9)),B(h.Alert,"errorIconColor",F("palette-error-main")),B(h.Alert,"infoIconColor",F("palette-info-main")),B(h.Alert,"successIconColor",F("palette-success-main")),B(h.Alert,"warningIconColor",F("palette-warning-main")),B(h.AppBar,"defaultBg",F("palette-grey-100")),B(h.Avatar,"defaultBg",F("palette-grey-400")),B(h.Button,"inheritContainedBg",F("palette-grey-300")),B(h.Button,"inheritContainedHoverBg",F("palette-grey-A100")),B(h.Chip,"defaultBorder",F("palette-grey-400")),B(h.Chip,"defaultAvatarColor",F("palette-grey-700")),B(h.Chip,"defaultIconColor",F("palette-grey-700")),B(h.FilledInput,"bg","rgba(0, 0, 0, 0.06)"),B(h.FilledInput,"hoverBg","rgba(0, 0, 0, 0.09)"),B(h.FilledInput,"disabledBg","rgba(0, 0, 0, 0.12)"),B(h.LinearProgress,"primaryBg",W(me,h.primary.main,.62)),B(h.LinearProgress,"secondaryBg",W(me,h.secondary.main,.62)),B(h.LinearProgress,"errorBg",W(me,h.error.main,.62)),B(h.LinearProgress,"infoBg",W(me,h.info.main,.62)),B(h.LinearProgress,"successBg",W(me,h.success.main,.62)),B(h.LinearProgress,"warningBg",W(me,h.warning.main,.62)),B(h.Skeleton,"bg",A?W(Dt,h.text.primary,.11):`rgba(${F("palette-text-primaryChannel")} / 0.11)`),B(h.Slider,"primaryTrack",W(me,h.primary.main,.62)),B(h.Slider,"secondaryTrack",W(me,h.secondary.main,.62)),B(h.Slider,"errorTrack",W(me,h.error.main,.62)),B(h.Slider,"infoTrack",W(me,h.info.main,.62)),B(h.Slider,"successTrack",W(me,h.success.main,.62)),B(h.Slider,"warningTrack",W(me,h.warning.main,.62));const E=A?W(he,h.background.default,.6825):kr(h.background.default,.8);B(h.SnackbarContent,"bg",E),B(h.SnackbarContent,"color",Ze(()=>A?oo.text.primary:h.getContrastText(E))),B(h.SpeedDialAction,"fabHoverBg",kr(h.background.paper,.15)),B(h.StepConnector,"border",F("palette-grey-400")),B(h.StepContent,"border",F("palette-grey-400")),B(h.Switch,"defaultColor",F("palette-common-white")),B(h.Switch,"defaultDisabledColor",F("palette-grey-100")),B(h.Switch,"primaryDisabledColor",W(me,h.primary.main,.62)),B(h.Switch,"secondaryDisabledColor",W(me,h.secondary.main,.62)),B(h.Switch,"errorDisabledColor",W(me,h.error.main,.62)),B(h.Switch,"infoDisabledColor",W(me,h.info.main,.62)),B(h.Switch,"successDisabledColor",W(me,h.success.main,.62)),B(h.Switch,"warningDisabledColor",W(me,h.warning.main,.62)),B(h.TableCell,"border",W(me,W(Dt,h.divider,1),.88)),B(h.Tooltip,"bg",W(Dt,h.grey[700],.92))}if(h.mode==="dark"){B(h.Alert,"errorColor",W(me,h.error.light,.6)),B(h.Alert,"infoColor",W(me,h.info.light,.6)),B(h.Alert,"successColor",W(me,h.success.light,.6)),B(h.Alert,"warningColor",W(me,h.warning.light,.6)),B(h.Alert,"errorFilledBg",F("palette-error-dark")),B(h.Alert,"infoFilledBg",F("palette-info-dark")),B(h.Alert,"successFilledBg",F("palette-success-dark")),B(h.Alert,"warningFilledBg",F("palette-warning-dark")),B(h.Alert,"errorFilledColor",Ze(()=>h.getContrastText(h.error.dark))),B(h.Alert,"infoFilledColor",Ze(()=>h.getContrastText(h.info.dark))),B(h.Alert,"successFilledColor",Ze(()=>h.getContrastText(h.success.dark))),B(h.Alert,"warningFilledColor",Ze(()=>h.getContrastText(h.warning.dark))),B(h.Alert,"errorStandardBg",W(he,h.error.light,.9)),B(h.Alert,"infoStandardBg",W(he,h.info.light,.9)),B(h.Alert,"successStandardBg",W(he,h.success.light,.9)),B(h.Alert,"warningStandardBg",W(he,h.warning.light,.9)),B(h.Alert,"errorIconColor",F("palette-error-main")),B(h.Alert,"infoIconColor",F("palette-info-main")),B(h.Alert,"successIconColor",F("palette-success-main")),B(h.Alert,"warningIconColor",F("palette-warning-main")),B(h.AppBar,"defaultBg",F("palette-grey-900")),B(h.AppBar,"darkBg",F("palette-background-paper")),B(h.AppBar,"darkColor",F("palette-text-primary")),B(h.Avatar,"defaultBg",F("palette-grey-600")),B(h.Button,"inheritContainedBg",F("palette-grey-800")),B(h.Button,"inheritContainedHoverBg",F("palette-grey-700")),B(h.Chip,"defaultBorder",F("palette-grey-700")),B(h.Chip,"defaultAvatarColor",F("palette-grey-300")),B(h.Chip,"defaultIconColor",F("palette-grey-300")),B(h.FilledInput,"bg","rgba(255, 255, 255, 0.09)"),B(h.FilledInput,"hoverBg","rgba(255, 255, 255, 0.13)"),B(h.FilledInput,"disabledBg","rgba(255, 255, 255, 0.12)"),B(h.LinearProgress,"primaryBg",W(he,h.primary.main,.5)),B(h.LinearProgress,"secondaryBg",W(he,h.secondary.main,.5)),B(h.LinearProgress,"errorBg",W(he,h.error.main,.5)),B(h.LinearProgress,"infoBg",W(he,h.info.main,.5)),B(h.LinearProgress,"successBg",W(he,h.success.main,.5)),B(h.LinearProgress,"warningBg",W(he,h.warning.main,.5)),B(h.Skeleton,"bg",A?W(Dt,h.text.primary,.13):`rgba(${F("palette-text-primaryChannel")} / 0.13)`),B(h.Slider,"primaryTrack",W(he,h.primary.main,.5)),B(h.Slider,"secondaryTrack",W(he,h.secondary.main,.5)),B(h.Slider,"errorTrack",W(he,h.error.main,.5)),B(h.Slider,"infoTrack",W(he,h.info.main,.5)),B(h.Slider,"successTrack",W(he,h.success.main,.5)),B(h.Slider,"warningTrack",W(he,h.warning.main,.5));const E=A?W(me,h.background.default,.985):kr(h.background.default,.98);B(h.SnackbarContent,"bg",E),B(h.SnackbarContent,"color",Ze(()=>A?Fn.text.primary:h.getContrastText(E))),B(h.SpeedDialAction,"fabHoverBg",kr(h.background.paper,.15)),B(h.StepConnector,"border",F("palette-grey-600")),B(h.StepContent,"border",F("palette-grey-600")),B(h.Switch,"defaultColor",F("palette-grey-300")),B(h.Switch,"defaultDisabledColor",F("palette-grey-600")),B(h.Switch,"primaryDisabledColor",W(he,h.primary.main,.55)),B(h.Switch,"secondaryDisabledColor",W(he,h.secondary.main,.55)),B(h.Switch,"errorDisabledColor",W(he,h.error.main,.55)),B(h.Switch,"infoDisabledColor",W(he,h.info.main,.55)),B(h.Switch,"successDisabledColor",W(he,h.success.main,.55)),B(h.Switch,"warningDisabledColor",W(he,h.warning.main,.55)),B(h.TableCell,"border",W(he,W(Dt,h.divider,1),.68)),B(h.Tooltip,"bg",W(Dt,h.grey[700],.92))}lt(h.background,"default"),lt(h.background,"paper"),lt(h.common,"background"),lt(h.common,"onBackground"),lt(h,"divider"),Object.keys(h).forEach(E=>{const H=h[E];E!=="tonalOffset"&&H&&typeof H=="object"&&(H.main&&B(h[E],"mainChannel",cr(dr(H.main))),H.light&&B(h[E],"lightChannel",cr(dr(H.light))),H.dark&&B(h[E],"darkChannel",cr(dr(H.dark))),H.contrastText&&B(h[E],"contrastTextChannel",cr(dr(H.contrastText))),E==="text"&&(lt(h[E],"primary"),lt(h[E],"secondary")),E==="action"&&(H.active&<(h[E],"active"),H.selected&<(h[E],"selected")))})}),R=r.reduce((te,h)=>Ne(te,h),R);const Y={prefix:l,disableCssColorScheme:a,shouldSkipGeneratingVar:d,getSelector:Jl(R),enableContrastVars:c},{vars:_,generateThemeVars:K,generateStyleSheets:V}=bl(R,Y);return R.vars=_,Object.entries(R.colorSchemes[R.defaultColorScheme]).forEach(([te,h])=>{R[te]=h}),R.generateThemeVars=K,R.generateStyleSheets=V,R.generateSpacing=function(){return Pn(m.spacing,fo(this))},R.getColorSchemeSelector=yl(f),R.spacing=R.generateSpacing(),R.shouldSkipGeneratingVar=d,R.unstable_sxConfig={..._r,...m==null?void 0:m.unstable_sxConfig},R.unstable_sx=function(h){return $r({sx:h,theme:this})},R.toRuntimeSource=Nn,R}function dn(e,r,n){e.colorSchemes&&n&&(e.colorSchemes[r]={...n!==!0&&n,palette:ho({...n===!0?{}:n.palette,mode:r})})}function ec(e={},...r){const{palette:n,cssVariables:i=!1,colorSchemes:a=n?void 0:{light:!0},defaultColorScheme:l=n==null?void 0:n.mode,...c}=e,d=l||"light",f=a==null?void 0:a[d],x={...a,...n?{[d]:{...typeof f!="boolean"&&f,palette:n}}:void 0};if(i===!1){if(!("colorSchemes"in e))return no(e,...r);let m=n;"palette"in e||x[d]&&(x[d]!==!0?m=x[d].palette:d==="dark"&&(m={mode:"dark"}));const b=no({...e,palette:m},...r);return b.defaultColorScheme=d,b.colorSchemes=x,b.palette.mode==="light"&&(b.colorSchemes.light={...x.light!==!0&&x.light,palette:b.palette},dn(b,"dark",x.dark)),b.palette.mode==="dark"&&(b.colorSchemes.dark={...x.dark!==!0&&x.dark,palette:b.palette},dn(b,"light",x.light)),b}return!n&&!("light"in x)&&d==="light"&&(x.light=!0),Zl({...c,colorSchemes:x,defaultColorScheme:d,...typeof i!="boolean"&&i},...r)}const tc=ec();function rc(){const e=sl(tc);return process.env.NODE_ENV!=="production"&&zr.useDebugValue(e),e[Js]||e}function oc({isOpen:e,onClose:r,onCreate:n}){const[i,a]=u.useState(""),[l,c]=u.useState(""),[d,f]=u.useState(null),[x,m]=u.useState(null),[b,g]=u.useState(!1),[v,C]=u.useState(""),p=u.useRef(null),T=async S=>{if(C(""),!S.name.endsWith(".json")){C("Please upload a JSON file");return}try{const R=await S.text(),Y=JSON.parse(R);if(!Array.isArray(Y)){C("JSON must be an array of objects");return}f(S),m(Y)}catch{C("Invalid JSON format")}},s=S=>{S.preventDefault();const R=S.dataTransfer.files[0];R&&T(R)},k=()=>{i.trim()&&x&&(n(i.trim(),l.trim(),x),D())},D=()=>{a(""),c(""),f(null),m(null),C(""),r()},A=!i.trim()||!x;return t.jsxs(t.Fragment,{children:[t.jsxs(o.Dialog,{open:e,onClose:D,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",width:480,boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2.5,fontWeight:500,fontSize:"1.125rem",color:"text.primary",letterSpacing:"-0.01em",borderBottom:"1px solid",borderColor:"divider"},children:["Create new report",t.jsx(o.IconButton,{onClick:D,size:"small",sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(w.Close,{sx:{fontSize:18}})})]}),t.jsx(o.DialogContent,{sx:{px:3,pt:2,pb:2},children:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[t.jsx(o.TextField,{label:"Report name",required:!0,fullWidth:!0,value:i,onChange:S=>a(S.target.value),placeholder:"Enter report name",autoFocus:!0,sx:{"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:1,color:"text.primary"},"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}}}}),t.jsx(o.TextField,{label:"Description (optional)",fullWidth:!0,multiline:!0,rows:2,value:l,onChange:S=>c(S.target.value),placeholder:"Add details about this report",sx:{"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:1,color:"text.primary"},"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}}}}),t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:1.25},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"Data source"}),t.jsx(o.IconButton,{size:"small",onClick:()=>g(!0),sx:{p:.25,color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:t.jsx(w.Info,{sx:{fontSize:16}})})]}),t.jsxs(o.Box,{onDrop:s,onDragOver:S=>S.preventDefault(),onClick:()=>{var S;return(S=p.current)==null?void 0:S.click()},sx:{position:"relative",border:"1.5px",borderStyle:x?"solid":"dashed",borderColor:x?"success.main":v?"error.main":"primary.main",borderRadius:2,p:3,textAlign:"center",cursor:"pointer",bgcolor:x?S=>ne(S.palette.success.main,.04):v?S=>ne(S.palette.error.main,.04):S=>ne(S.palette.primary.main,.04),transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:x?S=>ne(S.palette.success.main,.08):v?S=>ne(S.palette.error.main,.08):S=>ne(S.palette.primary.main,.08),borderColor:x?"success.dark":v?"error.dark":"primary.dark"}},children:[t.jsx("input",{ref:p,type:"file",accept:".json",style:{display:"none"},onChange:S=>{var R;return((R=S.target.files)==null?void 0:R[0])&&T(S.target.files[0])}}),x?t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:.75,animation:"fadeIn 0.2s ease-in","@keyframes fadeIn":{from:{opacity:0,transform:"scale(0.98)"},to:{opacity:1,transform:"scale(1)"}}},children:[t.jsx(o.Box,{sx:{width:40,height:40,borderRadius:"50%",bgcolor:S=>ne(S.palette.success.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:.5},children:t.jsx(w.CheckCircle,{sx:{fontSize:24,color:"success.main"}})}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.main",fontSize:"0.875rem"},children:d==null?void 0:d.name}),t.jsx(o.Typography,{variant:"caption",sx:{color:"success.dark",fontSize:"0.75rem"},children:"Ready to create"})]}):t.jsxs(o.Box,{children:[t.jsx(o.Box,{sx:{width:48,height:48,borderRadius:"50%",bgcolor:S=>ne(S.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mx:"auto",mb:1.5},children:t.jsx(w.CloudUpload,{sx:{fontSize:28,color:"primary.main"}})}),t.jsx(o.Typography,{variant:"body2",sx:{color:"text.primary",fontSize:"0.875rem",fontWeight:500,mb:.25},children:"Upload JSON file"}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.75rem",display:"block"},children:"Click to browse or drag and drop"}),v&&t.jsx(o.Box,{sx:{mt:1.25,p:.75,borderRadius:1,bgcolor:S=>ne(S.palette.error.main,.08),border:1,borderColor:S=>ne(S.palette.error.main,.2)},children:t.jsx(o.Typography,{variant:"caption",sx:{color:"error.main",fontSize:"0.6875rem",fontWeight:500},children:v})})]})]})]})]})}),t.jsxs(o.DialogActions,{sx:{px:3,py:2,gap:1},children:[t.jsx(o.Button,{onClick:D,variant:"text",sx:{textTransform:"none",color:"primary.main",fontWeight:500,fontSize:"0.875rem",borderRadius:"4px",px:2,py:.625,minWidth:64,"&:hover":{bgcolor:S=>ne(S.palette.primary.main,.04)}},children:"Cancel"}),t.jsx(o.Button,{onClick:k,disabled:A,variant:"contained",disableElevation:!0,sx:{textTransform:"none",fontWeight:500,fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",borderRadius:"4px",px:2.5,py:.625,minWidth:64,"&:hover":{bgcolor:"primary.dark",boxShadow:2},"&:disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Create"})]})]}),t.jsxs(o.Dialog,{open:b,onClose:()=>g(!1),maxWidth:"sm",PaperProps:{sx:{borderRadius:3,width:560,maxHeight:"80vh",boxShadow:8}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,fontWeight:500,fontSize:"1.25rem",color:"text.primary",letterSpacing:"-0.01em"},children:["JSON format guide",t.jsx(o.IconButton,{onClick:()=>g(!1),size:"small",sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:t.jsx(w.Close,{sx:{fontSize:20}})})]}),t.jsx(o.DialogContent,{sx:{px:3,py:2},children:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Required format"}),t.jsx(o.Typography,{variant:"body2",sx:{color:"text.secondary",fontSize:"0.8125rem",lineHeight:1.5},children:"Your JSON file must be an array of objects. Each object represents a row, and all should have the same field names."})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Example structure"}),t.jsx(o.Box,{component:"pre",sx:{bgcolor:"action.hover",border:1,borderColor:"divider",p:2,borderRadius:1,overflow:"auto",maxHeight:200,fontSize:"0.75rem",fontFamily:"monospace",lineHeight:1.5,color:"text.primary"},children:`[
|
|
75
|
+
export default theme;`}function En(t){return typeof t=="number"?`${(t*100).toFixed(0)}%`:`calc((${t}) * 100%)`}const cc=t=>{if(!Number.isNaN(+t))return+t;const r=t.match(/\d*\.?\d+/g);if(!r)return 0;let n=0;for(let i=0;i<r.length;i+=1)n+=+r[i];return n};function dc(t){Object.assign(t,{alpha(r,n){const i=this||t;return i.colorSpace?`oklch(from ${r} l c h / ${typeof n=="string"?`calc(${n})`:n})`:i.vars?`rgba(${r.replace(/var\(--([^,\s)]+)(?:,[^)]+)?\)+/g,"var(--$1Channel)")} / ${typeof n=="string"?`calc(${n})`:n})`:N(r,cc(n))},lighten(r,n){const i=this||t;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${r}, #fff ${En(n)})`:uo(r,n)},darken(r,n){const i=this||t;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${r}, #000 ${En(n)})`:co(r,n)}})}function To(t={},...r){const{breakpoints:n,mixins:i={},spacing:a,palette:c={},transitions:l={},typography:d={},shape:f,colorSpace:h,...m}=t;if(t.vars&&t.generateThemeVars===void 0)throw new Error(process.env.NODE_ENV!=="production"?"MUI: `vars` is a private field used for CSS variables support.\nPlease use another name or follow the [docs](https://mui.com/material-ui/customization/css-theme-variables/usage/) to enable the feature.":Gt(20));const g=Ro({...c,colorSpace:h}),y=li(t);let S=Ge(y,{mixins:Kl(y.breakpoints,i),palette:g,shadows:rc.slice(),typography:Ql(g,d),transitions:sc(l),zIndex:{...ac}});if(S=Ge(S,m),S=r.reduce((C,x)=>Ge(C,x),S),process.env.NODE_ENV!=="production"){const C=["active","checked","completed","disabled","error","expanded","focused","focusVisible","required","selected"],x=(E,s)=>{let T;for(T in E){const I=E[T];if(C.includes(T)&&Object.keys(I).length>0){if(process.env.NODE_ENV!=="production"){const A=Dl("",T);console.error([`MUI: The \`${s}\` component increases the CSS specificity of the \`${T}\` internal state.`,"You can not override it like this: ",JSON.stringify(E,null,2),"",`Instead, you need to use the '&.${A}' syntax:`,JSON.stringify({root:{[`&.${A}`]:I}},null,2),"","https://mui.com/r/state-classes-guide"].join(`
|
|
76
|
+
`))}E[T]={}}}};Object.keys(S.components).forEach(E=>{const s=S.components[E].styleOverrides;s&&E.startsWith("Mui")&&x(s,E)})}return S.unstable_sxConfig={...so,...m==null?void 0:m.unstable_sxConfig},S.unstable_sx=function(x){return ao({sx:x,theme:this})},S.toRuntimeSource=fi,dc(S),S}function uc(t){let r;return t<1?r=5.11916*t**2:r=4.5*Math.log(t+1)+2,Math.round(r*10)/1e3}const pc=[...Array(25)].map((t,r)=>{if(r===0)return"none";const n=uc(r);return`linear-gradient(rgba(255 255 255 / ${n}), rgba(255 255 255 / ${n}))`});function xi(t){return{inputPlaceholder:t==="dark"?.5:.42,inputUnderline:t==="dark"?.7:.42,switchTrackDisabled:t==="dark"?.2:.12,switchTrack:t==="dark"?.3:.38}}function hi(t){return t==="dark"?pc:[]}function fc(t){const{palette:r={mode:"light"},opacity:n,overlays:i,colorSpace:a,...c}=t,l=Ro({...r,colorSpace:a});return{palette:l,opacity:{...xi(l.mode),...n},overlays:i||hi(l.mode),...c}}function xc(t){var r;return!!t[0].match(/(cssVarPrefix|colorSchemeSelector|modularCssLayers|rootSelector|typography|mixins|breakpoints|direction|transitions)/)||!!t[0].match(/sxConfig$/)||t[0]==="palette"&&!!((r=t[1])!=null&&r.match(/(mode|contrastThreshold|tonalOffset)/))}const hc=t=>[...[...Array(25)].map((r,n)=>`--${t?`${t}-`:""}overlays-${n}`),`--${t?`${t}-`:""}palette-AppBar-darkBg`,`--${t?`${t}-`:""}palette-AppBar-darkColor`],mc=t=>(r,n)=>{const i=t.rootSelector||":root",a=t.colorSchemeSelector;let c=a;if(a==="class"&&(c=".%s"),a==="data"&&(c="[data-%s]"),a!=null&&a.startsWith("data-")&&!a.includes("%s")&&(c=`[${a}="%s"]`),t.defaultColorScheme===r){if(r==="dark"){const l={};return hc(t.cssVarPrefix).forEach(d=>{l[d]=n[d],delete n[d]}),c==="media"?{[i]:n,"@media (prefers-color-scheme: dark)":{[i]:l}}:c?{[c.replace("%s",r)]:l,[`${i}, ${c.replace("%s",r)}`]:n}:{[i]:{...n,...l}}}if(c&&c!=="media")return`${i}, ${c.replace("%s",String(r))}`}else if(r){if(c==="media")return{[`@media (prefers-color-scheme: ${String(r)})`]:{[i]:n}};if(c)return c.replace("%s",String(r))}return i};function gc(t,r){r.forEach(n=>{t[n]||(t[n]={})})}function M(t,r,n){!t[r]&&n&&(t[r]=n)}function Dr(t){return typeof t!="string"||!t.startsWith("hsl")?t:ci(t)}function yt(t,r){`${r}Channel`in t||(t[`${r}Channel`]=Br(Dr(t[r]),`MUI: Can't create \`palette.${r}Channel\` because \`palette.${r}\` is not one of these formats: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().
|
|
77
|
+
To suppress this warning, you need to explicitly provide the \`palette.${r}Channel\` as a string (in rgb format, for example "12 12 12") or undefined if you want to remove the channel token.`))}function yc(t){return typeof t=="number"?`${t}px`:typeof t=="string"||typeof t=="function"||Array.isArray(t)?t:"8px"}const ut=t=>{try{return t()}catch{}},bc=(t="mui")=>Wl(t);function jo(t,r,n,i,a){if(!n)return;n=n===!0?{}:n;const c=a==="dark"?"dark":"light";if(!i){r[a]=fc({...n,palette:{mode:c,...n==null?void 0:n.palette},colorSpace:t});return}const{palette:l,...d}=To({...i,palette:{mode:c,...n==null?void 0:n.palette},colorSpace:t});return r[a]={...n,palette:l,opacity:{...xi(c),...n==null?void 0:n.opacity},overlays:(n==null?void 0:n.overlays)||hi(c)},d}function vc(t={},...r){const{colorSchemes:n={light:!0},defaultColorScheme:i,disableCssColorScheme:a=!1,cssVarPrefix:c="mui",nativeColor:l=!1,shouldSkipGeneratingVar:d=xc,colorSchemeSelector:f=n.light&&n.dark?"media":void 0,rootSelector:h=":root",...m}=t,g=Object.keys(n)[0],y=i||(n.light&&g!=="light"?"light":g),S=bc(c),{[y]:C,light:x,dark:E,...s}=n,T={...s};let I=C;if((y==="dark"&&!("dark"in n)||y==="light"&&!("light"in n))&&(I=!0),!I)throw new Error(process.env.NODE_ENV!=="production"?`MUI: The \`colorSchemes.${y}\` option is either missing or invalid.`:Gt(21,y));let A;l&&(A="oklch");const v=jo(A,T,I,m,y);x&&!T.light&&jo(A,T,x,void 0,"light"),E&&!T.dark&&jo(A,T,E,void 0,"dark");let W={defaultColorScheme:y,...v,cssVarPrefix:c,colorSchemeSelector:f,rootSelector:h,getCssVar:S,colorSchemes:T,font:{...ql(v.typography),...v.font},spacing:yc(m.spacing)};Object.keys(W.colorSchemes).forEach(X=>{const p=W.colorSchemes[X].palette,L=_=>{const F=_.split("-"),oe=F[1],ue=F[2];return S(_,p[oe][ue])};p.mode==="light"&&(M(p.common,"background","#fff"),M(p.common,"onBackground","#000")),p.mode==="dark"&&(M(p.common,"background","#000"),M(p.common,"onBackground","#fff"));function $(_,F,oe){if(A){let ue;return _===Ut&&(ue=`transparent ${((1-oe)*100).toFixed(0)}%`),_===ye&&(ue=`#000 ${(oe*100).toFixed(0)}%`),_===be&&(ue=`#fff ${(oe*100).toFixed(0)}%`),`color-mix(in ${A}, ${F}, ${ue})`}return _(F,oe)}if(gc(p,["Alert","AppBar","Avatar","Button","Chip","FilledInput","LinearProgress","Skeleton","Slider","SnackbarContent","SpeedDialAction","StepConnector","StepContent","Switch","TableCell","Tooltip"]),p.mode==="light"){M(p.Alert,"errorColor",$(ye,p.error.light,.6)),M(p.Alert,"infoColor",$(ye,p.info.light,.6)),M(p.Alert,"successColor",$(ye,p.success.light,.6)),M(p.Alert,"warningColor",$(ye,p.warning.light,.6)),M(p.Alert,"errorFilledBg",L("palette-error-main")),M(p.Alert,"infoFilledBg",L("palette-info-main")),M(p.Alert,"successFilledBg",L("palette-success-main")),M(p.Alert,"warningFilledBg",L("palette-warning-main")),M(p.Alert,"errorFilledColor",ut(()=>p.getContrastText(p.error.main))),M(p.Alert,"infoFilledColor",ut(()=>p.getContrastText(p.info.main))),M(p.Alert,"successFilledColor",ut(()=>p.getContrastText(p.success.main))),M(p.Alert,"warningFilledColor",ut(()=>p.getContrastText(p.warning.main))),M(p.Alert,"errorStandardBg",$(be,p.error.light,.9)),M(p.Alert,"infoStandardBg",$(be,p.info.light,.9)),M(p.Alert,"successStandardBg",$(be,p.success.light,.9)),M(p.Alert,"warningStandardBg",$(be,p.warning.light,.9)),M(p.Alert,"errorIconColor",L("palette-error-main")),M(p.Alert,"infoIconColor",L("palette-info-main")),M(p.Alert,"successIconColor",L("palette-success-main")),M(p.Alert,"warningIconColor",L("palette-warning-main")),M(p.AppBar,"defaultBg",L("palette-grey-100")),M(p.Avatar,"defaultBg",L("palette-grey-400")),M(p.Button,"inheritContainedBg",L("palette-grey-300")),M(p.Button,"inheritContainedHoverBg",L("palette-grey-A100")),M(p.Chip,"defaultBorder",L("palette-grey-400")),M(p.Chip,"defaultAvatarColor",L("palette-grey-700")),M(p.Chip,"defaultIconColor",L("palette-grey-700")),M(p.FilledInput,"bg","rgba(0, 0, 0, 0.06)"),M(p.FilledInput,"hoverBg","rgba(0, 0, 0, 0.09)"),M(p.FilledInput,"disabledBg","rgba(0, 0, 0, 0.12)"),M(p.LinearProgress,"primaryBg",$(be,p.primary.main,.62)),M(p.LinearProgress,"secondaryBg",$(be,p.secondary.main,.62)),M(p.LinearProgress,"errorBg",$(be,p.error.main,.62)),M(p.LinearProgress,"infoBg",$(be,p.info.main,.62)),M(p.LinearProgress,"successBg",$(be,p.success.main,.62)),M(p.LinearProgress,"warningBg",$(be,p.warning.main,.62)),M(p.Skeleton,"bg",A?$(Ut,p.text.primary,.11):`rgba(${L("palette-text-primaryChannel")} / 0.11)`),M(p.Slider,"primaryTrack",$(be,p.primary.main,.62)),M(p.Slider,"secondaryTrack",$(be,p.secondary.main,.62)),M(p.Slider,"errorTrack",$(be,p.error.main,.62)),M(p.Slider,"infoTrack",$(be,p.info.main,.62)),M(p.Slider,"successTrack",$(be,p.success.main,.62)),M(p.Slider,"warningTrack",$(be,p.warning.main,.62));const _=A?$(ye,p.background.default,.6825):Gr(p.background.default,.8);M(p.SnackbarContent,"bg",_),M(p.SnackbarContent,"color",ut(()=>A?ko.text.primary:p.getContrastText(_))),M(p.SpeedDialAction,"fabHoverBg",Gr(p.background.paper,.15)),M(p.StepConnector,"border",L("palette-grey-400")),M(p.StepContent,"border",L("palette-grey-400")),M(p.Switch,"defaultColor",L("palette-common-white")),M(p.Switch,"defaultDisabledColor",L("palette-grey-100")),M(p.Switch,"primaryDisabledColor",$(be,p.primary.main,.62)),M(p.Switch,"secondaryDisabledColor",$(be,p.secondary.main,.62)),M(p.Switch,"errorDisabledColor",$(be,p.error.main,.62)),M(p.Switch,"infoDisabledColor",$(be,p.info.main,.62)),M(p.Switch,"successDisabledColor",$(be,p.success.main,.62)),M(p.Switch,"warningDisabledColor",$(be,p.warning.main,.62)),M(p.TableCell,"border",$(be,$(Ut,p.divider,1),.88)),M(p.Tooltip,"bg",$(Ut,p.grey[700],.92))}if(p.mode==="dark"){M(p.Alert,"errorColor",$(be,p.error.light,.6)),M(p.Alert,"infoColor",$(be,p.info.light,.6)),M(p.Alert,"successColor",$(be,p.success.light,.6)),M(p.Alert,"warningColor",$(be,p.warning.light,.6)),M(p.Alert,"errorFilledBg",L("palette-error-dark")),M(p.Alert,"infoFilledBg",L("palette-info-dark")),M(p.Alert,"successFilledBg",L("palette-success-dark")),M(p.Alert,"warningFilledBg",L("palette-warning-dark")),M(p.Alert,"errorFilledColor",ut(()=>p.getContrastText(p.error.dark))),M(p.Alert,"infoFilledColor",ut(()=>p.getContrastText(p.info.dark))),M(p.Alert,"successFilledColor",ut(()=>p.getContrastText(p.success.dark))),M(p.Alert,"warningFilledColor",ut(()=>p.getContrastText(p.warning.dark))),M(p.Alert,"errorStandardBg",$(ye,p.error.light,.9)),M(p.Alert,"infoStandardBg",$(ye,p.info.light,.9)),M(p.Alert,"successStandardBg",$(ye,p.success.light,.9)),M(p.Alert,"warningStandardBg",$(ye,p.warning.light,.9)),M(p.Alert,"errorIconColor",L("palette-error-main")),M(p.Alert,"infoIconColor",L("palette-info-main")),M(p.Alert,"successIconColor",L("palette-success-main")),M(p.Alert,"warningIconColor",L("palette-warning-main")),M(p.AppBar,"defaultBg",L("palette-grey-900")),M(p.AppBar,"darkBg",L("palette-background-paper")),M(p.AppBar,"darkColor",L("palette-text-primary")),M(p.Avatar,"defaultBg",L("palette-grey-600")),M(p.Button,"inheritContainedBg",L("palette-grey-800")),M(p.Button,"inheritContainedHoverBg",L("palette-grey-700")),M(p.Chip,"defaultBorder",L("palette-grey-700")),M(p.Chip,"defaultAvatarColor",L("palette-grey-300")),M(p.Chip,"defaultIconColor",L("palette-grey-300")),M(p.FilledInput,"bg","rgba(255, 255, 255, 0.09)"),M(p.FilledInput,"hoverBg","rgba(255, 255, 255, 0.13)"),M(p.FilledInput,"disabledBg","rgba(255, 255, 255, 0.12)"),M(p.LinearProgress,"primaryBg",$(ye,p.primary.main,.5)),M(p.LinearProgress,"secondaryBg",$(ye,p.secondary.main,.5)),M(p.LinearProgress,"errorBg",$(ye,p.error.main,.5)),M(p.LinearProgress,"infoBg",$(ye,p.info.main,.5)),M(p.LinearProgress,"successBg",$(ye,p.success.main,.5)),M(p.LinearProgress,"warningBg",$(ye,p.warning.main,.5)),M(p.Skeleton,"bg",A?$(Ut,p.text.primary,.13):`rgba(${L("palette-text-primaryChannel")} / 0.13)`),M(p.Slider,"primaryTrack",$(ye,p.primary.main,.5)),M(p.Slider,"secondaryTrack",$(ye,p.secondary.main,.5)),M(p.Slider,"errorTrack",$(ye,p.error.main,.5)),M(p.Slider,"infoTrack",$(ye,p.info.main,.5)),M(p.Slider,"successTrack",$(ye,p.success.main,.5)),M(p.Slider,"warningTrack",$(ye,p.warning.main,.5));const _=A?$(be,p.background.default,.985):Gr(p.background.default,.98);M(p.SnackbarContent,"bg",_),M(p.SnackbarContent,"color",ut(()=>A?ui.text.primary:p.getContrastText(_))),M(p.SpeedDialAction,"fabHoverBg",Gr(p.background.paper,.15)),M(p.StepConnector,"border",L("palette-grey-600")),M(p.StepContent,"border",L("palette-grey-600")),M(p.Switch,"defaultColor",L("palette-grey-300")),M(p.Switch,"defaultDisabledColor",L("palette-grey-600")),M(p.Switch,"primaryDisabledColor",$(ye,p.primary.main,.55)),M(p.Switch,"secondaryDisabledColor",$(ye,p.secondary.main,.55)),M(p.Switch,"errorDisabledColor",$(ye,p.error.main,.55)),M(p.Switch,"infoDisabledColor",$(ye,p.info.main,.55)),M(p.Switch,"successDisabledColor",$(ye,p.success.main,.55)),M(p.Switch,"warningDisabledColor",$(ye,p.warning.main,.55)),M(p.TableCell,"border",$(ye,$(Ut,p.divider,1),.68)),M(p.Tooltip,"bg",$(Ut,p.grey[700],.92))}yt(p.background,"default"),yt(p.background,"paper"),yt(p.common,"background"),yt(p.common,"onBackground"),yt(p,"divider"),Object.keys(p).forEach(_=>{const F=p[_];_!=="tonalOffset"&&F&&typeof F=="object"&&(F.main&&M(p[_],"mainChannel",Br(Dr(F.main))),F.light&&M(p[_],"lightChannel",Br(Dr(F.light))),F.dark&&M(p[_],"darkChannel",Br(Dr(F.dark))),F.contrastText&&M(p[_],"contrastTextChannel",Br(Dr(F.contrastText))),_==="text"&&(yt(p[_],"primary"),yt(p[_],"secondary")),_==="action"&&(F.active&&yt(p[_],"active"),F.selected&&yt(p[_],"selected")))})}),W=r.reduce((X,p)=>Ge(X,p),W);const U={prefix:c,disableCssColorScheme:a,shouldSkipGeneratingVar:d,getSelector:mc(W),enableContrastVars:l},{vars:w,generateThemeVars:O,generateStyleSheets:V}=$l(W,U);return W.vars=w,Object.entries(W.colorSchemes[W.defaultColorScheme]).forEach(([X,p])=>{W[X]=p}),W.generateThemeVars=O,W.generateStyleSheets=V,W.generateSpacing=function(){return ai(m.spacing,Oo(this))},W.getColorSchemeSelector=Fl(f),W.spacing=W.generateSpacing(),W.shouldSkipGeneratingVar=d,W.unstable_sxConfig={...so,...m==null?void 0:m.unstable_sxConfig},W.unstable_sx=function(p){return ao({sx:p,theme:this})},W.toRuntimeSource=fi,W}function Bn(t,r,n){t.colorSchemes&&n&&(t.colorSchemes[r]={...n!==!0&&n,palette:Ro({...n===!0?{}:n.palette,mode:r})})}function Sc(t={},...r){const{palette:n,cssVariables:i=!1,colorSchemes:a=n?void 0:{light:!0},defaultColorScheme:c=n==null?void 0:n.mode,...l}=t,d=c||"light",f=a==null?void 0:a[d],h={...a,...n?{[d]:{...typeof f!="boolean"&&f,palette:n}}:void 0};if(i===!1){if(!("colorSchemes"in t))return To(t,...r);let m=n;"palette"in t||h[d]&&(h[d]!==!0?m=h[d].palette:d==="dark"&&(m={mode:"dark"}));const g=To({...t,palette:m},...r);return g.defaultColorScheme=d,g.colorSchemes=h,g.palette.mode==="light"&&(g.colorSchemes.light={...h.light!==!0&&h.light,palette:g.palette},Bn(g,"dark",h.dark)),g.palette.mode==="dark"&&(g.colorSchemes.dark={...h.dark!==!0&&h.dark,palette:g.palette},Bn(g,"light",h.light)),g}return!n&&!("light"in h)&&d==="light"&&(h.light=!0),vc({...l,colorSchemes:h,defaultColorScheme:d,...typeof i!="boolean"&&i},...r)}const Cc=Sc();function jc(){const t=zl(Cc);return process.env.NODE_ENV!=="production"&&Jr.useDebugValue(t),t[ma]||t}function wc({isOpen:t,onClose:r,onCreate:n}){const[i,a]=u.useState(""),[c,l]=u.useState(""),[d,f]=u.useState(null),[h,m]=u.useState(null),[g,y]=u.useState(!1),[S,C]=u.useState(""),x=u.useRef(null),E=async v=>{if(C(""),!v.name.endsWith(".json")){C("Please upload a JSON file");return}try{const W=await v.text(),U=JSON.parse(W);if(!Array.isArray(U)){C("JSON must be an array of objects");return}f(v),m(U)}catch{C("Invalid JSON format")}},s=v=>{v.preventDefault();const W=v.dataTransfer.files[0];W&&E(W)},T=()=>{i.trim()&&h&&(n(i.trim(),c.trim(),h),I())},I=()=>{a(""),l(""),f(null),m(null),C(""),r()},A=!i.trim()||!h;return e.jsxs(e.Fragment,{children:[e.jsxs(o.Dialog,{open:t,onClose:I,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",width:480,maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[e.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2.5,fontWeight:500,fontSize:"1.125rem",color:"text.primary",letterSpacing:"-0.01em",borderBottom:"1px solid",borderColor:"divider"},children:["Create new report",e.jsx(o.IconButton,{onClick:I,size:"small",sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(j.Close,{sx:{fontSize:18}})})]}),e.jsx(o.DialogContent,{sx:{px:3,pt:2,pb:2},children:e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[e.jsx(o.TextField,{label:"Report name",required:!0,fullWidth:!0,value:i,onChange:v=>a(v.target.value),placeholder:"Enter report name",autoFocus:!0,sx:{"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:1,color:"text.primary"},"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}}}}),e.jsx(o.TextField,{label:"Description (optional)",fullWidth:!0,multiline:!0,rows:2,value:c,onChange:v=>l(v.target.value),placeholder:"Add details about this report",sx:{"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:1,color:"text.primary"},"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}}}}),e.jsxs(o.Box,{children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:1.25},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"Data source"}),e.jsx(o.IconButton,{size:"small",onClick:()=>y(!0),sx:{p:.25,color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:e.jsx(j.Info,{sx:{fontSize:16}})})]}),e.jsxs(o.Box,{onDrop:s,onDragOver:v=>v.preventDefault(),onClick:()=>{var v;return(v=x.current)==null?void 0:v.click()},sx:{position:"relative",border:"1.5px",borderStyle:h?"solid":"dashed",borderColor:h?"success.main":S?"error.main":"primary.main",borderRadius:2,p:3,textAlign:"center",cursor:"pointer",bgcolor:h?v=>N(v.palette.success.main,.04):S?v=>N(v.palette.error.main,.04):v=>N(v.palette.primary.main,.04),transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:h?v=>N(v.palette.success.main,.08):S?v=>N(v.palette.error.main,.08):v=>N(v.palette.primary.main,.08),borderColor:h?"success.dark":S?"error.dark":"primary.dark"}},children:[e.jsx("input",{ref:x,type:"file",accept:".json",style:{display:"none"},onChange:v=>{var W;return((W=v.target.files)==null?void 0:W[0])&&E(v.target.files[0])}}),h?e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:.75,animation:"fadeIn 0.2s ease-in","@keyframes fadeIn":{from:{opacity:0,transform:"scale(0.98)"},to:{opacity:1,transform:"scale(1)"}}},children:[e.jsx(o.Box,{sx:{width:40,height:40,borderRadius:"50%",bgcolor:v=>N(v.palette.success.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:.5},children:e.jsx(j.CheckCircle,{sx:{fontSize:24,color:"success.main"}})}),e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.main",fontSize:"0.875rem"},children:d==null?void 0:d.name}),e.jsx(o.Typography,{variant:"caption",sx:{color:"success.dark",fontSize:"0.75rem"},children:"Ready to create"})]}):e.jsxs(o.Box,{children:[e.jsx(o.Box,{sx:{width:48,height:48,borderRadius:"50%",bgcolor:v=>N(v.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mx:"auto",mb:1.5},children:e.jsx(j.CloudUpload,{sx:{fontSize:28,color:"primary.main"}})}),e.jsx(o.Typography,{variant:"body2",sx:{color:"text.primary",fontSize:"0.875rem",fontWeight:500,mb:.25},children:"Upload JSON file"}),e.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.75rem",display:"block"},children:"Click to browse or drag and drop"}),S&&e.jsx(o.Box,{sx:{mt:1.25,p:.75,borderRadius:1,bgcolor:v=>N(v.palette.error.main,.08),border:1,borderColor:v=>N(v.palette.error.main,.2)},children:e.jsx(o.Typography,{variant:"caption",sx:{color:"error.main",fontSize:"0.6875rem",fontWeight:500},children:S})})]})]})]})]})}),e.jsxs(o.DialogActions,{sx:{px:3,py:2,gap:1},children:[e.jsx(o.Button,{onClick:I,variant:"text",sx:{textTransform:"none",color:"primary.main",fontWeight:500,fontSize:"0.875rem",borderRadius:"4px",px:2,py:.625,minWidth:64,"&:hover":{bgcolor:v=>N(v.palette.primary.main,.04)}},children:"Cancel"}),e.jsx(o.Button,{onClick:T,disabled:A,variant:"contained",disableElevation:!0,sx:{textTransform:"none",fontWeight:500,fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",borderRadius:"4px",px:2.5,py:.625,minWidth:64,"&:hover":{bgcolor:"primary.dark",boxShadow:2},"&:disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Create"})]})]}),e.jsxs(o.Dialog,{open:g,onClose:()=>y(!1),maxWidth:"sm",PaperProps:{sx:{borderRadius:3,width:560,maxHeight:"80vh",boxShadow:8}},children:[e.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,fontWeight:500,fontSize:"1.25rem",color:"text.primary",letterSpacing:"-0.01em"},children:["JSON format guide",e.jsx(o.IconButton,{onClick:()=>y(!1),size:"small",sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsx(o.DialogContent,{sx:{px:3,py:2},children:e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Required format"}),e.jsx(o.Typography,{variant:"body2",sx:{color:"text.secondary",fontSize:"0.8125rem",lineHeight:1.5},children:"Your JSON file must be an array of objects. Each object represents a row, and all should have the same field names."})]}),e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Example structure"}),e.jsx(o.Box,{component:"pre",sx:{bgcolor:"action.hover",border:1,borderColor:"divider",p:2,borderRadius:1,overflow:"auto",maxHeight:200,fontSize:"0.75rem",fontFamily:"monospace",lineHeight:1.5,color:"text.primary"},children:`[
|
|
78
78
|
{
|
|
79
79
|
"id": 1,
|
|
80
80
|
"customerName": "John Smith",
|
|
@@ -102,7 +102,7 @@ To suppress this warning, you need to explicitly provide the \`palette.${r}Chann
|
|
|
102
102
|
"memberSince": "2024-03-10",
|
|
103
103
|
"status": "inactive"
|
|
104
104
|
}
|
|
105
|
-
]`})]}),
|
|
105
|
+
]`})]}),e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Supported data types"}),e.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.5},children:e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"• Text, numbers, booleans, dates, and null values"})})]}),e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Guidelines"}),e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.5},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"• Must be valid JSON with array format"}),e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"• All objects should have consistent field names"}),e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:'• Field names auto-format (e.g., "customerName" → "Customer Name")'})]})]})]})}),e.jsx(o.DialogActions,{sx:{px:3,py:2},children:e.jsx(o.Button,{onClick:()=>y(!1),variant:"contained",disableElevation:!0,sx:{textTransform:"none",fontWeight:500,fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",borderRadius:"4px",px:2.5,py:.625,minWidth:64,"&:hover":{bgcolor:"primary.dark",boxShadow:2}},children:"Got it"})})]})]})}function mi({isOpen:t,onClose:r}){return t?e.jsxs(o.Dialog,{open:t,onClose:r,maxWidth:"md",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",maxHeight:"min(640px, calc(100vh - 180px))",my:"auto",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",display:"flex",flexDirection:"column"}},children:[e.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:["JSON Format Guide",e.jsx(o.IconButton,{onClick:r,size:"small",sx:{color:"text.secondary"},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsx(o.DialogContent,{dividers:!0,sx:{overflowY:"auto",flex:1},children:e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:3,py:1},children:[e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Expected JSON Structure"}),e.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["The uploaded JSON must be an ",e.jsx("strong",{children:"array of objects"}),". Each object represents a single row in your report, and the keys of each object become the column names."]})]}),e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Example JSON"}),e.jsx(o.Paper,{elevation:0,sx:{p:2,bgcolor:"action.hover",border:1,borderColor:"divider",borderRadius:1,overflowX:"auto"},children:e.jsx(o.Box,{component:"pre",sx:{fontSize:"caption.fontSize",fontFamily:"monospace",m:0},children:`[
|
|
106
106
|
{
|
|
107
107
|
"Active Sessions": 33,
|
|
108
108
|
"Active State": true,
|
|
@@ -112,4 +112,4 @@ To suppress this warning, you need to explicitly provide the \`palette.${r}Chann
|
|
|
112
112
|
"Region": "Europe",
|
|
113
113
|
"Subscription Type": "Basic"
|
|
114
114
|
}
|
|
115
|
-
]`})})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Supported Column Types"}),t.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:"The system automatically detects column types from your data:"}),t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:[t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,minWidth:80},children:"Number:"}),t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["Numeric values (e.g., ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"33"}),", ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"42.5"}),")"]})]}),t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,minWidth:80},children:"Boolean:"}),t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["True/false values (e.g., ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"true"}),", ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"false"}),")"]})]}),t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,minWidth:80},children:"String:"}),t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["Text values (e.g., ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"Europe"'}),", ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"Analytics Pro"'}),")"]})]}),t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,minWidth:80},children:"Date:"}),t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["ISO date strings (e.g., ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"2024-08-22"'}),")"]})]})]})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Notes"}),t.jsxs(o.Box,{component:"ul",sx:{m:0,pl:2.5,"& li":{fontSize:"body2.fontSize",color:"text.secondary",mb:.5}},children:[t.jsx("li",{children:"Each object in the array represents one row in the report."}),t.jsx("li",{children:"The keys of the JSON objects become report columns."}),t.jsx("li",{children:"All objects should have consistent keys for proper column detection."}),t.jsx("li",{children:"Column names are case-sensitive and preserve spacing."})]})]})]})}),t.jsx(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid #e8eaed",bgcolor:"#f8f9fa",gap:1.25,justifyContent:"flex-end"},children:t.jsx(o.Button,{onClick:r,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#1967d2",color:"#ffffff",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#1557b0",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Got it"})})]}):null}function ic({onFileUpload:e,onError:r,isUploading:n}){const[i,a]=u.useState(!1),[l,c]=u.useState(""),[d,f]=u.useState(!1),x=u.useRef(null),m=async s=>{if(!s.name.endsWith(".json")){r("Please upload a valid JSON file");return}c(s.name);try{const k=await s.text(),D=JSON.parse(k);if(!Array.isArray(D)){r("JSON must be an array of objects");return}if(D.length===0){r("JSON array is empty");return}e(D)}catch{r("Invalid JSON format. Please check your file and try again.")}finally{c("")}},b=s=>{s.preventDefault(),a(!0)},g=s=>{s.preventDefault(),a(!1)},v=s=>{s.preventDefault(),a(!1);const k=s.dataTransfer.files[0];k&&m(k)},C=()=>{var s;(s=x.current)==null||s.click()},p=s=>{var D;const k=(D=s.target.files)==null?void 0:D[0];k&&m(k)},T=s=>{s.stopPropagation(),f(!0)};return t.jsxs(t.Fragment,{children:[t.jsxs(o.Box,{onDragOver:b,onDragLeave:g,onDrop:v,onClick:C,sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderStyle:"dashed",borderColor:i?"primary.main":"divider",bgcolor:i?s=>ne(s.palette.primary.main,.12):"transparent",borderRadius:1,px:2,py:6,cursor:"pointer",transition:"all 0.2s",opacity:n?.5:1,pointerEvents:n?"none":"auto","&:hover":{borderColor:i?"primary.main":"text.secondary"}},children:[t.jsx(o.Box,{component:"input",ref:x,type:"file",accept:".json",onChange:p,sx:{display:"none"}}),n?t.jsxs(t.Fragment,{children:[t.jsx(o.CircularProgress,{size:32,sx:{mb:2}}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,mb:.5},children:"Uploading..."}),l&&t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:l})]}):t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:s=>ne(s.palette.primary.main,.12),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx(w.UploadFile,{sx:{fontSize:32,color:"primary.main"}})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:1.5},children:[t.jsx(o.Button,{variant:"contained",sx:{fontWeight:500},children:"Upload Data (JSON)"}),t.jsx(o.IconButton,{onClick:T,size:"small",sx:{border:1,borderColor:"divider","&:hover":{borderColor:"text.secondary",bgcolor:"action.hover"}},title:"View JSON format guide",children:t.jsx(w.InfoOutlined,{sx:{fontSize:16}})})]}),t.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{textAlign:"center",maxWidth:500},children:"Upload structured JSON data to generate your report."}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{mt:1},children:"Click to browse or drag and drop a JSON file here"})]})]}),t.jsx(nc,{isOpen:d,onClose:()=>f(!1)})]})}function sc({schema:e,onConfirm:r,hasConflicts:n}){return t.jsxs(o.Paper,{sx:{border:2,borderColor:"divider",p:3},children:[t.jsxs(o.Box,{sx:{mb:2},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontWeight:600,mb:.5},children:"Schema Preview"}),t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"Review the detected schema before generating your table"})]}),n&&t.jsxs(o.Alert,{severity:"warning",sx:{mb:2},children:[t.jsx(o.AlertTitle,{sx:{fontWeight:600},children:"Schema Conflict Detected"}),"Some columns have inconsistent data types across rows. Please resolve these conflicts before proceeding."]}),t.jsx(o.TableContainer,{sx:{mb:3},children:t.jsxs(o.Table,{children:[t.jsx(o.TableHead,{children:t.jsxs(o.TableRow,{sx:{bgcolor:"action.hover"},children:[t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Column Name"}),t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Detected Type"}),t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Status"})]})}),t.jsx(o.TableBody,{children:e.map(i=>t.jsxs(o.TableRow,{sx:{bgcolor:i.hasConflict?a=>ne(a.palette.warning.main,.12):"transparent"},children:[t.jsxs(o.TableCell,{sx:{fontWeight:500},children:[i.name,i.hasConflict&&t.jsx(o.Box,{component:"span",sx:{ml:1,color:"warning.main"},children:"⚠"})]}),t.jsx(o.TableCell,{children:t.jsx(o.Chip,{label:i.type,size:"small",sx:{bgcolor:"action.hover"}})}),t.jsx(o.TableCell,{children:t.jsx(o.Chip,{label:i.required?"Required":"Optional",size:"small",color:i.required?"success":"default"})})]},i.name))})]})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pt:2,borderTop:1,borderColor:"divider"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(w.Lock,{sx:{fontSize:16}}),t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"Schema will be locked for this report"})]}),t.jsx(o.Button,{variant:"contained",onClick:r,disabled:n,sx:{fontWeight:500},children:"Generate Table"})]})]})}function ac({error:e,onRetry:r}){return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderColor:"error.light",bgcolor:n=>ne(n.palette.error.main,.12),borderRadius:1,px:2,py:6},children:[t.jsx(o.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:n=>ne(n.palette.error.main,.3),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx(w.ErrorOutline,{color:"error",sx:{fontSize:32}})}),t.jsx(o.Typography,{variant:"h6",color:"error.main",sx:{fontWeight:600,mb:1},children:"Upload Failed"}),t.jsx(o.Typography,{variant:"body2",color:"error.main",sx:{textAlign:"center",maxWidth:500,mb:3},children:e}),t.jsx(o.Button,{variant:"contained",color:"error",startIcon:t.jsx(w.Upload,{sx:{fontSize:16}}),onClick:r,sx:{fontWeight:500},children:"Try Again"})]})}function Un({title:e,description:r,showIcon:n=!0}){return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"60vh",px:3,py:8},children:[n&&t.jsx(o.Box,{sx:{width:80,height:80,borderRadius:"50%",bgcolor:i=>ne(i.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:3},children:t.jsx(w.Description,{sx:{fontSize:36,color:"primary.main"}})}),t.jsx(o.Typography,{variant:"h5",sx:{fontWeight:500,mb:1,color:"text.primary",fontSize:"1.125rem"},children:e}),t.jsx(o.Typography,{variant:"body1",sx:{textAlign:"center",maxWidth:520,color:"text.secondary",fontSize:"0.875rem",lineHeight:1.5},children:r})]})}function lc({value:e,onChange:r,searchHistory:n,onAddToHistory:i,onToggleFavourite:a,onDeleteHistory:l,disabled:c}){const[d,f]=u.useState(!1),[x,m]=u.useState(!1),[b,g]=u.useState(-1),v=u.useRef(null),C=u.useRef(null);u.useEffect(()=>{function _(K){v.current&&!v.current.contains(K.target)&&(f(!1),m(!1))}return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[]);const p=u.useCallback(()=>{m(!0),g(-1),n.length>0&&f(!0)},[n.length]),T=u.useCallback(_=>{r(_),g(-1)},[r]),s=u.useCallback(_=>{var K;r(_),i(_),f(!1),(K=C.current)==null||K.blur()},[r,i]),k=u.useCallback(_=>{g(-1),s(_)},[s]),D=u.useCallback(_=>{var K;_.key==="Enter"?b>=0&&b<n.length?(_.preventDefault(),k(n[b].query)):e.trim()&&s(e.trim()):_.key==="Escape"?(f(!1),g(-1),(K=C.current)==null||K.blur()):_.key==="ArrowDown"?(_.preventDefault(),n.length>0&&(d||f(!0),g(V=>V<n.length-1?V+1:V))):_.key==="ArrowUp"&&(_.preventDefault(),g(V=>V>0?V-1:-1))},[b,n,e,d,k,s]),A=u.useCallback(()=>{var _;r(""),(_=C.current)==null||_.focus()},[r]),S=u.useMemo(()=>n.filter(_=>_.isFavourite),[n]),R=u.useMemo(()=>n.filter(_=>!_.isFavourite),[n]),Y=d&&n.length>0;return t.jsxs(o.Box,{sx:{position:"relative",width:256},ref:v,children:[t.jsx(o.TextField,{inputRef:C,size:"small",fullWidth:!0,value:e,onChange:_=>T(_.target.value),onFocus:p,onKeyDown:D,placeholder:"Search all columns...",disabled:c,sx:{"& .MuiOutlinedInput-root":{borderRadius:"28px",fontSize:"0.875rem",bgcolor:"#f1f3f4","& fieldset":{borderColor:"transparent",transition:"all 0.15s ease"},"&:hover":{bgcolor:"#e8eaed"},"&:hover fieldset":{borderColor:"transparent"},"&.Mui-focused":{bgcolor:"background.paper"},"&.Mui-focused fieldset":{borderColor:"#0b57d0",borderWidth:2}}},InputProps:{startAdornment:t.jsx(o.InputAdornment,{position:"start",children:t.jsx(w.Search,{sx:{fontSize:16,color:"text.secondary"}})}),endAdornment:e?t.jsx(o.InputAdornment,{position:"end",children:t.jsx(o.IconButton,{size:"small",onClick:A,edge:"end",children:t.jsx(w.Close,{sx:{fontSize:16}})})}):null}}),Y&&t.jsxs(o.Paper,{sx:{position:"absolute",zIndex:50,mt:.5,width:"100%",maxHeight:384,overflowY:"auto"},elevation:3,children:[S.length>0&&t.jsxs(o.Box,{sx:{py:1},children:[t.jsx(o.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:600,textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Favourite Searches"}),S.map((_,K)=>t.jsx(un,{entry:_,isSelected:b===K,onClick:()=>k(_.query),onToggleFavourite:()=>a(_.query),onDelete:()=>l(_.query)},`fav-${_.query}`))]}),R.length>0&&t.jsxs(o.Box,{sx:{py:1},children:[S.length>0&&t.jsx(o.Divider,{}),t.jsx(o.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:600,textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Recent Searches"}),R.map((_,K)=>{const V=S.length+K;return t.jsx(un,{entry:_,isSelected:b===V,onClick:()=>k(_.query),onToggleFavourite:()=>a(_.query),onDelete:()=>l(_.query)},`recent-${_.query}`)})]})]})]})}const un=u.memo(function({entry:r,isSelected:n,onClick:i,onToggleFavourite:a,onDelete:l}){const c=u.useCallback(f=>{f.stopPropagation(),a()},[a]),d=u.useCallback(f=>{f.stopPropagation(),l()},[l]);return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:1.5,py:1,cursor:"pointer",bgcolor:n?f=>ne(f.palette.primary.main,.12):"transparent","&:hover":{bgcolor:n?f=>ne(f.palette.primary.main,.12):"action.hover"}},children:[t.jsx(o.Box,{sx:{flex:1,minWidth:0},onClick:i,children:t.jsx(o.Typography,{variant:"body2",noWrap:!0,children:r.query})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,ml:1},children:[t.jsx(o.IconButton,{size:"small",onClick:c,title:r.isFavourite?"Remove from favourites":"Add to favourites",sx:{p:.5},children:r.isFavourite?t.jsx(w.Star,{sx:{fontSize:14,color:"warning.light"}}):t.jsx(w.StarBorder,{sx:{fontSize:14,color:"action.disabled"}})}),t.jsx(o.IconButton,{size:"small",onClick:d,title:"Delete from history",sx:{p:.5,"&:hover":{color:"error.main"}},children:t.jsx(w.Delete,{sx:{fontSize:14,opacity:.5}})})]})]})});function cc({views:e,activeViewId:r,isDirty:n,onSelectView:i,onCreateView:a,onManageViews:l,onToggleDefault:c,onToggleFavorite:d,onRestoreView:f,onPermanentDelete:x,isReadOnly:m}){const b=rc(),[g,v]=u.useState(!1),[C,p]=u.useState(!1),[T,s]=u.useState({top:0,left:0}),k=u.useRef(null),D=u.useRef(null),A=e.find(E=>E.id===r),S=A==null?void 0:A.isDefault,R=e.filter(E=>E.isDefault&&!E.isDeleted),Y=e.filter(E=>!E.isDefault&&!E.isDeleted).sort((E,H)=>(H.updatedAt||0)-(E.updatedAt||0)),_=e.filter(E=>E.isFavorite&&!E.isDeleted).sort((E,H)=>(H.updatedAt||0)-(E.updatedAt||0)),K=e.filter(E=>E.isDeleted);u.useEffect(()=>{if(g&&D.current){const E=D.current.getBoundingClientRect();s({top:E.bottom+window.scrollY+8,left:E.left+window.scrollX})}},[g]),u.useEffect(()=>{const E=H=>{k.current&&!k.current.contains(H.target)&&D.current&&!D.current.contains(H.target)&&v(!1)};return g&&document.addEventListener("mousedown",E),()=>{document.removeEventListener("mousedown",E)}},[g]);const V=E=>{i(E),v(!1)},te=(E,H=!1)=>t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:r===E.id?b.palette.primary.light+"20":"transparent",transition:"background-color 0.2s","&:hover":{backgroundColor:r===E.id?b.palette.primary.light+"20":b.palette.grey[50]}},children:[t.jsxs(o.Button,{onClick:()=>V(E.id),sx:{display:"flex",alignItems:"center",gap:1,flex:1,textAlign:"left",minWidth:0,textTransform:"none",justifyContent:"flex-start",color:"inherit",p:0,"&:hover":{backgroundColor:"transparent"}},children:[r===E.id&&t.jsx(w.Check,{sx:{fontSize:16,flexShrink:0}}),r!==E.id&&t.jsx(o.Box,{sx:{width:"16px",flexShrink:0}}),t.jsx(o.Typography,{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:r===E.id?b.palette.primary.dark:b.palette.text.primary,fontWeight:r===E.id?500:400},children:E.name}),H&&t.jsx(o.Typography,{component:"span",sx:{fontSize:"caption.fontSize",color:b.palette.text.secondary,backgroundColor:b.palette.grey[100],px:1,py:.25,borderRadius:1,flexShrink:0},children:"Default"})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[d&&t.jsx(o.IconButton,{onClick:de=>{de.stopPropagation(),d(E.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:b.palette.grey[200]}},title:E.isFavorite?"Remove from favorites":"Add to favorites",children:t.jsx(w.Star,{sx:{fontSize:16}})}),c&&!E.isDefault&&t.jsx(o.IconButton,{onClick:de=>{de.stopPropagation(),c(E.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:b.palette.grey[200]}},title:"Set as default",children:t.jsx(w.RadioButtonUnchecked,{sx:{fontSize:16}})})]})]},E.id),h=E=>t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:b.palette.grey[50]},children:[t.jsx(o.Typography,{sx:{color:b.palette.text.secondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:E.name}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[f&&t.jsx(o.IconButton,{onClick:H=>{H.stopPropagation(),f(E.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:b.palette.grey[200]}},title:"Restore view",children:t.jsx(w.Undo,{sx:{fontSize:16,color:"success.main"}})}),x&&t.jsx(o.IconButton,{onClick:H=>{H.stopPropagation(),x(E.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:b.palette.grey[200]}},title:"Delete permanently",children:t.jsx(w.Delete,{sx:{fontSize:16,color:"error.main"}})})]})]},E.id),F=n||!S,W=n;return t.jsxs(o.Box,{sx:{position:"relative"},children:[t.jsxs(o.Button,{ref:D,onClick:()=>v(!g),sx:{display:"flex",alignItems:"center",gap:.75,px:1.5,py:.625,fontSize:"0.8125rem",fontWeight:500,borderRadius:1,border:1,borderColor:F?"warning.main":"divider",background:"transparent",color:"inherit",cursor:"pointer",whiteSpace:"nowrap",transition:"border-color 0.15s ease, background-color 0.15s ease",textTransform:"none",mr:.5,"&:hover":{bgcolor:E=>ne(E.palette.primary.main,.04),borderColor:F?"warning.dark":"primary.main"}},children:[W&&t.jsx(o.Box,{component:"span",sx:{width:8,height:8,borderRadius:"50%",bgcolor:"warning.main",flexShrink:0}}),t.jsx(o.Typography,{component:"span",sx:{color:"text.secondary",fontSize:"inherit",letterSpacing:0},children:"View: "}),t.jsx(o.Typography,{component:"span",sx:{fontWeight:600,fontSize:"inherit",color:"text.primary"},children:(A==null?void 0:A.name)||"Default View"}),t.jsx(w.KeyboardArrowDown,{sx:{fontSize:16,color:"text.secondary",ml:.25,flexShrink:0}})]}),g&&gn.createPortal(t.jsxs(o.Box,{ref:k,sx:{position:"fixed",width:"320px",backgroundColor:b.palette.background.paper,border:`1px solid ${b.palette.divider}`,borderRadius:1,boxShadow:b.shadows[8],zIndex:50,maxHeight:"500px",overflowY:"auto",top:T.top,left:T.left},children:[R.length>0&&t.jsxs(o.Box,{sx:{py:.5},children:[t.jsx(o.Typography,{sx:{px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:b.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Default Views"}),R.map(E=>te(E,!0))]}),_.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${b.palette.divider}`}}),t.jsxs(o.Box,{sx:{py:.5},children:[t.jsxs(o.Box,{sx:{px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:b.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",gap:.5},children:[t.jsx(w.Star,{sx:{fontSize:12,color:"warning.light"}}),t.jsx(o.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:"Favorite Views"})]}),_.map(E=>te(E))]})]}),Y.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${b.palette.divider}`}}),t.jsxs(o.Box,{sx:{py:.5},children:[t.jsx(o.Typography,{sx:{px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:b.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Custom Views"}),Y.map(E=>te(E))]})]}),K.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${b.palette.divider}`}}),t.jsxs(o.Box,{sx:{py:.5},children:[t.jsxs(o.Button,{onClick:()=>p(!C),sx:{width:"100%",px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:b.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",justifyContent:"space-between",transition:"background-color 0.2s","&:hover":{backgroundColor:b.palette.grey[50]}},children:[t.jsxs(o.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:["Recently Deleted (",K.length,")"]}),t.jsx(w.ChevronRight,{sx:{fontSize:16}})]}),C&&t.jsx(o.Box,{sx:{backgroundColor:b.palette.grey[50]},children:K.map(E=>h(E))})]})]}),t.jsx(o.Box,{sx:{borderTop:`1px solid ${b.palette.divider}`}}),t.jsxs(o.Button,{onClick:()=>{a(),v(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:b.palette.text.primary,textTransform:"none",justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:b.palette.grey[50]}},children:[t.jsx(w.Add,{sx:{fontSize:16}}),t.jsx(o.Typography,{component:"span",sx:{fontSize:"inherit"},children:"Create New Report View"})]}),t.jsxs(o.Button,{onClick:()=>{l(),v(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:b.palette.text.primary,textTransform:"none",justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:b.palette.grey[50]}},children:[t.jsx(w.Settings,{sx:{fontSize:16}}),t.jsx(o.Typography,{component:"span",sx:{fontSize:"inherit"},children:"View Setup"})]})]}),document.body)]})}function dc({onClick:e,hiddenCount:r,hasCustomOrder:n}){const i=r>0||n;return t.jsxs(o.Button,{onClick:e,variant:"text",size:"small",startIcon:t.jsx(w.ViewColumn,{sx:{fontSize:18}}),sx:{color:i?"#0b57d0":"text.secondary",textTransform:"none",fontWeight:i?500:400,fontSize:"0.875rem",px:1.5,py:0,height:36,minWidth:"auto",borderRadius:"18px",border:i?"1px solid #d3e3fd":"1px solid transparent",bgcolor:i?"#e8f0fe":"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:i?"#d3e3fd":a=>ne(a.palette.text.primary,.06),color:i?"#0b57d0":"text.primary"}},children:["Columns",i&&t.jsx(o.Box,{component:"span",sx:{ml:.5,width:18,height:18,display:"inline-flex",alignItems:"center",justifyContent:"center",bgcolor:"#0b57d0",color:"#fff",borderRadius:"50%",fontSize:"0.65rem",fontWeight:700,lineHeight:1},children:r>0?r:"✓"})]})}function uc({columnName:e,columnType:r="string",currentSort:n,hasFilters:i,isInSortStack:a,position:l,onSort:c,onRemoveSort:d,onSortAscending:f,onSortDescending:x,onFilter:m,onClearFilter:b,onHideColumn:g,onManageColumns:v,onManageViews:C,onResetLayout:p,onClose:T}){const s=u.useRef(null);u.useEffect(()=>{const D=S=>{s.current&&!s.current.contains(S.target)&&T()},A=S=>{S.key==="Escape"&&T()};return document.addEventListener("mousedown",D),document.addEventListener("keydown",A),()=>{document.removeEventListener("mousedown",D),document.removeEventListener("keydown",A)}},[T]);const k=()=>n?n.direction==="asc"?r==="number"?"(0→9)":r==="boolean"?"(False→True)":"(A→Z)":r==="number"?"(9→0)":r==="boolean"?"(True→False)":"(Z→A)":"";return gn.createPortal(t.jsxs(o.Paper,{ref:s,sx:{position:"fixed",left:`${l.x}px`,top:`${l.y}px`,zIndex:100,minWidth:240},elevation:3,children:[t.jsxs(o.Box,{sx:{px:2,py:1},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500},children:"Sorting"}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.IconButton,{size:"small",onClick:()=>{f?f(e):(n==null?void 0:n.direction)!=="asc"&&(c(e),(n==null?void 0:n.direction)==="desc"&&setTimeout(()=>c(e),0))},title:"Sort Ascending",sx:{p:.75},children:t.jsx(w.ArrowUpward,{color:(n==null?void 0:n.direction)==="asc"?"primary":void 0,sx:{fontSize:16}})}),t.jsx(o.IconButton,{size:"small",onClick:()=>{x?x(e):n?n.direction==="asc"&&c(e):(c(e),setTimeout(()=>c(e),0))},title:"Sort Descending",sx:{p:.75},children:t.jsx(w.ArrowDownward,{color:(n==null?void 0:n.direction)==="desc"?"primary":void 0,sx:{fontSize:16}})}),t.jsx(o.IconButton,{size:"small",onClick:()=>d(e),title:"Clear sorting",disabled:!n,sx:{p:.75,"&:hover":{color:"error.main"}},children:t.jsx(w.Close,{sx:{fontSize:16}})})]})]}),n&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mt:.5},children:[t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:k()}),t.jsx(o.Chip,{label:`Level ${n.priority}`,size:"small",color:"primary",sx:{height:20,fontSize:"caption.fontSize"}})]})]}),t.jsx(o.Divider,{}),t.jsxs(o.MenuList,{dense:!0,children:[t.jsxs(o.MenuItem,{onClick:()=>{m(e),T()},children:[t.jsx(w.FilterList,{sx:{fontSize:16,mr:1}}),"Filter this column",i&&t.jsx(o.Chip,{label:"Active",size:"small",color:"primary",sx:{ml:"auto",height:20,fontSize:"caption.fontSize"}})]}),i&&t.jsxs(o.MenuItem,{onClick:()=>{b(e),T()},sx:{color:"warning.main"},children:[t.jsx(w.FilterListOff,{sx:{fontSize:16,mr:1}}),"Clear Filters"]})]}),t.jsx(o.Divider,{}),t.jsx(o.MenuList,{dense:!0,children:t.jsxs(o.MenuItem,{onClick:()=>{g(e),T()},children:[t.jsx(w.VisibilityOff,{sx:{fontSize:16,mr:1}}),"Hide column"]})}),t.jsx(o.Divider,{}),t.jsxs(o.MenuList,{dense:!0,children:[t.jsxs(o.MenuItem,{onClick:()=>{v(),T()},children:[t.jsx(w.Settings,{sx:{fontSize:16,mr:1}}),"Column Settings"]}),t.jsxs(o.MenuItem,{onClick:()=>{C(),T()},children:[t.jsx(w.Description,{sx:{fontSize:16,mr:1}}),"View Setup"]}),t.jsxs(o.MenuItem,{onClick:()=>{p(),T()},children:[t.jsx(w.Undo,{sx:{fontSize:16,mr:1}}),"Reset to Default Layout"]})]})]}),document.body)}const fc=150,fn="COLUMN_HEADER",pc=u.memo(function({column:r,index:n,sortRule:i,hasFilters:a,isInSortStack:l,width:c,onColumnClick:d,onMoveColumn:f,onResizeStart:x,onSort:m,onRemoveSort:b,onSortAscending:g,onSortDescending:v,onOpenFilterForColumn:C,onClearFiltersForColumn:p,onHideColumn:T,onManageColumns:s,onManageViews:k,onResetLayout:D}){const A=u.useRef(null),[S,R]=u.useState(!1),[Y,_]=u.useState({x:0,y:0}),[{handlerId:K,isOver:V},te]=dt.useDrop({accept:fn,collect(O){return{handlerId:O.getHandlerId(),isOver:O.isOver()}},hover(O,N){var oe;if(!A.current)return;const Q=O.index,X=n;if(Q===X)return;const Z=(oe=A.current)==null?void 0:oe.getBoundingClientRect(),re=(Z.right-Z.left)/2,J=N.getClientOffset(),q=((J==null?void 0:J.x)??0)-Z.left;Q<X&&q<re||Q>X&&q>re||(f(Q,X),O.index=X)}}),[{isDragging:h},F]=dt.useDrag({type:fn,item:()=>({index:n,columnName:r.name}),collect:O=>({isDragging:O.isDragging()})});F(te(A));const W=u.useCallback(O=>{O.preventDefault(),O.stopPropagation(),_({x:O.clientX,y:O.clientY}),R(!0)},[]),E=u.useCallback(()=>{R(!1)},[]),H=u.useCallback(()=>{d(r.name)},[d,r.name]),de=u.useCallback(O=>{O.stopPropagation(),C(r.name)},[C,r.name]),ue=u.useCallback(()=>i?t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25,color:"#0b57d0"},children:[i.direction==="asc"?t.jsx(w.ArrowUpward,{sx:{fontSize:13,color:"#0b57d0"}}):t.jsx(w.ArrowDownward,{sx:{fontSize:13,color:"#0b57d0"}}),t.jsx(o.Box,{sx:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:16,height:16,bgcolor:"#0b57d0",color:"#fff",fontSize:"0.6rem",fontWeight:700,borderRadius:"50%",lineHeight:1},children:i.priority})]}):null,[i]),Be=u.useCallback(()=>a?t.jsx(o.Box,{onClick:de,title:"Active filters on this column",sx:{ml:.75,width:7,height:7,borderRadius:"50%",bgcolor:"#0b57d0",cursor:"pointer",flexShrink:0,"&:hover":{transform:"scale(1.25)"},transition:"transform 0.12s ease"}}):null,[a,de]);return t.jsxs(t.Fragment,{children:[t.jsxs(o.TableCell,{ref:A,"data-handler-id":K,"data-column-index":n,onClick:H,onContextMenu:W,sx:{position:"sticky",top:0,zIndex:5,textAlign:"left",fontSize:"0.8125rem",fontWeight:400,textTransform:"none",letterSpacing:0,whiteSpace:"nowrap",cursor:"pointer",userSelect:"none",color:"#5f6368",opacity:h?.25:1,transition:"background-color 0.12s ease, opacity 0.15s ease",bgcolor:V?O=>ne(O.palette.primary.main,.06):"#f8f9fa",borderBottom:"none",py:0,px:2,height:44,"&:hover":{bgcolor:"#e8eaed",color:"#3c4043"},width:c?`${c}px`:`${fc}px`},children:[t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center"},children:[Ct(r.name),ue(),Be()]}),t.jsx(o.Box,{sx:{position:"absolute",right:0,top:0,height:"100%",width:8,cursor:"col-resize",zIndex:10,"&:hover":{bgcolor:"primary.light"}},onMouseDown:O=>{O.stopPropagation(),x(O,r.name)},onClick:O=>O.stopPropagation()}),V&&t.jsx(o.Box,{sx:{position:"absolute",left:0,top:0,bottom:0,width:4,bgcolor:"primary.main"}})]}),S&&t.jsx(uc,{columnName:r.name,columnType:r.type,currentSort:i,hasFilters:a,isInSortStack:l,position:Y,onSort:m,onRemoveSort:b,onSortAscending:g,onSortDescending:v,onFilter:C,onClearFilter:p,onHideColumn:T,onManageColumns:s,onManageViews:k,onResetLayout:D,onClose:E})]})});function xc({selectedCount:e,onExportSelected:r,onClearSelection:n}){const[i,a]=u.useState(null);if(e===0)return null;const l=f=>{a(f.currentTarget)},c=f=>{r(f),a(null)},d=()=>{a(null)};return t.jsx(o.Box,{sx:{position:"fixed",bottom:24,left:"50%",transform:"translateX(-50%)",zIndex:50},children:t.jsxs(o.Box,{sx:{bgcolor:"warning.main",color:"warning.contrastText",boxShadow:3,borderRadius:2,px:3,py:1.5,display:"flex",alignItems:"center",gap:2},children:[t.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:500},children:[e," ",e===1?"row":"rows"," selected"]}),t.jsx(o.Divider,{orientation:"vertical",flexItem:!0,sx:{bgcolor:"warning.light",opacity:.5}}),t.jsx(o.Button,{onClick:l,startIcon:t.jsx(w.Download,{sx:{fontSize:16}}),size:"small",sx:{bgcolor:f=>ne(f.palette.warning.dark,.3),color:"warning.contrastText","&:hover":{bgcolor:f=>ne(f.palette.warning.dark,.5)},textTransform:"none"},children:"Export Selected"}),t.jsxs(o.Menu,{anchorEl:i,open:!!i,onClose:d,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:[t.jsx(o.MenuItem,{onClick:()=>c("csv"),children:"Export as CSV"}),t.jsx(o.MenuItem,{onClick:()=>c("excel"),children:"Export as Excel"}),t.jsx(o.MenuItem,{onClick:()=>c("json"),children:"Export as JSON"})]}),t.jsx(o.Divider,{orientation:"vertical",flexItem:!0,sx:{bgcolor:"primary.light",opacity:.5}}),t.jsx(o.Button,{onClick:n,startIcon:t.jsx(w.Close,{sx:{fontSize:16}}),size:"small",sx:{color:"warning.contrastText","&:hover":{bgcolor:f=>ne(f.palette.warning.dark,.3)},textTransform:"none"},children:"Clear Selection"})]})})}const pn=[10,25,50,100];function hc({currentPage:e,pageSize:r,totalRows:n,onPageChange:i,onPageSizeChange:a}){const l=Math.ceil(n/r);if(n<=Math.min(...pn))return null;const c=()=>{e>1&&i(e-1)},d=()=>{e<l&&i(e+1)},f=(e-1)*r+1,x=Math.min(e*r,n);return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:3,px:2,py:1,borderTop:"1px solid",borderColor:"divider",bgcolor:"background.paper",minHeight:48},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400},children:"Rows per page:"}),t.jsx(o.Select,{value:r,onChange:m=>a(Number(m.target.value)),size:"small",MenuProps:{PaperProps:{sx:{maxHeight:300}},anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"}},sx:{minWidth:70,fontSize:"0.8125rem",color:"text.primary","& .MuiSelect-select":{py:.5,px:1.5},"& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"}},children:pn.map(m=>t.jsx(o.MenuItem,{value:m,sx:{fontSize:"0.8125rem"},children:m},m))})]}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400},children:[f,"–",x," of ",n]}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400},children:["Page ",e," of ",l]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.IconButton,{onClick:c,disabled:e===1,size:"small",title:"Previous page",sx:{p:.75,color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"action.disabled"}},children:t.jsx(w.ChevronLeft,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:d,disabled:e===l,size:"small",title:"Next page",sx:{p:.75,color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"action.disabled"}},children:t.jsx(w.ChevronRight,{sx:{fontSize:20}})})]})]})}function mc(){return t.jsx(o.Chip,{icon:t.jsx(w.Visibility,{sx:{fontSize:14}}),label:"View Only",size:"small",variant:"outlined",sx:{bgcolor:"action.hover",borderColor:"divider",fontSize:"caption.fontSize",fontWeight:500}})}function gc(e,r){if(e==null||e==="")return"—";if(r==="boolean")return e?"True":"False";if(r==="object"||r==="array")try{return JSON.stringify(e,null,2)}catch{return String(e)}return String(e)}function bc({open:e,onClose:r,row:n,schema:i,reportName:a}){if(!n)return null;const l=i.filter(c=>c.name in n);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"md",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",overflow:"hidden",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[t.jsxs(o.Box,{sx:{px:3,py:2,bgcolor:"#f8f9fa",borderBottom:"1px solid #e8eaed",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[t.jsxs(o.Stack,{direction:"row",spacing:1.5,alignItems:"center",children:[t.jsx(o.Box,{sx:{width:36,height:36,borderRadius:"8px",bgcolor:"#e8f0fe",display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx(w.Visibility,{sx:{fontSize:18,color:"#1967d2"}})}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"#202124",letterSpacing:"0",lineHeight:1.5},children:"Record Detail"}),a&&t.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"#5f6368"},children:a})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{p:.75,color:"#5f6368",transition:"all 0.2s ease","&:hover":{bgcolor:"#f1f3f4",color:"#202124"}},children:t.jsx(w.Close,{sx:{fontSize:20}})})]}),t.jsx(o.DialogContent,{sx:{p:3,bgcolor:"#ffffff"},children:t.jsx(o.Box,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:2},children:l.map(c=>{const d=n[c.name],f=gc(d,c.type),x=f==="—";return t.jsxs(o.Box,{sx:{p:2,borderRadius:"8px",border:"1px solid #e8eaed",bgcolor:"#ffffff",transition:"all 0.2s ease","&:hover":{bgcolor:"#f8f9fa",borderColor:"#dadce0"}},children:[t.jsxs(o.Stack,{direction:"row",alignItems:"center",spacing:.75,mb:1,children:[t.jsx(o.Typography,{variant:"caption",sx:{color:"#5f6368",fontSize:"0.6875rem",fontWeight:600,letterSpacing:"0.1em",textTransform:"uppercase",flex:1},children:Ct(c.name)}),t.jsx(o.Chip,{label:c.type.toUpperCase(),size:"small",sx:{height:18,fontSize:"0.625rem",fontWeight:600,fontFamily:"monospace",bgcolor:"#f1f3f4",color:"#5f6368","& .MuiChip-label":{px:.75}}})]}),t.jsx(o.Typography,{variant:"body2",sx:{color:x?"#bdc1c6":"#3c4043",fontStyle:x?"italic":"normal",fontSize:"0.875rem",wordBreak:"break-word",whiteSpace:c.type==="object"||c.type==="array"?"pre-wrap":"normal",fontFamily:c.type==="number"?"monospace":"inherit",fontWeight:c.type==="number"?500:400},children:f})]},c.name)})})}),t.jsx(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid #e8eaed",bgcolor:"#f8f9fa",gap:1.25,justifyContent:"flex-end"},children:t.jsx(o.Button,{onClick:r,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#1967d2",color:"#ffffff",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#1557b0",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Close"})})]})}function yc({open:e,onClose:r,onConfirm:n,rowPreview:i}){return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2.5,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[t.jsxs(o.Stack,{direction:"row",spacing:1.5,alignItems:"flex-start",children:[t.jsx(o.Box,{sx:{width:40,height:40,borderRadius:"50%",bgcolor:"#fce8e6",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(w.WarningAmberRounded,{sx:{fontSize:22,color:"#d93025"}})}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"#202124",letterSpacing:"0",lineHeight:1.5,mb:.5},children:"Delete record?"}),t.jsxs(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"#5f6368"},children:[i?`"${i}"`:"This record"," will be permanently removed."]})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{p:.75,color:"#5f6368",transition:"all 0.2s ease","&:hover":{bgcolor:"#f1f3f4",color:"#202124"}},children:t.jsx(w.Close,{sx:{fontSize:20}})})]}),t.jsx(o.DialogContent,{sx:{px:3,pb:2},children:t.jsx(o.Box,{sx:{p:2,borderRadius:"8px",bgcolor:"#fce8e6",border:"1px solid #f28b82"},children:t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"#d93025",fontWeight:500},children:"This action cannot be undone. The record will be deleted from this report immediately."})})}),t.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid #e8eaed",bgcolor:"#f8f9fa",gap:1.25,justifyContent:"flex-end"},children:[t.jsx(o.Button,{onClick:r,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"#5f6368",px:3,py:.875,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"#e8eaed",color:"#202124"}},children:"Cancel"}),t.jsx(o.Button,{onClick:()=>{n(),r()},variant:"contained",startIcon:t.jsx(w.DeleteForever,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#d93025",color:"#ffffff",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#b3190e",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Delete record"})]})]})}function Sc({open:e,onClose:r,onSave:n,row:i,schema:a,reportName:l}){const[c,d]=u.useState({});if(u.useEffect(()=>{e&&i&&d({...i})},[e,i]),!i)return null;const f=a.filter(g=>g.name in i),x=(g,v)=>{d(C=>({...C,[g]:v}))},m=()=>{const g={...c};f.forEach(v=>{const C=c[v.name];if(v.type==="number"){const p=Number(C);g[v.name]=isNaN(p)?i[v.name]:p}else v.type==="boolean"&&(g[v.name]=!!C)}),n(g),r()},b=g=>{const v=c[g.name],C=Ct(g.name);return g.type==="boolean"?t.jsx(o.FormControlLabel,{control:t.jsx(o.Switch,{checked:!!v,onChange:p=>x(g.name,p.target.checked),size:"small",sx:{"& .MuiSwitch-switchBase.Mui-checked":{color:"#1967d2"},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{bgcolor:"#1967d2"}}}),label:t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"#3c4043",fontWeight:500},children:C}),sx:{m:0}},g.name):t.jsx(o.TextField,{label:C,value:v??"",onChange:p=>x(g.name,p.target.value),type:g.type==="number"?"number":"text",size:"small",fullWidth:!0,variant:"outlined",InputLabelProps:g.type==="string"&&String(v).match(/^\d{4}-\d{2}-\d{2}/)?{shrink:!0}:void 0,sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"#ffffff","& fieldset":{borderColor:"#dadce0"},"&:hover fieldset":{borderColor:"#1967d2"},"&.Mui-focused fieldset":{borderColor:"#1967d2",borderWidth:"2px"}},"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"#5f6368","&.Mui-focused":{color:"#1967d2"}},"& .MuiInputBase-input":{color:"#3c4043"}}},g.name)};return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"md",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",overflow:"hidden",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[t.jsxs(o.Box,{sx:{px:3,py:2,bgcolor:"#f8f9fa",borderBottom:"1px solid #e8eaed",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[t.jsxs(o.Stack,{direction:"row",spacing:1.5,alignItems:"center",children:[t.jsx(o.Box,{sx:{width:36,height:36,borderRadius:"8px",bgcolor:"#fef7e0",display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx(w.Edit,{sx:{fontSize:18,color:"#ea8600"}})}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"#202124",letterSpacing:"0",lineHeight:1.5},children:"Edit Record"}),l&&t.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"#5f6368"},children:l})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{p:.75,color:"#5f6368",transition:"all 0.2s ease","&:hover":{bgcolor:"#f1f3f4",color:"#202124"}},children:t.jsx(w.Close,{sx:{fontSize:20}})})]}),t.jsx(o.DialogContent,{sx:{p:3,bgcolor:"#ffffff"},children:t.jsx(o.Box,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:2.5},children:f.map(g=>t.jsx(o.Box,{sx:g.type==="boolean"?{gridColumn:"1 / -1"}:{},children:b(g)},g.name))})}),t.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid #e8eaed",bgcolor:"#f8f9fa",gap:1.25,justifyContent:"flex-end"},children:[t.jsx(o.Button,{onClick:r,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"#5f6368",px:3,py:.875,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"#e8eaed",color:"#202124"}},children:"Cancel"}),t.jsx(o.Button,{onClick:m,variant:"contained",startIcon:t.jsx(w.Save,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#1967d2",color:"#ffffff",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#1557b0",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Save Changes"})]})]})}const vc=160,Cc={active:{bg:"#e6f4ea",color:"#137333"},completed:{bg:"#e6f4ea",color:"#137333"},approved:{bg:"#e6f4ea",color:"#137333"},success:{bg:"#e6f4ea",color:"#137333"},done:{bg:"#e6f4ea",color:"#137333"},contract:{bg:"#e8f0fe",color:"#0b57d0"},"in progress":{bg:"#e8f0fe",color:"#0b57d0"},"in review":{bg:"#e8f0fe",color:"#0b57d0"},review:{bg:"#e8f0fe",color:"#0b57d0"},pending:{bg:"#e8f0fe",color:"#0b57d0"},"on leave":{bg:"#fce8e6",color:"#c5221f"},"on hold":{bg:"#fef7e0",color:"#b06000"},probation:{bg:"#fef7e0",color:"#b06000"},cancelled:{bg:"#fce8e6",color:"#c5221f"},rejected:{bg:"#fce8e6",color:"#c5221f"},blocked:{bg:"#fce8e6",color:"#c5221f"},inactive:{bg:"#f1f3f4",color:"#5f6368"},"not started":{bg:"#f1f3f4",color:"#5f6368"},paused:{bg:"#f1f3f4",color:"#5f6368"}},jc={low:"#5f6368",medium:"#b06000",high:"#e8710a",critical:"#c5221f",urgent:"#c5221f"};function wc(e){const r=e.toLowerCase().trim(),n=Cc[r]||{bg:"#f1f3f4",color:"#5f6368"};return t.jsx(o.Box,{component:"span",sx:{display:"inline-flex",alignItems:"center",px:1.25,py:.375,borderRadius:"12px",fontSize:"0.75rem",fontWeight:500,bgcolor:n.bg,color:n.color,whiteSpace:"nowrap",lineHeight:1.6,letterSpacing:"0.01em"},children:e})}function kc(e){const r=e.toLowerCase().trim(),n=jc[r];return n?t.jsx(o.Box,{component:"span",sx:{color:n,fontWeight:500,fontSize:"inherit"},children:e}):e}function Tc(e){return t.jsx(o.Box,{component:"span",sx:{color:"#0b57d0",fontFamily:'"Roboto Mono", "Courier New", monospace',fontSize:"0.8125rem",fontWeight:400,letterSpacing:"0.04em"},children:e})}function zc(e,r){if(r==null||r==="")return t.jsx(o.Box,{component:"span",sx:{color:"#bdc1c6"},children:"—"});const n=String(r),i=e.name.toLowerCase().replace(/[_\s-]/g,"");return/\b(status|state|stage|employmenttype|contracttype|availability)\b/.test(e.name.toLowerCase())?wc(n):/\b(priority|severity|urgency|importance|criticality)\b/.test(e.name.toLowerCase())?kc(n):/(\bid\b|id$|_id$|code$|ref$|no$|num$)/.test(i)||/^[A-Z]{2,8}-\d{2,}$/.test(n)?Tc(n):e.type==="number"&&typeof r=="number"?r.toLocaleString():typeof r=="boolean"?r?"Yes":"No":typeof r=="object"?JSON.stringify(r):n}function Ec({schema:e,data:r,sortStack:n=[],filters:i=[],views:a=[],activeViewId:l="",isDirty:c=!1,isExporting:d=!1,columnVisibility:f={},columnOrder:x=[],columnWidths:m={},grouping:b=null,onSort:g,onSortAscending:v,onSortDescending:C,onOpenFilters:p,onOpenSort:T,onOpenFilterForColumn:s,onSelectView:k,onCreateView:D,onManageViews:A,onUpdateCurrentView:S,onSaveAsNewView:R,onToggleDefault:Y,onToggleFavorite:_,onRestoreView:K,onPermanentDelete:V,onExport:te,onOpenColumns:h,onUpdateColumnWidth:F,onUpdateColumnOrder:W,onUpdateColumnVisibility:E,onClearFiltersForColumn:H,onResetLayout:de,onOpenGroup:ue,onToggleGroupCollapse:Be,onOpenAuditHistory:O,onOpenSharePreset:N,searchQuery:Q,searchHistory:X=[],onAddToSearchHistory:Z,onToggleSearchFavourite:re,onDeleteSearchHistory:J,selectedRowIds:q=new Set,onSearchChange:oe,onToggleRowSelection:ie,onToggleAllRows:se,onRangeSelection:ve,onClearSelection:$,onExportSelected:De,currentPage:Ae=1,pageSize:et=10,totalRowsBeforePagination:tt=r.length,onPageChange:Fe,onPageSizeChange:Le,isReadOnly:Me=!1,userRole:ft,reportName:At,onEditRow:pt,onDuplicateRow:xt,onDeleteRow:ht}){const[rt,Rt]=u.useState(null),[ot,Gt]=u.useState(0),[kt,Te]=u.useState(0),[nt,qe]=u.useState(null),[it,Mt]=u.useState(null),[mt,Je]=u.useState(null),[hr,Tt]=u.useState(!1),[Yt,Pt]=u.useState(!1),[zt,gt]=u.useState(null),[ye,qt]=u.useState(""),[Jt,Ke]=u.useState(!1),[P,He]=u.useState(null),[le,Oe]=u.useState(null),[fe,Ue]=u.useState(null);u.useRef(null);const bt=u.useMemo(()=>x.length>0?x.map(M=>e.find(L=>L.name===M)).filter(M=>M!==void 0):e,[x,e]),Pe=u.useMemo(()=>bt.filter(M=>f[M.name]!==!1),[bt,f]),Kt=u.useMemo(()=>e.filter(M=>f[M.name]===!1).length,[e,f]),Wt=u.useMemo(()=>e.map(M=>M.name),[e]),je=u.useMemo(()=>JSON.stringify(x)!==JSON.stringify(Wt),[x,Wt]),U=u.useCallback((M,L)=>{M.preventDefault(),M.stopPropagation(),Rt(L),Gt(M.clientX),Te(m[L]||150)},[m]);u.useEffect(()=>{if(!rt)return;const M=ae=>{const $e=ae.clientX-ot,ce=Math.max(100,kt+$e);F==null||F(rt,ce)},L=()=>{Rt(null)};return document.addEventListener("mousemove",M),document.addEventListener("mouseup",L),()=>{document.removeEventListener("mousemove",M),document.removeEventListener("mouseup",L)}},[rt,ot,kt,F]);const st=u.useCallback(M=>M==null?"-":typeof M=="object"?JSON.stringify(M):typeof M=="boolean"?M?"true":"false":String(M),[]);u.useCallback(M=>{const L=n.find(ae=>ae.column===M);return L?t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[L.direction==="asc"?t.jsx(w.ArrowUpward,{sx:{fontSize:14}}):t.jsx(w.ArrowDownward,{sx:{fontSize:14}}),t.jsx(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center",width:16,height:16,bgcolor:"primary.main",color:"primary.contrastText",fontSize:"caption.fontSize",fontWeight:"bold",borderRadius:"50%"},children:L.priority})]}):null},[n]),u.useCallback(M=>i.some(ae=>ae.column===M)?t.jsx(o.IconButton,{size:"small",onClick:ae=>{ae.stopPropagation(),s==null||s(M)},sx:{ml:.5,p:.25,color:"primary.main","&:hover":{color:"primary.main"}},title:"Active filters on this column",children:t.jsx(w.FilterList,{sx:{fontSize:14}})}):null,[i,s]);const We=u.useCallback(M=>{g&&g(M)},[g]),Xt=u.useCallback((M,L)=>{if(!W)return;const ae=[...x.length>0?x:e.map(ce=>ce.name)],[$e]=ae.splice(M,1);ae.splice(L,0,$e),W(ae)},[W,x,e]),Qt=u.useCallback(M=>{if(!g)return;const L=n.find(ae=>ae.column===M);(!L||L.direction!=="asc")&&g(M)},[g,n]),Zt=u.useCallback(M=>{if(!g)return;const L=n.find(ae=>ae.column===M);L?L.direction==="asc"&&g(M):(g(M),setTimeout(()=>g(M),0))},[g,n]),er=u.useCallback(M=>{if(!g)return;const L=n.find(ae=>ae.column===M);L&&(L.direction==="asc"?(g(M),setTimeout(()=>g(M),0)):L.direction==="desc"&&g(M))},[g,n]),tr=u.useCallback(M=>{E&&E(M,!1)},[E]),rr=(b==null?void 0:b.enabled)&&r.length>0&&r[0]&&"isGroupHeader"in r[0],_t=u.useMemo(()=>Pe.map(M=>M.name),[Pe]),_e=u.useMemo(()=>Q&&Q.trim()?En(r,e,Q,_t):r,[r,e,Q,_t]);u.useEffect(()=>{const M=L=>{!se||!$||L.target instanceof HTMLInputElement||L.target instanceof HTMLTextAreaElement||((L.ctrlKey||L.metaKey)&&L.key==="a"&&(L.preventDefault(),se(!0,_e.length)),L.key==="Escape"&&(L.preventDefault(),$()))};return document.addEventListener("keydown",M),()=>document.removeEventListener("keydown",M)},[se,$,_e.length]);const Et=u.useCallback((M,L)=>{ie&&(L.shiftKey&&nt!==null?(L.preventDefault(),ve&&ve(nt,M)):(ie(M),qe(M)))},[ie,nt,ve]),or=u.useMemo(()=>_e.length>0&&q.size>0&&_e.every((M,L)=>q.has(L)),[_e,q]);q.size>0;const at=ie&&se,nr=u.useCallback(M=>{var $e;const L=M.groupLevel,ae=L*24;return t.jsx(o.TableRow,{onClick:()=>Be==null?void 0:Be(M.groupKey),sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"},cursor:"pointer",borderTop:2,borderColor:"divider"},children:t.jsx(o.TableCell,{colSpan:Pe.length+(at?1:0),sx:{pl:`${ae+24}px`},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[M.isCollapsed?t.jsx(w.ChevronRight,{sx:{fontSize:16}}):t.jsx(w.KeyboardArrowDown,{sx:{fontSize:16}}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:Xi(L,(($e=b==null?void 0:b.levels[L])==null?void 0:$e.column)||"",M.groupValue)}),t.jsxs(o.Box,{sx:{px:1,py:.25,fontSize:"caption.fontSize",fontWeight:500,bgcolor:ce=>ne(ce.palette.primary.main,.12),color:"primary.main",borderRadius:2},children:[M.rowCount," ",M.rowCount===1?"row":"rows"]}),Object.keys(M.aggregates).length>0&&t.jsx(o.Typography,{variant:"caption",sx:{ml:1,color:"text.secondary"},children:Object.entries(M.aggregates).map(([ce,Bt])=>Ki(Bt)).filter(Boolean).join(" • ")})]})})},M.groupKey)},[Pe,at,b,Be]),It=u.useCallback((M,L)=>{const ae=q.has(L),$e=it===L;return t.jsxs(o.TableRow,{"data-row-index":L,onMouseEnter:()=>Mt(L),onMouseLeave:()=>Mt(null),onClick:ce=>{!ie||ce.target.closest("[data-row-action]")||Et(L,ce)},onContextMenu:ce=>{ce.preventDefault(),ce.stopPropagation(),Ue({mouseX:ce.clientX,mouseY:ce.clientY,row:M,rowIndex:L})},sx:{height:52,cursor:"pointer",bgcolor:ae?ce=>ne(ce.palette.warning.main,.12):"background.paper",transition:"background-color 0.12s ease","&:hover":{bgcolor:ae?ce=>ne(ce.palette.warning.main,.2):"#f8f9fa"},borderBottom:"1px solid",borderColor:"divider"},children:[Pe.map((ce,Bt)=>t.jsx(o.TableCell,{sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",py:0,px:2,fontSize:"0.875rem",fontWeight:400,color:"#202124",borderBottom:"none",minWidth:m[ce.name]?`${m[ce.name]}px`:`${vc}px`},children:zc(ce,M[ce.name])},ce.name)),t.jsx(o.TableCell,{"data-row-action":"true",onClick:ce=>ce.stopPropagation(),sx:{position:"sticky",right:0,width:40,minWidth:40,maxWidth:40,p:0,border:"none",bgcolor:"transparent",opacity:$e?1:0,transition:"opacity 0.12s ease",zIndex:2,verticalAlign:"middle"},children:t.jsx(o.IconButton,{size:"small",onClick:ce=>{ce.stopPropagation(),ce.preventDefault(),Ue({anchorEl:ce.currentTarget,row:M,rowIndex:L})},sx:{color:"text.secondary","&:hover":{bgcolor:ce=>ne(ce.palette.text.primary,.08),color:"text.primary"}},children:t.jsx(w.MoreVert,{sx:{fontSize:18}})})})]},L)},[q,it,Et,Pe,m,st,pt,xt,ht,ie,Je,Tt,Ue]);return t.jsxs(dt.DndProvider,{backend:io.HTML5Backend,children:[t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:[at&&De&&$&&t.jsx(xc,{selectedCount:q.size,onExportSelected:De,onClearSelection:$}),t.jsxs(o.Box,{sx:{position:"sticky",top:0,zIndex:10,bgcolor:"background.paper",borderBottom:"1px solid",borderColor:"divider",px:2,py:0,height:56,display:"flex",alignItems:"center",gap:.5},children:[Me&&t.jsx(mc,{}),oe&&Z&&re&&J&&t.jsx(o.Box,{sx:{flexGrow:1,maxWidth:480,minWidth:240},children:t.jsx(lc,{value:Q||"",onChange:oe,searchHistory:X,onAddToHistory:Z,onToggleFavourite:re,onDeleteHistory:J,disabled:Me})}),t.jsx(o.Box,{sx:{flexGrow:1}}),k&&D&&A&&S&&a.length>0&&t.jsx(cc,{views:a||[],activeViewId:l||"",isDirty:c,onSelectView:k,onCreateView:D,onManageViews:A,onToggleDefault:Y,onToggleFavorite:_,onRestoreView:K,onPermanentDelete:V,isReadOnly:Me}),t.jsx(o.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5,my:1}}),!Me&&T&&t.jsxs(o.Button,{onClick:T,variant:"text",size:"small",startIcon:t.jsx(w.SwapVert,{sx:{fontSize:18}}),sx:{color:n.length>0?"#0b57d0":"text.secondary",textTransform:"none",fontWeight:n.length>0?500:400,fontSize:"0.875rem",px:1.5,py:0,height:36,minWidth:"auto",borderRadius:"18px",border:n.length>0?"1px solid #d3e3fd":"1px solid transparent",bgcolor:n.length>0?"#e8f0fe":"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:n.length>0?"#d3e3fd":M=>ne(M.palette.text.primary,.06),color:n.length>0?"#0b57d0":"text.primary"}},children:["Sort",n.length>0&&t.jsx(o.Box,{component:"span",sx:{ml:.5,width:18,height:18,display:"inline-flex",alignItems:"center",justifyContent:"center",bgcolor:"#0b57d0",color:"#fff",borderRadius:"50%",fontSize:"0.65rem",fontWeight:700,lineHeight:1},children:n.length})]}),!Me&&p&&t.jsxs(o.Button,{onClick:p,variant:"text",size:"small",startIcon:t.jsx(w.FilterList,{sx:{fontSize:18}}),sx:{color:i.length>0?"#0b57d0":"text.secondary",textTransform:"none",fontWeight:i.length>0?500:400,fontSize:"0.875rem",px:1.5,py:0,height:36,minWidth:"auto",borderRadius:"18px",border:i.length>0?"1px solid #d3e3fd":"1px solid transparent",bgcolor:i.length>0?"#e8f0fe":"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:i.length>0?"#d3e3fd":M=>ne(M.palette.text.primary,.06),color:i.length>0?"#0b57d0":"text.primary"}},children:["Filter",i.length>0&&t.jsx(o.Box,{component:"span",sx:{ml:.5,width:18,height:18,display:"inline-flex",alignItems:"center",justifyContent:"center",bgcolor:"#0b57d0",color:"#fff",borderRadius:"50%",fontSize:"0.65rem",fontWeight:700,lineHeight:1},children:i.length})]}),!Me&&h&&t.jsx(dc,{onClick:h,hiddenCount:Kt,hasCustomOrder:je}),t.jsx(o.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5,my:1}}),te&&t.jsx(o.Tooltip,{title:"Export",children:t.jsx(o.IconButton,{onClick:te,disabled:d,size:"small",sx:{color:"text.secondary",borderRadius:1,transition:"color 0.15s ease, background-color 0.15s ease","&:hover":{bgcolor:M=>ne(M.palette.text.primary,.06),color:"text.primary"}},children:t.jsx(w.Download,{sx:{fontSize:18}})})}),t.jsx(o.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5,my:1}}),!Me&&ue&&t.jsx(o.Tooltip,{title:"Group",children:t.jsx(o.IconButton,{onClick:ue,size:"small",sx:{color:"text.secondary",borderRadius:1,transition:"color 0.15s ease, background-color 0.15s ease","&:hover":{bgcolor:M=>ne(M.palette.text.primary,.06),color:"text.primary"}},children:t.jsx(w.Layers,{sx:{fontSize:18}})})}),O&&t.jsx(o.Tooltip,{title:"Audit History",children:t.jsx(o.IconButton,{onClick:O,size:"small",sx:{color:"text.secondary",borderRadius:1,transition:"color 0.15s ease, background-color 0.15s ease","&:hover":{bgcolor:M=>ne(M.palette.text.primary,.06),color:"text.primary"}},children:t.jsx(w.History,{sx:{fontSize:18}})})}),N&&t.jsx(o.Tooltip,{title:"Share Report State",children:t.jsx(o.IconButton,{onClick:N,size:"small",sx:{color:"text.secondary",borderRadius:1,transition:"color 0.15s ease, background-color 0.15s ease","&:hover":{bgcolor:M=>ne(M.palette.text.primary,.06),color:"text.primary"}},children:t.jsx(w.Share,{sx:{fontSize:18}})})})]}),t.jsxs(o.Box,{sx:{position:"relative",overflow:"hidden",flex:1,display:"flex",flexDirection:"column"},children:[t.jsx(o.Box,{sx:{flex:1,overflowY:"auto",overflowX:"auto",position:"relative",bgcolor:"background.paper","&::-webkit-scrollbar":{width:8,height:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:M=>M.palette.mode==="dark"?"rgba(255,255,255,0.2)":"rgba(0,0,0,0.2)",borderRadius:4,"&:hover":{bgcolor:M=>M.palette.mode==="dark"?"rgba(255,255,255,0.3)":"rgba(0,0,0,0.3)"}}},children:t.jsxs(o.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",width:"100%",minWidth:"100%"},stickyHeader:!0,children:[t.jsx(o.TableHead,{children:t.jsxs(o.TableRow,{sx:{height:44,bgcolor:"transparent",borderBottom:"1px solid",borderColor:"divider"},children:[Pe.map((M,L)=>t.jsx(pc,{column:M,index:L,sortRule:n.find(ae=>ae.column===M.name),hasFilters:i.some(ae=>ae.column===M.name),isInSortStack:n.some(ae=>ae.column===M.name),width:m[M.name],onColumnClick:We,onMoveColumn:Xt,onResizeStart:U,onSort:We,onRemoveSort:er,onSortAscending:Qt,onSortDescending:Zt,onOpenFilterForColumn:s||(()=>{}),onClearFiltersForColumn:H||(()=>{}),onHideColumn:tr,onManageColumns:h||(()=>{}),onManageViews:A||(()=>{}),onResetLayout:de||(()=>{})},M.name)),t.jsx(o.TableCell,{sx:{position:"sticky",top:0,right:0,width:40,minWidth:40,p:0,border:"none",bgcolor:"#f8f9fa",zIndex:6}})]})}),t.jsx(o.TableBody,{children:_e.length===0?t.jsx(o.TableRow,{children:t.jsx(o.TableCell,{colSpan:Pe.length+(at?1:0),align:"center",sx:{py:4},children:t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})})}):rr?_e.map((M,L)=>M.isGroupHeader?nr(M):It(M,L)):_e.map((M,L)=>It(M,L))})]})}),Fe&&Le&&t.jsx(hc,{currentPage:Ae,pageSize:et,totalRows:tt,onPageChange:Fe,onPageSizeChange:Le}),!(Fe&&Le)&&t.jsx(o.Box,{sx:{px:3,py:1.5,bgcolor:"action.hover",borderTop:1,borderColor:"divider"},children:t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["Showing ",_e.length," ",_e.length===1?"row":"rows"]})})]})]}),t.jsxs(o.Popover,{open:!!fe,onClose:()=>Ue(null),anchorEl:(fe==null?void 0:fe.anchorEl)||null,anchorReference:fe!=null&&fe.anchorEl?"anchorEl":"anchorPosition",anchorPosition:fe&&!fe.anchorEl?{top:fe.mouseY,left:fe.mouseX}:void 0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:fe!=null&&fe.anchorEl?{vertical:"top",horizontal:"right"}:{vertical:"top",horizontal:"left"},PaperProps:{sx:{minWidth:176,py:.5,borderRadius:1.5,boxShadow:3}},children:[t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{fe&&(Je(fe.row),Tt(!0)),Ue(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(w.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"View"})]}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{fe&&(He(fe.row),Oe(fe.rowIndex),Ke(!0)),Ue(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(w.Edit,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Edit"})]}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{fe&&(xt==null||xt(fe.rowIndex,fe.row)),Ue(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(w.ContentCopy,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Duplicate"})]}),t.jsx(o.Divider,{sx:{my:.5}}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{if(fe){gt(fe.rowIndex);const M=Object.values(fe.row).find(L=>L!=null&&L!=="");qt(M?String(M):""),Pt(!0)}Ue(null)},sx:{py:1,px:2,gap:1.5,color:"error.main"},children:[t.jsx(w.Delete,{sx:{fontSize:18,color:"error.main"}}),t.jsx(o.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]}),t.jsx(bc,{open:hr,onClose:()=>{Tt(!1),Je(null)},row:mt,schema:e,reportName:At}),t.jsx(Sc,{open:Jt,onClose:()=>{Ke(!1),He(null),Oe(null)},onSave:M=>{le!==null&&(pt==null||pt(le,M))},row:P,schema:e,reportName:At}),t.jsx(yc,{open:Yt,onClose:()=>{Pt(!1),gt(null)},onConfirm:()=>{zt!==null&&(ht==null||ht(zt))},rowPreview:ye})]})}function Ic({schema:e,filters:r,onAddFilter:n,onRemoveFilter:i,onUpdateFilter:a,onClearAll:l,onClose:c,focusColumn:d}){const[f,x]=u.useState(""),[m,b]=u.useState(""),[g,v]=u.useState(""),[C,p]=u.useState([]);u.useEffect(()=>{p([...r])},[r]),u.useEffect(()=>{d&&x(d)},[d]);const T=u.useCallback(()=>{x(""),b(""),v("")},[]),s=u.useMemo(()=>e.filter(V=>V.type!=="mixed"&&V.type!=="null"&&V.type!=="array"&&V.type!=="object"),[e]),k=e.find(V=>V.name===f),D=u.useMemo(()=>k?Po(k.type):[],[k]),A=u.useCallback(()=>!(!f||!m||vr(m)&&!g.trim()),[f,m,g]),S=u.useCallback(()=>{if(!A())return;const V={column:f,operator:m};if(vr(m)){const te=k==null?void 0:k.type;V.value=te==="number"?Number(g):g}p([...C,V]),T()},[A,f,m,k,g,C,T]),R=u.useCallback(V=>{p(C.filter((te,h)=>h!==V))},[C]),Y=u.useCallback(()=>{l(),C.forEach(V=>n(V)),c()},[C,n,l,c]),_=u.useCallback(()=>{p([...r]),T(),c()},[r,T,c]),K=u.useCallback(V=>{var W;const te=e.find(E=>E.name===V.column);if(!te)return"";const F=((W=Po(te.type).find(E=>E.value===V.operator))==null?void 0:W.label)||V.operator;return vr(V.operator)?`${V.column} ${F.toLowerCase()} "${V.value}"`:`${V.column} ${F.toLowerCase()}`},[e]);return t.jsx(o.Box,{onClick:_,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:V=>V.stopPropagation(),elevation:0,sx:{position:"relative",width:520,maxWidth:"calc(100vw - 120px)",maxHeight:"min(520px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"#ffffff",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid #e8eaed",flexShrink:0},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"#202124",letterSpacing:"0",lineHeight:1.5},children:"Filter columns"}),t.jsx(o.IconButton,{onClick:_,size:"small",sx:{p:.75,color:"#5f6368",transition:"all 0.2s ease","&:hover":{bgcolor:"#f1f3f4",color:"#202124"}},children:t.jsx(w.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"#dadce0",borderRadius:4,"&:hover":{bgcolor:"#bdc1c6"}}},children:[t.jsxs(o.Box,{sx:{mb:2.5},children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"#5f6368",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add filter"}),t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.75},children:[t.jsxs(o.FormControl,{size:"small",fullWidth:!0,children:[t.jsx(o.InputLabel,{sx:{fontSize:"0.875rem",color:"#5f6368","&.Mui-focused":{color:"#1967d2"}},children:"Column"}),t.jsx(o.Select,{value:f,onChange:V=>{x(V.target.value),b(""),v("")},label:"Column",sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"#ffffff","& .MuiOutlinedInput-notchedOutline":{borderColor:"#dadce0",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"#1967d2"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"#1967d2",borderWidth:"2px"}},children:s.map(V=>t.jsxs(o.MenuItem,{value:V.name,sx:{fontSize:"0.875rem",color:"#3c4043",py:1,"&:hover":{bgcolor:"#f1f3f4"},"&.Mui-selected":{bgcolor:"#e8f0fe","&:hover":{bgcolor:"#d2e3fc"}}},children:[Ct(V.name)," (",V.type,")"]},V.name))})]}),f&&t.jsxs(o.FormControl,{size:"small",fullWidth:!0,children:[t.jsx(o.InputLabel,{sx:{fontSize:"0.875rem",color:"#5f6368","&.Mui-focused":{color:"#1967d2"}},children:"Operator"}),t.jsx(o.Select,{value:m,onChange:V=>{b(V.target.value),v("")},label:"Operator",sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"#ffffff","& .MuiOutlinedInput-notchedOutline":{borderColor:"#dadce0",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"#1967d2"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"#1967d2",borderWidth:"2px"}},children:D.map(V=>t.jsx(o.MenuItem,{value:V.value,sx:{fontSize:"0.875rem",color:"#3c4043",py:1,"&:hover":{bgcolor:"#f1f3f4"},"&.Mui-selected":{bgcolor:"#e8f0fe","&:hover":{bgcolor:"#d2e3fc"}}},children:V.label},V.value))})]}),m&&vr(m)&&t.jsx(o.TextField,{size:"small",fullWidth:!0,type:(k==null?void 0:k.type)==="number"?"number":"text",value:g,onChange:V=>v(V.target.value),label:"Value",placeholder:"Enter value...",sx:{"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"#5f6368","&.Mui-focused":{color:"#1967d2"}},"& .MuiOutlinedInput-root":{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"#ffffff","& fieldset":{borderColor:"#dadce0",transition:"border-color 0.2s ease"},"&:hover fieldset":{borderColor:"#1967d2"},"&.Mui-focused fieldset":{borderColor:"#1967d2",borderWidth:"2px"}},"& .MuiInputBase-input":{py:1,color:"#3c4043"}}})]}),t.jsx(o.Button,{onClick:S,disabled:!A(),sx:{mt:1.5,textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"#1967d2",p:0,justifyContent:"flex-start",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"#1557b0",textDecoration:"underline"},"&.Mui-disabled":{color:"#bdc1c6"}},children:"+ Add another filter"})]}),C.length>0&&t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1.5},children:[t.jsxs(o.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"#5f6368",letterSpacing:"0.1em",textTransform:"uppercase"},children:["Active filters (",C.length,")"]}),t.jsx(o.Button,{onClick:()=>p([]),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"#d93025",p:0,minWidth:"auto",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"#b3190e",textDecoration:"underline"}},children:"Clear all"})]}),t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:C.map((V,te)=>t.jsx(o.Chip,{label:K(V),onDelete:()=>R(te),sx:{bgcolor:"#e8f0fe",color:"#1967d2",fontSize:"0.875rem",fontWeight:400,height:32,borderRadius:"16px",border:"1px solid #d2e3fc",transition:"all 0.2s ease","&:hover":{bgcolor:"#d2e3fc",borderColor:"#aecbfa"},"& .MuiChip-label":{px:1.5,color:"#1967d2"},"& .MuiChip-deleteIcon":{color:"#1967d2",fontSize:18,transition:"all 0.2s ease","&:hover":{color:"#1557b0"}}}},te))})]})]}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid #e8eaed",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"#f8f9fa"},children:[t.jsx(o.Button,{onClick:_,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"#5f6368",px:3,py:1,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"#e8eaed",color:"#202124"}},children:"Cancel"}),t.jsx(o.Button,{onClick:Y,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#1967d2",color:"#ffffff",px:3,py:1,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#1557b0",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Apply filter"})]})]})})}const xn="SORT_RULE";function Bc({rule:e,index:r,onToggleDirection:n,onRemove:i,onMove:a}){const l=u.useRef(null),[{handlerId:c},d]=dt.useDrop({accept:xn,collect(m){return{handlerId:m.getHandlerId()}},hover(m,b){var k;if(!l.current)return;const g=m.index,v=r;if(g===v)return;const C=(k=l.current)==null?void 0:k.getBoundingClientRect(),p=(C.bottom-C.top)/2,T=b.getClientOffset(),s=((T==null?void 0:T.y)??0)-C.top;g<v&&s<p||g>v&&s>p||(a(g,v),m.index=v)}}),[{isDragging:f},x]=dt.useDrag({type:xn,item:()=>({index:r}),collect:m=>({isDragging:m.isDragging()})});return x(d(l)),t.jsxs(o.Box,{ref:l,"data-handler-id":c,sx:{display:"flex",alignItems:"center",gap:1.25,px:2,py:1.25,borderRadius:"8px",bgcolor:"#ffffff",border:"1px solid #e8eaed",opacity:f?.4:1,cursor:"move",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:"#f8f9fa",borderColor:"#dadce0",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.1), 0 1px 3px 1px rgba(60, 64, 67, 0.05)",transform:"translateY(-1px)"}},children:[t.jsx(o.Chip,{label:e.priority,size:"small",sx:{width:26,height:26,fontSize:"0.75rem",fontWeight:600,bgcolor:"#1967d2",color:"#ffffff",boxShadow:"0 1px 2px 0 rgba(25, 103, 210, 0.3)","& .MuiChip-label":{px:0}}}),t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:"3px",cursor:"grab",px:.5,opacity:.6,transition:"opacity 0.2s ease","&:hover":{opacity:1},"&:active":{cursor:"grabbing"}},children:[t.jsx(o.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"#5f6368"}}),t.jsx(o.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"#5f6368"}}),t.jsx(o.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"#5f6368"}})]}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",fontWeight:400,color:"#3c4043",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"0 0 100px",lineHeight:1.5},children:e.column}),t.jsx(o.FormControl,{size:"small",sx:{flex:1,minWidth:100},children:t.jsxs(o.Select,{value:e.direction,onChange:m=>n(r,m.target.value),sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"#ffffff","& .MuiOutlinedInput-notchedOutline":{borderColor:"#dadce0",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"#1967d2"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"#1967d2",borderWidth:"2px"},"& .MuiSelect-select":{py:.875,color:"#3c4043",fontWeight:400}},children:[t.jsx(o.MenuItem,{value:"asc",sx:{fontSize:"0.875rem",color:"#3c4043","&:hover":{bgcolor:"#f1f3f4"},"&.Mui-selected":{bgcolor:"#e8f0fe","&:hover":{bgcolor:"#d2e3fc"}}},children:"Ascending"}),t.jsx(o.MenuItem,{value:"desc",sx:{fontSize:"0.875rem",color:"#3c4043","&:hover":{bgcolor:"#f1f3f4"},"&.Mui-selected":{bgcolor:"#e8f0fe","&:hover":{bgcolor:"#d2e3fc"}}},children:"Descending"})]})}),t.jsx(o.IconButton,{onClick:()=>i(r),size:"small",sx:{p:.5,color:"#5f6368",transition:"all 0.2s ease","&:hover":{color:"#d93025",bgcolor:"rgba(217, 48, 37, 0.08)",transform:"scale(1.1)"}},children:t.jsx(w.Close,{sx:{fontSize:18}})})]})}function Dc({schema:e,sortStack:r,onUpdateSortStack:n,onClose:i}){const[a,l]=u.useState(""),[c,d]=u.useState([]);u.useEffect(()=>{d([...r])},[r]);const f=u.useCallback(()=>!(c.length>=3||!a||c.some(s=>s.column===a)),[c,a]),x=u.useCallback(()=>{if(!f())return;const s=c.length+1,k={column:a,direction:"asc",priority:s};d([...c,k]),l("")},[f,a,c]),m=u.useCallback(s=>{const D=c.filter((A,S)=>S!==s).map((A,S)=>({...A,priority:S+1}));d(D)},[c]),b=u.useCallback((s,k)=>{const D=[...c];D[s]={...D[s],direction:k},d(D)},[c]),g=u.useCallback((s,k)=>{const D=[...c],[A]=D.splice(s,1);D.splice(k,0,A);const S=D.map((R,Y)=>({...R,priority:Y+1}));d(S)},[c]),v=u.useCallback(()=>{d([])},[]),C=u.useCallback(()=>{n(c),i()},[c,n,i]),p=u.useCallback(()=>{d([...r]),l(""),i()},[r,i]),T=e.filter(s=>!c.some(k=>k.column===s.name));return t.jsx(dt.DndProvider,{backend:io.HTML5Backend,children:t.jsx(o.Box,{onClick:p,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:s=>s.stopPropagation(),elevation:0,sx:{position:"relative",width:480,maxWidth:"calc(100vw - 120px)",maxHeight:"min(440px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"#ffffff",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid #e8eaed",flexShrink:0},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"#202124",letterSpacing:"0",lineHeight:1.5},children:"Sort columns"}),t.jsx(o.IconButton,{onClick:p,size:"small",sx:{p:.75,color:"#5f6368",transition:"all 0.2s ease","&:hover":{bgcolor:"#f1f3f4",color:"#202124"}},children:t.jsx(w.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"#dadce0",borderRadius:4,"&:hover":{bgcolor:"#bdc1c6"}}},children:[t.jsxs(o.Box,{sx:{mb:2.5},children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"#5f6368",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add sort level"}),t.jsxs(o.FormControl,{size:"small",fullWidth:!0,disabled:c.length>=3,children:[t.jsx(o.InputLabel,{sx:{fontSize:"0.875rem",color:"#5f6368","&.Mui-focused":{color:"#1967d2"}},children:"Select column..."}),t.jsx(o.Select,{value:a,onChange:s=>l(s.target.value),label:"Select column...",sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"#ffffff","& .MuiOutlinedInput-notchedOutline":{borderColor:"#dadce0",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"#1967d2"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"#1967d2",borderWidth:"2px"},"&.Mui-disabled":{bgcolor:"#f8f9fa"}},children:T.map(s=>t.jsx(o.MenuItem,{value:s.name,sx:{fontSize:"0.875rem",color:"#3c4043",py:1,"&:hover":{bgcolor:"#f1f3f4"},"&.Mui-selected":{bgcolor:"#e8f0fe","&:hover":{bgcolor:"#d2e3fc"}}},children:Ct(s.name)},s.name))})]}),t.jsx(o.Button,{onClick:x,disabled:!f(),sx:{mt:1.5,textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"#1967d2",p:0,justifyContent:"flex-start",minHeight:"auto",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"#1557b0",textDecoration:"underline"},"&.Mui-disabled":{color:"#bdc1c6"}},children:"+ Add sort column"})]}),c.length>0&&t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1.5},children:[t.jsxs(o.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"#5f6368",letterSpacing:"0.1em",textTransform:"uppercase"},children:["Sorted sequence (",c.length,"/3)"]}),t.jsx(o.Button,{onClick:v,sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"#d93025",p:0,minWidth:"auto",minHeight:"auto",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"#b3190e",textDecoration:"underline"}},children:"Clear all"})]}),t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:c.map((s,k)=>t.jsx(Bc,{rule:s,index:k,onToggleDirection:b,onRemove:m,onMove:g},`${s.column}-${k}`))})]})]}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid #e8eaed",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"#f8f9fa"},children:[t.jsx(o.Button,{onClick:p,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"#5f6368",px:3,py:1,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"#e8eaed",color:"#202124"}},children:"Cancel"}),t.jsx(o.Button,{onClick:C,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#1967d2",color:"#ffffff",px:3,py:1,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#1557b0",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Apply sort"})]})]})})})}function Oc({views:e,activeViewId:r,onSelectView:n,onCreateView:i,onEditView:a,onDeleteView:l,onRestoreView:c,onPermanentDelete:d,onClose:f}){return t.jsxs(o.Dialog,{open:!0,onClose:f,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{mt:8,borderRadius:"12px",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:["Manage Views",t.jsx(o.IconButton,{onClick:f,size:"small",sx:{color:"text.secondary"},children:t.jsx(w.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.DialogContent,{children:[t.jsx(o.Box,{sx:{mb:2},children:t.jsx(o.Button,{onClick:i,variant:"contained",startIcon:t.jsx(w.Add,{sx:{fontSize:16}}),size:"small",children:"Create New Report View"})}),t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:e.map(x=>t.jsx(o.Paper,{sx:{p:2,border:1,borderColor:x.isDeleted?"error.light":r===x.id?"primary.main":"divider",bgcolor:x.isDeleted?m=>ne(m.palette.error.main,.12):r===x.id?m=>ne(m.palette.primary.main,.12):"background.paper",opacity:x.isDeleted?.75:1,cursor:x.isDeleted?"default":"pointer","&:hover":x.isDeleted?{}:{bgcolor:"action.hover"}},onClick:()=>!x.isDeleted&&n(x.id),elevation:0,children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.5},children:[t.jsxs(o.Box,{sx:{flex:1},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,textDecoration:x.isDeleted?"line-through":"none",color:x.isDeleted?"text.secondary":"text.primary"},children:x.name}),x.isDeleted&&t.jsx(o.Chip,{label:"Deleted",size:"small",color:"error",sx:{height:20}}),x.isDefault&&t.jsx(o.Chip,{label:"Default",size:"small",color:"primary",sx:{height:20}}),x.isFavorite&&t.jsx(o.Chip,{label:"★ Favorite",size:"small",sx:{height:20}})]}),x.description&&t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:x.description})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[!x.isDeleted&&t.jsxs(t.Fragment,{children:[t.jsx(o.IconButton,{size:"small",onClick:m=>{m.stopPropagation(),a(x.id)},title:"Edit view",children:t.jsx(w.Edit,{sx:{fontSize:16}})}),t.jsx(o.IconButton,{size:"small",onClick:m=>{m.stopPropagation(),l(x.id)},title:"Delete view",sx:{"&:hover":{color:"error.main"}},children:t.jsx(w.Delete,{sx:{fontSize:16}})})]}),x.isDeleted&&c&&t.jsx(o.IconButton,{size:"small",onClick:m=>{m.stopPropagation(),c(x.id)},title:"Restore view",sx:{color:"success.main"},children:t.jsx(w.Undo,{sx:{fontSize:16}})}),x.isDeleted&&d&&t.jsx(o.IconButton,{size:"small",onClick:m=>{m.stopPropagation(),d(x.id)},title:"Delete permanently",sx:{color:"error.main"},children:t.jsx(w.Delete,{sx:{fontSize:16}})})]})]})},x.id))})]}),t.jsx(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid #e8eaed",bgcolor:"#f8f9fa",gap:1.25,justifyContent:"flex-end"},children:t.jsx(o.Button,{onClick:f,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#1967d2",color:"#ffffff",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#1557b0",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Close"})})]})}function hn({currentSnapshot:e,onSave:r,onClose:n,isEditMode:i=!1,initialName:a="",initialDescription:l="",initialIsDefault:c=!1}){const[d,f]=u.useState(a),[x,m]=u.useState(l),[b,g]=u.useState(c),v=()=>{d.trim()&&(r(d.trim(),x.trim(),b),n())},C=T=>{T.key==="Enter"&&!T.shiftKey?v():T.key==="Escape"&&n()},p=()=>i&&a?`Update ${a} view`:"Create New Report View";return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{mt:8,borderRadius:"12px",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:[p(),t.jsx(o.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:t.jsx(w.Close,{sx:{fontSize:20}})})]}),t.jsx(o.DialogContent,{children:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2,pt:1},children:[t.jsx(o.TextField,{label:"View Name",required:!0,value:d,onChange:T=>f(T.target.value),onKeyDown:C,placeholder:"e.g., Active Users",autoFocus:!0,fullWidth:!0,size:"small"}),t.jsx(o.TextField,{label:"Description (optional)",value:x,onChange:T=>m(T.target.value),placeholder:"Brief description of this view",multiline:!0,rows:2,fullWidth:!0,size:"small"}),t.jsxs(o.Paper,{sx:{p:2,bgcolor:"action.hover"},variant:"outlined",children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,mb:1},children:"This view will capture:"}),t.jsxs(o.Box,{component:"ul",sx:{m:0,pl:2,"& li":{fontSize:"body2.fontSize",color:"text.secondary"}},children:[t.jsxs("li",{children:[e.filters.length," filter",e.filters.length!==1?"s":""]}),t.jsxs("li",{children:["Sorting: ",es(e.sortStack)]}),t.jsx("li",{children:"Column order & visibility"})]})]}),!i&&t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{checked:b,onChange:T=>g(T.target.checked),size:"small"}),label:t.jsx(o.Typography,{variant:"body2",children:"Set as default view"})})]})}),t.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid #e8eaed",bgcolor:"#f8f9fa",gap:1.25,justifyContent:"flex-end"},children:[t.jsx(o.Button,{onClick:n,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"#5f6368",px:3,py:.875,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"#e8eaed",color:"#202124"}},children:"Cancel"}),t.jsx(o.Button,{onClick:v,disabled:!d.trim(),variant:"contained",startIcon:t.jsx(w.Save,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#1967d2",color:"#ffffff",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#1557b0",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"#e8eaed",color:"#bdc1c6"}},children:i?"Save Changes":"Create Report View"})]})]})}function Ac({viewName:e,onConfirm:r,onCancel:n}){return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{mt:8,borderRadius:"12px",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:["Delete View",t.jsx(o.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:t.jsx(w.Close,{sx:{fontSize:20}})})]}),t.jsx(o.DialogContent,{children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.5,mt:1},children:[t.jsx(w.Warning,{color:"error",sx:{fontSize:20,flexShrink:0}}),t.jsxs(o.Box,{children:[t.jsxs(o.Typography,{variant:"body2",sx:{mb:1},children:["Are you sure you want to delete the view ",t.jsxs("strong",{children:['"',e,'"']}),"?"]}),t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"This action cannot be undone."})]})]})}),t.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid #e8eaed",bgcolor:"#f8f9fa",gap:1.25,justifyContent:"flex-end"},children:[t.jsx(o.Button,{onClick:n,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"#5f6368",px:3,py:.875,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"#e8eaed",color:"#202124"}},children:"Cancel"}),t.jsx(o.Button,{onClick:r,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#d93025",color:"#ffffff",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#b3190e",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Delete View"})]})]})}const Gn=80,Yn=600,mn="COLUMN";function Rc({column:e,index:r,isVisible:n,width:i,onToggleVisibility:a,onWidthChange:l,moveColumn:c}){const d=u.useRef(null),[f,x]=u.useState(i.toString()),[{handlerId:m},b]=dt.useDrop({accept:mn,collect(s){return{handlerId:s.getHandlerId()}},hover(s,k){var K;if(!d.current)return;const D=s.index,A=r;if(D===A)return;const S=(K=d.current)==null?void 0:K.getBoundingClientRect(),R=(S.bottom-S.top)/2,Y=k.getClientOffset(),_=((Y==null?void 0:Y.y)??0)-S.top;D<A&&_<R||D>A&&_>R||(c(D,A),s.index=A)}}),[{isDragging:g},v]=dt.useDrag({type:mn,item:()=>({index:r}),collect:s=>({isDragging:s.isDragging()})});v(b(d));const C=()=>{const s=parseInt(f);if(isNaN(s)){x(i.toString());return}const k=Math.max(Gn,Math.min(Yn,s));x(k.toString()),l(e.name,k)},p=s=>{(s===""||/^\d+$/.test(s))&&x(s)},T=s=>({string:"#1967d2",number:"#188038",boolean:"#9334e6",array:"#ea8600",object:"#d93025",null:"#5f6368",mixed:"#5f6368"})[s]||"#5f6368";return t.jsxs(o.TableRow,{ref:d,"data-handler-id":m,sx:{opacity:g?.4:1,bgcolor:n?"#ffffff":"#f8f9fa",transition:"all 0.2s ease","&:hover":{bgcolor:n?"#f8f9fa":"#f1f3f4"},cursor:"move",height:56,borderBottom:"1px solid #e8eaed"},children:[t.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[t.jsx(o.Box,{sx:{color:"#5f6368",cursor:"grab",opacity:.6,transition:"opacity 0.2s ease","&:hover":{opacity:1},"&:active":{cursor:"grabbing"}},children:t.jsx(w.DragIndicator,{sx:{fontSize:20}})}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:400,fontSize:"0.875rem",color:n?"#3c4043":"#5f6368"},children:Ct(e.name)})]})}),t.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsx(o.Chip,{label:e.type.toUpperCase(),size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:600,bgcolor:`${T(e.type)}15`,color:T(e.type),border:`1px solid ${T(e.type)}30`,"& .MuiChip-label":{px:1}}})}),t.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.TextField,{type:"text",value:f,onChange:s=>p(s.target.value),onBlur:C,placeholder:"150",size:"small",sx:{width:80,"& .MuiOutlinedInput-root":{height:32,fontSize:"0.8125rem",borderRadius:"4px",bgcolor:"#ffffff","& fieldset":{borderColor:"#dadce0"},"&:hover fieldset":{borderColor:"#1967d2"},"&.Mui-focused fieldset":{borderColor:"#1967d2",borderWidth:"2px"}},"& .MuiInputBase-input":{py:.5,px:1.25,color:"#3c4043"}}}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"#5f6368"},children:"px"})]})}),t.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[t.jsx(o.IconButton,{onClick:()=>a(e.name,!n),title:n?"Hide column":"Show column",size:"small",sx:{p:.75,color:n?"#1967d2":"#5f6368",transition:"all 0.2s ease","&:hover":{bgcolor:"#f1f3f4",color:n?"#1557b0":"#1967d2"}},children:n?t.jsx(w.Visibility,{sx:{fontSize:20}}):t.jsx(w.VisibilityOff,{sx:{fontSize:20}})}),t.jsx(o.Chip,{label:n?"Visible":"Hidden",size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:500,bgcolor:n?"#e6f4ea":"#f1f3f4",color:n?"#188038":"#5f6368","& .MuiChip-label":{px:1}}})]})})]})}function Mc({schema:e,columnVisibility:r,columnOrder:n,columnWidths:i={},views:a=[],activeViewId:l="",onUpdateColumnVisibility:c,onUpdateColumnOrder:d,onUpdateColumnWidth:f,onResetLayout:x,onSaveToCurrentView:m,onSaveToAllViews:b,onSelectView:g,onClose:v}){const[C,p]=u.useState(!1),[T,s]=u.useState(n),[k,D]=u.useState("all"),[A,S]=u.useState(null),R=(E,H)=>{const de=[...T],[ue]=de.splice(E,1);de.splice(H,0,ue),s(de),d(de)},Y=()=>{x(),p(!1)},K=T.map(E=>e.find(H=>H.name===E)).filter(E=>E!==void 0).filter(E=>{const H=r[E.name]??!0;return k==="active"?H:k==="hidden"?!H:!0}),V=Object.values(r).filter(E=>E).length,te=e.length,h=a.find(E=>E.id===l),F=a.filter(E=>!E.isDeleted),W=u.useMemo(()=>{if(!h)return!1;const E=h.snapshot,H=JSON.stringify(r)!==JSON.stringify(E.columnVisibility),de=JSON.stringify(n)!==JSON.stringify(E.columnOrder),ue=JSON.stringify(i)!==JSON.stringify(E.columnWidths);return H||de||ue},[h,r,n,i]);return t.jsx(dt.DndProvider,{backend:io.HTML5Backend,children:t.jsx(o.Box,{onClick:v,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:E=>E.stopPropagation(),elevation:0,sx:{position:"relative",width:720,maxWidth:"calc(100vw - 120px)",maxHeight:"min(760px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"#ffffff",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2,pb:1.5,borderBottom:"1px solid #e8eaed",flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",mb:1.5},children:[t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"#202124",letterSpacing:"0",lineHeight:1.5},children:"Manage columns"}),t.jsxs(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"#5f6368",mt:.5},children:[V," of ",te," columns visible • Drag to reorder"]})]}),F.length>0&&g&&t.jsxs(o.Box,{sx:{ml:2},children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.6875rem",color:"#5f6368",mb:.75,display:"block",textTransform:"uppercase",fontWeight:600,letterSpacing:"0.1em"},children:"View:"}),t.jsx(o.Button,{onClick:E=>S(E.currentTarget),variant:"outlined",size:"small",endIcon:t.jsx(w.KeyboardArrowDown,{sx:{fontSize:18}}),sx:{minWidth:180,justifyContent:"space-between",textTransform:"none",fontSize:"0.875rem",fontWeight:400,color:"#3c4043",borderColor:"#dadce0",py:.75,px:1.5,"&:hover":{borderColor:"#1967d2",bgcolor:"#f8f9fa"}},children:t.jsx(o.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis"},children:(h==null?void 0:h.name)||"Select View"})}),t.jsx(o.Menu,{anchorEl:A,open:!!A,onClose:()=>S(null),PaperProps:{sx:{mt:.5,borderRadius:"8px",boxShadow:"0 2px 6px rgba(60, 64, 67, 0.15)"}},children:F.map(E=>t.jsx(o.MenuItem,{onClick:()=>{g(E.id),S(null)},selected:E.id===l,sx:{fontSize:"0.875rem",color:"#3c4043",py:1,px:2,"&:hover":{bgcolor:"#f1f3f4"},"&.Mui-selected":{bgcolor:"#e8f0fe","&:hover":{bgcolor:"#d2e3fc"}}},children:E.name},E.id))})]}),t.jsx(o.IconButton,{onClick:v,size:"small",sx:{ml:2,p:.75,color:"#5f6368",transition:"all 0.2s ease","&:hover":{bgcolor:"#f1f3f4",color:"#202124"}},children:t.jsx(w.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.Tabs,{value:k,onChange:(E,H)=>D(H),sx:{minHeight:36,mt:.5,"& .MuiTabs-indicator":{bgcolor:"#1967d2",height:3}},children:[t.jsx(o.Tab,{label:"All",value:"all",sx:{minHeight:36,py:.75,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"#5f6368","&.Mui-selected":{color:"#1967d2"}}}),t.jsx(o.Tab,{label:"Visible",value:"active",sx:{minHeight:36,py:.75,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"#5f6368","&.Mui-selected":{color:"#1967d2"}}}),t.jsx(o.Tab,{label:"Hidden",value:"hidden",sx:{minHeight:36,py:.75,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"#5f6368","&.Mui-selected":{color:"#1967d2"}}})]})]}),t.jsx(o.Box,{sx:{flex:1,overflow:"auto","&::-webkit-scrollbar":{width:8,height:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"#dadce0",borderRadius:4,"&:hover":{bgcolor:"#bdc1c6"}}},children:t.jsxs(o.Table,{stickyHeader:!0,sx:{minWidth:650},children:[t.jsx(o.TableHead,{children:t.jsxs(o.TableRow,{children:[t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"0.6875rem",color:"#5f6368",bgcolor:"#f8f9fa",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid #e8eaed"},children:"Column name"}),t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"0.6875rem",color:"#5f6368",bgcolor:"#f8f9fa",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid #e8eaed"},children:"Type"}),t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"0.6875rem",color:"#5f6368",bgcolor:"#f8f9fa",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid #e8eaed"},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:["Width",t.jsx(o.Tooltip,{title:`Column width in pixels (min: ${Gn}px, max: ${Yn}px)`,arrow:!0,placement:"top",children:t.jsx(w.InfoOutlined,{sx:{fontSize:14,color:"#5f6368",cursor:"help"}})})]})}),t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"0.6875rem",color:"#5f6368",bgcolor:"#f8f9fa",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid #e8eaed"},children:"Visibility"})]})}),t.jsx(o.TableBody,{children:K.length===0?t.jsx(o.TableRow,{children:t.jsx(o.TableCell,{colSpan:4,align:"center",sx:{py:6,borderBottom:"none"},children:t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"#5f6368"},children:"No columns in this category"})})}):K.map((E,H)=>t.jsx(Rc,{column:E,index:H,isVisible:r[E.name]??!0,width:i[E.name]||150,onToggleVisibility:c,onWidthChange:f||(()=>{}),moveColumn:R},E.name))})]})}),t.jsxs(o.Box,{sx:{px:3,py:1.75,borderTop:"1px solid #e8eaed",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0,bgcolor:"#f8f9fa"},children:[t.jsx(o.Button,{onClick:()=>p(!0),disabled:!W,variant:"outlined",startIcon:t.jsx(w.Undo,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"#5f6368",borderColor:"#dadce0",px:2.5,py:.875,minHeight:36,borderRadius:"4px","&:hover":{borderColor:"#1967d2",bgcolor:"#ffffff",color:"#1967d2"},"&.Mui-disabled":{color:"#bdc1c6",borderColor:"#e8eaed"}},children:"Reset to default"}),t.jsxs(o.Stack,{direction:"row",spacing:1.25,children:[m&&t.jsx(o.Button,{onClick:()=>{m(),v()},disabled:!W,variant:"contained",startIcon:t.jsx(w.Save,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#1967d2",color:"#ffffff",px:2.5,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#1557b0",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"#e8eaed",color:"#bdc1c6"}},children:"Save to current view"}),b&&t.jsx(o.Button,{onClick:()=>{b(),v()},disabled:!W,variant:"contained",startIcon:t.jsx(w.GridView,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#188038",color:"#ffffff",px:2.5,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#0d652d",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"#e8eaed",color:"#bdc1c6"}},children:"Save to all views"})]})]}),C&&t.jsx(o.Box,{onClick:()=>p(!1),sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1400},children:t.jsxs(o.Paper,{onClick:E=>E.stopPropagation(),elevation:0,sx:{width:400,maxWidth:"90vw",borderRadius:"12px",bgcolor:"#ffffff",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"},children:[t.jsxs(o.Box,{sx:{px:3,py:2.5},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1rem",fontWeight:500,color:"#202124",mb:1.5},children:"Reset column layout?"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"#5f6368",lineHeight:1.5},children:"This will restore default visibility, order, and widths for all columns."})]}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid #e8eaed",display:"flex",gap:1.5,justifyContent:"flex-end",bgcolor:"#f8f9fa"},children:[t.jsx(o.Button,{onClick:()=>p(!1),variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"#5f6368",px:3,py:1,borderRadius:"4px","&:hover":{bgcolor:"#e8eaed",color:"#202124"}},children:"Cancel"}),t.jsx(o.Button,{onClick:Y,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#d93025",color:"#ffffff",px:3,py:1,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)","&:hover":{bgcolor:"#b3190e",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Reset layout"})]})]})})]})})})}function Pc({schema:e,grouping:r,onApply:n,onClose:i}){var S;const[a,l]=u.useState(r||{enabled:!1,levels:[],collapsedGroups:[]}),[c,d]=u.useState(""),[f,x]=u.useState(null),m=u.useMemo(()=>Gi(e),[e]),b=u.useMemo(()=>m.filter(R=>!a.levels.some((Y,_)=>Y.column===R.name&&_!==f)),[m,a.levels,f]),g=a.levels.length<3&&b.length>0,v=u.useCallback(()=>{!g||!c||(l({...a,levels:[...a.levels,{column:c}],enabled:!0}),d(""))},[g,c,a]),C=u.useCallback(R=>{const Y=a.levels.filter((_,K)=>K!==R);if(Y.length===0){n(null),i();return}l({...a,levels:Y,enabled:Y.length>0})},[a,n,i]),p=u.useCallback(R=>{x(R),d(a.levels[R].column)},[a.levels]),T=u.useCallback(()=>{if(f===null||!c)return;const R=[...a.levels];R[f]={column:c},l({...a,levels:R}),x(null),d("")},[f,c,a]),s=u.useCallback(()=>{x(null),d("")},[]),k=u.useCallback((R,Y)=>{const _=Y==="up"?R-1:R+1;if(_<0||_>=a.levels.length)return;const K=[...a.levels],[V]=K.splice(R,1);K.splice(_,0,V),l({...a,levels:K})},[a]),D=u.useCallback(()=>{n(null),i()},[n,i]),A=u.useCallback(()=>{a.levels.length===0?n(null):n({...a,enabled:!0,collapsedGroups:(r==null?void 0:r.collapsedGroups)||[]}),i()},[a,r,n,i]);return t.jsx(o.Box,{onClick:i,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:R=>R.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(560px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"#ffffff",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid #e8eaed",flexShrink:0},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"#202124",letterSpacing:"0",lineHeight:1.5},children:"Group configuration"}),t.jsx(o.IconButton,{onClick:i,size:"small",sx:{p:.75,color:"#5f6368",transition:"all 0.2s ease","&:hover":{bgcolor:"#f1f3f4",color:"#202124"}},children:t.jsx(w.Close,{sx:{fontSize:20}})})]}),t.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"#dadce0",borderRadius:4,"&:hover":{bgcolor:"#bdc1c6"}}},children:t.jsxs(o.Stack,{spacing:2.5,children:[f===null&&t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"#5f6368",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add group level"}),t.jsx(o.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:t.jsxs(o.Select,{value:c,onChange:R=>d(R.target.value),disabled:!g,displayEmpty:!0,sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"#ffffff","& .MuiOutlinedInput-notchedOutline":{borderColor:"#dadce0",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"#1967d2"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"#1967d2",borderWidth:"2px"},"&.Mui-disabled":{bgcolor:"#f8f9fa"}},children:[t.jsx(o.MenuItem,{value:"",sx:{fontSize:"0.875rem",color:"#5f6368"},children:"Select a column..."}),b.map(R=>t.jsxs(o.MenuItem,{value:R.name,sx:{fontSize:"0.875rem",color:"#3c4043",py:1,"&:hover":{bgcolor:"#f1f3f4"},"&.Mui-selected":{bgcolor:"#e8f0fe","&:hover":{bgcolor:"#d2e3fc"}}},children:[Ct(R.name)," (",R.type.toUpperCase(),")"]},R.name))]})}),t.jsx(o.Button,{onClick:v,disabled:!g||!c,variant:"outlined",startIcon:t.jsx(w.Add,{sx:{fontSize:18}}),fullWidth:!0,sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"#1967d2",borderColor:"#dadce0",py:1,transition:"all 0.2s ease","&:hover":{borderColor:"#1967d2",bgcolor:"#f8f9fa"},"&.Mui-disabled":{color:"#bdc1c6",borderColor:"#e8eaed"}},children:"Add group level"}),a.levels.length===3&&t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",textAlign:"center",mt:1.5,fontSize:"0.75rem",color:"#5f6368"},children:"Maximum group levels (3) reached"}),m.length===0&&t.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{textAlign:"center",py:2,fontSize:"0.875rem",color:"#5f6368"},children:"No groupable columns available. Only STRING and BOOLEAN columns can be grouped."})]}),f!==null&&t.jsxs(o.Alert,{severity:"warning",sx:{borderRadius:"8px",border:"1px solid #fdd663",bgcolor:"#fef7e0","& .MuiAlert-icon":{color:"#ea8600"}},children:[t.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:500,mb:1.5,fontSize:"0.875rem",color:"#3c4043"},children:["Edit Group Level ",f+1]}),t.jsx(o.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:t.jsxs(o.Select,{value:c,onChange:R=>d(R.target.value),sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"#ffffff","& .MuiOutlinedInput-notchedOutline":{borderColor:"#dadce0"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"#1967d2"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"#1967d2",borderWidth:"2px"}},children:[t.jsx(o.MenuItem,{value:"",sx:{fontSize:"0.875rem"},children:"Select a column..."}),t.jsxs(o.MenuItem,{value:a.levels[f].column,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:"#e8f0fe"}},children:[a.levels[f].column," (",(S=e.find(R=>R.name===a.levels[f].column))==null?void 0:S.type.toUpperCase(),")"]}),b.filter(R=>R.name!==a.levels[f].column).map(R=>t.jsxs(o.MenuItem,{value:R.name,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:"#e8f0fe"}},children:[Ct(R.name)," (",R.type.toUpperCase(),")"]},R.name))]})}),t.jsxs(o.Stack,{direction:"row",spacing:1.5,children:[t.jsx(o.Button,{onClick:T,disabled:!c,variant:"contained",fullWidth:!0,size:"small",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#ea8600",color:"#ffffff",py:.875,boxShadow:"none","&:hover":{bgcolor:"#c96e00",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)"}},children:"Save"}),t.jsx(o.Button,{onClick:s,variant:"outlined",fullWidth:!0,size:"small",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"#5f6368",borderColor:"#dadce0",py:.875,"&:hover":{borderColor:"#bdc1c6",bgcolor:"#f8f9fa"}},children:"Cancel"})]})]}),a.levels.length>0&&f===null&&t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1.5},children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"#5f6368",letterSpacing:"0.1em",textTransform:"uppercase"},children:"Active group levels"}),t.jsx(o.Button,{onClick:D,size:"small",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"#d93025",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",color:"#b3190e",textDecoration:"underline"}},children:"Clear all"})]}),t.jsx(o.Stack,{spacing:1.5,children:a.levels.map((R,Y)=>{const _=e.find(K=>K.name===R.column);return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,p:2,borderRadius:"8px",bgcolor:"#ffffff",border:"1px solid #e8eaed",transition:"all 0.2s ease","&:hover":{bgcolor:"#f8f9fa",borderColor:"#dadce0",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.1)"}},children:[t.jsx(o.Chip,{label:`L${Y+1}`,size:"small",sx:{width:40,height:28,fontWeight:600,fontSize:"0.75rem",bgcolor:"#1967d2",color:"#ffffff",boxShadow:"0 1px 2px 0 rgba(25, 103, 210, 0.3)"}}),t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:R.column}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"#5f6368"},children:_==null?void 0:_.type.toUpperCase()})]}),t.jsxs(o.Stack,{direction:"row",spacing:.5,children:[t.jsx(o.IconButton,{size:"small",onClick:()=>k(Y,"up"),disabled:Y===0,sx:{color:"#5f6368","&:hover":{bgcolor:"#f1f3f4"},"&.Mui-disabled":{color:"#e8eaed"}},children:t.jsx(w.KeyboardArrowUp,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{size:"small",onClick:()=>k(Y,"down"),disabled:Y===a.levels.length-1,sx:{color:"#5f6368","&:hover":{bgcolor:"#f1f3f4"},"&.Mui-disabled":{color:"#e8eaed"}},children:t.jsx(w.KeyboardArrowDown,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{size:"small",onClick:()=>p(Y),sx:{color:"#5f6368","&:hover":{bgcolor:"#f1f3f4",color:"#1967d2"}},children:t.jsx(w.Edit,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{size:"small",onClick:()=>C(Y),sx:{color:"#5f6368","&:hover":{bgcolor:"rgba(217, 48, 37, 0.08)",color:"#d93025"}},children:t.jsx(w.Delete,{sx:{fontSize:18}})})]})]},Y)})})]})]})}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid #e8eaed",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"#f8f9fa"},children:[t.jsx(o.Button,{onClick:i,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"#5f6368",px:3,py:1,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"#e8eaed",color:"#202124"}},children:"Cancel"}),t.jsx(o.Button,{onClick:A,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#1967d2",color:"#ffffff",px:3,py:1,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#1557b0",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Apply grouping"})]})]})})}const Wc={filters:w.FilterList,sorting:w.UnfoldMore,visibility:w.Visibility,order:w.ViewColumn,widths:w.Straighten,grouping:w.Layers};function _c({changes:e,onClose:r}){const n=i=>({filters:"primary",sorting:"secondary",visibility:"success",order:"warning",widths:"info",grouping:"error"})[i]||"default";return t.jsxs(o.Dialog,{open:!0,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{mt:8,borderRadius:"12px",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:["View Changes Summary",t.jsx(o.IconButton,{onClick:r,size:"small",sx:{color:"text.secondary"},children:t.jsx(w.Close,{sx:{fontSize:20}})})]}),t.jsx(o.DialogContent,{dividers:!0,children:e.length===0?t.jsx(o.Box,{sx:{textAlign:"center",py:4},children:t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"No changes detected"})}):t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"The following modifications have been made to this view:"}),t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.5},children:e.map((i,a)=>{const l=Wc[i.category];return t.jsxs(o.Paper,{elevation:0,sx:{display:"flex",gap:1.5,p:1.5,border:1,borderColor:"divider",borderRadius:1},children:[t.jsx(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:1,bgcolor:`${n(i.category)}.lighter`,color:`${n(i.category)}.main`,flexShrink:0},children:t.jsx(l,{sx:{fontSize:16}})}),t.jsxs(o.Box,{sx:{flex:1,minWidth:0},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500},children:i.label}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:i.description})]})]},a)})})]})}),t.jsx(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid #e8eaed",bgcolor:"#f8f9fa",gap:1.25,justifyContent:"flex-end"},children:t.jsx(o.Button,{onClick:r,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#1967d2",color:"#ffffff",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#1557b0",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Close"})})]})}function $c({viewName:e,isDefaultView:r,changes:n=[],onSaveToCurrentView:i,onSaveAsNewView:a,onCancel:l}){const[c,d]=u.useState(!1);return t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{width:"100%",flexShrink:0,bgcolor:"#e8f0fe",borderBottom:"1px solid #d3e3fd",zIndex:10},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:1.25},children:[t.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:400,fontSize:"0.875rem",color:"#3c4043"},children:['Unsaved changes to "',e,'"']}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Button,{onClick:l,variant:"text",size:"small",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2,py:.625,borderRadius:"18px",color:"#5f6368",bgcolor:"transparent",minHeight:32,"&:hover":{bgcolor:"rgba(60, 64, 67, 0.08)",color:"#202124"}},children:"Discard"}),t.jsx(o.Button,{onClick:a,variant:"contained",size:"small",disableElevation:!0,sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2.5,py:.625,borderRadius:"18px",bgcolor:"#0b57d0",color:"#fff",minHeight:32,boxShadow:"none","&:hover":{bgcolor:"#0842a0",boxShadow:"0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px rgba(60, 64, 67, 0.15)"}},children:"Save as new view"})]})]})}),c&&t.jsx(_c,{changes:n,onClose:()=>d(!1)})]})}function Fc({onExportAnyway:e,onSaveAndExport:r,onCancel:n}){return t.jsx(o.Box,{sx:{mb:2,mx:3,mt:2},children:t.jsxs(o.Alert,{severity:"warning",icon:t.jsx(w.Warning,{sx:{fontSize:20}}),action:t.jsx(o.IconButton,{size:"small",onClick:n,sx:{color:"warning.main"},children:t.jsx(w.Close,{sx:{fontSize:20}})}),sx:{alignItems:"flex-start"},children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:600,mb:.5},children:"You are exporting with unsaved view changes"}),t.jsx(o.Typography,{variant:"body2",sx:{mb:1.5},children:"Your current view has unsaved changes. Choose how to proceed:"}),t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Button,{onClick:r,variant:"contained",color:"primary",startIcon:t.jsx(w.Save,{sx:{fontSize:14}}),size:"small",children:"Save View & Export"}),t.jsx(o.Button,{onClick:e,variant:"contained",color:"warning",startIcon:t.jsx(w.Download,{sx:{fontSize:14}}),size:"small",children:"Export Anyway"})]})]})})}function Vc({auditHistory:e,onClose:r}){const[n,i]=u.useState(new Set),a=c=>{i(d=>{const f=new Set(d);return f.has(c)?f.delete(c):f.add(c),f})},l=[...e].sort((c,d)=>new Date(d.timestamp).getTime()-new Date(c.timestamp).getTime());return t.jsx(o.Box,{onClick:r,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:c=>c.stopPropagation(),elevation:0,sx:{position:"relative",width:680,maxWidth:"calc(100vw - 120px)",maxHeight:"min(720px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"#ffffff",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid #e8eaed",flexShrink:0},children:[t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"#202124",letterSpacing:"0",lineHeight:1.5},children:"Audit history"}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"#5f6368",mt:.5,display:"block"},children:[l.length," event",l.length!==1?"s":""," recorded"]})]}),t.jsx(o.IconButton,{onClick:r,size:"small",sx:{p:.75,color:"#5f6368",transition:"all 0.2s ease","&:hover":{bgcolor:"#f1f3f4",color:"#202124"}},children:t.jsx(w.Close,{sx:{fontSize:20}})})]}),t.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"#dadce0",borderRadius:4,"&:hover":{bgcolor:"#bdc1c6"}}},children:l.length===0?t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8,textAlign:"center"},children:[t.jsx(w.AccessTime,{sx:{fontSize:64,color:"#e8eaed",mb:2}}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"#5f6368",mb:.5},children:"No audit events recorded yet"}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"#bdc1c6"},children:"Changes to this report will appear here"})]}):t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.5},children:l.map(c=>{const d=n.has(c.id),f=hs(c.feature);return t.jsxs(o.Paper,{elevation:0,sx:{border:"1px solid #e8eaed",borderRadius:"8px",overflow:"hidden",transition:"all 0.2s ease","&:hover":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.1)",borderColor:"#dadce0"}},children:[t.jsxs(o.Box,{onClick:()=>a(c.id),sx:{px:2.5,py:1.75,display:"flex",alignItems:"center",gap:1.5,cursor:"pointer",bgcolor:"#ffffff",transition:"background-color 0.2s ease","&:hover":{bgcolor:"#f8f9fa"}},children:[t.jsx(o.Box,{sx:{flexShrink:0,color:"#5f6368",transition:"transform 0.2s ease",transform:"rotate(0deg)"},children:d?t.jsx(w.KeyboardArrowDown,{sx:{fontSize:20}}):t.jsx(w.ChevronRight,{sx:{fontSize:20}})}),t.jsx(o.Chip,{label:xs(c.feature),size:"small",sx:{height:24,fontSize:"0.6875rem",fontWeight:600,bgcolor:`${f}15`,color:f,border:`1px solid ${f}30`,"& .MuiChip-label":{px:1}}}),t.jsx(o.Typography,{variant:"body2",sx:{flex:1,fontWeight:400,fontSize:"0.875rem",color:"#3c4043"},children:ps(c.action)}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,flexShrink:0},children:[t.jsx(w.AccessTime,{sx:{fontSize:16,color:"#5f6368",opacity:.6}}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"#5f6368"},children:ms(c.timestamp)})]}),c.user&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,flexShrink:0},children:[t.jsx(w.Person,{sx:{fontSize:16,color:"#5f6368",opacity:.6}}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"#5f6368"},children:c.user})]})]}),t.jsx(o.Collapse,{in:d,timeout:200,children:t.jsxs(o.Box,{sx:{px:2.5,pb:2,pt:1.5,borderTop:"1px solid #e8eaed",bgcolor:"#f8f9fa"},children:[c.previousState&&t.jsxs(o.Box,{sx:{mb:2},children:[t.jsx(o.Typography,{variant:"caption",sx:{fontWeight:600,fontSize:"0.6875rem",color:"#5f6368",textTransform:"uppercase",letterSpacing:"0.1em",mb:1,display:"block"},children:"Previous state"}),t.jsx(o.Box,{component:"pre",sx:{fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Courier New", monospace',bgcolor:"#ffffff",border:"1px solid #dadce0",borderRadius:"4px",p:1.5,overflow:"auto",maxHeight:200,color:"#3c4043",lineHeight:1.6,"&::-webkit-scrollbar":{width:6,height:6},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"#dadce0",borderRadius:3}},children:Io(c.previousState)})]}),c.newState&&t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontWeight:600,fontSize:"0.6875rem",color:"#5f6368",textTransform:"uppercase",letterSpacing:"0.1em",mb:1,display:"block"},children:"New state"}),t.jsx(o.Box,{component:"pre",sx:{fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Courier New", monospace',bgcolor:"#ffffff",border:"1px solid #dadce0",borderRadius:"4px",p:1.5,overflow:"auto",maxHeight:200,color:"#3c4043",lineHeight:1.6,"&::-webkit-scrollbar":{width:6,height:6},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"#dadce0",borderRadius:3}},children:Io(c.newState)})]})]})})]},c.id)})})})]})})}function Nc({onSave:e,onClose:r}){const[n,i]=u.useState(""),[a,l]=u.useState(""),[c,d]=u.useState(""),[f,x]=u.useState([]),[m,b]=u.useState(""),[g,v]=u.useState(""),C=S=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(S),p=()=>{const S=c.trim();if(S){if(!C(S)){v("Please enter a valid email address");return}if(f.includes(S)){v("This email is already added");return}x([...f,S]),d(""),v("")}},T=S=>{x(f.filter(R=>R!==S))},s=S=>{S.key==="Enter"&&(S.preventDefault(),p())},k=()=>{if(!n.trim()){b("Preset name is required");return}e(n.trim(),a.trim(),f.length>0?f:void 0)},D=S=>{i(S),m&&b("")},A=S=>{d(S),g&&v("")};return t.jsx(o.Box,{onClick:r,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:S=>S.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(480px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"#ffffff",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid #e8eaed",flexShrink:0},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"#202124",letterSpacing:"0",lineHeight:1.5},children:"Create shareable preset"}),t.jsx(o.IconButton,{onClick:r,size:"small",sx:{p:.75,color:"#5f6368",transition:"all 0.2s ease","&:hover":{bgcolor:"#f1f3f4",color:"#202124"}},children:t.jsx(w.Close,{sx:{fontSize:20}})})]}),t.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"#dadce0",borderRadius:4,"&:hover":{bgcolor:"#bdc1c6"}}},children:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[t.jsx(o.Alert,{severity:"info",icon:t.jsx(w.Info,{sx:{fontSize:20}}),sx:{borderRadius:"8px",border:"1px solid #d2e3fc",bgcolor:"#e8f0fe","& .MuiAlert-icon":{color:"#1967d2"},"& .MuiAlert-message":{fontSize:"0.8125rem",color:"#3c4043",lineHeight:1.5}},children:"This preset will capture filters, sorting, grouping, column configuration, and the active view. The actual data is not saved or shared."}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"#5f6368",lineHeight:1.6},children:"Save the current report configuration and generate a shareable link that others can use to view the same filters, sorting, and column layout."}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.6875rem",fontWeight:600,color:"#5f6368",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Preset name *"}),t.jsx(o.TextField,{required:!0,value:n,onChange:S=>D(S.target.value),placeholder:"e.g., Q4 Active Users Report",error:!!m,helperText:m,autoFocus:!0,fullWidth:!0,size:"small",sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"#ffffff","& fieldset":{borderColor:"#dadce0"},"&:hover fieldset":{borderColor:"#1967d2"},"&.Mui-focused fieldset":{borderColor:"#1967d2",borderWidth:"2px"},"&.Mui-error fieldset":{borderColor:"#d93025"}},"& .MuiInputBase-input":{py:1.25,color:"#3c4043"},"& .MuiFormHelperText-root":{fontSize:"0.75rem",color:"#d93025",mt:.75}}})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.6875rem",fontWeight:600,color:"#5f6368",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Description (optional)"}),t.jsx(o.TextField,{value:a,onChange:S=>l(S.target.value),placeholder:"Briefly describe what this preset shows...",multiline:!0,rows:3,fullWidth:!0,size:"small",sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"#ffffff","& fieldset":{borderColor:"#dadce0"},"&:hover fieldset":{borderColor:"#1967d2"},"&.Mui-focused fieldset":{borderColor:"#1967d2",borderWidth:"2px"}},"& .MuiInputBase-input":{py:1.25,color:"#3c4043",lineHeight:1.6}}})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.6875rem",fontWeight:600,color:"#5f6368",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Share with (optional)"}),t.jsxs(o.Box,{sx:{display:"flex",gap:1,alignItems:"flex-start"},children:[t.jsx(o.TextField,{value:c,onChange:S=>A(S.target.value),onKeyPress:s,placeholder:"Enter email address",error:!!g,helperText:g,fullWidth:!0,size:"small",InputProps:{startAdornment:t.jsx(w.Email,{sx:{fontSize:18,color:"#5f6368",mr:1}})},sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"#ffffff","& fieldset":{borderColor:"#dadce0"},"&:hover fieldset":{borderColor:"#1967d2"},"&.Mui-focused fieldset":{borderColor:"#1967d2",borderWidth:"2px"},"&.Mui-error fieldset":{borderColor:"#d93025"}},"& .MuiInputBase-input":{py:1.25,color:"#3c4043"},"& .MuiFormHelperText-root":{fontSize:"0.75rem",color:"#d93025",mt:.75}}}),t.jsx(o.Button,{onClick:p,variant:"outlined",startIcon:t.jsx(w.Add,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"#1967d2",borderColor:"#dadce0",px:2,py:1.25,minHeight:40,borderRadius:"4px",flexShrink:0,"&:hover":{borderColor:"#1967d2",bgcolor:"#f8f9fa"}},children:"Add"})]}),f.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1,mt:1.5},children:f.map(S=>t.jsx(o.Chip,{label:S,onDelete:()=>T(S),deleteIcon:t.jsx(w.Delete,{sx:{fontSize:16}}),sx:{bgcolor:"#e8f0fe",color:"#1967d2",fontSize:"0.8125rem",height:28,"& .MuiChip-deleteIcon":{color:"#1967d2","&:hover":{color:"#1557b0"}}}},S))}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"#5f6368",mt:1,display:"block",lineHeight:1.5},children:f.length>0?`An email with the shareable link will be sent to ${f.length} recipient${f.length>1?"s":""}`:"Add email addresses to send the shareable link automatically"})]})]})}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid #e8eaed",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"#f8f9fa"},children:[t.jsx(o.Button,{onClick:r,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"#5f6368",px:3,py:1,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"#e8eaed",color:"#202124"}},children:"Cancel"}),t.jsx(o.Button,{onClick:k,variant:"contained",startIcon:t.jsx(w.Share,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#1967d2",color:"#ffffff",px:3,py:1,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#1557b0",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Create & share"})]})]})})}function Lc({presetName:e,shareUrl:r,onCopyLink:n,onOpenPreset:i,onDeletePreset:a,onClose:l}){const[c,d]=u.useState(!1),f=()=>{n(),d(!0),setTimeout(()=>d(!1),2e3)};return t.jsx(o.Box,{onClick:l,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:x=>x.stopPropagation(),elevation:0,sx:{position:"relative",width:580,maxWidth:"calc(100vw - 120px)",maxHeight:"min(480px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"#ffffff",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid #e8eaed",flexShrink:0},children:[t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"#202124",letterSpacing:"0",lineHeight:1.5},children:"Shareable link generated"}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"#5f6368",mt:.5,display:"block"},children:["Preset: ",e]})]}),t.jsx(o.IconButton,{onClick:l,size:"small",sx:{p:.75,color:"#5f6368",transition:"all 0.2s ease","&:hover":{bgcolor:"#f1f3f4",color:"#202124"}},children:t.jsx(w.Close,{sx:{fontSize:20}})})]}),t.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"#dadce0",borderRadius:4,"&:hover":{bgcolor:"#bdc1c6"}}},children:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[t.jsxs(o.Alert,{severity:"success",icon:t.jsx(w.Check,{sx:{fontSize:20}}),sx:{borderRadius:"8px",border:"1px solid #ceead6",bgcolor:"#e6f4ea","& .MuiAlert-icon":{color:"#188038"},"& .MuiAlert-message":{fontSize:"0.875rem",color:"#3c4043"}},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043",mb:.5},children:"Preset created successfully!"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"#5f6368",lineHeight:1.5},children:"Share the link below with anyone who needs access to this report configuration."})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.6875rem",fontWeight:600,color:"#5f6368",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Shareable URL"}),t.jsxs(o.Box,{sx:{display:"flex",gap:1.5},children:[t.jsx(o.TextField,{value:r,size:"small",fullWidth:!0,InputProps:{readOnly:!0},onClick:x=>x.target.select(),sx:{"& .MuiOutlinedInput-root":{fontSize:"0.8125rem",borderRadius:"4px",bgcolor:"#f8f9fa",fontFamily:'"Roboto Mono", "Courier New", monospace',"& fieldset":{borderColor:"#dadce0"},"&:hover fieldset":{borderColor:"#1967d2"},"&.Mui-focused fieldset":{borderColor:"#1967d2",borderWidth:"2px"}},"& .MuiInputBase-input":{py:1.25,color:"#1967d2",cursor:"pointer"}}}),t.jsx(o.Button,{onClick:f,variant:"contained",startIcon:c?t.jsx(w.Check,{sx:{fontSize:18}}):t.jsx(w.ContentCopy,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:c?"#188038":"#1967d2",color:"#ffffff",px:3,py:1.25,minWidth:110,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:c?"#0d652d":"#1557b0",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:c?"Copied!":"Copy"})]})]}),t.jsxs(o.Box,{sx:{display:"flex",gap:1.5},children:[t.jsx(o.Button,{onClick:i,variant:"outlined",startIcon:t.jsx(w.OpenInNew,{sx:{fontSize:18}}),fullWidth:!0,sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"#1967d2",borderColor:"#dadce0",py:1,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{borderColor:"#1967d2",bgcolor:"#f8f9fa"}},children:"Open link"}),t.jsx(o.Button,{onClick:a,variant:"outlined",startIcon:t.jsx(w.Delete,{sx:{fontSize:18}}),fullWidth:!0,sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"#d93025",borderColor:"#dadce0",py:1,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{borderColor:"#d93025",bgcolor:"rgba(217, 48, 37, 0.04)"}},children:"Delete preset"})]})]})}),t.jsx(o.Box,{sx:{px:3,py:2,borderTop:"1px solid #e8eaed",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"#f8f9fa"},children:t.jsx(o.Button,{onClick:l,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#1967d2",color:"#ffffff",px:3,py:1,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#1557b0",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Done"})})]})})}function Hc({presetName:e,onClear:r}){return t.jsx(o.Chip,{icon:t.jsx(w.Link,{sx:{fontSize:14}}),label:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:["Preset: ",t.jsx(o.Box,{component:"span",sx:{fontWeight:600},children:e})]}),onDelete:r,deleteIcon:t.jsx(o.IconButton,{size:"small",title:"Exit preset view",sx:{p:0},children:t.jsx(w.Close,{sx:{fontSize:14}})}),sx:{bgcolor:n=>ne(n.palette.primary.main,.12),borderColor:"primary.light",border:1,fontSize:"body2.fontSize",fontWeight:500,"& .MuiChip-deleteIcon":{color:"primary.main","&:hover":{color:"primary.main"}}}})}function Uc({presets:e,reportId:r,onOpenPreset:n,onCopyLink:i,onDeletePreset:a,onClose:l}){const[c,d]=u.useState(null),f=(m,b)=>{i(m,b),d(m),setTimeout(()=>d(null),2e3)},x=m=>new Date(m).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});return t.jsx(o.Box,{onClick:l,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:m=>m.stopPropagation(),elevation:0,sx:{position:"relative",width:680,maxWidth:"calc(100vw - 120px)",maxHeight:"min(720px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"#ffffff",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid #e8eaed",flexShrink:0},children:[t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"#202124",letterSpacing:"0",lineHeight:1.5},children:"Manage Presets"}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"#5f6368",mt:.5,display:"block"},children:[e.length," saved ",e.length===1?"preset":"presets"]})]}),t.jsx(o.IconButton,{onClick:l,size:"small",sx:{p:.75,color:"#5f6368",transition:"all 0.2s ease","&:hover":{bgcolor:"#f1f3f4",color:"#202124"}},children:t.jsx(w.Close,{sx:{fontSize:20}})})]}),t.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"#dadce0",borderRadius:4,"&:hover":{bgcolor:"#bdc1c6"}}},children:e.length===0?t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8},children:[t.jsx(w.Share,{sx:{fontSize:48,color:"#dadce0",mb:2}}),t.jsx(o.Typography,{variant:"body1",sx:{fontSize:"0.875rem",color:"#5f6368",textAlign:"center"},children:"No presets created yet"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"#80868b",textAlign:"center",mt:.5},children:"Create a preset to share report configurations"})]}):t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:e.map(m=>t.jsxs(o.Paper,{elevation:0,sx:{p:2.5,border:"1px solid #e8eaed",borderRadius:"8px",bgcolor:"#ffffff",transition:"all 0.2s ease","&:hover":{borderColor:"#dadce0",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.1), 0 1px 3px 1px rgba(60, 64, 67, 0.05)"}},children:[t.jsx(o.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",mb:1.5},children:t.jsxs(o.Box,{sx:{flex:1,minWidth:0},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"0.9375rem",fontWeight:500,color:"#202124",mb:.5},children:m.name}),m.description&&t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"#5f6368",lineHeight:1.5},children:m.description})]})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:2},children:[t.jsx(o.Chip,{label:`Created ${x(m.createdAt)}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"#f1f3f4",color:"#5f6368","& .MuiChip-label":{px:1}}}),t.jsx(o.Chip,{label:`By ${m.createdBy}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"#f1f3f4",color:"#5f6368","& .MuiChip-label":{px:1}}})]}),t.jsx(o.Divider,{sx:{my:1.5,borderColor:"#f1f3f4"}}),t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Button,{onClick:()=>n(m.id),variant:"outlined",size:"small",startIcon:t.jsx(w.OpenInNew,{sx:{fontSize:16}}),sx:{textTransform:"none",fontSize:"0.8125rem",fontWeight:500,color:"#1967d2",borderColor:"#dadce0",px:1.5,py:.75,borderRadius:"4px","&:hover":{borderColor:"#1967d2",bgcolor:"#f8f9fa"}},children:"Open"}),t.jsx(o.Button,{onClick:()=>f(m.id,m.name),variant:"outlined",size:"small",startIcon:c===m.id?t.jsx(w.Check,{sx:{fontSize:16}}):t.jsx(w.ContentCopy,{sx:{fontSize:16}}),sx:{textTransform:"none",fontSize:"0.8125rem",fontWeight:500,color:c===m.id?"#188038":"#5f6368",borderColor:"#dadce0",px:1.5,py:.75,borderRadius:"4px","&:hover":{borderColor:"#5f6368",bgcolor:"#f8f9fa"}},children:c===m.id?"Copied!":"Copy link"}),t.jsx(o.Button,{onClick:()=>a(m.id,m.name),variant:"outlined",size:"small",startIcon:t.jsx(w.Delete,{sx:{fontSize:16}}),sx:{textTransform:"none",fontSize:"0.8125rem",fontWeight:500,color:"#d93025",borderColor:"#dadce0",px:1.5,py:.75,borderRadius:"4px","&:hover":{borderColor:"#d93025",bgcolor:"rgba(217, 48, 37, 0.04)"}},children:"Delete"})]})]},m.id))})}),t.jsx(o.Box,{sx:{px:3,py:1.75,borderTop:"1px solid #e8eaed",bgcolor:"#f8f9fa",gap:1.25,justifyContent:"flex-end",display:"flex"},children:t.jsx(o.Button,{onClick:l,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#1967d2",color:"#ffffff",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#1557b0",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Close"})})]})})}function Gc({totalRows:e,visibleRows:r,hasGrouping:n,visibleColumnsCount:i,totalColumnsCount:a,onExport:l,onClose:c}){const[d,f]=u.useState("csv"),[x,m]=u.useState("visible"),[b,g]=u.useState("visible"),v=e>5e4,C=x==="visible"?r:e,p=b==="visible"?i:a,T=()=>{l({format:d,scope:x,columnScope:b}),c()},s={csv:"CSV",excel:"Excel (.xlsx)",json:"JSON"};return t.jsx(o.Box,{onClick:c,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:k=>k.stopPropagation(),elevation:0,sx:{position:"relative",width:480,maxWidth:"calc(100vw - 120px)",maxHeight:"min(620px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"#ffffff",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid #e8eaed",flexShrink:0},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"#202124",letterSpacing:"0",lineHeight:1.5},children:"Export report"}),t.jsx(o.IconButton,{onClick:c,size:"small",sx:{p:.75,color:"#5f6368",transition:"all 0.2s ease","&:hover":{bgcolor:"#f1f3f4",color:"#202124"}},children:t.jsx(w.Close,{sx:{fontSize:20}})})]}),t.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"#dadce0",borderRadius:4,"&:hover":{bgcolor:"#bdc1c6"}}},children:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[v&&t.jsxs(o.Alert,{severity:"warning",icon:t.jsx(w.Warning,{sx:{fontSize:20}}),sx:{borderRadius:"8px",border:"1px solid #fdd663",bgcolor:"#fef7e0","& .MuiAlert-icon":{color:"#ea8600"},"& .MuiAlertTitle-root":{fontSize:"0.875rem",fontWeight:500,color:"#3c4043",mb:.5},"& .MuiAlert-message":{fontSize:"0.8125rem",color:"#5f6368"}},children:[t.jsx(o.AlertTitle,{children:"Large dataset warning"}),"This export contains over 50,000 rows. Processing may take a few moments."]}),t.jsxs(o.FormControl,{component:"fieldset",children:[t.jsx(o.FormLabel,{component:"legend",sx:{fontSize:"0.6875rem",fontWeight:600,color:"#5f6368",letterSpacing:"0.1em",mb:1.5,textTransform:"uppercase"},children:"Format"}),t.jsxs(o.RadioGroup,{value:d,onChange:k=>f(k.target.value),children:[t.jsx(o.FormControlLabel,{value:"csv",control:t.jsx(o.Radio,{size:"small",sx:{color:"#5f6368","&.Mui-checked":{color:"#1967d2"}}}),label:t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:"CSV"}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"#5f6368"},children:"Comma-separated values, compatible with Excel"})]}),sx:{mb:1.25,alignItems:"flex-start",px:1.5,py:1,borderRadius:"8px",transition:"background-color 0.2s ease","&:hover":{bgcolor:"#f8f9fa"}}}),t.jsx(o.FormControlLabel,{value:"excel",control:t.jsx(o.Radio,{size:"small",sx:{color:"#5f6368","&.Mui-checked":{color:"#1967d2"}}}),label:t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:"Excel (.xlsx)"}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"#5f6368"},children:"Native Excel format with formatting support"})]}),sx:{mb:1.25,alignItems:"flex-start",px:1.5,py:1,borderRadius:"8px",transition:"background-color 0.2s ease","&:hover":{bgcolor:"#f8f9fa"}}}),t.jsx(o.FormControlLabel,{value:"json",control:t.jsx(o.Radio,{size:"small",sx:{color:"#5f6368","&.Mui-checked":{color:"#1967d2"}}}),label:t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:"JSON"}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"#5f6368"},children:"Structured data with metadata and filters"})]}),sx:{alignItems:"flex-start",px:1.5,py:1,borderRadius:"8px",transition:"background-color 0.2s ease","&:hover":{bgcolor:"#f8f9fa"}}})]})]}),t.jsxs(o.FormControl,{component:"fieldset",children:[t.jsx(o.FormLabel,{component:"legend",sx:{fontSize:"0.6875rem",fontWeight:600,color:"#5f6368",letterSpacing:"0.1em",mb:1.5,textTransform:"uppercase"},children:"Rows"}),t.jsxs(o.RadioGroup,{value:x,onChange:k=>m(k.target.value),children:[t.jsx(o.FormControlLabel,{value:"visible",control:t.jsx(o.Radio,{size:"small",sx:{color:"#5f6368","&.Mui-checked":{color:"#1967d2"}}}),label:t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:"Visible rows"}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"#5f6368"},children:["Export ",r.toLocaleString()," rows (filtered and searched)"]})]}),sx:{mb:1.25,alignItems:"flex-start",px:1.5,py:1,borderRadius:"8px",transition:"background-color 0.2s ease","&:hover":{bgcolor:"#f8f9fa"}}}),t.jsx(o.FormControlLabel,{value:"all",control:t.jsx(o.Radio,{size:"small",sx:{color:"#5f6368","&.Mui-checked":{color:"#1967d2"}}}),label:t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:"All rows"}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"#5f6368"},children:["Export ",e.toLocaleString()," rows (complete original dataset)"]})]}),sx:{alignItems:"flex-start",px:1.5,py:1,borderRadius:"8px",transition:"background-color 0.2s ease","&:hover":{bgcolor:"#f8f9fa"}}})]})]}),t.jsxs(o.FormControl,{component:"fieldset",children:[t.jsx(o.FormLabel,{component:"legend",sx:{fontSize:"0.6875rem",fontWeight:600,color:"#5f6368",letterSpacing:"0.1em",mb:1.5,textTransform:"uppercase"},children:"Columns"}),t.jsxs(o.RadioGroup,{value:b,onChange:k=>g(k.target.value),children:[t.jsx(o.FormControlLabel,{value:"visible",control:t.jsx(o.Radio,{size:"small",sx:{color:"#5f6368","&.Mui-checked":{color:"#1967d2"}}}),label:t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:"Visible columns only"}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"#5f6368"},children:["Export ",i," visible columns"]})]}),sx:{mb:1.25,alignItems:"flex-start",px:1.5,py:1,borderRadius:"8px",transition:"background-color 0.2s ease","&:hover":{bgcolor:"#f8f9fa"}}}),t.jsx(o.FormControlLabel,{value:"all",control:t.jsx(o.Radio,{size:"small",sx:{color:"#5f6368","&.Mui-checked":{color:"#1967d2"}}}),label:t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:"All columns"}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"#5f6368"},children:["Export all ",a," columns (including hidden)"]})]}),sx:{alignItems:"flex-start",px:1.5,py:1,borderRadius:"8px",transition:"background-color 0.2s ease","&:hover":{bgcolor:"#f8f9fa"}}})]})]}),t.jsxs(o.Box,{sx:{pt:1},children:[t.jsx(o.Divider,{sx:{mb:2,borderColor:"#e8eaed"}}),t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"#5f6368"},children:"Format:"}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:s[d]})]}),t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"#5f6368"},children:"Rows to export:"}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:C.toLocaleString()})]}),t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"#5f6368"},children:"Columns to export:"}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:p})]})]})]})]})}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid #e8eaed",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"#f8f9fa"},children:[t.jsx(o.Button,{onClick:c,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"#5f6368",px:3,py:1,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"#e8eaed",color:"#202124"}},children:"Cancel"}),t.jsxs(o.Button,{onClick:T,variant:"contained",startIcon:t.jsx(w.Download,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#1967d2",color:"#ffffff",px:3,py:1,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#1557b0",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:["Download ",s[d]]})]})]})})}function Yc({warning:e,onDismiss:r}){return t.jsx(o.Box,{sx:{position:"fixed",top:16,right:16,zIndex:50,maxWidth:448},children:t.jsxs(o.Alert,{severity:"warning",icon:t.jsx(w.Warning,{sx:{fontSize:20}}),action:t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:"warning.main"},children:t.jsx(w.Close,{sx:{fontSize:16}})}),sx:{borderLeft:4,borderColor:"warning.main",boxShadow:3},children:[t.jsx(o.AlertTitle,{sx:{fontWeight:600},children:"Feature Limit Reached"}),t.jsx(o.Box,{sx:{fontSize:"body2.fontSize",mb:1},children:e.message}),t.jsxs(o.Box,{sx:{fontSize:"caption.fontSize",opacity:.9},children:["Please remove some ",e.type==="filter"?"filters":e.type==="sort"?"sort levels":"grouping levels"," before adding more."]})]})})}function qc({error:e,onDismiss:r,autoDismiss:n=!0,autoDismissDelay:i=5e3}){u.useEffect(()=>{if(n){const d=setTimeout(()=>{r()},i);return()=>clearTimeout(d)}},[n,i,r]);const l=(()=>{switch(e.type){case"system":return{severity:"error",icon:t.jsx(w.Cancel,{sx:{fontSize:20}})};case"processing":return{severity:"warning",icon:t.jsx(w.Warning,{sx:{fontSize:20}})};case"ui":default:return{severity:"info",icon:t.jsx(w.InfoOutlined,{sx:{fontSize:20}})}}})(),c=Is(e);return t.jsx(o.Box,{sx:{position:"fixed",top:16,right:16,zIndex:50,maxWidth:448},children:t.jsxs(o.Alert,{severity:l.severity,icon:l.icon,action:t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:`${l.severity}.main`},children:t.jsx(w.Close,{sx:{fontSize:16}})}),sx:{borderLeft:4,borderColor:`${l.severity}.main`,boxShadow:3},children:[t.jsxs(o.AlertTitle,{sx:{fontWeight:600},children:[e.context.charAt(0).toUpperCase()+e.context.slice(1)," Error"]}),t.jsx(o.Box,{sx:{fontSize:"body2.fontSize"},children:c}),e.details&&process.env.NODE_ENV==="development"&&t.jsx(o.Box,{component:"pre",sx:{fontSize:"caption.fontSize",mt:1,fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:JSON.stringify(e.details,null,2)})]})})}class Jc extends u.Component{constructor(r){super(r),this.handleReset=()=>{this.setState({hasError:!1,error:null})},this.state={hasError:!1,error:null}}static getDerivedStateFromError(r){return{hasError:!0,error:r}}componentDidCatch(r,n){console.error("[ErrorBoundary] Caught error:",r,n),this.props.onError&&this.props.onError(r,n)}render(){var r,n;return this.state.hasError?this.props.fallback?this.props.fallback:t.jsx(o.Paper,{sx:{bgcolor:i=>ne(i.palette.error.main,.12),border:1,borderColor:"error.light",borderRadius:2,p:3,m:2},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.5},children:[t.jsx(w.Warning,{color:"error",sx:{fontSize:24,flexShrink:0}}),t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"h6",sx:{color:"error.main",fontWeight:600},children:this.props.context?`${this.props.context} Error`:"Something went wrong"}),t.jsx(o.Typography,{variant:"body2",sx:{color:"error.main",mt:1},children:((r=this.state.error)==null?void 0:r.message)||"An unexpected error occurred"}),process.env.NODE_ENV==="development"&&t.jsx(o.Box,{component:"pre",sx:{mt:1.5,fontSize:"caption.fontSize",color:"error.main",bgcolor:i=>ne(i.palette.error.main,.12),p:1.5,borderRadius:1,overflow:"auto",maxHeight:160},children:(n=this.state.error)==null?void 0:n.stack}),t.jsx(o.Button,{onClick:this.handleReset,variant:"contained",color:"error",startIcon:t.jsx(w.Refresh,{sx:{fontSize:16}}),sx:{mt:2},children:"Try Again"})]})]})}):this.props.children}}function ar({children:e,feature:r,onError:n}){return t.jsx(Jc,{context:r,onError:(i,a)=>{n&&n(i)},fallback:t.jsxs(o.Alert,{severity:"warning",sx:{m:1},icon:t.jsx(w.Warning,{sx:{fontSize:20}}),children:[t.jsxs(o.AlertTitle,{children:[r," temporarily unavailable"]}),"Other features continue to work normally"]}),children:e})}function qn({reportEngine:e}){var mr,gr;const{activeReport:r,paginatedData:n,processedData:i,tableMetrics:a,tableEngine:l,activeView:c,isDirty:d,currentTableState:f,viewChanges:x,showFilterPanel:m,setShowFilterPanel:b,filterFocusColumn:g,handleAddFilter:v,handleUpdateFilter:C,handleRemoveFilter:p,handleClearAllFilters:T,handleOpenFilterForColumn:s,handleCloseFilterPanel:k,handleClearFiltersForColumn:D,showSortPanel:A,setShowSortPanel:S,handleSort:R,handleUpdateSortStack:Y,handleSortAscending:_,handleSortDescending:K,showManageViews:V,setShowManageViews:te,showCreateViewModal:h,setShowCreateViewModal:F,showEditViewModal:W,setShowEditViewModal:E,showDeleteConfirmation:H,setShowDeleteConfirmation:de,editingView:ue,deletingView:Be,handleSelectView:O,handleCreateView:N,handleUpdateCurrentView:Q,handleSaveAsNewView:X,handleRevertChanges:Z,handleToggleDefault:re,handleToggleFavorite:J,handleSoftDelete:q,handleRestoreView:oe,handlePermanentDelete:ie,handleEditView:se,handleSaveEditView:ve,handleConfirmDelete:$,showManageColumns:De,setShowManageColumns:Ae,handleUpdateColumnVisibility:et,handleUpdateColumnOrder:tt,handleUpdateColumnWidth:Fe,handleResetColumnLayout:Le,showGroupPanel:Me,setShowGroupPanel:ft,handleGroup:At,handleToggleGroupCollapse:pt,searchQuery:xt,searchHistory:ht,handleSearchChange:rt,handleAddToSearchHistory:Rt,handleToggleSearchFavourite:ot,handleDeleteSearchHistory:Gt,selectedRowIds:kt,handleToggleRowSelection:Te,handleToggleAllRows:nt,handleRangeSelection:qe,handleClearSelection:it,currentPage:Mt,pageSize:mt,paginationEngine:Je,handlePageChange:hr,handlePageSizeChange:Tt,isExporting:Yt,showExportModal:Pt,setShowExportModal:zt,showDirtyExportWarning:gt,handleExport:ye,handleExportWithConfig:qt,handleExportSelected:Jt,handleExportAnyway:Ke,handleSaveAndExport:P,handleCancelExport:He,showAuditHistory:le,setShowAuditHistory:Oe,showCreatePreset:fe,setShowCreatePreset:Ue,showShareLink:bt,setShowShareLink:Pe,showManagePresets:Kt,setShowManagePresets:Wt,generatedPreset:je,activePreset:U,handleOpenSharePreset:st,handleOpenManagePresets:We,handleCreatePreset:Xt,handleCopyPresetLink:Qt,handleOpenPreset:Zt,handleDeletePreset:er,handleClearActivePreset:tr,handleOpenPresetById:rr,handleCopyPresetLinkById:_t,handleDeletePresetById:_e,isViewerRole:Et,userRole:or,featureLimitWarning:at,setFeatureLimitWarning:nr,reportError:It,setReportError:M,handleError:L,updateReport:ae,showSnack:$e}=e,ce=u.useCallback((ze,Ie)=>{if(!(r!=null&&r.uploadedData))return;const yt=[...r.uploadedData];yt[ze]=Ie,ae(r.id,{uploadedData:yt})},[r,ae]),Bt=u.useCallback(ze=>{if(!(r!=null&&r.uploadedData))return;const Ie=r.uploadedData.filter((yt,Hr)=>Hr!==ze);ae(r.id,{uploadedData:Ie})},[r,ae]),Lr=u.useCallback((ze,Ie)=>{if(!(r!=null&&r.uploadedData))return;const yt=[...r.uploadedData];yt.splice(ze+1,0,{...Ie}),ae(r.id,{uploadedData:yt})},[r,ae]);return!r||!r.schemaLocked||!r.schema||!r.uploadedData||!r.views?null:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,overflow:"hidden",position:"relative"},children:[!Et&&d&&c&&t.jsx($c,{viewName:c.name,isDefaultView:c.isDefault,changes:x,onSaveToCurrentView:c.isDefault?void 0:Q,onSaveAsNewView:X,onCancel:Z}),t.jsxs(o.Box,{id:"table-content-area",sx:{flex:1,minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column",position:"relative"},children:[at&&t.jsx(Yc,{warning:at,onDismiss:()=>nr(null)}),It&&t.jsx(qc,{error:It,onDismiss:()=>M(null)}),gt&&t.jsx(Fc,{onExportAnyway:Ke,onSaveAndExport:P,onCancel:He}),t.jsx(Ec,{schema:r.schema,data:n,sortStack:r.sortStack,filters:r.filters,views:r.views,activeViewId:r.activeViewId,isDirty:d,isExporting:Yt,columnVisibility:r.columnVisibility||(c==null?void 0:c.snapshot.columnVisibility),columnOrder:r.columnOrder||(c==null?void 0:c.snapshot.columnOrder),columnWidths:r.columnWidths||(c==null?void 0:c.snapshot.columnWidths),grouping:r.grouping,onSort:R,onSortAscending:_,onSortDescending:K,onOpenFilters:()=>b(!0),onOpenSort:()=>S(!0),onOpenFilterForColumn:s,onSelectView:O,onCreateView:()=>F(!0),onManageViews:()=>te(!0),onUpdateCurrentView:Q,onSaveAsNewView:X,onToggleDefault:re,onToggleFavorite:J,onRestoreView:oe,onPermanentDelete:ie,onExport:ye,onOpenColumns:()=>Ae(!0),onUpdateColumnWidth:Fe,onUpdateColumnOrder:tt,onUpdateColumnVisibility:et,onClearFiltersForColumn:D,onResetLayout:Le,onOpenGroup:()=>ft(!0),onToggleGroupCollapse:pt,onOpenAuditHistory:()=>Oe(!0),onOpenSharePreset:st,searchQuery:xt,searchHistory:ht,onAddToSearchHistory:Rt,onToggleSearchFavourite:ot,onDeleteSearchHistory:Gt,selectedRowIds:kt,onSearchChange:rt,onToggleRowSelection:Te,onToggleAllRows:nt,onRangeSelection:qe,onClearSelection:it,onExportSelected:Jt,currentPage:(Je==null?void 0:Je.currentPage)||Mt,pageSize:(Je==null?void 0:Je.pageSize)||mt,onPageChange:hr,onPageSizeChange:Tt,totalRowsBeforePagination:(a==null?void 0:a.searchedRows)||i.length,isReadOnly:Et,userRole:or,reportName:r.name,onEditRow:ce,onDeleteRow:Bt,onDuplicateRow:Lr})]}),m&&t.jsx(ar,{feature:"Filters",onError:ze=>{const Ie=ct("ui","filters",ze);L(Ie)},children:t.jsx(Ic,{schema:r.schema,filters:r.filters??[],onAddFilter:v,onUpdateFilter:C,onRemoveFilter:p,onClearAll:T,onClose:k,focusColumn:g})}),A&&t.jsx(ar,{feature:"Sorting",onError:ze=>{const Ie=ct("ui","sorting",ze);L(Ie)},children:t.jsx(Dc,{schema:r.schema,sortStack:r.sortStack??[],onUpdateSortStack:Y,onClose:()=>S(!1)})}),V&&t.jsx(ar,{feature:"Views",onError:ze=>{const Ie=ct("ui","views",ze);L(Ie)},children:t.jsx(Oc,{views:r.views,activeViewId:r.activeViewId??"",onSelectView:O,onCreateView:()=>{te(!1),F(!0)},onEditView:se,onDeleteView:q,onRestoreView:oe,onPermanentDelete:ie,onClose:()=>te(!1)})}),h&&f&&t.jsx(hn,{currentSnapshot:f,onSave:N,onClose:()=>F(!1)}),W&&ue&&t.jsx(hn,{currentSnapshot:ue.snapshot,onSave:ve,onClose:()=>{E(!1)},isEditMode:!0,initialName:ue.name,initialDescription:ue.description,initialIsDefault:ue.isDefault}),H&&Be&&t.jsx(Ac,{viewName:Be.name,onConfirm:$,onCancel:()=>{de(!1)}}),De&&c&&t.jsx(Mc,{schema:r.schema,columnVisibility:r.columnVisibility||c.snapshot.columnVisibility,columnOrder:r.columnOrder||c.snapshot.columnOrder,columnWidths:r.columnWidths||c.snapshot.columnWidths,views:r.views,activeViewId:r.activeViewId,onUpdateColumnVisibility:et,onUpdateColumnOrder:tt,onUpdateColumnWidth:Fe,onResetLayout:Le,onSelectView:ze=>{O(ze)},onSaveToCurrentView:()=>{Ae(!1)},onSaveToAllViews:()=>{if(c){const ze=r.views.map(Ie=>({...Ie,snapshot:{...Ie.snapshot,columnVisibility:c.snapshot.columnVisibility,columnOrder:c.snapshot.columnOrder,columnWidths:c.snapshot.columnWidths}}));ae(r.id,{views:ze}),$e("Column configuration applied to all views","success")}Ae(!1)},onClose:()=>Ae(!1)}),Me&&t.jsx(ar,{feature:"Grouping",onError:ze=>{const Ie=ct("ui","grouping",ze);L(Ie)},children:t.jsx(Pc,{schema:r.schema,grouping:r.grouping||null,onApply:At,onClose:()=>ft(!1)})}),le&&t.jsx(Vc,{auditHistory:r.auditHistory||[],onClose:()=>Oe(!1)}),fe&&t.jsx(Nc,{onSave:Xt,onClose:()=>Ue(!1)}),bt&&je&&t.jsx(Lc,{presetName:je.preset.name,shareUrl:je.url,onCopyLink:Qt,onOpenPreset:Zt,onDeletePreset:er,onClose:()=>{Pe(!1)}}),Kt&&t.jsx(Uc,{presets:r.presets||[],reportId:r.id,onOpenPreset:rr,onCopyLink:_t,onDeletePreset:_e,onClose:()=>Wt(!1)}),U&&t.jsx(o.Box,{sx:{mt:2},children:t.jsx(Hc,{presetName:U.name,onClear:tr})}),Pt&&t.jsx(ar,{feature:"Export",onError:ze=>{const Ie=ct("ui","export",ze);L(Ie)},children:t.jsx(Gc,{totalRows:(a==null?void 0:a.totalRows)||((mr=r.uploadedData)==null?void 0:mr.length)||0,visibleRows:(a==null?void 0:a.searchedRows)||i.length,visibleColumnsCount:((gr=l==null?void 0:l.columnEngine)==null?void 0:gr.visibleColumns.length)||r.schema.length,totalColumnsCount:r.schema.length,hasGrouping:(a==null?void 0:a.isGrouped)||!1,onExport:qt,onClose:()=>{zt(!1)}})})]})}function Jn({open:e,message:r,severity:n,onClose:i}){return t.jsx(o.Snackbar,{open:e,autoHideDuration:4e3,onClose:i,anchorOrigin:{vertical:"top",horizontal:"right"},children:t.jsx(o.Alert,{onClose:i,severity:n,variant:"filled",sx:{width:"100%",boxShadow:3},children:r})})}function Kn(){const e=co(),{reports:r,activeReportId:n,activeReport:i,uploadState:a,schema:l,hasSchemaConflicts:c,isModalOpen:d,setIsModalOpen:f,setActiveReportId:x,createReport:m,handleFileUpload:b,handleUploadError:g,handleRetry:v,handleConfirm:C,snack:p,handleSnackClose:T}=e;return t.jsxs(o.Box,{sx:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[t.jsx(Ys,{onCreateReport:()=>f(!0)}),t.jsx(qs,{reports:r,activeReportId:n,onTabClick:x}),t.jsx(o.Box,{component:"main",sx:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column",m:0,p:0},children:r.length===0?t.jsx(Un,{title:"No reports yet",description:"Create your first report to start analyzing your data."}):i?t.jsx(t.Fragment,{children:i.schemaLocked&&i.schema&&i.uploadedData&&i.views?t.jsx(qn,{reportEngine:e}):t.jsx(o.Box,{sx:{p:3},children:a==="preview"&&i.schema&&i.uploadedData?t.jsx(sc,{schema:i.schema,onConfirm:C,hasConflicts:c}):i.uploadError?t.jsx(ac,{error:i.uploadError,onRetry:v}):t.jsx(ic,{onFileUpload:b,onError:g,isUploading:a==="uploading"})})}):null}),t.jsx(oc,{isOpen:d,onClose:()=>f(!1),onCreate:m}),t.jsx(Jn,{open:p.open,message:p.message,severity:p.severity,onClose:T})]})}function Kc(){return t.jsx(lo,{children:t.jsx(Kn,{})})}function Xn(){const e=co(),{snack:r,handleSnackClose:n}=e;return t.jsxs(o.Box,{sx:{minHeight:"100vh"},children:[t.jsx(o.Box,{component:"main",children:e.activeReport?t.jsx(qn,{reportEngine:e}):t.jsx(Un,{title:"No report data",description:"This viewer requires report data to be loaded."})}),t.jsx(Jn,{open:r.open,message:r.message,severity:r.severity,onClose:n})]})}function Xc({data:e,autoLoad:r=!0,config:n}){return t.jsx(lo,{data:e,mode:"viewer",autoLoad:r,config:n,children:t.jsx(Xn,{})})}exports.URMBuilder=Kc;exports.URMBuilderRaw=Kn;exports.URMProvider=lo;exports.URMViewer=Xc;exports.URMViewerRaw=Xn;exports.useURMContext=co;
|
|
115
|
+
]`})})]}),e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Supported Column Types"}),e.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:"The system automatically detects column types from your data:"}),e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:[e.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,minWidth:80},children:"Number:"}),e.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["Numeric values (e.g., ",e.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"33"}),", ",e.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"42.5"}),")"]})]}),e.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,minWidth:80},children:"Boolean:"}),e.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["True/false values (e.g., ",e.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"true"}),", ",e.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"false"}),")"]})]}),e.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,minWidth:80},children:"String:"}),e.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["Text values (e.g., ",e.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"Europe"'}),", ",e.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"Analytics Pro"'}),")"]})]}),e.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,minWidth:80},children:"Date:"}),e.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["ISO date strings (e.g., ",e.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"2024-08-22"'}),")"]})]})]})]}),e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Notes"}),e.jsxs(o.Box,{component:"ul",sx:{m:0,pl:2.5,"& li":{fontSize:"body2.fontSize",color:"text.secondary",mb:.5}},children:[e.jsx("li",{children:"Each object in the array represents one row in the report."}),e.jsx("li",{children:"The keys of the JSON objects become report columns."}),e.jsx("li",{children:"All objects should have consistent keys for proper column detection."}),e.jsx("li",{children:"Column names are case-sensitive and preserve spacing."})]})]})]})}),e.jsx(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid #e8eaed",bgcolor:"#f8f9fa",gap:1.25,justifyContent:"flex-end"},children:e.jsx(o.Button,{onClick:r,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#1967d2",color:"#ffffff",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#1557b0",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Got it"})})]}):null}function kc({onFileUpload:t,onError:r,isUploading:n}){const[i,a]=u.useState(!1),[c,l]=u.useState(""),[d,f]=u.useState(!1),h=u.useRef(null),m=async s=>{if(!s.name.endsWith(".json")){r("Please upload a valid JSON file");return}l(s.name);try{const T=await s.text(),I=JSON.parse(T);if(!Array.isArray(I)){r("JSON must be an array of objects");return}if(I.length===0){r("JSON array is empty");return}t(I)}catch{r("Invalid JSON format. Please check your file and try again.")}finally{l("")}},g=s=>{s.preventDefault(),a(!0)},y=s=>{s.preventDefault(),a(!1)},S=s=>{s.preventDefault(),a(!1);const T=s.dataTransfer.files[0];T&&m(T)},C=()=>{var s;(s=h.current)==null||s.click()},x=s=>{var I;const T=(I=s.target.files)==null?void 0:I[0];T&&m(T)},E=s=>{s.stopPropagation(),f(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(o.Box,{onDragOver:g,onDragLeave:y,onDrop:S,onClick:C,sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderStyle:"dashed",borderColor:i?"primary.main":"divider",bgcolor:i?s=>N(s.palette.primary.main,.12):"transparent",borderRadius:1,px:2,py:6,cursor:"pointer",transition:"all 0.2s",opacity:n?.5:1,pointerEvents:n?"none":"auto","&:hover":{borderColor:i?"primary.main":"text.secondary"}},children:[e.jsx(o.Box,{component:"input",ref:h,type:"file",accept:".json",onChange:x,sx:{display:"none"}}),n?e.jsxs(e.Fragment,{children:[e.jsx(o.CircularProgress,{size:32,sx:{mb:2}}),e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,mb:.5},children:"Uploading..."}),c&&e.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:c})]}):e.jsxs(e.Fragment,{children:[e.jsx(o.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:s=>N(s.palette.primary.main,.12),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(j.UploadFile,{sx:{fontSize:32,color:"primary.main"}})}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:1.5},children:[e.jsx(o.Button,{variant:"contained",sx:{fontWeight:500},children:"Upload Data (JSON)"}),e.jsx(o.IconButton,{onClick:E,size:"small",sx:{border:1,borderColor:"divider","&:hover":{borderColor:"text.secondary",bgcolor:"action.hover"}},title:"View JSON format guide",children:e.jsx(j.InfoOutlined,{sx:{fontSize:16}})})]}),e.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{textAlign:"center",maxWidth:500},children:"Upload structured JSON data to generate your report."}),e.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{mt:1},children:"Click to browse or drag and drop a JSON file here"})]})]}),e.jsx(mi,{isOpen:d,onClose:()=>f(!1)})]})}function Tc({schema:t,onConfirm:r,hasConflicts:n}){return e.jsxs(o.Paper,{sx:{border:2,borderColor:"divider",p:3},children:[e.jsxs(o.Box,{sx:{mb:2},children:[e.jsx(o.Typography,{variant:"h6",sx:{fontWeight:600,mb:.5},children:"Schema Preview"}),e.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"Review the detected schema before generating your table"})]}),n&&e.jsxs(o.Alert,{severity:"warning",sx:{mb:2},children:[e.jsx(o.AlertTitle,{sx:{fontWeight:600},children:"Schema Conflict Detected"}),"Some columns have inconsistent data types across rows. Please resolve these conflicts before proceeding."]}),e.jsx(o.TableContainer,{sx:{mb:3},children:e.jsxs(o.Table,{children:[e.jsx(o.TableHead,{children:e.jsxs(o.TableRow,{sx:{bgcolor:"action.hover"},children:[e.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Column Name"}),e.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Detected Type"}),e.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Status"})]})}),e.jsx(o.TableBody,{children:t.map(i=>e.jsxs(o.TableRow,{sx:{bgcolor:i.hasConflict?a=>N(a.palette.warning.main,.12):"transparent"},children:[e.jsxs(o.TableCell,{sx:{fontWeight:500},children:[i.name,i.hasConflict&&e.jsx(o.Box,{component:"span",sx:{ml:1,color:"warning.main"},children:"⚠"})]}),e.jsx(o.TableCell,{children:e.jsx(o.Chip,{label:i.type,size:"small",sx:{bgcolor:"action.hover"}})}),e.jsx(o.TableCell,{children:e.jsx(o.Chip,{label:i.required?"Required":"Optional",size:"small",color:i.required?"success":"default"})})]},i.name))})]})}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pt:2,borderTop:1,borderColor:"divider"},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(j.Lock,{sx:{fontSize:16}}),e.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"Schema will be locked for this report"})]}),e.jsx(o.Button,{variant:"contained",onClick:r,disabled:n,sx:{fontWeight:500},children:"Generate Table"})]})]})}function zc({error:t,onRetry:r}){return e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderColor:"error.light",bgcolor:n=>N(n.palette.error.main,.12),borderRadius:1,px:2,py:6},children:[e.jsx(o.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:n=>N(n.palette.error.main,.3),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(j.ErrorOutline,{color:"error",sx:{fontSize:32}})}),e.jsx(o.Typography,{variant:"h6",color:"error.main",sx:{fontWeight:600,mb:1},children:"Upload Failed"}),e.jsx(o.Typography,{variant:"body2",color:"error.main",sx:{textAlign:"center",maxWidth:500,mb:3},children:t}),e.jsx(o.Button,{variant:"contained",color:"error",startIcon:e.jsx(j.Upload,{sx:{fontSize:16}}),onClick:r,sx:{fontWeight:500},children:"Try Again"})]})}function gi({title:t,description:r,showIcon:n=!0}){return e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"60vh",px:3,py:8},children:[n&&e.jsx(o.Box,{sx:{width:80,height:80,borderRadius:"50%",bgcolor:i=>N(i.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:3},children:e.jsx(j.Description,{sx:{fontSize:36,color:"primary.main"}})}),e.jsx(o.Typography,{variant:"h5",sx:{fontWeight:500,mb:1,color:"text.primary",fontSize:"1.125rem"},children:t}),e.jsx(o.Typography,{variant:"body1",sx:{textAlign:"center",maxWidth:520,color:"text.secondary",fontSize:"0.875rem",lineHeight:1.5},children:r})]})}function Ic({value:t,onChange:r,searchHistory:n,onAddToHistory:i,onToggleFavourite:a,onDeleteHistory:c,disabled:l}){const[d,f]=u.useState(!1),[h,m]=u.useState(!1),[g,y]=u.useState(-1),S=u.useRef(null),C=u.useRef(null);u.useEffect(()=>{function w(O){S.current&&!S.current.contains(O.target)&&(f(!1),m(!1))}return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[]);const x=u.useCallback(()=>{m(!0),y(-1),n.length>0&&f(!0)},[n.length]),E=u.useCallback(w=>{r(w),y(-1)},[r]),s=u.useCallback(w=>{var O;r(w),i(w),f(!1),(O=C.current)==null||O.blur()},[r,i]),T=u.useCallback(w=>{y(-1),s(w)},[s]),I=u.useCallback(w=>{var O;w.key==="Enter"?g>=0&&g<n.length?(w.preventDefault(),T(n[g].query)):t.trim()&&s(t.trim()):w.key==="Escape"?(f(!1),y(-1),(O=C.current)==null||O.blur()):w.key==="ArrowDown"?(w.preventDefault(),n.length>0&&(d||f(!0),y(V=>V<n.length-1?V+1:V))):w.key==="ArrowUp"&&(w.preventDefault(),y(V=>V>0?V-1:-1))},[g,n,t,d,T,s]),A=u.useCallback(()=>{var w;r(""),(w=C.current)==null||w.focus()},[r]),v=u.useMemo(()=>n.filter(w=>w.isFavourite),[n]),W=u.useMemo(()=>n.filter(w=>!w.isFavourite),[n]),U=d&&n.length>0;return e.jsxs(o.Box,{sx:{position:"relative",width:240},ref:S,children:[e.jsx(o.TextField,{inputRef:C,size:"small",fullWidth:!0,value:t,onChange:w=>E(w.target.value),onFocus:x,onKeyDown:I,placeholder:"Search data...",disabled:l,sx:{"& .MuiOutlinedInput-root":{borderRadius:"20px",fontSize:"0.875rem",bgcolor:"#ffffff",height:"36px","& fieldset":{borderColor:"#dadce0",transition:"all 0.15s ease"},"&:hover":{bgcolor:"action.hover"},"&:hover fieldset":{borderColor:"#dadce0"},"&.Mui-focused":{bgcolor:"#ffffff"},"&.Mui-focused fieldset":{borderColor:"#2932e5",borderWidth:2}},"& .MuiOutlinedInput-input":{py:"6px",px:"8px"}},InputProps:{startAdornment:e.jsx(o.InputAdornment,{position:"start",sx:{ml:.5},children:e.jsx(j.Search,{sx:{fontSize:18,color:"#5f6368"}})}),endAdornment:t?e.jsx(o.InputAdornment,{position:"end",children:e.jsx(o.IconButton,{size:"small",onClick:A,edge:"end",sx:{mr:-.5},children:e.jsx(j.Close,{sx:{fontSize:16}})})}):null}}),U&&e.jsxs(o.Paper,{sx:{position:"absolute",zIndex:50,mt:.5,width:"100%",maxHeight:384,overflowY:"auto"},elevation:3,children:[v.length>0&&e.jsxs(o.Box,{sx:{py:1},children:[e.jsx(o.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:600,textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Favourite Searches"}),v.map((w,O)=>e.jsx(Dn,{entry:w,isSelected:g===O,onClick:()=>T(w.query),onToggleFavourite:()=>a(w.query),onDelete:()=>c(w.query)},`fav-${w.query}`))]}),W.length>0&&e.jsxs(o.Box,{sx:{py:1},children:[v.length>0&&e.jsx(o.Divider,{}),e.jsx(o.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:600,textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Recent Searches"}),W.map((w,O)=>{const V=v.length+O;return e.jsx(Dn,{entry:w,isSelected:g===V,onClick:()=>T(w.query),onToggleFavourite:()=>a(w.query),onDelete:()=>c(w.query)},`recent-${w.query}`)})]})]})]})}const Dn=u.memo(function({entry:r,isSelected:n,onClick:i,onToggleFavourite:a,onDelete:c}){const l=u.useCallback(f=>{f.stopPropagation(),a()},[a]),d=u.useCallback(f=>{f.stopPropagation(),c()},[c]);return e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:1.5,py:1,cursor:"pointer",bgcolor:n?f=>N(f.palette.primary.main,.12):"transparent","&:hover":{bgcolor:n?f=>N(f.palette.primary.main,.12):"action.hover"}},children:[e.jsx(o.Box,{sx:{flex:1,minWidth:0},onClick:i,children:e.jsx(o.Typography,{variant:"body2",noWrap:!0,children:r.query})}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,ml:1},children:[e.jsx(o.IconButton,{size:"small",onClick:l,title:r.isFavourite?"Remove from favourites":"Add to favourites",sx:{p:.5},children:r.isFavourite?e.jsx(j.Star,{sx:{fontSize:14,color:"warning.light"}}):e.jsx(j.StarBorder,{sx:{fontSize:14,color:"action.disabled"}})}),e.jsx(o.IconButton,{size:"small",onClick:d,title:"Delete from history",sx:{p:.5,"&:hover":{color:"error.main"}},children:e.jsx(j.Delete,{sx:{fontSize:14,opacity:.5}})})]})]})});function Ec({views:t,activeViewId:r,isDirty:n,onSelectView:i,onCreateView:a,onManageViews:c,onToggleDefault:l,onToggleFavorite:d,onRestoreView:f,onPermanentDelete:h,isReadOnly:m}){const g=jc(),[y,S]=u.useState(!1),[C,x]=u.useState(!1),[E,s]=u.useState({top:0,left:0}),T=u.useRef(null),I=u.useRef(null),A=t.find(_=>_.id===r),v=A==null?void 0:A.isDefault,W=t.filter(_=>_.isDefault&&!_.isDeleted),U=t.filter(_=>!_.isDefault&&!_.isDeleted).sort((_,F)=>(F.updatedAt||0)-(_.updatedAt||0)),w=t.filter(_=>_.isFavorite&&!_.isDeleted).sort((_,F)=>(F.updatedAt||0)-(_.updatedAt||0)),O=t.filter(_=>_.isDeleted);u.useEffect(()=>{if(y&&I.current){const _=I.current.getBoundingClientRect();s({top:_.bottom+window.scrollY+8,left:_.right+window.scrollX-320})}},[y]),u.useEffect(()=>{const _=F=>{T.current&&!T.current.contains(F.target)&&I.current&&!I.current.contains(F.target)&&S(!1)};return y&&document.addEventListener("mousedown",_),()=>{document.removeEventListener("mousedown",_)}},[y]);const V=_=>{i(_),S(!1)},X=(_,F=!1)=>e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:r===_.id?g.palette.primary.light+"20":"transparent",transition:"background-color 0.2s","&:hover":{backgroundColor:r===_.id?g.palette.primary.light+"20":g.palette.grey[50]}},children:[e.jsxs(o.Button,{onClick:()=>V(_.id),sx:{display:"flex",alignItems:"center",gap:1,flex:1,textAlign:"left",minWidth:0,textTransform:"none",justifyContent:"flex-start",color:"inherit",p:0,"&:hover":{backgroundColor:"transparent"}},children:[r===_.id&&e.jsx(j.Check,{sx:{fontSize:16,flexShrink:0}}),r!==_.id&&e.jsx(o.Box,{sx:{width:"16px",flexShrink:0}}),e.jsx(o.Typography,{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:r===_.id?g.palette.primary.dark:g.palette.text.primary,fontWeight:r===_.id?500:400},children:_.name}),F&&e.jsx(o.Typography,{component:"span",sx:{fontSize:"caption.fontSize",color:g.palette.text.secondary,backgroundColor:g.palette.grey[100],px:1,py:.25,borderRadius:1,flexShrink:0},children:"Default"})]}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[d&&e.jsx(o.IconButton,{onClick:oe=>{oe.stopPropagation(),d(_.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:g.palette.grey[200]}},title:_.isFavorite?"Remove from favorites":"Add to favorites",children:e.jsx(j.Star,{sx:{fontSize:16}})}),l&&!_.isDefault&&e.jsx(o.IconButton,{onClick:oe=>{oe.stopPropagation(),l(_.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:g.palette.grey[200]}},title:"Set as default",children:e.jsx(j.RadioButtonUnchecked,{sx:{fontSize:16}})})]})]},_.id),p=_=>e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:g.palette.grey[50]},children:[e.jsx(o.Typography,{sx:{color:g.palette.text.secondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:_.name}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[f&&e.jsx(o.IconButton,{onClick:F=>{F.stopPropagation(),f(_.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:g.palette.grey[200]}},title:"Restore view",children:e.jsx(j.Undo,{sx:{fontSize:16,color:"success.main"}})}),h&&e.jsx(o.IconButton,{onClick:F=>{F.stopPropagation(),h(_.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:g.palette.grey[200]}},title:"Delete permanently",children:e.jsx(j.Delete,{sx:{fontSize:16,color:"error.main"}})})]})]},_.id),L=n||!v,$=n;return e.jsxs(o.Box,{sx:{position:"relative"},children:[e.jsxs(o.IconButton,{ref:I,onClick:()=>S(!y),size:"small",sx:{position:"relative",color:L?"warning.main":"text.secondary",bgcolor:L?N(g.palette.warning.main,.12):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:L?N(g.palette.warning.main,.2):N(g.palette.text.primary,.06),color:L?"warning.dark":"text.primary"}},title:`View: ${(A==null?void 0:A.name)||"Default View"}`,children:[e.jsx(j.Visibility,{sx:{fontSize:20}}),$&&e.jsx(o.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:8,height:8,borderRadius:"50%",bgcolor:"warning.main",border:"2px solid",borderColor:"background.paper"}})]}),y&&_n.createPortal(e.jsxs(o.Box,{ref:T,sx:{position:"fixed",width:"320px",backgroundColor:g.palette.background.paper,border:`1px solid ${g.palette.divider}`,borderRadius:1,boxShadow:g.shadows[8],zIndex:50,maxHeight:"500px",overflowY:"auto",top:E.top,left:E.left},children:[W.length>0&&e.jsxs(o.Box,{sx:{py:.5},children:[e.jsx(o.Typography,{sx:{px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:g.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Default Views"}),W.map(_=>X(_,!0))]}),w.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(o.Box,{sx:{borderTop:`1px solid ${g.palette.divider}`}}),e.jsxs(o.Box,{sx:{py:.5},children:[e.jsxs(o.Box,{sx:{px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:g.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",gap:.5},children:[e.jsx(j.Star,{sx:{fontSize:12,color:"warning.light"}}),e.jsx(o.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:"Favorite Views"})]}),w.map(_=>X(_))]})]}),U.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(o.Box,{sx:{borderTop:`1px solid ${g.palette.divider}`}}),e.jsxs(o.Box,{sx:{py:.5},children:[e.jsx(o.Typography,{sx:{px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:g.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Custom Views"}),U.map(_=>X(_))]})]}),O.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(o.Box,{sx:{borderTop:`1px solid ${g.palette.divider}`}}),e.jsxs(o.Box,{sx:{py:.5},children:[e.jsxs(o.Button,{onClick:()=>x(!C),sx:{width:"100%",px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:g.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",justifyContent:"space-between",transition:"background-color 0.2s","&:hover":{backgroundColor:g.palette.grey[50]}},children:[e.jsxs(o.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:["Recently Deleted (",O.length,")"]}),e.jsx(j.ChevronRight,{sx:{fontSize:16}})]}),C&&e.jsx(o.Box,{sx:{backgroundColor:g.palette.grey[50]},children:O.map(_=>p(_))})]})]}),e.jsx(o.Box,{sx:{borderTop:`1px solid ${g.palette.divider}`}}),e.jsxs(o.Button,{onClick:()=>{a(),S(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:g.palette.text.primary,textTransform:"none",justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:g.palette.grey[50]}},children:[e.jsx(j.Add,{sx:{fontSize:16}}),e.jsx(o.Typography,{component:"span",sx:{fontSize:"inherit"},children:"Create New Report View"})]}),e.jsxs(o.Button,{onClick:()=>{c(),S(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:g.palette.text.primary,textTransform:"none",justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:g.palette.grey[50]}},children:[e.jsx(j.Settings,{sx:{fontSize:16}}),e.jsx(o.Typography,{component:"span",sx:{fontSize:"inherit"},children:"View Setup"})]})]}),document.body)]})}function Bc({columnName:t,columnType:r="string",currentSort:n,hasFilters:i,isInSortStack:a,position:c,onSort:l,onRemoveSort:d,onSortAscending:f,onSortDescending:h,onFilter:m,onClearFilter:g,onHideColumn:y,onManageColumns:S,onManageViews:C,onResetLayout:x,onClose:E}){const s=u.useRef(null);u.useEffect(()=>{const I=v=>{s.current&&!s.current.contains(v.target)&&E()},A=v=>{v.key==="Escape"&&E()};return document.addEventListener("mousedown",I),document.addEventListener("keydown",A),()=>{document.removeEventListener("mousedown",I),document.removeEventListener("keydown",A)}},[E]);const T=()=>n?n.direction==="asc"?r==="number"?"(0→9)":r==="boolean"?"(False→True)":"(A→Z)":r==="number"?"(9→0)":r==="boolean"?"(True→False)":"(Z→A)":"";return _n.createPortal(e.jsxs(o.Paper,{ref:s,sx:{position:"fixed",left:`${c.x}px`,top:`${c.y}px`,zIndex:100,minWidth:240},elevation:3,children:[e.jsxs(o.Box,{sx:{px:2,py:1},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:1},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500},children:"Sorting"}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(o.IconButton,{size:"small",onClick:()=>{f?f(t):(n==null?void 0:n.direction)!=="asc"&&(l(t),(n==null?void 0:n.direction)==="desc"&&setTimeout(()=>l(t),0))},title:"Sort Ascending",sx:{p:.75},children:e.jsx(j.ArrowUpward,{color:(n==null?void 0:n.direction)==="asc"?"primary":void 0,sx:{fontSize:16}})}),e.jsx(o.IconButton,{size:"small",onClick:()=>{h?h(t):n?n.direction==="asc"&&l(t):(l(t),setTimeout(()=>l(t),0))},title:"Sort Descending",sx:{p:.75},children:e.jsx(j.ArrowDownward,{color:(n==null?void 0:n.direction)==="desc"?"primary":void 0,sx:{fontSize:16}})}),e.jsx(o.IconButton,{size:"small",onClick:()=>d(t),title:"Clear sorting",disabled:!n,sx:{p:.75,"&:hover":{color:"error.main"}},children:e.jsx(j.Close,{sx:{fontSize:16}})})]})]}),n&&e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mt:.5},children:[e.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:T()}),e.jsx(o.Chip,{label:`Level ${n.priority}`,size:"small",color:"primary",sx:{height:20,fontSize:"caption.fontSize"}})]})]}),e.jsx(o.Divider,{}),e.jsxs(o.MenuList,{dense:!0,children:[e.jsxs(o.MenuItem,{onClick:()=>{m(t),E()},children:[e.jsx(j.FilterList,{sx:{fontSize:16,mr:1}}),"Filter this column",i&&e.jsx(o.Chip,{label:"Active",size:"small",color:"primary",sx:{ml:"auto",height:20,fontSize:"caption.fontSize"}})]}),i&&e.jsxs(o.MenuItem,{onClick:()=>{g(t),E()},sx:{color:"warning.main"},children:[e.jsx(j.FilterListOff,{sx:{fontSize:16,mr:1}}),"Clear Filters"]})]}),e.jsx(o.Divider,{}),e.jsx(o.MenuList,{dense:!0,children:e.jsxs(o.MenuItem,{onClick:()=>{y(t),E()},children:[e.jsx(j.VisibilityOff,{sx:{fontSize:16,mr:1}}),"Hide column"]})}),e.jsx(o.Divider,{}),e.jsxs(o.MenuList,{dense:!0,children:[e.jsxs(o.MenuItem,{onClick:()=>{S(),E()},children:[e.jsx(j.Settings,{sx:{fontSize:16,mr:1}}),"Column Settings"]}),e.jsxs(o.MenuItem,{onClick:()=>{C(),E()},children:[e.jsx(j.Description,{sx:{fontSize:16,mr:1}}),"View Setup"]}),e.jsxs(o.MenuItem,{onClick:()=>{x(),E()},children:[e.jsx(j.Undo,{sx:{fontSize:16,mr:1}}),"Reset to Default Layout"]})]})]}),document.body)}const Dc=150,On="COLUMN_HEADER",Oc=u.memo(function({column:r,index:n,sortRule:i,hasFilters:a,isInSortStack:c,width:l,onColumnClick:d,onMoveColumn:f,onResizeStart:h,onSort:m,onRemoveSort:g,onSortAscending:y,onSortDescending:S,onOpenFilterForColumn:C,onClearFiltersForColumn:x,onHideColumn:E,onManageColumns:s,onManageViews:T,onResetLayout:I}){const A=u.useRef(null),[v,W]=u.useState(!1),[U,w]=u.useState({x:0,y:0}),[{handlerId:O,isOver:V},X]=vt.useDrop({accept:On,collect(R){return{handlerId:R.getHandlerId(),isOver:R.isOver()}},hover(R,q){var ae;if(!A.current)return;const ee=R.index,te=n;if(ee===te)return;const re=(ae=A.current)==null?void 0:ae.getBoundingClientRect(),ne=(re.right-re.left)/2,Z=q.getClientOffset(),Q=((Z==null?void 0:Z.x)??0)-re.left;ee<te&&Q<ne||ee>te&&Q>ne||(f(ee,te),R.index=te)}}),[{isDragging:p},L]=vt.useDrag({type:On,item:()=>({index:n,columnName:r.name}),collect:R=>({isDragging:R.isDragging()})});L(X(A));const $=u.useCallback(R=>{R.preventDefault(),R.stopPropagation(),w({x:R.clientX,y:R.clientY}),W(!0)},[]),_=u.useCallback(()=>{W(!1)},[]),F=u.useCallback(()=>{d(r.name)},[d,r.name]),oe=u.useCallback(R=>{R.stopPropagation(),C(r.name)},[C,r.name]),ue=u.useCallback(()=>i?e.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25,color:"primary.main"},children:[i.direction==="asc"?e.jsx(j.ArrowUpward,{sx:{fontSize:13,color:"primary.main"}}):e.jsx(j.ArrowDownward,{sx:{fontSize:13,color:"primary.main"}}),e.jsx(o.Box,{sx:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:16,height:16,bgcolor:"primary.main",color:"#fff",fontSize:"0.6rem",fontWeight:700,borderRadius:"50%",lineHeight:1},children:i.priority})]}):null,[i]),Ee=u.useCallback(()=>a?e.jsx(o.Box,{onClick:oe,title:"Active filters on this column",sx:{ml:.75,width:7,height:7,borderRadius:"50%",bgcolor:"primary.main",cursor:"pointer",flexShrink:0,"&:hover":{transform:"scale(1.25)"},transition:"transform 0.12s ease"}}):null,[a,oe]);return e.jsxs(e.Fragment,{children:[e.jsxs(o.TableCell,{ref:A,"data-handler-id":O,"data-column-index":n,onClick:F,onContextMenu:$,sx:{position:"sticky",top:0,zIndex:5,textAlign:"left",fontSize:"0.8125rem",fontWeight:700,textTransform:"none",letterSpacing:0,whiteSpace:"nowrap",cursor:"pointer",userSelect:"none",color:"primary.main",opacity:p?.25:1,transition:"background-color 0.12s ease, opacity 0.15s ease",bgcolor:V?R=>N(R.palette.primary.main,.08):"#f5f5f5",borderBottom:"1px solid",borderColor:"#e0e0e0",py:0,px:2,height:34,"&:hover":{bgcolor:"#e8eaed",color:"primary.dark"},width:l?`${l}px`:`${Dc}px`},children:[e.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center"},children:[St(r.name),ue(),Ee()]}),e.jsx(o.Box,{sx:{position:"absolute",right:0,top:0,height:"100%",width:8,cursor:"col-resize",zIndex:10,"&:hover":{bgcolor:"primary.light"}},onMouseDown:R=>{R.stopPropagation(),h(R,r.name)},onClick:R=>R.stopPropagation()}),V&&e.jsx(o.Box,{sx:{position:"absolute",left:0,top:0,bottom:0,width:4,bgcolor:"primary.main"}})]}),v&&e.jsx(Bc,{columnName:r.name,columnType:r.type,currentSort:i,hasFilters:a,isInSortStack:c,position:U,onSort:m,onRemoveSort:g,onSortAscending:y,onSortDescending:S,onFilter:C,onClearFilter:x,onHideColumn:E,onManageColumns:s,onManageViews:T,onResetLayout:I,onClose:_})]})});function Ac({selectedCount:t,selectedRowIds:r,searchedData:n,resolvedFavoritesSet:i,onExportSelected:a,onClearSelection:c,onBulkSetFavorites:l}){const[d,f]=u.useState(null),h=u.useMemo(()=>Array.from(r),[r]),m=u.useMemo(()=>h.filter(s=>{const T=n[s];return T!==void 0&&i.has(T)}),[h,n,i]),g=u.useMemo(()=>h.filter(s=>{const T=n[s];return T!==void 0&&!i.has(T)}),[h,n,i]),y=m.length>0,S=g.length>0;if(t===0)return null;const C=()=>{l&&l(h,!0)},x=()=>{l&&l(h,!1)},E=s=>{a(s),f(null)};return e.jsx(o.Box,{sx:{width:"100%",flexShrink:0,bgcolor:s=>N(s.palette.primary.main,.08),borderBottom:s=>`1px solid ${N(s.palette.primary.main,.25)}`,zIndex:10},children:e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:1.25},children:[e.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"primary.main"},children:[t," ",t===1?"row":"rows"," selected"]}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(o.Button,{onClick:c,startIcon:e.jsx(j.Close,{sx:{fontSize:16}}),size:"small",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2,py:.625,borderRadius:"18px",color:"text.secondary","&:hover":{bgcolor:s=>N(s.palette.text.primary,.06),color:"text.primary"}},children:"Clear"}),e.jsx(o.Button,{onClick:s=>f(s.currentTarget),startIcon:e.jsx(j.Download,{sx:{fontSize:16}}),size:"small",variant:"outlined",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2,py:.625,borderRadius:"18px",borderColor:s=>N(s.palette.primary.main,.4),color:"primary.main","&:hover":{borderColor:"primary.main",bgcolor:s=>N(s.palette.primary.main,.06)}},children:"Export Selected"}),e.jsxs(o.Menu,{anchorEl:d,open:!!d,onClose:()=>f(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},PaperProps:{sx:{mt:.5,minWidth:180,borderRadius:1.5}},children:[e.jsx(o.MenuItem,{dense:!0,onClick:()=>E("csv"),sx:{py:1,px:2},children:"Export as CSV"}),e.jsx(o.MenuItem,{dense:!0,onClick:()=>E("excel"),sx:{py:1,px:2},children:"Export as Excel"}),e.jsx(o.MenuItem,{dense:!0,onClick:()=>E("json"),sx:{py:1,px:2},children:"Export as JSON"})]}),l&&S&&e.jsx(o.Button,{onClick:C,startIcon:e.jsx(j.StarBorder,{sx:{fontSize:16}}),size:"small",variant:"outlined",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2,py:.625,borderRadius:"18px",borderColor:s=>N(s.palette.warning.main,.5),color:"warning.dark","&:hover":{borderColor:"warning.main",bgcolor:s=>N(s.palette.warning.main,.06)}},children:"Add to Favorites"}),l&&y&&e.jsx(o.Button,{onClick:x,startIcon:e.jsx(j.Star,{sx:{fontSize:16,color:"#fbbc04"}}),size:"small",variant:"outlined",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2,py:.625,borderRadius:"18px",borderColor:s=>N(s.palette.warning.main,.5),color:"warning.dark","&:hover":{borderColor:"warning.main",bgcolor:s=>N(s.palette.warning.main,.06)}},children:"Remove from Favorites"})]})]})})}const Mc={active:{bg:"#e6f4ea",color:"#137333"},completed:{bg:"#e6f4ea",color:"#137333"},approved:{bg:"#e6f4ea",color:"#137333"},success:{bg:"#e6f4ea",color:"#137333"},done:{bg:"#e6f4ea",color:"#137333"},contract:{bg:"#e8eaf6",color:"#3949ab"},"in progress":{bg:"#e8eaf6",color:"#3949ab"},"in review":{bg:"#e8eaf6",color:"#3949ab"},review:{bg:"#e8eaf6",color:"#3949ab"},pending:{bg:"#e8eaf6",color:"#3949ab"},"on leave":{bg:"#fce8e6",color:"#c5221f"},"on hold":{bg:"#fff8e1",color:"#e65100"},probation:{bg:"#fff8e1",color:"#e65100"},cancelled:{bg:"#fce8e6",color:"#c5221f"},rejected:{bg:"#fce8e6",color:"#c5221f"},blocked:{bg:"#fce8e6",color:"#c5221f"},inactive:{bg:"#f1f3f4",color:"#5f6368"},"not started":{bg:"#f1f3f4",color:"#5f6368"},paused:{bg:"#f1f3f4",color:"#5f6368"}},Rc={low:"#5f6368",medium:"#e65100",high:"#e8710a",critical:"#c5221f",urgent:"#c5221f"};function Wc(t){const r=t.toLowerCase().trim(),n=Mc[r]||{bg:"#f1f3f4",color:"#5f6368"};return e.jsx(o.Box,{component:"span",sx:{display:"inline-flex",alignItems:"center",px:1,py:.25,borderRadius:"10px",fontSize:"0.75rem",fontWeight:500,bgcolor:n.bg,color:n.color,whiteSpace:"nowrap",lineHeight:1.5},children:t})}function Pc(t,r){if(r==null||r==="")return e.jsx(o.Box,{component:"span",sx:{color:"text.disabled",fontSize:"0.8125rem"},children:"—"});const n=String(r),i=t.name.toLowerCase();if(/\b(status|state|stage)\b/.test(i))return Wc(n);if(/\b(priority|severity|urgency)\b/.test(i)){const a=Rc[n.toLowerCase().trim()];return a?e.jsx(o.Box,{component:"span",sx:{color:a,fontWeight:600,fontSize:"0.8125rem"},children:n}):e.jsx(o.Box,{component:"span",sx:{fontSize:"0.8125rem"},children:n})}return typeof r=="boolean"?e.jsx(o.Box,{component:"span",sx:{fontSize:"0.8125rem"},children:r?"Yes":"No"}):typeof r=="object"?e.jsx(o.Box,{component:"span",sx:{fontSize:"0.8125rem"},children:JSON.stringify(r)}):e.jsx(o.Box,{component:"span",sx:{fontSize:"0.8125rem"},children:n})}function _c(t){const r=t.find(a=>{const c=a.name.toLowerCase();return/\b(name|title|label|subject|task_?name|taskname)\b/.test(c)})||t[0]||null,n=t.find(a=>{const c=a.name.toLowerCase().replace(/[\s_-]/g,"");return/(^id$|id$|_id$|taskid|code$|ref$)/.test(c)&&a!==r})||null,i=t.filter(a=>a!==r&&a!==n).slice(0,4);return{primaryCol:r,idCol:n,bodyColumns:i}}function $c({row:t,rowIndex:r,visibleColumns:n,isSelected:i,isFavorite:a,isReadOnly:c,onToggleSelection:l,onToggleFavorite:d,onView:f,onEdit:h,onDuplicate:m,onDelete:g}){const[y,S]=u.useState(null),[C,x]=u.useState(!1),{primaryCol:E,idCol:s,bodyColumns:T}=u.useMemo(()=>_c(n),[n]),I=E?t[E.name]:null,A=s?t[s.name]:null,v=C||i||a||!!y;return e.jsxs(o.Box,{onMouseEnter:()=>x(!0),onMouseLeave:()=>x(!1),onClick:()=>l(r),sx:{position:"relative",display:"flex",flexDirection:"column",bgcolor:"background.paper",border:"1px solid",borderColor:i?"primary.main":W=>N(W.palette.divider,.8),borderWidth:i?2:1,borderRadius:"12px",cursor:"pointer",transition:"box-shadow 0.2s ease, border-color 0.2s ease, transform 0.15s ease",overflow:"hidden",minHeight:180,boxShadow:i?W=>`0 0 0 3px ${N(W.palette.primary.main,.15)}, 0 2px 8px ${N(W.palette.common.black,.08)}`:C?"0 4px 16px rgba(60,64,67,0.15), 0 1px 4px rgba(60,64,67,0.08)":"0 1px 3px rgba(60,64,67,0.08), 0 1px 2px rgba(60,64,67,0.06)",transform:C&&!i?"translateY(-2px)":"none","&:active":{transform:"translateY(0)"},...i&&{bgcolor:W=>N(W.palette.primary.main,.03)}},children:[e.jsx(o.Box,{sx:{px:2,pt:2,pb:1.5},children:e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,fontSize:"0.9375rem",color:"text.primary",lineHeight:1.35,wordBreak:"break-word",letterSpacing:"-0.01em"},children:I!=null&&I!==""?String(I):e.jsx(o.Box,{component:"span",sx:{color:"text.disabled",fontStyle:"italic",fontWeight:400},children:"Untitled"})})}),e.jsx(o.Box,{sx:{mx:2,height:"1px",bgcolor:"divider",flexShrink:0}}),e.jsxs(o.Box,{sx:{px:2,py:1.5,flex:1,display:"flex",flexDirection:"column",gap:1},children:[T.map(W=>e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,minHeight:22},children:[e.jsx(o.Typography,{sx:{color:"text.secondary",fontWeight:500,fontSize:"0.6875rem",textTransform:"uppercase",letterSpacing:"0.06em",minWidth:68,flexShrink:0,lineHeight:1},children:St(W.name)}),e.jsx(o.Box,{sx:{flex:1,lineHeight:1},children:Pc(W,t[W.name])})]},W.name)),T.length===0&&e.jsx(o.Typography,{variant:"caption",color:"text.disabled",sx:{fontStyle:"italic"},children:"No additional fields visible"})]}),e.jsxs(o.Box,{sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid",borderColor:"divider",bgcolor:W=>N(W.palette.action.hover,.1),minHeight:40},children:[e.jsx(o.Typography,{sx:{color:"primary.main",fontFamily:'"Roboto Mono", "Courier New", monospace',fontSize:"0.75rem",fontWeight:400,letterSpacing:"0.04em",opacity:A?.85:0,userSelect:"none"},children:A?String(A):" "}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.25,opacity:v?1:0,transition:"opacity 0.15s ease"},onClick:W=>W.stopPropagation(),children:[d&&e.jsx(o.Tooltip,{title:a?"Remove from favorites":"Add to favorites",placement:"top",children:e.jsx(o.IconButton,{size:"small",onClick:W=>{W.stopPropagation(),d(r)},sx:{width:28,height:28,color:a?"#fbbc04":"action.disabled","&:hover":{bgcolor:W=>N(W.palette.warning.main,.1),color:"#fbbc04"}},children:a?e.jsx(j.Star,{sx:{fontSize:17}}):e.jsx(j.StarBorder,{sx:{fontSize:17}})})}),e.jsx(o.Tooltip,{title:"More actions",placement:"top",children:e.jsx(o.IconButton,{size:"small",onClick:W=>{W.stopPropagation(),S(W.currentTarget)},sx:{width:28,height:28,color:"action.active","&:hover":{bgcolor:W=>N(W.palette.text.primary,.08)}},children:e.jsx(j.MoreVert,{sx:{fontSize:17}})})})]})]}),e.jsxs(o.Popover,{open:!!y,anchorEl:y,onClose:()=>S(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},PaperProps:{sx:{minWidth:180,py:.5,borderRadius:"10px",boxShadow:"0 4px 20px rgba(60,64,67,0.15), 0 1px 6px rgba(60,64,67,0.1)"}},onClick:W=>W.stopPropagation(),children:[e.jsxs(o.MenuItem,{dense:!0,onClick:()=>{f(t),S(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[e.jsx(j.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(o.Typography,{variant:"body2",children:"View"})]}),!c&&e.jsxs(o.MenuItem,{dense:!0,onClick:()=>{h(t,r),S(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[e.jsx(j.Edit,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(o.Typography,{variant:"body2",children:"Edit"})]}),!c&&e.jsxs(o.MenuItem,{dense:!0,onClick:()=>{m(r,t),S(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[e.jsx(j.ContentCopy,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(o.Typography,{variant:"body2",children:"Duplicate"})]}),!c&&e.jsxs(e.Fragment,{children:[e.jsx(o.Divider,{sx:{my:.5,mx:.5}}),e.jsxs(o.MenuItem,{dense:!0,onClick:()=>{g(r,t),S(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5,color:"error.main"},children:[e.jsx(j.Delete,{sx:{fontSize:18,color:"error.main"}}),e.jsx(o.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]})]})]})}function Fc({row:t,grouping:r,onToggleCollapse:n}){var i;return e.jsxs(o.Box,{onClick:()=>n(t.groupKey),sx:{gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:1,px:2,py:1,mt:1,mb:.5,bgcolor:"background.paper",border:"1px solid",borderColor:"divider",borderRadius:"8px",cursor:"pointer",boxShadow:"0 1px 2px rgba(60,64,67,0.06)","&:hover":{bgcolor:a=>N(a.palette.primary.main,.04),borderColor:"primary.light"},transition:"all 0.15s ease"},children:[t.isCollapsed?e.jsx(j.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}):e.jsx(j.KeyboardArrowDown,{sx:{fontSize:16,color:"text.secondary"}}),e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,color:"text.primary"},children:Vn(t.groupLevel,((i=r==null?void 0:r.levels[t.groupLevel])==null?void 0:i.column)||"",t.groupValue)}),e.jsxs(o.Box,{sx:{px:1,py:.125,fontSize:"0.6875rem",fontWeight:600,bgcolor:a=>N(a.palette.primary.main,.1),color:"primary.main",borderRadius:"10px"},children:[t.rowCount," ",t.rowCount===1?"row":"rows"]}),Object.keys(t.aggregates).length>0&&e.jsx(o.Typography,{variant:"caption",sx:{ml:.5,color:"text.secondary"},children:Object.entries(t.aggregates).map(([a,c])=>Nn(c)).filter(Boolean).join(" • ")})]})}function Lc({data:t,visibleColumns:r,grouping:n,selectedRowIds:i,resolvedFavoritesSet:a,isReadOnly:c,isGrouped:l,onToggleRowSelection:d,onToggleRowFavorite:f,onToggleGroupCollapse:h,onViewRow:m,onEditRow:g,onDuplicateRow:y,onDeleteRow:S}){return t.length===0?e.jsx(o.Box,{sx:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",py:10},children:e.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})}):e.jsx(o.Box,{sx:{p:2,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(272px, 1fr))",gap:1.5,alignContent:"start"},children:t.map((C,x)=>l&&C.isGroupHeader?e.jsx(Fc,{row:C,grouping:n,onToggleCollapse:h||(()=>{})},`group-${C.groupKey}`):e.jsx($c,{row:C,rowIndex:x,visibleColumns:r,isSelected:i.has(x),isFavorite:a.has(C),isReadOnly:c,onToggleSelection:d,onToggleFavorite:f,onView:m,onEdit:g,onDuplicate:y,onDelete:S},`card-${x}`))})}const An=[10,15,25,50,100];function Nc({currentPage:t,pageSize:r,totalRows:n,totalFields:i,onPageChange:a,onPageSizeChange:c}){const l=Math.ceil(n/r);if(n<=Math.min(...An))return null;const d=()=>{t>1&&a(t-1)},f=()=>{t<l&&a(t+1)},h=(t-1)*r+1,m=Math.min(t*r,n);return e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:3,px:2,py:1,borderTop:"1px solid",borderColor:"divider",bgcolor:"background.paper",minHeight:48},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:2},children:[e.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400},children:["Total data: ",e.jsx(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:n})]}),i!==void 0&&e.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400},children:["Total fields: ",e.jsx(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:i})]})]}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:3},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400},children:"Rows per page:"}),e.jsx(o.Select,{value:r,onChange:g=>c(Number(g.target.value)),size:"small",MenuProps:{PaperProps:{sx:{maxHeight:300}},anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"}},sx:{minWidth:70,fontSize:"0.8125rem",color:"text.primary","& .MuiSelect-select":{py:.5,px:1.5},"& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"}},children:An.map(g=>e.jsx(o.MenuItem,{value:g,sx:{fontSize:"0.8125rem"},children:g},g))})]}),e.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400},children:[h,"–",m," of ",n]}),e.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400},children:["Page ",t," of ",l]}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(o.IconButton,{onClick:d,disabled:t===1,size:"small",title:"Previous page",sx:{p:.75,color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"action.disabled"}},children:e.jsx(j.ChevronLeft,{sx:{fontSize:20}})}),e.jsx(o.IconButton,{onClick:f,disabled:t===l,size:"small",title:"Next page",sx:{p:.75,color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"action.disabled"}},children:e.jsx(j.ChevronRight,{sx:{fontSize:20}})})]})]})]})}function Vc(){return e.jsx(o.Chip,{icon:e.jsx(j.Visibility,{sx:{fontSize:14}}),label:"View Only",size:"small",variant:"outlined",sx:{bgcolor:"action.hover",borderColor:"divider",fontSize:"caption.fontSize",fontWeight:500}})}function Hc(t,r){if(t==null||t==="")return"—";if(r==="boolean")return t?"True":"False";if(r==="object"||r==="array")try{return JSON.stringify(t,null,2)}catch{return String(t)}return String(t)}function Uc({open:t,onClose:r,row:n,schema:i,reportName:a}){if(!n)return null;const c=i.filter(l=>l.name in n);return e.jsxs(o.Dialog,{open:t,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08)"}},children:[e.jsxs(o.Box,{sx:{px:2,py:1.5,bgcolor:"#fff",borderBottom:"1px solid divider",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(o.Stack,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(j.Visibility,{sx:{fontSize:18,color:"primary.main"}}),e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"0.9375rem",fontWeight:500,color:"#202124"},children:"View Record"})]}),e.jsx(o.IconButton,{size:"small",onClick:r,sx:{p:.5,color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:e.jsx(j.Close,{sx:{fontSize:18}})})]}),e.jsx(o.DialogContent,{sx:{p:0,bgcolor:"grey.50",overflowY:"auto",flex:1},children:e.jsx(o.Box,{children:c.map(l=>{const d=n[l.name],f=Hc(d,l.type),h=f==="—";return e.jsxs(o.Box,{sx:{px:2,py:1.25,borderBottom:"1px solid divider",bgcolor:"#fff",transition:"background-color 0.15s ease","&:hover":{bgcolor:"grey.50"},"&:last-child":{borderBottom:"none"}},children:[e.jsx(o.Typography,{variant:"caption",sx:{color:"#5f6368",fontSize:"0.6875rem",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.02em",display:"block",mb:.5},children:St(l.name)}),e.jsx(o.Typography,{variant:"body2",sx:{color:h?"#9e9e9e":"#202124",fontStyle:h?"italic":"normal",fontSize:"0.875rem",wordBreak:"break-word",whiteSpace:l.type==="object"||l.type==="array"?"pre-wrap":"normal",fontFamily:l.type==="number"?"monospace":"inherit",fontWeight:400,lineHeight:1.5},children:f})]},l.name)})})}),e.jsx(o.DialogActions,{sx:{px:2,py:1.25,borderTop:"1px solid divider",bgcolor:"#fff",gap:1,justifyContent:"flex-end"},children:e.jsx(o.Button,{onClick:r,variant:"contained",sx:{textTransform:"none",fontSize:"0.8125rem",fontWeight:500,bgcolor:"primary.main",color:"#fff",px:2.5,py:.625,minHeight:32,borderRadius:"4px",boxShadow:"none","&:hover":{bgcolor:"primary.dark",boxShadow:"none"}},children:"Close"})})]})}function Gc({open:t,onClose:r,onConfirm:n,rowPreview:i}){return e.jsxs(o.Dialog,{open:t,onClose:r,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",maxHeight:"min(480px, calc(100vh - 180px))",my:"auto",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[e.jsxs(o.Box,{sx:{px:3,pt:2.5,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[e.jsxs(o.Stack,{direction:"row",spacing:1.5,alignItems:"flex-start",children:[e.jsx(o.Box,{sx:{width:40,height:40,borderRadius:"50%",bgcolor:"#fce8e6",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(j.WarningAmberRounded,{sx:{fontSize:22,color:"#d93025"}})}),e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"#202124",letterSpacing:"0",lineHeight:1.5,mb:.5},children:"Delete record?"}),e.jsxs(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"#5f6368"},children:[i?`"${i}"`:"This record"," will be permanently removed."]})]})]}),e.jsx(o.IconButton,{size:"small",onClick:r,sx:{p:.75,color:"#5f6368",transition:"all 0.2s ease","&:hover":{bgcolor:"#f1f3f4",color:"#202124"}},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsx(o.DialogContent,{sx:{px:3,pb:2},children:e.jsx(o.Box,{sx:{p:2,borderRadius:"8px",bgcolor:"#fce8e6",border:"1px solid #f28b82"},children:e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"#d93025",fontWeight:500},children:"This action cannot be undone. The record will be deleted from this report immediately."})})}),e.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid #e8eaed",bgcolor:"grey.50",gap:1.25,justifyContent:"flex-end"},children:[e.jsx(o.Button,{onClick:r,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"#5f6368",px:3,py:.875,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"#e8eaed",color:"#202124"}},children:"Cancel"}),e.jsx(o.Button,{onClick:()=>{n(),r()},variant:"contained",startIcon:e.jsx(j.DeleteForever,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#d93025",color:"#ffffff",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#b3190e",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Delete record"})]})]})}function Yc({open:t,onClose:r,onSave:n,row:i,schema:a,reportName:c}){const[l,d]=u.useState({});if(u.useEffect(()=>{t&&i&&d({...i})},[t,i]),!i)return null;const f=a.filter(y=>y.name in i),h=(y,S)=>{d(C=>({...C,[y]:S}))},m=()=>{const y={...l};f.forEach(S=>{const C=l[S.name];if(S.type==="number"){const x=Number(C);y[S.name]=isNaN(x)?i[S.name]:x}else S.type==="boolean"&&(y[S.name]=!!C)}),n(y),r()},g=y=>{const S=l[y.name],C=St(y.name);return y.type==="boolean"?e.jsx(o.FormControlLabel,{control:e.jsx(o.Switch,{checked:!!S,onChange:x=>h(y.name,x.target.checked),size:"small",sx:{"& .MuiSwitch-switchBase.Mui-checked":{color:"primary.main"},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{bgcolor:"primary.main"}}}),label:e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.primary",fontWeight:500},children:C}),sx:{m:0,bgcolor:"#fff",px:2,py:1,borderRadius:"4px",border:"1px solid #dadce0"}},y.name):e.jsx(o.TextField,{label:C,value:S??"",onChange:x=>h(y.name,x.target.value),type:y.type==="number"?"number":"text",size:"small",fullWidth:!0,variant:"outlined",InputLabelProps:y.type==="string"&&String(S).match(/^\d{4}-\d{2}-\d{2}/)?{shrink:!0}:void 0,sx:{"& .MuiOutlinedInput-root":{fontSize:"0.8125rem",borderRadius:"4px",bgcolor:"#ffffff","& fieldset":{borderColor:"#dadce0"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputLabel-root":{fontSize:"0.8125rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiInputBase-input":{color:"text.primary",py:1}}},y.name)};return e.jsxs(o.Dialog,{open:t,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08)"}},children:[e.jsxs(o.Box,{sx:{px:2,py:1.5,bgcolor:"#fff",borderBottom:"1px solid divider",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(o.Stack,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(j.Edit,{sx:{fontSize:18,color:"#ea8600"}}),e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"0.9375rem",fontWeight:500,color:"#202124"},children:"Edit Record"})]}),e.jsx(o.IconButton,{size:"small",onClick:r,sx:{p:.5,color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:e.jsx(j.Close,{sx:{fontSize:18}})})]}),e.jsx(o.DialogContent,{sx:{p:2,bgcolor:"grey.50",overflowY:"auto",flex:1},children:e.jsx(o.Stack,{spacing:1.5,children:f.map(y=>e.jsx(o.Box,{children:g(y)},y.name))})}),e.jsxs(o.DialogActions,{sx:{px:2,py:1.25,borderTop:"1px solid divider",bgcolor:"#fff",gap:1,justifyContent:"flex-end"},children:[e.jsx(o.Button,{onClick:r,variant:"text",sx:{textTransform:"none",fontSize:"0.8125rem",fontWeight:500,color:"text.secondary",px:2,py:.625,minHeight:32,"&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),e.jsx(o.Button,{onClick:m,variant:"contained",startIcon:e.jsx(j.Save,{sx:{fontSize:16}}),sx:{textTransform:"none",fontSize:"0.8125rem",fontWeight:500,bgcolor:"primary.main",color:"#fff",px:2.5,py:.625,minHeight:32,borderRadius:"4px",boxShadow:"none","&:hover":{bgcolor:"primary.dark",boxShadow:"none"}},children:"Save"})]})]})}const Jc=160,qc={active:{bg:"#e6f4ea",color:"#137333"},completed:{bg:"#e6f4ea",color:"#137333"},approved:{bg:"#e6f4ea",color:"#137333"},success:{bg:"#e6f4ea",color:"#137333"},done:{bg:"#e6f4ea",color:"#137333"},contract:{bg:"#e8eaf6",color:"#2932e5"},"in progress":{bg:"#e8eaf6",color:"#2932e5"},"in review":{bg:"#e8eaf6",color:"#2932e5"},review:{bg:"#e8eaf6",color:"#2932e5"},pending:{bg:"#e8eaf6",color:"#2932e5"},"on leave":{bg:"#fce8e6",color:"#c5221f"},"on hold":{bg:"#fef7e0",color:"#b06000"},probation:{bg:"#fef7e0",color:"#b06000"},cancelled:{bg:"#fce8e6",color:"#c5221f"},rejected:{bg:"#fce8e6",color:"#c5221f"},blocked:{bg:"#fce8e6",color:"#c5221f"},inactive:{bg:"#f1f3f4",color:"#5f6368"},"not started":{bg:"#f1f3f4",color:"#5f6368"},paused:{bg:"#f1f3f4",color:"#5f6368"}},Kc={low:"#5f6368",medium:"#b06000",high:"#e8710a",critical:"#c5221f",urgent:"#c5221f"};function Xc(t){const r=t.toLowerCase().trim(),n=qc[r]||{bg:"grey.100",color:"grey.600"};return e.jsx(o.Box,{component:"span",sx:{display:"inline-flex",alignItems:"center",px:1.25,py:.375,borderRadius:"12px",fontSize:"0.75rem",fontWeight:500,bgcolor:n.bg,color:n.color,whiteSpace:"nowrap",lineHeight:1.6,letterSpacing:"0.01em"},children:t})}function Qc(t){const r=t.toLowerCase().trim(),n=Kc[r];return n?e.jsx(o.Box,{component:"span",sx:{color:n,fontWeight:500,fontSize:"inherit"},children:t}):t}function Zc(t){return e.jsx(o.Box,{component:"span",sx:{color:"primary.main",fontFamily:'"Roboto Mono", "Courier New", monospace',fontSize:"0.8125rem",fontWeight:400,letterSpacing:"0.04em"},children:t})}function ed(t,r){const n=t.name.toLowerCase().replace(/[_\s-]/g,""),i=t.name.toLowerCase(),a=r.findIndex(h=>h.name===t.name),c=/(\bid\b|id$|_id$|code$|ref$|no$|num$)/.test(n),l=i.includes("name")||i.includes("task")||i.includes("title")||i.includes("label")||i.includes("subject")||i.includes("description")||i.includes("filename"),d=i.includes("assignee")||i.includes("assigned")||i.includes("owner")||i.includes("author")||i.includes("creator")||i.includes("member")||i.includes("contact")||i.includes("recipient")||i.includes("sender"),f=a===0&&t.type!=="boolean"&&!i.includes("status")&&!i.includes("state");return c||l&&!d||f&&!d}function td(t){return e.jsx(o.Box,{component:"span",sx:{fontWeight:700,color:"text.primary",fontSize:"inherit"},children:t})}function rd(t,r,n=!1){if(r==null||r==="")return e.jsx(o.Box,{component:"span",sx:{color:"grey.400"},children:"—"});const i=String(r),a=t.name.toLowerCase().replace(/[_\s-]/g,""),c=/\b(status|state|stage|employmenttype|contracttype|availability)\b/.test(t.name.toLowerCase());if(c)return Xc(i);const l=/\b(priority|severity|urgency|importance|criticality)\b/.test(t.name.toLowerCase());if(l)return Qc(i);const d=/(\bid\b|id$|_id$|code$|ref$|no$|num$)/.test(a)||/^[A-Z]{2,8}-\d{2,}$/.test(i);return d?Zc(i):n&&!c&&!l&&!d?td(i):t.type==="number"&&typeof r=="number"?r.toLocaleString():typeof r=="boolean"?r?"Yes":"No":typeof r=="object"?JSON.stringify(r):i}function od({schema:t,data:r,sortStack:n=[],filters:i=[],views:a=[],activeViewId:c="",isDirty:l=!1,isExporting:d=!1,columnVisibility:f={},columnOrder:h=[],columnWidths:m={},grouping:g=null,onSort:y,onSortAscending:S,onSortDescending:C,onOpenFilters:x,onOpenSort:E,onOpenFilterForColumn:s,onSelectView:T,onCreateView:I,onManageViews:A,onUpdateCurrentView:v,onSaveAsNewView:W,onToggleDefault:U,onToggleFavorite:w,onRestoreView:O,onPermanentDelete:V,onExport:X,onOpenColumns:p,onUpdateColumnWidth:L,onUpdateColumnOrder:$,onUpdateColumnVisibility:_,onClearFiltersForColumn:F,onResetLayout:oe,onOpenGroup:ue,onToggleGroupCollapse:Ee,onOpenAuditHistory:R,onOpenSharePreset:q,searchQuery:ee,searchHistory:te=[],onAddToSearchHistory:re,onToggleSearchFavourite:ne,onDeleteSearchHistory:Z,selectedRowIds:Q=new Set,onSearchChange:ae,onToggleRowSelection:ce,onToggleAllRows:le,onRangeSelection:je,onClearSelection:G,onExportSelected:Me,currentPage:Ye=1,pageSize:jt=15,totalRowsBeforePagination:tt=r.length,onPageChange:$e,onPageSizeChange:Je,isReadOnly:Ae=!1,userRole:wt,reportName:Yt,onEditRow:pt,onDuplicateRow:rt,onDeleteRow:kt,favoriteRowIndices:Tt=[],resolvedFavoritesSet:ft=new Set,showFavoritesOnly:Fe=!1,onToggleRowFavorite:qe,onBulkSetFavorites:Jt,showDevPanel:Be=!1,onOpenDevConfig:zt,onToggleFavoritesFilter:Ke}){const[ot,qt]=u.useState(null),[xt,Pr]=u.useState(0),[mr,nt]=u.useState(0),[_t,gr]=u.useState(null),[$t,It]=u.useState(null),[Ce,Et]=u.useState(null),[yr,Ve]=u.useState(!1),[P,He]=u.useState(!1),[de,Re]=u.useState(null),[br,Ft]=u.useState(""),[Bt,Lt]=u.useState(!1),[Nt,ht]=u.useState(null),[Kt,Vt]=u.useState(null),[ie,H]=u.useState(null),[it,xe]=u.useState(null),[Le,Xt]=u.useState("list"),[vr,Qt]=u.useState(!1);u.useRef(null);const Zt=u.useMemo(()=>h.length>0?h.map(D=>t.find(Y=>Y.name===D)).filter(D=>D!==void 0):t,[h,t]),Ne=u.useMemo(()=>Zt.filter(D=>f[D.name]!==!1),[Zt,f]),st=u.useMemo(()=>t.filter(D=>f[D.name]===!1).length,[t,f]),er=u.useMemo(()=>t.map(D=>D.name),[t]),mt=u.useMemo(()=>JSON.stringify(h)!==JSON.stringify(er),[h,er]),Sr=u.useCallback((D,Y)=>{D.preventDefault(),D.stopPropagation(),qt(Y),Pr(D.clientX),nt(m[Y]||150)},[m]);u.useEffect(()=>{if(!ot)return;const D=pe=>{const Pe=pe.clientX-xt,se=Math.max(100,mr+Pe);L==null||L(ot,se)},Y=()=>{qt(null)};return document.addEventListener("mousemove",D),document.addEventListener("mouseup",Y),()=>{document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",Y)}},[ot,xt,mr,L]);const tr=u.useCallback(D=>D==null?"-":typeof D=="object"?JSON.stringify(D):typeof D=="boolean"?D?"true":"false":String(D),[]);u.useCallback(D=>{const Y=n.find(pe=>pe.column===D);return Y?e.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[Y.direction==="asc"?e.jsx(j.ArrowUpward,{sx:{fontSize:14}}):e.jsx(j.ArrowDownward,{sx:{fontSize:14}}),e.jsx(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center",width:16,height:16,bgcolor:"primary.main",color:"primary.contrastText",fontSize:"caption.fontSize",fontWeight:"bold",borderRadius:"50%"},children:Y.priority})]}):null},[n]),u.useCallback(D=>i.some(pe=>pe.column===D)?e.jsx(o.IconButton,{size:"small",onClick:pe=>{pe.stopPropagation(),s==null||s(D)},sx:{ml:.5,p:.25,color:"primary.main","&:hover":{color:"primary.main"}},title:"Active filters on this column",children:e.jsx(j.FilterList,{sx:{fontSize:14}})}):null,[i,s]);const rr=u.useCallback(D=>{y&&y(D)},[y]),or=u.useCallback((D,Y)=>{if(!$)return;const pe=[...h.length>0?h:t.map(se=>se.name)],[Pe]=pe.splice(D,1);pe.splice(Y,0,Pe),$(pe)},[$,h,t]),Cr=u.useCallback(D=>{if(!y)return;const Y=n.find(pe=>pe.column===D);(!Y||Y.direction!=="asc")&&y(D)},[y,n]),gt=u.useCallback(D=>{if(!y)return;const Y=n.find(pe=>pe.column===D);Y?Y.direction==="asc"&&y(D):(y(D),setTimeout(()=>y(D),0))},[y,n]),at=u.useCallback(D=>{if(!y)return;const Y=n.find(pe=>pe.column===D);Y&&(Y.direction==="asc"?(y(D),setTimeout(()=>y(D),0)):Y.direction==="desc"&&y(D))},[y,n]),nr=u.useCallback(D=>{_&&_(D,!1)},[_]),ir=(g==null?void 0:g.enabled)&&r.length>0&&r[0]&&"isGroupHeader"in r[0],sr=u.useMemo(()=>Ne.map(D=>D.name),[Ne]),We=u.useMemo(()=>ee&&ee.trim()?Xn(r,t,ee,sr):r,[r,t,ee,sr]);u.useEffect(()=>{const D=Y=>{!le||!G||Y.target instanceof HTMLInputElement||Y.target instanceof HTMLTextAreaElement||((Y.ctrlKey||Y.metaKey)&&Y.key==="a"&&(Y.preventDefault(),le(!0,We.length)),Y.key==="Escape"&&(Y.preventDefault(),G()))};return document.addEventListener("keydown",D),()=>document.removeEventListener("keydown",D)},[le,G,We.length]);const ar=u.useCallback((D,Y)=>{ce&&(Y.shiftKey&&_t!==null?(Y.preventDefault(),je&&je(_t,D)):(ce(D),gr(D)))},[ce,_t,je]),jr=u.useMemo(()=>We.length>0&&Q.size>0&&We.every((D,Y)=>Q.has(Y)),[We,Q]);Q.size>0;const Dt=ce&&le,wr=u.useCallback(D=>{var Pe;const Y=D.groupLevel,pe=Y*24;return e.jsx(o.TableRow,{onClick:()=>Ee==null?void 0:Ee(D.groupKey),sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"},cursor:"pointer",borderTop:2,borderColor:"divider"},children:e.jsx(o.TableCell,{colSpan:Ne.length+(Dt?1:0),sx:{pl:`${pe+24}px`},children:e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[D.isCollapsed?e.jsx(j.ChevronRight,{sx:{fontSize:16}}):e.jsx(j.KeyboardArrowDown,{sx:{fontSize:16}}),e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:Vn(Y,((Pe=g==null?void 0:g.levels[Y])==null?void 0:Pe.column)||"",D.groupValue)}),e.jsxs(o.Box,{sx:{px:1,py:.25,fontSize:"caption.fontSize",fontWeight:500,bgcolor:se=>N(se.palette.primary.main,.12),color:"primary.main",borderRadius:2},children:[D.rowCount," ",D.rowCount===1?"row":"rows"]}),Object.keys(D.aggregates).length>0&&e.jsx(o.Typography,{variant:"caption",sx:{ml:1,color:"text.secondary"},children:Object.entries(D.aggregates).map(([se,Ot])=>Nn(Ot)).filter(Boolean).join(" • ")})]})})},D.groupKey)},[Ne,Dt,g,Ee]),lr=u.useCallback((D,Y)=>{const pe=Q.has(Y),Pe=$t===Y;return e.jsxs(o.TableRow,{"data-row-index":Y,onMouseEnter:()=>It(Y),onMouseLeave:()=>It(null),onClick:se=>{!ce||se.target.closest("[data-row-action]")||ar(Y,se)},onContextMenu:se=>{se.preventDefault(),se.stopPropagation(),H({mouseX:se.clientX,mouseY:se.clientY,row:D,rowIndex:Y})},sx:{height:34,cursor:"pointer",bgcolor:pe?se=>N(se.palette.warning.main,.12):"background.paper",transition:"background-color 0.12s ease","&:hover":{bgcolor:pe?se=>N(se.palette.warning.main,.2):"#f8f9fa"},borderBottom:"1px solid",borderColor:"#e0e0e0"},children:[Ne.map((se,Ot)=>e.jsx(o.TableCell,{sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",py:"6px",px:2,fontSize:"0.8125rem",fontWeight:400,color:"#202124",borderBottom:"none",minWidth:m[se.name]?`${m[se.name]}px`:`${Jc}px`},children:rd(se,D[se.name],ed(se,Ne))},se.name)),e.jsxs(o.TableCell,{"data-row-action":"true",onClick:se=>se.stopPropagation(),sx:{position:"sticky",right:0,width:qe?76:40,minWidth:qe?76:40,maxWidth:qe?76:40,p:0,border:"none",bgcolor:"transparent",opacity:Pe?1:0,transition:"opacity 0.12s ease",zIndex:2,verticalAlign:"middle",display:"flex",alignItems:"center",justifyContent:"flex-end",gap:.25},children:[qe&&e.jsx(o.IconButton,{size:"small",onClick:se=>{se.stopPropagation(),se.preventDefault(),qe(Y)},title:ft.has(D)?"Remove from favorites":"Add to favorites",sx:{color:ft.has(D)?"#fbbc04":"text.secondary","&:hover":{bgcolor:se=>N(se.palette.warning.main,.08),color:"#fbbc04"}},children:ft.has(D)?e.jsx(j.Star,{sx:{fontSize:18}}):e.jsx(j.StarBorder,{sx:{fontSize:18}})}),e.jsx(o.IconButton,{size:"small",onClick:se=>{se.stopPropagation(),se.preventDefault(),H({anchorEl:se.currentTarget,row:D,rowIndex:Y})},sx:{color:"text.secondary","&:hover":{bgcolor:se=>N(se.palette.text.primary,.08),color:"text.primary"}},children:e.jsx(j.MoreVert,{sx:{fontSize:18}})})]})]},Y)},[Q,$t,ar,Ne,m,tr,pt,rt,kt,ce,Et,Ve,H]);return e.jsxs(vt.DndProvider,{backend:zo.HTML5Backend,children:[e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:[Dt&&Me&&G&&e.jsx(Ac,{selectedCount:Q.size,selectedRowIds:Q,searchedData:We,resolvedFavoritesSet:ft,onExportSelected:Me,onClearSelection:G,onBulkSetFavorites:Jt}),e.jsxs(o.Box,{sx:{position:"sticky",top:0,zIndex:10,bgcolor:"background.paper",borderBottom:"1px solid",borderColor:"divider",px:2,py:0,height:56,display:"flex",alignItems:"center",gap:1},children:[Ae&&e.jsx(Vc,{}),ae&&re&&ne&&Z&&e.jsx(Ic,{value:ee||"",onChange:ae,searchHistory:te,onAddToHistory:re,onToggleFavourite:ne,onDeleteHistory:Z,disabled:Ae}),e.jsx(o.Tooltip,{title:"JSON format guide",children:e.jsx(o.IconButton,{size:"small",onClick:()=>Qt(!0),sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:D=>N(D.palette.text.primary,.06),color:"text.primary"}},children:e.jsx(j.InfoOutlined,{sx:{fontSize:20}})})}),Ke&&e.jsx(o.Tooltip,{title:Fe?"Show all data":"Show favorites only",children:e.jsxs(o.IconButton,{onClick:Ke,size:"small",disabled:Ae,sx:{position:"relative",color:Fe?"warning.main":"text.secondary",bgcolor:Fe?D=>N(D.palette.warning.main,.12):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:Fe?D=>N(D.palette.warning.main,.2):D=>N(D.palette.text.primary,.06),color:Fe?"warning.main":"text.primary"},"&.Mui-disabled":{color:"action.disabled"}},children:[Fe?e.jsx(j.Star,{sx:{fontSize:20}}):e.jsx(j.StarBorder,{sx:{fontSize:20}}),Fe&&Tt.length>0&&e.jsx(o.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"warning.main",color:"#fff",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:Tt.length})]})}),Be&&zt&&e.jsx(o.Tooltip,{title:"Developer configuration",children:e.jsx(o.IconButton,{size:"small",onClick:zt,sx:{color:"text.secondary",borderRadius:1,border:"1px dashed",borderColor:D=>N(D.palette.text.secondary,.3),"&:hover":{bgcolor:D=>N(D.palette.warning.main,.08),borderColor:"warning.main",color:"warning.dark"}},children:e.jsx(j.DisplaySettings,{sx:{fontSize:20}})})}),e.jsx(o.Box,{sx:{flexGrow:1}}),T&&I&&A&&v&&a.length>0&&e.jsx(Ec,{views:a||[],activeViewId:c||"",isDirty:l,onSelectView:T,onCreateView:I,onManageViews:A,onToggleDefault:U,onToggleFavorite:w,onRestoreView:O,onPermanentDelete:V,isReadOnly:Ae}),!Ae&&E&&e.jsx(o.Tooltip,{title:"Sort",children:e.jsxs(o.IconButton,{onClick:E,size:"small",sx:{position:"relative",color:n.length>0?"primary.main":"text.secondary",bgcolor:n.length>0?"primary.lighter":"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:n.length>0?D=>N(D.palette.primary.main,.2):D=>N(D.palette.text.primary,.06),color:n.length>0?"primary.main":"text.primary"}},children:[e.jsx(j.SwapVert,{sx:{fontSize:20}}),n.length>0&&e.jsx(o.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"primary.main",color:"#fff",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:n.length})]})}),!Ae&&x&&e.jsx(o.Tooltip,{title:"Filter",children:e.jsxs(o.IconButton,{onClick:x,size:"small",sx:{position:"relative",color:i.length>0?"primary.main":"text.secondary",bgcolor:i.length>0?"primary.lighter":"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:i.length>0?D=>N(D.palette.primary.main,.2):D=>N(D.palette.text.primary,.06),color:i.length>0?"primary.main":"text.primary"}},children:[e.jsx(j.FilterList,{sx:{fontSize:20}}),i.length>0&&e.jsx(o.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"primary.main",color:"#fff",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:i.length})]})}),!Ae&&p&&e.jsx(o.Tooltip,{title:"Columns",children:e.jsxs(o.IconButton,{onClick:p,size:"small",sx:{position:"relative",color:st>0||mt?"primary.main":"text.secondary",bgcolor:st>0||mt?"primary.lighter":"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:st>0||mt?D=>N(D.palette.primary.main,.2):D=>N(D.palette.text.primary,.06),color:st>0||mt?"primary.main":"text.primary"}},children:[e.jsx(j.ViewColumn,{sx:{fontSize:20}}),st>0&&e.jsx(o.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"primary.main",color:"#fff",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:st})]})}),e.jsx(o.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5,my:1.5}}),e.jsx(o.Tooltip,{title:"List view",children:e.jsx(o.IconButton,{size:"small",onClick:()=>Xt("list"),sx:{borderRadius:1,color:Le==="list"?"primary.main":"text.secondary",bgcolor:Le==="list"?"primary.lighter":"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:Le==="list"?D=>N(D.palette.primary.main,.2):D=>N(D.palette.text.primary,.06),color:Le==="list"?"primary.main":"text.primary"}},children:e.jsx(j.TableRows,{sx:{fontSize:20}})})}),e.jsx(o.Tooltip,{title:"Grid view",children:e.jsx(o.IconButton,{size:"small",onClick:()=>Xt("grid"),sx:{borderRadius:1,color:Le==="grid"?"primary.main":"text.secondary",bgcolor:Le==="grid"?"primary.lighter":"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:Le==="grid"?D=>N(D.palette.primary.main,.2):D=>N(D.palette.text.primary,.06),color:Le==="grid"?"primary.main":"text.primary"}},children:e.jsx(j.GridView,{sx:{fontSize:20}})})}),e.jsx(o.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5,my:1.5}}),e.jsx(o.Tooltip,{title:"Settings",children:e.jsx(o.IconButton,{onClick:D=>xe(D.currentTarget),size:"small",sx:{color:"text.secondary",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:D=>N(D.palette.text.primary,.06),color:"text.primary"}},children:e.jsx(j.Settings,{sx:{fontSize:20}})})})]}),e.jsxs(o.Popover,{open:!!it,anchorEl:it,onClose:()=>xe(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},PaperProps:{sx:{mt:.5,minWidth:200,py:.5,borderRadius:1.5,boxShadow:3}},children:[X&&e.jsxs(o.MenuItem,{dense:!0,onClick:()=>{X(),xe(null)},disabled:d,sx:{py:1,px:2,gap:1.5},children:[e.jsx(j.Download,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(o.Typography,{variant:"body2",children:"Export"})]}),!Ae&&ue&&e.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ue(),xe(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(j.Layers,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(o.Typography,{variant:"body2",children:"Grouping"})]}),R&&e.jsxs(o.MenuItem,{dense:!0,onClick:()=>{R(),xe(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(j.History,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(o.Typography,{variant:"body2",children:"Audit History"})]}),q&&e.jsxs(o.MenuItem,{dense:!0,onClick:()=>{q(),xe(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(j.Share,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(o.Typography,{variant:"body2",children:"Share Report State"})]})]}),e.jsxs(o.Box,{sx:{position:"relative",overflow:"hidden",flex:1,display:"flex",flexDirection:"column"},children:[Le==="grid"&&e.jsx(o.Box,{sx:{flex:1,overflowY:"auto",overflowX:"hidden",bgcolor:D=>N("#d8dee4",.2)},children:e.jsx(Lc,{data:We,visibleColumns:Ne,grouping:g,selectedRowIds:Q,resolvedFavoritesSet:ft,isReadOnly:Ae,isGrouped:!!ir,onToggleRowSelection:ce||(()=>{}),onToggleRowFavorite:qe,onToggleGroupCollapse:Ee,onViewRow:D=>{Et(D),Ve(!0)},onEditRow:(D,Y)=>{ht(D),Vt(Y),Lt(!0)},onDuplicateRow:(D,Y)=>rt==null?void 0:rt(D,Y),onDeleteRow:(D,Y)=>{Re(D);const pe=Object.values(Y).find(Pe=>Pe!=null&&Pe!=="");Ft(pe?String(pe):""),He(!0)}})}),Le==="list"&&e.jsx(o.Box,{sx:{flex:1,overflowY:"auto",overflowX:"auto",position:"relative",bgcolor:"background.paper","&::-webkit-scrollbar":{width:8,height:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:D=>D.palette.mode==="dark"?"rgba(255,255,255,0.2)":"rgba(0,0,0,0.2)",borderRadius:4,"&:hover":{bgcolor:D=>D.palette.mode==="dark"?"rgba(255,255,255,0.3)":"rgba(0,0,0,0.3)"}}},children:e.jsxs(o.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",width:"100%",minWidth:"100%"},stickyHeader:!0,children:[e.jsx(o.TableHead,{children:e.jsxs(o.TableRow,{sx:{height:34,bgcolor:"#f5f5f5",borderBottom:"1px solid",borderColor:"#e0e0e0"},children:[Ne.map((D,Y)=>e.jsx(Oc,{column:D,index:Y,sortRule:n.find(pe=>pe.column===D.name),hasFilters:i.some(pe=>pe.column===D.name),isInSortStack:n.some(pe=>pe.column===D.name),width:m[D.name],onColumnClick:rr,onMoveColumn:or,onResizeStart:Sr,onSort:rr,onRemoveSort:at,onSortAscending:Cr,onSortDescending:gt,onOpenFilterForColumn:s||(()=>{}),onClearFiltersForColumn:F||(()=>{}),onHideColumn:nr,onManageColumns:p||(()=>{}),onManageViews:A||(()=>{}),onResetLayout:oe||(()=>{})},D.name)),e.jsx(o.TableCell,{sx:{position:"sticky",top:0,right:0,width:qe?76:40,minWidth:qe?76:40,p:0,border:"none",bgcolor:"#f5f5f5",borderBottom:"1px solid",borderColor:"#e0e0e0",zIndex:6}})]})}),e.jsx(o.TableBody,{children:We.length===0?e.jsx(o.TableRow,{children:e.jsx(o.TableCell,{colSpan:Ne.length+(Dt?1:0),align:"center",sx:{py:4},children:e.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})})}):ir?We.map((D,Y)=>D.isGroupHeader?wr(D):lr(D,Y)):We.map((D,Y)=>lr(D,Y))})]})}),$e&&Je&&e.jsx(Nc,{currentPage:Ye,pageSize:jt,totalRows:tt,totalFields:t.length,onPageChange:$e,onPageSizeChange:Je}),!($e&&Je)&&e.jsx(o.Box,{sx:{px:3,py:1.5,bgcolor:"action.hover",borderTop:1,borderColor:"divider"},children:e.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["Showing ",We.length," ",We.length===1?"row":"rows"]})})]})]}),e.jsxs(o.Popover,{open:!!ie,onClose:()=>H(null),anchorEl:(ie==null?void 0:ie.anchorEl)||null,anchorReference:ie!=null&&ie.anchorEl?"anchorEl":"anchorPosition",anchorPosition:ie&&!ie.anchorEl?{top:ie.mouseY,left:ie.mouseX}:void 0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:ie!=null&&ie.anchorEl?{vertical:"top",horizontal:"right"}:{vertical:"top",horizontal:"left"},PaperProps:{sx:{minWidth:176,py:.5,borderRadius:1.5,boxShadow:3}},children:[e.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ie&&(Et(ie.row),Ve(!0)),H(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(j.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(o.Typography,{variant:"body2",children:"View"})]}),e.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ie&&(ht(ie.row),Vt(ie.rowIndex),Lt(!0)),H(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(j.Edit,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(o.Typography,{variant:"body2",children:"Edit"})]}),e.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ie&&(rt==null||rt(ie.rowIndex,ie.row)),H(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(j.ContentCopy,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(o.Typography,{variant:"body2",children:"Duplicate"})]}),e.jsx(o.Divider,{sx:{my:.5}}),e.jsxs(o.MenuItem,{dense:!0,onClick:()=>{if(ie){Re(ie.rowIndex);const D=Object.values(ie.row).find(Y=>Y!=null&&Y!=="");Ft(D?String(D):""),He(!0)}H(null)},sx:{py:1,px:2,gap:1.5,color:"error.main"},children:[e.jsx(j.Delete,{sx:{fontSize:18,color:"error.main"}}),e.jsx(o.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]}),e.jsx(Uc,{open:yr,onClose:()=>{Ve(!1),Et(null)},row:Ce,schema:t,reportName:Yt}),e.jsx(Yc,{open:Bt,onClose:()=>{Lt(!1),ht(null),Vt(null)},onSave:D=>{Kt!==null&&(pt==null||pt(Kt,D))},row:Nt,schema:t,reportName:Yt}),e.jsx(Gc,{open:P,onClose:()=>{He(!1),Re(null)},onConfirm:()=>{de!==null&&(kt==null||kt(de))},rowPreview:br}),e.jsx(mi,{isOpen:vr,onClose:()=>Qt(!1)})]})}function nd({schema:t,filters:r,onAddFilter:n,onRemoveFilter:i,onUpdateFilter:a,onClearAll:c,onClose:l,focusColumn:d}){const[f,h]=u.useState(""),[m,g]=u.useState(""),[y,S]=u.useState(""),[C,x]=u.useState([]),E=Mr();u.useEffect(()=>{x([...r])},[r]),u.useEffect(()=>{d&&h(d)},[d]);const s=u.useCallback(()=>{h(""),g(""),S("")},[]),T=u.useMemo(()=>t.filter(p=>p.type!=="mixed"&&p.type!=="null"&&p.type!=="array"&&p.type!=="object"),[t]),I=t.find(p=>p.name===f),A=u.useMemo(()=>{const p=I?rn(I.type):[],L=E.filter.allowedOperators;return L.length>0?p.filter($=>L.includes($.value)):p},[I]),v=u.useCallback(()=>!(!f||!m||Nr(m)&&!y.trim()||C.length>=E.filter.maxConditions),[f,m,y,C,E]),W=u.useCallback(()=>{if(!v())return;const p={column:f,operator:m};if(Nr(m)){const $=I==null?void 0:I.type;p.value=$==="number"?Number(y):y}if(C.some($=>$.column===p.column&&$.operator===p.operator&&$.value===p.value)){s();return}x([...C,p]),s()},[v,f,m,I,y,C,s]),U=u.useCallback(p=>{x(C.filter((L,$)=>$!==p))},[C]),w=u.useMemo(()=>C.length!==r.length?!0:JSON.stringify(C)!==JSON.stringify(r),[C,r]),O=u.useCallback(()=>{c(),C.forEach(p=>n(p)),l()},[C,n,c,l]),V=u.useCallback(()=>{x([...r]),s(),l()},[r,s,l]),X=u.useCallback(p=>{var F;const L=t.find(oe=>oe.name===p.column);if(!L)return"";const _=((F=rn(L.type).find(oe=>oe.value===p.operator))==null?void 0:F.label)||p.operator;return Nr(p.operator)?`${p.column} ${_.toLowerCase()} "${p.value}"`:`${p.column} ${_.toLowerCase()}`},[t]);return e.jsx(o.Box,{onClick:V,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(o.Paper,{onClick:p=>p.stopPropagation(),elevation:0,sx:{position:"relative",width:520,maxWidth:"calc(100vw - 120px)",maxHeight:"min(520px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"background.paper",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Filter columns"}),e.jsx(o.IconButton,{onClick:V,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"grey.100",color:"text.primary"}},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsxs(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"grey.300",borderRadius:4,"&:hover":{bgcolor:"grey.400"}}},children:[e.jsxs(o.Box,{sx:{mb:2.5},children:[e.jsx(o.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add filter"}),e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.75},children:[e.jsxs(o.FormControl,{size:"small",fullWidth:!0,children:[e.jsx(o.InputLabel,{sx:{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},children:"Column"}),e.jsx(o.Select,{value:f,onChange:p=>{h(p.target.value),g(""),S("")},label:"Column",sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"grey.300",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"}},children:T.map(p=>e.jsxs(o.MenuItem,{value:p.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:L=>N(L.palette.primary.main,.2)}}},children:[St(p.name)," (",p.type,")"]},p.name))})]}),f&&e.jsxs(o.FormControl,{size:"small",fullWidth:!0,children:[e.jsx(o.InputLabel,{sx:{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},children:"Operator"}),e.jsx(o.Select,{value:m,onChange:p=>{g(p.target.value),S("")},label:"Operator",sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"grey.300",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"}},children:A.map(p=>e.jsx(o.MenuItem,{value:p.value,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:L=>N(L.palette.primary.main,.2)}}},children:p.label},p.value))})]}),m&&Nr(m)&&e.jsx(o.TextField,{size:"small",fullWidth:!0,type:(I==null?void 0:I.type)==="number"?"number":"text",value:y,onChange:p=>S(p.target.value),label:"Value",placeholder:"Enter value...",sx:{"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"grey.300",transition:"border-color 0.2s ease"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputBase-input":{py:1,color:"text.primary"}}})]}),e.jsx(o.Button,{onClick:W,disabled:!v(),sx:{mt:1.5,textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"primary.main",p:0,justifyContent:"flex-start",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"primary.dark",textDecoration:"underline"},"&.Mui-disabled":{color:"grey.400"}},children:"+ Add another filter"})]}),C.length>0&&e.jsxs(o.Box,{children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1.5},children:[e.jsxs(o.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:["Active filters (",C.length,")"]}),e.jsx(o.Button,{onClick:()=>x([]),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"error.main",p:0,minWidth:"auto",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"#b3190e",textDecoration:"underline"}},children:"Clear all"})]}),e.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:C.map((p,L)=>e.jsx(o.Chip,{label:X(p),onDelete:()=>U(L),sx:{bgcolor:"primary.lighter",color:"primary.main",fontSize:"0.875rem",fontWeight:400,height:32,borderRadius:"16px",border:$=>`1px solid ${N($.palette.primary.main,.3)}`,transition:"all 0.2s ease","&:hover":{bgcolor:$=>N($.palette.primary.main,.2),borderColor:"#aecbfa"},"& .MuiChip-label":{px:1.5,color:"primary.main"},"& .MuiChip-deleteIcon":{color:"primary.main",fontSize:18,transition:"all 0.2s ease","&:hover":{color:"primary.dark"}}}},L))})]})]}),e.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"grey.50"},children:[e.jsx(o.Button,{onClick:V,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(o.Button,{onClick:O,disabled:!w,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"grey.300",color:"grey.500"}},children:"Apply filter"})]})]})})}const Mn="SORT_RULE";function id({rule:t,index:r,onToggleDirection:n,onRemove:i,onMove:a}){const c=u.useRef(null),[{handlerId:l},d]=vt.useDrop({accept:Mn,collect(m){return{handlerId:m.getHandlerId()}},hover(m,g){var T;if(!c.current)return;const y=m.index,S=r;if(y===S)return;const C=(T=c.current)==null?void 0:T.getBoundingClientRect(),x=(C.bottom-C.top)/2,E=g.getClientOffset(),s=((E==null?void 0:E.y)??0)-C.top;y<S&&s<x||y>S&&s>x||(a(y,S),m.index=S)}}),[{isDragging:f},h]=vt.useDrag({type:Mn,item:()=>({index:r}),collect:m=>({isDragging:m.isDragging()})});return h(d(c)),e.jsxs(o.Box,{ref:c,"data-handler-id":l,sx:{display:"flex",alignItems:"center",gap:1.25,px:2,py:1.25,borderRadius:"8px",bgcolor:"background.paper",border:"1px solid divider",opacity:f?.4:1,cursor:"move",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:"grey.50",borderColor:"grey.300",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.1), 0 1px 3px 1px rgba(60, 64, 67, 0.05)",transform:"translateY(-1px)"}},children:[e.jsx(o.Chip,{label:t.priority,size:"small",sx:{width:26,height:26,fontSize:"0.75rem",fontWeight:600,bgcolor:"primary.main",color:"background.paper",boxShadow:"0 1px 2px 0 rgba(25, 103, 210, 0.3)","& .MuiChip-label":{px:0}}}),e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:"3px",cursor:"grab",px:.5,opacity:.6,transition:"opacity 0.2s ease","&:hover":{opacity:1},"&:active":{cursor:"grabbing"}},children:[e.jsx(o.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}}),e.jsx(o.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}}),e.jsx(o.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}})]}),e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",fontWeight:400,color:"text.primary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"0 0 100px",lineHeight:1.5},children:t.column}),e.jsx(o.FormControl,{size:"small",sx:{flex:1,minWidth:100},children:e.jsxs(o.Select,{value:t.direction,onChange:m=>n(r,m.target.value),sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"grey.300",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"& .MuiSelect-select":{py:.875,color:"text.primary",fontWeight:400}},children:[e.jsx(o.MenuItem,{value:"asc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:m=>N(m.palette.primary.main,.2)}}},children:"Ascending"}),e.jsx(o.MenuItem,{value:"desc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:m=>N(m.palette.primary.main,.2)}}},children:"Descending"})]})}),e.jsx(o.IconButton,{onClick:()=>i(r),size:"small",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{color:"error.main",bgcolor:"rgba(217, 48, 37, 0.08)",transform:"scale(1.1)"}},children:e.jsx(j.Close,{sx:{fontSize:18}})})]})}function sd({schema:t,sortStack:r,onUpdateSortStack:n,onClose:i}){const[a,c]=u.useState(""),[l,d]=u.useState([]);u.useEffect(()=>{d([...r])},[r]);const f=Mr(),h=u.useCallback(()=>!(l.length>=f.sort.maxLevels||!a||l.some(T=>T.column===a)),[l,a]),m=u.useCallback(()=>{if(!h())return;const T=l.length+1,I={column:a,direction:"asc",priority:T};d([...l,I]),c("")},[h,a,l]),g=u.useCallback(T=>{const A=l.filter((v,W)=>W!==T).map((v,W)=>({...v,priority:W+1}));d(A)},[l]),y=u.useCallback((T,I)=>{const A=[...l];A[T]={...A[T],direction:I},d(A)},[l]),S=u.useCallback((T,I)=>{const A=[...l],[v]=A.splice(T,1);A.splice(I,0,v);const W=A.map((U,w)=>({...U,priority:w+1}));d(W)},[l]),C=u.useCallback(()=>{d([])},[]),x=u.useCallback(()=>{n(l),i()},[l,n,i]),E=u.useCallback(()=>{d([...r]),c(""),i()},[r,i]),s=t.filter(T=>!l.some(I=>I.column===T.name));return e.jsx(vt.DndProvider,{backend:zo.HTML5Backend,children:e.jsx(o.Box,{onClick:E,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(o.Paper,{onClick:T=>T.stopPropagation(),elevation:0,sx:{position:"relative",width:480,maxWidth:"calc(100vw - 120px)",maxHeight:"min(440px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"background.paper",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Sort columns"}),e.jsx(o.IconButton,{onClick:E,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"grey.100",color:"text.primary"}},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsxs(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"grey.300",borderRadius:4,"&:hover":{bgcolor:"grey.400"}}},children:[e.jsxs(o.Box,{sx:{mb:2.5},children:[e.jsx(o.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add sort level"}),e.jsxs(o.FormControl,{size:"small",fullWidth:!0,disabled:l.length>=f.sort.maxLevels,children:[e.jsx(o.InputLabel,{sx:{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},children:"Select column..."}),e.jsxs(o.Select,{value:a,onChange:T=>c(T.target.value),label:"Select column...",displayEmpty:!0,sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"grey.300",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-disabled":{bgcolor:"grey.50"}},children:[e.jsx(o.MenuItem,{value:"",disabled:!0,sx:{display:"none"},children:e.jsx("em",{children:"Select column..."})}),s.map(T=>e.jsx(o.MenuItem,{value:T.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:I=>N(I.palette.primary.main,.2)}}},children:St(T.name)},T.name))]})]}),e.jsx(o.Button,{onClick:m,disabled:!h(),sx:{mt:1.5,textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"primary.main",p:0,justifyContent:"flex-start",minHeight:"auto",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"primary.dark",textDecoration:"underline"},"&.Mui-disabled":{color:"grey.400"}},children:"+ Add sort column"})]}),l.length>0&&e.jsxs(o.Box,{children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1.5},children:[e.jsxs(o.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:["Sorted sequence (",l.length,"/",f.sort.maxLevels,")"]}),e.jsx(o.Button,{onClick:C,sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"error.main",p:0,minWidth:"auto",minHeight:"auto",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"#b3190e",textDecoration:"underline"}},children:"Clear all"})]}),e.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:l.map((T,I)=>e.jsx(id,{rule:T,index:I,onToggleDirection:y,onRemove:g,onMove:S},`${T.column}-${I}`))})]})]}),e.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"grey.50"},children:[e.jsx(o.Button,{onClick:E,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(o.Button,{onClick:x,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Apply sort"})]})]})})})}function ad({views:t,activeViewId:r,onSelectView:n,onCreateView:i,onEditView:a,onDeleteView:c,onRestoreView:l,onPermanentDelete:d,onClose:f}){return e.jsxs(o.Dialog,{open:!0,onClose:f,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{mt:8,borderRadius:"12px",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[e.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:["Manage Views",e.jsx(o.IconButton,{onClick:f,size:"small",sx:{color:"text.secondary"},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsxs(o.DialogContent,{children:[e.jsx(o.Box,{sx:{mb:2},children:e.jsx(o.Button,{onClick:i,variant:"contained",startIcon:e.jsx(j.Add,{sx:{fontSize:16}}),size:"small",children:"Create New Report View"})}),e.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:t.map(h=>e.jsx(o.Paper,{sx:{p:2,border:1,borderColor:h.isDeleted?"error.light":r===h.id?"primary.main":"divider",bgcolor:h.isDeleted?m=>N(m.palette.error.main,.12):r===h.id?m=>N(m.palette.primary.main,.12):"background.paper",opacity:h.isDeleted?.75:1,cursor:h.isDeleted?"default":"pointer","&:hover":h.isDeleted?{}:{bgcolor:"action.hover"}},onClick:()=>!h.isDeleted&&n(h.id),elevation:0,children:e.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.5},children:[e.jsxs(o.Box,{sx:{flex:1},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,textDecoration:h.isDeleted?"line-through":"none",color:h.isDeleted?"text.secondary":"text.primary"},children:h.name}),h.isDeleted&&e.jsx(o.Chip,{label:"Deleted",size:"small",color:"error",sx:{height:20}}),h.isDefault&&e.jsx(o.Chip,{label:"Default",size:"small",color:"primary",sx:{height:20}}),h.isFavorite&&e.jsx(o.Chip,{label:"★ Favorite",size:"small",sx:{height:20}})]}),h.description&&e.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:h.description})]}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[!h.isDeleted&&e.jsxs(e.Fragment,{children:[e.jsx(o.IconButton,{size:"small",onClick:m=>{m.stopPropagation(),a(h.id)},title:"Edit view",children:e.jsx(j.Edit,{sx:{fontSize:16}})}),e.jsx(o.IconButton,{size:"small",onClick:m=>{m.stopPropagation(),c(h.id)},title:"Delete view",sx:{"&:hover":{color:"error.main"}},children:e.jsx(j.Delete,{sx:{fontSize:16}})})]}),h.isDeleted&&l&&e.jsx(o.IconButton,{size:"small",onClick:m=>{m.stopPropagation(),l(h.id)},title:"Restore view",sx:{color:"success.main"},children:e.jsx(j.Undo,{sx:{fontSize:16}})}),h.isDeleted&&d&&e.jsx(o.IconButton,{size:"small",onClick:m=>{m.stopPropagation(),d(h.id)},title:"Delete permanently",sx:{color:"error.main"},children:e.jsx(j.Delete,{sx:{fontSize:16}})})]})]})},h.id))})]}),e.jsx(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"grey.50",gap:1.25,justifyContent:"flex-end"},children:e.jsx(o.Button,{onClick:f,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"background.paper",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Close"})})]})}function Rn({currentSnapshot:t,onSave:r,onClose:n,isEditMode:i=!1,initialName:a="",initialDescription:c="",initialIsDefault:l=!1}){const[d,f]=u.useState(a),[h,m]=u.useState(c),[g,y]=u.useState(l),S=()=>{d.trim()&&(r(d.trim(),h.trim(),g),n())},C=E=>{E.key==="Enter"&&!E.shiftKey?S():E.key==="Escape"&&n()},x=()=>i&&a?`Update ${a} view`:"Create New Report View";return e.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{mt:8,borderRadius:"12px",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[e.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:[x(),e.jsx(o.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsx(o.DialogContent,{children:e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2,pt:1},children:[e.jsx(o.TextField,{label:"View Name",required:!0,value:d,onChange:E=>f(E.target.value),onKeyDown:C,placeholder:"e.g., Active Users",autoFocus:!0,fullWidth:!0,size:"small"}),e.jsx(o.TextField,{label:"Description (optional)",value:h,onChange:E=>m(E.target.value),placeholder:"Brief description of this view",multiline:!0,rows:2,fullWidth:!0,size:"small"}),e.jsxs(o.Paper,{sx:{p:2,bgcolor:"action.hover"},variant:"outlined",children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,mb:1},children:"This view will capture:"}),e.jsxs(o.Box,{component:"ul",sx:{m:0,pl:2,"& li":{fontSize:"body2.fontSize",color:"text.secondary"}},children:[e.jsxs("li",{children:[t.filters.length," filter",t.filters.length!==1?"s":""]}),e.jsxs("li",{children:["Sorting: ",bs(t.sortStack)]}),e.jsx("li",{children:"Column order & visibility"})]})]}),!i&&e.jsx(o.FormControlLabel,{control:e.jsx(o.Checkbox,{checked:g,onChange:E=>y(E.target.checked),size:"small"}),label:e.jsx(o.Typography,{variant:"body2",children:"Set as default view"})})]})}),e.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"grey.50",gap:1.25,justifyContent:"flex-end"},children:[e.jsx(o.Button,{onClick:n,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(o.Button,{onClick:S,disabled:!d.trim(),variant:"contained",startIcon:e.jsx(j.Save,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"background.paper",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"grey.400"}},children:i?"Save Changes":"Create Report View"})]})]})}function ld({viewName:t,onConfirm:r,onCancel:n}){return e.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",maxHeight:"min(480px, calc(100vh - 180px))",my:"auto",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[e.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:["Delete View",e.jsx(o.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsx(o.DialogContent,{children:e.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.5,mt:1},children:[e.jsx(j.Warning,{color:"error",sx:{fontSize:20,flexShrink:0}}),e.jsxs(o.Box,{children:[e.jsxs(o.Typography,{variant:"body2",sx:{mb:1},children:["Are you sure you want to delete the view ",e.jsxs("strong",{children:['"',t,'"']}),"?"]}),e.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"This action cannot be undone."})]})]})}),e.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid #e8eaed",bgcolor:"#f8f9fa",gap:1.25,justifyContent:"flex-end"},children:[e.jsx(o.Button,{onClick:n,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"#5f6368",px:3,py:.875,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"#e8eaed",color:"#202124"}},children:"Cancel"}),e.jsx(o.Button,{onClick:r,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#d93025",color:"#ffffff",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#b3190e",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Delete View"})]})]})}const yi=80,bi=600,Wn="COLUMN";function cd({column:t,index:r,isVisible:n,width:i,onToggleVisibility:a,onWidthChange:c,moveColumn:l}){const d=u.useRef(null),[f,h]=u.useState(i.toString());u.useEffect(()=>{h(i.toString())},[i]);const[{handlerId:m},g]=vt.useDrop({accept:Wn,collect(T){return{handlerId:T.getHandlerId()}},hover(T,I){var V;if(!d.current)return;const A=T.index,v=r;if(A===v)return;const W=(V=d.current)==null?void 0:V.getBoundingClientRect(),U=(W.bottom-W.top)/2,w=I.getClientOffset(),O=((w==null?void 0:w.y)??0)-W.top;A<v&&O<U||A>v&&O>U||(l(A,v),T.index=v)}}),[{isDragging:y},S]=vt.useDrag({type:Wn,item:()=>({index:r}),collect:T=>({isDragging:T.isDragging()})});S(g(d));const C=()=>{const T=parseInt(f);if(isNaN(T)){h(i.toString());return}const I=Math.max(yi,Math.min(bi,T));h(I.toString()),c(t.name,I)},x=T=>{(T===""||/^\d+$/.test(T))&&h(T)},E=T=>{T.key==="Enter"&&(T.preventDefault(),C(),T.target.blur())},s=T=>({string:"primary.main",number:"#188038",boolean:"#9334e6",array:"#ea8600",object:"error.main",null:"text.secondary",mixed:"text.secondary"})[T]||"text.secondary";return e.jsxs(o.TableRow,{ref:d,"data-handler-id":m,sx:{opacity:y?.4:1,bgcolor:n?"background.paper":"grey.50",transition:"all 0.2s ease","&:hover":{bgcolor:n?"grey.50":"grey.100"},cursor:"move",height:56,borderBottom:"1px solid divider"},children:[e.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[e.jsx(o.Box,{sx:{color:"text.secondary",cursor:"grab",opacity:.6,transition:"opacity 0.2s ease","&:hover":{opacity:1},"&:active":{cursor:"grabbing"}},children:e.jsx(j.DragIndicator,{sx:{fontSize:20}})}),e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:400,fontSize:"0.875rem",color:n?"text.primary":"text.secondary"},children:St(t.name)})]})}),e.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:e.jsx(o.Chip,{label:t.type.toUpperCase(),size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:600,bgcolor:`${s(t.type)}15`,color:s(t.type),border:`1px solid ${s(t.type)}30`,"& .MuiChip-label":{px:1}}})}),e.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(o.TextField,{type:"text",value:f,onChange:T=>x(T.target.value),onBlur:C,onKeyDown:E,placeholder:"150",size:"small",sx:{width:80,"& .MuiOutlinedInput-root":{height:32,fontSize:"0.8125rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"grey.300"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputBase-input":{py:.5,px:1.25,color:"text.primary"}}}),e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},children:"px"})]})}),e.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[e.jsx(o.IconButton,{onClick:()=>a(t.name,!n),title:n?"Hide column":"Show column",size:"small",sx:{p:.75,color:n?"primary.main":"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"grey.100",color:n?"primary.dark":"primary.main"}},children:n?e.jsx(j.Visibility,{sx:{fontSize:20}}):e.jsx(j.VisibilityOff,{sx:{fontSize:20}})}),e.jsx(o.Chip,{label:n?"Visible":"Hidden",size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:500,bgcolor:n?"#e6f4ea":"grey.100",color:n?"#188038":"text.secondary","& .MuiChip-label":{px:1}}})]})})]})}function dd({schema:t,columnVisibility:r,columnOrder:n,columnWidths:i={},views:a=[],activeViewId:c="",onUpdateColumnVisibility:l,onUpdateColumnOrder:d,onUpdateColumnWidth:f,onResetLayout:h,onSaveToCurrentView:m,onSaveToAllViews:g,onSelectView:y,onClose:S}){const[C,x]=u.useState(!1),[E,s]=u.useState(n),[T,I]=u.useState("all"),[A,v]=u.useState(null);u.useEffect(()=>{s(n)},[n]);const W=(F,oe)=>{const ue=[...E],[Ee]=ue.splice(F,1);ue.splice(oe,0,Ee),s(ue),d(ue)},U=()=>{h(),x(!1)},O=E.map(F=>t.find(oe=>oe.name===F)).filter(F=>F!==void 0).filter(F=>{const oe=r[F.name]??!0;return T==="active"?oe:T==="hidden"?!oe:!0}),V=Object.values(r).filter(F=>F).length,X=t.length,p=a.find(F=>F.id===c),L=a.filter(F=>!F.isDeleted),$=L.length>1,_=u.useMemo(()=>{if(!p)return!1;const F=p.snapshot,oe=JSON.stringify(r)!==JSON.stringify(F.columnVisibility),ue=JSON.stringify(n)!==JSON.stringify(F.columnOrder),Ee=JSON.stringify(i)!==JSON.stringify(F.columnWidths);return oe||ue||Ee},[p,r,n,i]);return e.jsx(vt.DndProvider,{backend:zo.HTML5Backend,children:e.jsx(o.Box,{onClick:S,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(o.Paper,{onClick:F=>F.stopPropagation(),elevation:0,sx:{position:"relative",width:720,maxWidth:"calc(100vw - 120px)",maxHeight:"min(760px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"background.paper",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(o.Box,{sx:{px:3,pt:2,pb:1.5,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",mb:1.5},children:[e.jsxs(o.Box,{sx:{flex:1},children:[e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Manage columns"}),e.jsxs(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary",mt:.5},children:[V," of ",X," columns visible • Drag to reorder"]})]}),L.length>0&&y&&e.jsxs(o.Box,{sx:{ml:2},children:[e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.6875rem",color:"text.secondary",mb:.75,display:"block",textTransform:"uppercase",fontWeight:600,letterSpacing:"0.1em"},children:"View:"}),e.jsx(o.Button,{onClick:F=>v(F.currentTarget),variant:"outlined",size:"small",endIcon:e.jsx(j.KeyboardArrowDown,{sx:{fontSize:18}}),sx:{minWidth:180,justifyContent:"space-between",textTransform:"none",fontSize:"0.875rem",fontWeight:400,color:"text.primary",borderColor:"grey.300",py:.75,px:1.5,"&:hover":{borderColor:"primary.main",bgcolor:"grey.50"}},children:e.jsx(o.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis"},children:(p==null?void 0:p.name)||"Select View"})}),e.jsx(o.Menu,{anchorEl:A,open:!!A,onClose:()=>v(null),PaperProps:{sx:{mt:.5,borderRadius:"8px",boxShadow:"0 2px 6px rgba(60, 64, 67, 0.15)"}},children:L.map(F=>e.jsx(o.MenuItem,{onClick:()=>{y(F.id),v(null)},selected:F.id===c,sx:{fontSize:"0.875rem",color:"text.primary",py:1,px:2,"&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:oe=>N(oe.palette.primary.main,.2)}}},children:F.name},F.id))})]}),e.jsx(o.IconButton,{onClick:S,size:"small",sx:{ml:2,p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"grey.100",color:"text.primary"}},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsxs(o.Tabs,{value:T,onChange:(F,oe)=>I(oe),sx:{minHeight:36,mt:.5,"& .MuiTabs-indicator":{bgcolor:"primary.main",height:3}},children:[e.jsx(o.Tab,{label:"All",value:"all",sx:{minHeight:36,py:.75,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary","&.Mui-selected":{color:"primary.main"}}}),e.jsx(o.Tab,{label:"Visible",value:"active",sx:{minHeight:36,py:.75,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary","&.Mui-selected":{color:"primary.main"}}}),e.jsx(o.Tab,{label:"Hidden",value:"hidden",sx:{minHeight:36,py:.75,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary","&.Mui-selected":{color:"primary.main"}}})]})]}),e.jsx(o.Box,{sx:{flex:1,overflow:"auto","&::-webkit-scrollbar":{width:8,height:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"grey.300",borderRadius:4,"&:hover":{bgcolor:"grey.400"}}},children:e.jsxs(o.Table,{stickyHeader:!0,sx:{minWidth:650},children:[e.jsx(o.TableHead,{children:e.jsxs(o.TableRow,{children:[e.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"0.6875rem",color:"text.secondary",bgcolor:"grey.50",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid divider"},children:"Column name"}),e.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"0.6875rem",color:"text.secondary",bgcolor:"grey.50",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid divider"},children:"Type"}),e.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"0.6875rem",color:"text.secondary",bgcolor:"grey.50",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid divider"},children:e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:["Width",e.jsx(o.Tooltip,{title:`Column width in pixels (min: ${yi}px, max: ${bi}px)`,arrow:!0,placement:"top",children:e.jsx(j.InfoOutlined,{sx:{fontSize:14,color:"text.secondary",cursor:"help"}})})]})}),e.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"0.6875rem",color:"text.secondary",bgcolor:"grey.50",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid divider"},children:"Visibility"})]})}),e.jsx(o.TableBody,{children:O.length===0?e.jsx(o.TableRow,{children:e.jsx(o.TableCell,{colSpan:4,align:"center",sx:{py:6,borderBottom:"none"},children:e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"text.secondary"},children:"No columns in this category"})})}):O.map((F,oe)=>e.jsx(cd,{column:F,index:oe,isVisible:r[F.name]??!0,width:i[F.name]||150,onToggleVisibility:l,onWidthChange:f||(()=>{}),moveColumn:W},F.name))})]})}),e.jsxs(o.Box,{sx:{px:3,py:1.75,borderTop:"1px solid divider",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0,bgcolor:"grey.50"},children:[e.jsx(o.Button,{onClick:()=>x(!0),disabled:!_,variant:"outlined",startIcon:e.jsx(j.Undo,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",borderColor:"grey.300",px:2.5,py:.875,minHeight:36,borderRadius:"4px","&:hover":{borderColor:"primary.main",bgcolor:"background.paper",color:"primary.main"},"&.Mui-disabled":{color:"grey.400",borderColor:"divider"}},children:"Reset to default"}),e.jsxs(o.Stack,{direction:"row",spacing:1.25,children:[m&&e.jsx(o.Button,{onClick:()=>{m(),S()},disabled:!_,variant:"contained",startIcon:e.jsx(j.Save,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"background.paper",px:2.5,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"grey.400"}},children:"Save to current view"}),g&&$&&e.jsx(o.Button,{onClick:()=>{g(),S()},disabled:!_||!$,variant:"contained",startIcon:e.jsx(j.GridView,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#188038",color:"background.paper",px:2.5,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#0d652d",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"grey.400"}},children:"Save to all views"})]})]}),C&&e.jsx(o.Box,{onClick:()=>x(!1),sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1400},children:e.jsxs(o.Paper,{onClick:F=>F.stopPropagation(),elevation:0,sx:{width:400,maxWidth:"90vw",borderRadius:"12px",bgcolor:"background.paper",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"},children:[e.jsxs(o.Box,{sx:{px:3,py:2.5},children:[e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1rem",fontWeight:500,color:"text.primary",mb:1.5},children:"Reset column layout?"}),e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"text.secondary",lineHeight:1.5},children:"This will restore default visibility, order, and widths for all columns."})]}),e.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",bgcolor:"grey.50"},children:[e.jsx(o.Button,{onClick:()=>x(!1),variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",px:3,py:1,borderRadius:"4px","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(o.Button,{onClick:U,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"error.main",color:"background.paper",px:3,py:1,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)","&:hover":{bgcolor:"#b3190e",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Reset layout"})]})]})})]})})})}function ud({schema:t,grouping:r,onApply:n,onClose:i}){var W;const[a,c]=u.useState(r||{enabled:!1,levels:[],collapsedGroups:[]}),[l,d]=u.useState(""),[f,h]=u.useState(null),m=u.useMemo(()=>fs(t),[t]),g=u.useMemo(()=>m.filter(U=>!a.levels.some((w,O)=>w.column===U.name&&O!==f)),[m,a.levels,f]),y=Mr(),S=a.levels.length<y.grouping.maxLevels&&g.length>0,C=u.useCallback(()=>{!S||!l||(c({...a,levels:[...a.levels,{column:l}],enabled:!0}),d(""))},[S,l,a]),x=u.useCallback(U=>{const w=a.levels.filter((O,V)=>V!==U);if(w.length===0){n(null),i();return}c({...a,levels:w,enabled:w.length>0})},[a,n,i]),E=u.useCallback(U=>{h(U),d(a.levels[U].column)},[a.levels]),s=u.useCallback(()=>{if(f===null||!l)return;const U=[...a.levels];U[f]={column:l},c({...a,levels:U}),h(null),d("")},[f,l,a]),T=u.useCallback(()=>{h(null),d("")},[]),I=u.useCallback((U,w)=>{const O=w==="up"?U-1:U+1;if(O<0||O>=a.levels.length)return;const V=[...a.levels],[X]=V.splice(U,1);V.splice(O,0,X),c({...a,levels:V})},[a]),A=u.useCallback(()=>{n(null),i()},[n,i]),v=u.useCallback(()=>{a.levels.length===0?n(null):n({...a,enabled:!0,collapsedGroups:(r==null?void 0:r.collapsedGroups)||[]}),i()},[a,r,n,i]);return e.jsx(o.Box,{onClick:i,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(o.Paper,{onClick:U=>U.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(560px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"background.paper",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Group configuration"}),e.jsx(o.IconButton,{onClick:i,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"grey.100",color:"text.primary"}},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"grey.300",borderRadius:4,"&:hover":{bgcolor:"grey.400"}}},children:e.jsxs(o.Stack,{spacing:2.5,children:[f===null&&e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add group level"}),e.jsx(o.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:e.jsxs(o.Select,{value:l,onChange:U=>d(U.target.value),disabled:!S,displayEmpty:!0,sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"grey.300",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-disabled":{bgcolor:"grey.50"}},children:[e.jsx(o.MenuItem,{value:"",sx:{fontSize:"0.875rem",color:"text.secondary"},children:"Select a column..."}),g.map(U=>e.jsxs(o.MenuItem,{value:U.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:w=>N(w.palette.primary.main,.2)}}},children:[St(U.name)," (",U.type.toUpperCase(),")"]},U.name))]})}),e.jsx(o.Button,{onClick:C,disabled:!S||!l,variant:"outlined",startIcon:e.jsx(j.Add,{sx:{fontSize:18}}),fullWidth:!0,sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"primary.main",borderColor:"grey.300",py:1,transition:"all 0.2s ease","&:hover":{borderColor:"primary.main",bgcolor:"grey.50"},"&.Mui-disabled":{color:"grey.400",borderColor:"divider"}},children:"Add group level"}),a.levels.length>=y.grouping.maxLevels&&e.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",textAlign:"center",mt:1.5,fontSize:"0.75rem",color:"text.secondary"},children:"Maximum group levels (3) reached"}),m.length===0&&e.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{textAlign:"center",py:2,fontSize:"0.875rem",color:"text.secondary"},children:"No groupable columns available. Only STRING and BOOLEAN columns can be grouped."})]}),f!==null&&e.jsxs(o.Alert,{severity:"warning",sx:{borderRadius:"8px",border:"1px solid #fdd663",bgcolor:"#fef7e0","& .MuiAlert-icon":{color:"#ea8600"}},children:[e.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:500,mb:1.5,fontSize:"0.875rem",color:"text.primary"},children:["Edit Group Level ",f+1]}),e.jsx(o.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:e.jsxs(o.Select,{value:l,onChange:U=>d(U.target.value),sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"grey.300"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"}},children:[e.jsx(o.MenuItem,{value:"",sx:{fontSize:"0.875rem"},children:"Select a column..."}),e.jsxs(o.MenuItem,{value:a.levels[f].column,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:"primary.lighter"}},children:[a.levels[f].column," (",(W=t.find(U=>U.name===a.levels[f].column))==null?void 0:W.type.toUpperCase(),")"]}),g.filter(U=>U.name!==a.levels[f].column).map(U=>e.jsxs(o.MenuItem,{value:U.name,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:"primary.lighter"}},children:[St(U.name)," (",U.type.toUpperCase(),")"]},U.name))]})}),e.jsxs(o.Stack,{direction:"row",spacing:1.5,children:[e.jsx(o.Button,{onClick:s,disabled:!l,variant:"contained",fullWidth:!0,size:"small",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#ea8600",color:"background.paper",py:.875,boxShadow:"none","&:hover":{bgcolor:"#c96e00",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)"}},children:"Save"}),e.jsx(o.Button,{onClick:T,variant:"outlined",fullWidth:!0,size:"small",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",borderColor:"grey.300",py:.875,"&:hover":{borderColor:"grey.400",bgcolor:"grey.50"}},children:"Cancel"})]})]}),a.levels.length>0&&f===null&&e.jsxs(o.Box,{children:[e.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1.5},children:[e.jsx(o.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:"Active group levels"}),e.jsx(o.Button,{onClick:A,size:"small",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"error.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",color:"#b3190e",textDecoration:"underline"}},children:"Clear all"})]}),e.jsx(o.Stack,{spacing:1.5,children:a.levels.map((U,w)=>{const O=t.find(V=>V.name===U.column);return e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,p:2,borderRadius:"8px",bgcolor:"background.paper",border:"1px solid divider",transition:"all 0.2s ease","&:hover":{bgcolor:"grey.50",borderColor:"grey.300",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.1)"}},children:[e.jsx(o.Chip,{label:`L${w+1}`,size:"small",sx:{width:40,height:28,fontWeight:600,fontSize:"0.75rem",bgcolor:"primary.main",color:"background.paper",boxShadow:"0 1px 2px 0 rgba(25, 103, 210, 0.3)"}}),e.jsxs(o.Box,{sx:{flex:1},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:U.column}),e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},children:O==null?void 0:O.type.toUpperCase()})]}),e.jsxs(o.Stack,{direction:"row",spacing:.5,children:[e.jsx(o.IconButton,{size:"small",onClick:()=>I(w,"up"),disabled:w===0,sx:{color:"text.secondary","&:hover":{bgcolor:"grey.100"},"&.Mui-disabled":{color:"divider"}},children:e.jsx(j.KeyboardArrowUp,{sx:{fontSize:18}})}),e.jsx(o.IconButton,{size:"small",onClick:()=>I(w,"down"),disabled:w===a.levels.length-1,sx:{color:"text.secondary","&:hover":{bgcolor:"grey.100"},"&.Mui-disabled":{color:"divider"}},children:e.jsx(j.KeyboardArrowDown,{sx:{fontSize:18}})}),e.jsx(o.IconButton,{size:"small",onClick:()=>E(w),sx:{color:"text.secondary","&:hover":{bgcolor:"grey.100",color:"primary.main"}},children:e.jsx(j.Edit,{sx:{fontSize:18}})}),e.jsx(o.IconButton,{size:"small",onClick:()=>x(w),sx:{color:"text.secondary","&:hover":{bgcolor:"rgba(217, 48, 37, 0.08)",color:"error.main"}},children:e.jsx(j.Delete,{sx:{fontSize:18}})})]})]},w)})})]})]})}),e.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"grey.50"},children:[e.jsx(o.Button,{onClick:i,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(o.Button,{onClick:v,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Apply grouping"})]})]})})}const pd={filters:j.FilterList,sorting:j.UnfoldMore,visibility:j.Visibility,order:j.ViewColumn,widths:j.Straighten,grouping:j.Layers};function fd({changes:t,onClose:r}){const n=i=>({filters:"primary",sorting:"secondary",visibility:"success",order:"warning",widths:"info",grouping:"error"})[i]||"default";return e.jsxs(o.Dialog,{open:!0,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{mt:8,borderRadius:"12px",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[e.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:["View Changes Summary",e.jsx(o.IconButton,{onClick:r,size:"small",sx:{color:"text.secondary"},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsx(o.DialogContent,{dividers:!0,children:t.length===0?e.jsx(o.Box,{sx:{textAlign:"center",py:4},children:e.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"No changes detected"})}):e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"The following modifications have been made to this view:"}),e.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.5},children:t.map((i,a)=>{const c=pd[i.category];return e.jsxs(o.Paper,{elevation:0,sx:{display:"flex",gap:1.5,p:1.5,border:1,borderColor:"divider",borderRadius:1},children:[e.jsx(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:1,bgcolor:`${n(i.category)}.lighter`,color:`${n(i.category)}.main`,flexShrink:0},children:e.jsx(c,{sx:{fontSize:16}})}),e.jsxs(o.Box,{sx:{flex:1,minWidth:0},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500},children:i.label}),e.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:i.description})]})]},a)})})]})}),e.jsx(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid #e8eaed",bgcolor:"#f8f9fa",gap:1.25,justifyContent:"flex-end"},children:e.jsx(o.Button,{onClick:r,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#1967d2",color:"#ffffff",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#1557b0",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Close"})})]})}function xd({viewName:t,isDefaultView:r,changes:n=[],onSaveToCurrentView:i,onSaveAsNewView:a,onCancel:c}){const[l,d]=u.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(o.Box,{sx:{width:"100%",flexShrink:0,bgcolor:"primary.lighter",borderBottom:f=>`1px solid ${N(f.palette.primary.main,.3)}`,zIndex:10},children:e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:1.25},children:[e.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:400,fontSize:"0.875rem",color:"#3c4043"},children:['Unsaved changes to "',t,'"']}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(o.Button,{onClick:c,variant:"text",size:"small",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2,py:.625,borderRadius:"18px",color:"#5f6368",bgcolor:"transparent",minHeight:32,"&:hover":{bgcolor:"rgba(60, 64, 67, 0.08)",color:"#202124"}},children:"Discard"}),e.jsx(o.Button,{onClick:a,variant:"contained",size:"small",disableElevation:!0,sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2.5,py:.625,borderRadius:"18px",minHeight:32,boxShadow:"none","&:hover":{boxShadow:"0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px rgba(60, 64, 67, 0.15)"}},children:"Save as new view"})]})]})}),l&&e.jsx(fd,{changes:n,onClose:()=>d(!1)})]})}function hd({onExportAnyway:t,onSaveAndExport:r,onCancel:n}){return e.jsx(o.Box,{sx:{mb:2,mx:3,mt:2},children:e.jsxs(o.Alert,{severity:"warning",icon:e.jsx(j.Warning,{sx:{fontSize:20}}),action:e.jsx(o.IconButton,{size:"small",onClick:n,sx:{color:"warning.main"},children:e.jsx(j.Close,{sx:{fontSize:20}})}),sx:{alignItems:"flex-start"},children:[e.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:600,mb:.5},children:"You are exporting with unsaved view changes"}),e.jsx(o.Typography,{variant:"body2",sx:{mb:1.5},children:"Your current view has unsaved changes. Choose how to proceed:"}),e.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[e.jsx(o.Button,{onClick:r,variant:"contained",color:"primary",startIcon:e.jsx(j.Save,{sx:{fontSize:14}}),size:"small",children:"Save View & Export"}),e.jsx(o.Button,{onClick:t,variant:"contained",color:"warning",startIcon:e.jsx(j.Download,{sx:{fontSize:14}}),size:"small",children:"Export Anyway"})]})]})})}function md({auditHistory:t,onClose:r}){const[n,i]=u.useState(new Set),a=l=>{i(d=>{const f=new Set(d);return f.has(l)?f.delete(l):f.add(l),f})},c=[...t].sort((l,d)=>new Date(d.timestamp).getTime()-new Date(l.timestamp).getTime());return e.jsx(o.Box,{onClick:r,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(o.Paper,{onClick:l=>l.stopPropagation(),elevation:0,sx:{position:"relative",width:680,maxWidth:"calc(100vw - 120px)",maxHeight:"min(720px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"background.paper",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Audit history"}),e.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",mt:.5,display:"block"},children:[c.length," event",c.length!==1?"s":""," recorded"]})]}),e.jsx(o.IconButton,{onClick:r,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"grey.100",color:"text.primary"}},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"grey.300",borderRadius:4,"&:hover":{bgcolor:"grey.400"}}},children:c.length===0?e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8,textAlign:"center"},children:[e.jsx(j.AccessTime,{sx:{fontSize:64,color:"divider",mb:2}}),e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"text.secondary",mb:.5},children:"No audit events recorded yet"}),e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"grey.400"},children:"Changes to this report will appear here"})]}):e.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.5},children:c.map(l=>{const d=n.has(l.id),f=Ms(l.feature);return e.jsxs(o.Paper,{elevation:0,sx:{border:"1px solid divider",borderRadius:"8px",overflow:"hidden",transition:"all 0.2s ease","&:hover":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.1)",borderColor:"grey.300"}},children:[e.jsxs(o.Box,{onClick:()=>a(l.id),sx:{px:2.5,py:1.75,display:"flex",alignItems:"center",gap:1.5,cursor:"pointer",bgcolor:"background.paper",transition:"background-color 0.2s ease","&:hover":{bgcolor:"grey.50"}},children:[e.jsx(o.Box,{sx:{flexShrink:0,color:"text.secondary",transition:"transform 0.2s ease",transform:"rotate(0deg)"},children:d?e.jsx(j.KeyboardArrowDown,{sx:{fontSize:20}}):e.jsx(j.ChevronRight,{sx:{fontSize:20}})}),e.jsx(o.Chip,{label:As(l.feature),size:"small",sx:{height:24,fontSize:"0.6875rem",fontWeight:600,bgcolor:`${f}15`,color:f,border:`1px solid ${f}30`,"& .MuiChip-label":{px:1}}}),e.jsx(o.Typography,{variant:"body2",sx:{flex:1,fontWeight:400,fontSize:"0.875rem",color:"text.primary"},children:Os(l.action)}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,flexShrink:0},children:[e.jsx(j.AccessTime,{sx:{fontSize:16,color:"text.secondary",opacity:.6}}),e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},children:Rs(l.timestamp)})]}),l.user&&e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,flexShrink:0},children:[e.jsx(j.Person,{sx:{fontSize:16,color:"text.secondary",opacity:.6}}),e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},children:l.user})]})]}),e.jsx(o.Collapse,{in:d,timeout:200,children:e.jsxs(o.Box,{sx:{px:2.5,pb:2,pt:1.5,borderTop:"1px solid divider",bgcolor:"grey.50"},children:[l.previousState&&e.jsxs(o.Box,{sx:{mb:2},children:[e.jsx(o.Typography,{variant:"caption",sx:{fontWeight:600,fontSize:"0.6875rem",color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.1em",mb:1,display:"block"},children:"Previous state"}),e.jsx(o.Box,{component:"pre",sx:{fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Courier New", monospace',bgcolor:"background.paper",border:"1px solid grey.300",borderRadius:"4px",p:1.5,overflow:"auto",maxHeight:200,color:"text.primary",lineHeight:1.6,"&::-webkit-scrollbar":{width:6,height:6},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"grey.300",borderRadius:3}},children:qo(l.previousState)})]}),l.newState&&e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"caption",sx:{fontWeight:600,fontSize:"0.6875rem",color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.1em",mb:1,display:"block"},children:"New state"}),e.jsx(o.Box,{component:"pre",sx:{fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Courier New", monospace',bgcolor:"background.paper",border:"1px solid grey.300",borderRadius:"4px",p:1.5,overflow:"auto",maxHeight:200,color:"text.primary",lineHeight:1.6,"&::-webkit-scrollbar":{width:6,height:6},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"grey.300",borderRadius:3}},children:qo(l.newState)})]})]})})]},l.id)})})})]})})}function gd({onSave:t,onClose:r}){const[n,i]=u.useState(""),[a,c]=u.useState(""),[l,d]=u.useState(""),[f,h]=u.useState([]),[m,g]=u.useState(""),[y,S]=u.useState(""),C=v=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v),x=()=>{const v=l.trim();if(v){if(!C(v)){S("Please enter a valid email address");return}if(f.includes(v)){S("This email is already added");return}h([...f,v]),d(""),S("")}},E=v=>{h(f.filter(W=>W!==v))},s=v=>{v.key==="Enter"&&(v.preventDefault(),x())},T=()=>{if(!n.trim()){g("Preset name is required");return}t(n.trim(),a.trim(),f.length>0?f:void 0)},I=v=>{i(v),m&&g("")},A=v=>{d(v),y&&S("")};return e.jsx(o.Box,{onClick:r,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(o.Paper,{onClick:v=>v.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(480px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"background.paper",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Create shareable preset"}),e.jsx(o.IconButton,{onClick:r,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"grey.100",color:"text.primary"}},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"grey.300",borderRadius:4,"&:hover":{bgcolor:"grey.400"}}},children:e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[e.jsx(o.Alert,{severity:"info",icon:e.jsx(j.Info,{sx:{fontSize:20}}),sx:{borderRadius:"8px",border:v=>`1px solid ${N(v.palette.primary.main,.3)}`,bgcolor:"primary.lighter","& .MuiAlert-icon":{color:"primary.main"},"& .MuiAlert-message":{fontSize:"0.8125rem",color:"text.primary",lineHeight:1.5}},children:"This preset will capture filters, sorting, grouping, column configuration, and the active view. The actual data is not saved or shared."}),e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"text.secondary",lineHeight:1.6},children:"Save the current report configuration and generate a shareable link that others can use to view the same filters, sorting, and column layout."}),e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Preset name *"}),e.jsx(o.TextField,{required:!0,value:n,onChange:v=>I(v.target.value),placeholder:"e.g., Q4 Active Users Report",error:!!m,helperText:m,autoFocus:!0,fullWidth:!0,size:"small",sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"grey.300"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-error fieldset":{borderColor:"error.main"}},"& .MuiInputBase-input":{py:1.25,color:"text.primary"},"& .MuiFormHelperText-root":{fontSize:"0.75rem",color:"error.main",mt:.75}}})]}),e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Description (optional)"}),e.jsx(o.TextField,{value:a,onChange:v=>c(v.target.value),placeholder:"Briefly describe what this preset shows...",multiline:!0,rows:3,fullWidth:!0,size:"small",sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"grey.300"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputBase-input":{py:1.25,color:"text.primary",lineHeight:1.6}}})]}),e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Share with (optional)"}),e.jsxs(o.Box,{sx:{display:"flex",gap:1,alignItems:"flex-start"},children:[e.jsx(o.TextField,{value:l,onChange:v=>A(v.target.value),onKeyPress:s,placeholder:"Enter email address",error:!!y,helperText:y,fullWidth:!0,size:"small",InputProps:{startAdornment:e.jsx(j.Email,{sx:{fontSize:18,color:"text.secondary",mr:1}})},sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"grey.300"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-error fieldset":{borderColor:"error.main"}},"& .MuiInputBase-input":{py:1.25,color:"text.primary"},"& .MuiFormHelperText-root":{fontSize:"0.75rem",color:"error.main",mt:.75}}}),e.jsx(o.Button,{onClick:x,variant:"outlined",startIcon:e.jsx(j.Add,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"primary.main",borderColor:"grey.300",px:2,py:1.25,minHeight:40,borderRadius:"4px",flexShrink:0,"&:hover":{borderColor:"primary.main",bgcolor:"grey.50"}},children:"Add"})]}),f.length>0&&e.jsx(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1,mt:1.5},children:f.map(v=>e.jsx(o.Chip,{label:v,onDelete:()=>E(v),deleteIcon:e.jsx(j.Delete,{sx:{fontSize:16}}),sx:{bgcolor:"primary.lighter",color:"primary.main",fontSize:"0.8125rem",height:28,"& .MuiChip-deleteIcon":{color:"primary.main","&:hover":{color:"primary.dark"}}}},v))}),e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary",mt:1,display:"block",lineHeight:1.5},children:f.length>0?`An email with the shareable link will be sent to ${f.length} recipient${f.length>1?"s":""}`:"Add email addresses to send the shareable link automatically"})]})]})}),e.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"grey.50"},children:[e.jsx(o.Button,{onClick:r,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(o.Button,{onClick:T,variant:"contained",startIcon:e.jsx(j.Share,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Create & share"})]})]})})}function yd({presetName:t,shareUrl:r,onCopyLink:n,onOpenPreset:i,onDeletePreset:a,onClose:c}){const[l,d]=u.useState(!1),f=()=>{n(),d(!0),setTimeout(()=>d(!1),2e3)};return e.jsx(o.Box,{onClick:c,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(o.Paper,{onClick:h=>h.stopPropagation(),elevation:0,sx:{position:"relative",width:580,maxWidth:"calc(100vw - 120px)",maxHeight:"min(480px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"#ffffff",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid #e8eaed",flexShrink:0},children:[e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"#202124",letterSpacing:"0",lineHeight:1.5},children:"Shareable link generated"}),e.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"#5f6368",mt:.5,display:"block"},children:["Preset: ",t]})]}),e.jsx(o.IconButton,{onClick:c,size:"small",sx:{p:.75,color:"#5f6368",transition:"all 0.2s ease","&:hover":{bgcolor:"#f1f3f4",color:"#202124"}},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"#dadce0",borderRadius:4,"&:hover":{bgcolor:"#bdc1c6"}}},children:e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[e.jsxs(o.Alert,{severity:"success",icon:e.jsx(j.Check,{sx:{fontSize:20}}),sx:{borderRadius:"8px",border:"1px solid #ceead6",bgcolor:"#e6f4ea","& .MuiAlert-icon":{color:"#188038"},"& .MuiAlert-message":{fontSize:"0.875rem",color:"#3c4043"}},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043",mb:.5},children:"Preset created successfully!"}),e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"#5f6368",lineHeight:1.5},children:"Share the link below with anyone who needs access to this report configuration."})]}),e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.6875rem",fontWeight:600,color:"#5f6368",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Shareable URL"}),e.jsxs(o.Box,{sx:{display:"flex",gap:1.5},children:[e.jsx(o.TextField,{value:r,size:"small",fullWidth:!0,InputProps:{readOnly:!0},onClick:h=>h.target.select(),sx:{"& .MuiOutlinedInput-root":{fontSize:"0.8125rem",borderRadius:"4px",bgcolor:"#f8f9fa",fontFamily:'"Roboto Mono", "Courier New", monospace',"& fieldset":{borderColor:"#dadce0"},"&:hover fieldset":{borderColor:"#1967d2"},"&.Mui-focused fieldset":{borderColor:"#1967d2",borderWidth:"2px"}},"& .MuiInputBase-input":{py:1.25,color:"#1967d2",cursor:"pointer"}}}),e.jsx(o.Button,{onClick:f,variant:"contained",startIcon:l?e.jsx(j.Check,{sx:{fontSize:18}}):e.jsx(j.ContentCopy,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:l?"#188038":"#1967d2",color:"#ffffff",px:3,py:1.25,minWidth:110,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:l?"#0d652d":"#1557b0",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:l?"Copied!":"Copy"})]})]}),e.jsxs(o.Box,{sx:{display:"flex",gap:1.5},children:[e.jsx(o.Button,{onClick:i,variant:"outlined",startIcon:e.jsx(j.OpenInNew,{sx:{fontSize:18}}),fullWidth:!0,sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"#1967d2",borderColor:"#dadce0",py:1,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{borderColor:"#1967d2",bgcolor:"#f8f9fa"}},children:"Open link"}),e.jsx(o.Button,{onClick:a,variant:"outlined",startIcon:e.jsx(j.Delete,{sx:{fontSize:18}}),fullWidth:!0,sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"#d93025",borderColor:"#dadce0",py:1,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{borderColor:"#d93025",bgcolor:"rgba(217, 48, 37, 0.04)"}},children:"Delete preset"})]})]})}),e.jsx(o.Box,{sx:{px:3,py:2,borderTop:"1px solid #e8eaed",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"#f8f9fa"},children:e.jsx(o.Button,{onClick:c,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#1967d2",color:"#ffffff",px:3,py:1,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#1557b0",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Done"})})]})})}function bd({presetName:t,onClear:r}){return e.jsx(o.Chip,{icon:e.jsx(j.Link,{sx:{fontSize:14}}),label:e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:["Preset: ",e.jsx(o.Box,{component:"span",sx:{fontWeight:600},children:t})]}),onDelete:r,deleteIcon:e.jsx(o.IconButton,{size:"small",title:"Exit preset view",sx:{p:0},children:e.jsx(j.Close,{sx:{fontSize:14}})}),sx:{bgcolor:n=>N(n.palette.primary.main,.12),borderColor:"primary.light",border:1,fontSize:"body2.fontSize",fontWeight:500,"& .MuiChip-deleteIcon":{color:"primary.main","&:hover":{color:"primary.main"}}}})}function vd({presets:t,reportId:r,onOpenPreset:n,onCopyLink:i,onDeletePreset:a,onClose:c}){const[l,d]=u.useState(null),f=(m,g)=>{i(m,g),d(m),setTimeout(()=>d(null),2e3)},h=m=>new Date(m).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});return e.jsx(o.Box,{onClick:c,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(o.Paper,{onClick:m=>m.stopPropagation(),elevation:0,sx:{position:"relative",width:680,maxWidth:"calc(100vw - 120px)",maxHeight:"min(720px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"#ffffff",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid #e8eaed",flexShrink:0},children:[e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"#202124",letterSpacing:"0",lineHeight:1.5},children:"Manage Presets"}),e.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"#5f6368",mt:.5,display:"block"},children:[t.length," saved ",t.length===1?"preset":"presets"]})]}),e.jsx(o.IconButton,{onClick:c,size:"small",sx:{p:.75,color:"#5f6368",transition:"all 0.2s ease","&:hover":{bgcolor:"#f1f3f4",color:"#202124"}},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"#dadce0",borderRadius:4,"&:hover":{bgcolor:"#bdc1c6"}}},children:t.length===0?e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8},children:[e.jsx(j.Share,{sx:{fontSize:48,color:"#dadce0",mb:2}}),e.jsx(o.Typography,{variant:"body1",sx:{fontSize:"0.875rem",color:"#5f6368",textAlign:"center"},children:"No presets created yet"}),e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"#80868b",textAlign:"center",mt:.5},children:"Create a preset to share report configurations"})]}):e.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:t.map(m=>e.jsxs(o.Paper,{elevation:0,sx:{p:2.5,border:"1px solid #e8eaed",borderRadius:"8px",bgcolor:"#ffffff",transition:"all 0.2s ease","&:hover":{borderColor:"#dadce0",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.1), 0 1px 3px 1px rgba(60, 64, 67, 0.05)"}},children:[e.jsx(o.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",mb:1.5},children:e.jsxs(o.Box,{sx:{flex:1,minWidth:0},children:[e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"0.9375rem",fontWeight:500,color:"#202124",mb:.5},children:m.name}),m.description&&e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"#5f6368",lineHeight:1.5},children:m.description})]})}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:2},children:[e.jsx(o.Chip,{label:`Created ${h(m.createdAt)}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"#f1f3f4",color:"#5f6368","& .MuiChip-label":{px:1}}}),e.jsx(o.Chip,{label:`By ${m.createdBy}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"#f1f3f4",color:"#5f6368","& .MuiChip-label":{px:1}}})]}),e.jsx(o.Divider,{sx:{my:1.5,borderColor:"#f1f3f4"}}),e.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[e.jsx(o.Button,{onClick:()=>n(m.id),variant:"outlined",size:"small",startIcon:e.jsx(j.OpenInNew,{sx:{fontSize:16}}),sx:{textTransform:"none",fontSize:"0.8125rem",fontWeight:500,color:"#1967d2",borderColor:"#dadce0",px:1.5,py:.75,borderRadius:"4px","&:hover":{borderColor:"#1967d2",bgcolor:"#f8f9fa"}},children:"Open"}),e.jsx(o.Button,{onClick:()=>f(m.id,m.name),variant:"outlined",size:"small",startIcon:l===m.id?e.jsx(j.Check,{sx:{fontSize:16}}):e.jsx(j.ContentCopy,{sx:{fontSize:16}}),sx:{textTransform:"none",fontSize:"0.8125rem",fontWeight:500,color:l===m.id?"#188038":"#5f6368",borderColor:"#dadce0",px:1.5,py:.75,borderRadius:"4px","&:hover":{borderColor:"#5f6368",bgcolor:"#f8f9fa"}},children:l===m.id?"Copied!":"Copy link"}),e.jsx(o.Button,{onClick:()=>a(m.id,m.name),variant:"outlined",size:"small",startIcon:e.jsx(j.Delete,{sx:{fontSize:16}}),sx:{textTransform:"none",fontSize:"0.8125rem",fontWeight:500,color:"#d93025",borderColor:"#dadce0",px:1.5,py:.75,borderRadius:"4px","&:hover":{borderColor:"#d93025",bgcolor:"rgba(217, 48, 37, 0.04)"}},children:"Delete"})]})]},m.id))})}),e.jsx(o.Box,{sx:{px:3,py:1.75,borderTop:"1px solid #e8eaed",bgcolor:"#f8f9fa",gap:1.25,justifyContent:"flex-end",display:"flex"},children:e.jsx(o.Button,{onClick:c,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#1967d2",color:"#ffffff",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#1557b0",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Close"})})]})})}function Sd({totalRows:t,visibleRows:r,hasGrouping:n,visibleColumnsCount:i,totalColumnsCount:a,onExport:c,onClose:l}){const d=Mr(),[f,h]=u.useState(d.export.allowedFormats[0]||"csv"),[m,g]=u.useState("visible"),[y,S]=u.useState("visible"),C=t>5e4,x=m==="visible"?r:t,E=y==="visible"?i:a,s=()=>{c({format:f,scope:m,columnScope:y}),l()},T={csv:"CSV",excel:"Excel (.xlsx)",json:"JSON"};return e.jsx(o.Box,{onClick:l,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(o.Paper,{onClick:I=>I.stopPropagation(),elevation:0,sx:{position:"relative",width:480,maxWidth:"calc(100vw - 120px)",maxHeight:"min(620px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"#ffffff",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid #e8eaed",flexShrink:0},children:[e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"#202124",letterSpacing:"0",lineHeight:1.5},children:"Export report"}),e.jsx(o.IconButton,{onClick:l,size:"small",sx:{p:.75,color:"#5f6368",transition:"all 0.2s ease","&:hover":{bgcolor:"#f1f3f4",color:"#202124"}},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"#dadce0",borderRadius:4,"&:hover":{bgcolor:"#bdc1c6"}}},children:e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[C&&e.jsxs(o.Alert,{severity:"warning",icon:e.jsx(j.Warning,{sx:{fontSize:20}}),sx:{borderRadius:"8px",border:"1px solid #fdd663",bgcolor:"#fef7e0","& .MuiAlert-icon":{color:"#ea8600"},"& .MuiAlertTitle-root":{fontSize:"0.875rem",fontWeight:500,color:"#3c4043",mb:.5},"& .MuiAlert-message":{fontSize:"0.8125rem",color:"#5f6368"}},children:[e.jsx(o.AlertTitle,{children:"Large dataset warning"}),"This export contains over 50,000 rows. Processing may take a few moments."]}),e.jsxs(o.FormControl,{component:"fieldset",children:[e.jsx(o.FormLabel,{component:"legend",sx:{fontSize:"0.6875rem",fontWeight:600,color:"#5f6368",letterSpacing:"0.1em",mb:1.5,textTransform:"uppercase"},children:"Format"}),e.jsxs(o.RadioGroup,{value:f,onChange:I=>h(I.target.value),children:[d.export.allowedFormats.includes("csv")&&e.jsx(o.FormControlLabel,{value:"csv",control:e.jsx(o.Radio,{size:"small",sx:{color:"#5f6368","&.Mui-checked":{color:"#1967d2"}}}),label:e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:"CSV"}),e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"#5f6368"},children:"Comma-separated values, compatible with Excel"})]}),sx:{mb:1.25,alignItems:"flex-start",px:1.5,py:1,borderRadius:"8px",transition:"background-color 0.2s ease","&:hover":{bgcolor:"#f8f9fa"}}}),d.export.allowedFormats.includes("excel")&&e.jsx(o.FormControlLabel,{value:"excel",control:e.jsx(o.Radio,{size:"small",sx:{color:"#5f6368","&.Mui-checked":{color:"#1967d2"}}}),label:e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:"Excel (.xlsx)"}),e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"#5f6368"},children:"Native Excel format with formatting support"})]}),sx:{mb:1.25,alignItems:"flex-start",px:1.5,py:1,borderRadius:"8px",transition:"background-color 0.2s ease","&:hover":{bgcolor:"#f8f9fa"}}}),d.export.allowedFormats.includes("json")&&e.jsx(o.FormControlLabel,{value:"json",control:e.jsx(o.Radio,{size:"small",sx:{color:"#5f6368","&.Mui-checked":{color:"#1967d2"}}}),label:e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:"JSON"}),e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"#5f6368"},children:"Structured data with metadata and filters"})]}),sx:{alignItems:"flex-start",px:1.5,py:1,borderRadius:"8px",transition:"background-color 0.2s ease","&:hover":{bgcolor:"#f8f9fa"}}})]})]}),e.jsxs(o.FormControl,{component:"fieldset",children:[e.jsx(o.FormLabel,{component:"legend",sx:{fontSize:"0.6875rem",fontWeight:600,color:"#5f6368",letterSpacing:"0.1em",mb:1.5,textTransform:"uppercase"},children:"Rows"}),e.jsxs(o.RadioGroup,{value:m,onChange:I=>g(I.target.value),children:[e.jsx(o.FormControlLabel,{value:"visible",control:e.jsx(o.Radio,{size:"small",sx:{color:"#5f6368","&.Mui-checked":{color:"#1967d2"}}}),label:e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:"Visible rows"}),e.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"#5f6368"},children:["Export ",r.toLocaleString()," rows (filtered and searched)"]})]}),sx:{mb:1.25,alignItems:"flex-start",px:1.5,py:1,borderRadius:"8px",transition:"background-color 0.2s ease","&:hover":{bgcolor:"#f8f9fa"}}}),e.jsx(o.FormControlLabel,{value:"all",control:e.jsx(o.Radio,{size:"small",sx:{color:"#5f6368","&.Mui-checked":{color:"#1967d2"}}}),label:e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:"All rows"}),e.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"#5f6368"},children:["Export ",t.toLocaleString()," rows (complete original dataset)"]})]}),sx:{alignItems:"flex-start",px:1.5,py:1,borderRadius:"8px",transition:"background-color 0.2s ease","&:hover":{bgcolor:"#f8f9fa"}}})]})]}),e.jsxs(o.FormControl,{component:"fieldset",children:[e.jsx(o.FormLabel,{component:"legend",sx:{fontSize:"0.6875rem",fontWeight:600,color:"#5f6368",letterSpacing:"0.1em",mb:1.5,textTransform:"uppercase"},children:"Columns"}),e.jsxs(o.RadioGroup,{value:y,onChange:I=>S(I.target.value),children:[e.jsx(o.FormControlLabel,{value:"visible",control:e.jsx(o.Radio,{size:"small",sx:{color:"#5f6368","&.Mui-checked":{color:"#1967d2"}}}),label:e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:"Visible columns only"}),e.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"#5f6368"},children:["Export ",i," visible columns"]})]}),sx:{mb:1.25,alignItems:"flex-start",px:1.5,py:1,borderRadius:"8px",transition:"background-color 0.2s ease","&:hover":{bgcolor:"#f8f9fa"}}}),e.jsx(o.FormControlLabel,{value:"all",control:e.jsx(o.Radio,{size:"small",sx:{color:"#5f6368","&.Mui-checked":{color:"#1967d2"}}}),label:e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:"All columns"}),e.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"#5f6368"},children:["Export all ",a," columns (including hidden)"]})]}),sx:{alignItems:"flex-start",px:1.5,py:1,borderRadius:"8px",transition:"background-color 0.2s ease","&:hover":{bgcolor:"#f8f9fa"}}})]})]}),e.jsxs(o.Box,{sx:{pt:1},children:[e.jsx(o.Divider,{sx:{mb:2,borderColor:"#e8eaed"}}),e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[e.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"#5f6368"},children:"Format:"}),e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:T[f]})]}),e.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"#5f6368"},children:"Rows to export:"}),e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:x.toLocaleString()})]}),e.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"#5f6368"},children:"Columns to export:"}),e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:E})]})]})]})]})}),e.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid #e8eaed",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"#f8f9fa"},children:[e.jsx(o.Button,{onClick:l,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"#5f6368",px:3,py:1,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"#e8eaed",color:"#202124"}},children:"Cancel"}),e.jsxs(o.Button,{onClick:s,variant:"contained",startIcon:e.jsx(j.Download,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#1967d2",color:"#ffffff",px:3,py:1,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#1557b0",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:["Download ",T[f]]})]})]})})}function Cd({warning:t,onDismiss:r}){return e.jsx(o.Box,{sx:{position:"fixed",top:16,right:16,zIndex:50,maxWidth:448},children:e.jsxs(o.Alert,{severity:"warning",icon:e.jsx(j.Warning,{sx:{fontSize:20}}),action:e.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:"warning.main"},children:e.jsx(j.Close,{sx:{fontSize:16}})}),sx:{borderLeft:4,borderColor:"warning.main",boxShadow:3},children:[e.jsx(o.AlertTitle,{sx:{fontWeight:600},children:"Feature Limit Reached"}),e.jsx(o.Box,{sx:{fontSize:"body2.fontSize",mb:1},children:t.message}),e.jsxs(o.Box,{sx:{fontSize:"caption.fontSize",opacity:.9},children:["Please remove some ",t.type==="filter"?"filters":t.type==="sort"?"sort levels":"grouping levels"," before adding more."]})]})})}function jd({error:t,onDismiss:r,autoDismiss:n=!0,autoDismissDelay:i=5e3}){u.useEffect(()=>{if(n){const d=setTimeout(()=>{r()},i);return()=>clearTimeout(d)}},[n,i,r]);const c=(()=>{switch(t.type){case"system":return{severity:"error",icon:e.jsx(j.Cancel,{sx:{fontSize:20}})};case"processing":return{severity:"warning",icon:e.jsx(j.Warning,{sx:{fontSize:20}})};case"ui":default:return{severity:"info",icon:e.jsx(j.InfoOutlined,{sx:{fontSize:20}})}}})(),l=Js(t);return e.jsx(o.Box,{sx:{position:"fixed",top:16,right:16,zIndex:50,maxWidth:448},children:e.jsxs(o.Alert,{severity:c.severity,icon:c.icon,action:e.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:`${c.severity}.main`},children:e.jsx(j.Close,{sx:{fontSize:16}})}),sx:{borderLeft:4,borderColor:`${c.severity}.main`,boxShadow:3},children:[e.jsxs(o.AlertTitle,{sx:{fontWeight:600},children:[t.context.charAt(0).toUpperCase()+t.context.slice(1)," Error"]}),e.jsx(o.Box,{sx:{fontSize:"body2.fontSize"},children:l}),t.details&&process.env.NODE_ENV==="development"&&e.jsx(o.Box,{component:"pre",sx:{fontSize:"caption.fontSize",mt:1,fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:JSON.stringify(t.details,null,2)})]})})}class wd extends u.Component{constructor(r){super(r),this.handleReset=()=>{this.setState({hasError:!1,error:null})},this.state={hasError:!1,error:null}}static getDerivedStateFromError(r){return{hasError:!0,error:r}}componentDidCatch(r,n){console.error("[ErrorBoundary] Caught error:",r,n),this.props.onError&&this.props.onError(r,n)}render(){var r,n;return this.state.hasError?this.props.fallback?this.props.fallback:e.jsx(o.Paper,{sx:{bgcolor:i=>N(i.palette.error.main,.12),border:1,borderColor:"error.light",borderRadius:2,p:3,m:2},children:e.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.5},children:[e.jsx(j.Warning,{color:"error",sx:{fontSize:24,flexShrink:0}}),e.jsxs(o.Box,{sx:{flex:1},children:[e.jsx(o.Typography,{variant:"h6",sx:{color:"error.main",fontWeight:600},children:this.props.context?`${this.props.context} Error`:"Something went wrong"}),e.jsx(o.Typography,{variant:"body2",sx:{color:"error.main",mt:1},children:((r=this.state.error)==null?void 0:r.message)||"An unexpected error occurred"}),process.env.NODE_ENV==="development"&&e.jsx(o.Box,{component:"pre",sx:{mt:1.5,fontSize:"caption.fontSize",color:"error.main",bgcolor:i=>N(i.palette.error.main,.12),p:1.5,borderRadius:1,overflow:"auto",maxHeight:160},children:(n=this.state.error)==null?void 0:n.stack}),e.jsx(o.Button,{onClick:this.handleReset,variant:"contained",color:"error",startIcon:e.jsx(j.Refresh,{sx:{fontSize:16}}),sx:{mt:2},children:"Try Again"})]})]})}):this.props.children}}function zr({children:t,feature:r,onError:n}){return e.jsx(wd,{context:r,onError:(i,a)=>{n&&n(i)},fallback:e.jsxs(o.Alert,{severity:"warning",sx:{m:1},icon:e.jsx(j.Warning,{sx:{fontSize:20}}),children:[e.jsxs(o.AlertTitle,{children:[r," temporarily unavailable"]}),"Other features continue to work normally"]}),children:t})}const Pn=[{value:"equals",label:"Equals",group:"Text"},{value:"contains",label:"Contains",group:"Text"},{value:"startsWith",label:"Starts with",group:"Text"},{value:"endsWith",label:"Ends with",group:"Text"},{value:"gt",label:"Greater than (>)",group:"Numeric"},{value:"lt",label:"Less than (<)",group:"Numeric"},{value:"gte",label:"At least (≥)",group:"Numeric"},{value:"lte",label:"At most (≤)",group:"Numeric"},{value:"isTrue",label:"Is true",group:"Boolean"},{value:"isFalse",label:"Is false",group:"Boolean"},{value:"NULL",label:"Is empty (NULL)",group:"Null checks"},{value:"NOT_NULL",label:"Is not empty",group:"Null checks"}],kd=[{value:"csv",label:"CSV",desc:"Comma-separated values"},{value:"excel",label:"Excel (.xlsx)",desc:"Native Excel format"},{value:"json",label:"JSON",desc:"Structured data with metadata"}];function Qe({children:t,type:r}){return e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:1.5},children:[e.jsx(o.Box,{sx:{px:1,py:.25,borderRadius:"6px",fontSize:"0.6875rem",fontWeight:700,letterSpacing:"0.06em",textTransform:"uppercase",bgcolor:r==="constraint"?n=>N(n.palette.error.main,.1):n=>N(n.palette.success.main,.1),color:r==="constraint"?"error.dark":"success.dark"},children:r==="constraint"?"Constraint":"Default"}),e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:t})]})}function Ir({children:t,active:r}){return e.jsx(o.Box,{hidden:!r,sx:{pt:2.5,pb:1,display:r?"flex":"none",flexDirection:"column",gap:2.5},children:t})}function Td({open:t,onClose:r,config:n,onApply:i}){const[a,c]=u.useState(0),[l,d]=u.useState(n),f=()=>d(n),h=()=>d(_e),m=()=>{i(l),r()},g={sort:w=>d(O=>({...O,sort:{...O.sort,...w}})),filter:w=>d(O=>({...O,filter:{...O.filter,...w}})),columns:w=>d(O=>({...O,columns:{...O.columns,...w}})),grouping:w=>d(O=>({...O,grouping:{...O.grouping,...w}})),export:w=>d(O=>({...O,export:{...O.export,...w}}))},y=w=>{const O=l.filter.allowedOperators,V=O.includes(w)?O.filter(X=>X!==w):[...O,w];V.length!==0&&g.filter({allowedOperators:V})},S=w=>{const O=l.export.allowedFormats,V=O.includes(w)?O.filter(X=>X!==w):[...O,w];V.length!==0&&g.export({allowedFormats:V})},C=()=>g.sort({defaultSortStack:[...l.sort.defaultSortStack,{column:"",direction:"asc"}]}),x=w=>g.sort({defaultSortStack:l.sort.defaultSortStack.filter((O,V)=>V!==w)}),E=(w,O,V)=>{const X=[...l.sort.defaultSortStack];X[w]={...X[w],[O]:V},g.sort({defaultSortStack:X})},s=()=>g.filter({defaultFilters:[...l.filter.defaultFilters,{column:"",operator:"equals",value:""}]}),T=w=>g.filter({defaultFilters:l.filter.defaultFilters.filter((O,V)=>V!==w)}),I=(w,O,V)=>{const X=[...l.filter.defaultFilters];X[w]={...X[w],[O]:V},g.filter({defaultFilters:X})},A=()=>{const w=l.grouping.defaultGrouping||[];w.length>=l.grouping.maxLevels||g.grouping({defaultGrouping:[...w,{column:""}]})},v=w=>{const V=(l.grouping.defaultGrouping||[]).filter((X,p)=>p!==w);g.grouping({defaultGrouping:V.length?V:null})},W=(w,O)=>{const V=[...l.grouping.defaultGrouping||[]];V[w]={column:O},g.grouping({defaultGrouping:V})},U=[{label:"Sort",icon:e.jsx(j.SwapVert,{sx:{fontSize:17}})},{label:"Filter",icon:e.jsx(j.FilterList,{sx:{fontSize:17}})},{label:"Columns",icon:e.jsx(j.ViewColumn,{sx:{fontSize:17}})},{label:"Grouping",icon:e.jsx(j.Layers,{sx:{fontSize:17}})},{label:"Export",icon:e.jsx(j.Download,{sx:{fontSize:17}})}];return e.jsxs(o.Dialog,{open:t,onClose:r,maxWidth:"sm",fullWidth:!0,TransitionProps:{onEnter:f},PaperProps:{sx:{borderRadius:"12px",maxHeight:"min(720px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:"0 8px 32px rgba(60,64,67,0.2), 0 2px 8px rgba(60,64,67,0.12)"}},children:[e.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(o.Box,{sx:{width:28,height:28,borderRadius:"6px",bgcolor:w=>N(w.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(o.Typography,{sx:{fontSize:"1rem"},children:"⚙️"})}),e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"subtitle1",sx:{fontWeight:600,lineHeight:1.2},children:"Developer Configuration"}),e.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"Constraints · Defaults · Ctrl+Shift+D"})]})]}),e.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:"text.secondary"},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsx(o.Box,{sx:{borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:e.jsx(o.Tabs,{value:a,onChange:(w,O)=>c(O),variant:"fullWidth",sx:{minHeight:42,"& .MuiTab-root":{minHeight:42,fontSize:"0.8125rem",textTransform:"none",fontWeight:500,gap:.5}},children:U.map((w,O)=>e.jsx(o.Tab,{label:w.label,icon:w.icon,iconPosition:"start"},O))})}),e.jsxs(o.DialogContent,{sx:{overflowY:"auto",flex:1,px:3,py:0},children:[e.jsxs(Ir,{active:a===0,children:[e.jsx(Qe,{type:"constraint",children:"Max sort levels"}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:2,mb:1},children:[e.jsx(o.Slider,{value:l.sort.maxLevels,onChange:(w,O)=>g.sort({maxLevels:O}),min:1,max:10,step:1,marks:!0,valueLabelDisplay:"on",sx:{flex:1}}),e.jsx(o.Chip,{label:l.sort.maxLevels===_e.sort.maxLevels?"Default":"Custom",size:"small",color:l.sort.maxLevels===_e.sort.maxLevels?"default":"primary",sx:{minWidth:68}})]}),e.jsxs(o.Typography,{variant:"caption",color:"text.secondary",children:["Users can sort by at most ",l.sort.maxLevels," column",l.sort.maxLevels!==1?"s":""," simultaneously."]}),e.jsx(o.Divider,{sx:{my:.5}}),e.jsx(Qe,{type:"default",children:"Default sort on load"}),e.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1.5},children:"These sort rules are applied automatically when a report first loads. Use exact column key names."}),l.sort.defaultSortStack.map((w,O)=>e.jsxs(o.Box,{sx:{display:"flex",gap:1,mb:1,alignItems:"center"},children:[e.jsx(o.TextField,{size:"small",label:"Column name",value:w.column,onChange:V=>E(O,"column",V.target.value),sx:{flex:1}}),e.jsxs(o.FormControl,{size:"small",sx:{minWidth:130},children:[e.jsx(o.InputLabel,{children:"Direction"}),e.jsxs(o.Select,{value:w.direction,label:"Direction",onChange:V=>E(O,"direction",V.target.value),children:[e.jsx(o.MenuItem,{value:"asc",children:"Ascending ↑"}),e.jsx(o.MenuItem,{value:"desc",children:"Descending ↓"})]})]}),e.jsx(o.IconButton,{size:"small",onClick:()=>x(O),sx:{color:"error.main"},children:e.jsx(j.Delete,{sx:{fontSize:18}})})]},O)),l.sort.defaultSortStack.length<l.sort.maxLevels&&e.jsx(o.Button,{startIcon:e.jsx(j.Add,{sx:{fontSize:16}}),size:"small",onClick:C,sx:{textTransform:"none",fontSize:"0.8125rem",mt:.5},children:"Add default sort level"})]}),e.jsxs(Ir,{active:a===1,children:[e.jsx(Qe,{type:"constraint",children:"Max filter conditions"}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:2,mb:1},children:[e.jsx(o.Slider,{value:l.filter.maxConditions,onChange:(w,O)=>g.filter({maxConditions:O}),min:1,max:20,step:1,marks:!0,valueLabelDisplay:"on",sx:{flex:1}}),e.jsx(o.Chip,{label:l.filter.maxConditions===_e.filter.maxConditions?"Default":"Custom",size:"small",color:l.filter.maxConditions===_e.filter.maxConditions?"default":"primary",sx:{minWidth:68}})]}),e.jsx(o.Divider,{sx:{my:.5}}),e.jsx(Qe,{type:"constraint",children:"Allowed operators"}),e.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1.5},children:"Only checked operators appear in the filter dropdown. At least one must remain checked."}),["Text","Numeric","Boolean","Null checks"].map(w=>e.jsxs(o.Box,{sx:{mb:1.5},children:[e.jsx(o.Typography,{sx:{fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"text.secondary",fontSize:"0.6875rem",display:"block",mb:.5},children:w}),e.jsx(o.FormGroup,{row:!0,sx:{gap:.5},children:Pn.filter(O=>O.group===w).map(O=>e.jsx(o.FormControlLabel,{control:e.jsx(o.Checkbox,{size:"small",checked:l.filter.allowedOperators.includes(O.value),onChange:()=>y(O.value)}),label:e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem"},children:O.label}),sx:{mr:1.5}},O.value))})]},w)),e.jsx(o.Divider,{sx:{my:.5}}),e.jsx(Qe,{type:"default",children:"Default filters on load"}),e.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1.5},children:"These filters are pre-applied when a report first loads. Use exact column key names."}),l.filter.defaultFilters.map((w,O)=>e.jsxs(o.Box,{sx:{display:"flex",gap:1,mb:1,alignItems:"center",flexWrap:"wrap"},children:[e.jsx(o.TextField,{size:"small",label:"Column",value:w.column,onChange:V=>I(O,"column",V.target.value),sx:{flex:1,minWidth:120}}),e.jsxs(o.FormControl,{size:"small",sx:{minWidth:130},children:[e.jsx(o.InputLabel,{children:"Operator"}),e.jsx(o.Select,{value:w.operator,label:"Operator",onChange:V=>I(O,"operator",V.target.value),children:Pn.map(V=>e.jsx(o.MenuItem,{value:V.value,children:V.label},V.value))})]}),e.jsx(o.TextField,{size:"small",label:"Value",value:w.value||"",onChange:V=>I(O,"value",V.target.value),sx:{flex:1,minWidth:100}}),e.jsx(o.IconButton,{size:"small",onClick:()=>T(O),sx:{color:"error.main"},children:e.jsx(j.Delete,{sx:{fontSize:18}})})]},O)),l.filter.defaultFilters.length<l.filter.maxConditions&&e.jsx(o.Button,{startIcon:e.jsx(j.Add,{sx:{fontSize:16}}),size:"small",onClick:s,sx:{textTransform:"none",fontSize:"0.8125rem",mt:.5},children:"Add default filter"})]}),e.jsxs(Ir,{active:a===2,children:[e.jsx(Qe,{type:"constraint",children:"Max visible columns"}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:2,mb:.5},children:[e.jsx(o.Slider,{value:l.columns.maxVisible,onChange:(w,O)=>g.columns({maxVisible:O}),min:1,max:50,step:1,valueLabelDisplay:"on",sx:{flex:1}}),e.jsx(o.Chip,{label:l.columns.maxVisible===_e.columns.maxVisible?"Default":"Custom",size:"small",color:l.columns.maxVisible===_e.columns.maxVisible?"default":"primary",sx:{minWidth:68}})]}),e.jsx(o.Divider,{sx:{my:.5}}),e.jsx(Qe,{type:"constraint",children:"Column width range (px)"}),e.jsxs(o.Box,{sx:{display:"flex",gap:2},children:[e.jsx(o.TextField,{label:"Min width",type:"number",size:"small",value:l.columns.minColumnWidth,onChange:w=>g.columns({minColumnWidth:Math.max(40,Math.min(400,Number(w.target.value)))}),inputProps:{min:40,max:400,step:10},sx:{flex:1}}),e.jsx(o.TextField,{label:"Max width",type:"number",size:"small",value:l.columns.maxColumnWidth,onChange:w=>g.columns({maxColumnWidth:Math.max(100,Math.min(2e3,Number(w.target.value)))}),inputProps:{min:100,max:2e3,step:50},sx:{flex:1}})]}),e.jsx(o.Divider,{sx:{my:.5}}),e.jsx(Qe,{type:"default",children:"Default hidden columns"}),e.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1},children:"Comma-separated exact column key names to hide on first load."}),e.jsx(o.TextField,{size:"small",fullWidth:!0,multiline:!0,rows:2,placeholder:"e.g. id, created_at, internal_notes",value:l.columns.defaultHiddenColumns.join(", "),onChange:w=>g.columns({defaultHiddenColumns:w.target.value.split(",").map(O=>O.trim()).filter(Boolean)})}),e.jsx(o.Divider,{sx:{my:.5}}),e.jsx(Qe,{type:"default",children:"Default column order"}),e.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1},children:"Comma-separated column key names in display order. Omitted columns appear at the end."}),e.jsx(o.TextField,{size:"small",fullWidth:!0,multiline:!0,rows:2,placeholder:"e.g. name, status, assignee, due_date",value:l.columns.defaultColumnOrder.join(", "),onChange:w=>g.columns({defaultColumnOrder:w.target.value.split(",").map(O=>O.trim()).filter(Boolean)})})]}),e.jsxs(Ir,{active:a===3,children:[e.jsx(Qe,{type:"constraint",children:"Max group levels"}),e.jsx(o.Box,{sx:{display:"flex",gap:1.5,mb:1},children:[1,2,3].map(w=>e.jsxs(o.Box,{onClick:()=>g.grouping({maxLevels:w}),sx:{flex:1,py:2.5,borderRadius:"10px",border:"2px solid",cursor:"pointer",borderColor:l.grouping.maxLevels===w?"primary.main":"divider",bgcolor:l.grouping.maxLevels===w?O=>N(O.palette.primary.main,.06):"transparent",textAlign:"center",transition:"all 0.15s ease","&:hover":{borderColor:"primary.light"}},children:[e.jsx(o.Typography,{variant:"h5",sx:{fontWeight:700,color:l.grouping.maxLevels===w?"primary.main":"text.secondary"},children:w}),e.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:["Single","Double","Triple"][w-1]})]},w))}),e.jsxs(o.Box,{sx:{display:"flex",gap:2},children:[e.jsx(o.FormControlLabel,{control:e.jsx(o.Checkbox,{checked:l.grouping.allowNested,onChange:w=>g.grouping({allowNested:w.target.checked})}),label:e.jsx(o.Typography,{variant:"body2",children:"Allow nested groups"})}),e.jsx(o.FormControlLabel,{control:e.jsx(o.Checkbox,{checked:l.grouping.allowCollapse,onChange:w=>g.grouping({allowCollapse:w.target.checked})}),label:e.jsx(o.Typography,{variant:"body2",children:"Allow collapse/expand"})})]}),e.jsx(o.Divider,{sx:{my:.5}}),e.jsx(Qe,{type:"default",children:"Default grouping on load"}),e.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1.5},children:"These group levels are applied automatically on first load. Use exact column key names."}),(l.grouping.defaultGrouping||[]).map((w,O)=>e.jsxs(o.Box,{sx:{display:"flex",gap:1,mb:1,alignItems:"center"},children:[e.jsx(o.Chip,{label:`L${O+1}`,size:"small",color:"primary",sx:{minWidth:36,fontWeight:700}}),e.jsx(o.TextField,{size:"small",label:"Column name",value:w.column,onChange:V=>W(O,V.target.value),sx:{flex:1}}),e.jsx(o.IconButton,{size:"small",onClick:()=>v(O),sx:{color:"error.main"},children:e.jsx(j.Delete,{sx:{fontSize:18}})})]},O)),(l.grouping.defaultGrouping||[]).length<l.grouping.maxLevels&&e.jsx(o.Button,{startIcon:e.jsx(j.Add,{sx:{fontSize:16}}),size:"small",onClick:A,sx:{textTransform:"none",fontSize:"0.8125rem",mt:.5},children:"Add default group level"})]}),e.jsxs(Ir,{active:a===4,children:[e.jsx(Qe,{type:"constraint",children:"Allowed export formats"}),e.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1.5},children:"Only checked formats appear in the Export dialog. At least one must remain checked."}),e.jsx(o.FormGroup,{sx:{gap:1},children:kd.map(w=>e.jsxs(o.Box,{onClick:()=>S(w.value),sx:{display:"flex",alignItems:"center",gap:1.5,p:1.5,borderRadius:"8px",border:"1px solid",cursor:"pointer",transition:"all 0.15s ease",borderColor:l.export.allowedFormats.includes(w.value)?"primary.main":"divider",bgcolor:l.export.allowedFormats.includes(w.value)?O=>N(O.palette.primary.main,.04):"transparent","&:hover":{borderColor:"primary.light"}},children:[e.jsx(o.Checkbox,{size:"small",checked:l.export.allowedFormats.includes(w.value),onChange:()=>S(w.value),onClick:O=>O.stopPropagation()}),e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500},children:w.label}),e.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:w.desc})]})]},w.value))}),e.jsx(o.Alert,{severity:"info",sx:{borderRadius:2,fontSize:"0.8125rem",mt:1},children:'Export constraints apply to both the Export dialog and the bulk "Export Selected" action bar.'})]})]}),e.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid",borderColor:"divider",bgcolor:w=>N(w.palette.action.hover,.4),justifyContent:"space-between",flexShrink:0},children:[e.jsx(o.Button,{startIcon:e.jsx(j.RestartAlt,{sx:{fontSize:18}}),onClick:h,size:"small",sx:{textTransform:"none",fontSize:"0.875rem",color:"text.secondary","&:hover":{color:"text.primary",bgcolor:w=>N(w.palette.text.primary,.06)}},children:"Reset to defaults"}),e.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[e.jsx(o.Button,{onClick:r,size:"small",sx:{textTransform:"none",fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px"},children:"Cancel"}),e.jsx(o.Button,{onClick:m,size:"small",variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2.5,borderRadius:"18px"},children:"Apply"})]})]})]})}function vi({reportEngine:t}){var Ot,_r;const{activeReport:r,paginatedData:n,processedData:i,tableMetrics:a,tableEngine:c,activeView:l,isDirty:d,currentTableState:f,viewChanges:h,showFilterPanel:m,setShowFilterPanel:g,filterFocusColumn:y,handleAddFilter:S,handleUpdateFilter:C,handleRemoveFilter:x,handleClearAllFilters:E,handleOpenFilterForColumn:s,handleCloseFilterPanel:T,handleClearFiltersForColumn:I,showSortPanel:A,setShowSortPanel:v,handleSort:W,handleUpdateSortStack:U,handleSortAscending:w,handleSortDescending:O,showManageViews:V,setShowManageViews:X,showCreateViewModal:p,setShowCreateViewModal:L,showEditViewModal:$,setShowEditViewModal:_,showDeleteConfirmation:F,setShowDeleteConfirmation:oe,editingView:ue,deletingView:Ee,handleSelectView:R,handleCreateView:q,handleUpdateCurrentView:ee,handleSaveColumnConfigToCurrentView:te,handleSaveColumnConfigToAllViews:re,handleSaveAsNewView:ne,handleRevertChanges:Z,handleToggleDefault:Q,handleToggleFavorite:ae,handleSoftDelete:ce,handleRestoreView:le,handlePermanentDelete:je,handleEditView:G,handleSaveEditView:Me,handleConfirmDelete:Ye,showManageColumns:jt,setShowManageColumns:tt,handleUpdateColumnVisibility:$e,handleUpdateColumnOrder:Je,handleUpdateColumnWidth:Ae,handleResetColumnLayout:wt,showGroupPanel:Yt,setShowGroupPanel:pt,handleGroup:rt,handleToggleGroupCollapse:kt,searchQuery:Tt,searchHistory:ft,handleSearchChange:Fe,handleAddToSearchHistory:qe,handleToggleSearchFavourite:Jt,handleDeleteSearchHistory:Be,selectedRowIds:zt,handleToggleRowSelection:Ke,handleToggleAllRows:ot,handleRangeSelection:qt,handleClearSelection:xt,currentPage:Pr,pageSize:mr,paginationEngine:nt,handlePageChange:_t,handlePageSizeChange:gr,isExporting:$t,showExportModal:It,setShowExportModal:Ce,showDirtyExportWarning:Et,handleExport:yr,handleExportWithConfig:Ve,handleExportSelected:P,handleExportAnyway:He,handleSaveAndExport:de,handleCancelExport:Re,showAuditHistory:br,setShowAuditHistory:Ft,showCreatePreset:Bt,setShowCreatePreset:Lt,showShareLink:Nt,setShowShareLink:ht,showManagePresets:Kt,setShowManagePresets:Vt,generatedPreset:ie,activePreset:H,handleOpenSharePreset:it,handleOpenManagePresets:xe,handleCreatePreset:Le,handleCopyPresetLink:Xt,handleOpenPreset:vr,handleDeletePreset:Qt,handleClearActivePreset:Zt,handleOpenPresetById:Ne,handleCopyPresetLinkById:st,handleDeletePresetById:er,isViewerRole:mt,userRole:Sr,featureLimitWarning:tr,setFeatureLimitWarning:rr,reportError:or,setReportError:Cr,handleError:gt,updateReport:at,showSnack:nr,favoriteRowIndices:ir,resolvedFavoritesSet:sr,showFavoritesOnly:We,handleToggleRowFavorite:ar,handleBulkSetFavorites:jr,handleToggleFavoritesFilter:Dt}=t,wr=u.useCallback((ke,Te)=>{if(!(r!=null&&r.uploadedData))return;const At=[...r.uploadedData];At[ke]=Te,at(r.id,{uploadedData:At})},[r,at]),lr=u.useCallback(ke=>{if(!(r!=null&&r.uploadedData))return;const Te=r.uploadedData.filter((At,po)=>po!==ke);at(r.id,{uploadedData:Te})},[r,at]),D=u.useCallback((ke,Te)=>{if(!(r!=null&&r.uploadedData))return;const At=[...r.uploadedData];At.splice(ke+1,0,{...Te}),at(r.id,{uploadedData:At})},[r,at]);if(!r||!r.schemaLocked||!r.schema||!r.uploadedData||!r.views)return null;const Y=Mr(),{handleDevConfigChange:pe}=Kr(),[Pe,se]=u.useState(!1);return u.useEffect(()=>{const ke=Te=>{Te.ctrlKey&&Te.shiftKey&&Te.key==="D"&&(Te.preventDefault(),se(!0))};return document.addEventListener("keydown",ke),()=>document.removeEventListener("keydown",ke)},[]),e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,overflow:"hidden",position:"relative"},children:[!mt&&d&&l&&e.jsx(xd,{viewName:l.name,isDefaultView:l.isDefault,changes:h,onSaveToCurrentView:l.isDefault?void 0:ee,onSaveAsNewView:ne,onCancel:Z}),e.jsxs(o.Box,{id:"table-content-area",sx:{flex:1,minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column",position:"relative"},children:[tr&&e.jsx(Cd,{warning:tr,onDismiss:()=>rr(null)}),or&&e.jsx(jd,{error:or,onDismiss:()=>Cr(null)}),Et&&e.jsx(hd,{onExportAnyway:He,onSaveAndExport:de,onCancel:Re}),e.jsx(od,{schema:r.schema,data:n,sortStack:r.sortStack,filters:r.filters,views:r.views,activeViewId:r.activeViewId,isDirty:d,isExporting:$t,columnVisibility:r.columnVisibility||(l==null?void 0:l.snapshot.columnVisibility),columnOrder:r.columnOrder||(l==null?void 0:l.snapshot.columnOrder),columnWidths:r.columnWidths||(l==null?void 0:l.snapshot.columnWidths),grouping:r.grouping,onSort:W,onSortAscending:w,onSortDescending:O,onOpenFilters:()=>g(!0),onOpenSort:()=>v(!0),onOpenFilterForColumn:s,onSelectView:R,onCreateView:()=>L(!0),onManageViews:()=>X(!0),onUpdateCurrentView:ee,onSaveAsNewView:ne,onToggleDefault:Q,onToggleFavorite:ae,onRestoreView:le,onPermanentDelete:je,onExport:yr,onOpenColumns:()=>tt(!0),onUpdateColumnWidth:Ae,onUpdateColumnOrder:Je,onUpdateColumnVisibility:$e,onClearFiltersForColumn:I,onResetLayout:wt,onOpenGroup:()=>pt(!0),onToggleGroupCollapse:kt,onOpenAuditHistory:()=>Ft(!0),onOpenSharePreset:it,searchQuery:Tt,searchHistory:ft,onAddToSearchHistory:qe,onToggleSearchFavourite:Jt,onDeleteSearchHistory:Be,selectedRowIds:zt,onSearchChange:Fe,onToggleRowSelection:Ke,onToggleAllRows:ot,onRangeSelection:qt,onClearSelection:xt,onExportSelected:P,currentPage:(nt==null?void 0:nt.currentPage)||Pr,pageSize:(nt==null?void 0:nt.pageSize)||mr,onPageChange:_t,onPageSizeChange:gr,totalRowsBeforePagination:(a==null?void 0:a.searchedRows)||i.length,isReadOnly:mt,userRole:Sr,reportName:r.name,onEditRow:wr,onDeleteRow:lr,onDuplicateRow:D,favoriteRowIndices:ir,resolvedFavoritesSet:sr,showFavoritesOnly:We,onToggleRowFavorite:ar,onBulkSetFavorites:jr,onToggleFavoritesFilter:Dt,showDevPanel:Y.display.showDevPanel,onOpenDevConfig:()=>se(!0)})]}),m&&e.jsx(zr,{feature:"Filters",onError:ke=>{const Te=bt("ui","filters",ke);gt(Te)},children:e.jsx(nd,{schema:r.schema,filters:r.filters??[],onAddFilter:S,onUpdateFilter:C,onRemoveFilter:x,onClearAll:E,onClose:T,focusColumn:y})}),A&&e.jsx(zr,{feature:"Sorting",onError:ke=>{const Te=bt("ui","sorting",ke);gt(Te)},children:e.jsx(sd,{schema:r.schema,sortStack:r.sortStack??[],onUpdateSortStack:U,onClose:()=>v(!1)})}),V&&e.jsx(zr,{feature:"Views",onError:ke=>{const Te=bt("ui","views",ke);gt(Te)},children:e.jsx(ad,{views:r.views,activeViewId:r.activeViewId??"",onSelectView:R,onCreateView:()=>{X(!1),L(!0)},onEditView:G,onDeleteView:ce,onRestoreView:le,onPermanentDelete:je,onClose:()=>X(!1)})}),p&&f&&e.jsx(Rn,{currentSnapshot:f,onSave:q,onClose:()=>L(!1)}),$&&ue&&e.jsx(Rn,{currentSnapshot:ue.snapshot,onSave:Me,onClose:()=>{_(!1)},isEditMode:!0,initialName:ue.name,initialDescription:ue.description,initialIsDefault:ue.isDefault}),F&&Ee&&e.jsx(ld,{viewName:Ee.name,onConfirm:Ye,onCancel:()=>{oe(!1)}}),jt&&l&&e.jsx(dd,{schema:r.schema,columnVisibility:r.columnVisibility||l.snapshot.columnVisibility,columnOrder:r.columnOrder||l.snapshot.columnOrder,columnWidths:r.columnWidths||l.snapshot.columnWidths,views:r.views,activeViewId:r.activeViewId,onUpdateColumnVisibility:$e,onUpdateColumnOrder:Je,onUpdateColumnWidth:Ae,onResetLayout:wt,onSelectView:ke=>{R(ke)},onSaveToCurrentView:()=>{te(),tt(!1)},onSaveToAllViews:()=>{re(),tt(!1)},onClose:()=>tt(!1)}),Yt&&e.jsx(zr,{feature:"Grouping",onError:ke=>{const Te=bt("ui","grouping",ke);gt(Te)},children:e.jsx(ud,{schema:r.schema,grouping:r.grouping||null,onApply:rt,onClose:()=>pt(!1)})}),br&&e.jsx(md,{auditHistory:r.auditHistory||[],onClose:()=>Ft(!1)}),Bt&&e.jsx(gd,{onSave:Le,onClose:()=>Lt(!1)}),Nt&&ie&&e.jsx(yd,{presetName:ie.preset.name,shareUrl:ie.url,onCopyLink:Xt,onOpenPreset:vr,onDeletePreset:Qt,onClose:()=>{ht(!1)}}),Kt&&e.jsx(vd,{presets:r.presets||[],reportId:r.id,onOpenPreset:Ne,onCopyLink:st,onDeletePreset:er,onClose:()=>Vt(!1)}),H&&e.jsx(o.Box,{sx:{mt:2},children:e.jsx(bd,{presetName:H.name,onClear:Zt})}),It&&e.jsx(zr,{feature:"Export",onError:ke=>{const Te=bt("ui","export",ke);gt(Te)},children:e.jsx(Sd,{totalRows:(a==null?void 0:a.totalRows)||((Ot=r.uploadedData)==null?void 0:Ot.length)||0,visibleRows:(a==null?void 0:a.searchedRows)||i.length,visibleColumnsCount:((_r=c==null?void 0:c.columnEngine)==null?void 0:_r.visibleColumns.length)||r.schema.length,totalColumnsCount:r.schema.length,hasGrouping:(a==null?void 0:a.isGrouped)||!1,onExport:Ve,onClose:()=>{Ce(!1)}})}),e.jsx(Td,{open:Pe,onClose:()=>se(!1),config:Y,onApply:pe})]})}function Si({open:t,message:r,severity:n,onClose:i}){return e.jsx(o.Snackbar,{open:t,autoHideDuration:4e3,onClose:i,anchorOrigin:{vertical:"top",horizontal:"right"},children:e.jsx(o.Alert,{onClose:i,severity:n,variant:"filled",sx:{width:"100%",boxShadow:3},children:r})})}function Ci(){const t=Kr(),{reports:r,activeReportId:n,activeReport:i,uploadState:a,schema:c,hasSchemaConflicts:l,isModalOpen:d,setIsModalOpen:f,setActiveReportId:h,createReport:m,handleFileUpload:g,handleUploadError:y,handleRetry:S,handleConfirm:C,snack:x,handleSnackClose:E}=t;return e.jsxs(o.Box,{sx:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsx(ha,{onCreateReport:()=>f(!0),reports:r,activeReportId:n,onReportClick:h}),e.jsx(o.Box,{component:"main",sx:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column",m:0,p:0},children:r.length===0?e.jsx(gi,{title:"No reports yet",description:"Create your first report to start analyzing your data."}):i?e.jsx(e.Fragment,{children:i.schemaLocked&&i.schema&&i.uploadedData&&i.views?e.jsx(vi,{reportEngine:t}):e.jsx(o.Box,{sx:{p:3},children:a==="preview"&&i.schema&&i.uploadedData?e.jsx(Tc,{schema:i.schema,onConfirm:C,hasConflicts:l}):i.uploadError?e.jsx(zc,{error:i.uploadError,onRetry:S}):e.jsx(kc,{onFileUpload:g,onError:y,isUploading:a==="uploading"})})}):null}),e.jsx(wc,{isOpen:d,onClose:()=>f(!1),onCreate:m}),e.jsx(Si,{open:x.open,message:x.message,severity:x.severity,onClose:E})]})}function zd(){return e.jsx(Bo,{children:e.jsx(Ci,{})})}function ji(){const t=Kr(),{snack:r,handleSnackClose:n}=t;return e.jsxs(o.Box,{sx:{minHeight:"100vh"},children:[e.jsx(o.Box,{component:"main",children:t.activeReport?e.jsx(vi,{reportEngine:t}):e.jsx(gi,{title:"No report data",description:"This viewer requires report data to be loaded."})}),e.jsx(Si,{open:r.open,message:r.message,severity:r.severity,onClose:n})]})}function Id({data:t,autoLoad:r=!0,config:n}){return e.jsx(Bo,{data:t,mode:"viewer",autoLoad:r,config:n,children:e.jsx(ji,{})})}exports.URMBuilder=zd;exports.URMBuilderRaw=Ci;exports.URMProvider=Bo;exports.URMViewer=Id;exports.URMViewerRaw=ji;exports.useURMContext=Kr;
|