dts-universal-report-module 1.3.7 → 1.3.8

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.
Files changed (3) hide show
  1. package/dist/index.esm.js +5579 -5460
  2. package/dist/index.js +30 -30
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- "use strict";var da=Object.defineProperty;var ua=(e,r,n)=>r in e?da(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n;var Ci=(e,r,n)=>ua(e,typeof r!="symbol"?r+"":r,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),p=require("react"),pa=require("xlsx"),O=require("@mui/icons-material"),o=require("@mui/material"),bs=require("react-dom"),ha=require("@emotion/react"),ir=require("react-dnd"),si=require("react-dnd-html5-backend");function vs(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 an=vs(p),Vo=vs(pa),gt={sort:{maxLevels:5},filter:{maxConditions:3,allowedOperators:["equals","contains","startsWith","endsWith","gt","lt","gte","lte","isTrue","isFalse","NULL","NOT_NULL"]},columns:{maxVisible:20,minColumnWidth:60,maxColumnWidth:800},grouping:{maxLevels:3,allowNested:!0,allowCollapse:!0},export:{allowedFormats:["csv","excel","json","pdf"]},views:{maxViews:10,isAdmin:!1},dates:{displayFormat:null},display:{showDevPanel:!1}},Ss="urm_dev_config";function ma(){try{const e=localStorage.getItem(Ss);if(!e)return gt;const r=JSON.parse(e),n={sort:{...gt.sort,...r.sort},filter:{...gt.filter,...r.filter},columns:{...gt.columns,...r.columns},grouping:{...gt.grouping,...r.grouping},export:{...gt.export,...r.export},views:{...gt.views,...r.views},dates:{...gt.dates,...r.dates},display:{...gt.display,...r.display}};return n.sort.maxLevels=Math.min(5,Math.max(1,n.sort.maxLevels)),n}catch{return gt}}function xa(e){try{localStorage.setItem(Ss,JSON.stringify(e))}catch{}}function fa(e,r,n){if(!n||!r)return e;const i={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},views:{...e.views,...r.views},dates:{...e.dates,...r.dates},display:{...e.display,...r.display}};return i.sort.maxLevels=Math.min(5,Math.max(1,i.sort.maxLevels)),i}const Cs=p.createContext(gt);function br(){return p.useContext(Cs)}const ga=/^\d{4}-\d{2}-\d{2}$/,ya=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/,ba=/^(\d{1,2})[\/\-\.](\d{1,2})[\/\-\.](\d{2,4})$|^([A-Za-z]+)\s+\d{1,2},?\s+\d{4}$/,va=9783072e5,Sa=41024448e5,Ca=978307200,wa=4102444800;function ja(e){return e==null||e===""?"unknown":typeof e=="number"?Number.isInteger(e)&&e>=va&&e<=Sa?"timestamp_ms":Number.isInteger(e)&&e>=Ca&&e<=wa?"timestamp_s":"unknown":typeof e!="string"?"unknown":ya.test(e)||ga.test(e)?"iso":ba.test(e.trim())?"locale_string":"unknown"}function ka(e,r){const n=r.map(c=>c[e]).filter(c=>c!=null&&c!=="");if(n.length===0)return"unknown";const i={iso:0,timestamp_ms:0,timestamp_s:0,locale_string:0,unknown:0};for(const c of n){const l=ja(c);i[l]++}const s=n.length,a=.7;for(const c of["iso","timestamp_ms","timestamp_s","locale_string"])if(i[c]/s>=a)return c;return"unknown"}function za(e,r){if(e==null||e==="")return null;try{switch(r){case"timestamp_ms":{const n=new Date(Number(e));return isNaN(n.getTime())?null:n}case"timestamp_s":{const n=new Date(Number(e)*1e3);return isNaN(n.getTime())?null:n}case"iso":{const n=new Date(String(e));return isNaN(n.getTime())?null:n}case"locale_string":{const n=new Date(String(e));return isNaN(n.getTime())?null:n}default:return null}}catch{return null}}const wi=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Ta=["January","February","March","April","May","June","July","August","September","October","November","December"];function Ye(e){return String(e).padStart(2,"0")}function Ba(e){const r=Date.now()-e.getTime(),n=Math.abs(r),i=r>0,s=Math.floor(n/1e3),a=Math.floor(s/60),c=Math.floor(a/60),l=Math.floor(c/24),u=Math.floor(l/7),g=Math.floor(l/30),f=Math.floor(l/365);let m;return s<60?m="just now":a<60?m=`${a} minute${a!==1?"s":""}`:c<24?m=`${c} hour${c!==1?"s":""}`:l<7?m=`${l} day${l!==1?"s":""}`:u<5?m=`${u} week${u!==1?"s":""}`:g<12?m=`${g} month${g!==1?"s":""}`:m=`${f} year${f!==1?"s":""}`,s<60?m:i?`${m} ago`:`in ${m}`}function Ia(e,r){const n=e.getFullYear(),i=e.getMonth(),s=e.getDate(),a=e.getHours(),c=e.getMinutes();switch(r){case"YYYY-MM-DD":return`${n}-${Ye(i+1)}-${Ye(s)}`;case"DD/MM/YYYY":return`${Ye(s)}/${Ye(i+1)}/${n}`;case"MM/DD/YYYY":return`${Ye(i+1)}/${Ye(s)}/${n}`;case"MMM DD, YYYY":return`${wi[i]} ${Ye(s)}, ${n}`;case"DD MMM YYYY":return`${Ye(s)} ${wi[i]} ${n}`;case"MMMM D, YYYY":return`${Ta[i]} ${s}, ${n}`;case"YYYY-MM-DD HH:mm":return`${n}-${Ye(i+1)}-${Ye(s)} ${Ye(a)}:${Ye(c)}`;case"DD/MM/YYYY HH:mm":return`${Ye(s)}/${Ye(i+1)}/${n} ${Ye(a)}:${Ye(c)}`;case"MM/DD/YYYY HH:mm":return`${Ye(i+1)}/${Ye(s)}/${n} ${Ye(a)}:${Ye(c)}`;case"relative":return Ba(e);case"locale":return e.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"});default:return e.toLocaleDateString()}}function Ea(e,r,n){if(!n||r==="unknown")return String(e);const i=za(e,r);return!i||isNaN(i.getTime())?String(e):Ia(i,n)}function Da(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 ws(e,r="",n=0){if(n>2)return{[r]:e};const i={};for(const s of Object.keys(e)){const a=r?`${r}.${s}`:s,c=e[s];c!==null&&typeof c=="object"&&!Array.isArray(c)&&n<2?Object.assign(i,ws(c,a,n+1)):i[a]=c}return i}function oo(e){return e.map(r=>typeof r!="object"||r===null||Array.isArray(r)?r:ws(r))}function fo(e){if(!Array.isArray(e)||e.length===0)return[];const r=oo(e),n=new Set;r.forEach(c=>{typeof c=="object"&&c!==null&&Object.keys(c).forEach(l=>n.add(l))});const i=[];n.forEach(c=>{const l=new Set;let u=0;r.forEach(v=>{typeof v=="object"&&v!==null&&c in v&&(u++,l.add(Da(v[c])))});const g=u===r.length,f=l.size>1&&!l.has("null");let m="mixed";if(l.size===1)m=Array.from(l)[0];else if(l.size===2&&l.has("null")){const v=Array.from(l).filter(C=>C!=="null");v.length===1&&(m=v[0])}i.push({name:c,type:m,required:g,hasConflict:f})});const a=r.slice(0,50);for(const c of i){if(c.type!=="string"&&c.type!=="number")continue;const l=ka(c.name,a);l!=="unknown"&&(c.type="date",c.dateFormat=l)}return i}function ji(e,r){return!r||r.length===0?e:e.filter(n=>!r.includes(n.name))}function _a(e){return e.some(r=>r.hasConflict)}function dt(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 ki(e){return e==null}function $a(e){return(r,n,i)=>{const s=ki(r),a=ki(n);if(s&&a)return 0;if(s)return 1;if(a)return-1;let c=0;switch(e){case"number":const l=Number(r),u=Number(n);c=l-u;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 Oa(e,r,n){if(!n||n.length===0)return e;const i=[...n].sort((s,a)=>s.priority-a.priority);return[...e].sort((s,a)=>{for(const c of i){const l=r.find(f=>f.name===c.column);if(!l)continue;const g=$a(l.type)(s[c.column],a[c.column],c.direction);if(g!==0)return g}return 0})}function Ma(e){return e===null?"asc":e==="asc"?"desc":null}function Wa(e){return e==="string"||e==="boolean"}function Aa(e){return e.filter(r=>Wa(r.type))}function Ra(e,r){const n={};return r.forEach(i=>{if(i.type==="number"){const s=e.map(a=>a[i.name]).filter(a=>typeof a=="number");s.length>0&&(n[i.name]=s.reduce((a,c)=>a+c,0))}}),n}function Pa(e,r,n){if(!n.enabled||n.levels.length===0)return e;const i=ai(e,n.levels,r);return js(i,n.collapsedGroups||[])}function ai(e,r,n,i="",s=0){if(s>=r.length)return e;const a=r[s].column,c=new Map;e.forEach(g=>{const f=g[a],m=f==null?"(empty)":String(f);c.has(m)||c.set(m,[]),c.get(m).push(g)});const l=[];return Array.from(c.keys()).sort().forEach(g=>{const f=c.get(g),m=`${a}:${g}`,v=i?`${i}|${m}`:m,C=Ra(f,n),B=s<r.length-1?ai(f,r,n,v,s+1):f,b={key:v,level:s,column:a,value:g,rowCount:f.length,aggregates:C,children:B};l.push(b)}),l}function js(e,r,n=[],i=0){for(const s of e)if("key"in s&&"level"in s&&"children"in s){const a=r.includes(s.key);n.push({isGroupHeader:!0,groupKey:s.key,groupLevel:s.level,groupColumn:s.column,groupValue:s.value,rowCount:s.rowCount,aggregates:s.aggregates,isCollapsed:a}),!a&&s.children&&js(s.children,r,n,i+1)}else n.push({...s,__urm_row_id__:s.__urm_row_id__,__urm_is_grouped_data_row__:!0,__urm_group_level__:i});return n}function zi(e,r,n){if(!n.enabled||n.levels.length===0)return[];const i=ai(e,n.levels,r),s=[],a=c=>{for(const l of c)"key"in l&&"level"in l&&"children"in l&&(s.push(l.key),a(l.children))};return a(i),s}function Na(e,r){const n=e.collapsedGroups||[],i=n.includes(r)?n.filter(s=>s!==r):[...n,r];return{...e,collapsedGroups:i}}function ks(e,r){return e==null?"":typeof e=="number"?`Σ ${e.toLocaleString()}`:String(e)}function La(e,r,n){const i=r?dt(r):"",s=String(n??"");return i?`${i}: ${s}`:s}function io(){return`flt_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Je(e){return"children"in e}function Rt(){return{id:io(),operator:"and",children:[]}}function Fe(e){return e?Array.isArray(e)?{id:io(),operator:"and",children:e.map(r=>({...r,id:r.id??io()}))}:e:Rt()}function Tt(e){return e?Je(e)?e.children.reduce((r,n)=>r+Tt(n),0):1:0}function Xo(e,r){if(e.id===r)return e;for(const n of e.children){if(n.id===r)return n;if(Je(n)){const i=Xo(n,r);if(i)return i}}}function so(e,r,n){return e.id===r?{...e,children:[...e.children,n]}:{...e,children:e.children.map(i=>Je(i)?so(i,r,n):i)}}function li(e,r,n){return{...e,children:e.children.map(i=>i.id===r&&!Je(i)?{...i,...n}:Je(i)?li(i,r,n):i)}}function ci(e,r,n){return e.id===r?{...e,operator:n}:{...e,children:e.children.map(i=>Je(i)?ci(i,r,n):i)}}function di(e,r){const n=e.children.filter(i=>i.id!==r).map(i=>Je(i)?di(i,r):i).filter(i=>!Je(i)||i.children.length>0);return{...e,children:n}}function Zn(e,r){return e?Je(e)?e.children.some(n=>Zn(n,r)):e.column===r:!1}function zs(e,r){const n=e.children.filter(i=>Je(i)||i.column!==r).map(i=>Je(i)?zs(i,r):i).filter(i=>!Je(i)||i.children.length>0);return{...e,children:n}}function Ts(e){return e?Je(e)?e.children.flatMap(Ts):[e]:[]}function To(e){if(!e)return null;if(!Je(e)){const{id:i,...s}=e;return s}const{id:r,...n}=e;return{...n,children:e.children.map(To)}}function vo(e,r){if(!r||!r.enabled||!r.levels||r.levels.length===0)return[...e];const n=r.levels.map(s=>s.column),i=e.filter(s=>!n.includes(s));return[...n,...i]}function ui(e,r,n){if(!r||!r.enabled||!r.levels||r.levels.length===0)return[...e];const i=r.levels.map(a=>a.column),s=e.filter(a=>!i.includes(a));if(n){const a=[],c=new Set(i),l=new Set(s);let u=0;for(const g of n)c.has(g)?a.push(g):l.has(g)&&u<s.length?(a.push(s[u]),u++):l.has(g)||a.push(g);for(let g=u;g<s.length;g++)a.includes(s[g])||a.push(s[g]);return a}return[...e]}function Fn(e){const r={},n=[],i={};return e.forEach(s=>{r[s.name]=!0,n.push(s.name),i[s.name]=170}),{id:"default-view",name:"Default View",description:"Unfiltered, unsorted baseline view",isDefault:!0,snapshot:{filters:Rt(),sortStack:[],columnVisibility:r,columnOrder:n,columnWidths:i,grouping:null}}}function Fa(e,r,n,i,s,a,c,l){const u={},g=[],f={};n.forEach(C=>{u[C.name]=!0,g.push(C.name),f[C.name]=170});const v=ui(s||g,c||null,l||g);return{filters:Fe(e),sortStack:r||[],columnVisibility:i||u,columnOrder:v,columnWidths:a||f,grouping:c||null}}function Va(e,r){const n=C=>{if(C==null)return C;if(Array.isArray(C))return C.map(B=>n(B));if(typeof C=="object"){const B={};return Object.keys(C).sort().forEach(b=>{B[b]=n(C[b])}),B}return C},i=C=>JSON.stringify(n(C));if(i(To(e.filters))!==i(To(r.filters))||i(e.sortStack)!==i(r.sortStack))return!0;const s=e.columnVisibility??{},a=r.columnVisibility??{};if(i(s)!==i(a))return!0;const c=ui(e.columnOrder||[],e.grouping||null,r.columnOrder||[]),l=[...c].sort().join(","),u=[...r.columnOrder||[]].sort().join(",");if(l!==u)return!1;const g=[...r.columnOrder||[]].sort().join(",");if((r.columnOrder||[]).join(",")!==g){if(c.join(",")!==(r.columnOrder||[]).join(","))return!0}else{const C=[...c].sort().join(",");if(c.join(",")!==C)return!0}const m=e.columnWidths??{},v=r.columnWidths??{};return i(m)!==i(v)||i(e.grouping)!==i(r.grouping)}function Ha(e){return!e||e.length===0?"None":e.sort((r,n)=>r.priority-n.priority).map(r=>`${r.column} ${r.direction==="asc"?"↑":"↓"}`).join(", ")}function Ga(e,r){var b,y,z;const n=[],i=JSON.stringify(To(e.filters)),s=JSON.stringify(To(r.filters));if(i!==s){const x=Tt(e.filters),j=Tt(r.filters);x>j?n.push({category:"filters",label:"Filters Added",description:`${x-j} new filter${x-j>1?"s":""} added`}):x<j?n.push({category:"filters",label:"Filters Removed",description:`${j-x} filter${j-x>1?"s":""} removed`}):n.push({category:"filters",label:"Filters Modified",description:"Filter conditions have been changed"})}const a=JSON.stringify(e.sortStack),c=JSON.stringify(r.sortStack);if(a!==c){const x=e.sortStack.length,j=r.sortStack.length;x>j?n.push({category:"sorting",label:"Sorting Added",description:`${x-j} new sort rule${x-j>1?"s":""} added`}):x<j?n.push({category:"sorting",label:"Sorting Removed",description:`${j-x} sort rule${j-x>1?"s":""} removed`}):n.push({category:"sorting",label:"Sorting Modified",description:"Sort rules or order have been changed"})}const l=JSON.stringify(e.columnVisibility),u=JSON.stringify(r.columnVisibility);if(l!==u){const x=Object.values(e.columnVisibility).filter(E=>E).length,j=Object.values(r.columnVisibility).filter(E=>E).length;x>j?n.push({category:"visibility",label:"Columns Shown",description:`${x-j} column${x-j>1?"s":""} made visible`}):x<j?n.push({category:"visibility",label:"Columns Hidden",description:`${j-x} column${j-x>1?"s":""} hidden`}):n.push({category:"visibility",label:"Column Visibility Changed",description:"Column visibility settings have been modified"})}const g=JSON.stringify(e.columnOrder),f=JSON.stringify(r.columnOrder);g!==f&&n.push({category:"order",label:"Column Order Changed",description:"Columns have been reordered"});const m=JSON.stringify(e.columnWidths),v=JSON.stringify(r.columnWidths);if(m!==v){const x=Object.keys(e.columnWidths).filter(j=>e.columnWidths[j]!==r.columnWidths[j]).length;n.push({category:"widths",label:"Column Widths Adjusted",description:`${x} column width${x>1?"s":""} modified`})}const C=JSON.stringify(e.grouping),B=JSON.stringify(r.grouping);if(C!==B){const x=(b=e.grouping)==null?void 0:b.enabled,j=(y=r.grouping)==null?void 0:y.enabled;if(x&&!j){const E=((z=e.grouping)==null?void 0:z.levels.length)||0;n.push({category:"grouping",label:"Grouping Applied",description:`${E} grouping level${E>1?"s":""} added`})}else!x&&j?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}function Ti(){try{return localStorage.getItem("urm:debug")==="true"}catch{return!1}}function Bi(e){return`[${e}]`}const Ut={warn(e,r,...n){Ti()&&console.warn(Bi(e),r,...n)},error(e,r,...n){Ti()&&console.error(Bi(e),r,...n)}},Bs="urm_report_";function Ua(e,r){try{const n=`${Bs}${e}`;localStorage.setItem(n,JSON.stringify(r))}catch(n){Ut.error("urm:persistence","Failed to save report state",n)}}function Ya(e){try{const r=`${Bs}${e}`,n=localStorage.getItem(r);return n?JSON.parse(n):null}catch(r){return Ut.error("urm:persistence","Failed to load report state",r),null}}function Io(e,r,n=0){const i=[];for(const s of e){const a=r.includes(s.key);if(i.push({type:"group",key:s.key,level:n,column:s.column,value:s.value,rowCount:s.rowCount,aggregates:s.aggregates,collapsed:a}),!a&&s.children&&s.children.length>0){const c=s.children[0];if(qa(c)){const l=s.children,u=Io(l,r,n+1);i.push(...u)}else{const l=s.children;for(const u of l)i.push({type:"row",parentGroupKey:s.key,level:n+1,data:u})}}}return i}function qa(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 ln(e){return e.filter(r=>r.type==="row").map(r=>r.type==="row"?r.data:null).filter(r=>r!==null)}function cn(e,r){const n=new Date,i=n.getFullYear(),s=String(n.getMonth()+1).padStart(2,"0"),a=String(n.getDate()).padStart(2,"0"),c=`${i}-${s}-${a}`;return`${e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}_${c}.${r}`}function Zo(e,r,n,i,s,a,c){let l,u;a?(l={...a},u=c||r.map(f=>f.name)):s?(l={...s.snapshot.columnVisibility},u=c||[...s.snapshot.columnOrder]):(l={},u=[],r.forEach(f=>{l[f.name]=!0,u.push(f.name)}));const g=Object.entries(l).filter(([f,m])=>!m).map(([f,m])=>f);return{data:e,schema:r,appliedFilters:n,appliedSortStack:i,columnVisibility:l,columnOrder:u,grouping:(s==null?void 0:s.snapshot.grouping)??null,hiddenColumns:g,viewMeta:s?{id:s.id,name:s.name,isDefault:s.isDefault}:void 0}}function en(e,r="export",n){const{data:i,columnOrder:s,grouping:a}=e,c=s.filter(m=>e.columnVisibility[m]);let l;if(a&&a.enabled){const m=a.collapsedGroups??[],v=Io(i,m);l=ln(v)}else l=i;const u=c.join(","),g=l.map(m=>c.map(v=>{const C=m[v];if(C==null)return"";const B=String(C);return B.includes(",")||B.includes('"')||B.includes(`
2
- `)?`"${B.replace(/"/g,'""')}"`:B}).join(",")),f=[u,...g].join(`
3
- `);pi(f,cn(r,"csv"),"text/csv;charset=utf-8;")}function tn(e,r="export",n){const{data:i,columnOrder:s,grouping:a}=e,c=s.filter(m=>e.columnVisibility[m]);let l;if(a&&a.enabled){const m=a.collapsedGroups??[],v=Io(i,m);l=ln(v)}else l=i;const u=[c,...l.map(m=>c.map(v=>m[v]??""))],g=Vo.utils.aoa_to_sheet(u),f=Vo.utils.book_new();Vo.utils.book_append_sheet(f,g,"Data"),Vo.writeFile(f,cn(r,"xlsx"))}function rn(e,r="export",n){const{data:i,appliedFilters:s,appliedSortStack:a,viewMeta:c,hiddenColumns:l,columnOrder:u,grouping:g}=e,f=u.filter(B=>e.columnVisibility[B]);let m;if(g&&g.enabled){const B=g.collapsedGroups??[],b=Io(i,B);m=ln(b)}else m=i;m=m.map(B=>{const b={};return f.forEach(y=>{b[y]=B[y]}),b});const v={meta:{exportedAt:new Date().toISOString(),reportName:r,view:(c==null?void 0:c.name)||"Default View",filters:Ts(s).map(B=>({field:B.column,operator:B.operator,value:B.value})),sortStack:a.map(B=>({field:B.column,direction:B.direction,priority:B.priority})),grouping:g||{},hiddenColumns:l,columnOrder:u,exportConfig:n||{scope:"visible"}},data:m},C=JSON.stringify(v,null,2);pi(C,cn(r,"json"),"application/json;charset=utf-8;")}function pi(e,r,n){const i=new Blob([e],{type:n}),s=URL.createObjectURL(i),a=document.createElement("a");a.href=s,a.download=r,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(s)}function hi(e,r="export",n){var b;const{data:i,columnOrder:s,grouping:a}=e,c=s.filter(y=>e.columnVisibility[y]);let l;if(a&&a.enabled){const y=a.collapsedGroups??[],z=Io(i,y);l=ln(z)}else l=i;const u=new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}),g=c.map(y=>`<th>${Ho(y)}</th>`).join(""),f=l.map((y,z)=>{const x=c.map(j=>{const E=y[j],S=E==null?"":String(E);return`<td>${Ho(S)}</td>`}).join("");return`<tr class="${z%2===0?"even":"odd"}">${x}</tr>`}).join(""),m=`<!DOCTYPE html>
1
+ "use strict";var pa=Object.defineProperty;var ha=(e,r,n)=>r in e?pa(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n;var ji=(e,r,n)=>ha(e,typeof r!="symbol"?r+"":r,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),p=require("react"),fa=require("xlsx"),$=require("@mui/icons-material"),o=require("@mui/material"),Ss=require("react-dom"),ma=require("@emotion/react"),or=require("react-dnd"),si=require("react-dnd-html5-backend");function Cs(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 ln=Cs(p),Ho=Cs(fa),xt={sort:{maxLevels:5},filter:{maxConditions:3,allowedOperators:["equals","contains","startsWith","endsWith","gt","lt","gte","lte","isTrue","isFalse","NULL","NOT_NULL"]},columns:{maxVisible:20,minColumnWidth:60,maxColumnWidth:800},grouping:{maxLevels:3,allowNested:!0,allowCollapse:!0},export:{allowedFormats:["csv","excel","json","pdf"]},views:{maxViews:10,isAdmin:!1},dates:{displayFormat:null},display:{showDevPanel:!1}},ws="urm_dev_config";function xa(){try{const e=localStorage.getItem(ws);if(!e)return xt;const r=JSON.parse(e),n={sort:{...xt.sort,...r.sort},filter:{...xt.filter,...r.filter},columns:{...xt.columns,...r.columns},grouping:{...xt.grouping,...r.grouping},export:{...xt.export,...r.export},views:{...xt.views,...r.views},dates:{...xt.dates,...r.dates},display:{...xt.display,...r.display}};return n.sort.maxLevels=Math.min(5,Math.max(1,n.sort.maxLevels)),n}catch{return xt}}function ga(e){try{localStorage.setItem(ws,JSON.stringify(e))}catch{}}function ya(e,r,n){if(!n||!r)return e;const i={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},views:{...e.views,...r.views},dates:{...e.dates,...r.dates},display:{...e.display,...r.display}};return i.sort.maxLevels=Math.min(5,Math.max(1,i.sort.maxLevels)),i}const js=p.createContext(xt);function gr(){return p.useContext(js)}const ba=/^\d{4}-\d{2}-\d{2}$/,va=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/,Sa=/^(\d{1,2})[\/\-\.](\d{1,2})[\/\-\.](\d{2,4})$|^([A-Za-z]+)\s+\d{1,2},?\s+\d{4}$/,Ca=9783072e5,wa=41024448e5,ja=978307200,ka=4102444800;function za(e){return e==null||e===""?"unknown":typeof e=="number"?Number.isInteger(e)&&e>=Ca&&e<=wa?"timestamp_ms":Number.isInteger(e)&&e>=ja&&e<=ka?"timestamp_s":"unknown":typeof e!="string"?"unknown":va.test(e)||ba.test(e)?"iso":Sa.test(e.trim())?"locale_string":"unknown"}function Ta(e,r){const n=r.map(c=>c[e]).filter(c=>c!=null&&c!=="");if(n.length===0)return"unknown";const i={iso:0,timestamp_ms:0,timestamp_s:0,locale_string:0,unknown:0};for(const c of n){const l=za(c);i[l]++}const s=n.length,a=.7;for(const c of["iso","timestamp_ms","timestamp_s","locale_string"])if(i[c]/s>=a)return c;return"unknown"}function Ba(e,r){if(e==null||e==="")return null;try{switch(r){case"timestamp_ms":{const n=new Date(Number(e));return isNaN(n.getTime())?null:n}case"timestamp_s":{const n=new Date(Number(e)*1e3);return isNaN(n.getTime())?null:n}case"iso":{const n=new Date(String(e));return isNaN(n.getTime())?null:n}case"locale_string":{const n=new Date(String(e));return isNaN(n.getTime())?null:n}default:return null}}catch{return null}}const ki=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Ia=["January","February","March","April","May","June","July","August","September","October","November","December"];function qe(e){return String(e).padStart(2,"0")}function Ea(e){const r=Date.now()-e.getTime(),n=Math.abs(r),i=r>0,s=Math.floor(n/1e3),a=Math.floor(s/60),c=Math.floor(a/60),l=Math.floor(c/24),u=Math.floor(l/7),g=Math.floor(l/30),x=Math.floor(l/365);let f;return s<60?f="just now":a<60?f=`${a} minute${a!==1?"s":""}`:c<24?f=`${c} hour${c!==1?"s":""}`:l<7?f=`${l} day${l!==1?"s":""}`:u<5?f=`${u} week${u!==1?"s":""}`:g<12?f=`${g} month${g!==1?"s":""}`:f=`${x} year${x!==1?"s":""}`,s<60?f:i?`${f} ago`:`in ${f}`}function Da(e,r){const n=e.getFullYear(),i=e.getMonth(),s=e.getDate(),a=e.getHours(),c=e.getMinutes();switch(r){case"YYYY-MM-DD":return`${n}-${qe(i+1)}-${qe(s)}`;case"DD/MM/YYYY":return`${qe(s)}/${qe(i+1)}/${n}`;case"MM/DD/YYYY":return`${qe(i+1)}/${qe(s)}/${n}`;case"MMM DD, YYYY":return`${ki[i]} ${qe(s)}, ${n}`;case"DD MMM YYYY":return`${qe(s)} ${ki[i]} ${n}`;case"MMMM D, YYYY":return`${Ia[i]} ${s}, ${n}`;case"YYYY-MM-DD HH:mm":return`${n}-${qe(i+1)}-${qe(s)} ${qe(a)}:${qe(c)}`;case"DD/MM/YYYY HH:mm":return`${qe(s)}/${qe(i+1)}/${n} ${qe(a)}:${qe(c)}`;case"MM/DD/YYYY HH:mm":return`${qe(i+1)}/${qe(s)}/${n} ${qe(a)}:${qe(c)}`;case"relative":return Ea(e);case"locale":return e.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"});default:return e.toLocaleDateString()}}function _a(e,r,n){if(!n||r==="unknown")return String(e);const i=Ba(e,r);return!i||isNaN(i.getTime())?String(e):Da(i,n)}function $a(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 ks(e,r="",n=0){if(n>2)return{[r]:e};const i={};for(const s of Object.keys(e)){const a=r?`${r}.${s}`:s,c=e[s];c!==null&&typeof c=="object"&&!Array.isArray(c)&&n<2?Object.assign(i,ks(c,a,n+1)):i[a]=c}return i}function io(e){return e.map(r=>typeof r!="object"||r===null||Array.isArray(r)?r:ks(r))}function xo(e){if(!Array.isArray(e)||e.length===0)return[];const r=io(e),n=new Set;r.forEach(c=>{typeof c=="object"&&c!==null&&Object.keys(c).forEach(l=>n.add(l))});const i=[];n.forEach(c=>{const l=new Set;let u=0;r.forEach(S=>{typeof S=="object"&&S!==null&&c in S&&(u++,l.add($a(S[c])))});const g=u===r.length,x=l.size>1&&!l.has("null");let f="mixed";if(l.size===1)f=Array.from(l)[0];else if(l.size===2&&l.has("null")){const S=Array.from(l).filter(C=>C!=="null");S.length===1&&(f=S[0])}i.push({name:c,type:f,required:g,hasConflict:x})});const a=r.slice(0,50);for(const c of i){if(c.type!=="string"&&c.type!=="number")continue;const l=Ta(c.name,a);l!=="unknown"&&(c.type="date",c.dateFormat=l)}return i}function zi(e,r){return!r||r.length===0?e:e.filter(n=>!r.includes(n.name))}function Oa(e){return e.some(r=>r.hasConflict)}function dt(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 Ti(e){return e==null}function Ma(e){return(r,n,i)=>{const s=Ti(r),a=Ti(n);if(s&&a)return 0;if(s)return 1;if(a)return-1;let c=0;switch(e){case"number":const l=Number(r),u=Number(n);c=l-u;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 Aa(e,r,n){if(!n||n.length===0)return e;const i=[...n].sort((s,a)=>s.priority-a.priority);return[...e].sort((s,a)=>{for(const c of i){const l=r.find(x=>x.name===c.column);if(!l)continue;const g=Ma(l.type)(s[c.column],a[c.column],c.direction);if(g!==0)return g}return 0})}function Wa(e){return e===null?"asc":e==="asc"?"desc":null}function Ra(e){return e==="string"||e==="boolean"}function Pa(e){return e.filter(r=>Ra(r.type))}function Na(e,r){const n={};return r.forEach(i=>{if(i.type==="number"){const s=e.map(a=>a[i.name]).filter(a=>typeof a=="number");s.length>0&&(n[i.name]=s.reduce((a,c)=>a+c,0))}}),n}function La(e,r,n){if(!n.enabled||n.levels.length===0)return e;const i=ai(e,n.levels,r);return zs(i,n.collapsedGroups||[])}function ai(e,r,n,i="",s=0){if(s>=r.length)return e;const a=r[s].column,c=new Map;e.forEach(g=>{const x=g[a],f=x==null?"(empty)":String(x);c.has(f)||c.set(f,[]),c.get(f).push(g)});const l=[];return Array.from(c.keys()).sort().forEach(g=>{const x=c.get(g),f=`${a}:${g}`,S=i?`${i}|${f}`:f,C=Na(x,n),B=s<r.length-1?ai(x,r,n,S,s+1):x,v={key:S,level:s,column:a,value:g,rowCount:x.length,aggregates:C,children:B};l.push(v)}),l}function zs(e,r,n=[],i=0){for(const s of e)if("key"in s&&"level"in s&&"children"in s){const a=r.includes(s.key);n.push({isGroupHeader:!0,groupKey:s.key,groupLevel:s.level,groupColumn:s.column,groupValue:s.value,rowCount:s.rowCount,aggregates:s.aggregates,isCollapsed:a}),!a&&s.children&&zs(s.children,r,n,i+1)}else n.push({...s,__urm_row_id__:s.__urm_row_id__,__urm_is_grouped_data_row__:!0,__urm_group_level__:i});return n}function Bi(e,r,n){if(!n.enabled||n.levels.length===0)return[];const i=ai(e,n.levels,r),s=[],a=c=>{for(const l of c)"key"in l&&"level"in l&&"children"in l&&(s.push(l.key),a(l.children))};return a(i),s}function Fa(e,r){const n=e.collapsedGroups||[],i=n.includes(r)?n.filter(s=>s!==r):[...n,r];return{...e,collapsedGroups:i}}function Ts(e,r){return e==null?"":typeof e=="number"?`Σ ${e.toLocaleString()}`:String(e)}function Va(e,r,n){const i=r?dt(r):"",s=String(n??"");return i?`${i}: ${s}`:s}function ao(){return`flt_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Xe(e){return"children"in e}function At(){return{id:ao(),operator:"and",children:[]}}function He(e){return e?Array.isArray(e)?{id:ao(),operator:"and",children:e.map(r=>({...r,id:r.id??ao()}))}:e:At()}function Tt(e){return e?Xe(e)?e.children.reduce((r,n)=>r+Tt(n),0):1:0}function Qo(e,r){if(e.id===r)return e;for(const n of e.children){if(n.id===r)return n;if(Xe(n)){const i=Qo(n,r);if(i)return i}}}function lo(e,r,n){return e.id===r?{...e,children:[...e.children,n]}:{...e,children:e.children.map(i=>Xe(i)?lo(i,r,n):i)}}function li(e,r,n){return{...e,children:e.children.map(i=>i.id===r&&!Xe(i)?{...i,...n}:Xe(i)?li(i,r,n):i)}}function ci(e,r,n){return e.id===r?{...e,operator:n}:{...e,children:e.children.map(i=>Xe(i)?ci(i,r,n):i)}}function di(e,r){const n=e.children.filter(i=>i.id!==r).map(i=>Xe(i)?di(i,r):i).filter(i=>!Xe(i)||i.children.length>0);return{...e,children:n}}function Zn(e,r){return e?Xe(e)?e.children.some(n=>Zn(n,r)):e.column===r:!1}function Bs(e,r){const n=e.children.filter(i=>Xe(i)||i.column!==r).map(i=>Xe(i)?Bs(i,r):i).filter(i=>!Xe(i)||i.children.length>0);return{...e,children:n}}function Is(e){return e?Xe(e)?e.children.flatMap(Is):[e]:[]}function To(e){if(!e)return null;if(!Xe(e)){const{id:i,...s}=e;return s}const{id:r,...n}=e;return{...n,children:e.children.map(To)}}function vo(e,r){if(!r||!r.enabled||!r.levels||r.levels.length===0)return[...e];const n=r.levels.map(s=>s.column),i=e.filter(s=>!n.includes(s));return[...n,...i]}function ui(e,r,n){if(!r||!r.enabled||!r.levels||r.levels.length===0)return[...e];const i=r.levels.map(a=>a.column),s=e.filter(a=>!i.includes(a));if(n){const a=[],c=new Set(i),l=new Set(s);let u=0;for(const g of n)c.has(g)?a.push(g):l.has(g)&&u<s.length?(a.push(s[u]),u++):l.has(g)||a.push(g);for(let g=u;g<s.length;g++)a.includes(s[g])||a.push(s[g]);return a}return[...e]}function Fn(e){const r={},n=[],i={};return e.forEach(s=>{r[s.name]=!0,n.push(s.name),i[s.name]=170}),{id:"default-view",name:"Default View",description:"Unfiltered, unsorted baseline view",isDefault:!0,snapshot:{filters:At(),sortStack:[],columnVisibility:r,columnOrder:n,columnWidths:i,grouping:null}}}function Ha(e,r,n,i,s,a,c,l){const u={},g=[],x={};n.forEach(C=>{u[C.name]=!0,g.push(C.name),x[C.name]=170});const S=ui(s||g,c||null,l||g);return{filters:He(e),sortStack:r||[],columnVisibility:i||u,columnOrder:S,columnWidths:a||x,grouping:c||null}}function Ua(e,r){const n=C=>{if(C==null)return C;if(Array.isArray(C))return C.map(B=>n(B));if(typeof C=="object"){const B={};return Object.keys(C).sort().forEach(v=>{B[v]=n(C[v])}),B}return C},i=C=>JSON.stringify(n(C));if(i(To(e.filters))!==i(To(r.filters))||i(e.sortStack)!==i(r.sortStack))return!0;const s=e.columnVisibility??{},a=r.columnVisibility??{};if(i(s)!==i(a))return!0;const c=ui(e.columnOrder||[],e.grouping||null,r.columnOrder||[]),l=[...c].sort().join(","),u=[...r.columnOrder||[]].sort().join(",");if(l!==u)return!1;const g=[...r.columnOrder||[]].sort().join(",");if((r.columnOrder||[]).join(",")!==g){if(c.join(",")!==(r.columnOrder||[]).join(","))return!0}else{const C=[...c].sort().join(",");if(c.join(",")!==C)return!0}const f=e.columnWidths??{},S=r.columnWidths??{};return i(f)!==i(S)||i(e.grouping)!==i(r.grouping)}function Ga(e){return!e||e.length===0?"None":e.sort((r,n)=>r.priority-n.priority).map(r=>`${r.column} ${r.direction==="asc"?"↑":"↓"}`).join(", ")}function Ya(e,r){var v,m,T;const n=[],i=JSON.stringify(To(e.filters)),s=JSON.stringify(To(r.filters));if(i!==s){const h=Tt(e.filters),z=Tt(r.filters);h>z?n.push({category:"filters",label:"Filters Added",description:`${h-z} new filter${h-z>1?"s":""} added`}):h<z?n.push({category:"filters",label:"Filters Removed",description:`${z-h} filter${z-h>1?"s":""} removed`}):n.push({category:"filters",label:"Filters Modified",description:"Filter conditions have been changed"})}const a=JSON.stringify(e.sortStack),c=JSON.stringify(r.sortStack);if(a!==c){const h=e.sortStack.length,z=r.sortStack.length;h>z?n.push({category:"sorting",label:"Sorting Added",description:`${h-z} new sort rule${h-z>1?"s":""} added`}):h<z?n.push({category:"sorting",label:"Sorting Removed",description:`${z-h} sort rule${z-h>1?"s":""} removed`}):n.push({category:"sorting",label:"Sorting Modified",description:"Sort rules or order have been changed"})}const l=JSON.stringify(e.columnVisibility),u=JSON.stringify(r.columnVisibility);if(l!==u){const h=Object.values(e.columnVisibility).filter(I=>I).length,z=Object.values(r.columnVisibility).filter(I=>I).length;h>z?n.push({category:"visibility",label:"Columns Shown",description:`${h-z} column${h-z>1?"s":""} made visible`}):h<z?n.push({category:"visibility",label:"Columns Hidden",description:`${z-h} column${z-h>1?"s":""} hidden`}):n.push({category:"visibility",label:"Column Visibility Changed",description:"Column visibility settings have been modified"})}const g=JSON.stringify(e.columnOrder),x=JSON.stringify(r.columnOrder);g!==x&&n.push({category:"order",label:"Column Order Changed",description:"Columns have been reordered"});const f=JSON.stringify(e.columnWidths),S=JSON.stringify(r.columnWidths);if(f!==S){const h=Object.keys(e.columnWidths).filter(z=>e.columnWidths[z]!==r.columnWidths[z]).length;n.push({category:"widths",label:"Column Widths Adjusted",description:`${h} column width${h>1?"s":""} modified`})}const C=JSON.stringify(e.grouping),B=JSON.stringify(r.grouping);if(C!==B){const h=(v=e.grouping)==null?void 0:v.enabled,z=(m=r.grouping)==null?void 0:m.enabled;if(h&&!z){const I=((T=e.grouping)==null?void 0:T.levels.length)||0;n.push({category:"grouping",label:"Grouping Applied",description:`${I} grouping level${I>1?"s":""} added`})}else!h&&z?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}function Ii(){try{return localStorage.getItem("urm:debug")==="true"}catch{return!1}}function Ei(e){return`[${e}]`}const Gt={warn(e,r,...n){Ii()&&console.warn(Ei(e),r,...n)},error(e,r,...n){Ii()&&console.error(Ei(e),r,...n)}},Es="urm_report_";function qa(e,r){try{const n=`${Es}${e}`;localStorage.setItem(n,JSON.stringify(r))}catch(n){Gt.error("urm:persistence","Failed to save report state",n)}}function Ja(e){try{const r=`${Es}${e}`,n=localStorage.getItem(r);return n?JSON.parse(n):null}catch(r){return Gt.error("urm:persistence","Failed to load report state",r),null}}function Io(e,r,n=0){const i=[];for(const s of e){const a=r.includes(s.key);if(i.push({type:"group",key:s.key,level:n,column:s.column,value:s.value,rowCount:s.rowCount,aggregates:s.aggregates,collapsed:a}),!a&&s.children&&s.children.length>0){const c=s.children[0];if(Ka(c)){const l=s.children,u=Io(l,r,n+1);i.push(...u)}else{const l=s.children;for(const u of l)i.push({type:"row",parentGroupKey:s.key,level:n+1,data:u})}}}return i}function Ka(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 cn(e){return e.filter(r=>r.type==="row").map(r=>r.type==="row"?r.data:null).filter(r=>r!==null)}function dn(e,r){const n=new Date,i=n.getFullYear(),s=String(n.getMonth()+1).padStart(2,"0"),a=String(n.getDate()).padStart(2,"0"),c=`${i}-${s}-${a}`;return`${e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}_${c}.${r}`}function en(e,r,n,i,s,a,c){let l,u;a?(l={...a},u=c||r.map(x=>x.name)):s?(l={...s.snapshot.columnVisibility},u=c||[...s.snapshot.columnOrder]):(l={},u=[],r.forEach(x=>{l[x.name]=!0,u.push(x.name)}));const g=Object.entries(l).filter(([x,f])=>!f).map(([x,f])=>x);return{data:e,schema:r,appliedFilters:n,appliedSortStack:i,columnVisibility:l,columnOrder:u,grouping:(s==null?void 0:s.snapshot.grouping)??null,hiddenColumns:g,viewMeta:s?{id:s.id,name:s.name,isDefault:s.isDefault}:void 0}}function tn(e,r="export",n){const{data:i,columnOrder:s,grouping:a}=e,c=s.filter(f=>e.columnVisibility[f]);let l;if(a&&a.enabled){const f=a.collapsedGroups??[],S=Io(i,f);l=cn(S)}else l=i;const u=c.join(","),g=l.map(f=>c.map(S=>{const C=f[S];if(C==null)return"";const B=String(C);return B.includes(",")||B.includes('"')||B.includes(`
2
+ `)?`"${B.replace(/"/g,'""')}"`:B}).join(",")),x=[u,...g].join(`
3
+ `);pi(x,dn(r,"csv"),"text/csv;charset=utf-8;")}function rn(e,r="export",n){const{data:i,columnOrder:s,grouping:a}=e,c=s.filter(f=>e.columnVisibility[f]);let l;if(a&&a.enabled){const f=a.collapsedGroups??[],S=Io(i,f);l=cn(S)}else l=i;const u=[c,...l.map(f=>c.map(S=>f[S]??""))],g=Ho.utils.aoa_to_sheet(u),x=Ho.utils.book_new();Ho.utils.book_append_sheet(x,g,"Data"),Ho.writeFile(x,dn(r,"xlsx"))}function on(e,r="export",n){const{data:i,appliedFilters:s,appliedSortStack:a,viewMeta:c,hiddenColumns:l,columnOrder:u,grouping:g}=e,x=u.filter(B=>e.columnVisibility[B]);let f;if(g&&g.enabled){const B=g.collapsedGroups??[],v=Io(i,B);f=cn(v)}else f=i;f=f.map(B=>{const v={};return x.forEach(m=>{v[m]=B[m]}),v});const S={meta:{exportedAt:new Date().toISOString(),reportName:r,view:(c==null?void 0:c.name)||"Default View",filters:Is(s).map(B=>({field:B.column,operator:B.operator,value:B.value})),sortStack:a.map(B=>({field:B.column,direction:B.direction,priority:B.priority})),grouping:g||{},hiddenColumns:l,columnOrder:u,exportConfig:n||{scope:"visible"}},data:f},C=JSON.stringify(S,null,2);pi(C,dn(r,"json"),"application/json;charset=utf-8;")}function pi(e,r,n){const i=new Blob([e],{type:n}),s=URL.createObjectURL(i),a=document.createElement("a");a.href=s,a.download=r,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(s)}function hi(e,r="export",n){var v;const{data:i,columnOrder:s,grouping:a}=e,c=s.filter(m=>e.columnVisibility[m]);let l;if(a&&a.enabled){const m=a.collapsedGroups??[],T=Io(i,m);l=cn(T)}else l=i;const u=new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}),g=c.map(m=>`<th>${Uo(m)}</th>`).join(""),x=l.map((m,T)=>{const h=c.map(z=>{const I=m[z],b=I==null?"":String(I);return`<td>${Uo(b)}</td>`}).join("");return`<tr class="${T%2===0?"even":"odd"}">${h}</tr>`}).join(""),f=`<!DOCTYPE html>
4
4
  <html lang="en">
5
5
  <head>
6
6
  <meta charset="UTF-8" />
7
- <title>${Ho(r)}</title>
7
+ <title>${Uo(r)}</title>
8
8
  <style>
9
9
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
10
10
  body {
@@ -82,7 +82,7 @@
82
82
  </head>
83
83
  <body>
84
84
  <div class="report-header">
85
- <div class="report-title">${Ho(r)}</div>
85
+ <div class="report-title">${Uo(r)}</div>
86
86
  <div class="report-meta">
87
87
  ${l.length.toLocaleString()} row${l.length!==1?"s":""}<br/>
88
88
  Generated ${u}
@@ -90,7 +90,7 @@
90
90
  </div>
91
91
  <table>
92
92
  <thead><tr>${g}</tr></thead>
93
- <tbody>${f}</tbody>
93
+ <tbody>${x}</tbody>
94
94
  </table>
95
95
  <div class="report-footer">Universal Report Module &mdash; PDF Export</div>
96
96
  <script>
@@ -102,26 +102,26 @@
102
102
  };
103
103
  <\/script>
104
104
  </body>
105
- </html>`;try{const y=document.createElement("iframe");y.style.position="fixed",y.style.right="0",y.style.bottom="0",y.style.width="0",y.style.height="0",y.style.border="0",document.body.appendChild(y);const z=((b=y.contentWindow)==null?void 0:b.document)||y.contentDocument;if(z){z.open(),z.write(m),z.close(),setTimeout(()=>{var x,j;try{(x=y.contentWindow)==null||x.focus(),(j=y.contentWindow)==null||j.print()}catch{}setTimeout(()=>{document.body.removeChild(y)},3e3)},300);return}}catch{}const v=new Blob([m],{type:"text/html;charset=utf-8;"}),C=URL.createObjectURL(v);window.open(C,"_blank")||pi(m,cn(r,"html"),"text/html;charset=utf-8;")}function Ho(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const Ii=10;function Ja(e,r){const n=r.trim();if(!n)return e;const i=e.findIndex(a=>a.query.toLowerCase()===n.toLowerCase());let s;return i!==-1?s=[{...e[i],lastUsed:Date.now()},...e.slice(0,i),...e.slice(i+1)]:s=[{query:n,isFavourite:!1,lastUsed:Date.now()},...e],s.length>Ii&&(s=[...s].sort((c,l)=>c.isFavourite&&!l.isFavourite?-1:!c.isFavourite&&l.isFavourite?1:l.lastUsed-c.lastUsed).slice(0,Ii)),s}function Ka(e,r){return e.map(n=>n.query===r?{...n,isFavourite:!n.isFavourite}:n)}function Xa(e,r){return e.filter(n=>n.query!==r)}function Qa(e){const r=e.filter(i=>i.isFavourite).sort((i,s)=>s.lastUsed-i.lastUsed),n=e.filter(i=>!i.isFavourite).sort((i,s)=>s.lastUsed-i.lastUsed);return[...r,...n]}const Za={owner:["view_report","edit_columns","edit_filters","edit_sorting","edit_views","create_views","delete_views","delete_report","export_data","promote_global_view"],editor:["view_report","edit_columns","edit_filters","edit_sorting","edit_views","create_views","delete_views","export_data"],viewer:["view_report","export_data"]};function el(e,r){return!e||e.owner===r?"owner":e.editors.includes(r)?"editor":(e.viewers.includes(r),"viewer")}function jt(e,r){return Za[r].includes(e)}function kt(e){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",promote_global_view:"promote views to global"}[e]||"perform this action"}.`}function tl(e){return e==="viewer"}const Ei=1e3;function ei(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}function Gt(e){if(!e)return"";const n=e.replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2");return ei(n)}const rl={equals:"equals",contains:"contains",startsWith:"starts with",endsWith:"ends with",gt:"is greater than",lt:"is less than",gte:"is greater than or equal to",lte:"is less than or equal to",isTrue:"is true",isFalse:"is false",NULL:"is empty",NOT_NULL:"is not empty"};function ol(e){if(!e||!e.column)return"a filter";const r=Gt(e.column),n=rl[e.operator]??e.operator;return["isTrue","isFalse","NULL","NOT_NULL"].includes(e.operator)?`"${r}" ${n}`:`"${r}" ${n} "${e.value}"`}function Vn(e){return e?typeof e=="string"?e:"children"in e?"a condition group":ol(e):"a filter"}function Di(e){return!e||!e.enabled||e.levels.length===0?"grouping removed":`grouped by ${e.levels.map(n=>`"${Gt(n.column)}"`).join(", ")}`}function nl(e){var s,a,c;const{action:r,previousState:n,newState:i}=e;switch(r){case"filter_added":return{summary:`Filter added: ${Vn(i)}`};case"filter_removed":return{summary:`Filter removed: ${Vn(n)}`};case"filter_updated":{if(typeof i=="string")return{summary:`Filter updated: ${i}`};const l=n,u=i;return l!=null&&l.column&&(u!=null&&u.column)&&l.column!==u.column?{summary:`Filter changed on "${Gt(u.column)}"`,detail:`Previously filtered "${Gt(l.column)}"`}:{summary:`Filter updated: ${Vn(u)}`}}case"filter_cleared":{const l=n&&typeof n=="object"&&"count"in n?n.count:0;return{summary:l>0?`All filters cleared (${l} filter${l!==1?"s":""} removed)`:"All filters cleared"}}case"sort_level_added":{const l=i!=null&&i.column?Gt(i.column):"",u=(i==null?void 0:i.direction)==="asc"?"ascending":"descending";return{summary:l?`Sort added: "${l}" ${u}`:"Sort level added"}}case"sort_level_removed":{const l=n!=null&&n.column?Gt(n.column):"";return{summary:l?`Sort removed: "${l}"`:"Sort level removed"}}case"sort_reordered":return{summary:"Sort order changed"};case"sort_cleared":return{summary:"All sorting cleared"};case"group_level_added":return{summary:`Grouping applied: ${Di(i)}`};case"group_level_removed":{const l=n,u=(a=(s=l==null?void 0:l.levels)==null?void 0:s[0])!=null&&a.column?Gt(l.levels[0].column):"";return{summary:u?`Group level removed: "${u}"`:"Group level removed"}}case"group_reordered":return{summary:`Grouping updated: ${Di(i)}`};case"group_cleared":return{summary:"Grouping removed"};case"column_hidden":{const l=(i==null?void 0:i.column)??(typeof i=="string"?i:"");return{summary:l?`Column hidden: "${Gt(l)}"`:"Column hidden"}}case"column_shown":{const l=(i==null?void 0:i.column)??(typeof i=="string"?i:"");return{summary:l?`Column shown: "${Gt(l)}"`:"Column made visible"}}case"column_reordered":{const l=Array.isArray(n)?n:[],u=Array.isArray(i)?i:[];return l.length>0&&u.length>0?{summary:"Column order changed",detail:`${u.length} column${u.length!==1?"s":""} reordered`}:{summary:"Columns reordered"}}case"column_resized":{const l=(i==null?void 0:i.column)??"",u=(i==null?void 0:i.width)??"";return{summary:l?`Column resized: "${Gt(l)}"`:"Column resized",detail:u?`New width: ${u}px`:void 0}}case"view_created":{const l=(i==null?void 0:i.name)??(i==null?void 0:i.viewName)??"";return{summary:l?`View created: "${l}"`:"New view created"}}case"view_updated":{const l=(i==null?void 0:i.name)??(n==null?void 0:n.name)??"";return{summary:l?`View updated: "${l}"`:"View updated"}}case"view_deleted":{const l=(n==null?void 0:n.name)??(n==null?void 0:n.viewName)??"";return{summary:l?`View deleted: "${l}"`:"View deleted"}}case"view_set_default":{const l=(i==null?void 0:i.name)??"";return{summary:l?`Default view set to "${l}"`:"Default view changed"}}case"view_switched":{const l=(n==null?void 0:n.name)??"",u=(i==null?void 0:i.name)??"";return l&&u?{summary:`Switched to view "${u}"`,detail:`From "${l}"`}:u?{summary:`Switched to view "${u}"`}:{summary:"View switched"}}case"export_csv":case"export_excel":case"export_json":case"export_pdf":{const l=r==="export_csv"?"CSV":r==="export_excel"?"Excel":r==="export_json"?"JSON":"PDF",u=i==null?void 0:i.rowCount,g=(i==null?void 0:i.scope)==="all"?"all rows":"filtered rows",f=(i==null?void 0:i.viewName)??"",m=typeof u=="number"?` (${u.toLocaleString()} rows)`:"";return{summary:`Exported as ${l}${m}`,detail:f?`${ei(g)} · View: "${f}"`:ei(g)}}case"export_triggered":{const l=((c=i==null?void 0:i.format)==null?void 0:c.toUpperCase())??"";return{summary:l?`Export triggered: ${l}`:"Export triggered"}}case"preset_created":{const l=(i==null?void 0:i.name)??"";return{summary:l?`Preset created: "${l}"`:"New preset created"}}case"preset_applied":{const l=(i==null?void 0:i.name)??"";return{summary:l?`Preset applied: "${l}"`:"Preset applied"}}case"preset_deleted":{const l=(n==null?void 0:n.name)??"";return{summary:l?`Preset deleted: "${l}"`:"Preset deleted"}}case"preset_link_copied":{const l=(i==null?void 0:i.name)??"";return{summary:l?`Preset link copied: "${l}"`:"Preset link copied to clipboard"}}case"row_edited":{const l=(i==null?void 0:i.id)??(n==null?void 0:n.id)??"",u=(i==null?void 0:i.label)??(n==null?void 0:n.label)??(l?`#${l}`:"");return{summary:u?`Row edited: "${u}"`:"Row edited"}}case"row_deleted":{const l=(n==null?void 0:n.id)??"",u=(n==null?void 0:n.label)??(l?`#${l}`:"");return{summary:u?`Row deleted: "${u}"`:"Row deleted"}}case"row_duplicated":{const l=(n==null?void 0:n.id)??"",u=(n==null?void 0:n.label)??(l?`#${l}`:"");return{summary:u?`Row duplicated: "${u}"`:"Row duplicated"}}case"theme_changed":{const l=typeof n=="string"?n:(n==null?void 0:n.theme)??"",u=typeof i=="string"?i:(i==null?void 0:i.theme)??"";return l&&u?{summary:`Theme changed from "${l}" to "${u}"`}:u?{summary:`Theme changed to "${u}"`}:{summary:"Theme changed"}}case"error_occurred":{const l=(i==null?void 0:i.message)??(i==null?void 0:i.error)??typeof i=="string"?i:"";return{summary:"An error was recorded",detail:l?`Details: ${String(l).slice(0,120)}`:void 0}}default:return{summary:sl(r)}}}function il(){return`EVT_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function jo(e,r,n,i,s,a){return{id:il(),user:r,reportId:e,feature:n,action:i,timestamp:new Date().toISOString(),previousState:s,newState:a}}function ko(e,r){const n=[r,...e];return n.length>Ei?n.slice(0,Ei):n}function sl(e){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",export_pdf:"Exported as PDF",preset_created:"Preset Created",preset_applied:"Preset Applied",preset_deleted:"Preset Deleted",preset_link_copied:"Preset Link Copied",row_edited:"Row Edited",row_deleted:"Row Deleted",row_duplicated:"Row Duplicated",error_occurred:"Error Occurred"}[e]||e}function al(e){return{filters:"Filters",sorting:"Sorting",grouping:"Grouping",columns:"Columns",views:"Views",theme:"Theme",export:"Export",presets:"Presets",rows:"Rows",system:"System"}[e]||e}function ll(e){const r=new Date(e),i=new Date().getTime()-r.getTime(),s=Math.floor(i/6e4),a=Math.floor(i/36e5),c=Math.floor(i/864e5);return s<1?"Just now":s<60?`${s} minute${s>1?"s":""} ago`:a<24?`${a} hour${a>1?"s":""} ago`:c<7?`${c} day${c>1?"s":""} ago`:r.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}const _i=100;function cl(){return`preset_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function dl(e){var a;const r=(a=e.views)==null?void 0:a.find(c=>c.id===e.activeViewId),n=r==null?void 0:r.snapshot.columnOrder,i=e.columnOrder||[],s=ui(i,e.grouping||null,n);return{filters:Fe(e.filters),sortStack:e.sortStack?[...e.sortStack]:[],columnVisibility:e.columnVisibility?{...e.columnVisibility}:{},columnOrder:s,columnWidths:e.columnWidths?{...e.columnWidths}:{},grouping:e.grouping?{...e.grouping}:null,activeViewId:e.activeViewId}}function ul(e,r,n,i){return{id:cl(),name:e,description:r,createdBy:n,createdAt:Date.now(),config:i}}function pl(e,r){const n=e||[];if(n.length>=_i)throw new Error(`Maximum of ${_i} presets reached. Please delete old presets first.`);return[...n,r]}function hl(e,r){return(e||[]).filter(i=>i.id!==r)}function $i(e,r){if(e)return e.find(n=>n.id===r)}function ml(){return typeof window>"u"?null:new URLSearchParams(window.location.search).get("preset")}function xl(e){const r=e.columnOrder,n=vo(r,e.grouping);return{filters:Fe(e.filters),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 fl(e){try{if(navigator.clipboard&&navigator.clipboard.writeText)return await navigator.clipboard.writeText(e),!0}catch(r){Ut.warn("urm:presets","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){Ut.error("urm:presets","execCommand copy failed",i)}return document.body.removeChild(r),n}catch(r){return Ut.error("urm:presets","Fallback copy method failed",r),!1}}function gl(e,r){return{totalRows:e.length,totalColumns:r.length}}function gr(e,r,n,i){const s=n instanceof Error?n.message:n,a={type:e,context:r,message:s,details:i,timestamp:Date.now(),recoverable:yl(e,r)};return process.env.NODE_ENV==="development"&&Ut.error("urm:error-handling","[Report Error]",{type:e,context:r,message:s,details:i}),a}function yl(e,r){return e==="ui"?!0:r==="export"?!1:e==="processing"&&["filters","sorting","grouping","columns"].includes(r)?!0:e!=="system"}function bl(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 vl(e){return{filters:e.filters,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 Sl(e,r,n){n(e.id,{filters:Fe(r.filters),sortStack:r.sortStack,grouping:r.grouping,columnVisibility:r.columnVisibility,columnOrder:r.columnOrder,columnWidths:r.columnWidths,activeViewId:r.activeViewId})}function Cl(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 Is(e,r){const n=[],i=[],s=new Set(r.map(a=>a.name));return e.forEach(a=>{s.has(a.column)?n.push(a):i.push(a.column)}),{validRules:n,invalidColumns:i}}function Es(e,r){if(!e||!e.levels||e.levels.length===0)return{validGrouping:null,invalidColumns:[]};const n=new Set(r.map(a=>a.name)),i=[],s=[];return e.levels.forEach(a=>{n.has(a.column)?i.push(a):s.push(a.column)}),i.length===0?{validGrouping:null,invalidColumns:s}:{validGrouping:{...e,levels:i},invalidColumns:s}}function wl(e,r){const n=[],i=new Set(r.map(a=>a.name)),s={...e};if(s.filters){const a=c=>{const l=c.children.filter(u=>{if(Je(u))return!0;const g=i.has(u.column);return g||n.push(`Filter for column "${u.column}" ignored (column not found)`),g}).map(u=>Je(u)?a(u):u).filter(u=>!Je(u)||u.children.length>0);return{...c,children:l}};s.filters=a(Fe(s.filters))}if(s.sortStack&&Array.isArray(s.sortStack)){const{validRules:a,invalidColumns:c}=Is(s.sortStack,r);c.length>0&&n.push(`Sort rules for columns ignored: ${c.join(", ")}`),s.sortStack=a.length>0?a:void 0}if(s.grouping){const{validGrouping:a,invalidColumns:c}=Es(s.grouping,r);c.length>0&&n.push(`Grouping for columns ignored: ${c.join(", ")}`),s.grouping=a}if(s.columnVisibility){const a={};Object.entries(s.columnVisibility).forEach(([c,l])=>{i.has(c)?a[c]=l:n.push(`Column visibility for "${c}" ignored (column not found)`)}),s.columnVisibility=Object.keys(a).length>0?a:void 0}if(s.columnOrder&&Array.isArray(s.columnOrder)){const a=s.columnOrder.filter(c=>{const l=i.has(c);return l||n.push(`Column "${c}" in order ignored (column not found)`),l});s.columnOrder=a.length>0?a:void 0}if(s.columnWidths){const a={};Object.entries(s.columnWidths).forEach(([c,l])=>{i.has(c)?a[c]=l:n.push(`Column width for "${c}" ignored (column not found)`)}),s.columnWidths=Object.keys(a).length>0?a:void 0}return{sanitizedConfig:s,warnings:n}}function jl(e,r){return gr("processing","export",e,{retryAvailable:!!(r!=null&&r.onRetry)})}function Oi(e,r,n,i){const s=jo(e,r,"system","error_occurred",null,{errorType:n.type,errorContext:n.context,errorMessage:n.message,recoverable:n.recoverable,timestamp:n.timestamp});return ko(i||[],s)}function kl(e){return e==null}function zl(e,r,n){const{operator:i,value:s}=r;if(i==="NULL")return e==null;if(i==="NOT_NULL")return e!=null;if(kl(e))return!1;if(n==="date"){const a=new Date(e).getTime(),c=new Date(s).getTime();switch(i){case"equals":return a===c;case"gt":return a>c;case"lt":return a<c;case"gte":return a>=c;case"lte":return a<=c;default:return!0}}switch(i){case"equals":return String(e).toLowerCase()===String(s).toLowerCase();case"contains":return String(e).toLowerCase().includes(String(s).toLowerCase());case"startsWith":return String(e).toLowerCase().startsWith(String(s).toLowerCase());case"endsWith":return String(e).toLowerCase().endsWith(String(s).toLowerCase());case"gt":return Number(e)>Number(s);case"lt":return Number(e)<Number(s);case"gte":return Number(e)>=Number(s);case"lte":return Number(e)<=Number(s);case"isTrue":return e===!0;case"isFalse":return e===!1;default:return!0}}function ti(e,r,n){var s;if(Je(r))return r.children.length===0?!0:r.operator==="and"?r.children.every(a=>ti(e,a,n)):r.children.some(a=>ti(e,a,n));const i=((s=n.find(a=>a.name===r.column))==null?void 0:s.type)??"string";return zl(e[r.column],r,i)}function Tl(e,r,n){return!r||r.children.length===0?e:e.filter(i=>ti(i,r,n))}function on(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"date":return[{value:"equals",label:"Is"},{value:"gt",label:"After"},{value:"lt",label:"Before"},{value:"gte",label:"On or after"},{value:"lte",label:"On or before"},{value:"NULL",label:"Is NULL"},{value:"NOT_NULL",label:"Is NOT NULL"}];case"mixed":case"null":case"array":case"object":default:return[]}}function Bl(e){return e!=="isTrue"&&e!=="isFalse"&&e!=="NULL"&&e!=="NOT_NULL"}function Il({data:e,filters:r,schema:n}){return{filteredData:p.useMemo(()=>!r||r.children.length===0?e:Tl(e,r,n),[e,r,n])}}function El(e,r,n,i){if(!n||n.trim()==="")return e;const s=n.toLowerCase().trim(),a=r.filter(c=>i.includes(c.name));return e.filter(c=>a.some(l=>{const u=c[l.name];return u==null?!1:String(u).toLowerCase().includes(s)}))}function Dl({data:e,searchQuery:r,schema:n,visibleColumns:i,mode:s="client"}){return{searchedData:p.useMemo(()=>s==="server"||!r||r.trim()===""?e:El(e,n,r,i),[e,r,n,i,s])}}function _l({data:e,sortStack:r,schema:n}){return{sortedData:p.useMemo(()=>!r||r.length===0?e:Oa(e,n,r),[e,r,n])}}function $l({data:e,grouping:r,schema:n}){const i=p.useMemo(()=>!r||!r.enabled||r.levels.length===0?e:Pa(e,n,r),[e,r,n]),s=(r==null?void 0:r.enabled)&&((r==null?void 0:r.levels.length)||0)>0;return{groupedData:i,isGrouped:s}}function Ol({schema:e,columnVisibility:r,columnOrder:n}){const i=p.useMemo(()=>n.filter(l=>r[l]!==!1),[n,r]),s=p.useMemo(()=>Object.entries(r).filter(([l,u])=>!u).map(([l,u])=>l),[r]),a=p.useMemo(()=>n.map(l=>e.find(g=>g.name===l)||{name:l,type:"string"}),[n,e]),c=p.useMemo(()=>i.map(l=>e.find(g=>g.name===l)||{name:l,type:"string"}),[i,e]);return{visibleColumns:i,hiddenColumns:s,allColumns:a,visibleColumnSchemas:c,hiddenCount:s.length}}function Ml({views:e,activeViewId:r,currentState:n}){const i=p.useMemo(()=>e.find(g=>g.id===r),[e,r]),s=p.useMemo(()=>i?Va(n,i.snapshot):!1,[i,n]),a=p.useMemo(()=>e.find(g=>g.isDefault),[e]),c=p.useMemo(()=>e.filter(g=>!g.isDefault&&!g.isDeleted),[e]),l=p.useMemo(()=>e.filter(g=>g.isFavorite&&!g.isDeleted),[e]),u=p.useMemo(()=>e.filter(g=>g.isDeleted),[e]);return{activeView:i,isDirty:s,defaultView:a,customViews:c,favoriteViews:l,deletedViews:u,isDefaultView:(i==null?void 0:i.isDefault)||!1}}function Wl(e,r,n){if(!e||e.length===0)return[];if(r<=0)return e.slice(0,n);const i=e.slice(r,n);if(i.length===0)return[];const s=i[0],a=!!(s.__isGroupHeader||s.isGroupHeader),c=a?s.groupLevel??0:s.__urm_group_level__??0;if(c===0&&a)return i;const l=c-1;if(l<0)return i;const u={};let g=l+1;for(let m=r-1;m>=0;m--){const v=e[m];if(v.__isGroupHeader||v.isGroupHeader){const C=v.groupLevel??0;if(C<=l&&u[C]===void 0&&(u[C]=v,g--,g<=0))break}}const f=[];for(let m=0;m<=l;m++)u[m]&&f.push({...u[m],__urm_is_continuation_header__:!0});return[...f,...i]}function Al({data:e,enabled:r=!1,pageSize:n=100,initialPage:i=1}){const[s,a]=p.useState(i),c=e.length,l=Math.max(1,Math.ceil(c/n));p.useEffect(()=>{s>l&&a(l)},[s,l]);const u=p.useMemo(()=>{if(!r)return e;const C=(s-1)*n,B=C+n;return Wl(e,C,B)},[e,r,s,n]),g=p.useCallback(C=>{const B=Math.max(1,Math.min(C,l));a(B)},[l]),f=p.useCallback(()=>{s<l&&a(C=>Math.min(C+1,l))},[l]),m=p.useCallback(()=>{s>1&&a(C=>Math.max(C-1,1))},[]),v=p.useCallback(()=>{a(1)},[]);return{paginatedData:u,currentPage:s,totalPages:l,pageSize:n,totalRows:c,goToPage:g,nextPage:f,prevPage:m,resetPage:v,hasNextPage:s<l,hasPrevPage:s>1}}function Rl(e){const{rawData:r,schema:n,filters:i,sortStack:s,grouping:a,searchQuery:c,searchMode:l,columnVisibility:u,columnOrder:g,columnWidths:f,views:m,activeViewId:v,pagination:C}=e,B=p.useMemo(()=>({filters:i,sortStack:s,grouping:a,columnVisibility:u,columnOrder:g,columnWidths:f}),[i,s,a,u,g,f]),b=Ml({views:m,activeViewId:v,currentState:B}),y=Ol({schema:n,columnVisibility:u,columnOrder:g}),{filteredData:z}=Il({data:r,filters:i,schema:n}),{sortedData:x}=_l({data:z,sortStack:s,schema:n}),{groupedData:j,isGrouped:E}=$l({data:x,grouping:a,schema:n}),{searchedData:S}=Dl({data:j,searchQuery:c,schema:n,visibleColumns:y.visibleColumns,mode:l}),R=Al({data:S,enabled:(C==null?void 0:C.enabled)||!1,pageSize:(C==null?void 0:C.pageSize)||100,initialPage:(C==null?void 0:C.currentPage)||1}),q=C!=null&&C.enabled?R.paginatedData:S,T=p.useMemo(()=>({totalRows:r.length,filteredRows:z.length,sortedRows:x.length,groupedRows:E?j.length:x.length,searchedRows:S.length,visibleRows:q.length,hiddenColumns:y.hiddenCount,activeFilters:Tt(i),activeSorts:s.length,isGrouped:E}),[r.length,z.length,x.length,j.length,S.length,q.length,y.hiddenCount,i,s.length,E]);return{data:q,filteredData:z,sortedData:x,groupedData:j,searchedData:S,viewEngine:b,columnEngine:y,paginationEngine:R,metrics:T,isGrouped:E,isPaginated:(C==null?void 0:C.enabled)||!1}}let Pl=0;function Nl(e,r){e!==null&&e.__urm_row_id__===void 0&&Object.defineProperty(e,"__urm_row_id__",{value:r?r(e):Pl++,writable:!1,enumerable:!1,configurable:!1})}const At="user-demo-001";function Ll(e={}){var ke,pt,Fo,vi,Si;const{mode:r="builder",autoLoad:n=!0,initialData:i,dataSource:s,pagination:a,search:c,scheduler:l,reportName:u,reportId:g,sharedReportId:f,sharedViewId:m,viewPersistence:v,config:C={}}=e,B=(v==null?void 0:v.mode)??"local",b=(a==null?void 0:a.mode)??"client",y=(c==null?void 0:c.mode)??"client",[z,x]=p.useState([]),j=br(),[E,S]=p.useState(""),[R,q]=p.useState(!1),[T,F]=p.useState(!1),[X,W]=p.useState({message:"",severity:"info",open:!1}),h=(k,_="info")=>{W({message:k,severity:_,open:!0})},I=()=>W(k=>({...k,open:!1})),N=C.notifDurationMs??2e3,d=z.find(k=>k.id===E),[oe,G]=p.useState("idle"),[te,ge]=p.useState(!1),[V,K]=p.useState(!1),[ce,de]=p.useState(!1),[ne,Q]=p.useState(!1),[pe,D]=p.useState(!1),[ee,xe]=p.useState(void 0),[ae,Te]=p.useState(null),[Y,Pe]=p.useState(null),[Et,mt]=p.useState(!1),[$r,Pt]=p.useState(!1),[it,Yt]=p.useState(null),[Ke,Dt]=p.useState(!1),[Sr,vt]=p.useState(!1),[qt,ao]=p.useState({enabled:!1,levels:[],collapsedGroups:[]}),[ar,lo]=p.useState(""),[_t,Cr]=p.useState(""),[Xe,Nt]=p.useState(new Set),[Jt,Ze]=p.useState(1),[et,Lt]=p.useState(15),[co,Or]=p.useState(!1),[wr,He]=p.useState(!1),[Se,lr]=p.useState(!1),[Kt,cr]=p.useState(null),[uo,Ft]=p.useState(!1),[Mr,dr]=p.useState(null),[tt,Xt]=p.useState(null),xt=p.useRef(null),Be=p.useMemo(()=>d?el(d.permissions,At):"owner",[d]),he=tl(Be),jr=p.useMemo(()=>!(d!=null&&d.uploadedData)||!(d!=null&&d.schema)?{totalRows:0,totalColumns:0}:gl(d.uploadedData,d.schema),[d==null?void 0:d.uploadedData,d==null?void 0:d.schema]),$t=p.useCallback(()=>{d&&(xt.current=vl(d))},[d]),H=p.useCallback((k,_)=>{x(A=>A.map(M=>M.id===k?{...M,..._}:M))},[]),St=p.useCallback(k=>{if(!d)return;Xt(k);const _=Oi(d.id,At,k,d.auditHistory||[]);H(d.id,{auditHistory:_}),h(k.message,"error"),k.recoverable&&xt.current&&setTimeout(()=>{Sl(d,xt.current,H),h("Previous state restored","success")},100)},[d,H]),ie=p.useCallback((k,_,A,M)=>{if(!d)return;const U=jo(d.id,At,k,_,A,M),J=d.auditHistory||[],le=ko(J,U);setTimeout(()=>{H(d.id,{auditHistory:le})},0)},[d,H]);p.useEffect(()=>{if(d!=null&&d.schemaLocked&&d.schema&&(!d.views||d.views.length===0)){const k=Fn(d.schema);(()=>{try{const _=localStorage.getItem("urm_dev_config");return _?JSON.parse(_):null}catch{return null}})(),H(d.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})}},[d==null?void 0:d.schemaLocked,d==null?void 0:d.schema,d==null?void 0:d.id,H]),p.useEffect(()=>{if(i&&n&&!T&&z.length===0){const k=oo(i),_={id:g||`auto-report-${Date.now()}`,name:u||(r==="viewer"?"Data View":"Imported Data"),description:"Auto-generated from external data",schemaLocked:!0,uploadedData:k,schema:ji(fo(k),C.hiddenColumns),permissions:{owner:At,editors:[],viewers:[]}};x([_]),S(_.id),F(!0),G("confirmed")}},[i,n,T,z.length,r,u,g]),p.useEffect(()=>{b!=="server"||!T||!E||H(E,{uploadedData:oo(i||[])})},[i,b,T,E]),p.useEffect(()=>{b==="server"&&((a==null?void 0:a.page)!==void 0&&Ze(a.page),(a==null?void 0:a.pageSize)!==void 0&&Lt(a.pageSize))},[a==null?void 0:a.page,a==null?void 0:a.pageSize,b]),p.useEffect(()=>{if(!s||T)return;let k=!1,_=null;const A=async()=>{try{G("uploading");let M;if(s.type==="api"){const J=await fetch(s.url,{headers:s.headers||{}});if(!J.ok)throw new Error(`HTTP ${J.status}: ${J.statusText}`);M=await J.json()}else M=await s.fetch();if(k)return;if(!Array.isArray(M))throw new Error("Data source must return an array of objects");const U=fo(M);if(T)x(J=>J.map(le=>le.id===E?{...le,uploadedData:oo(M)}:le)),G("confirmed");else{const J={id:g||`auto-report-${Date.now()}`,name:u||(r==="viewer"?"Data View":"Imported Data"),description:`Loaded from ${s.type==="api"?s.url:"callback"}`,schemaLocked:!0,uploadedData:oo(M),schema:ji(fo(oo(M)),C.hiddenColumns),permissions:{owner:At,editors:[],viewers:[]}};x([J]),S(J.id),F(!0),G("confirmed")}}catch(M){k||(G("error"),d&&H(d.id,{uploadError:(M==null?void 0:M.message)||"Failed to load data from source"}))}};return A(),s.refreshInterval&&s.refreshInterval>0&&(_=setInterval(A,s.refreshInterval)),()=>{k=!0,_&&clearInterval(_)}},[s,u,r,g]);const ut=(ke=d==null?void 0:d.views)==null?void 0:ke.find(k=>k.id===d.activeViewId),Ot=p.useMemo(()=>d!=null&&d.uploadedData?(d.uploadedData.forEach(k=>Nl(k,C.getRowId)),d.uploadedData):[],[d==null?void 0:d.uploadedData]);p.useEffect(()=>{Nt(k=>{if(k.size===0)return k;const _=new Set(Ot.map(M=>M==null?void 0:M.__urm_row_id__)),A=new Set(Array.from(k).filter(M=>_.has(M==null?void 0:M.__urm_row_id__)));return A.size===k.size?k:A})},[Ot]);const Qt=Rl({rawData:Ot,schema:(d==null?void 0:d.schema)||[],filters:Fe(d==null?void 0:d.filters),sortStack:(d==null?void 0:d.sortStack)||[],grouping:(d==null?void 0:d.grouping)||null,searchQuery:_t||"",searchMode:y,columnVisibility:(d==null?void 0:d.columnVisibility)||(ut==null?void 0:ut.snapshot.columnVisibility)||{},columnOrder:(d==null?void 0:d.columnOrder)||(ut==null?void 0:ut.snapshot.columnOrder)||[],columnWidths:(d==null?void 0:d.columnWidths)||(ut==null?void 0:ut.snapshot.columnWidths)||{},views:(d==null?void 0:d.views)||[],activeViewId:(d==null?void 0:d.activeViewId)||"",pagination:{enabled:b==="client",pageSize:et,currentPage:Jt}}),{data:Wr=[],searchedData:kr=[],groupedData:Zt=[],sortedData:ur=[],metrics:pr={totalRows:0,searchedRows:0,isGrouped:!1},isGrouped:Ar=!1,paginationEngine:ze}=Qt||{},Qe=b==="server"?(a==null?void 0:a.totalRows)??0:pr.searchedRows,Z=((pt=Qt.viewEngine)==null?void 0:pt.activeView)||ut,se=((Fo=Qt.viewEngine)==null?void 0:Fo.isDirty)||!1;p.useEffect(()=>{if(!(!Z||!d)&&!d.columnOrder){const k=Z.snapshot.columnOrder,_=vo(k,Z.snapshot.grouping);H(d.id,{columnOrder:_})}},[d==null?void 0:d.activeViewId]);const be=p.useMemo(()=>!(d!=null&&d.schema)||!Z?null:Fa(d.filters,d.sortStack||[],d.schema,d.columnVisibility,d.columnOrder,d.columnWidths,d.grouping,Z.snapshot.columnOrder),[d==null?void 0:d.filters,d==null?void 0:d.sortStack,d==null?void 0:d.schema,d==null?void 0:d.columnVisibility,d==null?void 0:d.columnOrder,d==null?void 0:d.columnWidths,d==null?void 0:d.grouping,Z]),Rr=p.useMemo(()=>!Z||!be||!se?[]:Ga(be,Z.snapshot),[Z,be,se]),hr=p.useCallback((k,_,A)=>{const M={id:`report-${Date.now()}`,name:k,description:_,schemaLocked:!1,permissions:{owner:At,editors:[],viewers:[]}};if(A&&Array.isArray(A)&&A.length>0){const U=fo(A),J=Fn(U);M.uploadedData=A,M.schema=U,M.schemaLocked=!0,M.views=[J],M.activeViewId=J.id,M.sortStack=J.snapshot.sortStack,M.filters=J.snapshot.filters,M.columnVisibility=J.snapshot.columnVisibility,M.columnOrder=J.snapshot.columnOrder,M.columnWidths=J.snapshot.columnWidths,M.grouping=J.snapshot.grouping}x(U=>[...U,M]),S(M.id),q(!1),G("confirmed")},[]),Pr=p.useCallback(k=>{d&&(G("uploading"),setTimeout(()=>{const _=fo(k);H(d.id,{uploadedData:k,schema:_,uploadError:void 0}),G("preview")},500))},[d,H]),po=p.useCallback(k=>{d&&(H(d.id,{uploadError:k}),G("idle"))},[d,H]),Nr=p.useCallback(()=>{d&&(H(d.id,{uploadError:void 0,uploadedData:void 0,schema:void 0}),G("idle"))},[d,H]),mr=p.useCallback(()=>{d&&(H(d.id,{schemaLocked:!0}),G("confirmed"))},[d,H]),Lr=p.useCallback(k=>{if(!d)return;if(!jt("edit_sorting",Be)){h(kt("edit_sorting"),"error");return}const _=d.sortStack??[],A=_.find(M=>M.column===k);if(A){const M=Ma(A.direction);if(M===null){const U=_.filter(J=>J.column!==k).map((J,le)=>({...J,priority:le+1}));ie("sorting","sort_level_removed",A,null),H(d.id,{sortStack:U.length>0?U:void 0})}else{const U=M,J=_.map(le=>le.column===k?{...le,direction:U}:le);ie("sorting","sort_reordered",{column:k,direction:A.direction},{column:k,direction:U}),H(d.id,{sortStack:J})}}else{if(_.length>=j.sort.maxLevels){h(`Sort limit reached — maximum ${j.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const M={column:k,direction:"asc",priority:_.length+1};ie("sorting","sort_level_added",null,M),H(d.id,{sortStack:[..._,M]})}},[d,Be,H,ie]),Fr=p.useCallback(k=>{if(!d)return;const _=d.sortStack??[],A=k.length===0?"sort_cleared":"sort_reordered";if(d.schema){const{validRules:M,invalidColumns:U}=Is(k,d.schema);U.length>0&&h(`Removed invalid sort columns: ${U.join(", ")}`),$t();try{ie("sorting",A,_,M.length>0?M:null),H(d.id,{sortStack:M.length>0?M:void 0})}catch(J){const le=gr("processing","sorting",J);St(le)}}else ie("sorting",A,_,k.length>0?k:null),H(d.id,{sortStack:k.length>0?k:void 0})},[d,H,$t,St,ie]),Mt=p.useCallback(k=>{if(!d)return;const _=d.sortStack??[],A=_.find(M=>M.column===k);if(!(A&&A.direction==="asc"))if(A){const M=_.map(U=>U.column===k?{...U,direction:"asc"}:U);ie("sorting","sort_reordered",{column:k,direction:A.direction},{column:k,direction:"asc"}),H(d.id,{sortStack:M})}else{if(_.length>=j.sort.maxLevels){h(`Sort limit reached — maximum ${j.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const M={column:k,direction:"asc",priority:_.length+1};ie("sorting","sort_level_added",null,M),H(d.id,{sortStack:[..._,M]})}},[d,H,ie]),Ce=p.useCallback(k=>{if(!d)return;const _=d.sortStack??[],A=_.find(M=>M.column===k);if(!(A&&A.direction==="desc"))if(A){const M=_.map(U=>U.column===k?{...U,direction:"desc"}:U);ie("sorting","sort_reordered",{column:k,direction:A.direction},{column:k,direction:"desc"}),H(d.id,{sortStack:M})}else{if(_.length>=j.sort.maxLevels){h(`Sort limit reached — maximum ${j.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const M={column:k,direction:"desc",priority:_.length+1};ie("sorting","sort_level_added",null,M),H(d.id,{sortStack:[..._,M]})}},[d,H,ie]),Ge=p.useCallback((k,_)=>{var M;if(!d)return;if(!jt("edit_filters",Be)){h(kt("edit_filters"),"error");return}const A=(M=d.schema)==null?void 0:M.find(U=>U.name===_.column);if(A&&_.value!==void 0){const U=Cl(A.type,_.operator,_.value);if(!U.isValid){h(U.errorMessage||"Invalid filter value","error");return}}$t();try{const U=Fe(d.filters),J={..._,id:io()},le=so(U,k,J);ie("filters","filter_added",null,J),H(d.id,{filters:le})}catch(U){const J=gr("processing","filters",U);St(J)}},[d,Be,H,$t,St,ie]),zr=p.useCallback(k=>{if(!d)return;if(!jt("edit_filters",Be)){h(kt("edit_filters"),"error");return}const _=Fe(d.filters),A=so(_,k,Rt());ie("filters","filter_added",null,"a condition group"),H(d.id,{filters:A})},[d,Be,H,ie]),st=p.useCallback((k,_)=>{if(!d)return;if(!jt("edit_filters",Be)){h(kt("edit_filters"),"error");return}const A=Fe(d.filters),M=Xo(A,k),U=li(A,k,_),J=Xo(U,k);ie("filters","filter_updated",M,J),H(d.id,{filters:U})},[d,Be,H,ie]),er=p.useCallback((k,_)=>{if(!d)return;if(!jt("edit_filters",Be)){h(kt("edit_filters"),"error");return}const A=Fe(d.filters),M=ci(A,k,_);ie("filters","filter_updated",null,`group operator changed to ${_.toUpperCase()}`),H(d.id,{filters:M})},[d,Be,H,ie]),Wt=p.useCallback(k=>{if(!d)return;if(!jt("edit_filters",Be)){h(kt("edit_filters"),"error");return}const _=Fe(d.filters),A=Xo(_,k),M=di(_,k);ie("filters","filter_removed",A,null),H(d.id,{filters:M})},[d,Be,H,ie]),fe=p.useCallback(()=>{if(!d)return;if(!jt("edit_filters",Be)){h(kt("edit_filters"),"error");return}const k=Fe(d.filters);ie("filters","filter_cleared",{count:Tt(k)},null),H(d.id,{filters:Rt()})},[d,Be,H,ie]),je=p.useCallback(k=>{if(!d)return;if(!jt("edit_filters",Be)){h(kt("edit_filters"),"error");return}const _=Fe(d.filters);ie("filters","filter_cleared",{count:Tt(_)},{count:Tt(k)}),H(d.id,{filters:k})},[d,Be,H,ie]),We=p.useCallback(k=>{var U;if(!d)return;const _=(U=d.views)==null?void 0:U.find(J=>J.id===k);if(!_)return;const A=_.snapshot.columnOrder,M=vo(A,_.snapshot.grouping);ie("views","view_switched",{previousViewId:d.activeViewId},{viewId:k,name:_.name}),H(d.id,{filters:_.snapshot.filters,sortStack:_.snapshot.sortStack.length>0?[..._.snapshot.sortStack]:void 0,columnVisibility:{..._.snapshot.columnVisibility},columnOrder:M,columnWidths:{..._.snapshot.columnWidths},grouping:_.snapshot.grouping,activeViewId:k}),Nt(new Set)},[d,H,ie]),qe=p.useCallback((k,_,A)=>{var Ue;if(!(d!=null&&d.schema)||!be)return;const M=d.views??[],U=M.filter(Ln=>!Ln.isDeleted).length,J=((Ue=j.views)==null?void 0:Ue.maxViews)??10;if(U>=J){h(`View limit reached — you can have at most ${J} saved views. Delete an existing view to create a new one.`,"error");return}const le={id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:k,description:_||void 0,isDefault:A,isFavorite:!1,isDeleted:!1,scope:"personal",createdBy:At,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...be}},ve=A?M.map(Ln=>({...Ln,isDefault:!1})):M;ie("views","view_created",null,{viewId:le.id,name:k,isDefault:A}),H(d.id,{views:[...ve,le],activeViewId:le.id}),h(`"${k}" view created`,"success")},[d,be,H,ie]),at=p.useCallback(k=>{var le;if(!(d!=null&&d.views))return;const _=d.views.find(ve=>ve.id===k);if(!_)return;const A=d.views,M=A.filter(ve=>!ve.isDeleted).length,U=((le=j.views)==null?void 0:le.maxViews)??10;if(M>=U){h(`View limit reached — you can have at most ${U} saved views. Delete an existing view to create a new one.`,"error");return}const J={..._,id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:`${_.name} (copy)`,scope:"personal",isDefault:!1,isFavorite:!1,isDeleted:!1,createdBy:At,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{..._.snapshot}};H(d.id,{views:[...A,J]}),h(`"${J.name}" created`,"success")},[d,j,H]),Ct=p.useCallback(()=>{var _;if(!Z||!be||!d)return;const k=(_=d.views)==null?void 0:_.map(A=>A.id===Z.id?{...A,snapshot:{...be}}:A);H(d.id,{views:k}),h(`"${Z.name}" view updated`,"success")},[Z,be,d,H]),tr=p.useCallback(k=>{var M;if(!Z||!be||!d)return;const _=k??be.columnWidths,A=(M=d.views)==null?void 0:M.map(U=>U.id===Z.id?{...U,snapshot:{...U.snapshot,columnVisibility:be.columnVisibility,columnOrder:be.columnOrder,columnWidths:_},updatedAt:Date.now()}:U);H(d.id,{views:A,columnWidths:_}),h(`Column configuration saved to "${Z.name}"`,"success")},[Z,be,d,H]),$o=p.useCallback(k=>{var J,le;if(!be||!d||!Z)return;const _=k??be.columnWidths,A={...Z,snapshot:{...Z.snapshot,columnVisibility:be.columnVisibility,columnOrder:be.columnOrder,columnWidths:_},updatedAt:Date.now()},M=(J=d.views)==null?void 0:J.map(ve=>ve.id===Z.id?A:{...ve,snapshot:{...ve.snapshot,columnVisibility:be.columnVisibility,columnOrder:be.columnOrder,columnWidths:_},updatedAt:Date.now()});H(d.id,{views:M,columnWidths:_});const U=(((le=d.views)==null?void 0:le.length)||0)-1;h(`Column configuration saved to current view and ${U} other view${U===1?"":"s"}`,"success")},[be,d,Z,H]),Vr=p.useCallback(()=>{de(!0)},[]),zn=p.useCallback(()=>{if(!Z||!d)return;const k=Z.snapshot.columnOrder,_=vo(k,Z.snapshot.grouping);H(d.id,{filters:Z.snapshot.filters,sortStack:Z.snapshot.sortStack.length>0?[...Z.snapshot.sortStack]:void 0,columnVisibility:{...Z.snapshot.columnVisibility},columnOrder:_,columnWidths:{...Z.snapshot.columnWidths},grouping:Z.snapshot.grouping}),h("Changes reverted to last saved state","success")},[Z,d,H]),Hr=p.useCallback(k=>{if(!(d!=null&&d.views))return;const _=d.views.map(M=>({...M,isDefault:M.id===k}));H(d.id,{views:_});const A=d.views.find(M=>M.id===k);A&&h(`"${A.name}" set as default view`,"success")},[d,H]),ho=p.useCallback(k=>{if(!(d!=null&&d.views))return;const _=d.views.map(M=>M.id===k?{...M,isFavorite:!M.isFavorite,updatedAt:Date.now()}:M);H(d.id,{views:_});const A=d.views.find(M=>M.id===k);A&&!A.isFavorite?h(`"${A.name}" added to favorites`,"success"):A&&h(`"${A.name}" removed from favorites`,"info")},[d,H]),Tn=p.useCallback(k=>{if(!(d!=null&&d.views))return;const _=d.views.find(Ue=>Ue.id===k),A=d.views.filter(Ue=>!Ue.isDeleted||Ue.id===k);if((_==null?void 0:_.isDefault)&&A.filter(Ue=>Ue.isDefault).length===1){h("Cannot delete the last default view","error");return}const U=d.views.map(Ue=>Ue.id===k?{...Ue,isDeleted:!0,updatedAt:Date.now()}:Ue),J=d.activeViewId===k,le=U.find(Ue=>Ue.isDefault&&!Ue.isDeleted);H(d.id,{views:U,activeViewId:J&&le?le.id:d.activeViewId,filters:J&&le?le.snapshot.filters:d.filters,sortStack:J&&le?le.snapshot.sortStack.length>0?le.snapshot.sortStack:void 0:d.sortStack});const ve=d.views.find(Ue=>Ue.id===k);ve&&h(`"${ve.name}" moved to Recently Deleted`,"info")},[d,H]),Oo=p.useCallback(k=>{if(!(d!=null&&d.views))return;const _=d.views.map(M=>M.id===k?{...M,isDeleted:!1,updatedAt:Date.now()}:M);H(d.id,{views:_});const A=d.views.find(M=>M.id===k);A&&h(`"${A.name}" restored`,"success")},[d,H]),Gr=p.useCallback(k=>{if(!(d!=null&&d.views))return;const _=d.views.find(ve=>ve.id===k),A=d.views.filter(ve=>!ve.isDeleted||ve.id===k);if((_==null?void 0:_.isDefault)&&A.filter(ve=>ve.isDefault).length===1){h("Cannot delete the last default view","error");return}const U=d.views.filter(ve=>ve.id!==k),J=d.activeViewId===k,le=U.find(ve=>ve.isDefault&&!ve.isDeleted);H(d.id,{views:U,activeViewId:J&&le?le.id:d.activeViewId,filters:J&&le?le.snapshot.filters:d.filters,sortStack:J&&le?le.snapshot.sortStack.length>0?le.snapshot.sortStack:void 0:d.sortStack}),_&&h(`"${_.name}" permanently deleted`,"success")},[d,H]),Mo=p.useCallback(k=>{Te(k),Q(!0)},[]),Ur=p.useCallback(async k=>{if(!d)return;const _=new URLSearchParams(window.location.search);_.set("reportId",d.id),_.set("view",k);const A=`${window.location.origin}${window.location.pathname}?${_.toString()}`,M=await fl(A);h(M?"Link copied to clipboard":"Failed to copy link",M?"success":"error")},[d]),mo=p.useCallback((k,_)=>{if(!ae||!(d!=null&&d.views))return;const A=d.views.map(M=>M.id===ae?{...M,name:k,description:_||void 0}:M);H(d.id,{views:A}),Te(null)},[ae,d,H]),Wo=p.useCallback(k=>{Pe(k),D(!0)},[]),Yr=p.useCallback(()=>{if(!Y||!(d!=null&&d.views))return;const k=d.views.find(U=>U.id===Y),_=d.views.filter(U=>U.id!==Y),A=d.activeViewId===Y,M=_.find(U=>U.isDefault);ie("views","view_deleted",{viewId:Y,name:k==null?void 0:k.name},null),H(d.id,{views:_,activeViewId:A&&M?M.id:d.activeViewId,filters:A&&M?M.snapshot.filters:d.filters,sortStack:A&&M?M.snapshot.sortStack.length>0?M.snapshot.sortStack:void 0:d.sortStack}),Pe(null),D(!1)},[Y,d,H,ie]),qr=p.useCallback(k=>{var U;if(!(d!=null&&d.views))return;if(!(((U=j.views)==null?void 0:U.isAdmin)??!1)){h("Only administrators can promote views to Global.","error");return}const A=d.views.find(J=>J.id===k);if(!A)return;if(A.scope==="global"){h(`"${A.name}" is already a Global View.`,"info");return}const M=d.views.map(J=>J.id===k?{...J,scope:"global",isDefault:!0,updatedAt:Date.now()}:J.scope==="global"&&J.isDefault?{...J,isDefault:!1}:J);H(d.id,{views:M}),h(`"${A.name}" promoted to Global View and set as default.`,"success")},[d,j,H]),Tr=p.useRef(!0);p.useEffect(()=>{var k;if(Tr.current){Tr.current=!1;return}if(b==="server"){Ze(1),(k=a==null?void 0:a.onPaginationChange)==null||k.call(a,1,et);return}ze!=null&&ze.resetPage?ze.resetPage():Ze(1)},[d==null?void 0:d.filters,_t,d==null?void 0:d.activeViewId,d==null?void 0:d.grouping]);const xr=p.useCallback(k=>{var _;if(b==="server"){Ze(k),(_=a==null?void 0:a.onPaginationChange)==null||_.call(a,k,et);return}ze!=null&&ze.goToPage&&ze.goToPage(k),Ze(k)},[b,a,et,ze]),Ao=p.useCallback(k=>{var M;const _=(Jt-1)*et,A=Math.floor(_/k)+1;if(b==="server"){Lt(k),Ze(A),(M=a==null?void 0:a.onPaginationChange)==null||M.call(a,A,k);return}Lt(k),Ze(A),ze==null||ze.goToPage(A)},[Jt,et,b,a,ze]),Jr=p.useCallback((k,_)=>{if(!d)return;if(!jt("edit_columns",Be)){h(kt("edit_columns"),"error");return}const M={...d.columnVisibility||(Z==null?void 0:Z.snapshot.columnVisibility)||{},[k]:_};ie("columns",_?"column_shown":"column_hidden",{columnName:k,visible:!_},{columnName:k,visible:_}),H(d.id,{columnVisibility:M})},[d,Z,Be,H,ie]),Bn=p.useCallback(k=>{if(d){if(!jt("edit_columns",Be)){h(kt("edit_columns"),"error");return}ie("columns","column_reordered",d.columnOrder,k),H(d.id,{columnOrder:k})}},[d,Be,H,ie]),In=p.useCallback((k,_)=>{if(!d)return;if(!jt("edit_columns",Be)){h(kt("edit_columns"),"error");return}const A=d.columnWidths||(Z==null?void 0:Z.snapshot.columnWidths)||{},M={...A,[k]:_};ie("columns","column_resized",{columnName:k,width:A[k]},{columnName:k,width:_}),H(d.id,{columnWidths:M})},[d,Z,Be,H,ie]),En=p.useCallback(k=>{if(!d)return;const _=Fe(d.filters),A=zs(_,k);H(d.id,{filters:A})},[d,H]),Dn=p.useCallback(()=>{if(!Z||!(d!=null&&d.schema))return;const k={},_=[],A={};d.schema.forEach(M=>{k[M.name]=!0,_.push(M.name),A[M.name]=170}),H(d.id,{columnVisibility:k,columnOrder:_,columnWidths:A,filters:void 0,sortStack:void 0}),h("Reset to default layout - all filters and sorts cleared","success")},[Z,d,H]);p.useEffect(()=>{const k=setTimeout(()=>Cr(ar),300);return()=>clearTimeout(k)},[ar]),p.useEffect(()=>{var k;y==="server"&&((k=c==null?void 0:c.onSearchChange)==null||k.call(c,_t))},[_t,y,c]);const _n=p.useCallback(k=>{lo(k),Ze(1)},[]),$n=p.useCallback(k=>{if(!k.trim()||!d)return;const _=d.searchHistory||[],A=Ja(_,k);H(d.id,{searchHistory:A})},[d,H]),On=p.useCallback(k=>{if(!d)return;const _=d.searchHistory||[],A=Ka(_,k);H(d.id,{searchHistory:A})},[d,H]),Mn=p.useCallback(k=>{if(!d)return;const _=d.searchHistory||[],A=Xa(_,k);H(d.id,{searchHistory:A})},[d,H]);p.useEffect(()=>{if(!C.onSelectionChange)return;const k=Array.from(Xe);C.onSelectionChange(k,k.map(_=>_==null?void 0:_.__urm_row_id__))},[Xe,C.onSelectionChange]);const Wn=p.useCallback(k=>{const _=k==null?void 0:k.__urm_row_id__;Nt(A=>{const M=new Set(A);if(_!==void 0){const U=Array.from(M).find(J=>(J==null?void 0:J.__urm_row_id__)===_);U!==void 0?M.delete(U):M.add(k)}else{const U=JSON.stringify(k),J=Array.from(M).find(le=>JSON.stringify(le)===U);J!==void 0?M.delete(J):M.add(k)}return M})},[]),Kr=p.useCallback((k,_)=>{Nt(A=>{const M=new Set(A);for(const U of _)k?M.add(U):M.delete(U);return M})},[]),rr=p.useCallback((k,_,A)=>{Nt(M=>{const U=new Set(M),J=Math.min(k,_),le=Math.max(k,_);for(let ve=J;ve<=le;ve++)A[ve]!==void 0&&U.add(A[ve]);return U})},[]),An=p.useCallback(()=>{Nt(new Set)},[]),Rn=p.useCallback(k=>{const _=k==null?void 0:k.__urm_row_id__;Nt(A=>{const M=new Set(A);if(_!==void 0){const U=Array.from(M).find(J=>(J==null?void 0:J.__urm_row_id__)===_);U!==void 0&&M.delete(U)}else M.delete(k);return M})},[]),Re=p.useCallback(k=>{var _,A;if(d){if(!jt("edit_columns",Be)){h(kt("edit_columns"),"error");return}if(k&&d.schema){const{validGrouping:M,invalidColumns:U}=Es(k,d.schema);U.length>0&&h(`Removed invalid grouping columns: ${U.join(", ")}`,"warning"),$t();try{const J=d.grouping;M===null?ie("grouping","group_cleared",J,null):J?ie("grouping","group_reordered",J,M):ie("grouping","group_level_added",null,M);const le=(Z==null?void 0:Z.snapshot.columnOrder)||d.columnOrder||[],ve=vo(le,M),Ue=M.levels.length>0?{...M,collapsedGroups:zi(ur,d.schema,M)}:M;H(d.id,{grouping:Ue,columnOrder:ve}),Ze(1),ze==null||ze.resetPage(),b==="server"&&((_=a==null?void 0:a.onPaginationChange)==null||_.call(a,1,et)),JSON.stringify(ve)!==JSON.stringify(d.columnOrder)&&ie("columns","column_reordered",d.columnOrder,ve),vt(!1)}catch(J){const le=gr("processing","grouping",J);St(le)}}else{const M=d.grouping;ie("grouping","group_cleared",M,null);const U=(Z==null?void 0:Z.snapshot.columnOrder)||d.columnOrder||[];H(d.id,{grouping:k,columnOrder:U}),Ze(1),ze==null||ze.resetPage(),b==="server"&&((A=a==null?void 0:a.onPaginationChange)==null||A.call(a,1,et)),JSON.stringify(U)!==JSON.stringify(d.columnOrder)&&ie("columns","column_reordered",d.columnOrder,U),vt(!1)}}},[d,Z,Be,H,$t,St,ie,ur]),lt=p.useCallback(k=>{if(!d||!j.grouping.allowCollapse)return;const _=d.grouping;if(!_)return;const A=Na(_,k);H(d.id,{grouping:A})},[d,j,H]),xo=p.useCallback(()=>{!(d!=null&&d.grouping)||!j.grouping.allowCollapse||H(d.id,{grouping:{...d.grouping,collapsedGroups:[]}})},[d,j,H]),Ro=p.useCallback(()=>{if(!(d!=null&&d.grouping)||!d.schema||!j.grouping.allowCollapse)return;const k=zi(ur,d.schema,d.grouping);H(d.id,{grouping:{...d.grouping,collapsedGroups:k}})},[d,ur,j,H]),Pn=p.useCallback(()=>{Ft(!0)},[]),ft=p.useCallback(k=>{d!=null&&d.schema&&(mt(!0),setTimeout(()=>{try{let _;k.scope==="visible"?_=kr:_=d.uploadedData||[];let A;k.columnScope==="all"?(A={},(d.schema??[]).forEach(ve=>{A[ve.name]=!0})):A=d.columnVisibility||(Z==null?void 0:Z.snapshot.columnVisibility)||{};const M=d.columnOrder||(Z==null?void 0:Z.snapshot.columnOrder),U=Zo(_,d.schema,Fe(d.filters),d.sortStack??[],Z,A,M),J=d.name;let le;switch(k.format){case"csv":en(U,J,k),le="export_csv";break;case"excel":tn(U,J,k),le="export_excel";break;case"json":rn(U,J,k),le="export_json";break;case"pdf":hi(U,J,k),le="export_pdf";break}ie("export",le,null,{format:k.format,scope:k.scope,columnScope:k.columnScope,rowCount:_.length,viewName:(Z==null?void 0:Z.name)||"Default View"}),h(`Export completed successfully (${k.format.toUpperCase()})`,"success")}catch(_){const A=jl(_,{onRetry:()=>ft(k)});h(`Export failed: ${A.message}. Click Export to retry.`,"error");const M=Oi(d.id,At,A,d.auditHistory||[]);H(d.id,{auditHistory:M}),Ut.error("urm:report-engine","Export failed",_)}finally{mt(!1)}},500))},[d,Z,kr,H,ie]),Xr=p.useCallback(k=>{if(d!=null&&d.schema){if(se&&Z&&!Z.isDefault){Yt(k.format),Pt(!0),Ft(!1);return}ft(k),Ft(!1)}},[d,Z,se,ft]),wt=p.useCallback(k=>{ft({format:k,scope:"visible",columnScope:"visible"})},[ft]),Po=p.useCallback(()=>{it&&wt(it),Pt(!1),Yt(null)},[it,wt]),Nn=p.useCallback(()=>{Ct(),it&&wt(it),Pt(!1),Yt(null)},[Ct,it,wt]),No=p.useCallback(()=>{Pt(!1),Yt(null)},[]),Lo=p.useCallback(k=>{!(d!=null&&d.schema)||Xe.size===0||(mt(!0),setTimeout(()=>{try{const _=Array.from(Xe),A=Zo(_,d.schema,Fe(d.filters),d.sortStack??[],Z),M=`${d.name.toLowerCase().replace(/\s+/g,"_")}_selected_export`;switch(k){case"csv":en(A,M);break;case"excel":tn(A,M);break;case"json":rn(A,M);break}h(`Exported ${_.length} selected rows`,"info")}catch(_){h("Export failed. Please try again.","error"),Ut.error("urm:report-engine","Bulk export failed",_)}finally{mt(!1)}},500))},[d,Z,Xe,Zt]),w=p.useCallback((k,_)=>{if(d)try{const A=dl(d),M=ul(k,_,At,A),U=pl(d.presets,M);H(d.id,{presets:U}),ie("presets","preset_created",null,{presetId:M.id,name:M.name}),He(!1),h(`Preset "${k}" saved successfully`,"success")}catch(A){h(A instanceof Error?A.message:"Failed to create preset","error")}},[d,H,ie]),P=p.useCallback(()=>{cr(null),h("Exited preset view","info")},[]),re=p.useCallback(()=>{lr(!0)},[]),we=p.useCallback((k,_)=>{if(!d)return;const A=hl(d.presets,k);H(d.id,{presets:A}),ie("presets","preset_deleted",{presetId:k,name:_},null),Kt===k&&cr(null),h(`Preset "${_}" deleted`,"success")},[d,Kt,H,ie]);p.useEffect(()=>{if(!f||z.length===0)return;const k=z.find(_=>_.id===f);k&&k.id!==E&&S(k.id)},[f,z,E]);const Me=p.useRef(!1);p.useEffect(()=>{var _;if(!m||Me.current||!d||d.id!==f)return;const k=(_=d.views)==null?void 0:_.find(A=>A.id===m&&!A.isDeleted);k&&We(k.id),Me.current=!0},[m,f,d,We]),p.useEffect(()=>{if(!d)return;const k=ml();if(k&&d.presets&&d.schemaLocked&&d.schema){const _=$i(d.presets,k);if(_){const{sanitizedConfig:A,warnings:M}=wl(_.config,d.schema);M.length>0&&M.forEach(J=>h(J,"warning"));const U=xl(A);H(d.id,U),cr(k),ie("presets","preset_applied",null,{presetId:_.id,name:_.name}),h(`Loaded preset: ${_.name}`,"info")}else h("Preset not found","info")}},[d==null?void 0:d.schemaLocked]);const nt=Kt?$i(d==null?void 0:d.presets,Kt):void 0;p.useEffect(()=>{var k;d!=null&&d.views&&d.views.length>0&&d.activeViewId&&(B==="api"?(k=v==null?void 0:v.onViewsChange)==null||k.call(v,d.views,d.activeViewId):Ua(d.id,{views:d.views,activeViewId:d.activeViewId}))},[d==null?void 0:d.views,d==null?void 0:d.activeViewId,d==null?void 0:d.id,B]),p.useEffect(()=>{if(d!=null&&d.schemaLocked&&d.schema&&(!d.views||d.views.length===0)){const k=B==="api"?v!=null&&v.views&&v.views.length>0?{views:v.views,activeViewId:v.activeViewId??v.views[0].id}:null:Ya(d.id);if(k&&k.views.length>0){const _=k.views.find(A=>A.id===k.activeViewId);if(_)H(d.id,{views:k.views,activeViewId:k.activeViewId,filters:Fe(_.snapshot.filters),sortStack:_.snapshot.sortStack.length>0?_.snapshot.sortStack:void 0});else{const A=k.views.find(M=>M.isDefault)||Fn(d.schema);H(d.id,{views:k.views,activeViewId:A.id,filters:Fe(A.snapshot.filters),sortStack:A.snapshot.sortStack.length>0?A.snapshot.sortStack:void 0})}}}},[d==null?void 0:d.schemaLocked,d==null?void 0:d.schema,d==null?void 0:d.id,B,v]);const rt=p.useCallback(k=>{var M;const _=Fe(d==null?void 0:d.filters),A=((M=j.filter)==null?void 0:M.maxConditions)??3;if(Tt(_)>=A){h(`Filter limit reached — maximum ${A} filters allowed. Remove an existing filter before adding a new one.`,"warning");return}xe(k),ge(!0)},[d,j,h]),me=p.useCallback(()=>{ge(!1),xe(void 0)},[]),Vt=(vi=d==null?void 0:d.views)==null?void 0:vi.find(k=>k.id===ae),or=(Si=d==null?void 0:d.views)==null?void 0:Si.find(k=>k.id===Y);return{reports:z,activeReport:d,activeReportId:E,setActiveReportId:S,isModalOpen:R,setIsModalOpen:q,createReport:hr,updateReport:H,uploadState:oe,handleFileUpload:Pr,handleUploadError:po,handleRetry:Nr,handleConfirm:mr,paginatedData:Wr,processedData:kr,displayData:Zt,tableMetrics:pr,isGrouped:Ar,tableEngine:Qt,activeView:Z,isDirty:se,currentTableState:be,viewChanges:Rr,filters:d==null?void 0:d.filters,showFilterPanel:te,setShowFilterPanel:ge,filterFocusColumn:ee,handleAddCondition:Ge,handleAddGroup:zr,handleUpdateCondition:st,handleSetGroupOperator:er,handleRemoveFilterNode:Wt,handleClearAllFilters:fe,handleReplaceFilters:je,handleOpenFilterForColumn:rt,handleCloseFilterPanel:me,handleClearFiltersForColumn:En,sortStack:d==null?void 0:d.sortStack,showSortPanel:V,setShowSortPanel:K,handleSort:Lr,handleUpdateSortStack:Fr,handleSortAscending:Mt,handleSortDescending:Ce,views:d==null?void 0:d.views,showCreateViewModal:ce,setShowCreateViewModal:de,showEditViewModal:ne,setShowEditViewModal:Q,showDeleteConfirmation:pe,setShowDeleteConfirmation:D,editingView:Vt,deletingView:or,editingViewId:ae,deletingViewId:Y,handleSelectView:We,handleCreateView:qe,handleCloneView:at,handleUpdateCurrentView:Ct,handleSaveColumnConfigToCurrentView:tr,handleSaveColumnConfigToAllViews:$o,handleSaveAsNewView:Vr,handleRevertChanges:zn,handleToggleDefault:Hr,handleToggleFavorite:ho,handleSoftDelete:Tn,handleRestoreView:Oo,handlePermanentDelete:Gr,handleEditView:Mo,handleCopyViewLink:Ur,handleSaveEditView:mo,handleDeleteView:Wo,handleConfirmDelete:Yr,handlePromoteToGlobal:qr,showManageColumns:Ke,setShowManageColumns:Dt,columnVisibility:d==null?void 0:d.columnVisibility,columnOrder:d==null?void 0:d.columnOrder,columnWidths:d==null?void 0:d.columnWidths,handleUpdateColumnVisibility:Jr,handleUpdateColumnOrder:Bn,handleUpdateColumnWidth:In,handleResetColumnLayout:Dn,showGroupPanel:Sr,setShowGroupPanel:vt,grouping:d==null?void 0:d.grouping,groupingState:qt,handleGroup:Re,handleToggleGroupCollapse:lt,handleExpandAllGroups:xo,handleCollapseAllGroups:Ro,searchQuery:ar,debouncedSearchQuery:_t,searchHistory:Qa((d==null?void 0:d.searchHistory)||[]),handleSearchChange:_n,handleAddToSearchHistory:$n,handleToggleSearchFavourite:On,handleDeleteSearchHistory:Mn,selectedRowIds:Xe,handleToggleRowSelection:Wn,handleToggleAllRows:Kr,handleRangeSelection:rr,handleClearSelection:An,handleUpdateSelectionAfterDelete:Rn,currentPage:Jt,pageSize:et,paginationEngine:ze,paginationMode:b,paginationTotalRows:Qe,handlePageChange:xr,handlePageSizeChange:Ao,isExporting:Et,showExportModal:uo,setShowExportModal:Ft,showDirtyExportWarning:$r,handleExport:Pn,handleExportWithConfig:Xr,handleExportSelected:Lo,handleExportAnyway:Po,handleSaveAndExport:Nn,handleCancelExport:No,showAuditHistory:co,setShowAuditHistory:Or,auditHistory:d==null?void 0:d.auditHistory,showCreatePreset:wr,setShowCreatePreset:He,showManagePresets:Se,setShowManagePresets:lr,activePreset:nt,activePresetId:Kt,handleOpenManagePresets:re,handleCreatePreset:w,handleClearActivePreset:P,handleDeletePresetById:we,userRole:Be,isViewerRole:he,currentUserId:At,featureLimitWarning:Mr,setFeatureLimitWarning:dr,datasetMeta:jr,reportError:tt,setReportError:Xt,handleError:St,schema:d==null?void 0:d.schema,hasSchemaConflicts:d!=null&&d.schema?_a(d.schema):!1,snack:X,handleSnackClose:I,showSnack:h,snackDurationMs:N,config:C,scheduler:l}}const Ds=p.createContext(void 0);function mi(e){const{children:r,initialData:n,data:i,reportName:s,reportId:a,dataSource:c,pagination:l,search:u,scheduler:g,mode:f="builder",autoLoad:m=!0,config:v,devConfig:C,showDevPanel:B=!1,sharedReportId:b,sharedViewId:y,viewPersistence:z}=e,j=Ll({mode:f,autoLoad:m,initialData:i||n,dataSource:c,pagination:l,search:u,scheduler:g,reportName:s,reportId:a,sharedReportId:b,sharedViewId:y,viewPersistence:z,config:v}),[E,S]=p.useState(()=>ma()),R=(()=>{const X=fa(E,C,!!C);return{...X,display:{...X.display,showDevPanel:B||X.display.showDevPanel}}})(),q=p.useCallback(F=>{S(F),xa(F)},[]),T={...j,activeDevConfig:R,handleDevConfigChange:q};return t.jsx(Cs.Provider,{value:R,children:t.jsx(Ds.Provider,{value:T,children:r})})}function dn(){const e=p.useContext(Ds);if(e===void 0)throw new Error("useReportContext must be used within a ReportProvider. Wrap your component tree with <ReportProvider>...</ReportProvider>");return e}function Fl({onCreateReport:e,reports:r=[],activeReportId:n,onReportClick:i}){const s=r.find(a=>a.id===n);return t.jsx(o.Box,{component:"header",sx:a=>{var f,m,v;const c=((v=(m=(f=a.components)==null?void 0:f.MuiCardHeader)==null?void 0:m.styleOverrides)==null?void 0:v.root)||{},l=c.backgroundColor&&c.backgroundColor!=="transparent"?c.backgroundColor:a.palette.background.paper,u=c.borderBottom&&c.borderBottom!=="none"?c.borderBottom:"1px solid",g=c.boxShadow&&c.boxShadow!=="none"?c.boxShadow:void 0;return{position:"sticky",top:0,zIndex:50,borderBottom:u,borderColor:u!=="none"?"divider":void 0,boxShadow:g,bgcolor:l}},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,height:64},children:[t.jsxs(o.Breadcrumbs,{separator:t.jsx(O.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}),sx:{display:"flex",alignItems:"center"},children:[t.jsx(o.Typography,{variant:"h6",component:"h1",sx:{fontWeight:a=>a.typography.h6.fontWeight||500,fontSize:a=>a.typography.h6.fontSize||"1.375rem",color:a=>a.typography.h6.color||"text.primary",letterSpacing:"-0.01em",cursor:r.length>0&&s?"pointer":"default","&:hover":r.length>0&&s?{color:"primary.main"}:{}},onClick:()=>{r.length>0},children:"Reports"}),s&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.Typography,{sx:{fontWeight:a=>a.typography.h6.fontWeight||500,fontSize:a=>a.typography.h6.fontSize||"1.125rem",color:"primary.main",cursor:"pointer","&:hover":{textDecoration:"underline"}},onClick:()=>i==null?void 0:i(s.id),children:s.name}),t.jsx(o.Tooltip,{title:s.description||"No description",arrow:!0,placement:"bottom",children:t.jsx(O.InfoOutlined,{sx:{fontSize:18,color:"text.secondary",opacity:.7,cursor:"help","&:hover":{opacity:1}}})})]})]}),t.jsx(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:t.jsx(o.Button,{variant:"contained",startIcon:t.jsx(O.Add,{sx:{fontSize:18}}),onClick:e,sx:{borderRadius:"20px",px:3,fontSize:"0.875rem",py:.75},children:"New Report"})})]})})}function Er(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 Vl="$$material";function Hl(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Go={exports:{}},Uo={exports:{}},Ie={};/** @license React v16.13.1
105
+ </html>`;try{const m=document.createElement("iframe");m.style.position="fixed",m.style.right="0",m.style.bottom="0",m.style.width="0",m.style.height="0",m.style.border="0",document.body.appendChild(m);const T=((v=m.contentWindow)==null?void 0:v.document)||m.contentDocument;if(T){T.open(),T.write(f),T.close(),setTimeout(()=>{var h,z;try{(h=m.contentWindow)==null||h.focus(),(z=m.contentWindow)==null||z.print()}catch{}setTimeout(()=>{document.body.removeChild(m)},3e3)},300);return}}catch{}const S=new Blob([f],{type:"text/html;charset=utf-8;"}),C=URL.createObjectURL(S);window.open(C,"_blank")||pi(f,dn(r,"html"),"text/html;charset=utf-8;")}function Uo(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const Di=10;function Xa(e,r){const n=r.trim();if(!n)return e;const i=e.findIndex(a=>a.query.toLowerCase()===n.toLowerCase());let s;return i!==-1?s=[{...e[i],lastUsed:Date.now()},...e.slice(0,i),...e.slice(i+1)]:s=[{query:n,isFavourite:!1,lastUsed:Date.now()},...e],s.length>Di&&(s=[...s].sort((c,l)=>c.isFavourite&&!l.isFavourite?-1:!c.isFavourite&&l.isFavourite?1:l.lastUsed-c.lastUsed).slice(0,Di)),s}function Qa(e,r){return e.map(n=>n.query===r?{...n,isFavourite:!n.isFavourite}:n)}function Za(e,r){return e.filter(n=>n.query!==r)}function el(e){const r=e.filter(i=>i.isFavourite).sort((i,s)=>s.lastUsed-i.lastUsed),n=e.filter(i=>!i.isFavourite).sort((i,s)=>s.lastUsed-i.lastUsed);return[...r,...n]}const tl={owner:["view_report","edit_columns","edit_filters","edit_sorting","edit_views","create_views","delete_views","delete_report","export_data","promote_global_view"],editor:["view_report","edit_columns","edit_filters","edit_sorting","edit_views","create_views","delete_views","export_data"],viewer:["view_report","export_data"]};function rl(e,r){return!e||e.owner===r?"owner":e.editors.includes(r)?"editor":(e.viewers.includes(r),"viewer")}function jt(e,r){return tl[r].includes(e)}function kt(e){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",promote_global_view:"promote views to global"}[e]||"perform this action"}.`}function ol(e){return e==="viewer"}const _i=1e3;function ei(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}function Ut(e){if(!e)return"";const n=e.replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2");return ei(n)}const nl={equals:"equals",contains:"contains",startsWith:"starts with",endsWith:"ends with",gt:"is greater than",lt:"is less than",gte:"is greater than or equal to",lte:"is less than or equal to",isTrue:"is true",isFalse:"is false",NULL:"is empty",NOT_NULL:"is not empty"};function il(e){if(!e||!e.column)return"a filter";const r=Ut(e.column),n=nl[e.operator]??e.operator;return["isTrue","isFalse","NULL","NOT_NULL"].includes(e.operator)?`"${r}" ${n}`:`"${r}" ${n} "${e.value}"`}function Vn(e){return e?typeof e=="string"?e:"children"in e?"a condition group":il(e):"a filter"}function $i(e){return!e||!e.enabled||e.levels.length===0?"grouping removed":`grouped by ${e.levels.map(n=>`"${Ut(n.column)}"`).join(", ")}`}function sl(e){var s,a,c;const{action:r,previousState:n,newState:i}=e;switch(r){case"filter_added":return{summary:`Filter added: ${Vn(i)}`};case"filter_removed":return{summary:`Filter removed: ${Vn(n)}`};case"filter_updated":{if(typeof i=="string")return{summary:`Filter updated: ${i}`};const l=n,u=i;return l!=null&&l.column&&(u!=null&&u.column)&&l.column!==u.column?{summary:`Filter changed on "${Ut(u.column)}"`,detail:`Previously filtered "${Ut(l.column)}"`}:{summary:`Filter updated: ${Vn(u)}`}}case"filter_cleared":{const l=n&&typeof n=="object"&&"count"in n?n.count:0;return{summary:l>0?`All filters cleared (${l} filter${l!==1?"s":""} removed)`:"All filters cleared"}}case"sort_level_added":{const l=i!=null&&i.column?Ut(i.column):"",u=(i==null?void 0:i.direction)==="asc"?"ascending":"descending";return{summary:l?`Sort added: "${l}" ${u}`:"Sort level added"}}case"sort_level_removed":{const l=n!=null&&n.column?Ut(n.column):"";return{summary:l?`Sort removed: "${l}"`:"Sort level removed"}}case"sort_reordered":return{summary:"Sort order changed"};case"sort_cleared":return{summary:"All sorting cleared"};case"group_level_added":return{summary:`Grouping applied: ${$i(i)}`};case"group_level_removed":{const l=n,u=(a=(s=l==null?void 0:l.levels)==null?void 0:s[0])!=null&&a.column?Ut(l.levels[0].column):"";return{summary:u?`Group level removed: "${u}"`:"Group level removed"}}case"group_reordered":return{summary:`Grouping updated: ${$i(i)}`};case"group_cleared":return{summary:"Grouping removed"};case"column_hidden":{const l=(i==null?void 0:i.column)??(typeof i=="string"?i:"");return{summary:l?`Column hidden: "${Ut(l)}"`:"Column hidden"}}case"column_shown":{const l=(i==null?void 0:i.column)??(typeof i=="string"?i:"");return{summary:l?`Column shown: "${Ut(l)}"`:"Column made visible"}}case"column_reordered":{const l=Array.isArray(n)?n:[],u=Array.isArray(i)?i:[];return l.length>0&&u.length>0?{summary:"Column order changed",detail:`${u.length} column${u.length!==1?"s":""} reordered`}:{summary:"Columns reordered"}}case"column_resized":{const l=(i==null?void 0:i.column)??"",u=(i==null?void 0:i.width)??"";return{summary:l?`Column resized: "${Ut(l)}"`:"Column resized",detail:u?`New width: ${u}px`:void 0}}case"view_created":{const l=(i==null?void 0:i.name)??(i==null?void 0:i.viewName)??"";return{summary:l?`View created: "${l}"`:"New view created"}}case"view_updated":{const l=(i==null?void 0:i.name)??(n==null?void 0:n.name)??"";return{summary:l?`View updated: "${l}"`:"View updated"}}case"view_deleted":{const l=(n==null?void 0:n.name)??(n==null?void 0:n.viewName)??"";return{summary:l?`View deleted: "${l}"`:"View deleted"}}case"view_set_default":{const l=(i==null?void 0:i.name)??"";return{summary:l?`Default view set to "${l}"`:"Default view changed"}}case"view_switched":{const l=(n==null?void 0:n.name)??"",u=(i==null?void 0:i.name)??"";return l&&u?{summary:`Switched to view "${u}"`,detail:`From "${l}"`}:u?{summary:`Switched to view "${u}"`}:{summary:"View switched"}}case"export_csv":case"export_excel":case"export_json":case"export_pdf":{const l=r==="export_csv"?"CSV":r==="export_excel"?"Excel":r==="export_json"?"JSON":"PDF",u=i==null?void 0:i.rowCount,g=(i==null?void 0:i.scope)==="all"?"all rows":"filtered rows",x=(i==null?void 0:i.viewName)??"",f=typeof u=="number"?` (${u.toLocaleString()} rows)`:"";return{summary:`Exported as ${l}${f}`,detail:x?`${ei(g)} · View: "${x}"`:ei(g)}}case"export_triggered":{const l=((c=i==null?void 0:i.format)==null?void 0:c.toUpperCase())??"";return{summary:l?`Export triggered: ${l}`:"Export triggered"}}case"preset_created":{const l=(i==null?void 0:i.name)??"";return{summary:l?`Preset created: "${l}"`:"New preset created"}}case"preset_applied":{const l=(i==null?void 0:i.name)??"";return{summary:l?`Preset applied: "${l}"`:"Preset applied"}}case"preset_deleted":{const l=(n==null?void 0:n.name)??"";return{summary:l?`Preset deleted: "${l}"`:"Preset deleted"}}case"preset_link_copied":{const l=(i==null?void 0:i.name)??"";return{summary:l?`Preset link copied: "${l}"`:"Preset link copied to clipboard"}}case"row_edited":{const l=(i==null?void 0:i.id)??(n==null?void 0:n.id)??"",u=(i==null?void 0:i.label)??(n==null?void 0:n.label)??(l?`#${l}`:"");return{summary:u?`Row edited: "${u}"`:"Row edited"}}case"row_deleted":{const l=(n==null?void 0:n.id)??"",u=(n==null?void 0:n.label)??(l?`#${l}`:"");return{summary:u?`Row deleted: "${u}"`:"Row deleted"}}case"row_duplicated":{const l=(n==null?void 0:n.id)??"",u=(n==null?void 0:n.label)??(l?`#${l}`:"");return{summary:u?`Row duplicated: "${u}"`:"Row duplicated"}}case"theme_changed":{const l=typeof n=="string"?n:(n==null?void 0:n.theme)??"",u=typeof i=="string"?i:(i==null?void 0:i.theme)??"";return l&&u?{summary:`Theme changed from "${l}" to "${u}"`}:u?{summary:`Theme changed to "${u}"`}:{summary:"Theme changed"}}case"error_occurred":{const l=(i==null?void 0:i.message)??(i==null?void 0:i.error)??typeof i=="string"?i:"";return{summary:"An error was recorded",detail:l?`Details: ${String(l).slice(0,120)}`:void 0}}default:return{summary:ll(r)}}}function al(){return`EVT_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function jo(e,r,n,i,s,a){return{id:al(),user:r,reportId:e,feature:n,action:i,timestamp:new Date().toISOString(),previousState:s,newState:a}}function ko(e,r){const n=[r,...e];return n.length>_i?n.slice(0,_i):n}function ll(e){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",export_pdf:"Exported as PDF",preset_created:"Preset Created",preset_applied:"Preset Applied",preset_deleted:"Preset Deleted",preset_link_copied:"Preset Link Copied",row_edited:"Row Edited",row_deleted:"Row Deleted",row_duplicated:"Row Duplicated",error_occurred:"Error Occurred"}[e]||e}function cl(e){return{filters:"Filters",sorting:"Sorting",grouping:"Grouping",columns:"Columns",views:"Views",theme:"Theme",export:"Export",presets:"Presets",rows:"Rows",system:"System"}[e]||e}function dl(e){const r=new Date(e),i=new Date().getTime()-r.getTime(),s=Math.floor(i/6e4),a=Math.floor(i/36e5),c=Math.floor(i/864e5);return s<1?"Just now":s<60?`${s} minute${s>1?"s":""} ago`:a<24?`${a} hour${a>1?"s":""} ago`:c<7?`${c} day${c>1?"s":""} ago`:r.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}const Oi=100;function ul(){return`preset_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function pl(e){var a;const r=(a=e.views)==null?void 0:a.find(c=>c.id===e.activeViewId),n=r==null?void 0:r.snapshot.columnOrder,i=e.columnOrder||[],s=ui(i,e.grouping||null,n);return{filters:He(e.filters),sortStack:e.sortStack?[...e.sortStack]:[],columnVisibility:e.columnVisibility?{...e.columnVisibility}:{},columnOrder:s,columnWidths:e.columnWidths?{...e.columnWidths}:{},grouping:e.grouping?{...e.grouping}:null,activeViewId:e.activeViewId}}function hl(e,r,n,i){return{id:ul(),name:e,description:r,createdBy:n,createdAt:Date.now(),config:i}}function fl(e,r){const n=e||[];if(n.length>=Oi)throw new Error(`Maximum of ${Oi} presets reached. Please delete old presets first.`);return[...n,r]}function ml(e,r){return(e||[]).filter(i=>i.id!==r)}function Mi(e,r){if(e)return e.find(n=>n.id===r)}function xl(){return typeof window>"u"?null:new URLSearchParams(window.location.search).get("preset")}function gl(e){const r=e.columnOrder,n=vo(r,e.grouping);return{filters:He(e.filters),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 yl(e){try{if(navigator.clipboard&&navigator.clipboard.writeText)return await navigator.clipboard.writeText(e),!0}catch(r){Gt.warn("urm:presets","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){Gt.error("urm:presets","execCommand copy failed",i)}return document.body.removeChild(r),n}catch(r){return Gt.error("urm:presets","Fallback copy method failed",r),!1}}function bl(e,r){return{totalRows:e.length,totalColumns:r.length}}function mr(e,r,n,i){const s=n instanceof Error?n.message:n,a={type:e,context:r,message:s,details:i,timestamp:Date.now(),recoverable:vl(e,r)};return process.env.NODE_ENV==="development"&&Gt.error("urm:error-handling","[Report Error]",{type:e,context:r,message:s,details:i}),a}function vl(e,r){return e==="ui"?!0:r==="export"?!1:e==="processing"&&["filters","sorting","grouping","columns"].includes(r)?!0:e!=="system"}function Sl(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 Cl(e){return{filters:e.filters,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 wl(e,r,n){n(e.id,{filters:He(r.filters),sortStack:r.sortStack,grouping:r.grouping,columnVisibility:r.columnVisibility,columnOrder:r.columnOrder,columnWidths:r.columnWidths,activeViewId:r.activeViewId})}function jl(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 Ds(e,r){const n=[],i=[],s=new Set(r.map(a=>a.name));return e.forEach(a=>{s.has(a.column)?n.push(a):i.push(a.column)}),{validRules:n,invalidColumns:i}}function _s(e,r){if(!e||!e.levels||e.levels.length===0)return{validGrouping:null,invalidColumns:[]};const n=new Set(r.map(a=>a.name)),i=[],s=[];return e.levels.forEach(a=>{n.has(a.column)?i.push(a):s.push(a.column)}),i.length===0?{validGrouping:null,invalidColumns:s}:{validGrouping:{...e,levels:i},invalidColumns:s}}function kl(e,r){const n=[],i=new Set(r.map(a=>a.name)),s={...e};if(s.filters){const a=c=>{const l=c.children.filter(u=>{if(Xe(u))return!0;const g=i.has(u.column);return g||n.push(`Filter for column "${u.column}" ignored (column not found)`),g}).map(u=>Xe(u)?a(u):u).filter(u=>!Xe(u)||u.children.length>0);return{...c,children:l}};s.filters=a(He(s.filters))}if(s.sortStack&&Array.isArray(s.sortStack)){const{validRules:a,invalidColumns:c}=Ds(s.sortStack,r);c.length>0&&n.push(`Sort rules for columns ignored: ${c.join(", ")}`),s.sortStack=a.length>0?a:void 0}if(s.grouping){const{validGrouping:a,invalidColumns:c}=_s(s.grouping,r);c.length>0&&n.push(`Grouping for columns ignored: ${c.join(", ")}`),s.grouping=a}if(s.columnVisibility){const a={};Object.entries(s.columnVisibility).forEach(([c,l])=>{i.has(c)?a[c]=l:n.push(`Column visibility for "${c}" ignored (column not found)`)}),s.columnVisibility=Object.keys(a).length>0?a:void 0}if(s.columnOrder&&Array.isArray(s.columnOrder)){const a=s.columnOrder.filter(c=>{const l=i.has(c);return l||n.push(`Column "${c}" in order ignored (column not found)`),l});s.columnOrder=a.length>0?a:void 0}if(s.columnWidths){const a={};Object.entries(s.columnWidths).forEach(([c,l])=>{i.has(c)?a[c]=l:n.push(`Column width for "${c}" ignored (column not found)`)}),s.columnWidths=Object.keys(a).length>0?a:void 0}return{sanitizedConfig:s,warnings:n}}function zl(e,r){return mr("processing","export",e,{retryAvailable:!!(r!=null&&r.onRetry)})}function Ai(e,r,n,i){const s=jo(e,r,"system","error_occurred",null,{errorType:n.type,errorContext:n.context,errorMessage:n.message,recoverable:n.recoverable,timestamp:n.timestamp});return ko(i||[],s)}function Tl(e){return e==null}function Bl(e,r,n){const{operator:i,value:s}=r;if(i==="NULL")return e==null;if(i==="NOT_NULL")return e!=null;if(Tl(e))return!1;if(n==="date"){const a=new Date(e).getTime(),c=new Date(s).getTime();switch(i){case"equals":return a===c;case"gt":return a>c;case"lt":return a<c;case"gte":return a>=c;case"lte":return a<=c;default:return!0}}switch(i){case"equals":return String(e).toLowerCase()===String(s).toLowerCase();case"contains":return String(e).toLowerCase().includes(String(s).toLowerCase());case"startsWith":return String(e).toLowerCase().startsWith(String(s).toLowerCase());case"endsWith":return String(e).toLowerCase().endsWith(String(s).toLowerCase());case"gt":return Number(e)>Number(s);case"lt":return Number(e)<Number(s);case"gte":return Number(e)>=Number(s);case"lte":return Number(e)<=Number(s);case"isTrue":return e===!0;case"isFalse":return e===!1;default:return!0}}function ti(e,r,n){var s;if(Xe(r))return r.children.length===0?!0:r.operator==="and"?r.children.every(a=>ti(e,a,n)):r.children.some(a=>ti(e,a,n));const i=((s=n.find(a=>a.name===r.column))==null?void 0:s.type)??"string";return Bl(e[r.column],r,i)}function Il(e,r,n){return!r||r.children.length===0?e:e.filter(i=>ti(i,r,n))}function nn(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"date":return[{value:"equals",label:"Is"},{value:"gt",label:"After"},{value:"lt",label:"Before"},{value:"gte",label:"On or after"},{value:"lte",label:"On or before"},{value:"NULL",label:"Is NULL"},{value:"NOT_NULL",label:"Is NOT NULL"}];case"mixed":case"null":case"array":case"object":default:return[]}}function El(e){return e!=="isTrue"&&e!=="isFalse"&&e!=="NULL"&&e!=="NOT_NULL"}function Dl({data:e,filters:r,schema:n}){return{filteredData:p.useMemo(()=>!r||r.children.length===0?e:Il(e,r,n),[e,r,n])}}function _l(e,r,n,i){if(!n||n.trim()==="")return e;const s=n.toLowerCase().trim(),a=r.filter(c=>i.includes(c.name));return e.filter(c=>a.some(l=>{const u=c[l.name];return u==null?!1:String(u).toLowerCase().includes(s)}))}function $l({data:e,searchQuery:r,schema:n,visibleColumns:i,mode:s="client"}){return{searchedData:p.useMemo(()=>s==="server"||!r||r.trim()===""?e:_l(e,n,r,i),[e,r,n,i,s])}}function Ol({data:e,sortStack:r,schema:n}){return{sortedData:p.useMemo(()=>!r||r.length===0?e:Aa(e,n,r),[e,r,n])}}function Ml({data:e,grouping:r,schema:n}){const i=p.useMemo(()=>!r||!r.enabled||r.levels.length===0?e:La(e,n,r),[e,r,n]),s=(r==null?void 0:r.enabled)&&((r==null?void 0:r.levels.length)||0)>0;return{groupedData:i,isGrouped:s}}function Al({schema:e,columnVisibility:r,columnOrder:n}){const i=p.useMemo(()=>n.filter(l=>r[l]!==!1),[n,r]),s=p.useMemo(()=>Object.entries(r).filter(([l,u])=>!u).map(([l,u])=>l),[r]),a=p.useMemo(()=>n.map(l=>e.find(g=>g.name===l)||{name:l,type:"string"}),[n,e]),c=p.useMemo(()=>i.map(l=>e.find(g=>g.name===l)||{name:l,type:"string"}),[i,e]);return{visibleColumns:i,hiddenColumns:s,allColumns:a,visibleColumnSchemas:c,hiddenCount:s.length}}function Wl({views:e,activeViewId:r,currentState:n}){const i=p.useMemo(()=>e.find(g=>g.id===r),[e,r]),s=p.useMemo(()=>i?Ua(n,i.snapshot):!1,[i,n]),a=p.useMemo(()=>e.find(g=>g.isDefault),[e]),c=p.useMemo(()=>e.filter(g=>!g.isDefault&&!g.isDeleted),[e]),l=p.useMemo(()=>e.filter(g=>g.isFavorite&&!g.isDeleted),[e]),u=p.useMemo(()=>e.filter(g=>g.isDeleted),[e]);return{activeView:i,isDirty:s,defaultView:a,customViews:c,favoriteViews:l,deletedViews:u,isDefaultView:(i==null?void 0:i.isDefault)||!1}}function Rl(e,r,n){if(!e||e.length===0)return[];if(r<=0)return e.slice(0,n);const i=e.slice(r,n);if(i.length===0)return[];const s=i[0],a=!!(s.__isGroupHeader||s.isGroupHeader),c=a?s.groupLevel??0:s.__urm_group_level__??0;if(c===0&&a)return i;const l=c-1;if(l<0)return i;const u={};let g=l+1;for(let f=r-1;f>=0;f--){const S=e[f];if(S.__isGroupHeader||S.isGroupHeader){const C=S.groupLevel??0;if(C<=l&&u[C]===void 0&&(u[C]=S,g--,g<=0))break}}const x=[];for(let f=0;f<=l;f++)u[f]&&x.push({...u[f],__urm_is_continuation_header__:!0});return[...x,...i]}function Pl({data:e,enabled:r=!1,pageSize:n=100,initialPage:i=1}){const[s,a]=p.useState(i),c=e.length,l=Math.max(1,Math.ceil(c/n));p.useEffect(()=>{s>l&&a(l)},[s,l]);const u=p.useMemo(()=>{if(!r)return e;const C=(s-1)*n,B=C+n;return Rl(e,C,B)},[e,r,s,n]),g=p.useCallback(C=>{const B=Math.max(1,Math.min(C,l));a(B)},[l]),x=p.useCallback(()=>{s<l&&a(C=>Math.min(C+1,l))},[l]),f=p.useCallback(()=>{s>1&&a(C=>Math.max(C-1,1))},[]),S=p.useCallback(()=>{a(1)},[]);return{paginatedData:u,currentPage:s,totalPages:l,pageSize:n,totalRows:c,goToPage:g,nextPage:x,prevPage:f,resetPage:S,hasNextPage:s<l,hasPrevPage:s>1}}function Nl(e){const{rawData:r,schema:n,filters:i,sortStack:s,grouping:a,searchQuery:c,searchMode:l,columnVisibility:u,columnOrder:g,columnWidths:x,views:f,activeViewId:S,pagination:C}=e,B=p.useMemo(()=>({filters:i,sortStack:s,grouping:a,columnVisibility:u,columnOrder:g,columnWidths:x}),[i,s,a,u,g,x]),v=Wl({views:f,activeViewId:S,currentState:B}),m=Al({schema:n,columnVisibility:u,columnOrder:g}),{filteredData:T}=Dl({data:r,filters:i,schema:n}),{sortedData:h}=Ol({data:T,sortStack:s,schema:n}),{groupedData:z,isGrouped:I}=Ml({data:h,grouping:a,schema:n}),{searchedData:b}=$l({data:z,searchQuery:c,schema:n,visibleColumns:m.visibleColumns,mode:l}),R=Pl({data:b,enabled:(C==null?void 0:C.enabled)||!1,pageSize:(C==null?void 0:C.pageSize)||100,initialPage:(C==null?void 0:C.currentPage)||1}),H=C!=null&&C.enabled?R.paginatedData:b,E=p.useMemo(()=>({totalRows:r.length,filteredRows:T.length,sortedRows:h.length,groupedRows:I?z.length:h.length,searchedRows:b.length,visibleRows:H.length,hiddenColumns:m.hiddenCount,activeFilters:Tt(i),activeSorts:s.length,isGrouped:I}),[r.length,T.length,h.length,z.length,b.length,H.length,m.hiddenCount,i,s.length,I]);return{data:H,filteredData:T,sortedData:h,groupedData:z,searchedData:b,viewEngine:v,columnEngine:m,paginationEngine:R,metrics:E,isGrouped:I,isPaginated:(C==null?void 0:C.enabled)||!1}}let Ll=0;function Fl(e,r){e!==null&&e.__urm_row_id__===void 0&&Object.defineProperty(e,"__urm_row_id__",{value:r?r(e):Ll++,writable:!1,enumerable:!1,configurable:!1})}const Mt="user-demo-001";function Vl(e={}){var Vo,vi,Si,Ci,wi;const{mode:r="builder",autoLoad:n=!0,initialData:i,dataSource:s,pagination:a,search:c,scheduler:l,reportName:u,reportId:g,sharedReportId:x,sharedViewId:f,viewPersistence:S,permissions:C,config:B={}}=e,v=(S==null?void 0:S.mode)??"local",m=(a==null?void 0:a.mode)??"client",T=(c==null?void 0:c.mode)??"client",[h,z]=p.useState([]),I=gr(),[b,R]=p.useState(""),[H,E]=p.useState(!1),[G,Z]=p.useState(!1),[O,y]=p.useState({message:"",severity:"info",open:!1}),w=(k,D="info")=>{y({message:k,severity:D,open:!0})},P=()=>y(k=>({...k,open:!1})),te=B.notifDurationMs??2e3,d=h.find(k=>k.id===b),[J,re]=p.useState("idle"),[Se,F]=p.useState(!1),[X,ue]=p.useState(!1),[pe,K]=p.useState(!1),[he,ae]=p.useState(!1),[W,ie]=p.useState(!1),[U,ne]=p.useState(void 0),[ke,Q]=p.useState(null),[De,We]=p.useState(null),[Wt,Yt]=p.useState(!1),[_r,Rt]=p.useState(!1),[ht,bt]=p.useState(null),[$r,Qe]=p.useState(!1),[Et,qt]=p.useState(!1),[Pt,ir]=p.useState({enabled:!1,levels:[],collapsedGroups:[]}),[sr,Or]=p.useState(""),[Jt,br]=p.useState(""),[vt,Je]=p.useState(new Set),[vr,it]=p.useState(1),[rt,Nt]=p.useState(15),[ar,co]=p.useState(!1),[Mr,lr]=p.useState(!1),[Ke,Ce]=p.useState(!1),[Dt,Sr]=p.useState(null),[Ar,cr]=p.useState(!1),[Cr,Wr]=p.useState(null),[dr,Ze]=p.useState(null),Lt=p.useRef(null),ve=p.useMemo(()=>d?rl(d.permissions,Mt):"owner",[d]),$o=ol(ve),fe=p.useMemo(()=>!(d!=null&&d.uploadedData)||!(d!=null&&d.schema)?{totalRows:0,totalColumns:0}:bl(d.uploadedData,d.schema),[d==null?void 0:d.uploadedData,d==null?void 0:d.schema]),St=p.useCallback(()=>{d&&(Lt.current=Cl(d))},[d]),V=p.useCallback((k,D)=>{z(A=>A.map(M=>M.id===k?{...M,...D}:M))},[]),ft=p.useCallback(k=>{if(!d)return;Ze(k);const D=Ai(d.id,Mt,k,d.auditHistory||[]);V(d.id,{auditHistory:D}),w(k.message,"error"),k.recoverable&&Lt.current&&setTimeout(()=>{wl(d,Lt.current,V),w("Previous state restored","success")},100)},[d,V]),se=p.useCallback((k,D,A,M)=>{if(!d)return;const Y=jo(d.id,Mt,k,D,A,M),q=d.auditHistory||[],ce=ko(q,Y);setTimeout(()=>{V(d.id,{auditHistory:ce})},0)},[d,V]);p.useEffect(()=>{if(d!=null&&d.schemaLocked&&d.schema&&(!d.views||d.views.length===0)){const k=Fn(d.schema);(()=>{try{const D=localStorage.getItem("urm_dev_config");return D?JSON.parse(D):null}catch{return null}})(),V(d.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})}},[d==null?void 0:d.schemaLocked,d==null?void 0:d.schema,d==null?void 0:d.id,V]),p.useEffect(()=>{if(i&&n&&!G&&h.length===0){const k=io(i),D={id:g||`auto-report-${Date.now()}`,name:u||(r==="viewer"?"Data View":"Imported Data"),description:"Auto-generated from external data",schemaLocked:!0,uploadedData:k,schema:zi(xo(k),B.hiddenColumns),permissions:C??{owner:Mt,editors:[],viewers:[]}};z([D]),R(D.id),Z(!0),re("confirmed")}},[i,n,G,h.length,r,u,g]),p.useEffect(()=>{m!=="server"||!G||!b||V(b,{uploadedData:io(i||[])})},[i,m,G,b]),p.useEffect(()=>{m==="server"&&((a==null?void 0:a.page)!==void 0&&it(a.page),(a==null?void 0:a.pageSize)!==void 0&&Nt(a.pageSize))},[a==null?void 0:a.page,a==null?void 0:a.pageSize,m]),p.useEffect(()=>{if(!s||G)return;let k=!1,D=null;const A=async()=>{try{re("uploading");let M;if(s.type==="api"){const q=await fetch(s.url,{headers:s.headers||{}});if(!q.ok)throw new Error(`HTTP ${q.status}: ${q.statusText}`);M=await q.json()}else M=await s.fetch();if(k)return;if(!Array.isArray(M))throw new Error("Data source must return an array of objects");const Y=xo(M);if(G)z(q=>q.map(ce=>ce.id===b?{...ce,uploadedData:io(M)}:ce)),re("confirmed");else{const q={id:g||`auto-report-${Date.now()}`,name:u||(r==="viewer"?"Data View":"Imported Data"),description:`Loaded from ${s.type==="api"?s.url:"callback"}`,schemaLocked:!0,uploadedData:io(M),schema:zi(xo(io(M)),B.hiddenColumns),permissions:C??{owner:Mt,editors:[],viewers:[]}};z([q]),R(q.id),Z(!0),re("confirmed")}}catch(M){k||(re("error"),d&&V(d.id,{uploadError:(M==null?void 0:M.message)||"Failed to load data from source"}))}};return A(),s.refreshInterval&&s.refreshInterval>0&&(D=setInterval(A,s.refreshInterval)),()=>{k=!0,D&&clearInterval(D)}},[s,u,r,g]);const st=(Vo=d==null?void 0:d.views)==null?void 0:Vo.find(k=>k.id===d.activeViewId),wr=p.useMemo(()=>d!=null&&d.uploadedData?(d.uploadedData.forEach(k=>Fl(k,B.getRowId)),d.uploadedData):[],[d==null?void 0:d.uploadedData]);p.useEffect(()=>{Je(k=>{if(k.size===0)return k;const D=new Set(wr.map(M=>M==null?void 0:M.__urm_row_id__)),A=new Set(Array.from(k).filter(M=>D.has(M==null?void 0:M.__urm_row_id__)));return A.size===k.size?k:A})},[wr]);const Ct=Nl({rawData:wr,schema:(d==null?void 0:d.schema)||[],filters:He(d==null?void 0:d.filters),sortStack:(d==null?void 0:d.sortStack)||[],grouping:(d==null?void 0:d.grouping)||null,searchQuery:Jt||"",searchMode:T,columnVisibility:(d==null?void 0:d.columnVisibility)||(st==null?void 0:st.snapshot.columnVisibility)||{},columnOrder:(d==null?void 0:d.columnOrder)||(st==null?void 0:st.snapshot.columnOrder)||[],columnWidths:(d==null?void 0:d.columnWidths)||(st==null?void 0:st.snapshot.columnWidths)||{},views:(d==null?void 0:d.views)||[],activeViewId:(d==null?void 0:d.activeViewId)||"",pagination:{enabled:m==="client",pageSize:rt,currentPage:vr}}),{data:Rr=[],searchedData:ur=[],groupedData:jr=[],sortedData:Ft=[],metrics:kr={totalRows:0,searchedRows:0,isGrouped:!1},isGrouped:Pr=!1,paginationEngine:_e}=Ct||{},ut=m==="server"?(a==null?void 0:a.totalRows)??0:kr.searchedRows,ee=((vi=Ct.viewEngine)==null?void 0:vi.activeView)||st,le=((Si=Ct.viewEngine)==null?void 0:Si.isDirty)||!1;p.useEffect(()=>{if(!(!ee||!d)&&!d.columnOrder){const k=ee.snapshot.columnOrder,D=vo(k,ee.snapshot.grouping);V(d.id,{columnOrder:D})}},[d==null?void 0:d.activeViewId]);const ye=p.useMemo(()=>!(d!=null&&d.schema)||!ee?null:Ha(d.filters,d.sortStack||[],d.schema,d.columnVisibility,d.columnOrder,d.columnWidths,d.grouping,ee.snapshot.columnOrder),[d==null?void 0:d.filters,d==null?void 0:d.sortStack,d==null?void 0:d.schema,d==null?void 0:d.columnVisibility,d==null?void 0:d.columnOrder,d==null?void 0:d.columnWidths,d==null?void 0:d.grouping,ee]),uo=p.useMemo(()=>!ee||!ye||!le?[]:Ya(ye,ee.snapshot),[ee,ye,le]),Nr=p.useCallback((k,D,A)=>{const M={id:`report-${Date.now()}`,name:k,description:D,schemaLocked:!1,permissions:{owner:Mt,editors:[],viewers:[]}};if(A&&Array.isArray(A)&&A.length>0){const Y=xo(A),q=Fn(Y);M.uploadedData=A,M.schema=Y,M.schemaLocked=!0,M.views=[q],M.activeViewId=q.id,M.sortStack=q.snapshot.sortStack,M.filters=q.snapshot.filters,M.columnVisibility=q.snapshot.columnVisibility,M.columnOrder=q.snapshot.columnOrder,M.columnWidths=q.snapshot.columnWidths,M.grouping=q.snapshot.grouping}z(Y=>[...Y,M]),R(M.id),E(!1),re("confirmed")},[]),pr=p.useCallback(k=>{d&&(re("uploading"),setTimeout(()=>{const D=xo(k);V(d.id,{uploadedData:k,schema:D,uploadError:void 0}),re("preview")},500))},[d,V]),Lr=p.useCallback(k=>{d&&(V(d.id,{uploadError:k}),re("idle"))},[d,V]),po=p.useCallback(()=>{d&&(V(d.id,{uploadError:void 0,uploadedData:void 0,schema:void 0}),re("idle"))},[d,V]),Fr=p.useCallback(()=>{d&&(V(d.id,{schemaLocked:!0}),re("confirmed"))},[d,V]),Kt=p.useCallback(k=>{if(!d)return;if(!jt("edit_sorting",ve)){w(kt("edit_sorting"),"error");return}const D=d.sortStack??[],A=D.find(M=>M.column===k);if(A){const M=Wa(A.direction);if(M===null){const Y=D.filter(q=>q.column!==k).map((q,ce)=>({...q,priority:ce+1}));se("sorting","sort_level_removed",A,null),V(d.id,{sortStack:Y.length>0?Y:void 0})}else{const Y=M,q=D.map(ce=>ce.column===k?{...ce,direction:Y}:ce);se("sorting","sort_reordered",{column:k,direction:A.direction},{column:k,direction:Y}),V(d.id,{sortStack:q})}}else{if(D.length>=I.sort.maxLevels){w(`Sort limit reached — maximum ${I.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const M={column:k,direction:"asc",priority:D.length+1};se("sorting","sort_level_added",null,M),V(d.id,{sortStack:[...D,M]})}},[d,ve,V,se]),Vr=p.useCallback(k=>{if(!d)return;const D=d.sortStack??[],A=k.length===0?"sort_cleared":"sort_reordered";if(d.schema){const{validRules:M,invalidColumns:Y}=Ds(k,d.schema);Y.length>0&&w(`Removed invalid sort columns: ${Y.join(", ")}`),St();try{se("sorting",A,D,M.length>0?M:null),V(d.id,{sortStack:M.length>0?M:void 0})}catch(q){const ce=mr("processing","sorting",q);ft(ce)}}else se("sorting",A,D,k.length>0?k:null),V(d.id,{sortStack:k.length>0?k:void 0})},[d,V,St,ft,se]),Hr=p.useCallback(k=>{if(!d)return;const D=d.sortStack??[],A=D.find(M=>M.column===k);if(!(A&&A.direction==="asc"))if(A){const M=D.map(Y=>Y.column===k?{...Y,direction:"asc"}:Y);se("sorting","sort_reordered",{column:k,direction:A.direction},{column:k,direction:"asc"}),V(d.id,{sortStack:M})}else{if(D.length>=I.sort.maxLevels){w(`Sort limit reached — maximum ${I.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const M={column:k,direction:"asc",priority:D.length+1};se("sorting","sort_level_added",null,M),V(d.id,{sortStack:[...D,M]})}},[d,V,se]),_t=p.useCallback(k=>{if(!d)return;const D=d.sortStack??[],A=D.find(M=>M.column===k);if(!(A&&A.direction==="desc"))if(A){const M=D.map(Y=>Y.column===k?{...Y,direction:"desc"}:Y);se("sorting","sort_reordered",{column:k,direction:A.direction},{column:k,direction:"desc"}),V(d.id,{sortStack:M})}else{if(D.length>=I.sort.maxLevels){w(`Sort limit reached — maximum ${I.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const M={column:k,direction:"desc",priority:D.length+1};se("sorting","sort_level_added",null,M),V(d.id,{sortStack:[...D,M]})}},[d,V,se]),je=p.useCallback((k,D)=>{var M;if(!d)return;if(!jt("edit_filters",ve)){w(kt("edit_filters"),"error");return}const A=(M=d.schema)==null?void 0:M.find(Y=>Y.name===D.column);if(A&&D.value!==void 0){const Y=jl(A.type,D.operator,D.value);if(!Y.isValid){w(Y.errorMessage||"Invalid filter value","error");return}}St();try{const Y=He(d.filters),q={...D,id:ao()},ce=lo(Y,k,q);se("filters","filter_added",null,q),V(d.id,{filters:ce})}catch(Y){const q=mr("processing","filters",Y);ft(q)}},[d,ve,V,St,ft,se]),Ge=p.useCallback(k=>{if(!d)return;if(!jt("edit_filters",ve)){w(kt("edit_filters"),"error");return}const D=He(d.filters),A=lo(D,k,At());se("filters","filter_added",null,"a condition group"),V(d.id,{filters:A})},[d,ve,V,se]),zr=p.useCallback((k,D)=>{if(!d)return;if(!jt("edit_filters",ve)){w(kt("edit_filters"),"error");return}const A=He(d.filters),M=Qo(A,k),Y=li(A,k,D),q=Qo(Y,k);se("filters","filter_updated",M,q),V(d.id,{filters:Y})},[d,ve,V,se]),at=p.useCallback((k,D)=>{if(!d)return;if(!jt("edit_filters",ve)){w(kt("edit_filters"),"error");return}const A=He(d.filters),M=ci(A,k,D);se("filters","filter_updated",null,`group operator changed to ${D.toUpperCase()}`),V(d.id,{filters:M})},[d,ve,V,se]),Xt=p.useCallback(k=>{if(!d)return;if(!jt("edit_filters",ve)){w(kt("edit_filters"),"error");return}const D=He(d.filters),A=Qo(D,k),M=di(D,k);se("filters","filter_removed",A,null),V(d.id,{filters:M})},[d,ve,V,se]),$t=p.useCallback(()=>{if(!d)return;if(!jt("edit_filters",ve)){w(kt("edit_filters"),"error");return}const k=He(d.filters);se("filters","filter_cleared",{count:Tt(k)},null),V(d.id,{filters:At()})},[d,ve,V,se]),xe=p.useCallback(k=>{if(!d)return;if(!jt("edit_filters",ve)){w(kt("edit_filters"),"error");return}const D=He(d.filters);se("filters","filter_cleared",{count:Tt(D)},{count:Tt(k)}),V(d.id,{filters:k})},[d,ve,V,se]),me=p.useCallback(k=>{var Y;if(!d)return;const D=(Y=d.views)==null?void 0:Y.find(q=>q.id===k);if(!D)return;const A=D.snapshot.columnOrder,M=vo(A,D.snapshot.grouping);se("views","view_switched",{previousViewId:d.activeViewId},{viewId:k,name:D.name}),V(d.id,{filters:D.snapshot.filters,sortStack:D.snapshot.sortStack.length>0?[...D.snapshot.sortStack]:void 0,columnVisibility:{...D.snapshot.columnVisibility},columnOrder:M,columnWidths:{...D.snapshot.columnWidths},grouping:D.snapshot.grouping,activeViewId:k}),Je(new Set)},[d,V,se]),Re=p.useCallback((k,D,A)=>{var Ye;if(!(d!=null&&d.schema)||!ye)return;const M=d.views??[],Y=M.filter(Ln=>!Ln.isDeleted).length,q=((Ye=I.views)==null?void 0:Ye.maxViews)??10;if(Y>=q){w(`View limit reached — you can have at most ${q} saved views. Delete an existing view to create a new one.`,"error");return}const ce={id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:k,description:D||void 0,isDefault:A,isFavorite:!1,isDeleted:!1,scope:"personal",createdBy:Mt,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...ye}},we=A?M.map(Ln=>({...Ln,isDefault:!1})):M;se("views","view_created",null,{viewId:ce.id,name:k,isDefault:A}),V(d.id,{views:[...we,ce],activeViewId:ce.id}),w(`"${k}" view created`,"success")},[d,ye,V,se]),Ne=p.useCallback(k=>{var ce;if(!(d!=null&&d.views))return;const D=d.views.find(we=>we.id===k);if(!D)return;const A=d.views,M=A.filter(we=>!we.isDeleted).length,Y=((ce=I.views)==null?void 0:ce.maxViews)??10;if(M>=Y){w(`View limit reached — you can have at most ${Y} saved views. Delete an existing view to create a new one.`,"error");return}const q={...D,id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:`${D.name} (copy)`,scope:"personal",isDefault:!1,isFavorite:!1,isDeleted:!1,createdBy:Mt,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...D.snapshot}};V(d.id,{views:[...A,q]}),w(`"${q.name}" created`,"success")},[d,I,V]),et=p.useCallback(()=>{var D;if(!ee||!ye||!d)return;const k=(D=d.views)==null?void 0:D.map(A=>A.id===ee.id?{...A,snapshot:{...ye}}:A);V(d.id,{views:k}),w(`"${ee.name}" view updated`,"success")},[ee,ye,d,V]),wt=p.useCallback(k=>{var M;if(!ee||!ye||!d)return;const D=k??ye.columnWidths,A=(M=d.views)==null?void 0:M.map(Y=>Y.id===ee.id?{...Y,snapshot:{...Y.snapshot,columnVisibility:ye.columnVisibility,columnOrder:ye.columnOrder,columnWidths:D},updatedAt:Date.now()}:Y);V(d.id,{views:A,columnWidths:D}),w(`Column configuration saved to "${ee.name}"`,"success")},[ee,ye,d,V]),Ot=p.useCallback(k=>{var q,ce;if(!ye||!d||!ee)return;const D=k??ye.columnWidths,A={...ee,snapshot:{...ee.snapshot,columnVisibility:ye.columnVisibility,columnOrder:ye.columnOrder,columnWidths:D},updatedAt:Date.now()},M=(q=d.views)==null?void 0:q.map(we=>we.id===ee.id?A:{...we,snapshot:{...we.snapshot,columnVisibility:ye.columnVisibility,columnOrder:ye.columnOrder,columnWidths:D},updatedAt:Date.now()});V(d.id,{views:M,columnWidths:D});const Y=(((ce=d.views)==null?void 0:ce.length)||0)-1;w(`Column configuration saved to current view and ${Y} other view${Y===1?"":"s"}`,"success")},[ye,d,ee,V]),Oo=p.useCallback(()=>{K(!0)},[]),Ur=p.useCallback(()=>{if(!ee||!d)return;const k=ee.snapshot.columnOrder,D=vo(k,ee.snapshot.grouping);V(d.id,{filters:ee.snapshot.filters,sortStack:ee.snapshot.sortStack.length>0?[...ee.snapshot.sortStack]:void 0,columnVisibility:{...ee.snapshot.columnVisibility},columnOrder:D,columnWidths:{...ee.snapshot.columnWidths},grouping:ee.snapshot.grouping}),w("Changes reverted to last saved state","success")},[ee,d,V]),Tn=p.useCallback(k=>{if(!(d!=null&&d.views))return;const D=d.views.map(M=>({...M,isDefault:M.id===k}));V(d.id,{views:D});const A=d.views.find(M=>M.id===k);A&&w(`"${A.name}" set as default view`,"success")},[d,V]),Gr=p.useCallback(k=>{if(!(d!=null&&d.views))return;const D=d.views.map(M=>M.id===k?{...M,isFavorite:!M.isFavorite,updatedAt:Date.now()}:M);V(d.id,{views:D});const A=d.views.find(M=>M.id===k);A&&!A.isFavorite?w(`"${A.name}" added to favorites`,"success"):A&&w(`"${A.name}" removed from favorites`,"info")},[d,V]),ho=p.useCallback(k=>{if(!(d!=null&&d.views))return;const D=d.views.find(Ye=>Ye.id===k),A=d.views.filter(Ye=>!Ye.isDeleted||Ye.id===k);if((D==null?void 0:D.isDefault)&&A.filter(Ye=>Ye.isDefault).length===1){w("Cannot delete the last default view","error");return}const Y=d.views.map(Ye=>Ye.id===k?{...Ye,isDeleted:!0,updatedAt:Date.now()}:Ye),q=d.activeViewId===k,ce=Y.find(Ye=>Ye.isDefault&&!Ye.isDeleted);V(d.id,{views:Y,activeViewId:q&&ce?ce.id:d.activeViewId,filters:q&&ce?ce.snapshot.filters:d.filters,sortStack:q&&ce?ce.snapshot.sortStack.length>0?ce.snapshot.sortStack:void 0:d.sortStack});const we=d.views.find(Ye=>Ye.id===k);we&&w(`"${we.name}" moved to Recently Deleted`,"info")},[d,V]),Bn=p.useCallback(k=>{if(!(d!=null&&d.views))return;const D=d.views.map(M=>M.id===k?{...M,isDeleted:!1,updatedAt:Date.now()}:M);V(d.id,{views:D});const A=d.views.find(M=>M.id===k);A&&w(`"${A.name}" restored`,"success")},[d,V]),Mo=p.useCallback(k=>{if(!(d!=null&&d.views))return;const D=d.views.find(we=>we.id===k),A=d.views.filter(we=>!we.isDeleted||we.id===k);if((D==null?void 0:D.isDefault)&&A.filter(we=>we.isDefault).length===1){w("Cannot delete the last default view","error");return}const Y=d.views.filter(we=>we.id!==k),q=d.activeViewId===k,ce=Y.find(we=>we.isDefault&&!we.isDeleted);V(d.id,{views:Y,activeViewId:q&&ce?ce.id:d.activeViewId,filters:q&&ce?ce.snapshot.filters:d.filters,sortStack:q&&ce?ce.snapshot.sortStack.length>0?ce.snapshot.sortStack:void 0:d.sortStack}),D&&w(`"${D.name}" permanently deleted`,"success")},[d,V]),Yr=p.useCallback(k=>{Q(k),ae(!0)},[]),Ao=p.useCallback(async k=>{if(!d)return;const D=new URLSearchParams(window.location.search);D.set("reportId",d.id),D.set("view",k);const A=`${window.location.origin}${window.location.pathname}?${D.toString()}`,M=await yl(A);w(M?"Link copied to clipboard":"Failed to copy link",M?"success":"error")},[d]),qr=p.useCallback((k,D)=>{if(!ke||!(d!=null&&d.views))return;const A=d.views.map(M=>M.id===ke?{...M,name:k,description:D||void 0}:M);V(d.id,{views:A}),Q(null)},[ke,d,V]),fo=p.useCallback(k=>{We(k),ie(!0)},[]),Wo=p.useCallback(()=>{if(!De||!(d!=null&&d.views))return;const k=d.views.find(Y=>Y.id===De),D=d.views.filter(Y=>Y.id!==De),A=d.activeViewId===De,M=D.find(Y=>Y.isDefault);se("views","view_deleted",{viewId:De,name:k==null?void 0:k.name},null),V(d.id,{views:D,activeViewId:A&&M?M.id:d.activeViewId,filters:A&&M?M.snapshot.filters:d.filters,sortStack:A&&M?M.snapshot.sortStack.length>0?M.snapshot.sortStack:void 0:d.sortStack}),We(null),ie(!1)},[De,d,V,se]),Jr=p.useCallback(k=>{var Y;if(!(d!=null&&d.views))return;if(!(((Y=I.views)==null?void 0:Y.isAdmin)??!1)){w("Only administrators can promote views to Global.","error");return}const A=d.views.find(q=>q.id===k);if(!A)return;if(A.scope==="global"){w(`"${A.name}" is already a Global View.`,"info");return}const M=d.views.map(q=>q.id===k?{...q,scope:"global",isDefault:!0,updatedAt:Date.now()}:q.scope==="global"&&q.isDefault?{...q,isDefault:!1}:q);V(d.id,{views:M}),w(`"${A.name}" promoted to Global View and set as default.`,"success")},[d,I,V]),Kr=p.useCallback((k,D)=>{if(!(d!=null&&d.views))return;const A=d.views.find(q=>q.id===k);if(!A)return;const M=d.views.map(q=>q.id===k?{...q,isDefaultForAllUsers:D,updatedAt:Date.now()}:D&&q.isDefaultForAllUsers?{...q,isDefaultForAllUsers:!1}:q);se("views",D?"view_set_default":"view_updated",{viewId:k,isDefaultForAllUsers:!D},{viewId:k,isDefaultForAllUsers:D}),V(d.id,{views:M}),w(`"${A.name}" ${D?"set as":"removed from"} default for all users.`,"success")},[d,V,se]),Qt=p.useRef(!0);p.useEffect(()=>{var k;if(Qt.current){Qt.current=!1;return}if(m==="server"){it(1),(k=a==null?void 0:a.onPaginationChange)==null||k.call(a,1,rt);return}_e!=null&&_e.resetPage?_e.resetPage():it(1)},[d==null?void 0:d.filters,Jt,d==null?void 0:d.activeViewId,d==null?void 0:d.grouping]);const Ro=p.useCallback(k=>{var D;if(m==="server"){it(k),(D=a==null?void 0:a.onPaginationChange)==null||D.call(a,k,rt);return}_e!=null&&_e.goToPage&&_e.goToPage(k),it(k)},[m,a,rt,_e]),Xr=p.useCallback(k=>{var M;const D=(vr-1)*rt,A=Math.floor(D/k)+1;if(m==="server"){Nt(k),it(A),(M=a==null?void 0:a.onPaginationChange)==null||M.call(a,A,k);return}Nt(k),it(A),_e==null||_e.goToPage(A)},[vr,rt,m,a,_e]),In=p.useCallback((k,D)=>{if(!d)return;if(!jt("edit_columns",ve)){w(kt("edit_columns"),"error");return}const M={...d.columnVisibility||(ee==null?void 0:ee.snapshot.columnVisibility)||{},[k]:D};se("columns",D?"column_shown":"column_hidden",{columnName:k,visible:!D},{columnName:k,visible:D}),V(d.id,{columnVisibility:M})},[d,ee,ve,V,se]),En=p.useCallback(k=>{if(d){if(!jt("edit_columns",ve)){w(kt("edit_columns"),"error");return}se("columns","column_reordered",d.columnOrder,k),V(d.id,{columnOrder:k})}},[d,ve,V,se]),Dn=p.useCallback((k,D)=>{if(!d)return;if(!jt("edit_columns",ve)){w(kt("edit_columns"),"error");return}const A=d.columnWidths||(ee==null?void 0:ee.snapshot.columnWidths)||{},M={...A,[k]:D};se("columns","column_resized",{columnName:k,width:A[k]},{columnName:k,width:D}),V(d.id,{columnWidths:M})},[d,ee,ve,V,se]),_n=p.useCallback(k=>{if(!d)return;const D=He(d.filters),A=Bs(D,k);V(d.id,{filters:A})},[d,V]),$n=p.useCallback(()=>{if(!ee||!(d!=null&&d.schema))return;const k={},D=[],A={};d.schema.forEach(M=>{k[M.name]=!0,D.push(M.name),A[M.name]=170}),V(d.id,{columnVisibility:k,columnOrder:D,columnWidths:A,filters:void 0,sortStack:void 0}),w("Reset to default layout - all filters and sorts cleared","success")},[ee,d,V]);p.useEffect(()=>{const k=setTimeout(()=>br(sr),300);return()=>clearTimeout(k)},[sr]),p.useEffect(()=>{var k;T==="server"&&((k=c==null?void 0:c.onSearchChange)==null||k.call(c,Jt))},[Jt,T,c]);const On=p.useCallback(k=>{Or(k),it(1)},[]),Mn=p.useCallback(k=>{if(!k.trim()||!d)return;const D=d.searchHistory||[],A=Xa(D,k);V(d.id,{searchHistory:A})},[d,V]),An=p.useCallback(k=>{if(!d)return;const D=d.searchHistory||[],A=Qa(D,k);V(d.id,{searchHistory:A})},[d,V]),Wn=p.useCallback(k=>{if(!d)return;const D=d.searchHistory||[],A=Za(D,k);V(d.id,{searchHistory:A})},[d,V]);p.useEffect(()=>{if(!B.onSelectionChange)return;const k=Array.from(vt);B.onSelectionChange(k,k.map(D=>D==null?void 0:D.__urm_row_id__))},[vt,B.onSelectionChange]);const Qr=p.useCallback(k=>{const D=k==null?void 0:k.__urm_row_id__;Je(A=>{const M=new Set(A);if(D!==void 0){const Y=Array.from(M).find(q=>(q==null?void 0:q.__urm_row_id__)===D);Y!==void 0?M.delete(Y):M.add(k)}else{const Y=JSON.stringify(k),q=Array.from(M).find(ce=>JSON.stringify(ce)===Y);q!==void 0?M.delete(q):M.add(k)}return M})},[]),Zt=p.useCallback((k,D)=>{Je(A=>{const M=new Set(A);for(const Y of D)k?M.add(Y):M.delete(Y);return M})},[]),Rn=p.useCallback((k,D,A)=>{Je(M=>{const Y=new Set(M),q=Math.min(k,D),ce=Math.max(k,D);for(let we=q;we<=ce;we++)A[we]!==void 0&&Y.add(A[we]);return Y})},[]),Pn=p.useCallback(()=>{Je(new Set)},[]),Pe=p.useCallback(k=>{const D=k==null?void 0:k.__urm_row_id__;Je(A=>{const M=new Set(A);if(D!==void 0){const Y=Array.from(M).find(q=>(q==null?void 0:q.__urm_row_id__)===D);Y!==void 0&&M.delete(Y)}else M.delete(k);return M})},[]),lt=p.useCallback(k=>{var D,A;if(d){if(!jt("edit_columns",ve)){w(kt("edit_columns"),"error");return}if(k&&d.schema){const{validGrouping:M,invalidColumns:Y}=_s(k,d.schema);Y.length>0&&w(`Removed invalid grouping columns: ${Y.join(", ")}`,"warning"),St();try{const q=d.grouping;M===null?se("grouping","group_cleared",q,null):q?se("grouping","group_reordered",q,M):se("grouping","group_level_added",null,M);const ce=(ee==null?void 0:ee.snapshot.columnOrder)||d.columnOrder||[],we=vo(ce,M),Ye=M.levels.length>0?{...M,collapsedGroups:Bi(Ft,d.schema,M)}:M;V(d.id,{grouping:Ye,columnOrder:we}),it(1),_e==null||_e.resetPage(),m==="server"&&((D=a==null?void 0:a.onPaginationChange)==null||D.call(a,1,rt)),JSON.stringify(we)!==JSON.stringify(d.columnOrder)&&se("columns","column_reordered",d.columnOrder,we),qt(!1)}catch(q){const ce=mr("processing","grouping",q);ft(ce)}}else{const M=d.grouping;se("grouping","group_cleared",M,null);const Y=(ee==null?void 0:ee.snapshot.columnOrder)||d.columnOrder||[];V(d.id,{grouping:k,columnOrder:Y}),it(1),_e==null||_e.resetPage(),m==="server"&&((A=a==null?void 0:a.onPaginationChange)==null||A.call(a,1,rt)),JSON.stringify(Y)!==JSON.stringify(d.columnOrder)&&se("columns","column_reordered",d.columnOrder,Y),qt(!1)}}},[d,ee,ve,V,St,ft,se,Ft]),mo=p.useCallback(k=>{if(!d||!I.grouping.allowCollapse)return;const D=d.grouping;if(!D)return;const A=Fa(D,k);V(d.id,{grouping:A})},[d,I,V]),Po=p.useCallback(()=>{!(d!=null&&d.grouping)||!I.grouping.allowCollapse||V(d.id,{grouping:{...d.grouping,collapsedGroups:[]}})},[d,I,V]),Nn=p.useCallback(()=>{if(!(d!=null&&d.grouping)||!d.schema||!I.grouping.allowCollapse)return;const k=Bi(Ft,d.schema,d.grouping);V(d.id,{grouping:{...d.grouping,collapsedGroups:k}})},[d,Ft,I,V]),er=p.useCallback(()=>{cr(!0)},[]),mt=p.useCallback(k=>{d!=null&&d.schema&&(Yt(!0),setTimeout(()=>{try{let D;k.scope==="visible"?D=ur:D=d.uploadedData||[];let A;k.columnScope==="all"?(A={},(d.schema??[]).forEach(we=>{A[we.name]=!0})):A=d.columnVisibility||(ee==null?void 0:ee.snapshot.columnVisibility)||{};const M=d.columnOrder||(ee==null?void 0:ee.snapshot.columnOrder),Y=en(D,d.schema,He(d.filters),d.sortStack??[],ee,A,M),q=d.name;let ce;switch(k.format){case"csv":tn(Y,q,k),ce="export_csv";break;case"excel":rn(Y,q,k),ce="export_excel";break;case"json":on(Y,q,k),ce="export_json";break;case"pdf":hi(Y,q,k),ce="export_pdf";break}se("export",ce,null,{format:k.format,scope:k.scope,columnScope:k.columnScope,rowCount:D.length,viewName:(ee==null?void 0:ee.name)||"Default View"}),w(`Export completed successfully (${k.format.toUpperCase()})`,"success")}catch(D){const A=zl(D,{onRetry:()=>mt(k)});w(`Export failed: ${A.message}. Click Export to retry.`,"error");const M=Ai(d.id,Mt,A,d.auditHistory||[]);V(d.id,{auditHistory:M}),Gt.error("urm:report-engine","Export failed",D)}finally{Yt(!1)}},500))},[d,ee,ur,V,se]),No=p.useCallback(k=>{if(d!=null&&d.schema){if(le&&ee&&!ee.isDefault){bt(k.format),Rt(!0),cr(!1);return}mt(k),cr(!1)}},[d,ee,le,mt]),Zr=p.useCallback(k=>{mt({format:k,scope:"visible",columnScope:"visible"})},[mt]),Lo=p.useCallback(()=>{ht&&Zr(ht),Rt(!1),bt(null)},[ht,Zr]),Fo=p.useCallback(()=>{et(),ht&&Zr(ht),Rt(!1),bt(null)},[et,ht,Zr]),j=p.useCallback(()=>{Rt(!1),bt(null)},[]),N=p.useCallback(k=>{!(d!=null&&d.schema)||vt.size===0||(Yt(!0),setTimeout(()=>{try{const D=Array.from(vt),A=en(D,d.schema,He(d.filters),d.sortStack??[],ee),M=`${d.name.toLowerCase().replace(/\s+/g,"_")}_selected_export`;switch(k){case"csv":tn(A,M);break;case"excel":rn(A,M);break;case"json":on(A,M);break}w(`Exported ${D.length} selected rows`,"info")}catch(D){w("Export failed. Please try again.","error"),Gt.error("urm:report-engine","Bulk export failed",D)}finally{Yt(!1)}},500))},[d,ee,vt,jr]),oe=p.useCallback((k,D)=>{if(d)try{const A=pl(d),M=hl(k,D,Mt,A),Y=fl(d.presets,M);V(d.id,{presets:Y}),se("presets","preset_created",null,{presetId:M.id,name:M.name}),lr(!1),w(`Preset "${k}" saved successfully`,"success")}catch(A){w(A instanceof Error?A.message:"Failed to create preset","error")}},[d,V,se]),ze=p.useCallback(()=>{Sr(null),w("Exited preset view","info")},[]),Le=p.useCallback(()=>{Ce(!0)},[]),nt=p.useCallback((k,D)=>{if(!d)return;const A=ml(d.presets,k);V(d.id,{presets:A}),se("presets","preset_deleted",{presetId:k,name:D},null),Dt===k&&Sr(null),w(`Preset "${D}" deleted`,"success")},[d,Dt,V,se]);p.useEffect(()=>{if(!x||h.length===0)return;const k=h.find(D=>D.id===x);k&&k.id!==b&&R(k.id)},[x,h,b]);const tt=p.useRef(!1);p.useEffect(()=>{var D;if(!f||tt.current||!d||d.id!==x)return;const k=(D=d.views)==null?void 0:D.find(A=>A.id===f&&!A.isDeleted);k&&me(k.id),tt.current=!0},[f,x,d,me]),p.useEffect(()=>{if(!d)return;const k=xl();if(k&&d.presets&&d.schemaLocked&&d.schema){const D=Mi(d.presets,k);if(D){const{sanitizedConfig:A,warnings:M}=kl(D.config,d.schema);M.length>0&&M.forEach(q=>w(q,"warning"));const Y=gl(A);V(d.id,Y),Sr(k),se("presets","preset_applied",null,{presetId:D.id,name:D.name}),w(`Loaded preset: ${D.name}`,"info")}else w("Preset not found","info")}},[d==null?void 0:d.schemaLocked]);const ge=Dt?Mi(d==null?void 0:d.presets,Dt):void 0;p.useEffect(()=>{var k;d!=null&&d.views&&d.views.length>0&&d.activeViewId&&((k=S==null?void 0:S.onViewsChange)==null||k.call(S,d.views,d.activeViewId),v!=="api"&&qa(d.id,{views:d.views,activeViewId:d.activeViewId}))},[d==null?void 0:d.views,d==null?void 0:d.activeViewId,d==null?void 0:d.id,v,S]),p.useEffect(()=>{if(d!=null&&d.schemaLocked&&d.schema&&(!d.views||d.views.length===0)){const k=v==="api"?S!=null&&S.views&&S.views.length>0?{views:S.views,activeViewId:S.activeViewId??S.views[0].id}:null:Ja(d.id);if(k&&k.views.length>0){const D=k.views.find(A=>A.id===k.activeViewId);if(D)V(d.id,{views:k.views,activeViewId:k.activeViewId,filters:He(D.snapshot.filters),sortStack:D.snapshot.sortStack.length>0?D.snapshot.sortStack:void 0});else{const A=k.views.find(M=>M.isDefault)||Fn(d.schema);V(d.id,{views:k.views,activeViewId:A.id,filters:He(A.snapshot.filters),sortStack:A.snapshot.sortStack.length>0?A.snapshot.sortStack:void 0})}}}},[d==null?void 0:d.schemaLocked,d==null?void 0:d.schema,d==null?void 0:d.id,v,S]);const Vt=p.useCallback(k=>{var M;const D=He(d==null?void 0:d.filters),A=((M=I.filter)==null?void 0:M.maxConditions)??3;if(Tt(D)>=A){w(`Filter limit reached — maximum ${A} filters allowed. Remove an existing filter before adding a new one.`,"warning");return}ne(k),F(!0)},[d,I,w]),tr=p.useCallback(()=>{F(!1),ne(void 0)},[]),Me=(Ci=d==null?void 0:d.views)==null?void 0:Ci.find(k=>k.id===ke),hr=(wi=d==null?void 0:d.views)==null?void 0:wi.find(k=>k.id===De);return{reports:h,activeReport:d,activeReportId:b,setActiveReportId:R,isModalOpen:H,setIsModalOpen:E,createReport:Nr,updateReport:V,uploadState:J,handleFileUpload:pr,handleUploadError:Lr,handleRetry:po,handleConfirm:Fr,paginatedData:Rr,processedData:ur,displayData:jr,tableMetrics:kr,isGrouped:Pr,tableEngine:Ct,activeView:ee,isDirty:le,currentTableState:ye,viewChanges:uo,filters:d==null?void 0:d.filters,showFilterPanel:Se,setShowFilterPanel:F,filterFocusColumn:U,handleAddCondition:je,handleAddGroup:Ge,handleUpdateCondition:zr,handleSetGroupOperator:at,handleRemoveFilterNode:Xt,handleClearAllFilters:$t,handleReplaceFilters:xe,handleOpenFilterForColumn:Vt,handleCloseFilterPanel:tr,handleClearFiltersForColumn:_n,sortStack:d==null?void 0:d.sortStack,showSortPanel:X,setShowSortPanel:ue,handleSort:Kt,handleUpdateSortStack:Vr,handleSortAscending:Hr,handleSortDescending:_t,views:d==null?void 0:d.views,showCreateViewModal:pe,setShowCreateViewModal:K,showEditViewModal:he,setShowEditViewModal:ae,showDeleteConfirmation:W,setShowDeleteConfirmation:ie,editingView:Me,deletingView:hr,editingViewId:ke,deletingViewId:De,handleSelectView:me,handleCreateView:Re,handleCloneView:Ne,handleUpdateCurrentView:et,handleSaveColumnConfigToCurrentView:wt,handleSaveColumnConfigToAllViews:Ot,handleSaveAsNewView:Oo,handleRevertChanges:Ur,handleToggleDefault:Tn,handleToggleFavorite:Gr,handleSoftDelete:ho,handleRestoreView:Bn,handlePermanentDelete:Mo,handleEditView:Yr,handleCopyViewLink:Ao,handleSaveEditView:qr,handleDeleteView:fo,handleConfirmDelete:Wo,handlePromoteToGlobal:Jr,handleSetDefaultForAllUsers:Kr,showManageColumns:$r,setShowManageColumns:Qe,columnVisibility:d==null?void 0:d.columnVisibility,columnOrder:d==null?void 0:d.columnOrder,columnWidths:d==null?void 0:d.columnWidths,handleUpdateColumnVisibility:In,handleUpdateColumnOrder:En,handleUpdateColumnWidth:Dn,handleResetColumnLayout:$n,showGroupPanel:Et,setShowGroupPanel:qt,grouping:d==null?void 0:d.grouping,groupingState:Pt,handleGroup:lt,handleToggleGroupCollapse:mo,handleExpandAllGroups:Po,handleCollapseAllGroups:Nn,searchQuery:sr,debouncedSearchQuery:Jt,searchHistory:el((d==null?void 0:d.searchHistory)||[]),handleSearchChange:On,handleAddToSearchHistory:Mn,handleToggleSearchFavourite:An,handleDeleteSearchHistory:Wn,selectedRowIds:vt,handleToggleRowSelection:Qr,handleToggleAllRows:Zt,handleRangeSelection:Rn,handleClearSelection:Pn,handleUpdateSelectionAfterDelete:Pe,currentPage:vr,pageSize:rt,paginationEngine:_e,paginationMode:m,paginationTotalRows:ut,handlePageChange:Ro,handlePageSizeChange:Xr,isExporting:Wt,showExportModal:Ar,setShowExportModal:cr,showDirtyExportWarning:_r,handleExport:er,handleExportWithConfig:No,handleExportSelected:N,handleExportAnyway:Lo,handleSaveAndExport:Fo,handleCancelExport:j,showAuditHistory:ar,setShowAuditHistory:co,auditHistory:d==null?void 0:d.auditHistory,showCreatePreset:Mr,setShowCreatePreset:lr,showManagePresets:Ke,setShowManagePresets:Ce,activePreset:ge,activePresetId:Dt,handleOpenManagePresets:Le,handleCreatePreset:oe,handleClearActivePreset:ze,handleDeletePresetById:nt,userRole:ve,isViewerRole:$o,currentUserId:Mt,permissions:d==null?void 0:d.permissions,featureLimitWarning:Cr,setFeatureLimitWarning:Wr,datasetMeta:fe,reportError:dr,setReportError:Ze,handleError:ft,schema:d==null?void 0:d.schema,hasSchemaConflicts:d!=null&&d.schema?Oa(d.schema):!1,snack:O,handleSnackClose:P,showSnack:w,snackDurationMs:te,config:B,scheduler:l}}const $s=p.createContext(void 0);function fi(e){const{children:r,initialData:n,data:i,reportName:s,reportId:a,dataSource:c,pagination:l,search:u,scheduler:g,mode:x="builder",autoLoad:f=!0,config:S,devConfig:C,showDevPanel:B=!1,sharedReportId:v,sharedViewId:m,viewPersistence:T,permissions:h}=e,I=Vl({mode:x,autoLoad:f,initialData:i||n,dataSource:c,pagination:l,search:u,scheduler:g,reportName:s,reportId:a,sharedReportId:v,sharedViewId:m,viewPersistence:T,permissions:h,config:S}),[b,R]=p.useState(()=>xa()),H=(()=>{const O=ya(b,C,!!C);return{...O,display:{...O.display,showDevPanel:B||O.display.showDevPanel}}})(),E=p.useCallback(Z=>{R(Z),ga(Z)},[]),G={...I,activeDevConfig:H,handleDevConfigChange:E};return t.jsx(js.Provider,{value:H,children:t.jsx($s.Provider,{value:G,children:r})})}function un(){const e=p.useContext($s);if(e===void 0)throw new Error("useReportContext must be used within a ReportProvider. Wrap your component tree with <ReportProvider>...</ReportProvider>");return e}function Hl({onCreateReport:e,reports:r=[],activeReportId:n,onReportClick:i}){const s=r.find(a=>a.id===n);return t.jsx(o.Box,{component:"header",sx:a=>{var x,f,S;const c=((S=(f=(x=a.components)==null?void 0:x.MuiCardHeader)==null?void 0:f.styleOverrides)==null?void 0:S.root)||{},l=c.backgroundColor&&c.backgroundColor!=="transparent"?c.backgroundColor:a.palette.background.paper,u=c.borderBottom&&c.borderBottom!=="none"?c.borderBottom:"1px solid",g=c.boxShadow&&c.boxShadow!=="none"?c.boxShadow:void 0;return{position:"sticky",top:0,zIndex:50,borderBottom:u,borderColor:u!=="none"?"divider":void 0,boxShadow:g,bgcolor:l}},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,height:64},children:[t.jsxs(o.Breadcrumbs,{separator:t.jsx($.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}),sx:{display:"flex",alignItems:"center"},children:[t.jsx(o.Typography,{variant:"h6",component:"h1",sx:{fontWeight:a=>a.typography.h6.fontWeight||500,fontSize:a=>a.typography.h6.fontSize||"1.375rem",color:a=>a.typography.h6.color||"text.primary",letterSpacing:"-0.01em",cursor:r.length>0&&s?"pointer":"default","&:hover":r.length>0&&s?{color:"primary.main"}:{}},onClick:()=>{r.length>0},children:"Reports"}),s&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.Typography,{sx:{fontWeight:a=>a.typography.h6.fontWeight||500,fontSize:a=>a.typography.h6.fontSize||"1.125rem",color:"primary.main",cursor:"pointer","&:hover":{textDecoration:"underline"}},onClick:()=>i==null?void 0:i(s.id),children:s.name}),t.jsx(o.Tooltip,{title:s.description||"No description",arrow:!0,placement:"bottom",children:t.jsx($.InfoOutlined,{sx:{fontSize:18,color:"text.secondary",opacity:.7,cursor:"help","&:hover":{opacity:1}}})})]})]}),t.jsx(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:t.jsx(o.Button,{variant:"contained",startIcon:t.jsx($.Add,{sx:{fontSize:18}}),onClick:e,sx:{borderRadius:"20px",px:3,fontSize:"0.875rem",py:.75},children:"New Report"})})]})})}function Ir(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 Ul="$$material";function Gl(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Go={exports:{}},Yo={exports:{}},Te={};/** @license React v16.13.1
106
106
  * react-is.production.min.js
107
107
  *
108
108
  * Copyright (c) Facebook, Inc. and its affiliates.
109
109
  *
110
110
  * This source code is licensed under the MIT license found in the
111
111
  * LICENSE file in the root directory of this source tree.
112
- */var Mi;function Gl(){if(Mi)return Ie;Mi=1;var e=typeof Symbol=="function"&&Symbol.for,r=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,i=e?Symbol.for("react.fragment"):60107,s=e?Symbol.for("react.strict_mode"):60108,a=e?Symbol.for("react.profiler"):60114,c=e?Symbol.for("react.provider"):60109,l=e?Symbol.for("react.context"):60110,u=e?Symbol.for("react.async_mode"):60111,g=e?Symbol.for("react.concurrent_mode"):60111,f=e?Symbol.for("react.forward_ref"):60112,m=e?Symbol.for("react.suspense"):60113,v=e?Symbol.for("react.suspense_list"):60120,C=e?Symbol.for("react.memo"):60115,B=e?Symbol.for("react.lazy"):60116,b=e?Symbol.for("react.block"):60121,y=e?Symbol.for("react.fundamental"):60117,z=e?Symbol.for("react.responder"):60118,x=e?Symbol.for("react.scope"):60119;function j(S){if(typeof S=="object"&&S!==null){var R=S.$$typeof;switch(R){case r:switch(S=S.type,S){case u:case g:case i:case a:case s:case m:return S;default:switch(S=S&&S.$$typeof,S){case l:case f:case B:case C:case c:return S;default:return R}}case n:return R}}}function E(S){return j(S)===g}return Ie.AsyncMode=u,Ie.ConcurrentMode=g,Ie.ContextConsumer=l,Ie.ContextProvider=c,Ie.Element=r,Ie.ForwardRef=f,Ie.Fragment=i,Ie.Lazy=B,Ie.Memo=C,Ie.Portal=n,Ie.Profiler=a,Ie.StrictMode=s,Ie.Suspense=m,Ie.isAsyncMode=function(S){return E(S)||j(S)===u},Ie.isConcurrentMode=E,Ie.isContextConsumer=function(S){return j(S)===l},Ie.isContextProvider=function(S){return j(S)===c},Ie.isElement=function(S){return typeof S=="object"&&S!==null&&S.$$typeof===r},Ie.isForwardRef=function(S){return j(S)===f},Ie.isFragment=function(S){return j(S)===i},Ie.isLazy=function(S){return j(S)===B},Ie.isMemo=function(S){return j(S)===C},Ie.isPortal=function(S){return j(S)===n},Ie.isProfiler=function(S){return j(S)===a},Ie.isStrictMode=function(S){return j(S)===s},Ie.isSuspense=function(S){return j(S)===m},Ie.isValidElementType=function(S){return typeof S=="string"||typeof S=="function"||S===i||S===g||S===a||S===s||S===m||S===v||typeof S=="object"&&S!==null&&(S.$$typeof===B||S.$$typeof===C||S.$$typeof===c||S.$$typeof===l||S.$$typeof===f||S.$$typeof===y||S.$$typeof===z||S.$$typeof===x||S.$$typeof===b)},Ie.typeOf=j,Ie}var Ee={};/** @license React v16.13.1
112
+ */var Wi;function Yl(){if(Wi)return Te;Wi=1;var e=typeof Symbol=="function"&&Symbol.for,r=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,i=e?Symbol.for("react.fragment"):60107,s=e?Symbol.for("react.strict_mode"):60108,a=e?Symbol.for("react.profiler"):60114,c=e?Symbol.for("react.provider"):60109,l=e?Symbol.for("react.context"):60110,u=e?Symbol.for("react.async_mode"):60111,g=e?Symbol.for("react.concurrent_mode"):60111,x=e?Symbol.for("react.forward_ref"):60112,f=e?Symbol.for("react.suspense"):60113,S=e?Symbol.for("react.suspense_list"):60120,C=e?Symbol.for("react.memo"):60115,B=e?Symbol.for("react.lazy"):60116,v=e?Symbol.for("react.block"):60121,m=e?Symbol.for("react.fundamental"):60117,T=e?Symbol.for("react.responder"):60118,h=e?Symbol.for("react.scope"):60119;function z(b){if(typeof b=="object"&&b!==null){var R=b.$$typeof;switch(R){case r:switch(b=b.type,b){case u:case g:case i:case a:case s:case f:return b;default:switch(b=b&&b.$$typeof,b){case l:case x:case B:case C:case c:return b;default:return R}}case n:return R}}}function I(b){return z(b)===g}return Te.AsyncMode=u,Te.ConcurrentMode=g,Te.ContextConsumer=l,Te.ContextProvider=c,Te.Element=r,Te.ForwardRef=x,Te.Fragment=i,Te.Lazy=B,Te.Memo=C,Te.Portal=n,Te.Profiler=a,Te.StrictMode=s,Te.Suspense=f,Te.isAsyncMode=function(b){return I(b)||z(b)===u},Te.isConcurrentMode=I,Te.isContextConsumer=function(b){return z(b)===l},Te.isContextProvider=function(b){return z(b)===c},Te.isElement=function(b){return typeof b=="object"&&b!==null&&b.$$typeof===r},Te.isForwardRef=function(b){return z(b)===x},Te.isFragment=function(b){return z(b)===i},Te.isLazy=function(b){return z(b)===B},Te.isMemo=function(b){return z(b)===C},Te.isPortal=function(b){return z(b)===n},Te.isProfiler=function(b){return z(b)===a},Te.isStrictMode=function(b){return z(b)===s},Te.isSuspense=function(b){return z(b)===f},Te.isValidElementType=function(b){return typeof b=="string"||typeof b=="function"||b===i||b===g||b===a||b===s||b===f||b===S||typeof b=="object"&&b!==null&&(b.$$typeof===B||b.$$typeof===C||b.$$typeof===c||b.$$typeof===l||b.$$typeof===x||b.$$typeof===m||b.$$typeof===T||b.$$typeof===h||b.$$typeof===v)},Te.typeOf=z,Te}var Be={};/** @license React v16.13.1
113
113
  * react-is.development.js
114
114
  *
115
115
  * Copyright (c) Facebook, Inc. and its affiliates.
116
116
  *
117
117
  * This source code is licensed under the MIT license found in the
118
118
  * LICENSE file in the root directory of this source tree.
119
- */var Wi;function Ul(){return Wi||(Wi=1,process.env.NODE_ENV!=="production"&&(function(){var e=typeof Symbol=="function"&&Symbol.for,r=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,i=e?Symbol.for("react.fragment"):60107,s=e?Symbol.for("react.strict_mode"):60108,a=e?Symbol.for("react.profiler"):60114,c=e?Symbol.for("react.provider"):60109,l=e?Symbol.for("react.context"):60110,u=e?Symbol.for("react.async_mode"):60111,g=e?Symbol.for("react.concurrent_mode"):60111,f=e?Symbol.for("react.forward_ref"):60112,m=e?Symbol.for("react.suspense"):60113,v=e?Symbol.for("react.suspense_list"):60120,C=e?Symbol.for("react.memo"):60115,B=e?Symbol.for("react.lazy"):60116,b=e?Symbol.for("react.block"):60121,y=e?Symbol.for("react.fundamental"):60117,z=e?Symbol.for("react.responder"):60118,x=e?Symbol.for("react.scope"):60119;function j(Y){return typeof Y=="string"||typeof Y=="function"||Y===i||Y===g||Y===a||Y===s||Y===m||Y===v||typeof Y=="object"&&Y!==null&&(Y.$$typeof===B||Y.$$typeof===C||Y.$$typeof===c||Y.$$typeof===l||Y.$$typeof===f||Y.$$typeof===y||Y.$$typeof===z||Y.$$typeof===x||Y.$$typeof===b)}function E(Y){if(typeof Y=="object"&&Y!==null){var Pe=Y.$$typeof;switch(Pe){case r:var Et=Y.type;switch(Et){case u:case g:case i:case a:case s:case m:return Et;default:var mt=Et&&Et.$$typeof;switch(mt){case l:case f:case B:case C:case c:return mt;default:return Pe}}case n:return Pe}}}var S=u,R=g,q=l,T=c,F=r,X=f,W=i,h=B,I=C,N=n,d=a,oe=s,G=m,te=!1;function ge(Y){return te||(te=!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.")),V(Y)||E(Y)===u}function V(Y){return E(Y)===g}function K(Y){return E(Y)===l}function ce(Y){return E(Y)===c}function de(Y){return typeof Y=="object"&&Y!==null&&Y.$$typeof===r}function ne(Y){return E(Y)===f}function Q(Y){return E(Y)===i}function pe(Y){return E(Y)===B}function D(Y){return E(Y)===C}function ee(Y){return E(Y)===n}function xe(Y){return E(Y)===a}function ae(Y){return E(Y)===s}function Te(Y){return E(Y)===m}Ee.AsyncMode=S,Ee.ConcurrentMode=R,Ee.ContextConsumer=q,Ee.ContextProvider=T,Ee.Element=F,Ee.ForwardRef=X,Ee.Fragment=W,Ee.Lazy=h,Ee.Memo=I,Ee.Portal=N,Ee.Profiler=d,Ee.StrictMode=oe,Ee.Suspense=G,Ee.isAsyncMode=ge,Ee.isConcurrentMode=V,Ee.isContextConsumer=K,Ee.isContextProvider=ce,Ee.isElement=de,Ee.isForwardRef=ne,Ee.isFragment=Q,Ee.isLazy=pe,Ee.isMemo=D,Ee.isPortal=ee,Ee.isProfiler=xe,Ee.isStrictMode=ae,Ee.isSuspense=Te,Ee.isValidElementType=j,Ee.typeOf=E})()),Ee}var Ai;function _s(){return Ai||(Ai=1,process.env.NODE_ENV==="production"?Uo.exports=Gl():Uo.exports=Ul()),Uo.exports}/*
119
+ */var Ri;function ql(){return Ri||(Ri=1,process.env.NODE_ENV!=="production"&&(function(){var e=typeof Symbol=="function"&&Symbol.for,r=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,i=e?Symbol.for("react.fragment"):60107,s=e?Symbol.for("react.strict_mode"):60108,a=e?Symbol.for("react.profiler"):60114,c=e?Symbol.for("react.provider"):60109,l=e?Symbol.for("react.context"):60110,u=e?Symbol.for("react.async_mode"):60111,g=e?Symbol.for("react.concurrent_mode"):60111,x=e?Symbol.for("react.forward_ref"):60112,f=e?Symbol.for("react.suspense"):60113,S=e?Symbol.for("react.suspense_list"):60120,C=e?Symbol.for("react.memo"):60115,B=e?Symbol.for("react.lazy"):60116,v=e?Symbol.for("react.block"):60121,m=e?Symbol.for("react.fundamental"):60117,T=e?Symbol.for("react.responder"):60118,h=e?Symbol.for("react.scope"):60119;function z(Q){return typeof Q=="string"||typeof Q=="function"||Q===i||Q===g||Q===a||Q===s||Q===f||Q===S||typeof Q=="object"&&Q!==null&&(Q.$$typeof===B||Q.$$typeof===C||Q.$$typeof===c||Q.$$typeof===l||Q.$$typeof===x||Q.$$typeof===m||Q.$$typeof===T||Q.$$typeof===h||Q.$$typeof===v)}function I(Q){if(typeof Q=="object"&&Q!==null){var De=Q.$$typeof;switch(De){case r:var We=Q.type;switch(We){case u:case g:case i:case a:case s:case f:return We;default:var Wt=We&&We.$$typeof;switch(Wt){case l:case x:case B:case C:case c:return Wt;default:return De}}case n:return De}}}var b=u,R=g,H=l,E=c,G=r,Z=x,O=i,y=B,w=C,P=n,te=a,d=s,J=f,re=!1;function Se(Q){return re||(re=!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.")),F(Q)||I(Q)===u}function F(Q){return I(Q)===g}function X(Q){return I(Q)===l}function ue(Q){return I(Q)===c}function pe(Q){return typeof Q=="object"&&Q!==null&&Q.$$typeof===r}function K(Q){return I(Q)===x}function he(Q){return I(Q)===i}function ae(Q){return I(Q)===B}function W(Q){return I(Q)===C}function ie(Q){return I(Q)===n}function U(Q){return I(Q)===a}function ne(Q){return I(Q)===s}function ke(Q){return I(Q)===f}Be.AsyncMode=b,Be.ConcurrentMode=R,Be.ContextConsumer=H,Be.ContextProvider=E,Be.Element=G,Be.ForwardRef=Z,Be.Fragment=O,Be.Lazy=y,Be.Memo=w,Be.Portal=P,Be.Profiler=te,Be.StrictMode=d,Be.Suspense=J,Be.isAsyncMode=Se,Be.isConcurrentMode=F,Be.isContextConsumer=X,Be.isContextProvider=ue,Be.isElement=pe,Be.isForwardRef=K,Be.isFragment=he,Be.isLazy=ae,Be.isMemo=W,Be.isPortal=ie,Be.isProfiler=U,Be.isStrictMode=ne,Be.isSuspense=ke,Be.isValidElementType=z,Be.typeOf=I})()),Be}var Pi;function Os(){return Pi||(Pi=1,process.env.NODE_ENV==="production"?Yo.exports=Yl():Yo.exports=ql()),Yo.exports}/*
120
120
  object-assign
121
121
  (c) Sindre Sorhus
122
122
  @license MIT
123
- */var Hn,Ri;function Yl(){if(Ri)return Hn;Ri=1;var e=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function i(a){if(a==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(a)}function s(){try{if(!Object.assign)return!1;var a=new String("abc");if(a[5]="de",Object.getOwnPropertyNames(a)[0]==="5")return!1;for(var c={},l=0;l<10;l++)c["_"+String.fromCharCode(l)]=l;var u=Object.getOwnPropertyNames(c).map(function(f){return c[f]});if(u.join("")!=="0123456789")return!1;var g={};return"abcdefghijklmnopqrst".split("").forEach(function(f){g[f]=f}),Object.keys(Object.assign({},g)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return Hn=s()?Object.assign:function(a,c){for(var l,u=i(a),g,f=1;f<arguments.length;f++){l=Object(arguments[f]);for(var m in l)r.call(l,m)&&(u[m]=l[m]);if(e){g=e(l);for(var v=0;v<g.length;v++)n.call(l,g[v])&&(u[g[v]]=l[g[v]])}}return u},Hn}var Gn,Pi;function xi(){if(Pi)return Gn;Pi=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Gn=e,Gn}var Un,Ni;function $s(){return Ni||(Ni=1,Un=Function.call.bind(Object.prototype.hasOwnProperty)),Un}var Yn,Li;function ql(){if(Li)return Yn;Li=1;var e=function(){};if(process.env.NODE_ENV!=="production"){var r=xi(),n={},i=$s();e=function(a){var c="Warning: "+a;typeof console<"u"&&console.error(c);try{throw new Error(c)}catch{}}}function s(a,c,l,u,g){if(process.env.NODE_ENV!=="production"){for(var f in a)if(i(a,f)){var m;try{if(typeof a[f]!="function"){var v=Error((u||"React class")+": "+l+" type `"+f+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof a[f]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw v.name="Invariant Violation",v}m=a[f](c,f,u,l,null,r)}catch(B){m=B}if(m&&!(m instanceof Error)&&e((u||"React class")+": type specification of "+l+" `"+f+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof m+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),m instanceof Error&&!(m.message in n)){n[m.message]=!0;var C=g?g():"";e("Failed "+l+" type: "+m.message+(C??""))}}}}return s.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},Yn=s,Yn}var qn,Fi;function Jl(){if(Fi)return qn;Fi=1;var e=_s(),r=Yl(),n=xi(),i=$s(),s=ql(),a=function(){};process.env.NODE_ENV!=="production"&&(a=function(l){var u="Warning: "+l;typeof console<"u"&&console.error(u);try{throw new Error(u)}catch{}});function c(){return null}return qn=function(l,u){var g=typeof Symbol=="function"&&Symbol.iterator,f="@@iterator";function m(V){var K=V&&(g&&V[g]||V[f]);if(typeof K=="function")return K}var v="<<anonymous>>",C={array:z("array"),bigint:z("bigint"),bool:z("boolean"),func:z("function"),number:z("number"),object:z("object"),string:z("string"),symbol:z("symbol"),any:x(),arrayOf:j,element:E(),elementType:S(),instanceOf:R,node:X(),objectOf:T,oneOf:q,oneOfType:F,shape:h,exact:I};function B(V,K){return V===K?V!==0||1/V===1/K:V!==V&&K!==K}function b(V,K){this.message=V,this.data=K&&typeof K=="object"?K:{},this.stack=""}b.prototype=Error.prototype;function y(V){if(process.env.NODE_ENV!=="production")var K={},ce=0;function de(Q,pe,D,ee,xe,ae,Te){if(ee=ee||v,ae=ae||D,Te!==n){if(u){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}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var Pe=ee+":"+D;!K[Pe]&&ce<3&&(a("You are manually calling a React.PropTypes validation function for the `"+ae+"` prop on `"+ee+"`. 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."),K[Pe]=!0,ce++)}}return pe[D]==null?Q?pe[D]===null?new b("The "+xe+" `"+ae+"` is marked as required "+("in `"+ee+"`, but its value is `null`.")):new b("The "+xe+" `"+ae+"` is marked as required in "+("`"+ee+"`, but its value is `undefined`.")):null:V(pe,D,ee,xe,ae)}var ne=de.bind(null,!1);return ne.isRequired=de.bind(null,!0),ne}function z(V){function K(ce,de,ne,Q,pe,D){var ee=ce[de],xe=oe(ee);if(xe!==V){var ae=G(ee);return new b("Invalid "+Q+" `"+pe+"` of type "+("`"+ae+"` supplied to `"+ne+"`, expected ")+("`"+V+"`."),{expectedType:V})}return null}return y(K)}function x(){return y(c)}function j(V){function K(ce,de,ne,Q,pe){if(typeof V!="function")return new b("Property `"+pe+"` of component `"+ne+"` has invalid PropType notation inside arrayOf.");var D=ce[de];if(!Array.isArray(D)){var ee=oe(D);return new b("Invalid "+Q+" `"+pe+"` of type "+("`"+ee+"` supplied to `"+ne+"`, expected an array."))}for(var xe=0;xe<D.length;xe++){var ae=V(D,xe,ne,Q,pe+"["+xe+"]",n);if(ae instanceof Error)return ae}return null}return y(K)}function E(){function V(K,ce,de,ne,Q){var pe=K[ce];if(!l(pe)){var D=oe(pe);return new b("Invalid "+ne+" `"+Q+"` of type "+("`"+D+"` supplied to `"+de+"`, expected a single ReactElement."))}return null}return y(V)}function S(){function V(K,ce,de,ne,Q){var pe=K[ce];if(!e.isValidElementType(pe)){var D=oe(pe);return new b("Invalid "+ne+" `"+Q+"` of type "+("`"+D+"` supplied to `"+de+"`, expected a single ReactElement type."))}return null}return y(V)}function R(V){function K(ce,de,ne,Q,pe){if(!(ce[de]instanceof V)){var D=V.name||v,ee=ge(ce[de]);return new b("Invalid "+Q+" `"+pe+"` of type "+("`"+ee+"` supplied to `"+ne+"`, expected ")+("instance of `"+D+"`."))}return null}return y(K)}function q(V){if(!Array.isArray(V))return process.env.NODE_ENV!=="production"&&(arguments.length>1?a("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])."):a("Invalid argument supplied to oneOf, expected an array.")),c;function K(ce,de,ne,Q,pe){for(var D=ce[de],ee=0;ee<V.length;ee++)if(B(D,V[ee]))return null;var xe=JSON.stringify(V,function(Te,Y){var Pe=G(Y);return Pe==="symbol"?String(Y):Y});return new b("Invalid "+Q+" `"+pe+"` of value `"+String(D)+"` "+("supplied to `"+ne+"`, expected one of "+xe+"."))}return y(K)}function T(V){function K(ce,de,ne,Q,pe){if(typeof V!="function")return new b("Property `"+pe+"` of component `"+ne+"` has invalid PropType notation inside objectOf.");var D=ce[de],ee=oe(D);if(ee!=="object")return new b("Invalid "+Q+" `"+pe+"` of type "+("`"+ee+"` supplied to `"+ne+"`, expected an object."));for(var xe in D)if(i(D,xe)){var ae=V(D,xe,ne,Q,pe+"."+xe,n);if(ae instanceof Error)return ae}return null}return y(K)}function F(V){if(!Array.isArray(V))return process.env.NODE_ENV!=="production"&&a("Invalid argument supplied to oneOfType, expected an instance of array."),c;for(var K=0;K<V.length;K++){var ce=V[K];if(typeof ce!="function")return a("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+te(ce)+" at index "+K+"."),c}function de(ne,Q,pe,D,ee){for(var xe=[],ae=0;ae<V.length;ae++){var Te=V[ae],Y=Te(ne,Q,pe,D,ee,n);if(Y==null)return null;Y.data&&i(Y.data,"expectedType")&&xe.push(Y.data.expectedType)}var Pe=xe.length>0?", expected one of type ["+xe.join(", ")+"]":"";return new b("Invalid "+D+" `"+ee+"` supplied to "+("`"+pe+"`"+Pe+"."))}return y(de)}function X(){function V(K,ce,de,ne,Q){return N(K[ce])?null:new b("Invalid "+ne+" `"+Q+"` supplied to "+("`"+de+"`, expected a ReactNode."))}return y(V)}function W(V,K,ce,de,ne){return new b((V||"React class")+": "+K+" type `"+ce+"."+de+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+ne+"`.")}function h(V){function K(ce,de,ne,Q,pe){var D=ce[de],ee=oe(D);if(ee!=="object")return new b("Invalid "+Q+" `"+pe+"` of type `"+ee+"` "+("supplied to `"+ne+"`, expected `object`."));for(var xe in V){var ae=V[xe];if(typeof ae!="function")return W(ne,Q,pe,xe,G(ae));var Te=ae(D,xe,ne,Q,pe+"."+xe,n);if(Te)return Te}return null}return y(K)}function I(V){function K(ce,de,ne,Q,pe){var D=ce[de],ee=oe(D);if(ee!=="object")return new b("Invalid "+Q+" `"+pe+"` of type `"+ee+"` "+("supplied to `"+ne+"`, expected `object`."));var xe=r({},ce[de],V);for(var ae in xe){var Te=V[ae];if(i(V,ae)&&typeof Te!="function")return W(ne,Q,pe,ae,G(Te));if(!Te)return new b("Invalid "+Q+" `"+pe+"` key `"+ae+"` supplied to `"+ne+"`.\nBad object: "+JSON.stringify(ce[de],null," ")+`
124
- Valid keys: `+JSON.stringify(Object.keys(V),null," "));var Y=Te(D,ae,ne,Q,pe+"."+ae,n);if(Y)return Y}return null}return y(K)}function N(V){switch(typeof V){case"number":case"string":case"undefined":return!0;case"boolean":return!V;case"object":if(Array.isArray(V))return V.every(N);if(V===null||l(V))return!0;var K=m(V);if(K){var ce=K.call(V),de;if(K!==V.entries){for(;!(de=ce.next()).done;)if(!N(de.value))return!1}else for(;!(de=ce.next()).done;){var ne=de.value;if(ne&&!N(ne[1]))return!1}}else return!1;return!0;default:return!1}}function d(V,K){return V==="symbol"?!0:K?K["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&K instanceof Symbol:!1}function oe(V){var K=typeof V;return Array.isArray(V)?"array":V instanceof RegExp?"object":d(K,V)?"symbol":K}function G(V){if(typeof V>"u"||V===null)return""+V;var K=oe(V);if(K==="object"){if(V instanceof Date)return"date";if(V instanceof RegExp)return"regexp"}return K}function te(V){var K=G(V);switch(K){case"array":case"object":return"an "+K;case"boolean":case"date":case"regexp":return"a "+K;default:return K}}function ge(V){return!V.constructor||!V.constructor.name?v:V.constructor.name}return C.checkPropTypes=s,C.resetWarningCache=s.resetWarningCache,C.PropTypes=C,C},qn}var Jn,Vi;function Kl(){if(Vi)return Jn;Vi=1;var e=xi();function r(){}function n(){}return n.resetWarningCache=r,Jn=function(){function i(c,l,u,g,f,m){if(m!==e){var v=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 v.name="Invariant Violation",v}}i.isRequired=i;function s(){return i}var a={array:i,bigint:i,bool:i,func:i,number:i,object:i,string:i,symbol:i,any:i,arrayOf:s,element:i,elementType:i,instanceOf:s,node:i,objectOf:s,oneOf:s,oneOfType:s,shape:s,exact:s,checkPropTypes:n,resetWarningCache:r};return a.PropTypes=a,a},Jn}var Hi;function Xl(){if(Hi)return Go.exports;if(Hi=1,process.env.NODE_ENV!=="production"){var e=_s(),r=!0;Go.exports=Jl()(e.isElement,r)}else Go.exports=Kl()();return Go.exports}var Ql=Xl();const go=Hl(Ql);var Yo={exports:{}},$e={};/**
123
+ */var Hn,Ni;function Jl(){if(Ni)return Hn;Ni=1;var e=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function i(a){if(a==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(a)}function s(){try{if(!Object.assign)return!1;var a=new String("abc");if(a[5]="de",Object.getOwnPropertyNames(a)[0]==="5")return!1;for(var c={},l=0;l<10;l++)c["_"+String.fromCharCode(l)]=l;var u=Object.getOwnPropertyNames(c).map(function(x){return c[x]});if(u.join("")!=="0123456789")return!1;var g={};return"abcdefghijklmnopqrst".split("").forEach(function(x){g[x]=x}),Object.keys(Object.assign({},g)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return Hn=s()?Object.assign:function(a,c){for(var l,u=i(a),g,x=1;x<arguments.length;x++){l=Object(arguments[x]);for(var f in l)r.call(l,f)&&(u[f]=l[f]);if(e){g=e(l);for(var S=0;S<g.length;S++)n.call(l,g[S])&&(u[g[S]]=l[g[S]])}}return u},Hn}var Un,Li;function mi(){if(Li)return Un;Li=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Un=e,Un}var Gn,Fi;function Ms(){return Fi||(Fi=1,Gn=Function.call.bind(Object.prototype.hasOwnProperty)),Gn}var Yn,Vi;function Kl(){if(Vi)return Yn;Vi=1;var e=function(){};if(process.env.NODE_ENV!=="production"){var r=mi(),n={},i=Ms();e=function(a){var c="Warning: "+a;typeof console<"u"&&console.error(c);try{throw new Error(c)}catch{}}}function s(a,c,l,u,g){if(process.env.NODE_ENV!=="production"){for(var x in a)if(i(a,x)){var f;try{if(typeof a[x]!="function"){var S=Error((u||"React class")+": "+l+" type `"+x+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof a[x]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw S.name="Invariant Violation",S}f=a[x](c,x,u,l,null,r)}catch(B){f=B}if(f&&!(f instanceof Error)&&e((u||"React class")+": type specification of "+l+" `"+x+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof f+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),f instanceof Error&&!(f.message in n)){n[f.message]=!0;var C=g?g():"";e("Failed "+l+" type: "+f.message+(C??""))}}}}return s.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},Yn=s,Yn}var qn,Hi;function Xl(){if(Hi)return qn;Hi=1;var e=Os(),r=Jl(),n=mi(),i=Ms(),s=Kl(),a=function(){};process.env.NODE_ENV!=="production"&&(a=function(l){var u="Warning: "+l;typeof console<"u"&&console.error(u);try{throw new Error(u)}catch{}});function c(){return null}return qn=function(l,u){var g=typeof Symbol=="function"&&Symbol.iterator,x="@@iterator";function f(F){var X=F&&(g&&F[g]||F[x]);if(typeof X=="function")return X}var S="<<anonymous>>",C={array:T("array"),bigint:T("bigint"),bool:T("boolean"),func:T("function"),number:T("number"),object:T("object"),string:T("string"),symbol:T("symbol"),any:h(),arrayOf:z,element:I(),elementType:b(),instanceOf:R,node:Z(),objectOf:E,oneOf:H,oneOfType:G,shape:y,exact:w};function B(F,X){return F===X?F!==0||1/F===1/X:F!==F&&X!==X}function v(F,X){this.message=F,this.data=X&&typeof X=="object"?X:{},this.stack=""}v.prototype=Error.prototype;function m(F){if(process.env.NODE_ENV!=="production")var X={},ue=0;function pe(he,ae,W,ie,U,ne,ke){if(ie=ie||S,ne=ne||W,ke!==n){if(u){var Q=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 Q.name="Invariant Violation",Q}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var De=ie+":"+W;!X[De]&&ue<3&&(a("You are manually calling a React.PropTypes validation function for the `"+ne+"` prop on `"+ie+"`. 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."),X[De]=!0,ue++)}}return ae[W]==null?he?ae[W]===null?new v("The "+U+" `"+ne+"` is marked as required "+("in `"+ie+"`, but its value is `null`.")):new v("The "+U+" `"+ne+"` is marked as required in "+("`"+ie+"`, but its value is `undefined`.")):null:F(ae,W,ie,U,ne)}var K=pe.bind(null,!1);return K.isRequired=pe.bind(null,!0),K}function T(F){function X(ue,pe,K,he,ae,W){var ie=ue[pe],U=d(ie);if(U!==F){var ne=J(ie);return new v("Invalid "+he+" `"+ae+"` of type "+("`"+ne+"` supplied to `"+K+"`, expected ")+("`"+F+"`."),{expectedType:F})}return null}return m(X)}function h(){return m(c)}function z(F){function X(ue,pe,K,he,ae){if(typeof F!="function")return new v("Property `"+ae+"` of component `"+K+"` has invalid PropType notation inside arrayOf.");var W=ue[pe];if(!Array.isArray(W)){var ie=d(W);return new v("Invalid "+he+" `"+ae+"` of type "+("`"+ie+"` supplied to `"+K+"`, expected an array."))}for(var U=0;U<W.length;U++){var ne=F(W,U,K,he,ae+"["+U+"]",n);if(ne instanceof Error)return ne}return null}return m(X)}function I(){function F(X,ue,pe,K,he){var ae=X[ue];if(!l(ae)){var W=d(ae);return new v("Invalid "+K+" `"+he+"` of type "+("`"+W+"` supplied to `"+pe+"`, expected a single ReactElement."))}return null}return m(F)}function b(){function F(X,ue,pe,K,he){var ae=X[ue];if(!e.isValidElementType(ae)){var W=d(ae);return new v("Invalid "+K+" `"+he+"` of type "+("`"+W+"` supplied to `"+pe+"`, expected a single ReactElement type."))}return null}return m(F)}function R(F){function X(ue,pe,K,he,ae){if(!(ue[pe]instanceof F)){var W=F.name||S,ie=Se(ue[pe]);return new v("Invalid "+he+" `"+ae+"` of type "+("`"+ie+"` supplied to `"+K+"`, expected ")+("instance of `"+W+"`."))}return null}return m(X)}function H(F){if(!Array.isArray(F))return process.env.NODE_ENV!=="production"&&(arguments.length>1?a("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])."):a("Invalid argument supplied to oneOf, expected an array.")),c;function X(ue,pe,K,he,ae){for(var W=ue[pe],ie=0;ie<F.length;ie++)if(B(W,F[ie]))return null;var U=JSON.stringify(F,function(ke,Q){var De=J(Q);return De==="symbol"?String(Q):Q});return new v("Invalid "+he+" `"+ae+"` of value `"+String(W)+"` "+("supplied to `"+K+"`, expected one of "+U+"."))}return m(X)}function E(F){function X(ue,pe,K,he,ae){if(typeof F!="function")return new v("Property `"+ae+"` of component `"+K+"` has invalid PropType notation inside objectOf.");var W=ue[pe],ie=d(W);if(ie!=="object")return new v("Invalid "+he+" `"+ae+"` of type "+("`"+ie+"` supplied to `"+K+"`, expected an object."));for(var U in W)if(i(W,U)){var ne=F(W,U,K,he,ae+"."+U,n);if(ne instanceof Error)return ne}return null}return m(X)}function G(F){if(!Array.isArray(F))return process.env.NODE_ENV!=="production"&&a("Invalid argument supplied to oneOfType, expected an instance of array."),c;for(var X=0;X<F.length;X++){var ue=F[X];if(typeof ue!="function")return a("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+re(ue)+" at index "+X+"."),c}function pe(K,he,ae,W,ie){for(var U=[],ne=0;ne<F.length;ne++){var ke=F[ne],Q=ke(K,he,ae,W,ie,n);if(Q==null)return null;Q.data&&i(Q.data,"expectedType")&&U.push(Q.data.expectedType)}var De=U.length>0?", expected one of type ["+U.join(", ")+"]":"";return new v("Invalid "+W+" `"+ie+"` supplied to "+("`"+ae+"`"+De+"."))}return m(pe)}function Z(){function F(X,ue,pe,K,he){return P(X[ue])?null:new v("Invalid "+K+" `"+he+"` supplied to "+("`"+pe+"`, expected a ReactNode."))}return m(F)}function O(F,X,ue,pe,K){return new v((F||"React class")+": "+X+" type `"+ue+"."+pe+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+K+"`.")}function y(F){function X(ue,pe,K,he,ae){var W=ue[pe],ie=d(W);if(ie!=="object")return new v("Invalid "+he+" `"+ae+"` of type `"+ie+"` "+("supplied to `"+K+"`, expected `object`."));for(var U in F){var ne=F[U];if(typeof ne!="function")return O(K,he,ae,U,J(ne));var ke=ne(W,U,K,he,ae+"."+U,n);if(ke)return ke}return null}return m(X)}function w(F){function X(ue,pe,K,he,ae){var W=ue[pe],ie=d(W);if(ie!=="object")return new v("Invalid "+he+" `"+ae+"` of type `"+ie+"` "+("supplied to `"+K+"`, expected `object`."));var U=r({},ue[pe],F);for(var ne in U){var ke=F[ne];if(i(F,ne)&&typeof ke!="function")return O(K,he,ae,ne,J(ke));if(!ke)return new v("Invalid "+he+" `"+ae+"` key `"+ne+"` supplied to `"+K+"`.\nBad object: "+JSON.stringify(ue[pe],null," ")+`
124
+ Valid keys: `+JSON.stringify(Object.keys(F),null," "));var Q=ke(W,ne,K,he,ae+"."+ne,n);if(Q)return Q}return null}return m(X)}function P(F){switch(typeof F){case"number":case"string":case"undefined":return!0;case"boolean":return!F;case"object":if(Array.isArray(F))return F.every(P);if(F===null||l(F))return!0;var X=f(F);if(X){var ue=X.call(F),pe;if(X!==F.entries){for(;!(pe=ue.next()).done;)if(!P(pe.value))return!1}else for(;!(pe=ue.next()).done;){var K=pe.value;if(K&&!P(K[1]))return!1}}else return!1;return!0;default:return!1}}function te(F,X){return F==="symbol"?!0:X?X["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&X instanceof Symbol:!1}function d(F){var X=typeof F;return Array.isArray(F)?"array":F instanceof RegExp?"object":te(X,F)?"symbol":X}function J(F){if(typeof F>"u"||F===null)return""+F;var X=d(F);if(X==="object"){if(F instanceof Date)return"date";if(F instanceof RegExp)return"regexp"}return X}function re(F){var X=J(F);switch(X){case"array":case"object":return"an "+X;case"boolean":case"date":case"regexp":return"a "+X;default:return X}}function Se(F){return!F.constructor||!F.constructor.name?S:F.constructor.name}return C.checkPropTypes=s,C.resetWarningCache=s.resetWarningCache,C.PropTypes=C,C},qn}var Jn,Ui;function Ql(){if(Ui)return Jn;Ui=1;var e=mi();function r(){}function n(){}return n.resetWarningCache=r,Jn=function(){function i(c,l,u,g,x,f){if(f!==e){var S=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 S.name="Invariant Violation",S}}i.isRequired=i;function s(){return i}var a={array:i,bigint:i,bool:i,func:i,number:i,object:i,string:i,symbol:i,any:i,arrayOf:s,element:i,elementType:i,instanceOf:s,node:i,objectOf:s,oneOf:s,oneOfType:s,shape:s,exact:s,checkPropTypes:n,resetWarningCache:r};return a.PropTypes=a,a},Jn}var Gi;function Zl(){if(Gi)return Go.exports;if(Gi=1,process.env.NODE_ENV!=="production"){var e=Os(),r=!0;Go.exports=Xl()(e.isElement,r)}else Go.exports=Ql()();return Go.exports}var ec=Zl();const go=Gl(ec);var qo={exports:{}},$e={};/**
125
125
  * @license React
126
126
  * react-is.production.js
127
127
  *
@@ -129,7 +129,7 @@ Valid keys: `+JSON.stringify(Object.keys(V),null," "));var Y=Te(D,ae,ne,Q,pe+".
129
129
  *
130
130
  * This source code is licensed under the MIT license found in the
131
131
  * LICENSE file in the root directory of this source tree.
132
- */var Gi;function Zl(){if(Gi)return $e;Gi=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),c=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),g=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),v=Symbol.for("react.view_transition"),C=Symbol.for("react.client.reference");function B(b){if(typeof b=="object"&&b!==null){var y=b.$$typeof;switch(y){case e:switch(b=b.type,b){case n:case s:case i:case u:case g:case v:return b;default:switch(b=b&&b.$$typeof,b){case c:case l:case m:case f:return b;case a:return b;default:return y}}case r:return y}}}return $e.ContextConsumer=a,$e.ContextProvider=c,$e.Element=e,$e.ForwardRef=l,$e.Fragment=n,$e.Lazy=m,$e.Memo=f,$e.Portal=r,$e.Profiler=s,$e.StrictMode=i,$e.Suspense=u,$e.SuspenseList=g,$e.isContextConsumer=function(b){return B(b)===a},$e.isContextProvider=function(b){return B(b)===c},$e.isElement=function(b){return typeof b=="object"&&b!==null&&b.$$typeof===e},$e.isForwardRef=function(b){return B(b)===l},$e.isFragment=function(b){return B(b)===n},$e.isLazy=function(b){return B(b)===m},$e.isMemo=function(b){return B(b)===f},$e.isPortal=function(b){return B(b)===r},$e.isProfiler=function(b){return B(b)===s},$e.isStrictMode=function(b){return B(b)===i},$e.isSuspense=function(b){return B(b)===u},$e.isSuspenseList=function(b){return B(b)===g},$e.isValidElementType=function(b){return typeof b=="string"||typeof b=="function"||b===n||b===s||b===i||b===u||b===g||typeof b=="object"&&b!==null&&(b.$$typeof===m||b.$$typeof===f||b.$$typeof===c||b.$$typeof===a||b.$$typeof===l||b.$$typeof===C||b.getModuleId!==void 0)},$e.typeOf=B,$e}var Oe={};/**
132
+ */var Yi;function tc(){if(Yi)return $e;Yi=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),c=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),g=Symbol.for("react.suspense_list"),x=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),S=Symbol.for("react.view_transition"),C=Symbol.for("react.client.reference");function B(v){if(typeof v=="object"&&v!==null){var m=v.$$typeof;switch(m){case e:switch(v=v.type,v){case n:case s:case i:case u:case g:case S:return v;default:switch(v=v&&v.$$typeof,v){case c:case l:case f:case x:return v;case a:return v;default:return m}}case r:return m}}}return $e.ContextConsumer=a,$e.ContextProvider=c,$e.Element=e,$e.ForwardRef=l,$e.Fragment=n,$e.Lazy=f,$e.Memo=x,$e.Portal=r,$e.Profiler=s,$e.StrictMode=i,$e.Suspense=u,$e.SuspenseList=g,$e.isContextConsumer=function(v){return B(v)===a},$e.isContextProvider=function(v){return B(v)===c},$e.isElement=function(v){return typeof v=="object"&&v!==null&&v.$$typeof===e},$e.isForwardRef=function(v){return B(v)===l},$e.isFragment=function(v){return B(v)===n},$e.isLazy=function(v){return B(v)===f},$e.isMemo=function(v){return B(v)===x},$e.isPortal=function(v){return B(v)===r},$e.isProfiler=function(v){return B(v)===s},$e.isStrictMode=function(v){return B(v)===i},$e.isSuspense=function(v){return B(v)===u},$e.isSuspenseList=function(v){return B(v)===g},$e.isValidElementType=function(v){return typeof v=="string"||typeof v=="function"||v===n||v===s||v===i||v===u||v===g||typeof v=="object"&&v!==null&&(v.$$typeof===f||v.$$typeof===x||v.$$typeof===c||v.$$typeof===a||v.$$typeof===l||v.$$typeof===C||v.getModuleId!==void 0)},$e.typeOf=B,$e}var Oe={};/**
133
133
  * @license React
134
134
  * react-is.development.js
135
135
  *
@@ -137,16 +137,16 @@ Valid keys: `+JSON.stringify(Object.keys(V),null," "));var Y=Te(D,ae,ne,Q,pe+".
137
137
  *
138
138
  * This source code is licensed under the MIT license found in the
139
139
  * LICENSE file in the root directory of this source tree.
140
- */var Ui;function ec(){return Ui||(Ui=1,process.env.NODE_ENV!=="production"&&(function(){function e(b){if(typeof b=="object"&&b!==null){var y=b.$$typeof;switch(y){case r:switch(b=b.type,b){case i:case a:case s:case g:case f:case C:return b;default:switch(b=b&&b.$$typeof,b){case l:case u:case v:case m:return b;case c:return b;default:return y}}case n:return y}}}var r=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),l=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),f=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),C=Symbol.for("react.view_transition"),B=Symbol.for("react.client.reference");Oe.ContextConsumer=c,Oe.ContextProvider=l,Oe.Element=r,Oe.ForwardRef=u,Oe.Fragment=i,Oe.Lazy=v,Oe.Memo=m,Oe.Portal=n,Oe.Profiler=a,Oe.StrictMode=s,Oe.Suspense=g,Oe.SuspenseList=f,Oe.isContextConsumer=function(b){return e(b)===c},Oe.isContextProvider=function(b){return e(b)===l},Oe.isElement=function(b){return typeof b=="object"&&b!==null&&b.$$typeof===r},Oe.isForwardRef=function(b){return e(b)===u},Oe.isFragment=function(b){return e(b)===i},Oe.isLazy=function(b){return e(b)===v},Oe.isMemo=function(b){return e(b)===m},Oe.isPortal=function(b){return e(b)===n},Oe.isProfiler=function(b){return e(b)===a},Oe.isStrictMode=function(b){return e(b)===s},Oe.isSuspense=function(b){return e(b)===g},Oe.isSuspenseList=function(b){return e(b)===f},Oe.isValidElementType=function(b){return typeof b=="string"||typeof b=="function"||b===i||b===a||b===s||b===g||b===f||typeof b=="object"&&b!==null&&(b.$$typeof===v||b.$$typeof===m||b.$$typeof===l||b.$$typeof===c||b.$$typeof===u||b.$$typeof===B||b.getModuleId!==void 0)},Oe.typeOf=e})()),Oe}var Yi;function tc(){return Yi||(Yi=1,process.env.NODE_ENV==="production"?Yo.exports=Zl():Yo.exports=ec()),Yo.exports}var Os=tc();function fr(e){if(typeof e!="object"||e===null)return!1;const r=Object.getPrototypeOf(e);return(r===null||r===Object.prototype||Object.getPrototypeOf(r)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Ms(e){if(an.isValidElement(e)||Os.isValidElementType(e)||!fr(e))return e;const r={};return Object.keys(e).forEach(n=>{r[n]=Ms(e[n])}),r}function bt(e,r,n={clone:!0}){const i=n.clone?{...e}:e;return fr(e)&&fr(r)&&Object.keys(r).forEach(s=>{an.isValidElement(r[s])||Os.isValidElementType(r[s])?i[s]=r[s]:fr(r[s])&&Object.prototype.hasOwnProperty.call(e,s)&&fr(e[s])?i[s]=bt(e[s],r[s],n):n.clone?i[s]=fr(r[s])?Ms(r[s]):r[s]:i[s]=r[s]}),i}const rc=e=>{const r=Object.keys(e).map(n=>({key:n,val:e[n]}))||[];return r.sort((n,i)=>n.val-i.val),r.reduce((n,i)=>({...n,[i.key]:i.val}),{})};function oc(e){const{values:r={xs:0,sm:600,md:900,lg:1200,xl:1536},unit:n="px",step:i=5,...s}=e,a=rc(r),c=Object.keys(a);function l(v){return`@media (min-width:${typeof r[v]=="number"?r[v]:v}${n})`}function u(v){return`@media (max-width:${(typeof r[v]=="number"?r[v]:v)-i/100}${n})`}function g(v,C){const B=c.indexOf(C);return`@media (min-width:${typeof r[v]=="number"?r[v]:v}${n}) and (max-width:${(B!==-1&&typeof r[c[B]]=="number"?r[c[B]]:C)-i/100}${n})`}function f(v){return c.indexOf(v)+1<c.length?g(v,c[c.indexOf(v)+1]):l(v)}function m(v){const C=c.indexOf(v);return C===0?l(c[1]):C===c.length-1?u(c[C]):g(v,c[c.indexOf(v)+1]).replace("@media","@media not all and")}return{keys:c,values:a,up:l,down:u,between:g,only:f,not:m,unit:n,...s}}function qi(e,r){if(!e.containerQueries)return r;const n=Object.keys(r).filter(i=>i.startsWith("@container")).sort((i,s)=>{var c,l;const a=/min-width:\s*([0-9.]+)/;return+(((c=i.match(a))==null?void 0:c[1])||0)-+(((l=s.match(a))==null?void 0:l[1])||0)});return n.length?n.reduce((i,s)=>{const a=r[s];return delete i[s],i[s]=a,i},{...r}):r}function nc(e,r){return r==="@"||r.startsWith("@")&&(e.some(n=>r.startsWith(`@${n}`))||!!r.match(/^@\d/))}function ic(e,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>\`.
141
- For example, \`@sm\` or \`@600\` or \`@40rem/sidebar\`.`);return null}const[,i,s]=n,a=Number.isNaN(+i)?i||0:+i;return e.containerQueries(s).up(a)}function sc(e){const r=(a,c)=>a.replace("@media",c?`@container ${c}`:"@container");function n(a,c){a.up=(...l)=>r(e.breakpoints.up(...l),c),a.down=(...l)=>r(e.breakpoints.down(...l),c),a.between=(...l)=>r(e.breakpoints.between(...l),c),a.only=(...l)=>r(e.breakpoints.only(...l),c),a.not=(...l)=>{const u=r(e.breakpoints.not(...l),c);return u.includes("not all and")?u.replace("not all and ","").replace("min-width:","width<").replace("max-width:","width>").replace("and","or"):u}}const i={},s=a=>(n(i,a),i);return n(s),{...e,containerQueries:s}}const ac={borderRadius:4},vr=process.env.NODE_ENV!=="production"?go.oneOfType([go.number,go.string,go.object,go.array]):{};function zo(e,r){return r?bt(e,r,{clone:!1}):e}const un={xs:0,sm:600,md:900,lg:1200,xl:1536},Ji={keys:["xs","sm","md","lg","xl"],up:e=>`@media (min-width:${un[e]}px)`},lc={containerQueries:e=>({up:r=>{let n=typeof r=="number"?r:un[r]||r;return typeof n=="number"&&(n=`${n}px`),e?`@container ${e} (min-width:${n})`:`@container (min-width:${n})`}})};function sr(e,r,n){const i=e.theme||{};if(Array.isArray(r)){const a=i.breakpoints||Ji;return r.reduce((c,l,u)=>(c[a.up(a.keys[u])]=n(r[u]),c),{})}if(typeof r=="object"){const a=i.breakpoints||Ji;return Object.keys(r).reduce((c,l)=>{if(nc(a.keys,l)){const u=ic(i.containerQueries?i:lc,l);u&&(c[u]=n(r[l],l))}else if(Object.keys(a.values||un).includes(l)){const u=a.up(l);c[u]=n(r[l],l)}else{const u=l;c[u]=r[u]}return c},{})}return n(r)}function cc(e={}){var n;return((n=e.keys)==null?void 0:n.reduce((i,s)=>{const a=e.up(s);return i[a]={},i},{}))||{}}function Ki(e,r){return e.reduce((n,i)=>{const s=n[i];return(!s||Object.keys(s).length===0)&&delete n[i],n},r)}function Ws(e){if(typeof e!="string")throw new Error(process.env.NODE_ENV!=="production"?"MUI: `capitalize(string)` expects a string argument.":Er(7));return e.charAt(0).toUpperCase()+e.slice(1)}function pn(e,r,n=!0){if(!r||typeof r!="string")return null;if(e&&e.vars&&n){const i=`vars.${r}`.split(".").reduce((s,a)=>s&&s[a]?s[a]:null,e);if(i!=null)return i}return r.split(".").reduce((i,s)=>i&&i[s]!=null?i[s]:null,e)}function nn(e,r,n,i=n){let s;return typeof e=="function"?s=e(n):Array.isArray(e)?s=e[n]||i:s=pn(e,n)||i,r&&(s=r(s,i,e)),s}function Ve(e){const{prop:r,cssProperty:n=e.prop,themeKey:i,transform:s}=e,a=c=>{if(c[r]==null)return null;const l=c[r],u=c.theme,g=pn(u,i)||{};return sr(c,l,m=>{let v=nn(g,s,m);return m===v&&typeof m=="string"&&(v=nn(g,s,`${r}${m==="default"?"":Ws(m)}`,m)),n===!1?v:{[n]:v}})};return a.propTypes=process.env.NODE_ENV!=="production"?{[r]:vr}:{},a.filterProps=[r],a}function dc(e){const r={};return n=>(r[n]===void 0&&(r[n]=e(n)),r[n])}const uc={m:"margin",p:"padding"},pc={t:"Top",r:"Right",b:"Bottom",l:"Left",x:["Left","Right"],y:["Top","Bottom"]},Xi={marginX:"mx",marginY:"my",paddingX:"px",paddingY:"py"},hc=dc(e=>{if(e.length>2)if(Xi[e])e=Xi[e];else return[e];const[r,n]=e.split(""),i=uc[r],s=pc[n]||"";return Array.isArray(s)?s.map(a=>i+a):[i+s]}),hn=["m","mt","mr","mb","ml","mx","my","margin","marginTop","marginRight","marginBottom","marginLeft","marginX","marginY","marginInline","marginInlineStart","marginInlineEnd","marginBlock","marginBlockStart","marginBlockEnd"],mn=["p","pt","pr","pb","pl","px","py","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingX","paddingY","paddingInline","paddingInlineStart","paddingInlineEnd","paddingBlock","paddingBlockStart","paddingBlockEnd"],mc=[...hn,...mn];function Eo(e,r,n,i){const s=pn(e,r,!0)??n;return typeof s=="number"||typeof s=="string"?a=>typeof a=="string"?a:(process.env.NODE_ENV!=="production"&&typeof a!="number"&&console.error(`MUI: Expected ${i} argument to be a number or a string, got ${a}.`),typeof s=="string"?s.startsWith("var(")&&a===0?0:s.startsWith("var(")&&a===1?s:`calc(${a} * ${s})`:s*a):Array.isArray(s)?a=>{if(typeof a=="string")return a;const c=Math.abs(a);process.env.NODE_ENV!=="production"&&(Number.isInteger(c)?c>s.length-1&&console.error([`MUI: The value provided (${c}) overflows.`,`The supported values are: ${JSON.stringify(s)}.`,`${c} > ${s.length-1}, you need to add the missing values.`].join(`
140
+ */var qi;function rc(){return qi||(qi=1,process.env.NODE_ENV!=="production"&&(function(){function e(v){if(typeof v=="object"&&v!==null){var m=v.$$typeof;switch(m){case r:switch(v=v.type,v){case i:case a:case s:case g:case x:case C:return v;default:switch(v=v&&v.$$typeof,v){case l:case u:case S:case f:return v;case c:return v;default:return m}}case n:return m}}}var r=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),l=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),x=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),C=Symbol.for("react.view_transition"),B=Symbol.for("react.client.reference");Oe.ContextConsumer=c,Oe.ContextProvider=l,Oe.Element=r,Oe.ForwardRef=u,Oe.Fragment=i,Oe.Lazy=S,Oe.Memo=f,Oe.Portal=n,Oe.Profiler=a,Oe.StrictMode=s,Oe.Suspense=g,Oe.SuspenseList=x,Oe.isContextConsumer=function(v){return e(v)===c},Oe.isContextProvider=function(v){return e(v)===l},Oe.isElement=function(v){return typeof v=="object"&&v!==null&&v.$$typeof===r},Oe.isForwardRef=function(v){return e(v)===u},Oe.isFragment=function(v){return e(v)===i},Oe.isLazy=function(v){return e(v)===S},Oe.isMemo=function(v){return e(v)===f},Oe.isPortal=function(v){return e(v)===n},Oe.isProfiler=function(v){return e(v)===a},Oe.isStrictMode=function(v){return e(v)===s},Oe.isSuspense=function(v){return e(v)===g},Oe.isSuspenseList=function(v){return e(v)===x},Oe.isValidElementType=function(v){return typeof v=="string"||typeof v=="function"||v===i||v===a||v===s||v===g||v===x||typeof v=="object"&&v!==null&&(v.$$typeof===S||v.$$typeof===f||v.$$typeof===l||v.$$typeof===c||v.$$typeof===u||v.$$typeof===B||v.getModuleId!==void 0)},Oe.typeOf=e})()),Oe}var Ji;function oc(){return Ji||(Ji=1,process.env.NODE_ENV==="production"?qo.exports=tc():qo.exports=rc()),qo.exports}var As=oc();function fr(e){if(typeof e!="object"||e===null)return!1;const r=Object.getPrototypeOf(e);return(r===null||r===Object.prototype||Object.getPrototypeOf(r)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Ws(e){if(ln.isValidElement(e)||As.isValidElementType(e)||!fr(e))return e;const r={};return Object.keys(e).forEach(n=>{r[n]=Ws(e[n])}),r}function yt(e,r,n={clone:!0}){const i=n.clone?{...e}:e;return fr(e)&&fr(r)&&Object.keys(r).forEach(s=>{ln.isValidElement(r[s])||As.isValidElementType(r[s])?i[s]=r[s]:fr(r[s])&&Object.prototype.hasOwnProperty.call(e,s)&&fr(e[s])?i[s]=yt(e[s],r[s],n):n.clone?i[s]=fr(r[s])?Ws(r[s]):r[s]:i[s]=r[s]}),i}const nc=e=>{const r=Object.keys(e).map(n=>({key:n,val:e[n]}))||[];return r.sort((n,i)=>n.val-i.val),r.reduce((n,i)=>({...n,[i.key]:i.val}),{})};function ic(e){const{values:r={xs:0,sm:600,md:900,lg:1200,xl:1536},unit:n="px",step:i=5,...s}=e,a=nc(r),c=Object.keys(a);function l(S){return`@media (min-width:${typeof r[S]=="number"?r[S]:S}${n})`}function u(S){return`@media (max-width:${(typeof r[S]=="number"?r[S]:S)-i/100}${n})`}function g(S,C){const B=c.indexOf(C);return`@media (min-width:${typeof r[S]=="number"?r[S]:S}${n}) and (max-width:${(B!==-1&&typeof r[c[B]]=="number"?r[c[B]]:C)-i/100}${n})`}function x(S){return c.indexOf(S)+1<c.length?g(S,c[c.indexOf(S)+1]):l(S)}function f(S){const C=c.indexOf(S);return C===0?l(c[1]):C===c.length-1?u(c[C]):g(S,c[c.indexOf(S)+1]).replace("@media","@media not all and")}return{keys:c,values:a,up:l,down:u,between:g,only:x,not:f,unit:n,...s}}function Ki(e,r){if(!e.containerQueries)return r;const n=Object.keys(r).filter(i=>i.startsWith("@container")).sort((i,s)=>{var c,l;const a=/min-width:\s*([0-9.]+)/;return+(((c=i.match(a))==null?void 0:c[1])||0)-+(((l=s.match(a))==null?void 0:l[1])||0)});return n.length?n.reduce((i,s)=>{const a=r[s];return delete i[s],i[s]=a,i},{...r}):r}function sc(e,r){return r==="@"||r.startsWith("@")&&(e.some(n=>r.startsWith(`@${n}`))||!!r.match(/^@\d/))}function ac(e,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>\`.
141
+ For example, \`@sm\` or \`@600\` or \`@40rem/sidebar\`.`);return null}const[,i,s]=n,a=Number.isNaN(+i)?i||0:+i;return e.containerQueries(s).up(a)}function lc(e){const r=(a,c)=>a.replace("@media",c?`@container ${c}`:"@container");function n(a,c){a.up=(...l)=>r(e.breakpoints.up(...l),c),a.down=(...l)=>r(e.breakpoints.down(...l),c),a.between=(...l)=>r(e.breakpoints.between(...l),c),a.only=(...l)=>r(e.breakpoints.only(...l),c),a.not=(...l)=>{const u=r(e.breakpoints.not(...l),c);return u.includes("not all and")?u.replace("not all and ","").replace("min-width:","width<").replace("max-width:","width>").replace("and","or"):u}}const i={},s=a=>(n(i,a),i);return n(s),{...e,containerQueries:s}}const cc={borderRadius:4},yr=process.env.NODE_ENV!=="production"?go.oneOfType([go.number,go.string,go.object,go.array]):{};function zo(e,r){return r?yt(e,r,{clone:!1}):e}const pn={xs:0,sm:600,md:900,lg:1200,xl:1536},Xi={keys:["xs","sm","md","lg","xl"],up:e=>`@media (min-width:${pn[e]}px)`},dc={containerQueries:e=>({up:r=>{let n=typeof r=="number"?r:pn[r]||r;return typeof n=="number"&&(n=`${n}px`),e?`@container ${e} (min-width:${n})`:`@container (min-width:${n})`}})};function nr(e,r,n){const i=e.theme||{};if(Array.isArray(r)){const a=i.breakpoints||Xi;return r.reduce((c,l,u)=>(c[a.up(a.keys[u])]=n(r[u]),c),{})}if(typeof r=="object"){const a=i.breakpoints||Xi;return Object.keys(r).reduce((c,l)=>{if(sc(a.keys,l)){const u=ac(i.containerQueries?i:dc,l);u&&(c[u]=n(r[l],l))}else if(Object.keys(a.values||pn).includes(l)){const u=a.up(l);c[u]=n(r[l],l)}else{const u=l;c[u]=r[u]}return c},{})}return n(r)}function uc(e={}){var n;return((n=e.keys)==null?void 0:n.reduce((i,s)=>{const a=e.up(s);return i[a]={},i},{}))||{}}function Qi(e,r){return e.reduce((n,i)=>{const s=n[i];return(!s||Object.keys(s).length===0)&&delete n[i],n},r)}function Rs(e){if(typeof e!="string")throw new Error(process.env.NODE_ENV!=="production"?"MUI: `capitalize(string)` expects a string argument.":Ir(7));return e.charAt(0).toUpperCase()+e.slice(1)}function hn(e,r,n=!0){if(!r||typeof r!="string")return null;if(e&&e.vars&&n){const i=`vars.${r}`.split(".").reduce((s,a)=>s&&s[a]?s[a]:null,e);if(i!=null)return i}return r.split(".").reduce((i,s)=>i&&i[s]!=null?i[s]:null,e)}function sn(e,r,n,i=n){let s;return typeof e=="function"?s=e(n):Array.isArray(e)?s=e[n]||i:s=hn(e,n)||i,r&&(s=r(s,i,e)),s}function Ue(e){const{prop:r,cssProperty:n=e.prop,themeKey:i,transform:s}=e,a=c=>{if(c[r]==null)return null;const l=c[r],u=c.theme,g=hn(u,i)||{};return nr(c,l,f=>{let S=sn(g,s,f);return f===S&&typeof f=="string"&&(S=sn(g,s,`${r}${f==="default"?"":Rs(f)}`,f)),n===!1?S:{[n]:S}})};return a.propTypes=process.env.NODE_ENV!=="production"?{[r]:yr}:{},a.filterProps=[r],a}function pc(e){const r={};return n=>(r[n]===void 0&&(r[n]=e(n)),r[n])}const hc={m:"margin",p:"padding"},fc={t:"Top",r:"Right",b:"Bottom",l:"Left",x:["Left","Right"],y:["Top","Bottom"]},Zi={marginX:"mx",marginY:"my",paddingX:"px",paddingY:"py"},mc=pc(e=>{if(e.length>2)if(Zi[e])e=Zi[e];else return[e];const[r,n]=e.split(""),i=hc[r],s=fc[n]||"";return Array.isArray(s)?s.map(a=>i+a):[i+s]}),fn=["m","mt","mr","mb","ml","mx","my","margin","marginTop","marginRight","marginBottom","marginLeft","marginX","marginY","marginInline","marginInlineStart","marginInlineEnd","marginBlock","marginBlockStart","marginBlockEnd"],mn=["p","pt","pr","pb","pl","px","py","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingX","paddingY","paddingInline","paddingInlineStart","paddingInlineEnd","paddingBlock","paddingBlockStart","paddingBlockEnd"],xc=[...fn,...mn];function Eo(e,r,n,i){const s=hn(e,r,!0)??n;return typeof s=="number"||typeof s=="string"?a=>typeof a=="string"?a:(process.env.NODE_ENV!=="production"&&typeof a!="number"&&console.error(`MUI: Expected ${i} argument to be a number or a string, got ${a}.`),typeof s=="string"?s.startsWith("var(")&&a===0?0:s.startsWith("var(")&&a===1?s:`calc(${a} * ${s})`:s*a):Array.isArray(s)?a=>{if(typeof a=="string")return a;const c=Math.abs(a);process.env.NODE_ENV!=="production"&&(Number.isInteger(c)?c>s.length-1&&console.error([`MUI: The value provided (${c}) overflows.`,`The supported values are: ${JSON.stringify(s)}.`,`${c} > ${s.length-1}, you need to add the missing values.`].join(`
142
142
  `)):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(`
143
143
  `)));const l=s[c];return a>=0?l:typeof l=="number"?-l:typeof l=="string"&&l.startsWith("var(")?`calc(-1 * ${l})`:`-${l}`}:typeof s=="function"?s:(process.env.NODE_ENV!=="production"&&console.error([`MUI: The \`theme.${r}\` value (${s}) is invalid.`,"It should be a number, an array or a function."].join(`
144
- `)),()=>{})}function fi(e){return Eo(e,"spacing",8,"spacing")}function Do(e,r){return typeof r=="string"||r==null?r:e(r)}function xc(e,r){return n=>e.reduce((i,s)=>(i[s]=Do(r,n),i),{})}function fc(e,r,n,i){if(!r.includes(n))return null;const s=hc(n),a=xc(s,i),c=e[n];return sr(e,c,a)}function As(e,r){const n=fi(e.theme);return Object.keys(e).map(i=>fc(e,r,i,n)).reduce(zo,{})}function Ne(e){return As(e,hn)}Ne.propTypes=process.env.NODE_ENV!=="production"?hn.reduce((e,r)=>(e[r]=vr,e),{}):{};Ne.filterProps=hn;function Le(e){return As(e,mn)}Le.propTypes=process.env.NODE_ENV!=="production"?mn.reduce((e,r)=>(e[r]=vr,e),{}):{};Le.filterProps=mn;process.env.NODE_ENV!=="production"&&mc.reduce((e,r)=>(e[r]=vr,e),{});function Rs(e=8,r=fi({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(a=>{const c=r(a);return typeof c=="number"?`${c}px`:c}).join(" "));return n.mui=!0,n}function xn(...e){const r=e.reduce((i,s)=>(s.filterProps.forEach(a=>{i[a]=s}),i),{}),n=i=>Object.keys(i).reduce((s,a)=>r[a]?zo(s,r[a](i)):s,{});return n.propTypes=process.env.NODE_ENV!=="production"?e.reduce((i,s)=>Object.assign(i,s.propTypes),{}):{},n.filterProps=e.reduce((i,s)=>i.concat(s.filterProps),[]),n}function zt(e){return typeof e!="number"?e:`${e}px solid`}function It(e,r){return Ve({prop:e,themeKey:"borders",transform:r})}const gc=It("border",zt),yc=It("borderTop",zt),bc=It("borderRight",zt),vc=It("borderBottom",zt),Sc=It("borderLeft",zt),Cc=It("borderColor"),wc=It("borderTopColor"),jc=It("borderRightColor"),kc=It("borderBottomColor"),zc=It("borderLeftColor"),Tc=It("outline",zt),Bc=It("outlineColor"),fn=e=>{if(e.borderRadius!==void 0&&e.borderRadius!==null){const r=Eo(e.theme,"shape.borderRadius",4,"borderRadius"),n=i=>({borderRadius:Do(r,i)});return sr(e,e.borderRadius,n)}return null};fn.propTypes=process.env.NODE_ENV!=="production"?{borderRadius:vr}:{};fn.filterProps=["borderRadius"];xn(gc,yc,bc,vc,Sc,Cc,wc,jc,kc,zc,fn,Tc,Bc);const gn=e=>{if(e.gap!==void 0&&e.gap!==null){const r=Eo(e.theme,"spacing",8,"gap"),n=i=>({gap:Do(r,i)});return sr(e,e.gap,n)}return null};gn.propTypes=process.env.NODE_ENV!=="production"?{gap:vr}:{};gn.filterProps=["gap"];const yn=e=>{if(e.columnGap!==void 0&&e.columnGap!==null){const r=Eo(e.theme,"spacing",8,"columnGap"),n=i=>({columnGap:Do(r,i)});return sr(e,e.columnGap,n)}return null};yn.propTypes=process.env.NODE_ENV!=="production"?{columnGap:vr}:{};yn.filterProps=["columnGap"];const bn=e=>{if(e.rowGap!==void 0&&e.rowGap!==null){const r=Eo(e.theme,"spacing",8,"rowGap"),n=i=>({rowGap:Do(r,i)});return sr(e,e.rowGap,n)}return null};bn.propTypes=process.env.NODE_ENV!=="production"?{rowGap:vr}:{};bn.filterProps=["rowGap"];const Ic=Ve({prop:"gridColumn"}),Ec=Ve({prop:"gridRow"}),Dc=Ve({prop:"gridAutoFlow"}),_c=Ve({prop:"gridAutoColumns"}),$c=Ve({prop:"gridAutoRows"}),Oc=Ve({prop:"gridTemplateColumns"}),Mc=Ve({prop:"gridTemplateRows"}),Wc=Ve({prop:"gridTemplateAreas"}),Ac=Ve({prop:"gridArea"});xn(gn,yn,bn,Ic,Ec,Dc,_c,$c,Oc,Mc,Wc,Ac);function no(e,r){return r==="grey"?r:e}const Rc=Ve({prop:"color",themeKey:"palette",transform:no}),Pc=Ve({prop:"bgcolor",cssProperty:"backgroundColor",themeKey:"palette",transform:no}),Nc=Ve({prop:"backgroundColor",themeKey:"palette",transform:no});xn(Rc,Pc,Nc);function yt(e){return e<=1&&e!==0?`${e*100}%`:e}const Lc=Ve({prop:"width",transform:yt}),gi=e=>{if(e.maxWidth!==void 0&&e.maxWidth!==null){const r=n=>{var s,a,c,l,u;const i=((c=(a=(s=e.theme)==null?void 0:s.breakpoints)==null?void 0:a.values)==null?void 0:c[n])||un[n];return i?((u=(l=e.theme)==null?void 0:l.breakpoints)==null?void 0:u.unit)!=="px"?{maxWidth:`${i}${e.theme.breakpoints.unit}`}:{maxWidth:i}:{maxWidth:yt(n)}};return sr(e,e.maxWidth,r)}return null};gi.filterProps=["maxWidth"];const Fc=Ve({prop:"minWidth",transform:yt}),Vc=Ve({prop:"height",transform:yt}),Hc=Ve({prop:"maxHeight",transform:yt}),Gc=Ve({prop:"minHeight",transform:yt});Ve({prop:"size",cssProperty:"width",transform:yt});Ve({prop:"size",cssProperty:"height",transform:yt});const Uc=Ve({prop:"boxSizing"});xn(Lc,gi,Fc,Vc,Hc,Gc,Uc);const vn={border:{themeKey:"borders",transform:zt},borderTop:{themeKey:"borders",transform:zt},borderRight:{themeKey:"borders",transform:zt},borderBottom:{themeKey:"borders",transform:zt},borderLeft:{themeKey:"borders",transform:zt},borderColor:{themeKey:"palette"},borderTopColor:{themeKey:"palette"},borderRightColor:{themeKey:"palette"},borderBottomColor:{themeKey:"palette"},borderLeftColor:{themeKey:"palette"},outline:{themeKey:"borders",transform:zt},outlineColor:{themeKey:"palette"},borderRadius:{themeKey:"shape.borderRadius",style:fn},color:{themeKey:"palette",transform:no},bgcolor:{themeKey:"palette",cssProperty:"backgroundColor",transform:no},backgroundColor:{themeKey:"palette",transform:no},p:{style:Le},pt:{style:Le},pr:{style:Le},pb:{style:Le},pl:{style:Le},px:{style:Le},py:{style:Le},padding:{style:Le},paddingTop:{style:Le},paddingRight:{style:Le},paddingBottom:{style:Le},paddingLeft:{style:Le},paddingX:{style:Le},paddingY:{style:Le},paddingInline:{style:Le},paddingInlineStart:{style:Le},paddingInlineEnd:{style:Le},paddingBlock:{style:Le},paddingBlockStart:{style:Le},paddingBlockEnd:{style:Le},m:{style:Ne},mt:{style:Ne},mr:{style:Ne},mb:{style:Ne},ml:{style:Ne},mx:{style:Ne},my:{style:Ne},margin:{style:Ne},marginTop:{style:Ne},marginRight:{style:Ne},marginBottom:{style:Ne},marginLeft:{style:Ne},marginX:{style:Ne},marginY:{style:Ne},marginInline:{style:Ne},marginInlineStart:{style:Ne},marginInlineEnd:{style:Ne},marginBlock:{style:Ne},marginBlockStart:{style:Ne},marginBlockEnd:{style:Ne},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:gn},rowGap:{style:bn},columnGap:{style:yn},gridColumn:{},gridRow:{},gridAutoFlow:{},gridAutoColumns:{},gridAutoRows:{},gridTemplateColumns:{},gridTemplateRows:{},gridTemplateAreas:{},gridArea:{},position:{},zIndex:{themeKey:"zIndex"},top:{},right:{},bottom:{},left:{},boxShadow:{themeKey:"shadows"},width:{transform:yt},maxWidth:{style:gi},minWidth:{transform:yt},height:{transform:yt},maxHeight:{transform:yt},minHeight:{transform:yt},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 Yc(...e){const r=e.reduce((i,s)=>i.concat(Object.keys(s)),[]),n=new Set(r);return e.every(i=>n.size===Object.keys(i).length)}function qc(e,r){return typeof e=="function"?e(r):e}function Jc(){function e(n,i,s,a){const c={[n]:i,theme:s},l=a[n];if(!l)return{[n]:i};const{cssProperty:u=n,themeKey:g,transform:f,style:m}=l;if(i==null)return null;if(g==="typography"&&i==="inherit")return{[n]:i};const v=pn(s,g)||{};return m?m(c):sr(c,i,B=>{let b=nn(v,f,B);return B===b&&typeof B=="string"&&(b=nn(v,f,`${n}${B==="default"?"":Ws(B)}`,B)),u===!1?b:{[u]:b}})}function r(n){const{sx:i,theme:s={},nested:a}=n||{};if(!i)return null;const c=s.unstable_sxConfig??vn;function l(u){let g=u;if(typeof u=="function")g=u(s);else if(typeof u!="object")return u;if(!g)return null;const f=cc(s.breakpoints),m=Object.keys(f);let v=f;return Object.keys(g).forEach(C=>{const B=qc(g[C],s);if(B!=null)if(typeof B=="object")if(c[C])v=zo(v,e(C,B,s,c));else{const b=sr({theme:s},B,y=>({[C]:y}));Yc(b,B)?v[C]=r({sx:B,theme:s,nested:!0}):v=zo(v,b)}else v=zo(v,e(C,B,s,c))}),!a&&s.modularCssLayers?{"@layer sx":qi(s,Ki(m,v))}:qi(s,Ki(m,v))}return Array.isArray(i)?i.map(l):l(i)}return r}const Sn=Jc();Sn.filterProps=["sx"];function Kc(e,r){var i;const n=this;if(n.vars){if(!((i=n.colorSchemes)!=null&&i[e])||typeof n.getColorSchemeSelector!="function")return{};let s=n.getColorSchemeSelector(e);return s==="&"?r:((s.includes("data-")||s.includes("."))&&(s=`*:where(${s.replace(/\s*&$/,"")}) &`),{[s]:r})}return n.palette.mode===e?r:{}}function Ps(e={},...r){const{breakpoints:n={},palette:i={},spacing:s,shape:a={},...c}=e,l=oc(n),u=Rs(s);let g=bt({breakpoints:l,direction:"ltr",components:{},palette:{mode:"light",...i},spacing:u,shape:{...ac,...a}},c);return g=sc(g),g.applyStyles=Kc,g=r.reduce((f,m)=>bt(f,m),g),g.unstable_sxConfig={...vn,...c==null?void 0:c.unstable_sxConfig},g.unstable_sx=function(m){return Sn({sx:m,theme:this})},g}function Xc(e){return Object.keys(e).length===0}function Qc(e=null){const r=an.useContext(ha.ThemeContext);return!r||Xc(r)?e:r}const Zc=Ps();function ed(e=Zc){return Qc(e)}const Qi=e=>e,td=()=>{let e=Qi;return{configure(r){e=r},generate(r){return e(r)},reset(){e=Qi}}},rd=td(),od={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 nd(e,r,n="Mui"){const i=od[r];return i?`${n}-${i}`:`${rd.generate(e)}-${r}`}function id(e,r=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(r,Math.min(e,n))}function yi(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}].`),id(e,r,n)}function sd(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,s)=>s<3?parseInt(i,16):Math.round(parseInt(i,16)/255*1e3)/1e3).join(", ")})`:""}function yr(e){if(e.type)return e;if(e.charAt(0)==="#")return yr(sd(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.
145
- The following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().`:Er(9,e));let i=e.substring(r+1,e.length-1),s;if(n==="color"){if(i=i.split(" "),s=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(s))throw new Error(process.env.NODE_ENV!=="production"?`MUI: unsupported \`${s}\` color space.
146
- The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rgb, rec-2020.`:Er(10,s))}else i=i.split(",");return i=i.map(a=>parseFloat(a)),{type:n,values:i,colorSpace:s}}const ad=e=>{const r=yr(e);return r.values.slice(0,3).map((n,i)=>r.type.includes("hsl")&&i!==0?`${n}%`:n).join(" ")},So=(e,r)=>{try{return ad(e)}catch{return r&&process.env.NODE_ENV!=="production"&&console.warn(r),e}};function Cn(e){const{type:r,colorSpace:n}=e;let{values:i}=e;return r.includes("rgb")?i=i.map((s,a)=>a<3?parseInt(s,10):s):r.includes("hsl")&&(i[1]=`${i[1]}%`,i[2]=`${i[2]}%`),r.includes("color")?i=`${n} ${i.join(" ")}`:i=`${i.join(", ")}`,`${r}(${i})`}function Ns(e){e=yr(e);const{values:r}=e,n=r[0],i=r[1]/100,s=r[2]/100,a=i*Math.min(s,1-s),c=(g,f=(g+n/30)%12)=>s-a*Math.max(Math.min(f-3,9-f,1),-1);let l="rgb";const u=[Math.round(c(0)*255),Math.round(c(8)*255),Math.round(c(4)*255)];return e.type==="hsla"&&(l+="a",u.push(r[3])),Cn({type:l,values:u})}function ri(e){e=yr(e);let r=e.type==="hsl"||e.type==="hsla"?yr(Ns(e)).values:e.values;return r=r.map(n=>(e.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 Zi(e,r){const n=ri(e),i=ri(r);return(Math.max(n,i)+.05)/(Math.min(n,i)+.05)}function $(e,r){return e=yr(e),r=yi(r),(e.type==="rgb"||e.type==="hsl")&&(e.type+="a"),e.type==="color"?e.values[3]=`/${r}`:e.values[3]=r,Cn(e)}function Br(e,r,n){try{return $(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function wn(e,r){if(e=yr(e),r=yi(r),e.type.includes("hsl"))e.values[2]*=1-r;else if(e.type.includes("rgb")||e.type.includes("color"))for(let n=0;n<3;n+=1)e.values[n]*=1-r;return Cn(e)}function De(e,r,n){try{return wn(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function jn(e,r){if(e=yr(e),r=yi(r),e.type.includes("hsl"))e.values[2]+=(100-e.values[2])*r;else if(e.type.includes("rgb"))for(let n=0;n<3;n+=1)e.values[n]+=(255-e.values[n])*r;else if(e.type.includes("color"))for(let n=0;n<3;n+=1)e.values[n]+=(1-e.values[n])*r;return Cn(e)}function _e(e,r,n){try{return jn(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function ld(e,r=.15){return ri(e)>.5?wn(e,r):jn(e,r)}function qo(e,r,n){try{return ld(e,r)}catch{return e}}function cd(e=""){function r(...i){if(!i.length)return"";const s=i[0];return typeof s=="string"&&!s.match(/(#|\(|\)|(-?(\d*\.)?\d+)(px|em|%|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc))|^(-?(\d*\.)?\d+)$|(\d+ \d+ \d+)/)?`, var(--${e?`${e}-`:""}${s}${r(...i.slice(1))})`:`, ${s}`}return(i,...s)=>`var(--${e?`${e}-`:""}${i}${r(...s)})`}const es=(e,r,n,i=[])=>{let s=e;r.forEach((a,c)=>{c===r.length-1?Array.isArray(s)?s[Number(a)]=n:s&&typeof s=="object"&&(s[a]=n):s&&typeof s=="object"&&(s[a]||(s[a]=i.includes(a)?[]:{}),s=s[a])})},dd=(e,r,n)=>{function i(s,a=[],c=[]){Object.entries(s).forEach(([l,u])=>{(!n||n&&!n([...a,l]))&&u!=null&&(typeof u=="object"&&Object.keys(u).length>0?i(u,[...a,l],Array.isArray(u)?[...c,l]:c):r([...a,l],u,c))})}i(e)},ud=(e,r)=>typeof r=="number"?["lineHeight","fontWeight","opacity","zIndex"].some(i=>e.includes(i))||e[e.length-1].toLowerCase().includes("opacity")?r:`${r}px`:r;function Kn(e,r){const{prefix:n,shouldSkipGeneratingVar:i}=r||{},s={},a={},c={};return dd(e,(l,u,g)=>{if((typeof u=="string"||typeof u=="number")&&(!i||!i(l,u))){const f=`--${n?`${n}-`:""}${l.join("-")}`,m=ud(l,u);Object.assign(s,{[f]:m}),es(a,l,`var(${f})`,g),es(c,l,`var(${f}, ${m})`,g)}},l=>l[0]==="vars"),{css:s,vars:a,varsWithDefaults:c}}function pd(e,r={}){const{getSelector:n=z,disableCssColorScheme:i,colorSchemeSelector:s,enableContrastVars:a}=r,{colorSchemes:c={},components:l,defaultColorScheme:u="light",...g}=e,{vars:f,css:m,varsWithDefaults:v}=Kn(g,r);let C=v;const B={},{[u]:b,...y}=c;if(Object.entries(y||{}).forEach(([E,S])=>{const{vars:R,css:q,varsWithDefaults:T}=Kn(S,r);C=bt(C,T),B[E]={css:q,vars:R}}),b){const{css:E,vars:S,varsWithDefaults:R}=Kn(b,r);C=bt(C,R),B[u]={css:E,vars:S}}function z(E,S){var q,T;let R=s;if(s==="class"&&(R=".%s"),s==="data"&&(R="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(R=`[${s}="%s"]`),E){if(R==="media")return e.defaultColorScheme===E?":root":{[`@media (prefers-color-scheme: ${((T=(q=c[E])==null?void 0:q.palette)==null?void 0:T.mode)||E})`]:{":root":S}};if(R)return e.defaultColorScheme===E?`:root, ${R.replace("%s",String(E))}`:R.replace("%s",String(E))}return":root"}return{vars:C,generateThemeVars:()=>{let E={...f};return Object.entries(B).forEach(([,{vars:S}])=>{E=bt(E,S)}),E},generateStyleSheets:()=>{var F,X;const E=[],S=e.defaultColorScheme||"light";function R(W,h){Object.keys(h).length&&E.push(typeof W=="string"?{[W]:{...h}}:W)}R(n(void 0,{...m}),m);const{[S]:q,...T}=B;if(q){const{css:W}=q,h=(X=(F=c[S])==null?void 0:F.palette)==null?void 0:X.mode,I=!i&&h?{colorScheme:h,...W}:{...W};R(n(S,{...I}),I)}return Object.entries(T).forEach(([W,{css:h}])=>{var d,oe;const I=(oe=(d=c[W])==null?void 0:d.palette)==null?void 0:oe.mode,N=!i&&I?{colorScheme:I,...h}:{...h};R(n(W,{...N}),N)}),a&&E.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)"}}),E}}}function hd(e){return function(n){return e==="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})`):e?e.startsWith("data-")&&!e.includes("%s")?`[${e}="${n}"] &`:e==="class"?`.${n} &`:e==="data"?`[data-${n}] &`:`${e.replace("%s",n)} &`:"&"}}const Bo={black:"#000",white:"#fff"},md={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"},Qr={50:"#f3e5f5",200:"#ce93d8",300:"#ba68c8",400:"#ab47bc",500:"#9c27b0",700:"#7b1fa2"},Zr={300:"#e57373",400:"#ef5350",500:"#f44336",700:"#d32f2f",800:"#c62828"},yo={300:"#ffb74d",400:"#ffa726",500:"#ff9800",700:"#f57c00",900:"#e65100"},eo={50:"#e3f2fd",200:"#90caf9",400:"#42a5f5",700:"#1976d2",800:"#1565c0"},to={300:"#4fc3f7",400:"#29b6f6",500:"#03a9f4",700:"#0288d1",900:"#01579b"},ro={300:"#81c784",400:"#66bb6a",500:"#4caf50",700:"#388e3c",800:"#2e7d32",900:"#1b5e20"};function Ls(){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:Bo.white,default:Bo.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 Fs=Ls();function Vs(){return{text:{primary:Bo.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:Bo.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 oi=Vs();function ts(e,r,n,i){const s=i.light||i,a=i.dark||i*1.5;e[r]||(e.hasOwnProperty(n)?e[r]=e[n]:r==="light"?e.light=jn(e.main,s):r==="dark"&&(e.dark=wn(e.main,a)))}function rs(e,r,n,i,s){const a=s.light||s,c=s.dark||s*1.5;r[n]||(r.hasOwnProperty(i)?r[n]=r[i]:n==="light"?r.light=`color-mix(in ${e}, ${r.main}, #fff ${(a*100).toFixed(0)}%)`:n==="dark"&&(r.dark=`color-mix(in ${e}, ${r.main}, #000 ${(c*100).toFixed(0)}%)`))}function xd(e="light"){return e==="dark"?{main:eo[200],light:eo[50],dark:eo[400]}:{main:eo[700],light:eo[400],dark:eo[800]}}function fd(e="light"){return e==="dark"?{main:Qr[200],light:Qr[50],dark:Qr[400]}:{main:Qr[500],light:Qr[300],dark:Qr[700]}}function gd(e="light"){return e==="dark"?{main:Zr[500],light:Zr[300],dark:Zr[700]}:{main:Zr[700],light:Zr[400],dark:Zr[800]}}function yd(e="light"){return e==="dark"?{main:to[400],light:to[300],dark:to[700]}:{main:to[700],light:to[500],dark:to[900]}}function bd(e="light"){return e==="dark"?{main:ro[400],light:ro[300],dark:ro[700]}:{main:ro[800],light:ro[500],dark:ro[900]}}function vd(e="light"){return e==="dark"?{main:yo[400],light:yo[300],dark:yo[700]}:{main:"#ed6c02",light:yo[500],dark:yo[900]}}function Sd(e){return`oklch(from ${e} var(--__l) 0 h / var(--__a))`}function bi(e){const{mode:r="light",contrastThreshold:n=3,tonalOffset:i=.2,colorSpace:s,...a}=e,c=e.primary||xd(r),l=e.secondary||fd(r),u=e.error||gd(r),g=e.info||yd(r),f=e.success||bd(r),m=e.warning||vd(r);function v(y){if(s)return Sd(y);const z=Zi(y,oi.text.primary)>=n?oi.text.primary:Fs.text.primary;if(process.env.NODE_ENV!=="production"){const x=Zi(y,z);x<3&&console.error([`MUI: The contrast ratio of ${x}:1 for ${z} on ${y}`,"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(`
147
- `))}return z}const C=({color:y,name:z,mainShade:x=500,lightShade:j=300,darkShade:E=700})=>{if(y={...y},!y.main&&y[x]&&(y.main=y[x]),!y.hasOwnProperty("main"))throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${z?` (${z})`:""} provided to augmentColor(color) is invalid.
148
- The color object needs to have a \`main\` property or a \`${x}\` property.`:Er(11,z?` (${z})`:"",x));if(typeof y.main!="string")throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${z?` (${z})`:""} provided to augmentColor(color) is invalid.
149
- \`color.main\` should be a string, but \`${JSON.stringify(y.main)}\` was provided instead.
144
+ `)),()=>{})}function xi(e){return Eo(e,"spacing",8,"spacing")}function Do(e,r){return typeof r=="string"||r==null?r:e(r)}function gc(e,r){return n=>e.reduce((i,s)=>(i[s]=Do(r,n),i),{})}function yc(e,r,n,i){if(!r.includes(n))return null;const s=mc(n),a=gc(s,i),c=e[n];return nr(e,c,a)}function Ps(e,r){const n=xi(e.theme);return Object.keys(e).map(i=>yc(e,r,i,n)).reduce(zo,{})}function Fe(e){return Ps(e,fn)}Fe.propTypes=process.env.NODE_ENV!=="production"?fn.reduce((e,r)=>(e[r]=yr,e),{}):{};Fe.filterProps=fn;function Ve(e){return Ps(e,mn)}Ve.propTypes=process.env.NODE_ENV!=="production"?mn.reduce((e,r)=>(e[r]=yr,e),{}):{};Ve.filterProps=mn;process.env.NODE_ENV!=="production"&&xc.reduce((e,r)=>(e[r]=yr,e),{});function Ns(e=8,r=xi({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(a=>{const c=r(a);return typeof c=="number"?`${c}px`:c}).join(" "));return n.mui=!0,n}function xn(...e){const r=e.reduce((i,s)=>(s.filterProps.forEach(a=>{i[a]=s}),i),{}),n=i=>Object.keys(i).reduce((s,a)=>r[a]?zo(s,r[a](i)):s,{});return n.propTypes=process.env.NODE_ENV!=="production"?e.reduce((i,s)=>Object.assign(i,s.propTypes),{}):{},n.filterProps=e.reduce((i,s)=>i.concat(s.filterProps),[]),n}function zt(e){return typeof e!="number"?e:`${e}px solid`}function It(e,r){return Ue({prop:e,themeKey:"borders",transform:r})}const bc=It("border",zt),vc=It("borderTop",zt),Sc=It("borderRight",zt),Cc=It("borderBottom",zt),wc=It("borderLeft",zt),jc=It("borderColor"),kc=It("borderTopColor"),zc=It("borderRightColor"),Tc=It("borderBottomColor"),Bc=It("borderLeftColor"),Ic=It("outline",zt),Ec=It("outlineColor"),gn=e=>{if(e.borderRadius!==void 0&&e.borderRadius!==null){const r=Eo(e.theme,"shape.borderRadius",4,"borderRadius"),n=i=>({borderRadius:Do(r,i)});return nr(e,e.borderRadius,n)}return null};gn.propTypes=process.env.NODE_ENV!=="production"?{borderRadius:yr}:{};gn.filterProps=["borderRadius"];xn(bc,vc,Sc,Cc,wc,jc,kc,zc,Tc,Bc,gn,Ic,Ec);const yn=e=>{if(e.gap!==void 0&&e.gap!==null){const r=Eo(e.theme,"spacing",8,"gap"),n=i=>({gap:Do(r,i)});return nr(e,e.gap,n)}return null};yn.propTypes=process.env.NODE_ENV!=="production"?{gap:yr}:{};yn.filterProps=["gap"];const bn=e=>{if(e.columnGap!==void 0&&e.columnGap!==null){const r=Eo(e.theme,"spacing",8,"columnGap"),n=i=>({columnGap:Do(r,i)});return nr(e,e.columnGap,n)}return null};bn.propTypes=process.env.NODE_ENV!=="production"?{columnGap:yr}:{};bn.filterProps=["columnGap"];const vn=e=>{if(e.rowGap!==void 0&&e.rowGap!==null){const r=Eo(e.theme,"spacing",8,"rowGap"),n=i=>({rowGap:Do(r,i)});return nr(e,e.rowGap,n)}return null};vn.propTypes=process.env.NODE_ENV!=="production"?{rowGap:yr}:{};vn.filterProps=["rowGap"];const Dc=Ue({prop:"gridColumn"}),_c=Ue({prop:"gridRow"}),$c=Ue({prop:"gridAutoFlow"}),Oc=Ue({prop:"gridAutoColumns"}),Mc=Ue({prop:"gridAutoRows"}),Ac=Ue({prop:"gridTemplateColumns"}),Wc=Ue({prop:"gridTemplateRows"}),Rc=Ue({prop:"gridTemplateAreas"}),Pc=Ue({prop:"gridArea"});xn(yn,bn,vn,Dc,_c,$c,Oc,Mc,Ac,Wc,Rc,Pc);function so(e,r){return r==="grey"?r:e}const Nc=Ue({prop:"color",themeKey:"palette",transform:so}),Lc=Ue({prop:"bgcolor",cssProperty:"backgroundColor",themeKey:"palette",transform:so}),Fc=Ue({prop:"backgroundColor",themeKey:"palette",transform:so});xn(Nc,Lc,Fc);function gt(e){return e<=1&&e!==0?`${e*100}%`:e}const Vc=Ue({prop:"width",transform:gt}),gi=e=>{if(e.maxWidth!==void 0&&e.maxWidth!==null){const r=n=>{var s,a,c,l,u;const i=((c=(a=(s=e.theme)==null?void 0:s.breakpoints)==null?void 0:a.values)==null?void 0:c[n])||pn[n];return i?((u=(l=e.theme)==null?void 0:l.breakpoints)==null?void 0:u.unit)!=="px"?{maxWidth:`${i}${e.theme.breakpoints.unit}`}:{maxWidth:i}:{maxWidth:gt(n)}};return nr(e,e.maxWidth,r)}return null};gi.filterProps=["maxWidth"];const Hc=Ue({prop:"minWidth",transform:gt}),Uc=Ue({prop:"height",transform:gt}),Gc=Ue({prop:"maxHeight",transform:gt}),Yc=Ue({prop:"minHeight",transform:gt});Ue({prop:"size",cssProperty:"width",transform:gt});Ue({prop:"size",cssProperty:"height",transform:gt});const qc=Ue({prop:"boxSizing"});xn(Vc,gi,Hc,Uc,Gc,Yc,qc);const Sn={border:{themeKey:"borders",transform:zt},borderTop:{themeKey:"borders",transform:zt},borderRight:{themeKey:"borders",transform:zt},borderBottom:{themeKey:"borders",transform:zt},borderLeft:{themeKey:"borders",transform:zt},borderColor:{themeKey:"palette"},borderTopColor:{themeKey:"palette"},borderRightColor:{themeKey:"palette"},borderBottomColor:{themeKey:"palette"},borderLeftColor:{themeKey:"palette"},outline:{themeKey:"borders",transform:zt},outlineColor:{themeKey:"palette"},borderRadius:{themeKey:"shape.borderRadius",style:gn},color:{themeKey:"palette",transform:so},bgcolor:{themeKey:"palette",cssProperty:"backgroundColor",transform:so},backgroundColor:{themeKey:"palette",transform:so},p:{style:Ve},pt:{style:Ve},pr:{style:Ve},pb:{style:Ve},pl:{style:Ve},px:{style:Ve},py:{style:Ve},padding:{style:Ve},paddingTop:{style:Ve},paddingRight:{style:Ve},paddingBottom:{style:Ve},paddingLeft:{style:Ve},paddingX:{style:Ve},paddingY:{style:Ve},paddingInline:{style:Ve},paddingInlineStart:{style:Ve},paddingInlineEnd:{style:Ve},paddingBlock:{style:Ve},paddingBlockStart:{style:Ve},paddingBlockEnd:{style:Ve},m:{style:Fe},mt:{style:Fe},mr:{style:Fe},mb:{style:Fe},ml:{style:Fe},mx:{style:Fe},my:{style:Fe},margin:{style:Fe},marginTop:{style:Fe},marginRight:{style:Fe},marginBottom:{style:Fe},marginLeft:{style:Fe},marginX:{style:Fe},marginY:{style:Fe},marginInline:{style:Fe},marginInlineStart:{style:Fe},marginInlineEnd:{style:Fe},marginBlock:{style:Fe},marginBlockStart:{style:Fe},marginBlockEnd:{style:Fe},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:yn},rowGap:{style:vn},columnGap:{style:bn},gridColumn:{},gridRow:{},gridAutoFlow:{},gridAutoColumns:{},gridAutoRows:{},gridTemplateColumns:{},gridTemplateRows:{},gridTemplateAreas:{},gridArea:{},position:{},zIndex:{themeKey:"zIndex"},top:{},right:{},bottom:{},left:{},boxShadow:{themeKey:"shadows"},width:{transform:gt},maxWidth:{style:gi},minWidth:{transform:gt},height:{transform:gt},maxHeight:{transform:gt},minHeight:{transform:gt},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 Jc(...e){const r=e.reduce((i,s)=>i.concat(Object.keys(s)),[]),n=new Set(r);return e.every(i=>n.size===Object.keys(i).length)}function Kc(e,r){return typeof e=="function"?e(r):e}function Xc(){function e(n,i,s,a){const c={[n]:i,theme:s},l=a[n];if(!l)return{[n]:i};const{cssProperty:u=n,themeKey:g,transform:x,style:f}=l;if(i==null)return null;if(g==="typography"&&i==="inherit")return{[n]:i};const S=hn(s,g)||{};return f?f(c):nr(c,i,B=>{let v=sn(S,x,B);return B===v&&typeof B=="string"&&(v=sn(S,x,`${n}${B==="default"?"":Rs(B)}`,B)),u===!1?v:{[u]:v}})}function r(n){const{sx:i,theme:s={},nested:a}=n||{};if(!i)return null;const c=s.unstable_sxConfig??Sn;function l(u){let g=u;if(typeof u=="function")g=u(s);else if(typeof u!="object")return u;if(!g)return null;const x=uc(s.breakpoints),f=Object.keys(x);let S=x;return Object.keys(g).forEach(C=>{const B=Kc(g[C],s);if(B!=null)if(typeof B=="object")if(c[C])S=zo(S,e(C,B,s,c));else{const v=nr({theme:s},B,m=>({[C]:m}));Jc(v,B)?S[C]=r({sx:B,theme:s,nested:!0}):S=zo(S,v)}else S=zo(S,e(C,B,s,c))}),!a&&s.modularCssLayers?{"@layer sx":Ki(s,Qi(f,S))}:Ki(s,Qi(f,S))}return Array.isArray(i)?i.map(l):l(i)}return r}const Cn=Xc();Cn.filterProps=["sx"];function Qc(e,r){var i;const n=this;if(n.vars){if(!((i=n.colorSchemes)!=null&&i[e])||typeof n.getColorSchemeSelector!="function")return{};let s=n.getColorSchemeSelector(e);return s==="&"?r:((s.includes("data-")||s.includes("."))&&(s=`*:where(${s.replace(/\s*&$/,"")}) &`),{[s]:r})}return n.palette.mode===e?r:{}}function Ls(e={},...r){const{breakpoints:n={},palette:i={},spacing:s,shape:a={},...c}=e,l=ic(n),u=Ns(s);let g=yt({breakpoints:l,direction:"ltr",components:{},palette:{mode:"light",...i},spacing:u,shape:{...cc,...a}},c);return g=lc(g),g.applyStyles=Qc,g=r.reduce((x,f)=>yt(x,f),g),g.unstable_sxConfig={...Sn,...c==null?void 0:c.unstable_sxConfig},g.unstable_sx=function(f){return Cn({sx:f,theme:this})},g}function Zc(e){return Object.keys(e).length===0}function ed(e=null){const r=ln.useContext(ma.ThemeContext);return!r||Zc(r)?e:r}const td=Ls();function rd(e=td){return ed(e)}const es=e=>e,od=()=>{let e=es;return{configure(r){e=r},generate(r){return e(r)},reset(){e=es}}},nd=od(),id={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 sd(e,r,n="Mui"){const i=id[r];return i?`${n}-${i}`:`${nd.generate(e)}-${r}`}function ad(e,r=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(r,Math.min(e,n))}function yi(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}].`),ad(e,r,n)}function ld(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,s)=>s<3?parseInt(i,16):Math.round(parseInt(i,16)/255*1e3)/1e3).join(", ")})`:""}function xr(e){if(e.type)return e;if(e.charAt(0)==="#")return xr(ld(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.
145
+ The following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().`:Ir(9,e));let i=e.substring(r+1,e.length-1),s;if(n==="color"){if(i=i.split(" "),s=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(s))throw new Error(process.env.NODE_ENV!=="production"?`MUI: unsupported \`${s}\` color space.
146
+ The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rgb, rec-2020.`:Ir(10,s))}else i=i.split(",");return i=i.map(a=>parseFloat(a)),{type:n,values:i,colorSpace:s}}const cd=e=>{const r=xr(e);return r.values.slice(0,3).map((n,i)=>r.type.includes("hsl")&&i!==0?`${n}%`:n).join(" ")},So=(e,r)=>{try{return cd(e)}catch{return r&&process.env.NODE_ENV!=="production"&&console.warn(r),e}};function wn(e){const{type:r,colorSpace:n}=e;let{values:i}=e;return r.includes("rgb")?i=i.map((s,a)=>a<3?parseInt(s,10):s):r.includes("hsl")&&(i[1]=`${i[1]}%`,i[2]=`${i[2]}%`),r.includes("color")?i=`${n} ${i.join(" ")}`:i=`${i.join(", ")}`,`${r}(${i})`}function Fs(e){e=xr(e);const{values:r}=e,n=r[0],i=r[1]/100,s=r[2]/100,a=i*Math.min(s,1-s),c=(g,x=(g+n/30)%12)=>s-a*Math.max(Math.min(x-3,9-x,1),-1);let l="rgb";const u=[Math.round(c(0)*255),Math.round(c(8)*255),Math.round(c(4)*255)];return e.type==="hsla"&&(l+="a",u.push(r[3])),wn({type:l,values:u})}function ri(e){e=xr(e);let r=e.type==="hsl"||e.type==="hsla"?xr(Fs(e)).values:e.values;return r=r.map(n=>(e.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 ts(e,r){const n=ri(e),i=ri(r);return(Math.max(n,i)+.05)/(Math.min(n,i)+.05)}function _(e,r){return e=xr(e),r=yi(r),(e.type==="rgb"||e.type==="hsl")&&(e.type+="a"),e.type==="color"?e.values[3]=`/${r}`:e.values[3]=r,wn(e)}function Tr(e,r,n){try{return _(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function jn(e,r){if(e=xr(e),r=yi(r),e.type.includes("hsl"))e.values[2]*=1-r;else if(e.type.includes("rgb")||e.type.includes("color"))for(let n=0;n<3;n+=1)e.values[n]*=1-r;return wn(e)}function Ie(e,r,n){try{return jn(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function kn(e,r){if(e=xr(e),r=yi(r),e.type.includes("hsl"))e.values[2]+=(100-e.values[2])*r;else if(e.type.includes("rgb"))for(let n=0;n<3;n+=1)e.values[n]+=(255-e.values[n])*r;else if(e.type.includes("color"))for(let n=0;n<3;n+=1)e.values[n]+=(1-e.values[n])*r;return wn(e)}function Ee(e,r,n){try{return kn(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function dd(e,r=.15){return ri(e)>.5?jn(e,r):kn(e,r)}function Jo(e,r,n){try{return dd(e,r)}catch{return e}}function ud(e=""){function r(...i){if(!i.length)return"";const s=i[0];return typeof s=="string"&&!s.match(/(#|\(|\)|(-?(\d*\.)?\d+)(px|em|%|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc))|^(-?(\d*\.)?\d+)$|(\d+ \d+ \d+)/)?`, var(--${e?`${e}-`:""}${s}${r(...i.slice(1))})`:`, ${s}`}return(i,...s)=>`var(--${e?`${e}-`:""}${i}${r(...s)})`}const rs=(e,r,n,i=[])=>{let s=e;r.forEach((a,c)=>{c===r.length-1?Array.isArray(s)?s[Number(a)]=n:s&&typeof s=="object"&&(s[a]=n):s&&typeof s=="object"&&(s[a]||(s[a]=i.includes(a)?[]:{}),s=s[a])})},pd=(e,r,n)=>{function i(s,a=[],c=[]){Object.entries(s).forEach(([l,u])=>{(!n||n&&!n([...a,l]))&&u!=null&&(typeof u=="object"&&Object.keys(u).length>0?i(u,[...a,l],Array.isArray(u)?[...c,l]:c):r([...a,l],u,c))})}i(e)},hd=(e,r)=>typeof r=="number"?["lineHeight","fontWeight","opacity","zIndex"].some(i=>e.includes(i))||e[e.length-1].toLowerCase().includes("opacity")?r:`${r}px`:r;function Kn(e,r){const{prefix:n,shouldSkipGeneratingVar:i}=r||{},s={},a={},c={};return pd(e,(l,u,g)=>{if((typeof u=="string"||typeof u=="number")&&(!i||!i(l,u))){const x=`--${n?`${n}-`:""}${l.join("-")}`,f=hd(l,u);Object.assign(s,{[x]:f}),rs(a,l,`var(${x})`,g),rs(c,l,`var(${x}, ${f})`,g)}},l=>l[0]==="vars"),{css:s,vars:a,varsWithDefaults:c}}function fd(e,r={}){const{getSelector:n=T,disableCssColorScheme:i,colorSchemeSelector:s,enableContrastVars:a}=r,{colorSchemes:c={},components:l,defaultColorScheme:u="light",...g}=e,{vars:x,css:f,varsWithDefaults:S}=Kn(g,r);let C=S;const B={},{[u]:v,...m}=c;if(Object.entries(m||{}).forEach(([I,b])=>{const{vars:R,css:H,varsWithDefaults:E}=Kn(b,r);C=yt(C,E),B[I]={css:H,vars:R}}),v){const{css:I,vars:b,varsWithDefaults:R}=Kn(v,r);C=yt(C,R),B[u]={css:I,vars:b}}function T(I,b){var H,E;let R=s;if(s==="class"&&(R=".%s"),s==="data"&&(R="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(R=`[${s}="%s"]`),I){if(R==="media")return e.defaultColorScheme===I?":root":{[`@media (prefers-color-scheme: ${((E=(H=c[I])==null?void 0:H.palette)==null?void 0:E.mode)||I})`]:{":root":b}};if(R)return e.defaultColorScheme===I?`:root, ${R.replace("%s",String(I))}`:R.replace("%s",String(I))}return":root"}return{vars:C,generateThemeVars:()=>{let I={...x};return Object.entries(B).forEach(([,{vars:b}])=>{I=yt(I,b)}),I},generateStyleSheets:()=>{var G,Z;const I=[],b=e.defaultColorScheme||"light";function R(O,y){Object.keys(y).length&&I.push(typeof O=="string"?{[O]:{...y}}:O)}R(n(void 0,{...f}),f);const{[b]:H,...E}=B;if(H){const{css:O}=H,y=(Z=(G=c[b])==null?void 0:G.palette)==null?void 0:Z.mode,w=!i&&y?{colorScheme:y,...O}:{...O};R(n(b,{...w}),w)}return Object.entries(E).forEach(([O,{css:y}])=>{var te,d;const w=(d=(te=c[O])==null?void 0:te.palette)==null?void 0:d.mode,P=!i&&w?{colorScheme:w,...y}:{...y};R(n(O,{...P}),P)}),a&&I.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)"}}),I}}}function md(e){return function(n){return e==="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})`):e?e.startsWith("data-")&&!e.includes("%s")?`[${e}="${n}"] &`:e==="class"?`.${n} &`:e==="data"?`[data-${n}] &`:`${e.replace("%s",n)} &`:"&"}}const Bo={black:"#000",white:"#fff"},xd={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"},eo={50:"#f3e5f5",200:"#ce93d8",300:"#ba68c8",400:"#ab47bc",500:"#9c27b0",700:"#7b1fa2"},to={300:"#e57373",400:"#ef5350",500:"#f44336",700:"#d32f2f",800:"#c62828"},yo={300:"#ffb74d",400:"#ffa726",500:"#ff9800",700:"#f57c00",900:"#e65100"},ro={50:"#e3f2fd",200:"#90caf9",400:"#42a5f5",700:"#1976d2",800:"#1565c0"},oo={300:"#4fc3f7",400:"#29b6f6",500:"#03a9f4",700:"#0288d1",900:"#01579b"},no={300:"#81c784",400:"#66bb6a",500:"#4caf50",700:"#388e3c",800:"#2e7d32",900:"#1b5e20"};function Vs(){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:Bo.white,default:Bo.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 Hs=Vs();function Us(){return{text:{primary:Bo.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:Bo.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 oi=Us();function os(e,r,n,i){const s=i.light||i,a=i.dark||i*1.5;e[r]||(e.hasOwnProperty(n)?e[r]=e[n]:r==="light"?e.light=kn(e.main,s):r==="dark"&&(e.dark=jn(e.main,a)))}function ns(e,r,n,i,s){const a=s.light||s,c=s.dark||s*1.5;r[n]||(r.hasOwnProperty(i)?r[n]=r[i]:n==="light"?r.light=`color-mix(in ${e}, ${r.main}, #fff ${(a*100).toFixed(0)}%)`:n==="dark"&&(r.dark=`color-mix(in ${e}, ${r.main}, #000 ${(c*100).toFixed(0)}%)`))}function gd(e="light"){return e==="dark"?{main:ro[200],light:ro[50],dark:ro[400]}:{main:ro[700],light:ro[400],dark:ro[800]}}function yd(e="light"){return e==="dark"?{main:eo[200],light:eo[50],dark:eo[400]}:{main:eo[500],light:eo[300],dark:eo[700]}}function bd(e="light"){return e==="dark"?{main:to[500],light:to[300],dark:to[700]}:{main:to[700],light:to[400],dark:to[800]}}function vd(e="light"){return e==="dark"?{main:oo[400],light:oo[300],dark:oo[700]}:{main:oo[700],light:oo[500],dark:oo[900]}}function Sd(e="light"){return e==="dark"?{main:no[400],light:no[300],dark:no[700]}:{main:no[800],light:no[500],dark:no[900]}}function Cd(e="light"){return e==="dark"?{main:yo[400],light:yo[300],dark:yo[700]}:{main:"#ed6c02",light:yo[500],dark:yo[900]}}function wd(e){return`oklch(from ${e} var(--__l) 0 h / var(--__a))`}function bi(e){const{mode:r="light",contrastThreshold:n=3,tonalOffset:i=.2,colorSpace:s,...a}=e,c=e.primary||gd(r),l=e.secondary||yd(r),u=e.error||bd(r),g=e.info||vd(r),x=e.success||Sd(r),f=e.warning||Cd(r);function S(m){if(s)return wd(m);const T=ts(m,oi.text.primary)>=n?oi.text.primary:Hs.text.primary;if(process.env.NODE_ENV!=="production"){const h=ts(m,T);h<3&&console.error([`MUI: The contrast ratio of ${h}:1 for ${T} on ${m}`,"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(`
147
+ `))}return T}const C=({color:m,name:T,mainShade:h=500,lightShade:z=300,darkShade:I=700})=>{if(m={...m},!m.main&&m[h]&&(m.main=m[h]),!m.hasOwnProperty("main"))throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${T?` (${T})`:""} provided to augmentColor(color) is invalid.
148
+ The color object needs to have a \`main\` property or a \`${h}\` property.`:Ir(11,T?` (${T})`:"",h));if(typeof m.main!="string")throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${T?` (${T})`:""} provided to augmentColor(color) is invalid.
149
+ \`color.main\` should be a string, but \`${JSON.stringify(m.main)}\` was provided instead.
150
150
 
151
151
  Did you intend to use one of the following approaches?
152
152
 
@@ -158,17 +158,17 @@ const theme1 = createTheme({ palette: {
158
158
 
159
159
  const theme2 = createTheme({ palette: {
160
160
  primary: { main: green[500] },
161
- } });`:Er(12,z?` (${z})`:"",JSON.stringify(y.main)));return s?(rs(s,y,"light",j,i),rs(s,y,"dark",E,i)):(ts(y,"light",j,i),ts(y,"dark",E,i)),y.contrastText||(y.contrastText=v(y.main)),y};let B;return r==="light"?B=Ls():r==="dark"&&(B=Vs()),process.env.NODE_ENV!=="production"&&(B||console.error(`MUI: The palette mode \`${r}\` is not supported.`)),bt({common:{...Bo},mode:r,primary:C({color:c,name:"primary"}),secondary:C({color:l,name:"secondary",mainShade:"A400",lightShade:"A200",darkShade:"A700"}),error:C({color:u,name:"error"}),warning:C({color:m,name:"warning"}),info:C({color:g,name:"info"}),success:C({color:f,name:"success"}),grey:md,contrastThreshold:n,getContrastText:v,augmentColor:C,tonalOffset:i,...B},a)}function Cd(e){const r={};return Object.entries(e).forEach(i=>{const[s,a]=i;typeof a=="object"&&(r[s]=`${a.fontStyle?`${a.fontStyle} `:""}${a.fontVariant?`${a.fontVariant} `:""}${a.fontWeight?`${a.fontWeight} `:""}${a.fontStretch?`${a.fontStretch} `:""}${a.fontSize||""}${a.lineHeight?`/${a.lineHeight} `:""}${a.fontFamily||""}`)}),r}function wd(e,r){return{toolbar:{minHeight:56,[e.up("xs")]:{"@media (orientation: landscape)":{minHeight:48}},[e.up("sm")]:{minHeight:64}},...r}}function jd(e){return Math.round(e*1e5)/1e5}const os={textTransform:"uppercase"},ns='"Roboto", "Helvetica", "Arial", sans-serif';function kd(e,r){const{fontFamily:n=ns,fontSize:i=14,fontWeightLight:s=300,fontWeightRegular:a=400,fontWeightMedium:c=500,fontWeightBold:l=700,htmlFontSize:u=16,allVariants:g,pxToRem:f,...m}=typeof r=="function"?r(e):r;process.env.NODE_ENV!=="production"&&(typeof i!="number"&&console.error("MUI: `fontSize` is required to be a number."),typeof u!="number"&&console.error("MUI: `htmlFontSize` is required to be a number."));const v=i/14,C=f||(y=>`${y/u*v}rem`),B=(y,z,x,j,E)=>({fontFamily:n,fontWeight:y,fontSize:C(z),lineHeight:x,...n===ns?{letterSpacing:`${jd(j/z)}em`}:{},...E,...g}),b={h1:B(s,96,1.167,-1.5),h2:B(s,60,1.2,-.5),h3:B(a,48,1.167,0),h4:B(a,34,1.235,.25),h5:B(a,24,1.334,0),h6:B(c,20,1.6,.15),subtitle1:B(a,16,1.75,.15),subtitle2:B(c,14,1.57,.1),body1:B(a,16,1.5,.15),body2:B(a,14,1.43,.15),button:B(c,14,1.75,.4,os),caption:B(a,12,1.66,.4),overline:B(a,12,2.66,1,os),inherit:{fontFamily:"inherit",fontWeight:"inherit",fontSize:"inherit",lineHeight:"inherit",letterSpacing:"inherit"}};return bt({htmlFontSize:u,pxToRem:C,fontFamily:n,fontSize:i,fontWeightLight:s,fontWeightRegular:a,fontWeightMedium:c,fontWeightBold:l,...b},m,{clone:!1})}const zd=.2,Td=.14,Bd=.12;function Ae(...e){return[`${e[0]}px ${e[1]}px ${e[2]}px ${e[3]}px rgba(0,0,0,${zd})`,`${e[4]}px ${e[5]}px ${e[6]}px ${e[7]}px rgba(0,0,0,${Td})`,`${e[8]}px ${e[9]}px ${e[10]}px ${e[11]}px rgba(0,0,0,${Bd})`].join(",")}const Id=["none",Ae(0,2,1,-1,0,1,1,0,0,1,3,0),Ae(0,3,1,-2,0,2,2,0,0,1,5,0),Ae(0,3,3,-2,0,3,4,0,0,1,8,0),Ae(0,2,4,-1,0,4,5,0,0,1,10,0),Ae(0,3,5,-1,0,5,8,0,0,1,14,0),Ae(0,3,5,-1,0,6,10,0,0,1,18,0),Ae(0,4,5,-2,0,7,10,1,0,2,16,1),Ae(0,5,5,-3,0,8,10,1,0,3,14,2),Ae(0,5,6,-3,0,9,12,1,0,3,16,2),Ae(0,6,6,-3,0,10,14,1,0,4,18,3),Ae(0,6,7,-4,0,11,15,1,0,4,20,3),Ae(0,7,8,-4,0,12,17,2,0,5,22,4),Ae(0,7,8,-4,0,13,19,2,0,5,24,4),Ae(0,7,9,-4,0,14,21,2,0,5,26,4),Ae(0,8,9,-5,0,15,22,2,0,6,28,5),Ae(0,8,10,-5,0,16,24,2,0,6,30,5),Ae(0,8,11,-5,0,17,26,2,0,6,32,5),Ae(0,9,11,-5,0,18,28,2,0,7,34,6),Ae(0,9,12,-6,0,19,29,2,0,7,36,6),Ae(0,10,13,-6,0,20,31,3,0,8,38,7),Ae(0,10,13,-6,0,21,33,3,0,8,40,7),Ae(0,10,14,-6,0,22,35,3,0,8,42,7),Ae(0,11,14,-7,0,23,36,3,0,9,44,8),Ae(0,11,15,-7,0,24,38,3,0,9,46,8)],Ed={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)"},Dd={shortest:150,shorter:200,short:250,standard:300,complex:375,enteringScreen:225,leavingScreen:195};function is(e){return`${Math.round(e)}ms`}function _d(e){if(!e)return 0;const r=e/36;return Math.min(Math.round((4+15*r**.25+r/5)*10),3e3)}function $d(e){const r={...Ed,...e.easing},n={...Dd,...e.duration};return{getAutoHeightDuration:_d,create:(s=["all"],a={})=>{const{duration:c=n.standard,easing:l=r.easeInOut,delay:u=0,...g}=a;if(process.env.NODE_ENV!=="production"){const f=v=>typeof v=="string",m=v=>!Number.isNaN(parseFloat(v));!f(s)&&!Array.isArray(s)&&console.error('MUI: Argument "props" must be a string or Array.'),!m(c)&&!f(c)&&console.error(`MUI: Argument "duration" must be a number or a string but found ${c}.`),f(l)||console.error('MUI: Argument "easing" must be a string.'),!m(u)&&!f(u)&&console.error('MUI: Argument "delay" must be a number or a string.'),typeof a!="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(`
162
- `)),Object.keys(g).length!==0&&console.error(`MUI: Unrecognized argument(s) [${Object.keys(g).join(",")}].`)}return(Array.isArray(s)?s:[s]).map(f=>`${f} ${typeof c=="string"?c:is(c)} ${l} ${typeof u=="string"?u:is(u)}`).join(",")},...e,easing:r,duration:n}}const Od={mobileStepper:1e3,fab:1050,speedDial:1050,appBar:1100,drawer:1200,modal:1300,snackbar:1400,tooltip:1500};function Md(e){return fr(e)||typeof e>"u"||typeof e=="string"||typeof e=="boolean"||typeof e=="number"||Array.isArray(e)}function Hs(e={}){const r={...e};function n(i){const s=Object.entries(i);for(let a=0;a<s.length;a++){const[c,l]=s[a];!Md(l)||c.startsWith("unstable_")?delete i[c]:fr(l)&&(i[c]={...l},n(i[c]))}}return n(r),`import { unstable_createBreakpoints as createBreakpoints, createTransitions } from '@mui/material/styles';
161
+ } });`:Ir(12,T?` (${T})`:"",JSON.stringify(m.main)));return s?(ns(s,m,"light",z,i),ns(s,m,"dark",I,i)):(os(m,"light",z,i),os(m,"dark",I,i)),m.contrastText||(m.contrastText=S(m.main)),m};let B;return r==="light"?B=Vs():r==="dark"&&(B=Us()),process.env.NODE_ENV!=="production"&&(B||console.error(`MUI: The palette mode \`${r}\` is not supported.`)),yt({common:{...Bo},mode:r,primary:C({color:c,name:"primary"}),secondary:C({color:l,name:"secondary",mainShade:"A400",lightShade:"A200",darkShade:"A700"}),error:C({color:u,name:"error"}),warning:C({color:f,name:"warning"}),info:C({color:g,name:"info"}),success:C({color:x,name:"success"}),grey:xd,contrastThreshold:n,getContrastText:S,augmentColor:C,tonalOffset:i,...B},a)}function jd(e){const r={};return Object.entries(e).forEach(i=>{const[s,a]=i;typeof a=="object"&&(r[s]=`${a.fontStyle?`${a.fontStyle} `:""}${a.fontVariant?`${a.fontVariant} `:""}${a.fontWeight?`${a.fontWeight} `:""}${a.fontStretch?`${a.fontStretch} `:""}${a.fontSize||""}${a.lineHeight?`/${a.lineHeight} `:""}${a.fontFamily||""}`)}),r}function kd(e,r){return{toolbar:{minHeight:56,[e.up("xs")]:{"@media (orientation: landscape)":{minHeight:48}},[e.up("sm")]:{minHeight:64}},...r}}function zd(e){return Math.round(e*1e5)/1e5}const is={textTransform:"uppercase"},ss='"Roboto", "Helvetica", "Arial", sans-serif';function Td(e,r){const{fontFamily:n=ss,fontSize:i=14,fontWeightLight:s=300,fontWeightRegular:a=400,fontWeightMedium:c=500,fontWeightBold:l=700,htmlFontSize:u=16,allVariants:g,pxToRem:x,...f}=typeof r=="function"?r(e):r;process.env.NODE_ENV!=="production"&&(typeof i!="number"&&console.error("MUI: `fontSize` is required to be a number."),typeof u!="number"&&console.error("MUI: `htmlFontSize` is required to be a number."));const S=i/14,C=x||(m=>`${m/u*S}rem`),B=(m,T,h,z,I)=>({fontFamily:n,fontWeight:m,fontSize:C(T),lineHeight:h,...n===ss?{letterSpacing:`${zd(z/T)}em`}:{},...I,...g}),v={h1:B(s,96,1.167,-1.5),h2:B(s,60,1.2,-.5),h3:B(a,48,1.167,0),h4:B(a,34,1.235,.25),h5:B(a,24,1.334,0),h6:B(c,20,1.6,.15),subtitle1:B(a,16,1.75,.15),subtitle2:B(c,14,1.57,.1),body1:B(a,16,1.5,.15),body2:B(a,14,1.43,.15),button:B(c,14,1.75,.4,is),caption:B(a,12,1.66,.4),overline:B(a,12,2.66,1,is),inherit:{fontFamily:"inherit",fontWeight:"inherit",fontSize:"inherit",lineHeight:"inherit",letterSpacing:"inherit"}};return yt({htmlFontSize:u,pxToRem:C,fontFamily:n,fontSize:i,fontWeightLight:s,fontWeightRegular:a,fontWeightMedium:c,fontWeightBold:l,...v},f,{clone:!1})}const Bd=.2,Id=.14,Ed=.12;function Ae(...e){return[`${e[0]}px ${e[1]}px ${e[2]}px ${e[3]}px rgba(0,0,0,${Bd})`,`${e[4]}px ${e[5]}px ${e[6]}px ${e[7]}px rgba(0,0,0,${Id})`,`${e[8]}px ${e[9]}px ${e[10]}px ${e[11]}px rgba(0,0,0,${Ed})`].join(",")}const Dd=["none",Ae(0,2,1,-1,0,1,1,0,0,1,3,0),Ae(0,3,1,-2,0,2,2,0,0,1,5,0),Ae(0,3,3,-2,0,3,4,0,0,1,8,0),Ae(0,2,4,-1,0,4,5,0,0,1,10,0),Ae(0,3,5,-1,0,5,8,0,0,1,14,0),Ae(0,3,5,-1,0,6,10,0,0,1,18,0),Ae(0,4,5,-2,0,7,10,1,0,2,16,1),Ae(0,5,5,-3,0,8,10,1,0,3,14,2),Ae(0,5,6,-3,0,9,12,1,0,3,16,2),Ae(0,6,6,-3,0,10,14,1,0,4,18,3),Ae(0,6,7,-4,0,11,15,1,0,4,20,3),Ae(0,7,8,-4,0,12,17,2,0,5,22,4),Ae(0,7,8,-4,0,13,19,2,0,5,24,4),Ae(0,7,9,-4,0,14,21,2,0,5,26,4),Ae(0,8,9,-5,0,15,22,2,0,6,28,5),Ae(0,8,10,-5,0,16,24,2,0,6,30,5),Ae(0,8,11,-5,0,17,26,2,0,6,32,5),Ae(0,9,11,-5,0,18,28,2,0,7,34,6),Ae(0,9,12,-6,0,19,29,2,0,7,36,6),Ae(0,10,13,-6,0,20,31,3,0,8,38,7),Ae(0,10,13,-6,0,21,33,3,0,8,40,7),Ae(0,10,14,-6,0,22,35,3,0,8,42,7),Ae(0,11,14,-7,0,23,36,3,0,9,44,8),Ae(0,11,15,-7,0,24,38,3,0,9,46,8)],_d={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)"},$d={shortest:150,shorter:200,short:250,standard:300,complex:375,enteringScreen:225,leavingScreen:195};function as(e){return`${Math.round(e)}ms`}function Od(e){if(!e)return 0;const r=e/36;return Math.min(Math.round((4+15*r**.25+r/5)*10),3e3)}function Md(e){const r={..._d,...e.easing},n={...$d,...e.duration};return{getAutoHeightDuration:Od,create:(s=["all"],a={})=>{const{duration:c=n.standard,easing:l=r.easeInOut,delay:u=0,...g}=a;if(process.env.NODE_ENV!=="production"){const x=S=>typeof S=="string",f=S=>!Number.isNaN(parseFloat(S));!x(s)&&!Array.isArray(s)&&console.error('MUI: Argument "props" must be a string or Array.'),!f(c)&&!x(c)&&console.error(`MUI: Argument "duration" must be a number or a string but found ${c}.`),x(l)||console.error('MUI: Argument "easing" must be a string.'),!f(u)&&!x(u)&&console.error('MUI: Argument "delay" must be a number or a string.'),typeof a!="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(`
162
+ `)),Object.keys(g).length!==0&&console.error(`MUI: Unrecognized argument(s) [${Object.keys(g).join(",")}].`)}return(Array.isArray(s)?s:[s]).map(x=>`${x} ${typeof c=="string"?c:as(c)} ${l} ${typeof u=="string"?u:as(u)}`).join(",")},...e,easing:r,duration:n}}const Ad={mobileStepper:1e3,fab:1050,speedDial:1050,appBar:1100,drawer:1200,modal:1300,snackbar:1400,tooltip:1500};function Wd(e){return fr(e)||typeof e>"u"||typeof e=="string"||typeof e=="boolean"||typeof e=="number"||Array.isArray(e)}function Gs(e={}){const r={...e};function n(i){const s=Object.entries(i);for(let a=0;a<s.length;a++){const[c,l]=s[a];!Wd(l)||c.startsWith("unstable_")?delete i[c]:fr(l)&&(i[c]={...l},n(i[c]))}}return n(r),`import { unstable_createBreakpoints as createBreakpoints, createTransitions } from '@mui/material/styles';
163
163
 
164
164
  const theme = ${JSON.stringify(r,null,2)};
165
165
 
166
166
  theme.breakpoints = createBreakpoints(theme.breakpoints || {});
167
167
  theme.transitions = createTransitions(theme.transitions || {});
168
168
 
169
- export default theme;`}function ss(e){return typeof e=="number"?`${(e*100).toFixed(0)}%`:`calc((${e}) * 100%)`}const Wd=e=>{if(!Number.isNaN(+e))return+e;const r=e.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 Ad(e){Object.assign(e,{alpha(r,n){const i=this||e;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})`:$(r,Wd(n))},lighten(r,n){const i=this||e;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${r}, #fff ${ss(n)})`:jn(r,n)},darken(r,n){const i=this||e;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${r}, #000 ${ss(n)})`:wn(r,n)}})}function ni(e={},...r){const{breakpoints:n,mixins:i={},spacing:s,palette:a={},transitions:c={},typography:l={},shape:u,colorSpace:g,...f}=e;if(e.vars&&e.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.":Er(20));const m=bi({...a,colorSpace:g}),v=Ps(e);let C=bt(v,{mixins:wd(v.breakpoints,i),palette:m,shadows:Id.slice(),typography:kd(m,l),transitions:$d(c),zIndex:{...Od}});if(C=bt(C,f),C=r.reduce((B,b)=>bt(B,b),C),process.env.NODE_ENV!=="production"){const B=["active","checked","completed","disabled","error","expanded","focused","focusVisible","required","selected"],b=(y,z)=>{let x;for(x in y){const j=y[x];if(B.includes(x)&&Object.keys(j).length>0){if(process.env.NODE_ENV!=="production"){const E=nd("",x);console.error([`MUI: The \`${z}\` component increases the CSS specificity of the \`${x}\` internal state.`,"You can not override it like this: ",JSON.stringify(y,null,2),"",`Instead, you need to use the '&.${E}' syntax:`,JSON.stringify({root:{[`&.${E}`]:j}},null,2),"","https://mui.com/r/state-classes-guide"].join(`
170
- `))}y[x]={}}}};Object.keys(C.components).forEach(y=>{const z=C.components[y].styleOverrides;z&&y.startsWith("Mui")&&b(z,y)})}return C.unstable_sxConfig={...vn,...f==null?void 0:f.unstable_sxConfig},C.unstable_sx=function(b){return Sn({sx:b,theme:this})},C.toRuntimeSource=Hs,Ad(C),C}function Rd(e){let r;return e<1?r=5.11916*e**2:r=4.5*Math.log(e+1)+2,Math.round(r*10)/1e3}const Pd=[...Array(25)].map((e,r)=>{if(r===0)return"none";const n=Rd(r);return`linear-gradient(rgba(255 255 255 / ${n}), rgba(255 255 255 / ${n}))`});function Gs(e){return{inputPlaceholder:e==="dark"?.5:.42,inputUnderline:e==="dark"?.7:.42,switchTrackDisabled:e==="dark"?.2:.12,switchTrack:e==="dark"?.3:.38}}function Us(e){return e==="dark"?Pd:[]}function Nd(e){const{palette:r={mode:"light"},opacity:n,overlays:i,colorSpace:s,...a}=e,c=bi({...r,colorSpace:s});return{palette:c,opacity:{...Gs(c.mode),...n},overlays:i||Us(c.mode),...a}}function Ld(e){var r;return!!e[0].match(/(cssVarPrefix|colorSchemeSelector|modularCssLayers|rootSelector|typography|mixins|breakpoints|direction|transitions)/)||!!e[0].match(/sxConfig$/)||e[0]==="palette"&&!!((r=e[1])!=null&&r.match(/(mode|contrastThreshold|tonalOffset)/))}const Fd=e=>[...[...Array(25)].map((r,n)=>`--${e?`${e}-`:""}overlays-${n}`),`--${e?`${e}-`:""}palette-AppBar-darkBg`,`--${e?`${e}-`:""}palette-AppBar-darkColor`],Vd=e=>(r,n)=>{const i=e.rootSelector||":root",s=e.colorSchemeSelector;let a=s;if(s==="class"&&(a=".%s"),s==="data"&&(a="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(a=`[${s}="%s"]`),e.defaultColorScheme===r){if(r==="dark"){const c={};return Fd(e.cssVarPrefix).forEach(l=>{c[l]=n[l],delete n[l]}),a==="media"?{[i]:n,"@media (prefers-color-scheme: dark)":{[i]:c}}:a?{[a.replace("%s",r)]:c,[`${i}, ${a.replace("%s",r)}`]:n}:{[i]:{...n,...c}}}if(a&&a!=="media")return`${i}, ${a.replace("%s",String(r))}`}else if(r){if(a==="media")return{[`@media (prefers-color-scheme: ${String(r)})`]:{[i]:n}};if(a)return a.replace("%s",String(r))}return i};function Hd(e,r){r.forEach(n=>{e[n]||(e[n]={})})}function L(e,r,n){!e[r]&&n&&(e[r]=n)}function Co(e){return typeof e!="string"||!e.startsWith("hsl")?e:Ns(e)}function nr(e,r){`${r}Channel`in e||(e[`${r}Channel`]=So(Co(e[r]),`MUI: Can't create \`palette.${r}Channel\` because \`palette.${r}\` is not one of these formats: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().
171
- 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 Gd(e){return typeof e=="number"?`${e}px`:typeof e=="string"||typeof e=="function"||Array.isArray(e)?e:"8px"}const Ht=e=>{try{return e()}catch{}},Ud=(e="mui")=>cd(e);function Xn(e,r,n,i,s){if(!n)return;n=n===!0?{}:n;const a=s==="dark"?"dark":"light";if(!i){r[s]=Nd({...n,palette:{mode:a,...n==null?void 0:n.palette},colorSpace:e});return}const{palette:c,...l}=ni({...i,palette:{mode:a,...n==null?void 0:n.palette},colorSpace:e});return r[s]={...n,palette:c,opacity:{...Gs(a),...n==null?void 0:n.opacity},overlays:(n==null?void 0:n.overlays)||Us(a)},l}function Yd(e={},...r){const{colorSchemes:n={light:!0},defaultColorScheme:i,disableCssColorScheme:s=!1,cssVarPrefix:a="mui",nativeColor:c=!1,shouldSkipGeneratingVar:l=Ld,colorSchemeSelector:u=n.light&&n.dark?"media":void 0,rootSelector:g=":root",...f}=e,m=Object.keys(n)[0],v=i||(n.light&&m!=="light"?"light":m),C=Ud(a),{[v]:B,light:b,dark:y,...z}=n,x={...z};let j=B;if((v==="dark"&&!("dark"in n)||v==="light"&&!("light"in n))&&(j=!0),!j)throw new Error(process.env.NODE_ENV!=="production"?`MUI: The \`colorSchemes.${v}\` option is either missing or invalid.`:Er(21,v));let E;c&&(E="oklch");const S=Xn(E,x,j,f,v);b&&!x.light&&Xn(E,x,b,void 0,"light"),y&&!x.dark&&Xn(E,x,y,void 0,"dark");let R={defaultColorScheme:v,...S,cssVarPrefix:a,colorSchemeSelector:u,rootSelector:g,getCssVar:C,colorSchemes:x,font:{...Cd(S.typography),...S.font},spacing:Gd(f.spacing)};Object.keys(R.colorSchemes).forEach(W=>{const h=R.colorSchemes[W].palette,I=d=>{const oe=d.split("-"),G=oe[1],te=oe[2];return C(d,h[G][te])};h.mode==="light"&&(L(h.common,"background","#fff"),L(h.common,"onBackground","#000")),h.mode==="dark"&&(L(h.common,"background","#000"),L(h.common,"onBackground","#fff"));function N(d,oe,G){if(E){let te;return d===Br&&(te=`transparent ${((1-G)*100).toFixed(0)}%`),d===De&&(te=`#000 ${(G*100).toFixed(0)}%`),d===_e&&(te=`#fff ${(G*100).toFixed(0)}%`),`color-mix(in ${E}, ${oe}, ${te})`}return d(oe,G)}if(Hd(h,["Alert","AppBar","Avatar","Button","Chip","FilledInput","LinearProgress","Skeleton","Slider","SnackbarContent","SpeedDialAction","StepConnector","StepContent","Switch","TableCell","Tooltip"]),h.mode==="light"){L(h.Alert,"errorColor",N(De,h.error.light,.6)),L(h.Alert,"infoColor",N(De,h.info.light,.6)),L(h.Alert,"successColor",N(De,h.success.light,.6)),L(h.Alert,"warningColor",N(De,h.warning.light,.6)),L(h.Alert,"errorFilledBg",I("palette-error-main")),L(h.Alert,"infoFilledBg",I("palette-info-main")),L(h.Alert,"successFilledBg",I("palette-success-main")),L(h.Alert,"warningFilledBg",I("palette-warning-main")),L(h.Alert,"errorFilledColor",Ht(()=>h.getContrastText(h.error.main))),L(h.Alert,"infoFilledColor",Ht(()=>h.getContrastText(h.info.main))),L(h.Alert,"successFilledColor",Ht(()=>h.getContrastText(h.success.main))),L(h.Alert,"warningFilledColor",Ht(()=>h.getContrastText(h.warning.main))),L(h.Alert,"errorStandardBg",N(_e,h.error.light,.9)),L(h.Alert,"infoStandardBg",N(_e,h.info.light,.9)),L(h.Alert,"successStandardBg",N(_e,h.success.light,.9)),L(h.Alert,"warningStandardBg",N(_e,h.warning.light,.9)),L(h.Alert,"errorIconColor",I("palette-error-main")),L(h.Alert,"infoIconColor",I("palette-info-main")),L(h.Alert,"successIconColor",I("palette-success-main")),L(h.Alert,"warningIconColor",I("palette-warning-main")),L(h.AppBar,"defaultBg",I("palette-grey-100")),L(h.Avatar,"defaultBg",I("palette-grey-400")),L(h.Button,"inheritContainedBg",I("palette-grey-300")),L(h.Button,"inheritContainedHoverBg",I("palette-grey-A100")),L(h.Chip,"defaultBorder",I("palette-grey-400")),L(h.Chip,"defaultAvatarColor",I("palette-grey-700")),L(h.Chip,"defaultIconColor",I("palette-grey-700")),L(h.FilledInput,"bg","rgba(0, 0, 0, 0.06)"),L(h.FilledInput,"hoverBg","rgba(0, 0, 0, 0.09)"),L(h.FilledInput,"disabledBg","rgba(0, 0, 0, 0.12)"),L(h.LinearProgress,"primaryBg",N(_e,h.primary.main,.62)),L(h.LinearProgress,"secondaryBg",N(_e,h.secondary.main,.62)),L(h.LinearProgress,"errorBg",N(_e,h.error.main,.62)),L(h.LinearProgress,"infoBg",N(_e,h.info.main,.62)),L(h.LinearProgress,"successBg",N(_e,h.success.main,.62)),L(h.LinearProgress,"warningBg",N(_e,h.warning.main,.62)),L(h.Skeleton,"bg",E?N(Br,h.text.primary,.11):`rgba(${I("palette-text-primaryChannel")} / 0.11)`),L(h.Slider,"primaryTrack",N(_e,h.primary.main,.62)),L(h.Slider,"secondaryTrack",N(_e,h.secondary.main,.62)),L(h.Slider,"errorTrack",N(_e,h.error.main,.62)),L(h.Slider,"infoTrack",N(_e,h.info.main,.62)),L(h.Slider,"successTrack",N(_e,h.success.main,.62)),L(h.Slider,"warningTrack",N(_e,h.warning.main,.62));const d=E?N(De,h.background.default,.6825):qo(h.background.default,.8);L(h.SnackbarContent,"bg",d),L(h.SnackbarContent,"color",Ht(()=>E?oi.text.primary:h.getContrastText(d))),L(h.SpeedDialAction,"fabHoverBg",qo(h.background.paper,.15)),L(h.StepConnector,"border",I("palette-grey-400")),L(h.StepContent,"border",I("palette-grey-400")),L(h.Switch,"defaultColor",I("palette-common-white")),L(h.Switch,"defaultDisabledColor",I("palette-grey-100")),L(h.Switch,"primaryDisabledColor",N(_e,h.primary.main,.62)),L(h.Switch,"secondaryDisabledColor",N(_e,h.secondary.main,.62)),L(h.Switch,"errorDisabledColor",N(_e,h.error.main,.62)),L(h.Switch,"infoDisabledColor",N(_e,h.info.main,.62)),L(h.Switch,"successDisabledColor",N(_e,h.success.main,.62)),L(h.Switch,"warningDisabledColor",N(_e,h.warning.main,.62)),L(h.TableCell,"border",N(_e,N(Br,h.divider,1),.88)),L(h.Tooltip,"bg",N(Br,h.grey[700],.92))}if(h.mode==="dark"){L(h.Alert,"errorColor",N(_e,h.error.light,.6)),L(h.Alert,"infoColor",N(_e,h.info.light,.6)),L(h.Alert,"successColor",N(_e,h.success.light,.6)),L(h.Alert,"warningColor",N(_e,h.warning.light,.6)),L(h.Alert,"errorFilledBg",I("palette-error-dark")),L(h.Alert,"infoFilledBg",I("palette-info-dark")),L(h.Alert,"successFilledBg",I("palette-success-dark")),L(h.Alert,"warningFilledBg",I("palette-warning-dark")),L(h.Alert,"errorFilledColor",Ht(()=>h.getContrastText(h.error.dark))),L(h.Alert,"infoFilledColor",Ht(()=>h.getContrastText(h.info.dark))),L(h.Alert,"successFilledColor",Ht(()=>h.getContrastText(h.success.dark))),L(h.Alert,"warningFilledColor",Ht(()=>h.getContrastText(h.warning.dark))),L(h.Alert,"errorStandardBg",N(De,h.error.light,.9)),L(h.Alert,"infoStandardBg",N(De,h.info.light,.9)),L(h.Alert,"successStandardBg",N(De,h.success.light,.9)),L(h.Alert,"warningStandardBg",N(De,h.warning.light,.9)),L(h.Alert,"errorIconColor",I("palette-error-main")),L(h.Alert,"infoIconColor",I("palette-info-main")),L(h.Alert,"successIconColor",I("palette-success-main")),L(h.Alert,"warningIconColor",I("palette-warning-main")),L(h.AppBar,"defaultBg",I("palette-grey-900")),L(h.AppBar,"darkBg",I("palette-background-paper")),L(h.AppBar,"darkColor",I("palette-text-primary")),L(h.Avatar,"defaultBg",I("palette-grey-600")),L(h.Button,"inheritContainedBg",I("palette-grey-800")),L(h.Button,"inheritContainedHoverBg",I("palette-grey-700")),L(h.Chip,"defaultBorder",I("palette-grey-700")),L(h.Chip,"defaultAvatarColor",I("palette-grey-300")),L(h.Chip,"defaultIconColor",I("palette-grey-300")),L(h.FilledInput,"bg","rgba(255, 255, 255, 0.09)"),L(h.FilledInput,"hoverBg","rgba(255, 255, 255, 0.13)"),L(h.FilledInput,"disabledBg","rgba(255, 255, 255, 0.12)"),L(h.LinearProgress,"primaryBg",N(De,h.primary.main,.5)),L(h.LinearProgress,"secondaryBg",N(De,h.secondary.main,.5)),L(h.LinearProgress,"errorBg",N(De,h.error.main,.5)),L(h.LinearProgress,"infoBg",N(De,h.info.main,.5)),L(h.LinearProgress,"successBg",N(De,h.success.main,.5)),L(h.LinearProgress,"warningBg",N(De,h.warning.main,.5)),L(h.Skeleton,"bg",E?N(Br,h.text.primary,.13):`rgba(${I("palette-text-primaryChannel")} / 0.13)`),L(h.Slider,"primaryTrack",N(De,h.primary.main,.5)),L(h.Slider,"secondaryTrack",N(De,h.secondary.main,.5)),L(h.Slider,"errorTrack",N(De,h.error.main,.5)),L(h.Slider,"infoTrack",N(De,h.info.main,.5)),L(h.Slider,"successTrack",N(De,h.success.main,.5)),L(h.Slider,"warningTrack",N(De,h.warning.main,.5));const d=E?N(_e,h.background.default,.985):qo(h.background.default,.98);L(h.SnackbarContent,"bg",d),L(h.SnackbarContent,"color",Ht(()=>E?Fs.text.primary:h.getContrastText(d))),L(h.SpeedDialAction,"fabHoverBg",qo(h.background.paper,.15)),L(h.StepConnector,"border",I("palette-grey-600")),L(h.StepContent,"border",I("palette-grey-600")),L(h.Switch,"defaultColor",I("palette-grey-300")),L(h.Switch,"defaultDisabledColor",I("palette-grey-600")),L(h.Switch,"primaryDisabledColor",N(De,h.primary.main,.55)),L(h.Switch,"secondaryDisabledColor",N(De,h.secondary.main,.55)),L(h.Switch,"errorDisabledColor",N(De,h.error.main,.55)),L(h.Switch,"infoDisabledColor",N(De,h.info.main,.55)),L(h.Switch,"successDisabledColor",N(De,h.success.main,.55)),L(h.Switch,"warningDisabledColor",N(De,h.warning.main,.55)),L(h.TableCell,"border",N(De,N(Br,h.divider,1),.68)),L(h.Tooltip,"bg",N(Br,h.grey[700],.92))}nr(h.background,"default"),nr(h.background,"paper"),nr(h.common,"background"),nr(h.common,"onBackground"),nr(h,"divider"),Object.keys(h).forEach(d=>{const oe=h[d];d!=="tonalOffset"&&oe&&typeof oe=="object"&&(oe.main&&L(h[d],"mainChannel",So(Co(oe.main))),oe.light&&L(h[d],"lightChannel",So(Co(oe.light))),oe.dark&&L(h[d],"darkChannel",So(Co(oe.dark))),oe.contrastText&&L(h[d],"contrastTextChannel",So(Co(oe.contrastText))),d==="text"&&(nr(h[d],"primary"),nr(h[d],"secondary")),d==="action"&&(oe.active&&nr(h[d],"active"),oe.selected&&nr(h[d],"selected")))})}),R=r.reduce((W,h)=>bt(W,h),R);const q={prefix:a,disableCssColorScheme:s,shouldSkipGeneratingVar:l,getSelector:Vd(R),enableContrastVars:c},{vars:T,generateThemeVars:F,generateStyleSheets:X}=pd(R,q);return R.vars=T,Object.entries(R.colorSchemes[R.defaultColorScheme]).forEach(([W,h])=>{R[W]=h}),R.generateThemeVars=F,R.generateStyleSheets=X,R.generateSpacing=function(){return Rs(f.spacing,fi(this))},R.getColorSchemeSelector=hd(u),R.spacing=R.generateSpacing(),R.shouldSkipGeneratingVar=l,R.unstable_sxConfig={...vn,...f==null?void 0:f.unstable_sxConfig},R.unstable_sx=function(h){return Sn({sx:h,theme:this})},R.toRuntimeSource=Hs,R}function as(e,r,n){e.colorSchemes&&n&&(e.colorSchemes[r]={...n!==!0&&n,palette:bi({...n===!0?{}:n.palette,mode:r})})}function qd(e={},...r){const{palette:n,cssVariables:i=!1,colorSchemes:s=n?void 0:{light:!0},defaultColorScheme:a=n==null?void 0:n.mode,...c}=e,l=a||"light",u=s==null?void 0:s[l],g={...s,...n?{[l]:{...typeof u!="boolean"&&u,palette:n}}:void 0};if(i===!1){if(!("colorSchemes"in e))return ni(e,...r);let f=n;"palette"in e||g[l]&&(g[l]!==!0?f=g[l].palette:l==="dark"&&(f={mode:"dark"}));const m=ni({...e,palette:f},...r);return m.defaultColorScheme=l,m.colorSchemes=g,m.palette.mode==="light"&&(m.colorSchemes.light={...g.light!==!0&&g.light,palette:m.palette},as(m,"dark",g.dark)),m.palette.mode==="dark"&&(m.colorSchemes.dark={...g.dark!==!0&&g.dark,palette:m.palette},as(m,"light",g.light)),m}return!n&&!("light"in g)&&l==="light"&&(g.light=!0),Yd({...c,colorSchemes:g,defaultColorScheme:l,...typeof i!="boolean"&&i},...r)}const Jd=qd();function ht(){const e=ed(Jd);return process.env.NODE_ENV!=="production"&&an.useDebugValue(e),e[Vl]||e}async function Kd(e,r,n){try{new URL(e)}catch{throw new Error("Please enter a valid URL")}const i={"Content-Type":"application/json"};r&&(i.Authorization=`Bearer ${r}`);const s=new AbortController,a=setTimeout(()=>s.abort(),3e4);let c;try{c=await fetch(e,{headers:i,signal:s.signal})}catch(g){throw clearTimeout(a),(g==null?void 0:g.name)==="AbortError"?new Error("Request timed out after 30 seconds"):new Error("Failed to fetch — check the URL and your network connection")}finally{clearTimeout(a)}if(c.status===401)throw new Error("Authentication failed (401) — check your API key");if(!c.ok)throw new Error(`API error ${c.status}: ${c.statusText}`);let l;try{l=await c.json()}catch{throw new Error("Response is not valid JSON")}let u;if(Array.isArray(l))u=l;else if(n&&l[n]&&Array.isArray(l[n]))u=l[n];else{const f=["data","results","items","records"].find(m=>l[m]&&Array.isArray(l[m]));if(f)u=l[f];else throw new Error("API response must be a JSON array, or specify the data path key.")}return{data:u,source:e,fetchedAt:new Date().toISOString()}}function Xd(e,r){return r.map(n=>`${n.x}px ${n.y}px ${n.blur}px ${n.spread}px ${$(e.palette.common.black,n.opacity)}`).join(", ")}const Qd={menu:[{x:0,y:8,blur:16,spread:4,opacity:.12},{x:0,y:4,blur:16,spread:0,opacity:.08},{x:0,y:0,blur:0,spread:1,opacity:.05}],restButton:[{x:0,y:1,blur:2,spread:0,opacity:.3},{x:0,y:1,blur:3,spread:1,opacity:.15}],restButtonLight:[{x:0,y:1,blur:2,spread:0,opacity:.1},{x:0,y:1,blur:3,spread:1,opacity:.05}],hoverButton:[{x:0,y:1,blur:3,spread:0,opacity:.3},{x:0,y:4,blur:8,spread:3,opacity:.15}],pressedButton:[{x:0,y:1,blur:2,spread:0,opacity:.3}],pressedButtonLight:[{x:0,y:1,blur:2,spread:0,opacity:.1}],small:[{x:0,y:2,blur:6,spread:0,opacity:.15}],cardRest:[{x:0,y:1,blur:3,spread:0,opacity:.08},{x:0,y:1,blur:2,spread:0,opacity:.06}],cardHover:[{x:0,y:4,blur:16,spread:0,opacity:.15},{x:0,y:1,blur:4,spread:0,opacity:.08}],popover:[{x:0,y:4,blur:20,spread:0,opacity:.15},{x:0,y:1,blur:6,spread:0,opacity:.1}],flatHover:[{x:0,y:1,blur:2,spread:0,opacity:.06}]};function ye(e,r){return Xd(e,Qd[r])}function ot(e){return`${Number(e.shape.borderRadius)*1.5}px`}function _o(e){return`${Number(e.shape.borderRadius)}px`}function ls(e){const r=e.tokens;return{containerPad:`${(r==null?void 0:r.containerPad)??16}px`,cardGap:`${(r==null?void 0:r.cardGap)??12}px`}}function ct(e){const r=e.tokens,n=(r==null?void 0:r.highlight)||e.palette.primary.main;return{main:n,bg:`var(--highlight-bg, ${$(n,.08)})`,hoverBg:`var(--highlight-hover, ${$(n,.12)})`}}function ue(e,r="menu"){const n=e.tokens;return{paper:{boxShadow:(n==null?void 0:n.cardBodyShadow)||ye(e,r),border:n!=null&&n.cardBodyBorder&&n.cardBodyBorder!=="none"?n.cardBodyBorder:"none"},header:{backgroundColor:(n==null?void 0:n.cardHdrBg)||"transparent",borderBottom:(n==null?void 0:n.cardHdrBorder)||"none",boxShadow:(n==null?void 0:n.cardHdrAccent)||"none"}}}function Zd({isOpen:e,onClose:r,onCreate:n,preloadedData:i,preloadedDataLabel:s}){const[a,c]=p.useState(""),[l,u]=p.useState(!1),[g,f]=p.useState(""),[m,v]=p.useState(null),[C,B]=p.useState(null),[b,y]=p.useState(!1),[z,x]=p.useState(""),j=p.useRef(null),[E,S]=p.useState("json"),[R,q]=p.useState(""),[T,F]=p.useState(""),[X,W]=p.useState(""),[h,I]=p.useState("idle"),[N,d]=p.useState(""),[oe,G]=p.useState(null),[te,ge]=p.useState(0),V=async D=>{if(x(""),!D.name.endsWith(".json")){x("Only .json files are allowed");return}const ee=10*1024*1024;if(D.size>ee){x("File size exceeds 10MB limit");return}try{const xe=await D.text();let ae;try{ae=JSON.parse(xe)}catch{x("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(ae)){x("JSON must be an array of objects");return}if(ae.length===0){x("No data rows found in JSON file");return}v(D),B(ae)}catch{x("Network error — please try again")}},K=D=>{D.preventDefault();const ee=D.dataTransfer.files[0];ee&&V(ee)},ce=async()=>{if(R.trim()){I("loading"),d("");try{const D=await Kd(R.trim(),T.trim()||void 0,X.trim()||void 0);G(D.data),ge(D.data.length),I("ready")}catch(D){d((D==null?void 0:D.message)||"Connection failed"),I("error")}}},de=()=>{if(!a.trim()){u(!0);return}const D=E==="api"?oe:i||C;D&&(n(a.trim(),g.trim(),D),ne())},ne=()=>{c(""),u(!1),f(""),v(null),B(null),x(""),S("json"),q(""),F(""),W(""),I("idle"),d(""),G(null),ge(0),r()},Q=i||C,pe=l&&!a.trim();return a.trim(),t.jsxs(t.Fragment,{children:[t.jsxs(o.Dialog,{open:e,onClose:ne,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:D=>({borderRadius:ot(D),width:480,maxHeight:"min(720px, calc(100vh - 120px))",my:"auto",display:"flex",flexDirection:"column",...ue(D).paper})},children:[t.jsxs(o.DialogTitle,{sx:D=>({display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2.5,fontWeight:ee=>ee.typography.h6.fontWeight||500,fontSize:ee=>ee.typography.h6.fontSize||"1.125rem",color:"text.primary",letterSpacing:"-0.01em",...ue(D).header}),children:["Create new report",t.jsx(o.IconButton,{onClick:ne,size:"small",sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Close,{sx:{fontSize:18}})})]}),t.jsx(o.DialogContent,{sx:{px:3,pt:2,pb:2,overflowY:"auto"},children:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2,pt:2},children:[t.jsx(o.TextField,{label:"Report name",required:!0,fullWidth:!0,value:a,onChange:D=>{c(D.target.value),l&&D.target.value.trim()&&u(!1)},placeholder:"Enter report name",autoFocus:!0,error:pe,helperText:pe?"Report name is required":void 0,inputProps:{maxLength:255},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:g,onChange:D=>f(D.target.value),placeholder:"Add details about this report",inputProps:{maxLength:500},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.Tabs,{value:E==="json"?0:1,onChange:(D,ee)=>{S(ee===0?"json":"api"),I("idle"),d("")},variant:"fullWidth",sx:{borderBottom:1,borderColor:"divider",minHeight:40,"& .MuiTabs-indicator":{height:3,bgcolor:"primary.main"}},children:[t.jsx(o.Tab,{label:"Upload JSON",icon:t.jsx(O.Description,{fontSize:"small"}),iconPosition:"start",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,minHeight:40,py:.5,borderRadius:"8px 8px 0 0","&.Mui-selected":{color:"text.primary",fontWeight:600,bgcolor:D=>`var(--highlight-hover, ${$(D.palette.primary.main,.15)})`},"&:hover":{bgcolor:D=>`var(--highlight-hover, ${$(D.palette.primary.main,.08)})`}}}),t.jsx(o.Tab,{label:"Connect API",icon:t.jsx(O.Api,{fontSize:"small"}),iconPosition:"start",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,minHeight:40,py:.5,borderRadius:"8px 8px 0 0","&.Mui-selected":{color:"text.primary",fontWeight:600,bgcolor:D=>`var(--highlight-hover, ${$(D.palette.primary.main,.15)})`},"&:hover":{bgcolor:D=>`var(--highlight-hover, ${$(D.palette.primary.main,.08)})`}}})]}),E==="json"&&t.jsx(o.Box,{children:i?t.jsxs(o.Box,{sx:{border:"1.5px solid",borderColor:"success.main",borderRadius:2,p:2.5,bgcolor:D=>$(D.palette.success.main,.04),display:"flex",alignItems:"center",gap:2},children:[t.jsx(o.Box,{sx:{width:36,height:36,borderRadius:"50%",bgcolor:D=>$(D.palette.success.main,.12),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(O.CheckCircle,{sx:{fontSize:20,color:"success.main"}})}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.dark",fontSize:"0.875rem"},children:s||`${i.length.toLocaleString()} records loaded`}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary"},children:"Data source is connected — ready to create"})]})]}):t.jsxs(t.Fragment,{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:()=>y(!0),sx:{p:.25,color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:t.jsx(O.Info,{sx:{fontSize:16}})})]}),t.jsxs(o.Box,{onDrop:K,onDragOver:D=>D.preventDefault(),onPaste:D=>D.preventDefault(),onClick:()=>{var D;return(D=j.current)==null?void 0:D.click()},sx:{position:"relative",border:"1.5px",borderStyle:C?"solid":"dashed",borderColor:C?"success.main":z?"error.main":"primary.main",borderRadius:2,p:3,textAlign:"center",cursor:"pointer",bgcolor:C?D=>$(D.palette.success.main,.04):z?D=>$(D.palette.error.main,.04):D=>$(D.palette.primary.main,.04),transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:C?D=>$(D.palette.success.main,.08):z?D=>$(D.palette.error.main,.08):D=>$(D.palette.primary.main,.08),borderColor:C?"success.dark":z?"error.dark":"primary.dark"}},children:[t.jsx(o.Box,{component:"input",ref:j,type:"file",accept:".json",sx:{display:"none"},onChange:D=>{var ee;return((ee=D.target.files)==null?void 0:ee[0])&&V(D.target.files[0])}}),C?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:D=>$(D.palette.success.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:.5},children:t.jsx(O.CheckCircle,{sx:{fontSize:24,color:"success.main"}})}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.main",fontSize:"0.875rem"},children:m==null?void 0:m.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:D=>$(D.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mx:"auto",mb:1.5},children:t.jsx(O.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"}),z&&t.jsx(o.Box,{sx:{mt:1.25,p:.75,borderRadius:1,bgcolor:D=>$(D.palette.error.main,.08),border:1,borderColor:D=>$(D.palette.error.main,.2)},children:t.jsx(o.Typography,{variant:"caption",sx:{color:"error.main",fontSize:"0.6875rem",fontWeight:500},children:z})})]})]})]})}),E==="api"&&t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[t.jsx(o.TextField,{label:"API Endpoint URL",required:!0,fullWidth:!0,size:"small",value:R,onChange:D=>{q(D.target.value),I("idle")},placeholder:"http://localhost:8000/api/reports/sales-pipeline/data/flat",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:"API Key (optional)",fullWidth:!0,size:"small",value:T,onChange:D=>F(D.target.value),placeholder:"Leave blank if no auth required",InputProps:{startAdornment:t.jsx(o.InputAdornment,{position:"start",children:t.jsx(O.Lock,{sx:{fontSize:16,color:"text.secondary"}})})},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:"Response data path (optional)",fullWidth:!0,size:"small",value:X,onChange:D=>W(D.target.value),placeholder:"data (leave blank if API returns a plain array)",helperText:'If your API returns { "data": [...] }, enter: data',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}},"& .MuiFormHelperText-root":{fontSize:"0.75rem",mx:0}}}),t.jsx(o.Button,{variant:"outlined",fullWidth:!0,disabled:!R.trim()||h==="loading",onClick:ce,startIcon:h==="loading"?t.jsx(o.CircularProgress,{size:16,color:"inherit"}):t.jsx(O.Api,{}),sx:{fontSize:"0.875rem",borderRadius:1,py:.875,borderColor:"primary.main",color:"primary.main","&:hover":{bgcolor:D=>$(D.palette.primary.main,.04),borderColor:"primary.dark"},"&:disabled":{borderColor:"action.disabledBackground",color:"action.disabled"}},children:h==="loading"?"Connecting...":"Test Connection & Load Data"}),h==="ready"&&t.jsxs(o.Box,{sx:{border:"1.5px solid",borderColor:"success.main",borderRadius:2,p:2,bgcolor:D=>$(D.palette.success.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[t.jsx(O.CheckCircle,{sx:{fontSize:20,color:"success.main",flexShrink:0,mt:.1}}),t.jsxs(o.Box,{children:[t.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.dark",fontSize:"0.875rem"},children:[te.toLocaleString()," records loaded — ready to create"]}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.75rem",wordBreak:"break-all",display:"block",mt:.25},children:R})]})]}),h==="error"&&t.jsxs(o.Box,{sx:{border:"1.5px solid",borderColor:"error.main",borderRadius:2,p:2,bgcolor:D=>$(D.palette.error.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[t.jsx(O.ErrorOutline,{sx:{fontSize:20,color:"error.main",flexShrink:0,mt:.1}}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,color:"error.main",fontSize:"0.875rem"},children:"Connection failed"}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.75rem",display:"block",mt:.25},children:N})]})]})]})]})}),t.jsxs(o.DialogActions,{sx:{px:3,py:2,gap:1,borderTop:"1px solid",borderColor:"divider"},children:[t.jsx(o.Button,{onClick:ne,variant:"text",sx:{color:"primary.main",fontSize:"0.875rem",borderRadius:D=>`${D.shape.borderRadius}px`,px:2,py:.625,minWidth:64,"&:hover":{bgcolor:D=>$(D.palette.primary.main,.04)}},children:"Cancel"}),t.jsx(o.Button,{onClick:de,disabled:E==="json"&&!Q||E==="api"&&h!=="ready",variant:"contained",sx:{fontSize:"0.875rem",borderRadius:D=>`${D.shape.borderRadius}px`,px:2.5,py:.625,minWidth:64,"&:disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Create"})]})]}),t.jsxs(o.Dialog,{open:b,onClose:()=>y(!1),maxWidth:"sm",PaperProps:{sx:D=>({borderRadius:3,width:560,maxHeight:"80vh",...ue(D).paper})},children:[t.jsxs(o.DialogTitle,{sx:D=>({display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,fontWeight:500,fontSize:"1.25rem",color:"text.primary",letterSpacing:"-0.01em",...ue(D).header}),children:["JSON format guide",t.jsx(o.IconButton,{onClick:()=>y(!1),size:"small",sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:t.jsx(O.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:`[
169
+ export default theme;`}function ls(e){return typeof e=="number"?`${(e*100).toFixed(0)}%`:`calc((${e}) * 100%)`}const Rd=e=>{if(!Number.isNaN(+e))return+e;const r=e.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 Pd(e){Object.assign(e,{alpha(r,n){const i=this||e;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})`:_(r,Rd(n))},lighten(r,n){const i=this||e;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${r}, #fff ${ls(n)})`:kn(r,n)},darken(r,n){const i=this||e;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${r}, #000 ${ls(n)})`:jn(r,n)}})}function ni(e={},...r){const{breakpoints:n,mixins:i={},spacing:s,palette:a={},transitions:c={},typography:l={},shape:u,colorSpace:g,...x}=e;if(e.vars&&e.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.":Ir(20));const f=bi({...a,colorSpace:g}),S=Ls(e);let C=yt(S,{mixins:kd(S.breakpoints,i),palette:f,shadows:Dd.slice(),typography:Td(f,l),transitions:Md(c),zIndex:{...Ad}});if(C=yt(C,x),C=r.reduce((B,v)=>yt(B,v),C),process.env.NODE_ENV!=="production"){const B=["active","checked","completed","disabled","error","expanded","focused","focusVisible","required","selected"],v=(m,T)=>{let h;for(h in m){const z=m[h];if(B.includes(h)&&Object.keys(z).length>0){if(process.env.NODE_ENV!=="production"){const I=sd("",h);console.error([`MUI: The \`${T}\` component increases the CSS specificity of the \`${h}\` internal state.`,"You can not override it like this: ",JSON.stringify(m,null,2),"",`Instead, you need to use the '&.${I}' syntax:`,JSON.stringify({root:{[`&.${I}`]:z}},null,2),"","https://mui.com/r/state-classes-guide"].join(`
170
+ `))}m[h]={}}}};Object.keys(C.components).forEach(m=>{const T=C.components[m].styleOverrides;T&&m.startsWith("Mui")&&v(T,m)})}return C.unstable_sxConfig={...Sn,...x==null?void 0:x.unstable_sxConfig},C.unstable_sx=function(v){return Cn({sx:v,theme:this})},C.toRuntimeSource=Gs,Pd(C),C}function Nd(e){let r;return e<1?r=5.11916*e**2:r=4.5*Math.log(e+1)+2,Math.round(r*10)/1e3}const Ld=[...Array(25)].map((e,r)=>{if(r===0)return"none";const n=Nd(r);return`linear-gradient(rgba(255 255 255 / ${n}), rgba(255 255 255 / ${n}))`});function Ys(e){return{inputPlaceholder:e==="dark"?.5:.42,inputUnderline:e==="dark"?.7:.42,switchTrackDisabled:e==="dark"?.2:.12,switchTrack:e==="dark"?.3:.38}}function qs(e){return e==="dark"?Ld:[]}function Fd(e){const{palette:r={mode:"light"},opacity:n,overlays:i,colorSpace:s,...a}=e,c=bi({...r,colorSpace:s});return{palette:c,opacity:{...Ys(c.mode),...n},overlays:i||qs(c.mode),...a}}function Vd(e){var r;return!!e[0].match(/(cssVarPrefix|colorSchemeSelector|modularCssLayers|rootSelector|typography|mixins|breakpoints|direction|transitions)/)||!!e[0].match(/sxConfig$/)||e[0]==="palette"&&!!((r=e[1])!=null&&r.match(/(mode|contrastThreshold|tonalOffset)/))}const Hd=e=>[...[...Array(25)].map((r,n)=>`--${e?`${e}-`:""}overlays-${n}`),`--${e?`${e}-`:""}palette-AppBar-darkBg`,`--${e?`${e}-`:""}palette-AppBar-darkColor`],Ud=e=>(r,n)=>{const i=e.rootSelector||":root",s=e.colorSchemeSelector;let a=s;if(s==="class"&&(a=".%s"),s==="data"&&(a="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(a=`[${s}="%s"]`),e.defaultColorScheme===r){if(r==="dark"){const c={};return Hd(e.cssVarPrefix).forEach(l=>{c[l]=n[l],delete n[l]}),a==="media"?{[i]:n,"@media (prefers-color-scheme: dark)":{[i]:c}}:a?{[a.replace("%s",r)]:c,[`${i}, ${a.replace("%s",r)}`]:n}:{[i]:{...n,...c}}}if(a&&a!=="media")return`${i}, ${a.replace("%s",String(r))}`}else if(r){if(a==="media")return{[`@media (prefers-color-scheme: ${String(r)})`]:{[i]:n}};if(a)return a.replace("%s",String(r))}return i};function Gd(e,r){r.forEach(n=>{e[n]||(e[n]={})})}function L(e,r,n){!e[r]&&n&&(e[r]=n)}function Co(e){return typeof e!="string"||!e.startsWith("hsl")?e:Fs(e)}function rr(e,r){`${r}Channel`in e||(e[`${r}Channel`]=So(Co(e[r]),`MUI: Can't create \`palette.${r}Channel\` because \`palette.${r}\` is not one of these formats: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().
171
+ 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 Yd(e){return typeof e=="number"?`${e}px`:typeof e=="string"||typeof e=="function"||Array.isArray(e)?e:"8px"}const Ht=e=>{try{return e()}catch{}},qd=(e="mui")=>ud(e);function Xn(e,r,n,i,s){if(!n)return;n=n===!0?{}:n;const a=s==="dark"?"dark":"light";if(!i){r[s]=Fd({...n,palette:{mode:a,...n==null?void 0:n.palette},colorSpace:e});return}const{palette:c,...l}=ni({...i,palette:{mode:a,...n==null?void 0:n.palette},colorSpace:e});return r[s]={...n,palette:c,opacity:{...Ys(a),...n==null?void 0:n.opacity},overlays:(n==null?void 0:n.overlays)||qs(a)},l}function Jd(e={},...r){const{colorSchemes:n={light:!0},defaultColorScheme:i,disableCssColorScheme:s=!1,cssVarPrefix:a="mui",nativeColor:c=!1,shouldSkipGeneratingVar:l=Vd,colorSchemeSelector:u=n.light&&n.dark?"media":void 0,rootSelector:g=":root",...x}=e,f=Object.keys(n)[0],S=i||(n.light&&f!=="light"?"light":f),C=qd(a),{[S]:B,light:v,dark:m,...T}=n,h={...T};let z=B;if((S==="dark"&&!("dark"in n)||S==="light"&&!("light"in n))&&(z=!0),!z)throw new Error(process.env.NODE_ENV!=="production"?`MUI: The \`colorSchemes.${S}\` option is either missing or invalid.`:Ir(21,S));let I;c&&(I="oklch");const b=Xn(I,h,z,x,S);v&&!h.light&&Xn(I,h,v,void 0,"light"),m&&!h.dark&&Xn(I,h,m,void 0,"dark");let R={defaultColorScheme:S,...b,cssVarPrefix:a,colorSchemeSelector:u,rootSelector:g,getCssVar:C,colorSchemes:h,font:{...jd(b.typography),...b.font},spacing:Yd(x.spacing)};Object.keys(R.colorSchemes).forEach(O=>{const y=R.colorSchemes[O].palette,w=te=>{const d=te.split("-"),J=d[1],re=d[2];return C(te,y[J][re])};y.mode==="light"&&(L(y.common,"background","#fff"),L(y.common,"onBackground","#000")),y.mode==="dark"&&(L(y.common,"background","#000"),L(y.common,"onBackground","#fff"));function P(te,d,J){if(I){let re;return te===Tr&&(re=`transparent ${((1-J)*100).toFixed(0)}%`),te===Ie&&(re=`#000 ${(J*100).toFixed(0)}%`),te===Ee&&(re=`#fff ${(J*100).toFixed(0)}%`),`color-mix(in ${I}, ${d}, ${re})`}return te(d,J)}if(Gd(y,["Alert","AppBar","Avatar","Button","Chip","FilledInput","LinearProgress","Skeleton","Slider","SnackbarContent","SpeedDialAction","StepConnector","StepContent","Switch","TableCell","Tooltip"]),y.mode==="light"){L(y.Alert,"errorColor",P(Ie,y.error.light,.6)),L(y.Alert,"infoColor",P(Ie,y.info.light,.6)),L(y.Alert,"successColor",P(Ie,y.success.light,.6)),L(y.Alert,"warningColor",P(Ie,y.warning.light,.6)),L(y.Alert,"errorFilledBg",w("palette-error-main")),L(y.Alert,"infoFilledBg",w("palette-info-main")),L(y.Alert,"successFilledBg",w("palette-success-main")),L(y.Alert,"warningFilledBg",w("palette-warning-main")),L(y.Alert,"errorFilledColor",Ht(()=>y.getContrastText(y.error.main))),L(y.Alert,"infoFilledColor",Ht(()=>y.getContrastText(y.info.main))),L(y.Alert,"successFilledColor",Ht(()=>y.getContrastText(y.success.main))),L(y.Alert,"warningFilledColor",Ht(()=>y.getContrastText(y.warning.main))),L(y.Alert,"errorStandardBg",P(Ee,y.error.light,.9)),L(y.Alert,"infoStandardBg",P(Ee,y.info.light,.9)),L(y.Alert,"successStandardBg",P(Ee,y.success.light,.9)),L(y.Alert,"warningStandardBg",P(Ee,y.warning.light,.9)),L(y.Alert,"errorIconColor",w("palette-error-main")),L(y.Alert,"infoIconColor",w("palette-info-main")),L(y.Alert,"successIconColor",w("palette-success-main")),L(y.Alert,"warningIconColor",w("palette-warning-main")),L(y.AppBar,"defaultBg",w("palette-grey-100")),L(y.Avatar,"defaultBg",w("palette-grey-400")),L(y.Button,"inheritContainedBg",w("palette-grey-300")),L(y.Button,"inheritContainedHoverBg",w("palette-grey-A100")),L(y.Chip,"defaultBorder",w("palette-grey-400")),L(y.Chip,"defaultAvatarColor",w("palette-grey-700")),L(y.Chip,"defaultIconColor",w("palette-grey-700")),L(y.FilledInput,"bg","rgba(0, 0, 0, 0.06)"),L(y.FilledInput,"hoverBg","rgba(0, 0, 0, 0.09)"),L(y.FilledInput,"disabledBg","rgba(0, 0, 0, 0.12)"),L(y.LinearProgress,"primaryBg",P(Ee,y.primary.main,.62)),L(y.LinearProgress,"secondaryBg",P(Ee,y.secondary.main,.62)),L(y.LinearProgress,"errorBg",P(Ee,y.error.main,.62)),L(y.LinearProgress,"infoBg",P(Ee,y.info.main,.62)),L(y.LinearProgress,"successBg",P(Ee,y.success.main,.62)),L(y.LinearProgress,"warningBg",P(Ee,y.warning.main,.62)),L(y.Skeleton,"bg",I?P(Tr,y.text.primary,.11):`rgba(${w("palette-text-primaryChannel")} / 0.11)`),L(y.Slider,"primaryTrack",P(Ee,y.primary.main,.62)),L(y.Slider,"secondaryTrack",P(Ee,y.secondary.main,.62)),L(y.Slider,"errorTrack",P(Ee,y.error.main,.62)),L(y.Slider,"infoTrack",P(Ee,y.info.main,.62)),L(y.Slider,"successTrack",P(Ee,y.success.main,.62)),L(y.Slider,"warningTrack",P(Ee,y.warning.main,.62));const te=I?P(Ie,y.background.default,.6825):Jo(y.background.default,.8);L(y.SnackbarContent,"bg",te),L(y.SnackbarContent,"color",Ht(()=>I?oi.text.primary:y.getContrastText(te))),L(y.SpeedDialAction,"fabHoverBg",Jo(y.background.paper,.15)),L(y.StepConnector,"border",w("palette-grey-400")),L(y.StepContent,"border",w("palette-grey-400")),L(y.Switch,"defaultColor",w("palette-common-white")),L(y.Switch,"defaultDisabledColor",w("palette-grey-100")),L(y.Switch,"primaryDisabledColor",P(Ee,y.primary.main,.62)),L(y.Switch,"secondaryDisabledColor",P(Ee,y.secondary.main,.62)),L(y.Switch,"errorDisabledColor",P(Ee,y.error.main,.62)),L(y.Switch,"infoDisabledColor",P(Ee,y.info.main,.62)),L(y.Switch,"successDisabledColor",P(Ee,y.success.main,.62)),L(y.Switch,"warningDisabledColor",P(Ee,y.warning.main,.62)),L(y.TableCell,"border",P(Ee,P(Tr,y.divider,1),.88)),L(y.Tooltip,"bg",P(Tr,y.grey[700],.92))}if(y.mode==="dark"){L(y.Alert,"errorColor",P(Ee,y.error.light,.6)),L(y.Alert,"infoColor",P(Ee,y.info.light,.6)),L(y.Alert,"successColor",P(Ee,y.success.light,.6)),L(y.Alert,"warningColor",P(Ee,y.warning.light,.6)),L(y.Alert,"errorFilledBg",w("palette-error-dark")),L(y.Alert,"infoFilledBg",w("palette-info-dark")),L(y.Alert,"successFilledBg",w("palette-success-dark")),L(y.Alert,"warningFilledBg",w("palette-warning-dark")),L(y.Alert,"errorFilledColor",Ht(()=>y.getContrastText(y.error.dark))),L(y.Alert,"infoFilledColor",Ht(()=>y.getContrastText(y.info.dark))),L(y.Alert,"successFilledColor",Ht(()=>y.getContrastText(y.success.dark))),L(y.Alert,"warningFilledColor",Ht(()=>y.getContrastText(y.warning.dark))),L(y.Alert,"errorStandardBg",P(Ie,y.error.light,.9)),L(y.Alert,"infoStandardBg",P(Ie,y.info.light,.9)),L(y.Alert,"successStandardBg",P(Ie,y.success.light,.9)),L(y.Alert,"warningStandardBg",P(Ie,y.warning.light,.9)),L(y.Alert,"errorIconColor",w("palette-error-main")),L(y.Alert,"infoIconColor",w("palette-info-main")),L(y.Alert,"successIconColor",w("palette-success-main")),L(y.Alert,"warningIconColor",w("palette-warning-main")),L(y.AppBar,"defaultBg",w("palette-grey-900")),L(y.AppBar,"darkBg",w("palette-background-paper")),L(y.AppBar,"darkColor",w("palette-text-primary")),L(y.Avatar,"defaultBg",w("palette-grey-600")),L(y.Button,"inheritContainedBg",w("palette-grey-800")),L(y.Button,"inheritContainedHoverBg",w("palette-grey-700")),L(y.Chip,"defaultBorder",w("palette-grey-700")),L(y.Chip,"defaultAvatarColor",w("palette-grey-300")),L(y.Chip,"defaultIconColor",w("palette-grey-300")),L(y.FilledInput,"bg","rgba(255, 255, 255, 0.09)"),L(y.FilledInput,"hoverBg","rgba(255, 255, 255, 0.13)"),L(y.FilledInput,"disabledBg","rgba(255, 255, 255, 0.12)"),L(y.LinearProgress,"primaryBg",P(Ie,y.primary.main,.5)),L(y.LinearProgress,"secondaryBg",P(Ie,y.secondary.main,.5)),L(y.LinearProgress,"errorBg",P(Ie,y.error.main,.5)),L(y.LinearProgress,"infoBg",P(Ie,y.info.main,.5)),L(y.LinearProgress,"successBg",P(Ie,y.success.main,.5)),L(y.LinearProgress,"warningBg",P(Ie,y.warning.main,.5)),L(y.Skeleton,"bg",I?P(Tr,y.text.primary,.13):`rgba(${w("palette-text-primaryChannel")} / 0.13)`),L(y.Slider,"primaryTrack",P(Ie,y.primary.main,.5)),L(y.Slider,"secondaryTrack",P(Ie,y.secondary.main,.5)),L(y.Slider,"errorTrack",P(Ie,y.error.main,.5)),L(y.Slider,"infoTrack",P(Ie,y.info.main,.5)),L(y.Slider,"successTrack",P(Ie,y.success.main,.5)),L(y.Slider,"warningTrack",P(Ie,y.warning.main,.5));const te=I?P(Ee,y.background.default,.985):Jo(y.background.default,.98);L(y.SnackbarContent,"bg",te),L(y.SnackbarContent,"color",Ht(()=>I?Hs.text.primary:y.getContrastText(te))),L(y.SpeedDialAction,"fabHoverBg",Jo(y.background.paper,.15)),L(y.StepConnector,"border",w("palette-grey-600")),L(y.StepContent,"border",w("palette-grey-600")),L(y.Switch,"defaultColor",w("palette-grey-300")),L(y.Switch,"defaultDisabledColor",w("palette-grey-600")),L(y.Switch,"primaryDisabledColor",P(Ie,y.primary.main,.55)),L(y.Switch,"secondaryDisabledColor",P(Ie,y.secondary.main,.55)),L(y.Switch,"errorDisabledColor",P(Ie,y.error.main,.55)),L(y.Switch,"infoDisabledColor",P(Ie,y.info.main,.55)),L(y.Switch,"successDisabledColor",P(Ie,y.success.main,.55)),L(y.Switch,"warningDisabledColor",P(Ie,y.warning.main,.55)),L(y.TableCell,"border",P(Ie,P(Tr,y.divider,1),.68)),L(y.Tooltip,"bg",P(Tr,y.grey[700],.92))}rr(y.background,"default"),rr(y.background,"paper"),rr(y.common,"background"),rr(y.common,"onBackground"),rr(y,"divider"),Object.keys(y).forEach(te=>{const d=y[te];te!=="tonalOffset"&&d&&typeof d=="object"&&(d.main&&L(y[te],"mainChannel",So(Co(d.main))),d.light&&L(y[te],"lightChannel",So(Co(d.light))),d.dark&&L(y[te],"darkChannel",So(Co(d.dark))),d.contrastText&&L(y[te],"contrastTextChannel",So(Co(d.contrastText))),te==="text"&&(rr(y[te],"primary"),rr(y[te],"secondary")),te==="action"&&(d.active&&rr(y[te],"active"),d.selected&&rr(y[te],"selected")))})}),R=r.reduce((O,y)=>yt(O,y),R);const H={prefix:a,disableCssColorScheme:s,shouldSkipGeneratingVar:l,getSelector:Ud(R),enableContrastVars:c},{vars:E,generateThemeVars:G,generateStyleSheets:Z}=fd(R,H);return R.vars=E,Object.entries(R.colorSchemes[R.defaultColorScheme]).forEach(([O,y])=>{R[O]=y}),R.generateThemeVars=G,R.generateStyleSheets=Z,R.generateSpacing=function(){return Ns(x.spacing,xi(this))},R.getColorSchemeSelector=md(u),R.spacing=R.generateSpacing(),R.shouldSkipGeneratingVar=l,R.unstable_sxConfig={...Sn,...x==null?void 0:x.unstable_sxConfig},R.unstable_sx=function(y){return Cn({sx:y,theme:this})},R.toRuntimeSource=Gs,R}function cs(e,r,n){e.colorSchemes&&n&&(e.colorSchemes[r]={...n!==!0&&n,palette:bi({...n===!0?{}:n.palette,mode:r})})}function Kd(e={},...r){const{palette:n,cssVariables:i=!1,colorSchemes:s=n?void 0:{light:!0},defaultColorScheme:a=n==null?void 0:n.mode,...c}=e,l=a||"light",u=s==null?void 0:s[l],g={...s,...n?{[l]:{...typeof u!="boolean"&&u,palette:n}}:void 0};if(i===!1){if(!("colorSchemes"in e))return ni(e,...r);let x=n;"palette"in e||g[l]&&(g[l]!==!0?x=g[l].palette:l==="dark"&&(x={mode:"dark"}));const f=ni({...e,palette:x},...r);return f.defaultColorScheme=l,f.colorSchemes=g,f.palette.mode==="light"&&(f.colorSchemes.light={...g.light!==!0&&g.light,palette:f.palette},cs(f,"dark",g.dark)),f.palette.mode==="dark"&&(f.colorSchemes.dark={...g.dark!==!0&&g.dark,palette:f.palette},cs(f,"light",g.light)),f}return!n&&!("light"in g)&&l==="light"&&(g.light=!0),Jd({...c,colorSchemes:g,defaultColorScheme:l,...typeof i!="boolean"&&i},...r)}const Xd=Kd();function pt(){const e=rd(Xd);return process.env.NODE_ENV!=="production"&&ln.useDebugValue(e),e[Ul]||e}async function Qd(e,r,n){try{new URL(e)}catch{throw new Error("Please enter a valid URL")}const i={"Content-Type":"application/json"};r&&(i.Authorization=`Bearer ${r}`);const s=new AbortController,a=setTimeout(()=>s.abort(),3e4);let c;try{c=await fetch(e,{headers:i,signal:s.signal})}catch(g){throw clearTimeout(a),(g==null?void 0:g.name)==="AbortError"?new Error("Request timed out after 30 seconds"):new Error("Failed to fetch — check the URL and your network connection")}finally{clearTimeout(a)}if(c.status===401)throw new Error("Authentication failed (401) — check your API key");if(!c.ok)throw new Error(`API error ${c.status}: ${c.statusText}`);let l;try{l=await c.json()}catch{throw new Error("Response is not valid JSON")}let u;if(Array.isArray(l))u=l;else if(n&&l[n]&&Array.isArray(l[n]))u=l[n];else{const x=["data","results","items","records"].find(f=>l[f]&&Array.isArray(l[f]));if(x)u=l[x];else throw new Error("API response must be a JSON array, or specify the data path key.")}return{data:u,source:e,fetchedAt:new Date().toISOString()}}function Zd(e,r){return r.map(n=>`${n.x}px ${n.y}px ${n.blur}px ${n.spread}px ${_(e.palette.common.black,n.opacity)}`).join(", ")}const eu={menu:[{x:0,y:8,blur:16,spread:4,opacity:.12},{x:0,y:4,blur:16,spread:0,opacity:.08},{x:0,y:0,blur:0,spread:1,opacity:.05}],restButton:[{x:0,y:1,blur:2,spread:0,opacity:.3},{x:0,y:1,blur:3,spread:1,opacity:.15}],restButtonLight:[{x:0,y:1,blur:2,spread:0,opacity:.1},{x:0,y:1,blur:3,spread:1,opacity:.05}],hoverButton:[{x:0,y:1,blur:3,spread:0,opacity:.3},{x:0,y:4,blur:8,spread:3,opacity:.15}],pressedButton:[{x:0,y:1,blur:2,spread:0,opacity:.3}],pressedButtonLight:[{x:0,y:1,blur:2,spread:0,opacity:.1}],small:[{x:0,y:2,blur:6,spread:0,opacity:.15}],cardRest:[{x:0,y:1,blur:3,spread:0,opacity:.08},{x:0,y:1,blur:2,spread:0,opacity:.06}],cardHover:[{x:0,y:4,blur:16,spread:0,opacity:.15},{x:0,y:1,blur:4,spread:0,opacity:.08}],popover:[{x:0,y:4,blur:20,spread:0,opacity:.15},{x:0,y:1,blur:6,spread:0,opacity:.1}],flatHover:[{x:0,y:1,blur:2,spread:0,opacity:.06}]};function be(e,r){return Zd(e,eu[r])}function ot(e){return`${Number(e.shape.borderRadius)*1.5}px`}function _o(e){return`${Number(e.shape.borderRadius)}px`}function ds(e){const r=e.tokens;return{containerPad:`${(r==null?void 0:r.containerPad)??16}px`,cardGap:`${(r==null?void 0:r.cardGap)??12}px`}}function ct(e){const r=e.tokens,n=(r==null?void 0:r.highlight)||e.palette.primary.main;return{main:n,bg:`var(--highlight-bg, ${_(n,.08)})`,hoverBg:`var(--highlight-hover, ${_(n,.12)})`}}function de(e,r="menu"){const n=e.tokens;return{paper:{boxShadow:(n==null?void 0:n.cardBodyShadow)||be(e,r),border:n!=null&&n.cardBodyBorder&&n.cardBodyBorder!=="none"?n.cardBodyBorder:"none"},header:{backgroundColor:(n==null?void 0:n.cardHdrBg)||"transparent",borderBottom:(n==null?void 0:n.cardHdrBorder)||"none",boxShadow:(n==null?void 0:n.cardHdrAccent)||"none"}}}function tu({isOpen:e,onClose:r,onCreate:n,preloadedData:i,preloadedDataLabel:s}){const[a,c]=p.useState(""),[l,u]=p.useState(!1),[g,x]=p.useState(""),[f,S]=p.useState(null),[C,B]=p.useState(null),[v,m]=p.useState(!1),[T,h]=p.useState(""),z=p.useRef(null),[I,b]=p.useState("json"),[R,H]=p.useState(""),[E,G]=p.useState(""),[Z,O]=p.useState(""),[y,w]=p.useState("idle"),[P,te]=p.useState(""),[d,J]=p.useState(null),[re,Se]=p.useState(0),F=async W=>{if(h(""),!W.name.endsWith(".json")){h("Only .json files are allowed");return}const ie=10*1024*1024;if(W.size>ie){h("File size exceeds 10MB limit");return}try{const U=await W.text();let ne;try{ne=JSON.parse(U)}catch{h("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(ne)){h("JSON must be an array of objects");return}if(ne.length===0){h("No data rows found in JSON file");return}S(W),B(ne)}catch{h("Network error — please try again")}},X=W=>{W.preventDefault();const ie=W.dataTransfer.files[0];ie&&F(ie)},ue=async()=>{if(R.trim()){w("loading"),te("");try{const W=await Qd(R.trim(),E.trim()||void 0,Z.trim()||void 0);J(W.data),Se(W.data.length),w("ready")}catch(W){te((W==null?void 0:W.message)||"Connection failed"),w("error")}}},pe=()=>{if(!a.trim()){u(!0);return}const W=I==="api"?d:i||C;W&&(n(a.trim(),g.trim(),W),K())},K=()=>{c(""),u(!1),x(""),S(null),B(null),h(""),b("json"),H(""),G(""),O(""),w("idle"),te(""),J(null),Se(0),r()},he=i||C,ae=l&&!a.trim();return a.trim(),t.jsxs(t.Fragment,{children:[t.jsxs(o.Dialog,{open:e,onClose:K,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:W=>({borderRadius:ot(W),width:480,maxHeight:"min(720px, calc(100vh - 120px))",my:"auto",display:"flex",flexDirection:"column",...de(W).paper})},children:[t.jsxs(o.DialogTitle,{sx:W=>({display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2.5,fontWeight:ie=>ie.typography.h6.fontWeight||500,fontSize:ie=>ie.typography.h6.fontSize||"1.125rem",color:"text.primary",letterSpacing:"-0.01em",...de(W).header}),children:["Create new report",t.jsx(o.IconButton,{onClick:K,size:"small",sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.Close,{sx:{fontSize:18}})})]}),t.jsx(o.DialogContent,{sx:{px:3,pt:2,pb:2,overflowY:"auto"},children:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2,pt:2},children:[t.jsx(o.TextField,{label:"Report name",required:!0,fullWidth:!0,value:a,onChange:W=>{c(W.target.value),l&&W.target.value.trim()&&u(!1)},placeholder:"Enter report name",autoFocus:!0,error:ae,helperText:ae?"Report name is required":void 0,inputProps:{maxLength:255},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:g,onChange:W=>x(W.target.value),placeholder:"Add details about this report",inputProps:{maxLength:500},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.Tabs,{value:I==="json"?0:1,onChange:(W,ie)=>{b(ie===0?"json":"api"),w("idle"),te("")},variant:"fullWidth",sx:{borderBottom:1,borderColor:"divider",minHeight:40,"& .MuiTabs-indicator":{height:3,bgcolor:"primary.main"}},children:[t.jsx(o.Tab,{label:"Upload JSON",icon:t.jsx($.Description,{fontSize:"small"}),iconPosition:"start",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,minHeight:40,py:.5,borderRadius:"8px 8px 0 0","&.Mui-selected":{color:"text.primary",fontWeight:600,bgcolor:W=>`var(--highlight-hover, ${_(W.palette.primary.main,.15)})`},"&:hover":{bgcolor:W=>`var(--highlight-hover, ${_(W.palette.primary.main,.08)})`}}}),t.jsx(o.Tab,{label:"Connect API",icon:t.jsx($.Api,{fontSize:"small"}),iconPosition:"start",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,minHeight:40,py:.5,borderRadius:"8px 8px 0 0","&.Mui-selected":{color:"text.primary",fontWeight:600,bgcolor:W=>`var(--highlight-hover, ${_(W.palette.primary.main,.15)})`},"&:hover":{bgcolor:W=>`var(--highlight-hover, ${_(W.palette.primary.main,.08)})`}}})]}),I==="json"&&t.jsx(o.Box,{children:i?t.jsxs(o.Box,{sx:{border:"1.5px solid",borderColor:"success.main",borderRadius:2,p:2.5,bgcolor:W=>_(W.palette.success.main,.04),display:"flex",alignItems:"center",gap:2},children:[t.jsx(o.Box,{sx:{width:36,height:36,borderRadius:"50%",bgcolor:W=>_(W.palette.success.main,.12),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx($.CheckCircle,{sx:{fontSize:20,color:"success.main"}})}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.dark",fontSize:"0.875rem"},children:s||`${i.length.toLocaleString()} records loaded`}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary"},children:"Data source is connected — ready to create"})]})]}):t.jsxs(t.Fragment,{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:()=>m(!0),sx:{p:.25,color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:t.jsx($.Info,{sx:{fontSize:16}})})]}),t.jsxs(o.Box,{onDrop:X,onDragOver:W=>W.preventDefault(),onPaste:W=>W.preventDefault(),onClick:()=>{var W;return(W=z.current)==null?void 0:W.click()},sx:{position:"relative",border:"1.5px",borderStyle:C?"solid":"dashed",borderColor:C?"success.main":T?"error.main":"primary.main",borderRadius:2,p:3,textAlign:"center",cursor:"pointer",bgcolor:C?W=>_(W.palette.success.main,.04):T?W=>_(W.palette.error.main,.04):W=>_(W.palette.primary.main,.04),transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:C?W=>_(W.palette.success.main,.08):T?W=>_(W.palette.error.main,.08):W=>_(W.palette.primary.main,.08),borderColor:C?"success.dark":T?"error.dark":"primary.dark"}},children:[t.jsx(o.Box,{component:"input",ref:z,type:"file",accept:".json",sx:{display:"none"},onChange:W=>{var ie;return((ie=W.target.files)==null?void 0:ie[0])&&F(W.target.files[0])}}),C?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:W=>_(W.palette.success.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:.5},children:t.jsx($.CheckCircle,{sx:{fontSize:24,color:"success.main"}})}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.main",fontSize:"0.875rem"},children:f==null?void 0:f.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:W=>_(W.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mx:"auto",mb:1.5},children:t.jsx($.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"}),T&&t.jsx(o.Box,{sx:{mt:1.25,p:.75,borderRadius:1,bgcolor:W=>_(W.palette.error.main,.08),border:1,borderColor:W=>_(W.palette.error.main,.2)},children:t.jsx(o.Typography,{variant:"caption",sx:{color:"error.main",fontSize:"0.6875rem",fontWeight:500},children:T})})]})]})]})}),I==="api"&&t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[t.jsx(o.TextField,{label:"API Endpoint URL",required:!0,fullWidth:!0,size:"small",value:R,onChange:W=>{H(W.target.value),w("idle")},placeholder:"http://localhost:8000/api/reports/sales-pipeline/data/flat",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:"API Key (optional)",fullWidth:!0,size:"small",value:E,onChange:W=>G(W.target.value),placeholder:"Leave blank if no auth required",InputProps:{startAdornment:t.jsx(o.InputAdornment,{position:"start",children:t.jsx($.Lock,{sx:{fontSize:16,color:"text.secondary"}})})},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:"Response data path (optional)",fullWidth:!0,size:"small",value:Z,onChange:W=>O(W.target.value),placeholder:"data (leave blank if API returns a plain array)",helperText:'If your API returns { "data": [...] }, enter: data',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}},"& .MuiFormHelperText-root":{fontSize:"0.75rem",mx:0}}}),t.jsx(o.Button,{variant:"outlined",fullWidth:!0,disabled:!R.trim()||y==="loading",onClick:ue,startIcon:y==="loading"?t.jsx(o.CircularProgress,{size:16,color:"inherit"}):t.jsx($.Api,{}),sx:{fontSize:"0.875rem",borderRadius:1,py:.875,borderColor:"primary.main",color:"primary.main","&:hover":{bgcolor:W=>_(W.palette.primary.main,.04),borderColor:"primary.dark"},"&:disabled":{borderColor:"action.disabledBackground",color:"action.disabled"}},children:y==="loading"?"Connecting...":"Test Connection & Load Data"}),y==="ready"&&t.jsxs(o.Box,{sx:{border:"1.5px solid",borderColor:"success.main",borderRadius:2,p:2,bgcolor:W=>_(W.palette.success.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[t.jsx($.CheckCircle,{sx:{fontSize:20,color:"success.main",flexShrink:0,mt:.1}}),t.jsxs(o.Box,{children:[t.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.dark",fontSize:"0.875rem"},children:[re.toLocaleString()," records loaded — ready to create"]}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.75rem",wordBreak:"break-all",display:"block",mt:.25},children:R})]})]}),y==="error"&&t.jsxs(o.Box,{sx:{border:"1.5px solid",borderColor:"error.main",borderRadius:2,p:2,bgcolor:W=>_(W.palette.error.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[t.jsx($.ErrorOutline,{sx:{fontSize:20,color:"error.main",flexShrink:0,mt:.1}}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,color:"error.main",fontSize:"0.875rem"},children:"Connection failed"}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.75rem",display:"block",mt:.25},children:P})]})]})]})]})}),t.jsxs(o.DialogActions,{sx:{px:3,py:2,gap:1,borderTop:"1px solid",borderColor:"divider"},children:[t.jsx(o.Button,{onClick:K,variant:"text",sx:{color:"primary.main",fontSize:"0.875rem",borderRadius:W=>`${W.shape.borderRadius}px`,px:2,py:.625,minWidth:64,"&:hover":{bgcolor:W=>_(W.palette.primary.main,.04)}},children:"Cancel"}),t.jsx(o.Button,{onClick:pe,disabled:I==="json"&&!he||I==="api"&&y!=="ready",variant:"contained",sx:{fontSize:"0.875rem",borderRadius:W=>`${W.shape.borderRadius}px`,px:2.5,py:.625,minWidth:64,"&:disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Create"})]})]}),t.jsxs(o.Dialog,{open:v,onClose:()=>m(!1),maxWidth:"sm",PaperProps:{sx:W=>({borderRadius:3,width:560,maxHeight:"80vh",...de(W).paper})},children:[t.jsxs(o.DialogTitle,{sx:W=>({display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,fontWeight:500,fontSize:"1.25rem",color:"text.primary",letterSpacing:"-0.01em",...de(W).header}),children:["JSON format guide",t.jsx(o.IconButton,{onClick:()=>m(!1),size:"small",sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:t.jsx($.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:`[
172
172
  {
173
173
  "id": 1,
174
174
  "customerName": "John Smith",
@@ -178,7 +178,7 @@ To suppress this warning, you need to explicitly provide the \`palette.${r}Chann
178
178
  "memberSince": "2024-01-15",
179
179
  "status": "active"
180
180
  }
181
- ]`})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Supported data types"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"Text, numbers, booleans, dates, and null values"})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Guidelines"}),t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"• Must be valid JSON with array format"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"• All objects should have consistent field names"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:'• Field names auto-format (e.g., "customerName" → "Customer Name")'})]})]})]})}),t.jsx(o.DialogActions,{sx:{px:3,py:2},children:t.jsx(o.Button,{onClick:()=>y(!1),variant:"contained",sx:{fontSize:"0.875rem",borderRadius:D=>`${D.shape.borderRadius}px`,px:2.5,py:.625,minWidth:64},children:"Got it"})})]})]})}function Ys({isOpen:e,onClose:r,content:n}){return e?t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"md",fullWidth:!0,PaperProps:{sx:i=>({borderRadius:ot(i),maxHeight:"min(640px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",...ue(i).paper})},children:[t.jsxs(o.DialogTitle,{sx:i=>({display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,...ue(i).header}),children:["JSON Format Guide",t.jsx(o.IconButton,{onClick:r,size:"small",sx:{color:"text.secondary"},children:t.jsx(O.Close,{sx:{fontSize:20}})})]}),t.jsx(o.DialogContent,{dividers:!0,sx:{overflowY:"auto",flex:1},children:n?typeof n=="string"?t.jsx(o.Typography,{variant:"body2",sx:{whiteSpace:"pre-wrap"},children:n}):n:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:3,py:1},children:[t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Expected JSON Structure"}),t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["The uploaded JSON must be an ",t.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."]})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Example JSON"}),t.jsx(o.Paper,{elevation:0,sx:{p:2,bgcolor:"action.hover",border:1,borderColor:"divider",borderRadius:1,overflowX:"auto"},children:t.jsx(o.Box,{component:"pre",sx:{fontSize:"caption.fontSize",fontFamily:"monospace",m:0},children:`[
181
+ ]`})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Supported data types"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"Text, numbers, booleans, dates, and null values"})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Guidelines"}),t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"• Must be valid JSON with array format"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"• All objects should have consistent field names"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:'• Field names auto-format (e.g., "customerName" → "Customer Name")'})]})]})]})}),t.jsx(o.DialogActions,{sx:{px:3,py:2},children:t.jsx(o.Button,{onClick:()=>m(!1),variant:"contained",sx:{fontSize:"0.875rem",borderRadius:W=>`${W.shape.borderRadius}px`,px:2.5,py:.625,minWidth:64},children:"Got it"})})]})]})}function Js({isOpen:e,onClose:r,content:n}){return e?t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"md",fullWidth:!0,PaperProps:{sx:i=>({borderRadius:ot(i),maxHeight:"min(640px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",...de(i).paper})},children:[t.jsxs(o.DialogTitle,{sx:i=>({display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,...de(i).header}),children:["JSON Format Guide",t.jsx(o.IconButton,{onClick:r,size:"small",sx:{color:"text.secondary"},children:t.jsx($.Close,{sx:{fontSize:20}})})]}),t.jsx(o.DialogContent,{dividers:!0,sx:{overflowY:"auto",flex:1},children:n?typeof n=="string"?t.jsx(o.Typography,{variant:"body2",sx:{whiteSpace:"pre-wrap"},children:n}):n:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:3,py:1},children:[t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Expected JSON Structure"}),t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["The uploaded JSON must be an ",t.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."]})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Example JSON"}),t.jsx(o.Paper,{elevation:0,sx:{p:2,bgcolor:"action.hover",border:1,borderColor:"divider",borderRadius:1,overflowX:"auto"},children:t.jsx(o.Box,{component:"pre",sx:{fontSize:"caption.fontSize",fontFamily:"monospace",m:0},children:`[
182
182
  {
183
183
  "Active Sessions": 33,
184
184
  "Active State": true,
@@ -188,10 +188,10 @@ To suppress this warning, you need to explicitly provide the \`palette.${r}Chann
188
188
  "Region": "Europe",
189
189
  "Subscription Type": "Basic"
190
190
  }
191
- ]`})})]}),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:i=>i.typography.body2.fontWeight||500,fontSize:i=>i.typography.body2.fontSize||"0.875rem",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:i=>i.typography.body2.fontWeight||500,fontSize:i=>i.typography.body2.fontSize||"0.875rem",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:i=>i.typography.body2.fontWeight||500,fontSize:i=>i.typography.body2.fontSize||"0.875rem",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:i=>i.typography.body2.fontWeight||500,fontSize:i=>i.typography.body2.fontSize||"0.875rem",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 divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:t.jsx(o.Button,{onClick:r,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",px:3,py:.875,minHeight:36,borderRadius:i=>`${i.shape.borderRadius}px`,boxShadow:i=>ye(i,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:i=>ye(i,"hoverButton")},"&:active":{boxShadow:i=>ye(i,"pressedButton"),transform:"translateY(1px)"}},children:"Got it"})})]}):null}function eu({onFileUpload:e,onError:r,isUploading:n,jsonGuideContent:i}){const[s,a]=p.useState(!1),[c,l]=p.useState(""),[u,g]=p.useState(!1),f=p.useRef(null),m=async x=>{if(!x.name.endsWith(".json")){r("Only .json files are allowed");return}const j=10*1024*1024;if(x.size>j){r("File size exceeds 10MB limit");return}l(x.name);try{const E=await x.text();let S;try{S=JSON.parse(E)}catch{r("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(S)){r("JSON must be an array of objects");return}if(S.length===0){r("No data rows found in JSON file");return}e(S)}catch{r("Network error — please try again")}finally{l("")}},v=x=>{x.preventDefault(),a(!0)},C=x=>{x.preventDefault(),a(!1)},B=x=>{x.preventDefault(),a(!1);const j=x.dataTransfer.files[0];j&&m(j)},b=()=>{var x;(x=f.current)==null||x.click()},y=x=>{var E;const j=(E=x.target.files)==null?void 0:E[0];j&&m(j)},z=x=>{x.stopPropagation(),g(!0)};return t.jsxs(t.Fragment,{children:[t.jsxs(o.Box,{onDragOver:v,onDragLeave:C,onDrop:B,onPaste:x=>x.preventDefault(),onClick:b,sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderStyle:"dashed",borderColor:s?"primary.main":"divider",bgcolor:s?x=>$(x.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:s?"primary.main":"text.secondary"}},children:[t.jsx(o.Box,{component:"input",ref:f,type:"file",accept:".json",onChange:y,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:x=>x.typography.body2.fontWeight||500,fontSize:x=>x.typography.body2.fontSize||"0.875rem",mb:.5},children:"Uploading..."}),c&&t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:c})]}):t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:x=>$(x.palette.primary.main,.12),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx(O.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:z,size:"small",sx:{border:1,borderColor:"divider","&:hover":{borderColor:"text.secondary",bgcolor:"action.hover"}},title:"View JSON format guide",children:t.jsx(O.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(Ys,{isOpen:u,onClose:()=>g(!1),content:i})]})}function tu({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:i=>i.typography.h6.fontWeight||600,fontSize:i=>i.typography.h6.fontSize||"1.25rem",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:i=>i.typography.h6.fontWeight||600,fontSize:i=>i.typography.subtitle2.fontSize||"0.875rem"},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?s=>$(s.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(O.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 ru({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=>$(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=>$(n.palette.error.main,.3),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx(O.ErrorOutline,{color:"error",sx:{fontSize:32}})}),t.jsx(o.Typography,{variant:"h6",color:"error.main",sx:{fontWeight:n=>n.typography.h6.fontWeight||600,fontSize:n=>n.typography.h6.fontSize||"1.25rem",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(O.Upload,{sx:{fontSize:16}}),onClick:r,sx:{fontWeight:500},children:"Try Again"})]})}function qs({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=>$(i.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:3},children:t.jsx(O.Description,{sx:{fontSize:36,color:"primary.main"}})}),t.jsx(o.Typography,{variant:"h5",sx:{fontWeight:i=>i.typography.h5.fontWeight||500,mb:1,color:i=>i.typography.h5.color||"text.primary",fontSize:i=>i.typography.h5.fontSize||"1.125rem"},children:e}),t.jsx(o.Typography,{variant:"body1",sx:{textAlign:"center",maxWidth:520,color:"text.secondary",fontSize:i=>i.typography.body2.fontSize||"0.875rem",lineHeight:1.5},children:r})]})}function ou({value:e,onChange:r,searchHistory:n,onAddToHistory:i,onToggleFavourite:s,onDeleteHistory:a,disabled:c}){const[l,u]=p.useState(!1),[g,f]=p.useState(!1),[m,v]=p.useState(-1),C=p.useRef(null),B=p.useRef(null);p.useEffect(()=>{function T(F){C.current&&!C.current.contains(F.target)&&(u(!1),f(!1))}return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]);const b=p.useCallback(()=>{f(!0),v(-1),n.length>0&&u(!0)},[n.length]),y=p.useCallback(T=>{r(T),v(-1)},[r]),z=p.useCallback(T=>{var F;r(T),i(T),u(!1),(F=B.current)==null||F.blur()},[r,i]),x=p.useCallback(T=>{v(-1),z(T)},[z]),j=p.useCallback(T=>{var F;T.key==="Enter"?m>=0&&m<n.length?(T.preventDefault(),x(n[m].query)):e.trim()&&z(e.trim()):T.key==="Escape"?(u(!1),v(-1),(F=B.current)==null||F.blur()):T.key==="ArrowDown"?(T.preventDefault(),n.length>0&&(l||u(!0),v(X=>X<n.length-1?X+1:X))):T.key==="ArrowUp"&&(T.preventDefault(),v(X=>X>0?X-1:-1))},[m,n,e,l,x,z]),E=p.useCallback(()=>{var T;r(""),(T=B.current)==null||T.focus()},[r]),S=p.useMemo(()=>n.filter(T=>T.isFavourite),[n]),R=p.useMemo(()=>n.filter(T=>!T.isFavourite),[n]),q=l&&n.length>0;return t.jsxs(o.Box,{sx:{position:"relative",width:240},ref:C,children:[t.jsx(o.TextField,{inputRef:B,size:"small",fullWidth:!0,value:e,onChange:T=>y(T.target.value),onFocus:b,onKeyDown:j,placeholder:"Search data...",disabled:c,sx:{"& .MuiOutlinedInput-root":{borderRadius:"20px",fontSize:"0.875rem",bgcolor:"background.paper",height:"36px","& fieldset":{borderColor:T=>$(T.palette.text.primary,.3),transition:"all 0.15s ease"},"&:hover":{bgcolor:"action.hover"},"&:hover fieldset":{borderColor:T=>$(T.palette.text.primary,.5)},"&.Mui-focused":{bgcolor:"background.paper"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}},"& .MuiOutlinedInput-input":{py:"6px",px:"8px",color:"text.primary"}},InputProps:{startAdornment:t.jsx(o.InputAdornment,{position:"start",sx:{ml:.5},children:t.jsx(O.Search,{sx:{fontSize:18,color:"text.secondary"}})}),endAdornment:e?t.jsx(o.InputAdornment,{position:"end",children:t.jsx(o.IconButton,{size:"small",onClick:E,edge:"end",sx:{mr:-.5},children:t.jsx(O.Close,{sx:{fontSize:16}})})}):null}}),q&&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:T=>T.typography.caption.fontWeight||600,fontSize:T=>T.typography.caption.fontSize||"0.75rem",textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Favourite Searches"}),S.map((T,F)=>t.jsx(cs,{entry:T,isSelected:m===F,onClick:()=>x(T.query),onToggleFavourite:()=>s(T.query),onDelete:()=>a(T.query)},`fav-${T.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:T=>T.typography.caption.fontWeight||600,fontSize:T=>T.typography.caption.fontSize||"0.75rem",textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Recent Searches"}),R.map((T,F)=>{const X=S.length+F;return t.jsx(cs,{entry:T,isSelected:m===X,onClick:()=>x(T.query),onToggleFavourite:()=>s(T.query),onDelete:()=>a(T.query)},`recent-${T.query}`)})]})]})]})}const cs=p.memo(function({entry:r,isSelected:n,onClick:i,onToggleFavourite:s,onDelete:a}){const c=p.useCallback(u=>{u.stopPropagation(),s()},[s]),l=p.useCallback(u=>{u.stopPropagation(),a()},[a]);return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:1.5,py:1,cursor:"pointer",bgcolor:n?u=>$(u.palette.primary.main,.12):"transparent","&:hover":{bgcolor:n?u=>$(u.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(O.Star,{sx:{fontSize:14,color:"warning.light"}}):t.jsx(O.StarBorder,{sx:{fontSize:14,color:"action.disabled"}})}),t.jsx(o.IconButton,{size:"small",onClick:l,title:"Delete from history",sx:{p:.5,"&:hover":{color:"error.main"}},children:t.jsx(O.Delete,{sx:{fontSize:14,opacity:.5}})})]})]})});function nu({views:e,activeViewId:r,isDirty:n,onSelectView:i,onCreateView:s,onToggleDefault:a,onToggleFavorite:c,onRestoreView:l,onPermanentDelete:u,onEditView:g,onCloneView:f,onCopyLink:m,onDeleteView:v,onPromoteToGlobal:C,isReadOnly:B,isAdmin:b=!1}){const y=ht(),[z,x]=p.useState(!1),[j,E]=p.useState(!1),[S,R]=p.useState({top:0,left:0}),[q,T]=p.useState(null),[F,X]=p.useState(null),W=p.useRef(null),h=p.useRef(null),I=e.find(D=>D.id===r),N=I==null?void 0:I.isDefault,d=(D,ee)=>D.name.localeCompare(ee.name),oe=e.filter(D=>D.scope==="global"&&!D.isDeleted).sort(d),G=e.filter(D=>D.scope!=="global"&&!D.isDeleted).sort(d),te=e.filter(D=>D.isFavorite&&!D.isDeleted).sort(d),ge=e.filter(D=>D.isDeleted);p.useEffect(()=>{if(z&&h.current){const D=h.current.getBoundingClientRect();R({top:D.bottom+window.scrollY+8,left:D.right+window.scrollX-320})}},[z]),p.useEffect(()=>{const D=ee=>{W.current&&!W.current.contains(ee.target)&&h.current&&!h.current.contains(ee.target)&&x(!1)};return z&&document.addEventListener("mousedown",D),()=>{document.removeEventListener("mousedown",D)}},[z]);const V=D=>{if(n&&D!==r){T(D),x(!1);return}i(D),x(!1)},K=()=>{q&&(i(q),T(null))},ce=()=>{T(null)},de=(D,ee=!1)=>{const xe=D.scope==="global",ae=!B&&(!xe||b),Te=b&&!xe;return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:r===D.id?$(y.palette.primary.main,.12):"transparent",transition:"background-color 0.2s","&:hover":{backgroundColor:r===D.id?$(y.palette.primary.main,.12):y.palette.action.hover}},children:[t.jsxs(o.Button,{onClick:()=>V(D.id),sx:{display:"flex",alignItems:"center",gap:1,flex:1,textAlign:"left",minWidth:0,justifyContent:"flex-start",color:"inherit",p:0,"&:hover":{backgroundColor:"transparent"}},children:[r===D.id&&t.jsx(O.Check,{sx:{fontSize:16,flexShrink:0}}),r!==D.id&&t.jsx(o.Box,{sx:{width:"16px",flexShrink:0}}),t.jsx(o.Typography,{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:r===D.id?y.palette.primary.dark:y.palette.text.primary,fontWeight:r===D.id?Y=>Y.typography.body2.fontWeight||500:400,fontSize:Y=>Y.typography.body2.fontSize||"0.875rem"},children:D.name}),ee&&t.jsx(o.Typography,{component:"span",sx:{fontSize:"caption.fontSize",color:y.palette.text.secondary,backgroundColor:y.palette.action.selected,px:1,py:.25,borderRadius:1,flexShrink:0},children:"Default"})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[ae&&c&&t.jsx(o.IconButton,{onClick:Y=>{Y.stopPropagation(),c(D.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:y.palette.action.hover}},title:D.isFavorite?"Remove from favorites":"Add to favorites",children:t.jsx(O.Star,{sx:{fontSize:16}})}),ae&&a&&!D.isDefault&&t.jsx(o.IconButton,{onClick:Y=>{Y.stopPropagation(),a(D.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:y.palette.action.hover}},title:"Set as default",children:t.jsx(O.RadioButtonUnchecked,{sx:{fontSize:16}})}),(ae||Te)&&(g||f||m||v||Te&&C)&&t.jsx(o.IconButton,{onClick:Y=>{Y.stopPropagation(),X({el:Y.currentTarget,view:D})},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:y.palette.action.hover}},title:"More actions",children:t.jsx(O.MoreVert,{sx:{fontSize:16}})})]})]},D.id)},ne=D=>t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:y.palette.action.hover},children:[t.jsx(o.Typography,{sx:{color:y.palette.text.secondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:D.name}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[l&&t.jsx(o.IconButton,{onClick:ee=>{ee.stopPropagation(),l(D.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:y.palette.action.hover}},title:"Restore view",children:t.jsx(O.Undo,{sx:{fontSize:16,color:"success.main"}})}),u&&t.jsx(o.IconButton,{onClick:ee=>{ee.stopPropagation(),u(D.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:y.palette.action.hover}},title:"Delete permanently",children:t.jsx(O.Delete,{sx:{fontSize:16,color:"error.main"}})})]})]},D.id),Q=n||!N,pe=n;return t.jsxs(o.Box,{sx:{position:"relative"},children:[t.jsxs(o.Button,{ref:h,onClick:()=>x(!z),variant:"outlined",size:"small",endIcon:t.jsx(O.KeyboardArrowDown,{sx:{fontSize:18}}),sx:{position:"relative",minWidth:140,maxWidth:220,justifyContent:"space-between",fontSize:"0.8125rem",textTransform:"none",color:Q?"warning.main":"text.primary",borderColor:Q?"warning.main":"divider",bgcolor:Q?$(y.palette.warning.main,.12):"transparent",borderRadius:1,py:.5,px:1.25,transition:"all 0.15s ease","&:hover":{borderColor:Q?"warning.dark":"primary.main",bgcolor:Q?$(y.palette.warning.main,.2):$(y.palette.text.primary,.06),color:Q?"warning.dark":"text.primary"}},title:`View: ${(I==null?void 0:I.name)||"Default View"}`,children:[t.jsx(o.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis"},children:(I==null?void 0:I.name)||"Default View"}),pe&&t.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"}})]}),z&&bs.createPortal(t.jsxs(o.Box,{ref:W,sx:{position:"fixed",width:"320px",backgroundColor:y.palette.background.paper,border:`1px solid ${y.palette.divider}`,borderRadius:1,boxShadow:y.shadows[8],zIndex:50,maxHeight:"500px",overflowY:"auto",top:S.top,left:S.left},children:[oe.length>0&&t.jsxs(o.Box,{sx:{py:.5},children:[t.jsx(o.Typography,{sx:{px:2,py:1,fontSize:D=>D.typography.caption.fontSize||"caption.fontSize",fontWeight:D=>D.typography.caption.fontWeight||600,color:y.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Global Views"}),oe.map(D=>de(D,D.isDefault))]}),te.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${y.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:y.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",gap:.5},children:[t.jsx(O.Star,{sx:{fontSize:12,color:"warning.light"}}),t.jsx(o.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:"Favorite Views"})]}),te.map(D=>de(D))]})]}),G.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${y.palette.divider}`}}),t.jsxs(o.Box,{sx:{py:.5},children:[t.jsx(o.Typography,{sx:{px:2,py:1,fontSize:D=>D.typography.caption.fontSize||"caption.fontSize",fontWeight:D=>D.typography.caption.fontWeight||600,color:y.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Personal Views"}),G.map(D=>de(D))]})]}),ge.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${y.palette.divider}`}}),t.jsxs(o.Box,{sx:{py:.5},children:[t.jsxs(o.Button,{onClick:()=>E(!j),sx:{width:"100%",px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:y.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",justifyContent:"space-between",transition:"background-color 0.2s","&:hover":{backgroundColor:y.palette.action.hover}},children:[t.jsxs(o.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:["Recently Deleted (",ge.length,")"]}),t.jsx(O.ChevronRight,{sx:{fontSize:16}})]}),j&&t.jsx(o.Box,{sx:{backgroundColor:y.palette.action.hover},children:ge.map(D=>ne(D))})]})]}),t.jsx(o.Box,{sx:{borderTop:`1px solid ${y.palette.divider}`}}),t.jsxs(o.Button,{onClick:()=>{s(),x(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:y.palette.text.primary,justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:y.palette.action.hover}},children:[t.jsx(O.Add,{sx:{fontSize:16}}),t.jsx(o.Typography,{component:"span",sx:{fontSize:"inherit"},children:"Create New Report View"})]}),t.jsxs(o.Popover,{open:!!F,anchorEl:(F==null?void 0:F.el)||null,onClose:()=>X(null),disablePortal:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[g&&t.jsxs(o.MenuItem,{onClick:()=>{F&&g(F.view.id),X(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(O.Edit,{sx:{fontSize:18}}),"Edit"]}),m&&t.jsxs(o.MenuItem,{onClick:()=>{F&&m(F.view.id),X(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(O.Link,{sx:{fontSize:18}}),"Copy Link"]}),f&&t.jsxs(o.MenuItem,{onClick:()=>{F&&f(F.view.id),X(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(O.ContentCopy,{sx:{fontSize:18}}),"Clone"]}),C&&b&&(F==null?void 0:F.view.scope)!=="global"&&t.jsxs(o.MenuItem,{onClick:()=>{F&&C(F.view.id),X(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(O.Language,{sx:{fontSize:18}}),"Promote to Global"]}),v&&[t.jsx(o.Divider,{},"delete-divider"),t.jsxs(o.MenuItem,{onClick:()=>{F&&v(F.view.id),X(null)},sx:{gap:1.5,fontSize:"body2.fontSize",color:"error.main"},children:[t.jsx(O.Delete,{sx:{fontSize:18}}),"Delete"]},"delete-item")]]})]}),document.body),t.jsxs(o.Dialog,{open:q!==null,onClose:ce,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:_o(y)}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",gap:1,pb:1},children:[t.jsx(O.Warning,{sx:{fontSize:20,color:"warning.main"}}),"Unsaved changes"]}),t.jsx(o.DialogContent,{children:t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"You have unsaved changes to the current view. Switching views will discard them."})}),t.jsxs(o.DialogActions,{sx:{px:3,pb:2,gap:1},children:[t.jsx(o.Button,{onClick:ce,variant:"text",children:"Stay here"}),t.jsx(o.Button,{onClick:K,variant:"contained",color:"warning",children:"Discard & switch"})]})]})]})}function iu({columnName:e,columnType:r="string",currentSort:n,hasFilters:i,isInSortStack:s,isReadOnly:a=!1,hasModifications:c=!1,position:l,onSortAscending:u,onSortDescending:g,onRemoveSort:f,onFilter:m,onClearFilter:v,onGroupByColumn:C,onHideColumn:B,onManageColumns:b,onResetLayout:y,onClose:z}){const x=ht(),j=x.palette,E=p.useRef(null);p.useEffect(()=>{if(!E.current)return;const X=E.current,W=X.getBoundingClientRect(),h=window.innerWidth,I=window.innerHeight;W.right>h-8&&(X.style.left=`${h-W.width-8}px`),W.bottom>I-8&&(X.style.top=`${I-W.height-8}px`)},[l]),p.useEffect(()=>{const X=h=>{E.current&&!E.current.contains(h.target)&&z()},W=h=>{h.key==="Escape"&&z()};return document.addEventListener("mousedown",X),document.addEventListener("keydown",W),()=>{document.removeEventListener("mousedown",X),document.removeEventListener("keydown",W)}},[z]);const S=p.useCallback(X=>()=>{X(),z()},[z]),R=(n==null?void 0:n.direction)==="asc",q=(n==null?void 0:n.direction)==="desc",T=r==="number"?"0→9":r==="boolean"?"F→T":"A→Z",F=r==="number"?"9→0":r==="boolean"?"T→F":"Z→A";return bs.createPortal(t.jsxs(o.Paper,{ref:E,elevation:0,sx:{position:"fixed",left:`${l.x}px`,top:`${l.y}px`,zIndex:x.zIndex.tooltip,minWidth:210,maxWidth:264,border:"1px solid",borderColor:"divider",borderRadius:_o(x),overflow:"hidden",boxShadow:`0 4px 20px ${$(j.common.black,.12)}, 0 1px 4px ${$(j.common.black,.06)}`},children:[!a&&t.jsxs(o.Box,{sx:{px:2,py:.75,display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid",borderColor:"divider"},children:[t.jsx(o.Typography,{sx:{fontSize:X=>X.typography.body2.fontSize||"0.8125rem",fontWeight:X=>X.typography.body2.fontWeight||500,color:"text.primary"},children:"Sorting"}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.25},children:[t.jsx(o.Tooltip,{title:`Sort Ascending (${T})`,placement:"top",arrow:!0,children:t.jsx(o.IconButton,{size:"small",onClick:S(()=>u(e)),sx:{p:.625,borderRadius:"6px",color:R?"primary.main":"text.secondary",bgcolor:R?$(j.primary.main,.1):"transparent","&:hover":{bgcolor:$(j.primary.main,.08),color:"primary.main"}},children:t.jsx(O.ArrowUpward,{sx:{fontSize:16}})})}),t.jsx(o.Tooltip,{title:`Sort Descending (${F})`,placement:"top",arrow:!0,children:t.jsx(o.IconButton,{size:"small",onClick:S(()=>g(e)),sx:{p:.625,borderRadius:"6px",color:q?"primary.main":"text.secondary",bgcolor:q?$(j.primary.main,.1):"transparent","&:hover":{bgcolor:$(j.primary.main,.08),color:"primary.main"}},children:t.jsx(O.ArrowDownward,{sx:{fontSize:16}})})}),t.jsx(o.Tooltip,{title:"Clear Sort",placement:"top",arrow:!0,children:t.jsx("span",{children:t.jsx(o.IconButton,{size:"small",disabled:!s,onClick:S(()=>f(e)),sx:{p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:$(j.error.main,.08),color:"error.main"},"&.Mui-disabled":{opacity:.3}},children:t.jsx(O.Close,{sx:{fontSize:16}})})})})]})]}),t.jsxs(o.MenuList,{dense:!0,sx:{py:.5},children:[t.jsxs(o.MenuItem,{onClick:S(()=>m(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx(O.FilterList,{sx:{fontSize:16,color:i?"primary.main":"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Filter by Column",primaryTypographyProps:{fontSize:"0.8125rem",fontWeight:i?600:400,color:i?"primary.main":"text.primary"}})]}),i&&!a&&t.jsxs(o.MenuItem,{onClick:S(()=>v(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:$(j.warning.main,.06),"& .MuiListItemText-primary":{color:"warning.main"},"& .MuiListItemIcon-root svg":{color:"warning.main"}}},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx(O.FilterListOff,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Clear Filter",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]}),!a&&C&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.25}}),t.jsx(o.MenuList,{dense:!0,sx:{py:.5},children:t.jsxs(o.MenuItem,{onClick:S(()=>C(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx(O.GroupWorkOutlined,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Group By Column",primaryTypographyProps:{fontSize:"0.8125rem"}})]})})]}),t.jsx(o.Divider,{sx:{my:.25}}),t.jsxs(o.MenuList,{dense:!0,sx:{py:.5},children:[!a&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",mx:.5,borderRadius:"6px",overflow:"hidden","&:hover":{bgcolor:"action.hover"}},children:[t.jsxs(o.MenuItem,{onClick:S(()=>B(e)),sx:{flex:1,py:.75,px:1.5,minHeight:34,borderRadius:"6px 0 0 6px","&:hover":{bgcolor:"transparent"}},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx(O.VisibilityOff,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Hide Column",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),t.jsx(o.Tooltip,{title:"Manage Columns",placement:"top",arrow:!0,children:t.jsx(o.IconButton,{size:"small",onClick:S(b),sx:{mr:.75,p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:$(j.primary.main,.08),color:"primary.main"}},children:t.jsx(O.Settings,{sx:{fontSize:16}})})})]}),a&&t.jsxs(o.MenuItem,{onClick:S(b),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx(O.Settings,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Manage Columns",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),!a&&c&&y&&t.jsxs(o.MenuItem,{onClick:S(y),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:$(j.error.main,.05),"& .MuiListItemText-primary":{color:"error.main"},"& .MuiListItemIcon-root svg":{color:"error.main"}}},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx(O.RestartAlt,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Reset to Default Layout",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]})]}),document.body)}const su=176,ds="COLUMN_HEADER",au=p.memo(function({column:r,index:n,sortRule:i,hasFilters:s,isInSortStack:a,isReadOnly:c=!1,isGrouped:l=!1,hasModifications:u=!1,width:g,onColumnClick:f,onMoveColumn:m,onColumnDragEnd:v,onResizeStart:C,onSortAscending:B,onSortDescending:b,onRemoveSort:y,onOpenFilterForColumn:z,onClearFiltersForColumn:x,onGroupByColumn:j,onHideColumn:E,onManageColumns:S,onResetLayout:R}){const T=ht().urmTable,F=p.useRef(null),[X,W]=p.useState(!1),[h,I]=p.useState({x:0,y:0}),[{handlerId:N,isOver:d},oe]=ir.useDrop({accept:ds,collect(Q){return{handlerId:Q.getHandlerId(),isOver:Q.isOver()}},hover(Q,pe){var Pe;if(!F.current)return;const D=Q.index,ee=n;if(D===ee)return;const xe=(Pe=F.current)==null?void 0:Pe.getBoundingClientRect(),ae=(xe.right-xe.left)/2,Te=pe.getClientOffset(),Y=((Te==null?void 0:Te.x)??0)-xe.left;D<ee&&Y<ae||D>ee&&Y>ae||(m(D,ee),Q.index=ee)}}),[{isDragging:G},te]=ir.useDrag({type:ds,item:()=>({index:n,columnName:r.name}),collect:Q=>({isDragging:Q.isDragging()}),end:()=>{v==null||v()}});te(oe(F));const ge=p.useCallback(Q=>{Q.preventDefault(),Q.stopPropagation(),I({x:Q.clientX,y:Q.clientY}),W(!0)},[]),V=p.useCallback(()=>W(!1),[]),K=p.useCallback(()=>{l||f(r.name)},[f,r.name,l]),ce=p.useCallback(Q=>{Q.stopPropagation(),z(r.name)},[z,r.name]),de=p.useCallback(()=>i?t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[i.direction==="asc"?t.jsx(O.ArrowUpward,{sx:{fontSize:13,color:"primary.main"}}):t.jsx(O.ArrowDownward,{sx:{fontSize:13,color:"primary.main"}}),t.jsx(o.Box,{sx:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:16,height:16,bgcolor:"primary.main",color:"primary.contrastText",fontSize:"0.6rem",fontWeight:700,borderRadius:"50%",lineHeight:1},children:i.priority})]}):null,[i]),ne=p.useCallback(()=>s?t.jsx(O.FilterList,{onClick:ce,titleAccess:"Active filter on this column — click to edit",sx:{ml:.5,fontSize:13,color:"primary.main",cursor:"pointer",flexShrink:0,"&:hover":{transform:"scale(1.15)"},transition:"transform 0.12s ease"}}):null,[s,ce]);return t.jsxs(t.Fragment,{children:[t.jsxs(o.TableCell,{ref:F,"data-handler-id":N,"data-column-index":n,onClick:K,onContextMenu:ge,sx:{position:"sticky",top:0,zIndex:5,textAlign:(T==null?void 0:T.cellAlignH)??"left",verticalAlign:(T==null?void 0:T.cellAlignV)??"middle",fontSize:"0.8125rem",fontWeight:700,textTransform:"none",letterSpacing:0,whiteSpace:"nowrap",overflow:"visible",cursor:"pointer",userSelect:"none",color:(T==null?void 0:T.headerColor)??"text.secondary",opacity:G?.25:1,transition:"background-color 0.12s ease, opacity 0.15s ease, width 0.3s ease, min-width 0.3s ease, max-width 0.3s ease",bgcolor:d?Q=>$(Q.palette.primary.main,.08):(T==null?void 0:T.headerBg)??"action.hover",boxShadow:Q=>`0 1px 0 ${$(Q.palette.common.black,.08)}`,backgroundImage:"none",borderBottom:(T==null?void 0:T.rowDivider)??"1px solid",borderRight:T==null?void 0:T.colDivider,borderColor:"divider",py:0,px:l?0:(T==null?void 0:T.cellPaddingX)??2,"&:hover":{bgcolor:Q=>$(Q.palette.primary.main,.1),color:"text.primary"},width:l?"32px":g?`${g}px`:`${su}px`,minWidth:l?"32px":void 0,maxWidth:l?"32px":void 0},children:[!l&&t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",overflow:"hidden",maxWidth:"100%",pr:"12px"},children:[dt(r.name),de(),ne()]}),!l&&t.jsx(o.Box,{draggable:!1,onDragStart:Q=>Q.preventDefault(),sx:{position:"absolute",right:0,top:0,height:"100%",width:8,cursor:"col-resize",zIndex:20,display:"flex",alignItems:"center",justifyContent:"center","&:hover > div":{opacity:1}},onMouseDown:Q=>{Q.preventDefault(),Q.stopPropagation(),C(Q,r.name)},onClick:Q=>Q.stopPropagation(),children:t.jsx(o.Box,{draggable:!1,sx:{width:2,height:"50%",borderRadius:1,opacity:0,bgcolor:"primary.main",transition:"opacity 0.15s ease",pointerEvents:"none"}})}),d&&t.jsx(o.Box,{sx:{position:"absolute",left:0,top:0,bottom:0,width:4,bgcolor:"primary.main"}})]}),X&&t.jsx(iu,{columnName:r.name,columnType:r.type,currentSort:i,hasFilters:s,isInSortStack:a,isReadOnly:c,hasModifications:u,position:h,onSortAscending:B,onSortDescending:b,onRemoveSort:y,onFilter:z,onClearFilter:x,onGroupByColumn:j,onHideColumn:E,onManageColumns:S,onResetLayout:R,onClose:V})]})}),lu={active:"success",completed:"success",approved:"success",success:"success",done:"success",contract:"info","in progress":"info","in review":"info",review:"info",pending:"info","on leave":"error","on hold":"warning",probation:"warning",cancelled:"error",rejected:"error",blocked:"error",inactive:"neutral","not started":"neutral",paused:"neutral"};function sn(e,r){const n=lu[r.toLowerCase().trim()];if(!n||n==="neutral")return{bg:e.palette.action.selected,color:e.palette.text.secondary};const i=e.palette[n];return{bg:$(i.main,e.palette.mode==="dark"?.24:.12),color:e.palette.mode==="dark"?i.light:i.dark}}function cu(e,r){switch(r.toLowerCase().trim()){case"low":return e.palette.text.secondary;case"medium":return e.palette.warning.main;case"high":return e.palette.mode==="dark"?e.palette.warning.light:e.palette.warning.dark;case"critical":case"urgent":return e.palette.error.main;default:return}}const du={filters:{hue:"primary",shade:"main"},sorting:{hue:"secondary",shade:"main"},grouping:{hue:"success",shade:"main"},columns:{hue:"warning",shade:"main"},views:{hue:"error",shade:"main"},theme:{hue:"info",shade:"main"},export:{hue:"primary",shade:"dark"},presets:{hue:"secondary",shade:"dark"},system:{hue:"error",shade:"dark"},rows:{hue:"success",shade:"dark"}};function uu(e,r){const n=du[r];return n?e.palette[n.hue][n.shade]:e.palette.text.secondary}function Bt(e){return $(e.palette.primary.main,e.palette.mode==="dark"?.24:.12)}function pu(e){const r=e.toLowerCase().trim();return t.jsx(o.Box,{component:"span",sx:{display:"inline-flex",alignItems:"center",px:1,py:.25,borderRadius:"10px",fontSize:"0.75rem",fontWeight:n=>{var i;return(i=n.tokens)!=null&&i.statusBold?700:500},bgcolor:n=>sn(n,r).bg,color:n=>sn(n,r).color,whiteSpace:"nowrap",lineHeight:1.5},children:e})}function hu(e,r){if(r==null||r==="")return t.jsx(o.Box,{component:"span",sx:{color:"text.disabled",fontSize:"0.875rem"},children:"—"});const n=String(r),i=e.name.toLowerCase();if(/\b(status|state|stage)\b/.test(i))return pu(n);if(/\b(priority|severity|urgency)\b/.test(i)){const s=n.toLowerCase().trim();return t.jsx(o.Box,{component:"span",sx:a=>{const c=cu(a,s);return c?{color:c,fontWeight:600,fontSize:"0.875rem"}:{fontSize:"0.875rem"}},children:n})}return typeof r=="boolean"?t.jsx(o.Box,{component:"span",sx:{fontSize:"0.875rem"},children:r?"Yes":"No"}):typeof r=="object"?t.jsx(o.Box,{component:"span",sx:{fontSize:"0.875rem"},children:JSON.stringify(r)}):t.jsx(o.Box,{component:"span",sx:{fontSize:"0.875rem"},children:n})}function mu(e){const r=e.find(s=>{const a=s.name.toLowerCase();return/\b(name|title|label|subject|task_?name|taskname)\b/.test(a)})||e[0]||null,n=e.find(s=>{const a=s.name.toLowerCase().replace(/[\s_-]/g,"");return/(^id$|id$|_id$|taskid|code$|ref$)/.test(a)&&s!==r})||null,i=e.filter(s=>s!==r&&s!==n).slice(0,4);return{primaryCol:r,idCol:n,bodyColumns:i}}function xu({row:e,rowIndex:r,visibleColumns:n,isSelected:i,onCardClick:s,onCardDoubleClick:a,onCardContextMenu:c,onOpenRowMenu:l,onToggleSelection:u,hideCheckbox:g}){const[f,m]=p.useState(!1),{primaryCol:v,idCol:C,bodyColumns:B}=p.useMemo(()=>mu(n),[n]),b=v?e[v.name]:null,y=C?e[C.name]:null,z=f||i;return t.jsxs(o.Box,{onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),onClick:x=>s(r,x),onDoubleClick:x=>a(e,r,x),onContextMenu:x=>{x.preventDefault(),x.stopPropagation(),c(e,r,x)},sx:{position:"relative",display:"flex",flexDirection:"column",bgcolor:"background.paper",border:x=>{var E,S,R,q;const j=(q=(R=(S=(E=x.components)==null?void 0:E.MuiCard)==null?void 0:S.styleOverrides)==null?void 0:R.root)==null?void 0:q.border;return i?"2px solid":j&&j!=="none"?j:"1px solid"},borderColor:i?x=>ct(x).main:x=>{var E,S,R,q;const j=(q=(R=(S=(E=x.components)==null?void 0:E.MuiCard)==null?void 0:S.styleOverrides)==null?void 0:R.root)==null?void 0:q.border;return j&&j!=="none"?"inherit":$(x.palette.divider,.8)},borderWidth:i?2:void 0,borderRadius:x=>{var E,S,R,q;const j=(q=(R=(S=(E=x.components)==null?void 0:E.MuiCard)==null?void 0:S.styleOverrides)==null?void 0:R.root)==null?void 0:q.borderRadius;return j!==void 0?typeof j=="number"?`${j}px`:j:`${x.shape.borderRadius}px`},cursor:"pointer",transition:"box-shadow 0.2s ease, border-color 0.2s ease, transform 0.15s ease",overflow:"hidden",minHeight:180,boxShadow:i?x=>`0 0 0 3px ${$(ct(x).main,.15)}, 0 2px 8px ${$(x.palette.common.black,.08)}`:f?x=>{var E,S,R,q;const j=(q=(R=(S=(E=x.components)==null?void 0:E.MuiCard)==null?void 0:S.styleOverrides)==null?void 0:R.root)==null?void 0:q.boxShadow;return j&&j!=="none"?j:ye(x,"cardHover")}:x=>{var E,S,R,q;const j=(q=(R=(S=(E=x.components)==null?void 0:E.MuiCard)==null?void 0:S.styleOverrides)==null?void 0:R.root)==null?void 0:q.boxShadow;return j&&j!=="none"?j:ye(x,"cardRest")},transform:f&&!i?"translateY(-2px)":"none","&:active":{transform:"translateY(0)"},...i&&{bgcolor:x=>$(ct(x).main,.03)}},children:[t.jsxs(o.Box,{sx:x=>{var q,T,F,X;const j=((F=(T=(q=x.components)==null?void 0:q.MuiCardHeader)==null?void 0:T.styleOverrides)==null?void 0:F.root)||{},E=(j.backgroundColor&&j.backgroundColor!=="transparent"?j.backgroundColor:void 0)??((X=x.tokens)==null?void 0:X.cardHdrHex)??"transparent",S=j.borderBottom&&j.borderBottom!=="none"?j.borderBottom:void 0,R=j.boxShadow&&j.boxShadow!=="none"?j.boxShadow:void 0;return{px:2,pt:1.75,pb:1.5,bgcolor:E,borderBottom:S,boxShadow:R,display:"flex",alignItems:"center",gap:.5}},children:[!g&&z&&t.jsx(o.Checkbox,{size:"small",checked:i,onClick:x=>x.stopPropagation(),onChange:()=>u(e),sx:{p:.25}}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:x=>x.typography.body2.fontWeight||600,fontSize:x=>x.typography.body1.fontSize||"0.9375rem",color:"text.primary",lineHeight:1.35,wordBreak:"break-word",letterSpacing:"-0.01em"},children:b!=null&&b!==""?String(b):t.jsx(o.Box,{component:"span",sx:{color:"text.disabled",fontStyle:"italic",fontWeight:400},children:"Untitled"})})]}),t.jsx(o.Box,{sx:x=>{var S,R,q;const j=((q=(R=(S=x.components)==null?void 0:S.MuiCardHeader)==null?void 0:R.styleOverrides)==null?void 0:q.root)||{};return j.borderBottom&&j.borderBottom!=="none"?{display:"none"}:{mx:2,height:"1px",bgcolor:"divider",flexShrink:0}}}),t.jsxs(o.Box,{sx:{px:2,py:1.5,flex:1,display:"grid",gridTemplateColumns:"repeat(2, 1fr)",columnGap:1.5,rowGap:1,alignContent:"start"},children:[B.map(x=>t.jsxs(o.Box,{sx:{minWidth:0},children:[t.jsx(o.Typography,{sx:{color:"text.secondary",fontWeight:j=>j.typography.body2.fontWeight||500,fontSize:j=>j.typography.caption.fontSize||"0.6875rem",textTransform:"uppercase",letterSpacing:"0.06em",lineHeight:1.2,mb:.25},children:dt(x.name)}),t.jsx(o.Box,{sx:{lineHeight:1.3,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},title:String(e[x.name]??""),children:hu(x,e[x.name])})]},x.name)),B.length===0&&t.jsx(o.Typography,{variant:"caption",color:"text.disabled",sx:{fontStyle:"italic",gridColumn:"1 / -1"},children:"No additional fields visible"})]}),t.jsxs(o.Box,{sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid",borderColor:"divider",bgcolor:x=>$(x.palette.action.hover,.1),minHeight:40},children:[t.jsx(o.Typography,{sx:{color:"primary.main",fontFamily:'"Roboto Mono", "Courier New", monospace',fontSize:"0.75rem",fontWeight:400,letterSpacing:"0.04em",opacity:y?.85:0,userSelect:"none"},children:y?String(y):" "}),t.jsx(o.Box,{sx:{display:"flex",alignItems:"center",gap:.25,opacity:z?1:0,transition:"opacity 0.15s ease"},onClick:x=>x.stopPropagation(),children:t.jsx(o.Tooltip,{title:"More actions",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:x=>{x.stopPropagation(),l(e,r,x.currentTarget)},sx:{width:28,height:28,color:"action.active","&:hover":{bgcolor:x=>$(x.palette.text.primary,.08)}},children:t.jsx(O.MoreVert,{sx:{fontSize:17}})})})})]})]})}function fu({row:e,grouping:r,onToggleCollapse:n}){var i;return t.jsxs(o.Box,{onClick:()=>n(e.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:s=>ye(s,"flatHover"),"&:hover":{bgcolor:s=>$(s.palette.primary.main,.04),borderColor:"primary.light"},transition:"all 0.15s ease"},children:[e.isCollapsed?t.jsx(O.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}):t.jsx(O.KeyboardArrowDown,{sx:{fontSize:16,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"h5",sx:{fontWeight:s=>s.typography.h5.fontWeight||600,color:s=>s.typography.h5.color||"text.primary"},children:La(e.groupLevel,((i=r==null?void 0:r.levels[e.groupLevel])==null?void 0:i.column)||"",e.groupValue)}),t.jsxs(o.Box,{sx:{px:1,py:.125,fontSize:"0.6875rem",fontWeight:600,bgcolor:s=>$(s.palette.primary.main,.1),color:"primary.main",borderRadius:"10px"},children:[e.rowCount," ",e.rowCount===1?"row":"rows"]}),Object.keys(e.aggregates).length>0&&t.jsx(o.Typography,{variant:"caption",sx:{ml:.5,color:"text.secondary"},children:Object.entries(e.aggregates).map(([s,a])=>ks(a)).filter(Boolean).join(" • ")})]})}function gu({data:e,visibleColumns:r,grouping:n,selectedRowIds:i,isGrouped:s,onToggleGroupCollapse:a,onCardClick:c,onCardDoubleClick:l,onCardContextMenu:u,onOpenRowMenu:g,onToggleSelection:f,hideSelectionCheckboxes:m}){const v=p.useMemo(()=>{const C=new Set;return i.forEach(B=>{const b=B==null?void 0:B.__urm_row_id__;b!==void 0&&C.add(b)}),C},[i]);return e.length===0?t.jsx(o.Box,{sx:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",py:10},children:t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})}):t.jsx(o.Box,{sx:{fontFamily:C=>C.typography.fontFamily},children:t.jsx(o.Box,{sx:{p:C=>ls(C).containerPad,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:C=>ls(C).cardGap,alignContent:"start"},children:e.map((C,B)=>s&&C.isGroupHeader?t.jsx(fu,{row:C,grouping:n,onToggleCollapse:a||(()=>{})},`group-${C.groupKey}`):t.jsx(xu,{row:C,rowIndex:B,visibleColumns:r,isSelected:v.has(C==null?void 0:C.__urm_row_id__),onCardClick:c,onCardDoubleClick:l,onCardContextMenu:u,onOpenRowMenu:g,onToggleSelection:f,hideCheckbox:m},`card-${B}`))})})}const us=[10,15,25,50,100];function yu(e,r){const n=e.trim();if(n==="")return"Page number is required";if(!/^-?\d+$/.test(n))return"Must be a number";const i=parseInt(n,10);return i<1?"Page number must be at least 1":i>r?"Entered page number is out of range":null}function bu({currentPage:e,pageSize:r,totalRows:n,totalFields:i,onPageChange:s,onPageSizeChange:a}){const l=ht().palette,u=Math.ceil(n/r),[g,f]=p.useState(String(e)),[m,v]=p.useState(null),[C,B]=p.useState(!1),b=p.useRef(null);p.useEffect(()=>{C||(f(String(e)),v(null))},[e,C]);const y=p.useCallback(()=>{const I=yu(g,u);if(I){v(I);return}const N=parseInt(g.trim(),10);v(null),B(!1),N!==e&&s(N)},[g,u,e,s]),z=p.useCallback(I=>{var N;I.key==="Enter"?(I.preventDefault(),y()):I.key==="Escape"&&(f(String(e)),v(null),B(!1),(N=b.current)==null||N.blur())},[y,e]),x=p.useCallback(()=>{f(String(e)),v(null),B(!1)},[e]),j=p.useCallback(()=>{B(!0),v(null),setTimeout(()=>{var I;return(I=b.current)==null?void 0:I.select()},0)},[]);if(n<=Math.min(...us))return null;const E=()=>{f(String(e)),v(null),B(!1)},S=()=>{E(),s(1)},R=()=>{E(),e>1&&s(e-1)},q=()=>{E(),e<u&&s(e+1)},T=()=>{E(),s(u)},F=(e-1)*r+1,X=Math.min(e*r,n),W=`${Math.max(2,String(u).length+.5)}ch`,h={p:.75,color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"action.disabled"}};return t.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:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:2},children:[t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:I=>I.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400},children:["Total data:"," ",t.jsx(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:n})]}),i!==void 0&&t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:I=>I.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400},children:["Total fields:"," ",t.jsx(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:i})]})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:3},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:I=>I.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400},children:"Rows per page:"}),t.jsx(o.Select,{value:r,onChange:I=>a(Number(I.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:us.map(I=>t.jsx(o.MenuItem,{value:I,sx:{fontSize:"0.8125rem"},children:I},I))})]}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:I=>I.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400,userSelect:"none"},children:[F,"–",X," of ",n]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,position:"relative"},children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:I=>I.typography.body2.fontSize||"0.8125rem",color:"text.secondary",userSelect:"none"},children:"Page"}),t.jsxs(o.Box,{sx:{position:"relative"},children:[m&&t.jsx(o.Box,{sx:{position:"absolute",bottom:"calc(100% + 6px)",left:"50%",transform:"translateX(-50%)",bgcolor:"background.paper",border:"1px solid",borderColor:$(l.error.main,.4),borderRadius:"6px",px:1,py:.5,boxShadow:`0 2px 8px ${$(l.common.black,.12)}`,zIndex:20,whiteSpace:"nowrap","&::after":{content:'""',position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)",border:"5px solid transparent",borderTopColor:$(l.error.main,.4)}},children:t.jsx(o.Typography,{sx:{fontSize:I=>I.typography.caption.fontSize||"0.6875rem",fontWeight:I=>I.typography.caption.fontWeight||500,color:"error.main",lineHeight:1.3},children:m})}),t.jsx(o.InputBase,{inputRef:b,value:g,onChange:I=>{f(I.target.value),m&&v(null)},onKeyDown:z,onFocus:j,onBlur:x,inputProps:{"aria-label":`Page number, 1 to ${u}`,style:{textAlign:"center",padding:"2px 0",width:W,fontSize:"0.8125rem",fontWeight:600}},sx:{fontSize:"0.8125rem",fontWeight:600,color:m?"error.main":"text.primary",border:"1px solid",borderColor:m?"error.main":C?"primary.main":"divider",borderRadius:"4px",bgcolor:m?$(l.error.main,.04):C?$(l.primary.main,.04):"background.paper",px:.75,transition:"border-color 0.15s ease, background-color 0.15s ease","&:hover":{borderColor:m?"error.main":"text.secondary"},"&:focus-within":{boxShadow:m?`0 0 0 2px ${$(l.error.main,.2)}`:`0 0 0 2px ${$(l.primary.main,.2)}`}}})]}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:I=>I.typography.body2.fontSize||"0.8125rem",color:"text.secondary",userSelect:"none"},children:["of ",u]})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.IconButton,{onClick:S,disabled:e===1,size:"small",title:"First page",sx:h,children:t.jsx(O.FirstPage,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:R,disabled:e===1,size:"small",title:"Previous page",sx:h,children:t.jsx(O.ChevronLeft,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:q,disabled:e===u,size:"small",title:"Next page",sx:h,children:t.jsx(O.ChevronRight,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:T,disabled:e===u,size:"small",title:"Last page",sx:h,children:t.jsx(O.LastPage,{sx:{fontSize:20}})})]})]})]})}function vu(){return t.jsx(o.Chip,{icon:t.jsx(O.Visibility,{sx:{fontSize:14}}),label:"View Only",size:"small",variant:"outlined",sx:{bgcolor:"action.hover",borderColor:"divider",fontSize:e=>e.typography.caption.fontSize||"caption.fontSize",fontWeight:e=>e.typography.caption.fontWeight||500}})}const Js="urm_hint_seen_";function Su(e){try{return localStorage.getItem(Js+e)==="true"}catch{return!1}}function Cu(e){try{localStorage.setItem(Js+e,"true")}catch{}}const Ks={"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:"8px"},"& .MuiInputLabel-root":{fontSize:"0.875rem"},"& .MuiFormHelperText-root":{fontSize:"0.75rem",mx:.5},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}}};function ii(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 Xs({row:e,schema:r}){const i=ht().palette,s=r.filter(l=>l.name in e),a=s.filter(l=>l.type!=="object"&&l.type!=="array"),c=s.filter(l=>l.type==="object"||l.type==="array");return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[a.map(l=>t.jsx(o.TextField,{label:dt(l.name),value:ii(e[l.name],l.type)||"No value",size:"small",fullWidth:!0,InputProps:{readOnly:!0},sx:Ks},l.name)),c.map(l=>{const u=ii(e[l.name],l.type);return t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontWeight:g=>g.typography.caption.fontWeight||500,fontSize:g=>g.typography.caption.fontSize||"0.75rem",color:"text.secondary",display:"block",mb:.75},children:dt(l.name)}),t.jsx(o.Box,{component:"pre",sx:{m:0,px:1.5,py:1.25,borderRadius:"8px",border:"1px solid",borderColor:"divider",bgcolor:$(i.text.primary,.02),fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:u?"text.primary":"text.disabled",fontStyle:u?"normal":"italic",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6,maxHeight:160,overflowY:"auto"},children:u||"No value"})]},l.name)}),s.length===0&&t.jsx(o.Typography,{variant:"body2",sx:{color:"text.disabled",textAlign:"center",py:3,fontSize:l=>l.typography.body2.fontSize||"0.875rem"},children:"No fields to display"})]})}function wu({open:e,onClose:r,row:n,schema:i,reportName:s}){const a=ht(),c=a.palette;if(!n)return null;const l=i.filter(g=>g.name in n).length,u=ue(a);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:ot(a),maxHeight:"min(720px, calc(100vh - 80px))",display:"flex",flexDirection:"column",overflow:"hidden",...u.paper}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2.5,pb:2,display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0,...u.header},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,minWidth:0},children:[t.jsx(o.Box,{sx:{width:36,height:36,borderRadius:"10px",bgcolor:$(c.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(O.VisibilityOutlined,{sx:{fontSize:18,color:"primary.main"}})}),t.jsxs(o.Box,{sx:{minWidth:0},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:g=>g.typography.h6.fontSize||"1rem",fontWeight:g=>g.typography.h6.fontWeight||600,color:g=>g.typography.h6.color||"text.primary",lineHeight:1.3},children:"View Record"}),s&&t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:g=>g.typography.caption.fontSize||"0.75rem",color:"text.secondary",display:"block",mt:.25,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[s," · ",l," ",l===1?"field":"fields"]})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{mt:.25,color:"text.secondary",borderRadius:"8px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Close,{sx:{fontSize:18}})})]}),t.jsx(o.Divider,{}),t.jsx(o.DialogContent,{sx:{overflowY:"auto",flex:1,bgcolor:$(c.text.primary,.015)},children:t.jsx(Xs,{row:n,schema:i})}),t.jsx(o.Divider,{}),t.jsx(o.DialogActions,{sx:{px:3,py:1.75,bgcolor:"background.paper",justifyContent:"flex-end"},children:t.jsx(o.Button,{onClick:r,variant:"contained",sx:{fontSize:"0.8125rem",px:3,py:.75,borderRadius:g=>`${g.shape.borderRadius}px`,minWidth:80},children:"Close"})})]})}function ju({open:e,onClose:r,onConfirm:n,row:i,schema:s}){const a=ht(),c=ue(a);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:ot(a),maxHeight:"min(720px, calc(100vh - 80px))",my:"auto",display:"flex",flexDirection:"column",...c.paper}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2.5,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between",...c.header},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:l=>$(l.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(O.WarningAmberRounded,{sx:{fontSize:22,color:"error.main"}})}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:l=>l.typography.h6.fontSize||"1.125rem",fontWeight:l=>l.typography.h6.fontWeight||500,color:l=>l.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5,mb:.5},children:"Delete record?"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:l=>l.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"This record will be permanently removed."})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.DialogContent,{sx:{px:3,pb:2,overflowY:"auto",flex:1,display:"flex",flexDirection:"column",gap:2},children:[i&&s&&t.jsx(Xs,{row:i,schema:s}),t.jsx(o.Box,{sx:{p:2,borderRadius:"8px",bgcolor:l=>$(l.palette.error.main,.1),border:l=>`1px solid ${$(l.palette.error.main,.5)}`},children:t.jsx(o.Typography,{variant:"body2",sx:{fontSize:l=>l.typography.body2.fontSize||"0.8125rem",color:"error.main",fontWeight:l=>l.typography.body2.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 divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:[t.jsx(o.Button,{onClick:r,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:l=>`${l.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:()=>{n(),r()},variant:"contained",startIcon:t.jsx(O.DeleteForever,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"error.main",color:"error.contrastText",px:3,py:.875,minHeight:36,borderRadius:l=>`${l.shape.borderRadius}px`,boxShadow:l=>ye(l,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"error.dark",boxShadow:l=>ye(l,"hoverButton")},"&:active":{boxShadow:l=>ye(l,"pressedButton"),transform:"translateY(1px)"}},children:"Delete record"})]})]})}function ku({open:e,onClose:r,onSave:n,row:i,schema:s,reportName:a}){var z;const c=ht(),l=c.palette,[u,g]=p.useState({});if(p.useEffect(()=>{e&&i&&g({...i})},[e,i]),!i)return null;const f=s.filter(x=>x.name in i),m=f.filter(x=>x.type!=="object"&&x.type!=="array"),v=f.filter(x=>x.type==="object"||x.type==="array"),C=(x,j)=>{g(E=>({...E,[x]:j}))},B=()=>{const x={...u};f.forEach(j=>{const E=u[j.name];if(j.type==="number"){const S=Number(E);x[j.name]=isNaN(S)?i[j.name]:S}else j.type==="boolean"&&(x[j.name]=!!E)}),n(x),r()},b=f.length,y=ue(c);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:ot(c),maxHeight:"min(760px, calc(100vh - 80px))",display:"flex",flexDirection:"column",overflow:"hidden",...y.paper}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2.5,pb:2,display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0,...y.header},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,minWidth:0},children:[t.jsx(o.Box,{sx:{width:36,height:36,borderRadius:"10px",bgcolor:$(((z=l.warning)==null?void 0:z.main)??"#ed6c02",.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(O.EditOutlined,{sx:{fontSize:18,color:"warning.main"}})}),t.jsxs(o.Box,{sx:{minWidth:0},children:[t.jsx(o.Typography,{sx:{fontSize:x=>x.typography.h6.fontSize||"1rem",fontWeight:x=>x.typography.h6.fontWeight||600,color:"text.primary",lineHeight:1.3},children:"Edit Record"}),a&&t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:x=>x.typography.caption.fontSize||"0.75rem",color:"text.secondary",display:"block",mt:.25,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[a," · ",b," ",b===1?"field":"fields"]})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{mt:.25,color:"text.secondary",borderRadius:"8px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Close,{sx:{fontSize:18}})})]}),t.jsx(o.Divider,{}),t.jsxs(o.DialogContent,{sx:{p:2.5,overflowY:"auto",flex:1,bgcolor:$(l.text.primary,.015),display:"flex",flexDirection:"column",gap:2},children:[m.map(x=>{const j=u[x.name];return x.type==="boolean"?t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontWeight:E=>E.typography.caption.fontWeight||500,fontSize:E=>E.typography.caption.fontSize||"0.75rem",color:"text.secondary",display:"block",mb:.75},children:dt(x.name)}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Switch,{checked:!!j,onChange:E=>C(x.name,E.target.checked),size:"small"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:E=>E.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:j?"Enabled":"Disabled"})]})]},x.name):t.jsx(o.TextField,{label:dt(x.name),value:j??"",onChange:E=>C(x.name,E.target.value),type:x.type==="number"?"number":"text",size:"small",fullWidth:!0,sx:Ks},x.name)}),v.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:v.map(x=>{const j=ii(i[x.name],x.type);return t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:.75},children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:E=>E.typography.caption.fontSize||"0.75rem",fontWeight:E=>E.typography.caption.fontWeight||500,color:"text.secondary"},children:dt(x.name)}),t.jsx(o.Chip,{label:"read only",size:"small",sx:{height:16,fontSize:"0.5625rem",fontWeight:600,letterSpacing:"0.04em",bgcolor:$(l.text.secondary,.07),color:"text.secondary",border:"none"}}),t.jsx(o.Tooltip,{title:"Object and array fields cannot be edited directly",arrow:!0,children:t.jsx(O.InfoOutlined,{sx:{fontSize:13,color:"text.disabled",cursor:"help"}})})]}),t.jsx(o.Box,{component:"pre",sx:{m:0,px:1.5,py:1.25,borderRadius:"8px",border:"1px solid",borderColor:"divider",bgcolor:$(l.text.primary,.02),fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:j?"text.primary":"text.disabled",fontStyle:j?"normal":"italic",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6,maxHeight:160,overflowY:"auto"},children:j||"No value"})]},x.name)})}),f.length===0&&t.jsxs(o.Box,{sx:{py:6,display:"flex",flexDirection:"column",alignItems:"center",gap:1,color:"text.disabled"},children:[t.jsx(O.EditOutlined,{sx:{fontSize:40,opacity:.4}}),t.jsx(o.Typography,{variant:"body2",children:"No editable fields"})]})]}),t.jsx(o.Divider,{}),t.jsxs(o.DialogActions,{sx:{px:3,py:1.75,bgcolor:"background.paper",gap:1,justifyContent:"flex-end"},children:[t.jsx(o.Button,{onClick:r,variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",px:2,borderRadius:x=>`${x.shape.borderRadius}px`,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:B,variant:"contained",startIcon:t.jsx(O.SaveOutlined,{sx:{fontSize:15}}),sx:{fontSize:"0.8125rem",px:2.5,borderRadius:x=>`${x.shape.borderRadius}px`,minWidth:90},children:"Save"})]})]})}const zu=176,Tu=170,Bu=40,Iu=32;function Qs(e){return e.type==="date"?180:zu}function Eu(e,r){return r!=null&&r!==Tu&&r!==Qs(e)}function Du(e,r,n,i){return p.useMemo(()=>{const s=e.map(v=>i!=null&&i.has(v.name)?{name:v.name,width:Iu,explicit:!0}:{name:v.name,width:r[v.name]??Qs(v),explicit:Eu(v,r[v.name])}),a={};s.forEach(v=>{a[v.name]=v.width});const c=s.reduce((v,C)=>v+C.width,0),u=Math.max(0,n-Bu)-c;if(u<=0)return{widths:a,fillerWidth:0};const g=s.filter(v=>!v.explicit);if(g.length===0)return{widths:a,fillerWidth:u};const f=g.reduce((v,C)=>v+C.width,0)||1;let m=0;return g.forEach((v,C)=>{const b=C===g.length-1?v.width+u-m:Math.round(v.width+u*v.width/f);a[v.name]=b,m+=b-v.width}),{widths:a,fillerWidth:0}},[e,r,n,i])}const ps=176,_u=Rt(),$u={low:"text.secondary",medium:"warning.dark",high:"warning.main",critical:"error.main",urgent:"error.main"};function Ou(e){const r=e.toLowerCase().trim();return t.jsx(o.Box,{component:"span",sx:{display:"inline-flex",alignItems:"center",px:1.25,py:.375,borderRadius:"12px",fontSize:"0.75rem",fontWeight:n=>{var i;return(i=n.tokens)!=null&&i.statusBold?700:500},bgcolor:n=>sn(n,r).bg,color:n=>sn(n,r).color,whiteSpace:"nowrap",lineHeight:1.6,letterSpacing:"0.01em"},children:e})}function Mu(e){const r=e.toLowerCase().trim(),n=$u[r];return n?t.jsx(o.Box,{component:"span",sx:{color:n,fontWeight:500,fontSize:"inherit"},children:e}):e}function Wu(e,r){const n=r.trim();if(!n)return e;const i=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=e.split(new RegExp(`(${i})`,"gi"));return s.length===1?e:s.map((a,c)=>a.toLowerCase()===n.toLowerCase()?t.jsx(o.Box,{component:"mark",sx:{bgcolor:"warning.light",color:"inherit",px:"1px",borderRadius:"2px"},children:a},c):a)}function Au(e,r,n,i=""){if(r==null||r==="")return t.jsx(o.Box,{component:"span",sx:{color:"text.disabled"},children:"—"});const s=String(r);if(/\b(status|state|stage|employmenttype|contracttype|availability)\b/.test(e.name.toLowerCase()))return Ou(s);if(/\b(priority|severity|urgency|importance|criticality)\b/.test(e.name.toLowerCase()))return Mu(s);if(e.type==="date"){const l=e.dateFormat??"iso",u=Ea(r,l,n??null);return t.jsx(o.Box,{component:"span",sx:{color:"text.primary",whiteSpace:"nowrap"},children:u})}if(e.type==="number"&&typeof r=="number")return r.toLocaleString();if(typeof r=="boolean")return r?"Yes":"No";if(Array.isArray(r)){if(r.length===0)return t.jsx(o.Box,{component:"span",sx:{color:"text.disabled"},children:"[ ]"});const l=r.slice(0,3).map(u=>typeof u=="object"?JSON.stringify(u):String(u)).join(", ");return t.jsxs(o.Box,{component:"span",sx:{color:"text.secondary",fontSize:"0.8125rem"},children:[l,r.length>3?` +${r.length-3} more`:""]})}if(typeof r=="object"){const l=JSON.stringify(r);return t.jsx(o.Box,{component:"span",title:l,sx:{color:"text.secondary",fontSize:"0.8125rem",fontFamily:"monospace",cursor:"help"},children:l.length>40?l.slice(0,40)+"…":l})}return Wu(s,i)}function Ru({schema:e,data:r,sortStack:n=[],filters:i=_u,views:s=[],activeViewId:a="",isDirty:c=!1,isExporting:l=!1,columnVisibility:u={},columnOrder:g=[],columnWidths:f={},grouping:m=null,classTokens:v={},onSort:C,onSortAscending:B,onSortDescending:b,onOpenFilters:y,onOpenSort:z,onOpenFilterForColumn:x,onSelectView:j,onCreateView:E,onUpdateCurrentView:S,onSaveAsNewView:R,onDiscardChanges:q,onToggleDefault:T,onToggleFavorite:F,onRestoreView:X,onPermanentDelete:W,onEditView:h,onCloneView:I,onCopyLink:N,onDeleteView:d,onPromoteToGlobal:oe,isAdmin:G=!1,onExport:te,onOpenColumns:ge,onUpdateColumnWidth:V,onUpdateColumnOrder:K,onUpdateColumnVisibility:ce,onClearFiltersForColumn:de,onResetLayout:ne,onOpenGroup:Q,onGroupByColumn:pe,onToggleGroupCollapse:D,onExpandAllGroups:ee,onCollapseAllGroups:xe,onOpenAuditHistory:ae,onOpenScheduledReports:Te,searchQuery:Y,highlightQuery:Pe="",searchHistory:Et=[],onAddToSearchHistory:mt,onToggleSearchFavourite:$r,onDeleteSearchHistory:Pt,selectedRowIds:it=new Set,onSearchChange:Yt,onToggleRowSelection:Ke,onToggleAllRows:Dt,onRangeSelection:Sr,onClearSelection:vt,onExportSelected:qt,currentPage:ao=1,pageSize:ar=15,totalRowsBeforePagination:lo=r.length,onPageChange:_t,onPageSizeChange:Cr,isReadOnly:Xe=!1,userRole:Nt,reportName:Jt,onEditRow:Ze,onDuplicateRow:et,onDeleteRow:Lt,showDevPanel:co=!1,onOpenDevConfig:Or,rowActions:wr,hideDefaultRowActions:He,hideToolbarActions:Se,customSettingsActions:lr,jsonGuideContent:Kt,viewOptions:cr,defaultViewMode:uo,bulkActions:Ft,hideSelectionCheckboxes:Mr,rowClickBehavior:dr="select",openModalOn:tt,onRowClick:Xt,onRowRightClick:xt}){var Lo;const he=ht().urmTable,[jr,$t]=p.useState(null),[H,St]=p.useState(0),[ie,ut]=p.useState(0),[Ot,Qt]=p.useState(null),Wr=br(),kr=((Lo=Wr.dates)==null?void 0:Lo.displayFormat)??null,[Zt,ur]=p.useState(null),[pr,Ar]=p.useState(null),[ze,Qe]=p.useState(null),[Z,se]=p.useState(!1),[be,Rr]=p.useState(!1),[hr,Pr]=p.useState(null),[po,Nr]=p.useState(!1),[mr,Lr]=p.useState(null),[Fr,Mt]=p.useState(null),[Ce,Ge]=p.useState(null),[zr,st]=p.useState(null),er=p.useRef(null),Wt=p.useCallback(()=>{er.current&&(clearTimeout(er.current),er.current=null)},[]),fe=p.useCallback(()=>{Wt(),er.current=setTimeout(()=>st(null),200)},[Wt]);p.useEffect(()=>Wt,[Wt]);const[je,We]=p.useState(null),qe=p.useMemo(()=>cr??["list","grid"],[cr]),[at,Ct]=p.useState(()=>uo??qe[0]??"list"),[tr,$o]=p.useState(!1),[Vr,zn]=p.useState(()=>!Su("toolbar_search")),Hr=p.useRef(null),ho=p.useRef(null),[Tn,Oo]=p.useState(0);p.useLayoutEffect(()=>{const w=Hr.current;if(!w)return;Oo(w.clientWidth);const P=new ResizeObserver(re=>{Oo(re[0].contentRect.width)});return P.observe(w),()=>P.disconnect()},[]);const Gr=p.useCallback(()=>{Cu("toolbar_search"),zn(!1)},[]);p.useEffect(()=>{if(!Vr)return;const w=setTimeout(Gr,2e3);return()=>clearTimeout(w)},[Vr,Gr]);const Mo=p.useMemo(()=>{const w=Ot??g;return w.length>0?w.map(P=>e.find(re=>re.name===P)).filter(P=>P!==void 0):e},[Ot,g,e]),Ur=p.useMemo(()=>Mo.filter(w=>u[w.name]!==!1),[Mo,u]),mo=p.useMemo(()=>new Set(((m==null?void 0:m.levels)??[]).map(w=>w.column)),[m]),Wo=!!(m!=null&&m.enabled&&(m!=null&&m.levels)&&m.levels.length>0),Yr=p.useMemo(()=>{if(!Wo)return Ur;const w=((m==null?void 0:m.levels)??[]).map(re=>e.find(we=>we.name===re.column)).filter(re=>re!==void 0),P=Ur.filter(re=>!mo.has(re.name));return[...w,...P]},[Ur,Wo,mo,m,e]),qr=p.useMemo(()=>{const w=new Set;if(!(m!=null&&m.enabled)||!r)return w;for(const P of r)(P.isGroupHeader||P.__isGroupHeader)&&!P.isCollapsed&&P.groupColumn&&w.add(P.groupColumn);return w},[r,m]),{widths:Tr}=Du(Yr,f,Tn,qr),xr=p.useMemo(()=>e.filter(w=>u[w.name]===!1).length,[e,u]),Ao=p.useMemo(()=>e.map(w=>w.name),[e]),Jr=p.useMemo(()=>g.length===0?!1:JSON.stringify(g)!==JSON.stringify(Ao),[g,Ao]),Bn=p.useCallback((w,P)=>{w.preventDefault(),w.stopPropagation(),$t(P),St(w.clientX),ut(f[P]||150)},[f]);p.useEffect(()=>{if(!jr)return;const w=re=>{const we=re.clientX-H,Me=Math.max(100,Math.min(600,ie+we));V==null||V(jr,Me)},P=()=>{$t(null)};return document.addEventListener("mousemove",w),document.addEventListener("mouseup",P),()=>{document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",P)}},[jr,H,ie,V]);const In=p.useCallback(w=>w==null?"-":typeof w=="object"?JSON.stringify(w):typeof w=="boolean"?w?"true":"false":String(w),[]);p.useCallback(w=>{const P=n.find(re=>re.column===w);return P?t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[P.direction==="asc"?t.jsx(O.ArrowUpward,{sx:{fontSize:14}}):t.jsx(O.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:P.priority})]}):null},[n]),p.useCallback(w=>Zn(i,w)?t.jsx(o.IconButton,{size:"small",onClick:re=>{re.stopPropagation(),x==null||x(w)},sx:{ml:.5,p:.25,color:"primary.main","&:hover":{color:"primary.main"}},title:"Active filters on this column",children:t.jsx(O.FilterList,{sx:{fontSize:14}})}):null,[i,x]);const En=p.useCallback(w=>{C&&C(w)},[C]),Dn=p.useCallback((w,P)=>{Qt(re=>{const Me=[...re??(g.length>0?g:e.map(rt=>rt.name))],[nt]=Me.splice(w,1);return Me.splice(P,0,nt),Me})},[g,e]),_n=p.useCallback(()=>{Ot&&K&&K(Ot),Qt(null)},[Ot,K]),$n=p.useCallback(w=>{if(!C)return;const P=n.find(re=>re.column===w);(!P||P.direction!=="asc")&&C(w)},[C,n]),On=p.useCallback(w=>{if(!C)return;const P=n.find(re=>re.column===w);P?P.direction==="asc"&&C(w):(C(w),setTimeout(()=>C(w),0))},[C,n]),Mn=p.useCallback(w=>{if(!C)return;const P=n.find(re=>re.column===w);P&&(P.direction==="asc"?(C(w),setTimeout(()=>C(w),0)):P.direction==="desc"&&C(w))},[C,n]),Wn=p.useCallback(w=>{ce&&ce(w,!1)},[ce]),Kr=!!(m!=null&&m.enabled&&(m!=null&&m.levels)&&m.levels.length>0),rr=p.useMemo(()=>Tt(i),[i]),An=n.length>0||rr>0||((m==null?void 0:m.enabled)??!1)||Object.values(u).some(w=>w===!1),Rn=(ao-1)*ar,Re=r,lt=p.useMemo(()=>{const w=new Set;return it.forEach(P=>{const re=P==null?void 0:P.__urm_row_id__;re!==void 0&&w.add(re)}),w},[it]);p.useEffect(()=>{const w=P=>{!Dt||!vt||P.target instanceof HTMLInputElement||P.target instanceof HTMLTextAreaElement||((P.ctrlKey||P.metaKey)&&P.key==="a"&&(P.preventDefault(),Dt(!0,Re)),P.key==="Escape"&&(P.preventDefault(),vt()))};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[Dt,vt,Re]);const xo=p.useCallback((w,P)=>{Xt==null||Xt(Re[w],w,P),(dr==="activate"||dr==="both")&&(Qe(Re[w]),se(!0)),dr!=="activate"&&Ke&&(P.shiftKey&&Zt!==null?(P.preventDefault(),Sr&&Sr(Zt,w,Re)):(Ke(Re[w]),ur(w)))},[Ke,Zt,Sr,Re,Xt,dr,Qe,se]),Ro=p.useMemo(()=>Re.length>0&&lt.size>0&&Re.every(w=>lt.has(w==null?void 0:w.__urm_row_id__)),[Re,lt]),Pn=!Ro&&Re.some(w=>lt.has(w==null?void 0:w.__urm_row_id__)),ft=!!(Ke&&Dt&&!Mr),Xr=p.useMemo(()=>!(m!=null&&m.enabled)||!(m!=null&&m.levels)?new Set:new Set(m.levels.map(w=>w.column)),[m]),wt=p.useMemo(()=>Yr,[Yr]),Po=p.useMemo(()=>{const w=new Map;if(!(m!=null&&m.enabled)||!Re)return w;let P=[];for(const re of Re)if(re.__isGroupHeader||re.isGroupHeader){const we=re.groupLevel??0;P[we]=re.groupKey,P=P.slice(0,we+1),w.has(re.groupKey)||w.set(re.groupKey,[])}else if(re.__urm_is_grouped_data_row__)for(const we of P)we&&w.has(we)&&w.get(we).push(re);return w},[m,Re]),Nn=p.useCallback(w=>{const P=w.groupLevel,re=P===0?v.groupRowLevel0||"urm-group-level-0":P===1?v.groupRowLevel1||"urm-group-level-1":v.groupRowLevel2||"urm-group-level-2",we=P===0?ke=>ke.palette.mode==="dark"?$(ke.palette.action.hover,.12):"#f1f5f9":ke=>ke.palette.mode==="dark"?$(ke.palette.action.hover,.06):"#f8fafc",Me=String(w.groupValue??"(empty)"),nt=`${w.rowCount} ${w.rowCount===1?"item":"items"}`,rt=Po.get(w.groupKey)||[],me=rt.filter(ke=>lt.has(ke==null?void 0:ke.__urm_row_id__)).length,Vt=rt.length>0&&me===rt.length,or=me>0&&me<rt.length;return t.jsxs(o.TableRow,{onClick:()=>D==null?void 0:D(w.groupKey),className:`urm-group-header-row urm-group-level-${P} ${re} ${v.groupRow||""}`,sx:{bgcolor:we,"&:hover":{bgcolor:ke=>$(ke.palette.text.primary,.07)},cursor:"pointer",borderTop:"1px solid",borderBottom:"1px solid",borderColor:"divider",position:"relative"},children:[ft&&t.jsx(o.TableCell,{padding:"checkbox",onClick:ke=>ke.stopPropagation(),sx:{borderBottom:"1px solid",borderColor:"divider",verticalAlign:"middle",bgcolor:"inherit"},children:t.jsx(o.Checkbox,{size:"small",checked:Vt,indeterminate:or,onChange:()=>{if(!Ke)return;const ke=!Vt;rt.forEach(pt=>{const Fo=lt.has(pt==null?void 0:pt.__urm_row_id__);ke!==Fo&&Ke(pt)})}})}),t.jsxs(o.TableCell,{colSpan:wt.length,className:`urm-group-cell ${v.groupCellFirst||""} ${v.groupCell||""}`,sx:{pl:`${P*24+16}px`,position:"relative",py:1.25,borderBottom:"1px solid",borderColor:"divider"},children:[P>0&&t.jsx(o.Box,{sx:{position:"absolute",left:`${P*24+4}px`,top:0,bottom:0,width:"1px",bgcolor:"divider"}}),t.jsxs(o.Box,{className:`urm-group-content ${v.groupContent||""}`,sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Box,{className:`urm-group-caret ${v.groupCaret||""}`,sx:{color:"text.secondary",display:"inline-flex",alignItems:"center"},children:w.isCollapsed?t.jsx(O.ChevronRight,{sx:{fontSize:18}}):t.jsx(O.KeyboardArrowDown,{sx:{fontSize:18}})}),t.jsx(o.Typography,{variant:"h5",className:`urm-group-title ${v.groupTitle||""}`,sx:{fontWeight:P===0?600:500,fontSize:P===0?"0.9375rem":"0.875rem",color:"text.primary",whiteSpace:"nowrap"},children:Me}),!w.isCollapsed&&t.jsx(o.Box,{className:"urm-group-column-heading-badge",sx:{px:1,py:.25,fontSize:"0.7rem",fontWeight:500,lineHeight:1,whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",bgcolor:ke=>$(ke.palette.primary.main,.1),color:"primary.main",borderRadius:"10px",border:"1px solid",borderColor:ke=>$(ke.palette.primary.main,.2),ml:.5},children:dt(w.groupColumn||"")}),!!w.__urm_is_continuation_header__&&t.jsx(o.Box,{className:"urm-group-continuation-badge",sx:{px:1,py:.25,fontSize:"0.7rem",fontWeight:500,lineHeight:1,whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",bgcolor:ke=>$(ke.palette.text.secondary,.05),color:"text.secondary",borderRadius:"10px",border:"1px dashed",borderColor:"divider",ml:.5},children:"Continued"}),t.jsx(o.Box,{className:`urm-group-count ${v.groupBadge||""} ${v.groupCount||""}`,sx:{px:1.25,py:.25,fontSize:"0.75rem",fontWeight:500,lineHeight:1,whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",bgcolor:ke=>$(ke.palette.text.secondary,.08),color:"text.secondary",borderRadius:"12px",ml:.5},children:nt}),Object.keys(w.aggregates||{}).length>0&&t.jsxs(o.Typography,{variant:"caption",className:`urm-group-aggregates ${v.groupAggregates||""}`,sx:{ml:1.5,color:"text.secondary",fontWeight:500},children:["(",Object.entries(w.aggregates).map(([ke,pt])=>ks(pt)).filter(Boolean).join(" • "),")"]})]})]})]},w.groupKey)},[Xr,wt,ft,m,e,D,v,he,Po,lt,Ke]),No=p.useCallback((w,P)=>{const re=lt.has(w==null?void 0:w.__urm_row_id__),we=pr===P,Me=Z&&(w==null?void 0:w.__urm_row_id__)===(ze==null?void 0:ze.__urm_row_id__),nt=!!(w!=null&&w.__urm_is_grouped_data_row__),rt=nt?w.__urm_group_level__??(m==null?void 0:m.levels.length)??1:0;return t.jsxs(o.TableRow,{"data-row-index":P,className:nt?`urm-data-row-grouped ${v.dataRowGrouped||""}`:"",onMouseEnter:()=>Ar(P),onMouseLeave:()=>Ar(null),onClick:me=>{me.target.closest("[data-row-action-btn]")||xo(P,me)},onDoubleClick:()=>{tt!=null&&tt.includes("doubleClick")&&(Qe(w),se(!0))},onContextMenu:me=>{me.preventDefault(),me.stopPropagation(),xt==null||xt(w,P,me),st(null),Ge({mouseX:me.clientX,mouseY:me.clientY,row:w,rowIndex:P}),tt!=null&&tt.includes("rightClick")&&(Qe(w),se(!0))},sx:{cursor:"pointer",bgcolor:re?me=>ct(me).bg:Me?me=>$(me.palette.info.main,.12):he!=null&&he.striped&&P%2===1?he.stripeBg:"background.paper",transition:"background-color 0.12s ease","&:hover":{bgcolor:re?me=>ct(me).hoverBg:Me?me=>$(me.palette.info.main,.2):me=>`var(--highlight-hover-row, ${$(ct(me).main,.04)})`},borderBottom:(he==null?void 0:he.rowDivider)??"1px solid",borderColor:"divider"},children:[ft&&t.jsx(o.TableCell,{padding:"checkbox",onClick:me=>me.stopPropagation(),sx:{borderBottom:(he==null?void 0:he.rowDivider)??"1px solid",borderColor:"divider",verticalAlign:(he==null?void 0:he.cellAlignV)??"middle"},children:t.jsx(o.Checkbox,{size:"small",checked:re,onChange:()=>Ke==null?void 0:Ke(w)})}),wt.map((me,Vt)=>{const or=Vt===0,ke=Xr.has(me.name),pt=qr.has(me.name);return t.jsxs(o.TableCell,{className:nt&&or?`urm-data-cell-grouped ${v.dataCellGrouped||""}`:"",sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",py:(he==null?void 0:he.rowPaddingY)??"6px",px:ke&&pt?0:(he==null?void 0:he.cellPaddingX)??2,position:"relative",textAlign:(he==null?void 0:he.cellAlignH)??"left",verticalAlign:(he==null?void 0:he.cellAlignV)??"middle",fontSize:"0.8125rem",fontWeight:400,color:"text.primary",borderBottom:(he==null?void 0:he.rowDivider)??"1px solid",borderRight:he==null?void 0:he.colDivider,borderColor:"divider",width:ke&&pt?"32px":void 0,minWidth:ke&&pt?"32px":f[me.name]?`${f[me.name]}px`:`${me.type==="date"?Math.max(ps,180):ps}px`,maxWidth:ke&&pt?"32px":void 0,transition:"all 0.3s ease-in-out"},children:[nt&&or&&rt>0&&t.jsx(o.Box,{sx:{position:"absolute",left:4,top:0,bottom:0,width:"1px",bgcolor:"divider"}}),!ke&&t.jsx(o.Box,{sx:{display:"flex",alignItems:"center"},children:t.jsx("span",{className:`urm-item-title ${v.itemTitle||""}`,children:Au(me,w[me.name],kr,Pe)})})]},me.name)}),t.jsx(o.TableCell,{"data-row-action":"true",sx:{position:"sticky",right:0,width:0,minWidth:0,maxWidth:0,p:0,border:"none",background:"transparent",opacity:we?1:0,transition:"opacity 0.12s ease",zIndex:10},children:t.jsx(o.Box,{sx:{position:"absolute",right:8,top:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"flex-end",zIndex:10},children:t.jsx(o.IconButton,{"data-row-action-btn":"true",size:"small",onClick:me=>{me.stopPropagation(),me.preventDefault(),st(null),Ge({anchorEl:me.currentTarget,row:w,rowIndex:P})},sx:{color:"text.secondary",opacity:we?1:0,transition:"opacity 0.12s ease",pointerEvents:we?"auto":"none","&:hover":{bgcolor:me=>$(me.palette.text.primary,.08),color:"text.primary"}},children:t.jsx(O.MoreVert,{sx:{fontSize:18}})})})})]},P)},[it,Rn,pr,xo,Yr,f,Pe,In,Ze,et,Lt,Ke,ft,Qe,se,ze,Z,Ge,Kr,mo,xt,tt,Xr,qr,lt]);return t.jsxs(ir.DndProvider,{backend:si.HTML5Backend,children:[t.jsxs(o.Box,{sx:w=>{var nt,rt,me;const P=((me=(rt=(nt=w.components)==null?void 0:nt.MuiCard)==null?void 0:rt.styleOverrides)==null?void 0:me.root)||{},re=P.border&&P.border!=="none"?P.border:"1px solid",we=P.borderRadius!==void 0?typeof P.borderRadius=="number"?`${P.borderRadius}px`:P.borderRadius:`${w.shape.borderRadius}px`,Me=P.boxShadow&&P.boxShadow!=="none"?P.boxShadow:ye(w,"cardRest");return{display:"flex",flexDirection:"column",height:"100%",bgcolor:"background.paper",border:re,borderColor:re!=="none"?"divider":void 0,borderRadius:we,boxShadow:Me,overflow:"hidden"}},children:[t.jsxs(o.Box,{sx:w=>{var nt,rt,me,Vt,or;const P=((me=(rt=(nt=w.components)==null?void 0:nt.MuiCardHeader)==null?void 0:rt.styleOverrides)==null?void 0:me.root)||{},re=(P.backgroundColor&&P.backgroundColor!=="transparent"?P.backgroundColor:void 0)??((Vt=w.tokens)==null?void 0:Vt.cardHdrHex)??((or=w.urmTable)==null?void 0:or.headerBg)??w.palette.background.paper,we=P.borderBottom&&P.borderBottom!=="none"?P.borderBottom:"1px solid",Me=P.boxShadow&&P.boxShadow!=="none"?P.boxShadow:void 0;return{position:"sticky",top:0,zIndex:10,bgcolor:re,borderBottom:we,borderColor:we!=="none"?"divider":void 0,boxShadow:Me,px:2,py:0,minHeight:56,display:"flex",alignItems:"center",gap:1}},children:[Xe&&t.jsx(vu,{}),Yt&&mt&&$r&&Pt&&!(Se!=null&&Se.includes("search"))&&t.jsx(o.Tooltip,{open:Vr,title:t.jsxs(o.Box,{sx:{p:.5},children:[t.jsx(o.Typography,{variant:"caption",sx:{display:"block",fontWeight:w=>w.typography.caption.fontWeight||500,mb:.25},children:"💡 Search tip"}),t.jsx(o.Typography,{variant:"caption",children:"Type to search across all columns instantly"})]}),placement:"bottom-start",arrow:!0,PopperProps:{onClick:Gr},componentsProps:{tooltip:{sx:{bgcolor:"primary.main","& .MuiTooltip-arrow":{color:"primary.main"},maxWidth:220,cursor:"pointer",userSelect:"none"}}},children:t.jsx(o.Box,{component:"span",children:t.jsx(ou,{value:Y||"",onChange:w=>{Vr&&Gr(),Yt(w)},searchHistory:Et,onAddToHistory:mt,onToggleFavourite:$r,onDeleteHistory:Pt,disabled:Xe})})}),!(Se!=null&&Se.includes("jsonGuide"))&&t.jsx(o.Tooltip,{title:"JSON format guide",children:t.jsx(o.IconButton,{size:"small",onClick:()=>$o(!0),sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:w=>$(w.palette.text.primary,.06),color:"text.primary"}},children:t.jsx(O.InfoOutlined,{sx:{fontSize:20}})})}),j&&E&&S&&s.length>0&&t.jsx(nu,{views:s||[],activeViewId:a||"",isDirty:c,onSelectView:j,onCreateView:E,onToggleDefault:T,onToggleFavorite:F,onRestoreView:X,onPermanentDelete:W,onEditView:h,onCloneView:I,onCopyLink:N,onDeleteView:d,onPromoteToGlobal:oe,isAdmin:G,isReadOnly:Xe}),c&&!Xe&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25,ml:1},children:[S&&t.jsx(o.Button,{onClick:S,size:"small",variant:"contained",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",bgcolor:w=>`var(--urm-btn-save-current-bg, ${w.palette.primary.main})`,color:w=>`var(--urm-btn-save-current-color, ${w.palette.primary.contrastText})`,textTransform:"none",boxShadow:w=>ye(w,"restButton"),"&:hover":{bgcolor:w=>`var(--urm-btn-save-current-hover-bg, ${w.palette.primary.dark})`,boxShadow:w=>ye(w,"hoverButton")}},children:"Save current view"}),R&&t.jsx(o.Button,{onClick:R,size:"small",variant:"outlined",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",borderColor:w=>`var(--urm-btn-save-new-border, ${w.palette.primary.main})`,color:w=>`var(--urm-btn-save-new-color, ${w.palette.primary.main})`,bgcolor:w=>`var(--urm-btn-save-new-bg, ${w.palette.background.paper})`,borderWidth:"1.5px",textTransform:"none","&:hover":{borderWidth:"1.5px",borderColor:w=>`var(--urm-btn-save-new-hover-border, ${w.palette.primary.dark})`,bgcolor:w=>`var(--urm-btn-save-new-hover-bg, ${$(w.palette.primary.main,.08)})`}},children:"Save new view"}),q&&t.jsx(o.Button,{onClick:q,size:"small",variant:"contained",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",bgcolor:w=>`var(--urm-btn-discard-bg, ${$(w.palette.text.primary,.12)})`,color:w=>`var(--urm-btn-discard-color, ${w.palette.text.primary})`,textTransform:"none",boxShadow:"none","&:hover":{bgcolor:w=>`var(--urm-btn-discard-hover-bg, ${$(w.palette.text.primary,.18)})`,boxShadow:"none"}},children:"Discard"})]}),co&&Or&&t.jsx(o.Tooltip,{title:"Developer configuration",children:t.jsx(o.IconButton,{size:"small",onClick:Or,sx:{color:"text.secondary",borderRadius:1,border:"1px dashed",borderColor:w=>$(w.palette.text.secondary,.3),"&:hover":{bgcolor:w=>$(w.palette.warning.main,.08),borderColor:"warning.main",color:"warning.dark"}},children:t.jsx(O.DisplaySettings,{sx:{fontSize:20}})})}),t.jsx(o.Box,{sx:{flexGrow:1}}),!Xe&&z&&!(Se!=null&&Se.includes("sort"))&&t.jsx(o.Tooltip,{title:"Sort",children:t.jsxs(o.IconButton,{onClick:z,size:"small",sx:{position:"relative",color:n.length>0?"primary.main":"text.secondary",bgcolor:n.length>0?w=>Bt(w):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:n.length>0?w=>$(w.palette.primary.main,.2):w=>$(w.palette.text.primary,.06),color:n.length>0?"primary.main":"text.primary"}},children:[t.jsx(O.SwapVert,{sx:{fontSize:20}}),n.length>0&&t.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:"primary.contrastText",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:n.length})]})}),!Xe&&y&&!(Se!=null&&Se.includes("filter"))&&t.jsx(o.Tooltip,{title:"Filter",children:t.jsxs(o.IconButton,{onClick:y,size:"small",sx:{position:"relative",color:rr>0?"primary.main":"text.secondary",bgcolor:rr>0?w=>Bt(w):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:rr>0?w=>$(w.palette.primary.main,.2):w=>$(w.palette.text.primary,.06),color:rr>0?"primary.main":"text.primary"}},children:[t.jsx(O.FilterList,{sx:{fontSize:20}}),rr>0&&t.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:"primary.contrastText",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:rr})]})}),!Xe&&ge&&!(Se!=null&&Se.includes("columns"))&&t.jsx(o.Tooltip,{title:"Show/Hide Columns",children:t.jsxs(o.IconButton,{onClick:ge,size:"small",sx:{position:"relative",color:xr>0||Jr?"primary.main":"text.secondary",bgcolor:xr>0||Jr?w=>Bt(w):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:xr>0||Jr?w=>$(w.palette.primary.main,.2):w=>$(w.palette.text.primary,.06),color:xr>0||Jr?"primary.main":"text.primary"}},children:[t.jsx(O.ViewColumn,{sx:{fontSize:20}}),xr>0&&t.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:"primary.contrastText",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:xr})]})}),Kr&&(ee||xe)&&(()=>{var re;const w=(((re=m==null?void 0:m.collapsedGroups)==null?void 0:re.length)??0)>0,P=w?ee:xe;return P?t.jsx(o.Tooltip,{title:w?"Expand all groups":"Collapse all groups",children:t.jsx(o.IconButton,{onClick:P,size:"small",sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:we=>$(we.palette.text.primary,.06),color:"text.primary"}},children:w?t.jsx(O.UnfoldMore,{sx:{fontSize:20}}):t.jsx(O.UnfoldLess,{sx:{fontSize:20}})})}):null})(),qe.length>1&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5,my:1.5}}),qe.map(w=>{const P=at===w,re=w==="list"?t.jsx(O.TableRows,{sx:{fontSize:20}}):t.jsx(O.GridView,{sx:{fontSize:20}}),we=w==="list"?"List view":"Grid view";return t.jsx(o.Tooltip,{title:we,children:t.jsx(o.IconButton,{size:"small",onClick:()=>Ct(w),sx:{borderRadius:1,color:P?"primary.main":"text.secondary",bgcolor:P?Me=>Bt(Me):"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:P?Me=>$(Me.palette.primary.main,.2):Me=>$(Me.palette.text.primary,.06),color:P?"primary.main":"text.primary"}},children:re})},w)})]}),!(Se!=null&&Se.includes("settings"))&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5,my:1.5}}),t.jsx(o.Tooltip,{title:"Settings",children:t.jsx(o.IconButton,{onClick:w=>We(w.currentTarget),size:"small",sx:{color:"text.secondary",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:w=>$(w.palette.text.primary,.06),color:"text.primary"}},children:t.jsx(O.Settings,{sx:{fontSize:20}})})})]})]}),t.jsxs(o.Popover,{open:!!je,anchorEl:je,onClose:()=>We(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:[te&&!(Se!=null&&Se.includes("export"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{te(),We(null)},disabled:l,sx:{py:1,px:2,gap:1.5},children:[t.jsx(O.Download,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Export"})]}),!Xe&&Q&&!(Se!=null&&Se.includes("grouping"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Q(),We(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(O.Layers,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Grouping"})]}),ae&&!(Se!=null&&Se.includes("auditHistory"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ae(),We(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(O.History,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Audit History"})]}),Te&&!(Se!=null&&Se.includes("scheduledReports"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Te(),We(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(O.Schedule,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Scheduled Reports"})]}),lr==null?void 0:lr.map(w=>t.jsxs(o.MenuItem,{dense:!0,disabled:w.disabled,onClick:()=>{w.onClick(),We(null)},sx:{py:1,px:2,gap:1.5},children:[w.icon,t.jsx(o.Typography,{variant:"body2",children:w.label})]},w.key))]}),t.jsxs(o.Box,{sx:{position:"relative",flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[Ft&&Ft.length>0&&lt.size>0&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,px:2,py:1,bgcolor:w=>ct(w).bg,borderBottom:"1px solid",borderColor:"divider"},children:[t.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:w=>w.typography.body2.fontWeight||600,mr:1},children:[lt.size," selected"]}),t.jsx(o.Button,{size:"small",onClick:()=>vt==null?void 0:vt(),children:"Clear"}),Ft.map(w=>{var re,we;const P=Array.from(it);return(re=w.hidden)!=null&&re.call(w,P)?null:t.jsx(o.Button,{size:"small",variant:"outlined",startIcon:w.icon,disabled:(we=w.disabled)==null?void 0:we.call(w,P),onClick:()=>w.onClick(P),children:w.label},w.key)})]}),at!=="list"&&t.jsx(o.Box,{sx:{flex:1,overflowY:"auto",overflowX:"hidden",bgcolor:"action.hover"},children:t.jsx(gu,{data:Re,visibleColumns:Ur,grouping:m,selectedRowIds:it,isGrouped:!!Kr,onToggleGroupCollapse:D,onCardClick:(w,P)=>xo(w,P),onCardDoubleClick:w=>{tt!=null&&tt.includes("doubleClick")&&(Qe(w),se(!0))},onCardContextMenu:(w,P,re)=>{xt==null||xt(w,P,re),st(null),Ge({mouseX:re.clientX,mouseY:re.clientY,row:w,rowIndex:P}),tt!=null&&tt.includes("rightClick")&&(Qe(w),se(!0))},onOpenRowMenu:(w,P,re)=>Ge({anchorEl:re,row:w,rowIndex:P}),onToggleSelection:w=>Ke==null?void 0:Ke(w),hideSelectionCheckboxes:Mr})}),at==="list"&&t.jsxs(o.Box,{sx:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[t.jsx(o.Box,{ref:Hr,onScroll:w=>{ho.current&&(ho.current.scrollLeft=w.target.scrollLeft)},sx:{overflowX:"auto",overflowY:"hidden",flexShrink:0,scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:t.jsxs(o.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",borderSpacing:0,width:"100%",minWidth:`${Object.values(Tr).reduce((w,P)=>w+P,0)}px`},children:[t.jsxs("colgroup",{children:[ft&&t.jsx("col",{style:{width:"40px"}}),wt.map(w=>t.jsx("col",{style:{width:`${Tr[w.name]}px`}},w.name))]}),t.jsx(o.TableHead,{children:t.jsxs(o.TableRow,{sx:{bgcolor:(he==null?void 0:he.headerBg)??"action.hover",borderBottom:(he==null?void 0:he.rowDivider)??"1px solid",borderColor:"divider"},children:[ft&&t.jsx(o.TableCell,{padding:"checkbox",sx:{borderBottom:(he==null?void 0:he.rowDivider)??"1px solid",borderColor:"divider",verticalAlign:(he==null?void 0:he.cellAlignV)??"middle"},children:t.jsx(o.Checkbox,{size:"small",checked:Ro,indeterminate:Pn,onChange:w=>Dt==null?void 0:Dt(w.target.checked,Re)})}),wt.map((w,P)=>{const re=Xr.has(w.name),we=qr.has(w.name);return t.jsx(au,{column:w,index:P,isGrouped:re&&we,sortRule:n.find(Me=>Me.column===w.name),hasFilters:Zn(i,w.name),isInSortStack:n.some(Me=>Me.column===w.name),isReadOnly:Xe,hasModifications:An,width:re&&we?32:f[w.name],onColumnClick:En,onMoveColumn:Dn,onColumnDragEnd:_n,onResizeStart:Bn,onSortAscending:B||$n,onSortDescending:b||On,onRemoveSort:Mn,onOpenFilterForColumn:x||(()=>{}),onClearFiltersForColumn:de||(()=>{}),onGroupByColumn:pe,onHideColumn:Wn,onManageColumns:ge||(()=>{}),onResetLayout:ne},w.name)})]})})]})}),t.jsx(o.Box,{ref:ho,onScroll:w=>{Hr.current&&(Hr.current.scrollLeft=w.target.scrollLeft)},sx:{flex:1,overflowY:"auto",overflowX:"auto",minHeight:0,bgcolor:"background.paper","&::-webkit-scrollbar":{width:8,height:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:w=>$(w.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:w=>$(w.palette.text.primary,.3)}}},children:t.jsxs(o.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",borderSpacing:0,width:"100%",minWidth:`${Object.values(Tr).reduce((w,P)=>w+P,0)}px`},children:[t.jsxs("colgroup",{children:[ft&&t.jsx("col",{style:{width:"40px"}}),wt.map(w=>t.jsx("col",{style:{width:`${Tr[w.name]}px`}},w.name))]}),t.jsx(o.TableBody,{children:Re.length===0?t.jsx(o.TableRow,{children:t.jsx(o.TableCell,{colSpan:wt.length,align:"center",sx:{py:4},children:t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})})}):Kr?Re.map((w,P)=>w.isGroupHeader?Nn(w):No(w,P)):Re.map((w,P)=>No(w,P))})]})})]}),_t&&Cr&&t.jsx(bu,{currentPage:ao,pageSize:ar,totalRows:lo,totalFields:e.length,onPageChange:_t,onPageSizeChange:Cr}),!(_t&&Cr)&&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 ",Re.length," ",Re.length===1?"row":"rows"]})})]})]}),t.jsxs(o.Popover,{open:!!Ce,onClose:()=>{Ge(null),st(null)},anchorEl:(Ce==null?void 0:Ce.anchorEl)||null,anchorReference:Ce!=null&&Ce.anchorEl?"anchorEl":"anchorPosition",anchorPosition:Ce&&!Ce.anchorEl?{top:Ce.mouseY,left:Ce.mouseX}:void 0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:Ce!=null&&Ce.anchorEl?{vertical:"top",horizontal:"right"}:{vertical:"top",horizontal:"left"},PaperProps:{sx:{minWidth:176,py:.5,borderRadius:1.5,boxShadow:3}},children:[!(He!=null&&He.includes("view"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Ce&&(Qe(Ce.row),se(!0)),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(O.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"View"})]}),!(He!=null&&He.includes("edit"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Ce&&(Lr(Ce.row),Mt(Ce.rowIndex),Nr(!0)),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(O.Edit,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Edit"})]}),!(He!=null&&He.includes("duplicate"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Ce&&(et==null||et(Ce.rowIndex,Ce.row)),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(O.ContentCopy,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Duplicate"})]}),Ce&&(wr==null?void 0:wr.map(w=>{var P,re;return(P=w.hidden)!=null&&P.call(w,Ce.row)?null:t.jsxs(o.MenuItem,{dense:!0,disabled:(re=w.disabled)==null?void 0:re.call(w,Ce.row),onClick:()=>{w.onClick(Ce.row,Ce.rowIndex),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[w.icon,t.jsx(o.Typography,{variant:"body2",children:w.label})]},w.key)})),lt.size>0&&qt&&!(He!=null&&He.includes("export"))&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.5}}),t.jsxs(o.MenuItem,{dense:!0,onMouseEnter:w=>{Wt(),st(w.currentTarget)},onMouseLeave:fe,sx:{py:1,px:2,gap:1.5,justifyContent:"space-between"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(O.Download,{sx:{fontSize:18,color:"text.secondary"}}),t.jsxs(o.Typography,{variant:"body2",children:["Export Selected (",lt.size,")"]})]}),t.jsx(O.ChevronRight,{sx:{fontSize:18,color:"text.secondary"}})]}),t.jsx(o.Popper,{open:!!zr,anchorEl:zr,placement:"right-start",transition:!0,sx:{zIndex:w=>w.zIndex.modal+1},modifiers:[{name:"offset",options:{offset:[0,0]}}],children:({TransitionProps:w})=>t.jsx(o.Grow,{...w,timeout:150,children:t.jsx(o.Paper,{onMouseEnter:Wt,onMouseLeave:fe,sx:{minWidth:176,py:.5,borderRadius:1.5,boxShadow:3},children:t.jsxs(o.MenuList,{dense:!0,autoFocusItem:!1,children:[t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{qt("csv"),st(null),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(O.TableChart,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"CSV"})]}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{qt("excel"),st(null),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(O.TableChart,{sx:{fontSize:18,color:"success.main"}}),t.jsx(o.Typography,{variant:"body2",children:"Excel"})]}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{qt("json"),st(null),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(O.DataObject,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"JSON"})]}),Wr.export.allowedFormats.includes("pdf")&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{qt("pdf"),st(null),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(O.PictureAsPdf,{sx:{fontSize:18,color:"error.main"}}),t.jsx(o.Typography,{variant:"body2",children:"PDF"})]})]})})})})]}),!(He!=null&&He.includes("delete"))&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.5}}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Ce&&(Pr(Ce.row),Rr(!0)),Ge(null)},sx:{py:1,px:2,gap:1.5,color:"error.main"},children:[t.jsx(O.Delete,{sx:{fontSize:18,color:"error.main"}}),t.jsx(o.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]})]}),t.jsx(wu,{open:Z,onClose:()=>{se(!1),Qe(null)},row:ze,schema:e,reportName:Jt}),t.jsx(ku,{open:po,onClose:()=>{Nr(!1),Lr(null),Mt(null)},onSave:w=>{Fr!==null&&(Ze==null||Ze(Fr,w))},row:mr,schema:e,reportName:Jt}),t.jsx(ju,{open:be,onClose:()=>{Rr(!1),Pr(null)},onConfirm:()=>{hr!==null&&(Lt==null||Lt(hr))},row:hr,schema:e}),t.jsx(Ys,{isOpen:tr,onClose:()=>$o(!1),content:Kt})]})}function Dr({content:e,isDev:r=!1}){const[n,i]=p.useState(null);return t.jsxs(t.Fragment,{children:[t.jsx(o.IconButton,{size:"small",onClick:s=>i(s.currentTarget),"aria-label":`Help: ${e.title}`,sx:{p:.375,color:"text.disabled","&:hover":{color:"primary.main",bgcolor:s=>$(s.palette.primary.main,.08)}},children:t.jsx(O.InfoOutlined,{sx:{fontSize:15}})}),t.jsxs(o.Popover,{open:!!n,anchorEl:n,onClose:()=>i(null),anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},PaperProps:{sx:{width:280,borderRadius:"10px",boxShadow:4,p:0,overflow:"hidden"}},children:[t.jsx(o.Box,{sx:{px:2,py:1.5,bgcolor:s=>$(s.palette.primary.main,.06)},children:t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:s=>s.typography.body2.fontWeight||600,color:"primary.main",fontSize:s=>s.typography.body2.fontSize||"0.875rem"},children:e.title})}),t.jsx(o.Divider,{}),t.jsxs(o.Box,{sx:{px:2,py:1.5,display:"flex",flexDirection:"column",gap:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{color:"text.secondary",fontSize:s=>s.typography.body2.fontSize||"0.8125rem",lineHeight:1.6},children:e.description}),e.tips&&e.tips.length>0&&t.jsx(o.Box,{component:"ul",sx:{m:0,pl:2,display:"flex",flexDirection:"column",gap:.5},children:e.tips.map((s,a)=>t.jsx(o.Box,{component:"li",sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.5},children:s},a))}),r&&e.devNote&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.5}}),t.jsxs(o.Box,{sx:{px:1.25,py:.75,borderRadius:"6px",bgcolor:s=>$(s.palette.warning.main,.08),border:"1px solid",borderColor:s=>$(s.palette.warning.main,.2)},children:[t.jsx(o.Typography,{variant:"caption",sx:{color:"warning.dark",fontWeight:s=>s.typography.caption.fontWeight||500,fontSize:s=>s.typography.caption.fontSize||"0.75rem",display:"block",mb:.25},children:"Dev note"}),t.jsx(o.Typography,{variant:"caption",sx:{color:"warning.dark",fontSize:s=>s.typography.caption.fontSize||"0.75rem",lineHeight:1.5},children:e.devNote})]})]})]})]})]})}const _r={filter:{title:"Filter columns",description:"Narrow down rows by setting conditions on any column. Only rows matching all active filters are shown.",tips:["Add multiple conditions to combine filters (AND logic)",'Use "Contains" for partial text matches','Use "Is empty" to find missing values',"Clear all filters to return to the full dataset"],devNote:"Max filter conditions controlled by DevConfig → Filter → maxConditions. Allowed operators also configurable."},sort:{title:"Sort columns",description:"Order rows by one or more columns. Drag levels to set sort priority — the first level is applied first.",tips:["Add multiple sort levels for multi-column sorting","Drag the ⋮⋮ handle to reorder sort priority","Each level can be ascending (A→Z, 0→9) or descending"],devNote:"Max sort levels controlled by DevConfig → Sort → maxLevels."},grouping:{title:"Group data",description:"Organize rows into collapsible groups by one or more column values. Each unique value becomes a group header.",tips:["Add up to 3 nesting levels for hierarchical grouping","Click a group header to collapse or expand it","Aggregates (count) are shown on each group header","Combine grouping with filters and sort for focused views"],devNote:"Max group levels controlled by DevConfig → Grouping → maxLevels. allowNested and allowCollapse also configurable."},columns:{title:"Manage columns",description:"Control which columns are visible, their display order, and their widths.",tips:["Drag rows to reorder columns","Toggle the eye icon to show or hide a column","Drag the resize handle in the table header to resize","Reset to restore default visibility and order"],devNote:"Max visible columns and width range controlled by DevConfig → Columns."},export:{title:"Export data",description:"Download the report data as a file. Choose between CSV, Excel, or JSON format.",tips:["CSV: universal format, opens in any spreadsheet app","Excel: formatted .xlsx file with native Excel support","JSON: structured data including metadata","Export visible rows only (after filters) or all rows"],devNote:"Allowed export formats controlled by DevConfig → Export → allowedFormats."},schedule:{title:"Scheduled reports",description:"Set up automatic exports that run at a specified time — daily, weekly, or monthly.",tips:["The browser tab must remain open for the schedule to fire","Each schedule triggers a file download automatically","Add an email address to open a notification in your mail app","Pause a schedule without deleting it"],devNote:"Schedules are stored in localStorage per-report. Key: urm_schedules_{reportId}."},auditHistory:{title:"Audit history",description:"A full log of all changes made to this report — filters applied, sorts changed, views saved, exports triggered, and more.",tips:["Each entry shows the action, timestamp, and who performed it","Use audit history to trace back unexpected changes"],devNote:"Audit entries are stored per-report in IndexedDB via the persistence layer."}},Qn=40;function Pu({operator:e,onSelect:r}){return t.jsxs(o.Select,{value:e,onChange:n=>r(n.target.value),size:"small",variant:"outlined",sx:{position:"relative",zIndex:1,mt:1,width:58,height:24,fontSize:"0.6875rem",fontWeight:700,color:"primary.main",bgcolor:"background.paper",borderRadius:"6px","& .MuiSelect-select":{py:0,px:1,display:"flex",alignItems:"center"},"& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"}},children:[t.jsx(o.MenuItem,{value:"and",sx:{fontSize:"0.75rem",fontWeight:600},children:"AND"}),t.jsx(o.MenuItem,{value:"or",sx:{fontSize:"0.75rem",fontWeight:600},children:"OR"})]})}function Nu({condition:e,schema:r,availableColumns:n,devConfig:i,onUpdate:s}){const a=r.find(u=>u.name===e.column),c=p.useMemo(()=>{const u=a?on(a.type):[],g=i.filter.allowedOperators;return g.length>0?u.filter(f=>g.includes(f.value)):u},[a,i]),l=Bl(e.operator);return t.jsxs(o.Box,{sx:{display:"flex",gap:1,alignItems:"center",flexWrap:"wrap"},children:[t.jsx(o.FormControl,{size:"small",sx:{minWidth:150,flex:"1 1 150px"},children:t.jsx(o.Select,{value:e.column,onChange:u=>{var m;const g=r.find(v=>v.name===u.target.value),f=g?on(g.type):[];s({column:u.target.value,operator:((m=f[0])==null?void 0:m.value)??e.operator,value:void 0})},displayEmpty:!0,sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper"},children:n.map(u=>t.jsx(o.MenuItem,{value:u.name,sx:{fontSize:"0.875rem"},children:dt(u.name)},u.name))})}),t.jsx(o.FormControl,{size:"small",sx:{minWidth:130,flex:"1 1 130px"},children:t.jsx(o.Select,{value:e.operator,onChange:u=>s({operator:u.target.value,value:void 0}),sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper"},children:c.map(u=>t.jsx(o.MenuItem,{value:u.value,sx:{fontSize:"0.875rem"},children:u.label},u.value))})}),l&&(a==null?void 0:a.type)==="date"&&t.jsx(o.TextField,{size:"small",type:"date",value:e.value??"",onChange:u=>s({value:u.target.value}),sx:{minWidth:160,flex:"1 1 160px","& .MuiInputBase-root":{height:36,fontSize:"0.875rem"}}}),l&&(a==null?void 0:a.type)!=="date"&&t.jsx(o.TextField,{size:"small",type:(a==null?void 0:a.type)==="number"?"number":"text",value:e.value??"",onChange:u=>s({value:(a==null?void 0:a.type)==="number"?Number(u.target.value):u.target.value}),placeholder:"Value…",sx:{minWidth:160,flex:"1 1 160px","& .MuiInputBase-root":{height:36,fontSize:"0.875rem"}}})]})}function Zs({group:e,depth:r,schema:n,availableColumns:i,devConfig:s,maxConditions:a,totalConditions:c,onChange:l}){const u=c>=a;return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[e.children.map((g,f)=>t.jsxs(o.Box,{sx:{display:"flex",alignItems:"stretch",gap:1},children:[t.jsxs(o.Box,{sx:{width:Qn,flexShrink:0,position:"relative",display:"flex",justifyContent:"center"},children:[f<e.children.length-1&&t.jsx(o.Box,{sx:{position:"absolute",top:0,bottom:0,left:"50%",width:"1px",bgcolor:"divider"}}),f>0&&t.jsx(Pu,{operator:e.operator,onSelect:m=>l(v=>ci(v,e.id,m))}),f>0&&t.jsx(o.Box,{sx:{position:"absolute",top:13,left:"50%",width:Qn/2,height:"1px",bgcolor:"divider"}})]}),t.jsx(o.Box,{sx:{flex:1,minWidth:0,pt:f>0?1:0},children:Je(g)?t.jsx(Lu,{group:g,depth:r+1,schema:n,availableColumns:i,devConfig:s,maxConditions:a,totalConditions:c,onChange:l}):t.jsx(Nu,{condition:g,schema:n,availableColumns:i,devConfig:s,onUpdate:m=>l(v=>li(v,g.id,m))})}),t.jsx(o.IconButton,{size:"small",onClick:()=>l(m=>di(m,g.id)),sx:{mt:f>0?1:.25,color:"text.secondary",flexShrink:0},children:t.jsx(O.Close,{sx:{fontSize:16}})})]},g.id)),t.jsxs(o.Box,{sx:{display:"flex",gap:2,pl:`${Qn}px`},children:[t.jsx(o.Button,{size:"small",disabled:u||i.length===0,onClick:()=>l(g=>{var f,m,v;return so(g,e.id,{id:io(),column:((f=i[0])==null?void 0:f.name)??"",operator:((v=on(((m=i[0])==null?void 0:m.type)??"string")[0])==null?void 0:v.value)??"equals"})}),sx:{fontSize:"0.8125rem",color:"primary.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",textDecoration:"underline"}},children:"+ Add condition"}),t.jsx(o.Button,{size:"small",disabled:u,onClick:()=>l(g=>so(g,e.id,Rt())),sx:{fontSize:"0.8125rem",color:"text.secondary",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",textDecoration:"underline"}},children:"+ Add group"})]})]})}function Lu(e){return t.jsx(o.Box,{sx:{position:"relative",border:"1px solid",borderColor:r=>$(r.palette.primary.main,.2),borderLeft:"3px solid",borderLeftColor:"primary.main",bgcolor:r=>$(r.palette.primary.main,r.palette.mode==="dark"?.06:.03),borderRadius:"8px",p:1.25},children:t.jsx(Zs,{...e})})}function Fu({schema:e,filters:r,onReplaceFilters:n,onClose:i,focusColumn:s,onOpenDevConfig:a}){const[c,l]=p.useState(r??Rt()),u=br(),g=p.useMemo(()=>e.filter(z=>z.type!=="mixed"&&z.type!=="null"&&z.type!=="array"&&z.type!=="object"),[e]);p.useEffect(()=>{var x;const z=r??Rt();if(s&&z.children.length===0){const j=e.find(E=>E.name===s);if(j){l(so(z,z.id,{id:io(),column:s,operator:((x=on(j.type)[0])==null?void 0:x.value)??"equals"}));return}}l(z)},[r,s,e]);const f=Tt(c),m=u.filter.maxConditions,v=p.useCallback(z=>{l(x=>z(x))},[]),C=p.useMemo(()=>JSON.stringify(c)!==JSON.stringify(r??Rt()),[c,r]),B=p.useCallback(()=>{n(c),i()},[c,n,i]),b=p.useCallback(()=>{l(r??Rt()),i()},[r,i]),y=p.useCallback(()=>{n(Rt()),i()},[n,i]);return t.jsx(o.Box,{onClick:b,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:z=>$(z.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:z=>z.zIndex.modal,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:z=>z.stopPropagation(),elevation:0,sx:{position:"relative",width:640,maxWidth:"calc(100vw - 120px)",maxHeight:"min(620px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:z=>ot(z),bgcolor:"background.paper",outline:"none",boxShadow:z=>ue(z).paper.boxShadow,border:z=>ue(z).paper.border,overflow:"hidden",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,bgcolor:z=>ue(z).header.backgroundColor,borderBottom:z=>ue(z).header.borderBottom,boxShadow:z=>ue(z).header.boxShadow,flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:z=>z.typography.h6.fontSize||"1.125rem",fontWeight:z=>z.typography.h6.fontWeight||500,color:z=>z.typography.h6.color||"text.primary",lineHeight:1.5},children:"Filter columns"}),t.jsx(Dr,{content:_r.filter,isDev:process.env.NODE_ENV==="development"}),a&&t.jsx(o.IconButton,{onClick:a,size:"small",title:"Dev config",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Settings,{sx:{fontSize:18}})})]}),t.jsx(o.IconButton,{onClick:b,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.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:z=>$(z.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:z=>$(z.palette.text.primary,.3)}}},children:[f===0&&t.jsxs(o.Typography,{variant:"body2",sx:{color:"text.disabled",fontSize:z=>z.typography.body2.fontSize||"0.875rem",mb:2},children:["No conditions yet — add one below to start filtering",s?` on "${dt(s)}"`:"","."]}),t.jsx(Zs,{group:c,depth:0,schema:e,availableColumns:g,devConfig:u,maxConditions:m,totalConditions:f,onChange:v}),f>=m&&t.jsxs(o.Typography,{variant:"caption",sx:{display:"block",mt:1.5,color:"warning.dark",fontSize:z=>z.typography.caption.fontSize||"0.75rem",fontWeight:z=>z.typography.caption.fontWeight||500},children:["Filter limit reached — maximum ",m," conditions allowed. Remove one to add another."]})]}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",alignItems:"center",gap:1.5,justifyContent:"space-between",flexShrink:0,bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:y,disabled:f===0,sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"},"&.Mui-disabled":{color:"text.disabled"}},children:"Clear all"}),t.jsxs(o.Box,{sx:{display:"flex",gap:1.5},children:[t.jsx(o.Button,{onClick:b,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:z=>`${z.shape.borderRadius}px`,"&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:B,disabled:!C,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:z=>`${z.shape.borderRadius}px`,boxShadow:z=>ye(z,"restButton"),"&:hover":{bgcolor:"primary.dark"},"&.Mui-disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Apply filter"})]})]})]})})}const hs="SORT_RULE";function Vu({rule:e,index:r,onToggleDirection:n,onRemove:i,onMove:s}){const a=p.useRef(null),[{handlerId:c},l]=ir.useDrop({accept:hs,collect(f){return{handlerId:f.getHandlerId()}},hover(f,m){var x;if(!a.current)return;const v=f.index,C=r;if(v===C)return;const B=(x=a.current)==null?void 0:x.getBoundingClientRect(),b=(B.bottom-B.top)/2,y=m.getClientOffset(),z=((y==null?void 0:y.y)??0)-B.top;v<C&&z<b||v>C&&z>b||(s(v,C),f.index=C)}}),[{isDragging:u},g]=ir.useDrag({type:hs,item:()=>({index:r}),collect:f=>({isDragging:f.isDragging()})});return g(l(a)),t.jsxs(o.Box,{ref:a,"data-handler-id":c,sx:{display:"flex",alignItems:"center",gap:1.25,px:2,py:1.25,borderRadius:"8px",bgcolor:"background.paper",border:"1px solid divider",opacity:u?.4:1,cursor:"move",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:"action.hover",borderColor:"divider",boxShadow:f=>ye(f,"restButtonLight"),transform:"translateY(-1px)"}},children:[t.jsx(o.Chip,{label:e.priority,size:"small",sx:{width:26,height:26,fontSize:"0.75rem",fontWeight:600,bgcolor:"primary.main",color:"background.paper",boxShadow:f=>`0 1px 2px 0 ${$(f.palette.primary.main,.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:"text.secondary"}}),t.jsx(o.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}}),t.jsx(o.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}})]}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:f=>f.typography.body2.fontSize||"0.875rem",fontWeight:f=>f.typography.body2.fontWeight||400,color:"text.primary",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:f=>n(r,f.target.value),sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider",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:[t.jsx(o.MenuItem,{value:"asc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:f=>Bt(f),"&:hover":{bgcolor:f=>$(f.palette.primary.main,.2)}}},children:"Ascending"}),t.jsx(o.MenuItem,{value:"desc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:f=>Bt(f),"&:hover":{bgcolor:f=>$(f.palette.primary.main,.2)}}},children:"Descending"})]})}),t.jsx(o.IconButton,{onClick:()=>i(r),size:"small",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{color:"error.main",bgcolor:f=>$(f.palette.error.main,.08),transform:"scale(1.1)"}},children:t.jsx(O.Close,{sx:{fontSize:18}})})]})}function Hu({schema:e,sortStack:r,onUpdateSortStack:n,onClose:i,onOpenDevConfig:s}){const[a,c]=p.useState(""),[l,u]=p.useState([]);p.useEffect(()=>{u([...r])},[r]);const g=p.useMemo(()=>JSON.stringify(l)!==JSON.stringify(r),[l,r]),f=br(),m=p.useCallback(j=>{if(!j||l.length>=f.sort.maxLevels)return;const E={column:j,direction:"asc",priority:l.length+1};u([...l,E]),c(""),setTimeout(()=>{var S;return(S=document.activeElement)==null?void 0:S.blur()},0)},[l,f.sort.maxLevels]),v=p.useCallback(j=>{const S=l.filter((R,q)=>q!==j).map((R,q)=>({...R,priority:q+1}));u(S)},[l]),C=p.useCallback((j,E)=>{const S=[...l];S[j]={...S[j],direction:E},u(S)},[l]),B=p.useCallback((j,E)=>{const S=[...l],[R]=S.splice(j,1);S.splice(E,0,R);const q=S.map((T,F)=>({...T,priority:F+1}));u(q)},[l]),b=p.useCallback(()=>{n([]),i()},[n,i]),y=p.useCallback(()=>{n(l),i()},[l,n,i]),z=p.useCallback(()=>{u([...r]),c(""),i()},[r,i]),x=e.filter(j=>!l.some(E=>E.column===j.name));return t.jsx(ir.DndProvider,{backend:si.HTML5Backend,children:t.jsx(o.Box,{onClick:z,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:j=>$(j.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:j=>j.zIndex.modal,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:j=>j.stopPropagation(),elevation:0,sx:{position:"relative",width:480,maxWidth:"calc(100vw - 120px)",maxHeight:"min(440px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:j=>ot(j),bgcolor:"background.paper",outline:"none",boxShadow:j=>ue(j).paper.boxShadow,border:j=>ue(j).paper.border,overflow:"hidden",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,bgcolor:j=>ue(j).header.backgroundColor,borderBottom:j=>ue(j).header.borderBottom,boxShadow:j=>ue(j).header.boxShadow,flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:j=>j.typography.h6.fontSize||"1.125rem",fontWeight:j=>j.typography.h6.fontWeight||500,color:j=>j.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Sort columns"}),t.jsx(Dr,{content:_r.sort,isDev:process.env.NODE_ENV==="development"}),s&&t.jsx(o.IconButton,{onClick:s,size:"small",title:"Dev config",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Settings,{sx:{fontSize:18}})})]}),t.jsx(o.IconButton,{onClick:z,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.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:j=>$(j.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:j=>$(j.palette.text.primary,.3)}}},children:[t.jsxs(o.Box,{sx:{mb:2.5},children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:j=>j.typography.caption.fontSize||"0.6875rem",fontWeight:j=>j.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add sort level"}),t.jsxs(o.FormControl,{size:"small",fullWidth:!0,disabled:l.length>=f.sort.maxLevels,children:[t.jsx(o.InputLabel,{sx:{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},children:"Select column..."}),t.jsx(o.Select,{value:a,onChange:j=>m(j.target.value),label:"Select column...",sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-disabled":{bgcolor:"action.hover"}},children:x.map(j=>t.jsx(o.MenuItem,{value:j.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:E=>Bt(E),"&:hover":{bgcolor:E=>$(E.palette.primary.main,.2)}}},children:dt(j.name)},j.name))})]}),l.length>=f.sort.maxLevels&&t.jsxs(o.Typography,{variant:"caption",sx:{mt:.75,display:"block",color:"warning.dark",fontSize:j=>j.typography.caption.fontSize||"0.75rem",fontWeight:j=>j.typography.caption.fontWeight||500},children:["Maximum ",f.sort.maxLevels," sort levels allowed"]})]}),l.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:j=>j.typography.caption.fontSize||"0.6875rem",fontWeight:j=>j.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:["Sorted sequence (",l.length,"/",f.sort.maxLevels,")"]}),t.jsx(o.Button,{onClick:b,sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto",minHeight:"auto",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"}},children:"Clear all"})]}),t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:l.map((j,E)=>t.jsx(Vu,{rule:j,index:E,onToggleDirection:C,onRemove:v,onMove:B},`${j.column}-${E}`))})]})]}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:z,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:j=>`${j.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:y,variant:"contained",disabled:!g||l.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:j=>`${j.shape.borderRadius}px`,boxShadow:j=>ye(j,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:j=>ye(j,"hoverButton")},"&:active":{boxShadow:j=>ye(j,"pressedButton"),transform:"translateY(1px)"}},children:"Apply sort"})]})]})})})}const Jo=50;function ms({currentSnapshot:e,onSave:r,onClose:n,isEditMode:i=!1,initialName:s="",initialDescription:a="",initialIsDefault:c=!1,atViewLimit:l=!1,maxViews:u=10}){const[g,f]=p.useState(s),[m,v]=p.useState(!1),[C,B]=p.useState(a),[b,y]=p.useState(c),z=()=>{if(!g.trim()){v(!0);return}if(g.trim().length>Jo){v(!0);return}r(g.trim(),C.trim(),b),n()},x=E=>{E.key==="Enter"&&!E.shiftKey?z():E.key==="Escape"&&n()},j=()=>i&&s?`Update ${s} view`:"Create New Report View";return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:E=>({mt:8,borderRadius:ot(E),...ue(E).paper})},children:[t.jsxs(o.DialogTitle,{sx:E=>({display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,...ue(E).header}),children:[j(),t.jsx(o.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:t.jsx(O.Close,{sx:{fontSize:20}})})]}),t.jsx(o.DialogContent,{children:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2,pt:1},children:[l&&!i&&t.jsxs(o.Alert,{severity:"warning",sx:{borderRadius:"8px"},children:["You have reached the maximum of ",u," saved views. Delete an existing view before creating a new one."]}),t.jsx(o.TextField,{label:"View Name",required:!0,value:g,onChange:E=>{E.target.value.length<=Jo&&f(E.target.value),m&&E.target.value.trim()&&v(!1)},onKeyDown:x,placeholder:"e.g., Active Users",autoFocus:!0,fullWidth:!0,size:"small",disabled:l&&!i,inputProps:{maxLength:Jo},error:m&&!g.trim(),helperText:m&&!g.trim()?"View name is required":`${g.length} / ${Jo}`}),t.jsx(o.TextField,{label:"Description (optional)",value:C,onChange:E=>B(E.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:E=>E.typography.body2.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:[Tt(e.filters)," filter",Tt(e.filters)!==1?"s":""]}),t.jsxs("li",{children:["Sorting: ",Ha(e.sortStack)]}),t.jsx("li",{children:"Column order & visibility"})]})]}),!i&&t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{checked:b,onChange:E=>y(E.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 divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:[t.jsx(o.Button,{onClick:n,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:E=>`${E.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:z,variant:"contained",disabled:l&&!i,startIcon:t.jsx(O.Save,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:.875,minHeight:36,borderRadius:E=>`${E.shape.borderRadius}px`,boxShadow:E=>ye(E,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:E=>ye(E,"hoverButton")},"&:active":{boxShadow:E=>ye(E,"pressedButton"),transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"text.disabled"}},children:i?"Save Changes":"Create Report View"})]})]})}function Gu({viewName:e,onConfirm:r,onCancel:n}){return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:i=>({borderRadius:ot(i),maxHeight:"min(480px, calc(100vh - 180px))",my:"auto",...ue(i).paper})},children:[t.jsxs(o.DialogTitle,{sx:i=>({display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,...ue(i).header}),children:["Delete View",t.jsx(o.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:t.jsx(O.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(O.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",borderColor:"divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:[t.jsx(o.Button,{onClick:n,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:i=>`${i.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"action.selected",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:r,variant:"contained",color:"error",sx:{fontSize:"0.875rem",px:3,py:.875,minHeight:36,borderRadius:i=>`${i.shape.borderRadius}px`,boxShadow:i=>ye(i,"restButton"),transition:"all 0.2s ease","&:hover":{boxShadow:i=>ye(i,"hoverButton")},"&:active":{boxShadow:i=>ye(i,"pressedButton"),transform:"translateY(1px)"}},children:"Delete View"})]})]})}const xs="COLUMN";function Uu({column:e,index:r,isVisible:n,width:i,minColumnWidth:s,maxColumnWidth:a,canToggleOn:c,onToggleVisibility:l,onWidthChange:u,moveColumn:g}){const f=p.useRef(null),[m,v]=p.useState(i.toString());p.useEffect(()=>{v(i.toString())},[i]);const[{handlerId:C},B]=ir.useDrop({accept:xs,collect(S){return{handlerId:S.getHandlerId()}},hover(S,R){var I;if(!f.current)return;const q=S.index,T=r;if(q===T)return;const F=(I=f.current)==null?void 0:I.getBoundingClientRect(),X=(F.bottom-F.top)/2,W=R.getClientOffset(),h=((W==null?void 0:W.y)??0)-F.top;q<T&&h<X||q>T&&h>X||(g(q,T),S.index=T)}}),[{isDragging:b},y]=ir.useDrag({type:xs,item:()=>({index:r}),collect:S=>({isDragging:S.isDragging()})});y(B(f));const z=()=>{const S=parseInt(m);if(isNaN(S)){v(i.toString()),u(e.name,i);return}const R=Math.max(s,Math.min(a,S));v(R.toString()),u(e.name,R)},x=S=>{if(S===""||/^\d+$/.test(S)){v(S);const R=parseInt(S);if(!isNaN(R)&&R>=s){const q=Math.min(a,R);u(e.name,q)}}},j=S=>{S.key==="Enter"&&(S.preventDefault(),z(),S.target.blur())},E=S=>({string:"primary.main",number:"success.main",boolean:"secondary.main",array:"info.main",object:"error.main",null:"text.secondary",mixed:"text.secondary"})[S]||"text.secondary";return t.jsxs(o.TableRow,{ref:f,"data-handler-id":C,sx:{opacity:b?.4:1,bgcolor:n?"background.paper":"action.hover",transition:"opacity 0.15s ease","&:hover":{bgcolor:n?"action.hover":"action.selected"},cursor:"move",height:56,borderBottom:"1px solid divider"},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:"text.secondary",cursor:"grab",opacity:.6,transition:"opacity 0.2s ease","&:hover":{opacity:1},"&:active":{cursor:"grabbing"}},children:t.jsx(O.DragIndicator,{sx:{fontSize:20}})}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:S=>S.typography.body2.fontWeight||400,fontSize:S=>S.typography.body2.fontSize||"0.875rem",color:n?"text.primary":"text.secondary"},children:dt(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:`${E(e.type)}15`,color:E(e.type),border:`1px solid ${E(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:"number",value:m,onChange:S=>x(S.target.value),onBlur:z,onKeyDown:j,placeholder:"150",size:"small",inputProps:{min:s,max:a,step:10},sx:{width:90,"& .MuiOutlinedInput-root":{height:32,fontSize:"0.8125rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputBase-input":{py:.5,px:1.25,color:"text.primary"},"& input[type=number]::-webkit-inner-spin-button":{opacity:1},"& input[type=number]::-webkit-outer-spin-button":{opacity:1}}}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:S=>S.typography.caption.fontSize||"0.75rem",color:"text.secondary"},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:()=>l(e.name,!n),disabled:!n&&!c,title:n?"Hide column":c?"Show column":"Max visible columns reached",size:"small",sx:{p:.75,color:n?"primary.main":"text.secondary",transition:"all 0.2s ease","&:hover:not(:disabled)":{bgcolor:"action.hover",color:n?"primary.dark":"primary.main"},"&:disabled":{opacity:.5,cursor:"not-allowed"}},children:n?t.jsx(O.Visibility,{sx:{fontSize:20}}):t.jsx(O.VisibilityOff,{sx:{fontSize:20}})}),t.jsx(o.Chip,{label:n?"Visible":"Hidden",size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:500,bgcolor:n?S=>$(S.palette.success.main,.12):"action.selected",color:n?"success.main":"text.secondary","& .MuiChip-label":{px:1}}})]})})]})}function Yu({schema:e,columnVisibility:r,columnOrder:n,columnWidths:i={},views:s=[],activeViewId:a="",onUpdateColumnVisibility:c,onUpdateColumnOrder:l,onUpdateColumnWidth:u,onResetLayout:g,onClose:f}){const m=br(),[v,C]=p.useState(!1),[B,b]=p.useState(n),[y,z]=p.useState(i),[x,j]=p.useState("all");p.useEffect(()=>{b(n)},[n]),p.useEffect(()=>{z(i)},[i]);const E=(I,N)=>{z(d=>({...d,[I]:N})),u==null||u(I,N)},S=(I,N)=>{const d=[...B],[oe]=d.splice(I,1);d.splice(N,0,oe),b(d),l(d)},R=()=>{g(),C(!1)},T=B.map(I=>e.find(N=>N.name===I)).filter(I=>I!==void 0).filter(I=>{const N=r[I.name]??!0;return x==="active"?N:x==="hidden"?!N:!0}),F=Object.values(r).filter(I=>I).length,X=e.length,W=s.find(I=>I.id===a),h=p.useMemo(()=>{if(!W)return!1;const I=W.snapshot,N=I.columnVisibility??{},d=JSON.stringify(r)!==JSON.stringify(N),oe=I.columnOrder??[],G=n??[],te=JSON.stringify(G)!==JSON.stringify(oe)&&!(G.length===0&&oe.length===0),ge=I.columnWidths??{},V=JSON.stringify(y)!==JSON.stringify(ge);return d||te||V},[W,r,n,y]);return t.jsx(ir.DndProvider,{backend:si.HTML5Backend,children:t.jsx(o.Box,{onClick:f,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:I=>$(I.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:I=>I.zIndex.modal,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:I=>I.stopPropagation(),elevation:0,sx:{position:"relative",width:720,maxWidth:"calc(100vw - 120px)",maxHeight:"min(760px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:I=>ot(I),bgcolor:"background.paper",outline:"none",boxShadow:I=>ue(I).paper.boxShadow,border:I=>ue(I).paper.border,overflow:"hidden",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,flexShrink:0,bgcolor:I=>ue(I).header.backgroundColor,borderBottom:I=>ue(I).header.borderBottom,boxShadow:I=>ue(I).header.boxShadow},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[t.jsx(o.Box,{sx:{flex:1},children:t.jsxs(o.Typography,{variant:"h6",sx:{fontSize:I=>I.typography.h6.fontSize||"1.125rem",fontWeight:I=>I.typography.h6.fontWeight||500,color:I=>I.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:["Manage columns",t.jsx(Dr,{content:_r.columns,isDev:process.env.NODE_ENV==="development"})]})}),t.jsx(o.IconButton,{onClick:f,size:"small",sx:{ml:2,p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.Tabs,{value:x,onChange:(I,N)=>j(N),sx:{minHeight:36,mt:.5,"& .MuiTabs-indicator":{bgcolor:I=>ct(I).main,height:3}},children:[t.jsx(o.Tab,{label:"All",value:"all",sx:{minHeight:36,py:.75,px:2,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary",borderRadius:"8px 8px 0 0","&.Mui-selected":{borderBottomColor:"text.primary",fontWeight:600,bgcolor:I=>ct(I).hoverBg},"&:hover":{color:"text.primary",bgcolor:I=>ct(I).bg}}}),t.jsx(o.Tab,{label:"Visible",value:"active",sx:{minHeight:36,py:.75,px:2,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary",borderRadius:"8px 8px 0 0","&.Mui-selected":{color:"text.primary",fontWeight:600,bgcolor:I=>ct(I).hoverBg},"&:hover":{color:"text.primary",bgcolor:I=>ct(I).bg}}}),t.jsx(o.Tab,{label:"Hidden",value:"hidden",sx:{minHeight:36,py:.75,px:2,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary",borderRadius:"8px 8px 0 0","&.Mui-selected":{color:"text.primary",fontWeight:600,bgcolor:I=>ct(I).hoverBg},"&:hover":{color:"text.primary",bgcolor:I=>ct(I).bg}}})]})]}),t.jsx(o.Box,{sx:{flex:1,overflow:"auto","&::-webkit-scrollbar":{width:8,height:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:I=>$(I.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:I=>$(I.palette.text.primary,.3)}}},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:"text.secondary",bgcolor:"background.paper",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid divider"},children:"Column name"}),t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"0.6875rem",color:"text.secondary",bgcolor:"background.paper",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid divider"},children:"Type"}),t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"0.6875rem",color:"text.secondary",bgcolor:"background.paper",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid divider"},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:["Width",t.jsx(o.Tooltip,{title:`Column width in pixels (min: ${m.columns.minColumnWidth}px, max: ${m.columns.maxColumnWidth}px)`,arrow:!0,placement:"top",children:t.jsx(O.InfoOutlined,{sx:{fontSize:14,color:"text.secondary",cursor:"help"}})})]})}),t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"0.6875rem",color:"text.secondary",bgcolor:"background.paper",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid divider"},children:"Visibility"})]})}),t.jsx(o.TableBody,{children:T.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:I=>I.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"No columns in this category"})})}):T.map((I,N)=>{const d=r[I.name]??!0,oe=d||F<m.columns.maxVisible;return t.jsx(Uu,{column:I,index:N,isVisible:d,width:y[I.name]||170,minColumnWidth:m.columns.minColumnWidth,maxColumnWidth:m.columns.maxColumnWidth,canToggleOn:oe,onToggleVisibility:c,onWidthChange:E,moveColumn:S},I.name)})})]})}),t.jsx(o.Box,{sx:{px:3,py:1,borderTop:"1px solid divider",bgcolor:"background.default",flexShrink:0},children:t.jsxs(o.Typography,{variant:"body2",sx:{fontSize:I=>I.typography.body2.fontSize||"0.8125rem",color:"text.secondary"},children:[F," of ",X," columns visible • Drag to reorder"]})}),t.jsx(o.Box,{sx:{px:3,py:1.75,borderTop:"1px solid divider",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0,bgcolor:"action.hover"},children:t.jsx(o.Button,{onClick:()=>C(!0),disabled:!h,variant:"outlined",startIcon:t.jsx(O.Undo,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",color:"text.secondary",borderColor:"divider",px:2.5,py:.875,minHeight:36,borderRadius:I=>`${I.shape.borderRadius}px`,"&:hover":{borderColor:"primary.main",bgcolor:"background.paper",color:"primary.main"},"&.Mui-disabled":{color:"text.disabled",borderColor:"divider"}},children:"Reset"})}),v&&t.jsx(o.Box,{onClick:()=>C(!1),sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:I=>$(I.palette.common.black,.5),display:"flex",alignItems:"center",justifyContent:"center",zIndex:I=>I.zIndex.tooltip},children:t.jsxs(o.Paper,{onClick:I=>I.stopPropagation(),elevation:0,sx:{width:400,maxWidth:"90vw",borderRadius:I=>_o(I),bgcolor:"background.paper",boxShadow:I=>ue(I).paper.boxShadow,border:I=>ue(I).paper.border},children:[t.jsxs(o.Box,{sx:{px:3,py:2.5},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1rem",fontWeight:500,color:"text.primary",mb:1.5},children:"Reset column layout?"}),t.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."})]}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:()=>C(!1),variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,borderRadius:I=>`${I.shape.borderRadius}px`,"&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:R,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"error.main",color:"background.paper",px:3,py:1,borderRadius:I=>`${I.shape.borderRadius}px`,boxShadow:I=>ye(I,"pressedButton"),"&:hover":{bgcolor:"error.dark",boxShadow:I=>ye(I,"hoverButton")},"&:active":{boxShadow:I=>ye(I,"pressedButton"),transform:"translateY(1px)"}},children:"Reset layout"})]})]})})]})})})}function qu({schema:e,grouping:r,onApply:n,onClose:i,onOpenDevConfig:s}){var q;const[a,c]=p.useState(r||{enabled:!1,levels:[],collapsedGroups:[]}),[l,u]=p.useState(""),[g,f]=p.useState(null),m=p.useMemo(()=>Aa(e),[e]),v=p.useMemo(()=>m.filter(T=>!a.levels.some((F,X)=>F.column===T.name&&X!==g)),[m,a.levels,g]),C=br(),B=a.levels.length<C.grouping.maxLevels&&v.length>0&&(C.grouping.allowNested||a.levels.length===0),b=p.useCallback(T=>{!B||!T||(c({...a,levels:[...a.levels,{column:T}],enabled:!0}),u(""),setTimeout(()=>{var F;return(F=document.activeElement)==null?void 0:F.blur()},0))},[B,a]),y=p.useCallback(T=>{const F=a.levels.filter((X,W)=>W!==T);if(F.length===0){n(null),i();return}c({...a,levels:F,enabled:F.length>0})},[a,n,i]),z=p.useCallback(T=>{f(T),u(a.levels[T].column)},[a.levels]),x=p.useCallback(()=>{if(g===null||!l)return;const T=[...a.levels];T[g]={column:l},c({...a,levels:T}),f(null),u("")},[g,l,a]),j=p.useCallback(()=>{f(null),u("")},[]),E=p.useCallback((T,F)=>{const X=F==="up"?T-1:T+1;if(X<0||X>=a.levels.length)return;const W=[...a.levels],[h]=W.splice(T,1);W.splice(X,0,h),c({...a,levels:W})},[a]),S=p.useCallback(()=>{n(null),i()},[n,i]),R=p.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:T=>$(T.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:T=>T.zIndex.modal,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:T=>T.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(560px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:T=>ot(T),bgcolor:"background.paper",outline:"none",boxShadow:T=>ue(T).paper.boxShadow,border:T=>ue(T).paper.border,overflow:"hidden",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,bgcolor:T=>ue(T).header.backgroundColor,borderBottom:T=>ue(T).header.borderBottom,boxShadow:T=>ue(T).header.boxShadow,flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:T=>T.typography.h6.fontSize||"1.125rem",fontWeight:T=>T.typography.h6.fontWeight||500,color:T=>T.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Group configuration"}),t.jsx(Dr,{content:_r.grouping,isDev:process.env.NODE_ENV==="development"}),s&&t.jsx(o.IconButton,{onClick:s,size:"small",title:"Dev config",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Settings,{sx:{fontSize:18}})})]}),t.jsx(o.IconButton,{onClick:i,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Close,{sx:{fontSize:20}})})]}),t.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:1,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:T=>$(T.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:T=>$(T.palette.text.primary,.3)}}},children:t.jsxs(o.Stack,{spacing:2.5,children:[g===null&&t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:T=>T.typography.caption.fontSize||"0.6875rem",fontWeight:T=>T.typography.caption.fontWeight||600,color:"text.secondary",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:l,onChange:T=>b(T.target.value),disabled:!B,displayEmpty:!0,sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-disabled":{bgcolor:"action.hover"}},children:[t.jsx(o.MenuItem,{value:"",sx:{fontSize:"0.875rem",color:"text.secondary"},children:"Select a column..."}),v.map(T=>t.jsxs(o.MenuItem,{value:T.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:F=>Bt(F),"&:hover":{bgcolor:F=>$(F.palette.primary.main,.2)}}},children:[dt(T.name)," (",T.type.toUpperCase(),")"]},T.name))]})}),a.levels.length>=C.grouping.maxLevels&&t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",textAlign:"center",mt:1.5,fontSize:T=>T.typography.caption.fontSize||"0.75rem",color:"text.secondary"},children:"Maximum group levels (3) reached"}),m.length===0&&t.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{textAlign:"center",py:2,fontSize:T=>T.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"No groupable columns available. Only STRING and BOOLEAN columns can be grouped."})]}),g!==null&&t.jsxs(o.Alert,{severity:"warning",sx:{borderRadius:"8px",border:T=>`1px solid ${$(T.palette.warning.main,.5)}`,bgcolor:T=>$(T.palette.warning.main,.12),"& .MuiAlert-icon":{color:"warning.main"}},children:[t.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:T=>T.typography.body2.fontWeight||500,mb:1.5,fontSize:T=>T.typography.body2.fontSize||"0.875rem",color:"text.primary"},children:["Edit Group Level ",g+1]}),t.jsx(o.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:t.jsxs(o.Select,{value:l,onChange:T=>u(T.target.value),sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"}},children:[t.jsx(o.MenuItem,{value:"",sx:{fontSize:"0.875rem"},children:"Select a column..."}),t.jsxs(o.MenuItem,{value:a.levels[g].column,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:T=>Bt(T)}},children:[a.levels[g].column," (",(q=e.find(T=>T.name===a.levels[g].column))==null?void 0:q.type.toUpperCase(),")"]}),v.filter(T=>T.name!==a.levels[g].column).map(T=>t.jsxs(o.MenuItem,{value:T.name,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:F=>Bt(F)}},children:[dt(T.name)," (",T.type.toUpperCase(),")"]},T.name))]})}),t.jsxs(o.Stack,{direction:"row",spacing:1.5,children:[t.jsx(o.Button,{onClick:x,disabled:!l,variant:"contained",fullWidth:!0,size:"small",sx:{fontSize:"0.875rem",bgcolor:"warning.main",color:"background.paper",py:.875,boxShadow:"none","&:hover":{bgcolor:"warning.dark",boxShadow:T=>ye(T,"pressedButton")}},children:"Save"}),t.jsx(o.Button,{onClick:j,variant:"outlined",fullWidth:!0,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",borderColor:"divider",py:.875,"&:hover":{borderColor:"text.secondary",bgcolor:"action.hover"}},children:"Cancel"})]})]}),a.levels.length>0&&g===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:T=>T.typography.caption.fontSize||"0.6875rem",fontWeight:T=>T.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:"Active group levels"}),t.jsx(o.Button,{onClick:S,size:"small",sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"}},children:"Clear all"})]}),t.jsx(o.Stack,{spacing:1.5,children:a.levels.map((T,F)=>{const X=e.find(W=>W.name===T.column);return t.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:"action.hover",borderColor:"divider",boxShadow:W=>ye(W,"pressedButtonLight")}},children:[t.jsx(o.Chip,{label:`L${F+1}`,size:"small",sx:{width:40,height:28,fontWeight:600,fontSize:"0.75rem",bgcolor:"primary.main",color:"background.paper",boxShadow:W=>`0 1px 2px 0 ${$(W.palette.primary.main,.3)}`}}),t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:W=>W.typography.body2.fontWeight||500,fontSize:W=>W.typography.body2.fontSize||"0.875rem",color:"text.primary"},children:T.column}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:W=>W.typography.caption.fontSize||"0.75rem",color:"text.secondary"},children:X==null?void 0:X.type.toUpperCase()})]}),t.jsxs(o.Stack,{direction:"row",spacing:.5,children:[t.jsx(o.IconButton,{size:"small",onClick:()=>E(F,"up"),disabled:F===0,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"divider"}},children:t.jsx(O.KeyboardArrowUp,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{size:"small",onClick:()=>E(F,"down"),disabled:F===a.levels.length-1,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"divider"}},children:t.jsx(O.KeyboardArrowDown,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{size:"small",onClick:()=>z(F),sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover",color:"primary.main"}},children:t.jsx(O.Edit,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{size:"small",onClick:()=>y(F),sx:{color:"text.secondary","&:hover":{bgcolor:W=>$(W.palette.error.main,.08),color:"error.main"}},children:t.jsx(O.Delete,{sx:{fontSize:18}})})]})]},F)})})]})]})}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:i,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:T=>`${T.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:R,variant:"contained",disabled:a.levels.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:T=>`${T.shape.borderRadius}px`,boxShadow:T=>ye(T,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:T=>ye(T,"hoverButton")},"&:active":{boxShadow:T=>ye(T,"pressedButton"),transform:"translateY(1px)"}},children:"Apply grouping"})]})]})})}function Ju({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(O.Warning,{sx:{fontSize:20}}),action:t.jsx(o.IconButton,{size:"small",onClick:n,sx:{color:"warning.main"},children:t.jsx(O.Close,{sx:{fontSize:20}})}),sx:{alignItems:"flex-start"},children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:i=>i.typography.h6.fontWeight||600,fontSize:i=>i.typography.h6.fontSize||"1rem",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(O.Save,{sx:{fontSize:14}}),size:"small",children:"Save View & Export"}),t.jsx(o.Button,{onClick:e,variant:"contained",color:"warning",startIcon:t.jsx(O.Download,{sx:{fontSize:14}}),size:"small",children:"Export Anyway"})]})]})})}const fs=[{key:"1h",label:"Last 1 Hour",ms:3600*1e3},{key:"24h",label:"Last 24 Hours",ms:1440*60*1e3},{key:"7d",label:"Last 7 Days",ms:10080*60*1e3},{key:"30d",label:"Last 30 Days",ms:720*60*60*1e3},{key:"all",label:"All Time",ms:null}];function Ku(e,r){if(r===null)return e.length;const n=Date.now()-r;return e.filter(i=>new Date(i.timestamp).getTime()>=n).length}function Xu(e,r){if(r===null)return[];const n=Date.now()-r;return e.filter(i=>new Date(i.timestamp).getTime()<n)}function Qu({auditHistory:e,onClose:r,onClearAuditHistory:n}){const i=ht(),s=i.palette,[a,c]=p.useState("1h"),[l,u]=p.useState(!1),g=[...e].sort((B,b)=>new Date(b.timestamp).getTime()-new Date(B.timestamp).getTime()),f=fs.find(B=>B.key===a),m=Ku(e,f.ms),v=()=>u(!0),C=()=>{n&&(n(Xu(e,f.ms)),u(!1))};return t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{onClick:r,sx:{position:"fixed",inset:0,bgcolor:$(s.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:i.zIndex.modal,animation:"fadeIn 0.2s ease","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:B=>B.stopPropagation(),elevation:0,sx:{width:520,maxWidth:"calc(100vw - 48px)",maxHeight:"min(700px, calc(100vh - 80px))",display:"flex",flexDirection:"column",borderRadius:ot(i),bgcolor:"background.paper",overflow:"hidden",...ue(i).paper,animation:"slideIn 0.2s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.96) translateY(-8px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{px:2.5,py:1.75,display:"flex",alignItems:"center",justifyContent:"space-between",gap:1.5,flexShrink:0,...ue(i).header},children:[t.jsxs(o.Box,{sx:{minWidth:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.Typography,{sx:{fontSize:B=>B.typography.body1.fontSize||"0.9375rem",fontWeight:B=>B.typography.h6.fontWeight||600,color:"text.primary"},children:"Audit History"}),t.jsx(Dr,{content:_r.auditHistory,isDev:process.env.NODE_ENV==="development"})]}),t.jsxs(o.Typography,{sx:{fontSize:B=>B.typography.caption.fontSize||"0.75rem",color:"text.secondary",mt:.125},children:[g.length," event",g.length!==1?"s":""," recorded"]})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,flexShrink:0},children:[n&&e.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Select,{value:a,onChange:B=>c(B.target.value),size:"small",variant:"outlined",sx:{fontSize:"0.75rem",height:30,minWidth:120,"& .MuiSelect-select":{py:.375,px:1,fontSize:"0.75rem"},"& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:$(s.text.primary,.3)}},children:fs.map(B=>t.jsx(o.MenuItem,{value:B.key,sx:{fontSize:"0.8125rem"},children:B.label},B.key))}),t.jsx(o.Button,{size:"small",variant:"outlined",color:"error",startIcon:t.jsx(O.DeleteSweepOutlined,{sx:{fontSize:14}}),onClick:v,sx:{fontSize:"0.75rem",borderRadius:"7px",px:1.25,height:30,whiteSpace:"nowrap",borderColor:$(s.error.main,.5),"&:hover":{bgcolor:$(s.error.main,.06),borderColor:"error.main"}},children:"Clear Logs"})]}),t.jsx(o.IconButton,{onClick:r,size:"small",sx:{color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Close,{sx:{fontSize:17}})})]})]}),t.jsx(o.Box,{sx:{flex:1,overflowY:"auto",px:2,py:1.5,bgcolor:$(s.text.primary,.012),"&::-webkit-scrollbar":{width:5},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:$(s.text.primary,.14),borderRadius:3}},children:g.length===0?t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8,gap:1,textAlign:"center"},children:[t.jsx(O.AccessTime,{sx:{fontSize:44,color:"text.disabled",opacity:.5}}),t.jsx(o.Typography,{sx:{fontSize:B=>B.typography.body1.fontSize||"0.9375rem",color:"text.secondary",fontWeight:B=>B.typography.body2.fontWeight||500},children:"No audit events yet"}),t.jsx(o.Typography,{sx:{fontSize:B=>B.typography.body2.fontSize||"0.8125rem",color:"text.disabled"},children:"Changes to this report will appear here"})]}):t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:g.map(B=>{const b=uu(i,B.feature),{summary:y,detail:z}=nl(B);return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.25,px:1.5,py:1.25,borderRadius:"10px",bgcolor:"background.paper",border:"1px solid",borderColor:"divider",transition:"border-color 0.15s","&:hover":{borderColor:$(s.text.primary,.18)}},children:[t.jsx(o.Chip,{label:al(B.feature),size:"small",sx:{height:20,fontSize:"0.5625rem",fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",bgcolor:$(b,.1),color:b,border:`1px solid ${$(b,.22)}`,flexShrink:0,mt:.125,"& .MuiChip-label":{px:.75}}}),t.jsxs(o.Box,{sx:{flex:1,minWidth:0},children:[t.jsx(o.Typography,{sx:{fontSize:"0.8125rem",fontWeight:500,color:"text.primary",lineHeight:1.45,wordBreak:"break-word"},children:y}),z&&t.jsx(o.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.25,lineHeight:1.4},children:z}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mt:.5,flexWrap:"wrap"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.375},children:[t.jsx(O.AccessTime,{sx:{fontSize:11,color:"text.disabled"}}),t.jsx(o.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:ll(B.timestamp)})]}),B.user&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.375},children:[t.jsx(O.Person,{sx:{fontSize:11,color:"text.disabled"}}),t.jsx(o.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:B.user})]})]})]})]},B.id)})})})]})}),t.jsxs(o.Dialog,{open:l,onClose:()=>u(!1),maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:_o(i),...ue(i).paper}},children:[t.jsxs(o.DialogContent,{sx:{pt:3,pb:2,px:3},children:[t.jsx(o.Box,{sx:{width:44,height:44,borderRadius:"12px",bgcolor:$(s.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx(O.WarningAmberOutlined,{sx:{fontSize:22,color:"error.main"}})}),t.jsx(o.Typography,{sx:{fontSize:B=>B.typography.body1.fontSize||"0.9375rem",fontWeight:B=>B.typography.h6.fontWeight||600,color:"text.primary",mb:1},children:"Clear Audit Logs"}),t.jsxs(o.Typography,{sx:{fontSize:B=>B.typography.body2.fontSize||"0.8125rem",color:"text.secondary",lineHeight:1.65},children:["You are about to permanently remove"," ",t.jsxs(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:[m," audit record",m!==1?"s":""]})," ",f.key==="all"?"from all time":`from the ${f.label.toLowerCase()}`,". This action cannot be undone."]})]}),t.jsx(o.Divider,{}),t.jsxs(o.DialogActions,{sx:{px:2.5,py:1.5,gap:1},children:[t.jsx(o.Button,{onClick:()=>u(!1),variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),t.jsxs(o.Button,{onClick:C,variant:"contained",color:"error",startIcon:t.jsx(O.DeleteSweepOutlined,{sx:{fontSize:14}}),sx:{fontSize:"0.8125rem",borderRadius:"7px",px:2},children:["Clear ",m," Record",m!==1?"s":""]})]})]})]})}function Zu({onSave:e,onClose:r}){const[n,i]=p.useState(""),[s,a]=p.useState(""),[c,l]=p.useState(""),[u,g]=p.useState([]),[f,m]=p.useState(""),[v,C]=p.useState(""),B=S=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(S),b=()=>{const S=c.trim();if(S){if(!B(S)){C("Please enter a valid email address");return}if(u.includes(S)){C("This email is already added");return}g([...u,S]),l(""),C("")}},y=S=>{g(u.filter(R=>R!==S))},z=S=>{S.key==="Enter"&&(S.preventDefault(),b())},x=()=>{if(!n.trim()){m("Preset name is required");return}e(n.trim(),s.trim(),u.length>0?u:void 0)},j=S=>{i(S),f&&m("")},E=S=>{l(S),v&&C("")};return t.jsx(o.Box,{onClick:r,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:S=>$(S.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:S=>S.zIndex.modal,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:S=>ot(S),bgcolor:"background.paper",outline:"none",boxShadow:S=>ue(S).paper.boxShadow,border:S=>ue(S).paper.border,overflow:"hidden",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,bgcolor:S=>ue(S).header.backgroundColor,borderBottom:S=>ue(S).header.borderBottom,boxShadow:S=>ue(S).header.boxShadow,flexShrink:0},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:S=>S.typography.h6.fontSize||"1.125rem",fontWeight:S=>S.typography.h6.fontWeight||500,color:S=>S.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Create shareable preset"}),t.jsx(o.IconButton,{onClick:r,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.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:S=>$(S.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:S=>$(S.palette.text.primary,.3)}}},children:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[t.jsx(o.Alert,{severity:"info",icon:t.jsx(O.Info,{sx:{fontSize:20}}),sx:{borderRadius:"8px",border:S=>`1px solid ${$(S.palette.primary.main,.3)}`,bgcolor:S=>Bt(S),"& .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."}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:S=>S.typography.body2.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."}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:S=>S.typography.caption.fontSize||"0.6875rem",fontWeight:S=>S.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Preset name *"}),t.jsx(o.TextField,{required:!0,value:n,onChange:S=>j(S.target.value),placeholder:"e.g., Q4 Active Users Report",error:!!f,helperText:f,autoFocus:!0,fullWidth:!0,size:"small",sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"divider"},"&: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}}})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:S=>S.typography.caption.fontSize||"0.6875rem",fontWeight:S=>S.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Description (optional)"}),t.jsx(o.TextField,{value:s,onChange:S=>a(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:"background.paper","& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputBase-input":{py:1.25,color:"text.primary",lineHeight:1.6}}})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:S=>S.typography.caption.fontSize||"0.6875rem",fontWeight:S=>S.typography.caption.fontWeight||600,color:"text.secondary",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=>E(S.target.value),onKeyPress:z,placeholder:"Enter email address",error:!!v,helperText:v,fullWidth:!0,size:"small",InputProps:{startAdornment:t.jsx(O.Email,{sx:{fontSize:18,color:"text.secondary",mr:1}})},sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"divider"},"&: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}}}),t.jsx(o.Button,{onClick:b,variant:"outlined",startIcon:t.jsx(O.Add,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",color:"primary.main",borderColor:"divider",px:2,py:1.25,minHeight:40,borderRadius:S=>`${S.shape.borderRadius}px`,flexShrink:0,"&:hover":{borderColor:"primary.main",bgcolor:"action.hover"}},children:"Add"})]}),u.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1,mt:1.5},children:u.map(S=>t.jsx(o.Chip,{label:S,onDelete:()=>y(S),deleteIcon:t.jsx(O.Delete,{sx:{fontSize:16}}),sx:{bgcolor:R=>Bt(R),color:"primary.main",fontSize:"0.8125rem",height:28,"& .MuiChip-deleteIcon":{color:"primary.main","&:hover":{color:"primary.dark"}}}},S))}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary",mt:1,display:"block",lineHeight:1.5},children:u.length>0?`An email with the shareable link will be sent to ${u.length} recipient${u.length>1?"s":""}`:"Add email addresses to send the shareable link automatically"})]})]})}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:r,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:S=>`${S.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:x,variant:"contained",startIcon:t.jsx(O.Share,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:S=>`${S.shape.borderRadius}px`,boxShadow:S=>ye(S,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:S=>ye(S,"hoverButton")},"&:active":{boxShadow:S=>ye(S,"pressedButton"),transform:"translateY(1px)"}},children:"Create & share"})]})]})})}function ep({presetName:e,onClear:r}){return t.jsx(o.Chip,{icon:t.jsx(O.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(O.Close,{sx:{fontSize:14}})}),sx:{bgcolor: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 tp({presets:e,reportId:r,onOpenPreset:n,onDeletePreset:i,onClose:s}){const a=c=>new Date(c).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});return t.jsx(o.Box,{onClick:s,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:c=>$(c.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:c=>c.zIndex.modal,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 - 200px))",display:"flex",flexDirection:"column",borderRadius:c=>ot(c),bgcolor:"background.paper",outline:"none",boxShadow:c=>ue(c).paper.boxShadow,border:c=>ue(c).paper.border,overflow:"hidden",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,bgcolor:c=>ue(c).header.backgroundColor,borderBottom:c=>ue(c).header.borderBottom,boxShadow:c=>ue(c).header.boxShadow,flexShrink:0},children:[t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:c=>c.typography.h6.fontSize||"1.125rem",fontWeight:c=>c.typography.h6.fontWeight||500,color:c=>c.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Manage Presets"}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:c=>c.typography.caption.fontSize||"0.8125rem",color:"text.secondary",mt:.5,display:"block"},children:[e.length," saved ",e.length===1?"preset":"presets"]})]}),t.jsx(o.IconButton,{onClick:s,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.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:"divider",borderRadius:4,"&:hover":{bgcolor:c=>$(c.palette.text.primary,.2)}}},children:e.length===0?t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8},children:[t.jsx(O.Share,{sx:{fontSize:48,color:"divider",mb:2}}),t.jsx(o.Typography,{variant:"body1",sx:{fontSize:c=>c.typography.body2.fontSize||"0.875rem",color:"text.secondary",textAlign:"center"},children:"No presets created yet"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:c=>c.typography.body2.fontSize||"0.8125rem",color:"text.disabled",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(c=>t.jsxs(o.Paper,{elevation:0,sx:{p:2.5,border:"1px solid divider",borderRadius:"8px",bgcolor:"background.paper",transition:"all 0.2s ease","&:hover":{borderColor:"divider",boxShadow:l=>ye(l,"restButtonLight")}},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:l=>l.typography.body1.fontSize||"0.9375rem",fontWeight:l=>l.typography.h6.fontWeight||500,color:"text.primary",mb:.5},children:c.name}),c.description&&t.jsx(o.Typography,{variant:"body2",sx:{fontSize:l=>l.typography.body2.fontSize||"0.8125rem",color:"text.secondary",lineHeight:1.5},children:c.description})]})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:2},children:[t.jsx(o.Chip,{label:`Created ${a(c.createdAt)}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"action.hover",color:"text.secondary","& .MuiChip-label":{px:1}}}),t.jsx(o.Chip,{label:`By ${c.createdBy}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"action.hover",color:"text.secondary","& .MuiChip-label":{px:1}}})]}),t.jsx(o.Divider,{sx:{my:1.5,borderColor:"divider"}}),t.jsx(o.Box,{sx:{display:"flex",gap:1},children:t.jsx(o.Button,{onClick:()=>i(c.id,c.name),variant:"outlined",size:"small",startIcon:t.jsx(O.Delete,{sx:{fontSize:16}}),sx:{fontSize:"0.8125rem",color:"error.main",borderColor:"divider",px:1.5,py:.75,borderRadius:l=>`${l.shape.borderRadius}px`,"&:hover":{borderColor:"error.main",bgcolor:l=>$(l.palette.error.main,.04)}},children:"Delete"})})]},c.id))})}),t.jsx(o.Box,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end",display:"flex"},children:t.jsx(o.Button,{onClick:s,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",px:3,py:.875,minHeight:36,borderRadius:c=>`${c.shape.borderRadius}px`,boxShadow:c=>ye(c,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:c=>ye(c,"hoverButton")},"&:active":{boxShadow:c=>ye(c,"pressedButton"),transform:"translateY(1px)"}},children:"Close"})})]})})}const ea={maxFileSizeBytes:2*1024*1024,maxFileSizeHardBytes:3*1024*1024,maxRows:1e4,maxRowsHard:5e4,maxImageColumns:5},rp=[/^https?:\/\/.*\.(jpg|jpeg|png|gif|webp|svg|avif|bmp)/i,/^data:image\//i,/^\/.*\.(jpg|jpeg|png|gif|webp|svg)/i],op=[/image/i,/photo/i,/avatar/i,/thumbnail/i,/picture/i,/logo/i,/icon/i,/banner/i];function np(e,r){const n=[];for(const i of e){if(i.type!=="string")continue;const s=op.some(l=>l.test(i.name));let a=!1;const c=r.slice(0,10).map(l=>l[i.name]).filter(l=>typeof l=="string"&&l.length>0);c.length>0&&(a=c.filter(u=>rp.some(g=>g.test(u))).length/c.length>.6),(s||a)&&n.push(i.name)}return n}function kn(e,r){if(e.length===0||r.length===0)return 0;const n=e.slice(0,Math.min(50,e.length)),s=r.map(c=>{const l=n.map(g=>String(g[c]??"")).filter(g=>g.length>0);if(l.length===0)return 5;const u=l.reduce((g,f)=>g+f.length,0);return Math.ceil(u/l.length)+1}).reduce((c,l)=>c+l,0)+1;return r.reduce((c,l)=>c+l.length+1,0)+s*e.length}function ip(e,r){const n=kn(e,r);return Math.ceil(n*3.5)}function sp(e,r){const n=kn(e,r);return Math.ceil(n*.7)}function ap(e,r){const n=kn(e,r);return Math.ceil(n*2)}function lp(e,r,n){switch(e){case"csv":return kn(r,n);case"excel":return sp(r,n);case"json":return ip(r,n);case"pdf":return ap(r,n)}}function gs(e,r){return Math.ceil(e/r)}function cp(e,r,n,i,s=ea){const a=[],c=lp(e,r,n),l=r.length;if(l>s.maxRowsHard){const f=gs(l,s.maxRows);a.push({type:"row_count",severity:"error",message:`Export blocked: ${l.toLocaleString()} rows exceeds the maximum of ${s.maxRowsHard.toLocaleString()}`,detail:`Consider using filters to reduce the dataset before exporting, or split into ${f} smaller exports of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:f,value:l,limit:s.maxRowsHard})}else if(l>s.maxRows){const f=gs(l,s.maxRows);a.push({type:"row_count",severity:"warning",message:`Large export: ${l.toLocaleString()} rows`,detail:`This is a large export that may take a moment to complete. For faster results, consider splitting into ${f} smaller export${f>1?"s":""} of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:f,value:l,limit:s.maxRows})}if(c>s.maxFileSizeHardBytes?a.push({type:"file_size",severity:"error",message:`File size blocked: estimated ${wo(c)} exceeds the ${wo(s.maxFileSizeHardBytes)} limit`,detail:"Reduce the number of rows or columns and try again. Applying filters before exporting is the most effective way to reduce file size.",value:c,limit:s.maxFileSizeHardBytes}):c>s.maxFileSizeBytes&&a.push({type:"file_size",severity:"warning",message:`Large file: estimated ${wo(c)}`,detail:`This exceeds the recommended ${wo(s.maxFileSizeBytes)} size. The download will still proceed but may be slow on some connections.`,value:c,limit:s.maxFileSizeBytes}),e!=="excel"){const f=np(i.filter(m=>n.includes(m.name)),r);if(f.length>0){const m=f.length>s.maxImageColumns;a.push({type:"image_columns",severity:m?"error":"warning",message:`Image column${f.length>1?"s":""} detected: ${f.map(v=>`"${v.replace(/_/g," ")}"`).join(", ")}`,detail:m?`Exporting ${f.length} image columns may produce a very large file. Consider hiding these columns before exporting.`:"Image URL columns are included in the export as plain text links — not embedded images.",value:f.length,limit:s.maxImageColumns})}}const u=a.some(f=>f.severity==="error"),g=a.some(f=>f.severity==="warning");return{violations:a,hasBlockingViolation:u,hasWarning:g,estimatedBytes:c}}function wo(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function dp({violation:e}){const n=ht().palette,i=e.severity==="error",s=i?n.error.main:n.warning.main,a=$(i?n.error.main:n.warning.main,.06),c=i?$(n.error.main,.25):$(n.warning.main,.3),l=i?O.ErrorOutline:O.WarningAmberOutlined;return t.jsxs(o.Box,{sx:{display:"flex",gap:1.25,p:1.5,borderRadius:"10px",bgcolor:a,border:"1px solid",borderColor:c},children:[t.jsx(l,{sx:{fontSize:17,color:s,flexShrink:0,mt:.125}}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{sx:{fontSize:u=>u.typography.body2.fontSize||"0.8125rem",fontWeight:u=>u.typography.body2.fontWeight||600,color:i?"error.main":"warning.dark",lineHeight:1.4},children:e.message}),e.detail&&t.jsx(o.Typography,{sx:{fontSize:u=>u.typography.caption.fontSize||"0.75rem",color:"text.secondary",mt:.375,lineHeight:1.5},children:e.detail}),e.suggestedBatches&&e.suggestedBatches>1&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,mt:.75},children:[t.jsx(O.SplitscreenOutlined,{sx:{fontSize:14,color:"text.secondary"}}),t.jsxs(o.Typography,{sx:{fontSize:u=>u.typography.caption.fontSize||"0.75rem",color:"text.secondary",fontWeight:u=>u.typography.body2.fontWeight||500},children:["Suggestion: split into ",e.suggestedBatches," exports"]})]})]})]})}function up({format:e}){const r=ht(),n={csv:{color:r.palette.primary.main,bg:r.palette.primary.main,label:"CSV"},excel:{color:r.palette.success.main,bg:r.palette.success.main,label:"XLSX"},json:{color:r.palette.text.secondary,bg:r.palette.text.secondary,label:"JSON"},pdf:{color:r.palette.error.main,bg:r.palette.error.main,label:"PDF"}}[e];return t.jsxs(o.Box,{sx:{width:44,height:52,position:"relative",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",mb:1},children:[t.jsxs("svg",{width:"38",height:"46",viewBox:"0 0 38 46",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("path",{d:"M5 2C3.34315 2 2 3.34315 2 5V41C2 42.6569 3.34315 44 5 44H33C34.6569 44 36 42.6569 36 41V13L25 2H5Z",fill:r.palette.background.paper,stroke:n.color,strokeWidth:"2.5",strokeLinejoin:"round"}),t.jsx("path",{d:"M24 2V13H36",fill:$(r.palette.text.primary,.05),stroke:n.color,strokeWidth:"2.5",strokeLinejoin:"round"})]}),t.jsx(o.Box,{sx:{position:"absolute",bottom:8,left:3,right:3,bgcolor:n.bg,color:r.palette.primary.contrastText,fontSize:"0.625rem",fontWeight:800,py:.25,borderRadius:"3px",textAlign:"center",letterSpacing:"0.05em"},children:n.label})]})}function ys({checked:e}){const r=ht();return t.jsx(o.Box,{sx:{width:20,height:20,borderRadius:"50%",border:e?`2px solid var(--urm-export-card-selected-border, ${r.palette.primary.main})`:`2px solid var(--urm-export-radio-border, ${r.palette.divider})`,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:r.palette.background.paper,transition:"all 0.15s ease",flexShrink:0},children:e&&t.jsx(o.Box,{sx:{width:10,height:10,borderRadius:"50%",bgcolor:`var(--urm-export-card-selected-border, ${r.palette.primary.main})`}})})}function pp({totalRows:e,visibleRows:r,hasGrouping:n,visibleColumnsCount:i,totalColumnsCount:s,schema:a,sampleRows:c=[],allRows:l=[],processedRows:u=[],initialFormat:g,initialScope:f="visible",initialColumnScope:m="visible",classTokens:v={},onExport:C,onClose:B}){const b=ht(),y=b.palette,z=br(),x=p.useMemo(()=>{var ce,de,ne,Q,pe;const G=((ne=(de=(ce=b.components)==null?void 0:ce.MuiCard)==null?void 0:de.styleOverrides)==null?void 0:ne.root)||{},te=G.border&&G.border!=="none"?G.border:(Q=b.tokens)!=null&&Q.cardBodyBorder&&b.tokens.cardBodyBorder!=="none"?b.tokens.cardBodyBorder:y.divider,ge=G.borderRadius!==void 0?typeof G.borderRadius=="number"?`${G.borderRadius}px`:G.borderRadius:`${b.shape.borderRadius}px`,V=G.boxShadow&&G.boxShadow!=="none"?G.boxShadow:((pe=b.tokens)==null?void 0:pe.cardBodyShadow)||ye(b,"menu"),K=ct(b);return{sectionBorder:`var(--urm-export-section-border, ${te})`,sectionTitleColor:`var(--urm-export-section-title-color, ${y.text.primary})`,sectionTitleBg:`var(--urm-export-section-title-bg, ${y.background.paper})`,cardBg:`var(--urm-export-card-bg, ${y.background.paper})`,cardBorder:`var(--urm-export-card-border, ${te})`,cardRadius:ge,cardShadow:V,cardHoverBg:`var(--urm-export-card-hover-bg, ${y.mode==="dark"?$(y.common.white,.08):$(y.common.black,.04)})`,cardSelectedBg:`var(--urm-export-card-selected-bg, ${$(K.main,y.mode==="dark"?.16:.08)})`,cardSelectedBorder:`var(--urm-export-card-selected-border, ${K.main})`,cardSelectedColor:`var(--urm-export-card-selected-color, ${y.mode==="dark"?y.primary.light:y.primary.main})`,primaryBtnBg:`var(--urm-export-primary-btn-bg, ${y.primary.main})`,primaryBtnHoverBg:`var(--urm-export-primary-btn-hover-bg, ${y.primary.dark})`,primaryBtnColor:`var(--urm-export-primary-btn-color, ${y.primary.contrastText})`,sectionPadding:`var(--urm-export-section-padding, ${b.spacing(2)})`,optionGap:`var(--urm-export-option-gap, ${b.spacing(1.5)})`}},[y,b]),j=g||z.export.allowedFormats[0]||"csv",[E,S]=p.useState(j),[R,q]=p.useState(f),[T,F]=p.useState(m),X=R==="visible"?r:e,W=T==="visible"?i:s,h=p.useMemo(()=>R==="visible"?u.length>0?u:new Array(r):l.length>0?l:new Array(e),[R,r,e,u,l]),I=p.useMemo(()=>T==="all"?a.map(G=>G.name):a.map(G=>G.name).slice(0,i),[T,a,i]),N=p.useMemo(()=>cp(E,h,I,a,ea),[E,h,I,a]),d=()=>{N.hasBlockingViolation||(C({format:E,scope:R,columnScope:T}),B())},oe={csv:"CSV",excel:"Excel (.xlsx)",json:"JSON",pdf:"PDF"};return t.jsx(o.Box,{onClick:B,className:`urm-export-backdrop ${v.modalBackdrop||""}`,sx:{position:"fixed",inset:0,bgcolor:$(y.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:b.zIndex.modal,animation:"fadeIn 0.2s ease","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:G=>G.stopPropagation(),elevation:0,className:`urm-export-paper ${v.modalPaper||""}`,sx:{width:540,maxWidth:"calc(100vw - 32px)",maxHeight:"min(760px, calc(100vh - 48px))",display:"flex",flexDirection:"column",borderRadius:ot(b),bgcolor:x.sectionTitleBg,overflow:"hidden",border:`1px solid ${x.cardBorder}`,boxShadow:x.cardShadow,animation:"slideIn 0.2s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.96) translateY(-8px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{className:`urm-export-header ${v.modalHeader||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,pt:2.5,pb:1.5,flexShrink:0,bgcolor:G=>ue(G).header.backgroundColor,borderBottom:G=>ue(G).header.borderBottom,boxShadow:G=>ue(G).header.boxShadow},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Typography,{className:`urm-export-title ${v.modalTitle||""}`,sx:{fontSize:"1.125rem",fontWeight:700,color:y.text.primary},children:"Export Report"}),t.jsx(Dr,{content:_r.export,isDev:process.env.NODE_ENV==="development"})]}),t.jsx(o.IconButton,{onClick:B,size:"small",className:`urm-export-close ${v.modalCloseButton||""}`,sx:{color:y.text.secondary,borderRadius:"50%","&:hover":{bgcolor:y.action.hover,color:y.text.primary}},children:t.jsx(O.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.Box,{className:`urm-export-content ${v.modalContent||""}`,sx:{flex:1,overflowY:"auto",px:3,pb:2.5,pt:.5,display:"flex",flexDirection:"column",gap:x.optionGap,"&::-webkit-scrollbar":{width:6},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:$(y.text.primary,.15),borderRadius:3}},children:[N.violations.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:N.violations.map((G,te)=>t.jsx(dp,{violation:G},te))}),t.jsxs(o.Box,{className:`urm-export-section ${v.sectionContainer||""}`,sx:{position:"relative",border:`1.5px solid ${x.sectionBorder}`,borderRadius:"12px",p:x.sectionPadding,pt:2.25,bgcolor:x.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${v.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:x.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:x.sectionTitleColor,lineHeight:1,zIndex:1},children:"Choose File Format"}),t.jsx(o.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:x.optionGap},children:[{id:"csv",title:"CSV",info:"Comma-separated values, compatible with Excel",allowed:z.export.allowedFormats.includes("csv")},{id:"excel",title:"Excel (.xlsx)",info:"Native Excel format with formatting support",allowed:z.export.allowedFormats.includes("excel")},{id:"json",title:"JSON",info:"Structured data with metadata and filters",allowed:z.export.allowedFormats.includes("json")},{id:"pdf",title:"PDF",info:"Print-ready PDF document",allowed:z.export.allowedFormats.includes("pdf")}].filter(G=>G.allowed).map(G=>{const te=E===G.id;return t.jsxs(o.Box,{onClick:()=>S(G.id),className:`urm-export-format-card ${te?v.formatCardSelected||"":v.formatCard||""}`,sx:{position:"relative",display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",p:1.75,borderRadius:x.cardRadius,border:te?`2px solid ${x.cardSelectedBorder}`:`1px solid ${x.cardBorder}`,boxShadow:te?void 0:x.cardShadow,bgcolor:te?x.cardSelectedBg:x.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:te?x.cardSelectedBorder:$(y.text.primary,.25),bgcolor:te?x.cardSelectedBg:x.cardHoverBg}},children:[te&&t.jsx(o.Box,{sx:{position:"absolute",top:8,right:8,width:20,height:20,borderRadius:"50%",bgcolor:x.cardSelectedBorder,color:y.primary.contrastText,display:"flex",alignItems:"center",justifyContent:"center",boxShadow:`0 2px 4px ${$(y.primary.main,.3)}`},children:t.jsx(O.Check,{sx:{fontSize:13,strokeWidth:2}})}),t.jsx(up,{format:G.id}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.Typography,{sx:{fontSize:"0.875rem",fontWeight:700,color:te?x.cardSelectedColor:y.text.primary},children:G.title}),t.jsx(o.Tooltip,{title:G.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:ge=>ge.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:y.text.secondary,"&:hover":{color:y.text.primary}},children:t.jsx(O.InfoOutlined,{sx:{fontSize:13}})})})]})]},G.id)})})]}),t.jsxs(o.Box,{className:`urm-export-section ${v.sectionContainer||""}`,sx:{position:"relative",border:`1.5px solid ${x.sectionBorder}`,borderRadius:"12px",p:x.sectionPadding,pt:2.25,bgcolor:x.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${v.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:x.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:x.sectionTitleColor,lineHeight:1,zIndex:1},children:"Select Rows Range"}),t.jsx(o.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:x.optionGap},children:[{value:"visible",label:"Visible rows",icon:t.jsx(O.VisibilityOutlined,{sx:{fontSize:20}}),info:`Export ${r.toLocaleString()} rows (filtered and searched)`},{value:"all",label:"All rows",icon:t.jsx(O.TableChartOutlined,{sx:{fontSize:20}}),info:`Export ${e.toLocaleString()} rows (complete original dataset)`}].map(G=>{const te=R===G.value;return t.jsxs(o.Box,{onClick:()=>q(G.value),className:`urm-export-row-card ${te?v.rowCardSelected||"":v.rowCard||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:1.5,borderRadius:x.cardRadius,border:te?`2px solid ${x.cardSelectedBorder}`:`1px solid ${x.cardBorder}`,boxShadow:te?void 0:x.cardShadow,bgcolor:te?x.cardSelectedBg:x.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:te?x.cardSelectedBorder:$(y.text.primary,.25),bgcolor:te?x.cardSelectedBg:x.cardHoverBg}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(ys,{checked:te}),t.jsx(o.Box,{sx:{color:te?x.cardSelectedColor:y.text.secondary,display:"flex"},children:G.icon}),t.jsx(o.Typography,{sx:{fontSize:"0.875rem",fontWeight:600,color:te?x.cardSelectedColor:y.text.primary},children:G.label})]}),t.jsx(o.Tooltip,{title:G.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:ge=>ge.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:y.text.secondary,"&:hover":{color:y.text.primary}},children:t.jsx(O.InfoOutlined,{sx:{fontSize:16}})})})]},G.value)})})]}),t.jsxs(o.Box,{className:`urm-export-section ${v.sectionContainer||""}`,sx:{position:"relative",border:`1.5px solid ${x.sectionBorder}`,borderRadius:"12px",p:x.sectionPadding,pt:2.25,bgcolor:x.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${v.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:x.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:x.sectionTitleColor,lineHeight:1,zIndex:1},children:"Select Columns Range"}),t.jsx(o.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:x.optionGap},children:[{value:"visible",label:"Visible columns",icon:t.jsx(O.SwapVertOutlined,{sx:{fontSize:20}}),info:`Export ${i} visible column${i!==1?"s":""}`},{value:"all",label:"All columns",icon:t.jsx(O.TableChartOutlined,{sx:{fontSize:20}}),info:`Export all ${s} columns (including hidden)`}].map(G=>{const te=T===G.value;return t.jsxs(o.Box,{onClick:()=>F(G.value),className:`urm-export-column-card ${te?v.columnCardSelected||"":v.columnCard||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:1.5,borderRadius:x.cardRadius,border:te?`2px solid ${x.cardSelectedBorder}`:`1px solid ${x.cardBorder}`,boxShadow:te?void 0:x.cardShadow,bgcolor:te?x.cardSelectedBg:x.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:te?x.cardSelectedBorder:$(y.text.primary,.25),bgcolor:te?x.cardSelectedBg:x.cardHoverBg}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(ys,{checked:te}),t.jsx(o.Box,{sx:{color:te?x.cardSelectedColor:y.text.secondary,display:"flex"},children:G.icon}),t.jsx(o.Typography,{sx:{fontSize:"0.875rem",fontWeight:600,color:te?x.cardSelectedColor:y.text.primary},children:G.label})]}),t.jsx(o.Tooltip,{title:G.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:ge=>ge.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:y.text.secondary,"&:hover":{color:y.text.primary}},children:t.jsx(O.InfoOutlined,{sx:{fontSize:16}})})})]},G.value)})})]}),t.jsxs(o.Box,{className:`urm-export-summary ${v.summaryContainer||""}`,sx:{position:"relative",border:`1.5px solid ${x.sectionBorder}`,borderRadius:"12px",p:x.sectionPadding,pt:2.25,bgcolor:x.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${v.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:x.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:x.sectionTitleColor,lineHeight:1,zIndex:1},children:"Export Summary"}),t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[{icon:t.jsx(O.InsertDriveFileOutlined,{sx:{fontSize:18,color:y.text.secondary}}),label:"Format",value:oe[E]},{icon:t.jsx(O.FormatListNumberedOutlined,{sx:{fontSize:18,color:y.text.secondary}}),label:"Rows to Export",value:X.toLocaleString()},{icon:t.jsx(O.SwapVertOutlined,{sx:{fontSize:18,color:y.text.secondary}}),label:"Columns to Export",value:String(W)},{icon:t.jsx(O.InsertDriveFileOutlined,{sx:{fontSize:18,color:y.text.secondary}}),label:"Estimated File Size",value:`~${wo(N.estimatedBytes)}`,highlight:N.hasBlockingViolation?"error.main":N.hasWarning?"warning.main":void 0}].map(({icon:G,label:te,value:ge,highlight:V})=>t.jsxs(o.Box,{className:`urm-export-summary-row ${v.summaryRow||""}`,sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[G,t.jsx(o.Typography,{className:`urm-export-summary-label ${v.summaryLabel||""}`,sx:{fontSize:"0.8125rem",color:y.text.secondary,fontWeight:500},children:te})]}),t.jsx(o.Typography,{className:`urm-export-summary-value ${v.summaryValue||""}`,sx:{fontWeight:700,fontSize:"0.8125rem",color:V??y.text.primary},children:ge})]},te))})]})]}),t.jsxs(o.Box,{className:`urm-export-footer ${v.footer||""}`,sx:{px:3,py:2,display:"flex",alignItems:"center",justifyContent:"flex-end",gap:1.5,flexShrink:0},children:[N.hasBlockingViolation&&t.jsxs(o.Box,{sx:{flex:1,display:"flex",alignItems:"center",gap:.75},children:[t.jsx(O.ErrorOutline,{sx:{fontSize:15,color:"error.main"}}),t.jsx(o.Typography,{sx:{fontSize:G=>G.typography.caption.fontSize||"0.75rem",color:"error.main",fontWeight:G=>G.typography.body2.fontWeight||500},children:"Reduce rows or columns to enable download"})]}),t.jsx(o.Button,{onClick:B,variant:"outlined",className:`urm-export-cancel-btn ${v.cancelButton||""}`,sx:{fontSize:"0.875rem",fontWeight:600,color:y.text.primary,borderColor:x.cardBorder,px:3,py:1,borderRadius:"8px",textTransform:"none","&:hover":{bgcolor:x.cardHoverBg,borderColor:$(y.text.primary,.3)}},children:"Cancel"}),t.jsxs(o.Button,{onClick:d,disabled:N.hasBlockingViolation,variant:"contained",className:`urm-export-download-btn ${v.downloadButton||""}`,startIcon:t.jsx(O.Download,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",fontWeight:600,bgcolor:x.primaryBtnBg,color:x.primaryBtnColor,px:3,py:1,borderRadius:"8px",textTransform:"none",boxShadow:`0 2px 6px ${$(y.primary.main,.25)}`,"&:hover":{bgcolor:x.primaryBtnHoverBg},"&.Mui-disabled":{bgcolor:$(y.primary.main,.4),color:x.primaryBtnColor}},children:["Download ",oe[E]]})]})]})})}function hp({warning:e,onDismiss:r}){return t.jsx(o.Box,{sx:{position:"fixed",bottom:16,right:16,zIndex:50,maxWidth:448},children:t.jsxs(o.Alert,{severity:"warning",icon:t.jsx(O.Warning,{sx:{fontSize:20}}),action:t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:"warning.main"},children:t.jsx(O.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 mp({error:e,onDismiss:r,autoDismiss:n=!0,autoDismissDelay:i=3e4}){p.useEffect(()=>{if(n){const l=setTimeout(()=>{r()},i);return()=>clearTimeout(l)}},[n,i,r]);const a=(()=>{switch(e.type){case"system":return{severity:"error",icon:t.jsx(O.Cancel,{sx:{fontSize:20}})};case"processing":return{severity:"warning",icon:t.jsx(O.Warning,{sx:{fontSize:20}})};case"ui":default:return{severity:"info",icon:t.jsx(O.InfoOutlined,{sx:{fontSize:20}})}}})(),c=bl(e);return t.jsx(o.Box,{sx:{position:"fixed",bottom:16,right:16,zIndex:50,maxWidth:448},children:t.jsxs(o.Alert,{severity:a.severity,icon:a.icon,action:t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:`${a.severity}.main`},children:t.jsx(O.Close,{sx:{fontSize:16}})}),sx:{borderLeft:4,borderColor:`${a.severity}.main`,boxShadow:3},children:[t.jsxs(o.AlertTitle,{sx:{fontWeight:l=>l.typography.h6.fontWeight||600,fontSize:l=>l.typography.subtitle2.fontSize||"0.875rem"},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 xp extends p.Component{constructor(n){super(n);Ci(this,"handleReset",()=>{this.setState({hasError:!1,error:null})});this.state={hasError:!1,error:null}}static getDerivedStateFromError(n){return{hasError:!0,error:n}}componentDidCatch(n,i){Ut.error("urm:error-boundary","Caught unhandled component error",n,i),this.props.onError&&this.props.onError(n,i)}render(){var n,i;return this.state.hasError?this.props.fallback?this.props.fallback:t.jsx(o.Paper,{sx:{bgcolor:s=>$(s.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(O.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:s=>s.typography.h6.fontWeight||600,fontSize:s=>s.typography.h6.fontSize||"1.25rem"},children:this.props.context?`${this.props.context} Error`:"Something went wrong"}),t.jsx(o.Typography,{variant:"body2",sx:{color:"error.main",mt:1},children:((n=this.state.error)==null?void 0:n.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:s=>$(s.palette.error.main,.12),p:1.5,borderRadius:1,overflow:"auto",maxHeight:170},children:(i=this.state.error)==null?void 0:i.stack}),t.jsx(o.Button,{onClick:this.handleReset,variant:"contained",color:"error",startIcon:t.jsx(O.Refresh,{sx:{fontSize:16}}),sx:{mt:2},children:"Try Again"})]})]})}):this.props.children}}function fp({feature:e}){const[r,n]=p.useState(!0);return p.useEffect(()=>{const i=setTimeout(()=>n(!1),5e3);return()=>clearTimeout(i)},[]),t.jsx(o.Collapse,{in:r,unmountOnExit:!0,children:t.jsxs(o.Alert,{severity:"warning",sx:{m:1},icon:t.jsx(O.Warning,{sx:{fontSize:20}}),action:t.jsx(o.IconButton,{size:"small",onClick:()=>n(!1),"aria-label":"dismiss",sx:{color:"warning.dark"},children:t.jsx(O.Close,{sx:{fontSize:16}})}),children:[t.jsxs(o.AlertTitle,{children:[e," temporarily unavailable"]}),"Other features continue to work normally"]})})}function Ko({children:e,feature:r,onError:n}){return t.jsx(xp,{context:r,onError:i=>{n&&n(i)},fallback:t.jsx(fp,{feature:r}),children:e})}const gp=[{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"}],yp=[{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"},{value:"pdf",label:"PDF",desc:"Print-ready PDF document"}];function bo({children:e,active:r}){return t.jsx(o.Box,{hidden:!r,sx:{pt:2.5,pb:1,display:r?"flex":"none",flexDirection:"column",gap:2.5},children:e})}function bp({open:e,onClose:r,config:n,onApply:i}){const[s,a]=p.useState(0),[c,l]=p.useState(n),u=()=>l(n),g=()=>l(gt),f=()=>{i(c),r()},m={sort:y=>l(z=>({...z,sort:{...z.sort,...y}})),filter:y=>l(z=>({...z,filter:{...z.filter,...y}})),columns:y=>l(z=>({...z,columns:{...z.columns,...y}})),grouping:y=>l(z=>({...z,grouping:{...z.grouping,...y}})),export:y=>l(z=>({...z,export:{...z.export,...y}}))},v=y=>{const z=c.filter.allowedOperators,x=z.includes(y)?z.filter(j=>j!==y):[...z,y];x.length!==0&&m.filter({allowedOperators:x})},C=y=>{const z=c.export.allowedFormats,x=z.includes(y)?z.filter(j=>j!==y):[...z,y];x.length!==0&&m.export({allowedFormats:x})},B=[{label:"Sort",icon:t.jsx(O.SwapVert,{sx:{fontSize:17}})},{label:"Filter",icon:t.jsx(O.FilterList,{sx:{fontSize:17}})},{label:"Columns",icon:t.jsx(O.ViewColumn,{sx:{fontSize:17}})},{label:"Grouping",icon:t.jsx(O.Layers,{sx:{fontSize:17}})},{label:"Export",icon:t.jsx(O.Download,{sx:{fontSize:17}})}],b=y=>JSON.stringify(c[y])===JSON.stringify(gt[y]);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,TransitionProps:{onEnter:u},PaperProps:{sx:{borderRadius:y=>ot(y),maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:y=>`0 8px 32px ${$(y.palette.common.black,.2)}`}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(o.Box,{sx:{width:32,height:32,borderRadius:"8px",bgcolor:y=>$(y.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",fontSize:"1.1rem"},children:"⚙️"}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle1",sx:{fontWeight:600,lineHeight:1.2},children:"Developer Configuration"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"Set runtime constraints · Ctrl+Shift+D"})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:"text.secondary"},children:t.jsx(O.Close,{sx:{fontSize:20}})})]}),t.jsx(o.Box,{sx:{borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:t.jsx(o.Tabs,{value:s,onChange:(y,z)=>a(z),variant:"fullWidth",sx:{minHeight:44,"& .MuiTab-root":{minHeight:44,fontSize:"0.8125rem",textTransform:"none",fontWeight:500,gap:.5}},children:B.map((y,z)=>t.jsx(o.Tab,{label:y.label,icon:y.icon,iconPosition:"start"},z))})}),t.jsxs(o.DialogContent,{sx:{overflowY:"auto",flex:1,px:3,py:0},children:[t.jsxs(bo,{active:s===0,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum sort levels"}),!b("sort")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users can sort by at most this many columns simultaneously."}),t.jsx(o.Slider,{value:c.sort.maxLevels,onChange:(y,z)=>m.sort({maxLevels:z}),min:1,max:10,step:1,marks:!0,valueLabelDisplay:"on"}),t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between"},children:[t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"1 level (single)"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"10 levels (maximum)"})]})]}),t.jsxs(o.Alert,{severity:"info",sx:{borderRadius:2,fontSize:"0.8125rem"},children:['The "Add sort column" button is hidden once users reach this limit. Default is'," ",t.jsx("strong",{children:"5"}),"."]})]}),t.jsxs(bo,{active:s===1,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum filter conditions"}),!b("filter")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users can apply at most this many simultaneous filter conditions."}),t.jsx(o.Slider,{value:c.filter.maxConditions,onChange:(y,z)=>m.filter({maxConditions:z}),min:1,max:20,step:1,marks:!0,valueLabelDisplay:"on"}),t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between"},children:[t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"1 condition"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"20 conditions"})]})]}),t.jsx(o.Divider,{}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,mb:.5},children:"Allowed filter operators"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1.5},children:"Only checked operators appear in the filter type dropdown. At least one must remain checked."}),["Text","Numeric","Boolean","Null checks"].map(y=>t.jsxs(o.Box,{sx:{mb:1.5},children:[t.jsx(o.Typography,{sx:{fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"text.secondary",fontSize:"0.6875rem",display:"block",mb:.5},children:y}),t.jsx(o.FormGroup,{row:!0,sx:{gap:.5},children:gp.filter(z=>z.group===y).map(z=>t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{size:"small",checked:c.filter.allowedOperators.includes(z.value),onChange:()=>v(z.value)}),label:t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem"},children:z.label}),sx:{mr:1.5}},z.value))})]},y))]})]}),t.jsxs(bo,{active:s===2,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum visible columns"}),!b("columns")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users cannot make more than this many columns visible simultaneously."}),t.jsx(o.Slider,{value:c.columns.maxVisible,onChange:(y,z)=>m.columns({maxVisible:z}),min:1,max:50,step:1,valueLabelDisplay:"on"})]}),t.jsx(o.Divider,{}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,mb:.5},children:"Column width range (px)"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users cannot resize columns outside this minimum / maximum range."}),t.jsxs(o.Box,{sx:{display:"flex",gap:2},children:[t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Minimum width"}),t.jsx(o.Slider,{value:c.columns.minColumnWidth,onChange:(y,z)=>m.columns({minColumnWidth:z}),min:40,max:400,step:10,valueLabelDisplay:"on",valueLabelFormat:y=>`${y}px`})]}),t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Maximum width"}),t.jsx(o.Slider,{value:c.columns.maxColumnWidth,onChange:(y,z)=>m.columns({maxColumnWidth:z}),min:100,max:2e3,step:50,valueLabelDisplay:"on",valueLabelFormat:y=>`${y}px`})]})]})]})]}),t.jsxs(bo,{active:s===3,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum group levels"}),!b("grouping")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Box,{sx:{display:"flex",gap:1.5,mb:2},children:[1,2,3].map(y=>t.jsxs(o.Box,{onClick:()=>m.grouping({maxLevels:y}),sx:{flex:1,py:2.5,borderRadius:"10px",border:"2px solid",cursor:"pointer",textAlign:"center",transition:"all 0.15s ease",borderColor:c.grouping.maxLevels===y?"primary.main":"divider",bgcolor:c.grouping.maxLevels===y?z=>$(z.palette.primary.main,.06):"transparent","&:hover":{borderColor:"primary.light",bgcolor:z=>$(z.palette.primary.main,.04)}},children:[t.jsx(o.Typography,{variant:"h5",sx:{fontWeight:700,color:c.grouping.maxLevels===y?"primary.main":"text.secondary"},children:y}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:["Single","Double","Triple"][y-1]})]},y))}),t.jsxs(o.FormGroup,{row:!0,sx:{gap:2},children:[t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{checked:c.grouping.allowNested,onChange:y=>m.grouping({allowNested:y.target.checked})}),label:t.jsx(o.Typography,{variant:"body2",children:"Allow nested groups"})}),t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{checked:c.grouping.allowCollapse,onChange:y=>m.grouping({allowCollapse:y.target.checked})}),label:t.jsx(o.Typography,{variant:"body2",children:"Allow collapse / expand"})})]})]}),t.jsx(o.Alert,{severity:"info",sx:{borderRadius:2,fontSize:"0.8125rem"},children:'The "Add group level" button is hidden when users reach the configured limit.'})]}),t.jsx(bo,{active:s===4,children:t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Allowed export formats"}),!b("export")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1.5},children:"Only checked formats appear in the Export dialog and the bulk export action. At least one must remain checked."}),t.jsx(o.FormGroup,{sx:{gap:1},children:yp.map(y=>t.jsxs(o.Box,{onClick:()=>C(y.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:c.export.allowedFormats.includes(y.value)?"primary.main":"divider",bgcolor:c.export.allowedFormats.includes(y.value)?z=>$(z.palette.primary.main,.04):"transparent","&:hover":{borderColor:"primary.light"}},children:[t.jsx(o.Checkbox,{size:"small",checked:c.export.allowedFormats.includes(y.value),onChange:()=>C(y.value),onClick:z=>z.stopPropagation()}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500},children:y.label}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:y.desc})]})]},y.value))})]})})]}),t.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid",borderColor:"divider",bgcolor:y=>$(y.palette.action.hover,.4),justifyContent:"space-between",flexShrink:0},children:[t.jsx(o.Button,{startIcon:t.jsx(O.RestartAlt,{sx:{fontSize:18}}),onClick:g,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary","&:hover":{color:"text.primary",bgcolor:y=>$(y.palette.text.primary,.06)}},children:"Reset to defaults"}),t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Button,{onClick:r,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px"},children:"Cancel"}),t.jsx(o.Button,{onClick:f,size:"small",variant:"contained",sx:{fontSize:"0.875rem",px:2.5,borderRadius:"18px"},children:"Apply"})]})]})]})}const vp=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Sp={1:"1st",2:"2nd",3:"3rd",4:"4th",5:"5th",6:"6th",7:"7th",8:"8th",9:"9th",10:"10th",11:"11th",12:"12th",13:"13th",14:"14th",15:"15th",16:"16th",17:"17th",18:"18th",19:"19th",20:"20th",21:"21st",22:"22nd",23:"23rd",24:"24th",25:"25th",26:"26th",27:"27th",28:"28th"};function Qo(e,r,n,i,s=new Date){const[a,c]=r.split(":").map(Number),l=new Date(s);if(l.setSeconds(0,0),l.setHours(a,c,0,0),e==="daily")return l<=s&&l.setDate(l.getDate()+1),l.toISOString();if(e==="weekly"){const u=n??1,g=l.getDay();let f=u-g;return f<0&&(f+=7),f===0&&l<=s&&(f=7),l.setDate(l.getDate()+f),l.toISOString()}if(e==="monthly"){const u=Math.min(i??1,28);return l.setDate(u),l<=s&&(l.setMonth(l.getMonth()+1),l.setDate(u)),l.toISOString()}return l.toISOString()}function Cp(e){const r=ta(e.time);return e.frequency==="daily"?`Daily at ${r}`:e.frequency==="weekly"?`Every ${vp[e.dayOfWeek??1]} at ${r}`:e.frequency==="monthly"?`Monthly on the ${Sp[e.dayOfMonth??1]??`${e.dayOfMonth}th`} at ${r}`:r}function ta(e){const[r,n]=e.split(":").map(Number),i=r>=12?"PM":"AM";return`${r%12||12}:${String(n).padStart(2,"0")} ${i}`}function wp(e){const r=new Date(e).getTime()-Date.now();if(r<=0)return"now";const n=Math.floor(r/1e3),i=Math.floor(n/86400),s=Math.floor(n%86400/3600),a=Math.floor(n%3600/60);return i>0?`in ${i}d ${s}h`:s>0?`in ${s}h ${a}m`:a>0?`in ${a}m`:"in less than a minute"}function jp(e){const r=new Date(e),n=new Date,i=r.toDateString()===n.toDateString(),s=ta(`${String(r.getHours()).padStart(2,"0")}:${String(r.getMinutes()).padStart(2,"0")}`);return i?`Today at ${s}`:`${r.toLocaleDateString("en-US",{month:"short",day:"numeric"})} at ${s}`}function ra(e){return`urm_schedules_${e}`}function oa(e){try{const r=localStorage.getItem(ra(e));return r?JSON.parse(r).map(i=>({...i,runCount:typeof i.runCount=="number"?i.runCount:0,isActive:typeof i.isActive=="boolean"?i.isActive:!0,createdAt:i.createdAt||new Date().toISOString()})):[]}catch{return[]}}function na(e,r){try{localStorage.setItem(ra(e),JSON.stringify(r))}catch{}}const kp=[{value:0,label:"Sunday"},{value:1,label:"Monday"},{value:2,label:"Tuesday"},{value:3,label:"Wednesday"},{value:4,label:"Thursday"},{value:5,label:"Friday"},{value:6,label:"Saturday"}],zp=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,ia={name:"",frequency:"daily",dayOfWeek:1,dayOfMonth:1,time:"09:00",format:"pdf",scope:"all",email:""},Ir={"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:"8px"},"& .MuiInputLabel-root":{fontSize:"0.875rem"},"& .MuiFormHelperText-root":{fontSize:"0.75rem",mx:.5},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}}};function Tp({initial:e=ia,isEditing:r=!1,onSave:n,onBack:i}){const[s,a]=p.useState(e),[c,l]=p.useState(!1),[u,g]=p.useState(!1),f=(C,B)=>a(b=>({...b,[C]:B})),m=s.email.trim().length>0&&!zp.test(s.email.trim()),v=s.name.trim().length>0&&/^\d{2}:\d{2}$/.test(s.time)&&(s.frequency!=="monthly"||s.dayOfMonth>=1&&s.dayOfMonth<=28)&&!m;return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,mb:.5},children:[t.jsx(o.IconButton,{size:"small",onClick:i,sx:{color:"text.secondary",ml:-.75,"&:hover":{bgcolor:C=>$(C.palette.text.primary,.06)}},children:t.jsx(O.ArrowBack,{sx:{fontSize:18}})}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:C=>C.typography.body2.fontWeight||600,fontSize:C=>C.typography.body2.fontSize||"0.875rem"},children:r?"Edit schedule":"New schedule"})]}),t.jsx(o.TextField,{label:"Schedule name *",size:"small",fullWidth:!0,value:s.name,onChange:C=>{f("name",C.target.value),c&&C.target.value.trim()&&l(!1)},onBlur:()=>l(!0),placeholder:"e.g. Weekly Sales Report",autoFocus:!0,inputProps:{maxLength:50},error:c&&!s.name.trim(),helperText:c&&!s.name.trim()?"Schedule name is required":`${s.name.length}/50`,sx:Ir}),t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:Ir,children:[t.jsx(o.InputLabel,{children:"Frequency"}),t.jsxs(o.Select,{value:s.frequency,label:"Frequency",onChange:C=>f("frequency",C.target.value),children:[t.jsx(o.MenuItem,{value:"daily",children:"Daily"}),t.jsx(o.MenuItem,{value:"weekly",children:"Weekly"}),t.jsx(o.MenuItem,{value:"monthly",children:"Monthly"})]})]}),s.frequency==="weekly"&&t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:Ir,children:[t.jsx(o.InputLabel,{children:"Day of week"}),t.jsx(o.Select,{value:s.dayOfWeek,label:"Day of week",onChange:C=>f("dayOfWeek",Number(C.target.value)),children:kp.map(C=>t.jsx(o.MenuItem,{value:C.value,children:C.label},C.value))})]}),s.frequency==="monthly"&&t.jsx(o.TextField,{label:"Day of month (1–28)",size:"small",type:"number",fullWidth:!0,value:s.dayOfMonth,onChange:C=>f("dayOfMonth",Number(C.target.value)),inputProps:{min:1,max:28},error:s.dayOfMonth<1||s.dayOfMonth>28,helperText:s.dayOfMonth<1||s.dayOfMonth>28?"Day must be between 1 and 28":"Max 28 — works safely across all months including February",sx:Ir}),t.jsx(o.TextField,{label:"Time",size:"small",type:"time",fullWidth:!0,value:s.time,onChange:C=>f("time",C.target.value),InputLabelProps:{shrink:!0},helperText:"24-hour format · Tab must be open for the schedule to fire",sx:Ir}),t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:Ir,children:[t.jsx(o.InputLabel,{children:"Export format"}),t.jsxs(o.Select,{value:s.format,label:"Export format",onChange:C=>f("format",C.target.value),children:[t.jsx(o.MenuItem,{value:"pdf",children:"PDF — Print-ready document"}),t.jsx(o.MenuItem,{value:"csv",children:"CSV — Comma-separated values"}),t.jsx(o.MenuItem,{value:"excel",children:"Excel (.xlsx) — Native format"}),t.jsx(o.MenuItem,{value:"json",children:"JSON — Structured data"})]})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontWeight:500,color:"text.secondary",display:"block",mb:.75},children:"Data scope"}),t.jsxs(o.RadioGroup,{row:!0,value:s.scope,onChange:C=>f("scope",C.target.value),sx:{gap:2},children:[t.jsx(o.FormControlLabel,{value:"all",control:t.jsx(o.Radio,{size:"small"}),label:t.jsx(o.Typography,{variant:"body2",children:"All rows"})}),t.jsx(o.FormControlLabel,{value:"visible",control:t.jsx(o.Radio,{size:"small"}),label:t.jsx(o.Typography,{variant:"body2",children:"Filtered rows only"})})]})]}),t.jsxs(o.Box,{children:[t.jsx(o.TextField,{label:"Email reminder (optional)",size:"small",fullWidth:!0,type:"email",value:s.email,onChange:C=>f("email",C.target.value),onBlur:()=>g(!0),placeholder:"user@company.com",error:u&&m,helperText:u&&m?"Enter a valid email address":void 0,InputProps:{startAdornment:t.jsx(O.Email,{sx:{fontSize:15,color:"text.disabled",mr:1}})},sx:Ir}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:.5,mt:.5,px:.5},children:[t.jsx(O.InfoOutlined,{sx:{fontSize:12,color:"text.disabled",mt:.2,flexShrink:0}}),t.jsx(o.Typography,{variant:"caption",color:"text.disabled",sx:{lineHeight:1.5},children:"Opens your device's email app when the schedule fires. Requires a default mail app (e.g. Outlook, Mail) on this device."})]})]}),t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"flex-end",gap:1,pt:.5},children:[t.jsx(o.Button,{onClick:i,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px","&:hover":{bgcolor:C=>$(C.palette.text.primary,.06)}},children:"Cancel"}),t.jsx(o.Button,{onClick:()=>v&&n(s),disabled:!v,size:"small",variant:"contained",sx:{fontSize:"0.875rem",px:2.5,borderRadius:"18px"},children:r?"Save changes":"Create schedule"})]})]})}function Bp({scheduleName:e,onConfirm:r,onCancel:n}){return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:i=>({borderRadius:_o(i),...ue(i).paper})},children:[t.jsxs(o.DialogContent,{sx:{pt:3,pb:2,px:3},children:[t.jsx(o.Box,{sx:{width:44,height:44,borderRadius:"12px",bgcolor:i=>$(i.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx(O.WarningAmberOutlined,{sx:{fontSize:22,color:"error.main"}})}),t.jsx(o.Typography,{sx:{fontSize:i=>i.typography.body1.fontSize||"0.9375rem",fontWeight:i=>i.typography.h6.fontWeight||600,color:"text.primary",mb:1},children:"Delete Schedule"}),t.jsxs(o.Typography,{sx:{fontSize:i=>i.typography.body2.fontSize||"0.8125rem",color:"text.secondary",lineHeight:1.65},children:["Are you sure you want to delete"," ",t.jsxs(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:['"',e,'"']}),"? This action cannot be undone."]})]}),t.jsx(o.Divider,{}),t.jsxs(o.DialogActions,{sx:{px:2.5,py:1.5,gap:1},children:[t.jsx(o.Button,{onClick:n,variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",borderRadius:i=>`${i.shape.borderRadius}px`,"&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),t.jsx(o.Button,{onClick:r,variant:"contained",color:"error",sx:{fontSize:"0.8125rem",borderRadius:i=>`${i.shape.borderRadius}px`,px:2},children:"Delete"})]})]})}function Ip({schedule:e,tick:r,onToggle:n,onRunNow:i,onEdit:s,onDelete:a}){const c=e.isActive;return t.jsxs(o.Box,{sx:{border:"1px solid",borderColor:c?"primary.main":"divider",borderRadius:"10px",p:1.75,bgcolor:c?l=>$(l.palette.primary.main,.025):"background.paper",transition:"border-color 0.15s ease, background-color 0.15s ease"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,flex:1,minWidth:0,color:c?"text.primary":"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),t.jsx(o.Chip,{label:c?"Active":"Paused",size:"small",sx:{height:18,fontSize:"0.6875rem",fontWeight:600,flexShrink:0,bgcolor:c?l=>$(l.palette.success.main,.1):l=>$(l.palette.text.primary,.06),color:c?"success.dark":"text.secondary"}})]}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary",display:"block",mb:1},children:Cp(e)}),t.jsxs(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:.5,mb:1},children:[t.jsx(o.Chip,{label:e.format.toUpperCase(),size:"small",sx:{height:20,fontSize:"0.6875rem",fontWeight:500,bgcolor:l=>$(l.palette.primary.main,.08),color:"primary.main"}}),t.jsx(o.Chip,{label:e.scope==="all"?"All rows":"Filtered rows",size:"small",sx:{height:20,fontSize:"0.6875rem",bgcolor:l=>$(l.palette.text.primary,.06),color:"text.secondary"}}),e.email&&t.jsx(o.Chip,{icon:t.jsx(O.Email,{sx:{fontSize:11}}),label:e.email,size:"small",sx:{height:20,fontSize:"0.6875rem",maxWidth:220,bgcolor:l=>$(l.palette.text.primary,.06),color:"text.secondary","& .MuiChip-label":{overflow:"hidden",textOverflow:"ellipsis"}}})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:1},children:[t.jsxs(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1.5,alignItems:"center"},children:[c&&t.jsxs(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:500},children:["Next: ",wp(e.nextRunAt)]}),e.lastRunAt?t.jsxs(o.Typography,{variant:"caption",color:"text.secondary",children:["Last: ",jp(e.lastRunAt)," · ",e.runCount," run",e.runCount!==1?"s":""]}):t.jsx(o.Typography,{variant:"caption",color:"text.disabled",children:"Never run"})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.25,flexShrink:0},children:[t.jsx(o.Tooltip,{title:"Edit",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:()=>s(e),sx:{color:"text.secondary","&:hover":{color:"primary.main",bgcolor:l=>$(l.palette.primary.main,.08)}},children:t.jsx(O.Edit,{sx:{fontSize:15}})})}),t.jsx(o.Tooltip,{title:c?"Pause":"Resume",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:()=>n(e.id),sx:{color:c?"warning.main":"success.main","&:hover":{bgcolor:c?l=>$(l.palette.warning.main,.08):l=>$(l.palette.success.main,.08)}},children:c?t.jsx(O.Pause,{sx:{fontSize:15}}):t.jsx(O.PlayArrow,{sx:{fontSize:15}})})}),t.jsx(o.Tooltip,{title:"Export now",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:()=>i(e),sx:{color:"primary.main","&:hover":{bgcolor:l=>$(l.palette.primary.main,.08)}},children:t.jsx(O.Download,{sx:{fontSize:15}})})}),t.jsx(o.Tooltip,{title:"Delete",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:()=>a(e.id),sx:{color:"error.main","&:hover":{bgcolor:l=>$(l.palette.error.main,.08)}},children:t.jsx(O.Delete,{sx:{fontSize:15}})})})]})]})]})}function Ep({open:e,onClose:r,reportId:n,reportName:i,onRunNow:s,schedulerConfig:a}){const l=((a==null?void 0:a.mode)??"local")==="api",[u,g]=p.useState([]),f=l?(a==null?void 0:a.schedules)??[]:u,[m,v]=p.useState({type:"list"}),[C,B]=p.useState(0),[b,y]=p.useState(null);p.useEffect(()=>{e&&(l||g(oa(n)),v({type:"list"}))},[e,n,l]),p.useEffect(()=>{if(!e)return;const W=setInterval(()=>B(h=>h+1),3e4);return()=>clearInterval(W)},[e]);const z=p.useCallback(W=>{g(W),na(n,W)},[n]),x=W=>{var N;const h=Qo(W.frequency,W.time,W.dayOfWeek,W.dayOfMonth),I={id:`sched-${Date.now()}`,reportId:n,name:W.name.trim(),frequency:W.frequency,dayOfWeek:W.frequency==="weekly"?W.dayOfWeek:void 0,dayOfMonth:W.frequency==="monthly"?W.dayOfMonth:void 0,time:W.time,format:W.format,scope:W.scope,email:W.email.trim()||void 0,isActive:!0,createdAt:new Date().toISOString(),nextRunAt:h,runCount:0};l?(N=a==null?void 0:a.onScheduleCreate)==null||N.call(a,I):z([...f,I]),v({type:"list"})},j=W=>{var d;if(m.type!=="edit")return;const h=m.schedule,I=Qo(W.frequency,W.time,W.dayOfWeek,W.dayOfMonth),N={...h,name:W.name.trim(),frequency:W.frequency,dayOfWeek:W.frequency==="weekly"?W.dayOfWeek:void 0,dayOfMonth:W.frequency==="monthly"?W.dayOfMonth:void 0,time:W.time,format:W.format,scope:W.scope,email:W.email.trim()||void 0,nextRunAt:I};l?(d=a==null?void 0:a.onScheduleUpdate)==null||d.call(a,N):z(f.map(oe=>oe.id===h.id?N:oe)),v({type:"list"})},E=W=>{var oe;const h=f.find(G=>G.id===W);if(!h)return;const I=!h.isActive,N=I?Qo(h.frequency,h.time,h.dayOfWeek,h.dayOfMonth):h.nextRunAt,d={...h,isActive:I,nextRunAt:N};l?(oe=a==null?void 0:a.onScheduleToggle)==null||oe.call(a,W,I):z(f.map(G=>G.id===W?d:G))},S=W=>{if(s(W),!l){const h=new Date().toISOString();z(f.map(I=>I.id===W.id?{...I,lastRunAt:h,runCount:I.runCount+1}:I))}},R=W=>{const h=f.find(I=>I.id===W)??null;y(h)},q=()=>{var W;b&&(l?(W=a==null?void 0:a.onScheduleDelete)==null||W.call(a,b.id):z(f.filter(h=>h.id!==b.id)),y(null))},T=W=>({name:W.name,frequency:W.frequency,dayOfWeek:W.dayOfWeek??1,dayOfMonth:W.dayOfMonth??1,time:W.time,format:W.format,scope:W.scope,email:W.email??""}),F=m.type!=="list",X=f.filter(W=>W.isActive).length;return t.jsxs(t.Fragment,{children:[t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,disableEscapeKeyDown:F,PaperProps:{sx:W=>({borderRadius:ot(W),maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",...ue(W).paper})},children:[t.jsxs(o.DialogTitle,{sx:W=>({display:"flex",alignItems:"center",justifyContent:"space-between",py:1.5,px:2.5,flexShrink:0,minHeight:0,...ue(W).header}),children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[t.jsx(o.Box,{sx:{width:30,height:30,borderRadius:"7px",bgcolor:W=>$(W.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(O.Schedule,{sx:{fontSize:17,color:"primary.main"}})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"baseline",gap:.75},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:W=>W.typography.h6.fontWeight||600,fontSize:W=>W.typography.subtitle2.fontSize||"0.875rem",lineHeight:1},children:"Scheduled Reports"}),t.jsx(Dr,{content:_r.schedule,isDev:process.env.NODE_ENV==="development"})]}),t.jsxs(o.Typography,{variant:"caption",color:"text.secondary",sx:{lineHeight:1},children:["· ",i]})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:"text.secondary","&:hover":{bgcolor:W=>$(W.palette.text.primary,.06)}},children:t.jsx(O.Close,{sx:{fontSize:18}})})]}),t.jsxs(o.DialogContent,{sx:{overflowY:"auto",flex:1,px:2.5,py:2},children:[F&&t.jsx(Tp,{initial:m.type==="edit"?T(m.schedule):ia,isEditing:m.type==="edit",onSave:m.type==="edit"?j:x,onBack:()=>v({type:"list"})}),m.type==="list"&&t.jsxs(t.Fragment,{children:[t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1.75,pt:1.5},children:[t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:f.length===0?"No schedules yet":`${X} of ${f.length} active`}),t.jsx(o.Button,{startIcon:t.jsx(O.Add,{sx:{fontSize:15}}),size:"small",variant:"contained",onClick:()=>v({type:"create"}),sx:{fontSize:"0.8125rem",borderRadius:"18px",px:1.75,py:.625},children:"New schedule"})]}),f.length===0?t.jsxs(o.Box,{sx:{border:"1.5px dashed",borderColor:"divider",borderRadius:"10px",py:5,px:2,textAlign:"center"},children:[t.jsx(O.NotificationsActive,{sx:{fontSize:30,color:"text.disabled",mb:1.25,display:"block",mx:"auto"}}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:W=>W.typography.body2.fontWeight||500,fontSize:W=>W.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"No scheduled reports yet"}),t.jsx(o.Typography,{variant:"caption",color:"text.disabled",sx:{display:"block",mt:.5},children:'Use "New schedule" above to set up automatic exports'})]}):t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:f.map(W=>t.jsx(Ip,{schedule:W,tick:C,onToggle:E,onRunNow:S,onEdit:h=>v({type:"edit",schedule:h}),onDelete:R},W.id))})]})]}),m.type==="list"&&t.jsxs(o.DialogActions,{sx:{px:2.5,py:1.25,borderTop:"1px solid",borderColor:"divider",flexShrink:0,display:"flex",alignItems:"center",gap:1},children:[t.jsxs(o.Box,{sx:{flex:1,display:"flex",alignItems:"center",gap:.75,px:1.25,py:.75,borderRadius:"8px",bgcolor:W=>$(W.palette.warning.main,.06),border:"1px solid",borderColor:W=>$(W.palette.warning.main,.2)},children:[t.jsx(O.Schedule,{sx:{fontSize:13,color:"warning.main",flexShrink:0}}),t.jsx(o.Typography,{variant:"caption",sx:{color:"warning.dark",lineHeight:1.1},children:"Schedules require this browser tab to remain open."})]}),t.jsx(o.Button,{onClick:r,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px",flexShrink:0,"&:hover":{bgcolor:W=>$(W.palette.text.primary,.06)}},children:"Close"})]})]}),b&&t.jsx(Bp,{scheduleName:b.name,onConfirm:q,onCancel:()=>y(null)})]})}const Dp=6e4;function _p({reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:a,columnVisibility:c,columnOrder:l,filters:u,sortStack:g,onFired:f,schedulerConfig:m}){const v=(m==null?void 0:m.mode)??"local",C=p.useRef({reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:a,columnVisibility:c,columnOrder:l,filters:u,sortStack:g,onFired:f,schedulerConfig:m,schedulerMode:v});p.useEffect(()=>{C.current={reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:a,columnVisibility:c,columnOrder:l,filters:u,sortStack:g,onFired:f,schedulerConfig:m,schedulerMode:v}});const B=p.useCallback(b=>{var W,h,I,N,d;const{reportName:y,uploadedData:z,processedData:x,schema:j,activeView:E,columnVisibility:S,columnOrder:R,filters:q,sortStack:T,schedulerConfig:F,schedulerMode:X}=C.current;try{const oe=b.scope==="all"?z:x;if(X==="api"){const ge=(R.length>0?R:j.map(K=>K.name)).filter(K=>S[K]!==!1),V={schedule:b,triggeredAt:new Date().toISOString(),rows:oe,columns:ge,format:b.format,reportName:y};(W=F==null?void 0:F.onScheduleFire)==null||W.call(F,V),(I=(h=C.current).onFired)==null||I.call(h,b);return}const G=Zo(oe,j,q,T,E,S,R),te=`${b.name}_scheduled`;switch(b.format){case"csv":en(G,te,{scope:b.scope});break;case"excel":tn(G,te,{scope:b.scope});break;case"json":rn(G,te,{scope:b.scope});break;case"pdf":hi(G,te,{scope:b.scope});break}if(F!=null&&F.onScheduleFire){const ge=(R.length>0?R:j.map(V=>V.name)).filter(V=>S[V]!==!1);F.onScheduleFire({schedule:b,triggeredAt:new Date().toISOString(),rows:oe,columns:ge,format:b.format,reportName:y})}if(b.email){const ge=encodeURIComponent(`Scheduled Report: ${b.name}`),V=encodeURIComponent(`Your scheduled report "${b.name}" has been generated.
191
+ ]`})})]}),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:i=>i.typography.body2.fontWeight||500,fontSize:i=>i.typography.body2.fontSize||"0.875rem",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:i=>i.typography.body2.fontWeight||500,fontSize:i=>i.typography.body2.fontSize||"0.875rem",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:i=>i.typography.body2.fontWeight||500,fontSize:i=>i.typography.body2.fontSize||"0.875rem",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:i=>i.typography.body2.fontWeight||500,fontSize:i=>i.typography.body2.fontSize||"0.875rem",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 divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:t.jsx(o.Button,{onClick:r,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",px:3,py:.875,minHeight:36,borderRadius:i=>`${i.shape.borderRadius}px`,boxShadow:i=>be(i,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:i=>be(i,"hoverButton")},"&:active":{boxShadow:i=>be(i,"pressedButton"),transform:"translateY(1px)"}},children:"Got it"})})]}):null}function ru({onFileUpload:e,onError:r,isUploading:n,jsonGuideContent:i}){const[s,a]=p.useState(!1),[c,l]=p.useState(""),[u,g]=p.useState(!1),x=p.useRef(null),f=async h=>{if(!h.name.endsWith(".json")){r("Only .json files are allowed");return}const z=10*1024*1024;if(h.size>z){r("File size exceeds 10MB limit");return}l(h.name);try{const I=await h.text();let b;try{b=JSON.parse(I)}catch{r("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(b)){r("JSON must be an array of objects");return}if(b.length===0){r("No data rows found in JSON file");return}e(b)}catch{r("Network error — please try again")}finally{l("")}},S=h=>{h.preventDefault(),a(!0)},C=h=>{h.preventDefault(),a(!1)},B=h=>{h.preventDefault(),a(!1);const z=h.dataTransfer.files[0];z&&f(z)},v=()=>{var h;(h=x.current)==null||h.click()},m=h=>{var I;const z=(I=h.target.files)==null?void 0:I[0];z&&f(z)},T=h=>{h.stopPropagation(),g(!0)};return t.jsxs(t.Fragment,{children:[t.jsxs(o.Box,{onDragOver:S,onDragLeave:C,onDrop:B,onPaste:h=>h.preventDefault(),onClick:v,sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderStyle:"dashed",borderColor:s?"primary.main":"divider",bgcolor:s?h=>_(h.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:s?"primary.main":"text.secondary"}},children:[t.jsx(o.Box,{component:"input",ref:x,type:"file",accept:".json",onChange:m,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:h=>h.typography.body2.fontWeight||500,fontSize:h=>h.typography.body2.fontSize||"0.875rem",mb:.5},children:"Uploading..."}),c&&t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:c})]}):t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:h=>_(h.palette.primary.main,.12),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx($.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($.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(Js,{isOpen:u,onClose:()=>g(!1),content:i})]})}function ou({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:i=>i.typography.h6.fontWeight||600,fontSize:i=>i.typography.h6.fontSize||"1.25rem",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:i=>i.typography.h6.fontWeight||600,fontSize:i=>i.typography.subtitle2.fontSize||"0.875rem"},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?s=>_(s.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($.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 nu({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=>_(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=>_(n.palette.error.main,.3),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx($.ErrorOutline,{color:"error",sx:{fontSize:32}})}),t.jsx(o.Typography,{variant:"h6",color:"error.main",sx:{fontWeight:n=>n.typography.h6.fontWeight||600,fontSize:n=>n.typography.h6.fontSize||"1.25rem",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($.Upload,{sx:{fontSize:16}}),onClick:r,sx:{fontWeight:500},children:"Try Again"})]})}function Ks({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=>_(i.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:3},children:t.jsx($.Description,{sx:{fontSize:36,color:"primary.main"}})}),t.jsx(o.Typography,{variant:"h5",sx:{fontWeight:i=>i.typography.h5.fontWeight||500,mb:1,color:i=>i.typography.h5.color||"text.primary",fontSize:i=>i.typography.h5.fontSize||"1.125rem"},children:e}),t.jsx(o.Typography,{variant:"body1",sx:{textAlign:"center",maxWidth:520,color:"text.secondary",fontSize:i=>i.typography.body2.fontSize||"0.875rem",lineHeight:1.5},children:r})]})}function iu({value:e,onChange:r,searchHistory:n,onAddToHistory:i,onToggleFavourite:s,onDeleteHistory:a,disabled:c}){const[l,u]=p.useState(!1),[g,x]=p.useState(!1),[f,S]=p.useState(-1),C=p.useRef(null),B=p.useRef(null);p.useEffect(()=>{function E(G){C.current&&!C.current.contains(G.target)&&(u(!1),x(!1))}return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[]);const v=p.useCallback(()=>{x(!0),S(-1),n.length>0&&u(!0)},[n.length]),m=p.useCallback(E=>{r(E),S(-1)},[r]),T=p.useCallback(E=>{var G;r(E),i(E),u(!1),(G=B.current)==null||G.blur()},[r,i]),h=p.useCallback(E=>{S(-1),T(E)},[T]),z=p.useCallback(E=>{var G;E.key==="Enter"?f>=0&&f<n.length?(E.preventDefault(),h(n[f].query)):e.trim()&&T(e.trim()):E.key==="Escape"?(u(!1),S(-1),(G=B.current)==null||G.blur()):E.key==="ArrowDown"?(E.preventDefault(),n.length>0&&(l||u(!0),S(Z=>Z<n.length-1?Z+1:Z))):E.key==="ArrowUp"&&(E.preventDefault(),S(Z=>Z>0?Z-1:-1))},[f,n,e,l,h,T]),I=p.useCallback(()=>{var E;r(""),(E=B.current)==null||E.focus()},[r]),b=p.useMemo(()=>n.filter(E=>E.isFavourite),[n]),R=p.useMemo(()=>n.filter(E=>!E.isFavourite),[n]),H=l&&n.length>0;return t.jsxs(o.Box,{sx:{position:"relative",width:240},ref:C,children:[t.jsx(o.TextField,{inputRef:B,size:"small",fullWidth:!0,value:e,onChange:E=>m(E.target.value),onFocus:v,onKeyDown:z,placeholder:"Search data...",disabled:c,sx:{"& .MuiOutlinedInput-root":{borderRadius:"20px",fontSize:"0.875rem",bgcolor:"background.paper",height:"36px","& fieldset":{borderColor:E=>_(E.palette.text.primary,.3),transition:"all 0.15s ease"},"&:hover":{bgcolor:"action.hover"},"&:hover fieldset":{borderColor:E=>_(E.palette.text.primary,.5)},"&.Mui-focused":{bgcolor:"background.paper"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}},"& .MuiOutlinedInput-input":{py:"6px",px:"8px",color:"text.primary"}},InputProps:{startAdornment:t.jsx(o.InputAdornment,{position:"start",sx:{ml:.5},children:t.jsx($.Search,{sx:{fontSize:18,color:"text.secondary"}})}),endAdornment:e?t.jsx(o.InputAdornment,{position:"end",children:t.jsx(o.IconButton,{size:"small",onClick:I,edge:"end",sx:{mr:-.5},children:t.jsx($.Close,{sx:{fontSize:16}})})}):null}}),H&&t.jsxs(o.Paper,{sx:{position:"absolute",zIndex:50,mt:.5,width:"100%",maxHeight:384,overflowY:"auto"},elevation:3,children:[b.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:E=>E.typography.caption.fontWeight||600,fontSize:E=>E.typography.caption.fontSize||"0.75rem",textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Favourite Searches"}),b.map((E,G)=>t.jsx(us,{entry:E,isSelected:f===G,onClick:()=>h(E.query),onToggleFavourite:()=>s(E.query),onDelete:()=>a(E.query)},`fav-${E.query}`))]}),R.length>0&&t.jsxs(o.Box,{sx:{py:1},children:[b.length>0&&t.jsx(o.Divider,{}),t.jsx(o.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:E=>E.typography.caption.fontWeight||600,fontSize:E=>E.typography.caption.fontSize||"0.75rem",textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Recent Searches"}),R.map((E,G)=>{const Z=b.length+G;return t.jsx(us,{entry:E,isSelected:f===Z,onClick:()=>h(E.query),onToggleFavourite:()=>s(E.query),onDelete:()=>a(E.query)},`recent-${E.query}`)})]})]})]})}const us=p.memo(function({entry:r,isSelected:n,onClick:i,onToggleFavourite:s,onDelete:a}){const c=p.useCallback(u=>{u.stopPropagation(),s()},[s]),l=p.useCallback(u=>{u.stopPropagation(),a()},[a]);return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:1.5,py:1,cursor:"pointer",bgcolor:n?u=>_(u.palette.primary.main,.12):"transparent","&:hover":{bgcolor:n?u=>_(u.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($.Star,{sx:{fontSize:14,color:"warning.light"}}):t.jsx($.StarBorder,{sx:{fontSize:14,color:"action.disabled"}})}),t.jsx(o.IconButton,{size:"small",onClick:l,title:"Delete from history",sx:{p:.5,"&:hover":{color:"error.main"}},children:t.jsx($.Delete,{sx:{fontSize:14,opacity:.5}})})]})]})});function su({views:e,activeViewId:r,isDirty:n,onSelectView:i,onCreateView:s,onToggleDefault:a,onToggleFavorite:c,onRestoreView:l,onPermanentDelete:u,onEditView:g,onCloneView:x,onCopyLink:f,onDeleteView:S,onPromoteToGlobal:C,onSetDefaultForAllUsers:B,isReadOnly:v,isAdmin:m=!1,hideViewMenuActions:T}){const h=pt(),[z,I]=p.useState(!1),[b,R]=p.useState(!1),[H,E]=p.useState({top:0,left:0}),[G,Z]=p.useState(null),[O,y]=p.useState(null),w=p.useRef(null),P=p.useRef(null),te=e.find(U=>U.id===r),d=te==null?void 0:te.isDefault,J=(U,ne)=>U.name.localeCompare(ne.name),re=e.filter(U=>U.scope==="global"&&!U.isDeleted).sort(J),Se=e.filter(U=>U.scope!=="global"&&!U.isDeleted).sort(J),F=e.filter(U=>U.isFavorite&&!U.isDeleted).sort(J),X=e.filter(U=>U.isDeleted);p.useEffect(()=>{if(z&&P.current){const U=P.current.getBoundingClientRect();E({top:U.bottom+window.scrollY+8,left:U.right+window.scrollX-320})}},[z]),p.useEffect(()=>{const U=ne=>{w.current&&!w.current.contains(ne.target)&&P.current&&!P.current.contains(ne.target)&&I(!1)};return z&&document.addEventListener("mousedown",U),()=>{document.removeEventListener("mousedown",U)}},[z]);const ue=U=>{if(n&&U!==r){Z(U),I(!1);return}i(U),I(!1)},pe=()=>{G&&(i(G),Z(null))},K=()=>{Z(null)},he=(U,ne=!1)=>{const ke=U.scope==="global",Q=!v&&(!ke||m),De=m&&!ke;return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:r===U.id?_(h.palette.primary.main,.12):"transparent",transition:"background-color 0.2s","&:hover":{backgroundColor:r===U.id?_(h.palette.primary.main,.12):h.palette.action.hover}},children:[t.jsxs(o.Button,{onClick:()=>ue(U.id),sx:{display:"flex",alignItems:"center",gap:1,flex:1,textAlign:"left",minWidth:0,justifyContent:"flex-start",color:"inherit",p:0,"&:hover":{backgroundColor:"transparent"}},children:[r===U.id&&t.jsx($.Check,{sx:{fontSize:16,flexShrink:0}}),r!==U.id&&t.jsx(o.Box,{sx:{width:"16px",flexShrink:0}}),t.jsx(o.Typography,{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:r===U.id?h.palette.primary.dark:h.palette.text.primary,fontWeight:r===U.id?We=>We.typography.body2.fontWeight||500:400,fontSize:We=>We.typography.body2.fontSize||"0.875rem"},children:U.name}),ne&&t.jsx(o.Typography,{component:"span",sx:{fontSize:"caption.fontSize",color:h.palette.text.secondary,backgroundColor:h.palette.action.selected,px:1,py:.25,borderRadius:1,flexShrink:0},children:"Default"})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[Q&&c&&t.jsx(o.IconButton,{onClick:We=>{We.stopPropagation(),c(U.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.action.hover}},title:U.isFavorite?"Remove from favorites":"Add to favorites",children:t.jsx($.Star,{sx:{fontSize:16}})}),Q&&a&&!U.isDefault&&t.jsx(o.IconButton,{onClick:We=>{We.stopPropagation(),a(U.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.action.hover}},title:"Set as default",children:t.jsx($.RadioButtonUnchecked,{sx:{fontSize:16}})}),(Q||De)&&(g||x||f||S||De&&C)&&t.jsx(o.IconButton,{onClick:We=>{We.stopPropagation(),y({el:We.currentTarget,view:U})},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.action.hover}},title:"More actions",children:t.jsx($.MoreVert,{sx:{fontSize:16}})})]})]},U.id)},ae=U=>t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:h.palette.action.hover},children:[t.jsx(o.Typography,{sx:{color:h.palette.text.secondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:U.name}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[l&&t.jsx(o.IconButton,{onClick:ne=>{ne.stopPropagation(),l(U.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.action.hover}},title:"Restore view",children:t.jsx($.Undo,{sx:{fontSize:16,color:"success.main"}})}),u&&t.jsx(o.IconButton,{onClick:ne=>{ne.stopPropagation(),u(U.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.action.hover}},title:"Delete permanently",children:t.jsx($.Delete,{sx:{fontSize:16,color:"error.main"}})})]})]},U.id),W=n||!d,ie=n;return t.jsxs(o.Box,{sx:{position:"relative"},children:[t.jsxs(o.Button,{ref:P,onClick:()=>I(!z),variant:"outlined",size:"small",endIcon:t.jsx($.KeyboardArrowDown,{sx:{fontSize:18}}),sx:{position:"relative",minWidth:140,maxWidth:220,justifyContent:"space-between",fontSize:"0.8125rem",textTransform:"none",color:W?"warning.main":"text.primary",borderColor:W?"warning.main":"divider",bgcolor:W?_(h.palette.warning.main,.12):"transparent",borderRadius:1,py:.5,px:1.25,transition:"all 0.15s ease","&:hover":{borderColor:W?"warning.dark":"primary.main",bgcolor:W?_(h.palette.warning.main,.2):_(h.palette.text.primary,.06),color:W?"warning.dark":"text.primary"}},title:`View: ${(te==null?void 0:te.name)||"Default View"}`,children:[t.jsx(o.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis"},children:(te==null?void 0:te.name)||"Default View"}),ie&&t.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"}})]}),z&&Ss.createPortal(t.jsxs(o.Box,{ref:w,sx:{position:"fixed",width:"320px",backgroundColor:h.palette.background.paper,border:`1px solid ${h.palette.divider}`,borderRadius:1,boxShadow:h.shadows[8],zIndex:50,maxHeight:"500px",overflowY:"auto",top:H.top,left:H.left},children:[re.length>0&&t.jsxs(o.Box,{sx:{py:.5},children:[t.jsx(o.Typography,{sx:{px:2,py:1,fontSize:U=>U.typography.caption.fontSize||"caption.fontSize",fontWeight:U=>U.typography.caption.fontWeight||600,color:h.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Global Views"}),re.map(U=>he(U,U.isDefault))]}),F.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${h.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:h.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",gap:.5},children:[t.jsx($.Star,{sx:{fontSize:12,color:"warning.light"}}),t.jsx(o.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:"Favorite Views"})]}),F.map(U=>he(U))]})]}),Se.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${h.palette.divider}`}}),t.jsxs(o.Box,{sx:{py:.5},children:[t.jsx(o.Typography,{sx:{px:2,py:1,fontSize:U=>U.typography.caption.fontSize||"caption.fontSize",fontWeight:U=>U.typography.caption.fontWeight||600,color:h.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Personal Views"}),Se.map(U=>he(U))]})]}),X.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${h.palette.divider}`}}),t.jsxs(o.Box,{sx:{py:.5},children:[t.jsxs(o.Button,{onClick:()=>R(!b),sx:{width:"100%",px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:h.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",justifyContent:"space-between",transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.action.hover}},children:[t.jsxs(o.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:["Recently Deleted (",X.length,")"]}),t.jsx($.ChevronRight,{sx:{fontSize:16}})]}),b&&t.jsx(o.Box,{sx:{backgroundColor:h.palette.action.hover},children:X.map(U=>ae(U))})]})]}),t.jsx(o.Box,{sx:{borderTop:`1px solid ${h.palette.divider}`}}),t.jsxs(o.Button,{onClick:()=>{s(),I(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:h.palette.text.primary,justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.action.hover}},children:[t.jsx($.Add,{sx:{fontSize:16}}),t.jsx(o.Typography,{component:"span",sx:{fontSize:"inherit"},children:"Create New Report View"})]}),t.jsxs(o.Popover,{open:!!O,anchorEl:(O==null?void 0:O.el)||null,onClose:()=>y(null),disablePortal:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[g&&t.jsxs(o.MenuItem,{onClick:()=>{O&&g(O.view.id),y(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx($.Edit,{sx:{fontSize:18}}),"Edit"]}),f&&t.jsxs(o.MenuItem,{onClick:()=>{O&&f(O.view.id),y(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx($.Link,{sx:{fontSize:18}}),"Copy Link"]}),x&&t.jsxs(o.MenuItem,{onClick:()=>{O&&x(O.view.id),y(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx($.ContentCopy,{sx:{fontSize:18}}),"Clone"]}),C&&m&&(O==null?void 0:O.view.scope)!=="global"&&t.jsxs(o.MenuItem,{onClick:()=>{O&&C(O.view.id),y(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx($.Language,{sx:{fontSize:18}}),"Promote to Global"]}),B&&O&&!(T!=null&&T.includes("setDefaultForAllUsers"))?t.jsxs(o.MenuItem,{onClick:()=>{O&&B(O.view.id,!O.view.isDefaultForAllUsers),y(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx($.Star,{sx:{fontSize:18,color:O.view.isDefaultForAllUsers?"warning.main":"inherit"}}),O.view.isDefaultForAllUsers?"Remove from":"Set as"," Default for All Users"]}):null,S&&[t.jsx(o.Divider,{},"delete-divider"),t.jsxs(o.MenuItem,{onClick:()=>{O&&S(O.view.id),y(null)},sx:{gap:1.5,fontSize:"body2.fontSize",color:"error.main"},children:[t.jsx($.Delete,{sx:{fontSize:18}}),"Delete"]},"delete-item")]]})]}),document.body),t.jsxs(o.Dialog,{open:G!==null,onClose:K,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:_o(h)}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",gap:1,pb:1},children:[t.jsx($.Warning,{sx:{fontSize:20,color:"warning.main"}}),"Unsaved changes"]}),t.jsx(o.DialogContent,{children:t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"You have unsaved changes to the current view. Switching views will discard them."})}),t.jsxs(o.DialogActions,{sx:{px:3,pb:2,gap:1},children:[t.jsx(o.Button,{onClick:K,variant:"text",children:"Stay here"}),t.jsx(o.Button,{onClick:pe,variant:"contained",color:"warning",children:"Discard & switch"})]})]})]})}function au({columnName:e,columnType:r="string",currentSort:n,hasFilters:i,isInSortStack:s,isReadOnly:a=!1,hasModifications:c=!1,position:l,onSortAscending:u,onSortDescending:g,onRemoveSort:x,onFilter:f,onClearFilter:S,onGroupByColumn:C,onHideColumn:B,onManageColumns:v,onResetLayout:m,onClose:T}){const h=pt(),z=h.palette,I=p.useRef(null);p.useEffect(()=>{if(!I.current)return;const Z=I.current,O=Z.getBoundingClientRect(),y=window.innerWidth,w=window.innerHeight;O.right>y-8&&(Z.style.left=`${y-O.width-8}px`),O.bottom>w-8&&(Z.style.top=`${w-O.height-8}px`)},[l]),p.useEffect(()=>{const Z=y=>{I.current&&!I.current.contains(y.target)&&T()},O=y=>{y.key==="Escape"&&T()};return document.addEventListener("mousedown",Z),document.addEventListener("keydown",O),()=>{document.removeEventListener("mousedown",Z),document.removeEventListener("keydown",O)}},[T]);const b=p.useCallback(Z=>()=>{Z(),T()},[T]),R=(n==null?void 0:n.direction)==="asc",H=(n==null?void 0:n.direction)==="desc",E=r==="number"?"0→9":r==="boolean"?"F→T":"A→Z",G=r==="number"?"9→0":r==="boolean"?"T→F":"Z→A";return Ss.createPortal(t.jsxs(o.Paper,{ref:I,elevation:0,sx:{position:"fixed",left:`${l.x}px`,top:`${l.y}px`,zIndex:h.zIndex.tooltip,minWidth:210,maxWidth:264,border:"1px solid",borderColor:"divider",borderRadius:_o(h),overflow:"hidden",boxShadow:`0 4px 20px ${_(z.common.black,.12)}, 0 1px 4px ${_(z.common.black,.06)}`},children:[!a&&t.jsxs(o.Box,{sx:{px:2,py:.75,display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid",borderColor:"divider"},children:[t.jsx(o.Typography,{sx:{fontSize:Z=>Z.typography.body2.fontSize||"0.8125rem",fontWeight:Z=>Z.typography.body2.fontWeight||500,color:"text.primary"},children:"Sorting"}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.25},children:[t.jsx(o.Tooltip,{title:`Sort Ascending (${E})`,placement:"top",arrow:!0,children:t.jsx(o.IconButton,{size:"small",onClick:b(()=>u(e)),sx:{p:.625,borderRadius:"6px",color:R?"primary.main":"text.secondary",bgcolor:R?_(z.primary.main,.1):"transparent","&:hover":{bgcolor:_(z.primary.main,.08),color:"primary.main"}},children:t.jsx($.ArrowUpward,{sx:{fontSize:16}})})}),t.jsx(o.Tooltip,{title:`Sort Descending (${G})`,placement:"top",arrow:!0,children:t.jsx(o.IconButton,{size:"small",onClick:b(()=>g(e)),sx:{p:.625,borderRadius:"6px",color:H?"primary.main":"text.secondary",bgcolor:H?_(z.primary.main,.1):"transparent","&:hover":{bgcolor:_(z.primary.main,.08),color:"primary.main"}},children:t.jsx($.ArrowDownward,{sx:{fontSize:16}})})}),t.jsx(o.Tooltip,{title:"Clear Sort",placement:"top",arrow:!0,children:t.jsx("span",{children:t.jsx(o.IconButton,{size:"small",disabled:!s,onClick:b(()=>x(e)),sx:{p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:_(z.error.main,.08),color:"error.main"},"&.Mui-disabled":{opacity:.3}},children:t.jsx($.Close,{sx:{fontSize:16}})})})})]})]}),t.jsxs(o.MenuList,{dense:!0,sx:{py:.5},children:[t.jsxs(o.MenuItem,{onClick:b(()=>f(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx($.FilterList,{sx:{fontSize:16,color:i?"primary.main":"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Filter by Column",primaryTypographyProps:{fontSize:"0.8125rem",fontWeight:i?600:400,color:i?"primary.main":"text.primary"}})]}),i&&!a&&t.jsxs(o.MenuItem,{onClick:b(()=>S(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:_(z.warning.main,.06),"& .MuiListItemText-primary":{color:"warning.main"},"& .MuiListItemIcon-root svg":{color:"warning.main"}}},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx($.FilterListOff,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Clear Filter",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]}),!a&&C&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.25}}),t.jsx(o.MenuList,{dense:!0,sx:{py:.5},children:t.jsxs(o.MenuItem,{onClick:b(()=>C(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx($.GroupWorkOutlined,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Group By Column",primaryTypographyProps:{fontSize:"0.8125rem"}})]})})]}),t.jsx(o.Divider,{sx:{my:.25}}),t.jsxs(o.MenuList,{dense:!0,sx:{py:.5},children:[!a&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",mx:.5,borderRadius:"6px",overflow:"hidden","&:hover":{bgcolor:"action.hover"}},children:[t.jsxs(o.MenuItem,{onClick:b(()=>B(e)),sx:{flex:1,py:.75,px:1.5,minHeight:34,borderRadius:"6px 0 0 6px","&:hover":{bgcolor:"transparent"}},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx($.VisibilityOff,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Hide Column",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),t.jsx(o.Tooltip,{title:"Manage Columns",placement:"top",arrow:!0,children:t.jsx(o.IconButton,{size:"small",onClick:b(v),sx:{mr:.75,p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:_(z.primary.main,.08),color:"primary.main"}},children:t.jsx($.Settings,{sx:{fontSize:16}})})})]}),a&&t.jsxs(o.MenuItem,{onClick:b(v),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx($.Settings,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Manage Columns",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),!a&&c&&m&&t.jsxs(o.MenuItem,{onClick:b(m),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:_(z.error.main,.05),"& .MuiListItemText-primary":{color:"error.main"},"& .MuiListItemIcon-root svg":{color:"error.main"}}},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx($.RestartAlt,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Reset to Default Layout",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]})]}),document.body)}const lu=176,ps="COLUMN_HEADER",cu=p.memo(function({column:r,index:n,sortRule:i,hasFilters:s,isInSortStack:a,isReadOnly:c=!1,hasModifications:l=!1,width:u,onColumnClick:g,onMoveColumn:x,onColumnDragEnd:f,onResizeStart:S,onSortAscending:C,onSortDescending:B,onRemoveSort:v,onOpenFilterForColumn:m,onClearFiltersForColumn:T,onGroupByColumn:h,onHideColumn:z,onManageColumns:I,onResetLayout:b}){const H=pt().urmTable,E=p.useRef(null),[G,Z]=p.useState(!1),[O,y]=p.useState({x:0,y:0}),[{handlerId:w,isOver:P},te]=or.useDrop({accept:ps,collect(K){return{handlerId:K.getHandlerId(),isOver:K.isOver()}},hover(K,he){var Q;if(!E.current)return;const ae=K.index,W=n;if(ae===W)return;const ie=(Q=E.current)==null?void 0:Q.getBoundingClientRect(),U=(ie.right-ie.left)/2,ne=he.getClientOffset(),ke=((ne==null?void 0:ne.x)??0)-ie.left;ae<W&&ke<U||ae>W&&ke>U||(x(ae,W),K.index=W)}}),[{isDragging:d},J]=or.useDrag({type:ps,item:()=>({index:n,columnName:r.name}),collect:K=>({isDragging:K.isDragging()}),end:()=>{f==null||f()}});J(te(E));const re=p.useCallback(K=>{K.preventDefault(),K.stopPropagation(),y({x:K.clientX,y:K.clientY}),Z(!0)},[]),Se=p.useCallback(()=>Z(!1),[]),F=p.useCallback(()=>{g(r.name)},[g,r.name]),X=p.useCallback(K=>{K.stopPropagation(),m(r.name)},[m,r.name]),ue=p.useCallback(()=>i?t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[i.direction==="asc"?t.jsx($.ArrowUpward,{sx:{fontSize:13,color:"primary.main"}}):t.jsx($.ArrowDownward,{sx:{fontSize:13,color:"primary.main"}}),t.jsx(o.Box,{sx:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:16,height:16,bgcolor:"primary.main",color:"primary.contrastText",fontSize:"0.6rem",fontWeight:700,borderRadius:"50%",lineHeight:1},children:i.priority})]}):null,[i]),pe=p.useCallback(()=>s?t.jsx($.FilterList,{onClick:X,titleAccess:"Active filter on this column — click to edit",sx:{ml:.5,fontSize:13,color:"primary.main",cursor:"pointer",flexShrink:0,"&:hover":{transform:"scale(1.15)"},transition:"transform 0.12s ease"}}):null,[s,X]);return t.jsxs(t.Fragment,{children:[t.jsxs(o.TableCell,{ref:E,"data-handler-id":w,"data-column-index":n,onClick:F,onContextMenu:re,sx:{position:"sticky",top:0,zIndex:5,textAlign:(H==null?void 0:H.cellAlignH)??"left",verticalAlign:(H==null?void 0:H.cellAlignV)??"middle",fontSize:"0.8125rem",fontWeight:700,textTransform:"none",letterSpacing:0,whiteSpace:"nowrap",overflow:"visible",cursor:"pointer",userSelect:"none",color:(H==null?void 0:H.headerColor)??"text.secondary",opacity:d?.25:1,transition:"background-color 0.12s ease, opacity 0.15s ease",bgcolor:P?K=>_(K.palette.primary.main,.08):(H==null?void 0:H.headerBg)??"action.hover",boxShadow:K=>`0 1px 0 ${_(K.palette.common.black,.08)}`,backgroundImage:"none",borderBottom:(H==null?void 0:H.rowDivider)??"1px solid",borderRight:H==null?void 0:H.colDivider,borderColor:"divider",py:0,px:(H==null?void 0:H.cellPaddingX)??2,"&:hover":{bgcolor:K=>_(K.palette.primary.main,.1),color:"text.primary"},width:u?`${u}px`:`${lu}px`},children:[t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",overflow:"hidden",maxWidth:"100%",pr:"12px"},children:[dt(r.name),ue(),pe()]}),t.jsx(o.Box,{draggable:!1,onDragStart:K=>K.preventDefault(),sx:{position:"absolute",right:0,top:0,height:"100%",width:8,cursor:"col-resize",zIndex:20,display:"flex",alignItems:"center",justifyContent:"center","&:hover > div":{opacity:1}},onMouseDown:K=>{K.preventDefault(),K.stopPropagation(),S(K,r.name)},onClick:K=>K.stopPropagation(),children:t.jsx(o.Box,{draggable:!1,sx:{width:2,height:"50%",borderRadius:1,opacity:0,bgcolor:"primary.main",transition:"opacity 0.15s ease",pointerEvents:"none"}})}),P&&t.jsx(o.Box,{sx:{position:"absolute",left:0,top:0,bottom:0,width:4,bgcolor:"primary.main"}})]}),G&&t.jsx(au,{columnName:r.name,columnType:r.type,currentSort:i,hasFilters:s,isInSortStack:a,isReadOnly:c,hasModifications:l,position:O,onSortAscending:C,onSortDescending:B,onRemoveSort:v,onFilter:m,onClearFilter:T,onGroupByColumn:h,onHideColumn:z,onManageColumns:I,onResetLayout:b,onClose:Se})]})}),du={active:"success",completed:"success",approved:"success",success:"success",done:"success",contract:"info","in progress":"info","in review":"info",review:"info",pending:"info","on leave":"error","on hold":"warning",probation:"warning",cancelled:"error",rejected:"error",blocked:"error",inactive:"neutral","not started":"neutral",paused:"neutral"};function an(e,r){const n=du[r.toLowerCase().trim()];if(!n||n==="neutral")return{bg:e.palette.action.selected,color:e.palette.text.secondary};const i=e.palette[n];return{bg:_(i.main,e.palette.mode==="dark"?.24:.12),color:e.palette.mode==="dark"?i.light:i.dark}}function uu(e,r){switch(r.toLowerCase().trim()){case"low":return e.palette.text.secondary;case"medium":return e.palette.warning.main;case"high":return e.palette.mode==="dark"?e.palette.warning.light:e.palette.warning.dark;case"critical":case"urgent":return e.palette.error.main;default:return}}const pu={filters:{hue:"primary",shade:"main"},sorting:{hue:"secondary",shade:"main"},grouping:{hue:"success",shade:"main"},columns:{hue:"warning",shade:"main"},views:{hue:"error",shade:"main"},theme:{hue:"info",shade:"main"},export:{hue:"primary",shade:"dark"},presets:{hue:"secondary",shade:"dark"},system:{hue:"error",shade:"dark"},rows:{hue:"primary",shade:"main"}};function hu(e,r){const n=pu[r];return n?e.palette[n.hue][n.shade]:e.palette.text.secondary}function Bt(e){return _(e.palette.primary.main,e.palette.mode==="dark"?.24:.12)}function fu(e){const r=e.toLowerCase().trim();return t.jsx(o.Box,{component:"span",sx:{display:"inline-flex",alignItems:"center",px:1,py:.25,borderRadius:"10px",fontSize:"0.75rem",fontWeight:n=>{var i;return(i=n.tokens)!=null&&i.statusBold?700:500},bgcolor:n=>an(n,r).bg,color:n=>an(n,r).color,whiteSpace:"nowrap",lineHeight:1.5},children:e})}function mu(e,r){if(r==null||r==="")return t.jsx(o.Box,{component:"span",sx:{color:"text.disabled",fontSize:"0.875rem"},children:"—"});const n=String(r),i=e.name.toLowerCase();if(/\b(status|state|stage)\b/.test(i))return fu(n);if(/\b(priority|severity|urgency)\b/.test(i)){const s=n.toLowerCase().trim();return t.jsx(o.Box,{component:"span",sx:a=>{const c=uu(a,s);return c?{color:c,fontWeight:600,fontSize:"0.875rem"}:{fontSize:"0.875rem"}},children:n})}return typeof r=="boolean"?t.jsx(o.Box,{component:"span",sx:{fontSize:"0.875rem"},children:r?"Yes":"No"}):typeof r=="object"?t.jsx(o.Box,{component:"span",sx:{fontSize:"0.875rem"},children:JSON.stringify(r)}):t.jsx(o.Box,{component:"span",sx:{fontSize:"0.875rem"},children:n})}function xu(e){const r=e.find(s=>{const a=s.name.toLowerCase();return/\b(name|title|label|subject|task_?name|taskname)\b/.test(a)})||e[0]||null,n=e.find(s=>{const a=s.name.toLowerCase().replace(/[\s_-]/g,"");return/(^id$|id$|_id$|taskid|code$|ref$)/.test(a)&&s!==r})||null,i=e.filter(s=>s!==r&&s!==n).slice(0,4);return{primaryCol:r,idCol:n,bodyColumns:i}}function gu({row:e,rowIndex:r,visibleColumns:n,isSelected:i,onCardClick:s,onCardDoubleClick:a,onCardContextMenu:c,onOpenRowMenu:l,onToggleSelection:u,hideCheckbox:g}){const[x,f]=p.useState(!1),{primaryCol:S,idCol:C,bodyColumns:B}=p.useMemo(()=>xu(n),[n]),v=S?e[S.name]:null,m=C?e[C.name]:null,T=x||i;return t.jsxs(o.Box,{onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),onClick:h=>s(r,h),onDoubleClick:h=>a(e,r,h),onContextMenu:h=>{h.preventDefault(),h.stopPropagation(),c(e,r,h)},sx:{position:"relative",display:"flex",flexDirection:"column",bgcolor:"background.paper",border:h=>{var I,b,R,H;const z=(H=(R=(b=(I=h.components)==null?void 0:I.MuiCard)==null?void 0:b.styleOverrides)==null?void 0:R.root)==null?void 0:H.border;return i?"2px solid":z&&z!=="none"?z:"1px solid"},borderColor:i?h=>ct(h).main:h=>{var I,b,R,H;const z=(H=(R=(b=(I=h.components)==null?void 0:I.MuiCard)==null?void 0:b.styleOverrides)==null?void 0:R.root)==null?void 0:H.border;return z&&z!=="none"?"inherit":_(h.palette.divider,.8)},borderWidth:i?2:void 0,borderRadius:h=>{var I,b,R,H;const z=(H=(R=(b=(I=h.components)==null?void 0:I.MuiCard)==null?void 0:b.styleOverrides)==null?void 0:R.root)==null?void 0:H.borderRadius;return z!==void 0?typeof z=="number"?`${z}px`:z:`${h.shape.borderRadius}px`},cursor:"pointer",transition:"box-shadow 0.2s ease, border-color 0.2s ease, transform 0.15s ease",overflow:"hidden",minHeight:180,boxShadow:i?h=>`0 0 0 3px ${_(ct(h).main,.15)}, 0 2px 8px ${_(h.palette.common.black,.08)}`:x?h=>{var I,b,R,H;const z=(H=(R=(b=(I=h.components)==null?void 0:I.MuiCard)==null?void 0:b.styleOverrides)==null?void 0:R.root)==null?void 0:H.boxShadow;return z&&z!=="none"?z:be(h,"cardHover")}:h=>{var I,b,R,H;const z=(H=(R=(b=(I=h.components)==null?void 0:I.MuiCard)==null?void 0:b.styleOverrides)==null?void 0:R.root)==null?void 0:H.boxShadow;return z&&z!=="none"?z:be(h,"cardRest")},transform:x&&!i?"translateY(-2px)":"none","&:active":{transform:"translateY(0)"},...i&&{bgcolor:h=>_(ct(h).main,.03)}},children:[t.jsxs(o.Box,{sx:h=>{var H,E,G,Z;const z=((G=(E=(H=h.components)==null?void 0:H.MuiCardHeader)==null?void 0:E.styleOverrides)==null?void 0:G.root)||{},I=(z.backgroundColor&&z.backgroundColor!=="transparent"?z.backgroundColor:void 0)??((Z=h.tokens)==null?void 0:Z.cardHdrHex)??"transparent",b=z.borderBottom&&z.borderBottom!=="none"?z.borderBottom:void 0,R=z.boxShadow&&z.boxShadow!=="none"?z.boxShadow:void 0;return{px:2,pt:1.75,pb:1.5,bgcolor:I,borderBottom:b,boxShadow:R,display:"flex",alignItems:"center",gap:.5}},children:[!g&&T&&t.jsx(o.Checkbox,{size:"small",checked:i,onClick:h=>h.stopPropagation(),onChange:()=>u(e),sx:{p:.25}}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:h=>h.typography.body2.fontWeight||600,fontSize:h=>h.typography.body1.fontSize||"0.9375rem",color:"text.primary",lineHeight:1.35,wordBreak:"break-word",letterSpacing:"-0.01em"},children:v!=null&&v!==""?String(v):t.jsx(o.Box,{component:"span",sx:{color:"text.disabled",fontStyle:"italic",fontWeight:400},children:"Untitled"})})]}),t.jsx(o.Box,{sx:h=>{var b,R,H;const z=((H=(R=(b=h.components)==null?void 0:b.MuiCardHeader)==null?void 0:R.styleOverrides)==null?void 0:H.root)||{};return z.borderBottom&&z.borderBottom!=="none"?{display:"none"}:{mx:2,height:"1px",bgcolor:"divider",flexShrink:0}}}),t.jsxs(o.Box,{sx:{px:2,py:1.5,flex:1,display:"grid",gridTemplateColumns:"repeat(2, 1fr)",columnGap:1.5,rowGap:1,alignContent:"start"},children:[B.map(h=>t.jsxs(o.Box,{sx:{minWidth:0},children:[t.jsx(o.Typography,{sx:{color:"text.secondary",fontWeight:z=>z.typography.body2.fontWeight||500,fontSize:z=>z.typography.caption.fontSize||"0.6875rem",textTransform:"uppercase",letterSpacing:"0.06em",lineHeight:1.2,mb:.25},children:dt(h.name)}),t.jsx(o.Box,{sx:{lineHeight:1.3,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},title:String(e[h.name]??""),children:mu(h,e[h.name])})]},h.name)),B.length===0&&t.jsx(o.Typography,{variant:"caption",color:"text.disabled",sx:{fontStyle:"italic",gridColumn:"1 / -1"},children:"No additional fields visible"})]}),t.jsxs(o.Box,{sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid",borderColor:"divider",bgcolor:h=>_(h.palette.action.hover,.1),minHeight:40},children:[t.jsx(o.Typography,{sx:{color:"primary.main",fontFamily:'"Roboto Mono", "Courier New", monospace',fontSize:"0.75rem",fontWeight:400,letterSpacing:"0.04em",opacity:m?.85:0,userSelect:"none"},children:m?String(m):" "}),t.jsx(o.Box,{sx:{display:"flex",alignItems:"center",gap:.25,opacity:T?1:0,transition:"opacity 0.15s ease"},onClick:h=>h.stopPropagation(),children:t.jsx(o.Tooltip,{title:"More actions",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:h=>{h.stopPropagation(),l(e,r,h.currentTarget)},sx:{width:28,height:28,color:"action.active","&:hover":{bgcolor:h=>_(h.palette.text.primary,.08)}},children:t.jsx($.MoreVert,{sx:{fontSize:17}})})})})]})]})}function yu({row:e,grouping:r,onToggleCollapse:n}){var i;return t.jsxs(o.Box,{onClick:()=>n(e.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:s=>be(s,"flatHover"),"&:hover":{bgcolor:s=>_(s.palette.primary.main,.04),borderColor:"primary.light"},transition:"all 0.15s ease"},children:[e.isCollapsed?t.jsx($.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}):t.jsx($.KeyboardArrowDown,{sx:{fontSize:16,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"h5",sx:{fontWeight:s=>s.typography.h5.fontWeight||600,color:s=>s.typography.h5.color||"text.primary"},children:Va(e.groupLevel,((i=r==null?void 0:r.levels[e.groupLevel])==null?void 0:i.column)||"",e.groupValue)}),t.jsxs(o.Box,{sx:{px:1,py:.125,fontSize:"0.6875rem",fontWeight:600,bgcolor:s=>_(s.palette.primary.main,.1),color:"primary.main",borderRadius:"10px"},children:[e.rowCount," ",e.rowCount===1?"row":"rows"]}),Object.keys(e.aggregates).length>0&&t.jsx(o.Typography,{variant:"caption",sx:{ml:.5,color:"text.secondary"},children:Object.entries(e.aggregates).map(([s,a])=>Ts(a)).filter(Boolean).join(" • ")})]})}function bu({data:e,visibleColumns:r,grouping:n,selectedRowIds:i,isGrouped:s,onToggleGroupCollapse:a,onCardClick:c,onCardDoubleClick:l,onCardContextMenu:u,onOpenRowMenu:g,onToggleSelection:x,hideSelectionCheckboxes:f}){const S=p.useMemo(()=>{const C=new Set;return i.forEach(B=>{const v=B==null?void 0:B.__urm_row_id__;v!==void 0&&C.add(v)}),C},[i]);return e.length===0?t.jsx(o.Box,{sx:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",py:10},children:t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})}):t.jsx(o.Box,{sx:{fontFamily:C=>C.typography.fontFamily},children:t.jsx(o.Box,{sx:{p:C=>ds(C).containerPad,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:C=>ds(C).cardGap,alignContent:"start"},children:e.map((C,B)=>s&&C.isGroupHeader?t.jsx(yu,{row:C,grouping:n,onToggleCollapse:a||(()=>{})},`group-${C.groupKey}`):t.jsx(gu,{row:C,rowIndex:B,visibleColumns:r,isSelected:S.has(C==null?void 0:C.__urm_row_id__),onCardClick:c,onCardDoubleClick:l,onCardContextMenu:u,onOpenRowMenu:g,onToggleSelection:x,hideCheckbox:f},`card-${B}`))})})}const hs=[10,15,25,50,100];function vu(e,r){const n=e.trim();if(n==="")return"Page number is required";if(!/^-?\d+$/.test(n))return"Must be a number";const i=parseInt(n,10);return i<1?"Page number must be at least 1":i>r?"Entered page number is out of range":null}function Su({currentPage:e,pageSize:r,totalRows:n,totalFields:i,onPageChange:s,onPageSizeChange:a}){const l=pt().palette,u=Math.ceil(n/r),[g,x]=p.useState(String(e)),[f,S]=p.useState(null),[C,B]=p.useState(!1),v=p.useRef(null);p.useEffect(()=>{C||(x(String(e)),S(null))},[e,C]);const m=p.useCallback(()=>{const w=vu(g,u);if(w){S(w);return}const P=parseInt(g.trim(),10);S(null),B(!1),P!==e&&s(P)},[g,u,e,s]),T=p.useCallback(w=>{var P;w.key==="Enter"?(w.preventDefault(),m()):w.key==="Escape"&&(x(String(e)),S(null),B(!1),(P=v.current)==null||P.blur())},[m,e]),h=p.useCallback(()=>{x(String(e)),S(null),B(!1)},[e]),z=p.useCallback(()=>{B(!0),S(null),setTimeout(()=>{var w;return(w=v.current)==null?void 0:w.select()},0)},[]);if(n<=Math.min(...hs))return null;const I=()=>{x(String(e)),S(null),B(!1)},b=()=>{I(),s(1)},R=()=>{I(),e>1&&s(e-1)},H=()=>{I(),e<u&&s(e+1)},E=()=>{I(),s(u)},G=(e-1)*r+1,Z=Math.min(e*r,n),O=`${Math.max(2,String(u).length+.5)}ch`,y={p:.75,color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"action.disabled"}};return t.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:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:2},children:[t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:w=>w.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400},children:["Total data:"," ",t.jsx(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:n})]}),i!==void 0&&t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:w=>w.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400},children:["Total fields:"," ",t.jsx(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:i})]})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:3},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:w=>w.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400},children:"Rows per page:"}),t.jsx(o.Select,{value:r,onChange:w=>a(Number(w.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:hs.map(w=>t.jsx(o.MenuItem,{value:w,sx:{fontSize:"0.8125rem"},children:w},w))})]}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:w=>w.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400,userSelect:"none"},children:[G,"–",Z," of ",n]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,position:"relative"},children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:w=>w.typography.body2.fontSize||"0.8125rem",color:"text.secondary",userSelect:"none"},children:"Page"}),t.jsxs(o.Box,{sx:{position:"relative"},children:[f&&t.jsx(o.Box,{sx:{position:"absolute",bottom:"calc(100% + 6px)",left:"50%",transform:"translateX(-50%)",bgcolor:"background.paper",border:"1px solid",borderColor:_(l.error.main,.4),borderRadius:"6px",px:1,py:.5,boxShadow:`0 2px 8px ${_(l.common.black,.12)}`,zIndex:20,whiteSpace:"nowrap","&::after":{content:'""',position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)",border:"5px solid transparent",borderTopColor:_(l.error.main,.4)}},children:t.jsx(o.Typography,{sx:{fontSize:w=>w.typography.caption.fontSize||"0.6875rem",fontWeight:w=>w.typography.caption.fontWeight||500,color:"error.main",lineHeight:1.3},children:f})}),t.jsx(o.InputBase,{inputRef:v,value:g,onChange:w=>{x(w.target.value),f&&S(null)},onKeyDown:T,onFocus:z,onBlur:h,inputProps:{"aria-label":`Page number, 1 to ${u}`,style:{textAlign:"center",padding:"2px 0",width:O,fontSize:"0.8125rem",fontWeight:600}},sx:{fontSize:"0.8125rem",fontWeight:600,color:f?"error.main":"text.primary",border:"1px solid",borderColor:f?"error.main":C?"primary.main":"divider",borderRadius:"4px",bgcolor:f?_(l.error.main,.04):C?_(l.primary.main,.04):"background.paper",px:.75,transition:"border-color 0.15s ease, background-color 0.15s ease","&:hover":{borderColor:f?"error.main":"text.secondary"},"&:focus-within":{boxShadow:f?`0 0 0 2px ${_(l.error.main,.2)}`:`0 0 0 2px ${_(l.primary.main,.2)}`}}})]}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:w=>w.typography.body2.fontSize||"0.8125rem",color:"text.secondary",userSelect:"none"},children:["of ",u]})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.IconButton,{onClick:b,disabled:e===1,size:"small",title:"First page",sx:y,children:t.jsx($.FirstPage,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:R,disabled:e===1,size:"small",title:"Previous page",sx:y,children:t.jsx($.ChevronLeft,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:H,disabled:e===u,size:"small",title:"Next page",sx:y,children:t.jsx($.ChevronRight,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:E,disabled:e===u,size:"small",title:"Last page",sx:y,children:t.jsx($.LastPage,{sx:{fontSize:20}})})]})]})]})}function Cu(){return t.jsx(o.Chip,{icon:t.jsx($.Visibility,{sx:{fontSize:14}}),label:"View Only",size:"small",variant:"outlined",sx:{bgcolor:"action.hover",borderColor:"divider",fontSize:e=>e.typography.caption.fontSize||"caption.fontSize",fontWeight:e=>e.typography.caption.fontWeight||500}})}const Xs="urm_hint_seen_";function wu(e){try{return localStorage.getItem(Xs+e)==="true"}catch{return!1}}function ju(e){try{localStorage.setItem(Xs+e,"true")}catch{}}const Qs={"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:"8px"},"& .MuiInputLabel-root":{fontSize:"0.875rem"},"& .MuiFormHelperText-root":{fontSize:"0.75rem",mx:.5},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}}};function ii(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 Zs({row:e,schema:r}){const i=pt().palette,s=r.filter(l=>l.name in e),a=s.filter(l=>l.type!=="object"&&l.type!=="array"),c=s.filter(l=>l.type==="object"||l.type==="array");return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[a.map(l=>t.jsx(o.TextField,{label:dt(l.name),value:ii(e[l.name],l.type)||"No value",size:"small",fullWidth:!0,InputProps:{readOnly:!0},sx:Qs},l.name)),c.map(l=>{const u=ii(e[l.name],l.type);return t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontWeight:g=>g.typography.caption.fontWeight||500,fontSize:g=>g.typography.caption.fontSize||"0.75rem",color:"text.secondary",display:"block",mb:.75},children:dt(l.name)}),t.jsx(o.Box,{component:"pre",sx:{m:0,px:1.5,py:1.25,borderRadius:"8px",border:"1px solid",borderColor:"divider",bgcolor:_(i.text.primary,.02),fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:u?"text.primary":"text.disabled",fontStyle:u?"normal":"italic",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6,maxHeight:160,overflowY:"auto"},children:u||"No value"})]},l.name)}),s.length===0&&t.jsx(o.Typography,{variant:"body2",sx:{color:"text.disabled",textAlign:"center",py:3,fontSize:l=>l.typography.body2.fontSize||"0.875rem"},children:"No fields to display"})]})}function ku({open:e,onClose:r,row:n,schema:i,reportName:s}){const a=pt(),c=a.palette;if(!n)return null;const l=i.filter(g=>g.name in n).length,u=de(a);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:ot(a),maxHeight:"min(720px, calc(100vh - 80px))",display:"flex",flexDirection:"column",overflow:"hidden",...u.paper}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2.5,pb:2,display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0,...u.header},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,minWidth:0},children:[t.jsx(o.Box,{sx:{width:36,height:36,borderRadius:"10px",bgcolor:_(c.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx($.VisibilityOutlined,{sx:{fontSize:18,color:"primary.main"}})}),t.jsxs(o.Box,{sx:{minWidth:0},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:g=>g.typography.h6.fontSize||"1rem",fontWeight:g=>g.typography.h6.fontWeight||600,color:g=>g.typography.h6.color||"text.primary",lineHeight:1.3},children:"View Record"}),s&&t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:g=>g.typography.caption.fontSize||"0.75rem",color:"text.secondary",display:"block",mt:.25,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[s," · ",l," ",l===1?"field":"fields"]})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{mt:.25,color:"text.secondary",borderRadius:"8px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.Close,{sx:{fontSize:18}})})]}),t.jsx(o.Divider,{}),t.jsx(o.DialogContent,{sx:{overflowY:"auto",flex:1,bgcolor:_(c.text.primary,.015)},children:t.jsx(Zs,{row:n,schema:i})}),t.jsx(o.Divider,{}),t.jsx(o.DialogActions,{sx:{px:3,py:1.75,bgcolor:"background.paper",justifyContent:"flex-end"},children:t.jsx(o.Button,{onClick:r,variant:"contained",sx:{fontSize:"0.8125rem",px:3,py:.75,borderRadius:g=>`${g.shape.borderRadius}px`,minWidth:80},children:"Close"})})]})}function zu({open:e,onClose:r,onConfirm:n,row:i,schema:s}){const a=pt(),c=de(a);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:ot(a),maxHeight:"min(720px, calc(100vh - 80px))",my:"auto",display:"flex",flexDirection:"column",...c.paper}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2.5,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between",...c.header},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:l=>_(l.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx($.WarningAmberRounded,{sx:{fontSize:22,color:"error.main"}})}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:l=>l.typography.h6.fontSize||"1.125rem",fontWeight:l=>l.typography.h6.fontWeight||500,color:l=>l.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5,mb:.5},children:"Delete record?"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:l=>l.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"This record will be permanently removed."})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.DialogContent,{sx:{px:3,pb:2,overflowY:"auto",flex:1,display:"flex",flexDirection:"column",gap:2},children:[i&&s&&t.jsx(Zs,{row:i,schema:s}),t.jsx(o.Box,{sx:{p:2,borderRadius:"8px",bgcolor:l=>_(l.palette.error.main,.1),border:l=>`1px solid ${_(l.palette.error.main,.5)}`},children:t.jsx(o.Typography,{variant:"body2",sx:{fontSize:l=>l.typography.body2.fontSize||"0.8125rem",color:"error.main",fontWeight:l=>l.typography.body2.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 divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:[t.jsx(o.Button,{onClick:r,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:l=>`${l.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:()=>{n(),r()},variant:"contained",startIcon:t.jsx($.DeleteForever,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"error.main",color:"error.contrastText",px:3,py:.875,minHeight:36,borderRadius:l=>`${l.shape.borderRadius}px`,boxShadow:l=>be(l,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"error.dark",boxShadow:l=>be(l,"hoverButton")},"&:active":{boxShadow:l=>be(l,"pressedButton"),transform:"translateY(1px)"}},children:"Delete record"})]})]})}function Tu({open:e,onClose:r,onSave:n,row:i,schema:s,reportName:a}){var T;const c=pt(),l=c.palette,[u,g]=p.useState({});if(p.useEffect(()=>{e&&i&&g({...i})},[e,i]),!i)return null;const x=s.filter(h=>h.name in i),f=x.filter(h=>h.type!=="object"&&h.type!=="array"),S=x.filter(h=>h.type==="object"||h.type==="array"),C=(h,z)=>{g(I=>({...I,[h]:z}))},B=()=>{const h={...u};x.forEach(z=>{const I=u[z.name];if(z.type==="number"){const b=Number(I);h[z.name]=isNaN(b)?i[z.name]:b}else z.type==="boolean"&&(h[z.name]=!!I)}),n(h),r()},v=x.length,m=de(c);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:ot(c),maxHeight:"min(760px, calc(100vh - 80px))",display:"flex",flexDirection:"column",overflow:"hidden",...m.paper}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2.5,pb:2,display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0,...m.header},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,minWidth:0},children:[t.jsx(o.Box,{sx:{width:36,height:36,borderRadius:"10px",bgcolor:_(((T=l.warning)==null?void 0:T.main)??"#ed6c02",.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx($.EditOutlined,{sx:{fontSize:18,color:"warning.main"}})}),t.jsxs(o.Box,{sx:{minWidth:0},children:[t.jsx(o.Typography,{sx:{fontSize:h=>h.typography.h6.fontSize||"1rem",fontWeight:h=>h.typography.h6.fontWeight||600,color:"text.primary",lineHeight:1.3},children:"Edit Record"}),a&&t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:h=>h.typography.caption.fontSize||"0.75rem",color:"text.secondary",display:"block",mt:.25,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[a," · ",v," ",v===1?"field":"fields"]})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{mt:.25,color:"text.secondary",borderRadius:"8px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.Close,{sx:{fontSize:18}})})]}),t.jsx(o.Divider,{}),t.jsxs(o.DialogContent,{sx:{p:2.5,overflowY:"auto",flex:1,bgcolor:_(l.text.primary,.015),display:"flex",flexDirection:"column",gap:2},children:[f.map(h=>{const z=u[h.name];return h.type==="boolean"?t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontWeight:I=>I.typography.caption.fontWeight||500,fontSize:I=>I.typography.caption.fontSize||"0.75rem",color:"text.secondary",display:"block",mb:.75},children:dt(h.name)}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Switch,{checked:!!z,onChange:I=>C(h.name,I.target.checked),size:"small"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:I=>I.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:z?"Enabled":"Disabled"})]})]},h.name):t.jsx(o.TextField,{label:dt(h.name),value:z??"",onChange:I=>C(h.name,I.target.value),type:h.type==="number"?"number":"text",size:"small",fullWidth:!0,sx:Qs},h.name)}),S.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:S.map(h=>{const z=ii(i[h.name],h.type);return t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:.75},children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:I=>I.typography.caption.fontSize||"0.75rem",fontWeight:I=>I.typography.caption.fontWeight||500,color:"text.secondary"},children:dt(h.name)}),t.jsx(o.Chip,{label:"read only",size:"small",sx:{height:16,fontSize:"0.5625rem",fontWeight:600,letterSpacing:"0.04em",bgcolor:_(l.text.secondary,.07),color:"text.secondary",border:"none"}}),t.jsx(o.Tooltip,{title:"Object and array fields cannot be edited directly",arrow:!0,children:t.jsx($.InfoOutlined,{sx:{fontSize:13,color:"text.disabled",cursor:"help"}})})]}),t.jsx(o.Box,{component:"pre",sx:{m:0,px:1.5,py:1.25,borderRadius:"8px",border:"1px solid",borderColor:"divider",bgcolor:_(l.text.primary,.02),fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:z?"text.primary":"text.disabled",fontStyle:z?"normal":"italic",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6,maxHeight:160,overflowY:"auto"},children:z||"No value"})]},h.name)})}),x.length===0&&t.jsxs(o.Box,{sx:{py:6,display:"flex",flexDirection:"column",alignItems:"center",gap:1,color:"text.disabled"},children:[t.jsx($.EditOutlined,{sx:{fontSize:40,opacity:.4}}),t.jsx(o.Typography,{variant:"body2",children:"No editable fields"})]})]}),t.jsx(o.Divider,{}),t.jsxs(o.DialogActions,{sx:{px:3,py:1.75,bgcolor:"background.paper",gap:1,justifyContent:"flex-end"},children:[t.jsx(o.Button,{onClick:r,variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",px:2,borderRadius:h=>`${h.shape.borderRadius}px`,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:B,variant:"contained",startIcon:t.jsx($.SaveOutlined,{sx:{fontSize:15}}),sx:{fontSize:"0.8125rem",px:2.5,borderRadius:h=>`${h.shape.borderRadius}px`,minWidth:90},children:"Save"})]})]})}const Bu=176,Iu=170,Eu=40;function ea(e){return e.type==="date"?180:Bu}function Du(e,r){return r!=null&&r!==Iu&&r!==ea(e)}function _u(e,r,n){return p.useMemo(()=>{const i=e.map(f=>({name:f.name,width:r[f.name]??ea(f),explicit:Du(f,r[f.name])})),s={};i.forEach(f=>{s[f.name]=f.width});const a=i.reduce((f,S)=>f+S.width,0),l=Math.max(0,n-Eu)-a;if(l<=0)return{widths:s,fillerWidth:0};const u=i.filter(f=>!f.explicit);if(u.length===0)return{widths:s,fillerWidth:l};const g=u.reduce((f,S)=>f+S.width,0)||1;let x=0;return u.forEach((f,S)=>{const B=S===u.length-1?f.width+l-x:Math.round(f.width+l*f.width/g);s[f.name]=B,x+=B-f.width}),{widths:s,fillerWidth:0}},[e,r,n])}const fs=176,$u=At(),Ou={low:"text.secondary",medium:"warning.dark",high:"warning.main",critical:"error.main",urgent:"error.main"};function Mu(e){const r=e.toLowerCase().trim();return t.jsx(o.Box,{component:"span",sx:{display:"inline-flex",alignItems:"center",px:1.25,py:.375,borderRadius:"12px",fontSize:"0.75rem",fontWeight:n=>{var i;return(i=n.tokens)!=null&&i.statusBold?700:500},bgcolor:n=>an(n,r).bg,color:n=>an(n,r).color,whiteSpace:"nowrap",lineHeight:1.6,letterSpacing:"0.01em"},children:e})}function Au(e){const r=e.toLowerCase().trim(),n=Ou[r];return n?t.jsx(o.Box,{component:"span",sx:{color:n,fontWeight:500,fontSize:"inherit"},children:e}):e}function Wu(e,r){const n=r.trim();if(!n)return e;const i=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=e.split(new RegExp(`(${i})`,"gi"));return s.length===1?e:s.map((a,c)=>a.toLowerCase()===n.toLowerCase()?t.jsx(o.Box,{component:"mark",sx:{bgcolor:"warning.light",color:"inherit",px:"1px",borderRadius:"2px"},children:a},c):a)}function Ru(e,r,n,i=""){if(r==null||r==="")return t.jsx(o.Box,{component:"span",sx:{color:"text.disabled"},children:"—"});const s=String(r);if(/\b(status|state|stage|employmenttype|contracttype|availability)\b/.test(e.name.toLowerCase()))return Mu(s);if(/\b(priority|severity|urgency|importance|criticality)\b/.test(e.name.toLowerCase()))return Au(s);if(e.type==="date"){const l=e.dateFormat??"iso",u=_a(r,l,n??null);return t.jsx(o.Box,{component:"span",sx:{color:"text.primary",whiteSpace:"nowrap"},children:u})}if(e.type==="number"&&typeof r=="number")return r.toLocaleString();if(typeof r=="boolean")return r?"Yes":"No";if(Array.isArray(r)){if(r.length===0)return t.jsx(o.Box,{component:"span",sx:{color:"text.disabled"},children:"[ ]"});const l=r.slice(0,3).map(u=>typeof u=="object"?JSON.stringify(u):String(u)).join(", ");return t.jsxs(o.Box,{component:"span",sx:{color:"text.secondary",fontSize:"0.8125rem"},children:[l,r.length>3?` +${r.length-3} more`:""]})}if(typeof r=="object"){const l=JSON.stringify(r);return t.jsx(o.Box,{component:"span",title:l,sx:{color:"text.secondary",fontSize:"0.8125rem",fontFamily:"monospace",cursor:"help"},children:l.length>40?l.slice(0,40)+"…":l})}return Wu(s,i)}function Pu({schema:e,data:r,sortStack:n=[],filters:i=$u,views:s=[],activeViewId:a="",isDirty:c=!1,isExporting:l=!1,columnVisibility:u={},columnOrder:g=[],columnWidths:x={},grouping:f=null,classTokens:S={},onSort:C,onSortAscending:B,onSortDescending:v,onOpenFilters:m,onOpenSort:T,onOpenFilterForColumn:h,onSelectView:z,onCreateView:I,onUpdateCurrentView:b,onSaveAsNewView:R,onDiscardChanges:H,onToggleDefault:E,onToggleFavorite:G,onRestoreView:Z,onPermanentDelete:O,onEditView:y,onCloneView:w,onCopyLink:P,onDeleteView:te,onPromoteToGlobal:d,onSetDefaultForAllUsers:J,isAdmin:re=!1,hideViewMenuActions:Se,onExport:F,onOpenColumns:X,onUpdateColumnWidth:ue,onUpdateColumnOrder:pe,onUpdateColumnVisibility:K,onClearFiltersForColumn:he,onResetLayout:ae,onOpenGroup:W,onGroupByColumn:ie,onToggleGroupCollapse:U,onExpandAllGroups:ne,onCollapseAllGroups:ke,onOpenAuditHistory:Q,onOpenScheduledReports:De,searchQuery:We,highlightQuery:Wt="",searchHistory:Yt=[],onAddToSearchHistory:_r,onToggleSearchFavourite:Rt,onDeleteSearchHistory:ht,selectedRowIds:bt=new Set,onSearchChange:$r,onToggleRowSelection:Qe,onToggleAllRows:Et,onRangeSelection:qt,onClearSelection:Pt,onExportSelected:ir,currentPage:sr=1,pageSize:Or=15,totalRowsBeforePagination:Jt=r.length,onPageChange:br,onPageSizeChange:vt,isReadOnly:Je=!1,userRole:vr,reportName:it,onEditRow:rt,onDuplicateRow:Nt,onDeleteRow:ar,showDevPanel:co=!1,onOpenDevConfig:Mr,rowActions:lr,hideDefaultRowActions:Ke,hideToolbarActions:Ce,customSettingsActions:Dt,jsonGuideContent:Sr,viewOptions:Ar,defaultViewMode:cr,bulkActions:Cr,hideSelectionCheckboxes:Wr,rowClickBehavior:dr="select",openModalOn:Ze,onRowClick:Lt,onRowRightClick:ve}){var Fo;const fe=pt().urmTable,[St,V]=p.useState(null),[ft,se]=p.useState(0),[st,wr]=p.useState(0),[Ct,Rr]=p.useState(null),ur=gr(),jr=((Fo=ur.dates)==null?void 0:Fo.displayFormat)??null,[Ft,kr]=p.useState(null),[Pr,_e]=p.useState(null),[ut,ee]=p.useState(null),[le,ye]=p.useState(!1),[uo,Nr]=p.useState(!1),[pr,Lr]=p.useState(null),[po,Fr]=p.useState(!1),[Kt,Vr]=p.useState(null),[Hr,_t]=p.useState(null),[je,Ge]=p.useState(null),[zr,at]=p.useState(null),Xt=p.useRef(null),$t=p.useCallback(()=>{Xt.current&&(clearTimeout(Xt.current),Xt.current=null)},[]),xe=p.useCallback(()=>{$t(),Xt.current=setTimeout(()=>at(null),200)},[$t]);p.useEffect(()=>$t,[$t]);const[me,Re]=p.useState(null),Ne=p.useMemo(()=>Ar??["list","grid"],[Ar]),[et,wt]=p.useState(()=>cr??Ne[0]??"list"),[Ot,Oo]=p.useState(!1),[Ur,Tn]=p.useState(()=>!wu("toolbar_search")),Gr=p.useRef(null),ho=p.useRef(null),[Bn,Mo]=p.useState(0);p.useLayoutEffect(()=>{const j=Gr.current;if(!j)return;Mo(j.clientWidth);const N=new ResizeObserver(oe=>{Mo(oe[0].contentRect.width)});return N.observe(j),()=>N.disconnect()},[]);const Yr=p.useCallback(()=>{ju("toolbar_search"),Tn(!1)},[]);p.useEffect(()=>{if(!Ur)return;const j=setTimeout(Yr,2e3);return()=>clearTimeout(j)},[Ur,Yr]);const Ao=p.useMemo(()=>{const j=Ct??g;return j.length>0?j.map(N=>e.find(oe=>oe.name===N)).filter(N=>N!==void 0):e},[Ct,g,e]),qr=p.useMemo(()=>Ao.filter(j=>u[j.name]!==!1),[Ao,u]),fo=p.useMemo(()=>new Set(((f==null?void 0:f.levels)??[]).map(j=>j.column)),[f]),Wo=!!(f!=null&&f.enabled&&(f!=null&&f.levels)&&f.levels.length>0),Jr=p.useMemo(()=>{if(!Wo)return qr;const j=((f==null?void 0:f.levels)??[]).map(oe=>e.find(ze=>ze.name===oe.column)).filter(oe=>oe!==void 0),N=qr.filter(oe=>!fo.has(oe.name));return[...j,...N]},[qr,Wo,fo,f,e]),{widths:Kr}=_u(Jr,x,Bn),Qt=p.useMemo(()=>e.filter(j=>u[j.name]===!1).length,[e,u]),Ro=p.useMemo(()=>e.map(j=>j.name),[e]),Xr=p.useMemo(()=>g.length===0?!1:JSON.stringify(g)!==JSON.stringify(Ro),[g,Ro]),In=p.useCallback((j,N)=>{j.preventDefault(),j.stopPropagation(),V(N),se(j.clientX),wr(x[N]||150)},[x]);p.useEffect(()=>{if(!St)return;const j=oe=>{const ze=oe.clientX-ft,Le=Math.max(100,Math.min(600,st+ze));ue==null||ue(St,Le)},N=()=>{V(null)};return document.addEventListener("mousemove",j),document.addEventListener("mouseup",N),()=>{document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",N)}},[St,ft,st,ue]);const En=p.useCallback(j=>j==null?"-":typeof j=="object"?JSON.stringify(j):typeof j=="boolean"?j?"true":"false":String(j),[]);p.useCallback(j=>{const N=n.find(oe=>oe.column===j);return N?t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[N.direction==="asc"?t.jsx($.ArrowUpward,{sx:{fontSize:14}}):t.jsx($.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:N.priority})]}):null},[n]),p.useCallback(j=>Zn(i,j)?t.jsx(o.IconButton,{size:"small",onClick:oe=>{oe.stopPropagation(),h==null||h(j)},sx:{ml:.5,p:.25,color:"primary.main","&:hover":{color:"primary.main"}},title:"Active filters on this column",children:t.jsx($.FilterList,{sx:{fontSize:14}})}):null,[i,h]);const Dn=p.useCallback(j=>{C&&C(j)},[C]),_n=p.useCallback((j,N)=>{Rr(oe=>{const Le=[...oe??(g.length>0?g:e.map(tt=>tt.name))],[nt]=Le.splice(j,1);return Le.splice(N,0,nt),Le})},[g,e]),$n=p.useCallback(()=>{Ct&&pe&&pe(Ct),Rr(null)},[Ct,pe]),On=p.useCallback(j=>{if(!C)return;const N=n.find(oe=>oe.column===j);(!N||N.direction!=="asc")&&C(j)},[C,n]),Mn=p.useCallback(j=>{if(!C)return;const N=n.find(oe=>oe.column===j);N?N.direction==="asc"&&C(j):(C(j),setTimeout(()=>C(j),0))},[C,n]),An=p.useCallback(j=>{if(!C)return;const N=n.find(oe=>oe.column===j);N&&(N.direction==="asc"?(C(j),setTimeout(()=>C(j),0)):N.direction==="desc"&&C(j))},[C,n]),Wn=p.useCallback(j=>{K&&K(j,!1)},[K]),Qr=!!(f!=null&&f.enabled&&(f!=null&&f.levels)&&f.levels.length>0),Zt=p.useMemo(()=>Tt(i),[i]),Rn=n.length>0||Zt>0||((f==null?void 0:f.enabled)??!1)||Object.values(u).some(j=>j===!1),Pn=(sr-1)*Or,Pe=r,lt=p.useMemo(()=>{const j=new Set;return bt.forEach(N=>{const oe=N==null?void 0:N.__urm_row_id__;oe!==void 0&&j.add(oe)}),j},[bt]);p.useEffect(()=>{const j=N=>{!Et||!Pt||N.target instanceof HTMLInputElement||N.target instanceof HTMLTextAreaElement||((N.ctrlKey||N.metaKey)&&N.key==="a"&&(N.preventDefault(),Et(!0,Pe)),N.key==="Escape"&&(N.preventDefault(),Pt()))};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[Et,Pt,Pe]);const mo=p.useCallback((j,N)=>{Lt==null||Lt(Pe[j],j,N),(dr==="activate"||dr==="both")&&(ee(Pe[j]),ye(!0)),dr!=="activate"&&Qe&&(N.shiftKey&&Ft!==null?(N.preventDefault(),qt&&qt(Ft,j,Pe)):(Qe(Pe[j]),kr(j)))},[Qe,Ft,qt,Pe,Lt,dr,ee,ye]),Po=p.useMemo(()=>Pe.length>0&&lt.size>0&&Pe.every(j=>lt.has(j==null?void 0:j.__urm_row_id__)),[Pe,lt]),Nn=!Po&&Pe.some(j=>lt.has(j==null?void 0:j.__urm_row_id__)),er=!!(Qe&&Et&&!Wr),mt=p.useMemo(()=>Jr,[Jr]),No=p.useMemo(()=>{const j=new Map;if(!(f!=null&&f.enabled)||!Pe)return j;let N=[];for(const oe of Pe)if(oe.__isGroupHeader||oe.isGroupHeader){const ze=oe.groupLevel??0;N[ze]=oe.groupKey,N=N.slice(0,ze+1),j.has(oe.groupKey)||j.set(oe.groupKey,[])}else if(oe.__urm_is_grouped_data_row__)for(const ze of N)ze&&j.has(ze)&&j.get(ze).push(oe);return j},[f,Pe]),Zr=p.useCallback(j=>{const N=j.groupLevel,oe=N===0?S.groupRowLevel0||"urm-group-level-0":N===1?S.groupRowLevel1||"urm-group-level-1":S.groupRowLevel2||"urm-group-level-2",ze=N===0?Me=>Me.palette.mode==="dark"?_(Me.palette.action.hover,.12):"#f1f5f9":Me=>Me.palette.mode==="dark"?_(Me.palette.action.hover,.06):"#f8fafc",Le=String(j.groupValue??"(empty)"),nt=`${j.rowCount} ${j.rowCount===1?"item":"items"}`,tt=No.get(j.groupKey)||[],ge=tt.filter(Me=>lt.has(Me==null?void 0:Me.__urm_row_id__)).length,Vt=tt.length>0&&ge===tt.length,tr=ge>0&&ge<tt.length;return t.jsxs(o.TableRow,{onClick:()=>U==null?void 0:U(j.groupKey),className:`urm-group-header-row urm-group-level-${N} ${oe} ${S.groupRow||""}`,sx:{bgcolor:ze,"&:hover":{bgcolor:Me=>_(Me.palette.text.primary,.07)},cursor:"pointer",borderTop:"1px solid",borderBottom:"1px solid",borderColor:"divider",position:"relative"},children:[er&&t.jsx(o.TableCell,{padding:"checkbox",onClick:Me=>Me.stopPropagation(),sx:{borderBottom:"1px solid",borderColor:"divider",verticalAlign:"middle",bgcolor:"inherit"},children:t.jsx(o.Checkbox,{size:"small",checked:Vt,indeterminate:tr,onChange:()=>{if(!Qe)return;const Me=!Vt;tt.forEach(hr=>{const Vo=lt.has(hr==null?void 0:hr.__urm_row_id__);Me!==Vo&&Qe(hr)})}})}),t.jsxs(o.TableCell,{colSpan:mt.length,className:`urm-group-cell ${S.groupCellFirst||""} ${S.groupCell||""}`,sx:{pl:`${N*24+16}px`,position:"relative",py:1.25,borderBottom:"1px solid",borderColor:"divider"},children:[N>0&&t.jsx(o.Box,{sx:{position:"absolute",left:`${N*24+4}px`,top:0,bottom:0,width:"1px",bgcolor:"divider"}}),t.jsxs(o.Box,{className:`urm-group-content ${S.groupContent||""}`,sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Box,{className:`urm-group-caret ${S.groupCaret||""}`,sx:{color:"text.secondary",display:"inline-flex",alignItems:"center"},children:j.isCollapsed?t.jsx($.ChevronRight,{sx:{fontSize:18}}):t.jsx($.KeyboardArrowDown,{sx:{fontSize:18}})}),t.jsx(o.Typography,{variant:"h5",className:`urm-group-title ${S.groupTitle||""}`,sx:{fontWeight:N===0?600:500,fontSize:N===0?"0.9375rem":"0.875rem",color:"text.primary",whiteSpace:"nowrap"},children:Le}),!j.isCollapsed&&t.jsx(o.Box,{className:"urm-group-column-heading-badge",sx:{px:1,py:.25,fontSize:"0.7rem",fontWeight:500,lineHeight:1,whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",bgcolor:Me=>_(Me.palette.primary.main,.1),color:"primary.main",borderRadius:"10px",border:"1px solid",borderColor:Me=>_(Me.palette.primary.main,.2),ml:.5},children:dt(j.groupColumn||"")}),!!j.__urm_is_continuation_header__&&t.jsx(o.Box,{className:"urm-group-continuation-badge",sx:{px:1,py:.25,fontSize:"0.7rem",fontWeight:500,lineHeight:1,whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",bgcolor:Me=>_(Me.palette.text.secondary,.05),color:"text.secondary",borderRadius:"10px",border:"1px dashed",borderColor:"divider",ml:.5},children:"Continued"}),t.jsx(o.Box,{className:`urm-group-count ${S.groupBadge||""} ${S.groupCount||""}`,sx:{px:1.25,py:.25,fontSize:"0.75rem",fontWeight:500,lineHeight:1,whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",bgcolor:Me=>_(Me.palette.text.secondary,.08),color:"text.secondary",borderRadius:"12px",ml:.5},children:nt}),Object.keys(j.aggregates||{}).length>0&&t.jsxs(o.Typography,{variant:"caption",className:`urm-group-aggregates ${S.groupAggregates||""}`,sx:{ml:1.5,color:"text.secondary",fontWeight:500},children:["(",Object.entries(j.aggregates).map(([Me,hr])=>Ts(hr)).filter(Boolean).join(" • "),")"]})]})]})]},j.groupKey)},[mt,er,f,e,U,S,fe,No,lt,Qe]),Lo=p.useCallback((j,N)=>{const oe=lt.has(j==null?void 0:j.__urm_row_id__),ze=Pr===N,Le=le&&(j==null?void 0:j.__urm_row_id__)===(ut==null?void 0:ut.__urm_row_id__),nt=!!(j!=null&&j.__urm_is_grouped_data_row__),tt=nt?j.__urm_group_level__??(f==null?void 0:f.levels.length)??1:0;return t.jsxs(o.TableRow,{"data-row-index":N,className:nt?`urm-data-row-grouped ${S.dataRowGrouped||""}`:"",onMouseEnter:()=>_e(N),onMouseLeave:()=>_e(null),onClick:ge=>{ge.target.closest("[data-row-action-btn]")||mo(N,ge)},onDoubleClick:()=>{Ze!=null&&Ze.includes("doubleClick")&&(ee(j),ye(!0))},onContextMenu:ge=>{ge.preventDefault(),ge.stopPropagation(),ve==null||ve(j,N,ge),at(null),Ge({mouseX:ge.clientX,mouseY:ge.clientY,row:j,rowIndex:N}),Ze!=null&&Ze.includes("rightClick")&&(ee(j),ye(!0))},sx:{cursor:"pointer",bgcolor:oe?ge=>ct(ge).bg:Le?ge=>_(ge.palette.info.main,.12):fe!=null&&fe.striped&&N%2===1?fe.stripeBg:"background.paper",transition:"background-color 0.12s ease","&:hover":{bgcolor:oe?ge=>ct(ge).hoverBg:Le?ge=>_(ge.palette.info.main,.2):ge=>`var(--highlight-hover-row, ${_(ct(ge).main,.04)})`},borderBottom:(fe==null?void 0:fe.rowDivider)??"1px solid",borderColor:"divider"},children:[er&&t.jsx(o.TableCell,{padding:"checkbox",onClick:ge=>ge.stopPropagation(),sx:{borderBottom:(fe==null?void 0:fe.rowDivider)??"1px solid",borderColor:"divider",verticalAlign:(fe==null?void 0:fe.cellAlignV)??"middle"},children:t.jsx(o.Checkbox,{size:"small",checked:oe,onChange:()=>Qe==null?void 0:Qe(j)})}),mt.map((ge,Vt)=>{const tr=Vt===0;return t.jsxs(o.TableCell,{className:nt&&tr?`urm-data-cell-grouped ${S.dataCellGrouped||""}`:"",sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",py:(fe==null?void 0:fe.rowPaddingY)??"6px",px:(fe==null?void 0:fe.cellPaddingX)??2,position:"relative",textAlign:(fe==null?void 0:fe.cellAlignH)??"left",verticalAlign:(fe==null?void 0:fe.cellAlignV)??"middle",fontSize:"0.8125rem",fontWeight:400,color:"text.primary",borderBottom:(fe==null?void 0:fe.rowDivider)??"1px solid",borderRight:fe==null?void 0:fe.colDivider,borderColor:"divider",minWidth:x[ge.name]?`${x[ge.name]}px`:`${ge.type==="date"?Math.max(fs,180):fs}px`},children:[nt&&tr&&tt>0&&t.jsx(o.Box,{sx:{position:"absolute",left:4,top:0,bottom:0,width:"1px",bgcolor:"divider"}}),t.jsx(o.Box,{sx:{display:"flex",alignItems:"center"},children:t.jsx("span",{className:`urm-item-title ${S.itemTitle||""}`,children:Ru(ge,j[ge.name],jr,Wt)})})]},ge.name)}),t.jsx(o.TableCell,{"data-row-action":"true",sx:{position:"sticky",right:0,width:0,minWidth:0,maxWidth:0,p:0,border:"none",background:"transparent",opacity:ze?1:0,transition:"opacity 0.12s ease",zIndex:10},children:t.jsx(o.Box,{sx:{position:"absolute",right:8,top:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"flex-end",zIndex:10},children:t.jsx(o.IconButton,{"data-row-action-btn":"true",size:"small",onClick:ge=>{ge.stopPropagation(),ge.preventDefault(),at(null),Ge({anchorEl:ge.currentTarget,row:j,rowIndex:N})},sx:{color:"text.secondary",opacity:ze?1:0,transition:"opacity 0.12s ease",pointerEvents:ze?"auto":"none","&:hover":{bgcolor:ge=>_(ge.palette.text.primary,.08),color:"text.primary"}},children:t.jsx($.MoreVert,{sx:{fontSize:18}})})})})]},N)},[bt,Pn,Pr,mo,Jr,x,Wt,En,rt,Nt,ar,Qe,er,ee,ye,ut,le,Ge,Qr,fo,ve,Ze,lt]);return t.jsxs(or.DndProvider,{backend:si.HTML5Backend,children:[t.jsxs(o.Box,{sx:j=>{var nt,tt,ge;const N=((ge=(tt=(nt=j.components)==null?void 0:nt.MuiCard)==null?void 0:tt.styleOverrides)==null?void 0:ge.root)||{},oe=N.border&&N.border!=="none"?N.border:"1px solid",ze=N.borderRadius!==void 0?typeof N.borderRadius=="number"?`${N.borderRadius}px`:N.borderRadius:`${j.shape.borderRadius}px`,Le=N.boxShadow&&N.boxShadow!=="none"?N.boxShadow:be(j,"cardRest");return{display:"flex",flexDirection:"column",height:"100%",bgcolor:"background.paper",border:oe,borderColor:oe!=="none"?"divider":void 0,borderRadius:ze,boxShadow:Le,overflow:"hidden"}},children:[t.jsxs(o.Box,{sx:j=>{var nt,tt,ge,Vt,tr;const N=((ge=(tt=(nt=j.components)==null?void 0:nt.MuiCardHeader)==null?void 0:tt.styleOverrides)==null?void 0:ge.root)||{},oe=(N.backgroundColor&&N.backgroundColor!=="transparent"?N.backgroundColor:void 0)??((Vt=j.tokens)==null?void 0:Vt.cardHdrHex)??((tr=j.urmTable)==null?void 0:tr.headerBg)??j.palette.background.paper,ze=N.borderBottom&&N.borderBottom!=="none"?N.borderBottom:"1px solid",Le=N.boxShadow&&N.boxShadow!=="none"?N.boxShadow:void 0;return{position:"sticky",top:0,zIndex:10,bgcolor:oe,borderBottom:ze,borderColor:ze!=="none"?"divider":void 0,boxShadow:Le,px:2,py:0,minHeight:56,display:"flex",alignItems:"center",gap:1}},children:[Je&&t.jsx(Cu,{}),$r&&_r&&Rt&&ht&&!(Ce!=null&&Ce.includes("search"))&&t.jsx(o.Tooltip,{open:Ur,title:t.jsxs(o.Box,{sx:{p:.5},children:[t.jsx(o.Typography,{variant:"caption",sx:{display:"block",fontWeight:j=>j.typography.caption.fontWeight||500,mb:.25},children:"💡 Search tip"}),t.jsx(o.Typography,{variant:"caption",children:"Type to search across all columns instantly"})]}),placement:"bottom-start",arrow:!0,PopperProps:{onClick:Yr},componentsProps:{tooltip:{sx:{bgcolor:"primary.main","& .MuiTooltip-arrow":{color:"primary.main"},maxWidth:220,cursor:"pointer",userSelect:"none"}}},children:t.jsx(o.Box,{component:"span",children:t.jsx(iu,{value:We||"",onChange:j=>{Ur&&Yr(),$r(j)},searchHistory:Yt,onAddToHistory:_r,onToggleFavourite:Rt,onDeleteHistory:ht,disabled:Je})})}),!(Ce!=null&&Ce.includes("jsonGuide"))&&t.jsx(o.Tooltip,{title:"JSON format guide",children:t.jsx(o.IconButton,{size:"small",onClick:()=>Oo(!0),sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:j=>_(j.palette.text.primary,.06),color:"text.primary"}},children:t.jsx($.InfoOutlined,{sx:{fontSize:20}})})}),z&&I&&b&&s.length>0&&t.jsx(su,{views:s||[],activeViewId:a||"",isDirty:c,onSelectView:z,onCreateView:I,onToggleDefault:E,onToggleFavorite:G,onRestoreView:Z,onPermanentDelete:O,onEditView:y,onCloneView:w,onCopyLink:P,onDeleteView:te,onPromoteToGlobal:d,onSetDefaultForAllUsers:J,isAdmin:re,hideViewMenuActions:Se,isReadOnly:Je}),c&&!Je&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25,ml:1},children:[b&&t.jsx(o.Button,{onClick:b,size:"small",variant:"contained",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",bgcolor:j=>`var(--urm-btn-save-current-bg, ${j.palette.primary.main})`,color:j=>`var(--urm-btn-save-current-color, ${j.palette.primary.contrastText})`,textTransform:"none",boxShadow:j=>be(j,"restButton"),"&:hover":{bgcolor:j=>`var(--urm-btn-save-current-hover-bg, ${j.palette.primary.dark})`,boxShadow:j=>be(j,"hoverButton")}},children:"Save current view"}),R&&t.jsx(o.Button,{onClick:R,size:"small",variant:"outlined",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",borderColor:j=>`var(--urm-btn-save-new-border, ${j.palette.primary.main})`,color:j=>`var(--urm-btn-save-new-color, ${j.palette.primary.main})`,bgcolor:j=>`var(--urm-btn-save-new-bg, ${j.palette.background.paper})`,borderWidth:"1.5px",textTransform:"none","&:hover":{borderWidth:"1.5px",borderColor:j=>`var(--urm-btn-save-new-hover-border, ${j.palette.primary.dark})`,bgcolor:j=>`var(--urm-btn-save-new-hover-bg, ${_(j.palette.primary.main,.08)})`}},children:"Save new view"}),H&&t.jsx(o.Button,{onClick:H,size:"small",variant:"contained",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",bgcolor:j=>`var(--urm-btn-discard-bg, ${_(j.palette.text.primary,.12)})`,color:j=>`var(--urm-btn-discard-color, ${j.palette.text.primary})`,textTransform:"none",boxShadow:"none","&:hover":{bgcolor:j=>`var(--urm-btn-discard-hover-bg, ${_(j.palette.text.primary,.18)})`,boxShadow:"none"}},children:"Discard"})]}),co&&Mr&&t.jsx(o.Tooltip,{title:"Developer configuration",children:t.jsx(o.IconButton,{size:"small",onClick:Mr,sx:{color:"text.secondary",borderRadius:1,border:"1px dashed",borderColor:j=>_(j.palette.text.secondary,.3),"&:hover":{bgcolor:j=>_(j.palette.warning.main,.08),borderColor:"warning.main",color:"warning.dark"}},children:t.jsx($.DisplaySettings,{sx:{fontSize:20}})})}),t.jsx(o.Box,{sx:{flexGrow:1}}),!Je&&T&&!(Ce!=null&&Ce.includes("sort"))&&t.jsx(o.Tooltip,{title:"Sort",children:t.jsxs(o.IconButton,{onClick:T,size:"small",sx:{position:"relative",color:n.length>0?"primary.main":"text.secondary",bgcolor:n.length>0?j=>Bt(j):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:n.length>0?j=>_(j.palette.primary.main,.2):j=>_(j.palette.text.primary,.06),color:n.length>0?"primary.main":"text.primary"}},children:[t.jsx($.SwapVert,{sx:{fontSize:20}}),n.length>0&&t.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:"primary.contrastText",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:n.length})]})}),!Je&&m&&!(Ce!=null&&Ce.includes("filter"))&&t.jsx(o.Tooltip,{title:"Filter",children:t.jsxs(o.IconButton,{onClick:m,size:"small",sx:{position:"relative",color:Zt>0?"primary.main":"text.secondary",bgcolor:Zt>0?j=>Bt(j):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:Zt>0?j=>_(j.palette.primary.main,.2):j=>_(j.palette.text.primary,.06),color:Zt>0?"primary.main":"text.primary"}},children:[t.jsx($.FilterList,{sx:{fontSize:20}}),Zt>0&&t.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:"primary.contrastText",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:Zt})]})}),!Je&&X&&!(Ce!=null&&Ce.includes("columns"))&&t.jsx(o.Tooltip,{title:"Show/Hide Columns",children:t.jsxs(o.IconButton,{onClick:X,size:"small",sx:{position:"relative",color:Qt>0||Xr?"primary.main":"text.secondary",bgcolor:Qt>0||Xr?j=>Bt(j):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:Qt>0||Xr?j=>_(j.palette.primary.main,.2):j=>_(j.palette.text.primary,.06),color:Qt>0||Xr?"primary.main":"text.primary"}},children:[t.jsx($.ViewColumn,{sx:{fontSize:20}}),Qt>0&&t.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:"primary.contrastText",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:Qt})]})}),Qr&&(ne||ke)&&(()=>{var oe;const j=(((oe=f==null?void 0:f.collapsedGroups)==null?void 0:oe.length)??0)>0,N=j?ne:ke;return N?t.jsx(o.Tooltip,{title:j?"Expand all groups":"Collapse all groups",children:t.jsx(o.IconButton,{onClick:N,size:"small",sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:ze=>_(ze.palette.text.primary,.06),color:"text.primary"}},children:j?t.jsx($.UnfoldMore,{sx:{fontSize:20}}):t.jsx($.UnfoldLess,{sx:{fontSize:20}})})}):null})(),Ne.length>1&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5,my:1.5}}),Ne.map(j=>{const N=et===j,oe=j==="list"?t.jsx($.TableRows,{sx:{fontSize:20}}):t.jsx($.GridView,{sx:{fontSize:20}}),ze=j==="list"?"List view":"Grid view";return t.jsx(o.Tooltip,{title:ze,children:t.jsx(o.IconButton,{size:"small",onClick:()=>wt(j),sx:{borderRadius:1,color:N?"primary.main":"text.secondary",bgcolor:N?Le=>Bt(Le):"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:N?Le=>_(Le.palette.primary.main,.2):Le=>_(Le.palette.text.primary,.06),color:N?"primary.main":"text.primary"}},children:oe})},j)})]}),!(Ce!=null&&Ce.includes("settings"))&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5,my:1.5}}),t.jsx(o.Tooltip,{title:"Settings",children:t.jsx(o.IconButton,{onClick:j=>Re(j.currentTarget),size:"small",sx:{color:"text.secondary",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:j=>_(j.palette.text.primary,.06),color:"text.primary"}},children:t.jsx($.Settings,{sx:{fontSize:20}})})})]})]}),t.jsxs(o.Popover,{open:!!me,anchorEl:me,onClose:()=>Re(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:[F&&!(Ce!=null&&Ce.includes("export"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{F(),Re(null)},disabled:l,sx:{py:1,px:2,gap:1.5},children:[t.jsx($.Download,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Export"})]}),!Je&&W&&!(Ce!=null&&Ce.includes("grouping"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{W(),Re(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.Layers,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Grouping"})]}),Q&&!(Ce!=null&&Ce.includes("auditHistory"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Q(),Re(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.History,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Audit History"})]}),De&&!(Ce!=null&&Ce.includes("scheduledReports"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{De(),Re(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.Schedule,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Scheduled Reports"})]}),Dt==null?void 0:Dt.map(j=>t.jsxs(o.MenuItem,{dense:!0,disabled:j.disabled,onClick:()=>{j.onClick(),Re(null)},sx:{py:1,px:2,gap:1.5},children:[j.icon,t.jsx(o.Typography,{variant:"body2",children:j.label})]},j.key))]}),t.jsxs(o.Box,{sx:{position:"relative",flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[Cr&&Cr.length>0&&lt.size>0&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,px:2,py:1,bgcolor:j=>ct(j).bg,borderBottom:"1px solid",borderColor:"divider"},children:[t.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:j=>j.typography.body2.fontWeight||600,mr:1},children:[lt.size," selected"]}),t.jsx(o.Button,{size:"small",onClick:()=>Pt==null?void 0:Pt(),children:"Clear"}),Cr.map(j=>{var oe,ze;const N=Array.from(bt);return(oe=j.hidden)!=null&&oe.call(j,N)?null:t.jsx(o.Button,{size:"small",variant:"outlined",startIcon:j.icon,disabled:(ze=j.disabled)==null?void 0:ze.call(j,N),onClick:()=>j.onClick(N),children:j.label},j.key)})]}),et!=="list"&&t.jsx(o.Box,{sx:{flex:1,overflowY:"auto",overflowX:"hidden",bgcolor:"action.hover"},children:t.jsx(bu,{data:Pe,visibleColumns:qr,grouping:f,selectedRowIds:bt,isGrouped:!!Qr,onToggleGroupCollapse:U,onCardClick:(j,N)=>mo(j,N),onCardDoubleClick:j=>{Ze!=null&&Ze.includes("doubleClick")&&(ee(j),ye(!0))},onCardContextMenu:(j,N,oe)=>{ve==null||ve(j,N,oe),at(null),Ge({mouseX:oe.clientX,mouseY:oe.clientY,row:j,rowIndex:N}),Ze!=null&&Ze.includes("rightClick")&&(ee(j),ye(!0))},onOpenRowMenu:(j,N,oe)=>Ge({anchorEl:oe,row:j,rowIndex:N}),onToggleSelection:j=>Qe==null?void 0:Qe(j),hideSelectionCheckboxes:Wr})}),et==="list"&&t.jsxs(o.Box,{sx:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[t.jsx(o.Box,{ref:Gr,onScroll:j=>{ho.current&&(ho.current.scrollLeft=j.target.scrollLeft)},sx:{overflowX:"auto",overflowY:"hidden",flexShrink:0,scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:t.jsxs(o.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",borderSpacing:0,width:"100%",minWidth:`${Object.values(Kr).reduce((j,N)=>j+N,0)}px`},children:[t.jsxs("colgroup",{children:[er&&t.jsx("col",{style:{width:"40px"}}),mt.map(j=>t.jsx("col",{style:{width:`${Kr[j.name]}px`}},j.name))]}),t.jsx(o.TableHead,{children:t.jsxs(o.TableRow,{sx:{bgcolor:(fe==null?void 0:fe.headerBg)??"action.hover",borderBottom:(fe==null?void 0:fe.rowDivider)??"1px solid",borderColor:"divider"},children:[er&&t.jsx(o.TableCell,{padding:"checkbox",sx:{borderBottom:(fe==null?void 0:fe.rowDivider)??"1px solid",borderColor:"divider",verticalAlign:(fe==null?void 0:fe.cellAlignV)??"middle"},children:t.jsx(o.Checkbox,{size:"small",checked:Po,indeterminate:Nn,onChange:j=>Et==null?void 0:Et(j.target.checked,Pe)})}),mt.map((j,N)=>t.jsx(cu,{column:j,index:N,sortRule:n.find(oe=>oe.column===j.name),hasFilters:Zn(i,j.name),isInSortStack:n.some(oe=>oe.column===j.name),isReadOnly:Je,hasModifications:Rn,width:x[j.name],onColumnClick:Dn,onMoveColumn:_n,onColumnDragEnd:$n,onResizeStart:In,onSortAscending:B||On,onSortDescending:v||Mn,onRemoveSort:An,onOpenFilterForColumn:h||(()=>{}),onClearFiltersForColumn:he||(()=>{}),onGroupByColumn:ie,onHideColumn:Wn,onManageColumns:X||(()=>{}),onResetLayout:ae},j.name))]})})]})}),t.jsx(o.Box,{ref:ho,onScroll:j=>{Gr.current&&(Gr.current.scrollLeft=j.target.scrollLeft)},sx:{flex:1,overflowY:"auto",overflowX:"auto",minHeight:0,bgcolor:"background.paper","&::-webkit-scrollbar":{width:8,height:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:j=>_(j.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:j=>_(j.palette.text.primary,.3)}}},children:t.jsxs(o.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",borderSpacing:0,width:"100%",minWidth:`${Object.values(Kr).reduce((j,N)=>j+N,0)}px`},children:[t.jsxs("colgroup",{children:[er&&t.jsx("col",{style:{width:"40px"}}),mt.map(j=>t.jsx("col",{style:{width:`${Kr[j.name]}px`}},j.name))]}),t.jsx(o.TableBody,{children:Pe.length===0?t.jsx(o.TableRow,{children:t.jsx(o.TableCell,{colSpan:mt.length,align:"center",sx:{py:4},children:t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})})}):Qr?Pe.map((j,N)=>j.isGroupHeader?Zr(j):Lo(j,N)):Pe.map((j,N)=>Lo(j,N))})]})})]}),br&&vt&&t.jsx(Su,{currentPage:sr,pageSize:Or,totalRows:Jt,totalFields:e.length,onPageChange:br,onPageSizeChange:vt}),!(br&&vt)&&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 ",Pe.length," ",Pe.length===1?"row":"rows"]})})]})]}),t.jsxs(o.Popover,{open:!!je,onClose:()=>{Ge(null),at(null)},anchorEl:(je==null?void 0:je.anchorEl)||null,anchorReference:je!=null&&je.anchorEl?"anchorEl":"anchorPosition",anchorPosition:je&&!je.anchorEl?{top:je.mouseY,left:je.mouseX}:void 0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:je!=null&&je.anchorEl?{vertical:"top",horizontal:"right"}:{vertical:"top",horizontal:"left"},PaperProps:{sx:{minWidth:176,py:.5,borderRadius:1.5,boxShadow:3}},children:[!(Ke!=null&&Ke.includes("view"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{je&&(ee(je.row),ye(!0)),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"View"})]}),!(Ke!=null&&Ke.includes("edit"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{je&&(Vr(je.row),_t(je.rowIndex),Fr(!0)),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.Edit,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Edit"})]}),!(Ke!=null&&Ke.includes("duplicate"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{je&&(Nt==null||Nt(je.rowIndex,je.row)),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.ContentCopy,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Duplicate"})]}),je&&(lr==null?void 0:lr.map(j=>{var N,oe;return(N=j.hidden)!=null&&N.call(j,je.row)?null:t.jsxs(o.MenuItem,{dense:!0,disabled:(oe=j.disabled)==null?void 0:oe.call(j,je.row),onClick:()=>{j.onClick(je.row,je.rowIndex),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[j.icon,t.jsx(o.Typography,{variant:"body2",children:j.label})]},j.key)})),lt.size>0&&ir&&!(Ke!=null&&Ke.includes("export"))&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.5}}),t.jsxs(o.MenuItem,{dense:!0,onMouseEnter:j=>{$t(),at(j.currentTarget)},onMouseLeave:xe,sx:{py:1,px:2,gap:1.5,justifyContent:"space-between"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx($.Download,{sx:{fontSize:18,color:"text.secondary"}}),t.jsxs(o.Typography,{variant:"body2",children:["Export Selected (",lt.size,")"]})]}),t.jsx($.ChevronRight,{sx:{fontSize:18,color:"text.secondary"}})]}),t.jsx(o.Popper,{open:!!zr,anchorEl:zr,placement:"right-start",transition:!0,sx:{zIndex:j=>j.zIndex.modal+1},modifiers:[{name:"offset",options:{offset:[0,0]}}],children:({TransitionProps:j})=>t.jsx(o.Grow,{...j,timeout:150,children:t.jsx(o.Paper,{onMouseEnter:$t,onMouseLeave:xe,sx:{minWidth:176,py:.5,borderRadius:1.5,boxShadow:3},children:t.jsxs(o.MenuList,{dense:!0,autoFocusItem:!1,children:[t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ir("csv"),at(null),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.TableChart,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"CSV"})]}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ir("excel"),at(null),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.TableChart,{sx:{fontSize:18,color:"success.main"}}),t.jsx(o.Typography,{variant:"body2",children:"Excel"})]}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ir("json"),at(null),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.DataObject,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"JSON"})]}),ur.export.allowedFormats.includes("pdf")&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ir("pdf"),at(null),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.PictureAsPdf,{sx:{fontSize:18,color:"error.main"}}),t.jsx(o.Typography,{variant:"body2",children:"PDF"})]})]})})})})]}),!(Ke!=null&&Ke.includes("delete"))&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.5}}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{je&&(Lr(je.row),Nr(!0)),Ge(null)},sx:{py:1,px:2,gap:1.5,color:"error.main"},children:[t.jsx($.Delete,{sx:{fontSize:18,color:"error.main"}}),t.jsx(o.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]})]}),t.jsx(ku,{open:le,onClose:()=>{ye(!1),ee(null)},row:ut,schema:e,reportName:it}),t.jsx(Tu,{open:po,onClose:()=>{Fr(!1),Vr(null),_t(null)},onSave:j=>{Hr!==null&&(rt==null||rt(Hr,j))},row:Kt,schema:e,reportName:it}),t.jsx(zu,{open:uo,onClose:()=>{Nr(!1),Lr(null)},onConfirm:()=>{pr!==null&&(ar==null||ar(pr))},row:pr,schema:e}),t.jsx(Js,{isOpen:Ot,onClose:()=>Oo(!1),content:Sr})]})}function Er({content:e,isDev:r=!1}){const[n,i]=p.useState(null);return t.jsxs(t.Fragment,{children:[t.jsx(o.IconButton,{size:"small",onClick:s=>i(s.currentTarget),"aria-label":`Help: ${e.title}`,sx:{p:.375,color:"text.disabled","&:hover":{color:"primary.main",bgcolor:s=>_(s.palette.primary.main,.08)}},children:t.jsx($.InfoOutlined,{sx:{fontSize:15}})}),t.jsxs(o.Popover,{open:!!n,anchorEl:n,onClose:()=>i(null),anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},PaperProps:{sx:{width:280,borderRadius:"10px",boxShadow:4,p:0,overflow:"hidden"}},children:[t.jsx(o.Box,{sx:{px:2,py:1.5,bgcolor:s=>_(s.palette.primary.main,.06)},children:t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:s=>s.typography.body2.fontWeight||600,color:"primary.main",fontSize:s=>s.typography.body2.fontSize||"0.875rem"},children:e.title})}),t.jsx(o.Divider,{}),t.jsxs(o.Box,{sx:{px:2,py:1.5,display:"flex",flexDirection:"column",gap:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{color:"text.secondary",fontSize:s=>s.typography.body2.fontSize||"0.8125rem",lineHeight:1.6},children:e.description}),e.tips&&e.tips.length>0&&t.jsx(o.Box,{component:"ul",sx:{m:0,pl:2,display:"flex",flexDirection:"column",gap:.5},children:e.tips.map((s,a)=>t.jsx(o.Box,{component:"li",sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.5},children:s},a))}),r&&e.devNote&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.5}}),t.jsxs(o.Box,{sx:{px:1.25,py:.75,borderRadius:"6px",bgcolor:s=>_(s.palette.warning.main,.08),border:"1px solid",borderColor:s=>_(s.palette.warning.main,.2)},children:[t.jsx(o.Typography,{variant:"caption",sx:{color:"warning.dark",fontWeight:s=>s.typography.caption.fontWeight||500,fontSize:s=>s.typography.caption.fontSize||"0.75rem",display:"block",mb:.25},children:"Dev note"}),t.jsx(o.Typography,{variant:"caption",sx:{color:"warning.dark",fontSize:s=>s.typography.caption.fontSize||"0.75rem",lineHeight:1.5},children:e.devNote})]})]})]})]})]})}const Dr={filter:{title:"Filter columns",description:"Narrow down rows by setting conditions on any column. Only rows matching all active filters are shown.",tips:["Add multiple conditions to combine filters (AND logic)",'Use "Contains" for partial text matches','Use "Is empty" to find missing values',"Clear all filters to return to the full dataset"],devNote:"Max filter conditions controlled by DevConfig → Filter → maxConditions. Allowed operators also configurable."},sort:{title:"Sort columns",description:"Order rows by one or more columns. Drag levels to set sort priority — the first level is applied first.",tips:["Add multiple sort levels for multi-column sorting","Drag the ⋮⋮ handle to reorder sort priority","Each level can be ascending (A→Z, 0→9) or descending"],devNote:"Max sort levels controlled by DevConfig → Sort → maxLevels."},grouping:{title:"Group data",description:"Organize rows into collapsible groups by one or more column values. Each unique value becomes a group header.",tips:["Add up to 3 nesting levels for hierarchical grouping","Click a group header to collapse or expand it","Aggregates (count) are shown on each group header","Combine grouping with filters and sort for focused views"],devNote:"Max group levels controlled by DevConfig → Grouping → maxLevels. allowNested and allowCollapse also configurable."},columns:{title:"Manage columns",description:"Control which columns are visible, their display order, and their widths.",tips:["Drag rows to reorder columns","Toggle the eye icon to show or hide a column","Drag the resize handle in the table header to resize","Reset to restore default visibility and order"],devNote:"Max visible columns and width range controlled by DevConfig → Columns."},export:{title:"Export data",description:"Download the report data as a file. Choose between CSV, Excel, or JSON format.",tips:["CSV: universal format, opens in any spreadsheet app","Excel: formatted .xlsx file with native Excel support","JSON: structured data including metadata","Export visible rows only (after filters) or all rows"],devNote:"Allowed export formats controlled by DevConfig → Export → allowedFormats."},schedule:{title:"Scheduled reports",description:"Set up automatic exports that run at a specified time — daily, weekly, or monthly.",tips:["The browser tab must remain open for the schedule to fire","Each schedule triggers a file download automatically","Add an email address to open a notification in your mail app","Pause a schedule without deleting it"],devNote:"Schedules are stored in localStorage per-report. Key: urm_schedules_{reportId}."},auditHistory:{title:"Audit history",description:"A full log of all changes made to this report — filters applied, sorts changed, views saved, exports triggered, and more.",tips:["Each entry shows the action, timestamp, and who performed it","Use audit history to trace back unexpected changes"],devNote:"Audit entries are stored per-report in IndexedDB via the persistence layer."}},Qn=40;function Nu({operator:e,onSelect:r}){return t.jsxs(o.Select,{value:e,onChange:n=>r(n.target.value),size:"small",variant:"outlined",sx:{position:"relative",zIndex:1,mt:1,width:58,height:24,fontSize:"0.6875rem",fontWeight:700,color:"primary.main",bgcolor:"background.paper",borderRadius:"6px","& .MuiSelect-select":{py:0,px:1,display:"flex",alignItems:"center"},"& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"}},children:[t.jsx(o.MenuItem,{value:"and",sx:{fontSize:"0.75rem",fontWeight:600},children:"AND"}),t.jsx(o.MenuItem,{value:"or",sx:{fontSize:"0.75rem",fontWeight:600},children:"OR"})]})}function Lu({condition:e,schema:r,availableColumns:n,devConfig:i,onUpdate:s}){const a=r.find(u=>u.name===e.column),c=p.useMemo(()=>{const u=a?nn(a.type):[],g=i.filter.allowedOperators;return g.length>0?u.filter(x=>g.includes(x.value)):u},[a,i]),l=El(e.operator);return t.jsxs(o.Box,{sx:{display:"flex",gap:1,alignItems:"center",flexWrap:"wrap"},children:[t.jsx(o.FormControl,{size:"small",sx:{minWidth:150,flex:"1 1 150px"},children:t.jsx(o.Select,{value:e.column,onChange:u=>{var f;const g=r.find(S=>S.name===u.target.value),x=g?nn(g.type):[];s({column:u.target.value,operator:((f=x[0])==null?void 0:f.value)??e.operator,value:void 0})},displayEmpty:!0,sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper"},children:n.map(u=>t.jsx(o.MenuItem,{value:u.name,sx:{fontSize:"0.875rem"},children:dt(u.name)},u.name))})}),t.jsx(o.FormControl,{size:"small",sx:{minWidth:130,flex:"1 1 130px"},children:t.jsx(o.Select,{value:e.operator,onChange:u=>s({operator:u.target.value,value:void 0}),sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper"},children:c.map(u=>t.jsx(o.MenuItem,{value:u.value,sx:{fontSize:"0.875rem"},children:u.label},u.value))})}),l&&(a==null?void 0:a.type)==="date"&&t.jsx(o.TextField,{size:"small",type:"date",value:e.value??"",onChange:u=>s({value:u.target.value}),sx:{minWidth:160,flex:"1 1 160px","& .MuiInputBase-root":{height:36,fontSize:"0.875rem"}}}),l&&(a==null?void 0:a.type)!=="date"&&t.jsx(o.TextField,{size:"small",type:(a==null?void 0:a.type)==="number"?"number":"text",value:e.value??"",onChange:u=>s({value:(a==null?void 0:a.type)==="number"?Number(u.target.value):u.target.value}),placeholder:"Value…",sx:{minWidth:160,flex:"1 1 160px","& .MuiInputBase-root":{height:36,fontSize:"0.875rem"}}})]})}function ta({group:e,depth:r,schema:n,availableColumns:i,devConfig:s,maxConditions:a,totalConditions:c,onChange:l}){const u=c>=a;return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[e.children.map((g,x)=>t.jsxs(o.Box,{sx:{display:"flex",alignItems:"stretch",gap:1},children:[t.jsxs(o.Box,{sx:{width:Qn,flexShrink:0,position:"relative",display:"flex",justifyContent:"center"},children:[x<e.children.length-1&&t.jsx(o.Box,{sx:{position:"absolute",top:0,bottom:0,left:"50%",width:"1px",bgcolor:"divider"}}),x>0&&t.jsx(Nu,{operator:e.operator,onSelect:f=>l(S=>ci(S,e.id,f))}),x>0&&t.jsx(o.Box,{sx:{position:"absolute",top:13,left:"50%",width:Qn/2,height:"1px",bgcolor:"divider"}})]}),t.jsx(o.Box,{sx:{flex:1,minWidth:0,pt:x>0?1:0},children:Xe(g)?t.jsx(Fu,{group:g,depth:r+1,schema:n,availableColumns:i,devConfig:s,maxConditions:a,totalConditions:c,onChange:l}):t.jsx(Lu,{condition:g,schema:n,availableColumns:i,devConfig:s,onUpdate:f=>l(S=>li(S,g.id,f))})}),t.jsx(o.IconButton,{size:"small",onClick:()=>l(f=>di(f,g.id)),sx:{mt:x>0?1:.25,color:"text.secondary",flexShrink:0},children:t.jsx($.Close,{sx:{fontSize:16}})})]},g.id)),t.jsxs(o.Box,{sx:{display:"flex",gap:2,pl:`${Qn}px`},children:[t.jsx(o.Button,{size:"small",disabled:u||i.length===0,onClick:()=>l(g=>{var x,f,S;return lo(g,e.id,{id:ao(),column:((x=i[0])==null?void 0:x.name)??"",operator:((S=nn(((f=i[0])==null?void 0:f.type)??"string")[0])==null?void 0:S.value)??"equals"})}),sx:{fontSize:"0.8125rem",color:"primary.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",textDecoration:"underline"}},children:"+ Add condition"}),t.jsx(o.Button,{size:"small",disabled:u,onClick:()=>l(g=>lo(g,e.id,At())),sx:{fontSize:"0.8125rem",color:"text.secondary",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",textDecoration:"underline"}},children:"+ Add group"})]})]})}function Fu(e){return t.jsx(o.Box,{sx:{position:"relative",border:"1px solid",borderColor:r=>_(r.palette.primary.main,.2),borderLeft:"3px solid",borderLeftColor:"primary.main",bgcolor:r=>_(r.palette.primary.main,r.palette.mode==="dark"?.06:.03),borderRadius:"8px",p:1.25},children:t.jsx(ta,{...e})})}function Vu({schema:e,filters:r,onReplaceFilters:n,onClose:i,focusColumn:s,onOpenDevConfig:a}){const[c,l]=p.useState(r??At()),u=gr(),g=p.useMemo(()=>e.filter(T=>T.type!=="mixed"&&T.type!=="null"&&T.type!=="array"&&T.type!=="object"),[e]);p.useEffect(()=>{var h;const T=r??At();if(s&&T.children.length===0){const z=e.find(I=>I.name===s);if(z){l(lo(T,T.id,{id:ao(),column:s,operator:((h=nn(z.type)[0])==null?void 0:h.value)??"equals"}));return}}l(T)},[r,s,e]);const x=Tt(c),f=u.filter.maxConditions,S=p.useCallback(T=>{l(h=>T(h))},[]),C=p.useMemo(()=>JSON.stringify(c)!==JSON.stringify(r??At()),[c,r]),B=p.useCallback(()=>{n(c),i()},[c,n,i]),v=p.useCallback(()=>{l(r??At()),i()},[r,i]),m=p.useCallback(()=>{n(At()),i()},[n,i]);return t.jsx(o.Box,{onClick:v,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:T=>_(T.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:T=>T.zIndex.modal,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:T=>T.stopPropagation(),elevation:0,sx:{position:"relative",width:640,maxWidth:"calc(100vw - 120px)",maxHeight:"min(620px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:T=>ot(T),bgcolor:"background.paper",outline:"none",boxShadow:T=>de(T).paper.boxShadow,border:T=>de(T).paper.border,overflow:"hidden",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,bgcolor:T=>de(T).header.backgroundColor,borderBottom:T=>de(T).header.borderBottom,boxShadow:T=>de(T).header.boxShadow,flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:T=>T.typography.h6.fontSize||"1.125rem",fontWeight:T=>T.typography.h6.fontWeight||500,color:T=>T.typography.h6.color||"text.primary",lineHeight:1.5},children:"Filter columns"}),t.jsx(Er,{content:Dr.filter,isDev:process.env.NODE_ENV==="development"}),a&&t.jsx(o.IconButton,{onClick:a,size:"small",title:"Dev config",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.Settings,{sx:{fontSize:18}})})]}),t.jsx(o.IconButton,{onClick:v,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.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:T=>_(T.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:T=>_(T.palette.text.primary,.3)}}},children:[x===0&&t.jsxs(o.Typography,{variant:"body2",sx:{color:"text.disabled",fontSize:T=>T.typography.body2.fontSize||"0.875rem",mb:2},children:["No conditions yet — add one below to start filtering",s?` on "${dt(s)}"`:"","."]}),t.jsx(ta,{group:c,depth:0,schema:e,availableColumns:g,devConfig:u,maxConditions:f,totalConditions:x,onChange:S}),x>=f&&t.jsxs(o.Typography,{variant:"caption",sx:{display:"block",mt:1.5,color:"warning.dark",fontSize:T=>T.typography.caption.fontSize||"0.75rem",fontWeight:T=>T.typography.caption.fontWeight||500},children:["Filter limit reached — maximum ",f," conditions allowed. Remove one to add another."]})]}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",alignItems:"center",gap:1.5,justifyContent:"space-between",flexShrink:0,bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:m,disabled:x===0,sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"},"&.Mui-disabled":{color:"text.disabled"}},children:"Clear all"}),t.jsxs(o.Box,{sx:{display:"flex",gap:1.5},children:[t.jsx(o.Button,{onClick:v,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:T=>`${T.shape.borderRadius}px`,"&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:B,disabled:!C,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:T=>`${T.shape.borderRadius}px`,boxShadow:T=>be(T,"restButton"),"&:hover":{bgcolor:"primary.dark"},"&.Mui-disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Apply filter"})]})]})]})})}const ms="SORT_RULE";function Hu({rule:e,index:r,onToggleDirection:n,onRemove:i,onMove:s}){const a=p.useRef(null),[{handlerId:c},l]=or.useDrop({accept:ms,collect(x){return{handlerId:x.getHandlerId()}},hover(x,f){var h;if(!a.current)return;const S=x.index,C=r;if(S===C)return;const B=(h=a.current)==null?void 0:h.getBoundingClientRect(),v=(B.bottom-B.top)/2,m=f.getClientOffset(),T=((m==null?void 0:m.y)??0)-B.top;S<C&&T<v||S>C&&T>v||(s(S,C),x.index=C)}}),[{isDragging:u},g]=or.useDrag({type:ms,item:()=>({index:r}),collect:x=>({isDragging:x.isDragging()})});return g(l(a)),t.jsxs(o.Box,{ref:a,"data-handler-id":c,sx:{display:"flex",alignItems:"center",gap:1.25,px:2,py:1.25,borderRadius:"8px",bgcolor:"background.paper",border:"1px solid divider",opacity:u?.4:1,cursor:"move",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:"action.hover",borderColor:"divider",boxShadow:x=>be(x,"restButtonLight"),transform:"translateY(-1px)"}},children:[t.jsx(o.Chip,{label:e.priority,size:"small",sx:{width:26,height:26,fontSize:"0.75rem",fontWeight:600,bgcolor:"primary.main",color:"background.paper",boxShadow:x=>`0 1px 2px 0 ${_(x.palette.primary.main,.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:"text.secondary"}}),t.jsx(o.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}}),t.jsx(o.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}})]}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:x=>x.typography.body2.fontSize||"0.875rem",fontWeight:x=>x.typography.body2.fontWeight||400,color:"text.primary",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:x=>n(r,x.target.value),sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider",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:[t.jsx(o.MenuItem,{value:"asc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:x=>Bt(x),"&:hover":{bgcolor:x=>_(x.palette.primary.main,.2)}}},children:"Ascending"}),t.jsx(o.MenuItem,{value:"desc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:x=>Bt(x),"&:hover":{bgcolor:x=>_(x.palette.primary.main,.2)}}},children:"Descending"})]})}),t.jsx(o.IconButton,{onClick:()=>i(r),size:"small",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{color:"error.main",bgcolor:x=>_(x.palette.error.main,.08),transform:"scale(1.1)"}},children:t.jsx($.Close,{sx:{fontSize:18}})})]})}function Uu({schema:e,sortStack:r,onUpdateSortStack:n,onClose:i,onOpenDevConfig:s}){const[a,c]=p.useState(""),[l,u]=p.useState([]);p.useEffect(()=>{u([...r])},[r]);const g=p.useMemo(()=>JSON.stringify(l)!==JSON.stringify(r),[l,r]),x=gr(),f=p.useCallback(z=>{if(!z||l.length>=x.sort.maxLevels)return;const I={column:z,direction:"asc",priority:l.length+1};u([...l,I]),c(""),setTimeout(()=>{var b;return(b=document.activeElement)==null?void 0:b.blur()},0)},[l,x.sort.maxLevels]),S=p.useCallback(z=>{const b=l.filter((R,H)=>H!==z).map((R,H)=>({...R,priority:H+1}));u(b)},[l]),C=p.useCallback((z,I)=>{const b=[...l];b[z]={...b[z],direction:I},u(b)},[l]),B=p.useCallback((z,I)=>{const b=[...l],[R]=b.splice(z,1);b.splice(I,0,R);const H=b.map((E,G)=>({...E,priority:G+1}));u(H)},[l]),v=p.useCallback(()=>{n([]),i()},[n,i]),m=p.useCallback(()=>{n(l),i()},[l,n,i]),T=p.useCallback(()=>{u([...r]),c(""),i()},[r,i]),h=e.filter(z=>!l.some(I=>I.column===z.name));return t.jsx(or.DndProvider,{backend:si.HTML5Backend,children:t.jsx(o.Box,{onClick:T,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:z=>_(z.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:z=>z.zIndex.modal,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:z=>z.stopPropagation(),elevation:0,sx:{position:"relative",width:480,maxWidth:"calc(100vw - 120px)",maxHeight:"min(440px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:z=>ot(z),bgcolor:"background.paper",outline:"none",boxShadow:z=>de(z).paper.boxShadow,border:z=>de(z).paper.border,overflow:"hidden",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,bgcolor:z=>de(z).header.backgroundColor,borderBottom:z=>de(z).header.borderBottom,boxShadow:z=>de(z).header.boxShadow,flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:z=>z.typography.h6.fontSize||"1.125rem",fontWeight:z=>z.typography.h6.fontWeight||500,color:z=>z.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Sort columns"}),t.jsx(Er,{content:Dr.sort,isDev:process.env.NODE_ENV==="development"}),s&&t.jsx(o.IconButton,{onClick:s,size:"small",title:"Dev config",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.Settings,{sx:{fontSize:18}})})]}),t.jsx(o.IconButton,{onClick:T,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.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:z=>_(z.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:z=>_(z.palette.text.primary,.3)}}},children:[t.jsxs(o.Box,{sx:{mb:2.5},children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:z=>z.typography.caption.fontSize||"0.6875rem",fontWeight:z=>z.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add sort level"}),t.jsxs(o.FormControl,{size:"small",fullWidth:!0,disabled:l.length>=x.sort.maxLevels,children:[t.jsx(o.InputLabel,{sx:{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},children:"Select column..."}),t.jsx(o.Select,{value:a,onChange:z=>f(z.target.value),label:"Select column...",sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-disabled":{bgcolor:"action.hover"}},children:h.map(z=>t.jsx(o.MenuItem,{value:z.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:I=>Bt(I),"&:hover":{bgcolor:I=>_(I.palette.primary.main,.2)}}},children:dt(z.name)},z.name))})]}),l.length>=x.sort.maxLevels&&t.jsxs(o.Typography,{variant:"caption",sx:{mt:.75,display:"block",color:"warning.dark",fontSize:z=>z.typography.caption.fontSize||"0.75rem",fontWeight:z=>z.typography.caption.fontWeight||500},children:["Maximum ",x.sort.maxLevels," sort levels allowed"]})]}),l.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:z=>z.typography.caption.fontSize||"0.6875rem",fontWeight:z=>z.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:["Sorted sequence (",l.length,"/",x.sort.maxLevels,")"]}),t.jsx(o.Button,{onClick:v,sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto",minHeight:"auto",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"}},children:"Clear all"})]}),t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:l.map((z,I)=>t.jsx(Hu,{rule:z,index:I,onToggleDirection:C,onRemove:S,onMove:B},`${z.column}-${I}`))})]})]}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:T,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:z=>`${z.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:m,variant:"contained",disabled:!g||l.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:z=>`${z.shape.borderRadius}px`,boxShadow:z=>be(z,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:z=>be(z,"hoverButton")},"&:active":{boxShadow:z=>be(z,"pressedButton"),transform:"translateY(1px)"}},children:"Apply sort"})]})]})})})}const Ko=50;function xs({currentSnapshot:e,onSave:r,onClose:n,isEditMode:i=!1,initialName:s="",initialDescription:a="",initialIsDefault:c=!1,atViewLimit:l=!1,maxViews:u=10}){const[g,x]=p.useState(s),[f,S]=p.useState(!1),[C,B]=p.useState(a),[v,m]=p.useState(c),T=()=>{if(!g.trim()){S(!0);return}if(g.trim().length>Ko){S(!0);return}r(g.trim(),C.trim(),v),n()},h=I=>{I.key==="Enter"&&!I.shiftKey?T():I.key==="Escape"&&n()},z=()=>i&&s?`Update ${s} view`:"Create New Report View";return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:I=>({mt:8,borderRadius:ot(I),...de(I).paper})},children:[t.jsxs(o.DialogTitle,{sx:I=>({display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,...de(I).header}),children:[z(),t.jsx(o.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:t.jsx($.Close,{sx:{fontSize:20}})})]}),t.jsx(o.DialogContent,{children:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2,pt:1},children:[l&&!i&&t.jsxs(o.Alert,{severity:"warning",sx:{borderRadius:"8px"},children:["You have reached the maximum of ",u," saved views. Delete an existing view before creating a new one."]}),t.jsx(o.TextField,{label:"View Name",required:!0,value:g,onChange:I=>{I.target.value.length<=Ko&&x(I.target.value),f&&I.target.value.trim()&&S(!1)},onKeyDown:h,placeholder:"e.g., Active Users",autoFocus:!0,fullWidth:!0,size:"small",disabled:l&&!i,inputProps:{maxLength:Ko},error:f&&!g.trim(),helperText:f&&!g.trim()?"View name is required":`${g.length} / ${Ko}`}),t.jsx(o.TextField,{label:"Description (optional)",value:C,onChange:I=>B(I.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:I=>I.typography.body2.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:[Tt(e.filters)," filter",Tt(e.filters)!==1?"s":""]}),t.jsxs("li",{children:["Sorting: ",Ga(e.sortStack)]}),t.jsx("li",{children:"Column order & visibility"})]})]}),!i&&t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{checked:v,onChange:I=>m(I.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 divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:[t.jsx(o.Button,{onClick:n,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:I=>`${I.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:T,variant:"contained",disabled:l&&!i,startIcon:t.jsx($.Save,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:.875,minHeight:36,borderRadius:I=>`${I.shape.borderRadius}px`,boxShadow:I=>be(I,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:I=>be(I,"hoverButton")},"&:active":{boxShadow:I=>be(I,"pressedButton"),transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"text.disabled"}},children:i?"Save Changes":"Create Report View"})]})]})}function Gu({viewName:e,onConfirm:r,onCancel:n}){return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:i=>({borderRadius:ot(i),maxHeight:"min(480px, calc(100vh - 180px))",my:"auto",...de(i).paper})},children:[t.jsxs(o.DialogTitle,{sx:i=>({display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,...de(i).header}),children:["Delete View",t.jsx(o.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:t.jsx($.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($.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",borderColor:"divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:[t.jsx(o.Button,{onClick:n,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:i=>`${i.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"action.selected",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:r,variant:"contained",color:"error",sx:{fontSize:"0.875rem",px:3,py:.875,minHeight:36,borderRadius:i=>`${i.shape.borderRadius}px`,boxShadow:i=>be(i,"restButton"),transition:"all 0.2s ease","&:hover":{boxShadow:i=>be(i,"hoverButton")},"&:active":{boxShadow:i=>be(i,"pressedButton"),transform:"translateY(1px)"}},children:"Delete View"})]})]})}const gs="COLUMN";function Yu({column:e,index:r,isVisible:n,width:i,minColumnWidth:s,maxColumnWidth:a,canToggleOn:c,onToggleVisibility:l,onWidthChange:u,moveColumn:g}){const x=p.useRef(null),[f,S]=p.useState(i.toString());p.useEffect(()=>{S(i.toString())},[i]);const[{handlerId:C},B]=or.useDrop({accept:gs,collect(b){return{handlerId:b.getHandlerId()}},hover(b,R){var w;if(!x.current)return;const H=b.index,E=r;if(H===E)return;const G=(w=x.current)==null?void 0:w.getBoundingClientRect(),Z=(G.bottom-G.top)/2,O=R.getClientOffset(),y=((O==null?void 0:O.y)??0)-G.top;H<E&&y<Z||H>E&&y>Z||(g(H,E),b.index=E)}}),[{isDragging:v},m]=or.useDrag({type:gs,item:()=>({index:r}),collect:b=>({isDragging:b.isDragging()})});m(B(x));const T=()=>{const b=parseInt(f);if(isNaN(b)){S(i.toString()),u(e.name,i);return}const R=Math.max(s,Math.min(a,b));S(R.toString()),u(e.name,R)},h=b=>{if(b===""||/^\d+$/.test(b)){S(b);const R=parseInt(b);if(!isNaN(R)&&R>=s){const H=Math.min(a,R);u(e.name,H)}}},z=b=>{b.key==="Enter"&&(b.preventDefault(),T(),b.target.blur())},I=b=>({string:"primary.main",number:"success.main",boolean:"secondary.main",array:"info.main",object:"error.main",null:"text.secondary",mixed:"text.secondary"})[b]||"text.secondary";return t.jsxs(o.TableRow,{ref:x,"data-handler-id":C,sx:{opacity:v?.4:1,bgcolor:n?"background.paper":"action.hover",transition:"opacity 0.15s ease","&:hover":{bgcolor:n?"action.hover":"action.selected"},cursor:"move",height:56,borderBottom:"1px solid divider"},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:"text.secondary",cursor:"grab",opacity:.6,transition:"opacity 0.2s ease","&:hover":{opacity:1},"&:active":{cursor:"grabbing"}},children:t.jsx($.DragIndicator,{sx:{fontSize:20}})}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:b=>b.typography.body2.fontWeight||400,fontSize:b=>b.typography.body2.fontSize||"0.875rem",color:n?"text.primary":"text.secondary"},children:dt(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:`${I(e.type)}15`,color:I(e.type),border:`1px solid ${I(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:"number",value:f,onChange:b=>h(b.target.value),onBlur:T,onKeyDown:z,placeholder:"150",size:"small",inputProps:{min:s,max:a,step:10},sx:{width:90,"& .MuiOutlinedInput-root":{height:32,fontSize:"0.8125rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputBase-input":{py:.5,px:1.25,color:"text.primary"},"& input[type=number]::-webkit-inner-spin-button":{opacity:1},"& input[type=number]::-webkit-outer-spin-button":{opacity:1}}}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:b=>b.typography.caption.fontSize||"0.75rem",color:"text.secondary"},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:()=>l(e.name,!n),disabled:!n&&!c,title:n?"Hide column":c?"Show column":"Max visible columns reached",size:"small",sx:{p:.75,color:n?"primary.main":"text.secondary",transition:"all 0.2s ease","&:hover:not(:disabled)":{bgcolor:"action.hover",color:n?"primary.dark":"primary.main"},"&:disabled":{opacity:.5,cursor:"not-allowed"}},children:n?t.jsx($.Visibility,{sx:{fontSize:20}}):t.jsx($.VisibilityOff,{sx:{fontSize:20}})}),t.jsx(o.Chip,{label:n?"Visible":"Hidden",size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:500,bgcolor:n?b=>_(b.palette.success.main,.12):"action.selected",color:n?"success.main":"text.secondary","& .MuiChip-label":{px:1}}})]})})]})}function qu({schema:e,columnVisibility:r,columnOrder:n,columnWidths:i={},views:s=[],activeViewId:a="",onUpdateColumnVisibility:c,onUpdateColumnOrder:l,onUpdateColumnWidth:u,onResetLayout:g,onClose:x}){const f=gr(),[S,C]=p.useState(!1),[B,v]=p.useState(n),[m,T]=p.useState(i),[h,z]=p.useState("all");p.useEffect(()=>{v(n)},[n]),p.useEffect(()=>{T(i)},[i]);const I=(w,P)=>{T(te=>({...te,[w]:P})),u==null||u(w,P)},b=(w,P)=>{const te=[...B],[d]=te.splice(w,1);te.splice(P,0,d),v(te),l(te)},R=()=>{g(),C(!1)},E=B.map(w=>e.find(P=>P.name===w)).filter(w=>w!==void 0).filter(w=>{const P=r[w.name]??!0;return h==="active"?P:h==="hidden"?!P:!0}),G=Object.values(r).filter(w=>w).length,Z=e.length,O=s.find(w=>w.id===a),y=p.useMemo(()=>{if(!O)return!1;const w=O.snapshot,P=w.columnVisibility??{},te=JSON.stringify(r)!==JSON.stringify(P),d=w.columnOrder??[],J=n??[],re=JSON.stringify(J)!==JSON.stringify(d)&&!(J.length===0&&d.length===0),Se=w.columnWidths??{},F=JSON.stringify(m)!==JSON.stringify(Se);return te||re||F},[O,r,n,m]);return t.jsx(or.DndProvider,{backend:si.HTML5Backend,children:t.jsx(o.Box,{onClick:x,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:w=>_(w.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:w=>w.zIndex.modal,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:w=>w.stopPropagation(),elevation:0,sx:{position:"relative",width:720,maxWidth:"calc(100vw - 120px)",maxHeight:"min(760px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:w=>ot(w),bgcolor:"background.paper",outline:"none",boxShadow:w=>de(w).paper.boxShadow,border:w=>de(w).paper.border,overflow:"hidden",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,flexShrink:0,bgcolor:w=>de(w).header.backgroundColor,borderBottom:w=>de(w).header.borderBottom,boxShadow:w=>de(w).header.boxShadow},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[t.jsx(o.Box,{sx:{flex:1},children:t.jsxs(o.Typography,{variant:"h6",sx:{fontSize:w=>w.typography.h6.fontSize||"1.125rem",fontWeight:w=>w.typography.h6.fontWeight||500,color:w=>w.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:["Manage columns",t.jsx(Er,{content:Dr.columns,isDev:process.env.NODE_ENV==="development"})]})}),t.jsx(o.IconButton,{onClick:x,size:"small",sx:{ml:2,p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.Tabs,{value:h,onChange:(w,P)=>z(P),sx:{minHeight:36,mt:.5,"& .MuiTabs-indicator":{bgcolor:w=>ct(w).main,height:3}},children:[t.jsx(o.Tab,{label:"All",value:"all",sx:{minHeight:36,py:.75,px:2,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary",borderRadius:"8px 8px 0 0","&.Mui-selected":{borderBottomColor:"text.primary",fontWeight:600,bgcolor:w=>ct(w).hoverBg},"&:hover":{color:"text.primary",bgcolor:w=>ct(w).bg}}}),t.jsx(o.Tab,{label:"Visible",value:"active",sx:{minHeight:36,py:.75,px:2,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary",borderRadius:"8px 8px 0 0","&.Mui-selected":{color:"text.primary",fontWeight:600,bgcolor:w=>ct(w).hoverBg},"&:hover":{color:"text.primary",bgcolor:w=>ct(w).bg}}}),t.jsx(o.Tab,{label:"Hidden",value:"hidden",sx:{minHeight:36,py:.75,px:2,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary",borderRadius:"8px 8px 0 0","&.Mui-selected":{color:"text.primary",fontWeight:600,bgcolor:w=>ct(w).hoverBg},"&:hover":{color:"text.primary",bgcolor:w=>ct(w).bg}}})]})]}),t.jsx(o.Box,{sx:{flex:1,overflow:"auto","&::-webkit-scrollbar":{width:8,height:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:w=>_(w.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:w=>_(w.palette.text.primary,.3)}}},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:"text.secondary",bgcolor:"background.paper",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid divider"},children:"Column name"}),t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"0.6875rem",color:"text.secondary",bgcolor:"background.paper",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid divider"},children:"Type"}),t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"0.6875rem",color:"text.secondary",bgcolor:"background.paper",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid divider"},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:["Width",t.jsx(o.Tooltip,{title:`Column width in pixels (min: ${f.columns.minColumnWidth}px, max: ${f.columns.maxColumnWidth}px)`,arrow:!0,placement:"top",children:t.jsx($.InfoOutlined,{sx:{fontSize:14,color:"text.secondary",cursor:"help"}})})]})}),t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"0.6875rem",color:"text.secondary",bgcolor:"background.paper",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid divider"},children:"Visibility"})]})}),t.jsx(o.TableBody,{children:E.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:w=>w.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"No columns in this category"})})}):E.map((w,P)=>{const te=r[w.name]??!0,d=te||G<f.columns.maxVisible;return t.jsx(Yu,{column:w,index:P,isVisible:te,width:m[w.name]||170,minColumnWidth:f.columns.minColumnWidth,maxColumnWidth:f.columns.maxColumnWidth,canToggleOn:d,onToggleVisibility:c,onWidthChange:I,moveColumn:b},w.name)})})]})}),t.jsx(o.Box,{sx:{px:3,py:1,borderTop:"1px solid divider",bgcolor:"background.default",flexShrink:0},children:t.jsxs(o.Typography,{variant:"body2",sx:{fontSize:w=>w.typography.body2.fontSize||"0.8125rem",color:"text.secondary"},children:[G," of ",Z," columns visible • Drag to reorder"]})}),t.jsx(o.Box,{sx:{px:3,py:1.75,borderTop:"1px solid divider",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0,bgcolor:"action.hover"},children:t.jsx(o.Button,{onClick:()=>C(!0),disabled:!y,variant:"outlined",startIcon:t.jsx($.Undo,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",color:"text.secondary",borderColor:"divider",px:2.5,py:.875,minHeight:36,borderRadius:w=>`${w.shape.borderRadius}px`,"&:hover":{borderColor:"primary.main",bgcolor:"background.paper",color:"primary.main"},"&.Mui-disabled":{color:"text.disabled",borderColor:"divider"}},children:"Reset"})}),S&&t.jsx(o.Box,{onClick:()=>C(!1),sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:w=>_(w.palette.common.black,.5),display:"flex",alignItems:"center",justifyContent:"center",zIndex:w=>w.zIndex.tooltip},children:t.jsxs(o.Paper,{onClick:w=>w.stopPropagation(),elevation:0,sx:{width:400,maxWidth:"90vw",borderRadius:w=>_o(w),bgcolor:"background.paper",boxShadow:w=>de(w).paper.boxShadow,border:w=>de(w).paper.border},children:[t.jsxs(o.Box,{sx:{px:3,py:2.5},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1rem",fontWeight:500,color:"text.primary",mb:1.5},children:"Reset column layout?"}),t.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."})]}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:()=>C(!1),variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,borderRadius:w=>`${w.shape.borderRadius}px`,"&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:R,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"error.main",color:"background.paper",px:3,py:1,borderRadius:w=>`${w.shape.borderRadius}px`,boxShadow:w=>be(w,"pressedButton"),"&:hover":{bgcolor:"error.dark",boxShadow:w=>be(w,"hoverButton")},"&:active":{boxShadow:w=>be(w,"pressedButton"),transform:"translateY(1px)"}},children:"Reset layout"})]})]})})]})})})}function Ju({schema:e,grouping:r,onApply:n,onClose:i,onOpenDevConfig:s}){var H;const[a,c]=p.useState(r||{enabled:!1,levels:[],collapsedGroups:[]}),[l,u]=p.useState(""),[g,x]=p.useState(null),f=p.useMemo(()=>Pa(e),[e]),S=p.useMemo(()=>f.filter(E=>!a.levels.some((G,Z)=>G.column===E.name&&Z!==g)),[f,a.levels,g]),C=gr(),B=a.levels.length<C.grouping.maxLevels&&S.length>0&&(C.grouping.allowNested||a.levels.length===0),v=p.useCallback(E=>{!B||!E||(c({...a,levels:[...a.levels,{column:E}],enabled:!0}),u(""),setTimeout(()=>{var G;return(G=document.activeElement)==null?void 0:G.blur()},0))},[B,a]),m=p.useCallback(E=>{const G=a.levels.filter((Z,O)=>O!==E);if(G.length===0){n(null),i();return}c({...a,levels:G,enabled:G.length>0})},[a,n,i]),T=p.useCallback(E=>{x(E),u(a.levels[E].column)},[a.levels]),h=p.useCallback(()=>{if(g===null||!l)return;const E=[...a.levels];E[g]={column:l},c({...a,levels:E}),x(null),u("")},[g,l,a]),z=p.useCallback(()=>{x(null),u("")},[]),I=p.useCallback((E,G)=>{const Z=G==="up"?E-1:E+1;if(Z<0||Z>=a.levels.length)return;const O=[...a.levels],[y]=O.splice(E,1);O.splice(Z,0,y),c({...a,levels:O})},[a]),b=p.useCallback(()=>{n(null),i()},[n,i]),R=p.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:E=>_(E.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:E=>E.zIndex.modal,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:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(560px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:E=>ot(E),bgcolor:"background.paper",outline:"none",boxShadow:E=>de(E).paper.boxShadow,border:E=>de(E).paper.border,overflow:"hidden",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,bgcolor:E=>de(E).header.backgroundColor,borderBottom:E=>de(E).header.borderBottom,boxShadow:E=>de(E).header.boxShadow,flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:E=>E.typography.h6.fontSize||"1.125rem",fontWeight:E=>E.typography.h6.fontWeight||500,color:E=>E.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Group configuration"}),t.jsx(Er,{content:Dr.grouping,isDev:process.env.NODE_ENV==="development"}),s&&t.jsx(o.IconButton,{onClick:s,size:"small",title:"Dev config",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.Settings,{sx:{fontSize:18}})})]}),t.jsx(o.IconButton,{onClick:i,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.Close,{sx:{fontSize:20}})})]}),t.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:1,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:E=>_(E.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:E=>_(E.palette.text.primary,.3)}}},children:t.jsxs(o.Stack,{spacing:2.5,children:[g===null&&t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:E=>E.typography.caption.fontSize||"0.6875rem",fontWeight:E=>E.typography.caption.fontWeight||600,color:"text.secondary",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:l,onChange:E=>v(E.target.value),disabled:!B,displayEmpty:!0,sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-disabled":{bgcolor:"action.hover"}},children:[t.jsx(o.MenuItem,{value:"",sx:{fontSize:"0.875rem",color:"text.secondary"},children:"Select a column..."}),S.map(E=>t.jsxs(o.MenuItem,{value:E.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:G=>Bt(G),"&:hover":{bgcolor:G=>_(G.palette.primary.main,.2)}}},children:[dt(E.name)," (",E.type.toUpperCase(),")"]},E.name))]})}),a.levels.length>=C.grouping.maxLevels&&t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",textAlign:"center",mt:1.5,fontSize:E=>E.typography.caption.fontSize||"0.75rem",color:"text.secondary"},children:"Maximum group levels (3) reached"}),f.length===0&&t.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{textAlign:"center",py:2,fontSize:E=>E.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"No groupable columns available. Only STRING and BOOLEAN columns can be grouped."})]}),g!==null&&t.jsxs(o.Alert,{severity:"warning",sx:{borderRadius:"8px",border:E=>`1px solid ${_(E.palette.warning.main,.5)}`,bgcolor:E=>_(E.palette.warning.main,.12),"& .MuiAlert-icon":{color:"warning.main"}},children:[t.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:E=>E.typography.body2.fontWeight||500,mb:1.5,fontSize:E=>E.typography.body2.fontSize||"0.875rem",color:"text.primary"},children:["Edit Group Level ",g+1]}),t.jsx(o.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:t.jsxs(o.Select,{value:l,onChange:E=>u(E.target.value),sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"}},children:[t.jsx(o.MenuItem,{value:"",sx:{fontSize:"0.875rem"},children:"Select a column..."}),t.jsxs(o.MenuItem,{value:a.levels[g].column,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:E=>Bt(E)}},children:[a.levels[g].column," (",(H=e.find(E=>E.name===a.levels[g].column))==null?void 0:H.type.toUpperCase(),")"]}),S.filter(E=>E.name!==a.levels[g].column).map(E=>t.jsxs(o.MenuItem,{value:E.name,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:G=>Bt(G)}},children:[dt(E.name)," (",E.type.toUpperCase(),")"]},E.name))]})}),t.jsxs(o.Stack,{direction:"row",spacing:1.5,children:[t.jsx(o.Button,{onClick:h,disabled:!l,variant:"contained",fullWidth:!0,size:"small",sx:{fontSize:"0.875rem",bgcolor:"warning.main",color:"background.paper",py:.875,boxShadow:"none","&:hover":{bgcolor:"warning.dark",boxShadow:E=>be(E,"pressedButton")}},children:"Save"}),t.jsx(o.Button,{onClick:z,variant:"outlined",fullWidth:!0,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",borderColor:"divider",py:.875,"&:hover":{borderColor:"text.secondary",bgcolor:"action.hover"}},children:"Cancel"})]})]}),a.levels.length>0&&g===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:E=>E.typography.caption.fontSize||"0.6875rem",fontWeight:E=>E.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:"Active group levels"}),t.jsx(o.Button,{onClick:b,size:"small",sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"}},children:"Clear all"})]}),t.jsx(o.Stack,{spacing:1.5,children:a.levels.map((E,G)=>{const Z=e.find(O=>O.name===E.column);return t.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:"action.hover",borderColor:"divider",boxShadow:O=>be(O,"pressedButtonLight")}},children:[t.jsx(o.Chip,{label:`L${G+1}`,size:"small",sx:{width:40,height:28,fontWeight:600,fontSize:"0.75rem",bgcolor:"primary.main",color:"background.paper",boxShadow:O=>`0 1px 2px 0 ${_(O.palette.primary.main,.3)}`}}),t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:O=>O.typography.body2.fontWeight||500,fontSize:O=>O.typography.body2.fontSize||"0.875rem",color:"text.primary"},children:E.column}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:O=>O.typography.caption.fontSize||"0.75rem",color:"text.secondary"},children:Z==null?void 0:Z.type.toUpperCase()})]}),t.jsxs(o.Stack,{direction:"row",spacing:.5,children:[t.jsx(o.IconButton,{size:"small",onClick:()=>I(G,"up"),disabled:G===0,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"divider"}},children:t.jsx($.KeyboardArrowUp,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{size:"small",onClick:()=>I(G,"down"),disabled:G===a.levels.length-1,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"divider"}},children:t.jsx($.KeyboardArrowDown,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{size:"small",onClick:()=>T(G),sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover",color:"primary.main"}},children:t.jsx($.Edit,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{size:"small",onClick:()=>m(G),sx:{color:"text.secondary","&:hover":{bgcolor:O=>_(O.palette.error.main,.08),color:"error.main"}},children:t.jsx($.Delete,{sx:{fontSize:18}})})]})]},G)})})]})]})}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:i,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:E=>`${E.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:R,variant:"contained",disabled:a.levels.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:E=>`${E.shape.borderRadius}px`,boxShadow:E=>be(E,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:E=>be(E,"hoverButton")},"&:active":{boxShadow:E=>be(E,"pressedButton"),transform:"translateY(1px)"}},children:"Apply grouping"})]})]})})}function Ku({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($.Warning,{sx:{fontSize:20}}),action:t.jsx(o.IconButton,{size:"small",onClick:n,sx:{color:"warning.main"},children:t.jsx($.Close,{sx:{fontSize:20}})}),sx:{alignItems:"flex-start"},children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:i=>i.typography.h6.fontWeight||600,fontSize:i=>i.typography.h6.fontSize||"1rem",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($.Save,{sx:{fontSize:14}}),size:"small",children:"Save View & Export"}),t.jsx(o.Button,{onClick:e,variant:"contained",color:"warning",startIcon:t.jsx($.Download,{sx:{fontSize:14}}),size:"small",children:"Export Anyway"})]})]})})}const ys=[{key:"1h",label:"Last 1 Hour",ms:3600*1e3},{key:"24h",label:"Last 24 Hours",ms:1440*60*1e3},{key:"7d",label:"Last 7 Days",ms:10080*60*1e3},{key:"30d",label:"Last 30 Days",ms:720*60*60*1e3},{key:"all",label:"All Time",ms:null}];function Xu(e,r){if(r===null)return e.length;const n=Date.now()-r;return e.filter(i=>new Date(i.timestamp).getTime()>=n).length}function Qu(e,r){if(r===null)return[];const n=Date.now()-r;return e.filter(i=>new Date(i.timestamp).getTime()<n)}function Zu({auditHistory:e,onClose:r,onClearAuditHistory:n}){const i=pt(),s=i.palette,[a,c]=p.useState("1h"),[l,u]=p.useState(!1),g=[...e].sort((B,v)=>new Date(v.timestamp).getTime()-new Date(B.timestamp).getTime()),x=ys.find(B=>B.key===a),f=Xu(e,x.ms),S=()=>u(!0),C=()=>{n&&(n(Qu(e,x.ms)),u(!1))};return t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{onClick:r,sx:{position:"fixed",inset:0,bgcolor:_(s.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:i.zIndex.modal,animation:"fadeIn 0.2s ease","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:B=>B.stopPropagation(),elevation:0,sx:{width:520,maxWidth:"calc(100vw - 48px)",maxHeight:"min(700px, calc(100vh - 80px))",display:"flex",flexDirection:"column",borderRadius:ot(i),bgcolor:"background.paper",overflow:"hidden",...de(i).paper,animation:"slideIn 0.2s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.96) translateY(-8px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{px:2.5,py:1.75,display:"flex",alignItems:"center",justifyContent:"space-between",gap:1.5,flexShrink:0,...de(i).header},children:[t.jsxs(o.Box,{sx:{minWidth:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.Typography,{sx:{fontSize:B=>B.typography.body1.fontSize||"0.9375rem",fontWeight:B=>B.typography.h6.fontWeight||600,color:"text.primary"},children:"Audit History"}),t.jsx(Er,{content:Dr.auditHistory,isDev:process.env.NODE_ENV==="development"})]}),t.jsxs(o.Typography,{sx:{fontSize:B=>B.typography.caption.fontSize||"0.75rem",color:"text.secondary",mt:.125},children:[g.length," event",g.length!==1?"s":""," recorded"]})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,flexShrink:0},children:[n&&e.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Select,{value:a,onChange:B=>c(B.target.value),size:"small",variant:"outlined",sx:{fontSize:"0.75rem",height:30,minWidth:120,"& .MuiSelect-select":{py:.375,px:1,fontSize:"0.75rem"},"& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:_(s.text.primary,.3)}},children:ys.map(B=>t.jsx(o.MenuItem,{value:B.key,sx:{fontSize:"0.8125rem"},children:B.label},B.key))}),t.jsx(o.Button,{size:"small",variant:"outlined",color:"error",startIcon:t.jsx($.DeleteSweepOutlined,{sx:{fontSize:14}}),onClick:S,sx:{fontSize:"0.75rem",borderRadius:"7px",px:1.25,height:30,whiteSpace:"nowrap",borderColor:_(s.error.main,.5),"&:hover":{bgcolor:_(s.error.main,.06),borderColor:"error.main"}},children:"Clear Logs"})]}),t.jsx(o.IconButton,{onClick:r,size:"small",sx:{color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.Close,{sx:{fontSize:17}})})]})]}),t.jsx(o.Box,{sx:{flex:1,overflowY:"auto",px:2,py:1.5,bgcolor:_(s.text.primary,.012),"&::-webkit-scrollbar":{width:5},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:_(s.text.primary,.14),borderRadius:3}},children:g.length===0?t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8,gap:1,textAlign:"center"},children:[t.jsx($.AccessTime,{sx:{fontSize:44,color:"text.disabled",opacity:.5}}),t.jsx(o.Typography,{sx:{fontSize:B=>B.typography.body1.fontSize||"0.9375rem",color:"text.secondary",fontWeight:B=>B.typography.body2.fontWeight||500},children:"No audit events yet"}),t.jsx(o.Typography,{sx:{fontSize:B=>B.typography.body2.fontSize||"0.8125rem",color:"text.disabled"},children:"Changes to this report will appear here"})]}):t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:g.map(B=>{const v=hu(i,B.feature),{summary:m,detail:T}=sl(B);return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.25,px:1.5,py:1.25,borderRadius:"10px",bgcolor:"background.paper",border:"1px solid",borderColor:"divider",transition:"border-color 0.15s","&:hover":{borderColor:_(s.text.primary,.18)}},children:[t.jsx(o.Chip,{label:cl(B.feature),size:"small",sx:{height:20,fontSize:"0.5625rem",fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",bgcolor:_(v,.1),color:v,border:`1px solid ${_(v,.22)}`,flexShrink:0,mt:.125,"& .MuiChip-label":{px:.75}}}),t.jsxs(o.Box,{sx:{flex:1,minWidth:0},children:[t.jsx(o.Typography,{sx:{fontSize:"0.8125rem",fontWeight:500,color:"text.primary",lineHeight:1.45,wordBreak:"break-word"},children:m}),T&&t.jsx(o.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.25,lineHeight:1.4},children:T}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mt:.5,flexWrap:"wrap"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.375},children:[t.jsx($.AccessTime,{sx:{fontSize:11,color:"text.disabled"}}),t.jsx(o.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:dl(B.timestamp)})]}),B.user&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.375},children:[t.jsx($.Person,{sx:{fontSize:11,color:"text.disabled"}}),t.jsx(o.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:B.user})]})]})]})]},B.id)})})})]})}),t.jsxs(o.Dialog,{open:l,onClose:()=>u(!1),maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:_o(i),...de(i).paper}},children:[t.jsxs(o.DialogContent,{sx:{pt:3,pb:2,px:3},children:[t.jsx(o.Box,{sx:{width:44,height:44,borderRadius:"12px",bgcolor:_(s.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx($.WarningAmberOutlined,{sx:{fontSize:22,color:"error.main"}})}),t.jsx(o.Typography,{sx:{fontSize:B=>B.typography.body1.fontSize||"0.9375rem",fontWeight:B=>B.typography.h6.fontWeight||600,color:"text.primary",mb:1},children:"Clear Audit Logs"}),t.jsxs(o.Typography,{sx:{fontSize:B=>B.typography.body2.fontSize||"0.8125rem",color:"text.secondary",lineHeight:1.65},children:["You are about to permanently remove"," ",t.jsxs(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:[f," audit record",f!==1?"s":""]})," ",x.key==="all"?"from all time":`from the ${x.label.toLowerCase()}`,". This action cannot be undone."]})]}),t.jsx(o.Divider,{}),t.jsxs(o.DialogActions,{sx:{px:2.5,py:1.5,gap:1},children:[t.jsx(o.Button,{onClick:()=>u(!1),variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),t.jsxs(o.Button,{onClick:C,variant:"contained",color:"error",startIcon:t.jsx($.DeleteSweepOutlined,{sx:{fontSize:14}}),sx:{fontSize:"0.8125rem",borderRadius:"7px",px:2},children:["Clear ",f," Record",f!==1?"s":""]})]})]})]})}function ep({onSave:e,onClose:r}){const[n,i]=p.useState(""),[s,a]=p.useState(""),[c,l]=p.useState(""),[u,g]=p.useState([]),[x,f]=p.useState(""),[S,C]=p.useState(""),B=b=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(b),v=()=>{const b=c.trim();if(b){if(!B(b)){C("Please enter a valid email address");return}if(u.includes(b)){C("This email is already added");return}g([...u,b]),l(""),C("")}},m=b=>{g(u.filter(R=>R!==b))},T=b=>{b.key==="Enter"&&(b.preventDefault(),v())},h=()=>{if(!n.trim()){f("Preset name is required");return}e(n.trim(),s.trim(),u.length>0?u:void 0)},z=b=>{i(b),x&&f("")},I=b=>{l(b),S&&C("")};return t.jsx(o.Box,{onClick:r,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:b=>_(b.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:b=>b.zIndex.modal,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:b=>b.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(480px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:b=>ot(b),bgcolor:"background.paper",outline:"none",boxShadow:b=>de(b).paper.boxShadow,border:b=>de(b).paper.border,overflow:"hidden",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,bgcolor:b=>de(b).header.backgroundColor,borderBottom:b=>de(b).header.borderBottom,boxShadow:b=>de(b).header.boxShadow,flexShrink:0},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:b=>b.typography.h6.fontSize||"1.125rem",fontWeight:b=>b.typography.h6.fontWeight||500,color:b=>b.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Create shareable preset"}),t.jsx(o.IconButton,{onClick:r,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.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:b=>_(b.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:b=>_(b.palette.text.primary,.3)}}},children:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[t.jsx(o.Alert,{severity:"info",icon:t.jsx($.Info,{sx:{fontSize:20}}),sx:{borderRadius:"8px",border:b=>`1px solid ${_(b.palette.primary.main,.3)}`,bgcolor:b=>Bt(b),"& .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."}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:b=>b.typography.body2.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."}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:b=>b.typography.caption.fontSize||"0.6875rem",fontWeight:b=>b.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Preset name *"}),t.jsx(o.TextField,{required:!0,value:n,onChange:b=>z(b.target.value),placeholder:"e.g., Q4 Active Users Report",error:!!x,helperText:x,autoFocus:!0,fullWidth:!0,size:"small",sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"divider"},"&: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}}})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:b=>b.typography.caption.fontSize||"0.6875rem",fontWeight:b=>b.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Description (optional)"}),t.jsx(o.TextField,{value:s,onChange:b=>a(b.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:"divider"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputBase-input":{py:1.25,color:"text.primary",lineHeight:1.6}}})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:b=>b.typography.caption.fontSize||"0.6875rem",fontWeight:b=>b.typography.caption.fontWeight||600,color:"text.secondary",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:b=>I(b.target.value),onKeyPress:T,placeholder:"Enter email address",error:!!S,helperText:S,fullWidth:!0,size:"small",InputProps:{startAdornment:t.jsx($.Email,{sx:{fontSize:18,color:"text.secondary",mr:1}})},sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"divider"},"&: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}}}),t.jsx(o.Button,{onClick:v,variant:"outlined",startIcon:t.jsx($.Add,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",color:"primary.main",borderColor:"divider",px:2,py:1.25,minHeight:40,borderRadius:b=>`${b.shape.borderRadius}px`,flexShrink:0,"&:hover":{borderColor:"primary.main",bgcolor:"action.hover"}},children:"Add"})]}),u.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1,mt:1.5},children:u.map(b=>t.jsx(o.Chip,{label:b,onDelete:()=>m(b),deleteIcon:t.jsx($.Delete,{sx:{fontSize:16}}),sx:{bgcolor:R=>Bt(R),color:"primary.main",fontSize:"0.8125rem",height:28,"& .MuiChip-deleteIcon":{color:"primary.main","&:hover":{color:"primary.dark"}}}},b))}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary",mt:1,display:"block",lineHeight:1.5},children:u.length>0?`An email with the shareable link will be sent to ${u.length} recipient${u.length>1?"s":""}`:"Add email addresses to send the shareable link automatically"})]})]})}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:r,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:b=>`${b.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:h,variant:"contained",startIcon:t.jsx($.Share,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:b=>`${b.shape.borderRadius}px`,boxShadow:b=>be(b,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:b=>be(b,"hoverButton")},"&:active":{boxShadow:b=>be(b,"pressedButton"),transform:"translateY(1px)"}},children:"Create & share"})]})]})})}function tp({presetName:e,onClear:r}){return t.jsx(o.Chip,{icon:t.jsx($.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($.Close,{sx:{fontSize:14}})}),sx:{bgcolor: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 rp({presets:e,reportId:r,onOpenPreset:n,onDeletePreset:i,onClose:s}){const a=c=>new Date(c).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});return t.jsx(o.Box,{onClick:s,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:c=>_(c.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:c=>c.zIndex.modal,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 - 200px))",display:"flex",flexDirection:"column",borderRadius:c=>ot(c),bgcolor:"background.paper",outline:"none",boxShadow:c=>de(c).paper.boxShadow,border:c=>de(c).paper.border,overflow:"hidden",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,bgcolor:c=>de(c).header.backgroundColor,borderBottom:c=>de(c).header.borderBottom,boxShadow:c=>de(c).header.boxShadow,flexShrink:0},children:[t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:c=>c.typography.h6.fontSize||"1.125rem",fontWeight:c=>c.typography.h6.fontWeight||500,color:c=>c.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Manage Presets"}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:c=>c.typography.caption.fontSize||"0.8125rem",color:"text.secondary",mt:.5,display:"block"},children:[e.length," saved ",e.length===1?"preset":"presets"]})]}),t.jsx(o.IconButton,{onClick:s,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.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:"divider",borderRadius:4,"&:hover":{bgcolor:c=>_(c.palette.text.primary,.2)}}},children:e.length===0?t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8},children:[t.jsx($.Share,{sx:{fontSize:48,color:"divider",mb:2}}),t.jsx(o.Typography,{variant:"body1",sx:{fontSize:c=>c.typography.body2.fontSize||"0.875rem",color:"text.secondary",textAlign:"center"},children:"No presets created yet"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:c=>c.typography.body2.fontSize||"0.8125rem",color:"text.disabled",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(c=>t.jsxs(o.Paper,{elevation:0,sx:{p:2.5,border:"1px solid divider",borderRadius:"8px",bgcolor:"background.paper",transition:"all 0.2s ease","&:hover":{borderColor:"divider",boxShadow:l=>be(l,"restButtonLight")}},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:l=>l.typography.body1.fontSize||"0.9375rem",fontWeight:l=>l.typography.h6.fontWeight||500,color:"text.primary",mb:.5},children:c.name}),c.description&&t.jsx(o.Typography,{variant:"body2",sx:{fontSize:l=>l.typography.body2.fontSize||"0.8125rem",color:"text.secondary",lineHeight:1.5},children:c.description})]})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:2},children:[t.jsx(o.Chip,{label:`Created ${a(c.createdAt)}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"action.hover",color:"text.secondary","& .MuiChip-label":{px:1}}}),t.jsx(o.Chip,{label:`By ${c.createdBy}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"action.hover",color:"text.secondary","& .MuiChip-label":{px:1}}})]}),t.jsx(o.Divider,{sx:{my:1.5,borderColor:"divider"}}),t.jsx(o.Box,{sx:{display:"flex",gap:1},children:t.jsx(o.Button,{onClick:()=>i(c.id,c.name),variant:"outlined",size:"small",startIcon:t.jsx($.Delete,{sx:{fontSize:16}}),sx:{fontSize:"0.8125rem",color:"error.main",borderColor:"divider",px:1.5,py:.75,borderRadius:l=>`${l.shape.borderRadius}px`,"&:hover":{borderColor:"error.main",bgcolor:l=>_(l.palette.error.main,.04)}},children:"Delete"})})]},c.id))})}),t.jsx(o.Box,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end",display:"flex"},children:t.jsx(o.Button,{onClick:s,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",px:3,py:.875,minHeight:36,borderRadius:c=>`${c.shape.borderRadius}px`,boxShadow:c=>be(c,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:c=>be(c,"hoverButton")},"&:active":{boxShadow:c=>be(c,"pressedButton"),transform:"translateY(1px)"}},children:"Close"})})]})})}const ra={maxFileSizeBytes:2*1024*1024,maxFileSizeHardBytes:3*1024*1024,maxRows:1e4,maxRowsHard:5e4,maxImageColumns:5},op=[/^https?:\/\/.*\.(jpg|jpeg|png|gif|webp|svg|avif|bmp)/i,/^data:image\//i,/^\/.*\.(jpg|jpeg|png|gif|webp|svg)/i],np=[/image/i,/photo/i,/avatar/i,/thumbnail/i,/picture/i,/logo/i,/icon/i,/banner/i];function ip(e,r){const n=[];for(const i of e){if(i.type!=="string")continue;const s=np.some(l=>l.test(i.name));let a=!1;const c=r.slice(0,10).map(l=>l[i.name]).filter(l=>typeof l=="string"&&l.length>0);c.length>0&&(a=c.filter(u=>op.some(g=>g.test(u))).length/c.length>.6),(s||a)&&n.push(i.name)}return n}function zn(e,r){if(e.length===0||r.length===0)return 0;const n=e.slice(0,Math.min(50,e.length)),s=r.map(c=>{const l=n.map(g=>String(g[c]??"")).filter(g=>g.length>0);if(l.length===0)return 5;const u=l.reduce((g,x)=>g+x.length,0);return Math.ceil(u/l.length)+1}).reduce((c,l)=>c+l,0)+1;return r.reduce((c,l)=>c+l.length+1,0)+s*e.length}function sp(e,r){const n=zn(e,r);return Math.ceil(n*3.5)}function ap(e,r){const n=zn(e,r);return Math.ceil(n*.7)}function lp(e,r){const n=zn(e,r);return Math.ceil(n*2)}function cp(e,r,n){switch(e){case"csv":return zn(r,n);case"excel":return ap(r,n);case"json":return sp(r,n);case"pdf":return lp(r,n)}}function bs(e,r){return Math.ceil(e/r)}function dp(e,r,n,i,s=ra){const a=[],c=cp(e,r,n),l=r.length;if(l>s.maxRowsHard){const x=bs(l,s.maxRows);a.push({type:"row_count",severity:"error",message:`Export blocked: ${l.toLocaleString()} rows exceeds the maximum of ${s.maxRowsHard.toLocaleString()}`,detail:`Consider using filters to reduce the dataset before exporting, or split into ${x} smaller exports of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:x,value:l,limit:s.maxRowsHard})}else if(l>s.maxRows){const x=bs(l,s.maxRows);a.push({type:"row_count",severity:"warning",message:`Large export: ${l.toLocaleString()} rows`,detail:`This is a large export that may take a moment to complete. For faster results, consider splitting into ${x} smaller export${x>1?"s":""} of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:x,value:l,limit:s.maxRows})}if(c>s.maxFileSizeHardBytes?a.push({type:"file_size",severity:"error",message:`File size blocked: estimated ${wo(c)} exceeds the ${wo(s.maxFileSizeHardBytes)} limit`,detail:"Reduce the number of rows or columns and try again. Applying filters before exporting is the most effective way to reduce file size.",value:c,limit:s.maxFileSizeHardBytes}):c>s.maxFileSizeBytes&&a.push({type:"file_size",severity:"warning",message:`Large file: estimated ${wo(c)}`,detail:`This exceeds the recommended ${wo(s.maxFileSizeBytes)} size. The download will still proceed but may be slow on some connections.`,value:c,limit:s.maxFileSizeBytes}),e!=="excel"){const x=ip(i.filter(f=>n.includes(f.name)),r);if(x.length>0){const f=x.length>s.maxImageColumns;a.push({type:"image_columns",severity:f?"error":"warning",message:`Image column${x.length>1?"s":""} detected: ${x.map(S=>`"${S.replace(/_/g," ")}"`).join(", ")}`,detail:f?`Exporting ${x.length} image columns may produce a very large file. Consider hiding these columns before exporting.`:"Image URL columns are included in the export as plain text links — not embedded images.",value:x.length,limit:s.maxImageColumns})}}const u=a.some(x=>x.severity==="error"),g=a.some(x=>x.severity==="warning");return{violations:a,hasBlockingViolation:u,hasWarning:g,estimatedBytes:c}}function wo(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function up({violation:e}){const n=pt().palette,i=e.severity==="error",s=i?n.error.main:n.warning.main,a=_(i?n.error.main:n.warning.main,.06),c=i?_(n.error.main,.25):_(n.warning.main,.3),l=i?$.ErrorOutline:$.WarningAmberOutlined;return t.jsxs(o.Box,{sx:{display:"flex",gap:1.25,p:1.5,borderRadius:"10px",bgcolor:a,border:"1px solid",borderColor:c},children:[t.jsx(l,{sx:{fontSize:17,color:s,flexShrink:0,mt:.125}}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{sx:{fontSize:u=>u.typography.body2.fontSize||"0.8125rem",fontWeight:u=>u.typography.body2.fontWeight||600,color:i?"error.main":"warning.dark",lineHeight:1.4},children:e.message}),e.detail&&t.jsx(o.Typography,{sx:{fontSize:u=>u.typography.caption.fontSize||"0.75rem",color:"text.secondary",mt:.375,lineHeight:1.5},children:e.detail}),e.suggestedBatches&&e.suggestedBatches>1&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,mt:.75},children:[t.jsx($.SplitscreenOutlined,{sx:{fontSize:14,color:"text.secondary"}}),t.jsxs(o.Typography,{sx:{fontSize:u=>u.typography.caption.fontSize||"0.75rem",color:"text.secondary",fontWeight:u=>u.typography.body2.fontWeight||500},children:["Suggestion: split into ",e.suggestedBatches," exports"]})]})]})]})}function pp({format:e}){const r=pt(),n={csv:{color:r.palette.primary.main,bg:r.palette.primary.main,label:"CSV"},excel:{color:r.palette.success.main,bg:r.palette.success.main,label:"XLSX"},json:{color:r.palette.text.secondary,bg:r.palette.text.secondary,label:"JSON"},pdf:{color:r.palette.error.main,bg:r.palette.error.main,label:"PDF"}}[e];return t.jsxs(o.Box,{sx:{width:44,height:52,position:"relative",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",mb:1},children:[t.jsxs("svg",{width:"38",height:"46",viewBox:"0 0 38 46",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("path",{d:"M5 2C3.34315 2 2 3.34315 2 5V41C2 42.6569 3.34315 44 5 44H33C34.6569 44 36 42.6569 36 41V13L25 2H5Z",fill:r.palette.background.paper,stroke:n.color,strokeWidth:"2.5",strokeLinejoin:"round"}),t.jsx("path",{d:"M24 2V13H36",fill:_(r.palette.text.primary,.05),stroke:n.color,strokeWidth:"2.5",strokeLinejoin:"round"})]}),t.jsx(o.Box,{sx:{position:"absolute",bottom:8,left:3,right:3,bgcolor:n.bg,color:r.palette.primary.contrastText,fontSize:"0.625rem",fontWeight:800,py:.25,borderRadius:"3px",textAlign:"center",letterSpacing:"0.05em"},children:n.label})]})}function vs({checked:e}){const r=pt();return t.jsx(o.Box,{sx:{width:20,height:20,borderRadius:"50%",border:e?`2px solid var(--urm-export-card-selected-border, ${r.palette.primary.main})`:`2px solid var(--urm-export-radio-border, ${r.palette.divider})`,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:r.palette.background.paper,transition:"all 0.15s ease",flexShrink:0},children:e&&t.jsx(o.Box,{sx:{width:10,height:10,borderRadius:"50%",bgcolor:`var(--urm-export-card-selected-border, ${r.palette.primary.main})`}})})}function hp({totalRows:e,visibleRows:r,hasGrouping:n,visibleColumnsCount:i,totalColumnsCount:s,schema:a,sampleRows:c=[],allRows:l=[],processedRows:u=[],initialFormat:g,initialScope:x="visible",initialColumnScope:f="visible",classTokens:S={},onExport:C,onClose:B}){const v=pt(),m=v.palette,T=gr(),h=p.useMemo(()=>{var ue,pe,K,he,ae;const J=((K=(pe=(ue=v.components)==null?void 0:ue.MuiCard)==null?void 0:pe.styleOverrides)==null?void 0:K.root)||{},re=J.border&&J.border!=="none"?J.border:(he=v.tokens)!=null&&he.cardBodyBorder&&v.tokens.cardBodyBorder!=="none"?v.tokens.cardBodyBorder:m.divider,Se=J.borderRadius!==void 0?typeof J.borderRadius=="number"?`${J.borderRadius}px`:J.borderRadius:`${v.shape.borderRadius}px`,F=J.boxShadow&&J.boxShadow!=="none"?J.boxShadow:((ae=v.tokens)==null?void 0:ae.cardBodyShadow)||be(v,"menu"),X=ct(v);return{sectionBorder:`var(--urm-export-section-border, ${re})`,sectionTitleColor:`var(--urm-export-section-title-color, ${m.text.primary})`,sectionTitleBg:`var(--urm-export-section-title-bg, ${m.background.paper})`,cardBg:`var(--urm-export-card-bg, ${m.background.paper})`,cardBorder:`var(--urm-export-card-border, ${re})`,cardRadius:Se,cardShadow:F,cardHoverBg:`var(--urm-export-card-hover-bg, ${m.mode==="dark"?_(m.common.white,.08):_(m.common.black,.04)})`,cardSelectedBg:`var(--urm-export-card-selected-bg, ${_(X.main,m.mode==="dark"?.16:.08)})`,cardSelectedBorder:`var(--urm-export-card-selected-border, ${X.main})`,cardSelectedColor:`var(--urm-export-card-selected-color, ${m.mode==="dark"?m.primary.light:m.primary.main})`,primaryBtnBg:`var(--urm-export-primary-btn-bg, ${m.primary.main})`,primaryBtnHoverBg:`var(--urm-export-primary-btn-hover-bg, ${m.primary.dark})`,primaryBtnColor:`var(--urm-export-primary-btn-color, ${m.primary.contrastText})`,sectionPadding:`var(--urm-export-section-padding, ${v.spacing(2)})`,optionGap:`var(--urm-export-option-gap, ${v.spacing(1.5)})`}},[m,v]),z=g||T.export.allowedFormats[0]||"csv",[I,b]=p.useState(z),[R,H]=p.useState(x),[E,G]=p.useState(f),Z=R==="visible"?r:e,O=E==="visible"?i:s,y=p.useMemo(()=>R==="visible"?u.length>0?u:new Array(r):l.length>0?l:new Array(e),[R,r,e,u,l]),w=p.useMemo(()=>E==="all"?a.map(J=>J.name):a.map(J=>J.name).slice(0,i),[E,a,i]),P=p.useMemo(()=>dp(I,y,w,a,ra),[I,y,w,a]),te=()=>{P.hasBlockingViolation||(C({format:I,scope:R,columnScope:E}),B())},d={csv:"CSV",excel:"Excel (.xlsx)",json:"JSON",pdf:"PDF"};return t.jsx(o.Box,{onClick:B,className:`urm-export-backdrop ${S.modalBackdrop||""}`,sx:{position:"fixed",inset:0,bgcolor:_(m.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:v.zIndex.modal,animation:"fadeIn 0.2s ease","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:J=>J.stopPropagation(),elevation:0,className:`urm-export-paper ${S.modalPaper||""}`,sx:{width:540,maxWidth:"calc(100vw - 32px)",maxHeight:"min(760px, calc(100vh - 48px))",display:"flex",flexDirection:"column",borderRadius:ot(v),bgcolor:h.sectionTitleBg,overflow:"hidden",border:`1px solid ${h.cardBorder}`,boxShadow:h.cardShadow,animation:"slideIn 0.2s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.96) translateY(-8px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{className:`urm-export-header ${S.modalHeader||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,pt:2.5,pb:1.5,flexShrink:0,bgcolor:J=>de(J).header.backgroundColor,borderBottom:J=>de(J).header.borderBottom,boxShadow:J=>de(J).header.boxShadow},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Typography,{className:`urm-export-title ${S.modalTitle||""}`,sx:{fontSize:"1.125rem",fontWeight:700,color:m.text.primary},children:"Export Report"}),t.jsx(Er,{content:Dr.export,isDev:process.env.NODE_ENV==="development"})]}),t.jsx(o.IconButton,{onClick:B,size:"small",className:`urm-export-close ${S.modalCloseButton||""}`,sx:{color:m.text.secondary,borderRadius:"50%","&:hover":{bgcolor:m.action.hover,color:m.text.primary}},children:t.jsx($.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.Box,{className:`urm-export-content ${S.modalContent||""}`,sx:{flex:1,overflowY:"auto",px:3,pb:2.5,pt:.5,display:"flex",flexDirection:"column",gap:h.optionGap,"&::-webkit-scrollbar":{width:6},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:_(m.text.primary,.15),borderRadius:3}},children:[P.violations.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:P.violations.map((J,re)=>t.jsx(up,{violation:J},re))}),t.jsxs(o.Box,{className:`urm-export-section ${S.sectionContainer||""}`,sx:{position:"relative",border:`1.5px solid ${h.sectionBorder}`,borderRadius:"12px",p:h.sectionPadding,pt:2.25,bgcolor:h.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${S.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:h.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:h.sectionTitleColor,lineHeight:1,zIndex:1},children:"Choose File Format"}),t.jsx(o.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:h.optionGap},children:[{id:"csv",title:"CSV",info:"Comma-separated values, compatible with Excel",allowed:T.export.allowedFormats.includes("csv")},{id:"excel",title:"Excel (.xlsx)",info:"Native Excel format with formatting support",allowed:T.export.allowedFormats.includes("excel")},{id:"json",title:"JSON",info:"Structured data with metadata and filters",allowed:T.export.allowedFormats.includes("json")},{id:"pdf",title:"PDF",info:"Print-ready PDF document",allowed:T.export.allowedFormats.includes("pdf")}].filter(J=>J.allowed).map(J=>{const re=I===J.id;return t.jsxs(o.Box,{onClick:()=>b(J.id),className:`urm-export-format-card ${re?S.formatCardSelected||"":S.formatCard||""}`,sx:{position:"relative",display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",p:1.75,borderRadius:h.cardRadius,border:re?`2px solid ${h.cardSelectedBorder}`:`1px solid ${h.cardBorder}`,boxShadow:re?void 0:h.cardShadow,bgcolor:re?h.cardSelectedBg:h.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:re?h.cardSelectedBorder:_(m.text.primary,.25),bgcolor:re?h.cardSelectedBg:h.cardHoverBg}},children:[re&&t.jsx(o.Box,{sx:{position:"absolute",top:8,right:8,width:20,height:20,borderRadius:"50%",bgcolor:h.cardSelectedBorder,color:m.primary.contrastText,display:"flex",alignItems:"center",justifyContent:"center",boxShadow:`0 2px 4px ${_(m.primary.main,.3)}`},children:t.jsx($.Check,{sx:{fontSize:13,strokeWidth:2}})}),t.jsx(pp,{format:J.id}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.Typography,{sx:{fontSize:"0.875rem",fontWeight:700,color:re?h.cardSelectedColor:m.text.primary},children:J.title}),t.jsx(o.Tooltip,{title:J.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:Se=>Se.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:m.text.secondary,"&:hover":{color:m.text.primary}},children:t.jsx($.InfoOutlined,{sx:{fontSize:13}})})})]})]},J.id)})})]}),t.jsxs(o.Box,{className:`urm-export-section ${S.sectionContainer||""}`,sx:{position:"relative",border:`1.5px solid ${h.sectionBorder}`,borderRadius:"12px",p:h.sectionPadding,pt:2.25,bgcolor:h.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${S.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:h.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:h.sectionTitleColor,lineHeight:1,zIndex:1},children:"Select Rows Range"}),t.jsx(o.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:h.optionGap},children:[{value:"visible",label:"Visible rows",icon:t.jsx($.VisibilityOutlined,{sx:{fontSize:20}}),info:`Export ${r.toLocaleString()} rows (filtered and searched)`},{value:"all",label:"All rows",icon:t.jsx($.TableChartOutlined,{sx:{fontSize:20}}),info:`Export ${e.toLocaleString()} rows (complete original dataset)`}].map(J=>{const re=R===J.value;return t.jsxs(o.Box,{onClick:()=>H(J.value),className:`urm-export-row-card ${re?S.rowCardSelected||"":S.rowCard||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:1.5,borderRadius:h.cardRadius,border:re?`2px solid ${h.cardSelectedBorder}`:`1px solid ${h.cardBorder}`,boxShadow:re?void 0:h.cardShadow,bgcolor:re?h.cardSelectedBg:h.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:re?h.cardSelectedBorder:_(m.text.primary,.25),bgcolor:re?h.cardSelectedBg:h.cardHoverBg}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(vs,{checked:re}),t.jsx(o.Box,{sx:{color:re?h.cardSelectedColor:m.text.secondary,display:"flex"},children:J.icon}),t.jsx(o.Typography,{sx:{fontSize:"0.875rem",fontWeight:600,color:re?h.cardSelectedColor:m.text.primary},children:J.label})]}),t.jsx(o.Tooltip,{title:J.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:Se=>Se.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:m.text.secondary,"&:hover":{color:m.text.primary}},children:t.jsx($.InfoOutlined,{sx:{fontSize:16}})})})]},J.value)})})]}),t.jsxs(o.Box,{className:`urm-export-section ${S.sectionContainer||""}`,sx:{position:"relative",border:`1.5px solid ${h.sectionBorder}`,borderRadius:"12px",p:h.sectionPadding,pt:2.25,bgcolor:h.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${S.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:h.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:h.sectionTitleColor,lineHeight:1,zIndex:1},children:"Select Columns Range"}),t.jsx(o.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:h.optionGap},children:[{value:"visible",label:"Visible columns",icon:t.jsx($.SwapVertOutlined,{sx:{fontSize:20}}),info:`Export ${i} visible column${i!==1?"s":""}`},{value:"all",label:"All columns",icon:t.jsx($.TableChartOutlined,{sx:{fontSize:20}}),info:`Export all ${s} columns (including hidden)`}].map(J=>{const re=E===J.value;return t.jsxs(o.Box,{onClick:()=>G(J.value),className:`urm-export-column-card ${re?S.columnCardSelected||"":S.columnCard||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:1.5,borderRadius:h.cardRadius,border:re?`2px solid ${h.cardSelectedBorder}`:`1px solid ${h.cardBorder}`,boxShadow:re?void 0:h.cardShadow,bgcolor:re?h.cardSelectedBg:h.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:re?h.cardSelectedBorder:_(m.text.primary,.25),bgcolor:re?h.cardSelectedBg:h.cardHoverBg}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(vs,{checked:re}),t.jsx(o.Box,{sx:{color:re?h.cardSelectedColor:m.text.secondary,display:"flex"},children:J.icon}),t.jsx(o.Typography,{sx:{fontSize:"0.875rem",fontWeight:600,color:re?h.cardSelectedColor:m.text.primary},children:J.label})]}),t.jsx(o.Tooltip,{title:J.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:Se=>Se.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:m.text.secondary,"&:hover":{color:m.text.primary}},children:t.jsx($.InfoOutlined,{sx:{fontSize:16}})})})]},J.value)})})]}),t.jsxs(o.Box,{className:`urm-export-summary ${S.summaryContainer||""}`,sx:{position:"relative",border:`1.5px solid ${h.sectionBorder}`,borderRadius:"12px",p:h.sectionPadding,pt:2.25,bgcolor:h.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${S.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:h.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:h.sectionTitleColor,lineHeight:1,zIndex:1},children:"Export Summary"}),t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[{icon:t.jsx($.InsertDriveFileOutlined,{sx:{fontSize:18,color:m.text.secondary}}),label:"Format",value:d[I]},{icon:t.jsx($.FormatListNumberedOutlined,{sx:{fontSize:18,color:m.text.secondary}}),label:"Rows to Export",value:Z.toLocaleString()},{icon:t.jsx($.SwapVertOutlined,{sx:{fontSize:18,color:m.text.secondary}}),label:"Columns to Export",value:String(O)},{icon:t.jsx($.InsertDriveFileOutlined,{sx:{fontSize:18,color:m.text.secondary}}),label:"Estimated File Size",value:`~${wo(P.estimatedBytes)}`,highlight:P.hasBlockingViolation?"error.main":P.hasWarning?"warning.main":void 0}].map(({icon:J,label:re,value:Se,highlight:F})=>t.jsxs(o.Box,{className:`urm-export-summary-row ${S.summaryRow||""}`,sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[J,t.jsx(o.Typography,{className:`urm-export-summary-label ${S.summaryLabel||""}`,sx:{fontSize:"0.8125rem",color:m.text.secondary,fontWeight:500},children:re})]}),t.jsx(o.Typography,{className:`urm-export-summary-value ${S.summaryValue||""}`,sx:{fontWeight:700,fontSize:"0.8125rem",color:F??m.text.primary},children:Se})]},re))})]})]}),t.jsxs(o.Box,{className:`urm-export-footer ${S.footer||""}`,sx:{px:3,py:2,display:"flex",alignItems:"center",justifyContent:"flex-end",gap:1.5,flexShrink:0},children:[P.hasBlockingViolation&&t.jsxs(o.Box,{sx:{flex:1,display:"flex",alignItems:"center",gap:.75},children:[t.jsx($.ErrorOutline,{sx:{fontSize:15,color:"error.main"}}),t.jsx(o.Typography,{sx:{fontSize:J=>J.typography.caption.fontSize||"0.75rem",color:"error.main",fontWeight:J=>J.typography.body2.fontWeight||500},children:"Reduce rows or columns to enable download"})]}),t.jsx(o.Button,{onClick:B,variant:"outlined",className:`urm-export-cancel-btn ${S.cancelButton||""}`,sx:{fontSize:"0.875rem",fontWeight:600,color:m.text.primary,borderColor:h.cardBorder,px:3,py:1,borderRadius:"8px",textTransform:"none","&:hover":{bgcolor:h.cardHoverBg,borderColor:_(m.text.primary,.3)}},children:"Cancel"}),t.jsxs(o.Button,{onClick:te,disabled:P.hasBlockingViolation,variant:"contained",className:`urm-export-download-btn ${S.downloadButton||""}`,startIcon:t.jsx($.Download,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",fontWeight:600,bgcolor:h.primaryBtnBg,color:h.primaryBtnColor,px:3,py:1,borderRadius:"8px",textTransform:"none",boxShadow:`0 2px 6px ${_(m.primary.main,.25)}`,"&:hover":{bgcolor:h.primaryBtnHoverBg},"&.Mui-disabled":{bgcolor:_(m.primary.main,.4),color:h.primaryBtnColor}},children:["Download ",d[I]]})]})]})})}function fp({warning:e,onDismiss:r}){return t.jsx(o.Box,{sx:{position:"fixed",bottom:16,right:16,zIndex:50,maxWidth:448},children:t.jsxs(o.Alert,{severity:"warning",icon:t.jsx($.Warning,{sx:{fontSize:20}}),action:t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:"warning.main"},children:t.jsx($.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 mp({error:e,onDismiss:r,autoDismiss:n=!0,autoDismissDelay:i=3e4}){p.useEffect(()=>{if(n){const l=setTimeout(()=>{r()},i);return()=>clearTimeout(l)}},[n,i,r]);const a=(()=>{switch(e.type){case"system":return{severity:"error",icon:t.jsx($.Cancel,{sx:{fontSize:20}})};case"processing":return{severity:"warning",icon:t.jsx($.Warning,{sx:{fontSize:20}})};case"ui":default:return{severity:"info",icon:t.jsx($.InfoOutlined,{sx:{fontSize:20}})}}})(),c=Sl(e);return t.jsx(o.Box,{sx:{position:"fixed",bottom:16,right:16,zIndex:50,maxWidth:448},children:t.jsxs(o.Alert,{severity:a.severity,icon:a.icon,action:t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:`${a.severity}.main`},children:t.jsx($.Close,{sx:{fontSize:16}})}),sx:{borderLeft:4,borderColor:`${a.severity}.main`,boxShadow:3},children:[t.jsxs(o.AlertTitle,{sx:{fontWeight:l=>l.typography.h6.fontWeight||600,fontSize:l=>l.typography.subtitle2.fontSize||"0.875rem"},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 xp extends p.Component{constructor(n){super(n);ji(this,"handleReset",()=>{this.setState({hasError:!1,error:null})});this.state={hasError:!1,error:null}}static getDerivedStateFromError(n){return{hasError:!0,error:n}}componentDidCatch(n,i){Gt.error("urm:error-boundary","Caught unhandled component error",n,i),this.props.onError&&this.props.onError(n,i)}render(){var n,i;return this.state.hasError?this.props.fallback?this.props.fallback:t.jsx(o.Paper,{sx:{bgcolor:s=>_(s.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($.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:s=>s.typography.h6.fontWeight||600,fontSize:s=>s.typography.h6.fontSize||"1.25rem"},children:this.props.context?`${this.props.context} Error`:"Something went wrong"}),t.jsx(o.Typography,{variant:"body2",sx:{color:"error.main",mt:1},children:((n=this.state.error)==null?void 0:n.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:s=>_(s.palette.error.main,.12),p:1.5,borderRadius:1,overflow:"auto",maxHeight:170},children:(i=this.state.error)==null?void 0:i.stack}),t.jsx(o.Button,{onClick:this.handleReset,variant:"contained",color:"error",startIcon:t.jsx($.Refresh,{sx:{fontSize:16}}),sx:{mt:2},children:"Try Again"})]})]})}):this.props.children}}function gp({feature:e}){const[r,n]=p.useState(!0);return p.useEffect(()=>{const i=setTimeout(()=>n(!1),5e3);return()=>clearTimeout(i)},[]),t.jsx(o.Collapse,{in:r,unmountOnExit:!0,children:t.jsxs(o.Alert,{severity:"warning",sx:{m:1},icon:t.jsx($.Warning,{sx:{fontSize:20}}),action:t.jsx(o.IconButton,{size:"small",onClick:()=>n(!1),"aria-label":"dismiss",sx:{color:"warning.dark"},children:t.jsx($.Close,{sx:{fontSize:16}})}),children:[t.jsxs(o.AlertTitle,{children:[e," temporarily unavailable"]}),"Other features continue to work normally"]})})}function Xo({children:e,feature:r,onError:n}){return t.jsx(xp,{context:r,onError:i=>{n&&n(i)},fallback:t.jsx(gp,{feature:r}),children:e})}const yp=[{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"}],bp=[{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"},{value:"pdf",label:"PDF",desc:"Print-ready PDF document"}];function bo({children:e,active:r}){return t.jsx(o.Box,{hidden:!r,sx:{pt:2.5,pb:1,display:r?"flex":"none",flexDirection:"column",gap:2.5},children:e})}function vp({open:e,onClose:r,config:n,onApply:i}){const[s,a]=p.useState(0),[c,l]=p.useState(n),u=()=>l(n),g=()=>l(xt),x=()=>{i(c),r()},f={sort:m=>l(T=>({...T,sort:{...T.sort,...m}})),filter:m=>l(T=>({...T,filter:{...T.filter,...m}})),columns:m=>l(T=>({...T,columns:{...T.columns,...m}})),grouping:m=>l(T=>({...T,grouping:{...T.grouping,...m}})),export:m=>l(T=>({...T,export:{...T.export,...m}}))},S=m=>{const T=c.filter.allowedOperators,h=T.includes(m)?T.filter(z=>z!==m):[...T,m];h.length!==0&&f.filter({allowedOperators:h})},C=m=>{const T=c.export.allowedFormats,h=T.includes(m)?T.filter(z=>z!==m):[...T,m];h.length!==0&&f.export({allowedFormats:h})},B=[{label:"Sort",icon:t.jsx($.SwapVert,{sx:{fontSize:m=>m.typography.body1.fontSize}})},{label:"Filter",icon:t.jsx($.FilterList,{sx:{fontSize:m=>m.typography.body1.fontSize}})},{label:"Columns",icon:t.jsx($.ViewColumn,{sx:{fontSize:m=>m.typography.body1.fontSize}})},{label:"Grouping",icon:t.jsx($.Layers,{sx:{fontSize:m=>m.typography.body1.fontSize}})},{label:"Export",icon:t.jsx($.Download,{sx:{fontSize:m=>m.typography.body1.fontSize}})}],v=m=>JSON.stringify(c[m])===JSON.stringify(xt[m]);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,TransitionProps:{onEnter:u},PaperProps:{sx:{borderRadius:m=>ot(m),maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:m=>m.shadows[8]}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(o.Box,{sx:{width:32,height:32,borderRadius:m=>m.shape.borderRadius,bgcolor:m=>_(m.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",fontSize:m=>m.typography.h5.fontSize},children:"⚙️"}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle1",sx:{fontWeight:600,lineHeight:1.2},children:"Developer Configuration"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"Set runtime constraints · Ctrl+Shift+D"})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:"text.secondary"},children:t.jsx($.Close,{sx:{fontSize:20}})})]}),t.jsx(o.Box,{sx:{borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:t.jsx(o.Tabs,{value:s,onChange:(m,T)=>a(T),variant:"fullWidth",sx:{minHeight:44,"& .MuiTab-root":{minHeight:44,fontSize:m=>m.typography.caption.fontSize,textTransform:"none",fontWeight:m=>m.typography.button.fontWeight,gap:.5}},children:B.map((m,T)=>t.jsx(o.Tab,{label:m.label,icon:m.icon,iconPosition:"start"},T))})}),t.jsxs(o.DialogContent,{sx:{overflowY:"auto",flex:1,px:3,py:0},children:[t.jsxs(bo,{active:s===0,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum sort levels"}),!v("sort")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users can sort by at most this many columns simultaneously."}),t.jsx(o.Slider,{value:c.sort.maxLevels,onChange:(m,T)=>f.sort({maxLevels:T}),min:1,max:10,step:1,marks:!0,valueLabelDisplay:"on"}),t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between"},children:[t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"1 level (single)"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"10 levels (maximum)"})]})]}),t.jsxs(o.Alert,{severity:"info",sx:{borderRadius:m=>m.shape.borderRadius,fontSize:m=>m.typography.caption.fontSize},children:['The "Add sort column" button is hidden once users reach this limit. Default is'," ",t.jsx("strong",{children:"5"}),"."]})]}),t.jsxs(bo,{active:s===1,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum filter conditions"}),!v("filter")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users can apply at most this many simultaneous filter conditions."}),t.jsx(o.Slider,{value:c.filter.maxConditions,onChange:(m,T)=>f.filter({maxConditions:T}),min:1,max:20,step:1,marks:!0,valueLabelDisplay:"on"}),t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between"},children:[t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"1 condition"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"20 conditions"})]})]}),t.jsx(o.Divider,{}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,mb:.5},children:"Allowed filter operators"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1.5},children:"Only checked operators appear in the filter type dropdown. At least one must remain checked."}),["Text","Numeric","Boolean","Null checks"].map(m=>t.jsxs(o.Box,{sx:{mb:1.5},children:[t.jsx(o.Typography,{sx:{fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"text.secondary",fontSize:T=>T.typography.overline.fontSize,display:"block",mb:.5},children:m}),t.jsx(o.FormGroup,{row:!0,sx:{gap:.5},children:yp.filter(T=>T.group===m).map(T=>t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{size:"small",checked:c.filter.allowedOperators.includes(T.value),onChange:()=>S(T.value)}),label:t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem"},children:T.label}),sx:{mr:1.5}},T.value))})]},m))]})]}),t.jsxs(bo,{active:s===2,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum visible columns"}),!v("columns")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users cannot make more than this many columns visible simultaneously."}),t.jsx(o.Slider,{value:c.columns.maxVisible,onChange:(m,T)=>f.columns({maxVisible:T}),min:1,max:50,step:1,valueLabelDisplay:"on"})]}),t.jsx(o.Divider,{}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,mb:.5},children:"Column width range (px)"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users cannot resize columns outside this minimum / maximum range."}),t.jsxs(o.Box,{sx:{display:"flex",gap:2},children:[t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Minimum width"}),t.jsx(o.Slider,{value:c.columns.minColumnWidth,onChange:(m,T)=>f.columns({minColumnWidth:T}),min:40,max:400,step:10,valueLabelDisplay:"on",valueLabelFormat:m=>`${m}px`})]}),t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Maximum width"}),t.jsx(o.Slider,{value:c.columns.maxColumnWidth,onChange:(m,T)=>f.columns({maxColumnWidth:T}),min:100,max:2e3,step:50,valueLabelDisplay:"on",valueLabelFormat:m=>`${m}px`})]})]})]})]}),t.jsxs(bo,{active:s===3,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum group levels"}),!v("grouping")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Box,{sx:{display:"flex",gap:1.5,mb:2},children:[1,2,3].map(m=>t.jsxs(o.Box,{onClick:()=>f.grouping({maxLevels:m}),sx:{flex:1,py:2.5,borderRadius:T=>Number(T.shape.borderRadius||0)*1.25,border:"2px solid",cursor:"pointer",textAlign:"center",transition:"all 0.15s ease",borderColor:c.grouping.maxLevels===m?"primary.main":"divider",bgcolor:c.grouping.maxLevels===m?T=>_(T.palette.primary.main,.06):"transparent","&:hover":{borderColor:"primary.light",bgcolor:T=>_(T.palette.primary.main,.04)}},children:[t.jsx(o.Typography,{variant:"h5",sx:{fontWeight:700,color:c.grouping.maxLevels===m?"primary.main":"text.secondary"},children:m}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:["Single","Double","Triple"][m-1]})]},m))}),t.jsxs(o.FormGroup,{row:!0,sx:{gap:2},children:[t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{checked:c.grouping.allowNested,onChange:m=>f.grouping({allowNested:m.target.checked})}),label:t.jsx(o.Typography,{variant:"body2",children:"Allow nested groups"})}),t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{checked:c.grouping.allowCollapse,onChange:m=>f.grouping({allowCollapse:m.target.checked})}),label:t.jsx(o.Typography,{variant:"body2",children:"Allow collapse / expand"})})]})]}),t.jsx(o.Alert,{severity:"info",sx:{borderRadius:m=>m.shape.borderRadius,fontSize:m=>m.typography.caption.fontSize},children:'The "Add group level" button is hidden when users reach the configured limit.'})]}),t.jsx(bo,{active:s===4,children:t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Allowed export formats"}),!v("export")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1.5},children:"Only checked formats appear in the Export dialog and the bulk export action. At least one must remain checked."}),t.jsx(o.FormGroup,{sx:{gap:1},children:bp.map(m=>t.jsxs(o.Box,{onClick:()=>C(m.value),sx:{display:"flex",alignItems:"center",gap:1.5,p:1.5,borderRadius:T=>T.shape.borderRadius,border:"1px solid",cursor:"pointer",transition:"all 0.15s ease",borderColor:c.export.allowedFormats.includes(m.value)?"primary.main":"divider",bgcolor:c.export.allowedFormats.includes(m.value)?T=>_(T.palette.primary.main,.04):"transparent","&:hover":{borderColor:"primary.light"}},children:[t.jsx(o.Checkbox,{size:"small",checked:c.export.allowedFormats.includes(m.value),onChange:()=>C(m.value),onClick:T=>T.stopPropagation()}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500},children:m.label}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:m.desc})]})]},m.value))})]})})]}),t.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid",borderColor:"divider",bgcolor:m=>_(m.palette.action.hover,.4),justifyContent:"space-between",flexShrink:0},children:[t.jsx(o.Button,{startIcon:t.jsx($.RestartAlt,{sx:{fontSize:18}}),onClick:g,size:"small",sx:{fontSize:m=>m.typography.body2.fontSize,color:"text.secondary","&:hover":{color:"text.primary",bgcolor:m=>_(m.palette.text.primary,.06)}},children:"Reset to defaults"}),t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Button,{onClick:r,size:"small",sx:{fontSize:m=>m.typography.body2.fontSize,color:"text.secondary",px:2,borderRadius:m=>Number(m.shape.borderRadius)*2.25},children:"Cancel"}),t.jsx(o.Button,{onClick:x,size:"small",variant:"contained",sx:{fontSize:m=>m.typography.body2.fontSize,px:2.5,borderRadius:m=>Number(m.shape.borderRadius)*2.25},children:"Apply"})]})]})]})}const Sp=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Cp={1:"1st",2:"2nd",3:"3rd",4:"4th",5:"5th",6:"6th",7:"7th",8:"8th",9:"9th",10:"10th",11:"11th",12:"12th",13:"13th",14:"14th",15:"15th",16:"16th",17:"17th",18:"18th",19:"19th",20:"20th",21:"21st",22:"22nd",23:"23rd",24:"24th",25:"25th",26:"26th",27:"27th",28:"28th"};function Zo(e,r,n,i,s=new Date){const[a,c]=r.split(":").map(Number),l=new Date(s);if(l.setSeconds(0,0),l.setHours(a,c,0,0),e==="daily")return l<=s&&l.setDate(l.getDate()+1),l.toISOString();if(e==="weekly"){const u=n??1,g=l.getDay();let x=u-g;return x<0&&(x+=7),x===0&&l<=s&&(x=7),l.setDate(l.getDate()+x),l.toISOString()}if(e==="monthly"){const u=Math.min(i??1,28);return l.setDate(u),l<=s&&(l.setMonth(l.getMonth()+1),l.setDate(u)),l.toISOString()}return l.toISOString()}function wp(e){const r=oa(e.time);return e.frequency==="daily"?`Daily at ${r}`:e.frequency==="weekly"?`Every ${Sp[e.dayOfWeek??1]} at ${r}`:e.frequency==="monthly"?`Monthly on the ${Cp[e.dayOfMonth??1]??`${e.dayOfMonth}th`} at ${r}`:r}function oa(e){const[r,n]=e.split(":").map(Number),i=r>=12?"PM":"AM";return`${r%12||12}:${String(n).padStart(2,"0")} ${i}`}function jp(e){const r=new Date(e).getTime()-Date.now();if(r<=0)return"now";const n=Math.floor(r/1e3),i=Math.floor(n/86400),s=Math.floor(n%86400/3600),a=Math.floor(n%3600/60);return i>0?`in ${i}d ${s}h`:s>0?`in ${s}h ${a}m`:a>0?`in ${a}m`:"in less than a minute"}function kp(e){const r=new Date(e),n=new Date,i=r.toDateString()===n.toDateString(),s=oa(`${String(r.getHours()).padStart(2,"0")}:${String(r.getMinutes()).padStart(2,"0")}`);return i?`Today at ${s}`:`${r.toLocaleDateString("en-US",{month:"short",day:"numeric"})} at ${s}`}function na(e){return`urm_schedules_${e}`}function ia(e){try{const r=localStorage.getItem(na(e));return r?JSON.parse(r).map(i=>({...i,runCount:typeof i.runCount=="number"?i.runCount:0,isActive:typeof i.isActive=="boolean"?i.isActive:!0,createdAt:i.createdAt||new Date().toISOString()})):[]}catch{return[]}}function sa(e,r){try{localStorage.setItem(na(e),JSON.stringify(r))}catch{}}const zp=[{value:0,label:"Sunday"},{value:1,label:"Monday"},{value:2,label:"Tuesday"},{value:3,label:"Wednesday"},{value:4,label:"Thursday"},{value:5,label:"Friday"},{value:6,label:"Saturday"}],Tp=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,aa={name:"",frequency:"daily",dayOfWeek:1,dayOfMonth:1,time:"09:00",format:"pdf",scope:"all",email:""},Br={"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:"8px"},"& .MuiInputLabel-root":{fontSize:"0.875rem"},"& .MuiFormHelperText-root":{fontSize:"0.75rem",mx:.5},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}}};function Bp({initial:e=aa,isEditing:r=!1,onSave:n,onBack:i}){const[s,a]=p.useState(e),[c,l]=p.useState(!1),[u,g]=p.useState(!1),x=(C,B)=>a(v=>({...v,[C]:B})),f=s.email.trim().length>0&&!Tp.test(s.email.trim()),S=s.name.trim().length>0&&/^\d{2}:\d{2}$/.test(s.time)&&(s.frequency!=="monthly"||s.dayOfMonth>=1&&s.dayOfMonth<=28)&&!f;return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,mb:.5},children:[t.jsx(o.IconButton,{size:"small",onClick:i,sx:{color:"text.secondary",ml:-.75,"&:hover":{bgcolor:C=>_(C.palette.text.primary,.06)}},children:t.jsx($.ArrowBack,{sx:{fontSize:18}})}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:C=>C.typography.body2.fontWeight||600,fontSize:C=>C.typography.body2.fontSize||"0.875rem"},children:r?"Edit schedule":"New schedule"})]}),t.jsx(o.TextField,{label:"Schedule name *",size:"small",fullWidth:!0,value:s.name,onChange:C=>{x("name",C.target.value),c&&C.target.value.trim()&&l(!1)},onBlur:()=>l(!0),placeholder:"e.g. Weekly Sales Report",autoFocus:!0,inputProps:{maxLength:50},error:c&&!s.name.trim(),helperText:c&&!s.name.trim()?"Schedule name is required":`${s.name.length}/50`,sx:Br}),t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:Br,children:[t.jsx(o.InputLabel,{children:"Frequency"}),t.jsxs(o.Select,{value:s.frequency,label:"Frequency",onChange:C=>x("frequency",C.target.value),children:[t.jsx(o.MenuItem,{value:"daily",children:"Daily"}),t.jsx(o.MenuItem,{value:"weekly",children:"Weekly"}),t.jsx(o.MenuItem,{value:"monthly",children:"Monthly"})]})]}),s.frequency==="weekly"&&t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:Br,children:[t.jsx(o.InputLabel,{children:"Day of week"}),t.jsx(o.Select,{value:s.dayOfWeek,label:"Day of week",onChange:C=>x("dayOfWeek",Number(C.target.value)),children:zp.map(C=>t.jsx(o.MenuItem,{value:C.value,children:C.label},C.value))})]}),s.frequency==="monthly"&&t.jsx(o.TextField,{label:"Day of month (1–28)",size:"small",type:"number",fullWidth:!0,value:s.dayOfMonth,onChange:C=>x("dayOfMonth",Number(C.target.value)),inputProps:{min:1,max:28},error:s.dayOfMonth<1||s.dayOfMonth>28,helperText:s.dayOfMonth<1||s.dayOfMonth>28?"Day must be between 1 and 28":"Max 28 — works safely across all months including February",sx:Br}),t.jsx(o.TextField,{label:"Time",size:"small",type:"time",fullWidth:!0,value:s.time,onChange:C=>x("time",C.target.value),InputLabelProps:{shrink:!0},helperText:"24-hour format · Tab must be open for the schedule to fire",sx:Br}),t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:Br,children:[t.jsx(o.InputLabel,{children:"Export format"}),t.jsxs(o.Select,{value:s.format,label:"Export format",onChange:C=>x("format",C.target.value),children:[t.jsx(o.MenuItem,{value:"pdf",children:"PDF — Print-ready document"}),t.jsx(o.MenuItem,{value:"csv",children:"CSV — Comma-separated values"}),t.jsx(o.MenuItem,{value:"excel",children:"Excel (.xlsx) — Native format"}),t.jsx(o.MenuItem,{value:"json",children:"JSON — Structured data"})]})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontWeight:500,color:"text.secondary",display:"block",mb:.75},children:"Data scope"}),t.jsxs(o.RadioGroup,{row:!0,value:s.scope,onChange:C=>x("scope",C.target.value),sx:{gap:2},children:[t.jsx(o.FormControlLabel,{value:"all",control:t.jsx(o.Radio,{size:"small"}),label:t.jsx(o.Typography,{variant:"body2",children:"All rows"})}),t.jsx(o.FormControlLabel,{value:"visible",control:t.jsx(o.Radio,{size:"small"}),label:t.jsx(o.Typography,{variant:"body2",children:"Filtered rows only"})})]})]}),t.jsxs(o.Box,{children:[t.jsx(o.TextField,{label:"Email reminder (optional)",size:"small",fullWidth:!0,type:"email",value:s.email,onChange:C=>x("email",C.target.value),onBlur:()=>g(!0),placeholder:"user@company.com",error:u&&f,helperText:u&&f?"Enter a valid email address":void 0,InputProps:{startAdornment:t.jsx($.Email,{sx:{fontSize:15,color:"text.disabled",mr:1}})},sx:Br}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:.5,mt:.5,px:.5},children:[t.jsx($.InfoOutlined,{sx:{fontSize:12,color:"text.disabled",mt:.2,flexShrink:0}}),t.jsx(o.Typography,{variant:"caption",color:"text.disabled",sx:{lineHeight:1.5},children:"Opens your device's email app when the schedule fires. Requires a default mail app (e.g. Outlook, Mail) on this device."})]})]}),t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"flex-end",gap:1,pt:.5},children:[t.jsx(o.Button,{onClick:i,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px","&:hover":{bgcolor:C=>_(C.palette.text.primary,.06)}},children:"Cancel"}),t.jsx(o.Button,{onClick:()=>S&&n(s),disabled:!S,size:"small",variant:"contained",sx:{fontSize:"0.875rem",px:2.5,borderRadius:"18px"},children:r?"Save changes":"Create schedule"})]})]})}function Ip({scheduleName:e,onConfirm:r,onCancel:n}){return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:i=>({borderRadius:_o(i),...de(i).paper})},children:[t.jsxs(o.DialogContent,{sx:{pt:3,pb:2,px:3},children:[t.jsx(o.Box,{sx:{width:44,height:44,borderRadius:"12px",bgcolor:i=>_(i.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx($.WarningAmberOutlined,{sx:{fontSize:22,color:"error.main"}})}),t.jsx(o.Typography,{sx:{fontSize:i=>i.typography.body1.fontSize||"0.9375rem",fontWeight:i=>i.typography.h6.fontWeight||600,color:"text.primary",mb:1},children:"Delete Schedule"}),t.jsxs(o.Typography,{sx:{fontSize:i=>i.typography.body2.fontSize||"0.8125rem",color:"text.secondary",lineHeight:1.65},children:["Are you sure you want to delete"," ",t.jsxs(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:['"',e,'"']}),"? This action cannot be undone."]})]}),t.jsx(o.Divider,{}),t.jsxs(o.DialogActions,{sx:{px:2.5,py:1.5,gap:1},children:[t.jsx(o.Button,{onClick:n,variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",borderRadius:i=>`${i.shape.borderRadius}px`,"&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),t.jsx(o.Button,{onClick:r,variant:"contained",color:"error",sx:{fontSize:"0.8125rem",borderRadius:i=>`${i.shape.borderRadius}px`,px:2},children:"Delete"})]})]})}function Ep({schedule:e,tick:r,onToggle:n,onRunNow:i,onEdit:s,onDelete:a}){const c=e.isActive;return t.jsxs(o.Box,{sx:{border:"1px solid",borderColor:c?"primary.main":"divider",borderRadius:"10px",p:1.75,bgcolor:c?l=>_(l.palette.primary.main,.025):"background.paper",transition:"border-color 0.15s ease, background-color 0.15s ease"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,flex:1,minWidth:0,color:c?"text.primary":"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),t.jsx(o.Chip,{label:c?"Active":"Paused",size:"small",sx:{height:18,fontSize:"0.6875rem",fontWeight:600,flexShrink:0,bgcolor:c?l=>_(l.palette.success.main,.1):l=>_(l.palette.text.primary,.06),color:c?"success.dark":"text.secondary"}})]}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary",display:"block",mb:1},children:wp(e)}),t.jsxs(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:.5,mb:1},children:[t.jsx(o.Chip,{label:e.format.toUpperCase(),size:"small",sx:{height:20,fontSize:"0.6875rem",fontWeight:500,bgcolor:l=>_(l.palette.primary.main,.08),color:"primary.main"}}),t.jsx(o.Chip,{label:e.scope==="all"?"All rows":"Filtered rows",size:"small",sx:{height:20,fontSize:"0.6875rem",bgcolor:l=>_(l.palette.text.primary,.06),color:"text.secondary"}}),e.email&&t.jsx(o.Chip,{icon:t.jsx($.Email,{sx:{fontSize:11}}),label:e.email,size:"small",sx:{height:20,fontSize:"0.6875rem",maxWidth:220,bgcolor:l=>_(l.palette.text.primary,.06),color:"text.secondary","& .MuiChip-label":{overflow:"hidden",textOverflow:"ellipsis"}}})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:1},children:[t.jsxs(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1.5,alignItems:"center"},children:[c&&t.jsxs(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:500},children:["Next: ",jp(e.nextRunAt)]}),e.lastRunAt?t.jsxs(o.Typography,{variant:"caption",color:"text.secondary",children:["Last: ",kp(e.lastRunAt)," · ",e.runCount," run",e.runCount!==1?"s":""]}):t.jsx(o.Typography,{variant:"caption",color:"text.disabled",children:"Never run"})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.25,flexShrink:0},children:[t.jsx(o.Tooltip,{title:"Edit",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:()=>s(e),sx:{color:"text.secondary","&:hover":{color:"primary.main",bgcolor:l=>_(l.palette.primary.main,.08)}},children:t.jsx($.Edit,{sx:{fontSize:15}})})}),t.jsx(o.Tooltip,{title:c?"Pause":"Resume",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:()=>n(e.id),sx:{color:c?"warning.main":"success.main","&:hover":{bgcolor:c?l=>_(l.palette.warning.main,.08):l=>_(l.palette.success.main,.08)}},children:c?t.jsx($.Pause,{sx:{fontSize:15}}):t.jsx($.PlayArrow,{sx:{fontSize:15}})})}),t.jsx(o.Tooltip,{title:"Export now",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:()=>i(e),sx:{color:"primary.main","&:hover":{bgcolor:l=>_(l.palette.primary.main,.08)}},children:t.jsx($.Download,{sx:{fontSize:15}})})}),t.jsx(o.Tooltip,{title:"Delete",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:()=>a(e.id),sx:{color:"error.main","&:hover":{bgcolor:l=>_(l.palette.error.main,.08)}},children:t.jsx($.Delete,{sx:{fontSize:15}})})})]})]})]})}function Dp({open:e,onClose:r,reportId:n,reportName:i,onRunNow:s,schedulerConfig:a}){const l=((a==null?void 0:a.mode)??"local")==="api",[u,g]=p.useState([]),x=l?(a==null?void 0:a.schedules)??[]:u,[f,S]=p.useState({type:"list"}),[C,B]=p.useState(0),[v,m]=p.useState(null);p.useEffect(()=>{e&&(l||g(ia(n)),S({type:"list"}))},[e,n,l]),p.useEffect(()=>{if(!e)return;const O=setInterval(()=>B(y=>y+1),3e4);return()=>clearInterval(O)},[e]);const T=p.useCallback(O=>{g(O),sa(n,O)},[n]),h=O=>{var P;const y=Zo(O.frequency,O.time,O.dayOfWeek,O.dayOfMonth),w={id:`sched-${Date.now()}`,reportId:n,name:O.name.trim(),frequency:O.frequency,dayOfWeek:O.frequency==="weekly"?O.dayOfWeek:void 0,dayOfMonth:O.frequency==="monthly"?O.dayOfMonth:void 0,time:O.time,format:O.format,scope:O.scope,email:O.email.trim()||void 0,isActive:!0,createdAt:new Date().toISOString(),nextRunAt:y,runCount:0};l?(P=a==null?void 0:a.onScheduleCreate)==null||P.call(a,w):T([...x,w]),S({type:"list"})},z=O=>{var te;if(f.type!=="edit")return;const y=f.schedule,w=Zo(O.frequency,O.time,O.dayOfWeek,O.dayOfMonth),P={...y,name:O.name.trim(),frequency:O.frequency,dayOfWeek:O.frequency==="weekly"?O.dayOfWeek:void 0,dayOfMonth:O.frequency==="monthly"?O.dayOfMonth:void 0,time:O.time,format:O.format,scope:O.scope,email:O.email.trim()||void 0,nextRunAt:w};l?(te=a==null?void 0:a.onScheduleUpdate)==null||te.call(a,P):T(x.map(d=>d.id===y.id?P:d)),S({type:"list"})},I=O=>{var d;const y=x.find(J=>J.id===O);if(!y)return;const w=!y.isActive,P=w?Zo(y.frequency,y.time,y.dayOfWeek,y.dayOfMonth):y.nextRunAt,te={...y,isActive:w,nextRunAt:P};l?(d=a==null?void 0:a.onScheduleToggle)==null||d.call(a,O,w):T(x.map(J=>J.id===O?te:J))},b=O=>{if(s(O),!l){const y=new Date().toISOString();T(x.map(w=>w.id===O.id?{...w,lastRunAt:y,runCount:w.runCount+1}:w))}},R=O=>{const y=x.find(w=>w.id===O)??null;m(y)},H=()=>{var O;v&&(l?(O=a==null?void 0:a.onScheduleDelete)==null||O.call(a,v.id):T(x.filter(y=>y.id!==v.id)),m(null))},E=O=>({name:O.name,frequency:O.frequency,dayOfWeek:O.dayOfWeek??1,dayOfMonth:O.dayOfMonth??1,time:O.time,format:O.format,scope:O.scope,email:O.email??""}),G=f.type!=="list",Z=x.filter(O=>O.isActive).length;return t.jsxs(t.Fragment,{children:[t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,disableEscapeKeyDown:G,PaperProps:{sx:O=>({borderRadius:ot(O),maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",...de(O).paper})},children:[t.jsxs(o.DialogTitle,{sx:O=>({display:"flex",alignItems:"center",justifyContent:"space-between",py:1.5,px:2.5,flexShrink:0,minHeight:0,...de(O).header}),children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[t.jsx(o.Box,{sx:{width:30,height:30,borderRadius:"7px",bgcolor:O=>_(O.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx($.Schedule,{sx:{fontSize:17,color:"primary.main"}})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"baseline",gap:.75},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:O=>O.typography.h6.fontWeight||600,fontSize:O=>O.typography.subtitle2.fontSize||"0.875rem",lineHeight:1},children:"Scheduled Reports"}),t.jsx(Er,{content:Dr.schedule,isDev:process.env.NODE_ENV==="development"})]}),t.jsxs(o.Typography,{variant:"caption",color:"text.secondary",sx:{lineHeight:1},children:["· ",i]})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:"text.secondary","&:hover":{bgcolor:O=>_(O.palette.text.primary,.06)}},children:t.jsx($.Close,{sx:{fontSize:18}})})]}),t.jsxs(o.DialogContent,{sx:{overflowY:"auto",flex:1,px:2.5,py:2},children:[G&&t.jsx(Bp,{initial:f.type==="edit"?E(f.schedule):aa,isEditing:f.type==="edit",onSave:f.type==="edit"?z:h,onBack:()=>S({type:"list"})}),f.type==="list"&&t.jsxs(t.Fragment,{children:[t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1.75,pt:1.5},children:[t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:x.length===0?"No schedules yet":`${Z} of ${x.length} active`}),t.jsx(o.Button,{startIcon:t.jsx($.Add,{sx:{fontSize:15}}),size:"small",variant:"contained",onClick:()=>S({type:"create"}),sx:{fontSize:"0.8125rem",borderRadius:"18px",px:1.75,py:.625},children:"New schedule"})]}),x.length===0?t.jsxs(o.Box,{sx:{border:"1.5px dashed",borderColor:"divider",borderRadius:"10px",py:5,px:2,textAlign:"center"},children:[t.jsx($.NotificationsActive,{sx:{fontSize:30,color:"text.disabled",mb:1.25,display:"block",mx:"auto"}}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:O=>O.typography.body2.fontWeight||500,fontSize:O=>O.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"No scheduled reports yet"}),t.jsx(o.Typography,{variant:"caption",color:"text.disabled",sx:{display:"block",mt:.5},children:'Use "New schedule" above to set up automatic exports'})]}):t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:x.map(O=>t.jsx(Ep,{schedule:O,tick:C,onToggle:I,onRunNow:b,onEdit:y=>S({type:"edit",schedule:y}),onDelete:R},O.id))})]})]}),f.type==="list"&&t.jsxs(o.DialogActions,{sx:{px:2.5,py:1.25,borderTop:"1px solid",borderColor:"divider",flexShrink:0,display:"flex",alignItems:"center",gap:1},children:[t.jsxs(o.Box,{sx:{flex:1,display:"flex",alignItems:"center",gap:.75,px:1.25,py:.75,borderRadius:"8px",bgcolor:O=>_(O.palette.warning.main,.06),border:"1px solid",borderColor:O=>_(O.palette.warning.main,.2)},children:[t.jsx($.Schedule,{sx:{fontSize:13,color:"warning.main",flexShrink:0}}),t.jsx(o.Typography,{variant:"caption",sx:{color:"warning.dark",lineHeight:1.1},children:"Schedules require this browser tab to remain open."})]}),t.jsx(o.Button,{onClick:r,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px",flexShrink:0,"&:hover":{bgcolor:O=>_(O.palette.text.primary,.06)}},children:"Close"})]})]}),v&&t.jsx(Ip,{scheduleName:v.name,onConfirm:H,onCancel:()=>m(null)})]})}const _p=6e4;function $p({reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:a,columnVisibility:c,columnOrder:l,filters:u,sortStack:g,onFired:x,schedulerConfig:f}){const S=(f==null?void 0:f.mode)??"local",C=p.useRef({reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:a,columnVisibility:c,columnOrder:l,filters:u,sortStack:g,onFired:x,schedulerConfig:f,schedulerMode:S});p.useEffect(()=>{C.current={reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:a,columnVisibility:c,columnOrder:l,filters:u,sortStack:g,onFired:x,schedulerConfig:f,schedulerMode:S}});const B=p.useCallback(v=>{var O,y,w,P,te;const{reportName:m,uploadedData:T,processedData:h,schema:z,activeView:I,columnVisibility:b,columnOrder:R,filters:H,sortStack:E,schedulerConfig:G,schedulerMode:Z}=C.current;try{const d=v.scope==="all"?T:h;if(Z==="api"){const Se=(R.length>0?R:z.map(X=>X.name)).filter(X=>b[X]!==!1),F={schedule:v,triggeredAt:new Date().toISOString(),rows:d,columns:Se,format:v.format,reportName:m};(O=G==null?void 0:G.onScheduleFire)==null||O.call(G,F),(w=(y=C.current).onFired)==null||w.call(y,v);return}const J=en(d,z,H,E,I,b,R),re=`${v.name}_scheduled`;switch(v.format){case"csv":tn(J,re,{scope:v.scope});break;case"excel":rn(J,re,{scope:v.scope});break;case"json":on(J,re,{scope:v.scope});break;case"pdf":hi(J,re,{scope:v.scope});break}if(G!=null&&G.onScheduleFire){const Se=(R.length>0?R:z.map(F=>F.name)).filter(F=>b[F]!==!1);G.onScheduleFire({schedule:v,triggeredAt:new Date().toISOString(),rows:d,columns:Se,format:v.format,reportName:m})}if(v.email){const Se=encodeURIComponent(`Scheduled Report: ${v.name}`),F=encodeURIComponent(`Your scheduled report "${v.name}" has been generated.
192
192
 
193
- Report: ${y}
194
- Format: ${b.format.toUpperCase()}
193
+ Report: ${m}
194
+ Format: ${v.format.toUpperCase()}
195
195
  Generated: ${new Date().toLocaleString()}
196
196
 
197
- The file has been downloaded to your device.`);window.open(`mailto:${b.email}?subject=${ge}&body=${V}`,"_blank")}(d=(N=C.current).onFired)==null||d.call(N,b)}catch(oe){Ut.error("urm:scheduler",`Export failed for schedule: ${b.name}`,oe)}},[]);p.useEffect(()=>{if(!e)return;const b=()=>{const{reportId:z,schedulerMode:x,schedulerConfig:j}=C.current;if(!z)return;const E=x==="api"?(j==null?void 0:j.schedules)??[]:oa(z),S=new Date;let R=!1;const q=E.map(T=>{if(!T.isActive)return T;if(new Date(T.nextRunAt)<=S){B(T);const X=Qo(T.frequency,T.time,T.dayOfWeek,T.dayOfMonth,S);return R=!0,{...T,lastRunAt:S.toISOString(),nextRunAt:X,runCount:T.runCount+1}}return T});R&&x==="local"&&na(z,q)};b();const y=setInterval(b,Dp);return()=>clearInterval(y)},[e,B])}function sa({reportEngine:e}){var Ce,Ge,zr,st,er,Wt;const{activeReport:r,paginatedData:n,processedData:i,tableMetrics:s,tableEngine:a,activeView:c,isDirty:l,currentTableState:u,showFilterPanel:g,setShowFilterPanel:f,filterFocusColumn:m,handleReplaceFilters:v,handleOpenFilterForColumn:C,handleCloseFilterPanel:B,handleClearFiltersForColumn:b,showSortPanel:y,setShowSortPanel:z,handleSort:x,handleUpdateSortStack:j,handleSortAscending:E,handleSortDescending:S,showCreateViewModal:R,setShowCreateViewModal:q,showEditViewModal:T,setShowEditViewModal:F,showDeleteConfirmation:X,setShowDeleteConfirmation:W,editingView:h,deletingView:I,handleSelectView:N,handleCreateView:d,handleUpdateCurrentView:oe,handleSaveAsNewView:G,handleRevertChanges:te,handleToggleDefault:ge,handleToggleFavorite:V,handleSoftDelete:K,handleRestoreView:ce,handlePermanentDelete:de,handleEditView:ne,handleCloneView:Q,handleCopyViewLink:pe,handleSaveEditView:D,handleConfirmDelete:ee,handlePromoteToGlobal:xe,showManageColumns:ae,setShowManageColumns:Te,handleUpdateColumnVisibility:Y,handleUpdateColumnOrder:Pe,handleUpdateColumnWidth:Et,handleResetColumnLayout:mt,showGroupPanel:$r,setShowGroupPanel:Pt,handleGroup:it,handleToggleGroupCollapse:Yt,handleExpandAllGroups:Ke,handleCollapseAllGroups:Dt,searchQuery:Sr,debouncedSearchQuery:vt,searchHistory:qt,handleSearchChange:ao,handleAddToSearchHistory:ar,handleToggleSearchFavourite:lo,handleDeleteSearchHistory:_t,selectedRowIds:Cr,handleToggleRowSelection:Xe,handleToggleAllRows:Nt,handleRangeSelection:Jt,handleClearSelection:Ze,handleUpdateSelectionAfterDelete:et,currentPage:Lt,pageSize:co,paginationTotalRows:Or,handlePageChange:wr,handlePageSizeChange:He,isExporting:Se,showExportModal:lr,setShowExportModal:Kt,showDirtyExportWarning:cr,handleExport:uo,handleExportWithConfig:Ft,handleExportSelected:Mr,handleExportAnyway:dr,handleSaveAndExport:tt,handleCancelExport:Xt,showAuditHistory:xt,setShowAuditHistory:Be,showCreatePreset:he,setShowCreatePreset:jr,showManagePresets:$t,setShowManagePresets:H,activePreset:St,handleCreatePreset:ie,handleClearActivePreset:ut,handleOpenPresetById:Ot,handleDeletePresetById:Qt,isViewerRole:Wr,userRole:kr,featureLimitWarning:Zt,setFeatureLimitWarning:ur,reportError:pr,setReportError:Ar,handleError:ze,updateReport:Qe,showSnack:Z,config:se,scheduler:be}=e,[Rr,hr]=p.useState(!1);_p({reportId:r==null?void 0:r.id,reportName:(r==null?void 0:r.name)||"Report",uploadedData:(r==null?void 0:r.uploadedData)||[],processedData:i||[],schema:(r==null?void 0:r.schema)||[],activeView:c,columnVisibility:(r==null?void 0:r.columnVisibility)||((Ce=c==null?void 0:c.snapshot)==null?void 0:Ce.columnVisibility)||{},columnOrder:(r==null?void 0:r.columnOrder)||((Ge=c==null?void 0:c.snapshot)==null?void 0:Ge.columnOrder)||[],filters:Fe(r==null?void 0:r.filters),sortStack:(r==null?void 0:r.sortStack)||[],onFired:fe=>{Z(`Scheduled export "${fe.name}" completed`,"success")},schedulerConfig:be});const Pr=p.useCallback((fe,je)=>{if(!(r!=null&&r.uploadedData))return;const We=r.uploadedData[fe],qe=[...r.uploadedData];qe[fe]=je;const at=jo(r.id,"user","rows","row_edited",We,je),Ct=ko(r.auditHistory||[],at);Qe(r.id,{uploadedData:qe,auditHistory:Ct})},[r,Qe]),po=p.useCallback(fe=>{if(!(r!=null&&r.uploadedData))return;const je=r.uploadedData.indexOf(fe);if(je===-1)return;const We=r.uploadedData.filter((Ct,tr)=>tr!==je),qe=jo(r.id,"user","rows","row_deleted",fe,null),at=ko(r.auditHistory||[],qe);Qe(r.id,{uploadedData:We,auditHistory:at}),et(fe)},[r,Qe,et]),Nr=p.useCallback((fe,je)=>{if(!(r!=null&&r.uploadedData))return;const We=r.uploadedData.indexOf(je),qe=We!==-1?We+1:fe+1,at=[...r.uploadedData];at.splice(qe,0,{...je});const Ct=jo(r.id,"user","rows","row_duplicated",je,{...je}),tr=ko(r.auditHistory||[],Ct);Qe(r.id,{uploadedData:at,auditHistory:tr})},[r,Qe]),mr=br(),{handleDevConfigChange:Lr}=dn(),[Fr,Mt]=p.useState(!1);return p.useEffect(()=>{const fe=je=>{je.ctrlKey&&je.shiftKey&&je.key==="D"&&(je.preventDefault(),Mt(!0))};return document.addEventListener("keydown",fe),()=>document.removeEventListener("keydown",fe)},[]),!r||!r.schemaLocked||!r.schema||!r.uploadedData||!r.views?null:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,position:"relative"},children:[t.jsxs(o.Box,{id:"table-content-area",sx:{flex:1,minHeight:0,display:"flex",flexDirection:"column",position:"relative"},children:[Zt&&t.jsx(hp,{warning:Zt,onDismiss:()=>ur(null)}),pr&&t.jsx(mp,{error:pr,onDismiss:()=>Ar(null)}),cr&&t.jsx(Ju,{onExportAnyway:dr,onSaveAndExport:tt,onCancel:Xt}),t.jsx(Ru,{schema:r.schema,data:n,sortStack:r.sortStack,filters:r.filters,views:r.views,activeViewId:r.activeViewId,isDirty:l,isExporting:Se,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:x,onSortAscending:E,onSortDescending:S,onOpenFilters:()=>f(!0),onOpenSort:()=>z(!0),onOpenFilterForColumn:C,onSelectView:N,onCreateView:()=>q(!0),onUpdateCurrentView:oe,onSaveAsNewView:G,onDiscardChanges:te,onToggleDefault:ge,onToggleFavorite:V,onRestoreView:ce,onPermanentDelete:de,onEditView:ne,onCloneView:Q,onCopyLink:pe,onDeleteView:K,onPromoteToGlobal:xe,isAdmin:((zr=mr.views)==null?void 0:zr.isAdmin)??!1,onExport:uo,onOpenColumns:()=>Te(!0),onUpdateColumnWidth:Et,onUpdateColumnOrder:Pe,onUpdateColumnVisibility:Y,onClearFiltersForColumn:b,onResetLayout:mt,onOpenGroup:()=>Pt(!0),onGroupByColumn:(st=se==null?void 0:se.hideToolbarActions)!=null&&st.includes("grouping")?void 0:fe=>{it({enabled:!0,levels:[{column:fe}],collapsedGroups:[]})},onToggleGroupCollapse:Yt,onExpandAllGroups:Ke,onCollapseAllGroups:Dt,onOpenAuditHistory:()=>Be(!0),onOpenScheduledReports:()=>hr(!0),searchQuery:Sr,highlightQuery:vt,searchHistory:qt,onAddToSearchHistory:ar,onToggleSearchFavourite:lo,onDeleteSearchHistory:_t,selectedRowIds:Cr,onSearchChange:ao,onToggleRowSelection:Xe,onToggleAllRows:Nt,onRangeSelection:Jt,onClearSelection:Ze,onExportSelected:Mr,currentPage:Lt,pageSize:co,onPageChange:wr,onPageSizeChange:He,totalRowsBeforePagination:Or,isReadOnly:Wr,userRole:kr,reportName:r.name,onEditRow:Pr,onDeleteRow:po,onDuplicateRow:Nr,rowActions:se==null?void 0:se.rowActions,hideDefaultRowActions:se==null?void 0:se.hideDefaultRowActions,hideToolbarActions:se==null?void 0:se.hideToolbarActions,customSettingsActions:se==null?void 0:se.customSettingsActions,jsonGuideContent:se==null?void 0:se.jsonGuideContent,viewOptions:se==null?void 0:se.viewOptions,defaultViewMode:se==null?void 0:se.defaultViewMode,bulkActions:se==null?void 0:se.bulkActions,hideSelectionCheckboxes:se==null?void 0:se.hideSelectionCheckboxes,rowClickBehavior:se==null?void 0:se.rowClickBehavior,openModalOn:se==null?void 0:se.openModalOn,onRowClick:se==null?void 0:se.onRowClick,onRowRightClick:se==null?void 0:se.onRowRightClick,showDevPanel:mr.display.showDevPanel,onOpenDevConfig:()=>Mt(!0)})]}),g&&t.jsx(Ko,{feature:"Filters",onError:fe=>{const je=gr("ui","filters",fe);ze(je)},children:t.jsx(Fu,{schema:r.schema,filters:r.filters,onReplaceFilters:v,onClose:B,focusColumn:m,onOpenDevConfig:()=>Mt(!0)})}),y&&t.jsx(Ko,{feature:"Sorting",onError:fe=>{const je=gr("ui","sorting",fe);ze(je)},children:t.jsx(Hu,{schema:r.schema,sortStack:r.sortStack??[],onUpdateSortStack:j,onClose:()=>z(!1),onOpenDevConfig:()=>Mt(!0)})}),R&&u&&(()=>{var We;const fe=(r.views??[]).filter(qe=>!qe.isDeleted).length,je=((We=mr.views)==null?void 0:We.maxViews)??10;return t.jsx(ms,{currentSnapshot:u,onSave:d,onClose:()=>q(!1),atViewLimit:fe>=je,maxViews:je})})(),T&&h&&t.jsx(ms,{currentSnapshot:h.snapshot,onSave:D,onClose:()=>{F(!1)},isEditMode:!0,initialName:h.name,initialDescription:h.description,initialIsDefault:h.isDefault}),X&&I&&t.jsx(Gu,{viewName:I.name,onConfirm:ee,onCancel:()=>{W(!1)}}),ae&&c&&t.jsx(Yu,{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:Y,onUpdateColumnOrder:Pe,onUpdateColumnWidth:Et,onResetLayout:mt,onClose:()=>Te(!1)}),$r&&t.jsx(Ko,{feature:"Grouping",onError:fe=>{const je=gr("ui","grouping",fe);ze(je)},children:t.jsx(qu,{schema:r.schema,grouping:r.grouping||null,onApply:it,onClose:()=>Pt(!1),onOpenDevConfig:()=>Mt(!0)})}),xt&&t.jsx(Qu,{auditHistory:r.auditHistory||[],onClose:()=>Be(!1)}),he&&t.jsx(Zu,{onSave:ie,onClose:()=>jr(!1)}),$t&&t.jsx(tp,{presets:r.presets||[],reportId:r.id,onOpenPreset:Ot,onDeletePreset:Qt,onClose:()=>H(!1)}),St&&t.jsx(o.Box,{sx:{mt:2},children:t.jsx(ep,{presetName:St.name,onClear:ut})}),lr&&t.jsx(Ko,{feature:"Export",onError:fe=>{const je=gr("ui","export",fe);ze(je)},children:t.jsx(pp,{totalRows:(s==null?void 0:s.totalRows)||((er=r.uploadedData)==null?void 0:er.length)||0,visibleRows:(s==null?void 0:s.searchedRows)||i.length,visibleColumnsCount:((Wt=a==null?void 0:a.columnEngine)==null?void 0:Wt.visibleColumns.length)||r.schema.length,totalColumnsCount:r.schema.length,hasGrouping:(s==null?void 0:s.isGrouped)||!1,schema:r.schema,allRows:r.uploadedData||[],processedRows:i||[],onExport:Ft,onClose:()=>{Kt(!1)}})}),r&&t.jsx(Ep,{open:Rr,onClose:()=>hr(!1),reportId:r.id,reportName:r.name,schedulerConfig:be,onRunNow:fe=>{var at;const je=(be==null?void 0:be.mode)??"local",We=fe.scope==="all"?r.uploadedData||[]:i||[],qe=Zo(We,r.schema||[],Fe(r.filters),r.sortStack||[],c,r.columnVisibility,r.columnOrder);if(je==="api"){const Ct=(r.columnOrder||[]).filter(tr=>(r.columnVisibility??{})[tr]!==!1);(at=be==null?void 0:be.onScheduleFire)==null||at.call(be,{schedule:fe,triggeredAt:new Date().toISOString(),rows:We,columns:Ct,format:fe.format,reportName:r.name})}else fe.format==="csv"&&en(qe,fe.name),fe.format==="excel"&&tn(qe,fe.name),fe.format==="json"&&rn(qe,fe.name),fe.format==="pdf"&&hi(qe,fe.name);Z(`"${fe.name}" exported successfully`,"success")}}),t.jsx(bp,{open:Fr,onClose:()=>Mt(!1),config:mr,onApply:Lr})]})}const $p={error:"err",warning:"warn",info:"info",success:"suc"};function aa({open:e,message:r,severity:n,onClose:i,autoHideDurationMs:s}){var j,E,S,R;const a=o.useTheme(),c=a.tokens,l=(c==null?void 0:c.notifPosition)??"bottom-right",u=(c==null?void 0:c.notifStyle)??"toast",g=(c==null?void 0:c.notifAccent)??"severity",f=(c==null?void 0:c.notifAutoDismiss)??!0,m=(c==null?void 0:c.toastW)??252,v=l.startsWith("top")?"top":"bottom",C=l.endsWith("center")?"center":l.endsWith("left")?"left":"right",B=$p[n],b=((j=c==null?void 0:c.status)==null?void 0:j[`${B}Soft`])??a.palette[n].light,y=((E=c==null?void 0:c.status)==null?void 0:E[`${B}Txt`])??a.palette[n].dark,z=g==="primary"?a.palette.primary.main:g==="mono"?a.palette.text.secondary:y,x=u==="toast"?(c==null?void 0:c.toastBg)??a.palette.background.paper:b;return t.jsx(o.Snackbar,{open:e,autoHideDuration:f?s??(c!=null&&c.autoDismissSec?c.autoDismissSec*1e3:3e4):void 0,onClose:(q,T)=>{T!=="escapeKeyDown"&&i()},anchorOrigin:{vertical:v,horizontal:C},children:t.jsx(o.Alert,{severity:n,icon:u==="toast"?t.jsx(o.Box,{sx:{width:30,height:30,borderRadius:`${Math.max(Math.round((Number(a.shape.borderRadius)||4)*.6),2)}px`,bgcolor:((S=c==null?void 0:c.status)==null?void 0:S[`${B}Soft`])??a.palette[n].light,color:((R=c==null?void 0:c.status)==null?void 0:R[`${B}Txt`])??a.palette[n].dark,display:"grid",placeItems:"center",flexShrink:0,fontSize:"15px",fontWeight:800,mt:-.5,ml:-.5},children:n==="error"||n==="warning"?"!":n==="success"?"✓":"i"}):void 0,action:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[f&&(c==null?void 0:c.autoDismissSec)&&t.jsx(o.Box,{sx:{px:1,py:.25,borderRadius:"999px",bgcolor:$(z,.14),color:z,fontSize:"0.7rem",fontWeight:800,fontVariantNumeric:"tabular-nums"},children:`${c.autoDismissSec}s`}),t.jsx(o.IconButton,{size:"small",onClick:i,sx:{color:"text.secondary",p:.25},children:t.jsx(O.Close,{sx:{fontSize:16}})})]}),sx:{width:m,alignItems:"flex-start",bgcolor:x,color:y,boxShadow:u==="inline"?"none":(c==null?void 0:c.cardShadow)??3,border:u==="inline"?"1px solid":u==="toast"?(c==null?void 0:c.cardBorder)??"1px solid":"none",borderColor:"divider",borderLeft:u==="banner"?`4px solid ${z}`:void 0,borderRadius:`${a.shape.borderRadius}px`,"& .MuiAlert-icon":{color:z}},children:t.jsxs(o.Box,{children:[u==="toast"&&t.jsx(o.Box,{sx:{fontWeight:700,mb:"2px",fontSize:"0.875rem",color:a.palette.text.primary},children:n==="error"?"Error":n==="warning"?"Warning":n==="success"?"Success":"Info"}),t.jsx(o.Box,{sx:{fontSize:"0.8125rem",lineHeight:1.4},children:r})]})})})}function la({hasExternalData:e=!1}){const r=dn(),{reports:n,activeReportId:i,activeReport:s,uploadState:a,hasSchemaConflicts:c,isModalOpen:l,setIsModalOpen:u,setActiveReportId:g,createReport:f,handleFileUpload:m,handleUploadError:v,handleRetry:C,handleConfirm:B,snack:b,handleSnackClose:y,snackDurationMs:z,config:x}=r,j=e&&a==="uploading"&&n.length===0;return t.jsxs(o.Box,{sx:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[t.jsx(Fl,{onCreateReport:()=>u(!0),reports:n,activeReportId:i,onReportClick:g}),t.jsx(o.Box,{component:"main",sx:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column",m:0,p:0},children:j?t.jsxs(o.Box,{sx:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2},children:[t.jsx(o.CircularProgress,{size:40,thickness:3}),t.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{minWidth:260,textAlign:"center"},children:"Fetching API data — please wait..."})]}):n.length===0?t.jsx(qs,{title:"No reports yet",description:"Create your first report to start analyzing your data."}):s?t.jsx(t.Fragment,{children:s.schemaLocked&&s.schema&&s.uploadedData&&s.views?t.jsx(sa,{reportEngine:r}):t.jsx(o.Box,{sx:{p:3},children:a==="preview"&&s.schema&&s.uploadedData?t.jsx(tu,{schema:s.schema,onConfirm:B,hasConflicts:c}):s.uploadError?t.jsx(ru,{error:s.uploadError,onRetry:C}):t.jsx(eu,{onFileUpload:m,onError:v,isUploading:a==="uploading",jsonGuideContent:x==null?void 0:x.jsonGuideContent})})}):null}),!e&&t.jsx(Zd,{isOpen:l,onClose:()=>u(!1),onCreate:f}),t.jsx(aa,{open:b.open,message:b.message,severity:b.severity,onClose:y,autoHideDurationMs:z})]})}function Op({data:e,dataSource:r,pagination:n,search:i,reportName:s,reportId:a,autoLoad:c=!0,config:l}={}){return t.jsx(mi,{mode:"builder",data:e,dataSource:r,pagination:n,search:i,reportName:s,reportId:a,autoLoad:c,config:l,children:t.jsx(la,{hasExternalData:!!(e||r)})})}function ca(){const e=dn(),{snack:r,handleSnackClose:n,snackDurationMs:i}=e;return t.jsxs(o.Box,{sx:{height:"100%",overflow:"hidden",display:"flex",flexDirection:"column"},children:[t.jsx(o.Box,{component:"main",sx:{flex:1,minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column"},children:e.activeReport?t.jsx(sa,{reportEngine:e}):t.jsx(qs,{title:"No report data",description:"This viewer requires report data to be loaded."})}),t.jsx(aa,{open:r.open,message:r.message,severity:r.severity,onClose:n,autoHideDurationMs:i})]})}function Mp({data:e,reportId:r,pagination:n,search:i,autoLoad:s=!0,config:a}){return t.jsx(mi,{data:e,reportId:r,pagination:n,search:i,mode:"viewer",autoLoad:s,config:a,children:t.jsx(ca,{})})}exports.URMBuilder=Op;exports.URMBuilderRaw=la;exports.URMProvider=mi;exports.URMViewer=Mp;exports.URMViewerRaw=ca;exports.useURMContext=dn;
197
+ The file has been downloaded to your device.`);window.open(`mailto:${v.email}?subject=${Se}&body=${F}`,"_blank")}(te=(P=C.current).onFired)==null||te.call(P,v)}catch(d){Gt.error("urm:scheduler",`Export failed for schedule: ${v.name}`,d)}},[]);p.useEffect(()=>{if(!e)return;const v=()=>{const{reportId:T,schedulerMode:h,schedulerConfig:z}=C.current;if(!T)return;const I=h==="api"?(z==null?void 0:z.schedules)??[]:ia(T),b=new Date;let R=!1;const H=I.map(E=>{if(!E.isActive)return E;if(new Date(E.nextRunAt)<=b){B(E);const Z=Zo(E.frequency,E.time,E.dayOfWeek,E.dayOfMonth,b);return R=!0,{...E,lastRunAt:b.toISOString(),nextRunAt:Z,runCount:E.runCount+1}}return E});R&&h==="local"&&sa(T,H)};v();const m=setInterval(v,_p);return()=>clearInterval(m)},[e,B])}function la({reportEngine:e}){var je,Ge,zr,at,Xt,$t;const{activeReport:r,paginatedData:n,processedData:i,tableMetrics:s,tableEngine:a,activeView:c,isDirty:l,currentTableState:u,showFilterPanel:g,setShowFilterPanel:x,filterFocusColumn:f,handleReplaceFilters:S,handleOpenFilterForColumn:C,handleCloseFilterPanel:B,handleClearFiltersForColumn:v,showSortPanel:m,setShowSortPanel:T,handleSort:h,handleUpdateSortStack:z,handleSortAscending:I,handleSortDescending:b,showCreateViewModal:R,setShowCreateViewModal:H,showEditViewModal:E,setShowEditViewModal:G,showDeleteConfirmation:Z,setShowDeleteConfirmation:O,editingView:y,deletingView:w,handleSelectView:P,handleCreateView:te,handleUpdateCurrentView:d,handleSaveAsNewView:J,handleRevertChanges:re,handleToggleDefault:Se,handleToggleFavorite:F,handleSoftDelete:X,handleRestoreView:ue,handlePermanentDelete:pe,handleEditView:K,handleCloneView:he,handleCopyViewLink:ae,handleSaveEditView:W,handleConfirmDelete:ie,handlePromoteToGlobal:U,handleSetDefaultForAllUsers:ne,showManageColumns:ke,setShowManageColumns:Q,handleUpdateColumnVisibility:De,handleUpdateColumnOrder:We,handleUpdateColumnWidth:Wt,handleResetColumnLayout:Yt,showGroupPanel:_r,setShowGroupPanel:Rt,handleGroup:ht,handleToggleGroupCollapse:bt,handleExpandAllGroups:$r,handleCollapseAllGroups:Qe,searchQuery:Et,debouncedSearchQuery:qt,searchHistory:Pt,handleSearchChange:ir,handleAddToSearchHistory:sr,handleToggleSearchFavourite:Or,handleDeleteSearchHistory:Jt,selectedRowIds:br,handleToggleRowSelection:vt,handleToggleAllRows:Je,handleRangeSelection:vr,handleClearSelection:it,handleUpdateSelectionAfterDelete:rt,currentPage:Nt,pageSize:ar,paginationTotalRows:co,handlePageChange:Mr,handlePageSizeChange:lr,isExporting:Ke,showExportModal:Ce,setShowExportModal:Dt,showDirtyExportWarning:Sr,handleExport:Ar,handleExportWithConfig:cr,handleExportSelected:Cr,handleExportAnyway:Wr,handleSaveAndExport:dr,handleCancelExport:Ze,showAuditHistory:Lt,setShowAuditHistory:ve,showCreatePreset:$o,setShowCreatePreset:fe,showManagePresets:St,setShowManagePresets:V,activePreset:ft,handleCreatePreset:se,handleClearActivePreset:st,handleOpenPresetById:wr,handleDeletePresetById:Ct,isViewerRole:Rr,userRole:ur,featureLimitWarning:jr,setFeatureLimitWarning:Ft,reportError:kr,setReportError:Pr,handleError:_e,updateReport:ut,showSnack:ee,config:le,scheduler:ye,isGrouped:uo}=e,[Nr,pr]=p.useState(!1);$p({reportId:r==null?void 0:r.id,reportName:(r==null?void 0:r.name)||"Report",uploadedData:(r==null?void 0:r.uploadedData)||[],processedData:i||[],schema:(r==null?void 0:r.schema)||[],activeView:c,columnVisibility:(r==null?void 0:r.columnVisibility)||((je=c==null?void 0:c.snapshot)==null?void 0:je.columnVisibility)||{},columnOrder:(r==null?void 0:r.columnOrder)||((Ge=c==null?void 0:c.snapshot)==null?void 0:Ge.columnOrder)||[],filters:He(r==null?void 0:r.filters),sortStack:(r==null?void 0:r.sortStack)||[],onFired:xe=>{ee(`Scheduled export "${xe.name}" completed`,"success")},schedulerConfig:ye});const Lr=p.useCallback((xe,me)=>{if(!(r!=null&&r.uploadedData))return;const Re=r.uploadedData[xe],Ne=[...r.uploadedData];Ne[xe]=me;const et=jo(r.id,"user","rows","row_edited",Re,me),wt=ko(r.auditHistory||[],et);ut(r.id,{uploadedData:Ne,auditHistory:wt})},[r,ut]),po=p.useCallback(xe=>{if(!(r!=null&&r.uploadedData))return;const me=r.uploadedData.indexOf(xe);if(me===-1)return;const Re=r.uploadedData.filter((wt,Ot)=>Ot!==me),Ne=jo(r.id,"user","rows","row_deleted",xe,null),et=ko(r.auditHistory||[],Ne);ut(r.id,{uploadedData:Re,auditHistory:et}),rt(xe)},[r,ut,rt]),Fr=p.useCallback((xe,me)=>{if(!(r!=null&&r.uploadedData))return;const Re=r.uploadedData.indexOf(me),Ne=Re!==-1?Re+1:xe+1,et=[...r.uploadedData];et.splice(Ne,0,{...me});const wt=jo(r.id,"user","rows","row_duplicated",me,{...me}),Ot=ko(r.auditHistory||[],wt);ut(r.id,{uploadedData:et,auditHistory:Ot})},[r,ut]),Kt=gr(),{handleDevConfigChange:Vr}=un(),[Hr,_t]=p.useState(!1);return p.useEffect(()=>{const xe=me=>{me.ctrlKey&&me.shiftKey&&me.key==="D"&&(me.preventDefault(),_t(!0))};return document.addEventListener("keydown",xe),()=>document.removeEventListener("keydown",xe)},[]),!r||!r.schemaLocked||!r.schema||!r.uploadedData||!r.views?null:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,position:"relative"},children:[t.jsxs(o.Box,{id:"table-content-area",sx:{flex:1,minHeight:0,display:"flex",flexDirection:"column",position:"relative",pl:uo?4:0},children:[jr&&t.jsx(fp,{warning:jr,onDismiss:()=>Ft(null)}),kr&&t.jsx(mp,{error:kr,onDismiss:()=>Pr(null)}),Sr&&t.jsx(Ku,{onExportAnyway:Wr,onSaveAndExport:dr,onCancel:Ze}),t.jsx(Pu,{schema:r.schema,data:n,sortStack:r.sortStack,filters:r.filters,views:r.views,activeViewId:r.activeViewId,isDirty:l,isExporting:Ke,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:h,onSortAscending:I,onSortDescending:b,onOpenFilters:()=>x(!0),onOpenSort:()=>T(!0),onOpenFilterForColumn:C,onSelectView:P,onCreateView:()=>H(!0),onUpdateCurrentView:d,onSaveAsNewView:J,onDiscardChanges:re,onToggleDefault:Se,onToggleFavorite:F,onRestoreView:ue,onPermanentDelete:pe,onEditView:K,onCloneView:he,onCopyLink:ae,onDeleteView:X,onPromoteToGlobal:U,onSetDefaultForAllUsers:ne,isAdmin:((zr=Kt.views)==null?void 0:zr.isAdmin)??!1,hideViewMenuActions:le==null?void 0:le.hideViewMenuActions,onExport:Ar,onOpenColumns:()=>Q(!0),onUpdateColumnWidth:Wt,onUpdateColumnOrder:We,onUpdateColumnVisibility:De,onClearFiltersForColumn:v,onResetLayout:Yt,onOpenGroup:()=>Rt(!0),onGroupByColumn:(at=le==null?void 0:le.hideToolbarActions)!=null&&at.includes("grouping")?void 0:xe=>{var Ne;const me=r==null?void 0:r.grouping;if(!((me==null?void 0:me.enabled)&&(me==null?void 0:me.levels)&&me.levels.length>0))ht({enabled:!0,levels:[{column:xe}],collapsedGroups:[]});else{if(me.levels.some(Ot=>Ot.column===xe))return;const wt=((Ne=Kt.grouping)==null?void 0:Ne.maxLevels)??3;if(me.levels.length>=wt)return;ht({enabled:!0,levels:[...me.levels,{column:xe}],collapsedGroups:me.collapsedGroups})}},onToggleGroupCollapse:bt,onExpandAllGroups:$r,onCollapseAllGroups:Qe,onOpenAuditHistory:()=>ve(!0),onOpenScheduledReports:()=>pr(!0),searchQuery:Et,highlightQuery:qt,searchHistory:Pt,onAddToSearchHistory:sr,onToggleSearchFavourite:Or,onDeleteSearchHistory:Jt,selectedRowIds:br,onSearchChange:ir,onToggleRowSelection:vt,onToggleAllRows:Je,onRangeSelection:vr,onClearSelection:it,onExportSelected:Cr,currentPage:Nt,pageSize:ar,onPageChange:Mr,onPageSizeChange:lr,totalRowsBeforePagination:co,isReadOnly:Rr,userRole:ur,reportName:r.name,onEditRow:Lr,onDeleteRow:po,onDuplicateRow:Fr,rowActions:le==null?void 0:le.rowActions,hideDefaultRowActions:le==null?void 0:le.hideDefaultRowActions,hideToolbarActions:le==null?void 0:le.hideToolbarActions,customSettingsActions:le==null?void 0:le.customSettingsActions,jsonGuideContent:le==null?void 0:le.jsonGuideContent,viewOptions:le==null?void 0:le.viewOptions,defaultViewMode:le==null?void 0:le.defaultViewMode,bulkActions:le==null?void 0:le.bulkActions,hideSelectionCheckboxes:le==null?void 0:le.hideSelectionCheckboxes,rowClickBehavior:le==null?void 0:le.rowClickBehavior,openModalOn:le==null?void 0:le.openModalOn,onRowClick:le==null?void 0:le.onRowClick,onRowRightClick:le==null?void 0:le.onRowRightClick,showDevPanel:Kt.display.showDevPanel,onOpenDevConfig:()=>_t(!0)})]}),g&&t.jsx(Xo,{feature:"Filters",onError:xe=>{const me=mr("ui","filters",xe);_e(me)},children:t.jsx(Vu,{schema:r.schema,filters:r.filters,onReplaceFilters:S,onClose:B,focusColumn:f,onOpenDevConfig:()=>_t(!0)})}),m&&t.jsx(Xo,{feature:"Sorting",onError:xe=>{const me=mr("ui","sorting",xe);_e(me)},children:t.jsx(Uu,{schema:r.schema,sortStack:r.sortStack??[],onUpdateSortStack:z,onClose:()=>T(!1),onOpenDevConfig:()=>_t(!0)})}),R&&u&&(()=>{var Re;const xe=(r.views??[]).filter(Ne=>!Ne.isDeleted).length,me=((Re=Kt.views)==null?void 0:Re.maxViews)??10;return t.jsx(xs,{currentSnapshot:u,onSave:te,onClose:()=>H(!1),atViewLimit:xe>=me,maxViews:me})})(),E&&y&&t.jsx(xs,{currentSnapshot:y.snapshot,onSave:W,onClose:()=>{G(!1)},isEditMode:!0,initialName:y.name,initialDescription:y.description,initialIsDefault:y.isDefault}),Z&&w&&t.jsx(Gu,{viewName:w.name,onConfirm:ie,onCancel:()=>{O(!1)}}),ke&&c&&t.jsx(qu,{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:De,onUpdateColumnOrder:We,onUpdateColumnWidth:Wt,onResetLayout:Yt,onClose:()=>Q(!1)}),_r&&t.jsx(Xo,{feature:"Grouping",onError:xe=>{const me=mr("ui","grouping",xe);_e(me)},children:t.jsx(Ju,{schema:r.schema,grouping:r.grouping||null,onApply:ht,onClose:()=>Rt(!1),onOpenDevConfig:()=>_t(!0)})}),Lt&&t.jsx(Zu,{auditHistory:r.auditHistory||[],onClose:()=>ve(!1)}),$o&&t.jsx(ep,{onSave:se,onClose:()=>fe(!1)}),St&&t.jsx(rp,{presets:r.presets||[],reportId:r.id,onOpenPreset:wr,onDeletePreset:Ct,onClose:()=>V(!1)}),ft&&t.jsx(o.Box,{sx:{mt:2},children:t.jsx(tp,{presetName:ft.name,onClear:st})}),Ce&&t.jsx(Xo,{feature:"Export",onError:xe=>{const me=mr("ui","export",xe);_e(me)},children:t.jsx(hp,{totalRows:(s==null?void 0:s.totalRows)||((Xt=r.uploadedData)==null?void 0:Xt.length)||0,visibleRows:(s==null?void 0:s.searchedRows)||i.length,visibleColumnsCount:(($t=a==null?void 0:a.columnEngine)==null?void 0:$t.visibleColumns.length)||r.schema.length,totalColumnsCount:r.schema.length,hasGrouping:(s==null?void 0:s.isGrouped)||!1,schema:r.schema,allRows:r.uploadedData||[],processedRows:i||[],onExport:cr,onClose:()=>{Dt(!1)}})}),r&&t.jsx(Dp,{open:Nr,onClose:()=>pr(!1),reportId:r.id,reportName:r.name,schedulerConfig:ye,onRunNow:xe=>{var et;const me=(ye==null?void 0:ye.mode)??"local",Re=xe.scope==="all"?r.uploadedData||[]:i||[],Ne=en(Re,r.schema||[],He(r.filters),r.sortStack||[],c,r.columnVisibility,r.columnOrder);if(me==="api"){const wt=(r.columnOrder||[]).filter(Ot=>(r.columnVisibility??{})[Ot]!==!1);(et=ye==null?void 0:ye.onScheduleFire)==null||et.call(ye,{schedule:xe,triggeredAt:new Date().toISOString(),rows:Re,columns:wt,format:xe.format,reportName:r.name})}else xe.format==="csv"&&tn(Ne,xe.name),xe.format==="excel"&&rn(Ne,xe.name),xe.format==="json"&&on(Ne,xe.name),xe.format==="pdf"&&hi(Ne,xe.name);ee(`"${xe.name}" exported successfully`,"success")}}),t.jsx(vp,{open:Hr,onClose:()=>_t(!1),config:Kt,onApply:Vr})]})}const Op={error:"err",warning:"warn",info:"info",success:"suc"};function ca({open:e,message:r,severity:n,onClose:i,autoHideDurationMs:s}){var z,I,b,R;const a=o.useTheme(),c=a.tokens,l=(c==null?void 0:c.notifPosition)??"bottom-right",u=(c==null?void 0:c.notifStyle)??"toast",g=(c==null?void 0:c.notifAccent)??"severity",x=(c==null?void 0:c.notifAutoDismiss)??!0,f=(c==null?void 0:c.toastW)??252,S=l.startsWith("top")?"top":"bottom",C=l.endsWith("center")?"center":l.endsWith("left")?"left":"right",B=Op[n],v=((z=c==null?void 0:c.status)==null?void 0:z[`${B}Soft`])??a.palette[n].light,m=((I=c==null?void 0:c.status)==null?void 0:I[`${B}Txt`])??a.palette[n].dark,T=g==="primary"?a.palette.primary.main:g==="mono"?a.palette.text.secondary:m,h=u==="toast"?(c==null?void 0:c.toastBg)??a.palette.background.paper:v;return t.jsx(o.Snackbar,{open:e,autoHideDuration:x?s??(c!=null&&c.autoDismissSec?c.autoDismissSec*1e3:3e4):void 0,onClose:(H,E)=>{E!=="escapeKeyDown"&&i()},anchorOrigin:{vertical:S,horizontal:C},children:t.jsx(o.Alert,{severity:n,icon:u==="toast"?t.jsx(o.Box,{sx:{width:30,height:30,borderRadius:`${Math.max(Math.round((Number(a.shape.borderRadius)||4)*.6),2)}px`,bgcolor:((b=c==null?void 0:c.status)==null?void 0:b[`${B}Soft`])??a.palette[n].light,color:((R=c==null?void 0:c.status)==null?void 0:R[`${B}Txt`])??a.palette[n].dark,display:"grid",placeItems:"center",flexShrink:0,fontSize:"15px",fontWeight:800,mt:-.5,ml:-.5},children:n==="error"||n==="warning"?"!":n==="success"?"✓":"i"}):void 0,action:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[x&&(c==null?void 0:c.autoDismissSec)&&t.jsx(o.Box,{sx:{px:1,py:.25,borderRadius:"999px",bgcolor:_(T,.14),color:T,fontSize:"0.7rem",fontWeight:800,fontVariantNumeric:"tabular-nums"},children:`${c.autoDismissSec}s`}),t.jsx(o.IconButton,{size:"small",onClick:i,sx:{color:"text.secondary",p:.25},children:t.jsx($.Close,{sx:{fontSize:16}})})]}),sx:{width:f,alignItems:"flex-start",bgcolor:h,color:m,boxShadow:u==="inline"?"none":(c==null?void 0:c.cardShadow)??3,border:u==="inline"?"1px solid":u==="toast"?(c==null?void 0:c.cardBorder)??"1px solid":"none",borderColor:"divider",borderLeft:u==="banner"?`4px solid ${T}`:void 0,borderRadius:`${a.shape.borderRadius}px`,"& .MuiAlert-icon":{color:T}},children:t.jsxs(o.Box,{children:[u==="toast"&&t.jsx(o.Box,{sx:{fontWeight:700,mb:"2px",fontSize:"0.875rem",color:a.palette.text.primary},children:n==="error"?"Error":n==="warning"?"Warning":n==="success"?"Success":"Info"}),t.jsx(o.Box,{sx:{fontSize:"0.8125rem",lineHeight:1.4},children:r})]})})})}function da({hasExternalData:e=!1}){const r=un(),{reports:n,activeReportId:i,activeReport:s,uploadState:a,hasSchemaConflicts:c,isModalOpen:l,setIsModalOpen:u,setActiveReportId:g,createReport:x,handleFileUpload:f,handleUploadError:S,handleRetry:C,handleConfirm:B,snack:v,handleSnackClose:m,snackDurationMs:T,config:h}=r,z=e&&a==="uploading"&&n.length===0;return t.jsxs(o.Box,{sx:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[t.jsx(Hl,{onCreateReport:()=>u(!0),reports:n,activeReportId:i,onReportClick:g}),t.jsx(o.Box,{component:"main",sx:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column",m:0,p:0},children:z?t.jsxs(o.Box,{sx:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2},children:[t.jsx(o.CircularProgress,{size:40,thickness:3}),t.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{minWidth:260,textAlign:"center"},children:"Fetching API data — please wait..."})]}):n.length===0?t.jsx(Ks,{title:"No reports yet",description:"Create your first report to start analyzing your data."}):s?t.jsx(t.Fragment,{children:s.schemaLocked&&s.schema&&s.uploadedData&&s.views?t.jsx(la,{reportEngine:r}):t.jsx(o.Box,{sx:{p:3},children:a==="preview"&&s.schema&&s.uploadedData?t.jsx(ou,{schema:s.schema,onConfirm:B,hasConflicts:c}):s.uploadError?t.jsx(nu,{error:s.uploadError,onRetry:C}):t.jsx(ru,{onFileUpload:f,onError:S,isUploading:a==="uploading",jsonGuideContent:h==null?void 0:h.jsonGuideContent})})}):null}),!e&&t.jsx(tu,{isOpen:l,onClose:()=>u(!1),onCreate:x}),t.jsx(ca,{open:v.open,message:v.message,severity:v.severity,onClose:m,autoHideDurationMs:T})]})}function Mp({data:e,dataSource:r,pagination:n,search:i,reportName:s,reportId:a,autoLoad:c=!0,config:l}={}){return t.jsx(fi,{mode:"builder",data:e,dataSource:r,pagination:n,search:i,reportName:s,reportId:a,autoLoad:c,config:l,children:t.jsx(da,{hasExternalData:!!(e||r)})})}function ua(){const e=un(),{snack:r,handleSnackClose:n,snackDurationMs:i}=e;return t.jsxs(o.Box,{sx:{height:"100%",overflow:"hidden",display:"flex",flexDirection:"column"},children:[t.jsx(o.Box,{component:"main",sx:{flex:1,minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column"},children:e.activeReport?t.jsx(la,{reportEngine:e}):t.jsx(Ks,{title:"No report data",description:"This viewer requires report data to be loaded."})}),t.jsx(ca,{open:r.open,message:r.message,severity:r.severity,onClose:n,autoHideDurationMs:i})]})}function Ap({data:e,reportId:r,pagination:n,search:i,autoLoad:s=!0,config:a}){return t.jsx(fi,{data:e,reportId:r,pagination:n,search:i,mode:"viewer",autoLoad:s,config:a,children:t.jsx(ua,{})})}exports.URMBuilder=Mp;exports.URMBuilderRaw=da;exports.URMProvider=fi;exports.URMViewer=Ap;exports.URMViewerRaw=ua;exports.useURMContext=un;