dts-universal-report-module 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.esm.js +9654 -8294
  2. package/dist/index.js +27 -27
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,25 +1,25 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("react"),os=require("xlsx"),k=require("@mui/icons-material"),r=require("@mui/material"),Fn=require("react-dom"),ns=require("@emotion/react"),St=require("react-dnd"),_o=require("react-dnd-html5-backend");function Ln(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 oo=Ln(p),Vr=Ln(os);function is(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 Vn(t,o="",n=0){if(n>2)return{[o]:t};const i={};for(const a of Object.keys(t)){const l=o?`${o}.${a}`:a,c=t[a];c!==null&&typeof c=="object"&&!Array.isArray(c)&&n<2?Object.assign(i,Vn(c,l,n+1)):i[l]=c}return i}function Kr(t){return t.map(o=>typeof o!="object"||o===null||Array.isArray(o)?o:Vn(o))}function Tr(t){if(!Array.isArray(t)||t.length===0)return[];const o=Kr(t),n=new Set;o.forEach(a=>{typeof a=="object"&&a!==null&&Object.keys(a).forEach(l=>n.add(l))});const i=[];return n.forEach(a=>{const l=new Set;let c=0;o.forEach(h=>{typeof h=="object"&&h!==null&&a in h&&(c++,l.add(is(h[a])))});const d=c===o.length,u=l.size>1&&!l.has("null");let f="mixed";if(l.size===1)f=Array.from(l)[0];else if(l.size===2&&l.has("null")){const h=Array.from(l).filter(m=>m!=="null");h.length===1&&(f=h[0])}i.push({name:a,type:f,required:d,hasConflict:u})}),i}function ss(t){return t.some(o=>o.hasConflict)}function ct(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 Xo(t){return t==null}function as(t){return(o,n,i)=>{const a=Xo(o),l=Xo(n);if(a&&l)return 0;if(a)return 1;if(l)return-1;let c=0;switch(t){case"number":const d=Number(o),u=Number(n);c=d-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 ls(t,o,n){if(!n||n.length===0)return t;const i=[...n].sort((a,l)=>a.priority-l.priority);return[...t].sort((a,l)=>{for(const c of i){const d=o.find(h=>h.name===c.column);if(!d)continue;const f=as(d.type)(a[c.column],l[c.column],c.direction);if(f!==0)return f}return 0})}function cs(t){return t===null?"asc":t==="asc"?"desc":null}function ds(t){return t==="string"||t==="boolean"}function us(t){return t.filter(o=>ds(o.type))}function ps(t,o){const n={};return o.forEach(i=>{if(i.type==="number"){const a=t.map(l=>l[i.name]).filter(l=>typeof l=="number");a.length>0&&(n[i.name]=a.reduce((l,c)=>l+c,0))}}),n}function xs(t,o,n){if(!n.enabled||n.levels.length===0)return t;const i=Hn(t,n.levels,o);return Un(i,n.collapsedGroups||[])}function Hn(t,o,n,i="",a=0){if(a>=o.length)return t;const l=o[a].column,c=new Map;t.forEach(f=>{const h=f[l],m=h==null?"(empty)":String(h);c.has(m)||c.set(m,[]),c.get(m).push(f)});const d=[];return Array.from(c.keys()).sort().forEach(f=>{const h=c.get(f),m=`${l}:${f}`,v=i?`${i}|${m}`:m,w=ps(h,n),z=a<o.length-1?Hn(h,o,n,v,a+1):h,y={key:v,level:a,column:l,value:f,rowCount:h.length,aggregates:w,children:z};d.push(y)}),d}function Un(t,o,n=[]){for(const i of t)if("key"in i&&"level"in i&&"children"in i){const a=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:a}),!a&&i.children&&Un(i.children,o,n)}else n.push(i);return n}function fs(t,o){const n=t.collapsedGroups||[],i=n.includes(o)?n.filter(a=>a!==o):[...n,o];return{...t,collapsedGroups:i}}function Gn(t,o){return t==null?"":typeof t=="number"?`Σ ${t.toLocaleString()}`:String(t)}function Yn(t,o,n){return`${o}: ${n}`}function Br(t,o){if(!o||!o.enabled||!o.levels||o.levels.length===0)return[...t];const n=o.levels.map(a=>a.column),i=t.filter(a=>!n.includes(a));return[...n,...i]}function qn(t,o,n){if(!o||!o.enabled||!o.levels||o.levels.length===0)return[...t];const i=o.levels.map(l=>l.column),a=t.filter(l=>!i.includes(l));if(n){const l=[],c=new Set(i),d=new Set(a);let u=0;for(const f of n)c.has(f)?l.push(f):d.has(f)&&u<a.length?(l.push(a[u]),u++):d.has(f)||l.push(f);for(let f=u;f<a.length;f++)l.includes(a[f])||l.push(a[f]);return l}return[...t]}function jo(t){const o={},n=[],i={};return t.forEach(a=>{o[a.name]=!0,n.push(a.name),i[a.name]=150}),{id:"default-view",name:"Default View",description:"Unfiltered, unsorted baseline view",isDefault:!0,snapshot:{filters:[],sortStack:[],columnVisibility:o,columnOrder:n,columnWidths:i,grouping:null}}}function hs(t,o,n,i,a,l,c,d){const u={},f=[],h={};n.forEach(w=>{u[w.name]=!0,f.push(w.name),h[w.name]=150});const v=qn(a||f,c||null,d||f);return{filters:t||[],sortStack:o||[],columnVisibility:i||u,columnOrder:v,columnWidths:l||h,grouping:c||null}}function ms(t,o){const n=u=>{if(u==null)return u;if(Array.isArray(u))return u.map(f=>n(f));if(typeof u=="object"){const f={};return Object.keys(u).sort().forEach(h=>{f[h]=n(u[h])}),f}return u},i=u=>JSON.stringify(n(u));if(i(t.filters)!==i(o.filters)||i(t.sortStack)!==i(o.sortStack)||i(t.columnVisibility)!==i(o.columnVisibility))return!0;const a=[...t.columnOrder||[]].sort().join(","),l=[...o.columnOrder||[]].sort().join(",");if(a!==l)return!1;const c=[...o.columnOrder||[]].sort().join(",");if((o.columnOrder||[]).join(",")!==c){if((t.columnOrder||[]).join(",")!==(o.columnOrder||[]).join(","))return!0}else{const u=[...t.columnOrder||[]].sort().join(",");if((t.columnOrder||[]).join(",")!==u)return!0}return i(t.columnWidths)!==i(o.columnWidths)||i(t.grouping)!==i(o.grouping)}function gs(t){return!t||t.length===0?"None":t.sort((o,n)=>o.priority-n.priority).map(o=>`${o.column} ${o.direction==="asc"?"↑":"↓"}`).join(", ")}function ys(t,o){var y,j,b;const n=[],i=JSON.stringify(t.filters),a=JSON.stringify(o.filters);if(i!==a){const g=t.filters.length,S=o.filters.length;g>S?n.push({category:"filters",label:"Filters Added",description:`${g-S} new filter${g-S>1?"s":""} added`}):g<S?n.push({category:"filters",label:"Filters Removed",description:`${S-g} filter${S-g>1?"s":""} removed`}):n.push({category:"filters",label:"Filters Modified",description:"Filter conditions have been changed"})}const l=JSON.stringify(t.sortStack),c=JSON.stringify(o.sortStack);if(l!==c){const g=t.sortStack.length,S=o.sortStack.length;g>S?n.push({category:"sorting",label:"Sorting Added",description:`${g-S} new sort rule${g-S>1?"s":""} added`}):g<S?n.push({category:"sorting",label:"Sorting Removed",description:`${S-g} sort rule${S-g>1?"s":""} removed`}):n.push({category:"sorting",label:"Sorting Modified",description:"Sort rules or order have been changed"})}const d=JSON.stringify(t.columnVisibility),u=JSON.stringify(o.columnVisibility);if(d!==u){const g=Object.values(t.columnVisibility).filter(s=>s).length,S=Object.values(o.columnVisibility).filter(s=>s).length;g>S?n.push({category:"visibility",label:"Columns Shown",description:`${g-S} column${g-S>1?"s":""} made visible`}):g<S?n.push({category:"visibility",label:"Columns Hidden",description:`${S-g} column${S-g>1?"s":""} hidden`}):n.push({category:"visibility",label:"Column Visibility Changed",description:"Column visibility settings have been modified"})}const f=JSON.stringify(t.columnOrder),h=JSON.stringify(o.columnOrder);f!==h&&n.push({category:"order",label:"Column Order Changed",description:"Columns have been reordered"});const m=JSON.stringify(t.columnWidths),v=JSON.stringify(o.columnWidths);if(m!==v){const g=Object.keys(t.columnWidths).filter(S=>t.columnWidths[S]!==o.columnWidths[S]).length;n.push({category:"widths",label:"Column Widths Adjusted",description:`${g} column width${g>1?"s":""} modified`})}const w=JSON.stringify(t.grouping),z=JSON.stringify(o.grouping);if(w!==z){const g=(y=t.grouping)==null?void 0:y.enabled,S=(j=o.grouping)==null?void 0:j.enabled;if(g&&!S){const s=((b=t.grouping)==null?void 0:b.levels.length)||0;n.push({category:"grouping",label:"Grouping Applied",description:`${s} grouping level${s>1?"s":""} added`})}else!g&&S?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 Qo(){try{return localStorage.getItem("urm:debug")==="true"}catch{return!1}}function Zo(t){return`[${t}]`}const Vt={warn(t,o,...n){Qo()&&console.warn(Zo(t),o,...n)},error(t,o,...n){Qo()&&console.error(Zo(t),o,...n)}},Jn="urm_report_";function bs(t,o){try{const n=`${Jn}${t}`;localStorage.setItem(n,JSON.stringify(o))}catch(n){Vt.error("urm:persistence","Failed to save report state",n)}}function vs(t){try{const o=`${Jn}${t}`,n=localStorage.getItem(o);return n?JSON.parse(n):null}catch(o){return Vt.error("urm:persistence","Failed to load report state",o),null}}function no(t,o,n=0){const i=[];for(const a of t){const l=o.includes(a.key);if(i.push({type:"group",key:a.key,level:n,column:a.column,value:a.value,rowCount:a.rowCount,aggregates:a.aggregates,collapsed:l}),!l&&a.children&&a.children.length>0){const c=a.children[0];if(Ss(c)){const d=a.children,u=no(d,o,n+1);i.push(...u)}else{const d=a.children;for(const u of d)i.push({type:"row",parentGroupKey:a.key,level:n+1,data:u})}}}return i}function Ss(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 Po(t){return t.filter(o=>o.type==="row").map(o=>o.type==="row"?o.data:null).filter(o=>o!==null)}function $o(t,o){const n=new Date,i=n.getFullYear(),a=String(n.getMonth()+1).padStart(2,"0"),l=String(n.getDate()).padStart(2,"0"),c=`${i}-${a}-${l}`;return`${t.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}_${c}.${o}`}function Qr(t,o,n,i,a,l,c){let d,u;l?(d={...l},u=c||o.map(h=>h.name)):a?(d={...a.snapshot.columnVisibility},u=c||[...a.snapshot.columnOrder]):(d={},u=[],o.forEach(h=>{d[h.name]=!0,u.push(h.name)}));const f=Object.entries(d).filter(([h,m])=>!m).map(([h,m])=>h);return{data:t,schema:o,appliedFilters:n,appliedSortStack:i,columnVisibility:d,columnOrder:u,grouping:(a==null?void 0:a.snapshot.grouping)??null,hiddenColumns:f,viewMeta:a?{id:a.id,name:a.name,isDefault:a.isDefault}:void 0}}function Zr(t,o="export",n){const{data:i,columnOrder:a,grouping:l}=t,c=a.filter(m=>t.columnVisibility[m]);let d;if(l&&l.enabled){const m=no(i);d=Po(m)}else d=i;const u=c.join(","),f=d.map(m=>c.map(v=>{const w=m[v];if(w==null)return"";const z=String(w);return z.includes(",")||z.includes('"')||z.includes(`
2
- `)?`"${z.replace(/"/g,'""')}"`:z}).join(",")),h=[u,...f].join(`
3
- `);Kn(h,$o(o,"csv"),"text/csv;charset=utf-8;")}function eo(t,o="export",n){const{data:i,columnOrder:a,grouping:l}=t,c=a.filter(m=>t.columnVisibility[m]);let d;if(l&&l.enabled){const m=no(i);d=Po(m)}else d=i;const u=[c,...d.map(m=>c.map(v=>m[v]??""))],f=Vr.utils.aoa_to_sheet(u),h=Vr.utils.book_new();Vr.utils.book_append_sheet(h,f,"Data"),Vr.writeFile(h,$o(o,"xlsx"))}function to(t,o="export",n){const{data:i,appliedFilters:a,appliedSortStack:l,viewMeta:c,hiddenColumns:d,columnOrder:u,grouping:f}=t;let h;if(f&&f.enabled){const w=no(i);h=Po(w)}else h=i;const m={meta:{exportedAt:new Date().toISOString(),reportName:o,view:(c==null?void 0:c.name)||"Default View",filters:a.map(w=>({field:w.column,operator:w.operator,value:w.value})),sortStack:l.map(w=>({field:w.column,direction:w.direction,priority:w.priority})),grouping:f||{},hiddenColumns:d,columnOrder:u,exportConfig:n||{scope:"visible"}},data:h},v=JSON.stringify(m,null,2);Kn(v,$o(o,"json"),"application/json;charset=utf-8;")}function Kn(t,o,n){const i=new Blob([t],{type:n}),a=URL.createObjectURL(i),l=document.createElement("a");l.href=a,l.download=o,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(a)}const en=10;function Cs(t,o){const n=o.trim();if(!n)return t;const i=t.findIndex(l=>l.query.toLowerCase()===n.toLowerCase());let a;return i!==-1?a=[{...t[i],lastUsed:Date.now()},...t.slice(0,i),...t.slice(i+1)]:a=[{query:n,isFavourite:!1,lastUsed:Date.now()},...t],a.length>en&&(a=[...a].sort((c,d)=>c.isFavourite&&!d.isFavourite?-1:!c.isFavourite&&d.isFavourite?1:d.lastUsed-c.lastUsed).slice(0,en)),a}function js(t,o){return t.map(n=>n.query===o?{...n,isFavourite:!n.isFavourite}:n)}function ws(t,o){return t.filter(n=>n.query!==o)}function ks(t){const o=t.filter(i=>i.isFavourite).sort((i,a)=>a.lastUsed-i.lastUsed),n=t.filter(i=>!i.isFavourite).sort((i,a)=>a.lastUsed-i.lastUsed);return[...o,...n]}const Ts={owner:["view_report","edit_columns","edit_filters","edit_sorting","edit_views","create_views","delete_views","delete_report","export_data"],editor:["view_report","edit_columns","edit_filters","edit_sorting","edit_views","create_views","delete_views","export_data"],viewer:["view_report","export_data"]};function zs(t,o){return!t||t.owner===o?"owner":t.editors.includes(o)?"editor":(t.viewers.includes(o),"viewer")}function mt(t,o){return Ts[o].includes(t)}function gt(t){return`You do not have permission to ${{view_report:"view this report",edit_columns:"modify columns",edit_filters:"modify filters",edit_sorting:"modify sorting",edit_views:"edit views",create_views:"create views",delete_views:"delete views",delete_report:"delete this report",export_data:"export data"}[t]||"perform this action"}.`}function Is(t){return t==="viewer"}const tn=1e3;function Es(){return`EVT_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Xn(t,o,n,i,a,l){return{id:Es(),user:o,reportId:t,feature:n,action:i,timestamp:new Date().toISOString(),previousState:a,newState:l}}function Qn(t,o){const n=[o,...t];return n.length>tn?n.slice(0,tn):n}function Ds(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 Bs(t){return{filters:"Filters",sorting:"Sorting",grouping:"Grouping",columns:"Columns",views:"Views",theme:"Theme",export:"Export",presets:"Presets",system:"System"}[t]||t}function Os(t){return{filters:"bg-blue-100 text-blue-800 border-blue-200",sorting:"bg-purple-100 text-purple-800 border-purple-200",grouping:"bg-green-100 text-green-800 border-green-200",columns:"bg-orange-100 text-orange-800 border-orange-200",views:"bg-pink-100 text-pink-800 border-pink-200",theme:"bg-gray-100 text-gray-800 border-gray-200",export:"bg-cyan-100 text-cyan-800 border-cyan-200",presets:"bg-indigo-100 text-indigo-800 border-indigo-200",system:"bg-red-100 text-red-800 border-red-200"}[t]||"bg-gray-100 text-gray-800 border-gray-200"}function As(t){const o=new Date(t),i=new Date().getTime()-o.getTime(),a=Math.floor(i/6e4),l=Math.floor(i/36e5),c=Math.floor(i/864e5);return a<1?"Just now":a<60?`${a} minute${a>1?"s":""} ago`:l<24?`${l} hour${l>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"})}function rn(t){return t==null?"None":typeof t=="string"||typeof t=="number"||typeof t=="boolean"?String(t):JSON.stringify(t,null,2)}const on=100;function Ms(){return`preset_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Ws(t){var l;const o=(l=t.views)==null?void 0:l.find(c=>c.id===t.activeViewId),n=o==null?void 0:o.snapshot.columnOrder,i=t.columnOrder||[],a=qn(i,t.grouping||null,n);return{filters:t.filters?[...t.filters]:[],sortStack:t.sortStack?[...t.sortStack]:[],columnVisibility:t.columnVisibility?{...t.columnVisibility}:{},columnOrder:a,columnWidths:t.columnWidths?{...t.columnWidths}:{},grouping:t.grouping?{...t.grouping}:null,activeViewId:t.activeViewId}}function Rs(t,o,n,i){return{id:Ms(),name:t,description:o,createdBy:n,createdAt:Date.now(),config:i}}function _s(t,o){const n=t||[];if(n.length>=on)throw new Error(`Maximum of ${on} presets reached. Please delete old presets first.`);return[...n,o]}function Ps(t,o){return(t||[]).filter(i=>i.id!==o)}function nn(t,o){if(t)return t.find(n=>n.id===o)}function $s(){return typeof window>"u"?null:new URLSearchParams(window.location.search).get("preset")}function Ns(t){const o=t.columnOrder,n=Br(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 Fs(t,o){return{totalRows:t.length,totalColumns:o.length}}const Ls={MAX_CACHE_ENTRIES:3};function Vs(t,o){let n=null;return function(...a){const l=()=>{n=null,t(...a)};n&&clearTimeout(n),n=setTimeout(l,o)}}class Hr{constructor(o=Ls.MAX_CACHE_ENTRIES){this.cache=new Map,this.maxEntries=o}get(o){const n=this.cache.get(o);return n?n.value:null}set(o,n){var i;if(this.cache.size>=this.maxEntries&&!this.cache.has(o)){const a=(i=Array.from(this.cache.entries()).sort((l,c)=>l[1].timestamp-c[1].timestamp)[0])==null?void 0:i[0];a&&this.cache.delete(a)}this.cache.set(o,{key:o,value:n,timestamp:Date.now()})}has(o){return this.cache.has(o)}clear(){this.cache.clear()}size(){return this.cache.size}}class Hs{constructor(){this.metrics=new Map}start(o){this.metrics.set(o,performance.now())}end(o){const n=this.metrics.get(o);if(!n)return 0;const i=performance.now()-n;return this.metrics.delete(o),i}measure(o,n){this.start(o);const i=n(),a=this.end(o);return{result:i,duration:a}}async measureAsync(o,n){this.start(o);const i=await n(),a=this.end(o);return{result:i,duration:a}}}function vt(t,o,n,i){const a=n instanceof Error?n.message:n,l={type:t,context:o,message:a,details:i,timestamp:Date.now(),recoverable:Us(t,o)};return process.env.NODE_ENV==="development"&&Vt.error("urm:error-handling","[Report Error]",{type:t,context:o,message:a,details:i}),l}function Us(t,o){return t==="ui"||t==="processing"&&["filters","sorting","grouping","columns"].includes(o)?!0:t!=="system"}function Gs(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 Ys(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 qs(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 Js(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 Zn(t,o){const n=[],i=[],a=new Set(o.map(l=>l.name));return t.forEach(l=>{a.has(l.column)?n.push(l):i.push(l.column)}),{validRules:n,invalidColumns:i}}function ei(t,o){if(!t||!t.levels||t.levels.length===0)return{validGrouping:null,invalidColumns:[]};const n=new Set(o.map(l=>l.name)),i=[],a=[];return t.levels.forEach(l=>{n.has(l.column)?i.push(l):a.push(l.column)}),i.length===0?{validGrouping:null,invalidColumns:a}:{validGrouping:{...t,levels:i},invalidColumns:a}}function Ks(t,o){const n=[],i=new Set(o.map(l=>l.name)),a={...t};if(a.filters&&Array.isArray(a.filters)){const l=a.filters.filter(c=>{const d=i.has(c.column);return d||n.push(`Filter for column "${c.column}" ignored (column not found)`),d});a.filters=l.length>0?l:void 0}if(a.sortStack&&Array.isArray(a.sortStack)){const{validRules:l,invalidColumns:c}=Zn(a.sortStack,o);c.length>0&&n.push(`Sort rules for columns ignored: ${c.join(", ")}`),a.sortStack=l.length>0?l:void 0}if(a.grouping){const{validGrouping:l,invalidColumns:c}=ei(a.grouping,o);c.length>0&&n.push(`Grouping for columns ignored: ${c.join(", ")}`),a.grouping=l}if(a.columnVisibility){const l={};Object.entries(a.columnVisibility).forEach(([c,d])=>{i.has(c)?l[c]=d:n.push(`Column visibility for "${c}" ignored (column not found)`)}),a.columnVisibility=Object.keys(l).length>0?l:void 0}if(a.columnOrder&&Array.isArray(a.columnOrder)){const l=a.columnOrder.filter(c=>{const d=i.has(c);return d||n.push(`Column "${c}" in order ignored (column not found)`),d});a.columnOrder=l.length>0?l:void 0}if(a.columnWidths){const l={};Object.entries(a.columnWidths).forEach(([c,d])=>{i.has(c)?l[c]=d:n.push(`Column width for "${c}" ignored (column not found)`)}),a.columnWidths=Object.keys(l).length>0?l:void 0}return{sanitizedConfig:a,warnings:n}}function Xs(t,o){return vt("processing","export",t,{retryAvailable:!!(o!=null&&o.onRetry)})}function sn(t,o,n,i){const a=Xn(t,o,"system","error_occurred",null,{errorType:n.type,errorContext:n.context,errorMessage:n.message,recoverable:n.recoverable,timestamp:n.timestamp});return Qn(i||[],a)}function Qs(t){return t==null}function Zs(t,o){const{operator:n,value:i}=o;if(n==="NULL")return t==null;if(n==="NOT_NULL")return t!=null;if(Qs(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 ea(t,o){return!o||o.length===0?t:t.filter(n=>o.every(i=>Zs(n[i.column],i)))}function an(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 Ur(t){return t!=="isTrue"&&t!=="isFalse"&&t!=="NULL"&&t!=="NOT_NULL"}function ta({data:t,filters:o}){return{filteredData:p.useMemo(()=>!o||o.length===0?t:ea(t,o),[t,o])}}function ra(t,o,n,i){if(!n||n.trim()==="")return t;const a=n.toLowerCase().trim(),l=o.filter(c=>i.includes(c.name));return t.filter(c=>l.some(d=>{const u=c[d.name];return u==null?!1:String(u).toLowerCase().includes(a)}))}function oa({data:t,searchQuery:o,schema:n,visibleColumns:i}){return{searchedData:p.useMemo(()=>!o||o.trim()===""?t:ra(t,n,o,i),[t,o,n,i])}}function na({data:t,sortStack:o,schema:n}){return{sortedData:p.useMemo(()=>!o||o.length===0?t:ls(t,n,o),[t,o,n])}}function ia({data:t,grouping:o,schema:n}){const i=p.useMemo(()=>!o||!o.enabled||o.levels.length===0?t:xs(t,n,o),[t,o,n]),a=(o==null?void 0:o.enabled)&&((o==null?void 0:o.levels.length)||0)>0;return{groupedData:i,isGrouped:a}}function sa({schema:t,columnVisibility:o,columnOrder:n}){const i=p.useMemo(()=>n.filter(d=>o[d]!==!1),[n,o]),a=p.useMemo(()=>Object.entries(o).filter(([d,u])=>!u).map(([d,u])=>d),[o]),l=p.useMemo(()=>n.map(d=>t.find(f=>f.name===d)||{name:d,type:"string"}),[n,t]),c=p.useMemo(()=>i.map(d=>t.find(f=>f.name===d)||{name:d,type:"string"}),[i,t]);return{visibleColumns:i,hiddenColumns:a,allColumns:l,visibleColumnSchemas:c,hiddenCount:a.length}}function aa({views:t,activeViewId:o,currentState:n}){const i=p.useMemo(()=>t.find(f=>f.id===o),[t,o]),a=p.useMemo(()=>i?ms(n,i.snapshot):!1,[i,n]),l=p.useMemo(()=>t.find(f=>f.isDefault),[t]),c=p.useMemo(()=>t.filter(f=>!f.isDefault&&!f.isDeleted),[t]),d=p.useMemo(()=>t.filter(f=>f.isFavorite&&!f.isDeleted),[t]),u=p.useMemo(()=>t.filter(f=>f.isDeleted),[t]);return{activeView:i,isDirty:a,defaultView:l,customViews:c,favoriteViews:d,deletedViews:u,isDefaultView:(i==null?void 0:i.isDefault)||!1}}function la({data:t,enabled:o=!1,pageSize:n=100,initialPage:i=1}){const[a,l]=p.useState(i),c=t.length,d=Math.ceil(c/n),u=p.useMemo(()=>{if(!o)return t;const w=(a-1)*n,z=w+n;return t.slice(w,z)},[t,o,a,n]),f=p.useCallback(w=>{const z=Math.max(1,Math.min(w,d));l(z)},[d]),h=p.useCallback(()=>{a<d&&l(a+1)},[a,d]),m=p.useCallback(()=>{a>1&&l(a-1)},[a]),v=p.useCallback(()=>{l(1)},[]);return{paginatedData:u,currentPage:a,totalPages:d,pageSize:n,totalRows:c,goToPage:f,nextPage:h,prevPage:m,resetPage:v,hasNextPage:a<d,hasPrevPage:a>1}}function ca(t){const{rawData:o,schema:n,filters:i,sortStack:a,grouping:l,searchQuery:c,columnVisibility:d,columnOrder:u,columnWidths:f,views:h,activeViewId:m,pagination:v}=t,w=p.useMemo(()=>({filters:i,sortStack:a,grouping:l,columnVisibility:d,columnOrder:u,columnWidths:f}),[i,a,l,d,u,f]),z=aa({views:h,activeViewId:m,currentState:w}),y=sa({schema:n,columnVisibility:d,columnOrder:u}),{filteredData:j}=ta({data:o,filters:i}),{sortedData:b}=na({data:j,sortStack:a,schema:n}),{groupedData:g,isGrouped:S}=ia({data:b,grouping:l,schema:n}),{searchedData:s}=oa({data:g,searchQuery:c,schema:n,visibleColumns:y.visibleColumns}),I=la({data:s,enabled:(v==null?void 0:v.enabled)||!1,pageSize:(v==null?void 0:v.pageSize)||100,initialPage:(v==null?void 0:v.currentPage)||1}),A=v!=null&&v.enabled?I.paginatedData:s,H=p.useMemo(()=>({totalRows:o.length,filteredRows:j.length,sortedRows:b.length,groupedRows:S?g.length:b.length,searchedRows:s.length,visibleRows:A.length,hiddenColumns:y.hiddenCount,activeFilters:i.length,activeSorts:a.length,isGrouped:S}),[o.length,j.length,b.length,g.length,s.length,A.length,y.hiddenCount,i.length,a.length,S]);return{data:A,filteredData:j,sortedData:b,groupedData:g,searchedData:s,viewEngine:z,columnEngine:y,paginationEngine:I,metrics:H,isGrouped:S,isPaginated:(v==null?void 0:v.enabled)||!1}}let da=0;function ua(t){t!=null&&t.__urm_row_id__===void 0&&Object.defineProperty(t,"__urm_row_id__",{value:da++,writable:!1,enumerable:!1,configurable:!1})}const yt="user-demo-001";function pa(t={}){var Go,Yo,qo,Jo,Ko;const{mode:o="builder",autoLoad:n=!0,initialData:i,dataSource:a,reportName:l,sharedReportId:c,config:d={}}=t,[u,f]=p.useState([]),[h,m]=p.useState(""),[v,w]=p.useState(!1),[z,y]=p.useState(!1),[j,b]=p.useState({message:"",severity:"info",open:!1}),g=(C,T="info")=>{b({message:C,severity:T,open:!0})},S=()=>b(C=>({...C,open:!1})),s=u.find(C=>C.id===h),[I,A]=p.useState("idle"),[H,N]=p.useState(!1),[K,te]=p.useState(!1),[se,x]=p.useState(!1),[V,$]=p.useState(!1),[J,oe]=p.useState(!1),[ue,pe]=p.useState(!1),[_,O]=p.useState(void 0),[L,re]=p.useState(null),[Q,X]=p.useState(null),[ae,Z]=p.useState(!1),[W,ee]=p.useState(!1),[ie,ne]=p.useState(null),[ke,U]=p.useState(!1),[Oe,Le]=p.useState(!1),[dt,$r]=p.useState({enabled:!1,levels:[],collapsedGroups:[]}),[Re,jt]=p.useState(""),[Ae,Ge]=p.useState(new Set),[Ke,Xe]=p.useState(1),[_e,wt]=p.useState(15),[Yt,rt]=p.useState(!1),[Qe,$e]=p.useState(!1),[dr,qt]=p.useState(!1),[ot,kt]=p.useState(null),[At,ut]=p.useState(!1),[ur,Nr]=p.useState(null),[Mt,pr]=p.useState(null);p.useRef(new Hs),p.useRef(new Hr),p.useRef(new Hr),p.useRef(new Hr),p.useRef(new Hr);const[Wt,Ze]=p.useState(null),Tt=p.useRef(null),je=p.useMemo(()=>s?zs(s.permissions,yt):"owner",[s]),xr=Is(je),zt=p.useMemo(()=>!(s!=null&&s.uploadedData)||!(s!=null&&s.schema)?{totalRows:0,totalColumns:0}:Fs(s.uploadedData,s.schema),[s==null?void 0:s.uploadedData,s==null?void 0:s.schema]),nt=p.useCallback(()=>{s&&(Tt.current=Ys(s))},[s]),P=p.useCallback((C,T)=>{f(B=>B.map(E=>E.id===C?{...E,...T}:E))},[]),et=p.useCallback(C=>{if(!s)return;Ze(C);const T=sn(s.id,yt,C,s.auditHistory||[]);P(s.id,{auditHistory:T}),g(C.message,"error"),C.recoverable&&Tt.current&&setTimeout(()=>{qs(s,Tt.current,P),g("Previous state restored","success")},100)},[s,P]),ge=p.useCallback((C,T,B,E)=>{if(!s)return;const q=Xn(s.id,yt,C,T,B,E),Y=s.auditHistory||[],ye=Qn(Y,q);setTimeout(()=>{P(s.id,{auditHistory:ye})},0)},[s,P]);p.useEffect(()=>{if(s!=null&&s.schemaLocked&&s.schema&&(!s.views||s.views.length===0)){const C=jo(s.schema);(()=>{try{const T=localStorage.getItem("urm_dev_config");return T?JSON.parse(T):null}catch{return null}})(),P(s.id,{views:[C],activeViewId:C.id,filters:C.snapshot.filters,sortStack:C.snapshot.sortStack,columnVisibility:C.snapshot.columnVisibility,columnOrder:C.snapshot.columnOrder,columnWidths:C.snapshot.columnWidths,grouping:C.snapshot.grouping})}},[s==null?void 0:s.schemaLocked,s==null?void 0:s.schema,s==null?void 0:s.id,P]),p.useEffect(()=>{if(i&&n&&!z&&u.length===0){const C=Kr(i),T={id:`auto-report-${Date.now()}`,name:l||(o==="viewer"?"Data View":"Imported Data"),description:"Auto-generated from external data",schemaLocked:!0,uploadedData:C,schema:Tr(C),permissions:{owner:yt,editors:[],viewers:[]}};f([T]),m(T.id),y(!0),A("confirmed")}},[i,n,z,u.length,o,l]),p.useEffect(()=>{if(!a||z)return;let C=!1,T=null;const B=async()=>{try{A("uploading");let E;if(a.type==="api"){const Y=await fetch(a.url,{headers:a.headers||{}});if(!Y.ok)throw new Error(`HTTP ${Y.status}: ${Y.statusText}`);E=await Y.json()}else E=await a.fetch();if(C)return;if(!Array.isArray(E))throw new Error("Data source must return an array of objects");const q=Tr(E);if(z)f(Y=>Y.map(ye=>ye.id===h?{...ye,uploadedData:E}:ye)),A("confirmed");else{const Y={id:`auto-report-${Date.now()}`,name:l||(o==="viewer"?"Data View":"Imported Data"),description:`Loaded from ${a.type==="api"?a.url:"callback"}`,schemaLocked:!0,uploadedData:Kr(E),schema:Tr(Kr(E)),permissions:{owner:yt,editors:[],viewers:[]}};f([Y]),m(Y.id),y(!0),A("confirmed")}}catch(E){C||(A("error"),s&&P(s.id,{uploadError:(E==null?void 0:E.message)||"Failed to load data from source"}))}};return B(),a.refreshInterval&&a.refreshInterval>0&&(T=setInterval(B,a.refreshInterval)),()=>{C=!0,T&&clearInterval(T)}},[a,l,o]);const Pe=(Go=s==null?void 0:s.views)==null?void 0:Go.find(C=>C.id===s.activeViewId),Rt=p.useMemo(()=>s!=null&&s.uploadedData?(s.uploadedData.forEach(ua),s.showFavoritesOnly?!s.favoriteRowIndices||s.favoriteRowIndices.length===0?[]:s.uploadedData.filter((C,T)=>s.favoriteRowIndices.includes(T)):s.uploadedData):[],[s==null?void 0:s.uploadedData,s==null?void 0:s.showFavoritesOnly,s==null?void 0:s.favoriteRowIndices]),fr=p.useMemo(()=>{var T;if(!(s!=null&&s.uploadedData)||!((T=s==null?void 0:s.favoriteRowIndices)!=null&&T.length))return new Set;const C=new Set;return s.favoriteRowIndices.forEach(B=>{const E=s.uploadedData[B];E!==void 0&&C.add(E)}),C},[s==null?void 0:s.uploadedData,s==null?void 0:s.showFavoritesOnly,s==null?void 0:s.favoriteRowIndices]),pt=ca({rawData:Rt,schema:(s==null?void 0:s.schema)||[],filters:(s==null?void 0:s.filters)||[],sortStack:(s==null?void 0:s.sortStack)||[],grouping:(s==null?void 0:s.grouping)||null,searchQuery:Re||"",columnVisibility:(s==null?void 0:s.columnVisibility)||(Pe==null?void 0:Pe.snapshot.columnVisibility)||{},columnOrder:(s==null?void 0:s.columnOrder)||(Pe==null?void 0:Pe.snapshot.columnOrder)||[],columnWidths:(s==null?void 0:s.columnWidths)||(Pe==null?void 0:Pe.snapshot.columnWidths)||{},views:(s==null?void 0:s.views)||[],activeViewId:(s==null?void 0:s.activeViewId)||"",pagination:{enabled:!0,pageSize:_e,currentPage:Ke}}),{data:hr=[],searchedData:Ye=[],groupedData:Jt=[],metrics:_t={totalRows:0,searchedRows:0,isGrouped:!1},isGrouped:Kt=!1,paginationEngine:Te}=pt||{},F=((Yo=pt.viewEngine)==null?void 0:Yo.activeView)||Pe,Me=((qo=pt.viewEngine)==null?void 0:qo.isDirty)||!1;p.useEffect(()=>{if(!(!F||!s)&&!s.columnOrder){const C=F.snapshot.columnOrder,T=Br(C,F.snapshot.grouping);P(s.id,{columnOrder:T})}},[s==null?void 0:s.activeViewId]);const Ce=p.useMemo(()=>!(s!=null&&s.schema)||!F?null:hs(s.filters||[],s.sortStack||[],s.schema,s.columnVisibility,s.columnOrder,s.columnWidths,s.grouping,F.snapshot.columnOrder),[s==null?void 0:s.filters,s==null?void 0:s.sortStack,s==null?void 0:s.schema,s==null?void 0:s.columnVisibility,s==null?void 0:s.columnOrder,s==null?void 0:s.columnWidths,s==null?void 0:s.grouping,F]),it=p.useMemo(()=>!F||!Ce||!Me?[]:ys(Ce,F.snapshot),[F,Ce,Me]),Ne=p.useCallback((C,T,B)=>{const E={id:`report-${Date.now()}`,name:C,description:T,schemaLocked:!1,permissions:{owner:yt,editors:[],viewers:[]}};if(B&&Array.isArray(B)&&B.length>0){const q=Tr(B),Y=jo(q);E.uploadedData=B,E.schema=q,E.schemaLocked=!0,E.views=[Y],E.activeViewId=Y.id,E.sortStack=Y.snapshot.sortStack,E.filters=Y.snapshot.filters,E.columnVisibility=Y.snapshot.columnVisibility,E.columnOrder=Y.snapshot.columnOrder,E.columnWidths=Y.snapshot.columnWidths,E.grouping=Y.snapshot.grouping}f(q=>[...q,E]),m(E.id),w(!1),A("confirmed")},[]),mr=p.useCallback(C=>{s&&(A("uploading"),setTimeout(()=>{const T=Tr(C);P(s.id,{uploadedData:C,schema:T,uploadError:void 0}),A("preview")},500))},[s,P]),gr=p.useCallback(C=>{s&&(P(s.id,{uploadError:C}),A("idle"))},[s,P]),Xt=p.useCallback(()=>{s&&(P(s.id,{uploadError:void 0,uploadedData:void 0,schema:void 0}),A("idle"))},[s,P]),yr=p.useCallback(()=>{s&&(P(s.id,{schemaLocked:!0}),A("confirmed"))},[s,P]),br=p.useCallback(C=>{if(!s)return;if(!mt("edit_sorting",je)){g(gt("edit_sorting"),"error");return}const T=s.sortStack??[],B=T.find(E=>E.column===C);if(B){const E=cs(B.direction);if(E===null){const q=T.filter(Y=>Y.column!==C).map((Y,ye)=>({...Y,priority:ye+1}));P(s.id,{sortStack:q.length>0?q:void 0})}else{const q=T.map(Y=>Y.column===C?{...Y,direction:E}:Y);P(s.id,{sortStack:q})}}else{if(T.length>=3)return;const E={column:C,direction:"asc",priority:T.length+1};P(s.id,{sortStack:[...T,E]})}},[s,je,P]),Qt=p.useCallback(C=>{if(s)if(s.schema){const{validRules:T,invalidColumns:B}=Zn(C,s.schema);B.length>0&&g(`Removed invalid sort columns: ${B.join(", ")}`),nt();try{P(s.id,{sortStack:T.length>0?T:void 0})}catch(E){const q=vt("processing","sorting",E);et(q)}}else P(s.id,{sortStack:C.length>0?C:void 0})},[s,P,nt,et]),Zt=p.useCallback(C=>{if(!s)return;const T=s.sortStack??[],B=T.find(E=>E.column===C);if(!(B&&B.direction==="asc"))if(B){const E=T.map(q=>q.column===C?{...q,direction:"asc"}:q);P(s.id,{sortStack:E})}else{if(T.length>=3)return;const E={column:C,direction:"asc",priority:T.length+1};P(s.id,{sortStack:[...T,E]})}},[s,P]),Ve=p.useCallback(C=>{if(!s)return;const T=s.sortStack??[],B=T.find(E=>E.column===C);if(!(B&&B.direction==="desc"))if(B){const E=T.map(q=>q.column===C?{...q,direction:"desc"}:q);P(s.id,{sortStack:E})}else{if(T.length>=3)return;const E={column:C,direction:"desc",priority:T.length+1};P(s.id,{sortStack:[...T,E]})}},[s,P]),st=p.useCallback(C=>{var B;if(!s)return;if(!mt("edit_filters",je)){g(gt("edit_filters"),"error");return}const T=(B=s.schema)==null?void 0:B.find(E=>E.name===C.column);if(T&&C.value!==void 0){const E=Js(T.type,C.operator,C.value);if(!E.isValid){g(E.errorMessage||"Invalid filter value","error");return}}nt();try{const E=s.filters??[];ge("filters","filter_added",E,[...E,C]),P(s.id,{filters:[...E,C]})}catch(E){const q=vt("processing","filters",E);et(q)}},[s,je,P,nt,et,ge]),Pt=p.useCallback((C,T)=>{if(!s)return;if(!mt("edit_filters",je)){g(gt("edit_filters"),"error");return}const B=s.filters??[],E=[...B];ge("filters","filter_updated",B[C],T),E[C]=T,P(s.id,{filters:E})},[s,je,P,ge]),It=p.useCallback(C=>{if(!s)return;if(!mt("edit_filters",je)){g(gt("edit_filters"),"error");return}const T=s.filters??[],B=T.filter((E,q)=>q!==C);ge("filters","filter_removed",T[C],null),P(s.id,{filters:B.length>0?B:void 0})},[s,je,P,ge]),xt=p.useCallback(()=>{if(!s)return;if(!mt("edit_filters",je)){g(gt("edit_filters"),"error");return}const C=s.filters??[];ge("filters","filter_cleared",C,null),P(s.id,{filters:void 0})},[s,je,P,ge]),at=p.useCallback(C=>{var q;if(!s)return;const T=(q=s.views)==null?void 0:q.find(Y=>Y.id===C);if(!T)return;const B=T.snapshot.columnOrder,E=Br(B,T.snapshot.grouping);P(s.id,{filters:T.snapshot.filters.length>0?[...T.snapshot.filters]:void 0,sortStack:T.snapshot.sortStack.length>0?[...T.snapshot.sortStack]:void 0,columnVisibility:{...T.snapshot.columnVisibility},columnOrder:E,columnWidths:{...T.snapshot.columnWidths},grouping:T.snapshot.grouping,activeViewId:C}),Ge(new Set),x(!1)},[s,P]),$t=p.useCallback((C,T,B)=>{if(!(s!=null&&s.schema)||!Ce)return;const E={id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:C,description:T||void 0,isDefault:B,isFavorite:!1,isDeleted:!1,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...Ce}},q=s.views??[],Y=B?q.map(ye=>({...ye,isDefault:!1})):q;P(s.id,{views:[...Y,E],activeViewId:E.id}),g(`"${C}" view created`,"success")},[s,Ce,P]),Nt=p.useCallback(()=>{var T;if(!F||!Ce||F.isDefault||!s)return;const C=(T=s.views)==null?void 0:T.map(B=>B.id===F.id?{...B,snapshot:{...Ce}}:B);P(s.id,{views:C}),g(`"${F.name}" view updated`,"success")},[F,Ce,s,P]),vr=p.useCallback(C=>{var E;if(!F||!Ce||!s)return;const T=C??Ce.columnWidths,B=(E=s.views)==null?void 0:E.map(q=>q.id===F.id?{...q,snapshot:{...q.snapshot,columnVisibility:Ce.columnVisibility,columnOrder:Ce.columnOrder,columnWidths:T},updatedAt:Date.now()}:q);P(s.id,{views:B,columnWidths:T}),g(`Column configuration saved to "${F.name}"`,"success")},[F,Ce,s,P]),Sr=p.useCallback(C=>{var Y,ye;if(!Ce||!s||!F)return;const T=C??Ce.columnWidths,B={...F,snapshot:{...F.snapshot,columnVisibility:Ce.columnVisibility,columnOrder:Ce.columnOrder,columnWidths:T},updatedAt:Date.now()},E=(Y=s.views)==null?void 0:Y.map(ze=>ze.id===F.id?B:{...ze,snapshot:{...ze.snapshot,columnVisibility:Ce.columnVisibility,columnOrder:Ce.columnOrder,columnWidths:T},updatedAt:Date.now()});P(s.id,{views:E,columnWidths:T});const q=(((ye=s.views)==null?void 0:ye.length)||0)-1;g(`Column configuration saved to current view and ${q} other view${q===1?"":"s"}`,"success")},[Ce,s,F,P]),Cr=p.useCallback(()=>{$(!0)},[]),jr=p.useCallback(()=>{if(!F||!s)return;const C=F.snapshot.columnOrder,T=Br(C,F.snapshot.grouping);P(s.id,{filters:F.snapshot.filters.length>0?[...F.snapshot.filters]:void 0,sortStack:F.snapshot.sortStack.length>0?[...F.snapshot.sortStack]:void 0,columnVisibility:{...F.snapshot.columnVisibility},columnOrder:T,columnWidths:{...F.snapshot.columnWidths},grouping:F.snapshot.grouping}),g("Changes reverted to last saved state","success")},[F,s,P]),er=p.useCallback(C=>{if(!(s!=null&&s.views))return;const T=s.views.map(E=>({...E,isDefault:E.id===C}));P(s.id,{views:T});const B=s.views.find(E=>E.id===C);B&&g(`"${B.name}" set as default view`,"success")},[s,P]),wr=p.useCallback(C=>{if(!(s!=null&&s.views))return;const T=s.views.map(E=>E.id===C?{...E,isFavorite:!E.isFavorite,updatedAt:Date.now()}:E);P(s.id,{views:T});const B=s.views.find(E=>E.id===C);B&&!B.isFavorite?g(`"${B.name}" added to favorites`,"success"):B&&g(`"${B.name}" removed from favorites`,"info")},[s,P]),Be=p.useCallback(C=>{if(!(s!=null&&s.views))return;const T=s.views.map(Y=>Y.id===C?{...Y,isDeleted:!0,updatedAt:Date.now()}:Y),B=s.activeViewId===C,E=T.find(Y=>Y.isDefault&&!Y.isDeleted);P(s.id,{views:T,activeViewId:B&&E?E.id:s.activeViewId,filters:B&&E?E.snapshot.filters.length>0?E.snapshot.filters:void 0:s.filters,sortStack:B&&E?E.snapshot.sortStack.length>0?E.snapshot.sortStack:void 0:s.sortStack});const q=s.views.find(Y=>Y.id===C);q&&g(`"${q.name}" moved to Recently Deleted`,"info")},[s,P]),ft=p.useCallback(C=>{if(!(s!=null&&s.views))return;const T=s.views.map(E=>E.id===C?{...E,isDeleted:!1,updatedAt:Date.now()}:E);P(s.id,{views:T});const B=s.views.find(E=>E.id===C);B&&g(`"${B.name}" restored`,"success")},[s,P]),tr=p.useCallback(C=>{if(!(s!=null&&s.views))return;const T=s.views.find(ze=>ze.id===C),B=s.views.filter(ze=>!ze.isDeleted||ze.id===C);if((T==null?void 0:T.isDefault)&&B.filter(ze=>ze.isDefault).length===1){g("Cannot delete the last default view","error");return}const q=s.views.filter(ze=>ze.id!==C),Y=s.activeViewId===C,ye=q.find(ze=>ze.isDefault&&!ze.isDeleted);P(s.id,{views:q,activeViewId:Y&&ye?ye.id:s.activeViewId,filters:Y&&ye?ye.snapshot.filters.length>0?ye.snapshot.filters:void 0:s.filters,sortStack:Y&&ye?ye.snapshot.sortStack.length>0?ye.snapshot.sortStack:void 0:s.sortStack}),T&&g(`"${T.name}" permanently deleted`,"success")},[s,P]),Fr=p.useCallback(C=>{re(C),oe(!0),x(!1)},[]),ht=p.useCallback((C,T)=>{if(!L||!(s!=null&&s.views))return;const B=s.views.map(E=>E.id===L?{...E,name:C,description:T||void 0}:E);P(s.id,{views:B}),re(null)},[L,s,P]),kr=p.useCallback(C=>{X(C),pe(!0),x(!1)},[]),rr=p.useCallback(()=>{if(!Q||!(s!=null&&s.views))return;const C=s.views.filter(E=>E.id!==Q),T=s.activeViewId===Q,B=C.find(E=>E.isDefault);P(s.id,{views:C,activeViewId:T&&B?B.id:s.activeViewId,filters:T&&B?B.snapshot.filters.length>0?B.snapshot.filters:void 0:s.filters,sortStack:T&&B?B.snapshot.sortStack.length>0?B.snapshot.sortStack:void 0:s.sortStack}),X(null),pe(!1)},[Q,s,P]);p.useEffect(()=>{if(!Re||!Re.trim())return;const C=Ye.filter(T=>!(T!=null&&T.isGroupHeader));C.length!==0&&Ge(new Set(C))},[Re,Ye]),p.useEffect(()=>{Te!=null&&Te.resetPage?Te.resetPage():Xe(1)},[s==null?void 0:s.filters,Re,s==null?void 0:s.activeViewId]),p.useEffect(()=>{Te&&Te.currentPage!==Ke&&Xe(Te.currentPage)},[Te==null?void 0:Te.currentPage]);const D=p.useCallback(C=>{Te!=null&&Te.goToPage&&Te.goToPage(C),Xe(C)},[Te]),G=p.useCallback(C=>{const T=(Ke-1)*_e,B=Math.floor(T/C)+1;wt(C),Xe(B)},[Ke,_e]),de=p.useCallback((C,T)=>{if(!s)return;if(!mt("edit_columns",je)){g(gt("edit_columns"),"error");return}const E={...s.columnVisibility||(F==null?void 0:F.snapshot.columnVisibility)||{},[C]:T};P(s.id,{columnVisibility:E})},[s,F,je,P]),We=p.useCallback(C=>{if(s){if(!mt("edit_columns",je)){g(gt("edit_columns"),"error");return}P(s.id,{columnOrder:C})}},[s,je,P]),le=p.useCallback((C,T)=>{if(!s)return;if(!mt("edit_columns",je)){g(gt("edit_columns"),"error");return}const E={...s.columnWidths||(F==null?void 0:F.snapshot.columnWidths)||{},[C]:T};P(s.id,{columnWidths:E})},[s,F,je,P]),ce=p.useCallback(C=>{if(!s)return;const B=(s.filters??[]).filter(E=>E.column!==C);P(s.id,{filters:B.length>0?B:void 0})},[s,P]),Se=p.useCallback(()=>{if(!F||!(s!=null&&s.schema))return;const C={},T=[],B={};s.schema.forEach(E=>{C[E.name]=!0,T.push(E.name),B[E.name]=150}),P(s.id,{columnVisibility:C,columnOrder:T,columnWidths:B,filters:void 0,sortStack:void 0}),g("Reset to default layout - all filters and sorts cleared","success")},[F,s,P]),Fe=p.useCallback(Vs(C=>{jt(C)},300),[]),So=p.useCallback(C=>{Fe(C)},[Fe]),Et=p.useCallback(C=>{if(!C.trim()||!s)return;const T=s.searchHistory||[],B=Cs(T,C);P(s.id,{searchHistory:B})},[s,P]),Co=p.useCallback(C=>{if(!s)return;const T=s.searchHistory||[],B=js(T,C);P(s.id,{searchHistory:B})},[s,P]),Bi=p.useCallback(C=>{if(!s)return;const T=s.searchHistory||[],B=ws(T,C);P(s.id,{searchHistory:B})},[s,P]),Oi=p.useCallback(C=>{Ge(T=>{const B=new Set(T);return B.has(C)?B.delete(C):B.add(C),B})},[]),Ai=p.useCallback((C,T)=>{Ge(B=>{const E=new Set(B);for(const q of T)C?E.add(q):E.delete(q);return E})},[]),Mi=p.useCallback((C,T,B)=>{Ge(E=>{const q=new Set(E),Y=Math.min(C,T),ye=Math.max(C,T);for(let ze=Y;ze<=ye;ze++)B[ze]!==void 0&&q.add(B[ze]);return q})},[]),Wi=p.useCallback(()=>{Ge(new Set)},[]),Ri=p.useCallback(C=>{Ge(T=>{const B=new Set(T);return B.delete(C),B})},[]),_i=p.useCallback(C=>{if(!(s!=null&&s.uploadedData))return;const T=s.uploadedData.indexOf(C);if(T===-1)return;const B=s.favoriteRowIndices||[],q=B.includes(T)?B.filter(Y=>Y!==T):[...B,T];P(s.id,{favoriteRowIndices:q})},[s,P]),Pi=p.useCallback((C,T)=>{if(!(s!=null&&s.uploadedData))return;const B=s.favoriteRowIndices||[],E=C.map(Y=>s.uploadedData.indexOf(Y)).filter(Y=>Y!==-1),q=T?[...B,...E.filter(Y=>!B.includes(Y))]:B.filter(Y=>!E.includes(Y));P(s.id,{favoriteRowIndices:q})},[s,P]),$i=p.useCallback(()=>{if(!s)return;const C=s.favoriteRowIndices||[],T=!s.showFavoritesOnly;if(T&&C.length===0){g("No rows marked as favorite","warning");return}P(s.id,{showFavoritesOnly:T}),Ge(new Set),g(T?`Showing ${C.length} favorite row${C.length===1?"":"s"}`:"Showing all data","info")},[s,P]),Ni=p.useCallback(C=>{if(s){if(!mt("edit_columns",je)){g(gt("edit_columns"),"error");return}if(C&&s.schema){const{validGrouping:T,invalidColumns:B}=ei(C,s.schema);B.length>0&&g(`Removed invalid grouping columns: ${B.join(", ")}`,"warning"),nt();try{const E=s.grouping;T===null?ge("grouping","group_cleared",E,null):E?ge("grouping","group_reordered",E,T):ge("grouping","group_level_added",null,T);const q=(F==null?void 0:F.snapshot.columnOrder)||s.columnOrder||[],Y=Br(q,T);P(s.id,{grouping:T,columnOrder:Y}),JSON.stringify(Y)!==JSON.stringify(s.columnOrder)&&ge("columns","column_reordered",s.columnOrder,Y),Le(!1)}catch(E){const q=vt("processing","grouping",E);et(q)}}else{const T=s.grouping;ge("grouping","group_cleared",T,null);const B=(F==null?void 0:F.snapshot.columnOrder)||s.columnOrder||[];P(s.id,{grouping:C,columnOrder:[...B]}),JSON.stringify(B)!==JSON.stringify(s.columnOrder)&&ge("columns","column_reordered",s.columnOrder,B),Le(!1)}}},[s,F,je,P,nt,et,ge]),Fi=p.useCallback(C=>{if(!s)return;const T=s.grouping;if(!T)return;const B=fs(T,C);P(s.id,{grouping:B})},[s,P]),Li=p.useCallback(()=>{ut(!0)},[]),or=p.useCallback(C=>{s!=null&&s.schema&&(Z(!0),setTimeout(()=>{try{let T;C.scope==="visible"?T=Ye:T=s.uploadedData||[];let B;C.columnScope==="all"?(B={},s.schema.forEach(ze=>{B[ze.name]=!0})):B=s.columnVisibility||(F==null?void 0:F.snapshot.columnVisibility)||{};const E=s.columnOrder||(F==null?void 0:F.snapshot.columnOrder),q=Qr(T,s.schema,s.filters??[],s.sortStack??[],F,B,E),Y=s.name;let ye;switch(C.format){case"csv":Zr(q,Y,C),ye="export_csv";break;case"excel":eo(q,Y,C),ye="export_excel";break;case"json":to(q,Y,C),ye="export_json";break}ge("export",ye,null,{format:C.format,scope:C.scope,columnScope:C.columnScope,rowCount:T.length,viewName:(F==null?void 0:F.name)||"Default View"}),g(`Export completed successfully (${C.format.toUpperCase()})`,"success")}catch(T){const B=Xs(T,{onRetry:()=>or(C)});g(`Export failed: ${B.message}`,{action:{label:"Retry",onClick:()=>or(C)}});const E=sn(s.id,yt,B,s.auditHistory||[]);P(s.id,{auditHistory:E}),Vt.error("urm:report-engine","Export failed",T)}finally{Z(!1)}},500))},[s,F,Ye,P,ge]),Vi=p.useCallback(C=>{if(s!=null&&s.schema){if(Me&&F&&!F.isDefault){ne(C.format),ee(!0),ut(!1);return}or(C),ut(!1)}},[s,F,Me,or]),Lr=p.useCallback(C=>{or({format:C,scope:"visible",columnScope:"visible"})},[or]),Hi=p.useCallback(()=>{ie&&Lr(ie),ee(!1),ne(null)},[ie,Lr]),Ui=p.useCallback(()=>{Nt(),ie&&Lr(ie),ee(!1),ne(null)},[Nt,ie,Lr]),Gi=p.useCallback(()=>{ee(!1),ne(null)},[]),Yi=p.useCallback(C=>{!(s!=null&&s.schema)||Ae.size===0||(Z(!0),setTimeout(()=>{try{const T=Array.from(Ae),B=Qr(T,s.schema,s.filters??[],s.sortStack??[],F),E=`${s.name.toLowerCase().replace(/\s+/g,"_")}_selected_export`;switch(C){case"csv":Zr(B,E);break;case"excel":eo(B,E);break;case"json":to(B,E);break}g(`Exported ${T.length} selected rows`,"info")}catch(T){g("Export failed. Please try again.","error"),Vt.error("urm:report-engine","Bulk export failed",T)}finally{Z(!1)}},500))},[s,F,Ae,Jt]),qi=p.useCallback((C,T)=>{if(s)try{const B=Ws(s),E=Rs(C,T,yt,B),q=_s(s.presets,E);P(s.id,{presets:q}),ge("presets","preset_created",null,{presetId:E.id,name:E.name}),$e(!1),g(`Preset "${C}" saved successfully`,"success")}catch(B){g(B instanceof Error?B.message:"Failed to create preset","error")}},[s,P,ge]),Ji=p.useCallback(()=>{kt(null),g("Exited preset view","info")},[]),Ki=p.useCallback(()=>{qt(!0)},[]),Xi=p.useCallback((C,T)=>{if(!s)return;const B=Ps(s.presets,C);P(s.id,{presets:B}),ge("presets","preset_deleted",{presetId:C,name:T},null),ot===C&&kt(null),g(`Preset "${T}" deleted`,"success")},[s,ot,P,ge]);p.useEffect(()=>{if(!c||u.length===0)return;const C=u.find(T=>T.id===c);C&&C.id!==h&&m(C.id)},[c,u,h]),p.useEffect(()=>{if(!s)return;const C=$s();if(C&&s.presets&&s.schemaLocked&&s.schema){const T=nn(s.presets,C);if(T){const{sanitizedConfig:B,warnings:E}=Ks(T.config,s.schema);E.length>0&&E.forEach(Y=>g(Y,"warning"));const q=Ns(B);P(s.id,q),kt(C),ge("presets","preset_applied",null,{presetId:T.id,name:T.name}),g(`Loaded preset: ${T.name}`,"info")}else g("Preset not found","info")}},[s==null?void 0:s.schemaLocked]);const Qi=ot?nn(s==null?void 0:s.presets,ot):void 0;p.useEffect(()=>{s!=null&&s.views&&s.views.length>0&&s.activeViewId&&bs(s.id,{views:s.views,activeViewId:s.activeViewId})},[s==null?void 0:s.views,s==null?void 0:s.activeViewId,s==null?void 0:s.id]),p.useEffect(()=>{if(s!=null&&s.schemaLocked&&s.schema&&(!s.views||s.views.length===0)){const C=vs(s.id);if(C&&C.views.length>0){const T=C.views.find(B=>B.id===C.activeViewId);if(T)P(s.id,{views:C.views,activeViewId:C.activeViewId,filters:T.snapshot.filters.length>0?T.snapshot.filters:void 0,sortStack:T.snapshot.sortStack.length>0?T.snapshot.sortStack:void 0});else{const B=C.views.find(E=>E.isDefault)||jo(s.schema);P(s.id,{views:C.views,activeViewId:B.id,filters:B.snapshot.filters.length>0?B.snapshot.filters:void 0,sortStack:B.snapshot.sortStack.length>0?B.snapshot.sortStack:void 0})}}}},[s==null?void 0:s.schemaLocked,s==null?void 0:s.schema,s==null?void 0:s.id]);const Zi=p.useCallback(C=>{O(C),N(!0)},[]),es=p.useCallback(()=>{N(!1),O(void 0)},[]),ts=(Jo=s==null?void 0:s.views)==null?void 0:Jo.find(C=>C.id===L),rs=(Ko=s==null?void 0:s.views)==null?void 0:Ko.find(C=>C.id===Q);return{reports:u,activeReport:s,activeReportId:h,setActiveReportId:m,isModalOpen:v,setIsModalOpen:w,createReport:Ne,updateReport:P,uploadState:I,handleFileUpload:mr,handleUploadError:gr,handleRetry:Xt,handleConfirm:yr,paginatedData:hr,processedData:Ye,displayData:Jt,tableMetrics:_t,isGrouped:Kt,tableEngine:pt,activeView:F,isDirty:Me,currentTableState:Ce,viewChanges:it,filters:s==null?void 0:s.filters,showFilterPanel:H,setShowFilterPanel:N,filterFocusColumn:_,handleAddFilter:st,handleUpdateFilter:Pt,handleRemoveFilter:It,handleClearAllFilters:xt,handleOpenFilterForColumn:Zi,handleCloseFilterPanel:es,handleClearFiltersForColumn:ce,sortStack:s==null?void 0:s.sortStack,showSortPanel:K,setShowSortPanel:te,handleSort:br,handleUpdateSortStack:Qt,handleSortAscending:Zt,handleSortDescending:Ve,views:s==null?void 0:s.views,showManageViews:se,setShowManageViews:x,showCreateViewModal:V,setShowCreateViewModal:$,showEditViewModal:J,setShowEditViewModal:oe,showDeleteConfirmation:ue,setShowDeleteConfirmation:pe,editingView:ts,deletingView:rs,editingViewId:L,deletingViewId:Q,handleSelectView:at,handleCreateView:$t,handleUpdateCurrentView:Nt,handleSaveColumnConfigToCurrentView:vr,handleSaveColumnConfigToAllViews:Sr,handleSaveAsNewView:Cr,handleRevertChanges:jr,handleToggleDefault:er,handleToggleFavorite:wr,handleSoftDelete:Be,handleRestoreView:ft,handlePermanentDelete:tr,handleEditView:Fr,handleSaveEditView:ht,handleDeleteView:kr,handleConfirmDelete:rr,showManageColumns:ke,setShowManageColumns:U,columnVisibility:s==null?void 0:s.columnVisibility,columnOrder:s==null?void 0:s.columnOrder,columnWidths:s==null?void 0:s.columnWidths,handleUpdateColumnVisibility:de,handleUpdateColumnOrder:We,handleUpdateColumnWidth:le,handleResetColumnLayout:Se,showGroupPanel:Oe,setShowGroupPanel:Le,grouping:s==null?void 0:s.grouping,groupingState:dt,handleGroup:Ni,handleToggleGroupCollapse:Fi,searchQuery:Re,searchHistory:ks((s==null?void 0:s.searchHistory)||[]),handleSearchChange:So,handleAddToSearchHistory:Et,handleToggleSearchFavourite:Co,handleDeleteSearchHistory:Bi,selectedRowIds:Ae,handleToggleRowSelection:Oi,handleToggleAllRows:Ai,handleRangeSelection:Mi,handleClearSelection:Wi,handleUpdateSelectionAfterDelete:Ri,favoriteRowIndices:(s==null?void 0:s.favoriteRowIndices)||[],resolvedFavoritesSet:fr,showFavoritesOnly:(s==null?void 0:s.showFavoritesOnly)||!1,handleToggleRowFavorite:_i,handleBulkSetFavorites:Pi,handleToggleFavoritesFilter:$i,currentPage:Ke,pageSize:_e,paginationEngine:Te,handlePageChange:D,handlePageSizeChange:G,isExporting:ae,showExportModal:At,setShowExportModal:ut,showDirtyExportWarning:W,handleExport:Li,handleExportWithConfig:Vi,handleExportSelected:Yi,handleExportAnyway:Hi,handleSaveAndExport:Ui,handleCancelExport:Gi,showAuditHistory:Yt,setShowAuditHistory:rt,auditHistory:s==null?void 0:s.auditHistory,showCreatePreset:Qe,setShowCreatePreset:$e,showManagePresets:dr,setShowManagePresets:qt,activePreset:Qi,activePresetId:ot,handleOpenManagePresets:Ki,handleCreatePreset:qi,handleClearActivePreset:Ji,handleDeletePresetById:Xi,userRole:je,isViewerRole:xr,currentUserId:yt,featureLimitWarning:Mt,setFeatureLimitWarning:pr,datasetMeta:zt,reportError:Wt,setReportError:Ze,handleError:et,schema:s==null?void 0:s.schema,hasSchemaConflicts:s!=null&&s.schema?ss(s.schema):!1,snack:j,handleSnackClose:S,showSnack:g}}const tt={sort:{maxLevels:5},filter:{maxConditions:10,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"]},display:{showDevPanel:!1}},ti="urm_dev_config";function xa(){try{const t=localStorage.getItem(ti);if(!t)return tt;const o=JSON.parse(t),n={sort:{...tt.sort,...o.sort},filter:{...tt.filter,...o.filter},columns:{...tt.columns,...o.columns},grouping:{...tt.grouping,...o.grouping},export:{...tt.export,...o.export},display:{...tt.display,...o.display}};return n.sort.maxLevels=Math.min(5,Math.max(1,n.sort.maxLevels)),n}catch{return tt}}function fa(t){try{localStorage.setItem(ti,JSON.stringify(t))}catch{}}function ha(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},display:{...t.display,...o.display}};return i.sort.maxLevels=Math.min(5,Math.max(1,i.sort.maxLevels)),i}const ri=p.createContext(tt);function Rr(){return p.useContext(ri)}const oi=p.createContext(void 0);function No(t){const{children:o,initialData:n,data:i,reportName:a,dataSource:l,mode:c="builder",autoLoad:d=!0,config:u,devConfig:f,showDevPanel:h=!1,sharedReportId:m}=t,w=pa({mode:c,autoLoad:d,initialData:i||n,dataSource:l,reportName:a,sharedReportId:m,config:u}),[z,y]=p.useState(()=>xa()),j=(()=>{const s=ha(z,f,!!f);return{...s,display:{...s.display,showDevPanel:h||s.display.showDevPanel}}})(),b=p.useCallback(S=>{y(S),fa(S)},[]),g={...w,activeDevConfig:j,handleDevConfigChange:b};return e.jsx(ri.Provider,{value:j,children:e.jsx(oi.Provider,{value:g,children:o})})}function io(){const t=p.useContext(oi);if(t===void 0)throw new Error("useReportContext must be used within a ReportProvider. Wrap your component tree with <ReportProvider>...</ReportProvider>");return t}function ma({onCreateReport:t,reports:o=[],activeReportId:n,onReportClick:i}){const a=o.find(l=>l.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(k.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&&a?"pointer":"default","&:hover":o.length>0&&a?{color:"primary.main"}:{}},onClick:()=>{o.length>0},children:"Reports"}),a&&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(a.id),children:a.name}),e.jsx(r.Tooltip,{title:a.description||"No description",arrow:!0,placement:"bottom",children:e.jsx(k.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(k.Add,{sx:{fontSize:18}}),onClick:t,sx:{borderRadius:"20px",px:3,textTransform:"none",fontWeight:500,fontSize:"0.875rem",py:.75},children:"New Report"})})]})})}function Ht(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 ga="$$material";function ya(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Gr={exports:{}},Yr={exports:{}},xe={};/** @license React v16.13.1
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("react"),ks=require("xlsx"),k=require("@mui/icons-material"),r=require("@mui/material"),di=require("react-dom"),Ts=require("@emotion/react"),wt=require("react-dnd"),Xo=require("react-dnd-html5-backend");function ui(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 fo=ui(p),Qr=ui(ks),Ue={sort:{maxLevels:5},filter:{maxConditions:10,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}},pi="urm_dev_config";function Is(){try{const t=localStorage.getItem(pi);if(!t)return Ue;const o=JSON.parse(t),n={sort:{...Ue.sort,...o.sort},filter:{...Ue.filter,...o.filter},columns:{...Ue.columns,...o.columns},grouping:{...Ue.grouping,...o.grouping},export:{...Ue.export,...o.export},views:{...Ue.views,...o.views},dates:{...Ue.dates,...o.dates},display:{...Ue.display,...o.display}};return n.sort.maxLevels=Math.min(5,Math.max(1,n.sort.maxLevels)),n}catch{return Ue}}function zs(t){try{localStorage.setItem(pi,JSON.stringify(t))}catch{}}function Es(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 xi=p.createContext(Ue);function Gt(){return p.useContext(xi)}const Bs=/^\d{4}-\d{2}-\d{2}$/,Ds=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/,Os=/^(\d{1,2})[\/\-\.](\d{1,2})[\/\-\.](\d{2,4})$|^([A-Za-z]+)\s+\d{1,2},?\s+\d{4}$/,As=9783072e5,Ms=41024448e5,_s=978307200,$s=4102444800;function Ws(t){return t==null||t===""?"unknown":typeof t=="number"?Number.isInteger(t)&&t>=As&&t<=Ms?"timestamp_ms":Number.isInteger(t)&&t>=_s&&t<=$s?"timestamp_s":"unknown":typeof t!="string"?"unknown":Ds.test(t)||Bs.test(t)?"iso":Os.test(t.trim())?"locale_string":"unknown"}function Rs(t,o){const n=o.map(d=>d[t]).filter(d=>d!=null&&d!=="");if(n.length===0)return"unknown";const i={iso:0,timestamp_ms:0,timestamp_s:0,locale_string:0,unknown:0};for(const d of n){const l=Ws(d);i[l]++}const s=n.length,c=.7;for(const d of["iso","timestamp_ms","timestamp_s","locale_string"])if(i[d]/s>=c)return d;return"unknown"}function Ps(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 mn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Ns=["January","February","March","April","May","June","July","August","September","October","November","December"];function Oe(t){return String(t).padStart(2,"0")}function Ls(t){const o=Date.now()-t.getTime(),n=Math.abs(o),i=o>0,s=Math.floor(n/1e3),c=Math.floor(s/60),d=Math.floor(c/60),l=Math.floor(d/24),u=Math.floor(l/7),m=Math.floor(l/30),h=Math.floor(l/365);let b;return s<60?b="just now":c<60?b=`${c} minute${c!==1?"s":""}`:d<24?b=`${d} hour${d!==1?"s":""}`:l<7?b=`${l} day${l!==1?"s":""}`:u<5?b=`${u} week${u!==1?"s":""}`:m<12?b=`${m} month${m!==1?"s":""}`:b=`${h} year${h!==1?"s":""}`,s<60?b:i?`${b} ago`:`in ${b}`}function Fs(t,o){const n=t.getFullYear(),i=t.getMonth(),s=t.getDate(),c=t.getHours(),d=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`${mn[i]} ${Oe(s)}, ${n}`;case"DD MMM YYYY":return`${Oe(s)} ${mn[i]} ${n}`;case"MMMM D, YYYY":return`${Ns[i]} ${s}, ${n}`;case"YYYY-MM-DD HH:mm":return`${n}-${Oe(i+1)}-${Oe(s)} ${Oe(c)}:${Oe(d)}`;case"DD/MM/YYYY HH:mm":return`${Oe(s)}/${Oe(i+1)}/${n} ${Oe(c)}:${Oe(d)}`;case"MM/DD/YYYY HH:mm":return`${Oe(i+1)}/${Oe(s)}/${n} ${Oe(c)}:${Oe(d)}`;case"relative":return Ls(t);case"locale":return t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"});default:return t.toLocaleDateString()}}function Vs(t,o,n){if(!n||o==="unknown")return String(t);const i=Ps(t,o);return!i||isNaN(i.getTime())?String(t):Fs(i,n)}function Hs(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 mi(t,o="",n=0){if(n>2)return{[o]:t};const i={};for(const s of Object.keys(t)){const c=o?`${o}.${s}`:s,d=t[s];d!==null&&typeof d=="object"&&!Array.isArray(d)&&n<2?Object.assign(i,mi(d,c,n+1)):i[c]=d}return i}function ao(t){return t.map(o=>typeof o!="object"||o===null||Array.isArray(o)?o:mi(o))}function Wr(t){if(!Array.isArray(t)||t.length===0)return[];const o=ao(t),n=new Set;o.forEach(d=>{typeof d=="object"&&d!==null&&Object.keys(d).forEach(l=>n.add(l))});const i=[];n.forEach(d=>{const l=new Set;let u=0;o.forEach(f=>{typeof f=="object"&&f!==null&&d in f&&(u++,l.add(Hs(f[d])))});const m=u===o.length,h=l.size>1&&!l.has("null");let b="mixed";if(l.size===1)b=Array.from(l)[0];else if(l.size===2&&l.has("null")){const f=Array.from(l).filter(g=>g!=="null");f.length===1&&(b=f[0])}i.push({name:d,type:b,required:m,hasConflict:h})});const c=o.slice(0,50);for(const d of i){if(d.type!=="string"&&d.type!=="number")continue;const l=Rs(d.name,c);l!=="unknown"&&(d.type="date",d.dateFormat=l)}return i}function Us(t){return t.some(o=>o.hasConflict)}function Ge(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 fn(t){return t==null}function Ys(t){return(o,n,i)=>{const s=fn(o),c=fn(n);if(s&&c)return 0;if(s)return 1;if(c)return-1;let d=0;switch(t){case"number":const l=Number(o),u=Number(n);d=l-u;break;case"boolean":d=(o?1:0)-(n?1:0);break;case"string":d=String(o).localeCompare(String(n));break;case"array":case"object":d=JSON.stringify(o).localeCompare(JSON.stringify(n));break;case"mixed":case"null":default:d=String(o).localeCompare(String(n));break}return i==="asc"?d:-d}}function Gs(t,o,n){if(!n||n.length===0)return t;const i=[...n].sort((s,c)=>s.priority-c.priority);return[...t].sort((s,c)=>{for(const d of i){const l=o.find(h=>h.name===d.column);if(!l)continue;const m=Ys(l.type)(s[d.column],c[d.column],d.direction);if(m!==0)return m}return 0})}function qs(t){return t===null?"asc":t==="asc"?"desc":null}function Js(t){return t==="string"||t==="boolean"}function Ks(t){return t.filter(o=>Js(o.type))}function Xs(t,o){const n={};return o.forEach(i=>{if(i.type==="number"){const s=t.map(c=>c[i.name]).filter(c=>typeof c=="number");s.length>0&&(n[i.name]=s.reduce((c,d)=>c+d,0))}}),n}function Zs(t,o,n){if(!n.enabled||n.levels.length===0)return t;const i=fi(t,n.levels,o);return hi(i,n.collapsedGroups||[])}function fi(t,o,n,i="",s=0){if(s>=o.length)return t;const c=o[s].column,d=new Map;t.forEach(m=>{const h=m[c],b=h==null?"(empty)":String(h);d.has(b)||d.set(b,[]),d.get(b).push(m)});const l=[];return Array.from(d.keys()).sort().forEach(m=>{const h=d.get(m),b=`${c}:${m}`,f=i?`${i}|${b}`:b,g=Xs(h,n),T=s<o.length-1?fi(h,o,n,f,s+1):h,y={key:f,level:s,column:c,value:m,rowCount:h.length,aggregates:g,children:T};l.push(y)}),l}function hi(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&&hi(i.children,o,n)}else n.push(i);return n}function Qs(t,o){const n=t.collapsedGroups||[],i=n.includes(o)?n.filter(s=>s!==o):[...n,o];return{...t,collapsedGroups:i}}function gi(t,o){return t==null?"":typeof t=="number"?`Σ ${t.toLocaleString()}`:String(t)}function yi(t,o,n){return`${o}: ${n}`}function Fr(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 bi(t,o,n){if(!o||!o.enabled||!o.levels||o.levels.length===0)return[...t];const i=o.levels.map(c=>c.column),s=t.filter(c=>!i.includes(c));if(n){const c=[],d=new Set(i),l=new Set(s);let u=0;for(const m of n)d.has(m)?c.push(m):l.has(m)&&u<s.length?(c.push(s[u]),u++):l.has(m)||c.push(m);for(let m=u;m<s.length;m++)c.includes(s[m])||c.push(s[m]);return c}return[...t]}function Mo(t){const o={},n=[],i={};return t.forEach(s=>{o[s.name]=!0,n.push(s.name),i[s.name]=150}),{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 ea(t,o,n,i,s,c,d,l){const u={},m=[],h={};n.forEach(g=>{u[g.name]=!0,m.push(g.name),h[g.name]=150});const f=bi(s||m,d||null,l||m);return{filters:t||[],sortStack:o||[],columnVisibility:i||u,columnOrder:f,columnWidths:c||h,grouping:d||null}}function ta(t,o){const n=u=>{if(u==null)return u;if(Array.isArray(u))return u.map(m=>n(m));if(typeof u=="object"){const m={};return Object.keys(u).sort().forEach(h=>{m[h]=n(u[h])}),m}return u},i=u=>JSON.stringify(n(u));if(i(t.filters)!==i(o.filters)||i(t.sortStack)!==i(o.sortStack)||i(t.columnVisibility)!==i(o.columnVisibility))return!0;const s=[...t.columnOrder||[]].sort().join(","),c=[...o.columnOrder||[]].sort().join(",");if(s!==c)return!1;const d=[...o.columnOrder||[]].sort().join(",");if((o.columnOrder||[]).join(",")!==d){if((t.columnOrder||[]).join(",")!==(o.columnOrder||[]).join(","))return!0}else{const u=[...t.columnOrder||[]].sort().join(",");if((t.columnOrder||[]).join(",")!==u)return!0}return i(t.columnWidths)!==i(o.columnWidths)||i(t.grouping)!==i(o.grouping)}function ra(t){return!t||t.length===0?"None":t.sort((o,n)=>o.priority-n.priority).map(o=>`${o.column} ${o.direction==="asc"?"↑":"↓"}`).join(", ")}function oa(t,o){var y,w,v;const n=[],i=JSON.stringify(t.filters),s=JSON.stringify(o.filters);if(i!==s){const j=t.filters.length,S=o.filters.length;j>S?n.push({category:"filters",label:"Filters Added",description:`${j-S} new filter${j-S>1?"s":""} added`}):j<S?n.push({category:"filters",label:"Filters Removed",description:`${S-j} filter${S-j>1?"s":""} removed`}):n.push({category:"filters",label:"Filters Modified",description:"Filter conditions have been changed"})}const c=JSON.stringify(t.sortStack),d=JSON.stringify(o.sortStack);if(c!==d){const j=t.sortStack.length,S=o.sortStack.length;j>S?n.push({category:"sorting",label:"Sorting Added",description:`${j-S} new sort rule${j-S>1?"s":""} added`}):j<S?n.push({category:"sorting",label:"Sorting Removed",description:`${S-j} sort rule${S-j>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 j=Object.values(t.columnVisibility).filter(I=>I).length,S=Object.values(o.columnVisibility).filter(I=>I).length;j>S?n.push({category:"visibility",label:"Columns Shown",description:`${j-S} column${j-S>1?"s":""} made visible`}):j<S?n.push({category:"visibility",label:"Columns Hidden",description:`${S-j} column${S-j>1?"s":""} hidden`}):n.push({category:"visibility",label:"Column Visibility Changed",description:"Column visibility settings have been modified"})}const m=JSON.stringify(t.columnOrder),h=JSON.stringify(o.columnOrder);m!==h&&n.push({category:"order",label:"Column Order Changed",description:"Columns have been reordered"});const b=JSON.stringify(t.columnWidths),f=JSON.stringify(o.columnWidths);if(b!==f){const j=Object.keys(t.columnWidths).filter(S=>t.columnWidths[S]!==o.columnWidths[S]).length;n.push({category:"widths",label:"Column Widths Adjusted",description:`${j} column width${j>1?"s":""} modified`})}const g=JSON.stringify(t.grouping),T=JSON.stringify(o.grouping);if(g!==T){const j=(y=t.grouping)==null?void 0:y.enabled,S=(w=o.grouping)==null?void 0:w.enabled;if(j&&!S){const I=((v=t.grouping)==null?void 0:v.levels.length)||0;n.push({category:"grouping",label:"Grouping Applied",description:`${I} grouping level${I>1?"s":""} added`})}else!j&&S?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 hn(){try{return localStorage.getItem("urm:debug")==="true"}catch{return!1}}function gn(t){return`[${t}]`}const Ut={warn(t,o,...n){hn()&&console.warn(gn(t),o,...n)},error(t,o,...n){hn()&&console.error(gn(t),o,...n)}},vi="urm_report_";function na(t,o){try{const n=`${vi}${t}`;localStorage.setItem(n,JSON.stringify(o))}catch(n){Ut.error("urm:persistence","Failed to save report state",n)}}function ia(t){try{const o=`${vi}${t}`,n=localStorage.getItem(o);return n?JSON.parse(n):null}catch(o){return Ut.error("urm:persistence","Failed to load report state",o),null}}function ho(t,o,n=0){const i=[];for(const s of t){const c=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:c}),!c&&s.children&&s.children.length>0){const d=s.children[0];if(sa(d)){const l=s.children,u=ho(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 sa(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 Zo(t){return t.filter(o=>o.type==="row").map(o=>o.type==="row"?o.data:null).filter(o=>o!==null)}function Qo(t,o){const n=new Date,i=n.getFullYear(),s=String(n.getMonth()+1).padStart(2,"0"),c=String(n.getDate()).padStart(2,"0"),d=`${i}-${s}-${c}`;return`${t.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}_${d}.${o}`}function co(t,o,n,i,s,c,d){let l,u;c?(l={...c},u=d||o.map(h=>h.name)):s?(l={...s.snapshot.columnVisibility},u=d||[...s.snapshot.columnOrder]):(l={},u=[],o.forEach(h=>{l[h.name]=!0,u.push(h.name)}));const m=Object.entries(l).filter(([h,b])=>!b).map(([h,b])=>h);return{data:t,schema:o,appliedFilters:n,appliedSortStack:i,columnVisibility:l,columnOrder:u,grouping:(s==null?void 0:s.snapshot.grouping)??null,hiddenColumns:m,viewMeta:s?{id:s.id,name:s.name,isDefault:s.isDefault}:void 0}}function uo(t,o="export",n){const{data:i,columnOrder:s,grouping:c}=t,d=s.filter(b=>t.columnVisibility[b]);let l;if(c&&c.enabled){const b=ho(i);l=Zo(b)}else l=i;const u=d.join(","),m=l.map(b=>d.map(f=>{const g=b[f];if(g==null)return"";const T=String(g);return T.includes(",")||T.includes('"')||T.includes(`
2
+ `)?`"${T.replace(/"/g,'""')}"`:T}).join(",")),h=[u,...m].join(`
3
+ `);Si(h,Qo(o,"csv"),"text/csv;charset=utf-8;")}function po(t,o="export",n){const{data:i,columnOrder:s,grouping:c}=t,d=s.filter(b=>t.columnVisibility[b]);let l;if(c&&c.enabled){const b=ho(i);l=Zo(b)}else l=i;const u=[d,...l.map(b=>d.map(f=>b[f]??""))],m=Qr.utils.aoa_to_sheet(u),h=Qr.utils.book_new();Qr.utils.book_append_sheet(h,m,"Data"),Qr.writeFile(h,Qo(o,"xlsx"))}function xo(t,o="export",n){const{data:i,appliedFilters:s,appliedSortStack:c,viewMeta:d,hiddenColumns:l,columnOrder:u,grouping:m}=t;let h;if(m&&m.enabled){const g=ho(i);h=Zo(g)}else h=i;const b={meta:{exportedAt:new Date().toISOString(),reportName:o,view:(d==null?void 0:d.name)||"Default View",filters:s.map(g=>({field:g.column,operator:g.operator,value:g.value})),sortStack:c.map(g=>({field:g.column,direction:g.direction,priority:g.priority})),grouping:m||{},hiddenColumns:l,columnOrder:u,exportConfig:n||{scope:"visible"}},data:h},f=JSON.stringify(b,null,2);Si(f,Qo(o,"json"),"application/json;charset=utf-8;")}function Si(t,o,n){const i=new Blob([t],{type:n}),s=URL.createObjectURL(i),c=document.createElement("a");c.href=s,c.download=o,document.body.appendChild(c),c.click(),document.body.removeChild(c),URL.revokeObjectURL(s)}const yn=10;function aa(t,o){const n=o.trim();if(!n)return t;const i=t.findIndex(c=>c.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>yn&&(s=[...s].sort((d,l)=>d.isFavourite&&!l.isFavourite?-1:!d.isFavourite&&l.isFavourite?1:l.lastUsed-d.lastUsed).slice(0,yn)),s}function la(t,o){return t.map(n=>n.query===o?{...n,isFavourite:!n.isFavourite}:n)}function ca(t,o){return t.filter(n=>n.query!==o)}function da(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 ua={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 pa(t,o){return!t||t.owner===o?"owner":t.editors.includes(o)?"editor":(t.viewers.includes(o),"viewer")}function pt(t,o){return ua[o].includes(t)}function xt(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 xa(t){return t==="viewer"}const bn=1e3;function Uo(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 Uo(n)}const ma={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 _o(t){if(!t||!t.column)return"a filter";const o=ht(t.column),n=ma[t.operator]??t.operator;return["isTrue","isFalse","NULL","NOT_NULL"].includes(t.operator)?`"${o}" ${n}`:`"${o}" ${n} "${t.value}"`}function vn(t){return!t||!t.enabled||t.levels.length===0?"grouping removed":`grouped by ${t.levels.map(n=>`"${ht(n.column)}"`).join(", ")}`}function fa(t){var s,c,d;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: ${_o(l)}`}}case"filter_removed":return{summary:`Filter removed: ${_o(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: ${_o(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: ${vn(i)}`};case"group_level_removed":{const l=n,u=(c=(s=l==null?void 0:l.levels)==null?void 0:s[0])!=null&&c.column?ht(l.levels[0].column):"";return{summary:u?`Group level removed: "${u}"`:"Group level removed"}}case"group_reordered":return{summary:`Grouping updated: ${vn(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,m=(i==null?void 0:i.scope)==="all"?"all rows":"filtered rows",h=(i==null?void 0:i.viewName)??"",b=typeof u=="number"?` (${u.toLocaleString()} rows)`:"";return{summary:`Exported as ${l}${b}`,detail:h?`${Uo(m)} · View: "${h}"`:Uo(m)}}case"export_triggered":{const l=((d=i==null?void 0:i.format)==null?void 0:d.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:ga(o)}}}function ha(){return`EVT_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function ji(t,o,n,i,s,c){return{id:ha(),user:o,reportId:t,feature:n,action:i,timestamp:new Date().toISOString(),previousState:s,newState:c}}function Ci(t,o){const n=[o,...t];return n.length>bn?n.slice(0,bn):n}function ga(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 ya(t){return{filters:"Filters",sorting:"Sorting",grouping:"Grouping",columns:"Columns",views:"Views",theme:"Theme",export:"Export",presets:"Presets",system:"System"}[t]||t}function ba(t){return{filters:"#1976d2",sorting:"#7b1fa2",grouping:"#2e7d32",columns:"#e65100",views:"#c2185b",theme:"#546e7a",export:"#00838f",presets:"#303f9f",system:"#c62828"}[t]||"#546e7a"}function va(t){const o=new Date(t),i=new Date().getTime()-o.getTime(),s=Math.floor(i/6e4),c=Math.floor(i/36e5),d=Math.floor(i/864e5);return s<1?"Just now":s<60?`${s} minute${s>1?"s":""} ago`:c<24?`${c} hour${c>1?"s":""} ago`:d<7?`${d} day${d>1?"s":""} ago`:o.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}const Sn=100;function Sa(){return`preset_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function ja(t){var c;const o=(c=t.views)==null?void 0:c.find(d=>d.id===t.activeViewId),n=o==null?void 0:o.snapshot.columnOrder,i=t.columnOrder||[],s=bi(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 Ca(t,o,n,i){return{id:Sa(),name:t,description:o,createdBy:n,createdAt:Date.now(),config:i}}function wa(t,o){const n=t||[];if(n.length>=Sn)throw new Error(`Maximum of ${Sn} presets reached. Please delete old presets first.`);return[...n,o]}function ka(t,o){return(t||[]).filter(i=>i.id!==o)}function jn(t,o){if(t)return t.find(n=>n.id===o)}function Ta(){return typeof window>"u"?null:new URLSearchParams(window.location.search).get("preset")}function Ia(t){const o=t.columnOrder,n=Fr(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 za(t,o){return{totalRows:t.length,totalColumns:o.length}}const Ea={MAX_CACHE_ENTRIES:3};function Ba(t,o){let n=null;return function(...s){const c=()=>{n=null,t(...s)};n&&clearTimeout(n),n=setTimeout(c,o)}}class eo{constructor(o=Ea.MAX_CACHE_ENTRIES){this.cache=new Map,this.maxEntries=o}get(o){const n=this.cache.get(o);return n?n.value:null}set(o,n){var i;if(this.cache.size>=this.maxEntries&&!this.cache.has(o)){const s=(i=Array.from(this.cache.entries()).sort((c,d)=>c[1].timestamp-d[1].timestamp)[0])==null?void 0:i[0];s&&this.cache.delete(s)}this.cache.set(o,{key:o,value:n,timestamp:Date.now()})}has(o){return this.cache.has(o)}clear(){this.cache.clear()}size(){return this.cache.size}}class Da{constructor(){this.metrics=new Map}start(o){this.metrics.set(o,performance.now())}end(o){const n=this.metrics.get(o);if(!n)return 0;const i=performance.now()-n;return this.metrics.delete(o),i}measure(o,n){this.start(o);const i=n(),s=this.end(o);return{result:i,duration:s}}async measureAsync(o,n){this.start(o);const i=await n(),s=this.end(o);return{result:i,duration:s}}}function Ct(t,o,n,i){const s=n instanceof Error?n.message:n,c={type:t,context:o,message:s,details:i,timestamp:Date.now(),recoverable:Oa(t,o)};return process.env.NODE_ENV==="development"&&Ut.error("urm:error-handling","[Report Error]",{type:t,context:o,message:s,details:i}),c}function Oa(t,o){return t==="ui"||t==="processing"&&["filters","sorting","grouping","columns"].includes(o)?!0:t!=="system"}function Aa(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 _a(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 wi(t,o){const n=[],i=[],s=new Set(o.map(c=>c.name));return t.forEach(c=>{s.has(c.column)?n.push(c):i.push(c.column)}),{validRules:n,invalidColumns:i}}function ki(t,o){if(!t||!t.levels||t.levels.length===0)return{validGrouping:null,invalidColumns:[]};const n=new Set(o.map(c=>c.name)),i=[],s=[];return t.levels.forEach(c=>{n.has(c.column)?i.push(c):s.push(c.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(c=>c.name)),s={...t};if(s.filters&&Array.isArray(s.filters)){const c=s.filters.filter(d=>{const l=i.has(d.column);return l||n.push(`Filter for column "${d.column}" ignored (column not found)`),l});s.filters=c.length>0?c:void 0}if(s.sortStack&&Array.isArray(s.sortStack)){const{validRules:c,invalidColumns:d}=wi(s.sortStack,o);d.length>0&&n.push(`Sort rules for columns ignored: ${d.join(", ")}`),s.sortStack=c.length>0?c:void 0}if(s.grouping){const{validGrouping:c,invalidColumns:d}=ki(s.grouping,o);d.length>0&&n.push(`Grouping for columns ignored: ${d.join(", ")}`),s.grouping=c}if(s.columnVisibility){const c={};Object.entries(s.columnVisibility).forEach(([d,l])=>{i.has(d)?c[d]=l:n.push(`Column visibility for "${d}" ignored (column not found)`)}),s.columnVisibility=Object.keys(c).length>0?c:void 0}if(s.columnOrder&&Array.isArray(s.columnOrder)){const c=s.columnOrder.filter(d=>{const l=i.has(d);return l||n.push(`Column "${d}" in order ignored (column not found)`),l});s.columnOrder=c.length>0?c:void 0}if(s.columnWidths){const c={};Object.entries(s.columnWidths).forEach(([d,l])=>{i.has(d)?c[d]=l:n.push(`Column width for "${d}" ignored (column not found)`)}),s.columnWidths=Object.keys(c).length>0?c:void 0}return{sanitizedConfig:s,warnings:n}}function Ra(t,o){return Ct("processing","export",t,{retryAvailable:!!(o!=null&&o.onRetry)})}function Cn(t,o,n,i){const s=ji(t,o,"system","error_occurred",null,{errorType:n.type,errorContext:n.context,errorMessage:n.message,recoverable:n.recoverable,timestamp:n.timestamp});return Ci(i||[],s)}function Pa(t){return t==null}function Na(t,o){const{operator:n,value:i}=o;if(n==="NULL")return t==null;if(n==="NOT_NULL")return t!=null;if(Pa(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 La(t,o){return!o||o.length===0?t:t.filter(n=>o.every(i=>Na(n[i.column],i)))}function wn(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 to(t){return t!=="isTrue"&&t!=="isFalse"&&t!=="NULL"&&t!=="NOT_NULL"}function Fa({data:t,filters:o}){return{filteredData:p.useMemo(()=>!o||o.length===0?t:La(t,o),[t,o])}}function Va(t,o,n,i){if(!n||n.trim()==="")return t;const s=n.toLowerCase().trim(),c=o.filter(d=>i.includes(d.name));return t.filter(d=>c.some(l=>{const u=d[l.name];return u==null?!1:String(u).toLowerCase().includes(s)}))}function Ha({data:t,searchQuery:o,schema:n,visibleColumns:i}){return{searchedData:p.useMemo(()=>!o||o.trim()===""?t:Va(t,n,o,i),[t,o,n,i])}}function Ua({data:t,sortStack:o,schema:n}){return{sortedData:p.useMemo(()=>!o||o.length===0?t:Gs(t,n,o),[t,o,n])}}function Ya({data:t,grouping:o,schema:n}){const i=p.useMemo(()=>!o||!o.enabled||o.levels.length===0?t:Zs(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 Ga({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]),c=p.useMemo(()=>n.map(l=>t.find(m=>m.name===l)||{name:l,type:"string"}),[n,t]),d=p.useMemo(()=>i.map(l=>t.find(m=>m.name===l)||{name:l,type:"string"}),[i,t]);return{visibleColumns:i,hiddenColumns:s,allColumns:c,visibleColumnSchemas:d,hiddenCount:s.length}}function qa({views:t,activeViewId:o,currentState:n}){const i=p.useMemo(()=>t.find(m=>m.id===o),[t,o]),s=p.useMemo(()=>i?ta(n,i.snapshot):!1,[i,n]),c=p.useMemo(()=>t.find(m=>m.isDefault),[t]),d=p.useMemo(()=>t.filter(m=>!m.isDefault&&!m.isDeleted),[t]),l=p.useMemo(()=>t.filter(m=>m.isFavorite&&!m.isDeleted),[t]),u=p.useMemo(()=>t.filter(m=>m.isDeleted),[t]);return{activeView:i,isDirty:s,defaultView:c,customViews:d,favoriteViews:l,deletedViews:u,isDefaultView:(i==null?void 0:i.isDefault)||!1}}function Ja({data:t,enabled:o=!1,pageSize:n=100,initialPage:i=1}){const[s,c]=p.useState(i),d=t.length,l=Math.ceil(d/n),u=p.useMemo(()=>{if(!o)return t;const g=(s-1)*n,T=g+n;return t.slice(g,T)},[t,o,s,n]),m=p.useCallback(g=>{const T=Math.max(1,Math.min(g,l));c(T)},[l]),h=p.useCallback(()=>{s<l&&c(s+1)},[s,l]),b=p.useCallback(()=>{s>1&&c(s-1)},[s]),f=p.useCallback(()=>{c(1)},[]);return{paginatedData:u,currentPage:s,totalPages:l,pageSize:n,totalRows:d,goToPage:m,nextPage:h,prevPage:b,resetPage:f,hasNextPage:s<l,hasPrevPage:s>1}}function Ka(t){const{rawData:o,schema:n,filters:i,sortStack:s,grouping:c,searchQuery:d,columnVisibility:l,columnOrder:u,columnWidths:m,views:h,activeViewId:b,pagination:f}=t,g=p.useMemo(()=>({filters:i,sortStack:s,grouping:c,columnVisibility:l,columnOrder:u,columnWidths:m}),[i,s,c,l,u,m]),T=qa({views:h,activeViewId:b,currentState:g}),y=Ga({schema:n,columnVisibility:l,columnOrder:u}),{filteredData:w}=Fa({data:o,filters:i}),{sortedData:v}=Ua({data:w,sortStack:s,schema:n}),{groupedData:j,isGrouped:S}=Ya({data:v,grouping:c,schema:n}),{searchedData:I}=Ha({data:j,searchQuery:d,schema:n,visibleColumns:y.visibleColumns}),a=Ja({data:I,enabled:(f==null?void 0:f.enabled)||!1,pageSize:(f==null?void 0:f.pageSize)||100,initialPage:(f==null?void 0:f.currentPage)||1}),A=f!=null&&f.enabled?a.paginatedData:I,B=p.useMemo(()=>({totalRows:o.length,filteredRows:w.length,sortedRows:v.length,groupedRows:S?j.length:v.length,searchedRows:I.length,visibleRows:A.length,hiddenColumns:y.hiddenCount,activeFilters:i.length,activeSorts:s.length,isGrouped:S}),[o.length,w.length,v.length,j.length,I.length,A.length,y.hiddenCount,i.length,s.length,S]);return{data:A,filteredData:w,sortedData:v,groupedData:j,searchedData:I,viewEngine:T,columnEngine:y,paginationEngine:a,metrics:B,isGrouped:S,isPaginated:(f==null?void 0:f.enabled)||!1}}let Xa=0;function Za(t){t!=null&&t.__urm_row_id__===void 0&&Object.defineProperty(t,"__urm_row_id__",{value:Xa++,writable:!1,enumerable:!1,configurable:!1})}const mt="user-demo-001";function Qa(t={}){var ln,cn,dn,un,pn;const{mode:o="builder",autoLoad:n=!0,initialData:i,dataSource:s,reportName:c,sharedReportId:d,config:l={}}=t,[u,m]=p.useState([]),h=Gt(),[b,f]=p.useState(""),[g,T]=p.useState(!1),[y,w]=p.useState(!1),[v,j]=p.useState({message:"",severity:"info",open:!1}),S=(C,z="info")=>{j({message:C,severity:z,open:!0})},I=()=>j(C=>({...C,open:!1})),a=u.find(C=>C.id===b),[A,B]=p.useState("idle"),[$,Y]=p.useState(!1),[Q,te]=p.useState(!1),[x,N]=p.useState(!1),[W,H]=p.useState(!1),[J,ue]=p.useState(!1),[pe,re]=p.useState(!1),[O,F]=p.useState(void 0),[G,se]=p.useState(null),[ee,le]=p.useState(null),[ae,P]=p.useState(!1),[ne,ce]=p.useState(!1),[ie,he]=p.useState(null),[q,Ae]=p.useState(!1),[We,tt]=p.useState(!1),[Kt,hr]=p.useState({enabled:!1,levels:[],collapsedGroups:[]}),[At,it]=p.useState(""),[Re,Ee]=p.useState(new Set),[gt,st]=p.useState(1),[rt,Je]=p.useState(15),[It,Xt]=p.useState(!1),[at,Ke]=p.useState(!1),[Pe,Zt]=p.useState(!1),[yt,zt]=p.useState(null),[Qt,lt]=p.useState(!1),[gr,yr]=p.useState(null),[br,Mt]=p.useState(null);p.useRef(new Da),p.useRef(new eo),p.useRef(new eo),p.useRef(new eo),p.useRef(new eo);const[vr,Sr]=p.useState(null),Xe=p.useRef(null),ve=p.useMemo(()=>a?pa(a.permissions,mt):"owner",[a]),jr=xa(ve),er=p.useMemo(()=>!(a!=null&&a.uploadedData)||!(a!=null&&a.schema)?{totalRows:0,totalColumns:0}:za(a.uploadedData,a.schema),[a==null?void 0:a.uploadedData,a==null?void 0:a.schema]),ot=p.useCallback(()=>{a&&(Xe.current=Ma(a))},[a]),L=p.useCallback((C,z)=>{m(_=>_.map(D=>D.id===C?{...D,...z}:D))},[]),Ne=p.useCallback(C=>{if(!a)return;Sr(C);const z=Cn(a.id,mt,C,a.auditHistory||[]);L(a.id,{auditHistory:z}),S(C.message,"error"),C.recoverable&&Xe.current&&setTimeout(()=>{_a(a,Xe.current,L),S("Previous state restored","success")},100)},[a,L]),Se=p.useCallback((C,z,_,D)=>{if(!a)return;const U=ji(a.id,mt,C,z,_,D),V=a.auditHistory||[],xe=Ci(V,U);setTimeout(()=>{L(a.id,{auditHistory:xe})},0)},[a,L]);p.useEffect(()=>{if(a!=null&&a.schemaLocked&&a.schema&&(!a.views||a.views.length===0)){const C=Mo(a.schema);(()=>{try{const z=localStorage.getItem("urm_dev_config");return z?JSON.parse(z):null}catch{return null}})(),L(a.id,{views:[C],activeViewId:C.id,filters:C.snapshot.filters,sortStack:C.snapshot.sortStack,columnVisibility:C.snapshot.columnVisibility,columnOrder:C.snapshot.columnOrder,columnWidths:C.snapshot.columnWidths,grouping:C.snapshot.grouping})}},[a==null?void 0:a.schemaLocked,a==null?void 0:a.schema,a==null?void 0:a.id,L]),p.useEffect(()=>{if(i&&n&&!y&&u.length===0){const C=ao(i),z={id:`auto-report-${Date.now()}`,name:c||(o==="viewer"?"Data View":"Imported Data"),description:"Auto-generated from external data",schemaLocked:!0,uploadedData:C,schema:Wr(C),permissions:{owner:mt,editors:[],viewers:[]}};m([z]),f(z.id),w(!0),B("confirmed")}},[i,n,y,u.length,o,c]),p.useEffect(()=>{if(!s||y)return;let C=!1,z=null;const _=async()=>{try{B("uploading");let D;if(s.type==="api"){const V=await fetch(s.url,{headers:s.headers||{}});if(!V.ok)throw new Error(`HTTP ${V.status}: ${V.statusText}`);D=await V.json()}else D=await s.fetch();if(C)return;if(!Array.isArray(D))throw new Error("Data source must return an array of objects");const U=Wr(D);if(y)m(V=>V.map(xe=>xe.id===b?{...xe,uploadedData:D}:xe)),B("confirmed");else{const V={id:`auto-report-${Date.now()}`,name:c||(o==="viewer"?"Data View":"Imported Data"),description:`Loaded from ${s.type==="api"?s.url:"callback"}`,schemaLocked:!0,uploadedData:ao(D),schema:Wr(ao(D)),permissions:{owner:mt,editors:[],viewers:[]}};m([V]),f(V.id),w(!0),B("confirmed")}}catch(D){C||(B("error"),a&&L(a.id,{uploadError:(D==null?void 0:D.message)||"Failed to load data from source"}))}};return _(),s.refreshInterval&&s.refreshInterval>0&&(z=setInterval(_,s.refreshInterval)),()=>{C=!0,z&&clearInterval(z)}},[s,c,o]);const _e=(ln=a==null?void 0:a.views)==null?void 0:ln.find(C=>C.id===a.activeViewId),Cr=p.useMemo(()=>a!=null&&a.uploadedData?(a.uploadedData.forEach(Za),a.showFavoritesOnly?!a.favoriteRowIndices||a.favoriteRowIndices.length===0?[]:a.uploadedData.filter((C,z)=>a.favoriteRowIndices.includes(z)):a.uploadedData):[],[a==null?void 0:a.uploadedData,a==null?void 0:a.showFavoritesOnly,a==null?void 0:a.favoriteRowIndices]),_t=p.useMemo(()=>{var z;if(!(a!=null&&a.uploadedData)||!((z=a==null?void 0:a.favoriteRowIndices)!=null&&z.length))return new Set;const C=new Set;return a.favoriteRowIndices.forEach(_=>{const D=a.uploadedData[_];D!==void 0&&C.add(D)}),C},[a==null?void 0:a.uploadedData,a==null?void 0:a.showFavoritesOnly,a==null?void 0:a.favoriteRowIndices]),bt=Ka({rawData:Cr,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:At||"",columnVisibility:(a==null?void 0:a.columnVisibility)||(_e==null?void 0:_e.snapshot.columnVisibility)||{},columnOrder:(a==null?void 0:a.columnOrder)||(_e==null?void 0:_e.snapshot.columnOrder)||[],columnWidths:(a==null?void 0:a.columnWidths)||(_e==null?void 0:_e.snapshot.columnWidths)||{},views:(a==null?void 0:a.views)||[],activeViewId:(a==null?void 0:a.activeViewId)||"",pagination:{enabled:!0,pageSize:rt,currentPage:gt}}),{data:$t=[],searchedData:Wt=[],groupedData:Et=[],metrics:wr={totalRows:0,searchedRows:0,isGrouped:!1},isGrouped:Rt=!1,paginationEngine:De}=bt||{},X=((cn=bt.viewEngine)==null?void 0:cn.activeView)||_e,vt=((dn=bt.viewEngine)==null?void 0:dn.isDirty)||!1;p.useEffect(()=>{if(!(!X||!a)&&!a.columnOrder){const C=X.snapshot.columnOrder,z=Fr(C,X.snapshot.grouping);L(a.id,{columnOrder:z})}},[a==null?void 0:a.activeViewId]);const ge=p.useMemo(()=>!(a!=null&&a.schema)||!X?null:ea(a.filters||[],a.sortStack||[],a.schema,a.columnVisibility,a.columnOrder,a.columnWidths,a.grouping,X.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,X]),je=p.useMemo(()=>!X||!ge||!vt?[]:oa(ge,X.snapshot),[X,ge,vt]),Ze=p.useCallback((C,z,_)=>{const D={id:`report-${Date.now()}`,name:C,description:z,schemaLocked:!1,permissions:{owner:mt,editors:[],viewers:[]}};if(_&&Array.isArray(_)&&_.length>0){const U=Wr(_),V=Mo(U);D.uploadedData=_,D.schema=U,D.schemaLocked=!0,D.views=[V],D.activeViewId=V.id,D.sortStack=V.snapshot.sortStack,D.filters=V.snapshot.filters,D.columnVisibility=V.snapshot.columnVisibility,D.columnOrder=V.snapshot.columnOrder,D.columnWidths=V.snapshot.columnWidths,D.grouping=V.snapshot.grouping}m(U=>[...U,D]),f(D.id),T(!1),B("confirmed")},[]),kr=p.useCallback(C=>{a&&(B("uploading"),setTimeout(()=>{const z=Wr(C);L(a.id,{uploadedData:C,schema:z,uploadError:void 0}),B("preview")},500))},[a,L]),St=p.useCallback(C=>{a&&(L(a.id,{uploadError:C}),B("idle"))},[a,L]),$e=p.useCallback(()=>{a&&(L(a.id,{uploadError:void 0,uploadedData:void 0,schema:void 0}),B("idle"))},[a,L]),tr=p.useCallback(()=>{a&&(L(a.id,{schemaLocked:!0}),B("confirmed"))},[a,L]),Tr=p.useCallback(C=>{if(!a)return;if(!pt("edit_sorting",ve)){S(xt("edit_sorting"),"error");return}const z=a.sortStack??[],_=z.find(D=>D.column===C);if(_){const D=qs(_.direction);if(D===null){const U=z.filter(V=>V.column!==C).map((V,xe)=>({...V,priority:xe+1}));L(a.id,{sortStack:U.length>0?U:void 0})}else{const U=z.map(V=>V.column===C?{...V,direction:D}:V);L(a.id,{sortStack:U})}}else{if(z.length>=h.sort.maxLevels)return;const D={column:C,direction:"asc",priority:z.length+1};L(a.id,{sortStack:[...z,D]})}},[a,ve,L]),rr=p.useCallback(C=>{if(a)if(a.schema){const{validRules:z,invalidColumns:_}=wi(C,a.schema);_.length>0&&S(`Removed invalid sort columns: ${_.join(", ")}`),ot();try{L(a.id,{sortStack:z.length>0?z:void 0})}catch(D){const U=Ct("processing","sorting",D);Ne(U)}}else L(a.id,{sortStack:C.length>0?C:void 0})},[a,L,ot,Ne]),or=p.useCallback(C=>{if(!a)return;const z=a.sortStack??[],_=z.find(D=>D.column===C);if(!(_&&_.direction==="asc"))if(_){const D=z.map(U=>U.column===C?{...U,direction:"asc"}:U);L(a.id,{sortStack:D})}else{if(z.length>=h.sort.maxLevels)return;const D={column:C,direction:"asc",priority:z.length+1};L(a.id,{sortStack:[...z,D]})}},[a,L]),Ir=p.useCallback(C=>{if(!a)return;const z=a.sortStack??[],_=z.find(D=>D.column===C);if(!(_&&_.direction==="desc"))if(_){const D=z.map(U=>U.column===C?{...U,direction:"desc"}:U);L(a.id,{sortStack:D})}else{if(z.length>=h.sort.maxLevels)return;const D={column:C,direction:"desc",priority:z.length+1};L(a.id,{sortStack:[...z,D]})}},[a,L]),nr=p.useCallback(C=>{var _;if(!a)return;if(!pt("edit_filters",ve)){S(xt("edit_filters"),"error");return}const z=(_=a.schema)==null?void 0:_.find(D=>D.name===C.column);if(z&&C.value!==void 0){const D=$a(z.type,C.operator,C.value);if(!D.isValid){S(D.errorMessage||"Invalid filter value","error");return}}ot();try{const D=a.filters??[];Se("filters","filter_added",D,[...D,C]),L(a.id,{filters:[...D,C]})}catch(D){const U=Ct("processing","filters",D);Ne(U)}},[a,ve,L,ot,Ne,Se]),ir=p.useCallback((C,z)=>{if(!a)return;if(!pt("edit_filters",ve)){S(xt("edit_filters"),"error");return}const _=a.filters??[],D=[..._];Se("filters","filter_updated",_[C],z),D[C]=z,L(a.id,{filters:D})},[a,ve,L,Se]),Le=p.useCallback(C=>{if(!a)return;if(!pt("edit_filters",ve)){S(xt("edit_filters"),"error");return}const z=a.filters??[],_=z.filter((D,U)=>U!==C);Se("filters","filter_removed",z[C],null),L(a.id,{filters:_.length>0?_:void 0})},[a,ve,L,Se]),ct=p.useCallback(()=>{if(!a)return;if(!pt("edit_filters",ve)){S(xt("edit_filters"),"error");return}const C=a.filters??[];Se("filters","filter_cleared",C,null),L(a.id,{filters:void 0})},[a,ve,L,Se]),dt=p.useCallback(C=>{if(!a)return;if(!pt("edit_filters",ve)){S(xt("edit_filters"),"error");return}const z=a.filters??[];Se("filters","filter_cleared",z,C),L(a.id,{filters:C.length>0?C:void 0})},[a,ve,L,Se]),Fe=p.useCallback(C=>{var U;if(!a)return;const z=(U=a.views)==null?void 0:U.find(V=>V.id===C);if(!z)return;const _=z.snapshot.columnOrder,D=Fr(_,z.snapshot.grouping);L(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:D,columnWidths:{...z.snapshot.columnWidths},grouping:z.snapshot.grouping,activeViewId:C}),Ee(new Set),N(!1)},[a,L]),sr=p.useCallback((C,z,_)=>{var xn;if(!(a!=null&&a.schema)||!ge)return;const D=a.views??[],U=D.filter(Ao=>!Ao.isDeleted).length,V=((xn=h.views)==null?void 0:xn.maxViews)??10;if(U>=V){S(`View limit reached — you can have at most ${V} saved views. Delete an existing view to create a new one.`,"error");return}const xe={id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:C,description:z||void 0,isDefault:_,isFavorite:!1,isDeleted:!1,scope:"personal",createdBy:mt,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...ge}},ke=_?D.map(Ao=>({...Ao,isDefault:!1})):D;L(a.id,{views:[...ke,xe],activeViewId:xe.id}),S(`"${C}" view created`,"success")},[a,ge,L]),Pt=p.useCallback(()=>{var z;if(!X||!ge||X.isDefault||!a)return;const C=(z=a.views)==null?void 0:z.map(_=>_.id===X.id?{..._,snapshot:{...ge}}:_);L(a.id,{views:C}),S(`"${X.name}" view updated`,"success")},[X,ge,a,L]),zr=p.useCallback(C=>{var D;if(!X||!ge||!a)return;const z=C??ge.columnWidths,_=(D=a.views)==null?void 0:D.map(U=>U.id===X.id?{...U,snapshot:{...U.snapshot,columnVisibility:ge.columnVisibility,columnOrder:ge.columnOrder,columnWidths:z},updatedAt:Date.now()}:U);L(a.id,{views:_,columnWidths:z}),S(`Column configuration saved to "${X.name}"`,"success")},[X,ge,a,L]),Er=p.useCallback(C=>{var V,xe;if(!ge||!a||!X)return;const z=C??ge.columnWidths,_={...X,snapshot:{...X.snapshot,columnVisibility:ge.columnVisibility,columnOrder:ge.columnOrder,columnWidths:z},updatedAt:Date.now()},D=(V=a.views)==null?void 0:V.map(ke=>ke.id===X.id?_:{...ke,snapshot:{...ke.snapshot,columnVisibility:ge.columnVisibility,columnOrder:ge.columnOrder,columnWidths:z},updatedAt:Date.now()});L(a.id,{views:D,columnWidths:z});const U=(((xe=a.views)==null?void 0:xe.length)||0)-1;S(`Column configuration saved to current view and ${U} other view${U===1?"":"s"}`,"success")},[ge,a,X,L]),Br=p.useCallback(()=>{H(!0)},[]),Dr=p.useCallback(()=>{if(!X||!a)return;const C=X.snapshot.columnOrder,z=Fr(C,X.snapshot.grouping);L(a.id,{filters:X.snapshot.filters.length>0?[...X.snapshot.filters]:void 0,sortStack:X.snapshot.sortStack.length>0?[...X.snapshot.sortStack]:void 0,columnVisibility:{...X.snapshot.columnVisibility},columnOrder:z,columnWidths:{...X.snapshot.columnWidths},grouping:X.snapshot.grouping}),S("Changes reverted to last saved state","success")},[X,a,L]),Or=p.useCallback(C=>{if(!(a!=null&&a.views))return;const z=a.views.map(D=>({...D,isDefault:D.id===C}));L(a.id,{views:z});const _=a.views.find(D=>D.id===C);_&&S(`"${_.name}" set as default view`,"success")},[a,L]),Ar=p.useCallback(C=>{if(!(a!=null&&a.views))return;const z=a.views.map(D=>D.id===C?{...D,isFavorite:!D.isFavorite,updatedAt:Date.now()}:D);L(a.id,{views:z});const _=a.views.find(D=>D.id===C);_&&!_.isFavorite?S(`"${_.name}" added to favorites`,"success"):_&&S(`"${_.name}" removed from favorites`,"info")},[a,L]),Nt=p.useCallback(C=>{if(!(a!=null&&a.views))return;const z=a.views.map(V=>V.id===C?{...V,isDeleted:!0,updatedAt:Date.now()}:V),_=a.activeViewId===C,D=z.find(V=>V.isDefault&&!V.isDeleted);L(a.id,{views:z,activeViewId:_&&D?D.id:a.activeViewId,filters:_&&D?D.snapshot.filters.length>0?D.snapshot.filters:void 0:a.filters,sortStack:_&&D?D.snapshot.sortStack.length>0?D.snapshot.sortStack:void 0:a.sortStack});const U=a.views.find(V=>V.id===C);U&&S(`"${U.name}" moved to Recently Deleted`,"info")},[a,L]),Mr=p.useCallback(C=>{if(!(a!=null&&a.views))return;const z=a.views.map(D=>D.id===C?{...D,isDeleted:!1,updatedAt:Date.now()}:D);L(a.id,{views:z});const _=a.views.find(D=>D.id===C);_&&S(`"${_.name}" restored`,"success")},[a,L]),_r=p.useCallback(C=>{if(!(a!=null&&a.views))return;const z=a.views.find(ke=>ke.id===C),_=a.views.filter(ke=>!ke.isDeleted||ke.id===C);if((z==null?void 0:z.isDefault)&&_.filter(ke=>ke.isDefault).length===1){S("Cannot delete the last default view","error");return}const U=a.views.filter(ke=>ke.id!==C),V=a.activeViewId===C,xe=U.find(ke=>ke.isDefault&&!ke.isDeleted);L(a.id,{views:U,activeViewId:V&&xe?xe.id:a.activeViewId,filters:V&&xe?xe.snapshot.filters.length>0?xe.snapshot.filters:void 0:a.filters,sortStack:V&&xe?xe.snapshot.sortStack.length>0?xe.snapshot.sortStack:void 0:a.sortStack}),z&&S(`"${z.name}" permanently deleted`,"success")},[a,L]),Me=p.useCallback(C=>{se(C),ue(!0),N(!1)},[]),Ve=p.useCallback((C,z)=>{if(!G||!(a!=null&&a.views))return;const _=a.views.map(D=>D.id===G?{...D,name:C,description:z||void 0}:D);L(a.id,{views:_}),se(null)},[G,a,L]),ar=p.useCallback(C=>{le(C),re(!0),N(!1)},[]),Kr=p.useCallback(()=>{if(!ee||!(a!=null&&a.views))return;const C=a.views.filter(D=>D.id!==ee),z=a.activeViewId===ee,_=C.find(D=>D.isDefault);L(a.id,{views:C,activeViewId:z&&_?_.id:a.activeViewId,filters:z&&_?_.snapshot.filters.length>0?_.snapshot.filters:void 0:a.filters,sortStack:z&&_?_.snapshot.sortStack.length>0?_.snapshot.sortStack:void 0:a.sortStack}),le(null),re(!1)},[ee,a,L]),ut=p.useCallback(C=>{var U;if(!(a!=null&&a.views))return;if(!(((U=h.views)==null?void 0:U.isAdmin)??!1)){S("Only administrators can promote views to Global.","error");return}const _=a.views.find(V=>V.id===C);if(!_)return;if(_.scope==="global"){S(`"${_.name}" is already a Global View.`,"info");return}const D=a.views.map(V=>V.id===C?{...V,scope:"global",isDefault:!0,updatedAt:Date.now()}:V.scope==="global"&&V.isDefault?{...V,isDefault:!1}:V);L(a.id,{views:D}),S(`"${_.name}" promoted to Global View and set as default.`,"success")},[a,h,L]);p.useEffect(()=>{De!=null&&De.resetPage?De.resetPage():st(1)},[a==null?void 0:a.filters,At,a==null?void 0:a.activeViewId]),p.useEffect(()=>{De&&De.currentPage!==gt&&st(De.currentPage)},[De==null?void 0:De.currentPage]);const lr=p.useCallback(C=>{De!=null&&De.goToPage&&De.goToPage(C),st(C)},[De]),Lt=p.useCallback(C=>{const z=(gt-1)*rt,_=Math.floor(z/C)+1;Je(C),st(_)},[gt,rt]),Ft=p.useCallback((C,z)=>{if(!a)return;if(!pt("edit_columns",ve)){S(xt("edit_columns"),"error");return}const D={...a.columnVisibility||(X==null?void 0:X.snapshot.columnVisibility)||{},[C]:z};L(a.id,{columnVisibility:D})},[a,X,ve,L]),M=p.useCallback(C=>{if(a){if(!pt("edit_columns",ve)){S(xt("edit_columns"),"error");return}L(a.id,{columnOrder:C})}},[a,ve,L]),Z=p.useCallback((C,z)=>{if(!a)return;if(!pt("edit_columns",ve)){S(xt("edit_columns"),"error");return}const D={...a.columnWidths||(X==null?void 0:X.snapshot.columnWidths)||{},[C]:z};L(a.id,{columnWidths:D})},[a,X,ve,L]),K=p.useCallback(C=>{if(!a)return;const _=(a.filters??[]).filter(D=>D.column!==C);L(a.id,{filters:_.length>0?_:void 0})},[a,L]),de=p.useCallback(()=>{if(!X||!(a!=null&&a.schema))return;const C={},z=[],_={};a.schema.forEach(D=>{C[D.name]=!0,z.push(D.name),_[D.name]=150}),L(a.id,{columnVisibility:C,columnOrder:z,columnWidths:_,filters:void 0,sortStack:void 0}),S("Reset to default layout - all filters and sorts cleared","success")},[X,a,L]),oe=p.useCallback(Ba(C=>{it(C)},300),[]),He=p.useCallback(C=>{oe(C)},[oe]),nt=p.useCallback(C=>{if(!C.trim()||!a)return;const z=a.searchHistory||[],_=aa(z,C);L(a.id,{searchHistory:_})},[a,L]),Xr=p.useCallback(C=>{if(!a)return;const z=a.searchHistory||[],_=la(z,C);L(a.id,{searchHistory:_})},[a,L]),Oo=p.useCallback(C=>{if(!a)return;const z=a.searchHistory||[],_=ca(z,C);L(a.id,{searchHistory:_})},[a,L]),$r=p.useCallback(C=>{const z=C==null?void 0:C.__urm_row_id__;Ee(_=>{const D=new Set(_);if(z!==void 0){const U=Array.from(D).find(V=>(V==null?void 0:V.__urm_row_id__)===z);U!==void 0?D.delete(U):D.add(C)}else D.has(C)?D.delete(C):D.add(C);return D})},[]),ts=p.useCallback((C,z)=>{Ee(_=>{const D=new Set(_);for(const U of z)C?D.add(U):D.delete(U);return D})},[]),rs=p.useCallback((C,z,_)=>{Ee(D=>{const U=new Set(D),V=Math.min(C,z),xe=Math.max(C,z);for(let ke=V;ke<=xe;ke++)_[ke]!==void 0&&U.add(_[ke]);return U})},[]),os=p.useCallback(()=>{Ee(new Set)},[]),ns=p.useCallback(C=>{const z=C==null?void 0:C.__urm_row_id__;Ee(_=>{const D=new Set(_);if(z!==void 0){const U=Array.from(D).find(V=>(V==null?void 0:V.__urm_row_id__)===z);U!==void 0&&D.delete(U)}else D.delete(C);return D})},[]),is=p.useCallback(C=>{if(!(a!=null&&a.uploadedData))return;const z=a.uploadedData.indexOf(C);if(z===-1)return;const _=a.favoriteRowIndices||[],U=_.includes(z)?_.filter(V=>V!==z):[..._,z];L(a.id,{favoriteRowIndices:U})},[a,L]),ss=p.useCallback((C,z)=>{if(!(a!=null&&a.uploadedData))return;const _=a.favoriteRowIndices||[],D=C.map(V=>a.uploadedData.indexOf(V)).filter(V=>V!==-1),U=z?[..._,...D.filter(V=>!_.includes(V))]:_.filter(V=>!D.includes(V));L(a.id,{favoriteRowIndices:U})},[a,L]),as=p.useCallback(()=>{if(!a)return;const C=a.favoriteRowIndices||[],z=!a.showFavoritesOnly;if(z&&C.length===0){S("No rows marked as favorite","warning");return}if(L(a.id,{showFavoritesOnly:z}),z&&Re.size>0){const _=new Set(C.map(U=>{var V,xe;return(xe=(V=a.uploadedData)==null?void 0:V[U])==null?void 0:xe.__urm_row_id__}).filter(U=>U!==void 0)),D=new Set(Array.from(Re).filter(U=>(U==null?void 0:U.__urm_row_id__)!==void 0&&_.has(U.__urm_row_id__)));Ee(D)}S(z?`Showing ${C.length} favorite row${C.length===1?"":"s"}`:"Showing all data","info")},[a,L,Re]),ls=p.useCallback(C=>{if(a){if(!pt("edit_columns",ve)){S(xt("edit_columns"),"error");return}if(C&&a.schema){const{validGrouping:z,invalidColumns:_}=ki(C,a.schema);_.length>0&&S(`Removed invalid grouping columns: ${_.join(", ")}`,"warning"),ot();try{const D=a.grouping;z===null?Se("grouping","group_cleared",D,null):D?Se("grouping","group_reordered",D,z):Se("grouping","group_level_added",null,z);const U=(X==null?void 0:X.snapshot.columnOrder)||a.columnOrder||[],V=Fr(U,z);L(a.id,{grouping:z,columnOrder:V}),JSON.stringify(V)!==JSON.stringify(a.columnOrder)&&Se("columns","column_reordered",a.columnOrder,V),tt(!1)}catch(D){const U=Ct("processing","grouping",D);Ne(U)}}else{const z=a.grouping;Se("grouping","group_cleared",z,null);const _=(X==null?void 0:X.snapshot.columnOrder)||a.columnOrder||[];L(a.id,{grouping:C,columnOrder:[..._]}),JSON.stringify(_)!==JSON.stringify(a.columnOrder)&&Se("columns","column_reordered",a.columnOrder,_),tt(!1)}}},[a,X,ve,L,ot,Ne,Se]),cs=p.useCallback(C=>{if(!a)return;const z=a.grouping;if(!z)return;const _=Qs(z,C);L(a.id,{grouping:_})},[a,L]),ds=p.useCallback(()=>{lt(!0)},[]),cr=p.useCallback(C=>{a!=null&&a.schema&&(P(!0),setTimeout(()=>{try{let z;C.scope==="visible"?z=Wt:z=a.uploadedData||[];let _;C.columnScope==="all"?(_={},a.schema.forEach(ke=>{_[ke.name]=!0})):_=a.columnVisibility||(X==null?void 0:X.snapshot.columnVisibility)||{};const D=a.columnOrder||(X==null?void 0:X.snapshot.columnOrder),U=co(z,a.schema,a.filters??[],a.sortStack??[],X,_,D),V=a.name;let xe;switch(C.format){case"csv":uo(U,V,C),xe="export_csv";break;case"excel":po(U,V,C),xe="export_excel";break;case"json":xo(U,V,C),xe="export_json";break}Se("export",xe,null,{format:C.format,scope:C.scope,columnScope:C.columnScope,rowCount:z.length,viewName:(X==null?void 0:X.name)||"Default View"}),S(`Export completed successfully (${C.format.toUpperCase()})`,"success")}catch(z){const _=Ra(z,{onRetry:()=>cr(C)});S(`Export failed: ${_.message}`,{action:{label:"Retry",onClick:()=>cr(C)}});const D=Cn(a.id,mt,_,a.auditHistory||[]);L(a.id,{auditHistory:D}),Ut.error("urm:report-engine","Export failed",z)}finally{P(!1)}},500))},[a,X,Wt,L,Se]),us=p.useCallback(C=>{if(a!=null&&a.schema){if(vt&&X&&!X.isDefault){he(C.format),ce(!0),lt(!1);return}cr(C),lt(!1)}},[a,X,vt,cr]),Zr=p.useCallback(C=>{cr({format:C,scope:"visible",columnScope:"visible"})},[cr]),ps=p.useCallback(()=>{ie&&Zr(ie),ce(!1),he(null)},[ie,Zr]),xs=p.useCallback(()=>{Pt(),ie&&Zr(ie),ce(!1),he(null)},[Pt,ie,Zr]),ms=p.useCallback(()=>{ce(!1),he(null)},[]),fs=p.useCallback(C=>{!(a!=null&&a.schema)||Re.size===0||(P(!0),setTimeout(()=>{try{const z=Array.from(Re),_=co(z,a.schema,a.filters??[],a.sortStack??[],X),D=`${a.name.toLowerCase().replace(/\s+/g,"_")}_selected_export`;switch(C){case"csv":uo(_,D);break;case"excel":po(_,D);break;case"json":xo(_,D);break}S(`Exported ${z.length} selected rows`,"info")}catch(z){S("Export failed. Please try again.","error"),Ut.error("urm:report-engine","Bulk export failed",z)}finally{P(!1)}},500))},[a,X,Re,Et]),hs=p.useCallback((C,z)=>{if(a)try{const _=ja(a),D=Ca(C,z,mt,_),U=wa(a.presets,D);L(a.id,{presets:U}),Se("presets","preset_created",null,{presetId:D.id,name:D.name}),Ke(!1),S(`Preset "${C}" saved successfully`,"success")}catch(_){S(_ instanceof Error?_.message:"Failed to create preset","error")}},[a,L,Se]),gs=p.useCallback(()=>{zt(null),S("Exited preset view","info")},[]),ys=p.useCallback(()=>{Zt(!0)},[]),bs=p.useCallback((C,z)=>{if(!a)return;const _=ka(a.presets,C);L(a.id,{presets:_}),Se("presets","preset_deleted",{presetId:C,name:z},null),yt===C&&zt(null),S(`Preset "${z}" deleted`,"success")},[a,yt,L,Se]);p.useEffect(()=>{if(!d||u.length===0)return;const C=u.find(z=>z.id===d);C&&C.id!==b&&f(C.id)},[d,u,b]),p.useEffect(()=>{if(!a)return;const C=Ta();if(C&&a.presets&&a.schemaLocked&&a.schema){const z=jn(a.presets,C);if(z){const{sanitizedConfig:_,warnings:D}=Wa(z.config,a.schema);D.length>0&&D.forEach(V=>S(V,"warning"));const U=Ia(_);L(a.id,U),zt(C),Se("presets","preset_applied",null,{presetId:z.id,name:z.name}),S(`Loaded preset: ${z.name}`,"info")}else S("Preset not found","info")}},[a==null?void 0:a.schemaLocked]);const vs=yt?jn(a==null?void 0:a.presets,yt):void 0;p.useEffect(()=>{a!=null&&a.views&&a.views.length>0&&a.activeViewId&&na(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 C=ia(a.id);if(C&&C.views.length>0){const z=C.views.find(_=>_.id===C.activeViewId);if(z)L(a.id,{views:C.views,activeViewId:C.activeViewId,filters:z.snapshot.filters.length>0?z.snapshot.filters:void 0,sortStack:z.snapshot.sortStack.length>0?z.snapshot.sortStack:void 0});else{const _=C.views.find(D=>D.isDefault)||Mo(a.schema);L(a.id,{views:C.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 Ss=p.useCallback(C=>{F(C),Y(!0)},[]),js=p.useCallback(()=>{Y(!1),F(void 0)},[]),Cs=(un=a==null?void 0:a.views)==null?void 0:un.find(C=>C.id===G),ws=(pn=a==null?void 0:a.views)==null?void 0:pn.find(C=>C.id===ee);return{reports:u,activeReport:a,activeReportId:b,setActiveReportId:f,isModalOpen:g,setIsModalOpen:T,createReport:Ze,updateReport:L,uploadState:A,handleFileUpload:kr,handleUploadError:St,handleRetry:$e,handleConfirm:tr,paginatedData:$t,processedData:Wt,displayData:Et,tableMetrics:wr,isGrouped:Rt,tableEngine:bt,activeView:X,isDirty:vt,currentTableState:ge,viewChanges:je,filters:a==null?void 0:a.filters,showFilterPanel:$,setShowFilterPanel:Y,filterFocusColumn:O,handleAddFilter:nr,handleUpdateFilter:ir,handleRemoveFilter:Le,handleClearAllFilters:ct,handleReplaceFilters:dt,handleOpenFilterForColumn:Ss,handleCloseFilterPanel:js,handleClearFiltersForColumn:K,sortStack:a==null?void 0:a.sortStack,showSortPanel:Q,setShowSortPanel:te,handleSort:Tr,handleUpdateSortStack:rr,handleSortAscending:or,handleSortDescending:Ir,views:a==null?void 0:a.views,showManageViews:x,setShowManageViews:N,showCreateViewModal:W,setShowCreateViewModal:H,showEditViewModal:J,setShowEditViewModal:ue,showDeleteConfirmation:pe,setShowDeleteConfirmation:re,editingView:Cs,deletingView:ws,editingViewId:G,deletingViewId:ee,handleSelectView:Fe,handleCreateView:sr,handleUpdateCurrentView:Pt,handleSaveColumnConfigToCurrentView:zr,handleSaveColumnConfigToAllViews:Er,handleSaveAsNewView:Br,handleRevertChanges:Dr,handleToggleDefault:Or,handleToggleFavorite:Ar,handleSoftDelete:Nt,handleRestoreView:Mr,handlePermanentDelete:_r,handleEditView:Me,handleSaveEditView:Ve,handleDeleteView:ar,handleConfirmDelete:Kr,handlePromoteToGlobal:ut,showManageColumns:q,setShowManageColumns:Ae,columnVisibility:a==null?void 0:a.columnVisibility,columnOrder:a==null?void 0:a.columnOrder,columnWidths:a==null?void 0:a.columnWidths,handleUpdateColumnVisibility:Ft,handleUpdateColumnOrder:M,handleUpdateColumnWidth:Z,handleResetColumnLayout:de,showGroupPanel:We,setShowGroupPanel:tt,grouping:a==null?void 0:a.grouping,groupingState:Kt,handleGroup:ls,handleToggleGroupCollapse:cs,searchQuery:At,searchHistory:da((a==null?void 0:a.searchHistory)||[]),handleSearchChange:He,handleAddToSearchHistory:nt,handleToggleSearchFavourite:Xr,handleDeleteSearchHistory:Oo,selectedRowIds:Re,handleToggleRowSelection:$r,handleToggleAllRows:ts,handleRangeSelection:rs,handleClearSelection:os,handleUpdateSelectionAfterDelete:ns,favoriteRowIndices:(a==null?void 0:a.favoriteRowIndices)||[],resolvedFavoritesSet:_t,showFavoritesOnly:(a==null?void 0:a.showFavoritesOnly)||!1,handleToggleRowFavorite:is,handleBulkSetFavorites:ss,handleToggleFavoritesFilter:as,currentPage:gt,pageSize:rt,paginationEngine:De,handlePageChange:lr,handlePageSizeChange:Lt,isExporting:ae,showExportModal:Qt,setShowExportModal:lt,showDirtyExportWarning:ne,handleExport:ds,handleExportWithConfig:us,handleExportSelected:fs,handleExportAnyway:ps,handleSaveAndExport:xs,handleCancelExport:ms,showAuditHistory:It,setShowAuditHistory:Xt,auditHistory:a==null?void 0:a.auditHistory,showCreatePreset:at,setShowCreatePreset:Ke,showManagePresets:Pe,setShowManagePresets:Zt,activePreset:vs,activePresetId:yt,handleOpenManagePresets:ys,handleCreatePreset:hs,handleClearActivePreset:gs,handleDeletePresetById:bs,userRole:ve,isViewerRole:jr,currentUserId:mt,featureLimitWarning:br,setFeatureLimitWarning:Mt,datasetMeta:er,reportError:vr,setReportError:Sr,handleError:Ne,schema:a==null?void 0:a.schema,hasSchemaConflicts:a!=null&&a.schema?Us(a.schema):!1,snack:v,handleSnackClose:I,showSnack:S}}const Ti=p.createContext(void 0);function en(t){const{children:o,initialData:n,data:i,reportName:s,dataSource:c,mode:d="builder",autoLoad:l=!0,config:u,devConfig:m,showDevPanel:h=!1,sharedReportId:b}=t,g=Qa({mode:d,autoLoad:l,initialData:i||n,dataSource:c,reportName:s,sharedReportId:b,config:u}),[T,y]=p.useState(()=>Is()),w=(()=>{const I=Es(T,m,!!m);return{...I,display:{...I.display,showDevPanel:h||I.display.showDevPanel}}})(),v=p.useCallback(S=>{y(S),zs(S)},[]),j={...g,activeDevConfig:w,handleDevConfigChange:v};return e.jsx(xi.Provider,{value:w,children:e.jsx(Ti.Provider,{value:j,children:o})})}function go(){const t=p.useContext(Ti);if(t===void 0)throw new Error("useReportContext must be used within a ReportProvider. Wrap your component tree with <ReportProvider>...</ReportProvider>");return t}function el({onCreateReport:t,reports:o=[],activeReportId:n,onReportClick:i}){const s=o.find(c=>c.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(k.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(k.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(k.Add,{sx:{fontSize:18}}),onClick:t,sx:{borderRadius:"20px",px:3,textTransform:"none",fontWeight:500,fontSize:"0.875rem",py:.75},children:"New Report"})})]})})}function Yt(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 tl="$$material";function rl(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ro={exports:{}},oo={exports:{}},me={};/** @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 ln;function ba(){if(ln)return xe;ln=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,a=t?Symbol.for("react.strict_mode"):60108,l=t?Symbol.for("react.profiler"):60114,c=t?Symbol.for("react.provider"):60109,d=t?Symbol.for("react.context"):60110,u=t?Symbol.for("react.async_mode"):60111,f=t?Symbol.for("react.concurrent_mode"):60111,h=t?Symbol.for("react.forward_ref"):60112,m=t?Symbol.for("react.suspense"):60113,v=t?Symbol.for("react.suspense_list"):60120,w=t?Symbol.for("react.memo"):60115,z=t?Symbol.for("react.lazy"):60116,y=t?Symbol.for("react.block"):60121,j=t?Symbol.for("react.fundamental"):60117,b=t?Symbol.for("react.responder"):60118,g=t?Symbol.for("react.scope"):60119;function S(I){if(typeof I=="object"&&I!==null){var A=I.$$typeof;switch(A){case o:switch(I=I.type,I){case u:case f:case i:case l:case a:case m:return I;default:switch(I=I&&I.$$typeof,I){case d:case h:case z:case w:case c:return I;default:return A}}case n:return A}}}function s(I){return S(I)===f}return xe.AsyncMode=u,xe.ConcurrentMode=f,xe.ContextConsumer=d,xe.ContextProvider=c,xe.Element=o,xe.ForwardRef=h,xe.Fragment=i,xe.Lazy=z,xe.Memo=w,xe.Portal=n,xe.Profiler=l,xe.StrictMode=a,xe.Suspense=m,xe.isAsyncMode=function(I){return s(I)||S(I)===u},xe.isConcurrentMode=s,xe.isContextConsumer=function(I){return S(I)===d},xe.isContextProvider=function(I){return S(I)===c},xe.isElement=function(I){return typeof I=="object"&&I!==null&&I.$$typeof===o},xe.isForwardRef=function(I){return S(I)===h},xe.isFragment=function(I){return S(I)===i},xe.isLazy=function(I){return S(I)===z},xe.isMemo=function(I){return S(I)===w},xe.isPortal=function(I){return S(I)===n},xe.isProfiler=function(I){return S(I)===l},xe.isStrictMode=function(I){return S(I)===a},xe.isSuspense=function(I){return S(I)===m},xe.isValidElementType=function(I){return typeof I=="string"||typeof I=="function"||I===i||I===f||I===l||I===a||I===m||I===v||typeof I=="object"&&I!==null&&(I.$$typeof===z||I.$$typeof===w||I.$$typeof===c||I.$$typeof===d||I.$$typeof===h||I.$$typeof===j||I.$$typeof===b||I.$$typeof===g||I.$$typeof===y)},xe.typeOf=S,xe}var fe={};/** @license React v16.13.1
10
+ */var kn;function ol(){if(kn)return me;kn=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,c=t?Symbol.for("react.profiler"):60114,d=t?Symbol.for("react.provider"):60109,l=t?Symbol.for("react.context"):60110,u=t?Symbol.for("react.async_mode"):60111,m=t?Symbol.for("react.concurrent_mode"):60111,h=t?Symbol.for("react.forward_ref"):60112,b=t?Symbol.for("react.suspense"):60113,f=t?Symbol.for("react.suspense_list"):60120,g=t?Symbol.for("react.memo"):60115,T=t?Symbol.for("react.lazy"):60116,y=t?Symbol.for("react.block"):60121,w=t?Symbol.for("react.fundamental"):60117,v=t?Symbol.for("react.responder"):60118,j=t?Symbol.for("react.scope"):60119;function S(a){if(typeof a=="object"&&a!==null){var A=a.$$typeof;switch(A){case o:switch(a=a.type,a){case u:case m:case i:case c:case s:case b:return a;default:switch(a=a&&a.$$typeof,a){case l:case h:case T:case g:case d:return a;default:return A}}case n:return A}}}function I(a){return S(a)===m}return me.AsyncMode=u,me.ConcurrentMode=m,me.ContextConsumer=l,me.ContextProvider=d,me.Element=o,me.ForwardRef=h,me.Fragment=i,me.Lazy=T,me.Memo=g,me.Portal=n,me.Profiler=c,me.StrictMode=s,me.Suspense=b,me.isAsyncMode=function(a){return I(a)||S(a)===u},me.isConcurrentMode=I,me.isContextConsumer=function(a){return S(a)===l},me.isContextProvider=function(a){return S(a)===d},me.isElement=function(a){return typeof a=="object"&&a!==null&&a.$$typeof===o},me.isForwardRef=function(a){return S(a)===h},me.isFragment=function(a){return S(a)===i},me.isLazy=function(a){return S(a)===T},me.isMemo=function(a){return S(a)===g},me.isPortal=function(a){return S(a)===n},me.isProfiler=function(a){return S(a)===c},me.isStrictMode=function(a){return S(a)===s},me.isSuspense=function(a){return S(a)===b},me.isValidElementType=function(a){return typeof a=="string"||typeof a=="function"||a===i||a===m||a===c||a===s||a===b||a===f||typeof a=="object"&&a!==null&&(a.$$typeof===T||a.$$typeof===g||a.$$typeof===d||a.$$typeof===l||a.$$typeof===h||a.$$typeof===w||a.$$typeof===v||a.$$typeof===j||a.$$typeof===y)},me.typeOf=S,me}var fe={};/** @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 cn;function va(){return cn||(cn=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,a=t?Symbol.for("react.strict_mode"):60108,l=t?Symbol.for("react.profiler"):60114,c=t?Symbol.for("react.provider"):60109,d=t?Symbol.for("react.context"):60110,u=t?Symbol.for("react.async_mode"):60111,f=t?Symbol.for("react.concurrent_mode"):60111,h=t?Symbol.for("react.forward_ref"):60112,m=t?Symbol.for("react.suspense"):60113,v=t?Symbol.for("react.suspense_list"):60120,w=t?Symbol.for("react.memo"):60115,z=t?Symbol.for("react.lazy"):60116,y=t?Symbol.for("react.block"):60121,j=t?Symbol.for("react.fundamental"):60117,b=t?Symbol.for("react.responder"):60118,g=t?Symbol.for("react.scope"):60119;function S(U){return typeof U=="string"||typeof U=="function"||U===i||U===f||U===l||U===a||U===m||U===v||typeof U=="object"&&U!==null&&(U.$$typeof===z||U.$$typeof===w||U.$$typeof===c||U.$$typeof===d||U.$$typeof===h||U.$$typeof===j||U.$$typeof===b||U.$$typeof===g||U.$$typeof===y)}function s(U){if(typeof U=="object"&&U!==null){var Oe=U.$$typeof;switch(Oe){case o:var Le=U.type;switch(Le){case u:case f:case i:case l:case a:case m:return Le;default:var dt=Le&&Le.$$typeof;switch(dt){case d:case h:case z:case w:case c:return dt;default:return Oe}}case n:return Oe}}}var I=u,A=f,H=d,N=c,K=o,te=h,se=i,x=z,V=w,$=n,J=l,oe=a,ue=m,pe=!1;function _(U){return pe||(pe=!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.")),O(U)||s(U)===u}function O(U){return s(U)===f}function L(U){return s(U)===d}function re(U){return s(U)===c}function Q(U){return typeof U=="object"&&U!==null&&U.$$typeof===o}function X(U){return s(U)===h}function ae(U){return s(U)===i}function Z(U){return s(U)===z}function W(U){return s(U)===w}function ee(U){return s(U)===n}function ie(U){return s(U)===l}function ne(U){return s(U)===a}function ke(U){return s(U)===m}fe.AsyncMode=I,fe.ConcurrentMode=A,fe.ContextConsumer=H,fe.ContextProvider=N,fe.Element=K,fe.ForwardRef=te,fe.Fragment=se,fe.Lazy=x,fe.Memo=V,fe.Portal=$,fe.Profiler=J,fe.StrictMode=oe,fe.Suspense=ue,fe.isAsyncMode=_,fe.isConcurrentMode=O,fe.isContextConsumer=L,fe.isContextProvider=re,fe.isElement=Q,fe.isForwardRef=X,fe.isFragment=ae,fe.isLazy=Z,fe.isMemo=W,fe.isPortal=ee,fe.isProfiler=ie,fe.isStrictMode=ne,fe.isSuspense=ke,fe.isValidElementType=S,fe.typeOf=s})()),fe}var dn;function ni(){return dn||(dn=1,process.env.NODE_ENV==="production"?Yr.exports=ba():Yr.exports=va()),Yr.exports}/*
17
+ */var Tn;function nl(){return Tn||(Tn=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,c=t?Symbol.for("react.profiler"):60114,d=t?Symbol.for("react.provider"):60109,l=t?Symbol.for("react.context"):60110,u=t?Symbol.for("react.async_mode"):60111,m=t?Symbol.for("react.concurrent_mode"):60111,h=t?Symbol.for("react.forward_ref"):60112,b=t?Symbol.for("react.suspense"):60113,f=t?Symbol.for("react.suspense_list"):60120,g=t?Symbol.for("react.memo"):60115,T=t?Symbol.for("react.lazy"):60116,y=t?Symbol.for("react.block"):60121,w=t?Symbol.for("react.fundamental"):60117,v=t?Symbol.for("react.responder"):60118,j=t?Symbol.for("react.scope"):60119;function S(q){return typeof q=="string"||typeof q=="function"||q===i||q===m||q===c||q===s||q===b||q===f||typeof q=="object"&&q!==null&&(q.$$typeof===T||q.$$typeof===g||q.$$typeof===d||q.$$typeof===l||q.$$typeof===h||q.$$typeof===w||q.$$typeof===v||q.$$typeof===j||q.$$typeof===y)}function I(q){if(typeof q=="object"&&q!==null){var Ae=q.$$typeof;switch(Ae){case o:var We=q.type;switch(We){case u:case m:case i:case c:case s:case b:return We;default:var tt=We&&We.$$typeof;switch(tt){case l:case h:case T:case g:case d:return tt;default:return Ae}}case n:return Ae}}}var a=u,A=m,B=l,$=d,Y=o,Q=h,te=i,x=T,N=g,W=n,H=c,J=s,ue=b,pe=!1;function re(q){return pe||(pe=!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.")),O(q)||I(q)===u}function O(q){return I(q)===m}function F(q){return I(q)===l}function G(q){return I(q)===d}function se(q){return typeof q=="object"&&q!==null&&q.$$typeof===o}function ee(q){return I(q)===h}function le(q){return I(q)===i}function ae(q){return I(q)===T}function P(q){return I(q)===g}function ne(q){return I(q)===n}function ce(q){return I(q)===c}function ie(q){return I(q)===s}function he(q){return I(q)===b}fe.AsyncMode=a,fe.ConcurrentMode=A,fe.ContextConsumer=B,fe.ContextProvider=$,fe.Element=Y,fe.ForwardRef=Q,fe.Fragment=te,fe.Lazy=x,fe.Memo=N,fe.Portal=W,fe.Profiler=H,fe.StrictMode=J,fe.Suspense=ue,fe.isAsyncMode=re,fe.isConcurrentMode=O,fe.isContextConsumer=F,fe.isContextProvider=G,fe.isElement=se,fe.isForwardRef=ee,fe.isFragment=le,fe.isLazy=ae,fe.isMemo=P,fe.isPortal=ne,fe.isProfiler=ce,fe.isStrictMode=ie,fe.isSuspense=he,fe.isValidElementType=S,fe.typeOf=I})()),fe}var In;function Ii(){return In||(In=1,process.env.NODE_ENV==="production"?oo.exports=ol():oo.exports=nl()),oo.exports}/*
18
18
  object-assign
19
19
  (c) Sindre Sorhus
20
20
  @license MIT
21
- */var wo,un;function Sa(){if(un)return wo;un=1;var t=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function i(l){if(l==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(l)}function a(){try{if(!Object.assign)return!1;var l=new String("abc");if(l[5]="de",Object.getOwnPropertyNames(l)[0]==="5")return!1;for(var c={},d=0;d<10;d++)c["_"+String.fromCharCode(d)]=d;var u=Object.getOwnPropertyNames(c).map(function(h){return c[h]});if(u.join("")!=="0123456789")return!1;var f={};return"abcdefghijklmnopqrst".split("").forEach(function(h){f[h]=h}),Object.keys(Object.assign({},f)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return wo=a()?Object.assign:function(l,c){for(var d,u=i(l),f,h=1;h<arguments.length;h++){d=Object(arguments[h]);for(var m in d)o.call(d,m)&&(u[m]=d[m]);if(t){f=t(d);for(var v=0;v<f.length;v++)n.call(d,f[v])&&(u[f[v]]=d[f[v]])}}return u},wo}var ko,pn;function Fo(){if(pn)return ko;pn=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return ko=t,ko}var To,xn;function ii(){return xn||(xn=1,To=Function.call.bind(Object.prototype.hasOwnProperty)),To}var zo,fn;function Ca(){if(fn)return zo;fn=1;var t=function(){};if(process.env.NODE_ENV!=="production"){var o=Fo(),n={},i=ii();t=function(l){var c="Warning: "+l;typeof console<"u"&&console.error(c);try{throw new Error(c)}catch{}}}function a(l,c,d,u,f){if(process.env.NODE_ENV!=="production"){for(var h in l)if(i(l,h)){var m;try{if(typeof l[h]!="function"){var v=Error((u||"React class")+": "+d+" type `"+h+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof l[h]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw v.name="Invariant Violation",v}m=l[h](c,h,u,d,null,o)}catch(z){m=z}if(m&&!(m instanceof Error)&&t((u||"React class")+": type specification of "+d+" `"+h+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof m+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),m instanceof Error&&!(m.message in n)){n[m.message]=!0;var w=f?f():"";t("Failed "+d+" type: "+m.message+(w??""))}}}}return a.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},zo=a,zo}var Io,hn;function ja(){if(hn)return Io;hn=1;var t=ni(),o=Sa(),n=Fo(),i=ii(),a=Ca(),l=function(){};process.env.NODE_ENV!=="production"&&(l=function(d){var u="Warning: "+d;typeof console<"u"&&console.error(u);try{throw new Error(u)}catch{}});function c(){return null}return Io=function(d,u){var f=typeof Symbol=="function"&&Symbol.iterator,h="@@iterator";function m(O){var L=O&&(f&&O[f]||O[h]);if(typeof L=="function")return L}var v="<<anonymous>>",w={array:b("array"),bigint:b("bigint"),bool:b("boolean"),func:b("function"),number:b("number"),object:b("object"),string:b("string"),symbol:b("symbol"),any:g(),arrayOf:S,element:s(),elementType:I(),instanceOf:A,node:te(),objectOf:N,oneOf:H,oneOfType:K,shape:x,exact:V};function z(O,L){return O===L?O!==0||1/O===1/L:O!==O&&L!==L}function y(O,L){this.message=O,this.data=L&&typeof L=="object"?L:{},this.stack=""}y.prototype=Error.prototype;function j(O){if(process.env.NODE_ENV!=="production")var L={},re=0;function Q(ae,Z,W,ee,ie,ne,ke){if(ee=ee||v,ne=ne||W,ke!==n){if(u){var U=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 U.name="Invariant Violation",U}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var Oe=ee+":"+W;!L[Oe]&&re<3&&(l("You are manually calling a React.PropTypes validation function for the `"+ne+"` prop on `"+ee+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),L[Oe]=!0,re++)}}return Z[W]==null?ae?Z[W]===null?new y("The "+ie+" `"+ne+"` is marked as required "+("in `"+ee+"`, but its value is `null`.")):new y("The "+ie+" `"+ne+"` is marked as required in "+("`"+ee+"`, but its value is `undefined`.")):null:O(Z,W,ee,ie,ne)}var X=Q.bind(null,!1);return X.isRequired=Q.bind(null,!0),X}function b(O){function L(re,Q,X,ae,Z,W){var ee=re[Q],ie=oe(ee);if(ie!==O){var ne=ue(ee);return new y("Invalid "+ae+" `"+Z+"` of type "+("`"+ne+"` supplied to `"+X+"`, expected ")+("`"+O+"`."),{expectedType:O})}return null}return j(L)}function g(){return j(c)}function S(O){function L(re,Q,X,ae,Z){if(typeof O!="function")return new y("Property `"+Z+"` of component `"+X+"` has invalid PropType notation inside arrayOf.");var W=re[Q];if(!Array.isArray(W)){var ee=oe(W);return new y("Invalid "+ae+" `"+Z+"` of type "+("`"+ee+"` supplied to `"+X+"`, expected an array."))}for(var ie=0;ie<W.length;ie++){var ne=O(W,ie,X,ae,Z+"["+ie+"]",n);if(ne instanceof Error)return ne}return null}return j(L)}function s(){function O(L,re,Q,X,ae){var Z=L[re];if(!d(Z)){var W=oe(Z);return new y("Invalid "+X+" `"+ae+"` of type "+("`"+W+"` supplied to `"+Q+"`, expected a single ReactElement."))}return null}return j(O)}function I(){function O(L,re,Q,X,ae){var Z=L[re];if(!t.isValidElementType(Z)){var W=oe(Z);return new y("Invalid "+X+" `"+ae+"` of type "+("`"+W+"` supplied to `"+Q+"`, expected a single ReactElement type."))}return null}return j(O)}function A(O){function L(re,Q,X,ae,Z){if(!(re[Q]instanceof O)){var W=O.name||v,ee=_(re[Q]);return new y("Invalid "+ae+" `"+Z+"` of type "+("`"+ee+"` supplied to `"+X+"`, expected ")+("instance of `"+W+"`."))}return null}return j(L)}function H(O){if(!Array.isArray(O))return process.env.NODE_ENV!=="production"&&(arguments.length>1?l("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])."):l("Invalid argument supplied to oneOf, expected an array.")),c;function L(re,Q,X,ae,Z){for(var W=re[Q],ee=0;ee<O.length;ee++)if(z(W,O[ee]))return null;var ie=JSON.stringify(O,function(ke,U){var Oe=ue(U);return Oe==="symbol"?String(U):U});return new y("Invalid "+ae+" `"+Z+"` of value `"+String(W)+"` "+("supplied to `"+X+"`, expected one of "+ie+"."))}return j(L)}function N(O){function L(re,Q,X,ae,Z){if(typeof O!="function")return new y("Property `"+Z+"` of component `"+X+"` has invalid PropType notation inside objectOf.");var W=re[Q],ee=oe(W);if(ee!=="object")return new y("Invalid "+ae+" `"+Z+"` of type "+("`"+ee+"` supplied to `"+X+"`, expected an object."));for(var ie in W)if(i(W,ie)){var ne=O(W,ie,X,ae,Z+"."+ie,n);if(ne instanceof Error)return ne}return null}return j(L)}function K(O){if(!Array.isArray(O))return process.env.NODE_ENV!=="production"&&l("Invalid argument supplied to oneOfType, expected an instance of array."),c;for(var L=0;L<O.length;L++){var re=O[L];if(typeof re!="function")return l("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+pe(re)+" at index "+L+"."),c}function Q(X,ae,Z,W,ee){for(var ie=[],ne=0;ne<O.length;ne++){var ke=O[ne],U=ke(X,ae,Z,W,ee,n);if(U==null)return null;U.data&&i(U.data,"expectedType")&&ie.push(U.data.expectedType)}var Oe=ie.length>0?", expected one of type ["+ie.join(", ")+"]":"";return new y("Invalid "+W+" `"+ee+"` supplied to "+("`"+Z+"`"+Oe+"."))}return j(Q)}function te(){function O(L,re,Q,X,ae){return $(L[re])?null:new y("Invalid "+X+" `"+ae+"` supplied to "+("`"+Q+"`, expected a ReactNode."))}return j(O)}function se(O,L,re,Q,X){return new y((O||"React class")+": "+L+" type `"+re+"."+Q+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+X+"`.")}function x(O){function L(re,Q,X,ae,Z){var W=re[Q],ee=oe(W);if(ee!=="object")return new y("Invalid "+ae+" `"+Z+"` of type `"+ee+"` "+("supplied to `"+X+"`, expected `object`."));for(var ie in O){var ne=O[ie];if(typeof ne!="function")return se(X,ae,Z,ie,ue(ne));var ke=ne(W,ie,X,ae,Z+"."+ie,n);if(ke)return ke}return null}return j(L)}function V(O){function L(re,Q,X,ae,Z){var W=re[Q],ee=oe(W);if(ee!=="object")return new y("Invalid "+ae+" `"+Z+"` of type `"+ee+"` "+("supplied to `"+X+"`, expected `object`."));var ie=o({},re[Q],O);for(var ne in ie){var ke=O[ne];if(i(O,ne)&&typeof ke!="function")return se(X,ae,Z,ne,ue(ke));if(!ke)return new y("Invalid "+ae+" `"+Z+"` key `"+ne+"` supplied to `"+X+"`.\nBad object: "+JSON.stringify(re[Q],null," ")+`
22
- Valid keys: `+JSON.stringify(Object.keys(O),null," "));var U=ke(W,ne,X,ae,Z+"."+ne,n);if(U)return U}return null}return j(L)}function $(O){switch(typeof O){case"number":case"string":case"undefined":return!0;case"boolean":return!O;case"object":if(Array.isArray(O))return O.every($);if(O===null||d(O))return!0;var L=m(O);if(L){var re=L.call(O),Q;if(L!==O.entries){for(;!(Q=re.next()).done;)if(!$(Q.value))return!1}else for(;!(Q=re.next()).done;){var X=Q.value;if(X&&!$(X[1]))return!1}}else return!1;return!0;default:return!1}}function J(O,L){return O==="symbol"?!0:L?L["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&L instanceof Symbol:!1}function oe(O){var L=typeof O;return Array.isArray(O)?"array":O instanceof RegExp?"object":J(L,O)?"symbol":L}function ue(O){if(typeof O>"u"||O===null)return""+O;var L=oe(O);if(L==="object"){if(O instanceof Date)return"date";if(O instanceof RegExp)return"regexp"}return L}function pe(O){var L=ue(O);switch(L){case"array":case"object":return"an "+L;case"boolean":case"date":case"regexp":return"a "+L;default:return L}}function _(O){return!O.constructor||!O.constructor.name?v:O.constructor.name}return w.checkPropTypes=a,w.resetWarningCache=a.resetWarningCache,w.PropTypes=w,w},Io}var Eo,mn;function wa(){if(mn)return Eo;mn=1;var t=Fo();function o(){}function n(){}return n.resetWarningCache=o,Eo=function(){function i(c,d,u,f,h,m){if(m!==t){var v=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw v.name="Invariant Violation",v}}i.isRequired=i;function a(){return i}var l={array:i,bigint:i,bool:i,func:i,number:i,object:i,string:i,symbol:i,any:i,arrayOf:a,element:i,elementType:i,instanceOf:a,node:i,objectOf:a,oneOf:a,oneOfType:a,shape:a,exact:a,checkPropTypes:n,resetWarningCache:o};return l.PropTypes=l,l},Eo}var gn;function ka(){if(gn)return Gr.exports;if(gn=1,process.env.NODE_ENV!=="production"){var t=ni(),o=!0;Gr.exports=ja()(t.isElement,o)}else Gr.exports=wa()();return Gr.exports}var Ta=ka();const zr=ya(Ta);var qr={exports:{}},be={};/**
21
+ */var $o,zn;function il(){if(zn)return $o;zn=1;var t=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function i(c){if(c==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(c)}function s(){try{if(!Object.assign)return!1;var c=new String("abc");if(c[5]="de",Object.getOwnPropertyNames(c)[0]==="5")return!1;for(var d={},l=0;l<10;l++)d["_"+String.fromCharCode(l)]=l;var u=Object.getOwnPropertyNames(d).map(function(h){return d[h]});if(u.join("")!=="0123456789")return!1;var m={};return"abcdefghijklmnopqrst".split("").forEach(function(h){m[h]=h}),Object.keys(Object.assign({},m)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return $o=s()?Object.assign:function(c,d){for(var l,u=i(c),m,h=1;h<arguments.length;h++){l=Object(arguments[h]);for(var b in l)o.call(l,b)&&(u[b]=l[b]);if(t){m=t(l);for(var f=0;f<m.length;f++)n.call(l,m[f])&&(u[m[f]]=l[m[f]])}}return u},$o}var Wo,En;function tn(){if(En)return Wo;En=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Wo=t,Wo}var Ro,Bn;function zi(){return Bn||(Bn=1,Ro=Function.call.bind(Object.prototype.hasOwnProperty)),Ro}var Po,Dn;function sl(){if(Dn)return Po;Dn=1;var t=function(){};if(process.env.NODE_ENV!=="production"){var o=tn(),n={},i=zi();t=function(c){var d="Warning: "+c;typeof console<"u"&&console.error(d);try{throw new Error(d)}catch{}}}function s(c,d,l,u,m){if(process.env.NODE_ENV!=="production"){for(var h in c)if(i(c,h)){var b;try{if(typeof c[h]!="function"){var f=Error((u||"React class")+": "+l+" type `"+h+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof c[h]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw f.name="Invariant Violation",f}b=c[h](d,h,u,l,null,o)}catch(T){b=T}if(b&&!(b instanceof Error)&&t((u||"React class")+": type specification of "+l+" `"+h+"` 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 g=m?m():"";t("Failed "+l+" type: "+b.message+(g??""))}}}}return s.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},Po=s,Po}var No,On;function al(){if(On)return No;On=1;var t=Ii(),o=il(),n=tn(),i=zi(),s=sl(),c=function(){};process.env.NODE_ENV!=="production"&&(c=function(l){var u="Warning: "+l;typeof console<"u"&&console.error(u);try{throw new Error(u)}catch{}});function d(){return null}return No=function(l,u){var m=typeof Symbol=="function"&&Symbol.iterator,h="@@iterator";function b(O){var F=O&&(m&&O[m]||O[h]);if(typeof F=="function")return F}var f="<<anonymous>>",g={array:v("array"),bigint:v("bigint"),bool:v("boolean"),func:v("function"),number:v("number"),object:v("object"),string:v("string"),symbol:v("symbol"),any:j(),arrayOf:S,element:I(),elementType:a(),instanceOf:A,node:Q(),objectOf:$,oneOf:B,oneOfType:Y,shape:x,exact:N};function T(O,F){return O===F?O!==0||1/O===1/F:O!==O&&F!==F}function y(O,F){this.message=O,this.data=F&&typeof F=="object"?F:{},this.stack=""}y.prototype=Error.prototype;function w(O){if(process.env.NODE_ENV!=="production")var F={},G=0;function se(le,ae,P,ne,ce,ie,he){if(ne=ne||f,ie=ie||P,he!==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 Ae=ne+":"+P;!F[Ae]&&G<3&&(c("You are manually calling a React.PropTypes validation function for the `"+ie+"` 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."),F[Ae]=!0,G++)}}return ae[P]==null?le?ae[P]===null?new y("The "+ce+" `"+ie+"` is marked as required "+("in `"+ne+"`, but its value is `null`.")):new y("The "+ce+" `"+ie+"` is marked as required in "+("`"+ne+"`, but its value is `undefined`.")):null:O(ae,P,ne,ce,ie)}var ee=se.bind(null,!1);return ee.isRequired=se.bind(null,!0),ee}function v(O){function F(G,se,ee,le,ae,P){var ne=G[se],ce=J(ne);if(ce!==O){var ie=ue(ne);return new y("Invalid "+le+" `"+ae+"` of type "+("`"+ie+"` supplied to `"+ee+"`, expected ")+("`"+O+"`."),{expectedType:O})}return null}return w(F)}function j(){return w(d)}function S(O){function F(G,se,ee,le,ae){if(typeof O!="function")return new y("Property `"+ae+"` of component `"+ee+"` has invalid PropType notation inside arrayOf.");var P=G[se];if(!Array.isArray(P)){var ne=J(P);return new y("Invalid "+le+" `"+ae+"` of type "+("`"+ne+"` supplied to `"+ee+"`, expected an array."))}for(var ce=0;ce<P.length;ce++){var ie=O(P,ce,ee,le,ae+"["+ce+"]",n);if(ie instanceof Error)return ie}return null}return w(F)}function I(){function O(F,G,se,ee,le){var ae=F[G];if(!l(ae)){var P=J(ae);return new y("Invalid "+ee+" `"+le+"` of type "+("`"+P+"` supplied to `"+se+"`, expected a single ReactElement."))}return null}return w(O)}function a(){function O(F,G,se,ee,le){var ae=F[G];if(!t.isValidElementType(ae)){var P=J(ae);return new y("Invalid "+ee+" `"+le+"` of type "+("`"+P+"` supplied to `"+se+"`, expected a single ReactElement type."))}return null}return w(O)}function A(O){function F(G,se,ee,le,ae){if(!(G[se]instanceof O)){var P=O.name||f,ne=re(G[se]);return new y("Invalid "+le+" `"+ae+"` of type "+("`"+ne+"` supplied to `"+ee+"`, expected ")+("instance of `"+P+"`."))}return null}return w(F)}function B(O){if(!Array.isArray(O))return process.env.NODE_ENV!=="production"&&(arguments.length>1?c("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):c("Invalid argument supplied to oneOf, expected an array.")),d;function F(G,se,ee,le,ae){for(var P=G[se],ne=0;ne<O.length;ne++)if(T(P,O[ne]))return null;var ce=JSON.stringify(O,function(he,q){var Ae=ue(q);return Ae==="symbol"?String(q):q});return new y("Invalid "+le+" `"+ae+"` of value `"+String(P)+"` "+("supplied to `"+ee+"`, expected one of "+ce+"."))}return w(F)}function $(O){function F(G,se,ee,le,ae){if(typeof O!="function")return new y("Property `"+ae+"` of component `"+ee+"` has invalid PropType notation inside objectOf.");var P=G[se],ne=J(P);if(ne!=="object")return new y("Invalid "+le+" `"+ae+"` of type "+("`"+ne+"` supplied to `"+ee+"`, expected an object."));for(var ce in P)if(i(P,ce)){var ie=O(P,ce,ee,le,ae+"."+ce,n);if(ie instanceof Error)return ie}return null}return w(F)}function Y(O){if(!Array.isArray(O))return process.env.NODE_ENV!=="production"&&c("Invalid argument supplied to oneOfType, expected an instance of array."),d;for(var F=0;F<O.length;F++){var G=O[F];if(typeof G!="function")return c("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+pe(G)+" at index "+F+"."),d}function se(ee,le,ae,P,ne){for(var ce=[],ie=0;ie<O.length;ie++){var he=O[ie],q=he(ee,le,ae,P,ne,n);if(q==null)return null;q.data&&i(q.data,"expectedType")&&ce.push(q.data.expectedType)}var Ae=ce.length>0?", expected one of type ["+ce.join(", ")+"]":"";return new y("Invalid "+P+" `"+ne+"` supplied to "+("`"+ae+"`"+Ae+"."))}return w(se)}function Q(){function O(F,G,se,ee,le){return W(F[G])?null:new y("Invalid "+ee+" `"+le+"` supplied to "+("`"+se+"`, expected a ReactNode."))}return w(O)}function te(O,F,G,se,ee){return new y((O||"React class")+": "+F+" type `"+G+"."+se+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+ee+"`.")}function x(O){function F(G,se,ee,le,ae){var P=G[se],ne=J(P);if(ne!=="object")return new y("Invalid "+le+" `"+ae+"` of type `"+ne+"` "+("supplied to `"+ee+"`, expected `object`."));for(var ce in O){var ie=O[ce];if(typeof ie!="function")return te(ee,le,ae,ce,ue(ie));var he=ie(P,ce,ee,le,ae+"."+ce,n);if(he)return he}return null}return w(F)}function N(O){function F(G,se,ee,le,ae){var P=G[se],ne=J(P);if(ne!=="object")return new y("Invalid "+le+" `"+ae+"` of type `"+ne+"` "+("supplied to `"+ee+"`, expected `object`."));var ce=o({},G[se],O);for(var ie in ce){var he=O[ie];if(i(O,ie)&&typeof he!="function")return te(ee,le,ae,ie,ue(he));if(!he)return new y("Invalid "+le+" `"+ae+"` key `"+ie+"` supplied to `"+ee+"`.\nBad object: "+JSON.stringify(G[se],null," ")+`
22
+ Valid keys: `+JSON.stringify(Object.keys(O),null," "));var q=he(P,ie,ee,le,ae+"."+ie,n);if(q)return q}return null}return w(F)}function W(O){switch(typeof O){case"number":case"string":case"undefined":return!0;case"boolean":return!O;case"object":if(Array.isArray(O))return O.every(W);if(O===null||l(O))return!0;var F=b(O);if(F){var G=F.call(O),se;if(F!==O.entries){for(;!(se=G.next()).done;)if(!W(se.value))return!1}else for(;!(se=G.next()).done;){var ee=se.value;if(ee&&!W(ee[1]))return!1}}else return!1;return!0;default:return!1}}function H(O,F){return O==="symbol"?!0:F?F["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&F instanceof Symbol:!1}function J(O){var F=typeof O;return Array.isArray(O)?"array":O instanceof RegExp?"object":H(F,O)?"symbol":F}function ue(O){if(typeof O>"u"||O===null)return""+O;var F=J(O);if(F==="object"){if(O instanceof Date)return"date";if(O instanceof RegExp)return"regexp"}return F}function pe(O){var F=ue(O);switch(F){case"array":case"object":return"an "+F;case"boolean":case"date":case"regexp":return"a "+F;default:return F}}function re(O){return!O.constructor||!O.constructor.name?f:O.constructor.name}return g.checkPropTypes=s,g.resetWarningCache=s.resetWarningCache,g.PropTypes=g,g},No}var Lo,An;function ll(){if(An)return Lo;An=1;var t=tn();function o(){}function n(){}return n.resetWarningCache=o,Lo=function(){function i(d,l,u,m,h,b){if(b!==t){var f=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 f.name="Invariant Violation",f}}i.isRequired=i;function s(){return i}var c={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 c.PropTypes=c,c},Lo}var Mn;function cl(){if(Mn)return ro.exports;if(Mn=1,process.env.NODE_ENV!=="production"){var t=Ii(),o=!0;ro.exports=al()(t.isElement,o)}else ro.exports=ll()();return ro.exports}var dl=cl();const Rr=rl(dl);var no={exports:{}},Ce={};/**
23
23
  * @license React
24
24
  * react-is.production.js
25
25
  *
@@ -27,7 +27,7 @@ Valid keys: `+JSON.stringify(Object.keys(O),null," "));var U=ke(W,ne,X,ae,Z+"."
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 yn;function za(){if(yn)return be;yn=1;var t=Symbol.for("react.transitional.element"),o=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),c=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),f=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),v=Symbol.for("react.view_transition"),w=Symbol.for("react.client.reference");function z(y){if(typeof y=="object"&&y!==null){var j=y.$$typeof;switch(j){case t:switch(y=y.type,y){case n:case a:case i:case u:case f:case v:return y;default:switch(y=y&&y.$$typeof,y){case c:case d:case m:case h:return y;case l:return y;default:return j}}case o:return j}}}return be.ContextConsumer=l,be.ContextProvider=c,be.Element=t,be.ForwardRef=d,be.Fragment=n,be.Lazy=m,be.Memo=h,be.Portal=o,be.Profiler=a,be.StrictMode=i,be.Suspense=u,be.SuspenseList=f,be.isContextConsumer=function(y){return z(y)===l},be.isContextProvider=function(y){return z(y)===c},be.isElement=function(y){return typeof y=="object"&&y!==null&&y.$$typeof===t},be.isForwardRef=function(y){return z(y)===d},be.isFragment=function(y){return z(y)===n},be.isLazy=function(y){return z(y)===m},be.isMemo=function(y){return z(y)===h},be.isPortal=function(y){return z(y)===o},be.isProfiler=function(y){return z(y)===a},be.isStrictMode=function(y){return z(y)===i},be.isSuspense=function(y){return z(y)===u},be.isSuspenseList=function(y){return z(y)===f},be.isValidElementType=function(y){return typeof y=="string"||typeof y=="function"||y===n||y===a||y===i||y===u||y===f||typeof y=="object"&&y!==null&&(y.$$typeof===m||y.$$typeof===h||y.$$typeof===c||y.$$typeof===l||y.$$typeof===d||y.$$typeof===w||y.getModuleId!==void 0)},be.typeOf=z,be}var ve={};/**
30
+ */var _n;function ul(){if(_n)return Ce;_n=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"),c=Symbol.for("react.consumer"),d=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),m=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),f=Symbol.for("react.view_transition"),g=Symbol.for("react.client.reference");function T(y){if(typeof y=="object"&&y!==null){var w=y.$$typeof;switch(w){case t:switch(y=y.type,y){case n:case s:case i:case u:case m:case f:return y;default:switch(y=y&&y.$$typeof,y){case d:case l:case b:case h:return y;case c:return y;default:return w}}case o:return w}}}return Ce.ContextConsumer=c,Ce.ContextProvider=d,Ce.Element=t,Ce.ForwardRef=l,Ce.Fragment=n,Ce.Lazy=b,Ce.Memo=h,Ce.Portal=o,Ce.Profiler=s,Ce.StrictMode=i,Ce.Suspense=u,Ce.SuspenseList=m,Ce.isContextConsumer=function(y){return T(y)===c},Ce.isContextProvider=function(y){return T(y)===d},Ce.isElement=function(y){return typeof y=="object"&&y!==null&&y.$$typeof===t},Ce.isForwardRef=function(y){return T(y)===l},Ce.isFragment=function(y){return T(y)===n},Ce.isLazy=function(y){return T(y)===b},Ce.isMemo=function(y){return T(y)===h},Ce.isPortal=function(y){return T(y)===o},Ce.isProfiler=function(y){return T(y)===s},Ce.isStrictMode=function(y){return T(y)===i},Ce.isSuspense=function(y){return T(y)===u},Ce.isSuspenseList=function(y){return T(y)===m},Ce.isValidElementType=function(y){return typeof y=="string"||typeof y=="function"||y===n||y===s||y===i||y===u||y===m||typeof y=="object"&&y!==null&&(y.$$typeof===b||y.$$typeof===h||y.$$typeof===d||y.$$typeof===c||y.$$typeof===l||y.$$typeof===g||y.getModuleId!==void 0)},Ce.typeOf=T,Ce}var we={};/**
31
31
  * @license React
32
32
  * react-is.development.js
33
33
  *
@@ -35,16 +35,16 @@ Valid keys: `+JSON.stringify(Object.keys(O),null," "));var U=ke(W,ne,X,ae,Z+"."
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 bn;function Ia(){return bn||(bn=1,process.env.NODE_ENV!=="production"&&(function(){function t(y){if(typeof y=="object"&&y!==null){var j=y.$$typeof;switch(j){case o:switch(y=y.type,y){case i:case l:case a:case f:case h:case w:return y;default:switch(y=y&&y.$$typeof,y){case d:case u:case v:case m:return y;case c:return y;default:return j}}case n:return j}}}var o=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),d=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),w=Symbol.for("react.view_transition"),z=Symbol.for("react.client.reference");ve.ContextConsumer=c,ve.ContextProvider=d,ve.Element=o,ve.ForwardRef=u,ve.Fragment=i,ve.Lazy=v,ve.Memo=m,ve.Portal=n,ve.Profiler=l,ve.StrictMode=a,ve.Suspense=f,ve.SuspenseList=h,ve.isContextConsumer=function(y){return t(y)===c},ve.isContextProvider=function(y){return t(y)===d},ve.isElement=function(y){return typeof y=="object"&&y!==null&&y.$$typeof===o},ve.isForwardRef=function(y){return t(y)===u},ve.isFragment=function(y){return t(y)===i},ve.isLazy=function(y){return t(y)===v},ve.isMemo=function(y){return t(y)===m},ve.isPortal=function(y){return t(y)===n},ve.isProfiler=function(y){return t(y)===l},ve.isStrictMode=function(y){return t(y)===a},ve.isSuspense=function(y){return t(y)===f},ve.isSuspenseList=function(y){return t(y)===h},ve.isValidElementType=function(y){return typeof y=="string"||typeof y=="function"||y===i||y===l||y===a||y===f||y===h||typeof y=="object"&&y!==null&&(y.$$typeof===v||y.$$typeof===m||y.$$typeof===d||y.$$typeof===c||y.$$typeof===u||y.$$typeof===z||y.getModuleId!==void 0)},ve.typeOf=t})()),ve}var vn;function Ea(){return vn||(vn=1,process.env.NODE_ENV==="production"?qr.exports=za():qr.exports=Ia()),qr.exports}var si=Ea();function Dt(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 ai(t){if(oo.isValidElement(t)||si.isValidElementType(t)||!Dt(t))return t;const o={};return Object.keys(t).forEach(n=>{o[n]=ai(t[n])}),o}function Ue(t,o,n={clone:!0}){const i=n.clone?{...t}:t;return Dt(t)&&Dt(o)&&Object.keys(o).forEach(a=>{oo.isValidElement(o[a])||si.isValidElementType(o[a])?i[a]=o[a]:Dt(o[a])&&Object.prototype.hasOwnProperty.call(t,a)&&Dt(t[a])?i[a]=Ue(t[a],o[a],n):n.clone?i[a]=Dt(o[a])?ai(o[a]):o[a]:i[a]=o[a]}),i}const Da=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 Ba(t){const{values:o={xs:0,sm:600,md:900,lg:1200,xl:1536},unit:n="px",step:i=5,...a}=t,l=Da(o),c=Object.keys(l);function d(v){return`@media (min-width:${typeof o[v]=="number"?o[v]:v}${n})`}function u(v){return`@media (max-width:${(typeof o[v]=="number"?o[v]:v)-i/100}${n})`}function f(v,w){const z=c.indexOf(w);return`@media (min-width:${typeof o[v]=="number"?o[v]:v}${n}) and (max-width:${(z!==-1&&typeof o[c[z]]=="number"?o[c[z]]:w)-i/100}${n})`}function h(v){return c.indexOf(v)+1<c.length?f(v,c[c.indexOf(v)+1]):d(v)}function m(v){const w=c.indexOf(v);return w===0?d(c[1]):w===c.length-1?u(c[w]):f(v,c[c.indexOf(v)+1]).replace("@media","@media not all and")}return{keys:c,values:l,up:d,down:u,between:f,only:h,not:m,unit:n,...a}}function Sn(t,o){if(!t.containerQueries)return o;const n=Object.keys(o).filter(i=>i.startsWith("@container")).sort((i,a)=>{var c,d;const l=/min-width:\s*([0-9.]+)/;return+(((c=i.match(l))==null?void 0:c[1])||0)-+(((d=a.match(l))==null?void 0:d[1])||0)});return n.length?n.reduce((i,a)=>{const l=o[a];return delete i[a],i[a]=l,i},{...o}):o}function Oa(t,o){return o==="@"||o.startsWith("@")&&(t.some(n=>o.startsWith(`@${n}`))||!!o.match(/^@\d/))}function Aa(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,a]=n,l=Number.isNaN(+i)?i||0:+i;return t.containerQueries(a).up(l)}function Ma(t){const o=(l,c)=>l.replace("@media",c?`@container ${c}`:"@container");function n(l,c){l.up=(...d)=>o(t.breakpoints.up(...d),c),l.down=(...d)=>o(t.breakpoints.down(...d),c),l.between=(...d)=>o(t.breakpoints.between(...d),c),l.only=(...d)=>o(t.breakpoints.only(...d),c),l.not=(...d)=>{const u=o(t.breakpoints.not(...d),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={},a=l=>(n(i,l),i);return n(a),{...t,containerQueries:a}}const Wa={borderRadius:4},Ot=process.env.NODE_ENV!=="production"?zr.oneOfType([zr.number,zr.string,zr.object,zr.array]):{};function Mr(t,o){return o?Ue(t,o,{clone:!1}):t}const so={xs:0,sm:600,md:900,lg:1200,xl:1536},Cn={keys:["xs","sm","md","lg","xl"],up:t=>`@media (min-width:${so[t]}px)`},Ra={containerQueries:t=>({up:o=>{let n=typeof o=="number"?o:so[o]||o;return typeof n=="number"&&(n=`${n}px`),t?`@container ${t} (min-width:${n})`:`@container (min-width:${n})`}})};function Ct(t,o,n){const i=t.theme||{};if(Array.isArray(o)){const l=i.breakpoints||Cn;return o.reduce((c,d,u)=>(c[l.up(l.keys[u])]=n(o[u]),c),{})}if(typeof o=="object"){const l=i.breakpoints||Cn;return Object.keys(o).reduce((c,d)=>{if(Oa(l.keys,d)){const u=Aa(i.containerQueries?i:Ra,d);u&&(c[u]=n(o[d],d))}else if(Object.keys(l.values||so).includes(d)){const u=l.up(d);c[u]=n(o[d],d)}else{const u=d;c[u]=o[u]}return c},{})}return n(o)}function _a(t={}){var n;return((n=t.keys)==null?void 0:n.reduce((i,a)=>{const l=t.up(a);return i[l]={},i},{}))||{}}function jn(t,o){return t.reduce((n,i)=>{const a=n[i];return(!a||Object.keys(a).length===0)&&delete n[i],n},o)}function li(t){if(typeof t!="string")throw new Error(process.env.NODE_ENV!=="production"?"MUI: `capitalize(string)` expects a string argument.":Ht(7));return t.charAt(0).toUpperCase()+t.slice(1)}function ao(t,o,n=!0){if(!o||typeof o!="string")return null;if(t&&t.vars&&n){const i=`vars.${o}`.split(".").reduce((a,l)=>a&&a[l]?a[l]:null,t);if(i!=null)return i}return o.split(".").reduce((i,a)=>i&&i[a]!=null?i[a]:null,t)}function ro(t,o,n,i=n){let a;return typeof t=="function"?a=t(n):Array.isArray(t)?a=t[n]||i:a=ao(t,n)||i,o&&(a=o(a,i,t)),a}function De(t){const{prop:o,cssProperty:n=t.prop,themeKey:i,transform:a}=t,l=c=>{if(c[o]==null)return null;const d=c[o],u=c.theme,f=ao(u,i)||{};return Ct(c,d,m=>{let v=ro(f,a,m);return m===v&&typeof m=="string"&&(v=ro(f,a,`${o}${m==="default"?"":li(m)}`,m)),n===!1?v:{[n]:v}})};return l.propTypes=process.env.NODE_ENV!=="production"?{[o]:Ot}:{},l.filterProps=[o],l}function Pa(t){const o={};return n=>(o[n]===void 0&&(o[n]=t(n)),o[n])}const $a={m:"margin",p:"padding"},Na={t:"Top",r:"Right",b:"Bottom",l:"Left",x:["Left","Right"],y:["Top","Bottom"]},wn={marginX:"mx",marginY:"my",paddingX:"px",paddingY:"py"},Fa=Pa(t=>{if(t.length>2)if(wn[t])t=wn[t];else return[t];const[o,n]=t.split(""),i=$a[o],a=Na[n]||"";return Array.isArray(a)?a.map(l=>i+l):[i+a]}),lo=["m","mt","mr","mb","ml","mx","my","margin","marginTop","marginRight","marginBottom","marginLeft","marginX","marginY","marginInline","marginInlineStart","marginInlineEnd","marginBlock","marginBlockStart","marginBlockEnd"],co=["p","pt","pr","pb","pl","px","py","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingX","paddingY","paddingInline","paddingInlineStart","paddingInlineEnd","paddingBlock","paddingBlockStart","paddingBlockEnd"],La=[...lo,...co];function _r(t,o,n,i){const a=ao(t,o,!0)??n;return typeof a=="number"||typeof a=="string"?l=>typeof l=="string"?l:(process.env.NODE_ENV!=="production"&&typeof l!="number"&&console.error(`MUI: Expected ${i} argument to be a number or a string, got ${l}.`),typeof a=="string"?a.startsWith("var(")&&l===0?0:a.startsWith("var(")&&l===1?a:`calc(${l} * ${a})`:a*l):Array.isArray(a)?l=>{if(typeof l=="string")return l;const c=Math.abs(l);process.env.NODE_ENV!=="production"&&(Number.isInteger(c)?c>a.length-1&&console.error([`MUI: The value provided (${c}) overflows.`,`The supported values are: ${JSON.stringify(a)}.`,`${c} > ${a.length-1}, you need to add the missing values.`].join(`
38
+ */var $n;function pl(){return $n||($n=1,process.env.NODE_ENV!=="production"&&(function(){function t(y){if(typeof y=="object"&&y!==null){var w=y.$$typeof;switch(w){case o:switch(y=y.type,y){case i:case c:case s:case m:case h:case g:return y;default:switch(y=y&&y.$$typeof,y){case l:case u:case f:case b:return y;case d:return y;default:return w}}case n:return w}}}var o=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),d=Symbol.for("react.consumer"),l=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),b=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),g=Symbol.for("react.view_transition"),T=Symbol.for("react.client.reference");we.ContextConsumer=d,we.ContextProvider=l,we.Element=o,we.ForwardRef=u,we.Fragment=i,we.Lazy=f,we.Memo=b,we.Portal=n,we.Profiler=c,we.StrictMode=s,we.Suspense=m,we.SuspenseList=h,we.isContextConsumer=function(y){return t(y)===d},we.isContextProvider=function(y){return t(y)===l},we.isElement=function(y){return typeof y=="object"&&y!==null&&y.$$typeof===o},we.isForwardRef=function(y){return t(y)===u},we.isFragment=function(y){return t(y)===i},we.isLazy=function(y){return t(y)===f},we.isMemo=function(y){return t(y)===b},we.isPortal=function(y){return t(y)===n},we.isProfiler=function(y){return t(y)===c},we.isStrictMode=function(y){return t(y)===s},we.isSuspense=function(y){return t(y)===m},we.isSuspenseList=function(y){return t(y)===h},we.isValidElementType=function(y){return typeof y=="string"||typeof y=="function"||y===i||y===c||y===s||y===m||y===h||typeof y=="object"&&y!==null&&(y.$$typeof===f||y.$$typeof===b||y.$$typeof===l||y.$$typeof===d||y.$$typeof===u||y.$$typeof===T||y.getModuleId!==void 0)},we.typeOf=t})()),we}var Wn;function xl(){return Wn||(Wn=1,process.env.NODE_ENV==="production"?no.exports=ul():no.exports=pl()),no.exports}var Ei=xl();function Bt(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 Bi(t){if(fo.isValidElement(t)||Ei.isValidElementType(t)||!Bt(t))return t;const o={};return Object.keys(t).forEach(n=>{o[n]=Bi(t[n])}),o}function qe(t,o,n={clone:!0}){const i=n.clone?{...t}:t;return Bt(t)&&Bt(o)&&Object.keys(o).forEach(s=>{fo.isValidElement(o[s])||Ei.isValidElementType(o[s])?i[s]=o[s]:Bt(o[s])&&Object.prototype.hasOwnProperty.call(t,s)&&Bt(t[s])?i[s]=qe(t[s],o[s],n):n.clone?i[s]=Bt(o[s])?Bi(o[s]):o[s]:i[s]=o[s]}),i}const ml=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,c=ml(o),d=Object.keys(c);function l(f){return`@media (min-width:${typeof o[f]=="number"?o[f]:f}${n})`}function u(f){return`@media (max-width:${(typeof o[f]=="number"?o[f]:f)-i/100}${n})`}function m(f,g){const T=d.indexOf(g);return`@media (min-width:${typeof o[f]=="number"?o[f]:f}${n}) and (max-width:${(T!==-1&&typeof o[d[T]]=="number"?o[d[T]]:g)-i/100}${n})`}function h(f){return d.indexOf(f)+1<d.length?m(f,d[d.indexOf(f)+1]):l(f)}function b(f){const g=d.indexOf(f);return g===0?l(d[1]):g===d.length-1?u(d[g]):m(f,d[d.indexOf(f)+1]).replace("@media","@media not all and")}return{keys:d,values:c,up:l,down:u,between:m,only:h,not:b,unit:n,...s}}function Rn(t,o){if(!t.containerQueries)return o;const n=Object.keys(o).filter(i=>i.startsWith("@container")).sort((i,s)=>{var d,l;const c=/min-width:\s*([0-9.]+)/;return+(((d=i.match(c))==null?void 0:d[1])||0)-+(((l=s.match(c))==null?void 0:l[1])||0)});return n.length?n.reduce((i,s)=>{const c=o[s];return delete i[s],i[s]=c,i},{...o}):o}function hl(t,o){return o==="@"||o.startsWith("@")&&(t.some(n=>o.startsWith(`@${n}`))||!!o.match(/^@\d/))}function gl(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,c=Number.isNaN(+i)?i||0:+i;return t.containerQueries(s).up(c)}function yl(t){const o=(c,d)=>c.replace("@media",d?`@container ${d}`:"@container");function n(c,d){c.up=(...l)=>o(t.breakpoints.up(...l),d),c.down=(...l)=>o(t.breakpoints.down(...l),d),c.between=(...l)=>o(t.breakpoints.between(...l),d),c.only=(...l)=>o(t.breakpoints.only(...l),d),c.not=(...l)=>{const u=o(t.breakpoints.not(...l),d);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=c=>(n(i,c),i);return n(s),{...t,containerQueries:s}}const bl={borderRadius:4},Ot=process.env.NODE_ENV!=="production"?Rr.oneOfType([Rr.number,Rr.string,Rr.object,Rr.array]):{};function Yr(t,o){return o?qe(t,o,{clone:!1}):t}const yo={xs:0,sm:600,md:900,lg:1200,xl:1536},Pn={keys:["xs","sm","md","lg","xl"],up:t=>`@media (min-width:${yo[t]}px)`},vl={containerQueries:t=>({up:o=>{let n=typeof o=="number"?o:yo[o]||o;return typeof n=="number"&&(n=`${n}px`),t?`@container ${t} (min-width:${n})`:`@container (min-width:${n})`}})};function kt(t,o,n){const i=t.theme||{};if(Array.isArray(o)){const c=i.breakpoints||Pn;return o.reduce((d,l,u)=>(d[c.up(c.keys[u])]=n(o[u]),d),{})}if(typeof o=="object"){const c=i.breakpoints||Pn;return Object.keys(o).reduce((d,l)=>{if(hl(c.keys,l)){const u=gl(i.containerQueries?i:vl,l);u&&(d[u]=n(o[l],l))}else if(Object.keys(c.values||yo).includes(l)){const u=c.up(l);d[u]=n(o[l],l)}else{const u=l;d[u]=o[u]}return d},{})}return n(o)}function Sl(t={}){var n;return((n=t.keys)==null?void 0:n.reduce((i,s)=>{const c=t.up(s);return i[c]={},i},{}))||{}}function Nn(t,o){return t.reduce((n,i)=>{const s=n[i];return(!s||Object.keys(s).length===0)&&delete n[i],n},o)}function Di(t){if(typeof t!="string")throw new Error(process.env.NODE_ENV!=="production"?"MUI: `capitalize(string)` expects a string argument.":Yt(7));return t.charAt(0).toUpperCase()+t.slice(1)}function bo(t,o,n=!0){if(!o||typeof o!="string")return null;if(t&&t.vars&&n){const i=`vars.${o}`.split(".").reduce((s,c)=>s&&s[c]?s[c]:null,t);if(i!=null)return i}return o.split(".").reduce((i,s)=>i&&i[s]!=null?i[s]:null,t)}function mo(t,o,n,i=n){let s;return typeof t=="function"?s=t(n):Array.isArray(t)?s=t[n]||i:s=bo(t,n)||i,o&&(s=o(s,i,t)),s}function Be(t){const{prop:o,cssProperty:n=t.prop,themeKey:i,transform:s}=t,c=d=>{if(d[o]==null)return null;const l=d[o],u=d.theme,m=bo(u,i)||{};return kt(d,l,b=>{let f=mo(m,s,b);return b===f&&typeof b=="string"&&(f=mo(m,s,`${o}${b==="default"?"":Di(b)}`,b)),n===!1?f:{[n]:f}})};return c.propTypes=process.env.NODE_ENV!=="production"?{[o]:Ot}:{},c.filterProps=[o],c}function jl(t){const o={};return n=>(o[n]===void 0&&(o[n]=t(n)),o[n])}const Cl={m:"margin",p:"padding"},wl={t:"Top",r:"Right",b:"Bottom",l:"Left",x:["Left","Right"],y:["Top","Bottom"]},Ln={marginX:"mx",marginY:"my",paddingX:"px",paddingY:"py"},kl=jl(t=>{if(t.length>2)if(Ln[t])t=Ln[t];else return[t];const[o,n]=t.split(""),i=Cl[o],s=wl[n]||"";return Array.isArray(s)?s.map(c=>i+c):[i+s]}),vo=["m","mt","mr","mb","ml","mx","my","margin","marginTop","marginRight","marginBottom","marginLeft","marginX","marginY","marginInline","marginInlineStart","marginInlineEnd","marginBlock","marginBlockStart","marginBlockEnd"],So=["p","pt","pr","pb","pl","px","py","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingX","paddingY","paddingInline","paddingInlineStart","paddingInlineEnd","paddingBlock","paddingBlockStart","paddingBlockEnd"],Tl=[...vo,...So];function qr(t,o,n,i){const s=bo(t,o,!0)??n;return typeof s=="number"||typeof s=="string"?c=>typeof c=="string"?c:(process.env.NODE_ENV!=="production"&&typeof c!="number"&&console.error(`MUI: Expected ${i} argument to be a number or a string, got ${c}.`),typeof s=="string"?s.startsWith("var(")&&c===0?0:s.startsWith("var(")&&c===1?s:`calc(${c} * ${s})`:s*c):Array.isArray(s)?c=>{if(typeof c=="string")return c;const d=Math.abs(c);process.env.NODE_ENV!=="production"&&(Number.isInteger(d)?d>s.length-1&&console.error([`MUI: The value provided (${d}) overflows.`,`The supported values are: ${JSON.stringify(s)}.`,`${d} > ${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 d=a[c];return l>=0?d:typeof d=="number"?-d:typeof d=="string"&&d.startsWith("var(")?`calc(-1 * ${d})`:`-${d}`}:typeof a=="function"?a:(process.env.NODE_ENV!=="production"&&console.error([`MUI: The \`theme.${o}\` value (${a}) is invalid.`,"It should be a number, an array or a function."].join(`
42
- `)),()=>{})}function Lo(t){return _r(t,"spacing",8,"spacing")}function Pr(t,o){return typeof o=="string"||o==null?o:t(o)}function Va(t,o){return n=>t.reduce((i,a)=>(i[a]=Pr(o,n),i),{})}function Ha(t,o,n,i){if(!o.includes(n))return null;const a=Fa(n),l=Va(a,i),c=t[n];return Ct(t,c,l)}function ci(t,o){const n=Lo(t.theme);return Object.keys(t).map(i=>Ha(t,o,i,n)).reduce(Mr,{})}function Ie(t){return ci(t,lo)}Ie.propTypes=process.env.NODE_ENV!=="production"?lo.reduce((t,o)=>(t[o]=Ot,t),{}):{};Ie.filterProps=lo;function Ee(t){return ci(t,co)}Ee.propTypes=process.env.NODE_ENV!=="production"?co.reduce((t,o)=>(t[o]=Ot,t),{}):{};Ee.filterProps=co;process.env.NODE_ENV!=="production"&&La.reduce((t,o)=>(t[o]=Ot,t),{});function di(t=8,o=Lo({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(l=>{const c=o(l);return typeof c=="number"?`${c}px`:c}).join(" "));return n.mui=!0,n}function uo(...t){const o=t.reduce((i,a)=>(a.filterProps.forEach(l=>{i[l]=a}),i),{}),n=i=>Object.keys(i).reduce((a,l)=>o[l]?Mr(a,o[l](i)):a,{});return n.propTypes=process.env.NODE_ENV!=="production"?t.reduce((i,a)=>Object.assign(i,a.propTypes),{}):{},n.filterProps=t.reduce((i,a)=>i.concat(a.filterProps),[]),n}function qe(t){return typeof t!="number"?t:`${t}px solid`}function Je(t,o){return De({prop:t,themeKey:"borders",transform:o})}const Ua=Je("border",qe),Ga=Je("borderTop",qe),Ya=Je("borderRight",qe),qa=Je("borderBottom",qe),Ja=Je("borderLeft",qe),Ka=Je("borderColor"),Xa=Je("borderTopColor"),Qa=Je("borderRightColor"),Za=Je("borderBottomColor"),el=Je("borderLeftColor"),tl=Je("outline",qe),rl=Je("outlineColor"),po=t=>{if(t.borderRadius!==void 0&&t.borderRadius!==null){const o=_r(t.theme,"shape.borderRadius",4,"borderRadius"),n=i=>({borderRadius:Pr(o,i)});return Ct(t,t.borderRadius,n)}return null};po.propTypes=process.env.NODE_ENV!=="production"?{borderRadius:Ot}:{};po.filterProps=["borderRadius"];uo(Ua,Ga,Ya,qa,Ja,Ka,Xa,Qa,Za,el,po,tl,rl);const xo=t=>{if(t.gap!==void 0&&t.gap!==null){const o=_r(t.theme,"spacing",8,"gap"),n=i=>({gap:Pr(o,i)});return Ct(t,t.gap,n)}return null};xo.propTypes=process.env.NODE_ENV!=="production"?{gap:Ot}:{};xo.filterProps=["gap"];const fo=t=>{if(t.columnGap!==void 0&&t.columnGap!==null){const o=_r(t.theme,"spacing",8,"columnGap"),n=i=>({columnGap:Pr(o,i)});return Ct(t,t.columnGap,n)}return null};fo.propTypes=process.env.NODE_ENV!=="production"?{columnGap:Ot}:{};fo.filterProps=["columnGap"];const ho=t=>{if(t.rowGap!==void 0&&t.rowGap!==null){const o=_r(t.theme,"spacing",8,"rowGap"),n=i=>({rowGap:Pr(o,i)});return Ct(t,t.rowGap,n)}return null};ho.propTypes=process.env.NODE_ENV!=="production"?{rowGap:Ot}:{};ho.filterProps=["rowGap"];const ol=De({prop:"gridColumn"}),nl=De({prop:"gridRow"}),il=De({prop:"gridAutoFlow"}),sl=De({prop:"gridAutoColumns"}),al=De({prop:"gridAutoRows"}),ll=De({prop:"gridTemplateColumns"}),cl=De({prop:"gridTemplateRows"}),dl=De({prop:"gridTemplateAreas"}),ul=De({prop:"gridArea"});uo(xo,fo,ho,ol,nl,il,sl,al,ll,cl,dl,ul);function cr(t,o){return o==="grey"?o:t}const pl=De({prop:"color",themeKey:"palette",transform:cr}),xl=De({prop:"bgcolor",cssProperty:"backgroundColor",themeKey:"palette",transform:cr}),fl=De({prop:"backgroundColor",themeKey:"palette",transform:cr});uo(pl,xl,fl);function He(t){return t<=1&&t!==0?`${t*100}%`:t}const hl=De({prop:"width",transform:He}),Vo=t=>{if(t.maxWidth!==void 0&&t.maxWidth!==null){const o=n=>{var a,l,c,d,u;const i=((c=(l=(a=t.theme)==null?void 0:a.breakpoints)==null?void 0:l.values)==null?void 0:c[n])||so[n];return i?((u=(d=t.theme)==null?void 0:d.breakpoints)==null?void 0:u.unit)!=="px"?{maxWidth:`${i}${t.theme.breakpoints.unit}`}:{maxWidth:i}:{maxWidth:He(n)}};return Ct(t,t.maxWidth,o)}return null};Vo.filterProps=["maxWidth"];const ml=De({prop:"minWidth",transform:He}),gl=De({prop:"height",transform:He}),yl=De({prop:"maxHeight",transform:He}),bl=De({prop:"minHeight",transform:He});De({prop:"size",cssProperty:"width",transform:He});De({prop:"size",cssProperty:"height",transform:He});const vl=De({prop:"boxSizing"});uo(hl,Vo,ml,gl,yl,bl,vl);const mo={border:{themeKey:"borders",transform:qe},borderTop:{themeKey:"borders",transform:qe},borderRight:{themeKey:"borders",transform:qe},borderBottom:{themeKey:"borders",transform:qe},borderLeft:{themeKey:"borders",transform:qe},borderColor:{themeKey:"palette"},borderTopColor:{themeKey:"palette"},borderRightColor:{themeKey:"palette"},borderBottomColor:{themeKey:"palette"},borderLeftColor:{themeKey:"palette"},outline:{themeKey:"borders",transform:qe},outlineColor:{themeKey:"palette"},borderRadius:{themeKey:"shape.borderRadius",style:po},color:{themeKey:"palette",transform:cr},bgcolor:{themeKey:"palette",cssProperty:"backgroundColor",transform:cr},backgroundColor:{themeKey:"palette",transform:cr},p:{style:Ee},pt:{style:Ee},pr:{style:Ee},pb:{style:Ee},pl:{style:Ee},px:{style:Ee},py:{style:Ee},padding:{style:Ee},paddingTop:{style:Ee},paddingRight:{style:Ee},paddingBottom:{style:Ee},paddingLeft:{style:Ee},paddingX:{style:Ee},paddingY:{style:Ee},paddingInline:{style:Ee},paddingInlineStart:{style:Ee},paddingInlineEnd:{style:Ee},paddingBlock:{style:Ee},paddingBlockStart:{style:Ee},paddingBlockEnd:{style:Ee},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:xo},rowGap:{style:ho},columnGap:{style:fo},gridColumn:{},gridRow:{},gridAutoFlow:{},gridAutoColumns:{},gridAutoRows:{},gridTemplateColumns:{},gridTemplateRows:{},gridTemplateAreas:{},gridArea:{},position:{},zIndex:{themeKey:"zIndex"},top:{},right:{},bottom:{},left:{},boxShadow:{themeKey:"shadows"},width:{transform:He},maxWidth:{style:Vo},minWidth:{transform:He},height:{transform:He},maxHeight:{transform:He},minHeight:{transform:He},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 Sl(...t){const o=t.reduce((i,a)=>i.concat(Object.keys(a)),[]),n=new Set(o);return t.every(i=>n.size===Object.keys(i).length)}function Cl(t,o){return typeof t=="function"?t(o):t}function jl(){function t(n,i,a,l){const c={[n]:i,theme:a},d=l[n];if(!d)return{[n]:i};const{cssProperty:u=n,themeKey:f,transform:h,style:m}=d;if(i==null)return null;if(f==="typography"&&i==="inherit")return{[n]:i};const v=ao(a,f)||{};return m?m(c):Ct(c,i,z=>{let y=ro(v,h,z);return z===y&&typeof z=="string"&&(y=ro(v,h,`${n}${z==="default"?"":li(z)}`,z)),u===!1?y:{[u]:y}})}function o(n){const{sx:i,theme:a={},nested:l}=n||{};if(!i)return null;const c=a.unstable_sxConfig??mo;function d(u){let f=u;if(typeof u=="function")f=u(a);else if(typeof u!="object")return u;if(!f)return null;const h=_a(a.breakpoints),m=Object.keys(h);let v=h;return Object.keys(f).forEach(w=>{const z=Cl(f[w],a);if(z!=null)if(typeof z=="object")if(c[w])v=Mr(v,t(w,z,a,c));else{const y=Ct({theme:a},z,j=>({[w]:j}));Sl(y,z)?v[w]=o({sx:z,theme:a,nested:!0}):v=Mr(v,y)}else v=Mr(v,t(w,z,a,c))}),!l&&a.modularCssLayers?{"@layer sx":Sn(a,jn(m,v))}:Sn(a,jn(m,v))}return Array.isArray(i)?i.map(d):d(i)}return o}const go=jl();go.filterProps=["sx"];function wl(t,o){var i;const n=this;if(n.vars){if(!((i=n.colorSchemes)!=null&&i[t])||typeof n.getColorSchemeSelector!="function")return{};let a=n.getColorSchemeSelector(t);return a==="&"?o:((a.includes("data-")||a.includes("."))&&(a=`*:where(${a.replace(/\s*&$/,"")}) &`),{[a]:o})}return n.palette.mode===t?o:{}}function ui(t={},...o){const{breakpoints:n={},palette:i={},spacing:a,shape:l={},...c}=t,d=Ba(n),u=di(a);let f=Ue({breakpoints:d,direction:"ltr",components:{},palette:{mode:"light",...i},spacing:u,shape:{...Wa,...l}},c);return f=Ma(f),f.applyStyles=wl,f=o.reduce((h,m)=>Ue(h,m),f),f.unstable_sxConfig={...mo,...c==null?void 0:c.unstable_sxConfig},f.unstable_sx=function(m){return go({sx:m,theme:this})},f}function kl(t){return Object.keys(t).length===0}function Tl(t=null){const o=oo.useContext(ns.ThemeContext);return!o||kl(o)?t:o}const zl=ui();function Il(t=zl){return Tl(t)}const kn=t=>t,El=()=>{let t=kn;return{configure(o){t=o},generate(o){return t(o)},reset(){t=kn}}},Dl=El(),Bl={active:"active",checked:"checked",completed:"completed",disabled:"disabled",error:"error",expanded:"expanded",focused:"focused",focusVisible:"focusVisible",open:"open",readOnly:"readOnly",required:"required",selected:"selected"};function Ol(t,o,n="Mui"){const i=Bl[o];return i?`${n}-${i}`:`${Dl.generate(t)}-${o}`}function Al(t,o=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(o,Math.min(t,n))}function Ho(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}].`),Al(t,o,n)}function Ml(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,a)=>a<3?parseInt(i,16):Math.round(parseInt(i,16)/255*1e3)/1e3).join(", ")})`:""}function Bt(t){if(t.type)return t;if(t.charAt(0)==="#")return Bt(Ml(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().`:Ht(9,t));let i=t.substring(o+1,t.length-1),a;if(n==="color"){if(i=i.split(" "),a=i.shift(),i.length===4&&i[3].charAt(0)==="/"&&(i[3]=i[3].slice(1)),!["srgb","display-p3","a98-rgb","prophoto-rgb","rec-2020"].includes(a))throw new Error(process.env.NODE_ENV!=="production"?`MUI: unsupported \`${a}\` color space.
44
- The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rgb, rec-2020.`:Ht(10,a))}else i=i.split(",");return i=i.map(l=>parseFloat(l)),{type:n,values:i,colorSpace:a}}const Wl=t=>{const o=Bt(t);return o.values.slice(0,3).map((n,i)=>o.type.includes("hsl")&&i!==0?`${n}%`:n).join(" ")},Or=(t,o)=>{try{return Wl(t)}catch{return o&&process.env.NODE_ENV!=="production"&&console.warn(o),t}};function yo(t){const{type:o,colorSpace:n}=t;let{values:i}=t;return o.includes("rgb")?i=i.map((a,l)=>l<3?parseInt(a,10):a):o.includes("hsl")&&(i[1]=`${i[1]}%`,i[2]=`${i[2]}%`),o.includes("color")?i=`${n} ${i.join(" ")}`:i=`${i.join(", ")}`,`${o}(${i})`}function pi(t){t=Bt(t);const{values:o}=t,n=o[0],i=o[1]/100,a=o[2]/100,l=i*Math.min(a,1-a),c=(f,h=(f+n/30)%12)=>a-l*Math.max(Math.min(h-3,9-h,1),-1);let d="rgb";const u=[Math.round(c(0)*255),Math.round(c(8)*255),Math.round(c(4)*255)];return t.type==="hsla"&&(d+="a",u.push(o[3])),yo({type:d,values:u})}function Oo(t){t=Bt(t);let o=t.type==="hsl"||t.type==="hsla"?Bt(pi(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 Tn(t,o){const n=Oo(t),i=Oo(o);return(Math.max(n,i)+.05)/(Math.min(n,i)+.05)}function R(t,o){return t=Bt(t),o=Ho(o),(t.type==="rgb"||t.type==="hsl")&&(t.type+="a"),t.type==="color"?t.values[3]=`/${o}`:t.values[3]=o,yo(t)}function Ft(t,o,n){try{return R(t,o)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),t}}function bo(t,o){if(t=Bt(t),o=Ho(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 yo(t)}function he(t,o,n){try{return bo(t,o)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),t}}function vo(t,o){if(t=Bt(t),o=Ho(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 yo(t)}function me(t,o,n){try{return vo(t,o)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),t}}function Rl(t,o=.15){return Oo(t)>.5?bo(t,o):vo(t,o)}function Jr(t,o,n){try{return Rl(t,o)}catch{return t}}function _l(t=""){function o(...i){if(!i.length)return"";const a=i[0];return typeof a=="string"&&!a.match(/(#|\(|\)|(-?(\d*\.)?\d+)(px|em|%|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc))|^(-?(\d*\.)?\d+)$|(\d+ \d+ \d+)/)?`, var(--${t?`${t}-`:""}${a}${o(...i.slice(1))})`:`, ${a}`}return(i,...a)=>`var(--${t?`${t}-`:""}${i}${o(...a)})`}const zn=(t,o,n,i=[])=>{let a=t;o.forEach((l,c)=>{c===o.length-1?Array.isArray(a)?a[Number(l)]=n:a&&typeof a=="object"&&(a[l]=n):a&&typeof a=="object"&&(a[l]||(a[l]=i.includes(l)?[]:{}),a=a[l])})},Pl=(t,o,n)=>{function i(a,l=[],c=[]){Object.entries(a).forEach(([d,u])=>{(!n||n&&!n([...l,d]))&&u!=null&&(typeof u=="object"&&Object.keys(u).length>0?i(u,[...l,d],Array.isArray(u)?[...c,d]:c):o([...l,d],u,c))})}i(t)},$l=(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 Do(t,o){const{prefix:n,shouldSkipGeneratingVar:i}=o||{},a={},l={},c={};return Pl(t,(d,u,f)=>{if((typeof u=="string"||typeof u=="number")&&(!i||!i(d,u))){const h=`--${n?`${n}-`:""}${d.join("-")}`,m=$l(d,u);Object.assign(a,{[h]:m}),zn(l,d,`var(${h})`,f),zn(c,d,`var(${h}, ${m})`,f)}},d=>d[0]==="vars"),{css:a,vars:l,varsWithDefaults:c}}function Nl(t,o={}){const{getSelector:n=b,disableCssColorScheme:i,colorSchemeSelector:a,enableContrastVars:l}=o,{colorSchemes:c={},components:d,defaultColorScheme:u="light",...f}=t,{vars:h,css:m,varsWithDefaults:v}=Do(f,o);let w=v;const z={},{[u]:y,...j}=c;if(Object.entries(j||{}).forEach(([s,I])=>{const{vars:A,css:H,varsWithDefaults:N}=Do(I,o);w=Ue(w,N),z[s]={css:H,vars:A}}),y){const{css:s,vars:I,varsWithDefaults:A}=Do(y,o);w=Ue(w,A),z[u]={css:s,vars:I}}function b(s,I){var H,N;let A=a;if(a==="class"&&(A=".%s"),a==="data"&&(A="[data-%s]"),a!=null&&a.startsWith("data-")&&!a.includes("%s")&&(A=`[${a}="%s"]`),s){if(A==="media")return t.defaultColorScheme===s?":root":{[`@media (prefers-color-scheme: ${((N=(H=c[s])==null?void 0:H.palette)==null?void 0:N.mode)||s})`]:{":root":I}};if(A)return t.defaultColorScheme===s?`:root, ${A.replace("%s",String(s))}`:A.replace("%s",String(s))}return":root"}return{vars:w,generateThemeVars:()=>{let s={...h};return Object.entries(z).forEach(([,{vars:I}])=>{s=Ue(s,I)}),s},generateStyleSheets:()=>{var K,te;const s=[],I=t.defaultColorScheme||"light";function A(se,x){Object.keys(x).length&&s.push(typeof se=="string"?{[se]:{...x}}:se)}A(n(void 0,{...m}),m);const{[I]:H,...N}=z;if(H){const{css:se}=H,x=(te=(K=c[I])==null?void 0:K.palette)==null?void 0:te.mode,V=!i&&x?{colorScheme:x,...se}:{...se};A(n(I,{...V}),V)}return Object.entries(N).forEach(([se,{css:x}])=>{var J,oe;const V=(oe=(J=c[se])==null?void 0:J.palette)==null?void 0:oe.mode,$=!i&&V?{colorScheme:V,...x}:{...x};A(n(se,{...$}),$)}),l&&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 Fl(t){return function(n){return t==="media"?(process.env.NODE_ENV!=="production"&&n!=="light"&&n!=="dark"&&console.error(`MUI: @media (prefers-color-scheme) supports only 'light' or 'dark', but receive '${n}'.`),`@media (prefers-color-scheme: ${n})`):t?t.startsWith("data-")&&!t.includes("%s")?`[${t}="${n}"] &`:t==="class"?`.${n} &`:t==="data"?`[data-${n}] &`:`${t.replace("%s",n)} &`:"&"}}const Wr={black:"#000",white:"#fff"},Ll={50:"#fafafa",100:"#f5f5f5",200:"#eeeeee",300:"#e0e0e0",400:"#bdbdbd",500:"#9e9e9e",600:"#757575",700:"#616161",800:"#424242",900:"#212121",A100:"#f5f5f5",A200:"#eeeeee",A400:"#bdbdbd",A700:"#616161"},nr={50:"#f3e5f5",200:"#ce93d8",300:"#ba68c8",400:"#ab47bc",500:"#9c27b0",700:"#7b1fa2"},ir={300:"#e57373",400:"#ef5350",500:"#f44336",700:"#d32f2f",800:"#c62828"},Ir={300:"#ffb74d",400:"#ffa726",500:"#ff9800",700:"#f57c00",900:"#e65100"},sr={50:"#e3f2fd",200:"#90caf9",400:"#42a5f5",700:"#1976d2",800:"#1565c0"},ar={300:"#4fc3f7",400:"#29b6f6",500:"#03a9f4",700:"#0288d1",900:"#01579b"},lr={300:"#81c784",400:"#66bb6a",500:"#4caf50",700:"#388e3c",800:"#2e7d32",900:"#1b5e20"};function xi(){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:Wr.white,default:Wr.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 fi=xi();function hi(){return{text:{primary:Wr.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:Wr.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 Ao=hi();function In(t,o,n,i){const a=i.light||i,l=i.dark||i*1.5;t[o]||(t.hasOwnProperty(n)?t[o]=t[n]:o==="light"?t.light=vo(t.main,a):o==="dark"&&(t.dark=bo(t.main,l)))}function En(t,o,n,i,a){const l=a.light||a,c=a.dark||a*1.5;o[n]||(o.hasOwnProperty(i)?o[n]=o[i]:n==="light"?o.light=`color-mix(in ${t}, ${o.main}, #fff ${(l*100).toFixed(0)}%)`:n==="dark"&&(o.dark=`color-mix(in ${t}, ${o.main}, #000 ${(c*100).toFixed(0)}%)`))}function Vl(t="light"){return t==="dark"?{main:sr[200],light:sr[50],dark:sr[400]}:{main:sr[700],light:sr[400],dark:sr[800]}}function Hl(t="light"){return t==="dark"?{main:nr[200],light:nr[50],dark:nr[400]}:{main:nr[500],light:nr[300],dark:nr[700]}}function Ul(t="light"){return t==="dark"?{main:ir[500],light:ir[300],dark:ir[700]}:{main:ir[700],light:ir[400],dark:ir[800]}}function Gl(t="light"){return t==="dark"?{main:ar[400],light:ar[300],dark:ar[700]}:{main:ar[700],light:ar[500],dark:ar[900]}}function Yl(t="light"){return t==="dark"?{main:lr[400],light:lr[300],dark:lr[700]}:{main:lr[800],light:lr[500],dark:lr[900]}}function ql(t="light"){return t==="dark"?{main:Ir[400],light:Ir[300],dark:Ir[700]}:{main:"#ed6c02",light:Ir[500],dark:Ir[900]}}function Jl(t){return`oklch(from ${t} var(--__l) 0 h / var(--__a))`}function Uo(t){const{mode:o="light",contrastThreshold:n=3,tonalOffset:i=.2,colorSpace:a,...l}=t,c=t.primary||Vl(o),d=t.secondary||Hl(o),u=t.error||Ul(o),f=t.info||Gl(o),h=t.success||Yl(o),m=t.warning||ql(o);function v(j){if(a)return Jl(j);const b=Tn(j,Ao.text.primary)>=n?Ao.text.primary:fi.text.primary;if(process.env.NODE_ENV!=="production"){const g=Tn(j,b);g<3&&console.error([`MUI: The contrast ratio of ${g}:1 for ${b} 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 b}const w=({color:j,name:b,mainShade:g=500,lightShade:S=300,darkShade:s=700})=>{if(j={...j},!j.main&&j[g]&&(j.main=j[g]),!j.hasOwnProperty("main"))throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${b?` (${b})`:""} provided to augmentColor(color) is invalid.
46
- The color object needs to have a \`main\` property or a \`${g}\` property.`:Ht(11,b?` (${b})`:"",g));if(typeof j.main!="string")throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${b?` (${b})`:""} provided to augmentColor(color) is invalid.
47
- \`color.main\` should be a string, but \`${JSON.stringify(j.main)}\` was provided instead.
41
+ `)));const l=s[d];return c>=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 rn(t){return qr(t,"spacing",8,"spacing")}function Jr(t,o){return typeof o=="string"||o==null?o:t(o)}function Il(t,o){return n=>t.reduce((i,s)=>(i[s]=Jr(o,n),i),{})}function zl(t,o,n,i){if(!o.includes(n))return null;const s=kl(n),c=Il(s,i),d=t[n];return kt(t,d,c)}function Oi(t,o){const n=rn(t.theme);return Object.keys(t).map(i=>zl(t,o,i,n)).reduce(Yr,{})}function Ie(t){return Oi(t,vo)}Ie.propTypes=process.env.NODE_ENV!=="production"?vo.reduce((t,o)=>(t[o]=Ot,t),{}):{};Ie.filterProps=vo;function ze(t){return Oi(t,So)}ze.propTypes=process.env.NODE_ENV!=="production"?So.reduce((t,o)=>(t[o]=Ot,t),{}):{};ze.filterProps=So;process.env.NODE_ENV!=="production"&&Tl.reduce((t,o)=>(t[o]=Ot,t),{});function Ai(t=8,o=rn({spacing:t})){if(t.mui)return t;const n=(...i)=>(process.env.NODE_ENV!=="production"&&(i.length<=4||console.error(`MUI: Too many arguments provided, expected between 0 and 4, got ${i.length}`)),(i.length===0?[1]:i).map(c=>{const d=o(c);return typeof d=="number"?`${d}px`:d}).join(" "));return n.mui=!0,n}function jo(...t){const o=t.reduce((i,s)=>(s.filterProps.forEach(c=>{i[c]=s}),i),{}),n=i=>Object.keys(i).reduce((s,c)=>o[c]?Yr(s,o[c](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 Qe(t){return typeof t!="number"?t:`${t}px solid`}function et(t,o){return Be({prop:t,themeKey:"borders",transform:o})}const El=et("border",Qe),Bl=et("borderTop",Qe),Dl=et("borderRight",Qe),Ol=et("borderBottom",Qe),Al=et("borderLeft",Qe),Ml=et("borderColor"),_l=et("borderTopColor"),$l=et("borderRightColor"),Wl=et("borderBottomColor"),Rl=et("borderLeftColor"),Pl=et("outline",Qe),Nl=et("outlineColor"),Co=t=>{if(t.borderRadius!==void 0&&t.borderRadius!==null){const o=qr(t.theme,"shape.borderRadius",4,"borderRadius"),n=i=>({borderRadius:Jr(o,i)});return kt(t,t.borderRadius,n)}return null};Co.propTypes=process.env.NODE_ENV!=="production"?{borderRadius:Ot}:{};Co.filterProps=["borderRadius"];jo(El,Bl,Dl,Ol,Al,Ml,_l,$l,Wl,Rl,Co,Pl,Nl);const wo=t=>{if(t.gap!==void 0&&t.gap!==null){const o=qr(t.theme,"spacing",8,"gap"),n=i=>({gap:Jr(o,i)});return kt(t,t.gap,n)}return null};wo.propTypes=process.env.NODE_ENV!=="production"?{gap:Ot}:{};wo.filterProps=["gap"];const ko=t=>{if(t.columnGap!==void 0&&t.columnGap!==null){const o=qr(t.theme,"spacing",8,"columnGap"),n=i=>({columnGap:Jr(o,i)});return kt(t,t.columnGap,n)}return null};ko.propTypes=process.env.NODE_ENV!=="production"?{columnGap:Ot}:{};ko.filterProps=["columnGap"];const To=t=>{if(t.rowGap!==void 0&&t.rowGap!==null){const o=qr(t.theme,"spacing",8,"rowGap"),n=i=>({rowGap:Jr(o,i)});return kt(t,t.rowGap,n)}return null};To.propTypes=process.env.NODE_ENV!=="production"?{rowGap:Ot}:{};To.filterProps=["rowGap"];const Ll=Be({prop:"gridColumn"}),Fl=Be({prop:"gridRow"}),Vl=Be({prop:"gridAutoFlow"}),Hl=Be({prop:"gridAutoColumns"}),Ul=Be({prop:"gridAutoRows"}),Yl=Be({prop:"gridTemplateColumns"}),Gl=Be({prop:"gridTemplateRows"}),ql=Be({prop:"gridTemplateAreas"}),Jl=Be({prop:"gridArea"});jo(wo,ko,To,Ll,Fl,Vl,Hl,Ul,Yl,Gl,ql,Jl);function fr(t,o){return o==="grey"?o:t}const Kl=Be({prop:"color",themeKey:"palette",transform:fr}),Xl=Be({prop:"bgcolor",cssProperty:"backgroundColor",themeKey:"palette",transform:fr}),Zl=Be({prop:"backgroundColor",themeKey:"palette",transform:fr});jo(Kl,Xl,Zl);function Ye(t){return t<=1&&t!==0?`${t*100}%`:t}const Ql=Be({prop:"width",transform:Ye}),on=t=>{if(t.maxWidth!==void 0&&t.maxWidth!==null){const o=n=>{var s,c,d,l,u;const i=((d=(c=(s=t.theme)==null?void 0:s.breakpoints)==null?void 0:c.values)==null?void 0:d[n])||yo[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:Ye(n)}};return kt(t,t.maxWidth,o)}return null};on.filterProps=["maxWidth"];const ec=Be({prop:"minWidth",transform:Ye}),tc=Be({prop:"height",transform:Ye}),rc=Be({prop:"maxHeight",transform:Ye}),oc=Be({prop:"minHeight",transform:Ye});Be({prop:"size",cssProperty:"width",transform:Ye});Be({prop:"size",cssProperty:"height",transform:Ye});const nc=Be({prop:"boxSizing"});jo(Ql,on,ec,tc,rc,oc,nc);const Io={border:{themeKey:"borders",transform:Qe},borderTop:{themeKey:"borders",transform:Qe},borderRight:{themeKey:"borders",transform:Qe},borderBottom:{themeKey:"borders",transform:Qe},borderLeft:{themeKey:"borders",transform:Qe},borderColor:{themeKey:"palette"},borderTopColor:{themeKey:"palette"},borderRightColor:{themeKey:"palette"},borderBottomColor:{themeKey:"palette"},borderLeftColor:{themeKey:"palette"},outline:{themeKey:"borders",transform:Qe},outlineColor:{themeKey:"palette"},borderRadius:{themeKey:"shape.borderRadius",style:Co},color:{themeKey:"palette",transform:fr},bgcolor:{themeKey:"palette",cssProperty:"backgroundColor",transform:fr},backgroundColor:{themeKey:"palette",transform:fr},p:{style:ze},pt:{style:ze},pr:{style:ze},pb:{style:ze},pl:{style:ze},px:{style:ze},py:{style:ze},padding:{style:ze},paddingTop:{style:ze},paddingRight:{style:ze},paddingBottom:{style:ze},paddingLeft:{style:ze},paddingX:{style:ze},paddingY:{style:ze},paddingInline:{style:ze},paddingInlineStart:{style:ze},paddingInlineEnd:{style:ze},paddingBlock:{style:ze},paddingBlockStart:{style:ze},paddingBlockEnd:{style:ze},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:wo},rowGap:{style:To},columnGap:{style:ko},gridColumn:{},gridRow:{},gridAutoFlow:{},gridAutoColumns:{},gridAutoRows:{},gridTemplateColumns:{},gridTemplateRows:{},gridTemplateAreas:{},gridArea:{},position:{},zIndex:{themeKey:"zIndex"},top:{},right:{},bottom:{},left:{},boxShadow:{themeKey:"shadows"},width:{transform:Ye},maxWidth:{style:on},minWidth:{transform:Ye},height:{transform:Ye},maxHeight:{transform:Ye},minHeight:{transform:Ye},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 ic(...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 sc(t,o){return typeof t=="function"?t(o):t}function ac(){function t(n,i,s,c){const d={[n]:i,theme:s},l=c[n];if(!l)return{[n]:i};const{cssProperty:u=n,themeKey:m,transform:h,style:b}=l;if(i==null)return null;if(m==="typography"&&i==="inherit")return{[n]:i};const f=bo(s,m)||{};return b?b(d):kt(d,i,T=>{let y=mo(f,h,T);return T===y&&typeof T=="string"&&(y=mo(f,h,`${n}${T==="default"?"":Di(T)}`,T)),u===!1?y:{[u]:y}})}function o(n){const{sx:i,theme:s={},nested:c}=n||{};if(!i)return null;const d=s.unstable_sxConfig??Io;function l(u){let m=u;if(typeof u=="function")m=u(s);else if(typeof u!="object")return u;if(!m)return null;const h=Sl(s.breakpoints),b=Object.keys(h);let f=h;return Object.keys(m).forEach(g=>{const T=sc(m[g],s);if(T!=null)if(typeof T=="object")if(d[g])f=Yr(f,t(g,T,s,d));else{const y=kt({theme:s},T,w=>({[g]:w}));ic(y,T)?f[g]=o({sx:T,theme:s,nested:!0}):f=Yr(f,y)}else f=Yr(f,t(g,T,s,d))}),!c&&s.modularCssLayers?{"@layer sx":Rn(s,Nn(b,f))}:Rn(s,Nn(b,f))}return Array.isArray(i)?i.map(l):l(i)}return o}const zo=ac();zo.filterProps=["sx"];function lc(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 Mi(t={},...o){const{breakpoints:n={},palette:i={},spacing:s,shape:c={},...d}=t,l=fl(n),u=Ai(s);let m=qe({breakpoints:l,direction:"ltr",components:{},palette:{mode:"light",...i},spacing:u,shape:{...bl,...c}},d);return m=yl(m),m.applyStyles=lc,m=o.reduce((h,b)=>qe(h,b),m),m.unstable_sxConfig={...Io,...d==null?void 0:d.unstable_sxConfig},m.unstable_sx=function(b){return zo({sx:b,theme:this})},m}function cc(t){return Object.keys(t).length===0}function dc(t=null){const o=fo.useContext(Ts.ThemeContext);return!o||cc(o)?t:o}const uc=Mi();function pc(t=uc){return dc(t)}const Fn=t=>t,xc=()=>{let t=Fn;return{configure(o){t=o},generate(o){return t(o)},reset(){t=Fn}}},mc=xc(),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 hc(t,o,n="Mui"){const i=fc[o];return i?`${n}-${i}`:`${mc.generate(t)}-${o}`}function gc(t,o=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(o,Math.min(t,n))}function nn(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}].`),gc(t,o,n)}function yc(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 Dt(t){if(t.type)return t;if(t.charAt(0)==="#")return Dt(yc(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().`:Yt(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.`:Yt(10,s))}else i=i.split(",");return i=i.map(c=>parseFloat(c)),{type:n,values:i,colorSpace:s}}const bc=t=>{const o=Dt(t);return o.values.slice(0,3).map((n,i)=>o.type.includes("hsl")&&i!==0?`${n}%`:n).join(" ")},Vr=(t,o)=>{try{return bc(t)}catch{return o&&process.env.NODE_ENV!=="production"&&console.warn(o),t}};function Eo(t){const{type:o,colorSpace:n}=t;let{values:i}=t;return o.includes("rgb")?i=i.map((s,c)=>c<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 _i(t){t=Dt(t);const{values:o}=t,n=o[0],i=o[1]/100,s=o[2]/100,c=i*Math.min(s,1-s),d=(m,h=(m+n/30)%12)=>s-c*Math.max(Math.min(h-3,9-h,1),-1);let l="rgb";const u=[Math.round(d(0)*255),Math.round(d(8)*255),Math.round(d(4)*255)];return t.type==="hsla"&&(l+="a",u.push(o[3])),Eo({type:l,values:u})}function Yo(t){t=Dt(t);let o=t.type==="hsl"||t.type==="hsla"?Dt(_i(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 Vn(t,o){const n=Yo(t),i=Yo(o);return(Math.max(n,i)+.05)/(Math.min(n,i)+.05)}function E(t,o){return t=Dt(t),o=nn(o),(t.type==="rgb"||t.type==="hsl")&&(t.type+="a"),t.type==="color"?t.values[3]=`/${o}`:t.values[3]=o,Eo(t)}function Vt(t,o,n){try{return E(t,o)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),t}}function Bo(t,o){if(t=Dt(t),o=nn(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 Eo(t)}function ye(t,o,n){try{return Bo(t,o)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),t}}function Do(t,o){if(t=Dt(t),o=nn(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 Eo(t)}function be(t,o,n){try{return Do(t,o)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),t}}function vc(t,o=.15){return Yo(t)>.5?Bo(t,o):Do(t,o)}function io(t,o,n){try{return vc(t,o)}catch{return t}}function Sc(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 Hn=(t,o,n,i=[])=>{let s=t;o.forEach((c,d)=>{d===o.length-1?Array.isArray(s)?s[Number(c)]=n:s&&typeof s=="object"&&(s[c]=n):s&&typeof s=="object"&&(s[c]||(s[c]=i.includes(c)?[]:{}),s=s[c])})},jc=(t,o,n)=>{function i(s,c=[],d=[]){Object.entries(s).forEach(([l,u])=>{(!n||n&&!n([...c,l]))&&u!=null&&(typeof u=="object"&&Object.keys(u).length>0?i(u,[...c,l],Array.isArray(u)?[...d,l]:d):o([...c,l],u,d))})}i(t)},Cc=(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 Fo(t,o){const{prefix:n,shouldSkipGeneratingVar:i}=o||{},s={},c={},d={};return jc(t,(l,u,m)=>{if((typeof u=="string"||typeof u=="number")&&(!i||!i(l,u))){const h=`--${n?`${n}-`:""}${l.join("-")}`,b=Cc(l,u);Object.assign(s,{[h]:b}),Hn(c,l,`var(${h})`,m),Hn(d,l,`var(${h}, ${b})`,m)}},l=>l[0]==="vars"),{css:s,vars:c,varsWithDefaults:d}}function wc(t,o={}){const{getSelector:n=v,disableCssColorScheme:i,colorSchemeSelector:s,enableContrastVars:c}=o,{colorSchemes:d={},components:l,defaultColorScheme:u="light",...m}=t,{vars:h,css:b,varsWithDefaults:f}=Fo(m,o);let g=f;const T={},{[u]:y,...w}=d;if(Object.entries(w||{}).forEach(([I,a])=>{const{vars:A,css:B,varsWithDefaults:$}=Fo(a,o);g=qe(g,$),T[I]={css:B,vars:A}}),y){const{css:I,vars:a,varsWithDefaults:A}=Fo(y,o);g=qe(g,A),T[u]={css:I,vars:a}}function v(I,a){var B,$;let A=s;if(s==="class"&&(A=".%s"),s==="data"&&(A="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(A=`[${s}="%s"]`),I){if(A==="media")return t.defaultColorScheme===I?":root":{[`@media (prefers-color-scheme: ${(($=(B=d[I])==null?void 0:B.palette)==null?void 0:$.mode)||I})`]:{":root":a}};if(A)return t.defaultColorScheme===I?`:root, ${A.replace("%s",String(I))}`:A.replace("%s",String(I))}return":root"}return{vars:g,generateThemeVars:()=>{let I={...h};return Object.entries(T).forEach(([,{vars:a}])=>{I=qe(I,a)}),I},generateStyleSheets:()=>{var Y,Q;const I=[],a=t.defaultColorScheme||"light";function A(te,x){Object.keys(x).length&&I.push(typeof te=="string"?{[te]:{...x}}:te)}A(n(void 0,{...b}),b);const{[a]:B,...$}=T;if(B){const{css:te}=B,x=(Q=(Y=d[a])==null?void 0:Y.palette)==null?void 0:Q.mode,N=!i&&x?{colorScheme:x,...te}:{...te};A(n(a,{...N}),N)}return Object.entries($).forEach(([te,{css:x}])=>{var H,J;const N=(J=(H=d[te])==null?void 0:H.palette)==null?void 0:J.mode,W=!i&&N?{colorScheme:N,...x}:{...x};A(n(te,{...W}),W)}),c&&I.push({":root":{"--__l-threshold":"0.7","--__l":"clamp(0, (l / var(--__l-threshold) - 1) * -infinity, 1)","--__a":"clamp(0.87, (l / var(--__l-threshold) - 1) * -infinity, 1)"}}),I}}}function kc(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 Gr={black:"#000",white:"#fff"},Tc={50:"#fafafa",100:"#f5f5f5",200:"#eeeeee",300:"#e0e0e0",400:"#bdbdbd",500:"#9e9e9e",600:"#757575",700:"#616161",800:"#424242",900:"#212121",A100:"#f5f5f5",A200:"#eeeeee",A400:"#bdbdbd",A700:"#616161"},dr={50:"#f3e5f5",200:"#ce93d8",300:"#ba68c8",400:"#ab47bc",500:"#9c27b0",700:"#7b1fa2"},ur={300:"#e57373",400:"#ef5350",500:"#f44336",700:"#d32f2f",800:"#c62828"},Pr={300:"#ffb74d",400:"#ffa726",500:"#ff9800",700:"#f57c00",900:"#e65100"},pr={50:"#e3f2fd",200:"#90caf9",400:"#42a5f5",700:"#1976d2",800:"#1565c0"},xr={300:"#4fc3f7",400:"#29b6f6",500:"#03a9f4",700:"#0288d1",900:"#01579b"},mr={300:"#81c784",400:"#66bb6a",500:"#4caf50",700:"#388e3c",800:"#2e7d32",900:"#1b5e20"};function $i(){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:Gr.white,default:Gr.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 Wi=$i();function Ri(){return{text:{primary:Gr.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:Gr.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 Go=Ri();function Un(t,o,n,i){const s=i.light||i,c=i.dark||i*1.5;t[o]||(t.hasOwnProperty(n)?t[o]=t[n]:o==="light"?t.light=Do(t.main,s):o==="dark"&&(t.dark=Bo(t.main,c)))}function Yn(t,o,n,i,s){const c=s.light||s,d=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 ${(c*100).toFixed(0)}%)`:n==="dark"&&(o.dark=`color-mix(in ${t}, ${o.main}, #000 ${(d*100).toFixed(0)}%)`))}function Ic(t="light"){return t==="dark"?{main:pr[200],light:pr[50],dark:pr[400]}:{main:pr[700],light:pr[400],dark:pr[800]}}function zc(t="light"){return t==="dark"?{main:dr[200],light:dr[50],dark:dr[400]}:{main:dr[500],light:dr[300],dark:dr[700]}}function Ec(t="light"){return t==="dark"?{main:ur[500],light:ur[300],dark:ur[700]}:{main:ur[700],light:ur[400],dark:ur[800]}}function Bc(t="light"){return t==="dark"?{main:xr[400],light:xr[300],dark:xr[700]}:{main:xr[700],light:xr[500],dark:xr[900]}}function Dc(t="light"){return t==="dark"?{main:mr[400],light:mr[300],dark:mr[700]}:{main:mr[800],light:mr[500],dark:mr[900]}}function Oc(t="light"){return t==="dark"?{main:Pr[400],light:Pr[300],dark:Pr[700]}:{main:"#ed6c02",light:Pr[500],dark:Pr[900]}}function Ac(t){return`oklch(from ${t} var(--__l) 0 h / var(--__a))`}function sn(t){const{mode:o="light",contrastThreshold:n=3,tonalOffset:i=.2,colorSpace:s,...c}=t,d=t.primary||Ic(o),l=t.secondary||zc(o),u=t.error||Ec(o),m=t.info||Bc(o),h=t.success||Dc(o),b=t.warning||Oc(o);function f(w){if(s)return Ac(w);const v=Vn(w,Go.text.primary)>=n?Go.text.primary:Wi.text.primary;if(process.env.NODE_ENV!=="production"){const j=Vn(w,v);j<3&&console.error([`MUI: The contrast ratio of ${j}:1 for ${v} on ${w}`,"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 v}const g=({color:w,name:v,mainShade:j=500,lightShade:S=300,darkShade:I=700})=>{if(w={...w},!w.main&&w[j]&&(w.main=w[j]),!w.hasOwnProperty("main"))throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${v?` (${v})`:""} provided to augmentColor(color) is invalid.
46
+ The color object needs to have a \`main\` property or a \`${j}\` property.`:Yt(11,v?` (${v})`:"",j));if(typeof w.main!="string")throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${v?` (${v})`:""} provided to augmentColor(color) is invalid.
47
+ \`color.main\` should be a string, but \`${JSON.stringify(w.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
- } });`:Ht(12,b?` (${b})`:"",JSON.stringify(j.main)));return a?(En(a,j,"light",S,i),En(a,j,"dark",s,i)):(In(j,"light",S,i),In(j,"dark",s,i)),j.contrastText||(j.contrastText=v(j.main)),j};let z;return o==="light"?z=xi():o==="dark"&&(z=hi()),process.env.NODE_ENV!=="production"&&(z||console.error(`MUI: The palette mode \`${o}\` is not supported.`)),Ue({common:{...Wr},mode:o,primary:w({color:c,name:"primary"}),secondary:w({color:d,name:"secondary",mainShade:"A400",lightShade:"A200",darkShade:"A700"}),error:w({color:u,name:"error"}),warning:w({color:m,name:"warning"}),info:w({color:f,name:"info"}),success:w({color:h,name:"success"}),grey:Ll,contrastThreshold:n,getContrastText:v,augmentColor:w,tonalOffset:i,...z},l)}function Kl(t){const o={};return Object.entries(t).forEach(i=>{const[a,l]=i;typeof l=="object"&&(o[a]=`${l.fontStyle?`${l.fontStyle} `:""}${l.fontVariant?`${l.fontVariant} `:""}${l.fontWeight?`${l.fontWeight} `:""}${l.fontStretch?`${l.fontStretch} `:""}${l.fontSize||""}${l.lineHeight?`/${l.lineHeight} `:""}${l.fontFamily||""}`)}),o}function Xl(t,o){return{toolbar:{minHeight:56,[t.up("xs")]:{"@media (orientation: landscape)":{minHeight:48}},[t.up("sm")]:{minHeight:64}},...o}}function Ql(t){return Math.round(t*1e5)/1e5}const Dn={textTransform:"uppercase"},Bn='"Roboto", "Helvetica", "Arial", sans-serif';function Zl(t,o){const{fontFamily:n=Bn,fontSize:i=14,fontWeightLight:a=300,fontWeightRegular:l=400,fontWeightMedium:c=500,fontWeightBold:d=700,htmlFontSize:u=16,allVariants:f,pxToRem:h,...m}=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 v=i/14,w=h||(j=>`${j/u*v}rem`),z=(j,b,g,S,s)=>({fontFamily:n,fontWeight:j,fontSize:w(b),lineHeight:g,...n===Bn?{letterSpacing:`${Ql(S/b)}em`}:{},...s,...f}),y={h1:z(a,96,1.167,-1.5),h2:z(a,60,1.2,-.5),h3:z(l,48,1.167,0),h4:z(l,34,1.235,.25),h5:z(l,24,1.334,0),h6:z(c,20,1.6,.15),subtitle1:z(l,16,1.75,.15),subtitle2:z(c,14,1.57,.1),body1:z(l,16,1.5,.15),body2:z(l,14,1.43,.15),button:z(c,14,1.75,.4,Dn),caption:z(l,12,1.66,.4),overline:z(l,12,2.66,1,Dn),inherit:{fontFamily:"inherit",fontWeight:"inherit",fontSize:"inherit",lineHeight:"inherit",letterSpacing:"inherit"}};return Ue({htmlFontSize:u,pxToRem:w,fontFamily:n,fontSize:i,fontWeightLight:a,fontWeightRegular:l,fontWeightMedium:c,fontWeightBold:d,...y},m,{clone:!1})}const ec=.2,tc=.14,rc=.12;function we(...t){return[`${t[0]}px ${t[1]}px ${t[2]}px ${t[3]}px rgba(0,0,0,${ec})`,`${t[4]}px ${t[5]}px ${t[6]}px ${t[7]}px rgba(0,0,0,${tc})`,`${t[8]}px ${t[9]}px ${t[10]}px ${t[11]}px rgba(0,0,0,${rc})`].join(",")}const oc=["none",we(0,2,1,-1,0,1,1,0,0,1,3,0),we(0,3,1,-2,0,2,2,0,0,1,5,0),we(0,3,3,-2,0,3,4,0,0,1,8,0),we(0,2,4,-1,0,4,5,0,0,1,10,0),we(0,3,5,-1,0,5,8,0,0,1,14,0),we(0,3,5,-1,0,6,10,0,0,1,18,0),we(0,4,5,-2,0,7,10,1,0,2,16,1),we(0,5,5,-3,0,8,10,1,0,3,14,2),we(0,5,6,-3,0,9,12,1,0,3,16,2),we(0,6,6,-3,0,10,14,1,0,4,18,3),we(0,6,7,-4,0,11,15,1,0,4,20,3),we(0,7,8,-4,0,12,17,2,0,5,22,4),we(0,7,8,-4,0,13,19,2,0,5,24,4),we(0,7,9,-4,0,14,21,2,0,5,26,4),we(0,8,9,-5,0,15,22,2,0,6,28,5),we(0,8,10,-5,0,16,24,2,0,6,30,5),we(0,8,11,-5,0,17,26,2,0,6,32,5),we(0,9,11,-5,0,18,28,2,0,7,34,6),we(0,9,12,-6,0,19,29,2,0,7,36,6),we(0,10,13,-6,0,20,31,3,0,8,38,7),we(0,10,13,-6,0,21,33,3,0,8,40,7),we(0,10,14,-6,0,22,35,3,0,8,42,7),we(0,11,14,-7,0,23,36,3,0,9,44,8),we(0,11,15,-7,0,24,38,3,0,9,46,8)],nc={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)"},ic={shortest:150,shorter:200,short:250,standard:300,complex:375,enteringScreen:225,leavingScreen:195};function On(t){return`${Math.round(t)}ms`}function sc(t){if(!t)return 0;const o=t/36;return Math.min(Math.round((4+15*o**.25+o/5)*10),3e3)}function ac(t){const o={...nc,...t.easing},n={...ic,...t.duration};return{getAutoHeightDuration:sc,create:(a=["all"],l={})=>{const{duration:c=n.standard,easing:d=o.easeInOut,delay:u=0,...f}=l;if(process.env.NODE_ENV!=="production"){const h=v=>typeof v=="string",m=v=>!Number.isNaN(parseFloat(v));!h(a)&&!Array.isArray(a)&&console.error('MUI: Argument "props" must be a string or Array.'),!m(c)&&!h(c)&&console.error(`MUI: Argument "duration" must be a number or a string but found ${c}.`),h(d)||console.error('MUI: Argument "easing" must be a string.'),!m(u)&&!h(u)&&console.error('MUI: Argument "delay" must be a number or a string.'),typeof l!="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(a)?a:[a]).map(h=>`${h} ${typeof c=="string"?c:On(c)} ${d} ${typeof u=="string"?u:On(u)}`).join(",")},...t,easing:o,duration:n}}const lc={mobileStepper:1e3,fab:1050,speedDial:1050,appBar:1100,drawer:1200,modal:1300,snackbar:1400,tooltip:1500};function cc(t){return Dt(t)||typeof t>"u"||typeof t=="string"||typeof t=="boolean"||typeof t=="number"||Array.isArray(t)}function mi(t={}){const o={...t};function n(i){const a=Object.entries(i);for(let l=0;l<a.length;l++){const[c,d]=a[l];!cc(d)||c.startsWith("unstable_")?delete i[c]:Dt(d)&&(i[c]={...d},n(i[c]))}}return n(o),`import { unstable_createBreakpoints as createBreakpoints, createTransitions } from '@mui/material/styles';
59
+ } });`:Yt(12,v?` (${v})`:"",JSON.stringify(w.main)));return s?(Yn(s,w,"light",S,i),Yn(s,w,"dark",I,i)):(Un(w,"light",S,i),Un(w,"dark",I,i)),w.contrastText||(w.contrastText=f(w.main)),w};let T;return o==="light"?T=$i():o==="dark"&&(T=Ri()),process.env.NODE_ENV!=="production"&&(T||console.error(`MUI: The palette mode \`${o}\` is not supported.`)),qe({common:{...Gr},mode:o,primary:g({color:d,name:"primary"}),secondary:g({color:l,name:"secondary",mainShade:"A400",lightShade:"A200",darkShade:"A700"}),error:g({color:u,name:"error"}),warning:g({color:b,name:"warning"}),info:g({color:m,name:"info"}),success:g({color:h,name:"success"}),grey:Tc,contrastThreshold:n,getContrastText:f,augmentColor:g,tonalOffset:i,...T},c)}function Mc(t){const o={};return Object.entries(t).forEach(i=>{const[s,c]=i;typeof c=="object"&&(o[s]=`${c.fontStyle?`${c.fontStyle} `:""}${c.fontVariant?`${c.fontVariant} `:""}${c.fontWeight?`${c.fontWeight} `:""}${c.fontStretch?`${c.fontStretch} `:""}${c.fontSize||""}${c.lineHeight?`/${c.lineHeight} `:""}${c.fontFamily||""}`)}),o}function _c(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 Gn={textTransform:"uppercase"},qn='"Roboto", "Helvetica", "Arial", sans-serif';function Wc(t,o){const{fontFamily:n=qn,fontSize:i=14,fontWeightLight:s=300,fontWeightRegular:c=400,fontWeightMedium:d=500,fontWeightBold:l=700,htmlFontSize:u=16,allVariants:m,pxToRem:h,...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 f=i/14,g=h||(w=>`${w/u*f}rem`),T=(w,v,j,S,I)=>({fontFamily:n,fontWeight:w,fontSize:g(v),lineHeight:j,...n===qn?{letterSpacing:`${$c(S/v)}em`}:{},...I,...m}),y={h1:T(s,96,1.167,-1.5),h2:T(s,60,1.2,-.5),h3:T(c,48,1.167,0),h4:T(c,34,1.235,.25),h5:T(c,24,1.334,0),h6:T(d,20,1.6,.15),subtitle1:T(c,16,1.75,.15),subtitle2:T(d,14,1.57,.1),body1:T(c,16,1.5,.15),body2:T(c,14,1.43,.15),button:T(d,14,1.75,.4,Gn),caption:T(c,12,1.66,.4),overline:T(c,12,2.66,1,Gn),inherit:{fontFamily:"inherit",fontWeight:"inherit",fontSize:"inherit",lineHeight:"inherit",letterSpacing:"inherit"}};return qe({htmlFontSize:u,pxToRem:g,fontFamily:n,fontSize:i,fontWeightLight:s,fontWeightRegular:c,fontWeightMedium:d,fontWeightBold:l,...y},b,{clone:!1})}const Rc=.2,Pc=.14,Nc=.12;function Te(...t){return[`${t[0]}px ${t[1]}px ${t[2]}px ${t[3]}px rgba(0,0,0,${Rc})`,`${t[4]}px ${t[5]}px ${t[6]}px ${t[7]}px rgba(0,0,0,${Pc})`,`${t[8]}px ${t[9]}px ${t[10]}px ${t[11]}px rgba(0,0,0,${Nc})`].join(",")}const Lc=["none",Te(0,2,1,-1,0,1,1,0,0,1,3,0),Te(0,3,1,-2,0,2,2,0,0,1,5,0),Te(0,3,3,-2,0,3,4,0,0,1,8,0),Te(0,2,4,-1,0,4,5,0,0,1,10,0),Te(0,3,5,-1,0,5,8,0,0,1,14,0),Te(0,3,5,-1,0,6,10,0,0,1,18,0),Te(0,4,5,-2,0,7,10,1,0,2,16,1),Te(0,5,5,-3,0,8,10,1,0,3,14,2),Te(0,5,6,-3,0,9,12,1,0,3,16,2),Te(0,6,6,-3,0,10,14,1,0,4,18,3),Te(0,6,7,-4,0,11,15,1,0,4,20,3),Te(0,7,8,-4,0,12,17,2,0,5,22,4),Te(0,7,8,-4,0,13,19,2,0,5,24,4),Te(0,7,9,-4,0,14,21,2,0,5,26,4),Te(0,8,9,-5,0,15,22,2,0,6,28,5),Te(0,8,10,-5,0,16,24,2,0,6,30,5),Te(0,8,11,-5,0,17,26,2,0,6,32,5),Te(0,9,11,-5,0,18,28,2,0,7,34,6),Te(0,9,12,-6,0,19,29,2,0,7,36,6),Te(0,10,13,-6,0,20,31,3,0,8,38,7),Te(0,10,13,-6,0,21,33,3,0,8,40,7),Te(0,10,14,-6,0,22,35,3,0,8,42,7),Te(0,11,14,-7,0,23,36,3,0,9,44,8),Te(0,11,15,-7,0,24,38,3,0,9,46,8)],Fc={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)"},Vc={shortest:150,shorter:200,short:250,standard:300,complex:375,enteringScreen:225,leavingScreen:195};function Jn(t){return`${Math.round(t)}ms`}function Hc(t){if(!t)return 0;const o=t/36;return Math.min(Math.round((4+15*o**.25+o/5)*10),3e3)}function Uc(t){const o={...Fc,...t.easing},n={...Vc,...t.duration};return{getAutoHeightDuration:Hc,create:(s=["all"],c={})=>{const{duration:d=n.standard,easing:l=o.easeInOut,delay:u=0,...m}=c;if(process.env.NODE_ENV!=="production"){const h=f=>typeof f=="string",b=f=>!Number.isNaN(parseFloat(f));!h(s)&&!Array.isArray(s)&&console.error('MUI: Argument "props" must be a string or Array.'),!b(d)&&!h(d)&&console.error(`MUI: Argument "duration" must be a number or a string but found ${d}.`),h(l)||console.error('MUI: Argument "easing" must be a string.'),!b(u)&&!h(u)&&console.error('MUI: Argument "delay" must be a number or a string.'),typeof c!="object"&&console.error(["MUI: Secong argument of transition.create must be an object.","Arguments should be either `create('prop1', options)` or `create(['prop1', 'prop2'], options)`"].join(`
60
+ `)),Object.keys(m).length!==0&&console.error(`MUI: Unrecognized argument(s) [${Object.keys(m).join(",")}].`)}return(Array.isArray(s)?s:[s]).map(h=>`${h} ${typeof d=="string"?d:Jn(d)} ${l} ${typeof u=="string"?u:Jn(u)}`).join(",")},...t,easing:o,duration:n}}const Yc={mobileStepper:1e3,fab:1050,speedDial:1050,appBar:1100,drawer:1200,modal:1300,snackbar:1400,tooltip:1500};function Gc(t){return Bt(t)||typeof t>"u"||typeof t=="string"||typeof t=="boolean"||typeof t=="number"||Array.isArray(t)}function Pi(t={}){const o={...t};function n(i){const s=Object.entries(i);for(let c=0;c<s.length;c++){const[d,l]=s[c];!Gc(l)||d.startsWith("unstable_")?delete i[d]:Bt(l)&&(i[d]={...l},n(i[d]))}}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 An(t){return typeof t=="number"?`${(t*100).toFixed(0)}%`:`calc((${t}) * 100%)`}const dc=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 uc(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})`:R(o,dc(n))},lighten(o,n){const i=this||t;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${o}, #fff ${An(n)})`:vo(o,n)},darken(o,n){const i=this||t;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${o}, #000 ${An(n)})`:bo(o,n)}})}function Mo(t={},...o){const{breakpoints:n,mixins:i={},spacing:a,palette:l={},transitions:c={},typography:d={},shape:u,colorSpace:f,...h}=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.":Ht(20));const m=Uo({...l,colorSpace:f}),v=ui(t);let w=Ue(v,{mixins:Xl(v.breakpoints,i),palette:m,shadows:oc.slice(),typography:Zl(m,d),transitions:ac(c),zIndex:{...lc}});if(w=Ue(w,h),w=o.reduce((z,y)=>Ue(z,y),w),process.env.NODE_ENV!=="production"){const z=["active","checked","completed","disabled","error","expanded","focused","focusVisible","required","selected"],y=(j,b)=>{let g;for(g in j){const S=j[g];if(z.includes(g)&&Object.keys(S).length>0){if(process.env.NODE_ENV!=="production"){const s=Ol("",g);console.error([`MUI: The \`${b}\` component increases the CSS specificity of the \`${g}\` 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}`]:S}},null,2),"","https://mui.com/r/state-classes-guide"].join(`
68
- `))}j[g]={}}}};Object.keys(w.components).forEach(j=>{const b=w.components[j].styleOverrides;b&&j.startsWith("Mui")&&y(b,j)})}return w.unstable_sxConfig={...mo,...h==null?void 0:h.unstable_sxConfig},w.unstable_sx=function(y){return go({sx:y,theme:this})},w.toRuntimeSource=mi,uc(w),w}function pc(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 xc=[...Array(25)].map((t,o)=>{if(o===0)return"none";const n=pc(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 yi(t){return t==="dark"?xc:[]}function fc(t){const{palette:o={mode:"light"},opacity:n,overlays:i,colorSpace:a,...l}=t,c=Uo({...o,colorSpace:a});return{palette:c,opacity:{...gi(c.mode),...n},overlays:i||yi(c.mode),...l}}function hc(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 mc=t=>[...[...Array(25)].map((o,n)=>`--${t?`${t}-`:""}overlays-${n}`),`--${t?`${t}-`:""}palette-AppBar-darkBg`,`--${t?`${t}-`:""}palette-AppBar-darkColor`],gc=t=>(o,n)=>{const i=t.rootSelector||":root",a=t.colorSchemeSelector;let l=a;if(a==="class"&&(l=".%s"),a==="data"&&(l="[data-%s]"),a!=null&&a.startsWith("data-")&&!a.includes("%s")&&(l=`[${a}="%s"]`),t.defaultColorScheme===o){if(o==="dark"){const c={};return mc(t.cssVarPrefix).forEach(d=>{c[d]=n[d],delete n[d]}),l==="media"?{[i]:n,"@media (prefers-color-scheme: dark)":{[i]:c}}:l?{[l.replace("%s",o)]:c,[`${i}, ${l.replace("%s",o)}`]:n}:{[i]:{...n,...c}}}if(l&&l!=="media")return`${i}, ${l.replace("%s",String(o))}`}else if(o){if(l==="media")return{[`@media (prefers-color-scheme: ${String(o)})`]:{[i]:n}};if(l)return l.replace("%s",String(o))}return i};function yc(t,o){o.forEach(n=>{t[n]||(t[n]={})})}function M(t,o,n){!t[o]&&n&&(t[o]=n)}function Ar(t){return typeof t!="string"||!t.startsWith("hsl")?t:pi(t)}function bt(t,o){`${o}Channel`in t||(t[`${o}Channel`]=Or(Ar(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 bc(t){return typeof t=="number"?`${t}px`:typeof t=="string"||typeof t=="function"||Array.isArray(t)?t:"8px"}const lt=t=>{try{return t()}catch{}},vc=(t="mui")=>_l(t);function Bo(t,o,n,i,a){if(!n)return;n=n===!0?{}:n;const l=a==="dark"?"dark":"light";if(!i){o[a]=fc({...n,palette:{mode:l,...n==null?void 0:n.palette},colorSpace:t});return}const{palette:c,...d}=Mo({...i,palette:{mode:l,...n==null?void 0:n.palette},colorSpace:t});return o[a]={...n,palette:c,opacity:{...gi(l),...n==null?void 0:n.opacity},overlays:(n==null?void 0:n.overlays)||yi(l)},d}function Sc(t={},...o){const{colorSchemes:n={light:!0},defaultColorScheme:i,disableCssColorScheme:a=!1,cssVarPrefix:l="mui",nativeColor:c=!1,shouldSkipGeneratingVar:d=hc,colorSchemeSelector:u=n.light&&n.dark?"media":void 0,rootSelector:f=":root",...h}=t,m=Object.keys(n)[0],v=i||(n.light&&m!=="light"?"light":m),w=vc(l),{[v]:z,light:y,dark:j,...b}=n,g={...b};let S=z;if((v==="dark"&&!("dark"in n)||v==="light"&&!("light"in n))&&(S=!0),!S)throw new Error(process.env.NODE_ENV!=="production"?`MUI: The \`colorSchemes.${v}\` option is either missing or invalid.`:Ht(21,v));let s;c&&(s="oklch");const I=Bo(s,g,S,h,v);y&&!g.light&&Bo(s,g,y,void 0,"light"),j&&!g.dark&&Bo(s,g,j,void 0,"dark");let A={defaultColorScheme:v,...I,cssVarPrefix:l,colorSchemeSelector:u,rootSelector:f,getCssVar:w,colorSchemes:g,font:{...Kl(I.typography),...I.font},spacing:bc(h.spacing)};Object.keys(A.colorSchemes).forEach(se=>{const x=A.colorSchemes[se].palette,V=J=>{const oe=J.split("-"),ue=oe[1],pe=oe[2];return w(J,x[ue][pe])};x.mode==="light"&&(M(x.common,"background","#fff"),M(x.common,"onBackground","#000")),x.mode==="dark"&&(M(x.common,"background","#000"),M(x.common,"onBackground","#fff"));function $(J,oe,ue){if(s){let pe;return J===Ft&&(pe=`transparent ${((1-ue)*100).toFixed(0)}%`),J===he&&(pe=`#000 ${(ue*100).toFixed(0)}%`),J===me&&(pe=`#fff ${(ue*100).toFixed(0)}%`),`color-mix(in ${s}, ${oe}, ${pe})`}return J(oe,ue)}if(yc(x,["Alert","AppBar","Avatar","Button","Chip","FilledInput","LinearProgress","Skeleton","Slider","SnackbarContent","SpeedDialAction","StepConnector","StepContent","Switch","TableCell","Tooltip"]),x.mode==="light"){M(x.Alert,"errorColor",$(he,x.error.light,.6)),M(x.Alert,"infoColor",$(he,x.info.light,.6)),M(x.Alert,"successColor",$(he,x.success.light,.6)),M(x.Alert,"warningColor",$(he,x.warning.light,.6)),M(x.Alert,"errorFilledBg",V("palette-error-main")),M(x.Alert,"infoFilledBg",V("palette-info-main")),M(x.Alert,"successFilledBg",V("palette-success-main")),M(x.Alert,"warningFilledBg",V("palette-warning-main")),M(x.Alert,"errorFilledColor",lt(()=>x.getContrastText(x.error.main))),M(x.Alert,"infoFilledColor",lt(()=>x.getContrastText(x.info.main))),M(x.Alert,"successFilledColor",lt(()=>x.getContrastText(x.success.main))),M(x.Alert,"warningFilledColor",lt(()=>x.getContrastText(x.warning.main))),M(x.Alert,"errorStandardBg",$(me,x.error.light,.9)),M(x.Alert,"infoStandardBg",$(me,x.info.light,.9)),M(x.Alert,"successStandardBg",$(me,x.success.light,.9)),M(x.Alert,"warningStandardBg",$(me,x.warning.light,.9)),M(x.Alert,"errorIconColor",V("palette-error-main")),M(x.Alert,"infoIconColor",V("palette-info-main")),M(x.Alert,"successIconColor",V("palette-success-main")),M(x.Alert,"warningIconColor",V("palette-warning-main")),M(x.AppBar,"defaultBg",V("palette-grey-100")),M(x.Avatar,"defaultBg",V("palette-grey-400")),M(x.Button,"inheritContainedBg",V("palette-grey-300")),M(x.Button,"inheritContainedHoverBg",V("palette-grey-A100")),M(x.Chip,"defaultBorder",V("palette-grey-400")),M(x.Chip,"defaultAvatarColor",V("palette-grey-700")),M(x.Chip,"defaultIconColor",V("palette-grey-700")),M(x.FilledInput,"bg","rgba(0, 0, 0, 0.06)"),M(x.FilledInput,"hoverBg","rgba(0, 0, 0, 0.09)"),M(x.FilledInput,"disabledBg","rgba(0, 0, 0, 0.12)"),M(x.LinearProgress,"primaryBg",$(me,x.primary.main,.62)),M(x.LinearProgress,"secondaryBg",$(me,x.secondary.main,.62)),M(x.LinearProgress,"errorBg",$(me,x.error.main,.62)),M(x.LinearProgress,"infoBg",$(me,x.info.main,.62)),M(x.LinearProgress,"successBg",$(me,x.success.main,.62)),M(x.LinearProgress,"warningBg",$(me,x.warning.main,.62)),M(x.Skeleton,"bg",s?$(Ft,x.text.primary,.11):`rgba(${V("palette-text-primaryChannel")} / 0.11)`),M(x.Slider,"primaryTrack",$(me,x.primary.main,.62)),M(x.Slider,"secondaryTrack",$(me,x.secondary.main,.62)),M(x.Slider,"errorTrack",$(me,x.error.main,.62)),M(x.Slider,"infoTrack",$(me,x.info.main,.62)),M(x.Slider,"successTrack",$(me,x.success.main,.62)),M(x.Slider,"warningTrack",$(me,x.warning.main,.62));const J=s?$(he,x.background.default,.6825):Jr(x.background.default,.8);M(x.SnackbarContent,"bg",J),M(x.SnackbarContent,"color",lt(()=>s?Ao.text.primary:x.getContrastText(J))),M(x.SpeedDialAction,"fabHoverBg",Jr(x.background.paper,.15)),M(x.StepConnector,"border",V("palette-grey-400")),M(x.StepContent,"border",V("palette-grey-400")),M(x.Switch,"defaultColor",V("palette-common-white")),M(x.Switch,"defaultDisabledColor",V("palette-grey-100")),M(x.Switch,"primaryDisabledColor",$(me,x.primary.main,.62)),M(x.Switch,"secondaryDisabledColor",$(me,x.secondary.main,.62)),M(x.Switch,"errorDisabledColor",$(me,x.error.main,.62)),M(x.Switch,"infoDisabledColor",$(me,x.info.main,.62)),M(x.Switch,"successDisabledColor",$(me,x.success.main,.62)),M(x.Switch,"warningDisabledColor",$(me,x.warning.main,.62)),M(x.TableCell,"border",$(me,$(Ft,x.divider,1),.88)),M(x.Tooltip,"bg",$(Ft,x.grey[700],.92))}if(x.mode==="dark"){M(x.Alert,"errorColor",$(me,x.error.light,.6)),M(x.Alert,"infoColor",$(me,x.info.light,.6)),M(x.Alert,"successColor",$(me,x.success.light,.6)),M(x.Alert,"warningColor",$(me,x.warning.light,.6)),M(x.Alert,"errorFilledBg",V("palette-error-dark")),M(x.Alert,"infoFilledBg",V("palette-info-dark")),M(x.Alert,"successFilledBg",V("palette-success-dark")),M(x.Alert,"warningFilledBg",V("palette-warning-dark")),M(x.Alert,"errorFilledColor",lt(()=>x.getContrastText(x.error.dark))),M(x.Alert,"infoFilledColor",lt(()=>x.getContrastText(x.info.dark))),M(x.Alert,"successFilledColor",lt(()=>x.getContrastText(x.success.dark))),M(x.Alert,"warningFilledColor",lt(()=>x.getContrastText(x.warning.dark))),M(x.Alert,"errorStandardBg",$(he,x.error.light,.9)),M(x.Alert,"infoStandardBg",$(he,x.info.light,.9)),M(x.Alert,"successStandardBg",$(he,x.success.light,.9)),M(x.Alert,"warningStandardBg",$(he,x.warning.light,.9)),M(x.Alert,"errorIconColor",V("palette-error-main")),M(x.Alert,"infoIconColor",V("palette-info-main")),M(x.Alert,"successIconColor",V("palette-success-main")),M(x.Alert,"warningIconColor",V("palette-warning-main")),M(x.AppBar,"defaultBg",V("palette-grey-900")),M(x.AppBar,"darkBg",V("palette-background-paper")),M(x.AppBar,"darkColor",V("palette-text-primary")),M(x.Avatar,"defaultBg",V("palette-grey-600")),M(x.Button,"inheritContainedBg",V("palette-grey-800")),M(x.Button,"inheritContainedHoverBg",V("palette-grey-700")),M(x.Chip,"defaultBorder",V("palette-grey-700")),M(x.Chip,"defaultAvatarColor",V("palette-grey-300")),M(x.Chip,"defaultIconColor",V("palette-grey-300")),M(x.FilledInput,"bg","rgba(255, 255, 255, 0.09)"),M(x.FilledInput,"hoverBg","rgba(255, 255, 255, 0.13)"),M(x.FilledInput,"disabledBg","rgba(255, 255, 255, 0.12)"),M(x.LinearProgress,"primaryBg",$(he,x.primary.main,.5)),M(x.LinearProgress,"secondaryBg",$(he,x.secondary.main,.5)),M(x.LinearProgress,"errorBg",$(he,x.error.main,.5)),M(x.LinearProgress,"infoBg",$(he,x.info.main,.5)),M(x.LinearProgress,"successBg",$(he,x.success.main,.5)),M(x.LinearProgress,"warningBg",$(he,x.warning.main,.5)),M(x.Skeleton,"bg",s?$(Ft,x.text.primary,.13):`rgba(${V("palette-text-primaryChannel")} / 0.13)`),M(x.Slider,"primaryTrack",$(he,x.primary.main,.5)),M(x.Slider,"secondaryTrack",$(he,x.secondary.main,.5)),M(x.Slider,"errorTrack",$(he,x.error.main,.5)),M(x.Slider,"infoTrack",$(he,x.info.main,.5)),M(x.Slider,"successTrack",$(he,x.success.main,.5)),M(x.Slider,"warningTrack",$(he,x.warning.main,.5));const J=s?$(me,x.background.default,.985):Jr(x.background.default,.98);M(x.SnackbarContent,"bg",J),M(x.SnackbarContent,"color",lt(()=>s?fi.text.primary:x.getContrastText(J))),M(x.SpeedDialAction,"fabHoverBg",Jr(x.background.paper,.15)),M(x.StepConnector,"border",V("palette-grey-600")),M(x.StepContent,"border",V("palette-grey-600")),M(x.Switch,"defaultColor",V("palette-grey-300")),M(x.Switch,"defaultDisabledColor",V("palette-grey-600")),M(x.Switch,"primaryDisabledColor",$(he,x.primary.main,.55)),M(x.Switch,"secondaryDisabledColor",$(he,x.secondary.main,.55)),M(x.Switch,"errorDisabledColor",$(he,x.error.main,.55)),M(x.Switch,"infoDisabledColor",$(he,x.info.main,.55)),M(x.Switch,"successDisabledColor",$(he,x.success.main,.55)),M(x.Switch,"warningDisabledColor",$(he,x.warning.main,.55)),M(x.TableCell,"border",$(he,$(Ft,x.divider,1),.68)),M(x.Tooltip,"bg",$(Ft,x.grey[700],.92))}bt(x.background,"default"),bt(x.background,"paper"),bt(x.common,"background"),bt(x.common,"onBackground"),bt(x,"divider"),Object.keys(x).forEach(J=>{const oe=x[J];J!=="tonalOffset"&&oe&&typeof oe=="object"&&(oe.main&&M(x[J],"mainChannel",Or(Ar(oe.main))),oe.light&&M(x[J],"lightChannel",Or(Ar(oe.light))),oe.dark&&M(x[J],"darkChannel",Or(Ar(oe.dark))),oe.contrastText&&M(x[J],"contrastTextChannel",Or(Ar(oe.contrastText))),J==="text"&&(bt(x[J],"primary"),bt(x[J],"secondary")),J==="action"&&(oe.active&&bt(x[J],"active"),oe.selected&&bt(x[J],"selected")))})}),A=o.reduce((se,x)=>Ue(se,x),A);const H={prefix:l,disableCssColorScheme:a,shouldSkipGeneratingVar:d,getSelector:gc(A),enableContrastVars:c},{vars:N,generateThemeVars:K,generateStyleSheets:te}=Nl(A,H);return A.vars=N,Object.entries(A.colorSchemes[A.defaultColorScheme]).forEach(([se,x])=>{A[se]=x}),A.generateThemeVars=K,A.generateStyleSheets=te,A.generateSpacing=function(){return di(h.spacing,Lo(this))},A.getColorSchemeSelector=Fl(u),A.spacing=A.generateSpacing(),A.shouldSkipGeneratingVar=d,A.unstable_sxConfig={...mo,...h==null?void 0:h.unstable_sxConfig},A.unstable_sx=function(x){return go({sx:x,theme:this})},A.toRuntimeSource=mi,A}function Mn(t,o,n){t.colorSchemes&&n&&(t.colorSchemes[o]={...n!==!0&&n,palette:Uo({...n===!0?{}:n.palette,mode:o})})}function Cc(t={},...o){const{palette:n,cssVariables:i=!1,colorSchemes:a=n?void 0:{light:!0},defaultColorScheme:l=n==null?void 0:n.mode,...c}=t,d=l||"light",u=a==null?void 0:a[d],f={...a,...n?{[d]:{...typeof u!="boolean"&&u,palette:n}}:void 0};if(i===!1){if(!("colorSchemes"in t))return Mo(t,...o);let h=n;"palette"in t||f[d]&&(f[d]!==!0?h=f[d].palette:d==="dark"&&(h={mode:"dark"}));const m=Mo({...t,palette:h},...o);return m.defaultColorScheme=d,m.colorSchemes=f,m.palette.mode==="light"&&(m.colorSchemes.light={...f.light!==!0&&f.light,palette:m.palette},Mn(m,"dark",f.dark)),m.palette.mode==="dark"&&(m.colorSchemes.dark={...f.dark!==!0&&f.dark,palette:m.palette},Mn(m,"light",f.light)),m}return!n&&!("light"in f)&&d==="light"&&(f.light=!0),Sc({...c,colorSchemes:f,defaultColorScheme:d,...typeof i!="boolean"&&i},...o)}const jc=Cc();function wc(){const t=Il(jc);return process.env.NODE_ENV!=="production"&&oo.useDebugValue(t),t[ga]||t}async function kc(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 a=new AbortController,l=setTimeout(()=>a.abort(),3e4);let c;try{c=await fetch(t,{headers:i,signal:a.signal})}catch(f){throw clearTimeout(l),(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(l)}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 d;try{d=await c.json()}catch{throw new Error("Response is not valid JSON")}let u;if(Array.isArray(d))u=d;else if(n&&d[n]&&Array.isArray(d[n]))u=d[n];else{const h=["data","results","items","records"].find(m=>d[m]&&Array.isArray(d[m]));if(h)u=d[h];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 Tc({isOpen:t,onClose:o,onCreate:n,preloadedData:i,preloadedDataLabel:a}){const[l,c]=p.useState(""),[d,u]=p.useState(!1),[f,h]=p.useState(""),[m,v]=p.useState(null),[w,z]=p.useState(null),[y,j]=p.useState(!1),[b,g]=p.useState(""),S=p.useRef(null),[s,I]=p.useState("json"),[A,H]=p.useState(""),[N,K]=p.useState(""),[te,se]=p.useState(""),[x,V]=p.useState("idle"),[$,J]=p.useState(""),[oe,ue]=p.useState(null),[pe,_]=p.useState(0),O=async W=>{if(g(""),!W.name.endsWith(".json")){g("Only .json files are allowed");return}const ee=10*1024*1024;if(W.size>ee){g("File size exceeds 10MB limit");return}try{const ie=await W.text();let ne;try{ne=JSON.parse(ie)}catch{g("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(ne)){g("JSON must be an array of objects");return}if(ne.length===0){g("No data rows found in JSON file");return}v(W),z(ne)}catch{g("Network error — please try again")}},L=W=>{W.preventDefault();const ee=W.dataTransfer.files[0];ee&&O(ee)},re=async()=>{if(A.trim()){V("loading"),J("");try{const W=await kc(A.trim(),N.trim()||void 0,te.trim()||void 0);ue(W.data),_(W.data.length),V("ready")}catch(W){J((W==null?void 0:W.message)||"Connection failed"),V("error")}}},Q=()=>{if(!l.trim()){u(!0);return}const W=s==="api"?oe:i||w;W&&(n(l.trim(),f.trim(),W),X())},X=()=>{c(""),u(!1),h(""),v(null),z(null),g(""),I("json"),H(""),K(""),se(""),V("idle"),J(""),ue(null),_(0),o()},ae=i||w,Z=d&&!l.trim();return l.trim(),e.jsxs(e.Fragment,{children:[e.jsxs(r.Dialog,{open:t,onClose:X,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",width:480,maxHeight:"min(720px, calc(100vh - 120px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[e.jsxs(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:X,size:"small",sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(k.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:l,onChange:W=>{c(W.target.value),d&&W.target.value.trim()&&u(!1)},placeholder:"Enter report name",autoFocus:!0,error:Z,helperText:Z?"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:W=>h(W.target.value),placeholder:"Add details about this report",inputProps:{maxLength:500},sx:{"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:1,color:"text.primary"},"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}}}}),e.jsxs(r.Tabs,{value:s==="json"?0:1,onChange:(W,ee)=>{I(ee===0?"json":"api"),V("idle"),J("")},variant:"fullWidth",sx:{borderBottom:1,borderColor:"divider",minHeight:40},children:[e.jsx(r.Tab,{label:"Upload JSON",icon:e.jsx(k.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(k.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:W=>R(W.palette.success.main,.04),display:"flex",alignItems:"center",gap:2},children:[e.jsx(r.Box,{sx:{width:36,height:36,borderRadius:"50%",bgcolor:W=>R(W.palette.success.main,.12),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(k.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:a||`${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(k.Info,{sx:{fontSize:16}})})]}),e.jsxs(r.Box,{onDrop:L,onDragOver:W=>W.preventDefault(),onPaste:W=>W.preventDefault(),onClick:()=>{var W;return(W=S.current)==null?void 0:W.click()},sx:{position:"relative",border:"1.5px",borderStyle:w?"solid":"dashed",borderColor:w?"success.main":b?"error.main":"primary.main",borderRadius:2,p:3,textAlign:"center",cursor:"pointer",bgcolor:w?W=>R(W.palette.success.main,.04):b?W=>R(W.palette.error.main,.04):W=>R(W.palette.primary.main,.04),transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:w?W=>R(W.palette.success.main,.08):b?W=>R(W.palette.error.main,.08):W=>R(W.palette.primary.main,.08),borderColor:w?"success.dark":b?"error.dark":"primary.dark"}},children:[e.jsx(r.Box,{component:"input",ref:S,type:"file",accept:".json",sx:{display:"none"},onChange:W=>{var ee;return((ee=W.target.files)==null?void 0:ee[0])&&O(W.target.files[0])}}),w?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:W=>R(W.palette.success.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:.5},children:e.jsx(k.CheckCircle,{sx:{fontSize:24,color:"success.main"}})}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.main",fontSize:"0.875rem"},children:m==null?void 0:m.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:W=>R(W.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mx:"auto",mb:1.5},children:e.jsx(k.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"}),b&&e.jsx(r.Box,{sx:{mt:1.25,p:.75,borderRadius:1,bgcolor:W=>R(W.palette.error.main,.08),border:1,borderColor:W=>R(W.palette.error.main,.2)},children:e.jsx(r.Typography,{variant:"caption",sx:{color:"error.main",fontSize:"0.6875rem",fontWeight:500},children:b})})]})]})]})}),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:W=>{H(W.target.value),V("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:N,onChange:W=>K(W.target.value),placeholder:"Leave blank if no auth required",InputProps:{startAdornment:e.jsx(r.InputAdornment,{position:"start",children:e.jsx(k.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:te,onChange:W=>se(W.target.value),placeholder:"data (leave blank if API returns a plain array)",helperText:'If your API returns { "data": [...] }, enter: data',sx:{"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:1,color:"text.primary"},"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}},"& .MuiFormHelperText-root":{fontSize:"0.75rem",mx:0}}}),e.jsx(r.Button,{variant:"outlined",fullWidth:!0,disabled:!A.trim()||x==="loading",onClick:re,startIcon:x==="loading"?e.jsx(r.CircularProgress,{size:16,color:"inherit"}):e.jsx(k.Api,{}),sx:{textTransform:"none",fontWeight:500,fontSize:"0.875rem",borderRadius:1,py:.875,borderColor:"primary.main",color:"primary.main","&:hover":{bgcolor:W=>R(W.palette.primary.main,.04),borderColor:"primary.dark"},"&:disabled":{borderColor:"action.disabledBackground",color:"action.disabled"}},children:x==="loading"?"Connecting...":"Test Connection & Load Data"}),x==="ready"&&e.jsxs(r.Box,{sx:{border:"1.5px solid",borderColor:"success.main",borderRadius:2,p:2,bgcolor:W=>R(W.palette.success.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[e.jsx(k.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:[pe.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})]})]}),x==="error"&&e.jsxs(r.Box,{sx:{border:"1.5px solid",borderColor:"error.main",borderRadius:2,p:2,bgcolor:W=>R(W.palette.error.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[e.jsx(k.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:$})]})]})]})]})}),e.jsxs(r.DialogActions,{sx:{px:3,py:2,gap:1,borderTop:"1px solid",borderColor:"divider"},children:[e.jsx(r.Button,{onClick:X,variant:"text",sx:{textTransform:"none",color:"primary.main",fontWeight:500,fontSize:"0.875rem",borderRadius:"4px",px:2,py:.625,minWidth:64,"&:hover":{bgcolor:W=>R(W.palette.primary.main,.04)}},children:"Cancel"}),e.jsx(r.Button,{onClick:Q,disabled:s==="json"&&!ae||s==="api"&&x!=="ready",variant:"contained",disableElevation:!0,sx:{textTransform:"none",fontWeight:500,fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",borderRadius:"4px",px:2.5,py:.625,minWidth:64,"&:hover":{bgcolor:"primary.dark",boxShadow:2},"&:disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Create"})]})]}),e.jsxs(r.Dialog,{open:y,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(k.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 Kn(t){return typeof t=="number"?`${(t*100).toFixed(0)}%`:`calc((${t}) * 100%)`}const qc=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 Jc(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})`:E(o,qc(n))},lighten(o,n){const i=this||t;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${o}, #fff ${Kn(n)})`:Do(o,n)},darken(o,n){const i=this||t;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${o}, #000 ${Kn(n)})`:Bo(o,n)}})}function qo(t={},...o){const{breakpoints:n,mixins:i={},spacing:s,palette:c={},transitions:d={},typography:l={},shape:u,colorSpace:m,...h}=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.":Yt(20));const b=sn({...c,colorSpace:m}),f=Mi(t);let g=qe(f,{mixins:_c(f.breakpoints,i),palette:b,shadows:Lc.slice(),typography:Wc(b,l),transitions:Uc(d),zIndex:{...Yc}});if(g=qe(g,h),g=o.reduce((T,y)=>qe(T,y),g),process.env.NODE_ENV!=="production"){const T=["active","checked","completed","disabled","error","expanded","focused","focusVisible","required","selected"],y=(w,v)=>{let j;for(j in w){const S=w[j];if(T.includes(j)&&Object.keys(S).length>0){if(process.env.NODE_ENV!=="production"){const I=hc("",j);console.error([`MUI: The \`${v}\` component increases the CSS specificity of the \`${j}\` internal state.`,"You can not override it like this: ",JSON.stringify(w,null,2),"",`Instead, you need to use the '&.${I}' syntax:`,JSON.stringify({root:{[`&.${I}`]:S}},null,2),"","https://mui.com/r/state-classes-guide"].join(`
68
+ `))}w[j]={}}}};Object.keys(g.components).forEach(w=>{const v=g.components[w].styleOverrides;v&&w.startsWith("Mui")&&y(v,w)})}return g.unstable_sxConfig={...Io,...h==null?void 0:h.unstable_sxConfig},g.unstable_sx=function(y){return zo({sx:y,theme:this})},g.toRuntimeSource=Pi,Jc(g),g}function Kc(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 Xc=[...Array(25)].map((t,o)=>{if(o===0)return"none";const n=Kc(o);return`linear-gradient(rgba(255 255 255 / ${n}), rgba(255 255 255 / ${n}))`});function Ni(t){return{inputPlaceholder:t==="dark"?.5:.42,inputUnderline:t==="dark"?.7:.42,switchTrackDisabled:t==="dark"?.2:.12,switchTrack:t==="dark"?.3:.38}}function Li(t){return t==="dark"?Xc:[]}function Zc(t){const{palette:o={mode:"light"},opacity:n,overlays:i,colorSpace:s,...c}=t,d=sn({...o,colorSpace:s});return{palette:d,opacity:{...Ni(d.mode),...n},overlays:i||Li(d.mode),...c}}function Qc(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 ed=t=>[...[...Array(25)].map((o,n)=>`--${t?`${t}-`:""}overlays-${n}`),`--${t?`${t}-`:""}palette-AppBar-darkBg`,`--${t?`${t}-`:""}palette-AppBar-darkColor`],td=t=>(o,n)=>{const i=t.rootSelector||":root",s=t.colorSchemeSelector;let c=s;if(s==="class"&&(c=".%s"),s==="data"&&(c="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(c=`[${s}="%s"]`),t.defaultColorScheme===o){if(o==="dark"){const d={};return ed(t.cssVarPrefix).forEach(l=>{d[l]=n[l],delete n[l]}),c==="media"?{[i]:n,"@media (prefers-color-scheme: dark)":{[i]:d}}:c?{[c.replace("%s",o)]:d,[`${i}, ${c.replace("%s",o)}`]:n}:{[i]:{...n,...d}}}if(c&&c!=="media")return`${i}, ${c.replace("%s",String(o))}`}else if(o){if(c==="media")return{[`@media (prefers-color-scheme: ${String(o)})`]:{[i]:n}};if(c)return c.replace("%s",String(o))}return i};function rd(t,o){o.forEach(n=>{t[n]||(t[n]={})})}function R(t,o,n){!t[o]&&n&&(t[o]=n)}function Hr(t){return typeof t!="string"||!t.startsWith("hsl")?t:_i(t)}function jt(t,o){`${o}Channel`in t||(t[`${o}Channel`]=Vr(Hr(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 od(t){return typeof t=="number"?`${t}px`:typeof t=="string"||typeof t=="function"||Array.isArray(t)?t:"8px"}const ft=t=>{try{return t()}catch{}},nd=(t="mui")=>Sc(t);function Vo(t,o,n,i,s){if(!n)return;n=n===!0?{}:n;const c=s==="dark"?"dark":"light";if(!i){o[s]=Zc({...n,palette:{mode:c,...n==null?void 0:n.palette},colorSpace:t});return}const{palette:d,...l}=qo({...i,palette:{mode:c,...n==null?void 0:n.palette},colorSpace:t});return o[s]={...n,palette:d,opacity:{...Ni(c),...n==null?void 0:n.opacity},overlays:(n==null?void 0:n.overlays)||Li(c)},l}function id(t={},...o){const{colorSchemes:n={light:!0},defaultColorScheme:i,disableCssColorScheme:s=!1,cssVarPrefix:c="mui",nativeColor:d=!1,shouldSkipGeneratingVar:l=Qc,colorSchemeSelector:u=n.light&&n.dark?"media":void 0,rootSelector:m=":root",...h}=t,b=Object.keys(n)[0],f=i||(n.light&&b!=="light"?"light":b),g=nd(c),{[f]:T,light:y,dark:w,...v}=n,j={...v};let S=T;if((f==="dark"&&!("dark"in n)||f==="light"&&!("light"in n))&&(S=!0),!S)throw new Error(process.env.NODE_ENV!=="production"?`MUI: The \`colorSchemes.${f}\` option is either missing or invalid.`:Yt(21,f));let I;d&&(I="oklch");const a=Vo(I,j,S,h,f);y&&!j.light&&Vo(I,j,y,void 0,"light"),w&&!j.dark&&Vo(I,j,w,void 0,"dark");let A={defaultColorScheme:f,...a,cssVarPrefix:c,colorSchemeSelector:u,rootSelector:m,getCssVar:g,colorSchemes:j,font:{...Mc(a.typography),...a.font},spacing:od(h.spacing)};Object.keys(A.colorSchemes).forEach(te=>{const x=A.colorSchemes[te].palette,N=H=>{const J=H.split("-"),ue=J[1],pe=J[2];return g(H,x[ue][pe])};x.mode==="light"&&(R(x.common,"background","#fff"),R(x.common,"onBackground","#000")),x.mode==="dark"&&(R(x.common,"background","#000"),R(x.common,"onBackground","#fff"));function W(H,J,ue){if(I){let pe;return H===Vt&&(pe=`transparent ${((1-ue)*100).toFixed(0)}%`),H===ye&&(pe=`#000 ${(ue*100).toFixed(0)}%`),H===be&&(pe=`#fff ${(ue*100).toFixed(0)}%`),`color-mix(in ${I}, ${J}, ${pe})`}return H(J,ue)}if(rd(x,["Alert","AppBar","Avatar","Button","Chip","FilledInput","LinearProgress","Skeleton","Slider","SnackbarContent","SpeedDialAction","StepConnector","StepContent","Switch","TableCell","Tooltip"]),x.mode==="light"){R(x.Alert,"errorColor",W(ye,x.error.light,.6)),R(x.Alert,"infoColor",W(ye,x.info.light,.6)),R(x.Alert,"successColor",W(ye,x.success.light,.6)),R(x.Alert,"warningColor",W(ye,x.warning.light,.6)),R(x.Alert,"errorFilledBg",N("palette-error-main")),R(x.Alert,"infoFilledBg",N("palette-info-main")),R(x.Alert,"successFilledBg",N("palette-success-main")),R(x.Alert,"warningFilledBg",N("palette-warning-main")),R(x.Alert,"errorFilledColor",ft(()=>x.getContrastText(x.error.main))),R(x.Alert,"infoFilledColor",ft(()=>x.getContrastText(x.info.main))),R(x.Alert,"successFilledColor",ft(()=>x.getContrastText(x.success.main))),R(x.Alert,"warningFilledColor",ft(()=>x.getContrastText(x.warning.main))),R(x.Alert,"errorStandardBg",W(be,x.error.light,.9)),R(x.Alert,"infoStandardBg",W(be,x.info.light,.9)),R(x.Alert,"successStandardBg",W(be,x.success.light,.9)),R(x.Alert,"warningStandardBg",W(be,x.warning.light,.9)),R(x.Alert,"errorIconColor",N("palette-error-main")),R(x.Alert,"infoIconColor",N("palette-info-main")),R(x.Alert,"successIconColor",N("palette-success-main")),R(x.Alert,"warningIconColor",N("palette-warning-main")),R(x.AppBar,"defaultBg",N("palette-grey-100")),R(x.Avatar,"defaultBg",N("palette-grey-400")),R(x.Button,"inheritContainedBg",N("palette-grey-300")),R(x.Button,"inheritContainedHoverBg",N("palette-grey-A100")),R(x.Chip,"defaultBorder",N("palette-grey-400")),R(x.Chip,"defaultAvatarColor",N("palette-grey-700")),R(x.Chip,"defaultIconColor",N("palette-grey-700")),R(x.FilledInput,"bg","rgba(0, 0, 0, 0.06)"),R(x.FilledInput,"hoverBg","rgba(0, 0, 0, 0.09)"),R(x.FilledInput,"disabledBg","rgba(0, 0, 0, 0.12)"),R(x.LinearProgress,"primaryBg",W(be,x.primary.main,.62)),R(x.LinearProgress,"secondaryBg",W(be,x.secondary.main,.62)),R(x.LinearProgress,"errorBg",W(be,x.error.main,.62)),R(x.LinearProgress,"infoBg",W(be,x.info.main,.62)),R(x.LinearProgress,"successBg",W(be,x.success.main,.62)),R(x.LinearProgress,"warningBg",W(be,x.warning.main,.62)),R(x.Skeleton,"bg",I?W(Vt,x.text.primary,.11):`rgba(${N("palette-text-primaryChannel")} / 0.11)`),R(x.Slider,"primaryTrack",W(be,x.primary.main,.62)),R(x.Slider,"secondaryTrack",W(be,x.secondary.main,.62)),R(x.Slider,"errorTrack",W(be,x.error.main,.62)),R(x.Slider,"infoTrack",W(be,x.info.main,.62)),R(x.Slider,"successTrack",W(be,x.success.main,.62)),R(x.Slider,"warningTrack",W(be,x.warning.main,.62));const H=I?W(ye,x.background.default,.6825):io(x.background.default,.8);R(x.SnackbarContent,"bg",H),R(x.SnackbarContent,"color",ft(()=>I?Go.text.primary:x.getContrastText(H))),R(x.SpeedDialAction,"fabHoverBg",io(x.background.paper,.15)),R(x.StepConnector,"border",N("palette-grey-400")),R(x.StepContent,"border",N("palette-grey-400")),R(x.Switch,"defaultColor",N("palette-common-white")),R(x.Switch,"defaultDisabledColor",N("palette-grey-100")),R(x.Switch,"primaryDisabledColor",W(be,x.primary.main,.62)),R(x.Switch,"secondaryDisabledColor",W(be,x.secondary.main,.62)),R(x.Switch,"errorDisabledColor",W(be,x.error.main,.62)),R(x.Switch,"infoDisabledColor",W(be,x.info.main,.62)),R(x.Switch,"successDisabledColor",W(be,x.success.main,.62)),R(x.Switch,"warningDisabledColor",W(be,x.warning.main,.62)),R(x.TableCell,"border",W(be,W(Vt,x.divider,1),.88)),R(x.Tooltip,"bg",W(Vt,x.grey[700],.92))}if(x.mode==="dark"){R(x.Alert,"errorColor",W(be,x.error.light,.6)),R(x.Alert,"infoColor",W(be,x.info.light,.6)),R(x.Alert,"successColor",W(be,x.success.light,.6)),R(x.Alert,"warningColor",W(be,x.warning.light,.6)),R(x.Alert,"errorFilledBg",N("palette-error-dark")),R(x.Alert,"infoFilledBg",N("palette-info-dark")),R(x.Alert,"successFilledBg",N("palette-success-dark")),R(x.Alert,"warningFilledBg",N("palette-warning-dark")),R(x.Alert,"errorFilledColor",ft(()=>x.getContrastText(x.error.dark))),R(x.Alert,"infoFilledColor",ft(()=>x.getContrastText(x.info.dark))),R(x.Alert,"successFilledColor",ft(()=>x.getContrastText(x.success.dark))),R(x.Alert,"warningFilledColor",ft(()=>x.getContrastText(x.warning.dark))),R(x.Alert,"errorStandardBg",W(ye,x.error.light,.9)),R(x.Alert,"infoStandardBg",W(ye,x.info.light,.9)),R(x.Alert,"successStandardBg",W(ye,x.success.light,.9)),R(x.Alert,"warningStandardBg",W(ye,x.warning.light,.9)),R(x.Alert,"errorIconColor",N("palette-error-main")),R(x.Alert,"infoIconColor",N("palette-info-main")),R(x.Alert,"successIconColor",N("palette-success-main")),R(x.Alert,"warningIconColor",N("palette-warning-main")),R(x.AppBar,"defaultBg",N("palette-grey-900")),R(x.AppBar,"darkBg",N("palette-background-paper")),R(x.AppBar,"darkColor",N("palette-text-primary")),R(x.Avatar,"defaultBg",N("palette-grey-600")),R(x.Button,"inheritContainedBg",N("palette-grey-800")),R(x.Button,"inheritContainedHoverBg",N("palette-grey-700")),R(x.Chip,"defaultBorder",N("palette-grey-700")),R(x.Chip,"defaultAvatarColor",N("palette-grey-300")),R(x.Chip,"defaultIconColor",N("palette-grey-300")),R(x.FilledInput,"bg","rgba(255, 255, 255, 0.09)"),R(x.FilledInput,"hoverBg","rgba(255, 255, 255, 0.13)"),R(x.FilledInput,"disabledBg","rgba(255, 255, 255, 0.12)"),R(x.LinearProgress,"primaryBg",W(ye,x.primary.main,.5)),R(x.LinearProgress,"secondaryBg",W(ye,x.secondary.main,.5)),R(x.LinearProgress,"errorBg",W(ye,x.error.main,.5)),R(x.LinearProgress,"infoBg",W(ye,x.info.main,.5)),R(x.LinearProgress,"successBg",W(ye,x.success.main,.5)),R(x.LinearProgress,"warningBg",W(ye,x.warning.main,.5)),R(x.Skeleton,"bg",I?W(Vt,x.text.primary,.13):`rgba(${N("palette-text-primaryChannel")} / 0.13)`),R(x.Slider,"primaryTrack",W(ye,x.primary.main,.5)),R(x.Slider,"secondaryTrack",W(ye,x.secondary.main,.5)),R(x.Slider,"errorTrack",W(ye,x.error.main,.5)),R(x.Slider,"infoTrack",W(ye,x.info.main,.5)),R(x.Slider,"successTrack",W(ye,x.success.main,.5)),R(x.Slider,"warningTrack",W(ye,x.warning.main,.5));const H=I?W(be,x.background.default,.985):io(x.background.default,.98);R(x.SnackbarContent,"bg",H),R(x.SnackbarContent,"color",ft(()=>I?Wi.text.primary:x.getContrastText(H))),R(x.SpeedDialAction,"fabHoverBg",io(x.background.paper,.15)),R(x.StepConnector,"border",N("palette-grey-600")),R(x.StepContent,"border",N("palette-grey-600")),R(x.Switch,"defaultColor",N("palette-grey-300")),R(x.Switch,"defaultDisabledColor",N("palette-grey-600")),R(x.Switch,"primaryDisabledColor",W(ye,x.primary.main,.55)),R(x.Switch,"secondaryDisabledColor",W(ye,x.secondary.main,.55)),R(x.Switch,"errorDisabledColor",W(ye,x.error.main,.55)),R(x.Switch,"infoDisabledColor",W(ye,x.info.main,.55)),R(x.Switch,"successDisabledColor",W(ye,x.success.main,.55)),R(x.Switch,"warningDisabledColor",W(ye,x.warning.main,.55)),R(x.TableCell,"border",W(ye,W(Vt,x.divider,1),.68)),R(x.Tooltip,"bg",W(Vt,x.grey[700],.92))}jt(x.background,"default"),jt(x.background,"paper"),jt(x.common,"background"),jt(x.common,"onBackground"),jt(x,"divider"),Object.keys(x).forEach(H=>{const J=x[H];H!=="tonalOffset"&&J&&typeof J=="object"&&(J.main&&R(x[H],"mainChannel",Vr(Hr(J.main))),J.light&&R(x[H],"lightChannel",Vr(Hr(J.light))),J.dark&&R(x[H],"darkChannel",Vr(Hr(J.dark))),J.contrastText&&R(x[H],"contrastTextChannel",Vr(Hr(J.contrastText))),H==="text"&&(jt(x[H],"primary"),jt(x[H],"secondary")),H==="action"&&(J.active&&jt(x[H],"active"),J.selected&&jt(x[H],"selected")))})}),A=o.reduce((te,x)=>qe(te,x),A);const B={prefix:c,disableCssColorScheme:s,shouldSkipGeneratingVar:l,getSelector:td(A),enableContrastVars:d},{vars:$,generateThemeVars:Y,generateStyleSheets:Q}=wc(A,B);return A.vars=$,Object.entries(A.colorSchemes[A.defaultColorScheme]).forEach(([te,x])=>{A[te]=x}),A.generateThemeVars=Y,A.generateStyleSheets=Q,A.generateSpacing=function(){return Ai(h.spacing,rn(this))},A.getColorSchemeSelector=kc(u),A.spacing=A.generateSpacing(),A.shouldSkipGeneratingVar=l,A.unstable_sxConfig={...Io,...h==null?void 0:h.unstable_sxConfig},A.unstable_sx=function(x){return zo({sx:x,theme:this})},A.toRuntimeSource=Pi,A}function Xn(t,o,n){t.colorSchemes&&n&&(t.colorSchemes[o]={...n!==!0&&n,palette:sn({...n===!0?{}:n.palette,mode:o})})}function sd(t={},...o){const{palette:n,cssVariables:i=!1,colorSchemes:s=n?void 0:{light:!0},defaultColorScheme:c=n==null?void 0:n.mode,...d}=t,l=c||"light",u=s==null?void 0:s[l],m={...s,...n?{[l]:{...typeof u!="boolean"&&u,palette:n}}:void 0};if(i===!1){if(!("colorSchemes"in t))return qo(t,...o);let h=n;"palette"in t||m[l]&&(m[l]!==!0?h=m[l].palette:l==="dark"&&(h={mode:"dark"}));const b=qo({...t,palette:h},...o);return b.defaultColorScheme=l,b.colorSchemes=m,b.palette.mode==="light"&&(b.colorSchemes.light={...m.light!==!0&&m.light,palette:b.palette},Xn(b,"dark",m.dark)),b.palette.mode==="dark"&&(b.colorSchemes.dark={...m.dark!==!0&&m.dark,palette:b.palette},Xn(b,"light",m.light)),b}return!n&&!("light"in m)&&l==="light"&&(m.light=!0),id({...d,colorSchemes:m,defaultColorScheme:l,...typeof i!="boolean"&&i},...o)}const ad=sd();function Tt(){const t=pc(ad);return process.env.NODE_ENV!=="production"&&fo.useDebugValue(t),t[tl]||t}async function ld(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,c=setTimeout(()=>s.abort(),3e4);let d;try{d=await fetch(t,{headers:i,signal:s.signal})}catch(m){throw clearTimeout(c),(m==null?void 0:m.name)==="AbortError"?new Error("Request timed out after 30 seconds"):new Error("Failed to fetch — check the URL and your network connection")}finally{clearTimeout(c)}if(d.status===401)throw new Error("Authentication failed (401) — check your API key");if(!d.ok)throw new Error(`API error ${d.status}: ${d.statusText}`);let l;try{l=await d.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 h=["data","results","items","records"].find(b=>l[b]&&Array.isArray(l[b]));if(h)u=l[h];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 cd({isOpen:t,onClose:o,onCreate:n,preloadedData:i,preloadedDataLabel:s}){const[c,d]=p.useState(""),[l,u]=p.useState(!1),[m,h]=p.useState(""),[b,f]=p.useState(null),[g,T]=p.useState(null),[y,w]=p.useState(!1),[v,j]=p.useState(""),S=p.useRef(null),[I,a]=p.useState("json"),[A,B]=p.useState(""),[$,Y]=p.useState(""),[Q,te]=p.useState(""),[x,N]=p.useState("idle"),[W,H]=p.useState(""),[J,ue]=p.useState(null),[pe,re]=p.useState(0),O=async P=>{if(j(""),!P.name.endsWith(".json")){j("Only .json files are allowed");return}const ne=10*1024*1024;if(P.size>ne){j("File size exceeds 10MB limit");return}try{const ce=await P.text();let ie;try{ie=JSON.parse(ce)}catch{j("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(ie)){j("JSON must be an array of objects");return}if(ie.length===0){j("No data rows found in JSON file");return}f(P),T(ie)}catch{j("Network error — please try again")}},F=P=>{P.preventDefault();const ne=P.dataTransfer.files[0];ne&&O(ne)},G=async()=>{if(A.trim()){N("loading"),H("");try{const P=await ld(A.trim(),$.trim()||void 0,Q.trim()||void 0);ue(P.data),re(P.data.length),N("ready")}catch(P){H((P==null?void 0:P.message)||"Connection failed"),N("error")}}},se=()=>{if(!c.trim()){u(!0);return}const P=I==="api"?J:i||g;P&&(n(c.trim(),m.trim(),P),ee())},ee=()=>{d(""),u(!1),h(""),f(null),T(null),j(""),a("json"),B(""),Y(""),te(""),N("idle"),H(""),ue(null),re(0),o()},le=i||g,ae=l&&!c.trim();return c.trim(),e.jsxs(e.Fragment,{children:[e.jsxs(r.Dialog,{open:t,onClose:ee,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",width:480,maxHeight:"min(720px, calc(100vh - 120px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[e.jsxs(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:ee,size:"small",sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(k.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:c,onChange:P=>{d(P.target.value),l&&P.target.value.trim()&&u(!1)},placeholder:"Enter report name",autoFocus:!0,error:ae,helperText:ae?"Report name is required":void 0,inputProps:{maxLength:255},sx:{"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:1,color:"text.primary"},"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}}}}),e.jsx(r.TextField,{label:"Description (optional)",fullWidth:!0,multiline:!0,rows:2,value:m,onChange:P=>h(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:I==="json"?0:1,onChange:(P,ne)=>{a(ne===0?"json":"api"),N("idle"),H("")},variant:"fullWidth",sx:{borderBottom:1,borderColor:"divider",minHeight:40},children:[e.jsx(r.Tab,{label:"Upload JSON",icon:e.jsx(k.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(k.Api,{fontSize:"small"}),iconPosition:"start",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,minHeight:40,py:.5}})]}),I==="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=>E(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=>E(P.palette.success.main,.12),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(k.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:()=>w(!0),sx:{p:.25,color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:e.jsx(k.Info,{sx:{fontSize:16}})})]}),e.jsxs(r.Box,{onDrop:F,onDragOver:P=>P.preventDefault(),onPaste:P=>P.preventDefault(),onClick:()=>{var P;return(P=S.current)==null?void 0:P.click()},sx:{position:"relative",border:"1.5px",borderStyle:g?"solid":"dashed",borderColor:g?"success.main":v?"error.main":"primary.main",borderRadius:2,p:3,textAlign:"center",cursor:"pointer",bgcolor:g?P=>E(P.palette.success.main,.04):v?P=>E(P.palette.error.main,.04):P=>E(P.palette.primary.main,.04),transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:g?P=>E(P.palette.success.main,.08):v?P=>E(P.palette.error.main,.08):P=>E(P.palette.primary.main,.08),borderColor:g?"success.dark":v?"error.dark":"primary.dark"}},children:[e.jsx(r.Box,{component:"input",ref:S,type:"file",accept:".json",sx:{display:"none"},onChange:P=>{var ne;return((ne=P.target.files)==null?void 0:ne[0])&&O(P.target.files[0])}}),g?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=>E(P.palette.success.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:.5},children:e.jsx(k.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=>E(P.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mx:"auto",mb:1.5},children:e.jsx(k.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"}),v&&e.jsx(r.Box,{sx:{mt:1.25,p:.75,borderRadius:1,bgcolor:P=>E(P.palette.error.main,.08),border:1,borderColor:P=>E(P.palette.error.main,.2)},children:e.jsx(r.Typography,{variant:"caption",sx:{color:"error.main",fontSize:"0.6875rem",fontWeight:500},children:v})})]})]})]})}),I==="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),N("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:$,onChange:P=>Y(P.target.value),placeholder:"Leave blank if no auth required",InputProps:{startAdornment:e.jsx(r.InputAdornment,{position:"start",children:e.jsx(k.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:Q,onChange:P=>te(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()||x==="loading",onClick:G,startIcon:x==="loading"?e.jsx(r.CircularProgress,{size:16,color:"inherit"}):e.jsx(k.Api,{}),sx:{textTransform:"none",fontWeight:500,fontSize:"0.875rem",borderRadius:1,py:.875,borderColor:"primary.main",color:"primary.main","&:hover":{bgcolor:P=>E(P.palette.primary.main,.04),borderColor:"primary.dark"},"&:disabled":{borderColor:"action.disabledBackground",color:"action.disabled"}},children:x==="loading"?"Connecting...":"Test Connection & Load Data"}),x==="ready"&&e.jsxs(r.Box,{sx:{border:"1.5px solid",borderColor:"success.main",borderRadius:2,p:2,bgcolor:P=>E(P.palette.success.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[e.jsx(k.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:[pe.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})]})]}),x==="error"&&e.jsxs(r.Box,{sx:{border:"1.5px solid",borderColor:"error.main",borderRadius:2,p:2,bgcolor:P=>E(P.palette.error.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[e.jsx(k.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:ee,variant:"text",sx:{textTransform:"none",color:"primary.main",fontWeight:500,fontSize:"0.875rem",borderRadius:"4px",px:2,py:.625,minWidth:64,"&:hover":{bgcolor:P=>E(P.palette.primary.main,.04)}},children:"Cancel"}),e.jsx(r.Button,{onClick:se,disabled:I==="json"&&!le||I==="api"&&x!=="ready",variant:"contained",disableElevation:!0,sx:{textTransform:"none",fontWeight:500,fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",borderRadius:"4px",px:2.5,py:.625,minWidth:64,"&:hover":{bgcolor:"primary.dark",boxShadow:2},"&:disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Create"})]})]}),e.jsxs(r.Dialog,{open:y,onClose:()=>w(!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:()=>w(!1),size:"small",sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:e.jsx(k.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:()=>j(!1),variant:"contained",disableElevation:!0,sx:{textTransform:"none",fontWeight:500,fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",borderRadius:"4px",px:2.5,py:.625,minWidth:64,"&:hover":{bgcolor:"primary.dark",boxShadow:2}},children:"Got it"})})]})]})}function bi({isOpen:t,onClose:o}){return t?e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"md",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",maxHeight:"min(640px, calc(100vh - 180px))",my:"auto",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",display:"flex",flexDirection:"column"}},children:[e.jsxs(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(k.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:()=>w(!1),variant:"contained",disableElevation:!0,sx:{textTransform:"none",fontWeight:500,fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",borderRadius:"4px",px:2.5,py:.625,minWidth:64,"&:hover":{bgcolor:"primary.dark",boxShadow:2}},children:"Got it"})})]})]})}function Fi({isOpen:t,onClose:o}){return t?e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"md",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",maxHeight:"min(640px, calc(100vh - 180px))",my:"auto",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",display:"flex",flexDirection:"column"}},children:[e.jsxs(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(k.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:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"#ffffff",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Got it"})})]}):null}function zc({onFileUpload:t,onError:o,isUploading:n}){const[i,a]=p.useState(!1),[l,c]=p.useState(""),[d,u]=p.useState(!1),f=p.useRef(null),h=async b=>{if(!b.name.endsWith(".json")){o("Only .json files are allowed");return}const g=10*1024*1024;if(b.size>g){o("File size exceeds 10MB limit");return}c(b.name);try{const S=await b.text();let s;try{s=JSON.parse(S)}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("")}},m=b=>{b.preventDefault(),a(!0)},v=b=>{b.preventDefault(),a(!1)},w=b=>{b.preventDefault(),a(!1);const g=b.dataTransfer.files[0];g&&h(g)},z=()=>{var b;(b=f.current)==null||b.click()},y=b=>{var S;const g=(S=b.target.files)==null?void 0:S[0];g&&h(g)},j=b=>{b.stopPropagation(),u(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(r.Box,{onDragOver:m,onDragLeave:v,onDrop:w,onPaste:b=>b.preventDefault(),onClick:z,sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderStyle:"dashed",borderColor:i?"primary.main":"divider",bgcolor:i?b=>R(b.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:y,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..."}),l&&e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:l})]}):e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:b=>R(b.palette.primary.main,.12),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(k.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(k.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(bi,{isOpen:d,onClose:()=>u(!1)})]})}function Ic({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?a=>R(a.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(k.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 Ec({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=>R(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=>R(n.palette.error.main,.3),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(k.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(k.Upload,{sx:{fontSize:16}}),onClick:o,sx:{fontWeight:500},children:"Try Again"})]})}function vi({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=>R(i.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:3},children:e.jsx(k.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 Dc({value:t,onChange:o,searchHistory:n,onAddToHistory:i,onToggleFavourite:a,onDeleteHistory:l,disabled:c}){const[d,u]=p.useState(!1),[f,h]=p.useState(!1),[m,v]=p.useState(-1),w=p.useRef(null),z=p.useRef(null);p.useEffect(()=>{function N(K){w.current&&!w.current.contains(K.target)&&(u(!1),h(!1))}return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[]);const y=p.useCallback(()=>{h(!0),v(-1),n.length>0&&u(!0)},[n.length]),j=p.useCallback(N=>{o(N),v(-1)},[o]),b=p.useCallback(N=>{var K;o(N),i(N),u(!1),(K=z.current)==null||K.blur()},[o,i]),g=p.useCallback(N=>{v(-1),b(N)},[b]),S=p.useCallback(N=>{var K;N.key==="Enter"?m>=0&&m<n.length?(N.preventDefault(),g(n[m].query)):t.trim()&&b(t.trim()):N.key==="Escape"?(u(!1),v(-1),(K=z.current)==null||K.blur()):N.key==="ArrowDown"?(N.preventDefault(),n.length>0&&(d||u(!0),v(te=>te<n.length-1?te+1:te))):N.key==="ArrowUp"&&(N.preventDefault(),v(te=>te>0?te-1:-1))},[m,n,t,d,g,b]),s=p.useCallback(()=>{var N;o(""),(N=z.current)==null||N.focus()},[o]),I=p.useMemo(()=>n.filter(N=>N.isFavourite),[n]),A=p.useMemo(()=>n.filter(N=>!N.isFavourite),[n]),H=d&&n.length>0;return e.jsxs(r.Box,{sx:{position:"relative",width:240},ref:w,children:[e.jsx(r.TextField,{inputRef:z,size:"small",fullWidth:!0,value:t,onChange:N=>j(N.target.value),onFocus:y,onKeyDown:S,placeholder:"Search data...",disabled:c,sx:{"& .MuiOutlinedInput-root":{borderRadius:"20px",fontSize:"0.875rem",bgcolor:"common.white",height:"36px","& fieldset":{borderColor:"divider",transition:"all 0.15s ease"},"&:hover":{bgcolor:"action.hover"},"&:hover fieldset":{borderColor:"divider"},"&.Mui-focused":{bgcolor:"common.white"},"&.Mui-focused fieldset":{borderColor:"#2932e5",borderWidth:2}},"& .MuiOutlinedInput-input":{py:"6px",px:"8px"}},InputProps:{startAdornment:e.jsx(r.InputAdornment,{position:"start",sx:{ml:.5},children:e.jsx(k.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(k.Close,{sx:{fontSize:16}})})}):null}}),H&&e.jsxs(r.Paper,{sx:{position:"absolute",zIndex:50,mt:.5,width:"100%",maxHeight:384,overflowY:"auto"},elevation:3,children:[I.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"}),I.map((N,K)=>e.jsx(Wn,{entry:N,isSelected:m===K,onClick:()=>g(N.query),onToggleFavourite:()=>a(N.query),onDelete:()=>l(N.query)},`fav-${N.query}`))]}),A.length>0&&e.jsxs(r.Box,{sx:{py:1},children:[I.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((N,K)=>{const te=I.length+K;return e.jsx(Wn,{entry:N,isSelected:m===te,onClick:()=>g(N.query),onToggleFavourite:()=>a(N.query),onDelete:()=>l(N.query)},`recent-${N.query}`)})]})]})]})}const Wn=p.memo(function({entry:o,isSelected:n,onClick:i,onToggleFavourite:a,onDelete:l}){const c=p.useCallback(u=>{u.stopPropagation(),a()},[a]),d=p.useCallback(u=>{u.stopPropagation(),l()},[l]);return e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:1.5,py:1,cursor:"pointer",bgcolor:n?u=>R(u.palette.primary.main,.12):"transparent","&:hover":{bgcolor:n?u=>R(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(k.Star,{sx:{fontSize:14,color:"warning.light"}}):e.jsx(k.StarBorder,{sx:{fontSize:14,color:"action.disabled"}})}),e.jsx(r.IconButton,{size:"small",onClick:d,title:"Delete from history",sx:{p:.5,"&:hover":{color:"error.main"}},children:e.jsx(k.Delete,{sx:{fontSize:14,opacity:.5}})})]})]})});function Bc({views:t,activeViewId:o,isDirty:n,onSelectView:i,onCreateView:a,onManageViews:l,onToggleDefault:c,onToggleFavorite:d,onRestoreView:u,onPermanentDelete:f,isReadOnly:h}){const m=wc(),[v,w]=p.useState(!1),[z,y]=p.useState(!1),[j,b]=p.useState({top:0,left:0}),[g,S]=p.useState(null),s=p.useRef(null),I=p.useRef(null),A=t.find(_=>_.id===o),H=A==null?void 0:A.isDefault,N=t.filter(_=>_.isDefault&&!_.isDeleted),K=t.filter(_=>!_.isDefault&&!_.isDeleted).sort((_,O)=>(O.updatedAt||0)-(_.updatedAt||0)),te=t.filter(_=>_.isFavorite&&!_.isDeleted).sort((_,O)=>(O.updatedAt||0)-(_.updatedAt||0)),se=t.filter(_=>_.isDeleted);p.useEffect(()=>{if(v&&I.current){const _=I.current.getBoundingClientRect();b({top:_.bottom+window.scrollY+8,left:_.right+window.scrollX-320})}},[v]),p.useEffect(()=>{const _=O=>{s.current&&!s.current.contains(O.target)&&I.current&&!I.current.contains(O.target)&&w(!1)};return v&&document.addEventListener("mousedown",_),()=>{document.removeEventListener("mousedown",_)}},[v]);const x=_=>{if(n&&_!==o){S(_),w(!1);return}i(_),w(!1)},V=()=>{g&&(i(g),S(null))},$=()=>{S(null)},J=(_,O=!1)=>e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:o===_.id?m.palette.primary.light+"20":"transparent",transition:"background-color 0.2s","&:hover":{backgroundColor:o===_.id?m.palette.primary.light+"20":m.palette.grey[50]}},children:[e.jsxs(r.Button,{onClick:()=>x(_.id),sx:{display:"flex",alignItems:"center",gap:1,flex:1,textAlign:"left",minWidth:0,textTransform:"none",justifyContent:"flex-start",color:"inherit",p:0,"&:hover":{backgroundColor:"transparent"}},children:[o===_.id&&e.jsx(k.Check,{sx:{fontSize:16,flexShrink:0}}),o!==_.id&&e.jsx(r.Box,{sx:{width:"16px",flexShrink:0}}),e.jsx(r.Typography,{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:o===_.id?m.palette.primary.dark:m.palette.text.primary,fontWeight:o===_.id?500:400},children:_.name}),O&&e.jsx(r.Typography,{component:"span",sx:{fontSize:"caption.fontSize",color:m.palette.text.secondary,backgroundColor:m.palette.grey[100],px:1,py:.25,borderRadius:1,flexShrink:0},children:"Default"})]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[d&&e.jsx(r.IconButton,{onClick:L=>{L.stopPropagation(),d(_.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:m.palette.grey[200]}},title:_.isFavorite?"Remove from favorites":"Add to favorites",children:e.jsx(k.Star,{sx:{fontSize:16}})}),c&&!_.isDefault&&e.jsx(r.IconButton,{onClick:L=>{L.stopPropagation(),c(_.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:m.palette.grey[200]}},title:"Set as default",children:e.jsx(k.RadioButtonUnchecked,{sx:{fontSize:16}})})]})]},_.id),oe=_=>e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:m.palette.grey[50]},children:[e.jsx(r.Typography,{sx:{color:m.palette.text.secondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:_.name}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[u&&e.jsx(r.IconButton,{onClick:O=>{O.stopPropagation(),u(_.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:m.palette.grey[200]}},title:"Restore view",children:e.jsx(k.Undo,{sx:{fontSize:16,color:"success.main"}})}),f&&e.jsx(r.IconButton,{onClick:O=>{O.stopPropagation(),f(_.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:m.palette.grey[200]}},title:"Delete permanently",children:e.jsx(k.Delete,{sx:{fontSize:16,color:"error.main"}})})]})]},_.id),ue=n||!H,pe=n;return e.jsxs(r.Box,{sx:{position:"relative"},children:[e.jsxs(r.IconButton,{ref:I,onClick:()=>w(!v),size:"small",sx:{position:"relative",color:ue?"warning.main":"text.secondary",bgcolor:ue?R(m.palette.warning.main,.12):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:ue?R(m.palette.warning.main,.2):R(m.palette.text.primary,.06),color:ue?"warning.dark":"text.primary"}},title:`View: ${(A==null?void 0:A.name)||"Default View"}`,children:[e.jsx(k.Visibility,{sx:{fontSize:20}}),pe&&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"}})]}),v&&Fn.createPortal(e.jsxs(r.Box,{ref:s,sx:{position:"fixed",width:"320px",backgroundColor:m.palette.background.paper,border:`1px solid ${m.palette.divider}`,borderRadius:1,boxShadow:m.shadows[8],zIndex:50,maxHeight:"500px",overflowY:"auto",top:j.top,left:j.left},children:[N.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:m.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Default Views"}),N.map(_=>J(_,!0))]}),te.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{borderTop:`1px solid ${m.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:m.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",gap:.5},children:[e.jsx(k.Star,{sx:{fontSize:12,color:"warning.light"}}),e.jsx(r.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:"Favorite Views"})]}),te.map(_=>J(_))]})]}),K.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{borderTop:`1px solid ${m.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:m.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Custom Views"}),K.map(_=>J(_))]})]}),se.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{borderTop:`1px solid ${m.palette.divider}`}}),e.jsxs(r.Box,{sx:{py:.5},children:[e.jsxs(r.Button,{onClick:()=>y(!z),sx:{width:"100%",px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:m.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",justifyContent:"space-between",transition:"background-color 0.2s","&:hover":{backgroundColor:m.palette.grey[50]}},children:[e.jsxs(r.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:["Recently Deleted (",se.length,")"]}),e.jsx(k.ChevronRight,{sx:{fontSize:16}})]}),z&&e.jsx(r.Box,{sx:{backgroundColor:m.palette.grey[50]},children:se.map(_=>oe(_))})]})]}),e.jsx(r.Box,{sx:{borderTop:`1px solid ${m.palette.divider}`}}),e.jsxs(r.Button,{onClick:()=>{a(),w(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:m.palette.text.primary,textTransform:"none",justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:m.palette.grey[50]}},children:[e.jsx(k.Add,{sx:{fontSize:16}}),e.jsx(r.Typography,{component:"span",sx:{fontSize:"inherit"},children:"Create New Report View"})]}),e.jsxs(r.Button,{onClick:()=>{l(),w(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:m.palette.text.primary,textTransform:"none",justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:m.palette.grey[50]}},children:[e.jsx(k.Settings,{sx:{fontSize:16}}),e.jsx(r.Typography,{component:"span",sx:{fontSize:"inherit"},children:"View Setup"})]})]}),document.body),e.jsxs(r.Dialog,{open:g!==null,onClose:$,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px"}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",gap:1,pb:1},children:[e.jsx(k.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:$,variant:"text",sx:{textTransform:"none",fontWeight:500},children:"Stay here"}),e.jsx(r.Button,{onClick:V,variant:"contained",color:"warning",disableElevation:!0,sx:{textTransform:"none",fontWeight:500},children:"Discard & switch"})]})]})]})}function Oc({columnName:t,columnType:o="string",currentSort:n,hasFilters:i,isInSortStack:a,position:l,onSort:c,onRemoveSort:d,onSortAscending:u,onSortDescending:f,onFilter:h,onClearFilter:m,onHideColumn:v,onManageColumns:w,onManageViews:z,onResetLayout:y,onClose:j}){const b=p.useRef(null);p.useEffect(()=>{const S=I=>{b.current&&!b.current.contains(I.target)&&j()},s=I=>{I.key==="Escape"&&j()};return document.addEventListener("mousedown",S),document.addEventListener("keydown",s),()=>{document.removeEventListener("mousedown",S),document.removeEventListener("keydown",s)}},[j]);const g=()=>n?n.direction==="asc"?o==="number"?"(0→9)":o==="boolean"?"(False→True)":"(A→Z)":o==="number"?"(9→0)":o==="boolean"?"(True→False)":"(Z→A)":"";return Fn.createPortal(e.jsxs(r.Paper,{ref:b,sx:{position:"fixed",left:`${l.x}px`,top:`${l.y}px`,zIndex:100,minWidth:240},elevation:3,children:[e.jsxs(r.Box,{sx:{px:2,py:1},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:1},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500},children:"Sorting"}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(r.IconButton,{size:"small",onClick:()=>{u?u(t):(n==null?void 0:n.direction)!=="asc"&&(c(t),(n==null?void 0:n.direction)==="desc"&&setTimeout(()=>c(t),0))},title:"Sort Ascending",sx:{p:.75},children:e.jsx(k.ArrowUpward,{color:(n==null?void 0:n.direction)==="asc"?"primary":void 0,sx:{fontSize:16}})}),e.jsx(r.IconButton,{size:"small",onClick:()=>{f?f(t):n?n.direction==="asc"&&c(t):(c(t),setTimeout(()=>c(t),0))},title:"Sort Descending",sx:{p:.75},children:e.jsx(k.ArrowDownward,{color:(n==null?void 0:n.direction)==="desc"?"primary":void 0,sx:{fontSize:16}})}),e.jsx(r.IconButton,{size:"small",onClick:()=>d(t),title:"Clear sorting",disabled:!n,sx:{p:.75,"&:hover":{color:"error.main"}},children:e.jsx(k.Close,{sx:{fontSize:16}})})]})]}),n&&e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1,mt:.5},children:[e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:g()}),e.jsx(r.Chip,{label:`Level ${n.priority}`,size:"small",color:"primary",sx:{height:20,fontSize:"caption.fontSize"}})]})]}),e.jsx(r.Divider,{}),e.jsxs(r.MenuList,{dense:!0,children:[e.jsxs(r.MenuItem,{onClick:()=>{h(t),j()},children:[e.jsx(k.FilterList,{sx:{fontSize:16,mr:1}}),"Filter this column",i&&e.jsx(r.Chip,{label:"Active",size:"small",color:"primary",sx:{ml:"auto",height:20,fontSize:"caption.fontSize"}})]}),i&&e.jsxs(r.MenuItem,{onClick:()=>{m(t),j()},sx:{color:"warning.main"},children:[e.jsx(k.FilterListOff,{sx:{fontSize:16,mr:1}}),"Clear Filters"]})]}),e.jsx(r.Divider,{}),e.jsx(r.MenuList,{dense:!0,children:e.jsxs(r.MenuItem,{onClick:()=>{v(t),j()},children:[e.jsx(k.VisibilityOff,{sx:{fontSize:16,mr:1}}),"Hide column"]})}),e.jsx(r.Divider,{}),e.jsxs(r.MenuList,{dense:!0,children:[e.jsxs(r.MenuItem,{onClick:()=>{w(),j()},children:[e.jsx(k.Settings,{sx:{fontSize:16,mr:1}}),"Column Settings"]}),e.jsxs(r.MenuItem,{onClick:()=>{z(),j()},children:[e.jsx(k.Description,{sx:{fontSize:16,mr:1}}),"View Setup"]}),e.jsxs(r.MenuItem,{onClick:()=>{y(),j()},children:[e.jsx(k.Undo,{sx:{fontSize:16,mr:1}}),"Reset to Default Layout"]})]})]}),document.body)}const Ac=150,Rn="COLUMN_HEADER",Mc=p.memo(function({column:o,index:n,sortRule:i,hasFilters:a,isInSortStack:l,width:c,onColumnClick:d,onMoveColumn:u,onResizeStart:f,onSort:h,onRemoveSort:m,onSortAscending:v,onSortDescending:w,onOpenFilterForColumn:z,onClearFiltersForColumn:y,onHideColumn:j,onManageColumns:b,onManageViews:g,onResetLayout:S}){const s=p.useRef(null),[I,A]=p.useState(!1),[H,N]=p.useState({x:0,y:0}),[{handlerId:K,isOver:te},se]=St.useDrop({accept:Rn,collect(O){return{handlerId:O.getHandlerId(),isOver:O.isOver()}},hover(O,L){var ee;if(!s.current)return;const re=O.index,Q=n;if(re===Q)return;const X=(ee=s.current)==null?void 0:ee.getBoundingClientRect(),ae=(X.right-X.left)/2,Z=L.getClientOffset(),W=((Z==null?void 0:Z.x)??0)-X.left;re<Q&&W<ae||re>Q&&W>ae||(u(re,Q),O.index=Q)}}),[{isDragging:x},V]=St.useDrag({type:Rn,item:()=>({index:n,columnName:o.name}),collect:O=>({isDragging:O.isDragging()})});V(se(s));const $=p.useCallback(O=>{O.preventDefault(),O.stopPropagation(),N({x:O.clientX,y:O.clientY}),A(!0)},[]),J=p.useCallback(()=>{A(!1)},[]),oe=p.useCallback(()=>{d(o.name)},[d,o.name]),ue=p.useCallback(O=>{O.stopPropagation(),z(o.name)},[z,o.name]),pe=p.useCallback(()=>i?e.jsxs(r.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25,color:"primary.main"},children:[i.direction==="asc"?e.jsx(k.ArrowUpward,{sx:{fontSize:13,color:"primary.main"}}):e.jsx(k.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:"#fff",fontSize:"0.6rem",fontWeight:700,borderRadius:"50%",lineHeight:1},children:i.priority})]}):null,[i]),_=p.useCallback(()=>a?e.jsx(r.Box,{onClick:ue,title:"Active filters on this column",sx:{ml:.75,width:7,height:7,borderRadius:"50%",bgcolor:"primary.main",cursor:"pointer",flexShrink:0,"&:hover":{transform:"scale(1.25)"},transition:"transform 0.12s ease"}}):null,[a,ue]);return e.jsxs(e.Fragment,{children:[e.jsxs(r.TableCell,{ref:s,"data-handler-id":K,"data-column-index":n,onClick:oe,onContextMenu:$,sx:{position:"sticky",top:0,zIndex:5,textAlign:"left",fontSize:"0.8125rem",fontWeight:700,textTransform:"none",letterSpacing:0,whiteSpace:"nowrap",overflow:"hidden",cursor:"pointer",userSelect:"none",color:"primary.main",opacity:x?.25:1,transition:"background-color 0.12s ease, opacity 0.15s ease",bgcolor:te?O=>R(O.palette.primary.main,.08):"#f5f5f5",backgroundImage:"none",borderBottom:"1px solid",borderColor:"#e0e0e0",py:0,px:2,height:34,"&:hover":{bgcolor:"#e8e8e8",color:"primary.dark"},width:c?`${c}px`:`${Ac}px`},children:[e.jsxs(r.Box,{sx:{display:"inline-flex",alignItems:"center"},children:[ct(o.name),pe(),_()]}),e.jsx(r.Box,{sx:{position:"absolute",right:0,top:0,height:"100%",width:8,cursor:"col-resize",zIndex:10,"&:hover":{bgcolor:"primary.light"}},onMouseDown:O=>{O.stopPropagation(),f(O,o.name)},onClick:O=>O.stopPropagation()}),te&&e.jsx(r.Box,{sx:{position:"absolute",left:0,top:0,bottom:0,width:4,bgcolor:"primary.main"}})]}),I&&e.jsx(Oc,{columnName:o.name,columnType:o.type,currentSort:i,hasFilters:a,isInSortStack:l,position:H,onSort:h,onRemoveSort:m,onSortAscending:v,onSortDescending:w,onFilter:z,onClearFilter:y,onHideColumn:j,onManageColumns:b,onManageViews:g,onResetLayout:S,onClose:J})]})});function Wc({selectedCount:t,selectedRowIds:o,resolvedFavoritesSet:n,viewMode:i="list",onExportSelected:a,onClearSelection:l,onBulkSetFavorites:c}){const[d,u]=p.useState(null),f=p.useMemo(()=>Array.from(o),[o]),h=p.useMemo(()=>f.filter(b=>n.has(b)),[f,n]),m=p.useMemo(()=>f.filter(b=>!n.has(b)),[f,n]),v=h.length>0,w=m.length>0;if(t===0)return null;const z=()=>{c&&c(f,!0)},y=()=>{c&&c(f,!1)},j=b=>{a(b),u(null)};return e.jsx(r.Box,{sx:{width:"100%",flexShrink:0,bgcolor:b=>R(b.palette.primary.main,.08),borderBottom:b=>`1px solid ${R(b.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:l,startIcon:e.jsx(k.Close,{sx:{fontSize:16}}),size:"small",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2,py:.625,borderRadius:"18px",color:"text.secondary","&:hover":{bgcolor:b=>R(b.palette.text.primary,.06),color:"text.primary"}},children:"Clear"}),e.jsx(r.Button,{onClick:b=>u(b.currentTarget),startIcon:e.jsx(k.Download,{sx:{fontSize:16}}),size:"small",variant:"outlined",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2,py:.625,borderRadius:"18px",borderColor:b=>R(b.palette.primary.main,.4),color:"primary.main","&:hover":{borderColor:"primary.main",bgcolor:b=>R(b.palette.primary.main,.06)}},children:"Export Selected"}),e.jsxs(r.Menu,{anchorEl:d,open:!!d,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:()=>j("csv"),sx:{py:1,px:2},children:"Export as CSV"}),e.jsx(r.MenuItem,{dense:!0,onClick:()=>j("excel"),sx:{py:1,px:2},children:"Export as Excel"}),e.jsx(r.MenuItem,{dense:!0,onClick:()=>j("json"),sx:{py:1,px:2},children:"Export as JSON"})]}),c&&w&&e.jsx(r.Button,{onClick:z,startIcon:e.jsx(k.StarBorder,{sx:{fontSize:16}}),size:"small",variant:"outlined",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2,py:.625,borderRadius:"18px",borderColor:b=>R(b.palette.warning.main,.5),color:"warning.dark","&:hover":{borderColor:"warning.main",bgcolor:b=>R(b.palette.warning.main,.06)}},children:"Add to Favorites"}),c&&v&&e.jsx(r.Button,{onClick:y,startIcon:e.jsx(k.Star,{sx:{fontSize:16,color:"#fbbc04"}}),size:"small",variant:"outlined",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2,py:.625,borderRadius:"18px",borderColor:b=>R(b.palette.warning.main,.5),color:"warning.dark","&:hover":{borderColor:"warning.main",bgcolor:b=>R(b.palette.warning.main,.06)}},children:"Remove from Favorites"})]})]})})}const Rc={active:{bg:"#e6f4ea",color:"#137333"},completed:{bg:"#e6f4ea",color:"#137333"},approved:{bg:"#e6f4ea",color:"#137333"},success:{bg:"#e6f4ea",color:"#137333"},done:{bg:"#e6f4ea",color:"#137333"},contract:{bg:"#e8eaf6",color:"#3949ab"},"in progress":{bg:"#e8eaf6",color:"#3949ab"},"in review":{bg:"#e8eaf6",color:"#3949ab"},review:{bg:"#e8eaf6",color:"#3949ab"},pending:{bg:"#e8eaf6",color:"#3949ab"},"on leave":{bg:"#fce8e6",color:"#c5221f"},"on hold":{bg:"#fff8e1",color:"#e65100"},probation:{bg:"#fff8e1",color:"#e65100"},cancelled:{bg:"#fce8e6",color:"#c5221f"},rejected:{bg:"#fce8e6",color:"#c5221f"},blocked:{bg:"#fce8e6",color:"#c5221f"},inactive:{bg:"#f1f3f4",color:"text.secondary"},"not started":{bg:"#f1f3f4",color:"text.secondary"},paused:{bg:"#f1f3f4",color:"text.secondary"}},_c={low:"text.secondary",medium:"#e65100",high:"#e8710a",critical:"#c5221f",urgent:"#c5221f"};function Pc(t){const o=t.toLowerCase().trim(),n=Rc[o]||{bg:"#f1f3f4",color:"text.secondary"};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.bg,color:n.color,whiteSpace:"nowrap",lineHeight:1.5},children:t})}function $c(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 Pc(n);if(/\b(priority|severity|urgency)\b/.test(i)){const a=_c[n.toLowerCase().trim()];return a?e.jsx(r.Box,{component:"span",sx:{color:a,fontWeight:600,fontSize:"0.8125rem"},children:n}):e.jsx(r.Box,{component:"span",sx:{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 Nc(t){const o=t.find(a=>{const l=a.name.toLowerCase();return/\b(name|title|label|subject|task_?name|taskname)\b/.test(l)})||t[0]||null,n=t.find(a=>{const l=a.name.toLowerCase().replace(/[\s_-]/g,"");return/(^id$|id$|_id$|taskid|code$|ref$)/.test(l)&&a!==o})||null,i=t.filter(a=>a!==o&&a!==n).slice(0,4);return{primaryCol:o,idCol:n,bodyColumns:i}}function Fc({row:t,rowIndex:o,visibleColumns:n,isSelected:i,isFavorite:a,isReadOnly:l,onToggleSelection:c,onToggleFavorite:d,onView:u,onEdit:f,onDuplicate:h,onDelete:m}){const[v,w]=p.useState(null),[z,y]=p.useState(!1),{primaryCol:j,idCol:b,bodyColumns:g}=p.useMemo(()=>Nc(n),[n]),S=j?t[j.name]:null,s=b?t[b.name]:null,I=z||i||a||!!v;return e.jsxs(r.Box,{onMouseEnter:()=>y(!0),onMouseLeave:()=>y(!1),onClick:()=>c(o),sx:{position:"relative",display:"flex",flexDirection:"column",bgcolor:"background.paper",border:"1px solid",borderColor:i?"primary.main":A=>R(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 ${R(A.palette.primary.main,.15)}, 0 2px 8px ${R(A.palette.common.black,.08)}`:z?"0 4px 16px rgba(60,64,67,0.15), 0 1px 4px rgba(60,64,67,0.08)":"0 1px 3px rgba(60,64,67,0.08), 0 1px 2px rgba(60,64,67,0.06)",transform:z&&!i?"translateY(-2px)":"none","&:active":{transform:"translateY(0)"},...i&&{bgcolor:A=>R(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:S!=null&&S!==""?String(S):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:[g.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:ct(A.name)}),e.jsx(r.Box,{sx:{flex:1,lineHeight:1},children:$c(A,t[A.name])})]},A.name)),g.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=>R(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:s?.85:0,userSelect:"none"},children:s?String(s):" "}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.25,opacity:I?1:0,transition:"opacity 0.15s ease"},onClick:A=>A.stopPropagation(),children:[d&&e.jsx(r.Tooltip,{title:a?"Remove from favorites":"Add to favorites",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:A=>{A.stopPropagation(),d(t)},sx:{width:28,height:28,color:a?"#fbbc04":"action.disabled","&:hover":{bgcolor:A=>R(A.palette.warning.main,.1),color:"#fbbc04"}},children:a?e.jsx(k.Star,{sx:{fontSize:17}}):e.jsx(k.StarBorder,{sx:{fontSize:17}})})}),e.jsx(r.Tooltip,{title:"More actions",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:A=>{A.stopPropagation(),w(A.currentTarget)},sx:{width:28,height:28,color:"action.active","&:hover":{bgcolor:A=>R(A.palette.text.primary,.08)}},children:e.jsx(k.MoreVert,{sx:{fontSize:17}})})})]})]}),e.jsxs(r.Popover,{open:!!v,anchorEl:v,onClose:()=>w(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},PaperProps:{sx:{minWidth:180,py:.5,borderRadius:"10px",boxShadow:"0 4px 20px rgba(60,64,67,0.15), 0 1px 6px rgba(60,64,67,0.1)"}},onClick:A=>A.stopPropagation(),children:[e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{u(t),w(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[e.jsx(k.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"View"})]}),!l&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{f(t,o),w(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[e.jsx(k.Edit,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Edit"})]}),!l&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{h(o,t),w(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[e.jsx(k.ContentCopy,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Duplicate"})]}),!l&&e.jsxs(e.Fragment,{children:[e.jsx(r.Divider,{sx:{my:.5,mx:.5}}),e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{m(o,t),w(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5,color:"error.main"},children:[e.jsx(k.Delete,{sx:{fontSize:18,color:"error.main"}}),e.jsx(r.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]})]})]})}function Lc({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:"0 1px 2px rgba(60,64,67,0.06)","&:hover":{bgcolor:a=>R(a.palette.primary.main,.04),borderColor:"primary.light"},transition:"all 0.15s ease"},children:[t.isCollapsed?e.jsx(k.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}):e.jsx(k.KeyboardArrowDown,{sx:{fontSize:16,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600,color:"text.primary"},children:Yn(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:a=>R(a.palette.primary.main,.1),color:"primary.main",borderRadius:"10px"},children:[t.rowCount," ",t.rowCount===1?"row":"rows"]}),Object.keys(t.aggregates).length>0&&e.jsx(r.Typography,{variant:"caption",sx:{ml:.5,color:"text.secondary"},children:Object.entries(t.aggregates).map(([a,l])=>Gn(l)).filter(Boolean).join(" • ")})]})}function Vc({data:t,visibleColumns:o,grouping:n,selectedRowIds:i,resolvedFavoritesSet:a,isReadOnly:l,isGrouped:c,sortStack:d=[],onSort:u,onToggleRowSelection:f,onToggleRowFavorite:h,onToggleGroupCollapse:m,onViewRow:v,onEditRow:w,onDuplicateRow:z,onDeleteRow:y}){const j=p.useMemo(()=>{const b=new Set;return i.forEach(g=>{const S=g==null?void 0:g.__urm_row_id__;S!==void 0&&b.add(S)}),b},[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,{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(b=>{const g=d.find(S=>S.column===b.name);return e.jsxs(r.Box,{onClick:()=>u(b.name),sx:{display:"inline-flex",alignItems:"center",gap:.5,px:1.25,py:.375,borderRadius:"6px",border:"1px solid",borderColor:g?"primary.main":"divider",bgcolor:g?S=>R(S.palette.primary.main,.07):"transparent",cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:"primary.light",bgcolor:S=>R(S.palette.primary.main,.05)}},children:[e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",fontWeight:g?600:400,color:g?"primary.main":"text.secondary",whiteSpace:"nowrap"},children:ct(b.name)}),g?g.direction==="asc"?e.jsx(k.ArrowUpward,{sx:{fontSize:12,color:"primary.main"}}):e.jsx(k.ArrowDownward,{sx:{fontSize:12,color:"primary.main"}}):e.jsx(k.SwapVert,{sx:{fontSize:12,color:"text.disabled"}})]},b.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((b,g)=>c&&b.isGroupHeader?e.jsx(Lc,{row:b,grouping:n,onToggleCollapse:m||(()=>{})},`group-${b.groupKey}`):e.jsx(Fc,{row:b,rowIndex:g,visibleColumns:o,isSelected:j.has(b==null?void 0:b.__urm_row_id__),isFavorite:a.has(b),isReadOnly:l,onToggleSelection:()=>f(b),onToggleFavorite:h,onView:v,onEdit:w,onDuplicate:z,onDelete:y},`card-${g}`))})]})}const _n=[10,15,25,50,100];function Hc({currentPage:t,pageSize:o,totalRows:n,totalFields:i,onPageChange:a,onPageSizeChange:l}){const c=Math.ceil(n/o);if(n<=Math.min(..._n))return null;const d=()=>{t>1&&a(t-1)},u=()=>{t<c&&a(t+1)},f=(t-1)*o+1,h=Math.min(t*o,n);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:m=>l(Number(m.target.value)),size:"small",MenuProps:{PaperProps:{sx:{maxHeight:300}},anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"}},sx:{minWidth:70,fontSize:"0.8125rem",color:"text.primary","& .MuiSelect-select":{py:.5,px:1.5},"& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"}},children:_n.map(m=>e.jsx(r.MenuItem,{value:m,sx:{fontSize:"0.8125rem"},children:m},m))})]}),e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400,userSelect:"none",WebkitUserSelect:"none"},children:[f,"–",h," of ",n]}),e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400,userSelect:"none",WebkitUserSelect:"none"},children:["Page ",t," of ",c]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(r.IconButton,{onClick:d,disabled:t===1,size:"small",title:"Previous page",sx:{p:.75,color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"action.disabled"}},children:e.jsx(k.ChevronLeft,{sx:{fontSize:20}})}),e.jsx(r.IconButton,{onClick:u,disabled:t===c,size:"small",title:"Next page",sx:{p:.75,color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"action.disabled"}},children:e.jsx(k.ChevronRight,{sx:{fontSize:20}})})]})]})]})}function Uc(){return e.jsx(r.Chip,{icon:e.jsx(k.Visibility,{sx:{fontSize:14}}),label:"View Only",size:"small",variant:"outlined",sx:{bgcolor:"action.hover",borderColor:"divider",fontSize:"caption.fontSize",fontWeight:500}})}const Si="urm_hint_seen_";function Gc(t){try{return localStorage.getItem(Si+t)==="true"}catch{return!1}}function Yc(t){try{localStorage.setItem(Si+t,"true")}catch{}}function qc(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 Jc({open:t,onClose:o,row:n,schema:i,reportName:a}){if(!n)return null;const l=i.filter(c=>c.name in n);return e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08)"}},children:[e.jsxs(r.Box,{sx:{px:2,py:1.5,bgcolor:"#fff",borderBottom:"1px solid divider",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(r.Stack,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(k.Visibility,{sx:{fontSize:18,color:"primary.main"}}),e.jsx(r.Typography,{variant:"h6",sx:{fontSize:"0.9375rem",fontWeight:500,color:"text.primary"},children:"View Record"})]}),e.jsx(r.IconButton,{size:"small",onClick:o,sx:{p:.5,color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:e.jsx(k.Close,{sx:{fontSize:18}})})]}),e.jsx(r.DialogContent,{sx:{p:0,bgcolor:"grey.50",overflowY:"auto",flex:1},children:e.jsx(r.Box,{children:l.map(c=>{const d=n[c.name],u=qc(d,c.type),f=u==="—";return e.jsxs(r.Box,{sx:{px:2,py:1.25,borderBottom:"1px solid divider",bgcolor:"#fff",transition:"background-color 0.15s ease","&:hover":{bgcolor:"grey.50"},"&:last-child":{borderBottom:"none"}},children:[e.jsx(r.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.6875rem",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.02em",display:"block",mb:.5},children:ct(c.name)}),e.jsx(r.Typography,{variant:"body2",sx:{color:f?"#9e9e9e":"text.primary",fontStyle:f?"italic":"normal",fontSize:"0.875rem",wordBreak:"break-word",whiteSpace:c.type==="object"||c.type==="array"?"pre-wrap":"normal",fontFamily:c.type==="number"?"monospace":"inherit",fontWeight:400,lineHeight:1.5},children:u})]},c.name)})})}),e.jsx(r.DialogActions,{sx:{px:2,py:1.25,borderTop:"1px solid divider",bgcolor:"#fff",gap:1,justifyContent:"flex-end"},children:e.jsx(r.Button,{onClick:o,variant:"contained",sx:{textTransform:"none",fontSize:"0.8125rem",fontWeight:500,bgcolor:"primary.main",color:"#fff",px:2.5,py:.625,minHeight:32,borderRadius:"4px",boxShadow:"none","&:hover":{bgcolor:"primary.dark",boxShadow:"none"}},children:"Close"})})]})}function Kc({open:t,onClose:o,onConfirm:n,rowPreview:i}){return e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",maxHeight:"min(480px, calc(100vh - 180px))",my:"auto",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[e.jsxs(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:"#fce8e6",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(k.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:"#f1f3f4",color:"text.primary"}},children:e.jsx(k.Close,{sx:{fontSize:20}})})]}),e.jsx(r.DialogContent,{sx:{px:3,pb:2},children:e.jsx(r.Box,{sx:{p:2,borderRadius:"8px",bgcolor:"#fce8e6",border:"1px solid #f28b82"},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:"grey.50",gap:1.25,justifyContent:"flex-end"},children:[e.jsx(r.Button,{onClick:o,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:()=>{n(),o()},variant:"contained",startIcon:e.jsx(k.DeleteForever,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"error.main",color:"common.white",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#b3190e",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Delete record"})]})]})}function Xc({open:t,onClose:o,onSave:n,row:i,schema:a,reportName:l}){const[c,d]=p.useState({});if(p.useEffect(()=>{t&&i&&d({...i})},[t,i]),!i)return null;const u=a.filter(v=>v.name in i),f=(v,w)=>{d(z=>({...z,[v]:w}))},h=()=>{const v={...c};u.forEach(w=>{const z=c[w.name];if(w.type==="number"){const y=Number(z);v[w.name]=isNaN(y)?i[w.name]:y}else w.type==="boolean"&&(v[w.name]=!!z)}),n(v),o()},m=v=>{const w=c[v.name],z=ct(v.name);return v.type==="boolean"?e.jsx(r.FormControlLabel,{control:e.jsx(r.Switch,{checked:!!w,onChange:y=>f(v.name,y.target.checked),size:"small",sx:{"& .MuiSwitch-switchBase.Mui-checked":{color:"primary.main"},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{bgcolor:"primary.main"}}}),label:e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.primary",fontWeight:500},children:z}),sx:{m:0,bgcolor:"#fff",px:2,py:1,borderRadius:"4px",border:"1px solid divider"}},v.name):e.jsx(r.TextField,{label:z,value:w??"",onChange:y=>f(v.name,y.target.value),type:v.type==="number"?"number":"text",size:"small",fullWidth:!0,variant:"outlined",InputLabelProps:v.type==="string"&&String(w).match(/^\d{4}-\d{2}-\d{2}/)?{shrink:!0}:void 0,sx:{"& .MuiOutlinedInput-root":{fontSize:"0.8125rem",borderRadius:"4px",bgcolor:"common.white","& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputLabel-root":{fontSize:"0.8125rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiInputBase-input":{color:"text.primary",py:1}}},v.name)};return e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08)"}},children:[e.jsxs(r.Box,{sx:{px:2,py:1.5,bgcolor:"#fff",borderBottom:"1px solid divider",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(r.Stack,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(k.Edit,{sx:{fontSize:18,color:"#ea8600"}}),e.jsx(r.Typography,{variant:"h6",sx:{fontSize:"0.9375rem",fontWeight:500,color:"text.primary"},children:"Edit Record"})]}),e.jsx(r.IconButton,{size:"small",onClick:o,sx:{p:.5,color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:e.jsx(k.Close,{sx:{fontSize:18}})})]}),e.jsx(r.DialogContent,{sx:{p:2,bgcolor:"grey.50",overflowY:"auto",flex:1},children:e.jsx(r.Stack,{spacing:1.5,children:u.map(v=>e.jsx(r.Box,{children:m(v)},v.name))})}),e.jsxs(r.DialogActions,{sx:{px:2,py:1.25,borderTop:"1px solid divider",bgcolor:"#fff",gap:1,justifyContent:"flex-end"},children:[e.jsx(r.Button,{onClick:o,variant:"text",sx:{textTransform:"none",fontSize:"0.8125rem",fontWeight:500,color:"text.secondary",px:2,py:.625,minHeight:32,"&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),e.jsx(r.Button,{onClick:h,variant:"contained",startIcon:e.jsx(k.Save,{sx:{fontSize:16}}),sx:{textTransform:"none",fontSize:"0.8125rem",fontWeight:500,bgcolor:"primary.main",color:"#fff",px:2.5,py:.625,minHeight:32,borderRadius:"4px",boxShadow:"none","&:hover":{bgcolor:"primary.dark",boxShadow:"none"}},children:"Save"})]})]})}const Qc=160,Zc={active:{bg:"success.lighter",color:"success.dark"},completed:{bg:"success.lighter",color:"success.dark"},approved:{bg:"success.lighter",color:"success.dark"},success:{bg:"success.lighter",color:"success.dark"},done:{bg:"success.lighter",color:"success.dark"},contract:{bg:"primary.lighter",color:"primary.main"},"in progress":{bg:"primary.lighter",color:"primary.main"},"in review":{bg:"primary.lighter",color:"primary.main"},review:{bg:"primary.lighter",color:"primary.main"},pending:{bg:"primary.lighter",color:"primary.main"},"on leave":{bg:"error.lighter",color:"error.dark"},"on hold":{bg:"warning.lighter",color:"warning.dark"},probation:{bg:"warning.lighter",color:"warning.dark"},cancelled:{bg:"error.lighter",color:"error.dark"},rejected:{bg:"error.lighter",color:"error.dark"},blocked:{bg:"error.lighter",color:"error.dark"},inactive:{bg:"action.selected",color:"text.secondary"},"not started":{bg:"action.selected",color:"text.secondary"},paused:{bg:"action.selected",color:"text.secondary"}},ed={low:"text.secondary",medium:"warning.dark",high:"warning.main",critical:"error.main",urgent:"error.main"};function td(t){const o=t.toLowerCase().trim(),n=Zc[o]||{bg:"grey.100",color:"grey.600"};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.bg,color:n.color,whiteSpace:"nowrap",lineHeight:1.6,letterSpacing:"0.01em"},children:t})}function rd(t){const o=t.toLowerCase().trim(),n=ed[o];return n?e.jsx(r.Box,{component:"span",sx:{color:n,fontWeight:500,fontSize:"inherit"},children:t}):t}function od(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 nd(t,o){const n=t.name.toLowerCase().replace(/[_\s-]/g,""),i=t.name.toLowerCase(),a=o.findIndex(f=>f.name===t.name),l=/(\bid\b|id$|_id$|code$|ref$|no$|num$)/.test(n),c=i.includes("name")||i.includes("task")||i.includes("title")||i.includes("label")||i.includes("subject")||i.includes("description")||i.includes("filename"),d=i.includes("assignee")||i.includes("assigned")||i.includes("owner")||i.includes("author")||i.includes("creator")||i.includes("member")||i.includes("contact")||i.includes("recipient")||i.includes("sender"),u=a===0&&t.type!=="boolean"&&!i.includes("status")&&!i.includes("state");return l||c&&!d||u&&!d}function id(t){return e.jsx(r.Box,{component:"span",sx:{fontWeight:700,color:"text.primary",fontSize:"inherit"},children:t})}function sd(t,o,n=!1){if(o==null||o==="")return e.jsx(r.Box,{component:"span",sx:{color:"grey.400"},children:"—"});const i=String(o),a=t.name.toLowerCase().replace(/[_\s-]/g,""),l=/\b(status|state|stage|employmenttype|contracttype|availability)\b/.test(t.name.toLowerCase());if(l)return td(i);const c=/\b(priority|severity|urgency|importance|criticality)\b/.test(t.name.toLowerCase());if(c)return rd(i);const d=/(\bid\b|id$|_id$|code$|ref$|no$|num$)/.test(a)||/^[A-Z]{2,8}-\d{2,}$/.test(i);if(d)return od(i);if(n&&!l&&!c&&!d)return id(i);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:"grey.400"},children:"[ ]"});const u=o.slice(0,3).map(f=>typeof f=="object"?JSON.stringify(f):String(f)).join(", ");return e.jsxs(r.Box,{component:"span",sx:{color:"text.secondary",fontSize:"0.8125rem"},children:[u,o.length>3?` +${o.length-3} more`:""]})}if(typeof o=="object"){const u=JSON.stringify(o);return e.jsx(r.Box,{component:"span",title:u,sx:{color:"text.secondary",fontSize:"0.8125rem",fontFamily:"monospace",cursor:"help"},children:u.length>40?u.slice(0,40)+"…":u})}return i}function ad({schema:t,data:o,sortStack:n=[],filters:i=[],views:a=[],activeViewId:l="",isDirty:c=!1,isExporting:d=!1,columnVisibility:u={},columnOrder:f=[],columnWidths:h={},grouping:m=null,onSort:v,onSortAscending:w,onSortDescending:z,onOpenFilters:y,onOpenSort:j,onOpenFilterForColumn:b,onSelectView:g,onCreateView:S,onManageViews:s,onUpdateCurrentView:I,onSaveAsNewView:A,onToggleDefault:H,onToggleFavorite:N,onRestoreView:K,onPermanentDelete:te,onExport:se,onOpenColumns:x,onUpdateColumnWidth:V,onUpdateColumnOrder:$,onUpdateColumnVisibility:J,onClearFiltersForColumn:oe,onResetLayout:ue,onOpenGroup:pe,onToggleGroupCollapse:_,onOpenAuditHistory:O,onOpenScheduledReports:L,searchQuery:re,searchHistory:Q=[],onAddToSearchHistory:X,onToggleSearchFavourite:ae,onDeleteSearchHistory:Z,selectedRowIds:W=new Set,onSearchChange:ee,onToggleRowSelection:ie,onToggleAllRows:ne,onRangeSelection:ke,onClearSelection:U,onExportSelected:Oe,currentPage:Le=1,pageSize:dt=15,totalRowsBeforePagination:$r=o.length,onPageChange:Re,onPageSizeChange:jt,isReadOnly:Ae=!1,userRole:Ge,reportName:Ke,onEditRow:Xe,onDuplicateRow:_e,onDeleteRow:wt,favoriteRowIndices:Yt=[],resolvedFavoritesSet:rt=new Set,showFavoritesOnly:Qe=!1,onToggleRowFavorite:$e,onBulkSetFavorites:dr,showDevPanel:qt=!1,onOpenDevConfig:ot,onToggleFavoritesFilter:kt}){const[At,ut]=p.useState(null),[ur,Nr]=p.useState(0),[Mt,pr]=p.useState(0),[Wt,Ze]=p.useState(null),[Tt,je]=p.useState(null),[xr,zt]=p.useState(null),[nt,P]=p.useState(!1),[et,ge]=p.useState(!1),[Pe,Rt]=p.useState(null),[fr,pt]=p.useState(""),[hr,Ye]=p.useState(!1),[Jt,_t]=p.useState(null),[Kt,Te]=p.useState(null),[F,Me]=p.useState(null),[Ce,it]=p.useState(null),[Ne,mr]=p.useState("list"),[gr,Xt]=p.useState(!1),[yr,br]=p.useState(()=>!Gc("toolbar_search"));p.useRef(null);const Qt=p.useCallback(()=>{Yc("toolbar_search"),br(!1)},[]),Zt=p.useMemo(()=>f.length>0?f.map(D=>t.find(G=>G.name===D)).filter(D=>D!==void 0):t,[f,t]),Ve=p.useMemo(()=>Zt.filter(D=>u[D.name]!==!1),[Zt,u]),st=p.useMemo(()=>t.filter(D=>u[D.name]===!1).length,[t,u]),Pt=p.useMemo(()=>t.map(D=>D.name),[t]),It=p.useMemo(()=>JSON.stringify(f)!==JSON.stringify(Pt),[f,Pt]),xt=p.useCallback((D,G)=>{D.preventDefault(),D.stopPropagation(),ut(G),Nr(D.clientX),pr(h[G]||150)},[h]);p.useEffect(()=>{if(!At)return;const D=de=>{const We=de.clientX-ur,le=Math.max(100,Mt+We);V==null||V(At,le)},G=()=>{ut(null)};return document.addEventListener("mousemove",D),document.addEventListener("mouseup",G),()=>{document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",G)}},[At,ur,Mt,V]);const at=p.useCallback(D=>D==null?"-":typeof D=="object"?JSON.stringify(D):typeof D=="boolean"?D?"true":"false":String(D),[]);p.useCallback(D=>{const G=n.find(de=>de.column===D);return G?e.jsxs(r.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[G.direction==="asc"?e.jsx(k.ArrowUpward,{sx:{fontSize:14}}):e.jsx(k.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:G.priority})]}):null},[n]),p.useCallback(D=>i.some(de=>de.column===D)?e.jsx(r.IconButton,{size:"small",onClick:de=>{de.stopPropagation(),b==null||b(D)},sx:{ml:.5,p:.25,color:"primary.main","&:hover":{color:"primary.main"}},title:"Active filters on this column",children:e.jsx(k.FilterList,{sx:{fontSize:14}})}):null,[i,b]);const $t=p.useCallback(D=>{v&&v(D)},[v]),Nt=p.useCallback((D,G)=>{if(!$)return;const de=[...f.length>0?f:t.map(le=>le.name)],[We]=de.splice(D,1);de.splice(G,0,We),$(de)},[$,f,t]),vr=p.useCallback(D=>{if(!v)return;const G=n.find(de=>de.column===D);(!G||G.direction!=="asc")&&v(D)},[v,n]),Sr=p.useCallback(D=>{if(!v)return;const G=n.find(de=>de.column===D);G?G.direction==="asc"&&v(D):(v(D),setTimeout(()=>v(D),0))},[v,n]),Cr=p.useCallback(D=>{if(!v)return;const G=n.find(de=>de.column===D);G&&(G.direction==="asc"?(v(D),setTimeout(()=>v(D),0)):G.direction==="desc"&&v(D))},[v,n]),jr=p.useCallback(D=>{J&&J(D,!1)},[J]),er=(m==null?void 0:m.enabled)&&o.length>0&&o[0]&&"isGroupHeader"in o[0],wr=(Le-1)*dt,Be=o,ft=p.useMemo(()=>{const D=new Set;return W.forEach(G=>{const de=G==null?void 0:G.__urm_row_id__;de!==void 0&&D.add(de)}),D},[W]);p.useEffect(()=>{const D=G=>{!ne||!U||G.target instanceof HTMLInputElement||G.target instanceof HTMLTextAreaElement||((G.ctrlKey||G.metaKey)&&G.key==="a"&&(G.preventDefault(),ne(!0,Be)),G.key==="Escape"&&(G.preventDefault(),U()))};return document.addEventListener("keydown",D),()=>document.removeEventListener("keydown",D)},[ne,U,Be]);const tr=p.useCallback((D,G)=>{ie&&(G.shiftKey&&Wt!==null?(G.preventDefault(),ke&&ke(Wt,D,Be)):(ie(Be[D]),Ze(D)))},[ie,Wt,ke,Be]);!p.useMemo(()=>Be.length>0&&ft.size>0&&Be.every(D=>ft.has(D==null?void 0:D.__urm_row_id__)),[Be,ft])&&Be.some(D=>ft.has(D==null?void 0:D.__urm_row_id__));const ht=ie&&ne,kr=p.useCallback(D=>{var We;const G=D.groupLevel,de=G*24;return e.jsx(r.TableRow,{onClick:()=>_==null?void 0:_(D.groupKey),sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"},cursor:"pointer",borderTop:2,borderColor:"divider"},children:e.jsx(r.TableCell,{colSpan:Ve.length+(ht?1:0),sx:{pl:`${de+24}px`},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[D.isCollapsed?e.jsx(k.ChevronRight,{sx:{fontSize:16}}):e.jsx(k.KeyboardArrowDown,{sx:{fontSize:16}}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600},children:Yn(G,((We=m==null?void 0:m.levels[G])==null?void 0:We.column)||"",D.groupValue)}),e.jsxs(r.Box,{sx:{px:1,py:.25,fontSize:"caption.fontSize",fontWeight:500,bgcolor:le=>R(le.palette.primary.main,.12),color:"primary.main",borderRadius:2},children:[D.rowCount," ",D.rowCount===1?"row":"rows"]}),Object.keys(D.aggregates).length>0&&e.jsx(r.Typography,{variant:"caption",sx:{ml:1,color:"text.secondary"},children:Object.entries(D.aggregates).map(([le,ce])=>Gn(ce)).filter(Boolean).join(" • ")})]})})},D.groupKey)},[Ve,ht,m,_]),rr=p.useCallback((D,G)=>{const de=ft.has(D==null?void 0:D.__urm_row_id__),We=Tt===G;return e.jsxs(r.TableRow,{"data-row-index":G,onMouseEnter:()=>je(G),onMouseLeave:()=>je(null),onClick:le=>{!ie||le.target.closest("[data-row-action]")||tr(G,le)},onContextMenu:le=>{le.preventDefault(),le.stopPropagation(),Me({mouseX:le.clientX,mouseY:le.clientY,row:D,rowIndex:G})},sx:{height:34,cursor:"pointer",bgcolor:de?le=>R(le.palette.warning.main,.12):"background.paper",transition:"background-color 0.12s ease","&:hover":{bgcolor:de?le=>R(le.palette.warning.main,.2):"action.hover"},borderBottom:"1px solid",borderColor:"divider"},children:[Ve.map((le,ce)=>e.jsx(r.TableCell,{sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",py:"6px",px:2,fontSize:"0.8125rem",fontWeight:400,color:"text.primary",borderBottom:"none",minWidth:h[le.name]?`${h[le.name]}px`:`${Qc}px`},children:sd(le,D[le.name],nd(le,Ve))},le.name)),e.jsxs(r.TableCell,{"data-row-action":"true",onClick:le=>le.stopPropagation(),sx:{position:"sticky",right:0,width:$e?76:40,minWidth:$e?76:40,maxWidth:$e?76:40,p:0,border:"none",bgcolor:"transparent",opacity:We?1:0,transition:"opacity 0.12s ease",zIndex:2,verticalAlign:"middle",display:"flex",alignItems:"center",justifyContent:"flex-end",gap:.25},children:[$e&&e.jsx(r.IconButton,{size:"small",onClick:le=>{le.stopPropagation(),le.preventDefault(),$e(D)},title:rt.has(D)?"Remove from favorites":"Add to favorites",sx:{color:rt.has(D)?"warning.main":"text.secondary","&:hover":{bgcolor:le=>R(le.palette.warning.main,.08),color:"warning.main"}},children:rt.has(D)?e.jsx(k.Star,{sx:{fontSize:18}}):e.jsx(k.StarBorder,{sx:{fontSize:18}})}),e.jsx(r.IconButton,{size:"small",onClick:le=>{le.stopPropagation(),le.preventDefault(),Me({anchorEl:le.currentTarget,row:D,rowIndex:G})},sx:{color:"text.secondary","&:hover":{bgcolor:le=>R(le.palette.text.primary,.08),color:"text.primary"}},children:e.jsx(k.MoreVert,{sx:{fontSize:18}})})]})]},G)},[W,wr,Tt,tr,Ve,h,at,Xe,_e,wt,ie,$e,rt,zt,P,Me]);return e.jsxs(St.DndProvider,{backend:_o.HTML5Backend,children:[e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:[ht&&Oe&&U&&e.jsx(Wc,{selectedCount:W.size,selectedRowIds:W,resolvedFavoritesSet:rt,viewMode:Ne,onExportSelected:Oe,onClearSelection:U,onBulkSetFavorites:dr}),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:[Ae&&e.jsx(Uc,{}),ee&&X&&ae&&Z&&e.jsx(r.Tooltip,{open:yr,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:Qt},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(Dc,{value:re||"",onChange:ee,searchHistory:Q,onAddToHistory:X,onToggleFavourite:ae,onDeleteHistory:Z,disabled:Ae})})}),e.jsx(r.Tooltip,{title:"JSON format guide",children:e.jsx(r.IconButton,{size:"small",onClick:()=>Xt(!0),sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:D=>R(D.palette.text.primary,.06),color:"text.primary"}},children:e.jsx(k.InfoOutlined,{sx:{fontSize:20}})})}),kt&&e.jsx(r.Tooltip,{title:Qe?"Show all data":"Show favorites only",children:e.jsxs(r.IconButton,{onClick:kt,size:"small",disabled:Ae,sx:{position:"relative",color:Qe?"warning.main":"text.secondary",bgcolor:Qe?D=>R(D.palette.warning.main,.12):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:Qe?D=>R(D.palette.warning.main,.2):D=>R(D.palette.text.primary,.06),color:Qe?"warning.main":"text.primary"},"&.Mui-disabled":{color:"action.disabled"}},children:[Qe?e.jsx(k.Star,{sx:{fontSize:20}}):e.jsx(k.StarBorder,{sx:{fontSize:20}}),Qe&&Yt.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:"common.white",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:Yt.length})]})}),qt&&ot&&e.jsx(r.Tooltip,{title:"Developer configuration",children:e.jsx(r.IconButton,{size:"small",onClick:ot,sx:{color:"text.secondary",borderRadius:1,border:"1px dashed",borderColor:D=>R(D.palette.text.secondary,.3),"&:hover":{bgcolor:D=>R(D.palette.warning.main,.08),borderColor:"warning.main",color:"warning.dark"}},children:e.jsx(k.DisplaySettings,{sx:{fontSize:20}})})}),e.jsx(r.Box,{sx:{flexGrow:1}}),g&&S&&s&&I&&a.length>0&&e.jsx(Bc,{views:a||[],activeViewId:l||"",isDirty:c,onSelectView:g,onCreateView:S,onManageViews:s,onToggleDefault:H,onToggleFavorite:N,onRestoreView:K,onPermanentDelete:te,isReadOnly:Ae}),!Ae&&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?"primary.lighter":"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:n.length>0?D=>R(D.palette.primary.main,.2):D=>R(D.palette.text.primary,.06),color:n.length>0?"primary.main":"text.primary"}},children:[e.jsx(k.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:"common.white",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:n.length})]})}),!Ae&&y&&e.jsx(r.Tooltip,{title:"Filter",children:e.jsxs(r.IconButton,{onClick:y,size:"small",sx:{position:"relative",color:i.length>0?"primary.main":"text.secondary",bgcolor:i.length>0?"primary.lighter":"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:i.length>0?D=>R(D.palette.primary.main,.2):D=>R(D.palette.text.primary,.06),color:i.length>0?"primary.main":"text.primary"}},children:[e.jsx(k.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:"common.white",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:i.length})]})}),!Ae&&x&&e.jsx(r.Tooltip,{title:"Columns",children:e.jsxs(r.IconButton,{onClick:x,size:"small",sx:{position:"relative",color:st>0||It?"primary.main":"text.secondary",bgcolor:st>0||It?"primary.lighter":"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:st>0||It?D=>R(D.palette.primary.main,.2):D=>R(D.palette.text.primary,.06),color:st>0||It?"primary.main":"text.primary"}},children:[e.jsx(k.ViewColumn,{sx:{fontSize:20}}),st>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:"common.white",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:st})]})}),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:()=>mr("list"),sx:{borderRadius:1,color:Ne==="list"?"primary.main":"text.secondary",bgcolor:Ne==="list"?"primary.lighter":"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:Ne==="list"?D=>R(D.palette.primary.main,.2):D=>R(D.palette.text.primary,.06),color:Ne==="list"?"primary.main":"text.primary"}},children:e.jsx(k.TableRows,{sx:{fontSize:20}})})}),e.jsx(r.Tooltip,{title:"Grid view",children:e.jsx(r.IconButton,{size:"small",onClick:()=>mr("grid"),sx:{borderRadius:1,color:Ne==="grid"?"primary.main":"text.secondary",bgcolor:Ne==="grid"?"primary.lighter":"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:Ne==="grid"?D=>R(D.palette.primary.main,.2):D=>R(D.palette.text.primary,.06),color:Ne==="grid"?"primary.main":"text.primary"}},children:e.jsx(k.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:D=>it(D.currentTarget),size:"small",sx:{color:"text.secondary",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:D=>R(D.palette.text.primary,.06),color:"text.primary"}},children:e.jsx(k.Settings,{sx:{fontSize:20}})})})]}),e.jsxs(r.Popover,{open:!!Ce,anchorEl:Ce,onClose:()=>it(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:[se&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{se(),it(null)},disabled:d,sx:{py:1,px:2,gap:1.5},children:[e.jsx(k.Download,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Export"})]}),!Ae&&pe&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{pe(),it(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(k.Layers,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Grouping"})]}),O&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{O(),it(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(k.History,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Audit History"})]}),L&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{L(),it(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(k.Schedule,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Scheduled Reports"})]})]}),e.jsxs(r.Box,{sx:{position:"relative",overflow:"hidden",flex:1,display:"flex",flexDirection:"column"},children:[Ne==="grid"&&e.jsx(r.Box,{sx:{flex:1,overflowY:"auto",overflowX:"hidden",bgcolor:"action.hover"},children:e.jsx(Vc,{data:Be,visibleColumns:Ve,grouping:m,selectedRowIds:W,resolvedFavoritesSet:rt,isReadOnly:Ae,isGrouped:!!er,sortStack:n,onSort:v,onToggleRowSelection:ie||(()=>{}),onToggleRowFavorite:$e,onToggleGroupCollapse:_,onViewRow:D=>{zt(D),P(!0)},onEditRow:(D,G)=>{_t(D),Te(G),Ye(!0)},onDuplicateRow:(D,G)=>_e==null?void 0:_e(D,G),onDeleteRow:(D,G)=>{Rt(G);const de=Object.values(G).find(We=>We!=null&&We!=="");pt(de?String(de):""),ge(!0)}})}),Ne==="list"&&e.jsx(r.Box,{sx:{flex:1,overflowY:"auto",overflowX:"auto",position:"relative",bgcolor:"background.paper","&::-webkit-scrollbar":{width:8,height:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:D=>D.palette.mode==="dark"?"rgba(255,255,255,0.2)":"rgba(0,0,0,0.2)",borderRadius:4,"&:hover":{bgcolor:D=>D.palette.mode==="dark"?"rgba(255,255,255,0.3)":"rgba(0,0,0,0.3)"}}},children:e.jsxs(r.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",width:"100%",minWidth:"100%"},stickyHeader:!0,children:[e.jsx(r.TableHead,{children:e.jsxs(r.TableRow,{sx:{height:34,bgcolor:"action.hover",borderBottom:"1px solid",borderColor:"divider"},children:[Ve.map((D,G)=>e.jsx(Mc,{column:D,index:G,sortRule:n.find(de=>de.column===D.name),hasFilters:i.some(de=>de.column===D.name),isInSortStack:n.some(de=>de.column===D.name),width:h[D.name],onColumnClick:$t,onMoveColumn:Nt,onResizeStart:xt,onSort:$t,onRemoveSort:Cr,onSortAscending:vr,onSortDescending:Sr,onOpenFilterForColumn:b||(()=>{}),onClearFiltersForColumn:oe||(()=>{}),onHideColumn:jr,onManageColumns:x||(()=>{}),onManageViews:s||(()=>{}),onResetLayout:ue||(()=>{})},D.name)),e.jsx(r.TableCell,{sx:{position:"sticky",top:0,right:0,width:$e?76:40,minWidth:$e?76:40,p:0,border:"none",bgcolor:"action.hover",borderBottom:"1px solid",borderColor:"divider",zIndex:6}})]})}),e.jsx(r.TableBody,{children:Be.length===0?e.jsx(r.TableRow,{children:e.jsx(r.TableCell,{colSpan:Ve.length+(ht?1:0),align:"center",sx:{py:4},children:e.jsx(r.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})})}):er?Be.map((D,G)=>D.isGroupHeader?kr(D):rr(D,G)):Be.map((D,G)=>rr(D,G))})]})}),Re&&jt&&e.jsx(Hc,{currentPage:Le,pageSize:dt,totalRows:$r,totalFields:t.length,onPageChange:Re,onPageSizeChange:jt}),!(Re&&jt)&&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 ",Be.length," ",Be.length===1?"row":"rows"]})})]})]}),e.jsxs(r.Popover,{open:!!F,onClose:()=>Me(null),anchorEl:(F==null?void 0:F.anchorEl)||null,anchorReference:F!=null&&F.anchorEl?"anchorEl":"anchorPosition",anchorPosition:F&&!F.anchorEl?{top:F.mouseY,left:F.mouseX}:void 0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:F!=null&&F.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:()=>{F&&(zt(F.row),P(!0)),Me(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(k.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"View"})]}),e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{F&&(_t(F.row),Te(F.rowIndex),Ye(!0)),Me(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(k.Edit,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Edit"})]}),e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{F&&(_e==null||_e(F.rowIndex,F.row)),Me(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(k.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(F){Rt(F.row);const D=Object.values(F.row).find(G=>G!=null&&G!=="");pt(D?String(D):""),ge(!0)}Me(null)},sx:{py:1,px:2,gap:1.5,color:"error.main"},children:[e.jsx(k.Delete,{sx:{fontSize:18,color:"error.main"}}),e.jsx(r.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]}),e.jsx(Jc,{open:nt,onClose:()=>{P(!1),zt(null)},row:xr,schema:t,reportName:Ke}),e.jsx(Xc,{open:hr,onClose:()=>{Ye(!1),_t(null),Te(null)},onSave:D=>{Kt!==null&&(Xe==null||Xe(Kt,D))},row:Jt,schema:t,reportName:Ke}),e.jsx(Kc,{open:et,onClose:()=>{ge(!1),Rt(null)},onConfirm:()=>{Pe!==null&&(wt==null||wt(Pe))},rowPreview:fr}),e.jsx(bi,{isOpen:gr,onClose:()=>Xt(!1)})]})}function Ut({content:t,isDev:o=!1}){const[n,i]=p.useState(null);return e.jsxs(e.Fragment,{children:[e.jsx(r.IconButton,{size:"small",onClick:a=>i(a.currentTarget),"aria-label":`Help: ${t.title}`,sx:{p:.375,color:"text.disabled","&:hover":{color:"primary.main",bgcolor:a=>R(a.palette.primary.main,.08)}},children:e.jsx(k.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:a=>R(a.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((a,l)=>e.jsx(r.Box,{component:"li",sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.5},children:a},l))}),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:a=>R(a.palette.warning.main,.08),border:"1px solid",borderColor:a=>R(a.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 Gt={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 ld({schema:t,filters:o,onAddFilter:n,onRemoveFilter:i,onUpdateFilter:a,onClearAll:l,onClose:c,focusColumn:d}){const[u,f]=p.useState(""),[h,m]=p.useState(""),[v,w]=p.useState(""),[z,y]=p.useState([]),j=Rr();p.useEffect(()=>{y([...o])},[o]),p.useEffect(()=>{d&&f(d)},[d]);const b=p.useCallback(()=>{f(""),m(""),w("")},[]),g=p.useMemo(()=>t.filter(x=>x.type!=="mixed"&&x.type!=="null"&&x.type!=="array"&&x.type!=="object"),[t]),S=t.find(x=>x.name===u),s=p.useMemo(()=>{const x=S?an(S.type):[],V=j.filter.allowedOperators;return V.length>0?x.filter($=>V.includes($.value)):x},[S]),I=p.useCallback(()=>!(!u||!h||Ur(h)&&!v.trim()||z.length>=j.filter.maxConditions),[u,h,v,z,j]),A=p.useCallback(()=>{if(!I())return;const x={column:u,operator:h};if(Ur(h)){const $=S==null?void 0:S.type;x.value=$==="number"?Number(v):v}if(z.some($=>$.column===x.column&&$.operator===x.operator&&$.value===x.value)){b();return}y([...z,x]),b()},[I,u,h,S,v,z,b]),H=p.useCallback(x=>{y(z.filter((V,$)=>$!==x))},[z]),N=p.useMemo(()=>z.length!==o.length?!0:JSON.stringify(z)!==JSON.stringify(o),[z,o]),K=p.useCallback(()=>{l(),z.forEach(x=>n(x)),c()},[z,n,l,c]),te=p.useCallback(()=>{y([...o]),b(),c()},[o,b,c]),se=p.useCallback(x=>{var oe;const V=t.find(ue=>ue.name===x.column);if(!V)return"";const J=((oe=an(V.type).find(ue=>ue.value===x.operator))==null?void 0:oe.label)||x.operator;return Ur(x.operator)?`${x.column} ${J.toLowerCase()} "${x.value}"`:`${x.column} ${J.toLowerCase()}`},[t]);return e.jsx(r.Box,{onClick:te,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(r.Paper,{onClick:x=>x.stopPropagation(),elevation:0,sx:{position:"relative",width:520,maxWidth:"calc(100vw - 120px)",maxHeight:"min(520px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"background.paper",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(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(Ut,{content:Gt.filter,isDev:process.env.NODE_ENV==="development"})]}),e.jsx(r.IconButton,{onClick:te,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"grey.100",color:"text.primary"}},children:e.jsx(k.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:"grey.300",borderRadius:4,"&:hover":{bgcolor:"grey.400"}}},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,children:[e.jsx(r.InputLabel,{sx:{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},children:"Column"}),e.jsx(r.Select,{value:u,onChange:x=>{f(x.target.value),m(""),w("")},label:"Column",sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"grey.300",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"}},children:g.map(x=>e.jsxs(r.MenuItem,{value:x.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:V=>R(V.palette.primary.main,.2)}}},children:[ct(x.name)," (",x.type,")"]},x.name))})]}),u&&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:x=>{m(x.target.value),w("")},label:"Operator",sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"grey.300",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"}},children:s.map(x=>e.jsx(r.MenuItem,{value:x.value,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:V=>R(V.palette.primary.main,.2)}}},children:x.label},x.value))})]}),h&&Ur(h)&&e.jsx(r.TextField,{size:"small",fullWidth:!0,type:(S==null?void 0:S.type)==="number"?"number":"text",value:v,onChange:x=>w(x.target.value),label:"Value",placeholder:"Enter value...",sx:{"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"grey.300",transition:"border-color 0.2s ease"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputBase-input":{py:1,color:"text.primary"}}})]}),e.jsx(r.Button,{onClick:A,disabled:!I(),sx:{mt:1.5,textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"primary.main",p:0,justifyContent:"flex-start",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"primary.dark",textDecoration:"underline"},"&.Mui-disabled":{color:"grey.400"}},children:"+ Add another filter"})]}),z.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 (",z.length,")"]}),e.jsx(r.Button,{onClick:()=>y([]),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"error.main",p:0,minWidth:"auto",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"#b3190e",textDecoration:"underline"}},children:"Clear all"})]}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:z.map((x,V)=>e.jsx(r.Chip,{label:se(x),onDelete:()=>H(V),sx:{bgcolor:"primary.lighter",color:"primary.main",fontSize:"0.875rem",fontWeight:400,height:32,borderRadius:"16px",border:$=>`1px solid ${R($.palette.primary.main,.3)}`,transition:"all 0.2s ease","&:hover":{bgcolor:$=>R($.palette.primary.main,.2),borderColor:"#aecbfa"},"& .MuiChip-label":{px:1.5,color:"primary.main"},"& .MuiChip-deleteIcon":{color:"primary.main",fontSize:18,transition:"all 0.2s ease","&:hover":{color:"primary.dark"}}}},V))})]})]}),e.jsxs(r.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"grey.50"},children:[e.jsx(r.Button,{onClick:te,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:K,disabled:!N,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"grey.300",color:"grey.500"}},children:"Apply filter"})]})]})})}const Pn="SORT_RULE";function cd({rule:t,index:o,onToggleDirection:n,onRemove:i,onMove:a}){const l=p.useRef(null),[{handlerId:c},d]=St.useDrop({accept:Pn,collect(h){return{handlerId:h.getHandlerId()}},hover(h,m){var g;if(!l.current)return;const v=h.index,w=o;if(v===w)return;const z=(g=l.current)==null?void 0:g.getBoundingClientRect(),y=(z.bottom-z.top)/2,j=m.getClientOffset(),b=((j==null?void 0:j.y)??0)-z.top;v<w&&b<y||v>w&&b>y||(a(v,w),h.index=w)}}),[{isDragging:u},f]=St.useDrag({type:Pn,item:()=>({index:o}),collect:h=>({isDragging:h.isDragging()})});return f(d(l)),e.jsxs(r.Box,{ref:l,"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:"grey.50",borderColor:"grey.300",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.1), 0 1px 3px 1px rgba(60, 64, 67, 0.05)",transform:"translateY(-1px)"}},children:[e.jsx(r.Chip,{label:t.priority,size:"small",sx:{width:26,height:26,fontSize:"0.75rem",fontWeight:600,bgcolor:"primary.main",color:"background.paper",boxShadow:"0 1px 2px 0 rgba(25, 103, 210, 0.3)","& .MuiChip-label":{px:0}}}),e.jsxs(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:h=>n(o,h.target.value),sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"grey.300",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"& .MuiSelect-select":{py:.875,color:"text.primary",fontWeight:400}},children:[e.jsx(r.MenuItem,{value:"asc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:h=>R(h.palette.primary.main,.2)}}},children:"Ascending"}),e.jsx(r.MenuItem,{value:"desc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:h=>R(h.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:"rgba(217, 48, 37, 0.08)",transform:"scale(1.1)"}},children:e.jsx(k.Close,{sx:{fontSize:18}})})]})}function dd({schema:t,sortStack:o,onUpdateSortStack:n,onClose:i}){const[a,l]=p.useState(""),[c,d]=p.useState([]);p.useEffect(()=>{d([...o])},[o]);const u=Rr(),f=p.useCallback(()=>!(c.length>=u.sort.maxLevels||!a||c.some(g=>g.column===a)),[c,a]),h=p.useCallback(()=>{if(!f())return;const g=c.length+1,S={column:a,direction:"asc",priority:g};d([...c,S]),l("")},[f,a,c]),m=p.useCallback(g=>{const s=c.filter((I,A)=>A!==g).map((I,A)=>({...I,priority:A+1}));d(s)},[c]),v=p.useCallback((g,S)=>{const s=[...c];s[g]={...s[g],direction:S},d(s)},[c]),w=p.useCallback((g,S)=>{const s=[...c],[I]=s.splice(g,1);s.splice(S,0,I);const A=s.map((H,N)=>({...H,priority:N+1}));d(A)},[c]),z=p.useCallback(()=>{d([])},[]),y=p.useCallback(()=>{n(c),i()},[c,n,i]),j=p.useCallback(()=>{d([...o]),l(""),i()},[o,i]),b=t.filter(g=>!c.some(S=>S.column===g.name));return e.jsx(St.DndProvider,{backend:_o.HTML5Backend,children:e.jsx(r.Box,{onClick:j,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(r.Paper,{onClick:g=>g.stopPropagation(),elevation:0,sx:{position:"relative",width:480,maxWidth:"calc(100vw - 120px)",maxHeight:"min(440px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"background.paper",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(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(Ut,{content:Gt.sort,isDev:process.env.NODE_ENV==="development"})]}),e.jsx(r.IconButton,{onClick:j,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"grey.100",color:"text.primary"}},children:e.jsx(k.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:"grey.300",borderRadius:4,"&:hover":{bgcolor:"grey.400"}}},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>=u.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:a,onChange:g=>l(g.target.value),label:"Select column...",sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"grey.300",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-disabled":{bgcolor:"grey.50"}},children:b.map(g=>e.jsx(r.MenuItem,{value:g.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:S=>R(S.palette.primary.main,.2)}}},children:ct(g.name)},g.name))})]}),e.jsx(r.Button,{onClick:h,disabled:!f(),sx:{mt:1.5,textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"primary.main",p:0,justifyContent:"flex-start",minHeight:"auto",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"primary.dark",textDecoration:"underline"},"&.Mui-disabled":{color:"grey.400"}},children:"+ Add sort column"}),c.length>=u.sort.maxLevels&&e.jsxs(r.Typography,{variant:"caption",sx:{mt:.75,display:"block",color:"warning.dark",fontSize:"0.75rem",fontWeight:500},children:["Maximum ",u.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,"/",u.sort.maxLevels,")"]}),e.jsx(r.Button,{onClick:z,sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"error.main",p:0,minWidth:"auto",minHeight:"auto",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"#b3190e",textDecoration:"underline"}},children:"Clear all"})]}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:c.map((g,S)=>e.jsx(cd,{rule:g,index:S,onToggleDirection:v,onRemove:m,onMove:w},`${g.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:"grey.50"},children:[e.jsx(r.Button,{onClick:j,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:y,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Apply sort"})]})]})})})}function ud({views:t,activeViewId:o,onSelectView:n,onCreateView:i,onEditView:a,onDeleteView:l,onRestoreView:c,onPermanentDelete:d,onClose:u}){return e.jsxs(r.Dialog,{open:!0,onClose:u,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{mt:8,borderRadius:"12px",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:["Manage Views",e.jsx(r.IconButton,{onClick:u,size:"small",sx:{color:"text.secondary"},children:e.jsx(k.Close,{sx:{fontSize:20}})})]}),e.jsxs(r.DialogContent,{children:[e.jsx(r.Box,{sx:{mb:2},children:e.jsx(r.Button,{onClick:i,variant:"contained",startIcon:e.jsx(k.Add,{sx:{fontSize:16}}),size:"small",children:"Create New Report View"})}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:t.map(f=>e.jsx(r.Paper,{sx:{p:2,border:1,borderColor:f.isDeleted?"error.light":o===f.id?"primary.main":"divider",bgcolor:f.isDeleted?h=>R(h.palette.error.main,.12):o===f.id?h=>R(h.palette.primary.main,.12):"background.paper",opacity:f.isDeleted?.75:1,cursor:f.isDeleted?"default":"pointer","&:hover":f.isDeleted?{}:{bgcolor:"action.hover"}},onClick:()=>!f.isDeleted&&n(f.id),elevation:0,children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.5},children:[e.jsxs(r.Box,{sx:{flex:1},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,textDecoration:f.isDeleted?"line-through":"none",color:f.isDeleted?"text.secondary":"text.primary"},children:f.name}),f.isDeleted&&e.jsx(r.Chip,{label:"Deleted",size:"small",color:"error",sx:{height:20}}),f.isDefault&&e.jsx(r.Chip,{label:"Default",size:"small",color:"primary",sx:{height:20}}),f.isFavorite&&e.jsx(r.Chip,{label:"★ Favorite",size:"small",sx:{height:20}})]}),f.description&&e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:f.description})]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[!f.isDeleted&&e.jsxs(e.Fragment,{children:[e.jsx(r.IconButton,{size:"small",onClick:h=>{h.stopPropagation(),a(f.id)},title:"Edit view",children:e.jsx(k.Edit,{sx:{fontSize:16}})}),e.jsx(r.IconButton,{size:"small",onClick:h=>{h.stopPropagation(),l(f.id)},title:"Delete view",sx:{"&:hover":{color:"error.main"}},children:e.jsx(k.Delete,{sx:{fontSize:16}})})]}),f.isDeleted&&c&&e.jsx(r.IconButton,{size:"small",onClick:h=>{h.stopPropagation(),c(f.id)},title:"Restore view",sx:{color:"success.main"},children:e.jsx(k.Undo,{sx:{fontSize:16}})}),f.isDeleted&&d&&e.jsx(r.IconButton,{size:"small",onClick:h=>{h.stopPropagation(),d(f.id)},title:"Delete permanently",sx:{color:"error.main"},children:e.jsx(k.Delete,{sx:{fontSize:16}})})]})]})},f.id))})]}),e.jsx(r.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"grey.50",gap:1.25,justifyContent:"flex-end"},children:e.jsx(r.Button,{onClick:u,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"background.paper",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Close"})})]})}function $n({currentSnapshot:t,onSave:o,onClose:n,isEditMode:i=!1,initialName:a="",initialDescription:l="",initialIsDefault:c=!1}){const[d,u]=p.useState(a),[f,h]=p.useState(!1),[m,v]=p.useState(l),[w,z]=p.useState(c),y=()=>{if(!d.trim()){h(!0);return}o(d.trim(),m.trim(),w),n()},j=g=>{g.key==="Enter"&&!g.shiftKey?y():g.key==="Escape"&&n()},b=()=>i&&a?`Update ${a} view`:"Create New Report View";return e.jsxs(r.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{mt:8,borderRadius:"12px",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:[b(),e.jsx(r.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:e.jsx(k.Close,{sx:{fontSize:20}})})]}),e.jsx(r.DialogContent,{children:e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:2,pt:1},children:[e.jsx(r.TextField,{label:"View Name",required:!0,value:d,onChange:g=>{u(g.target.value),f&&g.target.value.trim()&&h(!1)},onKeyDown:j,placeholder:"e.g., Active Users",autoFocus:!0,fullWidth:!0,size:"small",inputProps:{maxLength:100},error:f&&!d.trim(),helperText:f&&!d.trim()?"View name is required":void 0}),e.jsx(r.TextField,{label:"Description (optional)",value:m,onChange:g=>v(g.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: ",gs(t.sortStack)]}),e.jsx("li",{children:"Column order & visibility"})]})]}),!i&&e.jsx(r.FormControlLabel,{control:e.jsx(r.Checkbox,{checked:w,onChange:g=>z(g.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:"grey.50",gap:1.25,justifyContent:"flex-end"},children:[e.jsx(r.Button,{onClick:n,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:y,variant:"contained",startIcon:e.jsx(k.Save,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"background.paper",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"grey.400"}},children:i?"Save Changes":"Create Report View"})]})]})}function pd({viewName:t,onConfirm:o,onCancel:n}){return e.jsxs(r.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",maxHeight:"min(480px, calc(100vh - 180px))",my:"auto",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[e.jsxs(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(k.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(k.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:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"action.selected",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:o,variant:"contained",color:"error",disableElevation:!0,sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Delete View"})]})]})}const Wo=80,Ro=600,Nn="COLUMN";function xd({column:t,index:o,isVisible:n,width:i,onToggleVisibility:a,onWidthChange:l,moveColumn:c}){const d=p.useRef(null),[u,f]=p.useState(i.toString());p.useEffect(()=>{f(i.toString())},[i]);const[{handlerId:h},m]=St.useDrop({accept:Nn,collect(g){return{handlerId:g.getHandlerId()}},hover(g,S){var te;if(!d.current)return;const s=g.index,I=o;if(s===I)return;const A=(te=d.current)==null?void 0:te.getBoundingClientRect(),H=(A.bottom-A.top)/2,N=S.getClientOffset(),K=((N==null?void 0:N.y)??0)-A.top;s<I&&K<H||s>I&&K>H||(c(s,I),g.index=I)}}),[{isDragging:v},w]=St.useDrag({type:Nn,item:()=>({index:o}),collect:g=>({isDragging:g.isDragging()})});w(m(d));const z=()=>{const g=parseInt(u);if(isNaN(g)){f(i.toString()),l(t.name,i);return}const S=Math.max(Wo,Math.min(Ro,g));f(S.toString()),l(t.name,S)},y=g=>{if(g===""||/^\d+$/.test(g)){f(g);const S=parseInt(g);if(!isNaN(S)&&S>=Wo){const s=Math.min(Ro,S);l(t.name,s)}}},j=g=>{g.key==="Enter"&&(g.preventDefault(),z(),g.target.blur())},b=g=>({string:"primary.main",number:"success.main",boolean:"#9334e6",array:"#ea8600",object:"error.main",null:"text.secondary",mixed:"text.secondary"})[g]||"text.secondary";return e.jsxs(r.TableRow,{ref:d,"data-handler-id":h,sx:{opacity:v?.4:1,bgcolor:n?"background.paper":"grey.50",transition:"all 0.2s ease","&:hover":{bgcolor:n?"grey.50":"grey.100"},cursor:"move",height:56,borderBottom:"1px solid divider"},children:[e.jsx(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(k.DragIndicator,{sx:{fontSize:20}})}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:400,fontSize:"0.875rem",color:n?"text.primary":"text.secondary"},children:ct(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:`${b(t.type)}15`,color:b(t.type),border:`1px solid ${b(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:"text",value:u,onChange:g=>y(g.target.value),onBlur:z,onKeyDown:j,placeholder:"150",size:"small",sx:{width:80,"& .MuiOutlinedInput-root":{height:32,fontSize:"0.8125rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"grey.300"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputBase-input":{py:.5,px:1.25,color:"text.primary"}}}),e.jsx(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:()=>a(t.name,!n),title:n?"Hide column":"Show column",size:"small",sx:{p:.75,color:n?"primary.main":"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"grey.100",color:n?"primary.dark":"primary.main"}},children:n?e.jsx(k.Visibility,{sx:{fontSize:20}}):e.jsx(k.VisibilityOff,{sx:{fontSize:20}})}),e.jsx(r.Chip,{label:n?"Visible":"Hidden",size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:500,bgcolor:n?"#e6f4ea":"grey.100",color:n?"success.main":"text.secondary","& .MuiChip-label":{px:1}}})]})})]})}function fd({schema:t,columnVisibility:o,columnOrder:n,columnWidths:i={},views:a=[],activeViewId:l="",onUpdateColumnVisibility:c,onUpdateColumnOrder:d,onUpdateColumnWidth:u,onResetLayout:f,onSaveToCurrentView:h,onSaveToAllViews:m,onSelectView:v,onClose:w}){const[z,y]=p.useState(!1),[j,b]=p.useState(n),[g,S]=p.useState(i),[s,I]=p.useState("all"),[A,H]=p.useState(null);p.useEffect(()=>{b(n)},[n]),p.useEffect(()=>{S(i)},[i]);const N=(_,O)=>{S(L=>({...L,[_]:O}))},K=(_,O)=>{const L=[...j],[re]=L.splice(_,1);L.splice(O,0,re),b(L),d(L)},te=()=>{f(),y(!1)},x=j.map(_=>t.find(O=>O.name===_)).filter(_=>_!==void 0).filter(_=>{const O=o[_.name]??!0;return s==="active"?O:s==="hidden"?!O:!0}),V=Object.values(o).filter(_=>_).length,$=t.length,J=a.find(_=>_.id===l),oe=a.filter(_=>!_.isDeleted),ue=oe.length>1,pe=p.useMemo(()=>{if(!J)return!1;const _=J.snapshot,O=JSON.stringify(o)!==JSON.stringify(_.columnVisibility),L=JSON.stringify(n)!==JSON.stringify(_.columnOrder),re=JSON.stringify(g)!==JSON.stringify(_.columnWidths);return O||L||re},[J,o,n,g]);return e.jsx(St.DndProvider,{backend:_o.HTML5Backend,children:e.jsx(r.Box,{onClick:w,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(r.Paper,{onClick:_=>_.stopPropagation(),elevation:0,sx:{position:"relative",width:720,maxWidth:"calc(100vw - 120px)",maxHeight:"min(760px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"background.paper",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(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(Ut,{content:Gt.columns,isDev:process.env.NODE_ENV==="development"})]}),e.jsxs(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary",mt:.5},children:[V," of ",$," columns visible • Drag to reorder"]})]}),oe.length>0&&v&&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:_=>H(_.currentTarget),variant:"outlined",size:"small",endIcon:e.jsx(k.KeyboardArrowDown,{sx:{fontSize:18}}),sx:{minWidth:180,justifyContent:"space-between",textTransform:"none",fontSize:"0.875rem",fontWeight:400,color:"text.primary",borderColor:"grey.300",py:.75,px:1.5,"&:hover":{borderColor:"primary.main",bgcolor:"grey.50"}},children:e.jsx(r.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis"},children:(J==null?void 0:J.name)||"Select View"})}),e.jsx(r.Menu,{anchorEl:A,open:!!A,onClose:()=>H(null),PaperProps:{sx:{mt:.5,borderRadius:"8px",boxShadow:"0 2px 6px rgba(60, 64, 67, 0.15)"}},children:oe.map(_=>e.jsx(r.MenuItem,{onClick:()=>{v(_.id),H(null)},selected:_.id===l,sx:{fontSize:"0.875rem",color:"text.primary",py:1,px:2,"&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:O=>R(O.palette.primary.main,.2)}}},children:_.name},_.id))})]}),e.jsx(r.IconButton,{onClick:w,size:"small",sx:{ml:2,p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"grey.100",color:"text.primary"}},children:e.jsx(k.Close,{sx:{fontSize:20}})})]}),e.jsxs(r.Tabs,{value:s,onChange:(_,O)=>I(O),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:"grey.300",borderRadius:4,"&:hover":{bgcolor:"grey.400"}}},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:"grey.50",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:"grey.50",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:"grey.50",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: ${Wo}px, max: ${Ro}px)`,arrow:!0,placement:"top",children:e.jsx(k.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:"grey.50",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid divider"},children:"Visibility"})]})}),e.jsx(r.TableBody,{children:x.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"})})}):x.map((_,O)=>e.jsx(xd,{column:_,index:O,isVisible:o[_.name]??!0,width:g[_.name]||150,onToggleVisibility:c,onWidthChange:N,moveColumn:K},_.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:"grey.50"},children:[e.jsx(r.Button,{onClick:()=>y(!0),disabled:!pe,variant:"outlined",startIcon:e.jsx(k.Undo,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",borderColor:"grey.300",px:2.5,py:.875,minHeight:36,borderRadius:"4px","&:hover":{borderColor:"primary.main",bgcolor:"background.paper",color:"primary.main"},"&.Mui-disabled":{color:"grey.400",borderColor:"divider"}},children:"Reset to default"}),e.jsxs(r.Stack,{direction:"row",spacing:1.25,children:[h&&e.jsx(r.Button,{onClick:()=>{h(g),w()},disabled:!pe,variant:"contained",startIcon:e.jsx(k.Save,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"background.paper",px:2.5,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"grey.400"}},children:"Save to current view"}),m&&ue&&e.jsx(r.Button,{onClick:()=>{m(g),w()},disabled:!pe||!ue,variant:"contained",startIcon:e.jsx(k.GridView,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"success.main",color:"background.paper",px:2.5,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"success.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"grey.400"}},children:"Save to all views"})]})]}),z&&e.jsx(r.Box,{onClick:()=>y(!1),sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1400},children:e.jsxs(r.Paper,{onClick:_=>_.stopPropagation(),elevation:0,sx:{width:400,maxWidth:"90vw",borderRadius:"12px",bgcolor:"background.paper",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"},children:[e.jsxs(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:"grey.50"},children:[e.jsx(r.Button,{onClick:()=>y(!1),variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",px:3,py:1,borderRadius:"4px","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:te,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"error.main",color:"background.paper",px:3,py:1,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)","&:hover":{bgcolor:"#b3190e",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Reset layout"})]})]})})]})})})}function hd({schema:t,grouping:o,onApply:n,onClose:i}){var A;const[a,l]=p.useState(o||{enabled:!1,levels:[],collapsedGroups:[]}),[c,d]=p.useState(""),[u,f]=p.useState(null),h=p.useMemo(()=>us(t),[t]),m=p.useMemo(()=>h.filter(H=>!a.levels.some((N,K)=>N.column===H.name&&K!==u)),[h,a.levels,u]),v=Rr(),w=a.levels.length<v.grouping.maxLevels&&m.length>0,z=p.useCallback(()=>{!w||!c||(l({...a,levels:[...a.levels,{column:c}],enabled:!0}),d(""))},[w,c,a]),y=p.useCallback(H=>{const N=a.levels.filter((K,te)=>te!==H);if(N.length===0){n(null),i();return}l({...a,levels:N,enabled:N.length>0})},[a,n,i]),j=p.useCallback(H=>{f(H),d(a.levels[H].column)},[a.levels]),b=p.useCallback(()=>{if(u===null||!c)return;const H=[...a.levels];H[u]={column:c},l({...a,levels:H}),f(null),d("")},[u,c,a]),g=p.useCallback(()=>{f(null),d("")},[]),S=p.useCallback((H,N)=>{const K=N==="up"?H-1:H+1;if(K<0||K>=a.levels.length)return;const te=[...a.levels],[se]=te.splice(H,1);te.splice(K,0,se),l({...a,levels:te})},[a]),s=p.useCallback(()=>{n(null),i()},[n,i]),I=p.useCallback(()=>{a.levels.length===0?n(null):n({...a,enabled:!0,collapsedGroups:(o==null?void 0:o.collapsedGroups)||[]}),i()},[a,o,n,i]);return e.jsx(r.Box,{onClick:i,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(r.Paper,{onClick:H=>H.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(560px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"background.paper",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(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"}),e.jsx(Ut,{content:Gt.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:"grey.100",color:"text.primary"}},children:e.jsx(k.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:"grey.300",borderRadius:4,"&:hover":{bgcolor:"grey.400"}}},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:H=>d(H.target.value),disabled:!w,displayEmpty:!0,sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"grey.300",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-disabled":{bgcolor:"grey.50"}},children:[e.jsx(r.MenuItem,{value:"",sx:{fontSize:"0.875rem",color:"text.secondary"},children:"Select a column..."}),m.map(H=>e.jsxs(r.MenuItem,{value:H.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:N=>R(N.palette.primary.main,.2)}}},children:[ct(H.name)," (",H.type.toUpperCase(),")"]},H.name))]})}),e.jsx(r.Button,{onClick:z,disabled:!w||!c,variant:"outlined",startIcon:e.jsx(k.Add,{sx:{fontSize:18}}),fullWidth:!0,sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"primary.main",borderColor:"grey.300",py:1,transition:"all 0.2s ease","&:hover":{borderColor:"primary.main",bgcolor:"grey.50"},"&.Mui-disabled":{color:"grey.400",borderColor:"divider"}},children:"Add group level"}),a.levels.length>=v.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"}),h.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:"1px solid #fdd663",bgcolor:"#fef7e0","& .MuiAlert-icon":{color:"#ea8600"}},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:H=>d(H.target.value),sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"grey.300"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"}},children:[e.jsx(r.MenuItem,{value:"",sx:{fontSize:"0.875rem"},children:"Select a column..."}),e.jsxs(r.MenuItem,{value:a.levels[u].column,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:"primary.lighter"}},children:[a.levels[u].column," (",(A=t.find(H=>H.name===a.levels[u].column))==null?void 0:A.type.toUpperCase(),")"]}),m.filter(H=>H.name!==a.levels[u].column).map(H=>e.jsxs(r.MenuItem,{value:H.name,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:"primary.lighter"}},children:[ct(H.name)," (",H.type.toUpperCase(),")"]},H.name))]})}),e.jsxs(r.Stack,{direction:"row",spacing:1.5,children:[e.jsx(r.Button,{onClick:b,disabled:!c,variant:"contained",fullWidth:!0,size:"small",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#ea8600",color:"background.paper",py:.875,boxShadow:"none","&:hover":{bgcolor:"#c96e00",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)"}},children:"Save"}),e.jsx(r.Button,{onClick:g,variant:"outlined",fullWidth:!0,size:"small",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",borderColor:"grey.300",py:.875,"&:hover":{borderColor:"grey.400",bgcolor:"grey.50"}},children:"Cancel"})]})]}),a.levels.length>0&&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:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"error.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",color:"#b3190e",textDecoration:"underline"}},children:"Clear all"})]}),e.jsx(r.Stack,{spacing:1.5,children:a.levels.map((H,N)=>{const K=t.find(te=>te.name===H.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:"grey.50",borderColor:"grey.300",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.1)"}},children:[e.jsx(r.Chip,{label:`L${N+1}`,size:"small",sx:{width:40,height:28,fontWeight:600,fontSize:"0.75rem",bgcolor:"primary.main",color:"background.paper",boxShadow:"0 1px 2px 0 rgba(25, 103, 210, 0.3)"}}),e.jsxs(r.Box,{sx:{flex:1},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:H.column}),e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},children:K==null?void 0:K.type.toUpperCase()})]}),e.jsxs(r.Stack,{direction:"row",spacing:.5,children:[e.jsx(r.IconButton,{size:"small",onClick:()=>S(N,"up"),disabled:N===0,sx:{color:"text.secondary","&:hover":{bgcolor:"grey.100"},"&.Mui-disabled":{color:"divider"}},children:e.jsx(k.KeyboardArrowUp,{sx:{fontSize:18}})}),e.jsx(r.IconButton,{size:"small",onClick:()=>S(N,"down"),disabled:N===a.levels.length-1,sx:{color:"text.secondary","&:hover":{bgcolor:"grey.100"},"&.Mui-disabled":{color:"divider"}},children:e.jsx(k.KeyboardArrowDown,{sx:{fontSize:18}})}),e.jsx(r.IconButton,{size:"small",onClick:()=>j(N),sx:{color:"text.secondary","&:hover":{bgcolor:"grey.100",color:"primary.main"}},children:e.jsx(k.Edit,{sx:{fontSize:18}})}),e.jsx(r.IconButton,{size:"small",onClick:()=>y(N),sx:{color:"text.secondary","&:hover":{bgcolor:"rgba(217, 48, 37, 0.08)",color:"error.main"}},children:e.jsx(k.Delete,{sx:{fontSize:18}})})]})]},N)})})]})]})}),e.jsxs(r.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"grey.50"},children:[e.jsx(r.Button,{onClick:i,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:I,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Apply grouping"})]})]})})}const md={filters:k.FilterList,sorting:k.UnfoldMore,visibility:k.Visibility,order:k.ViewColumn,widths:k.Straighten,grouping:k.Layers};function gd({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:"12px",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[e.jsxs(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(k.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,a)=>{const l=md[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(l,{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})]})]},a)})})]})}),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:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"common.white",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Close"})})]})}function yd({viewName:t,isDefaultView:o,changes:n=[],onSaveToCurrentView:i,onSaveAsNewView:a,onCancel:l}){const[c,d]=p.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{width:"100%",flexShrink:0,bgcolor:"primary.lighter",borderBottom:u=>`1px solid ${R(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:l,variant:"text",size:"small",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2,py:.625,borderRadius:"18px",color:"text.secondary",bgcolor:"transparent",minHeight:32,"&:hover":{bgcolor:"rgba(60, 64, 67, 0.08)",color:"text.primary"}},children:"Discard"}),e.jsx(r.Button,{onClick:a,variant:"contained",size:"small",disableElevation:!0,sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2.5,py:.625,borderRadius:"18px",minHeight:32,boxShadow:"none","&:hover":{boxShadow:"0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px rgba(60, 64, 67, 0.15)"}},children:"Save as new view"})]})]})}),c&&e.jsx(gd,{changes:n,onClose:()=>d(!1)})]})}function bd({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(k.Warning,{sx:{fontSize:20}}),action:e.jsx(r.IconButton,{size:"small",onClick:n,sx:{color:"warning.main"},children:e.jsx(k.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(k.Save,{sx:{fontSize:14}}),size:"small",children:"Save View & Export"}),e.jsx(r.Button,{onClick:t,variant:"contained",color:"warning",startIcon:e.jsx(k.Download,{sx:{fontSize:14}}),size:"small",children:"Export Anyway"})]})]})})}function vd({auditHistory:t,onClose:o}){const[n,i]=p.useState(new Set),a=c=>{i(d=>{const u=new Set(d);return u.has(c)?u.delete(c):u.add(c),u})},l=[...t].sort((c,d)=>new Date(d.timestamp).getTime()-new Date(c.timestamp).getTime());return e.jsx(r.Box,{onClick:o,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(r.Paper,{onClick:c=>c.stopPropagation(),elevation:0,sx:{position:"relative",width:480,maxWidth:"calc(100vw - 120px)",maxHeight:"min(720px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"background.paper",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsxs(r.Box,{children:[e.jsxs(r.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:["Audit history",e.jsx(Ut,{content:Gt.auditHistory,isDev:process.env.NODE_ENV==="development"})]}),e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",mt:.5,display:"block"},children:[l.length," event",l.length!==1?"s":""," recorded"]})]}),e.jsx(r.IconButton,{onClick:o,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"grey.100",color:"text.primary"}},children:e.jsx(k.Close,{sx:{fontSize:20}})})]}),e.jsx(r.Box,{sx:{flex:1,overflow:"auto",px:2,py:1,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"grey.300",borderRadius:4,"&:hover":{bgcolor:"grey.400"}}},children:l.length===0?e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8,textAlign:"center"},children:[e.jsx(k.AccessTime,{sx:{fontSize:64,color:"divider",mb:2}}),e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"text.secondary",mb:.5},children:"No audit events recorded yet"}),e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"grey.400"},children:"Changes to this report will appear here"})]}):e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1.5},children:l.map(c=>{const d=n.has(c.id),u=Os(c.feature);return e.jsxs(r.Paper,{elevation:0,sx:{border:"1px solid divider",borderRadius:"8px",overflow:"hidden",transition:"all 0.2s ease","&:hover":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.1)",borderColor:"grey.300"}},children:[e.jsxs(r.Box,{onClick:()=>a(c.id),sx:{px:2.5,py:1.75,display:"flex",alignItems:"center",gap:1.5,cursor:"pointer",bgcolor:"background.paper",transition:"background-color 0.2s ease","&:hover":{bgcolor:"grey.50"}},children:[e.jsx(r.Box,{sx:{flexShrink:0,color:"text.secondary",transition:"transform 0.2s ease",transform:"rotate(0deg)"},children:d?e.jsx(k.KeyboardArrowDown,{sx:{fontSize:20}}):e.jsx(k.ChevronRight,{sx:{fontSize:20}})}),e.jsx(r.Chip,{label:Bs(c.feature),size:"small",sx:{height:24,fontSize:"0.6875rem",fontWeight:600,bgcolor:`${u}15`,color:u,border:`1px solid ${u}30`,"& .MuiChip-label":{px:1}}}),e.jsx(r.Typography,{variant:"body2",sx:{flex:1,fontWeight:400,fontSize:"0.875rem",color:"text.primary"},children:Ds(c.action)}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75,flexShrink:0},children:[e.jsx(k.AccessTime,{sx:{fontSize:16,color:"text.secondary",opacity:.6}}),e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},children:As(c.timestamp)})]}),c.user&&e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75,flexShrink:0},children:[e.jsx(k.Person,{sx:{fontSize:16,color:"text.secondary",opacity:.6}}),e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},children:c.user})]})]}),e.jsx(r.Collapse,{in:d,timeout:200,children:e.jsxs(r.Box,{sx:{px:2.5,pb:2,pt:1.5,borderTop:"1px solid divider",bgcolor:"grey.50"},children:[c.previousState&&e.jsxs(r.Box,{sx:{mb:2},children:[e.jsx(r.Typography,{variant:"caption",sx:{fontWeight:600,fontSize:"0.6875rem",color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.1em",mb:1,display:"block"},children:"Previous state"}),e.jsx(r.Box,{component:"pre",sx:{fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Courier New", monospace',bgcolor:"background.paper",border:"1px solid grey.300",borderRadius:"4px",p:1.5,overflow:"auto",maxHeight:200,color:"text.primary",lineHeight:1.6,"&::-webkit-scrollbar":{width:6,height:6},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"grey.300",borderRadius:3}},children:rn(c.previousState)})]}),c.newState&&e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"caption",sx:{fontWeight:600,fontSize:"0.6875rem",color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.1em",mb:1,display:"block"},children:"New state"}),e.jsx(r.Box,{component:"pre",sx:{fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Courier New", monospace',bgcolor:"background.paper",border:"1px solid grey.300",borderRadius:"4px",p:1.5,overflow:"auto",maxHeight:200,color:"text.primary",lineHeight:1.6,"&::-webkit-scrollbar":{width:6,height:6},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"grey.300",borderRadius:3}},children:rn(c.newState)})]})]})})]},c.id)})})})]})})}function Sd({onSave:t,onClose:o}){const[n,i]=p.useState(""),[a,l]=p.useState(""),[c,d]=p.useState(""),[u,f]=p.useState([]),[h,m]=p.useState(""),[v,w]=p.useState(""),z=I=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(I),y=()=>{const I=c.trim();if(I){if(!z(I)){w("Please enter a valid email address");return}if(u.includes(I)){w("This email is already added");return}f([...u,I]),d(""),w("")}},j=I=>{f(u.filter(A=>A!==I))},b=I=>{I.key==="Enter"&&(I.preventDefault(),y())},g=()=>{if(!n.trim()){m("Preset name is required");return}t(n.trim(),a.trim(),u.length>0?u:void 0)},S=I=>{i(I),h&&m("")},s=I=>{d(I),v&&w("")};return e.jsx(r.Box,{onClick:o,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(r.Paper,{onClick:I=>I.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(480px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"background.paper",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(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:"grey.100",color:"text.primary"}},children:e.jsx(k.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:"grey.300",borderRadius:4,"&:hover":{bgcolor:"grey.400"}}},children:e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[e.jsx(r.Alert,{severity:"info",icon:e.jsx(k.Info,{sx:{fontSize:20}}),sx:{borderRadius:"8px",border:I=>`1px solid ${R(I.palette.primary.main,.3)}`,bgcolor:"primary.lighter","& .MuiAlert-icon":{color:"primary.main"},"& .MuiAlert-message":{fontSize:"0.8125rem",color:"text.primary",lineHeight:1.5}},children:"This preset will capture filters, sorting, grouping, column configuration, and the active view. The actual data is not saved or shared."}),e.jsx(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:I=>S(I.target.value),placeholder:"e.g., Q4 Active Users Report",error:!!h,helperText:h,autoFocus:!0,fullWidth:!0,size:"small",sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"grey.300"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-error fieldset":{borderColor:"error.main"}},"& .MuiInputBase-input":{py:1.25,color:"text.primary"},"& .MuiFormHelperText-root":{fontSize:"0.75rem",color:"error.main",mt:.75}}})]}),e.jsxs(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:a,onChange:I=>l(I.target.value),placeholder:"Briefly describe what this preset shows...",multiline:!0,rows:3,fullWidth:!0,size:"small",sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"grey.300"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputBase-input":{py:1.25,color:"text.primary",lineHeight:1.6}}})]}),e.jsxs(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:I=>s(I.target.value),onKeyPress:b,placeholder:"Enter email address",error:!!v,helperText:v,fullWidth:!0,size:"small",InputProps:{startAdornment:e.jsx(k.Email,{sx:{fontSize:18,color:"text.secondary",mr:1}})},sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"grey.300"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-error fieldset":{borderColor:"error.main"}},"& .MuiInputBase-input":{py:1.25,color:"text.primary"},"& .MuiFormHelperText-root":{fontSize:"0.75rem",color:"error.main",mt:.75}}}),e.jsx(r.Button,{onClick:y,variant:"outlined",startIcon:e.jsx(k.Add,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"primary.main",borderColor:"grey.300",px:2,py:1.25,minHeight:40,borderRadius:"4px",flexShrink:0,"&:hover":{borderColor:"primary.main",bgcolor:"grey.50"}},children:"Add"})]}),u.length>0&&e.jsx(r.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1,mt:1.5},children:u.map(I=>e.jsx(r.Chip,{label:I,onDelete:()=>j(I),deleteIcon:e.jsx(k.Delete,{sx:{fontSize:16}}),sx:{bgcolor:"primary.lighter",color:"primary.main",fontSize:"0.8125rem",height:28,"& .MuiChip-deleteIcon":{color:"primary.main","&:hover":{color:"primary.dark"}}}},I))}),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:"grey.50"},children:[e.jsx(r.Button,{onClick:o,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:g,variant:"contained",startIcon:e.jsx(k.Share,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Create & share"})]})]})})}function Cd({presetName:t,onClear:o}){return e.jsx(r.Chip,{icon:e.jsx(k.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(k.Close,{sx:{fontSize:14}})}),sx:{bgcolor:n=>R(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 jd({presets:t,reportId:o,onOpenPreset:n,onDeletePreset:i,onClose:a}){const[l,c]=p.useState(null),d=u=>new Date(u).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});return e.jsx(r.Box,{onClick:a,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(r.Paper,{onClick:u=>u.stopPropagation(),elevation:0,sx:{position:"relative",width:680,maxWidth:"calc(100vw - 120px)",maxHeight:"min(720px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"common.white",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(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:a,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"#f1f3f4",color:"text.primary"}},children:e.jsx(k.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:"#bdc1c6"}}},children:t.length===0?e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8},children:[e.jsx(k.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:"#80868b",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(u=>e.jsxs(r.Paper,{elevation:0,sx:{p:2.5,border:"1px solid divider",borderRadius:"8px",bgcolor:"common.white",transition:"all 0.2s ease","&:hover":{borderColor:"divider",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.1), 0 1px 3px 1px rgba(60, 64, 67, 0.05)"}},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:u.name}),u.description&&e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.5},children:u.description})]})}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:2},children:[e.jsx(r.Chip,{label:`Created ${d(u.createdAt)}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"#f1f3f4",color:"text.secondary","& .MuiChip-label":{px:1}}}),e.jsx(r.Chip,{label:`By ${u.createdBy}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"#f1f3f4",color:"text.secondary","& .MuiChip-label":{px:1}}})]}),e.jsx(r.Divider,{sx:{my:1.5,borderColor:"#f1f3f4"}}),e.jsx(r.Box,{sx:{display:"flex",gap:1},children:e.jsx(r.Button,{onClick:()=>i(u.id,u.name),variant:"outlined",size:"small",startIcon:e.jsx(k.Delete,{sx:{fontSize:16}}),sx:{textTransform:"none",fontSize:"0.8125rem",fontWeight:500,color:"error.main",borderColor:"divider",px:1.5,py:.75,borderRadius:"4px","&:hover":{borderColor:"error.main",bgcolor:"rgba(217, 48, 37, 0.04)"}},children:"Delete"})})]},u.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:a,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"common.white",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Close"})})]})})}function wd({totalRows:t,visibleRows:o,hasGrouping:n,visibleColumnsCount:i,totalColumnsCount:a,onExport:l,onClose:c}){const d=Rr(),[u,f]=p.useState(d.export.allowedFormats[0]||"csv"),[h,m]=p.useState("visible"),[v,w]=p.useState("visible"),z=t>5e4,y=h==="visible"?o:t,j=v==="visible"?i:a,b=()=>{l({format:u,scope:h,columnScope:v}),c()},g={csv:"CSV",excel:"Excel (.xlsx)",json:"JSON"};return e.jsx(r.Box,{onClick:c,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(r.Paper,{onClick:S=>S.stopPropagation(),elevation:0,sx:{position:"relative",width:480,maxWidth:"calc(100vw - 120px)",maxHeight:"min(620px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"common.white",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(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:"Export report"}),e.jsx(Ut,{content:Gt.export,isDev:process.env.NODE_ENV==="development"})]}),e.jsx(r.IconButton,{onClick:c,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"#f1f3f4",color:"text.primary"}},children:e.jsx(k.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:"divider",borderRadius:4,"&:hover":{bgcolor:"#bdc1c6"}}},children:e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[z&&e.jsxs(r.Alert,{severity:"warning",icon:e.jsx(k.Warning,{sx:{fontSize:20}}),sx:{borderRadius:"8px",border:"1px solid #fdd663",bgcolor:"#fef7e0","& .MuiAlert-icon":{color:"#ea8600"},"& .MuiAlertTitle-root":{fontSize:"0.875rem",fontWeight:500,color:"text.primary",mb:.5},"& .MuiAlert-message":{fontSize:"0.8125rem",color:"text.secondary"}},children:[e.jsx(r.AlertTitle,{children:"Large dataset warning"}),"This export contains over 50,000 rows. Processing may take a few moments."]}),e.jsxs(r.FormControl,{component:"fieldset",children:[e.jsx(r.FormLabel,{component:"legend",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,textTransform:"uppercase"},children:"Format"}),e.jsxs(r.RadioGroup,{value:u,onChange:S=>f(S.target.value),children:[d.export.allowedFormats.includes("csv")&&e.jsx(r.FormControlLabel,{value:"csv",control:e.jsx(r.Radio,{size:"small",sx:{color:"text.secondary","&.Mui-checked":{color:"primary.main"}}}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"CSV"}),e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},children:"Comma-separated values, compatible with Excel"})]}),sx:{mb:1.25,alignItems:"flex-start",px:1.5,py:1,borderRadius:"8px",transition:"background-color 0.2s ease","&:hover":{bgcolor:"#f8f9fa"}}}),d.export.allowedFormats.includes("excel")&&e.jsx(r.FormControlLabel,{value:"excel",control:e.jsx(r.Radio,{size:"small",sx:{color:"text.secondary","&.Mui-checked":{color:"primary.main"}}}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"Excel (.xlsx)"}),e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},children:"Native Excel format with formatting support"})]}),sx:{mb:1.25,alignItems:"flex-start",px:1.5,py:1,borderRadius:"8px",transition:"background-color 0.2s ease","&:hover":{bgcolor:"#f8f9fa"}}}),d.export.allowedFormats.includes("json")&&e.jsx(r.FormControlLabel,{value:"json",control:e.jsx(r.Radio,{size:"small",sx:{color:"text.secondary","&.Mui-checked":{color:"primary.main"}}}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"JSON"}),e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},children:"Structured data with metadata and filters"})]}),sx:{alignItems:"flex-start",px:1.5,py:1,borderRadius:"8px",transition:"background-color 0.2s ease","&:hover":{bgcolor:"#f8f9fa"}}})]})]}),e.jsxs(r.FormControl,{component:"fieldset",children:[e.jsx(r.FormLabel,{component:"legend",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,textTransform:"uppercase"},children:"Rows"}),e.jsxs(r.RadioGroup,{value:h,onChange:S=>m(S.target.value),children:[e.jsx(r.FormControlLabel,{value:"visible",control:e.jsx(r.Radio,{size:"small",sx:{color:"text.secondary","&.Mui-checked":{color:"primary.main"}}}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"Visible rows"}),e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},children:["Export ",o.toLocaleString()," rows (filtered and searched)"]})]}),sx:{mb:1.25,alignItems:"flex-start",px:1.5,py:1,borderRadius:"8px",transition:"background-color 0.2s ease","&:hover":{bgcolor:"#f8f9fa"}}}),e.jsx(r.FormControlLabel,{value:"all",control:e.jsx(r.Radio,{size:"small",sx:{color:"text.secondary","&.Mui-checked":{color:"primary.main"}}}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"All rows"}),e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},children:["Export ",t.toLocaleString()," rows (complete original dataset)"]})]}),sx:{alignItems:"flex-start",px:1.5,py:1,borderRadius:"8px",transition:"background-color 0.2s ease","&:hover":{bgcolor:"#f8f9fa"}}})]})]}),e.jsxs(r.FormControl,{component:"fieldset",children:[e.jsx(r.FormLabel,{component:"legend",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,textTransform:"uppercase"},children:"Columns"}),e.jsxs(r.RadioGroup,{value:v,onChange:S=>w(S.target.value),children:[e.jsx(r.FormControlLabel,{value:"visible",control:e.jsx(r.Radio,{size:"small",sx:{color:"text.secondary","&.Mui-checked":{color:"primary.main"}}}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"Visible columns only"}),e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},children:["Export ",i," visible columns"]})]}),sx:{mb:1.25,alignItems:"flex-start",px:1.5,py:1,borderRadius:"8px",transition:"background-color 0.2s ease","&:hover":{bgcolor:"#f8f9fa"}}}),e.jsx(r.FormControlLabel,{value:"all",control:e.jsx(r.Radio,{size:"small",sx:{color:"text.secondary","&.Mui-checked":{color:"primary.main"}}}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"All columns"}),e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},children:["Export all ",a," columns (including hidden)"]})]}),sx:{alignItems:"flex-start",px:1.5,py:1,borderRadius:"8px",transition:"background-color 0.2s ease","&:hover":{bgcolor:"#f8f9fa"}}})]})]}),e.jsxs(r.Box,{sx:{pt:1},children:[e.jsx(r.Divider,{sx:{mb:2,borderColor:"divider"}}),e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[e.jsxs(r.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"text.secondary"},children:"Format:"}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:g[u]})]}),e.jsxs(r.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"text.secondary"},children:"Rows to export:"}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:y.toLocaleString()})]}),e.jsxs(r.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"text.secondary"},children:"Columns to export:"}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:j})]})]})]})]})}),e.jsxs(r.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"#f8f9fa"},children:[e.jsx(r.Button,{onClick:c,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsxs(r.Button,{onClick:b,variant:"contained",startIcon:e.jsx(k.Download,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"common.white",px:3,py:1,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:["Download ",g[u]]})]})]})})}function kd({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(k.Warning,{sx:{fontSize:20}}),action:e.jsx(r.IconButton,{size:"small",onClick:o,sx:{color:"warning.main"},children:e.jsx(k.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 Td({error:t,onDismiss:o,autoDismiss:n=!0,autoDismissDelay:i=5e3}){p.useEffect(()=>{if(n){const d=setTimeout(()=>{o()},i);return()=>clearTimeout(d)}},[n,i,o]);const l=(()=>{switch(t.type){case"system":return{severity:"error",icon:e.jsx(k.Cancel,{sx:{fontSize:20}})};case"processing":return{severity:"warning",icon:e.jsx(k.Warning,{sx:{fontSize:20}})};case"ui":default:return{severity:"info",icon:e.jsx(k.InfoOutlined,{sx:{fontSize:20}})}}})(),c=Gs(t);return e.jsx(r.Box,{sx:{position:"fixed",top:16,right:16,zIndex:50,maxWidth:448},children:e.jsxs(r.Alert,{severity:l.severity,icon:l.icon,action:e.jsx(r.IconButton,{size:"small",onClick:o,sx:{color:`${l.severity}.main`},children:e.jsx(k.Close,{sx:{fontSize:16}})}),sx:{borderLeft:4,borderColor:`${l.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 zd extends p.Component{constructor(o){super(o),this.handleReset=()=>{this.setState({hasError:!1,error:null})},this.state={hasError:!1,error:null}}static getDerivedStateFromError(o){return{hasError:!0,error:o}}componentDidCatch(o,n){Vt.error("urm:error-boundary","Caught unhandled component error",o,n),this.props.onError&&this.props.onError(o,n)}render(){var o,n;return this.state.hasError?this.props.fallback?this.props.fallback:e.jsx(r.Paper,{sx:{bgcolor:i=>R(i.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(k.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:((o=this.state.error)==null?void 0:o.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:i=>R(i.palette.error.main,.12),p:1.5,borderRadius:1,overflow:"auto",maxHeight:160},children:(n=this.state.error)==null?void 0:n.stack}),e.jsx(r.Button,{onClick:this.handleReset,variant:"contained",color:"error",startIcon:e.jsx(k.Refresh,{sx:{fontSize:16}}),sx:{mt:2},children:"Try Again"})]})]})}):this.props.children}}function Er({children:t,feature:o,onError:n}){return e.jsx(zd,{context:o,onError:(i,a)=>{n&&n(i)},fallback:e.jsxs(r.Alert,{severity:"warning",sx:{m:1},icon:e.jsx(k.Warning,{sx:{fontSize:20}}),children:[e.jsxs(r.AlertTitle,{children:[o," temporarily unavailable"]}),"Other features continue to work normally"]}),children:t})}const Id=[{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"}],Ed=[{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 Dr({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 Dd({open:t,onClose:o,config:n,onApply:i}){const[a,l]=p.useState(0),[c,d]=p.useState(n),u=()=>d(n),f=()=>d(tt),h=()=>{i(c),o()},m={sort:j=>d(b=>({...b,sort:{...b.sort,...j}})),filter:j=>d(b=>({...b,filter:{...b.filter,...j}})),columns:j=>d(b=>({...b,columns:{...b.columns,...j}})),grouping:j=>d(b=>({...b,grouping:{...b.grouping,...j}})),export:j=>d(b=>({...b,export:{...b.export,...j}}))},v=j=>{const b=c.filter.allowedOperators,g=b.includes(j)?b.filter(S=>S!==j):[...b,j];g.length!==0&&m.filter({allowedOperators:g})},w=j=>{const b=c.export.allowedFormats,g=b.includes(j)?b.filter(S=>S!==j):[...b,j];g.length!==0&&m.export({allowedFormats:g})},z=[{label:"Sort",icon:e.jsx(k.SwapVert,{sx:{fontSize:17}})},{label:"Filter",icon:e.jsx(k.FilterList,{sx:{fontSize:17}})},{label:"Columns",icon:e.jsx(k.ViewColumn,{sx:{fontSize:17}})},{label:"Grouping",icon:e.jsx(k.Layers,{sx:{fontSize:17}})},{label:"Export",icon:e.jsx(k.Download,{sx:{fontSize:17}})}],y=j=>JSON.stringify(c[j])===JSON.stringify(tt[j]);return e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"sm",fullWidth:!0,TransitionProps:{onEnter:u},PaperProps:{sx:{borderRadius:"12px",maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:"0 8px 32px rgba(60,64,67,0.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=>R(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(k.Close,{sx:{fontSize:20}})})]}),e.jsx(r.Box,{sx:{borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:e.jsx(r.Tabs,{value:a,onChange:(j,b)=>l(b),variant:"fullWidth",sx:{minHeight:44,"& .MuiTab-root":{minHeight:44,fontSize:"0.8125rem",textTransform:"none",fontWeight:500,gap:.5}},children:z.map((j,b)=>e.jsx(r.Tab,{label:j.label,icon:j.icon,iconPosition:"start"},b))})}),e.jsxs(r.DialogContent,{sx:{overflowY:"auto",flex:1,px:3,py:0},children:[e.jsxs(Dr,{active:a===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"}),!y("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,b)=>m.sort({maxLevels:b}),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(Dr,{active:a===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"}),!y("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,b)=>m.filter({maxConditions:b}),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:Id.filter(b=>b.group===j).map(b=>e.jsx(r.FormControlLabel,{control:e.jsx(r.Checkbox,{size:"small",checked:c.filter.allowedOperators.includes(b.value),onChange:()=>v(b.value)}),label:e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem"},children:b.label}),sx:{mr:1.5}},b.value))})]},j))]})]}),e.jsxs(Dr,{active:a===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"}),!y("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,b)=>m.columns({maxVisible:b}),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,b)=>m.columns({minColumnWidth:b}),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,b)=>m.columns({maxColumnWidth:b}),min:100,max:2e3,step:50,valueLabelDisplay:"on",valueLabelFormat:j=>`${j}px`})]})]})]})]}),e.jsxs(Dr,{active:a===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"}),!y("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:()=>m.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?b=>R(b.palette.primary.main,.06):"transparent","&:hover":{borderColor:"primary.light",bgcolor:b=>R(b.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=>m.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=>m.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(Dr,{active:a===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"}),!y("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:Ed.map(j=>e.jsxs(r.Box,{onClick:()=>w(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)?b=>R(b.palette.primary.main,.04):"transparent","&:hover":{borderColor:"primary.light"}},children:[e.jsx(r.Checkbox,{size:"small",checked:c.export.allowedFormats.includes(j.value),onChange:()=>w(j.value),onClick:b=>b.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=>R(j.palette.action.hover,.4),justifyContent:"space-between",flexShrink:0},children:[e.jsx(r.Button,{startIcon:e.jsx(k.RestartAlt,{sx:{fontSize:18}}),onClick:f,size:"small",sx:{textTransform:"none",fontSize:"0.875rem",color:"text.secondary","&:hover":{color:"text.primary",bgcolor:j=>R(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:{textTransform:"none",fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px"},children:"Cancel"}),e.jsx(r.Button,{onClick:h,size:"small",variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2.5,borderRadius:"18px"},children:"Apply"})]})]})]})}const Bd=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Od={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 Xr(t,o,n,i,a=new Date){const[l,c]=o.split(":").map(Number),d=new Date(a);if(d.setSeconds(0,0),d.setHours(l,c,0,0),t==="daily")return d<=a&&d.setDate(d.getDate()+1),d.toISOString();if(t==="weekly"){const u=n??1,f=d.getDay();let h=u-f;return h<0&&(h+=7),h===0&&d<=a&&(h=7),d.setDate(d.getDate()+h),d.toISOString()}if(t==="monthly"){const u=Math.min(i??1,28);return d.setDate(u),d<=a&&(d.setMonth(d.getMonth()+1),d.setDate(u)),d.toISOString()}return d.toISOString()}function Ad(t){const o=Ci(t.time);return t.frequency==="daily"?`Daily at ${o}`:t.frequency==="weekly"?`Every ${Bd[t.dayOfWeek??1]} at ${o}`:t.frequency==="monthly"?`Monthly on the ${Od[t.dayOfMonth??1]??`${t.dayOfMonth}th`} at ${o}`:o}function Ci(t){const[o,n]=t.split(":").map(Number),i=o>=12?"PM":"AM";return`${o%12||12}:${String(n).padStart(2,"0")} ${i}`}function Md(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),a=Math.floor(n%86400/3600),l=Math.floor(n%3600/60);return i>0?`in ${i}d ${a}h`:a>0?`in ${a}h ${l}m`:l>0?`in ${l}m`:"in less than a minute"}function Wd(t){const o=new Date(t),n=new Date,i=o.toDateString()===n.toDateString(),a=Ci(`${String(o.getHours()).padStart(2,"0")}:${String(o.getMinutes()).padStart(2,"0")}`);return i?`Today at ${a}`:`${o.toLocaleDateString("en-US",{month:"short",day:"numeric"})} at ${a}`}function ji(t){return`urm_schedules_${t}`}function wi(t){try{const o=localStorage.getItem(ji(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 ki(t,o){try{localStorage.setItem(ji(t),JSON.stringify(o))}catch{}}const Rd=[{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"}],Ti={name:"",frequency:"daily",dayOfWeek:1,dayOfMonth:1,time:"09:00",format:"csv",scope:"all",email:""},Lt={"& .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 _d({initial:t=Ti,isEditing:o=!1,onSave:n,onBack:i}){const[a,l]=p.useState(t),[c,d]=p.useState(!1),u=(h,m)=>l(v=>({...v,[h]:m})),f=a.name.trim().length>0&&/^\d{2}:\d{2}$/.test(a.time)&&(a.frequency!=="monthly"||a.dayOfMonth>=1&&a.dayOfMonth<=28);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:h=>R(h.palette.text.primary,.06)}},children:e.jsx(k.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:a.name,onChange:h=>{u("name",h.target.value),c&&h.target.value.trim()&&d(!1)},onBlur:()=>d(!0),placeholder:"e.g. Weekly Sales Report",autoFocus:!0,inputProps:{maxLength:50},error:c&&!a.name.trim(),helperText:c&&!a.name.trim()?"Schedule name is required":`${a.name.length}/50`,sx:Lt}),e.jsxs(r.FormControl,{size:"small",fullWidth:!0,sx:Lt,children:[e.jsx(r.InputLabel,{children:"Frequency"}),e.jsxs(r.Select,{value:a.frequency,label:"Frequency",onChange:h=>u("frequency",h.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"})]})]}),a.frequency==="weekly"&&e.jsxs(r.FormControl,{size:"small",fullWidth:!0,sx:Lt,children:[e.jsx(r.InputLabel,{children:"Day of week"}),e.jsx(r.Select,{value:a.dayOfWeek,label:"Day of week",onChange:h=>u("dayOfWeek",Number(h.target.value)),children:Rd.map(h=>e.jsx(r.MenuItem,{value:h.value,children:h.label},h.value))})]}),a.frequency==="monthly"&&e.jsx(r.TextField,{label:"Day of month (1–28)",size:"small",type:"number",fullWidth:!0,value:a.dayOfMonth,onChange:h=>{const m=Number(h.target.value);u("dayOfMonth",m)},inputProps:{min:1,max:28},error:a.dayOfMonth<1||a.dayOfMonth>28,helperText:a.dayOfMonth<1||a.dayOfMonth>28?"Day must be between 1 and 28":"Max 28 — works safely across all months including February",sx:Lt}),e.jsx(r.TextField,{label:"Time",size:"small",type:"time",fullWidth:!0,value:a.time,onChange:h=>u("time",h.target.value),InputLabelProps:{shrink:!0},helperText:"24-hour format · Tab must be open for the schedule to fire",sx:Lt}),e.jsxs(r.FormControl,{size:"small",fullWidth:!0,sx:Lt,children:[e.jsx(r.InputLabel,{children:"Export format"}),e.jsxs(r.Select,{value:a.format,label:"Export format",onChange:h=>u("format",h.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:a.scope,onChange:h=>u("scope",h.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:a.email,onChange:h=>u("email",h.target.value),placeholder:"user@company.com",InputProps:{startAdornment:e.jsx(k.Email,{sx:{fontSize:15,color:"text.disabled",mr:1}})},sx:Lt}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"flex-start",gap:.5,mt:.5,px:.5},children:[e.jsx(k.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:{textTransform:"none",fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px","&:hover":{bgcolor:h=>R(h.palette.text.primary,.06)}},children:"Cancel"}),e.jsx(r.Button,{onClick:()=>f&&n(a),disabled:!f,size:"small",variant:"contained",disableElevation:!0,sx:{textTransform:"none",fontWeight:500,fontSize:"0.875rem",px:2.5,borderRadius:"18px"},children:o?"Save changes":"Create schedule"})]})]})}function Pd({schedule:t,onToggle:o,onRunNow:n,onEdit:i,onDelete:a}){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=>R(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=>R(c.palette.success.main,.1):c=>R(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:Ad(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=>R(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=>R(c.palette.text.primary,.06),color:"text.secondary"}}),t.email&&e.jsx(r.Chip,{icon:e.jsx(k.Email,{sx:{fontSize:11}}),label:t.email,size:"small",sx:{height:20,fontSize:"0.6875rem",maxWidth:220,bgcolor:c=>R(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: ",Md(t.nextRunAt)]}),t.lastRunAt?e.jsxs(r.Typography,{variant:"caption",color:"text.secondary",children:["Last: ",Wd(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:()=>i(t),sx:{color:"text.secondary","&:hover":{color:"primary.main",bgcolor:c=>R(c.palette.primary.main,.08)}},children:e.jsx(k.Edit,{sx:{fontSize:15}})})}),e.jsx(r.Tooltip,{title:l?"Pause":"Resume",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:()=>o(t.id),sx:{color:l?"warning.main":"success.main","&:hover":{bgcolor:l?c=>R(c.palette.warning.main,.08):c=>R(c.palette.success.main,.08)}},children:l?e.jsx(k.Pause,{sx:{fontSize:15}}):e.jsx(k.PlayArrow,{sx:{fontSize:15}})})}),e.jsx(r.Tooltip,{title:"Export now",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:()=>n(t),sx:{color:"primary.main","&:hover":{bgcolor:c=>R(c.palette.primary.main,.08)}},children:e.jsx(k.Download,{sx:{fontSize:15}})})}),e.jsx(r.Tooltip,{title:"Delete",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:()=>a(t.id),sx:{color:"error.main","&:hover":{bgcolor:c=>R(c.palette.error.main,.08)}},children:e.jsx(k.Delete,{sx:{fontSize:15}})})})]})]})]})}function $d({open:t,onClose:o,reportId:n,reportName:i,onRunNow:a}){const[l,c]=p.useState([]),[d,u]=p.useState({type:"list"}),[f,h]=p.useState(0);p.useEffect(()=>{t&&(c(wi(n)),u({type:"list"}))},[t,n]),p.useEffect(()=>{if(!t)return;const S=setInterval(()=>h(s=>s+1),3e4);return()=>clearInterval(S)},[t]);const m=p.useCallback(S=>{c(S),ki(n,S)},[n]),v=S=>{const s=Xr(S.frequency,S.time,S.dayOfWeek,S.dayOfMonth),I={id:`sched-${Date.now()}`,reportId:n,name:S.name.trim(),frequency:S.frequency,dayOfWeek:S.frequency==="weekly"?S.dayOfWeek:void 0,dayOfMonth:S.frequency==="monthly"?S.dayOfMonth:void 0,time:S.time,format:S.format,scope:S.scope,email:S.email.trim()||void 0,isActive:!0,createdAt:new Date().toISOString(),nextRunAt:s,runCount:0};m([...l,I]),u({type:"list"})},w=S=>{if(d.type!=="edit")return;const s=d.schedule,I=Xr(S.frequency,S.time,S.dayOfWeek,S.dayOfMonth);m(l.map(A=>A.id===s.id?{...s,name:S.name.trim(),frequency:S.frequency,dayOfWeek:S.frequency==="weekly"?S.dayOfWeek:void 0,dayOfMonth:S.frequency==="monthly"?S.dayOfMonth:void 0,time:S.time,format:S.format,scope:S.scope,email:S.email.trim()||void 0,nextRunAt:I}:A)),u({type:"list"})},z=S=>{m(l.map(s=>{if(s.id!==S)return s;const I=s.isActive?s.nextRunAt:Xr(s.frequency,s.time,s.dayOfWeek,s.dayOfMonth);return{...s,isActive:!s.isActive,nextRunAt:I}}))},y=S=>m(l.filter(s=>s.id!==S)),j=S=>({name:S.name,frequency:S.frequency,dayOfWeek:S.dayOfWeek??1,dayOfMonth:S.dayOfMonth??1,time:S.time,format:S.format,scope:S.scope,email:S.email??""}),b=d.type!=="list",g=l.filter(S=>S.isActive).length;return e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"sm",fullWidth:!0,disableEscapeKeyDown:b,PaperProps:{sx:{borderRadius:"12px",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:S=>R(S.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(k.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(Ut,{content:Gt.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:S=>R(S.palette.text.primary,.06)}},children:e.jsx(k.Close,{sx:{fontSize:18}})})]}),e.jsxs(r.DialogContent,{sx:{overflowY:"auto",flex:1,px:2.5,py:2},children:[b&&e.jsx(_d,{initial:d.type==="edit"?j(d.schedule):Ti,isEditing:d.type==="edit",onSave:d.type==="edit"?w:v,onBack:()=>u({type:"list"})}),d.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:l.length===0?"No schedules yet":`${g} of ${l.length} active`}),e.jsx(r.Button,{startIcon:e.jsx(k.Add,{sx:{fontSize:15}}),size:"small",variant:"contained",disableElevation:!0,onClick:()=>u({type:"create"}),sx:{textTransform:"none",fontWeight:500,fontSize:"0.8125rem",borderRadius:"18px",px:1.75,py:.625},children:"New schedule"})]}),l.length===0?e.jsxs(r.Box,{sx:{border:"1.5px dashed",borderColor:"divider",borderRadius:"10px",py:5,px:2,textAlign:"center"},children:[e.jsx(k.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:l.map(S=>e.jsx(Pd,{schedule:S,tick:f,onToggle:z,onRunNow:a,onEdit:s=>u({type:"edit",schedule:s}),onDelete:y},S.id))})]})]}),d.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:S=>R(S.palette.warning.main,.06),border:"1px solid",borderColor:S=>R(S.palette.warning.main,.2)},children:[e.jsx(k.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:{textTransform:"none",fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px",flexShrink:0,"&:hover":{bgcolor:S=>R(S.palette.text.primary,.06)}},children:"Close"})]})]})}const Nd=6e4;function Fd({reportId:t,reportName:o,uploadedData:n,processedData:i,schema:a,activeView:l,columnVisibility:c,columnOrder:d,filters:u,sortStack:f,onFired:h}){const m=p.useRef({reportId:t,reportName:o,uploadedData:n,processedData:i,schema:a,activeView:l,columnVisibility:c,columnOrder:d,filters:u,sortStack:f,onFired:h});p.useEffect(()=>{m.current={reportId:t,reportName:o,uploadedData:n,processedData:i,schema:a,activeView:l,columnVisibility:c,columnOrder:d,filters:u,sortStack:f,onFired:h}});const v=p.useCallback(w=>{var H,N;const{reportName:z,uploadedData:y,processedData:j,schema:b,activeView:g,columnVisibility:S,columnOrder:s,filters:I,sortStack:A}=m.current;try{const K=w.scope==="all"?y:j,te=Qr(K,b,I,A,g,S,s),se=`${w.name}_scheduled`;switch(w.format){case"csv":Zr(te,se,{scope:w.scope});break;case"excel":eo(te,se,{scope:w.scope});break;case"json":to(te,se,{scope:w.scope});break}if(w.email){const x=encodeURIComponent(`Scheduled Report: ${w.name}`),V=encodeURIComponent(`Your scheduled report "${w.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:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"#ffffff",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Got it"})})]}):null}function dd({onFileUpload:t,onError:o,isUploading:n}){const[i,s]=p.useState(!1),[c,d]=p.useState(""),[l,u]=p.useState(!1),m=p.useRef(null),h=async v=>{if(!v.name.endsWith(".json")){o("Only .json files are allowed");return}const j=10*1024*1024;if(v.size>j){o("File size exceeds 10MB limit");return}d(v.name);try{const S=await v.text();let I;try{I=JSON.parse(S)}catch{o("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(I)){o("JSON must be an array of objects");return}if(I.length===0){o("No data rows found in JSON file");return}t(I)}catch{o("Network error — please try again")}finally{d("")}},b=v=>{v.preventDefault(),s(!0)},f=v=>{v.preventDefault(),s(!1)},g=v=>{v.preventDefault(),s(!1);const j=v.dataTransfer.files[0];j&&h(j)},T=()=>{var v;(v=m.current)==null||v.click()},y=v=>{var S;const j=(S=v.target.files)==null?void 0:S[0];j&&h(j)},w=v=>{v.stopPropagation(),u(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(r.Box,{onDragOver:b,onDragLeave:f,onDrop:g,onPaste:v=>v.preventDefault(),onClick:T,sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderStyle:"dashed",borderColor:i?"primary.main":"divider",bgcolor:i?v=>E(v.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:m,type:"file",accept:".json",onChange:y,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..."}),c&&e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:c})]}):e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:v=>E(v.palette.primary.main,.12),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(k.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:w,size:"small",sx:{border:1,borderColor:"divider","&:hover":{borderColor:"text.secondary",bgcolor:"action.hover"}},title:"View JSON format guide",children:e.jsx(k.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(Fi,{isOpen:l,onClose:()=>u(!1)})]})}function ud({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=>E(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(k.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 pd({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=>E(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=>E(n.palette.error.main,.3),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(k.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(k.Upload,{sx:{fontSize:16}}),onClick:o,sx:{fontWeight:500},children:"Try Again"})]})}function Vi({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=>E(i.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:3},children:e.jsx(k.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 xd({value:t,onChange:o,searchHistory:n,onAddToHistory:i,onToggleFavourite:s,onDeleteHistory:c,disabled:d}){const[l,u]=p.useState(!1),[m,h]=p.useState(!1),[b,f]=p.useState(-1),g=p.useRef(null),T=p.useRef(null);p.useEffect(()=>{function $(Y){g.current&&!g.current.contains(Y.target)&&(u(!1),h(!1))}return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[]);const y=p.useCallback(()=>{h(!0),f(-1),n.length>0&&u(!0)},[n.length]),w=p.useCallback($=>{o($),f(-1)},[o]),v=p.useCallback($=>{var Y;o($),i($),u(!1),(Y=T.current)==null||Y.blur()},[o,i]),j=p.useCallback($=>{f(-1),v($)},[v]),S=p.useCallback($=>{var Y;$.key==="Enter"?b>=0&&b<n.length?($.preventDefault(),j(n[b].query)):t.trim()&&v(t.trim()):$.key==="Escape"?(u(!1),f(-1),(Y=T.current)==null||Y.blur()):$.key==="ArrowDown"?($.preventDefault(),n.length>0&&(l||u(!0),f(Q=>Q<n.length-1?Q+1:Q))):$.key==="ArrowUp"&&($.preventDefault(),f(Q=>Q>0?Q-1:-1))},[b,n,t,l,j,v]),I=p.useCallback(()=>{var $;o(""),($=T.current)==null||$.focus()},[o]),a=p.useMemo(()=>n.filter($=>$.isFavourite),[n]),A=p.useMemo(()=>n.filter($=>!$.isFavourite),[n]),B=l&&n.length>0;return e.jsxs(r.Box,{sx:{position:"relative",width:240},ref:g,children:[e.jsx(r.TextField,{inputRef:T,size:"small",fullWidth:!0,value:t,onChange:$=>w($.target.value),onFocus:y,onKeyDown:S,placeholder:"Search data...",disabled:d,sx:{"& .MuiOutlinedInput-root":{borderRadius:"20px",fontSize:"0.875rem",bgcolor:"background.paper",height:"36px","& fieldset":{borderColor:$=>`rgba(${$.palette.mode==="dark"?"255,255,255":"0,0,0"}, 0.30)`,transition:"all 0.15s ease"},"&:hover":{bgcolor:"action.hover"},"&:hover fieldset":{borderColor:$=>`rgba(${$.palette.mode==="dark"?"255,255,255":"0,0,0"}, 0.50)`},"&.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(k.Search,{sx:{fontSize:18,color:"text.secondary"}})}),endAdornment:t?e.jsx(r.InputAdornment,{position:"end",children:e.jsx(r.IconButton,{size:"small",onClick:I,edge:"end",sx:{mr:-.5},children:e.jsx(k.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:[a.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"}),a.map(($,Y)=>e.jsx(Zn,{entry:$,isSelected:b===Y,onClick:()=>j($.query),onToggleFavourite:()=>s($.query),onDelete:()=>c($.query)},`fav-${$.query}`))]}),A.length>0&&e.jsxs(r.Box,{sx:{py:1},children:[a.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(($,Y)=>{const Q=a.length+Y;return e.jsx(Zn,{entry:$,isSelected:b===Q,onClick:()=>j($.query),onToggleFavourite:()=>s($.query),onDelete:()=>c($.query)},`recent-${$.query}`)})]})]})]})}const Zn=p.memo(function({entry:o,isSelected:n,onClick:i,onToggleFavourite:s,onDelete:c}){const d=p.useCallback(u=>{u.stopPropagation(),s()},[s]),l=p.useCallback(u=>{u.stopPropagation(),c()},[c]);return e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:1.5,py:1,cursor:"pointer",bgcolor:n?u=>E(u.palette.primary.main,.12):"transparent","&:hover":{bgcolor:n?u=>E(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:d,title:o.isFavourite?"Remove from favourites":"Add to favourites",sx:{p:.5},children:o.isFavourite?e.jsx(k.Star,{sx:{fontSize:14,color:"warning.light"}}):e.jsx(k.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(k.Delete,{sx:{fontSize:14,opacity:.5}})})]})]})});function md({views:t,activeViewId:o,isDirty:n,onSelectView:i,onCreateView:s,onManageViews:c,onToggleDefault:d,onToggleFavorite:l,onRestoreView:u,onPermanentDelete:m,isReadOnly:h,isAdmin:b=!1}){const f=Tt(),[g,T]=p.useState(!1),[y,w]=p.useState(!1),[v,j]=p.useState({top:0,left:0}),[S,I]=p.useState(null),a=p.useRef(null),A=p.useRef(null),B=t.find(O=>O.id===o),$=B==null?void 0:B.isDefault,Y=t.filter(O=>O.scope==="global"&&!O.isDeleted),Q=t.filter(O=>O.scope!=="global"&&!O.isDeleted),te=t.filter(O=>O.isFavorite&&!O.isDeleted).sort((O,F)=>(F.updatedAt||0)-(O.updatedAt||0)),x=t.filter(O=>O.isDeleted);p.useEffect(()=>{if(g&&A.current){const O=A.current.getBoundingClientRect();j({top:O.bottom+window.scrollY+8,left:O.right+window.scrollX-320})}},[g]),p.useEffect(()=>{const O=F=>{a.current&&!a.current.contains(F.target)&&A.current&&!A.current.contains(F.target)&&T(!1)};return g&&document.addEventListener("mousedown",O),()=>{document.removeEventListener("mousedown",O)}},[g]);const N=O=>{if(n&&O!==o){I(O),T(!1);return}i(O),T(!1)},W=()=>{S&&(i(S),I(null))},H=()=>{I(null)},J=(O,F=!1)=>{const G=O.scope==="global",se=!h&&(!G||b);return e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:o===O.id?f.palette.primary.light+"20":"transparent",transition:"background-color 0.2s","&:hover":{backgroundColor:o===O.id?f.palette.primary.light+"20":f.palette.grey[50]}},children:[e.jsxs(r.Button,{onClick:()=>N(O.id),sx:{display:"flex",alignItems:"center",gap:1,flex:1,textAlign:"left",minWidth:0,textTransform:"none",justifyContent:"flex-start",color:"inherit",p:0,"&:hover":{backgroundColor:"transparent"}},children:[o===O.id&&e.jsx(k.Check,{sx:{fontSize:16,flexShrink:0}}),o!==O.id&&e.jsx(r.Box,{sx:{width:"16px",flexShrink:0}}),e.jsx(r.Typography,{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:o===O.id?f.palette.primary.dark:f.palette.text.primary,fontWeight:o===O.id?500:400},children:O.name}),F&&e.jsx(r.Typography,{component:"span",sx:{fontSize:"caption.fontSize",color:f.palette.text.secondary,backgroundColor:f.palette.grey[100],px:1,py:.25,borderRadius:1,flexShrink:0},children:"Default"})]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[se&&l&&e.jsx(r.IconButton,{onClick:ee=>{ee.stopPropagation(),l(O.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:f.palette.grey[200]}},title:O.isFavorite?"Remove from favorites":"Add to favorites",children:e.jsx(k.Star,{sx:{fontSize:16}})}),se&&d&&!O.isDefault&&e.jsx(r.IconButton,{onClick:ee=>{ee.stopPropagation(),d(O.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:f.palette.grey[200]}},title:"Set as default",children:e.jsx(k.RadioButtonUnchecked,{sx:{fontSize:16}})})]})]},O.id)},ue=O=>e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:f.palette.grey[50]},children:[e.jsx(r.Typography,{sx:{color:f.palette.text.secondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:O.name}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[u&&e.jsx(r.IconButton,{onClick:F=>{F.stopPropagation(),u(O.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:f.palette.grey[200]}},title:"Restore view",children:e.jsx(k.Undo,{sx:{fontSize:16,color:"success.main"}})}),m&&e.jsx(r.IconButton,{onClick:F=>{F.stopPropagation(),m(O.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:f.palette.grey[200]}},title:"Delete permanently",children:e.jsx(k.Delete,{sx:{fontSize:16,color:"error.main"}})})]})]},O.id),pe=n||!$,re=n;return e.jsxs(r.Box,{sx:{position:"relative"},children:[e.jsxs(r.IconButton,{ref:A,onClick:()=>T(!g),size:"small",sx:{position:"relative",color:pe?"warning.main":"text.secondary",bgcolor:pe?E(f.palette.warning.main,.12):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:pe?E(f.palette.warning.main,.2):E(f.palette.text.primary,.06),color:pe?"warning.dark":"text.primary"}},title:`View: ${(B==null?void 0:B.name)||"Default View"}`,children:[e.jsx(k.Visibility,{sx:{fontSize:20}}),re&&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"}})]}),g&&di.createPortal(e.jsxs(r.Box,{ref:a,sx:{position:"fixed",width:"320px",backgroundColor:f.palette.background.paper,border:`1px solid ${f.palette.divider}`,borderRadius:1,boxShadow:f.shadows[8],zIndex:50,maxHeight:"500px",overflowY:"auto",top:v.top,left:v.left},children:[Y.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:f.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Global Views"}),Y.map(O=>J(O,O.isDefault))]}),te.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{borderTop:`1px solid ${f.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:f.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",gap:.5},children:[e.jsx(k.Star,{sx:{fontSize:12,color:"warning.light"}}),e.jsx(r.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:"Favorite Views"})]}),te.map(O=>J(O))]})]}),Q.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{borderTop:`1px solid ${f.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:f.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Personal Views"}),Q.map(O=>J(O))]})]}),x.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{borderTop:`1px solid ${f.palette.divider}`}}),e.jsxs(r.Box,{sx:{py:.5},children:[e.jsxs(r.Button,{onClick:()=>w(!y),sx:{width:"100%",px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:f.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",justifyContent:"space-between",transition:"background-color 0.2s","&:hover":{backgroundColor:f.palette.grey[50]}},children:[e.jsxs(r.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:["Recently Deleted (",x.length,")"]}),e.jsx(k.ChevronRight,{sx:{fontSize:16}})]}),y&&e.jsx(r.Box,{sx:{backgroundColor:f.palette.grey[50]},children:x.map(O=>ue(O))})]})]}),e.jsx(r.Box,{sx:{borderTop:`1px solid ${f.palette.divider}`}}),e.jsxs(r.Button,{onClick:()=>{s(),T(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:f.palette.text.primary,textTransform:"none",justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:f.palette.grey[50]}},children:[e.jsx(k.Add,{sx:{fontSize:16}}),e.jsx(r.Typography,{component:"span",sx:{fontSize:"inherit"},children:"Create New Report View"})]}),e.jsxs(r.Button,{onClick:()=>{c(),T(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:f.palette.text.primary,textTransform:"none",justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:f.palette.grey[50]}},children:[e.jsx(k.Settings,{sx:{fontSize:16}}),e.jsx(r.Typography,{component:"span",sx:{fontSize:"inherit"},children:"View Setup"})]})]}),document.body),e.jsxs(r.Dialog,{open:S!==null,onClose:H,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px"}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",gap:1,pb:1},children:[e.jsx(k.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:H,variant:"text",sx:{textTransform:"none",fontWeight:500},children:"Stay here"}),e.jsx(r.Button,{onClick:W,variant:"contained",color:"warning",disableElevation:!0,sx:{textTransform:"none",fontWeight:500},children:"Discard & switch"})]})]})]})}function fd({columnName:t,columnType:o="string",currentSort:n,hasFilters:i,isInSortStack:s,isReadOnly:c=!1,hasModifications:d=!1,position:l,onSortAscending:u,onSortDescending:m,onRemoveSort:h,onFilter:b,onClearFilter:f,onGroupByColumn:g,onHideColumn:T,onManageColumns:y,onManageViews:w,onResetLayout:v,onClose:j}){var te,x;const I=Tt().palette,a=p.useRef(null);p.useEffect(()=>{if(!a.current)return;const N=a.current,W=N.getBoundingClientRect(),H=window.innerWidth,J=window.innerHeight;W.right>H-8&&(N.style.left=`${H-W.width-8}px`),W.bottom>J-8&&(N.style.top=`${J-W.height-8}px`)},[l]),p.useEffect(()=>{const N=H=>{a.current&&!a.current.contains(H.target)&&j()},W=H=>{H.key==="Escape"&&j()};return document.addEventListener("mousedown",N),document.addEventListener("keydown",W),()=>{document.removeEventListener("mousedown",N),document.removeEventListener("keydown",W)}},[j]);const A=p.useCallback(N=>()=>{N(),j()},[j]),B=(n==null?void 0:n.direction)==="asc",$=(n==null?void 0:n.direction)==="desc",Y=o==="number"?"0→9":o==="boolean"?"F→T":"A→Z",Q=o==="number"?"9→0":o==="boolean"?"T→F":"Z→A";return di.createPortal(e.jsxs(r.Paper,{ref:a,elevation:0,sx:{position:"fixed",left:`${l.x}px`,top:`${l.y}px`,zIndex:1400,minWidth:210,maxWidth:264,border:"1px solid",borderColor:"divider",borderRadius:"10px",overflow:"hidden",boxShadow:`0 4px 20px ${E(((te=I.common)==null?void 0:te.black)??"#000",.12)}, 0 1px 4px ${E(((x=I.common)==null?void 0:x.black)??"#000",.06)}`},children:[!c&&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 (${Y})`,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?E(I.primary.main,.1):"transparent","&:hover":{bgcolor:E(I.primary.main,.08),color:"primary.main"}},children:e.jsx(k.ArrowUpward,{sx:{fontSize:16}})})}),e.jsx(r.Tooltip,{title:`Sort Descending (${Q})`,placement:"top",arrow:!0,children:e.jsx(r.IconButton,{size:"small",onClick:A(()=>m(t)),sx:{p:.625,borderRadius:"6px",color:$?"primary.main":"text.secondary",bgcolor:$?E(I.primary.main,.1):"transparent","&:hover":{bgcolor:E(I.primary.main,.08),color:"primary.main"}},children:e.jsx(k.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(()=>h(t)),sx:{p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:E(I.error.main,.08),color:"error.main"},"&.Mui-disabled":{opacity:.3}},children:e.jsx(k.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(k.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&&!c&&e.jsxs(r.MenuItem,{onClick:A(()=>f(t)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:E(I.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(k.FilterListOff,{sx:{fontSize:16,color:"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Clear Filter",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]}),!c&&g&&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(()=>g(t)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(k.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:[!c&&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(()=>T(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(k.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(y),sx:{mr:.75,p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:E(I.primary.main,.08),color:"primary.main"}},children:e.jsx(k.Settings,{sx:{fontSize:16}})})})]}),c&&e.jsxs(r.MenuItem,{onClick:A(y),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(k.Settings,{sx:{fontSize:16,color:"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Manage Columns",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),w&&e.jsxs(r.MenuItem,{onClick:A(w),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(k.TableRows,{sx:{fontSize:16,color:"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Manage Views",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),!c&&d&&v&&e.jsxs(r.MenuItem,{onClick:A(v),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:E(I.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(k.RestartAlt,{sx:{fontSize:16,color:"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Reset to Default Layout",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]})]}),document.body)}const hd=150,Qn="COLUMN_HEADER",gd=p.memo(function({column:o,index:n,sortRule:i,hasFilters:s,isInSortStack:c,isReadOnly:d=!1,hasModifications:l=!1,width:u,onColumnClick:m,onMoveColumn:h,onResizeStart:b,onSortAscending:f,onSortDescending:g,onRemoveSort:T,onOpenFilterForColumn:y,onClearFiltersForColumn:w,onGroupByColumn:v,onHideColumn:j,onManageColumns:S,onManageViews:I,onResetLayout:a}){const A=p.useRef(null),[B,$]=p.useState(!1),[Y,Q]=p.useState({x:0,y:0}),[{handlerId:te,isOver:x},N]=wt.useDrop({accept:Qn,collect(G){return{handlerId:G.getHandlerId(),isOver:G.isOver()}},hover(G,se){var ie;if(!A.current)return;const ee=G.index,le=n;if(ee===le)return;const ae=(ie=A.current)==null?void 0:ie.getBoundingClientRect(),P=(ae.right-ae.left)/2,ne=se.getClientOffset(),ce=((ne==null?void 0:ne.x)??0)-ae.left;ee<le&&ce<P||ee>le&&ce>P||(h(ee,le),G.index=le)}}),[{isDragging:W},H]=wt.useDrag({type:Qn,item:()=>({index:n,columnName:o.name}),collect:G=>({isDragging:G.isDragging()})});H(N(A));const J=p.useCallback(G=>{G.preventDefault(),G.stopPropagation(),Q({x:G.clientX,y:G.clientY}),$(!0)},[]),ue=p.useCallback(()=>$(!1),[]),pe=p.useCallback(()=>{m(o.name)},[m,o.name]),re=p.useCallback(G=>{G.stopPropagation(),y(o.name)},[y,o.name]),O=p.useCallback(()=>i?e.jsxs(r.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[i.direction==="asc"?e.jsx(k.ArrowUpward,{sx:{fontSize:13,color:"primary.main"}}):e.jsx(k.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]),F=p.useCallback(()=>s?e.jsx(r.Box,{onClick:re,title:"Active filters on this column",sx:{ml:.75,width:7,height:7,borderRadius:"50%",bgcolor:"primary.main",cursor:"pointer",flexShrink:0,"&:hover":{transform:"scale(1.25)"},transition:"transform 0.12s ease"}}):null,[s,re]);return e.jsxs(e.Fragment,{children:[e.jsxs(r.TableCell,{ref:A,"data-handler-id":te,"data-column-index":n,onClick:pe,onContextMenu:J,sx:{position:"sticky",top:0,zIndex:50,textAlign:"left",fontSize:"0.8125rem",fontWeight:700,textTransform:"none",letterSpacing:0,whiteSpace:"nowrap",overflow:"hidden",cursor:"pointer",userSelect:"none",color:"primary.main",opacity:W?.25:1,transition:"background-color 0.12s ease, opacity 0.15s ease",bgcolor:x?G=>E(G.palette.primary.main,.08):"action.hover",boxShadow:"0 1px 0 rgba(0,0,0,0.08)",backgroundImage:"none",borderBottom:"1px solid",borderColor:"divider",py:0,px:2,height:34,"&:hover":{bgcolor:G=>E(G.palette.primary.main,.1),color:"primary.dark"},width:u?`${u}px`:`${hd}px`},children:[e.jsxs(r.Box,{sx:{display:"inline-flex",alignItems:"center"},children:[Ge(o.name),O(),F()]}),e.jsx(r.Box,{sx:{position:"absolute",right:0,top:0,height:"100%",width:8,cursor:"col-resize",zIndex:10,"&:hover":{bgcolor:"primary.light"}},onMouseDown:G=>{G.stopPropagation(),b(G,o.name)},onClick:G=>G.stopPropagation()}),x&&e.jsx(r.Box,{sx:{position:"absolute",left:0,top:0,bottom:0,width:4,bgcolor:"primary.main"}})]}),B&&e.jsx(fd,{columnName:o.name,columnType:o.type,currentSort:i,hasFilters:s,isInSortStack:c,isReadOnly:d,hasModifications:l,position:Y,onSortAscending:f,onSortDescending:g,onRemoveSort:T,onFilter:y,onClearFilter:w,onGroupByColumn:v,onHideColumn:j,onManageColumns:S,onManageViews:I,onResetLayout:a,onClose:ue})]})});function yd({selectedCount:t,selectedRowIds:o,resolvedFavoritesSet:n,viewMode:i="list",onExportSelected:s,onClearSelection:c,onBulkSetFavorites:d}){const[l,u]=p.useState(null),m=p.useMemo(()=>Array.from(o),[o]),h=p.useMemo(()=>m.filter(v=>n.has(v)),[m,n]),b=p.useMemo(()=>m.filter(v=>!n.has(v)),[m,n]),f=h.length>0,g=b.length>0;if(t===0)return null;const T=()=>{d&&d(m,!0)},y=()=>{d&&d(m,!1)},w=v=>{s(v),u(null)};return e.jsx(r.Box,{sx:{width:"100%",flexShrink:0,bgcolor:v=>E(v.palette.primary.main,.08),borderBottom:v=>`1px solid ${E(v.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:c,startIcon:e.jsx(k.Close,{sx:{fontSize:16}}),size:"small",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2,py:.625,borderRadius:"18px",color:"text.secondary","&:hover":{bgcolor:v=>E(v.palette.text.primary,.06),color:"text.primary"}},children:"Clear"}),e.jsx(r.Button,{onClick:v=>u(v.currentTarget),startIcon:e.jsx(k.Download,{sx:{fontSize:16}}),size:"small",variant:"outlined",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2,py:.625,borderRadius:"18px",borderColor:v=>E(v.palette.primary.main,.4),color:"primary.main","&:hover":{borderColor:"primary.main",bgcolor:v=>E(v.palette.primary.main,.06)}},children:"Export Selected"}),e.jsxs(r.Menu,{anchorEl:l,open:!!l,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:()=>w("csv"),sx:{py:1,px:2},children:"Export as CSV"}),e.jsx(r.MenuItem,{dense:!0,onClick:()=>w("excel"),sx:{py:1,px:2},children:"Export as Excel"}),e.jsx(r.MenuItem,{dense:!0,onClick:()=>w("json"),sx:{py:1,px:2},children:"Export as JSON"})]}),d&&g&&e.jsx(r.Button,{onClick:T,startIcon:e.jsx(k.StarBorder,{sx:{fontSize:16}}),size:"small",variant:"outlined",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2,py:.625,borderRadius:"18px",borderColor:v=>E(v.palette.warning.main,.5),color:"warning.dark","&:hover":{borderColor:"warning.main",bgcolor:v=>E(v.palette.warning.main,.06)}},children:"Add to Favorites"}),d&&f&&e.jsx(r.Button,{onClick:y,startIcon:e.jsx(k.Star,{sx:{fontSize:16,color:"#fbbc04"}}),size:"small",variant:"outlined",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2,py:.625,borderRadius:"18px",borderColor:v=>E(v.palette.warning.main,.5),color:"warning.dark","&:hover":{borderColor:"warning.main",bgcolor:v=>E(v.palette.warning.main,.06)}},children:"Remove from Favorites"})]})]})})}const bd={active:{bg:"#e6f4ea",color:"#137333"},completed:{bg:"#e6f4ea",color:"#137333"},approved:{bg:"#e6f4ea",color:"#137333"},success:{bg:"#e6f4ea",color:"#137333"},done:{bg:"#e6f4ea",color:"#137333"},contract:{bg:"#e8eaf6",color:"#3949ab"},"in progress":{bg:"#e8eaf6",color:"#3949ab"},"in review":{bg:"#e8eaf6",color:"#3949ab"},review:{bg:"#e8eaf6",color:"#3949ab"},pending:{bg:"#e8eaf6",color:"#3949ab"},"on leave":{bg:"#fce8e6",color:"#c5221f"},"on hold":{bg:"#fff8e1",color:"#e65100"},probation:{bg:"#fff8e1",color:"#e65100"},cancelled:{bg:"#fce8e6",color:"#c5221f"},rejected:{bg:"#fce8e6",color:"#c5221f"},blocked:{bg:"#fce8e6",color:"#c5221f"},inactive:{bg:"#f1f3f4",color:"text.secondary"},"not started":{bg:"#f1f3f4",color:"text.secondary"},paused:{bg:"#f1f3f4",color:"text.secondary"}},vd={low:"text.secondary",medium:"#e65100",high:"#e8710a",critical:"#c5221f",urgent:"#c5221f"};function Sd(t){const o=t.toLowerCase().trim(),n=bd[o]||{bg:"#f1f3f4",color:"text.secondary"};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.bg,color:n.color,whiteSpace:"nowrap",lineHeight:1.5},children:t})}function jd(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 Sd(n);if(/\b(priority|severity|urgency)\b/.test(i)){const s=vd[n.toLowerCase().trim()];return s?e.jsx(r.Box,{component:"span",sx:{color:s,fontWeight:600,fontSize:"0.8125rem"},children:n}):e.jsx(r.Box,{component:"span",sx:{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 Cd(t){const o=t.find(s=>{const c=s.name.toLowerCase();return/\b(name|title|label|subject|task_?name|taskname)\b/.test(c)})||t[0]||null,n=t.find(s=>{const c=s.name.toLowerCase().replace(/[\s_-]/g,"");return/(^id$|id$|_id$|taskid|code$|ref$)/.test(c)&&s!==o})||null,i=t.filter(s=>s!==o&&s!==n).slice(0,4);return{primaryCol:o,idCol:n,bodyColumns:i}}function wd({row:t,rowIndex:o,visibleColumns:n,isSelected:i,isFavorite:s,isReadOnly:c,onToggleSelection:d,onToggleFavorite:l,onView:u,onEdit:m,onDuplicate:h,onDelete:b}){const[f,g]=p.useState(null),[T,y]=p.useState(!1),{primaryCol:w,idCol:v,bodyColumns:j}=p.useMemo(()=>Cd(n),[n]),S=w?t[w.name]:null,I=v?t[v.name]:null,a=T||i||s||!!f;return e.jsxs(r.Box,{onMouseEnter:()=>y(!0),onMouseLeave:()=>y(!1),onClick:()=>d(o),sx:{position:"relative",display:"flex",flexDirection:"column",bgcolor:"background.paper",border:"1px solid",borderColor:i?"primary.main":A=>E(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 ${E(A.palette.primary.main,.15)}, 0 2px 8px ${E(A.palette.common.black,.08)}`:T?"0 4px 16px rgba(60,64,67,0.15), 0 1px 4px rgba(60,64,67,0.08)":"0 1px 3px rgba(60,64,67,0.08), 0 1px 2px rgba(60,64,67,0.06)",transform:T&&!i?"translateY(-2px)":"none","&:active":{transform:"translateY(0)"},...i&&{bgcolor:A=>E(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:S!=null&&S!==""?String(S):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(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:Ge(A.name)}),e.jsx(r.Box,{sx:{flex:1,lineHeight:1},children:jd(A,t[A.name])})]},A.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:A=>E(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:I?.85:0,userSelect:"none"},children:I?String(I):" "}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.25,opacity:a?1:0,transition:"opacity 0.15s ease"},onClick:A=>A.stopPropagation(),children:[l&&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(),l(t)},sx:{width:28,height:28,color:s?"#fbbc04":"action.disabled","&:hover":{bgcolor:A=>E(A.palette.warning.main,.1),color:"#fbbc04"}},children:s?e.jsx(k.Star,{sx:{fontSize:17}}):e.jsx(k.StarBorder,{sx:{fontSize:17}})})}),e.jsx(r.Tooltip,{title:"More actions",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:A=>{A.stopPropagation(),g(A.currentTarget)},sx:{width:28,height:28,color:"action.active","&:hover":{bgcolor:A=>E(A.palette.text.primary,.08)}},children:e.jsx(k.MoreVert,{sx:{fontSize:17}})})})]})]}),e.jsxs(r.Popover,{open:!!f,anchorEl:f,onClose:()=>g(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},PaperProps:{sx:{minWidth:180,py:.5,borderRadius:"10px",boxShadow:"0 4px 20px rgba(60,64,67,0.15), 0 1px 6px rgba(60,64,67,0.1)"}},onClick:A=>A.stopPropagation(),children:[e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{u(t),g(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[e.jsx(k.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"View"})]}),!c&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{m(t,o),g(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[e.jsx(k.Edit,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Edit"})]}),!c&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{h(o,t),g(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[e.jsx(k.ContentCopy,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Duplicate"})]}),!c&&e.jsxs(e.Fragment,{children:[e.jsx(r.Divider,{sx:{my:.5,mx:.5}}),e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{b(o,t),g(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5,color:"error.main"},children:[e.jsx(k.Delete,{sx:{fontSize:18,color:"error.main"}}),e.jsx(r.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]})]})]})}function kd({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:"0 1px 2px rgba(60,64,67,0.06)","&:hover":{bgcolor:s=>E(s.palette.primary.main,.04),borderColor:"primary.light"},transition:"all 0.15s ease"},children:[t.isCollapsed?e.jsx(k.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}):e.jsx(k.KeyboardArrowDown,{sx:{fontSize:16,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600,color:"text.primary"},children:yi(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=>E(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,c])=>gi(c)).filter(Boolean).join(" • ")})]})}function Td({data:t,visibleColumns:o,grouping:n,selectedRowIds:i,resolvedFavoritesSet:s,isReadOnly:c,isGrouped:d,sortStack:l=[],onSort:u,onToggleRowSelection:m,onToggleRowFavorite:h,onToggleGroupCollapse:b,onViewRow:f,onEditRow:g,onDuplicateRow:T,onDeleteRow:y}){const w=p.useMemo(()=>{const v=new Set;return i.forEach(j=>{const S=j==null?void 0:j.__urm_row_id__;S!==void 0&&v.add(S)}),v},[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,{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(v=>{const j=l.find(S=>S.column===v.name);return e.jsxs(r.Box,{onClick:()=>u(v.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?S=>E(S.palette.primary.main,.07):"transparent",cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:"primary.light",bgcolor:S=>E(S.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:Ge(v.name)}),j?j.direction==="asc"?e.jsx(k.ArrowUpward,{sx:{fontSize:12,color:"primary.main"}}):e.jsx(k.ArrowDownward,{sx:{fontSize:12,color:"primary.main"}}):e.jsx(k.SwapVert,{sx:{fontSize:12,color:"text.disabled"}})]},v.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((v,j)=>d&&v.isGroupHeader?e.jsx(kd,{row:v,grouping:n,onToggleCollapse:b||(()=>{})},`group-${v.groupKey}`):e.jsx(wd,{row:v,rowIndex:j,visibleColumns:o,isSelected:w.has(v==null?void 0:v.__urm_row_id__),isFavorite:s.has(v),isReadOnly:c,onToggleSelection:()=>m(v),onToggleFavorite:h,onView:f,onEdit:g,onDuplicate:T,onDelete:y},`card-${j}`))})]})}const ei=[10,15,25,50,100];function Id(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 zd({currentPage:t,pageSize:o,totalRows:n,totalFields:i,onPageChange:s,onPageSizeChange:c}){var N;const l=Tt().palette,u=Math.ceil(n/o),[m,h]=p.useState(String(t)),[b,f]=p.useState(null),[g,T]=p.useState(!1),y=p.useRef(null);p.useEffect(()=>{g||(h(String(t)),f(null))},[t,g]);const w=p.useCallback(()=>{const W=Id(m,u);if(W){f(W);return}const H=parseInt(m.trim(),10);f(null),T(!1),H!==t&&s(H)},[m,u,t,s]),v=p.useCallback(W=>{var H;W.key==="Enter"?(W.preventDefault(),w()):W.key==="Escape"&&(h(String(t)),f(null),T(!1),(H=y.current)==null||H.blur())},[w,t]),j=p.useCallback(()=>{h(String(t)),f(null),T(!1)},[t]),S=p.useCallback(()=>{T(!0),f(null),setTimeout(()=>{var W;return(W=y.current)==null?void 0:W.select()},0)},[]);if(n<=Math.min(...ei))return null;const I=()=>{h(String(t)),f(null),T(!1)},a=()=>{I(),s(1)},A=()=>{I(),t>1&&s(t-1)},B=()=>{I(),t<u&&s(t+1)},$=()=>{I(),s(u)},Y=(t-1)*o+1,Q=Math.min(t*o,n),te=`${Math.max(2,String(u).length+.5)}ch`,x={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=>c(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:ei.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:[Y,"–",Q," 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:E(l.error.main,.4),borderRadius:"6px",px:1,py:.5,boxShadow:`0 2px 8px ${E(((N=l.common)==null?void 0:N.black)??"#000",.12)}`,zIndex:20,whiteSpace:"nowrap","&::after":{content:'""',position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)",border:"5px solid transparent",borderTopColor:E(l.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:y,value:m,onChange:W=>{h(W.target.value),b&&f(null)},onKeyDown:v,onFocus:S,onBlur:j,inputProps:{"aria-label":`Page number, 1 to ${u}`,style:{textAlign:"center",padding:"2px 0",width:te,fontSize:"0.8125rem",fontWeight:600}},sx:{fontSize:"0.8125rem",fontWeight:600,color:b?"error.main":"text.primary",border:"1px solid",borderColor:b?"error.main":g?"primary.main":"divider",borderRadius:"4px",bgcolor:b?E(l.error.main,.04):g?E(l.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 ${E(l.error.main,.2)}`:`0 0 0 2px ${E(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:a,disabled:t===1,size:"small",title:"First page",sx:x,children:e.jsx(k.FirstPage,{sx:{fontSize:20}})}),e.jsx(r.IconButton,{onClick:A,disabled:t===1,size:"small",title:"Previous page",sx:x,children:e.jsx(k.ChevronLeft,{sx:{fontSize:20}})}),e.jsx(r.IconButton,{onClick:B,disabled:t===u,size:"small",title:"Next page",sx:x,children:e.jsx(k.ChevronRight,{sx:{fontSize:20}})}),e.jsx(r.IconButton,{onClick:$,disabled:t===u,size:"small",title:"Last page",sx:x,children:e.jsx(k.LastPage,{sx:{fontSize:20}})})]})]})]})}function Ed(){return e.jsx(r.Chip,{icon:e.jsx(k.Visibility,{sx:{fontSize:14}}),label:"View Only",size:"small",variant:"outlined",sx:{bgcolor:"action.hover",borderColor:"divider",fontSize:"caption.fontSize",fontWeight:500}})}const Hi="urm_hint_seen_";function Bd(t){try{return localStorage.getItem(Hi+t)==="true"}catch{return!1}}function Dd(t){try{localStorage.setItem(Hi+t,"true")}catch{}}function ti(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 ri(t){const o={fontSize:11};switch(t){case"number":return e.jsx(k.Numbers,{sx:o});case"boolean":return e.jsx(k.CheckBox,{sx:o});case"array":return e.jsx(k.DataArray,{sx:o});case"object":return e.jsx(k.DataObject,{sx:o});default:return e.jsx(k.TextFields,{sx:o})}}function oi(t,o){var n,i;switch(t){case"number":return{bg:E(o.primary.main,.08),color:o.primary.main};case"boolean":return{bg:E(((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:E(o.secondary.main,.08),color:o.secondary.main};default:return{bg:E(o.text.secondary,.07),color:o.text.secondary}}}function Od({open:t,onClose:o,row:n,schema:i,reportName:s}){var b,f;const d=Tt().palette;if(!n)return null;const l=i.filter(g=>g.name in n),u=l.filter(g=>g.type!=="object"&&g.type!=="array"),m=l.filter(g=>g.type==="object"||g.type==="array"),h=l.length;return e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:"16px",maxHeight:"min(720px, calc(100vh - 80px))",display:"flex",flexDirection:"column",boxShadow:`0 8px 32px ${E(((b=d.common)==null?void 0:b.black)??"#000",.14)}, 0 2px 8px ${E(((f=d.common)==null?void 0:f.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:E(d.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(k.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," · ",h," ",h===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(k.Close,{sx:{fontSize:18}})})]}),e.jsx(r.Divider,{}),e.jsxs(r.DialogContent,{sx:{p:0,overflowY:"auto",flex:1,bgcolor:E(d.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:m.length>0?1.5:2,borderRadius:"12px",overflow:"hidden",border:"1px solid",borderColor:"divider"},children:u.map((g,T)=>{const y=n[g.name],w=ti(y,g.type),v=!w,j=oi(g.type,d),S=T===u.length-1&&u.length%2!==0;return e.jsxs(r.Box,{sx:{bgcolor:"background.paper",px:2,py:1.75,gridColumn:S?"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:j.bg,color:j.color,flexShrink:0},children:ri(g.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:Ge(g.name)})]}),e.jsx(r.Typography,{sx:{fontSize:"0.875rem",fontWeight:v?400:500,color:v?"text.disabled":"text.primary",fontStyle:v?"italic":"normal",lineHeight:1.5,wordBreak:"break-word",fontFamily:g.type==="number"?'"Roboto Mono", monospace':"inherit"},children:v?"No value":w})]},g.name)})}),m.map(g=>{const T=n[g.name],y=ti(T,g.type),w=!y,v=oi(g.type,d);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:v.bg,color:v.color},children:ri(g.type)}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.06em"},children:Ge(g.name)}),e.jsx(r.Chip,{label:g.type,size:"small",sx:{height:18,fontSize:"0.625rem",fontWeight:600,ml:"auto",bgcolor:v.bg,color:v.color,border:"none",letterSpacing:"0.03em"}})]}),e.jsx(r.Box,{component:"pre",sx:{m:0,px:2,py:1.5,bgcolor:E(d.text.primary,.02),fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:w?"text.disabled":"text.primary",fontStyle:w?"italic":"normal",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6},children:w?"No value":y})]},g.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(k.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",disableElevation:!0,sx:{textTransform:"none",fontSize:"0.8125rem",fontWeight:500,px:3,py:.75,borderRadius:"8px",minWidth:80},children:"Close"})})]})}function Ad({open:t,onClose:o,onConfirm:n,rowPreview:i}){return e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",maxHeight:"min(480px, calc(100vh - 180px))",my:"auto",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[e.jsxs(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:"#fce8e6",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(k.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:"#f1f3f4",color:"text.primary"}},children:e.jsx(k.Close,{sx:{fontSize:20}})})]}),e.jsx(r.DialogContent,{sx:{px:3,pb:2},children:e.jsx(r.Box,{sx:{p:2,borderRadius:"8px",bgcolor:"#fce8e6",border:"1px solid #f28b82"},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:"grey.50",gap:1.25,justifyContent:"flex-end"},children:[e.jsx(r.Button,{onClick:o,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:()=>{n(),o()},variant:"contained",startIcon:e.jsx(k.DeleteForever,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"error.main",color:"common.white",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#b3190e",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Delete record"})]})]})}function Ho(t){const o={fontSize:11};switch(t){case"number":return e.jsx(k.Numbers,{sx:o});case"boolean":return e.jsx(k.CheckBox,{sx:o});case"array":return e.jsx(k.DataArray,{sx:o});case"object":return e.jsx(k.DataObject,{sx:o});default:return e.jsx(k.TextFields,{sx:o})}}function ni(t,o){var n,i;switch(t){case"number":return{bg:E(o.primary.main,.08),color:o.primary.main};case"boolean":return{bg:E(((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:E(o.secondary.main,.08),color:o.secondary.main};default:return{bg:E(o.text.secondary,.07),color:o.text.secondary}}}function Md({open:t,onClose:o,onSave:n,row:i,schema:s,reportName:c}){var w,v,j;const l=Tt().palette,[u,m]=p.useState({});if(p.useEffect(()=>{t&&i&&m({...i})},[t,i]),!i)return null;const h=s.filter(S=>S.name in i),b=h.filter(S=>S.type!=="object"&&S.type!=="array"),f=h.filter(S=>S.type==="object"||S.type==="array"),g=(S,I)=>{m(a=>({...a,[S]:I}))},T=()=>{const S={...u};h.forEach(I=>{const a=u[I.name];if(I.type==="number"){const A=Number(a);S[I.name]=isNaN(A)?i[I.name]:A}else I.type==="boolean"&&(S[I.name]=!!a)}),n(S),o()},y=h.length;return e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:"16px",maxHeight:"min(760px, calc(100vh - 80px))",display:"flex",flexDirection:"column",boxShadow:`0 8px 32px ${E(((w=l.common)==null?void 0:w.black)??"#000",.14)}, 0 2px 8px ${E(((v=l.common)==null?void 0:v.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:E(((j=l.warning)==null?void 0:j.main)??"#ed6c02",.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(k.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"}),c&&e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary",display:"block",mt:.25,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[c," · ",y," ",y===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(k.Close,{sx:{fontSize:18}})})]}),e.jsx(r.Divider,{}),e.jsxs(r.DialogContent,{sx:{p:2.5,overflowY:"auto",flex:1,bgcolor:E(l.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((S,I)=>{const a=u[S.name],A=ni(S.type,l),B=S.type==="boolean",$=!B&&I===b.filter(Q=>Q.type!=="boolean").length-1&&b.filter(Q=>Q.type!=="boolean").length%2!==0,Y=B||$;return S.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:Ho(S.type)}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.06em"},children:Ge(S.name)})]}),e.jsx(r.Typography,{sx:{fontSize:"0.8125rem",color:"text.secondary",ml:.25},children:a?"Enabled":"Disabled"})]}),e.jsx(r.Switch,{checked:!!a,onChange:Q=>g(S.name,Q.target.checked),size:"small",sx:{"& .MuiSwitch-switchBase.Mui-checked":{color:"primary.main"},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{bgcolor:"primary.main"}}})]},S.name):e.jsxs(r.Box,{sx:{gridColumn:Y?"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 ${E(l.primary.main,.12)}`}},children:[e.jsxs(r.Box,{sx:{px:1.5,py:.875,borderBottom:"1px solid",borderColor:"divider",bgcolor:E(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:Ho(S.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:Ge(S.name)})]}),e.jsx(r.TextField,{value:a??"",onChange:Q=>g(S.name,Q.target.value),type:S.type==="number"?"number":"text",size:"small",fullWidth:!0,variant:"standard",placeholder:`Enter ${S.type==="number"?"number":"value"}…`,InputProps:{disableUnderline:!0},sx:{"& .MuiInputBase-root":{px:1.5,py:1,fontSize:"0.875rem",fontWeight:500,color:"text.primary",fontFamily:S.type==="number"?'"Roboto Mono", monospace':"inherit"},"& .MuiInputBase-input":{p:0,"&::placeholder":{color:"text.disabled",opacity:1,fontWeight:400}}}})]},S.name)})})]}),f.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(k.InfoOutlined,{sx:{fontSize:13,color:"text.disabled",cursor:"help"}})})]}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1.5},children:f.map(S=>{const I=i[S.name];let a="";try{a=I==null?"":JSON.stringify(I,null,2)}catch{a=String(I)}const A=ni(S.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:E(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:Ho(S.type)}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.06em",flex:1},children:Ge(S.name)}),e.jsx(r.Chip,{label:"read only",size:"small",sx:{height:16,fontSize:"0.5625rem",fontWeight:600,letterSpacing:"0.04em",bgcolor:E(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:a?"text.primary":"text.disabled",fontStyle:a?"normal":"italic",bgcolor:E(l.text.primary,.015),overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6,maxHeight:120,overflowY:"auto"},children:a||"No value"})]},S.name)})})]}),h.length===0&&e.jsxs(r.Box,{sx:{py:6,display:"flex",flexDirection:"column",alignItems:"center",gap:1,color:"text.disabled"},children:[e.jsx(k.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:{textTransform:"none",fontSize:"0.8125rem",fontWeight:500,color:"text.secondary",px:2,borderRadius:"8px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:T,variant:"contained",disableElevation:!0,startIcon:e.jsx(k.SaveOutlined,{sx:{fontSize:15}}),sx:{textTransform:"none",fontSize:"0.8125rem",fontWeight:500,px:2.5,borderRadius:"8px",minWidth:90},children:"Save"})]})]})}const _d=160,$d={active:{bg:"success.lighter",color:"success.dark"},completed:{bg:"success.lighter",color:"success.dark"},approved:{bg:"success.lighter",color:"success.dark"},success:{bg:"success.lighter",color:"success.dark"},done:{bg:"success.lighter",color:"success.dark"},contract:{bg:"primary.lighter",color:"primary.main"},"in progress":{bg:"primary.lighter",color:"primary.main"},"in review":{bg:"primary.lighter",color:"primary.main"},review:{bg:"primary.lighter",color:"primary.main"},pending:{bg:"primary.lighter",color:"primary.main"},"on leave":{bg:"error.lighter",color:"error.dark"},"on hold":{bg:"warning.lighter",color:"warning.dark"},probation:{bg:"warning.lighter",color:"warning.dark"},cancelled:{bg:"error.lighter",color:"error.dark"},rejected:{bg:"error.lighter",color:"error.dark"},blocked:{bg:"error.lighter",color:"error.dark"},inactive:{bg:"action.selected",color:"text.secondary"},"not started":{bg:"action.selected",color:"text.secondary"},paused:{bg:"action.selected",color:"text.secondary"}},Wd={low:"text.secondary",medium:"warning.dark",high:"warning.main",critical:"error.main",urgent:"error.main"};function Rd(t){const o=t.toLowerCase().trim(),n=$d[o]||{bg:"grey.100",color:"grey.600"};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.bg,color:n.color,whiteSpace:"nowrap",lineHeight:1.6,letterSpacing:"0.01em"},children:t})}function Pd(t){const o=t.toLowerCase().trim(),n=Wd[o];return n?e.jsx(r.Box,{component:"span",sx:{color:n,fontWeight:500,fontSize:"inherit"},children:t}):t}function Nd(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 Ld(t,o){const n=t.name.toLowerCase().replace(/[_\s-]/g,""),i=t.name.toLowerCase(),s=o.findIndex(m=>m.name===t.name),c=/(\bid\b|id$|_id$|code$|ref$|no$|num$)/.test(n),d=i.includes("name")||i.includes("task")||i.includes("title")||i.includes("label")||i.includes("subject")||i.includes("description")||i.includes("filename"),l=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 c||d&&!l||u&&!l}function Fd(t){return e.jsx(r.Box,{component:"span",sx:{fontWeight:700,color:"text.primary",fontSize:"inherit"},children:t})}function Vd(t,o,n=!1,i){if(o==null||o==="")return e.jsx(r.Box,{component:"span",sx:{color:"grey.400"},children:"—"});const s=String(o),c=t.name.toLowerCase().replace(/[_\s-]/g,""),d=/\b(status|state|stage|employmenttype|contracttype|availability)\b/.test(t.name.toLowerCase());if(d)return Rd(s);const l=/\b(priority|severity|urgency|importance|criticality)\b/.test(t.name.toLowerCase());if(l)return Pd(s);const u=/(\bid\b|id$|_id$|code$|ref$|no$|num$)/.test(c)||/^[A-Z]{2,8}-\d{2,}$/.test(s);if(u)return Nd(s);if(n&&!d&&!l&&!u)return Fd(s);if(t.type==="date"){const m=t.dateFormat??"iso",h=Vs(o,m,i??null);return e.jsx(r.Box,{component:"span",sx:{color:"text.primary",whiteSpace:"nowrap"},children:h})}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:"grey.400"},children:"[ ]"});const m=o.slice(0,3).map(h=>typeof h=="object"?JSON.stringify(h):String(h)).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 s}function Hd({schema:t,data:o,sortStack:n=[],filters:i=[],views:s=[],activeViewId:c="",isDirty:d=!1,isExporting:l=!1,columnVisibility:u={},columnOrder:m=[],columnWidths:h={},grouping:b=null,onSort:f,onSortAscending:g,onSortDescending:T,onOpenFilters:y,onOpenSort:w,onOpenFilterForColumn:v,onSelectView:j,onCreateView:S,onManageViews:I,onUpdateCurrentView:a,onSaveAsNewView:A,onToggleDefault:B,onToggleFavorite:$,onRestoreView:Y,onPermanentDelete:Q,isAdmin:te=!1,onExport:x,onOpenColumns:N,onUpdateColumnWidth:W,onUpdateColumnOrder:H,onUpdateColumnVisibility:J,onClearFiltersForColumn:ue,onResetLayout:pe,onOpenGroup:re,onGroupByColumn:O,onToggleGroupCollapse:F,onOpenAuditHistory:G,onOpenScheduledReports:se,searchQuery:ee,searchHistory:le=[],onAddToSearchHistory:ae,onToggleSearchFavourite:P,onDeleteSearchHistory:ne,selectedRowIds:ce=new Set,onSearchChange:ie,onToggleRowSelection:he,onToggleAllRows:q,onRangeSelection:Ae,onClearSelection:We,onExportSelected:tt,currentPage:Kt=1,pageSize:hr=15,totalRowsBeforePagination:At=o.length,onPageChange:it,onPageSizeChange:Re,isReadOnly:Ee=!1,userRole:gt,reportName:st,onEditRow:rt,onDuplicateRow:Je,onDeleteRow:It,favoriteRowIndices:Xt=[],resolvedFavoritesSet:at=new Set,showFavoritesOnly:Ke=!1,onToggleRowFavorite:Pe,onBulkSetFavorites:Zt,showDevPanel:yt=!1,onOpenDevConfig:zt,onToggleFavoritesFilter:Qt}){var Ft;const[lt,gr]=p.useState(null),[yr,br]=p.useState(0),[Mt,vr]=p.useState(0),Xe=((Ft=Gt().dates)==null?void 0:Ft.displayFormat)??null,[ve,jr]=p.useState(null),[er,ot]=p.useState(null),[L,Ne]=p.useState(null),[Se,_e]=p.useState(!1),[Cr,_t]=p.useState(!1),[bt,$t]=p.useState(null),[Wt,Et]=p.useState(""),[wr,Rt]=p.useState(!1),[De,X]=p.useState(null),[vt,ge]=p.useState(null),[je,Ze]=p.useState(null),[kr,St]=p.useState(null),[$e,tr]=p.useState("list"),[Tr,rr]=p.useState(!1),[or,Ir]=p.useState(()=>!Bd("toolbar_search"));p.useRef(null);const nr=p.useCallback(()=>{Dd("toolbar_search"),Ir(!1)},[]),ir=p.useMemo(()=>m.length>0?m.map(M=>t.find(Z=>Z.name===M)).filter(M=>M!==void 0):t,[m,t]),Le=p.useMemo(()=>ir.filter(M=>u[M.name]!==!1),[ir,u]),ct=p.useMemo(()=>t.filter(M=>u[M.name]===!1).length,[t,u]),dt=p.useMemo(()=>t.map(M=>M.name),[t]),Fe=p.useMemo(()=>JSON.stringify(m)!==JSON.stringify(dt),[m,dt]),sr=p.useCallback((M,Z)=>{M.preventDefault(),M.stopPropagation(),gr(Z),br(M.clientX),vr(h[Z]||150)},[h]);p.useEffect(()=>{if(!lt)return;const M=K=>{const de=K.clientX-yr,oe=Math.max(100,Mt+de);W==null||W(lt,oe)},Z=()=>{gr(null)};return document.addEventListener("mousemove",M),document.addEventListener("mouseup",Z),()=>{document.removeEventListener("mousemove",M),document.removeEventListener("mouseup",Z)}},[lt,yr,Mt,W]);const Pt=p.useCallback(M=>M==null?"-":typeof M=="object"?JSON.stringify(M):typeof M=="boolean"?M?"true":"false":String(M),[]);p.useCallback(M=>{const Z=n.find(K=>K.column===M);return Z?e.jsxs(r.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[Z.direction==="asc"?e.jsx(k.ArrowUpward,{sx:{fontSize:14}}):e.jsx(k.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:Z.priority})]}):null},[n]),p.useCallback(M=>i.some(K=>K.column===M)?e.jsx(r.IconButton,{size:"small",onClick:K=>{K.stopPropagation(),v==null||v(M)},sx:{ml:.5,p:.25,color:"primary.main","&:hover":{color:"primary.main"}},title:"Active filters on this column",children:e.jsx(k.FilterList,{sx:{fontSize:14}})}):null,[i,v]);const zr=p.useCallback(M=>{f&&f(M)},[f]),Er=p.useCallback((M,Z)=>{if(!H)return;const K=[...m.length>0?m:t.map(oe=>oe.name)],[de]=K.splice(M,1);K.splice(Z,0,de),H(K)},[H,m,t]),Br=p.useCallback(M=>{if(!f)return;const Z=n.find(K=>K.column===M);(!Z||Z.direction!=="asc")&&f(M)},[f,n]),Dr=p.useCallback(M=>{if(!f)return;const Z=n.find(K=>K.column===M);Z?Z.direction==="asc"&&f(M):(f(M),setTimeout(()=>f(M),0))},[f,n]),Or=p.useCallback(M=>{if(!f)return;const Z=n.find(K=>K.column===M);Z&&(Z.direction==="asc"?(f(M),setTimeout(()=>f(M),0)):Z.direction==="desc"&&f(M))},[f,n]),Ar=p.useCallback(M=>{J&&J(M,!1)},[J]),Nt=(b==null?void 0:b.enabled)&&o.length>0&&o[0]&&"isGroupHeader"in o[0],Mr=n.length>0||i.length>0||((b==null?void 0:b.enabled)??!1)||Object.values(u).some(M=>M===!1),_r=(Kt-1)*hr,Me=o,Ve=p.useMemo(()=>{const M=new Set;return ce.forEach(Z=>{const K=Z==null?void 0:Z.__urm_row_id__;K!==void 0&&M.add(K)}),M},[ce]);p.useEffect(()=>{const M=Z=>{!q||!We||Z.target instanceof HTMLInputElement||Z.target instanceof HTMLTextAreaElement||((Z.ctrlKey||Z.metaKey)&&Z.key==="a"&&(Z.preventDefault(),q(!0,Me)),Z.key==="Escape"&&(Z.preventDefault(),We()))};return document.addEventListener("keydown",M),()=>document.removeEventListener("keydown",M)},[q,We,Me]);const ar=p.useCallback((M,Z)=>{he&&(Z.shiftKey&&ve!==null?(Z.preventDefault(),Ae&&Ae(ve,M,Me)):(he(Me[M]),jr(M)))},[he,ve,Ae,Me]);!p.useMemo(()=>Me.length>0&&Ve.size>0&&Me.every(M=>Ve.has(M==null?void 0:M.__urm_row_id__)),[Me,Ve])&&Me.some(M=>Ve.has(M==null?void 0:M.__urm_row_id__));const ut=he&&q,lr=p.useCallback(M=>{var de;const Z=M.groupLevel,K=Z*24;return e.jsx(r.TableRow,{onClick:()=>F==null?void 0:F(M.groupKey),sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"},cursor:"pointer",borderTop:2,borderColor:"divider"},children:e.jsx(r.TableCell,{colSpan:Le.length+(ut?1:0),sx:{pl:`${K+24}px`},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[M.isCollapsed?e.jsx(k.ChevronRight,{sx:{fontSize:16}}):e.jsx(k.KeyboardArrowDown,{sx:{fontSize:16}}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600},children:yi(Z,((de=b==null?void 0:b.levels[Z])==null?void 0:de.column)||"",M.groupValue)}),e.jsxs(r.Box,{sx:{px:1,py:.25,fontSize:"caption.fontSize",fontWeight:500,bgcolor:oe=>E(oe.palette.primary.main,.12),color:"primary.main",borderRadius:2},children:[M.rowCount," ",M.rowCount===1?"row":"rows"]}),Object.keys(M.aggregates).length>0&&e.jsx(r.Typography,{variant:"caption",sx:{ml:1,color:"text.secondary"},children:Object.entries(M.aggregates).map(([oe,He])=>gi(He)).filter(Boolean).join(" • ")})]})})},M.groupKey)},[Le,ut,b,F]),Lt=p.useCallback((M,Z)=>{const K=Ve.has(M==null?void 0:M.__urm_row_id__),de=er===Z;return e.jsxs(r.TableRow,{"data-row-index":Z,onMouseEnter:()=>ot(Z),onMouseLeave:()=>ot(null),onClick:oe=>{!he||oe.target.closest("[data-row-action]")||ar(Z,oe)},onContextMenu:oe=>{oe.preventDefault(),oe.stopPropagation(),Ze({mouseX:oe.clientX,mouseY:oe.clientY,row:M,rowIndex:Z})},sx:{height:34,cursor:"pointer",bgcolor:K?oe=>E(oe.palette.warning.main,.12):"background.paper",transition:"background-color 0.12s ease","&:hover":{bgcolor:K?oe=>E(oe.palette.warning.main,.2):"action.hover"},borderBottom:"1px solid",borderColor:"divider"},children:[Le.map((oe,He)=>e.jsx(r.TableCell,{sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",py:"6px",px:He===Le.length-1?`${(Pe?76:40)+16}px`:2,fontSize:"0.8125rem",fontWeight:400,color:"text.primary",borderBottom:"1px solid",borderColor:"divider",minWidth:h[oe.name]?`${h[oe.name]}px`:`${_d}px`},children:Vd(oe,M[oe.name],Ld(oe,Le),Xe)},oe.name)),e.jsx(r.TableCell,{"data-row-action":"true",onClick:oe=>oe.stopPropagation(),sx:{position:"sticky",right:0,width:Pe?76:40,minWidth:Pe?76:40,maxWidth:Pe?76:40,p:0,border:"none",borderBottom:"1px solid",borderColor:"divider",opacity:de?1:0,transition:"opacity 0.12s ease",bgcolor:"background.paper",zIndex:10,verticalAlign:"middle"},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",height:"100%",px:1,gap:.25},children:[Pe&&e.jsx(r.IconButton,{size:"small",onClick:oe=>{oe.stopPropagation(),oe.preventDefault(),Pe(M)},title:at.has(M)?"Remove from favorites":"Add to favorites",sx:{color:at.has(M)?"warning.main":"text.secondary","&:hover":{bgcolor:oe=>E(oe.palette.warning.main,.08),color:"warning.main"}},children:at.has(M)?e.jsx(k.Star,{sx:{fontSize:18}}):e.jsx(k.StarBorder,{sx:{fontSize:18}})}),e.jsx(r.IconButton,{size:"small",onClick:oe=>{oe.stopPropagation(),oe.preventDefault(),Ze({anchorEl:oe.currentTarget,row:M,rowIndex:Z})},sx:{color:"text.secondary","&:hover":{bgcolor:oe=>E(oe.palette.text.primary,.08),color:"text.primary"}},children:e.jsx(k.MoreVert,{sx:{fontSize:18}})})]})})]},Z)},[ce,_r,er,ar,Le,h,Pt,rt,Je,It,he,Pe,at,Ne,_e,Ze]);return e.jsxs(wt.DndProvider,{backend:Xo.HTML5Backend,children:[e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:[ut&&tt&&We&&e.jsx(yd,{selectedCount:Ve.size,selectedRowIds:ce,resolvedFavoritesSet:at,viewMode:$e,onExportSelected:tt,onClearSelection:We,onBulkSetFavorites:Zt}),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:[Ee&&e.jsx(Ed,{}),ie&&ae&&P&&ne&&e.jsx(r.Tooltip,{open:or,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:nr},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(xd,{value:ee||"",onChange:ie,searchHistory:le,onAddToHistory:ae,onToggleFavourite:P,onDeleteHistory:ne,disabled:Ee})})}),e.jsx(r.Tooltip,{title:"JSON format guide",children:e.jsx(r.IconButton,{size:"small",onClick:()=>rr(!0),sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:M=>E(M.palette.text.primary,.06),color:"text.primary"}},children:e.jsx(k.InfoOutlined,{sx:{fontSize:20}})})}),Qt&&e.jsx(r.Tooltip,{title:Ke?"Show all data":"Show favorites only",children:e.jsxs(r.IconButton,{onClick:Qt,size:"small",disabled:Ee,sx:{position:"relative",color:Ke?"warning.main":"text.secondary",bgcolor:Ke?M=>E(M.palette.warning.main,.12):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:Ke?M=>E(M.palette.warning.main,.2):M=>E(M.palette.text.primary,.06),color:Ke?"warning.main":"text.primary"},"&.Mui-disabled":{color:"action.disabled"}},children:[Ke?e.jsx(k.Star,{sx:{fontSize:20}}):e.jsx(k.StarBorder,{sx:{fontSize:20}}),Ke&&Xt.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:"common.white",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:Xt.length})]})}),yt&&zt&&e.jsx(r.Tooltip,{title:"Developer configuration",children:e.jsx(r.IconButton,{size:"small",onClick:zt,sx:{color:"text.secondary",borderRadius:1,border:"1px dashed",borderColor:M=>E(M.palette.text.secondary,.3),"&:hover":{bgcolor:M=>E(M.palette.warning.main,.08),borderColor:"warning.main",color:"warning.dark"}},children:e.jsx(k.DisplaySettings,{sx:{fontSize:20}})})}),e.jsx(r.Box,{sx:{flexGrow:1}}),j&&S&&I&&a&&s.length>0&&e.jsx(md,{views:s||[],activeViewId:c||"",isDirty:d,onSelectView:j,onCreateView:S,onManageViews:I,onToggleDefault:B,onToggleFavorite:$,onRestoreView:Y,onPermanentDelete:Q,isAdmin:te,isReadOnly:Ee}),!Ee&&w&&e.jsx(r.Tooltip,{title:"Sort",children:e.jsxs(r.IconButton,{onClick:w,size:"small",sx:{position:"relative",color:n.length>0?"primary.main":"text.secondary",bgcolor:n.length>0?"primary.lighter":"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:n.length>0?M=>E(M.palette.primary.main,.2):M=>E(M.palette.text.primary,.06),color:n.length>0?"primary.main":"text.primary"}},children:[e.jsx(k.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:"common.white",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:n.length})]})}),!Ee&&y&&e.jsx(r.Tooltip,{title:"Filter",children:e.jsxs(r.IconButton,{onClick:y,size:"small",sx:{position:"relative",color:i.length>0?"primary.main":"text.secondary",bgcolor:i.length>0?"primary.lighter":"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:i.length>0?M=>E(M.palette.primary.main,.2):M=>E(M.palette.text.primary,.06),color:i.length>0?"primary.main":"text.primary"}},children:[e.jsx(k.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:"common.white",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:i.length})]})}),!Ee&&N&&e.jsx(r.Tooltip,{title:"Columns",children:e.jsxs(r.IconButton,{onClick:N,size:"small",sx:{position:"relative",color:ct>0||Fe?"primary.main":"text.secondary",bgcolor:ct>0||Fe?"primary.lighter":"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:ct>0||Fe?M=>E(M.palette.primary.main,.2):M=>E(M.palette.text.primary,.06),color:ct>0||Fe?"primary.main":"text.primary"}},children:[e.jsx(k.ViewColumn,{sx:{fontSize:20}}),ct>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:"common.white",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:ct})]})}),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:()=>tr("list"),sx:{borderRadius:1,color:$e==="list"?"primary.main":"text.secondary",bgcolor:$e==="list"?"primary.lighter":"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:$e==="list"?M=>E(M.palette.primary.main,.2):M=>E(M.palette.text.primary,.06),color:$e==="list"?"primary.main":"text.primary"}},children:e.jsx(k.TableRows,{sx:{fontSize:20}})})}),e.jsx(r.Tooltip,{title:"Grid view",children:e.jsx(r.IconButton,{size:"small",onClick:()=>tr("grid"),sx:{borderRadius:1,color:$e==="grid"?"primary.main":"text.secondary",bgcolor:$e==="grid"?"primary.lighter":"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:$e==="grid"?M=>E(M.palette.primary.main,.2):M=>E(M.palette.text.primary,.06),color:$e==="grid"?"primary.main":"text.primary"}},children:e.jsx(k.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:M=>St(M.currentTarget),size:"small",sx:{color:"text.secondary",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:M=>E(M.palette.text.primary,.06),color:"text.primary"}},children:e.jsx(k.Settings,{sx:{fontSize:20}})})})]}),e.jsxs(r.Popover,{open:!!kr,anchorEl:kr,onClose:()=>St(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},PaperProps:{sx:{mt:.5,minWidth:200,py:.5,borderRadius:1.5,boxShadow:3}},children:[x&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{x(),St(null)},disabled:l,sx:{py:1,px:2,gap:1.5},children:[e.jsx(k.Download,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Export"})]}),!Ee&&re&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{re(),St(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(k.Layers,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Grouping"})]}),G&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{G(),St(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(k.History,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Audit History"})]}),se&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{se(),St(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(k.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:[$e==="grid"&&e.jsx(r.Box,{sx:{flex:1,overflowY:"auto",overflowX:"hidden",bgcolor:"action.hover"},children:e.jsx(Td,{data:Me,visibleColumns:Le,grouping:b,selectedRowIds:ce,resolvedFavoritesSet:at,isReadOnly:Ee,isGrouped:!!Nt,sortStack:n,onSort:f,onToggleRowSelection:he||(()=>{}),onToggleRowFavorite:Pe,onToggleGroupCollapse:F,onViewRow:M=>{Ne(M),_e(!0)},onEditRow:(M,Z)=>{X(M),ge(Z),Rt(!0)},onDuplicateRow:(M,Z)=>Je==null?void 0:Je(M,Z),onDeleteRow:(M,Z)=>{$t(Z);const K=Object.values(Z).find(de=>de!=null&&de!=="");Et(K?String(K):""),_t(!0)}})}),$e==="list"&&e.jsx(r.Box,{sx:{flex:1,overflowY:"auto",overflowX:"auto",position:"relative",bgcolor:"background.paper","&::-webkit-scrollbar":{width:8,height:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:M=>M.palette.mode==="dark"?"rgba(255,255,255,0.2)":"rgba(0,0,0,0.2)",borderRadius:4,"&:hover":{bgcolor:M=>M.palette.mode==="dark"?"rgba(255,255,255,0.3)":"rgba(0,0,0,0.3)"}}},children:e.jsxs(r.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",width:"100%",minWidth:"100%"},children:[e.jsx(r.TableHead,{children:e.jsxs(r.TableRow,{sx:{height:34,bgcolor:"action.hover",borderBottom:"1px solid",borderColor:"divider"},children:[Le.map((M,Z)=>e.jsx(gd,{column:M,index:Z,sortRule:n.find(K=>K.column===M.name),hasFilters:i.some(K=>K.column===M.name),isInSortStack:n.some(K=>K.column===M.name),isReadOnly:Ee,hasModifications:Mr,width:h[M.name],onColumnClick:zr,onMoveColumn:Er,onResizeStart:sr,onSortAscending:g||Br,onSortDescending:T||Dr,onRemoveSort:Or,onOpenFilterForColumn:v||(()=>{}),onClearFiltersForColumn:ue||(()=>{}),onGroupByColumn:O,onHideColumn:Ar,onManageColumns:N||(()=>{}),onManageViews:I,onResetLayout:pe},M.name)),e.jsx(r.TableCell,{sx:{position:"sticky",top:0,right:0,width:Pe?76:40,minWidth:Pe?76:40,p:0,border:"none",borderBottom:"1px solid",borderColor:"divider",bgcolor:"action.hover",zIndex:25}})]})}),e.jsx(r.TableBody,{children:Me.length===0?e.jsx(r.TableRow,{children:e.jsx(r.TableCell,{colSpan:Le.length+(ut?1:0),align:"center",sx:{py:4},children:e.jsx(r.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})})}):Nt?Me.map((M,Z)=>M.isGroupHeader?lr(M):Lt(M,Z)):Me.map((M,Z)=>Lt(M,Z))})]})}),it&&Re&&e.jsx(zd,{currentPage:Kt,pageSize:hr,totalRows:At,totalFields:t.length,onPageChange:it,onPageSizeChange:Re}),!(it&&Re)&&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 ",Me.length," ",Me.length===1?"row":"rows"]})})]})]}),e.jsxs(r.Popover,{open:!!je,onClose:()=>Ze(null),anchorEl:(je==null?void 0:je.anchorEl)||null,anchorReference:je!=null&&je.anchorEl?"anchorEl":"anchorPosition",anchorPosition:je&&!je.anchorEl?{top:je.mouseY,left:je.mouseX}:void 0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:je!=null&&je.anchorEl?{vertical:"top",horizontal:"right"}:{vertical:"top",horizontal:"left"},PaperProps:{sx:{minWidth:176,py:.5,borderRadius:1.5,boxShadow:3}},children:[e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{je&&(Ne(je.row),_e(!0)),Ze(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(k.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"View"})]}),e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{je&&(X(je.row),ge(je.rowIndex),Rt(!0)),Ze(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(k.Edit,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Edit"})]}),e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{je&&(Je==null||Je(je.rowIndex,je.row)),Ze(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(k.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(je){$t(je.row);const M=Object.values(je.row).find(Z=>Z!=null&&Z!=="");Et(M?String(M):""),_t(!0)}Ze(null)},sx:{py:1,px:2,gap:1.5,color:"error.main"},children:[e.jsx(k.Delete,{sx:{fontSize:18,color:"error.main"}}),e.jsx(r.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]}),e.jsx(Od,{open:Se,onClose:()=>{_e(!1),Ne(null)},row:L,schema:t,reportName:st}),e.jsx(Md,{open:wr,onClose:()=>{Rt(!1),X(null),ge(null)},onSave:M=>{vt!==null&&(rt==null||rt(vt,M))},row:De,schema:t,reportName:st}),e.jsx(Ad,{open:Cr,onClose:()=>{_t(!1),$t(null)},onConfirm:()=>{bt!==null&&(It==null||It(bt))},rowPreview:Wt}),e.jsx(Fi,{isOpen:Tr,onClose:()=>rr(!1)})]})}function qt({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=>E(s.palette.primary.main,.08)}},children:e.jsx(k.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=>E(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,c)=>e.jsx(r.Box,{component:"li",sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.5},children:s},c))}),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=>E(s.palette.warning.main,.08),border:"1px solid",borderColor:s=>E(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 Jt={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 Ud({schema:t,filters:o,onAddFilter:n,onRemoveFilter:i,onUpdateFilter:s,onClearAll:c,onClose:d,focusColumn:l}){const[u,m]=p.useState(""),[h,b]=p.useState(""),[f,g]=p.useState(""),[T,y]=p.useState([]),w=Gt();p.useEffect(()=>{y([...o])},[o]),p.useEffect(()=>{l&&m(l)},[l]);const v=p.useCallback(()=>{m(""),b(""),g("")},[]),j=p.useMemo(()=>t.filter(x=>x.type!=="mixed"&&x.type!=="null"&&x.type!=="array"&&x.type!=="object"),[t]),S=t.find(x=>x.name===u),I=p.useMemo(()=>{const x=S?wn(S.type):[],N=w.filter.allowedOperators;return N.length>0?x.filter(W=>N.includes(W.value)):x},[S]),a=p.useCallback(()=>!(!u||!h||to(h)&&!f.trim()||T.length>=w.filter.maxConditions),[u,h,f,T,w]),A=p.useCallback(()=>{if(!a())return;const x={column:u,operator:h};if(to(h)){const W=S==null?void 0:S.type;x.value=W==="number"?Number(f):f}if(T.some(W=>W.column===x.column&&W.operator===x.operator&&W.value===x.value)){v();return}y([...T,x]),v()},[a,u,h,S,f,T,v]),B=p.useCallback(x=>{y(T.filter((N,W)=>W!==x))},[T]),$=p.useMemo(()=>T.length!==o.length?!0:JSON.stringify(T)!==JSON.stringify(o),[T,o]),Y=p.useCallback(()=>{c(),T.forEach(x=>n(x)),d()},[T,n,c,d]),Q=p.useCallback(()=>{y([...o]),v(),d()},[o,v,d]),te=p.useCallback(x=>{var J;const N=t.find(ue=>ue.name===x.column);if(!N)return"";const H=((J=wn(N.type).find(ue=>ue.value===x.operator))==null?void 0:J.label)||x.operator;return to(x.operator)?`${x.column} ${H.toLowerCase()} "${x.value}"`:`${x.column} ${H.toLowerCase()}`},[t]);return e.jsx(r.Box,{onClick:Q,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(r.Paper,{onClick:x=>x.stopPropagation(),elevation:0,sx:{position:"relative",width:520,maxWidth:"calc(100vw - 120px)",maxHeight:"min(520px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"background.paper",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(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(qt,{content:Jt.filter,isDev:process.env.NODE_ENV==="development"})]}),e.jsx(r.IconButton,{onClick:Q,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"grey.100",color:"text.primary"}},children:e.jsx(k.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:"grey.300",borderRadius:4,"&:hover":{bgcolor:"grey.400"}}},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,children:[e.jsx(r.InputLabel,{sx:{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},children:"Column"}),e.jsx(r.Select,{value:u,onChange:x=>{m(x.target.value),b(""),g("")},label:"Column",sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"grey.300",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"}},children:j.map(x=>e.jsxs(r.MenuItem,{value:x.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:N=>E(N.palette.primary.main,.2)}}},children:[Ge(x.name)," (",x.type,")"]},x.name))})]}),u&&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:x=>{b(x.target.value),g("")},label:"Operator",sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"grey.300",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"}},children:I.map(x=>e.jsx(r.MenuItem,{value:x.value,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:N=>E(N.palette.primary.main,.2)}}},children:x.label},x.value))})]}),h&&to(h)&&e.jsx(r.TextField,{size:"small",fullWidth:!0,type:(S==null?void 0:S.type)==="number"?"number":"text",value:f,onChange:x=>g(x.target.value),label:"Value",placeholder:"Enter value...",sx:{"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"grey.300",transition:"border-color 0.2s ease"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputBase-input":{py:1,color:"text.primary"}}})]}),e.jsx(r.Button,{onClick:A,disabled:!a(),sx:{mt:1.5,textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"primary.main",p:0,justifyContent:"flex-start",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"primary.dark",textDecoration:"underline"},"&.Mui-disabled":{color:"grey.400"}},children:"+ Add another filter"})]}),T.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 (",T.length,")"]}),e.jsx(r.Button,{onClick:()=>y([]),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"error.main",p:0,minWidth:"auto",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"#b3190e",textDecoration:"underline"}},children:"Clear all"})]}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:T.map((x,N)=>e.jsx(r.Chip,{label:te(x),onDelete:()=>B(N),sx:{bgcolor:"primary.lighter",color:"primary.main",fontSize:"0.875rem",fontWeight:400,height:32,borderRadius:"16px",border:W=>`1px solid ${E(W.palette.primary.main,.3)}`,transition:"all 0.2s ease","&:hover":{bgcolor:W=>E(W.palette.primary.main,.2),borderColor:"#aecbfa"},"& .MuiChip-label":{px:1.5,color:"primary.main"},"& .MuiChip-deleteIcon":{color:"primary.main",fontSize:18,transition:"all 0.2s ease","&:hover":{color:"primary.dark"}}}},N))})]})]}),e.jsxs(r.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"grey.50"},children:[e.jsx(r.Button,{onClick:Q,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:Y,disabled:!$,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"grey.300",color:"grey.500"}},children:"Apply filter"})]})]})})}const ii="SORT_RULE";function Yd({rule:t,index:o,onToggleDirection:n,onRemove:i,onMove:s}){const c=p.useRef(null),[{handlerId:d},l]=wt.useDrop({accept:ii,collect(h){return{handlerId:h.getHandlerId()}},hover(h,b){var j;if(!c.current)return;const f=h.index,g=o;if(f===g)return;const T=(j=c.current)==null?void 0:j.getBoundingClientRect(),y=(T.bottom-T.top)/2,w=b.getClientOffset(),v=((w==null?void 0:w.y)??0)-T.top;f<g&&v<y||f>g&&v>y||(s(f,g),h.index=g)}}),[{isDragging:u},m]=wt.useDrag({type:ii,item:()=>({index:o}),collect:h=>({isDragging:h.isDragging()})});return m(l(c)),e.jsxs(r.Box,{ref:c,"data-handler-id":d,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:"grey.50",borderColor:"grey.300",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.1), 0 1px 3px 1px rgba(60, 64, 67, 0.05)",transform:"translateY(-1px)"}},children:[e.jsx(r.Chip,{label:t.priority,size:"small",sx:{width:26,height:26,fontSize:"0.75rem",fontWeight:600,bgcolor:"primary.main",color:"background.paper",boxShadow:"0 1px 2px 0 rgba(25, 103, 210, 0.3)","& .MuiChip-label":{px:0}}}),e.jsxs(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:h=>n(o,h.target.value),sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"grey.300",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"& .MuiSelect-select":{py:.875,color:"text.primary",fontWeight:400}},children:[e.jsx(r.MenuItem,{value:"asc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:h=>E(h.palette.primary.main,.2)}}},children:"Ascending"}),e.jsx(r.MenuItem,{value:"desc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:h=>E(h.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:"rgba(217, 48, 37, 0.08)",transform:"scale(1.1)"}},children:e.jsx(k.Close,{sx:{fontSize:18}})})]})}function Gd({schema:t,sortStack:o,onUpdateSortStack:n,onClose:i}){const[s,c]=p.useState(""),[d,l]=p.useState([]);p.useEffect(()=>{l([...o])},[o]);const u=Gt(),m=p.useCallback(()=>!(d.length>=u.sort.maxLevels||!s||d.some(j=>j.column===s)),[d,s]),h=p.useCallback(()=>{if(!m())return;const j=d.length+1,S={column:s,direction:"asc",priority:j};l([...d,S]),c("")},[m,s,d]),b=p.useCallback(j=>{const I=d.filter((a,A)=>A!==j).map((a,A)=>({...a,priority:A+1}));l(I)},[d]),f=p.useCallback((j,S)=>{const I=[...d];I[j]={...I[j],direction:S},l(I)},[d]),g=p.useCallback((j,S)=>{const I=[...d],[a]=I.splice(j,1);I.splice(S,0,a);const A=I.map((B,$)=>({...B,priority:$+1}));l(A)},[d]),T=p.useCallback(()=>{l([])},[]),y=p.useCallback(()=>{n(d),i()},[d,n,i]),w=p.useCallback(()=>{l([...o]),c(""),i()},[o,i]),v=t.filter(j=>!d.some(S=>S.column===j.name));return e.jsx(wt.DndProvider,{backend:Xo.HTML5Backend,children:e.jsx(r.Box,{onClick:w,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(r.Paper,{onClick:j=>j.stopPropagation(),elevation:0,sx:{position:"relative",width:480,maxWidth:"calc(100vw - 120px)",maxHeight:"min(440px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"background.paper",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(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(qt,{content:Jt.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:"grey.100",color:"text.primary"}},children:e.jsx(k.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:"grey.300",borderRadius:4,"&:hover":{bgcolor:"grey.400"}}},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:d.length>=u.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:j=>c(j.target.value),label:"Select column...",sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"grey.300",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-disabled":{bgcolor:"grey.50"}},children:v.map(j=>e.jsx(r.MenuItem,{value:j.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:S=>E(S.palette.primary.main,.2)}}},children:Ge(j.name)},j.name))})]}),e.jsx(r.Button,{onClick:h,disabled:!m(),sx:{mt:1.5,textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"primary.main",p:0,justifyContent:"flex-start",minHeight:"auto",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"primary.dark",textDecoration:"underline"},"&.Mui-disabled":{color:"grey.400"}},children:"+ Add sort column"}),d.length>=u.sort.maxLevels&&e.jsxs(r.Typography,{variant:"caption",sx:{mt:.75,display:"block",color:"warning.dark",fontSize:"0.75rem",fontWeight:500},children:["Maximum ",u.sort.maxLevels," sort levels allowed"]})]}),d.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 (",d.length,"/",u.sort.maxLevels,")"]}),e.jsx(r.Button,{onClick:T,sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"error.main",p:0,minWidth:"auto",minHeight:"auto",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"#b3190e",textDecoration:"underline"}},children:"Clear all"})]}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:d.map((j,S)=>e.jsx(Yd,{rule:j,index:S,onToggleDirection:f,onRemove:b,onMove:g},`${j.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:"grey.50"},children:[e.jsx(r.Button,{onClick:w,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:y,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Apply sort"})]})]})})})}function qd({views:t,activeViewId:o,onSelectView:n,onCreateView:i,onEditView:s,onDeleteView:c,onRestoreView:d,onPermanentDelete:l,onPromoteToGlobal:u,isAdmin:m=!1,onClose:h}){var S,I;const f=Tt().palette,g=t.filter(a=>!a.isDeleted),T=t.filter(a=>a.isDeleted),y=g.filter(a=>a.scope==="global"),w=g.filter(a=>a.scope!=="global"),v=a=>{var Q,te,x,N,W;const A=a.scope==="global",B=a.id===o,$=m||!A,Y=m&&!A;return e.jsx(r.Paper,{variant:"outlined",sx:{p:0,overflow:"hidden",borderRadius:"8px",borderColor:B?"primary.main":"divider",bgcolor:B?E(f.primary.main,.03):"background.paper",transition:"border-color 0.15s","&:hover":{borderColor:B?"primary.main":E(f.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(a.id),h()},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:a.name}),a.description&&e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a.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(k.Language,{sx:{fontSize:"11px !important"}}),sx:{height:20,fontSize:"0.625rem",fontWeight:700,letterSpacing:"0.04em",bgcolor:E(((Q=f.info)==null?void 0:Q.main)??f.primary.main,.1),color:((te=f.info)==null?void 0:te.main)??f.primary.main,border:`1px solid ${E(((x=f.info)==null?void 0:x.main)??f.primary.main,.25)}`,"& .MuiChip-label":{px:.625},"& .MuiChip-icon":{ml:.5}}}),a.isDefault&&e.jsx(r.Chip,{label:"Default",size:"small",sx:{height:20,fontSize:"0.625rem",fontWeight:600,bgcolor:E(f.text.secondary,.08),color:"text.secondary","& .MuiChip-label":{px:.75}}})]})]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.25,flexShrink:0},children:[Y&&u&&e.jsx(r.Tooltip,{title:"Promote to Global View",arrow:!0,placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:H=>{H.stopPropagation(),u(a.id)},sx:{p:.625,color:"text.secondary",borderRadius:"6px","&:hover":{color:((N=f.info)==null?void 0:N.main)??f.primary.main,bgcolor:E(((W=f.info)==null?void 0:W.main)??f.primary.main,.08)}},children:e.jsx(k.Language,{sx:{fontSize:16}})})}),$&&e.jsx(r.Tooltip,{title:A&&!m?"Global Views are read-only":"Edit view",arrow:!0,placement:"top",children:e.jsx("span",{children:e.jsx(r.IconButton,{size:"small",disabled:A&&!m,onClick:H=>{H.stopPropagation(),s(a.id)},sx:{p:.625,borderRadius:"6px","&:hover":{color:"primary.main",bgcolor:E(f.primary.main,.08)},"&.Mui-disabled":{opacity:.35}},children:e.jsx(k.Edit,{sx:{fontSize:15}})})})}),e.jsx(r.Tooltip,{title:A&&!m?"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&&!m,onClick:H=>{H.stopPropagation(),c(a.id)},sx:{p:.625,borderRadius:"6px","&:hover":{color:"error.main",bgcolor:E(f.error.main,.08)},"&.Mui-disabled":{opacity:.35}},children:e.jsx(k.Delete,{sx:{fontSize:15}})})})})]})]})},a.id)},j=a=>{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:E(f.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:a.name}),e.jsxs(r.Box,{sx:{display:"flex",gap:.25,flexShrink:0,ml:1},children:[d&&e.jsx(r.Tooltip,{title:"Restore view",arrow:!0,children:e.jsx(r.IconButton,{size:"small",onClick:B=>{B.stopPropagation(),d(a.id)},sx:{p:.625,borderRadius:"6px","&:hover":{color:"success.main",bgcolor:E(((A=f.success)==null?void 0:A.main)??"#2e7d32",.08)}},children:e.jsx(k.Undo,{sx:{fontSize:15}})})}),l&&e.jsx(r.Tooltip,{title:"Delete permanently",arrow:!0,children:e.jsx(r.IconButton,{size:"small",onClick:B=>{B.stopPropagation(),l(a.id)},sx:{p:.625,borderRadius:"6px","&:hover":{color:"error.main",bgcolor:E(f.error.main,.08)}},children:e.jsx(k.Delete,{sx:{fontSize:15}})})})]})]},a.id)};return e.jsxs(r.Dialog,{open:!0,onClose:h,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{mt:8,borderRadius:"14px",maxHeight:"min(640px, calc(100vh - 80px))",boxShadow:`0 8px 32px ${E(((S=f.common)==null?void 0:S.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"}),m&&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:h,size:"small",sx:{color:"text.secondary"},children:e.jsx(k.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",disableElevation:!0,startIcon:e.jsx(k.Add,{sx:{fontSize:16}}),size:"small",sx:{textTransform:"none",borderRadius:"7px",fontWeight:500},children:"Create New View"})}),y.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(k.Language,{sx:{fontSize:14,color:((I=f.info)==null?void 0:I.main)??f.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:y.map(v)})]}),w.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:w.map(v)})]}),T.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:T.map(j)})]}),g.length===0&&T.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:h,variant:"contained",disableElevation:!0,sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,borderRadius:"7px",px:3},children:"Close"})})]})}const so=50;function si({currentSnapshot:t,onSave:o,onClose:n,isEditMode:i=!1,initialName:s="",initialDescription:c="",initialIsDefault:d=!1,atViewLimit:l=!1,maxViews:u=10}){const[m,h]=p.useState(s),[b,f]=p.useState(!1),[g,T]=p.useState(c),[y,w]=p.useState(d),v=()=>{if(!m.trim()){f(!0);return}if(m.trim().length>so){f(!0);return}o(m.trim(),g.trim(),y),n()},j=I=>{I.key==="Enter"&&!I.shiftKey?v():I.key==="Escape"&&n()},S=()=>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:"12px",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:[S(),e.jsx(r.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:e.jsx(k.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:m,onChange:I=>{I.target.value.length<=so&&h(I.target.value),b&&I.target.value.trim()&&f(!1)},onKeyDown:j,placeholder:"e.g., Active Users",autoFocus:!0,fullWidth:!0,size:"small",disabled:l&&!i,inputProps:{maxLength:so},error:b&&!m.trim(),helperText:b&&!m.trim()?"View name is required":`${m.length} / ${so}`}),e.jsx(r.TextField,{label:"Description (optional)",value:g,onChange:I=>T(I.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: ",ra(t.sortStack)]}),e.jsx("li",{children:"Column order & visibility"})]})]}),!i&&e.jsx(r.FormControlLabel,{control:e.jsx(r.Checkbox,{checked:y,onChange:I=>w(I.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:"grey.50",gap:1.25,justifyContent:"flex-end"},children:[e.jsx(r.Button,{onClick:n,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:v,variant:"contained",disabled:l&&!i,startIcon:e.jsx(k.Save,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"background.paper",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"grey.400"}},children:i?"Save Changes":"Create Report View"})]})]})}function Jd({viewName:t,onConfirm:o,onCancel:n}){return e.jsxs(r.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",maxHeight:"min(480px, calc(100vh - 180px))",my:"auto",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[e.jsxs(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(k.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(k.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:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"action.selected",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:o,variant:"contained",color:"error",disableElevation:!0,sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Delete View"})]})]})}const Jo=80,Ko=600,ai="COLUMN";function Kd({column:t,index:o,isVisible:n,width:i,onToggleVisibility:s,onWidthChange:c,moveColumn:d}){const l=p.useRef(null),[u,m]=p.useState(i.toString());p.useEffect(()=>{m(i.toString())},[i]);const[{handlerId:h},b]=wt.useDrop({accept:ai,collect(j){return{handlerId:j.getHandlerId()}},hover(j,S){var Q;if(!l.current)return;const I=j.index,a=o;if(I===a)return;const A=(Q=l.current)==null?void 0:Q.getBoundingClientRect(),B=(A.bottom-A.top)/2,$=S.getClientOffset(),Y=(($==null?void 0:$.y)??0)-A.top;I<a&&Y<B||I>a&&Y>B||(d(I,a),j.index=a)}}),[{isDragging:f},g]=wt.useDrag({type:ai,item:()=>({index:o}),collect:j=>({isDragging:j.isDragging()})});g(b(l));const T=()=>{const j=parseInt(u);if(isNaN(j)){m(i.toString()),c(t.name,i);return}const S=Math.max(Jo,Math.min(Ko,j));m(S.toString()),c(t.name,S)},y=j=>{if(j===""||/^\d+$/.test(j)){m(j);const S=parseInt(j);if(!isNaN(S)&&S>=Jo){const I=Math.min(Ko,S);c(t.name,I)}}},w=j=>{j.key==="Enter"&&(j.preventDefault(),T(),j.target.blur())},v=j=>({string:"primary.main",number:"success.main",boolean:"#9334e6",array:"#ea8600",object:"error.main",null:"text.secondary",mixed:"text.secondary"})[j]||"text.secondary";return e.jsxs(r.TableRow,{ref:l,"data-handler-id":h,sx:{opacity:f?.4:1,bgcolor:n?"background.paper":"grey.50",transition:"all 0.2s ease","&:hover":{bgcolor:n?"grey.50":"grey.100"},cursor:"move",height:56,borderBottom:"1px solid divider"},children:[e.jsx(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(k.DragIndicator,{sx:{fontSize:20}})}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:400,fontSize:"0.875rem",color:n?"text.primary":"text.secondary"},children:Ge(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:`${v(t.type)}15`,color:v(t.type),border:`1px solid ${v(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:"text",value:u,onChange:j=>y(j.target.value),onBlur:T,onKeyDown:w,placeholder:"150",size:"small",sx:{width:80,"& .MuiOutlinedInput-root":{height:32,fontSize:"0.8125rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"grey.300"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputBase-input":{py:.5,px:1.25,color:"text.primary"}}}),e.jsx(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:"grey.100",color:n?"primary.dark":"primary.main"}},children:n?e.jsx(k.Visibility,{sx:{fontSize:20}}):e.jsx(k.VisibilityOff,{sx:{fontSize:20}})}),e.jsx(r.Chip,{label:n?"Visible":"Hidden",size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:500,bgcolor:n?"#e6f4ea":"grey.100",color:n?"success.main":"text.secondary","& .MuiChip-label":{px:1}}})]})})]})}function Xd({schema:t,columnVisibility:o,columnOrder:n,columnWidths:i={},views:s=[],activeViewId:c="",onUpdateColumnVisibility:d,onUpdateColumnOrder:l,onUpdateColumnWidth:u,onResetLayout:m,onSaveToCurrentView:h,onSaveToAllViews:b,onSelectView:f,onClose:g}){const[T,y]=p.useState(!1),[w,v]=p.useState(n),[j,S]=p.useState(i),[I,a]=p.useState("all"),[A,B]=p.useState(null);p.useEffect(()=>{v(n)},[n]),p.useEffect(()=>{S(i)},[i]);const $=(re,O)=>{S(F=>({...F,[re]:O}))},Y=(re,O)=>{const F=[...w],[G]=F.splice(re,1);F.splice(O,0,G),v(F),l(F)},Q=()=>{m(),y(!1)},x=w.map(re=>t.find(O=>O.name===re)).filter(re=>re!==void 0).filter(re=>{const O=o[re.name]??!0;return I==="active"?O:I==="hidden"?!O:!0}),N=Object.values(o).filter(re=>re).length,W=t.length,H=s.find(re=>re.id===c),J=s.filter(re=>!re.isDeleted),ue=J.length>1,pe=p.useMemo(()=>{if(!H)return!1;const re=H.snapshot,O=JSON.stringify(o)!==JSON.stringify(re.columnVisibility),F=JSON.stringify(n)!==JSON.stringify(re.columnOrder),G=JSON.stringify(j)!==JSON.stringify(re.columnWidths);return O||F||G},[H,o,n,j]);return e.jsx(wt.DndProvider,{backend:Xo.HTML5Backend,children:e.jsx(r.Box,{onClick:g,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(r.Paper,{onClick:re=>re.stopPropagation(),elevation:0,sx:{position:"relative",width:720,maxWidth:"calc(100vw - 120px)",maxHeight:"min(760px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"background.paper",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(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(qt,{content:Jt.columns,isDev:process.env.NODE_ENV==="development"})]}),e.jsxs(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary",mt:.5},children:[N," of ",W," columns visible • Drag to reorder"]})]}),J.length>0&&f&&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:re=>B(re.currentTarget),variant:"outlined",size:"small",endIcon:e.jsx(k.KeyboardArrowDown,{sx:{fontSize:18}}),sx:{minWidth:180,justifyContent:"space-between",textTransform:"none",fontSize:"0.875rem",fontWeight:400,color:"text.primary",borderColor:"grey.300",py:.75,px:1.5,"&:hover":{borderColor:"primary.main",bgcolor:"grey.50"}},children:e.jsx(r.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis"},children:(H==null?void 0:H.name)||"Select View"})}),e.jsx(r.Menu,{anchorEl:A,open:!!A,onClose:()=>B(null),PaperProps:{sx:{mt:.5,borderRadius:"8px",boxShadow:"0 2px 6px rgba(60, 64, 67, 0.15)"}},children:J.map(re=>e.jsx(r.MenuItem,{onClick:()=>{f(re.id),B(null)},selected:re.id===c,sx:{fontSize:"0.875rem",color:"text.primary",py:1,px:2,"&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:O=>E(O.palette.primary.main,.2)}}},children:re.name},re.id))})]}),e.jsx(r.IconButton,{onClick:g,size:"small",sx:{ml:2,p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"grey.100",color:"text.primary"}},children:e.jsx(k.Close,{sx:{fontSize:20}})})]}),e.jsxs(r.Tabs,{value:I,onChange:(re,O)=>a(O),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:"grey.300",borderRadius:4,"&:hover":{bgcolor:"grey.400"}}},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:"grey.50",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:"grey.50",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:"grey.50",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: ${Jo}px, max: ${Ko}px)`,arrow:!0,placement:"top",children:e.jsx(k.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:"grey.50",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid divider"},children:"Visibility"})]})}),e.jsx(r.TableBody,{children:x.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"})})}):x.map((re,O)=>e.jsx(Kd,{column:re,index:O,isVisible:o[re.name]??!0,width:j[re.name]||150,onToggleVisibility:d,onWidthChange:$,moveColumn:Y},re.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:"grey.50"},children:[e.jsx(r.Button,{onClick:()=>y(!0),disabled:!pe,variant:"outlined",startIcon:e.jsx(k.Undo,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",borderColor:"grey.300",px:2.5,py:.875,minHeight:36,borderRadius:"4px","&:hover":{borderColor:"primary.main",bgcolor:"background.paper",color:"primary.main"},"&.Mui-disabled":{color:"grey.400",borderColor:"divider"}},children:"Reset to default"}),e.jsxs(r.Stack,{direction:"row",spacing:1.25,children:[h&&e.jsx(r.Button,{onClick:()=>{h(j),g()},disabled:!pe,variant:"contained",startIcon:e.jsx(k.Save,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"background.paper",px:2.5,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"grey.400"}},children:"Save to current view"}),b&&ue&&e.jsx(r.Button,{onClick:()=>{b(j),g()},disabled:!pe||!ue,variant:"contained",startIcon:e.jsx(k.GridView,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"success.main",color:"background.paper",px:2.5,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"success.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"grey.400"}},children:"Save to all views"})]})]}),T&&e.jsx(r.Box,{onClick:()=>y(!1),sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1400},children:e.jsxs(r.Paper,{onClick:re=>re.stopPropagation(),elevation:0,sx:{width:400,maxWidth:"90vw",borderRadius:"12px",bgcolor:"background.paper",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"},children:[e.jsxs(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:"grey.50"},children:[e.jsx(r.Button,{onClick:()=>y(!1),variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",px:3,py:1,borderRadius:"4px","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:Q,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"error.main",color:"background.paper",px:3,py:1,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)","&:hover":{bgcolor:"#b3190e",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Reset layout"})]})]})})]})})})}function Zd({schema:t,grouping:o,onApply:n,onClose:i}){var A;const[s,c]=p.useState(o||{enabled:!1,levels:[],collapsedGroups:[]}),[d,l]=p.useState(""),[u,m]=p.useState(null),h=p.useMemo(()=>Ks(t),[t]),b=p.useMemo(()=>h.filter(B=>!s.levels.some(($,Y)=>$.column===B.name&&Y!==u)),[h,s.levels,u]),f=Gt(),g=s.levels.length<f.grouping.maxLevels&&b.length>0,T=p.useCallback(()=>{!g||!d||(c({...s,levels:[...s.levels,{column:d}],enabled:!0}),l(""))},[g,d,s]),y=p.useCallback(B=>{const $=s.levels.filter((Y,Q)=>Q!==B);if($.length===0){n(null),i();return}c({...s,levels:$,enabled:$.length>0})},[s,n,i]),w=p.useCallback(B=>{m(B),l(s.levels[B].column)},[s.levels]),v=p.useCallback(()=>{if(u===null||!d)return;const B=[...s.levels];B[u]={column:d},c({...s,levels:B}),m(null),l("")},[u,d,s]),j=p.useCallback(()=>{m(null),l("")},[]),S=p.useCallback((B,$)=>{const Y=$==="up"?B-1:B+1;if(Y<0||Y>=s.levels.length)return;const Q=[...s.levels],[te]=Q.splice(B,1);Q.splice(Y,0,te),c({...s,levels:Q})},[s]),I=p.useCallback(()=>{n(null),i()},[n,i]),a=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:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(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:"12px",bgcolor:"background.paper",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(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"}),e.jsx(qt,{content:Jt.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:"grey.100",color:"text.primary"}},children:e.jsx(k.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:"grey.300",borderRadius:4,"&:hover":{bgcolor:"grey.400"}}},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:d,onChange:B=>l(B.target.value),disabled:!g,displayEmpty:!0,sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"grey.300",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-disabled":{bgcolor:"grey.50"}},children:[e.jsx(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:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:$=>E($.palette.primary.main,.2)}}},children:[Ge(B.name)," (",B.type.toUpperCase(),")"]},B.name))]})}),e.jsx(r.Button,{onClick:T,disabled:!g||!d,variant:"outlined",startIcon:e.jsx(k.Add,{sx:{fontSize:18}}),fullWidth:!0,sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"primary.main",borderColor:"grey.300",py:1,transition:"all 0.2s ease","&:hover":{borderColor:"primary.main",bgcolor:"grey.50"},"&.Mui-disabled":{color:"grey.400",borderColor:"divider"}},children:"Add group level"}),s.levels.length>=f.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"}),h.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:"1px solid #fdd663",bgcolor:"#fef7e0","& .MuiAlert-icon":{color:"#ea8600"}},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:d,onChange:B=>l(B.target.value),sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"grey.300"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"}},children:[e.jsx(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:"primary.lighter"}},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:"primary.lighter"}},children:[Ge(B.name)," (",B.type.toUpperCase(),")"]},B.name))]})}),e.jsxs(r.Stack,{direction:"row",spacing:1.5,children:[e.jsx(r.Button,{onClick:v,disabled:!d,variant:"contained",fullWidth:!0,size:"small",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#ea8600",color:"background.paper",py:.875,boxShadow:"none","&:hover":{bgcolor:"#c96e00",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)"}},children:"Save"}),e.jsx(r.Button,{onClick:j,variant:"outlined",fullWidth:!0,size:"small",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",borderColor:"grey.300",py:.875,"&:hover":{borderColor:"grey.400",bgcolor:"grey.50"}},children:"Cancel"})]})]}),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:I,size:"small",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"error.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",color:"#b3190e",textDecoration:"underline"}},children:"Clear all"})]}),e.jsx(r.Stack,{spacing:1.5,children:s.levels.map((B,$)=>{const Y=t.find(Q=>Q.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:"grey.50",borderColor:"grey.300",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.1)"}},children:[e.jsx(r.Chip,{label:`L${$+1}`,size:"small",sx:{width:40,height:28,fontWeight:600,fontSize:"0.75rem",bgcolor:"primary.main",color:"background.paper",boxShadow:"0 1px 2px 0 rgba(25, 103, 210, 0.3)"}}),e.jsxs(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:Y==null?void 0:Y.type.toUpperCase()})]}),e.jsxs(r.Stack,{direction:"row",spacing:.5,children:[e.jsx(r.IconButton,{size:"small",onClick:()=>S($,"up"),disabled:$===0,sx:{color:"text.secondary","&:hover":{bgcolor:"grey.100"},"&.Mui-disabled":{color:"divider"}},children:e.jsx(k.KeyboardArrowUp,{sx:{fontSize:18}})}),e.jsx(r.IconButton,{size:"small",onClick:()=>S($,"down"),disabled:$===s.levels.length-1,sx:{color:"text.secondary","&:hover":{bgcolor:"grey.100"},"&.Mui-disabled":{color:"divider"}},children:e.jsx(k.KeyboardArrowDown,{sx:{fontSize:18}})}),e.jsx(r.IconButton,{size:"small",onClick:()=>w($),sx:{color:"text.secondary","&:hover":{bgcolor:"grey.100",color:"primary.main"}},children:e.jsx(k.Edit,{sx:{fontSize:18}})}),e.jsx(r.IconButton,{size:"small",onClick:()=>y($),sx:{color:"text.secondary","&:hover":{bgcolor:"rgba(217, 48, 37, 0.08)",color:"error.main"}},children:e.jsx(k.Delete,{sx:{fontSize:18}})})]})]},$)})})]})]})}),e.jsxs(r.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"grey.50"},children:[e.jsx(r.Button,{onClick:i,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:a,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Apply grouping"})]})]})})}const Qd={filters:k.FilterList,sorting:k.UnfoldMore,visibility:k.Visibility,order:k.ViewColumn,widths:k.Straighten,grouping:k.Layers};function eu({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:"12px",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[e.jsxs(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(k.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 c=Qd[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(c,{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:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"common.white",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Close"})})]})}function tu({viewName:t,isDefaultView:o,changes:n=[],onSaveToCurrentView:i,onSaveAsNewView:s,onCancel:c}){const[d,l]=p.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{width:"100%",flexShrink:0,bgcolor:"primary.lighter",borderBottom:u=>`1px solid ${E(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:c,variant:"text",size:"small",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2,py:.625,borderRadius:"18px",color:"text.secondary",bgcolor:"transparent",minHeight:32,"&:hover":{bgcolor:"rgba(60, 64, 67, 0.08)",color:"text.primary"}},children:"Discard"}),e.jsx(r.Button,{onClick:s,variant:"contained",size:"small",disableElevation:!0,sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2.5,py:.625,borderRadius:"18px",minHeight:32,boxShadow:"none","&:hover":{boxShadow:"0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px rgba(60, 64, 67, 0.15)"}},children:"Save as new view"})]})]})}),d&&e.jsx(eu,{changes:n,onClose:()=>l(!1)})]})}function ru({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(k.Warning,{sx:{fontSize:20}}),action:e.jsx(r.IconButton,{size:"small",onClick:n,sx:{color:"warning.main"},children:e.jsx(k.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(k.Save,{sx:{fontSize:14}}),size:"small",children:"Save View & Export"}),e.jsx(r.Button,{onClick:t,variant:"contained",color:"warning",startIcon:e.jsx(k.Download,{sx:{fontSize:14}}),size:"small",children:"Export Anyway"})]})]})})}const li=[{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 ou(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 nu(t,o){if(o===null)return[];const n=Date.now()-o;return t.filter(i=>new Date(i.timestamp).getTime()<n)}function iu({auditHistory:t,onClose:o,onClearAuditHistory:n}){var T,y,w,v;const s=Tt().palette,[c,d]=p.useState("1h"),[l,u]=p.useState(!1),m=[...t].sort((j,S)=>new Date(S.timestamp).getTime()-new Date(j.timestamp).getTime()),h=li.find(j=>j.key===c),b=ou(t,h.ms),f=()=>u(!0),g=()=>{n&&(n(nu(t,h.ms)),u(!1))};return e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{onClick:o,sx:{position:"fixed",inset:0,bgcolor:E(((T=s.common)==null?void 0:T.black)??"#000",.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.2s ease","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(r.Paper,{onClick:j=>j.stopPropagation(),elevation:0,sx:{width:520,maxWidth:"calc(100vw - 48px)",maxHeight:"min(700px, calc(100vh - 80px))",display:"flex",flexDirection:"column",borderRadius:"16px",bgcolor:"background.paper",overflow:"hidden",boxShadow:`0 8px 32px ${E(((y=s.common)==null?void 0:y.black)??"#000",.14)}, 0 2px 8px ${E(((w=s.common)==null?void 0:w.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(qt,{content:Jt.auditHistory,isDev:process.env.NODE_ENV==="development"})]}),e.jsxs(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.125},children:[m.length," event",m.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:c,onChange:j=>d(j.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:E(s.text.primary,.3)}},children:li.map(j=>e.jsx(r.MenuItem,{value:j.key,sx:{fontSize:"0.8125rem"},children:j.label},j.key))}),e.jsx(r.Button,{size:"small",variant:"outlined",color:"error",startIcon:e.jsx(k.DeleteSweepOutlined,{sx:{fontSize:14}}),onClick:f,sx:{textTransform:"none",fontSize:"0.75rem",fontWeight:500,borderRadius:"7px",px:1.25,height:30,whiteSpace:"nowrap",borderColor:E(s.error.main,.5),"&:hover":{bgcolor:E(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(k.Close,{sx:{fontSize:17}})})]})]}),e.jsx(r.Box,{sx:{flex:1,overflowY:"auto",px:2,py:1.5,bgcolor:E(s.text.primary,.012),"&::-webkit-scrollbar":{width:5},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:E(s.text.primary,.14),borderRadius:3}},children:m.length===0?e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8,gap:1,textAlign:"center"},children:[e.jsx(k.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:m.map(j=>{const S=ba(j.feature),{summary:I,detail:a}=fa(j);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:E(s.text.primary,.18)}},children:[e.jsx(r.Chip,{label:ya(j.feature),size:"small",sx:{height:20,fontSize:"0.5625rem",fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",bgcolor:E(S,.1),color:S,border:`1px solid ${E(S,.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:I}),a&&e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.25,lineHeight:1.4},children:a}),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(k.AccessTime,{sx:{fontSize:11,color:"text.disabled"}}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:va(j.timestamp)})]}),j.user&&e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.375},children:[e.jsx(k.Person,{sx:{fontSize:11,color:"text.disabled"}}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:j.user})]})]})]})]},j.id)})})})]})}),e.jsxs(r.Dialog,{open:l,onClose:()=>u(!1),maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:"14px",boxShadow:`0 8px 32px ${E(((v=s.common)==null?void 0:v.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:E(s.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(k.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":""]})," ",h.key==="all"?"from all time":`from the ${h.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:{textTransform:"none",fontSize:"0.8125rem",fontWeight:500,color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),e.jsxs(r.Button,{onClick:g,variant:"contained",color:"error",disableElevation:!0,startIcon:e.jsx(k.DeleteSweepOutlined,{sx:{fontSize:14}}),sx:{textTransform:"none",fontSize:"0.8125rem",fontWeight:500,borderRadius:"7px",px:2},children:["Clear ",b," Record",b!==1?"s":""]})]})]})]})}function su({onSave:t,onClose:o}){const[n,i]=p.useState(""),[s,c]=p.useState(""),[d,l]=p.useState(""),[u,m]=p.useState([]),[h,b]=p.useState(""),[f,g]=p.useState(""),T=a=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a),y=()=>{const a=d.trim();if(a){if(!T(a)){g("Please enter a valid email address");return}if(u.includes(a)){g("This email is already added");return}m([...u,a]),l(""),g("")}},w=a=>{m(u.filter(A=>A!==a))},v=a=>{a.key==="Enter"&&(a.preventDefault(),y())},j=()=>{if(!n.trim()){b("Preset name is required");return}t(n.trim(),s.trim(),u.length>0?u:void 0)},S=a=>{i(a),h&&b("")},I=a=>{l(a),f&&g("")};return e.jsx(r.Box,{onClick:o,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(r.Paper,{onClick:a=>a.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(480px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"background.paper",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(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:"grey.100",color:"text.primary"}},children:e.jsx(k.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:"grey.300",borderRadius:4,"&:hover":{bgcolor:"grey.400"}}},children:e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[e.jsx(r.Alert,{severity:"info",icon:e.jsx(k.Info,{sx:{fontSize:20}}),sx:{borderRadius:"8px",border:a=>`1px solid ${E(a.palette.primary.main,.3)}`,bgcolor:"primary.lighter","& .MuiAlert-icon":{color:"primary.main"},"& .MuiAlert-message":{fontSize:"0.8125rem",color:"text.primary",lineHeight:1.5}},children:"This preset will capture filters, sorting, grouping, column configuration, and the active view. The actual data is not saved or shared."}),e.jsx(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:a=>S(a.target.value),placeholder:"e.g., Q4 Active Users Report",error:!!h,helperText:h,autoFocus:!0,fullWidth:!0,size:"small",sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"grey.300"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-error fieldset":{borderColor:"error.main"}},"& .MuiInputBase-input":{py:1.25,color:"text.primary"},"& .MuiFormHelperText-root":{fontSize:"0.75rem",color:"error.main",mt:.75}}})]}),e.jsxs(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:a=>c(a.target.value),placeholder:"Briefly describe what this preset shows...",multiline:!0,rows:3,fullWidth:!0,size:"small",sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"grey.300"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputBase-input":{py:1.25,color:"text.primary",lineHeight:1.6}}})]}),e.jsxs(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:d,onChange:a=>I(a.target.value),onKeyPress:v,placeholder:"Enter email address",error:!!f,helperText:f,fullWidth:!0,size:"small",InputProps:{startAdornment:e.jsx(k.Email,{sx:{fontSize:18,color:"text.secondary",mr:1}})},sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"grey.300"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-error fieldset":{borderColor:"error.main"}},"& .MuiInputBase-input":{py:1.25,color:"text.primary"},"& .MuiFormHelperText-root":{fontSize:"0.75rem",color:"error.main",mt:.75}}}),e.jsx(r.Button,{onClick:y,variant:"outlined",startIcon:e.jsx(k.Add,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"primary.main",borderColor:"grey.300",px:2,py:1.25,minHeight:40,borderRadius:"4px",flexShrink:0,"&:hover":{borderColor:"primary.main",bgcolor:"grey.50"}},children:"Add"})]}),u.length>0&&e.jsx(r.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1,mt:1.5},children:u.map(a=>e.jsx(r.Chip,{label:a,onDelete:()=>w(a),deleteIcon:e.jsx(k.Delete,{sx:{fontSize:16}}),sx:{bgcolor:"primary.lighter",color:"primary.main",fontSize:"0.8125rem",height:28,"& .MuiChip-deleteIcon":{color:"primary.main","&:hover":{color:"primary.dark"}}}},a))}),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:"grey.50"},children:[e.jsx(r.Button,{onClick:o,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:j,variant:"contained",startIcon:e.jsx(k.Share,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Create & share"})]})]})})}function au({presetName:t,onClear:o}){return e.jsx(r.Chip,{icon:e.jsx(k.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(k.Close,{sx:{fontSize:14}})}),sx:{bgcolor:n=>E(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 lu({presets:t,reportId:o,onOpenPreset:n,onDeletePreset:i,onClose:s}){const[c,d]=p.useState(null),l=u=>new Date(u).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:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(r.Paper,{onClick:u=>u.stopPropagation(),elevation:0,sx:{position:"relative",width:680,maxWidth:"calc(100vw - 120px)",maxHeight:"min(720px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"common.white",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(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:"#f1f3f4",color:"text.primary"}},children:e.jsx(k.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:"#bdc1c6"}}},children:t.length===0?e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8},children:[e.jsx(k.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:"#80868b",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(u=>e.jsxs(r.Paper,{elevation:0,sx:{p:2.5,border:"1px solid divider",borderRadius:"8px",bgcolor:"common.white",transition:"all 0.2s ease","&:hover":{borderColor:"divider",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.1), 0 1px 3px 1px rgba(60, 64, 67, 0.05)"}},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:u.name}),u.description&&e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.5},children:u.description})]})}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:2},children:[e.jsx(r.Chip,{label:`Created ${l(u.createdAt)}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"#f1f3f4",color:"text.secondary","& .MuiChip-label":{px:1}}}),e.jsx(r.Chip,{label:`By ${u.createdBy}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"#f1f3f4",color:"text.secondary","& .MuiChip-label":{px:1}}})]}),e.jsx(r.Divider,{sx:{my:1.5,borderColor:"#f1f3f4"}}),e.jsx(r.Box,{sx:{display:"flex",gap:1},children:e.jsx(r.Button,{onClick:()=>i(u.id,u.name),variant:"outlined",size:"small",startIcon:e.jsx(k.Delete,{sx:{fontSize:16}}),sx:{textTransform:"none",fontSize:"0.8125rem",fontWeight:500,color:"error.main",borderColor:"divider",px:1.5,py:.75,borderRadius:"4px","&:hover":{borderColor:"error.main",bgcolor:"rgba(217, 48, 37, 0.04)"}},children:"Delete"})})]},u.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:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"common.white",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Close"})})]})})}const Ui={maxFileSizeBytes:2*1024*1024,maxFileSizeHardBytes:3*1024*1024,maxRows:1e4,maxRowsHard:5e4,maxImageColumns:5},cu=[/^https?:\/\/.*\.(jpg|jpeg|png|gif|webp|svg|avif|bmp)/i,/^data:image\//i,/^\/.*\.(jpg|jpeg|png|gif|webp|svg)/i],du=[/image/i,/photo/i,/avatar/i,/thumbnail/i,/picture/i,/logo/i,/icon/i,/banner/i];function uu(t,o){const n=[];for(const i of t){if(i.type!=="string")continue;const s=du.some(l=>l.test(i.name));let c=!1;const d=o.slice(0,10).map(l=>l[i.name]).filter(l=>typeof l=="string"&&l.length>0);d.length>0&&(c=d.filter(u=>cu.some(m=>m.test(u))).length/d.length>.6),(s||c)&&n.push(i.name)}return n}function an(t,o){if(t.length===0||o.length===0)return 0;const n=t.slice(0,Math.min(50,t.length)),s=o.map(d=>{const l=n.map(m=>String(m[d]??"")).filter(m=>m.length>0);if(l.length===0)return 5;const u=l.reduce((m,h)=>m+h.length,0);return Math.ceil(u/l.length)+1}).reduce((d,l)=>d+l,0)+1;return o.reduce((d,l)=>d+l.length+1,0)+s*t.length}function pu(t,o){const n=an(t,o);return Math.ceil(n*3.5)}function xu(t,o){const n=an(t,o);return Math.ceil(n*.7)}function mu(t,o,n){switch(t){case"csv":return an(o,n);case"excel":return xu(o,n);case"json":return pu(o,n)}}function ci(t,o){return Math.ceil(t/o)}function fu(t,o,n,i,s=Ui){const c=[],d=mu(t,o,n),l=o.length;if(l>s.maxRowsHard){const h=ci(l,s.maxRows);c.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 ${h} smaller exports of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:h,value:l,limit:s.maxRowsHard})}else if(l>s.maxRows){const h=ci(l,s.maxRows);c.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 ${h} smaller export${h>1?"s":""} of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:h,value:l,limit:s.maxRows})}if(d>s.maxFileSizeHardBytes?c.push({type:"file_size",severity:"error",message:`File size blocked: estimated ${Ur(d)} exceeds the ${Ur(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:d,limit:s.maxFileSizeHardBytes}):d>s.maxFileSizeBytes&&c.push({type:"file_size",severity:"warning",message:`Large file: estimated ${Ur(d)}`,detail:`This exceeds the recommended ${Ur(s.maxFileSizeBytes)} size. The download will still proceed but may be slow on some connections.`,value:d,limit:s.maxFileSizeBytes}),t!=="excel"){const h=uu(i.filter(b=>n.includes(b.name)),o);if(h.length>0){const b=h.length>s.maxImageColumns;c.push({type:"image_columns",severity:b?"error":"warning",message:`Image column${h.length>1?"s":""} detected: ${h.map(f=>`"${f.replace(/_/g," ")}"`).join(", ")}`,detail:b?`Exporting ${h.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:h.length,limit:s.maxImageColumns})}}const u=c.some(h=>h.severity==="error"),m=c.some(h=>h.severity==="warning");return{violations:c,hasBlockingViolation:u,hasWarning:m,estimatedBytes:d}}function Ur(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function hu({violation:t}){const n=Tt().palette,i=t.severity==="error",s=i?n.error.main:n.warning.main,c=E(i?n.error.main:n.warning.main,.06),d=i?E(n.error.main,.25):E(n.warning.main,.3),l=i?k.ErrorOutline:k.WarningAmberOutlined;return e.jsxs(r.Box,{sx:{display:"flex",gap:1.25,p:1.5,borderRadius:"8px",bgcolor:c,border:"1px solid",borderColor:d},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(k.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 gu({totalRows:t,visibleRows:o,hasGrouping:n,visibleColumnsCount:i,totalColumnsCount:s,schema:c,sampleRows:d=[],allRows:l=[],processedRows:u=[],onExport:m,onClose:h}){var N,W,H;const f=Tt().palette,g=Gt(),[T,y]=p.useState(g.export.allowedFormats[0]||"csv"),[w,v]=p.useState("visible"),[j,S]=p.useState("visible"),I=w==="visible"?o:t,a=j==="visible"?i:s,A=p.useMemo(()=>w==="visible"?u.length>0?u:new Array(o):l.length>0?l:new Array(t),[w,o,t,u,l]),B=p.useMemo(()=>j==="all"?c.map(J=>J.name):c.map(J=>J.name).slice(0,i),[j,c,i]),$=p.useMemo(()=>fu(T,A,B,c,Ui),[T,A,B,c]),Y=()=>{$.hasBlockingViolation||(m({format:T,scope:w,columnScope:j}),h())},Q={csv:"CSV",excel:"Excel (.xlsx)",json:"JSON"},te={alignItems:"flex-start",px:1.5,py:.875,borderRadius:"8px",mx:0,transition:"background-color 0.15s","&:hover":{bgcolor:"action.hover"}},x={color:"text.secondary","&.Mui-checked":{color:"primary.main"},pt:.125};return e.jsx(r.Box,{onClick:h,sx:{position:"fixed",inset:0,bgcolor:E(((N=f.common)==null?void 0:N.black)??"#000",.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.2s ease","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(r.Paper,{onClick:J=>J.stopPropagation(),elevation:0,sx:{width:480,maxWidth:"calc(100vw - 48px)",maxHeight:"min(680px, calc(100vh - 80px))",display:"flex",flexDirection:"column",borderRadius:"14px",bgcolor:"background.paper",overflow:"hidden",boxShadow:`0 8px 32px ${E(((W=f.common)==null?void 0:W.black)??"#000",.14)}, 0 2px 8px ${E(((H=f.common)==null?void 0:H.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(qt,{content:Jt.export,isDev:process.env.NODE_ENV==="development"})]}),e.jsx(r.IconButton,{onClick:h,size:"small",sx:{color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(k.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:E(f.text.primary,.15),borderRadius:3}},children:[$.violations.length>0&&e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:$.violations.map((J,ue)=>e.jsx(hu,{violation:J},ue))}),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:T,onChange:J=>y(J.target.value),children:[g.export.allowedFormats.includes("csv")&&e.jsx(r.FormControlLabel,{value:"csv",control:e.jsx(r.Radio,{size:"small",sx:x}),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:{...te,mb:.5}}),g.export.allowedFormats.includes("excel")&&e.jsx(r.FormControlLabel,{value:"excel",control:e.jsx(r.Radio,{size:"small",sx:x}),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:{...te,mb:.5}}),g.export.allowedFormats.includes("json")&&e.jsx(r.FormControlLabel,{value:"json",control:e.jsx(r.Radio,{size:"small",sx:x}),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:te})]})]}),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:w,onChange:J=>v(J.target.value),children:[e.jsx(r.FormControlLabel,{value:"visible",control:e.jsx(r.Radio,{size:"small",sx:x}),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:{...te,mb:.5}}),e.jsx(r.FormControlLabel,{value:"all",control:e.jsx(r.Radio,{size:"small",sx:x}),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:te})]})]}),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:j,onChange:J=>S(J.target.value),children:[e.jsx(r.FormControlLabel,{value:"visible",control:e.jsx(r.Radio,{size:"small",sx:x}),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:{...te,mb:.5}}),e.jsx(r.FormControlLabel,{value:"all",control:e.jsx(r.Radio,{size:"small",sx:x}),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:te})]})]}),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:Q[T]},{label:"Rows to export",value:I.toLocaleString()},{label:"Columns to export",value:String(a)},{label:"Estimated file size",value:Ur($.estimatedBytes),highlight:$.hasBlockingViolation?"error.main":$.hasWarning?"warning.main":void 0}].map(({label:J,value:ue,highlight:pe})=>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:J}),e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"0.8125rem",color:pe??"text.primary"},children:ue})]},J))})]})]}),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:E(f.text.primary,.015)},children:[$.hasBlockingViolation&&e.jsxs(r.Box,{sx:{flex:1,display:"flex",alignItems:"center",gap:.75},children:[e.jsx(k.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:h,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",px:2.5,borderRadius:"8px","&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),e.jsxs(r.Button,{onClick:Y,disabled:$.hasBlockingViolation,variant:"contained",disableElevation:!0,startIcon:e.jsx(k.Download,{sx:{fontSize:16}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2.5,borderRadius:"8px"},children:["Download ",Q[T]]})]})]})})}function yu({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(k.Warning,{sx:{fontSize:20}}),action:e.jsx(r.IconButton,{size:"small",onClick:o,sx:{color:"warning.main"},children:e.jsx(k.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 bu({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 c=(()=>{switch(t.type){case"system":return{severity:"error",icon:e.jsx(k.Cancel,{sx:{fontSize:20}})};case"processing":return{severity:"warning",icon:e.jsx(k.Warning,{sx:{fontSize:20}})};case"ui":default:return{severity:"info",icon:e.jsx(k.InfoOutlined,{sx:{fontSize:20}})}}})(),d=Aa(t);return e.jsx(r.Box,{sx:{position:"fixed",top:16,right:16,zIndex:50,maxWidth:448},children:e.jsxs(r.Alert,{severity:c.severity,icon:c.icon,action:e.jsx(r.IconButton,{size:"small",onClick:o,sx:{color:`${c.severity}.main`},children:e.jsx(k.Close,{sx:{fontSize:16}})}),sx:{borderLeft:4,borderColor:`${c.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:d}),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 vu extends p.Component{constructor(o){super(o),this.handleReset=()=>{this.setState({hasError:!1,error:null})},this.state={hasError:!1,error:null}}static getDerivedStateFromError(o){return{hasError:!0,error:o}}componentDidCatch(o,n){Ut.error("urm:error-boundary","Caught unhandled component error",o,n),this.props.onError&&this.props.onError(o,n)}render(){var o,n;return this.state.hasError?this.props.fallback?this.props.fallback:e.jsx(r.Paper,{sx:{bgcolor:i=>E(i.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(k.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:((o=this.state.error)==null?void 0:o.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:i=>E(i.palette.error.main,.12),p:1.5,borderRadius:1,overflow:"auto",maxHeight:160},children:(n=this.state.error)==null?void 0:n.stack}),e.jsx(r.Button,{onClick:this.handleReset,variant:"contained",color:"error",startIcon:e.jsx(k.Refresh,{sx:{fontSize:16}}),sx:{mt:2},children:"Try Again"})]})]})}):this.props.children}}function Nr({children:t,feature:o,onError:n}){return e.jsx(vu,{context:o,onError:(i,s)=>{n&&n(i)},fallback:e.jsxs(r.Alert,{severity:"warning",sx:{m:1},icon:e.jsx(k.Warning,{sx:{fontSize:20}}),children:[e.jsxs(r.AlertTitle,{children:[o," temporarily unavailable"]}),"Other features continue to work normally"]}),children:t})}const Su=[{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"}],ju=[{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 Lr({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 Cu({open:t,onClose:o,config:n,onApply:i}){const[s,c]=p.useState(0),[d,l]=p.useState(n),u=()=>l(n),m=()=>l(Ue),h=()=>{i(d),o()},b={sort:w=>l(v=>({...v,sort:{...v.sort,...w}})),filter:w=>l(v=>({...v,filter:{...v.filter,...w}})),columns:w=>l(v=>({...v,columns:{...v.columns,...w}})),grouping:w=>l(v=>({...v,grouping:{...v.grouping,...w}})),export:w=>l(v=>({...v,export:{...v.export,...w}}))},f=w=>{const v=d.filter.allowedOperators,j=v.includes(w)?v.filter(S=>S!==w):[...v,w];j.length!==0&&b.filter({allowedOperators:j})},g=w=>{const v=d.export.allowedFormats,j=v.includes(w)?v.filter(S=>S!==w):[...v,w];j.length!==0&&b.export({allowedFormats:j})},T=[{label:"Sort",icon:e.jsx(k.SwapVert,{sx:{fontSize:17}})},{label:"Filter",icon:e.jsx(k.FilterList,{sx:{fontSize:17}})},{label:"Columns",icon:e.jsx(k.ViewColumn,{sx:{fontSize:17}})},{label:"Grouping",icon:e.jsx(k.Layers,{sx:{fontSize:17}})},{label:"Export",icon:e.jsx(k.Download,{sx:{fontSize:17}})}],y=w=>JSON.stringify(d[w])===JSON.stringify(Ue[w]);return e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"sm",fullWidth:!0,TransitionProps:{onEnter:u},PaperProps:{sx:{borderRadius:"12px",maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:"0 8px 32px rgba(60,64,67,0.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:w=>E(w.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(k.Close,{sx:{fontSize:20}})})]}),e.jsx(r.Box,{sx:{borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:e.jsx(r.Tabs,{value:s,onChange:(w,v)=>c(v),variant:"fullWidth",sx:{minHeight:44,"& .MuiTab-root":{minHeight:44,fontSize:"0.8125rem",textTransform:"none",fontWeight:500,gap:.5}},children:T.map((w,v)=>e.jsx(r.Tab,{label:w.label,icon:w.icon,iconPosition:"start"},v))})}),e.jsxs(r.DialogContent,{sx:{overflowY:"auto",flex:1,px:3,py:0},children:[e.jsxs(Lr,{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"}),!y("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:d.sort.maxLevels,onChange:(w,v)=>b.sort({maxLevels:v}),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(Lr,{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"}),!y("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:d.filter.maxConditions,onChange:(w,v)=>b.filter({maxConditions:v}),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(w=>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:w}),e.jsx(r.FormGroup,{row:!0,sx:{gap:.5},children:Su.filter(v=>v.group===w).map(v=>e.jsx(r.FormControlLabel,{control:e.jsx(r.Checkbox,{size:"small",checked:d.filter.allowedOperators.includes(v.value),onChange:()=>f(v.value)}),label:e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem"},children:v.label}),sx:{mr:1.5}},v.value))})]},w))]})]}),e.jsxs(Lr,{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"}),!y("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:d.columns.maxVisible,onChange:(w,v)=>b.columns({maxVisible:v}),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:d.columns.minColumnWidth,onChange:(w,v)=>b.columns({minColumnWidth:v}),min:40,max:400,step:10,valueLabelDisplay:"on",valueLabelFormat:w=>`${w}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:d.columns.maxColumnWidth,onChange:(w,v)=>b.columns({maxColumnWidth:v}),min:100,max:2e3,step:50,valueLabelDisplay:"on",valueLabelFormat:w=>`${w}px`})]})]})]})]}),e.jsxs(Lr,{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"}),!y("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(w=>e.jsxs(r.Box,{onClick:()=>b.grouping({maxLevels:w}),sx:{flex:1,py:2.5,borderRadius:"10px",border:"2px solid",cursor:"pointer",textAlign:"center",transition:"all 0.15s ease",borderColor:d.grouping.maxLevels===w?"primary.main":"divider",bgcolor:d.grouping.maxLevels===w?v=>E(v.palette.primary.main,.06):"transparent","&:hover":{borderColor:"primary.light",bgcolor:v=>E(v.palette.primary.main,.04)}},children:[e.jsx(r.Typography,{variant:"h5",sx:{fontWeight:700,color:d.grouping.maxLevels===w?"primary.main":"text.secondary"},children:w}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:["Single","Double","Triple"][w-1]})]},w))}),e.jsxs(r.FormGroup,{row:!0,sx:{gap:2},children:[e.jsx(r.FormControlLabel,{control:e.jsx(r.Checkbox,{checked:d.grouping.allowNested,onChange:w=>b.grouping({allowNested:w.target.checked})}),label:e.jsx(r.Typography,{variant:"body2",children:"Allow nested groups"})}),e.jsx(r.FormControlLabel,{control:e.jsx(r.Checkbox,{checked:d.grouping.allowCollapse,onChange:w=>b.grouping({allowCollapse:w.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(Lr,{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"}),!y("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:ju.map(w=>e.jsxs(r.Box,{onClick:()=>g(w.value),sx:{display:"flex",alignItems:"center",gap:1.5,p:1.5,borderRadius:"8px",border:"1px solid",cursor:"pointer",transition:"all 0.15s ease",borderColor:d.export.allowedFormats.includes(w.value)?"primary.main":"divider",bgcolor:d.export.allowedFormats.includes(w.value)?v=>E(v.palette.primary.main,.04):"transparent","&:hover":{borderColor:"primary.light"}},children:[e.jsx(r.Checkbox,{size:"small",checked:d.export.allowedFormats.includes(w.value),onChange:()=>g(w.value),onClick:v=>v.stopPropagation()}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500},children:w.label}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:w.desc})]})]},w.value))})]})})]}),e.jsxs(r.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid",borderColor:"divider",bgcolor:w=>E(w.palette.action.hover,.4),justifyContent:"space-between",flexShrink:0},children:[e.jsx(r.Button,{startIcon:e.jsx(k.RestartAlt,{sx:{fontSize:18}}),onClick:m,size:"small",sx:{textTransform:"none",fontSize:"0.875rem",color:"text.secondary","&:hover":{color:"text.primary",bgcolor:w=>E(w.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:{textTransform:"none",fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px"},children:"Cancel"}),e.jsx(r.Button,{onClick:h,size:"small",variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2.5,borderRadius:"18px"},children:"Apply"})]})]})]})}const wu=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],ku={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 lo(t,o,n,i,s=new Date){const[c,d]=o.split(":").map(Number),l=new Date(s);if(l.setSeconds(0,0),l.setHours(c,d,0,0),t==="daily")return l<=s&&l.setDate(l.getDate()+1),l.toISOString();if(t==="weekly"){const u=n??1,m=l.getDay();let h=u-m;return h<0&&(h+=7),h===0&&l<=s&&(h=7),l.setDate(l.getDate()+h),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 Tu(t){const o=Yi(t.time);return t.frequency==="daily"?`Daily at ${o}`:t.frequency==="weekly"?`Every ${wu[t.dayOfWeek??1]} at ${o}`:t.frequency==="monthly"?`Monthly on the ${ku[t.dayOfMonth??1]??`${t.dayOfMonth}th`} at ${o}`:o}function Yi(t){const[o,n]=t.split(":").map(Number),i=o>=12?"PM":"AM";return`${o%12||12}:${String(n).padStart(2,"0")} ${i}`}function Iu(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),c=Math.floor(n%3600/60);return i>0?`in ${i}d ${s}h`:s>0?`in ${s}h ${c}m`:c>0?`in ${c}m`:"in less than a minute"}function zu(t){const o=new Date(t),n=new Date,i=o.toDateString()===n.toDateString(),s=Yi(`${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 Gi(t){return`urm_schedules_${t}`}function qi(t){try{const o=localStorage.getItem(Gi(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 Ji(t,o){try{localStorage.setItem(Gi(t),JSON.stringify(o))}catch{}}const Eu=[{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"}],Bu=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Ki={name:"",frequency:"daily",dayOfWeek:1,dayOfMonth:1,time:"09:00",format:"csv",scope:"all",email:""},Ht={"& .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 Du({initial:t=Ki,isEditing:o=!1,onSave:n,onBack:i}){const[s,c]=p.useState(t),[d,l]=p.useState(!1),[u,m]=p.useState(!1),h=(g,T)=>c(y=>({...y,[g]:T})),b=s.email.trim().length>0&&!Bu.test(s.email.trim()),f=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:g=>E(g.palette.text.primary,.06)}},children:e.jsx(k.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:g=>{h("name",g.target.value),d&&g.target.value.trim()&&l(!1)},onBlur:()=>l(!0),placeholder:"e.g. Weekly Sales Report",autoFocus:!0,inputProps:{maxLength:50},error:d&&!s.name.trim(),helperText:d&&!s.name.trim()?"Schedule name is required":`${s.name.length}/50`,sx:Ht}),e.jsxs(r.FormControl,{size:"small",fullWidth:!0,sx:Ht,children:[e.jsx(r.InputLabel,{children:"Frequency"}),e.jsxs(r.Select,{value:s.frequency,label:"Frequency",onChange:g=>h("frequency",g.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:Ht,children:[e.jsx(r.InputLabel,{children:"Day of week"}),e.jsx(r.Select,{value:s.dayOfWeek,label:"Day of week",onChange:g=>h("dayOfWeek",Number(g.target.value)),children:Eu.map(g=>e.jsx(r.MenuItem,{value:g.value,children:g.label},g.value))})]}),s.frequency==="monthly"&&e.jsx(r.TextField,{label:"Day of month (1–28)",size:"small",type:"number",fullWidth:!0,value:s.dayOfMonth,onChange:g=>h("dayOfMonth",Number(g.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:Ht}),e.jsx(r.TextField,{label:"Time",size:"small",type:"time",fullWidth:!0,value:s.time,onChange:g=>h("time",g.target.value),InputLabelProps:{shrink:!0},helperText:"24-hour format · Tab must be open for the schedule to fire",sx:Ht}),e.jsxs(r.FormControl,{size:"small",fullWidth:!0,sx:Ht,children:[e.jsx(r.InputLabel,{children:"Export format"}),e.jsxs(r.Select,{value:s.format,label:"Export format",onChange:g=>h("format",g.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:g=>h("scope",g.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:g=>h("email",g.target.value),onBlur:()=>m(!0),placeholder:"user@company.com",error:u&&b,helperText:u&&b?"Enter a valid email address":void 0,InputProps:{startAdornment:e.jsx(k.Email,{sx:{fontSize:15,color:"text.disabled",mr:1}})},sx:Ht}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"flex-start",gap:.5,mt:.5,px:.5},children:[e.jsx(k.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:{textTransform:"none",fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px","&:hover":{bgcolor:g=>E(g.palette.text.primary,.06)}},children:"Cancel"}),e.jsx(r.Button,{onClick:()=>f&&n(s),disabled:!f,size:"small",variant:"contained",disableElevation:!0,sx:{textTransform:"none",fontWeight:500,fontSize:"0.875rem",px:2.5,borderRadius:"18px"},children:o?"Save changes":"Create schedule"})]})]})}function Ou({scheduleName:t,onConfirm:o,onCancel:n}){return e.jsxs(r.Dialog,{open:!0,onClose:n,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:"14px",boxShadow:i=>{var s;return`0 8px 32px ${E(((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=>E(i.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(k.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:{textTransform:"none",fontSize:"0.8125rem",fontWeight:500,color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),e.jsx(r.Button,{onClick:o,variant:"contained",color:"error",disableElevation:!0,sx:{textTransform:"none",fontSize:"0.8125rem",fontWeight:500,borderRadius:"7px",px:2},children:"Delete"})]})]})}function Au({schedule:t,tick:o,onToggle:n,onRunNow:i,onEdit:s,onDelete:c}){const d=t.isActive;return e.jsxs(r.Box,{sx:{border:"1px solid",borderColor:d?"primary.main":"divider",borderRadius:"10px",p:1.75,bgcolor:d?l=>E(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:d?"text.primary":"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.name}),e.jsx(r.Chip,{label:d?"Active":"Paused",size:"small",sx:{height:18,fontSize:"0.6875rem",fontWeight:600,flexShrink:0,bgcolor:d?l=>E(l.palette.success.main,.1):l=>E(l.palette.text.primary,.06),color:d?"success.dark":"text.secondary"}})]}),e.jsx(r.Typography,{variant:"caption",sx:{color:"text.secondary",display:"block",mb:1},children:Tu(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=>E(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=>E(l.palette.text.primary,.06),color:"text.secondary"}}),t.email&&e.jsx(r.Chip,{icon:e.jsx(k.Email,{sx:{fontSize:11}}),label:t.email,size:"small",sx:{height:20,fontSize:"0.6875rem",maxWidth:220,bgcolor:l=>E(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:[d&&e.jsxs(r.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:500},children:["Next: ",Iu(t.nextRunAt)]}),t.lastRunAt?e.jsxs(r.Typography,{variant:"caption",color:"text.secondary",children:["Last: ",zu(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=>E(l.palette.primary.main,.08)}},children:e.jsx(k.Edit,{sx:{fontSize:15}})})}),e.jsx(r.Tooltip,{title:d?"Pause":"Resume",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:()=>n(t.id),sx:{color:d?"warning.main":"success.main","&:hover":{bgcolor:d?l=>E(l.palette.warning.main,.08):l=>E(l.palette.success.main,.08)}},children:d?e.jsx(k.Pause,{sx:{fontSize:15}}):e.jsx(k.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=>E(l.palette.primary.main,.08)}},children:e.jsx(k.Download,{sx:{fontSize:15}})})}),e.jsx(r.Tooltip,{title:"Delete",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:()=>c(t.id),sx:{color:"error.main","&:hover":{bgcolor:l=>E(l.palette.error.main,.08)}},children:e.jsx(k.Delete,{sx:{fontSize:15}})})})]})]})]})}function Mu({open:t,onClose:o,reportId:n,reportName:i,onRunNow:s}){const[c,d]=p.useState([]),[l,u]=p.useState({type:"list"}),[m,h]=p.useState(0),[b,f]=p.useState(null);p.useEffect(()=>{t&&(d(qi(n)),u({type:"list"}))},[t,n]),p.useEffect(()=>{if(!t)return;const B=setInterval(()=>h($=>$+1),3e4);return()=>clearInterval(B)},[t]);const g=p.useCallback(B=>{d(B),Ji(n,B)},[n]),T=B=>{const $=lo(B.frequency,B.time,B.dayOfWeek,B.dayOfMonth),Y={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:$,runCount:0};g([...c,Y]),u({type:"list"})},y=B=>{if(l.type!=="edit")return;const $=l.schedule,Y=lo(B.frequency,B.time,B.dayOfWeek,B.dayOfMonth);g(c.map(Q=>Q.id===$.id?{...$,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:Y}:Q)),u({type:"list"})},w=B=>{g(c.map($=>{if($.id!==B)return $;const Y=$.isActive?$.nextRunAt:lo($.frequency,$.time,$.dayOfWeek,$.dayOfMonth);return{...$,isActive:!$.isActive,nextRunAt:Y}}))},v=B=>{s(B);const $=new Date().toISOString();g(c.map(Y=>Y.id===B.id?{...Y,lastRunAt:$,runCount:Y.runCount+1}:Y))},j=B=>{const $=c.find(Y=>Y.id===B)??null;f($)},S=()=>{b&&(g(c.filter(B=>B.id!==b.id)),f(null))},I=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??""}),a=l.type!=="list",A=c.filter(B=>B.isActive).length;return e.jsxs(e.Fragment,{children:[e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"sm",fullWidth:!0,disableEscapeKeyDown:a,PaperProps:{sx:{borderRadius:"12px",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=>E(B.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(k.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(qt,{content:Jt.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=>E(B.palette.text.primary,.06)}},children:e.jsx(k.Close,{sx:{fontSize:18}})})]}),e.jsxs(r.DialogContent,{sx:{overflowY:"auto",flex:1,px:2.5,py:2},children:[a&&e.jsx(Du,{initial:l.type==="edit"?I(l.schedule):Ki,isEditing:l.type==="edit",onSave:l.type==="edit"?y:T,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:c.length===0?"No schedules yet":`${A} of ${c.length} active`}),e.jsx(r.Button,{startIcon:e.jsx(k.Add,{sx:{fontSize:15}}),size:"small",variant:"contained",disableElevation:!0,onClick:()=>u({type:"create"}),sx:{textTransform:"none",fontWeight:500,fontSize:"0.8125rem",borderRadius:"18px",px:1.75,py:.625},children:"New schedule"})]}),c.length===0?e.jsxs(r.Box,{sx:{border:"1.5px dashed",borderColor:"divider",borderRadius:"10px",py:5,px:2,textAlign:"center"},children:[e.jsx(k.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:c.map(B=>e.jsx(Au,{schedule:B,tick:m,onToggle:w,onRunNow:v,onEdit:$=>u({type:"edit",schedule:$}),onDelete:j},B.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:B=>E(B.palette.warning.main,.06),border:"1px solid",borderColor:B=>E(B.palette.warning.main,.2)},children:[e.jsx(k.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:{textTransform:"none",fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px",flexShrink:0,"&:hover":{bgcolor:B=>E(B.palette.text.primary,.06)}},children:"Close"})]})]}),b&&e.jsx(Ou,{scheduleName:b.name,onConfirm:S,onCancel:()=>f(null)})]})}const _u=6e4;function $u({reportId:t,reportName:o,uploadedData:n,processedData:i,schema:s,activeView:c,columnVisibility:d,columnOrder:l,filters:u,sortStack:m,onFired:h}){const b=p.useRef({reportId:t,reportName:o,uploadedData:n,processedData:i,schema:s,activeView:c,columnVisibility:d,columnOrder:l,filters:u,sortStack:m,onFired:h});p.useEffect(()=>{b.current={reportId:t,reportName:o,uploadedData:n,processedData:i,schema:s,activeView:c,columnVisibility:d,columnOrder:l,filters:u,sortStack:m,onFired:h}});const f=p.useCallback(g=>{var B,$;const{reportName:T,uploadedData:y,processedData:w,schema:v,activeView:j,columnVisibility:S,columnOrder:I,filters:a,sortStack:A}=b.current;try{const Y=g.scope==="all"?y:w,Q=co(Y,v,a,A,j,S,I),te=`${g.name}_scheduled`;switch(g.format){case"csv":uo(Q,te,{scope:g.scope});break;case"excel":po(Q,te,{scope:g.scope});break;case"json":xo(Q,te,{scope:g.scope});break}if(g.email){const x=encodeURIComponent(`Scheduled Report: ${g.name}`),N=encodeURIComponent(`Your scheduled report "${g.name}" has been generated.
90
90
 
91
- Report: ${z}
92
- Format: ${w.format.toUpperCase()}
91
+ Report: ${T}
92
+ Format: ${g.format.toUpperCase()}
93
93
  Generated: ${new Date().toLocaleString()}
94
94
 
95
- The file has been downloaded to your device.`);window.open(`mailto:${w.email}?subject=${x}&body=${V}`,"_blank")}(N=(H=m.current).onFired)==null||N.call(H,w)}catch(K){Vt.error("urm:scheduler",`Export failed for schedule: ${w.name}`,K)}},[]);p.useEffect(()=>{if(!t)return;const w=()=>{const{reportId:y}=m.current;if(!y)return;const j=wi(y),b=new Date;let g=!1;const S=j.map(s=>{if(!s.isActive)return s;if(new Date(s.nextRunAt)<=b){v(s);const A=Xr(s.frequency,s.time,s.dayOfWeek,s.dayOfMonth,b);return g=!0,{...s,lastRunAt:b.toISOString(),nextRunAt:A,runCount:s.runCount+1}}return s});g&&ki(y,S)};w();const z=setInterval(w,Nd);return()=>clearInterval(z)},[t,v])}function zi({reportEngine:t}){var G,de,We,le;const{activeReport:o,paginatedData:n,processedData:i,displayData:a,tableMetrics:l,tableEngine:c,activeView:d,isDirty:u,currentTableState:f,viewChanges:h,showFilterPanel:m,setShowFilterPanel:v,filterFocusColumn:w,handleAddFilter:z,handleUpdateFilter:y,handleRemoveFilter:j,handleClearAllFilters:b,handleOpenFilterForColumn:g,handleCloseFilterPanel:S,handleClearFiltersForColumn:s,showSortPanel:I,setShowSortPanel:A,handleSort:H,handleUpdateSortStack:N,handleSortAscending:K,handleSortDescending:te,showManageViews:se,setShowManageViews:x,showCreateViewModal:V,setShowCreateViewModal:$,showEditViewModal:J,setShowEditViewModal:oe,showDeleteConfirmation:ue,setShowDeleteConfirmation:pe,editingView:_,deletingView:O,handleSelectView:L,handleCreateView:re,handleUpdateCurrentView:Q,handleSaveColumnConfigToCurrentView:X,handleSaveColumnConfigToAllViews:ae,handleSaveAsNewView:Z,handleRevertChanges:W,handleToggleDefault:ee,handleToggleFavorite:ie,handleSoftDelete:ne,handleRestoreView:ke,handlePermanentDelete:U,handleEditView:Oe,handleSaveEditView:Le,handleConfirmDelete:dt,showManageColumns:$r,setShowManageColumns:Re,handleUpdateColumnVisibility:jt,handleUpdateColumnOrder:Ae,handleUpdateColumnWidth:Ge,handleResetColumnLayout:Ke,showGroupPanel:Xe,setShowGroupPanel:_e,handleGroup:wt,handleToggleGroupCollapse:Yt,searchQuery:rt,searchHistory:Qe,handleSearchChange:$e,handleAddToSearchHistory:dr,handleToggleSearchFavourite:qt,handleDeleteSearchHistory:ot,selectedRowIds:kt,handleToggleRowSelection:At,handleToggleAllRows:ut,handleRangeSelection:ur,handleClearSelection:Nr,handleUpdateSelectionAfterDelete:Mt,currentPage:pr,pageSize:Wt,paginationEngine:Ze,handlePageChange:Tt,handlePageSizeChange:je,isExporting:xr,showExportModal:zt,setShowExportModal:nt,showDirtyExportWarning:P,handleExport:et,handleExportWithConfig:ge,handleExportSelected:Pe,handleExportAnyway:Rt,handleSaveAndExport:fr,handleCancelExport:pt,showAuditHistory:hr,setShowAuditHistory:Ye,showCreatePreset:Jt,setShowCreatePreset:_t,showManagePresets:Kt,setShowManagePresets:Te,generatedPreset:F,activePreset:Me,handleOpenManagePresets:Ce,handleCreatePreset:it,handleCopyPresetLink:Ne,handleOpenPreset:mr,handleClearActivePreset:gr,handleOpenPresetById:Xt,handleCopyPresetLinkById:yr,handleDeletePresetById:br,isViewerRole:Qt,userRole:Zt,featureLimitWarning:Ve,setFeatureLimitWarning:st,reportError:Pt,setReportError:It,handleError:xt,updateReport:at,showSnack:$t,favoriteRowIndices:Nt,resolvedFavoritesSet:vr,showFavoritesOnly:Sr,handleToggleRowFavorite:Cr,handleBulkSetFavorites:jr,handleToggleFavoritesFilter:er}=t,[wr,Be]=p.useState(!1);Fd({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:d,columnVisibility:(o==null?void 0:o.columnVisibility)||((G=d==null?void 0:d.snapshot)==null?void 0:G.columnVisibility)||{},columnOrder:(o==null?void 0:o.columnOrder)||((de=d==null?void 0:d.snapshot)==null?void 0:de.columnOrder)||[],filters:(o==null?void 0:o.filters)||[],sortStack:(o==null?void 0:o.sortStack)||[],onFired:ce=>{$t(`Scheduled export "${ce.name}" completed`,"success")}});const ft=p.useCallback((ce,Se)=>{if(!(o!=null&&o.uploadedData))return;const Fe=[...o.uploadedData];Fe[ce]=Se,at(o.id,{uploadedData:Fe})},[o,at]),tr=p.useCallback(ce=>{if(!(o!=null&&o.uploadedData))return;const Se=o.uploadedData.indexOf(ce);if(Se===-1)return;const Fe=o.uploadedData.filter((Et,Co)=>Co!==Se),So=(o.favoriteRowIndices||[]).filter(Et=>Et!==Se).map(Et=>Et>Se?Et-1:Et);at(o.id,{uploadedData:Fe,favoriteRowIndices:So}),Mt(ce)},[o,at,Mt]),Fr=p.useCallback((ce,Se)=>{if(!(o!=null&&o.uploadedData))return;const Fe=[...o.uploadedData];Fe.splice(ce+1,0,{...Se}),at(o.id,{uploadedData:Fe})},[o,at]),ht=Rr(),{handleDevConfigChange:kr}=io(),[rr,D]=p.useState(!1);return p.useEffect(()=>{const ce=Se=>{Se.ctrlKey&&Se.shiftKey&&Se.key==="D"&&(Se.preventDefault(),D(!0))};return document.addEventListener("keydown",ce),()=>document.removeEventListener("keydown",ce)},[]),!o||!o.schemaLocked||!o.schema||!o.uploadedData||!o.views?null:e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,overflow:"hidden",position:"relative"},children:[!Qt&&u&&d&&e.jsx(yd,{viewName:d.name,isDefaultView:d.isDefault,changes:h,onSaveToCurrentView:d.isDefault?void 0:Q,onSaveAsNewView:Z,onCancel:W}),e.jsxs(r.Box,{id:"table-content-area",sx:{flex:1,minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column",position:"relative"},children:[Ve&&e.jsx(kd,{warning:Ve,onDismiss:()=>st(null)}),Pt&&e.jsx(Td,{error:Pt,onDismiss:()=>It(null)}),P&&e.jsx(bd,{onExportAnyway:Rt,onSaveAndExport:fr,onCancel:pt}),e.jsx(ad,{schema:o.schema,data:n,sortStack:o.sortStack,filters:o.filters,views:o.views,activeViewId:o.activeViewId,isDirty:u,isExporting:xr,columnVisibility:o.columnVisibility||(d==null?void 0:d.snapshot.columnVisibility),columnOrder:o.columnOrder||(d==null?void 0:d.snapshot.columnOrder),columnWidths:o.columnWidths||(d==null?void 0:d.snapshot.columnWidths),grouping:o.grouping,onSort:H,onSortAscending:K,onSortDescending:te,onOpenFilters:()=>v(!0),onOpenSort:()=>A(!0),onOpenFilterForColumn:g,onSelectView:L,onCreateView:()=>$(!0),onManageViews:()=>x(!0),onUpdateCurrentView:Q,onSaveAsNewView:Z,onToggleDefault:ee,onToggleFavorite:ie,onRestoreView:ke,onPermanentDelete:U,onExport:et,onOpenColumns:()=>Re(!0),onUpdateColumnWidth:Ge,onUpdateColumnOrder:Ae,onUpdateColumnVisibility:jt,onClearFiltersForColumn:s,onResetLayout:Ke,onOpenGroup:()=>_e(!0),onToggleGroupCollapse:Yt,onOpenAuditHistory:()=>Ye(!0),onOpenScheduledReports:()=>Be(!0),searchQuery:rt,searchHistory:Qe,onAddToSearchHistory:dr,onToggleSearchFavourite:qt,onDeleteSearchHistory:ot,selectedRowIds:kt,onSearchChange:$e,onToggleRowSelection:At,onToggleAllRows:ut,onRangeSelection:ur,onClearSelection:Nr,onExportSelected:Pe,currentPage:(Ze==null?void 0:Ze.currentPage)||pr,pageSize:(Ze==null?void 0:Ze.pageSize)||Wt,onPageChange:Tt,onPageSizeChange:je,totalRowsBeforePagination:(l==null?void 0:l.searchedRows)||i.length,isReadOnly:Qt,userRole:Zt,reportName:o.name,onEditRow:ft,onDeleteRow:tr,onDuplicateRow:Fr,favoriteRowIndices:Nt,resolvedFavoritesSet:vr,showFavoritesOnly:Sr,onToggleRowFavorite:Cr,onBulkSetFavorites:jr,onToggleFavoritesFilter:er,showDevPanel:ht.display.showDevPanel,onOpenDevConfig:()=>D(!0)})]}),m&&e.jsx(Er,{feature:"Filters",onError:ce=>{const Se=vt("ui","filters",ce);xt(Se)},children:e.jsx(ld,{schema:o.schema,filters:o.filters??[],onAddFilter:z,onUpdateFilter:y,onRemoveFilter:j,onClearAll:b,onClose:S,focusColumn:w})}),I&&e.jsx(Er,{feature:"Sorting",onError:ce=>{const Se=vt("ui","sorting",ce);xt(Se)},children:e.jsx(dd,{schema:o.schema,sortStack:o.sortStack??[],onUpdateSortStack:N,onClose:()=>A(!1)})}),se&&e.jsx(Er,{feature:"Views",onError:ce=>{const Se=vt("ui","views",ce);xt(Se)},children:e.jsx(ud,{views:o.views,activeViewId:o.activeViewId??"",onSelectView:L,onCreateView:()=>{x(!1),$(!0)},onEditView:Oe,onDeleteView:ne,onRestoreView:ke,onPermanentDelete:U,onClose:()=>x(!1)})}),V&&f&&e.jsx($n,{currentSnapshot:f,onSave:re,onClose:()=>$(!1)}),J&&_&&e.jsx($n,{currentSnapshot:_.snapshot,onSave:Le,onClose:()=>{oe(!1)},isEditMode:!0,initialName:_.name,initialDescription:_.description,initialIsDefault:_.isDefault}),ue&&O&&e.jsx(pd,{viewName:O.name,onConfirm:dt,onCancel:()=>{pe(!1)}}),$r&&d&&e.jsx(fd,{schema:o.schema,columnVisibility:o.columnVisibility||d.snapshot.columnVisibility,columnOrder:o.columnOrder||d.snapshot.columnOrder,columnWidths:o.columnWidths||d.snapshot.columnWidths,views:o.views,activeViewId:o.activeViewId,onUpdateColumnVisibility:jt,onUpdateColumnOrder:Ae,onUpdateColumnWidth:Ge,onResetLayout:Ke,onSelectView:ce=>{L(ce)},onSaveToCurrentView:ce=>{X(ce),Re(!1)},onSaveToAllViews:ce=>{ae(ce),Re(!1)},onClose:()=>Re(!1)}),Xe&&e.jsx(Er,{feature:"Grouping",onError:ce=>{const Se=vt("ui","grouping",ce);xt(Se)},children:e.jsx(hd,{schema:o.schema,grouping:o.grouping||null,onApply:wt,onClose:()=>_e(!1)})}),hr&&e.jsx(vd,{auditHistory:o.auditHistory||[],onClose:()=>Ye(!1)}),Jt&&e.jsx(Sd,{onSave:it,onClose:()=>_t(!1)}),Kt&&e.jsx(jd,{presets:o.presets||[],reportId:o.id,onOpenPreset:Xt,onCopyLink:yr,onDeletePreset:br,onClose:()=>Te(!1)}),Me&&e.jsx(r.Box,{sx:{mt:2},children:e.jsx(Cd,{presetName:Me.name,onClear:gr})}),zt&&e.jsx(Er,{feature:"Export",onError:ce=>{const Se=vt("ui","export",ce);xt(Se)},children:e.jsx(wd,{totalRows:(l==null?void 0:l.totalRows)||((We=o.uploadedData)==null?void 0:We.length)||0,visibleRows:(l==null?void 0:l.searchedRows)||i.length,visibleColumnsCount:((le=c==null?void 0:c.columnEngine)==null?void 0:le.visibleColumns.length)||o.schema.length,totalColumnsCount:o.schema.length,hasGrouping:(l==null?void 0:l.isGrouped)||!1,onExport:ge,onClose:()=>{nt(!1)}})}),o&&e.jsx($d,{open:wr,onClose:()=>Be(!1),reportId:o.id,reportName:o.name,onRunNow:ce=>{const Se=ce.scope==="all"?o.uploadedData||[]:i||[],Fe=Qr(Se,o.schema||[],o.filters||[],o.sortStack||[],d,o.columnVisibility,o.columnOrder);ce.format==="csv"&&Zr(Fe,ce.name),ce.format==="excel"&&eo(Fe,ce.name),ce.format==="json"&&to(Fe,ce.name),$t(`"${ce.name}" exported successfully`,"success")}}),e.jsx(Dd,{open:rr,onClose:()=>D(!1),config:ht,onApply:kr})]})}function Ii({open:t,message:o,severity:n,onClose:i}){return e.jsx(r.Snackbar,{open:t,autoHideDuration:2e3,onClose:(a,l)=>{l!=="escapeKeyDown"&&i()},anchorOrigin:{vertical:"top",horizontal:"right"},children:e.jsx(r.Alert,{severity:n,variant:"filled",sx:{width:"100%",boxShadow:3},children:o})})}function Ei({hasExternalData:t=!1}){const o=io(),{reports:n,activeReportId:i,activeReport:a,uploadState:l,schema:c,hasSchemaConflicts:d,isModalOpen:u,setIsModalOpen:f,setActiveReportId:h,createReport:m,handleFileUpload:v,handleUploadError:w,handleRetry:z,handleConfirm:y,snack:j,handleSnackClose:b}=o,g=t&&l==="uploading"&&n.length===0;return e.jsxs(r.Box,{sx:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsx(ma,{onCreateReport:()=>f(!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:g?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(vi,{title:"No reports yet",description:"Create your first report to start analyzing your data."}):a?e.jsx(e.Fragment,{children:a.schemaLocked&&a.schema&&a.uploadedData&&a.views?e.jsx(zi,{reportEngine:o}):e.jsx(r.Box,{sx:{p:3},children:l==="preview"&&a.schema&&a.uploadedData?e.jsx(Ic,{schema:a.schema,onConfirm:y,hasConflicts:d}):a.uploadError?e.jsx(Ec,{error:a.uploadError,onRetry:z}):e.jsx(zc,{onFileUpload:v,onError:w,isUploading:l==="uploading"})})}):null}),!t&&e.jsx(Tc,{isOpen:u,onClose:()=>f(!1),onCreate:m}),e.jsx(Ii,{open:j.open,message:j.message,severity:j.severity,onClose:b})]})}function Ld({data:t,dataSource:o,reportName:n,autoLoad:i=!0,config:a}={}){return e.jsx(No,{mode:"builder",data:t,dataSource:o,reportName:n,autoLoad:i,config:a,children:e.jsx(Ei,{hasExternalData:!!(t||o)})})}function Di(){const t=io(),{snack:o,handleSnackClose:n}=t;return e.jsxs(r.Box,{sx:{minHeight:"100vh"},children:[e.jsx(r.Box,{component:"main",children:t.activeReport?e.jsx(zi,{reportEngine:t}):e.jsx(vi,{title:"No report data",description:"This viewer requires report data to be loaded."})}),e.jsx(Ii,{open:o.open,message:o.message,severity:o.severity,onClose:n})]})}function Vd({data:t,autoLoad:o=!0,config:n}){return e.jsx(No,{data:t,mode:"viewer",autoLoad:o,config:n,children:e.jsx(Di,{})})}exports.URMBuilder=Ld;exports.URMBuilderRaw=Ei;exports.URMProvider=No;exports.URMViewer=Vd;exports.URMViewerRaw=Di;exports.useURMContext=io;
95
+ The file has been downloaded to your device.`);window.open(`mailto:${g.email}?subject=${x}&body=${N}`,"_blank")}($=(B=b.current).onFired)==null||$.call(B,g)}catch(Y){Ut.error("urm:scheduler",`Export failed for schedule: ${g.name}`,Y)}},[]);p.useEffect(()=>{if(!t)return;const g=()=>{const{reportId:y}=b.current;if(!y)return;const w=qi(y),v=new Date;let j=!1;const S=w.map(I=>{if(!I.isActive)return I;if(new Date(I.nextRunAt)<=v){f(I);const A=lo(I.frequency,I.time,I.dayOfWeek,I.dayOfMonth,v);return j=!0,{...I,lastRunAt:v.toISOString(),nextRunAt:A,runCount:I.runCount+1}}return I});j&&Ji(y,S)};g();const T=setInterval(g,_u);return()=>clearInterval(T)},[t,f])}function Xi({reportEngine:t}){var lr,Lt,Ft,M,Z;const{activeReport:o,paginatedData:n,processedData:i,displayData:s,tableMetrics:c,tableEngine:d,activeView:l,isDirty:u,currentTableState:m,viewChanges:h,showFilterPanel:b,setShowFilterPanel:f,filterFocusColumn:g,handleAddFilter:T,handleUpdateFilter:y,handleRemoveFilter:w,handleClearAllFilters:v,handleReplaceFilters:j,handleOpenFilterForColumn:S,handleCloseFilterPanel:I,handleClearFiltersForColumn:a,showSortPanel:A,setShowSortPanel:B,handleSort:$,handleUpdateSortStack:Y,handleSortAscending:Q,handleSortDescending:te,showManageViews:x,setShowManageViews:N,showCreateViewModal:W,setShowCreateViewModal:H,showEditViewModal:J,setShowEditViewModal:ue,showDeleteConfirmation:pe,setShowDeleteConfirmation:re,editingView:O,deletingView:F,handleSelectView:G,handleCreateView:se,handleUpdateCurrentView:ee,handleSaveColumnConfigToCurrentView:le,handleSaveColumnConfigToAllViews:ae,handleSaveAsNewView:P,handleRevertChanges:ne,handleToggleDefault:ce,handleToggleFavorite:ie,handleSoftDelete:he,handleRestoreView:q,handlePermanentDelete:Ae,handleEditView:We,handleSaveEditView:tt,handleConfirmDelete:Kt,handlePromoteToGlobal:hr,showManageColumns:At,setShowManageColumns:it,handleUpdateColumnVisibility:Re,handleUpdateColumnOrder:Ee,handleUpdateColumnWidth:gt,handleResetColumnLayout:st,showGroupPanel:rt,setShowGroupPanel:Je,handleGroup:It,handleToggleGroupCollapse:Xt,searchQuery:at,searchHistory:Ke,handleSearchChange:Pe,handleAddToSearchHistory:Zt,handleToggleSearchFavourite:yt,handleDeleteSearchHistory:zt,selectedRowIds:Qt,handleToggleRowSelection:lt,handleToggleAllRows:gr,handleRangeSelection:yr,handleClearSelection:br,handleUpdateSelectionAfterDelete:Mt,currentPage:vr,pageSize:Sr,paginationEngine:Xe,handlePageChange:ve,handlePageSizeChange:jr,isExporting:er,showExportModal:ot,setShowExportModal:L,showDirtyExportWarning:Ne,handleExport:Se,handleExportWithConfig:_e,handleExportSelected:Cr,handleExportAnyway:_t,handleSaveAndExport:bt,handleCancelExport:$t,showAuditHistory:Wt,setShowAuditHistory:Et,showCreatePreset:wr,setShowCreatePreset:Rt,showManagePresets:De,setShowManagePresets:X,generatedPreset:vt,activePreset:ge,handleOpenManagePresets:je,handleCreatePreset:Ze,handleCopyPresetLink:kr,handleOpenPreset:St,handleClearActivePreset:$e,handleOpenPresetById:tr,handleCopyPresetLinkById:Tr,handleDeletePresetById:rr,isViewerRole:or,userRole:Ir,featureLimitWarning:nr,setFeatureLimitWarning:ir,reportError:Le,setReportError:ct,handleError:dt,updateReport:Fe,showSnack:sr,favoriteRowIndices:Pt,resolvedFavoritesSet:zr,showFavoritesOnly:Er,handleToggleRowFavorite:Br,handleBulkSetFavorites:Dr,handleToggleFavoritesFilter:Or}=t,[Ar,Nt]=p.useState(!1);$u({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)||((lr=l==null?void 0:l.snapshot)==null?void 0:lr.columnVisibility)||{},columnOrder:(o==null?void 0:o.columnOrder)||((Lt=l==null?void 0:l.snapshot)==null?void 0:Lt.columnOrder)||[],filters:(o==null?void 0:o.filters)||[],sortStack:(o==null?void 0:o.sortStack)||[],onFired:K=>{sr(`Scheduled export "${K.name}" completed`,"success")}});const Mr=p.useCallback((K,de)=>{if(!(o!=null&&o.uploadedData))return;const oe=[...o.uploadedData];oe[K]=de,Fe(o.id,{uploadedData:oe})},[o,Fe]),_r=p.useCallback(K=>{if(!(o!=null&&o.uploadedData))return;const de=o.uploadedData.indexOf(K);if(de===-1)return;const oe=o.uploadedData.filter((nt,Xr)=>Xr!==de),He=(o.favoriteRowIndices||[]).filter(nt=>nt!==de).map(nt=>nt>de?nt-1:nt);Fe(o.id,{uploadedData:oe,favoriteRowIndices:He}),Mt(K)},[o,Fe,Mt]),Me=p.useCallback((K,de)=>{if(!(o!=null&&o.uploadedData))return;const oe=o.uploadedData.indexOf(de),He=oe!==-1?oe+1:K+1,nt=[...o.uploadedData];nt.splice(He,0,{...de});const Oo=(o.favoriteRowIndices??[]).map($r=>$r>=He?$r+1:$r);Fe(o.id,{uploadedData:nt,favoriteRowIndices:Oo})},[o,Fe]),Ve=Gt(),{handleDevConfigChange:ar}=go(),[Kr,ut]=p.useState(!1);return p.useEffect(()=>{const K=de=>{de.ctrlKey&&de.shiftKey&&de.key==="D"&&(de.preventDefault(),ut(!0))};return document.addEventListener("keydown",K),()=>document.removeEventListener("keydown",K)},[]),!o||!o.schemaLocked||!o.schema||!o.uploadedData||!o.views?null:e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,overflow:"hidden",position:"relative"},children:[!or&&u&&l&&e.jsx(tu,{viewName:l.name,isDefaultView:l.isDefault,changes:h,onSaveToCurrentView:l.isDefault?void 0:ee,onSaveAsNewView:P,onCancel:ne}),e.jsxs(r.Box,{id:"table-content-area",sx:{flex:1,minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column",position:"relative"},children:[nr&&e.jsx(yu,{warning:nr,onDismiss:()=>ir(null)}),Le&&e.jsx(bu,{error:Le,onDismiss:()=>ct(null)}),Ne&&e.jsx(ru,{onExportAnyway:_t,onSaveAndExport:bt,onCancel:$t}),e.jsx(Hd,{schema:o.schema,data:n,sortStack:o.sortStack,filters:o.filters,views:o.views,activeViewId:o.activeViewId,isDirty:u,isExporting:er,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:$,onSortAscending:Q,onSortDescending:te,onOpenFilters:()=>f(!0),onOpenSort:()=>B(!0),onOpenFilterForColumn:S,onSelectView:G,onCreateView:()=>H(!0),onManageViews:()=>N(!0),onUpdateCurrentView:ee,onSaveAsNewView:P,onToggleDefault:ce,onToggleFavorite:ie,onRestoreView:q,onPermanentDelete:Ae,onExport:Se,onOpenColumns:()=>it(!0),onUpdateColumnWidth:gt,onUpdateColumnOrder:Ee,onUpdateColumnVisibility:Re,onClearFiltersForColumn:a,onResetLayout:st,onOpenGroup:()=>Je(!0),onToggleGroupCollapse:Xt,onOpenAuditHistory:()=>Et(!0),onOpenScheduledReports:()=>Nt(!0),searchQuery:at,searchHistory:Ke,onAddToSearchHistory:Zt,onToggleSearchFavourite:yt,onDeleteSearchHistory:zt,selectedRowIds:Qt,onSearchChange:Pe,onToggleRowSelection:lt,onToggleAllRows:gr,onRangeSelection:yr,onClearSelection:br,onExportSelected:Cr,currentPage:(Xe==null?void 0:Xe.currentPage)||vr,pageSize:(Xe==null?void 0:Xe.pageSize)||Sr,onPageChange:ve,onPageSizeChange:jr,totalRowsBeforePagination:(c==null?void 0:c.searchedRows)||i.length,isReadOnly:or,userRole:Ir,reportName:o.name,onEditRow:Mr,onDeleteRow:_r,onDuplicateRow:Me,favoriteRowIndices:Pt,resolvedFavoritesSet:zr,showFavoritesOnly:Er,onToggleRowFavorite:Br,onBulkSetFavorites:Dr,onToggleFavoritesFilter:Or,showDevPanel:Ve.display.showDevPanel,onOpenDevConfig:()=>ut(!0)})]}),b&&e.jsx(Nr,{feature:"Filters",onError:K=>{const de=Ct("ui","filters",K);dt(de)},children:e.jsx(Ud,{schema:o.schema,filters:o.filters??[],onAddFilter:T,onUpdateFilter:y,onRemoveFilter:w,onClearAll:v,onReplaceFilters:j,onClose:I,focusColumn:g})}),A&&e.jsx(Nr,{feature:"Sorting",onError:K=>{const de=Ct("ui","sorting",K);dt(de)},children:e.jsx(Gd,{schema:o.schema,sortStack:o.sortStack??[],onUpdateSortStack:Y,onClose:()=>B(!1)})}),x&&e.jsx(Nr,{feature:"Views",onError:K=>{const de=Ct("ui","views",K);dt(de)},children:e.jsx(qd,{views:o.views,activeViewId:o.activeViewId??"",onSelectView:G,onCreateView:()=>{N(!1),H(!0)},onEditView:We,onDeleteView:he,onRestoreView:q,onPermanentDelete:Ae,onPromoteToGlobal:hr,isAdmin:((Ft=Ve.views)==null?void 0:Ft.isAdmin)??!1,onClose:()=>N(!1)})}),W&&m&&(()=>{var oe;const K=(o.views??[]).filter(He=>!He.isDeleted).length,de=((oe=Ve.views)==null?void 0:oe.maxViews)??10;return e.jsx(si,{currentSnapshot:m,onSave:se,onClose:()=>H(!1),atViewLimit:K>=de,maxViews:de})})(),J&&O&&e.jsx(si,{currentSnapshot:O.snapshot,onSave:tt,onClose:()=>{ue(!1)},isEditMode:!0,initialName:O.name,initialDescription:O.description,initialIsDefault:O.isDefault}),pe&&F&&e.jsx(Jd,{viewName:F.name,onConfirm:Kt,onCancel:()=>{re(!1)}}),At&&l&&e.jsx(Xd,{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:Re,onUpdateColumnOrder:Ee,onUpdateColumnWidth:gt,onResetLayout:st,onSelectView:K=>{G(K)},onSaveToCurrentView:K=>{le(K),it(!1)},onSaveToAllViews:K=>{ae(K),it(!1)},onClose:()=>it(!1)}),rt&&e.jsx(Nr,{feature:"Grouping",onError:K=>{const de=Ct("ui","grouping",K);dt(de)},children:e.jsx(Zd,{schema:o.schema,grouping:o.grouping||null,onApply:It,onClose:()=>Je(!1)})}),Wt&&e.jsx(iu,{auditHistory:o.auditHistory||[],onClose:()=>Et(!1)}),wr&&e.jsx(su,{onSave:Ze,onClose:()=>Rt(!1)}),De&&e.jsx(lu,{presets:o.presets||[],reportId:o.id,onOpenPreset:tr,onCopyLink:Tr,onDeletePreset:rr,onClose:()=>X(!1)}),ge&&e.jsx(r.Box,{sx:{mt:2},children:e.jsx(au,{presetName:ge.name,onClear:$e})}),ot&&e.jsx(Nr,{feature:"Export",onError:K=>{const de=Ct("ui","export",K);dt(de)},children:e.jsx(gu,{totalRows:(c==null?void 0:c.totalRows)||((M=o.uploadedData)==null?void 0:M.length)||0,visibleRows:(c==null?void 0:c.searchedRows)||i.length,visibleColumnsCount:((Z=d==null?void 0:d.columnEngine)==null?void 0:Z.visibleColumns.length)||o.schema.length,totalColumnsCount:o.schema.length,hasGrouping:(c==null?void 0:c.isGrouped)||!1,onExport:_e,onClose:()=>{L(!1)}})}),o&&e.jsx(Mu,{open:Ar,onClose:()=>Nt(!1),reportId:o.id,reportName:o.name,onRunNow:K=>{const de=K.scope==="all"?o.uploadedData||[]:i||[],oe=co(de,o.schema||[],o.filters||[],o.sortStack||[],l,o.columnVisibility,o.columnOrder);K.format==="csv"&&uo(oe,K.name),K.format==="excel"&&po(oe,K.name),K.format==="json"&&xo(oe,K.name),sr(`"${K.name}" exported successfully`,"success")}}),e.jsx(Cu,{open:Kr,onClose:()=>ut(!1),config:Ve,onApply:ar})]})}function Zi({open:t,message:o,severity:n,onClose:i}){return e.jsx(r.Snackbar,{open:t,autoHideDuration:2e3,onClose:(s,c)=>{c!=="escapeKeyDown"&&i()},anchorOrigin:{vertical:"top",horizontal:"right"},children:e.jsx(r.Alert,{severity:n,variant:"filled",sx:{width:"100%",boxShadow:3},children:o})})}function Qi({hasExternalData:t=!1}){const o=go(),{reports:n,activeReportId:i,activeReport:s,uploadState:c,schema:d,hasSchemaConflicts:l,isModalOpen:u,setIsModalOpen:m,setActiveReportId:h,createReport:b,handleFileUpload:f,handleUploadError:g,handleRetry:T,handleConfirm:y,snack:w,handleSnackClose:v}=o,j=t&&c==="uploading"&&n.length===0;return e.jsxs(r.Box,{sx:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsx(el,{onCreateReport:()=>m(!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:j?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(Vi,{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(Xi,{reportEngine:o}):e.jsx(r.Box,{sx:{p:3},children:c==="preview"&&s.schema&&s.uploadedData?e.jsx(ud,{schema:s.schema,onConfirm:y,hasConflicts:l}):s.uploadError?e.jsx(pd,{error:s.uploadError,onRetry:T}):e.jsx(dd,{onFileUpload:f,onError:g,isUploading:c==="uploading"})})}):null}),!t&&e.jsx(cd,{isOpen:u,onClose:()=>m(!1),onCreate:b}),e.jsx(Zi,{open:w.open,message:w.message,severity:w.severity,onClose:v})]})}function Wu({data:t,dataSource:o,reportName:n,autoLoad:i=!0,config:s}={}){return e.jsx(en,{mode:"builder",data:t,dataSource:o,reportName:n,autoLoad:i,config:s,children:e.jsx(Qi,{hasExternalData:!!(t||o)})})}function es(){const t=go(),{snack:o,handleSnackClose:n}=t;return e.jsxs(r.Box,{sx:{minHeight:"100vh"},children:[e.jsx(r.Box,{component:"main",children:t.activeReport?e.jsx(Xi,{reportEngine:t}):e.jsx(Vi,{title:"No report data",description:"This viewer requires report data to be loaded."})}),e.jsx(Zi,{open:o.open,message:o.message,severity:o.severity,onClose:n})]})}function Ru({data:t,autoLoad:o=!0,config:n}){return e.jsx(en,{data:t,mode:"viewer",autoLoad:o,config:n,children:e.jsx(es,{})})}exports.URMBuilder=Wu;exports.URMBuilderRaw=Qi;exports.URMProvider=en;exports.URMViewer=Ru;exports.URMViewerRaw=es;exports.useURMContext=go;