dts-universal-report-module 1.0.17 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +652 -652
  2. package/dist/index.esm.js +6200 -6477
  3. package/dist/index.js +26 -26
  4. package/package.json +79 -79
package/dist/index.js CHANGED
@@ -1,25 +1,25 @@
1
- "use strict";var As=Object.defineProperty;var _s=(t,o,n)=>o in t?As(t,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[o]=n;var jn=(t,o,n)=>_s(t,typeof o!="symbol"?o+"":o,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("react"),Ms=require("xlsx"),z=require("@mui/icons-material"),r=require("@mui/material"),bi=require("react-dom"),Rs=require("@emotion/react"),Ot=require("react-dnd"),an=require("react-dnd-html5-backend");function vi(t){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(o,n,i.get?i:{enumerable:!0,get:()=>t[n]})}}return o.default=t,Object.freeze(o)}const Io=vi(p),co=vi(Ms),Ke={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"]},views:{maxViews:10,isAdmin:!1},dates:{displayFormat:null},display:{showDevPanel:!1}},Si="urm_dev_config";function Ws(){try{const t=localStorage.getItem(Si);if(!t)return Ke;const o=JSON.parse(t),n={sort:{...Ke.sort,...o.sort},filter:{...Ke.filter,...o.filter},columns:{...Ke.columns,...o.columns},grouping:{...Ke.grouping,...o.grouping},export:{...Ke.export,...o.export},views:{...Ke.views,...o.views},dates:{...Ke.dates,...o.dates},display:{...Ke.display,...o.display}};return n.sort.maxLevels=Math.min(5,Math.max(1,n.sort.maxLevels)),n}catch{return Ke}}function Ps(t){try{localStorage.setItem(Si,JSON.stringify(t))}catch{}}function Ns(t,o,n){if(!n||!o)return t;const i={sort:{...t.sort,...o.sort},filter:{...t.filter,...o.filter},columns:{...t.columns,...o.columns},grouping:{...t.grouping,...o.grouping},export:{...t.export,...o.export},views:{...t.views,...o.views},dates:{...t.dates,...o.dates},display:{...t.display,...o.display}};return i.sort.maxLevels=Math.min(5,Math.max(1,i.sort.maxLevels)),i}const ji=p.createContext(Ke);function ur(){return p.useContext(ji)}const Ls=/^\d{4}-\d{2}-\d{2}$/,Fs=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/,Vs=/^(\d{1,2})[\/\-\.](\d{1,2})[\/\-\.](\d{2,4})$|^([A-Za-z]+)\s+\d{1,2},?\s+\d{4}$/,Hs=9783072e5,Us=41024448e5,Ys=978307200,Gs=4102444800;function qs(t){return t==null||t===""?"unknown":typeof t=="number"?Number.isInteger(t)&&t>=Hs&&t<=Us?"timestamp_ms":Number.isInteger(t)&&t>=Ys&&t<=Gs?"timestamp_s":"unknown":typeof t!="string"?"unknown":Fs.test(t)||Ls.test(t)?"iso":Vs.test(t.trim())?"locale_string":"unknown"}function Js(t,o){const n=o.map(l=>l[t]).filter(l=>l!=null&&l!=="");if(n.length===0)return"unknown";const i={iso:0,timestamp_ms:0,timestamp_s:0,locale_string:0,unknown:0};for(const l of n){const c=qs(l);i[c]++}const s=n.length,d=.7;for(const l of["iso","timestamp_ms","timestamp_s","locale_string"])if(i[l]/s>=d)return l;return"unknown"}function Ks(t,o){if(t==null||t==="")return null;try{switch(o){case"timestamp_ms":{const n=new Date(Number(t));return isNaN(n.getTime())?null:n}case"timestamp_s":{const n=new Date(Number(t)*1e3);return isNaN(n.getTime())?null:n}case"iso":{const n=new Date(String(t));return isNaN(n.getTime())?null:n}case"locale_string":{const n=new Date(String(t));return isNaN(n.getTime())?null:n}default:return null}}catch{return null}}const Cn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Xs=["January","February","March","April","May","June","July","August","September","October","November","December"];function Ae(t){return String(t).padStart(2,"0")}function Qs(t){const o=Date.now()-t.getTime(),n=Math.abs(o),i=o>0,s=Math.floor(n/1e3),d=Math.floor(s/60),l=Math.floor(d/60),c=Math.floor(l/24),u=Math.floor(c/7),h=Math.floor(c/30),m=Math.floor(c/365);let b;return s<60?b="just now":d<60?b=`${d} minute${d!==1?"s":""}`:l<24?b=`${l} hour${l!==1?"s":""}`:c<7?b=`${c} day${c!==1?"s":""}`:u<5?b=`${u} week${u!==1?"s":""}`:h<12?b=`${h} month${h!==1?"s":""}`:b=`${m} year${m!==1?"s":""}`,s<60?b:i?`${b} ago`:`in ${b}`}function Zs(t,o){const n=t.getFullYear(),i=t.getMonth(),s=t.getDate(),d=t.getHours(),l=t.getMinutes();switch(o){case"YYYY-MM-DD":return`${n}-${Ae(i+1)}-${Ae(s)}`;case"DD/MM/YYYY":return`${Ae(s)}/${Ae(i+1)}/${n}`;case"MM/DD/YYYY":return`${Ae(i+1)}/${Ae(s)}/${n}`;case"MMM DD, YYYY":return`${Cn[i]} ${Ae(s)}, ${n}`;case"DD MMM YYYY":return`${Ae(s)} ${Cn[i]} ${n}`;case"MMMM D, YYYY":return`${Xs[i]} ${s}, ${n}`;case"YYYY-MM-DD HH:mm":return`${n}-${Ae(i+1)}-${Ae(s)} ${Ae(d)}:${Ae(l)}`;case"DD/MM/YYYY HH:mm":return`${Ae(s)}/${Ae(i+1)}/${n} ${Ae(d)}:${Ae(l)}`;case"MM/DD/YYYY HH:mm":return`${Ae(i+1)}/${Ae(s)}/${n} ${Ae(d)}:${Ae(l)}`;case"relative":return Qs(t);case"locale":return t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"});default:return t.toLocaleDateString()}}function ea(t,o,n){if(!n||o==="unknown")return String(t);const i=Ks(t,o);return!i||isNaN(i.getTime())?String(t):Zs(i,n)}function ta(t){return t==null?"null":Array.isArray(t)?"array":typeof t=="object"?"object":typeof t=="number"?"number":typeof t=="boolean"?"boolean":typeof t=="string"?"string":"mixed"}function Ci(t,o="",n=0){if(n>2)return{[o]:t};const i={};for(const s of Object.keys(t)){const d=o?`${o}.${s}`:s,l=t[s];l!==null&&typeof l=="object"&&!Array.isArray(l)&&n<2?Object.assign(i,Ci(l,d,n+1)):i[d]=l}return i}function go(t){return t.map(o=>typeof o!="object"||o===null||Array.isArray(o)?o:Ci(o))}function Gr(t){if(!Array.isArray(t)||t.length===0)return[];const o=go(t),n=new Set;o.forEach(l=>{typeof l=="object"&&l!==null&&Object.keys(l).forEach(c=>n.add(c))});const i=[];n.forEach(l=>{const c=new Set;let u=0;o.forEach(x=>{typeof x=="object"&&x!==null&&l in x&&(u++,c.add(ta(x[l])))});const h=u===o.length,m=c.size>1&&!c.has("null");let b="mixed";if(c.size===1)b=Array.from(c)[0];else if(c.size===2&&c.has("null")){const x=Array.from(c).filter(y=>y!=="null");x.length===1&&(b=x[0])}i.push({name:l,type:b,required:h,hasConflict:m})});const d=o.slice(0,50);for(const l of i){if(l.type!=="string"&&l.type!=="number")continue;const c=Js(l.name,d);c!=="unknown"&&(l.type="date",l.dateFormat=c)}return i}function ra(t){return t.some(o=>o.hasConflict)}function Qe(t){if(!t)return"";const n=t.replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2");return n.charAt(0).toUpperCase()+n.slice(1)}function wn(t){return t==null}function oa(t){return(o,n,i)=>{const s=wn(o),d=wn(n);if(s&&d)return 0;if(s)return 1;if(d)return-1;let l=0;switch(t){case"number":const c=Number(o),u=Number(n);l=c-u;break;case"boolean":l=(o?1:0)-(n?1:0);break;case"string":l=String(o).localeCompare(String(n));break;case"array":case"object":l=JSON.stringify(o).localeCompare(JSON.stringify(n));break;case"mixed":case"null":default:l=String(o).localeCompare(String(n));break}return i==="asc"?l:-l}}function na(t,o,n){if(!n||n.length===0)return t;const i=[...n].sort((s,d)=>s.priority-d.priority);return[...t].sort((s,d)=>{for(const l of i){const c=o.find(m=>m.name===l.column);if(!c)continue;const h=oa(c.type)(s[l.column],d[l.column],l.direction);if(h!==0)return h}return 0})}function ia(t){return t===null?"asc":t==="asc"?"desc":null}function sa(t){return t==="string"||t==="boolean"}function aa(t){return t.filter(o=>sa(o.type))}function la(t,o){const n={};return o.forEach(i=>{if(i.type==="number"){const s=t.map(d=>d[i.name]).filter(d=>typeof d=="number");s.length>0&&(n[i.name]=s.reduce((d,l)=>d+l,0))}}),n}function ca(t,o,n){if(!n.enabled||n.levels.length===0)return t;const i=wi(t,n.levels,o);return ki(i,n.collapsedGroups||[])}function wi(t,o,n,i="",s=0){if(s>=o.length)return t;const d=o[s].column,l=new Map;t.forEach(h=>{const m=h[d],b=m==null?"(empty)":String(m);l.has(b)||l.set(b,[]),l.get(b).push(h)});const c=[];return Array.from(l.keys()).sort().forEach(h=>{const m=l.get(h),b=`${d}:${h}`,x=i?`${i}|${b}`:b,y=la(m,n),D=s<o.length-1?wi(m,o,n,x,s+1):m,v={key:x,level:s,column:d,value:h,rowCount:m.length,aggregates:y,children:D};c.push(v)}),c}function ki(t,o,n=[]){for(const i of t)if("key"in i&&"level"in i&&"children"in i){const s=o.includes(i.key);n.push({isGroupHeader:!0,groupKey:i.key,groupLevel:i.level,groupColumn:i.column,groupValue:i.value,rowCount:i.rowCount,aggregates:i.aggregates,isCollapsed:s}),!s&&i.children&&ki(i.children,o,n)}else n.push(i);return n}function da(t,o){const n=t.collapsedGroups||[],i=n.includes(o)?n.filter(s=>s!==o):[...n,o];return{...t,collapsedGroups:i}}function Ti(t,o){return t==null?"":typeof t=="number"?`Σ ${t.toLocaleString()}`:String(t)}function Ii(t,o,n){return`${o}: ${n}`}function Qr(t,o){if(!o||!o.enabled||!o.levels||o.levels.length===0)return[...t];const n=o.levels.map(s=>s.column),i=t.filter(s=>!n.includes(s));return[...n,...i]}function zi(t,o,n){if(!o||!o.enabled||!o.levels||o.levels.length===0)return[...t];const i=o.levels.map(d=>d.column),s=t.filter(d=>!i.includes(d));if(n){const d=[],l=new Set(i),c=new Set(s);let u=0;for(const h of n)l.has(h)?d.push(h):c.has(h)&&u<s.length?(d.push(s[u]),u++):c.has(h)||d.push(h);for(let h=u;h<s.length;h++)d.includes(s[h])||d.push(s[h]);return d}return[...t]}function Uo(t){const o={},n=[],i={};return t.forEach(s=>{o[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:[],sortStack:[],columnVisibility:o,columnOrder:n,columnWidths:i,grouping:null}}}function ua(t,o,n,i,s,d,l,c){const u={},h=[],m={};n.forEach(y=>{u[y.name]=!0,h.push(y.name),m[y.name]=170});const x=zi(s||h,l||null,c||h);return{filters:t||[],sortStack:o||[],columnVisibility:i||u,columnOrder:x,columnWidths:d||m,grouping:l||null}}function pa(t,o){const n=x=>{if(x==null)return x;if(Array.isArray(x))return x.map(y=>n(y));if(typeof x=="object"){const y={};return Object.keys(x).sort().forEach(D=>{y[D]=n(x[D])}),y}return x},i=x=>JSON.stringify(n(x));if(i(t.filters)!==i(o.filters)||i(t.sortStack)!==i(o.sortStack))return!0;const s=t.columnVisibility??{},d=o.columnVisibility??{};if(i(s)!==i(d))return!0;const l=[...t.columnOrder||[]].sort().join(","),c=[...o.columnOrder||[]].sort().join(",");if(l!==c)return!1;const u=[...o.columnOrder||[]].sort().join(",");if((o.columnOrder||[]).join(",")!==u){if((t.columnOrder||[]).join(",")!==(o.columnOrder||[]).join(","))return!0}else{const x=[...t.columnOrder||[]].sort().join(",");if((t.columnOrder||[]).join(",")!==x)return!0}const m=t.columnWidths??{},b=o.columnWidths??{};return i(m)!==i(b)||i(t.grouping)!==i(o.grouping)}function xa(t){return!t||t.length===0?"None":t.sort((o,n)=>o.priority-n.priority).map(o=>`${o.column} ${o.direction==="asc"?"↑":"↓"}`).join(", ")}function ma(t,o){var v,C,S;const n=[],i=JSON.stringify(t.filters),s=JSON.stringify(o.filters);if(i!==s){const I=t.filters.length,f=o.filters.length;I>f?n.push({category:"filters",label:"Filters Added",description:`${I-f} new filter${I-f>1?"s":""} added`}):I<f?n.push({category:"filters",label:"Filters Removed",description:`${f-I} filter${f-I>1?"s":""} removed`}):n.push({category:"filters",label:"Filters Modified",description:"Filter conditions have been changed"})}const d=JSON.stringify(t.sortStack),l=JSON.stringify(o.sortStack);if(d!==l){const I=t.sortStack.length,f=o.sortStack.length;I>f?n.push({category:"sorting",label:"Sorting Added",description:`${I-f} new sort rule${I-f>1?"s":""} added`}):I<f?n.push({category:"sorting",label:"Sorting Removed",description:`${f-I} sort rule${f-I>1?"s":""} removed`}):n.push({category:"sorting",label:"Sorting Modified",description:"Sort rules or order have been changed"})}const c=JSON.stringify(t.columnVisibility),u=JSON.stringify(o.columnVisibility);if(c!==u){const I=Object.values(t.columnVisibility).filter(k=>k).length,f=Object.values(o.columnVisibility).filter(k=>k).length;I>f?n.push({category:"visibility",label:"Columns Shown",description:`${I-f} column${I-f>1?"s":""} made visible`}):I<f?n.push({category:"visibility",label:"Columns Hidden",description:`${f-I} column${f-I>1?"s":""} hidden`}):n.push({category:"visibility",label:"Column Visibility Changed",description:"Column visibility settings have been modified"})}const h=JSON.stringify(t.columnOrder),m=JSON.stringify(o.columnOrder);h!==m&&n.push({category:"order",label:"Column Order Changed",description:"Columns have been reordered"});const b=JSON.stringify(t.columnWidths),x=JSON.stringify(o.columnWidths);if(b!==x){const I=Object.keys(t.columnWidths).filter(f=>t.columnWidths[f]!==o.columnWidths[f]).length;n.push({category:"widths",label:"Column Widths Adjusted",description:`${I} column width${I>1?"s":""} modified`})}const y=JSON.stringify(t.grouping),D=JSON.stringify(o.grouping);if(y!==D){const I=(v=t.grouping)==null?void 0:v.enabled,f=(C=o.grouping)==null?void 0:C.enabled;if(I&&!f){const k=((S=t.grouping)==null?void 0:S.levels.length)||0;n.push({category:"grouping",label:"Grouping Applied",description:`${k} grouping level${k>1?"s":""} added`})}else!I&&f?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 kn(){try{return localStorage.getItem("urm:debug")==="true"}catch{return!1}}function Tn(t){return`[${t}]`}const cr={warn(t,o,...n){kn()&&console.warn(Tn(t),o,...n)},error(t,o,...n){kn()&&console.error(Tn(t),o,...n)}},Bi="urm_report_";function ha(t,o){try{const n=`${Bi}${t}`;localStorage.setItem(n,JSON.stringify(o))}catch(n){cr.error("urm:persistence","Failed to save report state",n)}}function fa(t){try{const o=`${Bi}${t}`,n=localStorage.getItem(o);return n?JSON.parse(n):null}catch(o){return cr.error("urm:persistence","Failed to load report state",o),null}}function zo(t,o,n=0){const i=[];for(const s of t){const d=o.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:d}),!d&&s.children&&s.children.length>0){const l=s.children[0];if(ga(l)){const c=s.children,u=zo(c,o,n+1);i.push(...u)}else{const c=s.children;for(const u of c)i.push({type:"row",parentGroupKey:s.key,level:n+1,data:u})}}}return i}function ga(t){return t&&typeof t=="object"&&"key"in t&&"level"in t&&"column"in t&&"value"in t&&"rowCount"in t&&"aggregates"in t&&"children"in t}function ln(t){return t.filter(o=>o.type==="row").map(o=>o.type==="row"?o.data:null).filter(o=>o!==null)}function cn(t,o){const n=new Date,i=n.getFullYear(),s=String(n.getMonth()+1).padStart(2,"0"),d=String(n.getDate()).padStart(2,"0"),l=`${i}-${s}-${d}`;return`${t.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}_${l}.${o}`}function So(t,o,n,i,s,d,l){let c,u;d?(c={...d},u=l||o.map(m=>m.name)):s?(c={...s.snapshot.columnVisibility},u=l||[...s.snapshot.columnOrder]):(c={},u=[],o.forEach(m=>{c[m.name]=!0,u.push(m.name)}));const h=Object.entries(c).filter(([m,b])=>!b).map(([m,b])=>m);return{data:t,schema:o,appliedFilters:n,appliedSortStack:i,columnVisibility:c,columnOrder:u,grouping:(s==null?void 0:s.snapshot.grouping)??null,hiddenColumns:h,viewMeta:s?{id:s.id,name:s.name,isDefault:s.isDefault}:void 0}}function jo(t,o="export",n){const{data:i,columnOrder:s,grouping:d}=t,l=s.filter(b=>t.columnVisibility[b]);let c;if(d&&d.enabled){const b=d.collapsedGroups??[],x=zo(i,b);c=ln(x)}else c=i;const u=l.join(","),h=c.map(b=>l.map(x=>{const y=b[x];if(y==null)return"";const D=String(y);return D.includes(",")||D.includes('"')||D.includes(`
2
- `)?`"${D.replace(/"/g,'""')}"`:D}).join(",")),m=[u,...h].join(`
3
- `);Di(m,cn(o,"csv"),"text/csv;charset=utf-8;")}function Co(t,o="export",n){const{data:i,columnOrder:s,grouping:d}=t,l=s.filter(b=>t.columnVisibility[b]);let c;if(d&&d.enabled){const b=d.collapsedGroups??[],x=zo(i,b);c=ln(x)}else c=i;const u=[l,...c.map(b=>l.map(x=>b[x]??""))],h=co.utils.aoa_to_sheet(u),m=co.utils.book_new();co.utils.book_append_sheet(m,h,"Data"),co.writeFile(m,cn(o,"xlsx"))}function wo(t,o="export",n){const{data:i,appliedFilters:s,appliedSortStack:d,viewMeta:l,hiddenColumns:c,columnOrder:u,grouping:h}=t;let m;if(h&&h.enabled){const y=h.collapsedGroups??[],D=zo(i,y);m=ln(D)}else m=i;const b={meta:{exportedAt:new Date().toISOString(),reportName:o,view:(l==null?void 0:l.name)||"Default View",filters:s.map(y=>({field:y.column,operator:y.operator,value:y.value})),sortStack:d.map(y=>({field:y.column,direction:y.direction,priority:y.priority})),grouping:h||{},hiddenColumns:c,columnOrder:u,exportConfig:n||{scope:"visible"}},data:m},x=JSON.stringify(b,null,2);Di(x,cn(o,"json"),"application/json;charset=utf-8;")}function Di(t,o,n){const i=new Blob([t],{type:n}),s=URL.createObjectURL(i),d=document.createElement("a");d.href=s,d.download=o,document.body.appendChild(d),d.click(),document.body.removeChild(d),URL.revokeObjectURL(s)}const In=10;function ya(t,o){const n=o.trim();if(!n)return t;const i=t.findIndex(d=>d.query.toLowerCase()===n.toLowerCase());let s;return i!==-1?s=[{...t[i],lastUsed:Date.now()},...t.slice(0,i),...t.slice(i+1)]:s=[{query:n,isFavourite:!1,lastUsed:Date.now()},...t],s.length>In&&(s=[...s].sort((l,c)=>l.isFavourite&&!c.isFavourite?-1:!l.isFavourite&&c.isFavourite?1:c.lastUsed-l.lastUsed).slice(0,In)),s}function ba(t,o){return t.map(n=>n.query===o?{...n,isFavourite:!n.isFavourite}:n)}function va(t,o){return t.filter(n=>n.query!==o)}function Sa(t){const o=t.filter(i=>i.isFavourite).sort((i,s)=>s.lastUsed-i.lastUsed),n=t.filter(i=>!i.isFavourite).sort((i,s)=>s.lastUsed-i.lastUsed);return[...o,...n]}const ja={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 Ca(t,o){return!t||t.owner===o?"owner":t.editors.includes(o)?"editor":(t.viewers.includes(o),"viewer")}function bt(t,o){return ja[o].includes(t)}function vt(t){return`You do not have permission to ${{view_report:"view this report",edit_columns:"modify columns",edit_filters:"modify filters",edit_sorting:"modify sorting",edit_views:"edit views",create_views:"create views",delete_views:"delete views",delete_report:"delete this report",export_data:"export data",promote_global_view:"promote views to global"}[t]||"perform this action"}.`}function wa(t){return t==="viewer"}const zn=1e3;function rn(t){return t&&t.charAt(0).toUpperCase()+t.slice(1)}function Ct(t){if(!t)return"";const n=t.replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2");return rn(n)}const ka={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 Yo(t){if(!t||!t.column)return"a filter";const o=Ct(t.column),n=ka[t.operator]??t.operator;return["isTrue","isFalse","NULL","NOT_NULL"].includes(t.operator)?`"${o}" ${n}`:`"${o}" ${n} "${t.value}"`}function Bn(t){return!t||!t.enabled||t.levels.length===0?"grouping removed":`grouped by ${t.levels.map(n=>`"${Ct(n.column)}"`).join(", ")}`}function Ta(t){var s,d,l;const{action:o,previousState:n,newState:i}=t;switch(o){case"filter_added":{const c=i&&Array.isArray(i)?i[i.length-1]:i;return{summary:`Filter added: ${Yo(c)}`}}case"filter_removed":return{summary:`Filter removed: ${Yo(n)}`};case"filter_updated":{const c=n,u=i;return(c==null?void 0:c.column)!==(u==null?void 0:u.column)?{summary:`Filter changed on "${Ct(u==null?void 0:u.column)}"`,detail:`Previously filtered "${Ct(c==null?void 0:c.column)}"`}:{summary:`Filter updated: ${Yo(u)}`}}case"filter_cleared":{const c=Array.isArray(n)?n.length:0;return{summary:c>0?`All filters cleared (${c} filter${c!==1?"s":""} removed)`:"All filters cleared"}}case"sort_level_added":{const c=i!=null&&i.column?Ct(i.column):"",u=(i==null?void 0:i.direction)==="asc"?"ascending":"descending";return{summary:c?`Sort added: "${c}" ${u}`:"Sort level added"}}case"sort_level_removed":{const c=n!=null&&n.column?Ct(n.column):"";return{summary:c?`Sort removed: "${c}"`:"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: ${Bn(i)}`};case"group_level_removed":{const c=n,u=(d=(s=c==null?void 0:c.levels)==null?void 0:s[0])!=null&&d.column?Ct(c.levels[0].column):"";return{summary:u?`Group level removed: "${u}"`:"Group level removed"}}case"group_reordered":return{summary:`Grouping updated: ${Bn(i)}`};case"group_cleared":return{summary:"Grouping removed"};case"column_hidden":{const c=(i==null?void 0:i.column)??(typeof i=="string"?i:"");return{summary:c?`Column hidden: "${Ct(c)}"`:"Column hidden"}}case"column_shown":{const c=(i==null?void 0:i.column)??(typeof i=="string"?i:"");return{summary:c?`Column shown: "${Ct(c)}"`:"Column made visible"}}case"column_reordered":{const c=Array.isArray(n)?n:[],u=Array.isArray(i)?i:[];return c.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 c=(i==null?void 0:i.column)??"",u=(i==null?void 0:i.width)??"";return{summary:c?`Column resized: "${Ct(c)}"`:"Column resized",detail:u?`New width: ${u}px`:void 0}}case"view_created":{const c=(i==null?void 0:i.name)??(i==null?void 0:i.viewName)??"";return{summary:c?`View created: "${c}"`:"New view created"}}case"view_updated":{const c=(i==null?void 0:i.name)??(n==null?void 0:n.name)??"";return{summary:c?`View updated: "${c}"`:"View updated"}}case"view_deleted":{const c=(n==null?void 0:n.name)??(n==null?void 0:n.viewName)??"";return{summary:c?`View deleted: "${c}"`:"View deleted"}}case"view_set_default":{const c=(i==null?void 0:i.name)??"";return{summary:c?`Default view set to "${c}"`:"Default view changed"}}case"view_switched":{const c=(n==null?void 0:n.name)??"",u=(i==null?void 0:i.name)??"";return c&&u?{summary:`Switched to view "${u}"`,detail:`From "${c}"`}:u?{summary:`Switched to view "${u}"`}:{summary:"View switched"}}case"export_csv":case"export_excel":case"export_json":{const c=o==="export_csv"?"CSV":o==="export_excel"?"Excel":"JSON",u=i==null?void 0:i.rowCount,h=(i==null?void 0:i.scope)==="all"?"all rows":"filtered rows",m=(i==null?void 0:i.viewName)??"",b=typeof u=="number"?` (${u.toLocaleString()} rows)`:"";return{summary:`Exported as ${c}${b}`,detail:m?`${rn(h)} · View: "${m}"`:rn(h)}}case"export_triggered":{const c=((l=i==null?void 0:i.format)==null?void 0:l.toUpperCase())??"";return{summary:c?`Export triggered: ${c}`:"Export triggered"}}case"preset_created":{const c=(i==null?void 0:i.name)??"";return{summary:c?`Preset created: "${c}"`:"New preset created"}}case"preset_applied":{const c=(i==null?void 0:i.name)??"";return{summary:c?`Preset applied: "${c}"`:"Preset applied"}}case"preset_deleted":{const c=(n==null?void 0:n.name)??"";return{summary:c?`Preset deleted: "${c}"`:"Preset deleted"}}case"preset_link_copied":{const c=(i==null?void 0:i.name)??"";return{summary:c?`Preset link copied: "${c}"`:"Preset link copied to clipboard"}}case"theme_changed":{const c=typeof n=="string"?n:(n==null?void 0:n.theme)??"",u=typeof i=="string"?i:(i==null?void 0:i.theme)??"";return c&&u?{summary:`Theme changed from "${c}" to "${u}"`}:u?{summary:`Theme changed to "${u}"`}:{summary:"Theme changed"}}case"error_occurred":{const c=(i==null?void 0:i.message)??(i==null?void 0:i.error)??typeof i=="string"?i:"";return{summary:"An error was recorded",detail:c?`Details: ${String(c).slice(0,120)}`:void 0}}default:return{summary:za(o)}}}function Ia(){return`EVT_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Ei(t,o,n,i,s,d){return{id:Ia(),user:o,reportId:t,feature:n,action:i,timestamp:new Date().toISOString(),previousState:s,newState:d}}function Oi(t,o){const n=[o,...t];return n.length>zn?n.slice(0,zn):n}function za(t){return{filter_added:"Filter Added",filter_removed:"Filter Removed",filter_updated:"Filter Updated",filter_cleared:"All Filters Cleared",sort_level_added:"Sort Level Added",sort_level_removed:"Sort Level Removed",sort_reordered:"Sort Reordered",sort_cleared:"All Sorting Cleared",group_level_added:"Group Level Added",group_level_removed:"Group Level Removed",group_reordered:"Group Reordered",group_cleared:"All Grouping Cleared",column_hidden:"Column Hidden",column_shown:"Column Shown",column_reordered:"Columns Reordered",column_resized:"Column Resized",view_created:"View Created",view_updated:"View Updated",view_deleted:"View Deleted",view_set_default:"View Set as Default",view_switched:"View Switched",theme_changed:"Theme Changed",export_triggered:"Export Triggered",export_csv:"Exported as CSV",export_excel:"Exported as Excel",export_json:"Exported as JSON",preset_created:"Preset Created",preset_applied:"Preset Applied",preset_deleted:"Preset Deleted",preset_link_copied:"Preset Link Copied",error_occurred:"Error Occurred"}[t]||t}function Ba(t){return{filters:"Filters",sorting:"Sorting",grouping:"Grouping",columns:"Columns",views:"Views",theme:"Theme",export:"Export",presets:"Presets",system:"System"}[t]||t}function Da(t){const o=new Date(t),i=new Date().getTime()-o.getTime(),s=Math.floor(i/6e4),d=Math.floor(i/36e5),l=Math.floor(i/864e5);return s<1?"Just now":s<60?`${s} minute${s>1?"s":""} ago`:d<24?`${d} hour${d>1?"s":""} ago`:l<7?`${l} day${l>1?"s":""} ago`:o.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}const Dn=100;function Ea(){return`preset_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Oa(t){var d;const o=(d=t.views)==null?void 0:d.find(l=>l.id===t.activeViewId),n=o==null?void 0:o.snapshot.columnOrder,i=t.columnOrder||[],s=zi(i,t.grouping||null,n);return{filters:t.filters?[...t.filters]:[],sortStack:t.sortStack?[...t.sortStack]:[],columnVisibility:t.columnVisibility?{...t.columnVisibility}:{},columnOrder:s,columnWidths:t.columnWidths?{...t.columnWidths}:{},grouping:t.grouping?{...t.grouping}:null,activeViewId:t.activeViewId}}function $a(t,o,n,i){return{id:Ea(),name:t,description:o,createdBy:n,createdAt:Date.now(),config:i}}function Aa(t,o){const n=t||[];if(n.length>=Dn)throw new Error(`Maximum of ${Dn} presets reached. Please delete old presets first.`);return[...n,o]}function _a(t,o){return(t||[]).filter(i=>i.id!==o)}function En(t,o){if(t)return t.find(n=>n.id===o)}function Ma(){return typeof window>"u"?null:new URLSearchParams(window.location.search).get("preset")}function Ra(t){const o=t.columnOrder,n=Qr(o,t.grouping);return{filters:t.filters.length>0?[...t.filters]:void 0,sortStack:t.sortStack.length>0?[...t.sortStack]:void 0,columnVisibility:{...t.columnVisibility},columnOrder:n,columnWidths:{...t.columnWidths},grouping:t.grouping?{...t.grouping}:null,activeViewId:t.activeViewId}}function Wa(t,o){return{totalRows:t.length,totalColumns:o.length}}function Et(t,o,n,i){const s=n instanceof Error?n.message:n,d={type:t,context:o,message:s,details:i,timestamp:Date.now(),recoverable:Pa(t,o)};return process.env.NODE_ENV==="development"&&cr.error("urm:error-handling","[Report Error]",{type:t,context:o,message:s,details:i}),d}function Pa(t,o){return t==="ui"?!0:o==="export"?!1:t==="processing"&&["filters","sorting","grouping","columns"].includes(o)?!0:t!=="system"}function Na(t){const n={filters:"There was an issue applying filters",sorting:"Sorting could not be applied",grouping:"Grouping configuration failed",columns:"Column configuration could not be updated",views:"View operation failed",presets:"Preset could not be applied",export:"Export failed",upload:"File upload failed",search:"Search operation failed"}[t.context]||"An error occurred";return t.recoverable?`${n}. Your previous state has been restored.`:`${n}. Please refresh the page.`}function La(t){return{filters:t.filters?[...t.filters]:void 0,sortStack:t.sortStack?[...t.sortStack]:void 0,grouping:t.grouping?{...t.grouping}:void 0,columnVisibility:t.columnVisibility?{...t.columnVisibility}:void 0,columnOrder:t.columnOrder?[...t.columnOrder]:void 0,columnWidths:t.columnWidths?{...t.columnWidths}:void 0,activeViewId:t.activeViewId}}function Fa(t,o,n){n(t.id,{filters:o.filters,sortStack:o.sortStack,grouping:o.grouping,columnVisibility:o.columnVisibility,columnOrder:o.columnOrder,columnWidths:o.columnWidths,activeViewId:o.activeViewId})}function Va(t,o,n){return["equals","contains","starts_with","ends_with","gt","gte","lt","lte"].includes(o)&&(n==null||n==="")?{isValid:!1,errorMessage:"Value is required for this operator"}:t==="number"&&["gt","gte","lt","lte","equals"].includes(o)&&isNaN(Number(n))?{isValid:!1,errorMessage:"Value must be a valid number"}:t==="date"&&n&&isNaN(Date.parse(n))?{isValid:!1,errorMessage:"Value must be a valid date"}:{isValid:!0}}function $i(t,o){const n=[],i=[],s=new Set(o.map(d=>d.name));return t.forEach(d=>{s.has(d.column)?n.push(d):i.push(d.column)}),{validRules:n,invalidColumns:i}}function Ai(t,o){if(!t||!t.levels||t.levels.length===0)return{validGrouping:null,invalidColumns:[]};const n=new Set(o.map(d=>d.name)),i=[],s=[];return t.levels.forEach(d=>{n.has(d.column)?i.push(d):s.push(d.column)}),i.length===0?{validGrouping:null,invalidColumns:s}:{validGrouping:{...t,levels:i},invalidColumns:s}}function Ha(t,o){const n=[],i=new Set(o.map(d=>d.name)),s={...t};if(s.filters&&Array.isArray(s.filters)){const d=s.filters.filter(l=>{const c=i.has(l.column);return c||n.push(`Filter for column "${l.column}" ignored (column not found)`),c});s.filters=d.length>0?d:void 0}if(s.sortStack&&Array.isArray(s.sortStack)){const{validRules:d,invalidColumns:l}=$i(s.sortStack,o);l.length>0&&n.push(`Sort rules for columns ignored: ${l.join(", ")}`),s.sortStack=d.length>0?d:void 0}if(s.grouping){const{validGrouping:d,invalidColumns:l}=Ai(s.grouping,o);l.length>0&&n.push(`Grouping for columns ignored: ${l.join(", ")}`),s.grouping=d}if(s.columnVisibility){const d={};Object.entries(s.columnVisibility).forEach(([l,c])=>{i.has(l)?d[l]=c:n.push(`Column visibility for "${l}" ignored (column not found)`)}),s.columnVisibility=Object.keys(d).length>0?d:void 0}if(s.columnOrder&&Array.isArray(s.columnOrder)){const d=s.columnOrder.filter(l=>{const c=i.has(l);return c||n.push(`Column "${l}" in order ignored (column not found)`),c});s.columnOrder=d.length>0?d:void 0}if(s.columnWidths){const d={};Object.entries(s.columnWidths).forEach(([l,c])=>{i.has(l)?d[l]=c:n.push(`Column width for "${l}" ignored (column not found)`)}),s.columnWidths=Object.keys(d).length>0?d:void 0}return{sanitizedConfig:s,warnings:n}}function Ua(t,o){return Et("processing","export",t,{retryAvailable:!!(o!=null&&o.onRetry)})}function On(t,o,n,i){const s=Ei(t,o,"system","error_occurred",null,{errorType:n.type,errorContext:n.context,errorMessage:n.message,recoverable:n.recoverable,timestamp:n.timestamp});return Oi(i||[],s)}function Ya(t){return t==null}function Ga(t,o){const{operator:n,value:i}=o;if(n==="NULL")return t==null;if(n==="NOT_NULL")return t!=null;if(Ya(t))return!1;switch(n){case"equals":return String(t)===String(i);case"contains":return String(t).toLowerCase().includes(String(i).toLowerCase());case"startsWith":return String(t).toLowerCase().startsWith(String(i).toLowerCase());case"endsWith":return String(t).toLowerCase().endsWith(String(i).toLowerCase());case"gt":return Number(t)>Number(i);case"lt":return Number(t)<Number(i);case"gte":return Number(t)>=Number(i);case"lte":return Number(t)<=Number(i);case"isTrue":return t===!0;case"isFalse":return t===!1;default:return!0}}function qa(t,o){return!o||o.length===0?t:t.filter(n=>o.every(i=>Ga(n[i.column],i)))}function $n(t){switch(t){case"string":return[{value:"equals",label:"Equals"},{value:"contains",label:"Contains"},{value:"startsWith",label:"Starts with"},{value:"endsWith",label:"Ends with"},{value:"NULL",label:"Is NULL"},{value:"NOT_NULL",label:"Is NOT NULL"}];case"number":return[{value:"equals",label:"="},{value:"gt",label:">"},{value:"lt",label:"<"},{value:"gte",label:"≥"},{value:"lte",label:"≤"}];case"boolean":return[{value:"isTrue",label:"Is true"},{value:"isFalse",label:"Is false"},{value:"NULL",label:"Is NULL"},{value:"NOT_NULL",label:"Is NOT NULL"}];case"mixed":case"null":case"array":case"object":default:return[]}}function uo(t){return t!=="isTrue"&&t!=="isFalse"&&t!=="NULL"&&t!=="NOT_NULL"}function Ja({data:t,filters:o}){return{filteredData:p.useMemo(()=>!o||o.length===0?t:qa(t,o),[t,o])}}function Ka(t,o,n,i){if(!n||n.trim()==="")return t;const s=n.toLowerCase().trim(),d=o.filter(l=>i.includes(l.name));return t.filter(l=>d.some(c=>{const u=l[c.name];return u==null?!1:String(u).toLowerCase().includes(s)}))}function Xa({data:t,searchQuery:o,schema:n,visibleColumns:i}){return{searchedData:p.useMemo(()=>!o||o.trim()===""?t:Ka(t,n,o,i),[t,o,n,i])}}function Qa({data:t,sortStack:o,schema:n}){return{sortedData:p.useMemo(()=>!o||o.length===0?t:na(t,n,o),[t,o,n])}}function Za({data:t,grouping:o,schema:n}){const i=p.useMemo(()=>!o||!o.enabled||o.levels.length===0?t:ca(t,n,o),[t,o,n]),s=(o==null?void 0:o.enabled)&&((o==null?void 0:o.levels.length)||0)>0;return{groupedData:i,isGrouped:s}}function el({schema:t,columnVisibility:o,columnOrder:n}){const i=p.useMemo(()=>n.filter(c=>o[c]!==!1),[n,o]),s=p.useMemo(()=>Object.entries(o).filter(([c,u])=>!u).map(([c,u])=>c),[o]),d=p.useMemo(()=>n.map(c=>t.find(h=>h.name===c)||{name:c,type:"string"}),[n,t]),l=p.useMemo(()=>i.map(c=>t.find(h=>h.name===c)||{name:c,type:"string"}),[i,t]);return{visibleColumns:i,hiddenColumns:s,allColumns:d,visibleColumnSchemas:l,hiddenCount:s.length}}function tl({views:t,activeViewId:o,currentState:n}){const i=p.useMemo(()=>t.find(h=>h.id===o),[t,o]),s=p.useMemo(()=>i?pa(n,i.snapshot):!1,[i,n]),d=p.useMemo(()=>t.find(h=>h.isDefault),[t]),l=p.useMemo(()=>t.filter(h=>!h.isDefault&&!h.isDeleted),[t]),c=p.useMemo(()=>t.filter(h=>h.isFavorite&&!h.isDeleted),[t]),u=p.useMemo(()=>t.filter(h=>h.isDeleted),[t]);return{activeView:i,isDirty:s,defaultView:d,customViews:l,favoriteViews:c,deletedViews:u,isDefaultView:(i==null?void 0:i.isDefault)||!1}}function rl({data:t,enabled:o=!1,pageSize:n=100,initialPage:i=1}){const[s,d]=p.useState(i),l=t.length,c=Math.ceil(l/n),u=p.useMemo(()=>{if(!o)return t;const y=(s-1)*n,D=y+n;return t.slice(y,D)},[t,o,s,n]),h=p.useCallback(y=>{const D=Math.max(1,Math.min(y,c));d(D)},[c]),m=p.useCallback(()=>{s<c&&d(s+1)},[s,c]),b=p.useCallback(()=>{s>1&&d(s-1)},[s]),x=p.useCallback(()=>{d(1)},[]);return{paginatedData:u,currentPage:s,totalPages:c,pageSize:n,totalRows:l,goToPage:h,nextPage:m,prevPage:b,resetPage:x,hasNextPage:s<c,hasPrevPage:s>1}}function ol(t){const{rawData:o,schema:n,filters:i,sortStack:s,grouping:d,searchQuery:l,columnVisibility:c,columnOrder:u,columnWidths:h,views:m,activeViewId:b,pagination:x}=t,y=p.useMemo(()=>({filters:i,sortStack:s,grouping:d,columnVisibility:c,columnOrder:u,columnWidths:h}),[i,s,d,c,u,h]),D=tl({views:m,activeViewId:b,currentState:y}),v=el({schema:n,columnVisibility:c,columnOrder:u}),{filteredData:C}=Ja({data:o,filters:i}),{sortedData:S}=Qa({data:C,sortStack:s,schema:n}),{groupedData:I,isGrouped:f}=Za({data:S,grouping:d,schema:n}),{searchedData:k}=Xa({data:I,searchQuery:l,schema:n,visibleColumns:v.visibleColumns}),j=rl({data:k,enabled:(x==null?void 0:x.enabled)||!1,pageSize:(x==null?void 0:x.pageSize)||100,initialPage:(x==null?void 0:x.currentPage)||1}),a=x!=null&&x.enabled?j.paginatedData:k,B=p.useMemo(()=>({totalRows:o.length,filteredRows:C.length,sortedRows:S.length,groupedRows:f?I.length:S.length,searchedRows:k.length,visibleRows:a.length,hiddenColumns:v.hiddenCount,activeFilters:i.length,activeSorts:s.length,isGrouped:f}),[o.length,C.length,S.length,I.length,k.length,a.length,v.hiddenCount,i.length,s.length,f]);return{data:a,filteredData:C,sortedData:S,groupedData:I,searchedData:k,viewEngine:D,columnEngine:v,paginationEngine:j,metrics:B,isGrouped:f,isPaginated:(x==null?void 0:x.enabled)||!1}}let nl=0;function il(t){t!==null&&t.__urm_row_id__===void 0&&Object.defineProperty(t,"__urm_row_id__",{value:nl++,writable:!1,enumerable:!1,configurable:!1})}const St="user-demo-001";function sl(t={}){var gn,yn,bn,vn,Sn;const{mode:o="builder",autoLoad:n=!0,initialData:i,dataSource:s,reportName:d,sharedReportId:l,config:c={}}=t,[u,h]=p.useState([]),m=ur(),[b,x]=p.useState(""),[y,D]=p.useState(!1),[v,C]=p.useState(!1),[S,I]=p.useState({message:"",severity:"info",open:!1}),f=(w,E="info")=>{I({message:w,severity:E,open:!0})},k=()=>I(w=>({...w,open:!1})),j=c.notifDurationMs??2e3,a=u.find(w=>w.id===b),[B,R]=p.useState("idle"),[J,K]=p.useState(!1),[ee,g]=p.useState(!1),[M,W]=p.useState(!1),[V,Q]=p.useState(!1),[xe,me]=p.useState(!1),[L,A]=p.useState(!1),[H,se]=p.useState(void 0),[G,re]=p.useState(null),[ae,ne]=p.useState(null),[P,ie]=p.useState(!1),[pe,le]=p.useState(!1),[ge,q]=p.useState(null),[_e,et]=p.useState(!1),[tt,_t]=p.useState(!1),[mr,Mt]=p.useState({enabled:!1,levels:[],collapsedGroups:[]}),[Rt,Wt]=p.useState(""),[pt,Ve]=p.useState(""),[qe,Ue]=p.useState(new Set),[rt,Je]=p.useState(null),[ot,wt]=p.useState(1),[He,lt]=p.useState(15),[Re,Or]=p.useState(!1),[$r,qt]=p.useState(!1),[hr,Pt]=p.useState(!1),[xt,Nt]=p.useState(null),[fr,kt]=p.useState(!1),[Ar,Ye]=p.useState(null),[gr,_r]=p.useState(null),Jt=p.useRef(null),Ce=p.useMemo(()=>a?Ca(a.permissions,St):"owner",[a]),Mr=wa(Ce),yr=p.useMemo(()=>!(a!=null&&a.uploadedData)||!(a!=null&&a.schema)?{totalRows:0,totalColumns:0}:Wa(a.uploadedData,a.schema),[a==null?void 0:a.uploadedData,a==null?void 0:a.schema]),ct=p.useCallback(()=>{a&&(Jt.current=La(a))},[a]),F=p.useCallback((w,E)=>{h(_=>_.map($=>$.id===w?{...$,...E}:$))},[]),Ge=p.useCallback(w=>{if(!a)return;_r(w);const E=On(a.id,St,w,a.auditHistory||[]);F(a.id,{auditHistory:E}),f(w.message,"error"),w.recoverable&&Jt.current&&setTimeout(()=>{Fa(a,Jt.current,F),f("Previous state restored","success")},100)},[a,F]),we=p.useCallback((w,E,_,$)=>{if(!a)return;const Y=Ei(a.id,St,w,E,_,$),U=a.auditHistory||[],oe=Oi(U,Y);setTimeout(()=>{F(a.id,{auditHistory:oe})},0)},[a,F]);p.useEffect(()=>{if(a!=null&&a.schemaLocked&&a.schema&&(!a.views||a.views.length===0)){const w=Uo(a.schema);(()=>{try{const E=localStorage.getItem("urm_dev_config");return E?JSON.parse(E):null}catch{return null}})(),F(a.id,{views:[w],activeViewId:w.id,filters:w.snapshot.filters,sortStack:w.snapshot.sortStack,columnVisibility:w.snapshot.columnVisibility,columnOrder:w.snapshot.columnOrder,columnWidths:w.snapshot.columnWidths,grouping:w.snapshot.grouping})}},[a==null?void 0:a.schemaLocked,a==null?void 0:a.schema,a==null?void 0:a.id,F]),p.useEffect(()=>{if(i&&n&&!v&&u.length===0){const w=go(i),E={id:`auto-report-${Date.now()}`,name:d||(o==="viewer"?"Data View":"Imported Data"),description:"Auto-generated from external data",schemaLocked:!0,uploadedData:w,schema:Gr(w),permissions:{owner:St,editors:[],viewers:[]}};h([E]),x(E.id),C(!0),R("confirmed")}},[i,n,v,u.length,o,d]),p.useEffect(()=>{if(!s||v)return;let w=!1,E=null;const _=async()=>{try{R("uploading");let $;if(s.type==="api"){const U=await fetch(s.url,{headers:s.headers||{}});if(!U.ok)throw new Error(`HTTP ${U.status}: ${U.statusText}`);$=await U.json()}else $=await s.fetch();if(w)return;if(!Array.isArray($))throw new Error("Data source must return an array of objects");const Y=Gr($);if(v)h(U=>U.map(oe=>oe.id===b?{...oe,uploadedData:$}:oe)),R("confirmed");else{const U={id:`auto-report-${Date.now()}`,name:d||(o==="viewer"?"Data View":"Imported Data"),description:`Loaded from ${s.type==="api"?s.url:"callback"}`,schemaLocked:!0,uploadedData:go($),schema:Gr(go($)),permissions:{owner:St,editors:[],viewers:[]}};h([U]),x(U.id),C(!0),R("confirmed")}}catch($){w||(R("error"),a&&F(a.id,{uploadError:($==null?void 0:$.message)||"Failed to load data from source"}))}};return _(),s.refreshInterval&&s.refreshInterval>0&&(E=setInterval(_,s.refreshInterval)),()=>{w=!0,E&&clearInterval(E)}},[s,d,o]);const Pe=(gn=a==null?void 0:a.views)==null?void 0:gn.find(w=>w.id===a.activeViewId),Rr=p.useMemo(()=>a!=null&&a.uploadedData?(a.uploadedData.forEach(il),a.showFavoritesOnly?!a.favoriteRowIndices||a.favoriteRowIndices.length===0?[]:a.uploadedData.filter((w,E)=>a.favoriteRowIndices.includes(E)):a.uploadedData):[],[a==null?void 0:a.uploadedData,a==null?void 0:a.showFavoritesOnly,a==null?void 0:a.favoriteRowIndices]),Kt=p.useMemo(()=>{var E;if(!(a!=null&&a.uploadedData)||!((E=a==null?void 0:a.favoriteRowIndices)!=null&&E.length))return new Set;const w=new Set;return a.favoriteRowIndices.forEach(_=>{const $=a.uploadedData[_];$!==void 0&&w.add($)}),w},[a==null?void 0:a.uploadedData,a==null?void 0:a.showFavoritesOnly,a==null?void 0:a.favoriteRowIndices]),mt=ol({rawData:Rr,schema:(a==null?void 0:a.schema)||[],filters:(a==null?void 0:a.filters)||[],sortStack:(a==null?void 0:a.sortStack)||[],grouping:(a==null?void 0:a.grouping)||null,searchQuery:pt||"",columnVisibility:(a==null?void 0:a.columnVisibility)||(Pe==null?void 0:Pe.snapshot.columnVisibility)||{},columnOrder:(a==null?void 0:a.columnOrder)||(Pe==null?void 0:Pe.snapshot.columnOrder)||[],columnWidths:(a==null?void 0:a.columnWidths)||(Pe==null?void 0:Pe.snapshot.columnWidths)||{},views:(a==null?void 0:a.views)||[],activeViewId:(a==null?void 0:a.activeViewId)||"",pagination:{enabled:!0,pageSize:He,currentPage:ot}}),{data:Xt=[],searchedData:Qt=[],groupedData:Zt=[],metrics:Wr={totalRows:0,searchedRows:0,isGrouped:!1},isGrouped:Lt=!1,paginationEngine:ze}=mt||{},Z=((yn=mt.viewEngine)==null?void 0:yn.activeView)||Pe,ht=((bn=mt.viewEngine)==null?void 0:bn.isDirty)||!1;p.useEffect(()=>{if(!(!Z||!a)&&!a.columnOrder){const w=Z.snapshot.columnOrder,E=Qr(w,Z.snapshot.grouping);F(a.id,{columnOrder:E})}},[a==null?void 0:a.activeViewId]);const ke=p.useMemo(()=>!(a!=null&&a.schema)||!Z?null:ua(a.filters||[],a.sortStack||[],a.schema,a.columnVisibility,a.columnOrder,a.columnWidths,a.grouping,Z.snapshot.columnOrder),[a==null?void 0:a.filters,a==null?void 0:a.sortStack,a==null?void 0:a.schema,a==null?void 0:a.columnVisibility,a==null?void 0:a.columnOrder,a==null?void 0:a.columnWidths,a==null?void 0:a.grouping,Z]),ye=p.useMemo(()=>!Z||!ke||!ht?[]:ma(ke,Z.snapshot),[Z,ke,ht]),nt=p.useCallback((w,E,_)=>{const $={id:`report-${Date.now()}`,name:w,description:E,schemaLocked:!1,permissions:{owner:St,editors:[],viewers:[]}};if(_&&Array.isArray(_)&&_.length>0){const Y=Gr(_),U=Uo(Y);$.uploadedData=_,$.schema=Y,$.schemaLocked=!0,$.views=[U],$.activeViewId=U.id,$.sortStack=U.snapshot.sortStack,$.filters=U.snapshot.filters,$.columnVisibility=U.snapshot.columnVisibility,$.columnOrder=U.snapshot.columnOrder,$.columnWidths=U.snapshot.columnWidths,$.grouping=U.snapshot.grouping}h(Y=>[...Y,$]),x($.id),D(!1),R("confirmed")},[]),er=p.useCallback(w=>{a&&(R("uploading"),setTimeout(()=>{const E=Gr(w);F(a.id,{uploadedData:w,schema:E,uploadError:void 0}),R("preview")},500))},[a,F]),ft=p.useCallback(w=>{a&&(F(a.id,{uploadError:w}),R("idle"))},[a,F]),Le=p.useCallback(()=>{a&&(F(a.id,{uploadError:void 0,uploadedData:void 0,schema:void 0}),R("idle"))},[a,F]),br=p.useCallback(()=>{a&&(F(a.id,{schemaLocked:!0}),R("confirmed"))},[a,F]),Tt=p.useCallback(w=>{if(!a)return;if(!bt("edit_sorting",Ce)){f(vt("edit_sorting"),"error");return}const E=a.sortStack??[],_=E.find($=>$.column===w);if(_){const $=ia(_.direction);if($===null){const Y=E.filter(U=>U.column!==w).map((U,oe)=>({...U,priority:oe+1}));F(a.id,{sortStack:Y.length>0?Y:void 0})}else{const Y=$,U=E.map(oe=>oe.column===w?{...oe,direction:Y}:oe);F(a.id,{sortStack:U})}}else{if(E.length>=m.sort.maxLevels){f(`Sort limit reached — maximum ${m.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const $={column:w,direction:"asc",priority:E.length+1};F(a.id,{sortStack:[...E,$]})}},[a,Ce,F]),dt=p.useCallback(w=>{if(a)if(a.schema){const{validRules:E,invalidColumns:_}=$i(w,a.schema);_.length>0&&f(`Removed invalid sort columns: ${_.join(", ")}`),ct();try{F(a.id,{sortStack:E.length>0?E:void 0})}catch($){const Y=Et("processing","sorting",$);Ge(Y)}}else F(a.id,{sortStack:w.length>0?w:void 0})},[a,F,ct,Ge]),It=p.useCallback(w=>{if(!a)return;const E=a.sortStack??[],_=E.find($=>$.column===w);if(!(_&&_.direction==="asc"))if(_){const $=E.map(Y=>Y.column===w?{...Y,direction:"asc"}:Y);F(a.id,{sortStack:$})}else{if(E.length>=m.sort.maxLevels){f(`Sort limit reached — maximum ${m.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const $={column:w,direction:"asc",priority:E.length+1};F(a.id,{sortStack:[...E,$]})}},[a,F]),Pr=p.useCallback(w=>{if(!a)return;const E=a.sortStack??[],_=E.find($=>$.column===w);if(!(_&&_.direction==="desc"))if(_){const $=E.map(Y=>Y.column===w?{...Y,direction:"desc"}:Y);F(a.id,{sortStack:$})}else{if(E.length>=m.sort.maxLevels){f(`Sort limit reached — maximum ${m.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const $={column:w,direction:"desc",priority:E.length+1};F(a.id,{sortStack:[...E,$]})}},[a,F]),tr=p.useCallback(w=>{var _;if(!a)return;if(!bt("edit_filters",Ce)){f(vt("edit_filters"),"error");return}const E=(_=a.schema)==null?void 0:_.find($=>$.name===w.column);if(E&&w.value!==void 0){const $=Va(E.type,w.operator,w.value);if(!$.isValid){f($.errorMessage||"Invalid filter value","error");return}}ct();try{const $=a.filters??[];we("filters","filter_added",$,[...$,w]),F(a.id,{filters:[...$,w]})}catch($){const Y=Et("processing","filters",$);Ge(Y)}},[a,Ce,F,ct,Ge,we]),rr=p.useCallback((w,E)=>{if(!a)return;if(!bt("edit_filters",Ce)){f(vt("edit_filters"),"error");return}const _=a.filters??[],$=[..._];we("filters","filter_updated",_[w],E),$[w]=E,F(a.id,{filters:$})},[a,Ce,F,we]),Ft=p.useCallback(w=>{if(!a)return;if(!bt("edit_filters",Ce)){f(vt("edit_filters"),"error");return}const E=a.filters??[],_=E.filter(($,Y)=>Y!==w);we("filters","filter_removed",E[w],null),F(a.id,{filters:_.length>0?_:void 0})},[a,Ce,F,we]),vr=p.useCallback(()=>{if(!a)return;if(!bt("edit_filters",Ce)){f(vt("edit_filters"),"error");return}const w=a.filters??[];we("filters","filter_cleared",w,null),F(a.id,{filters:void 0})},[a,Ce,F,we]),Ne=p.useCallback(w=>{if(!a)return;if(!bt("edit_filters",Ce)){f(vt("edit_filters"),"error");return}const E=a.filters??[];we("filters","filter_cleared",E,w),F(a.id,{filters:w.length>0?w:void 0})},[a,Ce,F,we]),gt=p.useCallback(w=>{var Y;if(!a)return;const E=(Y=a.views)==null?void 0:Y.find(U=>U.id===w);if(!E)return;const _=E.snapshot.columnOrder,$=Qr(_,E.snapshot.grouping);F(a.id,{filters:E.snapshot.filters.length>0?[...E.snapshot.filters]:void 0,sortStack:E.snapshot.sortStack.length>0?[...E.snapshot.sortStack]:void 0,columnVisibility:{...E.snapshot.columnVisibility},columnOrder:$,columnWidths:{...E.snapshot.columnWidths},grouping:E.snapshot.grouping,activeViewId:w}),Ue(new Set),W(!1)},[a,F]),or=p.useCallback((w,E,_)=>{var sr;if(!(a!=null&&a.schema)||!ke)return;const $=a.views??[],Y=$.filter(Yr=>!Yr.isDeleted).length,U=((sr=m.views)==null?void 0:sr.maxViews)??10;if(Y>=U){f(`View limit reached — you can have at most ${U} saved views. Delete an existing view to create a new one.`,"error");return}const oe={id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:w,description:E||void 0,isDefault:_,isFavorite:!1,isDeleted:!1,scope:"personal",createdBy:St,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...ke}},fe=_?$.map(Yr=>({...Yr,isDefault:!1})):$;F(a.id,{views:[...fe,oe],activeViewId:oe.id}),f(`"${w}" view created`,"success")},[a,ke,F]),yt=p.useCallback(()=>{var E;if(!Z||!ke||Z.isDefault||!a)return;const w=(E=a.views)==null?void 0:E.map(_=>_.id===Z.id?{..._,snapshot:{...ke}}:_);F(a.id,{views:w}),f(`"${Z.name}" view updated`,"success")},[Z,ke,a,F]),Nr=p.useCallback(w=>{var $;if(!Z||!ke||!a)return;const E=w??ke.columnWidths,_=($=a.views)==null?void 0:$.map(Y=>Y.id===Z.id?{...Y,snapshot:{...Y.snapshot,columnVisibility:ke.columnVisibility,columnOrder:ke.columnOrder,columnWidths:E},updatedAt:Date.now()}:Y);F(a.id,{views:_,columnWidths:E}),f(`Column configuration saved to "${Z.name}"`,"success")},[Z,ke,a,F]),Lr=p.useCallback(w=>{var U,oe;if(!ke||!a||!Z)return;const E=w??ke.columnWidths,_={...Z,snapshot:{...Z.snapshot,columnVisibility:ke.columnVisibility,columnOrder:ke.columnOrder,columnWidths:E},updatedAt:Date.now()},$=(U=a.views)==null?void 0:U.map(fe=>fe.id===Z.id?_:{...fe,snapshot:{...fe.snapshot,columnVisibility:ke.columnVisibility,columnOrder:ke.columnOrder,columnWidths:E},updatedAt:Date.now()});F(a.id,{views:$,columnWidths:E});const Y=(((oe=a.views)==null?void 0:oe.length)||0)-1;f(`Column configuration saved to current view and ${Y} other view${Y===1?"":"s"}`,"success")},[ke,a,Z,F]),Vt=p.useCallback(()=>{Q(!0)},[]),Fr=p.useCallback(()=>{if(!Z||!a)return;const w=Z.snapshot.columnOrder,E=Qr(w,Z.snapshot.grouping);F(a.id,{filters:Z.snapshot.filters.length>0?[...Z.snapshot.filters]:void 0,sortStack:Z.snapshot.sortStack.length>0?[...Z.snapshot.sortStack]:void 0,columnVisibility:{...Z.snapshot.columnVisibility},columnOrder:E,columnWidths:{...Z.snapshot.columnWidths},grouping:Z.snapshot.grouping}),f("Changes reverted to last saved state","success")},[Z,a,F]),Vr=p.useCallback(w=>{if(!(a!=null&&a.views))return;const E=a.views.map($=>({...$,isDefault:$.id===w}));F(a.id,{views:E});const _=a.views.find($=>$.id===w);_&&f(`"${_.name}" set as default view`,"success")},[a,F]),nr=p.useCallback(w=>{if(!(a!=null&&a.views))return;const E=a.views.map($=>$.id===w?{...$,isFavorite:!$.isFavorite,updatedAt:Date.now()}:$);F(a.id,{views:E});const _=a.views.find($=>$.id===w);_&&!_.isFavorite?f(`"${_.name}" added to favorites`,"success"):_&&f(`"${_.name}" removed from favorites`,"info")},[a,F]),Sr=p.useCallback(w=>{if(!(a!=null&&a.views))return;const E=a.views.map(U=>U.id===w?{...U,isDeleted:!0,updatedAt:Date.now()}:U),_=a.activeViewId===w,$=E.find(U=>U.isDefault&&!U.isDeleted);F(a.id,{views:E,activeViewId:_&&$?$.id:a.activeViewId,filters:_&&$?$.snapshot.filters.length>0?$.snapshot.filters:void 0:a.filters,sortStack:_&&$?$.snapshot.sortStack.length>0?$.snapshot.sortStack:void 0:a.sortStack});const Y=a.views.find(U=>U.id===w);Y&&f(`"${Y.name}" moved to Recently Deleted`,"info")},[a,F]),jr=p.useCallback(w=>{if(!(a!=null&&a.views))return;const E=a.views.map($=>$.id===w?{...$,isDeleted:!1,updatedAt:Date.now()}:$);F(a.id,{views:E});const _=a.views.find($=>$.id===w);_&&f(`"${_.name}" restored`,"success")},[a,F]),Cr=p.useCallback(w=>{if(!(a!=null&&a.views))return;const E=a.views.find(fe=>fe.id===w),_=a.views.filter(fe=>!fe.isDeleted||fe.id===w);if((E==null?void 0:E.isDefault)&&_.filter(fe=>fe.isDefault).length===1){f("Cannot delete the last default view","error");return}const Y=a.views.filter(fe=>fe.id!==w),U=a.activeViewId===w,oe=Y.find(fe=>fe.isDefault&&!fe.isDeleted);F(a.id,{views:Y,activeViewId:U&&oe?oe.id:a.activeViewId,filters:U&&oe?oe.snapshot.filters.length>0?oe.snapshot.filters:void 0:a.filters,sortStack:U&&oe?oe.snapshot.sortStack.length>0?oe.snapshot.sortStack:void 0:a.sortStack}),E&&f(`"${E.name}" permanently deleted`,"success")},[a,F]),ir=p.useCallback(w=>{re(w),me(!0),W(!1)},[]),wr=p.useCallback((w,E)=>{if(!G||!(a!=null&&a.views))return;const _=a.views.map($=>$.id===G?{...$,name:w,description:E||void 0}:$);F(a.id,{views:_}),re(null)},[G,a,F]),de=p.useCallback(w=>{ne(w),A(!0),W(!1)},[]),ce=p.useCallback(()=>{if(!ae||!(a!=null&&a.views))return;const w=a.views.filter($=>$.id!==ae),E=a.activeViewId===ae,_=w.find($=>$.isDefault);F(a.id,{views:w,activeViewId:E&&_?_.id:a.activeViewId,filters:E&&_?_.snapshot.filters.length>0?_.snapshot.filters:void 0:a.filters,sortStack:E&&_?_.snapshot.sortStack.length>0?_.snapshot.sortStack:void 0:a.sortStack}),ne(null),A(!1)},[ae,a,F]),De=p.useCallback(w=>{var Y;if(!(a!=null&&a.views))return;if(!(((Y=m.views)==null?void 0:Y.isAdmin)??!1)){f("Only administrators can promote views to Global.","error");return}const _=a.views.find(U=>U.id===w);if(!_)return;if(_.scope==="global"){f(`"${_.name}" is already a Global View.`,"info");return}const $=a.views.map(U=>U.id===w?{...U,scope:"global",isDefault:!0,updatedAt:Date.now()}:U.scope==="global"&&U.isDefault?{...U,isDefault:!1}:U);F(a.id,{views:$}),f(`"${_.name}" promoted to Global View and set as default.`,"success")},[a,m,F]);p.useEffect(()=>{ze!=null&&ze.resetPage?ze.resetPage():wt(1)},[a==null?void 0:a.filters,pt,a==null?void 0:a.activeViewId]),p.useEffect(()=>{ze&&ze.currentPage!==ot&&wt(ze.currentPage)},[ze==null?void 0:ze.currentPage]);const ut=p.useCallback(w=>{ze!=null&&ze.goToPage&&ze.goToPage(w),wt(w)},[ze]),it=p.useCallback(w=>{const E=(ot-1)*He,_=Math.floor(E/w)+1;lt(w),wt(_),ze==null||ze.goToPage(_)},[ot,He,ze]),zt=p.useCallback((w,E)=>{if(!a)return;if(!bt("edit_columns",Ce)){f(vt("edit_columns"),"error");return}const $={...a.columnVisibility||(Z==null?void 0:Z.snapshot.columnVisibility)||{},[w]:E};F(a.id,{columnVisibility:$})},[a,Z,Ce,F]),Hr=p.useCallback(w=>{if(a){if(!bt("edit_columns",Ce)){f(vt("edit_columns"),"error");return}F(a.id,{columnOrder:w})}},[a,Ce,F]),Ht=p.useCallback((w,E)=>{if(!a)return;if(!bt("edit_columns",Ce)){f(vt("edit_columns"),"error");return}const $={...a.columnWidths||(Z==null?void 0:Z.snapshot.columnWidths)||{},[w]:E};F(a.id,{columnWidths:$})},[a,Z,Ce,F]),ao=p.useCallback(w=>{if(!a)return;const _=(a.filters??[]).filter($=>$.column!==w);F(a.id,{filters:_.length>0?_:void 0})},[a,F]),O=p.useCallback(()=>{if(!Z||!(a!=null&&a.schema))return;const w={},E=[],_={};a.schema.forEach($=>{w[$.name]=!0,E.push($.name),_[$.name]=170}),F(a.id,{columnVisibility:w,columnOrder:E,columnWidths:_,filters:void 0,sortStack:void 0}),f("Reset to default layout - all filters and sorts cleared","success")},[Z,a,F]);p.useEffect(()=>{const w=setTimeout(()=>Ve(Rt),300);return()=>clearTimeout(w)},[Rt]);const X=p.useCallback(w=>{Wt(w)},[]),he=p.useCallback(w=>{if(!w.trim()||!a)return;const E=a.searchHistory||[],_=ya(E,w);F(a.id,{searchHistory:_})},[a,F]),Fe=p.useCallback(w=>{if(!a)return;const E=a.searchHistory||[],_=ba(E,w);F(a.id,{searchHistory:_})},[a,F]),ue=p.useCallback(w=>{if(!a)return;const E=a.searchHistory||[],_=va(E,w);F(a.id,{searchHistory:_})},[a,F]),Bt=p.useCallback(w=>{const E=w==null?void 0:w.__urm_row_id__;Ue(_=>{const $=new Set(_);if(E!==void 0){const Y=Array.from($).find(U=>(U==null?void 0:U.__urm_row_id__)===E);Y!==void 0?$.delete(Y):$.add(w)}else{const Y=JSON.stringify(w),U=Array.from($).find(oe=>JSON.stringify(oe)===Y);U!==void 0?$.delete(U):$.add(w)}return $})},[]),Ho=p.useCallback((w,E)=>{Ue(_=>{const $=new Set(_);for(const Y of E)w?$.add(Y):$.delete(Y);return $})},[]),us=p.useCallback((w,E,_)=>{Ue($=>{const Y=new Set($),U=Math.min(w,E),oe=Math.max(w,E);for(let fe=U;fe<=oe;fe++)_[fe]!==void 0&&Y.add(_[fe]);return Y})},[]),ps=p.useCallback(()=>{Ue(new Set),Je(null)},[]),xs=p.useCallback(w=>{const E=w==null?void 0:w.__urm_row_id__;Ue(_=>{const $=new Set(_);if(E!==void 0){const Y=Array.from($).find(U=>(U==null?void 0:U.__urm_row_id__)===E);Y!==void 0&&$.delete(Y)}else $.delete(w);return $})},[]),ms=p.useCallback(w=>{if(!(a!=null&&a.uploadedData))return;const E=a.uploadedData.indexOf(w);if(E===-1)return;const _=a.favoriteRowIndices||[],Y=_.includes(E)?_.filter(U=>U!==E):[..._,E];F(a.id,{favoriteRowIndices:Y})},[a,F]),hs=p.useCallback((w,E)=>{if(!(a!=null&&a.uploadedData))return;const _=a.favoriteRowIndices||[],$=w.map(U=>a.uploadedData.indexOf(U)).filter(U=>U!==-1),Y=E?[..._,...$.filter(U=>!_.includes(U))]:_.filter(U=>!$.includes(U));F(a.id,{favoriteRowIndices:Y})},[a,F]),fs=p.useCallback(()=>{if(!a)return;const w=a.favoriteRowIndices||[],E=!a.showFavoritesOnly;if(E&&w.length===0){f("No rows marked as favorite","warning");return}if(F(a.id,{showFavoritesOnly:E}),E){if(Je(new Set(qe)),qe.size>0){const _=new Set(w.map(Y=>{var U,oe;return(oe=(U=a.uploadedData)==null?void 0:U[Y])==null?void 0:oe.__urm_row_id__}).filter(Y=>Y!==void 0)),$=new Set(Array.from(qe).filter(Y=>(Y==null?void 0:Y.__urm_row_id__)!==void 0&&_.has(Y.__urm_row_id__)));Ue($)}f(`Showing ${w.length} favorite row${w.length===1?"":"s"}`,"info")}else{if(rt!==null){const _=new Set(Array.from(qe).map(oe=>oe==null?void 0:oe.__urm_row_id__).filter(Boolean)),$=new Set(Array.from(rt).map(oe=>oe==null?void 0:oe.__urm_row_id__).filter(Boolean)),Y=new Set(w.map(oe=>{var fe,sr;return(sr=(fe=a.uploadedData)==null?void 0:fe[oe])==null?void 0:sr.__urm_row_id__}).filter(oe=>oe!==void 0)),U=new Set;Array.from(rt).forEach(oe=>{const fe=oe==null?void 0:oe.__urm_row_id__;if(fe===void 0)return;const sr=Y.has(fe),Yr=_.has(fe);sr&&!Yr||U.add(oe)}),Array.from(qe).forEach(oe=>{const fe=oe==null?void 0:oe.__urm_row_id__;fe!==void 0&&($.has(fe)||U.add(oe))}),Ue(U),Je(null)}f("Showing all data","info")}},[a,F,qe,rt]),gs=p.useCallback(w=>{if(a){if(!bt("edit_columns",Ce)){f(vt("edit_columns"),"error");return}if(w&&a.schema){const{validGrouping:E,invalidColumns:_}=Ai(w,a.schema);_.length>0&&f(`Removed invalid grouping columns: ${_.join(", ")}`,"warning"),ct();try{const $=a.grouping;E===null?we("grouping","group_cleared",$,null):$?we("grouping","group_reordered",$,E):we("grouping","group_level_added",null,E);const Y=(Z==null?void 0:Z.snapshot.columnOrder)||a.columnOrder||[],U=Qr(Y,E);F(a.id,{grouping:E,columnOrder:U}),JSON.stringify(U)!==JSON.stringify(a.columnOrder)&&we("columns","column_reordered",a.columnOrder,U),_t(!1)}catch($){const Y=Et("processing","grouping",$);Ge(Y)}}else{const E=a.grouping;we("grouping","group_cleared",E,null);const _=(Z==null?void 0:Z.snapshot.columnOrder)||a.columnOrder||[];F(a.id,{grouping:w,columnOrder:[..._]}),JSON.stringify(_)!==JSON.stringify(a.columnOrder)&&we("columns","column_reordered",a.columnOrder,_),_t(!1)}}},[a,Z,Ce,F,ct,Ge,we]),ys=p.useCallback(w=>{if(!a)return;const E=a.grouping;if(!E)return;const _=da(E,w);F(a.id,{grouping:_})},[a,F]),bs=p.useCallback(()=>{kt(!0)},[]),Ur=p.useCallback(w=>{a!=null&&a.schema&&(ie(!0),setTimeout(()=>{try{let E;w.scope==="visible"?E=Qt:E=a.uploadedData||[];let _;w.columnScope==="all"?(_={},(a.schema??[]).forEach(fe=>{_[fe.name]=!0})):_=a.columnVisibility||(Z==null?void 0:Z.snapshot.columnVisibility)||{};const $=a.columnOrder||(Z==null?void 0:Z.snapshot.columnOrder),Y=So(E,a.schema,a.filters??[],a.sortStack??[],Z,_,$),U=a.name;let oe;switch(w.format){case"csv":jo(Y,U,w),oe="export_csv";break;case"excel":Co(Y,U,w),oe="export_excel";break;case"json":wo(Y,U,w),oe="export_json";break}we("export",oe,null,{format:w.format,scope:w.scope,columnScope:w.columnScope,rowCount:E.length,viewName:(Z==null?void 0:Z.name)||"Default View"}),f(`Export completed successfully (${w.format.toUpperCase()})`,"success")}catch(E){const _=Ua(E,{onRetry:()=>Ur(w)});f(`Export failed: ${_.message}. Click Export to retry.`,"error");const $=On(a.id,St,_,a.auditHistory||[]);F(a.id,{auditHistory:$}),cr.error("urm:report-engine","Export failed",E)}finally{ie(!1)}},500))},[a,Z,Qt,F,we]),vs=p.useCallback(w=>{if(a!=null&&a.schema){if(ht&&Z&&!Z.isDefault){q(w.format),le(!0),kt(!1);return}Ur(w),kt(!1)}},[a,Z,ht,Ur]),lo=p.useCallback(w=>{Ur({format:w,scope:"visible",columnScope:"visible"})},[Ur]),Ss=p.useCallback(()=>{ge&&lo(ge),le(!1),q(null)},[ge,lo]),js=p.useCallback(()=>{yt(),ge&&lo(ge),le(!1),q(null)},[yt,ge,lo]),Cs=p.useCallback(()=>{le(!1),q(null)},[]),ws=p.useCallback(w=>{!(a!=null&&a.schema)||qe.size===0||(ie(!0),setTimeout(()=>{try{const E=Array.from(qe),_=So(E,a.schema,a.filters??[],a.sortStack??[],Z),$=`${a.name.toLowerCase().replace(/\s+/g,"_")}_selected_export`;switch(w){case"csv":jo(_,$);break;case"excel":Co(_,$);break;case"json":wo(_,$);break}f(`Exported ${E.length} selected rows`,"info")}catch(E){f("Export failed. Please try again.","error"),cr.error("urm:report-engine","Bulk export failed",E)}finally{ie(!1)}},500))},[a,Z,qe,Zt]),ks=p.useCallback((w,E)=>{if(a)try{const _=Oa(a),$=$a(w,E,St,_),Y=Aa(a.presets,$);F(a.id,{presets:Y}),we("presets","preset_created",null,{presetId:$.id,name:$.name}),qt(!1),f(`Preset "${w}" saved successfully`,"success")}catch(_){f(_ instanceof Error?_.message:"Failed to create preset","error")}},[a,F,we]),Ts=p.useCallback(()=>{Nt(null),f("Exited preset view","info")},[]),Is=p.useCallback(()=>{Pt(!0)},[]),zs=p.useCallback((w,E)=>{if(!a)return;const _=_a(a.presets,w);F(a.id,{presets:_}),we("presets","preset_deleted",{presetId:w,name:E},null),xt===w&&Nt(null),f(`Preset "${E}" deleted`,"success")},[a,xt,F,we]);p.useEffect(()=>{if(!l||u.length===0)return;const w=u.find(E=>E.id===l);w&&w.id!==b&&x(w.id)},[l,u,b]),p.useEffect(()=>{if(!a)return;const w=Ma();if(w&&a.presets&&a.schemaLocked&&a.schema){const E=En(a.presets,w);if(E){const{sanitizedConfig:_,warnings:$}=Ha(E.config,a.schema);$.length>0&&$.forEach(U=>f(U,"warning"));const Y=Ra(_);F(a.id,Y),Nt(w),we("presets","preset_applied",null,{presetId:E.id,name:E.name}),f(`Loaded preset: ${E.name}`,"info")}else f("Preset not found","info")}},[a==null?void 0:a.schemaLocked]);const Bs=xt?En(a==null?void 0:a.presets,xt):void 0;p.useEffect(()=>{a!=null&&a.views&&a.views.length>0&&a.activeViewId&&ha(a.id,{views:a.views,activeViewId:a.activeViewId})},[a==null?void 0:a.views,a==null?void 0:a.activeViewId,a==null?void 0:a.id]),p.useEffect(()=>{if(a!=null&&a.schemaLocked&&a.schema&&(!a.views||a.views.length===0)){const w=fa(a.id);if(w&&w.views.length>0){const E=w.views.find(_=>_.id===w.activeViewId);if(E)F(a.id,{views:w.views,activeViewId:w.activeViewId,filters:E.snapshot.filters.length>0?E.snapshot.filters:void 0,sortStack:E.snapshot.sortStack.length>0?E.snapshot.sortStack:void 0});else{const _=w.views.find($=>$.isDefault)||Uo(a.schema);F(a.id,{views:w.views,activeViewId:_.id,filters:_.snapshot.filters.length>0?_.snapshot.filters:void 0,sortStack:_.snapshot.sortStack.length>0?_.snapshot.sortStack:void 0})}}}},[a==null?void 0:a.schemaLocked,a==null?void 0:a.schema,a==null?void 0:a.id]);const Ds=p.useCallback(w=>{var $;const E=(a==null?void 0:a.filters)??[],_=(($=m.filter)==null?void 0:$.maxConditions)??3;if(E.length>=_){f(`Filter limit reached — maximum ${_} filters allowed. Remove an existing filter before adding a new one.`,"warning");return}se(w),K(!0)},[a,m,f]),Es=p.useCallback(()=>{K(!1),se(void 0)},[]),Os=(vn=a==null?void 0:a.views)==null?void 0:vn.find(w=>w.id===G),$s=(Sn=a==null?void 0:a.views)==null?void 0:Sn.find(w=>w.id===ae);return{reports:u,activeReport:a,activeReportId:b,setActiveReportId:x,isModalOpen:y,setIsModalOpen:D,createReport:nt,updateReport:F,uploadState:B,handleFileUpload:er,handleUploadError:ft,handleRetry:Le,handleConfirm:br,paginatedData:Xt,processedData:Qt,displayData:Zt,tableMetrics:Wr,isGrouped:Lt,tableEngine:mt,activeView:Z,isDirty:ht,currentTableState:ke,viewChanges:ye,filters:a==null?void 0:a.filters,showFilterPanel:J,setShowFilterPanel:K,filterFocusColumn:H,handleAddFilter:tr,handleUpdateFilter:rr,handleRemoveFilter:Ft,handleClearAllFilters:vr,handleReplaceFilters:Ne,handleOpenFilterForColumn:Ds,handleCloseFilterPanel:Es,handleClearFiltersForColumn:ao,sortStack:a==null?void 0:a.sortStack,showSortPanel:ee,setShowSortPanel:g,handleSort:Tt,handleUpdateSortStack:dt,handleSortAscending:It,handleSortDescending:Pr,views:a==null?void 0:a.views,showManageViews:M,setShowManageViews:W,showCreateViewModal:V,setShowCreateViewModal:Q,showEditViewModal:xe,setShowEditViewModal:me,showDeleteConfirmation:L,setShowDeleteConfirmation:A,editingView:Os,deletingView:$s,editingViewId:G,deletingViewId:ae,handleSelectView:gt,handleCreateView:or,handleUpdateCurrentView:yt,handleSaveColumnConfigToCurrentView:Nr,handleSaveColumnConfigToAllViews:Lr,handleSaveAsNewView:Vt,handleRevertChanges:Fr,handleToggleDefault:Vr,handleToggleFavorite:nr,handleSoftDelete:Sr,handleRestoreView:jr,handlePermanentDelete:Cr,handleEditView:ir,handleSaveEditView:wr,handleDeleteView:de,handleConfirmDelete:ce,handlePromoteToGlobal:De,showManageColumns:_e,setShowManageColumns:et,columnVisibility:a==null?void 0:a.columnVisibility,columnOrder:a==null?void 0:a.columnOrder,columnWidths:a==null?void 0:a.columnWidths,handleUpdateColumnVisibility:zt,handleUpdateColumnOrder:Hr,handleUpdateColumnWidth:Ht,handleResetColumnLayout:O,showGroupPanel:tt,setShowGroupPanel:_t,grouping:a==null?void 0:a.grouping,groupingState:mr,handleGroup:gs,handleToggleGroupCollapse:ys,searchQuery:Rt,debouncedSearchQuery:pt,searchHistory:Sa((a==null?void 0:a.searchHistory)||[]),handleSearchChange:X,handleAddToSearchHistory:he,handleToggleSearchFavourite:Fe,handleDeleteSearchHistory:ue,selectedRowIds:qe,handleToggleRowSelection:Bt,handleToggleAllRows:Ho,handleRangeSelection:us,handleClearSelection:ps,handleUpdateSelectionAfterDelete:xs,favoriteRowIndices:(a==null?void 0:a.favoriteRowIndices)||[],resolvedFavoritesSet:Kt,showFavoritesOnly:(a==null?void 0:a.showFavoritesOnly)||!1,handleToggleRowFavorite:ms,handleBulkSetFavorites:hs,handleToggleFavoritesFilter:fs,currentPage:ot,pageSize:He,paginationEngine:ze,handlePageChange:ut,handlePageSizeChange:it,isExporting:P,showExportModal:fr,setShowExportModal:kt,showDirtyExportWarning:pe,handleExport:bs,handleExportWithConfig:vs,handleExportSelected:ws,handleExportAnyway:Ss,handleSaveAndExport:js,handleCancelExport:Cs,showAuditHistory:Re,setShowAuditHistory:Or,auditHistory:a==null?void 0:a.auditHistory,showCreatePreset:$r,setShowCreatePreset:qt,showManagePresets:hr,setShowManagePresets:Pt,activePreset:Bs,activePresetId:xt,handleOpenManagePresets:Is,handleCreatePreset:ks,handleClearActivePreset:Ts,handleDeletePresetById:zs,userRole:Ce,isViewerRole:Mr,currentUserId:St,featureLimitWarning:Ar,setFeatureLimitWarning:Ye,datasetMeta:yr,reportError:gr,setReportError:_r,handleError:Ge,schema:a==null?void 0:a.schema,hasSchemaConflicts:a!=null&&a.schema?ra(a.schema):!1,snack:S,handleSnackClose:k,showSnack:f,snackDurationMs:j}}const _i=p.createContext(void 0);function dn(t){const{children:o,initialData:n,data:i,reportName:s,dataSource:d,mode:l="builder",autoLoad:c=!0,config:u,devConfig:h,showDevPanel:m=!1,sharedReportId:b}=t,y=sl({mode:l,autoLoad:c,initialData:i||n,dataSource:d,reportName:s,sharedReportId:b,config:u}),[D,v]=p.useState(()=>Ws()),C=(()=>{const k=Ns(D,h,!!h);return{...k,display:{...k.display,showDevPanel:m||k.display.showDevPanel}}})(),S=p.useCallback(f=>{v(f),Ps(f)},[]),I={...y,activeDevConfig:C,handleDevConfigChange:S};return e.jsx(ji.Provider,{value:C,children:e.jsx(_i.Provider,{value:I,children:o})})}function Bo(){const t=p.useContext(_i);if(t===void 0)throw new Error("useReportContext must be used within a ReportProvider. Wrap your component tree with <ReportProvider>...</ReportProvider>");return t}function al({onCreateReport:t,reports:o=[],activeReportId:n,onReportClick:i}){const s=o.find(d=>d.id===n);return e.jsx(r.Box,{component:"header",sx:{position:"sticky",top:0,zIndex:50,borderBottom:"1px solid",borderColor:"divider",bgcolor:"background.paper"},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,height:64},children:[e.jsxs(r.Breadcrumbs,{separator:e.jsx(z.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}),sx:{display:"flex",alignItems:"center"},children:[e.jsx(r.Typography,{variant:"h6",component:"h1",sx:{fontWeight:500,fontSize:"1.375rem",color:"text.primary",letterSpacing:"-0.01em",cursor:o.length>0&&s?"pointer":"default","&:hover":o.length>0&&s?{color:"primary.main"}:{}},onClick:()=>{o.length>0},children:"Reports"}),s&&e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"1.125rem",color:"primary.main",cursor:"pointer","&:hover":{textDecoration:"underline"}},onClick:()=>i==null?void 0:i(s.id),children:s.name}),e.jsx(r.Tooltip,{title:s.description||"No description",arrow:!0,placement:"bottom",children:e.jsx(z.InfoOutlined,{sx:{fontSize:18,color:"text.secondary",opacity:.7,cursor:"help","&:hover":{opacity:1}}})})]})]}),e.jsx(r.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:e.jsx(r.Button,{variant:"contained",startIcon:e.jsx(z.Add,{sx:{fontSize:18}}),onClick:t,sx:{borderRadius:"20px",px:3,fontSize:"0.875rem",py:.75},children:"New Report"})})]})})}function dr(t,...o){const n=new URL(`https://mui.com/production-error/?code=${t}`);return o.forEach(i=>n.searchParams.append("args[]",i)),`Minified MUI error #${t}; visit ${n} for the full message.`}const ll="$$material";function cl(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var po={exports:{}},xo={exports:{}},be={};/** @license React v16.13.1
1
+ "use strict";var Bs=Object.defineProperty;var Is=(t,o,n)=>o in t?Bs(t,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[o]=n;var bn=(t,o,n)=>Is(t,typeof o!="symbol"?o+"":o,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("react"),Ds=require("xlsx"),B=require("@mui/icons-material"),r=require("@mui/material"),gi=require("react-dom"),Es=require("@emotion/react"),kt=require("react-dnd"),tn=require("react-dnd-html5-backend");function yi(t){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(o,n,i.get?i:{enumerable:!0,get:()=>t[n]})}}return o.default=t,Object.freeze(o)}const vo=yi(p),ro=yi(Ds),qe={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"]},views:{maxViews:10,isAdmin:!1},dates:{displayFormat:null},display:{showDevPanel:!1}},bi="urm_dev_config";function Os(){try{const t=localStorage.getItem(bi);if(!t)return qe;const o=JSON.parse(t),n={sort:{...qe.sort,...o.sort},filter:{...qe.filter,...o.filter},columns:{...qe.columns,...o.columns},grouping:{...qe.grouping,...o.grouping},export:{...qe.export,...o.export},views:{...qe.views,...o.views},dates:{...qe.dates,...o.dates},display:{...qe.display,...o.display}};return n.sort.maxLevels=Math.min(5,Math.max(1,n.sort.maxLevels)),n}catch{return qe}}function As(t){try{localStorage.setItem(bi,JSON.stringify(t))}catch{}}function $s(t,o,n){if(!n||!o)return t;const i={sort:{...t.sort,...o.sort},filter:{...t.filter,...o.filter},columns:{...t.columns,...o.columns},grouping:{...t.grouping,...o.grouping},export:{...t.export,...o.export},views:{...t.views,...o.views},dates:{...t.dates,...o.dates},display:{...t.display,...o.display}};return i.sort.maxLevels=Math.min(5,Math.max(1,i.sort.maxLevels)),i}const vi=p.createContext(qe);function nr(){return p.useContext(vi)}const Ms=/^\d{4}-\d{2}-\d{2}$/,Rs=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/,_s=/^(\d{1,2})[\/\-\.](\d{1,2})[\/\-\.](\d{2,4})$|^([A-Za-z]+)\s+\d{1,2},?\s+\d{4}$/,Ws=9783072e5,Ps=41024448e5,Ns=978307200,Ls=4102444800;function Fs(t){return t==null||t===""?"unknown":typeof t=="number"?Number.isInteger(t)&&t>=Ws&&t<=Ps?"timestamp_ms":Number.isInteger(t)&&t>=Ns&&t<=Ls?"timestamp_s":"unknown":typeof t!="string"?"unknown":Rs.test(t)||Ms.test(t)?"iso":_s.test(t.trim())?"locale_string":"unknown"}function Vs(t,o){const n=o.map(c=>c[t]).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=Fs(c);i[l]++}const s=n.length,d=.7;for(const c of["iso","timestamp_ms","timestamp_s","locale_string"])if(i[c]/s>=d)return c;return"unknown"}function Hs(t,o){if(t==null||t==="")return null;try{switch(o){case"timestamp_ms":{const n=new Date(Number(t));return isNaN(n.getTime())?null:n}case"timestamp_s":{const n=new Date(Number(t)*1e3);return isNaN(n.getTime())?null:n}case"iso":{const n=new Date(String(t));return isNaN(n.getTime())?null:n}case"locale_string":{const n=new Date(String(t));return isNaN(n.getTime())?null:n}default:return null}}catch{return null}}const vn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Us=["January","February","March","April","May","June","July","August","September","October","November","December"];function Oe(t){return String(t).padStart(2,"0")}function Ys(t){const o=Date.now()-t.getTime(),n=Math.abs(o),i=o>0,s=Math.floor(n/1e3),d=Math.floor(s/60),c=Math.floor(d/60),l=Math.floor(c/24),u=Math.floor(l/7),f=Math.floor(l/30),m=Math.floor(l/365);let h;return s<60?h="just now":d<60?h=`${d} minute${d!==1?"s":""}`:c<24?h=`${c} hour${c!==1?"s":""}`:l<7?h=`${l} day${l!==1?"s":""}`:u<5?h=`${u} week${u!==1?"s":""}`:f<12?h=`${f} month${f!==1?"s":""}`:h=`${m} year${m!==1?"s":""}`,s<60?h:i?`${h} ago`:`in ${h}`}function Gs(t,o){const n=t.getFullYear(),i=t.getMonth(),s=t.getDate(),d=t.getHours(),c=t.getMinutes();switch(o){case"YYYY-MM-DD":return`${n}-${Oe(i+1)}-${Oe(s)}`;case"DD/MM/YYYY":return`${Oe(s)}/${Oe(i+1)}/${n}`;case"MM/DD/YYYY":return`${Oe(i+1)}/${Oe(s)}/${n}`;case"MMM DD, YYYY":return`${vn[i]} ${Oe(s)}, ${n}`;case"DD MMM YYYY":return`${Oe(s)} ${vn[i]} ${n}`;case"MMMM D, YYYY":return`${Us[i]} ${s}, ${n}`;case"YYYY-MM-DD HH:mm":return`${n}-${Oe(i+1)}-${Oe(s)} ${Oe(d)}:${Oe(c)}`;case"DD/MM/YYYY HH:mm":return`${Oe(s)}/${Oe(i+1)}/${n} ${Oe(d)}:${Oe(c)}`;case"MM/DD/YYYY HH:mm":return`${Oe(i+1)}/${Oe(s)}/${n} ${Oe(d)}:${Oe(c)}`;case"relative":return Ys(t);case"locale":return t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"});default:return t.toLocaleDateString()}}function qs(t,o,n){if(!n||o==="unknown")return String(t);const i=Hs(t,o);return!i||isNaN(i.getTime())?String(t):Gs(i,n)}function Js(t){return t==null?"null":Array.isArray(t)?"array":typeof t=="object"?"object":typeof t=="number"?"number":typeof t=="boolean"?"boolean":typeof t=="string"?"string":"mixed"}function Si(t,o="",n=0){if(n>2)return{[o]:t};const i={};for(const s of Object.keys(t)){const d=o?`${o}.${s}`:s,c=t[s];c!==null&&typeof c=="object"&&!Array.isArray(c)&&n<2?Object.assign(i,Si(c,d,n+1)):i[d]=c}return i}function co(t){return t.map(o=>typeof o!="object"||o===null||Array.isArray(o)?o:Si(o))}function Wr(t){if(!Array.isArray(t)||t.length===0)return[];const o=co(t),n=new Set;o.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;o.forEach(x=>{typeof x=="object"&&x!==null&&c in x&&(u++,l.add(Js(x[c])))});const f=u===o.length,m=l.size>1&&!l.has("null");let h="mixed";if(l.size===1)h=Array.from(l)[0];else if(l.size===2&&l.has("null")){const x=Array.from(l).filter(b=>b!=="null");x.length===1&&(h=x[0])}i.push({name:c,type:h,required:f,hasConflict:m})});const d=o.slice(0,50);for(const c of i){if(c.type!=="string"&&c.type!=="number")continue;const l=Vs(c.name,d);l!=="unknown"&&(c.type="date",c.dateFormat=l)}return i}function Ks(t){return t.some(o=>o.hasConflict)}function Ke(t){if(!t)return"";const n=t.replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2");return n.charAt(0).toUpperCase()+n.slice(1)}function Sn(t){return t==null}function Xs(t){return(o,n,i)=>{const s=Sn(o),d=Sn(n);if(s&&d)return 0;if(s)return 1;if(d)return-1;let c=0;switch(t){case"number":const l=Number(o),u=Number(n);c=l-u;break;case"boolean":c=(o?1:0)-(n?1:0);break;case"string":c=String(o).localeCompare(String(n));break;case"array":case"object":c=JSON.stringify(o).localeCompare(JSON.stringify(n));break;case"mixed":case"null":default:c=String(o).localeCompare(String(n));break}return i==="asc"?c:-c}}function Qs(t,o,n){if(!n||n.length===0)return t;const i=[...n].sort((s,d)=>s.priority-d.priority);return[...t].sort((s,d)=>{for(const c of i){const l=o.find(m=>m.name===c.column);if(!l)continue;const f=Xs(l.type)(s[c.column],d[c.column],c.direction);if(f!==0)return f}return 0})}function Zs(t){return t===null?"asc":t==="asc"?"desc":null}function ea(t){return t==="string"||t==="boolean"}function ta(t){return t.filter(o=>ea(o.type))}function ra(t,o){const n={};return o.forEach(i=>{if(i.type==="number"){const s=t.map(d=>d[i.name]).filter(d=>typeof d=="number");s.length>0&&(n[i.name]=s.reduce((d,c)=>d+c,0))}}),n}function oa(t,o,n){if(!n.enabled||n.levels.length===0)return t;const i=ji(t,n.levels,o);return Ci(i,n.collapsedGroups||[])}function ji(t,o,n,i="",s=0){if(s>=o.length)return t;const d=o[s].column,c=new Map;t.forEach(f=>{const m=f[d],h=m==null?"(empty)":String(m);c.has(h)||c.set(h,[]),c.get(h).push(f)});const l=[];return Array.from(c.keys()).sort().forEach(f=>{const m=c.get(f),h=`${d}:${f}`,x=i?`${i}|${h}`:h,b=ra(m,n),D=s<o.length-1?ji(m,o,n,x,s+1):m,g={key:x,level:s,column:d,value:f,rowCount:m.length,aggregates:b,children:D};l.push(g)}),l}function Ci(t,o,n=[]){for(const i of t)if("key"in i&&"level"in i&&"children"in i){const s=o.includes(i.key);n.push({isGroupHeader:!0,groupKey:i.key,groupLevel:i.level,groupColumn:i.column,groupValue:i.value,rowCount:i.rowCount,aggregates:i.aggregates,isCollapsed:s}),!s&&i.children&&Ci(i.children,o,n)}else n.push(i);return n}function na(t,o){const n=t.collapsedGroups||[],i=n.includes(o)?n.filter(s=>s!==o):[...n,o];return{...t,collapsedGroups:i}}function wi(t,o){return t==null?"":typeof t=="number"?`Σ ${t.toLocaleString()}`:String(t)}function ki(t,o,n){return`${o}: ${n}`}function Vr(t,o){if(!o||!o.enabled||!o.levels||o.levels.length===0)return[...t];const n=o.levels.map(s=>s.column),i=t.filter(s=>!n.includes(s));return[...n,...i]}function Ti(t,o,n){if(!o||!o.enabled||!o.levels||o.levels.length===0)return[...t];const i=o.levels.map(d=>d.column),s=t.filter(d=>!i.includes(d));if(n){const d=[],c=new Set(i),l=new Set(s);let u=0;for(const f of n)c.has(f)?d.push(f):l.has(f)&&u<s.length?(d.push(s[u]),u++):l.has(f)||d.push(f);for(let f=u;f<s.length;f++)d.includes(s[f])||d.push(s[f]);return d}return[...t]}function No(t){const o={},n=[],i={};return t.forEach(s=>{o[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:[],sortStack:[],columnVisibility:o,columnOrder:n,columnWidths:i,grouping:null}}}function ia(t,o,n,i,s,d,c,l){const u={},f=[],m={};n.forEach(b=>{u[b.name]=!0,f.push(b.name),m[b.name]=170});const x=Ti(s||f,c||null,l||f);return{filters:t||[],sortStack:o||[],columnVisibility:i||u,columnOrder:x,columnWidths:d||m,grouping:c||null}}function sa(t,o){const n=x=>{if(x==null)return x;if(Array.isArray(x))return x.map(b=>n(b));if(typeof x=="object"){const b={};return Object.keys(x).sort().forEach(D=>{b[D]=n(x[D])}),b}return x},i=x=>JSON.stringify(n(x));if(i(t.filters)!==i(o.filters)||i(t.sortStack)!==i(o.sortStack))return!0;const s=t.columnVisibility??{},d=o.columnVisibility??{};if(i(s)!==i(d))return!0;const c=[...t.columnOrder||[]].sort().join(","),l=[...o.columnOrder||[]].sort().join(",");if(c!==l)return!1;const u=[...o.columnOrder||[]].sort().join(",");if((o.columnOrder||[]).join(",")!==u){if((t.columnOrder||[]).join(",")!==(o.columnOrder||[]).join(","))return!0}else{const x=[...t.columnOrder||[]].sort().join(",");if((t.columnOrder||[]).join(",")!==x)return!0}const m=t.columnWidths??{},h=o.columnWidths??{};return i(m)!==i(h)||i(t.grouping)!==i(o.grouping)}function aa(t){return!t||t.length===0?"None":t.sort((o,n)=>o.priority-n.priority).map(o=>`${o.column} ${o.direction==="asc"?"↑":"↓"}`).join(", ")}function la(t,o){var g,j,w;const n=[],i=JSON.stringify(t.filters),s=JSON.stringify(o.filters);if(i!==s){const I=t.filters.length,v=o.filters.length;I>v?n.push({category:"filters",label:"Filters Added",description:`${I-v} new filter${I-v>1?"s":""} added`}):I<v?n.push({category:"filters",label:"Filters Removed",description:`${v-I} filter${v-I>1?"s":""} removed`}):n.push({category:"filters",label:"Filters Modified",description:"Filter conditions have been changed"})}const d=JSON.stringify(t.sortStack),c=JSON.stringify(o.sortStack);if(d!==c){const I=t.sortStack.length,v=o.sortStack.length;I>v?n.push({category:"sorting",label:"Sorting Added",description:`${I-v} new sort rule${I-v>1?"s":""} added`}):I<v?n.push({category:"sorting",label:"Sorting Removed",description:`${v-I} sort rule${v-I>1?"s":""} removed`}):n.push({category:"sorting",label:"Sorting Modified",description:"Sort rules or order have been changed"})}const l=JSON.stringify(t.columnVisibility),u=JSON.stringify(o.columnVisibility);if(l!==u){const I=Object.values(t.columnVisibility).filter(S=>S).length,v=Object.values(o.columnVisibility).filter(S=>S).length;I>v?n.push({category:"visibility",label:"Columns Shown",description:`${I-v} column${I-v>1?"s":""} made visible`}):I<v?n.push({category:"visibility",label:"Columns Hidden",description:`${v-I} column${v-I>1?"s":""} hidden`}):n.push({category:"visibility",label:"Column Visibility Changed",description:"Column visibility settings have been modified"})}const f=JSON.stringify(t.columnOrder),m=JSON.stringify(o.columnOrder);f!==m&&n.push({category:"order",label:"Column Order Changed",description:"Columns have been reordered"});const h=JSON.stringify(t.columnWidths),x=JSON.stringify(o.columnWidths);if(h!==x){const I=Object.keys(t.columnWidths).filter(v=>t.columnWidths[v]!==o.columnWidths[v]).length;n.push({category:"widths",label:"Column Widths Adjusted",description:`${I} column width${I>1?"s":""} modified`})}const b=JSON.stringify(t.grouping),D=JSON.stringify(o.grouping);if(b!==D){const I=(g=t.grouping)==null?void 0:g.enabled,v=(j=o.grouping)==null?void 0:j.enabled;if(I&&!v){const S=((w=t.grouping)==null?void 0:w.levels.length)||0;n.push({category:"grouping",label:"Grouping Applied",description:`${S} grouping level${S>1?"s":""} added`})}else!I&&v?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 jn(){try{return localStorage.getItem("urm:debug")==="true"}catch{return!1}}function Cn(t){return`[${t}]`}const rr={warn(t,o,...n){jn()&&console.warn(Cn(t),o,...n)},error(t,o,...n){jn()&&console.error(Cn(t),o,...n)}},zi="urm_report_";function ca(t,o){try{const n=`${zi}${t}`;localStorage.setItem(n,JSON.stringify(o))}catch(n){rr.error("urm:persistence","Failed to save report state",n)}}function da(t){try{const o=`${zi}${t}`,n=localStorage.getItem(o);return n?JSON.parse(n):null}catch(o){return rr.error("urm:persistence","Failed to load report state",o),null}}function So(t,o,n=0){const i=[];for(const s of t){const d=o.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:d}),!d&&s.children&&s.children.length>0){const c=s.children[0];if(ua(c)){const l=s.children,u=So(l,o,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 ua(t){return t&&typeof t=="object"&&"key"in t&&"level"in t&&"column"in t&&"value"in t&&"rowCount"in t&&"aggregates"in t&&"children"in t}function rn(t){return t.filter(o=>o.type==="row").map(o=>o.type==="row"?o.data:null).filter(o=>o!==null)}function on(t,o){const n=new Date,i=n.getFullYear(),s=String(n.getMonth()+1).padStart(2,"0"),d=String(n.getDate()).padStart(2,"0"),c=`${i}-${s}-${d}`;return`${t.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}_${c}.${o}`}function mo(t,o,n,i,s,d,c){let l,u;d?(l={...d},u=c||o.map(m=>m.name)):s?(l={...s.snapshot.columnVisibility},u=c||[...s.snapshot.columnOrder]):(l={},u=[],o.forEach(m=>{l[m.name]=!0,u.push(m.name)}));const f=Object.entries(l).filter(([m,h])=>!h).map(([m,h])=>m);return{data:t,schema:o,appliedFilters:n,appliedSortStack:i,columnVisibility:l,columnOrder:u,grouping:(s==null?void 0:s.snapshot.grouping)??null,hiddenColumns:f,viewMeta:s?{id:s.id,name:s.name,isDefault:s.isDefault}:void 0}}function ho(t,o="export",n){const{data:i,columnOrder:s,grouping:d}=t,c=s.filter(h=>t.columnVisibility[h]);let l;if(d&&d.enabled){const h=d.collapsedGroups??[],x=So(i,h);l=rn(x)}else l=i;const u=c.join(","),f=l.map(h=>c.map(x=>{const b=h[x];if(b==null)return"";const D=String(b);return D.includes(",")||D.includes('"')||D.includes(`
2
+ `)?`"${D.replace(/"/g,'""')}"`:D}).join(",")),m=[u,...f].join(`
3
+ `);Bi(m,on(o,"csv"),"text/csv;charset=utf-8;")}function fo(t,o="export",n){const{data:i,columnOrder:s,grouping:d}=t,c=s.filter(h=>t.columnVisibility[h]);let l;if(d&&d.enabled){const h=d.collapsedGroups??[],x=So(i,h);l=rn(x)}else l=i;const u=[c,...l.map(h=>c.map(x=>h[x]??""))],f=ro.utils.aoa_to_sheet(u),m=ro.utils.book_new();ro.utils.book_append_sheet(m,f,"Data"),ro.writeFile(m,on(o,"xlsx"))}function go(t,o="export",n){const{data:i,appliedFilters:s,appliedSortStack:d,viewMeta:c,hiddenColumns:l,columnOrder:u,grouping:f}=t;let m;if(f&&f.enabled){const b=f.collapsedGroups??[],D=So(i,b);m=rn(D)}else m=i;const h={meta:{exportedAt:new Date().toISOString(),reportName:o,view:(c==null?void 0:c.name)||"Default View",filters:s.map(b=>({field:b.column,operator:b.operator,value:b.value})),sortStack:d.map(b=>({field:b.column,direction:b.direction,priority:b.priority})),grouping:f||{},hiddenColumns:l,columnOrder:u,exportConfig:n||{scope:"visible"}},data:m},x=JSON.stringify(h,null,2);Bi(x,on(o,"json"),"application/json;charset=utf-8;")}function Bi(t,o,n){const i=new Blob([t],{type:n}),s=URL.createObjectURL(i),d=document.createElement("a");d.href=s,d.download=o,document.body.appendChild(d),d.click(),document.body.removeChild(d),URL.revokeObjectURL(s)}const wn=10;function pa(t,o){const n=o.trim();if(!n)return t;const i=t.findIndex(d=>d.query.toLowerCase()===n.toLowerCase());let s;return i!==-1?s=[{...t[i],lastUsed:Date.now()},...t.slice(0,i),...t.slice(i+1)]:s=[{query:n,isFavourite:!1,lastUsed:Date.now()},...t],s.length>wn&&(s=[...s].sort((c,l)=>c.isFavourite&&!l.isFavourite?-1:!c.isFavourite&&l.isFavourite?1:l.lastUsed-c.lastUsed).slice(0,wn)),s}function xa(t,o){return t.map(n=>n.query===o?{...n,isFavourite:!n.isFavourite}:n)}function ma(t,o){return t.filter(n=>n.query!==o)}function ha(t){const o=t.filter(i=>i.isFavourite).sort((i,s)=>s.lastUsed-i.lastUsed),n=t.filter(i=>!i.isFavourite).sort((i,s)=>s.lastUsed-i.lastUsed);return[...o,...n]}const fa={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 ga(t,o){return!t||t.owner===o?"owner":t.editors.includes(o)?"editor":(t.viewers.includes(o),"viewer")}function ut(t,o){return fa[o].includes(t)}function pt(t){return`You do not have permission to ${{view_report:"view this report",edit_columns:"modify columns",edit_filters:"modify filters",edit_sorting:"modify sorting",edit_views:"edit views",create_views:"create views",delete_views:"delete views",delete_report:"delete this report",export_data:"export data",promote_global_view:"promote views to global"}[t]||"perform this action"}.`}function ya(t){return t==="viewer"}const kn=1e3;function Xo(t){return t&&t.charAt(0).toUpperCase()+t.slice(1)}function ht(t){if(!t)return"";const n=t.replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2");return Xo(n)}const ba={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 Lo(t){if(!t||!t.column)return"a filter";const o=ht(t.column),n=ba[t.operator]??t.operator;return["isTrue","isFalse","NULL","NOT_NULL"].includes(t.operator)?`"${o}" ${n}`:`"${o}" ${n} "${t.value}"`}function Tn(t){return!t||!t.enabled||t.levels.length===0?"grouping removed":`grouped by ${t.levels.map(n=>`"${ht(n.column)}"`).join(", ")}`}function va(t){var s,d,c;const{action:o,previousState:n,newState:i}=t;switch(o){case"filter_added":{const l=i&&Array.isArray(i)?i[i.length-1]:i;return{summary:`Filter added: ${Lo(l)}`}}case"filter_removed":return{summary:`Filter removed: ${Lo(n)}`};case"filter_updated":{const l=n,u=i;return(l==null?void 0:l.column)!==(u==null?void 0:u.column)?{summary:`Filter changed on "${ht(u==null?void 0:u.column)}"`,detail:`Previously filtered "${ht(l==null?void 0:l.column)}"`}:{summary:`Filter updated: ${Lo(u)}`}}case"filter_cleared":{const l=Array.isArray(n)?n.length: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?ht(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?ht(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: ${Tn(i)}`};case"group_level_removed":{const l=n,u=(d=(s=l==null?void 0:l.levels)==null?void 0:s[0])!=null&&d.column?ht(l.levels[0].column):"";return{summary:u?`Group level removed: "${u}"`:"Group level removed"}}case"group_reordered":return{summary:`Grouping updated: ${Tn(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: "${ht(l)}"`:"Column hidden"}}case"column_shown":{const l=(i==null?void 0:i.column)??(typeof i=="string"?i:"");return{summary:l?`Column shown: "${ht(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: "${ht(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":{const l=o==="export_csv"?"CSV":o==="export_excel"?"Excel":"JSON",u=i==null?void 0:i.rowCount,f=(i==null?void 0:i.scope)==="all"?"all rows":"filtered rows",m=(i==null?void 0:i.viewName)??"",h=typeof u=="number"?` (${u.toLocaleString()} rows)`:"";return{summary:`Exported as ${l}${h}`,detail:m?`${Xo(f)} · View: "${m}"`:Xo(f)}}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"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:ja(o)}}}function Sa(){return`EVT_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Ii(t,o,n,i,s,d){return{id:Sa(),user:o,reportId:t,feature:n,action:i,timestamp:new Date().toISOString(),previousState:s,newState:d}}function Di(t,o){const n=[o,...t];return n.length>kn?n.slice(0,kn):n}function ja(t){return{filter_added:"Filter Added",filter_removed:"Filter Removed",filter_updated:"Filter Updated",filter_cleared:"All Filters Cleared",sort_level_added:"Sort Level Added",sort_level_removed:"Sort Level Removed",sort_reordered:"Sort Reordered",sort_cleared:"All Sorting Cleared",group_level_added:"Group Level Added",group_level_removed:"Group Level Removed",group_reordered:"Group Reordered",group_cleared:"All Grouping Cleared",column_hidden:"Column Hidden",column_shown:"Column Shown",column_reordered:"Columns Reordered",column_resized:"Column Resized",view_created:"View Created",view_updated:"View Updated",view_deleted:"View Deleted",view_set_default:"View Set as Default",view_switched:"View Switched",theme_changed:"Theme Changed",export_triggered:"Export Triggered",export_csv:"Exported as CSV",export_excel:"Exported as Excel",export_json:"Exported as JSON",preset_created:"Preset Created",preset_applied:"Preset Applied",preset_deleted:"Preset Deleted",preset_link_copied:"Preset Link Copied",error_occurred:"Error Occurred"}[t]||t}function Ca(t){return{filters:"Filters",sorting:"Sorting",grouping:"Grouping",columns:"Columns",views:"Views",theme:"Theme",export:"Export",presets:"Presets",system:"System"}[t]||t}function wa(t){const o=new Date(t),i=new Date().getTime()-o.getTime(),s=Math.floor(i/6e4),d=Math.floor(i/36e5),c=Math.floor(i/864e5);return s<1?"Just now":s<60?`${s} minute${s>1?"s":""} ago`:d<24?`${d} hour${d>1?"s":""} ago`:c<7?`${c} day${c>1?"s":""} ago`:o.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}const zn=100;function ka(){return`preset_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Ta(t){var d;const o=(d=t.views)==null?void 0:d.find(c=>c.id===t.activeViewId),n=o==null?void 0:o.snapshot.columnOrder,i=t.columnOrder||[],s=Ti(i,t.grouping||null,n);return{filters:t.filters?[...t.filters]:[],sortStack:t.sortStack?[...t.sortStack]:[],columnVisibility:t.columnVisibility?{...t.columnVisibility}:{},columnOrder:s,columnWidths:t.columnWidths?{...t.columnWidths}:{},grouping:t.grouping?{...t.grouping}:null,activeViewId:t.activeViewId}}function za(t,o,n,i){return{id:ka(),name:t,description:o,createdBy:n,createdAt:Date.now(),config:i}}function Ba(t,o){const n=t||[];if(n.length>=zn)throw new Error(`Maximum of ${zn} presets reached. Please delete old presets first.`);return[...n,o]}function Ia(t,o){return(t||[]).filter(i=>i.id!==o)}function Bn(t,o){if(t)return t.find(n=>n.id===o)}function Da(){return typeof window>"u"?null:new URLSearchParams(window.location.search).get("preset")}function Ea(t){const o=t.columnOrder,n=Vr(o,t.grouping);return{filters:t.filters.length>0?[...t.filters]:void 0,sortStack:t.sortStack.length>0?[...t.sortStack]:void 0,columnVisibility:{...t.columnVisibility},columnOrder:n,columnWidths:{...t.columnWidths},grouping:t.grouping?{...t.grouping}:null,activeViewId:t.activeViewId}}function Oa(t,o){return{totalRows:t.length,totalColumns:o.length}}function wt(t,o,n,i){const s=n instanceof Error?n.message:n,d={type:t,context:o,message:s,details:i,timestamp:Date.now(),recoverable:Aa(t,o)};return process.env.NODE_ENV==="development"&&rr.error("urm:error-handling","[Report Error]",{type:t,context:o,message:s,details:i}),d}function Aa(t,o){return t==="ui"?!0:o==="export"?!1:t==="processing"&&["filters","sorting","grouping","columns"].includes(o)?!0:t!=="system"}function $a(t){const n={filters:"There was an issue applying filters",sorting:"Sorting could not be applied",grouping:"Grouping configuration failed",columns:"Column configuration could not be updated",views:"View operation failed",presets:"Preset could not be applied",export:"Export failed",upload:"File upload failed",search:"Search operation failed"}[t.context]||"An error occurred";return t.recoverable?`${n}. Your previous state has been restored.`:`${n}. Please refresh the page.`}function Ma(t){return{filters:t.filters?[...t.filters]:void 0,sortStack:t.sortStack?[...t.sortStack]:void 0,grouping:t.grouping?{...t.grouping}:void 0,columnVisibility:t.columnVisibility?{...t.columnVisibility}:void 0,columnOrder:t.columnOrder?[...t.columnOrder]:void 0,columnWidths:t.columnWidths?{...t.columnWidths}:void 0,activeViewId:t.activeViewId}}function Ra(t,o,n){n(t.id,{filters:o.filters,sortStack:o.sortStack,grouping:o.grouping,columnVisibility:o.columnVisibility,columnOrder:o.columnOrder,columnWidths:o.columnWidths,activeViewId:o.activeViewId})}function _a(t,o,n){return["equals","contains","starts_with","ends_with","gt","gte","lt","lte"].includes(o)&&(n==null||n==="")?{isValid:!1,errorMessage:"Value is required for this operator"}:t==="number"&&["gt","gte","lt","lte","equals"].includes(o)&&isNaN(Number(n))?{isValid:!1,errorMessage:"Value must be a valid number"}:t==="date"&&n&&isNaN(Date.parse(n))?{isValid:!1,errorMessage:"Value must be a valid date"}:{isValid:!0}}function Ei(t,o){const n=[],i=[],s=new Set(o.map(d=>d.name));return t.forEach(d=>{s.has(d.column)?n.push(d):i.push(d.column)}),{validRules:n,invalidColumns:i}}function Oi(t,o){if(!t||!t.levels||t.levels.length===0)return{validGrouping:null,invalidColumns:[]};const n=new Set(o.map(d=>d.name)),i=[],s=[];return t.levels.forEach(d=>{n.has(d.column)?i.push(d):s.push(d.column)}),i.length===0?{validGrouping:null,invalidColumns:s}:{validGrouping:{...t,levels:i},invalidColumns:s}}function Wa(t,o){const n=[],i=new Set(o.map(d=>d.name)),s={...t};if(s.filters&&Array.isArray(s.filters)){const d=s.filters.filter(c=>{const l=i.has(c.column);return l||n.push(`Filter for column "${c.column}" ignored (column not found)`),l});s.filters=d.length>0?d:void 0}if(s.sortStack&&Array.isArray(s.sortStack)){const{validRules:d,invalidColumns:c}=Ei(s.sortStack,o);c.length>0&&n.push(`Sort rules for columns ignored: ${c.join(", ")}`),s.sortStack=d.length>0?d:void 0}if(s.grouping){const{validGrouping:d,invalidColumns:c}=Oi(s.grouping,o);c.length>0&&n.push(`Grouping for columns ignored: ${c.join(", ")}`),s.grouping=d}if(s.columnVisibility){const d={};Object.entries(s.columnVisibility).forEach(([c,l])=>{i.has(c)?d[c]=l:n.push(`Column visibility for "${c}" ignored (column not found)`)}),s.columnVisibility=Object.keys(d).length>0?d:void 0}if(s.columnOrder&&Array.isArray(s.columnOrder)){const d=s.columnOrder.filter(c=>{const l=i.has(c);return l||n.push(`Column "${c}" in order ignored (column not found)`),l});s.columnOrder=d.length>0?d:void 0}if(s.columnWidths){const d={};Object.entries(s.columnWidths).forEach(([c,l])=>{i.has(c)?d[c]=l:n.push(`Column width for "${c}" ignored (column not found)`)}),s.columnWidths=Object.keys(d).length>0?d:void 0}return{sanitizedConfig:s,warnings:n}}function Pa(t,o){return wt("processing","export",t,{retryAvailable:!!(o!=null&&o.onRetry)})}function In(t,o,n,i){const s=Ii(t,o,"system","error_occurred",null,{errorType:n.type,errorContext:n.context,errorMessage:n.message,recoverable:n.recoverable,timestamp:n.timestamp});return Di(i||[],s)}function Na(t){return t==null}function La(t,o){const{operator:n,value:i}=o;if(n==="NULL")return t==null;if(n==="NOT_NULL")return t!=null;if(Na(t))return!1;switch(n){case"equals":return String(t)===String(i);case"contains":return String(t).toLowerCase().includes(String(i).toLowerCase());case"startsWith":return String(t).toLowerCase().startsWith(String(i).toLowerCase());case"endsWith":return String(t).toLowerCase().endsWith(String(i).toLowerCase());case"gt":return Number(t)>Number(i);case"lt":return Number(t)<Number(i);case"gte":return Number(t)>=Number(i);case"lte":return Number(t)<=Number(i);case"isTrue":return t===!0;case"isFalse":return t===!1;default:return!0}}function Fa(t,o){return!o||o.length===0?t:t.filter(n=>o.every(i=>La(n[i.column],i)))}function Dn(t){switch(t){case"string":return[{value:"equals",label:"Equals"},{value:"contains",label:"Contains"},{value:"startsWith",label:"Starts with"},{value:"endsWith",label:"Ends with"},{value:"NULL",label:"Is NULL"},{value:"NOT_NULL",label:"Is NOT NULL"}];case"number":return[{value:"equals",label:"="},{value:"gt",label:">"},{value:"lt",label:"<"},{value:"gte",label:"≥"},{value:"lte",label:"≤"}];case"boolean":return[{value:"isTrue",label:"Is true"},{value:"isFalse",label:"Is false"},{value:"NULL",label:"Is NULL"},{value:"NOT_NULL",label:"Is NOT NULL"}];case"mixed":case"null":case"array":case"object":default:return[]}}function oo(t){return t!=="isTrue"&&t!=="isFalse"&&t!=="NULL"&&t!=="NOT_NULL"}function Va({data:t,filters:o}){return{filteredData:p.useMemo(()=>!o||o.length===0?t:Fa(t,o),[t,o])}}function Ha(t,o,n,i){if(!n||n.trim()==="")return t;const s=n.toLowerCase().trim(),d=o.filter(c=>i.includes(c.name));return t.filter(c=>d.some(l=>{const u=c[l.name];return u==null?!1:String(u).toLowerCase().includes(s)}))}function Ua({data:t,searchQuery:o,schema:n,visibleColumns:i}){return{searchedData:p.useMemo(()=>!o||o.trim()===""?t:Ha(t,n,o,i),[t,o,n,i])}}function Ya({data:t,sortStack:o,schema:n}){return{sortedData:p.useMemo(()=>!o||o.length===0?t:Qs(t,n,o),[t,o,n])}}function Ga({data:t,grouping:o,schema:n}){const i=p.useMemo(()=>!o||!o.enabled||o.levels.length===0?t:oa(t,n,o),[t,o,n]),s=(o==null?void 0:o.enabled)&&((o==null?void 0:o.levels.length)||0)>0;return{groupedData:i,isGrouped:s}}function qa({schema:t,columnVisibility:o,columnOrder:n}){const i=p.useMemo(()=>n.filter(l=>o[l]!==!1),[n,o]),s=p.useMemo(()=>Object.entries(o).filter(([l,u])=>!u).map(([l,u])=>l),[o]),d=p.useMemo(()=>n.map(l=>t.find(f=>f.name===l)||{name:l,type:"string"}),[n,t]),c=p.useMemo(()=>i.map(l=>t.find(f=>f.name===l)||{name:l,type:"string"}),[i,t]);return{visibleColumns:i,hiddenColumns:s,allColumns:d,visibleColumnSchemas:c,hiddenCount:s.length}}function Ja({views:t,activeViewId:o,currentState:n}){const i=p.useMemo(()=>t.find(f=>f.id===o),[t,o]),s=p.useMemo(()=>i?sa(n,i.snapshot):!1,[i,n]),d=p.useMemo(()=>t.find(f=>f.isDefault),[t]),c=p.useMemo(()=>t.filter(f=>!f.isDefault&&!f.isDeleted),[t]),l=p.useMemo(()=>t.filter(f=>f.isFavorite&&!f.isDeleted),[t]),u=p.useMemo(()=>t.filter(f=>f.isDeleted),[t]);return{activeView:i,isDirty:s,defaultView:d,customViews:c,favoriteViews:l,deletedViews:u,isDefaultView:(i==null?void 0:i.isDefault)||!1}}function Ka({data:t,enabled:o=!1,pageSize:n=100,initialPage:i=1}){const[s,d]=p.useState(i),c=t.length,l=Math.ceil(c/n),u=p.useMemo(()=>{if(!o)return t;const b=(s-1)*n,D=b+n;return t.slice(b,D)},[t,o,s,n]),f=p.useCallback(b=>{const D=Math.max(1,Math.min(b,l));d(D)},[l]),m=p.useCallback(()=>{s<l&&d(s+1)},[s,l]),h=p.useCallback(()=>{s>1&&d(s-1)},[s]),x=p.useCallback(()=>{d(1)},[]);return{paginatedData:u,currentPage:s,totalPages:l,pageSize:n,totalRows:c,goToPage:f,nextPage:m,prevPage:h,resetPage:x,hasNextPage:s<l,hasPrevPage:s>1}}function Xa(t){const{rawData:o,schema:n,filters:i,sortStack:s,grouping:d,searchQuery:c,columnVisibility:l,columnOrder:u,columnWidths:f,views:m,activeViewId:h,pagination:x}=t,b=p.useMemo(()=>({filters:i,sortStack:s,grouping:d,columnVisibility:l,columnOrder:u,columnWidths:f}),[i,s,d,l,u,f]),D=Ja({views:m,activeViewId:h,currentState:b}),g=qa({schema:n,columnVisibility:l,columnOrder:u}),{filteredData:j}=Va({data:o,filters:i}),{sortedData:w}=Ya({data:j,sortStack:s,schema:n}),{groupedData:I,isGrouped:v}=Ga({data:w,grouping:d,schema:n}),{searchedData:S}=Ua({data:I,searchQuery:c,schema:n,visibleColumns:g.visibleColumns}),C=Ka({data:S,enabled:(x==null?void 0:x.enabled)||!1,pageSize:(x==null?void 0:x.pageSize)||100,initialPage:(x==null?void 0:x.currentPage)||1}),a=x!=null&&x.enabled?C.paginatedData:S,z=p.useMemo(()=>({totalRows:o.length,filteredRows:j.length,sortedRows:w.length,groupedRows:v?I.length:w.length,searchedRows:S.length,visibleRows:a.length,hiddenColumns:g.hiddenCount,activeFilters:i.length,activeSorts:s.length,isGrouped:v}),[o.length,j.length,w.length,I.length,S.length,a.length,g.hiddenCount,i.length,s.length,v]);return{data:a,filteredData:j,sortedData:w,groupedData:I,searchedData:S,viewEngine:D,columnEngine:g,paginationEngine:C,metrics:z,isGrouped:v,isPaginated:(x==null?void 0:x.enabled)||!1}}let Qa=0;function Za(t){t!==null&&t.__urm_row_id__===void 0&&Object.defineProperty(t,"__urm_row_id__",{value:Qa++,writable:!1,enumerable:!1,configurable:!1})}const xt="user-demo-001";function el(t={}){var xn,mn,hn,fn,gn;const{mode:o="builder",autoLoad:n=!0,initialData:i,dataSource:s,reportName:d,sharedReportId:c,config:l={}}=t,[u,f]=p.useState([]),m=nr(),[h,x]=p.useState(""),[b,D]=p.useState(!1),[g,j]=p.useState(!1),[w,I]=p.useState({message:"",severity:"info",open:!1}),v=(T,O="info")=>{I({message:T,severity:O,open:!0})},S=()=>I(T=>({...T,open:!1})),C=l.notifDurationMs??2e3,a=u.find(T=>T.id===h),[z,R]=p.useState("idle"),[q,K]=p.useState(!1),[ee,y]=p.useState(!1),[M,W]=p.useState(!1),[V,Q]=p.useState(!1),[xe,de]=p.useState(!1),[L,A]=p.useState(!1),[H,ie]=p.useState(void 0),[Y,re]=p.useState(null),[se,oe]=p.useState(null),[P,ne]=p.useState(!1),[ce,ae]=p.useState(!1),[fe,G]=p.useState(null),[Ae,Qe]=p.useState(!1),[Ze,Bt]=p.useState(!1),[ar,It]=p.useState({enabled:!1,levels:[],collapsedGroups:[]}),[Dt,Et]=p.useState(""),[lt,Ve]=p.useState(""),[Vt,et]=p.useState(new Set),[Ue,He]=p.useState(1),[nt,Ir]=p.useState(15),[lr,Ht]=p.useState(!1),[cr,Ut]=p.useState(!1),[Dr,Yt]=p.useState(!1),[ft,it]=p.useState(null),[dr,Gt]=p.useState(!1),[ur,qt]=p.useState(null),[Er,tt]=p.useState(null),Ot=p.useRef(null),ke=p.useMemo(()=>a?ga(a.permissions,xt):"owner",[a]),At=ya(ke),Or=p.useMemo(()=>!(a!=null&&a.uploadedData)||!(a!=null&&a.schema)?{totalRows:0,totalColumns:0}:Oa(a.uploadedData,a.schema),[a==null?void 0:a.uploadedData,a==null?void 0:a.schema]),Ye=p.useCallback(()=>{a&&(Ot.current=Ma(a))},[a]),F=p.useCallback((T,O)=>{f(_=>_.map($=>$.id===T?{...$,...O}:$))},[]),Ge=p.useCallback(T=>{if(!a)return;tt(T);const O=In(a.id,xt,T,a.auditHistory||[]);F(a.id,{auditHistory:O}),v(T.message,"error"),T.recoverable&&Ot.current&&setTimeout(()=>{Ra(a,Ot.current,F),v("Previous state restored","success")},100)},[a,F]),be=p.useCallback((T,O,_,$)=>{if(!a)return;const Z=Ii(a.id,xt,T,O,_,$),X=a.auditHistory||[],me=Di(X,Z);setTimeout(()=>{F(a.id,{auditHistory:me})},0)},[a,F]);p.useEffect(()=>{if(a!=null&&a.schemaLocked&&a.schema&&(!a.views||a.views.length===0)){const T=No(a.schema);(()=>{try{const O=localStorage.getItem("urm_dev_config");return O?JSON.parse(O):null}catch{return null}})(),F(a.id,{views:[T],activeViewId:T.id,filters:T.snapshot.filters,sortStack:T.snapshot.sortStack,columnVisibility:T.snapshot.columnVisibility,columnOrder:T.snapshot.columnOrder,columnWidths:T.snapshot.columnWidths,grouping:T.snapshot.grouping})}},[a==null?void 0:a.schemaLocked,a==null?void 0:a.schema,a==null?void 0:a.id,F]),p.useEffect(()=>{if(i&&n&&!g&&u.length===0){const T=co(i),O={id:`auto-report-${Date.now()}`,name:d||(o==="viewer"?"Data View":"Imported Data"),description:"Auto-generated from external data",schemaLocked:!0,uploadedData:T,schema:Wr(T),permissions:{owner:xt,editors:[],viewers:[]}};f([O]),x(O.id),j(!0),R("confirmed")}},[i,n,g,u.length,o,d]),p.useEffect(()=>{if(!s||g)return;let T=!1,O=null;const _=async()=>{try{R("uploading");let $;if(s.type==="api"){const X=await fetch(s.url,{headers:s.headers||{}});if(!X.ok)throw new Error(`HTTP ${X.status}: ${X.statusText}`);$=await X.json()}else $=await s.fetch();if(T)return;if(!Array.isArray($))throw new Error("Data source must return an array of objects");const Z=Wr($);if(g)f(X=>X.map(me=>me.id===h?{...me,uploadedData:$}:me)),R("confirmed");else{const X={id:`auto-report-${Date.now()}`,name:d||(o==="viewer"?"Data View":"Imported Data"),description:`Loaded from ${s.type==="api"?s.url:"callback"}`,schemaLocked:!0,uploadedData:co($),schema:Wr(co($)),permissions:{owner:xt,editors:[],viewers:[]}};f([X]),x(X.id),j(!0),R("confirmed")}}catch($){T||(R("error"),a&&F(a.id,{uploadError:($==null?void 0:$.message)||"Failed to load data from source"}))}};return _(),s.refreshInterval&&s.refreshInterval>0&&(O=setInterval(_,s.refreshInterval)),()=>{T=!0,O&&clearInterval(O)}},[s,d,o]);const Pe=(xn=a==null?void 0:a.views)==null?void 0:xn.find(T=>T.id===a.activeViewId),Ar=p.useMemo(()=>a!=null&&a.uploadedData?(a.uploadedData.forEach(Za),a.uploadedData):[],[a==null?void 0:a.uploadedData]),gt=Xa({rawData:Ar,schema:(a==null?void 0:a.schema)||[],filters:(a==null?void 0:a.filters)||[],sortStack:(a==null?void 0:a.sortStack)||[],grouping:(a==null?void 0:a.grouping)||null,searchQuery:lt||"",columnVisibility:(a==null?void 0:a.columnVisibility)||(Pe==null?void 0:Pe.snapshot.columnVisibility)||{},columnOrder:(a==null?void 0:a.columnOrder)||(Pe==null?void 0:Pe.snapshot.columnOrder)||[],columnWidths:(a==null?void 0:a.columnWidths)||(Pe==null?void 0:Pe.snapshot.columnWidths)||{},views:(a==null?void 0:a.views)||[],activeViewId:(a==null?void 0:a.activeViewId)||"",pagination:{enabled:!0,pageSize:nt,currentPage:Ue}}),{data:$r=[],searchedData:yt=[],groupedData:Jt=[],metrics:Kt={totalRows:0,searchedRows:0,isGrouped:!1},isGrouped:pr=!1,paginationEngine:Te}=gt||{},U=((mn=gt.viewEngine)==null?void 0:mn.activeView)||Pe,_e=((hn=gt.viewEngine)==null?void 0:hn.isDirty)||!1;p.useEffect(()=>{if(!(!U||!a)&&!a.columnOrder){const T=U.snapshot.columnOrder,O=Vr(T,U.snapshot.grouping);F(a.id,{columnOrder:O})}},[a==null?void 0:a.activeViewId]);const we=p.useMemo(()=>!(a!=null&&a.schema)||!U?null:ia(a.filters||[],a.sortStack||[],a.schema,a.columnVisibility,a.columnOrder,a.columnWidths,a.grouping,U.snapshot.columnOrder),[a==null?void 0:a.filters,a==null?void 0:a.sortStack,a==null?void 0:a.schema,a==null?void 0:a.columnVisibility,a==null?void 0:a.columnOrder,a==null?void 0:a.columnWidths,a==null?void 0:a.grouping,U]),ct=p.useMemo(()=>!U||!we||!_e?[]:la(we,U.snapshot),[U,we,_e]),Le=p.useCallback((T,O,_)=>{const $={id:`report-${Date.now()}`,name:T,description:O,schemaLocked:!1,permissions:{owner:xt,editors:[],viewers:[]}};if(_&&Array.isArray(_)&&_.length>0){const Z=Wr(_),X=No(Z);$.uploadedData=_,$.schema=Z,$.schemaLocked=!0,$.views=[X],$.activeViewId=X.id,$.sortStack=X.snapshot.sortStack,$.filters=X.snapshot.filters,$.columnVisibility=X.snapshot.columnVisibility,$.columnOrder=X.snapshot.columnOrder,$.columnWidths=X.snapshot.columnWidths,$.grouping=X.snapshot.grouping}f(Z=>[...Z,$]),x($.id),D(!1),R("confirmed")},[]),xr=p.useCallback(T=>{a&&(R("uploading"),setTimeout(()=>{const O=Wr(T);F(a.id,{uploadedData:T,schema:O,uploadError:void 0}),R("preview")},500))},[a,F]),mr=p.useCallback(T=>{a&&(F(a.id,{uploadError:T}),R("idle"))},[a,F]),hr=p.useCallback(()=>{a&&(F(a.id,{uploadError:void 0,uploadedData:void 0,schema:void 0}),R("idle"))},[a,F]),bt=p.useCallback(()=>{a&&(F(a.id,{schemaLocked:!0}),R("confirmed"))},[a,F]),Mr=p.useCallback(T=>{if(!a)return;if(!ut("edit_sorting",ke)){v(pt("edit_sorting"),"error");return}const O=a.sortStack??[],_=O.find($=>$.column===T);if(_){const $=Zs(_.direction);if($===null){const Z=O.filter(X=>X.column!==T).map((X,me)=>({...X,priority:me+1}));F(a.id,{sortStack:Z.length>0?Z:void 0})}else{const Z=$,X=O.map(me=>me.column===T?{...me,direction:Z}:me);F(a.id,{sortStack:X})}}else{if(O.length>=m.sort.maxLevels){v(`Sort limit reached — maximum ${m.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const $={column:T,direction:"asc",priority:O.length+1};F(a.id,{sortStack:[...O,$]})}},[a,ke,F]),vt=p.useCallback(T=>{if(a)if(a.schema){const{validRules:O,invalidColumns:_}=Ei(T,a.schema);_.length>0&&v(`Removed invalid sort columns: ${_.join(", ")}`),Ye();try{F(a.id,{sortStack:O.length>0?O:void 0})}catch($){const Z=wt("processing","sorting",$);Ge(Z)}}else F(a.id,{sortStack:T.length>0?T:void 0})},[a,F,Ye,Ge]),Xt=p.useCallback(T=>{if(!a)return;const O=a.sortStack??[],_=O.find($=>$.column===T);if(!(_&&_.direction==="asc"))if(_){const $=O.map(Z=>Z.column===T?{...Z,direction:"asc"}:Z);F(a.id,{sortStack:$})}else{if(O.length>=m.sort.maxLevels){v(`Sort limit reached — maximum ${m.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const $={column:T,direction:"asc",priority:O.length+1};F(a.id,{sortStack:[...O,$]})}},[a,F]),St=p.useCallback(T=>{if(!a)return;const O=a.sortStack??[],_=O.find($=>$.column===T);if(!(_&&_.direction==="desc"))if(_){const $=O.map(Z=>Z.column===T?{...Z,direction:"desc"}:Z);F(a.id,{sortStack:$})}else{if(O.length>=m.sort.maxLevels){v(`Sort limit reached — maximum ${m.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const $={column:T,direction:"desc",priority:O.length+1};F(a.id,{sortStack:[...O,$]})}},[a,F]),st=p.useCallback(T=>{var _;if(!a)return;if(!ut("edit_filters",ke)){v(pt("edit_filters"),"error");return}const O=(_=a.schema)==null?void 0:_.find($=>$.name===T.column);if(O&&T.value!==void 0){const $=_a(O.type,T.operator,T.value);if(!$.isValid){v($.errorMessage||"Invalid filter value","error");return}}Ye();try{const $=a.filters??[];be("filters","filter_added",$,[...$,T]),F(a.id,{filters:[...$,T]})}catch($){const Z=wt("processing","filters",$);Ge(Z)}},[a,ke,F,Ye,Ge,be]),jt=p.useCallback((T,O)=>{if(!a)return;if(!ut("edit_filters",ke)){v(pt("edit_filters"),"error");return}const _=a.filters??[],$=[..._];be("filters","filter_updated",_[T],O),$[T]=O,F(a.id,{filters:$})},[a,ke,F,be]),fr=p.useCallback(T=>{if(!a)return;if(!ut("edit_filters",ke)){v(pt("edit_filters"),"error");return}const O=a.filters??[],_=O.filter(($,Z)=>Z!==T);be("filters","filter_removed",O[T],null),F(a.id,{filters:_.length>0?_:void 0})},[a,ke,F,be]),Fe=p.useCallback(()=>{if(!a)return;if(!ut("edit_filters",ke)){v(pt("edit_filters"),"error");return}const T=a.filters??[];be("filters","filter_cleared",T,null),F(a.id,{filters:void 0})},[a,ke,F,be]),$t=p.useCallback(T=>{if(!a)return;if(!ut("edit_filters",ke)){v(pt("edit_filters"),"error");return}const O=a.filters??[];be("filters","filter_cleared",O,T),F(a.id,{filters:T.length>0?T:void 0})},[a,ke,F,be]),Mt=p.useCallback(T=>{var Z;if(!a)return;const O=(Z=a.views)==null?void 0:Z.find(X=>X.id===T);if(!O)return;const _=O.snapshot.columnOrder,$=Vr(_,O.snapshot.grouping);F(a.id,{filters:O.snapshot.filters.length>0?[...O.snapshot.filters]:void 0,sortStack:O.snapshot.sortStack.length>0?[...O.snapshot.sortStack]:void 0,columnVisibility:{...O.snapshot.columnVisibility},columnOrder:$,columnWidths:{...O.snapshot.columnWidths},grouping:O.snapshot.grouping,activeViewId:T}),et(new Set),W(!1)},[a,F]),dt=p.useCallback((T,O,_)=>{var yn;if(!(a!=null&&a.schema)||!we)return;const $=a.views??[],Z=$.filter(Po=>!Po.isDeleted).length,X=((yn=m.views)==null?void 0:yn.maxViews)??10;if(Z>=X){v(`View limit reached — you can have at most ${X} saved views. Delete an existing view to create a new one.`,"error");return}const me={id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:T,description:O||void 0,isDefault:_,isFavorite:!1,isDeleted:!1,scope:"personal",createdBy:xt,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...we}},ze=_?$.map(Po=>({...Po,isDefault:!1})):$;F(a.id,{views:[...ze,me],activeViewId:me.id}),v(`"${T}" view created`,"success")},[a,we,F]),at=p.useCallback(()=>{var O;if(!U||!we||U.isDefault||!a)return;const T=(O=a.views)==null?void 0:O.map(_=>_.id===U.id?{..._,snapshot:{...we}}:_);F(a.id,{views:T}),v(`"${U.name}" view updated`,"success")},[U,we,a,F]),Rt=p.useCallback(T=>{var $;if(!U||!we||!a)return;const O=T??we.columnWidths,_=($=a.views)==null?void 0:$.map(Z=>Z.id===U.id?{...Z,snapshot:{...Z.snapshot,columnVisibility:we.columnVisibility,columnOrder:we.columnOrder,columnWidths:O},updatedAt:Date.now()}:Z);F(a.id,{views:_,columnWidths:O}),v(`Column configuration saved to "${U.name}"`,"success")},[U,we,a,F]),Rr=p.useCallback(T=>{var X,me;if(!we||!a||!U)return;const O=T??we.columnWidths,_={...U,snapshot:{...U.snapshot,columnVisibility:we.columnVisibility,columnOrder:we.columnOrder,columnWidths:O},updatedAt:Date.now()},$=(X=a.views)==null?void 0:X.map(ze=>ze.id===U.id?_:{...ze,snapshot:{...ze.snapshot,columnVisibility:we.columnVisibility,columnOrder:we.columnOrder,columnWidths:O},updatedAt:Date.now()});F(a.id,{views:$,columnWidths:O});const Z=(((me=a.views)==null?void 0:me.length)||0)-1;v(`Column configuration saved to current view and ${Z} other view${Z===1?"":"s"}`,"success")},[we,a,U,F]),Qt=p.useCallback(()=>{Q(!0)},[]),gr=p.useCallback(()=>{if(!U||!a)return;const T=U.snapshot.columnOrder,O=Vr(T,U.snapshot.grouping);F(a.id,{filters:U.snapshot.filters.length>0?[...U.snapshot.filters]:void 0,sortStack:U.snapshot.sortStack.length>0?[...U.snapshot.sortStack]:void 0,columnVisibility:{...U.snapshot.columnVisibility},columnOrder:O,columnWidths:{...U.snapshot.columnWidths},grouping:U.snapshot.grouping}),v("Changes reverted to last saved state","success")},[U,a,F]),yr=p.useCallback(T=>{if(!(a!=null&&a.views))return;const O=a.views.map($=>({...$,isDefault:$.id===T}));F(a.id,{views:O});const _=a.views.find($=>$.id===T);_&&v(`"${_.name}" set as default view`,"success")},[a,F]),br=p.useCallback(T=>{if(!(a!=null&&a.views))return;const O=a.views.map($=>$.id===T?{...$,isFavorite:!$.isFavorite,updatedAt:Date.now()}:$);F(a.id,{views:O});const _=a.views.find($=>$.id===T);_&&!_.isFavorite?v(`"${_.name}" added to favorites`,"success"):_&&v(`"${_.name}" removed from favorites`,"info")},[a,F]),vr=p.useCallback(T=>{if(!(a!=null&&a.views))return;const O=a.views.map(X=>X.id===T?{...X,isDeleted:!0,updatedAt:Date.now()}:X),_=a.activeViewId===T,$=O.find(X=>X.isDefault&&!X.isDeleted);F(a.id,{views:O,activeViewId:_&&$?$.id:a.activeViewId,filters:_&&$?$.snapshot.filters.length>0?$.snapshot.filters:void 0:a.filters,sortStack:_&&$?$.snapshot.sortStack.length>0?$.snapshot.sortStack:void 0:a.sortStack});const Z=a.views.find(X=>X.id===T);Z&&v(`"${Z.name}" moved to Recently Deleted`,"info")},[a,F]),Sr=p.useCallback(T=>{if(!(a!=null&&a.views))return;const O=a.views.map($=>$.id===T?{...$,isDeleted:!1,updatedAt:Date.now()}:$);F(a.id,{views:O});const _=a.views.find($=>$.id===T);_&&v(`"${_.name}" restored`,"success")},[a,F]),le=p.useCallback(T=>{if(!(a!=null&&a.views))return;const O=a.views.find(ze=>ze.id===T),_=a.views.filter(ze=>!ze.isDeleted||ze.id===T);if((O==null?void 0:O.isDefault)&&_.filter(ze=>ze.isDefault).length===1){v("Cannot delete the last default view","error");return}const Z=a.views.filter(ze=>ze.id!==T),X=a.activeViewId===T,me=Z.find(ze=>ze.isDefault&&!ze.isDeleted);F(a.id,{views:Z,activeViewId:X&&me?me.id:a.activeViewId,filters:X&&me?me.snapshot.filters.length>0?me.snapshot.filters:void 0:a.filters,sortStack:X&&me?me.snapshot.sortStack.length>0?me.snapshot.sortStack:void 0:a.sortStack}),O&&v(`"${O.name}" permanently deleted`,"success")},[a,F]),he=p.useCallback(T=>{re(T),de(!0),W(!1)},[]),$e=p.useCallback((T,O)=>{if(!Y||!(a!=null&&a.views))return;const _=a.views.map($=>$.id===Y?{...$,name:T,description:O||void 0}:$);F(a.id,{views:_}),re(null)},[Y,a,F]),_t=p.useCallback(T=>{oe(T),A(!0),W(!1)},[]),Wt=p.useCallback(()=>{if(!se||!(a!=null&&a.views))return;const T=a.views.filter($=>$.id!==se),O=a.activeViewId===se,_=T.find($=>$.isDefault);F(a.id,{views:T,activeViewId:O&&_?_.id:a.activeViewId,filters:O&&_?_.snapshot.filters.length>0?_.snapshot.filters:void 0:a.filters,sortStack:O&&_?_.snapshot.sortStack.length>0?_.snapshot.sortStack:void 0:a.sortStack}),oe(null),A(!1)},[se,a,F]),We=p.useCallback(T=>{var Z;if(!(a!=null&&a.views))return;if(!(((Z=m.views)==null?void 0:Z.isAdmin)??!1)){v("Only administrators can promote views to Global.","error");return}const _=a.views.find(X=>X.id===T);if(!_)return;if(_.scope==="global"){v(`"${_.name}" is already a Global View.`,"info");return}const $=a.views.map(X=>X.id===T?{...X,scope:"global",isDefault:!0,updatedAt:Date.now()}:X.scope==="global"&&X.isDefault?{...X,isDefault:!1}:X);F(a.id,{views:$}),v(`"${_.name}" promoted to Global View and set as default.`,"success")},[a,m,F]);p.useEffect(()=>{Te!=null&&Te.resetPage?Te.resetPage():He(1)},[a==null?void 0:a.filters,lt,a==null?void 0:a.activeViewId]),p.useEffect(()=>{Te&&Te.currentPage!==Ue&&He(Te.currentPage)},[Te==null?void 0:Te.currentPage]);const Pt=p.useCallback(T=>{Te!=null&&Te.goToPage&&Te.goToPage(T),He(T)},[Te]),Qr=p.useCallback(T=>{const O=(Ue-1)*nt,_=Math.floor(O/T)+1;Ir(T),He(_),Te==null||Te.goToPage(_)},[Ue,nt,Te]),pn=p.useCallback((T,O)=>{if(!a)return;if(!ut("edit_columns",ke)){v(pt("edit_columns"),"error");return}const $={...a.columnVisibility||(U==null?void 0:U.snapshot.columnVisibility)||{},[T]:O};F(a.id,{columnVisibility:$})},[a,U,ke,F]),jr=p.useCallback(T=>{if(a){if(!ut("edit_columns",ke)){v(pt("edit_columns"),"error");return}F(a.id,{columnOrder:T})}},[a,ke,F]),_o=p.useCallback((T,O)=>{if(!a)return;if(!ut("edit_columns",ke)){v(pt("edit_columns"),"error");return}const $={...a.columnWidths||(U==null?void 0:U.snapshot.columnWidths)||{},[T]:O};F(a.id,{columnWidths:$})},[a,U,ke,F]),Zr=p.useCallback(T=>{if(!a)return;const _=(a.filters??[]).filter($=>$.column!==T);F(a.id,{filters:_.length>0?_:void 0})},[a,F]),eo=p.useCallback(()=>{if(!U||!(a!=null&&a.schema))return;const T={},O=[],_={};a.schema.forEach($=>{T[$.name]=!0,O.push($.name),_[$.name]=170}),F(a.id,{columnVisibility:T,columnOrder:O,columnWidths:_,filters:void 0,sortStack:void 0}),v("Reset to default layout - all filters and sorts cleared","success")},[U,a,F]);p.useEffect(()=>{const T=setTimeout(()=>Ve(Dt),300);return()=>clearTimeout(T)},[Dt]);const E=p.useCallback(T=>{Et(T)},[]),J=p.useCallback(T=>{if(!T.trim()||!a)return;const O=a.searchHistory||[],_=pa(O,T);F(a.id,{searchHistory:_})},[a,F]),ue=p.useCallback(T=>{if(!a)return;const O=a.searchHistory||[],_=xa(O,T);F(a.id,{searchHistory:_})},[a,F]),Ne=p.useCallback(T=>{if(!a)return;const O=a.searchHistory||[],_=ma(O,T);F(a.id,{searchHistory:_})},[a,F]),pe=p.useCallback(T=>{const O=T==null?void 0:T.__urm_row_id__;et(_=>{const $=new Set(_);if(O!==void 0){const Z=Array.from($).find(X=>(X==null?void 0:X.__urm_row_id__)===O);Z!==void 0?$.delete(Z):$.add(T)}else{const Z=JSON.stringify(T),X=Array.from($).find(me=>JSON.stringify(me)===Z);X!==void 0?$.delete(X):$.add(T)}return $})},[]),Zt=p.useCallback((T,O)=>{et(_=>{const $=new Set(_);for(const Z of O)T?$.add(Z):$.delete(Z);return $})},[]),Wo=p.useCallback((T,O,_)=>{et($=>{const Z=new Set($),X=Math.min(T,O),me=Math.max(T,O);for(let ze=X;ze<=me;ze++)_[ze]!==void 0&&Z.add(_[ze]);return Z})},[]),cs=p.useCallback(()=>{et(new Set)},[]),ds=p.useCallback(T=>{const O=T==null?void 0:T.__urm_row_id__;et(_=>{const $=new Set(_);if(O!==void 0){const Z=Array.from($).find(X=>(X==null?void 0:X.__urm_row_id__)===O);Z!==void 0&&$.delete(Z)}else $.delete(T);return $})},[]),us=p.useCallback(T=>{if(a){if(!ut("edit_columns",ke)){v(pt("edit_columns"),"error");return}if(T&&a.schema){const{validGrouping:O,invalidColumns:_}=Oi(T,a.schema);_.length>0&&v(`Removed invalid grouping columns: ${_.join(", ")}`,"warning"),Ye();try{const $=a.grouping;O===null?be("grouping","group_cleared",$,null):$?be("grouping","group_reordered",$,O):be("grouping","group_level_added",null,O);const Z=(U==null?void 0:U.snapshot.columnOrder)||a.columnOrder||[],X=Vr(Z,O);F(a.id,{grouping:O,columnOrder:X}),JSON.stringify(X)!==JSON.stringify(a.columnOrder)&&be("columns","column_reordered",a.columnOrder,X),Bt(!1)}catch($){const Z=wt("processing","grouping",$);Ge(Z)}}else{const O=a.grouping;be("grouping","group_cleared",O,null);const _=(U==null?void 0:U.snapshot.columnOrder)||a.columnOrder||[];F(a.id,{grouping:T,columnOrder:[..._]}),JSON.stringify(_)!==JSON.stringify(a.columnOrder)&&be("columns","column_reordered",a.columnOrder,_),Bt(!1)}}},[a,U,ke,F,Ye,Ge,be]),ps=p.useCallback(T=>{if(!a)return;const O=a.grouping;if(!O)return;const _=na(O,T);F(a.id,{grouping:_})},[a,F]),xs=p.useCallback(()=>{Gt(!0)},[]),_r=p.useCallback(T=>{a!=null&&a.schema&&(ne(!0),setTimeout(()=>{try{let O;T.scope==="visible"?O=yt:O=a.uploadedData||[];let _;T.columnScope==="all"?(_={},(a.schema??[]).forEach(ze=>{_[ze.name]=!0})):_=a.columnVisibility||(U==null?void 0:U.snapshot.columnVisibility)||{};const $=a.columnOrder||(U==null?void 0:U.snapshot.columnOrder),Z=mo(O,a.schema,a.filters??[],a.sortStack??[],U,_,$),X=a.name;let me;switch(T.format){case"csv":ho(Z,X,T),me="export_csv";break;case"excel":fo(Z,X,T),me="export_excel";break;case"json":go(Z,X,T),me="export_json";break}be("export",me,null,{format:T.format,scope:T.scope,columnScope:T.columnScope,rowCount:O.length,viewName:(U==null?void 0:U.name)||"Default View"}),v(`Export completed successfully (${T.format.toUpperCase()})`,"success")}catch(O){const _=Pa(O,{onRetry:()=>_r(T)});v(`Export failed: ${_.message}. Click Export to retry.`,"error");const $=In(a.id,xt,_,a.auditHistory||[]);F(a.id,{auditHistory:$}),rr.error("urm:report-engine","Export failed",O)}finally{ne(!1)}},500))},[a,U,yt,F,be]),ms=p.useCallback(T=>{if(a!=null&&a.schema){if(_e&&U&&!U.isDefault){G(T.format),ae(!0),Gt(!1);return}_r(T),Gt(!1)}},[a,U,_e,_r]),to=p.useCallback(T=>{_r({format:T,scope:"visible",columnScope:"visible"})},[_r]),hs=p.useCallback(()=>{fe&&to(fe),ae(!1),G(null)},[fe,to]),fs=p.useCallback(()=>{at(),fe&&to(fe),ae(!1),G(null)},[at,fe,to]),gs=p.useCallback(()=>{ae(!1),G(null)},[]),ys=p.useCallback(T=>{!(a!=null&&a.schema)||Vt.size===0||(ne(!0),setTimeout(()=>{try{const O=Array.from(Vt),_=mo(O,a.schema,a.filters??[],a.sortStack??[],U),$=`${a.name.toLowerCase().replace(/\s+/g,"_")}_selected_export`;switch(T){case"csv":ho(_,$);break;case"excel":fo(_,$);break;case"json":go(_,$);break}v(`Exported ${O.length} selected rows`,"info")}catch(O){v("Export failed. Please try again.","error"),rr.error("urm:report-engine","Bulk export failed",O)}finally{ne(!1)}},500))},[a,U,Vt,Jt]),bs=p.useCallback((T,O)=>{if(a)try{const _=Ta(a),$=za(T,O,xt,_),Z=Ba(a.presets,$);F(a.id,{presets:Z}),be("presets","preset_created",null,{presetId:$.id,name:$.name}),Ut(!1),v(`Preset "${T}" saved successfully`,"success")}catch(_){v(_ instanceof Error?_.message:"Failed to create preset","error")}},[a,F,be]),vs=p.useCallback(()=>{it(null),v("Exited preset view","info")},[]),Ss=p.useCallback(()=>{Yt(!0)},[]),js=p.useCallback((T,O)=>{if(!a)return;const _=Ia(a.presets,T);F(a.id,{presets:_}),be("presets","preset_deleted",{presetId:T,name:O},null),ft===T&&it(null),v(`Preset "${O}" deleted`,"success")},[a,ft,F,be]);p.useEffect(()=>{if(!c||u.length===0)return;const T=u.find(O=>O.id===c);T&&T.id!==h&&x(T.id)},[c,u,h]),p.useEffect(()=>{if(!a)return;const T=Da();if(T&&a.presets&&a.schemaLocked&&a.schema){const O=Bn(a.presets,T);if(O){const{sanitizedConfig:_,warnings:$}=Wa(O.config,a.schema);$.length>0&&$.forEach(X=>v(X,"warning"));const Z=Ea(_);F(a.id,Z),it(T),be("presets","preset_applied",null,{presetId:O.id,name:O.name}),v(`Loaded preset: ${O.name}`,"info")}else v("Preset not found","info")}},[a==null?void 0:a.schemaLocked]);const Cs=ft?Bn(a==null?void 0:a.presets,ft):void 0;p.useEffect(()=>{a!=null&&a.views&&a.views.length>0&&a.activeViewId&&ca(a.id,{views:a.views,activeViewId:a.activeViewId})},[a==null?void 0:a.views,a==null?void 0:a.activeViewId,a==null?void 0:a.id]),p.useEffect(()=>{if(a!=null&&a.schemaLocked&&a.schema&&(!a.views||a.views.length===0)){const T=da(a.id);if(T&&T.views.length>0){const O=T.views.find(_=>_.id===T.activeViewId);if(O)F(a.id,{views:T.views,activeViewId:T.activeViewId,filters:O.snapshot.filters.length>0?O.snapshot.filters:void 0,sortStack:O.snapshot.sortStack.length>0?O.snapshot.sortStack:void 0});else{const _=T.views.find($=>$.isDefault)||No(a.schema);F(a.id,{views:T.views,activeViewId:_.id,filters:_.snapshot.filters.length>0?_.snapshot.filters:void 0,sortStack:_.snapshot.sortStack.length>0?_.snapshot.sortStack:void 0})}}}},[a==null?void 0:a.schemaLocked,a==null?void 0:a.schema,a==null?void 0:a.id]);const ws=p.useCallback(T=>{var $;const O=(a==null?void 0:a.filters)??[],_=(($=m.filter)==null?void 0:$.maxConditions)??3;if(O.length>=_){v(`Filter limit reached — maximum ${_} filters allowed. Remove an existing filter before adding a new one.`,"warning");return}ie(T),K(!0)},[a,m,v]),ks=p.useCallback(()=>{K(!1),ie(void 0)},[]),Ts=(fn=a==null?void 0:a.views)==null?void 0:fn.find(T=>T.id===Y),zs=(gn=a==null?void 0:a.views)==null?void 0:gn.find(T=>T.id===se);return{reports:u,activeReport:a,activeReportId:h,setActiveReportId:x,isModalOpen:b,setIsModalOpen:D,createReport:Le,updateReport:F,uploadState:z,handleFileUpload:xr,handleUploadError:mr,handleRetry:hr,handleConfirm:bt,paginatedData:$r,processedData:yt,displayData:Jt,tableMetrics:Kt,isGrouped:pr,tableEngine:gt,activeView:U,isDirty:_e,currentTableState:we,viewChanges:ct,filters:a==null?void 0:a.filters,showFilterPanel:q,setShowFilterPanel:K,filterFocusColumn:H,handleAddFilter:st,handleUpdateFilter:jt,handleRemoveFilter:fr,handleClearAllFilters:Fe,handleReplaceFilters:$t,handleOpenFilterForColumn:ws,handleCloseFilterPanel:ks,handleClearFiltersForColumn:Zr,sortStack:a==null?void 0:a.sortStack,showSortPanel:ee,setShowSortPanel:y,handleSort:Mr,handleUpdateSortStack:vt,handleSortAscending:Xt,handleSortDescending:St,views:a==null?void 0:a.views,showManageViews:M,setShowManageViews:W,showCreateViewModal:V,setShowCreateViewModal:Q,showEditViewModal:xe,setShowEditViewModal:de,showDeleteConfirmation:L,setShowDeleteConfirmation:A,editingView:Ts,deletingView:zs,editingViewId:Y,deletingViewId:se,handleSelectView:Mt,handleCreateView:dt,handleUpdateCurrentView:at,handleSaveColumnConfigToCurrentView:Rt,handleSaveColumnConfigToAllViews:Rr,handleSaveAsNewView:Qt,handleRevertChanges:gr,handleToggleDefault:yr,handleToggleFavorite:br,handleSoftDelete:vr,handleRestoreView:Sr,handlePermanentDelete:le,handleEditView:he,handleSaveEditView:$e,handleDeleteView:_t,handleConfirmDelete:Wt,handlePromoteToGlobal:We,showManageColumns:Ae,setShowManageColumns:Qe,columnVisibility:a==null?void 0:a.columnVisibility,columnOrder:a==null?void 0:a.columnOrder,columnWidths:a==null?void 0:a.columnWidths,handleUpdateColumnVisibility:pn,handleUpdateColumnOrder:jr,handleUpdateColumnWidth:_o,handleResetColumnLayout:eo,showGroupPanel:Ze,setShowGroupPanel:Bt,grouping:a==null?void 0:a.grouping,groupingState:ar,handleGroup:us,handleToggleGroupCollapse:ps,searchQuery:Dt,debouncedSearchQuery:lt,searchHistory:ha((a==null?void 0:a.searchHistory)||[]),handleSearchChange:E,handleAddToSearchHistory:J,handleToggleSearchFavourite:ue,handleDeleteSearchHistory:Ne,selectedRowIds:Vt,handleToggleRowSelection:pe,handleToggleAllRows:Zt,handleRangeSelection:Wo,handleClearSelection:cs,handleUpdateSelectionAfterDelete:ds,currentPage:Ue,pageSize:nt,paginationEngine:Te,handlePageChange:Pt,handlePageSizeChange:Qr,isExporting:P,showExportModal:dr,setShowExportModal:Gt,showDirtyExportWarning:ce,handleExport:xs,handleExportWithConfig:ms,handleExportSelected:ys,handleExportAnyway:hs,handleSaveAndExport:fs,handleCancelExport:gs,showAuditHistory:lr,setShowAuditHistory:Ht,auditHistory:a==null?void 0:a.auditHistory,showCreatePreset:cr,setShowCreatePreset:Ut,showManagePresets:Dr,setShowManagePresets:Yt,activePreset:Cs,activePresetId:ft,handleOpenManagePresets:Ss,handleCreatePreset:bs,handleClearActivePreset:vs,handleDeletePresetById:js,userRole:ke,isViewerRole:At,currentUserId:xt,featureLimitWarning:ur,setFeatureLimitWarning:qt,datasetMeta:Or,reportError:Er,setReportError:tt,handleError:Ge,schema:a==null?void 0:a.schema,hasSchemaConflicts:a!=null&&a.schema?Ks(a.schema):!1,snack:w,handleSnackClose:S,showSnack:v,snackDurationMs:C}}const Ai=p.createContext(void 0);function nn(t){const{children:o,initialData:n,data:i,reportName:s,dataSource:d,mode:c="builder",autoLoad:l=!0,config:u,devConfig:f,showDevPanel:m=!1,sharedReportId:h}=t,b=el({mode:c,autoLoad:l,initialData:i||n,dataSource:d,reportName:s,sharedReportId:h,config:u}),[D,g]=p.useState(()=>Os()),j=(()=>{const S=$s(D,f,!!f);return{...S,display:{...S.display,showDevPanel:m||S.display.showDevPanel}}})(),w=p.useCallback(v=>{g(v),As(v)},[]),I={...b,activeDevConfig:j,handleDevConfigChange:w};return e.jsx(vi.Provider,{value:j,children:e.jsx(Ai.Provider,{value:I,children:o})})}function jo(){const t=p.useContext(Ai);if(t===void 0)throw new Error("useReportContext must be used within a ReportProvider. Wrap your component tree with <ReportProvider>...</ReportProvider>");return t}function tl({onCreateReport:t,reports:o=[],activeReportId:n,onReportClick:i}){const s=o.find(d=>d.id===n);return e.jsx(r.Box,{component:"header",sx:{position:"sticky",top:0,zIndex:50,borderBottom:"1px solid",borderColor:"divider",bgcolor:"background.paper"},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,height:64},children:[e.jsxs(r.Breadcrumbs,{separator:e.jsx(B.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}),sx:{display:"flex",alignItems:"center"},children:[e.jsx(r.Typography,{variant:"h6",component:"h1",sx:{fontWeight:500,fontSize:"1.375rem",color:"text.primary",letterSpacing:"-0.01em",cursor:o.length>0&&s?"pointer":"default","&:hover":o.length>0&&s?{color:"primary.main"}:{}},onClick:()=>{o.length>0},children:"Reports"}),s&&e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"1.125rem",color:"primary.main",cursor:"pointer","&:hover":{textDecoration:"underline"}},onClick:()=>i==null?void 0:i(s.id),children:s.name}),e.jsx(r.Tooltip,{title:s.description||"No description",arrow:!0,placement:"bottom",children:e.jsx(B.InfoOutlined,{sx:{fontSize:18,color:"text.secondary",opacity:.7,cursor:"help","&:hover":{opacity:1}}})})]})]}),e.jsx(r.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:e.jsx(r.Button,{variant:"contained",startIcon:e.jsx(B.Add,{sx:{fontSize:18}}),onClick:t,sx:{borderRadius:"20px",px:3,fontSize:"0.875rem",py:.75},children:"New Report"})})]})})}function or(t,...o){const n=new URL(`https://mui.com/production-error/?code=${t}`);return o.forEach(i=>n.searchParams.append("args[]",i)),`Minified MUI error #${t}; visit ${n} for the full message.`}const rl="$$material";function ol(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var no={exports:{}},io={exports:{}},ge={};/** @license React v16.13.1
4
4
  * react-is.production.min.js
5
5
  *
6
6
  * Copyright (c) Facebook, Inc. and its affiliates.
7
7
  *
8
8
  * This source code is licensed under the MIT license found in the
9
9
  * LICENSE file in the root directory of this source tree.
10
- */var An;function dl(){if(An)return be;An=1;var t=typeof Symbol=="function"&&Symbol.for,o=t?Symbol.for("react.element"):60103,n=t?Symbol.for("react.portal"):60106,i=t?Symbol.for("react.fragment"):60107,s=t?Symbol.for("react.strict_mode"):60108,d=t?Symbol.for("react.profiler"):60114,l=t?Symbol.for("react.provider"):60109,c=t?Symbol.for("react.context"):60110,u=t?Symbol.for("react.async_mode"):60111,h=t?Symbol.for("react.concurrent_mode"):60111,m=t?Symbol.for("react.forward_ref"):60112,b=t?Symbol.for("react.suspense"):60113,x=t?Symbol.for("react.suspense_list"):60120,y=t?Symbol.for("react.memo"):60115,D=t?Symbol.for("react.lazy"):60116,v=t?Symbol.for("react.block"):60121,C=t?Symbol.for("react.fundamental"):60117,S=t?Symbol.for("react.responder"):60118,I=t?Symbol.for("react.scope"):60119;function f(j){if(typeof j=="object"&&j!==null){var a=j.$$typeof;switch(a){case o:switch(j=j.type,j){case u:case h:case i:case d:case s:case b:return j;default:switch(j=j&&j.$$typeof,j){case c:case m:case D:case y:case l:return j;default:return a}}case n:return a}}}function k(j){return f(j)===h}return be.AsyncMode=u,be.ConcurrentMode=h,be.ContextConsumer=c,be.ContextProvider=l,be.Element=o,be.ForwardRef=m,be.Fragment=i,be.Lazy=D,be.Memo=y,be.Portal=n,be.Profiler=d,be.StrictMode=s,be.Suspense=b,be.isAsyncMode=function(j){return k(j)||f(j)===u},be.isConcurrentMode=k,be.isContextConsumer=function(j){return f(j)===c},be.isContextProvider=function(j){return f(j)===l},be.isElement=function(j){return typeof j=="object"&&j!==null&&j.$$typeof===o},be.isForwardRef=function(j){return f(j)===m},be.isFragment=function(j){return f(j)===i},be.isLazy=function(j){return f(j)===D},be.isMemo=function(j){return f(j)===y},be.isPortal=function(j){return f(j)===n},be.isProfiler=function(j){return f(j)===d},be.isStrictMode=function(j){return f(j)===s},be.isSuspense=function(j){return f(j)===b},be.isValidElementType=function(j){return typeof j=="string"||typeof j=="function"||j===i||j===h||j===d||j===s||j===b||j===x||typeof j=="object"&&j!==null&&(j.$$typeof===D||j.$$typeof===y||j.$$typeof===l||j.$$typeof===c||j.$$typeof===m||j.$$typeof===C||j.$$typeof===S||j.$$typeof===I||j.$$typeof===v)},be.typeOf=f,be}var ve={};/** @license React v16.13.1
10
+ */var En;function nl(){if(En)return ge;En=1;var t=typeof Symbol=="function"&&Symbol.for,o=t?Symbol.for("react.element"):60103,n=t?Symbol.for("react.portal"):60106,i=t?Symbol.for("react.fragment"):60107,s=t?Symbol.for("react.strict_mode"):60108,d=t?Symbol.for("react.profiler"):60114,c=t?Symbol.for("react.provider"):60109,l=t?Symbol.for("react.context"):60110,u=t?Symbol.for("react.async_mode"):60111,f=t?Symbol.for("react.concurrent_mode"):60111,m=t?Symbol.for("react.forward_ref"):60112,h=t?Symbol.for("react.suspense"):60113,x=t?Symbol.for("react.suspense_list"):60120,b=t?Symbol.for("react.memo"):60115,D=t?Symbol.for("react.lazy"):60116,g=t?Symbol.for("react.block"):60121,j=t?Symbol.for("react.fundamental"):60117,w=t?Symbol.for("react.responder"):60118,I=t?Symbol.for("react.scope"):60119;function v(C){if(typeof C=="object"&&C!==null){var a=C.$$typeof;switch(a){case o:switch(C=C.type,C){case u:case f:case i:case d:case s:case h:return C;default:switch(C=C&&C.$$typeof,C){case l:case m:case D:case b:case c:return C;default:return a}}case n:return a}}}function S(C){return v(C)===f}return ge.AsyncMode=u,ge.ConcurrentMode=f,ge.ContextConsumer=l,ge.ContextProvider=c,ge.Element=o,ge.ForwardRef=m,ge.Fragment=i,ge.Lazy=D,ge.Memo=b,ge.Portal=n,ge.Profiler=d,ge.StrictMode=s,ge.Suspense=h,ge.isAsyncMode=function(C){return S(C)||v(C)===u},ge.isConcurrentMode=S,ge.isContextConsumer=function(C){return v(C)===l},ge.isContextProvider=function(C){return v(C)===c},ge.isElement=function(C){return typeof C=="object"&&C!==null&&C.$$typeof===o},ge.isForwardRef=function(C){return v(C)===m},ge.isFragment=function(C){return v(C)===i},ge.isLazy=function(C){return v(C)===D},ge.isMemo=function(C){return v(C)===b},ge.isPortal=function(C){return v(C)===n},ge.isProfiler=function(C){return v(C)===d},ge.isStrictMode=function(C){return v(C)===s},ge.isSuspense=function(C){return v(C)===h},ge.isValidElementType=function(C){return typeof C=="string"||typeof C=="function"||C===i||C===f||C===d||C===s||C===h||C===x||typeof C=="object"&&C!==null&&(C.$$typeof===D||C.$$typeof===b||C.$$typeof===c||C.$$typeof===l||C.$$typeof===m||C.$$typeof===j||C.$$typeof===w||C.$$typeof===I||C.$$typeof===g)},ge.typeOf=v,ge}var ye={};/** @license React v16.13.1
11
11
  * react-is.development.js
12
12
  *
13
13
  * Copyright (c) Facebook, Inc. and its affiliates.
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var _n;function ul(){return _n||(_n=1,process.env.NODE_ENV!=="production"&&(function(){var t=typeof Symbol=="function"&&Symbol.for,o=t?Symbol.for("react.element"):60103,n=t?Symbol.for("react.portal"):60106,i=t?Symbol.for("react.fragment"):60107,s=t?Symbol.for("react.strict_mode"):60108,d=t?Symbol.for("react.profiler"):60114,l=t?Symbol.for("react.provider"):60109,c=t?Symbol.for("react.context"):60110,u=t?Symbol.for("react.async_mode"):60111,h=t?Symbol.for("react.concurrent_mode"):60111,m=t?Symbol.for("react.forward_ref"):60112,b=t?Symbol.for("react.suspense"):60113,x=t?Symbol.for("react.suspense_list"):60120,y=t?Symbol.for("react.memo"):60115,D=t?Symbol.for("react.lazy"):60116,v=t?Symbol.for("react.block"):60121,C=t?Symbol.for("react.fundamental"):60117,S=t?Symbol.for("react.responder"):60118,I=t?Symbol.for("react.scope"):60119;function f(q){return typeof q=="string"||typeof q=="function"||q===i||q===h||q===d||q===s||q===b||q===x||typeof q=="object"&&q!==null&&(q.$$typeof===D||q.$$typeof===y||q.$$typeof===l||q.$$typeof===c||q.$$typeof===m||q.$$typeof===C||q.$$typeof===S||q.$$typeof===I||q.$$typeof===v)}function k(q){if(typeof q=="object"&&q!==null){var _e=q.$$typeof;switch(_e){case o:var et=q.type;switch(et){case u:case h:case i:case d:case s:case b:return et;default:var tt=et&&et.$$typeof;switch(tt){case c:case m:case D:case y:case l:return tt;default:return _e}}case n:return _e}}}var j=u,a=h,B=c,R=l,J=o,K=m,ee=i,g=D,M=y,W=n,V=d,Q=s,xe=b,me=!1;function L(q){return me||(me=!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.")),A(q)||k(q)===u}function A(q){return k(q)===h}function H(q){return k(q)===c}function se(q){return k(q)===l}function G(q){return typeof q=="object"&&q!==null&&q.$$typeof===o}function re(q){return k(q)===m}function ae(q){return k(q)===i}function ne(q){return k(q)===D}function P(q){return k(q)===y}function ie(q){return k(q)===n}function pe(q){return k(q)===d}function le(q){return k(q)===s}function ge(q){return k(q)===b}ve.AsyncMode=j,ve.ConcurrentMode=a,ve.ContextConsumer=B,ve.ContextProvider=R,ve.Element=J,ve.ForwardRef=K,ve.Fragment=ee,ve.Lazy=g,ve.Memo=M,ve.Portal=W,ve.Profiler=V,ve.StrictMode=Q,ve.Suspense=xe,ve.isAsyncMode=L,ve.isConcurrentMode=A,ve.isContextConsumer=H,ve.isContextProvider=se,ve.isElement=G,ve.isForwardRef=re,ve.isFragment=ae,ve.isLazy=ne,ve.isMemo=P,ve.isPortal=ie,ve.isProfiler=pe,ve.isStrictMode=le,ve.isSuspense=ge,ve.isValidElementType=f,ve.typeOf=k})()),ve}var Mn;function Mi(){return Mn||(Mn=1,process.env.NODE_ENV==="production"?xo.exports=dl():xo.exports=ul()),xo.exports}/*
17
+ */var On;function il(){return On||(On=1,process.env.NODE_ENV!=="production"&&(function(){var t=typeof Symbol=="function"&&Symbol.for,o=t?Symbol.for("react.element"):60103,n=t?Symbol.for("react.portal"):60106,i=t?Symbol.for("react.fragment"):60107,s=t?Symbol.for("react.strict_mode"):60108,d=t?Symbol.for("react.profiler"):60114,c=t?Symbol.for("react.provider"):60109,l=t?Symbol.for("react.context"):60110,u=t?Symbol.for("react.async_mode"):60111,f=t?Symbol.for("react.concurrent_mode"):60111,m=t?Symbol.for("react.forward_ref"):60112,h=t?Symbol.for("react.suspense"):60113,x=t?Symbol.for("react.suspense_list"):60120,b=t?Symbol.for("react.memo"):60115,D=t?Symbol.for("react.lazy"):60116,g=t?Symbol.for("react.block"):60121,j=t?Symbol.for("react.fundamental"):60117,w=t?Symbol.for("react.responder"):60118,I=t?Symbol.for("react.scope"):60119;function v(G){return typeof G=="string"||typeof G=="function"||G===i||G===f||G===d||G===s||G===h||G===x||typeof G=="object"&&G!==null&&(G.$$typeof===D||G.$$typeof===b||G.$$typeof===c||G.$$typeof===l||G.$$typeof===m||G.$$typeof===j||G.$$typeof===w||G.$$typeof===I||G.$$typeof===g)}function S(G){if(typeof G=="object"&&G!==null){var Ae=G.$$typeof;switch(Ae){case o:var Qe=G.type;switch(Qe){case u:case f:case i:case d:case s:case h:return Qe;default:var Ze=Qe&&Qe.$$typeof;switch(Ze){case l:case m:case D:case b:case c:return Ze;default:return Ae}}case n:return Ae}}}var C=u,a=f,z=l,R=c,q=o,K=m,ee=i,y=D,M=b,W=n,V=d,Q=s,xe=h,de=!1;function L(G){return de||(de=!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.")),A(G)||S(G)===u}function A(G){return S(G)===f}function H(G){return S(G)===l}function ie(G){return S(G)===c}function Y(G){return typeof G=="object"&&G!==null&&G.$$typeof===o}function re(G){return S(G)===m}function se(G){return S(G)===i}function oe(G){return S(G)===D}function P(G){return S(G)===b}function ne(G){return S(G)===n}function ce(G){return S(G)===d}function ae(G){return S(G)===s}function fe(G){return S(G)===h}ye.AsyncMode=C,ye.ConcurrentMode=a,ye.ContextConsumer=z,ye.ContextProvider=R,ye.Element=q,ye.ForwardRef=K,ye.Fragment=ee,ye.Lazy=y,ye.Memo=M,ye.Portal=W,ye.Profiler=V,ye.StrictMode=Q,ye.Suspense=xe,ye.isAsyncMode=L,ye.isConcurrentMode=A,ye.isContextConsumer=H,ye.isContextProvider=ie,ye.isElement=Y,ye.isForwardRef=re,ye.isFragment=se,ye.isLazy=oe,ye.isMemo=P,ye.isPortal=ne,ye.isProfiler=ce,ye.isStrictMode=ae,ye.isSuspense=fe,ye.isValidElementType=v,ye.typeOf=S})()),ye}var An;function $i(){return An||(An=1,process.env.NODE_ENV==="production"?io.exports=nl():io.exports=il()),io.exports}/*
18
18
  object-assign
19
19
  (c) Sindre Sorhus
20
20
  @license MIT
21
- */var Go,Rn;function pl(){if(Rn)return Go;Rn=1;var t=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function i(d){if(d==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(d)}function s(){try{if(!Object.assign)return!1;var d=new String("abc");if(d[5]="de",Object.getOwnPropertyNames(d)[0]==="5")return!1;for(var l={},c=0;c<10;c++)l["_"+String.fromCharCode(c)]=c;var u=Object.getOwnPropertyNames(l).map(function(m){return l[m]});if(u.join("")!=="0123456789")return!1;var h={};return"abcdefghijklmnopqrst".split("").forEach(function(m){h[m]=m}),Object.keys(Object.assign({},h)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return Go=s()?Object.assign:function(d,l){for(var c,u=i(d),h,m=1;m<arguments.length;m++){c=Object(arguments[m]);for(var b in c)o.call(c,b)&&(u[b]=c[b]);if(t){h=t(c);for(var x=0;x<h.length;x++)n.call(c,h[x])&&(u[h[x]]=c[h[x]])}}return u},Go}var qo,Wn;function un(){if(Wn)return qo;Wn=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return qo=t,qo}var Jo,Pn;function Ri(){return Pn||(Pn=1,Jo=Function.call.bind(Object.prototype.hasOwnProperty)),Jo}var Ko,Nn;function xl(){if(Nn)return Ko;Nn=1;var t=function(){};if(process.env.NODE_ENV!=="production"){var o=un(),n={},i=Ri();t=function(d){var l="Warning: "+d;typeof console<"u"&&console.error(l);try{throw new Error(l)}catch{}}}function s(d,l,c,u,h){if(process.env.NODE_ENV!=="production"){for(var m in d)if(i(d,m)){var b;try{if(typeof d[m]!="function"){var x=Error((u||"React class")+": "+c+" type `"+m+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof d[m]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw x.name="Invariant Violation",x}b=d[m](l,m,u,c,null,o)}catch(D){b=D}if(b&&!(b instanceof Error)&&t((u||"React class")+": type specification of "+c+" `"+m+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof b+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),b instanceof Error&&!(b.message in n)){n[b.message]=!0;var y=h?h():"";t("Failed "+c+" type: "+b.message+(y??""))}}}}return s.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},Ko=s,Ko}var Xo,Ln;function ml(){if(Ln)return Xo;Ln=1;var t=Mi(),o=pl(),n=un(),i=Ri(),s=xl(),d=function(){};process.env.NODE_ENV!=="production"&&(d=function(c){var u="Warning: "+c;typeof console<"u"&&console.error(u);try{throw new Error(u)}catch{}});function l(){return null}return Xo=function(c,u){var h=typeof Symbol=="function"&&Symbol.iterator,m="@@iterator";function b(A){var H=A&&(h&&A[h]||A[m]);if(typeof H=="function")return H}var x="<<anonymous>>",y={array:S("array"),bigint:S("bigint"),bool:S("boolean"),func:S("function"),number:S("number"),object:S("object"),string:S("string"),symbol:S("symbol"),any:I(),arrayOf:f,element:k(),elementType:j(),instanceOf:a,node:K(),objectOf:R,oneOf:B,oneOfType:J,shape:g,exact:M};function D(A,H){return A===H?A!==0||1/A===1/H:A!==A&&H!==H}function v(A,H){this.message=A,this.data=H&&typeof H=="object"?H:{},this.stack=""}v.prototype=Error.prototype;function C(A){if(process.env.NODE_ENV!=="production")var H={},se=0;function G(ae,ne,P,ie,pe,le,ge){if(ie=ie||x,le=le||P,ge!==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 _e=ie+":"+P;!H[_e]&&se<3&&(d("You are manually calling a React.PropTypes validation function for the `"+le+"` 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."),H[_e]=!0,se++)}}return ne[P]==null?ae?ne[P]===null?new v("The "+pe+" `"+le+"` is marked as required "+("in `"+ie+"`, but its value is `null`.")):new v("The "+pe+" `"+le+"` is marked as required in "+("`"+ie+"`, but its value is `undefined`.")):null:A(ne,P,ie,pe,le)}var re=G.bind(null,!1);return re.isRequired=G.bind(null,!0),re}function S(A){function H(se,G,re,ae,ne,P){var ie=se[G],pe=Q(ie);if(pe!==A){var le=xe(ie);return new v("Invalid "+ae+" `"+ne+"` of type "+("`"+le+"` supplied to `"+re+"`, expected ")+("`"+A+"`."),{expectedType:A})}return null}return C(H)}function I(){return C(l)}function f(A){function H(se,G,re,ae,ne){if(typeof A!="function")return new v("Property `"+ne+"` of component `"+re+"` has invalid PropType notation inside arrayOf.");var P=se[G];if(!Array.isArray(P)){var ie=Q(P);return new v("Invalid "+ae+" `"+ne+"` of type "+("`"+ie+"` supplied to `"+re+"`, expected an array."))}for(var pe=0;pe<P.length;pe++){var le=A(P,pe,re,ae,ne+"["+pe+"]",n);if(le instanceof Error)return le}return null}return C(H)}function k(){function A(H,se,G,re,ae){var ne=H[se];if(!c(ne)){var P=Q(ne);return new v("Invalid "+re+" `"+ae+"` of type "+("`"+P+"` supplied to `"+G+"`, expected a single ReactElement."))}return null}return C(A)}function j(){function A(H,se,G,re,ae){var ne=H[se];if(!t.isValidElementType(ne)){var P=Q(ne);return new v("Invalid "+re+" `"+ae+"` of type "+("`"+P+"` supplied to `"+G+"`, expected a single ReactElement type."))}return null}return C(A)}function a(A){function H(se,G,re,ae,ne){if(!(se[G]instanceof A)){var P=A.name||x,ie=L(se[G]);return new v("Invalid "+ae+" `"+ne+"` of type "+("`"+ie+"` supplied to `"+re+"`, expected ")+("instance of `"+P+"`."))}return null}return C(H)}function B(A){if(!Array.isArray(A))return process.env.NODE_ENV!=="production"&&(arguments.length>1?d("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])."):d("Invalid argument supplied to oneOf, expected an array.")),l;function H(se,G,re,ae,ne){for(var P=se[G],ie=0;ie<A.length;ie++)if(D(P,A[ie]))return null;var pe=JSON.stringify(A,function(ge,q){var _e=xe(q);return _e==="symbol"?String(q):q});return new v("Invalid "+ae+" `"+ne+"` of value `"+String(P)+"` "+("supplied to `"+re+"`, expected one of "+pe+"."))}return C(H)}function R(A){function H(se,G,re,ae,ne){if(typeof A!="function")return new v("Property `"+ne+"` of component `"+re+"` has invalid PropType notation inside objectOf.");var P=se[G],ie=Q(P);if(ie!=="object")return new v("Invalid "+ae+" `"+ne+"` of type "+("`"+ie+"` supplied to `"+re+"`, expected an object."));for(var pe in P)if(i(P,pe)){var le=A(P,pe,re,ae,ne+"."+pe,n);if(le instanceof Error)return le}return null}return C(H)}function J(A){if(!Array.isArray(A))return process.env.NODE_ENV!=="production"&&d("Invalid argument supplied to oneOfType, expected an instance of array."),l;for(var H=0;H<A.length;H++){var se=A[H];if(typeof se!="function")return d("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+me(se)+" at index "+H+"."),l}function G(re,ae,ne,P,ie){for(var pe=[],le=0;le<A.length;le++){var ge=A[le],q=ge(re,ae,ne,P,ie,n);if(q==null)return null;q.data&&i(q.data,"expectedType")&&pe.push(q.data.expectedType)}var _e=pe.length>0?", expected one of type ["+pe.join(", ")+"]":"";return new v("Invalid "+P+" `"+ie+"` supplied to "+("`"+ne+"`"+_e+"."))}return C(G)}function K(){function A(H,se,G,re,ae){return W(H[se])?null:new v("Invalid "+re+" `"+ae+"` supplied to "+("`"+G+"`, expected a ReactNode."))}return C(A)}function ee(A,H,se,G,re){return new v((A||"React class")+": "+H+" type `"+se+"."+G+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+re+"`.")}function g(A){function H(se,G,re,ae,ne){var P=se[G],ie=Q(P);if(ie!=="object")return new v("Invalid "+ae+" `"+ne+"` of type `"+ie+"` "+("supplied to `"+re+"`, expected `object`."));for(var pe in A){var le=A[pe];if(typeof le!="function")return ee(re,ae,ne,pe,xe(le));var ge=le(P,pe,re,ae,ne+"."+pe,n);if(ge)return ge}return null}return C(H)}function M(A){function H(se,G,re,ae,ne){var P=se[G],ie=Q(P);if(ie!=="object")return new v("Invalid "+ae+" `"+ne+"` of type `"+ie+"` "+("supplied to `"+re+"`, expected `object`."));var pe=o({},se[G],A);for(var le in pe){var ge=A[le];if(i(A,le)&&typeof ge!="function")return ee(re,ae,ne,le,xe(ge));if(!ge)return new v("Invalid "+ae+" `"+ne+"` key `"+le+"` supplied to `"+re+"`.\nBad object: "+JSON.stringify(se[G],null," ")+`
22
- Valid keys: `+JSON.stringify(Object.keys(A),null," "));var q=ge(P,le,re,ae,ne+"."+le,n);if(q)return q}return null}return C(H)}function W(A){switch(typeof A){case"number":case"string":case"undefined":return!0;case"boolean":return!A;case"object":if(Array.isArray(A))return A.every(W);if(A===null||c(A))return!0;var H=b(A);if(H){var se=H.call(A),G;if(H!==A.entries){for(;!(G=se.next()).done;)if(!W(G.value))return!1}else for(;!(G=se.next()).done;){var re=G.value;if(re&&!W(re[1]))return!1}}else return!1;return!0;default:return!1}}function V(A,H){return A==="symbol"?!0:H?H["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&H instanceof Symbol:!1}function Q(A){var H=typeof A;return Array.isArray(A)?"array":A instanceof RegExp?"object":V(H,A)?"symbol":H}function xe(A){if(typeof A>"u"||A===null)return""+A;var H=Q(A);if(H==="object"){if(A instanceof Date)return"date";if(A instanceof RegExp)return"regexp"}return H}function me(A){var H=xe(A);switch(H){case"array":case"object":return"an "+H;case"boolean":case"date":case"regexp":return"a "+H;default:return H}}function L(A){return!A.constructor||!A.constructor.name?x:A.constructor.name}return y.checkPropTypes=s,y.resetWarningCache=s.resetWarningCache,y.PropTypes=y,y},Xo}var Qo,Fn;function hl(){if(Fn)return Qo;Fn=1;var t=un();function o(){}function n(){}return n.resetWarningCache=o,Qo=function(){function i(l,c,u,h,m,b){if(b!==t){var x=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 x.name="Invariant Violation",x}}i.isRequired=i;function s(){return i}var d={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:o};return d.PropTypes=d,d},Qo}var Vn;function fl(){if(Vn)return po.exports;if(Vn=1,process.env.NODE_ENV!=="production"){var t=Mi(),o=!0;po.exports=ml()(t.isElement,o)}else po.exports=hl()();return po.exports}var gl=fl();const qr=cl(gl);var mo={exports:{}},Te={};/**
21
+ */var Fo,$n;function sl(){if($n)return Fo;$n=1;var t=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function i(d){if(d==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(d)}function s(){try{if(!Object.assign)return!1;var d=new String("abc");if(d[5]="de",Object.getOwnPropertyNames(d)[0]==="5")return!1;for(var c={},l=0;l<10;l++)c["_"+String.fromCharCode(l)]=l;var u=Object.getOwnPropertyNames(c).map(function(m){return c[m]});if(u.join("")!=="0123456789")return!1;var f={};return"abcdefghijklmnopqrst".split("").forEach(function(m){f[m]=m}),Object.keys(Object.assign({},f)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return Fo=s()?Object.assign:function(d,c){for(var l,u=i(d),f,m=1;m<arguments.length;m++){l=Object(arguments[m]);for(var h in l)o.call(l,h)&&(u[h]=l[h]);if(t){f=t(l);for(var x=0;x<f.length;x++)n.call(l,f[x])&&(u[f[x]]=l[f[x]])}}return u},Fo}var Vo,Mn;function sn(){if(Mn)return Vo;Mn=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Vo=t,Vo}var Ho,Rn;function Mi(){return Rn||(Rn=1,Ho=Function.call.bind(Object.prototype.hasOwnProperty)),Ho}var Uo,_n;function al(){if(_n)return Uo;_n=1;var t=function(){};if(process.env.NODE_ENV!=="production"){var o=sn(),n={},i=Mi();t=function(d){var c="Warning: "+d;typeof console<"u"&&console.error(c);try{throw new Error(c)}catch{}}}function s(d,c,l,u,f){if(process.env.NODE_ENV!=="production"){for(var m in d)if(i(d,m)){var h;try{if(typeof d[m]!="function"){var x=Error((u||"React class")+": "+l+" type `"+m+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof d[m]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw x.name="Invariant Violation",x}h=d[m](c,m,u,l,null,o)}catch(D){h=D}if(h&&!(h instanceof Error)&&t((u||"React class")+": type specification of "+l+" `"+m+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof h+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),h instanceof Error&&!(h.message in n)){n[h.message]=!0;var b=f?f():"";t("Failed "+l+" type: "+h.message+(b??""))}}}}return s.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},Uo=s,Uo}var Yo,Wn;function ll(){if(Wn)return Yo;Wn=1;var t=$i(),o=sl(),n=sn(),i=Mi(),s=al(),d=function(){};process.env.NODE_ENV!=="production"&&(d=function(l){var u="Warning: "+l;typeof console<"u"&&console.error(u);try{throw new Error(u)}catch{}});function c(){return null}return Yo=function(l,u){var f=typeof Symbol=="function"&&Symbol.iterator,m="@@iterator";function h(A){var H=A&&(f&&A[f]||A[m]);if(typeof H=="function")return H}var x="<<anonymous>>",b={array:w("array"),bigint:w("bigint"),bool:w("boolean"),func:w("function"),number:w("number"),object:w("object"),string:w("string"),symbol:w("symbol"),any:I(),arrayOf:v,element:S(),elementType:C(),instanceOf:a,node:K(),objectOf:R,oneOf:z,oneOfType:q,shape:y,exact:M};function D(A,H){return A===H?A!==0||1/A===1/H:A!==A&&H!==H}function g(A,H){this.message=A,this.data=H&&typeof H=="object"?H:{},this.stack=""}g.prototype=Error.prototype;function j(A){if(process.env.NODE_ENV!=="production")var H={},ie=0;function Y(se,oe,P,ne,ce,ae,fe){if(ne=ne||x,ae=ae||P,fe!==n){if(u){var G=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw G.name="Invariant Violation",G}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var Ae=ne+":"+P;!H[Ae]&&ie<3&&(d("You are manually calling a React.PropTypes validation function for the `"+ae+"` prop on `"+ne+"`. 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."),H[Ae]=!0,ie++)}}return oe[P]==null?se?oe[P]===null?new g("The "+ce+" `"+ae+"` is marked as required "+("in `"+ne+"`, but its value is `null`.")):new g("The "+ce+" `"+ae+"` is marked as required in "+("`"+ne+"`, but its value is `undefined`.")):null:A(oe,P,ne,ce,ae)}var re=Y.bind(null,!1);return re.isRequired=Y.bind(null,!0),re}function w(A){function H(ie,Y,re,se,oe,P){var ne=ie[Y],ce=Q(ne);if(ce!==A){var ae=xe(ne);return new g("Invalid "+se+" `"+oe+"` of type "+("`"+ae+"` supplied to `"+re+"`, expected ")+("`"+A+"`."),{expectedType:A})}return null}return j(H)}function I(){return j(c)}function v(A){function H(ie,Y,re,se,oe){if(typeof A!="function")return new g("Property `"+oe+"` of component `"+re+"` has invalid PropType notation inside arrayOf.");var P=ie[Y];if(!Array.isArray(P)){var ne=Q(P);return new g("Invalid "+se+" `"+oe+"` of type "+("`"+ne+"` supplied to `"+re+"`, expected an array."))}for(var ce=0;ce<P.length;ce++){var ae=A(P,ce,re,se,oe+"["+ce+"]",n);if(ae instanceof Error)return ae}return null}return j(H)}function S(){function A(H,ie,Y,re,se){var oe=H[ie];if(!l(oe)){var P=Q(oe);return new g("Invalid "+re+" `"+se+"` of type "+("`"+P+"` supplied to `"+Y+"`, expected a single ReactElement."))}return null}return j(A)}function C(){function A(H,ie,Y,re,se){var oe=H[ie];if(!t.isValidElementType(oe)){var P=Q(oe);return new g("Invalid "+re+" `"+se+"` of type "+("`"+P+"` supplied to `"+Y+"`, expected a single ReactElement type."))}return null}return j(A)}function a(A){function H(ie,Y,re,se,oe){if(!(ie[Y]instanceof A)){var P=A.name||x,ne=L(ie[Y]);return new g("Invalid "+se+" `"+oe+"` of type "+("`"+ne+"` supplied to `"+re+"`, expected ")+("instance of `"+P+"`."))}return null}return j(H)}function z(A){if(!Array.isArray(A))return process.env.NODE_ENV!=="production"&&(arguments.length>1?d("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])."):d("Invalid argument supplied to oneOf, expected an array.")),c;function H(ie,Y,re,se,oe){for(var P=ie[Y],ne=0;ne<A.length;ne++)if(D(P,A[ne]))return null;var ce=JSON.stringify(A,function(fe,G){var Ae=xe(G);return Ae==="symbol"?String(G):G});return new g("Invalid "+se+" `"+oe+"` of value `"+String(P)+"` "+("supplied to `"+re+"`, expected one of "+ce+"."))}return j(H)}function R(A){function H(ie,Y,re,se,oe){if(typeof A!="function")return new g("Property `"+oe+"` of component `"+re+"` has invalid PropType notation inside objectOf.");var P=ie[Y],ne=Q(P);if(ne!=="object")return new g("Invalid "+se+" `"+oe+"` of type "+("`"+ne+"` supplied to `"+re+"`, expected an object."));for(var ce in P)if(i(P,ce)){var ae=A(P,ce,re,se,oe+"."+ce,n);if(ae instanceof Error)return ae}return null}return j(H)}function q(A){if(!Array.isArray(A))return process.env.NODE_ENV!=="production"&&d("Invalid argument supplied to oneOfType, expected an instance of array."),c;for(var H=0;H<A.length;H++){var ie=A[H];if(typeof ie!="function")return d("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+de(ie)+" at index "+H+"."),c}function Y(re,se,oe,P,ne){for(var ce=[],ae=0;ae<A.length;ae++){var fe=A[ae],G=fe(re,se,oe,P,ne,n);if(G==null)return null;G.data&&i(G.data,"expectedType")&&ce.push(G.data.expectedType)}var Ae=ce.length>0?", expected one of type ["+ce.join(", ")+"]":"";return new g("Invalid "+P+" `"+ne+"` supplied to "+("`"+oe+"`"+Ae+"."))}return j(Y)}function K(){function A(H,ie,Y,re,se){return W(H[ie])?null:new g("Invalid "+re+" `"+se+"` supplied to "+("`"+Y+"`, expected a ReactNode."))}return j(A)}function ee(A,H,ie,Y,re){return new g((A||"React class")+": "+H+" type `"+ie+"."+Y+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+re+"`.")}function y(A){function H(ie,Y,re,se,oe){var P=ie[Y],ne=Q(P);if(ne!=="object")return new g("Invalid "+se+" `"+oe+"` of type `"+ne+"` "+("supplied to `"+re+"`, expected `object`."));for(var ce in A){var ae=A[ce];if(typeof ae!="function")return ee(re,se,oe,ce,xe(ae));var fe=ae(P,ce,re,se,oe+"."+ce,n);if(fe)return fe}return null}return j(H)}function M(A){function H(ie,Y,re,se,oe){var P=ie[Y],ne=Q(P);if(ne!=="object")return new g("Invalid "+se+" `"+oe+"` of type `"+ne+"` "+("supplied to `"+re+"`, expected `object`."));var ce=o({},ie[Y],A);for(var ae in ce){var fe=A[ae];if(i(A,ae)&&typeof fe!="function")return ee(re,se,oe,ae,xe(fe));if(!fe)return new g("Invalid "+se+" `"+oe+"` key `"+ae+"` supplied to `"+re+"`.\nBad object: "+JSON.stringify(ie[Y],null," ")+`
22
+ Valid keys: `+JSON.stringify(Object.keys(A),null," "));var G=fe(P,ae,re,se,oe+"."+ae,n);if(G)return G}return null}return j(H)}function W(A){switch(typeof A){case"number":case"string":case"undefined":return!0;case"boolean":return!A;case"object":if(Array.isArray(A))return A.every(W);if(A===null||l(A))return!0;var H=h(A);if(H){var ie=H.call(A),Y;if(H!==A.entries){for(;!(Y=ie.next()).done;)if(!W(Y.value))return!1}else for(;!(Y=ie.next()).done;){var re=Y.value;if(re&&!W(re[1]))return!1}}else return!1;return!0;default:return!1}}function V(A,H){return A==="symbol"?!0:H?H["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&H instanceof Symbol:!1}function Q(A){var H=typeof A;return Array.isArray(A)?"array":A instanceof RegExp?"object":V(H,A)?"symbol":H}function xe(A){if(typeof A>"u"||A===null)return""+A;var H=Q(A);if(H==="object"){if(A instanceof Date)return"date";if(A instanceof RegExp)return"regexp"}return H}function de(A){var H=xe(A);switch(H){case"array":case"object":return"an "+H;case"boolean":case"date":case"regexp":return"a "+H;default:return H}}function L(A){return!A.constructor||!A.constructor.name?x:A.constructor.name}return b.checkPropTypes=s,b.resetWarningCache=s.resetWarningCache,b.PropTypes=b,b},Yo}var Go,Pn;function cl(){if(Pn)return Go;Pn=1;var t=sn();function o(){}function n(){}return n.resetWarningCache=o,Go=function(){function i(c,l,u,f,m,h){if(h!==t){var x=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 x.name="Invariant Violation",x}}i.isRequired=i;function s(){return i}var d={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:o};return d.PropTypes=d,d},Go}var Nn;function dl(){if(Nn)return no.exports;if(Nn=1,process.env.NODE_ENV!=="production"){var t=$i(),o=!0;no.exports=ll()(t.isElement,o)}else no.exports=cl()();return no.exports}var ul=dl();const Pr=ol(ul);var so={exports:{}},je={};/**
23
23
  * @license React
24
24
  * react-is.production.js
25
25
  *
@@ -27,7 +27,7 @@ Valid keys: `+JSON.stringify(Object.keys(A),null," "));var q=ge(P,le,re,ae,ne+"
27
27
  *
28
28
  * This source code is licensed under the MIT license found in the
29
29
  * LICENSE file in the root directory of this source tree.
30
- */var Hn;function yl(){if(Hn)return Te;Hn=1;var t=Symbol.for("react.transitional.element"),o=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),d=Symbol.for("react.consumer"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),x=Symbol.for("react.view_transition"),y=Symbol.for("react.client.reference");function D(v){if(typeof v=="object"&&v!==null){var C=v.$$typeof;switch(C){case t:switch(v=v.type,v){case n:case s:case i:case u:case h:case x:return v;default:switch(v=v&&v.$$typeof,v){case l:case c:case b:case m:return v;case d:return v;default:return C}}case o:return C}}}return Te.ContextConsumer=d,Te.ContextProvider=l,Te.Element=t,Te.ForwardRef=c,Te.Fragment=n,Te.Lazy=b,Te.Memo=m,Te.Portal=o,Te.Profiler=s,Te.StrictMode=i,Te.Suspense=u,Te.SuspenseList=h,Te.isContextConsumer=function(v){return D(v)===d},Te.isContextProvider=function(v){return D(v)===l},Te.isElement=function(v){return typeof v=="object"&&v!==null&&v.$$typeof===t},Te.isForwardRef=function(v){return D(v)===c},Te.isFragment=function(v){return D(v)===n},Te.isLazy=function(v){return D(v)===b},Te.isMemo=function(v){return D(v)===m},Te.isPortal=function(v){return D(v)===o},Te.isProfiler=function(v){return D(v)===s},Te.isStrictMode=function(v){return D(v)===i},Te.isSuspense=function(v){return D(v)===u},Te.isSuspenseList=function(v){return D(v)===h},Te.isValidElementType=function(v){return typeof v=="string"||typeof v=="function"||v===n||v===s||v===i||v===u||v===h||typeof v=="object"&&v!==null&&(v.$$typeof===b||v.$$typeof===m||v.$$typeof===l||v.$$typeof===d||v.$$typeof===c||v.$$typeof===y||v.getModuleId!==void 0)},Te.typeOf=D,Te}var Ie={};/**
30
+ */var Ln;function pl(){if(Ln)return je;Ln=1;var t=Symbol.for("react.transitional.element"),o=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),d=Symbol.for("react.consumer"),c=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),f=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),x=Symbol.for("react.view_transition"),b=Symbol.for("react.client.reference");function D(g){if(typeof g=="object"&&g!==null){var j=g.$$typeof;switch(j){case t:switch(g=g.type,g){case n:case s:case i:case u:case f:case x:return g;default:switch(g=g&&g.$$typeof,g){case c:case l:case h:case m:return g;case d:return g;default:return j}}case o:return j}}}return je.ContextConsumer=d,je.ContextProvider=c,je.Element=t,je.ForwardRef=l,je.Fragment=n,je.Lazy=h,je.Memo=m,je.Portal=o,je.Profiler=s,je.StrictMode=i,je.Suspense=u,je.SuspenseList=f,je.isContextConsumer=function(g){return D(g)===d},je.isContextProvider=function(g){return D(g)===c},je.isElement=function(g){return typeof g=="object"&&g!==null&&g.$$typeof===t},je.isForwardRef=function(g){return D(g)===l},je.isFragment=function(g){return D(g)===n},je.isLazy=function(g){return D(g)===h},je.isMemo=function(g){return D(g)===m},je.isPortal=function(g){return D(g)===o},je.isProfiler=function(g){return D(g)===s},je.isStrictMode=function(g){return D(g)===i},je.isSuspense=function(g){return D(g)===u},je.isSuspenseList=function(g){return D(g)===f},je.isValidElementType=function(g){return typeof g=="string"||typeof g=="function"||g===n||g===s||g===i||g===u||g===f||typeof g=="object"&&g!==null&&(g.$$typeof===h||g.$$typeof===m||g.$$typeof===c||g.$$typeof===d||g.$$typeof===l||g.$$typeof===b||g.getModuleId!==void 0)},je.typeOf=D,je}var Ce={};/**
31
31
  * @license React
32
32
  * react-is.development.js
33
33
  *
@@ -35,16 +35,16 @@ Valid keys: `+JSON.stringify(Object.keys(A),null," "));var q=ge(P,le,re,ae,ne+"
35
35
  *
36
36
  * This source code is licensed under the MIT license found in the
37
37
  * LICENSE file in the root directory of this source tree.
38
- */var Un;function bl(){return Un||(Un=1,process.env.NODE_ENV!=="production"&&(function(){function t(v){if(typeof v=="object"&&v!==null){var C=v.$$typeof;switch(C){case o:switch(v=v.type,v){case i:case d:case s:case h:case m:case y:return v;default:switch(v=v&&v.$$typeof,v){case c:case u:case x:case b:return v;case l:return v;default:return C}}case n:return C}}}var o=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),d=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),m=Symbol.for("react.suspense_list"),b=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),y=Symbol.for("react.view_transition"),D=Symbol.for("react.client.reference");Ie.ContextConsumer=l,Ie.ContextProvider=c,Ie.Element=o,Ie.ForwardRef=u,Ie.Fragment=i,Ie.Lazy=x,Ie.Memo=b,Ie.Portal=n,Ie.Profiler=d,Ie.StrictMode=s,Ie.Suspense=h,Ie.SuspenseList=m,Ie.isContextConsumer=function(v){return t(v)===l},Ie.isContextProvider=function(v){return t(v)===c},Ie.isElement=function(v){return typeof v=="object"&&v!==null&&v.$$typeof===o},Ie.isForwardRef=function(v){return t(v)===u},Ie.isFragment=function(v){return t(v)===i},Ie.isLazy=function(v){return t(v)===x},Ie.isMemo=function(v){return t(v)===b},Ie.isPortal=function(v){return t(v)===n},Ie.isProfiler=function(v){return t(v)===d},Ie.isStrictMode=function(v){return t(v)===s},Ie.isSuspense=function(v){return t(v)===h},Ie.isSuspenseList=function(v){return t(v)===m},Ie.isValidElementType=function(v){return typeof v=="string"||typeof v=="function"||v===i||v===d||v===s||v===h||v===m||typeof v=="object"&&v!==null&&(v.$$typeof===x||v.$$typeof===b||v.$$typeof===c||v.$$typeof===l||v.$$typeof===u||v.$$typeof===D||v.getModuleId!==void 0)},Ie.typeOf=t})()),Ie}var Yn;function vl(){return Yn||(Yn=1,process.env.NODE_ENV==="production"?mo.exports=yl():mo.exports=bl()),mo.exports}var Wi=vl();function Ut(t){if(typeof t!="object"||t===null)return!1;const o=Object.getPrototypeOf(t);return(o===null||o===Object.prototype||Object.getPrototypeOf(o)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)}function Pi(t){if(Io.isValidElement(t)||Wi.isValidElementType(t)||!Ut(t))return t;const o={};return Object.keys(t).forEach(n=>{o[n]=Pi(t[n])}),o}function Ze(t,o,n={clone:!0}){const i=n.clone?{...t}:t;return Ut(t)&&Ut(o)&&Object.keys(o).forEach(s=>{Io.isValidElement(o[s])||Wi.isValidElementType(o[s])?i[s]=o[s]:Ut(o[s])&&Object.prototype.hasOwnProperty.call(t,s)&&Ut(t[s])?i[s]=Ze(t[s],o[s],n):n.clone?i[s]=Ut(o[s])?Pi(o[s]):o[s]:i[s]=o[s]}),i}const Sl=t=>{const o=Object.keys(t).map(n=>({key:n,val:t[n]}))||[];return o.sort((n,i)=>n.val-i.val),o.reduce((n,i)=>({...n,[i.key]:i.val}),{})};function jl(t){const{values:o={xs:0,sm:600,md:900,lg:1200,xl:1536},unit:n="px",step:i=5,...s}=t,d=Sl(o),l=Object.keys(d);function c(x){return`@media (min-width:${typeof o[x]=="number"?o[x]:x}${n})`}function u(x){return`@media (max-width:${(typeof o[x]=="number"?o[x]:x)-i/100}${n})`}function h(x,y){const D=l.indexOf(y);return`@media (min-width:${typeof o[x]=="number"?o[x]:x}${n}) and (max-width:${(D!==-1&&typeof o[l[D]]=="number"?o[l[D]]:y)-i/100}${n})`}function m(x){return l.indexOf(x)+1<l.length?h(x,l[l.indexOf(x)+1]):c(x)}function b(x){const y=l.indexOf(x);return y===0?c(l[1]):y===l.length-1?u(l[y]):h(x,l[l.indexOf(x)+1]).replace("@media","@media not all and")}return{keys:l,values:d,up:c,down:u,between:h,only:m,not:b,unit:n,...s}}function Gn(t,o){if(!t.containerQueries)return o;const n=Object.keys(o).filter(i=>i.startsWith("@container")).sort((i,s)=>{var l,c;const d=/min-width:\s*([0-9.]+)/;return+(((l=i.match(d))==null?void 0:l[1])||0)-+(((c=s.match(d))==null?void 0:c[1])||0)});return n.length?n.reduce((i,s)=>{const d=o[s];return delete i[s],i[s]=d,i},{...o}):o}function Cl(t,o){return o==="@"||o.startsWith("@")&&(t.some(n=>o.startsWith(`@${n}`))||!!o.match(/^@\d/))}function wl(t,o){const n=o.match(/^@([^/]+)?\/?(.+)?$/);if(!n){if(process.env.NODE_ENV!=="production")throw new Error(`MUI: The provided shorthand ${`(${o})`} is invalid. The format should be \`@<breakpoint | number>\` or \`@<breakpoint | number>/<container>\`.
39
- For example, \`@sm\` or \`@600\` or \`@40rem/sidebar\`.`);return null}const[,i,s]=n,d=Number.isNaN(+i)?i||0:+i;return t.containerQueries(s).up(d)}function kl(t){const o=(d,l)=>d.replace("@media",l?`@container ${l}`:"@container");function n(d,l){d.up=(...c)=>o(t.breakpoints.up(...c),l),d.down=(...c)=>o(t.breakpoints.down(...c),l),d.between=(...c)=>o(t.breakpoints.between(...c),l),d.only=(...c)=>o(t.breakpoints.only(...c),l),d.not=(...c)=>{const u=o(t.breakpoints.not(...c),l);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=d=>(n(i,d),i);return n(s),{...t,containerQueries:s}}const Tl={borderRadius:4},Gt=process.env.NODE_ENV!=="production"?qr.oneOfType([qr.number,qr.string,qr.object,qr.array]):{};function ro(t,o){return o?Ze(t,o,{clone:!1}):t}const Do={xs:0,sm:600,md:900,lg:1200,xl:1536},qn={keys:["xs","sm","md","lg","xl"],up:t=>`@media (min-width:${Do[t]}px)`},Il={containerQueries:t=>({up:o=>{let n=typeof o=="number"?o:Do[o]||o;return typeof n=="number"&&(n=`${n}px`),t?`@container ${t} (min-width:${n})`:`@container (min-width:${n})`}})};function $t(t,o,n){const i=t.theme||{};if(Array.isArray(o)){const d=i.breakpoints||qn;return o.reduce((l,c,u)=>(l[d.up(d.keys[u])]=n(o[u]),l),{})}if(typeof o=="object"){const d=i.breakpoints||qn;return Object.keys(o).reduce((l,c)=>{if(Cl(d.keys,c)){const u=wl(i.containerQueries?i:Il,c);u&&(l[u]=n(o[c],c))}else if(Object.keys(d.values||Do).includes(c)){const u=d.up(c);l[u]=n(o[c],c)}else{const u=c;l[u]=o[u]}return l},{})}return n(o)}function zl(t={}){var n;return((n=t.keys)==null?void 0:n.reduce((i,s)=>{const d=t.up(s);return i[d]={},i},{}))||{}}function Jn(t,o){return t.reduce((n,i)=>{const s=n[i];return(!s||Object.keys(s).length===0)&&delete n[i],n},o)}function Ni(t){if(typeof t!="string")throw new Error(process.env.NODE_ENV!=="production"?"MUI: `capitalize(string)` expects a string argument.":dr(7));return t.charAt(0).toUpperCase()+t.slice(1)}function Eo(t,o,n=!0){if(!o||typeof o!="string")return null;if(t&&t.vars&&n){const i=`vars.${o}`.split(".").reduce((s,d)=>s&&s[d]?s[d]:null,t);if(i!=null)return i}return o.split(".").reduce((i,s)=>i&&i[s]!=null?i[s]:null,t)}function ko(t,o,n,i=n){let s;return typeof t=="function"?s=t(n):Array.isArray(t)?s=t[n]||i:s=Eo(t,n)||i,o&&(s=o(s,i,t)),s}function $e(t){const{prop:o,cssProperty:n=t.prop,themeKey:i,transform:s}=t,d=l=>{if(l[o]==null)return null;const c=l[o],u=l.theme,h=Eo(u,i)||{};return $t(l,c,b=>{let x=ko(h,s,b);return b===x&&typeof b=="string"&&(x=ko(h,s,`${o}${b==="default"?"":Ni(b)}`,b)),n===!1?x:{[n]:x}})};return d.propTypes=process.env.NODE_ENV!=="production"?{[o]:Gt}:{},d.filterProps=[o],d}function Bl(t){const o={};return n=>(o[n]===void 0&&(o[n]=t(n)),o[n])}const Dl={m:"margin",p:"padding"},El={t:"Top",r:"Right",b:"Bottom",l:"Left",x:["Left","Right"],y:["Top","Bottom"]},Kn={marginX:"mx",marginY:"my",paddingX:"px",paddingY:"py"},Ol=Bl(t=>{if(t.length>2)if(Kn[t])t=Kn[t];else return[t];const[o,n]=t.split(""),i=Dl[o],s=El[n]||"";return Array.isArray(s)?s.map(d=>i+d):[i+s]}),Oo=["m","mt","mr","mb","ml","mx","my","margin","marginTop","marginRight","marginBottom","marginLeft","marginX","marginY","marginInline","marginInlineStart","marginInlineEnd","marginBlock","marginBlockStart","marginBlockEnd"],$o=["p","pt","pr","pb","pl","px","py","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingX","paddingY","paddingInline","paddingInlineStart","paddingInlineEnd","paddingBlock","paddingBlockStart","paddingBlockEnd"],$l=[...Oo,...$o];function no(t,o,n,i){const s=Eo(t,o,!0)??n;return typeof s=="number"||typeof s=="string"?d=>typeof d=="string"?d:(process.env.NODE_ENV!=="production"&&typeof d!="number"&&console.error(`MUI: Expected ${i} argument to be a number or a string, got ${d}.`),typeof s=="string"?s.startsWith("var(")&&d===0?0:s.startsWith("var(")&&d===1?s:`calc(${d} * ${s})`:s*d):Array.isArray(s)?d=>{if(typeof d=="string")return d;const l=Math.abs(d);process.env.NODE_ENV!=="production"&&(Number.isInteger(l)?l>s.length-1&&console.error([`MUI: The value provided (${l}) overflows.`,`The supported values are: ${JSON.stringify(s)}.`,`${l} > ${s.length-1}, you need to add the missing values.`].join(`
38
+ */var Fn;function xl(){return Fn||(Fn=1,process.env.NODE_ENV!=="production"&&(function(){function t(g){if(typeof g=="object"&&g!==null){var j=g.$$typeof;switch(j){case o:switch(g=g.type,g){case i:case d:case s:case f:case m:case b:return g;default:switch(g=g&&g.$$typeof,g){case l:case u:case x:case h:return g;case c:return g;default:return j}}case n:return j}}}var o=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),d=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),l=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),m=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),b=Symbol.for("react.view_transition"),D=Symbol.for("react.client.reference");Ce.ContextConsumer=c,Ce.ContextProvider=l,Ce.Element=o,Ce.ForwardRef=u,Ce.Fragment=i,Ce.Lazy=x,Ce.Memo=h,Ce.Portal=n,Ce.Profiler=d,Ce.StrictMode=s,Ce.Suspense=f,Ce.SuspenseList=m,Ce.isContextConsumer=function(g){return t(g)===c},Ce.isContextProvider=function(g){return t(g)===l},Ce.isElement=function(g){return typeof g=="object"&&g!==null&&g.$$typeof===o},Ce.isForwardRef=function(g){return t(g)===u},Ce.isFragment=function(g){return t(g)===i},Ce.isLazy=function(g){return t(g)===x},Ce.isMemo=function(g){return t(g)===h},Ce.isPortal=function(g){return t(g)===n},Ce.isProfiler=function(g){return t(g)===d},Ce.isStrictMode=function(g){return t(g)===s},Ce.isSuspense=function(g){return t(g)===f},Ce.isSuspenseList=function(g){return t(g)===m},Ce.isValidElementType=function(g){return typeof g=="string"||typeof g=="function"||g===i||g===d||g===s||g===f||g===m||typeof g=="object"&&g!==null&&(g.$$typeof===x||g.$$typeof===h||g.$$typeof===l||g.$$typeof===c||g.$$typeof===u||g.$$typeof===D||g.getModuleId!==void 0)},Ce.typeOf=t})()),Ce}var Vn;function ml(){return Vn||(Vn=1,process.env.NODE_ENV==="production"?so.exports=pl():so.exports=xl()),so.exports}var Ri=ml();function Nt(t){if(typeof t!="object"||t===null)return!1;const o=Object.getPrototypeOf(t);return(o===null||o===Object.prototype||Object.getPrototypeOf(o)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)}function _i(t){if(vo.isValidElement(t)||Ri.isValidElementType(t)||!Nt(t))return t;const o={};return Object.keys(t).forEach(n=>{o[n]=_i(t[n])}),o}function Xe(t,o,n={clone:!0}){const i=n.clone?{...t}:t;return Nt(t)&&Nt(o)&&Object.keys(o).forEach(s=>{vo.isValidElement(o[s])||Ri.isValidElementType(o[s])?i[s]=o[s]:Nt(o[s])&&Object.prototype.hasOwnProperty.call(t,s)&&Nt(t[s])?i[s]=Xe(t[s],o[s],n):n.clone?i[s]=Nt(o[s])?_i(o[s]):o[s]:i[s]=o[s]}),i}const hl=t=>{const o=Object.keys(t).map(n=>({key:n,val:t[n]}))||[];return o.sort((n,i)=>n.val-i.val),o.reduce((n,i)=>({...n,[i.key]:i.val}),{})};function fl(t){const{values:o={xs:0,sm:600,md:900,lg:1200,xl:1536},unit:n="px",step:i=5,...s}=t,d=hl(o),c=Object.keys(d);function l(x){return`@media (min-width:${typeof o[x]=="number"?o[x]:x}${n})`}function u(x){return`@media (max-width:${(typeof o[x]=="number"?o[x]:x)-i/100}${n})`}function f(x,b){const D=c.indexOf(b);return`@media (min-width:${typeof o[x]=="number"?o[x]:x}${n}) and (max-width:${(D!==-1&&typeof o[c[D]]=="number"?o[c[D]]:b)-i/100}${n})`}function m(x){return c.indexOf(x)+1<c.length?f(x,c[c.indexOf(x)+1]):l(x)}function h(x){const b=c.indexOf(x);return b===0?l(c[1]):b===c.length-1?u(c[b]):f(x,c[c.indexOf(x)+1]).replace("@media","@media not all and")}return{keys:c,values:d,up:l,down:u,between:f,only:m,not:h,unit:n,...s}}function Hn(t,o){if(!t.containerQueries)return o;const n=Object.keys(o).filter(i=>i.startsWith("@container")).sort((i,s)=>{var c,l;const d=/min-width:\s*([0-9.]+)/;return+(((c=i.match(d))==null?void 0:c[1])||0)-+(((l=s.match(d))==null?void 0:l[1])||0)});return n.length?n.reduce((i,s)=>{const d=o[s];return delete i[s],i[s]=d,i},{...o}):o}function gl(t,o){return o==="@"||o.startsWith("@")&&(t.some(n=>o.startsWith(`@${n}`))||!!o.match(/^@\d/))}function yl(t,o){const n=o.match(/^@([^/]+)?\/?(.+)?$/);if(!n){if(process.env.NODE_ENV!=="production")throw new Error(`MUI: The provided shorthand ${`(${o})`} is invalid. The format should be \`@<breakpoint | number>\` or \`@<breakpoint | number>/<container>\`.
39
+ For example, \`@sm\` or \`@600\` or \`@40rem/sidebar\`.`);return null}const[,i,s]=n,d=Number.isNaN(+i)?i||0:+i;return t.containerQueries(s).up(d)}function bl(t){const o=(d,c)=>d.replace("@media",c?`@container ${c}`:"@container");function n(d,c){d.up=(...l)=>o(t.breakpoints.up(...l),c),d.down=(...l)=>o(t.breakpoints.down(...l),c),d.between=(...l)=>o(t.breakpoints.between(...l),c),d.only=(...l)=>o(t.breakpoints.only(...l),c),d.not=(...l)=>{const u=o(t.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=d=>(n(i,d),i);return n(s),{...t,containerQueries:s}}const vl={borderRadius:4},Ft=process.env.NODE_ENV!=="production"?Pr.oneOfType([Pr.number,Pr.string,Pr.object,Pr.array]):{};function Gr(t,o){return o?Xe(t,o,{clone:!1}):t}const Co={xs:0,sm:600,md:900,lg:1200,xl:1536},Un={keys:["xs","sm","md","lg","xl"],up:t=>`@media (min-width:${Co[t]}px)`},Sl={containerQueries:t=>({up:o=>{let n=typeof o=="number"?o:Co[o]||o;return typeof n=="number"&&(n=`${n}px`),t?`@container ${t} (min-width:${n})`:`@container (min-width:${n})`}})};function Tt(t,o,n){const i=t.theme||{};if(Array.isArray(o)){const d=i.breakpoints||Un;return o.reduce((c,l,u)=>(c[d.up(d.keys[u])]=n(o[u]),c),{})}if(typeof o=="object"){const d=i.breakpoints||Un;return Object.keys(o).reduce((c,l)=>{if(gl(d.keys,l)){const u=yl(i.containerQueries?i:Sl,l);u&&(c[u]=n(o[l],l))}else if(Object.keys(d.values||Co).includes(l)){const u=d.up(l);c[u]=n(o[l],l)}else{const u=l;c[u]=o[u]}return c},{})}return n(o)}function jl(t={}){var n;return((n=t.keys)==null?void 0:n.reduce((i,s)=>{const d=t.up(s);return i[d]={},i},{}))||{}}function Yn(t,o){return t.reduce((n,i)=>{const s=n[i];return(!s||Object.keys(s).length===0)&&delete n[i],n},o)}function Wi(t){if(typeof t!="string")throw new Error(process.env.NODE_ENV!=="production"?"MUI: `capitalize(string)` expects a string argument.":or(7));return t.charAt(0).toUpperCase()+t.slice(1)}function wo(t,o,n=!0){if(!o||typeof o!="string")return null;if(t&&t.vars&&n){const i=`vars.${o}`.split(".").reduce((s,d)=>s&&s[d]?s[d]:null,t);if(i!=null)return i}return o.split(".").reduce((i,s)=>i&&i[s]!=null?i[s]:null,t)}function yo(t,o,n,i=n){let s;return typeof t=="function"?s=t(n):Array.isArray(t)?s=t[n]||i:s=wo(t,n)||i,o&&(s=o(s,i,t)),s}function Ee(t){const{prop:o,cssProperty:n=t.prop,themeKey:i,transform:s}=t,d=c=>{if(c[o]==null)return null;const l=c[o],u=c.theme,f=wo(u,i)||{};return Tt(c,l,h=>{let x=yo(f,s,h);return h===x&&typeof h=="string"&&(x=yo(f,s,`${o}${h==="default"?"":Wi(h)}`,h)),n===!1?x:{[n]:x}})};return d.propTypes=process.env.NODE_ENV!=="production"?{[o]:Ft}:{},d.filterProps=[o],d}function Cl(t){const o={};return n=>(o[n]===void 0&&(o[n]=t(n)),o[n])}const wl={m:"margin",p:"padding"},kl={t:"Top",r:"Right",b:"Bottom",l:"Left",x:["Left","Right"],y:["Top","Bottom"]},Gn={marginX:"mx",marginY:"my",paddingX:"px",paddingY:"py"},Tl=Cl(t=>{if(t.length>2)if(Gn[t])t=Gn[t];else return[t];const[o,n]=t.split(""),i=wl[o],s=kl[n]||"";return Array.isArray(s)?s.map(d=>i+d):[i+s]}),ko=["m","mt","mr","mb","ml","mx","my","margin","marginTop","marginRight","marginBottom","marginLeft","marginX","marginY","marginInline","marginInlineStart","marginInlineEnd","marginBlock","marginBlockStart","marginBlockEnd"],To=["p","pt","pr","pb","pl","px","py","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingX","paddingY","paddingInline","paddingInlineStart","paddingInlineEnd","paddingBlock","paddingBlockStart","paddingBlockEnd"],zl=[...ko,...To];function Jr(t,o,n,i){const s=wo(t,o,!0)??n;return typeof s=="number"||typeof s=="string"?d=>typeof d=="string"?d:(process.env.NODE_ENV!=="production"&&typeof d!="number"&&console.error(`MUI: Expected ${i} argument to be a number or a string, got ${d}.`),typeof s=="string"?s.startsWith("var(")&&d===0?0:s.startsWith("var(")&&d===1?s:`calc(${d} * ${s})`:s*d):Array.isArray(s)?d=>{if(typeof d=="string")return d;const c=Math.abs(d);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(`
40
40
  `)):console.error([`MUI: The \`theme.${o}\` 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.${o}\` as a number.`].join(`
41
- `)));const c=s[l];return d>=0?c:typeof c=="number"?-c:typeof c=="string"&&c.startsWith("var(")?`calc(-1 * ${c})`:`-${c}`}:typeof s=="function"?s:(process.env.NODE_ENV!=="production"&&console.error([`MUI: The \`theme.${o}\` value (${s}) is invalid.`,"It should be a number, an array or a function."].join(`
42
- `)),()=>{})}function pn(t){return no(t,"spacing",8,"spacing")}function io(t,o){return typeof o=="string"||o==null?o:t(o)}function Al(t,o){return n=>t.reduce((i,s)=>(i[s]=io(o,n),i),{})}function _l(t,o,n,i){if(!o.includes(n))return null;const s=Ol(n),d=Al(s,i),l=t[n];return $t(t,l,d)}function Li(t,o){const n=pn(t.theme);return Object.keys(t).map(i=>_l(t,o,i,n)).reduce(ro,{})}function Ee(t){return Li(t,Oo)}Ee.propTypes=process.env.NODE_ENV!=="production"?Oo.reduce((t,o)=>(t[o]=Gt,t),{}):{};Ee.filterProps=Oo;function Oe(t){return Li(t,$o)}Oe.propTypes=process.env.NODE_ENV!=="production"?$o.reduce((t,o)=>(t[o]=Gt,t),{}):{};Oe.filterProps=$o;process.env.NODE_ENV!=="production"&&$l.reduce((t,o)=>(t[o]=Gt,t),{});function Fi(t=8,o=pn({spacing:t})){if(t.mui)return t;const n=(...i)=>(process.env.NODE_ENV!=="production"&&(i.length<=4||console.error(`MUI: Too many arguments provided, expected between 0 and 4, got ${i.length}`)),(i.length===0?[1]:i).map(d=>{const l=o(d);return typeof l=="number"?`${l}px`:l}).join(" "));return n.mui=!0,n}function Ao(...t){const o=t.reduce((i,s)=>(s.filterProps.forEach(d=>{i[d]=s}),i),{}),n=i=>Object.keys(i).reduce((s,d)=>o[d]?ro(s,o[d](i)):s,{});return n.propTypes=process.env.NODE_ENV!=="production"?t.reduce((i,s)=>Object.assign(i,s.propTypes),{}):{},n.filterProps=t.reduce((i,s)=>i.concat(s.filterProps),[]),n}function st(t){return typeof t!="number"?t:`${t}px solid`}function at(t,o){return $e({prop:t,themeKey:"borders",transform:o})}const Ml=at("border",st),Rl=at("borderTop",st),Wl=at("borderRight",st),Pl=at("borderBottom",st),Nl=at("borderLeft",st),Ll=at("borderColor"),Fl=at("borderTopColor"),Vl=at("borderRightColor"),Hl=at("borderBottomColor"),Ul=at("borderLeftColor"),Yl=at("outline",st),Gl=at("outlineColor"),_o=t=>{if(t.borderRadius!==void 0&&t.borderRadius!==null){const o=no(t.theme,"shape.borderRadius",4,"borderRadius"),n=i=>({borderRadius:io(o,i)});return $t(t,t.borderRadius,n)}return null};_o.propTypes=process.env.NODE_ENV!=="production"?{borderRadius:Gt}:{};_o.filterProps=["borderRadius"];Ao(Ml,Rl,Wl,Pl,Nl,Ll,Fl,Vl,Hl,Ul,_o,Yl,Gl);const Mo=t=>{if(t.gap!==void 0&&t.gap!==null){const o=no(t.theme,"spacing",8,"gap"),n=i=>({gap:io(o,i)});return $t(t,t.gap,n)}return null};Mo.propTypes=process.env.NODE_ENV!=="production"?{gap:Gt}:{};Mo.filterProps=["gap"];const Ro=t=>{if(t.columnGap!==void 0&&t.columnGap!==null){const o=no(t.theme,"spacing",8,"columnGap"),n=i=>({columnGap:io(o,i)});return $t(t,t.columnGap,n)}return null};Ro.propTypes=process.env.NODE_ENV!=="production"?{columnGap:Gt}:{};Ro.filterProps=["columnGap"];const Wo=t=>{if(t.rowGap!==void 0&&t.rowGap!==null){const o=no(t.theme,"spacing",8,"rowGap"),n=i=>({rowGap:io(o,i)});return $t(t,t.rowGap,n)}return null};Wo.propTypes=process.env.NODE_ENV!=="production"?{rowGap:Gt}:{};Wo.filterProps=["rowGap"];const ql=$e({prop:"gridColumn"}),Jl=$e({prop:"gridRow"}),Kl=$e({prop:"gridAutoFlow"}),Xl=$e({prop:"gridAutoColumns"}),Ql=$e({prop:"gridAutoRows"}),Zl=$e({prop:"gridTemplateColumns"}),ec=$e({prop:"gridTemplateRows"}),tc=$e({prop:"gridTemplateAreas"}),rc=$e({prop:"gridArea"});Ao(Mo,Ro,Wo,ql,Jl,Kl,Xl,Ql,Zl,ec,tc,rc);function Er(t,o){return o==="grey"?o:t}const oc=$e({prop:"color",themeKey:"palette",transform:Er}),nc=$e({prop:"bgcolor",cssProperty:"backgroundColor",themeKey:"palette",transform:Er}),ic=$e({prop:"backgroundColor",themeKey:"palette",transform:Er});Ao(oc,nc,ic);function Xe(t){return t<=1&&t!==0?`${t*100}%`:t}const sc=$e({prop:"width",transform:Xe}),xn=t=>{if(t.maxWidth!==void 0&&t.maxWidth!==null){const o=n=>{var s,d,l,c,u;const i=((l=(d=(s=t.theme)==null?void 0:s.breakpoints)==null?void 0:d.values)==null?void 0:l[n])||Do[n];return i?((u=(c=t.theme)==null?void 0:c.breakpoints)==null?void 0:u.unit)!=="px"?{maxWidth:`${i}${t.theme.breakpoints.unit}`}:{maxWidth:i}:{maxWidth:Xe(n)}};return $t(t,t.maxWidth,o)}return null};xn.filterProps=["maxWidth"];const ac=$e({prop:"minWidth",transform:Xe}),lc=$e({prop:"height",transform:Xe}),cc=$e({prop:"maxHeight",transform:Xe}),dc=$e({prop:"minHeight",transform:Xe});$e({prop:"size",cssProperty:"width",transform:Xe});$e({prop:"size",cssProperty:"height",transform:Xe});const uc=$e({prop:"boxSizing"});Ao(sc,xn,ac,lc,cc,dc,uc);const Po={border:{themeKey:"borders",transform:st},borderTop:{themeKey:"borders",transform:st},borderRight:{themeKey:"borders",transform:st},borderBottom:{themeKey:"borders",transform:st},borderLeft:{themeKey:"borders",transform:st},borderColor:{themeKey:"palette"},borderTopColor:{themeKey:"palette"},borderRightColor:{themeKey:"palette"},borderBottomColor:{themeKey:"palette"},borderLeftColor:{themeKey:"palette"},outline:{themeKey:"borders",transform:st},outlineColor:{themeKey:"palette"},borderRadius:{themeKey:"shape.borderRadius",style:_o},color:{themeKey:"palette",transform:Er},bgcolor:{themeKey:"palette",cssProperty:"backgroundColor",transform:Er},backgroundColor:{themeKey:"palette",transform:Er},p:{style:Oe},pt:{style:Oe},pr:{style:Oe},pb:{style:Oe},pl:{style:Oe},px:{style:Oe},py:{style:Oe},padding:{style:Oe},paddingTop:{style:Oe},paddingRight:{style:Oe},paddingBottom:{style:Oe},paddingLeft:{style:Oe},paddingX:{style:Oe},paddingY:{style:Oe},paddingInline:{style:Oe},paddingInlineStart:{style:Oe},paddingInlineEnd:{style:Oe},paddingBlock:{style:Oe},paddingBlockStart:{style:Oe},paddingBlockEnd:{style:Oe},m:{style:Ee},mt:{style:Ee},mr:{style:Ee},mb:{style:Ee},ml:{style:Ee},mx:{style:Ee},my:{style:Ee},margin:{style:Ee},marginTop:{style:Ee},marginRight:{style:Ee},marginBottom:{style:Ee},marginLeft:{style:Ee},marginX:{style:Ee},marginY:{style:Ee},marginInline:{style:Ee},marginInlineStart:{style:Ee},marginInlineEnd:{style:Ee},marginBlock:{style:Ee},marginBlockStart:{style:Ee},marginBlockEnd:{style:Ee},displayPrint:{cssProperty:!1,transform:t=>({"@media print":{display:t}})},display:{},overflow:{},textOverflow:{},visibility:{},whiteSpace:{},flexBasis:{},flexDirection:{},flexWrap:{},justifyContent:{},alignItems:{},alignContent:{},order:{},flex:{},flexGrow:{},flexShrink:{},alignSelf:{},justifyItems:{},justifySelf:{},gap:{style:Mo},rowGap:{style:Wo},columnGap:{style:Ro},gridColumn:{},gridRow:{},gridAutoFlow:{},gridAutoColumns:{},gridAutoRows:{},gridTemplateColumns:{},gridTemplateRows:{},gridTemplateAreas:{},gridArea:{},position:{},zIndex:{themeKey:"zIndex"},top:{},right:{},bottom:{},left:{},boxShadow:{themeKey:"shadows"},width:{transform:Xe},maxWidth:{style:xn},minWidth:{transform:Xe},height:{transform:Xe},maxHeight:{transform:Xe},minHeight:{transform:Xe},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 pc(...t){const o=t.reduce((i,s)=>i.concat(Object.keys(s)),[]),n=new Set(o);return t.every(i=>n.size===Object.keys(i).length)}function xc(t,o){return typeof t=="function"?t(o):t}function mc(){function t(n,i,s,d){const l={[n]:i,theme:s},c=d[n];if(!c)return{[n]:i};const{cssProperty:u=n,themeKey:h,transform:m,style:b}=c;if(i==null)return null;if(h==="typography"&&i==="inherit")return{[n]:i};const x=Eo(s,h)||{};return b?b(l):$t(l,i,D=>{let v=ko(x,m,D);return D===v&&typeof D=="string"&&(v=ko(x,m,`${n}${D==="default"?"":Ni(D)}`,D)),u===!1?v:{[u]:v}})}function o(n){const{sx:i,theme:s={},nested:d}=n||{};if(!i)return null;const l=s.unstable_sxConfig??Po;function c(u){let h=u;if(typeof u=="function")h=u(s);else if(typeof u!="object")return u;if(!h)return null;const m=zl(s.breakpoints),b=Object.keys(m);let x=m;return Object.keys(h).forEach(y=>{const D=xc(h[y],s);if(D!=null)if(typeof D=="object")if(l[y])x=ro(x,t(y,D,s,l));else{const v=$t({theme:s},D,C=>({[y]:C}));pc(v,D)?x[y]=o({sx:D,theme:s,nested:!0}):x=ro(x,v)}else x=ro(x,t(y,D,s,l))}),!d&&s.modularCssLayers?{"@layer sx":Gn(s,Jn(b,x))}:Gn(s,Jn(b,x))}return Array.isArray(i)?i.map(c):c(i)}return o}const No=mc();No.filterProps=["sx"];function hc(t,o){var i;const n=this;if(n.vars){if(!((i=n.colorSchemes)!=null&&i[t])||typeof n.getColorSchemeSelector!="function")return{};let s=n.getColorSchemeSelector(t);return s==="&"?o:((s.includes("data-")||s.includes("."))&&(s=`*:where(${s.replace(/\s*&$/,"")}) &`),{[s]:o})}return n.palette.mode===t?o:{}}function Vi(t={},...o){const{breakpoints:n={},palette:i={},spacing:s,shape:d={},...l}=t,c=jl(n),u=Fi(s);let h=Ze({breakpoints:c,direction:"ltr",components:{},palette:{mode:"light",...i},spacing:u,shape:{...Tl,...d}},l);return h=kl(h),h.applyStyles=hc,h=o.reduce((m,b)=>Ze(m,b),h),h.unstable_sxConfig={...Po,...l==null?void 0:l.unstable_sxConfig},h.unstable_sx=function(b){return No({sx:b,theme:this})},h}function fc(t){return Object.keys(t).length===0}function gc(t=null){const o=Io.useContext(Rs.ThemeContext);return!o||fc(o)?t:o}const yc=Vi();function bc(t=yc){return gc(t)}const Xn=t=>t,vc=()=>{let t=Xn;return{configure(o){t=o},generate(o){return t(o)},reset(){t=Xn}}},Sc=vc(),jc={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 Cc(t,o,n="Mui"){const i=jc[o];return i?`${n}-${i}`:`${Sc.generate(t)}-${o}`}function wc(t,o=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(o,Math.min(t,n))}function mn(t,o=0,n=1){return process.env.NODE_ENV!=="production"&&(t<o||t>n)&&console.error(`MUI: The value provided ${t} is out of range [${o}, ${n}].`),wc(t,o,n)}function kc(t){t=t.slice(1);const o=new RegExp(`.{1,${t.length>=6?2:1}}`,"g");let n=t.match(o);return n&&n[0].length===1&&(n=n.map(i=>i+i)),process.env.NODE_ENV!=="production"&&t.length!==t.trim().length&&console.error(`MUI: The color: "${t}" is invalid. Make sure the color input doesn't contain leading/trailing space.`),n?`rgb${n.length===4?"a":""}(${n.map((i,s)=>s<3?parseInt(i,16):Math.round(parseInt(i,16)/255*1e3)/1e3).join(", ")})`:""}function Yt(t){if(t.type)return t;if(t.charAt(0)==="#")return Yt(kc(t));const o=t.indexOf("("),n=t.substring(0,o);if(!["rgb","rgba","hsl","hsla","color"].includes(n))throw new Error(process.env.NODE_ENV!=="production"?`MUI: Unsupported \`${t}\` color.
43
- The following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().`:dr(9,t));let i=t.substring(o+1,t.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.
44
- The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rgb, rec-2020.`:dr(10,s))}else i=i.split(",");return i=i.map(d=>parseFloat(d)),{type:n,values:i,colorSpace:s}}const Tc=t=>{const o=Yt(t);return o.values.slice(0,3).map((n,i)=>o.type.includes("hsl")&&i!==0?`${n}%`:n).join(" ")},Zr=(t,o)=>{try{return Tc(t)}catch{return o&&process.env.NODE_ENV!=="production"&&console.warn(o),t}};function Lo(t){const{type:o,colorSpace:n}=t;let{values:i}=t;return o.includes("rgb")?i=i.map((s,d)=>d<3?parseInt(s,10):s):o.includes("hsl")&&(i[1]=`${i[1]}%`,i[2]=`${i[2]}%`),o.includes("color")?i=`${n} ${i.join(" ")}`:i=`${i.join(", ")}`,`${o}(${i})`}function Hi(t){t=Yt(t);const{values:o}=t,n=o[0],i=o[1]/100,s=o[2]/100,d=i*Math.min(s,1-s),l=(h,m=(h+n/30)%12)=>s-d*Math.max(Math.min(m-3,9-m,1),-1);let c="rgb";const u=[Math.round(l(0)*255),Math.round(l(8)*255),Math.round(l(4)*255)];return t.type==="hsla"&&(c+="a",u.push(o[3])),Lo({type:c,values:u})}function on(t){t=Yt(t);let o=t.type==="hsl"||t.type==="hsla"?Yt(Hi(t)).values:t.values;return o=o.map(n=>(t.type!=="color"&&(n/=255),n<=.03928?n/12.92:((n+.055)/1.055)**2.4)),Number((.2126*o[0]+.7152*o[1]+.0722*o[2]).toFixed(3))}function Qn(t,o){const n=on(t),i=on(o);return(Math.max(n,i)+.05)/(Math.min(n,i)+.05)}function T(t,o){return t=Yt(t),o=mn(o),(t.type==="rgb"||t.type==="hsl")&&(t.type+="a"),t.type==="color"?t.values[3]=`/${o}`:t.values[3]=o,Lo(t)}function ar(t,o,n){try{return T(t,o)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),t}}function Fo(t,o){if(t=Yt(t),o=mn(o),t.type.includes("hsl"))t.values[2]*=1-o;else if(t.type.includes("rgb")||t.type.includes("color"))for(let n=0;n<3;n+=1)t.values[n]*=1-o;return Lo(t)}function Se(t,o,n){try{return Fo(t,o)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),t}}function Vo(t,o){if(t=Yt(t),o=mn(o),t.type.includes("hsl"))t.values[2]+=(100-t.values[2])*o;else if(t.type.includes("rgb"))for(let n=0;n<3;n+=1)t.values[n]+=(255-t.values[n])*o;else if(t.type.includes("color"))for(let n=0;n<3;n+=1)t.values[n]+=(1-t.values[n])*o;return Lo(t)}function je(t,o,n){try{return Vo(t,o)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),t}}function Ic(t,o=.15){return on(t)>.5?Fo(t,o):Vo(t,o)}function ho(t,o,n){try{return Ic(t,o)}catch{return t}}function zc(t=""){function o(...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(--${t?`${t}-`:""}${s}${o(...i.slice(1))})`:`, ${s}`}return(i,...s)=>`var(--${t?`${t}-`:""}${i}${o(...s)})`}const Zn=(t,o,n,i=[])=>{let s=t;o.forEach((d,l)=>{l===o.length-1?Array.isArray(s)?s[Number(d)]=n:s&&typeof s=="object"&&(s[d]=n):s&&typeof s=="object"&&(s[d]||(s[d]=i.includes(d)?[]:{}),s=s[d])})},Bc=(t,o,n)=>{function i(s,d=[],l=[]){Object.entries(s).forEach(([c,u])=>{(!n||n&&!n([...d,c]))&&u!=null&&(typeof u=="object"&&Object.keys(u).length>0?i(u,[...d,c],Array.isArray(u)?[...l,c]:l):o([...d,c],u,l))})}i(t)},Dc=(t,o)=>typeof o=="number"?["lineHeight","fontWeight","opacity","zIndex"].some(i=>t.includes(i))||t[t.length-1].toLowerCase().includes("opacity")?o:`${o}px`:o;function Zo(t,o){const{prefix:n,shouldSkipGeneratingVar:i}=o||{},s={},d={},l={};return Bc(t,(c,u,h)=>{if((typeof u=="string"||typeof u=="number")&&(!i||!i(c,u))){const m=`--${n?`${n}-`:""}${c.join("-")}`,b=Dc(c,u);Object.assign(s,{[m]:b}),Zn(d,c,`var(${m})`,h),Zn(l,c,`var(${m}, ${b})`,h)}},c=>c[0]==="vars"),{css:s,vars:d,varsWithDefaults:l}}function Ec(t,o={}){const{getSelector:n=S,disableCssColorScheme:i,colorSchemeSelector:s,enableContrastVars:d}=o,{colorSchemes:l={},components:c,defaultColorScheme:u="light",...h}=t,{vars:m,css:b,varsWithDefaults:x}=Zo(h,o);let y=x;const D={},{[u]:v,...C}=l;if(Object.entries(C||{}).forEach(([k,j])=>{const{vars:a,css:B,varsWithDefaults:R}=Zo(j,o);y=Ze(y,R),D[k]={css:B,vars:a}}),v){const{css:k,vars:j,varsWithDefaults:a}=Zo(v,o);y=Ze(y,a),D[u]={css:k,vars:j}}function S(k,j){var B,R;let a=s;if(s==="class"&&(a=".%s"),s==="data"&&(a="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(a=`[${s}="%s"]`),k){if(a==="media")return t.defaultColorScheme===k?":root":{[`@media (prefers-color-scheme: ${((R=(B=l[k])==null?void 0:B.palette)==null?void 0:R.mode)||k})`]:{":root":j}};if(a)return t.defaultColorScheme===k?`:root, ${a.replace("%s",String(k))}`:a.replace("%s",String(k))}return":root"}return{vars:y,generateThemeVars:()=>{let k={...m};return Object.entries(D).forEach(([,{vars:j}])=>{k=Ze(k,j)}),k},generateStyleSheets:()=>{var J,K;const k=[],j=t.defaultColorScheme||"light";function a(ee,g){Object.keys(g).length&&k.push(typeof ee=="string"?{[ee]:{...g}}:ee)}a(n(void 0,{...b}),b);const{[j]:B,...R}=D;if(B){const{css:ee}=B,g=(K=(J=l[j])==null?void 0:J.palette)==null?void 0:K.mode,M=!i&&g?{colorScheme:g,...ee}:{...ee};a(n(j,{...M}),M)}return Object.entries(R).forEach(([ee,{css:g}])=>{var V,Q;const M=(Q=(V=l[ee])==null?void 0:V.palette)==null?void 0:Q.mode,W=!i&&M?{colorScheme:M,...g}:{...g};a(n(ee,{...W}),W)}),d&&k.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)"}}),k}}}function Oc(t){return function(n){return t==="media"?(process.env.NODE_ENV!=="production"&&n!=="light"&&n!=="dark"&&console.error(`MUI: @media (prefers-color-scheme) supports only 'light' or 'dark', but receive '${n}'.`),`@media (prefers-color-scheme: ${n})`):t?t.startsWith("data-")&&!t.includes("%s")?`[${t}="${n}"] &`:t==="class"?`.${n} &`:t==="data"?`[data-${n}] &`:`${t.replace("%s",n)} &`:"&"}}const oo={black:"#000",white:"#fff"},$c={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"},kr={50:"#f3e5f5",200:"#ce93d8",300:"#ba68c8",400:"#ab47bc",500:"#9c27b0",700:"#7b1fa2"},Tr={300:"#e57373",400:"#ef5350",500:"#f44336",700:"#d32f2f",800:"#c62828"},Jr={300:"#ffb74d",400:"#ffa726",500:"#ff9800",700:"#f57c00",900:"#e65100"},Ir={50:"#e3f2fd",200:"#90caf9",400:"#42a5f5",700:"#1976d2",800:"#1565c0"},zr={300:"#4fc3f7",400:"#29b6f6",500:"#03a9f4",700:"#0288d1",900:"#01579b"},Br={300:"#81c784",400:"#66bb6a",500:"#4caf50",700:"#388e3c",800:"#2e7d32",900:"#1b5e20"};function Ui(){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:oo.white,default:oo.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 Yi=Ui();function Gi(){return{text:{primary:oo.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:oo.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 nn=Gi();function ei(t,o,n,i){const s=i.light||i,d=i.dark||i*1.5;t[o]||(t.hasOwnProperty(n)?t[o]=t[n]:o==="light"?t.light=Vo(t.main,s):o==="dark"&&(t.dark=Fo(t.main,d)))}function ti(t,o,n,i,s){const d=s.light||s,l=s.dark||s*1.5;o[n]||(o.hasOwnProperty(i)?o[n]=o[i]:n==="light"?o.light=`color-mix(in ${t}, ${o.main}, #fff ${(d*100).toFixed(0)}%)`:n==="dark"&&(o.dark=`color-mix(in ${t}, ${o.main}, #000 ${(l*100).toFixed(0)}%)`))}function Ac(t="light"){return t==="dark"?{main:Ir[200],light:Ir[50],dark:Ir[400]}:{main:Ir[700],light:Ir[400],dark:Ir[800]}}function _c(t="light"){return t==="dark"?{main:kr[200],light:kr[50],dark:kr[400]}:{main:kr[500],light:kr[300],dark:kr[700]}}function Mc(t="light"){return t==="dark"?{main:Tr[500],light:Tr[300],dark:Tr[700]}:{main:Tr[700],light:Tr[400],dark:Tr[800]}}function Rc(t="light"){return t==="dark"?{main:zr[400],light:zr[300],dark:zr[700]}:{main:zr[700],light:zr[500],dark:zr[900]}}function Wc(t="light"){return t==="dark"?{main:Br[400],light:Br[300],dark:Br[700]}:{main:Br[800],light:Br[500],dark:Br[900]}}function Pc(t="light"){return t==="dark"?{main:Jr[400],light:Jr[300],dark:Jr[700]}:{main:"#ed6c02",light:Jr[500],dark:Jr[900]}}function Nc(t){return`oklch(from ${t} var(--__l) 0 h / var(--__a))`}function hn(t){const{mode:o="light",contrastThreshold:n=3,tonalOffset:i=.2,colorSpace:s,...d}=t,l=t.primary||Ac(o),c=t.secondary||_c(o),u=t.error||Mc(o),h=t.info||Rc(o),m=t.success||Wc(o),b=t.warning||Pc(o);function x(C){if(s)return Nc(C);const S=Qn(C,nn.text.primary)>=n?nn.text.primary:Yi.text.primary;if(process.env.NODE_ENV!=="production"){const I=Qn(C,S);I<3&&console.error([`MUI: The contrast ratio of ${I}:1 for ${S} on ${C}`,"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(`
45
- `))}return S}const y=({color:C,name:S,mainShade:I=500,lightShade:f=300,darkShade:k=700})=>{if(C={...C},!C.main&&C[I]&&(C.main=C[I]),!C.hasOwnProperty("main"))throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${S?` (${S})`:""} provided to augmentColor(color) is invalid.
46
- The color object needs to have a \`main\` property or a \`${I}\` property.`:dr(11,S?` (${S})`:"",I));if(typeof C.main!="string")throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${S?` (${S})`:""} provided to augmentColor(color) is invalid.
47
- \`color.main\` should be a string, but \`${JSON.stringify(C.main)}\` was provided instead.
41
+ `)));const l=s[c];return d>=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.${o}\` value (${s}) is invalid.`,"It should be a number, an array or a function."].join(`
42
+ `)),()=>{})}function an(t){return Jr(t,"spacing",8,"spacing")}function Kr(t,o){return typeof o=="string"||o==null?o:t(o)}function Bl(t,o){return n=>t.reduce((i,s)=>(i[s]=Kr(o,n),i),{})}function Il(t,o,n,i){if(!o.includes(n))return null;const s=Tl(n),d=Bl(s,i),c=t[n];return Tt(t,c,d)}function Pi(t,o){const n=an(t.theme);return Object.keys(t).map(i=>Il(t,o,i,n)).reduce(Gr,{})}function Ie(t){return Pi(t,ko)}Ie.propTypes=process.env.NODE_ENV!=="production"?ko.reduce((t,o)=>(t[o]=Ft,t),{}):{};Ie.filterProps=ko;function De(t){return Pi(t,To)}De.propTypes=process.env.NODE_ENV!=="production"?To.reduce((t,o)=>(t[o]=Ft,t),{}):{};De.filterProps=To;process.env.NODE_ENV!=="production"&&zl.reduce((t,o)=>(t[o]=Ft,t),{});function Ni(t=8,o=an({spacing:t})){if(t.mui)return t;const n=(...i)=>(process.env.NODE_ENV!=="production"&&(i.length<=4||console.error(`MUI: Too many arguments provided, expected between 0 and 4, got ${i.length}`)),(i.length===0?[1]:i).map(d=>{const c=o(d);return typeof c=="number"?`${c}px`:c}).join(" "));return n.mui=!0,n}function zo(...t){const o=t.reduce((i,s)=>(s.filterProps.forEach(d=>{i[d]=s}),i),{}),n=i=>Object.keys(i).reduce((s,d)=>o[d]?Gr(s,o[d](i)):s,{});return n.propTypes=process.env.NODE_ENV!=="production"?t.reduce((i,s)=>Object.assign(i,s.propTypes),{}):{},n.filterProps=t.reduce((i,s)=>i.concat(s.filterProps),[]),n}function rt(t){return typeof t!="number"?t:`${t}px solid`}function ot(t,o){return Ee({prop:t,themeKey:"borders",transform:o})}const Dl=ot("border",rt),El=ot("borderTop",rt),Ol=ot("borderRight",rt),Al=ot("borderBottom",rt),$l=ot("borderLeft",rt),Ml=ot("borderColor"),Rl=ot("borderTopColor"),_l=ot("borderRightColor"),Wl=ot("borderBottomColor"),Pl=ot("borderLeftColor"),Nl=ot("outline",rt),Ll=ot("outlineColor"),Bo=t=>{if(t.borderRadius!==void 0&&t.borderRadius!==null){const o=Jr(t.theme,"shape.borderRadius",4,"borderRadius"),n=i=>({borderRadius:Kr(o,i)});return Tt(t,t.borderRadius,n)}return null};Bo.propTypes=process.env.NODE_ENV!=="production"?{borderRadius:Ft}:{};Bo.filterProps=["borderRadius"];zo(Dl,El,Ol,Al,$l,Ml,Rl,_l,Wl,Pl,Bo,Nl,Ll);const Io=t=>{if(t.gap!==void 0&&t.gap!==null){const o=Jr(t.theme,"spacing",8,"gap"),n=i=>({gap:Kr(o,i)});return Tt(t,t.gap,n)}return null};Io.propTypes=process.env.NODE_ENV!=="production"?{gap:Ft}:{};Io.filterProps=["gap"];const Do=t=>{if(t.columnGap!==void 0&&t.columnGap!==null){const o=Jr(t.theme,"spacing",8,"columnGap"),n=i=>({columnGap:Kr(o,i)});return Tt(t,t.columnGap,n)}return null};Do.propTypes=process.env.NODE_ENV!=="production"?{columnGap:Ft}:{};Do.filterProps=["columnGap"];const Eo=t=>{if(t.rowGap!==void 0&&t.rowGap!==null){const o=Jr(t.theme,"spacing",8,"rowGap"),n=i=>({rowGap:Kr(o,i)});return Tt(t,t.rowGap,n)}return null};Eo.propTypes=process.env.NODE_ENV!=="production"?{rowGap:Ft}:{};Eo.filterProps=["rowGap"];const Fl=Ee({prop:"gridColumn"}),Vl=Ee({prop:"gridRow"}),Hl=Ee({prop:"gridAutoFlow"}),Ul=Ee({prop:"gridAutoColumns"}),Yl=Ee({prop:"gridAutoRows"}),Gl=Ee({prop:"gridTemplateColumns"}),ql=Ee({prop:"gridTemplateRows"}),Jl=Ee({prop:"gridTemplateAreas"}),Kl=Ee({prop:"gridArea"});zo(Io,Do,Eo,Fl,Vl,Hl,Ul,Yl,Gl,ql,Jl,Kl);function Br(t,o){return o==="grey"?o:t}const Xl=Ee({prop:"color",themeKey:"palette",transform:Br}),Ql=Ee({prop:"bgcolor",cssProperty:"backgroundColor",themeKey:"palette",transform:Br}),Zl=Ee({prop:"backgroundColor",themeKey:"palette",transform:Br});zo(Xl,Ql,Zl);function Je(t){return t<=1&&t!==0?`${t*100}%`:t}const ec=Ee({prop:"width",transform:Je}),ln=t=>{if(t.maxWidth!==void 0&&t.maxWidth!==null){const o=n=>{var s,d,c,l,u;const i=((c=(d=(s=t.theme)==null?void 0:s.breakpoints)==null?void 0:d.values)==null?void 0:c[n])||Co[n];return i?((u=(l=t.theme)==null?void 0:l.breakpoints)==null?void 0:u.unit)!=="px"?{maxWidth:`${i}${t.theme.breakpoints.unit}`}:{maxWidth:i}:{maxWidth:Je(n)}};return Tt(t,t.maxWidth,o)}return null};ln.filterProps=["maxWidth"];const tc=Ee({prop:"minWidth",transform:Je}),rc=Ee({prop:"height",transform:Je}),oc=Ee({prop:"maxHeight",transform:Je}),nc=Ee({prop:"minHeight",transform:Je});Ee({prop:"size",cssProperty:"width",transform:Je});Ee({prop:"size",cssProperty:"height",transform:Je});const ic=Ee({prop:"boxSizing"});zo(ec,ln,tc,rc,oc,nc,ic);const Oo={border:{themeKey:"borders",transform:rt},borderTop:{themeKey:"borders",transform:rt},borderRight:{themeKey:"borders",transform:rt},borderBottom:{themeKey:"borders",transform:rt},borderLeft:{themeKey:"borders",transform:rt},borderColor:{themeKey:"palette"},borderTopColor:{themeKey:"palette"},borderRightColor:{themeKey:"palette"},borderBottomColor:{themeKey:"palette"},borderLeftColor:{themeKey:"palette"},outline:{themeKey:"borders",transform:rt},outlineColor:{themeKey:"palette"},borderRadius:{themeKey:"shape.borderRadius",style:Bo},color:{themeKey:"palette",transform:Br},bgcolor:{themeKey:"palette",cssProperty:"backgroundColor",transform:Br},backgroundColor:{themeKey:"palette",transform:Br},p:{style:De},pt:{style:De},pr:{style:De},pb:{style:De},pl:{style:De},px:{style:De},py:{style:De},padding:{style:De},paddingTop:{style:De},paddingRight:{style:De},paddingBottom:{style:De},paddingLeft:{style:De},paddingX:{style:De},paddingY:{style:De},paddingInline:{style:De},paddingInlineStart:{style:De},paddingInlineEnd:{style:De},paddingBlock:{style:De},paddingBlockStart:{style:De},paddingBlockEnd:{style:De},m:{style:Ie},mt:{style:Ie},mr:{style:Ie},mb:{style:Ie},ml:{style:Ie},mx:{style:Ie},my:{style:Ie},margin:{style:Ie},marginTop:{style:Ie},marginRight:{style:Ie},marginBottom:{style:Ie},marginLeft:{style:Ie},marginX:{style:Ie},marginY:{style:Ie},marginInline:{style:Ie},marginInlineStart:{style:Ie},marginInlineEnd:{style:Ie},marginBlock:{style:Ie},marginBlockStart:{style:Ie},marginBlockEnd:{style:Ie},displayPrint:{cssProperty:!1,transform:t=>({"@media print":{display:t}})},display:{},overflow:{},textOverflow:{},visibility:{},whiteSpace:{},flexBasis:{},flexDirection:{},flexWrap:{},justifyContent:{},alignItems:{},alignContent:{},order:{},flex:{},flexGrow:{},flexShrink:{},alignSelf:{},justifyItems:{},justifySelf:{},gap:{style:Io},rowGap:{style:Eo},columnGap:{style:Do},gridColumn:{},gridRow:{},gridAutoFlow:{},gridAutoColumns:{},gridAutoRows:{},gridTemplateColumns:{},gridTemplateRows:{},gridTemplateAreas:{},gridArea:{},position:{},zIndex:{themeKey:"zIndex"},top:{},right:{},bottom:{},left:{},boxShadow:{themeKey:"shadows"},width:{transform:Je},maxWidth:{style:ln},minWidth:{transform:Je},height:{transform:Je},maxHeight:{transform:Je},minHeight:{transform:Je},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 sc(...t){const o=t.reduce((i,s)=>i.concat(Object.keys(s)),[]),n=new Set(o);return t.every(i=>n.size===Object.keys(i).length)}function ac(t,o){return typeof t=="function"?t(o):t}function lc(){function t(n,i,s,d){const c={[n]:i,theme:s},l=d[n];if(!l)return{[n]:i};const{cssProperty:u=n,themeKey:f,transform:m,style:h}=l;if(i==null)return null;if(f==="typography"&&i==="inherit")return{[n]:i};const x=wo(s,f)||{};return h?h(c):Tt(c,i,D=>{let g=yo(x,m,D);return D===g&&typeof D=="string"&&(g=yo(x,m,`${n}${D==="default"?"":Wi(D)}`,D)),u===!1?g:{[u]:g}})}function o(n){const{sx:i,theme:s={},nested:d}=n||{};if(!i)return null;const c=s.unstable_sxConfig??Oo;function l(u){let f=u;if(typeof u=="function")f=u(s);else if(typeof u!="object")return u;if(!f)return null;const m=jl(s.breakpoints),h=Object.keys(m);let x=m;return Object.keys(f).forEach(b=>{const D=ac(f[b],s);if(D!=null)if(typeof D=="object")if(c[b])x=Gr(x,t(b,D,s,c));else{const g=Tt({theme:s},D,j=>({[b]:j}));sc(g,D)?x[b]=o({sx:D,theme:s,nested:!0}):x=Gr(x,g)}else x=Gr(x,t(b,D,s,c))}),!d&&s.modularCssLayers?{"@layer sx":Hn(s,Yn(h,x))}:Hn(s,Yn(h,x))}return Array.isArray(i)?i.map(l):l(i)}return o}const Ao=lc();Ao.filterProps=["sx"];function cc(t,o){var i;const n=this;if(n.vars){if(!((i=n.colorSchemes)!=null&&i[t])||typeof n.getColorSchemeSelector!="function")return{};let s=n.getColorSchemeSelector(t);return s==="&"?o:((s.includes("data-")||s.includes("."))&&(s=`*:where(${s.replace(/\s*&$/,"")}) &`),{[s]:o})}return n.palette.mode===t?o:{}}function Li(t={},...o){const{breakpoints:n={},palette:i={},spacing:s,shape:d={},...c}=t,l=fl(n),u=Ni(s);let f=Xe({breakpoints:l,direction:"ltr",components:{},palette:{mode:"light",...i},spacing:u,shape:{...vl,...d}},c);return f=bl(f),f.applyStyles=cc,f=o.reduce((m,h)=>Xe(m,h),f),f.unstable_sxConfig={...Oo,...c==null?void 0:c.unstable_sxConfig},f.unstable_sx=function(h){return Ao({sx:h,theme:this})},f}function dc(t){return Object.keys(t).length===0}function uc(t=null){const o=vo.useContext(Es.ThemeContext);return!o||dc(o)?t:o}const pc=Li();function xc(t=pc){return uc(t)}const qn=t=>t,mc=()=>{let t=qn;return{configure(o){t=o},generate(o){return t(o)},reset(){t=qn}}},hc=mc(),fc={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 gc(t,o,n="Mui"){const i=fc[o];return i?`${n}-${i}`:`${hc.generate(t)}-${o}`}function yc(t,o=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(o,Math.min(t,n))}function cn(t,o=0,n=1){return process.env.NODE_ENV!=="production"&&(t<o||t>n)&&console.error(`MUI: The value provided ${t} is out of range [${o}, ${n}].`),yc(t,o,n)}function bc(t){t=t.slice(1);const o=new RegExp(`.{1,${t.length>=6?2:1}}`,"g");let n=t.match(o);return n&&n[0].length===1&&(n=n.map(i=>i+i)),process.env.NODE_ENV!=="production"&&t.length!==t.trim().length&&console.error(`MUI: The color: "${t}" is invalid. Make sure the color input doesn't contain leading/trailing space.`),n?`rgb${n.length===4?"a":""}(${n.map((i,s)=>s<3?parseInt(i,16):Math.round(parseInt(i,16)/255*1e3)/1e3).join(", ")})`:""}function Lt(t){if(t.type)return t;if(t.charAt(0)==="#")return Lt(bc(t));const o=t.indexOf("("),n=t.substring(0,o);if(!["rgb","rgba","hsl","hsla","color"].includes(n))throw new Error(process.env.NODE_ENV!=="production"?`MUI: Unsupported \`${t}\` color.
43
+ The following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().`:or(9,t));let i=t.substring(o+1,t.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.
44
+ The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rgb, rec-2020.`:or(10,s))}else i=i.split(",");return i=i.map(d=>parseFloat(d)),{type:n,values:i,colorSpace:s}}const vc=t=>{const o=Lt(t);return o.values.slice(0,3).map((n,i)=>o.type.includes("hsl")&&i!==0?`${n}%`:n).join(" ")},Hr=(t,o)=>{try{return vc(t)}catch{return o&&process.env.NODE_ENV!=="production"&&console.warn(o),t}};function $o(t){const{type:o,colorSpace:n}=t;let{values:i}=t;return o.includes("rgb")?i=i.map((s,d)=>d<3?parseInt(s,10):s):o.includes("hsl")&&(i[1]=`${i[1]}%`,i[2]=`${i[2]}%`),o.includes("color")?i=`${n} ${i.join(" ")}`:i=`${i.join(", ")}`,`${o}(${i})`}function Fi(t){t=Lt(t);const{values:o}=t,n=o[0],i=o[1]/100,s=o[2]/100,d=i*Math.min(s,1-s),c=(f,m=(f+n/30)%12)=>s-d*Math.max(Math.min(m-3,9-m,1),-1);let l="rgb";const u=[Math.round(c(0)*255),Math.round(c(8)*255),Math.round(c(4)*255)];return t.type==="hsla"&&(l+="a",u.push(o[3])),$o({type:l,values:u})}function Qo(t){t=Lt(t);let o=t.type==="hsl"||t.type==="hsla"?Lt(Fi(t)).values:t.values;return o=o.map(n=>(t.type!=="color"&&(n/=255),n<=.03928?n/12.92:((n+.055)/1.055)**2.4)),Number((.2126*o[0]+.7152*o[1]+.0722*o[2]).toFixed(3))}function Jn(t,o){const n=Qo(t),i=Qo(o);return(Math.max(n,i)+.05)/(Math.min(n,i)+.05)}function k(t,o){return t=Lt(t),o=cn(o),(t.type==="rgb"||t.type==="hsl")&&(t.type+="a"),t.type==="color"?t.values[3]=`/${o}`:t.values[3]=o,$o(t)}function er(t,o,n){try{return k(t,o)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),t}}function Mo(t,o){if(t=Lt(t),o=cn(o),t.type.includes("hsl"))t.values[2]*=1-o;else if(t.type.includes("rgb")||t.type.includes("color"))for(let n=0;n<3;n+=1)t.values[n]*=1-o;return $o(t)}function ve(t,o,n){try{return Mo(t,o)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),t}}function Ro(t,o){if(t=Lt(t),o=cn(o),t.type.includes("hsl"))t.values[2]+=(100-t.values[2])*o;else if(t.type.includes("rgb"))for(let n=0;n<3;n+=1)t.values[n]+=(255-t.values[n])*o;else if(t.type.includes("color"))for(let n=0;n<3;n+=1)t.values[n]+=(1-t.values[n])*o;return $o(t)}function Se(t,o,n){try{return Ro(t,o)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),t}}function Sc(t,o=.15){return Qo(t)>.5?Mo(t,o):Ro(t,o)}function ao(t,o,n){try{return Sc(t,o)}catch{return t}}function jc(t=""){function o(...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(--${t?`${t}-`:""}${s}${o(...i.slice(1))})`:`, ${s}`}return(i,...s)=>`var(--${t?`${t}-`:""}${i}${o(...s)})`}const Kn=(t,o,n,i=[])=>{let s=t;o.forEach((d,c)=>{c===o.length-1?Array.isArray(s)?s[Number(d)]=n:s&&typeof s=="object"&&(s[d]=n):s&&typeof s=="object"&&(s[d]||(s[d]=i.includes(d)?[]:{}),s=s[d])})},Cc=(t,o,n)=>{function i(s,d=[],c=[]){Object.entries(s).forEach(([l,u])=>{(!n||n&&!n([...d,l]))&&u!=null&&(typeof u=="object"&&Object.keys(u).length>0?i(u,[...d,l],Array.isArray(u)?[...c,l]:c):o([...d,l],u,c))})}i(t)},wc=(t,o)=>typeof o=="number"?["lineHeight","fontWeight","opacity","zIndex"].some(i=>t.includes(i))||t[t.length-1].toLowerCase().includes("opacity")?o:`${o}px`:o;function qo(t,o){const{prefix:n,shouldSkipGeneratingVar:i}=o||{},s={},d={},c={};return Cc(t,(l,u,f)=>{if((typeof u=="string"||typeof u=="number")&&(!i||!i(l,u))){const m=`--${n?`${n}-`:""}${l.join("-")}`,h=wc(l,u);Object.assign(s,{[m]:h}),Kn(d,l,`var(${m})`,f),Kn(c,l,`var(${m}, ${h})`,f)}},l=>l[0]==="vars"),{css:s,vars:d,varsWithDefaults:c}}function kc(t,o={}){const{getSelector:n=w,disableCssColorScheme:i,colorSchemeSelector:s,enableContrastVars:d}=o,{colorSchemes:c={},components:l,defaultColorScheme:u="light",...f}=t,{vars:m,css:h,varsWithDefaults:x}=qo(f,o);let b=x;const D={},{[u]:g,...j}=c;if(Object.entries(j||{}).forEach(([S,C])=>{const{vars:a,css:z,varsWithDefaults:R}=qo(C,o);b=Xe(b,R),D[S]={css:z,vars:a}}),g){const{css:S,vars:C,varsWithDefaults:a}=qo(g,o);b=Xe(b,a),D[u]={css:S,vars:C}}function w(S,C){var z,R;let a=s;if(s==="class"&&(a=".%s"),s==="data"&&(a="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(a=`[${s}="%s"]`),S){if(a==="media")return t.defaultColorScheme===S?":root":{[`@media (prefers-color-scheme: ${((R=(z=c[S])==null?void 0:z.palette)==null?void 0:R.mode)||S})`]:{":root":C}};if(a)return t.defaultColorScheme===S?`:root, ${a.replace("%s",String(S))}`:a.replace("%s",String(S))}return":root"}return{vars:b,generateThemeVars:()=>{let S={...m};return Object.entries(D).forEach(([,{vars:C}])=>{S=Xe(S,C)}),S},generateStyleSheets:()=>{var q,K;const S=[],C=t.defaultColorScheme||"light";function a(ee,y){Object.keys(y).length&&S.push(typeof ee=="string"?{[ee]:{...y}}:ee)}a(n(void 0,{...h}),h);const{[C]:z,...R}=D;if(z){const{css:ee}=z,y=(K=(q=c[C])==null?void 0:q.palette)==null?void 0:K.mode,M=!i&&y?{colorScheme:y,...ee}:{...ee};a(n(C,{...M}),M)}return Object.entries(R).forEach(([ee,{css:y}])=>{var V,Q;const M=(Q=(V=c[ee])==null?void 0:V.palette)==null?void 0:Q.mode,W=!i&&M?{colorScheme:M,...y}:{...y};a(n(ee,{...W}),W)}),d&&S.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)"}}),S}}}function Tc(t){return function(n){return t==="media"?(process.env.NODE_ENV!=="production"&&n!=="light"&&n!=="dark"&&console.error(`MUI: @media (prefers-color-scheme) supports only 'light' or 'dark', but receive '${n}'.`),`@media (prefers-color-scheme: ${n})`):t?t.startsWith("data-")&&!t.includes("%s")?`[${t}="${n}"] &`:t==="class"?`.${n} &`:t==="data"?`[data-${n}] &`:`${t.replace("%s",n)} &`:"&"}}const qr={black:"#000",white:"#fff"},zc={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"},Cr={50:"#f3e5f5",200:"#ce93d8",300:"#ba68c8",400:"#ab47bc",500:"#9c27b0",700:"#7b1fa2"},wr={300:"#e57373",400:"#ef5350",500:"#f44336",700:"#d32f2f",800:"#c62828"},Nr={300:"#ffb74d",400:"#ffa726",500:"#ff9800",700:"#f57c00",900:"#e65100"},kr={50:"#e3f2fd",200:"#90caf9",400:"#42a5f5",700:"#1976d2",800:"#1565c0"},Tr={300:"#4fc3f7",400:"#29b6f6",500:"#03a9f4",700:"#0288d1",900:"#01579b"},zr={300:"#81c784",400:"#66bb6a",500:"#4caf50",700:"#388e3c",800:"#2e7d32",900:"#1b5e20"};function Vi(){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:qr.white,default:qr.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 Hi=Vi();function Ui(){return{text:{primary:qr.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:qr.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 Zo=Ui();function Xn(t,o,n,i){const s=i.light||i,d=i.dark||i*1.5;t[o]||(t.hasOwnProperty(n)?t[o]=t[n]:o==="light"?t.light=Ro(t.main,s):o==="dark"&&(t.dark=Mo(t.main,d)))}function Qn(t,o,n,i,s){const d=s.light||s,c=s.dark||s*1.5;o[n]||(o.hasOwnProperty(i)?o[n]=o[i]:n==="light"?o.light=`color-mix(in ${t}, ${o.main}, #fff ${(d*100).toFixed(0)}%)`:n==="dark"&&(o.dark=`color-mix(in ${t}, ${o.main}, #000 ${(c*100).toFixed(0)}%)`))}function Bc(t="light"){return t==="dark"?{main:kr[200],light:kr[50],dark:kr[400]}:{main:kr[700],light:kr[400],dark:kr[800]}}function Ic(t="light"){return t==="dark"?{main:Cr[200],light:Cr[50],dark:Cr[400]}:{main:Cr[500],light:Cr[300],dark:Cr[700]}}function Dc(t="light"){return t==="dark"?{main:wr[500],light:wr[300],dark:wr[700]}:{main:wr[700],light:wr[400],dark:wr[800]}}function Ec(t="light"){return t==="dark"?{main:Tr[400],light:Tr[300],dark:Tr[700]}:{main:Tr[700],light:Tr[500],dark:Tr[900]}}function Oc(t="light"){return t==="dark"?{main:zr[400],light:zr[300],dark:zr[700]}:{main:zr[800],light:zr[500],dark:zr[900]}}function Ac(t="light"){return t==="dark"?{main:Nr[400],light:Nr[300],dark:Nr[700]}:{main:"#ed6c02",light:Nr[500],dark:Nr[900]}}function $c(t){return`oklch(from ${t} var(--__l) 0 h / var(--__a))`}function dn(t){const{mode:o="light",contrastThreshold:n=3,tonalOffset:i=.2,colorSpace:s,...d}=t,c=t.primary||Bc(o),l=t.secondary||Ic(o),u=t.error||Dc(o),f=t.info||Ec(o),m=t.success||Oc(o),h=t.warning||Ac(o);function x(j){if(s)return $c(j);const w=Jn(j,Zo.text.primary)>=n?Zo.text.primary:Hi.text.primary;if(process.env.NODE_ENV!=="production"){const I=Jn(j,w);I<3&&console.error([`MUI: The contrast ratio of ${I}:1 for ${w} on ${j}`,"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(`
45
+ `))}return w}const b=({color:j,name:w,mainShade:I=500,lightShade:v=300,darkShade:S=700})=>{if(j={...j},!j.main&&j[I]&&(j.main=j[I]),!j.hasOwnProperty("main"))throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${w?` (${w})`:""} provided to augmentColor(color) is invalid.
46
+ The color object needs to have a \`main\` property or a \`${I}\` property.`:or(11,w?` (${w})`:"",I));if(typeof j.main!="string")throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${w?` (${w})`:""} provided to augmentColor(color) is invalid.
47
+ \`color.main\` should be a string, but \`${JSON.stringify(j.main)}\` was provided instead.
48
48
 
49
49
  Did you intend to use one of the following approaches?
50
50
 
@@ -56,17 +56,17 @@ const theme1 = createTheme({ palette: {
56
56
 
57
57
  const theme2 = createTheme({ palette: {
58
58
  primary: { main: green[500] },
59
- } });`:dr(12,S?` (${S})`:"",JSON.stringify(C.main)));return s?(ti(s,C,"light",f,i),ti(s,C,"dark",k,i)):(ei(C,"light",f,i),ei(C,"dark",k,i)),C.contrastText||(C.contrastText=x(C.main)),C};let D;return o==="light"?D=Ui():o==="dark"&&(D=Gi()),process.env.NODE_ENV!=="production"&&(D||console.error(`MUI: The palette mode \`${o}\` is not supported.`)),Ze({common:{...oo},mode:o,primary:y({color:l,name:"primary"}),secondary:y({color:c,name:"secondary",mainShade:"A400",lightShade:"A200",darkShade:"A700"}),error:y({color:u,name:"error"}),warning:y({color:b,name:"warning"}),info:y({color:h,name:"info"}),success:y({color:m,name:"success"}),grey:$c,contrastThreshold:n,getContrastText:x,augmentColor:y,tonalOffset:i,...D},d)}function Lc(t){const o={};return Object.entries(t).forEach(i=>{const[s,d]=i;typeof d=="object"&&(o[s]=`${d.fontStyle?`${d.fontStyle} `:""}${d.fontVariant?`${d.fontVariant} `:""}${d.fontWeight?`${d.fontWeight} `:""}${d.fontStretch?`${d.fontStretch} `:""}${d.fontSize||""}${d.lineHeight?`/${d.lineHeight} `:""}${d.fontFamily||""}`)}),o}function Fc(t,o){return{toolbar:{minHeight:56,[t.up("xs")]:{"@media (orientation: landscape)":{minHeight:48}},[t.up("sm")]:{minHeight:64}},...o}}function Vc(t){return Math.round(t*1e5)/1e5}const ri={textTransform:"uppercase"},oi='"Roboto", "Helvetica", "Arial", sans-serif';function Hc(t,o){const{fontFamily:n=oi,fontSize:i=14,fontWeightLight:s=300,fontWeightRegular:d=400,fontWeightMedium:l=500,fontWeightBold:c=700,htmlFontSize:u=16,allVariants:h,pxToRem:m,...b}=typeof o=="function"?o(t):o;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 x=i/14,y=m||(C=>`${C/u*x}rem`),D=(C,S,I,f,k)=>({fontFamily:n,fontWeight:C,fontSize:y(S),lineHeight:I,...n===oi?{letterSpacing:`${Vc(f/S)}em`}:{},...k,...h}),v={h1:D(s,96,1.167,-1.5),h2:D(s,60,1.2,-.5),h3:D(d,48,1.167,0),h4:D(d,34,1.235,.25),h5:D(d,24,1.334,0),h6:D(l,20,1.6,.15),subtitle1:D(d,16,1.75,.15),subtitle2:D(l,14,1.57,.1),body1:D(d,16,1.5,.15),body2:D(d,14,1.43,.15),button:D(l,14,1.75,.4,ri),caption:D(d,12,1.66,.4),overline:D(d,12,2.66,1,ri),inherit:{fontFamily:"inherit",fontWeight:"inherit",fontSize:"inherit",lineHeight:"inherit",letterSpacing:"inherit"}};return Ze({htmlFontSize:u,pxToRem:y,fontFamily:n,fontSize:i,fontWeightLight:s,fontWeightRegular:d,fontWeightMedium:l,fontWeightBold:c,...v},b,{clone:!1})}const Uc=.2,Yc=.14,Gc=.12;function Be(...t){return[`${t[0]}px ${t[1]}px ${t[2]}px ${t[3]}px rgba(0,0,0,${Uc})`,`${t[4]}px ${t[5]}px ${t[6]}px ${t[7]}px rgba(0,0,0,${Yc})`,`${t[8]}px ${t[9]}px ${t[10]}px ${t[11]}px rgba(0,0,0,${Gc})`].join(",")}const qc=["none",Be(0,2,1,-1,0,1,1,0,0,1,3,0),Be(0,3,1,-2,0,2,2,0,0,1,5,0),Be(0,3,3,-2,0,3,4,0,0,1,8,0),Be(0,2,4,-1,0,4,5,0,0,1,10,0),Be(0,3,5,-1,0,5,8,0,0,1,14,0),Be(0,3,5,-1,0,6,10,0,0,1,18,0),Be(0,4,5,-2,0,7,10,1,0,2,16,1),Be(0,5,5,-3,0,8,10,1,0,3,14,2),Be(0,5,6,-3,0,9,12,1,0,3,16,2),Be(0,6,6,-3,0,10,14,1,0,4,18,3),Be(0,6,7,-4,0,11,15,1,0,4,20,3),Be(0,7,8,-4,0,12,17,2,0,5,22,4),Be(0,7,8,-4,0,13,19,2,0,5,24,4),Be(0,7,9,-4,0,14,21,2,0,5,26,4),Be(0,8,9,-5,0,15,22,2,0,6,28,5),Be(0,8,10,-5,0,16,24,2,0,6,30,5),Be(0,8,11,-5,0,17,26,2,0,6,32,5),Be(0,9,11,-5,0,18,28,2,0,7,34,6),Be(0,9,12,-6,0,19,29,2,0,7,36,6),Be(0,10,13,-6,0,20,31,3,0,8,38,7),Be(0,10,13,-6,0,21,33,3,0,8,40,7),Be(0,10,14,-6,0,22,35,3,0,8,42,7),Be(0,11,14,-7,0,23,36,3,0,9,44,8),Be(0,11,15,-7,0,24,38,3,0,9,46,8)],Jc={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)"},Kc={shortest:150,shorter:200,short:250,standard:300,complex:375,enteringScreen:225,leavingScreen:195};function ni(t){return`${Math.round(t)}ms`}function Xc(t){if(!t)return 0;const o=t/36;return Math.min(Math.round((4+15*o**.25+o/5)*10),3e3)}function Qc(t){const o={...Jc,...t.easing},n={...Kc,...t.duration};return{getAutoHeightDuration:Xc,create:(s=["all"],d={})=>{const{duration:l=n.standard,easing:c=o.easeInOut,delay:u=0,...h}=d;if(process.env.NODE_ENV!=="production"){const m=x=>typeof x=="string",b=x=>!Number.isNaN(parseFloat(x));!m(s)&&!Array.isArray(s)&&console.error('MUI: Argument "props" must be a string or Array.'),!b(l)&&!m(l)&&console.error(`MUI: Argument "duration" must be a number or a string but found ${l}.`),m(c)||console.error('MUI: Argument "easing" must be a string.'),!b(u)&&!m(u)&&console.error('MUI: Argument "delay" must be a number or a string.'),typeof d!="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(`
60
- `)),Object.keys(h).length!==0&&console.error(`MUI: Unrecognized argument(s) [${Object.keys(h).join(",")}].`)}return(Array.isArray(s)?s:[s]).map(m=>`${m} ${typeof l=="string"?l:ni(l)} ${c} ${typeof u=="string"?u:ni(u)}`).join(",")},...t,easing:o,duration:n}}const Zc={mobileStepper:1e3,fab:1050,speedDial:1050,appBar:1100,drawer:1200,modal:1300,snackbar:1400,tooltip:1500};function ed(t){return Ut(t)||typeof t>"u"||typeof t=="string"||typeof t=="boolean"||typeof t=="number"||Array.isArray(t)}function qi(t={}){const o={...t};function n(i){const s=Object.entries(i);for(let d=0;d<s.length;d++){const[l,c]=s[d];!ed(c)||l.startsWith("unstable_")?delete i[l]:Ut(c)&&(i[l]={...c},n(i[l]))}}return n(o),`import { unstable_createBreakpoints as createBreakpoints, createTransitions } from '@mui/material/styles';
59
+ } });`:or(12,w?` (${w})`:"",JSON.stringify(j.main)));return s?(Qn(s,j,"light",v,i),Qn(s,j,"dark",S,i)):(Xn(j,"light",v,i),Xn(j,"dark",S,i)),j.contrastText||(j.contrastText=x(j.main)),j};let D;return o==="light"?D=Vi():o==="dark"&&(D=Ui()),process.env.NODE_ENV!=="production"&&(D||console.error(`MUI: The palette mode \`${o}\` is not supported.`)),Xe({common:{...qr},mode:o,primary:b({color:c,name:"primary"}),secondary:b({color:l,name:"secondary",mainShade:"A400",lightShade:"A200",darkShade:"A700"}),error:b({color:u,name:"error"}),warning:b({color:h,name:"warning"}),info:b({color:f,name:"info"}),success:b({color:m,name:"success"}),grey:zc,contrastThreshold:n,getContrastText:x,augmentColor:b,tonalOffset:i,...D},d)}function Mc(t){const o={};return Object.entries(t).forEach(i=>{const[s,d]=i;typeof d=="object"&&(o[s]=`${d.fontStyle?`${d.fontStyle} `:""}${d.fontVariant?`${d.fontVariant} `:""}${d.fontWeight?`${d.fontWeight} `:""}${d.fontStretch?`${d.fontStretch} `:""}${d.fontSize||""}${d.lineHeight?`/${d.lineHeight} `:""}${d.fontFamily||""}`)}),o}function Rc(t,o){return{toolbar:{minHeight:56,[t.up("xs")]:{"@media (orientation: landscape)":{minHeight:48}},[t.up("sm")]:{minHeight:64}},...o}}function _c(t){return Math.round(t*1e5)/1e5}const Zn={textTransform:"uppercase"},ei='"Roboto", "Helvetica", "Arial", sans-serif';function Wc(t,o){const{fontFamily:n=ei,fontSize:i=14,fontWeightLight:s=300,fontWeightRegular:d=400,fontWeightMedium:c=500,fontWeightBold:l=700,htmlFontSize:u=16,allVariants:f,pxToRem:m,...h}=typeof o=="function"?o(t):o;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 x=i/14,b=m||(j=>`${j/u*x}rem`),D=(j,w,I,v,S)=>({fontFamily:n,fontWeight:j,fontSize:b(w),lineHeight:I,...n===ei?{letterSpacing:`${_c(v/w)}em`}:{},...S,...f}),g={h1:D(s,96,1.167,-1.5),h2:D(s,60,1.2,-.5),h3:D(d,48,1.167,0),h4:D(d,34,1.235,.25),h5:D(d,24,1.334,0),h6:D(c,20,1.6,.15),subtitle1:D(d,16,1.75,.15),subtitle2:D(c,14,1.57,.1),body1:D(d,16,1.5,.15),body2:D(d,14,1.43,.15),button:D(c,14,1.75,.4,Zn),caption:D(d,12,1.66,.4),overline:D(d,12,2.66,1,Zn),inherit:{fontFamily:"inherit",fontWeight:"inherit",fontSize:"inherit",lineHeight:"inherit",letterSpacing:"inherit"}};return Xe({htmlFontSize:u,pxToRem:b,fontFamily:n,fontSize:i,fontWeightLight:s,fontWeightRegular:d,fontWeightMedium:c,fontWeightBold:l,...g},h,{clone:!1})}const Pc=.2,Nc=.14,Lc=.12;function Be(...t){return[`${t[0]}px ${t[1]}px ${t[2]}px ${t[3]}px rgba(0,0,0,${Pc})`,`${t[4]}px ${t[5]}px ${t[6]}px ${t[7]}px rgba(0,0,0,${Nc})`,`${t[8]}px ${t[9]}px ${t[10]}px ${t[11]}px rgba(0,0,0,${Lc})`].join(",")}const Fc=["none",Be(0,2,1,-1,0,1,1,0,0,1,3,0),Be(0,3,1,-2,0,2,2,0,0,1,5,0),Be(0,3,3,-2,0,3,4,0,0,1,8,0),Be(0,2,4,-1,0,4,5,0,0,1,10,0),Be(0,3,5,-1,0,5,8,0,0,1,14,0),Be(0,3,5,-1,0,6,10,0,0,1,18,0),Be(0,4,5,-2,0,7,10,1,0,2,16,1),Be(0,5,5,-3,0,8,10,1,0,3,14,2),Be(0,5,6,-3,0,9,12,1,0,3,16,2),Be(0,6,6,-3,0,10,14,1,0,4,18,3),Be(0,6,7,-4,0,11,15,1,0,4,20,3),Be(0,7,8,-4,0,12,17,2,0,5,22,4),Be(0,7,8,-4,0,13,19,2,0,5,24,4),Be(0,7,9,-4,0,14,21,2,0,5,26,4),Be(0,8,9,-5,0,15,22,2,0,6,28,5),Be(0,8,10,-5,0,16,24,2,0,6,30,5),Be(0,8,11,-5,0,17,26,2,0,6,32,5),Be(0,9,11,-5,0,18,28,2,0,7,34,6),Be(0,9,12,-6,0,19,29,2,0,7,36,6),Be(0,10,13,-6,0,20,31,3,0,8,38,7),Be(0,10,13,-6,0,21,33,3,0,8,40,7),Be(0,10,14,-6,0,22,35,3,0,8,42,7),Be(0,11,14,-7,0,23,36,3,0,9,44,8),Be(0,11,15,-7,0,24,38,3,0,9,46,8)],Vc={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)"},Hc={shortest:150,shorter:200,short:250,standard:300,complex:375,enteringScreen:225,leavingScreen:195};function ti(t){return`${Math.round(t)}ms`}function Uc(t){if(!t)return 0;const o=t/36;return Math.min(Math.round((4+15*o**.25+o/5)*10),3e3)}function Yc(t){const o={...Vc,...t.easing},n={...Hc,...t.duration};return{getAutoHeightDuration:Uc,create:(s=["all"],d={})=>{const{duration:c=n.standard,easing:l=o.easeInOut,delay:u=0,...f}=d;if(process.env.NODE_ENV!=="production"){const m=x=>typeof x=="string",h=x=>!Number.isNaN(parseFloat(x));!m(s)&&!Array.isArray(s)&&console.error('MUI: Argument "props" must be a string or Array.'),!h(c)&&!m(c)&&console.error(`MUI: Argument "duration" must be a number or a string but found ${c}.`),m(l)||console.error('MUI: Argument "easing" must be a string.'),!h(u)&&!m(u)&&console.error('MUI: Argument "delay" must be a number or a string.'),typeof d!="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(`
60
+ `)),Object.keys(f).length!==0&&console.error(`MUI: Unrecognized argument(s) [${Object.keys(f).join(",")}].`)}return(Array.isArray(s)?s:[s]).map(m=>`${m} ${typeof c=="string"?c:ti(c)} ${l} ${typeof u=="string"?u:ti(u)}`).join(",")},...t,easing:o,duration:n}}const Gc={mobileStepper:1e3,fab:1050,speedDial:1050,appBar:1100,drawer:1200,modal:1300,snackbar:1400,tooltip:1500};function qc(t){return Nt(t)||typeof t>"u"||typeof t=="string"||typeof t=="boolean"||typeof t=="number"||Array.isArray(t)}function Yi(t={}){const o={...t};function n(i){const s=Object.entries(i);for(let d=0;d<s.length;d++){const[c,l]=s[d];!qc(l)||c.startsWith("unstable_")?delete i[c]:Nt(l)&&(i[c]={...l},n(i[c]))}}return n(o),`import { unstable_createBreakpoints as createBreakpoints, createTransitions } from '@mui/material/styles';
61
61
 
62
62
  const theme = ${JSON.stringify(o,null,2)};
63
63
 
64
64
  theme.breakpoints = createBreakpoints(theme.breakpoints || {});
65
65
  theme.transitions = createTransitions(theme.transitions || {});
66
66
 
67
- export default theme;`}function ii(t){return typeof t=="number"?`${(t*100).toFixed(0)}%`:`calc((${t}) * 100%)`}const td=t=>{if(!Number.isNaN(+t))return+t;const o=t.match(/\d*\.?\d+/g);if(!o)return 0;let n=0;for(let i=0;i<o.length;i+=1)n+=+o[i];return n};function rd(t){Object.assign(t,{alpha(o,n){const i=this||t;return i.colorSpace?`oklch(from ${o} l c h / ${typeof n=="string"?`calc(${n})`:n})`:i.vars?`rgba(${o.replace(/var\(--([^,\s)]+)(?:,[^)]+)?\)+/g,"var(--$1Channel)")} / ${typeof n=="string"?`calc(${n})`:n})`:T(o,td(n))},lighten(o,n){const i=this||t;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${o}, #fff ${ii(n)})`:Vo(o,n)},darken(o,n){const i=this||t;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${o}, #000 ${ii(n)})`:Fo(o,n)}})}function sn(t={},...o){const{breakpoints:n,mixins:i={},spacing:s,palette:d={},transitions:l={},typography:c={},shape:u,colorSpace:h,...m}=t;if(t.vars&&t.generateThemeVars===void 0)throw new Error(process.env.NODE_ENV!=="production"?"MUI: `vars` is a private field used for CSS variables support.\nPlease use another name or follow the [docs](https://mui.com/material-ui/customization/css-theme-variables/usage/) to enable the feature.":dr(20));const b=hn({...d,colorSpace:h}),x=Vi(t);let y=Ze(x,{mixins:Fc(x.breakpoints,i),palette:b,shadows:qc.slice(),typography:Hc(b,c),transitions:Qc(l),zIndex:{...Zc}});if(y=Ze(y,m),y=o.reduce((D,v)=>Ze(D,v),y),process.env.NODE_ENV!=="production"){const D=["active","checked","completed","disabled","error","expanded","focused","focusVisible","required","selected"],v=(C,S)=>{let I;for(I in C){const f=C[I];if(D.includes(I)&&Object.keys(f).length>0){if(process.env.NODE_ENV!=="production"){const k=Cc("",I);console.error([`MUI: The \`${S}\` component increases the CSS specificity of the \`${I}\` internal state.`,"You can not override it like this: ",JSON.stringify(C,null,2),"",`Instead, you need to use the '&.${k}' syntax:`,JSON.stringify({root:{[`&.${k}`]:f}},null,2),"","https://mui.com/r/state-classes-guide"].join(`
68
- `))}C[I]={}}}};Object.keys(y.components).forEach(C=>{const S=y.components[C].styleOverrides;S&&C.startsWith("Mui")&&v(S,C)})}return y.unstable_sxConfig={...Po,...m==null?void 0:m.unstable_sxConfig},y.unstable_sx=function(v){return No({sx:v,theme:this})},y.toRuntimeSource=qi,rd(y),y}function od(t){let o;return t<1?o=5.11916*t**2:o=4.5*Math.log(t+1)+2,Math.round(o*10)/1e3}const nd=[...Array(25)].map((t,o)=>{if(o===0)return"none";const n=od(o);return`linear-gradient(rgba(255 255 255 / ${n}), rgba(255 255 255 / ${n}))`});function Ji(t){return{inputPlaceholder:t==="dark"?.5:.42,inputUnderline:t==="dark"?.7:.42,switchTrackDisabled:t==="dark"?.2:.12,switchTrack:t==="dark"?.3:.38}}function Ki(t){return t==="dark"?nd:[]}function id(t){const{palette:o={mode:"light"},opacity:n,overlays:i,colorSpace:s,...d}=t,l=hn({...o,colorSpace:s});return{palette:l,opacity:{...Ji(l.mode),...n},overlays:i||Ki(l.mode),...d}}function sd(t){var o;return!!t[0].match(/(cssVarPrefix|colorSchemeSelector|modularCssLayers|rootSelector|typography|mixins|breakpoints|direction|transitions)/)||!!t[0].match(/sxConfig$/)||t[0]==="palette"&&!!((o=t[1])!=null&&o.match(/(mode|contrastThreshold|tonalOffset)/))}const ad=t=>[...[...Array(25)].map((o,n)=>`--${t?`${t}-`:""}overlays-${n}`),`--${t?`${t}-`:""}palette-AppBar-darkBg`,`--${t?`${t}-`:""}palette-AppBar-darkColor`],ld=t=>(o,n)=>{const i=t.rootSelector||":root",s=t.colorSchemeSelector;let d=s;if(s==="class"&&(d=".%s"),s==="data"&&(d="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(d=`[${s}="%s"]`),t.defaultColorScheme===o){if(o==="dark"){const l={};return ad(t.cssVarPrefix).forEach(c=>{l[c]=n[c],delete n[c]}),d==="media"?{[i]:n,"@media (prefers-color-scheme: dark)":{[i]:l}}:d?{[d.replace("%s",o)]:l,[`${i}, ${d.replace("%s",o)}`]:n}:{[i]:{...n,...l}}}if(d&&d!=="media")return`${i}, ${d.replace("%s",String(o))}`}else if(o){if(d==="media")return{[`@media (prefers-color-scheme: ${String(o)})`]:{[i]:n}};if(d)return d.replace("%s",String(o))}return i};function cd(t,o){o.forEach(n=>{t[n]||(t[n]={})})}function N(t,o,n){!t[o]&&n&&(t[o]=n)}function eo(t){return typeof t!="string"||!t.startsWith("hsl")?t:Hi(t)}function Dt(t,o){`${o}Channel`in t||(t[`${o}Channel`]=Zr(eo(t[o]),`MUI: Can't create \`palette.${o}Channel\` because \`palette.${o}\` is not one of these formats: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().
69
- To suppress this warning, you need to explicitly provide the \`palette.${o}Channel\` as a string (in rgb format, for example "12 12 12") or undefined if you want to remove the channel token.`))}function dd(t){return typeof t=="number"?`${t}px`:typeof t=="string"||typeof t=="function"||Array.isArray(t)?t:"8px"}const jt=t=>{try{return t()}catch{}},ud=(t="mui")=>zc(t);function en(t,o,n,i,s){if(!n)return;n=n===!0?{}:n;const d=s==="dark"?"dark":"light";if(!i){o[s]=id({...n,palette:{mode:d,...n==null?void 0:n.palette},colorSpace:t});return}const{palette:l,...c}=sn({...i,palette:{mode:d,...n==null?void 0:n.palette},colorSpace:t});return o[s]={...n,palette:l,opacity:{...Ji(d),...n==null?void 0:n.opacity},overlays:(n==null?void 0:n.overlays)||Ki(d)},c}function pd(t={},...o){const{colorSchemes:n={light:!0},defaultColorScheme:i,disableCssColorScheme:s=!1,cssVarPrefix:d="mui",nativeColor:l=!1,shouldSkipGeneratingVar:c=sd,colorSchemeSelector:u=n.light&&n.dark?"media":void 0,rootSelector:h=":root",...m}=t,b=Object.keys(n)[0],x=i||(n.light&&b!=="light"?"light":b),y=ud(d),{[x]:D,light:v,dark:C,...S}=n,I={...S};let f=D;if((x==="dark"&&!("dark"in n)||x==="light"&&!("light"in n))&&(f=!0),!f)throw new Error(process.env.NODE_ENV!=="production"?`MUI: The \`colorSchemes.${x}\` option is either missing or invalid.`:dr(21,x));let k;l&&(k="oklch");const j=en(k,I,f,m,x);v&&!I.light&&en(k,I,v,void 0,"light"),C&&!I.dark&&en(k,I,C,void 0,"dark");let a={defaultColorScheme:x,...j,cssVarPrefix:d,colorSchemeSelector:u,rootSelector:h,getCssVar:y,colorSchemes:I,font:{...Lc(j.typography),...j.font},spacing:dd(m.spacing)};Object.keys(a.colorSchemes).forEach(ee=>{const g=a.colorSchemes[ee].palette,M=V=>{const Q=V.split("-"),xe=Q[1],me=Q[2];return y(V,g[xe][me])};g.mode==="light"&&(N(g.common,"background","#fff"),N(g.common,"onBackground","#000")),g.mode==="dark"&&(N(g.common,"background","#000"),N(g.common,"onBackground","#fff"));function W(V,Q,xe){if(k){let me;return V===ar&&(me=`transparent ${((1-xe)*100).toFixed(0)}%`),V===Se&&(me=`#000 ${(xe*100).toFixed(0)}%`),V===je&&(me=`#fff ${(xe*100).toFixed(0)}%`),`color-mix(in ${k}, ${Q}, ${me})`}return V(Q,xe)}if(cd(g,["Alert","AppBar","Avatar","Button","Chip","FilledInput","LinearProgress","Skeleton","Slider","SnackbarContent","SpeedDialAction","StepConnector","StepContent","Switch","TableCell","Tooltip"]),g.mode==="light"){N(g.Alert,"errorColor",W(Se,g.error.light,.6)),N(g.Alert,"infoColor",W(Se,g.info.light,.6)),N(g.Alert,"successColor",W(Se,g.success.light,.6)),N(g.Alert,"warningColor",W(Se,g.warning.light,.6)),N(g.Alert,"errorFilledBg",M("palette-error-main")),N(g.Alert,"infoFilledBg",M("palette-info-main")),N(g.Alert,"successFilledBg",M("palette-success-main")),N(g.Alert,"warningFilledBg",M("palette-warning-main")),N(g.Alert,"errorFilledColor",jt(()=>g.getContrastText(g.error.main))),N(g.Alert,"infoFilledColor",jt(()=>g.getContrastText(g.info.main))),N(g.Alert,"successFilledColor",jt(()=>g.getContrastText(g.success.main))),N(g.Alert,"warningFilledColor",jt(()=>g.getContrastText(g.warning.main))),N(g.Alert,"errorStandardBg",W(je,g.error.light,.9)),N(g.Alert,"infoStandardBg",W(je,g.info.light,.9)),N(g.Alert,"successStandardBg",W(je,g.success.light,.9)),N(g.Alert,"warningStandardBg",W(je,g.warning.light,.9)),N(g.Alert,"errorIconColor",M("palette-error-main")),N(g.Alert,"infoIconColor",M("palette-info-main")),N(g.Alert,"successIconColor",M("palette-success-main")),N(g.Alert,"warningIconColor",M("palette-warning-main")),N(g.AppBar,"defaultBg",M("palette-grey-100")),N(g.Avatar,"defaultBg",M("palette-grey-400")),N(g.Button,"inheritContainedBg",M("palette-grey-300")),N(g.Button,"inheritContainedHoverBg",M("palette-grey-A100")),N(g.Chip,"defaultBorder",M("palette-grey-400")),N(g.Chip,"defaultAvatarColor",M("palette-grey-700")),N(g.Chip,"defaultIconColor",M("palette-grey-700")),N(g.FilledInput,"bg","rgba(0, 0, 0, 0.06)"),N(g.FilledInput,"hoverBg","rgba(0, 0, 0, 0.09)"),N(g.FilledInput,"disabledBg","rgba(0, 0, 0, 0.12)"),N(g.LinearProgress,"primaryBg",W(je,g.primary.main,.62)),N(g.LinearProgress,"secondaryBg",W(je,g.secondary.main,.62)),N(g.LinearProgress,"errorBg",W(je,g.error.main,.62)),N(g.LinearProgress,"infoBg",W(je,g.info.main,.62)),N(g.LinearProgress,"successBg",W(je,g.success.main,.62)),N(g.LinearProgress,"warningBg",W(je,g.warning.main,.62)),N(g.Skeleton,"bg",k?W(ar,g.text.primary,.11):`rgba(${M("palette-text-primaryChannel")} / 0.11)`),N(g.Slider,"primaryTrack",W(je,g.primary.main,.62)),N(g.Slider,"secondaryTrack",W(je,g.secondary.main,.62)),N(g.Slider,"errorTrack",W(je,g.error.main,.62)),N(g.Slider,"infoTrack",W(je,g.info.main,.62)),N(g.Slider,"successTrack",W(je,g.success.main,.62)),N(g.Slider,"warningTrack",W(je,g.warning.main,.62));const V=k?W(Se,g.background.default,.6825):ho(g.background.default,.8);N(g.SnackbarContent,"bg",V),N(g.SnackbarContent,"color",jt(()=>k?nn.text.primary:g.getContrastText(V))),N(g.SpeedDialAction,"fabHoverBg",ho(g.background.paper,.15)),N(g.StepConnector,"border",M("palette-grey-400")),N(g.StepContent,"border",M("palette-grey-400")),N(g.Switch,"defaultColor",M("palette-common-white")),N(g.Switch,"defaultDisabledColor",M("palette-grey-100")),N(g.Switch,"primaryDisabledColor",W(je,g.primary.main,.62)),N(g.Switch,"secondaryDisabledColor",W(je,g.secondary.main,.62)),N(g.Switch,"errorDisabledColor",W(je,g.error.main,.62)),N(g.Switch,"infoDisabledColor",W(je,g.info.main,.62)),N(g.Switch,"successDisabledColor",W(je,g.success.main,.62)),N(g.Switch,"warningDisabledColor",W(je,g.warning.main,.62)),N(g.TableCell,"border",W(je,W(ar,g.divider,1),.88)),N(g.Tooltip,"bg",W(ar,g.grey[700],.92))}if(g.mode==="dark"){N(g.Alert,"errorColor",W(je,g.error.light,.6)),N(g.Alert,"infoColor",W(je,g.info.light,.6)),N(g.Alert,"successColor",W(je,g.success.light,.6)),N(g.Alert,"warningColor",W(je,g.warning.light,.6)),N(g.Alert,"errorFilledBg",M("palette-error-dark")),N(g.Alert,"infoFilledBg",M("palette-info-dark")),N(g.Alert,"successFilledBg",M("palette-success-dark")),N(g.Alert,"warningFilledBg",M("palette-warning-dark")),N(g.Alert,"errorFilledColor",jt(()=>g.getContrastText(g.error.dark))),N(g.Alert,"infoFilledColor",jt(()=>g.getContrastText(g.info.dark))),N(g.Alert,"successFilledColor",jt(()=>g.getContrastText(g.success.dark))),N(g.Alert,"warningFilledColor",jt(()=>g.getContrastText(g.warning.dark))),N(g.Alert,"errorStandardBg",W(Se,g.error.light,.9)),N(g.Alert,"infoStandardBg",W(Se,g.info.light,.9)),N(g.Alert,"successStandardBg",W(Se,g.success.light,.9)),N(g.Alert,"warningStandardBg",W(Se,g.warning.light,.9)),N(g.Alert,"errorIconColor",M("palette-error-main")),N(g.Alert,"infoIconColor",M("palette-info-main")),N(g.Alert,"successIconColor",M("palette-success-main")),N(g.Alert,"warningIconColor",M("palette-warning-main")),N(g.AppBar,"defaultBg",M("palette-grey-900")),N(g.AppBar,"darkBg",M("palette-background-paper")),N(g.AppBar,"darkColor",M("palette-text-primary")),N(g.Avatar,"defaultBg",M("palette-grey-600")),N(g.Button,"inheritContainedBg",M("palette-grey-800")),N(g.Button,"inheritContainedHoverBg",M("palette-grey-700")),N(g.Chip,"defaultBorder",M("palette-grey-700")),N(g.Chip,"defaultAvatarColor",M("palette-grey-300")),N(g.Chip,"defaultIconColor",M("palette-grey-300")),N(g.FilledInput,"bg","rgba(255, 255, 255, 0.09)"),N(g.FilledInput,"hoverBg","rgba(255, 255, 255, 0.13)"),N(g.FilledInput,"disabledBg","rgba(255, 255, 255, 0.12)"),N(g.LinearProgress,"primaryBg",W(Se,g.primary.main,.5)),N(g.LinearProgress,"secondaryBg",W(Se,g.secondary.main,.5)),N(g.LinearProgress,"errorBg",W(Se,g.error.main,.5)),N(g.LinearProgress,"infoBg",W(Se,g.info.main,.5)),N(g.LinearProgress,"successBg",W(Se,g.success.main,.5)),N(g.LinearProgress,"warningBg",W(Se,g.warning.main,.5)),N(g.Skeleton,"bg",k?W(ar,g.text.primary,.13):`rgba(${M("palette-text-primaryChannel")} / 0.13)`),N(g.Slider,"primaryTrack",W(Se,g.primary.main,.5)),N(g.Slider,"secondaryTrack",W(Se,g.secondary.main,.5)),N(g.Slider,"errorTrack",W(Se,g.error.main,.5)),N(g.Slider,"infoTrack",W(Se,g.info.main,.5)),N(g.Slider,"successTrack",W(Se,g.success.main,.5)),N(g.Slider,"warningTrack",W(Se,g.warning.main,.5));const V=k?W(je,g.background.default,.985):ho(g.background.default,.98);N(g.SnackbarContent,"bg",V),N(g.SnackbarContent,"color",jt(()=>k?Yi.text.primary:g.getContrastText(V))),N(g.SpeedDialAction,"fabHoverBg",ho(g.background.paper,.15)),N(g.StepConnector,"border",M("palette-grey-600")),N(g.StepContent,"border",M("palette-grey-600")),N(g.Switch,"defaultColor",M("palette-grey-300")),N(g.Switch,"defaultDisabledColor",M("palette-grey-600")),N(g.Switch,"primaryDisabledColor",W(Se,g.primary.main,.55)),N(g.Switch,"secondaryDisabledColor",W(Se,g.secondary.main,.55)),N(g.Switch,"errorDisabledColor",W(Se,g.error.main,.55)),N(g.Switch,"infoDisabledColor",W(Se,g.info.main,.55)),N(g.Switch,"successDisabledColor",W(Se,g.success.main,.55)),N(g.Switch,"warningDisabledColor",W(Se,g.warning.main,.55)),N(g.TableCell,"border",W(Se,W(ar,g.divider,1),.68)),N(g.Tooltip,"bg",W(ar,g.grey[700],.92))}Dt(g.background,"default"),Dt(g.background,"paper"),Dt(g.common,"background"),Dt(g.common,"onBackground"),Dt(g,"divider"),Object.keys(g).forEach(V=>{const Q=g[V];V!=="tonalOffset"&&Q&&typeof Q=="object"&&(Q.main&&N(g[V],"mainChannel",Zr(eo(Q.main))),Q.light&&N(g[V],"lightChannel",Zr(eo(Q.light))),Q.dark&&N(g[V],"darkChannel",Zr(eo(Q.dark))),Q.contrastText&&N(g[V],"contrastTextChannel",Zr(eo(Q.contrastText))),V==="text"&&(Dt(g[V],"primary"),Dt(g[V],"secondary")),V==="action"&&(Q.active&&Dt(g[V],"active"),Q.selected&&Dt(g[V],"selected")))})}),a=o.reduce((ee,g)=>Ze(ee,g),a);const B={prefix:d,disableCssColorScheme:s,shouldSkipGeneratingVar:c,getSelector:ld(a),enableContrastVars:l},{vars:R,generateThemeVars:J,generateStyleSheets:K}=Ec(a,B);return a.vars=R,Object.entries(a.colorSchemes[a.defaultColorScheme]).forEach(([ee,g])=>{a[ee]=g}),a.generateThemeVars=J,a.generateStyleSheets=K,a.generateSpacing=function(){return Fi(m.spacing,pn(this))},a.getColorSchemeSelector=Oc(u),a.spacing=a.generateSpacing(),a.shouldSkipGeneratingVar=c,a.unstable_sxConfig={...Po,...m==null?void 0:m.unstable_sxConfig},a.unstable_sx=function(g){return No({sx:g,theme:this})},a.toRuntimeSource=qi,a}function si(t,o,n){t.colorSchemes&&n&&(t.colorSchemes[o]={...n!==!0&&n,palette:hn({...n===!0?{}:n.palette,mode:o})})}function xd(t={},...o){const{palette:n,cssVariables:i=!1,colorSchemes:s=n?void 0:{light:!0},defaultColorScheme:d=n==null?void 0:n.mode,...l}=t,c=d||"light",u=s==null?void 0:s[c],h={...s,...n?{[c]:{...typeof u!="boolean"&&u,palette:n}}:void 0};if(i===!1){if(!("colorSchemes"in t))return sn(t,...o);let m=n;"palette"in t||h[c]&&(h[c]!==!0?m=h[c].palette:c==="dark"&&(m={mode:"dark"}));const b=sn({...t,palette:m},...o);return b.defaultColorScheme=c,b.colorSchemes=h,b.palette.mode==="light"&&(b.colorSchemes.light={...h.light!==!0&&h.light,palette:b.palette},si(b,"dark",h.dark)),b.palette.mode==="dark"&&(b.colorSchemes.dark={...h.dark!==!0&&h.dark,palette:b.palette},si(b,"light",h.light)),b}return!n&&!("light"in h)&&c==="light"&&(h.light=!0),pd({...l,colorSchemes:h,defaultColorScheme:c,...typeof i!="boolean"&&i},...o)}const md=xd();function At(){const t=bc(md);return process.env.NODE_ENV!=="production"&&Io.useDebugValue(t),t[ll]||t}async function hd(t,o,n){try{new URL(t)}catch{throw new Error("Please enter a valid URL")}const i={"Content-Type":"application/json"};o&&(i.Authorization=`Bearer ${o}`);const s=new AbortController,d=setTimeout(()=>s.abort(),3e4);let l;try{l=await fetch(t,{headers:i,signal:s.signal})}catch(h){throw clearTimeout(d),(h==null?void 0:h.name)==="AbortError"?new Error("Request timed out after 30 seconds"):new Error("Failed to fetch — check the URL and your network connection")}finally{clearTimeout(d)}if(l.status===401)throw new Error("Authentication failed (401) — check your API key");if(!l.ok)throw new Error(`API error ${l.status}: ${l.statusText}`);let c;try{c=await l.json()}catch{throw new Error("Response is not valid JSON")}let u;if(Array.isArray(c))u=c;else if(n&&c[n]&&Array.isArray(c[n]))u=c[n];else{const m=["data","results","items","records"].find(b=>c[b]&&Array.isArray(c[b]));if(m)u=c[m];else throw new Error("API response must be a JSON array, or specify the data path key.")}return{data:u,source:t,fetchedAt:new Date().toISOString()}}function fd(t,o){return o.map(n=>`${n.x}px ${n.y}px ${n.blur}px ${n.spread}px ${T(t.palette.common.black,n.opacity)}`).join(", ")}const gd={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 te(t,o){return fd(t,gd[o])}function Me(t){return`${Number(t.shape.borderRadius)*1.5}px`}function so(t){return`${Number(t.shape.borderRadius)}px`}function yd({isOpen:t,onClose:o,onCreate:n,preloadedData:i,preloadedDataLabel:s}){const[d,l]=p.useState(""),[c,u]=p.useState(!1),[h,m]=p.useState(""),[b,x]=p.useState(null),[y,D]=p.useState(null),[v,C]=p.useState(!1),[S,I]=p.useState(""),f=p.useRef(null),[k,j]=p.useState("json"),[a,B]=p.useState(""),[R,J]=p.useState(""),[K,ee]=p.useState(""),[g,M]=p.useState("idle"),[W,V]=p.useState(""),[Q,xe]=p.useState(null),[me,L]=p.useState(0),A=async P=>{if(I(""),!P.name.endsWith(".json")){I("Only .json files are allowed");return}const ie=10*1024*1024;if(P.size>ie){I("File size exceeds 10MB limit");return}try{const pe=await P.text();let le;try{le=JSON.parse(pe)}catch{I("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(le)){I("JSON must be an array of objects");return}if(le.length===0){I("No data rows found in JSON file");return}x(P),D(le)}catch{I("Network error — please try again")}},H=P=>{P.preventDefault();const ie=P.dataTransfer.files[0];ie&&A(ie)},se=async()=>{if(a.trim()){M("loading"),V("");try{const P=await hd(a.trim(),R.trim()||void 0,K.trim()||void 0);xe(P.data),L(P.data.length),M("ready")}catch(P){V((P==null?void 0:P.message)||"Connection failed"),M("error")}}},G=()=>{if(!d.trim()){u(!0);return}const P=k==="api"?Q:i||y;P&&(n(d.trim(),h.trim(),P),re())},re=()=>{l(""),u(!1),m(""),x(null),D(null),I(""),j("json"),B(""),J(""),ee(""),M("idle"),V(""),xe(null),L(0),o()},ae=i||y,ne=c&&!d.trim();return d.trim(),e.jsxs(e.Fragment,{children:[e.jsxs(r.Dialog,{open:t,onClose:re,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:P=>Me(P),width:480,maxHeight:"min(720px, calc(100vh - 120px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:P=>te(P,"menu")}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2.5,fontWeight:500,fontSize:"1.125rem",color:"text.primary",letterSpacing:"-0.01em",borderBottom:"1px solid",borderColor:"divider"},children:["Create new report",e.jsx(r.IconButton,{onClick:re,size:"small",sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(z.Close,{sx:{fontSize:18}})})]}),e.jsx(r.DialogContent,{sx:{px:3,pt:2,pb:2,overflowY:"auto"},children:e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:2,pt:2},children:[e.jsx(r.TextField,{label:"Report name",required:!0,fullWidth:!0,value:d,onChange:P=>{l(P.target.value),c&&P.target.value.trim()&&u(!1)},placeholder:"Enter report name",autoFocus:!0,error:ne,helperText:ne?"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}}}}),e.jsx(r.TextField,{label:"Description (optional)",fullWidth:!0,multiline:!0,rows:2,value:h,onChange:P=>m(P.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}}}}),e.jsxs(r.Tabs,{value:k==="json"?0:1,onChange:(P,ie)=>{j(ie===0?"json":"api"),M("idle"),V("")},variant:"fullWidth",sx:{borderBottom:1,borderColor:"divider",minHeight:40},children:[e.jsx(r.Tab,{label:"Upload JSON",icon:e.jsx(z.Description,{fontSize:"small"}),iconPosition:"start",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,minHeight:40,py:.5}}),e.jsx(r.Tab,{label:"Connect API",icon:e.jsx(z.Api,{fontSize:"small"}),iconPosition:"start",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,minHeight:40,py:.5}})]}),k==="json"&&e.jsx(r.Box,{children:i?e.jsxs(r.Box,{sx:{border:"1.5px solid",borderColor:"success.main",borderRadius:2,p:2.5,bgcolor:P=>T(P.palette.success.main,.04),display:"flex",alignItems:"center",gap:2},children:[e.jsx(r.Box,{sx:{width:36,height:36,borderRadius:"50%",bgcolor:P=>T(P.palette.success.main,.12),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(z.CheckCircle,{sx:{fontSize:20,color:"success.main"}})}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.dark",fontSize:"0.875rem"},children:s||`${i.length.toLocaleString()} records loaded`}),e.jsx(r.Typography,{variant:"caption",sx:{color:"text.secondary"},children:"Data source is connected — ready to create"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:1.25},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"Data source"}),e.jsx(r.IconButton,{size:"small",onClick:()=>C(!0),sx:{p:.25,color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:e.jsx(z.Info,{sx:{fontSize:16}})})]}),e.jsxs(r.Box,{onDrop:H,onDragOver:P=>P.preventDefault(),onPaste:P=>P.preventDefault(),onClick:()=>{var P;return(P=f.current)==null?void 0:P.click()},sx:{position:"relative",border:"1.5px",borderStyle:y?"solid":"dashed",borderColor:y?"success.main":S?"error.main":"primary.main",borderRadius:2,p:3,textAlign:"center",cursor:"pointer",bgcolor:y?P=>T(P.palette.success.main,.04):S?P=>T(P.palette.error.main,.04):P=>T(P.palette.primary.main,.04),transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:y?P=>T(P.palette.success.main,.08):S?P=>T(P.palette.error.main,.08):P=>T(P.palette.primary.main,.08),borderColor:y?"success.dark":S?"error.dark":"primary.dark"}},children:[e.jsx(r.Box,{component:"input",ref:f,type:"file",accept:".json",sx:{display:"none"},onChange:P=>{var ie;return((ie=P.target.files)==null?void 0:ie[0])&&A(P.target.files[0])}}),y?e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:.75,animation:"fadeIn 0.2s ease-in","@keyframes fadeIn":{from:{opacity:0,transform:"scale(0.98)"},to:{opacity:1,transform:"scale(1)"}}},children:[e.jsx(r.Box,{sx:{width:40,height:40,borderRadius:"50%",bgcolor:P=>T(P.palette.success.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:.5},children:e.jsx(z.CheckCircle,{sx:{fontSize:24,color:"success.main"}})}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.main",fontSize:"0.875rem"},children:b==null?void 0:b.name}),e.jsx(r.Typography,{variant:"caption",sx:{color:"success.dark",fontSize:"0.75rem"},children:"Ready to create"})]}):e.jsxs(r.Box,{children:[e.jsx(r.Box,{sx:{width:48,height:48,borderRadius:"50%",bgcolor:P=>T(P.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mx:"auto",mb:1.5},children:e.jsx(z.CloudUpload,{sx:{fontSize:28,color:"primary.main"}})}),e.jsx(r.Typography,{variant:"body2",sx:{color:"text.primary",fontSize:"0.875rem",fontWeight:500,mb:.25},children:"Upload JSON file"}),e.jsx(r.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.75rem",display:"block"},children:"Click to browse or drag and drop"}),S&&e.jsx(r.Box,{sx:{mt:1.25,p:.75,borderRadius:1,bgcolor:P=>T(P.palette.error.main,.08),border:1,borderColor:P=>T(P.palette.error.main,.2)},children:e.jsx(r.Typography,{variant:"caption",sx:{color:"error.main",fontSize:"0.6875rem",fontWeight:500},children:S})})]})]})]})}),k==="api"&&e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[e.jsx(r.TextField,{label:"API Endpoint URL",required:!0,fullWidth:!0,size:"small",value:a,onChange:P=>{B(P.target.value),M("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}}}}),e.jsx(r.TextField,{label:"API Key (optional)",fullWidth:!0,size:"small",value:R,onChange:P=>J(P.target.value),placeholder:"Leave blank if no auth required",InputProps:{startAdornment:e.jsx(r.InputAdornment,{position:"start",children:e.jsx(z.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}}}}),e.jsx(r.TextField,{label:"Response data path (optional)",fullWidth:!0,size:"small",value:K,onChange:P=>ee(P.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}}}),e.jsx(r.Button,{variant:"outlined",fullWidth:!0,disabled:!a.trim()||g==="loading",onClick:se,startIcon:g==="loading"?e.jsx(r.CircularProgress,{size:16,color:"inherit"}):e.jsx(z.Api,{}),sx:{fontSize:"0.875rem",borderRadius:1,py:.875,borderColor:"primary.main",color:"primary.main","&:hover":{bgcolor:P=>T(P.palette.primary.main,.04),borderColor:"primary.dark"},"&:disabled":{borderColor:"action.disabledBackground",color:"action.disabled"}},children:g==="loading"?"Connecting...":"Test Connection & Load Data"}),g==="ready"&&e.jsxs(r.Box,{sx:{border:"1.5px solid",borderColor:"success.main",borderRadius:2,p:2,bgcolor:P=>T(P.palette.success.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[e.jsx(z.CheckCircle,{sx:{fontSize:20,color:"success.main",flexShrink:0,mt:.1}}),e.jsxs(r.Box,{children:[e.jsxs(r.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.dark",fontSize:"0.875rem"},children:[me.toLocaleString()," records loaded — ready to create"]}),e.jsx(r.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.75rem",wordBreak:"break-all",display:"block",mt:.25},children:a})]})]}),g==="error"&&e.jsxs(r.Box,{sx:{border:"1.5px solid",borderColor:"error.main",borderRadius:2,p:2,bgcolor:P=>T(P.palette.error.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[e.jsx(z.ErrorOutline,{sx:{fontSize:20,color:"error.main",flexShrink:0,mt:.1}}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,color:"error.main",fontSize:"0.875rem"},children:"Connection failed"}),e.jsx(r.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.75rem",display:"block",mt:.25},children:W})]})]})]})]})}),e.jsxs(r.DialogActions,{sx:{px:3,py:2,gap:1,borderTop:"1px solid",borderColor:"divider"},children:[e.jsx(r.Button,{onClick:re,variant:"text",sx:{color:"primary.main",fontSize:"0.875rem",borderRadius:P=>`${P.shape.borderRadius}px`,px:2,py:.625,minWidth:64,"&:hover":{bgcolor:P=>T(P.palette.primary.main,.04)}},children:"Cancel"}),e.jsx(r.Button,{onClick:G,disabled:k==="json"&&!ae||k==="api"&&g!=="ready",variant:"contained",sx:{fontSize:"0.875rem",borderRadius:P=>`${P.shape.borderRadius}px`,px:2.5,py:.625,minWidth:64,"&:disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Create"})]})]}),e.jsxs(r.Dialog,{open:v,onClose:()=>C(!1),maxWidth:"sm",PaperProps:{sx:{borderRadius:3,width:560,maxHeight:"80vh",boxShadow:8}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,fontWeight:500,fontSize:"1.25rem",color:"text.primary",letterSpacing:"-0.01em"},children:["JSON format guide",e.jsx(r.IconButton,{onClick:()=>C(!1),size:"small",sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:e.jsx(z.Close,{sx:{fontSize:20}})})]}),e.jsx(r.DialogContent,{sx:{px:3,py:2},children:e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Required format"}),e.jsx(r.Typography,{variant:"body2",sx:{color:"text.secondary",fontSize:"0.8125rem",lineHeight:1.5},children:"Your JSON file must be an array of objects. Each object represents a row, and all should have the same field names."})]}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Example structure"}),e.jsx(r.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:`[
67
+ export default theme;`}function ri(t){return typeof t=="number"?`${(t*100).toFixed(0)}%`:`calc((${t}) * 100%)`}const Jc=t=>{if(!Number.isNaN(+t))return+t;const o=t.match(/\d*\.?\d+/g);if(!o)return 0;let n=0;for(let i=0;i<o.length;i+=1)n+=+o[i];return n};function Kc(t){Object.assign(t,{alpha(o,n){const i=this||t;return i.colorSpace?`oklch(from ${o} l c h / ${typeof n=="string"?`calc(${n})`:n})`:i.vars?`rgba(${o.replace(/var\(--([^,\s)]+)(?:,[^)]+)?\)+/g,"var(--$1Channel)")} / ${typeof n=="string"?`calc(${n})`:n})`:k(o,Jc(n))},lighten(o,n){const i=this||t;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${o}, #fff ${ri(n)})`:Ro(o,n)},darken(o,n){const i=this||t;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${o}, #000 ${ri(n)})`:Mo(o,n)}})}function en(t={},...o){const{breakpoints:n,mixins:i={},spacing:s,palette:d={},transitions:c={},typography:l={},shape:u,colorSpace:f,...m}=t;if(t.vars&&t.generateThemeVars===void 0)throw new Error(process.env.NODE_ENV!=="production"?"MUI: `vars` is a private field used for CSS variables support.\nPlease use another name or follow the [docs](https://mui.com/material-ui/customization/css-theme-variables/usage/) to enable the feature.":or(20));const h=dn({...d,colorSpace:f}),x=Li(t);let b=Xe(x,{mixins:Rc(x.breakpoints,i),palette:h,shadows:Fc.slice(),typography:Wc(h,l),transitions:Yc(c),zIndex:{...Gc}});if(b=Xe(b,m),b=o.reduce((D,g)=>Xe(D,g),b),process.env.NODE_ENV!=="production"){const D=["active","checked","completed","disabled","error","expanded","focused","focusVisible","required","selected"],g=(j,w)=>{let I;for(I in j){const v=j[I];if(D.includes(I)&&Object.keys(v).length>0){if(process.env.NODE_ENV!=="production"){const S=gc("",I);console.error([`MUI: The \`${w}\` component increases the CSS specificity of the \`${I}\` internal state.`,"You can not override it like this: ",JSON.stringify(j,null,2),"",`Instead, you need to use the '&.${S}' syntax:`,JSON.stringify({root:{[`&.${S}`]:v}},null,2),"","https://mui.com/r/state-classes-guide"].join(`
68
+ `))}j[I]={}}}};Object.keys(b.components).forEach(j=>{const w=b.components[j].styleOverrides;w&&j.startsWith("Mui")&&g(w,j)})}return b.unstable_sxConfig={...Oo,...m==null?void 0:m.unstable_sxConfig},b.unstable_sx=function(g){return Ao({sx:g,theme:this})},b.toRuntimeSource=Yi,Kc(b),b}function Xc(t){let o;return t<1?o=5.11916*t**2:o=4.5*Math.log(t+1)+2,Math.round(o*10)/1e3}const Qc=[...Array(25)].map((t,o)=>{if(o===0)return"none";const n=Xc(o);return`linear-gradient(rgba(255 255 255 / ${n}), rgba(255 255 255 / ${n}))`});function Gi(t){return{inputPlaceholder:t==="dark"?.5:.42,inputUnderline:t==="dark"?.7:.42,switchTrackDisabled:t==="dark"?.2:.12,switchTrack:t==="dark"?.3:.38}}function qi(t){return t==="dark"?Qc:[]}function Zc(t){const{palette:o={mode:"light"},opacity:n,overlays:i,colorSpace:s,...d}=t,c=dn({...o,colorSpace:s});return{palette:c,opacity:{...Gi(c.mode),...n},overlays:i||qi(c.mode),...d}}function ed(t){var o;return!!t[0].match(/(cssVarPrefix|colorSchemeSelector|modularCssLayers|rootSelector|typography|mixins|breakpoints|direction|transitions)/)||!!t[0].match(/sxConfig$/)||t[0]==="palette"&&!!((o=t[1])!=null&&o.match(/(mode|contrastThreshold|tonalOffset)/))}const td=t=>[...[...Array(25)].map((o,n)=>`--${t?`${t}-`:""}overlays-${n}`),`--${t?`${t}-`:""}palette-AppBar-darkBg`,`--${t?`${t}-`:""}palette-AppBar-darkColor`],rd=t=>(o,n)=>{const i=t.rootSelector||":root",s=t.colorSchemeSelector;let d=s;if(s==="class"&&(d=".%s"),s==="data"&&(d="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(d=`[${s}="%s"]`),t.defaultColorScheme===o){if(o==="dark"){const c={};return td(t.cssVarPrefix).forEach(l=>{c[l]=n[l],delete n[l]}),d==="media"?{[i]:n,"@media (prefers-color-scheme: dark)":{[i]:c}}:d?{[d.replace("%s",o)]:c,[`${i}, ${d.replace("%s",o)}`]:n}:{[i]:{...n,...c}}}if(d&&d!=="media")return`${i}, ${d.replace("%s",String(o))}`}else if(o){if(d==="media")return{[`@media (prefers-color-scheme: ${String(o)})`]:{[i]:n}};if(d)return d.replace("%s",String(o))}return i};function od(t,o){o.forEach(n=>{t[n]||(t[n]={})})}function N(t,o,n){!t[o]&&n&&(t[o]=n)}function Ur(t){return typeof t!="string"||!t.startsWith("hsl")?t:Fi(t)}function Ct(t,o){`${o}Channel`in t||(t[`${o}Channel`]=Hr(Ur(t[o]),`MUI: Can't create \`palette.${o}Channel\` because \`palette.${o}\` is not one of these formats: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().
69
+ To suppress this warning, you need to explicitly provide the \`palette.${o}Channel\` as a string (in rgb format, for example "12 12 12") or undefined if you want to remove the channel token.`))}function nd(t){return typeof t=="number"?`${t}px`:typeof t=="string"||typeof t=="function"||Array.isArray(t)?t:"8px"}const mt=t=>{try{return t()}catch{}},id=(t="mui")=>jc(t);function Jo(t,o,n,i,s){if(!n)return;n=n===!0?{}:n;const d=s==="dark"?"dark":"light";if(!i){o[s]=Zc({...n,palette:{mode:d,...n==null?void 0:n.palette},colorSpace:t});return}const{palette:c,...l}=en({...i,palette:{mode:d,...n==null?void 0:n.palette},colorSpace:t});return o[s]={...n,palette:c,opacity:{...Gi(d),...n==null?void 0:n.opacity},overlays:(n==null?void 0:n.overlays)||qi(d)},l}function sd(t={},...o){const{colorSchemes:n={light:!0},defaultColorScheme:i,disableCssColorScheme:s=!1,cssVarPrefix:d="mui",nativeColor:c=!1,shouldSkipGeneratingVar:l=ed,colorSchemeSelector:u=n.light&&n.dark?"media":void 0,rootSelector:f=":root",...m}=t,h=Object.keys(n)[0],x=i||(n.light&&h!=="light"?"light":h),b=id(d),{[x]:D,light:g,dark:j,...w}=n,I={...w};let v=D;if((x==="dark"&&!("dark"in n)||x==="light"&&!("light"in n))&&(v=!0),!v)throw new Error(process.env.NODE_ENV!=="production"?`MUI: The \`colorSchemes.${x}\` option is either missing or invalid.`:or(21,x));let S;c&&(S="oklch");const C=Jo(S,I,v,m,x);g&&!I.light&&Jo(S,I,g,void 0,"light"),j&&!I.dark&&Jo(S,I,j,void 0,"dark");let a={defaultColorScheme:x,...C,cssVarPrefix:d,colorSchemeSelector:u,rootSelector:f,getCssVar:b,colorSchemes:I,font:{...Mc(C.typography),...C.font},spacing:nd(m.spacing)};Object.keys(a.colorSchemes).forEach(ee=>{const y=a.colorSchemes[ee].palette,M=V=>{const Q=V.split("-"),xe=Q[1],de=Q[2];return b(V,y[xe][de])};y.mode==="light"&&(N(y.common,"background","#fff"),N(y.common,"onBackground","#000")),y.mode==="dark"&&(N(y.common,"background","#000"),N(y.common,"onBackground","#fff"));function W(V,Q,xe){if(S){let de;return V===er&&(de=`transparent ${((1-xe)*100).toFixed(0)}%`),V===ve&&(de=`#000 ${(xe*100).toFixed(0)}%`),V===Se&&(de=`#fff ${(xe*100).toFixed(0)}%`),`color-mix(in ${S}, ${Q}, ${de})`}return V(Q,xe)}if(od(y,["Alert","AppBar","Avatar","Button","Chip","FilledInput","LinearProgress","Skeleton","Slider","SnackbarContent","SpeedDialAction","StepConnector","StepContent","Switch","TableCell","Tooltip"]),y.mode==="light"){N(y.Alert,"errorColor",W(ve,y.error.light,.6)),N(y.Alert,"infoColor",W(ve,y.info.light,.6)),N(y.Alert,"successColor",W(ve,y.success.light,.6)),N(y.Alert,"warningColor",W(ve,y.warning.light,.6)),N(y.Alert,"errorFilledBg",M("palette-error-main")),N(y.Alert,"infoFilledBg",M("palette-info-main")),N(y.Alert,"successFilledBg",M("palette-success-main")),N(y.Alert,"warningFilledBg",M("palette-warning-main")),N(y.Alert,"errorFilledColor",mt(()=>y.getContrastText(y.error.main))),N(y.Alert,"infoFilledColor",mt(()=>y.getContrastText(y.info.main))),N(y.Alert,"successFilledColor",mt(()=>y.getContrastText(y.success.main))),N(y.Alert,"warningFilledColor",mt(()=>y.getContrastText(y.warning.main))),N(y.Alert,"errorStandardBg",W(Se,y.error.light,.9)),N(y.Alert,"infoStandardBg",W(Se,y.info.light,.9)),N(y.Alert,"successStandardBg",W(Se,y.success.light,.9)),N(y.Alert,"warningStandardBg",W(Se,y.warning.light,.9)),N(y.Alert,"errorIconColor",M("palette-error-main")),N(y.Alert,"infoIconColor",M("palette-info-main")),N(y.Alert,"successIconColor",M("palette-success-main")),N(y.Alert,"warningIconColor",M("palette-warning-main")),N(y.AppBar,"defaultBg",M("palette-grey-100")),N(y.Avatar,"defaultBg",M("palette-grey-400")),N(y.Button,"inheritContainedBg",M("palette-grey-300")),N(y.Button,"inheritContainedHoverBg",M("palette-grey-A100")),N(y.Chip,"defaultBorder",M("palette-grey-400")),N(y.Chip,"defaultAvatarColor",M("palette-grey-700")),N(y.Chip,"defaultIconColor",M("palette-grey-700")),N(y.FilledInput,"bg","rgba(0, 0, 0, 0.06)"),N(y.FilledInput,"hoverBg","rgba(0, 0, 0, 0.09)"),N(y.FilledInput,"disabledBg","rgba(0, 0, 0, 0.12)"),N(y.LinearProgress,"primaryBg",W(Se,y.primary.main,.62)),N(y.LinearProgress,"secondaryBg",W(Se,y.secondary.main,.62)),N(y.LinearProgress,"errorBg",W(Se,y.error.main,.62)),N(y.LinearProgress,"infoBg",W(Se,y.info.main,.62)),N(y.LinearProgress,"successBg",W(Se,y.success.main,.62)),N(y.LinearProgress,"warningBg",W(Se,y.warning.main,.62)),N(y.Skeleton,"bg",S?W(er,y.text.primary,.11):`rgba(${M("palette-text-primaryChannel")} / 0.11)`),N(y.Slider,"primaryTrack",W(Se,y.primary.main,.62)),N(y.Slider,"secondaryTrack",W(Se,y.secondary.main,.62)),N(y.Slider,"errorTrack",W(Se,y.error.main,.62)),N(y.Slider,"infoTrack",W(Se,y.info.main,.62)),N(y.Slider,"successTrack",W(Se,y.success.main,.62)),N(y.Slider,"warningTrack",W(Se,y.warning.main,.62));const V=S?W(ve,y.background.default,.6825):ao(y.background.default,.8);N(y.SnackbarContent,"bg",V),N(y.SnackbarContent,"color",mt(()=>S?Zo.text.primary:y.getContrastText(V))),N(y.SpeedDialAction,"fabHoverBg",ao(y.background.paper,.15)),N(y.StepConnector,"border",M("palette-grey-400")),N(y.StepContent,"border",M("palette-grey-400")),N(y.Switch,"defaultColor",M("palette-common-white")),N(y.Switch,"defaultDisabledColor",M("palette-grey-100")),N(y.Switch,"primaryDisabledColor",W(Se,y.primary.main,.62)),N(y.Switch,"secondaryDisabledColor",W(Se,y.secondary.main,.62)),N(y.Switch,"errorDisabledColor",W(Se,y.error.main,.62)),N(y.Switch,"infoDisabledColor",W(Se,y.info.main,.62)),N(y.Switch,"successDisabledColor",W(Se,y.success.main,.62)),N(y.Switch,"warningDisabledColor",W(Se,y.warning.main,.62)),N(y.TableCell,"border",W(Se,W(er,y.divider,1),.88)),N(y.Tooltip,"bg",W(er,y.grey[700],.92))}if(y.mode==="dark"){N(y.Alert,"errorColor",W(Se,y.error.light,.6)),N(y.Alert,"infoColor",W(Se,y.info.light,.6)),N(y.Alert,"successColor",W(Se,y.success.light,.6)),N(y.Alert,"warningColor",W(Se,y.warning.light,.6)),N(y.Alert,"errorFilledBg",M("palette-error-dark")),N(y.Alert,"infoFilledBg",M("palette-info-dark")),N(y.Alert,"successFilledBg",M("palette-success-dark")),N(y.Alert,"warningFilledBg",M("palette-warning-dark")),N(y.Alert,"errorFilledColor",mt(()=>y.getContrastText(y.error.dark))),N(y.Alert,"infoFilledColor",mt(()=>y.getContrastText(y.info.dark))),N(y.Alert,"successFilledColor",mt(()=>y.getContrastText(y.success.dark))),N(y.Alert,"warningFilledColor",mt(()=>y.getContrastText(y.warning.dark))),N(y.Alert,"errorStandardBg",W(ve,y.error.light,.9)),N(y.Alert,"infoStandardBg",W(ve,y.info.light,.9)),N(y.Alert,"successStandardBg",W(ve,y.success.light,.9)),N(y.Alert,"warningStandardBg",W(ve,y.warning.light,.9)),N(y.Alert,"errorIconColor",M("palette-error-main")),N(y.Alert,"infoIconColor",M("palette-info-main")),N(y.Alert,"successIconColor",M("palette-success-main")),N(y.Alert,"warningIconColor",M("palette-warning-main")),N(y.AppBar,"defaultBg",M("palette-grey-900")),N(y.AppBar,"darkBg",M("palette-background-paper")),N(y.AppBar,"darkColor",M("palette-text-primary")),N(y.Avatar,"defaultBg",M("palette-grey-600")),N(y.Button,"inheritContainedBg",M("palette-grey-800")),N(y.Button,"inheritContainedHoverBg",M("palette-grey-700")),N(y.Chip,"defaultBorder",M("palette-grey-700")),N(y.Chip,"defaultAvatarColor",M("palette-grey-300")),N(y.Chip,"defaultIconColor",M("palette-grey-300")),N(y.FilledInput,"bg","rgba(255, 255, 255, 0.09)"),N(y.FilledInput,"hoverBg","rgba(255, 255, 255, 0.13)"),N(y.FilledInput,"disabledBg","rgba(255, 255, 255, 0.12)"),N(y.LinearProgress,"primaryBg",W(ve,y.primary.main,.5)),N(y.LinearProgress,"secondaryBg",W(ve,y.secondary.main,.5)),N(y.LinearProgress,"errorBg",W(ve,y.error.main,.5)),N(y.LinearProgress,"infoBg",W(ve,y.info.main,.5)),N(y.LinearProgress,"successBg",W(ve,y.success.main,.5)),N(y.LinearProgress,"warningBg",W(ve,y.warning.main,.5)),N(y.Skeleton,"bg",S?W(er,y.text.primary,.13):`rgba(${M("palette-text-primaryChannel")} / 0.13)`),N(y.Slider,"primaryTrack",W(ve,y.primary.main,.5)),N(y.Slider,"secondaryTrack",W(ve,y.secondary.main,.5)),N(y.Slider,"errorTrack",W(ve,y.error.main,.5)),N(y.Slider,"infoTrack",W(ve,y.info.main,.5)),N(y.Slider,"successTrack",W(ve,y.success.main,.5)),N(y.Slider,"warningTrack",W(ve,y.warning.main,.5));const V=S?W(Se,y.background.default,.985):ao(y.background.default,.98);N(y.SnackbarContent,"bg",V),N(y.SnackbarContent,"color",mt(()=>S?Hi.text.primary:y.getContrastText(V))),N(y.SpeedDialAction,"fabHoverBg",ao(y.background.paper,.15)),N(y.StepConnector,"border",M("palette-grey-600")),N(y.StepContent,"border",M("palette-grey-600")),N(y.Switch,"defaultColor",M("palette-grey-300")),N(y.Switch,"defaultDisabledColor",M("palette-grey-600")),N(y.Switch,"primaryDisabledColor",W(ve,y.primary.main,.55)),N(y.Switch,"secondaryDisabledColor",W(ve,y.secondary.main,.55)),N(y.Switch,"errorDisabledColor",W(ve,y.error.main,.55)),N(y.Switch,"infoDisabledColor",W(ve,y.info.main,.55)),N(y.Switch,"successDisabledColor",W(ve,y.success.main,.55)),N(y.Switch,"warningDisabledColor",W(ve,y.warning.main,.55)),N(y.TableCell,"border",W(ve,W(er,y.divider,1),.68)),N(y.Tooltip,"bg",W(er,y.grey[700],.92))}Ct(y.background,"default"),Ct(y.background,"paper"),Ct(y.common,"background"),Ct(y.common,"onBackground"),Ct(y,"divider"),Object.keys(y).forEach(V=>{const Q=y[V];V!=="tonalOffset"&&Q&&typeof Q=="object"&&(Q.main&&N(y[V],"mainChannel",Hr(Ur(Q.main))),Q.light&&N(y[V],"lightChannel",Hr(Ur(Q.light))),Q.dark&&N(y[V],"darkChannel",Hr(Ur(Q.dark))),Q.contrastText&&N(y[V],"contrastTextChannel",Hr(Ur(Q.contrastText))),V==="text"&&(Ct(y[V],"primary"),Ct(y[V],"secondary")),V==="action"&&(Q.active&&Ct(y[V],"active"),Q.selected&&Ct(y[V],"selected")))})}),a=o.reduce((ee,y)=>Xe(ee,y),a);const z={prefix:d,disableCssColorScheme:s,shouldSkipGeneratingVar:l,getSelector:rd(a),enableContrastVars:c},{vars:R,generateThemeVars:q,generateStyleSheets:K}=kc(a,z);return a.vars=R,Object.entries(a.colorSchemes[a.defaultColorScheme]).forEach(([ee,y])=>{a[ee]=y}),a.generateThemeVars=q,a.generateStyleSheets=K,a.generateSpacing=function(){return Ni(m.spacing,an(this))},a.getColorSchemeSelector=Tc(u),a.spacing=a.generateSpacing(),a.shouldSkipGeneratingVar=l,a.unstable_sxConfig={...Oo,...m==null?void 0:m.unstable_sxConfig},a.unstable_sx=function(y){return Ao({sx:y,theme:this})},a.toRuntimeSource=Yi,a}function oi(t,o,n){t.colorSchemes&&n&&(t.colorSchemes[o]={...n!==!0&&n,palette:dn({...n===!0?{}:n.palette,mode:o})})}function ad(t={},...o){const{palette:n,cssVariables:i=!1,colorSchemes:s=n?void 0:{light:!0},defaultColorScheme:d=n==null?void 0:n.mode,...c}=t,l=d||"light",u=s==null?void 0:s[l],f={...s,...n?{[l]:{...typeof u!="boolean"&&u,palette:n}}:void 0};if(i===!1){if(!("colorSchemes"in t))return en(t,...o);let m=n;"palette"in t||f[l]&&(f[l]!==!0?m=f[l].palette:l==="dark"&&(m={mode:"dark"}));const h=en({...t,palette:m},...o);return h.defaultColorScheme=l,h.colorSchemes=f,h.palette.mode==="light"&&(h.colorSchemes.light={...f.light!==!0&&f.light,palette:h.palette},oi(h,"dark",f.dark)),h.palette.mode==="dark"&&(h.colorSchemes.dark={...f.dark!==!0&&f.dark,palette:h.palette},oi(h,"light",f.light)),h}return!n&&!("light"in f)&&l==="light"&&(f.light=!0),sd({...c,colorSchemes:f,defaultColorScheme:l,...typeof i!="boolean"&&i},...o)}const ld=ad();function zt(){const t=xc(ld);return process.env.NODE_ENV!=="production"&&vo.useDebugValue(t),t[rl]||t}async function cd(t,o,n){try{new URL(t)}catch{throw new Error("Please enter a valid URL")}const i={"Content-Type":"application/json"};o&&(i.Authorization=`Bearer ${o}`);const s=new AbortController,d=setTimeout(()=>s.abort(),3e4);let c;try{c=await fetch(t,{headers:i,signal:s.signal})}catch(f){throw clearTimeout(d),(f==null?void 0:f.name)==="AbortError"?new Error("Request timed out after 30 seconds"):new Error("Failed to fetch — check the URL and your network connection")}finally{clearTimeout(d)}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 m=["data","results","items","records"].find(h=>l[h]&&Array.isArray(l[h]));if(m)u=l[m];else throw new Error("API response must be a JSON array, or specify the data path key.")}return{data:u,source:t,fetchedAt:new Date().toISOString()}}function dd(t,o){return o.map(n=>`${n.x}px ${n.y}px ${n.blur}px ${n.spread}px ${k(t.palette.common.black,n.opacity)}`).join(", ")}const ud={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 te(t,o){return dd(t,ud[o])}function Me(t){return`${Number(t.shape.borderRadius)*1.5}px`}function Xr(t){return`${Number(t.shape.borderRadius)}px`}function pd({isOpen:t,onClose:o,onCreate:n,preloadedData:i,preloadedDataLabel:s}){const[d,c]=p.useState(""),[l,u]=p.useState(!1),[f,m]=p.useState(""),[h,x]=p.useState(null),[b,D]=p.useState(null),[g,j]=p.useState(!1),[w,I]=p.useState(""),v=p.useRef(null),[S,C]=p.useState("json"),[a,z]=p.useState(""),[R,q]=p.useState(""),[K,ee]=p.useState(""),[y,M]=p.useState("idle"),[W,V]=p.useState(""),[Q,xe]=p.useState(null),[de,L]=p.useState(0),A=async P=>{if(I(""),!P.name.endsWith(".json")){I("Only .json files are allowed");return}const ne=10*1024*1024;if(P.size>ne){I("File size exceeds 10MB limit");return}try{const ce=await P.text();let ae;try{ae=JSON.parse(ce)}catch{I("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(ae)){I("JSON must be an array of objects");return}if(ae.length===0){I("No data rows found in JSON file");return}x(P),D(ae)}catch{I("Network error — please try again")}},H=P=>{P.preventDefault();const ne=P.dataTransfer.files[0];ne&&A(ne)},ie=async()=>{if(a.trim()){M("loading"),V("");try{const P=await cd(a.trim(),R.trim()||void 0,K.trim()||void 0);xe(P.data),L(P.data.length),M("ready")}catch(P){V((P==null?void 0:P.message)||"Connection failed"),M("error")}}},Y=()=>{if(!d.trim()){u(!0);return}const P=S==="api"?Q:i||b;P&&(n(d.trim(),f.trim(),P),re())},re=()=>{c(""),u(!1),m(""),x(null),D(null),I(""),C("json"),z(""),q(""),ee(""),M("idle"),V(""),xe(null),L(0),o()},se=i||b,oe=l&&!d.trim();return d.trim(),e.jsxs(e.Fragment,{children:[e.jsxs(r.Dialog,{open:t,onClose:re,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:P=>Me(P),width:480,maxHeight:"min(720px, calc(100vh - 120px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:P=>te(P,"menu")}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2.5,fontWeight:500,fontSize:"1.125rem",color:"text.primary",letterSpacing:"-0.01em",borderBottom:"1px solid",borderColor:"divider"},children:["Create new report",e.jsx(r.IconButton,{onClick:re,size:"small",sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(B.Close,{sx:{fontSize:18}})})]}),e.jsx(r.DialogContent,{sx:{px:3,pt:2,pb:2,overflowY:"auto"},children:e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:2,pt:2},children:[e.jsx(r.TextField,{label:"Report name",required:!0,fullWidth:!0,value:d,onChange:P=>{c(P.target.value),l&&P.target.value.trim()&&u(!1)},placeholder:"Enter report name",autoFocus:!0,error:oe,helperText:oe?"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}}}}),e.jsx(r.TextField,{label:"Description (optional)",fullWidth:!0,multiline:!0,rows:2,value:f,onChange:P=>m(P.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}}}}),e.jsxs(r.Tabs,{value:S==="json"?0:1,onChange:(P,ne)=>{C(ne===0?"json":"api"),M("idle"),V("")},variant:"fullWidth",sx:{borderBottom:1,borderColor:"divider",minHeight:40},children:[e.jsx(r.Tab,{label:"Upload JSON",icon:e.jsx(B.Description,{fontSize:"small"}),iconPosition:"start",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,minHeight:40,py:.5}}),e.jsx(r.Tab,{label:"Connect API",icon:e.jsx(B.Api,{fontSize:"small"}),iconPosition:"start",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,minHeight:40,py:.5}})]}),S==="json"&&e.jsx(r.Box,{children:i?e.jsxs(r.Box,{sx:{border:"1.5px solid",borderColor:"success.main",borderRadius:2,p:2.5,bgcolor:P=>k(P.palette.success.main,.04),display:"flex",alignItems:"center",gap:2},children:[e.jsx(r.Box,{sx:{width:36,height:36,borderRadius:"50%",bgcolor:P=>k(P.palette.success.main,.12),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(B.CheckCircle,{sx:{fontSize:20,color:"success.main"}})}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.dark",fontSize:"0.875rem"},children:s||`${i.length.toLocaleString()} records loaded`}),e.jsx(r.Typography,{variant:"caption",sx:{color:"text.secondary"},children:"Data source is connected — ready to create"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:1.25},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"Data source"}),e.jsx(r.IconButton,{size:"small",onClick:()=>j(!0),sx:{p:.25,color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:e.jsx(B.Info,{sx:{fontSize:16}})})]}),e.jsxs(r.Box,{onDrop:H,onDragOver:P=>P.preventDefault(),onPaste:P=>P.preventDefault(),onClick:()=>{var P;return(P=v.current)==null?void 0:P.click()},sx:{position:"relative",border:"1.5px",borderStyle:b?"solid":"dashed",borderColor:b?"success.main":w?"error.main":"primary.main",borderRadius:2,p:3,textAlign:"center",cursor:"pointer",bgcolor:b?P=>k(P.palette.success.main,.04):w?P=>k(P.palette.error.main,.04):P=>k(P.palette.primary.main,.04),transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:b?P=>k(P.palette.success.main,.08):w?P=>k(P.palette.error.main,.08):P=>k(P.palette.primary.main,.08),borderColor:b?"success.dark":w?"error.dark":"primary.dark"}},children:[e.jsx(r.Box,{component:"input",ref:v,type:"file",accept:".json",sx:{display:"none"},onChange:P=>{var ne;return((ne=P.target.files)==null?void 0:ne[0])&&A(P.target.files[0])}}),b?e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:.75,animation:"fadeIn 0.2s ease-in","@keyframes fadeIn":{from:{opacity:0,transform:"scale(0.98)"},to:{opacity:1,transform:"scale(1)"}}},children:[e.jsx(r.Box,{sx:{width:40,height:40,borderRadius:"50%",bgcolor:P=>k(P.palette.success.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:.5},children:e.jsx(B.CheckCircle,{sx:{fontSize:24,color:"success.main"}})}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.main",fontSize:"0.875rem"},children:h==null?void 0:h.name}),e.jsx(r.Typography,{variant:"caption",sx:{color:"success.dark",fontSize:"0.75rem"},children:"Ready to create"})]}):e.jsxs(r.Box,{children:[e.jsx(r.Box,{sx:{width:48,height:48,borderRadius:"50%",bgcolor:P=>k(P.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mx:"auto",mb:1.5},children:e.jsx(B.CloudUpload,{sx:{fontSize:28,color:"primary.main"}})}),e.jsx(r.Typography,{variant:"body2",sx:{color:"text.primary",fontSize:"0.875rem",fontWeight:500,mb:.25},children:"Upload JSON file"}),e.jsx(r.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.75rem",display:"block"},children:"Click to browse or drag and drop"}),w&&e.jsx(r.Box,{sx:{mt:1.25,p:.75,borderRadius:1,bgcolor:P=>k(P.palette.error.main,.08),border:1,borderColor:P=>k(P.palette.error.main,.2)},children:e.jsx(r.Typography,{variant:"caption",sx:{color:"error.main",fontSize:"0.6875rem",fontWeight:500},children:w})})]})]})]})}),S==="api"&&e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[e.jsx(r.TextField,{label:"API Endpoint URL",required:!0,fullWidth:!0,size:"small",value:a,onChange:P=>{z(P.target.value),M("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}}}}),e.jsx(r.TextField,{label:"API Key (optional)",fullWidth:!0,size:"small",value:R,onChange:P=>q(P.target.value),placeholder:"Leave blank if no auth required",InputProps:{startAdornment:e.jsx(r.InputAdornment,{position:"start",children:e.jsx(B.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}}}}),e.jsx(r.TextField,{label:"Response data path (optional)",fullWidth:!0,size:"small",value:K,onChange:P=>ee(P.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}}}),e.jsx(r.Button,{variant:"outlined",fullWidth:!0,disabled:!a.trim()||y==="loading",onClick:ie,startIcon:y==="loading"?e.jsx(r.CircularProgress,{size:16,color:"inherit"}):e.jsx(B.Api,{}),sx:{fontSize:"0.875rem",borderRadius:1,py:.875,borderColor:"primary.main",color:"primary.main","&:hover":{bgcolor:P=>k(P.palette.primary.main,.04),borderColor:"primary.dark"},"&:disabled":{borderColor:"action.disabledBackground",color:"action.disabled"}},children:y==="loading"?"Connecting...":"Test Connection & Load Data"}),y==="ready"&&e.jsxs(r.Box,{sx:{border:"1.5px solid",borderColor:"success.main",borderRadius:2,p:2,bgcolor:P=>k(P.palette.success.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[e.jsx(B.CheckCircle,{sx:{fontSize:20,color:"success.main",flexShrink:0,mt:.1}}),e.jsxs(r.Box,{children:[e.jsxs(r.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.dark",fontSize:"0.875rem"},children:[de.toLocaleString()," records loaded — ready to create"]}),e.jsx(r.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.75rem",wordBreak:"break-all",display:"block",mt:.25},children:a})]})]}),y==="error"&&e.jsxs(r.Box,{sx:{border:"1.5px solid",borderColor:"error.main",borderRadius:2,p:2,bgcolor:P=>k(P.palette.error.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[e.jsx(B.ErrorOutline,{sx:{fontSize:20,color:"error.main",flexShrink:0,mt:.1}}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,color:"error.main",fontSize:"0.875rem"},children:"Connection failed"}),e.jsx(r.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.75rem",display:"block",mt:.25},children:W})]})]})]})]})}),e.jsxs(r.DialogActions,{sx:{px:3,py:2,gap:1,borderTop:"1px solid",borderColor:"divider"},children:[e.jsx(r.Button,{onClick:re,variant:"text",sx:{color:"primary.main",fontSize:"0.875rem",borderRadius:P=>`${P.shape.borderRadius}px`,px:2,py:.625,minWidth:64,"&:hover":{bgcolor:P=>k(P.palette.primary.main,.04)}},children:"Cancel"}),e.jsx(r.Button,{onClick:Y,disabled:S==="json"&&!se||S==="api"&&y!=="ready",variant:"contained",sx:{fontSize:"0.875rem",borderRadius:P=>`${P.shape.borderRadius}px`,px:2.5,py:.625,minWidth:64,"&:disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Create"})]})]}),e.jsxs(r.Dialog,{open:g,onClose:()=>j(!1),maxWidth:"sm",PaperProps:{sx:{borderRadius:3,width:560,maxHeight:"80vh",boxShadow:8}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,fontWeight:500,fontSize:"1.25rem",color:"text.primary",letterSpacing:"-0.01em"},children:["JSON format guide",e.jsx(r.IconButton,{onClick:()=>j(!1),size:"small",sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:e.jsx(B.Close,{sx:{fontSize:20}})})]}),e.jsx(r.DialogContent,{sx:{px:3,py:2},children:e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Required format"}),e.jsx(r.Typography,{variant:"body2",sx:{color:"text.secondary",fontSize:"0.8125rem",lineHeight:1.5},children:"Your JSON file must be an array of objects. Each object represents a row, and all should have the same field names."})]}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Example structure"}),e.jsx(r.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:`[
70
70
  {
71
71
  "id": 1,
72
72
  "customerName": "John Smith",
@@ -76,7 +76,7 @@ To suppress this warning, you need to explicitly provide the \`palette.${o}Chann
76
76
  "memberSince": "2024-01-15",
77
77
  "status": "active"
78
78
  }
79
- ]`})]}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Supported data types"}),e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"Text, numbers, booleans, dates, and null values"})]}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Guidelines"}),e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:.5},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"• Must be valid JSON with array format"}),e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"• All objects should have consistent field names"}),e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:'• Field names auto-format (e.g., "customerName" → "Customer Name")'})]})]})]})}),e.jsx(r.DialogActions,{sx:{px:3,py:2},children:e.jsx(r.Button,{onClick:()=>C(!1),variant:"contained",sx:{fontSize:"0.875rem",borderRadius:P=>`${P.shape.borderRadius}px`,px:2.5,py:.625,minWidth:64},children:"Got it"})})]})]})}function Xi({isOpen:t,onClose:o}){return t?e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"md",fullWidth:!0,PaperProps:{sx:{borderRadius:n=>Me(n),maxHeight:"min(640px, calc(100vh - 180px))",my:"auto",boxShadow:n=>te(n,"menu"),display:"flex",flexDirection:"column"}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:["JSON Format Guide",e.jsx(r.IconButton,{onClick:o,size:"small",sx:{color:"text.secondary"},children:e.jsx(z.Close,{sx:{fontSize:20}})})]}),e.jsx(r.DialogContent,{dividers:!0,sx:{overflowY:"auto",flex:1},children:e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:3,py:1},children:[e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Expected JSON Structure"}),e.jsxs(r.Typography,{variant:"body2",color:"text.secondary",children:["The uploaded JSON must be an ",e.jsx("strong",{children:"array of objects"}),". Each object represents a single row in your report, and the keys of each object become the column names."]})]}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Example JSON"}),e.jsx(r.Paper,{elevation:0,sx:{p:2,bgcolor:"action.hover",border:1,borderColor:"divider",borderRadius:1,overflowX:"auto"},children:e.jsx(r.Box,{component:"pre",sx:{fontSize:"caption.fontSize",fontFamily:"monospace",m:0},children:`[
79
+ ]`})]}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Supported data types"}),e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"Text, numbers, booleans, dates, and null values"})]}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Guidelines"}),e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:.5},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"• Must be valid JSON with array format"}),e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"• All objects should have consistent field names"}),e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:'• Field names auto-format (e.g., "customerName" → "Customer Name")'})]})]})]})}),e.jsx(r.DialogActions,{sx:{px:3,py:2},children:e.jsx(r.Button,{onClick:()=>j(!1),variant:"contained",sx:{fontSize:"0.875rem",borderRadius:P=>`${P.shape.borderRadius}px`,px:2.5,py:.625,minWidth:64},children:"Got it"})})]})]})}function Ji({isOpen:t,onClose:o}){return t?e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"md",fullWidth:!0,PaperProps:{sx:{borderRadius:n=>Me(n),maxHeight:"min(640px, calc(100vh - 180px))",my:"auto",boxShadow:n=>te(n,"menu"),display:"flex",flexDirection:"column"}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:["JSON Format Guide",e.jsx(r.IconButton,{onClick:o,size:"small",sx:{color:"text.secondary"},children:e.jsx(B.Close,{sx:{fontSize:20}})})]}),e.jsx(r.DialogContent,{dividers:!0,sx:{overflowY:"auto",flex:1},children:e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:3,py:1},children:[e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Expected JSON Structure"}),e.jsxs(r.Typography,{variant:"body2",color:"text.secondary",children:["The uploaded JSON must be an ",e.jsx("strong",{children:"array of objects"}),". Each object represents a single row in your report, and the keys of each object become the column names."]})]}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Example JSON"}),e.jsx(r.Paper,{elevation:0,sx:{p:2,bgcolor:"action.hover",border:1,borderColor:"divider",borderRadius:1,overflowX:"auto"},children:e.jsx(r.Box,{component:"pre",sx:{fontSize:"caption.fontSize",fontFamily:"monospace",m:0},children:`[
80
80
  {
81
81
  "Active Sessions": 33,
82
82
  "Active State": true,
@@ -86,10 +86,10 @@ To suppress this warning, you need to explicitly provide the \`palette.${o}Chann
86
86
  "Region": "Europe",
87
87
  "Subscription Type": "Basic"
88
88
  }
89
- ]`})})]}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Supported Column Types"}),e.jsx(r.Typography,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:"The system automatically detects column types from your data:"}),e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:[e.jsxs(r.Box,{sx:{display:"flex",gap:1},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,minWidth:80},children:"Number:"}),e.jsxs(r.Typography,{variant:"body2",color:"text.secondary",children:["Numeric values (e.g.,"," ",e.jsx(r.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"33"}),","," ",e.jsx(r.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"42.5"}),")"]})]}),e.jsxs(r.Box,{sx:{display:"flex",gap:1},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,minWidth:80},children:"Boolean:"}),e.jsxs(r.Typography,{variant:"body2",color:"text.secondary",children:["True/false values (e.g.,"," ",e.jsx(r.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"true"}),","," ",e.jsx(r.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"false"}),")"]})]}),e.jsxs(r.Box,{sx:{display:"flex",gap:1},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,minWidth:80},children:"String:"}),e.jsxs(r.Typography,{variant:"body2",color:"text.secondary",children:["Text values (e.g.,"," ",e.jsx(r.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"Europe"'}),","," ",e.jsx(r.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"Analytics Pro"'}),")"]})]}),e.jsxs(r.Box,{sx:{display:"flex",gap:1},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,minWidth:80},children:"Date:"}),e.jsxs(r.Typography,{variant:"body2",color:"text.secondary",children:["ISO date strings (e.g.,"," ",e.jsx(r.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"2024-08-22"'}),")"]})]})]})]}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Notes"}),e.jsxs(r.Box,{component:"ul",sx:{m:0,pl:2.5,"& li":{fontSize:"body2.fontSize",color:"text.secondary",mb:.5}},children:[e.jsx("li",{children:"Each object in the array represents one row in the report."}),e.jsx("li",{children:"The keys of the JSON objects become report columns."}),e.jsx("li",{children:"All objects should have consistent keys for proper column detection."}),e.jsx("li",{children:"Column names are case-sensitive and preserve spacing."})]})]})]})}),e.jsx(r.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:e.jsx(r.Button,{onClick:o,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",px:3,py:.875,minHeight:36,borderRadius:n=>`${n.shape.borderRadius}px`,boxShadow:n=>te(n,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:n=>te(n,"hoverButton")},"&:active":{boxShadow:n=>te(n,"pressedButton"),transform:"translateY(1px)"}},children:"Got it"})})]}):null}function bd({onFileUpload:t,onError:o,isUploading:n}){const[i,s]=p.useState(!1),[d,l]=p.useState(""),[c,u]=p.useState(!1),h=p.useRef(null),m=async S=>{if(!S.name.endsWith(".json")){o("Only .json files are allowed");return}const I=10*1024*1024;if(S.size>I){o("File size exceeds 10MB limit");return}l(S.name);try{const f=await S.text();let k;try{k=JSON.parse(f)}catch{o("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(k)){o("JSON must be an array of objects");return}if(k.length===0){o("No data rows found in JSON file");return}t(k)}catch{o("Network error — please try again")}finally{l("")}},b=S=>{S.preventDefault(),s(!0)},x=S=>{S.preventDefault(),s(!1)},y=S=>{S.preventDefault(),s(!1);const I=S.dataTransfer.files[0];I&&m(I)},D=()=>{var S;(S=h.current)==null||S.click()},v=S=>{var f;const I=(f=S.target.files)==null?void 0:f[0];I&&m(I)},C=S=>{S.stopPropagation(),u(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(r.Box,{onDragOver:b,onDragLeave:x,onDrop:y,onPaste:S=>S.preventDefault(),onClick:D,sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderStyle:"dashed",borderColor:i?"primary.main":"divider",bgcolor:i?S=>T(S.palette.primary.main,.12):"transparent",borderRadius:1,px:2,py:6,cursor:"pointer",transition:"all 0.2s",opacity:n?.5:1,pointerEvents:n?"none":"auto","&:hover":{borderColor:i?"primary.main":"text.secondary"}},children:[e.jsx(r.Box,{component:"input",ref:h,type:"file",accept:".json",onChange:v,sx:{display:"none"}}),n?e.jsxs(e.Fragment,{children:[e.jsx(r.CircularProgress,{size:32,sx:{mb:2}}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,mb:.5},children:"Uploading..."}),d&&e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:d})]}):e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:S=>T(S.palette.primary.main,.12),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(z.UploadFile,{sx:{fontSize:32,color:"primary.main"}})}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:1.5},children:[e.jsx(r.Button,{variant:"contained",sx:{fontWeight:500},children:"Upload Data (JSON)"}),e.jsx(r.IconButton,{onClick:C,size:"small",sx:{border:1,borderColor:"divider","&:hover":{borderColor:"text.secondary",bgcolor:"action.hover"}},title:"View JSON format guide",children:e.jsx(z.InfoOutlined,{sx:{fontSize:16}})})]}),e.jsx(r.Typography,{variant:"body2",color:"text.secondary",sx:{textAlign:"center",maxWidth:500},children:"Upload structured JSON data to generate your report."}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",sx:{mt:1},children:"Click to browse or drag and drop a JSON file here"})]})]}),e.jsx(Xi,{isOpen:c,onClose:()=>u(!1)})]})}function vd({schema:t,onConfirm:o,hasConflicts:n}){return e.jsxs(r.Paper,{sx:{border:2,borderColor:"divider",p:3},children:[e.jsxs(r.Box,{sx:{mb:2},children:[e.jsx(r.Typography,{variant:"h6",sx:{fontWeight:600,mb:.5},children:"Schema Preview"}),e.jsx(r.Typography,{variant:"body2",color:"text.secondary",children:"Review the detected schema before generating your table"})]}),n&&e.jsxs(r.Alert,{severity:"warning",sx:{mb:2},children:[e.jsx(r.AlertTitle,{sx:{fontWeight:600},children:"Schema Conflict Detected"}),"Some columns have inconsistent data types across rows. Please resolve these conflicts before proceeding."]}),e.jsx(r.TableContainer,{sx:{mb:3},children:e.jsxs(r.Table,{children:[e.jsx(r.TableHead,{children:e.jsxs(r.TableRow,{sx:{bgcolor:"action.hover"},children:[e.jsx(r.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Column Name"}),e.jsx(r.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Detected Type"}),e.jsx(r.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Status"})]})}),e.jsx(r.TableBody,{children:t.map(i=>e.jsxs(r.TableRow,{sx:{bgcolor:i.hasConflict?s=>T(s.palette.warning.main,.12):"transparent"},children:[e.jsxs(r.TableCell,{sx:{fontWeight:500},children:[i.name,i.hasConflict&&e.jsx(r.Box,{component:"span",sx:{ml:1,color:"warning.main"},children:"⚠"})]}),e.jsx(r.TableCell,{children:e.jsx(r.Chip,{label:i.type,size:"small",sx:{bgcolor:"action.hover"}})}),e.jsx(r.TableCell,{children:e.jsx(r.Chip,{label:i.required?"Required":"Optional",size:"small",color:i.required?"success":"default"})})]},i.name))})]})}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pt:2,borderTop:1,borderColor:"divider"},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(z.Lock,{sx:{fontSize:16}}),e.jsx(r.Typography,{variant:"body2",color:"text.secondary",children:"Schema will be locked for this report"})]}),e.jsx(r.Button,{variant:"contained",onClick:o,disabled:n,sx:{fontWeight:500},children:"Generate Table"})]})]})}function Sd({error:t,onRetry:o}){return e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderColor:"error.light",bgcolor:n=>T(n.palette.error.main,.12),borderRadius:1,px:2,py:6},children:[e.jsx(r.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:n=>T(n.palette.error.main,.3),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(z.ErrorOutline,{color:"error",sx:{fontSize:32}})}),e.jsx(r.Typography,{variant:"h6",color:"error.main",sx:{fontWeight:600,mb:1},children:"Upload Failed"}),e.jsx(r.Typography,{variant:"body2",color:"error.main",sx:{textAlign:"center",maxWidth:500,mb:3},children:t}),e.jsx(r.Button,{variant:"contained",color:"error",startIcon:e.jsx(z.Upload,{sx:{fontSize:16}}),onClick:o,sx:{fontWeight:500},children:"Try Again"})]})}function Qi({title:t,description:o,showIcon:n=!0}){return e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"60vh",px:3,py:8},children:[n&&e.jsx(r.Box,{sx:{width:80,height:80,borderRadius:"50%",bgcolor:i=>T(i.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:3},children:e.jsx(z.Description,{sx:{fontSize:36,color:"primary.main"}})}),e.jsx(r.Typography,{variant:"h5",sx:{fontWeight:500,mb:1,color:"text.primary",fontSize:"1.125rem"},children:t}),e.jsx(r.Typography,{variant:"body1",sx:{textAlign:"center",maxWidth:520,color:"text.secondary",fontSize:"0.875rem",lineHeight:1.5},children:o})]})}function jd({value:t,onChange:o,searchHistory:n,onAddToHistory:i,onToggleFavourite:s,onDeleteHistory:d,disabled:l}){const[c,u]=p.useState(!1),[h,m]=p.useState(!1),[b,x]=p.useState(-1),y=p.useRef(null),D=p.useRef(null);p.useEffect(()=>{function R(J){y.current&&!y.current.contains(J.target)&&(u(!1),m(!1))}return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[]);const v=p.useCallback(()=>{m(!0),x(-1),n.length>0&&u(!0)},[n.length]),C=p.useCallback(R=>{o(R),x(-1)},[o]),S=p.useCallback(R=>{var J;o(R),i(R),u(!1),(J=D.current)==null||J.blur()},[o,i]),I=p.useCallback(R=>{x(-1),S(R)},[S]),f=p.useCallback(R=>{var J;R.key==="Enter"?b>=0&&b<n.length?(R.preventDefault(),I(n[b].query)):t.trim()&&S(t.trim()):R.key==="Escape"?(u(!1),x(-1),(J=D.current)==null||J.blur()):R.key==="ArrowDown"?(R.preventDefault(),n.length>0&&(c||u(!0),x(K=>K<n.length-1?K+1:K))):R.key==="ArrowUp"&&(R.preventDefault(),x(K=>K>0?K-1:-1))},[b,n,t,c,I,S]),k=p.useCallback(()=>{var R;o(""),(R=D.current)==null||R.focus()},[o]),j=p.useMemo(()=>n.filter(R=>R.isFavourite),[n]),a=p.useMemo(()=>n.filter(R=>!R.isFavourite),[n]),B=c&&n.length>0;return e.jsxs(r.Box,{sx:{position:"relative",width:240},ref:y,children:[e.jsx(r.TextField,{inputRef:D,size:"small",fullWidth:!0,value:t,onChange:R=>C(R.target.value),onFocus:v,onKeyDown:f,placeholder:"Search data...",disabled:l,sx:{"& .MuiOutlinedInput-root":{borderRadius:"20px",fontSize:"0.875rem",bgcolor:"background.paper",height:"36px","& fieldset":{borderColor:R=>T(R.palette.text.primary,.3),transition:"all 0.15s ease"},"&:hover":{bgcolor:"action.hover"},"&:hover fieldset":{borderColor:R=>T(R.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:e.jsx(r.InputAdornment,{position:"start",sx:{ml:.5},children:e.jsx(z.Search,{sx:{fontSize:18,color:"text.secondary"}})}),endAdornment:t?e.jsx(r.InputAdornment,{position:"end",children:e.jsx(r.IconButton,{size:"small",onClick:k,edge:"end",sx:{mr:-.5},children:e.jsx(z.Close,{sx:{fontSize:16}})})}):null}}),B&&e.jsxs(r.Paper,{sx:{position:"absolute",zIndex:50,mt:.5,width:"100%",maxHeight:384,overflowY:"auto"},elevation:3,children:[j.length>0&&e.jsxs(r.Box,{sx:{py:1},children:[e.jsx(r.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:600,textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Favourite Searches"}),j.map((R,J)=>e.jsx(ai,{entry:R,isSelected:b===J,onClick:()=>I(R.query),onToggleFavourite:()=>s(R.query),onDelete:()=>d(R.query)},`fav-${R.query}`))]}),a.length>0&&e.jsxs(r.Box,{sx:{py:1},children:[j.length>0&&e.jsx(r.Divider,{}),e.jsx(r.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:600,textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Recent Searches"}),a.map((R,J)=>{const K=j.length+J;return e.jsx(ai,{entry:R,isSelected:b===K,onClick:()=>I(R.query),onToggleFavourite:()=>s(R.query),onDelete:()=>d(R.query)},`recent-${R.query}`)})]})]})]})}const ai=p.memo(function({entry:o,isSelected:n,onClick:i,onToggleFavourite:s,onDelete:d}){const l=p.useCallback(u=>{u.stopPropagation(),s()},[s]),c=p.useCallback(u=>{u.stopPropagation(),d()},[d]);return e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:1.5,py:1,cursor:"pointer",bgcolor:n?u=>T(u.palette.primary.main,.12):"transparent","&:hover":{bgcolor:n?u=>T(u.palette.primary.main,.12):"action.hover"}},children:[e.jsx(r.Box,{sx:{flex:1,minWidth:0},onClick:i,children:e.jsx(r.Typography,{variant:"body2",noWrap:!0,children:o.query})}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5,ml:1},children:[e.jsx(r.IconButton,{size:"small",onClick:l,title:o.isFavourite?"Remove from favourites":"Add to favourites",sx:{p:.5},children:o.isFavourite?e.jsx(z.Star,{sx:{fontSize:14,color:"warning.light"}}):e.jsx(z.StarBorder,{sx:{fontSize:14,color:"action.disabled"}})}),e.jsx(r.IconButton,{size:"small",onClick:c,title:"Delete from history",sx:{p:.5,"&:hover":{color:"error.main"}},children:e.jsx(z.Delete,{sx:{fontSize:14,opacity:.5}})})]})]})});function Cd({views:t,activeViewId:o,isDirty:n,onSelectView:i,onCreateView:s,onManageViews:d,onToggleDefault:l,onToggleFavorite:c,onRestoreView:u,onPermanentDelete:h,isReadOnly:m,isAdmin:b=!1}){const x=At(),[y,D]=p.useState(!1),[v,C]=p.useState(!1),[S,I]=p.useState({top:0,left:0}),[f,k]=p.useState(null),j=p.useRef(null),a=p.useRef(null),B=t.find(A=>A.id===o),R=B==null?void 0:B.isDefault,J=t.filter(A=>A.scope==="global"&&!A.isDeleted),K=t.filter(A=>A.scope!=="global"&&!A.isDeleted),ee=t.filter(A=>A.isFavorite&&!A.isDeleted).sort((A,H)=>(H.updatedAt||0)-(A.updatedAt||0)),g=t.filter(A=>A.isDeleted);p.useEffect(()=>{if(y&&a.current){const A=a.current.getBoundingClientRect();I({top:A.bottom+window.scrollY+8,left:A.right+window.scrollX-320})}},[y]),p.useEffect(()=>{const A=H=>{j.current&&!j.current.contains(H.target)&&a.current&&!a.current.contains(H.target)&&D(!1)};return y&&document.addEventListener("mousedown",A),()=>{document.removeEventListener("mousedown",A)}},[y]);const M=A=>{if(n&&A!==o){k(A),D(!1);return}i(A),D(!1)},W=()=>{f&&(i(f),k(null))},V=()=>{k(null)},Q=(A,H=!1)=>{const se=A.scope==="global",G=!m&&(!se||b);return e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:o===A.id?T(x.palette.primary.main,.12):"transparent",transition:"background-color 0.2s","&:hover":{backgroundColor:o===A.id?T(x.palette.primary.main,.12):x.palette.action.hover}},children:[e.jsxs(r.Button,{onClick:()=>M(A.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:[o===A.id&&e.jsx(z.Check,{sx:{fontSize:16,flexShrink:0}}),o!==A.id&&e.jsx(r.Box,{sx:{width:"16px",flexShrink:0}}),e.jsx(r.Typography,{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:o===A.id?x.palette.primary.dark:x.palette.text.primary,fontWeight:o===A.id?500:400},children:A.name}),H&&e.jsx(r.Typography,{component:"span",sx:{fontSize:"caption.fontSize",color:x.palette.text.secondary,backgroundColor:x.palette.action.selected,px:1,py:.25,borderRadius:1,flexShrink:0},children:"Default"})]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[G&&c&&e.jsx(r.IconButton,{onClick:re=>{re.stopPropagation(),c(A.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:x.palette.action.hover}},title:A.isFavorite?"Remove from favorites":"Add to favorites",children:e.jsx(z.Star,{sx:{fontSize:16}})}),G&&l&&!A.isDefault&&e.jsx(r.IconButton,{onClick:re=>{re.stopPropagation(),l(A.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:x.palette.action.hover}},title:"Set as default",children:e.jsx(z.RadioButtonUnchecked,{sx:{fontSize:16}})})]})]},A.id)},xe=A=>e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:x.palette.action.hover},children:[e.jsx(r.Typography,{sx:{color:x.palette.text.secondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:A.name}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[u&&e.jsx(r.IconButton,{onClick:H=>{H.stopPropagation(),u(A.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:x.palette.action.hover}},title:"Restore view",children:e.jsx(z.Undo,{sx:{fontSize:16,color:"success.main"}})}),h&&e.jsx(r.IconButton,{onClick:H=>{H.stopPropagation(),h(A.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:x.palette.action.hover}},title:"Delete permanently",children:e.jsx(z.Delete,{sx:{fontSize:16,color:"error.main"}})})]})]},A.id),me=n||!R,L=n;return e.jsxs(r.Box,{sx:{position:"relative"},children:[e.jsxs(r.IconButton,{ref:a,onClick:()=>D(!y),size:"small",sx:{position:"relative",color:me?"warning.main":"text.secondary",bgcolor:me?T(x.palette.warning.main,.12):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:me?T(x.palette.warning.main,.2):T(x.palette.text.primary,.06),color:me?"warning.dark":"text.primary"}},title:`View: ${(B==null?void 0:B.name)||"Default View"}`,children:[e.jsx(z.Visibility,{sx:{fontSize:20}}),L&&e.jsx(r.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:8,height:8,borderRadius:"50%",bgcolor:"warning.main",border:"2px solid",borderColor:"background.paper"}})]}),y&&bi.createPortal(e.jsxs(r.Box,{ref:j,sx:{position:"fixed",width:"320px",backgroundColor:x.palette.background.paper,border:`1px solid ${x.palette.divider}`,borderRadius:1,boxShadow:x.shadows[8],zIndex:50,maxHeight:"500px",overflowY:"auto",top:S.top,left:S.left},children:[J.length>0&&e.jsxs(r.Box,{sx:{py:.5},children:[e.jsx(r.Typography,{sx:{px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:x.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Global Views"}),J.map(A=>Q(A,A.isDefault))]}),ee.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{borderTop:`1px solid ${x.palette.divider}`}}),e.jsxs(r.Box,{sx:{py:.5},children:[e.jsxs(r.Box,{sx:{px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:x.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",gap:.5},children:[e.jsx(z.Star,{sx:{fontSize:12,color:"warning.light"}}),e.jsx(r.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:"Favorite Views"})]}),ee.map(A=>Q(A))]})]}),K.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{borderTop:`1px solid ${x.palette.divider}`}}),e.jsxs(r.Box,{sx:{py:.5},children:[e.jsx(r.Typography,{sx:{px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:x.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Personal Views"}),K.map(A=>Q(A))]})]}),g.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{borderTop:`1px solid ${x.palette.divider}`}}),e.jsxs(r.Box,{sx:{py:.5},children:[e.jsxs(r.Button,{onClick:()=>C(!v),sx:{width:"100%",px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:x.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",justifyContent:"space-between",transition:"background-color 0.2s","&:hover":{backgroundColor:x.palette.action.hover}},children:[e.jsxs(r.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:["Recently Deleted (",g.length,")"]}),e.jsx(z.ChevronRight,{sx:{fontSize:16}})]}),v&&e.jsx(r.Box,{sx:{backgroundColor:x.palette.action.hover},children:g.map(A=>xe(A))})]})]}),e.jsx(r.Box,{sx:{borderTop:`1px solid ${x.palette.divider}`}}),e.jsxs(r.Button,{onClick:()=>{s(),D(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:x.palette.text.primary,justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:x.palette.action.hover}},children:[e.jsx(z.Add,{sx:{fontSize:16}}),e.jsx(r.Typography,{component:"span",sx:{fontSize:"inherit"},children:"Create New Report View"})]}),e.jsxs(r.Button,{onClick:()=>{d(),D(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:x.palette.text.primary,justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:x.palette.action.hover}},children:[e.jsx(z.Settings,{sx:{fontSize:16}}),e.jsx(r.Typography,{component:"span",sx:{fontSize:"inherit"},children:"View Setup"})]})]}),document.body),e.jsxs(r.Dialog,{open:f!==null,onClose:V,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:so(x)}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",gap:1,pb:1},children:[e.jsx(z.Warning,{sx:{fontSize:20,color:"warning.main"}}),"Unsaved changes"]}),e.jsx(r.DialogContent,{children:e.jsx(r.Typography,{variant:"body2",color:"text.secondary",children:"You have unsaved changes to the current view. Switching views will discard them."})}),e.jsxs(r.DialogActions,{sx:{px:3,pb:2,gap:1},children:[e.jsx(r.Button,{onClick:V,variant:"text",children:"Stay here"}),e.jsx(r.Button,{onClick:W,variant:"contained",color:"warning",children:"Discard & switch"})]})]})]})}function wd({columnName:t,columnType:o="string",currentSort:n,hasFilters:i,isInSortStack:s,isReadOnly:d=!1,hasModifications:l=!1,position:c,onSortAscending:u,onSortDescending:h,onRemoveSort:m,onFilter:b,onClearFilter:x,onGroupByColumn:y,onHideColumn:D,onManageColumns:v,onManageViews:C,onResetLayout:S,onClose:I}){var ee,g;const f=At(),k=f.palette,j=p.useRef(null);p.useEffect(()=>{if(!j.current)return;const M=j.current,W=M.getBoundingClientRect(),V=window.innerWidth,Q=window.innerHeight;W.right>V-8&&(M.style.left=`${V-W.width-8}px`),W.bottom>Q-8&&(M.style.top=`${Q-W.height-8}px`)},[c]),p.useEffect(()=>{const M=V=>{j.current&&!j.current.contains(V.target)&&I()},W=V=>{V.key==="Escape"&&I()};return document.addEventListener("mousedown",M),document.addEventListener("keydown",W),()=>{document.removeEventListener("mousedown",M),document.removeEventListener("keydown",W)}},[I]);const a=p.useCallback(M=>()=>{M(),I()},[I]),B=(n==null?void 0:n.direction)==="asc",R=(n==null?void 0:n.direction)==="desc",J=o==="number"?"0→9":o==="boolean"?"F→T":"A→Z",K=o==="number"?"9→0":o==="boolean"?"T→F":"Z→A";return bi.createPortal(e.jsxs(r.Paper,{ref:j,elevation:0,sx:{position:"fixed",left:`${c.x}px`,top:`${c.y}px`,zIndex:f.zIndex.tooltip,minWidth:210,maxWidth:264,border:"1px solid",borderColor:"divider",borderRadius:so(f),overflow:"hidden",boxShadow:`0 4px 20px ${T(((ee=k.common)==null?void 0:ee.black)??"#000",.12)}, 0 1px 4px ${T(((g=k.common)==null?void 0:g.black)??"#000",.06)}`},children:[!d&&e.jsxs(r.Box,{sx:{px:2,py:.75,display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid",borderColor:"divider"},children:[e.jsx(r.Typography,{sx:{fontSize:"0.8125rem",fontWeight:500,color:"text.primary"},children:"Sorting"}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.25},children:[e.jsx(r.Tooltip,{title:`Sort Ascending (${J})`,placement:"top",arrow:!0,children:e.jsx(r.IconButton,{size:"small",onClick:a(()=>u(t)),sx:{p:.625,borderRadius:"6px",color:B?"primary.main":"text.secondary",bgcolor:B?T(k.primary.main,.1):"transparent","&:hover":{bgcolor:T(k.primary.main,.08),color:"primary.main"}},children:e.jsx(z.ArrowUpward,{sx:{fontSize:16}})})}),e.jsx(r.Tooltip,{title:`Sort Descending (${K})`,placement:"top",arrow:!0,children:e.jsx(r.IconButton,{size:"small",onClick:a(()=>h(t)),sx:{p:.625,borderRadius:"6px",color:R?"primary.main":"text.secondary",bgcolor:R?T(k.primary.main,.1):"transparent","&:hover":{bgcolor:T(k.primary.main,.08),color:"primary.main"}},children:e.jsx(z.ArrowDownward,{sx:{fontSize:16}})})}),e.jsx(r.Tooltip,{title:"Clear Sort",placement:"top",arrow:!0,children:e.jsx("span",{children:e.jsx(r.IconButton,{size:"small",disabled:!s,onClick:a(()=>m(t)),sx:{p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:T(k.error.main,.08),color:"error.main"},"&.Mui-disabled":{opacity:.3}},children:e.jsx(z.Close,{sx:{fontSize:16}})})})})]})]}),e.jsxs(r.MenuList,{dense:!0,sx:{py:.5},children:[e.jsxs(r.MenuItem,{onClick:a(()=>b(t)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(z.FilterList,{sx:{fontSize:16,color:i?"primary.main":"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Filter by Column",primaryTypographyProps:{fontSize:"0.8125rem",fontWeight:i?600:400,color:i?"primary.main":"text.primary"}})]}),i&&!d&&e.jsxs(r.MenuItem,{onClick:a(()=>x(t)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:T(k.warning.main,.06),"& .MuiListItemText-primary":{color:"warning.main"},"& .MuiListItemIcon-root svg":{color:"warning.main"}}},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(z.FilterListOff,{sx:{fontSize:16,color:"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Clear Filter",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]}),!d&&y&&e.jsxs(e.Fragment,{children:[e.jsx(r.Divider,{sx:{my:.25}}),e.jsx(r.MenuList,{dense:!0,sx:{py:.5},children:e.jsxs(r.MenuItem,{onClick:a(()=>y(t)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(z.GroupWorkOutlined,{sx:{fontSize:16,color:"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Group By Column",primaryTypographyProps:{fontSize:"0.8125rem"}})]})})]}),e.jsx(r.Divider,{sx:{my:.25}}),e.jsxs(r.MenuList,{dense:!0,sx:{py:.5},children:[!d&&e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",mx:.5,borderRadius:"6px",overflow:"hidden","&:hover":{bgcolor:"action.hover"}},children:[e.jsxs(r.MenuItem,{onClick:a(()=>D(t)),sx:{flex:1,py:.75,px:1.5,minHeight:34,borderRadius:"6px 0 0 6px","&:hover":{bgcolor:"transparent"}},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(z.VisibilityOff,{sx:{fontSize:16,color:"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Hide Column",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),e.jsx(r.Tooltip,{title:"Manage Columns",placement:"top",arrow:!0,children:e.jsx(r.IconButton,{size:"small",onClick:a(v),sx:{mr:.75,p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:T(k.primary.main,.08),color:"primary.main"}},children:e.jsx(z.Settings,{sx:{fontSize:16}})})})]}),d&&e.jsxs(r.MenuItem,{onClick:a(v),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(z.Settings,{sx:{fontSize:16,color:"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Manage Columns",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),C&&e.jsxs(r.MenuItem,{onClick:a(C),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(z.TableRows,{sx:{fontSize:16,color:"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Manage Views",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),!d&&l&&S&&e.jsxs(r.MenuItem,{onClick:a(S),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:T(k.error.main,.05),"& .MuiListItemText-primary":{color:"error.main"},"& .MuiListItemIcon-root svg":{color:"error.main"}}},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(z.RestartAlt,{sx:{fontSize:16,color:"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Reset to Default Layout",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]})]}),document.body)}const kd=176,li="COLUMN_HEADER",Td=p.memo(function({column:o,index:n,sortRule:i,hasFilters:s,isInSortStack:d,isReadOnly:l=!1,hasModifications:c=!1,width:u,onColumnClick:h,onMoveColumn:m,onColumnDragEnd:b,onResizeStart:x,onSortAscending:y,onSortDescending:D,onRemoveSort:v,onOpenFilterForColumn:C,onClearFiltersForColumn:S,onGroupByColumn:I,onHideColumn:f,onManageColumns:k,onManageViews:j,onResetLayout:a}){const B=p.useRef(null),[R,J]=p.useState(!1),[K,ee]=p.useState({x:0,y:0}),[{handlerId:g,isOver:M},W]=Ot.useDrop({accept:li,collect(G){return{handlerId:G.getHandlerId(),isOver:G.isOver()}},hover(G,re){var ge;if(!B.current)return;const ae=G.index,ne=n;if(ae===ne)return;const P=(ge=B.current)==null?void 0:ge.getBoundingClientRect(),ie=(P.right-P.left)/2,pe=re.getClientOffset(),le=((pe==null?void 0:pe.x)??0)-P.left;ae<ne&&le<ie||ae>ne&&le>ie||(m(ae,ne),G.index=ne)}}),[{isDragging:V},Q]=Ot.useDrag({type:li,item:()=>({index:n,columnName:o.name}),collect:G=>({isDragging:G.isDragging()}),end:()=>{b==null||b()}});Q(W(B));const xe=p.useCallback(G=>{G.preventDefault(),G.stopPropagation(),ee({x:G.clientX,y:G.clientY}),J(!0)},[]),me=p.useCallback(()=>J(!1),[]),L=p.useCallback(()=>{h(o.name)},[h,o.name]),A=p.useCallback(G=>{G.stopPropagation(),C(o.name)},[C,o.name]),H=p.useCallback(()=>i?e.jsxs(r.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[i.direction==="asc"?e.jsx(z.ArrowUpward,{sx:{fontSize:13,color:"primary.main"}}):e.jsx(z.ArrowDownward,{sx:{fontSize:13,color:"primary.main"}}),e.jsx(r.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]),se=p.useCallback(()=>s?e.jsx(z.FilterList,{onClick:A,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,A]);return e.jsxs(e.Fragment,{children:[e.jsxs(r.TableCell,{ref:B,"data-handler-id":g,"data-column-index":n,onClick:L,onContextMenu:xe,sx:{position:"sticky",top:0,zIndex:5,textAlign:"left",fontSize:"0.8125rem",fontWeight:700,textTransform:"none",letterSpacing:0,whiteSpace:"nowrap",overflow:"visible",cursor:"pointer",userSelect:"none",color:"primary.main",opacity:V?.25:1,transition:"background-color 0.12s ease, opacity 0.15s ease",bgcolor:M?G=>T(G.palette.primary.main,.08):"action.hover",boxShadow:G=>`0 1px 0 ${T(G.palette.common.black,.08)}`,backgroundImage:"none",borderBottom:"1px solid",borderColor:"divider",py:0,px:2,height:34,"&:hover":{bgcolor:G=>T(G.palette.primary.main,.1),color:"primary.dark"},width:u?`${u}px`:`${kd}px`},children:[e.jsxs(r.Box,{sx:{display:"inline-flex",alignItems:"center",overflow:"hidden",maxWidth:"100%",pr:"12px"},children:[Qe(o.name),H(),se()]}),e.jsx(r.Box,{draggable:!1,onDragStart:G=>G.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:G=>{G.preventDefault(),G.stopPropagation(),x(G,o.name)},onClick:G=>G.stopPropagation(),children:e.jsx(r.Box,{draggable:!1,sx:{width:2,height:"50%",borderRadius:1,opacity:0,bgcolor:"primary.main",transition:"opacity 0.15s ease",pointerEvents:"none"}})}),M&&e.jsx(r.Box,{sx:{position:"absolute",left:0,top:0,bottom:0,width:4,bgcolor:"primary.main"}})]}),R&&e.jsx(wd,{columnName:o.name,columnType:o.type,currentSort:i,hasFilters:s,isInSortStack:d,isReadOnly:l,hasModifications:c,position:K,onSortAscending:y,onSortDescending:D,onRemoveSort:v,onFilter:C,onClearFilter:S,onGroupByColumn:I,onHideColumn:f,onManageColumns:k,onManageViews:j,onResetLayout:a,onClose:me})]})});function Id({selectedCount:t,selectedRowIds:o,resolvedFavoritesSet:n,viewMode:i="list",onExportSelected:s,onClearSelection:d,onBulkSetFavorites:l}){const[c,u]=p.useState(null),h=p.useMemo(()=>Array.from(o),[o]),m=p.useMemo(()=>h.filter(S=>n.has(S)),[h,n]),b=p.useMemo(()=>h.filter(S=>!n.has(S)),[h,n]),x=m.length>0,y=b.length>0;if(t===0)return null;const D=()=>{l&&l(h,!0)},v=()=>{l&&l(h,!1)},C=S=>{s(S),u(null)};return e.jsx(r.Box,{sx:{width:"100%",flexShrink:0,bgcolor:S=>T(S.palette.primary.main,.08),borderBottom:S=>`1px solid ${T(S.palette.primary.main,.25)}`,zIndex:10},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:1.25},children:[e.jsxs(r.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"primary.main"},children:[t," ",i==="grid"?t===1?"card":"cards":t===1?"row":"rows"," selected"]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(r.Button,{onClick:d,startIcon:e.jsx(z.Close,{sx:{fontSize:16}}),size:"small",sx:{fontSize:"0.875rem",px:2,py:.625,borderRadius:"18px",color:"text.secondary","&:hover":{bgcolor:S=>T(S.palette.text.primary,.06),color:"text.primary"}},children:"Clear"}),e.jsx(r.Button,{onClick:S=>u(S.currentTarget),startIcon:e.jsx(z.Download,{sx:{fontSize:16}}),size:"small",variant:"outlined",sx:{fontSize:"0.875rem",px:2,py:.625,borderRadius:"18px",borderColor:S=>T(S.palette.primary.main,.4),color:"primary.main","&:hover":{borderColor:"primary.main",bgcolor:S=>T(S.palette.primary.main,.06)}},children:"Export Selected"}),e.jsxs(r.Menu,{anchorEl:c,open:!!c,onClose:()=>u(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},PaperProps:{sx:{mt:.5,minWidth:180,borderRadius:1.5}},children:[e.jsx(r.MenuItem,{dense:!0,onClick:()=>C("csv"),sx:{py:1,px:2},children:"Export as CSV"}),e.jsx(r.MenuItem,{dense:!0,onClick:()=>C("excel"),sx:{py:1,px:2},children:"Export as Excel"}),e.jsx(r.MenuItem,{dense:!0,onClick:()=>C("json"),sx:{py:1,px:2},children:"Export as JSON"})]}),l&&y&&e.jsx(r.Button,{onClick:D,startIcon:e.jsx(z.StarBorder,{sx:{fontSize:16}}),size:"small",variant:"outlined",sx:{fontSize:"0.875rem",px:2,py:.625,borderRadius:"18px",borderColor:S=>T(S.palette.warning.main,.5),color:"warning.dark","&:hover":{borderColor:"warning.main",bgcolor:S=>T(S.palette.warning.main,.06)}},children:"Add to Favorites"}),l&&x&&e.jsx(r.Button,{onClick:v,startIcon:e.jsx(z.Star,{sx:{fontSize:16,color:"warning.main"}}),size:"small",variant:"outlined",sx:{fontSize:"0.875rem",px:2,py:.625,borderRadius:"18px",borderColor:S=>T(S.palette.warning.main,.5),color:"warning.dark","&:hover":{borderColor:"warning.main",bgcolor:S=>T(S.palette.warning.main,.06)}},children:"Remove from Favorites"})]})]})})}const zd={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 To(t,o){const n=zd[o.toLowerCase().trim()];if(!n||n==="neutral")return{bg:t.palette.action.selected,color:t.palette.text.secondary};const i=t.palette[n];return{bg:T(i.main,t.palette.mode==="dark"?.24:.12),color:t.palette.mode==="dark"?i.light:i.dark}}function Bd(t,o){switch(o.toLowerCase().trim()){case"low":return t.palette.text.secondary;case"medium":return t.palette.warning.main;case"high":return t.palette.warning.dark;case"critical":case"urgent":return t.palette.error.main;default:return}}const Dd={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"}};function Ed(t,o){const n=Dd[o];return n?t.palette[n.hue][n.shade]:t.palette.text.secondary}function We(t){return T(t.palette.primary.main,t.palette.mode==="dark"?.24:.12)}function Od(t){const o=t.toLowerCase().trim();return e.jsx(r.Box,{component:"span",sx:{display:"inline-flex",alignItems:"center",px:1,py:.25,borderRadius:"10px",fontSize:"0.75rem",fontWeight:500,bgcolor:n=>To(n,o).bg,color:n=>To(n,o).color,whiteSpace:"nowrap",lineHeight:1.5},children:t})}function $d(t,o){if(o==null||o==="")return e.jsx(r.Box,{component:"span",sx:{color:"text.disabled",fontSize:"0.8125rem"},children:"—"});const n=String(o),i=t.name.toLowerCase();if(/\b(status|state|stage)\b/.test(i))return Od(n);if(/\b(priority|severity|urgency)\b/.test(i)){const s=n.toLowerCase().trim();return e.jsx(r.Box,{component:"span",sx:d=>{const l=Bd(d,s);return l?{color:l,fontWeight:600,fontSize:"0.8125rem"}:{fontSize:"0.8125rem"}},children:n})}return typeof o=="boolean"?e.jsx(r.Box,{component:"span",sx:{fontSize:"0.8125rem"},children:o?"Yes":"No"}):typeof o=="object"?e.jsx(r.Box,{component:"span",sx:{fontSize:"0.8125rem"},children:JSON.stringify(o)}):e.jsx(r.Box,{component:"span",sx:{fontSize:"0.8125rem"},children:n})}function Ad(t){const o=t.find(s=>{const d=s.name.toLowerCase();return/\b(name|title|label|subject|task_?name|taskname)\b/.test(d)})||t[0]||null,n=t.find(s=>{const d=s.name.toLowerCase().replace(/[\s_-]/g,"");return/(^id$|id$|_id$|taskid|code$|ref$)/.test(d)&&s!==o})||null,i=t.filter(s=>s!==o&&s!==n).slice(0,4);return{primaryCol:o,idCol:n,bodyColumns:i}}function _d({row:t,rowIndex:o,visibleColumns:n,isSelected:i,isFavorite:s,isReadOnly:d,onToggleSelection:l,onToggleFavorite:c,onView:u,onEdit:h,onDuplicate:m,onDelete:b}){const[x,y]=p.useState(null),[D,v]=p.useState(!1),{primaryCol:C,idCol:S,bodyColumns:I}=p.useMemo(()=>Ad(n),[n]),f=C?t[C.name]:null,k=S?t[S.name]:null,j=D||i||s||!!x;return e.jsxs(r.Box,{onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1),onClick:()=>l(o),sx:{position:"relative",display:"flex",flexDirection:"column",bgcolor:"background.paper",border:"1px solid",borderColor:i?"primary.main":a=>T(a.palette.divider,.8),borderWidth:i?2:1,borderRadius:"12px",cursor:"pointer",transition:"box-shadow 0.2s ease, border-color 0.2s ease, transform 0.15s ease",overflow:"hidden",minHeight:180,boxShadow:i?a=>`0 0 0 3px ${T(a.palette.primary.main,.15)}, 0 2px 8px ${T(a.palette.common.black,.08)}`:D?a=>te(a,"cardHover"):a=>te(a,"cardRest"),transform:D&&!i?"translateY(-2px)":"none","&:active":{transform:"translateY(0)"},...i&&{bgcolor:a=>T(a.palette.primary.main,.03)}},children:[e.jsx(r.Box,{sx:{px:2,pt:2,pb:1.5},children:e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600,fontSize:"0.9375rem",color:"text.primary",lineHeight:1.35,wordBreak:"break-word",letterSpacing:"-0.01em"},children:f!=null&&f!==""?String(f):e.jsx(r.Box,{component:"span",sx:{color:"text.disabled",fontStyle:"italic",fontWeight:400},children:"Untitled"})})}),e.jsx(r.Box,{sx:{mx:2,height:"1px",bgcolor:"divider",flexShrink:0}}),e.jsxs(r.Box,{sx:{px:2,py:1.5,flex:1,display:"flex",flexDirection:"column",gap:1},children:[I.map(a=>e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,minHeight:22},children:[e.jsx(r.Typography,{sx:{color:"text.secondary",fontWeight:500,fontSize:"0.6875rem",textTransform:"uppercase",letterSpacing:"0.06em",minWidth:68,flexShrink:0,lineHeight:1},children:Qe(a.name)}),e.jsx(r.Box,{sx:{flex:1,lineHeight:1},children:$d(a,t[a.name])})]},a.name)),I.length===0&&e.jsx(r.Typography,{variant:"caption",color:"text.disabled",sx:{fontStyle:"italic"},children:"No additional fields visible"})]}),e.jsxs(r.Box,{sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid",borderColor:"divider",bgcolor:a=>T(a.palette.action.hover,.1),minHeight:40},children:[e.jsx(r.Typography,{sx:{color:"primary.main",fontFamily:'"Roboto Mono", "Courier New", monospace',fontSize:"0.75rem",fontWeight:400,letterSpacing:"0.04em",opacity:k?.85:0,userSelect:"none"},children:k?String(k):" "}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.25,opacity:j?1:0,transition:"opacity 0.15s ease"},onClick:a=>a.stopPropagation(),children:[c&&e.jsx(r.Tooltip,{title:s?"Remove from favorites":"Add to favorites",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:a=>{a.stopPropagation(),c(t)},sx:{width:28,height:28,color:s?"warning.main":"action.disabled","&:hover":{bgcolor:a=>T(a.palette.warning.main,.1),color:"warning.main"}},children:s?e.jsx(z.Star,{sx:{fontSize:17}}):e.jsx(z.StarBorder,{sx:{fontSize:17}})})}),e.jsx(r.Tooltip,{title:"More actions",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:a=>{a.stopPropagation(),y(a.currentTarget)},sx:{width:28,height:28,color:"action.active","&:hover":{bgcolor:a=>T(a.palette.text.primary,.08)}},children:e.jsx(z.MoreVert,{sx:{fontSize:17}})})})]})]}),e.jsxs(r.Popover,{open:!!x,anchorEl:x,onClose:()=>y(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},PaperProps:{sx:{minWidth:180,py:.5,borderRadius:"10px",boxShadow:a=>te(a,"popover")}},onClick:a=>a.stopPropagation(),children:[e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{u(t),y(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[e.jsx(z.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"View"})]}),!d&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{h(t,o),y(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[e.jsx(z.Edit,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Edit"})]}),!d&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{m(o,t),y(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[e.jsx(z.ContentCopy,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Duplicate"})]}),!d&&e.jsxs(e.Fragment,{children:[e.jsx(r.Divider,{sx:{my:.5,mx:.5}}),e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{b(o,t),y(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5,color:"error.main"},children:[e.jsx(z.Delete,{sx:{fontSize:18,color:"error.main"}}),e.jsx(r.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]})]})]})}function Md({row:t,grouping:o,onToggleCollapse:n}){var i;return e.jsxs(r.Box,{onClick:()=>n(t.groupKey),sx:{gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:1,px:2,py:1,mt:1,mb:.5,bgcolor:"background.paper",border:"1px solid",borderColor:"divider",borderRadius:"8px",cursor:"pointer",boxShadow:s=>te(s,"flatHover"),"&:hover":{bgcolor:s=>T(s.palette.primary.main,.04),borderColor:"primary.light"},transition:"all 0.15s ease"},children:[t.isCollapsed?e.jsx(z.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}):e.jsx(z.KeyboardArrowDown,{sx:{fontSize:16,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600,color:"text.primary"},children:Ii(t.groupLevel,((i=o==null?void 0:o.levels[t.groupLevel])==null?void 0:i.column)||"",t.groupValue)}),e.jsxs(r.Box,{sx:{px:1,py:.125,fontSize:"0.6875rem",fontWeight:600,bgcolor:s=>T(s.palette.primary.main,.1),color:"primary.main",borderRadius:"10px"},children:[t.rowCount," ",t.rowCount===1?"row":"rows"]}),Object.keys(t.aggregates).length>0&&e.jsx(r.Typography,{variant:"caption",sx:{ml:.5,color:"text.secondary"},children:Object.entries(t.aggregates).map(([s,d])=>Ti(d)).filter(Boolean).join(" • ")})]})}function Rd({data:t,visibleColumns:o,grouping:n,selectedRowIds:i,resolvedFavoritesSet:s,isReadOnly:d,isGrouped:l,sortStack:c=[],onSort:u,onToggleRowSelection:h,onToggleRowFavorite:m,onToggleGroupCollapse:b,onViewRow:x,onEditRow:y,onDuplicateRow:D,onDeleteRow:v}){const C=p.useMemo(()=>{const S=new Set;return i.forEach(I=>{const f=I==null?void 0:I.__urm_row_id__;f!==void 0&&S.add(f)}),S},[i]);return t.length===0?e.jsx(r.Box,{sx:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",py:10},children:e.jsx(r.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})}):e.jsxs(r.Box,{sx:{fontFamily:S=>S.typography.fontFamily},children:[u&&o.length>0&&e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75,px:2,py:1,borderBottom:"1px solid",borderColor:"divider",bgcolor:"background.paper",flexWrap:"wrap"},children:[e.jsx(r.Typography,{variant:"caption",sx:{color:"text.secondary",fontWeight:500,mr:.5,whiteSpace:"nowrap"},children:"Sort by:"}),o.map(S=>{const I=c.find(f=>f.column===S.name);return e.jsxs(r.Box,{onClick:()=>u(S.name),sx:{display:"inline-flex",alignItems:"center",gap:.5,px:1.25,py:.375,borderRadius:"6px",border:"1px solid",borderColor:I?"primary.main":"divider",bgcolor:I?f=>T(f.palette.primary.main,.07):"transparent",cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:"primary.light",bgcolor:f=>T(f.palette.primary.main,.05)}},children:[e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",fontWeight:I?600:400,color:I?"primary.main":"text.secondary",whiteSpace:"nowrap"},children:Qe(S.name)}),I?I.direction==="asc"?e.jsx(z.ArrowUpward,{sx:{fontSize:12,color:"primary.main"}}):e.jsx(z.ArrowDownward,{sx:{fontSize:12,color:"primary.main"}}):e.jsx(z.SwapVert,{sx:{fontSize:12,color:"text.disabled"}})]},S.name)})]}),e.jsx(r.Box,{sx:{p:2,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(272px, 1fr))",gap:1.5,alignContent:"start"},children:t.map((S,I)=>l&&S.isGroupHeader?e.jsx(Md,{row:S,grouping:n,onToggleCollapse:b||(()=>{})},`group-${S.groupKey}`):e.jsx(_d,{row:S,rowIndex:I,visibleColumns:o,isSelected:C.has(S==null?void 0:S.__urm_row_id__),isFavorite:s.has(S),isReadOnly:d,onToggleSelection:()=>h(S),onToggleFavorite:m,onView:x,onEdit:y,onDuplicate:D,onDelete:v},`card-${I}`))})]})}const ci=[10,15,25,50,100];function Wd(t,o){const n=t.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>o?"Entered page number is out of range":null}function Pd({currentPage:t,pageSize:o,totalRows:n,totalFields:i,onPageChange:s,onPageSizeChange:d}){var M;const c=At().palette,u=Math.ceil(n/o),[h,m]=p.useState(String(t)),[b,x]=p.useState(null),[y,D]=p.useState(!1),v=p.useRef(null);p.useEffect(()=>{y||(m(String(t)),x(null))},[t,y]);const C=p.useCallback(()=>{const W=Wd(h,u);if(W){x(W);return}const V=parseInt(h.trim(),10);x(null),D(!1),V!==t&&s(V)},[h,u,t,s]),S=p.useCallback(W=>{var V;W.key==="Enter"?(W.preventDefault(),C()):W.key==="Escape"&&(m(String(t)),x(null),D(!1),(V=v.current)==null||V.blur())},[C,t]),I=p.useCallback(()=>{m(String(t)),x(null),D(!1)},[t]),f=p.useCallback(()=>{D(!0),x(null),setTimeout(()=>{var W;return(W=v.current)==null?void 0:W.select()},0)},[]);if(n<=Math.min(...ci))return null;const k=()=>{m(String(t)),x(null),D(!1)},j=()=>{k(),s(1)},a=()=>{k(),t>1&&s(t-1)},B=()=>{k(),t<u&&s(t+1)},R=()=>{k(),s(u)},J=(t-1)*o+1,K=Math.min(t*o,n),ee=`${Math.max(2,String(u).length+.5)}ch`,g={p:.75,color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"action.disabled"}};return e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:3,px:2,py:1,borderTop:"1px solid",borderColor:"divider",bgcolor:"background.paper",minHeight:48},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:2},children:[e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400},children:["Total data:"," ",e.jsx(r.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:n})]}),i!==void 0&&e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400},children:["Total fields:"," ",e.jsx(r.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:i})]})]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:3},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400},children:"Rows per page:"}),e.jsx(r.Select,{value:o,onChange:W=>d(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:ci.map(W=>e.jsx(r.MenuItem,{value:W,sx:{fontSize:"0.8125rem"},children:W},W))})]}),e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400,userSelect:"none"},children:[J,"–",K," of ",n]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75,position:"relative"},children:[e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",userSelect:"none"},children:"Page"}),e.jsxs(r.Box,{sx:{position:"relative"},children:[b&&e.jsx(r.Box,{sx:{position:"absolute",bottom:"calc(100% + 6px)",left:"50%",transform:"translateX(-50%)",bgcolor:"background.paper",border:"1px solid",borderColor:T(c.error.main,.4),borderRadius:"6px",px:1,py:.5,boxShadow:`0 2px 8px ${T(((M=c.common)==null?void 0:M.black)??"#000",.12)}`,zIndex:20,whiteSpace:"nowrap","&::after":{content:'""',position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)",border:"5px solid transparent",borderTopColor:T(c.error.main,.4)}},children:e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:500,color:"error.main",lineHeight:1.3},children:b})}),e.jsx(r.InputBase,{inputRef:v,value:h,onChange:W=>{m(W.target.value),b&&x(null)},onKeyDown:S,onFocus:f,onBlur:I,inputProps:{"aria-label":`Page number, 1 to ${u}`,style:{textAlign:"center",padding:"2px 0",width:ee,fontSize:"0.8125rem",fontWeight:600}},sx:{fontSize:"0.8125rem",fontWeight:600,color:b?"error.main":"text.primary",border:"1px solid",borderColor:b?"error.main":y?"primary.main":"divider",borderRadius:"4px",bgcolor:b?T(c.error.main,.04):y?T(c.primary.main,.04):"background.paper",px:.75,transition:"border-color 0.15s ease, background-color 0.15s ease","&:hover":{borderColor:b?"error.main":"text.secondary"},"&:focus-within":{boxShadow:b?`0 0 0 2px ${T(c.error.main,.2)}`:`0 0 0 2px ${T(c.primary.main,.2)}`}}})]}),e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",userSelect:"none"},children:["of ",u]})]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(r.IconButton,{onClick:j,disabled:t===1,size:"small",title:"First page",sx:g,children:e.jsx(z.FirstPage,{sx:{fontSize:20}})}),e.jsx(r.IconButton,{onClick:a,disabled:t===1,size:"small",title:"Previous page",sx:g,children:e.jsx(z.ChevronLeft,{sx:{fontSize:20}})}),e.jsx(r.IconButton,{onClick:B,disabled:t===u,size:"small",title:"Next page",sx:g,children:e.jsx(z.ChevronRight,{sx:{fontSize:20}})}),e.jsx(r.IconButton,{onClick:R,disabled:t===u,size:"small",title:"Last page",sx:g,children:e.jsx(z.LastPage,{sx:{fontSize:20}})})]})]})]})}function Nd(){return e.jsx(r.Chip,{icon:e.jsx(z.Visibility,{sx:{fontSize:14}}),label:"View Only",size:"small",variant:"outlined",sx:{bgcolor:"action.hover",borderColor:"divider",fontSize:"caption.fontSize",fontWeight:500}})}const Zi="urm_hint_seen_";function Ld(t){try{return localStorage.getItem(Zi+t)==="true"}catch{return!1}}function Fd(t){try{localStorage.setItem(Zi+t,"true")}catch{}}function di(t,o){if(t==null||t==="")return"";if(o==="boolean")return t?"True":"False";if(o==="object"||o==="array")try{return JSON.stringify(t,null,2)}catch{return String(t)}return String(t)}function ui(t){const o={fontSize:11};switch(t){case"number":return e.jsx(z.Numbers,{sx:o});case"boolean":return e.jsx(z.CheckBox,{sx:o});case"array":return e.jsx(z.DataArray,{sx:o});case"object":return e.jsx(z.DataObject,{sx:o});default:return e.jsx(z.TextFields,{sx:o})}}function pi(t,o){var n,i;switch(t){case"number":return{bg:T(o.primary.main,.08),color:o.primary.main};case"boolean":return{bg:T(((n=o.success)==null?void 0:n.main)??"#2e7d32",.08),color:((i=o.success)==null?void 0:i.main)??"#2e7d32"};case"array":case"object":return{bg:T(o.secondary.main,.08),color:o.secondary.main};default:return{bg:T(o.text.secondary,.07),color:o.text.secondary}}}function Vd({open:t,onClose:o,row:n,schema:i,reportName:s}){var b,x;const d=At(),l=d.palette;if(!n)return null;const c=i.filter(y=>y.name in n),u=c.filter(y=>y.type!=="object"&&y.type!=="array"),h=c.filter(y=>y.type==="object"||y.type==="array"),m=c.length;return e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:Me(d),maxHeight:"min(720px, calc(100vh - 80px))",display:"flex",flexDirection:"column",boxShadow:`0 8px 32px ${T(((b=l.common)==null?void 0:b.black)??"#000",.14)}, 0 2px 8px ${T(((x=l.common)==null?void 0:x.black)??"#000",.08)}`,overflow:"hidden"}},children:[e.jsxs(r.Box,{sx:{px:3,pt:2.5,pb:2,bgcolor:"background.paper",display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,minWidth:0},children:[e.jsx(r.Box,{sx:{width:36,height:36,borderRadius:"10px",bgcolor:T(l.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(z.VisibilityOutlined,{sx:{fontSize:18,color:"primary.main"}})}),e.jsxs(r.Box,{sx:{minWidth:0},children:[e.jsx(r.Typography,{variant:"h6",sx:{fontSize:"1rem",fontWeight:600,color:"text.primary",lineHeight:1.3},children:"View Record"}),s&&e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary",display:"block",mt:.25,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[s," · ",m," ",m===1?"field":"fields"]})]})]}),e.jsx(r.IconButton,{size:"small",onClick:o,sx:{mt:.25,color:"text.secondary",borderRadius:"8px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(z.Close,{sx:{fontSize:18}})})]}),e.jsx(r.Divider,{}),e.jsxs(r.DialogContent,{sx:{p:0,overflowY:"auto",flex:1,bgcolor:T(l.text.primary,.015)},children:[u.length>0&&e.jsx(r.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"1px",bgcolor:"divider",m:2,mb:h.length>0?1.5:2,borderRadius:"12px",overflow:"hidden",border:"1px solid",borderColor:"divider"},children:u.map((y,D)=>{const v=n[y.name],C=di(v,y.type),S=!C,I=pi(y.type,l),f=D===u.length-1&&u.length%2!==0;return e.jsxs(r.Box,{sx:{bgcolor:"background.paper",px:2,py:1.75,gridColumn:f?"span 2":"span 1",display:"flex",flexDirection:"column",gap:.75},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5,px:.75,py:.25,borderRadius:"4px",bgcolor:I.bg,color:I.color,flexShrink:0},children:ui(y.type)}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.06em",lineHeight:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Qe(y.name)})]}),e.jsx(r.Typography,{sx:{fontSize:"0.875rem",fontWeight:S?400:500,color:S?"text.disabled":"text.primary",fontStyle:S?"italic":"normal",lineHeight:1.5,wordBreak:"break-word",fontFamily:y.type==="number"?'"Roboto Mono", monospace':"inherit"},children:S?"No value":C})]},y.name)})}),h.map(y=>{const D=n[y.name],v=di(D,y.type),C=!v,S=pi(y.type,l);return e.jsxs(r.Box,{sx:{mx:2,mb:1.5,borderRadius:"12px",overflow:"hidden",border:"1px solid",borderColor:"divider"},children:[e.jsxs(r.Box,{sx:{px:2,py:1.25,bgcolor:"background.paper",borderBottom:"1px solid",borderColor:"divider",display:"flex",alignItems:"center",gap:.75},children:[e.jsx(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5,px:.75,py:.25,borderRadius:"4px",bgcolor:S.bg,color:S.color},children:ui(y.type)}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.06em"},children:Qe(y.name)}),e.jsx(r.Chip,{label:y.type,size:"small",sx:{height:18,fontSize:"0.625rem",fontWeight:600,ml:"auto",bgcolor:S.bg,color:S.color,border:"none",letterSpacing:"0.03em"}})]}),e.jsx(r.Box,{component:"pre",sx:{m:0,px:2,py:1.5,bgcolor:T(l.text.primary,.02),fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:C?"text.disabled":"text.primary",fontStyle:C?"italic":"normal",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6},children:C?"No value":v})]},y.name)}),c.length===0&&e.jsxs(r.Box,{sx:{py:6,display:"flex",flexDirection:"column",alignItems:"center",gap:1,color:"text.disabled"},children:[e.jsx(z.VisibilityOutlined,{sx:{fontSize:40,opacity:.4}}),e.jsx(r.Typography,{variant:"body2",children:"No fields to display"})]})]}),e.jsx(r.Divider,{}),e.jsx(r.DialogActions,{sx:{px:3,py:1.75,bgcolor:"background.paper",justifyContent:"flex-end"},children:e.jsx(r.Button,{onClick:o,variant:"contained",sx:{fontSize:"0.8125rem",px:3,py:.75,borderRadius:y=>`${y.shape.borderRadius}px`,minWidth:80},children:"Close"})})]})}function Hd({open:t,onClose:o,onConfirm:n,rowPreview:i}){return e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:s=>Me(s),maxHeight:"min(480px, calc(100vh - 180px))",my:"auto",boxShadow:s=>te(s,"menu")}},children:[e.jsxs(r.Box,{sx:{px:3,pt:2.5,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[e.jsxs(r.Stack,{direction:"row",spacing:1.5,alignItems:"flex-start",children:[e.jsx(r.Box,{sx:{width:40,height:40,borderRadius:"50%",bgcolor:s=>T(s.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(z.WarningAmberRounded,{sx:{fontSize:22,color:"error.main"}})}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5,mb:.5},children:"Delete record?"}),e.jsxs(r.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"text.secondary"},children:[i?`"${i}"`:"This record"," will be permanently removed."]})]})]}),e.jsx(r.IconButton,{size:"small",onClick:o,sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(z.Close,{sx:{fontSize:20}})})]}),e.jsx(r.DialogContent,{sx:{px:3,pb:2},children:e.jsx(r.Box,{sx:{p:2,borderRadius:"8px",bgcolor:s=>T(s.palette.error.main,.1),border:s=>`1px solid ${T(s.palette.error.main,.5)}`},children:e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"error.main",fontWeight:500},children:"This action cannot be undone. The record will be deleted from this report immediately."})})}),e.jsxs(r.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:[e.jsx(r.Button,{onClick:o,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:s=>`${s.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:()=>{n(),o()},variant:"contained",startIcon:e.jsx(z.DeleteForever,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"error.main",color:"error.contrastText",px:3,py:.875,minHeight:36,borderRadius:s=>`${s.shape.borderRadius}px`,boxShadow:s=>te(s,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"error.dark",boxShadow:s=>te(s,"hoverButton")},"&:active":{boxShadow:s=>te(s,"pressedButton"),transform:"translateY(1px)"}},children:"Delete record"})]})]})}function tn(t){const o={fontSize:11};switch(t){case"number":return e.jsx(z.Numbers,{sx:o});case"boolean":return e.jsx(z.CheckBox,{sx:o});case"array":return e.jsx(z.DataArray,{sx:o});case"object":return e.jsx(z.DataObject,{sx:o});default:return e.jsx(z.TextFields,{sx:o})}}function xi(t,o){var n,i;switch(t){case"number":return{bg:T(o.primary.main,.08),color:o.primary.main};case"boolean":return{bg:T(((n=o.success)==null?void 0:n.main)??"#2e7d32",.08),color:((i=o.success)==null?void 0:i.main)??"#2e7d32"};case"array":case"object":return{bg:T(o.secondary.main,.08),color:o.secondary.main};default:return{bg:T(o.text.secondary,.07),color:o.text.secondary}}}function Ud({open:t,onClose:o,onSave:n,row:i,schema:s,reportName:d}){var C,S,I;const l=At(),c=l.palette,[u,h]=p.useState({});if(p.useEffect(()=>{t&&i&&h({...i})},[t,i]),!i)return null;const m=s.filter(f=>f.name in i),b=m.filter(f=>f.type!=="object"&&f.type!=="array"),x=m.filter(f=>f.type==="object"||f.type==="array"),y=(f,k)=>{h(j=>({...j,[f]:k}))},D=()=>{const f={...u};m.forEach(k=>{const j=u[k.name];if(k.type==="number"){const a=Number(j);f[k.name]=isNaN(a)?i[k.name]:a}else k.type==="boolean"&&(f[k.name]=!!j)}),n(f),o()},v=m.length;return e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:Me(l),maxHeight:"min(760px, calc(100vh - 80px))",display:"flex",flexDirection:"column",boxShadow:`0 8px 32px ${T(((C=c.common)==null?void 0:C.black)??"#000",.14)}, 0 2px 8px ${T(((S=c.common)==null?void 0:S.black)??"#000",.08)}`,overflow:"hidden"}},children:[e.jsxs(r.Box,{sx:{px:3,pt:2.5,pb:2,bgcolor:"background.paper",display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,minWidth:0},children:[e.jsx(r.Box,{sx:{width:36,height:36,borderRadius:"10px",bgcolor:T(((I=c.warning)==null?void 0:I.main)??"#ed6c02",.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(z.EditOutlined,{sx:{fontSize:18,color:"warning.main"}})}),e.jsxs(r.Box,{sx:{minWidth:0},children:[e.jsx(r.Typography,{sx:{fontSize:"1rem",fontWeight:600,color:"text.primary",lineHeight:1.3},children:"Edit Record"}),d&&e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary",display:"block",mt:.25,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[d," · ",v," ",v===1?"field":"fields"]})]})]}),e.jsx(r.IconButton,{size:"small",onClick:o,sx:{mt:.25,color:"text.secondary",borderRadius:"8px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(z.Close,{sx:{fontSize:18}})})]}),e.jsx(r.Divider,{}),e.jsxs(r.DialogContent,{sx:{p:2.5,overflowY:"auto",flex:1,bgcolor:T(c.text.primary,.015),display:"flex",flexDirection:"column",gap:2},children:[b.length>0&&e.jsxs(r.Box,{children:[b.length>1&&e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:700,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.08em",mb:1.25},children:"Fields"}),e.jsx(r.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:1.5},children:b.map((f,k)=>{const j=u[f.name],a=xi(f.type,c),B=f.type==="boolean",R=!B&&k===b.filter(K=>K.type!=="boolean").length-1&&b.filter(K=>K.type!=="boolean").length%2!==0,J=B||R;return f.type==="boolean"?e.jsxs(r.Box,{sx:{gridColumn:"span 2",bgcolor:"background.paper",border:"1px solid",borderColor:"divider",borderRadius:"10px",px:2,py:1.5,display:"flex",alignItems:"center",justifyContent:"space-between",gap:2,transition:"border-color 0.15s","&:hover":{borderColor:"primary.main"}},children:[e.jsxs(r.Box,{children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:.25},children:[e.jsx(r.Box,{sx:{display:"flex",alignItems:"center",px:.75,py:.25,borderRadius:"4px",bgcolor:a.bg,color:a.color},children:tn(f.type)}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.06em"},children:Qe(f.name)})]}),e.jsx(r.Typography,{sx:{fontSize:"0.8125rem",color:"text.secondary",ml:.25},children:j?"Enabled":"Disabled"})]}),e.jsx(r.Switch,{checked:!!j,onChange:K=>y(f.name,K.target.checked),size:"small",sx:{"& .MuiSwitch-switchBase.Mui-checked":{color:"primary.main"},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{bgcolor:"primary.main"}}})]},f.name):e.jsxs(r.Box,{sx:{gridColumn:J?"span 2":"span 1",bgcolor:"background.paper",border:"1px solid",borderColor:"divider",borderRadius:"10px",overflow:"hidden",transition:"border-color 0.15s","&:focus-within":{borderColor:"primary.main",boxShadow:`0 0 0 2px ${T(c.primary.main,.12)}`}},children:[e.jsxs(r.Box,{sx:{px:1.5,py:.875,borderBottom:"1px solid",borderColor:"divider",bgcolor:T(c.text.primary,.02),display:"flex",alignItems:"center",gap:.75},children:[e.jsx(r.Box,{sx:{display:"flex",alignItems:"center",px:.75,py:.25,borderRadius:"4px",bgcolor:a.bg,color:a.color},children:tn(f.type)}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.06em",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Qe(f.name)})]}),e.jsx(r.TextField,{value:j??"",onChange:K=>y(f.name,K.target.value),type:f.type==="number"?"number":"text",size:"small",fullWidth:!0,variant:"standard",placeholder:`Enter ${f.type==="number"?"number":"value"}…`,InputProps:{disableUnderline:!0},sx:{"& .MuiInputBase-root":{px:1.5,py:1,fontSize:"0.875rem",fontWeight:500,color:"text.primary",fontFamily:f.type==="number"?'"Roboto Mono", monospace':"inherit"},"& .MuiInputBase-input":{p:0,"&::placeholder":{color:"text.disabled",opacity:1,fontWeight:400}}}})]},f.name)})})]}),x.length>0&&e.jsxs(r.Box,{children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:1.25},children:[e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:700,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.08em"},children:"Read-only Fields"}),e.jsx(r.Tooltip,{title:"Object and array fields cannot be edited directly",arrow:!0,children:e.jsx(z.InfoOutlined,{sx:{fontSize:13,color:"text.disabled",cursor:"help"}})})]}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1.5},children:x.map(f=>{const k=i[f.name];let j="";try{j=k==null?"":JSON.stringify(k,null,2)}catch{j=String(k)}const a=xi(f.type,c);return e.jsxs(r.Box,{sx:{bgcolor:"background.paper",border:"1px solid",borderColor:"divider",borderRadius:"10px",overflow:"hidden",opacity:.8},children:[e.jsxs(r.Box,{sx:{px:1.5,py:.875,borderBottom:"1px solid",borderColor:"divider",bgcolor:T(c.text.primary,.02),display:"flex",alignItems:"center",gap:.75},children:[e.jsx(r.Box,{sx:{display:"flex",alignItems:"center",px:.75,py:.25,borderRadius:"4px",bgcolor:a.bg,color:a.color},children:tn(f.type)}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.06em",flex:1},children:Qe(f.name)}),e.jsx(r.Chip,{label:"read only",size:"small",sx:{height:16,fontSize:"0.5625rem",fontWeight:600,letterSpacing:"0.04em",bgcolor:T(c.text.secondary,.07),color:"text.secondary",border:"none"}})]}),e.jsx(r.Box,{component:"pre",sx:{m:0,px:1.5,py:1.25,fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:j?"text.primary":"text.disabled",fontStyle:j?"normal":"italic",bgcolor:T(c.text.primary,.015),overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6,maxHeight:120,overflowY:"auto"},children:j||"No value"})]},f.name)})})]}),m.length===0&&e.jsxs(r.Box,{sx:{py:6,display:"flex",flexDirection:"column",alignItems:"center",gap:1,color:"text.disabled"},children:[e.jsx(z.EditOutlined,{sx:{fontSize:40,opacity:.4}}),e.jsx(r.Typography,{variant:"body2",children:"No editable fields"})]})]}),e.jsx(r.Divider,{}),e.jsxs(r.DialogActions,{sx:{px:3,py:1.75,bgcolor:"background.paper",gap:1,justifyContent:"flex-end"},children:[e.jsx(r.Button,{onClick:o,variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",px:2,borderRadius:f=>`${f.shape.borderRadius}px`,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:D,variant:"contained",startIcon:e.jsx(z.SaveOutlined,{sx:{fontSize:15}}),sx:{fontSize:"0.8125rem",px:2.5,borderRadius:f=>`${f.shape.borderRadius}px`,minWidth:90},children:"Save"})]})]})}const Dr=176,Yd={low:"text.secondary",medium:"warning.dark",high:"warning.main",critical:"error.main",urgent:"error.main"};function Gd(t){const o=t.toLowerCase().trim();return e.jsx(r.Box,{component:"span",sx:{display:"inline-flex",alignItems:"center",px:1.25,py:.375,borderRadius:"12px",fontSize:"0.75rem",fontWeight:500,bgcolor:n=>To(n,o).bg,color:n=>To(n,o).color,whiteSpace:"nowrap",lineHeight:1.6,letterSpacing:"0.01em"},children:t})}function qd(t){const o=t.toLowerCase().trim(),n=Yd[o];return n?e.jsx(r.Box,{component:"span",sx:{color:n,fontWeight:500,fontSize:"inherit"},children:t}):t}function Jd(t){return e.jsx(r.Box,{component:"span",sx:{color:"primary.main",fontFamily:'"Roboto Mono", "Courier New", monospace',fontSize:"0.8125rem",fontWeight:400,letterSpacing:"0.04em"},children:t})}function Kd(t,o){const n=t.name.toLowerCase().replace(/[_\s-]/g,""),i=t.name.toLowerCase(),s=o.findIndex(h=>h.name===t.name),d=/(\bid\b|id$|_id$|code$|ref$|no$|num$)/.test(n),l=i.includes("name")||i.includes("task")||i.includes("title")||i.includes("label")||i.includes("subject")||i.includes("description")||i.includes("filename"),c=i.includes("assignee")||i.includes("assigned")||i.includes("owner")||i.includes("author")||i.includes("creator")||i.includes("member")||i.includes("contact")||i.includes("recipient")||i.includes("sender"),u=s===0&&t.type!=="boolean"&&!i.includes("status")&&!i.includes("state");return d||l&&!c||u&&!c}function es(t,o){const n=o.trim();if(!n)return t;const i=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=t.split(new RegExp(`(${i})`,"gi"));return s.length===1?t:s.map((d,l)=>d.toLowerCase()===n.toLowerCase()?e.jsx(r.Box,{component:"mark",sx:{bgcolor:"warning.light",color:"inherit",px:"1px",borderRadius:"2px"},children:d},l):d)}function Xd(t,o=""){return e.jsx(r.Box,{component:"span",sx:{fontWeight:700,color:"text.primary",fontSize:"inherit"},children:es(t,o)})}function Qd(t,o,n=!1,i,s=""){if(o==null||o==="")return e.jsx(r.Box,{component:"span",sx:{color:"text.disabled"},children:"—"});const d=String(o),l=t.name.toLowerCase().replace(/[_\s-]/g,""),c=/\b(status|state|stage|employmenttype|contracttype|availability)\b/.test(t.name.toLowerCase());if(c)return Gd(d);const u=/\b(priority|severity|urgency|importance|criticality)\b/.test(t.name.toLowerCase());if(u)return qd(d);const h=/(\bid\b|id$|_id$|code$|ref$|no$|num$)/.test(l)||/^[A-Z]{2,8}-\d{2,}$/.test(d);if(h)return Jd(d);if(n&&!c&&!u&&!h)return Xd(d,s);if(t.type==="date"){const m=t.dateFormat??"iso",b=ea(o,m,i??null);return e.jsx(r.Box,{component:"span",sx:{color:"text.primary",whiteSpace:"nowrap"},children:b})}if(t.type==="number"&&typeof o=="number")return o.toLocaleString();if(typeof o=="boolean")return o?"Yes":"No";if(Array.isArray(o)){if(o.length===0)return e.jsx(r.Box,{component:"span",sx:{color:"text.disabled"},children:"[ ]"});const m=o.slice(0,3).map(b=>typeof b=="object"?JSON.stringify(b):String(b)).join(", ");return e.jsxs(r.Box,{component:"span",sx:{color:"text.secondary",fontSize:"0.8125rem"},children:[m,o.length>3?` +${o.length-3} more`:""]})}if(typeof o=="object"){const m=JSON.stringify(o);return e.jsx(r.Box,{component:"span",title:m,sx:{color:"text.secondary",fontSize:"0.8125rem",fontFamily:"monospace",cursor:"help"},children:m.length>40?m.slice(0,40)+"…":m})}return es(d,s)}function Zd({schema:t,data:o,sortStack:n=[],filters:i=[],views:s=[],activeViewId:d="",isDirty:l=!1,isExporting:c=!1,columnVisibility:u={},columnOrder:h=[],columnWidths:m={},grouping:b=null,onSort:x,onSortAscending:y,onSortDescending:D,onOpenFilters:v,onOpenSort:C,onOpenFilterForColumn:S,onSelectView:I,onCreateView:f,onManageViews:k,onUpdateCurrentView:j,onSaveAsNewView:a,onToggleDefault:B,onToggleFavorite:R,onRestoreView:J,onPermanentDelete:K,isAdmin:ee=!1,onExport:g,onOpenColumns:M,onUpdateColumnWidth:W,onUpdateColumnOrder:V,onUpdateColumnVisibility:Q,onClearFiltersForColumn:xe,onResetLayout:me,onOpenGroup:L,onGroupByColumn:A,onToggleGroupCollapse:H,onOpenAuditHistory:se,onOpenScheduledReports:G,searchQuery:re,highlightQuery:ae="",searchHistory:ne=[],onAddToSearchHistory:P,onToggleSearchFavourite:ie,onDeleteSearchHistory:pe,selectedRowIds:le=new Set,onSearchChange:ge,onToggleRowSelection:q,onToggleAllRows:_e,onRangeSelection:et,onClearSelection:tt,onExportSelected:_t,currentPage:mr=1,pageSize:Mt=15,totalRowsBeforePagination:Rt=o.length,onPageChange:Wt,onPageSizeChange:pt,isReadOnly:Ve=!1,userRole:qe,reportName:Ue,onEditRow:rt,onDuplicateRow:Je,onDeleteRow:ot,favoriteRowIndices:wt=[],resolvedFavoritesSet:He=new Set,showFavoritesOnly:lt=!1,onToggleRowFavorite:Re,onBulkSetFavorites:Or,showDevPanel:$r=!1,onOpenDevConfig:qt,onToggleFavoritesFilter:hr}){var ao;const[Pt,xt]=p.useState(null),[Nt,fr]=p.useState(0),[kt,Ar]=p.useState(0),[Ye,gr]=p.useState(null),Jt=((ao=ur().dates)==null?void 0:ao.displayFormat)??null,[Ce,Mr]=p.useState(null),[yr,ct]=p.useState(null),[F,Ge]=p.useState(null),[we,Pe]=p.useState(!1),[Rr,Kt]=p.useState(!1),[mt,Xt]=p.useState(null),[Qt,Zt]=p.useState(""),[Wr,Lt]=p.useState(!1),[ze,Z]=p.useState(null),[ht,ke]=p.useState(null),[ye,nt]=p.useState(null),[er,ft]=p.useState(null),[Le,br]=p.useState("list"),[Tt,dt]=p.useState(!1),[It,Pr]=p.useState(()=>!Ld("toolbar_search")),tr=p.useRef(null),rr=p.useRef(null),Ft=p.useCallback(()=>{Fd("toolbar_search"),Pr(!1)},[]);p.useEffect(()=>{if(!It)return;const O=setTimeout(Ft,2e3);return()=>clearTimeout(O)},[It,Ft]);const vr=p.useMemo(()=>{const O=Ye??h;return O.length>0?O.map(X=>t.find(he=>he.name===X)).filter(X=>X!==void 0):t},[Ye,h,t]),Ne=p.useMemo(()=>vr.filter(O=>u[O.name]!==!1),[vr,u]),gt=p.useMemo(()=>t.filter(O=>u[O.name]===!1).length,[t,u]),or=p.useMemo(()=>t.map(O=>O.name),[t]),yt=p.useMemo(()=>h.length===0?!1:JSON.stringify(h)!==JSON.stringify(or),[h,or]),Nr=p.useCallback((O,X)=>{O.preventDefault(),O.stopPropagation(),xt(X),fr(O.clientX),Ar(m[X]||150)},[m]);p.useEffect(()=>{if(!Pt)return;const O=he=>{const Fe=he.clientX-Nt,ue=Math.max(100,Math.min(600,kt+Fe));W==null||W(Pt,ue)},X=()=>{xt(null)};return document.addEventListener("mousemove",O),document.addEventListener("mouseup",X),()=>{document.removeEventListener("mousemove",O),document.removeEventListener("mouseup",X)}},[Pt,Nt,kt,W]);const Lr=p.useCallback(O=>O==null?"-":typeof O=="object"?JSON.stringify(O):typeof O=="boolean"?O?"true":"false":String(O),[]);p.useCallback(O=>{const X=n.find(he=>he.column===O);return X?e.jsxs(r.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[X.direction==="asc"?e.jsx(z.ArrowUpward,{sx:{fontSize:14}}):e.jsx(z.ArrowDownward,{sx:{fontSize:14}}),e.jsx(r.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:X.priority})]}):null},[n]),p.useCallback(O=>i.some(he=>he.column===O)?e.jsx(r.IconButton,{size:"small",onClick:he=>{he.stopPropagation(),S==null||S(O)},sx:{ml:.5,p:.25,color:"primary.main","&:hover":{color:"primary.main"}},title:"Active filters on this column",children:e.jsx(z.FilterList,{sx:{fontSize:14}})}):null,[i,S]);const Vt=p.useCallback(O=>{x&&x(O)},[x]),Fr=p.useCallback((O,X)=>{gr(he=>{const ue=[...he??(h.length>0?h:t.map(Ho=>Ho.name))],[Bt]=ue.splice(O,1);return ue.splice(X,0,Bt),ue})},[h,t]),Vr=p.useCallback(()=>{Ye&&V&&V(Ye),gr(null)},[Ye,V]),nr=p.useCallback(O=>{if(!x)return;const X=n.find(he=>he.column===O);(!X||X.direction!=="asc")&&x(O)},[x,n]),Sr=p.useCallback(O=>{if(!x)return;const X=n.find(he=>he.column===O);X?X.direction==="asc"&&x(O):(x(O),setTimeout(()=>x(O),0))},[x,n]),jr=p.useCallback(O=>{if(!x)return;const X=n.find(he=>he.column===O);X&&(X.direction==="asc"?(x(O),setTimeout(()=>x(O),0)):X.direction==="desc"&&x(O))},[x,n]),Cr=p.useCallback(O=>{Q&&Q(O,!1)},[Q]),ir=(b==null?void 0:b.enabled)&&o.length>0&&o[0]&&"isGroupHeader"in o[0],wr=n.length>0||i.length>0||((b==null?void 0:b.enabled)??!1)||Object.values(u).some(O=>O===!1),de=(mr-1)*Mt,ce=o,De=p.useMemo(()=>{const O=new Set;return le.forEach(X=>{const he=X==null?void 0:X.__urm_row_id__;he!==void 0&&O.add(he)}),O},[le]);p.useEffect(()=>{const O=X=>{!_e||!tt||X.target instanceof HTMLInputElement||X.target instanceof HTMLTextAreaElement||((X.ctrlKey||X.metaKey)&&X.key==="a"&&(X.preventDefault(),_e(!0,ce)),X.key==="Escape"&&(X.preventDefault(),tt()))};return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[_e,tt,ce]);const ut=p.useCallback((O,X)=>{q&&(X.shiftKey&&Ce!==null?(X.preventDefault(),et&&et(Ce,O,ce)):(q(ce[O]),Mr(O)))},[q,Ce,et,ce]);!p.useMemo(()=>ce.length>0&&De.size>0&&ce.every(O=>De.has(O==null?void 0:O.__urm_row_id__)),[ce,De])&&ce.some(O=>De.has(O==null?void 0:O.__urm_row_id__));const zt=q&&_e,Hr=p.useCallback(O=>{var Fe;const X=O.groupLevel,he=X*24;return e.jsx(r.TableRow,{onClick:()=>H==null?void 0:H(O.groupKey),sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"},cursor:"pointer",borderTop:2,borderColor:"divider"},children:e.jsx(r.TableCell,{colSpan:Ne.length+(zt?1:0),sx:{pl:`${he+24}px`},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[O.isCollapsed?e.jsx(z.ChevronRight,{sx:{fontSize:16}}):e.jsx(z.KeyboardArrowDown,{sx:{fontSize:16}}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600},children:Ii(X,((Fe=b==null?void 0:b.levels[X])==null?void 0:Fe.column)||"",O.groupValue)}),e.jsxs(r.Box,{sx:{px:1,py:.25,fontSize:"caption.fontSize",fontWeight:500,bgcolor:ue=>T(ue.palette.primary.main,.12),color:"primary.main",borderRadius:2},children:[O.rowCount," ",O.rowCount===1?"row":"rows"]}),Object.keys(O.aggregates).length>0&&e.jsx(r.Typography,{variant:"caption",sx:{ml:1,color:"text.secondary"},children:Object.entries(O.aggregates).map(([ue,Bt])=>Ti(Bt)).filter(Boolean).join(" • ")})]})})},O.groupKey)},[Ne,zt,b,H]),Ht=p.useCallback((O,X)=>{const he=De.has(O==null?void 0:O.__urm_row_id__),Fe=yr===X;return e.jsxs(r.TableRow,{"data-row-index":X,onMouseEnter:()=>ct(X),onMouseLeave:()=>ct(null),onClick:ue=>{!q||ue.target.closest("[data-row-action-btn]")||ut(X,ue)},onContextMenu:ue=>{ue.preventDefault(),ue.stopPropagation(),nt({mouseX:ue.clientX,mouseY:ue.clientY,row:O,rowIndex:X})},sx:{height:34,cursor:"pointer",bgcolor:he?ue=>T(ue.palette.warning.main,.12):"background.paper",transition:"background-color 0.12s ease","&:hover":{bgcolor:he?ue=>T(ue.palette.warning.main,.2):"action.hover"},borderBottom:"1px solid",borderColor:"divider"},children:[Ne.map((ue,Bt)=>e.jsx(r.TableCell,{sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",py:"6px",px:2,textAlign:"left",...Bt===Ne.length-1&&{pr:`${Re?76:40}px`},fontSize:"0.8125rem",fontWeight:400,color:"text.primary",borderBottom:"1px solid",borderColor:"divider",minWidth:m[ue.name]?`${m[ue.name]}px`:`${ue.type==="date"?Math.max(Dr,180):Dr}px`},children:Qd(ue,O[ue.name],Kd(ue,Ne),Jt,ae)},ue.name)),e.jsx(r.TableCell,{"data-row-action":"true",sx:{position:"sticky",right:0,width:Re?76:40,minWidth:Re?76:40,maxWidth:Re?76:40,p:0,border:"none",borderBottom:"1px solid",borderColor:"divider",background:Fe||He.has(O)?ue=>`linear-gradient(to right, transparent, ${he?T(ue.palette.warning.main,.12):ue.palette.background.paper} 32px)`:"transparent",opacity:Fe||He.has(O)?1:0,transition:"opacity 0.12s ease, background 0.12s ease",zIndex:10,verticalAlign:"middle"},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",height:"100%",px:1,gap:.25},children:[Re&&e.jsx(r.IconButton,{"data-row-action-btn":"true",size:"small",onClick:ue=>{ue.stopPropagation(),ue.preventDefault(),Re(O)},title:He.has(O)?"Remove from favorites":"Add to favorites",sx:{color:He.has(O)?"warning.main":"text.secondary","&:hover":{bgcolor:ue=>T(ue.palette.warning.main,.08),color:"warning.main"}},children:He.has(O)?e.jsx(z.Star,{sx:{fontSize:18}}):e.jsx(z.StarBorder,{sx:{fontSize:18}})}),e.jsx(r.IconButton,{"data-row-action-btn":"true",size:"small",onClick:ue=>{ue.stopPropagation(),ue.preventDefault(),nt({anchorEl:ue.currentTarget,row:O,rowIndex:X})},sx:{color:"text.secondary",opacity:Fe?1:0,transition:"opacity 0.12s ease",pointerEvents:Fe?"auto":"none","&:hover":{bgcolor:ue=>T(ue.palette.text.primary,.08),color:"text.primary"}},children:e.jsx(z.MoreVert,{sx:{fontSize:18}})})]})})]},X)},[le,de,yr,ut,Ne,m,ae,Lr,rt,Je,ot,q,Re,He,Ge,Pe,nt]);return e.jsxs(Ot.DndProvider,{backend:an.HTML5Backend,children:[e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:[zt&&_t&&tt&&e.jsx(Id,{selectedCount:De.size,selectedRowIds:le,resolvedFavoritesSet:He,viewMode:Le,onExportSelected:_t,onClearSelection:tt,onBulkSetFavorites:Or}),e.jsxs(r.Box,{sx:{position:"sticky",top:0,zIndex:10,bgcolor:"background.paper",borderBottom:"1px solid",borderColor:"divider",px:2,py:0,height:56,display:"flex",alignItems:"center",gap:1},children:[Ve&&e.jsx(Nd,{}),ge&&P&&ie&&pe&&e.jsx(r.Tooltip,{open:It,title:e.jsxs(r.Box,{sx:{p:.5},children:[e.jsx(r.Typography,{variant:"caption",sx:{display:"block",fontWeight:500,mb:.25},children:"💡 Search tip"}),e.jsx(r.Typography,{variant:"caption",children:"Type to search across all columns instantly"})]}),placement:"bottom-start",arrow:!0,PopperProps:{onClick:Ft},componentsProps:{tooltip:{sx:{bgcolor:"primary.main","& .MuiTooltip-arrow":{color:"primary.main"},maxWidth:220,cursor:"pointer",userSelect:"none"}}},children:e.jsx(r.Box,{component:"span",children:e.jsx(jd,{value:re||"",onChange:O=>{It&&Ft(),ge(O)},searchHistory:ne,onAddToHistory:P,onToggleFavourite:ie,onDeleteHistory:pe,disabled:Ve})})}),e.jsx(r.Tooltip,{title:"JSON format guide",children:e.jsx(r.IconButton,{size:"small",onClick:()=>dt(!0),sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:O=>T(O.palette.text.primary,.06),color:"text.primary"}},children:e.jsx(z.InfoOutlined,{sx:{fontSize:20}})})}),hr&&e.jsx(r.Tooltip,{title:lt?"Show all data":"Show favorites only",children:e.jsxs(r.IconButton,{onClick:hr,size:"small",disabled:Ve,sx:{position:"relative",color:lt?"warning.main":"text.secondary",bgcolor:lt?O=>T(O.palette.warning.main,.12):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:lt?O=>T(O.palette.warning.main,.2):O=>T(O.palette.text.primary,.06),color:lt?"warning.main":"text.primary"},"&.Mui-disabled":{color:"action.disabled"}},children:[lt?e.jsx(z.Star,{sx:{fontSize:20}}):e.jsx(z.StarBorder,{sx:{fontSize:20}}),lt&&wt.length>0&&e.jsx(r.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"warning.main",color:"warning.contrastText",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:wt.length})]})}),$r&&qt&&e.jsx(r.Tooltip,{title:"Developer configuration",children:e.jsx(r.IconButton,{size:"small",onClick:qt,sx:{color:"text.secondary",borderRadius:1,border:"1px dashed",borderColor:O=>T(O.palette.text.secondary,.3),"&:hover":{bgcolor:O=>T(O.palette.warning.main,.08),borderColor:"warning.main",color:"warning.dark"}},children:e.jsx(z.DisplaySettings,{sx:{fontSize:20}})})}),e.jsx(r.Box,{sx:{flexGrow:1}}),I&&f&&k&&j&&s.length>0&&e.jsx(Cd,{views:s||[],activeViewId:d||"",isDirty:l,onSelectView:I,onCreateView:f,onManageViews:k,onToggleDefault:B,onToggleFavorite:R,onRestoreView:J,onPermanentDelete:K,isAdmin:ee,isReadOnly:Ve}),!Ve&&C&&e.jsx(r.Tooltip,{title:"Sort",children:e.jsxs(r.IconButton,{onClick:C,size:"small",sx:{position:"relative",color:n.length>0?"primary.main":"text.secondary",bgcolor:n.length>0?O=>We(O):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:n.length>0?O=>T(O.palette.primary.main,.2):O=>T(O.palette.text.primary,.06),color:n.length>0?"primary.main":"text.primary"}},children:[e.jsx(z.SwapVert,{sx:{fontSize:20}}),n.length>0&&e.jsx(r.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})]})}),!Ve&&v&&e.jsx(r.Tooltip,{title:"Filter",children:e.jsxs(r.IconButton,{onClick:v,size:"small",sx:{position:"relative",color:i.length>0?"primary.main":"text.secondary",bgcolor:i.length>0?O=>We(O):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:i.length>0?O=>T(O.palette.primary.main,.2):O=>T(O.palette.text.primary,.06),color:i.length>0?"primary.main":"text.primary"}},children:[e.jsx(z.FilterList,{sx:{fontSize:20}}),i.length>0&&e.jsx(r.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:i.length})]})}),!Ve&&M&&e.jsx(r.Tooltip,{title:"Columns",children:e.jsxs(r.IconButton,{onClick:M,size:"small",sx:{position:"relative",color:gt>0||yt?"primary.main":"text.secondary",bgcolor:gt>0||yt?O=>We(O):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:gt>0||yt?O=>T(O.palette.primary.main,.2):O=>T(O.palette.text.primary,.06),color:gt>0||yt?"primary.main":"text.primary"}},children:[e.jsx(z.ViewColumn,{sx:{fontSize:20}}),gt>0&&e.jsx(r.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:gt})]})}),e.jsx(r.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5,my:1.5}}),e.jsx(r.Tooltip,{title:"List view",children:e.jsx(r.IconButton,{size:"small",onClick:()=>br("list"),sx:{borderRadius:1,color:Le==="list"?"primary.main":"text.secondary",bgcolor:Le==="list"?O=>We(O):"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:Le==="list"?O=>T(O.palette.primary.main,.2):O=>T(O.palette.text.primary,.06),color:Le==="list"?"primary.main":"text.primary"}},children:e.jsx(z.TableRows,{sx:{fontSize:20}})})}),e.jsx(r.Tooltip,{title:"Grid view",children:e.jsx(r.IconButton,{size:"small",onClick:()=>br("grid"),sx:{borderRadius:1,color:Le==="grid"?"primary.main":"text.secondary",bgcolor:Le==="grid"?O=>We(O):"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:Le==="grid"?O=>T(O.palette.primary.main,.2):O=>T(O.palette.text.primary,.06),color:Le==="grid"?"primary.main":"text.primary"}},children:e.jsx(z.GridView,{sx:{fontSize:20}})})}),e.jsx(r.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5,my:1.5}}),e.jsx(r.Tooltip,{title:"Settings",children:e.jsx(r.IconButton,{onClick:O=>ft(O.currentTarget),size:"small",sx:{color:"text.secondary",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:O=>T(O.palette.text.primary,.06),color:"text.primary"}},children:e.jsx(z.Settings,{sx:{fontSize:20}})})})]}),e.jsxs(r.Popover,{open:!!er,anchorEl:er,onClose:()=>ft(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:[g&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{g(),ft(null)},disabled:c,sx:{py:1,px:2,gap:1.5},children:[e.jsx(z.Download,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Export"})]}),!Ve&&L&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{L(),ft(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(z.Layers,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Grouping"})]}),se&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{se(),ft(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(z.History,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Audit History"})]}),G&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{G(),ft(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(z.Schedule,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Scheduled Reports"})]})]}),e.jsxs(r.Box,{sx:{position:"relative",flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[Le==="grid"&&e.jsx(r.Box,{sx:{flex:1,overflowY:"auto",overflowX:"hidden",bgcolor:"action.hover"},children:e.jsx(Rd,{data:ce,visibleColumns:Ne,grouping:b,selectedRowIds:le,resolvedFavoritesSet:He,isReadOnly:Ve,isGrouped:!!ir,sortStack:n,onSort:x,onToggleRowSelection:q||(()=>{}),onToggleRowFavorite:Re,onToggleGroupCollapse:H,onViewRow:O=>{Ge(O),Pe(!0)},onEditRow:(O,X)=>{Z(O),ke(X),Lt(!0)},onDuplicateRow:(O,X)=>Je==null?void 0:Je(O,X),onDeleteRow:(O,X)=>{Xt(X);const he=Object.values(X).find(Fe=>Fe!=null&&Fe!=="");Zt(he?String(he):""),Kt(!0)}})}),Le==="list"&&e.jsxs(r.Box,{sx:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[e.jsx(r.Box,{ref:tr,onScroll:O=>{rr.current&&(rr.current.scrollLeft=O.target.scrollLeft)},sx:{overflowX:"auto",overflowY:"hidden",flexShrink:0,scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:e.jsxs(r.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",borderSpacing:0,width:"100%",minWidth:`${Ne.reduce((O,X)=>O+(m[X.name]||(X.type==="date"?180:Dr)),Re?76:40)}px`},children:[e.jsxs("colgroup",{children:[Ne.map(O=>e.jsx("col",{style:{width:`${m[O.name]||(O.type==="date"?180:Dr)}px`}},O.name)),e.jsx("col",{style:{width:`${Re?76:40}px`}})]}),e.jsx(r.TableHead,{children:e.jsxs(r.TableRow,{sx:{height:34,bgcolor:"action.hover",borderBottom:"1px solid",borderColor:"divider"},children:[Ne.map((O,X)=>e.jsx(Td,{column:O,index:X,sortRule:n.find(he=>he.column===O.name),hasFilters:i.some(he=>he.column===O.name),isInSortStack:n.some(he=>he.column===O.name),isReadOnly:Ve,hasModifications:wr,width:m[O.name],onColumnClick:Vt,onMoveColumn:Fr,onColumnDragEnd:Vr,onResizeStart:Nr,onSortAscending:y||nr,onSortDescending:D||Sr,onRemoveSort:jr,onOpenFilterForColumn:S||(()=>{}),onClearFiltersForColumn:xe||(()=>{}),onGroupByColumn:A,onHideColumn:Cr,onManageColumns:M||(()=>{}),onManageViews:k,onResetLayout:me},O.name)),e.jsx(r.TableCell,{sx:{width:Re?76:40,minWidth:Re?76:40,p:0,border:"none",borderBottom:"1px solid",borderColor:"divider",bgcolor:"action.hover"}})]})})]})}),e.jsx(r.Box,{ref:rr,onScroll:O=>{tr.current&&(tr.current.scrollLeft=O.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:O=>O.palette.mode==="dark"?"rgba(255,255,255,0.2)":"rgba(0,0,0,0.2)",borderRadius:4,"&:hover":{bgcolor:O=>O.palette.mode==="dark"?"rgba(255,255,255,0.3)":"rgba(0,0,0,0.3)"}}},children:e.jsxs(r.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",borderSpacing:0,width:"100%",minWidth:`${Ne.reduce((O,X)=>O+(m[X.name]||(X.type==="date"?180:Dr)),Re?76:40)}px`},children:[e.jsxs("colgroup",{children:[Ne.map(O=>e.jsx("col",{style:{width:`${m[O.name]||(O.type==="date"?180:Dr)}px`}},O.name)),e.jsx("col",{style:{width:`${Re?76:40}px`}})]}),e.jsx(r.TableBody,{children:ce.length===0?e.jsx(r.TableRow,{children:e.jsx(r.TableCell,{colSpan:Ne.length+(zt?1:0),align:"center",sx:{py:4},children:e.jsx(r.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})})}):ir?ce.map((O,X)=>O.isGroupHeader?Hr(O):Ht(O,X)):ce.map((O,X)=>Ht(O,X))})]})})]}),Wt&&pt&&e.jsx(Pd,{currentPage:mr,pageSize:Mt,totalRows:Rt,totalFields:t.length,onPageChange:Wt,onPageSizeChange:pt}),!(Wt&&pt)&&e.jsx(r.Box,{sx:{px:3,py:1.5,bgcolor:"action.hover",borderTop:1,borderColor:"divider"},children:e.jsxs(r.Typography,{variant:"body2",color:"text.secondary",children:["Showing ",ce.length," ",ce.length===1?"row":"rows"]})})]})]}),e.jsxs(r.Popover,{open:!!ye,onClose:()=>nt(null),anchorEl:(ye==null?void 0:ye.anchorEl)||null,anchorReference:ye!=null&&ye.anchorEl?"anchorEl":"anchorPosition",anchorPosition:ye&&!ye.anchorEl?{top:ye.mouseY,left:ye.mouseX}:void 0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:ye!=null&&ye.anchorEl?{vertical:"top",horizontal:"right"}:{vertical:"top",horizontal:"left"},PaperProps:{sx:{minWidth:176,py:.5,borderRadius:1.5,boxShadow:3}},children:[e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{ye&&(Ge(ye.row),Pe(!0)),nt(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(z.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"View"})]}),e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{ye&&(Z(ye.row),ke(ye.rowIndex),Lt(!0)),nt(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(z.Edit,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Edit"})]}),e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{ye&&(Je==null||Je(ye.rowIndex,ye.row)),nt(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(z.ContentCopy,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Duplicate"})]}),e.jsx(r.Divider,{sx:{my:.5}}),e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{if(ye){Xt(ye.row);const O=Object.values(ye.row).find(X=>X!=null&&X!=="");Zt(O?String(O):""),Kt(!0)}nt(null)},sx:{py:1,px:2,gap:1.5,color:"error.main"},children:[e.jsx(z.Delete,{sx:{fontSize:18,color:"error.main"}}),e.jsx(r.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]}),e.jsx(Vd,{open:we,onClose:()=>{Pe(!1),Ge(null)},row:F,schema:t,reportName:Ue}),e.jsx(Ud,{open:Wr,onClose:()=>{Lt(!1),Z(null),ke(null)},onSave:O=>{ht!==null&&(rt==null||rt(ht,O))},row:ze,schema:t,reportName:Ue}),e.jsx(Hd,{open:Rr,onClose:()=>{Kt(!1),Xt(null)},onConfirm:()=>{mt!==null&&(ot==null||ot(mt))},rowPreview:Qt}),e.jsx(Xi,{isOpen:Tt,onClose:()=>dt(!1)})]})}function pr({content:t,isDev:o=!1}){const[n,i]=p.useState(null);return e.jsxs(e.Fragment,{children:[e.jsx(r.IconButton,{size:"small",onClick:s=>i(s.currentTarget),"aria-label":`Help: ${t.title}`,sx:{p:.375,color:"text.disabled","&:hover":{color:"primary.main",bgcolor:s=>T(s.palette.primary.main,.08)}},children:e.jsx(z.InfoOutlined,{sx:{fontSize:15}})}),e.jsxs(r.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:[e.jsx(r.Box,{sx:{px:2,py:1.5,bgcolor:s=>T(s.palette.primary.main,.06)},children:e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600,color:"primary.main",fontSize:"0.875rem"},children:t.title})}),e.jsx(r.Divider,{}),e.jsxs(r.Box,{sx:{px:2,py:1.5,display:"flex",flexDirection:"column",gap:1},children:[e.jsx(r.Typography,{variant:"body2",sx:{color:"text.secondary",fontSize:"0.8125rem",lineHeight:1.6},children:t.description}),t.tips&&t.tips.length>0&&e.jsx(r.Box,{component:"ul",sx:{m:0,pl:2,display:"flex",flexDirection:"column",gap:.5},children:t.tips.map((s,d)=>e.jsx(r.Box,{component:"li",sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.5},children:s},d))}),o&&t.devNote&&e.jsxs(e.Fragment,{children:[e.jsx(r.Divider,{sx:{my:.5}}),e.jsxs(r.Box,{sx:{px:1.25,py:.75,borderRadius:"6px",bgcolor:s=>T(s.palette.warning.main,.08),border:"1px solid",borderColor:s=>T(s.palette.warning.main,.2)},children:[e.jsx(r.Typography,{variant:"caption",sx:{color:"warning.dark",fontWeight:500,display:"block",mb:.25},children:"Dev note"}),e.jsx(r.Typography,{variant:"caption",sx:{color:"warning.dark",lineHeight:1.5},children:t.devNote})]})]})]})]})]})}const xr={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."}};function eu({schema:t,filters:o,onAddFilter:n,onRemoveFilter:i,onUpdateFilter:s,onClearAll:d,onReplaceFilters:l,onClose:c,focusColumn:u}){const[h,m]=p.useState(""),[b,x]=p.useState(""),[y,D]=p.useState(""),[v,C]=p.useState([]),S=ur();p.useEffect(()=>{C([...o])},[o]),p.useEffect(()=>{u&&m(u)},[u]);const I=p.useCallback(()=>{m(""),x(""),D("")},[]),f=p.useMemo(()=>t.filter(M=>M.type!=="mixed"&&M.type!=="null"&&M.type!=="array"&&M.type!=="object"),[t]),k=t.find(M=>M.name===h),j=p.useMemo(()=>{const M=k?$n(k.type):[],W=S.filter.allowedOperators;return W.length>0?M.filter(V=>W.includes(V.value)):M},[k]),a=p.useCallback(()=>!(!h||!b||uo(b)&&!y.trim()||v.length>=S.filter.maxConditions),[h,b,y,v,S]),B=p.useCallback(()=>{if(!a())return;const M={column:h,operator:b};if(uo(b)){const V=k==null?void 0:k.type;M.value=V==="number"?Number(y):y}if(v.some(V=>V.column===M.column&&V.operator===M.operator&&V.value===M.value)){I();return}C([...v,M]),I()},[a,h,b,k,y,v,I]),R=p.useCallback(M=>{C(v.filter((W,V)=>V!==M))},[v]),J=p.useMemo(()=>v.length!==o.length?!0:JSON.stringify(v)!==JSON.stringify(o),[v,o]),K=p.useCallback(()=>{l(v),c()},[v,l,c]),ee=p.useCallback(()=>{C([...o]),I(),c()},[o,I,c]),g=p.useCallback(M=>{var xe;const W=t.find(me=>me.name===M.column);if(!W)return"";const Q=((xe=$n(W.type).find(me=>me.value===M.operator))==null?void 0:xe.label)||M.operator;return uo(M.operator)?`${M.column} ${Q.toLowerCase()} "${M.value}"`:`${M.column} ${Q.toLowerCase()}`},[t]);return e.jsx(r.Box,{onClick:ee,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:M=>T(M.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:M=>M.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(r.Paper,{onClick:M=>M.stopPropagation(),elevation:0,sx:{position:"relative",width:520,maxWidth:"calc(100vw - 120px)",maxHeight:"min(520px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:M=>Me(M),bgcolor:"background.paper",outline:"none",boxShadow:M=>te(M,"menu"),animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx(r.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Filter columns"}),e.jsx(pr,{content:xr.filter,isDev:process.env.NODE_ENV==="development"})]}),e.jsx(r.IconButton,{onClick:ee,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(z.Close,{sx:{fontSize:20}})})]}),e.jsxs(r.Box,{sx:{flex:1,overflow:"auto",px:3,py:1,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:M=>T(M.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:M=>T(M.palette.text.primary,.3)}}},children:[e.jsxs(r.Box,{sx:{mb:2.5},children:[e.jsx(r.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add filter"}),e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1.75},children:[e.jsxs(r.FormControl,{size:"small",fullWidth:!0,disabled:v.length>=S.filter.maxConditions,children:[e.jsx(r.InputLabel,{sx:{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},children:"Column"}),e.jsx(r.Select,{value:h,onChange:M=>{m(M.target.value),x(""),D("")},label:"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"}},children:f.map(M=>e.jsxs(r.MenuItem,{value:M.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:W=>We(W),"&:hover":{bgcolor:W=>T(W.palette.primary.main,.2)}}},children:[Qe(M.name)," (",M.type,")"]},M.name))})]}),h&&e.jsxs(r.FormControl,{size:"small",fullWidth:!0,children:[e.jsx(r.InputLabel,{sx:{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},children:"Operator"}),e.jsx(r.Select,{value:b,onChange:M=>{x(M.target.value),D("")},label:"Operator",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"}},children:j.map(M=>e.jsx(r.MenuItem,{value:M.value,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:W=>We(W),"&:hover":{bgcolor:W=>T(W.palette.primary.main,.2)}}},children:M.label},M.value))})]}),b&&uo(b)&&e.jsx(r.TextField,{size:"small",fullWidth:!0,type:(k==null?void 0:k.type)==="number"?"number":"text",value:y,onChange:M=>D(M.target.value),label:"Value",placeholder:"Enter value...",sx:{"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"divider",transition:"border-color 0.2s ease"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputBase-input":{py:1,color:"text.primary"}}})]}),e.jsx(r.Button,{onClick:B,disabled:!a(),sx:{mt:1.5,fontSize:"0.875rem",color:"primary.main",p:0,justifyContent:"flex-start",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"primary.dark",textDecoration:"underline"},"&.Mui-disabled":{color:"text.disabled"}},children:"+ Add another filter"}),v.length>=S.filter.maxConditions&&e.jsxs(r.Typography,{variant:"caption",sx:{display:"block",mt:.75,color:"warning.dark",fontSize:"0.75rem",fontWeight:500},children:["Filter limit reached — maximum ",S.filter.maxConditions," filters allowed. Remove an existing filter to add a new one."]})]}),v.length>0&&e.jsxs(r.Box,{children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1.5},children:[e.jsxs(r.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:["Active filters (",v.length,")"]}),e.jsx(r.Button,{onClick:()=>{d(),c()},sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"}},children:"Clear all"})]}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:v.map((M,W)=>e.jsx(r.Chip,{label:g(M),onDelete:()=>R(W),sx:{bgcolor:V=>We(V),color:"primary.main",fontSize:"0.875rem",fontWeight:400,height:32,borderRadius:"16px",border:V=>`1px solid ${T(V.palette.primary.main,.3)}`,transition:"all 0.2s ease","&:hover":{bgcolor:V=>T(V.palette.primary.main,.2),borderColor:V=>T(V.palette.primary.main,.5)},"& .MuiChip-label":{px:1.5,color:"primary.main"},"& .MuiChip-deleteIcon":{color:"primary.main",fontSize:18,transition:"all 0.2s ease","&:hover":{color:"primary.dark"}}}},W))})]})]}),e.jsxs(r.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[e.jsx(r.Button,{onClick:ee,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:M=>`${M.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:K,disabled:!J,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:M=>`${M.shape.borderRadius}px`,boxShadow:M=>te(M,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:M=>te(M,"hoverButton")},"&:active":{boxShadow:M=>te(M,"pressedButton"),transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Apply filter"})]})]})})}const mi="SORT_RULE";function tu({rule:t,index:o,onToggleDirection:n,onRemove:i,onMove:s}){const d=p.useRef(null),[{handlerId:l},c]=Ot.useDrop({accept:mi,collect(m){return{handlerId:m.getHandlerId()}},hover(m,b){var I;if(!d.current)return;const x=m.index,y=o;if(x===y)return;const D=(I=d.current)==null?void 0:I.getBoundingClientRect(),v=(D.bottom-D.top)/2,C=b.getClientOffset(),S=((C==null?void 0:C.y)??0)-D.top;x<y&&S<v||x>y&&S>v||(s(x,y),m.index=y)}}),[{isDragging:u},h]=Ot.useDrag({type:mi,item:()=>({index:o}),collect:m=>({isDragging:m.isDragging()})});return h(c(d)),e.jsxs(r.Box,{ref:d,"data-handler-id":l,sx:{display:"flex",alignItems:"center",gap:1.25,px:2,py:1.25,borderRadius:"8px",bgcolor:"background.paper",border:"1px solid divider",opacity:u?.4:1,cursor:"move",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:"action.hover",borderColor:"divider",boxShadow:m=>te(m,"restButtonLight"),transform:"translateY(-1px)"}},children:[e.jsx(r.Chip,{label:t.priority,size:"small",sx:{width:26,height:26,fontSize:"0.75rem",fontWeight:600,bgcolor:"primary.main",color:"background.paper",boxShadow:m=>`0 1px 2px 0 ${T(m.palette.primary.main,.3)}`,"& .MuiChip-label":{px:0}}}),e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:"3px",cursor:"grab",px:.5,opacity:.6,transition:"opacity 0.2s ease","&:hover":{opacity:1},"&:active":{cursor:"grabbing"}},children:[e.jsx(r.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}}),e.jsx(r.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}}),e.jsx(r.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}})]}),e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.875rem",fontWeight:400,color:"text.primary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"0 0 100px",lineHeight:1.5},children:t.column}),e.jsx(r.FormControl,{size:"small",sx:{flex:1,minWidth:100},children:e.jsxs(r.Select,{value:t.direction,onChange:m=>n(o,m.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:[e.jsx(r.MenuItem,{value:"asc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:m=>We(m),"&:hover":{bgcolor:m=>T(m.palette.primary.main,.2)}}},children:"Ascending"}),e.jsx(r.MenuItem,{value:"desc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:m=>We(m),"&:hover":{bgcolor:m=>T(m.palette.primary.main,.2)}}},children:"Descending"})]})}),e.jsx(r.IconButton,{onClick:()=>i(o),size:"small",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{color:"error.main",bgcolor:m=>T(m.palette.error.main,.08),transform:"scale(1.1)"}},children:e.jsx(z.Close,{sx:{fontSize:18}})})]})}function ru({schema:t,sortStack:o,onUpdateSortStack:n,onClose:i}){const[s,d]=p.useState(""),[l,c]=p.useState([]);p.useEffect(()=>{c([...o])},[o]);const u=p.useMemo(()=>JSON.stringify(l)!==JSON.stringify(o),[l,o]),h=ur(),m=p.useCallback(()=>!(l.length>=h.sort.maxLevels||!s||l.some(f=>f.column===s)),[l,s]),b=p.useCallback(()=>{if(!m())return;const f=l.length+1,k={column:s,direction:"asc",priority:f};c([...l,k]),d("")},[m,s,l]),x=p.useCallback(f=>{const j=l.filter((a,B)=>B!==f).map((a,B)=>({...a,priority:B+1}));c(j)},[l]),y=p.useCallback((f,k)=>{const j=[...l];j[f]={...j[f],direction:k},c(j)},[l]),D=p.useCallback((f,k)=>{const j=[...l],[a]=j.splice(f,1);j.splice(k,0,a);const B=j.map((R,J)=>({...R,priority:J+1}));c(B)},[l]),v=p.useCallback(()=>{n([]),i()},[n,i]),C=p.useCallback(()=>{n(l),i()},[l,n,i]),S=p.useCallback(()=>{c([...o]),d(""),i()},[o,i]),I=t.filter(f=>!l.some(k=>k.column===f.name));return e.jsx(Ot.DndProvider,{backend:an.HTML5Backend,children:e.jsx(r.Box,{onClick:S,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:f=>T(f.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:f=>f.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(r.Paper,{onClick:f=>f.stopPropagation(),elevation:0,sx:{position:"relative",width:480,maxWidth:"calc(100vw - 120px)",maxHeight:"min(440px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:f=>Me(f),bgcolor:"background.paper",outline:"none",boxShadow:f=>te(f,"menu"),animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx(r.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Sort columns"}),e.jsx(pr,{content:xr.sort,isDev:process.env.NODE_ENV==="development"})]}),e.jsx(r.IconButton,{onClick:S,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(z.Close,{sx:{fontSize:20}})})]}),e.jsxs(r.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:f=>T(f.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:f=>T(f.palette.text.primary,.3)}}},children:[e.jsxs(r.Box,{sx:{mb:2.5},children:[e.jsx(r.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add sort level"}),e.jsxs(r.FormControl,{size:"small",fullWidth:!0,disabled:l.length>=h.sort.maxLevels,children:[e.jsx(r.InputLabel,{sx:{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},children:"Select column..."}),e.jsx(r.Select,{value:s,onChange:f=>d(f.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:I.map(f=>e.jsx(r.MenuItem,{value:f.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:k=>We(k),"&:hover":{bgcolor:k=>T(k.palette.primary.main,.2)}}},children:Qe(f.name)},f.name))})]}),e.jsx(r.Button,{onClick:b,disabled:!m(),sx:{mt:1.5,fontSize:"0.875rem",color:"primary.main",p:0,justifyContent:"flex-start",minHeight:"auto",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"primary.dark",textDecoration:"underline"},"&.Mui-disabled":{color:"text.disabled"}},children:"+ Add sort column"}),l.length>=h.sort.maxLevels&&e.jsxs(r.Typography,{variant:"caption",sx:{mt:.75,display:"block",color:"warning.dark",fontSize:"0.75rem",fontWeight:500},children:["Maximum ",h.sort.maxLevels," sort levels allowed"]})]}),l.length>0&&e.jsxs(r.Box,{children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1.5},children:[e.jsxs(r.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:["Sorted sequence (",l.length,"/",h.sort.maxLevels,")"]}),e.jsx(r.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"})]}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:l.map((f,k)=>e.jsx(tu,{rule:f,index:k,onToggleDirection:y,onRemove:x,onMove:D},`${f.column}-${k}`))})]})]}),e.jsxs(r.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[e.jsx(r.Button,{onClick:S,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:f=>`${f.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:C,variant:"contained",disabled:!u||l.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:f=>`${f.shape.borderRadius}px`,boxShadow:f=>te(f,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:f=>te(f,"hoverButton")},"&:active":{boxShadow:f=>te(f,"pressedButton"),transform:"translateY(1px)"}},children:"Apply sort"})]})]})})})}function ou({views:t,activeViewId:o,onSelectView:n,onCreateView:i,onEditView:s,onDeleteView:d,onRestoreView:l,onPermanentDelete:c,onPromoteToGlobal:u,isAdmin:h=!1,onClose:m}){var f,k;const b=At(),x=b.palette,y=t.filter(j=>!j.isDeleted),D=t.filter(j=>j.isDeleted),v=y.filter(j=>j.scope==="global"),C=y.filter(j=>j.scope!=="global"),S=j=>{var K,ee,g,M,W;const a=j.scope==="global",B=j.id===o,R=h||!a,J=h&&!a;return e.jsx(r.Paper,{variant:"outlined",sx:{p:0,overflow:"hidden",borderRadius:"8px",borderColor:B?"primary.main":"divider",bgcolor:B?T(x.primary.main,.03):"background.paper",transition:"border-color 0.15s","&:hover":{borderColor:B?"primary.main":T(x.text.primary,.22)}},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:1.75,py:1.25,gap:1},children:[e.jsxs(r.Box,{sx:{flex:1,minWidth:0,cursor:"pointer",display:"flex",alignItems:"center",gap:1},onClick:()=>{n(j.id),m()},children:[e.jsxs(r.Box,{sx:{minWidth:0},children:[e.jsx(r.Typography,{sx:{fontSize:"0.875rem",fontWeight:B?600:500,color:B?"primary.main":"text.primary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:j.name}),j.description&&e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:j.description})]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[a&&e.jsx(r.Chip,{label:"Global",size:"small",icon:e.jsx(z.Language,{sx:{fontSize:"11px !important"}}),sx:{height:20,fontSize:"0.625rem",fontWeight:700,letterSpacing:"0.04em",bgcolor:T(((K=x.info)==null?void 0:K.main)??x.primary.main,.1),color:((ee=x.info)==null?void 0:ee.main)??x.primary.main,border:`1px solid ${T(((g=x.info)==null?void 0:g.main)??x.primary.main,.25)}`,"& .MuiChip-label":{px:.625},"& .MuiChip-icon":{ml:.5}}}),j.isDefault&&e.jsx(r.Chip,{label:"Default",size:"small",sx:{height:20,fontSize:"0.625rem",fontWeight:600,bgcolor:T(x.text.secondary,.08),color:"text.secondary","& .MuiChip-label":{px:.75}}})]})]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.25,flexShrink:0},children:[J&&u&&e.jsx(r.Tooltip,{title:"Promote to Global View",arrow:!0,placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:V=>{V.stopPropagation(),u(j.id)},sx:{p:.625,color:"text.secondary",borderRadius:"6px","&:hover":{color:((M=x.info)==null?void 0:M.main)??x.primary.main,bgcolor:T(((W=x.info)==null?void 0:W.main)??x.primary.main,.08)}},children:e.jsx(z.Language,{sx:{fontSize:16}})})}),R&&e.jsx(r.Tooltip,{title:a&&!h?"Global Views are read-only":"Edit view",arrow:!0,placement:"top",children:e.jsx("span",{children:e.jsx(r.IconButton,{size:"small",disabled:a&&!h,onClick:V=>{V.stopPropagation(),s(j.id)},sx:{p:.625,borderRadius:"6px","&:hover":{color:"primary.main",bgcolor:T(x.primary.main,.08)},"&.Mui-disabled":{opacity:.35}},children:e.jsx(z.Edit,{sx:{fontSize:15}})})})}),e.jsx(r.Tooltip,{title:a&&!h?"Only admins can delete Global Views":"Delete view",arrow:!0,placement:"top",children:e.jsx("span",{children:e.jsx(r.IconButton,{size:"small",disabled:a&&!h,onClick:V=>{V.stopPropagation(),d(j.id)},sx:{p:.625,borderRadius:"6px","&:hover":{color:"error.main",bgcolor:T(x.error.main,.08)},"&.Mui-disabled":{opacity:.35}},children:e.jsx(z.Delete,{sx:{fontSize:15}})})})})]})]})},j.id)},I=j=>{var a;return e.jsxs(r.Paper,{variant:"outlined",sx:{px:1.75,py:1.25,borderRadius:"8px",borderColor:"divider",display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:T(x.text.primary,.02)},children:[e.jsx(r.Typography,{sx:{fontSize:"0.875rem",color:"text.disabled",textDecoration:"line-through",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:j.name}),e.jsxs(r.Box,{sx:{display:"flex",gap:.25,flexShrink:0,ml:1},children:[l&&e.jsx(r.Tooltip,{title:"Restore view",arrow:!0,children:e.jsx(r.IconButton,{size:"small",onClick:B=>{B.stopPropagation(),l(j.id)},sx:{p:.625,borderRadius:"6px","&:hover":{color:"success.main",bgcolor:T(((a=x.success)==null?void 0:a.main)??"#2e7d32",.08)}},children:e.jsx(z.Undo,{sx:{fontSize:15}})})}),c&&e.jsx(r.Tooltip,{title:"Delete permanently",arrow:!0,children:e.jsx(r.IconButton,{size:"small",onClick:B=>{B.stopPropagation(),c(j.id)},sx:{p:.625,borderRadius:"6px","&:hover":{color:"error.main",bgcolor:T(x.error.main,.08)}},children:e.jsx(z.Delete,{sx:{fontSize:15}})})})]})]},j.id)};return e.jsxs(r.Dialog,{open:!0,onClose:m,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{mt:8,borderRadius:Me(b),maxHeight:"min(640px, calc(100vh - 80px))",boxShadow:`0 8px 32px ${T(((f=x.common)==null?void 0:f.black)??"#000",.14)}`}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:[e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontSize:"1rem",fontWeight:600},children:"Manage Views"}),h&&e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.125},children:"Admin mode — you can promote Personal Views to Global"})]}),e.jsx(r.IconButton,{onClick:m,size:"small",sx:{color:"text.secondary"},children:e.jsx(z.Close,{sx:{fontSize:19}})})]}),e.jsxs(r.DialogContent,{sx:{overflowY:"auto",pb:2},children:[e.jsx(r.Box,{sx:{mb:2},children:e.jsx(r.Button,{onClick:i,variant:"contained",startIcon:e.jsx(z.Add,{sx:{fontSize:16}}),size:"small",sx:{borderRadius:j=>`${j.shape.borderRadius}px`},children:"Create New View"})}),v.length>0&&e.jsxs(r.Box,{sx:{mb:2.5},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:1},children:[e.jsx(z.Language,{sx:{fontSize:14,color:((k=x.info)==null?void 0:k.main)??x.primary.main}}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:700,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.07em"},children:"Global Views"}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:"— visible to all users"})]}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:v.map(S)})]}),C.length>0&&e.jsxs(r.Box,{sx:{mb:2.5},children:[e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:700,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.07em",mb:1},children:"Personal Views"}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:C.map(S)})]}),D.length>0&&e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:700,color:"text.disabled",textTransform:"uppercase",letterSpacing:"0.07em",mb:1},children:"Recently Deleted"}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:D.map(I)})]}),y.length===0&&D.length===0&&e.jsx(r.Box,{sx:{py:4,textAlign:"center",color:"text.disabled"},children:e.jsx(r.Typography,{variant:"body2",children:"No views created yet"})})]}),e.jsx(r.DialogActions,{sx:{px:3,py:1.5,borderTop:"1px solid",borderColor:"divider",justifyContent:"flex-end"},children:e.jsx(r.Button,{onClick:m,variant:"contained",sx:{fontSize:"0.875rem",borderRadius:j=>`${j.shape.borderRadius}px`,px:3},children:"Close"})})]})}const fo=50;function hi({currentSnapshot:t,onSave:o,onClose:n,isEditMode:i=!1,initialName:s="",initialDescription:d="",initialIsDefault:l=!1,atViewLimit:c=!1,maxViews:u=10}){const[h,m]=p.useState(s),[b,x]=p.useState(!1),[y,D]=p.useState(d),[v,C]=p.useState(l),S=()=>{if(!h.trim()){x(!0);return}if(h.trim().length>fo){x(!0);return}o(h.trim(),y.trim(),v),n()},I=k=>{k.key==="Enter"&&!k.shiftKey?S():k.key==="Escape"&&n()},f=()=>i&&s?`Update ${s} view`:"Create New Report View";return e.jsxs(r.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{mt:8,borderRadius:k=>Me(k),boxShadow:k=>te(k,"menu")}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:[f(),e.jsx(r.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:e.jsx(z.Close,{sx:{fontSize:20}})})]}),e.jsx(r.DialogContent,{children:e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:2,pt:1},children:[c&&!i&&e.jsxs(r.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."]}),e.jsx(r.TextField,{label:"View Name",required:!0,value:h,onChange:k=>{k.target.value.length<=fo&&m(k.target.value),b&&k.target.value.trim()&&x(!1)},onKeyDown:I,placeholder:"e.g., Active Users",autoFocus:!0,fullWidth:!0,size:"small",disabled:c&&!i,inputProps:{maxLength:fo},error:b&&!h.trim(),helperText:b&&!h.trim()?"View name is required":`${h.length} / ${fo}`}),e.jsx(r.TextField,{label:"Description (optional)",value:y,onChange:k=>D(k.target.value),placeholder:"Brief description of this view",multiline:!0,rows:2,fullWidth:!0,size:"small"}),e.jsxs(r.Paper,{sx:{p:2,bgcolor:"action.hover"},variant:"outlined",children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,mb:1},children:"This view will capture:"}),e.jsxs(r.Box,{component:"ul",sx:{m:0,pl:2,"& li":{fontSize:"body2.fontSize",color:"text.secondary"}},children:[e.jsxs("li",{children:[t.filters.length," filter",t.filters.length!==1?"s":""]}),e.jsxs("li",{children:["Sorting: ",xa(t.sortStack)]}),e.jsx("li",{children:"Column order & visibility"})]})]}),!i&&e.jsx(r.FormControlLabel,{control:e.jsx(r.Checkbox,{checked:v,onChange:k=>C(k.target.checked),size:"small"}),label:e.jsx(r.Typography,{variant:"body2",children:"Set as default view"})})]})}),e.jsxs(r.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:[e.jsx(r.Button,{onClick:n,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:k=>`${k.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:S,variant:"contained",disabled:c&&!i,startIcon:e.jsx(z.Save,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:.875,minHeight:36,borderRadius:k=>`${k.shape.borderRadius}px`,boxShadow:k=>te(k,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:k=>te(k,"hoverButton")},"&:active":{boxShadow:k=>te(k,"pressedButton"),transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"text.disabled"}},children:i?"Save Changes":"Create Report View"})]})]})}function nu({viewName:t,onConfirm:o,onCancel:n}){return e.jsxs(r.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:i=>Me(i),maxHeight:"min(480px, calc(100vh - 180px))",my:"auto",boxShadow:i=>te(i,"menu")}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:["Delete View",e.jsx(r.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:e.jsx(z.Close,{sx:{fontSize:20}})})]}),e.jsx(r.DialogContent,{children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.5,mt:1},children:[e.jsx(z.Warning,{color:"error",sx:{fontSize:20,flexShrink:0}}),e.jsxs(r.Box,{children:[e.jsxs(r.Typography,{variant:"body2",sx:{mb:1},children:["Are you sure you want to delete the view ",e.jsxs("strong",{children:['"',t,'"']}),"?"]}),e.jsx(r.Typography,{variant:"body2",color:"text.secondary",children:"This action cannot be undone."})]})]})}),e.jsxs(r.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid",borderColor:"divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:[e.jsx(r.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"}),e.jsx(r.Button,{onClick:o,variant:"contained",color:"error",sx:{fontSize:"0.875rem",px:3,py:.875,minHeight:36,borderRadius:i=>`${i.shape.borderRadius}px`,boxShadow:i=>te(i,"restButton"),transition:"all 0.2s ease","&:hover":{boxShadow:i=>te(i,"hoverButton")},"&:active":{boxShadow:i=>te(i,"pressedButton"),transform:"translateY(1px)"}},children:"Delete View"})]})]})}const yo=100,bo=600,fi="COLUMN";function iu({column:t,index:o,isVisible:n,width:i,onToggleVisibility:s,onWidthChange:d,moveColumn:l}){const c=p.useRef(null),[u,h]=p.useState(i.toString());p.useEffect(()=>{h(i.toString())},[i]);const[{handlerId:m},b]=Ot.useDrop({accept:fi,collect(I){return{handlerId:I.getHandlerId()}},hover(I,f){var K;if(!c.current)return;const k=I.index,j=o;if(k===j)return;const a=(K=c.current)==null?void 0:K.getBoundingClientRect(),B=(a.bottom-a.top)/2,R=f.getClientOffset(),J=((R==null?void 0:R.y)??0)-a.top;k<j&&J<B||k>j&&J>B||(l(k,j),I.index=j)}}),[{isDragging:x},y]=Ot.useDrag({type:fi,item:()=>({index:o}),collect:I=>({isDragging:I.isDragging()})});y(b(c));const D=()=>{const I=parseInt(u);if(isNaN(I)){h(i.toString()),d(t.name,i);return}const f=Math.max(yo,Math.min(bo,I));h(f.toString()),d(t.name,f)},v=I=>{if(I===""||/^\d+$/.test(I)){h(I);const f=parseInt(I);if(!isNaN(f)&&f>=yo){const k=Math.min(bo,f);d(t.name,k)}}},C=I=>{I.key==="Enter"&&(I.preventDefault(),D(),I.target.blur())},S=I=>({string:"primary.main",number:"success.main",boolean:"secondary.main",array:"info.main",object:"error.main",null:"text.secondary",mixed:"text.secondary"})[I]||"text.secondary";return e.jsxs(r.TableRow,{ref:c,"data-handler-id":m,sx:{opacity:x?.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:[e.jsx(r.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[e.jsx(r.Box,{sx:{color:"text.secondary",cursor:"grab",opacity:.6,transition:"opacity 0.2s ease","&:hover":{opacity:1},"&:active":{cursor:"grabbing"}},children:e.jsx(z.DragIndicator,{sx:{fontSize:20}})}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:400,fontSize:"0.875rem",color:n?"text.primary":"text.secondary"},children:Qe(t.name)})]})}),e.jsx(r.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:e.jsx(r.Chip,{label:t.type.toUpperCase(),size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:600,bgcolor:`${S(t.type)}15`,color:S(t.type),border:`1px solid ${S(t.type)}30`,"& .MuiChip-label":{px:1}}})}),e.jsx(r.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(r.TextField,{type:"number",value:u,onChange:I=>v(I.target.value),onBlur:D,onKeyDown:C,placeholder:"150",size:"small",inputProps:{min:yo,max:bo,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}}}),e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},children:"px"})]})}),e.jsx(r.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[e.jsx(r.IconButton,{onClick:()=>s(t.name,!n),title:n?"Hide column":"Show column",size:"small",sx:{p:.75,color:n?"primary.main":"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:n?"primary.dark":"primary.main"}},children:n?e.jsx(z.Visibility,{sx:{fontSize:20}}):e.jsx(z.VisibilityOff,{sx:{fontSize:20}})}),e.jsx(r.Chip,{label:n?"Visible":"Hidden",size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:500,bgcolor:n?I=>T(I.palette.success.main,.12):"action.selected",color:n?"success.main":"text.secondary","& .MuiChip-label":{px:1}}})]})})]})}function su({schema:t,columnVisibility:o,columnOrder:n,columnWidths:i={},views:s=[],activeViewId:d="",onUpdateColumnVisibility:l,onUpdateColumnOrder:c,onUpdateColumnWidth:u,onResetLayout:h,onSaveToCurrentView:m,onSaveToAllViews:b,onSelectView:x,onClose:y}){const[D,v]=p.useState(!1),[C,S]=p.useState(n),[I,f]=p.useState(i),[k,j]=p.useState("all"),[a,B]=p.useState(null);p.useEffect(()=>{S(n)},[n]),p.useEffect(()=>{f(i)},[i]);const R=(L,A)=>{f(H=>({...H,[L]:A})),u==null||u(L,A)},J=(L,A)=>{const H=[...C],[se]=H.splice(L,1);H.splice(A,0,se),S(H),c(H)},K=()=>{h(),v(!1)},g=C.map(L=>t.find(A=>A.name===L)).filter(L=>L!==void 0).filter(L=>{const A=o[L.name]??!0;return k==="active"?A:k==="hidden"?!A:!0}),M=Object.values(o).filter(L=>L).length,W=t.length,V=s.find(L=>L.id===d),Q=s.filter(L=>!L.isDeleted),xe=Q.length>1,me=p.useMemo(()=>{if(!V)return!1;const L=V.snapshot,A=L.columnVisibility??{},H=JSON.stringify(o)!==JSON.stringify(A),se=L.columnOrder??[],G=n??[],re=JSON.stringify(G)!==JSON.stringify(se)&&!(G.length===0&&se.length===0),ae=L.columnWidths??{},ne=JSON.stringify(I)!==JSON.stringify(ae);return H||re||ne},[V,o,n,I]);return e.jsx(Ot.DndProvider,{backend:an.HTML5Backend,children:e.jsx(r.Box,{onClick:y,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:L=>T(L.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:L=>L.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(r.Paper,{onClick:L=>L.stopPropagation(),elevation:0,sx:{position:"relative",width:720,maxWidth:"calc(100vw - 120px)",maxHeight:"min(760px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:L=>Me(L),bgcolor:"background.paper",outline:"none",boxShadow:L=>te(L,"menu"),animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(r.Box,{sx:{px:3,pt:2,pb:1.5,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[e.jsxs(r.Box,{sx:{flex:1},children:[e.jsxs(r.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:["Manage columns",e.jsx(pr,{content:xr.columns,isDev:process.env.NODE_ENV==="development"})]}),e.jsxs(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary",mt:.5},children:[M," of ",W," columns visible • Drag to reorder"]})]}),Q.length>0&&x&&e.jsxs(r.Box,{sx:{ml:2},children:[e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.6875rem",color:"text.secondary",mb:.75,display:"block",textTransform:"uppercase",fontWeight:600,letterSpacing:"0.1em"},children:"View:"}),e.jsx(r.Button,{onClick:L=>B(L.currentTarget),variant:"outlined",size:"small",endIcon:e.jsx(z.KeyboardArrowDown,{sx:{fontSize:18}}),sx:{minWidth:180,justifyContent:"space-between",fontSize:"0.875rem",color:"text.primary",borderColor:"divider",py:.75,px:1.5,"&:hover":{borderColor:"primary.main",bgcolor:"action.hover"}},children:e.jsx(r.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis"},children:(V==null?void 0:V.name)||"Select View"})}),e.jsx(r.Menu,{anchorEl:a,open:!!a,onClose:()=>B(null),PaperProps:{sx:{mt:.5,borderRadius:"8px",boxShadow:L=>te(L,"small")}},children:Q.map(L=>e.jsx(r.MenuItem,{onClick:()=>{x(L.id),B(null)},selected:L.id===d,sx:{fontSize:"0.875rem",color:"text.primary",py:1,px:2,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:A=>We(A),"&:hover":{bgcolor:A=>T(A.palette.primary.main,.2)}}},children:L.name},L.id))})]}),e.jsx(r.IconButton,{onClick:y,size:"small",sx:{ml:2,p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(z.Close,{sx:{fontSize:20}})})]}),e.jsxs(r.Tabs,{value:k,onChange:(L,A)=>j(A),sx:{minHeight:36,mt:.5,"& .MuiTabs-indicator":{bgcolor:"primary.main",height:3}},children:[e.jsx(r.Tab,{label:"All",value:"all",sx:{minHeight:36,py:.75,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary","&.Mui-selected":{color:"primary.main"}}}),e.jsx(r.Tab,{label:"Visible",value:"active",sx:{minHeight:36,py:.75,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary","&.Mui-selected":{color:"primary.main"}}}),e.jsx(r.Tab,{label:"Hidden",value:"hidden",sx:{minHeight:36,py:.75,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary","&.Mui-selected":{color:"primary.main"}}})]})]}),e.jsx(r.Box,{sx:{flex:1,overflow:"auto","&::-webkit-scrollbar":{width:8,height:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:L=>T(L.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:L=>T(L.palette.text.primary,.3)}}},children:e.jsxs(r.Table,{stickyHeader:!0,sx:{minWidth:650},children:[e.jsx(r.TableHead,{children:e.jsxs(r.TableRow,{children:[e.jsx(r.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"}),e.jsx(r.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"}),e.jsx(r.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:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:["Width",e.jsx(r.Tooltip,{title:`Column width in pixels (min: ${yo}px, max: ${bo}px)`,arrow:!0,placement:"top",children:e.jsx(z.InfoOutlined,{sx:{fontSize:14,color:"text.secondary",cursor:"help"}})})]})}),e.jsx(r.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"})]})}),e.jsx(r.TableBody,{children:g.length===0?e.jsx(r.TableRow,{children:e.jsx(r.TableCell,{colSpan:4,align:"center",sx:{py:6,borderBottom:"none"},children:e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"text.secondary"},children:"No columns in this category"})})}):g.map((L,A)=>e.jsx(iu,{column:L,index:A,isVisible:o[L.name]??!0,width:I[L.name]||170,onToggleVisibility:l,onWidthChange:R,moveColumn:J},L.name))})]})}),e.jsxs(r.Box,{sx:{px:3,py:1.75,borderTop:"1px solid divider",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0,bgcolor:"action.hover"},children:[e.jsx(r.Button,{onClick:()=>v(!0),disabled:!me,variant:"outlined",startIcon:e.jsx(z.Undo,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",color:"text.secondary",borderColor:"divider",px:2.5,py:.875,minHeight:36,borderRadius:L=>`${L.shape.borderRadius}px`,"&:hover":{borderColor:"primary.main",bgcolor:"background.paper",color:"primary.main"},"&.Mui-disabled":{color:"text.disabled",borderColor:"divider"}},children:"Reset to default"}),e.jsxs(r.Stack,{direction:"row",spacing:1.25,children:[m&&e.jsx(r.Button,{onClick:()=>{m(I),y()},disabled:!me,variant:"contained",startIcon:e.jsx(z.Save,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:2.5,py:.875,minHeight:36,borderRadius:L=>`${L.shape.borderRadius}px`,boxShadow:L=>te(L,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:L=>te(L,"hoverButton")},"&:active":{boxShadow:L=>te(L,"pressedButton"),transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"text.disabled"}},children:"Save to current view"}),b&&xe&&e.jsx(r.Button,{onClick:()=>{b(I),y()},disabled:!me||!xe,variant:"contained",startIcon:e.jsx(z.GridView,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"success.main",color:"background.paper",px:2.5,py:.875,minHeight:36,borderRadius:L=>`${L.shape.borderRadius}px`,boxShadow:L=>te(L,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"success.dark",boxShadow:L=>te(L,"hoverButton")},"&:active":{boxShadow:L=>te(L,"pressedButton"),transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"text.disabled"}},children:"Save to all views"})]})]}),D&&e.jsx(r.Box,{onClick:()=>v(!1),sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:L=>T(L.palette.common.black,.5),display:"flex",alignItems:"center",justifyContent:"center",zIndex:L=>L.zIndex.tooltip},children:e.jsxs(r.Paper,{onClick:L=>L.stopPropagation(),elevation:0,sx:{width:400,maxWidth:"90vw",borderRadius:L=>so(L),bgcolor:"background.paper",boxShadow:L=>te(L,"menu")},children:[e.jsxs(r.Box,{sx:{px:3,py:2.5},children:[e.jsx(r.Typography,{variant:"h6",sx:{fontSize:"1rem",fontWeight:500,color:"text.primary",mb:1.5},children:"Reset column layout?"}),e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"text.secondary",lineHeight:1.5},children:"This will restore default visibility, order, and widths for all columns."})]}),e.jsxs(r.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",bgcolor:"action.hover"},children:[e.jsx(r.Button,{onClick:()=>v(!1),variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,borderRadius:L=>`${L.shape.borderRadius}px`,"&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:K,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"error.main",color:"background.paper",px:3,py:1,borderRadius:L=>`${L.shape.borderRadius}px`,boxShadow:L=>te(L,"pressedButton"),"&:hover":{bgcolor:"error.dark",boxShadow:L=>te(L,"hoverButton")},"&:active":{boxShadow:L=>te(L,"pressedButton"),transform:"translateY(1px)"}},children:"Reset layout"})]})]})})]})})})}function au({schema:t,grouping:o,onApply:n,onClose:i}){var a;const[s,d]=p.useState(o||{enabled:!1,levels:[],collapsedGroups:[]}),[l,c]=p.useState(""),[u,h]=p.useState(null),m=p.useMemo(()=>aa(t),[t]),b=p.useMemo(()=>m.filter(B=>!s.levels.some((R,J)=>R.column===B.name&&J!==u)),[m,s.levels,u]),x=ur(),y=s.levels.length<x.grouping.maxLevels&&b.length>0,D=p.useCallback(()=>{!y||!l||(d({...s,levels:[...s.levels,{column:l}],enabled:!0}),c(""))},[y,l,s]),v=p.useCallback(B=>{const R=s.levels.filter((J,K)=>K!==B);if(R.length===0){n(null),i();return}d({...s,levels:R,enabled:R.length>0})},[s,n,i]),C=p.useCallback(B=>{h(B),c(s.levels[B].column)},[s.levels]),S=p.useCallback(()=>{if(u===null||!l)return;const B=[...s.levels];B[u]={column:l},d({...s,levels:B}),h(null),c("")},[u,l,s]),I=p.useCallback(()=>{h(null),c("")},[]),f=p.useCallback((B,R)=>{const J=R==="up"?B-1:B+1;if(J<0||J>=s.levels.length)return;const K=[...s.levels],[ee]=K.splice(B,1);K.splice(J,0,ee),d({...s,levels:K})},[s]),k=p.useCallback(()=>{n(null),i()},[n,i]),j=p.useCallback(()=>{s.levels.length===0?n(null):n({...s,enabled:!0,collapsedGroups:(o==null?void 0:o.collapsedGroups)||[]}),i()},[s,o,n,i]);return e.jsx(r.Box,{onClick:i,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:B=>T(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:e.jsxs(r.Paper,{onClick:B=>B.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(560px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:B=>Me(B),bgcolor:"background.paper",outline:"none",boxShadow:B=>te(B,"menu"),animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx(r.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Group configuration"}),"// eslint-disable-next-line no-undef",e.jsx(pr,{content:xr.grouping,isDev:process.env.NODE_ENV==="development"})]}),e.jsx(r.IconButton,{onClick:i,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(z.Close,{sx:{fontSize:20}})})]}),e.jsx(r.Box,{sx:{flex:1,overflow:"auto",px:3,py:1,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:B=>T(B.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:B=>T(B.palette.text.primary,.3)}}},children:e.jsxs(r.Stack,{spacing:2.5,children:[u===null&&e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add group level"}),e.jsx(r.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:e.jsxs(r.Select,{value:l,onChange:B=>c(B.target.value),disabled:!y,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:[e.jsx(r.MenuItem,{value:"",sx:{fontSize:"0.875rem",color:"text.secondary"},children:"Select a column..."}),b.map(B=>e.jsxs(r.MenuItem,{value:B.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:R=>We(R),"&:hover":{bgcolor:R=>T(R.palette.primary.main,.2)}}},children:[Qe(B.name)," (",B.type.toUpperCase(),")"]},B.name))]})}),e.jsx(r.Button,{onClick:D,disabled:!y||!l,variant:"outlined",startIcon:e.jsx(z.Add,{sx:{fontSize:18}}),fullWidth:!0,sx:{fontSize:"0.875rem",color:"primary.main",borderColor:"divider",py:1,transition:"all 0.2s ease","&:hover":{borderColor:"primary.main",bgcolor:"action.hover"},"&.Mui-disabled":{color:"text.disabled",borderColor:"divider"}},children:"Add group level"}),s.levels.length>=x.grouping.maxLevels&&e.jsx(r.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",textAlign:"center",mt:1.5,fontSize:"0.75rem",color:"text.secondary"},children:"Maximum group levels (3) reached"}),m.length===0&&e.jsx(r.Typography,{variant:"body2",color:"text.secondary",sx:{textAlign:"center",py:2,fontSize:"0.875rem",color:"text.secondary"},children:"No groupable columns available. Only STRING and BOOLEAN columns can be grouped."})]}),u!==null&&e.jsxs(r.Alert,{severity:"warning",sx:{borderRadius:"8px",border:B=>`1px solid ${T(B.palette.warning.main,.5)}`,bgcolor:B=>T(B.palette.warning.main,.12),"& .MuiAlert-icon":{color:"warning.main"}},children:[e.jsxs(r.Typography,{variant:"body2",sx:{fontWeight:500,mb:1.5,fontSize:"0.875rem",color:"text.primary"},children:["Edit Group Level ",u+1]}),e.jsx(r.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:e.jsxs(r.Select,{value:l,onChange:B=>c(B.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:[e.jsx(r.MenuItem,{value:"",sx:{fontSize:"0.875rem"},children:"Select a column..."}),e.jsxs(r.MenuItem,{value:s.levels[u].column,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:B=>We(B)}},children:[s.levels[u].column," (",(a=t.find(B=>B.name===s.levels[u].column))==null?void 0:a.type.toUpperCase(),")"]}),b.filter(B=>B.name!==s.levels[u].column).map(B=>e.jsxs(r.MenuItem,{value:B.name,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:R=>We(R)}},children:[Qe(B.name)," (",B.type.toUpperCase(),")"]},B.name))]})}),e.jsxs(r.Stack,{direction:"row",spacing:1.5,children:[e.jsx(r.Button,{onClick:S,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:B=>te(B,"pressedButton")}},children:"Save"}),e.jsx(r.Button,{onClick:I,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"})]})]}),s.levels.length>0&&u===null&&e.jsxs(r.Box,{children:[e.jsxs(r.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1.5},children:[e.jsx(r.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:"Active group levels"}),e.jsx(r.Button,{onClick:k,size:"small",sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"}},children:"Clear all"})]}),e.jsx(r.Stack,{spacing:1.5,children:s.levels.map((B,R)=>{const J=t.find(K=>K.name===B.column);return e.jsxs(r.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:K=>te(K,"pressedButtonLight")}},children:[e.jsx(r.Chip,{label:`L${R+1}`,size:"small",sx:{width:40,height:28,fontWeight:600,fontSize:"0.75rem",bgcolor:"primary.main",color:"background.paper",boxShadow:K=>`0 1px 2px 0 ${T(K.palette.primary.main,.3)}`}}),e.jsxs(r.Box,{sx:{flex:1},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:B.column}),e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},children:J==null?void 0:J.type.toUpperCase()})]}),e.jsxs(r.Stack,{direction:"row",spacing:.5,children:[e.jsx(r.IconButton,{size:"small",onClick:()=>f(R,"up"),disabled:R===0,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"divider"}},children:e.jsx(z.KeyboardArrowUp,{sx:{fontSize:18}})}),e.jsx(r.IconButton,{size:"small",onClick:()=>f(R,"down"),disabled:R===s.levels.length-1,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"divider"}},children:e.jsx(z.KeyboardArrowDown,{sx:{fontSize:18}})}),e.jsx(r.IconButton,{size:"small",onClick:()=>C(R),sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover",color:"primary.main"}},children:e.jsx(z.Edit,{sx:{fontSize:18}})}),e.jsx(r.IconButton,{size:"small",onClick:()=>v(R),sx:{color:"text.secondary","&:hover":{bgcolor:K=>T(K.palette.error.main,.08),color:"error.main"}},children:e.jsx(z.Delete,{sx:{fontSize:18}})})]})]},R)})})]})]})}),e.jsxs(r.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[e.jsx(r.Button,{onClick:i,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"}),e.jsx(r.Button,{onClick:j,variant:"contained",disabled:s.levels.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:B=>`${B.shape.borderRadius}px`,boxShadow:B=>te(B,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:B=>te(B,"hoverButton")},"&:active":{boxShadow:B=>te(B,"pressedButton"),transform:"translateY(1px)"}},children:"Apply grouping"})]})]})})}const lu={filters:z.FilterList,sorting:z.UnfoldMore,visibility:z.Visibility,order:z.ViewColumn,widths:z.Straighten,grouping:z.Layers};function cu({changes:t,onClose:o}){const n=i=>({filters:"primary",sorting:"secondary",visibility:"success",order:"warning",widths:"info",grouping:"error"})[i]||"default";return e.jsxs(r.Dialog,{open:!0,onClose:o,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{mt:8,borderRadius:i=>Me(i),boxShadow:i=>te(i,"menu")}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:["View Changes Summary",e.jsx(r.IconButton,{onClick:o,size:"small",sx:{color:"text.secondary"},children:e.jsx(z.Close,{sx:{fontSize:20}})})]}),e.jsx(r.DialogContent,{dividers:!0,children:t.length===0?e.jsx(r.Box,{sx:{textAlign:"center",py:4},children:e.jsx(r.Typography,{variant:"body2",color:"text.secondary",children:"No changes detected"})}):e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"The following modifications have been made to this view:"}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1.5},children:t.map((i,s)=>{const d=lu[i.category];return e.jsxs(r.Paper,{elevation:0,sx:{display:"flex",gap:1.5,p:1.5,border:1,borderColor:"divider",borderRadius:1},children:[e.jsx(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:1,bgcolor:`${n(i.category)}.lighter`,color:`${n(i.category)}.main`,flexShrink:0},children:e.jsx(d,{sx:{fontSize:16}})}),e.jsxs(r.Box,{sx:{flex:1,minWidth:0},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500},children:i.label}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:i.description})]})]},s)})})]})}),e.jsx(r.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:e.jsx(r.Button,{onClick:o,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=>te(i,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:i=>te(i,"hoverButton")},"&:active":{boxShadow:i=>te(i,"pressedButton"),transform:"translateY(1px)"}},children:"Close"})})]})}function du({viewName:t,isDefaultView:o,changes:n=[],onSaveToCurrentView:i,onSaveAsNewView:s,onCancel:d}){const[l,c]=p.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{width:"100%",flexShrink:0,bgcolor:u=>We(u),borderBottom:u=>`1px solid ${T(u.palette.primary.main,.3)}`,zIndex:10},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:1.25},children:[e.jsxs(r.Typography,{variant:"body2",sx:{fontWeight:400,fontSize:"0.875rem",color:"text.primary"},children:['Unsaved changes to "',t,'"']}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(r.Button,{onClick:d,variant:"text",size:"small",sx:{fontSize:"0.875rem",px:2,py:.625,borderRadius:"18px",color:"text.secondary",bgcolor:"transparent",minHeight:32,"&:hover":{bgcolor:u=>T(u.palette.common.black,.08),color:"text.primary"}},children:"Discard"}),e.jsx(r.Button,{onClick:s,variant:"contained",size:"small",sx:{fontSize:"0.875rem",px:2.5,py:.625,borderRadius:"18px",minHeight:32,boxShadow:"none","&:hover":{boxShadow:u=>te(u,"restButton")}},children:"Save as new view"})]})]})}),l&&e.jsx(cu,{changes:n,onClose:()=>c(!1)})]})}function uu({onExportAnyway:t,onSaveAndExport:o,onCancel:n}){return e.jsx(r.Box,{sx:{mb:2,mx:3,mt:2},children:e.jsxs(r.Alert,{severity:"warning",icon:e.jsx(z.Warning,{sx:{fontSize:20}}),action:e.jsx(r.IconButton,{size:"small",onClick:n,sx:{color:"warning.main"},children:e.jsx(z.Close,{sx:{fontSize:20}})}),sx:{alignItems:"flex-start"},children:[e.jsx(r.Typography,{variant:"subtitle2",sx:{fontWeight:600,mb:.5},children:"You are exporting with unsaved view changes"}),e.jsx(r.Typography,{variant:"body2",sx:{mb:1.5},children:"Your current view has unsaved changes. Choose how to proceed:"}),e.jsxs(r.Box,{sx:{display:"flex",gap:1},children:[e.jsx(r.Button,{onClick:o,variant:"contained",color:"primary",startIcon:e.jsx(z.Save,{sx:{fontSize:14}}),size:"small",children:"Save View & Export"}),e.jsx(r.Button,{onClick:t,variant:"contained",color:"warning",startIcon:e.jsx(z.Download,{sx:{fontSize:14}}),size:"small",children:"Export Anyway"})]})]})})}const gi=[{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 pu(t,o){if(o===null)return t.length;const n=Date.now()-o;return t.filter(i=>new Date(i.timestamp).getTime()>=n).length}function xu(t,o){if(o===null)return[];const n=Date.now()-o;return t.filter(i=>new Date(i.timestamp).getTime()<n)}function mu({auditHistory:t,onClose:o,onClearAuditHistory:n}){var D,v,C,S;const i=At(),s=i.palette,[d,l]=p.useState("1h"),[c,u]=p.useState(!1),h=[...t].sort((I,f)=>new Date(f.timestamp).getTime()-new Date(I.timestamp).getTime()),m=gi.find(I=>I.key===d),b=pu(t,m.ms),x=()=>u(!0),y=()=>{n&&(n(xu(t,m.ms)),u(!1))};return e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{onClick:o,sx:{position:"fixed",inset:0,bgcolor:T(((D=s.common)==null?void 0:D.black)??"#000",.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:e.jsxs(r.Paper,{onClick:I=>I.stopPropagation(),elevation:0,sx:{width:520,maxWidth:"calc(100vw - 48px)",maxHeight:"min(700px, calc(100vh - 80px))",display:"flex",flexDirection:"column",borderRadius:Me(i),bgcolor:"background.paper",overflow:"hidden",boxShadow:`0 8px 32px ${T(((v=s.common)==null?void 0:v.black)??"#000",.14)}, 0 2px 8px ${T(((C=s.common)==null?void 0:C.black)??"#000",.08)}`,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:[e.jsxs(r.Box,{sx:{px:2.5,py:1.75,display:"flex",alignItems:"center",justifyContent:"space-between",gap:1.5,flexShrink:0,borderBottom:"1px solid",borderColor:"divider"},children:[e.jsxs(r.Box,{sx:{minWidth:0},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(r.Typography,{sx:{fontSize:"0.9375rem",fontWeight:600,color:"text.primary"},children:"Audit History"}),e.jsx(pr,{content:xr.auditHistory,isDev:process.env.NODE_ENV==="development"})]}),e.jsxs(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.125},children:[h.length," event",h.length!==1?"s":""," recorded"]})]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1,flexShrink:0},children:[n&&t.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(r.Select,{value:d,onChange:I=>l(I.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:T(s.text.primary,.3)}},children:gi.map(I=>e.jsx(r.MenuItem,{value:I.key,sx:{fontSize:"0.8125rem"},children:I.label},I.key))}),e.jsx(r.Button,{size:"small",variant:"outlined",color:"error",startIcon:e.jsx(z.DeleteSweepOutlined,{sx:{fontSize:14}}),onClick:x,sx:{fontSize:"0.75rem",borderRadius:"7px",px:1.25,height:30,whiteSpace:"nowrap",borderColor:T(s.error.main,.5),"&:hover":{bgcolor:T(s.error.main,.06),borderColor:"error.main"}},children:"Clear Logs"})]}),e.jsx(r.IconButton,{onClick:o,size:"small",sx:{color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(z.Close,{sx:{fontSize:17}})})]})]}),e.jsx(r.Box,{sx:{flex:1,overflowY:"auto",px:2,py:1.5,bgcolor:T(s.text.primary,.012),"&::-webkit-scrollbar":{width:5},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:T(s.text.primary,.14),borderRadius:3}},children:h.length===0?e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8,gap:1,textAlign:"center"},children:[e.jsx(z.AccessTime,{sx:{fontSize:44,color:"text.disabled",opacity:.5}}),e.jsx(r.Typography,{sx:{fontSize:"0.9375rem",color:"text.secondary",fontWeight:500},children:"No audit events yet"}),e.jsx(r.Typography,{sx:{fontSize:"0.8125rem",color:"text.disabled"},children:"Changes to this report will appear here"})]}):e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:h.map(I=>{const f=Ed(i,I.feature),{summary:k,detail:j}=Ta(I);return e.jsxs(r.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:T(s.text.primary,.18)}},children:[e.jsx(r.Chip,{label:Ba(I.feature),size:"small",sx:{height:20,fontSize:"0.5625rem",fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",bgcolor:T(f,.1),color:f,border:`1px solid ${T(f,.22)}`,flexShrink:0,mt:.125,"& .MuiChip-label":{px:.75}}}),e.jsxs(r.Box,{sx:{flex:1,minWidth:0},children:[e.jsx(r.Typography,{sx:{fontSize:"0.8125rem",fontWeight:500,color:"text.primary",lineHeight:1.45,wordBreak:"break-word"},children:k}),j&&e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.25,lineHeight:1.4},children:j}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1,mt:.5,flexWrap:"wrap"},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.375},children:[e.jsx(z.AccessTime,{sx:{fontSize:11,color:"text.disabled"}}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:Da(I.timestamp)})]}),I.user&&e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.375},children:[e.jsx(z.Person,{sx:{fontSize:11,color:"text.disabled"}}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:I.user})]})]})]})]},I.id)})})})]})}),e.jsxs(r.Dialog,{open:c,onClose:()=>u(!1),maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:so(i),boxShadow:`0 8px 32px ${T(((S=s.common)==null?void 0:S.black)??"#000",.14)}`}},children:[e.jsxs(r.DialogContent,{sx:{pt:3,pb:2,px:3},children:[e.jsx(r.Box,{sx:{width:44,height:44,borderRadius:"12px",bgcolor:T(s.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(z.WarningAmberOutlined,{sx:{fontSize:22,color:"error.main"}})}),e.jsx(r.Typography,{sx:{fontSize:"0.9375rem",fontWeight:600,color:"text.primary",mb:1},children:"Clear Audit Logs"}),e.jsxs(r.Typography,{sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.65},children:["You are about to permanently remove"," ",e.jsxs(r.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:[b," audit record",b!==1?"s":""]})," ",m.key==="all"?"from all time":`from the ${m.label.toLowerCase()}`,". This action cannot be undone."]})]}),e.jsx(r.Divider,{}),e.jsxs(r.DialogActions,{sx:{px:2.5,py:1.5,gap:1},children:[e.jsx(r.Button,{onClick:()=>u(!1),variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),e.jsxs(r.Button,{onClick:y,variant:"contained",color:"error",startIcon:e.jsx(z.DeleteSweepOutlined,{sx:{fontSize:14}}),sx:{fontSize:"0.8125rem",borderRadius:"7px",px:2},children:["Clear ",b," Record",b!==1?"s":""]})]})]})]})}function hu({onSave:t,onClose:o}){const[n,i]=p.useState(""),[s,d]=p.useState(""),[l,c]=p.useState(""),[u,h]=p.useState([]),[m,b]=p.useState(""),[x,y]=p.useState(""),D=j=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(j),v=()=>{const j=l.trim();if(j){if(!D(j)){y("Please enter a valid email address");return}if(u.includes(j)){y("This email is already added");return}h([...u,j]),c(""),y("")}},C=j=>{h(u.filter(a=>a!==j))},S=j=>{j.key==="Enter"&&(j.preventDefault(),v())},I=()=>{if(!n.trim()){b("Preset name is required");return}t(n.trim(),s.trim(),u.length>0?u:void 0)},f=j=>{i(j),m&&b("")},k=j=>{c(j),x&&y("")};return e.jsx(r.Box,{onClick:o,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:j=>T(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:e.jsxs(r.Paper,{onClick:j=>j.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(480px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:j=>Me(j),bgcolor:"background.paper",outline:"none",boxShadow:j=>te(j,"menu"),animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsx(r.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Create shareable preset"}),e.jsx(r.IconButton,{onClick:o,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(z.Close,{sx:{fontSize:20}})})]}),e.jsx(r.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=>T(j.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:j=>T(j.palette.text.primary,.3)}}},children:e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[e.jsx(r.Alert,{severity:"info",icon:e.jsx(z.Info,{sx:{fontSize:20}}),sx:{borderRadius:"8px",border:j=>`1px solid ${T(j.palette.primary.main,.3)}`,bgcolor:j=>We(j),"& .MuiAlert-icon":{color:"primary.main"},"& .MuiAlert-message":{fontSize:"0.8125rem",color:"text.primary",lineHeight:1.5}},children:"This preset will capture filters, sorting, grouping, column configuration, and the active view. The actual data is not saved or shared."}),e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"text.secondary",lineHeight:1.6},children:"Save the current report configuration and generate a shareable link that others can use to view the same filters, sorting, and column layout."}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Preset name *"}),e.jsx(r.TextField,{required:!0,value:n,onChange:j=>f(j.target.value),placeholder:"e.g., Q4 Active Users Report",error:!!m,helperText:m,autoFocus:!0,fullWidth:!0,size:"small",sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"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}}})]}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Description (optional)"}),e.jsx(r.TextField,{value:s,onChange:j=>d(j.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}}})]}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Share with (optional)"}),e.jsxs(r.Box,{sx:{display:"flex",gap:1,alignItems:"flex-start"},children:[e.jsx(r.TextField,{value:l,onChange:j=>k(j.target.value),onKeyPress:S,placeholder:"Enter email address",error:!!x,helperText:x,fullWidth:!0,size:"small",InputProps:{startAdornment:e.jsx(z.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}}}),e.jsx(r.Button,{onClick:v,variant:"outlined",startIcon:e.jsx(z.Add,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",color:"primary.main",borderColor:"divider",px:2,py:1.25,minHeight:40,borderRadius:j=>`${j.shape.borderRadius}px`,flexShrink:0,"&:hover":{borderColor:"primary.main",bgcolor:"action.hover"}},children:"Add"})]}),u.length>0&&e.jsx(r.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1,mt:1.5},children:u.map(j=>e.jsx(r.Chip,{label:j,onDelete:()=>C(j),deleteIcon:e.jsx(z.Delete,{sx:{fontSize:16}}),sx:{bgcolor:a=>We(a),color:"primary.main",fontSize:"0.8125rem",height:28,"& .MuiChip-deleteIcon":{color:"primary.main","&:hover":{color:"primary.dark"}}}},j))}),e.jsx(r.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"})]})]})}),e.jsxs(r.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[e.jsx(r.Button,{onClick:o,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"}),e.jsx(r.Button,{onClick:I,variant:"contained",startIcon:e.jsx(z.Share,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:j=>`${j.shape.borderRadius}px`,boxShadow:j=>te(j,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:j=>te(j,"hoverButton")},"&:active":{boxShadow:j=>te(j,"pressedButton"),transform:"translateY(1px)"}},children:"Create & share"})]})]})})}function fu({presetName:t,onClear:o}){return e.jsx(r.Chip,{icon:e.jsx(z.Link,{sx:{fontSize:14}}),label:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:["Preset:"," ",e.jsx(r.Box,{component:"span",sx:{fontWeight:600},children:t})]}),onDelete:o,deleteIcon:e.jsx(r.IconButton,{size:"small",title:"Exit preset view",sx:{p:0},children:e.jsx(z.Close,{sx:{fontSize:14}})}),sx:{bgcolor:n=>T(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 gu({presets:t,reportId:o,onOpenPreset:n,onDeletePreset:i,onClose:s}){const d=l=>new Date(l).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});return e.jsx(r.Box,{onClick:s,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:l=>T(l.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:l=>l.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(r.Paper,{onClick:l=>l.stopPropagation(),elevation:0,sx:{position:"relative",width:680,maxWidth:"calc(100vw - 120px)",maxHeight:"min(720px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:l=>Me(l),bgcolor:"background.paper",outline:"none",boxShadow:l=>te(l,"menu"),animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Manage Presets"}),e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",mt:.5,display:"block"},children:[t.length," saved ",t.length===1?"preset":"presets"]})]}),e.jsx(r.IconButton,{onClick:s,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(z.Close,{sx:{fontSize:20}})})]}),e.jsx(r.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:l=>T(l.palette.text.primary,.2)}}},children:t.length===0?e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8},children:[e.jsx(z.Share,{sx:{fontSize:48,color:"divider",mb:2}}),e.jsx(r.Typography,{variant:"body1",sx:{fontSize:"0.875rem",color:"text.secondary",textAlign:"center"},children:"No presets created yet"}),e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.disabled",textAlign:"center",mt:.5},children:"Create a preset to share report configurations"})]}):e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:t.map(l=>e.jsxs(r.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:c=>te(c,"restButtonLight")}},children:[e.jsx(r.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",mb:1.5},children:e.jsxs(r.Box,{sx:{flex:1,minWidth:0},children:[e.jsx(r.Typography,{variant:"h6",sx:{fontSize:"0.9375rem",fontWeight:500,color:"text.primary",mb:.5},children:l.name}),l.description&&e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.5},children:l.description})]})}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:2},children:[e.jsx(r.Chip,{label:`Created ${d(l.createdAt)}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"action.hover",color:"text.secondary","& .MuiChip-label":{px:1}}}),e.jsx(r.Chip,{label:`By ${l.createdBy}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"action.hover",color:"text.secondary","& .MuiChip-label":{px:1}}})]}),e.jsx(r.Divider,{sx:{my:1.5,borderColor:"divider"}}),e.jsx(r.Box,{sx:{display:"flex",gap:1},children:e.jsx(r.Button,{onClick:()=>i(l.id,l.name),variant:"outlined",size:"small",startIcon:e.jsx(z.Delete,{sx:{fontSize:16}}),sx:{fontSize:"0.8125rem",color:"error.main",borderColor:"divider",px:1.5,py:.75,borderRadius:c=>`${c.shape.borderRadius}px`,"&:hover":{borderColor:"error.main",bgcolor:c=>T(c.palette.error.main,.04)}},children:"Delete"})})]},l.id))})}),e.jsx(r.Box,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end",display:"flex"},children:e.jsx(r.Button,{onClick:s,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",px:3,py:.875,minHeight:36,borderRadius:l=>`${l.shape.borderRadius}px`,boxShadow:l=>te(l,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:l=>te(l,"hoverButton")},"&:active":{boxShadow:l=>te(l,"pressedButton"),transform:"translateY(1px)"}},children:"Close"})})]})})}const ts={maxFileSizeBytes:2*1024*1024,maxFileSizeHardBytes:3*1024*1024,maxRows:1e4,maxRowsHard:5e4,maxImageColumns:5},yu=[/^https?:\/\/.*\.(jpg|jpeg|png|gif|webp|svg|avif|bmp)/i,/^data:image\//i,/^\/.*\.(jpg|jpeg|png|gif|webp|svg)/i],bu=[/image/i,/photo/i,/avatar/i,/thumbnail/i,/picture/i,/logo/i,/icon/i,/banner/i];function vu(t,o){const n=[];for(const i of t){if(i.type!=="string")continue;const s=bu.some(c=>c.test(i.name));let d=!1;const l=o.slice(0,10).map(c=>c[i.name]).filter(c=>typeof c=="string"&&c.length>0);l.length>0&&(d=l.filter(u=>yu.some(h=>h.test(u))).length/l.length>.6),(s||d)&&n.push(i.name)}return n}function fn(t,o){if(t.length===0||o.length===0)return 0;const n=t.slice(0,Math.min(50,t.length)),s=o.map(l=>{const c=n.map(h=>String(h[l]??"")).filter(h=>h.length>0);if(c.length===0)return 5;const u=c.reduce((h,m)=>h+m.length,0);return Math.ceil(u/c.length)+1}).reduce((l,c)=>l+c,0)+1;return o.reduce((l,c)=>l+c.length+1,0)+s*t.length}function Su(t,o){const n=fn(t,o);return Math.ceil(n*3.5)}function ju(t,o){const n=fn(t,o);return Math.ceil(n*.7)}function Cu(t,o,n){switch(t){case"csv":return fn(o,n);case"excel":return ju(o,n);case"json":return Su(o,n)}}function yi(t,o){return Math.ceil(t/o)}function wu(t,o,n,i,s=ts){const d=[],l=Cu(t,o,n),c=o.length;if(c>s.maxRowsHard){const m=yi(c,s.maxRows);d.push({type:"row_count",severity:"error",message:`Export blocked: ${c.toLocaleString()} rows exceeds the maximum of ${s.maxRowsHard.toLocaleString()}`,detail:`Consider using filters to reduce the dataset before exporting, or split into ${m} smaller exports of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:m,value:c,limit:s.maxRowsHard})}else if(c>s.maxRows){const m=yi(c,s.maxRows);d.push({type:"row_count",severity:"warning",message:`Large export: ${c.toLocaleString()} rows`,detail:`This is a large export that may take a moment to complete. For faster results, consider splitting into ${m} smaller export${m>1?"s":""} of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:m,value:c,limit:s.maxRows})}if(l>s.maxFileSizeHardBytes?d.push({type:"file_size",severity:"error",message:`File size blocked: estimated ${to(l)} exceeds the ${to(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:l,limit:s.maxFileSizeHardBytes}):l>s.maxFileSizeBytes&&d.push({type:"file_size",severity:"warning",message:`Large file: estimated ${to(l)}`,detail:`This exceeds the recommended ${to(s.maxFileSizeBytes)} size. The download will still proceed but may be slow on some connections.`,value:l,limit:s.maxFileSizeBytes}),t!=="excel"){const m=vu(i.filter(b=>n.includes(b.name)),o);if(m.length>0){const b=m.length>s.maxImageColumns;d.push({type:"image_columns",severity:b?"error":"warning",message:`Image column${m.length>1?"s":""} detected: ${m.map(x=>`"${x.replace(/_/g," ")}"`).join(", ")}`,detail:b?`Exporting ${m.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:m.length,limit:s.maxImageColumns})}}const u=d.some(m=>m.severity==="error"),h=d.some(m=>m.severity==="warning");return{violations:d,hasBlockingViolation:u,hasWarning:h,estimatedBytes:l}}function to(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function ku({violation:t}){const n=At().palette,i=t.severity==="error",s=i?n.error.main:n.warning.main,d=T(i?n.error.main:n.warning.main,.06),l=i?T(n.error.main,.25):T(n.warning.main,.3),c=i?z.ErrorOutline:z.WarningAmberOutlined;return e.jsxs(r.Box,{sx:{display:"flex",gap:1.25,p:1.5,borderRadius:"8px",bgcolor:d,border:"1px solid",borderColor:l},children:[e.jsx(c,{sx:{fontSize:17,color:s,flexShrink:0,mt:.125}}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontSize:"0.8125rem",fontWeight:600,color:i?"error.main":"warning.dark",lineHeight:1.4},children:t.message}),t.detail&&e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.375,lineHeight:1.5},children:t.detail}),t.suggestedBatches&&t.suggestedBatches>1&&e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5,mt:.75},children:[e.jsx(z.SplitscreenOutlined,{sx:{fontSize:14,color:"text.secondary"}}),e.jsxs(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",fontWeight:500},children:["Suggestion: split into ",t.suggestedBatches," exports"]})]})]})]})}function Tu({totalRows:t,visibleRows:o,hasGrouping:n,visibleColumnsCount:i,totalColumnsCount:s,schema:d,sampleRows:l=[],allRows:c=[],processedRows:u=[],onExport:h,onClose:m}){var M,W,V;const b=At(),x=b.palette,y=ur(),[D,v]=p.useState(y.export.allowedFormats[0]||"csv"),[C,S]=p.useState("visible"),[I,f]=p.useState("visible"),k=C==="visible"?o:t,j=I==="visible"?i:s,a=p.useMemo(()=>C==="visible"?u.length>0?u:new Array(o):c.length>0?c:new Array(t),[C,o,t,u,c]),B=p.useMemo(()=>I==="all"?d.map(Q=>Q.name):d.map(Q=>Q.name).slice(0,i),[I,d,i]),R=p.useMemo(()=>wu(D,a,B,d,ts),[D,a,B,d]),J=()=>{R.hasBlockingViolation||(h({format:D,scope:C,columnScope:I}),m())},K={csv:"CSV",excel:"Excel (.xlsx)",json:"JSON"},ee={alignItems:"flex-start",px:1.5,py:.875,borderRadius:"8px",mx:0,transition:"background-color 0.15s","&:hover":{bgcolor:"action.hover"}},g={color:"text.secondary","&.Mui-checked":{color:"primary.main"},pt:.125};return e.jsx(r.Box,{onClick:m,sx:{position:"fixed",inset:0,bgcolor:T(((M=x.common)==null?void 0:M.black)??"#000",.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:e.jsxs(r.Paper,{onClick:Q=>Q.stopPropagation(),elevation:0,sx:{width:480,maxWidth:"calc(100vw - 48px)",maxHeight:"min(680px, calc(100vh - 180px))",display:"flex",flexDirection:"column",borderRadius:Me(b),bgcolor:"background.paper",overflow:"hidden",boxShadow:`0 8px 32px ${T(((W=x.common)==null?void 0:W.black)??"#000",.14)}, 0 2px 8px ${T(((V=x.common)==null?void 0:V.black)??"#000",.08)}`,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:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx(r.Typography,{sx:{fontSize:"1rem",fontWeight:600,color:"text.primary"},children:"Export Report"}),e.jsx(pr,{content:xr.export,isDev:process.env.NODE_ENV==="development"})]}),e.jsx(r.IconButton,{onClick:m,size:"small",sx:{color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(z.Close,{sx:{fontSize:18}})})]}),e.jsxs(r.Box,{sx:{flex:1,overflowY:"auto",px:3,py:2.5,display:"flex",flexDirection:"column",gap:2.5,"&::-webkit-scrollbar":{width:6},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:T(x.text.primary,.15),borderRadius:3}},children:[R.violations.length>0&&e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:R.violations.map((Q,xe)=>e.jsx(ku,{violation:Q},xe))}),e.jsxs(r.FormControl,{component:"fieldset",children:[e.jsx(r.FormLabel,{component:"legend",sx:{fontSize:"0.6875rem",fontWeight:700,color:"text.secondary",letterSpacing:"0.08em",mb:1,textTransform:"uppercase"},children:"Format"}),e.jsxs(r.RadioGroup,{value:D,onChange:Q=>v(Q.target.value),children:[y.export.allowedFormats.includes("csv")&&e.jsx(r.FormControlLabel,{value:"csv",control:e.jsx(r.Radio,{size:"small",sx:g}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"CSV"}),e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary"},children:"Comma-separated values, compatible with Excel"})]}),sx:{...ee,mb:.5}}),y.export.allowedFormats.includes("excel")&&e.jsx(r.FormControlLabel,{value:"excel",control:e.jsx(r.Radio,{size:"small",sx:g}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"Excel (.xlsx)"}),e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary"},children:"Native Excel format with formatting support"})]}),sx:{...ee,mb:.5}}),y.export.allowedFormats.includes("json")&&e.jsx(r.FormControlLabel,{value:"json",control:e.jsx(r.Radio,{size:"small",sx:g}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"JSON"}),e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary"},children:"Structured data with metadata and filters"})]}),sx:ee})]})]}),e.jsxs(r.FormControl,{component:"fieldset",children:[e.jsx(r.FormLabel,{component:"legend",sx:{fontSize:"0.6875rem",fontWeight:700,color:"text.secondary",letterSpacing:"0.08em",mb:1,textTransform:"uppercase"},children:"Rows"}),e.jsxs(r.RadioGroup,{value:C,onChange:Q=>S(Q.target.value),children:[e.jsx(r.FormControlLabel,{value:"visible",control:e.jsx(r.Radio,{size:"small",sx:g}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"Visible rows"}),e.jsxs(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary"},children:["Export ",o.toLocaleString()," rows (filtered and searched)"]})]}),sx:{...ee,mb:.5}}),e.jsx(r.FormControlLabel,{value:"all",control:e.jsx(r.Radio,{size:"small",sx:g}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"All rows"}),e.jsxs(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary"},children:["Export ",t.toLocaleString()," rows (complete original dataset)"]})]}),sx:ee})]})]}),e.jsxs(r.FormControl,{component:"fieldset",children:[e.jsx(r.FormLabel,{component:"legend",sx:{fontSize:"0.6875rem",fontWeight:700,color:"text.secondary",letterSpacing:"0.08em",mb:1,textTransform:"uppercase"},children:"Columns"}),e.jsxs(r.RadioGroup,{value:I,onChange:Q=>f(Q.target.value),children:[e.jsx(r.FormControlLabel,{value:"visible",control:e.jsx(r.Radio,{size:"small",sx:g}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"Visible columns only"}),e.jsxs(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary"},children:["Export ",i," visible column",i!==1?"s":""]})]}),sx:{...ee,mb:.5}}),e.jsx(r.FormControlLabel,{value:"all",control:e.jsx(r.Radio,{size:"small",sx:g}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"All columns"}),e.jsxs(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary"},children:["Export all ",s," columns (including hidden)"]})]}),sx:ee})]})]}),e.jsxs(r.Box,{children:[e.jsx(r.Divider,{sx:{mb:2}}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:[{label:"Format",value:K[D]},{label:"Rows to export",value:k.toLocaleString()},{label:"Columns to export",value:String(j)},{label:"Estimated file size",value:to(R.estimatedBytes),highlight:R.hasBlockingViolation?"error.main":R.hasWarning?"warning.main":void 0}].map(({label:Q,value:xe,highlight:me})=>e.jsxs(r.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(r.Typography,{sx:{fontSize:"0.8125rem",color:"text.secondary"},children:Q}),e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"0.8125rem",color:me??"text.primary"},children:xe})]},Q))})]})]}),e.jsxs(r.Box,{sx:{px:3,py:1.75,borderTop:"1px solid",borderColor:"divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:T(x.text.primary,.015)},children:[R.hasBlockingViolation&&e.jsxs(r.Box,{sx:{flex:1,display:"flex",alignItems:"center",gap:.75},children:[e.jsx(z.ErrorOutline,{sx:{fontSize:15,color:"error.main"}}),e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"error.main",fontWeight:500},children:"Reduce rows or columns to enable download"})]}),e.jsx(r.Button,{onClick:m,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:2.5,borderRadius:"8px","&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),e.jsxs(r.Button,{onClick:J,disabled:R.hasBlockingViolation,variant:"contained",startIcon:e.jsx(z.Download,{sx:{fontSize:16}}),sx:{fontSize:"0.875rem",px:2.5,borderRadius:"8px"},children:["Download ",K[D]]})]})]})})}function Iu({warning:t,onDismiss:o}){return e.jsx(r.Box,{sx:{position:"fixed",top:16,right:16,zIndex:50,maxWidth:448},children:e.jsxs(r.Alert,{severity:"warning",icon:e.jsx(z.Warning,{sx:{fontSize:20}}),action:e.jsx(r.IconButton,{size:"small",onClick:o,sx:{color:"warning.main"},children:e.jsx(z.Close,{sx:{fontSize:16}})}),sx:{borderLeft:4,borderColor:"warning.main",boxShadow:3},children:[e.jsx(r.AlertTitle,{sx:{fontWeight:600},children:"Feature Limit Reached"}),e.jsx(r.Box,{sx:{fontSize:"body2.fontSize",mb:1},children:t.message}),e.jsxs(r.Box,{sx:{fontSize:"caption.fontSize",opacity:.9},children:["Please remove some"," ",t.type==="filter"?"filters":t.type==="sort"?"sort levels":"grouping levels"," ","before adding more."]})]})})}function zu({error:t,onDismiss:o,autoDismiss:n=!0,autoDismissDelay:i=5e3}){p.useEffect(()=>{if(n){const c=setTimeout(()=>{o()},i);return()=>clearTimeout(c)}},[n,i,o]);const d=(()=>{switch(t.type){case"system":return{severity:"error",icon:e.jsx(z.Cancel,{sx:{fontSize:20}})};case"processing":return{severity:"warning",icon:e.jsx(z.Warning,{sx:{fontSize:20}})};case"ui":default:return{severity:"info",icon:e.jsx(z.InfoOutlined,{sx:{fontSize:20}})}}})(),l=Na(t);return e.jsx(r.Box,{sx:{position:"fixed",top:16,right:16,zIndex:50,maxWidth:448},children:e.jsxs(r.Alert,{severity:d.severity,icon:d.icon,action:e.jsx(r.IconButton,{size:"small",onClick:o,sx:{color:`${d.severity}.main`},children:e.jsx(z.Close,{sx:{fontSize:16}})}),sx:{borderLeft:4,borderColor:`${d.severity}.main`,boxShadow:3},children:[e.jsxs(r.AlertTitle,{sx:{fontWeight:600},children:[t.context.charAt(0).toUpperCase()+t.context.slice(1)," Error"]}),e.jsx(r.Box,{sx:{fontSize:"body2.fontSize"},children:l}),t.details&&process.env.NODE_ENV==="development"&&e.jsx(r.Box,{component:"pre",sx:{fontSize:"caption.fontSize",mt:1,fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:JSON.stringify(t.details,null,2)})]})})}class Bu extends p.Component{constructor(n){super(n);jn(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){cr.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:e.jsx(r.Paper,{sx:{bgcolor:s=>T(s.palette.error.main,.12),border:1,borderColor:"error.light",borderRadius:2,p:3,m:2},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.5},children:[e.jsx(z.Warning,{color:"error",sx:{fontSize:24,flexShrink:0}}),e.jsxs(r.Box,{sx:{flex:1},children:[e.jsx(r.Typography,{variant:"h6",sx:{color:"error.main",fontWeight:600},children:this.props.context?`${this.props.context} Error`:"Something went wrong"}),e.jsx(r.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"&&e.jsx(r.Box,{component:"pre",sx:{mt:1.5,fontSize:"caption.fontSize",color:"error.main",bgcolor:s=>T(s.palette.error.main,.12),p:1.5,borderRadius:1,overflow:"auto",maxHeight:170},children:(i=this.state.error)==null?void 0:i.stack}),e.jsx(r.Button,{onClick:this.handleReset,variant:"contained",color:"error",startIcon:e.jsx(z.Refresh,{sx:{fontSize:16}}),sx:{mt:2},children:"Try Again"})]})]})}):this.props.children}}function Du({feature:t}){const[o,n]=p.useState(!0);return p.useEffect(()=>{const i=setTimeout(()=>n(!1),5e3);return()=>clearTimeout(i)},[]),e.jsx(r.Collapse,{in:o,unmountOnExit:!0,children:e.jsxs(r.Alert,{severity:"warning",sx:{m:1},icon:e.jsx(z.Warning,{sx:{fontSize:20}}),action:e.jsx(r.IconButton,{size:"small",onClick:()=>n(!1),"aria-label":"dismiss",sx:{color:"warning.dark"},children:e.jsx(z.Close,{sx:{fontSize:16}})}),children:[e.jsxs(r.AlertTitle,{children:[t," temporarily unavailable"]}),"Other features continue to work normally"]})})}function Kr({children:t,feature:o,onError:n}){return e.jsx(Bu,{context:o,onError:i=>{n&&n(i)},fallback:e.jsx(Du,{feature:o}),children:t})}const Eu=[{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"}],Ou=[{value:"csv",label:"CSV",desc:"Comma-separated values"},{value:"excel",label:"Excel (.xlsx)",desc:"Native Excel format"},{value:"json",label:"JSON",desc:"Structured data with metadata"}];function Xr({children:t,active:o}){return e.jsx(r.Box,{hidden:!o,sx:{pt:2.5,pb:1,display:o?"flex":"none",flexDirection:"column",gap:2.5},children:t})}function $u({open:t,onClose:o,config:n,onApply:i}){const[s,d]=p.useState(0),[l,c]=p.useState(n),u=()=>c(n),h=()=>c(Ke),m=()=>{i(l),o()},b={sort:C=>c(S=>({...S,sort:{...S.sort,...C}})),filter:C=>c(S=>({...S,filter:{...S.filter,...C}})),columns:C=>c(S=>({...S,columns:{...S.columns,...C}})),grouping:C=>c(S=>({...S,grouping:{...S.grouping,...C}})),export:C=>c(S=>({...S,export:{...S.export,...C}}))},x=C=>{const S=l.filter.allowedOperators,I=S.includes(C)?S.filter(f=>f!==C):[...S,C];I.length!==0&&b.filter({allowedOperators:I})},y=C=>{const S=l.export.allowedFormats,I=S.includes(C)?S.filter(f=>f!==C):[...S,C];I.length!==0&&b.export({allowedFormats:I})},D=[{label:"Sort",icon:e.jsx(z.SwapVert,{sx:{fontSize:17}})},{label:"Filter",icon:e.jsx(z.FilterList,{sx:{fontSize:17}})},{label:"Columns",icon:e.jsx(z.ViewColumn,{sx:{fontSize:17}})},{label:"Grouping",icon:e.jsx(z.Layers,{sx:{fontSize:17}})},{label:"Export",icon:e.jsx(z.Download,{sx:{fontSize:17}})}],v=C=>JSON.stringify(l[C])===JSON.stringify(Ke[C]);return e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"sm",fullWidth:!0,TransitionProps:{onEnter:u},PaperProps:{sx:{borderRadius:C=>Me(C),maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:C=>`0 8px 32px ${T(C.palette.common.black,.2)}`}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[e.jsx(r.Box,{sx:{width:32,height:32,borderRadius:"8px",bgcolor:C=>T(C.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",fontSize:"1.1rem"},children:"⚙️"}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"subtitle1",sx:{fontWeight:600,lineHeight:1.2},children:"Developer Configuration"}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:"Set runtime constraints · Ctrl+Shift+D"})]})]}),e.jsx(r.IconButton,{size:"small",onClick:o,sx:{color:"text.secondary"},children:e.jsx(z.Close,{sx:{fontSize:20}})})]}),e.jsx(r.Box,{sx:{borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:e.jsx(r.Tabs,{value:s,onChange:(C,S)=>d(S),variant:"fullWidth",sx:{minHeight:44,"& .MuiTab-root":{minHeight:44,fontSize:"0.8125rem",textTransform:"none",fontWeight:500,gap:.5}},children:D.map((C,S)=>e.jsx(r.Tab,{label:C.label,icon:C.icon,iconPosition:"start"},S))})}),e.jsxs(r.DialogContent,{sx:{overflowY:"auto",flex:1,px:3,py:0},children:[e.jsxs(Xr,{active:s===0,children:[e.jsxs(r.Box,{children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum sort levels"}),!v("sort")&&e.jsx(r.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users can sort by at most this many columns simultaneously."}),e.jsx(r.Slider,{value:l.sort.maxLevels,onChange:(C,S)=>b.sort({maxLevels:S}),min:1,max:10,step:1,marks:!0,valueLabelDisplay:"on"}),e.jsxs(r.Box,{sx:{display:"flex",justifyContent:"space-between"},children:[e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:"1 level (single)"}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:"10 levels (maximum)"})]})]}),e.jsxs(r.Alert,{severity:"info",sx:{borderRadius:2,fontSize:"0.8125rem"},children:['The "Add sort column" button is hidden once users reach this limit. Default is'," ",e.jsx("strong",{children:"5"}),"."]})]}),e.jsxs(Xr,{active:s===1,children:[e.jsxs(r.Box,{children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum filter conditions"}),!v("filter")&&e.jsx(r.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users can apply at most this many simultaneous filter conditions."}),e.jsx(r.Slider,{value:l.filter.maxConditions,onChange:(C,S)=>b.filter({maxConditions:S}),min:1,max:20,step:1,marks:!0,valueLabelDisplay:"on"}),e.jsxs(r.Box,{sx:{display:"flex",justifyContent:"space-between"},children:[e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:"1 condition"}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:"20 conditions"})]})]}),e.jsx(r.Divider,{}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600,mb:.5},children:"Allowed filter operators"}),e.jsx(r.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(C=>e.jsxs(r.Box,{sx:{mb:1.5},children:[e.jsx(r.Typography,{sx:{fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"text.secondary",fontSize:"0.6875rem",display:"block",mb:.5},children:C}),e.jsx(r.FormGroup,{row:!0,sx:{gap:.5},children:Eu.filter(S=>S.group===C).map(S=>e.jsx(r.FormControlLabel,{control:e.jsx(r.Checkbox,{size:"small",checked:l.filter.allowedOperators.includes(S.value),onChange:()=>x(S.value)}),label:e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem"},children:S.label}),sx:{mr:1.5}},S.value))})]},C))]})]}),e.jsxs(Xr,{active:s===2,children:[e.jsxs(r.Box,{children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum visible columns"}),!v("columns")&&e.jsx(r.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users cannot make more than this many columns visible simultaneously."}),e.jsx(r.Slider,{value:l.columns.maxVisible,onChange:(C,S)=>b.columns({maxVisible:S}),min:1,max:50,step:1,valueLabelDisplay:"on"})]}),e.jsx(r.Divider,{}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600,mb:.5},children:"Column width range (px)"}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users cannot resize columns outside this minimum / maximum range."}),e.jsxs(r.Box,{sx:{display:"flex",gap:2},children:[e.jsxs(r.Box,{sx:{flex:1},children:[e.jsx(r.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Minimum width"}),e.jsx(r.Slider,{value:l.columns.minColumnWidth,onChange:(C,S)=>b.columns({minColumnWidth:S}),min:40,max:400,step:10,valueLabelDisplay:"on",valueLabelFormat:C=>`${C}px`})]}),e.jsxs(r.Box,{sx:{flex:1},children:[e.jsx(r.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Maximum width"}),e.jsx(r.Slider,{value:l.columns.maxColumnWidth,onChange:(C,S)=>b.columns({maxColumnWidth:S}),min:100,max:2e3,step:50,valueLabelDisplay:"on",valueLabelFormat:C=>`${C}px`})]})]})]})]}),e.jsxs(Xr,{active:s===3,children:[e.jsxs(r.Box,{children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum group levels"}),!v("grouping")&&e.jsx(r.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),e.jsx(r.Box,{sx:{display:"flex",gap:1.5,mb:2},children:[1,2,3].map(C=>e.jsxs(r.Box,{onClick:()=>b.grouping({maxLevels:C}),sx:{flex:1,py:2.5,borderRadius:"10px",border:"2px solid",cursor:"pointer",textAlign:"center",transition:"all 0.15s ease",borderColor:l.grouping.maxLevels===C?"primary.main":"divider",bgcolor:l.grouping.maxLevels===C?S=>T(S.palette.primary.main,.06):"transparent","&:hover":{borderColor:"primary.light",bgcolor:S=>T(S.palette.primary.main,.04)}},children:[e.jsx(r.Typography,{variant:"h5",sx:{fontWeight:700,color:l.grouping.maxLevels===C?"primary.main":"text.secondary"},children:C}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:["Single","Double","Triple"][C-1]})]},C))}),e.jsxs(r.FormGroup,{row:!0,sx:{gap:2},children:[e.jsx(r.FormControlLabel,{control:e.jsx(r.Checkbox,{checked:l.grouping.allowNested,onChange:C=>b.grouping({allowNested:C.target.checked})}),label:e.jsx(r.Typography,{variant:"body2",children:"Allow nested groups"})}),e.jsx(r.FormControlLabel,{control:e.jsx(r.Checkbox,{checked:l.grouping.allowCollapse,onChange:C=>b.grouping({allowCollapse:C.target.checked})}),label:e.jsx(r.Typography,{variant:"body2",children:"Allow collapse / expand"})})]})]}),e.jsx(r.Alert,{severity:"info",sx:{borderRadius:2,fontSize:"0.8125rem"},children:'The "Add group level" button is hidden when users reach the configured limit.'})]}),e.jsx(Xr,{active:s===4,children:e.jsxs(r.Box,{children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600},children:"Allowed export formats"}),!v("export")&&e.jsx(r.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),e.jsx(r.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."}),e.jsx(r.FormGroup,{sx:{gap:1},children:Ou.map(C=>e.jsxs(r.Box,{onClick:()=>y(C.value),sx:{display:"flex",alignItems:"center",gap:1.5,p:1.5,borderRadius:"8px",border:"1px solid",cursor:"pointer",transition:"all 0.15s ease",borderColor:l.export.allowedFormats.includes(C.value)?"primary.main":"divider",bgcolor:l.export.allowedFormats.includes(C.value)?S=>T(S.palette.primary.main,.04):"transparent","&:hover":{borderColor:"primary.light"}},children:[e.jsx(r.Checkbox,{size:"small",checked:l.export.allowedFormats.includes(C.value),onChange:()=>y(C.value),onClick:S=>S.stopPropagation()}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500},children:C.label}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:C.desc})]})]},C.value))})]})})]}),e.jsxs(r.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid",borderColor:"divider",bgcolor:C=>T(C.palette.action.hover,.4),justifyContent:"space-between",flexShrink:0},children:[e.jsx(r.Button,{startIcon:e.jsx(z.RestartAlt,{sx:{fontSize:18}}),onClick:h,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary","&:hover":{color:"text.primary",bgcolor:C=>T(C.palette.text.primary,.06)}},children:"Reset to defaults"}),e.jsxs(r.Box,{sx:{display:"flex",gap:1},children:[e.jsx(r.Button,{onClick:o,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px"},children:"Cancel"}),e.jsx(r.Button,{onClick:m,size:"small",variant:"contained",sx:{fontSize:"0.875rem",px:2.5,borderRadius:"18px"},children:"Apply"})]})]})]})}const Au=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],_u={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 vo(t,o,n,i,s=new Date){const[d,l]=o.split(":").map(Number),c=new Date(s);if(c.setSeconds(0,0),c.setHours(d,l,0,0),t==="daily")return c<=s&&c.setDate(c.getDate()+1),c.toISOString();if(t==="weekly"){const u=n??1,h=c.getDay();let m=u-h;return m<0&&(m+=7),m===0&&c<=s&&(m=7),c.setDate(c.getDate()+m),c.toISOString()}if(t==="monthly"){const u=Math.min(i??1,28);return c.setDate(u),c<=s&&(c.setMonth(c.getMonth()+1),c.setDate(u)),c.toISOString()}return c.toISOString()}function Mu(t){const o=rs(t.time);return t.frequency==="daily"?`Daily at ${o}`:t.frequency==="weekly"?`Every ${Au[t.dayOfWeek??1]} at ${o}`:t.frequency==="monthly"?`Monthly on the ${_u[t.dayOfMonth??1]??`${t.dayOfMonth}th`} at ${o}`:o}function rs(t){const[o,n]=t.split(":").map(Number),i=o>=12?"PM":"AM";return`${o%12||12}:${String(n).padStart(2,"0")} ${i}`}function Ru(t){const o=new Date(t).getTime()-Date.now();if(o<=0)return"now";const n=Math.floor(o/1e3),i=Math.floor(n/86400),s=Math.floor(n%86400/3600),d=Math.floor(n%3600/60);return i>0?`in ${i}d ${s}h`:s>0?`in ${s}h ${d}m`:d>0?`in ${d}m`:"in less than a minute"}function Wu(t){const o=new Date(t),n=new Date,i=o.toDateString()===n.toDateString(),s=rs(`${String(o.getHours()).padStart(2,"0")}:${String(o.getMinutes()).padStart(2,"0")}`);return i?`Today at ${s}`:`${o.toLocaleDateString("en-US",{month:"short",day:"numeric"})} at ${s}`}function os(t){return`urm_schedules_${t}`}function ns(t){try{const o=localStorage.getItem(os(t));return o?JSON.parse(o).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 is(t,o){try{localStorage.setItem(os(t),JSON.stringify(o))}catch{}}const Pu=[{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"}],Nu=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,ss={name:"",frequency:"daily",dayOfWeek:1,dayOfMonth:1,time:"09:00",format:"csv",scope:"all",email:""},lr={"& .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 Lu({initial:t=ss,isEditing:o=!1,onSave:n,onBack:i}){const[s,d]=p.useState(t),[l,c]=p.useState(!1),[u,h]=p.useState(!1),m=(y,D)=>d(v=>({...v,[y]:D})),b=s.email.trim().length>0&&!Nu.test(s.email.trim()),x=s.name.trim().length>0&&/^\d{2}:\d{2}$/.test(s.time)&&(s.frequency!=="monthly"||s.dayOfMonth>=1&&s.dayOfMonth<=28)&&!b;return e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5,mb:.5},children:[e.jsx(r.IconButton,{size:"small",onClick:i,sx:{color:"text.secondary",ml:-.75,"&:hover":{bgcolor:y=>T(y.palette.text.primary,.06)}},children:e.jsx(z.ArrowBack,{sx:{fontSize:18}})}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600},children:o?"Edit schedule":"New schedule"})]}),e.jsx(r.TextField,{label:"Schedule name *",size:"small",fullWidth:!0,value:s.name,onChange:y=>{m("name",y.target.value),l&&y.target.value.trim()&&c(!1)},onBlur:()=>c(!0),placeholder:"e.g. Weekly Sales Report",autoFocus:!0,inputProps:{maxLength:50},error:l&&!s.name.trim(),helperText:l&&!s.name.trim()?"Schedule name is required":`${s.name.length}/50`,sx:lr}),e.jsxs(r.FormControl,{size:"small",fullWidth:!0,sx:lr,children:[e.jsx(r.InputLabel,{children:"Frequency"}),e.jsxs(r.Select,{value:s.frequency,label:"Frequency",onChange:y=>m("frequency",y.target.value),children:[e.jsx(r.MenuItem,{value:"daily",children:"Daily"}),e.jsx(r.MenuItem,{value:"weekly",children:"Weekly"}),e.jsx(r.MenuItem,{value:"monthly",children:"Monthly"})]})]}),s.frequency==="weekly"&&e.jsxs(r.FormControl,{size:"small",fullWidth:!0,sx:lr,children:[e.jsx(r.InputLabel,{children:"Day of week"}),e.jsx(r.Select,{value:s.dayOfWeek,label:"Day of week",onChange:y=>m("dayOfWeek",Number(y.target.value)),children:Pu.map(y=>e.jsx(r.MenuItem,{value:y.value,children:y.label},y.value))})]}),s.frequency==="monthly"&&e.jsx(r.TextField,{label:"Day of month (1–28)",size:"small",type:"number",fullWidth:!0,value:s.dayOfMonth,onChange:y=>m("dayOfMonth",Number(y.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:lr}),e.jsx(r.TextField,{label:"Time",size:"small",type:"time",fullWidth:!0,value:s.time,onChange:y=>m("time",y.target.value),InputLabelProps:{shrink:!0},helperText:"24-hour format · Tab must be open for the schedule to fire",sx:lr}),e.jsxs(r.FormControl,{size:"small",fullWidth:!0,sx:lr,children:[e.jsx(r.InputLabel,{children:"Export format"}),e.jsxs(r.Select,{value:s.format,label:"Export format",onChange:y=>m("format",y.target.value),children:[e.jsx(r.MenuItem,{value:"csv",children:"CSV — Comma-separated values"}),e.jsx(r.MenuItem,{value:"excel",children:"Excel (.xlsx) — Native format"}),e.jsx(r.MenuItem,{value:"json",children:"JSON — Structured data"})]})]}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"caption",sx:{fontWeight:500,color:"text.secondary",display:"block",mb:.75},children:"Data scope"}),e.jsxs(r.RadioGroup,{row:!0,value:s.scope,onChange:y=>m("scope",y.target.value),sx:{gap:2},children:[e.jsx(r.FormControlLabel,{value:"all",control:e.jsx(r.Radio,{size:"small"}),label:e.jsx(r.Typography,{variant:"body2",children:"All rows"})}),e.jsx(r.FormControlLabel,{value:"visible",control:e.jsx(r.Radio,{size:"small"}),label:e.jsx(r.Typography,{variant:"body2",children:"Filtered rows only"})})]})]}),e.jsxs(r.Box,{children:[e.jsx(r.TextField,{label:"Email reminder (optional)",size:"small",fullWidth:!0,type:"email",value:s.email,onChange:y=>m("email",y.target.value),onBlur:()=>h(!0),placeholder:"user@company.com",error:u&&b,helperText:u&&b?"Enter a valid email address":void 0,InputProps:{startAdornment:e.jsx(z.Email,{sx:{fontSize:15,color:"text.disabled",mr:1}})},sx:lr}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"flex-start",gap:.5,mt:.5,px:.5},children:[e.jsx(z.InfoOutlined,{sx:{fontSize:12,color:"text.disabled",mt:.2,flexShrink:0}}),e.jsx(r.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."})]})]}),e.jsxs(r.Box,{sx:{display:"flex",justifyContent:"flex-end",gap:1,pt:.5},children:[e.jsx(r.Button,{onClick:i,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px","&:hover":{bgcolor:y=>T(y.palette.text.primary,.06)}},children:"Cancel"}),e.jsx(r.Button,{onClick:()=>x&&n(s),disabled:!x,size:"small",variant:"contained",sx:{fontSize:"0.875rem",px:2.5,borderRadius:"18px"},children:o?"Save changes":"Create schedule"})]})]})}function Fu({scheduleName:t,onConfirm:o,onCancel:n}){return e.jsxs(r.Dialog,{open:!0,onClose:n,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:i=>so(i),boxShadow:i=>{var s;return`0 8px 32px ${T(((s=i.palette.common)==null?void 0:s.black)??"#000",.14)}`}}},children:[e.jsxs(r.DialogContent,{sx:{pt:3,pb:2,px:3},children:[e.jsx(r.Box,{sx:{width:44,height:44,borderRadius:"12px",bgcolor:i=>T(i.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(z.WarningAmberOutlined,{sx:{fontSize:22,color:"error.main"}})}),e.jsx(r.Typography,{sx:{fontSize:"0.9375rem",fontWeight:600,color:"text.primary",mb:1},children:"Delete Schedule"}),e.jsxs(r.Typography,{sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.65},children:["Are you sure you want to delete"," ",e.jsxs(r.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:['"',t,'"']}),"? This action cannot be undone."]})]}),e.jsx(r.Divider,{}),e.jsxs(r.DialogActions,{sx:{px:2.5,py:1.5,gap:1},children:[e.jsx(r.Button,{onClick:n,variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",borderRadius:i=>`${i.shape.borderRadius}px`,"&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),e.jsx(r.Button,{onClick:o,variant:"contained",color:"error",sx:{fontSize:"0.8125rem",borderRadius:i=>`${i.shape.borderRadius}px`,px:2},children:"Delete"})]})]})}function Vu({schedule:t,tick:o,onToggle:n,onRunNow:i,onEdit:s,onDelete:d}){const l=t.isActive;return e.jsxs(r.Box,{sx:{border:"1px solid",borderColor:l?"primary.main":"divider",borderRadius:"10px",p:1.75,bgcolor:l?c=>T(c.palette.primary.main,.025):"background.paper",transition:"border-color 0.15s ease, background-color 0.15s ease"},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600,flex:1,minWidth:0,color:l?"text.primary":"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.name}),e.jsx(r.Chip,{label:l?"Active":"Paused",size:"small",sx:{height:18,fontSize:"0.6875rem",fontWeight:600,flexShrink:0,bgcolor:l?c=>T(c.palette.success.main,.1):c=>T(c.palette.text.primary,.06),color:l?"success.dark":"text.secondary"}})]}),e.jsx(r.Typography,{variant:"caption",sx:{color:"text.secondary",display:"block",mb:1},children:Mu(t)}),e.jsxs(r.Box,{sx:{display:"flex",flexWrap:"wrap",gap:.5,mb:1},children:[e.jsx(r.Chip,{label:t.format.toUpperCase(),size:"small",sx:{height:20,fontSize:"0.6875rem",fontWeight:500,bgcolor:c=>T(c.palette.primary.main,.08),color:"primary.main"}}),e.jsx(r.Chip,{label:t.scope==="all"?"All rows":"Filtered rows",size:"small",sx:{height:20,fontSize:"0.6875rem",bgcolor:c=>T(c.palette.text.primary,.06),color:"text.secondary"}}),t.email&&e.jsx(r.Chip,{icon:e.jsx(z.Email,{sx:{fontSize:11}}),label:t.email,size:"small",sx:{height:20,fontSize:"0.6875rem",maxWidth:220,bgcolor:c=>T(c.palette.text.primary,.06),color:"text.secondary","& .MuiChip-label":{overflow:"hidden",textOverflow:"ellipsis"}}})]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:1},children:[e.jsxs(r.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1.5,alignItems:"center"},children:[l&&e.jsxs(r.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:500},children:["Next: ",Ru(t.nextRunAt)]}),t.lastRunAt?e.jsxs(r.Typography,{variant:"caption",color:"text.secondary",children:["Last: ",Wu(t.lastRunAt)," · ",t.runCount," run",t.runCount!==1?"s":""]}):e.jsx(r.Typography,{variant:"caption",color:"text.disabled",children:"Never run"})]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.25,flexShrink:0},children:[e.jsx(r.Tooltip,{title:"Edit",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:()=>s(t),sx:{color:"text.secondary","&:hover":{color:"primary.main",bgcolor:c=>T(c.palette.primary.main,.08)}},children:e.jsx(z.Edit,{sx:{fontSize:15}})})}),e.jsx(r.Tooltip,{title:l?"Pause":"Resume",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:()=>n(t.id),sx:{color:l?"warning.main":"success.main","&:hover":{bgcolor:l?c=>T(c.palette.warning.main,.08):c=>T(c.palette.success.main,.08)}},children:l?e.jsx(z.Pause,{sx:{fontSize:15}}):e.jsx(z.PlayArrow,{sx:{fontSize:15}})})}),e.jsx(r.Tooltip,{title:"Export now",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:()=>i(t),sx:{color:"primary.main","&:hover":{bgcolor:c=>T(c.palette.primary.main,.08)}},children:e.jsx(z.Download,{sx:{fontSize:15}})})}),e.jsx(r.Tooltip,{title:"Delete",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:()=>d(t.id),sx:{color:"error.main","&:hover":{bgcolor:c=>T(c.palette.error.main,.08)}},children:e.jsx(z.Delete,{sx:{fontSize:15}})})})]})]})]})}function Hu({open:t,onClose:o,reportId:n,reportName:i,onRunNow:s}){const[d,l]=p.useState([]),[c,u]=p.useState({type:"list"}),[h,m]=p.useState(0),[b,x]=p.useState(null);p.useEffect(()=>{t&&(l(ns(n)),u({type:"list"}))},[t,n]),p.useEffect(()=>{if(!t)return;const B=setInterval(()=>m(R=>R+1),3e4);return()=>clearInterval(B)},[t]);const y=p.useCallback(B=>{l(B),is(n,B)},[n]),D=B=>{const R=vo(B.frequency,B.time,B.dayOfWeek,B.dayOfMonth),J={id:`sched-${Date.now()}`,reportId:n,name:B.name.trim(),frequency:B.frequency,dayOfWeek:B.frequency==="weekly"?B.dayOfWeek:void 0,dayOfMonth:B.frequency==="monthly"?B.dayOfMonth:void 0,time:B.time,format:B.format,scope:B.scope,email:B.email.trim()||void 0,isActive:!0,createdAt:new Date().toISOString(),nextRunAt:R,runCount:0};y([...d,J]),u({type:"list"})},v=B=>{if(c.type!=="edit")return;const R=c.schedule,J=vo(B.frequency,B.time,B.dayOfWeek,B.dayOfMonth);y(d.map(K=>K.id===R.id?{...R,name:B.name.trim(),frequency:B.frequency,dayOfWeek:B.frequency==="weekly"?B.dayOfWeek:void 0,dayOfMonth:B.frequency==="monthly"?B.dayOfMonth:void 0,time:B.time,format:B.format,scope:B.scope,email:B.email.trim()||void 0,nextRunAt:J}:K)),u({type:"list"})},C=B=>{y(d.map(R=>{if(R.id!==B)return R;const J=R.isActive?R.nextRunAt:vo(R.frequency,R.time,R.dayOfWeek,R.dayOfMonth);return{...R,isActive:!R.isActive,nextRunAt:J}}))},S=B=>{s(B);const R=new Date().toISOString();y(d.map(J=>J.id===B.id?{...J,lastRunAt:R,runCount:J.runCount+1}:J))},I=B=>{const R=d.find(J=>J.id===B)??null;x(R)},f=()=>{b&&(y(d.filter(B=>B.id!==b.id)),x(null))},k=B=>({name:B.name,frequency:B.frequency,dayOfWeek:B.dayOfWeek??1,dayOfMonth:B.dayOfMonth??1,time:B.time,format:B.format,scope:B.scope,email:B.email??""}),j=c.type!=="list",a=d.filter(B=>B.isActive).length;return e.jsxs(e.Fragment,{children:[e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"sm",fullWidth:!0,disableEscapeKeyDown:j,PaperProps:{sx:{borderRadius:B=>Me(B),maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:6}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",py:1.5,px:2.5,borderBottom:"1px solid",borderColor:"divider",flexShrink:0,minHeight:0},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[e.jsx(r.Box,{sx:{width:30,height:30,borderRadius:"7px",bgcolor:B=>T(B.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(z.Schedule,{sx:{fontSize:17,color:"primary.main"}})}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"baseline",gap:.75},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx(r.Typography,{variant:"subtitle2",sx:{fontWeight:600,lineHeight:1},children:"Scheduled Reports"}),e.jsx(pr,{content:xr.schedule,isDev:process.env.NODE_ENV==="development"})]}),e.jsxs(r.Typography,{variant:"caption",color:"text.secondary",sx:{lineHeight:1},children:["· ",i]})]})]}),e.jsx(r.IconButton,{size:"small",onClick:o,sx:{color:"text.secondary","&:hover":{bgcolor:B=>T(B.palette.text.primary,.06)}},children:e.jsx(z.Close,{sx:{fontSize:18}})})]}),e.jsxs(r.DialogContent,{sx:{overflowY:"auto",flex:1,px:2.5,py:2},children:[j&&e.jsx(Lu,{initial:c.type==="edit"?k(c.schedule):ss,isEditing:c.type==="edit",onSave:c.type==="edit"?v:D,onBack:()=>u({type:"list"})}),c.type==="list"&&e.jsxs(e.Fragment,{children:[e.jsxs(r.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1.75,pt:1.5},children:[e.jsx(r.Typography,{variant:"body2",color:"text.secondary",children:d.length===0?"No schedules yet":`${a} of ${d.length} active`}),e.jsx(r.Button,{startIcon:e.jsx(z.Add,{sx:{fontSize:15}}),size:"small",variant:"contained",onClick:()=>u({type:"create"}),sx:{fontSize:"0.8125rem",borderRadius:"18px",px:1.75,py:.625},children:"New schedule"})]}),d.length===0?e.jsxs(r.Box,{sx:{border:"1.5px dashed",borderColor:"divider",borderRadius:"10px",py:5,px:2,textAlign:"center"},children:[e.jsx(z.NotificationsActive,{sx:{fontSize:30,color:"text.disabled",mb:1.25,display:"block",mx:"auto"}}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,color:"text.secondary"},children:"No scheduled reports yet"}),e.jsx(r.Typography,{variant:"caption",color:"text.disabled",sx:{display:"block",mt:.5},children:'Use "New schedule" above to set up automatic exports'})]}):e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:d.map(B=>e.jsx(Vu,{schedule:B,tick:h,onToggle:C,onRunNow:S,onEdit:R=>u({type:"edit",schedule:R}),onDelete:I},B.id))})]})]}),c.type==="list"&&e.jsxs(r.DialogActions,{sx:{px:2.5,py:1.25,borderTop:"1px solid",borderColor:"divider",flexShrink:0,display:"flex",alignItems:"center",gap:1},children:[e.jsxs(r.Box,{sx:{flex:1,display:"flex",alignItems:"center",gap:.75,px:1.25,py:.75,borderRadius:"8px",bgcolor:B=>T(B.palette.warning.main,.06),border:"1px solid",borderColor:B=>T(B.palette.warning.main,.2)},children:[e.jsx(z.Schedule,{sx:{fontSize:13,color:"warning.main",flexShrink:0}}),e.jsx(r.Typography,{variant:"caption",sx:{color:"warning.dark",lineHeight:1.1},children:"Schedules require this browser tab to remain open."})]}),e.jsx(r.Button,{onClick:o,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px",flexShrink:0,"&:hover":{bgcolor:B=>T(B.palette.text.primary,.06)}},children:"Close"})]})]}),b&&e.jsx(Fu,{scheduleName:b.name,onConfirm:f,onCancel:()=>x(null)})]})}const Uu=6e4;function Yu({reportId:t,reportName:o,uploadedData:n,processedData:i,schema:s,activeView:d,columnVisibility:l,columnOrder:c,filters:u,sortStack:h,onFired:m}){const b=p.useRef({reportId:t,reportName:o,uploadedData:n,processedData:i,schema:s,activeView:d,columnVisibility:l,columnOrder:c,filters:u,sortStack:h,onFired:m});p.useEffect(()=>{b.current={reportId:t,reportName:o,uploadedData:n,processedData:i,schema:s,activeView:d,columnVisibility:l,columnOrder:c,filters:u,sortStack:h,onFired:m}});const x=p.useCallback(y=>{var B,R;const{reportName:D,uploadedData:v,processedData:C,schema:S,activeView:I,columnVisibility:f,columnOrder:k,filters:j,sortStack:a}=b.current;try{const J=y.scope==="all"?v:C,K=So(J,S,j,a,I,f,k),ee=`${y.name}_scheduled`;switch(y.format){case"csv":jo(K,ee,{scope:y.scope});break;case"excel":Co(K,ee,{scope:y.scope});break;case"json":wo(K,ee,{scope:y.scope});break}if(y.email){const g=encodeURIComponent(`Scheduled Report: ${y.name}`),M=encodeURIComponent(`Your scheduled report "${y.name}" has been generated.
89
+ ]`})})]}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Supported Column Types"}),e.jsx(r.Typography,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:"The system automatically detects column types from your data:"}),e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:[e.jsxs(r.Box,{sx:{display:"flex",gap:1},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,minWidth:80},children:"Number:"}),e.jsxs(r.Typography,{variant:"body2",color:"text.secondary",children:["Numeric values (e.g.,"," ",e.jsx(r.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"33"}),","," ",e.jsx(r.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"42.5"}),")"]})]}),e.jsxs(r.Box,{sx:{display:"flex",gap:1},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,minWidth:80},children:"Boolean:"}),e.jsxs(r.Typography,{variant:"body2",color:"text.secondary",children:["True/false values (e.g.,"," ",e.jsx(r.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"true"}),","," ",e.jsx(r.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"false"}),")"]})]}),e.jsxs(r.Box,{sx:{display:"flex",gap:1},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,minWidth:80},children:"String:"}),e.jsxs(r.Typography,{variant:"body2",color:"text.secondary",children:["Text values (e.g.,"," ",e.jsx(r.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"Europe"'}),","," ",e.jsx(r.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"Analytics Pro"'}),")"]})]}),e.jsxs(r.Box,{sx:{display:"flex",gap:1},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,minWidth:80},children:"Date:"}),e.jsxs(r.Typography,{variant:"body2",color:"text.secondary",children:["ISO date strings (e.g.,"," ",e.jsx(r.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"2024-08-22"'}),")"]})]})]})]}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Notes"}),e.jsxs(r.Box,{component:"ul",sx:{m:0,pl:2.5,"& li":{fontSize:"body2.fontSize",color:"text.secondary",mb:.5}},children:[e.jsx("li",{children:"Each object in the array represents one row in the report."}),e.jsx("li",{children:"The keys of the JSON objects become report columns."}),e.jsx("li",{children:"All objects should have consistent keys for proper column detection."}),e.jsx("li",{children:"Column names are case-sensitive and preserve spacing."})]})]})]})}),e.jsx(r.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:e.jsx(r.Button,{onClick:o,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",px:3,py:.875,minHeight:36,borderRadius:n=>`${n.shape.borderRadius}px`,boxShadow:n=>te(n,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:n=>te(n,"hoverButton")},"&:active":{boxShadow:n=>te(n,"pressedButton"),transform:"translateY(1px)"}},children:"Got it"})})]}):null}function xd({onFileUpload:t,onError:o,isUploading:n}){const[i,s]=p.useState(!1),[d,c]=p.useState(""),[l,u]=p.useState(!1),f=p.useRef(null),m=async w=>{if(!w.name.endsWith(".json")){o("Only .json files are allowed");return}const I=10*1024*1024;if(w.size>I){o("File size exceeds 10MB limit");return}c(w.name);try{const v=await w.text();let S;try{S=JSON.parse(v)}catch{o("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(S)){o("JSON must be an array of objects");return}if(S.length===0){o("No data rows found in JSON file");return}t(S)}catch{o("Network error — please try again")}finally{c("")}},h=w=>{w.preventDefault(),s(!0)},x=w=>{w.preventDefault(),s(!1)},b=w=>{w.preventDefault(),s(!1);const I=w.dataTransfer.files[0];I&&m(I)},D=()=>{var w;(w=f.current)==null||w.click()},g=w=>{var v;const I=(v=w.target.files)==null?void 0:v[0];I&&m(I)},j=w=>{w.stopPropagation(),u(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(r.Box,{onDragOver:h,onDragLeave:x,onDrop:b,onPaste:w=>w.preventDefault(),onClick:D,sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderStyle:"dashed",borderColor:i?"primary.main":"divider",bgcolor:i?w=>k(w.palette.primary.main,.12):"transparent",borderRadius:1,px:2,py:6,cursor:"pointer",transition:"all 0.2s",opacity:n?.5:1,pointerEvents:n?"none":"auto","&:hover":{borderColor:i?"primary.main":"text.secondary"}},children:[e.jsx(r.Box,{component:"input",ref:f,type:"file",accept:".json",onChange:g,sx:{display:"none"}}),n?e.jsxs(e.Fragment,{children:[e.jsx(r.CircularProgress,{size:32,sx:{mb:2}}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,mb:.5},children:"Uploading..."}),d&&e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:d})]}):e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:w=>k(w.palette.primary.main,.12),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(B.UploadFile,{sx:{fontSize:32,color:"primary.main"}})}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:1.5},children:[e.jsx(r.Button,{variant:"contained",sx:{fontWeight:500},children:"Upload Data (JSON)"}),e.jsx(r.IconButton,{onClick:j,size:"small",sx:{border:1,borderColor:"divider","&:hover":{borderColor:"text.secondary",bgcolor:"action.hover"}},title:"View JSON format guide",children:e.jsx(B.InfoOutlined,{sx:{fontSize:16}})})]}),e.jsx(r.Typography,{variant:"body2",color:"text.secondary",sx:{textAlign:"center",maxWidth:500},children:"Upload structured JSON data to generate your report."}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",sx:{mt:1},children:"Click to browse or drag and drop a JSON file here"})]})]}),e.jsx(Ji,{isOpen:l,onClose:()=>u(!1)})]})}function md({schema:t,onConfirm:o,hasConflicts:n}){return e.jsxs(r.Paper,{sx:{border:2,borderColor:"divider",p:3},children:[e.jsxs(r.Box,{sx:{mb:2},children:[e.jsx(r.Typography,{variant:"h6",sx:{fontWeight:600,mb:.5},children:"Schema Preview"}),e.jsx(r.Typography,{variant:"body2",color:"text.secondary",children:"Review the detected schema before generating your table"})]}),n&&e.jsxs(r.Alert,{severity:"warning",sx:{mb:2},children:[e.jsx(r.AlertTitle,{sx:{fontWeight:600},children:"Schema Conflict Detected"}),"Some columns have inconsistent data types across rows. Please resolve these conflicts before proceeding."]}),e.jsx(r.TableContainer,{sx:{mb:3},children:e.jsxs(r.Table,{children:[e.jsx(r.TableHead,{children:e.jsxs(r.TableRow,{sx:{bgcolor:"action.hover"},children:[e.jsx(r.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Column Name"}),e.jsx(r.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Detected Type"}),e.jsx(r.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Status"})]})}),e.jsx(r.TableBody,{children:t.map(i=>e.jsxs(r.TableRow,{sx:{bgcolor:i.hasConflict?s=>k(s.palette.warning.main,.12):"transparent"},children:[e.jsxs(r.TableCell,{sx:{fontWeight:500},children:[i.name,i.hasConflict&&e.jsx(r.Box,{component:"span",sx:{ml:1,color:"warning.main"},children:"⚠"})]}),e.jsx(r.TableCell,{children:e.jsx(r.Chip,{label:i.type,size:"small",sx:{bgcolor:"action.hover"}})}),e.jsx(r.TableCell,{children:e.jsx(r.Chip,{label:i.required?"Required":"Optional",size:"small",color:i.required?"success":"default"})})]},i.name))})]})}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pt:2,borderTop:1,borderColor:"divider"},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(B.Lock,{sx:{fontSize:16}}),e.jsx(r.Typography,{variant:"body2",color:"text.secondary",children:"Schema will be locked for this report"})]}),e.jsx(r.Button,{variant:"contained",onClick:o,disabled:n,sx:{fontWeight:500},children:"Generate Table"})]})]})}function hd({error:t,onRetry:o}){return e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderColor:"error.light",bgcolor:n=>k(n.palette.error.main,.12),borderRadius:1,px:2,py:6},children:[e.jsx(r.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:n=>k(n.palette.error.main,.3),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(B.ErrorOutline,{color:"error",sx:{fontSize:32}})}),e.jsx(r.Typography,{variant:"h6",color:"error.main",sx:{fontWeight:600,mb:1},children:"Upload Failed"}),e.jsx(r.Typography,{variant:"body2",color:"error.main",sx:{textAlign:"center",maxWidth:500,mb:3},children:t}),e.jsx(r.Button,{variant:"contained",color:"error",startIcon:e.jsx(B.Upload,{sx:{fontSize:16}}),onClick:o,sx:{fontWeight:500},children:"Try Again"})]})}function Ki({title:t,description:o,showIcon:n=!0}){return e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"60vh",px:3,py:8},children:[n&&e.jsx(r.Box,{sx:{width:80,height:80,borderRadius:"50%",bgcolor:i=>k(i.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:3},children:e.jsx(B.Description,{sx:{fontSize:36,color:"primary.main"}})}),e.jsx(r.Typography,{variant:"h5",sx:{fontWeight:500,mb:1,color:"text.primary",fontSize:"1.125rem"},children:t}),e.jsx(r.Typography,{variant:"body1",sx:{textAlign:"center",maxWidth:520,color:"text.secondary",fontSize:"0.875rem",lineHeight:1.5},children:o})]})}function fd({value:t,onChange:o,searchHistory:n,onAddToHistory:i,onToggleFavourite:s,onDeleteHistory:d,disabled:c}){const[l,u]=p.useState(!1),[f,m]=p.useState(!1),[h,x]=p.useState(-1),b=p.useRef(null),D=p.useRef(null);p.useEffect(()=>{function R(q){b.current&&!b.current.contains(q.target)&&(u(!1),m(!1))}return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[]);const g=p.useCallback(()=>{m(!0),x(-1),n.length>0&&u(!0)},[n.length]),j=p.useCallback(R=>{o(R),x(-1)},[o]),w=p.useCallback(R=>{var q;o(R),i(R),u(!1),(q=D.current)==null||q.blur()},[o,i]),I=p.useCallback(R=>{x(-1),w(R)},[w]),v=p.useCallback(R=>{var q;R.key==="Enter"?h>=0&&h<n.length?(R.preventDefault(),I(n[h].query)):t.trim()&&w(t.trim()):R.key==="Escape"?(u(!1),x(-1),(q=D.current)==null||q.blur()):R.key==="ArrowDown"?(R.preventDefault(),n.length>0&&(l||u(!0),x(K=>K<n.length-1?K+1:K))):R.key==="ArrowUp"&&(R.preventDefault(),x(K=>K>0?K-1:-1))},[h,n,t,l,I,w]),S=p.useCallback(()=>{var R;o(""),(R=D.current)==null||R.focus()},[o]),C=p.useMemo(()=>n.filter(R=>R.isFavourite),[n]),a=p.useMemo(()=>n.filter(R=>!R.isFavourite),[n]),z=l&&n.length>0;return e.jsxs(r.Box,{sx:{position:"relative",width:240},ref:b,children:[e.jsx(r.TextField,{inputRef:D,size:"small",fullWidth:!0,value:t,onChange:R=>j(R.target.value),onFocus:g,onKeyDown:v,placeholder:"Search data...",disabled:c,sx:{"& .MuiOutlinedInput-root":{borderRadius:"20px",fontSize:"0.875rem",bgcolor:"background.paper",height:"36px","& fieldset":{borderColor:R=>k(R.palette.text.primary,.3),transition:"all 0.15s ease"},"&:hover":{bgcolor:"action.hover"},"&:hover fieldset":{borderColor:R=>k(R.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:e.jsx(r.InputAdornment,{position:"start",sx:{ml:.5},children:e.jsx(B.Search,{sx:{fontSize:18,color:"text.secondary"}})}),endAdornment:t?e.jsx(r.InputAdornment,{position:"end",children:e.jsx(r.IconButton,{size:"small",onClick:S,edge:"end",sx:{mr:-.5},children:e.jsx(B.Close,{sx:{fontSize:16}})})}):null}}),z&&e.jsxs(r.Paper,{sx:{position:"absolute",zIndex:50,mt:.5,width:"100%",maxHeight:384,overflowY:"auto"},elevation:3,children:[C.length>0&&e.jsxs(r.Box,{sx:{py:1},children:[e.jsx(r.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:600,textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Favourite Searches"}),C.map((R,q)=>e.jsx(ni,{entry:R,isSelected:h===q,onClick:()=>I(R.query),onToggleFavourite:()=>s(R.query),onDelete:()=>d(R.query)},`fav-${R.query}`))]}),a.length>0&&e.jsxs(r.Box,{sx:{py:1},children:[C.length>0&&e.jsx(r.Divider,{}),e.jsx(r.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:600,textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Recent Searches"}),a.map((R,q)=>{const K=C.length+q;return e.jsx(ni,{entry:R,isSelected:h===K,onClick:()=>I(R.query),onToggleFavourite:()=>s(R.query),onDelete:()=>d(R.query)},`recent-${R.query}`)})]})]})]})}const ni=p.memo(function({entry:o,isSelected:n,onClick:i,onToggleFavourite:s,onDelete:d}){const c=p.useCallback(u=>{u.stopPropagation(),s()},[s]),l=p.useCallback(u=>{u.stopPropagation(),d()},[d]);return e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:1.5,py:1,cursor:"pointer",bgcolor:n?u=>k(u.palette.primary.main,.12):"transparent","&:hover":{bgcolor:n?u=>k(u.palette.primary.main,.12):"action.hover"}},children:[e.jsx(r.Box,{sx:{flex:1,minWidth:0},onClick:i,children:e.jsx(r.Typography,{variant:"body2",noWrap:!0,children:o.query})}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5,ml:1},children:[e.jsx(r.IconButton,{size:"small",onClick:c,title:o.isFavourite?"Remove from favourites":"Add to favourites",sx:{p:.5},children:o.isFavourite?e.jsx(B.Star,{sx:{fontSize:14,color:"warning.light"}}):e.jsx(B.StarBorder,{sx:{fontSize:14,color:"action.disabled"}})}),e.jsx(r.IconButton,{size:"small",onClick:l,title:"Delete from history",sx:{p:.5,"&:hover":{color:"error.main"}},children:e.jsx(B.Delete,{sx:{fontSize:14,opacity:.5}})})]})]})});function gd({views:t,activeViewId:o,isDirty:n,onSelectView:i,onCreateView:s,onManageViews:d,onToggleDefault:c,onToggleFavorite:l,onRestoreView:u,onPermanentDelete:f,isReadOnly:m,isAdmin:h=!1}){const x=zt(),[b,D]=p.useState(!1),[g,j]=p.useState(!1),[w,I]=p.useState({top:0,left:0}),[v,S]=p.useState(null),C=p.useRef(null),a=p.useRef(null),z=t.find(A=>A.id===o),R=z==null?void 0:z.isDefault,q=t.filter(A=>A.scope==="global"&&!A.isDeleted),K=t.filter(A=>A.scope!=="global"&&!A.isDeleted),ee=t.filter(A=>A.isFavorite&&!A.isDeleted).sort((A,H)=>(H.updatedAt||0)-(A.updatedAt||0)),y=t.filter(A=>A.isDeleted);p.useEffect(()=>{if(b&&a.current){const A=a.current.getBoundingClientRect();I({top:A.bottom+window.scrollY+8,left:A.right+window.scrollX-320})}},[b]),p.useEffect(()=>{const A=H=>{C.current&&!C.current.contains(H.target)&&a.current&&!a.current.contains(H.target)&&D(!1)};return b&&document.addEventListener("mousedown",A),()=>{document.removeEventListener("mousedown",A)}},[b]);const M=A=>{if(n&&A!==o){S(A),D(!1);return}i(A),D(!1)},W=()=>{v&&(i(v),S(null))},V=()=>{S(null)},Q=(A,H=!1)=>{const ie=A.scope==="global",Y=!m&&(!ie||h);return e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:o===A.id?k(x.palette.primary.main,.12):"transparent",transition:"background-color 0.2s","&:hover":{backgroundColor:o===A.id?k(x.palette.primary.main,.12):x.palette.action.hover}},children:[e.jsxs(r.Button,{onClick:()=>M(A.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:[o===A.id&&e.jsx(B.Check,{sx:{fontSize:16,flexShrink:0}}),o!==A.id&&e.jsx(r.Box,{sx:{width:"16px",flexShrink:0}}),e.jsx(r.Typography,{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:o===A.id?x.palette.primary.dark:x.palette.text.primary,fontWeight:o===A.id?500:400},children:A.name}),H&&e.jsx(r.Typography,{component:"span",sx:{fontSize:"caption.fontSize",color:x.palette.text.secondary,backgroundColor:x.palette.action.selected,px:1,py:.25,borderRadius:1,flexShrink:0},children:"Default"})]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[Y&&l&&e.jsx(r.IconButton,{onClick:re=>{re.stopPropagation(),l(A.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:x.palette.action.hover}},title:A.isFavorite?"Remove from favorites":"Add to favorites",children:e.jsx(B.Star,{sx:{fontSize:16}})}),Y&&c&&!A.isDefault&&e.jsx(r.IconButton,{onClick:re=>{re.stopPropagation(),c(A.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:x.palette.action.hover}},title:"Set as default",children:e.jsx(B.RadioButtonUnchecked,{sx:{fontSize:16}})})]})]},A.id)},xe=A=>e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:x.palette.action.hover},children:[e.jsx(r.Typography,{sx:{color:x.palette.text.secondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:A.name}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[u&&e.jsx(r.IconButton,{onClick:H=>{H.stopPropagation(),u(A.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:x.palette.action.hover}},title:"Restore view",children:e.jsx(B.Undo,{sx:{fontSize:16,color:"success.main"}})}),f&&e.jsx(r.IconButton,{onClick:H=>{H.stopPropagation(),f(A.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:x.palette.action.hover}},title:"Delete permanently",children:e.jsx(B.Delete,{sx:{fontSize:16,color:"error.main"}})})]})]},A.id),de=n||!R,L=n;return e.jsxs(r.Box,{sx:{position:"relative"},children:[e.jsxs(r.Button,{ref:a,onClick:()=>D(!b),variant:"outlined",size:"small",endIcon:e.jsx(B.KeyboardArrowDown,{sx:{fontSize:18}}),sx:{position:"relative",minWidth:140,maxWidth:220,justifyContent:"space-between",fontSize:"0.8125rem",textTransform:"none",color:de?"warning.main":"text.primary",borderColor:de?"warning.main":"divider",bgcolor:de?k(x.palette.warning.main,.12):"transparent",borderRadius:1,py:.5,px:1.25,transition:"all 0.15s ease","&:hover":{borderColor:de?"warning.dark":"primary.main",bgcolor:de?k(x.palette.warning.main,.2):k(x.palette.text.primary,.06),color:de?"warning.dark":"text.primary"}},title:`View: ${(z==null?void 0:z.name)||"Default View"}`,children:[e.jsx(r.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis"},children:(z==null?void 0:z.name)||"Default View"}),L&&e.jsx(r.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"}})]}),b&&gi.createPortal(e.jsxs(r.Box,{ref:C,sx:{position:"fixed",width:"320px",backgroundColor:x.palette.background.paper,border:`1px solid ${x.palette.divider}`,borderRadius:1,boxShadow:x.shadows[8],zIndex:50,maxHeight:"500px",overflowY:"auto",top:w.top,left:w.left},children:[q.length>0&&e.jsxs(r.Box,{sx:{py:.5},children:[e.jsx(r.Typography,{sx:{px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:x.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Global Views"}),q.map(A=>Q(A,A.isDefault))]}),ee.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{borderTop:`1px solid ${x.palette.divider}`}}),e.jsxs(r.Box,{sx:{py:.5},children:[e.jsxs(r.Box,{sx:{px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:x.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",gap:.5},children:[e.jsx(B.Star,{sx:{fontSize:12,color:"warning.light"}}),e.jsx(r.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:"Favorite Views"})]}),ee.map(A=>Q(A))]})]}),K.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{borderTop:`1px solid ${x.palette.divider}`}}),e.jsxs(r.Box,{sx:{py:.5},children:[e.jsx(r.Typography,{sx:{px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:x.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Personal Views"}),K.map(A=>Q(A))]})]}),y.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{borderTop:`1px solid ${x.palette.divider}`}}),e.jsxs(r.Box,{sx:{py:.5},children:[e.jsxs(r.Button,{onClick:()=>j(!g),sx:{width:"100%",px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:x.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",justifyContent:"space-between",transition:"background-color 0.2s","&:hover":{backgroundColor:x.palette.action.hover}},children:[e.jsxs(r.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:["Recently Deleted (",y.length,")"]}),e.jsx(B.ChevronRight,{sx:{fontSize:16}})]}),g&&e.jsx(r.Box,{sx:{backgroundColor:x.palette.action.hover},children:y.map(A=>xe(A))})]})]}),e.jsx(r.Box,{sx:{borderTop:`1px solid ${x.palette.divider}`}}),e.jsxs(r.Button,{onClick:()=>{s(),D(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:x.palette.text.primary,justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:x.palette.action.hover}},children:[e.jsx(B.Add,{sx:{fontSize:16}}),e.jsx(r.Typography,{component:"span",sx:{fontSize:"inherit"},children:"Create New Report View"})]}),e.jsxs(r.Button,{onClick:()=>{d(),D(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:x.palette.text.primary,justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:x.palette.action.hover}},children:[e.jsx(B.Settings,{sx:{fontSize:16}}),e.jsx(r.Typography,{component:"span",sx:{fontSize:"inherit"},children:"View Setup"})]})]}),document.body),e.jsxs(r.Dialog,{open:v!==null,onClose:V,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:Xr(x)}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",gap:1,pb:1},children:[e.jsx(B.Warning,{sx:{fontSize:20,color:"warning.main"}}),"Unsaved changes"]}),e.jsx(r.DialogContent,{children:e.jsx(r.Typography,{variant:"body2",color:"text.secondary",children:"You have unsaved changes to the current view. Switching views will discard them."})}),e.jsxs(r.DialogActions,{sx:{px:3,pb:2,gap:1},children:[e.jsx(r.Button,{onClick:V,variant:"text",children:"Stay here"}),e.jsx(r.Button,{onClick:W,variant:"contained",color:"warning",children:"Discard & switch"})]})]})]})}function yd({columnName:t,columnType:o="string",currentSort:n,hasFilters:i,isInSortStack:s,isReadOnly:d=!1,hasModifications:c=!1,position:l,onSortAscending:u,onSortDescending:f,onRemoveSort:m,onFilter:h,onClearFilter:x,onGroupByColumn:b,onHideColumn:D,onManageColumns:g,onManageViews:j,onResetLayout:w,onClose:I}){var ee,y;const v=zt(),S=v.palette,C=p.useRef(null);p.useEffect(()=>{if(!C.current)return;const M=C.current,W=M.getBoundingClientRect(),V=window.innerWidth,Q=window.innerHeight;W.right>V-8&&(M.style.left=`${V-W.width-8}px`),W.bottom>Q-8&&(M.style.top=`${Q-W.height-8}px`)},[l]),p.useEffect(()=>{const M=V=>{C.current&&!C.current.contains(V.target)&&I()},W=V=>{V.key==="Escape"&&I()};return document.addEventListener("mousedown",M),document.addEventListener("keydown",W),()=>{document.removeEventListener("mousedown",M),document.removeEventListener("keydown",W)}},[I]);const a=p.useCallback(M=>()=>{M(),I()},[I]),z=(n==null?void 0:n.direction)==="asc",R=(n==null?void 0:n.direction)==="desc",q=o==="number"?"0→9":o==="boolean"?"F→T":"A→Z",K=o==="number"?"9→0":o==="boolean"?"T→F":"Z→A";return gi.createPortal(e.jsxs(r.Paper,{ref:C,elevation:0,sx:{position:"fixed",left:`${l.x}px`,top:`${l.y}px`,zIndex:v.zIndex.tooltip,minWidth:210,maxWidth:264,border:"1px solid",borderColor:"divider",borderRadius:Xr(v),overflow:"hidden",boxShadow:`0 4px 20px ${k(((ee=S.common)==null?void 0:ee.black)??"#000",.12)}, 0 1px 4px ${k(((y=S.common)==null?void 0:y.black)??"#000",.06)}`},children:[!d&&e.jsxs(r.Box,{sx:{px:2,py:.75,display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid",borderColor:"divider"},children:[e.jsx(r.Typography,{sx:{fontSize:"0.8125rem",fontWeight:500,color:"text.primary"},children:"Sorting"}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.25},children:[e.jsx(r.Tooltip,{title:`Sort Ascending (${q})`,placement:"top",arrow:!0,children:e.jsx(r.IconButton,{size:"small",onClick:a(()=>u(t)),sx:{p:.625,borderRadius:"6px",color:z?"primary.main":"text.secondary",bgcolor:z?k(S.primary.main,.1):"transparent","&:hover":{bgcolor:k(S.primary.main,.08),color:"primary.main"}},children:e.jsx(B.ArrowUpward,{sx:{fontSize:16}})})}),e.jsx(r.Tooltip,{title:`Sort Descending (${K})`,placement:"top",arrow:!0,children:e.jsx(r.IconButton,{size:"small",onClick:a(()=>f(t)),sx:{p:.625,borderRadius:"6px",color:R?"primary.main":"text.secondary",bgcolor:R?k(S.primary.main,.1):"transparent","&:hover":{bgcolor:k(S.primary.main,.08),color:"primary.main"}},children:e.jsx(B.ArrowDownward,{sx:{fontSize:16}})})}),e.jsx(r.Tooltip,{title:"Clear Sort",placement:"top",arrow:!0,children:e.jsx("span",{children:e.jsx(r.IconButton,{size:"small",disabled:!s,onClick:a(()=>m(t)),sx:{p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:k(S.error.main,.08),color:"error.main"},"&.Mui-disabled":{opacity:.3}},children:e.jsx(B.Close,{sx:{fontSize:16}})})})})]})]}),e.jsxs(r.MenuList,{dense:!0,sx:{py:.5},children:[e.jsxs(r.MenuItem,{onClick:a(()=>h(t)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(B.FilterList,{sx:{fontSize:16,color:i?"primary.main":"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Filter by Column",primaryTypographyProps:{fontSize:"0.8125rem",fontWeight:i?600:400,color:i?"primary.main":"text.primary"}})]}),i&&!d&&e.jsxs(r.MenuItem,{onClick:a(()=>x(t)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:k(S.warning.main,.06),"& .MuiListItemText-primary":{color:"warning.main"},"& .MuiListItemIcon-root svg":{color:"warning.main"}}},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(B.FilterListOff,{sx:{fontSize:16,color:"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Clear Filter",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]}),!d&&b&&e.jsxs(e.Fragment,{children:[e.jsx(r.Divider,{sx:{my:.25}}),e.jsx(r.MenuList,{dense:!0,sx:{py:.5},children:e.jsxs(r.MenuItem,{onClick:a(()=>b(t)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(B.GroupWorkOutlined,{sx:{fontSize:16,color:"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Group By Column",primaryTypographyProps:{fontSize:"0.8125rem"}})]})})]}),e.jsx(r.Divider,{sx:{my:.25}}),e.jsxs(r.MenuList,{dense:!0,sx:{py:.5},children:[!d&&e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",mx:.5,borderRadius:"6px",overflow:"hidden","&:hover":{bgcolor:"action.hover"}},children:[e.jsxs(r.MenuItem,{onClick:a(()=>D(t)),sx:{flex:1,py:.75,px:1.5,minHeight:34,borderRadius:"6px 0 0 6px","&:hover":{bgcolor:"transparent"}},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(B.VisibilityOff,{sx:{fontSize:16,color:"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Hide Column",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),e.jsx(r.Tooltip,{title:"Manage Columns",placement:"top",arrow:!0,children:e.jsx(r.IconButton,{size:"small",onClick:a(g),sx:{mr:.75,p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:k(S.primary.main,.08),color:"primary.main"}},children:e.jsx(B.Settings,{sx:{fontSize:16}})})})]}),d&&e.jsxs(r.MenuItem,{onClick:a(g),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(B.Settings,{sx:{fontSize:16,color:"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Manage Columns",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),j&&e.jsxs(r.MenuItem,{onClick:a(j),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(B.TableRows,{sx:{fontSize:16,color:"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Manage Views",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),!d&&c&&w&&e.jsxs(r.MenuItem,{onClick:a(w),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:k(S.error.main,.05),"& .MuiListItemText-primary":{color:"error.main"},"& .MuiListItemIcon-root svg":{color:"error.main"}}},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(B.RestartAlt,{sx:{fontSize:16,color:"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Reset to Default Layout",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]})]}),document.body)}const bd=176,ii="COLUMN_HEADER",vd=p.memo(function({column:o,index:n,sortRule:i,hasFilters:s,isInSortStack:d,isReadOnly:c=!1,hasModifications:l=!1,width:u,onColumnClick:f,onMoveColumn:m,onColumnDragEnd:h,onResizeStart:x,onSortAscending:b,onSortDescending:D,onRemoveSort:g,onOpenFilterForColumn:j,onClearFiltersForColumn:w,onGroupByColumn:I,onHideColumn:v,onManageColumns:S,onManageViews:C,onResetLayout:a}){const z=p.useRef(null),[R,q]=p.useState(!1),[K,ee]=p.useState({x:0,y:0}),[{handlerId:y,isOver:M},W]=kt.useDrop({accept:ii,collect(Y){return{handlerId:Y.getHandlerId(),isOver:Y.isOver()}},hover(Y,re){var fe;if(!z.current)return;const se=Y.index,oe=n;if(se===oe)return;const P=(fe=z.current)==null?void 0:fe.getBoundingClientRect(),ne=(P.right-P.left)/2,ce=re.getClientOffset(),ae=((ce==null?void 0:ce.x)??0)-P.left;se<oe&&ae<ne||se>oe&&ae>ne||(m(se,oe),Y.index=oe)}}),[{isDragging:V},Q]=kt.useDrag({type:ii,item:()=>({index:n,columnName:o.name}),collect:Y=>({isDragging:Y.isDragging()}),end:()=>{h==null||h()}});Q(W(z));const xe=p.useCallback(Y=>{Y.preventDefault(),Y.stopPropagation(),ee({x:Y.clientX,y:Y.clientY}),q(!0)},[]),de=p.useCallback(()=>q(!1),[]),L=p.useCallback(()=>{f(o.name)},[f,o.name]),A=p.useCallback(Y=>{Y.stopPropagation(),j(o.name)},[j,o.name]),H=p.useCallback(()=>i?e.jsxs(r.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[i.direction==="asc"?e.jsx(B.ArrowUpward,{sx:{fontSize:13,color:"primary.main"}}):e.jsx(B.ArrowDownward,{sx:{fontSize:13,color:"primary.main"}}),e.jsx(r.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]),ie=p.useCallback(()=>s?e.jsx(B.FilterList,{onClick:A,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,A]);return e.jsxs(e.Fragment,{children:[e.jsxs(r.TableCell,{ref:z,"data-handler-id":y,"data-column-index":n,onClick:L,onContextMenu:xe,sx:{position:"sticky",top:0,zIndex:5,textAlign:"left",fontSize:"0.8125rem",fontWeight:700,textTransform:"none",letterSpacing:0,whiteSpace:"nowrap",overflow:"visible",cursor:"pointer",userSelect:"none",color:"primary.main",opacity:V?.25:1,transition:"background-color 0.12s ease, opacity 0.15s ease",bgcolor:M?Y=>k(Y.palette.primary.main,.08):"action.hover",boxShadow:Y=>`0 1px 0 ${k(Y.palette.common.black,.08)}`,backgroundImage:"none",borderBottom:"1px solid",borderColor:"divider",py:0,px:2,height:34,"&:hover":{bgcolor:Y=>k(Y.palette.primary.main,.1),color:"primary.dark"},width:u?`${u}px`:`${bd}px`},children:[e.jsxs(r.Box,{sx:{display:"inline-flex",alignItems:"center",overflow:"hidden",maxWidth:"100%",pr:"12px"},children:[Ke(o.name),H(),ie()]}),e.jsx(r.Box,{draggable:!1,onDragStart:Y=>Y.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:Y=>{Y.preventDefault(),Y.stopPropagation(),x(Y,o.name)},onClick:Y=>Y.stopPropagation(),children:e.jsx(r.Box,{draggable:!1,sx:{width:2,height:"50%",borderRadius:1,opacity:0,bgcolor:"primary.main",transition:"opacity 0.15s ease",pointerEvents:"none"}})}),M&&e.jsx(r.Box,{sx:{position:"absolute",left:0,top:0,bottom:0,width:4,bgcolor:"primary.main"}})]}),R&&e.jsx(yd,{columnName:o.name,columnType:o.type,currentSort:i,hasFilters:s,isInSortStack:d,isReadOnly:c,hasModifications:l,position:K,onSortAscending:b,onSortDescending:D,onRemoveSort:g,onFilter:j,onClearFilter:w,onGroupByColumn:I,onHideColumn:v,onManageColumns:S,onManageViews:C,onResetLayout:a,onClose:de})]})});function Sd({selectedCount:t,viewMode:o="list",onExportSelected:n,onClearSelection:i}){const[s,d]=p.useState(null);if(t===0)return null;const c=l=>{n(l),d(null)};return e.jsx(r.Box,{sx:{width:"100%",flexShrink:0,bgcolor:l=>k(l.palette.primary.main,.08),borderBottom:l=>`1px solid ${k(l.palette.primary.main,.25)}`,zIndex:10},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:1.25},children:[e.jsxs(r.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"primary.main"},children:[t," ",o==="grid"?t===1?"card":"cards":t===1?"row":"rows"," ","selected"]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(r.Button,{onClick:i,startIcon:e.jsx(B.Close,{sx:{fontSize:16}}),size:"small",sx:{fontSize:"0.875rem",px:2,py:.625,borderRadius:"18px",color:"text.secondary","&:hover":{bgcolor:l=>k(l.palette.text.primary,.06),color:"text.primary"}},children:"Clear"}),e.jsx(r.Button,{onClick:l=>d(l.currentTarget),startIcon:e.jsx(B.Download,{sx:{fontSize:16}}),size:"small",variant:"outlined",sx:{fontSize:"0.875rem",px:2,py:.625,borderRadius:"18px",borderColor:l=>k(l.palette.primary.main,.4),color:"primary.main","&:hover":{borderColor:"primary.main",bgcolor:l=>k(l.palette.primary.main,.06)}},children:"Export Selected"}),e.jsxs(r.Menu,{anchorEl:s,open:!!s,onClose:()=>d(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},PaperProps:{sx:{mt:.5,minWidth:180,borderRadius:1.5}},children:[e.jsx(r.MenuItem,{dense:!0,onClick:()=>c("csv"),sx:{py:1,px:2},children:"Export as CSV"}),e.jsx(r.MenuItem,{dense:!0,onClick:()=>c("excel"),sx:{py:1,px:2},children:"Export as Excel"}),e.jsx(r.MenuItem,{dense:!0,onClick:()=>c("json"),sx:{py:1,px:2},children:"Export as JSON"})]})]})]})})}const jd={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 bo(t,o){const n=jd[o.toLowerCase().trim()];if(!n||n==="neutral")return{bg:t.palette.action.selected,color:t.palette.text.secondary};const i=t.palette[n];return{bg:k(i.main,t.palette.mode==="dark"?.24:.12),color:t.palette.mode==="dark"?i.light:i.dark}}function Cd(t,o){switch(o.toLowerCase().trim()){case"low":return t.palette.text.secondary;case"medium":return t.palette.warning.main;case"high":return t.palette.warning.dark;case"critical":case"urgent":return t.palette.error.main;default:return}}const wd={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"}};function kd(t,o){const n=wd[o];return n?t.palette[n.hue][n.shade]:t.palette.text.secondary}function Re(t){return k(t.palette.primary.main,t.palette.mode==="dark"?.24:.12)}function Td(t){const o=t.toLowerCase().trim();return e.jsx(r.Box,{component:"span",sx:{display:"inline-flex",alignItems:"center",px:1,py:.25,borderRadius:"10px",fontSize:"0.75rem",fontWeight:500,bgcolor:n=>bo(n,o).bg,color:n=>bo(n,o).color,whiteSpace:"nowrap",lineHeight:1.5},children:t})}function zd(t,o){if(o==null||o==="")return e.jsx(r.Box,{component:"span",sx:{color:"text.disabled",fontSize:"0.8125rem"},children:"—"});const n=String(o),i=t.name.toLowerCase();if(/\b(status|state|stage)\b/.test(i))return Td(n);if(/\b(priority|severity|urgency)\b/.test(i)){const s=n.toLowerCase().trim();return e.jsx(r.Box,{component:"span",sx:d=>{const c=Cd(d,s);return c?{color:c,fontWeight:600,fontSize:"0.8125rem"}:{fontSize:"0.8125rem"}},children:n})}return typeof o=="boolean"?e.jsx(r.Box,{component:"span",sx:{fontSize:"0.8125rem"},children:o?"Yes":"No"}):typeof o=="object"?e.jsx(r.Box,{component:"span",sx:{fontSize:"0.8125rem"},children:JSON.stringify(o)}):e.jsx(r.Box,{component:"span",sx:{fontSize:"0.8125rem"},children:n})}function Bd(t){const o=t.find(s=>{const d=s.name.toLowerCase();return/\b(name|title|label|subject|task_?name|taskname)\b/.test(d)})||t[0]||null,n=t.find(s=>{const d=s.name.toLowerCase().replace(/[\s_-]/g,"");return/(^id$|id$|_id$|taskid|code$|ref$)/.test(d)&&s!==o})||null,i=t.filter(s=>s!==o&&s!==n).slice(0,4);return{primaryCol:o,idCol:n,bodyColumns:i}}function Id({row:t,rowIndex:o,visibleColumns:n,isSelected:i,isReadOnly:s,onToggleSelection:d,onView:c,onEdit:l,onDuplicate:u,onDelete:f}){const[m,h]=p.useState(null),[x,b]=p.useState(!1),{primaryCol:D,idCol:g,bodyColumns:j}=p.useMemo(()=>Bd(n),[n]),w=D?t[D.name]:null,I=g?t[g.name]:null,v=x||i||!!m;return e.jsxs(r.Box,{onMouseEnter:()=>b(!0),onMouseLeave:()=>b(!1),onClick:()=>d(o),sx:{position:"relative",display:"flex",flexDirection:"column",bgcolor:"background.paper",border:"1px solid",borderColor:i?"primary.main":S=>k(S.palette.divider,.8),borderWidth:i?2:1,borderRadius:"12px",cursor:"pointer",transition:"box-shadow 0.2s ease, border-color 0.2s ease, transform 0.15s ease",overflow:"hidden",minHeight:180,boxShadow:i?S=>`0 0 0 3px ${k(S.palette.primary.main,.15)}, 0 2px 8px ${k(S.palette.common.black,.08)}`:x?S=>te(S,"cardHover"):S=>te(S,"cardRest"),transform:x&&!i?"translateY(-2px)":"none","&:active":{transform:"translateY(0)"},...i&&{bgcolor:S=>k(S.palette.primary.main,.03)}},children:[e.jsx(r.Box,{sx:{px:2,pt:2,pb:1.5},children:e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600,fontSize:"0.9375rem",color:"text.primary",lineHeight:1.35,wordBreak:"break-word",letterSpacing:"-0.01em"},children:w!=null&&w!==""?String(w):e.jsx(r.Box,{component:"span",sx:{color:"text.disabled",fontStyle:"italic",fontWeight:400},children:"Untitled"})})}),e.jsx(r.Box,{sx:{mx:2,height:"1px",bgcolor:"divider",flexShrink:0}}),e.jsxs(r.Box,{sx:{px:2,py:1.5,flex:1,display:"flex",flexDirection:"column",gap:1},children:[j.map(S=>e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,minHeight:22},children:[e.jsx(r.Typography,{sx:{color:"text.secondary",fontWeight:500,fontSize:"0.6875rem",textTransform:"uppercase",letterSpacing:"0.06em",minWidth:68,flexShrink:0,lineHeight:1},children:Ke(S.name)}),e.jsx(r.Box,{sx:{flex:1,lineHeight:1},children:zd(S,t[S.name])})]},S.name)),j.length===0&&e.jsx(r.Typography,{variant:"caption",color:"text.disabled",sx:{fontStyle:"italic"},children:"No additional fields visible"})]}),e.jsxs(r.Box,{sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid",borderColor:"divider",bgcolor:S=>k(S.palette.action.hover,.1),minHeight:40},children:[e.jsx(r.Typography,{sx:{color:"primary.main",fontFamily:'"Roboto Mono", "Courier New", monospace',fontSize:"0.75rem",fontWeight:400,letterSpacing:"0.04em",opacity:I?.85:0,userSelect:"none"},children:I?String(I):" "}),e.jsx(r.Box,{sx:{display:"flex",alignItems:"center",gap:.25,opacity:v?1:0,transition:"opacity 0.15s ease"},onClick:S=>S.stopPropagation(),children:e.jsx(r.Tooltip,{title:"More actions",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:S=>{S.stopPropagation(),h(S.currentTarget)},sx:{width:28,height:28,color:"action.active","&:hover":{bgcolor:S=>k(S.palette.text.primary,.08)}},children:e.jsx(B.MoreVert,{sx:{fontSize:17}})})})})]}),e.jsxs(r.Popover,{open:!!m,anchorEl:m,onClose:()=>h(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},PaperProps:{sx:{minWidth:180,py:.5,borderRadius:"10px",boxShadow:S=>te(S,"popover")}},onClick:S=>S.stopPropagation(),children:[e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{c(t),h(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[e.jsx(B.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"View"})]}),!s&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{l(t,o),h(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[e.jsx(B.Edit,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Edit"})]}),!s&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{u(o,t),h(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[e.jsx(B.ContentCopy,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Duplicate"})]}),!s&&e.jsxs(e.Fragment,{children:[e.jsx(r.Divider,{sx:{my:.5,mx:.5}}),e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{f(o,t),h(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5,color:"error.main"},children:[e.jsx(B.Delete,{sx:{fontSize:18,color:"error.main"}}),e.jsx(r.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]})]})]})}function Dd({row:t,grouping:o,onToggleCollapse:n}){var i;return e.jsxs(r.Box,{onClick:()=>n(t.groupKey),sx:{gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:1,px:2,py:1,mt:1,mb:.5,bgcolor:"background.paper",border:"1px solid",borderColor:"divider",borderRadius:"8px",cursor:"pointer",boxShadow:s=>te(s,"flatHover"),"&:hover":{bgcolor:s=>k(s.palette.primary.main,.04),borderColor:"primary.light"},transition:"all 0.15s ease"},children:[t.isCollapsed?e.jsx(B.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}):e.jsx(B.KeyboardArrowDown,{sx:{fontSize:16,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600,color:"text.primary"},children:ki(t.groupLevel,((i=o==null?void 0:o.levels[t.groupLevel])==null?void 0:i.column)||"",t.groupValue)}),e.jsxs(r.Box,{sx:{px:1,py:.125,fontSize:"0.6875rem",fontWeight:600,bgcolor:s=>k(s.palette.primary.main,.1),color:"primary.main",borderRadius:"10px"},children:[t.rowCount," ",t.rowCount===1?"row":"rows"]}),Object.keys(t.aggregates).length>0&&e.jsx(r.Typography,{variant:"caption",sx:{ml:.5,color:"text.secondary"},children:Object.entries(t.aggregates).map(([s,d])=>wi(d)).filter(Boolean).join(" • ")})]})}function Ed({data:t,visibleColumns:o,grouping:n,selectedRowIds:i,isReadOnly:s,isGrouped:d,sortStack:c=[],onSort:l,onToggleRowSelection:u,onToggleGroupCollapse:f,onViewRow:m,onEditRow:h,onDuplicateRow:x,onDeleteRow:b}){const D=p.useMemo(()=>{const g=new Set;return i.forEach(j=>{const w=j==null?void 0:j.__urm_row_id__;w!==void 0&&g.add(w)}),g},[i]);return t.length===0?e.jsx(r.Box,{sx:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",py:10},children:e.jsx(r.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})}):e.jsxs(r.Box,{sx:{fontFamily:g=>g.typography.fontFamily},children:[l&&o.length>0&&e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75,px:2,py:1,borderBottom:"1px solid",borderColor:"divider",bgcolor:"background.paper",flexWrap:"wrap"},children:[e.jsx(r.Typography,{variant:"caption",sx:{color:"text.secondary",fontWeight:500,mr:.5,whiteSpace:"nowrap"},children:"Sort by:"}),o.map(g=>{const j=c.find(w=>w.column===g.name);return e.jsxs(r.Box,{onClick:()=>l(g.name),sx:{display:"inline-flex",alignItems:"center",gap:.5,px:1.25,py:.375,borderRadius:"6px",border:"1px solid",borderColor:j?"primary.main":"divider",bgcolor:j?w=>k(w.palette.primary.main,.07):"transparent",cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:"primary.light",bgcolor:w=>k(w.palette.primary.main,.05)}},children:[e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",fontWeight:j?600:400,color:j?"primary.main":"text.secondary",whiteSpace:"nowrap"},children:Ke(g.name)}),j?j.direction==="asc"?e.jsx(B.ArrowUpward,{sx:{fontSize:12,color:"primary.main"}}):e.jsx(B.ArrowDownward,{sx:{fontSize:12,color:"primary.main"}}):e.jsx(B.SwapVert,{sx:{fontSize:12,color:"text.disabled"}})]},g.name)})]}),e.jsx(r.Box,{sx:{p:2,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(272px, 1fr))",gap:1.5,alignContent:"start"},children:t.map((g,j)=>d&&g.isGroupHeader?e.jsx(Dd,{row:g,grouping:n,onToggleCollapse:f||(()=>{})},`group-${g.groupKey}`):e.jsx(Id,{row:g,rowIndex:j,visibleColumns:o,isSelected:D.has(g==null?void 0:g.__urm_row_id__),isReadOnly:s,onToggleSelection:()=>u(g),onView:m,onEdit:h,onDuplicate:x,onDelete:b},`card-${j}`))})]})}const si=[10,15,25,50,100];function Od(t,o){const n=t.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>o?"Entered page number is out of range":null}function Ad({currentPage:t,pageSize:o,totalRows:n,totalFields:i,onPageChange:s,onPageSizeChange:d}){var M;const l=zt().palette,u=Math.ceil(n/o),[f,m]=p.useState(String(t)),[h,x]=p.useState(null),[b,D]=p.useState(!1),g=p.useRef(null);p.useEffect(()=>{b||(m(String(t)),x(null))},[t,b]);const j=p.useCallback(()=>{const W=Od(f,u);if(W){x(W);return}const V=parseInt(f.trim(),10);x(null),D(!1),V!==t&&s(V)},[f,u,t,s]),w=p.useCallback(W=>{var V;W.key==="Enter"?(W.preventDefault(),j()):W.key==="Escape"&&(m(String(t)),x(null),D(!1),(V=g.current)==null||V.blur())},[j,t]),I=p.useCallback(()=>{m(String(t)),x(null),D(!1)},[t]),v=p.useCallback(()=>{D(!0),x(null),setTimeout(()=>{var W;return(W=g.current)==null?void 0:W.select()},0)},[]);if(n<=Math.min(...si))return null;const S=()=>{m(String(t)),x(null),D(!1)},C=()=>{S(),s(1)},a=()=>{S(),t>1&&s(t-1)},z=()=>{S(),t<u&&s(t+1)},R=()=>{S(),s(u)},q=(t-1)*o+1,K=Math.min(t*o,n),ee=`${Math.max(2,String(u).length+.5)}ch`,y={p:.75,color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"action.disabled"}};return e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:3,px:2,py:1,borderTop:"1px solid",borderColor:"divider",bgcolor:"background.paper",minHeight:48},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:2},children:[e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400},children:["Total data:"," ",e.jsx(r.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:n})]}),i!==void 0&&e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400},children:["Total fields:"," ",e.jsx(r.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:i})]})]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:3},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400},children:"Rows per page:"}),e.jsx(r.Select,{value:o,onChange:W=>d(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:si.map(W=>e.jsx(r.MenuItem,{value:W,sx:{fontSize:"0.8125rem"},children:W},W))})]}),e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400,userSelect:"none"},children:[q,"–",K," of ",n]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75,position:"relative"},children:[e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",userSelect:"none"},children:"Page"}),e.jsxs(r.Box,{sx:{position:"relative"},children:[h&&e.jsx(r.Box,{sx:{position:"absolute",bottom:"calc(100% + 6px)",left:"50%",transform:"translateX(-50%)",bgcolor:"background.paper",border:"1px solid",borderColor:k(l.error.main,.4),borderRadius:"6px",px:1,py:.5,boxShadow:`0 2px 8px ${k(((M=l.common)==null?void 0:M.black)??"#000",.12)}`,zIndex:20,whiteSpace:"nowrap","&::after":{content:'""',position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)",border:"5px solid transparent",borderTopColor:k(l.error.main,.4)}},children:e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:500,color:"error.main",lineHeight:1.3},children:h})}),e.jsx(r.InputBase,{inputRef:g,value:f,onChange:W=>{m(W.target.value),h&&x(null)},onKeyDown:w,onFocus:v,onBlur:I,inputProps:{"aria-label":`Page number, 1 to ${u}`,style:{textAlign:"center",padding:"2px 0",width:ee,fontSize:"0.8125rem",fontWeight:600}},sx:{fontSize:"0.8125rem",fontWeight:600,color:h?"error.main":"text.primary",border:"1px solid",borderColor:h?"error.main":b?"primary.main":"divider",borderRadius:"4px",bgcolor:h?k(l.error.main,.04):b?k(l.primary.main,.04):"background.paper",px:.75,transition:"border-color 0.15s ease, background-color 0.15s ease","&:hover":{borderColor:h?"error.main":"text.secondary"},"&:focus-within":{boxShadow:h?`0 0 0 2px ${k(l.error.main,.2)}`:`0 0 0 2px ${k(l.primary.main,.2)}`}}})]}),e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",userSelect:"none"},children:["of ",u]})]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(r.IconButton,{onClick:C,disabled:t===1,size:"small",title:"First page",sx:y,children:e.jsx(B.FirstPage,{sx:{fontSize:20}})}),e.jsx(r.IconButton,{onClick:a,disabled:t===1,size:"small",title:"Previous page",sx:y,children:e.jsx(B.ChevronLeft,{sx:{fontSize:20}})}),e.jsx(r.IconButton,{onClick:z,disabled:t===u,size:"small",title:"Next page",sx:y,children:e.jsx(B.ChevronRight,{sx:{fontSize:20}})}),e.jsx(r.IconButton,{onClick:R,disabled:t===u,size:"small",title:"Last page",sx:y,children:e.jsx(B.LastPage,{sx:{fontSize:20}})})]})]})]})}function $d(){return e.jsx(r.Chip,{icon:e.jsx(B.Visibility,{sx:{fontSize:14}}),label:"View Only",size:"small",variant:"outlined",sx:{bgcolor:"action.hover",borderColor:"divider",fontSize:"caption.fontSize",fontWeight:500}})}const Xi="urm_hint_seen_";function Md(t){try{return localStorage.getItem(Xi+t)==="true"}catch{return!1}}function Rd(t){try{localStorage.setItem(Xi+t,"true")}catch{}}function ai(t,o){if(t==null||t==="")return"";if(o==="boolean")return t?"True":"False";if(o==="object"||o==="array")try{return JSON.stringify(t,null,2)}catch{return String(t)}return String(t)}function li(t){const o={fontSize:11};switch(t){case"number":return e.jsx(B.Numbers,{sx:o});case"boolean":return e.jsx(B.CheckBox,{sx:o});case"array":return e.jsx(B.DataArray,{sx:o});case"object":return e.jsx(B.DataObject,{sx:o});default:return e.jsx(B.TextFields,{sx:o})}}function ci(t,o){var n,i;switch(t){case"number":return{bg:k(o.primary.main,.08),color:o.primary.main};case"boolean":return{bg:k(((n=o.success)==null?void 0:n.main)??"#2e7d32",.08),color:((i=o.success)==null?void 0:i.main)??"#2e7d32"};case"array":case"object":return{bg:k(o.secondary.main,.08),color:o.secondary.main};default:return{bg:k(o.text.secondary,.07),color:o.text.secondary}}}function _d({open:t,onClose:o,row:n,schema:i,reportName:s}){var h,x;const d=zt(),c=d.palette;if(!n)return null;const l=i.filter(b=>b.name in n),u=l.filter(b=>b.type!=="object"&&b.type!=="array"),f=l.filter(b=>b.type==="object"||b.type==="array"),m=l.length;return e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:Me(d),maxHeight:"min(720px, calc(100vh - 80px))",display:"flex",flexDirection:"column",boxShadow:`0 8px 32px ${k(((h=c.common)==null?void 0:h.black)??"#000",.14)}, 0 2px 8px ${k(((x=c.common)==null?void 0:x.black)??"#000",.08)}`,overflow:"hidden"}},children:[e.jsxs(r.Box,{sx:{px:3,pt:2.5,pb:2,bgcolor:"background.paper",display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,minWidth:0},children:[e.jsx(r.Box,{sx:{width:36,height:36,borderRadius:"10px",bgcolor:k(c.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(B.VisibilityOutlined,{sx:{fontSize:18,color:"primary.main"}})}),e.jsxs(r.Box,{sx:{minWidth:0},children:[e.jsx(r.Typography,{variant:"h6",sx:{fontSize:"1rem",fontWeight:600,color:"text.primary",lineHeight:1.3},children:"View Record"}),s&&e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary",display:"block",mt:.25,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[s," · ",m," ",m===1?"field":"fields"]})]})]}),e.jsx(r.IconButton,{size:"small",onClick:o,sx:{mt:.25,color:"text.secondary",borderRadius:"8px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(B.Close,{sx:{fontSize:18}})})]}),e.jsx(r.Divider,{}),e.jsxs(r.DialogContent,{sx:{p:0,overflowY:"auto",flex:1,bgcolor:k(c.text.primary,.015)},children:[u.length>0&&e.jsx(r.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"1px",bgcolor:"divider",m:2,mb:f.length>0?1.5:2,borderRadius:"12px",overflow:"hidden",border:"1px solid",borderColor:"divider"},children:u.map((b,D)=>{const g=n[b.name],j=ai(g,b.type),w=!j,I=ci(b.type,c),v=D===u.length-1&&u.length%2!==0;return e.jsxs(r.Box,{sx:{bgcolor:"background.paper",px:2,py:1.75,gridColumn:v?"span 2":"span 1",display:"flex",flexDirection:"column",gap:.75},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5,px:.75,py:.25,borderRadius:"4px",bgcolor:I.bg,color:I.color,flexShrink:0},children:li(b.type)}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.06em",lineHeight:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Ke(b.name)})]}),e.jsx(r.Typography,{sx:{fontSize:"0.875rem",fontWeight:w?400:500,color:w?"text.disabled":"text.primary",fontStyle:w?"italic":"normal",lineHeight:1.5,wordBreak:"break-word",fontFamily:b.type==="number"?'"Roboto Mono", monospace':"inherit"},children:w?"No value":j})]},b.name)})}),f.map(b=>{const D=n[b.name],g=ai(D,b.type),j=!g,w=ci(b.type,c);return e.jsxs(r.Box,{sx:{mx:2,mb:1.5,borderRadius:"12px",overflow:"hidden",border:"1px solid",borderColor:"divider"},children:[e.jsxs(r.Box,{sx:{px:2,py:1.25,bgcolor:"background.paper",borderBottom:"1px solid",borderColor:"divider",display:"flex",alignItems:"center",gap:.75},children:[e.jsx(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5,px:.75,py:.25,borderRadius:"4px",bgcolor:w.bg,color:w.color},children:li(b.type)}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.06em"},children:Ke(b.name)}),e.jsx(r.Chip,{label:b.type,size:"small",sx:{height:18,fontSize:"0.625rem",fontWeight:600,ml:"auto",bgcolor:w.bg,color:w.color,border:"none",letterSpacing:"0.03em"}})]}),e.jsx(r.Box,{component:"pre",sx:{m:0,px:2,py:1.5,bgcolor:k(c.text.primary,.02),fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:j?"text.disabled":"text.primary",fontStyle:j?"italic":"normal",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6},children:j?"No value":g})]},b.name)}),l.length===0&&e.jsxs(r.Box,{sx:{py:6,display:"flex",flexDirection:"column",alignItems:"center",gap:1,color:"text.disabled"},children:[e.jsx(B.VisibilityOutlined,{sx:{fontSize:40,opacity:.4}}),e.jsx(r.Typography,{variant:"body2",children:"No fields to display"})]})]}),e.jsx(r.Divider,{}),e.jsx(r.DialogActions,{sx:{px:3,py:1.75,bgcolor:"background.paper",justifyContent:"flex-end"},children:e.jsx(r.Button,{onClick:o,variant:"contained",sx:{fontSize:"0.8125rem",px:3,py:.75,borderRadius:b=>`${b.shape.borderRadius}px`,minWidth:80},children:"Close"})})]})}function Wd({open:t,onClose:o,onConfirm:n,rowPreview:i}){return e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:s=>Me(s),maxHeight:"min(480px, calc(100vh - 180px))",my:"auto",boxShadow:s=>te(s,"menu")}},children:[e.jsxs(r.Box,{sx:{px:3,pt:2.5,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[e.jsxs(r.Stack,{direction:"row",spacing:1.5,alignItems:"flex-start",children:[e.jsx(r.Box,{sx:{width:40,height:40,borderRadius:"50%",bgcolor:s=>k(s.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(B.WarningAmberRounded,{sx:{fontSize:22,color:"error.main"}})}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5,mb:.5},children:"Delete record?"}),e.jsxs(r.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"text.secondary"},children:[i?`"${i}"`:"This record"," will be permanently removed."]})]})]}),e.jsx(r.IconButton,{size:"small",onClick:o,sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(B.Close,{sx:{fontSize:20}})})]}),e.jsx(r.DialogContent,{sx:{px:3,pb:2},children:e.jsx(r.Box,{sx:{p:2,borderRadius:"8px",bgcolor:s=>k(s.palette.error.main,.1),border:s=>`1px solid ${k(s.palette.error.main,.5)}`},children:e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"error.main",fontWeight:500},children:"This action cannot be undone. The record will be deleted from this report immediately."})})}),e.jsxs(r.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:[e.jsx(r.Button,{onClick:o,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:s=>`${s.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:()=>{n(),o()},variant:"contained",startIcon:e.jsx(B.DeleteForever,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"error.main",color:"error.contrastText",px:3,py:.875,minHeight:36,borderRadius:s=>`${s.shape.borderRadius}px`,boxShadow:s=>te(s,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"error.dark",boxShadow:s=>te(s,"hoverButton")},"&:active":{boxShadow:s=>te(s,"pressedButton"),transform:"translateY(1px)"}},children:"Delete record"})]})]})}function Ko(t){const o={fontSize:11};switch(t){case"number":return e.jsx(B.Numbers,{sx:o});case"boolean":return e.jsx(B.CheckBox,{sx:o});case"array":return e.jsx(B.DataArray,{sx:o});case"object":return e.jsx(B.DataObject,{sx:o});default:return e.jsx(B.TextFields,{sx:o})}}function di(t,o){var n,i;switch(t){case"number":return{bg:k(o.primary.main,.08),color:o.primary.main};case"boolean":return{bg:k(((n=o.success)==null?void 0:n.main)??"#2e7d32",.08),color:((i=o.success)==null?void 0:i.main)??"#2e7d32"};case"array":case"object":return{bg:k(o.secondary.main,.08),color:o.secondary.main};default:return{bg:k(o.text.secondary,.07),color:o.text.secondary}}}function Pd({open:t,onClose:o,onSave:n,row:i,schema:s,reportName:d}){var j,w,I;const c=zt(),l=c.palette,[u,f]=p.useState({});if(p.useEffect(()=>{t&&i&&f({...i})},[t,i]),!i)return null;const m=s.filter(v=>v.name in i),h=m.filter(v=>v.type!=="object"&&v.type!=="array"),x=m.filter(v=>v.type==="object"||v.type==="array"),b=(v,S)=>{f(C=>({...C,[v]:S}))},D=()=>{const v={...u};m.forEach(S=>{const C=u[S.name];if(S.type==="number"){const a=Number(C);v[S.name]=isNaN(a)?i[S.name]:a}else S.type==="boolean"&&(v[S.name]=!!C)}),n(v),o()},g=m.length;return e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:Me(c),maxHeight:"min(760px, calc(100vh - 80px))",display:"flex",flexDirection:"column",boxShadow:`0 8px 32px ${k(((j=l.common)==null?void 0:j.black)??"#000",.14)}, 0 2px 8px ${k(((w=l.common)==null?void 0:w.black)??"#000",.08)}`,overflow:"hidden"}},children:[e.jsxs(r.Box,{sx:{px:3,pt:2.5,pb:2,bgcolor:"background.paper",display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,minWidth:0},children:[e.jsx(r.Box,{sx:{width:36,height:36,borderRadius:"10px",bgcolor:k(((I=l.warning)==null?void 0:I.main)??"#ed6c02",.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(B.EditOutlined,{sx:{fontSize:18,color:"warning.main"}})}),e.jsxs(r.Box,{sx:{minWidth:0},children:[e.jsx(r.Typography,{sx:{fontSize:"1rem",fontWeight:600,color:"text.primary",lineHeight:1.3},children:"Edit Record"}),d&&e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary",display:"block",mt:.25,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[d," · ",g," ",g===1?"field":"fields"]})]})]}),e.jsx(r.IconButton,{size:"small",onClick:o,sx:{mt:.25,color:"text.secondary",borderRadius:"8px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(B.Close,{sx:{fontSize:18}})})]}),e.jsx(r.Divider,{}),e.jsxs(r.DialogContent,{sx:{p:2.5,overflowY:"auto",flex:1,bgcolor:k(l.text.primary,.015),display:"flex",flexDirection:"column",gap:2},children:[h.length>0&&e.jsxs(r.Box,{children:[h.length>1&&e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:700,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.08em",mb:1.25},children:"Fields"}),e.jsx(r.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:1.5},children:h.map((v,S)=>{const C=u[v.name],a=di(v.type,l),z=v.type==="boolean",R=!z&&S===h.filter(K=>K.type!=="boolean").length-1&&h.filter(K=>K.type!=="boolean").length%2!==0,q=z||R;return v.type==="boolean"?e.jsxs(r.Box,{sx:{gridColumn:"span 2",bgcolor:"background.paper",border:"1px solid",borderColor:"divider",borderRadius:"10px",px:2,py:1.5,display:"flex",alignItems:"center",justifyContent:"space-between",gap:2,transition:"border-color 0.15s","&:hover":{borderColor:"primary.main"}},children:[e.jsxs(r.Box,{children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:.25},children:[e.jsx(r.Box,{sx:{display:"flex",alignItems:"center",px:.75,py:.25,borderRadius:"4px",bgcolor:a.bg,color:a.color},children:Ko(v.type)}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.06em"},children:Ke(v.name)})]}),e.jsx(r.Typography,{sx:{fontSize:"0.8125rem",color:"text.secondary",ml:.25},children:C?"Enabled":"Disabled"})]}),e.jsx(r.Switch,{checked:!!C,onChange:K=>b(v.name,K.target.checked),size:"small",sx:{"& .MuiSwitch-switchBase.Mui-checked":{color:"primary.main"},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{bgcolor:"primary.main"}}})]},v.name):e.jsxs(r.Box,{sx:{gridColumn:q?"span 2":"span 1",bgcolor:"background.paper",border:"1px solid",borderColor:"divider",borderRadius:"10px",overflow:"hidden",transition:"border-color 0.15s","&:focus-within":{borderColor:"primary.main",boxShadow:`0 0 0 2px ${k(l.primary.main,.12)}`}},children:[e.jsxs(r.Box,{sx:{px:1.5,py:.875,borderBottom:"1px solid",borderColor:"divider",bgcolor:k(l.text.primary,.02),display:"flex",alignItems:"center",gap:.75},children:[e.jsx(r.Box,{sx:{display:"flex",alignItems:"center",px:.75,py:.25,borderRadius:"4px",bgcolor:a.bg,color:a.color},children:Ko(v.type)}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.06em",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Ke(v.name)})]}),e.jsx(r.TextField,{value:C??"",onChange:K=>b(v.name,K.target.value),type:v.type==="number"?"number":"text",size:"small",fullWidth:!0,variant:"standard",placeholder:`Enter ${v.type==="number"?"number":"value"}…`,InputProps:{disableUnderline:!0},sx:{"& .MuiInputBase-root":{px:1.5,py:1,fontSize:"0.875rem",fontWeight:500,color:"text.primary",fontFamily:v.type==="number"?'"Roboto Mono", monospace':"inherit"},"& .MuiInputBase-input":{p:0,"&::placeholder":{color:"text.disabled",opacity:1,fontWeight:400}}}})]},v.name)})})]}),x.length>0&&e.jsxs(r.Box,{children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:1.25},children:[e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:700,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.08em"},children:"Read-only Fields"}),e.jsx(r.Tooltip,{title:"Object and array fields cannot be edited directly",arrow:!0,children:e.jsx(B.InfoOutlined,{sx:{fontSize:13,color:"text.disabled",cursor:"help"}})})]}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1.5},children:x.map(v=>{const S=i[v.name];let C="";try{C=S==null?"":JSON.stringify(S,null,2)}catch{C=String(S)}const a=di(v.type,l);return e.jsxs(r.Box,{sx:{bgcolor:"background.paper",border:"1px solid",borderColor:"divider",borderRadius:"10px",overflow:"hidden",opacity:.8},children:[e.jsxs(r.Box,{sx:{px:1.5,py:.875,borderBottom:"1px solid",borderColor:"divider",bgcolor:k(l.text.primary,.02),display:"flex",alignItems:"center",gap:.75},children:[e.jsx(r.Box,{sx:{display:"flex",alignItems:"center",px:.75,py:.25,borderRadius:"4px",bgcolor:a.bg,color:a.color},children:Ko(v.type)}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.06em",flex:1},children:Ke(v.name)}),e.jsx(r.Chip,{label:"read only",size:"small",sx:{height:16,fontSize:"0.5625rem",fontWeight:600,letterSpacing:"0.04em",bgcolor:k(l.text.secondary,.07),color:"text.secondary",border:"none"}})]}),e.jsx(r.Box,{component:"pre",sx:{m:0,px:1.5,py:1.25,fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:C?"text.primary":"text.disabled",fontStyle:C?"normal":"italic",bgcolor:k(l.text.primary,.015),overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6,maxHeight:120,overflowY:"auto"},children:C||"No value"})]},v.name)})})]}),m.length===0&&e.jsxs(r.Box,{sx:{py:6,display:"flex",flexDirection:"column",alignItems:"center",gap:1,color:"text.disabled"},children:[e.jsx(B.EditOutlined,{sx:{fontSize:40,opacity:.4}}),e.jsx(r.Typography,{variant:"body2",children:"No editable fields"})]})]}),e.jsx(r.Divider,{}),e.jsxs(r.DialogActions,{sx:{px:3,py:1.75,bgcolor:"background.paper",gap:1,justifyContent:"flex-end"},children:[e.jsx(r.Button,{onClick:o,variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",px:2,borderRadius:v=>`${v.shape.borderRadius}px`,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:D,variant:"contained",startIcon:e.jsx(B.SaveOutlined,{sx:{fontSize:15}}),sx:{fontSize:"0.8125rem",px:2.5,borderRadius:v=>`${v.shape.borderRadius}px`,minWidth:90},children:"Save"})]})]})}const Nd=176,Ld=170,Fd=40;function Qi(t){return t.type==="date"?180:Nd}function Vd(t,o){return o!=null&&o!==Ld&&o!==Qi(t)}function Hd(t,o,n){return p.useMemo(()=>{const i=t.map(h=>({name:h.name,width:o[h.name]??Qi(h),explicit:Vd(h,o[h.name])})),s={};i.forEach(h=>{s[h.name]=h.width});const d=i.reduce((h,x)=>h+x.width,0),l=Math.max(0,n-Fd)-d;if(l<=0)return{widths:s,fillerWidth:0};const u=i.filter(h=>!h.explicit);if(u.length===0)return{widths:s,fillerWidth:l};const f=u.reduce((h,x)=>h+x.width,0)||1;let m=0;return u.forEach((h,x)=>{const D=x===u.length-1?h.width+l-m:Math.round(h.width+l*h.width/f);s[h.name]=D,m+=D-h.width}),{widths:s,fillerWidth:0}},[t,o,n])}const ui=176,Ud={low:"text.secondary",medium:"warning.dark",high:"warning.main",critical:"error.main",urgent:"error.main"};function Yd(t){const o=t.toLowerCase().trim();return e.jsx(r.Box,{component:"span",sx:{display:"inline-flex",alignItems:"center",px:1.25,py:.375,borderRadius:"12px",fontSize:"0.75rem",fontWeight:500,bgcolor:n=>bo(n,o).bg,color:n=>bo(n,o).color,whiteSpace:"nowrap",lineHeight:1.6,letterSpacing:"0.01em"},children:t})}function Gd(t){const o=t.toLowerCase().trim(),n=Ud[o];return n?e.jsx(r.Box,{component:"span",sx:{color:n,fontWeight:500,fontSize:"inherit"},children:t}):t}function qd(t,o){const n=o.trim();if(!n)return t;const i=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=t.split(new RegExp(`(${i})`,"gi"));return s.length===1?t:s.map((d,c)=>d.toLowerCase()===n.toLowerCase()?e.jsx(r.Box,{component:"mark",sx:{bgcolor:"warning.light",color:"inherit",px:"1px",borderRadius:"2px"},children:d},c):d)}function Jd(t,o,n,i=""){if(o==null||o==="")return e.jsx(r.Box,{component:"span",sx:{color:"text.disabled"},children:"—"});const s=String(o);if(/\b(status|state|stage|employmenttype|contracttype|availability)\b/.test(t.name.toLowerCase()))return Yd(s);if(/\b(priority|severity|urgency|importance|criticality)\b/.test(t.name.toLowerCase()))return Gd(s);if(t.type==="date"){const l=t.dateFormat??"iso",u=qs(o,l,n??null);return e.jsx(r.Box,{component:"span",sx:{color:"text.primary",whiteSpace:"nowrap"},children:u})}if(t.type==="number"&&typeof o=="number")return o.toLocaleString();if(typeof o=="boolean")return o?"Yes":"No";if(Array.isArray(o)){if(o.length===0)return e.jsx(r.Box,{component:"span",sx:{color:"text.disabled"},children:"[ ]"});const l=o.slice(0,3).map(u=>typeof u=="object"?JSON.stringify(u):String(u)).join(", ");return e.jsxs(r.Box,{component:"span",sx:{color:"text.secondary",fontSize:"0.8125rem"},children:[l,o.length>3?` +${o.length-3} more`:""]})}if(typeof o=="object"){const l=JSON.stringify(o);return e.jsx(r.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 qd(s,i)}function Kd({schema:t,data:o,sortStack:n=[],filters:i=[],views:s=[],activeViewId:d="",isDirty:c=!1,isExporting:l=!1,columnVisibility:u={},columnOrder:f=[],columnWidths:m={},grouping:h=null,onSort:x,onSortAscending:b,onSortDescending:D,onOpenFilters:g,onOpenSort:j,onOpenFilterForColumn:w,onSelectView:I,onCreateView:v,onManageViews:S,onUpdateCurrentView:C,onSaveAsNewView:a,onToggleDefault:z,onToggleFavorite:R,onRestoreView:q,onPermanentDelete:K,isAdmin:ee=!1,onExport:y,onOpenColumns:M,onUpdateColumnWidth:W,onUpdateColumnOrder:V,onUpdateColumnVisibility:Q,onClearFiltersForColumn:xe,onResetLayout:de,onOpenGroup:L,onGroupByColumn:A,onToggleGroupCollapse:H,onOpenAuditHistory:ie,onOpenScheduledReports:Y,searchQuery:re,highlightQuery:se="",searchHistory:oe=[],onAddToSearchHistory:P,onToggleSearchFavourite:ne,onDeleteSearchHistory:ce,selectedRowIds:ae=new Set,onSearchChange:fe,onToggleRowSelection:G,onToggleAllRows:Ae,onRangeSelection:Qe,onClearSelection:Ze,onExportSelected:Bt,currentPage:ar=1,pageSize:It=15,totalRowsBeforePagination:Dt=o.length,onPageChange:Et,onPageSizeChange:lt,isReadOnly:Ve=!1,userRole:Vt,reportName:et,onEditRow:Ue,onDuplicateRow:He,onDeleteRow:nt,showDevPanel:Ir=!1,onOpenDevConfig:lr}){var eo;const[Ht,cr]=p.useState(null),[Ut,Dr]=p.useState(0),[Yt,ft]=p.useState(0),[it,dr]=p.useState(null),ur=((eo=nr().dates)==null?void 0:eo.displayFormat)??null,[qt,Er]=p.useState(null),[tt,Ot]=p.useState(null),[ke,At]=p.useState(null),[Or,Ye]=p.useState(!1),[F,Ge]=p.useState(!1),[be,Pe]=p.useState(null),[Ar,gt]=p.useState(""),[$r,yt]=p.useState(!1),[Jt,Kt]=p.useState(null),[pr,Te]=p.useState(null),[U,_e]=p.useState(null),[we,ct]=p.useState(null),[Le,xr]=p.useState("list"),[mr,hr]=p.useState(!1),[bt,Mr]=p.useState(()=>!Md("toolbar_search")),vt=p.useRef(null),Xt=p.useRef(null),[St,st]=p.useState(0);p.useLayoutEffect(()=>{const E=vt.current;if(!E)return;st(E.clientWidth);const J=new ResizeObserver(ue=>{st(ue[0].contentRect.width)});return J.observe(E),()=>J.disconnect()},[]);const jt=p.useCallback(()=>{Rd("toolbar_search"),Mr(!1)},[]);p.useEffect(()=>{if(!bt)return;const E=setTimeout(jt,2e3);return()=>clearTimeout(E)},[bt,jt]);const fr=p.useMemo(()=>{const E=it??f;return E.length>0?E.map(J=>t.find(ue=>ue.name===J)).filter(J=>J!==void 0):t},[it,f,t]),Fe=p.useMemo(()=>fr.filter(E=>u[E.name]!==!1),[fr,u]),{widths:$t,fillerWidth:Mt}=Hd(Fe,m,St),dt=p.useMemo(()=>t.filter(E=>u[E.name]===!1).length,[t,u]),at=p.useMemo(()=>t.map(E=>E.name),[t]),Rt=p.useMemo(()=>f.length===0?!1:JSON.stringify(f)!==JSON.stringify(at),[f,at]),Rr=p.useCallback((E,J)=>{E.preventDefault(),E.stopPropagation(),cr(J),Dr(E.clientX),ft(m[J]||150)},[m]);p.useEffect(()=>{if(!Ht)return;const E=ue=>{const Ne=ue.clientX-Ut,pe=Math.max(100,Math.min(600,Yt+Ne));W==null||W(Ht,pe)},J=()=>{cr(null)};return document.addEventListener("mousemove",E),document.addEventListener("mouseup",J),()=>{document.removeEventListener("mousemove",E),document.removeEventListener("mouseup",J)}},[Ht,Ut,Yt,W]);const Qt=p.useCallback(E=>E==null?"-":typeof E=="object"?JSON.stringify(E):typeof E=="boolean"?E?"true":"false":String(E),[]);p.useCallback(E=>{const J=n.find(ue=>ue.column===E);return J?e.jsxs(r.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[J.direction==="asc"?e.jsx(B.ArrowUpward,{sx:{fontSize:14}}):e.jsx(B.ArrowDownward,{sx:{fontSize:14}}),e.jsx(r.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:J.priority})]}):null},[n]),p.useCallback(E=>i.some(ue=>ue.column===E)?e.jsx(r.IconButton,{size:"small",onClick:ue=>{ue.stopPropagation(),w==null||w(E)},sx:{ml:.5,p:.25,color:"primary.main","&:hover":{color:"primary.main"}},title:"Active filters on this column",children:e.jsx(B.FilterList,{sx:{fontSize:14}})}):null,[i,w]);const gr=p.useCallback(E=>{x&&x(E)},[x]),yr=p.useCallback((E,J)=>{dr(ue=>{const pe=[...ue??(f.length>0?f:t.map(Wo=>Wo.name))],[Zt]=pe.splice(E,1);return pe.splice(J,0,Zt),pe})},[f,t]),br=p.useCallback(()=>{it&&V&&V(it),dr(null)},[it,V]),vr=p.useCallback(E=>{if(!x)return;const J=n.find(ue=>ue.column===E);(!J||J.direction!=="asc")&&x(E)},[x,n]),Sr=p.useCallback(E=>{if(!x)return;const J=n.find(ue=>ue.column===E);J?J.direction==="asc"&&x(E):(x(E),setTimeout(()=>x(E),0))},[x,n]),le=p.useCallback(E=>{if(!x)return;const J=n.find(ue=>ue.column===E);J&&(J.direction==="asc"?(x(E),setTimeout(()=>x(E),0)):J.direction==="desc"&&x(E))},[x,n]),he=p.useCallback(E=>{Q&&Q(E,!1)},[Q]),$e=(h==null?void 0:h.enabled)&&o.length>0&&o[0]&&"isGroupHeader"in o[0],_t=n.length>0||i.length>0||((h==null?void 0:h.enabled)??!1)||Object.values(u).some(E=>E===!1),Wt=(ar-1)*It,We=o,Pt=p.useMemo(()=>{const E=new Set;return ae.forEach(J=>{const ue=J==null?void 0:J.__urm_row_id__;ue!==void 0&&E.add(ue)}),E},[ae]);p.useEffect(()=>{const E=J=>{!Ae||!Ze||J.target instanceof HTMLInputElement||J.target instanceof HTMLTextAreaElement||((J.ctrlKey||J.metaKey)&&J.key==="a"&&(J.preventDefault(),Ae(!0,We)),J.key==="Escape"&&(J.preventDefault(),Ze()))};return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[Ae,Ze,We]);const Qr=p.useCallback((E,J)=>{G&&(J.shiftKey&&qt!==null?(J.preventDefault(),Qe&&Qe(qt,E,We)):(G(We[E]),Er(E)))},[G,qt,Qe,We]);!p.useMemo(()=>We.length>0&&Pt.size>0&&We.every(E=>Pt.has(E==null?void 0:E.__urm_row_id__)),[We,Pt])&&We.some(E=>Pt.has(E==null?void 0:E.__urm_row_id__));const jr=G&&Ae,_o=p.useCallback(E=>{var Ne;const J=E.groupLevel,ue=J*24;return e.jsx(r.TableRow,{onClick:()=>H==null?void 0:H(E.groupKey),sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"},cursor:"pointer",borderTop:2,borderColor:"divider"},children:e.jsx(r.TableCell,{colSpan:Fe.length+(jr?1:0),sx:{pl:`${ue+24}px`},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[E.isCollapsed?e.jsx(B.ChevronRight,{sx:{fontSize:16}}):e.jsx(B.KeyboardArrowDown,{sx:{fontSize:16}}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600},children:ki(J,((Ne=h==null?void 0:h.levels[J])==null?void 0:Ne.column)||"",E.groupValue)}),e.jsxs(r.Box,{sx:{px:1,py:.25,fontSize:"caption.fontSize",fontWeight:500,bgcolor:pe=>k(pe.palette.primary.main,.12),color:"primary.main",borderRadius:2},children:[E.rowCount," ",E.rowCount===1?"row":"rows"]}),Object.keys(E.aggregates).length>0&&e.jsx(r.Typography,{variant:"caption",sx:{ml:1,color:"text.secondary"},children:Object.entries(E.aggregates).map(([pe,Zt])=>wi(Zt)).filter(Boolean).join(" • ")})]})})},E.groupKey)},[Fe,jr,h,H]),Zr=p.useCallback((E,J)=>{const ue=Pt.has(E==null?void 0:E.__urm_row_id__),Ne=tt===J;return e.jsxs(r.TableRow,{"data-row-index":J,onMouseEnter:()=>Ot(J),onMouseLeave:()=>Ot(null),onClick:pe=>{!G||pe.target.closest("[data-row-action-btn]")||Qr(J,pe)},onContextMenu:pe=>{pe.preventDefault(),pe.stopPropagation(),_e({mouseX:pe.clientX,mouseY:pe.clientY,row:E,rowIndex:J})},sx:{height:34,cursor:"pointer",bgcolor:ue?pe=>k(pe.palette.warning.main,.12):"background.paper",transition:"background-color 0.12s ease","&:hover":{bgcolor:ue?pe=>k(pe.palette.warning.main,.2):"action.hover"},borderBottom:"1px solid",borderColor:"divider"},children:[Fe.map(pe=>e.jsx(r.TableCell,{sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",py:"6px",px:2,textAlign:"left",fontSize:"0.8125rem",fontWeight:400,color:"text.primary",borderBottom:"1px solid",borderColor:"divider",minWidth:m[pe.name]?`${m[pe.name]}px`:`${pe.type==="date"?Math.max(ui,180):ui}px`},children:Jd(pe,E[pe.name],ur,se)},pe.name)),e.jsx(r.TableCell,{sx:{p:0,border:"none",borderBottom:"1px solid",borderColor:"divider"}}),e.jsx(r.TableCell,{"data-row-action":"true",sx:{position:"sticky",right:0,width:40,minWidth:40,maxWidth:40,p:0,border:"none",borderBottom:"1px solid",borderColor:"divider",background:Ne?pe=>`linear-gradient(to right, transparent, ${ue?k(pe.palette.warning.main,.12):pe.palette.background.paper} 32px)`:"transparent",opacity:Ne?1:0,transition:"opacity 0.12s ease, background 0.12s ease",zIndex:10,verticalAlign:"middle"},children:e.jsx(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",height:"100%",px:1,gap:.25},children:e.jsx(r.IconButton,{"data-row-action-btn":"true",size:"small",onClick:pe=>{pe.stopPropagation(),pe.preventDefault(),_e({anchorEl:pe.currentTarget,row:E,rowIndex:J})},sx:{color:"text.secondary",opacity:Ne?1:0,transition:"opacity 0.12s ease",pointerEvents:Ne?"auto":"none","&:hover":{bgcolor:pe=>k(pe.palette.text.primary,.08),color:"text.primary"}},children:e.jsx(B.MoreVert,{sx:{fontSize:18}})})})})]},J)},[ae,Wt,tt,Qr,Fe,m,se,Qt,Ue,He,nt,G,At,Ye,_e]);return e.jsxs(kt.DndProvider,{backend:tn.HTML5Backend,children:[e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:[jr&&Bt&&Ze&&e.jsx(Sd,{selectedCount:Pt.size,viewMode:Le,onExportSelected:Bt,onClearSelection:Ze}),e.jsxs(r.Box,{sx:{position:"sticky",top:0,zIndex:10,bgcolor:"background.paper",borderBottom:"1px solid",borderColor:"divider",px:2,py:0,height:56,display:"flex",alignItems:"center",gap:1},children:[Ve&&e.jsx($d,{}),fe&&P&&ne&&ce&&e.jsx(r.Tooltip,{open:bt,title:e.jsxs(r.Box,{sx:{p:.5},children:[e.jsx(r.Typography,{variant:"caption",sx:{display:"block",fontWeight:500,mb:.25},children:"💡 Search tip"}),e.jsx(r.Typography,{variant:"caption",children:"Type to search across all columns instantly"})]}),placement:"bottom-start",arrow:!0,PopperProps:{onClick:jt},componentsProps:{tooltip:{sx:{bgcolor:"primary.main","& .MuiTooltip-arrow":{color:"primary.main"},maxWidth:220,cursor:"pointer",userSelect:"none"}}},children:e.jsx(r.Box,{component:"span",children:e.jsx(fd,{value:re||"",onChange:E=>{bt&&jt(),fe(E)},searchHistory:oe,onAddToHistory:P,onToggleFavourite:ne,onDeleteHistory:ce,disabled:Ve})})}),e.jsx(r.Tooltip,{title:"JSON format guide",children:e.jsx(r.IconButton,{size:"small",onClick:()=>hr(!0),sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:E=>k(E.palette.text.primary,.06),color:"text.primary"}},children:e.jsx(B.InfoOutlined,{sx:{fontSize:20}})})}),I&&v&&S&&C&&s.length>0&&e.jsx(gd,{views:s||[],activeViewId:d||"",isDirty:c,onSelectView:I,onCreateView:v,onManageViews:S,onToggleDefault:z,onToggleFavorite:R,onRestoreView:q,onPermanentDelete:K,isAdmin:ee,isReadOnly:Ve}),Ir&&lr&&e.jsx(r.Tooltip,{title:"Developer configuration",children:e.jsx(r.IconButton,{size:"small",onClick:lr,sx:{color:"text.secondary",borderRadius:1,border:"1px dashed",borderColor:E=>k(E.palette.text.secondary,.3),"&:hover":{bgcolor:E=>k(E.palette.warning.main,.08),borderColor:"warning.main",color:"warning.dark"}},children:e.jsx(B.DisplaySettings,{sx:{fontSize:20}})})}),e.jsx(r.Box,{sx:{flexGrow:1}}),!Ve&&j&&e.jsx(r.Tooltip,{title:"Sort",children:e.jsxs(r.IconButton,{onClick:j,size:"small",sx:{position:"relative",color:n.length>0?"primary.main":"text.secondary",bgcolor:n.length>0?E=>Re(E):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:n.length>0?E=>k(E.palette.primary.main,.2):E=>k(E.palette.text.primary,.06),color:n.length>0?"primary.main":"text.primary"}},children:[e.jsx(B.SwapVert,{sx:{fontSize:20}}),n.length>0&&e.jsx(r.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})]})}),!Ve&&g&&e.jsx(r.Tooltip,{title:"Filter",children:e.jsxs(r.IconButton,{onClick:g,size:"small",sx:{position:"relative",color:i.length>0?"primary.main":"text.secondary",bgcolor:i.length>0?E=>Re(E):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:i.length>0?E=>k(E.palette.primary.main,.2):E=>k(E.palette.text.primary,.06),color:i.length>0?"primary.main":"text.primary"}},children:[e.jsx(B.FilterList,{sx:{fontSize:20}}),i.length>0&&e.jsx(r.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:i.length})]})}),!Ve&&M&&e.jsx(r.Tooltip,{title:"Show/Hide Columns",children:e.jsxs(r.IconButton,{onClick:M,size:"small",sx:{position:"relative",color:dt>0||Rt?"primary.main":"text.secondary",bgcolor:dt>0||Rt?E=>Re(E):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:dt>0||Rt?E=>k(E.palette.primary.main,.2):E=>k(E.palette.text.primary,.06),color:dt>0||Rt?"primary.main":"text.primary"}},children:[e.jsx(B.ViewColumn,{sx:{fontSize:20}}),dt>0&&e.jsx(r.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:dt})]})}),e.jsx(r.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5,my:1.5}}),e.jsx(r.Tooltip,{title:"List view",children:e.jsx(r.IconButton,{size:"small",onClick:()=>xr("list"),sx:{borderRadius:1,color:Le==="list"?"primary.main":"text.secondary",bgcolor:Le==="list"?E=>Re(E):"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:Le==="list"?E=>k(E.palette.primary.main,.2):E=>k(E.palette.text.primary,.06),color:Le==="list"?"primary.main":"text.primary"}},children:e.jsx(B.TableRows,{sx:{fontSize:20}})})}),e.jsx(r.Tooltip,{title:"Grid view",children:e.jsx(r.IconButton,{size:"small",onClick:()=>xr("grid"),sx:{borderRadius:1,color:Le==="grid"?"primary.main":"text.secondary",bgcolor:Le==="grid"?E=>Re(E):"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:Le==="grid"?E=>k(E.palette.primary.main,.2):E=>k(E.palette.text.primary,.06),color:Le==="grid"?"primary.main":"text.primary"}},children:e.jsx(B.GridView,{sx:{fontSize:20}})})}),e.jsx(r.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5,my:1.5}}),e.jsx(r.Tooltip,{title:"Settings",children:e.jsx(r.IconButton,{onClick:E=>ct(E.currentTarget),size:"small",sx:{color:"text.secondary",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:E=>k(E.palette.text.primary,.06),color:"text.primary"}},children:e.jsx(B.Settings,{sx:{fontSize:20}})})})]}),e.jsxs(r.Popover,{open:!!we,anchorEl:we,onClose:()=>ct(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:[y&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{y(),ct(null)},disabled:l,sx:{py:1,px:2,gap:1.5},children:[e.jsx(B.Download,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Export"})]}),!Ve&&L&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{L(),ct(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(B.Layers,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Grouping"})]}),ie&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{ie(),ct(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(B.History,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Audit History"})]}),Y&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{Y(),ct(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(B.Schedule,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Scheduled Reports"})]})]}),e.jsxs(r.Box,{sx:{position:"relative",flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[Le==="grid"&&e.jsx(r.Box,{sx:{flex:1,overflowY:"auto",overflowX:"hidden",bgcolor:"action.hover"},children:e.jsx(Ed,{data:We,visibleColumns:Fe,grouping:h,selectedRowIds:ae,isReadOnly:Ve,isGrouped:!!$e,sortStack:n,onSort:x,onToggleRowSelection:G||(()=>{}),onToggleGroupCollapse:H,onViewRow:E=>{At(E),Ye(!0)},onEditRow:(E,J)=>{Kt(E),Te(J),yt(!0)},onDuplicateRow:(E,J)=>He==null?void 0:He(E,J),onDeleteRow:(E,J)=>{Pe(J);const ue=Object.values(J).find(Ne=>Ne!=null&&Ne!=="");gt(ue?String(ue):""),Ge(!0)}})}),Le==="list"&&e.jsxs(r.Box,{sx:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[e.jsx(r.Box,{ref:vt,onScroll:E=>{Xt.current&&(Xt.current.scrollLeft=E.target.scrollLeft)},sx:{overflowX:"auto",overflowY:"hidden",flexShrink:0,scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:e.jsxs(r.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",borderSpacing:0,width:"100%",minWidth:`${Object.values($t).reduce((E,J)=>E+J,0)+Mt+40}px`},children:[e.jsxs("colgroup",{children:[Fe.map(E=>e.jsx("col",{style:{width:`${$t[E.name]}px`}},E.name)),e.jsx("col",{style:{width:`${Mt}px`}}),e.jsx("col",{style:{width:"40px"}})]}),e.jsx(r.TableHead,{children:e.jsxs(r.TableRow,{sx:{height:34,bgcolor:"action.hover",borderBottom:"1px solid",borderColor:"divider"},children:[Fe.map((E,J)=>e.jsx(vd,{column:E,index:J,sortRule:n.find(ue=>ue.column===E.name),hasFilters:i.some(ue=>ue.column===E.name),isInSortStack:n.some(ue=>ue.column===E.name),isReadOnly:Ve,hasModifications:_t,width:m[E.name],onColumnClick:gr,onMoveColumn:yr,onColumnDragEnd:br,onResizeStart:Rr,onSortAscending:b||vr,onSortDescending:D||Sr,onRemoveSort:le,onOpenFilterForColumn:w||(()=>{}),onClearFiltersForColumn:xe||(()=>{}),onGroupByColumn:A,onHideColumn:he,onManageColumns:M||(()=>{}),onManageViews:S,onResetLayout:de},E.name)),e.jsx(r.TableCell,{sx:{p:0,border:"none",borderBottom:"1px solid",borderColor:"divider",bgcolor:"action.hover"}}),e.jsx(r.TableCell,{sx:{width:40,minWidth:40,p:0,border:"none",borderBottom:"1px solid",borderColor:"divider",bgcolor:"action.hover"}})]})})]})}),e.jsx(r.Box,{ref:Xt,onScroll:E=>{vt.current&&(vt.current.scrollLeft=E.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:E=>E.palette.mode==="dark"?"rgba(255,255,255,0.2)":"rgba(0,0,0,0.2)",borderRadius:4,"&:hover":{bgcolor:E=>E.palette.mode==="dark"?"rgba(255,255,255,0.3)":"rgba(0,0,0,0.3)"}}},children:e.jsxs(r.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",borderSpacing:0,width:"100%",minWidth:`${Object.values($t).reduce((E,J)=>E+J,0)+Mt+40}px`},children:[e.jsxs("colgroup",{children:[Fe.map(E=>e.jsx("col",{style:{width:`${$t[E.name]}px`}},E.name)),e.jsx("col",{style:{width:`${Mt}px`}}),e.jsx("col",{style:{width:"40px"}})]}),e.jsx(r.TableBody,{children:We.length===0?e.jsx(r.TableRow,{children:e.jsx(r.TableCell,{colSpan:Fe.length+(jr?1:0),align:"center",sx:{py:4},children:e.jsx(r.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})})}):$e?We.map((E,J)=>E.isGroupHeader?_o(E):Zr(E,J)):We.map((E,J)=>Zr(E,J))})]})})]}),Et&&lt&&e.jsx(Ad,{currentPage:ar,pageSize:It,totalRows:Dt,totalFields:t.length,onPageChange:Et,onPageSizeChange:lt}),!(Et&&lt)&&e.jsx(r.Box,{sx:{px:3,py:1.5,bgcolor:"action.hover",borderTop:1,borderColor:"divider"},children:e.jsxs(r.Typography,{variant:"body2",color:"text.secondary",children:["Showing ",We.length," ",We.length===1?"row":"rows"]})})]})]}),e.jsxs(r.Popover,{open:!!U,onClose:()=>_e(null),anchorEl:(U==null?void 0:U.anchorEl)||null,anchorReference:U!=null&&U.anchorEl?"anchorEl":"anchorPosition",anchorPosition:U&&!U.anchorEl?{top:U.mouseY,left:U.mouseX}:void 0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:U!=null&&U.anchorEl?{vertical:"top",horizontal:"right"}:{vertical:"top",horizontal:"left"},PaperProps:{sx:{minWidth:176,py:.5,borderRadius:1.5,boxShadow:3}},children:[e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{U&&(At(U.row),Ye(!0)),_e(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(B.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"View"})]}),e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{U&&(Kt(U.row),Te(U.rowIndex),yt(!0)),_e(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(B.Edit,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Edit"})]}),e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{U&&(He==null||He(U.rowIndex,U.row)),_e(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(B.ContentCopy,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Duplicate"})]}),e.jsx(r.Divider,{sx:{my:.5}}),e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{if(U){Pe(U.row);const E=Object.values(U.row).find(J=>J!=null&&J!=="");gt(E?String(E):""),Ge(!0)}_e(null)},sx:{py:1,px:2,gap:1.5,color:"error.main"},children:[e.jsx(B.Delete,{sx:{fontSize:18,color:"error.main"}}),e.jsx(r.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]}),e.jsx(_d,{open:Or,onClose:()=>{Ye(!1),At(null)},row:ke,schema:t,reportName:et}),e.jsx(Pd,{open:$r,onClose:()=>{yt(!1),Kt(null),Te(null)},onSave:E=>{pr!==null&&(Ue==null||Ue(pr,E))},row:Jt,schema:t,reportName:et}),e.jsx(Wd,{open:F,onClose:()=>{Ge(!1),Pe(null)},onConfirm:()=>{be!==null&&(nt==null||nt(be))},rowPreview:Ar}),e.jsx(Ji,{isOpen:mr,onClose:()=>hr(!1)})]})}function ir({content:t,isDev:o=!1}){const[n,i]=p.useState(null);return e.jsxs(e.Fragment,{children:[e.jsx(r.IconButton,{size:"small",onClick:s=>i(s.currentTarget),"aria-label":`Help: ${t.title}`,sx:{p:.375,color:"text.disabled","&:hover":{color:"primary.main",bgcolor:s=>k(s.palette.primary.main,.08)}},children:e.jsx(B.InfoOutlined,{sx:{fontSize:15}})}),e.jsxs(r.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:[e.jsx(r.Box,{sx:{px:2,py:1.5,bgcolor:s=>k(s.palette.primary.main,.06)},children:e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600,color:"primary.main",fontSize:"0.875rem"},children:t.title})}),e.jsx(r.Divider,{}),e.jsxs(r.Box,{sx:{px:2,py:1.5,display:"flex",flexDirection:"column",gap:1},children:[e.jsx(r.Typography,{variant:"body2",sx:{color:"text.secondary",fontSize:"0.8125rem",lineHeight:1.6},children:t.description}),t.tips&&t.tips.length>0&&e.jsx(r.Box,{component:"ul",sx:{m:0,pl:2,display:"flex",flexDirection:"column",gap:.5},children:t.tips.map((s,d)=>e.jsx(r.Box,{component:"li",sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.5},children:s},d))}),o&&t.devNote&&e.jsxs(e.Fragment,{children:[e.jsx(r.Divider,{sx:{my:.5}}),e.jsxs(r.Box,{sx:{px:1.25,py:.75,borderRadius:"6px",bgcolor:s=>k(s.palette.warning.main,.08),border:"1px solid",borderColor:s=>k(s.palette.warning.main,.2)},children:[e.jsx(r.Typography,{variant:"caption",sx:{color:"warning.dark",fontWeight:500,display:"block",mb:.25},children:"Dev note"}),e.jsx(r.Typography,{variant:"caption",sx:{color:"warning.dark",lineHeight:1.5},children:t.devNote})]})]})]})]})]})}const sr={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."}};function Xd({schema:t,filters:o,onAddFilter:n,onRemoveFilter:i,onUpdateFilter:s,onClearAll:d,onReplaceFilters:c,onClose:l,focusColumn:u}){const[f,m]=p.useState(""),[h,x]=p.useState(""),[b,D]=p.useState(""),[g,j]=p.useState([]),w=nr();p.useEffect(()=>{j([...o])},[o]),p.useEffect(()=>{u&&m(u)},[u]);const I=p.useCallback(()=>{m(""),x(""),D("")},[]),v=p.useMemo(()=>t.filter(M=>M.type!=="mixed"&&M.type!=="null"&&M.type!=="array"&&M.type!=="object"),[t]),S=t.find(M=>M.name===f),C=p.useMemo(()=>{const M=S?Dn(S.type):[],W=w.filter.allowedOperators;return W.length>0?M.filter(V=>W.includes(V.value)):M},[S]),a=p.useCallback(()=>!(!f||!h||oo(h)&&!b.trim()||g.length>=w.filter.maxConditions),[f,h,b,g,w]),z=p.useCallback(()=>{if(!a())return;const M={column:f,operator:h};if(oo(h)){const V=S==null?void 0:S.type;M.value=V==="number"?Number(b):b}if(g.some(V=>V.column===M.column&&V.operator===M.operator&&V.value===M.value)){I();return}j([...g,M]),I()},[a,f,h,S,b,g,I]),R=p.useCallback(M=>{j(g.filter((W,V)=>V!==M))},[g]),q=p.useMemo(()=>g.length!==o.length?!0:JSON.stringify(g)!==JSON.stringify(o),[g,o]),K=p.useCallback(()=>{c(g),l()},[g,c,l]),ee=p.useCallback(()=>{j([...o]),I(),l()},[o,I,l]),y=p.useCallback(M=>{var xe;const W=t.find(de=>de.name===M.column);if(!W)return"";const Q=((xe=Dn(W.type).find(de=>de.value===M.operator))==null?void 0:xe.label)||M.operator;return oo(M.operator)?`${M.column} ${Q.toLowerCase()} "${M.value}"`:`${M.column} ${Q.toLowerCase()}`},[t]);return e.jsx(r.Box,{onClick:ee,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:M=>k(M.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:M=>M.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(r.Paper,{onClick:M=>M.stopPropagation(),elevation:0,sx:{position:"relative",width:520,maxWidth:"calc(100vw - 120px)",maxHeight:"min(520px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:M=>Me(M),bgcolor:"background.paper",outline:"none",boxShadow:M=>te(M,"menu"),animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx(r.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Filter columns"}),e.jsx(ir,{content:sr.filter,isDev:process.env.NODE_ENV==="development"})]}),e.jsx(r.IconButton,{onClick:ee,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(B.Close,{sx:{fontSize:20}})})]}),e.jsxs(r.Box,{sx:{flex:1,overflow:"auto",px:3,py:1,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:M=>k(M.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:M=>k(M.palette.text.primary,.3)}}},children:[e.jsxs(r.Box,{sx:{mb:2.5},children:[e.jsx(r.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add filter"}),e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1.75},children:[e.jsxs(r.FormControl,{size:"small",fullWidth:!0,disabled:g.length>=w.filter.maxConditions,children:[e.jsx(r.InputLabel,{sx:{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},children:"Column"}),e.jsx(r.Select,{value:f,onChange:M=>{m(M.target.value),x(""),D("")},label:"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"}},children:v.map(M=>e.jsxs(r.MenuItem,{value:M.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:W=>Re(W),"&:hover":{bgcolor:W=>k(W.palette.primary.main,.2)}}},children:[Ke(M.name)," (",M.type,")"]},M.name))})]}),f&&e.jsxs(r.FormControl,{size:"small",fullWidth:!0,children:[e.jsx(r.InputLabel,{sx:{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},children:"Operator"}),e.jsx(r.Select,{value:h,onChange:M=>{x(M.target.value),D("")},label:"Operator",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"}},children:C.map(M=>e.jsx(r.MenuItem,{value:M.value,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:W=>Re(W),"&:hover":{bgcolor:W=>k(W.palette.primary.main,.2)}}},children:M.label},M.value))})]}),h&&oo(h)&&e.jsx(r.TextField,{size:"small",fullWidth:!0,type:(S==null?void 0:S.type)==="number"?"number":"text",value:b,onChange:M=>D(M.target.value),label:"Value",placeholder:"Enter value...",sx:{"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"divider",transition:"border-color 0.2s ease"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputBase-input":{py:1,color:"text.primary"}}})]}),e.jsx(r.Button,{onClick:z,disabled:!a(),sx:{mt:1.5,fontSize:"0.875rem",color:"primary.main",p:0,justifyContent:"flex-start",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"primary.dark",textDecoration:"underline"},"&.Mui-disabled":{color:"text.disabled"}},children:"+ Add another filter"}),g.length>=w.filter.maxConditions&&e.jsxs(r.Typography,{variant:"caption",sx:{display:"block",mt:.75,color:"warning.dark",fontSize:"0.75rem",fontWeight:500},children:["Filter limit reached — maximum ",w.filter.maxConditions," filters allowed. Remove an existing filter to add a new one."]})]}),g.length>0&&e.jsxs(r.Box,{children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1.5},children:[e.jsxs(r.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:["Active filters (",g.length,")"]}),e.jsx(r.Button,{onClick:()=>{d(),l()},sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"}},children:"Clear all"})]}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:g.map((M,W)=>e.jsx(r.Chip,{label:y(M),onDelete:()=>R(W),sx:{bgcolor:V=>Re(V),color:"primary.main",fontSize:"0.875rem",fontWeight:400,height:32,borderRadius:"16px",border:V=>`1px solid ${k(V.palette.primary.main,.3)}`,transition:"all 0.2s ease","&:hover":{bgcolor:V=>k(V.palette.primary.main,.2),borderColor:V=>k(V.palette.primary.main,.5)},"& .MuiChip-label":{px:1.5,color:"primary.main"},"& .MuiChip-deleteIcon":{color:"primary.main",fontSize:18,transition:"all 0.2s ease","&:hover":{color:"primary.dark"}}}},W))})]})]}),e.jsxs(r.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[e.jsx(r.Button,{onClick:ee,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:M=>`${M.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:K,disabled:!q,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:M=>`${M.shape.borderRadius}px`,boxShadow:M=>te(M,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:M=>te(M,"hoverButton")},"&:active":{boxShadow:M=>te(M,"pressedButton"),transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Apply filter"})]})]})})}const pi="SORT_RULE";function Qd({rule:t,index:o,onToggleDirection:n,onRemove:i,onMove:s}){const d=p.useRef(null),[{handlerId:c},l]=kt.useDrop({accept:pi,collect(m){return{handlerId:m.getHandlerId()}},hover(m,h){var I;if(!d.current)return;const x=m.index,b=o;if(x===b)return;const D=(I=d.current)==null?void 0:I.getBoundingClientRect(),g=(D.bottom-D.top)/2,j=h.getClientOffset(),w=((j==null?void 0:j.y)??0)-D.top;x<b&&w<g||x>b&&w>g||(s(x,b),m.index=b)}}),[{isDragging:u},f]=kt.useDrag({type:pi,item:()=>({index:o}),collect:m=>({isDragging:m.isDragging()})});return f(l(d)),e.jsxs(r.Box,{ref:d,"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:m=>te(m,"restButtonLight"),transform:"translateY(-1px)"}},children:[e.jsx(r.Chip,{label:t.priority,size:"small",sx:{width:26,height:26,fontSize:"0.75rem",fontWeight:600,bgcolor:"primary.main",color:"background.paper",boxShadow:m=>`0 1px 2px 0 ${k(m.palette.primary.main,.3)}`,"& .MuiChip-label":{px:0}}}),e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:"3px",cursor:"grab",px:.5,opacity:.6,transition:"opacity 0.2s ease","&:hover":{opacity:1},"&:active":{cursor:"grabbing"}},children:[e.jsx(r.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}}),e.jsx(r.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}}),e.jsx(r.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}})]}),e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.875rem",fontWeight:400,color:"text.primary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"0 0 100px",lineHeight:1.5},children:t.column}),e.jsx(r.FormControl,{size:"small",sx:{flex:1,minWidth:100},children:e.jsxs(r.Select,{value:t.direction,onChange:m=>n(o,m.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:[e.jsx(r.MenuItem,{value:"asc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:m=>Re(m),"&:hover":{bgcolor:m=>k(m.palette.primary.main,.2)}}},children:"Ascending"}),e.jsx(r.MenuItem,{value:"desc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:m=>Re(m),"&:hover":{bgcolor:m=>k(m.palette.primary.main,.2)}}},children:"Descending"})]})}),e.jsx(r.IconButton,{onClick:()=>i(o),size:"small",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{color:"error.main",bgcolor:m=>k(m.palette.error.main,.08),transform:"scale(1.1)"}},children:e.jsx(B.Close,{sx:{fontSize:18}})})]})}function Zd({schema:t,sortStack:o,onUpdateSortStack:n,onClose:i}){const[s,d]=p.useState(""),[c,l]=p.useState([]);p.useEffect(()=>{l([...o])},[o]);const u=p.useMemo(()=>JSON.stringify(c)!==JSON.stringify(o),[c,o]),f=nr(),m=p.useCallback(()=>!(c.length>=f.sort.maxLevels||!s||c.some(v=>v.column===s)),[c,s]),h=p.useCallback(()=>{if(!m())return;const v=c.length+1,S={column:s,direction:"asc",priority:v};l([...c,S]),d("")},[m,s,c]),x=p.useCallback(v=>{const C=c.filter((a,z)=>z!==v).map((a,z)=>({...a,priority:z+1}));l(C)},[c]),b=p.useCallback((v,S)=>{const C=[...c];C[v]={...C[v],direction:S},l(C)},[c]),D=p.useCallback((v,S)=>{const C=[...c],[a]=C.splice(v,1);C.splice(S,0,a);const z=C.map((R,q)=>({...R,priority:q+1}));l(z)},[c]),g=p.useCallback(()=>{n([]),i()},[n,i]),j=p.useCallback(()=>{n(c),i()},[c,n,i]),w=p.useCallback(()=>{l([...o]),d(""),i()},[o,i]),I=t.filter(v=>!c.some(S=>S.column===v.name));return e.jsx(kt.DndProvider,{backend:tn.HTML5Backend,children:e.jsx(r.Box,{onClick:w,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:v=>k(v.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:v=>v.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(r.Paper,{onClick:v=>v.stopPropagation(),elevation:0,sx:{position:"relative",width:480,maxWidth:"calc(100vw - 120px)",maxHeight:"min(440px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:v=>Me(v),bgcolor:"background.paper",outline:"none",boxShadow:v=>te(v,"menu"),animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx(r.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Sort columns"}),e.jsx(ir,{content:sr.sort,isDev:process.env.NODE_ENV==="development"})]}),e.jsx(r.IconButton,{onClick:w,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(B.Close,{sx:{fontSize:20}})})]}),e.jsxs(r.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:v=>k(v.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:v=>k(v.palette.text.primary,.3)}}},children:[e.jsxs(r.Box,{sx:{mb:2.5},children:[e.jsx(r.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add sort level"}),e.jsxs(r.FormControl,{size:"small",fullWidth:!0,disabled:c.length>=f.sort.maxLevels,children:[e.jsx(r.InputLabel,{sx:{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},children:"Select column..."}),e.jsx(r.Select,{value:s,onChange:v=>d(v.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:I.map(v=>e.jsx(r.MenuItem,{value:v.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:S=>Re(S),"&:hover":{bgcolor:S=>k(S.palette.primary.main,.2)}}},children:Ke(v.name)},v.name))})]}),e.jsx(r.Button,{onClick:h,disabled:!m(),sx:{mt:1.5,fontSize:"0.875rem",color:"primary.main",p:0,justifyContent:"flex-start",minHeight:"auto",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"primary.dark",textDecoration:"underline"},"&.Mui-disabled":{color:"text.disabled"}},children:"+ Add sort column"}),c.length>=f.sort.maxLevels&&e.jsxs(r.Typography,{variant:"caption",sx:{mt:.75,display:"block",color:"warning.dark",fontSize:"0.75rem",fontWeight:500},children:["Maximum ",f.sort.maxLevels," sort levels allowed"]})]}),c.length>0&&e.jsxs(r.Box,{children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1.5},children:[e.jsxs(r.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:["Sorted sequence (",c.length,"/",f.sort.maxLevels,")"]}),e.jsx(r.Button,{onClick:g,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"})]}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:c.map((v,S)=>e.jsx(Qd,{rule:v,index:S,onToggleDirection:b,onRemove:x,onMove:D},`${v.column}-${S}`))})]})]}),e.jsxs(r.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[e.jsx(r.Button,{onClick:w,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:v=>`${v.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:j,variant:"contained",disabled:!u||c.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:v=>`${v.shape.borderRadius}px`,boxShadow:v=>te(v,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:v=>te(v,"hoverButton")},"&:active":{boxShadow:v=>te(v,"pressedButton"),transform:"translateY(1px)"}},children:"Apply sort"})]})]})})})}function eu({views:t,activeViewId:o,onSelectView:n,onCreateView:i,onEditView:s,onDeleteView:d,onRestoreView:c,onPermanentDelete:l,onPromoteToGlobal:u,isAdmin:f=!1,onClose:m}){var v,S;const h=zt(),x=h.palette,b=t.filter(C=>!C.isDeleted),D=t.filter(C=>C.isDeleted),g=b.filter(C=>C.scope==="global"),j=b.filter(C=>C.scope!=="global"),w=C=>{var K,ee,y,M,W;const a=C.scope==="global",z=C.id===o,R=f||!a,q=f&&!a;return e.jsx(r.Paper,{variant:"outlined",sx:{p:0,overflow:"hidden",borderRadius:"8px",borderColor:z?"primary.main":"divider",bgcolor:z?k(x.primary.main,.03):"background.paper",transition:"border-color 0.15s","&:hover":{borderColor:z?"primary.main":k(x.text.primary,.22)}},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:1.75,py:1.25,gap:1},children:[e.jsxs(r.Box,{sx:{flex:1,minWidth:0,cursor:"pointer",display:"flex",alignItems:"center",gap:1},onClick:()=>{n(C.id),m()},children:[e.jsxs(r.Box,{sx:{minWidth:0},children:[e.jsx(r.Typography,{sx:{fontSize:"0.875rem",fontWeight:z?600:500,color:z?"primary.main":"text.primary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:C.name}),C.description&&e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:C.description})]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[a&&e.jsx(r.Chip,{label:"Global",size:"small",icon:e.jsx(B.Language,{sx:{fontSize:"11px !important"}}),sx:{height:20,fontSize:"0.625rem",fontWeight:700,letterSpacing:"0.04em",bgcolor:k(((K=x.info)==null?void 0:K.main)??x.primary.main,.1),color:((ee=x.info)==null?void 0:ee.main)??x.primary.main,border:`1px solid ${k(((y=x.info)==null?void 0:y.main)??x.primary.main,.25)}`,"& .MuiChip-label":{px:.625},"& .MuiChip-icon":{ml:.5}}}),C.isDefault&&e.jsx(r.Chip,{label:"Default",size:"small",sx:{height:20,fontSize:"0.625rem",fontWeight:600,bgcolor:k(x.text.secondary,.08),color:"text.secondary","& .MuiChip-label":{px:.75}}})]})]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.25,flexShrink:0},children:[q&&u&&e.jsx(r.Tooltip,{title:"Promote to Global View",arrow:!0,placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:V=>{V.stopPropagation(),u(C.id)},sx:{p:.625,color:"text.secondary",borderRadius:"6px","&:hover":{color:((M=x.info)==null?void 0:M.main)??x.primary.main,bgcolor:k(((W=x.info)==null?void 0:W.main)??x.primary.main,.08)}},children:e.jsx(B.Language,{sx:{fontSize:16}})})}),R&&e.jsx(r.Tooltip,{title:a&&!f?"Global Views are read-only":"Edit view",arrow:!0,placement:"top",children:e.jsx("span",{children:e.jsx(r.IconButton,{size:"small",disabled:a&&!f,onClick:V=>{V.stopPropagation(),s(C.id)},sx:{p:.625,borderRadius:"6px","&:hover":{color:"primary.main",bgcolor:k(x.primary.main,.08)},"&.Mui-disabled":{opacity:.35}},children:e.jsx(B.Edit,{sx:{fontSize:15}})})})}),e.jsx(r.Tooltip,{title:a&&!f?"Only admins can delete Global Views":"Delete view",arrow:!0,placement:"top",children:e.jsx("span",{children:e.jsx(r.IconButton,{size:"small",disabled:a&&!f,onClick:V=>{V.stopPropagation(),d(C.id)},sx:{p:.625,borderRadius:"6px","&:hover":{color:"error.main",bgcolor:k(x.error.main,.08)},"&.Mui-disabled":{opacity:.35}},children:e.jsx(B.Delete,{sx:{fontSize:15}})})})})]})]})},C.id)},I=C=>{var a;return e.jsxs(r.Paper,{variant:"outlined",sx:{px:1.75,py:1.25,borderRadius:"8px",borderColor:"divider",display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:k(x.text.primary,.02)},children:[e.jsx(r.Typography,{sx:{fontSize:"0.875rem",color:"text.disabled",textDecoration:"line-through",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:C.name}),e.jsxs(r.Box,{sx:{display:"flex",gap:.25,flexShrink:0,ml:1},children:[c&&e.jsx(r.Tooltip,{title:"Restore view",arrow:!0,children:e.jsx(r.IconButton,{size:"small",onClick:z=>{z.stopPropagation(),c(C.id)},sx:{p:.625,borderRadius:"6px","&:hover":{color:"success.main",bgcolor:k(((a=x.success)==null?void 0:a.main)??"#2e7d32",.08)}},children:e.jsx(B.Undo,{sx:{fontSize:15}})})}),l&&e.jsx(r.Tooltip,{title:"Delete permanently",arrow:!0,children:e.jsx(r.IconButton,{size:"small",onClick:z=>{z.stopPropagation(),l(C.id)},sx:{p:.625,borderRadius:"6px","&:hover":{color:"error.main",bgcolor:k(x.error.main,.08)}},children:e.jsx(B.Delete,{sx:{fontSize:15}})})})]})]},C.id)};return e.jsxs(r.Dialog,{open:!0,onClose:m,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{mt:8,borderRadius:Me(h),maxHeight:"min(640px, calc(100vh - 80px))",boxShadow:`0 8px 32px ${k(((v=x.common)==null?void 0:v.black)??"#000",.14)}`}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:[e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontSize:"1rem",fontWeight:600},children:"Manage Views"}),f&&e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.125},children:"Admin mode — you can promote Personal Views to Global"})]}),e.jsx(r.IconButton,{onClick:m,size:"small",sx:{color:"text.secondary"},children:e.jsx(B.Close,{sx:{fontSize:19}})})]}),e.jsxs(r.DialogContent,{sx:{overflowY:"auto",pb:2},children:[e.jsx(r.Box,{sx:{mb:2},children:e.jsx(r.Button,{onClick:i,variant:"contained",startIcon:e.jsx(B.Add,{sx:{fontSize:16}}),size:"small",sx:{borderRadius:C=>`${C.shape.borderRadius}px`},children:"Create New View"})}),g.length>0&&e.jsxs(r.Box,{sx:{mb:2.5},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:1},children:[e.jsx(B.Language,{sx:{fontSize:14,color:((S=x.info)==null?void 0:S.main)??x.primary.main}}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:700,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.07em"},children:"Global Views"}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:"— visible to all users"})]}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:g.map(w)})]}),j.length>0&&e.jsxs(r.Box,{sx:{mb:2.5},children:[e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:700,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.07em",mb:1},children:"Personal Views"}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:j.map(w)})]}),D.length>0&&e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:700,color:"text.disabled",textTransform:"uppercase",letterSpacing:"0.07em",mb:1},children:"Recently Deleted"}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:D.map(I)})]}),b.length===0&&D.length===0&&e.jsx(r.Box,{sx:{py:4,textAlign:"center",color:"text.disabled"},children:e.jsx(r.Typography,{variant:"body2",children:"No views created yet"})})]}),e.jsx(r.DialogActions,{sx:{px:3,py:1.5,borderTop:"1px solid",borderColor:"divider",justifyContent:"flex-end"},children:e.jsx(r.Button,{onClick:m,variant:"contained",sx:{fontSize:"0.875rem",borderRadius:C=>`${C.shape.borderRadius}px`,px:3},children:"Close"})})]})}const lo=50;function xi({currentSnapshot:t,onSave:o,onClose:n,isEditMode:i=!1,initialName:s="",initialDescription:d="",initialIsDefault:c=!1,atViewLimit:l=!1,maxViews:u=10}){const[f,m]=p.useState(s),[h,x]=p.useState(!1),[b,D]=p.useState(d),[g,j]=p.useState(c),w=()=>{if(!f.trim()){x(!0);return}if(f.trim().length>lo){x(!0);return}o(f.trim(),b.trim(),g),n()},I=S=>{S.key==="Enter"&&!S.shiftKey?w():S.key==="Escape"&&n()},v=()=>i&&s?`Update ${s} view`:"Create New Report View";return e.jsxs(r.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{mt:8,borderRadius:S=>Me(S),boxShadow:S=>te(S,"menu")}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:[v(),e.jsx(r.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:e.jsx(B.Close,{sx:{fontSize:20}})})]}),e.jsx(r.DialogContent,{children:e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:2,pt:1},children:[l&&!i&&e.jsxs(r.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."]}),e.jsx(r.TextField,{label:"View Name",required:!0,value:f,onChange:S=>{S.target.value.length<=lo&&m(S.target.value),h&&S.target.value.trim()&&x(!1)},onKeyDown:I,placeholder:"e.g., Active Users",autoFocus:!0,fullWidth:!0,size:"small",disabled:l&&!i,inputProps:{maxLength:lo},error:h&&!f.trim(),helperText:h&&!f.trim()?"View name is required":`${f.length} / ${lo}`}),e.jsx(r.TextField,{label:"Description (optional)",value:b,onChange:S=>D(S.target.value),placeholder:"Brief description of this view",multiline:!0,rows:2,fullWidth:!0,size:"small"}),e.jsxs(r.Paper,{sx:{p:2,bgcolor:"action.hover"},variant:"outlined",children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,mb:1},children:"This view will capture:"}),e.jsxs(r.Box,{component:"ul",sx:{m:0,pl:2,"& li":{fontSize:"body2.fontSize",color:"text.secondary"}},children:[e.jsxs("li",{children:[t.filters.length," filter",t.filters.length!==1?"s":""]}),e.jsxs("li",{children:["Sorting: ",aa(t.sortStack)]}),e.jsx("li",{children:"Column order & visibility"})]})]}),!i&&e.jsx(r.FormControlLabel,{control:e.jsx(r.Checkbox,{checked:g,onChange:S=>j(S.target.checked),size:"small"}),label:e.jsx(r.Typography,{variant:"body2",children:"Set as default view"})})]})}),e.jsxs(r.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:[e.jsx(r.Button,{onClick:n,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:S=>`${S.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:w,variant:"contained",disabled:l&&!i,startIcon:e.jsx(B.Save,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:.875,minHeight:36,borderRadius:S=>`${S.shape.borderRadius}px`,boxShadow:S=>te(S,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:S=>te(S,"hoverButton")},"&:active":{boxShadow:S=>te(S,"pressedButton"),transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"text.disabled"}},children:i?"Save Changes":"Create Report View"})]})]})}function tu({viewName:t,onConfirm:o,onCancel:n}){return e.jsxs(r.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:i=>Me(i),maxHeight:"min(480px, calc(100vh - 180px))",my:"auto",boxShadow:i=>te(i,"menu")}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:["Delete View",e.jsx(r.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:e.jsx(B.Close,{sx:{fontSize:20}})})]}),e.jsx(r.DialogContent,{children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.5,mt:1},children:[e.jsx(B.Warning,{color:"error",sx:{fontSize:20,flexShrink:0}}),e.jsxs(r.Box,{children:[e.jsxs(r.Typography,{variant:"body2",sx:{mb:1},children:["Are you sure you want to delete the view ",e.jsxs("strong",{children:['"',t,'"']}),"?"]}),e.jsx(r.Typography,{variant:"body2",color:"text.secondary",children:"This action cannot be undone."})]})]})}),e.jsxs(r.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid",borderColor:"divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:[e.jsx(r.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"}),e.jsx(r.Button,{onClick:o,variant:"contained",color:"error",sx:{fontSize:"0.875rem",px:3,py:.875,minHeight:36,borderRadius:i=>`${i.shape.borderRadius}px`,boxShadow:i=>te(i,"restButton"),transition:"all 0.2s ease","&:hover":{boxShadow:i=>te(i,"hoverButton")},"&:active":{boxShadow:i=>te(i,"pressedButton"),transform:"translateY(1px)"}},children:"Delete View"})]})]})}const uo=100,po=600,mi="COLUMN";function ru({column:t,index:o,isVisible:n,width:i,onToggleVisibility:s,onWidthChange:d,moveColumn:c}){const l=p.useRef(null),[u,f]=p.useState(i.toString());p.useEffect(()=>{f(i.toString())},[i]);const[{handlerId:m},h]=kt.useDrop({accept:mi,collect(I){return{handlerId:I.getHandlerId()}},hover(I,v){var K;if(!l.current)return;const S=I.index,C=o;if(S===C)return;const a=(K=l.current)==null?void 0:K.getBoundingClientRect(),z=(a.bottom-a.top)/2,R=v.getClientOffset(),q=((R==null?void 0:R.y)??0)-a.top;S<C&&q<z||S>C&&q>z||(c(S,C),I.index=C)}}),[{isDragging:x},b]=kt.useDrag({type:mi,item:()=>({index:o}),collect:I=>({isDragging:I.isDragging()})});b(h(l));const D=()=>{const I=parseInt(u);if(isNaN(I)){f(i.toString()),d(t.name,i);return}const v=Math.max(uo,Math.min(po,I));f(v.toString()),d(t.name,v)},g=I=>{if(I===""||/^\d+$/.test(I)){f(I);const v=parseInt(I);if(!isNaN(v)&&v>=uo){const S=Math.min(po,v);d(t.name,S)}}},j=I=>{I.key==="Enter"&&(I.preventDefault(),D(),I.target.blur())},w=I=>({string:"primary.main",number:"success.main",boolean:"secondary.main",array:"info.main",object:"error.main",null:"text.secondary",mixed:"text.secondary"})[I]||"text.secondary";return e.jsxs(r.TableRow,{ref:l,"data-handler-id":m,sx:{opacity:x?.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:[e.jsx(r.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[e.jsx(r.Box,{sx:{color:"text.secondary",cursor:"grab",opacity:.6,transition:"opacity 0.2s ease","&:hover":{opacity:1},"&:active":{cursor:"grabbing"}},children:e.jsx(B.DragIndicator,{sx:{fontSize:20}})}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:400,fontSize:"0.875rem",color:n?"text.primary":"text.secondary"},children:Ke(t.name)})]})}),e.jsx(r.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:e.jsx(r.Chip,{label:t.type.toUpperCase(),size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:600,bgcolor:`${w(t.type)}15`,color:w(t.type),border:`1px solid ${w(t.type)}30`,"& .MuiChip-label":{px:1}}})}),e.jsx(r.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(r.TextField,{type:"number",value:u,onChange:I=>g(I.target.value),onBlur:D,onKeyDown:j,placeholder:"150",size:"small",inputProps:{min:uo,max:po,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}}}),e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},children:"px"})]})}),e.jsx(r.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[e.jsx(r.IconButton,{onClick:()=>s(t.name,!n),title:n?"Hide column":"Show column",size:"small",sx:{p:.75,color:n?"primary.main":"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:n?"primary.dark":"primary.main"}},children:n?e.jsx(B.Visibility,{sx:{fontSize:20}}):e.jsx(B.VisibilityOff,{sx:{fontSize:20}})}),e.jsx(r.Chip,{label:n?"Visible":"Hidden",size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:500,bgcolor:n?I=>k(I.palette.success.main,.12):"action.selected",color:n?"success.main":"text.secondary","& .MuiChip-label":{px:1}}})]})})]})}function ou({schema:t,columnVisibility:o,columnOrder:n,columnWidths:i={},views:s=[],activeViewId:d="",onUpdateColumnVisibility:c,onUpdateColumnOrder:l,onUpdateColumnWidth:u,onResetLayout:f,onSaveToCurrentView:m,onSaveToAllViews:h,onSelectView:x,onClose:b}){const[D,g]=p.useState(!1),[j,w]=p.useState(n),[I,v]=p.useState(i),[S,C]=p.useState("all"),[a,z]=p.useState(null);p.useEffect(()=>{w(n)},[n]),p.useEffect(()=>{v(i)},[i]);const R=(L,A)=>{v(H=>({...H,[L]:A})),u==null||u(L,A)},q=(L,A)=>{const H=[...j],[ie]=H.splice(L,1);H.splice(A,0,ie),w(H),l(H)},K=()=>{f(),g(!1)},y=j.map(L=>t.find(A=>A.name===L)).filter(L=>L!==void 0).filter(L=>{const A=o[L.name]??!0;return S==="active"?A:S==="hidden"?!A:!0}),M=Object.values(o).filter(L=>L).length,W=t.length,V=s.find(L=>L.id===d),Q=s.filter(L=>!L.isDeleted),xe=Q.length>1,de=p.useMemo(()=>{if(!V)return!1;const L=V.snapshot,A=L.columnVisibility??{},H=JSON.stringify(o)!==JSON.stringify(A),ie=L.columnOrder??[],Y=n??[],re=JSON.stringify(Y)!==JSON.stringify(ie)&&!(Y.length===0&&ie.length===0),se=L.columnWidths??{},oe=JSON.stringify(I)!==JSON.stringify(se);return H||re||oe},[V,o,n,I]);return e.jsx(kt.DndProvider,{backend:tn.HTML5Backend,children:e.jsx(r.Box,{onClick:b,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:L=>k(L.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:L=>L.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(r.Paper,{onClick:L=>L.stopPropagation(),elevation:0,sx:{position:"relative",width:720,maxWidth:"calc(100vw - 120px)",maxHeight:"min(760px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:L=>Me(L),bgcolor:"background.paper",outline:"none",boxShadow:L=>te(L,"menu"),animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(r.Box,{sx:{px:3,pt:2,pb:1.5,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[e.jsxs(r.Box,{sx:{flex:1},children:[e.jsxs(r.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:["Manage columns",e.jsx(ir,{content:sr.columns,isDev:process.env.NODE_ENV==="development"})]}),e.jsxs(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary",mt:.5},children:[M," of ",W," columns visible • Drag to reorder"]})]}),Q.length>0&&x&&e.jsxs(r.Box,{sx:{ml:2},children:[e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.6875rem",color:"text.secondary",mb:.75,display:"block",textTransform:"uppercase",fontWeight:600,letterSpacing:"0.1em"},children:"View:"}),e.jsx(r.Button,{onClick:L=>z(L.currentTarget),variant:"outlined",size:"small",endIcon:e.jsx(B.KeyboardArrowDown,{sx:{fontSize:18}}),sx:{minWidth:180,justifyContent:"space-between",fontSize:"0.875rem",color:"text.primary",borderColor:"divider",py:.75,px:1.5,"&:hover":{borderColor:"primary.main",bgcolor:"action.hover"}},children:e.jsx(r.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis"},children:(V==null?void 0:V.name)||"Select View"})}),e.jsx(r.Menu,{anchorEl:a,open:!!a,onClose:()=>z(null),PaperProps:{sx:{mt:.5,borderRadius:"8px",boxShadow:L=>te(L,"small")}},children:Q.map(L=>e.jsx(r.MenuItem,{onClick:()=>{x(L.id),z(null)},selected:L.id===d,sx:{fontSize:"0.875rem",color:"text.primary",py:1,px:2,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:A=>Re(A),"&:hover":{bgcolor:A=>k(A.palette.primary.main,.2)}}},children:L.name},L.id))})]}),e.jsx(r.IconButton,{onClick:b,size:"small",sx:{ml:2,p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(B.Close,{sx:{fontSize:20}})})]}),e.jsxs(r.Tabs,{value:S,onChange:(L,A)=>C(A),sx:{minHeight:36,mt:.5,"& .MuiTabs-indicator":{bgcolor:"primary.main",height:3}},children:[e.jsx(r.Tab,{label:"All",value:"all",sx:{minHeight:36,py:.75,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary","&.Mui-selected":{color:"primary.main"}}}),e.jsx(r.Tab,{label:"Visible",value:"active",sx:{minHeight:36,py:.75,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary","&.Mui-selected":{color:"primary.main"}}}),e.jsx(r.Tab,{label:"Hidden",value:"hidden",sx:{minHeight:36,py:.75,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary","&.Mui-selected":{color:"primary.main"}}})]})]}),e.jsx(r.Box,{sx:{flex:1,overflow:"auto","&::-webkit-scrollbar":{width:8,height:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:L=>k(L.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:L=>k(L.palette.text.primary,.3)}}},children:e.jsxs(r.Table,{stickyHeader:!0,sx:{minWidth:650},children:[e.jsx(r.TableHead,{children:e.jsxs(r.TableRow,{children:[e.jsx(r.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"}),e.jsx(r.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"}),e.jsx(r.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:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:["Width",e.jsx(r.Tooltip,{title:`Column width in pixels (min: ${uo}px, max: ${po}px)`,arrow:!0,placement:"top",children:e.jsx(B.InfoOutlined,{sx:{fontSize:14,color:"text.secondary",cursor:"help"}})})]})}),e.jsx(r.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"})]})}),e.jsx(r.TableBody,{children:y.length===0?e.jsx(r.TableRow,{children:e.jsx(r.TableCell,{colSpan:4,align:"center",sx:{py:6,borderBottom:"none"},children:e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"text.secondary"},children:"No columns in this category"})})}):y.map((L,A)=>e.jsx(ru,{column:L,index:A,isVisible:o[L.name]??!0,width:I[L.name]||170,onToggleVisibility:c,onWidthChange:R,moveColumn:q},L.name))})]})}),e.jsxs(r.Box,{sx:{px:3,py:1.75,borderTop:"1px solid divider",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0,bgcolor:"action.hover"},children:[e.jsx(r.Button,{onClick:()=>g(!0),disabled:!de,variant:"outlined",startIcon:e.jsx(B.Undo,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",color:"text.secondary",borderColor:"divider",px:2.5,py:.875,minHeight:36,borderRadius:L=>`${L.shape.borderRadius}px`,"&:hover":{borderColor:"primary.main",bgcolor:"background.paper",color:"primary.main"},"&.Mui-disabled":{color:"text.disabled",borderColor:"divider"}},children:"Reset"}),e.jsxs(r.Stack,{direction:"row",spacing:1.25,children:[m&&e.jsx(r.Button,{onClick:()=>{m(I),b()},disabled:!de,variant:"contained",startIcon:e.jsx(B.Save,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:2.5,py:.875,minHeight:36,borderRadius:L=>`${L.shape.borderRadius}px`,boxShadow:L=>te(L,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:L=>te(L,"hoverButton")},"&:active":{boxShadow:L=>te(L,"pressedButton"),transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"text.disabled"}},children:"Save to current view"}),h&&xe&&e.jsx(r.Button,{onClick:()=>{h(I),b()},disabled:!de||!xe,variant:"contained",startIcon:e.jsx(B.GridView,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"success.main",color:"background.paper",px:2.5,py:.875,minHeight:36,borderRadius:L=>`${L.shape.borderRadius}px`,boxShadow:L=>te(L,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"success.dark",boxShadow:L=>te(L,"hoverButton")},"&:active":{boxShadow:L=>te(L,"pressedButton"),transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"text.disabled"}},children:"Save to all views"})]})]}),D&&e.jsx(r.Box,{onClick:()=>g(!1),sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:L=>k(L.palette.common.black,.5),display:"flex",alignItems:"center",justifyContent:"center",zIndex:L=>L.zIndex.tooltip},children:e.jsxs(r.Paper,{onClick:L=>L.stopPropagation(),elevation:0,sx:{width:400,maxWidth:"90vw",borderRadius:L=>Xr(L),bgcolor:"background.paper",boxShadow:L=>te(L,"menu")},children:[e.jsxs(r.Box,{sx:{px:3,py:2.5},children:[e.jsx(r.Typography,{variant:"h6",sx:{fontSize:"1rem",fontWeight:500,color:"text.primary",mb:1.5},children:"Reset column layout?"}),e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"text.secondary",lineHeight:1.5},children:"This will restore default visibility, order, and widths for all columns."})]}),e.jsxs(r.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",bgcolor:"action.hover"},children:[e.jsx(r.Button,{onClick:()=>g(!1),variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,borderRadius:L=>`${L.shape.borderRadius}px`,"&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:K,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"error.main",color:"background.paper",px:3,py:1,borderRadius:L=>`${L.shape.borderRadius}px`,boxShadow:L=>te(L,"pressedButton"),"&:hover":{bgcolor:"error.dark",boxShadow:L=>te(L,"hoverButton")},"&:active":{boxShadow:L=>te(L,"pressedButton"),transform:"translateY(1px)"}},children:"Reset layout"})]})]})})]})})})}function nu({schema:t,grouping:o,onApply:n,onClose:i}){var a;const[s,d]=p.useState(o||{enabled:!1,levels:[],collapsedGroups:[]}),[c,l]=p.useState(""),[u,f]=p.useState(null),m=p.useMemo(()=>ta(t),[t]),h=p.useMemo(()=>m.filter(z=>!s.levels.some((R,q)=>R.column===z.name&&q!==u)),[m,s.levels,u]),x=nr(),b=s.levels.length<x.grouping.maxLevels&&h.length>0,D=p.useCallback(()=>{!b||!c||(d({...s,levels:[...s.levels,{column:c}],enabled:!0}),l(""))},[b,c,s]),g=p.useCallback(z=>{const R=s.levels.filter((q,K)=>K!==z);if(R.length===0){n(null),i();return}d({...s,levels:R,enabled:R.length>0})},[s,n,i]),j=p.useCallback(z=>{f(z),l(s.levels[z].column)},[s.levels]),w=p.useCallback(()=>{if(u===null||!c)return;const z=[...s.levels];z[u]={column:c},d({...s,levels:z}),f(null),l("")},[u,c,s]),I=p.useCallback(()=>{f(null),l("")},[]),v=p.useCallback((z,R)=>{const q=R==="up"?z-1:z+1;if(q<0||q>=s.levels.length)return;const K=[...s.levels],[ee]=K.splice(z,1);K.splice(q,0,ee),d({...s,levels:K})},[s]),S=p.useCallback(()=>{n(null),i()},[n,i]),C=p.useCallback(()=>{s.levels.length===0?n(null):n({...s,enabled:!0,collapsedGroups:(o==null?void 0:o.collapsedGroups)||[]}),i()},[s,o,n,i]);return e.jsx(r.Box,{onClick:i,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:z=>k(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:e.jsxs(r.Paper,{onClick:z=>z.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(560px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:z=>Me(z),bgcolor:"background.paper",outline:"none",boxShadow:z=>te(z,"menu"),animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx(r.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Group configuration"}),"// eslint-disable-next-line no-undef",e.jsx(ir,{content:sr.grouping,isDev:process.env.NODE_ENV==="development"})]}),e.jsx(r.IconButton,{onClick:i,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(B.Close,{sx:{fontSize:20}})})]}),e.jsx(r.Box,{sx:{flex:1,overflow:"auto",px:3,py:1,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:z=>k(z.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:z=>k(z.palette.text.primary,.3)}}},children:e.jsxs(r.Stack,{spacing:2.5,children:[u===null&&e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add group level"}),e.jsx(r.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:e.jsxs(r.Select,{value:c,onChange:z=>l(z.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:[e.jsx(r.MenuItem,{value:"",sx:{fontSize:"0.875rem",color:"text.secondary"},children:"Select a column..."}),h.map(z=>e.jsxs(r.MenuItem,{value:z.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:R=>Re(R),"&:hover":{bgcolor:R=>k(R.palette.primary.main,.2)}}},children:[Ke(z.name)," (",z.type.toUpperCase(),")"]},z.name))]})}),e.jsx(r.Button,{onClick:D,disabled:!b||!c,variant:"outlined",startIcon:e.jsx(B.Add,{sx:{fontSize:18}}),fullWidth:!0,sx:{fontSize:"0.875rem",color:"primary.main",borderColor:"divider",py:1,transition:"all 0.2s ease","&:hover":{borderColor:"primary.main",bgcolor:"action.hover"},"&.Mui-disabled":{color:"text.disabled",borderColor:"divider"}},children:"Add group level"}),s.levels.length>=x.grouping.maxLevels&&e.jsx(r.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",textAlign:"center",mt:1.5,fontSize:"0.75rem",color:"text.secondary"},children:"Maximum group levels (3) reached"}),m.length===0&&e.jsx(r.Typography,{variant:"body2",color:"text.secondary",sx:{textAlign:"center",py:2,fontSize:"0.875rem",color:"text.secondary"},children:"No groupable columns available. Only STRING and BOOLEAN columns can be grouped."})]}),u!==null&&e.jsxs(r.Alert,{severity:"warning",sx:{borderRadius:"8px",border:z=>`1px solid ${k(z.palette.warning.main,.5)}`,bgcolor:z=>k(z.palette.warning.main,.12),"& .MuiAlert-icon":{color:"warning.main"}},children:[e.jsxs(r.Typography,{variant:"body2",sx:{fontWeight:500,mb:1.5,fontSize:"0.875rem",color:"text.primary"},children:["Edit Group Level ",u+1]}),e.jsx(r.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:e.jsxs(r.Select,{value:c,onChange:z=>l(z.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:[e.jsx(r.MenuItem,{value:"",sx:{fontSize:"0.875rem"},children:"Select a column..."}),e.jsxs(r.MenuItem,{value:s.levels[u].column,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:z=>Re(z)}},children:[s.levels[u].column," (",(a=t.find(z=>z.name===s.levels[u].column))==null?void 0:a.type.toUpperCase(),")"]}),h.filter(z=>z.name!==s.levels[u].column).map(z=>e.jsxs(r.MenuItem,{value:z.name,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:R=>Re(R)}},children:[Ke(z.name)," (",z.type.toUpperCase(),")"]},z.name))]})}),e.jsxs(r.Stack,{direction:"row",spacing:1.5,children:[e.jsx(r.Button,{onClick:w,disabled:!c,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:z=>te(z,"pressedButton")}},children:"Save"}),e.jsx(r.Button,{onClick:I,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"})]})]}),s.levels.length>0&&u===null&&e.jsxs(r.Box,{children:[e.jsxs(r.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1.5},children:[e.jsx(r.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:"Active group levels"}),e.jsx(r.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"})]}),e.jsx(r.Stack,{spacing:1.5,children:s.levels.map((z,R)=>{const q=t.find(K=>K.name===z.column);return e.jsxs(r.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:K=>te(K,"pressedButtonLight")}},children:[e.jsx(r.Chip,{label:`L${R+1}`,size:"small",sx:{width:40,height:28,fontWeight:600,fontSize:"0.75rem",bgcolor:"primary.main",color:"background.paper",boxShadow:K=>`0 1px 2px 0 ${k(K.palette.primary.main,.3)}`}}),e.jsxs(r.Box,{sx:{flex:1},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:z.column}),e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},children:q==null?void 0:q.type.toUpperCase()})]}),e.jsxs(r.Stack,{direction:"row",spacing:.5,children:[e.jsx(r.IconButton,{size:"small",onClick:()=>v(R,"up"),disabled:R===0,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"divider"}},children:e.jsx(B.KeyboardArrowUp,{sx:{fontSize:18}})}),e.jsx(r.IconButton,{size:"small",onClick:()=>v(R,"down"),disabled:R===s.levels.length-1,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"divider"}},children:e.jsx(B.KeyboardArrowDown,{sx:{fontSize:18}})}),e.jsx(r.IconButton,{size:"small",onClick:()=>j(R),sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover",color:"primary.main"}},children:e.jsx(B.Edit,{sx:{fontSize:18}})}),e.jsx(r.IconButton,{size:"small",onClick:()=>g(R),sx:{color:"text.secondary","&:hover":{bgcolor:K=>k(K.palette.error.main,.08),color:"error.main"}},children:e.jsx(B.Delete,{sx:{fontSize:18}})})]})]},R)})})]})]})}),e.jsxs(r.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[e.jsx(r.Button,{onClick:i,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"}),e.jsx(r.Button,{onClick:C,variant:"contained",disabled:s.levels.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=>te(z,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:z=>te(z,"hoverButton")},"&:active":{boxShadow:z=>te(z,"pressedButton"),transform:"translateY(1px)"}},children:"Apply grouping"})]})]})})}const iu={filters:B.FilterList,sorting:B.UnfoldMore,visibility:B.Visibility,order:B.ViewColumn,widths:B.Straighten,grouping:B.Layers};function su({changes:t,onClose:o}){const n=i=>({filters:"primary",sorting:"secondary",visibility:"success",order:"warning",widths:"info",grouping:"error"})[i]||"default";return e.jsxs(r.Dialog,{open:!0,onClose:o,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{mt:8,borderRadius:i=>Me(i),boxShadow:i=>te(i,"menu")}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:["View Changes Summary",e.jsx(r.IconButton,{onClick:o,size:"small",sx:{color:"text.secondary"},children:e.jsx(B.Close,{sx:{fontSize:20}})})]}),e.jsx(r.DialogContent,{dividers:!0,children:t.length===0?e.jsx(r.Box,{sx:{textAlign:"center",py:4},children:e.jsx(r.Typography,{variant:"body2",color:"text.secondary",children:"No changes detected"})}):e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"The following modifications have been made to this view:"}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1.5},children:t.map((i,s)=>{const d=iu[i.category];return e.jsxs(r.Paper,{elevation:0,sx:{display:"flex",gap:1.5,p:1.5,border:1,borderColor:"divider",borderRadius:1},children:[e.jsx(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:1,bgcolor:`${n(i.category)}.lighter`,color:`${n(i.category)}.main`,flexShrink:0},children:e.jsx(d,{sx:{fontSize:16}})}),e.jsxs(r.Box,{sx:{flex:1,minWidth:0},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500},children:i.label}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:i.description})]})]},s)})})]})}),e.jsx(r.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:e.jsx(r.Button,{onClick:o,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=>te(i,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:i=>te(i,"hoverButton")},"&:active":{boxShadow:i=>te(i,"pressedButton"),transform:"translateY(1px)"}},children:"Close"})})]})}function au({viewName:t,isDefaultView:o,changes:n=[],onSaveToCurrentView:i,onSaveAsNewView:s,onCancel:d}){const[c,l]=p.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{width:"100%",flexShrink:0,bgcolor:u=>Re(u),borderBottom:u=>`1px solid ${k(u.palette.primary.main,.3)}`,zIndex:10},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:1.25},children:[e.jsxs(r.Typography,{variant:"body2",sx:{fontWeight:400,fontSize:"0.875rem",color:"text.primary"},children:['Unsaved changes to "',t,'"']}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(r.Button,{onClick:d,variant:"text",size:"small",sx:{fontSize:"0.875rem",px:2,py:.625,borderRadius:"18px",color:"text.secondary",bgcolor:"transparent",minHeight:32,"&:hover":{bgcolor:u=>k(u.palette.common.black,.08),color:"text.primary"}},children:"Discard"}),e.jsx(r.Button,{onClick:s,variant:"contained",size:"small",sx:{fontSize:"0.875rem",px:2.5,py:.625,borderRadius:"18px",minHeight:32,boxShadow:"none","&:hover":{boxShadow:u=>te(u,"restButton")}},children:"Save as new view"})]})]})}),c&&e.jsx(su,{changes:n,onClose:()=>l(!1)})]})}function lu({onExportAnyway:t,onSaveAndExport:o,onCancel:n}){return e.jsx(r.Box,{sx:{mb:2,mx:3,mt:2},children:e.jsxs(r.Alert,{severity:"warning",icon:e.jsx(B.Warning,{sx:{fontSize:20}}),action:e.jsx(r.IconButton,{size:"small",onClick:n,sx:{color:"warning.main"},children:e.jsx(B.Close,{sx:{fontSize:20}})}),sx:{alignItems:"flex-start"},children:[e.jsx(r.Typography,{variant:"subtitle2",sx:{fontWeight:600,mb:.5},children:"You are exporting with unsaved view changes"}),e.jsx(r.Typography,{variant:"body2",sx:{mb:1.5},children:"Your current view has unsaved changes. Choose how to proceed:"}),e.jsxs(r.Box,{sx:{display:"flex",gap:1},children:[e.jsx(r.Button,{onClick:o,variant:"contained",color:"primary",startIcon:e.jsx(B.Save,{sx:{fontSize:14}}),size:"small",children:"Save View & Export"}),e.jsx(r.Button,{onClick:t,variant:"contained",color:"warning",startIcon:e.jsx(B.Download,{sx:{fontSize:14}}),size:"small",children:"Export Anyway"})]})]})})}const hi=[{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 cu(t,o){if(o===null)return t.length;const n=Date.now()-o;return t.filter(i=>new Date(i.timestamp).getTime()>=n).length}function du(t,o){if(o===null)return[];const n=Date.now()-o;return t.filter(i=>new Date(i.timestamp).getTime()<n)}function uu({auditHistory:t,onClose:o,onClearAuditHistory:n}){var D,g,j,w;const i=zt(),s=i.palette,[d,c]=p.useState("1h"),[l,u]=p.useState(!1),f=[...t].sort((I,v)=>new Date(v.timestamp).getTime()-new Date(I.timestamp).getTime()),m=hi.find(I=>I.key===d),h=cu(t,m.ms),x=()=>u(!0),b=()=>{n&&(n(du(t,m.ms)),u(!1))};return e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{onClick:o,sx:{position:"fixed",inset:0,bgcolor:k(((D=s.common)==null?void 0:D.black)??"#000",.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:e.jsxs(r.Paper,{onClick:I=>I.stopPropagation(),elevation:0,sx:{width:520,maxWidth:"calc(100vw - 48px)",maxHeight:"min(700px, calc(100vh - 80px))",display:"flex",flexDirection:"column",borderRadius:Me(i),bgcolor:"background.paper",overflow:"hidden",boxShadow:`0 8px 32px ${k(((g=s.common)==null?void 0:g.black)??"#000",.14)}, 0 2px 8px ${k(((j=s.common)==null?void 0:j.black)??"#000",.08)}`,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:[e.jsxs(r.Box,{sx:{px:2.5,py:1.75,display:"flex",alignItems:"center",justifyContent:"space-between",gap:1.5,flexShrink:0,borderBottom:"1px solid",borderColor:"divider"},children:[e.jsxs(r.Box,{sx:{minWidth:0},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(r.Typography,{sx:{fontSize:"0.9375rem",fontWeight:600,color:"text.primary"},children:"Audit History"}),e.jsx(ir,{content:sr.auditHistory,isDev:process.env.NODE_ENV==="development"})]}),e.jsxs(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.125},children:[f.length," event",f.length!==1?"s":""," recorded"]})]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1,flexShrink:0},children:[n&&t.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(r.Select,{value:d,onChange:I=>c(I.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:k(s.text.primary,.3)}},children:hi.map(I=>e.jsx(r.MenuItem,{value:I.key,sx:{fontSize:"0.8125rem"},children:I.label},I.key))}),e.jsx(r.Button,{size:"small",variant:"outlined",color:"error",startIcon:e.jsx(B.DeleteSweepOutlined,{sx:{fontSize:14}}),onClick:x,sx:{fontSize:"0.75rem",borderRadius:"7px",px:1.25,height:30,whiteSpace:"nowrap",borderColor:k(s.error.main,.5),"&:hover":{bgcolor:k(s.error.main,.06),borderColor:"error.main"}},children:"Clear Logs"})]}),e.jsx(r.IconButton,{onClick:o,size:"small",sx:{color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(B.Close,{sx:{fontSize:17}})})]})]}),e.jsx(r.Box,{sx:{flex:1,overflowY:"auto",px:2,py:1.5,bgcolor:k(s.text.primary,.012),"&::-webkit-scrollbar":{width:5},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:k(s.text.primary,.14),borderRadius:3}},children:f.length===0?e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8,gap:1,textAlign:"center"},children:[e.jsx(B.AccessTime,{sx:{fontSize:44,color:"text.disabled",opacity:.5}}),e.jsx(r.Typography,{sx:{fontSize:"0.9375rem",color:"text.secondary",fontWeight:500},children:"No audit events yet"}),e.jsx(r.Typography,{sx:{fontSize:"0.8125rem",color:"text.disabled"},children:"Changes to this report will appear here"})]}):e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:f.map(I=>{const v=kd(i,I.feature),{summary:S,detail:C}=va(I);return e.jsxs(r.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:k(s.text.primary,.18)}},children:[e.jsx(r.Chip,{label:Ca(I.feature),size:"small",sx:{height:20,fontSize:"0.5625rem",fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",bgcolor:k(v,.1),color:v,border:`1px solid ${k(v,.22)}`,flexShrink:0,mt:.125,"& .MuiChip-label":{px:.75}}}),e.jsxs(r.Box,{sx:{flex:1,minWidth:0},children:[e.jsx(r.Typography,{sx:{fontSize:"0.8125rem",fontWeight:500,color:"text.primary",lineHeight:1.45,wordBreak:"break-word"},children:S}),C&&e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.25,lineHeight:1.4},children:C}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1,mt:.5,flexWrap:"wrap"},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.375},children:[e.jsx(B.AccessTime,{sx:{fontSize:11,color:"text.disabled"}}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:wa(I.timestamp)})]}),I.user&&e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.375},children:[e.jsx(B.Person,{sx:{fontSize:11,color:"text.disabled"}}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:I.user})]})]})]})]},I.id)})})})]})}),e.jsxs(r.Dialog,{open:l,onClose:()=>u(!1),maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:Xr(i),boxShadow:`0 8px 32px ${k(((w=s.common)==null?void 0:w.black)??"#000",.14)}`}},children:[e.jsxs(r.DialogContent,{sx:{pt:3,pb:2,px:3},children:[e.jsx(r.Box,{sx:{width:44,height:44,borderRadius:"12px",bgcolor:k(s.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(B.WarningAmberOutlined,{sx:{fontSize:22,color:"error.main"}})}),e.jsx(r.Typography,{sx:{fontSize:"0.9375rem",fontWeight:600,color:"text.primary",mb:1},children:"Clear Audit Logs"}),e.jsxs(r.Typography,{sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.65},children:["You are about to permanently remove"," ",e.jsxs(r.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:[h," audit record",h!==1?"s":""]})," ",m.key==="all"?"from all time":`from the ${m.label.toLowerCase()}`,". This action cannot be undone."]})]}),e.jsx(r.Divider,{}),e.jsxs(r.DialogActions,{sx:{px:2.5,py:1.5,gap:1},children:[e.jsx(r.Button,{onClick:()=>u(!1),variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),e.jsxs(r.Button,{onClick:b,variant:"contained",color:"error",startIcon:e.jsx(B.DeleteSweepOutlined,{sx:{fontSize:14}}),sx:{fontSize:"0.8125rem",borderRadius:"7px",px:2},children:["Clear ",h," Record",h!==1?"s":""]})]})]})]})}function pu({onSave:t,onClose:o}){const[n,i]=p.useState(""),[s,d]=p.useState(""),[c,l]=p.useState(""),[u,f]=p.useState([]),[m,h]=p.useState(""),[x,b]=p.useState(""),D=C=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(C),g=()=>{const C=c.trim();if(C){if(!D(C)){b("Please enter a valid email address");return}if(u.includes(C)){b("This email is already added");return}f([...u,C]),l(""),b("")}},j=C=>{f(u.filter(a=>a!==C))},w=C=>{C.key==="Enter"&&(C.preventDefault(),g())},I=()=>{if(!n.trim()){h("Preset name is required");return}t(n.trim(),s.trim(),u.length>0?u:void 0)},v=C=>{i(C),m&&h("")},S=C=>{l(C),x&&b("")};return e.jsx(r.Box,{onClick:o,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:C=>k(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:e.jsxs(r.Paper,{onClick:C=>C.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(480px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:C=>Me(C),bgcolor:"background.paper",outline:"none",boxShadow:C=>te(C,"menu"),animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsx(r.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Create shareable preset"}),e.jsx(r.IconButton,{onClick:o,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(B.Close,{sx:{fontSize:20}})})]}),e.jsx(r.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:C=>k(C.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:C=>k(C.palette.text.primary,.3)}}},children:e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[e.jsx(r.Alert,{severity:"info",icon:e.jsx(B.Info,{sx:{fontSize:20}}),sx:{borderRadius:"8px",border:C=>`1px solid ${k(C.palette.primary.main,.3)}`,bgcolor:C=>Re(C),"& .MuiAlert-icon":{color:"primary.main"},"& .MuiAlert-message":{fontSize:"0.8125rem",color:"text.primary",lineHeight:1.5}},children:"This preset will capture filters, sorting, grouping, column configuration, and the active view. The actual data is not saved or shared."}),e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"text.secondary",lineHeight:1.6},children:"Save the current report configuration and generate a shareable link that others can use to view the same filters, sorting, and column layout."}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Preset name *"}),e.jsx(r.TextField,{required:!0,value:n,onChange:C=>v(C.target.value),placeholder:"e.g., Q4 Active Users Report",error:!!m,helperText:m,autoFocus:!0,fullWidth:!0,size:"small",sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"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}}})]}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Description (optional)"}),e.jsx(r.TextField,{value:s,onChange:C=>d(C.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}}})]}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Share with (optional)"}),e.jsxs(r.Box,{sx:{display:"flex",gap:1,alignItems:"flex-start"},children:[e.jsx(r.TextField,{value:c,onChange:C=>S(C.target.value),onKeyPress:w,placeholder:"Enter email address",error:!!x,helperText:x,fullWidth:!0,size:"small",InputProps:{startAdornment:e.jsx(B.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}}}),e.jsx(r.Button,{onClick:g,variant:"outlined",startIcon:e.jsx(B.Add,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",color:"primary.main",borderColor:"divider",px:2,py:1.25,minHeight:40,borderRadius:C=>`${C.shape.borderRadius}px`,flexShrink:0,"&:hover":{borderColor:"primary.main",bgcolor:"action.hover"}},children:"Add"})]}),u.length>0&&e.jsx(r.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1,mt:1.5},children:u.map(C=>e.jsx(r.Chip,{label:C,onDelete:()=>j(C),deleteIcon:e.jsx(B.Delete,{sx:{fontSize:16}}),sx:{bgcolor:a=>Re(a),color:"primary.main",fontSize:"0.8125rem",height:28,"& .MuiChip-deleteIcon":{color:"primary.main","&:hover":{color:"primary.dark"}}}},C))}),e.jsx(r.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"})]})]})}),e.jsxs(r.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[e.jsx(r.Button,{onClick:o,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:C=>`${C.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:I,variant:"contained",startIcon:e.jsx(B.Share,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:C=>`${C.shape.borderRadius}px`,boxShadow:C=>te(C,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:C=>te(C,"hoverButton")},"&:active":{boxShadow:C=>te(C,"pressedButton"),transform:"translateY(1px)"}},children:"Create & share"})]})]})})}function xu({presetName:t,onClear:o}){return e.jsx(r.Chip,{icon:e.jsx(B.Link,{sx:{fontSize:14}}),label:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:["Preset:"," ",e.jsx(r.Box,{component:"span",sx:{fontWeight:600},children:t})]}),onDelete:o,deleteIcon:e.jsx(r.IconButton,{size:"small",title:"Exit preset view",sx:{p:0},children:e.jsx(B.Close,{sx:{fontSize:14}})}),sx:{bgcolor:n=>k(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 mu({presets:t,reportId:o,onOpenPreset:n,onDeletePreset:i,onClose:s}){const d=c=>new Date(c).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});return e.jsx(r.Box,{onClick:s,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:c=>k(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:e.jsxs(r.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=>Me(c),bgcolor:"background.paper",outline:"none",boxShadow:c=>te(c,"menu"),animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Manage Presets"}),e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",mt:.5,display:"block"},children:[t.length," saved ",t.length===1?"preset":"presets"]})]}),e.jsx(r.IconButton,{onClick:s,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(B.Close,{sx:{fontSize:20}})})]}),e.jsx(r.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=>k(c.palette.text.primary,.2)}}},children:t.length===0?e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8},children:[e.jsx(B.Share,{sx:{fontSize:48,color:"divider",mb:2}}),e.jsx(r.Typography,{variant:"body1",sx:{fontSize:"0.875rem",color:"text.secondary",textAlign:"center"},children:"No presets created yet"}),e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.disabled",textAlign:"center",mt:.5},children:"Create a preset to share report configurations"})]}):e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:t.map(c=>e.jsxs(r.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=>te(l,"restButtonLight")}},children:[e.jsx(r.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",mb:1.5},children:e.jsxs(r.Box,{sx:{flex:1,minWidth:0},children:[e.jsx(r.Typography,{variant:"h6",sx:{fontSize:"0.9375rem",fontWeight:500,color:"text.primary",mb:.5},children:c.name}),c.description&&e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.5},children:c.description})]})}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:2},children:[e.jsx(r.Chip,{label:`Created ${d(c.createdAt)}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"action.hover",color:"text.secondary","& .MuiChip-label":{px:1}}}),e.jsx(r.Chip,{label:`By ${c.createdBy}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"action.hover",color:"text.secondary","& .MuiChip-label":{px:1}}})]}),e.jsx(r.Divider,{sx:{my:1.5,borderColor:"divider"}}),e.jsx(r.Box,{sx:{display:"flex",gap:1},children:e.jsx(r.Button,{onClick:()=>i(c.id,c.name),variant:"outlined",size:"small",startIcon:e.jsx(B.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=>k(l.palette.error.main,.04)}},children:"Delete"})})]},c.id))})}),e.jsx(r.Box,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end",display:"flex"},children:e.jsx(r.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=>te(c,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:c=>te(c,"hoverButton")},"&:active":{boxShadow:c=>te(c,"pressedButton"),transform:"translateY(1px)"}},children:"Close"})})]})})}const Zi={maxFileSizeBytes:2*1024*1024,maxFileSizeHardBytes:3*1024*1024,maxRows:1e4,maxRowsHard:5e4,maxImageColumns:5},hu=[/^https?:\/\/.*\.(jpg|jpeg|png|gif|webp|svg|avif|bmp)/i,/^data:image\//i,/^\/.*\.(jpg|jpeg|png|gif|webp|svg)/i],fu=[/image/i,/photo/i,/avatar/i,/thumbnail/i,/picture/i,/logo/i,/icon/i,/banner/i];function gu(t,o){const n=[];for(const i of t){if(i.type!=="string")continue;const s=fu.some(l=>l.test(i.name));let d=!1;const c=o.slice(0,10).map(l=>l[i.name]).filter(l=>typeof l=="string"&&l.length>0);c.length>0&&(d=c.filter(u=>hu.some(f=>f.test(u))).length/c.length>.6),(s||d)&&n.push(i.name)}return n}function un(t,o){if(t.length===0||o.length===0)return 0;const n=t.slice(0,Math.min(50,t.length)),s=o.map(c=>{const l=n.map(f=>String(f[c]??"")).filter(f=>f.length>0);if(l.length===0)return 5;const u=l.reduce((f,m)=>f+m.length,0);return Math.ceil(u/l.length)+1}).reduce((c,l)=>c+l,0)+1;return o.reduce((c,l)=>c+l.length+1,0)+s*t.length}function yu(t,o){const n=un(t,o);return Math.ceil(n*3.5)}function bu(t,o){const n=un(t,o);return Math.ceil(n*.7)}function vu(t,o,n){switch(t){case"csv":return un(o,n);case"excel":return bu(o,n);case"json":return yu(o,n)}}function fi(t,o){return Math.ceil(t/o)}function Su(t,o,n,i,s=Zi){const d=[],c=vu(t,o,n),l=o.length;if(l>s.maxRowsHard){const m=fi(l,s.maxRows);d.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 ${m} smaller exports of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:m,value:l,limit:s.maxRowsHard})}else if(l>s.maxRows){const m=fi(l,s.maxRows);d.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 ${m} smaller export${m>1?"s":""} of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:m,value:l,limit:s.maxRows})}if(c>s.maxFileSizeHardBytes?d.push({type:"file_size",severity:"error",message:`File size blocked: estimated ${Yr(c)} exceeds the ${Yr(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&&d.push({type:"file_size",severity:"warning",message:`Large file: estimated ${Yr(c)}`,detail:`This exceeds the recommended ${Yr(s.maxFileSizeBytes)} size. The download will still proceed but may be slow on some connections.`,value:c,limit:s.maxFileSizeBytes}),t!=="excel"){const m=gu(i.filter(h=>n.includes(h.name)),o);if(m.length>0){const h=m.length>s.maxImageColumns;d.push({type:"image_columns",severity:h?"error":"warning",message:`Image column${m.length>1?"s":""} detected: ${m.map(x=>`"${x.replace(/_/g," ")}"`).join(", ")}`,detail:h?`Exporting ${m.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:m.length,limit:s.maxImageColumns})}}const u=d.some(m=>m.severity==="error"),f=d.some(m=>m.severity==="warning");return{violations:d,hasBlockingViolation:u,hasWarning:f,estimatedBytes:c}}function Yr(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function ju({violation:t}){const n=zt().palette,i=t.severity==="error",s=i?n.error.main:n.warning.main,d=k(i?n.error.main:n.warning.main,.06),c=i?k(n.error.main,.25):k(n.warning.main,.3),l=i?B.ErrorOutline:B.WarningAmberOutlined;return e.jsxs(r.Box,{sx:{display:"flex",gap:1.25,p:1.5,borderRadius:"8px",bgcolor:d,border:"1px solid",borderColor:c},children:[e.jsx(l,{sx:{fontSize:17,color:s,flexShrink:0,mt:.125}}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontSize:"0.8125rem",fontWeight:600,color:i?"error.main":"warning.dark",lineHeight:1.4},children:t.message}),t.detail&&e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.375,lineHeight:1.5},children:t.detail}),t.suggestedBatches&&t.suggestedBatches>1&&e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5,mt:.75},children:[e.jsx(B.SplitscreenOutlined,{sx:{fontSize:14,color:"text.secondary"}}),e.jsxs(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",fontWeight:500},children:["Suggestion: split into ",t.suggestedBatches," exports"]})]})]})]})}function Cu({totalRows:t,visibleRows:o,hasGrouping:n,visibleColumnsCount:i,totalColumnsCount:s,schema:d,sampleRows:c=[],allRows:l=[],processedRows:u=[],onExport:f,onClose:m}){var M,W,V;const h=zt(),x=h.palette,b=nr(),[D,g]=p.useState(b.export.allowedFormats[0]||"csv"),[j,w]=p.useState("visible"),[I,v]=p.useState("visible"),S=j==="visible"?o:t,C=I==="visible"?i:s,a=p.useMemo(()=>j==="visible"?u.length>0?u:new Array(o):l.length>0?l:new Array(t),[j,o,t,u,l]),z=p.useMemo(()=>I==="all"?d.map(Q=>Q.name):d.map(Q=>Q.name).slice(0,i),[I,d,i]),R=p.useMemo(()=>Su(D,a,z,d,Zi),[D,a,z,d]),q=()=>{R.hasBlockingViolation||(f({format:D,scope:j,columnScope:I}),m())},K={csv:"CSV",excel:"Excel (.xlsx)",json:"JSON"},ee={alignItems:"flex-start",px:1.5,py:.875,borderRadius:"8px",mx:0,transition:"background-color 0.15s","&:hover":{bgcolor:"action.hover"}},y={color:"text.secondary","&.Mui-checked":{color:"primary.main"},pt:.125};return e.jsx(r.Box,{onClick:m,sx:{position:"fixed",inset:0,bgcolor:k(((M=x.common)==null?void 0:M.black)??"#000",.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:h.zIndex.modal,animation:"fadeIn 0.2s ease","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(r.Paper,{onClick:Q=>Q.stopPropagation(),elevation:0,sx:{width:480,maxWidth:"calc(100vw - 48px)",maxHeight:"min(680px, calc(100vh - 180px))",display:"flex",flexDirection:"column",borderRadius:Me(h),bgcolor:"background.paper",overflow:"hidden",boxShadow:`0 8px 32px ${k(((W=x.common)==null?void 0:W.black)??"#000",.14)}, 0 2px 8px ${k(((V=x.common)==null?void 0:V.black)??"#000",.08)}`,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:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx(r.Typography,{sx:{fontSize:"1rem",fontWeight:600,color:"text.primary"},children:"Export Report"}),e.jsx(ir,{content:sr.export,isDev:process.env.NODE_ENV==="development"})]}),e.jsx(r.IconButton,{onClick:m,size:"small",sx:{color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(B.Close,{sx:{fontSize:18}})})]}),e.jsxs(r.Box,{sx:{flex:1,overflowY:"auto",px:3,py:2.5,display:"flex",flexDirection:"column",gap:2.5,"&::-webkit-scrollbar":{width:6},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:k(x.text.primary,.15),borderRadius:3}},children:[R.violations.length>0&&e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:R.violations.map((Q,xe)=>e.jsx(ju,{violation:Q},xe))}),e.jsxs(r.FormControl,{component:"fieldset",children:[e.jsx(r.FormLabel,{component:"legend",sx:{fontSize:"0.6875rem",fontWeight:700,color:"text.secondary",letterSpacing:"0.08em",mb:1,textTransform:"uppercase"},children:"Format"}),e.jsxs(r.RadioGroup,{value:D,onChange:Q=>g(Q.target.value),children:[b.export.allowedFormats.includes("csv")&&e.jsx(r.FormControlLabel,{value:"csv",control:e.jsx(r.Radio,{size:"small",sx:y}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"CSV"}),e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary"},children:"Comma-separated values, compatible with Excel"})]}),sx:{...ee,mb:.5}}),b.export.allowedFormats.includes("excel")&&e.jsx(r.FormControlLabel,{value:"excel",control:e.jsx(r.Radio,{size:"small",sx:y}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"Excel (.xlsx)"}),e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary"},children:"Native Excel format with formatting support"})]}),sx:{...ee,mb:.5}}),b.export.allowedFormats.includes("json")&&e.jsx(r.FormControlLabel,{value:"json",control:e.jsx(r.Radio,{size:"small",sx:y}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"JSON"}),e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary"},children:"Structured data with metadata and filters"})]}),sx:ee})]})]}),e.jsxs(r.FormControl,{component:"fieldset",children:[e.jsx(r.FormLabel,{component:"legend",sx:{fontSize:"0.6875rem",fontWeight:700,color:"text.secondary",letterSpacing:"0.08em",mb:1,textTransform:"uppercase"},children:"Rows"}),e.jsxs(r.RadioGroup,{value:j,onChange:Q=>w(Q.target.value),children:[e.jsx(r.FormControlLabel,{value:"visible",control:e.jsx(r.Radio,{size:"small",sx:y}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"Visible rows"}),e.jsxs(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary"},children:["Export ",o.toLocaleString()," rows (filtered and searched)"]})]}),sx:{...ee,mb:.5}}),e.jsx(r.FormControlLabel,{value:"all",control:e.jsx(r.Radio,{size:"small",sx:y}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"All rows"}),e.jsxs(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary"},children:["Export ",t.toLocaleString()," rows (complete original dataset)"]})]}),sx:ee})]})]}),e.jsxs(r.FormControl,{component:"fieldset",children:[e.jsx(r.FormLabel,{component:"legend",sx:{fontSize:"0.6875rem",fontWeight:700,color:"text.secondary",letterSpacing:"0.08em",mb:1,textTransform:"uppercase"},children:"Columns"}),e.jsxs(r.RadioGroup,{value:I,onChange:Q=>v(Q.target.value),children:[e.jsx(r.FormControlLabel,{value:"visible",control:e.jsx(r.Radio,{size:"small",sx:y}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"Visible columns only"}),e.jsxs(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary"},children:["Export ",i," visible column",i!==1?"s":""]})]}),sx:{...ee,mb:.5}}),e.jsx(r.FormControlLabel,{value:"all",control:e.jsx(r.Radio,{size:"small",sx:y}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"All columns"}),e.jsxs(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary"},children:["Export all ",s," columns (including hidden)"]})]}),sx:ee})]})]}),e.jsxs(r.Box,{children:[e.jsx(r.Divider,{sx:{mb:2}}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:[{label:"Format",value:K[D]},{label:"Rows to export",value:S.toLocaleString()},{label:"Columns to export",value:String(C)},{label:"Estimated file size",value:Yr(R.estimatedBytes),highlight:R.hasBlockingViolation?"error.main":R.hasWarning?"warning.main":void 0}].map(({label:Q,value:xe,highlight:de})=>e.jsxs(r.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(r.Typography,{sx:{fontSize:"0.8125rem",color:"text.secondary"},children:Q}),e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"0.8125rem",color:de??"text.primary"},children:xe})]},Q))})]})]}),e.jsxs(r.Box,{sx:{px:3,py:1.75,borderTop:"1px solid",borderColor:"divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:k(x.text.primary,.015)},children:[R.hasBlockingViolation&&e.jsxs(r.Box,{sx:{flex:1,display:"flex",alignItems:"center",gap:.75},children:[e.jsx(B.ErrorOutline,{sx:{fontSize:15,color:"error.main"}}),e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"error.main",fontWeight:500},children:"Reduce rows or columns to enable download"})]}),e.jsx(r.Button,{onClick:m,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:2.5,borderRadius:"8px","&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),e.jsxs(r.Button,{onClick:q,disabled:R.hasBlockingViolation,variant:"contained",startIcon:e.jsx(B.Download,{sx:{fontSize:16}}),sx:{fontSize:"0.875rem",px:2.5,borderRadius:"8px"},children:["Download ",K[D]]})]})]})})}function wu({warning:t,onDismiss:o}){return e.jsx(r.Box,{sx:{position:"fixed",top:16,right:16,zIndex:50,maxWidth:448},children:e.jsxs(r.Alert,{severity:"warning",icon:e.jsx(B.Warning,{sx:{fontSize:20}}),action:e.jsx(r.IconButton,{size:"small",onClick:o,sx:{color:"warning.main"},children:e.jsx(B.Close,{sx:{fontSize:16}})}),sx:{borderLeft:4,borderColor:"warning.main",boxShadow:3},children:[e.jsx(r.AlertTitle,{sx:{fontWeight:600},children:"Feature Limit Reached"}),e.jsx(r.Box,{sx:{fontSize:"body2.fontSize",mb:1},children:t.message}),e.jsxs(r.Box,{sx:{fontSize:"caption.fontSize",opacity:.9},children:["Please remove some"," ",t.type==="filter"?"filters":t.type==="sort"?"sort levels":"grouping levels"," ","before adding more."]})]})})}function ku({error:t,onDismiss:o,autoDismiss:n=!0,autoDismissDelay:i=5e3}){p.useEffect(()=>{if(n){const l=setTimeout(()=>{o()},i);return()=>clearTimeout(l)}},[n,i,o]);const d=(()=>{switch(t.type){case"system":return{severity:"error",icon:e.jsx(B.Cancel,{sx:{fontSize:20}})};case"processing":return{severity:"warning",icon:e.jsx(B.Warning,{sx:{fontSize:20}})};case"ui":default:return{severity:"info",icon:e.jsx(B.InfoOutlined,{sx:{fontSize:20}})}}})(),c=$a(t);return e.jsx(r.Box,{sx:{position:"fixed",top:16,right:16,zIndex:50,maxWidth:448},children:e.jsxs(r.Alert,{severity:d.severity,icon:d.icon,action:e.jsx(r.IconButton,{size:"small",onClick:o,sx:{color:`${d.severity}.main`},children:e.jsx(B.Close,{sx:{fontSize:16}})}),sx:{borderLeft:4,borderColor:`${d.severity}.main`,boxShadow:3},children:[e.jsxs(r.AlertTitle,{sx:{fontWeight:600},children:[t.context.charAt(0).toUpperCase()+t.context.slice(1)," Error"]}),e.jsx(r.Box,{sx:{fontSize:"body2.fontSize"},children:c}),t.details&&process.env.NODE_ENV==="development"&&e.jsx(r.Box,{component:"pre",sx:{fontSize:"caption.fontSize",mt:1,fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:JSON.stringify(t.details,null,2)})]})})}class Tu extends p.Component{constructor(n){super(n);bn(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){rr.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:e.jsx(r.Paper,{sx:{bgcolor:s=>k(s.palette.error.main,.12),border:1,borderColor:"error.light",borderRadius:2,p:3,m:2},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.5},children:[e.jsx(B.Warning,{color:"error",sx:{fontSize:24,flexShrink:0}}),e.jsxs(r.Box,{sx:{flex:1},children:[e.jsx(r.Typography,{variant:"h6",sx:{color:"error.main",fontWeight:600},children:this.props.context?`${this.props.context} Error`:"Something went wrong"}),e.jsx(r.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"&&e.jsx(r.Box,{component:"pre",sx:{mt:1.5,fontSize:"caption.fontSize",color:"error.main",bgcolor:s=>k(s.palette.error.main,.12),p:1.5,borderRadius:1,overflow:"auto",maxHeight:170},children:(i=this.state.error)==null?void 0:i.stack}),e.jsx(r.Button,{onClick:this.handleReset,variant:"contained",color:"error",startIcon:e.jsx(B.Refresh,{sx:{fontSize:16}}),sx:{mt:2},children:"Try Again"})]})]})}):this.props.children}}function zu({feature:t}){const[o,n]=p.useState(!0);return p.useEffect(()=>{const i=setTimeout(()=>n(!1),5e3);return()=>clearTimeout(i)},[]),e.jsx(r.Collapse,{in:o,unmountOnExit:!0,children:e.jsxs(r.Alert,{severity:"warning",sx:{m:1},icon:e.jsx(B.Warning,{sx:{fontSize:20}}),action:e.jsx(r.IconButton,{size:"small",onClick:()=>n(!1),"aria-label":"dismiss",sx:{color:"warning.dark"},children:e.jsx(B.Close,{sx:{fontSize:16}})}),children:[e.jsxs(r.AlertTitle,{children:[t," temporarily unavailable"]}),"Other features continue to work normally"]})})}function Lr({children:t,feature:o,onError:n}){return e.jsx(Tu,{context:o,onError:i=>{n&&n(i)},fallback:e.jsx(zu,{feature:o}),children:t})}const Bu=[{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"}],Iu=[{value:"csv",label:"CSV",desc:"Comma-separated values"},{value:"excel",label:"Excel (.xlsx)",desc:"Native Excel format"},{value:"json",label:"JSON",desc:"Structured data with metadata"}];function Fr({children:t,active:o}){return e.jsx(r.Box,{hidden:!o,sx:{pt:2.5,pb:1,display:o?"flex":"none",flexDirection:"column",gap:2.5},children:t})}function Du({open:t,onClose:o,config:n,onApply:i}){const[s,d]=p.useState(0),[c,l]=p.useState(n),u=()=>l(n),f=()=>l(qe),m=()=>{i(c),o()},h={sort:j=>l(w=>({...w,sort:{...w.sort,...j}})),filter:j=>l(w=>({...w,filter:{...w.filter,...j}})),columns:j=>l(w=>({...w,columns:{...w.columns,...j}})),grouping:j=>l(w=>({...w,grouping:{...w.grouping,...j}})),export:j=>l(w=>({...w,export:{...w.export,...j}}))},x=j=>{const w=c.filter.allowedOperators,I=w.includes(j)?w.filter(v=>v!==j):[...w,j];I.length!==0&&h.filter({allowedOperators:I})},b=j=>{const w=c.export.allowedFormats,I=w.includes(j)?w.filter(v=>v!==j):[...w,j];I.length!==0&&h.export({allowedFormats:I})},D=[{label:"Sort",icon:e.jsx(B.SwapVert,{sx:{fontSize:17}})},{label:"Filter",icon:e.jsx(B.FilterList,{sx:{fontSize:17}})},{label:"Columns",icon:e.jsx(B.ViewColumn,{sx:{fontSize:17}})},{label:"Grouping",icon:e.jsx(B.Layers,{sx:{fontSize:17}})},{label:"Export",icon:e.jsx(B.Download,{sx:{fontSize:17}})}],g=j=>JSON.stringify(c[j])===JSON.stringify(qe[j]);return e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"sm",fullWidth:!0,TransitionProps:{onEnter:u},PaperProps:{sx:{borderRadius:j=>Me(j),maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:j=>`0 8px 32px ${k(j.palette.common.black,.2)}`}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[e.jsx(r.Box,{sx:{width:32,height:32,borderRadius:"8px",bgcolor:j=>k(j.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",fontSize:"1.1rem"},children:"⚙️"}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"subtitle1",sx:{fontWeight:600,lineHeight:1.2},children:"Developer Configuration"}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:"Set runtime constraints · Ctrl+Shift+D"})]})]}),e.jsx(r.IconButton,{size:"small",onClick:o,sx:{color:"text.secondary"},children:e.jsx(B.Close,{sx:{fontSize:20}})})]}),e.jsx(r.Box,{sx:{borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:e.jsx(r.Tabs,{value:s,onChange:(j,w)=>d(w),variant:"fullWidth",sx:{minHeight:44,"& .MuiTab-root":{minHeight:44,fontSize:"0.8125rem",textTransform:"none",fontWeight:500,gap:.5}},children:D.map((j,w)=>e.jsx(r.Tab,{label:j.label,icon:j.icon,iconPosition:"start"},w))})}),e.jsxs(r.DialogContent,{sx:{overflowY:"auto",flex:1,px:3,py:0},children:[e.jsxs(Fr,{active:s===0,children:[e.jsxs(r.Box,{children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum sort levels"}),!g("sort")&&e.jsx(r.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users can sort by at most this many columns simultaneously."}),e.jsx(r.Slider,{value:c.sort.maxLevels,onChange:(j,w)=>h.sort({maxLevels:w}),min:1,max:10,step:1,marks:!0,valueLabelDisplay:"on"}),e.jsxs(r.Box,{sx:{display:"flex",justifyContent:"space-between"},children:[e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:"1 level (single)"}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:"10 levels (maximum)"})]})]}),e.jsxs(r.Alert,{severity:"info",sx:{borderRadius:2,fontSize:"0.8125rem"},children:['The "Add sort column" button is hidden once users reach this limit. Default is'," ",e.jsx("strong",{children:"5"}),"."]})]}),e.jsxs(Fr,{active:s===1,children:[e.jsxs(r.Box,{children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum filter conditions"}),!g("filter")&&e.jsx(r.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users can apply at most this many simultaneous filter conditions."}),e.jsx(r.Slider,{value:c.filter.maxConditions,onChange:(j,w)=>h.filter({maxConditions:w}),min:1,max:20,step:1,marks:!0,valueLabelDisplay:"on"}),e.jsxs(r.Box,{sx:{display:"flex",justifyContent:"space-between"},children:[e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:"1 condition"}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:"20 conditions"})]})]}),e.jsx(r.Divider,{}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600,mb:.5},children:"Allowed filter operators"}),e.jsx(r.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(j=>e.jsxs(r.Box,{sx:{mb:1.5},children:[e.jsx(r.Typography,{sx:{fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"text.secondary",fontSize:"0.6875rem",display:"block",mb:.5},children:j}),e.jsx(r.FormGroup,{row:!0,sx:{gap:.5},children:Bu.filter(w=>w.group===j).map(w=>e.jsx(r.FormControlLabel,{control:e.jsx(r.Checkbox,{size:"small",checked:c.filter.allowedOperators.includes(w.value),onChange:()=>x(w.value)}),label:e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem"},children:w.label}),sx:{mr:1.5}},w.value))})]},j))]})]}),e.jsxs(Fr,{active:s===2,children:[e.jsxs(r.Box,{children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum visible columns"}),!g("columns")&&e.jsx(r.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users cannot make more than this many columns visible simultaneously."}),e.jsx(r.Slider,{value:c.columns.maxVisible,onChange:(j,w)=>h.columns({maxVisible:w}),min:1,max:50,step:1,valueLabelDisplay:"on"})]}),e.jsx(r.Divider,{}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600,mb:.5},children:"Column width range (px)"}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users cannot resize columns outside this minimum / maximum range."}),e.jsxs(r.Box,{sx:{display:"flex",gap:2},children:[e.jsxs(r.Box,{sx:{flex:1},children:[e.jsx(r.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Minimum width"}),e.jsx(r.Slider,{value:c.columns.minColumnWidth,onChange:(j,w)=>h.columns({minColumnWidth:w}),min:40,max:400,step:10,valueLabelDisplay:"on",valueLabelFormat:j=>`${j}px`})]}),e.jsxs(r.Box,{sx:{flex:1},children:[e.jsx(r.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Maximum width"}),e.jsx(r.Slider,{value:c.columns.maxColumnWidth,onChange:(j,w)=>h.columns({maxColumnWidth:w}),min:100,max:2e3,step:50,valueLabelDisplay:"on",valueLabelFormat:j=>`${j}px`})]})]})]})]}),e.jsxs(Fr,{active:s===3,children:[e.jsxs(r.Box,{children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum group levels"}),!g("grouping")&&e.jsx(r.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),e.jsx(r.Box,{sx:{display:"flex",gap:1.5,mb:2},children:[1,2,3].map(j=>e.jsxs(r.Box,{onClick:()=>h.grouping({maxLevels:j}),sx:{flex:1,py:2.5,borderRadius:"10px",border:"2px solid",cursor:"pointer",textAlign:"center",transition:"all 0.15s ease",borderColor:c.grouping.maxLevels===j?"primary.main":"divider",bgcolor:c.grouping.maxLevels===j?w=>k(w.palette.primary.main,.06):"transparent","&:hover":{borderColor:"primary.light",bgcolor:w=>k(w.palette.primary.main,.04)}},children:[e.jsx(r.Typography,{variant:"h5",sx:{fontWeight:700,color:c.grouping.maxLevels===j?"primary.main":"text.secondary"},children:j}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:["Single","Double","Triple"][j-1]})]},j))}),e.jsxs(r.FormGroup,{row:!0,sx:{gap:2},children:[e.jsx(r.FormControlLabel,{control:e.jsx(r.Checkbox,{checked:c.grouping.allowNested,onChange:j=>h.grouping({allowNested:j.target.checked})}),label:e.jsx(r.Typography,{variant:"body2",children:"Allow nested groups"})}),e.jsx(r.FormControlLabel,{control:e.jsx(r.Checkbox,{checked:c.grouping.allowCollapse,onChange:j=>h.grouping({allowCollapse:j.target.checked})}),label:e.jsx(r.Typography,{variant:"body2",children:"Allow collapse / expand"})})]})]}),e.jsx(r.Alert,{severity:"info",sx:{borderRadius:2,fontSize:"0.8125rem"},children:'The "Add group level" button is hidden when users reach the configured limit.'})]}),e.jsx(Fr,{active:s===4,children:e.jsxs(r.Box,{children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600},children:"Allowed export formats"}),!g("export")&&e.jsx(r.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),e.jsx(r.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."}),e.jsx(r.FormGroup,{sx:{gap:1},children:Iu.map(j=>e.jsxs(r.Box,{onClick:()=>b(j.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(j.value)?"primary.main":"divider",bgcolor:c.export.allowedFormats.includes(j.value)?w=>k(w.palette.primary.main,.04):"transparent","&:hover":{borderColor:"primary.light"}},children:[e.jsx(r.Checkbox,{size:"small",checked:c.export.allowedFormats.includes(j.value),onChange:()=>b(j.value),onClick:w=>w.stopPropagation()}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500},children:j.label}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:j.desc})]})]},j.value))})]})})]}),e.jsxs(r.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid",borderColor:"divider",bgcolor:j=>k(j.palette.action.hover,.4),justifyContent:"space-between",flexShrink:0},children:[e.jsx(r.Button,{startIcon:e.jsx(B.RestartAlt,{sx:{fontSize:18}}),onClick:f,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary","&:hover":{color:"text.primary",bgcolor:j=>k(j.palette.text.primary,.06)}},children:"Reset to defaults"}),e.jsxs(r.Box,{sx:{display:"flex",gap:1},children:[e.jsx(r.Button,{onClick:o,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px"},children:"Cancel"}),e.jsx(r.Button,{onClick:m,size:"small",variant:"contained",sx:{fontSize:"0.875rem",px:2.5,borderRadius:"18px"},children:"Apply"})]})]})]})}const Eu=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Ou={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 xo(t,o,n,i,s=new Date){const[d,c]=o.split(":").map(Number),l=new Date(s);if(l.setSeconds(0,0),l.setHours(d,c,0,0),t==="daily")return l<=s&&l.setDate(l.getDate()+1),l.toISOString();if(t==="weekly"){const u=n??1,f=l.getDay();let m=u-f;return m<0&&(m+=7),m===0&&l<=s&&(m=7),l.setDate(l.getDate()+m),l.toISOString()}if(t==="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 Au(t){const o=es(t.time);return t.frequency==="daily"?`Daily at ${o}`:t.frequency==="weekly"?`Every ${Eu[t.dayOfWeek??1]} at ${o}`:t.frequency==="monthly"?`Monthly on the ${Ou[t.dayOfMonth??1]??`${t.dayOfMonth}th`} at ${o}`:o}function es(t){const[o,n]=t.split(":").map(Number),i=o>=12?"PM":"AM";return`${o%12||12}:${String(n).padStart(2,"0")} ${i}`}function $u(t){const o=new Date(t).getTime()-Date.now();if(o<=0)return"now";const n=Math.floor(o/1e3),i=Math.floor(n/86400),s=Math.floor(n%86400/3600),d=Math.floor(n%3600/60);return i>0?`in ${i}d ${s}h`:s>0?`in ${s}h ${d}m`:d>0?`in ${d}m`:"in less than a minute"}function Mu(t){const o=new Date(t),n=new Date,i=o.toDateString()===n.toDateString(),s=es(`${String(o.getHours()).padStart(2,"0")}:${String(o.getMinutes()).padStart(2,"0")}`);return i?`Today at ${s}`:`${o.toLocaleDateString("en-US",{month:"short",day:"numeric"})} at ${s}`}function ts(t){return`urm_schedules_${t}`}function rs(t){try{const o=localStorage.getItem(ts(t));return o?JSON.parse(o).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 os(t,o){try{localStorage.setItem(ts(t),JSON.stringify(o))}catch{}}const Ru=[{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"}],_u=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,ns={name:"",frequency:"daily",dayOfWeek:1,dayOfMonth:1,time:"09:00",format:"csv",scope:"all",email:""},tr={"& .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 Wu({initial:t=ns,isEditing:o=!1,onSave:n,onBack:i}){const[s,d]=p.useState(t),[c,l]=p.useState(!1),[u,f]=p.useState(!1),m=(b,D)=>d(g=>({...g,[b]:D})),h=s.email.trim().length>0&&!_u.test(s.email.trim()),x=s.name.trim().length>0&&/^\d{2}:\d{2}$/.test(s.time)&&(s.frequency!=="monthly"||s.dayOfMonth>=1&&s.dayOfMonth<=28)&&!h;return e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5,mb:.5},children:[e.jsx(r.IconButton,{size:"small",onClick:i,sx:{color:"text.secondary",ml:-.75,"&:hover":{bgcolor:b=>k(b.palette.text.primary,.06)}},children:e.jsx(B.ArrowBack,{sx:{fontSize:18}})}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600},children:o?"Edit schedule":"New schedule"})]}),e.jsx(r.TextField,{label:"Schedule name *",size:"small",fullWidth:!0,value:s.name,onChange:b=>{m("name",b.target.value),c&&b.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:tr}),e.jsxs(r.FormControl,{size:"small",fullWidth:!0,sx:tr,children:[e.jsx(r.InputLabel,{children:"Frequency"}),e.jsxs(r.Select,{value:s.frequency,label:"Frequency",onChange:b=>m("frequency",b.target.value),children:[e.jsx(r.MenuItem,{value:"daily",children:"Daily"}),e.jsx(r.MenuItem,{value:"weekly",children:"Weekly"}),e.jsx(r.MenuItem,{value:"monthly",children:"Monthly"})]})]}),s.frequency==="weekly"&&e.jsxs(r.FormControl,{size:"small",fullWidth:!0,sx:tr,children:[e.jsx(r.InputLabel,{children:"Day of week"}),e.jsx(r.Select,{value:s.dayOfWeek,label:"Day of week",onChange:b=>m("dayOfWeek",Number(b.target.value)),children:Ru.map(b=>e.jsx(r.MenuItem,{value:b.value,children:b.label},b.value))})]}),s.frequency==="monthly"&&e.jsx(r.TextField,{label:"Day of month (1–28)",size:"small",type:"number",fullWidth:!0,value:s.dayOfMonth,onChange:b=>m("dayOfMonth",Number(b.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:tr}),e.jsx(r.TextField,{label:"Time",size:"small",type:"time",fullWidth:!0,value:s.time,onChange:b=>m("time",b.target.value),InputLabelProps:{shrink:!0},helperText:"24-hour format · Tab must be open for the schedule to fire",sx:tr}),e.jsxs(r.FormControl,{size:"small",fullWidth:!0,sx:tr,children:[e.jsx(r.InputLabel,{children:"Export format"}),e.jsxs(r.Select,{value:s.format,label:"Export format",onChange:b=>m("format",b.target.value),children:[e.jsx(r.MenuItem,{value:"csv",children:"CSV — Comma-separated values"}),e.jsx(r.MenuItem,{value:"excel",children:"Excel (.xlsx) — Native format"}),e.jsx(r.MenuItem,{value:"json",children:"JSON — Structured data"})]})]}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"caption",sx:{fontWeight:500,color:"text.secondary",display:"block",mb:.75},children:"Data scope"}),e.jsxs(r.RadioGroup,{row:!0,value:s.scope,onChange:b=>m("scope",b.target.value),sx:{gap:2},children:[e.jsx(r.FormControlLabel,{value:"all",control:e.jsx(r.Radio,{size:"small"}),label:e.jsx(r.Typography,{variant:"body2",children:"All rows"})}),e.jsx(r.FormControlLabel,{value:"visible",control:e.jsx(r.Radio,{size:"small"}),label:e.jsx(r.Typography,{variant:"body2",children:"Filtered rows only"})})]})]}),e.jsxs(r.Box,{children:[e.jsx(r.TextField,{label:"Email reminder (optional)",size:"small",fullWidth:!0,type:"email",value:s.email,onChange:b=>m("email",b.target.value),onBlur:()=>f(!0),placeholder:"user@company.com",error:u&&h,helperText:u&&h?"Enter a valid email address":void 0,InputProps:{startAdornment:e.jsx(B.Email,{sx:{fontSize:15,color:"text.disabled",mr:1}})},sx:tr}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"flex-start",gap:.5,mt:.5,px:.5},children:[e.jsx(B.InfoOutlined,{sx:{fontSize:12,color:"text.disabled",mt:.2,flexShrink:0}}),e.jsx(r.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."})]})]}),e.jsxs(r.Box,{sx:{display:"flex",justifyContent:"flex-end",gap:1,pt:.5},children:[e.jsx(r.Button,{onClick:i,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px","&:hover":{bgcolor:b=>k(b.palette.text.primary,.06)}},children:"Cancel"}),e.jsx(r.Button,{onClick:()=>x&&n(s),disabled:!x,size:"small",variant:"contained",sx:{fontSize:"0.875rem",px:2.5,borderRadius:"18px"},children:o?"Save changes":"Create schedule"})]})]})}function Pu({scheduleName:t,onConfirm:o,onCancel:n}){return e.jsxs(r.Dialog,{open:!0,onClose:n,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:i=>Xr(i),boxShadow:i=>{var s;return`0 8px 32px ${k(((s=i.palette.common)==null?void 0:s.black)??"#000",.14)}`}}},children:[e.jsxs(r.DialogContent,{sx:{pt:3,pb:2,px:3},children:[e.jsx(r.Box,{sx:{width:44,height:44,borderRadius:"12px",bgcolor:i=>k(i.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(B.WarningAmberOutlined,{sx:{fontSize:22,color:"error.main"}})}),e.jsx(r.Typography,{sx:{fontSize:"0.9375rem",fontWeight:600,color:"text.primary",mb:1},children:"Delete Schedule"}),e.jsxs(r.Typography,{sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.65},children:["Are you sure you want to delete"," ",e.jsxs(r.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:['"',t,'"']}),"? This action cannot be undone."]})]}),e.jsx(r.Divider,{}),e.jsxs(r.DialogActions,{sx:{px:2.5,py:1.5,gap:1},children:[e.jsx(r.Button,{onClick:n,variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",borderRadius:i=>`${i.shape.borderRadius}px`,"&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),e.jsx(r.Button,{onClick:o,variant:"contained",color:"error",sx:{fontSize:"0.8125rem",borderRadius:i=>`${i.shape.borderRadius}px`,px:2},children:"Delete"})]})]})}function Nu({schedule:t,tick:o,onToggle:n,onRunNow:i,onEdit:s,onDelete:d}){const c=t.isActive;return e.jsxs(r.Box,{sx:{border:"1px solid",borderColor:c?"primary.main":"divider",borderRadius:"10px",p:1.75,bgcolor:c?l=>k(l.palette.primary.main,.025):"background.paper",transition:"border-color 0.15s ease, background-color 0.15s ease"},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600,flex:1,minWidth:0,color:c?"text.primary":"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.name}),e.jsx(r.Chip,{label:c?"Active":"Paused",size:"small",sx:{height:18,fontSize:"0.6875rem",fontWeight:600,flexShrink:0,bgcolor:c?l=>k(l.palette.success.main,.1):l=>k(l.palette.text.primary,.06),color:c?"success.dark":"text.secondary"}})]}),e.jsx(r.Typography,{variant:"caption",sx:{color:"text.secondary",display:"block",mb:1},children:Au(t)}),e.jsxs(r.Box,{sx:{display:"flex",flexWrap:"wrap",gap:.5,mb:1},children:[e.jsx(r.Chip,{label:t.format.toUpperCase(),size:"small",sx:{height:20,fontSize:"0.6875rem",fontWeight:500,bgcolor:l=>k(l.palette.primary.main,.08),color:"primary.main"}}),e.jsx(r.Chip,{label:t.scope==="all"?"All rows":"Filtered rows",size:"small",sx:{height:20,fontSize:"0.6875rem",bgcolor:l=>k(l.palette.text.primary,.06),color:"text.secondary"}}),t.email&&e.jsx(r.Chip,{icon:e.jsx(B.Email,{sx:{fontSize:11}}),label:t.email,size:"small",sx:{height:20,fontSize:"0.6875rem",maxWidth:220,bgcolor:l=>k(l.palette.text.primary,.06),color:"text.secondary","& .MuiChip-label":{overflow:"hidden",textOverflow:"ellipsis"}}})]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:1},children:[e.jsxs(r.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1.5,alignItems:"center"},children:[c&&e.jsxs(r.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:500},children:["Next: ",$u(t.nextRunAt)]}),t.lastRunAt?e.jsxs(r.Typography,{variant:"caption",color:"text.secondary",children:["Last: ",Mu(t.lastRunAt)," · ",t.runCount," run",t.runCount!==1?"s":""]}):e.jsx(r.Typography,{variant:"caption",color:"text.disabled",children:"Never run"})]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.25,flexShrink:0},children:[e.jsx(r.Tooltip,{title:"Edit",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:()=>s(t),sx:{color:"text.secondary","&:hover":{color:"primary.main",bgcolor:l=>k(l.palette.primary.main,.08)}},children:e.jsx(B.Edit,{sx:{fontSize:15}})})}),e.jsx(r.Tooltip,{title:c?"Pause":"Resume",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:()=>n(t.id),sx:{color:c?"warning.main":"success.main","&:hover":{bgcolor:c?l=>k(l.palette.warning.main,.08):l=>k(l.palette.success.main,.08)}},children:c?e.jsx(B.Pause,{sx:{fontSize:15}}):e.jsx(B.PlayArrow,{sx:{fontSize:15}})})}),e.jsx(r.Tooltip,{title:"Export now",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:()=>i(t),sx:{color:"primary.main","&:hover":{bgcolor:l=>k(l.palette.primary.main,.08)}},children:e.jsx(B.Download,{sx:{fontSize:15}})})}),e.jsx(r.Tooltip,{title:"Delete",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:()=>d(t.id),sx:{color:"error.main","&:hover":{bgcolor:l=>k(l.palette.error.main,.08)}},children:e.jsx(B.Delete,{sx:{fontSize:15}})})})]})]})]})}function Lu({open:t,onClose:o,reportId:n,reportName:i,onRunNow:s}){const[d,c]=p.useState([]),[l,u]=p.useState({type:"list"}),[f,m]=p.useState(0),[h,x]=p.useState(null);p.useEffect(()=>{t&&(c(rs(n)),u({type:"list"}))},[t,n]),p.useEffect(()=>{if(!t)return;const z=setInterval(()=>m(R=>R+1),3e4);return()=>clearInterval(z)},[t]);const b=p.useCallback(z=>{c(z),os(n,z)},[n]),D=z=>{const R=xo(z.frequency,z.time,z.dayOfWeek,z.dayOfMonth),q={id:`sched-${Date.now()}`,reportId:n,name:z.name.trim(),frequency:z.frequency,dayOfWeek:z.frequency==="weekly"?z.dayOfWeek:void 0,dayOfMonth:z.frequency==="monthly"?z.dayOfMonth:void 0,time:z.time,format:z.format,scope:z.scope,email:z.email.trim()||void 0,isActive:!0,createdAt:new Date().toISOString(),nextRunAt:R,runCount:0};b([...d,q]),u({type:"list"})},g=z=>{if(l.type!=="edit")return;const R=l.schedule,q=xo(z.frequency,z.time,z.dayOfWeek,z.dayOfMonth);b(d.map(K=>K.id===R.id?{...R,name:z.name.trim(),frequency:z.frequency,dayOfWeek:z.frequency==="weekly"?z.dayOfWeek:void 0,dayOfMonth:z.frequency==="monthly"?z.dayOfMonth:void 0,time:z.time,format:z.format,scope:z.scope,email:z.email.trim()||void 0,nextRunAt:q}:K)),u({type:"list"})},j=z=>{b(d.map(R=>{if(R.id!==z)return R;const q=R.isActive?R.nextRunAt:xo(R.frequency,R.time,R.dayOfWeek,R.dayOfMonth);return{...R,isActive:!R.isActive,nextRunAt:q}}))},w=z=>{s(z);const R=new Date().toISOString();b(d.map(q=>q.id===z.id?{...q,lastRunAt:R,runCount:q.runCount+1}:q))},I=z=>{const R=d.find(q=>q.id===z)??null;x(R)},v=()=>{h&&(b(d.filter(z=>z.id!==h.id)),x(null))},S=z=>({name:z.name,frequency:z.frequency,dayOfWeek:z.dayOfWeek??1,dayOfMonth:z.dayOfMonth??1,time:z.time,format:z.format,scope:z.scope,email:z.email??""}),C=l.type!=="list",a=d.filter(z=>z.isActive).length;return e.jsxs(e.Fragment,{children:[e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"sm",fullWidth:!0,disableEscapeKeyDown:C,PaperProps:{sx:{borderRadius:z=>Me(z),maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:6}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",py:1.5,px:2.5,borderBottom:"1px solid",borderColor:"divider",flexShrink:0,minHeight:0},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[e.jsx(r.Box,{sx:{width:30,height:30,borderRadius:"7px",bgcolor:z=>k(z.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(B.Schedule,{sx:{fontSize:17,color:"primary.main"}})}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"baseline",gap:.75},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx(r.Typography,{variant:"subtitle2",sx:{fontWeight:600,lineHeight:1},children:"Scheduled Reports"}),e.jsx(ir,{content:sr.schedule,isDev:process.env.NODE_ENV==="development"})]}),e.jsxs(r.Typography,{variant:"caption",color:"text.secondary",sx:{lineHeight:1},children:["· ",i]})]})]}),e.jsx(r.IconButton,{size:"small",onClick:o,sx:{color:"text.secondary","&:hover":{bgcolor:z=>k(z.palette.text.primary,.06)}},children:e.jsx(B.Close,{sx:{fontSize:18}})})]}),e.jsxs(r.DialogContent,{sx:{overflowY:"auto",flex:1,px:2.5,py:2},children:[C&&e.jsx(Wu,{initial:l.type==="edit"?S(l.schedule):ns,isEditing:l.type==="edit",onSave:l.type==="edit"?g:D,onBack:()=>u({type:"list"})}),l.type==="list"&&e.jsxs(e.Fragment,{children:[e.jsxs(r.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1.75,pt:1.5},children:[e.jsx(r.Typography,{variant:"body2",color:"text.secondary",children:d.length===0?"No schedules yet":`${a} of ${d.length} active`}),e.jsx(r.Button,{startIcon:e.jsx(B.Add,{sx:{fontSize:15}}),size:"small",variant:"contained",onClick:()=>u({type:"create"}),sx:{fontSize:"0.8125rem",borderRadius:"18px",px:1.75,py:.625},children:"New schedule"})]}),d.length===0?e.jsxs(r.Box,{sx:{border:"1.5px dashed",borderColor:"divider",borderRadius:"10px",py:5,px:2,textAlign:"center"},children:[e.jsx(B.NotificationsActive,{sx:{fontSize:30,color:"text.disabled",mb:1.25,display:"block",mx:"auto"}}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,color:"text.secondary"},children:"No scheduled reports yet"}),e.jsx(r.Typography,{variant:"caption",color:"text.disabled",sx:{display:"block",mt:.5},children:'Use "New schedule" above to set up automatic exports'})]}):e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:d.map(z=>e.jsx(Nu,{schedule:z,tick:f,onToggle:j,onRunNow:w,onEdit:R=>u({type:"edit",schedule:R}),onDelete:I},z.id))})]})]}),l.type==="list"&&e.jsxs(r.DialogActions,{sx:{px:2.5,py:1.25,borderTop:"1px solid",borderColor:"divider",flexShrink:0,display:"flex",alignItems:"center",gap:1},children:[e.jsxs(r.Box,{sx:{flex:1,display:"flex",alignItems:"center",gap:.75,px:1.25,py:.75,borderRadius:"8px",bgcolor:z=>k(z.palette.warning.main,.06),border:"1px solid",borderColor:z=>k(z.palette.warning.main,.2)},children:[e.jsx(B.Schedule,{sx:{fontSize:13,color:"warning.main",flexShrink:0}}),e.jsx(r.Typography,{variant:"caption",sx:{color:"warning.dark",lineHeight:1.1},children:"Schedules require this browser tab to remain open."})]}),e.jsx(r.Button,{onClick:o,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px",flexShrink:0,"&:hover":{bgcolor:z=>k(z.palette.text.primary,.06)}},children:"Close"})]})]}),h&&e.jsx(Pu,{scheduleName:h.name,onConfirm:v,onCancel:()=>x(null)})]})}const Fu=6e4;function Vu({reportId:t,reportName:o,uploadedData:n,processedData:i,schema:s,activeView:d,columnVisibility:c,columnOrder:l,filters:u,sortStack:f,onFired:m}){const h=p.useRef({reportId:t,reportName:o,uploadedData:n,processedData:i,schema:s,activeView:d,columnVisibility:c,columnOrder:l,filters:u,sortStack:f,onFired:m});p.useEffect(()=>{h.current={reportId:t,reportName:o,uploadedData:n,processedData:i,schema:s,activeView:d,columnVisibility:c,columnOrder:l,filters:u,sortStack:f,onFired:m}});const x=p.useCallback(b=>{var z,R;const{reportName:D,uploadedData:g,processedData:j,schema:w,activeView:I,columnVisibility:v,columnOrder:S,filters:C,sortStack:a}=h.current;try{const q=b.scope==="all"?g:j,K=mo(q,w,C,a,I,v,S),ee=`${b.name}_scheduled`;switch(b.format){case"csv":ho(K,ee,{scope:b.scope});break;case"excel":fo(K,ee,{scope:b.scope});break;case"json":go(K,ee,{scope:b.scope});break}if(b.email){const y=encodeURIComponent(`Scheduled Report: ${b.name}`),M=encodeURIComponent(`Your scheduled report "${b.name}" has been generated.
90
90
 
91
91
  Report: ${D}
92
- Format: ${y.format.toUpperCase()}
92
+ Format: ${b.format.toUpperCase()}
93
93
  Generated: ${new Date().toLocaleString()}
94
94
 
95
- The file has been downloaded to your device.`);window.open(`mailto:${y.email}?subject=${g}&body=${M}`,"_blank")}(R=(B=b.current).onFired)==null||R.call(B,y)}catch(J){cr.error("urm:scheduler",`Export failed for schedule: ${y.name}`,J)}},[]);p.useEffect(()=>{if(!t)return;const y=()=>{const{reportId:v}=b.current;if(!v)return;const C=ns(v),S=new Date;let I=!1;const f=C.map(k=>{if(!k.isActive)return k;if(new Date(k.nextRunAt)<=S){x(k);const a=vo(k.frequency,k.time,k.dayOfWeek,k.dayOfMonth,S);return I=!0,{...k,lastRunAt:S.toISOString(),nextRunAt:a,runCount:k.runCount+1}}return k});I&&is(v,f)};y();const D=setInterval(y,Uu);return()=>clearInterval(D)},[t,x])}function as({reportEngine:t}){var Sr,jr,Cr,ir,wr;const{activeReport:o,paginatedData:n,processedData:i,tableMetrics:s,tableEngine:d,activeView:l,isDirty:c,currentTableState:u,viewChanges:h,showFilterPanel:m,setShowFilterPanel:b,filterFocusColumn:x,handleAddFilter:y,handleUpdateFilter:D,handleRemoveFilter:v,handleClearAllFilters:C,handleReplaceFilters:S,handleOpenFilterForColumn:I,handleCloseFilterPanel:f,handleClearFiltersForColumn:k,showSortPanel:j,setShowSortPanel:a,handleSort:B,handleUpdateSortStack:R,handleSortAscending:J,handleSortDescending:K,showManageViews:ee,setShowManageViews:g,showCreateViewModal:M,setShowCreateViewModal:W,showEditViewModal:V,setShowEditViewModal:Q,showDeleteConfirmation:xe,setShowDeleteConfirmation:me,editingView:L,deletingView:A,handleSelectView:H,handleCreateView:se,handleUpdateCurrentView:G,handleSaveColumnConfigToCurrentView:re,handleSaveColumnConfigToAllViews:ae,handleSaveAsNewView:ne,handleRevertChanges:P,handleToggleDefault:ie,handleToggleFavorite:pe,handleSoftDelete:le,handleRestoreView:ge,handlePermanentDelete:q,handleEditView:_e,handleSaveEditView:et,handleConfirmDelete:tt,handlePromoteToGlobal:_t,showManageColumns:mr,setShowManageColumns:Mt,handleUpdateColumnVisibility:Rt,handleUpdateColumnOrder:Wt,handleUpdateColumnWidth:pt,handleResetColumnLayout:Ve,showGroupPanel:qe,setShowGroupPanel:Ue,handleGroup:rt,handleToggleGroupCollapse:Je,searchQuery:ot,debouncedSearchQuery:wt,searchHistory:He,handleSearchChange:lt,handleAddToSearchHistory:Re,handleToggleSearchFavourite:Or,handleDeleteSearchHistory:$r,selectedRowIds:qt,handleToggleRowSelection:hr,handleToggleAllRows:Pt,handleRangeSelection:xt,handleClearSelection:Nt,handleUpdateSelectionAfterDelete:fr,currentPage:kt,pageSize:Ar,paginationEngine:Ye,handlePageChange:gr,handlePageSizeChange:_r,isExporting:Jt,showExportModal:Ce,setShowExportModal:Mr,showDirtyExportWarning:yr,handleExport:ct,handleExportWithConfig:F,handleExportSelected:Ge,handleExportAnyway:we,handleSaveAndExport:Pe,handleCancelExport:Rr,showAuditHistory:Kt,setShowAuditHistory:mt,showCreatePreset:Xt,setShowCreatePreset:Qt,showManagePresets:Zt,setShowManagePresets:Wr,activePreset:Lt,handleCreatePreset:ze,handleClearActivePreset:Z,handleOpenPresetById:ht,handleDeletePresetById:ke,isViewerRole:ye,userRole:nt,featureLimitWarning:er,setFeatureLimitWarning:ft,reportError:Le,setReportError:br,handleError:Tt,updateReport:dt,showSnack:It,favoriteRowIndices:Pr,resolvedFavoritesSet:tr,showFavoritesOnly:rr,handleToggleRowFavorite:Ft,handleBulkSetFavorites:vr,handleToggleFavoritesFilter:Ne}=t,[gt,or]=p.useState(!1);Yu({reportId:o==null?void 0:o.id,reportName:(o==null?void 0:o.name)||"Report",uploadedData:(o==null?void 0:o.uploadedData)||[],processedData:i||[],schema:(o==null?void 0:o.schema)||[],activeView:l,columnVisibility:(o==null?void 0:o.columnVisibility)||((Sr=l==null?void 0:l.snapshot)==null?void 0:Sr.columnVisibility)||{},columnOrder:(o==null?void 0:o.columnOrder)||((jr=l==null?void 0:l.snapshot)==null?void 0:jr.columnOrder)||[],filters:(o==null?void 0:o.filters)||[],sortStack:(o==null?void 0:o.sortStack)||[],onFired:de=>{It(`Scheduled export "${de.name}" completed`,"success")}});const yt=p.useCallback((de,ce)=>{if(!(o!=null&&o.uploadedData))return;const De=[...o.uploadedData];De[de]=ce,dt(o.id,{uploadedData:De})},[o,dt]),Nr=p.useCallback(de=>{if(!(o!=null&&o.uploadedData))return;const ce=o.uploadedData.indexOf(de);if(ce===-1)return;const De=o.uploadedData.filter((it,zt)=>zt!==ce),ut=(o.favoriteRowIndices||[]).filter(it=>it!==ce).map(it=>it>ce?it-1:it);dt(o.id,{uploadedData:De,favoriteRowIndices:ut}),fr(de)},[o,dt,fr]),Lr=p.useCallback((de,ce)=>{if(!(o!=null&&o.uploadedData))return;const De=o.uploadedData.indexOf(ce),ut=De!==-1?De+1:de+1,it=[...o.uploadedData];it.splice(ut,0,{...ce});const Hr=(o.favoriteRowIndices??[]).map(Ht=>Ht>=ut?Ht+1:Ht);dt(o.id,{uploadedData:it,favoriteRowIndices:Hr})},[o,dt]),Vt=ur(),{handleDevConfigChange:Fr}=Bo(),[Vr,nr]=p.useState(!1);return p.useEffect(()=>{const de=ce=>{ce.ctrlKey&&ce.shiftKey&&ce.key==="D"&&(ce.preventDefault(),nr(!0))};return document.addEventListener("keydown",de),()=>document.removeEventListener("keydown",de)},[]),!o||!o.schemaLocked||!o.schema||!o.uploadedData||!o.views?null:e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,position:"relative"},children:[!ye&&c&&l&&e.jsx(du,{viewName:l.name,isDefaultView:l.isDefault,changes:h,onSaveToCurrentView:l.isDefault?void 0:G,onSaveAsNewView:ne,onCancel:P}),e.jsxs(r.Box,{id:"table-content-area",sx:{flex:1,minHeight:0,display:"flex",flexDirection:"column",position:"relative"},children:[er&&e.jsx(Iu,{warning:er,onDismiss:()=>ft(null)}),Le&&e.jsx(zu,{error:Le,onDismiss:()=>br(null)}),yr&&e.jsx(uu,{onExportAnyway:we,onSaveAndExport:Pe,onCancel:Rr}),e.jsx(Zd,{schema:o.schema,data:n,sortStack:o.sortStack,filters:o.filters,views:o.views,activeViewId:o.activeViewId,isDirty:c,isExporting:Jt,columnVisibility:o.columnVisibility||(l==null?void 0:l.snapshot.columnVisibility),columnOrder:o.columnOrder||(l==null?void 0:l.snapshot.columnOrder),columnWidths:o.columnWidths||(l==null?void 0:l.snapshot.columnWidths),grouping:o.grouping,onSort:B,onSortAscending:J,onSortDescending:K,onOpenFilters:()=>b(!0),onOpenSort:()=>a(!0),onOpenFilterForColumn:I,onSelectView:H,onCreateView:()=>W(!0),onManageViews:()=>g(!0),onUpdateCurrentView:G,onSaveAsNewView:ne,onToggleDefault:ie,onToggleFavorite:pe,onRestoreView:ge,onPermanentDelete:q,onExport:ct,onOpenColumns:()=>Mt(!0),onUpdateColumnWidth:pt,onUpdateColumnOrder:Wt,onUpdateColumnVisibility:Rt,onClearFiltersForColumn:k,onResetLayout:Ve,onOpenGroup:()=>Ue(!0),onGroupByColumn:de=>{rt({enabled:!0,levels:[{column:de}],collapsedGroups:[]})},onToggleGroupCollapse:Je,onOpenAuditHistory:()=>mt(!0),onOpenScheduledReports:()=>or(!0),searchQuery:ot,highlightQuery:wt,searchHistory:He,onAddToSearchHistory:Re,onToggleSearchFavourite:Or,onDeleteSearchHistory:$r,selectedRowIds:qt,onSearchChange:lt,onToggleRowSelection:hr,onToggleAllRows:Pt,onRangeSelection:xt,onClearSelection:Nt,onExportSelected:Ge,currentPage:(Ye==null?void 0:Ye.currentPage)||kt,pageSize:(Ye==null?void 0:Ye.pageSize)||Ar,onPageChange:gr,onPageSizeChange:_r,totalRowsBeforePagination:(s==null?void 0:s.searchedRows)||i.length,isReadOnly:ye,userRole:nt,reportName:o.name,onEditRow:yt,onDeleteRow:Nr,onDuplicateRow:Lr,favoriteRowIndices:Pr,resolvedFavoritesSet:tr,showFavoritesOnly:rr,onToggleRowFavorite:Ft,onBulkSetFavorites:vr,onToggleFavoritesFilter:Ne,showDevPanel:Vt.display.showDevPanel,onOpenDevConfig:()=>nr(!0)})]}),m&&e.jsx(Kr,{feature:"Filters",onError:de=>{const ce=Et("ui","filters",de);Tt(ce)},children:e.jsx(eu,{schema:o.schema,filters:o.filters??[],onAddFilter:y,onUpdateFilter:D,onRemoveFilter:v,onClearAll:C,onReplaceFilters:S,onClose:f,focusColumn:x})}),j&&e.jsx(Kr,{feature:"Sorting",onError:de=>{const ce=Et("ui","sorting",de);Tt(ce)},children:e.jsx(ru,{schema:o.schema,sortStack:o.sortStack??[],onUpdateSortStack:R,onClose:()=>a(!1)})}),ee&&e.jsx(Kr,{feature:"Views",onError:de=>{const ce=Et("ui","views",de);Tt(ce)},children:e.jsx(ou,{views:o.views,activeViewId:o.activeViewId??"",onSelectView:H,onCreateView:()=>{g(!1),W(!0)},onEditView:_e,onDeleteView:le,onRestoreView:ge,onPermanentDelete:q,onPromoteToGlobal:_t,isAdmin:((Cr=Vt.views)==null?void 0:Cr.isAdmin)??!1,onClose:()=>g(!1)})}),M&&u&&(()=>{var De;const de=(o.views??[]).filter(ut=>!ut.isDeleted).length,ce=((De=Vt.views)==null?void 0:De.maxViews)??10;return e.jsx(hi,{currentSnapshot:u,onSave:se,onClose:()=>W(!1),atViewLimit:de>=ce,maxViews:ce})})(),V&&L&&e.jsx(hi,{currentSnapshot:L.snapshot,onSave:et,onClose:()=>{Q(!1)},isEditMode:!0,initialName:L.name,initialDescription:L.description,initialIsDefault:L.isDefault}),xe&&A&&e.jsx(nu,{viewName:A.name,onConfirm:tt,onCancel:()=>{me(!1)}}),mr&&l&&e.jsx(su,{schema:o.schema,columnVisibility:o.columnVisibility||l.snapshot.columnVisibility,columnOrder:o.columnOrder||l.snapshot.columnOrder,columnWidths:o.columnWidths||l.snapshot.columnWidths,views:o.views,activeViewId:o.activeViewId,onUpdateColumnVisibility:Rt,onUpdateColumnOrder:Wt,onUpdateColumnWidth:pt,onResetLayout:Ve,onSelectView:de=>{H(de)},onSaveToCurrentView:de=>{re(de),Mt(!1)},onSaveToAllViews:de=>{ae(de),Mt(!1)},onClose:()=>Mt(!1)}),qe&&e.jsx(Kr,{feature:"Grouping",onError:de=>{const ce=Et("ui","grouping",de);Tt(ce)},children:e.jsx(au,{schema:o.schema,grouping:o.grouping||null,onApply:rt,onClose:()=>Ue(!1)})}),Kt&&e.jsx(mu,{auditHistory:o.auditHistory||[],onClose:()=>mt(!1)}),Xt&&e.jsx(hu,{onSave:ze,onClose:()=>Qt(!1)}),Zt&&e.jsx(gu,{presets:o.presets||[],reportId:o.id,onOpenPreset:ht,onDeletePreset:ke,onClose:()=>Wr(!1)}),Lt&&e.jsx(r.Box,{sx:{mt:2},children:e.jsx(fu,{presetName:Lt.name,onClear:Z})}),Ce&&e.jsx(Kr,{feature:"Export",onError:de=>{const ce=Et("ui","export",de);Tt(ce)},children:e.jsx(Tu,{totalRows:(s==null?void 0:s.totalRows)||((ir=o.uploadedData)==null?void 0:ir.length)||0,visibleRows:(s==null?void 0:s.searchedRows)||i.length,visibleColumnsCount:((wr=d==null?void 0:d.columnEngine)==null?void 0:wr.visibleColumns.length)||o.schema.length,totalColumnsCount:o.schema.length,hasGrouping:(s==null?void 0:s.isGrouped)||!1,schema:o.schema,allRows:o.uploadedData||[],processedRows:i||[],onExport:F,onClose:()=>{Mr(!1)}})}),o&&e.jsx(Hu,{open:gt,onClose:()=>or(!1),reportId:o.id,reportName:o.name,onRunNow:de=>{const ce=de.scope==="all"?o.uploadedData||[]:i||[],De=So(ce,o.schema||[],o.filters||[],o.sortStack||[],l,o.columnVisibility,o.columnOrder);de.format==="csv"&&jo(De,de.name),de.format==="excel"&&Co(De,de.name),de.format==="json"&&wo(De,de.name),It(`"${de.name}" exported successfully`,"success")}}),e.jsx($u,{open:Vr,onClose:()=>nr(!1),config:Vt,onApply:Fr})]})}const Gu={error:"err",warning:"warn",info:"info",success:"suc"};function ls({open:t,message:o,severity:n,onClose:i,autoHideDurationMs:s}){var I,f;const d=r.useTheme(),l=d.tokens,c=(l==null?void 0:l.notifPosition)??"top-right",u=(l==null?void 0:l.notifStyle)??"toast",h=(l==null?void 0:l.notifAccent)??"severity",m=(l==null?void 0:l.notifAutoDismiss)??!0,b=(l==null?void 0:l.toastW)??252,x=c.startsWith("top")?"top":"bottom",y=c.endsWith("center")?"center":c.endsWith("left")?"left":"right",D=Gu[n],v=((I=l==null?void 0:l.status)==null?void 0:I[`${D}Soft`])??d.palette[n].light,C=((f=l==null?void 0:l.status)==null?void 0:f[`${D}Txt`])??d.palette[n].dark,S=h==="primary"?d.palette.primary.main:h==="mono"?d.palette.text.secondary:C;return e.jsx(r.Snackbar,{open:t,autoHideDuration:m?s??2e3:void 0,onClose:(k,j)=>{j!=="escapeKeyDown"&&i()},anchorOrigin:{vertical:x,horizontal:y},children:e.jsx(r.Alert,{severity:n,icon:!1,onClose:m?void 0:i,sx:{width:b,alignItems:"flex-start",bgcolor:v,color:C,boxShadow:u==="inline"?"none":(l==null?void 0:l.cardShadow)??3,border:u==="inline"?"1px solid":u==="toast"?(l==null?void 0:l.cardBorder)??"1px solid":"none",borderColor:"divider",borderLeft:u==="banner"?`4px solid ${S}`:void 0,borderRadius:`${d.shape.borderRadius}px`},children:o})})}function cs({hasExternalData:t=!1}){const o=Bo(),{reports:n,activeReportId:i,activeReport:s,uploadState:d,hasSchemaConflicts:l,isModalOpen:c,setIsModalOpen:u,setActiveReportId:h,createReport:m,handleFileUpload:b,handleUploadError:x,handleRetry:y,handleConfirm:D,snack:v,handleSnackClose:C,snackDurationMs:S}=o,I=t&&d==="uploading"&&n.length===0;return e.jsxs(r.Box,{sx:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsx(al,{onCreateReport:()=>u(!0),reports:n,activeReportId:i,onReportClick:h}),e.jsx(r.Box,{component:"main",sx:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column",m:0,p:0},children:I?e.jsxs(r.Box,{sx:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2},children:[e.jsx(r.CircularProgress,{size:40,thickness:3}),e.jsx(r.Typography,{variant:"body2",color:"text.secondary",sx:{minWidth:260,textAlign:"center"},children:"Fetching API data — please wait..."})]}):n.length===0?e.jsx(Qi,{title:"No reports yet",description:"Create your first report to start analyzing your data."}):s?e.jsx(e.Fragment,{children:s.schemaLocked&&s.schema&&s.uploadedData&&s.views?e.jsx(as,{reportEngine:o}):e.jsx(r.Box,{sx:{p:3},children:d==="preview"&&s.schema&&s.uploadedData?e.jsx(vd,{schema:s.schema,onConfirm:D,hasConflicts:l}):s.uploadError?e.jsx(Sd,{error:s.uploadError,onRetry:y}):e.jsx(bd,{onFileUpload:b,onError:x,isUploading:d==="uploading"})})}):null}),!t&&e.jsx(yd,{isOpen:c,onClose:()=>u(!1),onCreate:m}),e.jsx(ls,{open:v.open,message:v.message,severity:v.severity,onClose:C,autoHideDurationMs:S})]})}function qu({data:t,dataSource:o,reportName:n,autoLoad:i=!0,config:s}={}){return e.jsx(dn,{mode:"builder",data:t,dataSource:o,reportName:n,autoLoad:i,config:s,children:e.jsx(cs,{hasExternalData:!!(t||o)})})}function ds(){const t=Bo(),{snack:o,handleSnackClose:n,snackDurationMs:i}=t;return e.jsxs(r.Box,{sx:{minHeight:"100vh"},children:[e.jsx(r.Box,{component:"main",children:t.activeReport?e.jsx(as,{reportEngine:t}):e.jsx(Qi,{title:"No report data",description:"This viewer requires report data to be loaded."})}),e.jsx(ls,{open:o.open,message:o.message,severity:o.severity,onClose:n,autoHideDurationMs:i})]})}function Ju({data:t,autoLoad:o=!0,config:n}){return e.jsx(dn,{data:t,mode:"viewer",autoLoad:o,config:n,children:e.jsx(ds,{})})}exports.URMBuilder=qu;exports.URMBuilderRaw=cs;exports.URMProvider=dn;exports.URMViewer=Ju;exports.URMViewerRaw=ds;exports.useURMContext=Bo;
95
+ The file has been downloaded to your device.`);window.open(`mailto:${b.email}?subject=${y}&body=${M}`,"_blank")}(R=(z=h.current).onFired)==null||R.call(z,b)}catch(q){rr.error("urm:scheduler",`Export failed for schedule: ${b.name}`,q)}},[]);p.useEffect(()=>{if(!t)return;const b=()=>{const{reportId:g}=h.current;if(!g)return;const j=rs(g),w=new Date;let I=!1;const v=j.map(S=>{if(!S.isActive)return S;if(new Date(S.nextRunAt)<=w){x(S);const a=xo(S.frequency,S.time,S.dayOfWeek,S.dayOfMonth,w);return I=!0,{...S,lastRunAt:w.toISOString(),nextRunAt:a,runCount:S.runCount+1}}return S});I&&os(g,v)};b();const D=setInterval(b,Fu);return()=>clearInterval(D)},[t,x])}function is({reportEngine:t}){var gr,yr,br,vr,Sr;const{activeReport:o,paginatedData:n,processedData:i,tableMetrics:s,tableEngine:d,activeView:c,isDirty:l,currentTableState:u,viewChanges:f,showFilterPanel:m,setShowFilterPanel:h,filterFocusColumn:x,handleAddFilter:b,handleUpdateFilter:D,handleRemoveFilter:g,handleClearAllFilters:j,handleReplaceFilters:w,handleOpenFilterForColumn:I,handleCloseFilterPanel:v,handleClearFiltersForColumn:S,showSortPanel:C,setShowSortPanel:a,handleSort:z,handleUpdateSortStack:R,handleSortAscending:q,handleSortDescending:K,showManageViews:ee,setShowManageViews:y,showCreateViewModal:M,setShowCreateViewModal:W,showEditViewModal:V,setShowEditViewModal:Q,showDeleteConfirmation:xe,setShowDeleteConfirmation:de,editingView:L,deletingView:A,handleSelectView:H,handleCreateView:ie,handleUpdateCurrentView:Y,handleSaveColumnConfigToCurrentView:re,handleSaveColumnConfigToAllViews:se,handleSaveAsNewView:oe,handleRevertChanges:P,handleToggleDefault:ne,handleToggleFavorite:ce,handleSoftDelete:ae,handleRestoreView:fe,handlePermanentDelete:G,handleEditView:Ae,handleSaveEditView:Qe,handleConfirmDelete:Ze,handlePromoteToGlobal:Bt,showManageColumns:ar,setShowManageColumns:It,handleUpdateColumnVisibility:Dt,handleUpdateColumnOrder:Et,handleUpdateColumnWidth:lt,handleResetColumnLayout:Ve,showGroupPanel:Vt,setShowGroupPanel:et,handleGroup:Ue,handleToggleGroupCollapse:He,searchQuery:nt,debouncedSearchQuery:Ir,searchHistory:lr,handleSearchChange:Ht,handleAddToSearchHistory:cr,handleToggleSearchFavourite:Ut,handleDeleteSearchHistory:Dr,selectedRowIds:Yt,handleToggleRowSelection:ft,handleToggleAllRows:it,handleRangeSelection:dr,handleClearSelection:Gt,handleUpdateSelectionAfterDelete:ur,currentPage:qt,pageSize:Er,paginationEngine:tt,handlePageChange:Ot,handlePageSizeChange:ke,isExporting:At,showExportModal:Or,setShowExportModal:Ye,showDirtyExportWarning:F,handleExport:Ge,handleExportWithConfig:be,handleExportSelected:Pe,handleExportAnyway:Ar,handleSaveAndExport:gt,handleCancelExport:$r,showAuditHistory:yt,setShowAuditHistory:Jt,showCreatePreset:Kt,setShowCreatePreset:pr,showManagePresets:Te,setShowManagePresets:U,activePreset:_e,handleCreatePreset:we,handleClearActivePreset:ct,handleOpenPresetById:Le,handleDeletePresetById:xr,isViewerRole:mr,userRole:hr,featureLimitWarning:bt,setFeatureLimitWarning:Mr,reportError:vt,setReportError:Xt,handleError:St,updateReport:st,showSnack:jt}=t,[fr,Fe]=p.useState(!1);Vu({reportId:o==null?void 0:o.id,reportName:(o==null?void 0:o.name)||"Report",uploadedData:(o==null?void 0:o.uploadedData)||[],processedData:i||[],schema:(o==null?void 0:o.schema)||[],activeView:c,columnVisibility:(o==null?void 0:o.columnVisibility)||((gr=c==null?void 0:c.snapshot)==null?void 0:gr.columnVisibility)||{},columnOrder:(o==null?void 0:o.columnOrder)||((yr=c==null?void 0:c.snapshot)==null?void 0:yr.columnOrder)||[],filters:(o==null?void 0:o.filters)||[],sortStack:(o==null?void 0:o.sortStack)||[],onFired:le=>{jt(`Scheduled export "${le.name}" completed`,"success")}});const $t=p.useCallback((le,he)=>{if(!(o!=null&&o.uploadedData))return;const $e=[...o.uploadedData];$e[le]=he,st(o.id,{uploadedData:$e})},[o,st]),Mt=p.useCallback(le=>{if(!(o!=null&&o.uploadedData))return;const he=o.uploadedData.indexOf(le);if(he===-1)return;const $e=o.uploadedData.filter((_t,Wt)=>Wt!==he);st(o.id,{uploadedData:$e}),ur(le)},[o,st,ur]),dt=p.useCallback((le,he)=>{if(!(o!=null&&o.uploadedData))return;const $e=o.uploadedData.indexOf(he),_t=$e!==-1?$e+1:le+1,Wt=[...o.uploadedData];Wt.splice(_t,0,{...he}),st(o.id,{uploadedData:Wt})},[o,st]),at=nr(),{handleDevConfigChange:Rt}=jo(),[Rr,Qt]=p.useState(!1);return p.useEffect(()=>{const le=he=>{he.ctrlKey&&he.shiftKey&&he.key==="D"&&(he.preventDefault(),Qt(!0))};return document.addEventListener("keydown",le),()=>document.removeEventListener("keydown",le)},[]),!o||!o.schemaLocked||!o.schema||!o.uploadedData||!o.views?null:e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,position:"relative"},children:[!mr&&l&&c&&e.jsx(au,{viewName:c.name,isDefaultView:c.isDefault,changes:f,onSaveToCurrentView:c.isDefault?void 0:Y,onSaveAsNewView:oe,onCancel:P}),e.jsxs(r.Box,{id:"table-content-area",sx:{flex:1,minHeight:0,display:"flex",flexDirection:"column",position:"relative"},children:[bt&&e.jsx(wu,{warning:bt,onDismiss:()=>Mr(null)}),vt&&e.jsx(ku,{error:vt,onDismiss:()=>Xt(null)}),F&&e.jsx(lu,{onExportAnyway:Ar,onSaveAndExport:gt,onCancel:$r}),e.jsx(Kd,{schema:o.schema,data:n,sortStack:o.sortStack,filters:o.filters,views:o.views,activeViewId:o.activeViewId,isDirty:l,isExporting:At,columnVisibility:o.columnVisibility||(c==null?void 0:c.snapshot.columnVisibility),columnOrder:o.columnOrder||(c==null?void 0:c.snapshot.columnOrder),columnWidths:o.columnWidths||(c==null?void 0:c.snapshot.columnWidths),grouping:o.grouping,onSort:z,onSortAscending:q,onSortDescending:K,onOpenFilters:()=>h(!0),onOpenSort:()=>a(!0),onOpenFilterForColumn:I,onSelectView:H,onCreateView:()=>W(!0),onManageViews:()=>y(!0),onUpdateCurrentView:Y,onSaveAsNewView:oe,onToggleDefault:ne,onToggleFavorite:ce,onRestoreView:fe,onPermanentDelete:G,onExport:Ge,onOpenColumns:()=>It(!0),onUpdateColumnWidth:lt,onUpdateColumnOrder:Et,onUpdateColumnVisibility:Dt,onClearFiltersForColumn:S,onResetLayout:Ve,onOpenGroup:()=>et(!0),onGroupByColumn:le=>{Ue({enabled:!0,levels:[{column:le}],collapsedGroups:[]})},onToggleGroupCollapse:He,onOpenAuditHistory:()=>Jt(!0),onOpenScheduledReports:()=>Fe(!0),searchQuery:nt,highlightQuery:Ir,searchHistory:lr,onAddToSearchHistory:cr,onToggleSearchFavourite:Ut,onDeleteSearchHistory:Dr,selectedRowIds:Yt,onSearchChange:Ht,onToggleRowSelection:ft,onToggleAllRows:it,onRangeSelection:dr,onClearSelection:Gt,onExportSelected:Pe,currentPage:(tt==null?void 0:tt.currentPage)||qt,pageSize:(tt==null?void 0:tt.pageSize)||Er,onPageChange:Ot,onPageSizeChange:ke,totalRowsBeforePagination:(s==null?void 0:s.searchedRows)||i.length,isReadOnly:mr,userRole:hr,reportName:o.name,onEditRow:$t,onDeleteRow:Mt,onDuplicateRow:dt,showDevPanel:at.display.showDevPanel,onOpenDevConfig:()=>Qt(!0)})]}),m&&e.jsx(Lr,{feature:"Filters",onError:le=>{const he=wt("ui","filters",le);St(he)},children:e.jsx(Xd,{schema:o.schema,filters:o.filters??[],onAddFilter:b,onUpdateFilter:D,onRemoveFilter:g,onClearAll:j,onReplaceFilters:w,onClose:v,focusColumn:x})}),C&&e.jsx(Lr,{feature:"Sorting",onError:le=>{const he=wt("ui","sorting",le);St(he)},children:e.jsx(Zd,{schema:o.schema,sortStack:o.sortStack??[],onUpdateSortStack:R,onClose:()=>a(!1)})}),ee&&e.jsx(Lr,{feature:"Views",onError:le=>{const he=wt("ui","views",le);St(he)},children:e.jsx(eu,{views:o.views,activeViewId:o.activeViewId??"",onSelectView:H,onCreateView:()=>{y(!1),W(!0)},onEditView:Ae,onDeleteView:ae,onRestoreView:fe,onPermanentDelete:G,onPromoteToGlobal:Bt,isAdmin:((br=at.views)==null?void 0:br.isAdmin)??!1,onClose:()=>y(!1)})}),M&&u&&(()=>{var $e;const le=(o.views??[]).filter(_t=>!_t.isDeleted).length,he=(($e=at.views)==null?void 0:$e.maxViews)??10;return e.jsx(xi,{currentSnapshot:u,onSave:ie,onClose:()=>W(!1),atViewLimit:le>=he,maxViews:he})})(),V&&L&&e.jsx(xi,{currentSnapshot:L.snapshot,onSave:Qe,onClose:()=>{Q(!1)},isEditMode:!0,initialName:L.name,initialDescription:L.description,initialIsDefault:L.isDefault}),xe&&A&&e.jsx(tu,{viewName:A.name,onConfirm:Ze,onCancel:()=>{de(!1)}}),ar&&c&&e.jsx(ou,{schema:o.schema,columnVisibility:o.columnVisibility||c.snapshot.columnVisibility,columnOrder:o.columnOrder||c.snapshot.columnOrder,columnWidths:o.columnWidths||c.snapshot.columnWidths,views:o.views,activeViewId:o.activeViewId,onUpdateColumnVisibility:Dt,onUpdateColumnOrder:Et,onUpdateColumnWidth:lt,onResetLayout:Ve,onSelectView:le=>{H(le)},onSaveToCurrentView:le=>{re(le),It(!1)},onSaveToAllViews:le=>{se(le),It(!1)},onClose:()=>It(!1)}),Vt&&e.jsx(Lr,{feature:"Grouping",onError:le=>{const he=wt("ui","grouping",le);St(he)},children:e.jsx(nu,{schema:o.schema,grouping:o.grouping||null,onApply:Ue,onClose:()=>et(!1)})}),yt&&e.jsx(uu,{auditHistory:o.auditHistory||[],onClose:()=>Jt(!1)}),Kt&&e.jsx(pu,{onSave:we,onClose:()=>pr(!1)}),Te&&e.jsx(mu,{presets:o.presets||[],reportId:o.id,onOpenPreset:Le,onDeletePreset:xr,onClose:()=>U(!1)}),_e&&e.jsx(r.Box,{sx:{mt:2},children:e.jsx(xu,{presetName:_e.name,onClear:ct})}),Or&&e.jsx(Lr,{feature:"Export",onError:le=>{const he=wt("ui","export",le);St(he)},children:e.jsx(Cu,{totalRows:(s==null?void 0:s.totalRows)||((vr=o.uploadedData)==null?void 0:vr.length)||0,visibleRows:(s==null?void 0:s.searchedRows)||i.length,visibleColumnsCount:((Sr=d==null?void 0:d.columnEngine)==null?void 0:Sr.visibleColumns.length)||o.schema.length,totalColumnsCount:o.schema.length,hasGrouping:(s==null?void 0:s.isGrouped)||!1,schema:o.schema,allRows:o.uploadedData||[],processedRows:i||[],onExport:be,onClose:()=>{Ye(!1)}})}),o&&e.jsx(Lu,{open:fr,onClose:()=>Fe(!1),reportId:o.id,reportName:o.name,onRunNow:le=>{const he=le.scope==="all"?o.uploadedData||[]:i||[],$e=mo(he,o.schema||[],o.filters||[],o.sortStack||[],c,o.columnVisibility,o.columnOrder);le.format==="csv"&&ho($e,le.name),le.format==="excel"&&fo($e,le.name),le.format==="json"&&go($e,le.name),jt(`"${le.name}" exported successfully`,"success")}}),e.jsx(Du,{open:Rr,onClose:()=>Qt(!1),config:at,onApply:Rt})]})}const Hu={error:"err",warning:"warn",info:"info",success:"suc"};function ss({open:t,message:o,severity:n,onClose:i,autoHideDurationMs:s}){var I,v;const d=r.useTheme(),c=d.tokens,l=(c==null?void 0:c.notifPosition)??"top-right",u=(c==null?void 0:c.notifStyle)??"toast",f=(c==null?void 0:c.notifAccent)??"severity",m=(c==null?void 0:c.notifAutoDismiss)??!0,h=(c==null?void 0:c.toastW)??252,x=l.startsWith("top")?"top":"bottom",b=l.endsWith("center")?"center":l.endsWith("left")?"left":"right",D=Hu[n],g=((I=c==null?void 0:c.status)==null?void 0:I[`${D}Soft`])??d.palette[n].light,j=((v=c==null?void 0:c.status)==null?void 0:v[`${D}Txt`])??d.palette[n].dark,w=f==="primary"?d.palette.primary.main:f==="mono"?d.palette.text.secondary:j;return e.jsx(r.Snackbar,{open:t,autoHideDuration:m?s??2e3:void 0,onClose:(S,C)=>{C!=="escapeKeyDown"&&i()},anchorOrigin:{vertical:x,horizontal:b},children:e.jsx(r.Alert,{severity:n,icon:!1,onClose:m?void 0:i,sx:{width:h,alignItems:"flex-start",bgcolor:g,color:j,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 ${w}`:void 0,borderRadius:`${d.shape.borderRadius}px`},children:o})})}function as({hasExternalData:t=!1}){const o=jo(),{reports:n,activeReportId:i,activeReport:s,uploadState:d,hasSchemaConflicts:c,isModalOpen:l,setIsModalOpen:u,setActiveReportId:f,createReport:m,handleFileUpload:h,handleUploadError:x,handleRetry:b,handleConfirm:D,snack:g,handleSnackClose:j,snackDurationMs:w}=o,I=t&&d==="uploading"&&n.length===0;return e.jsxs(r.Box,{sx:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsx(tl,{onCreateReport:()=>u(!0),reports:n,activeReportId:i,onReportClick:f}),e.jsx(r.Box,{component:"main",sx:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column",m:0,p:0},children:I?e.jsxs(r.Box,{sx:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2},children:[e.jsx(r.CircularProgress,{size:40,thickness:3}),e.jsx(r.Typography,{variant:"body2",color:"text.secondary",sx:{minWidth:260,textAlign:"center"},children:"Fetching API data — please wait..."})]}):n.length===0?e.jsx(Ki,{title:"No reports yet",description:"Create your first report to start analyzing your data."}):s?e.jsx(e.Fragment,{children:s.schemaLocked&&s.schema&&s.uploadedData&&s.views?e.jsx(is,{reportEngine:o}):e.jsx(r.Box,{sx:{p:3},children:d==="preview"&&s.schema&&s.uploadedData?e.jsx(md,{schema:s.schema,onConfirm:D,hasConflicts:c}):s.uploadError?e.jsx(hd,{error:s.uploadError,onRetry:b}):e.jsx(xd,{onFileUpload:h,onError:x,isUploading:d==="uploading"})})}):null}),!t&&e.jsx(pd,{isOpen:l,onClose:()=>u(!1),onCreate:m}),e.jsx(ss,{open:g.open,message:g.message,severity:g.severity,onClose:j,autoHideDurationMs:w})]})}function Uu({data:t,dataSource:o,reportName:n,autoLoad:i=!0,config:s}={}){return e.jsx(nn,{mode:"builder",data:t,dataSource:o,reportName:n,autoLoad:i,config:s,children:e.jsx(as,{hasExternalData:!!(t||o)})})}function ls(){const t=jo(),{snack:o,handleSnackClose:n,snackDurationMs:i}=t;return e.jsxs(r.Box,{sx:{height:"100%",overflow:"hidden",display:"flex",flexDirection:"column"},children:[e.jsx(r.Box,{component:"main",sx:{flex:1,minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column"},children:t.activeReport?e.jsx(is,{reportEngine:t}):e.jsx(Ki,{title:"No report data",description:"This viewer requires report data to be loaded."})}),e.jsx(ss,{open:o.open,message:o.message,severity:o.severity,onClose:n,autoHideDurationMs:i})]})}function Yu({data:t,autoLoad:o=!0,config:n}){return e.jsx(nn,{data:t,mode:"viewer",autoLoad:o,config:n,children:e.jsx(ls,{})})}exports.URMBuilder=Uu;exports.URMBuilderRaw=as;exports.URMProvider=nn;exports.URMViewer=Yu;exports.URMViewerRaw=ls;exports.useURMContext=jo;